bump product version to 6.4.0.3
[LibreOffice.git] / sd / source / core / sdpage.cxx
blobffbd3ff1041ff2b1f9fbec7b55c59ff38ba5cf53
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 .
20 #include <algorithm>
22 #include <comphelper/classids.hxx>
23 #include <comphelper/embeddedobjectcontainer.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 <editeng/lrspitem.hxx>
31 #include <editeng/bulletitem.hxx>
32 #include <svx/svdpagv.hxx>
33 #include <editeng/fhgtitem.hxx>
34 #include <editeng/outlobj.hxx>
35 #include <svx/svdoole2.hxx>
36 #include <svx/svdograf.hxx>
37 #include <svx/svdopage.hxx>
38 #include <editeng/pbinitem.hxx>
39 #include <svx/svdundo.hxx>
40 #include <svl/hint.hxx>
41 #include <editeng/adjustitem.hxx>
42 #include <editeng/editobj.hxx>
43 #include <svx/unopage.hxx>
44 #include <editeng/flditem.hxx>
45 #include <svx/sdr/contact/displayinfo.hxx>
46 #include <svx/svditer.hxx>
47 #include <svx/svdlayer.hxx>
48 #include <svx/sdtmfitm.hxx>
49 #include <svx/sdtagitm.hxx>
50 #include <svx/sdtcfitm.hxx>
51 #include <svx/xfillit0.hxx>
52 #include <com/sun/star/animations/XAnimationNode.hpp>
53 #include <com/sun/star/animations/XTimeContainer.hpp>
54 #include <com/sun/star/container/XEnumerationAccess.hpp>
55 #include <com/sun/star/embed/XEmbeddedObject.hpp>
56 #include <com/sun/star/xml/dom/XNode.hpp>
57 #include <com/sun/star/xml/dom/XNodeList.hpp>
58 #include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
59 #include <rtl/ustring.hxx>
60 #include <sal/log.hxx>
61 #include <o3tl/enumarray.hxx>
62 #include <xmloff/autolayout.hxx>
64 #include <Outliner.hxx>
65 #include <app.hrc>
66 #include <createunopageimpl.hxx>
67 #include <drawdoc.hxx>
68 #include <sdmod.hxx>
69 #include <sdpage.hxx>
70 #include <sdresid.hxx>
71 #include <stlsheet.hxx>
72 #include <strings.hrc>
73 #include <strings.hxx>
74 #include <bitmaps.hlst>
75 #include <glob.hxx>
76 #include <anminfo.hxx>
77 #include <undo/undomanager.hxx>
78 #include <undo/undoobjects.hxx>
79 #include <svx/sdr/contact/viewobjectcontact.hxx>
80 #include <svx/sdr/contact/viewcontact.hxx>
81 #include <svx/sdr/contact/objectcontact.hxx>
82 #include <svx/unoapi.hxx>
83 #include <unokywds.hxx>
85 #include <set>
87 using namespace ::sd;
88 using namespace ::com::sun::star;
89 using namespace ::com::sun::star::uno;
90 using namespace com::sun::star::xml::dom;
91 using ::com::sun::star::uno::Reference;
94 sal_uInt16 SdPage::mnLastPageId = 1;
96 /*************************************************************************
98 |* Ctor
100 \************************************************************************/
102 SdPage::SdPage(SdDrawDocument& rNewDoc, bool bMasterPage)
103 : FmFormPage(rNewDoc, bMasterPage)
104 , SdrObjUserCall()
105 , mePageKind(PageKind::Standard)
106 , meAutoLayout(AUTOLAYOUT_NONE)
107 , mbSelected(false)
108 , mePresChange(PRESCHANGE_MANUAL)
109 , mfTime(1.0)
110 , mbSoundOn(false)
111 , mbExcluded(false)
112 , mbLoopSound(false)
113 , mbStopSound(false)
114 , mbScaleObjects(true)
115 , mbBackgroundFullSize( false )
116 , meCharSet(osl_getThreadTextEncoding())
117 , mnPaperBin(PAPERBIN_PRINTER_SETTINGS)
118 , mpPageLink(nullptr)
119 , mnTransitionType(0)
120 , mnTransitionSubtype(0)
121 , mbTransitionDirection(true)
122 , mnTransitionFadeColor(0)
123 , mfTransitionDuration(2.0)
124 , mbIsPrecious(true)
125 , mnPageId(mnLastPageId++)
127 // The name of the layout of the page is used by SVDRAW to determine the
128 // presentation template of the outline objects. Therefore, it already
129 // contains the designator for the outline (STR_LAYOUT_OUTLINE).
130 maLayoutName = SdResId(STR_LAYOUT_DEFAULT_NAME)+ SD_LT_SEPARATOR STR_LAYOUT_OUTLINE;
132 // Stuff that former SetModel did also:
133 ConnectLink();
136 namespace
138 void clearChildNodes(css::uno::Reference<css::animations::XAnimationNode> const & rAnimationNode)
140 css::uno::Reference<css::container::XEnumerationAccess > xEnumerationAccess(rAnimationNode, UNO_QUERY);
141 if (!xEnumerationAccess.is())
142 return;
143 css::uno::Reference<css::container::XEnumeration> xEnumeration = xEnumerationAccess->createEnumeration();
144 if (!xEnumeration.is())
145 return;
146 while (xEnumeration->hasMoreElements())
148 css::uno::Reference<css::animations::XAnimationNode> xChildNode(xEnumeration->nextElement(), UNO_QUERY);
149 if (!xChildNode.is())
150 continue;
151 clearChildNodes(xChildNode);
152 css::uno::Reference<css::animations::XTimeContainer> xAnimationNode(rAnimationNode, UNO_QUERY);
153 if (!xAnimationNode.is())
155 SAL_WARN("sd.core", "can't remove node child, possible leak");
156 continue;
158 xAnimationNode->removeChild(xChildNode);
163 /*************************************************************************
165 |* Dtor
167 \************************************************************************/
169 SdPage::~SdPage()
171 DisconnectLink();
173 EndListenOutlineText();
175 clearChildNodes(mxAnimationNode);
177 // clear SdrObjects with broadcasting
178 ClearSdrObjList();
181 struct OrdNumSorter
183 bool operator()( SdrObject const * p1, SdrObject const * p2 )
185 return p1->GetOrdNum() < p2->GetOrdNum();
189 /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
190 SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ )
192 // first sort all matching shapes with z-order
193 std::vector< SdrObject* > aMatches;
195 SdrObject* pObj = nullptr;
196 maPresentationShapeList.seekShape(0);
198 while( (pObj = maPresentationShapeList.getNextShape()) )
200 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
201 if( pInfo )
203 bool bFound = false;
204 if( pInfo->mePresObjKind == eObjKind )
206 bFound = true;
208 else if( bFuzzySearch && (eObjKind == PRESOBJ_OUTLINE) )
210 switch( pInfo->mePresObjKind )
212 case PRESOBJ_GRAPHIC:
213 case PRESOBJ_OBJECT:
214 case PRESOBJ_CHART:
215 case PRESOBJ_ORGCHART:
216 case PRESOBJ_TABLE:
217 case PRESOBJ_CALC:
218 case PRESOBJ_MEDIA:
219 bFound = true;
220 break;
221 default:
222 break;
225 if( bFound )
227 aMatches.push_back( pObj );
232 if( nIndex > 0 )
233 nIndex--;
235 if( (nIndex >= 0) && ( aMatches.size() > static_cast<unsigned int>(nIndex)) )
237 if( aMatches.size() > 1 )
238 std::nth_element( aMatches.begin(), aMatches.begin() + nIndex, aMatches.end(),
239 OrdNumSorter() );
240 return aMatches[nIndex];
243 return nullptr;
246 /** create background properties */
247 void SdPage::EnsureMasterPageDefaultBackground()
249 if(!mbMaster)
250 return;
252 // no hard attributes on MasterPage attributes
253 getSdrPageProperties().ClearItem();
254 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForMasterPageBackground();
256 if(pSheetForPresObj)
258 // set StyleSheet for background fill attributes
259 getSdrPageProperties().SetStyleSheet(pSheetForPresObj);
261 else
263 // no style found, assert and set at least drawing::FillStyle_NONE
264 OSL_FAIL("No Style for MasterPageBackground fill found (!)");
265 getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE));
269 /** creates a presentation object with the given PresObjKind on this page. A user call will be set
271 SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect )
273 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
274 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
276 SdrObject* pSdrObj = nullptr;
278 bool bForceText = false; // forces the shape text to be set even if its empty
279 bool bEmptyPresObj = true;
281 switch( eObjKind )
283 case PRESOBJ_TITLE:
285 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TITLETEXT);
287 if (mbMaster)
289 pSdrObj->SetNotVisibleAsMaster(true);
292 break;
294 case PRESOBJ_OUTLINE:
296 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_OUTLINETEXT);
298 if (mbMaster)
300 pSdrObj->SetNotVisibleAsMaster(true);
303 break;
305 case PRESOBJ_NOTES:
307 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
309 if (mbMaster)
311 pSdrObj->SetNotVisibleAsMaster(true);
314 break;
316 case PRESOBJ_TEXT:
318 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
320 break;
322 case PRESOBJ_GRAPHIC:
324 BitmapEx aBmpEx(BMP_PRESOBJ_GRAPHIC);
325 Graphic aGraphic( aBmpEx );
326 OutputDevice &aOutDev = *Application::GetDefaultDevice();
327 aOutDev.Push();
329 aOutDev.SetMapMode( aGraphic.GetPrefMapMode() );
330 Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() );
331 aOutDev.SetMapMode(MapMode(MapUnit::Map100thMM));
333 Size aSize = aOutDev.PixelToLogic(aSizePix);
334 Point aPnt (0, 0);
335 ::tools::Rectangle aRect (aPnt, aSize);
336 pSdrObj = new SdrGrafObj(getSdrModelFromSdrPage(), aGraphic, aRect);
337 aOutDev.Pop();
339 break;
341 case PRESOBJ_MEDIA:
342 case PRESOBJ_OBJECT:
344 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
345 BitmapEx aBmpEx(BMP_PRESOBJ_OBJECT);
346 Graphic aGraphic( aBmpEx );
347 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
349 break;
351 case PRESOBJ_CHART:
353 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
354 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarChart" );
355 BitmapEx aBmpEx(BMP_PRESOBJ_CHART);
356 Graphic aGraphic( aBmpEx );
357 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
359 break;
361 case PRESOBJ_ORGCHART:
363 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
364 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarOrg" );
365 BitmapEx aBmpEx(BMP_PRESOBJ_ORGCHART);
366 Graphic aGraphic( aBmpEx );
367 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
369 break;
371 case PRESOBJ_TABLE:
372 case PRESOBJ_CALC:
374 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
375 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarCalc" );
376 BitmapEx aBmpEx(BMP_PRESOBJ_TABLE);
377 Graphic aGraphic( aBmpEx );
378 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
380 break;
382 case PRESOBJ_HANDOUT:
384 // Save the first standard page at SdrPageObj
385 // #i105146# We want no content to be displayed for PageKind::Handout,
386 // so just never set a page as content
387 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), nullptr);
389 break;
391 case PRESOBJ_PAGE:
393 // Save note pages at SdrPageObj
394 sal_uInt16 nDestPageNum(GetPageNum());
396 if(nDestPageNum)
398 // decrement only when != 0, else we get a 0xffff
399 nDestPageNum -= 1;
402 if (nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
404 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), getSdrModelFromSdrPage().GetPage(nDestPageNum));
406 else
408 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage());
411 pSdrObj->SetResizeProtect(true);
413 break;
415 case PRESOBJ_HEADER:
416 case PRESOBJ_FOOTER:
417 case PRESOBJ_DATETIME:
418 case PRESOBJ_SLIDENUMBER:
420 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
421 bEmptyPresObj = false;
422 bForceText = true;
424 break;
425 default:
426 break;
429 if (pSdrObj)
431 pSdrObj->SetEmptyPresObj(bEmptyPresObj);
432 pSdrObj->SetLogicRect(rRect);
434 InsertObject(pSdrObj);
436 if ( dynamic_cast< const SdrTextObj *>( pSdrObj ) != nullptr )
438 // Tell the object EARLY that it is vertical to have the
439 // defaults for AutoGrowWidth/Height reversed
440 if(bVertical)
441 static_cast<SdrTextObj*>(pSdrObj)->SetVerticalWriting(true);
443 SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
444 if( bVertical )
445 aTempAttr.Put( makeSdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
446 else
447 aTempAttr.Put( makeSdrTextMinFrameHeightItem( rRect.GetSize().Height() ) );
449 if (mbMaster)
451 // The size of presentation objects on the master page have to
452 // be freely selectable by the user.
454 // potential problem: This action was still NOT
455 // adapted for vertical text. This sure needs to be done.
456 if(bVertical)
457 aTempAttr.Put(makeSdrTextAutoGrowWidthItem(false));
458 else
459 aTempAttr.Put(makeSdrTextAutoGrowHeightItem(false));
462 // check if we need another vertical adjustment than the default
463 SdrTextVertAdjust eV = SDRTEXTVERTADJUST_TOP;
465 if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind != PageKind::Standard) )
467 eV = SDRTEXTVERTADJUST_BOTTOM;
469 else if( (eObjKind == PRESOBJ_SLIDENUMBER) && (mePageKind != PageKind::Standard) )
471 eV = SDRTEXTVERTADJUST_BOTTOM;
474 if( eV != SDRTEXTVERTADJUST_TOP )
475 aTempAttr.Put(SdrTextVertAdjustItem(eV));
477 pSdrObj->SetMergedItemSet(aTempAttr);
479 pSdrObj->SetLogicRect(rRect);
482 OUString aString = GetPresObjText(eObjKind);
483 if( (!aString.isEmpty() || bForceText) && dynamic_cast< const SdrTextObj *>( pSdrObj ) != nullptr )
485 SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
487 OutlinerMode nOutlMode = pOutliner->GetMode();
488 pOutliner->Init( OutlinerMode::TextObject );
489 pOutliner->SetStyleSheet( 0, nullptr );
490 pOutliner->SetVertical( bVertical );
492 SetObjText( static_cast<SdrTextObj*>(pSdrObj), pOutliner, eObjKind, aString );
494 pOutliner->Init( nOutlMode );
495 pOutliner->SetStyleSheet( 0, nullptr );
498 if( (eObjKind == PRESOBJ_HEADER) || (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_DATETIME) )
500 SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
501 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
502 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
503 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
505 SvxAdjust eH = SvxAdjust::Left;
507 if( (eObjKind == PRESOBJ_DATETIME) && (mePageKind != PageKind::Standard ) )
509 eH = SvxAdjust::Right;
511 else if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind == PageKind::Standard ) )
513 eH = SvxAdjust::Center;
515 else if( eObjKind == PRESOBJ_SLIDENUMBER )
517 eH = SvxAdjust::Right;
520 if( eH != SvxAdjust::Left )
521 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST ));
523 pSdrObj->SetMergedItemSet(aTempAttr);
526 if (mbMaster)
528 SdrLayerAdmin& rLayerAdmin(getSdrModelFromSdrPage().GetLayerAdmin());
530 // background objects of the master page
531 pSdrObj->SetLayer( rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects) );
534 // Subscribe object at the style sheet
535 // Set style only when one was found (as in 5.2)
536 if( mePageKind != PageKind::Handout )
538 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind);
539 if(pSheetForPresObj)
540 pSdrObj->SetStyleSheet(pSheetForPresObj, false);
543 if (eObjKind == PRESOBJ_OUTLINE)
545 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
547 OUString aName( maLayoutName + " " + OUString::number( nLevel ) );
548 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page));
549 DBG_ASSERT(pSheet, "StyleSheet for outline object not found");
550 if (pSheet)
551 pSdrObj->StartListening(*pSheet, DuplicateHandling::Allow);
555 if ( eObjKind == PRESOBJ_OBJECT ||
556 eObjKind == PRESOBJ_CHART ||
557 eObjKind == PRESOBJ_ORGCHART ||
558 eObjKind == PRESOBJ_CALC ||
559 eObjKind == PRESOBJ_GRAPHIC )
561 SfxItemSet aSet( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
562 aSet.Put( makeSdrTextContourFrameItem( true ) );
563 aSet.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
565 pSdrObj->SetMergedItemSet(aSet);
568 if( bUndo )
570 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
572 pUndoManager->AddUndoAction( std::make_unique<UndoObjectPresentationKind>( *pSdrObj ) );
573 pUndoManager->AddUndoAction( std::make_unique<UndoObjectUserCall>(*pSdrObj) );
576 InsertPresObj(pSdrObj, eObjKind);
577 pSdrObj->SetUserCall(this);
579 pSdrObj->RecalcBoundRect();
582 return pSdrObj;
585 /*************************************************************************
587 |* Creates presentation objects on the master page.
588 |* All presentation objects get a UserCall to the page.
590 \************************************************************************/
592 SfxStyleSheet* SdPage::GetStyleSheetForMasterPageBackground() const
594 OUString aName(GetLayoutName());
595 OUString aSep( SD_LT_SEPARATOR );
596 sal_Int32 nPos = aName.indexOf(aSep);
598 if (nPos != -1)
600 nPos = nPos + aSep.getLength();
601 aName = aName.copy(0, nPos);
604 aName += STR_LAYOUT_BACKGROUND;
606 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
607 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SfxStyleFamily::Page);
608 return static_cast<SfxStyleSheet*>(pResult);
611 SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const
613 OUString aName(GetLayoutName());
614 OUString aSep( SD_LT_SEPARATOR );
615 sal_Int32 nPos = aName.indexOf(aSep);
616 if (nPos != -1)
618 nPos = nPos + aSep.getLength();
619 aName = aName.copy(0, nPos);
622 switch (eObjKind)
624 case PRESOBJ_OUTLINE:
626 aName = GetLayoutName() + " " + OUString::number( 1 );
628 break;
630 case PRESOBJ_TITLE:
631 aName += STR_LAYOUT_TITLE;
632 break;
634 case PRESOBJ_NOTES:
635 aName += STR_LAYOUT_NOTES;
636 break;
638 case PRESOBJ_TEXT:
639 aName += STR_LAYOUT_SUBTITLE;
640 break;
642 case PRESOBJ_HEADER:
643 case PRESOBJ_FOOTER:
644 case PRESOBJ_DATETIME:
645 case PRESOBJ_SLIDENUMBER:
646 aName += STR_LAYOUT_BACKGROUNDOBJECTS;
647 break;
649 default:
650 break;
653 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
654 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SfxStyleFamily::Page);
655 return static_cast<SfxStyleSheet*>(pResult);
658 /** returns the presentation style with the given helpid from this masterpage or this
659 slides masterpage */
660 SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
662 OUString aStyleName( GetLayoutName() );
663 const OUString aSep( SD_LT_SEPARATOR );
664 sal_Int32 nIndex = aStyleName.indexOf(aSep);
665 if( nIndex != -1 )
666 aStyleName = aStyleName.copy(0, nIndex + aSep.getLength());
668 const char *pNameId;
669 bool bOutline = false;
670 switch( nHelpId )
672 case HID_PSEUDOSHEET_TITLE: pNameId = STR_LAYOUT_TITLE; break;
673 case HID_PSEUDOSHEET_SUBTITLE: pNameId = STR_LAYOUT_SUBTITLE; break;
674 case HID_PSEUDOSHEET_OUTLINE1:
675 case HID_PSEUDOSHEET_OUTLINE2:
676 case HID_PSEUDOSHEET_OUTLINE3:
677 case HID_PSEUDOSHEET_OUTLINE4:
678 case HID_PSEUDOSHEET_OUTLINE5:
679 case HID_PSEUDOSHEET_OUTLINE6:
680 case HID_PSEUDOSHEET_OUTLINE7:
681 case HID_PSEUDOSHEET_OUTLINE8:
682 case HID_PSEUDOSHEET_OUTLINE9: pNameId = STR_LAYOUT_OUTLINE; bOutline = true; break;
683 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: pNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break;
684 case HID_PSEUDOSHEET_BACKGROUND: pNameId = STR_LAYOUT_BACKGROUND; break;
685 case HID_PSEUDOSHEET_NOTES: pNameId = STR_LAYOUT_NOTES; break;
687 default:
688 OSL_FAIL( "SdPage::getPresentationStyle(), illegal argument!" );
689 return nullptr;
691 aStyleName += OUString::createFromAscii(pNameId);
692 if (bOutline)
694 aStyleName += " " +
695 OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ));
698 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
699 SfxStyleSheetBase* pResult = pStShPool->Find(aStyleName, SfxStyleFamily::Page);
700 return dynamic_cast<SdStyleSheet*>(pResult);
703 /*************************************************************************
705 |* The presentation object rObj has changed and is no longer referenced by the
706 |* presentation object of the master page.
707 |* The UserCall is deleted.
709 \************************************************************************/
711 void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools::Rectangle& )
713 if (maLockAutoLayoutArrangement.isLocked())
714 return;
716 switch (eType)
718 case SdrUserCallType::MoveOnly:
719 case SdrUserCallType::Resize:
721 if ( getSdrModelFromSdrPage().isLocked())
722 break;
724 if (!mbMaster)
726 if (rObj.GetUserCall())
728 SdrObject& _rObj = const_cast<SdrObject&>(rObj);
729 SfxUndoManager* pUndoManager
730 = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
731 .GetUndoManager();
732 const bool bUndo
733 = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
735 if (bUndo)
736 pUndoManager->AddUndoAction(
737 std::make_unique<UndoObjectUserCall>(_rObj));
739 // Object was resized by user and does not listen to its slide anymore
740 _rObj.SetUserCall(nullptr);
743 else
745 // Object of the master page changed, therefore adjust
746 // object on all pages
747 sal_uInt16 nPageCount = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
748 .GetSdPageCount(mePageKind);
750 for (sal_uInt16 i = 0; i < nPageCount; i++)
752 SdPage* pLoopPage = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
753 .GetSdPage(i, mePageKind);
755 if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
757 // Page listens to this master page, therefore
758 // adjust AutoLayout
759 pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
764 break;
766 case SdrUserCallType::Delete:
767 case SdrUserCallType::Removed:
768 default:
769 break;
773 /*************************************************************************
775 |* Creates on a master page: background, title- and layout area
777 \************************************************************************/
779 void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
781 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
782 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
784 SdPage* pMasterPage = this;
786 if (!mbMaster)
788 pMasterPage = static_cast<SdPage*>(&(TRG_GetMasterPage()));
791 if (!pMasterPage)
793 return;
796 /**************************************************************************
797 * create background, title- and layout area
798 **************************************************************************/
799 if( mePageKind == PageKind::Standard )
801 pMasterPage->EnsureMasterPageDefaultBackground();
804 if (static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocumentType() != DocumentType::Impress)
805 return;
807 if( mePageKind == PageKind::Handout && bInit )
809 // handout template
811 // delete all available handout presentation objects
812 SdrObject *pObj=nullptr;
813 while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != nullptr )
815 pMasterPage->RemoveObject(pObj->GetOrdNum());
817 if( bUndo )
819 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
821 else
823 SdrObject::Free( pObj );
827 std::vector< ::tools::Rectangle > aAreas;
828 CalculateHandoutAreas( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()), pMasterPage->GetAutoLayout(), false, aAreas );
830 const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
831 std::vector< ::tools::Rectangle >::iterator iter( aAreas.begin() );
833 while( iter != aAreas.end() )
835 SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, false, (*iter++)) );
836 // #i105146# We want no content to be displayed for PageKind::Handout,
837 // so just never set a page as content
838 pPageObj->SetReferencedPage(nullptr);
840 if( bSkip && iter != aAreas.end() )
841 ++iter;
845 if( mePageKind != PageKind::Handout )
847 SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE );
848 if( pMasterTitle == nullptr )
849 pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE);
851 SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PageKind::Notes ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
852 if( pMasterOutline == nullptr )
853 pMasterPage->CreateDefaultPresObj( mePageKind == PageKind::Standard ? PRESOBJ_OUTLINE : PRESOBJ_NOTES );
856 // create header&footer objects
858 if( !bCreate )
859 return;
861 if( mePageKind != PageKind::Standard )
863 SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER );
864 if( pHeader == nullptr )
865 pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER );
868 SdrObject* pDate = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
869 if( pDate == nullptr )
870 pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME );
872 SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
873 if( pFooter == nullptr )
874 pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER );
876 SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
877 if( pNumber == nullptr )
878 pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER );
881 namespace {
883 static const o3tl::enumarray<PageKind, char const *> PageKindVector = {
884 "PageKind::Standard", "PageKind::Notes", "PageKind::Handout"
887 const char* const PresObjKindVector[] = {
888 "PRESOBJ_NONE", "PRESOBJ_TITLE", "PRESOBJ_OUTLINE",
889 "PRESOBJ_TEXT" ,"PRESOBJ_GRAPHIC" , "PRESOBJ_OBJECT",
890 "PRESOBJ_CHART", "PRESOBJ_ORGCHART", "PRESOBJ_TABLE",
891 "PRESOBJ_PAGE", "PRESOBJ_HANDOUT",
892 "PRESOBJ_NOTES","PRESOBJ_HEADER", "PRESOBJ_FOOTER",
893 "PRESOBJ_DATETIME", "PRESOBJ_SLIDENUMBER", "PRESOBJ_CALC",
894 "PRESOBJ_MEDIA", "PRESOBJ_MAX"
897 void getPresObjProp( const SdPage& rPage, const char* sObjKind, const char* sPageKind, double presObjPropValue[] )
899 bool bNoObjectFound = true; //used to break from outer loop
901 const std::vector< Reference<XNode> >& objectInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetObjectVector();
902 for( const Reference<XNode>& objectNode : objectInfo )
904 if(bNoObjectFound)
906 Reference<XNamedNodeMap> objectattrlist = objectNode->getAttributes();
907 Reference<XNode> objectattr = objectattrlist->getNamedItem("type");
908 OUString sObjType = objectattr->getNodeValue();
910 if (sObjType.equalsAscii(sObjKind))
912 Reference<XNodeList> objectChildren = objectNode->getChildNodes();
913 const int objSize = objectChildren->getLength();
915 for( int j=0; j< objSize; j++)
917 Reference<XNode> obj = objectChildren->item(j);
918 OUString nodename = obj->getNodeName();
920 //check whether child is blank 'text-node' or 'object-prop' node
921 if(nodename == "object-prop")
923 Reference<XNamedNodeMap> ObjAttributes = obj->getAttributes();
924 Reference<XNode> ObjPageKind = ObjAttributes->getNamedItem("pagekind");
925 OUString sObjPageKind = ObjPageKind->getNodeValue();
927 if (sObjPageKind.equalsAscii(sPageKind))
929 Reference<XNode> ObjSizeHeight = ObjAttributes->getNamedItem("relative-height");
930 OUString sValue = ObjSizeHeight->getNodeValue();
931 presObjPropValue[0] = sValue.toDouble();
933 Reference<XNode> ObjSizeWidth = ObjAttributes->getNamedItem("relative-width");
934 sValue = ObjSizeWidth->getNodeValue();
935 presObjPropValue[1] = sValue.toDouble();
937 Reference<XNode> ObjPosX = ObjAttributes->getNamedItem("relative-posX");
938 sValue = ObjPosX->getNodeValue();
939 presObjPropValue[2] = sValue.toDouble();
941 Reference<XNode> ObjPosY = ObjAttributes->getNamedItem("relative-posY");
942 sValue = ObjPosY->getNodeValue();
943 presObjPropValue[3] = sValue.toDouble();
945 bNoObjectFound = false;
946 break;
952 else
953 break;
959 SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind)
961 if( eObjKind == PRESOBJ_TITLE )
963 ::tools::Rectangle aTitleRect( GetTitleRect() );
964 return CreatePresObj(PRESOBJ_TITLE, false, aTitleRect);
966 else if( eObjKind == PRESOBJ_OUTLINE )
968 ::tools::Rectangle aLayoutRect( GetLayoutRect() );
969 return CreatePresObj( PRESOBJ_OUTLINE, false, aLayoutRect);
971 else if( eObjKind == PRESOBJ_NOTES )
973 ::tools::Rectangle aLayoutRect( GetLayoutRect() );
974 return CreatePresObj( PRESOBJ_NOTES, false, aLayoutRect);
976 else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) )
978 double propvalue[] = {0,0,0,0};
979 const char* sObjKind = PresObjKindVector[eObjKind];
980 const char* sPageKind = PageKindVector[mePageKind];
981 // create footer objects for standard master page
982 if( mePageKind == PageKind::Standard )
984 const long nLftBorder = GetLeftBorder();
985 const long nUppBorder = GetUpperBorder();
987 Point aPos ( nLftBorder, nUppBorder );
988 Size aSize ( GetSize() );
990 aSize.AdjustWidth( -(nLftBorder + GetRightBorder()) );
991 aSize.AdjustHeight( -(nUppBorder + GetLowerBorder()) );
993 getPresObjProp( *this, sObjKind, sPageKind, propvalue);
994 aPos.AdjustX(long( aSize.Width() * propvalue[2] ) );
995 aPos.AdjustY(long( aSize.Height() * propvalue[3] ) );
996 aSize.setWidth( long( aSize.Width() * propvalue[1] ) );
997 aSize.setHeight( long( aSize.Height() * propvalue[0] ) );
999 if(eObjKind == PRESOBJ_HEADER )
1001 OSL_FAIL( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a master slide" );
1002 return nullptr;
1004 else
1006 ::tools::Rectangle aRect( aPos, aSize );
1007 return CreatePresObj( eObjKind, false, aRect );
1010 else
1012 // create header&footer objects for handout and notes master
1013 Size aPageSize ( GetSize() );
1014 aPageSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1015 aPageSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1017 Point aPosition ( GetLeftBorder(), GetUpperBorder() );
1019 getPresObjProp( *this, sObjKind, sPageKind, propvalue);
1020 int NOTES_HEADER_FOOTER_WIDTH = long(aPageSize.Width() * propvalue[1]);
1021 int NOTES_HEADER_FOOTER_HEIGHT = long(aPageSize.Height() * propvalue[0]);
1022 Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
1023 Point aPos ( 0 ,0 );
1024 if( propvalue[2] == 0 )
1025 aPos.setX( aPosition.X() );
1026 else
1027 aPos.setX( aPosition.X() + long( aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH ) );
1028 if( propvalue[3] == 0 )
1029 aPos.setY( aPosition.Y() );
1030 else
1031 aPos.setY( aPosition.Y() + long( aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT ) );
1033 ::tools::Rectangle aRect( aPos, aSize );
1034 return CreatePresObj( eObjKind, false, aRect );
1037 else
1039 OSL_FAIL("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
1040 return nullptr;
1044 void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
1046 SdrObject* pObject = GetPresObj( eObjKind );
1048 if( pObject )
1050 SdDrawDocument* pDoc(static_cast< SdDrawDocument* >(&getSdrModelFromSdrPage()));
1051 const bool bUndo = pDoc->IsUndoEnabled();
1052 if( bUndo )
1053 pDoc->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
1054 SdrObjList* pOL = pObject->getParentSdrObjListFromSdrObject();
1055 pOL->RemoveObject(pObject->GetOrdNumDirect());
1057 if( !bUndo )
1058 SdrObject::Free(pObject);
1062 /*************************************************************************
1064 |* return title area
1066 \************************************************************************/
1068 ::tools::Rectangle SdPage::GetTitleRect() const
1070 ::tools::Rectangle aTitleRect;
1072 if (mePageKind != PageKind::Handout)
1074 double propvalue[] = {0,0,0,0};
1076 /******************************************************************
1077 * standard- or note page: title area
1078 ******************************************************************/
1079 Point aTitlePos ( GetLeftBorder(), GetUpperBorder() );
1080 Size aTitleSize ( GetSize() );
1081 aTitleSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1082 aTitleSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1083 const char* sPageKind = PageKindVector[mePageKind];
1085 if (mePageKind == PageKind::Standard)
1087 getPresObjProp( *this , "PRESOBJ_TITLE" ,sPageKind, propvalue);
1088 aTitlePos.AdjustX(long( aTitleSize.Width() * propvalue[2] ) );
1089 aTitlePos.AdjustY(long( aTitleSize.Height() * propvalue[3] ) );
1090 aTitleSize.setWidth( long( aTitleSize.Width() * propvalue[1] ) );
1091 aTitleSize.setHeight( long( aTitleSize.Height() * propvalue[0] ) );
1093 else if (mePageKind == PageKind::Notes)
1095 Point aPos = aTitlePos;
1096 getPresObjProp( *this, "PRESOBJ_TITLE" ,sPageKind, propvalue);
1097 aPos.AdjustX(long( aTitleSize.Width() * propvalue[2] ) );
1098 aPos.AdjustY(long( aTitleSize.Height() * propvalue[3] ) );
1100 // limit height
1101 aTitleSize.setHeight( long( aTitleSize.Height() * propvalue[0] ) );
1102 aTitleSize.setWidth( long( aTitleSize.Width() * propvalue[1] ) );
1104 Size aPartArea = aTitleSize;
1105 Size aSize;
1106 sal_uInt16 nDestPageNum(GetPageNum());
1107 SdrPage* pRefPage = nullptr;
1109 if(nDestPageNum)
1111 // only decrement if != 0, else we get 0xffff
1112 nDestPageNum -= 1;
1115 if(nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
1117 pRefPage = getSdrModelFromSdrPage().GetPage(nDestPageNum);
1120 if ( pRefPage )
1122 // scale actually page size into handout rectangle
1123 double fH = pRefPage->GetWidth() == 0
1124 ? 0 : static_cast<double>(aPartArea.Width()) / pRefPage->GetWidth();
1125 double fV = pRefPage->GetHeight() == 0
1126 ? 0 : static_cast<double>(aPartArea.Height()) / pRefPage->GetHeight();
1128 if ( fH > fV )
1129 fH = fV;
1130 aSize.setWidth( static_cast<long>(fH * pRefPage->GetWidth()) );
1131 aSize.setHeight( static_cast<long>(fH * pRefPage->GetHeight()) );
1133 aPos.AdjustX((aPartArea.Width() - aSize.Width()) / 2 );
1134 aPos.AdjustY((aPartArea.Height()- aSize.Height())/ 2 );
1137 aTitlePos = aPos;
1138 aTitleSize = aSize;
1141 aTitleRect.SetPos(aTitlePos);
1142 aTitleRect.SetSize(aTitleSize);
1145 return aTitleRect;
1148 /*************************************************************************
1150 |* return outline area
1152 \************************************************************************/
1154 ::tools::Rectangle SdPage::GetLayoutRect() const
1156 ::tools::Rectangle aLayoutRect;
1158 if (mePageKind != PageKind::Handout)
1160 double propvalue[] = {0,0,0,0};
1162 Point aLayoutPos ( GetLeftBorder(), GetUpperBorder() );
1163 Size aLayoutSize ( GetSize() );
1164 aLayoutSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1165 aLayoutSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1166 const char* sPageKind = PageKindVector[mePageKind];
1168 if (mePageKind == PageKind::Standard)
1170 getPresObjProp( *this ,"PRESOBJ_OUTLINE", sPageKind, propvalue);
1171 aLayoutPos.AdjustX(long( aLayoutSize.Width() * propvalue[2] ) );
1172 aLayoutPos.AdjustY(long( aLayoutSize.Height() * propvalue[3] ) );
1173 aLayoutSize.setWidth( long( aLayoutSize.Width() * propvalue[1] ) );
1174 aLayoutSize.setHeight( long( aLayoutSize.Height() * propvalue[0] ) );
1175 aLayoutRect.SetPos(aLayoutPos);
1176 aLayoutRect.SetSize(aLayoutSize);
1178 else if (mePageKind == PageKind::Notes)
1180 getPresObjProp( *this, "PRESOBJ_NOTES", sPageKind, propvalue);
1181 aLayoutPos.AdjustX(long( aLayoutSize.Width() * propvalue[2] ) );
1182 aLayoutPos.AdjustY(long( aLayoutSize.Height() * propvalue[3] ) );
1183 aLayoutSize.setWidth( long( aLayoutSize.Width() * propvalue[1] ) );
1184 aLayoutSize.setHeight( long( aLayoutSize.Height() * propvalue[0] ) );
1185 aLayoutRect.SetPos(aLayoutPos);
1186 aLayoutRect.SetSize(aLayoutSize);
1190 return aLayoutRect;
1193 /**************************************************************************
1195 |* assign an AutoLayout
1197 \*************************************************************************/
1199 const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout
1200 const int VERTICAL = 0x8000;
1202 struct LayoutDescriptor
1204 PresObjKind meKind[MAX_PRESOBJS];
1205 bool mbVertical[MAX_PRESOBJS];
1207 LayoutDescriptor( int k0 = 0, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0, int k5 = 0, int k6 = 0 );
1210 LayoutDescriptor::LayoutDescriptor( int k0, int k1, int k2, int k3, int k4, int k5, int k6 )
1212 meKind[0] = static_cast<PresObjKind>(k0 & (~VERTICAL)); mbVertical[0] = (k0 & VERTICAL) == VERTICAL;
1213 meKind[1] = static_cast<PresObjKind>(k1 & (~VERTICAL)); mbVertical[1] = (k1 & VERTICAL) == VERTICAL;
1214 meKind[2] = static_cast<PresObjKind>(k2 & (~VERTICAL)); mbVertical[2] = (k2 & VERTICAL) == VERTICAL;
1215 meKind[3] = static_cast<PresObjKind>(k3 & (~VERTICAL)); mbVertical[3] = (k3 & VERTICAL) == VERTICAL;
1216 meKind[4] = static_cast<PresObjKind>(k4 & (~VERTICAL)); mbVertical[4] = (k4 & VERTICAL) == VERTICAL;
1217 meKind[5] = static_cast<PresObjKind>(k5 & (~VERTICAL)); mbVertical[5] = (k5 & VERTICAL) == VERTICAL;
1218 meKind[6] = static_cast<PresObjKind>(k6 & (~VERTICAL)); mbVertical[6] = (k6 & VERTICAL) == VERTICAL;
1221 static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
1223 static const LayoutDescriptor aLayouts[AUTOLAYOUT_END-AUTOLAYOUT_START] =
1225 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_TEXT ), // AUTOLAYOUT_TITLE
1226 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_CONTENT
1227 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHART
1228 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_2CONTENT
1229 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTCHART
1230 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_ORG
1231 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTCLbIP
1232 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHARTTEXT
1233 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TAB
1234 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CLIPTEXT
1235 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ
1236 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OBJECT ), // AUTOLAYOUT_OBJ
1237 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_CONTENT_2CONTENT
1238 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ
1239 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT
1240 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_2CONTENT_CONTENT
1241 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT
1242 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOVEROBJ
1243 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_TITLE_4CONTENT
1244 PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),
1245 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_NONE ), // AUTOLAYOUT_TITLE_ONLY
1246 LayoutDescriptor( PRESOBJ_NONE ), // AUTOLAYOUT_NONE
1247 LayoutDescriptor( PRESOBJ_PAGE, PRESOBJ_NOTES ), // AUTOLAYOUT_NOTES
1248 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT1
1249 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT2
1250 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT3
1251 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT4
1252 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT6
1253 LayoutDescriptor( PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE ),// AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT
1254 LayoutDescriptor( PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_VTITLE_VCONTENT
1255 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_VCONTENT
1256 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_2VTEXT
1257 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT9
1258 LayoutDescriptor( PRESOBJ_TEXT, PRESOBJ_NONE ), // AUTOLAYOUT_ONLY_TEXT
1259 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_4CLIPART
1260 PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC ),
1261 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_TITLE_6CONTENT
1262 PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE )
1265 if( (eLayout < AUTOLAYOUT_START) || (eLayout >= AUTOLAYOUT_END) )
1266 eLayout = AUTOLAYOUT_NONE;
1268 return aLayouts[ eLayout - AUTOLAYOUT_START ];
1271 static OUString enumtoString(AutoLayout aut)
1273 OUString retstr;
1274 switch (aut)
1276 case AUTOLAYOUT_TITLE_CONTENT:
1277 retstr="AUTOLAYOUT_TITLE_CONTENT";
1278 break;
1279 case AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT:
1280 retstr="AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT";
1281 break;
1282 case AUTOLAYOUT_TITLE_CONTENT_2CONTENT:
1283 retstr="AUTOLAYOUT_TITLE_CONTENT_2CONTENT";
1284 break;
1285 case AUTOLAYOUT_TITLE_4CONTENT:
1286 retstr="AUTOLAYOUT_TITLE_4CONTENT";
1287 break;
1288 case AUTOLAYOUT_ONLY_TEXT:
1289 retstr="AUTOLAYOUT_ONLY_TEXT";
1290 break;
1291 case AUTOLAYOUT_TITLE_ONLY:
1292 retstr="AUTOLAYOUT_TITLE_ONLY";
1293 break;
1294 case AUTOLAYOUT_TITLE_6CONTENT:
1295 retstr="AUTOLAYOUT_TITLE_6CONTENT";
1296 break;
1297 case AUTOLAYOUT_START:
1298 retstr="AUTOLAYOUT_START";
1299 break;
1300 case AUTOLAYOUT_TITLE_2CONTENT_CONTENT:
1301 retstr="AUTOLAYOUT_TITLE_2CONTENT_CONTENT";
1302 break;
1303 case AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT:
1304 retstr="AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT";
1305 break;
1306 case AUTOLAYOUT_TITLE_2CONTENT:
1307 retstr="AUTOLAYOUT_TITLE_2CONTENT";
1308 break;
1309 case AUTOLAYOUT_VTITLE_VCONTENT:
1310 retstr="AUTOLAYOUT_VTITLE_VCONTENT";
1311 break;
1312 case AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT:
1313 retstr="AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT";
1314 break;
1315 case AUTOLAYOUT_TITLE_VCONTENT:
1316 retstr="AUTOLAYOUT_TITLE_VCONTENT";
1317 break;
1318 case AUTOLAYOUT_TITLE_2VTEXT:
1319 retstr="AUTOLAYOUT_TITLE_2VTEXT";
1320 break;
1321 default:
1322 retstr="unknown";
1323 break;
1324 // case AUTOLAYOUT_TITLE_4SCONTENT: return "AUTOLAYOUT_TITLE_4SCONTENT";
1326 return retstr;
1329 static void CalcAutoLayoutRectangles( SdPage const & rPage,::tools::Rectangle* rRectangle ,const OUString& sLayoutType )
1331 ::tools::Rectangle aTitleRect;
1332 ::tools::Rectangle aLayoutRect;
1334 if( rPage.GetPageKind() != PageKind::Handout )
1336 SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage());
1337 SdrObject* pMasterTitle = rMasterPage.GetPresObj( PRESOBJ_TITLE );
1338 SdrObject* pMasterSubTitle = rMasterPage.GetPresObj( PRESOBJ_TEXT );
1339 SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PageKind::Notes ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
1341 if( pMasterTitle )
1342 aTitleRect = pMasterTitle->GetLogicRect();
1344 if (aTitleRect.IsEmpty() )
1345 aTitleRect = rPage.GetTitleRect();
1346 if( pMasterSubTitle )
1347 aLayoutRect = pMasterSubTitle->GetLogicRect();
1348 else if( pMasterOutline )
1349 aLayoutRect = pMasterOutline->GetLogicRect();
1351 if (aLayoutRect.IsEmpty() )
1352 aLayoutRect = rPage.GetLayoutRect();
1355 rRectangle[0] = aTitleRect;
1356 for( int i = 1; i < MAX_PRESOBJS; i++ )
1357 rRectangle[i] = aLayoutRect;
1359 const Point aTitlePos( aTitleRect.TopLeft() );
1360 const Size aLayoutSize( aLayoutRect.GetSize() );
1361 const Point aLayoutPos( aLayoutRect.TopLeft() );
1362 double propvalue[] = {0,0,0,0};
1364 const std::vector< Reference<XNode> >& layoutInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetLayoutVector();
1365 auto aIter = std::find_if(layoutInfo.begin(), layoutInfo.end(),
1366 [&sLayoutType](const Reference<XNode>& layoutNode) {
1367 Reference<XNamedNodeMap> layoutAttrList = layoutNode->getAttributes();
1369 // get the attribute value of layout (i.e it's type)
1370 OUString sLayoutAttName = layoutAttrList->getNamedItem("type")->getNodeValue();
1371 return sLayoutAttName == sLayoutType;
1373 if (aIter == layoutInfo.end())
1374 return;
1376 int count=0;
1377 Reference<XNode> layoutNode = *aIter;
1378 Reference<XNodeList> layoutChildren = layoutNode->getChildNodes();
1379 const int presobjsize = layoutChildren->getLength();
1380 for( int j=0; j< presobjsize ; j++)
1382 OUString nodename;
1383 Reference<XNode> presobj = layoutChildren->item(j);
1384 nodename=presobj->getNodeName();
1386 //check whether child is blank 'text-node' or 'presobj' node
1387 if(nodename == "presobj")
1389 // TODO: rework sd to permit arbitrary number of presentation objects
1390 assert(count < MAX_PRESOBJS);
1392 Reference<XNamedNodeMap> presObjAttributes = presobj->getAttributes();
1394 Reference<XNode> presObjSizeHeight = presObjAttributes->getNamedItem("relative-height");
1395 OUString sValue = presObjSizeHeight->getNodeValue();
1396 propvalue[0] = sValue.toDouble();
1398 Reference<XNode> presObjSizeWidth = presObjAttributes->getNamedItem("relative-width");
1399 sValue = presObjSizeWidth->getNodeValue();
1400 propvalue[1] = sValue.toDouble();
1402 Reference<XNode> presObjPosX = presObjAttributes->getNamedItem("relative-posX");
1403 sValue = presObjPosX->getNodeValue();
1404 propvalue[2] = sValue.toDouble();
1406 Reference<XNode> presObjPosY = presObjAttributes->getNamedItem("relative-posY");
1407 sValue = presObjPosY->getNodeValue();
1408 propvalue[3] = sValue.toDouble();
1410 if(count == 0)
1412 Size aSize ( aTitleRect.GetSize() );
1413 aSize.setHeight( basegfx::fround(aSize.Height() * propvalue[0]) );
1414 aSize.setWidth( basegfx::fround(aSize.Width() * propvalue[1]) );
1415 Point aPos( basegfx::fround(aTitlePos.X() +(aSize.Width() * propvalue[2])),
1416 basegfx::fround(aTitlePos.Y() + (aSize.Height() * propvalue[3])) );
1417 rRectangle[count] = ::tools::Rectangle(aPos, aSize);
1418 count = count+1;
1420 else
1422 Size aSize( basegfx::fround(aLayoutSize.Width() * propvalue[1]),
1423 basegfx::fround(aLayoutSize.Height() * propvalue[0]) );
1424 Point aPos( basegfx::fround(aLayoutPos.X() +(aSize.Width() * propvalue[2])),
1425 basegfx::fround(aLayoutPos.Y() + (aSize.Height() * propvalue[3])) );
1426 rRectangle[count] = ::tools::Rectangle (aPos, aSize);
1427 count = count+1;
1433 static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::vector< SdrObject* >& rShapes, bool bInit, bool bSwitchLayout )
1435 int i;
1437 // init list of indexes for each presentation shape kind
1438 // this is used to find subsequent shapes with the same presentation shape kind
1439 int PresObjIndex[PRESOBJ_MAX];
1440 for( i = 0; i < PRESOBJ_MAX; i++ ) PresObjIndex[i] = 1;
1442 bool bMissing = false;
1444 // for each entry in the layoutdescriptor, arrange a presentation shape
1445 for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1447 PresObjKind eKind = rDescriptor.meKind[i];
1448 SdrObject* pObj = nullptr;
1449 while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != nullptr )
1451 PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
1453 if( !bSwitchLayout || !pObj->IsEmptyPresObj() )
1455 rShapes[i] = pObj;
1456 break;
1460 if( !pObj )
1461 bMissing = true;
1464 if( !(bMissing && bInit) )
1465 return;
1467 // for each entry in the layoutdescriptor, look for an alternative shape
1468 for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1470 if( rShapes[i] )
1471 continue;
1473 PresObjKind eKind = rDescriptor.meKind[i];
1475 SdrObject* pObj = nullptr;
1476 bool bFound = false;
1478 const size_t nShapeCount = rPage.GetObjCount();
1479 for(size_t nShapeIndex = 0; nShapeIndex < nShapeCount && !bFound; ++nShapeIndex )
1481 pObj = rPage.GetObj(nShapeIndex);
1483 if( pObj->IsEmptyPresObj() )
1484 continue;
1486 if( pObj->GetObjInventor() != SdrInventor::Default )
1487 continue;
1489 // do not reuse shapes that are already part of the layout
1490 if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() )
1491 continue;
1493 bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SfxStyleFamily::Page);
1494 SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() );
1496 switch( eKind )
1498 case PRESOBJ_TITLE:
1499 bFound = eSdrObjKind == OBJ_TITLETEXT;
1500 break;
1501 case PRESOBJ_TABLE:
1502 bFound = eSdrObjKind == OBJ_TABLE;
1503 break;
1504 case PRESOBJ_MEDIA:
1505 bFound = eSdrObjKind == OBJ_MEDIA;
1506 break;
1507 case PRESOBJ_OUTLINE:
1508 bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
1509 ((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
1510 (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2);
1511 break;
1512 case PRESOBJ_GRAPHIC:
1513 bFound = eSdrObjKind == OBJ_GRAF;
1514 break;
1515 case PRESOBJ_OBJECT:
1516 if( eSdrObjKind == OBJ_OLE2 )
1518 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1519 if( pOle2 )
1521 if( pOle2->IsEmpty() )
1522 bFound = true;
1523 else
1525 ::comphelper::IEmbeddedHelper* pPersist(rPage.getSdrModelFromSdrPage().GetPersist());
1527 if( pPersist )
1529 uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
1530 GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
1532 // TODO CL->KA: Why is this not working anymore?
1533 if( xObject.is() )
1535 SvGlobalName aClassId( xObject->getClassID() );
1537 const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
1538 const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
1539 const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
1541 if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
1543 bFound = true;
1550 break;
1551 case PRESOBJ_CHART:
1552 case PRESOBJ_CALC:
1553 if( eSdrObjKind == OBJ_OLE2 )
1555 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1556 if( pOle2 )
1559 ((eKind == PRESOBJ_CHART) &&
1560 ( pOle2->GetProgName() == "StarChart" || pOle2->IsChart() ) )
1562 ((eKind == PRESOBJ_CALC) &&
1563 ( pOle2->GetProgName() == "StarCalc" || pOle2->IsCalc() ) ) )
1565 bFound = true;
1568 break;
1570 else if( eSdrObjKind == OBJ_TABLE )
1572 bFound = true;
1574 break;
1575 case PRESOBJ_PAGE:
1576 case PRESOBJ_HANDOUT:
1577 bFound = eSdrObjKind == OBJ_PAGE;
1578 break;
1579 case PRESOBJ_NOTES:
1580 case PRESOBJ_TEXT:
1581 bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT);
1582 break;
1583 default:
1584 break;
1588 if( bFound )
1589 rShapes[i] = pObj;
1593 void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
1595 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1597 const bool bSwitchLayout = eLayout != GetAutoLayout();
1599 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
1600 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
1602 meAutoLayout = eLayout;
1604 // if needed, creates and initialises the presentation shapes on this slides master page
1605 CreateTitleAndLayout(bInit, bCreate);
1607 if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster)
1609 // MasterPage or no layout and no presentation shapes available, nothing to do
1610 return;
1613 ::tools::Rectangle aRectangle[MAX_PRESOBJS];
1614 const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
1615 OUString sLayoutName( enumtoString(meAutoLayout) );
1616 CalcAutoLayoutRectangles( *this, aRectangle, sLayoutName);
1618 std::set< SdrObject* > aUsedPresentationObjects;
1620 std::vector< SdrObject* > aLayoutShapes(PRESOBJ_MAX, nullptr);
1621 findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
1623 int i;
1625 // for each entry in the layoutdescriptor, arrange a presentation shape
1626 for (i = 0; (i < MAX_PRESOBJS) && (aDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1628 PresObjKind eKind = aDescriptor.meKind[i];
1629 SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );
1630 if( pObj )
1631 aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape
1634 // now delete all empty presentation objects that are no longer used by the new layout
1635 if( !bInit )
1636 return;
1638 SdrObject* pObj = nullptr;
1639 maPresentationShapeList.seekShape(0);
1641 while( (pObj = maPresentationShapeList.getNextShape()) )
1643 if( aUsedPresentationObjects.count(pObj) == 0 )
1646 if( pObj->IsEmptyPresObj() )
1648 if( bUndo )
1649 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
1651 RemoveObject( pObj->GetOrdNum() );
1653 if( !bUndo )
1654 SdrObject::Free( pObj );
1656 /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */
1661 /*************************************************************************
1663 |* insert object
1665 \************************************************************************/
1667 void SdPage::NbcInsertObject(SdrObject* pObj, size_t nPos)
1669 FmFormPage::NbcInsertObject(pObj, nPos);
1671 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).InsertObject(pObj);
1673 SdrLayerID nId = pObj->GetLayer();
1674 if( mbMaster )
1676 if( nId == SdrLayerID(0) )
1677 pObj->NbcSetLayer( SdrLayerID(2) ); // wrong layer. corrected to BackgroundObj layer
1679 else
1681 if( nId == SdrLayerID(2) )
1682 pObj->NbcSetLayer( SdrLayerID(0) ); // wrong layer. corrected to layout layer
1686 /*************************************************************************
1688 |* remove object
1690 \************************************************************************/
1692 SdrObject* SdPage::RemoveObject(size_t nObjNum)
1694 onRemoveObject(GetObj( nObjNum ));
1695 return FmFormPage::RemoveObject(nObjNum);
1698 /*************************************************************************
1700 |* remove object without broadcast
1702 \************************************************************************/
1704 SdrObject* SdPage::NbcRemoveObject(size_t nObjNum)
1706 onRemoveObject(GetObj( nObjNum ));
1707 return FmFormPage::NbcRemoveObject(nObjNum);
1710 // Also override ReplaceObject methods to realize when
1711 // objects are removed with this mechanism instead of RemoveObject
1712 SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
1714 onRemoveObject(GetObj( nObjNum ));
1715 return FmFormPage::ReplaceObject(pNewObj, nObjNum);
1718 // called after a shape is removed or replaced from this slide
1720 void SdPage::onRemoveObject( SdrObject* pObject )
1722 if( pObject )
1724 RemovePresObj(pObject);
1726 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).RemoveObject(pObject);
1728 removeAnimations( pObject );
1732 void SdPage::SetSize(const Size& aSize)
1734 Size aOldSize = GetSize();
1736 if (aSize != aOldSize)
1738 FmFormPage::SetSize(aSize);
1742 void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
1744 if (nLft != GetLeftBorder() || nUpp != GetUpperBorder() ||
1745 nRgt != GetRightBorder() || nLwr != GetLowerBorder() )
1747 FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
1751 void SdPage::SetLeftBorder(sal_Int32 nBorder)
1753 if (nBorder != GetLeftBorder() )
1755 FmFormPage::SetLeftBorder(nBorder);
1759 void SdPage::SetRightBorder(sal_Int32 nBorder)
1761 if (nBorder != GetRightBorder() )
1763 FmFormPage::SetRightBorder(nBorder);
1767 void SdPage::SetUpperBorder(sal_Int32 nBorder)
1769 if (nBorder != GetUpperBorder() )
1771 FmFormPage::SetUpperBorder(nBorder);
1775 void SdPage::SetLowerBorder(sal_Int32 nBorder)
1777 if (nBorder != GetLowerBorder() )
1779 FmFormPage::SetLowerBorder(nBorder);
1783 /*************************************************************************
1785 |* Sets BackgroundFullSize and then calls AdjustBackground
1787 \************************************************************************/
1789 void SdPage::SetBackgroundFullSize( bool bIn )
1791 if( bIn != mbBackgroundFullSize )
1793 mbBackgroundFullSize = bIn;
1797 /*************************************************************************
1799 |* Adjust all objects to new page size.
1801 |* bScaleAllObj: all objects are scaled into the new area within the page
1802 |* margins. We scale the position and size. For presentation objects on the
1803 |* master page, we also scale the font height of the presentation template.
1805 \************************************************************************/
1807 void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rNewBorderRect, bool bScaleAllObj)
1809 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1811 mbScaleObjects = bScaleAllObj;
1812 SdrObject* pObj = nullptr;
1813 Point aRefPnt(0, 0);
1814 Size aNewPageSize(rNewPageSize);
1815 sal_Int32 nLeft = rNewBorderRect.Left();
1816 sal_Int32 nRight = rNewBorderRect.Right();
1817 sal_Int32 nUpper = rNewBorderRect.Top();
1818 sal_Int32 nLower = rNewBorderRect.Bottom();
1820 // negative values are fixed values
1821 // -> use up to date values
1822 if (aNewPageSize.Width() < 0)
1824 aNewPageSize.setWidth( GetWidth() );
1826 if (aNewPageSize.Height() < 0)
1828 aNewPageSize.setHeight( GetHeight() );
1830 if (nLeft < 0)
1832 nLeft = GetLeftBorder();
1834 if (nRight < 0)
1836 nRight = GetRightBorder();
1838 if (nUpper < 0)
1840 nUpper = GetUpperBorder();
1842 if (nLower < 0)
1844 nLower = GetLowerBorder();
1847 Size aBackgroundSize(aNewPageSize);
1849 if (mbScaleObjects)
1851 aBackgroundSize.AdjustWidth( -(nLeft + nRight) );
1852 aBackgroundSize.AdjustHeight( -(nUpper + nLower) );
1853 aNewPageSize = aBackgroundSize;
1856 long nOldWidth = GetWidth() - GetLeftBorder() - GetRightBorder();
1857 long nOldHeight = GetHeight() - GetUpperBorder() - GetLowerBorder();
1859 Fraction aFractX(aNewPageSize.Width(), nOldWidth);
1860 Fraction aFractY(aNewPageSize.Height(), nOldHeight);
1862 const size_t nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
1864 for (size_t nObj = 0; nObj < nObjCnt; ++nObj)
1866 bool bIsPresObjOnMaster = false;
1868 // all Objects
1869 pObj = GetObj(nObj);
1871 if (mbMaster && IsPresObj(pObj))
1873 // There is a presentation object on the master page
1874 bIsPresObjOnMaster = true;
1877 if (pObj)
1879 // remember aTopLeft as original TopLeft
1880 Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
1882 if (!pObj->IsEdgeObj())
1884 /**************************************************************
1885 * Scale objects
1886 **************************************************************/
1887 if (mbScaleObjects)
1889 // use aTopLeft as original TopLeft
1890 aRefPnt = aTopLeft;
1893 pObj->Resize(aRefPnt, aFractX, aFractY);
1895 if (mbScaleObjects)
1897 SdrObjKind eObjKind = static_cast<SdrObjKind>(pObj->GetObjIdentifier());
1899 if (bIsPresObjOnMaster)
1901 /**********************************************************
1902 * presentation template: adjust test height
1903 **********************************************************/
1905 if (pObj == GetPresObj(PRESOBJ_TITLE, 0))
1907 SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
1909 if (pTitleSheet)
1911 SfxItemSet& rSet = pTitleSheet->GetItemSet();
1913 const SvxFontHeightItem& rOldHgt = rSet.Get(EE_CHAR_FONTHEIGHT);
1914 sal_uLong nFontHeight = rOldHgt.GetHeight();
1915 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1916 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1918 if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1920 const SvxFontHeightItem& rOldHgt2 = rSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1921 nFontHeight = rOldHgt2.GetHeight();
1922 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1923 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1926 if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1928 const SvxFontHeightItem& rOldHgt2 = rSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1929 nFontHeight = rOldHgt2.GetHeight();
1930 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1931 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1934 pTitleSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
1937 else if (pObj == GetPresObj(PRESOBJ_OUTLINE, 0))
1939 OUString aName(GetLayoutName() + " ");
1941 for (sal_Int32 i=1; i<=9; i++)
1943 OUString sLayoutName( aName + OUString::number( i ) );
1944 SfxStyleSheet* pOutlineSheet = static_cast<SfxStyleSheet*>(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetStyleSheetPool()->Find(sLayoutName, SfxStyleFamily::Page));
1946 if (pOutlineSheet)
1948 // Calculate new font height
1949 SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
1951 const SvxFontHeightItem& rOldHgt = aTempSet.Get(EE_CHAR_FONTHEIGHT);
1952 sal_uLong nFontHeight = rOldHgt.GetHeight();
1953 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1954 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1956 if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1958 const SvxFontHeightItem& rOldHgt2 = aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1959 nFontHeight = rOldHgt2.GetHeight();
1960 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1961 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1964 if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1966 const SvxFontHeightItem& rOldHgt2 = aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1967 nFontHeight = rOldHgt2.GetHeight();
1968 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1969 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1972 // adjust bullet
1973 static_cast<SdStyleSheet*>(pOutlineSheet)->AdjustToFontHeight(aTempSet, false);
1975 // Special treatment: reset the INVALIDS to
1976 // NULL pointer (otherwise we have INVALID's
1977 // or pointer to the DefaultItems in the
1978 // template; both would suppress the
1979 // attribute inheritance)
1980 aTempSet.ClearInvalidItems();
1982 // Special treatment: only the valid parts
1983 // of the BulletItems
1984 if (aTempSet.GetItemState(EE_PARA_BULLET) == SfxItemState::DEFAULT)
1986 SvxBulletItem aOldBulItem( pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET) );
1987 const SvxBulletItem& rNewBulItem = aTempSet.Get(EE_PARA_BULLET);
1988 aOldBulItem.CopyValidProperties(rNewBulItem);
1989 aTempSet.Put(aOldBulItem);
1992 pOutlineSheet->GetItemSet().Put(aTempSet);
1993 pOutlineSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
1997 else if (pObj == GetPresObj(PRESOBJ_NOTES, 0))
1999 SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PRESOBJ_NOTES);
2001 if (pNotesSheet)
2003 sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height();
2004 sal_uLong nFontHeight = static_cast<sal_uLong>(nHeight * 0.0741);
2005 SfxItemSet& rSet = pNotesSheet->GetItemSet();
2006 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
2007 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
2008 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
2009 pNotesSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
2013 else if ( eObjKind != OBJ_TITLETEXT &&
2014 eObjKind != OBJ_OUTLINETEXT &&
2015 dynamic_cast< const SdrTextObj *>( pObj ) != nullptr &&
2016 pObj->GetOutlinerParaObject() )
2018 /******************************************************
2019 * normal text object: adjust text height
2020 ******************************************************/
2021 SvtScriptType nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
2022 sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT;
2023 if ( nScriptType == SvtScriptType::ASIAN )
2024 nWhich = EE_CHAR_FONTHEIGHT_CJK;
2025 else if ( nScriptType == SvtScriptType::COMPLEX )
2026 nWhich = EE_CHAR_FONTHEIGHT_CTL;
2028 // use more modern method to scale the text height
2029 sal_uInt32 nFontHeight = static_cast<const SvxFontHeightItem&>(pObj->GetMergedItem(nWhich)).GetHeight();
2030 sal_uInt32 nNewFontHeight = sal_uInt32(static_cast<double>(nFontHeight) * static_cast<double>(aFractY));
2032 pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
2037 if (mbScaleObjects && !pObj->IsEdgeObj())
2039 /**************************************************************
2040 * scale object position
2041 **************************************************************/
2042 Point aNewPos;
2044 // corrected scaling; only distances may be scaled
2045 // use aTopLeft as original TopLeft
2046 aNewPos.setX( long((aTopLeft.X() - GetLeftBorder()) * static_cast<double>(aFractX)) + nLeft );
2047 aNewPos.setY( long((aTopLeft.Y() - GetUpperBorder()) * static_cast<double>(aFractY)) + nUpper );
2049 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
2051 if (aVec.Height() != 0 || aVec.Width() != 0)
2053 pObj->NbcMove(aVec);
2056 pObj->SetChanged();
2057 pObj->BroadcastObjectChange();
2063 static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect)
2065 SdDrawDocument& rModel(static_cast< SdDrawDocument& >(rPage.getSdrModelFromSdrPage()));
2066 if( !pSourceObj )
2067 return pSourceObj;
2069 SfxUndoManager* pUndoManager = rModel.GetUndoManager();
2070 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
2072 SdrObject* pNewObj = pSourceObj;
2073 if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) )
2075 pNewObj = rPage.CreatePresObj(PRESOBJ_OUTLINE, bVertical, rRect);
2077 // Set text of the subtitle into PRESOBJ_OUTLINE
2078 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2080 if(pOutlParaObj)
2082 // assign text
2083 SdOutliner* pOutl = rModel.GetInternalOutliner();
2084 pOutl->Clear();
2085 pOutl->SetText( *pOutlParaObj );
2086 std::unique_ptr<OutlinerParaObject> pNew = pOutl->CreateParaObject();
2087 pOutlParaObj = pNew.get();
2088 pNewObj->SetOutlinerParaObject( std::move(pNew) );
2089 pOutl->Clear();
2090 pNewObj->SetEmptyPresObj(false);
2092 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
2094 // assign new template
2095 OUString aName( rPage.GetLayoutName() + " " + OUString::number( nLevel ) );
2096 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( rModel.GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page) );
2098 if (pSheet && nLevel == 1)
2100 SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2102 if (pSubtitleSheet)
2103 pOutlParaObj->ChangeStyleSheetName(SfxStyleFamily::Page, pSubtitleSheet->GetName(), pSheet->GetName());
2107 // Remove LRSpace item
2108 SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
2110 aSet.Put(pNewObj->GetMergedItemSet());
2112 aSet.ClearItem(EE_PARA_LRSPACE);
2114 pNewObj->SetMergedItemSet(aSet);
2116 if( bUndo )
2117 pUndoManager->AddUndoAction( rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
2119 // Remove outline shape from page
2120 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2122 if( !bUndo )
2123 SdrObject::Free( pSourceObj );
2126 else if((eObjKind == PRESOBJ_TEXT) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) )
2128 // is there an outline shape we can use to replace empty subtitle shape?
2129 pNewObj = rPage.CreatePresObj(PRESOBJ_TEXT, bVertical, rRect);
2131 // Set text of the outline object into PRESOBJ_TITLE
2132 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2134 if(pOutlParaObj)
2136 // assign text
2137 SdOutliner* pOutl = rModel.GetInternalOutliner();
2138 pOutl->Clear();
2139 pOutl->SetText( *pOutlParaObj );
2140 pNewObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
2141 pOutl->Clear();
2142 pNewObj->SetEmptyPresObj(false);
2144 // reset left indent
2145 SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
2147 aSet.Put(pNewObj->GetMergedItemSet());
2149 const SvxLRSpaceItem& rLRItem = aSet.Get(EE_PARA_LRSPACE);
2150 SvxLRSpaceItem aNewLRItem(rLRItem);
2151 aNewLRItem.SetTextLeft(0);
2152 aSet.Put(aNewLRItem);
2154 pNewObj->SetMergedItemSet(aSet);
2156 SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2157 if (pSheet)
2158 pNewObj->SetStyleSheet(pSheet, true);
2160 // Remove subtitle shape from page
2161 if( bUndo )
2162 pUndoManager->AddUndoAction(rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
2164 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2166 if( !bUndo )
2167 SdrObject::Free( pSourceObj );
2170 else if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) )
2172 switch( pSourceObj->GetObjIdentifier() )
2174 case OBJ_TABLE: eObjKind = PRESOBJ_TABLE; break;
2175 case OBJ_MEDIA: eObjKind = PRESOBJ_MEDIA; break;
2176 case OBJ_GRAF: eObjKind = PRESOBJ_GRAPHIC; break;
2177 case OBJ_OLE2: eObjKind = PRESOBJ_OBJECT; break;
2181 return pNewObj;
2184 /** reuses or creates a presentation shape for an auto layout that fits the given parameter
2186 @param eObjKind
2187 The kind of presentation shape we like to have
2188 @param nIndex
2189 If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
2190 looking for an existing presentation shape
2191 @param bVertical
2192 If true, the shape is created vertical if bInit is true
2193 @param rRect
2194 The rectangle that should be used to transform the shape
2195 @param bInit
2196 If true the shape is created if not found
2197 @returns
2198 A presentation shape that was either found or created with the given parameters
2200 SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit)
2202 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
2203 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
2205 if (!pObj && bInit)
2207 pObj = CreatePresObj(eObjKind, bVertical, rRect);
2209 else if ( pObj && (pObj->GetUserCall() || bInit) )
2211 // convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2212 if( bInit )
2213 pObj = convertPresentationObjectImpl(*this, pObj, eObjKind, bVertical, rRect);
2215 if( bUndo )
2217 pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
2218 pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoAttrObject( *pObj, true, true ) );
2219 pUndoManager->AddUndoAction( std::make_unique<UndoObjectUserCall>( *pObj ) );
2222 pObj->AdjustToMaxRect(rRect);
2224 pObj->SetUserCall(this);
2226 SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
2227 if( pTextObject )
2229 if( pTextObject->IsVerticalWriting() != bVertical )
2231 pTextObject->SetVerticalWriting( bVertical );
2233 // here make sure the correct anchoring is used when the object
2234 // is re-used but orientation is changed
2235 if(PRESOBJ_OUTLINE == eObjKind)
2236 pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
2239 if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) )
2241 if ( pTextObject->IsAutoGrowHeight() )
2243 // switch off AutoGrowHeight, set new MinHeight
2244 SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2245 SdrMetricItem aMinHeight( makeSdrTextMinFrameHeightItem(rRect.GetSize().Height()) );
2246 aTempAttr.Put( aMinHeight );
2247 aTempAttr.Put( makeSdrTextAutoGrowHeightItem(false) );
2248 pTextObject->SetMergedItemSet(aTempAttr);
2249 pTextObject->SetLogicRect(rRect);
2251 // switch on AutoGrowHeight
2252 SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2253 aAttr.Put( makeSdrTextAutoGrowHeightItem(true) );
2255 pTextObject->SetMergedItemSet(aAttr);
2258 if ( pTextObject->IsAutoGrowWidth() )
2260 // switch off AutoGrowWidth , set new MinWidth
2261 SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2262 SdrMetricItem aMinWidth( makeSdrTextMinFrameWidthItem(rRect.GetSize().Width()) );
2263 aTempAttr.Put( aMinWidth );
2264 aTempAttr.Put( makeSdrTextAutoGrowWidthItem(false) );
2265 pTextObject->SetMergedItemSet(aTempAttr);
2266 pTextObject->SetLogicRect(rRect);
2268 // switch on AutoGrowWidth
2269 SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2270 aAttr.Put( makeSdrTextAutoGrowWidthItem(true) );
2271 pTextObject->SetMergedItemSet(aAttr);
2277 if(pObj && bInit )
2279 if( !IsPresObj( pObj ) )
2281 if( bUndo )
2282 pUndoManager->AddUndoAction( std::make_unique<UndoObjectPresentationKind>( *pObj ) );
2284 InsertPresObj( pObj, eObjKind );
2287 // make adjustments for vertical title and outline shapes
2288 if( bVertical && (( eObjKind == PRESOBJ_TITLE) || (eObjKind == PRESOBJ_OUTLINE)))
2290 SfxItemSet aNewSet(pObj->GetMergedItemSet());
2291 aNewSet.Put( makeSdrTextAutoGrowWidthItem(true) );
2292 aNewSet.Put( makeSdrTextAutoGrowHeightItem(false) );
2293 if( eObjKind == PRESOBJ_OUTLINE )
2295 aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
2296 aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
2298 pObj->SetMergedItemSet(aNewSet);
2302 if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || dynamic_cast< const SdrGrafObj *>( pObj ) == nullptr ) )
2303 pObj->AdjustToMaxRect(rRect);
2305 return pObj;
2308 /*************************************************************************
2310 |* Returns the PresObjKind of an object
2312 \************************************************************************/
2314 PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const
2316 PresObjKind eKind = PRESOBJ_NONE;
2317 if( (pObj != nullptr) && (maPresentationShapeList.hasShape(*pObj)) )
2319 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
2320 if( pInfo )
2321 eKind = pInfo->mePresObjKind;
2324 return eKind;
2327 bool SdPage::IsPresObj(const SdrObject* pObj)
2329 return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
2332 void SdPage::RemovePresObj(const SdrObject* pObj)
2334 if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
2336 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
2337 if( pInfo )
2338 pInfo->mePresObjKind = PRESOBJ_NONE;
2339 maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
2343 void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
2345 DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2346 DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2347 if( pObj )
2349 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
2350 if( pInfo )
2351 pInfo->mePresObjKind = eKind;
2352 maPresentationShapeList.addShape(*pObj);
2356 /*************************************************************************
2358 |* Set the text of an object
2360 \************************************************************************/
2362 void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const OUString& rString )
2364 if ( !pObj )
2365 return;
2367 DBG_ASSERT( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr, "SetObjText: No SdrTextObj!" );
2368 ::Outliner* pOutl = pOutliner;
2370 if (!pOutliner)
2372 SfxItemPool* pPool(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDrawOutliner().GetEmptyItemSet().GetPool());
2373 pOutl = new ::Outliner( pPool, OutlinerMode::OutlineObject );
2374 pOutl->SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
2375 pOutl->SetEditTextObjectPool(pPool);
2376 pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool()));
2377 pOutl->EnableUndo(false);
2378 pOutl->SetUpdateMode( false );
2381 OutlinerMode nOutlMode = pOutl->GetMode();
2382 Size aPaperSize = pOutl->GetPaperSize();
2383 bool bUpdateMode = pOutl->GetUpdateMode();
2384 pOutl->SetUpdateMode(false);
2385 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2387 // Always set the object's StyleSheet at the Outliner to
2388 // use the current objects StyleSheet. Thus it's the same as in
2389 // SetText(...).
2390 // Moved this implementation from where SetObjText(...) was called
2391 // to inside this method to work even when outliner is fetched here.
2392 pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
2394 OUString aString;
2396 switch( eObjKind )
2398 case PRESOBJ_OUTLINE:
2400 pOutl->Init( OutlinerMode::OutlineObject );
2402 aString += "\t" + rString;
2404 if (mbMaster)
2406 pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
2407 aString += "\n\t\t" +
2408 SdResId(STR_PRESOBJ_MPOUTLLAYER2) +
2409 "\n\t\t\t" +
2410 SdResId(STR_PRESOBJ_MPOUTLLAYER3) +
2411 "\n\t\t\t\t" +
2412 SdResId(STR_PRESOBJ_MPOUTLLAYER4) +
2413 "\n\t\t\t\t\t" +
2414 SdResId(STR_PRESOBJ_MPOUTLLAYER5) +
2415 "\n\t\t\t\t\t\t" +
2416 SdResId(STR_PRESOBJ_MPOUTLLAYER6) +
2417 "\n\t\t\t\t\t\t\t" +
2418 SdResId(STR_PRESOBJ_MPOUTLLAYER7);
2422 break;
2424 case PRESOBJ_TITLE:
2426 pOutl->Init( OutlinerMode::TitleObject );
2427 aString += rString;
2429 break;
2431 default:
2433 pOutl->Init( OutlinerMode::TextObject );
2434 aString += rString;
2436 // check if we need to add a text field
2437 std::unique_ptr<SvxFieldData> pData;
2439 switch( eObjKind )
2441 case PRESOBJ_HEADER:
2442 pData.reset(new SvxHeaderField());
2443 break;
2444 case PRESOBJ_FOOTER:
2445 pData .reset(new SvxFooterField());
2446 break;
2447 case PRESOBJ_SLIDENUMBER:
2448 pData.reset(new SvxPageField());
2449 break;
2450 case PRESOBJ_DATETIME:
2451 pData.reset(new SvxDateTimeField());
2452 break;
2453 default:
2454 break;
2457 if( pData )
2459 ESelection e;
2460 SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
2461 pOutl->QuickInsertField(aField,e);
2464 break;
2467 pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
2469 if( !aString.isEmpty() )
2470 pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
2472 pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
2474 if (!pOutliner)
2476 delete pOutl;
2477 pOutl = nullptr;
2479 else
2481 // restore the outliner
2482 pOutl->Init( nOutlMode );
2483 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2484 pOutl->SetUpdateMode( bUpdateMode );
2485 pOutl->SetPaperSize( aPaperSize );
2489 /*************************************************************************
2491 |* Set the name of the layout
2493 \************************************************************************/
2494 void SdPage::SetLayoutName(const OUString& aName)
2496 maLayoutName = aName;
2498 if( mbMaster )
2500 sal_Int32 nPos = maLayoutName.indexOf(SD_LT_SEPARATOR);
2501 if (nPos != -1)
2502 FmFormPage::SetName(maLayoutName.copy(0, nPos));
2506 /*************************************************************************
2508 |* Return the page name and generates it if necessary
2510 \************************************************************************/
2512 const OUString& SdPage::GetName() const
2514 OUString aCreatedPageName( maCreatedPageName );
2515 if (GetRealName().isEmpty())
2517 if ((mePageKind == PageKind::Standard || mePageKind == PageKind::Notes) && !mbMaster)
2519 // default name for handout pages
2520 sal_uInt16 nNum = (GetPageNum() + 1) / 2;
2522 aCreatedPageName = SdResId(STR_PAGE) + " ";
2523 if (static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()).GetDocumentType() == DocumentType::Draw )
2524 aCreatedPageName = SdResId(STR_PAGE_NAME) + " ";
2526 if( getSdrModelFromSdrPage().GetPageNumType() == css::style::NumberingType::NUMBER_NONE )
2528 // if the document has number none as a formatting
2529 // for page numbers we still default to arabic numbering
2530 // to keep the default page names unique
2531 aCreatedPageName += OUString::number( static_cast<sal_Int32>(nNum) );
2533 else
2535 aCreatedPageName += static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).CreatePageNumValue(nNum);
2538 else
2540 /******************************************************************
2541 * default name for note pages
2542 ******************************************************************/
2543 aCreatedPageName = SdResId(STR_LAYOUT_DEFAULT_NAME);
2546 else
2548 aCreatedPageName = GetRealName();
2551 if (mePageKind == PageKind::Notes)
2553 aCreatedPageName += " " + SdResId(STR_NOTES);
2555 else if (mePageKind == PageKind::Handout && mbMaster)
2557 aCreatedPageName += " (" + SdResId(STR_HANDOUT) + ")";
2560 const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
2561 return maCreatedPageName;
2564 void SdPage::SetOrientation( Orientation /*eOrient*/)
2566 // Do nothing
2569 Orientation SdPage::GetOrientation() const
2571 Size aSize = GetSize();
2572 if ( aSize.getWidth() > aSize.getHeight() )
2574 return Orientation::Landscape;
2576 else
2578 return Orientation::Portrait;
2582 /*************************************************************************
2584 |* returns the default text of a PresObjektes
2586 \************************************************************************/
2588 OUString SdPage::GetPresObjText(PresObjKind eObjKind) const
2590 OUString aString;
2592 if (eObjKind == PRESOBJ_TITLE)
2594 if (mbMaster)
2596 if (mePageKind != PageKind::Notes)
2598 aString = SdResId( STR_PRESOBJ_MPTITLE );
2600 else
2602 aString = SdResId( STR_PRESOBJ_MPNOTESTITLE );
2605 else
2607 aString = SdResId( STR_PRESOBJ_TITLE );
2610 else if (eObjKind == PRESOBJ_OUTLINE)
2612 if (mbMaster)
2614 aString = SdResId( STR_PRESOBJ_MPOUTLINE );
2616 else
2618 aString = SdResId( STR_PRESOBJ_OUTLINE );
2621 else if (eObjKind == PRESOBJ_NOTES)
2623 if (mbMaster)
2625 aString = SdResId( STR_PRESOBJ_MPNOTESTEXT );
2627 else
2629 aString = SdResId( STR_PRESOBJ_NOTESTEXT );
2632 else if (eObjKind == PRESOBJ_TEXT)
2634 aString = SdResId( STR_PRESOBJ_TEXT );
2636 else if (eObjKind == PRESOBJ_GRAPHIC)
2638 aString = SdResId( STR_PRESOBJ_GRAPHIC );
2640 else if (eObjKind == PRESOBJ_OBJECT)
2642 aString = SdResId( STR_PRESOBJ_OBJECT );
2644 else if (eObjKind == PRESOBJ_CHART)
2646 aString = SdResId( STR_PRESOBJ_CHART );
2648 else if (eObjKind == PRESOBJ_ORGCHART)
2650 aString = SdResId( STR_PRESOBJ_ORGCHART );
2652 else if (eObjKind == PRESOBJ_CALC)
2654 aString = SdResId( STR_PRESOBJ_TABLE );
2657 return aString;
2660 uno::Reference< uno::XInterface > SdPage::createUnoPage()
2662 return createUnoPageImpl( this );
2665 /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
2666 SdPage* SdPage::getImplementation( const css::uno::Reference< css::drawing::XDrawPage >& xPage )
2670 auto pUnoPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>(xPage);
2671 if( pUnoPage )
2672 return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
2674 catch( css::uno::Exception& )
2676 OSL_FAIL("sd::SdPage::getImplementation(), exception caught!" );
2679 return nullptr;
2682 sal_Int64 SdPage::GetHashCode() const
2684 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
2687 void SdPage::SetName (const OUString& rName)
2689 OUString aOldName( GetName() );
2690 FmFormPage::SetName (rName);
2691 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).UpdatePageRelativeURLs(aOldName, rName);
2692 ActionChanged();
2695 const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
2697 if( mePageKind == PageKind::Handout && !mbMaster )
2699 return static_cast<SdPage&>(TRG_GetMasterPage()).maHeaderFooterSettings;
2701 else
2703 return maHeaderFooterSettings;
2707 void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings )
2709 if( mePageKind == PageKind::Handout && !mbMaster )
2711 static_cast<SdPage&>(TRG_GetMasterPage()).maHeaderFooterSettings = rNewSettings;
2713 else
2715 maHeaderFooterSettings = rNewSettings;
2718 SetChanged();
2720 if(!TRG_HasMasterPage())
2721 return;
2723 TRG_GetMasterPageDescriptorViewContact().ActionChanged();
2725 // #i119056# For HeaderFooterSettings SdrObjects are used, but the properties
2726 // used are not part of their model data, but kept in SD. This data is applied
2727 // using a 'backdoor' on primitive creation. Thus, the normal mechanism to detect
2728 // object changes does not work here. It is necessary to trigger updates here
2729 // directly. BroadcastObjectChange used for PagePreview invalidations,
2730 // flushViewObjectContacts used to invalidate and flush all visualizations in
2731 // edit views.
2732 SdPage* pMasterPage = dynamic_cast< SdPage* >(&TRG_GetMasterPage());
2734 if(!pMasterPage)
2735 return;
2737 SdrObject* pCandidate = pMasterPage->GetPresObj( PRESOBJ_HEADER );
2739 if(pCandidate)
2741 pCandidate->BroadcastObjectChange();
2742 pCandidate->GetViewContact().flushViewObjectContacts();
2745 pCandidate = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
2747 if(pCandidate)
2749 pCandidate->BroadcastObjectChange();
2750 pCandidate->GetViewContact().flushViewObjectContacts();
2753 pCandidate = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
2755 if(pCandidate)
2757 pCandidate->BroadcastObjectChange();
2758 pCandidate->GetViewContact().flushViewObjectContacts();
2761 pCandidate = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
2763 if(pCandidate)
2765 pCandidate->BroadcastObjectChange();
2766 pCandidate->GetViewContact().flushViewObjectContacts();
2770 bool SdPage::checkVisibility(
2771 const sdr::contact::ViewObjectContact& rOriginal,
2772 const sdr::contact::DisplayInfo& rDisplayInfo,
2773 bool bEdit )
2775 if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
2776 return false;
2778 SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2779 if( pObj == nullptr )
2780 return false;
2782 const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
2783 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
2784 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
2785 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
2787 // empty presentation objects only visible during edit mode
2788 if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
2790 if( (pObj->GetObjInventor() != SdrInventor::Default) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
2791 return false;
2794 if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) )
2796 const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->getSdrPageFromSdrObject());
2798 if( pCheckPage )
2800 PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
2802 if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
2804 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
2806 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PageKind::Handout && bIsPrinting ) )
2808 // use the page that is currently processed
2809 const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
2811 if( pVisualizedSdPage )
2813 // if we are not on a masterpage, see if we have to draw this header&footer object at all
2814 const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
2816 switch( eKind )
2818 case PRESOBJ_FOOTER:
2819 return rSettings.mbFooterVisible;
2820 case PRESOBJ_HEADER:
2821 return rSettings.mbHeaderVisible;
2822 case PRESOBJ_DATETIME:
2823 return rSettings.mbDateTimeVisible;
2824 case PRESOBJ_SLIDENUMBER:
2825 return rSettings.mbSlideNumberVisible;
2826 default:
2827 break;
2831 } // check for placeholders on master
2832 else if( (eKind != PRESOBJ_NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) )
2834 // presentation objects on master slide are always invisible if slide is shown.
2835 return false;
2840 // i63977, do not print SdrpageObjs from master pages
2841 if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) )
2843 if( pObj->getSdrPageFromSdrObject() && pObj->getSdrPageFromSdrObject()->IsMasterPage() )
2844 return false;
2847 return true;
2850 bool SdPage::RestoreDefaultText( SdrObject* pObj )
2852 bool bRet = false;
2854 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
2856 if( pTextObj )
2858 PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
2860 if (ePresObjKind == PRESOBJ_TITLE ||
2861 ePresObjKind == PRESOBJ_OUTLINE ||
2862 ePresObjKind == PRESOBJ_NOTES ||
2863 ePresObjKind == PRESOBJ_TEXT)
2865 OUString aString( GetPresObjText(ePresObjKind) );
2867 if (!aString.isEmpty())
2869 bool bVertical = false;
2870 OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
2871 if( pOldPara )
2872 bVertical = pOldPara->IsVertical(); // is old para object vertical?
2874 SetObjText( pTextObj, nullptr, ePresObjKind, aString );
2876 if( pOldPara )
2878 // Here, only the vertical flag for the
2879 // OutlinerParaObjects needs to be changed. The
2880 // AutoGrowWidth/Height items still exist in the
2881 // not changed object.
2882 if(pTextObj->GetOutlinerParaObject()
2883 && pTextObj->GetOutlinerParaObject()->IsVertical() != bVertical)
2885 ::tools::Rectangle aObjectRect = pTextObj->GetSnapRect();
2886 pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
2887 pTextObj->SetSnapRect(aObjectRect);
2891 pTextObj->SetTextEditOutliner( nullptr ); // to make stylesheet settings work
2892 pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), true );
2893 pTextObj->SetEmptyPresObj(true);
2894 bRet = true;
2898 return bRet;
2901 void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< ::tools::Rectangle >& rAreas )
2903 SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PageKind::Handout );
2905 static const sal_uInt16 aOffsets[5][9] =
2907 { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
2908 { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
2909 { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
2910 { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
2911 { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
2914 const sal_uInt16* pOffsets = aOffsets[0];
2916 Size aArea = rHandoutMaster.GetSize();
2917 const bool bLandscape = aArea.Width() > aArea.Height();
2919 if( eLayout == AUTOLAYOUT_NONE )
2921 // use layout from handout master
2922 SdrObjListIter aShapeIter(&rHandoutMaster);
2924 std::vector< ::tools::Rectangle > vSlidesAreas;
2925 while ( aShapeIter.IsMore() )
2927 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>( aShapeIter.Next() );
2928 // get slide rectangles
2929 if (pPageObj)
2930 vSlidesAreas.push_back( pPageObj->GetCurrentBoundRect() );
2933 if ( !bHorizontal || vSlidesAreas.size() < 4 )
2934 { // top to bottom, then right
2935 rAreas.swap( vSlidesAreas );
2937 else
2938 { // left to right, then down
2939 switch ( vSlidesAreas.size() )
2941 case 4:
2942 pOffsets = aOffsets[2];
2943 break;
2945 default:
2946 [[fallthrough]];
2947 case 6:
2948 pOffsets = aOffsets[ bLandscape ? 3 : 1 ];
2949 break;
2951 case 9:
2952 pOffsets = aOffsets[4];
2953 break;
2956 rAreas.resize( static_cast<size_t>(vSlidesAreas.size()) );
2958 for( const tools::Rectangle& rRect : vSlidesAreas )
2960 rAreas[*pOffsets++] = rRect;
2964 else
2966 const long nGapW = 1000; // gap is 1cm
2967 const long nGapH = 1000;
2969 long nLeftBorder = rHandoutMaster.GetLeftBorder();
2970 long nRightBorder = rHandoutMaster.GetRightBorder();
2971 long nTopBorder = rHandoutMaster.GetUpperBorder();
2972 long nBottomBorder = rHandoutMaster.GetLowerBorder();
2974 const long nHeaderFooterHeight = static_cast< long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05 );
2976 nTopBorder += nHeaderFooterHeight;
2977 nBottomBorder += nHeaderFooterHeight;
2979 long nX = nGapW + nLeftBorder;
2980 long nY = nGapH + nTopBorder;
2982 aArea.AdjustWidth( -(nGapW * 2 + nLeftBorder + nRightBorder) );
2983 aArea.AdjustHeight( -(nGapH * 2 + nTopBorder + nBottomBorder) );
2985 sal_uInt16 nColCnt = 0, nRowCnt = 0;
2986 switch ( eLayout )
2988 case AUTOLAYOUT_HANDOUT1:
2989 nColCnt = 1; nRowCnt = 1;
2990 break;
2992 case AUTOLAYOUT_HANDOUT2:
2993 if( bLandscape )
2995 nColCnt = 2; nRowCnt = 1;
2997 else
2999 nColCnt = 1; nRowCnt = 2;
3001 break;
3003 case AUTOLAYOUT_HANDOUT3:
3004 if( bLandscape )
3006 nColCnt = 3; nRowCnt = 2;
3008 else
3010 nColCnt = 2; nRowCnt = 3;
3012 pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
3013 break;
3015 case AUTOLAYOUT_HANDOUT4:
3016 nColCnt = 2; nRowCnt = 2;
3017 pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
3018 break;
3020 case AUTOLAYOUT_HANDOUT6:
3021 if( bLandscape )
3023 nColCnt = 3; nRowCnt = 2;
3025 else
3027 nColCnt = 2; nRowCnt = 3;
3029 if( !bHorizontal )
3030 pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
3031 break;
3033 default:
3034 case AUTOLAYOUT_HANDOUT9:
3035 nColCnt = 3; nRowCnt = 3;
3037 if( !bHorizontal )
3038 pOffsets = aOffsets[4];
3039 break;
3042 rAreas.resize(static_cast<size_t>(nColCnt) * nRowCnt);
3044 Size aPartArea, aSize;
3045 aPartArea.setWidth( (aArea.Width() - ((nColCnt-1) * nGapW) ) / nColCnt );
3046 aPartArea.setHeight( (aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt );
3048 SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PageKind::Standard);
3049 if (pFirstPage && pFirstPage->GetWidth() && pFirstPage->GetHeight())
3051 // scale actual size into handout rect
3052 double fScale = static_cast<double>(aPartArea.Width()) / static_cast<double>(pFirstPage->GetWidth());
3054 aSize.setHeight( static_cast<long>(fScale * pFirstPage->GetHeight() ) );
3055 if( aSize.Height() > aPartArea.Height() )
3057 fScale = static_cast<double>(aPartArea.Height()) / static_cast<double>(pFirstPage->GetHeight());
3058 aSize.setHeight( aPartArea.Height() );
3059 aSize.setWidth( static_cast<long>(fScale * pFirstPage->GetWidth()) );
3061 else
3063 aSize.setWidth( aPartArea.Width() );
3066 nX += (aPartArea.Width() - aSize.Width()) / 2;
3067 nY += (aPartArea.Height()- aSize.Height())/ 2;
3069 else
3071 aSize = aPartArea;
3074 Point aPos( nX, nY );
3076 const bool bRTL = rModel.GetDefaultWritingMode() == css::text::WritingMode_RL_TB;
3078 const long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
3079 const long nOffsetY = aPartArea.Height() + nGapH;
3080 const long nStartX = bRTL ? nOffsetX*(1 - nColCnt) + nX : nX;
3082 for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
3084 aPos.setX( nStartX );
3085 for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
3087 rAreas[*pOffsets++] = ::tools::Rectangle(aPos, aSize);
3088 aPos.AdjustX(nOffsetX );
3091 aPos.AdjustY(nOffsetY );
3096 void SdPage::SetPrecious (const bool bIsPrecious)
3098 mbIsPrecious = bIsPrecious;
3101 HeaderFooterSettings::HeaderFooterSettings()
3103 mbHeaderVisible = true;
3104 mbFooterVisible = true;
3105 mbSlideNumberVisible = false;
3106 mbDateTimeVisible = true;
3107 mbDateTimeIsFixed = true;
3108 meDateFormat = SvxDateFormat::A;
3109 meTimeFormat = SvxTimeFormat::AppDefault;
3112 bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
3114 return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
3115 (maHeaderText == rSettings.maHeaderText) &&
3116 (mbFooterVisible == rSettings.mbFooterVisible) &&
3117 (maFooterText == rSettings.maFooterText) &&
3118 (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
3119 (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
3120 (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
3121 (meDateFormat == rSettings.meDateFormat) &&
3122 (meTimeFormat == rSettings.meTimeFormat) &&
3123 (maDateTimeText == rSettings.maDateTimeText);
3126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */