/src/libreoffice/sd/source/ui/func/fusumry.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #include <fusumry.hxx> |
21 | | #include <editeng/eeitem.hxx> |
22 | | #include <svx/svdotext.hxx> |
23 | | #include <svx/svdundo.hxx> |
24 | | #include <svx/xfillit0.hxx> |
25 | | #include <svx/xlineit0.hxx> |
26 | | #include <editeng/outlobj.hxx> |
27 | | #include <xmloff/autolayout.hxx> |
28 | | |
29 | | #include <strings.hrc> |
30 | | |
31 | | #include <pres.hxx> |
32 | | #include <View.hxx> |
33 | | #include <sdpage.hxx> |
34 | | #include <Outliner.hxx> |
35 | | #include <drawdoc.hxx> |
36 | | #include <ViewShell.hxx> |
37 | | #include <sdmod.hxx> |
38 | | #include <sdresid.hxx> |
39 | | #include <DrawViewShell.hxx> |
40 | | |
41 | | using namespace com::sun::star; |
42 | | |
43 | | namespace sd { |
44 | | |
45 | | |
46 | | FuSummaryPage::FuSummaryPage ( |
47 | | ViewShell& rViewSh, |
48 | | ::sd::Window* pWin, |
49 | | ::sd::View* pView, |
50 | | SdDrawDocument& rDoc, |
51 | | SfxRequest& rReq) |
52 | 0 | : FuPoor(rViewSh, pWin, pView, rDoc, rReq) |
53 | 0 | { |
54 | 0 | } |
55 | | |
56 | | rtl::Reference<FuPoor> FuSummaryPage::Create( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq ) |
57 | 0 | { |
58 | 0 | rtl::Reference<FuPoor> xFunc( new FuSummaryPage( rViewSh, pWin, pView, rDoc, rReq ) ); |
59 | 0 | xFunc->DoExecute(rReq); |
60 | 0 | return xFunc; |
61 | 0 | } |
62 | | |
63 | | void FuSummaryPage::DoExecute( SfxRequest& ) |
64 | 0 | { |
65 | 0 | std::unique_ptr<SdOutliner> pOutl; |
66 | 0 | rtl::Reference<SdPage> pSummaryPage; |
67 | 0 | sal_uInt16 i = 0; |
68 | 0 | sal_uInt16 nFirstPage = SDRPAGE_NOTFOUND; |
69 | 0 | sal_uInt16 nSelectedPages = 0; |
70 | 0 | sal_uInt16 nCount = mrDoc.GetSdPageCount(PageKind::Standard); |
71 | |
|
72 | 0 | while (i < nCount && nSelectedPages <= 1) |
73 | 0 | { |
74 | | /* How many pages are selected? |
75 | | exactly one: pool everything from this page |
76 | | otherwise: only pool the selected pages */ |
77 | 0 | SdPage* pActualPage = mrDoc.GetSdPage(i, PageKind::Standard); |
78 | |
|
79 | 0 | if (pActualPage->IsSelected()) |
80 | 0 | { |
81 | 0 | if (nFirstPage == SDRPAGE_NOTFOUND) |
82 | 0 | { |
83 | 0 | nFirstPage = i; |
84 | 0 | } |
85 | |
|
86 | 0 | nSelectedPages++; |
87 | 0 | } |
88 | |
|
89 | 0 | i++; |
90 | 0 | } |
91 | |
|
92 | 0 | bool bBegUndo = false; |
93 | |
|
94 | 0 | SfxStyleSheet* pStyle = nullptr; |
95 | |
|
96 | 0 | for (i = nFirstPage; i < nCount; i++) |
97 | 0 | { |
98 | 0 | SdPage* pActualPage = mrDoc.GetSdPage(i, PageKind::Standard); |
99 | |
|
100 | 0 | if (nSelectedPages <= 1 || pActualPage->IsSelected()) |
101 | 0 | { |
102 | 0 | SdPage* pActualNotesPage = mrDoc.GetSdPage(i, PageKind::Notes); |
103 | 0 | SdrTextObj* pTextObj = static_cast<SdrTextObj*>( pActualPage->GetPresObj(PresObjKind::Title) ); |
104 | |
|
105 | 0 | if (pTextObj && !pTextObj->IsEmptyPresObj()) |
106 | 0 | { |
107 | 0 | if (!pSummaryPage) |
108 | 0 | { |
109 | | // insert "table of content"-page and create outliner |
110 | 0 | const bool bUndo = mpView->IsUndoEnabled(); |
111 | |
|
112 | 0 | if( bUndo ) |
113 | 0 | { |
114 | 0 | mpView->BegUndo(SdResId(STR_UNDO_SUMMARY_PAGE)); |
115 | 0 | bBegUndo = true; |
116 | 0 | } |
117 | |
|
118 | 0 | SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers(); |
119 | | |
120 | | // page with title & structuring! |
121 | 0 | pSummaryPage = mrDoc.AllocSdPage(false); |
122 | 0 | pSummaryPage->SetSize(pActualPage->GetSize() ); |
123 | 0 | pSummaryPage->SetBorder(pActualPage->GetLeftBorder(), |
124 | 0 | pActualPage->GetUpperBorder(), |
125 | 0 | pActualPage->GetRightBorder(), |
126 | 0 | pActualPage->GetLowerBorder() ); |
127 | | |
128 | | // insert page at the back |
129 | 0 | mrDoc.InsertPage(pSummaryPage.get(), nCount * 2 + 1); |
130 | 0 | if( bUndo ) |
131 | 0 | mpView->AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage)); |
132 | | |
133 | | // use MasterPage of the current page |
134 | 0 | pSummaryPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage()); |
135 | 0 | pSummaryPage->SetLayoutName(pActualPage->GetLayoutName()); |
136 | 0 | pSummaryPage->SetAutoLayout(AUTOLAYOUT_TITLE_CONTENT, true); |
137 | 0 | pSummaryPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); |
138 | 0 | pSummaryPage->setHeaderFooterSettings(pActualPage->getHeaderFooterSettings()); |
139 | | |
140 | | // notes-page |
141 | 0 | rtl::Reference<SdPage> pNotesPage = mrDoc.AllocSdPage(false); |
142 | 0 | pNotesPage->SetSize(pActualNotesPage->GetSize()); |
143 | 0 | pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(), |
144 | 0 | pActualNotesPage->GetUpperBorder(), |
145 | 0 | pActualNotesPage->GetRightBorder(), |
146 | 0 | pActualNotesPage->GetLowerBorder() ); |
147 | 0 | pNotesPage->SetPageKind(PageKind::Notes); |
148 | | |
149 | | // insert page at the back |
150 | 0 | mrDoc.InsertPage(pNotesPage.get(), nCount * 2 + 2); |
151 | |
|
152 | 0 | if( bUndo ) |
153 | 0 | mpView->AddUndo(mrDoc.GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage)); |
154 | | |
155 | | // use MasterPage of the current page |
156 | 0 | pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage()); |
157 | 0 | pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName()); |
158 | 0 | pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), true); |
159 | 0 | pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); |
160 | 0 | pNotesPage->setHeaderFooterSettings(pActualNotesPage->getHeaderFooterSettings()); |
161 | |
|
162 | 0 | pOutl.reset(new SdOutliner( mrDoc, OutlinerMode::OutlineObject )); |
163 | 0 | pOutl->SetUpdateLayout(false); |
164 | 0 | pOutl->EnableUndo(false); |
165 | |
|
166 | 0 | if (mpDocSh) |
167 | 0 | pOutl->SetRefDevice(SdModule::get()->GetVirtualRefDevice()); |
168 | |
|
169 | 0 | pOutl->SetDefTab( mrDoc.GetDefaultTabulator() ); |
170 | 0 | pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mrDoc.GetStyleSheetPool())); |
171 | 0 | pStyle = pSummaryPage->GetStyleSheetForPresObj( PresObjKind::Outline ); |
172 | 0 | pOutl->SetStyleSheet( 0, pStyle ); |
173 | 0 | } |
174 | | |
175 | | // add text |
176 | 0 | OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject(); |
177 | | // #118876#, check if the OutlinerParaObject is created successfully |
178 | 0 | if( pParaObj ) |
179 | 0 | { |
180 | 0 | pParaObj->SetOutlinerMode( OutlinerMode::OutlineObject ); |
181 | 0 | pOutl->AddText(*pParaObj); |
182 | 0 | } |
183 | 0 | } |
184 | 0 | } |
185 | 0 | } |
186 | |
|
187 | 0 | if (!pSummaryPage) |
188 | 0 | return; |
189 | | |
190 | 0 | SdrTextObj* pTextObj = static_cast<SdrTextObj*>( pSummaryPage->GetPresObj(PresObjKind::Outline) ); |
191 | |
|
192 | 0 | if (!pTextObj) |
193 | 0 | return; |
194 | | |
195 | | // remove hard break- and character attributes |
196 | 0 | SfxItemSet aEmptyEEAttr(SfxItemSet::makeFixedSfxItemSet<EE_ITEMS_START, EE_ITEMS_END>(mrDoc.GetPool())); |
197 | 0 | sal_Int32 nParaCount = pOutl->GetParagraphCount(); |
198 | |
|
199 | 0 | for (sal_Int32 nPara = 0; nPara < nParaCount; nPara++) |
200 | 0 | { |
201 | 0 | pOutl->SetStyleSheet( nPara, pStyle ); |
202 | 0 | pOutl->RemoveCharAttribs(nPara); |
203 | 0 | pOutl->SetParaAttribs(nPara, aEmptyEEAttr); |
204 | 0 | pOutl->SetDepth(pOutl->GetParagraph(nPara), 0); |
205 | 0 | } |
206 | |
|
207 | 0 | pTextObj->SetOutlinerParaObject( pOutl->CreateParaObject() ); |
208 | 0 | pTextObj->SetEmptyPresObj(false); |
209 | | |
210 | | // remove hard attributes (Flag to sal_True) |
211 | 0 | SfxItemSet aAttr(mrDoc.GetPool()); |
212 | 0 | aAttr.Put(XLineStyleItem(drawing::LineStyle_NONE)); |
213 | 0 | aAttr.Put(XFillStyleItem(drawing::FillStyle_NONE)); |
214 | 0 | pTextObj->SetMergedItemSet(aAttr); |
215 | |
|
216 | 0 | if( bBegUndo ) |
217 | 0 | mpView->EndUndo(); |
218 | 0 | pOutl.reset(); |
219 | |
|
220 | 0 | DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( &mrViewShell ); |
221 | 0 | if(pDrawViewShell) |
222 | 0 | { |
223 | 0 | pDrawViewShell->SwitchPage( (pSummaryPage->GetPageNum() - 1) / 2); |
224 | 0 | } |
225 | 0 | } |
226 | | |
227 | | } // end of namespace sd |
228 | | |
229 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |