xref: /aoo41x/main/sd/source/core/sdpage.cxx (revision 63d109c7)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
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
125b190011SAndrew Rist  *
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 #include <algorithm>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <comphelper/classids.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include "eetext.hxx"
33cdf0e10cSrcweir #include <editeng/eeitem.hxx>
34cdf0e10cSrcweir #include <svx/svdoutl.hxx>
35cdf0e10cSrcweir #include <editeng/editdata.hxx>
36cdf0e10cSrcweir #include <svx/pageitem.hxx>
37cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
38cdf0e10cSrcweir #include <editeng/bulitem.hxx>
39cdf0e10cSrcweir #include <svx/svdpagv.hxx>
40cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
41cdf0e10cSrcweir #include <editeng/outlobj.hxx>
42cdf0e10cSrcweir #include <svx/svdoole2.hxx>
43cdf0e10cSrcweir #include <svx/svdograf.hxx>
44cdf0e10cSrcweir #include <svx/svdopage.hxx>
45cdf0e10cSrcweir #include <svx/svdopage.hxx>
46cdf0e10cSrcweir #include <sfx2/printer.hxx>
47cdf0e10cSrcweir #include <basic/basmgr.hxx>
48cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
49cdf0e10cSrcweir #include <svx/svdundo.hxx>
50cdf0e10cSrcweir #include <svl/smplhint.hxx>
51cdf0e10cSrcweir #include <editeng/adjitem.hxx>
52cdf0e10cSrcweir #include <editeng/editobj.hxx>
53cdf0e10cSrcweir #ifndef _SVX_SRIPTTYPEITEM_HXX
54cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #include <svx/unopage.hxx>
57cdf0e10cSrcweir #include <editeng/flditem.hxx>
58cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
59cdf0e10cSrcweir #include <svx/svditer.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #include <editeng/adjitem.hxx>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include "../ui/inc/DrawDocShell.hxx"
64cdf0e10cSrcweir #include "Outliner.hxx"
65cdf0e10cSrcweir #include "app.hrc"
66cdf0e10cSrcweir #include "misc.hxx"
67cdf0e10cSrcweir #include "eetext.hxx"
68cdf0e10cSrcweir #include "drawdoc.hxx"
69cdf0e10cSrcweir #include "sdpage.hxx"
70cdf0e10cSrcweir #include "pglink.hxx"
71cdf0e10cSrcweir #include "sdresid.hxx"
72cdf0e10cSrcweir #include "stlsheet.hxx"
73cdf0e10cSrcweir #include "glob.hrc"
74cdf0e10cSrcweir #include "glob.hxx"
75cdf0e10cSrcweir #include "helpids.h"
76cdf0e10cSrcweir #include "anminfo.hxx"
77cdf0e10cSrcweir #include "undo/undomanager.hxx"
78cdf0e10cSrcweir #include "undo/undoobjects.hxx"
79cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
80cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx>
81cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx>
82cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx>
83cdf0e10cSrcweir #include <svx/unoapi.hxx>
84cdf0e10cSrcweir 
85cdf0e10cSrcweir #include <set>
86cdf0e10cSrcweir 
87cdf0e10cSrcweir using namespace ::sd;
88cdf0e10cSrcweir using namespace ::com::sun::star;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir TYPEINIT2( SdPage, FmFormPage, SdrObjUserCall );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir /*************************************************************************
93cdf0e10cSrcweir |*
94cdf0e10cSrcweir |*		Ctor
95cdf0e10cSrcweir |*
96cdf0e10cSrcweir \************************************************************************/
97cdf0e10cSrcweir 
SdPage(SdDrawDocument & rNewDoc,StarBASIC * pBasic,sal_Bool bMasterPage)98cdf0e10cSrcweir SdPage::SdPage(SdDrawDocument& rNewDoc, StarBASIC* pBasic, sal_Bool bMasterPage)
99cdf0e10cSrcweir :	FmFormPage(rNewDoc, pBasic, bMasterPage)
100cdf0e10cSrcweir ,	SdrObjUserCall()
101cdf0e10cSrcweir ,	mePageKind(PK_STANDARD)
102cdf0e10cSrcweir ,	meAutoLayout(AUTOLAYOUT_NONE)
103cdf0e10cSrcweir ,	mbSelected(sal_False)
104cdf0e10cSrcweir ,	mePresChange(PRESCHANGE_MANUAL)
105cdf0e10cSrcweir ,	mnTime(1)
106cdf0e10cSrcweir ,	mbSoundOn(sal_False)
107cdf0e10cSrcweir ,	mbExcluded(sal_False)
108cdf0e10cSrcweir ,   mbLoopSound(sal_False)
109cdf0e10cSrcweir ,	mbStopSound(sal_False)
110cdf0e10cSrcweir ,	mbScaleObjects(sal_True)
111cdf0e10cSrcweir ,	mbBackgroundFullSize( sal_False )
112cdf0e10cSrcweir ,	meCharSet(gsl_getSystemTextEncoding())
113cdf0e10cSrcweir ,	mnPaperBin(PAPERBIN_PRINTER_SETTINGS)
114cdf0e10cSrcweir ,	mpPageLink(NULL)
115cdf0e10cSrcweir ,	mpItems(NULL)
116cdf0e10cSrcweir ,	mnTransitionType(0)
117cdf0e10cSrcweir ,	mnTransitionSubtype(0)
118cdf0e10cSrcweir ,	mbTransitionDirection(sal_True)
119cdf0e10cSrcweir ,	mnTransitionFadeColor(0)
120cdf0e10cSrcweir ,	mfTransitionDuration(2.0)
121cdf0e10cSrcweir ,   mbIsPrecious(true)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	// Der Layoutname der Seite wird von SVDRAW benutzt, um die Praesentations-
124cdf0e10cSrcweir 	// vorlagen der Gliederungsobjekte zu ermitteln. Darum enthaelt er bereits
125cdf0e10cSrcweir 	// den Bezeichner fuer die Gliederung (STR_LAYOUT_OUTLINE).
126cdf0e10cSrcweir 	maLayoutName  = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
127cdf0e10cSrcweir 	maLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
128cdf0e10cSrcweir 	maLayoutName += String(SdResId(STR_LAYOUT_OUTLINE));
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	Size aPageSize(GetSize());
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	if (aPageSize.Width() > aPageSize.Height())
133cdf0e10cSrcweir 	{
134cdf0e10cSrcweir 		meOrientation = ORIENTATION_LANDSCAPE;
135cdf0e10cSrcweir 	}
136cdf0e10cSrcweir 	else
137cdf0e10cSrcweir 	{
138cdf0e10cSrcweir 		meOrientation = ORIENTATION_PORTRAIT;
139cdf0e10cSrcweir 	}
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir /*************************************************************************
143cdf0e10cSrcweir |*
144cdf0e10cSrcweir |* Dtor
145cdf0e10cSrcweir |*
146cdf0e10cSrcweir \************************************************************************/
147cdf0e10cSrcweir 
~SdPage()148cdf0e10cSrcweir SdPage::~SdPage()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	DisconnectLink();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	EndListenOutlineText();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	if( mpItems )
155cdf0e10cSrcweir 		delete mpItems;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir struct OrdNumSorter
159cdf0e10cSrcweir {
operator ()OrdNumSorter160cdf0e10cSrcweir 	bool operator()( SdrObject* p1, SdrObject* p2 )
161cdf0e10cSrcweir 	{
162cdf0e10cSrcweir 		return p1->GetOrdNum() < p2->GetOrdNum();
163cdf0e10cSrcweir 	}
164cdf0e10cSrcweir };
165cdf0e10cSrcweir 
166cdf0e10cSrcweir /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
GetPresObj(PresObjKind eObjKind,int nIndex,bool bFuzzySearch)167cdf0e10cSrcweir SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir 	// first sort all matching shapes with z-order
170cdf0e10cSrcweir 	std::vector< SdrObject* > aMatches;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	SdrObject* pObj = 0;
173cdf0e10cSrcweir 	while( (pObj = maPresentationShapeList.getNextShape(pObj)) != 0 )
174cdf0e10cSrcweir 	{
175cdf0e10cSrcweir 		SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
176cdf0e10cSrcweir 		if( pInfo )
177cdf0e10cSrcweir 		{
178cdf0e10cSrcweir 			bool bFound = false;
179cdf0e10cSrcweir 			if( pInfo->mePresObjKind == eObjKind )
180cdf0e10cSrcweir 			{
181cdf0e10cSrcweir 				bFound = true;
182cdf0e10cSrcweir 			}
183cdf0e10cSrcweir 			else if( bFuzzySearch && (eObjKind == PRESOBJ_OUTLINE) )
184cdf0e10cSrcweir 			{
185cdf0e10cSrcweir 				switch( pInfo->mePresObjKind )
186cdf0e10cSrcweir 				{
187cdf0e10cSrcweir 				case PRESOBJ_GRAPHIC:
188cdf0e10cSrcweir 				case PRESOBJ_OBJECT:
189cdf0e10cSrcweir 				case PRESOBJ_CHART:
190cdf0e10cSrcweir 				case PRESOBJ_ORGCHART:
191cdf0e10cSrcweir 				case PRESOBJ_TABLE:
192cdf0e10cSrcweir 				case PRESOBJ_CALC:
193cdf0e10cSrcweir 				case PRESOBJ_IMAGE:
194cdf0e10cSrcweir 				case PRESOBJ_MEDIA:
195cdf0e10cSrcweir 					bFound = sal_True;
196cdf0e10cSrcweir 					break;
197cdf0e10cSrcweir 				default:
198cdf0e10cSrcweir 					break;
199cdf0e10cSrcweir 				}
200cdf0e10cSrcweir 			}
201cdf0e10cSrcweir 			if( bFound )
202cdf0e10cSrcweir 			{
203cdf0e10cSrcweir 				aMatches.push_back( pObj );
204cdf0e10cSrcweir 			}
205cdf0e10cSrcweir 		}
206cdf0e10cSrcweir 	}
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	if( aMatches.size() > 1 )
209cdf0e10cSrcweir 	{
210cdf0e10cSrcweir 		OrdNumSorter aSortHelper;
211cdf0e10cSrcweir 		std::sort( aMatches.begin(), aMatches.end(), aSortHelper );
212cdf0e10cSrcweir 	}
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	if( nIndex > 0 )
215cdf0e10cSrcweir 		nIndex--;
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	if( (nIndex >= 0) && ( aMatches.size() > static_cast<unsigned int>(nIndex)) )
218cdf0e10cSrcweir 		return aMatches[nIndex];
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	return 0;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir /** create background properties */
EnsureMasterPageDefaultBackground()224cdf0e10cSrcweir void SdPage::EnsureMasterPageDefaultBackground()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	if(mbMaster)
227cdf0e10cSrcweir 	{
228cdf0e10cSrcweir 		// no hard attributes on MasterPage attributes
229cdf0e10cSrcweir         getSdrPageProperties().ClearItem();
230cdf0e10cSrcweir 		SfxStyleSheet* pSheetForPresObj = GetStyleSheetForMasterPageBackground();
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         if(pSheetForPresObj)
233cdf0e10cSrcweir         {
234cdf0e10cSrcweir             // set StyleSheet for background fill attributes
235cdf0e10cSrcweir             getSdrPageProperties().SetStyleSheet(pSheetForPresObj);
236cdf0e10cSrcweir         }
237cdf0e10cSrcweir         else
238cdf0e10cSrcweir         {
239cdf0e10cSrcweir             // no style found, assert and set at least XFILL_NONE
240cdf0e10cSrcweir             OSL_ENSURE(false, "No Style for MasterPageBackground fill found (!)");
241cdf0e10cSrcweir             getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE));
242cdf0e10cSrcweir         }
243cdf0e10cSrcweir 	}
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir /** creates a presentation object with the given PresObjKind on this page. A user call will be set
247cdf0e10cSrcweir */
CreatePresObj(PresObjKind eObjKind,sal_Bool bVertical,const Rectangle & rRect,sal_Bool)248cdf0e10cSrcweir SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, sal_Bool bVertical, const Rectangle& rRect, sal_Bool /* bInsert */ )
249cdf0e10cSrcweir {
250cdf0e10cSrcweir     ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
251cdf0e10cSrcweir 	const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 	SdrObject* pSdrObj = NULL;
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 	bool bForceText = false;	// forces the shape text to be set even if its empty
256cdf0e10cSrcweir 	bool bEmptyPresObj = true;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	switch( eObjKind )
259cdf0e10cSrcweir 	{
260cdf0e10cSrcweir 		case PRESOBJ_TITLE:
261cdf0e10cSrcweir 		{
262cdf0e10cSrcweir 			pSdrObj = new SdrRectObj(OBJ_TITLETEXT);
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 			if (mbMaster)
265cdf0e10cSrcweir 			{
266cdf0e10cSrcweir 				pSdrObj->SetNotVisibleAsMaster(sal_True);
267cdf0e10cSrcweir 			}
268cdf0e10cSrcweir 		}
269cdf0e10cSrcweir 		break;
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 		case PRESOBJ_OUTLINE:
272cdf0e10cSrcweir 		{
273cdf0e10cSrcweir 			pSdrObj = new SdrRectObj(OBJ_OUTLINETEXT);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 			if (mbMaster)
276cdf0e10cSrcweir 			{
277cdf0e10cSrcweir 				pSdrObj->SetNotVisibleAsMaster(sal_True);
278cdf0e10cSrcweir 			}
279cdf0e10cSrcweir 		}
280cdf0e10cSrcweir 		break;
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 		case PRESOBJ_NOTES:
283cdf0e10cSrcweir 		{
284cdf0e10cSrcweir 			pSdrObj = new SdrRectObj(OBJ_TEXT);
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 			if (mbMaster)
287cdf0e10cSrcweir 			{
288cdf0e10cSrcweir 				pSdrObj->SetNotVisibleAsMaster(sal_True);
289cdf0e10cSrcweir 			}
290cdf0e10cSrcweir 		}
291cdf0e10cSrcweir 		break;
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 		case PRESOBJ_TEXT:
294cdf0e10cSrcweir 		{
295cdf0e10cSrcweir 			pSdrObj = new SdrRectObj(OBJ_TEXT);
296cdf0e10cSrcweir 		}
297cdf0e10cSrcweir 		break;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 		case PRESOBJ_GRAPHIC:
300cdf0e10cSrcweir 		{
301cdf0e10cSrcweir 			BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_GRAPHIC ) );
302cdf0e10cSrcweir 			Graphic  aGraphic( aBmpEx );
303cdf0e10cSrcweir 			OutputDevice &aOutDev = *Application::GetDefaultDevice();
304cdf0e10cSrcweir 			aOutDev.Push();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 			aOutDev.SetMapMode( aGraphic.GetPrefMapMode() );
307cdf0e10cSrcweir 			Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() );
308cdf0e10cSrcweir 			aOutDev.SetMapMode(MAP_100TH_MM);
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 			Size aSize = aOutDev.PixelToLogic(aSizePix);
311cdf0e10cSrcweir 			Point aPnt (0, 0);
312cdf0e10cSrcweir 			Rectangle aRect (aPnt, aSize);
313cdf0e10cSrcweir 			pSdrObj = new SdrGrafObj(aGraphic, aRect);
314cdf0e10cSrcweir 			aOutDev.Pop();
315cdf0e10cSrcweir 		}
316cdf0e10cSrcweir 		break;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 		case PRESOBJ_MEDIA:
319cdf0e10cSrcweir 		case PRESOBJ_OBJECT:
320cdf0e10cSrcweir 		{
321cdf0e10cSrcweir 			pSdrObj = new SdrOle2Obj();
322cdf0e10cSrcweir 			BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_OBJECT ) );
323cdf0e10cSrcweir 			Graphic aGraphic( aBmpEx );
324cdf0e10cSrcweir 			( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
325cdf0e10cSrcweir 		}
326cdf0e10cSrcweir 		break;
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 		case PRESOBJ_CHART:
329cdf0e10cSrcweir 		{
330cdf0e10cSrcweir 			pSdrObj = new SdrOle2Obj();
331cdf0e10cSrcweir 			( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarChart" )));
332cdf0e10cSrcweir 			BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_CHART ) );
333cdf0e10cSrcweir 			Graphic aGraphic( aBmpEx );
334cdf0e10cSrcweir 			( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
335cdf0e10cSrcweir 		}
336cdf0e10cSrcweir 		break;
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 		case PRESOBJ_ORGCHART:
339cdf0e10cSrcweir 		{
340cdf0e10cSrcweir 			pSdrObj = new SdrOle2Obj();
341cdf0e10cSrcweir 			( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarOrg" )));
342cdf0e10cSrcweir 			BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_ORGCHART ) );
343cdf0e10cSrcweir 			Graphic aGraphic( aBmpEx );
344cdf0e10cSrcweir 			( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
345cdf0e10cSrcweir 		}
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 		case PRESOBJ_TABLE:
348cdf0e10cSrcweir 		case PRESOBJ_CALC:
349cdf0e10cSrcweir 		{
350cdf0e10cSrcweir 			pSdrObj = new SdrOle2Obj();
351cdf0e10cSrcweir 			( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarCalc" )));
352cdf0e10cSrcweir 			BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_TABLE ) );
353cdf0e10cSrcweir 			Graphic aGraphic( aBmpEx );
354cdf0e10cSrcweir 			( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
355cdf0e10cSrcweir 		}
356cdf0e10cSrcweir 		break;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 		case PRESOBJ_HANDOUT:
359cdf0e10cSrcweir 		{
360cdf0e10cSrcweir 			//Erste Standardseite am SdrPageObj vermerken
361cdf0e10cSrcweir             // #i105146# We want no content to be displayed for PK_HANDOUT,
362cdf0e10cSrcweir             // so just never set a page as content
363cdf0e10cSrcweir 			pSdrObj = new SdrPageObj(0);
364cdf0e10cSrcweir //			pSdrObj->SetResizeProtect(sal_True);
365cdf0e10cSrcweir 		}
366cdf0e10cSrcweir 		break;
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 		case PRESOBJ_PAGE:
369cdf0e10cSrcweir 		{
370cdf0e10cSrcweir 			//Notizseite am SdrPageObj vermerken
371cdf0e10cSrcweir 			sal_uInt16 nDestPageNum(GetPageNum());
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 			if(nDestPageNum)
374cdf0e10cSrcweir 			{
375cdf0e10cSrcweir 				// decrement only when != 0, else we get a 0xffff
376cdf0e10cSrcweir 				nDestPageNum -= 1;
377cdf0e10cSrcweir 			}
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 			if(nDestPageNum < pModel->GetPageCount())
380cdf0e10cSrcweir 			{
381cdf0e10cSrcweir 				pSdrObj = new SdrPageObj(pModel->GetPage(nDestPageNum));
382cdf0e10cSrcweir 			}
383cdf0e10cSrcweir 			else
384cdf0e10cSrcweir 			{
385cdf0e10cSrcweir 				pSdrObj = new SdrPageObj();
386cdf0e10cSrcweir 			}
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 			pSdrObj->SetResizeProtect(sal_True);
389cdf0e10cSrcweir 		}
390cdf0e10cSrcweir 		break;
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 		case PRESOBJ_HEADER:
393cdf0e10cSrcweir 		case PRESOBJ_FOOTER:
394cdf0e10cSrcweir 		case PRESOBJ_DATETIME:
395cdf0e10cSrcweir 		case PRESOBJ_SLIDENUMBER:
396cdf0e10cSrcweir 		{
397cdf0e10cSrcweir 			pSdrObj = new SdrRectObj(OBJ_TEXT);
398cdf0e10cSrcweir 			bEmptyPresObj = false;
399cdf0e10cSrcweir 			bForceText = true;
400cdf0e10cSrcweir 		}
401cdf0e10cSrcweir 		break;
402cdf0e10cSrcweir 		default:
403cdf0e10cSrcweir 			break;
404cdf0e10cSrcweir 	}
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	if (pSdrObj)
407cdf0e10cSrcweir 	{
408cdf0e10cSrcweir 		pSdrObj->SetEmptyPresObj(bEmptyPresObj);
409cdf0e10cSrcweir 		pSdrObj->SetLogicRect(rRect);
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 		InsertObject(pSdrObj);
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 		if ( pSdrObj->ISA(SdrTextObj) )
414cdf0e10cSrcweir 		{
415cdf0e10cSrcweir 			// #96243# Tell the object EARLY that it is vertical to have the
416cdf0e10cSrcweir 			// defaults for AutoGrowWidth/Height reversed
417cdf0e10cSrcweir 			if(bVertical)
418cdf0e10cSrcweir 				((SdrTextObj*)pSdrObj)->SetVerticalWriting(sal_True);
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 			SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
421cdf0e10cSrcweir 			if( bVertical )
422cdf0e10cSrcweir 				aTempAttr.Put( SdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
423cdf0e10cSrcweir 			else
424cdf0e10cSrcweir 				aTempAttr.Put( SdrTextMinFrameHeightItem( rRect.GetSize().Height() ) );
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 			if (mbMaster)
427cdf0e10cSrcweir 			{
428cdf0e10cSrcweir 				// Bei Praesentationsobjekten auf der MasterPage soll die
429cdf0e10cSrcweir 				// Groesse vom Benutzwer frei waehlbar sein
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 				// #96243# potential problem: This action was still NOT
432cdf0e10cSrcweir 				// adapted for vertical text. This sure needs to be done.
433cdf0e10cSrcweir 				if(bVertical)
434cdf0e10cSrcweir 					aTempAttr.Put(SdrTextAutoGrowWidthItem(sal_False));
435cdf0e10cSrcweir 				else
436cdf0e10cSrcweir 					aTempAttr.Put(SdrTextAutoGrowHeightItem(sal_False));
437cdf0e10cSrcweir 			}
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 			// check if we need another vertical adjustement than the default
440cdf0e10cSrcweir 			SdrTextVertAdjust eV = SDRTEXTVERTADJUST_TOP;
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 			if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind != PK_STANDARD) )
443cdf0e10cSrcweir 			{
444cdf0e10cSrcweir 				eV = SDRTEXTVERTADJUST_BOTTOM;
445cdf0e10cSrcweir 			}
446cdf0e10cSrcweir 			else if( (eObjKind == PRESOBJ_SLIDENUMBER) && (mePageKind != PK_STANDARD) )
447cdf0e10cSrcweir 			{
448cdf0e10cSrcweir 				eV = SDRTEXTVERTADJUST_BOTTOM;
449cdf0e10cSrcweir 			}
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 			if( eV != SDRTEXTVERTADJUST_TOP )
452cdf0e10cSrcweir 				aTempAttr.Put(SdrTextVertAdjustItem(eV));
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 			pSdrObj->SetMergedItemSet(aTempAttr);
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 			pSdrObj->SetLogicRect(rRect);
457cdf0e10cSrcweir 		}
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 		String aString = GetPresObjText(eObjKind);
460cdf0e10cSrcweir 		if( (aString.Len() || bForceText) && pSdrObj->ISA(SdrTextObj) )
461cdf0e10cSrcweir 		{
462cdf0e10cSrcweir 			SdrOutliner* pOutliner = ( (SdDrawDocument*) GetModel() )->GetInternalOutliner();
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 			sal_uInt16 nOutlMode = pOutliner->GetMode();
465cdf0e10cSrcweir 			pOutliner->Init( OUTLINERMODE_TEXTOBJECT );
466cdf0e10cSrcweir 			pOutliner->SetStyleSheet( 0, NULL );
467cdf0e10cSrcweir 			pOutliner->SetVertical( bVertical );
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 			String aEmptyStr;
470cdf0e10cSrcweir 			SetObjText( (SdrTextObj*) pSdrObj, (SdrOutliner*)pOutliner, eObjKind, aString );
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 			pOutliner->Init( nOutlMode );
473cdf0e10cSrcweir 			pOutliner->SetStyleSheet( 0, NULL );
474cdf0e10cSrcweir 		}
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 		if( (eObjKind == PRESOBJ_HEADER) || (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_DATETIME) )
477cdf0e10cSrcweir 		{
478cdf0e10cSrcweir 			SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
479cdf0e10cSrcweir 			aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
480cdf0e10cSrcweir 			aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
481cdf0e10cSrcweir 			aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 			SvxAdjust eH = SVX_ADJUST_LEFT;
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 			if( (eObjKind == PRESOBJ_DATETIME) && (mePageKind != PK_STANDARD ) )
486cdf0e10cSrcweir 			{
487cdf0e10cSrcweir 				eH = SVX_ADJUST_RIGHT;
488cdf0e10cSrcweir 			}
489cdf0e10cSrcweir 			else if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind == PK_STANDARD ) )
490cdf0e10cSrcweir 			{
491cdf0e10cSrcweir 				eH = SVX_ADJUST_CENTER;
492cdf0e10cSrcweir 			}
493cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_SLIDENUMBER )
494cdf0e10cSrcweir 			{
495cdf0e10cSrcweir 				eH = SVX_ADJUST_RIGHT;
496cdf0e10cSrcweir 			}
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 			if( eH != SVX_ADJUST_LEFT )
499cdf0e10cSrcweir                 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST ));
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 			pSdrObj->SetMergedItemSet(aTempAttr);
502cdf0e10cSrcweir 		}
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 		if (mbMaster)
505cdf0e10cSrcweir 		{
506cdf0e10cSrcweir 			SdrLayerAdmin& rLayerAdmin = pModel->GetLayerAdmin();
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 			// Hintergrundobjekte der MasterPage
509cdf0e10cSrcweir 			pSdrObj->SetLayer( rLayerAdmin.
510cdf0e10cSrcweir 				GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False) );
511cdf0e10cSrcweir 		}
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 		// Objekt am StyleSheet anmelden
514cdf0e10cSrcweir 		// #95114# Set style only when one was found (as in 5.2)
515cdf0e10cSrcweir 		// pSdrObj->NbcSetStyleSheet( GetStyleSheetForPresObj(eObjKind), sal_False );
516cdf0e10cSrcweir 		if( mePageKind != PK_HANDOUT )
517cdf0e10cSrcweir 		{
518cdf0e10cSrcweir 			SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind);
519cdf0e10cSrcweir 			if(pSheetForPresObj)
520cdf0e10cSrcweir 				pSdrObj->SetStyleSheet(pSheetForPresObj, sal_False);
521cdf0e10cSrcweir 		}
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 		if (eObjKind == PRESOBJ_OUTLINE)
524cdf0e10cSrcweir 		{
525cdf0e10cSrcweir 			for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
526cdf0e10cSrcweir 			{
527cdf0e10cSrcweir 				String aName(maLayoutName);
528cdf0e10cSrcweir 				aName += sal_Unicode( ' ' );
529cdf0e10cSrcweir 				aName += String::CreateFromInt32( nLevel );
530cdf0e10cSrcweir 				SfxStyleSheet* pSheet = (SfxStyleSheet*)pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
531cdf0e10cSrcweir 				DBG_ASSERT(pSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden");
532cdf0e10cSrcweir 				if (pSheet)
533cdf0e10cSrcweir 					pSdrObj->StartListening(*pSheet);
534cdf0e10cSrcweir 			}
535cdf0e10cSrcweir 		}
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 		if ( eObjKind == PRESOBJ_OBJECT   ||
538cdf0e10cSrcweir 			 eObjKind == PRESOBJ_CHART    ||
539cdf0e10cSrcweir 			 eObjKind == PRESOBJ_ORGCHART ||
540cdf0e10cSrcweir 			 eObjKind == PRESOBJ_CALC    ||
541cdf0e10cSrcweir 			 eObjKind == PRESOBJ_GRAPHIC )
542cdf0e10cSrcweir 		{
543cdf0e10cSrcweir 			SfxItemSet aSet( ((SdDrawDocument*) pModel)->GetPool() );
544cdf0e10cSrcweir 			aSet.Put( SdrTextContourFrameItem( sal_True ) );
545cdf0e10cSrcweir             aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 			pSdrObj->SetMergedItemSet(aSet);
548cdf0e10cSrcweir 		}
549cdf0e10cSrcweir 
550cdf0e10cSrcweir 		if( bUndo )
551cdf0e10cSrcweir 		{
552cdf0e10cSrcweir 			pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
553cdf0e10cSrcweir 		}
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 		if( bUndo )
556cdf0e10cSrcweir 		{
557cdf0e10cSrcweir 			pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pSdrObj ) );
558cdf0e10cSrcweir 			pUndoManager->AddUndoAction( new UndoObjectUserCall(*pSdrObj) );
559cdf0e10cSrcweir 		}
560cdf0e10cSrcweir 
561cdf0e10cSrcweir 		InsertPresObj(pSdrObj, eObjKind);
562cdf0e10cSrcweir 		pSdrObj->SetUserCall(this);
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 		pSdrObj->RecalcBoundRect();
565cdf0e10cSrcweir 	}
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 	return(pSdrObj);
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir /*************************************************************************
571cdf0e10cSrcweir |*
572cdf0e10cSrcweir |* Es werden Praesentationsobjekte auf der Page erzeugt.
573cdf0e10cSrcweir |* Alle Praesentationsobjekte erhalten einen UserCall auf die Page.
574cdf0e10cSrcweir |*
575cdf0e10cSrcweir \************************************************************************/
576cdf0e10cSrcweir 
GetStyleSheetForMasterPageBackground() const577cdf0e10cSrcweir SfxStyleSheet* SdPage::GetStyleSheetForMasterPageBackground() const
578cdf0e10cSrcweir {
579cdf0e10cSrcweir 	String aName(GetLayoutName());
580cdf0e10cSrcweir 	String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
581cdf0e10cSrcweir 	sal_uInt16 nPos = aName.Search(aSep);
582cdf0e10cSrcweir 
583cdf0e10cSrcweir     if (nPos != STRING_NOTFOUND)
584cdf0e10cSrcweir 	{
585cdf0e10cSrcweir 		nPos = nPos + aSep.Len();
586cdf0e10cSrcweir 		aName.Erase(nPos);
587cdf0e10cSrcweir 	}
588cdf0e10cSrcweir 
589cdf0e10cSrcweir     aName += String(SdResId(STR_LAYOUT_BACKGROUND));
590cdf0e10cSrcweir 
591cdf0e10cSrcweir     SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
592cdf0e10cSrcweir 	SfxStyleSheetBase*	   pResult	 = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
593cdf0e10cSrcweir 	return (SfxStyleSheet*)pResult;
594cdf0e10cSrcweir }
595cdf0e10cSrcweir 
GetStyleSheetForPresObj(PresObjKind eObjKind) const596cdf0e10cSrcweir SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const
597cdf0e10cSrcweir {
598cdf0e10cSrcweir 	String aName(GetLayoutName());
599cdf0e10cSrcweir 	String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
600cdf0e10cSrcweir 	sal_uInt16 nPos = aName.Search(aSep);
601cdf0e10cSrcweir 	if (nPos != STRING_NOTFOUND)
602cdf0e10cSrcweir 	{
603cdf0e10cSrcweir 		nPos = nPos + aSep.Len();
604cdf0e10cSrcweir 		aName.Erase(nPos);
605cdf0e10cSrcweir 	}
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 	switch (eObjKind)
608cdf0e10cSrcweir 	{
609cdf0e10cSrcweir 		case PRESOBJ_OUTLINE:
610cdf0e10cSrcweir 		{
611cdf0e10cSrcweir 			aName = GetLayoutName();
612cdf0e10cSrcweir 			aName += sal_Unicode( ' ' );
613cdf0e10cSrcweir 			aName += String::CreateFromInt32( 1 );
614cdf0e10cSrcweir 		}
615cdf0e10cSrcweir 		break;
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 		case PRESOBJ_TITLE:
618cdf0e10cSrcweir 			aName += String(SdResId(STR_LAYOUT_TITLE));
619cdf0e10cSrcweir 			break;
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 		case PRESOBJ_NOTES:
622cdf0e10cSrcweir 			aName += String(SdResId(STR_LAYOUT_NOTES));
623cdf0e10cSrcweir 			break;
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 		case PRESOBJ_TEXT:
626cdf0e10cSrcweir 			aName += String(SdResId(STR_LAYOUT_SUBTITLE));
627cdf0e10cSrcweir 			break;
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 		case PRESOBJ_HEADER:
630cdf0e10cSrcweir 		case PRESOBJ_FOOTER:
631cdf0e10cSrcweir 		case PRESOBJ_DATETIME:
632cdf0e10cSrcweir 		case PRESOBJ_SLIDENUMBER:
633cdf0e10cSrcweir 			aName += String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
634cdf0e10cSrcweir 			break;
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 		default:
637cdf0e10cSrcweir 			break;
638cdf0e10cSrcweir 	}
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 	SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
641cdf0e10cSrcweir 	SfxStyleSheetBase*	   pResult	 = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
642cdf0e10cSrcweir 	return (SfxStyleSheet*)pResult;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir 
645cdf0e10cSrcweir /** returns the presentation style with the given helpid from this masterpage or this
646cdf0e10cSrcweir 	slides masterpage */
getPresentationStyle(sal_uInt32 nHelpId) const647cdf0e10cSrcweir SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
648cdf0e10cSrcweir {
649cdf0e10cSrcweir 	String aStyleName( pPage->GetLayoutName() );
650cdf0e10cSrcweir 	const String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
651cdf0e10cSrcweir 	aStyleName.Erase(aStyleName.Search(aSep) + aSep.Len());
652cdf0e10cSrcweir 
653cdf0e10cSrcweir 	sal_uInt16 nNameId;
654cdf0e10cSrcweir 	switch( nHelpId )
655cdf0e10cSrcweir 	{
656cdf0e10cSrcweir 	case HID_PSEUDOSHEET_TITLE:				nNameId = STR_LAYOUT_TITLE; 			break;
657cdf0e10cSrcweir 	case HID_PSEUDOSHEET_SUBTITLE:	 		nNameId = STR_LAYOUT_SUBTITLE; 			break;
658cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE1:
659cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE2:
660cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE3:
661cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE4:
662cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE5:
663cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE6:
664cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE7:
665cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE8:
666cdf0e10cSrcweir 	case HID_PSEUDOSHEET_OUTLINE9:			nNameId = STR_LAYOUT_OUTLINE; 			break;
667cdf0e10cSrcweir 	case HID_PSEUDOSHEET_BACKGROUNDOBJECTS:	nNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break;
668cdf0e10cSrcweir 	case HID_PSEUDOSHEET_BACKGROUND:		nNameId = STR_LAYOUT_BACKGROUND; 		break;
669cdf0e10cSrcweir 	case HID_PSEUDOSHEET_NOTES:				nNameId = STR_LAYOUT_NOTES; 			break;
670cdf0e10cSrcweir 
671cdf0e10cSrcweir 	default:
672cdf0e10cSrcweir 		DBG_ERROR( "SdPage::getPresentationStyle(), illegal argument!" );
673cdf0e10cSrcweir 		return 0;
674cdf0e10cSrcweir 	}
675cdf0e10cSrcweir 	aStyleName.Append( String( SdResId( nNameId ) ) );
676cdf0e10cSrcweir 	if( nNameId == STR_LAYOUT_OUTLINE )
677cdf0e10cSrcweir 	{
678cdf0e10cSrcweir 		aStyleName.Append( sal_Unicode( ' ' ));
679cdf0e10cSrcweir 		aStyleName.Append( String::CreateFromInt32( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE )));
680cdf0e10cSrcweir 	}
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 	SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
683cdf0e10cSrcweir 	SfxStyleSheetBase*	   pResult	 = pStShPool->Find(aStyleName, SD_STYLE_FAMILY_MASTERPAGE);
684cdf0e10cSrcweir 	return dynamic_cast<SdStyleSheet*>(pResult);
685cdf0e10cSrcweir }
686cdf0e10cSrcweir 
687cdf0e10cSrcweir /*************************************************************************
688cdf0e10cSrcweir |*
689cdf0e10cSrcweir |* Das Praesentationsobjekt rObj hat sich geaendert und wird nicht mehr
690cdf0e10cSrcweir |* durch das Praesentationsobjekt der MasterPage referenziert.
691cdf0e10cSrcweir |* Der UserCall wird geloescht.
692cdf0e10cSrcweir |*
693cdf0e10cSrcweir \************************************************************************/
694cdf0e10cSrcweir 
Changed(const SdrObject & rObj,SdrUserCallType eType,const Rectangle &)695cdf0e10cSrcweir void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& )
696cdf0e10cSrcweir {
697cdf0e10cSrcweir 	if (!maLockAutoLayoutArrangement.isLocked())
698cdf0e10cSrcweir 	{
699cdf0e10cSrcweir 		switch (eType)
700cdf0e10cSrcweir 		{
701cdf0e10cSrcweir 			case SDRUSERCALL_MOVEONLY:
702cdf0e10cSrcweir 			case SDRUSERCALL_RESIZE:
703cdf0e10cSrcweir 			{
704cdf0e10cSrcweir 				if( pModel->isLocked() )
705cdf0e10cSrcweir 					break;
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 				SdrObject* pObj = (SdrObject*) &rObj;
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 				if (pObj)
710cdf0e10cSrcweir 				{
711cdf0e10cSrcweir 					if (!mbMaster)
712cdf0e10cSrcweir 					{
713cdf0e10cSrcweir 						if( pObj->GetUserCall() )
714cdf0e10cSrcweir 						{
715cdf0e10cSrcweir 							::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
716cdf0e10cSrcweir 							const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
717cdf0e10cSrcweir /*
718cdf0e10cSrcweir 							DBG_ASSERT( bUndo || (pUndoManager && pUndoManager->IsDoing()),
719cdf0e10cSrcweir 											"SdPage::Changed(), model change without undo!?" );
720cdf0e10cSrcweir */
721cdf0e10cSrcweir 							if( bUndo )
722cdf0e10cSrcweir 								pUndoManager->AddUndoAction( new UndoObjectUserCall(*pObj) );
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 							// Objekt was resized by user and does not listen to its slide anymore
725cdf0e10cSrcweir 							pObj->SetUserCall(0);
726cdf0e10cSrcweir 						}
727cdf0e10cSrcweir 					}
728cdf0e10cSrcweir 					else if (pModel)
729cdf0e10cSrcweir 					{
730cdf0e10cSrcweir 						// MasterPage-Objekt wurde veraendert, daher
731cdf0e10cSrcweir 						// Objekte auf allen Seiten anpassen
732cdf0e10cSrcweir 						sal_uInt16 nPageCount = ((SdDrawDocument*) pModel)->GetSdPageCount(mePageKind);
733cdf0e10cSrcweir 
734cdf0e10cSrcweir 						for (sal_uInt16 i = 0; i < nPageCount; i++)
735cdf0e10cSrcweir 						{
736cdf0e10cSrcweir 							SdPage* pLoopPage = ((SdDrawDocument*) pModel)->GetSdPage(i, mePageKind);
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 							if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
739cdf0e10cSrcweir 							{
740cdf0e10cSrcweir 								// Seite hoert auf diese MasterPage, daher
741cdf0e10cSrcweir 								// AutoLayout anpassen
742cdf0e10cSrcweir 								pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
743cdf0e10cSrcweir 							}
744cdf0e10cSrcweir 						}
745cdf0e10cSrcweir 					}
746cdf0e10cSrcweir 				}
747cdf0e10cSrcweir 			}
748cdf0e10cSrcweir 			break;
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 			case SDRUSERCALL_DELETE:
751cdf0e10cSrcweir 			case SDRUSERCALL_REMOVED:
752cdf0e10cSrcweir 			default:
753cdf0e10cSrcweir 				break;
754cdf0e10cSrcweir 		}
755cdf0e10cSrcweir 	}
756cdf0e10cSrcweir }
757cdf0e10cSrcweir 
758cdf0e10cSrcweir /*************************************************************************
759cdf0e10cSrcweir |*
760cdf0e10cSrcweir |* Erzeugt auf einer MasterPage Hintergrund, Titel- und Layout-Bereich
761cdf0e10cSrcweir |*
762cdf0e10cSrcweir \************************************************************************/
763cdf0e10cSrcweir 
CreateTitleAndLayout(sal_Bool bInit,sal_Bool bCreate)764cdf0e10cSrcweir void SdPage::CreateTitleAndLayout(sal_Bool bInit, sal_Bool bCreate )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir 	::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
767cdf0e10cSrcweir 	const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
768cdf0e10cSrcweir 
769cdf0e10cSrcweir 	SdPage* pMasterPage = this;
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 	if (!mbMaster)
772cdf0e10cSrcweir 	{
773cdf0e10cSrcweir 		pMasterPage = (SdPage*)(&(TRG_GetMasterPage()));
774cdf0e10cSrcweir 	}
775cdf0e10cSrcweir 
776cdf0e10cSrcweir 	if (!pMasterPage)
777cdf0e10cSrcweir 	{
778cdf0e10cSrcweir 		return;
779cdf0e10cSrcweir 	}
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 	/**************************************************************************
782cdf0e10cSrcweir 	* Hintergrund, Titel- und Layout-Bereich werden angelegt
783cdf0e10cSrcweir 	**************************************************************************/
784cdf0e10cSrcweir 	if( mePageKind == PK_STANDARD )
785cdf0e10cSrcweir 	{
786cdf0e10cSrcweir         pMasterPage->EnsureMasterPageDefaultBackground();
787cdf0e10cSrcweir 	}
788cdf0e10cSrcweir 
789cdf0e10cSrcweir 	if( ( (SdDrawDocument*) GetModel() )->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
790cdf0e10cSrcweir 	{
791cdf0e10cSrcweir 		if( mePageKind == PK_HANDOUT && bInit )
792cdf0e10cSrcweir 		{
793cdf0e10cSrcweir 			// handout template
794cdf0e10cSrcweir 
795cdf0e10cSrcweir 			// delete all available handout presentation objects
796191717ebSAndre Fischer 			SdrObject *pObj=NULL;
797cdf0e10cSrcweir 			while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != 0 )
798cdf0e10cSrcweir 			{
799191717ebSAndre Fischer 				pMasterPage->RemoveObject(pObj->GetOrdNum());
800191717ebSAndre Fischer 
801cdf0e10cSrcweir 				if( bUndo )
802191717ebSAndre Fischer 				{
803cdf0e10cSrcweir 					pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
804191717ebSAndre Fischer 				}
805191717ebSAndre Fischer                 else
806191717ebSAndre Fischer 				{
807191717ebSAndre Fischer 					SdrObject::Free( pObj );  // memory leak i120050
808191717ebSAndre Fischer 				}
809cdf0e10cSrcweir 			}
810cdf0e10cSrcweir 
811cdf0e10cSrcweir 			std::vector< Rectangle > aAreas;
812cdf0e10cSrcweir 			CalculateHandoutAreas( *static_cast< SdDrawDocument* >(GetModel() ), pMasterPage->GetAutoLayout(), false, aAreas );
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 			const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
815cdf0e10cSrcweir 			std::vector< Rectangle >::iterator iter( aAreas.begin() );
816cdf0e10cSrcweir 
817cdf0e10cSrcweir             while( iter != aAreas.end() )
818cdf0e10cSrcweir 			{
819cdf0e10cSrcweir 				SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, sal_False, (*iter++), sal_True) );
820cdf0e10cSrcweir                 // #i105146# We want no content to be displayed for PK_HANDOUT,
821cdf0e10cSrcweir                 // so just never set a page as content
822cdf0e10cSrcweir                 pPageObj->SetReferencedPage(0L);
823cdf0e10cSrcweir 
824cdf0e10cSrcweir 				if( bSkip && iter != aAreas.end() )
825cdf0e10cSrcweir 					iter++;
826cdf0e10cSrcweir 			}
827cdf0e10cSrcweir 		}
828cdf0e10cSrcweir 
829cdf0e10cSrcweir 		if( mePageKind != PK_HANDOUT )
830cdf0e10cSrcweir 		{
831cdf0e10cSrcweir 			SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE );
832cdf0e10cSrcweir 			if( pMasterTitle == NULL )
833cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE, true);
834cdf0e10cSrcweir 
835cdf0e10cSrcweir 			SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
836cdf0e10cSrcweir 			if( pMasterOutline == NULL )
837cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj( mePageKind == PK_STANDARD ? PRESOBJ_OUTLINE : PRESOBJ_NOTES, true );
838cdf0e10cSrcweir 		}
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 		// create header&footer objects
841cdf0e10cSrcweir 
842cdf0e10cSrcweir 		if( bCreate )
843cdf0e10cSrcweir 		{
844cdf0e10cSrcweir 			if( mePageKind != PK_STANDARD )
845cdf0e10cSrcweir 			{
846cdf0e10cSrcweir 				SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER );
847cdf0e10cSrcweir 				if( pHeader == NULL )
848cdf0e10cSrcweir 					pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER, true );
849cdf0e10cSrcweir 			}
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 			SdrObject* pDate   = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
852cdf0e10cSrcweir 			if( pDate == NULL )
853cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME, true );
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 			SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
856cdf0e10cSrcweir 			if( pFooter == NULL )
857cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER, true );
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 			SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
860cdf0e10cSrcweir 			if( pNumber == NULL )
861cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER, true );
862cdf0e10cSrcweir 		}
863cdf0e10cSrcweir 	}
864cdf0e10cSrcweir }
865cdf0e10cSrcweir 
CreateDefaultPresObj(PresObjKind eObjKind,bool bInsert)866cdf0e10cSrcweir SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
867cdf0e10cSrcweir {
868cdf0e10cSrcweir 	if( eObjKind == PRESOBJ_TITLE )
869cdf0e10cSrcweir 	{
870cdf0e10cSrcweir 		Rectangle aTitleRect( GetTitleRect() );
871cdf0e10cSrcweir 		return CreatePresObj(PRESOBJ_TITLE, sal_False, aTitleRect, bInsert);
872cdf0e10cSrcweir 	}
873cdf0e10cSrcweir 	else if( eObjKind == PRESOBJ_OUTLINE )
874cdf0e10cSrcweir 	{
875cdf0e10cSrcweir 		Rectangle aLayoutRect( GetLayoutRect() );
876cdf0e10cSrcweir 		return CreatePresObj( PRESOBJ_OUTLINE, sal_False, aLayoutRect, bInsert);
877cdf0e10cSrcweir 	}
878cdf0e10cSrcweir 	else if( eObjKind == PRESOBJ_NOTES )
879cdf0e10cSrcweir 	{
880cdf0e10cSrcweir 		Rectangle aLayoutRect( GetLayoutRect() );
881cdf0e10cSrcweir 		return CreatePresObj( PRESOBJ_NOTES, sal_False, aLayoutRect, bInsert);
882cdf0e10cSrcweir 	}
883cdf0e10cSrcweir 	else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) )
884cdf0e10cSrcweir 	{
885cdf0e10cSrcweir 		// create footer objects for standard master page
886cdf0e10cSrcweir 		if( mePageKind == PK_STANDARD )
887cdf0e10cSrcweir 		{
888cdf0e10cSrcweir 			const long nLftBorder = GetLftBorder();
889cdf0e10cSrcweir 			const long nUppBorder = GetUppBorder();
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 			Point aTitlePos ( nLftBorder, nUppBorder );
892cdf0e10cSrcweir 			Size aPageSize ( GetSize() );
893cdf0e10cSrcweir 			aPageSize.Width()  -= nLftBorder + GetRgtBorder();
894cdf0e10cSrcweir 			aPageSize.Height() -= nUppBorder + GetLwrBorder();
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 			const int Y = long(nUppBorder + aPageSize.Height() * 0.911);
897cdf0e10cSrcweir 			const int W1 = long(aPageSize.Width() * 0.233);
898cdf0e10cSrcweir 			const int W2 = long(aPageSize.Width() * 0.317);
899cdf0e10cSrcweir 			const int H = long(aPageSize.Height() * 0.069);
900cdf0e10cSrcweir 
901cdf0e10cSrcweir 			if( eObjKind == PRESOBJ_DATETIME )
902cdf0e10cSrcweir 			{
903cdf0e10cSrcweir 				Point aPos( long(nLftBorder+(aPageSize.Width()*0.05)), Y );
904cdf0e10cSrcweir 				Size aSize( W1, H );
905cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
906cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert );
907cdf0e10cSrcweir 			}
908cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_FOOTER )
909cdf0e10cSrcweir 			{
910cdf0e10cSrcweir 				Point aPos( long(nLftBorder+ aPageSize.Width() * 0.342), Y );
911cdf0e10cSrcweir 				Size aSize( W2, H );
912cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
913cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert );
914cdf0e10cSrcweir 			}
915cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_SLIDENUMBER )
916cdf0e10cSrcweir 			{
917cdf0e10cSrcweir 				Point aPos( long(nLftBorder+(aPageSize.Width()*0.717)), Y );
918cdf0e10cSrcweir 				Size aSize( W1, H );
919cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
920cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert );
921cdf0e10cSrcweir 			}
922cdf0e10cSrcweir 			else
923cdf0e10cSrcweir 			{
924cdf0e10cSrcweir 				DBG_ERROR( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a slide master" );
925cdf0e10cSrcweir 				return NULL;
926cdf0e10cSrcweir 			}
927cdf0e10cSrcweir 		}
928cdf0e10cSrcweir 		else
929cdf0e10cSrcweir 		{
930cdf0e10cSrcweir 			// create header&footer objects for handout and notes master
931cdf0e10cSrcweir 			Point aTitlePos ( GetLftBorder(), GetUppBorder() );
932cdf0e10cSrcweir 			Size aPageSize ( GetSize() );
933cdf0e10cSrcweir 			aPageSize.Width()  -= GetLftBorder() + GetRgtBorder();
934cdf0e10cSrcweir 			aPageSize.Height() -= GetUppBorder() + GetLwrBorder();
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 
937cdf0e10cSrcweir 			const int NOTES_HEADER_FOOTER_WIDTH = long(aPageSize.Width() * 0.434);
938cdf0e10cSrcweir 			const int NOTES_HEADER_FOOTER_HEIGHT = long(aPageSize.Height() * 0.05);
939cdf0e10cSrcweir 
940cdf0e10cSrcweir 			Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 			const int X1 = GetLftBorder();
943cdf0e10cSrcweir 			const int X2 = GetLftBorder() + long(aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH);
944cdf0e10cSrcweir 			const int Y1 = GetUppBorder();
945cdf0e10cSrcweir 			const int Y2 = GetUppBorder() + long(aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT );
946cdf0e10cSrcweir 
947cdf0e10cSrcweir 			if( eObjKind == PRESOBJ_HEADER )
948cdf0e10cSrcweir 			{
949cdf0e10cSrcweir 				Point aPos( X1, Y1 );
950cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
951cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_HEADER, sal_False, aRect, bInsert );
952cdf0e10cSrcweir 			}
953cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_DATETIME )
954cdf0e10cSrcweir 			{
955cdf0e10cSrcweir 				Point aPos( X2, Y1 );
956cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
957cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert );
958cdf0e10cSrcweir 			}
959cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_FOOTER )
960cdf0e10cSrcweir 			{
961cdf0e10cSrcweir 				Point aPos( X1, Y2 );
962cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
963cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert );
964cdf0e10cSrcweir 			}
965cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_SLIDENUMBER )
966cdf0e10cSrcweir 			{
967cdf0e10cSrcweir 				Point aPos( X2, Y2 );
968cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
969cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert );
970cdf0e10cSrcweir 			}
971cdf0e10cSrcweir 
972cdf0e10cSrcweir 			DBG_ERROR("SdPage::CreateDefaultPresObj() - this should not happen!");
973cdf0e10cSrcweir 			return NULL;
974cdf0e10cSrcweir 		}
975cdf0e10cSrcweir 	}
976cdf0e10cSrcweir 	else
977cdf0e10cSrcweir 	{
978cdf0e10cSrcweir 		DBG_ERROR("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
979cdf0e10cSrcweir 		return NULL;
980cdf0e10cSrcweir 	}
981cdf0e10cSrcweir }
982cdf0e10cSrcweir 
983cdf0e10cSrcweir /*************************************************************************
984cdf0e10cSrcweir |*
985cdf0e10cSrcweir |* Titelbereich zurueckgeben
986cdf0e10cSrcweir |*
987cdf0e10cSrcweir \************************************************************************/
988cdf0e10cSrcweir 
GetTitleRect() const989cdf0e10cSrcweir Rectangle SdPage::GetTitleRect() const
990cdf0e10cSrcweir {
991cdf0e10cSrcweir 	Rectangle aTitleRect;
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 	if (mePageKind != PK_HANDOUT)
994cdf0e10cSrcweir 	{
995cdf0e10cSrcweir 		/******************************************************************
996cdf0e10cSrcweir 		* Standard- oder Notiz-Seite: Titelbereich
997cdf0e10cSrcweir 		******************************************************************/
998cdf0e10cSrcweir 		Point aTitlePos ( GetLftBorder(), GetUppBorder() );
999cdf0e10cSrcweir 		Size aTitleSize ( GetSize() );
1000cdf0e10cSrcweir 		aTitleSize.Width()  -= GetLftBorder() + GetRgtBorder();
1001cdf0e10cSrcweir 		aTitleSize.Height() -= GetUppBorder() + GetLwrBorder();
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 		if (mePageKind == PK_STANDARD)
1004cdf0e10cSrcweir 		{
1005cdf0e10cSrcweir 			aTitlePos.X() += long( aTitleSize.Width() * 0.05 );
1006cdf0e10cSrcweir 			aTitlePos.Y() += long( aTitleSize.Height() * 0.0399 );
1007cdf0e10cSrcweir 			aTitleSize.Width() = long( aTitleSize.Width() * 0.9 );
1008cdf0e10cSrcweir 			aTitleSize.Height() = long( aTitleSize.Height() * 0.167 );
1009cdf0e10cSrcweir 		}
1010cdf0e10cSrcweir 		else if (mePageKind == PK_NOTES)
1011cdf0e10cSrcweir 		{
1012cdf0e10cSrcweir 			Point aPos = aTitlePos;
1013cdf0e10cSrcweir 			aPos.Y() += long( aTitleSize.Height() * 0.076 );
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir 			// Hoehe beschraenken
1016cdf0e10cSrcweir 			aTitleSize.Height() = (long) (aTitleSize.Height() * 0.375);
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir 			Size aPartArea = aTitleSize;
1019cdf0e10cSrcweir 			Size aSize;
1020cdf0e10cSrcweir 			sal_uInt16 nDestPageNum(GetPageNum());
1021cdf0e10cSrcweir 			SdrPage* pRefPage = 0L;
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 			if(nDestPageNum)
1024cdf0e10cSrcweir 			{
1025cdf0e10cSrcweir 				// only decrement if != 0, else we get 0xffff
1026cdf0e10cSrcweir 				nDestPageNum -= 1;
1027cdf0e10cSrcweir 			}
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 			if(nDestPageNum < pModel->GetPageCount())
1030cdf0e10cSrcweir 			{
1031cdf0e10cSrcweir 				pRefPage = pModel->GetPage(nDestPageNum);
1032cdf0e10cSrcweir 			}
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir 			if ( pRefPage )
1035cdf0e10cSrcweir 			{
1036cdf0e10cSrcweir 				// tatsaechliche Seitengroesse in das Handout-Rechteck skalieren
1037cdf0e10cSrcweir 				double fH = (double) aPartArea.Width()  / pRefPage->GetWdt();
1038cdf0e10cSrcweir 				double fV = (double) aPartArea.Height() / pRefPage->GetHgt();
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir 				if ( fH > fV )
1041cdf0e10cSrcweir 					fH = fV;
1042cdf0e10cSrcweir 				aSize.Width()  = (long) (fH * pRefPage->GetWdt());
1043cdf0e10cSrcweir 				aSize.Height() = (long) (fH * pRefPage->GetHgt());
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir 				aPos.X() += (aPartArea.Width() - aSize.Width()) / 2;
1046cdf0e10cSrcweir 				aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2;
1047cdf0e10cSrcweir 			}
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 			aTitlePos = aPos;
1050cdf0e10cSrcweir 			aTitleSize = aSize;
1051cdf0e10cSrcweir 		}
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir 		aTitleRect.SetPos(aTitlePos);
1054cdf0e10cSrcweir 		aTitleRect.SetSize(aTitleSize);
1055cdf0e10cSrcweir 	}
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 	return aTitleRect;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir /*************************************************************************
1062cdf0e10cSrcweir |*
1063cdf0e10cSrcweir |* Gliederungsbereich zurueckgeben
1064cdf0e10cSrcweir |*
1065cdf0e10cSrcweir \************************************************************************/
1066cdf0e10cSrcweir 
GetLayoutRect() const1067cdf0e10cSrcweir Rectangle SdPage::GetLayoutRect() const
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir 	Rectangle aLayoutRect;
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir 	if (mePageKind != PK_HANDOUT)
1072cdf0e10cSrcweir 	{
1073cdf0e10cSrcweir 		Point aLayoutPos ( GetLftBorder(), GetUppBorder() );
1074cdf0e10cSrcweir 		Size aLayoutSize ( GetSize() );
1075cdf0e10cSrcweir 		aLayoutSize.Width()  -= GetLftBorder() + GetRgtBorder();
1076cdf0e10cSrcweir 		aLayoutSize.Height() -= GetUppBorder() + GetLwrBorder();
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 		if (mePageKind == PK_STANDARD)
1079cdf0e10cSrcweir 		{
1080cdf0e10cSrcweir 			aLayoutPos.X() += long( aLayoutSize.Width() * 0.05 );
1081cdf0e10cSrcweir 			aLayoutPos.Y() += long( aLayoutSize.Height() * 0.234 );
1082cdf0e10cSrcweir 			aLayoutSize.Width() = long( aLayoutSize.Width() * 0.9 );
1083cdf0e10cSrcweir 			aLayoutSize.Height() = long( aLayoutSize.Height() * 0.66 );
1084cdf0e10cSrcweir 			aLayoutRect.SetPos(aLayoutPos);
1085cdf0e10cSrcweir 			aLayoutRect.SetSize(aLayoutSize);
1086cdf0e10cSrcweir 		}
1087cdf0e10cSrcweir 		else if (mePageKind == PK_NOTES)
1088cdf0e10cSrcweir 		{
1089cdf0e10cSrcweir 			aLayoutPos.X() += long( aLayoutSize.Width() * 0.1 );
1090cdf0e10cSrcweir 			aLayoutPos.Y() += long( aLayoutSize.Height() * 0.475 );
1091cdf0e10cSrcweir 			aLayoutSize.Width() = long( aLayoutSize.Width() * 0.8 );
1092cdf0e10cSrcweir 			aLayoutSize.Height() = long( aLayoutSize.Height() * 0.45 );
1093cdf0e10cSrcweir 			aLayoutRect.SetPos(aLayoutPos);
1094cdf0e10cSrcweir 			aLayoutRect.SetSize(aLayoutSize);
1095cdf0e10cSrcweir 		}
1096cdf0e10cSrcweir 	}
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 	return aLayoutRect;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir /**************************************************************************
1103cdf0e10cSrcweir |*
1104cdf0e10cSrcweir |* Diese Methode weist ein AutoLayout zu
1105cdf0e10cSrcweir |*
1106cdf0e10cSrcweir \*************************************************************************/
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir const int MAX_PRESOBJS = 7;	// maximum number of presentation objects per layout
1109cdf0e10cSrcweir const int VERTICAL = 0x8000;
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir struct LayoutDescriptor
1112cdf0e10cSrcweir {
1113cdf0e10cSrcweir 	int mnLayout;
1114cdf0e10cSrcweir 	PresObjKind meKind[MAX_PRESOBJS];
1115cdf0e10cSrcweir 	bool mbVertical[MAX_PRESOBJS];
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 	LayoutDescriptor( int nLayout, int k0 = 0, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0, int k5 = 0, int k6 = 0 );
1118cdf0e10cSrcweir };
1119cdf0e10cSrcweir 
LayoutDescriptor(int nLayout,int k0,int k1,int k2,int k3,int k4,int k5,int k6)1120cdf0e10cSrcweir LayoutDescriptor::LayoutDescriptor( int nLayout, int k0, int k1, int k2, int k3, int k4, int k5, int k6 )
1121cdf0e10cSrcweir : mnLayout( nLayout )
1122cdf0e10cSrcweir {
1123cdf0e10cSrcweir 	meKind[0] = static_cast<PresObjKind>(k0 & (~VERTICAL)); mbVertical[0] = (k0 & VERTICAL) == VERTICAL;
1124cdf0e10cSrcweir 	meKind[1] = static_cast<PresObjKind>(k1 & (~VERTICAL)); mbVertical[1] = (k1 & VERTICAL) == VERTICAL;
1125cdf0e10cSrcweir 	meKind[2] = static_cast<PresObjKind>(k2 & (~VERTICAL)); mbVertical[2] = (k2 & VERTICAL) == VERTICAL;
1126cdf0e10cSrcweir 	meKind[3] = static_cast<PresObjKind>(k3 & (~VERTICAL)); mbVertical[3] = (k3 & VERTICAL) == VERTICAL;
1127cdf0e10cSrcweir 	meKind[4] = static_cast<PresObjKind>(k4 & (~VERTICAL)); mbVertical[4] = (k4 & VERTICAL) == VERTICAL;
1128cdf0e10cSrcweir     meKind[5] = static_cast<PresObjKind>(k5 & (~VERTICAL)); mbVertical[5] = (k5 & VERTICAL) == VERTICAL;
1129cdf0e10cSrcweir 	meKind[6] = static_cast<PresObjKind>(k6 & (~VERTICAL)); mbVertical[6] = (k6	& VERTICAL) == VERTICAL;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
GetLayoutDescriptor(AutoLayout eLayout)1132cdf0e10cSrcweir static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir 	static LayoutDescriptor aLayouts[AUTOLAYOUT__END-AUTOLAYOUT__START] =
1135cdf0e10cSrcweir 	{
1136cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_TEXT ),									// AUTOLAYOUT_TITLE
1137cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),								// AUTOLAYOUT_ENUM
1138cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),								// AUTOLAYOUT_CHART
1139cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_2TEXT
1140cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTCHART
1141cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),								// AUTOLAYOUT_ORG
1142cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTCLbIP
1143cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_CHARTTEXT
1144cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),								// AUTOLAYOUT_TAB
1145cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_CLIPTEXT
1146cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTOBJ
1147cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OBJECT ),								// AUTOLAYOUT_OBJ
1148cdf0e10cSrcweir 		LayoutDescriptor( 2, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),	// AUTOLAYOUT_TEXT2OBJ
1149cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTOBJ
1150cdf0e10cSrcweir 		LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_OBJOVERTEXT
1151cdf0e10cSrcweir 		LayoutDescriptor( 3, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),	// AUTOLAYOUT_2OBJTEXT
1152cdf0e10cSrcweir 		LayoutDescriptor( 5, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),	// AUTOLAYOUT_2OBJOVERTEXT
1153cdf0e10cSrcweir 		LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTOVEROBJ
1154cdf0e10cSrcweir 		LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,					// AUTOLAYOUT_4OBJ
1155cdf0e10cSrcweir 			PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),
1156cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_NONE ),									// AUTOLAYOUT_ONLY_TITLE
1157cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_NONE ),												// AUTOLAYOUT_NONE
1158cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_PAGE, PRESOBJ_NOTES ),									// AUTOLAYOUT_NOTES
1159cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT1
1160cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT2
1161cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT3
1162cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT4
1163cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT6
1164cdf0e10cSrcweir 		LayoutDescriptor( 7, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE ),// AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
1165cdf0e10cSrcweir 		LayoutDescriptor( 8, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ),			// AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
1166cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL ),						// AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
1167cdf0e10cSrcweir 		LayoutDescriptor( 9, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ),	// AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
1168cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT9
1169cdf0e10cSrcweir         LayoutDescriptor( 10, PRESOBJ_TEXT, PRESOBJ_NONE ),                                 // AUTOLAYOUT_ONLY_TEXT
1170cdf0e10cSrcweir         LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,			    // AUTOLAYOUT_4CLIPART
1171cdf0e10cSrcweir 			PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC ),
1172cdf0e10cSrcweir         LayoutDescriptor( 11, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,				// AUTOLAYOUT_6CLIPART
1173cdf0e10cSrcweir             PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE )
1174cdf0e10cSrcweir 	};
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir 	if( (eLayout < AUTOLAYOUT__START) || (eLayout >= AUTOLAYOUT__END) )
1177cdf0e10cSrcweir 		eLayout = AUTOLAYOUT_NONE;
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir 	return aLayouts[ eLayout - AUTOLAYOUT__START ];
1180cdf0e10cSrcweir }
1181cdf0e10cSrcweir 
CalcAutoLayoutRectangles(SdPage & rPage,int nLayout,Rectangle * rRectangle)1182cdf0e10cSrcweir static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRectangle )
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir 	Rectangle aTitleRect;
1185cdf0e10cSrcweir 	Rectangle aLayoutRect;
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 	if( rPage.GetPageKind() != PK_HANDOUT )
1188cdf0e10cSrcweir 	{
1189cdf0e10cSrcweir 		SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage());
1190cdf0e10cSrcweir 		SdrObject* pMasterTitle = rMasterPage.GetPresObj( PRESOBJ_TITLE );
1191634584e4SZhe Wang 		SdrObject* pMasterSubTitle = rMasterPage.GetPresObj( PRESOBJ_TEXT );
1192cdf0e10cSrcweir 		SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir 		if( pMasterTitle )
1195cdf0e10cSrcweir 			aTitleRect = pMasterTitle->GetLogicRect();
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir 		if (aTitleRect.IsEmpty() )
1198cdf0e10cSrcweir 			aTitleRect = rPage.GetTitleRect();
1199634584e4SZhe Wang 		if( pMasterSubTitle )
1200634584e4SZhe Wang 			aLayoutRect = pMasterSubTitle->GetLogicRect();
1201634584e4SZhe Wang 		else if( pMasterOutline )
1202cdf0e10cSrcweir 			aLayoutRect = pMasterOutline->GetLogicRect();
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 		if (aLayoutRect.IsEmpty() )
1205cdf0e10cSrcweir 			aLayoutRect = rPage.GetLayoutRect();
1206cdf0e10cSrcweir 	}
1207cdf0e10cSrcweir 
1208cdf0e10cSrcweir 	rRectangle[0] = aTitleRect;
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir 	int i;
1211cdf0e10cSrcweir 	for( i = 1; i < MAX_PRESOBJS; i++ )
1212cdf0e10cSrcweir 		rRectangle[i] = aLayoutRect;
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir 	Size        aTitleSize( aTitleRect.GetSize() );
1215cdf0e10cSrcweir 	Point       aTitlePos( aTitleRect.TopLeft() );
1216cdf0e10cSrcweir 	Size        aLayoutSize( aLayoutRect.GetSize() );
1217cdf0e10cSrcweir 	Point       aLayoutPos( aLayoutRect.TopLeft() );
1218cdf0e10cSrcweir 	Size        aTempSize;
1219cdf0e10cSrcweir 	Point       aTempPnt;
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir     sal_Bool    bRightToLeft = ( rPage.GetModel() && static_cast< SdDrawDocument* >( rPage.GetModel() )->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB );
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 	switch( nLayout )
1224cdf0e10cSrcweir 	{
1225cdf0e10cSrcweir 	case 0: // default layout using only the title and layout area
1226cdf0e10cSrcweir 		break; // do nothing
1227cdf0e10cSrcweir 	case 1: // title, 2 shapes
1228cdf0e10cSrcweir 	case 9: // title, 2 vertical shapes
1229cdf0e10cSrcweir 		aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.488);
1230cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir 		aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1233cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir         if( bRightToLeft && (nLayout != 9) )
1236cdf0e10cSrcweir             ::std::swap< Rectangle >( rRectangle[1], rRectangle[2] );
1237cdf0e10cSrcweir 		break;
1238cdf0e10cSrcweir 	case 2: // title, shape, 2 shapes
1239cdf0e10cSrcweir 		aTempPnt = aLayoutPos;
1240cdf0e10cSrcweir 		aTempSize = aLayoutSize;
1241cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1242cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1243cdf0e10cSrcweir 		aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1244cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1247cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir 		aLayoutPos = aTempPnt;
1250cdf0e10cSrcweir 		aLayoutSize = aTempSize;
1251cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1252cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir 		if( bRightToLeft )
1255cdf0e10cSrcweir 		{
1256cdf0e10cSrcweir 			::std::swap< long >( rRectangle[1].Left(), rRectangle[2].Left() );
1257cdf0e10cSrcweir 			rRectangle[3].Left() = rRectangle[2].Left();
1258cdf0e10cSrcweir 		}
1259cdf0e10cSrcweir 		break;
1260cdf0e10cSrcweir 	case 3: // title, 2 shapes, shape
1261cdf0e10cSrcweir 		aTempPnt = aLayoutPos;
1262cdf0e10cSrcweir 		aTempSize = aLayoutSize;
1263cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1264cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1265cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1268cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir 		aLayoutPos = aTempPnt;
1271cdf0e10cSrcweir 		aLayoutSize = aTempSize;
1272cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1273cdf0e10cSrcweir 		aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1274cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir         if( bRightToLeft )
1277cdf0e10cSrcweir         {
1278cdf0e10cSrcweir             ::std::swap< long >( rRectangle[1].Left(), rRectangle[2].Left() );
1279cdf0e10cSrcweir             rRectangle[3].Left() = rRectangle[2].Left();
1280cdf0e10cSrcweir         }
1281cdf0e10cSrcweir 		break;
1282cdf0e10cSrcweir 	case 4: // title, shape above shape
1283cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1284cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1285cdf0e10cSrcweir 
1286cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1287cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1288cdf0e10cSrcweir 		break;
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir 	case 5: // title, 2 shapes above shape
1291cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1292cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1293cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir 		aTempPnt = aLayoutPos;
1296cdf0e10cSrcweir 		aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1297cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir 		aLayoutPos.X() = aTempPnt.X();
1300cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1301cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() / 0.488);
1302cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1303cdf0e10cSrcweir 		break;
1304cdf0e10cSrcweir 	case 6: // title, 4 shapes
1305cdf0e10cSrcweir 	{
1306cdf0e10cSrcweir 		sal_uLong nX = long (aLayoutPos.X());
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1309cdf0e10cSrcweir 		aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.488);
1310cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1311cdf0e10cSrcweir 
1312cdf0e10cSrcweir 		aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1313cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1316cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir 		aLayoutPos.X() = nX;
1319cdf0e10cSrcweir 		rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
1320cdf0e10cSrcweir 		break;
1321cdf0e10cSrcweir 	}
1322cdf0e10cSrcweir 	case 7: // vertical title, shape above shape
1323cdf0e10cSrcweir 	{
1324cdf0e10cSrcweir 		Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1325cdf0e10cSrcweir 		rRectangle[0].SetSize( aSize );
1326cdf0e10cSrcweir 		rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir 		Size aPageSize ( rPage.GetSize() );
1329cdf0e10cSrcweir 		aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
1330cdf0e10cSrcweir 		aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
1331cdf0e10cSrcweir 		aSize.Width() = long( aPageSize.Width() * 0.7 );
1332cdf0e10cSrcweir 		rRectangle[1].SetPos( aTitleRect.TopLeft() );
1333cdf0e10cSrcweir 		rRectangle[1].SetSize( aSize );
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir 		aSize.Height() = rRectangle[0].GetSize().Height();
1336cdf0e10cSrcweir 		Point aPos( aTitleRect.TopLeft() );
1337cdf0e10cSrcweir 		aPos.Y() += long ( aSize.Height() * 0.53 );
1338cdf0e10cSrcweir 		rRectangle[2].SetPos( aPos );
1339cdf0e10cSrcweir 		aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
1340cdf0e10cSrcweir 		rRectangle[2].SetSize( aSize );
1341cdf0e10cSrcweir 		break;
1342cdf0e10cSrcweir 	}
1343cdf0e10cSrcweir 	case 8: // vertical title, shape
1344cdf0e10cSrcweir 	{
1345cdf0e10cSrcweir 		Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1346cdf0e10cSrcweir 		rRectangle[0].SetSize( aSize );
1347cdf0e10cSrcweir 		rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 		Size aPageSize ( rPage.GetSize() );
1350cdf0e10cSrcweir 		aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
1351cdf0e10cSrcweir 		aSize.Height() = rRectangle[0].GetSize().Height();
1352cdf0e10cSrcweir 		aSize.Width() = long( aPageSize.Width() * 0.7 );
1353cdf0e10cSrcweir 		rRectangle[1].SetPos( aTitleRect.TopLeft() );
1354cdf0e10cSrcweir 		rRectangle[1].SetSize( aSize );
1355cdf0e10cSrcweir 		break;
1356cdf0e10cSrcweir 	}
1357cdf0e10cSrcweir     case 10: // onlytext
1358cdf0e10cSrcweir     {
1359cdf0e10cSrcweir         Size aSize( rRectangle[0].GetSize().Width(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1360cdf0e10cSrcweir 		rRectangle[0].SetSize( aSize );
1361cdf0e10cSrcweir 		rRectangle[0].SetPos( aTitlePos);
1362cdf0e10cSrcweir 		break;
1363cdf0e10cSrcweir     }
1364cdf0e10cSrcweir     case 11: // title, 6 shapes
1365cdf0e10cSrcweir 	{
1366cdf0e10cSrcweir 		sal_uLong nX = long (aLayoutPos.X());
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1369cdf0e10cSrcweir 		aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.322);
1370cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir 		aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1373cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 		aLayoutPos.X() = long (nX + aLayoutSize.Width() * 2 * 1.05);
1376cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1379cdf0e10cSrcweir 		rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir 		aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1382cdf0e10cSrcweir 		rRectangle[5] = Rectangle (aLayoutPos, aLayoutSize);
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir 		aLayoutPos.X() = nX;
1385cdf0e10cSrcweir 		rRectangle[6] = Rectangle (aLayoutPos, aLayoutSize);
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir 		break;
1388cdf0e10cSrcweir     }
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 	}
1391cdf0e10cSrcweir }
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir 
findAutoLayoutShapesImpl(SdPage & rPage,const LayoutDescriptor & rDescriptor,std::vector<SdrObject * > & rShapes,bool bInit,bool bSwitchLayout)1394cdf0e10cSrcweir void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::vector< SdrObject* >& rShapes, bool bInit, bool bSwitchLayout )
1395cdf0e10cSrcweir {
1396cdf0e10cSrcweir 	int i;
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir 	// init list of indexes for each presentation shape kind
1399cdf0e10cSrcweir 	// this is used to find subsequent shapes with the same presentation shape kind
1400cdf0e10cSrcweir 	int PresObjIndex[PRESOBJ_MAX];
1401cdf0e10cSrcweir 	for( i = 0; i < PRESOBJ_MAX; i++ ) PresObjIndex[i] = 1;
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir 	bool bMissing = false;
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir 	// for each entry in the layoutdescriptor, arrange a presentation shape
14061776ad39SArmin Le Grand     for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1407cdf0e10cSrcweir 	{
1408cdf0e10cSrcweir 		PresObjKind eKind = rDescriptor.meKind[i];
1409cdf0e10cSrcweir 		SdrObject* pObj = 0;
1410cdf0e10cSrcweir 		while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != 0 )
1411cdf0e10cSrcweir 		{
1412cdf0e10cSrcweir 			PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir 			if( !bSwitchLayout || !pObj->IsEmptyPresObj() )
1415cdf0e10cSrcweir 			{
1416cdf0e10cSrcweir 				rShapes[i] = pObj;
1417cdf0e10cSrcweir 				break;
1418cdf0e10cSrcweir 			}
1419cdf0e10cSrcweir 		}
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir 		if( !pObj )
1422cdf0e10cSrcweir 			bMissing = true;
1423cdf0e10cSrcweir 	}
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir 	if( bMissing && bInit )
1426cdf0e10cSrcweir 	{
1427cdf0e10cSrcweir 		// for each entry in the layoutdescriptor, look for an alternative shape
14281776ad39SArmin Le Grand         for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1429cdf0e10cSrcweir 		{
1430cdf0e10cSrcweir 			if( rShapes[i] )
1431cdf0e10cSrcweir 				continue;
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir 			PresObjKind eKind = rDescriptor.meKind[i];
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir 			SdrObject* pObj = 0;
1436cdf0e10cSrcweir 			bool bFound = false;
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir 			const int nShapeCount = rPage.GetObjCount();
1439cdf0e10cSrcweir 			int nShapeIndex = 0;
1440cdf0e10cSrcweir 			while((nShapeIndex < nShapeCount) && !bFound )
1441cdf0e10cSrcweir 			{
1442cdf0e10cSrcweir 				pObj = rPage.GetObj(nShapeIndex++);
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir 				if( pObj->IsEmptyPresObj() )
1445cdf0e10cSrcweir 					continue;
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir 				if( pObj->GetObjInventor() != SdrInventor )
1448cdf0e10cSrcweir 					continue;
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir 				// do not reuse shapes that are already part of the layout
1451cdf0e10cSrcweir 				if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() )
1452cdf0e10cSrcweir 					continue;
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 				bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE);
1455cdf0e10cSrcweir 				SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() );
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir 				switch( eKind )
1458cdf0e10cSrcweir 				{
1459cdf0e10cSrcweir 				case PRESOBJ_TITLE:
1460cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_TITLETEXT;
1461cdf0e10cSrcweir 					break;
1462cdf0e10cSrcweir 				case PRESOBJ_TABLE:
1463cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_TABLE;
1464cdf0e10cSrcweir 					break;
1465cdf0e10cSrcweir 				case PRESOBJ_MEDIA:
1466cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_MEDIA;
1467cdf0e10cSrcweir 					break;
1468cdf0e10cSrcweir 				case PRESOBJ_OUTLINE:
1469cdf0e10cSrcweir 					bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
1470cdf0e10cSrcweir 						     ((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
1471cdf0e10cSrcweir 							 (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2);
1472cdf0e10cSrcweir 					break;
1473cdf0e10cSrcweir 				case PRESOBJ_GRAPHIC:
1474cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_GRAF;
1475cdf0e10cSrcweir 					break;
1476cdf0e10cSrcweir 				case PRESOBJ_OBJECT:
1477cdf0e10cSrcweir                     if( eSdrObjKind == OBJ_OLE2 )
1478cdf0e10cSrcweir 					{
1479cdf0e10cSrcweir 						SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1480cdf0e10cSrcweir 						if( pOle2 )
1481cdf0e10cSrcweir 						{
1482cdf0e10cSrcweir                             if( pOle2->IsEmpty() )
1483cdf0e10cSrcweir                                 bFound = true;
1484cdf0e10cSrcweir                             else if( rPage.GetModel() )
1485cdf0e10cSrcweir                             {
1486cdf0e10cSrcweir 							    SdrModel* pSdrModel = rPage.GetModel();
1487cdf0e10cSrcweir 							    ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
1488cdf0e10cSrcweir 							    if( pPersist )
1489cdf0e10cSrcweir 							    {
1490cdf0e10cSrcweir 								    uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
1491cdf0e10cSrcweir 										    GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir 								    // TODO CL->KA: Why is this not working anymore?
1494cdf0e10cSrcweir 								    if( xObject.is() )
1495cdf0e10cSrcweir 								    {
1496cdf0e10cSrcweir 									    SvGlobalName aClassId( xObject->getClassID() );
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir 									    const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
1499cdf0e10cSrcweir 									    const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
1500cdf0e10cSrcweir 									    const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir 									    if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
1503cdf0e10cSrcweir 									    {
1504cdf0e10cSrcweir                                             bFound = true;
1505cdf0e10cSrcweir                                         }
1506cdf0e10cSrcweir 								    }
1507cdf0e10cSrcweir 							    }
1508cdf0e10cSrcweir                              }
1509cdf0e10cSrcweir                          }
1510cdf0e10cSrcweir                     }
1511cdf0e10cSrcweir 					break;
1512cdf0e10cSrcweir 				case PRESOBJ_CHART:
1513cdf0e10cSrcweir 				case PRESOBJ_CALC:
1514cdf0e10cSrcweir 					if( eSdrObjKind == OBJ_OLE2 )
1515cdf0e10cSrcweir 					{
1516cdf0e10cSrcweir 						SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1517cdf0e10cSrcweir 						if( pOle2 )
1518cdf0e10cSrcweir 						{
1519cdf0e10cSrcweir 							if(
1520cdf0e10cSrcweir 								((eKind == PRESOBJ_CHART) &&
1521cdf0e10cSrcweir 									( pOle2->GetProgName().EqualsAscii( "StarChart" ) || pOle2->IsChart() ) )
1522cdf0e10cSrcweir 								||
1523cdf0e10cSrcweir 								((eKind == PRESOBJ_CALC) &&
1524cdf0e10cSrcweir 									( pOle2->GetProgName().EqualsAscii( "StarCalc" ) || pOle2->IsCalc() ) ) )
1525cdf0e10cSrcweir 							{
1526cdf0e10cSrcweir 								bFound = true;
1527cdf0e10cSrcweir 							}
1528cdf0e10cSrcweir 						}
1529cdf0e10cSrcweir 						break;
1530cdf0e10cSrcweir 					}
1531cdf0e10cSrcweir 					else if( eSdrObjKind == OBJ_TABLE )
1532cdf0e10cSrcweir 					{
1533cdf0e10cSrcweir 						bFound = true;
1534cdf0e10cSrcweir 					}
1535cdf0e10cSrcweir 					break;
1536cdf0e10cSrcweir 				case PRESOBJ_PAGE:
1537cdf0e10cSrcweir 				case PRESOBJ_HANDOUT:
1538cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_PAGE;
1539cdf0e10cSrcweir 					break;
1540cdf0e10cSrcweir 				case PRESOBJ_NOTES:
1541cdf0e10cSrcweir 				case PRESOBJ_TEXT:
1542cdf0e10cSrcweir 					bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT);
1543cdf0e10cSrcweir 					break;
1544cdf0e10cSrcweir 				default:
1545cdf0e10cSrcweir 					break;
1546cdf0e10cSrcweir 				}
1547cdf0e10cSrcweir 			}
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir 			if( bFound )
1550cdf0e10cSrcweir 				rShapes[i] = pObj;
1551cdf0e10cSrcweir 		}
1552cdf0e10cSrcweir 	}
1553cdf0e10cSrcweir }
1554cdf0e10cSrcweir 
SetAutoLayout(AutoLayout eLayout,sal_Bool bInit,sal_Bool bCreate)1555cdf0e10cSrcweir void SdPage::SetAutoLayout(AutoLayout eLayout, sal_Bool bInit, sal_Bool bCreate )
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir 	sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir 	const bool bSwitchLayout = eLayout != GetAutoLayout();
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir 	::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
1562cdf0e10cSrcweir 	const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
1563cdf0e10cSrcweir 
1564cdf0e10cSrcweir 	meAutoLayout = eLayout;
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir 	// if needed, creates and initialises the presentation shapes on this slides master page
1567cdf0e10cSrcweir 	CreateTitleAndLayout(bInit, bCreate);
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir 	if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster)
1570cdf0e10cSrcweir 	{
1571cdf0e10cSrcweir 		// MasterPage or no layout and no presentation shapes available, noting to do
1572cdf0e10cSrcweir 		return;
1573cdf0e10cSrcweir 	}
1574cdf0e10cSrcweir 
1575cdf0e10cSrcweir 	Rectangle aRectangle[MAX_PRESOBJS];
1576cdf0e10cSrcweir 	const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
1577cdf0e10cSrcweir 	CalcAutoLayoutRectangles( *this, aDescriptor.mnLayout, aRectangle );
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir 	std::set< SdrObject* > aUsedPresentationObjects;
1580cdf0e10cSrcweir 
1581cdf0e10cSrcweir 
1582cdf0e10cSrcweir 	std::vector< SdrObject* > aLayoutShapes(PRESOBJ_MAX, 0);
1583cdf0e10cSrcweir 	findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
1584cdf0e10cSrcweir 
1585cdf0e10cSrcweir 	int i;
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir 	// for each entry in the layoutdescriptor, arrange a presentation shape
15881776ad39SArmin Le Grand     for (i = 0; (i < MAX_PRESOBJS) && (aDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1589cdf0e10cSrcweir 	{
1590cdf0e10cSrcweir 		PresObjKind eKind = aDescriptor.meKind[i];
1591cdf0e10cSrcweir 		SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );
1592cdf0e10cSrcweir 		if( pObj )
1593cdf0e10cSrcweir 			aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape
1594cdf0e10cSrcweir 	}
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir 	// now delete all empty presentation objects that are no longer used by the new layout
1597cdf0e10cSrcweir 	if( bInit )
1598cdf0e10cSrcweir 	{
1599cdf0e10cSrcweir 		SdrObject* pObj = maPresentationShapeList.getNextShape(0);
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir 		while( pObj )
1602cdf0e10cSrcweir 		{
1603cdf0e10cSrcweir 			SdrObject* pNext = maPresentationShapeList.getNextShape(pObj);
1604cdf0e10cSrcweir 			if( aUsedPresentationObjects.count(pObj) == 0 )
1605cdf0e10cSrcweir 			{
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir 				if( pObj->IsEmptyPresObj() )
1608cdf0e10cSrcweir 				{
1609cdf0e10cSrcweir 					if( bUndo )
1610cdf0e10cSrcweir 						pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
1611cdf0e10cSrcweir 
1612cdf0e10cSrcweir 					RemoveObject( pObj->GetOrdNum() );
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir 					if( !bUndo )
1615cdf0e10cSrcweir 						SdrObject::Free( pObj );
1616cdf0e10cSrcweir 				}
1617cdf0e10cSrcweir /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout
1618cdf0e10cSrcweir 				else
1619cdf0e10cSrcweir 				{
1620cdf0e10cSrcweir 					if( bUndo )
1621cdf0e10cSrcweir 					{
1622cdf0e10cSrcweir 						pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
1623cdf0e10cSrcweir 						if( pObj->GetUserCall() )
1624cdf0e10cSrcweir 							pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
1625cdf0e10cSrcweir 					}
1626cdf0e10cSrcweir 					maPresentationShapeList.removeShape( *pObj );
1627cdf0e10cSrcweir 					pObj->SetUserCall(0);
1628cdf0e10cSrcweir 				}
1629cdf0e10cSrcweir */
1630cdf0e10cSrcweir 			}
1631cdf0e10cSrcweir 			pObj = pNext;
1632cdf0e10cSrcweir 		}
1633cdf0e10cSrcweir 	}
1634cdf0e10cSrcweir }
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir /*************************************************************************
1637cdf0e10cSrcweir |*
1638cdf0e10cSrcweir |* Objekt einfuegen
1639cdf0e10cSrcweir |*
1640cdf0e10cSrcweir \************************************************************************/
1641cdf0e10cSrcweir 
NbcInsertObject(SdrObject * pObj,sal_uLong nPos,const SdrInsertReason * pReason)1642cdf0e10cSrcweir void SdPage::NbcInsertObject(SdrObject* pObj, sal_uLong nPos, const SdrInsertReason* pReason)
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir 	FmFormPage::NbcInsertObject(pObj, nPos, pReason);
1645cdf0e10cSrcweir 
1646cdf0e10cSrcweir 	((SdDrawDocument*) pModel)->InsertObject(pObj, this);
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir 	SdrLayerID nId = pObj->GetLayer();
1649cdf0e10cSrcweir 	if( mbMaster )
1650cdf0e10cSrcweir 	{
1651cdf0e10cSrcweir 		if( nId == 0 )
1652cdf0e10cSrcweir 			pObj->NbcSetLayer( 2 );     // wrong layer. corrected to BackgroundObj layer
1653cdf0e10cSrcweir 	}
1654cdf0e10cSrcweir 	else
1655cdf0e10cSrcweir 	{
1656cdf0e10cSrcweir 		if( nId == 2 )
1657cdf0e10cSrcweir 			pObj->NbcSetLayer( 0 );     // wrong layer. corrected to layout layer
1658cdf0e10cSrcweir 	}
1659cdf0e10cSrcweir }
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir /*************************************************************************
1662cdf0e10cSrcweir |*
1663cdf0e10cSrcweir |* Objekt loeschen
1664cdf0e10cSrcweir |*
1665cdf0e10cSrcweir \************************************************************************/
1666cdf0e10cSrcweir 
RemoveObject(sal_uLong nObjNum)1667cdf0e10cSrcweir SdrObject* SdPage::RemoveObject(sal_uLong nObjNum)
1668cdf0e10cSrcweir {
1669cdf0e10cSrcweir 	onRemoveObject(GetObj( nObjNum ));
1670cdf0e10cSrcweir 	return FmFormPage::RemoveObject(nObjNum);
1671cdf0e10cSrcweir }
1672cdf0e10cSrcweir 
1673cdf0e10cSrcweir /*************************************************************************
1674cdf0e10cSrcweir |*
1675cdf0e10cSrcweir |* Objekt loeschen, ohne Broadcast
1676cdf0e10cSrcweir |*
1677cdf0e10cSrcweir \************************************************************************/
1678cdf0e10cSrcweir 
NbcRemoveObject(sal_uLong nObjNum)1679cdf0e10cSrcweir SdrObject* SdPage::NbcRemoveObject(sal_uLong nObjNum)
1680cdf0e10cSrcweir {
1681cdf0e10cSrcweir 	onRemoveObject(GetObj( nObjNum ));
1682cdf0e10cSrcweir 	return FmFormPage::NbcRemoveObject(nObjNum);
1683cdf0e10cSrcweir }
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir // #95876# Also overload ReplaceObject methods to realize when
1686cdf0e10cSrcweir // objects are removed with this mechanism instead of RemoveObject
NbcReplaceObject(SdrObject * pNewObj,sal_uLong nObjNum)1687cdf0e10cSrcweir SdrObject* SdPage::NbcReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum)
1688cdf0e10cSrcweir {
1689cdf0e10cSrcweir 	onRemoveObject(GetObj( nObjNum ));
1690cdf0e10cSrcweir 	return FmFormPage::NbcReplaceObject(pNewObj, nObjNum);
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir // #95876# Also overload ReplaceObject methods to realize when
1694cdf0e10cSrcweir // objects are removed with this mechanism instead of RemoveObject
ReplaceObject(SdrObject * pNewObj,sal_uLong nObjNum)1695cdf0e10cSrcweir SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum)
1696cdf0e10cSrcweir {
1697cdf0e10cSrcweir 	onRemoveObject(GetObj( nObjNum ));
1698cdf0e10cSrcweir 	return FmFormPage::ReplaceObject(pNewObj, nObjNum);
1699cdf0e10cSrcweir }
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir // -------------------------------------------------------------------------
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir // called after a shape is removed or replaced from this slide
1704cdf0e10cSrcweir 
onRemoveObject(SdrObject * pObject)1705cdf0e10cSrcweir void SdPage::onRemoveObject( SdrObject* pObject )
1706cdf0e10cSrcweir {
1707cdf0e10cSrcweir 	if( pObject )
1708cdf0e10cSrcweir 	{
1709cdf0e10cSrcweir 		RemovePresObj(pObject);
1710cdf0e10cSrcweir 
1711cdf0e10cSrcweir 		if( pModel )
1712cdf0e10cSrcweir 			static_cast<SdDrawDocument*>(pModel)->RemoveObject(pObject, this);
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir 		removeAnimations( pObject );
1715cdf0e10cSrcweir 	}
1716cdf0e10cSrcweir }
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir /*************************************************************************
1719cdf0e10cSrcweir |*
1720cdf0e10cSrcweir |*
1721cdf0e10cSrcweir |*
1722cdf0e10cSrcweir \************************************************************************/
1723cdf0e10cSrcweir 
SetSize(const Size & aSize)1724cdf0e10cSrcweir void SdPage::SetSize(const Size& aSize)
1725cdf0e10cSrcweir {
1726cdf0e10cSrcweir 	Size aOldSize = GetSize();
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir 	if (aSize != aOldSize)
1729cdf0e10cSrcweir 	{
1730cdf0e10cSrcweir 		FmFormPage::SetSize(aSize);
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir 		if (aOldSize.Height() == 10 && aOldSize.Width() == 10)
1733cdf0e10cSrcweir 		{
1734cdf0e10cSrcweir 			// Die Seite bekommt erstmalig eine gueltige Groesse gesetzt,
1735cdf0e10cSrcweir 			// daher wird nun die Orientation initialisiert
1736cdf0e10cSrcweir 			if (aSize.Width() > aSize.Height())
1737cdf0e10cSrcweir 			{
1738cdf0e10cSrcweir 				meOrientation = ORIENTATION_LANDSCAPE;
1739cdf0e10cSrcweir 			}
1740cdf0e10cSrcweir 			else
1741cdf0e10cSrcweir 			{
1742cdf0e10cSrcweir 				meOrientation = ORIENTATION_PORTRAIT;
1743cdf0e10cSrcweir 			}
1744cdf0e10cSrcweir 		}
1745cdf0e10cSrcweir 	}
1746cdf0e10cSrcweir }
1747cdf0e10cSrcweir 
1748cdf0e10cSrcweir 
1749cdf0e10cSrcweir /*************************************************************************
1750cdf0e10cSrcweir |*
1751cdf0e10cSrcweir |*
1752cdf0e10cSrcweir |*
1753cdf0e10cSrcweir \************************************************************************/
1754cdf0e10cSrcweir 
SetBorder(sal_Int32 nLft,sal_Int32 nUpp,sal_Int32 nRgt,sal_Int32 nLwr)1755cdf0e10cSrcweir void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
1756cdf0e10cSrcweir {
1757cdf0e10cSrcweir 	if (nLft != GetLftBorder() || nUpp != GetUppBorder() ||
1758cdf0e10cSrcweir 		nRgt != GetRgtBorder() || nLwr != GetLwrBorder() )
1759cdf0e10cSrcweir 	{
1760cdf0e10cSrcweir 		FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
1761cdf0e10cSrcweir 	}
1762cdf0e10cSrcweir }
1763cdf0e10cSrcweir 
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir /*************************************************************************
1766cdf0e10cSrcweir |*
1767cdf0e10cSrcweir |*
1768cdf0e10cSrcweir |*
1769cdf0e10cSrcweir \************************************************************************/
1770cdf0e10cSrcweir 
SetLftBorder(sal_Int32 nBorder)1771cdf0e10cSrcweir void SdPage::SetLftBorder(sal_Int32 nBorder)
1772cdf0e10cSrcweir {
1773cdf0e10cSrcweir 	if (nBorder != GetLftBorder() )
1774cdf0e10cSrcweir 	{
1775cdf0e10cSrcweir 		FmFormPage::SetLftBorder(nBorder);
1776cdf0e10cSrcweir 	}
1777cdf0e10cSrcweir }
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir 
1780cdf0e10cSrcweir /*************************************************************************
1781cdf0e10cSrcweir |*
1782cdf0e10cSrcweir |*
1783cdf0e10cSrcweir |*
1784cdf0e10cSrcweir \************************************************************************/
1785cdf0e10cSrcweir 
SetRgtBorder(sal_Int32 nBorder)1786cdf0e10cSrcweir void SdPage::SetRgtBorder(sal_Int32 nBorder)
1787cdf0e10cSrcweir {
1788cdf0e10cSrcweir 	if (nBorder != GetRgtBorder() )
1789cdf0e10cSrcweir 	{
1790cdf0e10cSrcweir 		FmFormPage::SetRgtBorder(nBorder);
1791cdf0e10cSrcweir 	}
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir /*************************************************************************
1796cdf0e10cSrcweir |*
1797cdf0e10cSrcweir |*
1798cdf0e10cSrcweir |*
1799cdf0e10cSrcweir \************************************************************************/
1800cdf0e10cSrcweir 
SetUppBorder(sal_Int32 nBorder)1801cdf0e10cSrcweir void SdPage::SetUppBorder(sal_Int32 nBorder)
1802cdf0e10cSrcweir {
1803cdf0e10cSrcweir 	if (nBorder != GetUppBorder() )
1804cdf0e10cSrcweir 	{
1805cdf0e10cSrcweir 		FmFormPage::SetUppBorder(nBorder);
1806cdf0e10cSrcweir 	}
1807cdf0e10cSrcweir }
1808cdf0e10cSrcweir 
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir /*************************************************************************
1811cdf0e10cSrcweir |*
1812cdf0e10cSrcweir |*
1813cdf0e10cSrcweir |*
1814cdf0e10cSrcweir \************************************************************************/
1815cdf0e10cSrcweir 
SetLwrBorder(sal_Int32 nBorder)1816cdf0e10cSrcweir void SdPage::SetLwrBorder(sal_Int32 nBorder)
1817cdf0e10cSrcweir {
1818cdf0e10cSrcweir 	if (nBorder != GetLwrBorder() )
1819cdf0e10cSrcweir 	{
1820cdf0e10cSrcweir 		FmFormPage::SetLwrBorder(nBorder);
1821cdf0e10cSrcweir 	}
1822cdf0e10cSrcweir }
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir /*************************************************************************
1825cdf0e10cSrcweir |*
1826cdf0e10cSrcweir |* Setzt BackgroundFullSize und ruft dann AdjustBackground auf
1827cdf0e10cSrcweir |*
1828cdf0e10cSrcweir \************************************************************************/
1829cdf0e10cSrcweir 
SetBackgroundFullSize(sal_Bool bIn)1830cdf0e10cSrcweir void SdPage::SetBackgroundFullSize( sal_Bool bIn )
1831cdf0e10cSrcweir {
1832cdf0e10cSrcweir 	if( bIn != mbBackgroundFullSize )
1833cdf0e10cSrcweir 	{
1834cdf0e10cSrcweir 		mbBackgroundFullSize = bIn;
1835cdf0e10cSrcweir 	}
1836cdf0e10cSrcweir }
1837cdf0e10cSrcweir 
1838cdf0e10cSrcweir /*************************************************************************
1839cdf0e10cSrcweir |*
1840cdf0e10cSrcweir |* Alle Objekte an neue Seitengroesse anpassen
1841cdf0e10cSrcweir |*
1842cdf0e10cSrcweir |* bScaleAllObj: Alle Objekte werden in die neue Flaeche innerhalb der
1843cdf0e10cSrcweir |* Seitenraender skaliert. Dabei werden die Position, Groesse und bei
1844cdf0e10cSrcweir |* Praesentationsobjekten auf der MasterPage auch die Schrifthoehe der
1845cdf0e10cSrcweir |* Praesentationsvorlagen skaliert.
1846cdf0e10cSrcweir |*
1847cdf0e10cSrcweir \************************************************************************/
1848cdf0e10cSrcweir 
ScaleObjects(const Size & rNewPageSize,const Rectangle & rNewBorderRect,sal_Bool bScaleAllObj)1849cdf0e10cSrcweir void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderRect, sal_Bool bScaleAllObj)
1850cdf0e10cSrcweir {
1851cdf0e10cSrcweir 	sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir 	mbScaleObjects = bScaleAllObj;
1854cdf0e10cSrcweir 	SdrObject* pObj = NULL;
1855cdf0e10cSrcweir 	Point aRefPnt(0, 0);
1856cdf0e10cSrcweir 	Size aNewPageSize(rNewPageSize);
1857cdf0e10cSrcweir 	sal_Int32 nLeft  = rNewBorderRect.Left();
1858cdf0e10cSrcweir 	sal_Int32 nRight = rNewBorderRect.Right();
1859cdf0e10cSrcweir 	sal_Int32 nUpper = rNewBorderRect.Top();
1860cdf0e10cSrcweir 	sal_Int32 nLower = rNewBorderRect.Bottom();
1861cdf0e10cSrcweir 
1862cdf0e10cSrcweir 	// Negative Werte stehen fuer nicht zu aendernde Werte
1863cdf0e10cSrcweir 	// -> aktuelle Werte verwenden
1864cdf0e10cSrcweir 	if (aNewPageSize.Width() < 0)
1865cdf0e10cSrcweir 	{
1866cdf0e10cSrcweir 		aNewPageSize.Width() = GetWdt();
1867cdf0e10cSrcweir 	}
1868cdf0e10cSrcweir 	if (aNewPageSize.Height() < 0)
1869cdf0e10cSrcweir 	{
1870cdf0e10cSrcweir 		aNewPageSize.Height() = GetHgt();
1871cdf0e10cSrcweir 	}
1872cdf0e10cSrcweir 	if (nLeft < 0)
1873cdf0e10cSrcweir 	{
1874cdf0e10cSrcweir 		nLeft = GetLftBorder();
1875cdf0e10cSrcweir 	}
1876cdf0e10cSrcweir 	if (nRight < 0)
1877cdf0e10cSrcweir 	{
1878cdf0e10cSrcweir 		nRight = GetRgtBorder();
1879cdf0e10cSrcweir 	}
1880cdf0e10cSrcweir 	if (nUpper < 0)
1881cdf0e10cSrcweir 	{
1882cdf0e10cSrcweir 		nUpper = GetUppBorder();
1883cdf0e10cSrcweir 	}
1884cdf0e10cSrcweir 	if (nLower < 0)
1885cdf0e10cSrcweir 	{
1886cdf0e10cSrcweir 		nLower = GetLwrBorder();
1887cdf0e10cSrcweir 	}
1888cdf0e10cSrcweir 
1889cdf0e10cSrcweir 	Point aBackgroundPos(nLeft, nUpper);
1890cdf0e10cSrcweir 	Size aBackgroundSize(aNewPageSize);
1891cdf0e10cSrcweir 	Rectangle aBorderRect (aBackgroundPos, aBackgroundSize);
1892cdf0e10cSrcweir 
1893cdf0e10cSrcweir 	if (mbScaleObjects)
1894cdf0e10cSrcweir 	{
1895cdf0e10cSrcweir 		aBackgroundSize.Width()  -= nLeft  + nRight;
1896cdf0e10cSrcweir 		aBackgroundSize.Height() -= nUpper + nLower;
1897cdf0e10cSrcweir 		aBorderRect.SetSize(aBackgroundSize);
1898cdf0e10cSrcweir 		aNewPageSize = aBackgroundSize;
1899cdf0e10cSrcweir 	}
1900cdf0e10cSrcweir 
1901cdf0e10cSrcweir 	long nOldWidth  = GetWdt() - GetLftBorder() - GetRgtBorder();
1902cdf0e10cSrcweir 	long nOldHeight = GetHgt() - GetUppBorder() - GetLwrBorder();
1903cdf0e10cSrcweir 
1904cdf0e10cSrcweir 	Fraction aFractX = Fraction(aNewPageSize.Width(), nOldWidth);
1905cdf0e10cSrcweir 	Fraction aFractY = Fraction(aNewPageSize.Height(), nOldHeight);
1906cdf0e10cSrcweir 
1907cdf0e10cSrcweir 	sal_uLong nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir 	for (sal_uLong nObj = 0; nObj < nObjCnt; nObj++)
1910cdf0e10cSrcweir 	{
1911cdf0e10cSrcweir 		sal_Bool bIsPresObjOnMaster = sal_False;
1912cdf0e10cSrcweir 
1913cdf0e10cSrcweir 		// Alle Objekte
1914cdf0e10cSrcweir 		pObj = GetObj(nObj);
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir 		if (mbMaster && IsPresObj(pObj))
1917cdf0e10cSrcweir 		{
1918cdf0e10cSrcweir 			// Es ist ein Praesentationsobjekt auf der MasterPage
1919cdf0e10cSrcweir 			bIsPresObjOnMaster = sal_True;
1920cdf0e10cSrcweir 		}
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir 		if (pObj)
1923cdf0e10cSrcweir 		{
1924cdf0e10cSrcweir 			// #88084# remember aTopLeft as original TopLeft
1925cdf0e10cSrcweir 			Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
1926cdf0e10cSrcweir 
1927cdf0e10cSrcweir             if (!pObj->IsEdgeObj())
1928cdf0e10cSrcweir 			{
1929cdf0e10cSrcweir 				/**************************************************************
1930cdf0e10cSrcweir 				* Objekt skalieren
1931cdf0e10cSrcweir 				**************************************************************/
1932cdf0e10cSrcweir 				if (mbScaleObjects)
1933cdf0e10cSrcweir 				{
1934cdf0e10cSrcweir 					// #88084# use aTopLeft as original TopLeft
1935cdf0e10cSrcweir 					aRefPnt = aTopLeft;
1936cdf0e10cSrcweir 				}
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir 				pObj->Resize(aRefPnt, aFractX, aFractY);
1939cdf0e10cSrcweir 
1940cdf0e10cSrcweir 				if (mbScaleObjects)
1941cdf0e10cSrcweir 				{
1942cdf0e10cSrcweir 					SdrObjKind eObjKind = (SdrObjKind) pObj->GetObjIdentifier();
1943cdf0e10cSrcweir 
1944cdf0e10cSrcweir 					if (bIsPresObjOnMaster)
1945cdf0e10cSrcweir 					{
1946cdf0e10cSrcweir 						/**********************************************************
1947cdf0e10cSrcweir 						* Praesentationsvorlage: Texthoehe anpassen
1948cdf0e10cSrcweir 						**********************************************************/
1949cdf0e10cSrcweir 						sal_uInt16 nIndexTitle = 0;
1950cdf0e10cSrcweir 						sal_uInt16 nIndexOutline = 0;
1951cdf0e10cSrcweir 						sal_uInt16 nIndexNotes = 0;
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir 						if (pObj == GetPresObj(PRESOBJ_TITLE, nIndexTitle))
1954cdf0e10cSrcweir 						{
1955cdf0e10cSrcweir 							SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
1956cdf0e10cSrcweir 
1957cdf0e10cSrcweir 							if (pTitleSheet)
1958cdf0e10cSrcweir 							{
1959cdf0e10cSrcweir 								SfxItemSet& rSet = pTitleSheet->GetItemSet();
1960cdf0e10cSrcweir 
1961cdf0e10cSrcweir 								SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT);
1962cdf0e10cSrcweir 								sal_uLong nFontHeight = rOldHgt.GetHeight();
1963cdf0e10cSrcweir 								nFontHeight = long(nFontHeight * (double) aFractY);
1964cdf0e10cSrcweir 								rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1965cdf0e10cSrcweir 
1966cdf0e10cSrcweir 								if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1967cdf0e10cSrcweir 								{
1968cdf0e10cSrcweir 									rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1969cdf0e10cSrcweir 									nFontHeight = rOldHgt.GetHeight();
1970cdf0e10cSrcweir 									nFontHeight = long(nFontHeight * (double) aFractY);
1971cdf0e10cSrcweir 									rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1972cdf0e10cSrcweir 								}
1973cdf0e10cSrcweir 
1974cdf0e10cSrcweir 								if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1975cdf0e10cSrcweir 								{
1976cdf0e10cSrcweir 									rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1977cdf0e10cSrcweir 									nFontHeight = rOldHgt.GetHeight();
1978cdf0e10cSrcweir 									nFontHeight = long(nFontHeight * (double) aFractY);
1979cdf0e10cSrcweir 									rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1980cdf0e10cSrcweir 								}
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir 								pTitleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1983cdf0e10cSrcweir 							}
1984cdf0e10cSrcweir 						}
1985cdf0e10cSrcweir 						else if (pObj == GetPresObj(PRESOBJ_OUTLINE, nIndexOutline))
1986cdf0e10cSrcweir 						{
1987cdf0e10cSrcweir 							String aName(GetLayoutName());
1988cdf0e10cSrcweir 							aName += sal_Unicode( ' ' );
1989cdf0e10cSrcweir 
1990cdf0e10cSrcweir 							for (sal_uInt16 i=1; i<=9; i++)
1991cdf0e10cSrcweir 							{
1992cdf0e10cSrcweir 								String sLayoutName(aName);
1993cdf0e10cSrcweir 								sLayoutName += String::CreateFromInt32( (sal_Int32)i );
1994cdf0e10cSrcweir 								SfxStyleSheet* pOutlineSheet = (SfxStyleSheet*)((SdDrawDocument*) pModel)->GetStyleSheetPool()->Find(sLayoutName, SD_STYLE_FAMILY_MASTERPAGE);
1995cdf0e10cSrcweir 
1996cdf0e10cSrcweir 								if (pOutlineSheet)
1997cdf0e10cSrcweir 								{
1998cdf0e10cSrcweir 									// Neue Fonthoehe berechnen
1999cdf0e10cSrcweir 									SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
2000cdf0e10cSrcweir 
2001cdf0e10cSrcweir 									SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT);
2002cdf0e10cSrcweir 									sal_uLong nFontHeight = rOldHgt.GetHeight();
2003cdf0e10cSrcweir 									nFontHeight = long(nFontHeight * (double) aFractY);
2004cdf0e10cSrcweir 									aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
2005cdf0e10cSrcweir 
2006cdf0e10cSrcweir 									if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
2007cdf0e10cSrcweir 									{
2008cdf0e10cSrcweir 										rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
2009cdf0e10cSrcweir 										nFontHeight = rOldHgt.GetHeight();
2010cdf0e10cSrcweir 										nFontHeight = long(nFontHeight * (double) aFractY);
2011cdf0e10cSrcweir 										aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
2012cdf0e10cSrcweir 									}
2013cdf0e10cSrcweir 
2014cdf0e10cSrcweir 									if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
2015cdf0e10cSrcweir 									{
2016cdf0e10cSrcweir 										rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
2017cdf0e10cSrcweir 										nFontHeight = rOldHgt.GetHeight();
2018cdf0e10cSrcweir 										nFontHeight = long(nFontHeight * (double) aFractY);
2019cdf0e10cSrcweir 										aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
2020cdf0e10cSrcweir 									}
2021cdf0e10cSrcweir 
2022cdf0e10cSrcweir 									// Bullet anpassen
2023cdf0e10cSrcweir 									((SdStyleSheet*) pOutlineSheet)->AdjustToFontHeight(aTempSet, sal_False);
2024cdf0e10cSrcweir 
2025cdf0e10cSrcweir 									// Sonderbehandlung: die INVALIDS auf NULL-Pointer
2026cdf0e10cSrcweir 									// zurueckgesetzen (sonst landen INVALIDs oder
2027cdf0e10cSrcweir 									// Pointer auf die DefaultItems in der Vorlage;
2028cdf0e10cSrcweir 									// beides wuerde die Attribut-Vererbung unterbinden)
2029cdf0e10cSrcweir 									aTempSet.ClearInvalidItems();
2030cdf0e10cSrcweir 
2031cdf0e10cSrcweir 									// Sonderbehandlung: nur die gueltigen Anteile des
2032cdf0e10cSrcweir 									// BulletItems
2033cdf0e10cSrcweir 									if (aTempSet.GetItemState(EE_PARA_BULLET) == SFX_ITEM_AVAILABLE)
2034cdf0e10cSrcweir 									{
2035cdf0e10cSrcweir 										SvxBulletItem aOldBulItem((SvxBulletItem&) pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET));
2036cdf0e10cSrcweir 										SvxBulletItem& rNewBulItem = (SvxBulletItem&) aTempSet.Get(EE_PARA_BULLET);
2037cdf0e10cSrcweir 										aOldBulItem.CopyValidProperties(rNewBulItem);
2038cdf0e10cSrcweir 										aTempSet.Put(aOldBulItem);
2039cdf0e10cSrcweir 									}
2040cdf0e10cSrcweir 
2041cdf0e10cSrcweir 									pOutlineSheet->GetItemSet().Put(aTempSet);
2042cdf0e10cSrcweir 									pOutlineSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
2043cdf0e10cSrcweir 								}
2044cdf0e10cSrcweir 							}
2045cdf0e10cSrcweir 						}
2046cdf0e10cSrcweir 						else if (pObj == GetPresObj(PRESOBJ_NOTES, nIndexNotes))
2047cdf0e10cSrcweir 						{
2048cdf0e10cSrcweir 							SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PRESOBJ_NOTES);
2049cdf0e10cSrcweir 
2050cdf0e10cSrcweir 							if (pNotesSheet)
2051cdf0e10cSrcweir 							{
2052cdf0e10cSrcweir 								sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height();
2053cdf0e10cSrcweir 								sal_uLong nFontHeight = (sal_uLong) (nHeight * 0.0741);
2054cdf0e10cSrcweir 								SfxItemSet& rSet = pNotesSheet->GetItemSet();
2055cdf0e10cSrcweir                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
2056cdf0e10cSrcweir                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
2057cdf0e10cSrcweir                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
2058cdf0e10cSrcweir 								pNotesSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
2059cdf0e10cSrcweir 							}
2060cdf0e10cSrcweir 						}
2061cdf0e10cSrcweir 					}
2062cdf0e10cSrcweir 					else if ( eObjKind != OBJ_TITLETEXT   &&
2063cdf0e10cSrcweir 							  eObjKind != OBJ_OUTLINETEXT &&
2064cdf0e10cSrcweir 							  pObj->ISA(SdrTextObj)       &&
2065cdf0e10cSrcweir 							  pObj->GetOutlinerParaObject() )
2066cdf0e10cSrcweir 					{
2067cdf0e10cSrcweir 						/******************************************************
2068cdf0e10cSrcweir 						* Normales Textobjekt: Texthoehe anpassen
2069cdf0e10cSrcweir 						******************************************************/
2070cdf0e10cSrcweir 						sal_uLong nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
2071cdf0e10cSrcweir 						sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT;
2072cdf0e10cSrcweir 						if ( nScriptType == SCRIPTTYPE_ASIAN )
2073cdf0e10cSrcweir 							nWhich = EE_CHAR_FONTHEIGHT_CJK;
2074cdf0e10cSrcweir 						else if ( nScriptType == SCRIPTTYPE_COMPLEX )
2075cdf0e10cSrcweir 							nWhich = EE_CHAR_FONTHEIGHT_CTL;
2076cdf0e10cSrcweir 
2077cdf0e10cSrcweir 						// #88084# use more modern method to scale the text height
2078cdf0e10cSrcweir 						sal_uInt32 nFontHeight = ((SvxFontHeightItem&)pObj->GetMergedItem(nWhich)).GetHeight();
2079cdf0e10cSrcweir 						sal_uInt32 nNewFontHeight = sal_uInt32((double)nFontHeight * (double)aFractY);
2080cdf0e10cSrcweir 
2081cdf0e10cSrcweir 						pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
2082cdf0e10cSrcweir 					}
2083cdf0e10cSrcweir 				}
2084cdf0e10cSrcweir 			}
2085cdf0e10cSrcweir 
2086cdf0e10cSrcweir 			if (mbScaleObjects && !pObj->IsEdgeObj())
2087cdf0e10cSrcweir 			{
2088cdf0e10cSrcweir 				/**************************************************************
2089cdf0e10cSrcweir 				* Objektposition skalieren
2090cdf0e10cSrcweir 				**************************************************************/
2091cdf0e10cSrcweir 				Point aNewPos;
2092cdf0e10cSrcweir 
2093cdf0e10cSrcweir 				// #76447# corrected scaling; only distances may be scaled
2094cdf0e10cSrcweir 				// #88084# use aTopLeft as original TopLeft
2095cdf0e10cSrcweir 				aNewPos.X() = long((aTopLeft.X() - GetLftBorder()) * (double)aFractX) + nLeft;
2096cdf0e10cSrcweir 				aNewPos.Y() = long((aTopLeft.Y() - GetUppBorder()) * (double)aFractY) + nUpper;
2097cdf0e10cSrcweir 
2098cdf0e10cSrcweir 				Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
2099cdf0e10cSrcweir 
2100cdf0e10cSrcweir 				if (aVec.Height() != 0 || aVec.Width() != 0)
2101cdf0e10cSrcweir 				{
2102cdf0e10cSrcweir 					pObj->NbcMove(aVec);
2103cdf0e10cSrcweir 				}
2104cdf0e10cSrcweir 
2105cdf0e10cSrcweir 				pObj->SetChanged();
2106cdf0e10cSrcweir 				pObj->BroadcastObjectChange();
2107cdf0e10cSrcweir 			}
2108cdf0e10cSrcweir 		}
2109cdf0e10cSrcweir 	}
2110cdf0e10cSrcweir }
2111cdf0e10cSrcweir 
convertPresentationObjectImpl(SdPage & rPage,SdrObject * pSourceObj,PresObjKind & eObjKind,bool bVertical,Rectangle aRect)2112cdf0e10cSrcweir SdrObject* convertPresentationObjectImpl( SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, Rectangle aRect )
2113cdf0e10cSrcweir {
2114cdf0e10cSrcweir 	SdDrawDocument* pModel = static_cast< SdDrawDocument* >( rPage.GetModel() );
2115cdf0e10cSrcweir 	DBG_ASSERT( pModel, "sd::convertPresentationObjectImpl(), no model on page!" );
2116cdf0e10cSrcweir 	if( !pModel || !pSourceObj )
2117cdf0e10cSrcweir 		return pSourceObj;
2118cdf0e10cSrcweir 
2119cdf0e10cSrcweir 	::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
2120cdf0e10cSrcweir 	const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir 	SdrObject* pNewObj = pSourceObj;
2123cdf0e10cSrcweir 	if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) )
2124cdf0e10cSrcweir 	{
2125cdf0e10cSrcweir 		pNewObj = rPage.CreatePresObj(PRESOBJ_OUTLINE, bVertical, aRect);
2126cdf0e10cSrcweir 
2127cdf0e10cSrcweir 		// Text des Untertitels in das PRESOBJ_OUTLINE setzen
2128cdf0e10cSrcweir 		OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2129cdf0e10cSrcweir 
2130cdf0e10cSrcweir 		if(pOutlParaObj)
2131cdf0e10cSrcweir 		{
2132cdf0e10cSrcweir 			// Text umsetzen
2133cdf0e10cSrcweir 			::sd::Outliner* pOutl = pModel->GetInternalOutliner( sal_True );
2134cdf0e10cSrcweir 			pOutl->Clear();
2135cdf0e10cSrcweir 			pOutl->SetText( *pOutlParaObj );
2136cdf0e10cSrcweir 			pOutlParaObj = pOutl->CreateParaObject();
2137cdf0e10cSrcweir 			pNewObj->SetOutlinerParaObject( pOutlParaObj );
2138cdf0e10cSrcweir 			pOutl->Clear();
2139cdf0e10cSrcweir 			pNewObj->SetEmptyPresObj(sal_False);
2140cdf0e10cSrcweir 
2141cdf0e10cSrcweir 			for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
2142cdf0e10cSrcweir 			{
2143cdf0e10cSrcweir 				// Neue Vorlage zuweisen
2144cdf0e10cSrcweir 				String aName(rPage.GetLayoutName());
2145cdf0e10cSrcweir 				aName += sal_Unicode( ' ' );
2146cdf0e10cSrcweir 				aName += String::CreateFromInt32( nLevel );
2147cdf0e10cSrcweir 				SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE) );
2148cdf0e10cSrcweir 
2149cdf0e10cSrcweir 				if (pSheet)
2150cdf0e10cSrcweir 				{
2151cdf0e10cSrcweir 					if (nLevel == 1)
2152cdf0e10cSrcweir 					{
2153cdf0e10cSrcweir 						SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2154cdf0e10cSrcweir 
2155cdf0e10cSrcweir 						if (pSubtitleSheet)
2156cdf0e10cSrcweir 							pOutlParaObj->ChangeStyleSheetName(SD_STYLE_FAMILY_MASTERPAGE, pSubtitleSheet->GetName(), pSheet->GetName());
2157cdf0e10cSrcweir 					}
2158cdf0e10cSrcweir 
2159cdf0e10cSrcweir 					pNewObj->StartListening(*pSheet);
2160cdf0e10cSrcweir 				}
2161cdf0e10cSrcweir 			}
2162cdf0e10cSrcweir 
2163cdf0e10cSrcweir 			// LRSpace-Item loeschen
2164cdf0e10cSrcweir 			SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir 			aSet.Put(pNewObj->GetMergedItemSet());
2167cdf0e10cSrcweir 
2168cdf0e10cSrcweir 			aSet.ClearItem(EE_PARA_LRSPACE);
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir 			pNewObj->SetMergedItemSet(aSet);
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir 			if( bUndo )
2173cdf0e10cSrcweir 				pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
2174cdf0e10cSrcweir 
2175cdf0e10cSrcweir 			// Remove outline shape from page
2176cdf0e10cSrcweir 			rPage.RemoveObject( pSourceObj->GetOrdNum() );
2177cdf0e10cSrcweir 
2178cdf0e10cSrcweir 			if( !bUndo )
2179cdf0e10cSrcweir 				SdrObject::Free( pSourceObj );
2180cdf0e10cSrcweir 		}
2181cdf0e10cSrcweir 	}
2182cdf0e10cSrcweir 	else if((eObjKind == PRESOBJ_TEXT) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) )
2183cdf0e10cSrcweir 	{
2184cdf0e10cSrcweir 		// is there an outline shape we can use to replace empty subtitle shape?
2185cdf0e10cSrcweir 		pNewObj = rPage.CreatePresObj(PRESOBJ_TEXT, bVertical, aRect);
2186cdf0e10cSrcweir 
2187cdf0e10cSrcweir 		// Text des Gliederungsobjekts in das PRESOBJ_TITLE setzen
2188cdf0e10cSrcweir 		OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2189cdf0e10cSrcweir 
2190cdf0e10cSrcweir 		if(pOutlParaObj)
2191cdf0e10cSrcweir 		{
2192cdf0e10cSrcweir 			// Text umsetzen
2193cdf0e10cSrcweir 			::sd::Outliner* pOutl = pModel->GetInternalOutliner();
2194cdf0e10cSrcweir 			pOutl->Clear();
2195cdf0e10cSrcweir 			pOutl->SetText( *pOutlParaObj );
2196cdf0e10cSrcweir 			pOutlParaObj = pOutl->CreateParaObject();
2197cdf0e10cSrcweir 			pNewObj->SetOutlinerParaObject( pOutlParaObj );
2198cdf0e10cSrcweir 			pOutl->Clear();
2199cdf0e10cSrcweir 			pNewObj->SetEmptyPresObj(sal_False);
2200cdf0e10cSrcweir 
2201cdf0e10cSrcweir 			// Linken Einzug zuruecksetzen
2202cdf0e10cSrcweir 			SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
2203cdf0e10cSrcweir 
2204cdf0e10cSrcweir 			aSet.Put(pNewObj->GetMergedItemSet());
2205cdf0e10cSrcweir 
2206cdf0e10cSrcweir 			const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&) aSet.Get(EE_PARA_LRSPACE);
2207cdf0e10cSrcweir 			SvxLRSpaceItem aNewLRItem(rLRItem);
2208cdf0e10cSrcweir 			aNewLRItem.SetTxtLeft(0);
2209cdf0e10cSrcweir 			aSet.Put(aNewLRItem);
2210cdf0e10cSrcweir 
2211cdf0e10cSrcweir 			pNewObj->SetMergedItemSet(aSet);
2212cdf0e10cSrcweir 
2213cdf0e10cSrcweir 			SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2214cdf0e10cSrcweir 			if (pSheet)
2215cdf0e10cSrcweir 				pNewObj->SetStyleSheet(pSheet, sal_True);
2216cdf0e10cSrcweir 
2217cdf0e10cSrcweir 			// Remove subtitle shape from page
2218cdf0e10cSrcweir 			if( bUndo )
2219cdf0e10cSrcweir 				pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
2220cdf0e10cSrcweir 
2221cdf0e10cSrcweir 			rPage.RemoveObject( pSourceObj->GetOrdNum() );
2222cdf0e10cSrcweir 
2223cdf0e10cSrcweir 			if( !bUndo )
2224cdf0e10cSrcweir 				SdrObject::Free( pSourceObj );
2225cdf0e10cSrcweir 		}
2226cdf0e10cSrcweir 	}
2227cdf0e10cSrcweir 	else if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) )
2228cdf0e10cSrcweir 	{
2229cdf0e10cSrcweir 		switch( pSourceObj->GetObjIdentifier() )
2230cdf0e10cSrcweir 		{
2231cdf0e10cSrcweir 		case OBJ_TABLE: eObjKind = PRESOBJ_TABLE; break;
2232cdf0e10cSrcweir 		case OBJ_MEDIA: eObjKind = PRESOBJ_MEDIA; break;
2233cdf0e10cSrcweir 		case OBJ_GRAF: eObjKind = PRESOBJ_GRAPHIC; break;
2234cdf0e10cSrcweir 		case OBJ_OLE2: eObjKind = PRESOBJ_OBJECT; break;
2235cdf0e10cSrcweir 		}
2236cdf0e10cSrcweir 	}
2237cdf0e10cSrcweir 
2238cdf0e10cSrcweir 	return pNewObj;
2239cdf0e10cSrcweir }
2240cdf0e10cSrcweir 
2241cdf0e10cSrcweir /** reuses or creates a presentation shape for an auto layout that fits the given parameter
2242cdf0e10cSrcweir 
2243cdf0e10cSrcweir 	@param	eObjKind
2244cdf0e10cSrcweir 		The kind of presentation shape we like to have
2245cdf0e10cSrcweir 	@param	nIndex
2246cdf0e10cSrcweir 		If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
2247cdf0e10cSrcweir 		looking for an existing presentation shape
2248cdf0e10cSrcweir 	@param	bVertical
2249cdf0e10cSrcweir 		If true, the shape is created vertical if bInit is true
2250cdf0e10cSrcweir 	@param	aRect
2251cdf0e10cSrcweir 		The rectangle that should be used to transform the shape
2252cdf0e10cSrcweir 	@param	bInit
2253cdf0e10cSrcweir 		If true the shape is created if not found
2254cdf0e10cSrcweir 	@returns
2255cdf0e10cSrcweir 		A presentation shape that was either found or created with the given parameters
2256cdf0e10cSrcweir */
InsertAutoLayoutShape(SdrObject * pObj,PresObjKind eObjKind,bool bVertical,Rectangle aRect,bool bInit)2257cdf0e10cSrcweir SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind, bool bVertical, Rectangle aRect, bool bInit )
2258cdf0e10cSrcweir {
2259cdf0e10cSrcweir 	::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
2260cdf0e10cSrcweir 	const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
2261cdf0e10cSrcweir 
2262cdf0e10cSrcweir 	if (!pObj && bInit)
2263cdf0e10cSrcweir 	{
2264cdf0e10cSrcweir 		pObj = CreatePresObj(eObjKind, bVertical, aRect);
2265cdf0e10cSrcweir 	}
2266cdf0e10cSrcweir 	else if ( pObj && (pObj->GetUserCall() || bInit) )
2267cdf0e10cSrcweir 	{
2268cdf0e10cSrcweir 		// convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2269cdf0e10cSrcweir 		if( bInit )
2270cdf0e10cSrcweir 			pObj = convertPresentationObjectImpl( *this, pObj, eObjKind, bVertical, aRect );
2271cdf0e10cSrcweir 
2272cdf0e10cSrcweir 		if( bUndo )
2273cdf0e10cSrcweir 		{
2274cdf0e10cSrcweir 			pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
2275cdf0e10cSrcweir 			pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, sal_True, sal_True ) );
2276cdf0e10cSrcweir 			pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
2277cdf0e10cSrcweir 		}
2278cdf0e10cSrcweir 
2279cdf0e10cSrcweir //		if ( pObj->ISA(SdrGrafObj) && !pObj->IsEmptyPresObj() )
2280cdf0e10cSrcweir 			( /*(SdrGrafObj*)*/ pObj)->AdjustToMaxRect( aRect );
2281cdf0e10cSrcweir //		else
2282cdf0e10cSrcweir //			SetLogicRect( pObj, aRect );
2283cdf0e10cSrcweir 
2284cdf0e10cSrcweir 		pObj->SetUserCall(this);
2285cdf0e10cSrcweir 
2286cdf0e10cSrcweir 		SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
2287cdf0e10cSrcweir 		if( pTextObject )
2288cdf0e10cSrcweir 		{
2289cdf0e10cSrcweir 			if( pTextObject->IsVerticalWriting() != (bVertical ? sal_True : sal_False) )
2290cdf0e10cSrcweir 			{
2291cdf0e10cSrcweir 				pTextObject->SetVerticalWriting( bVertical );
2292cdf0e10cSrcweir 
2293cdf0e10cSrcweir 				// #94826# here make sure the correct anchoring is used when the object
2294cdf0e10cSrcweir 				// is re-used but orientation is changed
2295cdf0e10cSrcweir 				if(PRESOBJ_OUTLINE == eObjKind)
2296cdf0e10cSrcweir 					pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
2297cdf0e10cSrcweir 			}
2298cdf0e10cSrcweir 
2299cdf0e10cSrcweir 			if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) )
2300cdf0e10cSrcweir 			{
2301cdf0e10cSrcweir 				if ( pTextObject->IsAutoGrowHeight() )
2302cdf0e10cSrcweir 				{
2303cdf0e10cSrcweir 					// switch off AutoGrowHeight, set new MinHeight
2304cdf0e10cSrcweir 					SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
2305cdf0e10cSrcweir 					SdrTextMinFrameHeightItem aMinHeight( aRect.GetSize().Height() );
2306cdf0e10cSrcweir 					aTempAttr.Put( aMinHeight );
2307cdf0e10cSrcweir 					aTempAttr.Put( SdrTextAutoGrowHeightItem(sal_False) );
2308cdf0e10cSrcweir 					pTextObject->SetMergedItemSet(aTempAttr);
2309cdf0e10cSrcweir 					pTextObject->SetLogicRect(aRect);
2310cdf0e10cSrcweir 
2311cdf0e10cSrcweir 					// switch on AutoGrowHeight
2312cdf0e10cSrcweir 					SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
2313cdf0e10cSrcweir 					aAttr.Put( SdrTextAutoGrowHeightItem(sal_True) );
2314cdf0e10cSrcweir 
2315cdf0e10cSrcweir 					pTextObject->SetMergedItemSet(aAttr);
2316cdf0e10cSrcweir 				}
2317cdf0e10cSrcweir 
2318cdf0e10cSrcweir 				if ( pTextObject->IsAutoGrowWidth() )
2319cdf0e10cSrcweir 				{
2320cdf0e10cSrcweir 					// switch off AutoGrowWidth , set new MinWidth
2321cdf0e10cSrcweir 					SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
2322cdf0e10cSrcweir 					SdrTextMinFrameWidthItem aMinWidth( aRect.GetSize().Width() );
2323cdf0e10cSrcweir 					aTempAttr.Put( aMinWidth );
2324cdf0e10cSrcweir 					aTempAttr.Put( SdrTextAutoGrowWidthItem(sal_False) );
2325cdf0e10cSrcweir 					pTextObject->SetMergedItemSet(aTempAttr);
2326cdf0e10cSrcweir 					pTextObject->SetLogicRect(aRect);
2327cdf0e10cSrcweir 
2328cdf0e10cSrcweir 					// switch on AutoGrowWidth
2329cdf0e10cSrcweir 					SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
2330cdf0e10cSrcweir 					aAttr.Put( SdrTextAutoGrowWidthItem(sal_True) );
2331cdf0e10cSrcweir 					pTextObject->SetMergedItemSet(aAttr);
2332cdf0e10cSrcweir 				}
2333cdf0e10cSrcweir 			}
2334cdf0e10cSrcweir 		}
2335cdf0e10cSrcweir 	}
2336cdf0e10cSrcweir 
2337cdf0e10cSrcweir 	if(pObj && bInit )
2338cdf0e10cSrcweir 	{
2339cdf0e10cSrcweir 		if( !IsPresObj( pObj ) )
2340cdf0e10cSrcweir 		{
2341cdf0e10cSrcweir 			if( bUndo )
2342cdf0e10cSrcweir 				pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
2343cdf0e10cSrcweir 
2344cdf0e10cSrcweir 			InsertPresObj( pObj, eObjKind );
2345cdf0e10cSrcweir 		}
2346cdf0e10cSrcweir 
2347cdf0e10cSrcweir 		// make adjustments for vertical title and outline shapes
2348cdf0e10cSrcweir 		if( bVertical && (( eObjKind == PRESOBJ_TITLE) || (eObjKind == PRESOBJ_OUTLINE)))
2349cdf0e10cSrcweir 		{
2350cdf0e10cSrcweir 			SfxItemSet aNewSet(pObj->GetMergedItemSet());
2351cdf0e10cSrcweir 			aNewSet.Put( SdrTextAutoGrowWidthItem(sal_True) );
2352cdf0e10cSrcweir 			aNewSet.Put( SdrTextAutoGrowHeightItem(sal_False) );
2353cdf0e10cSrcweir 			if( eObjKind == PRESOBJ_OUTLINE )
2354cdf0e10cSrcweir 			{
2355cdf0e10cSrcweir 				aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
2356cdf0e10cSrcweir 				aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
2357cdf0e10cSrcweir 			}
2358cdf0e10cSrcweir 			pObj->SetMergedItemSet(aNewSet);
2359cdf0e10cSrcweir 		}
2360cdf0e10cSrcweir 	}
2361cdf0e10cSrcweir 
2362cdf0e10cSrcweir 	if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || !pObj->ISA(SdrGrafObj) ) )
2363cdf0e10cSrcweir 		pObj->AdjustToMaxRect( aRect );
2364cdf0e10cSrcweir 
2365cdf0e10cSrcweir 	return pObj;
2366cdf0e10cSrcweir }
2367cdf0e10cSrcweir 
2368cdf0e10cSrcweir 
2369cdf0e10cSrcweir /*************************************************************************
2370cdf0e10cSrcweir |*
2371cdf0e10cSrcweir |* Liefert den PresObjKind eines Objektes zurueck
2372cdf0e10cSrcweir |*
2373cdf0e10cSrcweir \************************************************************************/
2374cdf0e10cSrcweir 
GetPresObjKind(SdrObject * pObj) const2375cdf0e10cSrcweir PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const
2376cdf0e10cSrcweir {
2377cdf0e10cSrcweir 	PresObjKind eKind = PRESOBJ_NONE;
2378cdf0e10cSrcweir 	if( (pObj != 0) && (maPresentationShapeList.hasShape(*pObj)) )
2379cdf0e10cSrcweir 	{
2380cdf0e10cSrcweir 		SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
2381cdf0e10cSrcweir 		if( pInfo )
2382cdf0e10cSrcweir 			eKind = pInfo->mePresObjKind;
2383cdf0e10cSrcweir 	}
2384cdf0e10cSrcweir 
2385cdf0e10cSrcweir 	return eKind;
2386cdf0e10cSrcweir }
2387cdf0e10cSrcweir 
IsPresObj(const SdrObject * pObj)2388cdf0e10cSrcweir bool SdPage::IsPresObj(const SdrObject* pObj)
2389cdf0e10cSrcweir {
2390cdf0e10cSrcweir 	return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
2391cdf0e10cSrcweir }
2392cdf0e10cSrcweir 
RemovePresObj(const SdrObject * pObj)2393cdf0e10cSrcweir void SdPage::RemovePresObj(const SdrObject* pObj)
2394cdf0e10cSrcweir {
2395cdf0e10cSrcweir 	if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
2396cdf0e10cSrcweir 	{
2397cdf0e10cSrcweir 		SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
2398cdf0e10cSrcweir 		if( pInfo )
2399cdf0e10cSrcweir 			pInfo->mePresObjKind = PRESOBJ_NONE;
2400cdf0e10cSrcweir 		maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
2401cdf0e10cSrcweir 	}
2402cdf0e10cSrcweir }
2403cdf0e10cSrcweir 
InsertPresObj(SdrObject * pObj,PresObjKind eKind)2404cdf0e10cSrcweir void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
2405cdf0e10cSrcweir {
2406cdf0e10cSrcweir 	DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2407cdf0e10cSrcweir 	DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2408cdf0e10cSrcweir 	if( pObj )
2409cdf0e10cSrcweir 	{
2410cdf0e10cSrcweir 		SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
2411cdf0e10cSrcweir 		if( pInfo )
2412cdf0e10cSrcweir 			pInfo->mePresObjKind = eKind;
2413cdf0e10cSrcweir 		maPresentationShapeList.addShape(*pObj);
2414cdf0e10cSrcweir 	}
2415cdf0e10cSrcweir }
2416cdf0e10cSrcweir 
2417cdf0e10cSrcweir /*************************************************************************
2418cdf0e10cSrcweir |*
2419cdf0e10cSrcweir |* Text des Objektes setzen
2420cdf0e10cSrcweir |*
2421cdf0e10cSrcweir \************************************************************************/
2422cdf0e10cSrcweir 
SetObjText(SdrTextObj * pObj,SdrOutliner * pOutliner,PresObjKind eObjKind,const String & rString)2423cdf0e10cSrcweir void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind,	const String& rString )
2424cdf0e10cSrcweir {
2425cdf0e10cSrcweir 	if ( pObj )
2426cdf0e10cSrcweir 	{
2427cdf0e10cSrcweir 		DBG_ASSERT( pObj->ISA(SdrTextObj), "SetObjText: Kein SdrTextObj!" );
2428cdf0e10cSrcweir 		::Outliner* pOutl = pOutliner;
2429cdf0e10cSrcweir 
2430cdf0e10cSrcweir 		if (!pOutliner)
2431cdf0e10cSrcweir 		{
2432cdf0e10cSrcweir 			SfxItemPool* pPool = ((SdDrawDocument*) GetModel())->GetDrawOutliner().GetEmptyItemSet().GetPool();
2433cdf0e10cSrcweir 			pOutl = new ::Outliner( pPool, OUTLINERMODE_OUTLINEOBJECT );
2434cdf0e10cSrcweir 			pOutl->SetRefDevice( SD_MOD()->GetRefDevice( *( (SdDrawDocument*) GetModel() )->GetDocSh() ) );
2435cdf0e10cSrcweir 			pOutl->SetEditTextObjectPool(pPool);
2436cdf0e10cSrcweir 			pOutl->SetStyleSheetPool((SfxStyleSheetPool*)GetModel()->GetStyleSheetPool());
2437cdf0e10cSrcweir 			pOutl->EnableUndo(sal_False);
2438cdf0e10cSrcweir 			pOutl->SetUpdateMode( sal_False );
2439cdf0e10cSrcweir 		}
2440cdf0e10cSrcweir 
2441cdf0e10cSrcweir 		sal_uInt16 nOutlMode = pOutl->GetMode();
2442cdf0e10cSrcweir 		Size aPaperSize = pOutl->GetPaperSize();
2443cdf0e10cSrcweir 		sal_Bool bUpdateMode = pOutl->GetUpdateMode();
2444cdf0e10cSrcweir 		pOutl->SetUpdateMode(sal_False);
2445cdf0e10cSrcweir 		pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2446cdf0e10cSrcweir 
2447cdf0e10cSrcweir 		// #95114# Always set the object's StyleSheet at the Outliner to
2448cdf0e10cSrcweir 		// use the current objects StyleSheet. Thus it's the same as in
2449cdf0e10cSrcweir 		// SetText(...).
2450cdf0e10cSrcweir 		// #95114# Moved this implementation from where SetObjText(...) was called
2451cdf0e10cSrcweir 		// to inside this method to work even when outliner is fetched here.
2452cdf0e10cSrcweir 		pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
2453cdf0e10cSrcweir 
2454cdf0e10cSrcweir 		String aString;
2455cdf0e10cSrcweir 
2456cdf0e10cSrcweir 		switch( eObjKind )
2457cdf0e10cSrcweir 		{
2458cdf0e10cSrcweir 			case PRESOBJ_OUTLINE:
2459cdf0e10cSrcweir 			{
2460cdf0e10cSrcweir 				pOutl->Init( OUTLINERMODE_OUTLINEOBJECT );
2461cdf0e10cSrcweir 
2462cdf0e10cSrcweir 				aString += sal_Unicode( '\t' );
2463cdf0e10cSrcweir 				aString += rString;
2464cdf0e10cSrcweir 
2465cdf0e10cSrcweir 				if (mbMaster)
2466cdf0e10cSrcweir 				{
2467cdf0e10cSrcweir 					pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
2468cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t" ));
2469cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER2 ) );
2470cdf0e10cSrcweir 
2471cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t" ));
2472cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER3 ) );
2473cdf0e10cSrcweir 
2474cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t" ));
2475cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER4 ) );
2476cdf0e10cSrcweir 
2477cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t" ));
2478cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER5 ) );
2479cdf0e10cSrcweir 
2480cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t" ));
2481cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER6 ) );
2482cdf0e10cSrcweir 
2483cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t" ));
2484cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER7 ) );
2485cdf0e10cSrcweir 
2486cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t\t" ));
2487cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER8 ) );
2488cdf0e10cSrcweir 
2489cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t\t\t" ));
2490cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER9 ) );
2491cdf0e10cSrcweir 				}
2492cdf0e10cSrcweir 			}
2493cdf0e10cSrcweir 			break;
2494cdf0e10cSrcweir 
2495cdf0e10cSrcweir 			case PRESOBJ_TITLE:
2496cdf0e10cSrcweir 			{
2497cdf0e10cSrcweir 				pOutl->Init( OUTLINERMODE_TITLEOBJECT );
2498cdf0e10cSrcweir 				aString += rString;
2499cdf0e10cSrcweir 			}
2500cdf0e10cSrcweir 			break;
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir 			default:
2503cdf0e10cSrcweir 			{
2504cdf0e10cSrcweir 				pOutl->Init( OUTLINERMODE_TEXTOBJECT );
2505cdf0e10cSrcweir 				aString += rString;
2506cdf0e10cSrcweir 
2507cdf0e10cSrcweir 				// check if we need to add a text field
2508cdf0e10cSrcweir 				SvxFieldData* pData = NULL;
2509cdf0e10cSrcweir 
2510cdf0e10cSrcweir 				switch( eObjKind )
2511cdf0e10cSrcweir 				{
2512cdf0e10cSrcweir 				case PRESOBJ_HEADER:
2513cdf0e10cSrcweir 					pData = new SvxHeaderField();
2514cdf0e10cSrcweir 					break;
2515cdf0e10cSrcweir 				case PRESOBJ_FOOTER:
2516cdf0e10cSrcweir 					pData = new SvxFooterField();
2517cdf0e10cSrcweir 					break;
2518cdf0e10cSrcweir 				case PRESOBJ_SLIDENUMBER:
2519cdf0e10cSrcweir 					pData = new SvxPageField();
2520cdf0e10cSrcweir 					break;
2521cdf0e10cSrcweir 				case PRESOBJ_DATETIME:
2522cdf0e10cSrcweir 					pData = new SvxDateTimeField();
2523cdf0e10cSrcweir 					break;
2524cdf0e10cSrcweir 				default:
2525cdf0e10cSrcweir 					break;
2526cdf0e10cSrcweir 				}
2527cdf0e10cSrcweir 
2528cdf0e10cSrcweir 				if( pData )
2529cdf0e10cSrcweir 				{
2530cdf0e10cSrcweir 					ESelection e;
2531cdf0e10cSrcweir                     SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
2532cdf0e10cSrcweir 					pOutl->QuickInsertField(aField,e);
2533cdf0e10cSrcweir 					delete pData;
2534cdf0e10cSrcweir 				}
2535cdf0e10cSrcweir 			}
2536cdf0e10cSrcweir 			break;
2537cdf0e10cSrcweir 		}
2538cdf0e10cSrcweir 
2539cdf0e10cSrcweir 		pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
2540cdf0e10cSrcweir 
2541cdf0e10cSrcweir 		if( aString.Len() )
2542cdf0e10cSrcweir 			pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
2543cdf0e10cSrcweir 
2544cdf0e10cSrcweir 		( (SdrTextObj*) pObj)->SetOutlinerParaObject( pOutl->CreateParaObject() );
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir 		if (!pOutliner)
2547cdf0e10cSrcweir 		{
2548cdf0e10cSrcweir 			delete pOutl;
2549cdf0e10cSrcweir 			pOutl = NULL;
2550cdf0e10cSrcweir 		}
2551cdf0e10cSrcweir 		else
2552cdf0e10cSrcweir 		{
2553cdf0e10cSrcweir 			// Outliner restaurieren
2554cdf0e10cSrcweir 			pOutl->Init( nOutlMode );
2555cdf0e10cSrcweir 			pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2556cdf0e10cSrcweir 			pOutl->SetUpdateMode( bUpdateMode );
2557cdf0e10cSrcweir 			pOutl->SetPaperSize( aPaperSize );
2558cdf0e10cSrcweir 		}
2559cdf0e10cSrcweir 	}
2560cdf0e10cSrcweir }
2561cdf0e10cSrcweir 
2562cdf0e10cSrcweir /*************************************************************************
2563cdf0e10cSrcweir |*
2564cdf0e10cSrcweir |* Link & Daten von einem VControl empfangen
2565cdf0e10cSrcweir |*
2566cdf0e10cSrcweir \************************************************************************/
2567cdf0e10cSrcweir 
SetLinkData(const String &,const String &)2568cdf0e10cSrcweir void SdPage::SetLinkData(const String&, const String& )
2569cdf0e10cSrcweir {
2570cdf0e10cSrcweir }
2571cdf0e10cSrcweir 
2572cdf0e10cSrcweir /*************************************************************************
2573cdf0e10cSrcweir |*
2574cdf0e10cSrcweir |* Layoutname setzen
2575cdf0e10cSrcweir |*
2576cdf0e10cSrcweir \************************************************************************/
SetLayoutName(String aName)2577cdf0e10cSrcweir void SdPage::SetLayoutName(String aName)
2578cdf0e10cSrcweir {
2579cdf0e10cSrcweir 	maLayoutName = aName;
2580cdf0e10cSrcweir 
2581cdf0e10cSrcweir 	if( mbMaster )
2582cdf0e10cSrcweir 	{
2583cdf0e10cSrcweir 		String aSep( RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR) );
2584cdf0e10cSrcweir 		sal_uInt16 nPos = maLayoutName.Search( aSep );
2585cdf0e10cSrcweir 		if ( nPos != STRING_NOTFOUND )
2586cdf0e10cSrcweir 		{
2587cdf0e10cSrcweir             FmFormPage::SetName(maLayoutName.Copy(0, nPos));
2588cdf0e10cSrcweir 		}
2589cdf0e10cSrcweir 	}
2590cdf0e10cSrcweir }
2591cdf0e10cSrcweir 
2592cdf0e10cSrcweir 
2593cdf0e10cSrcweir /*************************************************************************
2594cdf0e10cSrcweir |*
2595cdf0e10cSrcweir |* Seitenname zurueckgeben und ggf. generieren
2596cdf0e10cSrcweir |*
2597cdf0e10cSrcweir \************************************************************************/
2598cdf0e10cSrcweir 
GetName() const2599cdf0e10cSrcweir const String& SdPage::GetName() const
2600cdf0e10cSrcweir {
2601cdf0e10cSrcweir 	String aCreatedPageName( maCreatedPageName );
2602cdf0e10cSrcweir 	if (GetRealName().Len() == 0)
2603cdf0e10cSrcweir 	{
2604cdf0e10cSrcweir 		if ((mePageKind == PK_STANDARD || mePageKind == PK_NOTES) && !mbMaster)
2605cdf0e10cSrcweir 		{
2606cdf0e10cSrcweir 			// default name for handout pages
2607cdf0e10cSrcweir 			sal_uInt16	nNum = (GetPageNum() + 1) / 2;
2608cdf0e10cSrcweir 
2609cdf0e10cSrcweir 			aCreatedPageName = String(SdResId(STR_PAGE));
2610cdf0e10cSrcweir 			aCreatedPageName += sal_Unicode( ' ' );
2611cdf0e10cSrcweir 			if( GetModel()->GetPageNumType() == SVX_NUMBER_NONE )
2612cdf0e10cSrcweir 			{
2613cdf0e10cSrcweir 				// if the document has number none as a formating
2614cdf0e10cSrcweir 				// for page numbers we still default to arabic numbering
2615cdf0e10cSrcweir 				// to keep the default page names unique
2616cdf0e10cSrcweir 				aCreatedPageName += String::CreateFromInt32( (sal_Int32)nNum );
2617cdf0e10cSrcweir 			}
2618cdf0e10cSrcweir 			else
2619cdf0e10cSrcweir 			{
2620cdf0e10cSrcweir 				aCreatedPageName += ((SdDrawDocument*) GetModel())->CreatePageNumValue(nNum);
2621cdf0e10cSrcweir 			}
2622cdf0e10cSrcweir 		}
2623cdf0e10cSrcweir 		else
2624cdf0e10cSrcweir 		{
2625cdf0e10cSrcweir 			/******************************************************************
2626cdf0e10cSrcweir 			* Defaultname fuer Handzettelseiten
2627cdf0e10cSrcweir 			******************************************************************/
2628cdf0e10cSrcweir 			aCreatedPageName = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
2629cdf0e10cSrcweir 		}
2630cdf0e10cSrcweir 	}
2631cdf0e10cSrcweir 	else
2632cdf0e10cSrcweir 	{
2633cdf0e10cSrcweir 		aCreatedPageName = GetRealName();
2634cdf0e10cSrcweir 	}
2635cdf0e10cSrcweir 
2636cdf0e10cSrcweir 	if (mePageKind == PK_NOTES)
2637cdf0e10cSrcweir 	{
2638cdf0e10cSrcweir 		aCreatedPageName += sal_Unicode( ' ' );
2639cdf0e10cSrcweir 		aCreatedPageName += String(SdResId(STR_NOTES));
2640cdf0e10cSrcweir 	}
2641cdf0e10cSrcweir 	else if (mePageKind == PK_HANDOUT && mbMaster)
2642cdf0e10cSrcweir 	{
2643cdf0e10cSrcweir 		aCreatedPageName += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( " (" ));
2644cdf0e10cSrcweir 		aCreatedPageName += String(SdResId(STR_HANDOUT));
2645cdf0e10cSrcweir 		aCreatedPageName += sal_Unicode( ')' );
2646cdf0e10cSrcweir 	}
2647cdf0e10cSrcweir 
2648cdf0e10cSrcweir 	const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
2649cdf0e10cSrcweir 	return maCreatedPageName;
2650cdf0e10cSrcweir }
2651cdf0e10cSrcweir 
2652cdf0e10cSrcweir /*************************************************************************
2653cdf0e10cSrcweir |*
2654cdf0e10cSrcweir |*
2655cdf0e10cSrcweir |*
2656cdf0e10cSrcweir \************************************************************************/
2657cdf0e10cSrcweir 
SetOrientation(Orientation eOrient)2658cdf0e10cSrcweir void SdPage::SetOrientation( Orientation eOrient)
2659cdf0e10cSrcweir {
2660cdf0e10cSrcweir 	meOrientation = eOrient;
2661cdf0e10cSrcweir }
2662cdf0e10cSrcweir 
2663cdf0e10cSrcweir /*************************************************************************
2664cdf0e10cSrcweir |*
2665cdf0e10cSrcweir |*
2666cdf0e10cSrcweir |*
2667cdf0e10cSrcweir \************************************************************************/
2668cdf0e10cSrcweir 
GetOrientation() const2669cdf0e10cSrcweir Orientation SdPage::GetOrientation() const
2670cdf0e10cSrcweir {
2671cdf0e10cSrcweir 	return meOrientation;
2672cdf0e10cSrcweir }
2673cdf0e10cSrcweir 
2674cdf0e10cSrcweir /*************************************************************************
2675cdf0e10cSrcweir |*
2676cdf0e10cSrcweir |* Liefert den Default-Text eines PresObjektes zurueck
2677cdf0e10cSrcweir |*
2678cdf0e10cSrcweir \************************************************************************/
2679cdf0e10cSrcweir 
GetPresObjText(PresObjKind eObjKind) const2680cdf0e10cSrcweir String SdPage::GetPresObjText(PresObjKind eObjKind) const
2681cdf0e10cSrcweir {
2682cdf0e10cSrcweir 	String aString;
2683cdf0e10cSrcweir 
2684cdf0e10cSrcweir 	if (eObjKind == PRESOBJ_TITLE)
2685cdf0e10cSrcweir 	{
2686cdf0e10cSrcweir 		if (mbMaster)
2687cdf0e10cSrcweir 		{
2688cdf0e10cSrcweir 			if (mePageKind != PK_NOTES)
2689cdf0e10cSrcweir 			{
2690cdf0e10cSrcweir 				aString = String ( SdResId( STR_PRESOBJ_MPTITLE ) );
2691cdf0e10cSrcweir 			}
2692cdf0e10cSrcweir 			else
2693cdf0e10cSrcweir 			{
2694cdf0e10cSrcweir 				aString = String ( SdResId( STR_PRESOBJ_MPNOTESTITLE ) );
2695cdf0e10cSrcweir 			}
2696cdf0e10cSrcweir 		}
2697cdf0e10cSrcweir 		else
2698cdf0e10cSrcweir 		{
2699cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_TITLE ) );
2700cdf0e10cSrcweir 		}
2701cdf0e10cSrcweir 	}
2702cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_OUTLINE)
2703cdf0e10cSrcweir 	{
2704cdf0e10cSrcweir 		if (mbMaster)
2705cdf0e10cSrcweir 		{
2706cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_MPOUTLINE ) );
2707cdf0e10cSrcweir 		}
2708cdf0e10cSrcweir 		else
2709cdf0e10cSrcweir 		{
2710cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_OUTLINE ) );
2711cdf0e10cSrcweir 		}
2712cdf0e10cSrcweir 	}
2713cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_NOTES)
2714cdf0e10cSrcweir 	{
2715cdf0e10cSrcweir 		if (mbMaster)
2716cdf0e10cSrcweir 		{
2717cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_MPNOTESTEXT ) );
2718cdf0e10cSrcweir 		}
2719cdf0e10cSrcweir 		else
2720cdf0e10cSrcweir 		{
2721cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_NOTESTEXT ) );
2722cdf0e10cSrcweir 		}
2723cdf0e10cSrcweir 	}
2724cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_TEXT)
2725cdf0e10cSrcweir 	{
2726cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_TEXT ) );
2727cdf0e10cSrcweir 	}
2728cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_GRAPHIC)
2729cdf0e10cSrcweir 	{
2730cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_GRAPHIC ) );
2731cdf0e10cSrcweir 	}
2732cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_OBJECT)
2733cdf0e10cSrcweir 	{
2734cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_OBJECT ) );
2735cdf0e10cSrcweir 	}
2736cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_CHART)
2737cdf0e10cSrcweir 	{
2738cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_CHART ) );
2739cdf0e10cSrcweir 	}
2740cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_ORGCHART)
2741cdf0e10cSrcweir 	{
2742cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_ORGCHART ) );
2743cdf0e10cSrcweir 	}
2744cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_CALC)
2745cdf0e10cSrcweir 	{
2746cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_TABLE ) );
2747cdf0e10cSrcweir 	}
2748cdf0e10cSrcweir 
2749cdf0e10cSrcweir 	return(aString);
2750cdf0e10cSrcweir }
2751cdf0e10cSrcweir 
2752cdf0e10cSrcweir extern uno::Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage );
2753cdf0e10cSrcweir 
createUnoPage()2754cdf0e10cSrcweir uno::Reference< uno::XInterface > SdPage::createUnoPage()
2755cdf0e10cSrcweir {
2756cdf0e10cSrcweir 	return createUnoPageImpl( this );
2757cdf0e10cSrcweir }
2758cdf0e10cSrcweir 
2759cdf0e10cSrcweir /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
getImplementation(const::com::sun::star::uno::Reference<::com::sun::star::drawing::XDrawPage> & xPage)2760cdf0e10cSrcweir SdPage* SdPage::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage )
2761cdf0e10cSrcweir {
2762cdf0e10cSrcweir 	try
2763cdf0e10cSrcweir 	{
2764cdf0e10cSrcweir 	    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( xPage, ::com::sun::star::uno::UNO_QUERY );
2765cdf0e10cSrcweir 		if( xUnoTunnel.is() )
2766cdf0e10cSrcweir 		{
2767cdf0e10cSrcweir 			SvxDrawPage* pUnoPage = reinterpret_cast<SvxDrawPage*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SvxDrawPage::getUnoTunnelId()) ) );
2768cdf0e10cSrcweir 			if( pUnoPage )
2769cdf0e10cSrcweir 				return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
2770cdf0e10cSrcweir 		}
2771cdf0e10cSrcweir 	}
2772cdf0e10cSrcweir 	catch( ::com::sun::star::uno::Exception& e )
2773cdf0e10cSrcweir 	{
2774cdf0e10cSrcweir 		(void)e;
2775cdf0e10cSrcweir 		DBG_ERROR("sd::SdPage::getImplementation(), exception cathced!" );
2776cdf0e10cSrcweir 	}
2777cdf0e10cSrcweir 
2778cdf0e10cSrcweir 	return 0;
2779cdf0e10cSrcweir }
2780cdf0e10cSrcweir 
SetName(const String & rName)2781cdf0e10cSrcweir void SdPage::SetName (const String& rName)
2782cdf0e10cSrcweir {
2783cdf0e10cSrcweir     String aOldName = GetName();
2784cdf0e10cSrcweir     FmFormPage::SetName (rName);
2785cdf0e10cSrcweir     static_cast<SdDrawDocument*>(pModel)->UpdatePageRelativeURLs(aOldName, rName);
2786cdf0e10cSrcweir     ActionChanged();
2787cdf0e10cSrcweir }
2788cdf0e10cSrcweir 
getHeaderFooterSettings() const2789cdf0e10cSrcweir const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
2790cdf0e10cSrcweir {
2791cdf0e10cSrcweir 	if( mePageKind == PK_HANDOUT && !mbMaster )
2792cdf0e10cSrcweir 	{
2793cdf0e10cSrcweir 		return (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings);
2794cdf0e10cSrcweir 	}
2795cdf0e10cSrcweir 	else
2796cdf0e10cSrcweir 	{
2797cdf0e10cSrcweir 		return maHeaderFooterSettings;
2798cdf0e10cSrcweir 	}
2799cdf0e10cSrcweir }
2800cdf0e10cSrcweir 
setHeaderFooterSettings(const sd::HeaderFooterSettings & rNewSettings)2801cdf0e10cSrcweir void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings )
2802cdf0e10cSrcweir {
2803*63d109c7SArmin Le Grand     if( mePageKind == PK_HANDOUT && !mbMaster )
2804*63d109c7SArmin Le Grand     {
2805*63d109c7SArmin Le Grand         (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings) = rNewSettings;
2806*63d109c7SArmin Le Grand     }
2807*63d109c7SArmin Le Grand     else
2808*63d109c7SArmin Le Grand     {
2809*63d109c7SArmin Le Grand         maHeaderFooterSettings = rNewSettings;
2810*63d109c7SArmin Le Grand     }
2811cdf0e10cSrcweir 
2812*63d109c7SArmin Le Grand     SetChanged();
2813*63d109c7SArmin Le Grand 
2814*63d109c7SArmin Le Grand     if(TRG_HasMasterPage())
2815*63d109c7SArmin Le Grand     {
2816*63d109c7SArmin Le Grand         TRG_GetMasterPageDescriptorViewContact().ActionChanged();
2817*63d109c7SArmin Le Grand 
2818*63d109c7SArmin Le Grand         // #119056# For HeaderFooterSettings SdrObjects are used, but the properties
2819*63d109c7SArmin Le Grand         // used are not part of their model data, but kept in SD. This data is applied
2820*63d109c7SArmin Le Grand         // using a 'backdoor' on primitive creation. Thus, the normal mechanism to detect
2821*63d109c7SArmin Le Grand         // object changes does not work here. It is neccessary to trigger updates here
2822*63d109c7SArmin Le Grand         // directly. BroadcastObjectChange used for PagePreview invalidations,
2823*63d109c7SArmin Le Grand         // flushViewObjectContacts used to invalidate and flush all visualizations in
2824*63d109c7SArmin Le Grand         // edit views.
2825*63d109c7SArmin Le Grand         SdPage* pMasterPage = dynamic_cast< SdPage* >(&TRG_GetMasterPage());
2826*63d109c7SArmin Le Grand 
2827*63d109c7SArmin Le Grand         if(pMasterPage)
2828*63d109c7SArmin Le Grand         {
2829*63d109c7SArmin Le Grand             SdrObject* pCandidate = 0;
2830*63d109c7SArmin Le Grand 
2831*63d109c7SArmin Le Grand             pCandidate = pMasterPage->GetPresObj( PRESOBJ_HEADER );
2832*63d109c7SArmin Le Grand 
2833*63d109c7SArmin Le Grand             if(pCandidate)
2834*63d109c7SArmin Le Grand             {
2835*63d109c7SArmin Le Grand                 pCandidate->BroadcastObjectChange();
2836*63d109c7SArmin Le Grand                 pCandidate->GetViewContact().flushViewObjectContacts();
2837*63d109c7SArmin Le Grand             }
2838*63d109c7SArmin Le Grand 
2839*63d109c7SArmin Le Grand             pCandidate = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
2840*63d109c7SArmin Le Grand 
2841*63d109c7SArmin Le Grand             if(pCandidate)
2842*63d109c7SArmin Le Grand             {
2843*63d109c7SArmin Le Grand                 pCandidate->BroadcastObjectChange();
2844*63d109c7SArmin Le Grand                 pCandidate->GetViewContact().flushViewObjectContacts();
2845*63d109c7SArmin Le Grand             }
2846*63d109c7SArmin Le Grand 
2847*63d109c7SArmin Le Grand             pCandidate = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
2848*63d109c7SArmin Le Grand 
2849*63d109c7SArmin Le Grand             if(pCandidate)
2850*63d109c7SArmin Le Grand             {
2851*63d109c7SArmin Le Grand                 pCandidate->BroadcastObjectChange();
2852*63d109c7SArmin Le Grand                 pCandidate->GetViewContact().flushViewObjectContacts();
2853*63d109c7SArmin Le Grand             }
2854*63d109c7SArmin Le Grand 
2855*63d109c7SArmin Le Grand             pCandidate = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
2856*63d109c7SArmin Le Grand 
2857*63d109c7SArmin Le Grand             if(pCandidate)
2858*63d109c7SArmin Le Grand             {
2859*63d109c7SArmin Le Grand                 pCandidate->BroadcastObjectChange();
2860*63d109c7SArmin Le Grand                 pCandidate->GetViewContact().flushViewObjectContacts();
2861*63d109c7SArmin Le Grand             }
2862*63d109c7SArmin Le Grand         }
2863*63d109c7SArmin Le Grand     }
2864cdf0e10cSrcweir }
2865cdf0e10cSrcweir 
checkVisibility(const sdr::contact::ViewObjectContact & rOriginal,const sdr::contact::DisplayInfo & rDisplayInfo,bool bEdit)2866cdf0e10cSrcweir bool SdPage::checkVisibility(
2867cdf0e10cSrcweir 	const sdr::contact::ViewObjectContact& rOriginal,
2868cdf0e10cSrcweir 	const sdr::contact::DisplayInfo& rDisplayInfo,
2869cdf0e10cSrcweir 	bool bEdit )
2870cdf0e10cSrcweir {
2871cdf0e10cSrcweir 	if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
2872cdf0e10cSrcweir 		return false;
2873cdf0e10cSrcweir 
2874cdf0e10cSrcweir 	SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2875cdf0e10cSrcweir 	if( pObj == NULL )
2876cdf0e10cSrcweir 		return false;
2877cdf0e10cSrcweir 
2878cdf0e10cSrcweir     const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
2879cdf0e10cSrcweir 	const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
2880cdf0e10cSrcweir 	const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
2881cdf0e10cSrcweir 	const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
2882cdf0e10cSrcweir 
2883cdf0e10cSrcweir 	// empty presentation objects only visible during edit mode
2884cdf0e10cSrcweir 	if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
2885cdf0e10cSrcweir 	{
2886cdf0e10cSrcweir 		if( (pObj->GetObjInventor() != SdrInventor) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
2887cdf0e10cSrcweir 			return false;
2888cdf0e10cSrcweir 	}
2889cdf0e10cSrcweir 
2890cdf0e10cSrcweir 	if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) )
2891cdf0e10cSrcweir 	{
2892cdf0e10cSrcweir        	const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->GetPage());
2893cdf0e10cSrcweir 
2894cdf0e10cSrcweir 		if( pCheckPage )
2895cdf0e10cSrcweir 		{
2896cdf0e10cSrcweir 			PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
2897cdf0e10cSrcweir 
2898cdf0e10cSrcweir 			if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
2899cdf0e10cSrcweir 			{
2900cdf0e10cSrcweir 				const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
2901cdf0e10cSrcweir 
2902cdf0e10cSrcweir                 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PK_HANDOUT && bIsPrinting ) )
2903cdf0e10cSrcweir 				{
2904cdf0e10cSrcweir 					// use the page that is currently processed
2905cdf0e10cSrcweir                 	const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
2906cdf0e10cSrcweir 
2907cdf0e10cSrcweir                     if( pVisualizedSdPage )
2908cdf0e10cSrcweir 					{
2909cdf0e10cSrcweir 						// if we are not on a masterpage, see if we have to draw this header&footer object at all
2910cdf0e10cSrcweir 						const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
2911cdf0e10cSrcweir 
2912cdf0e10cSrcweir 						switch( eKind )
2913cdf0e10cSrcweir 						{
2914cdf0e10cSrcweir 						case PRESOBJ_FOOTER:
2915cdf0e10cSrcweir 							return rSettings.mbFooterVisible;
2916cdf0e10cSrcweir 						case PRESOBJ_HEADER:
2917cdf0e10cSrcweir 							return rSettings.mbHeaderVisible;
2918cdf0e10cSrcweir 						case PRESOBJ_DATETIME:
2919cdf0e10cSrcweir 							return rSettings.mbDateTimeVisible;
2920cdf0e10cSrcweir 						case PRESOBJ_SLIDENUMBER:
2921cdf0e10cSrcweir 							return rSettings.mbSlideNumberVisible;
2922cdf0e10cSrcweir 						default:
2923cdf0e10cSrcweir 							break;
2924cdf0e10cSrcweir 						}
2925cdf0e10cSrcweir 					}
2926cdf0e10cSrcweir 				}
2927cdf0e10cSrcweir 			} // check for placeholders on master
2928cdf0e10cSrcweir 			else if( (eKind != PRESOBJ_NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) )
2929cdf0e10cSrcweir 			{
2930cdf0e10cSrcweir 			    // presentation objects on master slide are always invisible if slide is shown.
2931cdf0e10cSrcweir                 return false;
2932cdf0e10cSrcweir 			}
2933cdf0e10cSrcweir 		}
2934cdf0e10cSrcweir 	}
2935cdf0e10cSrcweir 
2936cdf0e10cSrcweir 	// i63977, do not print SdrpageObjs from master pages
2937cdf0e10cSrcweir 	if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) )
2938cdf0e10cSrcweir 	{
2939cdf0e10cSrcweir 		if( pObj->GetPage() && pObj->GetPage()->IsMasterPage() )
2940cdf0e10cSrcweir 			return false;
2941cdf0e10cSrcweir 	}
2942cdf0e10cSrcweir 
2943cdf0e10cSrcweir 	return true;
2944cdf0e10cSrcweir }
2945cdf0e10cSrcweir 
RestoreDefaultText(SdrObject * pObj)2946cdf0e10cSrcweir bool SdPage::RestoreDefaultText( SdrObject* pObj )
2947cdf0e10cSrcweir {
2948cdf0e10cSrcweir 	bool bRet = false;
2949cdf0e10cSrcweir 
2950cdf0e10cSrcweir 	SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
2951cdf0e10cSrcweir 
2952cdf0e10cSrcweir 	if( pTextObj )
2953cdf0e10cSrcweir 	{
2954cdf0e10cSrcweir 		PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
2955cdf0e10cSrcweir 
2956cdf0e10cSrcweir 		if (ePresObjKind == PRESOBJ_TITLE   ||
2957cdf0e10cSrcweir 			ePresObjKind == PRESOBJ_OUTLINE ||
2958cdf0e10cSrcweir 			ePresObjKind == PRESOBJ_NOTES   ||
2959cdf0e10cSrcweir 			ePresObjKind == PRESOBJ_TEXT)
2960cdf0e10cSrcweir 		{
2961cdf0e10cSrcweir 			String aString( GetPresObjText(ePresObjKind) );
2962cdf0e10cSrcweir 
2963cdf0e10cSrcweir 			if (aString.Len())
2964cdf0e10cSrcweir 			{
2965cdf0e10cSrcweir 				sal_Bool bVertical = sal_False;
2966cdf0e10cSrcweir 				OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
2967cdf0e10cSrcweir 				if( pOldPara )
2968cdf0e10cSrcweir 					bVertical = pOldPara->IsVertical();  // is old para object vertical?
2969cdf0e10cSrcweir 
2970cdf0e10cSrcweir 				SetObjText( pTextObj, 0, ePresObjKind, aString );
2971cdf0e10cSrcweir 
2972cdf0e10cSrcweir 				if( pOldPara )
2973cdf0e10cSrcweir 				{
2974cdf0e10cSrcweir 					//pTextObj->SetVerticalWriting( bVertical );
2975cdf0e10cSrcweir 					//
2976cdf0e10cSrcweir 					// #94826# Here, only the vertical flag for the
2977cdf0e10cSrcweir 					// OutlinerParaObjects needs to be changed. The
2978cdf0e10cSrcweir 					// AutoGrowWidth/Height items still exist in the
2979cdf0e10cSrcweir 					// not changed object.
2980cdf0e10cSrcweir 					if(pTextObj
2981cdf0e10cSrcweir 						&& pTextObj->GetOutlinerParaObject()
2982cdf0e10cSrcweir 						&& pTextObj->GetOutlinerParaObject()->IsVertical() != (bool)bVertical)
2983cdf0e10cSrcweir 					{
2984cdf0e10cSrcweir 						Rectangle aObjectRect = pTextObj->GetSnapRect();
2985cdf0e10cSrcweir 						pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
2986cdf0e10cSrcweir 						pTextObj->SetSnapRect(aObjectRect);
2987cdf0e10cSrcweir 					}
2988cdf0e10cSrcweir 				}
2989cdf0e10cSrcweir 
2990cdf0e10cSrcweir 				pTextObj->SetTextEditOutliner( NULL );  // to make stylesheet settings work
2991cdf0e10cSrcweir 				pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), sal_True );
2992cdf0e10cSrcweir 				pTextObj->SetEmptyPresObj(sal_True);
2993cdf0e10cSrcweir 				bRet = true;
2994cdf0e10cSrcweir 			}
2995cdf0e10cSrcweir 		}
2996cdf0e10cSrcweir 	}
2997cdf0e10cSrcweir 	return bRet;
2998cdf0e10cSrcweir }
2999cdf0e10cSrcweir 
CalculateHandoutAreas(SdDrawDocument & rModel,AutoLayout eLayout,bool bHorizontal,std::vector<Rectangle> & rAreas)3000cdf0e10cSrcweir void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< Rectangle >& rAreas )
3001cdf0e10cSrcweir {
3002cdf0e10cSrcweir 	SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PK_HANDOUT );
3003cdf0e10cSrcweir 
3004cdf0e10cSrcweir 	if( eLayout == AUTOLAYOUT_NONE )
3005cdf0e10cSrcweir 	{
3006cdf0e10cSrcweir 		// use layout from handout master
3007cdf0e10cSrcweir         SdrObjListIter aShapeIter (rHandoutMaster);
3008cdf0e10cSrcweir         while (aShapeIter.IsMore())
3009cdf0e10cSrcweir         {
3010cdf0e10cSrcweir             SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
3011cdf0e10cSrcweir             if (pPageObj)
3012cdf0e10cSrcweir                 rAreas.push_back( pPageObj->GetCurrentBoundRect() );
3013cdf0e10cSrcweir         }
3014cdf0e10cSrcweir 	}
3015cdf0e10cSrcweir 	else
3016cdf0e10cSrcweir 	{
3017cdf0e10cSrcweir 		Size    aArea = rHandoutMaster.GetSize();
3018cdf0e10cSrcweir 
3019cdf0e10cSrcweir 		const long nGapW = 1000; // gap is 1cm
3020cdf0e10cSrcweir 		const long nGapH = 1000;
3021cdf0e10cSrcweir 
3022cdf0e10cSrcweir 		long nLeftBorder = rHandoutMaster.GetLftBorder();
3023cdf0e10cSrcweir 		long nRightBorder = rHandoutMaster.GetRgtBorder();
3024cdf0e10cSrcweir 		long nTopBorder = rHandoutMaster.GetUppBorder();
3025cdf0e10cSrcweir 		long nBottomBorder = rHandoutMaster.GetLwrBorder();
3026cdf0e10cSrcweir 
3027cdf0e10cSrcweir 		const long nHeaderFooterHeight = static_cast< long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05  );
3028cdf0e10cSrcweir 
3029cdf0e10cSrcweir 		nTopBorder += nHeaderFooterHeight;
3030cdf0e10cSrcweir 		nBottomBorder += nHeaderFooterHeight;
3031cdf0e10cSrcweir 
3032cdf0e10cSrcweir 		long nX = nGapW + nLeftBorder;
3033cdf0e10cSrcweir 		long nY = nGapH + nTopBorder;
3034cdf0e10cSrcweir 
3035cdf0e10cSrcweir 		aArea.Width() -= nGapW * 2 + nLeftBorder + nRightBorder;
3036cdf0e10cSrcweir 		aArea.Height() -= nGapH * 2 + nTopBorder + nBottomBorder;
3037cdf0e10cSrcweir 
3038cdf0e10cSrcweir 		const bool bLandscape = aArea.Width() > aArea.Height();
3039cdf0e10cSrcweir 
3040cdf0e10cSrcweir 		static sal_uInt16 aOffsets[5][9] =
3041cdf0e10cSrcweir 		{
3042cdf0e10cSrcweir 			{ 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
3043cdf0e10cSrcweir 			{ 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
3044cdf0e10cSrcweir 			{ 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
3045cdf0e10cSrcweir 			{ 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
3046cdf0e10cSrcweir 			{ 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
3047cdf0e10cSrcweir 		};
3048cdf0e10cSrcweir 
3049cdf0e10cSrcweir 		sal_uInt16* pOffsets = aOffsets[0];
3050cdf0e10cSrcweir 		sal_uInt16  nColCnt = 0, nRowCnt = 0;
3051cdf0e10cSrcweir 		switch ( eLayout )
3052cdf0e10cSrcweir 		{
3053cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT1:
3054cdf0e10cSrcweir 				nColCnt = 1; nRowCnt = 1;
3055cdf0e10cSrcweir 				break;
3056cdf0e10cSrcweir 
3057cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT2:
3058cdf0e10cSrcweir 				if( bLandscape )
3059cdf0e10cSrcweir 				{
3060cdf0e10cSrcweir 					nColCnt = 2; nRowCnt = 1;
3061cdf0e10cSrcweir 				}
3062cdf0e10cSrcweir 				else
3063cdf0e10cSrcweir 				{
3064cdf0e10cSrcweir 					nColCnt = 1; nRowCnt = 2;
3065cdf0e10cSrcweir 				}
3066cdf0e10cSrcweir 				break;
3067cdf0e10cSrcweir 
3068cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT3:
3069cdf0e10cSrcweir 				if( bLandscape )
3070cdf0e10cSrcweir 				{
3071cdf0e10cSrcweir 					nColCnt = 3; nRowCnt = 2;
3072cdf0e10cSrcweir 				}
3073cdf0e10cSrcweir 				else
3074cdf0e10cSrcweir 				{
3075cdf0e10cSrcweir 					nColCnt = 2; nRowCnt = 3;
3076cdf0e10cSrcweir 				}
3077cdf0e10cSrcweir 				pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
3078cdf0e10cSrcweir 				break;
3079cdf0e10cSrcweir 
3080cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT4:
3081cdf0e10cSrcweir 				nColCnt = 2; nRowCnt = 2;
3082cdf0e10cSrcweir 				pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
3083cdf0e10cSrcweir 				break;
3084cdf0e10cSrcweir 
3085cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT6:
3086cdf0e10cSrcweir 				if( bLandscape )
3087cdf0e10cSrcweir 				{
3088cdf0e10cSrcweir 					nColCnt = 3; nRowCnt = 2;
3089cdf0e10cSrcweir 				}
3090cdf0e10cSrcweir 				else
3091cdf0e10cSrcweir 				{
3092cdf0e10cSrcweir 					nColCnt = 2; nRowCnt = 3;
3093cdf0e10cSrcweir 				}
3094cdf0e10cSrcweir 				if( !bHorizontal )
3095cdf0e10cSrcweir 					pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
3096cdf0e10cSrcweir 				break;
3097cdf0e10cSrcweir 
3098cdf0e10cSrcweir 			default:
3099cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT9:
3100cdf0e10cSrcweir 				nColCnt = 3; nRowCnt = 3;
3101cdf0e10cSrcweir 
3102cdf0e10cSrcweir 				if( !bHorizontal )
3103cdf0e10cSrcweir 					pOffsets = aOffsets[4];
3104cdf0e10cSrcweir 				break;
3105cdf0e10cSrcweir 		}
3106cdf0e10cSrcweir 
3107cdf0e10cSrcweir 		rAreas.resize( nColCnt * nRowCnt );
3108cdf0e10cSrcweir 
3109cdf0e10cSrcweir 		Size aPartArea, aSize;
3110cdf0e10cSrcweir 		aPartArea.Width()  = ((aArea.Width()  - ((nColCnt-1) * nGapW) ) / nColCnt);
3111cdf0e10cSrcweir 		aPartArea.Height() = ((aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt);
3112cdf0e10cSrcweir 
3113cdf0e10cSrcweir 		SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PK_STANDARD);
3114cdf0e10cSrcweir 		if ( pFirstPage )
3115cdf0e10cSrcweir 		{
3116cdf0e10cSrcweir 			// scale actual size into handout rect
3117cdf0e10cSrcweir 			double fScale = (double)aPartArea.Width() / (double)pFirstPage->GetWdt();
3118cdf0e10cSrcweir 
3119cdf0e10cSrcweir 			aSize.Height() = (long)(fScale * pFirstPage->GetHgt() );
3120cdf0e10cSrcweir 			if( aSize.Height() > aPartArea.Height() )
3121cdf0e10cSrcweir 			{
3122cdf0e10cSrcweir 				fScale = (double)aPartArea.Height() / (double)pFirstPage->GetHgt();
3123cdf0e10cSrcweir 				aSize.Height() = aPartArea.Height();
3124cdf0e10cSrcweir 				aSize.Width() = (long)(fScale * pFirstPage->GetWdt());
3125cdf0e10cSrcweir 			}
3126cdf0e10cSrcweir 			else
3127cdf0e10cSrcweir 			{
3128cdf0e10cSrcweir 				aSize.Width() = aPartArea.Width();
3129cdf0e10cSrcweir 			}
3130cdf0e10cSrcweir 
3131cdf0e10cSrcweir 			nX += (aPartArea.Width() - aSize.Width()) / 2;
3132cdf0e10cSrcweir 			nY += (aPartArea.Height()- aSize.Height())/ 2;
3133cdf0e10cSrcweir 		}
3134cdf0e10cSrcweir 		else
3135cdf0e10cSrcweir 		{
3136cdf0e10cSrcweir 			aSize = aPartArea;
3137cdf0e10cSrcweir 		}
3138cdf0e10cSrcweir 
3139cdf0e10cSrcweir 		Point aPos( nX, nY );
3140cdf0e10cSrcweir 
3141cdf0e10cSrcweir 		const bool bRTL = rModel.GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB;
3142cdf0e10cSrcweir 
3143cdf0e10cSrcweir 		const long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
3144cdf0e10cSrcweir 		const long nOffsetY = aPartArea.Height() + nGapH;
3145cdf0e10cSrcweir 		const long nStartX = bRTL ? nOffsetX*(1 - nColCnt) - nX : nX;
3146cdf0e10cSrcweir 
3147cdf0e10cSrcweir 		for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
3148cdf0e10cSrcweir 		{
3149cdf0e10cSrcweir 			aPos.X() = nStartX;
3150cdf0e10cSrcweir 			for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
3151cdf0e10cSrcweir 			{
3152cdf0e10cSrcweir 				rAreas[*pOffsets++] = Rectangle(aPos, aSize);
3153cdf0e10cSrcweir 				aPos.X() += nOffsetX;
3154cdf0e10cSrcweir 			}
3155cdf0e10cSrcweir 
3156cdf0e10cSrcweir 			aPos.Y() += nOffsetY;
3157cdf0e10cSrcweir 		}
3158cdf0e10cSrcweir 	}
3159cdf0e10cSrcweir }
3160cdf0e10cSrcweir 
3161cdf0e10cSrcweir 
3162cdf0e10cSrcweir 
3163cdf0e10cSrcweir 
SetPrecious(const bool bIsPrecious)3164cdf0e10cSrcweir void SdPage::SetPrecious (const bool bIsPrecious)
3165cdf0e10cSrcweir {
3166cdf0e10cSrcweir     mbIsPrecious = bIsPrecious;
3167cdf0e10cSrcweir }
3168cdf0e10cSrcweir 
3169cdf0e10cSrcweir 
3170cdf0e10cSrcweir 
3171cdf0e10cSrcweir 
IsPrecious(void) const3172cdf0e10cSrcweir bool SdPage::IsPrecious (void) const
3173cdf0e10cSrcweir {
3174cdf0e10cSrcweir     return mbIsPrecious;
3175cdf0e10cSrcweir }
3176cdf0e10cSrcweir 
3177cdf0e10cSrcweir 
3178cdf0e10cSrcweir 
3179cdf0e10cSrcweir 
HeaderFooterSettings()3180cdf0e10cSrcweir HeaderFooterSettings::HeaderFooterSettings()
3181cdf0e10cSrcweir {
3182cdf0e10cSrcweir 	mbHeaderVisible = true;
3183cdf0e10cSrcweir 	mbFooterVisible = true;
3184cdf0e10cSrcweir 	mbSlideNumberVisible = false;
3185cdf0e10cSrcweir 	mbDateTimeVisible = true;
3186cdf0e10cSrcweir 	mbDateTimeIsFixed = true;
3187cdf0e10cSrcweir 	meDateTimeFormat = SVXDATEFORMAT_A;
3188cdf0e10cSrcweir }
3189cdf0e10cSrcweir 
operator ==(const HeaderFooterSettings & rSettings) const3190cdf0e10cSrcweir bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
3191cdf0e10cSrcweir {
3192cdf0e10cSrcweir 	return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
3193cdf0e10cSrcweir 		   (maHeaderText == rSettings.maHeaderText) &&
3194cdf0e10cSrcweir 		   (mbFooterVisible == rSettings.mbFooterVisible) &&
3195cdf0e10cSrcweir 		   (maFooterText == rSettings.maFooterText) &&
3196cdf0e10cSrcweir 		   (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
3197cdf0e10cSrcweir 		   (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
3198cdf0e10cSrcweir 		   (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
3199cdf0e10cSrcweir 		   (meDateTimeFormat == rSettings.meDateTimeFormat) &&
3200cdf0e10cSrcweir 		   (maDateTimeText == rSettings.maDateTimeText);
3201cdf0e10cSrcweir }
3202cdf0e10cSrcweir 
3203