1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "fuexpand.hxx"
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>
31 #include "strings.hrc"
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"
43 #include <sfx2/dispatch.hxx>
44 #include <editeng/eeitem.hxx>
46 using namespace com::sun::star
;
50 TYPEINIT1( FuExpandPage
, FuPoor
);
52 FuExpandPage::FuExpandPage (
58 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
62 rtl::Reference
<FuPoor
> FuExpandPage::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
64 rtl::Reference
<FuPoor
> xFunc( new FuExpandPage( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
65 xFunc
->DoExecute(rReq
);
69 void FuExpandPage::DoExecute( SfxRequest
& )
71 if ( mpView
&& mpView
->IsTextEdit() )
72 mpView
->SdrEndTextEdit();
74 // find selected page (only standard pages)
75 SdPage
* pActualPage
= NULL
;
77 sal_uInt16 nCount
= mpDoc
->GetSdPageCount(PK_STANDARD
);
79 while (!pActualPage
&& i
< nCount
)
81 if (mpDoc
->GetSdPage(i
, PK_STANDARD
)->IsSelected())
83 pActualPage
= mpDoc
->GetSdPage(i
, PK_STANDARD
);
91 ::sd::Outliner
* pOutl
=
92 new ::sd::Outliner( mpDoc
, OUTLINERMODE_OUTLINEOBJECT
);
93 pOutl
->SetUpdateMode(false);
94 pOutl
->EnableUndo(false);
97 pOutl
->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh
) );
99 pOutl
->SetDefTab( mpDoc
->GetDefaultTabulator() );
100 pOutl
->SetStyleSheetPool(static_cast<SfxStyleSheetPool
*>(mpDoc
->GetStyleSheetPool()));
102 SetOfByte aVisibleLayers
= pActualPage
->TRG_GetMasterPageVisibleLayers();
103 sal_uInt16 nActualPageNum
= pActualPage
->GetPageNum();
104 SdPage
* pActualNotesPage
= static_cast<SdPage
*>(mpDoc
->GetPage(nActualPageNum
+ 1));
105 SdrTextObj
* pActualOutline
= static_cast<SdrTextObj
*>(pActualPage
->GetPresObj(PRESOBJ_OUTLINE
));
109 const bool bUndo
= mpView
->IsUndoEnabled();
112 mpView
->BegUndo(SD_RESSTR(STR_UNDO_EXPAND_PAGE
));
114 // set current structuring-object into outliner
115 OutlinerParaObject
* pParaObj
= pActualOutline
->GetOutlinerParaObject();
116 pOutl
->SetText(*pParaObj
);
118 // remove hard paragraph- and character attributes
119 SfxItemSet
aEmptyEEAttr(mpDoc
->GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
120 sal_Int32 nParaCount1
= pOutl
->GetParagraphCount();
122 for (sal_Int32 nPara
= 0; nPara
< nParaCount1
; nPara
++)
124 pOutl
->RemoveCharAttribs(nPara
);
125 pOutl
->SetParaAttribs(nPara
, aEmptyEEAttr
);
129 Paragraph
* pPara
= pOutl
->GetParagraph( 0 );
133 sal_Int32 nParaPos
= pOutl
->GetAbsPos( pPara
);
134 sal_Int16 nDepth
= pOutl
->GetDepth( nParaPos
);
137 // page with title & structuring!
138 SdPage
* pPage
= mpDoc
->AllocSdPage(false);
139 pPage
->SetSize(pActualPage
->GetSize() );
140 pPage
->SetBorder(pActualPage
->GetLftBorder(),
141 pActualPage
->GetUppBorder(),
142 pActualPage
->GetRgtBorder(),
143 pActualPage
->GetLwrBorder() );
144 pPage
->SetName(OUString());
146 // insert page after current page
147 mpDoc
->InsertPage(pPage
, nActualPageNum
+ nPos
);
151 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pPage
));
153 // use MasterPage of the current page
154 pPage
->TRG_SetMasterPage(pActualPage
->TRG_GetMasterPage());
155 pPage
->SetLayoutName(pActualPage
->GetLayoutName());
156 pPage
->SetAutoLayout(AUTOLAYOUT_ENUM
, true);
157 pPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
160 SdPage
* pNotesPage
= mpDoc
->AllocSdPage(false);
161 pNotesPage
->SetSize(pActualNotesPage
->GetSize());
162 pNotesPage
->SetBorder(pActualNotesPage
->GetLftBorder(),
163 pActualNotesPage
->GetUppBorder(),
164 pActualNotesPage
->GetRgtBorder(),
165 pActualNotesPage
->GetLwrBorder() );
166 pNotesPage
->SetPageKind(PK_NOTES
);
167 pNotesPage
->SetName(OUString());
169 // insert page after current page
170 mpDoc
->InsertPage(pNotesPage
, nActualPageNum
+ nPos
);
174 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage
));
176 // use MasterPage of the current page
177 pNotesPage
->TRG_SetMasterPage(pActualNotesPage
->TRG_GetMasterPage());
178 pNotesPage
->SetLayoutName(pActualNotesPage
->GetLayoutName());
179 pNotesPage
->SetAutoLayout(pActualNotesPage
->GetAutoLayout(), true);
180 pNotesPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
182 // create title text objects
183 SdrTextObj
* pTextObj
= static_cast<SdrTextObj
*>(pPage
->GetPresObj(PRESOBJ_TITLE
));
184 SAL_WARN_IF(!pTextObj
, "sd.core", "worrying lack of PRESOBJ_TITLE object");
188 OutlinerParaObject
* pOutlinerParaObject
= pOutl
->CreateParaObject( nParaPos
, 1);
189 pOutlinerParaObject
->SetOutlinerMode(OUTLINERMODE_TITLEOBJECT
);
191 if( pOutlinerParaObject
->GetDepth(0) != -1 )
193 SdrOutliner
* pTempOutl
= SdrMakeOutliner(OUTLINERMODE_TITLEOBJECT
, *mpDoc
);
195 pTempOutl
->SetText( *pOutlinerParaObject
);
197 delete pOutlinerParaObject
;
199 pTempOutl
->SetDepth( pTempOutl
->GetParagraph( 0 ), -1 );
201 pOutlinerParaObject
= pTempOutl
->CreateParaObject();
205 pTextObj
->SetOutlinerParaObject(pOutlinerParaObject
);
207 pTextObj
->SetEmptyPresObj(false);
209 SfxStyleSheet
* pSheet
= pPage
->GetStyleSheetForPresObj(PRESOBJ_TITLE
);
210 pTextObj
->NbcSetStyleSheet(pSheet
, false);
212 SdrTextObj
* pOutlineObj
= NULL
;
213 sal_Int32 nChildCount
= pOutl
->GetChildCount(pPara
);
215 pOutlineObj
= static_cast<SdrTextObj
*>( pPage
->GetPresObj(PRESOBJ_OUTLINE
) );
218 // create structuring text objects
219 OutlinerParaObject
* pOPO
= pOutl
->CreateParaObject(++nParaPos
, nChildCount
);
221 SdrOutliner
* pTempOutl
= SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT
, *mpDoc
);
222 pTempOutl
->SetText( *pOPO
);
224 sal_Int32 nParaCount2
= pTempOutl
->GetParagraphCount();
226 for( nPara
= 0; nPara
< nParaCount2
; nPara
++ )
228 pTempOutl
->SetDepth (
229 pTempOutl
->GetParagraph( nPara
),
230 pTempOutl
->GetDepth( nPara
) - 1);
234 pOPO
= pTempOutl
->CreateParaObject();
237 pOutlineObj
->SetOutlinerParaObject( pOPO
);
238 pOutlineObj
->SetEmptyPresObj(false);
240 // remove hard attributes (Flag to sal_True)
241 SfxItemSet
aAttr(mpDoc
->GetPool());
242 aAttr
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
243 aAttr
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
244 pOutlineObj
->SetMergedItemSet(aAttr
);
248 pPara
= pOutl
->GetParagraph( ++nParaPos
);
257 mpViewShell
->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE
, SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
);
261 } // end of namespace sd
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */