Branch data 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 "fuexpand.hxx"
21 : :
22 : : #include <sfx2/viewfrm.hxx>
23 : : #include <svx/svdotext.hxx>
24 : : #include <svx/xlineit0.hxx>
25 : : #include <svx/svdundo.hxx>
26 : : #include <sfx2/printer.hxx>
27 : : #include <editeng/outlobj.hxx>
28 : : #include <svx/svdetc.hxx>
29 : :
30 : : #include "app.hrc"
31 : : #include "strings.hrc"
32 : : #include "pres.hxx"
33 : : #include "View.hxx"
34 : : #include "sdpage.hxx"
35 : : #include "Outliner.hxx"
36 : : #include "drawview.hxx"
37 : : #include "drawdoc.hxx"
38 : : #include "ViewShell.hxx"
39 : : #include "DrawDocShell.hxx"
40 : : #include "sdresid.hxx"
41 : : #include "optsitem.hxx"
42 : : #include "sdmod.hxx"
43 : : #include <sfx2/dispatch.hxx>
44 : : #include <editeng/eeitem.hxx>
45 : :
46 : : namespace sd {
47 : :
48 [ # # ][ # # ]: 0 : TYPEINIT1( FuExpandPage, FuPoor );
49 : :
50 : : /*************************************************************************
51 : : |*
52 : : |* Konstruktor
53 : : |*
54 : : \************************************************************************/
55 : :
56 : 0 : FuExpandPage::FuExpandPage (
57 : : ViewShell* pViewSh,
58 : : ::sd::Window* pWin,
59 : : ::sd::View* pView,
60 : : SdDrawDocument* pDoc,
61 : : SfxRequest& rReq)
62 : 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
63 : : {
64 : 0 : }
65 : :
66 : 0 : FunctionReference FuExpandPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
67 : : {
68 [ # # ][ # # ]: 0 : FunctionReference xFunc( new FuExpandPage( pViewSh, pWin, pView, pDoc, rReq ) );
69 [ # # ]: 0 : xFunc->DoExecute(rReq);
70 : 0 : return xFunc;
71 : : }
72 : :
73 : 0 : void FuExpandPage::DoExecute( SfxRequest& )
74 : : {
75 [ # # ][ # # ]: 0 : if ( mpView && mpView->IsTextEdit() )
[ # # ]
76 : 0 : mpView->SdrEndTextEdit();
77 : :
78 : : // Selektierte Seite finden (nur Standard-Seiten)
79 : 0 : SdPage* pActualPage = NULL;
80 : 0 : sal_uInt16 i = 0;
81 : 0 : sal_uInt16 nCount = mpDoc->GetSdPageCount(PK_STANDARD);
82 : :
83 [ # # ][ # # ]: 0 : while (!pActualPage && i < nCount)
[ # # ]
84 : : {
85 [ # # ]: 0 : if (mpDoc->GetSdPage(i, PK_STANDARD)->IsSelected())
86 : : {
87 : 0 : pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
88 : : }
89 : :
90 : 0 : i++;
91 : : }
92 : :
93 [ # # ]: 0 : if (pActualPage)
94 : : {
95 : : ::sd::Outliner* pOutl =
96 [ # # ][ # # ]: 0 : new ::sd::Outliner( mpDoc, OUTLINERMODE_OUTLINEOBJECT );
97 [ # # ]: 0 : pOutl->SetUpdateMode(sal_False);
98 [ # # ]: 0 : pOutl->EnableUndo(sal_False);
99 : :
100 [ # # ]: 0 : if (mpDocSh)
101 [ # # ][ # # ]: 0 : pOutl->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
[ # # ]
102 : :
103 [ # # ]: 0 : pOutl->SetDefTab( mpDoc->GetDefaultTabulator() );
104 [ # # ][ # # ]: 0 : pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
105 : :
106 [ # # ]: 0 : SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
107 [ # # ]: 0 : sal_uInt16 nActualPageNum = pActualPage->GetPageNum();
108 [ # # ]: 0 : SdPage* pActualNotesPage = (SdPage*) mpDoc->GetPage(nActualPageNum + 1);
109 [ # # ]: 0 : SdrTextObj* pActualOutline = (SdrTextObj*) pActualPage->GetPresObj(PRESOBJ_OUTLINE);
110 : :
111 [ # # ]: 0 : if (pActualOutline)
112 : : {
113 [ # # ]: 0 : const bool bUndo = mpView->IsUndoEnabled();
114 : :
115 [ # # ]: 0 : if( bUndo )
116 [ # # ][ # # ]: 0 : mpView->BegUndo(String(SdResId(STR_UNDO_EXPAND_PAGE)));
[ # # ][ # # ]
117 : :
118 : : // Aktuelles Gliederungsobjekt in Outliner setzen
119 [ # # ]: 0 : OutlinerParaObject* pParaObj = pActualOutline->GetOutlinerParaObject();
120 [ # # ]: 0 : pOutl->SetText(*pParaObj);
121 : :
122 : : // Harte Absatz- und Zeichenattribute entfernen
123 [ # # ]: 0 : SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), EE_ITEMS_START, EE_ITEMS_END);
124 [ # # ]: 0 : sal_uLong nParaCount1 = pOutl->GetParagraphCount();
125 : :
126 [ # # ]: 0 : for (sal_uInt16 nPara = 0; nPara < nParaCount1; nPara++)
127 : : {
128 [ # # ]: 0 : pOutl->QuickRemoveCharAttribs(nPara);
129 [ # # ]: 0 : pOutl->SetParaAttribs(nPara, aEmptyEEAttr);
130 : : }
131 : :
132 : 0 : sal_uInt16 nPos = 2;
133 [ # # ]: 0 : Paragraph* pPara = pOutl->GetParagraph( 0 );
134 : :
135 [ # # ]: 0 : while (pPara)
136 : : {
137 [ # # ]: 0 : sal_uLong nParaPos = pOutl->GetAbsPos( pPara );
138 [ # # ]: 0 : sal_Int16 nDepth = pOutl->GetDepth( (sal_uInt16) nParaPos );
139 [ # # ]: 0 : if ( nDepth == 0 )
140 : : {
141 : : // Seite mit Titel & Gliederung!
142 [ # # ]: 0 : SdPage* pPage = (SdPage*) mpDoc->AllocPage(sal_False);
143 [ # # ][ # # ]: 0 : pPage->SetSize(pActualPage->GetSize() );
144 : 0 : pPage->SetBorder(pActualPage->GetLftBorder(),
145 : 0 : pActualPage->GetUppBorder(),
146 : 0 : pActualPage->GetRgtBorder(),
147 [ # # ][ # # ]: 0 : pActualPage->GetLwrBorder() );
[ # # ][ # # ]
[ # # ]
148 [ # # ][ # # ]: 0 : pPage->SetName(String());
[ # # ]
149 : :
150 : : // Seite hinter aktueller Seite einfuegen
151 [ # # ]: 0 : mpDoc->InsertPage(pPage, nActualPageNum + nPos);
152 : 0 : nPos++;
153 : :
154 [ # # ]: 0 : if( bUndo )
155 [ # # ][ # # ]: 0 : mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage));
[ # # ]
156 : :
157 : : // MasterPage der aktuellen Seite verwenden
158 [ # # ][ # # ]: 0 : pPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
159 [ # # ][ # # ]: 0 : pPage->SetLayoutName(pActualPage->GetLayoutName());
[ # # ]
160 [ # # ]: 0 : pPage->SetAutoLayout(AUTOLAYOUT_ENUM, sal_True);
161 [ # # ]: 0 : pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
162 : :
163 : : // Notiz-Seite
164 [ # # ]: 0 : SdPage* pNotesPage = (SdPage*) mpDoc->AllocPage(sal_False);
165 [ # # ][ # # ]: 0 : pNotesPage->SetSize(pActualNotesPage->GetSize());
166 : 0 : pNotesPage->SetBorder(pActualNotesPage->GetLftBorder(),
167 : 0 : pActualNotesPage->GetUppBorder(),
168 : 0 : pActualNotesPage->GetRgtBorder(),
169 [ # # ][ # # ]: 0 : pActualNotesPage->GetLwrBorder() );
[ # # ][ # # ]
[ # # ]
170 : 0 : pNotesPage->SetPageKind(PK_NOTES);
171 [ # # ][ # # ]: 0 : pNotesPage->SetName(String());
[ # # ]
172 : :
173 : : // Seite hinter aktueller Seite einfuegen
174 [ # # ]: 0 : mpDoc->InsertPage(pNotesPage, nActualPageNum + nPos);
175 : 0 : nPos++;
176 : :
177 [ # # ]: 0 : if( bUndo )
178 [ # # ][ # # ]: 0 : mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
[ # # ]
179 : :
180 : : // MasterPage der aktuellen Seite verwenden
181 [ # # ][ # # ]: 0 : pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
182 [ # # ][ # # ]: 0 : pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName());
[ # # ]
183 [ # # ]: 0 : pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), sal_True);
184 [ # # ]: 0 : pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
185 : :
186 : : // Title-Textobjekt erstellen
187 [ # # ]: 0 : SdrTextObj* pTextObj = (SdrTextObj*) pPage->GetPresObj(PRESOBJ_TITLE);
188 : :
189 [ # # ]: 0 : OutlinerParaObject* pOutlinerParaObject = pOutl->CreateParaObject( (sal_uInt16) nParaPos, 1);
190 [ # # ]: 0 : pOutlinerParaObject->SetOutlinerMode(OUTLINERMODE_TITLEOBJECT);
191 : :
192 [ # # ][ # # ]: 0 : if( pOutlinerParaObject->GetDepth(0) != -1 )
193 : : {
194 [ # # ]: 0 : SdrOutliner* pTempOutl = SdrMakeOutliner( OUTLINERMODE_TITLEOBJECT, mpDoc );
195 : :
196 [ # # ]: 0 : pTempOutl->SetText( *pOutlinerParaObject );
197 : :
198 [ # # ][ # # ]: 0 : delete pOutlinerParaObject;
199 : :
200 [ # # ][ # # ]: 0 : pTempOutl->SetDepth( pTempOutl->GetParagraph( 0 ), -1 );
201 : :
202 [ # # ]: 0 : pOutlinerParaObject = pTempOutl->CreateParaObject();
203 [ # # ][ # # ]: 0 : delete pTempOutl;
204 : : }
205 : :
206 [ # # ]: 0 : pTextObj->SetOutlinerParaObject(pOutlinerParaObject);
207 : :
208 [ # # ]: 0 : pTextObj->SetEmptyPresObj(sal_False);
209 : :
210 [ # # ]: 0 : SfxStyleSheet* pSheet = pPage->GetStyleSheetForPresObj(PRESOBJ_TITLE);
211 [ # # ]: 0 : pTextObj->NbcSetStyleSheet(pSheet, sal_False);
212 : :
213 [ # # ]: 0 : sal_uLong nChildCount = pOutl->GetChildCount(pPara);
214 : :
215 [ # # ]: 0 : if (nChildCount > 0)
216 : : {
217 : : // Gliederungs-Textobjekt erstellen
218 [ # # ]: 0 : SdrTextObj* pOutlineObj = (SdrTextObj*) pPage->GetPresObj(PRESOBJ_OUTLINE);
219 [ # # ]: 0 : pPara = pOutl->GetParagraph( ++nParaPos );
220 : :
221 [ # # ]: 0 : OutlinerParaObject* pOPO = pOutl->CreateParaObject( (sal_uInt16) nParaPos, (sal_uInt16) nChildCount);
222 : :
223 [ # # ]: 0 : SdrOutliner* pTempOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, mpDoc );
224 [ # # ]: 0 : pTempOutl->SetText( *pOPO );
225 : :
226 [ # # ]: 0 : sal_uLong nParaCount2 = pTempOutl->GetParagraphCount();
227 : : sal_uLong nPara;
228 [ # # ]: 0 : for( nPara = 0; nPara < nParaCount2; nPara++ )
229 : : {
230 : : pTempOutl->SetDepth (
231 : : pTempOutl->GetParagraph( nPara ),
232 [ # # ][ # # ]: 0 : pTempOutl->GetDepth((sal_uInt16) nPara ) - 1);
[ # # ]
233 : : }
234 : :
235 [ # # ][ # # ]: 0 : delete pOPO;
236 [ # # ]: 0 : pOPO = pTempOutl->CreateParaObject();
237 [ # # ][ # # ]: 0 : delete pTempOutl;
238 : :
239 [ # # ]: 0 : pOutlineObj->SetOutlinerParaObject( pOPO );
240 [ # # ]: 0 : pOutlineObj->SetEmptyPresObj(sal_False);
241 : :
242 : : // Harte Attribute entfernen (Flag auf sal_True)
243 [ # # ]: 0 : SfxItemSet aAttr(mpDoc->GetPool());
244 [ # # ][ # # ]: 0 : aAttr.Put(XLineStyleItem(XLINE_NONE));
[ # # ]
245 [ # # ][ # # ]: 0 : aAttr.Put(XFillStyleItem(XFILL_NONE));
[ # # ]
246 [ # # ][ # # ]: 0 : pOutlineObj->SetMergedItemSet(aAttr);
247 : : }
248 : : }
249 : :
250 [ # # ]: 0 : pPara = pOutl->GetParagraph( ++nParaPos );
251 : : }
252 : :
253 [ # # ]: 0 : if( bUndo )
254 [ # # ][ # # ]: 0 : mpView->EndUndo();
255 : : }
256 : :
257 [ # # ][ # # ]: 0 : delete pOutl;
258 : :
259 [ # # ][ # # ]: 0 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
260 : : }
261 : 0 : }
262 : :
263 : : } // end of namespace sd
264 : :
265 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|