xref: /aoo42x/main/sd/source/core/sdpage2.cxx (revision 9b1ac905)
15b190011SAndrew Rist /**************************************************************
2*9b1ac905Smseidel  *
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
10*9b1ac905Smseidel  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9b1ac905Smseidel  *
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.
19*9b1ac905Smseidel  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew 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 	\********************************************************************/
93*9b1ac905Smseidel 	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)
148*9b1ac905Smseidel 	// - 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 					{
199*9b1ac905Smseidel 						OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject();
200cdf0e10cSrcweir 
201*9b1ac905Smseidel 						if( pOPO )
202*9b1ac905Smseidel 							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 |* das Gliederungstextobjekt bei den Vorlagen fuer die Gliederungsebenen
266cdf0e10cSrcweir |* abmelden
267cdf0e10cSrcweir \************************************************************************/
268cdf0e10cSrcweir 
EndListenOutlineText()269cdf0e10cSrcweir void SdPage::EndListenOutlineText()
270cdf0e10cSrcweir {
271cdf0e10cSrcweir 	SdrObject* pOutlineTextObj = GetPresObj(PRESOBJ_OUTLINE);
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 	if (pOutlineTextObj)
274cdf0e10cSrcweir 	{
275cdf0e10cSrcweir 		SdStyleSheetPool* pSPool = (SdStyleSheetPool*)pModel->GetStyleSheetPool();
276cdf0e10cSrcweir 		DBG_ASSERT(pSPool, "StyleSheetPool nicht gefunden");
277cdf0e10cSrcweir 		String aTrueLayoutName(maLayoutName);
278cdf0e10cSrcweir 		aTrueLayoutName.Erase( aTrueLayoutName.SearchAscii( SD_LT_SEPARATOR ));
279cdf0e10cSrcweir 		List* pOutlineStyles = pSPool->CreateOutlineSheetList(aTrueLayoutName);
280cdf0e10cSrcweir 		for (SfxStyleSheet* pSheet = (SfxStyleSheet*)pOutlineStyles->First();
281cdf0e10cSrcweir 			 pSheet;
282cdf0e10cSrcweir 			 pSheet = (SfxStyleSheet*)pOutlineStyles->Next())
283cdf0e10cSrcweir 			{
284cdf0e10cSrcweir 				pOutlineTextObj->EndListening(*pSheet);
285cdf0e10cSrcweir 			}
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 		delete pOutlineStyles;
288cdf0e10cSrcweir 	}
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir /*************************************************************************
292*9b1ac905Smseidel |* Neues Modell setzen
293cdf0e10cSrcweir \************************************************************************/
294cdf0e10cSrcweir 
SetModel(SdrModel * pNewModel)295cdf0e10cSrcweir void SdPage::SetModel(SdrModel* pNewModel)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir 	DisconnectLink();
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	// Model umsetzen
300cdf0e10cSrcweir 	FmFormPage::SetModel(pNewModel);
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	ConnectLink();
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
305cdf0e10cSrcweir /*************************************************************************
306cdf0e10cSrcweir |* Ist die Seite read-only?
307cdf0e10cSrcweir \************************************************************************/
308cdf0e10cSrcweir 
IsReadOnly() const309cdf0e10cSrcweir FASTBOOL SdPage::IsReadOnly() const
310cdf0e10cSrcweir {
311cdf0e10cSrcweir 	return sal_False;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir /*************************************************************************
315cdf0e10cSrcweir |* Beim sfx2::LinkManager anmelden
316cdf0e10cSrcweir \************************************************************************/
317cdf0e10cSrcweir 
ConnectLink()318cdf0e10cSrcweir void SdPage::ConnectLink()
319cdf0e10cSrcweir {
320cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	if (pLinkManager && !mpPageLink && maFileName.Len() && maBookmarkName.Len() &&
323cdf0e10cSrcweir 		mePageKind==PK_STANDARD && !IsMasterPage() &&
324cdf0e10cSrcweir 		( (SdDrawDocument*) pModel)->IsNewOrLoadCompleted())
325cdf0e10cSrcweir 	{
326cdf0e10cSrcweir 		/**********************************************************************
327cdf0e10cSrcweir 		* Anmelden
328cdf0e10cSrcweir 		* Nur Standardseiten duerfen gelinkt sein
329cdf0e10cSrcweir 		**********************************************************************/
330cdf0e10cSrcweir 		::sd::DrawDocShell* pDocSh = ((SdDrawDocument*) pModel)->GetDocSh();
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 		if (!pDocSh || pDocSh->GetMedium()->GetOrigURL() != maFileName)
333cdf0e10cSrcweir 		{
334cdf0e10cSrcweir 			// Keine Links auf Dokument-eigene Seiten!
335cdf0e10cSrcweir 			mpPageLink = new SdPageLink(this, maFileName, maBookmarkName);
336cdf0e10cSrcweir 			String aFilterName(SdResId(STR_IMPRESS));
337cdf0e10cSrcweir 			pLinkManager->InsertFileLink(*mpPageLink, OBJECT_CLIENT_FILE,
338cdf0e10cSrcweir 										 maFileName, &aFilterName, &maBookmarkName);
339cdf0e10cSrcweir 			mpPageLink->Connect();
340cdf0e10cSrcweir 		}
341cdf0e10cSrcweir 	}
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 
345cdf0e10cSrcweir /*************************************************************************
346cdf0e10cSrcweir |* Beim sfx2::LinkManager abmelden
347cdf0e10cSrcweir \************************************************************************/
348cdf0e10cSrcweir 
DisconnectLink()349cdf0e10cSrcweir void SdPage::DisconnectLink()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL;
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 	if (pLinkManager && mpPageLink)
354cdf0e10cSrcweir 	{
355cdf0e10cSrcweir 		/**********************************************************************
356cdf0e10cSrcweir 		* Abmelden
357cdf0e10cSrcweir 		* (Bei Remove wird *pGraphicLink implizit deleted)
358cdf0e10cSrcweir 		**********************************************************************/
359cdf0e10cSrcweir 		pLinkManager->Remove(mpPageLink);
360cdf0e10cSrcweir 		mpPageLink=NULL;
361cdf0e10cSrcweir 	}
362cdf0e10cSrcweir }
363cdf0e10cSrcweir 
364cdf0e10cSrcweir /*************************************************************************
365cdf0e10cSrcweir |* Copy-Ctor
366cdf0e10cSrcweir \************************************************************************/
367cdf0e10cSrcweir 
SdPage(const SdPage & rSrcPage)368cdf0e10cSrcweir SdPage::SdPage(const SdPage& rSrcPage)
369cdf0e10cSrcweir :	FmFormPage(rSrcPage)
370cdf0e10cSrcweir ,	SdrObjUserCall()
371cdf0e10cSrcweir ,	mpItems(NULL)
372cdf0e10cSrcweir {
373*9b1ac905Smseidel 	mePageKind				= rSrcPage.mePageKind;
374*9b1ac905Smseidel 	meAutoLayout			= rSrcPage.meAutoLayout;
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 	SdrObject* pObj = 0;
377cdf0e10cSrcweir 	while((pObj = rSrcPage.maPresentationShapeList.getNextShape(pObj)) != 0)
378cdf0e10cSrcweir 		InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj));
379cdf0e10cSrcweir 
380*9b1ac905Smseidel 	mbSelected				= sal_False;
381*9b1ac905Smseidel 	mnTransitionType		= rSrcPage.mnTransitionType;
382*9b1ac905Smseidel 	mnTransitionSubtype		= rSrcPage.mnTransitionSubtype;
383*9b1ac905Smseidel 	mbTransitionDirection	= rSrcPage.mbTransitionDirection;
384*9b1ac905Smseidel 	mnTransitionFadeColor	= rSrcPage.mnTransitionFadeColor;
385*9b1ac905Smseidel 	mfTransitionDuration	= rSrcPage.mfTransitionDuration;
386cdf0e10cSrcweir 	mePresChange			= rSrcPage.mePresChange;
387*9b1ac905Smseidel 	mnTime					= rSrcPage.mnTime;
388*9b1ac905Smseidel 	mbSoundOn				= rSrcPage.mbSoundOn;
389*9b1ac905Smseidel 	mbExcluded				= rSrcPage.mbExcluded;
390*9b1ac905Smseidel 
391*9b1ac905Smseidel 	maLayoutName			= rSrcPage.maLayoutName;
392*9b1ac905Smseidel 	maSoundFile				= rSrcPage.maSoundFile;
393*9b1ac905Smseidel 	mbLoopSound				= rSrcPage.mbLoopSound;
394*9b1ac905Smseidel 	mbStopSound				= rSrcPage.mbStopSound;
395*9b1ac905Smseidel 	maCreatedPageName		= String();
396*9b1ac905Smseidel 	maFileName				= rSrcPage.maFileName;
397*9b1ac905Smseidel 	maBookmarkName			= rSrcPage.maBookmarkName;
398*9b1ac905Smseidel 	mbScaleObjects			= rSrcPage.mbScaleObjects;
399*9b1ac905Smseidel 	mbBackgroundFullSize	= rSrcPage.mbBackgroundFullSize;
400*9b1ac905Smseidel 	meCharSet				= rSrcPage.meCharSet;
401*9b1ac905Smseidel 	mnPaperBin				= rSrcPage.mnPaperBin;
402*9b1ac905Smseidel 	meOrientation			= rSrcPage.meOrientation;
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 	// header footer
405cdf0e10cSrcweir 	setHeaderFooterSettings( rSrcPage.getHeaderFooterSettings() );
406cdf0e10cSrcweir 
407*9b1ac905Smseidel 	mpPageLink				= NULL; // Wird beim Einfuegen ueber ConnectLink() gesetzt
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 
412cdf0e10cSrcweir /*************************************************************************
413cdf0e10cSrcweir |* Clone
414cdf0e10cSrcweir \************************************************************************/
415cdf0e10cSrcweir 
Clone() const416cdf0e10cSrcweir SdrPage* SdPage::Clone() const
417cdf0e10cSrcweir {
418cdf0e10cSrcweir 	return Clone(NULL);
419cdf0e10cSrcweir }
420cdf0e10cSrcweir 
Clone(SdrModel * pNewModel) const421cdf0e10cSrcweir SdrPage* SdPage::Clone(SdrModel* pNewModel) const
422cdf0e10cSrcweir {
423cdf0e10cSrcweir 	DBG_ASSERT( pNewModel == 0, "sd::SdPage::Clone(), new page ignored, please check code! CL" );
424cdf0e10cSrcweir 	(void)pNewModel;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	SdPage* pNewPage = new SdPage(*this);
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	cloneAnimations( *pNewPage );
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 	// fix user calls for duplicated slide
431cdf0e10cSrcweir 	SdrObjListIter aSourceIter( *this, IM_DEEPWITHGROUPS );
432cdf0e10cSrcweir 	SdrObjListIter aTargetIter( *pNewPage, IM_DEEPWITHGROUPS );
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	while( aSourceIter.IsMore() && aTargetIter.IsMore() )
435cdf0e10cSrcweir 	{
436cdf0e10cSrcweir 		SdrObject* pSource = aSourceIter.Next();
437cdf0e10cSrcweir 		SdrObject* pTarget = aTargetIter.Next();
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 		if( pSource->GetUserCall() )
440cdf0e10cSrcweir 			pTarget->SetUserCall( pNewPage );
441cdf0e10cSrcweir 	}
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	return pNewPage;
444cdf0e10cSrcweir }
445cdf0e10cSrcweir 
446cdf0e10cSrcweir /*************************************************************************
447cdf0e10cSrcweir |* GetTextStyleSheetForObject
448cdf0e10cSrcweir \************************************************************************/
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 
GetTextStyleSheetForObject(SdrObject * pObj) const451cdf0e10cSrcweir SfxStyleSheet* SdPage::GetTextStyleSheetForObject( SdrObject* pObj ) const
452cdf0e10cSrcweir {
453cdf0e10cSrcweir 	const PresObjKind eKind = ((SdPage*)this)->GetPresObjKind(pObj);
454cdf0e10cSrcweir 	if( eKind != PRESOBJ_NONE )
455cdf0e10cSrcweir 	{
456cdf0e10cSrcweir 		return ((SdPage*)this)->GetStyleSheetForPresObj(eKind);
457cdf0e10cSrcweir 	}
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 	return FmFormPage::GetTextStyleSheetForObject( pObj );
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
getOrCreateItems()462cdf0e10cSrcweir SfxItemSet* SdPage::getOrCreateItems()
463cdf0e10cSrcweir {
464cdf0e10cSrcweir 	if( mpItems == NULL )
465cdf0e10cSrcweir 		mpItems = new SfxItemSet( pModel->GetItemPool(), SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES );
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 	return mpItems;
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 
setAlienAttributes(const com::sun::star::uno::Any & rAttributes)471cdf0e10cSrcweir sal_Bool SdPage::setAlienAttributes( const com::sun::star::uno::Any& rAttributes )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir 	SfxItemSet* pSet = getOrCreateItems();
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 	SvXMLAttrContainerItem aAlienAttributes( SDRATTR_XMLATTRIBUTES );
476cdf0e10cSrcweir 	if( aAlienAttributes.PutValue( rAttributes, 0 ) )
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir 		pSet->Put( aAlienAttributes );
479cdf0e10cSrcweir 		return sal_True;
480cdf0e10cSrcweir 	}
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 	return sal_False;
483cdf0e10cSrcweir }
484cdf0e10cSrcweir 
getAlienAttributes(com::sun::star::uno::Any & rAttributes)485cdf0e10cSrcweir void SdPage::getAlienAttributes( com::sun::star::uno::Any& rAttributes )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir 	const SfxPoolItem* pItem;
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 	if( (mpItems == NULL) || ( SFX_ITEM_SET != mpItems->GetItemState( SDRATTR_XMLATTRIBUTES, sal_False, &pItem ) ) )
490cdf0e10cSrcweir 	{
491cdf0e10cSrcweir 		SvXMLAttrContainerItem aAlienAttributes;
492cdf0e10cSrcweir 		aAlienAttributes.QueryValue( rAttributes, 0 );
493cdf0e10cSrcweir 	}
494cdf0e10cSrcweir 	else
495cdf0e10cSrcweir 	{
496cdf0e10cSrcweir 		((SvXMLAttrContainerItem*)pItem)->QueryValue( rAttributes, 0 );
497cdf0e10cSrcweir 	}
498cdf0e10cSrcweir }
499cdf0e10cSrcweir 
RemoveEmptyPresentationObjects()500cdf0e10cSrcweir void SdPage::RemoveEmptyPresentationObjects()
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	SdrObjListIter	aShapeIter( *this, IM_DEEPWITHGROUPS );
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 	SdrObject* pShape;
505cdf0e10cSrcweir 	for( pShape = aShapeIter.Next(); pShape; pShape = aShapeIter.Next() )
506cdf0e10cSrcweir 	{
507cdf0e10cSrcweir 		if( pShape && pShape->IsEmptyPresObj() )
508*9b1ac905Smseidel 		{
509cdf0e10cSrcweir 			RemoveObject( pShape->GetOrdNum() );
510*9b1ac905Smseidel 			SdrObject::Free( pShape );
511*9b1ac905Smseidel 		}
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 	}
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
getTransitionType(void) const516*9b1ac905Smseidel sal_Int16 SdPage::getTransitionType (void) const
517cdf0e10cSrcweir {
518*9b1ac905Smseidel 	return mnTransitionType;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
setTransitionType(sal_Int16 nTransitionType)521cdf0e10cSrcweir void SdPage::setTransitionType( sal_Int16 nTransitionType )
522cdf0e10cSrcweir {
523*9b1ac905Smseidel 	mnTransitionType = nTransitionType;
524*9b1ac905Smseidel 	ActionChanged();
525cdf0e10cSrcweir }
526cdf0e10cSrcweir 
getTransitionSubtype(void) const527cdf0e10cSrcweir sal_Int16 SdPage::getTransitionSubtype (void) const
528cdf0e10cSrcweir {
529*9b1ac905Smseidel 	return mnTransitionSubtype;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
setTransitionSubtype(sal_Int16 nTransitionSubtype)532cdf0e10cSrcweir void SdPage::setTransitionSubtype ( sal_Int16 nTransitionSubtype )
533cdf0e10cSrcweir {
534*9b1ac905Smseidel 	mnTransitionSubtype = nTransitionSubtype;
535*9b1ac905Smseidel 	ActionChanged();
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
getTransitionDirection(void) const538cdf0e10cSrcweir sal_Bool SdPage::getTransitionDirection (void) const
539cdf0e10cSrcweir {
540*9b1ac905Smseidel 	return mbTransitionDirection;
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
setTransitionDirection(sal_Bool bTransitionbDirection)543cdf0e10cSrcweir void SdPage::setTransitionDirection ( sal_Bool bTransitionbDirection )
544cdf0e10cSrcweir {
545*9b1ac905Smseidel 	mbTransitionDirection = bTransitionbDirection;
546*9b1ac905Smseidel 	ActionChanged();
547cdf0e10cSrcweir }
548cdf0e10cSrcweir 
getTransitionFadeColor(void) const549cdf0e10cSrcweir sal_Int32 SdPage::getTransitionFadeColor (void) const
550cdf0e10cSrcweir {
551*9b1ac905Smseidel 	return mnTransitionFadeColor;
552cdf0e10cSrcweir }
553cdf0e10cSrcweir 
setTransitionFadeColor(sal_Int32 nTransitionFadeColor)554*9b1ac905Smseidel void SdPage::setTransitionFadeColor ( sal_Int32 nTransitionFadeColor )
555cdf0e10cSrcweir {
556*9b1ac905Smseidel 	mnTransitionFadeColor = nTransitionFadeColor;
557*9b1ac905Smseidel 	ActionChanged();
558cdf0e10cSrcweir }
559cdf0e10cSrcweir 
getTransitionDuration(void) const560cdf0e10cSrcweir double SdPage::getTransitionDuration (void) const
561cdf0e10cSrcweir {
562*9b1ac905Smseidel 	return mfTransitionDuration;
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
setTransitionDuration(double fTranstionDuration)565cdf0e10cSrcweir void SdPage::setTransitionDuration ( double fTranstionDuration )
566cdf0e10cSrcweir {
567*9b1ac905Smseidel 	mfTransitionDuration = fTranstionDuration;
568*9b1ac905Smseidel 	ActionChanged();
569cdf0e10cSrcweir }
570cdf0e10cSrcweir 
571cdf0e10cSrcweir namespace sd {
572cdf0e10cSrcweir extern void createAnnotation( Reference< XAnnotation >& xAnnotation, SdPage* pPage );
573cdf0e10cSrcweir extern SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert );
574cdf0e10cSrcweir }
575cdf0e10cSrcweir 
createAnnotation(::com::sun::star::uno::Reference<::com::sun::star::office::XAnnotation> & xAnnotation)576cdf0e10cSrcweir void SdPage::createAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation )
577cdf0e10cSrcweir {
578*9b1ac905Smseidel 	sd::createAnnotation( xAnnotation, this );
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
addAnnotation(const Reference<XAnnotation> & xAnnotation,int nIndex)581cdf0e10cSrcweir void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIndex )
582cdf0e10cSrcweir {
583*9b1ac905Smseidel 	if( (nIndex == -1) || (nIndex > (int)maAnnotations.size()) )
584*9b1ac905Smseidel 	{
585*9b1ac905Smseidel 		maAnnotations.push_back( xAnnotation );
586cdf0e10cSrcweir 	}
587cdf0e10cSrcweir 	else
588cdf0e10cSrcweir 	{
589*9b1ac905Smseidel 		maAnnotations.insert( maAnnotations.begin() + nIndex, xAnnotation );
590cdf0e10cSrcweir 	}
591*9b1ac905Smseidel 
592cdf0e10cSrcweir 	if( pModel && pModel->IsUndoEnabled() )
593cdf0e10cSrcweir 	{
594*9b1ac905Smseidel 		SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true );
595*9b1ac905Smseidel 		if( pAction )
596*9b1ac905Smseidel 			pModel->AddUndo( pAction );
597cdf0e10cSrcweir 	}
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 	SetChanged();
600*9b1ac905Smseidel 
601cdf0e10cSrcweir 	if( pModel )
602cdf0e10cSrcweir 	{
603cdf0e10cSrcweir 		pModel->SetChanged();
604cdf0e10cSrcweir 		Reference< XInterface > xSource( xAnnotation, UNO_QUERY );
605*9b1ac905Smseidel 		NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAnnotationInserted" ) ), xSource );
606cdf0e10cSrcweir 	}
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
removeAnnotation(const Reference<XAnnotation> & xAnnotation)609cdf0e10cSrcweir void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir 	if( pModel && pModel->IsUndoEnabled() )
612cdf0e10cSrcweir 	{
613*9b1ac905Smseidel 		SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false );
614*9b1ac905Smseidel 		if( pAction )
615*9b1ac905Smseidel 			pModel->AddUndo( pAction );
616cdf0e10cSrcweir 	}
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 	AnnotationVector::iterator iter = std::find( maAnnotations.begin(), maAnnotations.end(), xAnnotation );
619cdf0e10cSrcweir 	if( iter != maAnnotations.end() )
620cdf0e10cSrcweir 		maAnnotations.erase( iter );
621cdf0e10cSrcweir 
622cdf0e10cSrcweir 	if( pModel )
623cdf0e10cSrcweir 	{
624cdf0e10cSrcweir 		pModel->SetChanged();
625cdf0e10cSrcweir 		Reference< XInterface > xSource( xAnnotation, UNO_QUERY );
626*9b1ac905Smseidel 		NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAnnotationRemoved" ) ), xSource );
627cdf0e10cSrcweir 	}
628cdf0e10cSrcweir }
629*9b1ac905Smseidel 
630