update credits
[LibreOffice.git] / sd / source / core / sdpage.cxx
blob48d5662270f662e5f31425d43f4fd88259278f01
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <algorithm>
23 #include <comphelper/classids.hxx>
25 #include <vcl/svapp.hxx>
26 #include <editeng/outliner.hxx>
27 #include <editeng/eeitem.hxx>
28 #include <svx/svdoutl.hxx>
29 #include <editeng/editdata.hxx>
30 #include <svx/pageitem.hxx>
31 #include <editeng/lrspitem.hxx>
32 #include <editeng/bulletitem.hxx>
33 #include <svx/svdpagv.hxx>
34 #include <editeng/fhgtitem.hxx>
35 #include <editeng/outlobj.hxx>
36 #include <svx/svdoole2.hxx>
37 #include <svx/svdograf.hxx>
38 #include <svx/svdopage.hxx>
39 #include <sfx2/printer.hxx>
40 #include <basic/basmgr.hxx>
41 #include <editeng/pbinitem.hxx>
42 #include <svx/svdundo.hxx>
43 #include <svl/smplhint.hxx>
44 #include <editeng/adjustitem.hxx>
45 #include <editeng/editobj.hxx>
46 #include <editeng/scripttypeitem.hxx>
47 #include <svx/unopage.hxx>
48 #include <editeng/flditem.hxx>
49 #include <svx/sdr/contact/displayinfo.hxx>
50 #include <svx/svditer.hxx>
52 #include "../ui/inc/DrawDocShell.hxx"
53 #include "Outliner.hxx"
54 #include "app.hrc"
55 #include "drawdoc.hxx"
56 #include "sdpage.hxx"
57 #include "pglink.hxx"
58 #include "sdresid.hxx"
59 #include "stlsheet.hxx"
60 #include "glob.hrc"
61 #include "glob.hxx"
62 #include "helpids.h"
63 #include "anminfo.hxx"
64 #include "undo/undomanager.hxx"
65 #include "undo/undoobjects.hxx"
66 #include <svx/sdr/contact/viewobjectcontact.hxx>
67 #include <svx/sdr/contact/viewcontact.hxx>
68 #include <svx/sdr/contact/objectcontact.hxx>
69 #include <svx/unoapi.hxx>
71 #include <set>
73 using namespace ::sd;
74 using namespace ::com::sun::star;
76 TYPEINIT2( SdPage, FmFormPage, SdrObjUserCall );
78 /*************************************************************************
80 |* Ctor
82 \************************************************************************/
84 SdPage::SdPage(SdDrawDocument& rNewDoc, StarBASIC* pBasic, sal_Bool bMasterPage)
85 : FmFormPage(rNewDoc, pBasic, bMasterPage)
86 , SdrObjUserCall()
87 , mePageKind(PK_STANDARD)
88 , meAutoLayout(AUTOLAYOUT_NONE)
89 , mbSelected(sal_False)
90 , mePresChange(PRESCHANGE_MANUAL)
91 , mfTime(1.0)
92 , mbSoundOn(sal_False)
93 , mbExcluded(sal_False)
94 , mbLoopSound(sal_False)
95 , mbStopSound(sal_False)
96 , mbScaleObjects(sal_True)
97 , mbBackgroundFullSize( sal_False )
98 , meCharSet(osl_getThreadTextEncoding())
99 , mnPaperBin(PAPERBIN_PRINTER_SETTINGS)
100 , mpPageLink(NULL)
101 , mpItems(NULL)
102 , mnTransitionType(0)
103 , mnTransitionSubtype(0)
104 , mbTransitionDirection(sal_True)
105 , mnTransitionFadeColor(0)
106 , mfTransitionDuration(2.0)
107 , mbIsPrecious(true)
109 // The name of the layout of the page is used by SVDRAW to determine the
110 // presentation template of the outline objects. Therefore, it already
111 // contains the designator for the outline (STR_LAYOUT_OUTLINE).
112 OUStringBuffer aBuf(SdResId(STR_LAYOUT_DEFAULT_NAME).toString());
113 aBuf.append(SD_LT_SEPARATOR).append(SdResId(STR_LAYOUT_OUTLINE).toString());
114 maLayoutName = aBuf.makeStringAndClear();
116 Size aPageSize(GetSize());
118 if (aPageSize.Width() > aPageSize.Height())
120 meOrientation = ORIENTATION_LANDSCAPE;
122 else
124 meOrientation = ORIENTATION_PORTRAIT;
128 /*************************************************************************
130 |* Dtor
132 \************************************************************************/
134 SdPage::~SdPage()
136 DisconnectLink();
138 EndListenOutlineText();
140 if( mpItems )
141 delete mpItems;
144 struct OrdNumSorter
146 bool operator()( SdrObject* p1, SdrObject* p2 )
148 return p1->GetOrdNum() < p2->GetOrdNum();
152 /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
153 SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ )
155 // first sort all matching shapes with z-order
156 std::vector< SdrObject* > aMatches;
158 SdrObject* pObj = 0;
159 while( (pObj = maPresentationShapeList.getNextShape(pObj)) != 0 )
161 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
162 if( pInfo )
164 bool bFound = false;
165 if( pInfo->mePresObjKind == eObjKind )
167 bFound = true;
169 else if( bFuzzySearch && (eObjKind == PRESOBJ_OUTLINE) )
171 switch( pInfo->mePresObjKind )
173 case PRESOBJ_GRAPHIC:
174 case PRESOBJ_OBJECT:
175 case PRESOBJ_CHART:
176 case PRESOBJ_ORGCHART:
177 case PRESOBJ_TABLE:
178 case PRESOBJ_CALC:
179 case PRESOBJ_IMAGE:
180 case PRESOBJ_MEDIA:
181 bFound = sal_True;
182 break;
183 default:
184 break;
187 if( bFound )
189 aMatches.push_back( pObj );
194 if( aMatches.size() > 1 )
196 OrdNumSorter aSortHelper;
197 std::sort( aMatches.begin(), aMatches.end(), aSortHelper );
200 if( nIndex > 0 )
201 nIndex--;
203 if( (nIndex >= 0) && ( aMatches.size() > static_cast<unsigned int>(nIndex)) )
204 return aMatches[nIndex];
206 return 0;
209 /** create background properties */
210 void SdPage::EnsureMasterPageDefaultBackground()
212 if(mbMaster)
214 // no hard attributes on MasterPage attributes
215 getSdrPageProperties().ClearItem();
216 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForMasterPageBackground();
218 if(pSheetForPresObj)
220 // set StyleSheet for background fill attributes
221 getSdrPageProperties().SetStyleSheet(pSheetForPresObj);
223 else
225 // no style found, assert and set at least XFILL_NONE
226 OSL_FAIL("No Style for MasterPageBackground fill found (!)");
227 getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE));
232 /** creates a presentation object with the given PresObjKind on this page. A user call will be set
234 SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, sal_Bool bVertical, const Rectangle& rRect, sal_Bool /* bInsert */ )
236 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
237 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
239 SdrObject* pSdrObj = NULL;
241 bool bForceText = false; // forces the shape text to be set even if its empty
242 bool bEmptyPresObj = true;
244 switch( eObjKind )
246 case PRESOBJ_TITLE:
248 pSdrObj = new SdrRectObj(OBJ_TITLETEXT);
250 if (mbMaster)
252 pSdrObj->SetNotVisibleAsMaster(sal_True);
255 break;
257 case PRESOBJ_OUTLINE:
259 pSdrObj = new SdrRectObj(OBJ_OUTLINETEXT);
261 if (mbMaster)
263 pSdrObj->SetNotVisibleAsMaster(sal_True);
266 break;
268 case PRESOBJ_NOTES:
270 pSdrObj = new SdrRectObj(OBJ_TEXT);
272 if (mbMaster)
274 pSdrObj->SetNotVisibleAsMaster(sal_True);
277 break;
279 case PRESOBJ_TEXT:
281 pSdrObj = new SdrRectObj(OBJ_TEXT);
283 break;
285 case PRESOBJ_GRAPHIC:
287 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_GRAPHIC ) );
288 Graphic aGraphic( aBmpEx );
289 OutputDevice &aOutDev = *Application::GetDefaultDevice();
290 aOutDev.Push();
292 aOutDev.SetMapMode( aGraphic.GetPrefMapMode() );
293 Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() );
294 aOutDev.SetMapMode(MAP_100TH_MM);
296 Size aSize = aOutDev.PixelToLogic(aSizePix);
297 Point aPnt (0, 0);
298 Rectangle aRect (aPnt, aSize);
299 pSdrObj = new SdrGrafObj(aGraphic, aRect);
300 aOutDev.Pop();
302 break;
304 case PRESOBJ_MEDIA:
305 case PRESOBJ_OBJECT:
307 pSdrObj = new SdrOle2Obj();
308 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_OBJECT ) );
309 Graphic aGraphic( aBmpEx );
310 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
312 break;
314 case PRESOBJ_CHART:
316 pSdrObj = new SdrOle2Obj();
317 ( (SdrOle2Obj*) pSdrObj)->SetProgName( OUString( "StarChart" ) );
318 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_CHART ) );
319 Graphic aGraphic( aBmpEx );
320 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
322 break;
324 case PRESOBJ_ORGCHART:
326 pSdrObj = new SdrOle2Obj();
327 ( (SdrOle2Obj*) pSdrObj)->SetProgName( OUString( "StarOrg" ) );
328 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_ORGCHART ) );
329 Graphic aGraphic( aBmpEx );
330 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
332 break;
334 case PRESOBJ_TABLE:
335 case PRESOBJ_CALC:
337 pSdrObj = new SdrOle2Obj();
338 ( (SdrOle2Obj*) pSdrObj)->SetProgName( OUString( "StarCalc" ) );
339 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_TABLE ) );
340 Graphic aGraphic( aBmpEx );
341 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic);
343 break;
345 case PRESOBJ_HANDOUT:
347 // Save the first standard page at SdrPageObj
348 // #i105146# We want no content to be displayed for PK_HANDOUT,
349 // so just never set a page as content
350 pSdrObj = new SdrPageObj(0);
352 break;
354 case PRESOBJ_PAGE:
356 // Save note pages at SdrPageObj
357 sal_uInt16 nDestPageNum(GetPageNum());
359 if(nDestPageNum)
361 // decrement only when != 0, else we get a 0xffff
362 nDestPageNum -= 1;
365 if(nDestPageNum < pModel->GetPageCount())
367 pSdrObj = new SdrPageObj(pModel->GetPage(nDestPageNum));
369 else
371 pSdrObj = new SdrPageObj();
374 pSdrObj->SetResizeProtect(sal_True);
376 break;
378 case PRESOBJ_HEADER:
379 case PRESOBJ_FOOTER:
380 case PRESOBJ_DATETIME:
381 case PRESOBJ_SLIDENUMBER:
383 pSdrObj = new SdrRectObj(OBJ_TEXT);
384 bEmptyPresObj = false;
385 bForceText = true;
387 break;
388 default:
389 break;
392 if (pSdrObj)
394 pSdrObj->SetEmptyPresObj(bEmptyPresObj);
395 pSdrObj->SetLogicRect(rRect);
397 InsertObject(pSdrObj);
399 if ( pSdrObj->ISA(SdrTextObj) )
401 // Tell the object EARLY that it is vertical to have the
402 // defaults for AutoGrowWidth/Height reversed
403 if(bVertical)
404 ((SdrTextObj*)pSdrObj)->SetVerticalWriting(sal_True);
406 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
407 if( bVertical )
408 aTempAttr.Put( SdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
409 else
410 aTempAttr.Put( SdrTextMinFrameHeightItem( rRect.GetSize().Height() ) );
412 if (mbMaster)
414 // The size of presentation objects on the master page have to
415 // be freely selectable by the user.
417 // potential problem: This action was still NOT
418 // adapted for vertical text. This sure needs to be done.
419 if(bVertical)
420 aTempAttr.Put(SdrTextAutoGrowWidthItem(sal_False));
421 else
422 aTempAttr.Put(SdrTextAutoGrowHeightItem(sal_False));
425 // check if we need another vertical adjustement than the default
426 SdrTextVertAdjust eV = SDRTEXTVERTADJUST_TOP;
428 if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind != PK_STANDARD) )
430 eV = SDRTEXTVERTADJUST_BOTTOM;
432 else if( (eObjKind == PRESOBJ_SLIDENUMBER) && (mePageKind != PK_STANDARD) )
434 eV = SDRTEXTVERTADJUST_BOTTOM;
437 if( eV != SDRTEXTVERTADJUST_TOP )
438 aTempAttr.Put(SdrTextVertAdjustItem(eV));
440 pSdrObj->SetMergedItemSet(aTempAttr);
442 pSdrObj->SetLogicRect(rRect);
445 String aString = GetPresObjText(eObjKind);
446 if( (aString.Len() || bForceText) && pSdrObj->ISA(SdrTextObj) )
448 SdrOutliner* pOutliner = ( (SdDrawDocument*) GetModel() )->GetInternalOutliner();
450 sal_uInt16 nOutlMode = pOutliner->GetMode();
451 pOutliner->Init( OUTLINERMODE_TEXTOBJECT );
452 pOutliner->SetStyleSheet( 0, NULL );
453 pOutliner->SetVertical( bVertical );
455 SetObjText( (SdrTextObj*) pSdrObj, (SdrOutliner*)pOutliner, eObjKind, aString );
457 pOutliner->Init( nOutlMode );
458 pOutliner->SetStyleSheet( 0, NULL );
461 if( (eObjKind == PRESOBJ_HEADER) || (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_DATETIME) )
463 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
464 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
465 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
466 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
468 SvxAdjust eH = SVX_ADJUST_LEFT;
470 if( (eObjKind == PRESOBJ_DATETIME) && (mePageKind != PK_STANDARD ) )
472 eH = SVX_ADJUST_RIGHT;
474 else if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind == PK_STANDARD ) )
476 eH = SVX_ADJUST_CENTER;
478 else if( eObjKind == PRESOBJ_SLIDENUMBER )
480 eH = SVX_ADJUST_RIGHT;
483 if( eH != SVX_ADJUST_LEFT )
484 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST ));
486 pSdrObj->SetMergedItemSet(aTempAttr);
489 if (mbMaster)
491 SdrLayerAdmin& rLayerAdmin = pModel->GetLayerAdmin();
493 // background objects of the master page
494 pSdrObj->SetLayer( rLayerAdmin.
495 GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False) );
498 // Subscribe object at the style sheet
499 // Set style only when one was found (as in 5.2)
500 if( mePageKind != PK_HANDOUT )
502 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind);
503 if(pSheetForPresObj)
504 pSdrObj->SetStyleSheet(pSheetForPresObj, sal_False);
507 if (eObjKind == PRESOBJ_OUTLINE)
509 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
511 String aName(maLayoutName);
512 aName += sal_Unicode( ' ' );
513 aName += OUString::number( nLevel );
514 SfxStyleSheet* pSheet = (SfxStyleSheet*)pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
515 DBG_ASSERT(pSheet, "StyleSheet for outline object not found");
516 if (pSheet)
517 pSdrObj->StartListening(*pSheet);
521 if ( eObjKind == PRESOBJ_OBJECT ||
522 eObjKind == PRESOBJ_CHART ||
523 eObjKind == PRESOBJ_ORGCHART ||
524 eObjKind == PRESOBJ_CALC ||
525 eObjKind == PRESOBJ_GRAPHIC )
527 SfxItemSet aSet( ((SdDrawDocument*) pModel)->GetPool() );
528 aSet.Put( SdrTextContourFrameItem( sal_True ) );
529 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
531 pSdrObj->SetMergedItemSet(aSet);
534 if( bUndo )
536 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
539 if( bUndo )
541 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pSdrObj ) );
542 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pSdrObj) );
545 InsertPresObj(pSdrObj, eObjKind);
546 pSdrObj->SetUserCall(this);
548 pSdrObj->RecalcBoundRect();
551 return(pSdrObj);
554 /*************************************************************************
556 |* Creates presentation objects on the master page.
557 |* All presentation objects get a UserCall to the page.
559 \************************************************************************/
561 SfxStyleSheet* SdPage::GetStyleSheetForMasterPageBackground() const
563 String aName(GetLayoutName());
564 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
565 sal_uInt16 nPos = aName.Search(aSep);
567 if (nPos != STRING_NOTFOUND)
569 nPos = nPos + aSep.Len();
570 aName.Erase(nPos);
573 aName += String(SdResId(STR_LAYOUT_BACKGROUND));
575 SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
576 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
577 return (SfxStyleSheet*)pResult;
580 SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const
582 String aName(GetLayoutName());
583 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
584 sal_uInt16 nPos = aName.Search(aSep);
585 if (nPos != STRING_NOTFOUND)
587 nPos = nPos + aSep.Len();
588 aName.Erase(nPos);
591 switch (eObjKind)
593 case PRESOBJ_OUTLINE:
595 aName = GetLayoutName();
596 aName += sal_Unicode( ' ' );
597 aName += OUString::number( 1 );
599 break;
601 case PRESOBJ_TITLE:
602 aName += String(SdResId(STR_LAYOUT_TITLE));
603 break;
605 case PRESOBJ_NOTES:
606 aName += String(SdResId(STR_LAYOUT_NOTES));
607 break;
609 case PRESOBJ_TEXT:
610 aName += String(SdResId(STR_LAYOUT_SUBTITLE));
611 break;
613 case PRESOBJ_HEADER:
614 case PRESOBJ_FOOTER:
615 case PRESOBJ_DATETIME:
616 case PRESOBJ_SLIDENUMBER:
617 aName += String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
618 break;
620 default:
621 break;
624 SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
625 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
626 return (SfxStyleSheet*)pResult;
629 /** returns the presentation style with the given helpid from this masterpage or this
630 slides masterpage */
631 SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
633 String aStyleName( pPage->GetLayoutName() );
634 const String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ));
635 aStyleName.Erase(aStyleName.Search(aSep) + aSep.Len());
637 sal_uInt16 nNameId;
638 switch( nHelpId )
640 case HID_PSEUDOSHEET_TITLE: nNameId = STR_LAYOUT_TITLE; break;
641 case HID_PSEUDOSHEET_SUBTITLE: nNameId = STR_LAYOUT_SUBTITLE; break;
642 case HID_PSEUDOSHEET_OUTLINE1:
643 case HID_PSEUDOSHEET_OUTLINE2:
644 case HID_PSEUDOSHEET_OUTLINE3:
645 case HID_PSEUDOSHEET_OUTLINE4:
646 case HID_PSEUDOSHEET_OUTLINE5:
647 case HID_PSEUDOSHEET_OUTLINE6:
648 case HID_PSEUDOSHEET_OUTLINE7:
649 case HID_PSEUDOSHEET_OUTLINE8:
650 case HID_PSEUDOSHEET_OUTLINE9: nNameId = STR_LAYOUT_OUTLINE; break;
651 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: nNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break;
652 case HID_PSEUDOSHEET_BACKGROUND: nNameId = STR_LAYOUT_BACKGROUND; break;
653 case HID_PSEUDOSHEET_NOTES: nNameId = STR_LAYOUT_NOTES; break;
655 default:
656 OSL_FAIL( "SdPage::getPresentationStyle(), illegal argument!" );
657 return 0;
659 aStyleName.Append( String( SdResId( nNameId ) ) );
660 if( nNameId == STR_LAYOUT_OUTLINE )
662 aStyleName.Append( sal_Unicode( ' ' ));
663 aStyleName.Append( OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE )));
666 SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
667 SfxStyleSheetBase* pResult = pStShPool->Find(aStyleName, SD_STYLE_FAMILY_MASTERPAGE);
668 return dynamic_cast<SdStyleSheet*>(pResult);
671 /*************************************************************************
673 |* The presentation object rObj has changed and is no longer referenzed by the
674 |* presentation object of the master page.
675 |* The UserCall is deleted.
677 \************************************************************************/
679 void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& )
681 if (!maLockAutoLayoutArrangement.isLocked())
683 switch (eType)
685 case SDRUSERCALL_MOVEONLY:
686 case SDRUSERCALL_RESIZE:
688 if( pModel->isLocked() )
689 break;
691 SdrObject* pObj = (SdrObject*) &rObj;
693 if (pObj)
695 if (!mbMaster)
697 if( pObj->GetUserCall() )
699 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
700 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
702 if( bUndo )
703 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pObj) );
705 // Objekt was resized by user and does not listen to its slide anymore
706 pObj->SetUserCall(0);
709 else if (pModel)
711 // Object of the master page changed, therefore adjust
712 // object on all pages
713 sal_uInt16 nPageCount = ((SdDrawDocument*) pModel)->GetSdPageCount(mePageKind);
715 for (sal_uInt16 i = 0; i < nPageCount; i++)
717 SdPage* pLoopPage = ((SdDrawDocument*) pModel)->GetSdPage(i, mePageKind);
719 if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
721 // Page listens to this master page, therefore
722 // adjust AutoLayout
723 pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
729 break;
731 case SDRUSERCALL_DELETE:
732 case SDRUSERCALL_REMOVED:
733 default:
734 break;
739 /*************************************************************************
741 |* Creates on a master page: background, title- and layout area
743 \************************************************************************/
745 void SdPage::CreateTitleAndLayout(sal_Bool bInit, sal_Bool bCreate )
747 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
748 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
750 SdPage* pMasterPage = this;
752 if (!mbMaster)
754 pMasterPage = (SdPage*)(&(TRG_GetMasterPage()));
757 if (!pMasterPage)
759 return;
762 /**************************************************************************
763 * create background, title- and layout area
764 **************************************************************************/
765 if( mePageKind == PK_STANDARD )
767 pMasterPage->EnsureMasterPageDefaultBackground();
770 if( ( (SdDrawDocument*) GetModel() )->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
772 if( mePageKind == PK_HANDOUT && bInit )
774 // handout template
776 // delete all available handout presentation objects
777 SdrObject *pObj=NULL;
778 while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != 0 )
780 pMasterPage->RemoveObject(pObj->GetOrdNum());
782 if( bUndo )
784 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
786 else
788 SdrObject::Free( pObj );
792 std::vector< Rectangle > aAreas;
793 CalculateHandoutAreas( *static_cast< SdDrawDocument* >(GetModel() ), pMasterPage->GetAutoLayout(), false, aAreas );
795 const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
796 std::vector< Rectangle >::iterator iter( aAreas.begin() );
798 while( iter != aAreas.end() )
800 SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, sal_False, (*iter++), sal_True) );
801 // #i105146# We want no content to be displayed for PK_HANDOUT,
802 // so just never set a page as content
803 pPageObj->SetReferencedPage(0L);
805 if( bSkip && iter != aAreas.end() )
806 ++iter;
810 if( mePageKind != PK_HANDOUT )
812 SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE );
813 if( pMasterTitle == NULL )
814 pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE, true);
816 SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
817 if( pMasterOutline == NULL )
818 pMasterPage->CreateDefaultPresObj( mePageKind == PK_STANDARD ? PRESOBJ_OUTLINE : PRESOBJ_NOTES, true );
821 // create header&footer objects
823 if( bCreate )
825 if( mePageKind != PK_STANDARD )
827 SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER );
828 if( pHeader == NULL )
829 pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER, true );
832 SdrObject* pDate = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
833 if( pDate == NULL )
834 pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME, true );
836 SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
837 if( pFooter == NULL )
838 pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER, true );
840 SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
841 if( pNumber == NULL )
842 pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER, true );
847 SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
849 if( eObjKind == PRESOBJ_TITLE )
851 Rectangle aTitleRect( GetTitleRect() );
852 return CreatePresObj(PRESOBJ_TITLE, sal_False, aTitleRect, bInsert);
854 else if( eObjKind == PRESOBJ_OUTLINE )
856 Rectangle aLayoutRect( GetLayoutRect() );
857 return CreatePresObj( PRESOBJ_OUTLINE, sal_False, aLayoutRect, bInsert);
859 else if( eObjKind == PRESOBJ_NOTES )
861 Rectangle aLayoutRect( GetLayoutRect() );
862 return CreatePresObj( PRESOBJ_NOTES, sal_False, aLayoutRect, bInsert);
864 else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) )
866 // create footer objects for standard master page
867 if( mePageKind == PK_STANDARD )
869 const long nLftBorder = GetLftBorder();
870 const long nUppBorder = GetUppBorder();
872 Size aPageSize ( GetSize() );
873 aPageSize.Width() -= nLftBorder + GetRgtBorder();
874 aPageSize.Height() -= nUppBorder + GetLwrBorder();
876 const int Y = long(nUppBorder + aPageSize.Height() * 0.911);
877 const int W1 = long(aPageSize.Width() * 0.233);
878 const int W2 = long(aPageSize.Width() * 0.317);
879 const int H = long(aPageSize.Height() * 0.069);
881 if( eObjKind == PRESOBJ_DATETIME )
883 Point aPos( long(nLftBorder+(aPageSize.Width()*0.05)), Y );
884 Size aSize( W1, H );
885 Rectangle aRect( aPos, aSize );
886 return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert );
888 else if( eObjKind == PRESOBJ_FOOTER )
890 Point aPos( long(nLftBorder+ aPageSize.Width() * 0.342), Y );
891 Size aSize( W2, H );
892 Rectangle aRect( aPos, aSize );
893 return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert );
895 else if( eObjKind == PRESOBJ_SLIDENUMBER )
897 Point aPos( long(nLftBorder+(aPageSize.Width()*0.717)), Y );
898 Size aSize( W1, H );
899 Rectangle aRect( aPos, aSize );
900 return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert );
902 else
904 OSL_FAIL( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a slide master" );
905 return NULL;
908 else
910 // create header&footer objects for handout and notes master
911 Size aPageSize ( GetSize() );
912 aPageSize.Width() -= GetLftBorder() + GetRgtBorder();
913 aPageSize.Height() -= GetUppBorder() + GetLwrBorder();
916 const int NOTES_HEADER_FOOTER_WIDTH = long(aPageSize.Width() * 0.434);
917 const int NOTES_HEADER_FOOTER_HEIGHT = long(aPageSize.Height() * 0.05);
919 Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
921 const int X1 = GetLftBorder();
922 const int X2 = GetLftBorder() + long(aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH);
923 const int Y1 = GetUppBorder();
924 const int Y2 = GetUppBorder() + long(aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT );
926 if( eObjKind == PRESOBJ_HEADER )
928 Point aPos( X1, Y1 );
929 Rectangle aRect( aPos, aSize );
930 return CreatePresObj( PRESOBJ_HEADER, sal_False, aRect, bInsert );
932 else if( eObjKind == PRESOBJ_DATETIME )
934 Point aPos( X2, Y1 );
935 Rectangle aRect( aPos, aSize );
936 return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert );
938 else if( eObjKind == PRESOBJ_FOOTER )
940 Point aPos( X1, Y2 );
941 Rectangle aRect( aPos, aSize );
942 return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert );
944 else if( eObjKind == PRESOBJ_SLIDENUMBER )
946 Point aPos( X2, Y2 );
947 Rectangle aRect( aPos, aSize );
948 return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert );
951 OSL_FAIL("SdPage::CreateDefaultPresObj() - this should not happen!");
952 return NULL;
955 else
957 OSL_FAIL("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
958 return NULL;
962 /*************************************************************************
964 |* return title area
966 \************************************************************************/
968 Rectangle SdPage::GetTitleRect() const
970 Rectangle aTitleRect;
972 if (mePageKind != PK_HANDOUT)
974 /******************************************************************
975 * standard- or note page: title area
976 ******************************************************************/
977 Point aTitlePos ( GetLftBorder(), GetUppBorder() );
978 Size aTitleSize ( GetSize() );
979 aTitleSize.Width() -= GetLftBorder() + GetRgtBorder();
980 aTitleSize.Height() -= GetUppBorder() + GetLwrBorder();
982 if (mePageKind == PK_STANDARD)
984 aTitlePos.X() += long( aTitleSize.Width() * 0.05 );
985 aTitlePos.Y() += long( aTitleSize.Height() * 0.0399 );
986 aTitleSize.Width() = long( aTitleSize.Width() * 0.9 );
987 aTitleSize.Height() = long( aTitleSize.Height() * 0.167 );
989 else if (mePageKind == PK_NOTES)
991 Point aPos = aTitlePos;
992 aPos.Y() += long( aTitleSize.Height() * 0.076 );
994 // limit height
995 aTitleSize.Height() = (long) (aTitleSize.Height() * 0.375);
997 Size aPartArea = aTitleSize;
998 Size aSize;
999 sal_uInt16 nDestPageNum(GetPageNum());
1000 SdrPage* pRefPage = 0L;
1002 if(nDestPageNum)
1004 // only decrement if != 0, else we get 0xffff
1005 nDestPageNum -= 1;
1008 if(nDestPageNum < pModel->GetPageCount())
1010 pRefPage = pModel->GetPage(nDestPageNum);
1013 if ( pRefPage )
1015 // scale actually page size into handout rectangle
1016 double fH = (double) aPartArea.Width() / pRefPage->GetWdt();
1017 double fV = (double) aPartArea.Height() / pRefPage->GetHgt();
1019 if ( fH > fV )
1020 fH = fV;
1021 aSize.Width() = (long) (fH * pRefPage->GetWdt());
1022 aSize.Height() = (long) (fH * pRefPage->GetHgt());
1024 aPos.X() += (aPartArea.Width() - aSize.Width()) / 2;
1025 aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2;
1028 aTitlePos = aPos;
1029 aTitleSize = aSize;
1032 aTitleRect.SetPos(aTitlePos);
1033 aTitleRect.SetSize(aTitleSize);
1036 return aTitleRect;
1040 /*************************************************************************
1042 |* return outline area
1044 \************************************************************************/
1046 Rectangle SdPage::GetLayoutRect() const
1048 Rectangle aLayoutRect;
1050 if (mePageKind != PK_HANDOUT)
1052 Point aLayoutPos ( GetLftBorder(), GetUppBorder() );
1053 Size aLayoutSize ( GetSize() );
1054 aLayoutSize.Width() -= GetLftBorder() + GetRgtBorder();
1055 aLayoutSize.Height() -= GetUppBorder() + GetLwrBorder();
1057 if (mePageKind == PK_STANDARD)
1059 aLayoutPos.X() += long( aLayoutSize.Width() * 0.05 );
1060 aLayoutPos.Y() += long( aLayoutSize.Height() * 0.234 );
1061 aLayoutSize.Width() = long( aLayoutSize.Width() * 0.9 );
1062 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.58 );
1063 aLayoutRect.SetPos(aLayoutPos);
1064 aLayoutRect.SetSize(aLayoutSize);
1066 else if (mePageKind == PK_NOTES)
1068 aLayoutPos.X() += long( aLayoutSize.Width() * 0.1 );
1069 aLayoutPos.Y() += long( aLayoutSize.Height() * 0.475 );
1070 aLayoutSize.Width() = long( aLayoutSize.Width() * 0.8 );
1071 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.45 );
1072 aLayoutRect.SetPos(aLayoutPos);
1073 aLayoutRect.SetSize(aLayoutSize);
1077 return aLayoutRect;
1081 /**************************************************************************
1083 |* assign a AutoLayout
1085 \*************************************************************************/
1087 const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout
1088 const int VERTICAL = 0x8000;
1090 struct LayoutDescriptor
1092 int mnLayout;
1093 PresObjKind meKind[MAX_PRESOBJS];
1094 bool mbVertical[MAX_PRESOBJS];
1096 LayoutDescriptor( int nLayout, int k0 = 0, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0, int k5 = 0, int k6 = 0 );
1099 LayoutDescriptor::LayoutDescriptor( int nLayout, int k0, int k1, int k2, int k3, int k4, int k5, int k6 )
1100 : mnLayout( nLayout )
1102 meKind[0] = static_cast<PresObjKind>(k0 & (~VERTICAL)); mbVertical[0] = (k0 & VERTICAL) == VERTICAL;
1103 meKind[1] = static_cast<PresObjKind>(k1 & (~VERTICAL)); mbVertical[1] = (k1 & VERTICAL) == VERTICAL;
1104 meKind[2] = static_cast<PresObjKind>(k2 & (~VERTICAL)); mbVertical[2] = (k2 & VERTICAL) == VERTICAL;
1105 meKind[3] = static_cast<PresObjKind>(k3 & (~VERTICAL)); mbVertical[3] = (k3 & VERTICAL) == VERTICAL;
1106 meKind[4] = static_cast<PresObjKind>(k4 & (~VERTICAL)); mbVertical[4] = (k4 & VERTICAL) == VERTICAL;
1107 meKind[5] = static_cast<PresObjKind>(k5 & (~VERTICAL)); mbVertical[5] = (k5 & VERTICAL) == VERTICAL;
1108 meKind[6] = static_cast<PresObjKind>(k6 & (~VERTICAL)); mbVertical[6] = (k6 & VERTICAL) == VERTICAL;
1111 static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
1113 static LayoutDescriptor aLayouts[AUTOLAYOUT__END-AUTOLAYOUT__START] =
1115 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_TEXT ), // AUTOLAYOUT_TITLE
1116 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_ENUM
1117 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHART
1118 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2TEXT
1119 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTCHART
1120 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_ORG
1121 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTCLbIP
1122 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHARTTEXT
1123 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TAB
1124 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CLIPTEXT
1125 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ
1126 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OBJECT ), // AUTOLAYOUT_OBJ
1127 LayoutDescriptor( 2, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXT2OBJ
1128 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ
1129 LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_OBJOVERTEXT
1130 LayoutDescriptor( 3, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2OBJTEXT
1131 LayoutDescriptor( 5, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2OBJOVERTEXT
1132 LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOVEROBJ
1133 LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_4OBJ
1134 PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),
1135 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_NONE ), // AUTOLAYOUT_ONLY_TITLE
1136 LayoutDescriptor( 0, PRESOBJ_NONE ), // AUTOLAYOUT_NONE
1137 LayoutDescriptor( 0, PRESOBJ_PAGE, PRESOBJ_NOTES ), // AUTOLAYOUT_NOTES
1138 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT1
1139 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT2
1140 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT3
1141 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT4
1142 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT6
1143 LayoutDescriptor( 7, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE ),// AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART
1144 LayoutDescriptor( 8, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE
1145 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE
1146 LayoutDescriptor( 9, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART
1147 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT9
1148 LayoutDescriptor( 10, PRESOBJ_TEXT, PRESOBJ_NONE ), // AUTOLAYOUT_ONLY_TEXT
1149 LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_4CLIPART
1150 PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC ),
1151 LayoutDescriptor( 11, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_6CLIPART
1152 PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE )
1155 if( (eLayout < AUTOLAYOUT__START) || (eLayout >= AUTOLAYOUT__END) )
1156 eLayout = AUTOLAYOUT_NONE;
1158 return aLayouts[ eLayout - AUTOLAYOUT__START ];
1161 static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRectangle )
1163 Rectangle aTitleRect;
1164 Rectangle aLayoutRect;
1166 if( rPage.GetPageKind() != PK_HANDOUT )
1168 SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage());
1169 SdrObject* pMasterTitle = rMasterPage.GetPresObj( PRESOBJ_TITLE );
1170 SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
1172 if( pMasterTitle )
1173 aTitleRect = pMasterTitle->GetLogicRect();
1175 if (aTitleRect.IsEmpty() )
1176 aTitleRect = rPage.GetTitleRect();
1178 if( pMasterOutline )
1179 aLayoutRect = pMasterOutline->GetLogicRect();
1181 if (aLayoutRect.IsEmpty() )
1182 aLayoutRect = rPage.GetLayoutRect();
1185 rRectangle[0] = aTitleRect;
1187 int i;
1188 for( i = 1; i < MAX_PRESOBJS; i++ )
1189 rRectangle[i] = aLayoutRect;
1191 Point aTitlePos( aTitleRect.TopLeft() );
1192 Size aLayoutSize( aLayoutRect.GetSize() );
1193 Point aLayoutPos( aLayoutRect.TopLeft() );
1194 Size aTempSize;
1195 Point aTempPnt;
1197 sal_Bool bRightToLeft = ( rPage.GetModel() && static_cast< SdDrawDocument* >( rPage.GetModel() )->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB );
1199 switch( nLayout )
1201 case 0: // default layout using only the title and layout area
1202 break; // do nothing
1203 case 1: // title, 2 shapes
1204 case 9: // title, 2 vertical shapes
1205 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1206 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1208 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1209 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1211 if( bRightToLeft && (nLayout != 9) )
1212 ::std::swap( rRectangle[1], rRectangle[2] );
1213 break;
1214 case 2: // title, shape, 2 shapes
1215 aTempPnt = aLayoutPos;
1216 aTempSize = aLayoutSize;
1217 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1218 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1219 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1220 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1222 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1223 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1225 aLayoutPos = aTempPnt;
1226 aLayoutSize = aTempSize;
1227 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1228 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1230 if( bRightToLeft )
1232 ::std::swap( rRectangle[1].Left(), rRectangle[2].Left() );
1233 rRectangle[3].Left() = rRectangle[2].Left();
1235 break;
1236 case 3: // title, 2 shapes, shape
1237 aTempPnt = aLayoutPos;
1238 aTempSize = aLayoutSize;
1239 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1240 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1241 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1243 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1244 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1246 aLayoutPos = aTempPnt;
1247 aLayoutSize = aTempSize;
1248 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1249 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1250 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1252 if( bRightToLeft )
1254 ::std::swap( rRectangle[1].Left(), rRectangle[2].Left() );
1255 rRectangle[3].Left() = rRectangle[2].Left();
1257 break;
1258 case 4: // title, shape above shape
1259 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1260 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1262 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1263 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1264 break;
1266 case 5: // title, 2 shapes above shape
1267 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1268 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1269 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1271 aTempPnt = aLayoutPos;
1272 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05);
1273 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1275 aLayoutPos.X() = aTempPnt.X();
1276 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1277 aLayoutSize.Width() = long (aLayoutSize.Width() / 0.488);
1278 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1279 break;
1280 case 6: // title, 4 shapes
1282 sal_uLong nX = long (aLayoutPos.X());
1284 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1285 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488);
1286 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1288 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1289 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1291 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1292 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1294 aLayoutPos.X() = nX;
1295 rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
1296 break;
1298 case 7: // vertical title, shape above shape
1300 Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1301 rRectangle[0].SetSize( aSize );
1302 rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
1304 Size aPageSize ( rPage.GetSize() );
1305 aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
1306 aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
1307 aSize.Width() = long( aPageSize.Width() * 0.7 );
1308 rRectangle[1].SetPos( aTitleRect.TopLeft() );
1309 rRectangle[1].SetSize( aSize );
1311 aSize.Height() = rRectangle[0].GetSize().Height();
1312 Point aPos( aTitleRect.TopLeft() );
1313 aPos.Y() += long ( aSize.Height() * 0.53 );
1314 rRectangle[2].SetPos( aPos );
1315 aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 );
1316 rRectangle[2].SetSize( aSize );
1317 break;
1319 case 8: // vertical title, shape
1321 Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1322 rRectangle[0].SetSize( aSize );
1323 rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) );
1325 Size aPageSize ( rPage.GetSize() );
1326 aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder();
1327 aSize.Height() = rRectangle[0].GetSize().Height();
1328 aSize.Width() = long( aPageSize.Width() * 0.7 );
1329 rRectangle[1].SetPos( aTitleRect.TopLeft() );
1330 rRectangle[1].SetSize( aSize );
1331 break;
1333 case 10: // onlytext
1335 Size aSize( rRectangle[0].GetSize().Width(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() );
1336 rRectangle[0].SetSize( aSize );
1337 rRectangle[0].SetPos( aTitlePos);
1338 break;
1340 case 11: // title, 6 shapes
1342 sal_uLong nX = long (aLayoutPos.X());
1344 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477);
1345 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.322);
1346 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize);
1348 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1349 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize);
1351 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 2 * 1.05);
1352 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize);
1354 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095);
1355 rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize);
1357 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05);
1358 rRectangle[5] = Rectangle (aLayoutPos, aLayoutSize);
1360 aLayoutPos.X() = nX;
1361 rRectangle[6] = Rectangle (aLayoutPos, aLayoutSize);
1363 break;
1370 void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::vector< SdrObject* >& rShapes, bool bInit, bool bSwitchLayout )
1372 int i;
1374 // init list of indexes for each presentation shape kind
1375 // this is used to find subsequent shapes with the same presentation shape kind
1376 int PresObjIndex[PRESOBJ_MAX];
1377 for( i = 0; i < PRESOBJ_MAX; i++ ) PresObjIndex[i] = 1;
1379 bool bMissing = false;
1381 // for each entry in the layoutdescriptor, arrange a presentation shape
1382 for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1384 PresObjKind eKind = rDescriptor.meKind[i];
1385 SdrObject* pObj = 0;
1386 while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != 0 )
1388 PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
1390 if( !bSwitchLayout || !pObj->IsEmptyPresObj() )
1392 rShapes[i] = pObj;
1393 break;
1397 if( !pObj )
1398 bMissing = true;
1401 if( bMissing && bInit )
1403 // for each entry in the layoutdescriptor, look for an alternative shape
1404 for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1406 if( rShapes[i] )
1407 continue;
1409 PresObjKind eKind = rDescriptor.meKind[i];
1411 SdrObject* pObj = 0;
1412 bool bFound = false;
1414 const int nShapeCount = rPage.GetObjCount();
1415 int nShapeIndex = 0;
1416 while((nShapeIndex < nShapeCount) && !bFound )
1418 pObj = rPage.GetObj(nShapeIndex++);
1420 if( pObj->IsEmptyPresObj() )
1421 continue;
1423 if( pObj->GetObjInventor() != SdrInventor )
1424 continue;
1426 // do not reuse shapes that are already part of the layout
1427 if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() )
1428 continue;
1430 bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE);
1431 SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() );
1433 switch( eKind )
1435 case PRESOBJ_TITLE:
1436 bFound = eSdrObjKind == OBJ_TITLETEXT;
1437 break;
1438 case PRESOBJ_TABLE:
1439 bFound = eSdrObjKind == OBJ_TABLE;
1440 break;
1441 case PRESOBJ_MEDIA:
1442 bFound = eSdrObjKind == OBJ_MEDIA;
1443 break;
1444 case PRESOBJ_OUTLINE:
1445 bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
1446 ((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
1447 (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2);
1448 break;
1449 case PRESOBJ_GRAPHIC:
1450 bFound = eSdrObjKind == OBJ_GRAF;
1451 break;
1452 case PRESOBJ_OBJECT:
1453 if( eSdrObjKind == OBJ_OLE2 )
1455 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1456 if( pOle2 )
1458 if( pOle2->IsEmpty() )
1459 bFound = true;
1460 else if( rPage.GetModel() )
1462 SdrModel* pSdrModel = rPage.GetModel();
1463 ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
1464 if( pPersist )
1466 uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
1467 GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
1469 // TODO CL->KA: Why is this not working anymore?
1470 if( xObject.is() )
1472 SvGlobalName aClassId( xObject->getClassID() );
1474 const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
1475 const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
1476 const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
1478 if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
1480 bFound = true;
1487 break;
1488 case PRESOBJ_CHART:
1489 case PRESOBJ_CALC:
1490 if( eSdrObjKind == OBJ_OLE2 )
1492 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1493 if( pOle2 )
1496 ((eKind == PRESOBJ_CHART) &&
1497 ( pOle2->GetProgName().EqualsAscii( "StarChart" ) || pOle2->IsChart() ) )
1499 ((eKind == PRESOBJ_CALC) &&
1500 ( pOle2->GetProgName().EqualsAscii( "StarCalc" ) || pOle2->IsCalc() ) ) )
1502 bFound = true;
1505 break;
1507 else if( eSdrObjKind == OBJ_TABLE )
1509 bFound = true;
1511 break;
1512 case PRESOBJ_PAGE:
1513 case PRESOBJ_HANDOUT:
1514 bFound = eSdrObjKind == OBJ_PAGE;
1515 break;
1516 case PRESOBJ_NOTES:
1517 case PRESOBJ_TEXT:
1518 bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT);
1519 break;
1520 default:
1521 break;
1525 if( bFound )
1526 rShapes[i] = pObj;
1531 void SdPage::SetAutoLayout(AutoLayout eLayout, sal_Bool bInit, sal_Bool bCreate )
1533 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1535 const bool bSwitchLayout = eLayout != GetAutoLayout();
1537 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
1538 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
1540 meAutoLayout = eLayout;
1542 // if needed, creates and initialises the presentation shapes on this slides master page
1543 CreateTitleAndLayout(bInit, bCreate);
1545 if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster)
1547 // MasterPage or no layout and no presentation shapes available, noting to do
1548 return;
1551 Rectangle aRectangle[MAX_PRESOBJS];
1552 const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
1553 CalcAutoLayoutRectangles( *this, aDescriptor.mnLayout, aRectangle );
1555 std::set< SdrObject* > aUsedPresentationObjects;
1558 std::vector< SdrObject* > aLayoutShapes(PRESOBJ_MAX, 0);
1559 findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
1561 int i;
1563 // for each entry in the layoutdescriptor, arrange a presentation shape
1564 for (i = 0; (i < MAX_PRESOBJS) && (aDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1566 PresObjKind eKind = aDescriptor.meKind[i];
1567 SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );
1568 if( pObj )
1569 aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape
1572 // now delete all empty presentation objects that are no longer used by the new layout
1573 if( bInit )
1575 SdrObject* pObj = maPresentationShapeList.getNextShape(0);
1577 while( pObj )
1579 SdrObject* pNext = maPresentationShapeList.getNextShape(pObj);
1580 if( aUsedPresentationObjects.count(pObj) == 0 )
1583 if( pObj->IsEmptyPresObj() )
1585 if( bUndo )
1586 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
1588 RemoveObject( pObj->GetOrdNum() );
1590 if( !bUndo )
1591 SdrObject::Free( pObj );
1593 /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */
1595 pObj = pNext;
1600 /*************************************************************************
1602 |* insert object
1604 \************************************************************************/
1606 void SdPage::NbcInsertObject(SdrObject* pObj, sal_uLong nPos, const SdrInsertReason* pReason)
1608 FmFormPage::NbcInsertObject(pObj, nPos, pReason);
1610 ((SdDrawDocument*) pModel)->InsertObject(pObj, this);
1612 SdrLayerID nId = pObj->GetLayer();
1613 if( mbMaster )
1615 if( nId == 0 )
1616 pObj->NbcSetLayer( 2 ); // wrong layer. corrected to BackgroundObj layer
1618 else
1620 if( nId == 2 )
1621 pObj->NbcSetLayer( 0 ); // wrong layer. corrected to layout layer
1625 /*************************************************************************
1627 |* remove object
1629 \************************************************************************/
1631 SdrObject* SdPage::RemoveObject(sal_uLong nObjNum)
1633 onRemoveObject(GetObj( nObjNum ));
1634 return FmFormPage::RemoveObject(nObjNum);
1637 /*************************************************************************
1639 |* remove object without broadcast
1641 \************************************************************************/
1643 SdrObject* SdPage::NbcRemoveObject(sal_uLong nObjNum)
1645 onRemoveObject(GetObj( nObjNum ));
1646 return FmFormPage::NbcRemoveObject(nObjNum);
1649 // Also overload ReplaceObject methods to realize when
1650 // objects are removed with this mechanism instead of RemoveObject
1651 SdrObject* SdPage::NbcReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum)
1653 onRemoveObject(GetObj( nObjNum ));
1654 return FmFormPage::NbcReplaceObject(pNewObj, nObjNum);
1657 // Also overload ReplaceObject methods to realize when
1658 // objects are removed with this mechanism instead of RemoveObject
1659 SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum)
1661 onRemoveObject(GetObj( nObjNum ));
1662 return FmFormPage::ReplaceObject(pNewObj, nObjNum);
1665 // -------------------------------------------------------------------------
1667 // called after a shape is removed or replaced from this slide
1669 void SdPage::onRemoveObject( SdrObject* pObject )
1671 if( pObject )
1673 RemovePresObj(pObject);
1675 if( pModel )
1676 static_cast<SdDrawDocument*>(pModel)->RemoveObject(pObject, this);
1678 removeAnimations( pObject );
1682 void SdPage::SetSize(const Size& aSize)
1684 Size aOldSize = GetSize();
1686 if (aSize != aOldSize)
1688 FmFormPage::SetSize(aSize);
1690 if (aOldSize.Height() == 10 && aOldSize.Width() == 10)
1692 // this page gets a valid size for the first time. Therefore
1693 // we initialize the orientation.
1694 if (aSize.Width() > aSize.Height())
1696 meOrientation = ORIENTATION_LANDSCAPE;
1698 else
1700 meOrientation = ORIENTATION_PORTRAIT;
1706 void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
1708 if (nLft != GetLftBorder() || nUpp != GetUppBorder() ||
1709 nRgt != GetRgtBorder() || nLwr != GetLwrBorder() )
1711 FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
1715 void SdPage::SetLftBorder(sal_Int32 nBorder)
1717 if (nBorder != GetLftBorder() )
1719 FmFormPage::SetLftBorder(nBorder);
1723 void SdPage::SetRgtBorder(sal_Int32 nBorder)
1725 if (nBorder != GetRgtBorder() )
1727 FmFormPage::SetRgtBorder(nBorder);
1731 void SdPage::SetUppBorder(sal_Int32 nBorder)
1733 if (nBorder != GetUppBorder() )
1735 FmFormPage::SetUppBorder(nBorder);
1739 void SdPage::SetLwrBorder(sal_Int32 nBorder)
1741 if (nBorder != GetLwrBorder() )
1743 FmFormPage::SetLwrBorder(nBorder);
1747 /*************************************************************************
1749 |* Sets BackgroundFullSize and then calls AdjustBackground
1751 \************************************************************************/
1753 void SdPage::SetBackgroundFullSize( sal_Bool bIn )
1755 if( bIn != mbBackgroundFullSize )
1757 mbBackgroundFullSize = bIn;
1761 /*************************************************************************
1763 |* Adjust all objects to new page size.
1765 |* bScaleAllObj: all objects are scaled into the new area within the page
1766 |* margins. We scale the position and size. For presentation objects on the
1767 |* master page, we also scale the font height of the presentation template.
1769 \************************************************************************/
1771 void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderRect, sal_Bool bScaleAllObj)
1773 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1775 mbScaleObjects = bScaleAllObj;
1776 SdrObject* pObj = NULL;
1777 Point aRefPnt(0, 0);
1778 Size aNewPageSize(rNewPageSize);
1779 sal_Int32 nLeft = rNewBorderRect.Left();
1780 sal_Int32 nRight = rNewBorderRect.Right();
1781 sal_Int32 nUpper = rNewBorderRect.Top();
1782 sal_Int32 nLower = rNewBorderRect.Bottom();
1784 // negative values are fixed values
1785 // -> use up to date values
1786 if (aNewPageSize.Width() < 0)
1788 aNewPageSize.Width() = GetWdt();
1790 if (aNewPageSize.Height() < 0)
1792 aNewPageSize.Height() = GetHgt();
1794 if (nLeft < 0)
1796 nLeft = GetLftBorder();
1798 if (nRight < 0)
1800 nRight = GetRgtBorder();
1802 if (nUpper < 0)
1804 nUpper = GetUppBorder();
1806 if (nLower < 0)
1808 nLower = GetLwrBorder();
1811 Point aBackgroundPos(nLeft, nUpper);
1812 Size aBackgroundSize(aNewPageSize);
1813 Rectangle aBorderRect (aBackgroundPos, aBackgroundSize);
1815 if (mbScaleObjects)
1817 aBackgroundSize.Width() -= nLeft + nRight;
1818 aBackgroundSize.Height() -= nUpper + nLower;
1819 aBorderRect.SetSize(aBackgroundSize);
1820 aNewPageSize = aBackgroundSize;
1823 long nOldWidth = GetWdt() - GetLftBorder() - GetRgtBorder();
1824 long nOldHeight = GetHgt() - GetUppBorder() - GetLwrBorder();
1826 Fraction aFractX = Fraction(aNewPageSize.Width(), nOldWidth);
1827 Fraction aFractY = Fraction(aNewPageSize.Height(), nOldHeight);
1829 sal_uLong nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
1831 for (sal_uLong nObj = 0; nObj < nObjCnt; nObj++)
1833 sal_Bool bIsPresObjOnMaster = sal_False;
1835 // all Objects
1836 pObj = GetObj(nObj);
1838 if (mbMaster && IsPresObj(pObj))
1840 // There is a presentation object on the master page
1841 bIsPresObjOnMaster = sal_True;
1844 if (pObj)
1846 // remember aTopLeft as original TopLeft
1847 Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
1849 if (!pObj->IsEdgeObj())
1851 /**************************************************************
1852 * Scale objects
1853 **************************************************************/
1854 if (mbScaleObjects)
1856 // use aTopLeft as original TopLeft
1857 aRefPnt = aTopLeft;
1860 pObj->Resize(aRefPnt, aFractX, aFractY);
1862 if (mbScaleObjects)
1864 SdrObjKind eObjKind = (SdrObjKind) pObj->GetObjIdentifier();
1866 if (bIsPresObjOnMaster)
1868 /**********************************************************
1869 * presentation template: adjust test height
1870 **********************************************************/
1871 sal_uInt16 nIndexTitle = 0;
1872 sal_uInt16 nIndexOutline = 0;
1873 sal_uInt16 nIndexNotes = 0;
1875 if (pObj == GetPresObj(PRESOBJ_TITLE, nIndexTitle))
1877 SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
1879 if (pTitleSheet)
1881 SfxItemSet& rSet = pTitleSheet->GetItemSet();
1883 SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT);
1884 sal_uLong nFontHeight = rOldHgt.GetHeight();
1885 nFontHeight = long(nFontHeight * (double) aFractY);
1886 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1888 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1890 rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1891 nFontHeight = rOldHgt.GetHeight();
1892 nFontHeight = long(nFontHeight * (double) aFractY);
1893 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1896 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1898 rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1899 nFontHeight = rOldHgt.GetHeight();
1900 nFontHeight = long(nFontHeight * (double) aFractY);
1901 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1904 pTitleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1907 else if (pObj == GetPresObj(PRESOBJ_OUTLINE, nIndexOutline))
1909 String aName(GetLayoutName());
1910 aName += sal_Unicode( ' ' );
1912 for (sal_uInt16 i=1; i<=9; i++)
1914 String sLayoutName(aName);
1915 sLayoutName += OUString::number( (sal_Int32)i );
1916 SfxStyleSheet* pOutlineSheet = (SfxStyleSheet*)((SdDrawDocument*) pModel)->GetStyleSheetPool()->Find(sLayoutName, SD_STYLE_FAMILY_MASTERPAGE);
1918 if (pOutlineSheet)
1920 // Calculate new font height
1921 SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
1923 SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT);
1924 sal_uLong nFontHeight = rOldHgt.GetHeight();
1925 nFontHeight = long(nFontHeight * (double) aFractY);
1926 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1928 if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1930 rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1931 nFontHeight = rOldHgt.GetHeight();
1932 nFontHeight = long(nFontHeight * (double) aFractY);
1933 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1936 if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1938 rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1939 nFontHeight = rOldHgt.GetHeight();
1940 nFontHeight = long(nFontHeight * (double) aFractY);
1941 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1944 // adjust bullet
1945 ((SdStyleSheet*) pOutlineSheet)->AdjustToFontHeight(aTempSet, sal_False);
1947 // Special treatment: reset the INVALIDS to
1948 // NULL pointer (otherwise we have INVALID's
1949 // or pointer to the DefaultItems in the
1950 // template; both would suppress the
1951 // attribute inheritance)
1952 aTempSet.ClearInvalidItems();
1954 // Special treatment: only the valid parts
1955 // of the BulletItems
1956 if (aTempSet.GetItemState(EE_PARA_BULLET) == SFX_ITEM_AVAILABLE)
1958 SvxBulletItem aOldBulItem((SvxBulletItem&) pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET));
1959 SvxBulletItem& rNewBulItem = (SvxBulletItem&) aTempSet.Get(EE_PARA_BULLET);
1960 aOldBulItem.CopyValidProperties(rNewBulItem);
1961 aTempSet.Put(aOldBulItem);
1964 pOutlineSheet->GetItemSet().Put(aTempSet);
1965 pOutlineSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1969 else if (pObj == GetPresObj(PRESOBJ_NOTES, nIndexNotes))
1971 SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PRESOBJ_NOTES);
1973 if (pNotesSheet)
1975 sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height();
1976 sal_uLong nFontHeight = (sal_uLong) (nHeight * 0.0741);
1977 SfxItemSet& rSet = pNotesSheet->GetItemSet();
1978 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
1979 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
1980 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
1981 pNotesSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1985 else if ( eObjKind != OBJ_TITLETEXT &&
1986 eObjKind != OBJ_OUTLINETEXT &&
1987 pObj->ISA(SdrTextObj) &&
1988 pObj->GetOutlinerParaObject() )
1990 /******************************************************
1991 * normal text object: adjust text height
1992 ******************************************************/
1993 sal_uLong nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
1994 sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT;
1995 if ( nScriptType == SCRIPTTYPE_ASIAN )
1996 nWhich = EE_CHAR_FONTHEIGHT_CJK;
1997 else if ( nScriptType == SCRIPTTYPE_COMPLEX )
1998 nWhich = EE_CHAR_FONTHEIGHT_CTL;
2000 // use more modern method to scale the text height
2001 sal_uInt32 nFontHeight = ((SvxFontHeightItem&)pObj->GetMergedItem(nWhich)).GetHeight();
2002 sal_uInt32 nNewFontHeight = sal_uInt32((double)nFontHeight * (double)aFractY);
2004 pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
2009 if (mbScaleObjects && !pObj->IsEdgeObj())
2011 /**************************************************************
2012 * scale object position
2013 **************************************************************/
2014 Point aNewPos;
2016 // corrected scaling; only distances may be scaled
2017 // use aTopLeft as original TopLeft
2018 aNewPos.X() = long((aTopLeft.X() - GetLftBorder()) * (double)aFractX) + nLeft;
2019 aNewPos.Y() = long((aTopLeft.Y() - GetUppBorder()) * (double)aFractY) + nUpper;
2021 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
2023 if (aVec.Height() != 0 || aVec.Width() != 0)
2025 pObj->NbcMove(aVec);
2028 pObj->SetChanged();
2029 pObj->BroadcastObjectChange();
2035 SdrObject* convertPresentationObjectImpl( SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, Rectangle aRect )
2037 SdDrawDocument* pModel = static_cast< SdDrawDocument* >( rPage.GetModel() );
2038 DBG_ASSERT( pModel, "sd::convertPresentationObjectImpl(), no model on page!" );
2039 if( !pModel || !pSourceObj )
2040 return pSourceObj;
2042 ::svl::IUndoManager* pUndoManager = static_cast<SdDrawDocument*>(pModel)->GetUndoManager();
2043 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
2045 SdrObject* pNewObj = pSourceObj;
2046 if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) )
2048 pNewObj = rPage.CreatePresObj(PRESOBJ_OUTLINE, bVertical, aRect);
2050 // Set text of the subtitle into PRESOBJ_OUTLINE
2051 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2053 if(pOutlParaObj)
2055 // assign text
2056 ::sd::Outliner* pOutl = pModel->GetInternalOutliner( sal_True );
2057 pOutl->Clear();
2058 pOutl->SetText( *pOutlParaObj );
2059 pOutlParaObj = pOutl->CreateParaObject();
2060 pNewObj->SetOutlinerParaObject( pOutlParaObj );
2061 pOutl->Clear();
2062 pNewObj->SetEmptyPresObj(sal_False);
2064 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
2066 // assign new template
2067 String aName(rPage.GetLayoutName());
2068 aName += sal_Unicode( ' ' );
2069 aName += OUString::number( nLevel );
2070 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE) );
2072 if (pSheet)
2074 if (nLevel == 1)
2076 SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2078 if (pSubtitleSheet)
2079 pOutlParaObj->ChangeStyleSheetName(SD_STYLE_FAMILY_MASTERPAGE, pSubtitleSheet->GetName(), pSheet->GetName());
2082 pNewObj->StartListening(*pSheet);
2086 // Remove LRSpace item
2087 SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
2089 aSet.Put(pNewObj->GetMergedItemSet());
2091 aSet.ClearItem(EE_PARA_LRSPACE);
2093 pNewObj->SetMergedItemSet(aSet);
2095 if( bUndo )
2096 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
2098 // Remove outline shape from page
2099 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2101 if( !bUndo )
2102 SdrObject::Free( pSourceObj );
2105 else if((eObjKind == PRESOBJ_TEXT) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) )
2107 // is there an outline shape we can use to replace empty subtitle shape?
2108 pNewObj = rPage.CreatePresObj(PRESOBJ_TEXT, bVertical, aRect);
2110 // Set text of the outline object into PRESOBJ_TITLE
2111 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2113 if(pOutlParaObj)
2115 // assign text
2116 ::sd::Outliner* pOutl = pModel->GetInternalOutliner();
2117 pOutl->Clear();
2118 pOutl->SetText( *pOutlParaObj );
2119 pOutlParaObj = pOutl->CreateParaObject();
2120 pNewObj->SetOutlinerParaObject( pOutlParaObj );
2121 pOutl->Clear();
2122 pNewObj->SetEmptyPresObj(sal_False);
2124 // reset left indent
2125 SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
2127 aSet.Put(pNewObj->GetMergedItemSet());
2129 const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&) aSet.Get(EE_PARA_LRSPACE);
2130 SvxLRSpaceItem aNewLRItem(rLRItem);
2131 aNewLRItem.SetTxtLeft(0);
2132 aSet.Put(aNewLRItem);
2134 pNewObj->SetMergedItemSet(aSet);
2136 SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2137 if (pSheet)
2138 pNewObj->SetStyleSheet(pSheet, sal_True);
2140 // Remove subtitle shape from page
2141 if( bUndo )
2142 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
2144 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2146 if( !bUndo )
2147 SdrObject::Free( pSourceObj );
2150 else if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) )
2152 switch( pSourceObj->GetObjIdentifier() )
2154 case OBJ_TABLE: eObjKind = PRESOBJ_TABLE; break;
2155 case OBJ_MEDIA: eObjKind = PRESOBJ_MEDIA; break;
2156 case OBJ_GRAF: eObjKind = PRESOBJ_GRAPHIC; break;
2157 case OBJ_OLE2: eObjKind = PRESOBJ_OBJECT; break;
2161 return pNewObj;
2164 /** reuses or creates a presentation shape for an auto layout that fits the given parameter
2166 @param eObjKind
2167 The kind of presentation shape we like to have
2168 @param nIndex
2169 If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
2170 looking for an existing presentation shape
2171 @param bVertical
2172 If true, the shape is created vertical if bInit is true
2173 @param aRect
2174 The rectangle that should be used to transform the shape
2175 @param bInit
2176 If true the shape is created if not found
2177 @returns
2178 A presentation shape that was either found or created with the given parameters
2180 SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind, bool bVertical, Rectangle aRect, bool bInit )
2182 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0;
2183 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
2185 if (!pObj && bInit)
2187 pObj = CreatePresObj(eObjKind, bVertical, aRect);
2189 else if ( pObj && (pObj->GetUserCall() || bInit) )
2191 // convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2192 if( bInit )
2193 pObj = convertPresentationObjectImpl( *this, pObj, eObjKind, bVertical, aRect );
2195 if( bUndo )
2197 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
2198 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, sal_True, sal_True ) );
2199 pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
2202 ( /*(SdrGrafObj*)*/ pObj)->AdjustToMaxRect( aRect );
2204 pObj->SetUserCall(this);
2206 SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
2207 if( pTextObject )
2209 if( pTextObject->IsVerticalWriting() != (bVertical ? sal_True : sal_False) )
2211 pTextObject->SetVerticalWriting( bVertical );
2213 // here make sure the correct anchoring is used when the object
2214 // is re-used but orientation is changed
2215 if(PRESOBJ_OUTLINE == eObjKind)
2216 pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
2219 if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) )
2221 if ( pTextObject->IsAutoGrowHeight() )
2223 // switch off AutoGrowHeight, set new MinHeight
2224 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
2225 SdrTextMinFrameHeightItem aMinHeight( aRect.GetSize().Height() );
2226 aTempAttr.Put( aMinHeight );
2227 aTempAttr.Put( SdrTextAutoGrowHeightItem(sal_False) );
2228 pTextObject->SetMergedItemSet(aTempAttr);
2229 pTextObject->SetLogicRect(aRect);
2231 // switch on AutoGrowHeight
2232 SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
2233 aAttr.Put( SdrTextAutoGrowHeightItem(sal_True) );
2235 pTextObject->SetMergedItemSet(aAttr);
2238 if ( pTextObject->IsAutoGrowWidth() )
2240 // switch off AutoGrowWidth , set new MinWidth
2241 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() );
2242 SdrTextMinFrameWidthItem aMinWidth( aRect.GetSize().Width() );
2243 aTempAttr.Put( aMinWidth );
2244 aTempAttr.Put( SdrTextAutoGrowWidthItem(sal_False) );
2245 pTextObject->SetMergedItemSet(aTempAttr);
2246 pTextObject->SetLogicRect(aRect);
2248 // switch on AutoGrowWidth
2249 SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() );
2250 aAttr.Put( SdrTextAutoGrowWidthItem(sal_True) );
2251 pTextObject->SetMergedItemSet(aAttr);
2257 if(pObj && bInit )
2259 if( !IsPresObj( pObj ) )
2261 if( bUndo )
2262 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
2264 InsertPresObj( pObj, eObjKind );
2267 // make adjustments for vertical title and outline shapes
2268 if( bVertical && (( eObjKind == PRESOBJ_TITLE) || (eObjKind == PRESOBJ_OUTLINE)))
2270 SfxItemSet aNewSet(pObj->GetMergedItemSet());
2271 aNewSet.Put( SdrTextAutoGrowWidthItem(sal_True) );
2272 aNewSet.Put( SdrTextAutoGrowHeightItem(sal_False) );
2273 if( eObjKind == PRESOBJ_OUTLINE )
2275 aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
2276 aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
2278 pObj->SetMergedItemSet(aNewSet);
2282 if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || !pObj->ISA(SdrGrafObj) ) )
2283 pObj->AdjustToMaxRect( aRect );
2285 return pObj;
2289 /*************************************************************************
2291 |* Returns the PresObjKind of a object
2293 \************************************************************************/
2295 PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const
2297 PresObjKind eKind = PRESOBJ_NONE;
2298 if( (pObj != 0) && (maPresentationShapeList.hasShape(*pObj)) )
2300 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
2301 if( pInfo )
2302 eKind = pInfo->mePresObjKind;
2305 return eKind;
2308 bool SdPage::IsPresObj(const SdrObject* pObj)
2310 return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
2313 void SdPage::RemovePresObj(const SdrObject* pObj)
2315 if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
2317 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
2318 if( pInfo )
2319 pInfo->mePresObjKind = PRESOBJ_NONE;
2320 maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
2324 void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
2326 DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2327 DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2328 if( pObj )
2330 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
2331 if( pInfo )
2332 pInfo->mePresObjKind = eKind;
2333 maPresentationShapeList.addShape(*pObj);
2337 /*************************************************************************
2339 |* Set the text of a object
2341 \************************************************************************/
2343 void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const String& rString )
2345 if ( pObj )
2347 DBG_ASSERT( pObj->ISA(SdrTextObj), "SetObjText: No SdrTextObj!" );
2348 ::Outliner* pOutl = pOutliner;
2350 if (!pOutliner)
2352 SfxItemPool* pPool = ((SdDrawDocument*) GetModel())->GetDrawOutliner().GetEmptyItemSet().GetPool();
2353 pOutl = new ::Outliner( pPool, OUTLINERMODE_OUTLINEOBJECT );
2354 pOutl->SetRefDevice( SD_MOD()->GetRefDevice( *( (SdDrawDocument*) GetModel() )->GetDocSh() ) );
2355 pOutl->SetEditTextObjectPool(pPool);
2356 pOutl->SetStyleSheetPool((SfxStyleSheetPool*)GetModel()->GetStyleSheetPool());
2357 pOutl->EnableUndo(sal_False);
2358 pOutl->SetUpdateMode( sal_False );
2361 sal_uInt16 nOutlMode = pOutl->GetMode();
2362 Size aPaperSize = pOutl->GetPaperSize();
2363 sal_Bool bUpdateMode = pOutl->GetUpdateMode();
2364 pOutl->SetUpdateMode(sal_False);
2365 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2367 // Always set the object's StyleSheet at the Outliner to
2368 // use the current objects StyleSheet. Thus it's the same as in
2369 // SetText(...).
2370 // Moved this implementation from where SetObjText(...) was called
2371 // to inside this method to work even when outliner is fetched here.
2372 pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
2374 OUString aString;
2376 switch( eObjKind )
2378 case PRESOBJ_OUTLINE:
2380 pOutl->Init( OUTLINERMODE_OUTLINEOBJECT );
2382 aString += "\t";
2383 aString += rString;
2385 if (mbMaster)
2387 pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
2388 aString += "\n\t\t";
2389 aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER2);
2391 aString += "\n\t\t\t";
2392 aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER3);
2394 aString += "\n\t\t\t\t";
2395 aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER4);
2397 aString += "\n\t\t\t\t\t";
2398 aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER5);
2400 aString += "\n\t\t\t\t\t\t";
2401 aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER6);
2403 aString += "\n\t\t\t\t\t\t\t";
2404 aString += SD_RESSTR(STR_PRESOBJ_MPOUTLLAYER7);
2408 break;
2410 case PRESOBJ_TITLE:
2412 pOutl->Init( OUTLINERMODE_TITLEOBJECT );
2413 aString += rString;
2415 break;
2417 default:
2419 pOutl->Init( OUTLINERMODE_TEXTOBJECT );
2420 aString += rString;
2422 // check if we need to add a text field
2423 SvxFieldData* pData = NULL;
2425 switch( eObjKind )
2427 case PRESOBJ_HEADER:
2428 pData = new SvxHeaderField();
2429 break;
2430 case PRESOBJ_FOOTER:
2431 pData = new SvxFooterField();
2432 break;
2433 case PRESOBJ_SLIDENUMBER:
2434 pData = new SvxPageField();
2435 break;
2436 case PRESOBJ_DATETIME:
2437 pData = new SvxDateTimeField();
2438 break;
2439 default:
2440 break;
2443 if( pData )
2445 ESelection e;
2446 SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
2447 pOutl->QuickInsertField(aField,e);
2448 delete pData;
2451 break;
2454 pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
2456 if( !aString.isEmpty() )
2457 pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
2459 ( (SdrTextObj*) pObj)->SetOutlinerParaObject( pOutl->CreateParaObject() );
2461 if (!pOutliner)
2463 delete pOutl;
2464 pOutl = NULL;
2466 else
2468 // Outliner restaurieren
2469 pOutl->Init( nOutlMode );
2470 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2471 pOutl->SetUpdateMode( bUpdateMode );
2472 pOutl->SetPaperSize( aPaperSize );
2477 /*************************************************************************
2479 |* Set the name of the layout
2481 \************************************************************************/
2482 void SdPage::SetLayoutName(OUString aName)
2484 maLayoutName = aName;
2486 if( mbMaster )
2488 OUString aSep(SD_LT_SEPARATOR);
2489 sal_Int32 nPos = maLayoutName.indexOf(aSep);
2490 if (nPos != -1)
2491 FmFormPage::SetName(maLayoutName.copy(0, nPos));
2496 /*************************************************************************
2498 |* Return the page name and generates it if necessary
2500 \************************************************************************/
2502 const String& SdPage::GetName() const
2504 String aCreatedPageName( maCreatedPageName );
2505 if (GetRealName().Len() == 0)
2507 if ((mePageKind == PK_STANDARD || mePageKind == PK_NOTES) && !mbMaster)
2509 // default name for handout pages
2510 sal_uInt16 nNum = (GetPageNum() + 1) / 2;
2512 aCreatedPageName = String(SdResId(STR_PAGE));
2513 aCreatedPageName += sal_Unicode( ' ' );
2514 if( GetModel()->GetPageNumType() == SVX_NUMBER_NONE )
2516 // if the document has number none as a formating
2517 // for page numbers we still default to arabic numbering
2518 // to keep the default page names unique
2519 aCreatedPageName += OUString::number( (sal_Int32)nNum );
2521 else
2523 aCreatedPageName += ((SdDrawDocument*) GetModel())->CreatePageNumValue(nNum);
2526 else
2528 /******************************************************************
2529 * default name for note pages
2530 ******************************************************************/
2531 aCreatedPageName = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
2534 else
2536 aCreatedPageName = GetRealName();
2539 if (mePageKind == PK_NOTES)
2541 aCreatedPageName += sal_Unicode( ' ' );
2542 aCreatedPageName += String(SdResId(STR_NOTES));
2544 else if (mePageKind == PK_HANDOUT && mbMaster)
2546 aCreatedPageName += OUString(" (");
2547 aCreatedPageName += SdResId(STR_HANDOUT).toString();
2548 aCreatedPageName += sal_Unicode( ')' );
2551 const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
2552 return maCreatedPageName;
2555 void SdPage::SetOrientation( Orientation eOrient)
2557 meOrientation = eOrient;
2560 Orientation SdPage::GetOrientation() const
2562 return meOrientation;
2565 /*************************************************************************
2567 |* returns the default text of a PresObjektes
2569 \************************************************************************/
2571 String SdPage::GetPresObjText(PresObjKind eObjKind) const
2573 String aString;
2575 if (eObjKind == PRESOBJ_TITLE)
2577 if (mbMaster)
2579 if (mePageKind != PK_NOTES)
2581 aString = String ( SdResId( STR_PRESOBJ_MPTITLE ) );
2583 else
2585 aString = String ( SdResId( STR_PRESOBJ_MPNOTESTITLE ) );
2588 else
2590 aString = String ( SdResId( STR_PRESOBJ_TITLE ) );
2593 else if (eObjKind == PRESOBJ_OUTLINE)
2595 if (mbMaster)
2597 aString = String ( SdResId( STR_PRESOBJ_MPOUTLINE ) );
2599 else
2601 aString = String ( SdResId( STR_PRESOBJ_OUTLINE ) );
2604 else if (eObjKind == PRESOBJ_NOTES)
2606 if (mbMaster)
2608 aString = String ( SdResId( STR_PRESOBJ_MPNOTESTEXT ) );
2610 else
2612 aString = String ( SdResId( STR_PRESOBJ_NOTESTEXT ) );
2615 else if (eObjKind == PRESOBJ_TEXT)
2617 aString = String ( SdResId( STR_PRESOBJ_TEXT ) );
2619 else if (eObjKind == PRESOBJ_GRAPHIC)
2621 aString = String ( SdResId( STR_PRESOBJ_GRAPHIC ) );
2623 else if (eObjKind == PRESOBJ_OBJECT)
2625 aString = String ( SdResId( STR_PRESOBJ_OBJECT ) );
2627 else if (eObjKind == PRESOBJ_CHART)
2629 aString = String ( SdResId( STR_PRESOBJ_CHART ) );
2631 else if (eObjKind == PRESOBJ_ORGCHART)
2633 aString = String ( SdResId( STR_PRESOBJ_ORGCHART ) );
2635 else if (eObjKind == PRESOBJ_CALC)
2637 aString = String ( SdResId( STR_PRESOBJ_TABLE ) );
2640 return(aString);
2643 extern uno::Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage );
2645 uno::Reference< uno::XInterface > SdPage::createUnoPage()
2647 return createUnoPageImpl( this );
2650 /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
2651 SdPage* SdPage::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage )
2655 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( xPage, ::com::sun::star::uno::UNO_QUERY );
2656 if( xUnoTunnel.is() )
2658 SvxDrawPage* pUnoPage = reinterpret_cast<SvxDrawPage*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SvxDrawPage::getUnoTunnelId()) ) );
2659 if( pUnoPage )
2660 return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
2663 catch( ::com::sun::star::uno::Exception& )
2665 OSL_FAIL("sd::SdPage::getImplementation(), exception caught!" );
2668 return 0;
2671 void SdPage::SetName (const String& rName)
2673 String aOldName = GetName();
2674 FmFormPage::SetName (rName);
2675 static_cast<SdDrawDocument*>(pModel)->UpdatePageRelativeURLs(aOldName, rName);
2676 ActionChanged();
2679 const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
2681 if( mePageKind == PK_HANDOUT && !mbMaster )
2683 return (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings);
2685 else
2687 return maHeaderFooterSettings;
2691 void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings )
2693 if( mePageKind == PK_HANDOUT && !mbMaster )
2695 (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings) = rNewSettings;
2697 else
2699 maHeaderFooterSettings = rNewSettings;
2702 SetChanged();
2703 if(TRG_HasMasterPage())
2705 TRG_GetMasterPageDescriptorViewContact().ActionChanged();
2709 bool SdPage::checkVisibility(
2710 const sdr::contact::ViewObjectContact& rOriginal,
2711 const sdr::contact::DisplayInfo& rDisplayInfo,
2712 bool bEdit )
2714 if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
2715 return false;
2717 SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2718 if( pObj == NULL )
2719 return false;
2721 const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
2722 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
2723 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
2724 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
2726 // empty presentation objects only visible during edit mode
2727 if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
2729 if( (pObj->GetObjInventor() != SdrInventor) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
2730 return false;
2733 if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) )
2735 const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->GetPage());
2737 if( pCheckPage )
2739 PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
2741 if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
2743 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
2745 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PK_HANDOUT && bIsPrinting ) )
2747 // use the page that is currently processed
2748 const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
2750 if( pVisualizedSdPage )
2752 // if we are not on a masterpage, see if we have to draw this header&footer object at all
2753 const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
2755 switch( eKind )
2757 case PRESOBJ_FOOTER:
2758 return rSettings.mbFooterVisible;
2759 case PRESOBJ_HEADER:
2760 return rSettings.mbHeaderVisible;
2761 case PRESOBJ_DATETIME:
2762 return rSettings.mbDateTimeVisible;
2763 case PRESOBJ_SLIDENUMBER:
2764 return rSettings.mbSlideNumberVisible;
2765 default:
2766 break;
2770 } // check for placeholders on master
2771 else if( (eKind != PRESOBJ_NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) )
2773 // presentation objects on master slide are always invisible if slide is shown.
2774 return false;
2779 // i63977, do not print SdrpageObjs from master pages
2780 if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) )
2782 if( pObj->GetPage() && pObj->GetPage()->IsMasterPage() )
2783 return false;
2786 return true;
2789 bool SdPage::RestoreDefaultText( SdrObject* pObj )
2791 bool bRet = false;
2793 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
2795 if( pTextObj )
2797 PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
2799 if (ePresObjKind == PRESOBJ_TITLE ||
2800 ePresObjKind == PRESOBJ_OUTLINE ||
2801 ePresObjKind == PRESOBJ_NOTES ||
2802 ePresObjKind == PRESOBJ_TEXT)
2804 String aString( GetPresObjText(ePresObjKind) );
2806 if (aString.Len())
2808 sal_Bool bVertical = sal_False;
2809 OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
2810 if( pOldPara )
2811 bVertical = pOldPara->IsVertical(); // is old para object vertical?
2813 SetObjText( pTextObj, 0, ePresObjKind, aString );
2815 if( pOldPara )
2817 // Here, only the vertical flag for the
2818 // OutlinerParaObjects needs to be changed. The
2819 // AutoGrowWidth/Height items still exist in the
2820 // not changed object.
2821 if(pTextObj
2822 && pTextObj->GetOutlinerParaObject()
2823 && pTextObj->GetOutlinerParaObject()->IsVertical() != (bool)bVertical)
2825 Rectangle aObjectRect = pTextObj->GetSnapRect();
2826 pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
2827 pTextObj->SetSnapRect(aObjectRect);
2831 pTextObj->SetTextEditOutliner( NULL ); // to make stylesheet settings work
2832 pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), sal_True );
2833 pTextObj->SetEmptyPresObj(sal_True);
2834 bRet = true;
2838 return bRet;
2841 void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< Rectangle >& rAreas )
2843 SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PK_HANDOUT );
2845 if( eLayout == AUTOLAYOUT_NONE )
2847 // use layout from handout master
2848 SdrObjListIter aShapeIter (rHandoutMaster);
2849 while (aShapeIter.IsMore())
2851 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
2852 if (pPageObj)
2853 rAreas.push_back( pPageObj->GetCurrentBoundRect() );
2856 else
2858 Size aArea = rHandoutMaster.GetSize();
2860 const long nGapW = 1000; // gap is 1cm
2861 const long nGapH = 1000;
2863 long nLeftBorder = rHandoutMaster.GetLftBorder();
2864 long nRightBorder = rHandoutMaster.GetRgtBorder();
2865 long nTopBorder = rHandoutMaster.GetUppBorder();
2866 long nBottomBorder = rHandoutMaster.GetLwrBorder();
2868 const long nHeaderFooterHeight = static_cast< long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05 );
2870 nTopBorder += nHeaderFooterHeight;
2871 nBottomBorder += nHeaderFooterHeight;
2873 long nX = nGapW + nLeftBorder;
2874 long nY = nGapH + nTopBorder;
2876 aArea.Width() -= nGapW * 2 + nLeftBorder + nRightBorder;
2877 aArea.Height() -= nGapH * 2 + nTopBorder + nBottomBorder;
2879 const bool bLandscape = aArea.Width() > aArea.Height();
2881 static sal_uInt16 aOffsets[5][9] =
2883 { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
2884 { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
2885 { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
2886 { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
2887 { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
2890 sal_uInt16* pOffsets = aOffsets[0];
2891 sal_uInt16 nColCnt = 0, nRowCnt = 0;
2892 switch ( eLayout )
2894 case AUTOLAYOUT_HANDOUT1:
2895 nColCnt = 1; nRowCnt = 1;
2896 break;
2898 case AUTOLAYOUT_HANDOUT2:
2899 if( bLandscape )
2901 nColCnt = 2; nRowCnt = 1;
2903 else
2905 nColCnt = 1; nRowCnt = 2;
2907 break;
2909 case AUTOLAYOUT_HANDOUT3:
2910 if( bLandscape )
2912 nColCnt = 3; nRowCnt = 2;
2914 else
2916 nColCnt = 2; nRowCnt = 3;
2918 pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
2919 break;
2921 case AUTOLAYOUT_HANDOUT4:
2922 nColCnt = 2; nRowCnt = 2;
2923 pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
2924 break;
2926 case AUTOLAYOUT_HANDOUT6:
2927 if( bLandscape )
2929 nColCnt = 3; nRowCnt = 2;
2931 else
2933 nColCnt = 2; nRowCnt = 3;
2935 if( !bHorizontal )
2936 pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
2937 break;
2939 default:
2940 case AUTOLAYOUT_HANDOUT9:
2941 nColCnt = 3; nRowCnt = 3;
2943 if( !bHorizontal )
2944 pOffsets = aOffsets[4];
2945 break;
2948 rAreas.resize( nColCnt * nRowCnt );
2950 Size aPartArea, aSize;
2951 aPartArea.Width() = ((aArea.Width() - ((nColCnt-1) * nGapW) ) / nColCnt);
2952 aPartArea.Height() = ((aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt);
2954 SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PK_STANDARD);
2955 if ( pFirstPage )
2957 // scale actual size into handout rect
2958 double fScale = (double)aPartArea.Width() / (double)pFirstPage->GetWdt();
2960 aSize.Height() = (long)(fScale * pFirstPage->GetHgt() );
2961 if( aSize.Height() > aPartArea.Height() )
2963 fScale = (double)aPartArea.Height() / (double)pFirstPage->GetHgt();
2964 aSize.Height() = aPartArea.Height();
2965 aSize.Width() = (long)(fScale * pFirstPage->GetWdt());
2967 else
2969 aSize.Width() = aPartArea.Width();
2972 nX += (aPartArea.Width() - aSize.Width()) / 2;
2973 nY += (aPartArea.Height()- aSize.Height())/ 2;
2975 else
2977 aSize = aPartArea;
2980 Point aPos( nX, nY );
2982 const bool bRTL = rModel.GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB;
2984 const long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
2985 const long nOffsetY = aPartArea.Height() + nGapH;
2986 const long nStartX = bRTL ? nOffsetX*(1 - nColCnt) + nX : nX;
2988 for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
2990 aPos.X() = nStartX;
2991 for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
2993 rAreas[*pOffsets++] = Rectangle(aPos, aSize);
2994 aPos.X() += nOffsetX;
2997 aPos.Y() += nOffsetY;
3005 void SdPage::SetPrecious (const bool bIsPrecious)
3007 mbIsPrecious = bIsPrecious;
3013 bool SdPage::IsPrecious (void) const
3015 return mbIsPrecious;
3021 HeaderFooterSettings::HeaderFooterSettings()
3023 mbHeaderVisible = true;
3024 mbFooterVisible = true;
3025 mbSlideNumberVisible = false;
3026 mbDateTimeVisible = true;
3027 mbDateTimeIsFixed = true;
3028 meDateTimeFormat = SVXDATEFORMAT_A;
3031 bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
3033 return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
3034 (maHeaderText == rSettings.maHeaderText) &&
3035 (mbFooterVisible == rSettings.mbFooterVisible) &&
3036 (maFooterText == rSettings.maFooterText) &&
3037 (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
3038 (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
3039 (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
3040 (meDateTimeFormat == rSettings.meDateTimeFormat) &&
3041 (maDateTimeText == rSettings.maDateTimeText);
3044 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */