merge the formfield patch from ooo-build
[ooovba.git] / sd / source / core / sdpage.cxx
blobe5355c20aacb53b1fca878a6dd05503cdf77b875
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdpage.cxx,v $
10 * $Revision: 1.69 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include <algorithm>
36 #include <comphelper/classids.hxx>
38 #include <vcl/svapp.hxx>
39 #include "eetext.hxx"
40 #include <svx/eeitem.hxx>
41 #include <svx/svdoutl.hxx>
42 #include <svx/editdata.hxx>
43 #include <svx/pageitem.hxx>
44 #include <svx/lrspitem.hxx>
45 #include <svx/bulitem.hxx>
46 #include <svx/svdpagv.hxx>
47 #include <svx/fhgtitem.hxx>
48 #include <svx/outlobj.hxx>
49 #include <svx/svdoole2.hxx>
50 #include <svx/svdograf.hxx>
51 #include <svx/svdopage.hxx>
52 #include <svx/svdopage.hxx>
53 #include <sfx2/printer.hxx>
54 #include <basic/basmgr.hxx>
55 #include <svx/pbinitem.hxx>
56 #include <svx/svdundo.hxx>
57 #include <svtools/smplhint.hxx>
58 #include <svx/adjitem.hxx>
59 #include <svx/editobj.hxx>
60 #ifndef _SVX_SRIPTTYPEITEM_HXX
61 #include <svx/scripttypeitem.hxx>
62 #endif
63 #include <svx/unopage.hxx>
64 #include <svx/flditem.hxx>
65 #include <svx/sdr/contact/displayinfo.hxx>
67 #include <svx/adjitem.hxx>
69 #include "../ui/inc/DrawDocShell.hxx"
70 #include "Outliner.hxx"
72 #include "misc.hxx"
73 #include "eetext.hxx"
74 #include "drawdoc.hxx"
75 #include "sdpage.hxx"
76 #include "pglink.hxx"
77 #include "sdresid.hxx"
78 #include "stlsheet.hxx"
79 #include "glob.hrc"
80 #include "glob.hxx"
81 #include "helpids.h"
82 #include "anminfo.hxx"
83 #include "undo/undomanager.hxx"
84 #include "undo/undoobjects.hxx"
85 #include <svx/sdr/contact/displayinfo.hxx>
86 #include <svx/sdr/contact/viewobjectcontact.hxx>
87 #include <svx/sdr/contact/viewcontact.hxx>
88 #include <svx/sdr/contact/objectcontact.hxx>
89 #include <svx/unoapi.hxx>
91 #include <set>
93 using namespace ::sd;
94 using namespace ::com::sun::star;
96 TYPEINIT2( SdPage, FmFormPage, SdrObjUserCall );
98 /*************************************************************************
100 |* Ctor
102 \************************************************************************/
104 SdPage::SdPage(SdDrawDocument& rNewDoc, StarBASIC* pBasic, BOOL bMasterPage)
105 : FmFormPage(rNewDoc, pBasic, bMasterPage)
106 , SdrObjUserCall()
107 , mePageKind(PK_STANDARD)
108 , meAutoLayout(AUTOLAYOUT_NONE)
109 , mbSelected(FALSE)
110 , mePresChange(PRESCHANGE_MANUAL)
111 , mnTime(1)
112 , mbSoundOn(FALSE)
113 , mbExcluded(FALSE)
114 , mbLoopSound(FALSE)
115 , mbStopSound(FALSE)
116 , mbScaleObjects(TRUE)
117 , mbBackgroundFullSize( FALSE )
118 , meCharSet(gsl_getSystemTextEncoding())
119 , mnPaperBin(PAPERBIN_PRINTER_SETTINGS)
120 , mpPageLink(NULL)
121 , mpItems(NULL)
122 , mnTransitionType(0)
123 , mnTransitionSubtype(0)
124 , mbTransitionDirection(sal_True)
125 , mnTransitionFadeColor(0)
126 , mfTransitionDuration(2.0)
127 , mbIsPrecious(true)
129 // Der Layoutname der Seite wird von SVDRAW benutzt, um die Praesentations-
130 // vorlagen der Gliederungsobjekte zu ermitteln. Darum enthaelt er bereits
131 // den Bezeichner fuer die Gliederung (STR_LAYOUT_OUTLINE).
132 maLayoutName = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
133 maLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
134 maLayoutName += String(SdResId(STR_LAYOUT_OUTLINE));
136 Size aPageSize(GetSize());
138 if (aPageSize.Width() > aPageSize.Height())
140 meOrientation = ORIENTATION_LANDSCAPE;
142 else
144 meOrientation = ORIENTATION_PORTRAIT;
148 /*************************************************************************
150 |* Dtor
152 \************************************************************************/
154 SdPage::~SdPage()
156 DisconnectLink();
158 EndListenOutlineText();
160 if( mpItems )
161 delete mpItems;
164 /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
165 SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex )
167 int nObjFound = 0; // index of the searched object
168 SdrObject* pObj = 0;
169 while( (pObj = maPresentationShapeList.getNextShape(pObj)) != 0 )
171 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
172 if( pInfo && (pInfo->mePresObjKind == eObjKind) )
174 nObjFound++; // found one
175 if( nObjFound == nIndex )
176 return pObj;
180 return 0;
183 /** creates a presentation object with the given PresObjKind on this page. A user call will be set
185 SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, BOOL bVertical, const Rectangle& rRect, BOOL /* bInsert */ )
187 sd::UndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
188 const bool bUndo = pUndoManager && pUndoManager->isInListAction() && IsInserted();
190 SdrObject* pSdrObj = NULL;
192 bool bForceText = false; // forces the shape text to be set even if its empty
193 bool bEmptyPresObj = true;
195 switch( eObjKind )
197 case PRESOBJ_TITLE:
199 pSdrObj = new SdrRectObj(OBJ_TITLETEXT);
201 if (mbMaster)
203 pSdrObj->SetNotVisibleAsMaster(TRUE);
206 break;
208 case PRESOBJ_OUTLINE:
210 pSdrObj = new SdrRectObj(OBJ_OUTLINETEXT);
212 if (mbMaster)
214 pSdrObj->SetNotVisibleAsMaster(TRUE);
217 break;
219 case PRESOBJ_NOTES:
221 pSdrObj = new SdrRectObj(OBJ_TEXT);
223 if (mbMaster)
225 pSdrObj->SetNotVisibleAsMaster(TRUE);
228 break;
230 case PRESOBJ_TEXT:
232 pSdrObj = new SdrRectObj(OBJ_TEXT);
234 break;
236 case PRESOBJ_GRAPHIC:
238 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_GRAPHIC ) );
239 Graphic aGraphic( aBmpEx );
240 OutputDevice &aOutDev = *Application::GetDefaultDevice();
241 aOutDev.Push();
243 aOutDev.SetMapMode( aGraphic.GetPrefMapMode() );
244 Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() );
245 aOutDev.SetMapMode(MAP_100TH_MM);
247 Size aSize = aOutDev.PixelToLogic(aSizePix);
248 Point aPnt (0, 0);
249 Rectangle aRect (aPnt, aSize);
250 pSdrObj = new SdrGrafObj(aGraphic, aRect);
251 aOutDev.Pop();
253 break;
255 case PRESOBJ_OBJECT:
257 pSdrObj = new SdrOle2Obj();
258 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_OBJECT ) );
259 Graphic aGraphic( aBmpEx );
260 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
262 break;
264 case PRESOBJ_CHART:
266 pSdrObj = new SdrOle2Obj();
267 ( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarChart" )));
268 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_CHART ) );
269 Graphic aGraphic( aBmpEx );
270 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
272 break;
274 case PRESOBJ_ORGCHART:
276 pSdrObj = new SdrOle2Obj();
277 ( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarOrg" )));
278 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_ORGCHART ) );
279 Graphic aGraphic( aBmpEx );
280 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
283 case PRESOBJ_TABLE:
285 pSdrObj = new SdrOle2Obj();
286 ( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarCalc" )));
287 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_TABLE ) );
288 Graphic aGraphic( aBmpEx );
289 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
291 break;
293 case PRESOBJ_BACKGROUND:
295 pSdrObj = new SdrRectObj();
296 pSdrObj->SetMoveProtect(TRUE);
297 pSdrObj->SetResizeProtect(TRUE);
298 pSdrObj->SetMarkProtect(TRUE);
300 break;
302 case PRESOBJ_HANDOUT:
304 //Erste Standardseite am SdrPageObj vermerken
305 SdrPage* pFirstPage = ( (SdDrawDocument*) pModel )->GetSdPage(0, PK_STANDARD);
306 pSdrObj = new SdrPageObj( pFirstPage );
307 pSdrObj->SetResizeProtect(TRUE);
309 break;
311 case PRESOBJ_PAGE:
313 //Notizseite am SdrPageObj vermerken
314 sal_uInt16 nDestPageNum(GetPageNum());
316 if(nDestPageNum)
318 // decrement only when != 0, else we get a 0xffff
319 nDestPageNum -= 1;
322 if(nDestPageNum < pModel->GetPageCount())
324 pSdrObj = new SdrPageObj(pModel->GetPage(nDestPageNum));
326 else
328 pSdrObj = new SdrPageObj();
331 pSdrObj->SetResizeProtect(TRUE);
333 break;
335 case PRESOBJ_HEADER:
336 case PRESOBJ_FOOTER:
337 case PRESOBJ_DATETIME:
338 case PRESOBJ_SLIDENUMBER:
340 pSdrObj = new SdrRectObj(OBJ_TEXT);
341 bEmptyPresObj = false;
342 bForceText = true;
344 break;
345 default:
346 break;
349 if (pSdrObj)
351 pSdrObj->SetEmptyPresObj(bEmptyPresObj);
352 pSdrObj->SetLogicRect(rRect);
354 InsertObject(pSdrObj);
356 if ( pSdrObj->ISA(SdrTextObj) )
358 // #96243# Tell the object EARLY that it is vertical to have the
359 // defaults for AutoGrowWidth/Height reversed
360 if(bVertical)
361 ((SdrTextObj*)pSdrObj)->SetVerticalWriting(TRUE);
363 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
364 if( bVertical )
365 aTempAttr.Put( SdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
366 else
367 aTempAttr.Put( SdrTextMinFrameHeightItem( rRect.GetSize().Height() ) );
369 if (mbMaster)
371 // Bei Praesentationsobjekten auf der MasterPage soll die
372 // Groesse vom Benutzwer frei waehlbar sein
374 // #96243# potential problem: This action was still NOT
375 // adapted for vertical text. This sure needs to be done.
376 if(bVertical)
377 aTempAttr.Put(SdrTextAutoGrowWidthItem(FALSE));
378 else
379 aTempAttr.Put(SdrTextAutoGrowHeightItem(FALSE));
382 // check if we need another vertical adjustement than the default
383 SdrTextVertAdjust eV = SDRTEXTVERTADJUST_TOP;
385 if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind != PK_STANDARD) )
387 eV = SDRTEXTVERTADJUST_BOTTOM;
389 else if( (eObjKind == PRESOBJ_SLIDENUMBER) && (mePageKind != PK_STANDARD) )
391 eV = SDRTEXTVERTADJUST_BOTTOM;
394 if( eV != SDRTEXTVERTADJUST_TOP )
395 aTempAttr.Put(SdrTextVertAdjustItem(eV));
397 pSdrObj->SetMergedItemSet(aTempAttr);
399 pSdrObj->SetLogicRect(rRect);
402 String aString = GetPresObjText(eObjKind);
403 if( (aString.Len() || bForceText) && pSdrObj->ISA(SdrTextObj) )
405 SdrOutliner* pOutliner = ( (SdDrawDocument*) GetModel() )->GetInternalOutliner();
407 USHORT nOutlMode = pOutliner->GetMode();
408 pOutliner->Init( OUTLINERMODE_TEXTOBJECT );
409 pOutliner->SetStyleSheet( 0, NULL );
410 pOutliner->SetVertical( bVertical );
412 String aEmptyStr;
413 SetObjText( (SdrTextObj*) pSdrObj, (SdrOutliner*)pOutliner, eObjKind, aString );
415 pOutliner->Init( nOutlMode );
416 pOutliner->SetStyleSheet( 0, NULL );
419 if( (eObjKind == PRESOBJ_HEADER) || (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_DATETIME) )
421 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
422 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
423 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
424 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
426 SvxAdjust eH = SVX_ADJUST_LEFT;
428 if( (eObjKind == PRESOBJ_DATETIME) && (mePageKind != PK_STANDARD ) )
430 eH = SVX_ADJUST_RIGHT;
432 else if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind == PK_STANDARD ) )
434 eH = SVX_ADJUST_CENTER;
436 else if( eObjKind == PRESOBJ_SLIDENUMBER )
438 eH = SVX_ADJUST_RIGHT;
441 if( eH != SVX_ADJUST_LEFT )
442 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST ));
444 pSdrObj->SetMergedItemSet(aTempAttr);
447 if (mbMaster)
449 SdrLayerAdmin& rLayerAdmin = pModel->GetLayerAdmin();
451 if (eObjKind == PRESOBJ_BACKGROUND)
453 // Hintergrund der MasterPage
454 pSdrObj->SetLayer( rLayerAdmin.
455 GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), FALSE) );
457 else
459 // Hintergrundobjekte der MasterPage
460 pSdrObj->SetLayer( rLayerAdmin.
461 GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), FALSE) );
465 // Objekt am StyleSheet anmelden
466 // #95114# Set style only when one was found (as in 5.2)
467 // pSdrObj->NbcSetStyleSheet( GetStyleSheetForPresObj(eObjKind), FALSE );
468 if( mePageKind != PK_HANDOUT )
470 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind);
471 if(pSheetForPresObj)
472 pSdrObj->SetStyleSheet(pSheetForPresObj, FALSE);
475 if (eObjKind == PRESOBJ_OUTLINE)
477 for (USHORT nLevel = 1; nLevel < 10; nLevel++)
479 String aName(maLayoutName);
480 aName += sal_Unicode( ' ' );
481 aName += String::CreateFromInt32( nLevel );
482 SfxStyleSheet* pSheet = (SfxStyleSheet*)pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
483 DBG_ASSERT(pSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden");
484 if (pSheet)
485 pSdrObj->StartListening(*pSheet);
489 if ( eObjKind == PRESOBJ_OBJECT ||
490 eObjKind == PRESOBJ_CHART ||
491 eObjKind == PRESOBJ_ORGCHART ||
492 eObjKind == PRESOBJ_TABLE ||
493 eObjKind == PRESOBJ_GRAPHIC )
495 SfxItemSet aSet( ((SdDrawDocument*) pModel)->GetPool() );
496 aSet.Put( SdrTextContourFrameItem( TRUE ) );
497 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
499 pSdrObj->SetMergedItemSet(aSet);
502 if( bUndo )
504 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
507 if( bUndo )
509 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pSdrObj ) );
510 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pSdrObj) );
513 InsertPresObj(pSdrObj, eObjKind);
514 pSdrObj->SetUserCall(this);
516 pSdrObj->RecalcBoundRect();
519 return(pSdrObj);
522 /*************************************************************************
524 |* Es werden Praesentationsobjekte auf der Page erzeugt.
525 |* Alle Praesentationsobjekte erhalten einen UserCall auf die Page.
527 \************************************************************************/
529 SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const
531 String aName(GetLayoutName());
532 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
533 USHORT nPos = aName.Search(aSep);
534 if (nPos != STRING_NOTFOUND)
536 nPos = nPos + aSep.Len();
537 aName.Erase(nPos);
540 switch (eObjKind)
542 case PRESOBJ_OUTLINE:
544 aName = GetLayoutName();
545 aName += sal_Unicode( ' ' );
546 aName += String::CreateFromInt32( 1 );
548 break;
550 case PRESOBJ_TITLE:
551 aName += String(SdResId(STR_LAYOUT_TITLE));
552 break;
554 case PRESOBJ_BACKGROUND:
555 aName += String(SdResId(STR_LAYOUT_BACKGROUND));
556 break;
558 case PRESOBJ_NOTES:
559 aName += String(SdResId(STR_LAYOUT_NOTES));
560 break;
562 case PRESOBJ_TEXT:
563 aName += String(SdResId(STR_LAYOUT_SUBTITLE));
564 break;
566 case PRESOBJ_HEADER:
567 case PRESOBJ_FOOTER:
568 case PRESOBJ_DATETIME:
569 case PRESOBJ_SLIDENUMBER:
570 aName += String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
571 break;
573 default:
574 break;
577 SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
578 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
579 return (SfxStyleSheet*)pResult;
582 /** returns the presentation style with the given helpid from this masterpage or this
583 slides masterpage */
584 SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
586 String aStyleName( pPage->GetLayoutName() );
587 const String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
588 aStyleName.Erase(aStyleName.Search(aSep) + aSep.Len());
590 sal_uInt16 nNameId;
591 switch( nHelpId )
593 case HID_PSEUDOSHEET_TITLE: nNameId = STR_LAYOUT_TITLE; break;
594 case HID_PSEUDOSHEET_SUBTITLE: nNameId = STR_LAYOUT_SUBTITLE; break;
595 case HID_PSEUDOSHEET_OUTLINE1:
596 case HID_PSEUDOSHEET_OUTLINE2:
597 case HID_PSEUDOSHEET_OUTLINE3:
598 case HID_PSEUDOSHEET_OUTLINE4:
599 case HID_PSEUDOSHEET_OUTLINE5:
600 case HID_PSEUDOSHEET_OUTLINE6:
601 case HID_PSEUDOSHEET_OUTLINE7:
602 case HID_PSEUDOSHEET_OUTLINE8:
603 case HID_PSEUDOSHEET_OUTLINE9: nNameId = STR_LAYOUT_OUTLINE; break;
604 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: nNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break;
605 case HID_PSEUDOSHEET_BACKGROUND: nNameId = STR_LAYOUT_BACKGROUND; break;
606 case HID_PSEUDOSHEET_NOTES: nNameId = STR_LAYOUT_NOTES; break;
608 default:
609 DBG_ERROR( "SdPage::getPresentationStyle(), illegal argument!" );
610 return 0;
612 aStyleName.Append( String( SdResId( nNameId ) ) );
613 if( nNameId == STR_LAYOUT_OUTLINE )
615 aStyleName.Append( sal_Unicode( ' ' ));
616 aStyleName.Append( String::CreateFromInt32( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE )));
619 SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
620 SfxStyleSheetBase* pResult = pStShPool->Find(aStyleName, SD_STYLE_FAMILY_MASTERPAGE);
621 return dynamic_cast<SdStyleSheet*>(pResult);
624 /*************************************************************************
626 |* Das Praesentationsobjekt rObj hat sich geaendert und wird nicht mehr
627 |* durch das Praesentationsobjekt der MasterPage referenziert.
628 |* Der UserCall wird geloescht.
630 \************************************************************************/
632 void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& )
634 if (!maLockAutoLayoutArrangement.isLocked())
636 switch (eType)
638 case SDRUSERCALL_MOVEONLY:
639 case SDRUSERCALL_RESIZE:
641 if( pModel->isLocked() )
642 break;
644 SdrObject* pObj = (SdrObject*) &rObj;
646 if (pObj)
648 if (!mbMaster)
650 if( pObj->GetUserCall() )
652 sd::UndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
653 const bool bUndo = pUndoManager && pUndoManager->isInListAction() && IsInserted();
655 DBG_ASSERT( bUndo || (pUndoManager && pUndoManager->isInUndo()),
656 "SdPage::Changed(), model change without undo!?" );
658 if( bUndo )
659 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pObj) );
661 // Objekt was resized by user and does not listen to its slide anymore
662 pObj->SetUserCall(0);
665 else if (pModel)
667 // MasterPage-Objekt wurde veraendert, daher
668 // Objekte auf allen Seiten anpassen
669 USHORT nPageCount = ((SdDrawDocument*) pModel)->GetSdPageCount(mePageKind);
671 for (USHORT i = 0; i < nPageCount; i++)
673 SdPage* pLoopPage = ((SdDrawDocument*) pModel)->GetSdPage(i, mePageKind);
675 if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
677 // Seite hoert auf diese MasterPage, daher
678 // AutoLayout anpassen
679 pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
685 break;
687 case SDRUSERCALL_DELETE:
688 case SDRUSERCALL_REMOVED:
689 default:
690 break;
695 /*************************************************************************
697 |* Erzeugt auf einer MasterPage Hintergrund, Titel- und Layout-Bereich
699 \************************************************************************/
701 void SdPage::CreateTitleAndLayout(BOOL bInit, BOOL bCreate )
703 sd::UndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
704 const bool bUndo = pUndoManager && pUndoManager->isInListAction() && IsInserted();
706 SdPage* pMasterPage = this;
708 if (!mbMaster)
710 pMasterPage = (SdPage*)(&(TRG_GetMasterPage()));
713 if (!pMasterPage)
715 return;
718 /**************************************************************************
719 * Hintergrund, Titel- und Layout-Bereich werden angelegt
720 **************************************************************************/
721 if( mePageKind == PK_STANDARD )
723 SdrObject* pMasterBackground = pMasterPage->GetPresObj( PRESOBJ_BACKGROUND );
724 if( pMasterBackground == NULL )
725 pMasterPage->CreateDefaultPresObj(PRESOBJ_BACKGROUND, true);
728 if( ( (SdDrawDocument*) GetModel() )->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
730 if( mePageKind == PK_HANDOUT && bInit )
732 // handout template
734 // delete all available handout presentation objects
735 SdrObject* pObj;
736 while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != 0 )
738 if( bUndo )
739 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
741 pMasterPage->RemoveObject(pObj->GetOrdNum());
744 std::vector< Rectangle > aAreas;
745 CalculateHandoutAreas( *static_cast< SdDrawDocument* >(GetModel() ), pMasterPage->GetAutoLayout(), false, aAreas );
747 const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
749 sal_uInt16 nPage = 0;
750 std::vector< Rectangle >::iterator iter( aAreas.begin() );
751 while( iter != aAreas.end() )
753 SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, FALSE, (*iter++), TRUE) );
755 const sal_uInt16 nDestinationPageNum(2 * nPage + 1);
757 if(nDestinationPageNum < pModel->GetPageCount())
759 pPageObj->SetReferencedPage(pModel->GetPage(nDestinationPageNum));
761 else
763 pPageObj->SetReferencedPage(0L);
766 if( bSkip && iter != aAreas.end() )
767 iter++;
769 nPage++;
773 if( mePageKind != PK_HANDOUT )
775 SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE );
776 if( pMasterTitle == NULL )
777 pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE, true);
779 SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
780 if( pMasterOutline == NULL )
781 pMasterPage->CreateDefaultPresObj( mePageKind == PK_STANDARD ? PRESOBJ_OUTLINE : PRESOBJ_NOTES, true );
784 // create header&footer objects
786 if( bCreate )
788 if( mePageKind != PK_STANDARD )
790 SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER );
791 if( pHeader == NULL )
792 pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER, true );
795 SdrObject* pDate = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
796 if( pDate == NULL )
797 pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME, true );
799 SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
800 if( pFooter == NULL )
801 pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER, true );
803 SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
804 if( pNumber == NULL )
805 pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER, true );
810 SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
812 if( eObjKind == PRESOBJ_TITLE )
814 Rectangle aTitleRect( GetTitleRect() );
815 return CreatePresObj(PRESOBJ_TITLE, FALSE, aTitleRect, bInsert);
817 else if( eObjKind == PRESOBJ_OUTLINE )
819 Rectangle aLayoutRect( GetLayoutRect() );
820 return CreatePresObj( PRESOBJ_OUTLINE, FALSE, aLayoutRect, bInsert);
822 else if( eObjKind == PRESOBJ_NOTES )
824 Rectangle aLayoutRect( GetLayoutRect() );
825 return CreatePresObj( PRESOBJ_NOTES, FALSE, aLayoutRect, bInsert);
827 else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) )
829 // create footer objects for standard master page
830 if( mePageKind == PK_STANDARD )
832 const long nLftBorder = GetLftBorder();
833 const long nUppBorder = GetUppBorder();
835 Point aTitlePos ( nLftBorder, nUppBorder );
836 Size aPageSize ( GetSize() );
837 aPageSize.Width() -= nLftBorder + GetRgtBorder();
838 aPageSize.Height() -= nUppBorder + GetLwrBorder();
840 const int Y = long(nUppBorder + aPageSize.Height() * 0.911);
841 const int W1 = long(aPageSize.Width() * 0.233);
842 const int W2 = long(aPageSize.Width() * 0.317);
843 const int H = long(aPageSize.Height() * 0.069);
845 if( eObjKind == PRESOBJ_DATETIME )
847 Point aPos( long(nLftBorder+(aPageSize.Width()*0.05)), Y );
848 Size aSize( W1, H );
849 Rectangle aRect( aPos, aSize );
850 return CreatePresObj( PRESOBJ_DATETIME, FALSE, aRect, bInsert );
852 else if( eObjKind == PRESOBJ_FOOTER )
854 Point aPos( long(nLftBorder+ aPageSize.Width() * 0.342), Y );
855 Size aSize( W2, H );
856 Rectangle aRect( aPos, aSize );
857 return CreatePresObj( PRESOBJ_FOOTER, FALSE, aRect, bInsert );
859 else if( eObjKind == PRESOBJ_SLIDENUMBER )
861 Point aPos( long(nLftBorder+(aPageSize.Width()*0.717)), Y );
862 Size aSize( W1, H );
863 Rectangle aRect( aPos, aSize );
864 return CreatePresObj( PRESOBJ_SLIDENUMBER, FALSE, aRect, bInsert );
866 else
868 DBG_ERROR( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a slide master" );
869 return NULL;
872 else
874 // create header&footer objects for handout and notes master
875 Point aTitlePos ( GetLftBorder(), GetUppBorder() );
876 Size aPageSize ( GetSize() );
877 aPageSize.Width() -= GetLftBorder() + GetRgtBorder();
878 aPageSize.Height() -= GetUppBorder() + GetLwrBorder();
881 const int NOTES_HEADER_FOOTER_WIDTH = long(aPageSize.Width() * 0.434);
882 const int NOTES_HEADER_FOOTER_HEIGHT = long(aPageSize.Height() * 0.05);
884 Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
886 const int X1 = GetLftBorder();
887 const int X2 = GetLftBorder() + long(aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH);
888 const int Y1 = GetUppBorder();
889 const int Y2 = GetUppBorder() + long(aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT );
891 if( eObjKind == PRESOBJ_HEADER )
893 Point aPos( X1, Y1 );
894 Rectangle aRect( aPos, aSize );
895 return CreatePresObj( PRESOBJ_HEADER, FALSE, aRect, bInsert );
897 else if( eObjKind == PRESOBJ_DATETIME )
899 Point aPos( X2, Y1 );
900 Rectangle aRect( aPos, aSize );
901 return CreatePresObj( PRESOBJ_DATETIME, FALSE, aRect, bInsert );
903 else if( eObjKind == PRESOBJ_FOOTER )
905 Point aPos( X1, Y2 );
906 Rectangle aRect( aPos, aSize );
907 return CreatePresObj( PRESOBJ_FOOTER, FALSE, aRect, bInsert );
909 else if( eObjKind == PRESOBJ_SLIDENUMBER )
911 Point aPos( X2, Y2 );
912 Rectangle aRect( aPos, aSize );
913 return CreatePresObj( PRESOBJ_SLIDENUMBER, FALSE, aRect, bInsert );
916 DBG_ERROR("SdPage::CreateDefaultPresObj() - this should not happen!");
917 return NULL;
920 else if( eObjKind == PRESOBJ_BACKGROUND )
922 Point aBackgroundPos ( GetLftBorder(), GetUppBorder() );
923 Size aBackgroundSize ( GetSize() );
924 aBackgroundSize.Width() -= GetLftBorder() + GetRgtBorder() - 1;
925 aBackgroundSize.Height() -= GetUppBorder() + GetLwrBorder() - 1;
926 Rectangle aBackgroundRect(aBackgroundPos, aBackgroundSize);
927 return CreatePresObj( PRESOBJ_BACKGROUND, FALSE, aBackgroundRect, bInsert );
929 else
931 DBG_ERROR("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
932 return NULL;
936 /*************************************************************************
938 |* Titelbereich zurueckgeben
940 \************************************************************************/
942 Rectangle SdPage::GetTitleRect() const
944 Rectangle aTitleRect;
946 if (mePageKind != PK_HANDOUT)
948 /******************************************************************
949 * Standard- oder Notiz-Seite: Titelbereich
950 ******************************************************************/
951 Point aTitlePos ( GetLftBorder(), GetUppBorder() );
952 Size aTitleSize ( GetSize() );
953 aTitleSize.Width() -= GetLftBorder() + GetRgtBorder();
954 aTitleSize.Height() -= GetUppBorder() + GetLwrBorder();
956 if (mePageKind == PK_STANDARD)
958 aTitlePos.X() += long( aTitleSize.Width() * 0.05 );
959 aTitlePos.Y() += long( aTitleSize.Height() * 0.0399 );
960 aTitleSize.Width() = long( aTitleSize.Width() * 0.9 );
961 aTitleSize.Height() = long( aTitleSize.Height() * 0.167 );
963 else if (mePageKind == PK_NOTES)
965 Point aPos = aTitlePos;
966 aPos.Y() += long( aTitleSize.Height() * 0.076 );
968 // Hoehe beschraenken
969 aTitleSize.Height() = (long) (aTitleSize.Height() * 0.375);
971 Size aPartArea = aTitleSize;
972 Size aSize;
973 sal_uInt16 nDestPageNum(GetPageNum());
974 SdrPage* pRefPage = 0L;
976 if(nDestPageNum)
978 // only decrement if != 0, else we get 0xffff
979 nDestPageNum -= 1;
982 if(nDestPageNum < pModel->GetPageCount())
984 pRefPage = pModel->GetPage(nDestPageNum);
987 if ( pRefPage )
989 // tatsaechliche Seitengroesse in das Handout-Rechteck skalieren
990 double fH = (double) aPartArea.Width() / pRefPage->GetWdt();
991 double fV = (double) aPartArea.Height() / pRefPage->GetHgt();
993 if ( fH > fV )
994 fH = fV;
995 aSize.Width() = (long) (fH * pRefPage->GetWdt());
996 aSize.Height() = (long) (fH * pRefPage->GetHgt());
998 aPos.X() += (aPartArea.Width() - aSize.Width()) / 2;
999 aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2;
1002 aTitlePos = aPos;
1003 aTitleSize = aSize;
1006 aTitleRect.SetPos(aTitlePos);
1007 aTitleRect.SetSize(aTitleSize);
1010 return aTitleRect;
1014 /*************************************************************************
1016 |* Gliederungsbereich zurueckgeben
1018 \************************************************************************/
1020 Rectangle SdPage::GetLayoutRect() const
1022 Rectangle aLayoutRect;
1024 if (mePageKind != PK_HANDOUT)
1026 Point aLayoutPos ( GetLftBorder(), GetUppBorder() );
1027 Size aLayoutSize ( GetSize() );
1028 aLayoutSize.Width() -= GetLftBorder() + GetRgtBorder();
1029 aLayoutSize.Height() -= GetUppBorder() + GetLwrBorder();
1031 if (mePageKind == PK_STANDARD)
1033 aLayoutPos.X() += long( aLayoutSize.Width() * 0.05 );
1034 aLayoutPos.Y() += long( aLayoutSize.Height() * 0.234 );
1035 aLayoutSize.Width() = long( aLayoutSize.Width() * 0.9 );
1036 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.66 );
1037 aLayoutRect.SetPos(aLayoutPos);
1038 aLayoutRect.SetSize(aLayoutSize);
1040 else if (mePageKind == PK_NOTES)
1042 aLayoutPos.X() += long( aLayoutSize.Width() * 0.1 );
1043 aLayoutPos.Y() += long( aLayoutSize.Height() * 0.475 );
1044 aLayoutSize.Width() = long( aLayoutSize.Width() * 0.8 );
1045 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.45 );
1046 aLayoutRect.SetPos(aLayoutPos);
1047 aLayoutRect.SetSize(aLayoutSize);
1051 return aLayoutRect;
1055 /**************************************************************************
1057 |* Diese Methode weist ein AutoLayout zu
1059 \*************************************************************************/
1061 const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout
1062 const int VERTICAL = 0x8000;
1064 struct LayoutDescriptor
1066 int mnLayout;
1067 PresObjKind meKind[MAX_PRESOBJS];
1068 bool mbVertical[MAX_PRESOBJS];
1070 LayoutDescriptor( int nLayout, int k0 = 0, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0, int k5 = 0, int k6 = 0 );
1073 LayoutDescriptor::LayoutDescriptor( int nLayout, int k0, int k1, int k2, int k3, int k4, int k5, int k6 )
1074 : mnLayout( nLayout )
1076 meKind[0] = static_cast<PresObjKind>(k0 & (~VERTICAL)); mbVertical[0] = (k0 & VERTICAL) == VERTICAL;
1077 meKind[1] = static_cast<PresObjKind>(k1 & (~VERTICAL)); mbVertical[1] = (k1 & VERTICAL) == VERTICAL;
1078 meKind[2] = static_cast<PresObjKind>(k2 & (~VERTICAL)); mbVertical[2] = (k2 & VERTICAL) == VERTICAL;
1079 meKind[3] = static_cast<PresObjKind>(k3 & (~VERTICAL)); mbVertical[3] = (k3 & VERTICAL) == VERTICAL;
1080 meKind[4] = static_cast<PresObjKind>(k4 & (~VERTICAL)); mbVertical[4] = (k4 & VERTICAL) == VERTICAL;
1081 meKind[5] = static_cast<PresObjKind>(k5 & (~VERTICAL)); mbVertical[5] = (k5 & VERTICAL) == VERTICAL;
1082 meKind[6] = static_cast<PresObjKind>(k6 & (~VERTICAL)); mbVertical[6] = (k6 & VERTICAL) == VERTICAL;
1085 static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
1087 static LayoutDescriptor aLayouts[AUTOLAYOUT__END-AUTOLAYOUT__START] =
1089 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_TEXT ), // AUTOLAYOUT_TITLE
1090 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_ENUM
1091 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_CHART ), // AUTOLAYOUT_CHART
1092 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2TEXT
1093 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_CHART ), // AUTOLAYOUT_TEXTCHART
1094 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_ORGCHART ), // AUTOLAYOUT_ORG
1095 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_GRAPHIC ), // AUTOLAYOUT_TEXTCLbIP
1096 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_CHART, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHARTTEXT
1097 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_TABLE ), // AUTOLAYOUT_TAB
1098 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_GRAPHIC, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CLIPTEXT
1099 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OBJECT ), // AUTOLAYOUT_TEXTOBJ
1100 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OBJECT ), // AUTOLAYOUT_OBJ
1101 LayoutDescriptor( 2, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OBJECT, PRESOBJ_OBJECT ), // AUTOLAYOUT_TEXT2OBJ
1102 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OBJECT, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ
1103 LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OBJECT, PRESOBJ_OUTLINE ), // AUTOLAYOUT_OBJOVERTEXT
1104 LayoutDescriptor( 3, PRESOBJ_TITLE, PRESOBJ_OBJECT, PRESOBJ_OBJECT, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2OBJTEXT
1105 LayoutDescriptor( 5, PRESOBJ_TITLE, PRESOBJ_OBJECT, PRESOBJ_OBJECT, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2OBJOVERTEXT
1106 LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OBJECT ), // AUTOLAYOUT_TEXTOVEROBJ
1107 LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OBJECT, PRESOBJ_OBJECT, // AUTOLAYOUT_4OBJ
1108 PRESOBJ_OBJECT, PRESOBJ_OBJECT ),
1109 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_NONE ), // AUTOLAYOUT_ONLY_TITLE
1110 LayoutDescriptor( 0, PRESOBJ_NONE ), // AUTOLAYOUT_NONE
1111 LayoutDescriptor( 0, PRESOBJ_PAGE, PRESOBJ_NOTES ), // AUTOLAYOUT_NOTES
1112 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT1
1113 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT2
1114 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT3
1115 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT4
1116 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT6
1117 LayoutDescriptor( 7, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_CHART ),// AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
1118 LayoutDescriptor( 8, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
1119 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
1120 LayoutDescriptor( 9, PRESOBJ_TITLE, PRESOBJ_GRAPHIC, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
1121 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT9
1122 LayoutDescriptor( 10, PRESOBJ_TEXT, PRESOBJ_NONE ), // AUTOLAYOUT_ONLY_TEXT
1123 LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC, // AUTOLAYOUT_4CLIPART
1124 PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC ),
1125 LayoutDescriptor( 11, PRESOBJ_TITLE, PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC, // AUTOLAYOUT_6CLIPART
1126 PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC )
1129 if( (eLayout < AUTOLAYOUT__START) || (eLayout >= AUTOLAYOUT__END) )
1130 eLayout = AUTOLAYOUT_NONE;
1132 return aLayouts[ eLayout - AUTOLAYOUT__START ];
1135 static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRectangle )
1137 Rectangle aTitleRect;
1138 Rectangle aLayoutRect;
1140 if( rPage.GetPageKind() != PK_HANDOUT )
1142 SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage());
1143 SdrObject* pMasterTitle = rMasterPage.GetPresObj( PRESOBJ_TITLE );
1144 SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
1146 if( pMasterTitle )
1147 aTitleRect = pMasterTitle->GetLogicRect();
1149 if (aTitleRect.IsEmpty() )
1150 aTitleRect = rPage.GetTitleRect();
1152 if( pMasterOutline )
1153 aLayoutRect = pMasterOutline->GetLogicRect();
1155 if (aLayoutRect.IsEmpty() )
1156 aLayoutRect = rPage.GetLayoutRect();
1159 rRectangle[0] = aTitleRect;
1161 int i;
1162 for( i = 1; i < MAX_PRESOBJS; i++ )
1163 rRectangle[i] = aLayoutRect;
1165 Size aTitleSize( aTitleRect.GetSize() );
1166 Point aTitlePos( aTitleRect.TopLeft() );
1167 Size aLayoutSize( aLayoutRect.GetSize() );
1168 Point aLayoutPos( aLayoutRect.TopLeft() );
1169 Size aTempSize;
1170 Point aTempPnt;
1172 sal_Bool bRightToLeft = ( rPage.GetModel() && static_cast< SdDrawDocument* >( rPage.GetModel() )->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB );
1174 switch( nLayout )
1176 case 0: // default layout using only the title and layout area
1177 break; // do nothing
1178 case 1: // title, 2 shapes
1179 case 9: // title, 2 vertical shapes
1180 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1181 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1183 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1184 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1186 if( bRightToLeft && (nLayout != 9) )
1187 ::std::swap< Rectangle >( rRectangle[1], rRectangle[2] );
1188 break;
1189 case 2: // title, shape, 2 shapes
1190 aTempPnt = aLayoutPos;
1191 aTempSize = aLayoutSize;
1192 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1193 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1194 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1195 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1197 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1198 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1200 aLayoutPos = aTempPnt;
1201 aLayoutSize = aTempSize;
1202 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1203 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1205 if( bRightToLeft )
1207 ::std::swap< long >( rRectangle[1].Left(), rRectangle[2].Left() );
1208 rRectangle[3].Left() = rRectangle[2].Left();
1210 break;
1211 case 3: // title, 2 shapes, shape
1212 aTempPnt = aLayoutPos;
1213 aTempSize = aLayoutSize;
1214 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1215 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1216 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1218 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1219 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1221 aLayoutPos = aTempPnt;
1222 aLayoutSize = aTempSize;
1223 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1224 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1225 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1227 if( bRightToLeft )
1229 ::std::swap< long >( rRectangle[1].Left(), rRectangle[2].Left() );
1230 rRectangle[3].Left() = rRectangle[2].Left();
1232 break;
1233 case 4: // title, shape above shape
1234 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1235 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1237 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1238 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1239 break;
1241 case 5: // title, 2 shapes above shape
1242 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1243 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1244 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1246 aTempPnt = aLayoutPos;
1247 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1248 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1250 aLayoutPos.X() = aTempPnt.X();
1251 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1252 aLayoutSize.Width() = long (aLayoutSize.Width() / 0.488);
1253 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1254 break;
1255 case 6: // title, 4 shapes
1257 ULONG nX = long (aLayoutPos.X());
1259 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1260 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1261 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1263 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1264 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1266 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1267 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1269 aLayoutPos.X() = nX;
1270 rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
1271 break;
1273 case 7: // vertical title, shape above shape
1275 Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1276 rRectangle[0].SetSize( aSize );
1277 rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
1279 Size aPageSize ( rPage.GetSize() );
1280 aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
1281 aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
1282 aSize.Width() = long( aPageSize.Width() * 0.7 );
1283 rRectangle[1].SetPos( aTitleRect.TopLeft() );
1284 rRectangle[1].SetSize( aSize );
1286 aSize.Height() = rRectangle[0].GetSize().Height();
1287 Point aPos( aTitleRect.TopLeft() );
1288 aPos.Y() += long ( aSize.Height() * 0.53 );
1289 rRectangle[2].SetPos( aPos );
1290 aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
1291 rRectangle[2].SetSize( aSize );
1292 break;
1294 case 8: // vertical title, shape
1296 Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1297 rRectangle[0].SetSize( aSize );
1298 rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
1300 Size aPageSize ( rPage.GetSize() );
1301 aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
1302 aSize.Height() = rRectangle[0].GetSize().Height();
1303 aSize.Width() = long( aPageSize.Width() * 0.7 );
1304 rRectangle[1].SetPos( aTitleRect.TopLeft() );
1305 rRectangle[1].SetSize( aSize );
1306 break;
1308 case 10: // onlytext
1310 Size aSize( rRectangle[0].GetSize().Width(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1311 rRectangle[0].SetSize( aSize );
1312 rRectangle[0].SetPos( aTitlePos);
1313 break;
1315 case 11: // title, 6 shapes
1317 ULONG nX = long (aLayoutPos.X());
1319 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1320 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.322);
1321 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1323 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1324 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1326 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 2 * 1.05);
1327 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1329 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1330 rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
1332 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1333 rRectangle[5] = Rectangle (aLayoutPos, aLayoutSize);
1335 aLayoutPos.X() = nX;
1336 rRectangle[6] = Rectangle (aLayoutPos, aLayoutSize);
1338 break;
1345 void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::vector< SdrObject* >& rShapes, bool bInit )
1347 int i;
1349 // init list of indexes for each presentation shape kind
1350 // this is used to find subsequent shapes with the same presentation shape kind
1351 int PresObjIndex[PRESOBJ_MAX];
1352 for( i = 0; i < PRESOBJ_MAX; i++ ) PresObjIndex[i] = 1;
1354 bool bMissing = false;
1356 // for each entry in the layoutdescriptor, arrange a presentation shape
1357 for( i = 0; (i < PRESOBJ_MAX) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++ )
1359 PresObjKind eKind = rDescriptor.meKind[i];
1360 SdrObject* pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind] );
1361 if( pObj )
1363 PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
1364 rShapes[i] = pObj;
1366 else
1368 bMissing = true;
1372 if( bMissing && bInit )
1374 // for each entry in the layoutdescriptor, look for an alternative shape
1375 for( i = 0; (i < PRESOBJ_MAX) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++ )
1377 if( rShapes[i] )
1378 continue;
1380 PresObjKind eKind = rDescriptor.meKind[i];
1382 SdrObject* pObj = 0;
1383 bool bFound = false;
1385 const int nShapeCount = rPage.GetObjCount();
1386 int nShapeIndex = 0;
1387 while((nShapeIndex < nShapeCount) && !bFound )
1389 pObj = rPage.GetObj(nShapeIndex++);
1391 if( pObj->IsEmptyPresObj() )
1392 continue;
1394 if( pObj->GetObjInventor() != SdrInventor )
1395 continue;
1397 // do not reuse shapes that are already part of the layout
1398 if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() )
1399 continue;
1401 bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE);
1402 SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() );
1404 switch( eKind )
1406 case PRESOBJ_TITLE:
1407 bFound = eSdrObjKind == OBJ_TITLETEXT;
1408 break;
1409 case PRESOBJ_OUTLINE:
1410 bFound = (eSdrObjKind == OBJ_OUTLINETEXT) || ((eSdrObjKind == OBJ_TEXT) && bPresStyle);
1411 break;
1412 case PRESOBJ_GRAPHIC:
1413 bFound = eSdrObjKind == OBJ_GRAF;
1414 break;
1415 case PRESOBJ_OBJECT:
1416 if( eSdrObjKind == OBJ_OLE2 )
1418 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1419 if( pOle2 )
1421 if( pOle2->IsEmpty() )
1422 bFound = true;
1423 else if( rPage.GetModel() )
1425 SdrModel* pSdrModel = rPage.GetModel();
1426 ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
1427 if( pPersist )
1429 uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
1430 GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
1432 // TODO CL->KA: Why is this not working anymore?
1433 if( xObject.is() )
1435 SvGlobalName aClassId( xObject->getClassID() );
1437 const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
1438 const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
1439 const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
1441 if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
1443 bFound = true;
1450 break;
1451 case PRESOBJ_CHART:
1452 case PRESOBJ_TABLE:
1453 if( eSdrObjKind == OBJ_OLE2 )
1455 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1456 if( pOle2 )
1459 ((eKind == PRESOBJ_CHART) &&
1460 ( pOle2->GetProgName().EqualsAscii( "StarChart" ) || pOle2->IsChart() ) )
1462 ((eKind == PRESOBJ_TABLE) &&
1463 ( pOle2->GetProgName().EqualsAscii( "StarCalc" ) || pOle2->IsCalc() ) ) )
1465 bFound = true;
1468 break;
1470 break;
1471 case PRESOBJ_PAGE:
1472 case PRESOBJ_HANDOUT:
1473 bFound = eSdrObjKind == OBJ_PAGE;
1474 break;
1475 case PRESOBJ_NOTES:
1476 case PRESOBJ_TEXT:
1477 bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT);
1478 break;
1479 default:
1480 break;
1484 if( bFound )
1485 rShapes[i] = pObj;
1490 void SdPage::SetAutoLayout(AutoLayout eLayout, BOOL bInit, BOOL bCreate )
1492 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1494 sd::UndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
1495 const bool bUndo = pUndoManager && pUndoManager->isInListAction() && IsInserted();
1497 meAutoLayout = eLayout;
1499 // if needed, creates and initialises the presentation shapes on this slides master page
1500 CreateTitleAndLayout(bInit, bCreate);
1502 if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster)
1504 // MasterPage or no layout and no presentation shapes available, noting to do
1505 return;
1508 Rectangle aRectangle[MAX_PRESOBJS];
1509 const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
1510 CalcAutoLayoutRectangles( *this, aDescriptor.mnLayout, aRectangle );
1512 std::set< SdrObject* > aUsedPresentationObjects;
1515 std::vector< SdrObject* > aLayoutShapes(PRESOBJ_MAX, 0);
1516 findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit );
1518 int i;
1520 // for each entry in the layoutdescriptor, arrange a presentation shape
1521 for( i = 0; (i < PRESOBJ_MAX) && (aDescriptor.meKind[i] != PRESOBJ_NONE); i++ )
1523 PresObjKind eKind = aDescriptor.meKind[i];
1524 SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );
1525 if( pObj )
1526 aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape
1529 // now delete all empty presentation objects that are no longer used by the new layout
1530 if( bInit )
1532 SdrObject* pObj = maPresentationShapeList.getNextShape(0);
1534 while( pObj )
1536 SdrObject* pNext = maPresentationShapeList.getNextShape(pObj);
1537 if( aUsedPresentationObjects.count(pObj) == 0 )
1540 if( pObj->IsEmptyPresObj() )
1542 if( bUndo )
1543 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
1545 RemoveObject( pObj->GetOrdNum() );
1547 if( !bUndo )
1548 SdrObject::Free( pObj );
1550 else
1552 if( bUndo )
1554 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
1555 if( pObj->GetUserCall() )
1556 pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
1558 maPresentationShapeList.removeShape( *pObj );
1559 pObj->SetUserCall(0);
1562 pObj = pNext;
1567 /*************************************************************************
1569 |* Objekt einfuegen
1571 \************************************************************************/
1573 void SdPage::NbcInsertObject(SdrObject* pObj, ULONG nPos, const SdrInsertReason* pReason)
1575 FmFormPage::NbcInsertObject(pObj, nPos, pReason);
1577 ((SdDrawDocument*) pModel)->InsertObject(pObj, this);
1579 SdrLayerID nId = pObj->GetLayer();
1580 if( mbMaster )
1582 if( nId == 0 )
1583 pObj->NbcSetLayer( 2 ); // wrong layer. corrected to BackgroundObj layer
1585 else
1587 if( nId == 2 )
1588 pObj->NbcSetLayer( 0 ); // wrong layer. corrected to layout layer
1592 /*************************************************************************
1594 |* Objekt loeschen
1596 \************************************************************************/
1598 SdrObject* SdPage::RemoveObject(ULONG nObjNum)
1600 onRemoveObject(GetObj( nObjNum ));
1601 return FmFormPage::RemoveObject(nObjNum);
1604 /*************************************************************************
1606 |* Objekt loeschen, ohne Broadcast
1608 \************************************************************************/
1610 SdrObject* SdPage::NbcRemoveObject(ULONG nObjNum)
1612 onRemoveObject(GetObj( nObjNum ));
1613 return FmFormPage::NbcRemoveObject(nObjNum);
1616 // #95876# Also overload ReplaceObject methods to realize when
1617 // objects are removed with this mechanism instead of RemoveObject
1618 SdrObject* SdPage::NbcReplaceObject(SdrObject* pNewObj, ULONG nObjNum)
1620 onRemoveObject(GetObj( nObjNum ));
1621 return FmFormPage::NbcReplaceObject(pNewObj, nObjNum);
1624 // #95876# Also overload ReplaceObject methods to realize when
1625 // objects are removed with this mechanism instead of RemoveObject
1626 SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, ULONG nObjNum)
1628 onRemoveObject(GetObj( nObjNum ));
1629 return FmFormPage::ReplaceObject(pNewObj, nObjNum);
1632 // -------------------------------------------------------------------------
1634 // called after a shape is removed or replaced from this slide
1636 void SdPage::onRemoveObject( SdrObject* pObject )
1638 if( pObject )
1640 RemovePresObj(pObject);
1642 if( pModel )
1643 static_cast<SdDrawDocument*>(pModel)->RemoveObject(pObject, this);
1645 removeAnimations( pObject );
1649 /*************************************************************************
1653 \************************************************************************/
1655 void SdPage::SetSize(const Size& aSize)
1657 Size aOldSize = GetSize();
1659 if (aSize != aOldSize)
1661 FmFormPage::SetSize(aSize);
1662 AdjustBackgroundSize();
1664 if (aOldSize.Height() == 10 && aOldSize.Width() == 10)
1666 // Die Seite bekommt erstmalig eine gueltige Groesse gesetzt,
1667 // daher wird nun die Orientation initialisiert
1668 if (aSize.Width() > aSize.Height())
1670 meOrientation = ORIENTATION_LANDSCAPE;
1672 else
1674 meOrientation = ORIENTATION_PORTRAIT;
1681 /*************************************************************************
1685 \************************************************************************/
1687 void SdPage::SetBorder(INT32 nLft, INT32 nUpp, INT32 nRgt, INT32 nLwr)
1689 if (nLft != GetLftBorder() || nUpp != GetUppBorder() ||
1690 nRgt != GetRgtBorder() || nLwr != GetLwrBorder() )
1692 FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
1693 AdjustBackgroundSize();
1698 /*************************************************************************
1702 \************************************************************************/
1704 void SdPage::SetLftBorder(INT32 nBorder)
1706 if (nBorder != GetLftBorder() )
1708 FmFormPage::SetLftBorder(nBorder);
1709 AdjustBackgroundSize();
1714 /*************************************************************************
1718 \************************************************************************/
1720 void SdPage::SetRgtBorder(INT32 nBorder)
1722 if (nBorder != GetRgtBorder() )
1724 FmFormPage::SetRgtBorder(nBorder);
1725 AdjustBackgroundSize();
1730 /*************************************************************************
1734 \************************************************************************/
1736 void SdPage::SetUppBorder(INT32 nBorder)
1738 if (nBorder != GetUppBorder() )
1740 FmFormPage::SetUppBorder(nBorder);
1741 AdjustBackgroundSize();
1746 /*************************************************************************
1750 \************************************************************************/
1752 void SdPage::SetLwrBorder(INT32 nBorder)
1754 if (nBorder != GetLwrBorder() )
1756 FmFormPage::SetLwrBorder(nBorder);
1757 AdjustBackgroundSize();
1761 /*************************************************************************
1763 |* Setzt BackgroundFullSize und ruft dann AdjustBackground auf
1765 \************************************************************************/
1767 void SdPage::SetBackgroundFullSize( BOOL bIn )
1769 if( bIn != mbBackgroundFullSize )
1771 mbBackgroundFullSize = bIn;
1772 AdjustBackgroundSize();
1776 /*************************************************************************
1778 |* Alle Objekte an neue Seitengroesse anpassen
1780 |* bScaleAllObj: Alle Objekte werden in die neue Flaeche innerhalb der
1781 |* Seitenraender skaliert. Dabei werden die Position, Groesse und bei
1782 |* Praesentationsobjekten auf der MasterPage auch die Schrifthoehe der
1783 |* Praesentationsvorlagen skaliert.
1785 \************************************************************************/
1787 void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderRect, BOOL bScaleAllObj)
1789 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1791 mbScaleObjects = bScaleAllObj;
1792 SdrObject* pObj = NULL;
1793 Point aRefPnt(0, 0);
1794 Size aNewPageSize(rNewPageSize);
1795 INT32 nLeft = rNewBorderRect.Left();
1796 INT32 nRight = rNewBorderRect.Right();
1797 INT32 nUpper = rNewBorderRect.Top();
1798 INT32 nLower = rNewBorderRect.Bottom();
1800 // Negative Werte stehen fuer nicht zu aendernde Werte
1801 // -> aktuelle Werte verwenden
1802 if (aNewPageSize.Width() < 0)
1804 aNewPageSize.Width() = GetWdt();
1806 if (aNewPageSize.Height() < 0)
1808 aNewPageSize.Height() = GetHgt();
1810 if (nLeft < 0)
1812 nLeft = GetLftBorder();
1814 if (nRight < 0)
1816 nRight = GetRgtBorder();
1818 if (nUpper < 0)
1820 nUpper = GetUppBorder();
1822 if (nLower < 0)
1824 nLower = GetLwrBorder();
1827 Point aBackgroundPos(nLeft, nUpper);
1828 Size aBackgroundSize(aNewPageSize);
1829 Rectangle aBorderRect (aBackgroundPos, aBackgroundSize);
1831 if (mbScaleObjects)
1833 aBackgroundSize.Width() -= nLeft + nRight;
1834 aBackgroundSize.Height() -= nUpper + nLower;
1835 aBorderRect.SetSize(aBackgroundSize);
1836 aNewPageSize = aBackgroundSize;
1839 long nOldWidth = GetWdt() - GetLftBorder() - GetRgtBorder();
1840 long nOldHeight = GetHgt() - GetUppBorder() - GetLwrBorder();
1842 Fraction aFractX = Fraction(aNewPageSize.Width(), nOldWidth);
1843 Fraction aFractY = Fraction(aNewPageSize.Height(), nOldHeight);
1845 ULONG nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
1847 for (ULONG nObj = 0; nObj < nObjCnt; nObj++)
1849 BOOL bIsPresObjOnMaster = FALSE;
1851 // Alle Objekte
1852 pObj = GetObj(nObj);
1854 if (mbMaster && IsPresObj(pObj))
1856 // Es ist ein Praesentationsobjekt auf der MasterPage
1857 bIsPresObjOnMaster = TRUE;
1860 if (pObj)
1862 USHORT nIndexBackground = 0;
1863 // #88084# remember aTopLeft as original TopLeft
1864 Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
1866 if (bIsPresObjOnMaster && (pObj == GetPresObj(PRESOBJ_BACKGROUND, nIndexBackground)) )
1868 /**************************************************************
1869 * 1. Praesentationsobjekte auf Handzettelseite sollen nur positioniert werden
1870 * 2. Hintergrundobjekt wird nicht skaliert
1871 **************************************************************/
1873 else if (!pObj->IsEdgeObj())
1875 /**************************************************************
1876 * Objekt skalieren
1877 **************************************************************/
1878 if (mbScaleObjects)
1880 // #88084# use aTopLeft as original TopLeft
1881 aRefPnt = aTopLeft;
1884 pObj->Resize(aRefPnt, aFractX, aFractY);
1886 if (mbScaleObjects)
1888 SdrObjKind eObjKind = (SdrObjKind) pObj->GetObjIdentifier();
1890 if (bIsPresObjOnMaster)
1892 /**********************************************************
1893 * Praesentationsvorlage: Texthoehe anpassen
1894 **********************************************************/
1895 USHORT nIndexTitle = 0;
1896 USHORT nIndexOutline = 0;
1897 USHORT nIndexNotes = 0;
1899 if (pObj == GetPresObj(PRESOBJ_TITLE, nIndexTitle))
1901 SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
1903 if (pTitleSheet)
1905 SfxItemSet& rSet = pTitleSheet->GetItemSet();
1907 SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT);
1908 ULONG nFontHeight = rOldHgt.GetHeight();
1909 nFontHeight = long(nFontHeight * (double) aFractY);
1910 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1912 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1914 rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1915 nFontHeight = rOldHgt.GetHeight();
1916 nFontHeight = long(nFontHeight * (double) aFractY);
1917 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1920 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1922 rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1923 nFontHeight = rOldHgt.GetHeight();
1924 nFontHeight = long(nFontHeight * (double) aFractY);
1925 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1928 pTitleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1931 else if (pObj == GetPresObj(PRESOBJ_OUTLINE, nIndexOutline))
1933 String aName(GetLayoutName());
1934 aName += sal_Unicode( ' ' );
1936 for (USHORT i=1; i<=9; i++)
1938 String sLayoutName(aName);
1939 sLayoutName += String::CreateFromInt32( (sal_Int32)i );
1940 SfxStyleSheet* pOutlineSheet = (SfxStyleSheet*)((SdDrawDocument*) pModel)->GetStyleSheetPool()->Find(sLayoutName, SD_STYLE_FAMILY_MASTERPAGE);
1942 if (pOutlineSheet)
1944 // Neue Fonthoehe berechnen
1945 SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
1947 SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT);
1948 ULONG nFontHeight = rOldHgt.GetHeight();
1949 nFontHeight = long(nFontHeight * (double) aFractY);
1950 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1952 if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1954 rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1955 nFontHeight = rOldHgt.GetHeight();
1956 nFontHeight = long(nFontHeight * (double) aFractY);
1957 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1960 if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1962 rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1963 nFontHeight = rOldHgt.GetHeight();
1964 nFontHeight = long(nFontHeight * (double) aFractY);
1965 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1968 // Bullet anpassen
1969 ((SdStyleSheet*) pOutlineSheet)->AdjustToFontHeight(aTempSet, FALSE);
1971 // Sonderbehandlung: die INVALIDS auf NULL-Pointer
1972 // zurueckgesetzen (sonst landen INVALIDs oder
1973 // Pointer auf die DefaultItems in der Vorlage;
1974 // beides wuerde die Attribut-Vererbung unterbinden)
1975 aTempSet.ClearInvalidItems();
1977 // Sonderbehandlung: nur die gueltigen Anteile des
1978 // BulletItems
1979 if (aTempSet.GetItemState(EE_PARA_BULLET) == SFX_ITEM_AVAILABLE)
1981 SvxBulletItem aOldBulItem((SvxBulletItem&) pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET));
1982 SvxBulletItem& rNewBulItem = (SvxBulletItem&) aTempSet.Get(EE_PARA_BULLET);
1983 aOldBulItem.CopyValidProperties(rNewBulItem);
1984 aTempSet.Put(aOldBulItem);
1987 pOutlineSheet->GetItemSet().Put(aTempSet);
1989 pOutlineSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1993 else if (pObj == GetPresObj(PRESOBJ_NOTES, nIndexNotes))
1995 SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PRESOBJ_NOTES);
1997 if (pNotesSheet)
1999 ULONG nHeight = pObj->GetLogicRect().GetSize().Height();
2000 ULONG nFontHeight = (ULONG) (nHeight * 0.0741);
2001 SfxItemSet& rSet = pNotesSheet->GetItemSet();
2002 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
2003 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
2004 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
2005 pNotesSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
2009 else if ( eObjKind != OBJ_TITLETEXT &&
2010 eObjKind != OBJ_OUTLINETEXT &&
2011 pObj->ISA(SdrTextObj) &&
2012 pObj->GetOutlinerParaObject() )
2014 /******************************************************
2015 * Normales Textobjekt: Texthoehe anpassen
2016 ******************************************************/
2017 ULONG nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
2018 USHORT nWhich = EE_CHAR_FONTHEIGHT;
2019 if ( nScriptType == SCRIPTTYPE_ASIAN )
2020 nWhich = EE_CHAR_FONTHEIGHT_CJK;
2021 else if ( nScriptType == SCRIPTTYPE_COMPLEX )
2022 nWhich = EE_CHAR_FONTHEIGHT_CTL;
2024 // #88084# use more modern method to scale the text height
2025 sal_uInt32 nFontHeight = ((SvxFontHeightItem&)pObj->GetMergedItem(nWhich)).GetHeight();
2026 sal_uInt32 nNewFontHeight = sal_uInt32((double)nFontHeight * (double)aFractY);
2028 pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
2033 if (mbScaleObjects && !pObj->IsEdgeObj())
2035 /**************************************************************
2036 * Objektposition skalieren
2037 **************************************************************/
2038 Point aNewPos;
2040 // #76447# corrected scaling; only distances may be scaled
2041 // #88084# use aTopLeft as original TopLeft
2042 aNewPos.X() = long((aTopLeft.X() - GetLftBorder()) * (double)aFractX) + nLeft;
2043 aNewPos.Y() = long((aTopLeft.Y() - GetUppBorder()) * (double)aFractY) + nUpper;
2045 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
2047 if (aVec.Height() != 0 || aVec.Width() != 0)
2049 pObj->NbcMove(aVec);
2052 Rectangle aBoundRect = pObj->GetCurrentBoundRect();
2054 if (!aBorderRect.IsInside(aBoundRect))
2056 /**********************************************************
2057 * Objekt liegt nicht vollstaendig innerhalb der Raender
2058 * -> Position korrigieren
2059 **********************************************************/
2060 Point aOldPos(aBoundRect.TopLeft());
2061 aNewPos = aOldPos;
2063 // Position links oben ggf. korrigieren
2064 aNewPos.X() = Max(aNewPos.X(), aBorderRect.Left());
2065 aNewPos.Y() = Max(aNewPos.Y(), aBorderRect.Top());
2066 aVec = Size(aNewPos.X() - aOldPos.X(), aNewPos.Y() - aOldPos.Y());
2068 if (aVec.Height() != 0 || aVec.Width() != 0)
2070 pObj->NbcMove(aVec);
2073 // Position rechts unten ggf. korrigieren
2074 aOldPos = aBoundRect.BottomRight();
2075 aNewPos = aOldPos;
2076 aNewPos.X() = Min(aNewPos.X(), aBorderRect.Right());
2077 aNewPos.Y() = Min(aNewPos.Y(), aBorderRect.Bottom());
2078 aVec = Size(aNewPos.X() - aOldPos.X(), aNewPos.Y() - aOldPos.Y());
2080 if (aVec.Height() != 0 || aVec.Width() != 0)
2082 pObj->NbcMove(aVec);
2086 pObj->SetChanged();
2087 pObj->BroadcastObjectChange();
2093 SdrObject* convertPresentationObjectImpl( SdPage& rPage, SdrObject* pSourceObj, PresObjKind eObjKind, bool bVertical, Rectangle aRect )
2095 SdDrawDocument* pModel = static_cast< SdDrawDocument* >( rPage.GetModel() );
2096 DBG_ASSERT( pModel, "sd::convertPresentationObjectImpl(), no model on page!" );
2097 if( !pModel || !pSourceObj )
2098 return pSourceObj;
2100 sd::UndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
2101 const bool bUndo = pUndoManager && pUndoManager->isInListAction() && rPage.IsInserted();
2103 SdrObject* pNewObj = pSourceObj;
2104 if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) )
2106 pNewObj = rPage.CreatePresObj(PRESOBJ_OUTLINE, bVertical, aRect);
2108 // Text des Untertitels in das PRESOBJ_OUTLINE setzen
2109 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2111 if(pOutlParaObj)
2113 // Text umsetzen
2114 ::sd::Outliner* pOutl = pModel->GetInternalOutliner( TRUE );
2115 pOutl->Clear();
2116 pOutl->SetText( *pOutlParaObj );
2117 pOutlParaObj = pOutl->CreateParaObject();
2118 pNewObj->SetOutlinerParaObject( pOutlParaObj );
2119 pOutl->Clear();
2120 pNewObj->SetEmptyPresObj(FALSE);
2122 for (USHORT nLevel = 1; nLevel < 10; nLevel++)
2124 // Neue Vorlage zuweisen
2125 String aName(rPage.GetLayoutName());
2126 aName += sal_Unicode( ' ' );
2127 aName += String::CreateFromInt32( nLevel );
2128 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE) );
2130 if (pSheet)
2132 if (nLevel == 1)
2134 SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2136 if (pSubtitleSheet)
2137 pOutlParaObj->ChangeStyleSheetName(SD_STYLE_FAMILY_MASTERPAGE, pSubtitleSheet->GetName(), pSheet->GetName());
2140 pNewObj->StartListening(*pSheet);
2144 // LRSpace-Item loeschen
2145 SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
2147 aSet.Put(pNewObj->GetMergedItemSet());
2149 aSet.ClearItem(EE_PARA_LRSPACE);
2151 pNewObj->SetMergedItemSet(aSet);
2153 if( bUndo )
2154 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
2156 // Remove outline shape from page
2157 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2159 if( !bUndo )
2160 SdrObject::Free( pSourceObj );
2163 else if((eObjKind == PRESOBJ_TEXT) && (pSourceObj->GetObjIdentifier() != OBJ_TEXT) )
2165 // is there an outline shape we can use to replace empty subtitle shape?
2166 pNewObj = rPage.CreatePresObj(PRESOBJ_TEXT, bVertical, aRect);
2168 // Text des Gliederungsobjekts in das PRESOBJ_TITLE setzen
2169 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2171 if(pOutlParaObj)
2173 // Text umsetzen
2174 ::sd::Outliner* pOutl = pModel->GetInternalOutliner();
2175 pOutl->Clear();
2176 pOutl->SetText( *pOutlParaObj );
2177 pOutlParaObj = pOutl->CreateParaObject();
2178 pNewObj->SetOutlinerParaObject( pOutlParaObj );
2179 pOutl->Clear();
2180 pNewObj->SetEmptyPresObj(FALSE);
2182 // Linken Einzug zuruecksetzen
2183 SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
2185 aSet.Put(pNewObj->GetMergedItemSet());
2187 const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&) aSet.Get(EE_PARA_LRSPACE);
2188 SvxLRSpaceItem aNewLRItem(rLRItem);
2189 aNewLRItem.SetTxtLeft(0);
2190 aSet.Put(aNewLRItem);
2192 pNewObj->SetMergedItemSet(aSet);
2194 SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2195 if (pSheet)
2196 pNewObj->SetStyleSheet(pSheet, TRUE);
2198 // Remove subtitle shape from page
2199 if( bUndo )
2200 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
2202 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2204 if( !bUndo )
2205 SdrObject::Free( pSourceObj );
2209 return pNewObj;
2212 /** reuses or creates a presentation shape for an auto layout that fits the given parameter
2214 @param eObjKind
2215 The kind of presentation shape we like to have
2216 @param nIndex
2217 If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
2218 looking for an existing presentation shape
2219 @param bVertical
2220 If true, the shape is created vertical if bInit is true
2221 @param aRect
2222 The rectangle that should be used to transform the shape
2223 @param bInit
2224 If true the shape is created if not found
2225 @returns
2226 A presentation shape that was either found or created with the given parameters
2228 SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind, bool bVertical, Rectangle aRect, bool bInit )
2230 sd::UndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
2231 const bool bUndo = pUndoManager && pUndoManager->isInListAction() && IsInserted();
2233 if (!pObj && bInit)
2235 pObj = CreatePresObj(eObjKind, bVertical, aRect);
2237 else if ( pObj && (pObj->GetUserCall() || bInit) )
2239 // convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2240 if( bInit )
2241 pObj = convertPresentationObjectImpl( *this, pObj, eObjKind, bVertical, aRect );
2243 if( bUndo )
2245 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
2246 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, TRUE, TRUE ) );
2247 pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
2250 if ( pObj->ISA(SdrGrafObj) && !pObj->IsEmptyPresObj() )
2251 ( (SdrGrafObj*) pObj)->AdjustToMaxRect( aRect, FALSE );
2252 else
2253 pObj->SetLogicRect(aRect);
2255 pObj->SetUserCall(this);
2257 SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
2258 if( pTextObject )
2260 if( pTextObject->IsVerticalWriting() != (bVertical ? sal_True : sal_False) )
2262 pTextObject->SetVerticalWriting( bVertical );
2264 // #94826# here make sure the correct anchoring is used when the object
2265 // is re-used but orientation is changed
2266 if(PRESOBJ_OUTLINE == eObjKind)
2267 pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
2270 if( !mbMaster )
2272 if ( pTextObject->IsAutoGrowHeight() )
2274 // switch off AutoGrowHeight, set new MinHeight
2275 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
2276 SdrTextMinFrameHeightItem aMinHeight( aRect.GetSize().Height() );
2277 aTempAttr.Put( aMinHeight );
2278 aTempAttr.Put( SdrTextAutoGrowHeightItem(FALSE) );
2279 pTextObject->SetMergedItemSet(aTempAttr);
2280 pTextObject->SetLogicRect(aRect);
2282 // switch on AutoGrowHeight
2283 SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
2284 aAttr.Put( SdrTextAutoGrowHeightItem(TRUE) );
2286 pTextObject->SetMergedItemSet(aAttr);
2289 if ( pTextObject->IsAutoGrowWidth() )
2291 // switch off AutoGrowWidth , set new MinWidth
2292 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
2293 SdrTextMinFrameWidthItem aMinWidth( aRect.GetSize().Width() );
2294 aTempAttr.Put( aMinWidth );
2295 aTempAttr.Put( SdrTextAutoGrowWidthItem(FALSE) );
2296 pTextObject->SetMergedItemSet(aTempAttr);
2297 pTextObject->SetLogicRect(aRect);
2299 // switch on AutoGrowWidth
2300 SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
2301 aAttr.Put( SdrTextAutoGrowWidthItem(TRUE) );
2302 pTextObject->SetMergedItemSet(aAttr);
2308 if(pObj && bInit )
2310 if( !IsPresObj( pObj ) )
2312 if( bUndo )
2313 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
2315 InsertPresObj( pObj, eObjKind );
2318 // make adjustments for vertical title and outline shapes
2319 if( bVertical && (( eObjKind == PRESOBJ_TITLE) || (eObjKind == PRESOBJ_OUTLINE)))
2321 SfxItemSet aNewSet(pObj->GetMergedItemSet());
2322 aNewSet.Put( SdrTextAutoGrowWidthItem(TRUE) );
2323 aNewSet.Put( SdrTextAutoGrowHeightItem(FALSE) );
2324 if( eObjKind == PRESOBJ_OUTLINE )
2326 aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
2327 aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
2329 pObj->SetMergedItemSet(aNewSet);
2333 return pObj;
2337 /*************************************************************************
2339 |* Liefert den PresObjKind eines Objektes zurueck
2341 \************************************************************************/
2343 PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const
2345 PresObjKind eKind = PRESOBJ_NONE;
2346 if( (pObj != 0) && (maPresentationShapeList.hasShape(*pObj)) )
2348 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
2349 if( pInfo )
2350 eKind = pInfo->mePresObjKind;
2353 return eKind;
2356 bool SdPage::IsPresObj(const SdrObject* pObj)
2358 return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
2361 void SdPage::RemovePresObj(const SdrObject* pObj)
2363 if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
2365 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
2366 if( pInfo )
2367 pInfo->mePresObjKind = PRESOBJ_NONE;
2368 maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
2372 void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
2374 DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2375 DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2376 if( pObj )
2378 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
2379 if( pInfo )
2380 pInfo->mePresObjKind = eKind;
2381 maPresentationShapeList.addShape(*pObj);
2385 /*************************************************************************
2387 |* Text des Objektes setzen
2389 \************************************************************************/
2391 void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const String& rString )
2393 if ( pObj )
2395 DBG_ASSERT( pObj->ISA(SdrTextObj), "SetObjText: Kein SdrTextObj!" );
2396 ::Outliner* pOutl = pOutliner;
2398 if (!pOutliner)
2400 SfxItemPool* pPool = ((SdDrawDocument*) GetModel())->GetDrawOutliner().GetEmptyItemSet().GetPool();
2401 pOutl = new ::Outliner( pPool, OUTLINERMODE_OUTLINEOBJECT );
2402 pOutl->SetRefDevice( SD_MOD()->GetRefDevice( *( (SdDrawDocument*) GetModel() )->GetDocSh() ) );
2403 pOutl->SetEditTextObjectPool(pPool);
2404 pOutl->SetStyleSheetPool((SfxStyleSheetPool*)GetModel()->GetStyleSheetPool());
2405 pOutl->EnableUndo(FALSE);
2406 pOutl->SetUpdateMode( FALSE );
2409 USHORT nOutlMode = pOutl->GetMode();
2410 Size aPaperSize = pOutl->GetPaperSize();
2411 BOOL bUpdateMode = pOutl->GetUpdateMode();
2412 pOutl->SetUpdateMode(FALSE);
2413 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2415 // #95114# Always set the object's StyleSheet at the Outliner to
2416 // use the current objects StyleSheet. Thus it's the same as in
2417 // SetText(...).
2418 // #95114# Moved this implementation from where SetObjText(...) was called
2419 // to inside this method to work even when outliner is fetched here.
2420 pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
2422 String aString;
2424 switch( eObjKind )
2426 case PRESOBJ_OUTLINE:
2428 pOutl->Init( OUTLINERMODE_OUTLINEOBJECT );
2430 aString += sal_Unicode( '\t' );
2431 aString += rString;
2433 if (mbMaster)
2435 pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
2436 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t" ));
2437 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER2 ) );
2439 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t" ));
2440 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER3 ) );
2442 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t" ));
2443 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER4 ) );
2445 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t" ));
2446 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER5 ) );
2448 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t" ));
2449 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER6 ) );
2451 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t" ));
2452 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER7 ) );
2454 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t\t" ));
2455 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER8 ) );
2457 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t\t\t" ));
2458 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER9 ) );
2461 break;
2463 case PRESOBJ_TITLE:
2465 pOutl->Init( OUTLINERMODE_TITLEOBJECT );
2466 aString += rString;
2468 break;
2470 default:
2472 pOutl->Init( OUTLINERMODE_TEXTOBJECT );
2473 aString += rString;
2475 // check if we need to add a text field
2476 SvxFieldData* pData = NULL;
2478 switch( eObjKind )
2480 case PRESOBJ_HEADER:
2481 pData = new SvxHeaderField();
2482 break;
2483 case PRESOBJ_FOOTER:
2484 pData = new SvxFooterField();
2485 break;
2486 case PRESOBJ_SLIDENUMBER:
2487 pData = new SvxPageField();
2488 break;
2489 case PRESOBJ_DATETIME:
2490 pData = new SvxDateTimeField();
2491 break;
2492 default:
2493 break;
2496 if( pData )
2498 ESelection e;
2499 SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
2500 pOutl->QuickInsertField(aField,e);
2501 delete pData;
2504 break;
2507 pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
2509 if( aString.Len() )
2510 pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
2512 ( (SdrTextObj*) pObj)->SetOutlinerParaObject( pOutl->CreateParaObject() );
2514 if (!pOutliner)
2516 delete pOutl;
2517 pOutl = NULL;
2519 else
2521 // Outliner restaurieren
2522 pOutl->Init( nOutlMode );
2523 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2524 pOutl->SetUpdateMode( bUpdateMode );
2525 pOutl->SetPaperSize( aPaperSize );
2530 /*************************************************************************
2532 |* Link & Daten von einem VControl empfangen
2534 \************************************************************************/
2536 void SdPage::SetLinkData(const String&, const String& )
2540 /*************************************************************************
2542 |* Layoutname setzen
2544 \************************************************************************/
2545 void SdPage::SetLayoutName(String aName)
2547 maLayoutName = aName;
2549 if( mbMaster )
2551 String aSep( RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR) );
2552 USHORT nPos = maLayoutName.Search( aSep );
2553 if ( nPos != STRING_NOTFOUND )
2555 FmFormPage::SetName(maLayoutName.Copy(0, nPos));
2561 /*************************************************************************
2563 |* Seitenname zurueckgeben und ggf. generieren
2565 \************************************************************************/
2567 const String& SdPage::GetName() const
2569 String aCreatedPageName( maCreatedPageName );
2570 if (GetRealName().Len() == 0)
2572 if ((mePageKind == PK_STANDARD || mePageKind == PK_NOTES) && !mbMaster)
2574 // default name for handout pages
2575 USHORT nNum = (GetPageNum() + 1) / 2;
2577 aCreatedPageName = String(SdResId(STR_PAGE));
2578 aCreatedPageName += sal_Unicode( ' ' );
2579 if( GetModel()->GetPageNumType() == SVX_NUMBER_NONE )
2581 // if the document has number none as a formating
2582 // for page numbers we still default to arabic numbering
2583 // to keep the default page names unique
2584 aCreatedPageName += String::CreateFromInt32( (sal_Int32)nNum );
2586 else
2588 aCreatedPageName += ((SdDrawDocument*) GetModel())->CreatePageNumValue(nNum);
2591 else
2593 /******************************************************************
2594 * Defaultname fuer Handzettelseiten
2595 ******************************************************************/
2596 aCreatedPageName = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
2599 else
2601 aCreatedPageName = GetRealName();
2604 if (mePageKind == PK_NOTES)
2606 aCreatedPageName += sal_Unicode( ' ' );
2607 aCreatedPageName += String(SdResId(STR_NOTES));
2609 else if (mePageKind == PK_HANDOUT && mbMaster)
2611 aCreatedPageName += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( " (" ));
2612 aCreatedPageName += String(SdResId(STR_HANDOUT));
2613 aCreatedPageName += sal_Unicode( ')' );
2616 const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
2617 return maCreatedPageName;
2621 /*************************************************************************
2625 \************************************************************************/
2627 void SdPage::AdjustBackgroundSize()
2629 SdrObject* pObj = GetPresObj(PRESOBJ_BACKGROUND);
2631 if (pObj)
2633 // Hintergrund-Objekt verschieben
2634 pObj->SetMoveProtect(FALSE);
2635 pObj->SetResizeProtect(FALSE);
2638 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
2640 Point aBackgroundPos;
2641 Size aBackgroundSize( GetSize() );
2643 if( !mbBackgroundFullSize )
2645 aBackgroundPos = Point( GetLftBorder(), GetUppBorder() );
2646 aBackgroundSize.Width() -= GetLftBorder() + GetRgtBorder() - 1;
2647 aBackgroundSize.Height() -= GetUppBorder() + GetLwrBorder() - 1;
2649 Rectangle aBackgroundRect (aBackgroundPos, aBackgroundSize);
2650 pObj->SetLogicRect(aBackgroundRect);
2652 pObj->SetMoveProtect(TRUE);
2653 pObj->SetResizeProtect(TRUE);
2657 /*************************************************************************
2661 \************************************************************************/
2663 void SdPage::SetOrientation( Orientation eOrient)
2665 meOrientation = eOrient;
2668 /*************************************************************************
2672 \************************************************************************/
2674 Orientation SdPage::GetOrientation() const
2676 return meOrientation;
2679 /*************************************************************************
2681 |* Liefert den Default-Text eines PresObjektes zurueck
2683 \************************************************************************/
2685 String SdPage::GetPresObjText(PresObjKind eObjKind) const
2687 String aString;
2689 if (eObjKind == PRESOBJ_TITLE)
2691 if (mbMaster)
2693 if (mePageKind != PK_NOTES)
2695 aString = String ( SdResId( STR_PRESOBJ_MPTITLE ) );
2697 else
2699 aString = String ( SdResId( STR_PRESOBJ_MPNOTESTITLE ) );
2702 else
2704 aString = String ( SdResId( STR_PRESOBJ_TITLE ) );
2707 else if (eObjKind == PRESOBJ_OUTLINE)
2709 if (mbMaster)
2711 aString = String ( SdResId( STR_PRESOBJ_MPOUTLINE ) );
2713 else
2715 aString = String ( SdResId( STR_PRESOBJ_OUTLINE ) );
2718 else if (eObjKind == PRESOBJ_NOTES)
2720 if (mbMaster)
2722 aString = String ( SdResId( STR_PRESOBJ_MPNOTESTEXT ) );
2724 else
2726 aString = String ( SdResId( STR_PRESOBJ_NOTESTEXT ) );
2729 else if (eObjKind == PRESOBJ_TEXT)
2731 aString = String ( SdResId( STR_PRESOBJ_TEXT ) );
2733 else if (eObjKind == PRESOBJ_GRAPHIC)
2735 aString = String ( SdResId( STR_PRESOBJ_GRAPHIC ) );
2737 else if (eObjKind == PRESOBJ_OBJECT)
2739 aString = String ( SdResId( STR_PRESOBJ_OBJECT ) );
2741 else if (eObjKind == PRESOBJ_CHART)
2743 aString = String ( SdResId( STR_PRESOBJ_CHART ) );
2745 else if (eObjKind == PRESOBJ_ORGCHART)
2747 aString = String ( SdResId( STR_PRESOBJ_ORGCHART ) );
2749 else if (eObjKind == PRESOBJ_TABLE)
2751 aString = String ( SdResId( STR_PRESOBJ_TABLE ) );
2754 return(aString);
2757 extern uno::Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage );
2759 uno::Reference< uno::XInterface > SdPage::createUnoPage()
2761 return createUnoPageImpl( this );
2764 /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
2765 SdPage* SdPage::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage )
2769 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( xPage, ::com::sun::star::uno::UNO_QUERY );
2770 if( xUnoTunnel.is() )
2772 SvxDrawPage* pUnoPage = reinterpret_cast<SvxDrawPage*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SvxDrawPage::getUnoTunnelId()) ) );
2773 if( pUnoPage )
2774 return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
2777 catch( ::com::sun::star::uno::Exception& e )
2779 (void)e;
2780 DBG_ERROR("sd::SdPage::getImplementation(), exception cathced!" );
2783 return 0;
2786 void SdPage::SetName (const String& rName)
2788 String aOldName = GetName();
2789 FmFormPage::SetName (rName);
2790 static_cast<SdDrawDocument*>(pModel)->UpdatePageRelativeURLs(aOldName, rName);
2791 ActionChanged();
2794 const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
2796 if( mePageKind == PK_HANDOUT && !mbMaster )
2798 return (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings);
2800 else
2802 return maHeaderFooterSettings;
2806 void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings )
2808 if( mePageKind == PK_HANDOUT && !mbMaster )
2810 (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings) = rNewSettings;
2812 else
2814 maHeaderFooterSettings = rNewSettings;
2817 SetChanged();
2818 if(TRG_HasMasterPage())
2820 TRG_GetMasterPageDescriptorViewContact().ActionChanged();
2824 bool SdPage::checkVisibility(
2825 const sdr::contact::ViewObjectContact& rOriginal,
2826 const sdr::contact::DisplayInfo& rDisplayInfo,
2827 bool bEdit )
2829 if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
2830 return false;
2832 SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2833 if( pObj == NULL )
2834 return false;
2836 const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
2837 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
2838 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
2839 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
2841 // empty presentation objects only visible during edit mode
2842 if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
2844 if( (pObj->GetObjInventor() != SdrInventor) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
2845 return false;
2848 if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) )
2850 const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->GetPage());
2852 if( pCheckPage )
2854 PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
2856 if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
2858 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
2860 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PK_HANDOUT && bIsPrinting ) )
2862 // use the page that is currently processed
2863 const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
2865 if( pVisualizedSdPage )
2867 // if we are not on a masterpage, see if we have to draw this header&footer object at all
2868 const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
2870 switch( eKind )
2872 case PRESOBJ_FOOTER:
2873 return rSettings.mbFooterVisible;
2874 case PRESOBJ_HEADER:
2875 return rSettings.mbHeaderVisible;
2876 case PRESOBJ_DATETIME:
2877 return rSettings.mbDateTimeVisible;
2878 case PRESOBJ_SLIDENUMBER:
2879 return rSettings.mbSlideNumberVisible;
2880 default:
2881 break;
2889 // i63977, do not print SdrpageObjs from master pages
2890 if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) )
2892 if( pObj->GetPage() && pObj->GetPage()->IsMasterPage() )
2893 return false;
2896 return true;
2899 bool SdPage::RestoreDefaultText( SdrObject* pObj )
2901 bool bRet = false;
2903 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
2905 if( pTextObj )
2907 PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
2909 if (ePresObjKind == PRESOBJ_TITLE ||
2910 ePresObjKind == PRESOBJ_OUTLINE ||
2911 ePresObjKind == PRESOBJ_NOTES ||
2912 ePresObjKind == PRESOBJ_TEXT)
2914 String aString( GetPresObjText(ePresObjKind) );
2916 if (aString.Len())
2918 BOOL bVertical = FALSE;
2919 OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
2920 if( pOldPara )
2921 bVertical = pOldPara->IsVertical(); // is old para object vertical?
2923 SetObjText( pTextObj, 0, ePresObjKind, aString );
2925 if( pOldPara )
2927 //pTextObj->SetVerticalWriting( bVertical );
2929 // #94826# Here, only the vertical flag for the
2930 // OutlinerParaObjects needs to be changed. The
2931 // AutoGrowWidth/Height items still exist in the
2932 // not changed object.
2933 if(pTextObj
2934 && pTextObj->GetOutlinerParaObject()
2935 && pTextObj->GetOutlinerParaObject()->IsVertical() != (bool)bVertical)
2937 Rectangle aObjectRect = pTextObj->GetSnapRect();
2938 pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
2939 pTextObj->SetSnapRect(aObjectRect);
2943 pTextObj->SetTextEditOutliner( NULL ); // to make stylesheet settings work
2944 pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), TRUE );
2945 pTextObj->SetEmptyPresObj(TRUE);
2946 bRet = true;
2950 return bRet;
2953 void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< Rectangle >& rAreas )
2955 SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PK_HANDOUT );
2957 Size aArea = rHandoutMaster.GetSize();
2959 const long nGapW = 1000; // gap is 1cm
2960 const long nGapH = 1000;
2962 long nLeftBorder = rHandoutMaster.GetLftBorder();
2963 long nRightBorder = rHandoutMaster.GetRgtBorder();
2964 long nTopBorder = rHandoutMaster.GetUppBorder();
2965 long nBottomBorder = rHandoutMaster.GetLwrBorder();
2967 const long nHeaderFooterHeight = static_cast< long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05 );
2969 nTopBorder += nHeaderFooterHeight;
2970 nBottomBorder += nHeaderFooterHeight;
2972 long nX = nGapW + nLeftBorder;
2973 long nY = nGapH + nTopBorder;
2975 aArea.Width() -= nGapW * 2 + nLeftBorder + nRightBorder;
2976 aArea.Height() -= nGapH * 2 + nTopBorder + nBottomBorder;
2978 const bool bLandscape = aArea.Width() > aArea.Height();
2980 static sal_uInt16 aOffsets[5][9] =
2982 { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
2983 { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
2984 { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
2985 { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
2986 { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
2989 sal_uInt16* pOffsets = aOffsets[0];
2990 USHORT nColCnt = 0, nRowCnt = 0;
2991 switch ( eLayout )
2993 case AUTOLAYOUT_HANDOUT1:
2994 nColCnt = 1; nRowCnt = 1;
2995 break;
2997 case AUTOLAYOUT_HANDOUT2:
2998 if( bLandscape )
3000 nColCnt = 2; nRowCnt = 1;
3002 else
3004 nColCnt = 1; nRowCnt = 2;
3006 break;
3008 case AUTOLAYOUT_HANDOUT3:
3009 if( bLandscape )
3011 nColCnt = 3; nRowCnt = 2;
3013 else
3015 nColCnt = 2; nRowCnt = 3;
3017 pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
3018 break;
3020 case AUTOLAYOUT_HANDOUT4:
3021 nColCnt = 2; nRowCnt = 2;
3022 pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
3023 break;
3025 case AUTOLAYOUT_HANDOUT6:
3026 if( bLandscape )
3028 nColCnt = 3; nRowCnt = 2;
3030 else
3032 nColCnt = 2; nRowCnt = 3;
3034 if( !bHorizontal )
3035 pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
3036 break;
3038 default:
3039 case AUTOLAYOUT_HANDOUT9:
3040 nColCnt = 3; nRowCnt = 3;
3042 if( !bHorizontal )
3043 pOffsets = aOffsets[4];
3044 break;
3047 rAreas.resize( nColCnt * nRowCnt );
3049 Size aPartArea, aSize;
3050 aPartArea.Width() = ((aArea.Width() - ((nColCnt-1) * nGapW) ) / nColCnt);
3051 aPartArea.Height() = ((aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt);
3053 SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PK_STANDARD);
3054 if ( pFirstPage )
3056 // scale actual size into handout rect
3057 double fScale = (double)aPartArea.Width() / (double)pFirstPage->GetWdt();
3059 aSize.Height() = (long)(fScale * pFirstPage->GetHgt() );
3060 if( aSize.Height() > aPartArea.Height() )
3062 fScale = (double)aPartArea.Height() / (double)pFirstPage->GetHgt();
3063 aSize.Height() = aPartArea.Height();
3064 aSize.Width() = (long)(fScale * pFirstPage->GetWdt());
3066 else
3068 aSize.Width() = aPartArea.Width();
3071 nX += (aPartArea.Width() - aSize.Width()) / 2;
3072 nY += (aPartArea.Height()- aSize.Height())/ 2;
3074 else
3076 aSize = aPartArea;
3079 Point aPos( nX, nY );
3081 const bool bRTL = rModel.GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB;
3083 const long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
3084 const long nOffsetY = aPartArea.Height() + nGapH;
3085 const long nStartX = bRTL ? nOffsetX*(1 - nColCnt) - nX : nX;
3087 for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
3089 aPos.X() = nStartX;
3090 for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
3092 rAreas[*pOffsets++] = Rectangle(aPos, aSize);
3093 aPos.X() += nOffsetX;
3096 aPos.Y() += nOffsetY;
3103 void SdPage::SetPrecious (const bool bIsPrecious)
3105 mbIsPrecious = bIsPrecious;
3111 bool SdPage::IsPrecious (void) const
3113 return mbIsPrecious;
3119 HeaderFooterSettings::HeaderFooterSettings()
3121 mbHeaderVisible = true;
3122 mbFooterVisible = true;
3123 mbSlideNumberVisible = false;
3124 mbDateTimeVisible = true;
3125 mbDateTimeIsFixed = true;
3126 meDateTimeFormat = SVXDATEFORMAT_A;
3129 bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
3131 return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
3132 (maHeaderText == rSettings.maHeaderText) &&
3133 (mbFooterVisible == rSettings.mbFooterVisible) &&
3134 (maFooterText == rSettings.maFooterText) &&
3135 (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
3136 (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
3137 (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
3138 (meDateTimeFormat == rSettings.meDateTimeFormat) &&
3139 (maDateTimeText == rSettings.maDateTimeText);