xref: /AOO41X/main/sd/source/core/sdpage2.cxx (revision 79aad27f7f29270c03e208e3d687e8e3850af11d)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir #include <sfx2/docfile.hxx>
27cdf0e10cSrcweir #include <vcl/svapp.hxx>
28cdf0e10cSrcweir #include <editeng/outliner.hxx>
29cdf0e10cSrcweir #ifndef _SVXLINK_HXX
30cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <svx/svdotext.hxx>
33cdf0e10cSrcweir #include <tools/urlobj.hxx>
34cdf0e10cSrcweir #include <editeng/outlobj.hxx>
35cdf0e10cSrcweir #include <svl/urihelper.hxx>
36cdf0e10cSrcweir #include <editeng/xmlcnitm.hxx>
37cdf0e10cSrcweir #include <svx/svditer.hxx>
38cdf0e10cSrcweir #include <tools/list.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "sdresid.hxx"
41cdf0e10cSrcweir #include "sdpage.hxx"
42cdf0e10cSrcweir #include "glob.hxx"
43cdf0e10cSrcweir #include "glob.hrc"
44cdf0e10cSrcweir #include "drawdoc.hxx"
45cdf0e10cSrcweir #include "stlpool.hxx"
46cdf0e10cSrcweir //#include "sdiocmpt.hxx"
47cdf0e10cSrcweir #include "pglink.hxx"
48cdf0e10cSrcweir //#include "strmname.h"
49cdf0e10cSrcweir #include "anminfo.hxx"
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include "../ui/inc/strings.hrc"
52cdf0e10cSrcweir #include "../ui/inc/DrawDocShell.hxx"
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // #90477#
55cdf0e10cSrcweir #include <tools/tenccvt.hxx>
56cdf0e10cSrcweir #include <svl/itemset.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir using namespace ::sd;
59cdf0e10cSrcweir using namespace ::com::sun::star;
60cdf0e10cSrcweir using namespace ::com::sun::star::uno;
61cdf0e10cSrcweir using namespace ::com::sun::star::office;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir extern void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName, const Reference< XInterface >& xSource );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir /*************************************************************************
66cdf0e10cSrcweir |*
67cdf0e10cSrcweir |* SetPresentationLayout, setzt: Layoutnamen, Masterpage-Verkn�pfung und
68cdf0e10cSrcweir |* Vorlagen fuer Praesentationsobjekte
69cdf0e10cSrcweir |*
70cdf0e10cSrcweir |* Vorraussetzungen: - Die Seite muss bereits das richtige Model kennen!
71cdf0e10cSrcweir |*					 - Die entsprechende Masterpage muss bereits im Model sein.
72cdf0e10cSrcweir |*					 - Die entsprechenden StyleSheets muessen bereits im
73cdf0e10cSrcweir |*					   im StyleSheetPool sein.
74cdf0e10cSrcweir |*
75cdf0e10cSrcweir |*  bReplaceStyleSheets = sal_True : Benannte StyleSheets werden ausgetauscht
76cdf0e10cSrcweir |*                        sal_False: Alle StyleSheets werden neu zugewiesen
77cdf0e10cSrcweir |*
78cdf0e10cSrcweir |*  bSetMasterPage      = sal_True : MasterPage suchen und zuweisen
79cdf0e10cSrcweir |*
80cdf0e10cSrcweir |*  bReverseOrder       = sal_False: MasterPages von vorn nach hinten suchen
81cdf0e10cSrcweir |*                        sal_True : MasterPages von hinten nach vorn suchen (fuer Undo-Action)
82cdf0e10cSrcweir |*
83cdf0e10cSrcweir \************************************************************************/
84cdf0e10cSrcweir 
SetPresentationLayout(const String & rLayoutName,sal_Bool bReplaceStyleSheets,sal_Bool bSetMasterPage,sal_Bool bReverseOrder)85cdf0e10cSrcweir void SdPage::SetPresentationLayout(const String& rLayoutName,
86cdf0e10cSrcweir 								   sal_Bool bReplaceStyleSheets,
87cdf0e10cSrcweir 								   sal_Bool bSetMasterPage,
88cdf0e10cSrcweir 								   sal_Bool bReverseOrder)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	/*********************************************************************
91cdf0e10cSrcweir 	|* Layoutname der Seite
92cdf0e10cSrcweir 	\********************************************************************/
93cdf0e10cSrcweir 	String aOldLayoutName(maLayoutName); 	// merken
94cdf0e10cSrcweir 	maLayoutName = rLayoutName;
95cdf0e10cSrcweir 	maLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
96cdf0e10cSrcweir 	maLayoutName += String(SdResId(STR_LAYOUT_OUTLINE));
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	/*********************************************************************
99cdf0e10cSrcweir 	|* ggf. Masterpage suchen und setzen
100cdf0e10cSrcweir 	\********************************************************************/
101cdf0e10cSrcweir 	if (bSetMasterPage && !IsMasterPage())
102cdf0e10cSrcweir 	{
103cdf0e10cSrcweir 		SdPage* pMaster;
104cdf0e10cSrcweir 		SdPage* pFoundMaster = 0;
105cdf0e10cSrcweir 		sal_uInt16 nMaster = 0;
106cdf0e10cSrcweir 		sal_uInt16 nMasterCount = pModel->GetMasterPageCount();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 		if( !bReverseOrder )
109cdf0e10cSrcweir 		{
110cdf0e10cSrcweir 			for ( nMaster = 0; nMaster < nMasterCount; nMaster++ )
111cdf0e10cSrcweir 			{
112cdf0e10cSrcweir 				pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster));
113cdf0e10cSrcweir 				if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName)
114cdf0e10cSrcweir 				{
115cdf0e10cSrcweir 					pFoundMaster = pMaster;
116cdf0e10cSrcweir 					break;
117cdf0e10cSrcweir 				}
118cdf0e10cSrcweir 			}
119cdf0e10cSrcweir 		}
120cdf0e10cSrcweir 		else
121cdf0e10cSrcweir 		{
122cdf0e10cSrcweir 			for ( nMaster = nMasterCount; nMaster > 0; nMaster-- )
123cdf0e10cSrcweir 			{
124cdf0e10cSrcweir 				pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster - 1));
125cdf0e10cSrcweir 				if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName)
126cdf0e10cSrcweir 				{
127cdf0e10cSrcweir 					pFoundMaster = pMaster;
128cdf0e10cSrcweir 					break;
129cdf0e10cSrcweir 				}
130cdf0e10cSrcweir 			}
131cdf0e10cSrcweir 		}
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 		DBG_ASSERT(pFoundMaster, "Masterpage for presentation layout not found!");
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 		// this should never happen, but we play failsafe here
136cdf0e10cSrcweir 		if( pFoundMaster == 0 )
137cdf0e10cSrcweir 			pFoundMaster = static_cast< SdDrawDocument *>(pModel)->GetSdPage( 0, mePageKind );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 		if( pFoundMaster )
140cdf0e10cSrcweir 			TRG_SetMasterPage(*pFoundMaster);
141cdf0e10cSrcweir 	}
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	/*********************************************************************
144cdf0e10cSrcweir 	|* Vorlagen fuer Praesentationsobjekte
145cdf0e10cSrcweir 	\********************************************************************/
146cdf0e10cSrcweir 	// Listen mit:
147cdf0e10cSrcweir 	// - Vorlagenzeigern fuer Gliederungstextobjekt (alte und neue Vorlagen)
148cdf0e10cSrcweir 	// -Replacedaten fuer OutlinerParaObject
149cdf0e10cSrcweir 	List aOutlineStyles;
150cdf0e10cSrcweir 	List aOldOutlineStyles;
151cdf0e10cSrcweir 	List aReplList;
152cdf0e10cSrcweir 	sal_Bool bListsFilled = sal_False;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	sal_uLong nObjCount = GetObjCount();
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 	for (sal_uLong nObj = 0; nObj < nObjCount; nObj++)
157cdf0e10cSrcweir 	{
158cdf0e10cSrcweir 		SdrTextObj* pObj = (SdrTextObj*) GetObj(nObj);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 		if (pObj->GetObjInventor() == SdrInventor &&
161cdf0e10cSrcweir 			pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
162cdf0e10cSrcweir 		{
163cdf0e10cSrcweir 			if (!bListsFilled || !bReplaceStyleSheets)
164cdf0e10cSrcweir 			{
165cdf0e10cSrcweir 				String aFullName;
166cdf0e10cSrcweir 				String aOldFullName;
167cdf0e10cSrcweir 				SfxStyleSheetBase* pSheet = NULL;
168cdf0e10cSrcweir 				SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 				for (sal_Int16 i = -1; i < 9; i++)
171cdf0e10cSrcweir 				{
172cdf0e10cSrcweir 					aFullName = maLayoutName;
173cdf0e10cSrcweir 					aOldFullName = aOldLayoutName;
174cdf0e10cSrcweir 					aFullName += sal_Unicode( ' ' );
175cdf0e10cSrcweir 					aFullName += String::CreateFromInt32( (sal_Int32) (i <= 0 ) ? 1 : i + 1);
176cdf0e10cSrcweir 					aOldFullName += sal_Unicode( ' ' );
177cdf0e10cSrcweir 					aOldFullName += String::CreateFromInt32( (sal_Int32) (i <= 0 ) ? 1 : i + 1 );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 					pSheet = pStShPool->Find(aOldFullName, SD_STYLE_FAMILY_MASTERPAGE);
180cdf0e10cSrcweir 					DBG_ASSERT(pSheet, "alte Gliederungsvorlage nicht gefunden");
181cdf0e10cSrcweir 					aOldOutlineStyles.Insert(pSheet, LIST_APPEND);
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 					pSheet = pStShPool->Find(aFullName, SD_STYLE_FAMILY_MASTERPAGE);
184cdf0e10cSrcweir 					DBG_ASSERT(pSheet, "neue Gliederungsvorlage nicht gefunden");
185cdf0e10cSrcweir 					aOutlineStyles.Insert(pSheet, LIST_APPEND);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 					if (bReplaceStyleSheets && pSheet)
188cdf0e10cSrcweir 					{
189cdf0e10cSrcweir 						// Replace anstatt Set
190cdf0e10cSrcweir 						StyleReplaceData* pReplData = new StyleReplaceData;
191cdf0e10cSrcweir 						pReplData->nNewFamily = pSheet->GetFamily();
192cdf0e10cSrcweir 						pReplData->nFamily    = pSheet->GetFamily();
193cdf0e10cSrcweir 						pReplData->aNewName   = aFullName;
194cdf0e10cSrcweir 						pReplData->aName      = aOldFullName;
195cdf0e10cSrcweir 						aReplList.Insert(pReplData, LIST_APPEND);
196cdf0e10cSrcweir 					}
197cdf0e10cSrcweir 					else
198cdf0e10cSrcweir 					{
199cdf0e10cSrcweir 		            	OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject();
200cdf0e10cSrcweir 
201cdf0e10cSrcweir                         if( pOPO )
202cdf0e10cSrcweir 						    pOPO->SetStyleSheets( i,  aFullName, SD_STYLE_FAMILY_MASTERPAGE );
203cdf0e10cSrcweir 					}
204cdf0e10cSrcweir 				}
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 				bListsFilled = sal_True;
207cdf0e10cSrcweir 			}
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 			SfxStyleSheet* pSheet = (SfxStyleSheet*)aOutlineStyles.First();
210cdf0e10cSrcweir 			SfxStyleSheet* pOldSheet = (SfxStyleSheet*)aOldOutlineStyles.First();
211cdf0e10cSrcweir 			while (pSheet)
212cdf0e10cSrcweir 			{
213cdf0e10cSrcweir 				if (pSheet != pOldSheet)
214cdf0e10cSrcweir 				{
215cdf0e10cSrcweir 					pObj->EndListening(*pOldSheet);
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 					if (!pObj->IsListening(*pSheet))
218cdf0e10cSrcweir 						pObj->StartListening(*pSheet);
219cdf0e10cSrcweir 				}
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 				pSheet = (SfxStyleSheet*)aOutlineStyles.Next();
222cdf0e10cSrcweir 				pOldSheet = (SfxStyleSheet*)aOldOutlineStyles.Next();
223cdf0e10cSrcweir 			}
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 			OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject();
226cdf0e10cSrcweir 			if ( bReplaceStyleSheets && pOPO )
227cdf0e10cSrcweir 			{
228cdf0e10cSrcweir 				StyleReplaceData* pReplData = (StyleReplaceData*) aReplList.First();
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 				while( pReplData )
231cdf0e10cSrcweir 				{
232cdf0e10cSrcweir 					pOPO->ChangeStyleSheets( pReplData->aName, pReplData->nFamily, pReplData->aNewName, pReplData->nNewFamily );
233cdf0e10cSrcweir 					pReplData = (StyleReplaceData*) aReplList.Next();
234cdf0e10cSrcweir 				}
235cdf0e10cSrcweir 			}
236cdf0e10cSrcweir 		}
237cdf0e10cSrcweir 		else if (pObj->GetObjInventor() == SdrInventor &&
238cdf0e10cSrcweir 				 pObj->GetObjIdentifier() == OBJ_TITLETEXT)
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir 			// PresObjKind nicht ueber GetPresObjKind() holen, da dort nur
241cdf0e10cSrcweir 			// die PresObjListe beruecksichtigt wird. Es sollen aber alle
242cdf0e10cSrcweir 			// "Titelobjekte" hier beruecksichtigt werden (Paste aus Clipboard usw.)
243cdf0e10cSrcweir 			SfxStyleSheet* pSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 			if (pSheet)
246cdf0e10cSrcweir 				pObj->SetStyleSheet(pSheet, sal_True);
247cdf0e10cSrcweir 		}
248cdf0e10cSrcweir 		else
249cdf0e10cSrcweir 		{
250cdf0e10cSrcweir 			SfxStyleSheet* pSheet = GetStyleSheetForPresObj(GetPresObjKind(pObj));
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 			if (pSheet)
253cdf0e10cSrcweir 				pObj->SetStyleSheet(pSheet, sal_True);
254cdf0e10cSrcweir 		}
255cdf0e10cSrcweir 	}
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 	for (sal_uLong i = 0; i < aReplList.Count(); i++)
258cdf0e10cSrcweir 	{
259cdf0e10cSrcweir 		delete (StyleReplaceData*) aReplList.GetObject(i);
260cdf0e10cSrcweir 	}
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 
264cdf0e10cSrcweir /*************************************************************************
265cdf0e10cSrcweir |*
266cdf0e10cSrcweir |* das Gliederungstextobjekt bei den Vorlagen fuer die Gliederungsebenen
267cdf0e10cSrcweir |* abmelden
268cdf0e10cSrcweir |*
269cdf0e10cSrcweir \************************************************************************/
270cdf0e10cSrcweir 
EndListenOutlineText()271cdf0e10cSrcweir void SdPage::EndListenOutlineText()
272cdf0e10cSrcweir {
273cdf0e10cSrcweir 	SdrObject* pOutlineTextObj = GetPresObj(PRESOBJ_OUTLINE);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	if (pOutlineTextObj)
276cdf0e10cSrcweir 	{
277cdf0e10cSrcweir 		SdStyleSheetPool* pSPool = (SdStyleSheetPool*)pModel->GetStyleSheetPool();
278cdf0e10cSrcweir 		DBG_ASSERT(pSPool, "StyleSheetPool nicht gefunden");
279cdf0e10cSrcweir 		String aTrueLayoutName(maLayoutName);
280cdf0e10cSrcweir 		aTrueLayoutName.Erase( aTrueLayoutName.SearchAscii( SD_LT_SEPARATOR ));
281cdf0e10cSrcweir 		List* pOutlineStyles = pSPool->CreateOutlineSheetList(aTrueLayoutName);
282cdf0e10cSrcweir 		for (SfxStyleSheet* pSheet = (SfxStyleSheet*)pOutlineStyles->First();
283cdf0e10cSrcweir 			 pSheet;
284cdf0e10cSrcweir 			 pSheet = (SfxStyleSheet*)pOutlineStyles->Next())
285cdf0e10cSrcweir 			{
286cdf0e10cSrcweir 				pOutlineTextObj->EndListening(*pSheet);
287cdf0e10cSrcweir 			}
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 		delete pOutlineStyles;
290cdf0e10cSrcweir 	}
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir /*************************************************************************
294cdf0e10cSrcweir |*
295cdf0e10cSrcweir |* Neues Model setzen
296cdf0e10cSrcweir |*
297cdf0e10cSrcweir \************************************************************************/
298cdf0e10cSrcweir 
SetModel(SdrModel * pNewModel)299cdf0e10cSrcweir void SdPage::SetModel(SdrModel* pNewModel)
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	DisconnectLink();
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 	// Model umsetzen
304cdf0e10cSrcweir 	FmFormPage::SetModel(pNewModel);
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	ConnectLink();
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir /*************************************************************************
310cdf0e10cSrcweir |*
311cdf0e10cSrcweir |* Ist die Seite read-only?
312cdf0e10cSrcweir |*
313cdf0e10cSrcweir \************************************************************************/
314cdf0e10cSrcweir 
IsReadOnly() const315cdf0e10cSrcweir FASTBOOL SdPage::IsReadOnly() const
316cdf0e10cSrcweir {
317cdf0e10cSrcweir 	return sal_False;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir /*************************************************************************
321cdf0e10cSrcweir |*
322cdf0e10cSrcweir |* Beim sfx2::LinkManager anmelden
323cdf0e10cSrcweir |*
324cdf0e10cSrcweir \************************************************************************/
325cdf0e10cSrcweir 
ConnectLink()326cdf0e10cSrcweir void SdPage::ConnectLink()
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL;
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 	if (pLinkManager && !mpPageLink && maFileName.Len() && maBookmarkName.Len() &&
331cdf0e10cSrcweir 		mePageKind==PK_STANDARD && !IsMasterPage() &&
332cdf0e10cSrcweir 		( (SdDrawDocument*) pModel)->IsNewOrLoadCompleted())
333cdf0e10cSrcweir 	{
334cdf0e10cSrcweir 		/**********************************************************************
335cdf0e10cSrcweir 		* Anmelden
336cdf0e10cSrcweir 		* Nur Standardseiten duerfen gelinkt sein
337cdf0e10cSrcweir 		**********************************************************************/
338cdf0e10cSrcweir 		::sd::DrawDocShell* pDocSh = ((SdDrawDocument*) pModel)->GetDocSh();
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 		if (!pDocSh || pDocSh->GetMedium()->GetOrigURL() != maFileName)
341cdf0e10cSrcweir 		{
342cdf0e10cSrcweir 			// Keine Links auf Dokument-eigene Seiten!
343cdf0e10cSrcweir 			mpPageLink = new SdPageLink(this, maFileName, maBookmarkName);
344cdf0e10cSrcweir 			String aFilterName(SdResId(STR_IMPRESS));
345cdf0e10cSrcweir 			pLinkManager->InsertFileLink(*mpPageLink, OBJECT_CLIENT_FILE,
346cdf0e10cSrcweir 										 maFileName, &aFilterName, &maBookmarkName);
347cdf0e10cSrcweir 			mpPageLink->Connect();
348cdf0e10cSrcweir 		}
349cdf0e10cSrcweir 	}
350cdf0e10cSrcweir }
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 
353cdf0e10cSrcweir /*************************************************************************
354cdf0e10cSrcweir |*
355cdf0e10cSrcweir |* Beim sfx2::LinkManager abmelden
356cdf0e10cSrcweir |*
357cdf0e10cSrcweir \************************************************************************/
358cdf0e10cSrcweir 
DisconnectLink()359cdf0e10cSrcweir void SdPage::DisconnectLink()
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	if (pLinkManager && mpPageLink)
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir 		/**********************************************************************
366cdf0e10cSrcweir 		* Abmelden
367cdf0e10cSrcweir 		* (Bei Remove wird *pGraphicLink implizit deleted)
368cdf0e10cSrcweir 		**********************************************************************/
369cdf0e10cSrcweir 		pLinkManager->Remove(mpPageLink);
370cdf0e10cSrcweir 		mpPageLink=NULL;
371cdf0e10cSrcweir 	}
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir /*************************************************************************
375cdf0e10cSrcweir |*
376cdf0e10cSrcweir |* Copy-Ctor
377cdf0e10cSrcweir |*
378cdf0e10cSrcweir \************************************************************************/
379cdf0e10cSrcweir 
SdPage(const SdPage & rSrcPage)380cdf0e10cSrcweir SdPage::SdPage(const SdPage& rSrcPage)
381cdf0e10cSrcweir :	FmFormPage(rSrcPage)
382cdf0e10cSrcweir ,	SdrObjUserCall()
383cdf0e10cSrcweir ,	mpItems(NULL)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir 	mePageKind           = rSrcPage.mePageKind;
386cdf0e10cSrcweir 	meAutoLayout         = rSrcPage.meAutoLayout;
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 	SdrObject* pObj = 0;
389cdf0e10cSrcweir 	while((pObj = rSrcPage.maPresentationShapeList.getNextShape(pObj)) != 0)
390cdf0e10cSrcweir 		InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj));
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	mbSelected           = sal_False;
393cdf0e10cSrcweir 	mnTransitionType	= rSrcPage.mnTransitionType;
394cdf0e10cSrcweir 	mnTransitionSubtype = rSrcPage.mnTransitionSubtype;
395cdf0e10cSrcweir 	mbTransitionDirection = rSrcPage.mbTransitionDirection;
396cdf0e10cSrcweir 	mnTransitionFadeColor = rSrcPage.mnTransitionFadeColor;
397cdf0e10cSrcweir 	mfTransitionDuration = rSrcPage.mfTransitionDuration;
398cdf0e10cSrcweir 	mePresChange			= rSrcPage.mePresChange;
399cdf0e10cSrcweir 	mnTime               = rSrcPage.mnTime;
400cdf0e10cSrcweir 	mbSoundOn            = rSrcPage.mbSoundOn;
401cdf0e10cSrcweir 	mbExcluded           = rSrcPage.mbExcluded;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 	maLayoutName         = rSrcPage.maLayoutName;
404cdf0e10cSrcweir 	maSoundFile          = rSrcPage.maSoundFile;
405cdf0e10cSrcweir 	mbLoopSound			 = rSrcPage.mbLoopSound;
406cdf0e10cSrcweir 	mbStopSound			 = rSrcPage.mbStopSound;
407cdf0e10cSrcweir 	maCreatedPageName    = String();
408cdf0e10cSrcweir 	maFileName           = rSrcPage.maFileName;
409cdf0e10cSrcweir 	maBookmarkName       = rSrcPage.maBookmarkName;
410cdf0e10cSrcweir 	mbScaleObjects       = rSrcPage.mbScaleObjects;
411cdf0e10cSrcweir 	mbBackgroundFullSize = rSrcPage.mbBackgroundFullSize;
412cdf0e10cSrcweir 	meCharSet            = rSrcPage.meCharSet;
413cdf0e10cSrcweir 	mnPaperBin           = rSrcPage.mnPaperBin;
414cdf0e10cSrcweir 	meOrientation        = rSrcPage.meOrientation;
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 	// header footer
417cdf0e10cSrcweir 	setHeaderFooterSettings( rSrcPage.getHeaderFooterSettings() );
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 	mpPageLink           = NULL;    // Wird beim Einfuegen ueber ConnectLink() gesetzt
420cdf0e10cSrcweir }
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 
424cdf0e10cSrcweir /*************************************************************************
425cdf0e10cSrcweir |*
426cdf0e10cSrcweir |* Clone
427cdf0e10cSrcweir |*
428cdf0e10cSrcweir \************************************************************************/
429cdf0e10cSrcweir 
Clone() const430cdf0e10cSrcweir SdrPage* SdPage::Clone() const
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	return Clone(NULL);
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
Clone(SdrModel * pNewModel) const435cdf0e10cSrcweir SdrPage* SdPage::Clone(SdrModel* pNewModel) const
436cdf0e10cSrcweir {
437cdf0e10cSrcweir 	DBG_ASSERT( pNewModel == 0, "sd::SdPage::Clone(), new page ignored, please check code! CL" );
438cdf0e10cSrcweir 	(void)pNewModel;
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 	SdPage* pNewPage = new SdPage(*this);
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 	cloneAnimations( *pNewPage );
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 	// fix user calls for duplicated slide
445cdf0e10cSrcweir 	SdrObjListIter aSourceIter( *this, IM_DEEPWITHGROUPS );
446cdf0e10cSrcweir 	SdrObjListIter aTargetIter( *pNewPage, IM_DEEPWITHGROUPS );
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 	while( aSourceIter.IsMore() && aTargetIter.IsMore() )
449cdf0e10cSrcweir 	{
450cdf0e10cSrcweir 		SdrObject* pSource = aSourceIter.Next();
451cdf0e10cSrcweir 		SdrObject* pTarget = aTargetIter.Next();
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 		if( pSource->GetUserCall() )
454cdf0e10cSrcweir 			pTarget->SetUserCall( pNewPage );
455cdf0e10cSrcweir 	}
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 	return pNewPage;
458cdf0e10cSrcweir }
459cdf0e10cSrcweir 
460cdf0e10cSrcweir /*************************************************************************
461cdf0e10cSrcweir |*
462cdf0e10cSrcweir |* GetTextStyleSheetForObject
463cdf0e10cSrcweir |*
464cdf0e10cSrcweir \************************************************************************/
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 
GetTextStyleSheetForObject(SdrObject * pObj) const467cdf0e10cSrcweir SfxStyleSheet* SdPage::GetTextStyleSheetForObject( SdrObject* pObj ) const
468cdf0e10cSrcweir {
469cdf0e10cSrcweir 	const PresObjKind eKind = ((SdPage*)this)->GetPresObjKind(pObj);
470cdf0e10cSrcweir 	if( eKind != PRESOBJ_NONE )
471cdf0e10cSrcweir 	{
472cdf0e10cSrcweir 		return ((SdPage*)this)->GetStyleSheetForPresObj(eKind);
473cdf0e10cSrcweir 	}
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 	return FmFormPage::GetTextStyleSheetForObject( pObj );
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
getOrCreateItems()478cdf0e10cSrcweir SfxItemSet* SdPage::getOrCreateItems()
479cdf0e10cSrcweir {
480cdf0e10cSrcweir 	if( mpItems == NULL )
481cdf0e10cSrcweir 		mpItems = new SfxItemSet( pModel->GetItemPool(), SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	return mpItems;
484cdf0e10cSrcweir }
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 
setAlienAttributes(const com::sun::star::uno::Any & rAttributes)487cdf0e10cSrcweir sal_Bool SdPage::setAlienAttributes( const com::sun::star::uno::Any& rAttributes )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir 	SfxItemSet* pSet = getOrCreateItems();
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 	SvXMLAttrContainerItem aAlienAttributes( SDRATTR_XMLATTRIBUTES );
492cdf0e10cSrcweir 	if( aAlienAttributes.PutValue( rAttributes, 0 ) )
493cdf0e10cSrcweir 	{
494cdf0e10cSrcweir 		pSet->Put( aAlienAttributes );
495cdf0e10cSrcweir 		return sal_True;
496cdf0e10cSrcweir 	}
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 	return sal_False;
499cdf0e10cSrcweir }
500cdf0e10cSrcweir 
getAlienAttributes(com::sun::star::uno::Any & rAttributes)501cdf0e10cSrcweir void SdPage::getAlienAttributes( com::sun::star::uno::Any& rAttributes )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir 	const SfxPoolItem* pItem;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 	if( (mpItems == NULL) || ( SFX_ITEM_SET != mpItems->GetItemState( SDRATTR_XMLATTRIBUTES, sal_False, &pItem ) ) )
506cdf0e10cSrcweir 	{
507cdf0e10cSrcweir 		SvXMLAttrContainerItem aAlienAttributes;
508cdf0e10cSrcweir 		aAlienAttributes.QueryValue( rAttributes, 0 );
509cdf0e10cSrcweir 	}
510cdf0e10cSrcweir 	else
511cdf0e10cSrcweir 	{
512cdf0e10cSrcweir 		((SvXMLAttrContainerItem*)pItem)->QueryValue( rAttributes, 0 );
513cdf0e10cSrcweir 	}
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
RemoveEmptyPresentationObjects()516cdf0e10cSrcweir void SdPage::RemoveEmptyPresentationObjects()
517cdf0e10cSrcweir {
518cdf0e10cSrcweir 	SdrObjListIter	aShapeIter( *this, IM_DEEPWITHGROUPS );
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 	SdrObject* pShape;
521cdf0e10cSrcweir 	for( pShape = aShapeIter.Next(); pShape; pShape = aShapeIter.Next() )
522cdf0e10cSrcweir 	{
523cdf0e10cSrcweir 		if( pShape && pShape->IsEmptyPresObj() )
524cdf0e10cSrcweir         {
525cdf0e10cSrcweir 			RemoveObject( pShape->GetOrdNum() );
526cdf0e10cSrcweir             SdrObject::Free( pShape );
527cdf0e10cSrcweir         }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 	}
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
getTransitionType(void) const532cdf0e10cSrcweir sal_Int16 SdPage::getTransitionType (void) const
533cdf0e10cSrcweir {
534cdf0e10cSrcweir     return mnTransitionType;
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
setTransitionType(sal_Int16 nTransitionType)537cdf0e10cSrcweir void SdPage::setTransitionType( sal_Int16 nTransitionType )
538cdf0e10cSrcweir {
539cdf0e10cSrcweir     mnTransitionType = nTransitionType;
540cdf0e10cSrcweir     ActionChanged();
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
getTransitionSubtype(void) const543cdf0e10cSrcweir sal_Int16 SdPage::getTransitionSubtype (void) const
544cdf0e10cSrcweir {
545cdf0e10cSrcweir     return mnTransitionSubtype;
546cdf0e10cSrcweir }
547cdf0e10cSrcweir 
setTransitionSubtype(sal_Int16 nTransitionSubtype)548cdf0e10cSrcweir void SdPage::setTransitionSubtype ( sal_Int16 nTransitionSubtype )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir     mnTransitionSubtype = nTransitionSubtype;
551cdf0e10cSrcweir     ActionChanged();
552cdf0e10cSrcweir }
553cdf0e10cSrcweir 
getTransitionDirection(void) const554cdf0e10cSrcweir sal_Bool SdPage::getTransitionDirection (void) const
555cdf0e10cSrcweir {
556cdf0e10cSrcweir     return mbTransitionDirection;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
setTransitionDirection(sal_Bool bTransitionbDirection)559cdf0e10cSrcweir void SdPage::setTransitionDirection ( sal_Bool bTransitionbDirection )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir     mbTransitionDirection = bTransitionbDirection;
562cdf0e10cSrcweir     ActionChanged();
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
getTransitionFadeColor(void) const565cdf0e10cSrcweir sal_Int32 SdPage::getTransitionFadeColor (void) const
566cdf0e10cSrcweir {
567cdf0e10cSrcweir     return mnTransitionFadeColor;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
setTransitionFadeColor(sal_Int32 nTransitionFadeColor)570cdf0e10cSrcweir void SdPage::setTransitionFadeColor ( sal_Int32 nTransitionFadeColor )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir     mnTransitionFadeColor = nTransitionFadeColor;
573cdf0e10cSrcweir     ActionChanged();
574cdf0e10cSrcweir }
575cdf0e10cSrcweir 
getTransitionDuration(void) const576cdf0e10cSrcweir double SdPage::getTransitionDuration (void) const
577cdf0e10cSrcweir {
578cdf0e10cSrcweir     return mfTransitionDuration;
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
setTransitionDuration(double fTranstionDuration)581cdf0e10cSrcweir void SdPage::setTransitionDuration ( double fTranstionDuration )
582cdf0e10cSrcweir {
583cdf0e10cSrcweir     mfTransitionDuration = fTranstionDuration;
584cdf0e10cSrcweir     ActionChanged();
585cdf0e10cSrcweir }
586cdf0e10cSrcweir 
587cdf0e10cSrcweir namespace sd {
588cdf0e10cSrcweir extern void createAnnotation( Reference< XAnnotation >& xAnnotation, SdPage* pPage );
589cdf0e10cSrcweir extern SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert );
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
createAnnotation(::com::sun::star::uno::Reference<::com::sun::star::office::XAnnotation> & xAnnotation)592cdf0e10cSrcweir void SdPage::createAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir     sd::createAnnotation( xAnnotation, this );
595cdf0e10cSrcweir }
596cdf0e10cSrcweir 
addAnnotation(const Reference<XAnnotation> & xAnnotation,int nIndex)597cdf0e10cSrcweir void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIndex )
598cdf0e10cSrcweir {
599cdf0e10cSrcweir     if( (nIndex == -1) || (nIndex > (int)maAnnotations.size()) )
600cdf0e10cSrcweir     {
601cdf0e10cSrcweir 	    maAnnotations.push_back( xAnnotation );
602cdf0e10cSrcweir 	}
603cdf0e10cSrcweir 	else
604cdf0e10cSrcweir 	{
605cdf0e10cSrcweir 	    maAnnotations.insert( maAnnotations.begin() + nIndex, xAnnotation );
606cdf0e10cSrcweir 	}
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 	if( pModel && pModel->IsUndoEnabled() )
609cdf0e10cSrcweir 	{
610cdf0e10cSrcweir 	    SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true );
611cdf0e10cSrcweir 	    if( pAction )
612cdf0e10cSrcweir 	        pModel->AddUndo( pAction );
613cdf0e10cSrcweir 	}
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 	SetChanged();
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 	if( pModel )
618cdf0e10cSrcweir 	{
619cdf0e10cSrcweir 		pModel->SetChanged();
620cdf0e10cSrcweir 		Reference< XInterface > xSource( xAnnotation, UNO_QUERY );
621cdf0e10cSrcweir 	    NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAnnotationInserted" ) ), xSource );
622cdf0e10cSrcweir 	}
623cdf0e10cSrcweir }
624cdf0e10cSrcweir 
removeAnnotation(const Reference<XAnnotation> & xAnnotation)625cdf0e10cSrcweir void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir 	if( pModel && pModel->IsUndoEnabled() )
628cdf0e10cSrcweir 	{
629cdf0e10cSrcweir 	    SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false );
630cdf0e10cSrcweir 	    if( pAction )
631cdf0e10cSrcweir 	        pModel->AddUndo( pAction );
632cdf0e10cSrcweir 	}
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 	AnnotationVector::iterator iter = std::find( maAnnotations.begin(), maAnnotations.end(), xAnnotation );
635cdf0e10cSrcweir 	if( iter != maAnnotations.end() )
636cdf0e10cSrcweir 		maAnnotations.erase( iter );
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 	if( pModel )
639cdf0e10cSrcweir 	{
640cdf0e10cSrcweir 		pModel->SetChanged();
641cdf0e10cSrcweir 		Reference< XInterface > xSource( xAnnotation, UNO_QUERY );
642cdf0e10cSrcweir 	    NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAnnotationRemoved" ) ), xSource );
643cdf0e10cSrcweir 	}
644cdf0e10cSrcweir }
645