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: fusumry.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 "fusumry.hxx"
36 #include <svx/eeitem.hxx>
37 #include <svx/svdotext.hxx>
38 #include <svx/svdundo.hxx>
39 #include <sfx2/printer.hxx>
40 #include <svx/outlobj.hxx>
42 #include "strings.hrc"
47 #include "Outliner.hxx"
48 #include "drawview.hxx"
49 #include "drawdoc.hxx"
50 #include "ViewShell.hxx"
51 #include "DrawDocShell.hxx"
52 #include "sdresid.hxx"
53 #include "optsitem.hxx"
54 #include "DrawViewShell.hxx"
58 TYPEINIT1( FuSummaryPage
, FuPoor
);
60 /*************************************************************************
64 \************************************************************************/
65 FuSummaryPage::FuSummaryPage (
71 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
75 FunctionReference
FuSummaryPage::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
77 FunctionReference
xFunc( new FuSummaryPage( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
78 xFunc
->DoExecute(rReq
);
82 void FuSummaryPage::DoExecute( SfxRequest
& )
84 ::sd::Outliner
* pOutl
= NULL
;
85 SdPage
* pSummaryPage
= NULL
;
87 USHORT nFirstPage
= SDRPAGE_NOTFOUND
;
88 USHORT nSelectedPages
= 0;
89 USHORT nCount
= mpDoc
->GetSdPageCount(PK_STANDARD
);
91 while (i
< nCount
&& nSelectedPages
<= 1)
93 /**********************************************************************
94 * Wieviele Seiten sind selektiert?
95 * Genau eine Seite selektiert: Ab dieser Seite alles zusammenfassen
96 * sonst: Nur die selektierten Seiten zusammenfassen
97 **********************************************************************/
98 SdPage
* pActualPage
= mpDoc
->GetSdPage(i
, PK_STANDARD
);
100 if (pActualPage
->IsSelected())
102 if (nFirstPage
== SDRPAGE_NOTFOUND
)
113 bool bBegUndo
= false;
115 SfxStyleSheet
* pStyle
= NULL
;
117 for (i
= nFirstPage
; i
< nCount
; i
++)
119 SdPage
* pActualPage
= mpDoc
->GetSdPage(i
, PK_STANDARD
);
121 if (nSelectedPages
<= 1 || pActualPage
->IsSelected())
123 SdPage
* pActualNotesPage
= mpDoc
->GetSdPage(i
, PK_NOTES
);
124 SdrTextObj
* pTextObj
= (SdrTextObj
*) pActualPage
->GetPresObj(PRESOBJ_TITLE
);
126 if (pTextObj
&& !pTextObj
->IsEmptyPresObj())
130 /**********************************************************
131 * Inhaltsverzeichnis-Seite einfuegen und Outliner anlegen
132 **********************************************************/
133 const bool bUndo
= mpView
->IsUndoEnabled();
137 mpView
->BegUndo(String(SdResId(STR_UNDO_SUMMARY_PAGE
)));
141 SetOfByte aVisibleLayers
= pActualPage
->TRG_GetMasterPageVisibleLayers();
143 // Seite mit Titel & Gliederung!
144 pSummaryPage
= (SdPage
*) mpDoc
->AllocPage(FALSE
);
145 pSummaryPage
->SetSize(pActualPage
->GetSize() );
146 pSummaryPage
->SetBorder(pActualPage
->GetLftBorder(),
147 pActualPage
->GetUppBorder(),
148 pActualPage
->GetRgtBorder(),
149 pActualPage
->GetLwrBorder() );
151 // Seite hinten einfuegen
152 mpDoc
->InsertPage(pSummaryPage
, nCount
* 2 + 1);
154 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage
));
156 // MasterPage der aktuellen Seite verwenden
157 pSummaryPage
->TRG_SetMasterPage(pActualPage
->TRG_GetMasterPage());
158 pSummaryPage
->SetLayoutName(pActualPage
->GetLayoutName());
159 pSummaryPage
->SetAutoLayout(AUTOLAYOUT_ENUM
, TRUE
);
160 pSummaryPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
161 pSummaryPage
->setHeaderFooterSettings(pActualPage
->getHeaderFooterSettings());
164 SdPage
* pNotesPage
= (SdPage
*) mpDoc
->AllocPage(FALSE
);
165 pNotesPage
->SetSize(pActualNotesPage
->GetSize());
166 pNotesPage
->SetBorder(pActualNotesPage
->GetLftBorder(),
167 pActualNotesPage
->GetUppBorder(),
168 pActualNotesPage
->GetRgtBorder(),
169 pActualNotesPage
->GetLwrBorder() );
170 pNotesPage
->SetPageKind(PK_NOTES
);
172 // Seite hinten einfuegen
173 mpDoc
->InsertPage(pNotesPage
, nCount
* 2 + 2);
176 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage
));
178 // MasterPage der aktuellen Seite verwenden
179 pNotesPage
->TRG_SetMasterPage(pActualNotesPage
->TRG_GetMasterPage());
180 pNotesPage
->SetLayoutName(pActualNotesPage
->GetLayoutName());
181 pNotesPage
->SetAutoLayout(pActualNotesPage
->GetAutoLayout(), TRUE
);
182 pNotesPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
183 pNotesPage
->setHeaderFooterSettings(pActualNotesPage
->getHeaderFooterSettings());
185 pOutl
= new ::sd::Outliner( mpDoc
, OUTLINERMODE_OUTLINEOBJECT
);
186 pOutl
->SetUpdateMode(FALSE
);
187 pOutl
->EnableUndo(FALSE
);
190 pOutl
->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh
));
192 pOutl
->SetDefTab( mpDoc
->GetDefaultTabulator() );
193 pOutl
->SetStyleSheetPool((SfxStyleSheetPool
*) mpDoc
->GetStyleSheetPool());
194 pStyle
= pSummaryPage
->GetStyleSheetForPresObj( PRESOBJ_OUTLINE
);
195 pOutl
->SetStyleSheet( 0, pStyle
);
198 /**************************************************************
200 **************************************************************/
201 OutlinerParaObject
* pParaObj
= pTextObj
->GetOutlinerParaObject();
202 pParaObj
->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT
);
203 pOutl
->AddText(*pParaObj
);
210 SdrTextObj
* pTextObj
= (SdrTextObj
*) pSummaryPage
->GetPresObj(PRESOBJ_OUTLINE
);
212 // Harte Absatz- und Zeichenattribute entfernen
213 SfxItemSet
aEmptyEEAttr(mpDoc
->GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
214 ULONG nParaCount
= pOutl
->GetParagraphCount();
216 for (USHORT nPara
= 0; nPara
< nParaCount
; nPara
++)
218 pOutl
->SetStyleSheet( nPara
, pStyle
);
219 pOutl
->QuickRemoveCharAttribs(nPara
);
220 pOutl
->SetParaAttribs(nPara
, aEmptyEEAttr
);
221 pOutl
->SetDepth(pOutl
->GetParagraph(nPara
), 0);
224 pTextObj
->SetOutlinerParaObject( pOutl
->CreateParaObject() );
225 pTextObj
->SetEmptyPresObj(FALSE
);
227 // Harte Attribute entfernen (Flag auf TRUE)
228 SfxItemSet
aAttr(mpDoc
->GetPool());
229 aAttr
.Put(XLineStyleItem(XLINE_NONE
));
230 aAttr
.Put(XFillStyleItem(XFILL_NONE
));
231 pTextObj
->SetMergedItemSet(aAttr
);
237 DrawViewShell
* pDrawViewShell
= dynamic_cast< DrawViewShell
* >( mpViewShell
);
240 pDrawViewShell
->SwitchPage( (pSummaryPage
->GetPageNum() - 1) / 2);
246 } // end of namespace sd