xref: /trunk/main/sd/source/ui/func/fusumry.cxx (revision 36a46462)
15b190011SAndrew Rist /**************************************************************
25b190011SAndrew Rist  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
105b190011SAndrew Rist  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
195b190011SAndrew Rist  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "fusumry.hxx"
29cdf0e10cSrcweir #include <editeng/eeitem.hxx>
30cdf0e10cSrcweir #include <svx/svdotext.hxx>
31cdf0e10cSrcweir #include <svx/svdundo.hxx>
32cdf0e10cSrcweir #include <sfx2/printer.hxx>
33cdf0e10cSrcweir #include <editeng/outlobj.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "strings.hrc"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include "pres.hxx"
38cdf0e10cSrcweir #include "View.hxx"
39cdf0e10cSrcweir #include "sdpage.hxx"
40cdf0e10cSrcweir #include "Outliner.hxx"
41cdf0e10cSrcweir #include "drawview.hxx"
42cdf0e10cSrcweir #include "drawdoc.hxx"
43cdf0e10cSrcweir #include "ViewShell.hxx"
44cdf0e10cSrcweir #include "DrawDocShell.hxx"
45cdf0e10cSrcweir #include "sdresid.hxx"
46cdf0e10cSrcweir #include "optsitem.hxx"
47cdf0e10cSrcweir #include "DrawViewShell.hxx"
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace sd {
50cdf0e10cSrcweir 
51cdf0e10cSrcweir TYPEINIT1( FuSummaryPage, FuPoor );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir /*************************************************************************
54cdf0e10cSrcweir |*
55cdf0e10cSrcweir |* Konstruktor
56cdf0e10cSrcweir |*
57cdf0e10cSrcweir \************************************************************************/
FuSummaryPage(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)58cdf0e10cSrcweir FuSummaryPage::FuSummaryPage (
59cdf0e10cSrcweir     ViewShell* pViewSh,
60cdf0e10cSrcweir     ::sd::Window* pWin,
61cdf0e10cSrcweir     ::sd::View* pView,
62cdf0e10cSrcweir     SdDrawDocument* pDoc,
63cdf0e10cSrcweir     SfxRequest& rReq)
64cdf0e10cSrcweir     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
Create(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)68cdf0e10cSrcweir FunctionReference FuSummaryPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	FunctionReference xFunc( new FuSummaryPage( pViewSh, pWin, pView, pDoc, rReq ) );
71cdf0e10cSrcweir 	xFunc->DoExecute(rReq);
72cdf0e10cSrcweir 	return xFunc;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
DoExecute(SfxRequest &)75cdf0e10cSrcweir void FuSummaryPage::DoExecute( SfxRequest& )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	::sd::Outliner* pOutl = NULL;
78cdf0e10cSrcweir 	SdPage* pSummaryPage = NULL;
79cdf0e10cSrcweir 	sal_uInt16 i = 0;
80cdf0e10cSrcweir 	sal_uInt16 nFirstPage = SDRPAGE_NOTFOUND;
81cdf0e10cSrcweir 	sal_uInt16 nSelectedPages = 0;
82cdf0e10cSrcweir 	sal_uInt16 nCount = mpDoc->GetSdPageCount(PK_STANDARD);
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	while (i < nCount && nSelectedPages <= 1)
85cdf0e10cSrcweir 	{
86cdf0e10cSrcweir 		/**********************************************************************
87cdf0e10cSrcweir 		* Wieviele Seiten sind selektiert?
88cdf0e10cSrcweir 		* Genau eine Seite selektiert: Ab dieser Seite alles zusammenfassen
89cdf0e10cSrcweir 		* sonst: Nur die selektierten Seiten zusammenfassen
90cdf0e10cSrcweir 		**********************************************************************/
91cdf0e10cSrcweir 		SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 		if (pActualPage->IsSelected())
94cdf0e10cSrcweir 		{
95cdf0e10cSrcweir 			if (nFirstPage == SDRPAGE_NOTFOUND)
96cdf0e10cSrcweir 			{
97cdf0e10cSrcweir 				nFirstPage = i;
98cdf0e10cSrcweir 			}
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 			nSelectedPages++;
101cdf0e10cSrcweir 		}
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 		i++;
104cdf0e10cSrcweir 	}
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	bool bBegUndo = false;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	SfxStyleSheet* pStyle = NULL;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	for (i = nFirstPage; i < nCount; i++)
111cdf0e10cSrcweir 	{
112cdf0e10cSrcweir 		SdPage* pActualPage = mpDoc->GetSdPage(i, PK_STANDARD);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 		if (nSelectedPages <= 1 || pActualPage->IsSelected())
115cdf0e10cSrcweir 		{
116cdf0e10cSrcweir 			SdPage* pActualNotesPage = mpDoc->GetSdPage(i, PK_NOTES);
117cdf0e10cSrcweir 			SdrTextObj* pTextObj = (SdrTextObj*) pActualPage->GetPresObj(PRESOBJ_TITLE);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 			if (pTextObj && !pTextObj->IsEmptyPresObj())
120cdf0e10cSrcweir 			{
121cdf0e10cSrcweir 				if (!pSummaryPage)
122cdf0e10cSrcweir 				{
123cdf0e10cSrcweir 					/**********************************************************
124cdf0e10cSrcweir 					* Inhaltsverzeichnis-Seite einfuegen und Outliner anlegen
125cdf0e10cSrcweir 					**********************************************************/
126cdf0e10cSrcweir 					const bool bUndo = mpView->IsUndoEnabled();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 					if( bUndo )
129cdf0e10cSrcweir 					{
130cdf0e10cSrcweir 						mpView->BegUndo(String(SdResId(STR_UNDO_SUMMARY_PAGE)));
131cdf0e10cSrcweir 						bBegUndo = true;
132cdf0e10cSrcweir 					}
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 					SetOfByte aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 					// Seite mit Titel & Gliederung!
137cdf0e10cSrcweir 					pSummaryPage = (SdPage*) mpDoc->AllocPage(sal_False);
138cdf0e10cSrcweir 					pSummaryPage->SetSize(pActualPage->GetSize() );
139cdf0e10cSrcweir 					pSummaryPage->SetBorder(pActualPage->GetLftBorder(),
140cdf0e10cSrcweir 									 pActualPage->GetUppBorder(),
141cdf0e10cSrcweir 									 pActualPage->GetRgtBorder(),
142cdf0e10cSrcweir 									 pActualPage->GetLwrBorder() );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 					// Seite hinten einfuegen
145cdf0e10cSrcweir 					mpDoc->InsertPage(pSummaryPage, nCount * 2 + 1);
146cdf0e10cSrcweir 					if( bUndo )
147cdf0e10cSrcweir 						mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pSummaryPage));
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 					// MasterPage der aktuellen Seite verwenden
150cdf0e10cSrcweir 					pSummaryPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
151cdf0e10cSrcweir 					pSummaryPage->SetLayoutName(pActualPage->GetLayoutName());
152cdf0e10cSrcweir 					pSummaryPage->SetAutoLayout(AUTOLAYOUT_ENUM, sal_True);
153cdf0e10cSrcweir 					pSummaryPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
154cdf0e10cSrcweir 					pSummaryPage->setHeaderFooterSettings(pActualPage->getHeaderFooterSettings());
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 					// Notiz-Seite
157cdf0e10cSrcweir 					SdPage* pNotesPage = (SdPage*) mpDoc->AllocPage(sal_False);
158cdf0e10cSrcweir 					pNotesPage->SetSize(pActualNotesPage->GetSize());
159cdf0e10cSrcweir 					pNotesPage->SetBorder(pActualNotesPage->GetLftBorder(),
160cdf0e10cSrcweir 										  pActualNotesPage->GetUppBorder(),
161cdf0e10cSrcweir 										  pActualNotesPage->GetRgtBorder(),
162cdf0e10cSrcweir 										  pActualNotesPage->GetLwrBorder() );
163cdf0e10cSrcweir 					pNotesPage->SetPageKind(PK_NOTES);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 					// Seite hinten einfuegen
166cdf0e10cSrcweir 					mpDoc->InsertPage(pNotesPage, nCount * 2 + 2);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 					if( bUndo )
169cdf0e10cSrcweir 						mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 					// MasterPage der aktuellen Seite verwenden
172cdf0e10cSrcweir 					pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
173cdf0e10cSrcweir 					pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName());
174cdf0e10cSrcweir 					pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), sal_True);
175cdf0e10cSrcweir 					pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
176cdf0e10cSrcweir 					pNotesPage->setHeaderFooterSettings(pActualNotesPage->getHeaderFooterSettings());
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 					pOutl = new ::sd::Outliner( mpDoc, OUTLINERMODE_OUTLINEOBJECT );
179cdf0e10cSrcweir 					pOutl->SetUpdateMode(sal_False);
180cdf0e10cSrcweir 					pOutl->EnableUndo(sal_False);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 					if (mpDocSh)
183cdf0e10cSrcweir 						pOutl->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh ));
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 					pOutl->SetDefTab( mpDoc->GetDefaultTabulator() );
186cdf0e10cSrcweir 					pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
187cdf0e10cSrcweir 					pStyle = pSummaryPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
188cdf0e10cSrcweir 					pOutl->SetStyleSheet( 0, pStyle );
189cdf0e10cSrcweir 				}
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 				/**************************************************************
192cdf0e10cSrcweir 				* Text hinzufuegen
193cdf0e10cSrcweir 				**************************************************************/
194cdf0e10cSrcweir 				OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
1953892a301SJian Fang Zhang 				// #118876#, check if the OutlinerParaObject is created successfully
1963892a301SJian Fang Zhang 				if( pParaObj )
1973892a301SJian Fang Zhang 				{
1983892a301SJian Fang Zhang 					pParaObj->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
1993892a301SJian Fang Zhang 					pOutl->AddText(*pParaObj);
2003892a301SJian Fang Zhang 				}
201cdf0e10cSrcweir 			}
202cdf0e10cSrcweir 		}
203cdf0e10cSrcweir 	}
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	if (pSummaryPage)
206cdf0e10cSrcweir 	{
207cdf0e10cSrcweir 		SdrTextObj* pTextObj = (SdrTextObj*) pSummaryPage->GetPresObj(PRESOBJ_OUTLINE);
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 		// Harte Absatz- und Zeichenattribute entfernen
210cdf0e10cSrcweir 		SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), EE_ITEMS_START, EE_ITEMS_END);
211cdf0e10cSrcweir 		sal_uLong nParaCount = pOutl->GetParagraphCount();
212cdf0e10cSrcweir 
213*36a46462SDamjan Jovanovic 		for (sal_uInt32 nPara = 0; nPara < nParaCount; nPara++)
214cdf0e10cSrcweir 		{
215cdf0e10cSrcweir 			pOutl->SetStyleSheet( nPara, pStyle );
216cdf0e10cSrcweir 			pOutl->QuickRemoveCharAttribs(nPara);
217cdf0e10cSrcweir 			pOutl->SetParaAttribs(nPara, aEmptyEEAttr);
218cdf0e10cSrcweir 			pOutl->SetDepth(pOutl->GetParagraph(nPara), 0);
219cdf0e10cSrcweir 		}
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 		pTextObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
222cdf0e10cSrcweir 		pTextObj->SetEmptyPresObj(sal_False);
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 		// Harte Attribute entfernen (Flag auf sal_True)
225cdf0e10cSrcweir 		SfxItemSet aAttr(mpDoc->GetPool());
226cdf0e10cSrcweir 		aAttr.Put(XLineStyleItem(XLINE_NONE));
227cdf0e10cSrcweir 		aAttr.Put(XFillStyleItem(XFILL_NONE));
228cdf0e10cSrcweir 		pTextObj->SetMergedItemSet(aAttr);
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 		if( bBegUndo )
231cdf0e10cSrcweir 			mpView->EndUndo();
232cdf0e10cSrcweir 		delete pOutl;
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 		DrawViewShell* pDrawViewShell= dynamic_cast< DrawViewShell* >( mpViewShell );
235cdf0e10cSrcweir 		if(pDrawViewShell)
236cdf0e10cSrcweir 		{
237cdf0e10cSrcweir 			pDrawViewShell->SwitchPage( (pSummaryPage->GetPageNum() - 1) / 2);
238cdf0e10cSrcweir 		}
239cdf0e10cSrcweir 	}
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 
243cdf0e10cSrcweir } // end of namespace sd
244