1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuexpand.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include "fuexpand.hxx"
37 #include <sfx2/viewfrm.hxx>
38 #include <svx/svdotext.hxx>
39 #include <svx/xlineit0.hxx>
40 #include <svx/svdundo.hxx>
41 #include <sfx2/printer.hxx>
42 #include <svx/outlobj.hxx>
43 #include <svx/svdetc.hxx>
46 #include "strings.hrc"
50 #include "Outliner.hxx"
51 #include "drawview.hxx"
52 #include "drawdoc.hxx"
53 #include "ViewShell.hxx"
54 #include "DrawDocShell.hxx"
55 #include "sdresid.hxx"
56 #include "optsitem.hxx"
58 #include <sfx2/dispatch.hxx>
59 #include <svx/eeitem.hxx>
63 TYPEINIT1( FuExpandPage
, FuPoor
);
65 /*************************************************************************
69 \************************************************************************/
71 FuExpandPage::FuExpandPage (
77 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
81 FunctionReference
FuExpandPage::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
83 FunctionReference
xFunc( new FuExpandPage( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
84 xFunc
->DoExecute(rReq
);
88 void FuExpandPage::DoExecute( SfxRequest
& )
90 // Selektierte Seite finden (nur Standard-Seiten)
91 SdPage
* pActualPage
= NULL
;
93 USHORT nCount
= mpDoc
->GetSdPageCount(PK_STANDARD
);
95 while (!pActualPage
&& i
< nCount
)
97 if (mpDoc
->GetSdPage(i
, PK_STANDARD
)->IsSelected())
99 pActualPage
= mpDoc
->GetSdPage(i
, PK_STANDARD
);
107 ::sd::Outliner
* pOutl
=
108 new ::sd::Outliner( mpDoc
, OUTLINERMODE_OUTLINEOBJECT
);
109 pOutl
->SetUpdateMode(FALSE
);
110 pOutl
->EnableUndo(FALSE
);
113 pOutl
->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh
) );
115 pOutl
->SetDefTab( mpDoc
->GetDefaultTabulator() );
116 pOutl
->SetStyleSheetPool((SfxStyleSheetPool
*) mpDoc
->GetStyleSheetPool());
118 SetOfByte aVisibleLayers
= pActualPage
->TRG_GetMasterPageVisibleLayers();
119 USHORT nActualPageNum
= pActualPage
->GetPageNum();
120 SdPage
* pActualNotesPage
= (SdPage
*) mpDoc
->GetPage(nActualPageNum
+ 1);
121 SdrTextObj
* pActualOutline
= (SdrTextObj
*) pActualPage
->GetPresObj(PRESOBJ_OUTLINE
);
125 const bool bUndo
= mpView
->IsUndoEnabled();
128 mpView
->BegUndo(String(SdResId(STR_UNDO_EXPAND_PAGE
)));
130 // Aktuelles Gliederungsobjekt in Outliner setzen
131 OutlinerParaObject
* pParaObj
= pActualOutline
->GetOutlinerParaObject();
132 pOutl
->SetText(*pParaObj
);
134 // Harte Absatz- und Zeichenattribute entfernen
135 SfxItemSet
aEmptyEEAttr(mpDoc
->GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
136 ULONG nParaCount1
= pOutl
->GetParagraphCount();
138 for (USHORT nPara
= 0; nPara
< nParaCount1
; nPara
++)
140 pOutl
->QuickRemoveCharAttribs(nPara
);
141 pOutl
->SetParaAttribs(nPara
, aEmptyEEAttr
);
145 Paragraph
* pPara
= pOutl
->GetParagraph( 0 );
149 ULONG nParaPos
= pOutl
->GetAbsPos( pPara
);
150 sal_Int16 nDepth
= pOutl
->GetDepth( (USHORT
) nParaPos
);
153 // Seite mit Titel & Gliederung!
154 SdPage
* pPage
= (SdPage
*) mpDoc
->AllocPage(FALSE
);
155 pPage
->SetSize(pActualPage
->GetSize() );
156 pPage
->SetBorder(pActualPage
->GetLftBorder(),
157 pActualPage
->GetUppBorder(),
158 pActualPage
->GetRgtBorder(),
159 pActualPage
->GetLwrBorder() );
160 pPage
->SetName(String());
162 // Seite hinter aktueller Seite einfuegen
163 mpDoc
->InsertPage(pPage
, nActualPageNum
+ nPos
);
167 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pPage
));
169 // MasterPage der aktuellen Seite verwenden
170 pPage
->TRG_SetMasterPage(pActualPage
->TRG_GetMasterPage());
171 pPage
->SetLayoutName(pActualPage
->GetLayoutName());
172 pPage
->SetAutoLayout(AUTOLAYOUT_ENUM
, TRUE
);
173 pPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
176 SdPage
* pNotesPage
= (SdPage
*) mpDoc
->AllocPage(FALSE
);
177 pNotesPage
->SetSize(pActualNotesPage
->GetSize());
178 pNotesPage
->SetBorder(pActualNotesPage
->GetLftBorder(),
179 pActualNotesPage
->GetUppBorder(),
180 pActualNotesPage
->GetRgtBorder(),
181 pActualNotesPage
->GetLwrBorder() );
182 pNotesPage
->SetPageKind(PK_NOTES
);
183 pNotesPage
->SetName(String());
185 // Seite hinter aktueller Seite einfuegen
186 mpDoc
->InsertPage(pNotesPage
, nActualPageNum
+ nPos
);
190 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage
));
192 // MasterPage der aktuellen Seite verwenden
193 pNotesPage
->TRG_SetMasterPage(pActualNotesPage
->TRG_GetMasterPage());
194 pNotesPage
->SetLayoutName(pActualNotesPage
->GetLayoutName());
195 pNotesPage
->SetAutoLayout(pActualNotesPage
->GetAutoLayout(), TRUE
);
196 pNotesPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
198 // Title-Textobjekt erstellen
199 SdrTextObj
* pTextObj
= (SdrTextObj
*) pPage
->GetPresObj(PRESOBJ_TITLE
);
202 OutlinerParaObject
* pOutlinerParaObject
= pOutl
->CreateParaObject( (USHORT
) nParaPos
, 1);
203 pOutlinerParaObject
->SetOutlinerMode(OUTLINERMODE_TITLEOBJECT
);
205 if( pOutlinerParaObject
->GetDepth(0) != -1 )
207 SdrOutliner
* pTempOutl
= SdrMakeOutliner( OUTLINERMODE_TITLEOBJECT
, mpDoc
);
209 pTempOutl
->SetText( *pOutlinerParaObject
);
211 delete pOutlinerParaObject
;
213 pTempOutl
->SetDepth( pTempOutl
->GetParagraph( 0 ), -1 );
215 pOutlinerParaObject
= pTempOutl
->CreateParaObject();
219 pTextObj
->SetOutlinerParaObject(pOutlinerParaObject
);
221 pTextObj
->SetEmptyPresObj(FALSE
);
223 SfxStyleSheet
* pSheet
= pPage
->GetStyleSheetForPresObj(PRESOBJ_TITLE
);
224 pTextObj
->NbcSetStyleSheet(pSheet
, FALSE
);
226 ULONG nChildCount
= pOutl
->GetChildCount(pPara
);
230 // Gliederungs-Textobjekt erstellen
231 SdrTextObj
* pOutlineObj
= (SdrTextObj
*) pPage
->GetPresObj(PRESOBJ_OUTLINE
);
232 pPara
= pOutl
->GetParagraph( ++nParaPos
);
234 OutlinerParaObject
* pOPO
= pOutl
->CreateParaObject( (USHORT
) nParaPos
, (USHORT
) nChildCount
);
237 SdrOutliner
* pTempOutl
= SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT
, mpDoc
);
238 pTempOutl
->SetText( *pOPO
);
240 ULONG nParaCount2
= pTempOutl
->GetParagraphCount();
242 for( nPara
= 0; nPara
< nParaCount2
; nPara
++ )
244 pTempOutl
->SetDepth (
245 pTempOutl
->GetParagraph( nPara
),
246 pTempOutl
->GetDepth((USHORT
) nPara
) - 1);
250 pOPO
= pTempOutl
->CreateParaObject();
254 pOutlineObj
->SetOutlinerParaObject( pOPO
);
255 pOutlineObj
->SetEmptyPresObj(FALSE
);
257 // Harte Attribute entfernen (Flag auf TRUE)
258 SfxItemSet
aAttr(mpDoc
->GetPool());
259 aAttr
.Put(XLineStyleItem(XLINE_NONE
));
260 aAttr
.Put(XFillStyleItem(XFILL_NONE
));
261 pOutlineObj
->SetMergedItemSet(aAttr
);
265 pPara
= pOutl
->GetParagraph( ++nParaPos
);
274 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE
, SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
);
278 } // end of namespace sd