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 <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 #include <xmloff/autolayout.hxx>
28 #include <strings.hrc>
33 #include <Outliner.hxx>
34 #include <drawview.hxx>
35 #include <drawdoc.hxx>
36 #include <ViewShell.hxx>
37 #include <DrawDocShell.hxx>
38 #include <sdresid.hxx>
39 #include <optsitem.hxx>
40 #include <DrawViewShell.hxx>
42 using namespace com::sun::star
;
47 FuSummaryPage::FuSummaryPage (
53 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
57 rtl::Reference
<FuPoor
> FuSummaryPage::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
59 rtl::Reference
<FuPoor
> xFunc( new FuSummaryPage( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
60 xFunc
->DoExecute(rReq
);
64 void FuSummaryPage::DoExecute( SfxRequest
& )
66 SdOutliner
* pOutl
= nullptr;
67 SdPage
* pSummaryPage
= nullptr;
69 sal_uInt16 nFirstPage
= SDRPAGE_NOTFOUND
;
70 sal_uInt16 nSelectedPages
= 0;
71 sal_uInt16 nCount
= mpDoc
->GetSdPageCount(PageKind::Standard
);
73 while (i
< nCount
&& nSelectedPages
<= 1)
75 /* How many pages are selected?
76 exactly one: pool everything from this page
77 otherwise: only pool the selected pages */
78 SdPage
* pActualPage
= mpDoc
->GetSdPage(i
, PageKind::Standard
);
80 if (pActualPage
->IsSelected())
82 if (nFirstPage
== SDRPAGE_NOTFOUND
)
93 bool bBegUndo
= false;
95 SfxStyleSheet
* pStyle
= nullptr;
97 for (i
= nFirstPage
; i
< nCount
; i
++)
99 SdPage
* pActualPage
= mpDoc
->GetSdPage(i
, PageKind::Standard
);
101 if (nSelectedPages
<= 1 || pActualPage
->IsSelected())
103 SdPage
* pActualNotesPage
= mpDoc
->GetSdPage(i
, PageKind::Notes
);
104 SdrTextObj
* pTextObj
= static_cast<SdrTextObj
*>( pActualPage
->GetPresObj(PRESOBJ_TITLE
) );
106 if (pTextObj
&& !pTextObj
->IsEmptyPresObj())
110 // insert "table of content"-page and create outliner
111 const bool bUndo
= mpView
->IsUndoEnabled();
115 mpView
->BegUndo(SdResId(STR_UNDO_SUMMARY_PAGE
));
119 SdrLayerIDSet aVisibleLayers
= pActualPage
->TRG_GetMasterPageVisibleLayers();
121 // page with title & structuring!
122 pSummaryPage
= mpDoc
->AllocSdPage(false);
123 pSummaryPage
->SetSize(pActualPage
->GetSize() );
124 pSummaryPage
->SetBorder(pActualPage
->GetLeftBorder(),
125 pActualPage
->GetUpperBorder(),
126 pActualPage
->GetRightBorder(),
127 pActualPage
->GetLowerBorder() );
129 // insert page at the back
130 mpDoc
->InsertPage(pSummaryPage
, nCount
* 2 + 1);
132 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage
));
134 // use MasterPage of the current page
135 pSummaryPage
->TRG_SetMasterPage(pActualPage
->TRG_GetMasterPage());
136 pSummaryPage
->SetLayoutName(pActualPage
->GetLayoutName());
137 pSummaryPage
->SetAutoLayout(AUTOLAYOUT_TITLE_CONTENT
, true);
138 pSummaryPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
139 pSummaryPage
->setHeaderFooterSettings(pActualPage
->getHeaderFooterSettings());
142 SdPage
* pNotesPage
= mpDoc
->AllocSdPage(false);
143 pNotesPage
->SetSize(pActualNotesPage
->GetSize());
144 pNotesPage
->SetBorder(pActualNotesPage
->GetLeftBorder(),
145 pActualNotesPage
->GetUpperBorder(),
146 pActualNotesPage
->GetRightBorder(),
147 pActualNotesPage
->GetLowerBorder() );
148 pNotesPage
->SetPageKind(PageKind::Notes
);
150 // insert page at the back
151 mpDoc
->InsertPage(pNotesPage
, nCount
* 2 + 2);
154 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage
));
156 // use MasterPage of the current page
157 pNotesPage
->TRG_SetMasterPage(pActualNotesPage
->TRG_GetMasterPage());
158 pNotesPage
->SetLayoutName(pActualNotesPage
->GetLayoutName());
159 pNotesPage
->SetAutoLayout(pActualNotesPage
->GetAutoLayout(), true);
160 pNotesPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
161 pNotesPage
->setHeaderFooterSettings(pActualNotesPage
->getHeaderFooterSettings());
163 pOutl
= new SdOutliner( mpDoc
, OutlinerMode::OutlineObject
);
164 pOutl
->SetUpdateMode(false);
165 pOutl
->EnableUndo(false);
168 pOutl
->SetRefDevice(SD_MOD()->GetVirtualRefDevice());
170 pOutl
->SetDefTab( mpDoc
->GetDefaultTabulator() );
171 pOutl
->SetStyleSheetPool(static_cast<SfxStyleSheetPool
*>(mpDoc
->GetStyleSheetPool()));
172 pStyle
= pSummaryPage
->GetStyleSheetForPresObj( PRESOBJ_OUTLINE
);
173 pOutl
->SetStyleSheet( 0, pStyle
);
177 OutlinerParaObject
* pParaObj
= pTextObj
->GetOutlinerParaObject();
178 // #118876#, check if the OutlinerParaObject is created successfully
181 pParaObj
->SetOutlinerMode( OutlinerMode::OutlineObject
);
182 pOutl
->AddText(*pParaObj
);
191 SdrTextObj
* pTextObj
= static_cast<SdrTextObj
*>( pSummaryPage
->GetPresObj(PRESOBJ_OUTLINE
) );
196 // remove hard break- and character attributes
197 SfxItemSet
aEmptyEEAttr(mpDoc
->GetPool(), svl::Items
<EE_ITEMS_START
, EE_ITEMS_END
>{});
198 sal_Int32 nParaCount
= pOutl
->GetParagraphCount();
200 for (sal_Int32 nPara
= 0; nPara
< nParaCount
; nPara
++)
202 pOutl
->SetStyleSheet( nPara
, pStyle
);
203 pOutl
->RemoveCharAttribs(nPara
);
204 pOutl
->SetParaAttribs(nPara
, aEmptyEEAttr
);
205 pOutl
->SetDepth(pOutl
->GetParagraph(nPara
), 0);
208 pTextObj
->SetOutlinerParaObject( pOutl
->CreateParaObject() );
209 pTextObj
->SetEmptyPresObj(false);
211 // remove hard attributes (Flag to sal_True)
212 SfxItemSet
aAttr(mpDoc
->GetPool());
213 aAttr
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
214 aAttr
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
215 pTextObj
->SetMergedItemSet(aAttr
);
221 DrawViewShell
* pDrawViewShell
= dynamic_cast< DrawViewShell
* >( mpViewShell
);
224 pDrawViewShell
->SwitchPage( (pSummaryPage
->GetPageNum() - 1) / 2);
228 } // end of namespace sd
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */