xref: /AOO41X/main/sd/source/core/sdpage.cxx (revision 5b1900111deff329a5580f97b99b67a25168e53d)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
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 
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 
148cdf0e10cSrcweir SdPage::~SdPage()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	DisconnectLink();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	EndListenOutlineText();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	if( mpItems )
155cdf0e10cSrcweir 		delete mpItems;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir struct OrdNumSorter
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	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 */
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 */
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 */
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 
577cdf0e10cSrcweir 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 
596cdf0e10cSrcweir 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 */
647cdf0e10cSrcweir 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 
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 
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
796cdf0e10cSrcweir 			SdrObject* pObj;
797cdf0e10cSrcweir 			while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != 0 )
798cdf0e10cSrcweir 			{
799cdf0e10cSrcweir 				if( bUndo )
800cdf0e10cSrcweir 					pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 				pMasterPage->RemoveObject(pObj->GetOrdNum());
803cdf0e10cSrcweir 			}
804cdf0e10cSrcweir 
805cdf0e10cSrcweir 			std::vector< Rectangle > aAreas;
806cdf0e10cSrcweir 			CalculateHandoutAreas( *static_cast< SdDrawDocument* >(GetModel() ), pMasterPage->GetAutoLayout(), false, aAreas );
807cdf0e10cSrcweir 
808cdf0e10cSrcweir 			const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
809cdf0e10cSrcweir 			std::vector< Rectangle >::iterator iter( aAreas.begin() );
810cdf0e10cSrcweir 
811cdf0e10cSrcweir             while( iter != aAreas.end() )
812cdf0e10cSrcweir 			{
813cdf0e10cSrcweir 				SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, sal_False, (*iter++), sal_True) );
814cdf0e10cSrcweir                 // #i105146# We want no content to be displayed for PK_HANDOUT,
815cdf0e10cSrcweir                 // so just never set a page as content
816cdf0e10cSrcweir                 pPageObj->SetReferencedPage(0L);
817cdf0e10cSrcweir 
818cdf0e10cSrcweir 				if( bSkip && iter != aAreas.end() )
819cdf0e10cSrcweir 					iter++;
820cdf0e10cSrcweir 			}
821cdf0e10cSrcweir 		}
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 		if( mePageKind != PK_HANDOUT )
824cdf0e10cSrcweir 		{
825cdf0e10cSrcweir 			SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE );
826cdf0e10cSrcweir 			if( pMasterTitle == NULL )
827cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE, true);
828cdf0e10cSrcweir 
829cdf0e10cSrcweir 			SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
830cdf0e10cSrcweir 			if( pMasterOutline == NULL )
831cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj( mePageKind == PK_STANDARD ? PRESOBJ_OUTLINE : PRESOBJ_NOTES, true );
832cdf0e10cSrcweir 		}
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 		// create header&footer objects
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 		if( bCreate )
837cdf0e10cSrcweir 		{
838cdf0e10cSrcweir 			if( mePageKind != PK_STANDARD )
839cdf0e10cSrcweir 			{
840cdf0e10cSrcweir 				SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER );
841cdf0e10cSrcweir 				if( pHeader == NULL )
842cdf0e10cSrcweir 					pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER, true );
843cdf0e10cSrcweir 			}
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 			SdrObject* pDate   = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
846cdf0e10cSrcweir 			if( pDate == NULL )
847cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME, true );
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 			SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
850cdf0e10cSrcweir 			if( pFooter == NULL )
851cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER, true );
852cdf0e10cSrcweir 
853cdf0e10cSrcweir 			SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
854cdf0e10cSrcweir 			if( pNumber == NULL )
855cdf0e10cSrcweir 				pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER, true );
856cdf0e10cSrcweir 		}
857cdf0e10cSrcweir 	}
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
860cdf0e10cSrcweir SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
861cdf0e10cSrcweir {
862cdf0e10cSrcweir 	if( eObjKind == PRESOBJ_TITLE )
863cdf0e10cSrcweir 	{
864cdf0e10cSrcweir 		Rectangle aTitleRect( GetTitleRect() );
865cdf0e10cSrcweir 		return CreatePresObj(PRESOBJ_TITLE, sal_False, aTitleRect, bInsert);
866cdf0e10cSrcweir 	}
867cdf0e10cSrcweir 	else if( eObjKind == PRESOBJ_OUTLINE )
868cdf0e10cSrcweir 	{
869cdf0e10cSrcweir 		Rectangle aLayoutRect( GetLayoutRect() );
870cdf0e10cSrcweir 		return CreatePresObj( PRESOBJ_OUTLINE, sal_False, aLayoutRect, bInsert);
871cdf0e10cSrcweir 	}
872cdf0e10cSrcweir 	else if( eObjKind == PRESOBJ_NOTES )
873cdf0e10cSrcweir 	{
874cdf0e10cSrcweir 		Rectangle aLayoutRect( GetLayoutRect() );
875cdf0e10cSrcweir 		return CreatePresObj( PRESOBJ_NOTES, sal_False, aLayoutRect, bInsert);
876cdf0e10cSrcweir 	}
877cdf0e10cSrcweir 	else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) )
878cdf0e10cSrcweir 	{
879cdf0e10cSrcweir 		// create footer objects for standard master page
880cdf0e10cSrcweir 		if( mePageKind == PK_STANDARD )
881cdf0e10cSrcweir 		{
882cdf0e10cSrcweir 			const long nLftBorder = GetLftBorder();
883cdf0e10cSrcweir 			const long nUppBorder = GetUppBorder();
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 			Point aTitlePos ( nLftBorder, nUppBorder );
886cdf0e10cSrcweir 			Size aPageSize ( GetSize() );
887cdf0e10cSrcweir 			aPageSize.Width()  -= nLftBorder + GetRgtBorder();
888cdf0e10cSrcweir 			aPageSize.Height() -= nUppBorder + GetLwrBorder();
889cdf0e10cSrcweir 
890cdf0e10cSrcweir 			const int Y = long(nUppBorder + aPageSize.Height() * 0.911);
891cdf0e10cSrcweir 			const int W1 = long(aPageSize.Width() * 0.233);
892cdf0e10cSrcweir 			const int W2 = long(aPageSize.Width() * 0.317);
893cdf0e10cSrcweir 			const int H = long(aPageSize.Height() * 0.069);
894cdf0e10cSrcweir 
895cdf0e10cSrcweir 			if( eObjKind == PRESOBJ_DATETIME )
896cdf0e10cSrcweir 			{
897cdf0e10cSrcweir 				Point aPos( long(nLftBorder+(aPageSize.Width()*0.05)), Y );
898cdf0e10cSrcweir 				Size aSize( W1, H );
899cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
900cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert );
901cdf0e10cSrcweir 			}
902cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_FOOTER )
903cdf0e10cSrcweir 			{
904cdf0e10cSrcweir 				Point aPos( long(nLftBorder+ aPageSize.Width() * 0.342), Y );
905cdf0e10cSrcweir 				Size aSize( W2, H );
906cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
907cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert );
908cdf0e10cSrcweir 			}
909cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_SLIDENUMBER )
910cdf0e10cSrcweir 			{
911cdf0e10cSrcweir 				Point aPos( long(nLftBorder+(aPageSize.Width()*0.717)), Y );
912cdf0e10cSrcweir 				Size aSize( W1, H );
913cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
914cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert );
915cdf0e10cSrcweir 			}
916cdf0e10cSrcweir 			else
917cdf0e10cSrcweir 			{
918cdf0e10cSrcweir 				DBG_ERROR( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a slide master" );
919cdf0e10cSrcweir 				return NULL;
920cdf0e10cSrcweir 			}
921cdf0e10cSrcweir 		}
922cdf0e10cSrcweir 		else
923cdf0e10cSrcweir 		{
924cdf0e10cSrcweir 			// create header&footer objects for handout and notes master
925cdf0e10cSrcweir 			Point aTitlePos ( GetLftBorder(), GetUppBorder() );
926cdf0e10cSrcweir 			Size aPageSize ( GetSize() );
927cdf0e10cSrcweir 			aPageSize.Width()  -= GetLftBorder() + GetRgtBorder();
928cdf0e10cSrcweir 			aPageSize.Height() -= GetUppBorder() + GetLwrBorder();
929cdf0e10cSrcweir 
930cdf0e10cSrcweir 
931cdf0e10cSrcweir 			const int NOTES_HEADER_FOOTER_WIDTH = long(aPageSize.Width() * 0.434);
932cdf0e10cSrcweir 			const int NOTES_HEADER_FOOTER_HEIGHT = long(aPageSize.Height() * 0.05);
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 			Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 			const int X1 = GetLftBorder();
937cdf0e10cSrcweir 			const int X2 = GetLftBorder() + long(aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH);
938cdf0e10cSrcweir 			const int Y1 = GetUppBorder();
939cdf0e10cSrcweir 			const int Y2 = GetUppBorder() + long(aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT );
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 			if( eObjKind == PRESOBJ_HEADER )
942cdf0e10cSrcweir 			{
943cdf0e10cSrcweir 				Point aPos( X1, Y1 );
944cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
945cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_HEADER, sal_False, aRect, bInsert );
946cdf0e10cSrcweir 			}
947cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_DATETIME )
948cdf0e10cSrcweir 			{
949cdf0e10cSrcweir 				Point aPos( X2, Y1 );
950cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
951cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert );
952cdf0e10cSrcweir 			}
953cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_FOOTER )
954cdf0e10cSrcweir 			{
955cdf0e10cSrcweir 				Point aPos( X1, Y2 );
956cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
957cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert );
958cdf0e10cSrcweir 			}
959cdf0e10cSrcweir 			else if( eObjKind == PRESOBJ_SLIDENUMBER )
960cdf0e10cSrcweir 			{
961cdf0e10cSrcweir 				Point aPos( X2, Y2 );
962cdf0e10cSrcweir 				Rectangle aRect( aPos, aSize );
963cdf0e10cSrcweir 				return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert );
964cdf0e10cSrcweir 			}
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 			DBG_ERROR("SdPage::CreateDefaultPresObj() - this should not happen!");
967cdf0e10cSrcweir 			return NULL;
968cdf0e10cSrcweir 		}
969cdf0e10cSrcweir 	}
970cdf0e10cSrcweir 	else
971cdf0e10cSrcweir 	{
972cdf0e10cSrcweir 		DBG_ERROR("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
973cdf0e10cSrcweir 		return NULL;
974cdf0e10cSrcweir 	}
975cdf0e10cSrcweir }
976cdf0e10cSrcweir 
977cdf0e10cSrcweir /*************************************************************************
978cdf0e10cSrcweir |*
979cdf0e10cSrcweir |* Titelbereich zurueckgeben
980cdf0e10cSrcweir |*
981cdf0e10cSrcweir \************************************************************************/
982cdf0e10cSrcweir 
983cdf0e10cSrcweir Rectangle SdPage::GetTitleRect() const
984cdf0e10cSrcweir {
985cdf0e10cSrcweir 	Rectangle aTitleRect;
986cdf0e10cSrcweir 
987cdf0e10cSrcweir 	if (mePageKind != PK_HANDOUT)
988cdf0e10cSrcweir 	{
989cdf0e10cSrcweir 		/******************************************************************
990cdf0e10cSrcweir 		* Standard- oder Notiz-Seite: Titelbereich
991cdf0e10cSrcweir 		******************************************************************/
992cdf0e10cSrcweir 		Point aTitlePos ( GetLftBorder(), GetUppBorder() );
993cdf0e10cSrcweir 		Size aTitleSize ( GetSize() );
994cdf0e10cSrcweir 		aTitleSize.Width()  -= GetLftBorder() + GetRgtBorder();
995cdf0e10cSrcweir 		aTitleSize.Height() -= GetUppBorder() + GetLwrBorder();
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 		if (mePageKind == PK_STANDARD)
998cdf0e10cSrcweir 		{
999cdf0e10cSrcweir 			aTitlePos.X() += long( aTitleSize.Width() * 0.05 );
1000cdf0e10cSrcweir 			aTitlePos.Y() += long( aTitleSize.Height() * 0.0399 );
1001cdf0e10cSrcweir 			aTitleSize.Width() = long( aTitleSize.Width() * 0.9 );
1002cdf0e10cSrcweir 			aTitleSize.Height() = long( aTitleSize.Height() * 0.167 );
1003cdf0e10cSrcweir 		}
1004cdf0e10cSrcweir 		else if (mePageKind == PK_NOTES)
1005cdf0e10cSrcweir 		{
1006cdf0e10cSrcweir 			Point aPos = aTitlePos;
1007cdf0e10cSrcweir 			aPos.Y() += long( aTitleSize.Height() * 0.076 );
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 			// Hoehe beschraenken
1010cdf0e10cSrcweir 			aTitleSize.Height() = (long) (aTitleSize.Height() * 0.375);
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 			Size aPartArea = aTitleSize;
1013cdf0e10cSrcweir 			Size aSize;
1014cdf0e10cSrcweir 			sal_uInt16 nDestPageNum(GetPageNum());
1015cdf0e10cSrcweir 			SdrPage* pRefPage = 0L;
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir 			if(nDestPageNum)
1018cdf0e10cSrcweir 			{
1019cdf0e10cSrcweir 				// only decrement if != 0, else we get 0xffff
1020cdf0e10cSrcweir 				nDestPageNum -= 1;
1021cdf0e10cSrcweir 			}
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 			if(nDestPageNum < pModel->GetPageCount())
1024cdf0e10cSrcweir 			{
1025cdf0e10cSrcweir 				pRefPage = pModel->GetPage(nDestPageNum);
1026cdf0e10cSrcweir 			}
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 			if ( pRefPage )
1029cdf0e10cSrcweir 			{
1030cdf0e10cSrcweir 				// tatsaechliche Seitengroesse in das Handout-Rechteck skalieren
1031cdf0e10cSrcweir 				double fH = (double) aPartArea.Width()  / pRefPage->GetWdt();
1032cdf0e10cSrcweir 				double fV = (double) aPartArea.Height() / pRefPage->GetHgt();
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir 				if ( fH > fV )
1035cdf0e10cSrcweir 					fH = fV;
1036cdf0e10cSrcweir 				aSize.Width()  = (long) (fH * pRefPage->GetWdt());
1037cdf0e10cSrcweir 				aSize.Height() = (long) (fH * pRefPage->GetHgt());
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir 				aPos.X() += (aPartArea.Width() - aSize.Width()) / 2;
1040cdf0e10cSrcweir 				aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2;
1041cdf0e10cSrcweir 			}
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 			aTitlePos = aPos;
1044cdf0e10cSrcweir 			aTitleSize = aSize;
1045cdf0e10cSrcweir 		}
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir 		aTitleRect.SetPos(aTitlePos);
1048cdf0e10cSrcweir 		aTitleRect.SetSize(aTitleSize);
1049cdf0e10cSrcweir 	}
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir 	return aTitleRect;
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir /*************************************************************************
1056cdf0e10cSrcweir |*
1057cdf0e10cSrcweir |* Gliederungsbereich zurueckgeben
1058cdf0e10cSrcweir |*
1059cdf0e10cSrcweir \************************************************************************/
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir Rectangle SdPage::GetLayoutRect() const
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir 	Rectangle aLayoutRect;
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir 	if (mePageKind != PK_HANDOUT)
1066cdf0e10cSrcweir 	{
1067cdf0e10cSrcweir 		Point aLayoutPos ( GetLftBorder(), GetUppBorder() );
1068cdf0e10cSrcweir 		Size aLayoutSize ( GetSize() );
1069cdf0e10cSrcweir 		aLayoutSize.Width()  -= GetLftBorder() + GetRgtBorder();
1070cdf0e10cSrcweir 		aLayoutSize.Height() -= GetUppBorder() + GetLwrBorder();
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir 		if (mePageKind == PK_STANDARD)
1073cdf0e10cSrcweir 		{
1074cdf0e10cSrcweir 			aLayoutPos.X() += long( aLayoutSize.Width() * 0.05 );
1075cdf0e10cSrcweir 			aLayoutPos.Y() += long( aLayoutSize.Height() * 0.234 );
1076cdf0e10cSrcweir 			aLayoutSize.Width() = long( aLayoutSize.Width() * 0.9 );
1077cdf0e10cSrcweir 			aLayoutSize.Height() = long( aLayoutSize.Height() * 0.66 );
1078cdf0e10cSrcweir 			aLayoutRect.SetPos(aLayoutPos);
1079cdf0e10cSrcweir 			aLayoutRect.SetSize(aLayoutSize);
1080cdf0e10cSrcweir 		}
1081cdf0e10cSrcweir 		else if (mePageKind == PK_NOTES)
1082cdf0e10cSrcweir 		{
1083cdf0e10cSrcweir 			aLayoutPos.X() += long( aLayoutSize.Width() * 0.1 );
1084cdf0e10cSrcweir 			aLayoutPos.Y() += long( aLayoutSize.Height() * 0.475 );
1085cdf0e10cSrcweir 			aLayoutSize.Width() = long( aLayoutSize.Width() * 0.8 );
1086cdf0e10cSrcweir 			aLayoutSize.Height() = long( aLayoutSize.Height() * 0.45 );
1087cdf0e10cSrcweir 			aLayoutRect.SetPos(aLayoutPos);
1088cdf0e10cSrcweir 			aLayoutRect.SetSize(aLayoutSize);
1089cdf0e10cSrcweir 		}
1090cdf0e10cSrcweir 	}
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir 	return aLayoutRect;
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir /**************************************************************************
1097cdf0e10cSrcweir |*
1098cdf0e10cSrcweir |* Diese Methode weist ein AutoLayout zu
1099cdf0e10cSrcweir |*
1100cdf0e10cSrcweir \*************************************************************************/
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir const int MAX_PRESOBJS = 7;	// maximum number of presentation objects per layout
1103cdf0e10cSrcweir const int VERTICAL = 0x8000;
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir struct LayoutDescriptor
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir 	int mnLayout;
1108cdf0e10cSrcweir 	PresObjKind meKind[MAX_PRESOBJS];
1109cdf0e10cSrcweir 	bool mbVertical[MAX_PRESOBJS];
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir 	LayoutDescriptor( int nLayout, int k0 = 0, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0, int k5 = 0, int k6 = 0 );
1112cdf0e10cSrcweir };
1113cdf0e10cSrcweir 
1114cdf0e10cSrcweir LayoutDescriptor::LayoutDescriptor( int nLayout, int k0, int k1, int k2, int k3, int k4, int k5, int k6 )
1115cdf0e10cSrcweir : mnLayout( nLayout )
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir 	meKind[0] = static_cast<PresObjKind>(k0 & (~VERTICAL)); mbVertical[0] = (k0 & VERTICAL) == VERTICAL;
1118cdf0e10cSrcweir 	meKind[1] = static_cast<PresObjKind>(k1 & (~VERTICAL)); mbVertical[1] = (k1 & VERTICAL) == VERTICAL;
1119cdf0e10cSrcweir 	meKind[2] = static_cast<PresObjKind>(k2 & (~VERTICAL)); mbVertical[2] = (k2 & VERTICAL) == VERTICAL;
1120cdf0e10cSrcweir 	meKind[3] = static_cast<PresObjKind>(k3 & (~VERTICAL)); mbVertical[3] = (k3 & VERTICAL) == VERTICAL;
1121cdf0e10cSrcweir 	meKind[4] = static_cast<PresObjKind>(k4 & (~VERTICAL)); mbVertical[4] = (k4 & VERTICAL) == VERTICAL;
1122cdf0e10cSrcweir     meKind[5] = static_cast<PresObjKind>(k5 & (~VERTICAL)); mbVertical[5] = (k5 & VERTICAL) == VERTICAL;
1123cdf0e10cSrcweir 	meKind[6] = static_cast<PresObjKind>(k6 & (~VERTICAL)); mbVertical[6] = (k6	& VERTICAL) == VERTICAL;
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir 	static LayoutDescriptor aLayouts[AUTOLAYOUT__END-AUTOLAYOUT__START] =
1129cdf0e10cSrcweir 	{
1130cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_TEXT ),									// AUTOLAYOUT_TITLE
1131cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),								// AUTOLAYOUT_ENUM
1132cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),								// AUTOLAYOUT_CHART
1133cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_2TEXT
1134cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTCHART
1135cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),								// AUTOLAYOUT_ORG
1136cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTCLbIP
1137cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_CHARTTEXT
1138cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ),								// AUTOLAYOUT_TAB
1139cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_CLIPTEXT
1140cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTOBJ
1141cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OBJECT ),								// AUTOLAYOUT_OBJ
1142cdf0e10cSrcweir 		LayoutDescriptor( 2, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),	// AUTOLAYOUT_TEXT2OBJ
1143cdf0e10cSrcweir 		LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTOBJ
1144cdf0e10cSrcweir 		LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_OBJOVERTEXT
1145cdf0e10cSrcweir 		LayoutDescriptor( 3, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),	// AUTOLAYOUT_2OBJTEXT
1146cdf0e10cSrcweir 		LayoutDescriptor( 5, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),	// AUTOLAYOUT_2OBJOVERTEXT
1147cdf0e10cSrcweir 		LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),				// AUTOLAYOUT_TEXTOVEROBJ
1148cdf0e10cSrcweir 		LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,					// AUTOLAYOUT_4OBJ
1149cdf0e10cSrcweir 			PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),
1150cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_NONE ),									// AUTOLAYOUT_ONLY_TITLE
1151cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_NONE ),												// AUTOLAYOUT_NONE
1152cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_PAGE, PRESOBJ_NOTES ),									// AUTOLAYOUT_NOTES
1153cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT1
1154cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT2
1155cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT3
1156cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT4
1157cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT6
1158cdf0e10cSrcweir 		LayoutDescriptor( 7, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE ),// AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
1159cdf0e10cSrcweir 		LayoutDescriptor( 8, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ),			// AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
1160cdf0e10cSrcweir 		LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL ),						// AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
1161cdf0e10cSrcweir 		LayoutDescriptor( 9, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ),	// AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
1162cdf0e10cSrcweir 		LayoutDescriptor( 0 ),																// AUTOLAYOUT_HANDOUT9
1163cdf0e10cSrcweir         LayoutDescriptor( 10, PRESOBJ_TEXT, PRESOBJ_NONE ),                                 // AUTOLAYOUT_ONLY_TEXT
1164cdf0e10cSrcweir         LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,			    // AUTOLAYOUT_4CLIPART
1165cdf0e10cSrcweir 			PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC ),
1166cdf0e10cSrcweir         LayoutDescriptor( 11, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE,				// AUTOLAYOUT_6CLIPART
1167cdf0e10cSrcweir             PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE )
1168cdf0e10cSrcweir 	};
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir 	if( (eLayout < AUTOLAYOUT__START) || (eLayout >= AUTOLAYOUT__END) )
1171cdf0e10cSrcweir 		eLayout = AUTOLAYOUT_NONE;
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 	return aLayouts[ eLayout - AUTOLAYOUT__START ];
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRectangle )
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir 	Rectangle aTitleRect;
1179cdf0e10cSrcweir 	Rectangle aLayoutRect;
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 	if( rPage.GetPageKind() != PK_HANDOUT )
1182cdf0e10cSrcweir 	{
1183cdf0e10cSrcweir 		SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage());
1184cdf0e10cSrcweir 		SdrObject* pMasterTitle = rMasterPage.GetPresObj( PRESOBJ_TITLE );
1185cdf0e10cSrcweir 		SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 		if( pMasterTitle )
1188cdf0e10cSrcweir 			aTitleRect = pMasterTitle->GetLogicRect();
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir 		if (aTitleRect.IsEmpty() )
1191cdf0e10cSrcweir 			aTitleRect = rPage.GetTitleRect();
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir 		if( pMasterOutline )
1194cdf0e10cSrcweir 			aLayoutRect = pMasterOutline->GetLogicRect();
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 		if (aLayoutRect.IsEmpty() )
1197cdf0e10cSrcweir 			aLayoutRect = rPage.GetLayoutRect();
1198cdf0e10cSrcweir 	}
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir 	rRectangle[0] = aTitleRect;
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir 	int i;
1203cdf0e10cSrcweir 	for( i = 1; i < MAX_PRESOBJS; i++ )
1204cdf0e10cSrcweir 		rRectangle[i] = aLayoutRect;
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir 	Size        aTitleSize( aTitleRect.GetSize() );
1207cdf0e10cSrcweir 	Point       aTitlePos( aTitleRect.TopLeft() );
1208cdf0e10cSrcweir 	Size        aLayoutSize( aLayoutRect.GetSize() );
1209cdf0e10cSrcweir 	Point       aLayoutPos( aLayoutRect.TopLeft() );
1210cdf0e10cSrcweir 	Size        aTempSize;
1211cdf0e10cSrcweir 	Point       aTempPnt;
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir     sal_Bool    bRightToLeft = ( rPage.GetModel() && static_cast< SdDrawDocument* >( rPage.GetModel() )->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB );
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir 	switch( nLayout )
1216cdf0e10cSrcweir 	{
1217cdf0e10cSrcweir 	case 0: // default layout using only the title and layout area
1218cdf0e10cSrcweir 		break; // do nothing
1219cdf0e10cSrcweir 	case 1: // title, 2 shapes
1220cdf0e10cSrcweir 	case 9: // title, 2 vertical shapes
1221cdf0e10cSrcweir 		aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.488);
1222cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir 		aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1225cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir         if( bRightToLeft && (nLayout != 9) )
1228cdf0e10cSrcweir             ::std::swap< Rectangle >( rRectangle[1], rRectangle[2] );
1229cdf0e10cSrcweir 		break;
1230cdf0e10cSrcweir 	case 2: // title, shape, 2 shapes
1231cdf0e10cSrcweir 		aTempPnt = aLayoutPos;
1232cdf0e10cSrcweir 		aTempSize = aLayoutSize;
1233cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1234cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1235cdf0e10cSrcweir 		aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1236cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1239cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir 		aLayoutPos = aTempPnt;
1242cdf0e10cSrcweir 		aLayoutSize = aTempSize;
1243cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1244cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir 		if( bRightToLeft )
1247cdf0e10cSrcweir 		{
1248cdf0e10cSrcweir 			::std::swap< long >( rRectangle[1].Left(), rRectangle[2].Left() );
1249cdf0e10cSrcweir 			rRectangle[3].Left() = rRectangle[2].Left();
1250cdf0e10cSrcweir 		}
1251cdf0e10cSrcweir 		break;
1252cdf0e10cSrcweir 	case 3: // title, 2 shapes, shape
1253cdf0e10cSrcweir 		aTempPnt = aLayoutPos;
1254cdf0e10cSrcweir 		aTempSize = aLayoutSize;
1255cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1256cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1257cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1260cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir 		aLayoutPos = aTempPnt;
1263cdf0e10cSrcweir 		aLayoutSize = aTempSize;
1264cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1265cdf0e10cSrcweir 		aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1266cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir         if( bRightToLeft )
1269cdf0e10cSrcweir         {
1270cdf0e10cSrcweir             ::std::swap< long >( rRectangle[1].Left(), rRectangle[2].Left() );
1271cdf0e10cSrcweir             rRectangle[3].Left() = rRectangle[2].Left();
1272cdf0e10cSrcweir         }
1273cdf0e10cSrcweir 		break;
1274cdf0e10cSrcweir 	case 4: // title, shape above shape
1275cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1276cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1279cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1280cdf0e10cSrcweir 		break;
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir 	case 5: // title, 2 shapes above shape
1283cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1284cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1285cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir 		aTempPnt = aLayoutPos;
1288cdf0e10cSrcweir 		aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1289cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir 		aLayoutPos.X() = aTempPnt.X();
1292cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1293cdf0e10cSrcweir 		aLayoutSize.Width() = long (aLayoutSize.Width() / 0.488);
1294cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1295cdf0e10cSrcweir 		break;
1296cdf0e10cSrcweir 	case 6: // title, 4 shapes
1297cdf0e10cSrcweir 	{
1298cdf0e10cSrcweir 		sal_uLong nX = long (aLayoutPos.X());
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1301cdf0e10cSrcweir 		aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.488);
1302cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir 		aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1305cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1308cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir 		aLayoutPos.X() = nX;
1311cdf0e10cSrcweir 		rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
1312cdf0e10cSrcweir 		break;
1313cdf0e10cSrcweir 	}
1314cdf0e10cSrcweir 	case 7: // vertical title, shape above shape
1315cdf0e10cSrcweir 	{
1316cdf0e10cSrcweir 		Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1317cdf0e10cSrcweir 		rRectangle[0].SetSize( aSize );
1318cdf0e10cSrcweir 		rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
1319cdf0e10cSrcweir 
1320cdf0e10cSrcweir 		Size aPageSize ( rPage.GetSize() );
1321cdf0e10cSrcweir 		aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
1322cdf0e10cSrcweir 		aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
1323cdf0e10cSrcweir 		aSize.Width() = long( aPageSize.Width() * 0.7 );
1324cdf0e10cSrcweir 		rRectangle[1].SetPos( aTitleRect.TopLeft() );
1325cdf0e10cSrcweir 		rRectangle[1].SetSize( aSize );
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir 		aSize.Height() = rRectangle[0].GetSize().Height();
1328cdf0e10cSrcweir 		Point aPos( aTitleRect.TopLeft() );
1329cdf0e10cSrcweir 		aPos.Y() += long ( aSize.Height() * 0.53 );
1330cdf0e10cSrcweir 		rRectangle[2].SetPos( aPos );
1331cdf0e10cSrcweir 		aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
1332cdf0e10cSrcweir 		rRectangle[2].SetSize( aSize );
1333cdf0e10cSrcweir 		break;
1334cdf0e10cSrcweir 	}
1335cdf0e10cSrcweir 	case 8: // vertical title, shape
1336cdf0e10cSrcweir 	{
1337cdf0e10cSrcweir 		Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1338cdf0e10cSrcweir 		rRectangle[0].SetSize( aSize );
1339cdf0e10cSrcweir 		rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir 		Size aPageSize ( rPage.GetSize() );
1342cdf0e10cSrcweir 		aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
1343cdf0e10cSrcweir 		aSize.Height() = rRectangle[0].GetSize().Height();
1344cdf0e10cSrcweir 		aSize.Width() = long( aPageSize.Width() * 0.7 );
1345cdf0e10cSrcweir 		rRectangle[1].SetPos( aTitleRect.TopLeft() );
1346cdf0e10cSrcweir 		rRectangle[1].SetSize( aSize );
1347cdf0e10cSrcweir 		break;
1348cdf0e10cSrcweir 	}
1349cdf0e10cSrcweir     case 10: // onlytext
1350cdf0e10cSrcweir     {
1351cdf0e10cSrcweir         Size aSize( rRectangle[0].GetSize().Width(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1352cdf0e10cSrcweir 		rRectangle[0].SetSize( aSize );
1353cdf0e10cSrcweir 		rRectangle[0].SetPos( aTitlePos);
1354cdf0e10cSrcweir 		break;
1355cdf0e10cSrcweir     }
1356cdf0e10cSrcweir     case 11: // title, 6 shapes
1357cdf0e10cSrcweir 	{
1358cdf0e10cSrcweir 		sal_uLong nX = long (aLayoutPos.X());
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir 		aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1361cdf0e10cSrcweir 		aLayoutSize.Width()  = long (aLayoutSize.Width() * 0.322);
1362cdf0e10cSrcweir 		rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir 		aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1365cdf0e10cSrcweir 		rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 		aLayoutPos.X() = long (nX + aLayoutSize.Width() * 2 * 1.05);
1368cdf0e10cSrcweir 		rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1369cdf0e10cSrcweir 
1370cdf0e10cSrcweir 		aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1371cdf0e10cSrcweir 		rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
1372cdf0e10cSrcweir 
1373cdf0e10cSrcweir 		aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1374cdf0e10cSrcweir 		rRectangle[5] = Rectangle (aLayoutPos, aLayoutSize);
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir 		aLayoutPos.X() = nX;
1377cdf0e10cSrcweir 		rRectangle[6] = Rectangle (aLayoutPos, aLayoutSize);
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir 		break;
1380cdf0e10cSrcweir     }
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir 	}
1383cdf0e10cSrcweir }
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::vector< SdrObject* >& rShapes, bool bInit, bool bSwitchLayout )
1387cdf0e10cSrcweir {
1388cdf0e10cSrcweir 	int i;
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 	// init list of indexes for each presentation shape kind
1391cdf0e10cSrcweir 	// this is used to find subsequent shapes with the same presentation shape kind
1392cdf0e10cSrcweir 	int PresObjIndex[PRESOBJ_MAX];
1393cdf0e10cSrcweir 	for( i = 0; i < PRESOBJ_MAX; i++ ) PresObjIndex[i] = 1;
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir 	bool bMissing = false;
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir 	// for each entry in the layoutdescriptor, arrange a presentation shape
1398cdf0e10cSrcweir 	for( i = 0; (i < PRESOBJ_MAX) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++ )
1399cdf0e10cSrcweir 	{
1400cdf0e10cSrcweir 		PresObjKind eKind = rDescriptor.meKind[i];
1401cdf0e10cSrcweir 		SdrObject* pObj = 0;
1402cdf0e10cSrcweir 		while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != 0 )
1403cdf0e10cSrcweir 		{
1404cdf0e10cSrcweir 			PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir 			if( !bSwitchLayout || !pObj->IsEmptyPresObj() )
1407cdf0e10cSrcweir 			{
1408cdf0e10cSrcweir 				rShapes[i] = pObj;
1409cdf0e10cSrcweir 				break;
1410cdf0e10cSrcweir 			}
1411cdf0e10cSrcweir 		}
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir 		if( !pObj )
1414cdf0e10cSrcweir 			bMissing = true;
1415cdf0e10cSrcweir 	}
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 	if( bMissing && bInit )
1418cdf0e10cSrcweir 	{
1419cdf0e10cSrcweir 		// for each entry in the layoutdescriptor, look for an alternative shape
1420cdf0e10cSrcweir 		for( i = 0; (i < PRESOBJ_MAX) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++ )
1421cdf0e10cSrcweir 		{
1422cdf0e10cSrcweir 			if( rShapes[i] )
1423cdf0e10cSrcweir 				continue;
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir 			PresObjKind eKind = rDescriptor.meKind[i];
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir 			SdrObject* pObj = 0;
1428cdf0e10cSrcweir 			bool bFound = false;
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir 			const int nShapeCount = rPage.GetObjCount();
1431cdf0e10cSrcweir 			int nShapeIndex = 0;
1432cdf0e10cSrcweir 			while((nShapeIndex < nShapeCount) && !bFound )
1433cdf0e10cSrcweir 			{
1434cdf0e10cSrcweir 				pObj = rPage.GetObj(nShapeIndex++);
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir 				if( pObj->IsEmptyPresObj() )
1437cdf0e10cSrcweir 					continue;
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir 				if( pObj->GetObjInventor() != SdrInventor )
1440cdf0e10cSrcweir 					continue;
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir 				// do not reuse shapes that are already part of the layout
1443cdf0e10cSrcweir 				if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() )
1444cdf0e10cSrcweir 					continue;
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir 				bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE);
1447cdf0e10cSrcweir 				SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() );
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir 				switch( eKind )
1450cdf0e10cSrcweir 				{
1451cdf0e10cSrcweir 				case PRESOBJ_TITLE:
1452cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_TITLETEXT;
1453cdf0e10cSrcweir 					break;
1454cdf0e10cSrcweir 				case PRESOBJ_TABLE:
1455cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_TABLE;
1456cdf0e10cSrcweir 					break;
1457cdf0e10cSrcweir 				case PRESOBJ_MEDIA:
1458cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_MEDIA;
1459cdf0e10cSrcweir 					break;
1460cdf0e10cSrcweir 				case PRESOBJ_OUTLINE:
1461cdf0e10cSrcweir 					bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
1462cdf0e10cSrcweir 						     ((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
1463cdf0e10cSrcweir 							 (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2);
1464cdf0e10cSrcweir 					break;
1465cdf0e10cSrcweir 				case PRESOBJ_GRAPHIC:
1466cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_GRAF;
1467cdf0e10cSrcweir 					break;
1468cdf0e10cSrcweir 				case PRESOBJ_OBJECT:
1469cdf0e10cSrcweir                     if( eSdrObjKind == OBJ_OLE2 )
1470cdf0e10cSrcweir 					{
1471cdf0e10cSrcweir 						SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1472cdf0e10cSrcweir 						if( pOle2 )
1473cdf0e10cSrcweir 						{
1474cdf0e10cSrcweir                             if( pOle2->IsEmpty() )
1475cdf0e10cSrcweir                                 bFound = true;
1476cdf0e10cSrcweir                             else if( rPage.GetModel() )
1477cdf0e10cSrcweir                             {
1478cdf0e10cSrcweir 							    SdrModel* pSdrModel = rPage.GetModel();
1479cdf0e10cSrcweir 							    ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
1480cdf0e10cSrcweir 							    if( pPersist )
1481cdf0e10cSrcweir 							    {
1482cdf0e10cSrcweir 								    uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
1483cdf0e10cSrcweir 										    GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir 								    // TODO CL->KA: Why is this not working anymore?
1486cdf0e10cSrcweir 								    if( xObject.is() )
1487cdf0e10cSrcweir 								    {
1488cdf0e10cSrcweir 									    SvGlobalName aClassId( xObject->getClassID() );
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir 									    const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
1491cdf0e10cSrcweir 									    const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
1492cdf0e10cSrcweir 									    const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir 									    if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
1495cdf0e10cSrcweir 									    {
1496cdf0e10cSrcweir                                             bFound = true;
1497cdf0e10cSrcweir                                         }
1498cdf0e10cSrcweir 								    }
1499cdf0e10cSrcweir 							    }
1500cdf0e10cSrcweir                              }
1501cdf0e10cSrcweir                          }
1502cdf0e10cSrcweir                     }
1503cdf0e10cSrcweir 					break;
1504cdf0e10cSrcweir 				case PRESOBJ_CHART:
1505cdf0e10cSrcweir 				case PRESOBJ_CALC:
1506cdf0e10cSrcweir 					if( eSdrObjKind == OBJ_OLE2 )
1507cdf0e10cSrcweir 					{
1508cdf0e10cSrcweir 						SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1509cdf0e10cSrcweir 						if( pOle2 )
1510cdf0e10cSrcweir 						{
1511cdf0e10cSrcweir 							if(
1512cdf0e10cSrcweir 								((eKind == PRESOBJ_CHART) &&
1513cdf0e10cSrcweir 									( pOle2->GetProgName().EqualsAscii( "StarChart" ) || pOle2->IsChart() ) )
1514cdf0e10cSrcweir 								||
1515cdf0e10cSrcweir 								((eKind == PRESOBJ_CALC) &&
1516cdf0e10cSrcweir 									( pOle2->GetProgName().EqualsAscii( "StarCalc" ) || pOle2->IsCalc() ) ) )
1517cdf0e10cSrcweir 							{
1518cdf0e10cSrcweir 								bFound = true;
1519cdf0e10cSrcweir 							}
1520cdf0e10cSrcweir 						}
1521cdf0e10cSrcweir 						break;
1522cdf0e10cSrcweir 					}
1523cdf0e10cSrcweir 					else if( eSdrObjKind == OBJ_TABLE )
1524cdf0e10cSrcweir 					{
1525cdf0e10cSrcweir 						bFound = true;
1526cdf0e10cSrcweir 					}
1527cdf0e10cSrcweir 					break;
1528cdf0e10cSrcweir 				case PRESOBJ_PAGE:
1529cdf0e10cSrcweir 				case PRESOBJ_HANDOUT:
1530cdf0e10cSrcweir 					bFound = eSdrObjKind == OBJ_PAGE;
1531cdf0e10cSrcweir 					break;
1532cdf0e10cSrcweir 				case PRESOBJ_NOTES:
1533cdf0e10cSrcweir 				case PRESOBJ_TEXT:
1534cdf0e10cSrcweir 					bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT);
1535cdf0e10cSrcweir 					break;
1536cdf0e10cSrcweir 				default:
1537cdf0e10cSrcweir 					break;
1538cdf0e10cSrcweir 				}
1539cdf0e10cSrcweir 			}
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir 			if( bFound )
1542cdf0e10cSrcweir 				rShapes[i] = pObj;
1543cdf0e10cSrcweir 		}
1544cdf0e10cSrcweir 	}
1545cdf0e10cSrcweir }
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir void SdPage::SetAutoLayout(AutoLayout eLayout, sal_Bool bInit, sal_Bool bCreate )
1548cdf0e10cSrcweir {
1549cdf0e10cSrcweir 	sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir 	const bool bSwitchLayout = eLayout != GetAutoLayout();
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir 	::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
1554cdf0e10cSrcweir 	const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
1555cdf0e10cSrcweir 
1556cdf0e10cSrcweir 	meAutoLayout = eLayout;
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir 	// if needed, creates and initialises the presentation shapes on this slides master page
1559cdf0e10cSrcweir 	CreateTitleAndLayout(bInit, bCreate);
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir 	if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster)
1562cdf0e10cSrcweir 	{
1563cdf0e10cSrcweir 		// MasterPage or no layout and no presentation shapes available, noting to do
1564cdf0e10cSrcweir 		return;
1565cdf0e10cSrcweir 	}
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir 	Rectangle aRectangle[MAX_PRESOBJS];
1568cdf0e10cSrcweir 	const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
1569cdf0e10cSrcweir 	CalcAutoLayoutRectangles( *this, aDescriptor.mnLayout, aRectangle );
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir 	std::set< SdrObject* > aUsedPresentationObjects;
1572cdf0e10cSrcweir 
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir 	std::vector< SdrObject* > aLayoutShapes(PRESOBJ_MAX, 0);
1575cdf0e10cSrcweir 	findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir 	int i;
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir 	// for each entry in the layoutdescriptor, arrange a presentation shape
1580cdf0e10cSrcweir 	for( i = 0; (i < PRESOBJ_MAX) && (aDescriptor.meKind[i] != PRESOBJ_NONE); i++ )
1581cdf0e10cSrcweir 	{
1582cdf0e10cSrcweir 		PresObjKind eKind = aDescriptor.meKind[i];
1583cdf0e10cSrcweir 		SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );
1584cdf0e10cSrcweir 		if( pObj )
1585cdf0e10cSrcweir 			aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape
1586cdf0e10cSrcweir 	}
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir 	// now delete all empty presentation objects that are no longer used by the new layout
1589cdf0e10cSrcweir 	if( bInit )
1590cdf0e10cSrcweir 	{
1591cdf0e10cSrcweir 		SdrObject* pObj = maPresentationShapeList.getNextShape(0);
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir 		while( pObj )
1594cdf0e10cSrcweir 		{
1595cdf0e10cSrcweir 			SdrObject* pNext = maPresentationShapeList.getNextShape(pObj);
1596cdf0e10cSrcweir 			if( aUsedPresentationObjects.count(pObj) == 0 )
1597cdf0e10cSrcweir 			{
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir 				if( pObj->IsEmptyPresObj() )
1600cdf0e10cSrcweir 				{
1601cdf0e10cSrcweir 					if( bUndo )
1602cdf0e10cSrcweir 						pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
1603cdf0e10cSrcweir 
1604cdf0e10cSrcweir 					RemoveObject( pObj->GetOrdNum() );
1605cdf0e10cSrcweir 
1606cdf0e10cSrcweir 					if( !bUndo )
1607cdf0e10cSrcweir 						SdrObject::Free( pObj );
1608cdf0e10cSrcweir 				}
1609cdf0e10cSrcweir /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout
1610cdf0e10cSrcweir 				else
1611cdf0e10cSrcweir 				{
1612cdf0e10cSrcweir 					if( bUndo )
1613cdf0e10cSrcweir 					{
1614cdf0e10cSrcweir 						pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
1615cdf0e10cSrcweir 						if( pObj->GetUserCall() )
1616cdf0e10cSrcweir 							pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
1617cdf0e10cSrcweir 					}
1618cdf0e10cSrcweir 					maPresentationShapeList.removeShape( *pObj );
1619cdf0e10cSrcweir 					pObj->SetUserCall(0);
1620cdf0e10cSrcweir 				}
1621cdf0e10cSrcweir */
1622cdf0e10cSrcweir 			}
1623cdf0e10cSrcweir 			pObj = pNext;
1624cdf0e10cSrcweir 		}
1625cdf0e10cSrcweir 	}
1626cdf0e10cSrcweir }
1627cdf0e10cSrcweir 
1628cdf0e10cSrcweir /*************************************************************************
1629cdf0e10cSrcweir |*
1630cdf0e10cSrcweir |* Objekt einfuegen
1631cdf0e10cSrcweir |*
1632cdf0e10cSrcweir \************************************************************************/
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir void SdPage::NbcInsertObject(SdrObject* pObj, sal_uLong nPos, const SdrInsertReason* pReason)
1635cdf0e10cSrcweir {
1636cdf0e10cSrcweir 	FmFormPage::NbcInsertObject(pObj, nPos, pReason);
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir 	((SdDrawDocument*) pModel)->InsertObject(pObj, this);
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir 	SdrLayerID nId = pObj->GetLayer();
1641cdf0e10cSrcweir 	if( mbMaster )
1642cdf0e10cSrcweir 	{
1643cdf0e10cSrcweir 		if( nId == 0 )
1644cdf0e10cSrcweir 			pObj->NbcSetLayer( 2 );     // wrong layer. corrected to BackgroundObj layer
1645cdf0e10cSrcweir 	}
1646cdf0e10cSrcweir 	else
1647cdf0e10cSrcweir 	{
1648cdf0e10cSrcweir 		if( nId == 2 )
1649cdf0e10cSrcweir 			pObj->NbcSetLayer( 0 );     // wrong layer. corrected to layout layer
1650cdf0e10cSrcweir 	}
1651cdf0e10cSrcweir }
1652cdf0e10cSrcweir 
1653cdf0e10cSrcweir /*************************************************************************
1654cdf0e10cSrcweir |*
1655cdf0e10cSrcweir |* Objekt loeschen
1656cdf0e10cSrcweir |*
1657cdf0e10cSrcweir \************************************************************************/
1658cdf0e10cSrcweir 
1659cdf0e10cSrcweir SdrObject* SdPage::RemoveObject(sal_uLong nObjNum)
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir 	onRemoveObject(GetObj( nObjNum ));
1662cdf0e10cSrcweir 	return FmFormPage::RemoveObject(nObjNum);
1663cdf0e10cSrcweir }
1664cdf0e10cSrcweir 
1665cdf0e10cSrcweir /*************************************************************************
1666cdf0e10cSrcweir |*
1667cdf0e10cSrcweir |* Objekt loeschen, ohne Broadcast
1668cdf0e10cSrcweir |*
1669cdf0e10cSrcweir \************************************************************************/
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir SdrObject* SdPage::NbcRemoveObject(sal_uLong nObjNum)
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir 	onRemoveObject(GetObj( nObjNum ));
1674cdf0e10cSrcweir 	return FmFormPage::NbcRemoveObject(nObjNum);
1675cdf0e10cSrcweir }
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir // #95876# Also overload ReplaceObject methods to realize when
1678cdf0e10cSrcweir // objects are removed with this mechanism instead of RemoveObject
1679cdf0e10cSrcweir SdrObject* SdPage::NbcReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum)
1680cdf0e10cSrcweir {
1681cdf0e10cSrcweir 	onRemoveObject(GetObj( nObjNum ));
1682cdf0e10cSrcweir 	return FmFormPage::NbcReplaceObject(pNewObj, nObjNum);
1683cdf0e10cSrcweir }
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir // #95876# Also overload ReplaceObject methods to realize when
1686cdf0e10cSrcweir // objects are removed with this mechanism instead of RemoveObject
1687cdf0e10cSrcweir SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum)
1688cdf0e10cSrcweir {
1689cdf0e10cSrcweir 	onRemoveObject(GetObj( nObjNum ));
1690cdf0e10cSrcweir 	return FmFormPage::ReplaceObject(pNewObj, nObjNum);
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir // -------------------------------------------------------------------------
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir // called after a shape is removed or replaced from this slide
1696cdf0e10cSrcweir 
1697cdf0e10cSrcweir void SdPage::onRemoveObject( SdrObject* pObject )
1698cdf0e10cSrcweir {
1699cdf0e10cSrcweir 	if( pObject )
1700cdf0e10cSrcweir 	{
1701cdf0e10cSrcweir 		RemovePresObj(pObject);
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir 		if( pModel )
1704cdf0e10cSrcweir 			static_cast<SdDrawDocument*>(pModel)->RemoveObject(pObject, this);
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir 		removeAnimations( pObject );
1707cdf0e10cSrcweir 	}
1708cdf0e10cSrcweir }
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir /*************************************************************************
1711cdf0e10cSrcweir |*
1712cdf0e10cSrcweir |*
1713cdf0e10cSrcweir |*
1714cdf0e10cSrcweir \************************************************************************/
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir void SdPage::SetSize(const Size& aSize)
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir 	Size aOldSize = GetSize();
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir 	if (aSize != aOldSize)
1721cdf0e10cSrcweir 	{
1722cdf0e10cSrcweir 		FmFormPage::SetSize(aSize);
1723cdf0e10cSrcweir 
1724cdf0e10cSrcweir 		if (aOldSize.Height() == 10 && aOldSize.Width() == 10)
1725cdf0e10cSrcweir 		{
1726cdf0e10cSrcweir 			// Die Seite bekommt erstmalig eine gueltige Groesse gesetzt,
1727cdf0e10cSrcweir 			// daher wird nun die Orientation initialisiert
1728cdf0e10cSrcweir 			if (aSize.Width() > aSize.Height())
1729cdf0e10cSrcweir 			{
1730cdf0e10cSrcweir 				meOrientation = ORIENTATION_LANDSCAPE;
1731cdf0e10cSrcweir 			}
1732cdf0e10cSrcweir 			else
1733cdf0e10cSrcweir 			{
1734cdf0e10cSrcweir 				meOrientation = ORIENTATION_PORTRAIT;
1735cdf0e10cSrcweir 			}
1736cdf0e10cSrcweir 		}
1737cdf0e10cSrcweir 	}
1738cdf0e10cSrcweir }
1739cdf0e10cSrcweir 
1740cdf0e10cSrcweir 
1741cdf0e10cSrcweir /*************************************************************************
1742cdf0e10cSrcweir |*
1743cdf0e10cSrcweir |*
1744cdf0e10cSrcweir |*
1745cdf0e10cSrcweir \************************************************************************/
1746cdf0e10cSrcweir 
1747cdf0e10cSrcweir void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
1748cdf0e10cSrcweir {
1749cdf0e10cSrcweir 	if (nLft != GetLftBorder() || nUpp != GetUppBorder() ||
1750cdf0e10cSrcweir 		nRgt != GetRgtBorder() || nLwr != GetLwrBorder() )
1751cdf0e10cSrcweir 	{
1752cdf0e10cSrcweir 		FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
1753cdf0e10cSrcweir 	}
1754cdf0e10cSrcweir }
1755cdf0e10cSrcweir 
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir /*************************************************************************
1758cdf0e10cSrcweir |*
1759cdf0e10cSrcweir |*
1760cdf0e10cSrcweir |*
1761cdf0e10cSrcweir \************************************************************************/
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir void SdPage::SetLftBorder(sal_Int32 nBorder)
1764cdf0e10cSrcweir {
1765cdf0e10cSrcweir 	if (nBorder != GetLftBorder() )
1766cdf0e10cSrcweir 	{
1767cdf0e10cSrcweir 		FmFormPage::SetLftBorder(nBorder);
1768cdf0e10cSrcweir 	}
1769cdf0e10cSrcweir }
1770cdf0e10cSrcweir 
1771cdf0e10cSrcweir 
1772cdf0e10cSrcweir /*************************************************************************
1773cdf0e10cSrcweir |*
1774cdf0e10cSrcweir |*
1775cdf0e10cSrcweir |*
1776cdf0e10cSrcweir \************************************************************************/
1777cdf0e10cSrcweir 
1778cdf0e10cSrcweir void SdPage::SetRgtBorder(sal_Int32 nBorder)
1779cdf0e10cSrcweir {
1780cdf0e10cSrcweir 	if (nBorder != GetRgtBorder() )
1781cdf0e10cSrcweir 	{
1782cdf0e10cSrcweir 		FmFormPage::SetRgtBorder(nBorder);
1783cdf0e10cSrcweir 	}
1784cdf0e10cSrcweir }
1785cdf0e10cSrcweir 
1786cdf0e10cSrcweir 
1787cdf0e10cSrcweir /*************************************************************************
1788cdf0e10cSrcweir |*
1789cdf0e10cSrcweir |*
1790cdf0e10cSrcweir |*
1791cdf0e10cSrcweir \************************************************************************/
1792cdf0e10cSrcweir 
1793cdf0e10cSrcweir void SdPage::SetUppBorder(sal_Int32 nBorder)
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir 	if (nBorder != GetUppBorder() )
1796cdf0e10cSrcweir 	{
1797cdf0e10cSrcweir 		FmFormPage::SetUppBorder(nBorder);
1798cdf0e10cSrcweir 	}
1799cdf0e10cSrcweir }
1800cdf0e10cSrcweir 
1801cdf0e10cSrcweir 
1802cdf0e10cSrcweir /*************************************************************************
1803cdf0e10cSrcweir |*
1804cdf0e10cSrcweir |*
1805cdf0e10cSrcweir |*
1806cdf0e10cSrcweir \************************************************************************/
1807cdf0e10cSrcweir 
1808cdf0e10cSrcweir void SdPage::SetLwrBorder(sal_Int32 nBorder)
1809cdf0e10cSrcweir {
1810cdf0e10cSrcweir 	if (nBorder != GetLwrBorder() )
1811cdf0e10cSrcweir 	{
1812cdf0e10cSrcweir 		FmFormPage::SetLwrBorder(nBorder);
1813cdf0e10cSrcweir 	}
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir /*************************************************************************
1817cdf0e10cSrcweir |*
1818cdf0e10cSrcweir |* Setzt BackgroundFullSize und ruft dann AdjustBackground auf
1819cdf0e10cSrcweir |*
1820cdf0e10cSrcweir \************************************************************************/
1821cdf0e10cSrcweir 
1822cdf0e10cSrcweir void SdPage::SetBackgroundFullSize( sal_Bool bIn )
1823cdf0e10cSrcweir {
1824cdf0e10cSrcweir 	if( bIn != mbBackgroundFullSize )
1825cdf0e10cSrcweir 	{
1826cdf0e10cSrcweir 		mbBackgroundFullSize = bIn;
1827cdf0e10cSrcweir 	}
1828cdf0e10cSrcweir }
1829cdf0e10cSrcweir 
1830cdf0e10cSrcweir /*************************************************************************
1831cdf0e10cSrcweir |*
1832cdf0e10cSrcweir |* Alle Objekte an neue Seitengroesse anpassen
1833cdf0e10cSrcweir |*
1834cdf0e10cSrcweir |* bScaleAllObj: Alle Objekte werden in die neue Flaeche innerhalb der
1835cdf0e10cSrcweir |* Seitenraender skaliert. Dabei werden die Position, Groesse und bei
1836cdf0e10cSrcweir |* Praesentationsobjekten auf der MasterPage auch die Schrifthoehe der
1837cdf0e10cSrcweir |* Praesentationsvorlagen skaliert.
1838cdf0e10cSrcweir |*
1839cdf0e10cSrcweir \************************************************************************/
1840cdf0e10cSrcweir 
1841cdf0e10cSrcweir void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderRect, sal_Bool bScaleAllObj)
1842cdf0e10cSrcweir {
1843cdf0e10cSrcweir 	sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1844cdf0e10cSrcweir 
1845cdf0e10cSrcweir 	mbScaleObjects = bScaleAllObj;
1846cdf0e10cSrcweir 	SdrObject* pObj = NULL;
1847cdf0e10cSrcweir 	Point aRefPnt(0, 0);
1848cdf0e10cSrcweir 	Size aNewPageSize(rNewPageSize);
1849cdf0e10cSrcweir 	sal_Int32 nLeft  = rNewBorderRect.Left();
1850cdf0e10cSrcweir 	sal_Int32 nRight = rNewBorderRect.Right();
1851cdf0e10cSrcweir 	sal_Int32 nUpper = rNewBorderRect.Top();
1852cdf0e10cSrcweir 	sal_Int32 nLower = rNewBorderRect.Bottom();
1853cdf0e10cSrcweir 
1854cdf0e10cSrcweir 	// Negative Werte stehen fuer nicht zu aendernde Werte
1855cdf0e10cSrcweir 	// -> aktuelle Werte verwenden
1856cdf0e10cSrcweir 	if (aNewPageSize.Width() < 0)
1857cdf0e10cSrcweir 	{
1858cdf0e10cSrcweir 		aNewPageSize.Width() = GetWdt();
1859cdf0e10cSrcweir 	}
1860cdf0e10cSrcweir 	if (aNewPageSize.Height() < 0)
1861cdf0e10cSrcweir 	{
1862cdf0e10cSrcweir 		aNewPageSize.Height() = GetHgt();
1863cdf0e10cSrcweir 	}
1864cdf0e10cSrcweir 	if (nLeft < 0)
1865cdf0e10cSrcweir 	{
1866cdf0e10cSrcweir 		nLeft = GetLftBorder();
1867cdf0e10cSrcweir 	}
1868cdf0e10cSrcweir 	if (nRight < 0)
1869cdf0e10cSrcweir 	{
1870cdf0e10cSrcweir 		nRight = GetRgtBorder();
1871cdf0e10cSrcweir 	}
1872cdf0e10cSrcweir 	if (nUpper < 0)
1873cdf0e10cSrcweir 	{
1874cdf0e10cSrcweir 		nUpper = GetUppBorder();
1875cdf0e10cSrcweir 	}
1876cdf0e10cSrcweir 	if (nLower < 0)
1877cdf0e10cSrcweir 	{
1878cdf0e10cSrcweir 		nLower = GetLwrBorder();
1879cdf0e10cSrcweir 	}
1880cdf0e10cSrcweir 
1881cdf0e10cSrcweir 	Point aBackgroundPos(nLeft, nUpper);
1882cdf0e10cSrcweir 	Size aBackgroundSize(aNewPageSize);
1883cdf0e10cSrcweir 	Rectangle aBorderRect (aBackgroundPos, aBackgroundSize);
1884cdf0e10cSrcweir 
1885cdf0e10cSrcweir 	if (mbScaleObjects)
1886cdf0e10cSrcweir 	{
1887cdf0e10cSrcweir 		aBackgroundSize.Width()  -= nLeft  + nRight;
1888cdf0e10cSrcweir 		aBackgroundSize.Height() -= nUpper + nLower;
1889cdf0e10cSrcweir 		aBorderRect.SetSize(aBackgroundSize);
1890cdf0e10cSrcweir 		aNewPageSize = aBackgroundSize;
1891cdf0e10cSrcweir 	}
1892cdf0e10cSrcweir 
1893cdf0e10cSrcweir 	long nOldWidth  = GetWdt() - GetLftBorder() - GetRgtBorder();
1894cdf0e10cSrcweir 	long nOldHeight = GetHgt() - GetUppBorder() - GetLwrBorder();
1895cdf0e10cSrcweir 
1896cdf0e10cSrcweir 	Fraction aFractX = Fraction(aNewPageSize.Width(), nOldWidth);
1897cdf0e10cSrcweir 	Fraction aFractY = Fraction(aNewPageSize.Height(), nOldHeight);
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir 	sal_uLong nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
1900cdf0e10cSrcweir 
1901cdf0e10cSrcweir 	for (sal_uLong nObj = 0; nObj < nObjCnt; nObj++)
1902cdf0e10cSrcweir 	{
1903cdf0e10cSrcweir 		sal_Bool bIsPresObjOnMaster = sal_False;
1904cdf0e10cSrcweir 
1905cdf0e10cSrcweir 		// Alle Objekte
1906cdf0e10cSrcweir 		pObj = GetObj(nObj);
1907cdf0e10cSrcweir 
1908cdf0e10cSrcweir 		if (mbMaster && IsPresObj(pObj))
1909cdf0e10cSrcweir 		{
1910cdf0e10cSrcweir 			// Es ist ein Praesentationsobjekt auf der MasterPage
1911cdf0e10cSrcweir 			bIsPresObjOnMaster = sal_True;
1912cdf0e10cSrcweir 		}
1913cdf0e10cSrcweir 
1914cdf0e10cSrcweir 		if (pObj)
1915cdf0e10cSrcweir 		{
1916cdf0e10cSrcweir 			// #88084# remember aTopLeft as original TopLeft
1917cdf0e10cSrcweir 			Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
1918cdf0e10cSrcweir 
1919cdf0e10cSrcweir             if (!pObj->IsEdgeObj())
1920cdf0e10cSrcweir 			{
1921cdf0e10cSrcweir 				/**************************************************************
1922cdf0e10cSrcweir 				* Objekt skalieren
1923cdf0e10cSrcweir 				**************************************************************/
1924cdf0e10cSrcweir 				if (mbScaleObjects)
1925cdf0e10cSrcweir 				{
1926cdf0e10cSrcweir 					// #88084# use aTopLeft as original TopLeft
1927cdf0e10cSrcweir 					aRefPnt = aTopLeft;
1928cdf0e10cSrcweir 				}
1929cdf0e10cSrcweir 
1930cdf0e10cSrcweir 				pObj->Resize(aRefPnt, aFractX, aFractY);
1931cdf0e10cSrcweir 
1932cdf0e10cSrcweir 				if (mbScaleObjects)
1933cdf0e10cSrcweir 				{
1934cdf0e10cSrcweir 					SdrObjKind eObjKind = (SdrObjKind) pObj->GetObjIdentifier();
1935cdf0e10cSrcweir 
1936cdf0e10cSrcweir 					if (bIsPresObjOnMaster)
1937cdf0e10cSrcweir 					{
1938cdf0e10cSrcweir 						/**********************************************************
1939cdf0e10cSrcweir 						* Praesentationsvorlage: Texthoehe anpassen
1940cdf0e10cSrcweir 						**********************************************************/
1941cdf0e10cSrcweir 						sal_uInt16 nIndexTitle = 0;
1942cdf0e10cSrcweir 						sal_uInt16 nIndexOutline = 0;
1943cdf0e10cSrcweir 						sal_uInt16 nIndexNotes = 0;
1944cdf0e10cSrcweir 
1945cdf0e10cSrcweir 						if (pObj == GetPresObj(PRESOBJ_TITLE, nIndexTitle))
1946cdf0e10cSrcweir 						{
1947cdf0e10cSrcweir 							SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir 							if (pTitleSheet)
1950cdf0e10cSrcweir 							{
1951cdf0e10cSrcweir 								SfxItemSet& rSet = pTitleSheet->GetItemSet();
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir 								SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT);
1954cdf0e10cSrcweir 								sal_uLong nFontHeight = rOldHgt.GetHeight();
1955cdf0e10cSrcweir 								nFontHeight = long(nFontHeight * (double) aFractY);
1956cdf0e10cSrcweir 								rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1957cdf0e10cSrcweir 
1958cdf0e10cSrcweir 								if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1959cdf0e10cSrcweir 								{
1960cdf0e10cSrcweir 									rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1961cdf0e10cSrcweir 									nFontHeight = rOldHgt.GetHeight();
1962cdf0e10cSrcweir 									nFontHeight = long(nFontHeight * (double) aFractY);
1963cdf0e10cSrcweir 									rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1964cdf0e10cSrcweir 								}
1965cdf0e10cSrcweir 
1966cdf0e10cSrcweir 								if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1967cdf0e10cSrcweir 								{
1968cdf0e10cSrcweir 									rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1969cdf0e10cSrcweir 									nFontHeight = rOldHgt.GetHeight();
1970cdf0e10cSrcweir 									nFontHeight = long(nFontHeight * (double) aFractY);
1971cdf0e10cSrcweir 									rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1972cdf0e10cSrcweir 								}
1973cdf0e10cSrcweir 
1974cdf0e10cSrcweir 								pTitleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1975cdf0e10cSrcweir 							}
1976cdf0e10cSrcweir 						}
1977cdf0e10cSrcweir 						else if (pObj == GetPresObj(PRESOBJ_OUTLINE, nIndexOutline))
1978cdf0e10cSrcweir 						{
1979cdf0e10cSrcweir 							String aName(GetLayoutName());
1980cdf0e10cSrcweir 							aName += sal_Unicode( ' ' );
1981cdf0e10cSrcweir 
1982cdf0e10cSrcweir 							for (sal_uInt16 i=1; i<=9; i++)
1983cdf0e10cSrcweir 							{
1984cdf0e10cSrcweir 								String sLayoutName(aName);
1985cdf0e10cSrcweir 								sLayoutName += String::CreateFromInt32( (sal_Int32)i );
1986cdf0e10cSrcweir 								SfxStyleSheet* pOutlineSheet = (SfxStyleSheet*)((SdDrawDocument*) pModel)->GetStyleSheetPool()->Find(sLayoutName, SD_STYLE_FAMILY_MASTERPAGE);
1987cdf0e10cSrcweir 
1988cdf0e10cSrcweir 								if (pOutlineSheet)
1989cdf0e10cSrcweir 								{
1990cdf0e10cSrcweir 									// Neue Fonthoehe berechnen
1991cdf0e10cSrcweir 									SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
1992cdf0e10cSrcweir 
1993cdf0e10cSrcweir 									SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT);
1994cdf0e10cSrcweir 									sal_uLong nFontHeight = rOldHgt.GetHeight();
1995cdf0e10cSrcweir 									nFontHeight = long(nFontHeight * (double) aFractY);
1996cdf0e10cSrcweir 									aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1997cdf0e10cSrcweir 
1998cdf0e10cSrcweir 									if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1999cdf0e10cSrcweir 									{
2000cdf0e10cSrcweir 										rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
2001cdf0e10cSrcweir 										nFontHeight = rOldHgt.GetHeight();
2002cdf0e10cSrcweir 										nFontHeight = long(nFontHeight * (double) aFractY);
2003cdf0e10cSrcweir 										aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
2004cdf0e10cSrcweir 									}
2005cdf0e10cSrcweir 
2006cdf0e10cSrcweir 									if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
2007cdf0e10cSrcweir 									{
2008cdf0e10cSrcweir 										rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
2009cdf0e10cSrcweir 										nFontHeight = rOldHgt.GetHeight();
2010cdf0e10cSrcweir 										nFontHeight = long(nFontHeight * (double) aFractY);
2011cdf0e10cSrcweir 										aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
2012cdf0e10cSrcweir 									}
2013cdf0e10cSrcweir 
2014cdf0e10cSrcweir 									// Bullet anpassen
2015cdf0e10cSrcweir 									((SdStyleSheet*) pOutlineSheet)->AdjustToFontHeight(aTempSet, sal_False);
2016cdf0e10cSrcweir 
2017cdf0e10cSrcweir 									// Sonderbehandlung: die INVALIDS auf NULL-Pointer
2018cdf0e10cSrcweir 									// zurueckgesetzen (sonst landen INVALIDs oder
2019cdf0e10cSrcweir 									// Pointer auf die DefaultItems in der Vorlage;
2020cdf0e10cSrcweir 									// beides wuerde die Attribut-Vererbung unterbinden)
2021cdf0e10cSrcweir 									aTempSet.ClearInvalidItems();
2022cdf0e10cSrcweir 
2023cdf0e10cSrcweir 									// Sonderbehandlung: nur die gueltigen Anteile des
2024cdf0e10cSrcweir 									// BulletItems
2025cdf0e10cSrcweir 									if (aTempSet.GetItemState(EE_PARA_BULLET) == SFX_ITEM_AVAILABLE)
2026cdf0e10cSrcweir 									{
2027cdf0e10cSrcweir 										SvxBulletItem aOldBulItem((SvxBulletItem&) pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET));
2028cdf0e10cSrcweir 										SvxBulletItem& rNewBulItem = (SvxBulletItem&) aTempSet.Get(EE_PARA_BULLET);
2029cdf0e10cSrcweir 										aOldBulItem.CopyValidProperties(rNewBulItem);
2030cdf0e10cSrcweir 										aTempSet.Put(aOldBulItem);
2031cdf0e10cSrcweir 									}
2032cdf0e10cSrcweir 
2033cdf0e10cSrcweir 									pOutlineSheet->GetItemSet().Put(aTempSet);
2034cdf0e10cSrcweir 									pOutlineSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
2035cdf0e10cSrcweir 								}
2036cdf0e10cSrcweir 							}
2037cdf0e10cSrcweir 						}
2038cdf0e10cSrcweir 						else if (pObj == GetPresObj(PRESOBJ_NOTES, nIndexNotes))
2039cdf0e10cSrcweir 						{
2040cdf0e10cSrcweir 							SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PRESOBJ_NOTES);
2041cdf0e10cSrcweir 
2042cdf0e10cSrcweir 							if (pNotesSheet)
2043cdf0e10cSrcweir 							{
2044cdf0e10cSrcweir 								sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height();
2045cdf0e10cSrcweir 								sal_uLong nFontHeight = (sal_uLong) (nHeight * 0.0741);
2046cdf0e10cSrcweir 								SfxItemSet& rSet = pNotesSheet->GetItemSet();
2047cdf0e10cSrcweir                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
2048cdf0e10cSrcweir                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
2049cdf0e10cSrcweir                                 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
2050cdf0e10cSrcweir 								pNotesSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
2051cdf0e10cSrcweir 							}
2052cdf0e10cSrcweir 						}
2053cdf0e10cSrcweir 					}
2054cdf0e10cSrcweir 					else if ( eObjKind != OBJ_TITLETEXT   &&
2055cdf0e10cSrcweir 							  eObjKind != OBJ_OUTLINETEXT &&
2056cdf0e10cSrcweir 							  pObj->ISA(SdrTextObj)       &&
2057cdf0e10cSrcweir 							  pObj->GetOutlinerParaObject() )
2058cdf0e10cSrcweir 					{
2059cdf0e10cSrcweir 						/******************************************************
2060cdf0e10cSrcweir 						* Normales Textobjekt: Texthoehe anpassen
2061cdf0e10cSrcweir 						******************************************************/
2062cdf0e10cSrcweir 						sal_uLong nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
2063cdf0e10cSrcweir 						sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT;
2064cdf0e10cSrcweir 						if ( nScriptType == SCRIPTTYPE_ASIAN )
2065cdf0e10cSrcweir 							nWhich = EE_CHAR_FONTHEIGHT_CJK;
2066cdf0e10cSrcweir 						else if ( nScriptType == SCRIPTTYPE_COMPLEX )
2067cdf0e10cSrcweir 							nWhich = EE_CHAR_FONTHEIGHT_CTL;
2068cdf0e10cSrcweir 
2069cdf0e10cSrcweir 						// #88084# use more modern method to scale the text height
2070cdf0e10cSrcweir 						sal_uInt32 nFontHeight = ((SvxFontHeightItem&)pObj->GetMergedItem(nWhich)).GetHeight();
2071cdf0e10cSrcweir 						sal_uInt32 nNewFontHeight = sal_uInt32((double)nFontHeight * (double)aFractY);
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir 						pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
2074cdf0e10cSrcweir 					}
2075cdf0e10cSrcweir 				}
2076cdf0e10cSrcweir 			}
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir 			if (mbScaleObjects && !pObj->IsEdgeObj())
2079cdf0e10cSrcweir 			{
2080cdf0e10cSrcweir 				/**************************************************************
2081cdf0e10cSrcweir 				* Objektposition skalieren
2082cdf0e10cSrcweir 				**************************************************************/
2083cdf0e10cSrcweir 				Point aNewPos;
2084cdf0e10cSrcweir 
2085cdf0e10cSrcweir 				// #76447# corrected scaling; only distances may be scaled
2086cdf0e10cSrcweir 				// #88084# use aTopLeft as original TopLeft
2087cdf0e10cSrcweir 				aNewPos.X() = long((aTopLeft.X() - GetLftBorder()) * (double)aFractX) + nLeft;
2088cdf0e10cSrcweir 				aNewPos.Y() = long((aTopLeft.Y() - GetUppBorder()) * (double)aFractY) + nUpper;
2089cdf0e10cSrcweir 
2090cdf0e10cSrcweir 				Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir 				if (aVec.Height() != 0 || aVec.Width() != 0)
2093cdf0e10cSrcweir 				{
2094cdf0e10cSrcweir 					pObj->NbcMove(aVec);
2095cdf0e10cSrcweir 				}
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir 				pObj->SetChanged();
2098cdf0e10cSrcweir 				pObj->BroadcastObjectChange();
2099cdf0e10cSrcweir 			}
2100cdf0e10cSrcweir 		}
2101cdf0e10cSrcweir 	}
2102cdf0e10cSrcweir }
2103cdf0e10cSrcweir 
2104cdf0e10cSrcweir SdrObject* convertPresentationObjectImpl( SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, Rectangle aRect )
2105cdf0e10cSrcweir {
2106cdf0e10cSrcweir 	SdDrawDocument* pModel = static_cast< SdDrawDocument* >( rPage.GetModel() );
2107cdf0e10cSrcweir 	DBG_ASSERT( pModel, "sd::convertPresentationObjectImpl(), no model on page!" );
2108cdf0e10cSrcweir 	if( !pModel || !pSourceObj )
2109cdf0e10cSrcweir 		return pSourceObj;
2110cdf0e10cSrcweir 
2111cdf0e10cSrcweir 	::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
2112cdf0e10cSrcweir 	const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir 	SdrObject* pNewObj = pSourceObj;
2115cdf0e10cSrcweir 	if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) )
2116cdf0e10cSrcweir 	{
2117cdf0e10cSrcweir 		pNewObj = rPage.CreatePresObj(PRESOBJ_OUTLINE, bVertical, aRect);
2118cdf0e10cSrcweir 
2119cdf0e10cSrcweir 		// Text des Untertitels in das PRESOBJ_OUTLINE setzen
2120cdf0e10cSrcweir 		OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir 		if(pOutlParaObj)
2123cdf0e10cSrcweir 		{
2124cdf0e10cSrcweir 			// Text umsetzen
2125cdf0e10cSrcweir 			::sd::Outliner* pOutl = pModel->GetInternalOutliner( sal_True );
2126cdf0e10cSrcweir 			pOutl->Clear();
2127cdf0e10cSrcweir 			pOutl->SetText( *pOutlParaObj );
2128cdf0e10cSrcweir 			pOutlParaObj = pOutl->CreateParaObject();
2129cdf0e10cSrcweir 			pNewObj->SetOutlinerParaObject( pOutlParaObj );
2130cdf0e10cSrcweir 			pOutl->Clear();
2131cdf0e10cSrcweir 			pNewObj->SetEmptyPresObj(sal_False);
2132cdf0e10cSrcweir 
2133cdf0e10cSrcweir 			for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
2134cdf0e10cSrcweir 			{
2135cdf0e10cSrcweir 				// Neue Vorlage zuweisen
2136cdf0e10cSrcweir 				String aName(rPage.GetLayoutName());
2137cdf0e10cSrcweir 				aName += sal_Unicode( ' ' );
2138cdf0e10cSrcweir 				aName += String::CreateFromInt32( nLevel );
2139cdf0e10cSrcweir 				SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE) );
2140cdf0e10cSrcweir 
2141cdf0e10cSrcweir 				if (pSheet)
2142cdf0e10cSrcweir 				{
2143cdf0e10cSrcweir 					if (nLevel == 1)
2144cdf0e10cSrcweir 					{
2145cdf0e10cSrcweir 						SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2146cdf0e10cSrcweir 
2147cdf0e10cSrcweir 						if (pSubtitleSheet)
2148cdf0e10cSrcweir 							pOutlParaObj->ChangeStyleSheetName(SD_STYLE_FAMILY_MASTERPAGE, pSubtitleSheet->GetName(), pSheet->GetName());
2149cdf0e10cSrcweir 					}
2150cdf0e10cSrcweir 
2151cdf0e10cSrcweir 					pNewObj->StartListening(*pSheet);
2152cdf0e10cSrcweir 				}
2153cdf0e10cSrcweir 			}
2154cdf0e10cSrcweir 
2155cdf0e10cSrcweir 			// LRSpace-Item loeschen
2156cdf0e10cSrcweir 			SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
2157cdf0e10cSrcweir 
2158cdf0e10cSrcweir 			aSet.Put(pNewObj->GetMergedItemSet());
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir 			aSet.ClearItem(EE_PARA_LRSPACE);
2161cdf0e10cSrcweir 
2162cdf0e10cSrcweir 			pNewObj->SetMergedItemSet(aSet);
2163cdf0e10cSrcweir 
2164cdf0e10cSrcweir 			if( bUndo )
2165cdf0e10cSrcweir 				pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir 			// Remove outline shape from page
2168cdf0e10cSrcweir 			rPage.RemoveObject( pSourceObj->GetOrdNum() );
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir 			if( !bUndo )
2171cdf0e10cSrcweir 				SdrObject::Free( pSourceObj );
2172cdf0e10cSrcweir 		}
2173cdf0e10cSrcweir 	}
2174cdf0e10cSrcweir 	else if((eObjKind == PRESOBJ_TEXT) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) )
2175cdf0e10cSrcweir 	{
2176cdf0e10cSrcweir 		// is there an outline shape we can use to replace empty subtitle shape?
2177cdf0e10cSrcweir 		pNewObj = rPage.CreatePresObj(PRESOBJ_TEXT, bVertical, aRect);
2178cdf0e10cSrcweir 
2179cdf0e10cSrcweir 		// Text des Gliederungsobjekts in das PRESOBJ_TITLE setzen
2180cdf0e10cSrcweir 		OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2181cdf0e10cSrcweir 
2182cdf0e10cSrcweir 		if(pOutlParaObj)
2183cdf0e10cSrcweir 		{
2184cdf0e10cSrcweir 			// Text umsetzen
2185cdf0e10cSrcweir 			::sd::Outliner* pOutl = pModel->GetInternalOutliner();
2186cdf0e10cSrcweir 			pOutl->Clear();
2187cdf0e10cSrcweir 			pOutl->SetText( *pOutlParaObj );
2188cdf0e10cSrcweir 			pOutlParaObj = pOutl->CreateParaObject();
2189cdf0e10cSrcweir 			pNewObj->SetOutlinerParaObject( pOutlParaObj );
2190cdf0e10cSrcweir 			pOutl->Clear();
2191cdf0e10cSrcweir 			pNewObj->SetEmptyPresObj(sal_False);
2192cdf0e10cSrcweir 
2193cdf0e10cSrcweir 			// Linken Einzug zuruecksetzen
2194cdf0e10cSrcweir 			SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
2195cdf0e10cSrcweir 
2196cdf0e10cSrcweir 			aSet.Put(pNewObj->GetMergedItemSet());
2197cdf0e10cSrcweir 
2198cdf0e10cSrcweir 			const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&) aSet.Get(EE_PARA_LRSPACE);
2199cdf0e10cSrcweir 			SvxLRSpaceItem aNewLRItem(rLRItem);
2200cdf0e10cSrcweir 			aNewLRItem.SetTxtLeft(0);
2201cdf0e10cSrcweir 			aSet.Put(aNewLRItem);
2202cdf0e10cSrcweir 
2203cdf0e10cSrcweir 			pNewObj->SetMergedItemSet(aSet);
2204cdf0e10cSrcweir 
2205cdf0e10cSrcweir 			SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2206cdf0e10cSrcweir 			if (pSheet)
2207cdf0e10cSrcweir 				pNewObj->SetStyleSheet(pSheet, sal_True);
2208cdf0e10cSrcweir 
2209cdf0e10cSrcweir 			// Remove subtitle shape from page
2210cdf0e10cSrcweir 			if( bUndo )
2211cdf0e10cSrcweir 				pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
2212cdf0e10cSrcweir 
2213cdf0e10cSrcweir 			rPage.RemoveObject( pSourceObj->GetOrdNum() );
2214cdf0e10cSrcweir 
2215cdf0e10cSrcweir 			if( !bUndo )
2216cdf0e10cSrcweir 				SdrObject::Free( pSourceObj );
2217cdf0e10cSrcweir 		}
2218cdf0e10cSrcweir 	}
2219cdf0e10cSrcweir 	else if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) )
2220cdf0e10cSrcweir 	{
2221cdf0e10cSrcweir 		switch( pSourceObj->GetObjIdentifier() )
2222cdf0e10cSrcweir 		{
2223cdf0e10cSrcweir 		case OBJ_TABLE: eObjKind = PRESOBJ_TABLE; break;
2224cdf0e10cSrcweir 		case OBJ_MEDIA: eObjKind = PRESOBJ_MEDIA; break;
2225cdf0e10cSrcweir 		case OBJ_GRAF: eObjKind = PRESOBJ_GRAPHIC; break;
2226cdf0e10cSrcweir 		case OBJ_OLE2: eObjKind = PRESOBJ_OBJECT; break;
2227cdf0e10cSrcweir 		}
2228cdf0e10cSrcweir 	}
2229cdf0e10cSrcweir 
2230cdf0e10cSrcweir 	return pNewObj;
2231cdf0e10cSrcweir }
2232cdf0e10cSrcweir 
2233cdf0e10cSrcweir /** reuses or creates a presentation shape for an auto layout that fits the given parameter
2234cdf0e10cSrcweir 
2235cdf0e10cSrcweir 	@param	eObjKind
2236cdf0e10cSrcweir 		The kind of presentation shape we like to have
2237cdf0e10cSrcweir 	@param	nIndex
2238cdf0e10cSrcweir 		If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
2239cdf0e10cSrcweir 		looking for an existing presentation shape
2240cdf0e10cSrcweir 	@param	bVertical
2241cdf0e10cSrcweir 		If true, the shape is created vertical if bInit is true
2242cdf0e10cSrcweir 	@param	aRect
2243cdf0e10cSrcweir 		The rectangle that should be used to transform the shape
2244cdf0e10cSrcweir 	@param	bInit
2245cdf0e10cSrcweir 		If true the shape is created if not found
2246cdf0e10cSrcweir 	@returns
2247cdf0e10cSrcweir 		A presentation shape that was either found or created with the given parameters
2248cdf0e10cSrcweir */
2249cdf0e10cSrcweir SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind, bool bVertical, Rectangle aRect, bool bInit )
2250cdf0e10cSrcweir {
2251cdf0e10cSrcweir 	::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
2252cdf0e10cSrcweir 	const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
2253cdf0e10cSrcweir 
2254cdf0e10cSrcweir 	if (!pObj && bInit)
2255cdf0e10cSrcweir 	{
2256cdf0e10cSrcweir 		pObj = CreatePresObj(eObjKind, bVertical, aRect);
2257cdf0e10cSrcweir 	}
2258cdf0e10cSrcweir 	else if ( pObj && (pObj->GetUserCall() || bInit) )
2259cdf0e10cSrcweir 	{
2260cdf0e10cSrcweir 		// convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2261cdf0e10cSrcweir 		if( bInit )
2262cdf0e10cSrcweir 			pObj = convertPresentationObjectImpl( *this, pObj, eObjKind, bVertical, aRect );
2263cdf0e10cSrcweir 
2264cdf0e10cSrcweir 		if( bUndo )
2265cdf0e10cSrcweir 		{
2266cdf0e10cSrcweir 			pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
2267cdf0e10cSrcweir 			pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, sal_True, sal_True ) );
2268cdf0e10cSrcweir 			pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
2269cdf0e10cSrcweir 		}
2270cdf0e10cSrcweir 
2271cdf0e10cSrcweir //		if ( pObj->ISA(SdrGrafObj) && !pObj->IsEmptyPresObj() )
2272cdf0e10cSrcweir 			( /*(SdrGrafObj*)*/ pObj)->AdjustToMaxRect( aRect );
2273cdf0e10cSrcweir //		else
2274cdf0e10cSrcweir //			SetLogicRect( pObj, aRect );
2275cdf0e10cSrcweir 
2276cdf0e10cSrcweir 		pObj->SetUserCall(this);
2277cdf0e10cSrcweir 
2278cdf0e10cSrcweir 		SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
2279cdf0e10cSrcweir 		if( pTextObject )
2280cdf0e10cSrcweir 		{
2281cdf0e10cSrcweir 			if( pTextObject->IsVerticalWriting() != (bVertical ? sal_True : sal_False) )
2282cdf0e10cSrcweir 			{
2283cdf0e10cSrcweir 				pTextObject->SetVerticalWriting( bVertical );
2284cdf0e10cSrcweir 
2285cdf0e10cSrcweir 				// #94826# here make sure the correct anchoring is used when the object
2286cdf0e10cSrcweir 				// is re-used but orientation is changed
2287cdf0e10cSrcweir 				if(PRESOBJ_OUTLINE == eObjKind)
2288cdf0e10cSrcweir 					pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
2289cdf0e10cSrcweir 			}
2290cdf0e10cSrcweir 
2291cdf0e10cSrcweir 			if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) )
2292cdf0e10cSrcweir 			{
2293cdf0e10cSrcweir 				if ( pTextObject->IsAutoGrowHeight() )
2294cdf0e10cSrcweir 				{
2295cdf0e10cSrcweir 					// switch off AutoGrowHeight, set new MinHeight
2296cdf0e10cSrcweir 					SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
2297cdf0e10cSrcweir 					SdrTextMinFrameHeightItem aMinHeight( aRect.GetSize().Height() );
2298cdf0e10cSrcweir 					aTempAttr.Put( aMinHeight );
2299cdf0e10cSrcweir 					aTempAttr.Put( SdrTextAutoGrowHeightItem(sal_False) );
2300cdf0e10cSrcweir 					pTextObject->SetMergedItemSet(aTempAttr);
2301cdf0e10cSrcweir 					pTextObject->SetLogicRect(aRect);
2302cdf0e10cSrcweir 
2303cdf0e10cSrcweir 					// switch on AutoGrowHeight
2304cdf0e10cSrcweir 					SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
2305cdf0e10cSrcweir 					aAttr.Put( SdrTextAutoGrowHeightItem(sal_True) );
2306cdf0e10cSrcweir 
2307cdf0e10cSrcweir 					pTextObject->SetMergedItemSet(aAttr);
2308cdf0e10cSrcweir 				}
2309cdf0e10cSrcweir 
2310cdf0e10cSrcweir 				if ( pTextObject->IsAutoGrowWidth() )
2311cdf0e10cSrcweir 				{
2312cdf0e10cSrcweir 					// switch off AutoGrowWidth , set new MinWidth
2313cdf0e10cSrcweir 					SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
2314cdf0e10cSrcweir 					SdrTextMinFrameWidthItem aMinWidth( aRect.GetSize().Width() );
2315cdf0e10cSrcweir 					aTempAttr.Put( aMinWidth );
2316cdf0e10cSrcweir 					aTempAttr.Put( SdrTextAutoGrowWidthItem(sal_False) );
2317cdf0e10cSrcweir 					pTextObject->SetMergedItemSet(aTempAttr);
2318cdf0e10cSrcweir 					pTextObject->SetLogicRect(aRect);
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir 					// switch on AutoGrowWidth
2321cdf0e10cSrcweir 					SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
2322cdf0e10cSrcweir 					aAttr.Put( SdrTextAutoGrowWidthItem(sal_True) );
2323cdf0e10cSrcweir 					pTextObject->SetMergedItemSet(aAttr);
2324cdf0e10cSrcweir 				}
2325cdf0e10cSrcweir 			}
2326cdf0e10cSrcweir 		}
2327cdf0e10cSrcweir 	}
2328cdf0e10cSrcweir 
2329cdf0e10cSrcweir 	if(pObj && bInit )
2330cdf0e10cSrcweir 	{
2331cdf0e10cSrcweir 		if( !IsPresObj( pObj ) )
2332cdf0e10cSrcweir 		{
2333cdf0e10cSrcweir 			if( bUndo )
2334cdf0e10cSrcweir 				pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
2335cdf0e10cSrcweir 
2336cdf0e10cSrcweir 			InsertPresObj( pObj, eObjKind );
2337cdf0e10cSrcweir 		}
2338cdf0e10cSrcweir 
2339cdf0e10cSrcweir 		// make adjustments for vertical title and outline shapes
2340cdf0e10cSrcweir 		if( bVertical && (( eObjKind == PRESOBJ_TITLE) || (eObjKind == PRESOBJ_OUTLINE)))
2341cdf0e10cSrcweir 		{
2342cdf0e10cSrcweir 			SfxItemSet aNewSet(pObj->GetMergedItemSet());
2343cdf0e10cSrcweir 			aNewSet.Put( SdrTextAutoGrowWidthItem(sal_True) );
2344cdf0e10cSrcweir 			aNewSet.Put( SdrTextAutoGrowHeightItem(sal_False) );
2345cdf0e10cSrcweir 			if( eObjKind == PRESOBJ_OUTLINE )
2346cdf0e10cSrcweir 			{
2347cdf0e10cSrcweir 				aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
2348cdf0e10cSrcweir 				aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
2349cdf0e10cSrcweir 			}
2350cdf0e10cSrcweir 			pObj->SetMergedItemSet(aNewSet);
2351cdf0e10cSrcweir 		}
2352cdf0e10cSrcweir 	}
2353cdf0e10cSrcweir 
2354cdf0e10cSrcweir 	if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || !pObj->ISA(SdrGrafObj) ) )
2355cdf0e10cSrcweir 		pObj->AdjustToMaxRect( aRect );
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir 	return pObj;
2358cdf0e10cSrcweir }
2359cdf0e10cSrcweir 
2360cdf0e10cSrcweir 
2361cdf0e10cSrcweir /*************************************************************************
2362cdf0e10cSrcweir |*
2363cdf0e10cSrcweir |* Liefert den PresObjKind eines Objektes zurueck
2364cdf0e10cSrcweir |*
2365cdf0e10cSrcweir \************************************************************************/
2366cdf0e10cSrcweir 
2367cdf0e10cSrcweir PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const
2368cdf0e10cSrcweir {
2369cdf0e10cSrcweir 	PresObjKind eKind = PRESOBJ_NONE;
2370cdf0e10cSrcweir 	if( (pObj != 0) && (maPresentationShapeList.hasShape(*pObj)) )
2371cdf0e10cSrcweir 	{
2372cdf0e10cSrcweir 		SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
2373cdf0e10cSrcweir 		if( pInfo )
2374cdf0e10cSrcweir 			eKind = pInfo->mePresObjKind;
2375cdf0e10cSrcweir 	}
2376cdf0e10cSrcweir 
2377cdf0e10cSrcweir 	return eKind;
2378cdf0e10cSrcweir }
2379cdf0e10cSrcweir 
2380cdf0e10cSrcweir bool SdPage::IsPresObj(const SdrObject* pObj)
2381cdf0e10cSrcweir {
2382cdf0e10cSrcweir 	return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
2383cdf0e10cSrcweir }
2384cdf0e10cSrcweir 
2385cdf0e10cSrcweir void SdPage::RemovePresObj(const SdrObject* pObj)
2386cdf0e10cSrcweir {
2387cdf0e10cSrcweir 	if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
2388cdf0e10cSrcweir 	{
2389cdf0e10cSrcweir 		SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
2390cdf0e10cSrcweir 		if( pInfo )
2391cdf0e10cSrcweir 			pInfo->mePresObjKind = PRESOBJ_NONE;
2392cdf0e10cSrcweir 		maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
2393cdf0e10cSrcweir 	}
2394cdf0e10cSrcweir }
2395cdf0e10cSrcweir 
2396cdf0e10cSrcweir void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
2397cdf0e10cSrcweir {
2398cdf0e10cSrcweir 	DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2399cdf0e10cSrcweir 	DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2400cdf0e10cSrcweir 	if( pObj )
2401cdf0e10cSrcweir 	{
2402cdf0e10cSrcweir 		SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
2403cdf0e10cSrcweir 		if( pInfo )
2404cdf0e10cSrcweir 			pInfo->mePresObjKind = eKind;
2405cdf0e10cSrcweir 		maPresentationShapeList.addShape(*pObj);
2406cdf0e10cSrcweir 	}
2407cdf0e10cSrcweir }
2408cdf0e10cSrcweir 
2409cdf0e10cSrcweir /*************************************************************************
2410cdf0e10cSrcweir |*
2411cdf0e10cSrcweir |* Text des Objektes setzen
2412cdf0e10cSrcweir |*
2413cdf0e10cSrcweir \************************************************************************/
2414cdf0e10cSrcweir 
2415cdf0e10cSrcweir void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind,	const String& rString )
2416cdf0e10cSrcweir {
2417cdf0e10cSrcweir 	if ( pObj )
2418cdf0e10cSrcweir 	{
2419cdf0e10cSrcweir 		DBG_ASSERT( pObj->ISA(SdrTextObj), "SetObjText: Kein SdrTextObj!" );
2420cdf0e10cSrcweir 		::Outliner* pOutl = pOutliner;
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir 		if (!pOutliner)
2423cdf0e10cSrcweir 		{
2424cdf0e10cSrcweir 			SfxItemPool* pPool = ((SdDrawDocument*) GetModel())->GetDrawOutliner().GetEmptyItemSet().GetPool();
2425cdf0e10cSrcweir 			pOutl = new ::Outliner( pPool, OUTLINERMODE_OUTLINEOBJECT );
2426cdf0e10cSrcweir 			pOutl->SetRefDevice( SD_MOD()->GetRefDevice( *( (SdDrawDocument*) GetModel() )->GetDocSh() ) );
2427cdf0e10cSrcweir 			pOutl->SetEditTextObjectPool(pPool);
2428cdf0e10cSrcweir 			pOutl->SetStyleSheetPool((SfxStyleSheetPool*)GetModel()->GetStyleSheetPool());
2429cdf0e10cSrcweir 			pOutl->EnableUndo(sal_False);
2430cdf0e10cSrcweir 			pOutl->SetUpdateMode( sal_False );
2431cdf0e10cSrcweir 		}
2432cdf0e10cSrcweir 
2433cdf0e10cSrcweir 		sal_uInt16 nOutlMode = pOutl->GetMode();
2434cdf0e10cSrcweir 		Size aPaperSize = pOutl->GetPaperSize();
2435cdf0e10cSrcweir 		sal_Bool bUpdateMode = pOutl->GetUpdateMode();
2436cdf0e10cSrcweir 		pOutl->SetUpdateMode(sal_False);
2437cdf0e10cSrcweir 		pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2438cdf0e10cSrcweir 
2439cdf0e10cSrcweir 		// #95114# Always set the object's StyleSheet at the Outliner to
2440cdf0e10cSrcweir 		// use the current objects StyleSheet. Thus it's the same as in
2441cdf0e10cSrcweir 		// SetText(...).
2442cdf0e10cSrcweir 		// #95114# Moved this implementation from where SetObjText(...) was called
2443cdf0e10cSrcweir 		// to inside this method to work even when outliner is fetched here.
2444cdf0e10cSrcweir 		pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
2445cdf0e10cSrcweir 
2446cdf0e10cSrcweir 		String aString;
2447cdf0e10cSrcweir 
2448cdf0e10cSrcweir 		switch( eObjKind )
2449cdf0e10cSrcweir 		{
2450cdf0e10cSrcweir 			case PRESOBJ_OUTLINE:
2451cdf0e10cSrcweir 			{
2452cdf0e10cSrcweir 				pOutl->Init( OUTLINERMODE_OUTLINEOBJECT );
2453cdf0e10cSrcweir 
2454cdf0e10cSrcweir 				aString += sal_Unicode( '\t' );
2455cdf0e10cSrcweir 				aString += rString;
2456cdf0e10cSrcweir 
2457cdf0e10cSrcweir 				if (mbMaster)
2458cdf0e10cSrcweir 				{
2459cdf0e10cSrcweir 					pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
2460cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t" ));
2461cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER2 ) );
2462cdf0e10cSrcweir 
2463cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t" ));
2464cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER3 ) );
2465cdf0e10cSrcweir 
2466cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t" ));
2467cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER4 ) );
2468cdf0e10cSrcweir 
2469cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t" ));
2470cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER5 ) );
2471cdf0e10cSrcweir 
2472cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t" ));
2473cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER6 ) );
2474cdf0e10cSrcweir 
2475cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t" ));
2476cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER7 ) );
2477cdf0e10cSrcweir 
2478cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t\t" ));
2479cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER8 ) );
2480cdf0e10cSrcweir 
2481cdf0e10cSrcweir 					aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t\t\t" ));
2482cdf0e10cSrcweir 					aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER9 ) );
2483cdf0e10cSrcweir 				}
2484cdf0e10cSrcweir 			}
2485cdf0e10cSrcweir 			break;
2486cdf0e10cSrcweir 
2487cdf0e10cSrcweir 			case PRESOBJ_TITLE:
2488cdf0e10cSrcweir 			{
2489cdf0e10cSrcweir 				pOutl->Init( OUTLINERMODE_TITLEOBJECT );
2490cdf0e10cSrcweir 				aString += rString;
2491cdf0e10cSrcweir 			}
2492cdf0e10cSrcweir 			break;
2493cdf0e10cSrcweir 
2494cdf0e10cSrcweir 			default:
2495cdf0e10cSrcweir 			{
2496cdf0e10cSrcweir 				pOutl->Init( OUTLINERMODE_TEXTOBJECT );
2497cdf0e10cSrcweir 				aString += rString;
2498cdf0e10cSrcweir 
2499cdf0e10cSrcweir 				// check if we need to add a text field
2500cdf0e10cSrcweir 				SvxFieldData* pData = NULL;
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir 				switch( eObjKind )
2503cdf0e10cSrcweir 				{
2504cdf0e10cSrcweir 				case PRESOBJ_HEADER:
2505cdf0e10cSrcweir 					pData = new SvxHeaderField();
2506cdf0e10cSrcweir 					break;
2507cdf0e10cSrcweir 				case PRESOBJ_FOOTER:
2508cdf0e10cSrcweir 					pData = new SvxFooterField();
2509cdf0e10cSrcweir 					break;
2510cdf0e10cSrcweir 				case PRESOBJ_SLIDENUMBER:
2511cdf0e10cSrcweir 					pData = new SvxPageField();
2512cdf0e10cSrcweir 					break;
2513cdf0e10cSrcweir 				case PRESOBJ_DATETIME:
2514cdf0e10cSrcweir 					pData = new SvxDateTimeField();
2515cdf0e10cSrcweir 					break;
2516cdf0e10cSrcweir 				default:
2517cdf0e10cSrcweir 					break;
2518cdf0e10cSrcweir 				}
2519cdf0e10cSrcweir 
2520cdf0e10cSrcweir 				if( pData )
2521cdf0e10cSrcweir 				{
2522cdf0e10cSrcweir 					ESelection e;
2523cdf0e10cSrcweir                     SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
2524cdf0e10cSrcweir 					pOutl->QuickInsertField(aField,e);
2525cdf0e10cSrcweir 					delete pData;
2526cdf0e10cSrcweir 				}
2527cdf0e10cSrcweir 			}
2528cdf0e10cSrcweir 			break;
2529cdf0e10cSrcweir 		}
2530cdf0e10cSrcweir 
2531cdf0e10cSrcweir 		pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
2532cdf0e10cSrcweir 
2533cdf0e10cSrcweir 		if( aString.Len() )
2534cdf0e10cSrcweir 			pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
2535cdf0e10cSrcweir 
2536cdf0e10cSrcweir 		( (SdrTextObj*) pObj)->SetOutlinerParaObject( pOutl->CreateParaObject() );
2537cdf0e10cSrcweir 
2538cdf0e10cSrcweir 		if (!pOutliner)
2539cdf0e10cSrcweir 		{
2540cdf0e10cSrcweir 			delete pOutl;
2541cdf0e10cSrcweir 			pOutl = NULL;
2542cdf0e10cSrcweir 		}
2543cdf0e10cSrcweir 		else
2544cdf0e10cSrcweir 		{
2545cdf0e10cSrcweir 			// Outliner restaurieren
2546cdf0e10cSrcweir 			pOutl->Init( nOutlMode );
2547cdf0e10cSrcweir 			pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2548cdf0e10cSrcweir 			pOutl->SetUpdateMode( bUpdateMode );
2549cdf0e10cSrcweir 			pOutl->SetPaperSize( aPaperSize );
2550cdf0e10cSrcweir 		}
2551cdf0e10cSrcweir 	}
2552cdf0e10cSrcweir }
2553cdf0e10cSrcweir 
2554cdf0e10cSrcweir /*************************************************************************
2555cdf0e10cSrcweir |*
2556cdf0e10cSrcweir |* Link & Daten von einem VControl empfangen
2557cdf0e10cSrcweir |*
2558cdf0e10cSrcweir \************************************************************************/
2559cdf0e10cSrcweir 
2560cdf0e10cSrcweir void SdPage::SetLinkData(const String&, const String& )
2561cdf0e10cSrcweir {
2562cdf0e10cSrcweir }
2563cdf0e10cSrcweir 
2564cdf0e10cSrcweir /*************************************************************************
2565cdf0e10cSrcweir |*
2566cdf0e10cSrcweir |* Layoutname setzen
2567cdf0e10cSrcweir |*
2568cdf0e10cSrcweir \************************************************************************/
2569cdf0e10cSrcweir void SdPage::SetLayoutName(String aName)
2570cdf0e10cSrcweir {
2571cdf0e10cSrcweir 	maLayoutName = aName;
2572cdf0e10cSrcweir 
2573cdf0e10cSrcweir 	if( mbMaster )
2574cdf0e10cSrcweir 	{
2575cdf0e10cSrcweir 		String aSep( RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR) );
2576cdf0e10cSrcweir 		sal_uInt16 nPos = maLayoutName.Search( aSep );
2577cdf0e10cSrcweir 		if ( nPos != STRING_NOTFOUND )
2578cdf0e10cSrcweir 		{
2579cdf0e10cSrcweir             FmFormPage::SetName(maLayoutName.Copy(0, nPos));
2580cdf0e10cSrcweir 		}
2581cdf0e10cSrcweir 	}
2582cdf0e10cSrcweir }
2583cdf0e10cSrcweir 
2584cdf0e10cSrcweir 
2585cdf0e10cSrcweir /*************************************************************************
2586cdf0e10cSrcweir |*
2587cdf0e10cSrcweir |* Seitenname zurueckgeben und ggf. generieren
2588cdf0e10cSrcweir |*
2589cdf0e10cSrcweir \************************************************************************/
2590cdf0e10cSrcweir 
2591cdf0e10cSrcweir const String& SdPage::GetName() const
2592cdf0e10cSrcweir {
2593cdf0e10cSrcweir 	String aCreatedPageName( maCreatedPageName );
2594cdf0e10cSrcweir 	if (GetRealName().Len() == 0)
2595cdf0e10cSrcweir 	{
2596cdf0e10cSrcweir 		if ((mePageKind == PK_STANDARD || mePageKind == PK_NOTES) && !mbMaster)
2597cdf0e10cSrcweir 		{
2598cdf0e10cSrcweir 			// default name for handout pages
2599cdf0e10cSrcweir 			sal_uInt16	nNum = (GetPageNum() + 1) / 2;
2600cdf0e10cSrcweir 
2601cdf0e10cSrcweir 			aCreatedPageName = String(SdResId(STR_PAGE));
2602cdf0e10cSrcweir 			aCreatedPageName += sal_Unicode( ' ' );
2603cdf0e10cSrcweir 			if( GetModel()->GetPageNumType() == SVX_NUMBER_NONE )
2604cdf0e10cSrcweir 			{
2605cdf0e10cSrcweir 				// if the document has number none as a formating
2606cdf0e10cSrcweir 				// for page numbers we still default to arabic numbering
2607cdf0e10cSrcweir 				// to keep the default page names unique
2608cdf0e10cSrcweir 				aCreatedPageName += String::CreateFromInt32( (sal_Int32)nNum );
2609cdf0e10cSrcweir 			}
2610cdf0e10cSrcweir 			else
2611cdf0e10cSrcweir 			{
2612cdf0e10cSrcweir 				aCreatedPageName += ((SdDrawDocument*) GetModel())->CreatePageNumValue(nNum);
2613cdf0e10cSrcweir 			}
2614cdf0e10cSrcweir 		}
2615cdf0e10cSrcweir 		else
2616cdf0e10cSrcweir 		{
2617cdf0e10cSrcweir 			/******************************************************************
2618cdf0e10cSrcweir 			* Defaultname fuer Handzettelseiten
2619cdf0e10cSrcweir 			******************************************************************/
2620cdf0e10cSrcweir 			aCreatedPageName = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
2621cdf0e10cSrcweir 		}
2622cdf0e10cSrcweir 	}
2623cdf0e10cSrcweir 	else
2624cdf0e10cSrcweir 	{
2625cdf0e10cSrcweir 		aCreatedPageName = GetRealName();
2626cdf0e10cSrcweir 	}
2627cdf0e10cSrcweir 
2628cdf0e10cSrcweir 	if (mePageKind == PK_NOTES)
2629cdf0e10cSrcweir 	{
2630cdf0e10cSrcweir 		aCreatedPageName += sal_Unicode( ' ' );
2631cdf0e10cSrcweir 		aCreatedPageName += String(SdResId(STR_NOTES));
2632cdf0e10cSrcweir 	}
2633cdf0e10cSrcweir 	else if (mePageKind == PK_HANDOUT && mbMaster)
2634cdf0e10cSrcweir 	{
2635cdf0e10cSrcweir 		aCreatedPageName += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( " (" ));
2636cdf0e10cSrcweir 		aCreatedPageName += String(SdResId(STR_HANDOUT));
2637cdf0e10cSrcweir 		aCreatedPageName += sal_Unicode( ')' );
2638cdf0e10cSrcweir 	}
2639cdf0e10cSrcweir 
2640cdf0e10cSrcweir 	const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
2641cdf0e10cSrcweir 	return maCreatedPageName;
2642cdf0e10cSrcweir }
2643cdf0e10cSrcweir 
2644cdf0e10cSrcweir /*************************************************************************
2645cdf0e10cSrcweir |*
2646cdf0e10cSrcweir |*
2647cdf0e10cSrcweir |*
2648cdf0e10cSrcweir \************************************************************************/
2649cdf0e10cSrcweir 
2650cdf0e10cSrcweir void SdPage::SetOrientation( Orientation eOrient)
2651cdf0e10cSrcweir {
2652cdf0e10cSrcweir 	meOrientation = eOrient;
2653cdf0e10cSrcweir }
2654cdf0e10cSrcweir 
2655cdf0e10cSrcweir /*************************************************************************
2656cdf0e10cSrcweir |*
2657cdf0e10cSrcweir |*
2658cdf0e10cSrcweir |*
2659cdf0e10cSrcweir \************************************************************************/
2660cdf0e10cSrcweir 
2661cdf0e10cSrcweir Orientation SdPage::GetOrientation() const
2662cdf0e10cSrcweir {
2663cdf0e10cSrcweir 	return meOrientation;
2664cdf0e10cSrcweir }
2665cdf0e10cSrcweir 
2666cdf0e10cSrcweir /*************************************************************************
2667cdf0e10cSrcweir |*
2668cdf0e10cSrcweir |* Liefert den Default-Text eines PresObjektes zurueck
2669cdf0e10cSrcweir |*
2670cdf0e10cSrcweir \************************************************************************/
2671cdf0e10cSrcweir 
2672cdf0e10cSrcweir String SdPage::GetPresObjText(PresObjKind eObjKind) const
2673cdf0e10cSrcweir {
2674cdf0e10cSrcweir 	String aString;
2675cdf0e10cSrcweir 
2676cdf0e10cSrcweir 	if (eObjKind == PRESOBJ_TITLE)
2677cdf0e10cSrcweir 	{
2678cdf0e10cSrcweir 		if (mbMaster)
2679cdf0e10cSrcweir 		{
2680cdf0e10cSrcweir 			if (mePageKind != PK_NOTES)
2681cdf0e10cSrcweir 			{
2682cdf0e10cSrcweir 				aString = String ( SdResId( STR_PRESOBJ_MPTITLE ) );
2683cdf0e10cSrcweir 			}
2684cdf0e10cSrcweir 			else
2685cdf0e10cSrcweir 			{
2686cdf0e10cSrcweir 				aString = String ( SdResId( STR_PRESOBJ_MPNOTESTITLE ) );
2687cdf0e10cSrcweir 			}
2688cdf0e10cSrcweir 		}
2689cdf0e10cSrcweir 		else
2690cdf0e10cSrcweir 		{
2691cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_TITLE ) );
2692cdf0e10cSrcweir 		}
2693cdf0e10cSrcweir 	}
2694cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_OUTLINE)
2695cdf0e10cSrcweir 	{
2696cdf0e10cSrcweir 		if (mbMaster)
2697cdf0e10cSrcweir 		{
2698cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_MPOUTLINE ) );
2699cdf0e10cSrcweir 		}
2700cdf0e10cSrcweir 		else
2701cdf0e10cSrcweir 		{
2702cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_OUTLINE ) );
2703cdf0e10cSrcweir 		}
2704cdf0e10cSrcweir 	}
2705cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_NOTES)
2706cdf0e10cSrcweir 	{
2707cdf0e10cSrcweir 		if (mbMaster)
2708cdf0e10cSrcweir 		{
2709cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_MPNOTESTEXT ) );
2710cdf0e10cSrcweir 		}
2711cdf0e10cSrcweir 		else
2712cdf0e10cSrcweir 		{
2713cdf0e10cSrcweir 			aString = String ( SdResId( STR_PRESOBJ_NOTESTEXT ) );
2714cdf0e10cSrcweir 		}
2715cdf0e10cSrcweir 	}
2716cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_TEXT)
2717cdf0e10cSrcweir 	{
2718cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_TEXT ) );
2719cdf0e10cSrcweir 	}
2720cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_GRAPHIC)
2721cdf0e10cSrcweir 	{
2722cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_GRAPHIC ) );
2723cdf0e10cSrcweir 	}
2724cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_OBJECT)
2725cdf0e10cSrcweir 	{
2726cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_OBJECT ) );
2727cdf0e10cSrcweir 	}
2728cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_CHART)
2729cdf0e10cSrcweir 	{
2730cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_CHART ) );
2731cdf0e10cSrcweir 	}
2732cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_ORGCHART)
2733cdf0e10cSrcweir 	{
2734cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_ORGCHART ) );
2735cdf0e10cSrcweir 	}
2736cdf0e10cSrcweir 	else if (eObjKind == PRESOBJ_CALC)
2737cdf0e10cSrcweir 	{
2738cdf0e10cSrcweir 		aString = String ( SdResId( STR_PRESOBJ_TABLE ) );
2739cdf0e10cSrcweir 	}
2740cdf0e10cSrcweir 
2741cdf0e10cSrcweir 	return(aString);
2742cdf0e10cSrcweir }
2743cdf0e10cSrcweir 
2744cdf0e10cSrcweir extern uno::Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage );
2745cdf0e10cSrcweir 
2746cdf0e10cSrcweir uno::Reference< uno::XInterface > SdPage::createUnoPage()
2747cdf0e10cSrcweir {
2748cdf0e10cSrcweir 	return createUnoPageImpl( this );
2749cdf0e10cSrcweir }
2750cdf0e10cSrcweir 
2751cdf0e10cSrcweir /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
2752cdf0e10cSrcweir SdPage* SdPage::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage )
2753cdf0e10cSrcweir {
2754cdf0e10cSrcweir 	try
2755cdf0e10cSrcweir 	{
2756cdf0e10cSrcweir 	    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( xPage, ::com::sun::star::uno::UNO_QUERY );
2757cdf0e10cSrcweir 		if( xUnoTunnel.is() )
2758cdf0e10cSrcweir 		{
2759cdf0e10cSrcweir 			SvxDrawPage* pUnoPage = reinterpret_cast<SvxDrawPage*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SvxDrawPage::getUnoTunnelId()) ) );
2760cdf0e10cSrcweir 			if( pUnoPage )
2761cdf0e10cSrcweir 				return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
2762cdf0e10cSrcweir 		}
2763cdf0e10cSrcweir 	}
2764cdf0e10cSrcweir 	catch( ::com::sun::star::uno::Exception& e )
2765cdf0e10cSrcweir 	{
2766cdf0e10cSrcweir 		(void)e;
2767cdf0e10cSrcweir 		DBG_ERROR("sd::SdPage::getImplementation(), exception cathced!" );
2768cdf0e10cSrcweir 	}
2769cdf0e10cSrcweir 
2770cdf0e10cSrcweir 	return 0;
2771cdf0e10cSrcweir }
2772cdf0e10cSrcweir 
2773cdf0e10cSrcweir void SdPage::SetName (const String& rName)
2774cdf0e10cSrcweir {
2775cdf0e10cSrcweir     String aOldName = GetName();
2776cdf0e10cSrcweir     FmFormPage::SetName (rName);
2777cdf0e10cSrcweir     static_cast<SdDrawDocument*>(pModel)->UpdatePageRelativeURLs(aOldName, rName);
2778cdf0e10cSrcweir     ActionChanged();
2779cdf0e10cSrcweir }
2780cdf0e10cSrcweir 
2781cdf0e10cSrcweir const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
2782cdf0e10cSrcweir {
2783cdf0e10cSrcweir 	if( mePageKind == PK_HANDOUT && !mbMaster )
2784cdf0e10cSrcweir 	{
2785cdf0e10cSrcweir 		return (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings);
2786cdf0e10cSrcweir 	}
2787cdf0e10cSrcweir 	else
2788cdf0e10cSrcweir 	{
2789cdf0e10cSrcweir 		return maHeaderFooterSettings;
2790cdf0e10cSrcweir 	}
2791cdf0e10cSrcweir }
2792cdf0e10cSrcweir 
2793cdf0e10cSrcweir void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings )
2794cdf0e10cSrcweir {
2795cdf0e10cSrcweir 	if( mePageKind == PK_HANDOUT && !mbMaster )
2796cdf0e10cSrcweir 	{
2797cdf0e10cSrcweir 		(((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings) = rNewSettings;
2798cdf0e10cSrcweir 	}
2799cdf0e10cSrcweir 	else
2800cdf0e10cSrcweir 	{
2801cdf0e10cSrcweir 		maHeaderFooterSettings = rNewSettings;
2802cdf0e10cSrcweir 	}
2803cdf0e10cSrcweir 
2804cdf0e10cSrcweir 	SetChanged();
2805cdf0e10cSrcweir 	if(TRG_HasMasterPage())
2806cdf0e10cSrcweir 	{
2807cdf0e10cSrcweir 		TRG_GetMasterPageDescriptorViewContact().ActionChanged();
2808cdf0e10cSrcweir 	}
2809cdf0e10cSrcweir }
2810cdf0e10cSrcweir 
2811cdf0e10cSrcweir bool SdPage::checkVisibility(
2812cdf0e10cSrcweir 	const sdr::contact::ViewObjectContact& rOriginal,
2813cdf0e10cSrcweir 	const sdr::contact::DisplayInfo& rDisplayInfo,
2814cdf0e10cSrcweir 	bool bEdit )
2815cdf0e10cSrcweir {
2816cdf0e10cSrcweir 	if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
2817cdf0e10cSrcweir 		return false;
2818cdf0e10cSrcweir 
2819cdf0e10cSrcweir 	SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2820cdf0e10cSrcweir 	if( pObj == NULL )
2821cdf0e10cSrcweir 		return false;
2822cdf0e10cSrcweir 
2823cdf0e10cSrcweir     const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
2824cdf0e10cSrcweir 	const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
2825cdf0e10cSrcweir 	const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
2826cdf0e10cSrcweir 	const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
2827cdf0e10cSrcweir 
2828cdf0e10cSrcweir 	// empty presentation objects only visible during edit mode
2829cdf0e10cSrcweir 	if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
2830cdf0e10cSrcweir 	{
2831cdf0e10cSrcweir 		if( (pObj->GetObjInventor() != SdrInventor) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
2832cdf0e10cSrcweir 			return false;
2833cdf0e10cSrcweir 	}
2834cdf0e10cSrcweir 
2835cdf0e10cSrcweir 	if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) )
2836cdf0e10cSrcweir 	{
2837cdf0e10cSrcweir        	const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->GetPage());
2838cdf0e10cSrcweir 
2839cdf0e10cSrcweir 		if( pCheckPage )
2840cdf0e10cSrcweir 		{
2841cdf0e10cSrcweir 			PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
2842cdf0e10cSrcweir 
2843cdf0e10cSrcweir 			if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
2844cdf0e10cSrcweir 			{
2845cdf0e10cSrcweir 				const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
2846cdf0e10cSrcweir 
2847cdf0e10cSrcweir                 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PK_HANDOUT && bIsPrinting ) )
2848cdf0e10cSrcweir 				{
2849cdf0e10cSrcweir 					// use the page that is currently processed
2850cdf0e10cSrcweir                 	const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
2851cdf0e10cSrcweir 
2852cdf0e10cSrcweir                     if( pVisualizedSdPage )
2853cdf0e10cSrcweir 					{
2854cdf0e10cSrcweir 						// if we are not on a masterpage, see if we have to draw this header&footer object at all
2855cdf0e10cSrcweir 						const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
2856cdf0e10cSrcweir 
2857cdf0e10cSrcweir 						switch( eKind )
2858cdf0e10cSrcweir 						{
2859cdf0e10cSrcweir 						case PRESOBJ_FOOTER:
2860cdf0e10cSrcweir 							return rSettings.mbFooterVisible;
2861cdf0e10cSrcweir 						case PRESOBJ_HEADER:
2862cdf0e10cSrcweir 							return rSettings.mbHeaderVisible;
2863cdf0e10cSrcweir 						case PRESOBJ_DATETIME:
2864cdf0e10cSrcweir 							return rSettings.mbDateTimeVisible;
2865cdf0e10cSrcweir 						case PRESOBJ_SLIDENUMBER:
2866cdf0e10cSrcweir 							return rSettings.mbSlideNumberVisible;
2867cdf0e10cSrcweir 						default:
2868cdf0e10cSrcweir 							break;
2869cdf0e10cSrcweir 						}
2870cdf0e10cSrcweir 					}
2871cdf0e10cSrcweir 				}
2872cdf0e10cSrcweir 			} // check for placeholders on master
2873cdf0e10cSrcweir 			else if( (eKind != PRESOBJ_NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) )
2874cdf0e10cSrcweir 			{
2875cdf0e10cSrcweir 			    // presentation objects on master slide are always invisible if slide is shown.
2876cdf0e10cSrcweir                 return false;
2877cdf0e10cSrcweir 			}
2878cdf0e10cSrcweir 		}
2879cdf0e10cSrcweir 	}
2880cdf0e10cSrcweir 
2881cdf0e10cSrcweir 	// i63977, do not print SdrpageObjs from master pages
2882cdf0e10cSrcweir 	if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) )
2883cdf0e10cSrcweir 	{
2884cdf0e10cSrcweir 		if( pObj->GetPage() && pObj->GetPage()->IsMasterPage() )
2885cdf0e10cSrcweir 			return false;
2886cdf0e10cSrcweir 	}
2887cdf0e10cSrcweir 
2888cdf0e10cSrcweir 	return true;
2889cdf0e10cSrcweir }
2890cdf0e10cSrcweir 
2891cdf0e10cSrcweir bool SdPage::RestoreDefaultText( SdrObject* pObj )
2892cdf0e10cSrcweir {
2893cdf0e10cSrcweir 	bool bRet = false;
2894cdf0e10cSrcweir 
2895cdf0e10cSrcweir 	SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
2896cdf0e10cSrcweir 
2897cdf0e10cSrcweir 	if( pTextObj )
2898cdf0e10cSrcweir 	{
2899cdf0e10cSrcweir 		PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
2900cdf0e10cSrcweir 
2901cdf0e10cSrcweir 		if (ePresObjKind == PRESOBJ_TITLE   ||
2902cdf0e10cSrcweir 			ePresObjKind == PRESOBJ_OUTLINE ||
2903cdf0e10cSrcweir 			ePresObjKind == PRESOBJ_NOTES   ||
2904cdf0e10cSrcweir 			ePresObjKind == PRESOBJ_TEXT)
2905cdf0e10cSrcweir 		{
2906cdf0e10cSrcweir 			String aString( GetPresObjText(ePresObjKind) );
2907cdf0e10cSrcweir 
2908cdf0e10cSrcweir 			if (aString.Len())
2909cdf0e10cSrcweir 			{
2910cdf0e10cSrcweir 				sal_Bool bVertical = sal_False;
2911cdf0e10cSrcweir 				OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
2912cdf0e10cSrcweir 				if( pOldPara )
2913cdf0e10cSrcweir 					bVertical = pOldPara->IsVertical();  // is old para object vertical?
2914cdf0e10cSrcweir 
2915cdf0e10cSrcweir 				SetObjText( pTextObj, 0, ePresObjKind, aString );
2916cdf0e10cSrcweir 
2917cdf0e10cSrcweir 				if( pOldPara )
2918cdf0e10cSrcweir 				{
2919cdf0e10cSrcweir 					//pTextObj->SetVerticalWriting( bVertical );
2920cdf0e10cSrcweir 					//
2921cdf0e10cSrcweir 					// #94826# Here, only the vertical flag for the
2922cdf0e10cSrcweir 					// OutlinerParaObjects needs to be changed. The
2923cdf0e10cSrcweir 					// AutoGrowWidth/Height items still exist in the
2924cdf0e10cSrcweir 					// not changed object.
2925cdf0e10cSrcweir 					if(pTextObj
2926cdf0e10cSrcweir 						&& pTextObj->GetOutlinerParaObject()
2927cdf0e10cSrcweir 						&& pTextObj->GetOutlinerParaObject()->IsVertical() != (bool)bVertical)
2928cdf0e10cSrcweir 					{
2929cdf0e10cSrcweir 						Rectangle aObjectRect = pTextObj->GetSnapRect();
2930cdf0e10cSrcweir 						pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
2931cdf0e10cSrcweir 						pTextObj->SetSnapRect(aObjectRect);
2932cdf0e10cSrcweir 					}
2933cdf0e10cSrcweir 				}
2934cdf0e10cSrcweir 
2935cdf0e10cSrcweir 				pTextObj->SetTextEditOutliner( NULL );  // to make stylesheet settings work
2936cdf0e10cSrcweir 				pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), sal_True );
2937cdf0e10cSrcweir 				pTextObj->SetEmptyPresObj(sal_True);
2938cdf0e10cSrcweir 				bRet = true;
2939cdf0e10cSrcweir 			}
2940cdf0e10cSrcweir 		}
2941cdf0e10cSrcweir 	}
2942cdf0e10cSrcweir 	return bRet;
2943cdf0e10cSrcweir }
2944cdf0e10cSrcweir 
2945cdf0e10cSrcweir void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< Rectangle >& rAreas )
2946cdf0e10cSrcweir {
2947cdf0e10cSrcweir 	SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PK_HANDOUT );
2948cdf0e10cSrcweir 
2949cdf0e10cSrcweir 	if( eLayout == AUTOLAYOUT_NONE )
2950cdf0e10cSrcweir 	{
2951cdf0e10cSrcweir 		// use layout from handout master
2952cdf0e10cSrcweir         SdrObjListIter aShapeIter (rHandoutMaster);
2953cdf0e10cSrcweir         while (aShapeIter.IsMore())
2954cdf0e10cSrcweir         {
2955cdf0e10cSrcweir             SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
2956cdf0e10cSrcweir             if (pPageObj)
2957cdf0e10cSrcweir                 rAreas.push_back( pPageObj->GetCurrentBoundRect() );
2958cdf0e10cSrcweir         }
2959cdf0e10cSrcweir 	}
2960cdf0e10cSrcweir 	else
2961cdf0e10cSrcweir 	{
2962cdf0e10cSrcweir 		Size    aArea = rHandoutMaster.GetSize();
2963cdf0e10cSrcweir 
2964cdf0e10cSrcweir 		const long nGapW = 1000; // gap is 1cm
2965cdf0e10cSrcweir 		const long nGapH = 1000;
2966cdf0e10cSrcweir 
2967cdf0e10cSrcweir 		long nLeftBorder = rHandoutMaster.GetLftBorder();
2968cdf0e10cSrcweir 		long nRightBorder = rHandoutMaster.GetRgtBorder();
2969cdf0e10cSrcweir 		long nTopBorder = rHandoutMaster.GetUppBorder();
2970cdf0e10cSrcweir 		long nBottomBorder = rHandoutMaster.GetLwrBorder();
2971cdf0e10cSrcweir 
2972cdf0e10cSrcweir 		const long nHeaderFooterHeight = static_cast< long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05  );
2973cdf0e10cSrcweir 
2974cdf0e10cSrcweir 		nTopBorder += nHeaderFooterHeight;
2975cdf0e10cSrcweir 		nBottomBorder += nHeaderFooterHeight;
2976cdf0e10cSrcweir 
2977cdf0e10cSrcweir 		long nX = nGapW + nLeftBorder;
2978cdf0e10cSrcweir 		long nY = nGapH + nTopBorder;
2979cdf0e10cSrcweir 
2980cdf0e10cSrcweir 		aArea.Width() -= nGapW * 2 + nLeftBorder + nRightBorder;
2981cdf0e10cSrcweir 		aArea.Height() -= nGapH * 2 + nTopBorder + nBottomBorder;
2982cdf0e10cSrcweir 
2983cdf0e10cSrcweir 		const bool bLandscape = aArea.Width() > aArea.Height();
2984cdf0e10cSrcweir 
2985cdf0e10cSrcweir 		static sal_uInt16 aOffsets[5][9] =
2986cdf0e10cSrcweir 		{
2987cdf0e10cSrcweir 			{ 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
2988cdf0e10cSrcweir 			{ 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
2989cdf0e10cSrcweir 			{ 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
2990cdf0e10cSrcweir 			{ 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
2991cdf0e10cSrcweir 			{ 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
2992cdf0e10cSrcweir 		};
2993cdf0e10cSrcweir 
2994cdf0e10cSrcweir 		sal_uInt16* pOffsets = aOffsets[0];
2995cdf0e10cSrcweir 		sal_uInt16  nColCnt = 0, nRowCnt = 0;
2996cdf0e10cSrcweir 		switch ( eLayout )
2997cdf0e10cSrcweir 		{
2998cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT1:
2999cdf0e10cSrcweir 				nColCnt = 1; nRowCnt = 1;
3000cdf0e10cSrcweir 				break;
3001cdf0e10cSrcweir 
3002cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT2:
3003cdf0e10cSrcweir 				if( bLandscape )
3004cdf0e10cSrcweir 				{
3005cdf0e10cSrcweir 					nColCnt = 2; nRowCnt = 1;
3006cdf0e10cSrcweir 				}
3007cdf0e10cSrcweir 				else
3008cdf0e10cSrcweir 				{
3009cdf0e10cSrcweir 					nColCnt = 1; nRowCnt = 2;
3010cdf0e10cSrcweir 				}
3011cdf0e10cSrcweir 				break;
3012cdf0e10cSrcweir 
3013cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT3:
3014cdf0e10cSrcweir 				if( bLandscape )
3015cdf0e10cSrcweir 				{
3016cdf0e10cSrcweir 					nColCnt = 3; nRowCnt = 2;
3017cdf0e10cSrcweir 				}
3018cdf0e10cSrcweir 				else
3019cdf0e10cSrcweir 				{
3020cdf0e10cSrcweir 					nColCnt = 2; nRowCnt = 3;
3021cdf0e10cSrcweir 				}
3022cdf0e10cSrcweir 				pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
3023cdf0e10cSrcweir 				break;
3024cdf0e10cSrcweir 
3025cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT4:
3026cdf0e10cSrcweir 				nColCnt = 2; nRowCnt = 2;
3027cdf0e10cSrcweir 				pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
3028cdf0e10cSrcweir 				break;
3029cdf0e10cSrcweir 
3030cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT6:
3031cdf0e10cSrcweir 				if( bLandscape )
3032cdf0e10cSrcweir 				{
3033cdf0e10cSrcweir 					nColCnt = 3; nRowCnt = 2;
3034cdf0e10cSrcweir 				}
3035cdf0e10cSrcweir 				else
3036cdf0e10cSrcweir 				{
3037cdf0e10cSrcweir 					nColCnt = 2; nRowCnt = 3;
3038cdf0e10cSrcweir 				}
3039cdf0e10cSrcweir 				if( !bHorizontal )
3040cdf0e10cSrcweir 					pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
3041cdf0e10cSrcweir 				break;
3042cdf0e10cSrcweir 
3043cdf0e10cSrcweir 			default:
3044cdf0e10cSrcweir 			case AUTOLAYOUT_HANDOUT9:
3045cdf0e10cSrcweir 				nColCnt = 3; nRowCnt = 3;
3046cdf0e10cSrcweir 
3047cdf0e10cSrcweir 				if( !bHorizontal )
3048cdf0e10cSrcweir 					pOffsets = aOffsets[4];
3049cdf0e10cSrcweir 				break;
3050cdf0e10cSrcweir 		}
3051cdf0e10cSrcweir 
3052cdf0e10cSrcweir 		rAreas.resize( nColCnt * nRowCnt );
3053cdf0e10cSrcweir 
3054cdf0e10cSrcweir 		Size aPartArea, aSize;
3055cdf0e10cSrcweir 		aPartArea.Width()  = ((aArea.Width()  - ((nColCnt-1) * nGapW) ) / nColCnt);
3056cdf0e10cSrcweir 		aPartArea.Height() = ((aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt);
3057cdf0e10cSrcweir 
3058cdf0e10cSrcweir 		SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PK_STANDARD);
3059cdf0e10cSrcweir 		if ( pFirstPage )
3060cdf0e10cSrcweir 		{
3061cdf0e10cSrcweir 			// scale actual size into handout rect
3062cdf0e10cSrcweir 			double fScale = (double)aPartArea.Width() / (double)pFirstPage->GetWdt();
3063cdf0e10cSrcweir 
3064cdf0e10cSrcweir 			aSize.Height() = (long)(fScale * pFirstPage->GetHgt() );
3065cdf0e10cSrcweir 			if( aSize.Height() > aPartArea.Height() )
3066cdf0e10cSrcweir 			{
3067cdf0e10cSrcweir 				fScale = (double)aPartArea.Height() / (double)pFirstPage->GetHgt();
3068cdf0e10cSrcweir 				aSize.Height() = aPartArea.Height();
3069cdf0e10cSrcweir 				aSize.Width() = (long)(fScale * pFirstPage->GetWdt());
3070cdf0e10cSrcweir 			}
3071cdf0e10cSrcweir 			else
3072cdf0e10cSrcweir 			{
3073cdf0e10cSrcweir 				aSize.Width() = aPartArea.Width();
3074cdf0e10cSrcweir 			}
3075cdf0e10cSrcweir 
3076cdf0e10cSrcweir 			nX += (aPartArea.Width() - aSize.Width()) / 2;
3077cdf0e10cSrcweir 			nY += (aPartArea.Height()- aSize.Height())/ 2;
3078cdf0e10cSrcweir 		}
3079cdf0e10cSrcweir 		else
3080cdf0e10cSrcweir 		{
3081cdf0e10cSrcweir 			aSize = aPartArea;
3082cdf0e10cSrcweir 		}
3083cdf0e10cSrcweir 
3084cdf0e10cSrcweir 		Point aPos( nX, nY );
3085cdf0e10cSrcweir 
3086cdf0e10cSrcweir 		const bool bRTL = rModel.GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB;
3087cdf0e10cSrcweir 
3088cdf0e10cSrcweir 		const long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
3089cdf0e10cSrcweir 		const long nOffsetY = aPartArea.Height() + nGapH;
3090cdf0e10cSrcweir 		const long nStartX = bRTL ? nOffsetX*(1 - nColCnt) - nX : nX;
3091cdf0e10cSrcweir 
3092cdf0e10cSrcweir 		for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
3093cdf0e10cSrcweir 		{
3094cdf0e10cSrcweir 			aPos.X() = nStartX;
3095cdf0e10cSrcweir 			for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
3096cdf0e10cSrcweir 			{
3097cdf0e10cSrcweir 				rAreas[*pOffsets++] = Rectangle(aPos, aSize);
3098cdf0e10cSrcweir 				aPos.X() += nOffsetX;
3099cdf0e10cSrcweir 			}
3100cdf0e10cSrcweir 
3101cdf0e10cSrcweir 			aPos.Y() += nOffsetY;
3102cdf0e10cSrcweir 		}
3103cdf0e10cSrcweir 	}
3104cdf0e10cSrcweir }
3105cdf0e10cSrcweir 
3106cdf0e10cSrcweir 
3107cdf0e10cSrcweir 
3108cdf0e10cSrcweir 
3109cdf0e10cSrcweir void SdPage::SetPrecious (const bool bIsPrecious)
3110cdf0e10cSrcweir {
3111cdf0e10cSrcweir     mbIsPrecious = bIsPrecious;
3112cdf0e10cSrcweir }
3113cdf0e10cSrcweir 
3114cdf0e10cSrcweir 
3115cdf0e10cSrcweir 
3116cdf0e10cSrcweir 
3117cdf0e10cSrcweir bool SdPage::IsPrecious (void) const
3118cdf0e10cSrcweir {
3119cdf0e10cSrcweir     return mbIsPrecious;
3120cdf0e10cSrcweir }
3121cdf0e10cSrcweir 
3122cdf0e10cSrcweir 
3123cdf0e10cSrcweir 
3124cdf0e10cSrcweir 
3125cdf0e10cSrcweir HeaderFooterSettings::HeaderFooterSettings()
3126cdf0e10cSrcweir {
3127cdf0e10cSrcweir 	mbHeaderVisible = true;
3128cdf0e10cSrcweir 	mbFooterVisible = true;
3129cdf0e10cSrcweir 	mbSlideNumberVisible = false;
3130cdf0e10cSrcweir 	mbDateTimeVisible = true;
3131cdf0e10cSrcweir 	mbDateTimeIsFixed = true;
3132cdf0e10cSrcweir 	meDateTimeFormat = SVXDATEFORMAT_A;
3133cdf0e10cSrcweir }
3134cdf0e10cSrcweir 
3135cdf0e10cSrcweir bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
3136cdf0e10cSrcweir {
3137cdf0e10cSrcweir 	return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
3138cdf0e10cSrcweir 		   (maHeaderText == rSettings.maHeaderText) &&
3139cdf0e10cSrcweir 		   (mbFooterVisible == rSettings.mbFooterVisible) &&
3140cdf0e10cSrcweir 		   (maFooterText == rSettings.maFooterText) &&
3141cdf0e10cSrcweir 		   (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
3142cdf0e10cSrcweir 		   (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
3143cdf0e10cSrcweir 		   (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
3144cdf0e10cSrcweir 		   (meDateTimeFormat == rSettings.meDateTimeFormat) &&
3145cdf0e10cSrcweir 		   (maDateTimeText == rSettings.maDateTimeText);
3146cdf0e10cSrcweir }
3147cdf0e10cSrcweir 
3148