Line data Source code
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 <sfx2/printer.hxx>
25 : #include <editeng/outlobj.hxx>
26 :
27 : #include "strings.hrc"
28 :
29 : #include "pres.hxx"
30 : #include "View.hxx"
31 : #include "sdpage.hxx"
32 : #include "Outliner.hxx"
33 : #include "drawview.hxx"
34 : #include "drawdoc.hxx"
35 : #include "ViewShell.hxx"
36 : #include "DrawDocShell.hxx"
37 : #include "sdresid.hxx"
38 : #include "optsitem.hxx"
39 : #include "DrawViewShell.hxx"
40 :
41 : using namespace com::sun::star;
42 :
43 : namespace sd {
44 :
45 0 : TYPEINIT1( FuSummaryPage, FuPoor );
46 :
47 0 : FuSummaryPage::FuSummaryPage (
48 : ViewShell* pViewSh,
49 : ::sd::Window* pWin,
50 : ::sd::View* pView,
51 : SdDrawDocument* pDoc,
52 : SfxRequest& rReq)
53 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
54 : {
55 0 : }
56 :
57 0 : rtl::Reference<FuPoor> FuSummaryPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
58 : {
59 0 : rtl::Reference<FuPoor> xFunc( new FuSummaryPage( pViewSh, pWin, pView, pDoc, rReq ) );
60 0 : xFunc->DoExecute(rReq);
61 0 : return xFunc;
62 : }
63 :
64 0 : void FuSummaryPage::DoExecute( SfxRequest& )
65 : {
66 0 : ::sd::Outliner* pOutl = NULL;
67 0 : SdPage* pSummaryPage = NULL;
68 0 : sal_uInt16 i = 0;
69 0 : sal_uInt16 nFirstPage = SDRPAGE_NOTFOUND;
70 0 : sal_uInt16 nSelectedPages = 0;
71 0 : sal_uInt16 nCount = mpDoc->GetSdPageCount(PK_STANDARD);
72 :
73 0 : while (i < nCount && nSelectedPages <= 1)
74 : {
75 : /* How many pages are selected?
76 : exactly one: pool everything from this page
77 : otherwise: only pool the selected pages */
78 0 : SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
79 :
80 0 : if (pActualPage->IsSelected())
81 : {
82 0 : if (nFirstPage == SDRPAGE_NOTFOUND)
83 : {
84 0 : nFirstPage = i;
85 : }
86 :
87 0 : nSelectedPages++;
88 : }
89 :
90 0 : i++;
91 : }
92 :
93 0 : bool bBegUndo = false;
94 :
95 0 : SfxStyleSheet* pStyle = NULL;
96 :
97 0 : for (i = nFirstPage; i < nCount; i++)
98 : {
99 0 : SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
100 :
101 0 : if (nSelectedPages <= 1 || pActualPage->IsSelected())
102 : {
103 0 : SdPage* pActualNotesPage = mpDoc->GetSdPage(i, PK_NOTES);
104 0 : SdrTextObj* pTextObj = static_cast<SdrTextObj*>( pActualPage->GetPresObj(PRESOBJ_TITLE) );
105 :
106 0 : if (pTextObj && !pTextObj->IsEmptyPresObj())
107 : {
108 0 : if (!pSummaryPage)
109 : {
110 : // insert "table of content"-page and create outliner
111 0 : const bool bUndo = mpView->IsUndoEnabled();
112 :
113 0 : if( bUndo )
114 : {
115 0 : mpView->BegUndo(SD_RESSTR(STR_UNDO_SUMMARY_PAGE));
116 0 : bBegUndo = true;
117 : }
118 :
119 0 : SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
120 :
121 : // page with title & structuring!
122 0 : pSummaryPage = mpDoc->AllocSdPage(false);
123 0 : pSummaryPage->SetSize(pActualPage->GetSize() );
124 : pSummaryPage->SetBorder(pActualPage->GetLftBorder(),
125 : pActualPage->GetUppBorder(),
126 : pActualPage->GetRgtBorder(),
127 0 : pActualPage->GetLwrBorder() );
128 :
129 : // insert page at the back
130 0 : mpDoc->InsertPage(pSummaryPage, nCount * 2 + 1);
131 0 : if( bUndo )
132 0 : mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage));
133 :
134 : // use MasterPage of the current page
135 0 : pSummaryPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
136 0 : pSummaryPage->SetLayoutName(pActualPage->GetLayoutName());
137 0 : pSummaryPage->SetAutoLayout(AUTOLAYOUT_ENUM, true);
138 0 : pSummaryPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
139 0 : pSummaryPage->setHeaderFooterSettings(pActualPage->getHeaderFooterSettings());
140 :
141 : // notes-page
142 0 : SdPage* pNotesPage = mpDoc->AllocSdPage(false);
143 0 : pNotesPage->SetSize(pActualNotesPage->GetSize());
144 : pNotesPage->SetBorder(pActualNotesPage->GetLftBorder(),
145 : pActualNotesPage->GetUppBorder(),
146 : pActualNotesPage->GetRgtBorder(),
147 0 : pActualNotesPage->GetLwrBorder() );
148 0 : pNotesPage->SetPageKind(PK_NOTES);
149 :
150 : // insert page at the back
151 0 : mpDoc->InsertPage(pNotesPage, nCount * 2 + 2);
152 :
153 0 : if( bUndo )
154 0 : mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
155 :
156 : // use MasterPage of the current page
157 0 : pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
158 0 : pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName());
159 0 : pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), true);
160 0 : pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
161 0 : pNotesPage->setHeaderFooterSettings(pActualNotesPage->getHeaderFooterSettings());
162 :
163 0 : pOutl = new ::sd::Outliner( mpDoc, OUTLINERMODE_OUTLINEOBJECT );
164 0 : pOutl->SetUpdateMode(false);
165 0 : pOutl->EnableUndo(false);
166 :
167 0 : if (mpDocSh)
168 0 : pOutl->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh ));
169 :
170 0 : pOutl->SetDefTab( mpDoc->GetDefaultTabulator() );
171 0 : pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
172 0 : pStyle = pSummaryPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
173 0 : pOutl->SetStyleSheet( 0, pStyle );
174 : }
175 :
176 : // add text
177 0 : OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
178 : // #118876#, check if the OutlinerParaObject is created successfully
179 0 : if( pParaObj )
180 : {
181 0 : pParaObj->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
182 0 : pOutl->AddText(*pParaObj);
183 : }
184 : }
185 : }
186 : }
187 :
188 0 : if (!pSummaryPage)
189 0 : return;
190 :
191 0 : SdrTextObj* pTextObj = static_cast<SdrTextObj*>( pSummaryPage->GetPresObj(PRESOBJ_OUTLINE) );
192 :
193 0 : if (!pTextObj)
194 0 : return;
195 :
196 : // remove hard break- and character attributes
197 0 : SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), EE_ITEMS_START, EE_ITEMS_END);
198 0 : sal_Int32 nParaCount = pOutl->GetParagraphCount();
199 :
200 0 : for (sal_Int32 nPara = 0; nPara < nParaCount; nPara++)
201 : {
202 0 : pOutl->SetStyleSheet( nPara, pStyle );
203 0 : pOutl->RemoveCharAttribs(nPara);
204 0 : pOutl->SetParaAttribs(nPara, aEmptyEEAttr);
205 0 : pOutl->SetDepth(pOutl->GetParagraph(nPara), 0);
206 : }
207 :
208 0 : pTextObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
209 0 : pTextObj->SetEmptyPresObj(false);
210 :
211 : // remove hard attributes (Flag to sal_True)
212 0 : SfxItemSet aAttr(mpDoc->GetPool());
213 0 : aAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
214 0 : aAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
215 0 : pTextObj->SetMergedItemSet(aAttr);
216 :
217 0 : if( bBegUndo )
218 0 : mpView->EndUndo();
219 0 : delete pOutl;
220 :
221 0 : DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( mpViewShell );
222 0 : if(pDrawViewShell)
223 : {
224 0 : pDrawViewShell->SwitchPage( (pSummaryPage->GetPageNum() - 1) / 2);
225 0 : }
226 : }
227 :
228 66 : } // end of namespace sd
229 :
230 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|