Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / core / sdpage.cxx
blob96835106736d43cffcb1a1a43f1b51c077b4d1d5
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 <svx/pageitem.hxx>
31 #include <editeng/lrspitem.hxx>
32 #include <editeng/bulletitem.hxx>
33 #include <svx/svdpagv.hxx>
34 #include <editeng/fhgtitem.hxx>
35 #include <editeng/outlobj.hxx>
36 #include <svx/svdoole2.hxx>
37 #include <svx/svdograf.hxx>
38 #include <svx/svdopage.hxx>
39 #include <sfx2/printer.hxx>
40 #include <basic/basmgr.hxx>
41 #include <editeng/pbinitem.hxx>
42 #include <svx/svdundo.hxx>
43 #include <svl/hint.hxx>
44 #include <editeng/adjustitem.hxx>
45 #include <editeng/editobj.hxx>
46 #include <editeng/scripttypeitem.hxx>
47 #include <svx/unopage.hxx>
48 #include <editeng/flditem.hxx>
49 #include <svx/sdr/contact/displayinfo.hxx>
50 #include <svx/svditer.hxx>
51 #include <svx/svdlayer.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/xml/dom/XNode.hpp>
56 #include <com/sun/star/xml/dom/XNodeList.hpp>
57 #include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
58 #include <rtl/ustring.hxx>
59 #include <basegfx/utils/tools.hxx>
60 #include <o3tl/enumarray.hxx>
61 #include <xmloff/autolayout.hxx>
63 #include <Outliner.hxx>
64 #include <app.hrc>
65 #include <createunopageimpl.hxx>
66 #include <drawdoc.hxx>
67 #include <sdmod.hxx>
68 #include <sdpage.hxx>
69 #include <pglink.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 <helpids.h>
77 #include <anminfo.hxx>
78 #include <undo/undomanager.hxx>
79 #include <undo/undoobjects.hxx>
80 #include <svx/sdr/contact/viewobjectcontact.hxx>
81 #include <svx/sdr/contact/viewcontact.hxx>
82 #include <svx/sdr/contact/objectcontact.hxx>
83 #include <svx/unoapi.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 , mpItems(nullptr)
120 , mnTransitionType(0)
121 , mnTransitionSubtype(0)
122 , mbTransitionDirection(true)
123 , mnTransitionFadeColor(0)
124 , mfTransitionDuration(2.0)
125 , mbIsPrecious(true)
126 , mnPageId(mnLastPageId++)
128 // The name of the layout of the page is used by SVDRAW to determine the
129 // presentation template of the outline objects. Therefore, it already
130 // contains the designator for the outline (STR_LAYOUT_OUTLINE).
131 maLayoutName = SdResId(STR_LAYOUT_DEFAULT_NAME)+ SD_LT_SEPARATOR STR_LAYOUT_OUTLINE;
133 // Stuff that former SetModel did also:
134 ConnectLink();
137 namespace
139 void clearChildNodes(css::uno::Reference<css::animations::XAnimationNode> const & rAnimationNode)
141 css::uno::Reference<css::container::XEnumerationAccess > xEnumerationAccess(rAnimationNode, UNO_QUERY);
142 if (!xEnumerationAccess.is())
143 return;
144 css::uno::Reference<css::container::XEnumeration> xEnumeration(xEnumerationAccess->createEnumeration(), UNO_QUERY);
145 if (!xEnumeration.is())
146 return;
147 while (xEnumeration->hasMoreElements())
149 css::uno::Reference<css::animations::XAnimationNode> xChildNode(xEnumeration->nextElement(), UNO_QUERY);
150 if (!xChildNode.is())
151 continue;
152 clearChildNodes(xChildNode);
153 css::uno::Reference<css::animations::XTimeContainer> xAnimationNode(rAnimationNode, UNO_QUERY);
154 if (!xAnimationNode.is())
156 SAL_WARN("sd.core", "can't remove node child, possible leak");
157 continue;
159 xAnimationNode->removeChild(xChildNode);
164 /*************************************************************************
166 |* Dtor
168 \************************************************************************/
170 SdPage::~SdPage()
172 DisconnectLink();
174 EndListenOutlineText();
176 clearChildNodes(mxAnimationNode);
178 // clear SdrObjects with broadcasting
179 ClearSdrObjList();
182 struct OrdNumSorter
184 bool operator()( SdrObject const * p1, SdrObject const * p2 )
186 return p1->GetOrdNum() < p2->GetOrdNum();
190 /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
191 SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ )
193 // first sort all matching shapes with z-order
194 std::vector< SdrObject* > aMatches;
196 SdrObject* pObj = nullptr;
197 maPresentationShapeList.seekShape(0);
199 while( (pObj = maPresentationShapeList.getNextShape()) )
201 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
202 if( pInfo )
204 bool bFound = false;
205 if( pInfo->mePresObjKind == eObjKind )
207 bFound = true;
209 else if( bFuzzySearch && (eObjKind == PRESOBJ_OUTLINE) )
211 switch( pInfo->mePresObjKind )
213 case PRESOBJ_GRAPHIC:
214 case PRESOBJ_OBJECT:
215 case PRESOBJ_CHART:
216 case PRESOBJ_ORGCHART:
217 case PRESOBJ_TABLE:
218 case PRESOBJ_CALC:
219 case PRESOBJ_MEDIA:
220 bFound = true;
221 break;
222 default:
223 break;
226 if( bFound )
228 aMatches.push_back( pObj );
233 if( aMatches.size() > 1 )
235 std::sort( aMatches.begin(), aMatches.end(), OrdNumSorter() );
238 if( nIndex > 0 )
239 nIndex--;
241 if( (nIndex >= 0) && ( aMatches.size() > static_cast<unsigned int>(nIndex)) )
242 return aMatches[nIndex];
244 return nullptr;
247 /** create background properties */
248 void SdPage::EnsureMasterPageDefaultBackground()
250 if(mbMaster)
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));
270 /** creates a presentation object with the given PresObjKind on this page. A user call will be set
272 SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect )
274 ::svl::IUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
275 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
277 SdrObject* pSdrObj = nullptr;
279 bool bForceText = false; // forces the shape text to be set even if its empty
280 bool bEmptyPresObj = true;
282 switch( eObjKind )
284 case PRESOBJ_TITLE:
286 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TITLETEXT);
288 if (mbMaster)
290 pSdrObj->SetNotVisibleAsMaster(true);
293 break;
295 case PRESOBJ_OUTLINE:
297 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_OUTLINETEXT);
299 if (mbMaster)
301 pSdrObj->SetNotVisibleAsMaster(true);
304 break;
306 case PRESOBJ_NOTES:
308 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
310 if (mbMaster)
312 pSdrObj->SetNotVisibleAsMaster(true);
315 break;
317 case PRESOBJ_TEXT:
319 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
321 break;
323 case PRESOBJ_GRAPHIC:
325 BitmapEx aBmpEx(BMP_PRESOBJ_GRAPHIC);
326 Graphic aGraphic( aBmpEx );
327 OutputDevice &aOutDev = *Application::GetDefaultDevice();
328 aOutDev.Push();
330 aOutDev.SetMapMode( aGraphic.GetPrefMapMode() );
331 Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() );
332 aOutDev.SetMapMode(MapMode(MapUnit::Map100thMM));
334 Size aSize = aOutDev.PixelToLogic(aSizePix);
335 Point aPnt (0, 0);
336 ::tools::Rectangle aRect (aPnt, aSize);
337 pSdrObj = new SdrGrafObj(getSdrModelFromSdrPage(), aGraphic, aRect);
338 aOutDev.Pop();
340 break;
342 case PRESOBJ_MEDIA:
343 case PRESOBJ_OBJECT:
345 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
346 BitmapEx aBmpEx(BMP_PRESOBJ_OBJECT);
347 Graphic aGraphic( aBmpEx );
348 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
350 break;
352 case PRESOBJ_CHART:
354 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
355 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarChart" );
356 BitmapEx aBmpEx(BMP_PRESOBJ_CHART);
357 Graphic aGraphic( aBmpEx );
358 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
360 break;
362 case PRESOBJ_ORGCHART:
364 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
365 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarOrg" );
366 BitmapEx aBmpEx(BMP_PRESOBJ_ORGCHART);
367 Graphic aGraphic( aBmpEx );
368 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
370 break;
372 case PRESOBJ_TABLE:
373 case PRESOBJ_CALC:
375 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
376 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarCalc" );
377 BitmapEx aBmpEx(BMP_PRESOBJ_TABLE);
378 Graphic aGraphic( aBmpEx );
379 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
381 break;
383 case PRESOBJ_HANDOUT:
385 // Save the first standard page at SdrPageObj
386 // #i105146# We want no content to be displayed for PageKind::Handout,
387 // so just never set a page as content
388 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), nullptr);
390 break;
392 case PRESOBJ_PAGE:
394 // Save note pages at SdrPageObj
395 sal_uInt16 nDestPageNum(GetPageNum());
397 if(nDestPageNum)
399 // decrement only when != 0, else we get a 0xffff
400 nDestPageNum -= 1;
403 if (nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
405 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), getSdrModelFromSdrPage().GetPage(nDestPageNum));
407 else
409 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage());
412 pSdrObj->SetResizeProtect(true);
414 break;
416 case PRESOBJ_HEADER:
417 case PRESOBJ_FOOTER:
418 case PRESOBJ_DATETIME:
419 case PRESOBJ_SLIDENUMBER:
421 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
422 bEmptyPresObj = false;
423 bForceText = true;
425 break;
426 default:
427 break;
430 if (pSdrObj)
432 pSdrObj->SetEmptyPresObj(bEmptyPresObj);
433 pSdrObj->SetLogicRect(rRect);
435 InsertObject(pSdrObj);
437 if ( dynamic_cast< const SdrTextObj *>( pSdrObj ) != nullptr )
439 // Tell the object EARLY that it is vertical to have the
440 // defaults for AutoGrowWidth/Height reversed
441 if(bVertical)
442 static_cast<SdrTextObj*>(pSdrObj)->SetVerticalWriting(true);
444 SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
445 if( bVertical )
446 aTempAttr.Put( makeSdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
447 else
448 aTempAttr.Put( makeSdrTextMinFrameHeightItem( rRect.GetSize().Height() ) );
450 if (mbMaster)
452 // The size of presentation objects on the master page have to
453 // be freely selectable by the user.
455 // potential problem: This action was still NOT
456 // adapted for vertical text. This sure needs to be done.
457 if(bVertical)
458 aTempAttr.Put(makeSdrTextAutoGrowWidthItem(false));
459 else
460 aTempAttr.Put(makeSdrTextAutoGrowHeightItem(false));
463 // check if we need another vertical adjustment than the default
464 SdrTextVertAdjust eV = SDRTEXTVERTADJUST_TOP;
466 if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind != PageKind::Standard) )
468 eV = SDRTEXTVERTADJUST_BOTTOM;
470 else if( (eObjKind == PRESOBJ_SLIDENUMBER) && (mePageKind != PageKind::Standard) )
472 eV = SDRTEXTVERTADJUST_BOTTOM;
475 if( eV != SDRTEXTVERTADJUST_TOP )
476 aTempAttr.Put(SdrTextVertAdjustItem(eV));
478 pSdrObj->SetMergedItemSet(aTempAttr);
480 pSdrObj->SetLogicRect(rRect);
483 OUString aString = GetPresObjText(eObjKind);
484 if( (!aString.isEmpty() || bForceText) && dynamic_cast< const SdrTextObj *>( pSdrObj ) != nullptr )
486 SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
488 OutlinerMode nOutlMode = pOutliner->GetMode();
489 pOutliner->Init( OutlinerMode::TextObject );
490 pOutliner->SetStyleSheet( 0, nullptr );
491 pOutliner->SetVertical( bVertical );
493 SetObjText( static_cast<SdrTextObj*>(pSdrObj), pOutliner, eObjKind, aString );
495 pOutliner->Init( nOutlMode );
496 pOutliner->SetStyleSheet( 0, nullptr );
499 if( (eObjKind == PRESOBJ_HEADER) || (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_DATETIME) )
501 SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
502 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
503 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
504 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
506 SvxAdjust eH = SvxAdjust::Left;
508 if( (eObjKind == PRESOBJ_DATETIME) && (mePageKind != PageKind::Standard ) )
510 eH = SvxAdjust::Right;
512 else if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind == PageKind::Standard ) )
514 eH = SvxAdjust::Center;
516 else if( eObjKind == PRESOBJ_SLIDENUMBER )
518 eH = SvxAdjust::Right;
521 if( eH != SvxAdjust::Left )
522 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST ));
524 pSdrObj->SetMergedItemSet(aTempAttr);
527 if (mbMaster)
529 SdrLayerAdmin& rLayerAdmin(getSdrModelFromSdrPage().GetLayerAdmin());
531 // background objects of the master page
532 pSdrObj->SetLayer( rLayerAdmin.
533 GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)) );
536 // Subscribe object at the style sheet
537 // Set style only when one was found (as in 5.2)
538 if( mePageKind != PageKind::Handout )
540 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind);
541 if(pSheetForPresObj)
542 pSdrObj->SetStyleSheet(pSheetForPresObj, false);
545 if (eObjKind == PRESOBJ_OUTLINE)
547 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
549 OUString aName( maLayoutName + " " + OUString::number( nLevel ) );
550 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page));
551 DBG_ASSERT(pSheet, "StyleSheet for outline object not found");
552 if (pSheet)
553 pSdrObj->StartListening(*pSheet);
557 if ( eObjKind == PRESOBJ_OBJECT ||
558 eObjKind == PRESOBJ_CHART ||
559 eObjKind == PRESOBJ_ORGCHART ||
560 eObjKind == PRESOBJ_CALC ||
561 eObjKind == PRESOBJ_GRAPHIC )
563 SfxItemSet aSet( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
564 aSet.Put( makeSdrTextContourFrameItem( true ) );
565 aSet.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
567 pSdrObj->SetMergedItemSet(aSet);
570 if( bUndo )
572 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
575 if( bUndo )
577 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pSdrObj ) );
578 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pSdrObj) );
581 InsertPresObj(pSdrObj, eObjKind);
582 pSdrObj->SetUserCall(this);
584 pSdrObj->RecalcBoundRect();
587 return pSdrObj;
590 /*************************************************************************
592 |* Creates presentation objects on the master page.
593 |* All presentation objects get a UserCall to the page.
595 \************************************************************************/
597 SfxStyleSheet* SdPage::GetStyleSheetForMasterPageBackground() const
599 OUString aName(GetLayoutName());
600 OUString aSep( SD_LT_SEPARATOR );
601 sal_Int32 nPos = aName.indexOf(aSep);
603 if (nPos != -1)
605 nPos = nPos + aSep.getLength();
606 aName = aName.copy(0, nPos);
609 aName += STR_LAYOUT_BACKGROUND;
611 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
612 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SfxStyleFamily::Page);
613 return static_cast<SfxStyleSheet*>(pResult);
616 SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const
618 OUString aName(GetLayoutName());
619 OUString aSep( SD_LT_SEPARATOR );
620 sal_Int32 nPos = aName.indexOf(aSep);
621 if (nPos != -1)
623 nPos = nPos + aSep.getLength();
624 aName = aName.copy(0, nPos);
627 switch (eObjKind)
629 case PRESOBJ_OUTLINE:
631 aName = GetLayoutName() + " " + OUString::number( 1 );
633 break;
635 case PRESOBJ_TITLE:
636 aName += STR_LAYOUT_TITLE;
637 break;
639 case PRESOBJ_NOTES:
640 aName += STR_LAYOUT_NOTES;
641 break;
643 case PRESOBJ_TEXT:
644 aName += STR_LAYOUT_SUBTITLE;
645 break;
647 case PRESOBJ_HEADER:
648 case PRESOBJ_FOOTER:
649 case PRESOBJ_DATETIME:
650 case PRESOBJ_SLIDENUMBER:
651 aName += STR_LAYOUT_BACKGROUNDOBJECTS;
652 break;
654 default:
655 break;
658 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
659 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SfxStyleFamily::Page);
660 return static_cast<SfxStyleSheet*>(pResult);
663 /** returns the presentation style with the given helpid from this masterpage or this
664 slides masterpage */
665 SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
667 OUString aStyleName( mpPage->GetLayoutName() );
668 const OUString aSep( SD_LT_SEPARATOR );
669 sal_Int32 nIndex = aStyleName.indexOf(aSep);
670 if( nIndex != -1 )
671 aStyleName = aStyleName.copy(0, nIndex + aSep.getLength());
673 const char *pNameId;
674 bool bOutline = false;
675 switch( nHelpId )
677 case HID_PSEUDOSHEET_TITLE: pNameId = STR_LAYOUT_TITLE; break;
678 case HID_PSEUDOSHEET_SUBTITLE: pNameId = STR_LAYOUT_SUBTITLE; break;
679 case HID_PSEUDOSHEET_OUTLINE1:
680 case HID_PSEUDOSHEET_OUTLINE2:
681 case HID_PSEUDOSHEET_OUTLINE3:
682 case HID_PSEUDOSHEET_OUTLINE4:
683 case HID_PSEUDOSHEET_OUTLINE5:
684 case HID_PSEUDOSHEET_OUTLINE6:
685 case HID_PSEUDOSHEET_OUTLINE7:
686 case HID_PSEUDOSHEET_OUTLINE8:
687 case HID_PSEUDOSHEET_OUTLINE9: pNameId = STR_LAYOUT_OUTLINE; bOutline = true; break;
688 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: pNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break;
689 case HID_PSEUDOSHEET_BACKGROUND: pNameId = STR_LAYOUT_BACKGROUND; break;
690 case HID_PSEUDOSHEET_NOTES: pNameId = STR_LAYOUT_NOTES; break;
692 default:
693 OSL_FAIL( "SdPage::getPresentationStyle(), illegal argument!" );
694 return nullptr;
696 aStyleName += OUString::createFromAscii(pNameId);
697 if (bOutline)
699 aStyleName += " ";
700 aStyleName += OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ));
703 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
704 SfxStyleSheetBase* pResult = pStShPool->Find(aStyleName, SfxStyleFamily::Page);
705 return dynamic_cast<SdStyleSheet*>(pResult);
708 /*************************************************************************
710 |* The presentation object rObj has changed and is no longer referenced by the
711 |* presentation object of the master page.
712 |* The UserCall is deleted.
714 \************************************************************************/
716 void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools::Rectangle& )
718 if (!maLockAutoLayoutArrangement.isLocked())
720 switch (eType)
722 case SdrUserCallType::MoveOnly:
723 case SdrUserCallType::Resize:
725 if ( getSdrModelFromSdrPage().isLocked())
726 break;
728 SdrObject* pObj = const_cast<SdrObject*>(&rObj);
730 if (pObj)
732 if (!mbMaster)
734 if( pObj->GetUserCall() )
736 ::svl::IUndoManager* pUndoManager = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager();
737 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
739 if( bUndo )
740 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pObj) );
742 // Object was resized by user and does not listen to its slide anymore
743 pObj->SetUserCall(nullptr);
746 else
748 // Object of the master page changed, therefore adjust
749 // object on all pages
750 sal_uInt16 nPageCount = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetSdPageCount(mePageKind);
752 for (sal_uInt16 i = 0; i < nPageCount; i++)
754 SdPage* pLoopPage = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetSdPage(i, mePageKind);
756 if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
758 // Page listens to this master page, therefore
759 // adjust AutoLayout
760 pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
766 break;
768 case SdrUserCallType::Delete:
769 case SdrUserCallType::Removed:
770 default:
771 break;
776 /*************************************************************************
778 |* Creates on a master page: background, title- and layout area
780 \************************************************************************/
782 void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
784 ::svl::IUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
785 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
787 SdPage* pMasterPage = this;
789 if (!mbMaster)
791 pMasterPage = static_cast<SdPage*>(&(TRG_GetMasterPage()));
794 if (!pMasterPage)
796 return;
799 /**************************************************************************
800 * create background, title- and layout area
801 **************************************************************************/
802 if( mePageKind == PageKind::Standard )
804 pMasterPage->EnsureMasterPageDefaultBackground();
807 if (static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocumentType() == DocumentType::Impress)
809 if( mePageKind == PageKind::Handout && bInit )
811 // handout template
813 // delete all available handout presentation objects
814 SdrObject *pObj=nullptr;
815 while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != nullptr )
817 pMasterPage->RemoveObject(pObj->GetOrdNum());
819 if( bUndo )
821 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
823 else
825 SdrObject::Free( pObj );
829 std::vector< ::tools::Rectangle > aAreas;
830 CalculateHandoutAreas( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()), pMasterPage->GetAutoLayout(), false, aAreas );
832 const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
833 std::vector< ::tools::Rectangle >::iterator iter( aAreas.begin() );
835 while( iter != aAreas.end() )
837 SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, false, (*iter++)) );
838 // #i105146# We want no content to be displayed for PageKind::Handout,
839 // so just never set a page as content
840 pPageObj->SetReferencedPage(nullptr);
842 if( bSkip && iter != aAreas.end() )
843 ++iter;
847 if( mePageKind != PageKind::Handout )
849 SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE );
850 if( pMasterTitle == nullptr )
851 pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE);
853 SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PageKind::Notes ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
854 if( pMasterOutline == nullptr )
855 pMasterPage->CreateDefaultPresObj( mePageKind == PageKind::Standard ? PRESOBJ_OUTLINE : PRESOBJ_NOTES );
858 // create header&footer objects
860 if( bCreate )
862 if( mePageKind != PageKind::Standard )
864 SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER );
865 if( pHeader == nullptr )
866 pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER );
869 SdrObject* pDate = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
870 if( pDate == nullptr )
871 pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME );
873 SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
874 if( pFooter == nullptr )
875 pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER );
877 SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
878 if( pNumber == nullptr )
879 pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER );
884 namespace {
886 static const o3tl::enumarray<PageKind, char const *> PageKindVector = {
887 "PageKind::Standard", "PageKind::Notes", "PageKind::Handout"
890 const char* const PresObjKindVector[] = {
891 "PRESOBJ_NONE", "PRESOBJ_TITLE", "PRESOBJ_OUTLINE",
892 "PRESOBJ_TEXT" ,"PRESOBJ_GRAPHIC" , "PRESOBJ_OBJECT",
893 "PRESOBJ_CHART", "PRESOBJ_ORGCHART", "PRESOBJ_TABLE",
894 "PRESOBJ_PAGE", "PRESOBJ_HANDOUT",
895 "PRESOBJ_NOTES","PRESOBJ_HEADER", "PRESOBJ_FOOTER",
896 "PRESOBJ_DATETIME", "PRESOBJ_SLIDENUMBER", "PRESOBJ_CALC",
897 "PRESOBJ_MEDIA", "PRESOBJ_MAX"
900 void getPresObjProp( const SdPage& rPage, const char* sObjKind, const char* sPageKind, double presObjPropValue[] )
902 bool bNoObjectFound = true; //used to break from outer loop
904 const std::vector< Reference<XNode> >& objectInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetObjectVector();
905 for( std::vector< Reference<XNode> >::const_iterator aIter=objectInfo.begin(); aIter != objectInfo.end(); ++aIter )
907 if(bNoObjectFound)
909 Reference<XNode> objectNode = *aIter; //get i'th object element
910 Reference<XNamedNodeMap> objectattrlist = objectNode->getAttributes();
911 Reference<XNode> objectattr = objectattrlist->getNamedItem("type");
912 rtl::OUString sObjType = objectattr->getNodeValue();
914 if (sObjType.equalsAscii(sObjKind))
916 Reference<XNodeList> objectChildren = objectNode->getChildNodes();
917 const int objSize = objectChildren->getLength();
919 for( int j=0; j< objSize; j++)
921 Reference<XNode> obj = objectChildren->item(j);
922 rtl::OUString nodename = obj->getNodeName();
924 //check whether children is blank 'text-node' or 'object-prop' node
925 if(nodename == "object-prop")
927 Reference<XNamedNodeMap> ObjAttributes = obj->getAttributes();
928 Reference<XNode> ObjPageKind = ObjAttributes->getNamedItem("pagekind");
929 rtl::OUString sObjPageKind = ObjPageKind->getNodeValue();
931 if (sObjPageKind.equalsAscii(sPageKind))
933 Reference<XNode> ObjSizeHeight = ObjAttributes->getNamedItem("relative-height");
934 rtl::OUString sValue = ObjSizeHeight->getNodeValue();
935 presObjPropValue[0] = sValue.toDouble();
937 Reference<XNode> ObjSizeWidth = ObjAttributes->getNamedItem("relative-width");
938 sValue = ObjSizeWidth->getNodeValue();
939 presObjPropValue[1] = sValue.toDouble();
941 Reference<XNode> ObjPosX = ObjAttributes->getNamedItem("relative-posX");
942 sValue = ObjPosX->getNodeValue();
943 presObjPropValue[2] = sValue.toDouble();
945 Reference<XNode> ObjPosY = ObjAttributes->getNamedItem("relative-posY");
946 sValue = ObjPosY->getNodeValue();
947 presObjPropValue[3] = sValue.toDouble();
949 bNoObjectFound = false;
950 break;
956 else
957 break;
963 SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind)
965 if( eObjKind == PRESOBJ_TITLE )
967 ::tools::Rectangle aTitleRect( GetTitleRect() );
968 return CreatePresObj(PRESOBJ_TITLE, false, aTitleRect);
970 else if( eObjKind == PRESOBJ_OUTLINE )
972 ::tools::Rectangle aLayoutRect( GetLayoutRect() );
973 return CreatePresObj( PRESOBJ_OUTLINE, false, aLayoutRect);
975 else if( eObjKind == PRESOBJ_NOTES )
977 ::tools::Rectangle aLayoutRect( GetLayoutRect() );
978 return CreatePresObj( PRESOBJ_NOTES, false, aLayoutRect);
980 else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) )
982 double propvalue[] = {0,0,0,0};
983 const char* sObjKind = PresObjKindVector[eObjKind];
984 const char* sPageKind = PageKindVector[mePageKind];
985 // create footer objects for standard master page
986 if( mePageKind == PageKind::Standard )
988 const long nLftBorder = GetLeftBorder();
989 const long nUppBorder = GetUpperBorder();
991 Point aPos ( nLftBorder, nUppBorder );
992 Size aSize ( GetSize() );
994 aSize.AdjustWidth( -(nLftBorder + GetRightBorder()) );
995 aSize.AdjustHeight( -(nUppBorder + GetLowerBorder()) );
997 getPresObjProp( *this, sObjKind, sPageKind, propvalue);
998 aPos.AdjustX(long( aSize.Width() * propvalue[2] ) );
999 aPos.AdjustY(long( aSize.Height() * propvalue[3] ) );
1000 aSize.setWidth( long( aSize.Width() * propvalue[1] ) );
1001 aSize.setHeight( long( aSize.Height() * propvalue[0] ) );
1003 if(eObjKind == PRESOBJ_HEADER )
1005 OSL_FAIL( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a master slide" );
1006 return nullptr;
1008 else
1010 ::tools::Rectangle aRect( aPos, aSize );
1011 return CreatePresObj( eObjKind, false, aRect );
1014 else
1016 // create header&footer objects for handout and notes master
1017 Size aPageSize ( GetSize() );
1018 aPageSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1019 aPageSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1021 Point aPosition ( GetLeftBorder(), GetUpperBorder() );
1023 getPresObjProp( *this, sObjKind, sPageKind, propvalue);
1024 int NOTES_HEADER_FOOTER_WIDTH = long(aPageSize.Width() * propvalue[1]);
1025 int NOTES_HEADER_FOOTER_HEIGHT = long(aPageSize.Height() * propvalue[0]);
1026 Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
1027 Point aPos ( 0 ,0 );
1028 if( propvalue[2] == 0 )
1029 aPos.setX( aPosition.X() );
1030 else
1031 aPos.setX( aPosition.X() + long( aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH ) );
1032 if( propvalue[3] == 0 )
1033 aPos.setY( aPosition.Y() );
1034 else
1035 aPos.setY( aPosition.Y() + long( aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT ) );
1037 ::tools::Rectangle aRect( aPos, aSize );
1038 return CreatePresObj( eObjKind, false, aRect );
1041 else
1043 OSL_FAIL("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
1044 return nullptr;
1048 void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
1050 SdrObject* pObject = GetPresObj( eObjKind );
1052 if( pObject )
1054 SdDrawDocument* pDoc(static_cast< SdDrawDocument* >(&getSdrModelFromSdrPage()));
1055 const bool bUndo = pDoc->IsUndoEnabled();
1056 if( bUndo )
1057 pDoc->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
1058 SdrObjList* pOL = pObject->getParentOfSdrObject();
1059 pOL->RemoveObject(pObject->GetOrdNumDirect());
1061 if( !bUndo )
1062 SdrObject::Free(pObject);
1066 /*************************************************************************
1068 |* return title area
1070 \************************************************************************/
1072 ::tools::Rectangle SdPage::GetTitleRect() const
1074 ::tools::Rectangle aTitleRect;
1076 if (mePageKind != PageKind::Handout)
1078 double propvalue[] = {0,0,0,0};
1080 /******************************************************************
1081 * standard- or note page: title area
1082 ******************************************************************/
1083 Point aTitlePos ( GetLeftBorder(), GetUpperBorder() );
1084 Size aTitleSize ( GetSize() );
1085 aTitleSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1086 aTitleSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1087 const char* sPageKind = PageKindVector[mePageKind];
1089 if (mePageKind == PageKind::Standard)
1091 getPresObjProp( *this , "PRESOBJ_TITLE" ,sPageKind, propvalue);
1092 aTitlePos.AdjustX(long( aTitleSize.Width() * propvalue[2] ) );
1093 aTitlePos.AdjustY(long( aTitleSize.Height() * propvalue[3] ) );
1094 aTitleSize.setWidth( long( aTitleSize.Width() * propvalue[1] ) );
1095 aTitleSize.setHeight( long( aTitleSize.Height() * propvalue[0] ) );
1097 else if (mePageKind == PageKind::Notes)
1099 Point aPos = aTitlePos;
1100 getPresObjProp( *this, "PRESOBJ_TITLE" ,sPageKind, propvalue);
1101 aPos.AdjustX(long( aTitleSize.Width() * propvalue[2] ) );
1102 aPos.AdjustY(long( aTitleSize.Height() * propvalue[3] ) );
1104 // limit height
1105 aTitleSize.setHeight( long( aTitleSize.Height() * propvalue[0] ) );
1106 aTitleSize.setWidth( long( aTitleSize.Width() * propvalue[1] ) );
1108 Size aPartArea = aTitleSize;
1109 Size aSize;
1110 sal_uInt16 nDestPageNum(GetPageNum());
1111 SdrPage* pRefPage = nullptr;
1113 if(nDestPageNum)
1115 // only decrement if != 0, else we get 0xffff
1116 nDestPageNum -= 1;
1119 if(nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
1121 pRefPage = getSdrModelFromSdrPage().GetPage(nDestPageNum);
1124 if ( pRefPage )
1126 // scale actually page size into handout rectangle
1127 double fH = pRefPage->GetWidth() == 0
1128 ? 0 : static_cast<double>(aPartArea.Width()) / pRefPage->GetWidth();
1129 double fV = pRefPage->GetHeight() == 0
1130 ? 0 : static_cast<double>(aPartArea.Height()) / pRefPage->GetHeight();
1132 if ( fH > fV )
1133 fH = fV;
1134 aSize.setWidth( static_cast<long>(fH * pRefPage->GetWidth()) );
1135 aSize.setHeight( static_cast<long>(fH * pRefPage->GetHeight()) );
1137 aPos.AdjustX((aPartArea.Width() - aSize.Width()) / 2 );
1138 aPos.AdjustY((aPartArea.Height()- aSize.Height())/ 2 );
1141 aTitlePos = aPos;
1142 aTitleSize = aSize;
1145 aTitleRect.SetPos(aTitlePos);
1146 aTitleRect.SetSize(aTitleSize);
1149 return aTitleRect;
1152 /*************************************************************************
1154 |* return outline area
1156 \************************************************************************/
1158 ::tools::Rectangle SdPage::GetLayoutRect() const
1160 ::tools::Rectangle aLayoutRect;
1162 if (mePageKind != PageKind::Handout)
1164 double propvalue[] = {0,0,0,0};
1166 Point aLayoutPos ( GetLeftBorder(), GetUpperBorder() );
1167 Size aLayoutSize ( GetSize() );
1168 aLayoutSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1169 aLayoutSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1170 const char* sPageKind = PageKindVector[mePageKind];
1172 if (mePageKind == PageKind::Standard)
1174 getPresObjProp( *this ,"PRESOBJ_OUTLINE", sPageKind, propvalue);
1175 aLayoutPos.AdjustX(long( aLayoutSize.Width() * propvalue[2] ) );
1176 aLayoutPos.AdjustY(long( aLayoutSize.Height() * propvalue[3] ) );
1177 aLayoutSize.setWidth( long( aLayoutSize.Width() * propvalue[1] ) );
1178 aLayoutSize.setHeight( long( aLayoutSize.Height() * propvalue[0] ) );
1179 aLayoutRect.SetPos(aLayoutPos);
1180 aLayoutRect.SetSize(aLayoutSize);
1182 else if (mePageKind == PageKind::Notes)
1184 getPresObjProp( *this, "PRESOBJ_NOTES", sPageKind, propvalue);
1185 aLayoutPos.AdjustX(long( aLayoutSize.Width() * propvalue[2] ) );
1186 aLayoutPos.AdjustY(long( aLayoutSize.Height() * propvalue[3] ) );
1187 aLayoutSize.setWidth( long( aLayoutSize.Width() * propvalue[1] ) );
1188 aLayoutSize.setHeight( long( aLayoutSize.Height() * propvalue[0] ) );
1189 aLayoutRect.SetPos(aLayoutPos);
1190 aLayoutRect.SetSize(aLayoutSize);
1194 return aLayoutRect;
1197 /**************************************************************************
1199 |* assign a AutoLayout
1201 \*************************************************************************/
1203 const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout
1204 const int VERTICAL = 0x8000;
1206 struct LayoutDescriptor
1208 PresObjKind meKind[MAX_PRESOBJS];
1209 bool mbVertical[MAX_PRESOBJS];
1211 LayoutDescriptor( int k0 = 0, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0, int k5 = 0, int k6 = 0 );
1214 LayoutDescriptor::LayoutDescriptor( int k0, int k1, int k2, int k3, int k4, int k5, int k6 )
1216 meKind[0] = static_cast<PresObjKind>(k0 & (~VERTICAL)); mbVertical[0] = (k0 & VERTICAL) == VERTICAL;
1217 meKind[1] = static_cast<PresObjKind>(k1 & (~VERTICAL)); mbVertical[1] = (k1 & VERTICAL) == VERTICAL;
1218 meKind[2] = static_cast<PresObjKind>(k2 & (~VERTICAL)); mbVertical[2] = (k2 & VERTICAL) == VERTICAL;
1219 meKind[3] = static_cast<PresObjKind>(k3 & (~VERTICAL)); mbVertical[3] = (k3 & VERTICAL) == VERTICAL;
1220 meKind[4] = static_cast<PresObjKind>(k4 & (~VERTICAL)); mbVertical[4] = (k4 & VERTICAL) == VERTICAL;
1221 meKind[5] = static_cast<PresObjKind>(k5 & (~VERTICAL)); mbVertical[5] = (k5 & VERTICAL) == VERTICAL;
1222 meKind[6] = static_cast<PresObjKind>(k6 & (~VERTICAL)); mbVertical[6] = (k6 & VERTICAL) == VERTICAL;
1225 static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
1227 static const LayoutDescriptor aLayouts[AUTOLAYOUT_END-AUTOLAYOUT_START] =
1229 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_TEXT ), // AUTOLAYOUT_TITLE
1230 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_CONTENT
1231 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHART
1232 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_2CONTENT
1233 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTCHART
1234 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_ORG
1235 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTCLbIP
1236 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHARTTEXT
1237 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TAB
1238 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CLIPTEXT
1239 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ
1240 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OBJECT ), // AUTOLAYOUT_OBJ
1241 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_CONTENT_2CONTENT
1242 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ
1243 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT
1244 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_2CONTENT_CONTENT
1245 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT
1246 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOVEROBJ
1247 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_TITLE_4CONTENT
1248 PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ),
1249 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_NONE ), // AUTOLAYOUT_TITLE_ONLY
1250 LayoutDescriptor( PRESOBJ_NONE ), // AUTOLAYOUT_NONE
1251 LayoutDescriptor( PRESOBJ_PAGE, PRESOBJ_NOTES ), // AUTOLAYOUT_NOTES
1252 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT1
1253 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT2
1254 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT3
1255 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT4
1256 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT6
1257 LayoutDescriptor( PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE ),// AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT
1258 LayoutDescriptor( PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_VTITLE_VCONTENT
1259 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_VCONTENT
1260 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_2VTEXT
1261 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT9
1262 LayoutDescriptor( PRESOBJ_TEXT, PRESOBJ_NONE ), // AUTOLAYOUT_ONLY_TEXT
1263 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_4CLIPART
1264 PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC ),
1265 LayoutDescriptor( PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_TITLE_6CONTENT
1266 PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE )
1269 if( (eLayout < AUTOLAYOUT_START) || (eLayout >= AUTOLAYOUT_END) )
1270 eLayout = AUTOLAYOUT_NONE;
1272 return aLayouts[ eLayout - AUTOLAYOUT_START ];
1275 rtl::OUString enumtoString(AutoLayout aut)
1277 rtl::OUString retstr;
1278 switch (aut)
1280 case AUTOLAYOUT_TITLE_CONTENT:
1281 retstr="AUTOLAYOUT_TITLE_CONTENT";
1282 break;
1283 case AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT:
1284 retstr="AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT";
1285 break;
1286 case AUTOLAYOUT_TITLE_CONTENT_2CONTENT:
1287 retstr="AUTOLAYOUT_TITLE_CONTENT_2CONTENT";
1288 break;
1289 case AUTOLAYOUT_TITLE_4CONTENT:
1290 retstr="AUTOLAYOUT_TITLE_4CONTENT";
1291 break;
1292 case AUTOLAYOUT_ONLY_TEXT:
1293 retstr="AUTOLAYOUT_ONLY_TEXT";
1294 break;
1295 case AUTOLAYOUT_TITLE_ONLY:
1296 retstr="AUTOLAYOUT_TITLE_ONLY";
1297 break;
1298 case AUTOLAYOUT_TITLE_6CONTENT:
1299 retstr="AUTOLAYOUT_TITLE_6CONTENT";
1300 break;
1301 case AUTOLAYOUT_START:
1302 retstr="AUTOLAYOUT_START";
1303 break;
1304 case AUTOLAYOUT_TITLE_2CONTENT_CONTENT:
1305 retstr="AUTOLAYOUT_TITLE_2CONTENT_CONTENT";
1306 break;
1307 case AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT:
1308 retstr="AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT";
1309 break;
1310 case AUTOLAYOUT_TITLE_2CONTENT:
1311 retstr="AUTOLAYOUT_TITLE_2CONTENT";
1312 break;
1313 case AUTOLAYOUT_VTITLE_VCONTENT:
1314 retstr="AUTOLAYOUT_VTITLE_VCONTENT";
1315 break;
1316 case AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT:
1317 retstr="AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT";
1318 break;
1319 case AUTOLAYOUT_TITLE_VCONTENT:
1320 retstr="AUTOLAYOUT_TITLE_VCONTENT";
1321 break;
1322 case AUTOLAYOUT_TITLE_2VTEXT:
1323 retstr="AUTOLAYOUT_TITLE_2VTEXT";
1324 break;
1325 default:
1326 retstr="unknown";
1327 break;
1328 // case AUTOLAYOUT_TITLE_4SCONTENT: return "AUTOLAYOUT_TITLE_4SCONTENT";
1330 return retstr;
1333 static void CalcAutoLayoutRectangles( SdPage const & rPage,::tools::Rectangle* rRectangle ,const rtl::OUString& sLayoutType )
1335 ::tools::Rectangle aTitleRect;
1336 ::tools::Rectangle aLayoutRect;
1338 if( rPage.GetPageKind() != PageKind::Handout )
1340 SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage());
1341 SdrObject* pMasterTitle = rMasterPage.GetPresObj( PRESOBJ_TITLE );
1342 SdrObject* pMasterSubTitle = rMasterPage.GetPresObj( PRESOBJ_TEXT );
1343 SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PageKind::Notes ? PRESOBJ_NOTES : PRESOBJ_OUTLINE );
1345 if( pMasterTitle )
1346 aTitleRect = pMasterTitle->GetLogicRect();
1348 if (aTitleRect.IsEmpty() )
1349 aTitleRect = rPage.GetTitleRect();
1350 if( pMasterSubTitle )
1351 aLayoutRect = pMasterSubTitle->GetLogicRect();
1352 else if( pMasterOutline )
1353 aLayoutRect = pMasterOutline->GetLogicRect();
1355 if (aLayoutRect.IsEmpty() )
1356 aLayoutRect = rPage.GetLayoutRect();
1359 rRectangle[0] = aTitleRect;
1360 for( int i = 1; i < MAX_PRESOBJS; i++ )
1361 rRectangle[i] = aLayoutRect;
1363 const Point aTitlePos( aTitleRect.TopLeft() );
1364 const Size aLayoutSize( aLayoutRect.GetSize() );
1365 const Point aLayoutPos( aLayoutRect.TopLeft() );
1366 double propvalue[] = {0,0,0,0};
1368 const std::vector< Reference<XNode> >& layoutInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetLayoutVector();
1369 for( std::vector< Reference<XNode> >::const_iterator aIter=layoutInfo.begin(); aIter != layoutInfo.end(); ++aIter )
1371 Reference<XNode> layoutNode = *aIter;
1372 Reference<XNamedNodeMap> layoutAttrList =layoutNode->getAttributes();
1374 // get the attribute value of layout (i.e it's type)
1375 rtl::OUString sLayoutAttName =
1376 layoutAttrList->getNamedItem("type")->getNodeValue();
1377 if(sLayoutAttName == sLayoutType)
1379 int count=0;
1380 Reference<XNodeList> layoutChildren = layoutNode->getChildNodes();
1381 const int presobjsize = layoutChildren->getLength();
1382 for( int j=0; j< presobjsize ; j++)
1384 rtl::OUString nodename;
1385 Reference<XNode> presobj = layoutChildren->item(j);
1386 nodename=presobj->getNodeName();
1388 //check whether children is blank 'text-node' or 'presobj' node
1389 if(nodename == "presobj")
1391 // TODO: rework sd to permit arbitrary number of presentation objects
1392 assert(count < MAX_PRESOBJS);
1394 Reference<XNamedNodeMap> presObjAttributes = presobj->getAttributes();
1396 Reference<XNode> presObjSizeHeight = presObjAttributes->getNamedItem("relative-height");
1397 rtl::OUString sValue = presObjSizeHeight->getNodeValue();
1398 propvalue[0] = sValue.toDouble();
1400 Reference<XNode> presObjSizeWidth = presObjAttributes->getNamedItem("relative-width");
1401 sValue = presObjSizeWidth->getNodeValue();
1402 propvalue[1] = sValue.toDouble();
1404 Reference<XNode> presObjPosX = presObjAttributes->getNamedItem("relative-posX");
1405 sValue = presObjPosX->getNodeValue();
1406 propvalue[2] = sValue.toDouble();
1408 Reference<XNode> presObjPosY = presObjAttributes->getNamedItem("relative-posY");
1409 sValue = presObjPosY->getNodeValue();
1410 propvalue[3] = sValue.toDouble();
1412 if(count == 0)
1414 Size aSize ( aTitleRect.GetSize() );
1415 aSize.setHeight( basegfx::fround(aSize.Height() * propvalue[0]) );
1416 aSize.setWidth( basegfx::fround(aSize.Width() * propvalue[1]) );
1417 Point aPos( basegfx::fround(aTitlePos.X() +(aSize.Width() * propvalue[2])),
1418 basegfx::fround(aTitlePos.Y() + (aSize.Height() * propvalue[3])) );
1419 rRectangle[count] = ::tools::Rectangle(aPos, aSize);
1420 count = count+1;
1422 else
1424 Size aSize( basegfx::fround(aLayoutSize.Width() * propvalue[1]),
1425 basegfx::fround(aLayoutSize.Height() * propvalue[0]) );
1426 Point aPos( basegfx::fround(aLayoutPos.X() +(aSize.Width() * propvalue[2])),
1427 basegfx::fround(aLayoutPos.Y() + (aSize.Height() * propvalue[3])) );
1428 rRectangle[count] = ::tools::Rectangle (aPos, aSize);
1429 count = count+1;
1433 break;
1438 void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::vector< SdrObject* >& rShapes, bool bInit, bool bSwitchLayout )
1440 int i;
1442 // init list of indexes for each presentation shape kind
1443 // this is used to find subsequent shapes with the same presentation shape kind
1444 int PresObjIndex[PRESOBJ_MAX];
1445 for( i = 0; i < PRESOBJ_MAX; i++ ) PresObjIndex[i] = 1;
1447 bool bMissing = false;
1449 // for each entry in the layoutdescriptor, arrange a presentation shape
1450 for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1452 PresObjKind eKind = rDescriptor.meKind[i];
1453 SdrObject* pObj = nullptr;
1454 while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != nullptr )
1456 PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
1458 if( !bSwitchLayout || !pObj->IsEmptyPresObj() )
1460 rShapes[i] = pObj;
1461 break;
1465 if( !pObj )
1466 bMissing = true;
1469 if( bMissing && bInit )
1471 // for each entry in the layoutdescriptor, look for an alternative shape
1472 for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1474 if( rShapes[i] )
1475 continue;
1477 PresObjKind eKind = rDescriptor.meKind[i];
1479 SdrObject* pObj = nullptr;
1480 bool bFound = false;
1482 const size_t nShapeCount = rPage.GetObjCount();
1483 for(size_t nShapeIndex = 0; nShapeIndex < nShapeCount && !bFound; ++nShapeIndex )
1485 pObj = rPage.GetObj(nShapeIndex);
1487 if( pObj->IsEmptyPresObj() )
1488 continue;
1490 if( pObj->GetObjInventor() != SdrInventor::Default )
1491 continue;
1493 // do not reuse shapes that are already part of the layout
1494 if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() )
1495 continue;
1497 bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SfxStyleFamily::Page);
1498 SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() );
1500 switch( eKind )
1502 case PRESOBJ_TITLE:
1503 bFound = eSdrObjKind == OBJ_TITLETEXT;
1504 break;
1505 case PRESOBJ_TABLE:
1506 bFound = eSdrObjKind == OBJ_TABLE;
1507 break;
1508 case PRESOBJ_MEDIA:
1509 bFound = eSdrObjKind == OBJ_MEDIA;
1510 break;
1511 case PRESOBJ_OUTLINE:
1512 bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
1513 ((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
1514 (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2);
1515 break;
1516 case PRESOBJ_GRAPHIC:
1517 bFound = eSdrObjKind == OBJ_GRAF;
1518 break;
1519 case PRESOBJ_OBJECT:
1520 if( eSdrObjKind == OBJ_OLE2 )
1522 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1523 if( pOle2 )
1525 if( pOle2->IsEmpty() )
1526 bFound = true;
1527 else
1529 ::comphelper::IEmbeddedHelper* pPersist(rPage.getSdrModelFromSdrPage().GetPersist());
1531 if( pPersist )
1533 uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
1534 GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
1536 // TODO CL->KA: Why is this not working anymore?
1537 if( xObject.is() )
1539 SvGlobalName aClassId( xObject->getClassID() );
1541 const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
1542 const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
1543 const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
1545 if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
1547 bFound = true;
1554 break;
1555 case PRESOBJ_CHART:
1556 case PRESOBJ_CALC:
1557 if( eSdrObjKind == OBJ_OLE2 )
1559 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1560 if( pOle2 )
1563 ((eKind == PRESOBJ_CHART) &&
1564 ( pOle2->GetProgName() == "StarChart" || pOle2->IsChart() ) )
1566 ((eKind == PRESOBJ_CALC) &&
1567 ( pOle2->GetProgName() == "StarCalc" || pOle2->IsCalc() ) ) )
1569 bFound = true;
1572 break;
1574 else if( eSdrObjKind == OBJ_TABLE )
1576 bFound = true;
1578 break;
1579 case PRESOBJ_PAGE:
1580 case PRESOBJ_HANDOUT:
1581 bFound = eSdrObjKind == OBJ_PAGE;
1582 break;
1583 case PRESOBJ_NOTES:
1584 case PRESOBJ_TEXT:
1585 bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT);
1586 break;
1587 default:
1588 break;
1592 if( bFound )
1593 rShapes[i] = pObj;
1598 void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
1600 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1602 const bool bSwitchLayout = eLayout != GetAutoLayout();
1604 ::svl::IUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
1605 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
1607 meAutoLayout = eLayout;
1609 // if needed, creates and initialises the presentation shapes on this slides master page
1610 CreateTitleAndLayout(bInit, bCreate);
1612 if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster)
1614 // MasterPage or no layout and no presentation shapes available, nothing to do
1615 return;
1618 ::tools::Rectangle aRectangle[MAX_PRESOBJS];
1619 const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
1620 rtl::OUString sLayoutName( enumtoString(meAutoLayout) );
1621 CalcAutoLayoutRectangles( *this, aRectangle, sLayoutName);
1623 std::set< SdrObject* > aUsedPresentationObjects;
1625 std::vector< SdrObject* > aLayoutShapes(PRESOBJ_MAX, nullptr);
1626 findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
1628 int i;
1630 // for each entry in the layoutdescriptor, arrange a presentation shape
1631 for (i = 0; (i < MAX_PRESOBJS) && (aDescriptor.meKind[i] != PRESOBJ_NONE); i++)
1633 PresObjKind eKind = aDescriptor.meKind[i];
1634 SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );
1635 if( pObj )
1636 aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape
1639 // now delete all empty presentation objects that are no longer used by the new layout
1640 if( bInit )
1642 SdrObject* pObj = nullptr;
1643 maPresentationShapeList.seekShape(0);
1645 while( (pObj = maPresentationShapeList.getNextShape()) )
1647 if( aUsedPresentationObjects.count(pObj) == 0 )
1650 if( pObj->IsEmptyPresObj() )
1652 if( bUndo )
1653 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
1655 RemoveObject( pObj->GetOrdNum() );
1657 if( !bUndo )
1658 SdrObject::Free( pObj );
1660 /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */
1666 /*************************************************************************
1668 |* insert object
1670 \************************************************************************/
1672 void SdPage::NbcInsertObject(SdrObject* pObj, size_t nPos)
1674 FmFormPage::NbcInsertObject(pObj, nPos);
1676 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).InsertObject(pObj);
1678 SdrLayerID nId = pObj->GetLayer();
1679 if( mbMaster )
1681 if( nId == SdrLayerID(0) )
1682 pObj->NbcSetLayer( SdrLayerID(2) ); // wrong layer. corrected to BackgroundObj layer
1684 else
1686 if( nId == SdrLayerID(2) )
1687 pObj->NbcSetLayer( SdrLayerID(0) ); // wrong layer. corrected to layout layer
1691 /*************************************************************************
1693 |* remove object
1695 \************************************************************************/
1697 SdrObject* SdPage::RemoveObject(size_t nObjNum)
1699 onRemoveObject(GetObj( nObjNum ));
1700 return FmFormPage::RemoveObject(nObjNum);
1703 /*************************************************************************
1705 |* remove object without broadcast
1707 \************************************************************************/
1709 SdrObject* SdPage::NbcRemoveObject(size_t nObjNum)
1711 onRemoveObject(GetObj( nObjNum ));
1712 return FmFormPage::NbcRemoveObject(nObjNum);
1715 // Also override ReplaceObject methods to realize when
1716 // objects are removed with this mechanism instead of RemoveObject
1717 SdrObject* SdPage::NbcReplaceObject(SdrObject* pNewObj, size_t nObjNum)
1719 onRemoveObject(GetObj( nObjNum ));
1720 return FmFormPage::NbcReplaceObject(pNewObj, nObjNum);
1723 // Also override ReplaceObject methods to realize when
1724 // objects are removed with this mechanism instead of RemoveObject
1725 SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
1727 onRemoveObject(GetObj( nObjNum ));
1728 return FmFormPage::ReplaceObject(pNewObj, nObjNum);
1731 // called after a shape is removed or replaced from this slide
1733 void SdPage::onRemoveObject( SdrObject* pObject )
1735 if( pObject )
1737 RemovePresObj(pObject);
1739 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).RemoveObject(pObject);
1741 removeAnimations( pObject );
1745 void SdPage::SetSize(const Size& aSize)
1747 Size aOldSize = GetSize();
1749 if (aSize != aOldSize)
1751 FmFormPage::SetSize(aSize);
1755 void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
1757 if (nLft != GetLeftBorder() || nUpp != GetUpperBorder() ||
1758 nRgt != GetRightBorder() || nLwr != GetLowerBorder() )
1760 FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
1764 void SdPage::SetLeftBorder(sal_Int32 nBorder)
1766 if (nBorder != GetLeftBorder() )
1768 FmFormPage::SetLeftBorder(nBorder);
1772 void SdPage::SetRightBorder(sal_Int32 nBorder)
1774 if (nBorder != GetRightBorder() )
1776 FmFormPage::SetRightBorder(nBorder);
1780 void SdPage::SetUpperBorder(sal_Int32 nBorder)
1782 if (nBorder != GetUpperBorder() )
1784 FmFormPage::SetUpperBorder(nBorder);
1788 void SdPage::SetLowerBorder(sal_Int32 nBorder)
1790 if (nBorder != GetLowerBorder() )
1792 FmFormPage::SetLowerBorder(nBorder);
1796 /*************************************************************************
1798 |* Sets BackgroundFullSize and then calls AdjustBackground
1800 \************************************************************************/
1802 void SdPage::SetBackgroundFullSize( bool bIn )
1804 if( bIn != mbBackgroundFullSize )
1806 mbBackgroundFullSize = bIn;
1810 /*************************************************************************
1812 |* Adjust all objects to new page size.
1814 |* bScaleAllObj: all objects are scaled into the new area within the page
1815 |* margins. We scale the position and size. For presentation objects on the
1816 |* master page, we also scale the font height of the presentation template.
1818 \************************************************************************/
1820 void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rNewBorderRect, bool bScaleAllObj)
1822 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1824 mbScaleObjects = bScaleAllObj;
1825 SdrObject* pObj = nullptr;
1826 Point aRefPnt(0, 0);
1827 Size aNewPageSize(rNewPageSize);
1828 sal_Int32 nLeft = rNewBorderRect.Left();
1829 sal_Int32 nRight = rNewBorderRect.Right();
1830 sal_Int32 nUpper = rNewBorderRect.Top();
1831 sal_Int32 nLower = rNewBorderRect.Bottom();
1833 // negative values are fixed values
1834 // -> use up to date values
1835 if (aNewPageSize.Width() < 0)
1837 aNewPageSize.setWidth( GetWidth() );
1839 if (aNewPageSize.Height() < 0)
1841 aNewPageSize.setHeight( GetHeight() );
1843 if (nLeft < 0)
1845 nLeft = GetLeftBorder();
1847 if (nRight < 0)
1849 nRight = GetRightBorder();
1851 if (nUpper < 0)
1853 nUpper = GetUpperBorder();
1855 if (nLower < 0)
1857 nLower = GetLowerBorder();
1860 Size aBackgroundSize(aNewPageSize);
1862 if (mbScaleObjects)
1864 aBackgroundSize.AdjustWidth( -(nLeft + nRight) );
1865 aBackgroundSize.AdjustHeight( -(nUpper + nLower) );
1866 aNewPageSize = aBackgroundSize;
1869 long nOldWidth = GetWidth() - GetLeftBorder() - GetRightBorder();
1870 long nOldHeight = GetHeight() - GetUpperBorder() - GetLowerBorder();
1872 Fraction aFractX = Fraction(aNewPageSize.Width(), nOldWidth);
1873 Fraction aFractY = Fraction(aNewPageSize.Height(), nOldHeight);
1875 const size_t nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
1877 for (size_t nObj = 0; nObj < nObjCnt; ++nObj)
1879 bool bIsPresObjOnMaster = false;
1881 // all Objects
1882 pObj = GetObj(nObj);
1884 if (mbMaster && IsPresObj(pObj))
1886 // There is a presentation object on the master page
1887 bIsPresObjOnMaster = true;
1890 if (pObj)
1892 // remember aTopLeft as original TopLeft
1893 Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
1895 if (!pObj->IsEdgeObj())
1897 /**************************************************************
1898 * Scale objects
1899 **************************************************************/
1900 if (mbScaleObjects)
1902 // use aTopLeft as original TopLeft
1903 aRefPnt = aTopLeft;
1906 pObj->Resize(aRefPnt, aFractX, aFractY);
1908 if (mbScaleObjects)
1910 SdrObjKind eObjKind = static_cast<SdrObjKind>(pObj->GetObjIdentifier());
1912 if (bIsPresObjOnMaster)
1914 /**********************************************************
1915 * presentation template: adjust test height
1916 **********************************************************/
1918 if (pObj == GetPresObj(PRESOBJ_TITLE, 0))
1920 SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
1922 if (pTitleSheet)
1924 SfxItemSet& rSet = pTitleSheet->GetItemSet();
1926 const SvxFontHeightItem& rOldHgt = rSet.Get(EE_CHAR_FONTHEIGHT);
1927 sal_uLong nFontHeight = rOldHgt.GetHeight();
1928 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1929 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1931 if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1933 const SvxFontHeightItem& rOldHgt2 = rSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1934 nFontHeight = rOldHgt2.GetHeight();
1935 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1936 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1939 if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1941 const SvxFontHeightItem& rOldHgt2 = rSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1942 nFontHeight = rOldHgt2.GetHeight();
1943 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1944 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1947 pTitleSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
1950 else if (pObj == GetPresObj(PRESOBJ_OUTLINE, 0))
1952 OUString aName(GetLayoutName());
1953 aName += " ";
1955 for (sal_Int32 i=1; i<=9; i++)
1957 OUString sLayoutName( aName + OUString::number( i ) );
1958 SfxStyleSheet* pOutlineSheet = static_cast<SfxStyleSheet*>(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetStyleSheetPool()->Find(sLayoutName, SfxStyleFamily::Page));
1960 if (pOutlineSheet)
1962 // Calculate new font height
1963 SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
1965 const SvxFontHeightItem& rOldHgt = aTempSet.Get(EE_CHAR_FONTHEIGHT);
1966 sal_uLong nFontHeight = rOldHgt.GetHeight();
1967 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1968 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1970 if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1972 const SvxFontHeightItem& rOldHgt2 = aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1973 nFontHeight = rOldHgt2.GetHeight();
1974 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1975 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1978 if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1980 const SvxFontHeightItem& rOldHgt2 = aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1981 nFontHeight = rOldHgt2.GetHeight();
1982 nFontHeight = long(nFontHeight * static_cast<double>(aFractY));
1983 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1986 // adjust bullet
1987 static_cast<SdStyleSheet*>(pOutlineSheet)->AdjustToFontHeight(aTempSet, false);
1989 // Special treatment: reset the INVALIDS to
1990 // NULL pointer (otherwise we have INVALID's
1991 // or pointer to the DefaultItems in the
1992 // template; both would suppress the
1993 // attribute inheritance)
1994 aTempSet.ClearInvalidItems();
1996 // Special treatment: only the valid parts
1997 // of the BulletItems
1998 if (aTempSet.GetItemState(EE_PARA_BULLET) == SfxItemState::DEFAULT)
2000 SvxBulletItem aOldBulItem( pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET) );
2001 const SvxBulletItem& rNewBulItem = aTempSet.Get(EE_PARA_BULLET);
2002 aOldBulItem.CopyValidProperties(rNewBulItem);
2003 aTempSet.Put(aOldBulItem);
2006 pOutlineSheet->GetItemSet().Put(aTempSet);
2007 pOutlineSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
2011 else if (pObj == GetPresObj(PRESOBJ_NOTES, 0))
2013 SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PRESOBJ_NOTES);
2015 if (pNotesSheet)
2017 sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height();
2018 sal_uLong nFontHeight = static_cast<sal_uLong>(nHeight * 0.0741);
2019 SfxItemSet& rSet = pNotesSheet->GetItemSet();
2020 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
2021 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
2022 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
2023 pNotesSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
2027 else if ( eObjKind != OBJ_TITLETEXT &&
2028 eObjKind != OBJ_OUTLINETEXT &&
2029 dynamic_cast< const SdrTextObj *>( pObj ) != nullptr &&
2030 pObj->GetOutlinerParaObject() )
2032 /******************************************************
2033 * normal text object: adjust text height
2034 ******************************************************/
2035 SvtScriptType nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
2036 sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT;
2037 if ( nScriptType == SvtScriptType::ASIAN )
2038 nWhich = EE_CHAR_FONTHEIGHT_CJK;
2039 else if ( nScriptType == SvtScriptType::COMPLEX )
2040 nWhich = EE_CHAR_FONTHEIGHT_CTL;
2042 // use more modern method to scale the text height
2043 sal_uInt32 nFontHeight = static_cast<const SvxFontHeightItem&>(pObj->GetMergedItem(nWhich)).GetHeight();
2044 sal_uInt32 nNewFontHeight = sal_uInt32(static_cast<double>(nFontHeight) * static_cast<double>(aFractY));
2046 pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
2051 if (mbScaleObjects && !pObj->IsEdgeObj())
2053 /**************************************************************
2054 * scale object position
2055 **************************************************************/
2056 Point aNewPos;
2058 // corrected scaling; only distances may be scaled
2059 // use aTopLeft as original TopLeft
2060 aNewPos.setX( long((aTopLeft.X() - GetLeftBorder()) * static_cast<double>(aFractX)) + nLeft );
2061 aNewPos.setY( long((aTopLeft.Y() - GetUpperBorder()) * static_cast<double>(aFractY)) + nUpper );
2063 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
2065 if (aVec.Height() != 0 || aVec.Width() != 0)
2067 pObj->NbcMove(aVec);
2070 pObj->SetChanged();
2071 pObj->BroadcastObjectChange();
2077 SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect)
2079 SdDrawDocument& rModel(static_cast< SdDrawDocument& >(rPage.getSdrModelFromSdrPage()));
2080 if( !pSourceObj )
2081 return pSourceObj;
2083 ::svl::IUndoManager* pUndoManager = rModel.GetUndoManager();
2084 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
2086 SdrObject* pNewObj = pSourceObj;
2087 if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) )
2089 pNewObj = rPage.CreatePresObj(PRESOBJ_OUTLINE, bVertical, rRect);
2091 // Set text of the subtitle into PRESOBJ_OUTLINE
2092 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2094 if(pOutlParaObj)
2096 // assign text
2097 SdOutliner* pOutl = rModel.GetInternalOutliner();
2098 pOutl->Clear();
2099 pOutl->SetText( *pOutlParaObj );
2100 pOutlParaObj = pOutl->CreateParaObject();
2101 pNewObj->SetOutlinerParaObject( pOutlParaObj );
2102 pOutl->Clear();
2103 pNewObj->SetEmptyPresObj(false);
2105 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
2107 // assign new template
2108 OUString aName( rPage.GetLayoutName() + " " + OUString::number( nLevel ) );
2109 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( rModel.GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page) );
2111 if (pSheet)
2113 if (nLevel == 1)
2115 SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2117 if (pSubtitleSheet)
2118 pOutlParaObj->ChangeStyleSheetName(SfxStyleFamily::Page, pSubtitleSheet->GetName(), pSheet->GetName());
2121 pNewObj->StartListening(*pSheet);
2125 // Remove LRSpace item
2126 SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
2128 aSet.Put(pNewObj->GetMergedItemSet());
2130 aSet.ClearItem(EE_PARA_LRSPACE);
2132 pNewObj->SetMergedItemSet(aSet);
2134 if( bUndo )
2135 pUndoManager->AddUndoAction( rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
2137 // Remove outline shape from page
2138 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2140 if( !bUndo )
2141 SdrObject::Free( pSourceObj );
2144 else if((eObjKind == PRESOBJ_TEXT) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) )
2146 // is there an outline shape we can use to replace empty subtitle shape?
2147 pNewObj = rPage.CreatePresObj(PRESOBJ_TEXT, bVertical, rRect);
2149 // Set text of the outline object into PRESOBJ_TITLE
2150 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2152 if(pOutlParaObj)
2154 // assign text
2155 SdOutliner* pOutl = rModel.GetInternalOutliner();
2156 pOutl->Clear();
2157 pOutl->SetText( *pOutlParaObj );
2158 pOutlParaObj = pOutl->CreateParaObject();
2159 pNewObj->SetOutlinerParaObject( pOutlParaObj );
2160 pOutl->Clear();
2161 pNewObj->SetEmptyPresObj(false);
2163 // reset left indent
2164 SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
2166 aSet.Put(pNewObj->GetMergedItemSet());
2168 const SvxLRSpaceItem& rLRItem = aSet.Get(EE_PARA_LRSPACE);
2169 SvxLRSpaceItem aNewLRItem(rLRItem);
2170 aNewLRItem.SetTextLeft(0);
2171 aSet.Put(aNewLRItem);
2173 pNewObj->SetMergedItemSet(aSet);
2175 SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT);
2176 if (pSheet)
2177 pNewObj->SetStyleSheet(pSheet, true);
2179 // Remove subtitle shape from page
2180 if( bUndo )
2181 pUndoManager->AddUndoAction(rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
2183 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2185 if( !bUndo )
2186 SdrObject::Free( pSourceObj );
2189 else if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) )
2191 switch( pSourceObj->GetObjIdentifier() )
2193 case OBJ_TABLE: eObjKind = PRESOBJ_TABLE; break;
2194 case OBJ_MEDIA: eObjKind = PRESOBJ_MEDIA; break;
2195 case OBJ_GRAF: eObjKind = PRESOBJ_GRAPHIC; break;
2196 case OBJ_OLE2: eObjKind = PRESOBJ_OBJECT; break;
2200 return pNewObj;
2203 /** reuses or creates a presentation shape for an auto layout that fits the given parameter
2205 @param eObjKind
2206 The kind of presentation shape we like to have
2207 @param nIndex
2208 If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
2209 looking for an existing presentation shape
2210 @param bVertical
2211 If true, the shape is created vertical if bInit is true
2212 @param rRect
2213 The rectangle that should be used to transform the shape
2214 @param bInit
2215 If true the shape is created if not found
2216 @returns
2217 A presentation shape that was either found or created with the given parameters
2219 SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit)
2221 ::svl::IUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
2222 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
2224 if (!pObj && bInit)
2226 pObj = CreatePresObj(eObjKind, bVertical, rRect);
2228 else if ( pObj && (pObj->GetUserCall() || bInit) )
2230 // convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2231 if( bInit )
2232 pObj = convertPresentationObjectImpl(*this, pObj, eObjKind, bVertical, rRect);
2234 if( bUndo )
2236 pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
2237 pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoAttrObject( *pObj, true, true ) );
2238 pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
2241 pObj->AdjustToMaxRect(rRect);
2243 pObj->SetUserCall(this);
2245 SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
2246 if( pTextObject )
2248 if( pTextObject->IsVerticalWriting() != bVertical )
2250 pTextObject->SetVerticalWriting( bVertical );
2252 // here make sure the correct anchoring is used when the object
2253 // is re-used but orientation is changed
2254 if(PRESOBJ_OUTLINE == eObjKind)
2255 pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
2258 if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) )
2260 if ( pTextObject->IsAutoGrowHeight() )
2262 // switch off AutoGrowHeight, set new MinHeight
2263 SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2264 SdrMetricItem aMinHeight( makeSdrTextMinFrameHeightItem(rRect.GetSize().Height()) );
2265 aTempAttr.Put( aMinHeight );
2266 aTempAttr.Put( makeSdrTextAutoGrowHeightItem(false) );
2267 pTextObject->SetMergedItemSet(aTempAttr);
2268 pTextObject->SetLogicRect(rRect);
2270 // switch on AutoGrowHeight
2271 SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2272 aAttr.Put( makeSdrTextAutoGrowHeightItem(true) );
2274 pTextObject->SetMergedItemSet(aAttr);
2277 if ( pTextObject->IsAutoGrowWidth() )
2279 // switch off AutoGrowWidth , set new MinWidth
2280 SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2281 SdrMetricItem aMinWidth( makeSdrTextMinFrameWidthItem(rRect.GetSize().Width()) );
2282 aTempAttr.Put( aMinWidth );
2283 aTempAttr.Put( makeSdrTextAutoGrowWidthItem(false) );
2284 pTextObject->SetMergedItemSet(aTempAttr);
2285 pTextObject->SetLogicRect(rRect);
2287 // switch on AutoGrowWidth
2288 SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2289 aAttr.Put( makeSdrTextAutoGrowWidthItem(true) );
2290 pTextObject->SetMergedItemSet(aAttr);
2296 if(pObj && bInit )
2298 if( !IsPresObj( pObj ) )
2300 if( bUndo )
2301 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) );
2303 InsertPresObj( pObj, eObjKind );
2306 // make adjustments for vertical title and outline shapes
2307 if( bVertical && (( eObjKind == PRESOBJ_TITLE) || (eObjKind == PRESOBJ_OUTLINE)))
2309 SfxItemSet aNewSet(pObj->GetMergedItemSet());
2310 aNewSet.Put( makeSdrTextAutoGrowWidthItem(true) );
2311 aNewSet.Put( makeSdrTextAutoGrowHeightItem(false) );
2312 if( eObjKind == PRESOBJ_OUTLINE )
2314 aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
2315 aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
2317 pObj->SetMergedItemSet(aNewSet);
2321 if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || dynamic_cast< const SdrGrafObj *>( pObj ) == nullptr ) )
2322 pObj->AdjustToMaxRect(rRect);
2324 return pObj;
2327 /*************************************************************************
2329 |* Returns the PresObjKind of a object
2331 \************************************************************************/
2333 PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const
2335 PresObjKind eKind = PRESOBJ_NONE;
2336 if( (pObj != nullptr) && (maPresentationShapeList.hasShape(*pObj)) )
2338 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
2339 if( pInfo )
2340 eKind = pInfo->mePresObjKind;
2343 return eKind;
2346 bool SdPage::IsPresObj(const SdrObject* pObj)
2348 return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
2351 void SdPage::RemovePresObj(const SdrObject* pObj)
2353 if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
2355 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
2356 if( pInfo )
2357 pInfo->mePresObjKind = PRESOBJ_NONE;
2358 maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
2362 void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
2364 DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2365 DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2366 if( pObj )
2368 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
2369 if( pInfo )
2370 pInfo->mePresObjKind = eKind;
2371 maPresentationShapeList.addShape(*pObj);
2375 /*************************************************************************
2377 |* Set the text of a object
2379 \************************************************************************/
2381 void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const OUString& rString )
2383 if ( pObj )
2385 DBG_ASSERT( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr, "SetObjText: No SdrTextObj!" );
2386 ::Outliner* pOutl = pOutliner;
2388 if (!pOutliner)
2390 SfxItemPool* pPool(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDrawOutliner().GetEmptyItemSet().GetPool());
2391 pOutl = new ::Outliner( pPool, OutlinerMode::OutlineObject );
2392 pOutl->SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
2393 pOutl->SetEditTextObjectPool(pPool);
2394 pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool()));
2395 pOutl->EnableUndo(false);
2396 pOutl->SetUpdateMode( false );
2399 OutlinerMode nOutlMode = pOutl->GetMode();
2400 Size aPaperSize = pOutl->GetPaperSize();
2401 bool bUpdateMode = pOutl->GetUpdateMode();
2402 pOutl->SetUpdateMode(false);
2403 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2405 // Always set the object's StyleSheet at the Outliner to
2406 // use the current objects StyleSheet. Thus it's the same as in
2407 // SetText(...).
2408 // Moved this implementation from where SetObjText(...) was called
2409 // to inside this method to work even when outliner is fetched here.
2410 pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
2412 OUString aString;
2414 switch( eObjKind )
2416 case PRESOBJ_OUTLINE:
2418 pOutl->Init( OutlinerMode::OutlineObject );
2420 aString += "\t";
2421 aString += rString;
2423 if (mbMaster)
2425 pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
2426 aString += "\n\t\t";
2427 aString += SdResId(STR_PRESOBJ_MPOUTLLAYER2);
2429 aString += "\n\t\t\t";
2430 aString += SdResId(STR_PRESOBJ_MPOUTLLAYER3);
2432 aString += "\n\t\t\t\t";
2433 aString += SdResId(STR_PRESOBJ_MPOUTLLAYER4);
2435 aString += "\n\t\t\t\t\t";
2436 aString += SdResId(STR_PRESOBJ_MPOUTLLAYER5);
2438 aString += "\n\t\t\t\t\t\t";
2439 aString += SdResId(STR_PRESOBJ_MPOUTLLAYER6);
2441 aString += "\n\t\t\t\t\t\t\t";
2442 aString += SdResId(STR_PRESOBJ_MPOUTLLAYER7);
2446 break;
2448 case PRESOBJ_TITLE:
2450 pOutl->Init( OutlinerMode::TitleObject );
2451 aString += rString;
2453 break;
2455 default:
2457 pOutl->Init( OutlinerMode::TextObject );
2458 aString += rString;
2460 // check if we need to add a text field
2461 SvxFieldData* pData = nullptr;
2463 switch( eObjKind )
2465 case PRESOBJ_HEADER:
2466 pData = new SvxHeaderField();
2467 break;
2468 case PRESOBJ_FOOTER:
2469 pData = new SvxFooterField();
2470 break;
2471 case PRESOBJ_SLIDENUMBER:
2472 pData = new SvxPageField();
2473 break;
2474 case PRESOBJ_DATETIME:
2475 pData = new SvxDateTimeField();
2476 break;
2477 default:
2478 break;
2481 if( pData )
2483 ESelection e;
2484 SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
2485 pOutl->QuickInsertField(aField,e);
2486 delete pData;
2489 break;
2492 pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
2494 if( !aString.isEmpty() )
2495 pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
2497 pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
2499 if (!pOutliner)
2501 delete pOutl;
2502 pOutl = nullptr;
2504 else
2506 // Outliner restaurieren
2507 pOutl->Init( nOutlMode );
2508 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2509 pOutl->SetUpdateMode( bUpdateMode );
2510 pOutl->SetPaperSize( aPaperSize );
2515 /*************************************************************************
2517 |* Set the name of the layout
2519 \************************************************************************/
2520 void SdPage::SetLayoutName(const OUString& aName)
2522 maLayoutName = aName;
2524 if( mbMaster )
2526 sal_Int32 nPos = maLayoutName.indexOf(SD_LT_SEPARATOR);
2527 if (nPos != -1)
2528 FmFormPage::SetName(maLayoutName.copy(0, nPos));
2532 /*************************************************************************
2534 |* Return the page name and generates it if necessary
2536 \************************************************************************/
2538 const OUString& SdPage::GetName() const
2540 OUString aCreatedPageName( maCreatedPageName );
2541 if (GetRealName().isEmpty())
2543 if ((mePageKind == PageKind::Standard || mePageKind == PageKind::Notes) && !mbMaster)
2545 // default name for handout pages
2546 sal_uInt16 nNum = (GetPageNum() + 1) / 2;
2548 aCreatedPageName = SdResId(STR_PAGE);
2549 aCreatedPageName += " ";
2550 if( getSdrModelFromSdrPage().GetPageNumType() == css::style::NumberingType::NUMBER_NONE )
2552 // if the document has number none as a formatting
2553 // for page numbers we still default to arabic numbering
2554 // to keep the default page names unique
2555 aCreatedPageName += OUString::number( static_cast<sal_Int32>(nNum) );
2557 else
2559 aCreatedPageName += static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).CreatePageNumValue(nNum);
2562 else
2564 /******************************************************************
2565 * default name for note pages
2566 ******************************************************************/
2567 aCreatedPageName = SdResId(STR_LAYOUT_DEFAULT_NAME);
2570 else
2572 aCreatedPageName = GetRealName();
2575 if (mePageKind == PageKind::Notes)
2577 aCreatedPageName += " ";
2578 aCreatedPageName += SdResId(STR_NOTES);
2580 else if (mePageKind == PageKind::Handout && mbMaster)
2582 aCreatedPageName += " (";
2583 aCreatedPageName += SdResId(STR_HANDOUT);
2584 aCreatedPageName += ")";
2587 const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
2588 return maCreatedPageName;
2591 void SdPage::SetOrientation( Orientation /*eOrient*/)
2593 // Do nothing
2596 Orientation SdPage::GetOrientation() const
2598 Size aSize = GetSize();
2599 if ( aSize.getWidth() > aSize.getHeight() )
2601 return Orientation::Landscape;
2603 else
2605 return Orientation::Portrait;
2609 /*************************************************************************
2611 |* returns the default text of a PresObjektes
2613 \************************************************************************/
2615 OUString SdPage::GetPresObjText(PresObjKind eObjKind) const
2617 OUString aString;
2619 if (eObjKind == PRESOBJ_TITLE)
2621 if (mbMaster)
2623 if (mePageKind != PageKind::Notes)
2625 aString = SdResId( STR_PRESOBJ_MPTITLE );
2627 else
2629 aString = SdResId( STR_PRESOBJ_MPNOTESTITLE );
2632 else
2634 aString = SdResId( STR_PRESOBJ_TITLE );
2637 else if (eObjKind == PRESOBJ_OUTLINE)
2639 if (mbMaster)
2641 aString = SdResId( STR_PRESOBJ_MPOUTLINE );
2643 else
2645 aString = SdResId( STR_PRESOBJ_OUTLINE );
2648 else if (eObjKind == PRESOBJ_NOTES)
2650 if (mbMaster)
2652 aString = SdResId( STR_PRESOBJ_MPNOTESTEXT );
2654 else
2656 aString = SdResId( STR_PRESOBJ_NOTESTEXT );
2659 else if (eObjKind == PRESOBJ_TEXT)
2661 aString = SdResId( STR_PRESOBJ_TEXT );
2663 else if (eObjKind == PRESOBJ_GRAPHIC)
2665 aString = SdResId( STR_PRESOBJ_GRAPHIC );
2667 else if (eObjKind == PRESOBJ_OBJECT)
2669 aString = SdResId( STR_PRESOBJ_OBJECT );
2671 else if (eObjKind == PRESOBJ_CHART)
2673 aString = SdResId( STR_PRESOBJ_CHART );
2675 else if (eObjKind == PRESOBJ_ORGCHART)
2677 aString = SdResId( STR_PRESOBJ_ORGCHART );
2679 else if (eObjKind == PRESOBJ_CALC)
2681 aString = SdResId( STR_PRESOBJ_TABLE );
2684 return aString;
2687 uno::Reference< uno::XInterface > SdPage::createUnoPage()
2689 return createUnoPageImpl( this );
2692 /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
2693 SdPage* SdPage::getImplementation( const css::uno::Reference< css::drawing::XDrawPage >& xPage )
2697 css::uno::Reference< css::lang::XUnoTunnel > xUnoTunnel( xPage, css::uno::UNO_QUERY );
2698 if( xUnoTunnel.is() )
2700 SvxDrawPage* pUnoPage = reinterpret_cast<SvxDrawPage*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SvxDrawPage::getUnoTunnelId()) ) );
2701 if( pUnoPage )
2702 return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
2705 catch( css::uno::Exception& )
2707 OSL_FAIL("sd::SdPage::getImplementation(), exception caught!" );
2710 return nullptr;
2713 sal_Int64 SdPage::GetHashCode() const
2715 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
2718 void SdPage::SetName (const OUString& rName)
2720 OUString aOldName( GetName() );
2721 FmFormPage::SetName (rName);
2722 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).UpdatePageRelativeURLs(aOldName, rName);
2723 ActionChanged();
2726 const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
2728 if( mePageKind == PageKind::Handout && !mbMaster )
2730 return static_cast<SdPage&>(TRG_GetMasterPage()).maHeaderFooterSettings;
2732 else
2734 return maHeaderFooterSettings;
2738 void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings )
2740 if( mePageKind == PageKind::Handout && !mbMaster )
2742 static_cast<SdPage&>(TRG_GetMasterPage()).maHeaderFooterSettings = rNewSettings;
2744 else
2746 maHeaderFooterSettings = rNewSettings;
2749 SetChanged();
2751 if(TRG_HasMasterPage())
2753 TRG_GetMasterPageDescriptorViewContact().ActionChanged();
2755 // #i119056# For HeaderFooterSettings SdrObjects are used, but the properties
2756 // used are not part of their model data, but kept in SD. This data is applied
2757 // using a 'backdoor' on primitive creation. Thus, the normal mechanism to detect
2758 // object changes does not work here. It is necessary to trigger updates here
2759 // directly. BroadcastObjectChange used for PagePreview invalidations,
2760 // flushViewObjectContacts used to invalidate and flush all visualizations in
2761 // edit views.
2762 SdPage* pMasterPage = dynamic_cast< SdPage* >(&TRG_GetMasterPage());
2764 if(pMasterPage)
2766 SdrObject* pCandidate = nullptr;
2768 pCandidate = pMasterPage->GetPresObj( PRESOBJ_HEADER );
2770 if(pCandidate)
2772 pCandidate->BroadcastObjectChange();
2773 pCandidate->GetViewContact().flushViewObjectContacts();
2776 pCandidate = pMasterPage->GetPresObj( PRESOBJ_DATETIME );
2778 if(pCandidate)
2780 pCandidate->BroadcastObjectChange();
2781 pCandidate->GetViewContact().flushViewObjectContacts();
2784 pCandidate = pMasterPage->GetPresObj( PRESOBJ_FOOTER );
2786 if(pCandidate)
2788 pCandidate->BroadcastObjectChange();
2789 pCandidate->GetViewContact().flushViewObjectContacts();
2792 pCandidate = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER );
2794 if(pCandidate)
2796 pCandidate->BroadcastObjectChange();
2797 pCandidate->GetViewContact().flushViewObjectContacts();
2803 bool SdPage::checkVisibility(
2804 const sdr::contact::ViewObjectContact& rOriginal,
2805 const sdr::contact::DisplayInfo& rDisplayInfo,
2806 bool bEdit )
2808 if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
2809 return false;
2811 SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2812 if( pObj == nullptr )
2813 return false;
2815 const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
2816 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
2817 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
2818 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
2820 // empty presentation objects only visible during edit mode
2821 if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
2823 if( (pObj->GetObjInventor() != SdrInventor::Default) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
2824 return false;
2827 if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) )
2829 const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->GetPage());
2831 if( pCheckPage )
2833 PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
2835 if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
2837 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
2839 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PageKind::Handout && bIsPrinting ) )
2841 // use the page that is currently processed
2842 const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
2844 if( pVisualizedSdPage )
2846 // if we are not on a masterpage, see if we have to draw this header&footer object at all
2847 const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
2849 switch( eKind )
2851 case PRESOBJ_FOOTER:
2852 return rSettings.mbFooterVisible;
2853 case PRESOBJ_HEADER:
2854 return rSettings.mbHeaderVisible;
2855 case PRESOBJ_DATETIME:
2856 return rSettings.mbDateTimeVisible;
2857 case PRESOBJ_SLIDENUMBER:
2858 return rSettings.mbSlideNumberVisible;
2859 default:
2860 break;
2864 } // check for placeholders on master
2865 else if( (eKind != PRESOBJ_NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) )
2867 // presentation objects on master slide are always invisible if slide is shown.
2868 return false;
2873 // i63977, do not print SdrpageObjs from master pages
2874 if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) )
2876 if( pObj->GetPage() && pObj->GetPage()->IsMasterPage() )
2877 return false;
2880 return true;
2883 bool SdPage::RestoreDefaultText( SdrObject* pObj )
2885 bool bRet = false;
2887 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
2889 if( pTextObj )
2891 PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
2893 if (ePresObjKind == PRESOBJ_TITLE ||
2894 ePresObjKind == PRESOBJ_OUTLINE ||
2895 ePresObjKind == PRESOBJ_NOTES ||
2896 ePresObjKind == PRESOBJ_TEXT)
2898 OUString aString( GetPresObjText(ePresObjKind) );
2900 if (!aString.isEmpty())
2902 bool bVertical = false;
2903 OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
2904 if( pOldPara )
2905 bVertical = pOldPara->IsVertical(); // is old para object vertical?
2907 SetObjText( pTextObj, nullptr, ePresObjKind, aString );
2909 if( pOldPara )
2911 // Here, only the vertical flag for the
2912 // OutlinerParaObjects needs to be changed. The
2913 // AutoGrowWidth/Height items still exist in the
2914 // not changed object.
2915 if(pTextObj
2916 && pTextObj->GetOutlinerParaObject()
2917 && pTextObj->GetOutlinerParaObject()->IsVertical() != bVertical)
2919 ::tools::Rectangle aObjectRect = pTextObj->GetSnapRect();
2920 pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
2921 pTextObj->SetSnapRect(aObjectRect);
2925 pTextObj->SetTextEditOutliner( nullptr ); // to make stylesheet settings work
2926 pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), true );
2927 pTextObj->SetEmptyPresObj(true);
2928 bRet = true;
2932 return bRet;
2935 void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< ::tools::Rectangle >& rAreas )
2937 SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PageKind::Handout );
2939 static const sal_uInt16 aOffsets[5][9] =
2941 { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
2942 { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
2943 { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
2944 { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
2945 { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
2948 const sal_uInt16* pOffsets = aOffsets[0];
2950 Size aArea = rHandoutMaster.GetSize();
2951 const bool bLandscape = aArea.Width() > aArea.Height();
2953 if( eLayout == AUTOLAYOUT_NONE )
2955 // use layout from handout master
2956 SdrObjListIter aShapeIter (rHandoutMaster);
2958 std::vector< ::tools::Rectangle > vSlidesAreas;
2959 while ( aShapeIter.IsMore() )
2961 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>( aShapeIter.Next() );
2962 // get slide rectangles
2963 if (pPageObj)
2964 vSlidesAreas.push_back( pPageObj->GetCurrentBoundRect() );
2967 if ( !bHorizontal || vSlidesAreas.size() < 4 )
2968 { // top to bottom, then right
2969 rAreas.swap( vSlidesAreas );
2971 else
2972 { // left to right, then down
2973 switch ( vSlidesAreas.size() )
2975 case 4:
2976 pOffsets = aOffsets[2];
2977 break;
2979 default:
2980 SAL_FALLTHROUGH;
2981 case 6:
2982 pOffsets = aOffsets[ bLandscape ? 3 : 1 ];
2983 break;
2985 case 9:
2986 pOffsets = aOffsets[4];
2987 break;
2990 rAreas.resize( static_cast<size_t>(vSlidesAreas.size()) );
2992 for( const tools::Rectangle& rRect : vSlidesAreas )
2994 rAreas[*pOffsets++] = rRect;
2998 else
3000 const long nGapW = 1000; // gap is 1cm
3001 const long nGapH = 1000;
3003 long nLeftBorder = rHandoutMaster.GetLeftBorder();
3004 long nRightBorder = rHandoutMaster.GetRightBorder();
3005 long nTopBorder = rHandoutMaster.GetUpperBorder();
3006 long nBottomBorder = rHandoutMaster.GetLowerBorder();
3008 const long nHeaderFooterHeight = static_cast< long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05 );
3010 nTopBorder += nHeaderFooterHeight;
3011 nBottomBorder += nHeaderFooterHeight;
3013 long nX = nGapW + nLeftBorder;
3014 long nY = nGapH + nTopBorder;
3016 aArea.AdjustWidth( -(nGapW * 2 + nLeftBorder + nRightBorder) );
3017 aArea.AdjustHeight( -(nGapH * 2 + nTopBorder + nBottomBorder) );
3019 sal_uInt16 nColCnt = 0, nRowCnt = 0;
3020 switch ( eLayout )
3022 case AUTOLAYOUT_HANDOUT1:
3023 nColCnt = 1; nRowCnt = 1;
3024 break;
3026 case AUTOLAYOUT_HANDOUT2:
3027 if( bLandscape )
3029 nColCnt = 2; nRowCnt = 1;
3031 else
3033 nColCnt = 1; nRowCnt = 2;
3035 break;
3037 case AUTOLAYOUT_HANDOUT3:
3038 if( bLandscape )
3040 nColCnt = 3; nRowCnt = 2;
3042 else
3044 nColCnt = 2; nRowCnt = 3;
3046 pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
3047 break;
3049 case AUTOLAYOUT_HANDOUT4:
3050 nColCnt = 2; nRowCnt = 2;
3051 pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
3052 break;
3054 case AUTOLAYOUT_HANDOUT6:
3055 if( bLandscape )
3057 nColCnt = 3; nRowCnt = 2;
3059 else
3061 nColCnt = 2; nRowCnt = 3;
3063 if( !bHorizontal )
3064 pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
3065 break;
3067 default:
3068 case AUTOLAYOUT_HANDOUT9:
3069 nColCnt = 3; nRowCnt = 3;
3071 if( !bHorizontal )
3072 pOffsets = aOffsets[4];
3073 break;
3076 rAreas.resize(static_cast<size_t>(nColCnt) * nRowCnt);
3078 Size aPartArea, aSize;
3079 aPartArea.setWidth( (aArea.Width() - ((nColCnt-1) * nGapW) ) / nColCnt );
3080 aPartArea.setHeight( (aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt );
3082 SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PageKind::Standard);
3083 if (pFirstPage && pFirstPage->GetWidth() && pFirstPage->GetHeight())
3085 // scale actual size into handout rect
3086 double fScale = static_cast<double>(aPartArea.Width()) / static_cast<double>(pFirstPage->GetWidth());
3088 aSize.setHeight( static_cast<long>(fScale * pFirstPage->GetHeight() ) );
3089 if( aSize.Height() > aPartArea.Height() )
3091 fScale = static_cast<double>(aPartArea.Height()) / static_cast<double>(pFirstPage->GetHeight());
3092 aSize.setHeight( aPartArea.Height() );
3093 aSize.setWidth( static_cast<long>(fScale * pFirstPage->GetWidth()) );
3095 else
3097 aSize.setWidth( aPartArea.Width() );
3100 nX += (aPartArea.Width() - aSize.Width()) / 2;
3101 nY += (aPartArea.Height()- aSize.Height())/ 2;
3103 else
3105 aSize = aPartArea;
3108 Point aPos( nX, nY );
3110 const bool bRTL = rModel.GetDefaultWritingMode() == css::text::WritingMode_RL_TB;
3112 const long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
3113 const long nOffsetY = aPartArea.Height() + nGapH;
3114 const long nStartX = bRTL ? nOffsetX*(1 - nColCnt) + nX : nX;
3116 for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
3118 aPos.setX( nStartX );
3119 for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
3121 rAreas[*pOffsets++] = ::tools::Rectangle(aPos, aSize);
3122 aPos.AdjustX(nOffsetX );
3125 aPos.AdjustY(nOffsetY );
3130 void SdPage::SetPrecious (const bool bIsPrecious)
3132 mbIsPrecious = bIsPrecious;
3135 HeaderFooterSettings::HeaderFooterSettings()
3137 mbHeaderVisible = true;
3138 mbFooterVisible = true;
3139 mbSlideNumberVisible = false;
3140 mbDateTimeVisible = true;
3141 mbDateTimeIsFixed = true;
3142 meDateFormat = SvxDateFormat::A;
3143 meTimeFormat = SvxTimeFormat::AppDefault;
3146 bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
3148 return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
3149 (maHeaderText == rSettings.maHeaderText) &&
3150 (mbFooterVisible == rSettings.mbFooterVisible) &&
3151 (maFooterText == rSettings.maFooterText) &&
3152 (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
3153 (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
3154 (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
3155 (meDateFormat == rSettings.meDateFormat) &&
3156 (meTimeFormat == rSettings.meTimeFormat) &&
3157 (maDateTimeText == rSettings.maDateTimeText);
3160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */