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 <editeng/outlobj.hxx>
25 #include <xmloff/autolayout.hxx>
27 #include <strings.hrc>
32 #include <Outliner.hxx>
33 #include <drawdoc.hxx>
34 #include <ViewShell.hxx>
36 #include <sdresid.hxx>
37 #include <DrawViewShell.hxx>
39 using namespace com::sun::star
;
44 FuSummaryPage::FuSummaryPage (
50 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
54 rtl::Reference
<FuPoor
> FuSummaryPage::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
56 rtl::Reference
<FuPoor
> xFunc( new FuSummaryPage( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
57 xFunc
->DoExecute(rReq
);
61 void FuSummaryPage::DoExecute( SfxRequest
& )
63 std::unique_ptr
<SdOutliner
> pOutl
;
64 SdPage
* pSummaryPage
= nullptr;
66 sal_uInt16 nFirstPage
= SDRPAGE_NOTFOUND
;
67 sal_uInt16 nSelectedPages
= 0;
68 sal_uInt16 nCount
= mpDoc
->GetSdPageCount(PageKind::Standard
);
70 while (i
< nCount
&& nSelectedPages
<= 1)
72 /* How many pages are selected?
73 exactly one: pool everything from this page
74 otherwise: only pool the selected pages */
75 SdPage
* pActualPage
= mpDoc
->GetSdPage(i
, PageKind::Standard
);
77 if (pActualPage
->IsSelected())
79 if (nFirstPage
== SDRPAGE_NOTFOUND
)
90 bool bBegUndo
= false;
92 SfxStyleSheet
* pStyle
= nullptr;
94 for (i
= nFirstPage
; i
< nCount
; i
++)
96 SdPage
* pActualPage
= mpDoc
->GetSdPage(i
, PageKind::Standard
);
98 if (nSelectedPages
<= 1 || pActualPage
->IsSelected())
100 SdPage
* pActualNotesPage
= mpDoc
->GetSdPage(i
, PageKind::Notes
);
101 SdrTextObj
* pTextObj
= static_cast<SdrTextObj
*>( pActualPage
->GetPresObj(PRESOBJ_TITLE
) );
103 if (pTextObj
&& !pTextObj
->IsEmptyPresObj())
107 // insert "table of content"-page and create outliner
108 const bool bUndo
= mpView
->IsUndoEnabled();
112 mpView
->BegUndo(SdResId(STR_UNDO_SUMMARY_PAGE
));
116 SdrLayerIDSet aVisibleLayers
= pActualPage
->TRG_GetMasterPageVisibleLayers();
118 // page with title & structuring!
119 pSummaryPage
= mpDoc
->AllocSdPage(false);
120 pSummaryPage
->SetSize(pActualPage
->GetSize() );
121 pSummaryPage
->SetBorder(pActualPage
->GetLeftBorder(),
122 pActualPage
->GetUpperBorder(),
123 pActualPage
->GetRightBorder(),
124 pActualPage
->GetLowerBorder() );
126 // insert page at the back
127 mpDoc
->InsertPage(pSummaryPage
, nCount
* 2 + 1);
129 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage
));
131 // use MasterPage of the current page
132 pSummaryPage
->TRG_SetMasterPage(pActualPage
->TRG_GetMasterPage());
133 pSummaryPage
->SetLayoutName(pActualPage
->GetLayoutName());
134 pSummaryPage
->SetAutoLayout(AUTOLAYOUT_TITLE_CONTENT
, true);
135 pSummaryPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
136 pSummaryPage
->setHeaderFooterSettings(pActualPage
->getHeaderFooterSettings());
139 SdPage
* pNotesPage
= mpDoc
->AllocSdPage(false);
140 pNotesPage
->SetSize(pActualNotesPage
->GetSize());
141 pNotesPage
->SetBorder(pActualNotesPage
->GetLeftBorder(),
142 pActualNotesPage
->GetUpperBorder(),
143 pActualNotesPage
->GetRightBorder(),
144 pActualNotesPage
->GetLowerBorder() );
145 pNotesPage
->SetPageKind(PageKind::Notes
);
147 // insert page at the back
148 mpDoc
->InsertPage(pNotesPage
, nCount
* 2 + 2);
151 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage
));
153 // use MasterPage of the current page
154 pNotesPage
->TRG_SetMasterPage(pActualNotesPage
->TRG_GetMasterPage());
155 pNotesPage
->SetLayoutName(pActualNotesPage
->GetLayoutName());
156 pNotesPage
->SetAutoLayout(pActualNotesPage
->GetAutoLayout(), true);
157 pNotesPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
158 pNotesPage
->setHeaderFooterSettings(pActualNotesPage
->getHeaderFooterSettings());
160 pOutl
.reset(new SdOutliner( mpDoc
, OutlinerMode::OutlineObject
));
161 pOutl
->SetUpdateMode(false);
162 pOutl
->EnableUndo(false);
165 pOutl
->SetRefDevice(SD_MOD()->GetVirtualRefDevice());
167 pOutl
->SetDefTab( mpDoc
->GetDefaultTabulator() );
168 pOutl
->SetStyleSheetPool(static_cast<SfxStyleSheetPool
*>(mpDoc
->GetStyleSheetPool()));
169 pStyle
= pSummaryPage
->GetStyleSheetForPresObj( PRESOBJ_OUTLINE
);
170 pOutl
->SetStyleSheet( 0, pStyle
);
174 OutlinerParaObject
* pParaObj
= pTextObj
->GetOutlinerParaObject();
175 // #118876#, check if the OutlinerParaObject is created successfully
178 pParaObj
->SetOutlinerMode( OutlinerMode::OutlineObject
);
179 pOutl
->AddText(*pParaObj
);
188 SdrTextObj
* pTextObj
= static_cast<SdrTextObj
*>( pSummaryPage
->GetPresObj(PRESOBJ_OUTLINE
) );
193 // remove hard break- and character attributes
194 SfxItemSet
aEmptyEEAttr(mpDoc
->GetPool(), svl::Items
<EE_ITEMS_START
, EE_ITEMS_END
>{});
195 sal_Int32 nParaCount
= pOutl
->GetParagraphCount();
197 for (sal_Int32 nPara
= 0; nPara
< nParaCount
; nPara
++)
199 pOutl
->SetStyleSheet( nPara
, pStyle
);
200 pOutl
->RemoveCharAttribs(nPara
);
201 pOutl
->SetParaAttribs(nPara
, aEmptyEEAttr
);
202 pOutl
->SetDepth(pOutl
->GetParagraph(nPara
), 0);
205 pTextObj
->SetOutlinerParaObject( pOutl
->CreateParaObject() );
206 pTextObj
->SetEmptyPresObj(false);
208 // remove hard attributes (Flag to sal_True)
209 SfxItemSet
aAttr(mpDoc
->GetPool());
210 aAttr
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
211 aAttr
.Put(XFillStyleItem(drawing::FillStyle_NONE
));
212 pTextObj
->SetMergedItemSet(aAttr
);
218 DrawViewShell
* pDrawViewShell
= dynamic_cast< DrawViewShell
* >( mpViewShell
);
221 pDrawViewShell
->SwitchPage( (pSummaryPage
->GetPageNum() - 1) / 2);
225 } // end of namespace sd
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */