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