nss: upgrade to release 3.73
[LibreOffice.git] / sd / source / core / sdpage.cxx
blobfb670e9585d4cc40a014aa22669e776e8e8549ca
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>
21 #include <array>
23 #include <comphelper/classids.hxx>
24 #include <comphelper/embeddedobjectcontainer.hxx>
25 #include <comphelper/lok.hxx>
27 #include <vcl/svapp.hxx>
28 #include <editeng/outliner.hxx>
29 #include <editeng/eeitem.hxx>
30 #include <svx/svdoutl.hxx>
31 #include <editeng/editdata.hxx>
32 #include <editeng/lrspitem.hxx>
33 #include <editeng/bulletitem.hxx>
34 #include <svx/svdpagv.hxx>
35 #include <editeng/fhgtitem.hxx>
36 #include <editeng/outlobj.hxx>
37 #include <svx/svdoole2.hxx>
38 #include <svx/svdograf.hxx>
39 #include <svx/svdopage.hxx>
40 #include <sfx2/lokhelper.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 <svx/unopage.hxx>
47 #include <editeng/flditem.hxx>
48 #include <svx/sdr/contact/displayinfo.hxx>
49 #include <svx/svditer.hxx>
50 #include <svx/svdlayer.hxx>
51 #include <svx/sdtmfitm.hxx>
52 #include <svx/sdtagitm.hxx>
53 #include <svx/sdtcfitm.hxx>
54 #include <svx/xfillit0.hxx>
55 #include <com/sun/star/animations/XAnimationNode.hpp>
56 #include <com/sun/star/animations/XTimeContainer.hpp>
57 #include <com/sun/star/container/XEnumerationAccess.hpp>
58 #include <com/sun/star/embed/XEmbeddedObject.hpp>
59 #include <com/sun/star/xml/dom/XNode.hpp>
60 #include <com/sun/star/xml/dom/XNodeList.hpp>
61 #include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
62 #include <rtl/ustring.hxx>
63 #include <sal/log.hxx>
64 #include <o3tl/enumarray.hxx>
65 #include <o3tl/safeint.hxx>
66 #include <xmloff/autolayout.hxx>
68 #include <Outliner.hxx>
69 #include <app.hrc>
70 #include <createunopageimpl.hxx>
71 #include <drawdoc.hxx>
72 #include <sdmod.hxx>
73 #include <sdpage.hxx>
74 #include <sdresid.hxx>
75 #include <stlsheet.hxx>
76 #include <strings.hrc>
77 #include <strings.hxx>
78 #include <bitmaps.hlst>
79 #include <glob.hxx>
80 #include <anminfo.hxx>
81 #include <undo/undomanager.hxx>
82 #include <undo/undoobjects.hxx>
83 #include <svx/sdr/contact/viewobjectcontact.hxx>
84 #include <svx/sdr/contact/viewcontact.hxx>
85 #include <svx/sdr/contact/objectcontact.hxx>
86 #include <svx/unoapi.hxx>
87 #include <unokywds.hxx>
89 #include <set>
91 using namespace ::sd;
92 using namespace ::com::sun::star;
93 using namespace ::com::sun::star::uno;
94 using namespace com::sun::star::xml::dom;
95 using ::com::sun::star::uno::Reference;
98 sal_uInt16 SdPage::mnLastPageId = 1;
100 /*************************************************************************
102 |* Ctor
104 \************************************************************************/
106 SdPage::SdPage(SdDrawDocument& rNewDoc, bool bMasterPage)
107 : FmFormPage(rNewDoc, bMasterPage)
108 , SdrObjUserCall()
109 , mePageKind(PageKind::Standard)
110 , meAutoLayout(AUTOLAYOUT_NONE)
111 , mbSelected(false)
112 , mePresChange(PresChange::Manual)
113 , mfTime(1.0)
114 , mbSoundOn(false)
115 , mbExcluded(false)
116 , mbLoopSound(false)
117 , mbStopSound(false)
118 , mbScaleObjects(true)
119 , mbBackgroundFullSize( false )
120 , meCharSet(osl_getThreadTextEncoding())
121 , mnPaperBin(PAPERBIN_PRINTER_SETTINGS)
122 , mpPageLink(nullptr)
123 , mnTransitionType(0)
124 , mnTransitionSubtype(0)
125 , mbTransitionDirection(true)
126 , mnTransitionFadeColor(0)
127 , mfTransitionDuration(2.0)
128 , mbIsPrecious(true)
129 , mnPageId(mnLastPageId++)
131 // The name of the layout of the page is used by SVDRAW to determine the
132 // presentation template of the outline objects. Therefore, it already
133 // contains the designator for the outline (STR_LAYOUT_OUTLINE).
134 maLayoutName = SdResId(STR_LAYOUT_DEFAULT_NAME)+ SD_LT_SEPARATOR STR_LAYOUT_OUTLINE;
136 // Stuff that former SetModel did also:
137 ConnectLink();
140 namespace
142 void clearChildNodes(css::uno::Reference<css::animations::XAnimationNode> const & rAnimationNode)
144 css::uno::Reference<css::container::XEnumerationAccess > xEnumerationAccess(rAnimationNode, UNO_QUERY);
145 if (!xEnumerationAccess.is())
146 return;
147 css::uno::Reference<css::container::XEnumeration> xEnumeration = xEnumerationAccess->createEnumeration();
148 if (!xEnumeration.is())
149 return;
150 while (xEnumeration->hasMoreElements())
152 css::uno::Reference<css::animations::XAnimationNode> xChildNode(xEnumeration->nextElement(), UNO_QUERY);
153 if (!xChildNode.is())
154 continue;
155 clearChildNodes(xChildNode);
156 css::uno::Reference<css::animations::XTimeContainer> xAnimationNode(rAnimationNode, UNO_QUERY);
157 if (!xAnimationNode.is())
159 SAL_WARN("sd.core", "can't remove node child, possible leak");
160 continue;
162 xAnimationNode->removeChild(xChildNode);
167 /*************************************************************************
169 |* Dtor
171 \************************************************************************/
173 SdPage::~SdPage()
175 DisconnectLink();
177 EndListenOutlineText();
179 clearChildNodes(mxAnimationNode);
181 // clear SdrObjects with broadcasting
182 ClearSdrObjList();
185 namespace {
187 struct OrdNumSorter
189 bool operator()( SdrObject const * p1, SdrObject const * p2 )
191 return p1->GetOrdNum() < p2->GetOrdNum();
197 /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
198 SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ )
200 // first sort all matching shapes with z-order
201 std::vector< SdrObject* > aMatches;
203 SdrObject* pObj = nullptr;
204 maPresentationShapeList.seekShape(0);
206 while( (pObj = maPresentationShapeList.getNextShape()) )
208 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
209 if( pInfo )
211 bool bFound = false;
212 if( pInfo->mePresObjKind == eObjKind )
214 bFound = true;
216 else if( bFuzzySearch && (eObjKind == PresObjKind::Outline) )
218 switch( pInfo->mePresObjKind )
220 case PresObjKind::Graphic:
221 case PresObjKind::Object:
222 case PresObjKind::Chart:
223 case PresObjKind::OrgChart:
224 case PresObjKind::Table:
225 case PresObjKind::Calc:
226 case PresObjKind::Media:
227 bFound = true;
228 break;
229 default:
230 break;
233 if( bFound )
235 aMatches.push_back( pObj );
240 if( nIndex > 0 )
241 nIndex--;
243 if( (nIndex >= 0) && ( aMatches.size() > o3tl::make_unsigned(nIndex)) )
245 if( aMatches.size() > 1 )
246 std::nth_element( aMatches.begin(), aMatches.begin() + nIndex, aMatches.end(),
247 OrdNumSorter() );
248 return aMatches[nIndex];
251 return nullptr;
254 /** create background properties */
255 void SdPage::EnsureMasterPageDefaultBackground()
257 if(!mbMaster)
258 return;
260 // no hard attributes on MasterPage attributes
261 getSdrPageProperties().ClearItem();
262 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForMasterPageBackground();
264 if(pSheetForPresObj)
266 // set StyleSheet for background fill attributes
267 getSdrPageProperties().SetStyleSheet(pSheetForPresObj);
269 else
271 // no style found, assert and set at least drawing::FillStyle_NONE
272 OSL_FAIL("No Style for MasterPageBackground fill found (!)");
273 getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE));
277 /** creates a presentation object with the given PresObjKind on this page. A user call will be set
279 SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect )
281 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
282 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
284 SdrObject* pSdrObj = nullptr;
286 bool bForceText = false; // forces the shape text to be set even if it's empty
287 bool bEmptyPresObj = true;
289 switch( eObjKind )
291 case PresObjKind::Title:
293 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TITLETEXT);
295 if (mbMaster)
297 pSdrObj->SetNotVisibleAsMaster(true);
300 break;
302 case PresObjKind::Outline:
304 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_OUTLINETEXT);
306 if (mbMaster)
308 pSdrObj->SetNotVisibleAsMaster(true);
311 break;
313 case PresObjKind::Notes:
315 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
317 if (mbMaster)
319 pSdrObj->SetNotVisibleAsMaster(true);
322 break;
324 case PresObjKind::Text:
326 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
328 break;
330 case PresObjKind::Graphic:
332 BitmapEx aBmpEx(BMP_PRESOBJ_GRAPHIC);
333 Graphic aGraphic( aBmpEx );
334 OutputDevice &aOutDev = *Application::GetDefaultDevice();
335 aOutDev.Push();
337 aOutDev.SetMapMode( aGraphic.GetPrefMapMode() );
338 Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() );
339 aOutDev.SetMapMode(MapMode(MapUnit::Map100thMM));
341 Size aSize = aOutDev.PixelToLogic(aSizePix);
342 Point aPnt (0, 0);
343 ::tools::Rectangle aRect (aPnt, aSize);
344 pSdrObj = new SdrGrafObj(getSdrModelFromSdrPage(), aGraphic, aRect);
345 aOutDev.Pop();
347 break;
349 case PresObjKind::Media:
350 case PresObjKind::Object:
352 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
353 BitmapEx aBmpEx(BMP_PRESOBJ_OBJECT);
354 Graphic aGraphic( aBmpEx );
355 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
357 break;
359 case PresObjKind::Chart:
361 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
362 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarChart" );
363 BitmapEx aBmpEx(BMP_PRESOBJ_CHART);
364 Graphic aGraphic( aBmpEx );
365 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
367 break;
369 case PresObjKind::OrgChart:
371 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
372 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarOrg" );
373 BitmapEx aBmpEx(BMP_PRESOBJ_ORGCHART);
374 Graphic aGraphic( aBmpEx );
375 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
377 break;
379 case PresObjKind::Table:
380 case PresObjKind::Calc:
382 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
383 static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarCalc" );
384 BitmapEx aBmpEx(BMP_PRESOBJ_TABLE);
385 Graphic aGraphic( aBmpEx );
386 static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
388 break;
390 case PresObjKind::Handout:
392 // Save the first standard page at SdrPageObj
393 // #i105146# We want no content to be displayed for PageKind::Handout,
394 // so just never set a page as content
395 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), nullptr);
397 break;
399 case PresObjKind::Page:
401 // Save note pages at SdrPageObj
402 sal_uInt16 nDestPageNum(GetPageNum());
404 if(nDestPageNum)
406 // decrement only when != 0, else we get a 0xffff
407 nDestPageNum -= 1;
410 if (nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
412 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), getSdrModelFromSdrPage().GetPage(nDestPageNum));
414 else
416 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage());
419 pSdrObj->SetResizeProtect(true);
421 break;
423 case PresObjKind::Header:
424 case PresObjKind::Footer:
425 case PresObjKind::DateTime:
426 case PresObjKind::SlideNumber:
428 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
429 bEmptyPresObj = false;
430 bForceText = true;
432 break;
433 default:
434 break;
437 if (pSdrObj)
439 pSdrObj->SetEmptyPresObj(bEmptyPresObj);
440 pSdrObj->SetLogicRect(rRect);
442 InsertObject(pSdrObj);
444 if ( dynamic_cast< const SdrTextObj *>( pSdrObj ) != nullptr )
446 // Tell the object EARLY that it is vertical to have the
447 // defaults for AutoGrowWidth/Height reversed
448 if(bVertical)
449 static_cast<SdrTextObj*>(pSdrObj)->SetVerticalWriting(true);
451 SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
452 if( bVertical )
453 aTempAttr.Put( makeSdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
454 else
455 aTempAttr.Put( makeSdrTextMinFrameHeightItem( rRect.GetSize().Height() ) );
457 if (mbMaster)
459 // The size of presentation objects on the master page have to
460 // be freely selectable by the user.
462 // potential problem: This action was still NOT
463 // adapted for vertical text. This sure needs to be done.
464 if(bVertical)
465 aTempAttr.Put(makeSdrTextAutoGrowWidthItem(false));
466 else
467 aTempAttr.Put(makeSdrTextAutoGrowHeightItem(false));
470 // check if we need another vertical adjustment than the default
471 SdrTextVertAdjust eV = SDRTEXTVERTADJUST_TOP;
473 if( (eObjKind == PresObjKind::Footer) && (mePageKind != PageKind::Standard) )
475 eV = SDRTEXTVERTADJUST_BOTTOM;
477 else if( (eObjKind == PresObjKind::SlideNumber) && (mePageKind != PageKind::Standard) )
479 eV = SDRTEXTVERTADJUST_BOTTOM;
482 if( eV != SDRTEXTVERTADJUST_TOP )
483 aTempAttr.Put(SdrTextVertAdjustItem(eV));
485 pSdrObj->SetMergedItemSet(aTempAttr);
487 pSdrObj->SetLogicRect(rRect);
490 OUString aString = GetPresObjText(eObjKind);
491 if( (!aString.isEmpty() || bForceText) && dynamic_cast< const SdrTextObj *>( pSdrObj ) != nullptr )
493 SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
495 OutlinerMode nOutlMode = pOutliner->GetMode();
496 pOutliner->Init( OutlinerMode::TextObject );
497 pOutliner->SetStyleSheet( 0, nullptr );
498 pOutliner->SetVertical( bVertical );
500 SetObjText( static_cast<SdrTextObj*>(pSdrObj), pOutliner, eObjKind, aString );
502 pOutliner->Init( nOutlMode );
503 pOutliner->SetStyleSheet( 0, nullptr );
506 if( (eObjKind == PresObjKind::Header) || (eObjKind == PresObjKind::Footer) || (eObjKind == PresObjKind::SlideNumber) || (eObjKind == PresObjKind::DateTime) )
508 SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
509 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
510 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
511 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
513 SvxAdjust eH = SvxAdjust::Left;
515 if( (eObjKind == PresObjKind::DateTime) && (mePageKind != PageKind::Standard ) )
517 eH = SvxAdjust::Right;
519 else if( (eObjKind == PresObjKind::Footer) && (mePageKind == PageKind::Standard ) )
521 eH = SvxAdjust::Center;
523 else if( eObjKind == PresObjKind::SlideNumber )
525 eH = SvxAdjust::Right;
528 if( eH != SvxAdjust::Left )
529 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST ));
531 pSdrObj->SetMergedItemSet(aTempAttr);
534 if (mbMaster)
536 SdrLayerAdmin& rLayerAdmin(getSdrModelFromSdrPage().GetLayerAdmin());
538 // background objects of the master page
539 pSdrObj->SetLayer( rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects) );
542 // Subscribe object at the style sheet
543 // Set style only when one was found (as in 5.2)
544 if( mePageKind != PageKind::Handout )
546 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind);
547 if(pSheetForPresObj)
548 pSdrObj->SetStyleSheet(pSheetForPresObj, false);
551 if (eObjKind == PresObjKind::Outline)
553 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
555 OUString aName( maLayoutName + " " + OUString::number( nLevel ) );
556 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page));
557 DBG_ASSERT(pSheet, "StyleSheet for outline object not found");
558 if (pSheet)
559 pSdrObj->StartListening(*pSheet, DuplicateHandling::Allow);
563 if ( eObjKind == PresObjKind::Object ||
564 eObjKind == PresObjKind::Chart ||
565 eObjKind == PresObjKind::OrgChart ||
566 eObjKind == PresObjKind::Calc ||
567 eObjKind == PresObjKind::Graphic )
569 SfxItemSet aSet( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
570 aSet.Put( makeSdrTextContourFrameItem( true ) );
571 aSet.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
573 pSdrObj->SetMergedItemSet(aSet);
576 if( bUndo )
578 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
580 pUndoManager->AddUndoAction( std::make_unique<UndoObjectPresentationKind>( *pSdrObj ) );
581 pUndoManager->AddUndoAction( std::make_unique<UndoObjectUserCall>(*pSdrObj) );
584 InsertPresObj(pSdrObj, eObjKind);
585 pSdrObj->SetUserCall(this);
587 pSdrObj->RecalcBoundRect();
590 return pSdrObj;
593 /*************************************************************************
595 |* Creates presentation objects on the master page.
596 |* All presentation objects get a UserCall to the page.
598 \************************************************************************/
600 SfxStyleSheet* SdPage::GetStyleSheetForMasterPageBackground() const
602 OUString aName(GetLayoutName());
603 OUString aSep( SD_LT_SEPARATOR );
604 sal_Int32 nPos = aName.indexOf(aSep);
606 if (nPos != -1)
608 nPos = nPos + aSep.getLength();
609 aName = aName.copy(0, nPos);
612 aName += STR_LAYOUT_BACKGROUND;
614 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
615 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SfxStyleFamily::Page);
616 return static_cast<SfxStyleSheet*>(pResult);
619 SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const
621 OUString aName(GetLayoutName());
622 OUString aSep( SD_LT_SEPARATOR );
623 sal_Int32 nPos = aName.indexOf(aSep);
624 if (nPos != -1)
626 nPos = nPos + aSep.getLength();
627 aName = aName.copy(0, nPos);
630 switch (eObjKind)
632 case PresObjKind::Outline:
634 aName = GetLayoutName() + " " + OUString::number( 1 );
636 break;
638 case PresObjKind::Title:
639 aName += STR_LAYOUT_TITLE;
640 break;
642 case PresObjKind::Notes:
643 aName += STR_LAYOUT_NOTES;
644 break;
646 case PresObjKind::Text:
647 aName += STR_LAYOUT_SUBTITLE;
648 break;
650 case PresObjKind::Header:
651 case PresObjKind::Footer:
652 case PresObjKind::DateTime:
653 case PresObjKind::SlideNumber:
654 aName += STR_LAYOUT_BACKGROUNDOBJECTS;
655 break;
657 default:
658 break;
661 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
662 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SfxStyleFamily::Page);
663 return static_cast<SfxStyleSheet*>(pResult);
666 /** returns the presentation style with the given helpid from this masterpage or this
667 slides masterpage */
668 SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
670 OUString aStyleName( GetLayoutName() );
671 const OUString aSep( SD_LT_SEPARATOR );
672 sal_Int32 nIndex = aStyleName.indexOf(aSep);
673 if( nIndex != -1 )
674 aStyleName = aStyleName.copy(0, nIndex + aSep.getLength());
676 const char *pNameId;
677 bool bOutline = false;
678 switch( nHelpId )
680 case HID_PSEUDOSHEET_TITLE: pNameId = STR_LAYOUT_TITLE; break;
681 case HID_PSEUDOSHEET_SUBTITLE: pNameId = STR_LAYOUT_SUBTITLE; break;
682 case HID_PSEUDOSHEET_OUTLINE1:
683 case HID_PSEUDOSHEET_OUTLINE2:
684 case HID_PSEUDOSHEET_OUTLINE3:
685 case HID_PSEUDOSHEET_OUTLINE4:
686 case HID_PSEUDOSHEET_OUTLINE5:
687 case HID_PSEUDOSHEET_OUTLINE6:
688 case HID_PSEUDOSHEET_OUTLINE7:
689 case HID_PSEUDOSHEET_OUTLINE8:
690 case HID_PSEUDOSHEET_OUTLINE9: pNameId = STR_LAYOUT_OUTLINE; bOutline = true; break;
691 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: pNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break;
692 case HID_PSEUDOSHEET_BACKGROUND: pNameId = STR_LAYOUT_BACKGROUND; break;
693 case HID_PSEUDOSHEET_NOTES: pNameId = STR_LAYOUT_NOTES; break;
695 default:
696 OSL_FAIL( "SdPage::getPresentationStyle(), illegal argument!" );
697 return nullptr;
699 aStyleName += OUString::createFromAscii(pNameId);
700 if (bOutline)
702 aStyleName += " " +
703 OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ));
706 SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
707 SfxStyleSheetBase* pResult = pStShPool->Find(aStyleName, SfxStyleFamily::Page);
708 return dynamic_cast<SdStyleSheet*>(pResult);
711 /*************************************************************************
713 |* The presentation object rObj has changed and is no longer referenced by the
714 |* presentation object of the master page.
715 |* The UserCall is deleted.
717 \************************************************************************/
719 void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools::Rectangle& )
721 if (maLockAutoLayoutArrangement.isLocked())
722 return;
724 switch (eType)
726 case SdrUserCallType::MoveOnly:
727 case SdrUserCallType::Resize:
729 if ( getSdrModelFromSdrPage().isLocked())
730 break;
732 if (!mbMaster)
734 if (rObj.GetUserCall())
736 SdrObject& _rObj = const_cast<SdrObject&>(rObj);
737 SfxUndoManager* pUndoManager
738 = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
739 .GetUndoManager();
740 const bool bUndo
741 = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
743 if (bUndo)
744 pUndoManager->AddUndoAction(
745 std::make_unique<UndoObjectUserCall>(_rObj));
747 // Object was resized by user and does not listen to its slide anymore
748 _rObj.SetUserCall(nullptr);
751 else
753 // Object of the master page changed, therefore adjust
754 // object on all pages
755 sal_uInt16 nPageCount = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
756 .GetSdPageCount(mePageKind);
758 for (sal_uInt16 i = 0; i < nPageCount; i++)
760 SdPage* pLoopPage = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
761 .GetSdPage(i, mePageKind);
763 if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
765 // Page listens to this master page, therefore
766 // adjust AutoLayout
767 pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
772 break;
774 case SdrUserCallType::Delete:
775 case SdrUserCallType::Removed:
776 default:
777 break;
781 /*************************************************************************
783 |* Creates on a master page: background, title- and layout area
785 \************************************************************************/
787 void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
789 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
790 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
792 SdPage* pMasterPage = this;
794 if (!mbMaster)
796 pMasterPage = static_cast<SdPage*>(&(TRG_GetMasterPage()));
799 if (!pMasterPage)
801 return;
804 /**************************************************************************
805 * create background, title- and layout area
806 **************************************************************************/
807 if( mePageKind == PageKind::Standard )
809 pMasterPage->EnsureMasterPageDefaultBackground();
812 if (static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocumentType() != DocumentType::Impress)
813 return;
815 if( mePageKind == PageKind::Handout && bInit )
817 // handout template
819 // delete all available handout presentation objects
820 SdrObject *pObj=nullptr;
821 while( (pObj = pMasterPage->GetPresObj(PresObjKind::Handout)) != nullptr )
823 pMasterPage->RemoveObject(pObj->GetOrdNum());
825 if( bUndo )
827 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
829 else
831 SdrObject::Free( pObj );
835 std::vector< ::tools::Rectangle > aAreas;
836 CalculateHandoutAreas( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()), pMasterPage->GetAutoLayout(), false, aAreas );
838 const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
839 std::vector< ::tools::Rectangle >::iterator iter( aAreas.begin() );
841 while( iter != aAreas.end() )
843 SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PresObjKind::Handout, false, (*iter++)) );
844 // #i105146# We want no content to be displayed for PageKind::Handout,
845 // so just never set a page as content
846 pPageObj->SetReferencedPage(nullptr);
848 if( bSkip && iter != aAreas.end() )
849 ++iter;
853 if( mePageKind != PageKind::Handout )
855 SdrObject* pMasterTitle = pMasterPage->GetPresObj( PresObjKind::Title );
856 if( pMasterTitle == nullptr )
857 pMasterPage->CreateDefaultPresObj(PresObjKind::Title);
859 SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PageKind::Notes ? PresObjKind::Notes : PresObjKind::Outline );
860 if( pMasterOutline == nullptr )
861 pMasterPage->CreateDefaultPresObj( mePageKind == PageKind::Standard ? PresObjKind::Outline : PresObjKind::Notes );
864 // create header&footer objects
866 if( !bCreate )
867 return;
869 if( mePageKind != PageKind::Standard )
871 SdrObject* pHeader = pMasterPage->GetPresObj( PresObjKind::Header );
872 if( pHeader == nullptr )
873 pMasterPage->CreateDefaultPresObj( PresObjKind::Header );
876 SdrObject* pDate = pMasterPage->GetPresObj( PresObjKind::DateTime );
877 if( pDate == nullptr )
878 pMasterPage->CreateDefaultPresObj( PresObjKind::DateTime );
880 SdrObject* pFooter = pMasterPage->GetPresObj( PresObjKind::Footer );
881 if( pFooter == nullptr )
882 pMasterPage->CreateDefaultPresObj( PresObjKind::Footer );
884 SdrObject* pNumber = pMasterPage->GetPresObj( PresObjKind::SlideNumber );
885 if( pNumber == nullptr )
886 pMasterPage->CreateDefaultPresObj( PresObjKind::SlideNumber );
889 namespace {
891 const o3tl::enumarray<PageKind, char const *> PageKindVector = {
892 "PageKind::Standard", "PageKind::Notes", "PageKind::Handout"
895 const o3tl::enumarray<PresObjKind, const char*> PresObjKindVector = {
896 "PRESOBJ_NONE", "PRESOBJ_TITLE", "PRESOBJ_OUTLINE",
897 "PRESOBJ_TEXT" ,"PRESOBJ_GRAPHIC" , "PRESOBJ_OBJECT",
898 "PRESOBJ_CHART", "PRESOBJ_ORGCHART", "PRESOBJ_TABLE",
899 "PRESOBJ_PAGE", "PRESOBJ_HANDOUT",
900 "PRESOBJ_NOTES","PRESOBJ_HEADER", "PRESOBJ_FOOTER",
901 "PRESOBJ_DATETIME", "PRESOBJ_SLIDENUMBER", "PRESOBJ_CALC",
902 "PRESOBJ_MEDIA"
905 void getPresObjProp( const SdPage& rPage, const char* sObjKind, const char* sPageKind, double presObjPropValue[] )
907 bool bNoObjectFound = true; //used to break from outer loop
909 const std::vector< Reference<XNode> >& objectInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetObjectVector();
910 for( const Reference<XNode>& objectNode : objectInfo )
912 if(bNoObjectFound)
914 Reference<XNamedNodeMap> objectattrlist = objectNode->getAttributes();
915 Reference<XNode> objectattr = objectattrlist->getNamedItem("type");
916 OUString sObjType = objectattr->getNodeValue();
918 if (sObjType.equalsAscii(sObjKind))
920 Reference<XNodeList> objectChildren = objectNode->getChildNodes();
921 const int objSize = objectChildren->getLength();
923 for( int j=0; j< objSize; j++)
925 Reference<XNode> obj = objectChildren->item(j);
926 OUString nodename = obj->getNodeName();
928 //check whether child is blank 'text-node' or 'object-prop' node
929 if(nodename == "object-prop")
931 Reference<XNamedNodeMap> ObjAttributes = obj->getAttributes();
932 Reference<XNode> ObjPageKind = ObjAttributes->getNamedItem("pagekind");
933 OUString sObjPageKind = ObjPageKind->getNodeValue();
935 if (sObjPageKind.equalsAscii(sPageKind))
937 Reference<XNode> ObjSizeHeight = ObjAttributes->getNamedItem("relative-height");
938 OUString sValue = ObjSizeHeight->getNodeValue();
939 presObjPropValue[0] = sValue.toDouble();
941 Reference<XNode> ObjSizeWidth = ObjAttributes->getNamedItem("relative-width");
942 sValue = ObjSizeWidth->getNodeValue();
943 presObjPropValue[1] = sValue.toDouble();
945 Reference<XNode> ObjPosX = ObjAttributes->getNamedItem("relative-posX");
946 sValue = ObjPosX->getNodeValue();
947 presObjPropValue[2] = sValue.toDouble();
949 Reference<XNode> ObjPosY = ObjAttributes->getNamedItem("relative-posY");
950 sValue = ObjPosY->getNodeValue();
951 presObjPropValue[3] = sValue.toDouble();
953 bNoObjectFound = false;
954 break;
960 else
961 break;
967 SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind)
969 if( eObjKind == PresObjKind::Title )
971 ::tools::Rectangle aTitleRect( GetTitleRect() );
972 return CreatePresObj(PresObjKind::Title, false, aTitleRect);
974 else if( eObjKind == PresObjKind::Outline )
976 ::tools::Rectangle aLayoutRect( GetLayoutRect() );
977 return CreatePresObj( PresObjKind::Outline, false, aLayoutRect);
979 else if( eObjKind == PresObjKind::Notes )
981 ::tools::Rectangle aLayoutRect( GetLayoutRect() );
982 return CreatePresObj( PresObjKind::Notes, false, aLayoutRect);
984 else if( (eObjKind == PresObjKind::Footer) || (eObjKind == PresObjKind::DateTime) || (eObjKind == PresObjKind::SlideNumber) || (eObjKind == PresObjKind::Header ) )
986 double propvalue[] = {0,0,0,0};
987 const char* sObjKind = PresObjKindVector[eObjKind];
988 const char* sPageKind = PageKindVector[mePageKind];
989 // create footer objects for standard master page
990 if( mePageKind == PageKind::Standard )
992 const ::tools::Long nLftBorder = GetLeftBorder();
993 const ::tools::Long nUppBorder = GetUpperBorder();
995 Point aPos ( nLftBorder, nUppBorder );
996 Size aSize ( GetSize() );
998 aSize.AdjustWidth( -(nLftBorder + GetRightBorder()) );
999 aSize.AdjustHeight( -(nUppBorder + GetLowerBorder()) );
1001 getPresObjProp( *this, sObjKind, sPageKind, propvalue);
1002 aPos.AdjustX(::tools::Long( aSize.Width() * propvalue[2] ) );
1003 aPos.AdjustY(::tools::Long( aSize.Height() * propvalue[3] ) );
1004 aSize.setWidth( ::tools::Long( aSize.Width() * propvalue[1] ) );
1005 aSize.setHeight( ::tools::Long( aSize.Height() * propvalue[0] ) );
1007 if(eObjKind == PresObjKind::Header )
1009 OSL_FAIL( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a master slide" );
1010 return nullptr;
1012 else
1014 ::tools::Rectangle aRect( aPos, aSize );
1015 return CreatePresObj( eObjKind, false, aRect );
1018 else
1020 // create header&footer objects for handout and notes master
1021 Size aPageSize ( GetSize() );
1022 aPageSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1023 aPageSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1025 Point aPosition ( GetLeftBorder(), GetUpperBorder() );
1027 getPresObjProp( *this, sObjKind, sPageKind, propvalue);
1028 int NOTES_HEADER_FOOTER_WIDTH = ::tools::Long(aPageSize.Width() * propvalue[1]);
1029 int NOTES_HEADER_FOOTER_HEIGHT = ::tools::Long(aPageSize.Height() * propvalue[0]);
1030 Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
1031 Point aPos ( 0 ,0 );
1032 if( propvalue[2] == 0 )
1033 aPos.setX( aPosition.X() );
1034 else
1035 aPos.setX( aPosition.X() + ::tools::Long( aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH ) );
1036 if( propvalue[3] == 0 )
1037 aPos.setY( aPosition.Y() );
1038 else
1039 aPos.setY( aPosition.Y() + ::tools::Long( aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT ) );
1041 ::tools::Rectangle aRect( aPos, aSize );
1042 return CreatePresObj( eObjKind, false, aRect );
1045 else
1047 OSL_FAIL("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
1048 return nullptr;
1052 void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
1054 SdrObject* pObject = GetPresObj( eObjKind );
1056 if( pObject )
1058 SdDrawDocument* pDoc(static_cast< SdDrawDocument* >(&getSdrModelFromSdrPage()));
1059 const bool bUndo = pDoc->IsUndoEnabled();
1060 if( bUndo )
1061 pDoc->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
1062 SdrObjList* pOL = pObject->getParentSdrObjListFromSdrObject();
1063 pOL->RemoveObject(pObject->GetOrdNumDirect());
1065 if( !bUndo )
1066 SdrObject::Free(pObject);
1070 /*************************************************************************
1072 |* return title area
1074 \************************************************************************/
1076 ::tools::Rectangle SdPage::GetTitleRect() const
1078 ::tools::Rectangle aTitleRect;
1080 if (mePageKind != PageKind::Handout)
1082 double propvalue[] = {0,0,0,0};
1084 /******************************************************************
1085 * standard- or note page: title area
1086 ******************************************************************/
1087 Point aTitlePos ( GetLeftBorder(), GetUpperBorder() );
1088 Size aTitleSize ( GetSize() );
1089 aTitleSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1090 aTitleSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1091 const char* sPageKind = PageKindVector[mePageKind];
1093 if (mePageKind == PageKind::Standard)
1095 getPresObjProp( *this , "PRESOBJ_TITLE" ,sPageKind, propvalue);
1096 aTitlePos.AdjustX(::tools::Long( aTitleSize.Width() * propvalue[2] ) );
1097 aTitlePos.AdjustY(::tools::Long( aTitleSize.Height() * propvalue[3] ) );
1098 aTitleSize.setWidth( ::tools::Long( aTitleSize.Width() * propvalue[1] ) );
1099 aTitleSize.setHeight( ::tools::Long( aTitleSize.Height() * propvalue[0] ) );
1101 else if (mePageKind == PageKind::Notes)
1103 Point aPos = aTitlePos;
1104 getPresObjProp( *this, "PRESOBJ_TITLE" ,sPageKind, propvalue);
1105 aPos.AdjustX(::tools::Long( aTitleSize.Width() * propvalue[2] ) );
1106 aPos.AdjustY(::tools::Long( aTitleSize.Height() * propvalue[3] ) );
1108 // limit height
1109 aTitleSize.setHeight( ::tools::Long( aTitleSize.Height() * propvalue[0] ) );
1110 aTitleSize.setWidth( ::tools::Long( aTitleSize.Width() * propvalue[1] ) );
1112 Size aPartArea = aTitleSize;
1113 Size aSize;
1114 sal_uInt16 nDestPageNum(GetPageNum());
1115 SdrPage* pRefPage = nullptr;
1117 if(nDestPageNum)
1119 // only decrement if != 0, else we get 0xffff
1120 nDestPageNum -= 1;
1123 if(nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
1125 pRefPage = getSdrModelFromSdrPage().GetPage(nDestPageNum);
1128 if ( pRefPage )
1130 // scale actually page size into handout rectangle
1131 double fH = pRefPage->GetWidth() == 0
1132 ? 0 : static_cast<double>(aPartArea.Width()) / pRefPage->GetWidth();
1133 double fV = pRefPage->GetHeight() == 0
1134 ? 0 : static_cast<double>(aPartArea.Height()) / pRefPage->GetHeight();
1136 if ( fH > fV )
1137 fH = fV;
1138 aSize.setWidth( static_cast<::tools::Long>(fH * pRefPage->GetWidth()) );
1139 aSize.setHeight( static_cast<::tools::Long>(fH * pRefPage->GetHeight()) );
1141 aPos.AdjustX((aPartArea.Width() - aSize.Width()) / 2 );
1142 aPos.AdjustY((aPartArea.Height()- aSize.Height())/ 2 );
1145 aTitlePos = aPos;
1146 aTitleSize = aSize;
1149 aTitleRect.SetPos(aTitlePos);
1150 aTitleRect.SetSize(aTitleSize);
1153 return aTitleRect;
1156 /*************************************************************************
1158 |* return outline area
1160 \************************************************************************/
1162 ::tools::Rectangle SdPage::GetLayoutRect() const
1164 ::tools::Rectangle aLayoutRect;
1166 if (mePageKind != PageKind::Handout)
1168 double propvalue[] = {0,0,0,0};
1170 Point aLayoutPos ( GetLeftBorder(), GetUpperBorder() );
1171 Size aLayoutSize ( GetSize() );
1172 aLayoutSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1173 aLayoutSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1174 const char* sPageKind = PageKindVector[mePageKind];
1176 if (mePageKind == PageKind::Standard)
1178 getPresObjProp( *this ,"PRESOBJ_OUTLINE", sPageKind, propvalue);
1179 aLayoutPos.AdjustX(::tools::Long( aLayoutSize.Width() * propvalue[2] ) );
1180 aLayoutPos.AdjustY(::tools::Long( aLayoutSize.Height() * propvalue[3] ) );
1181 aLayoutSize.setWidth( ::tools::Long( aLayoutSize.Width() * propvalue[1] ) );
1182 aLayoutSize.setHeight( ::tools::Long( aLayoutSize.Height() * propvalue[0] ) );
1183 aLayoutRect.SetPos(aLayoutPos);
1184 aLayoutRect.SetSize(aLayoutSize);
1186 else if (mePageKind == PageKind::Notes)
1188 getPresObjProp( *this, "PRESOBJ_NOTES", sPageKind, propvalue);
1189 aLayoutPos.AdjustX(::tools::Long( aLayoutSize.Width() * propvalue[2] ) );
1190 aLayoutPos.AdjustY(::tools::Long( aLayoutSize.Height() * propvalue[3] ) );
1191 aLayoutSize.setWidth( ::tools::Long( aLayoutSize.Width() * propvalue[1] ) );
1192 aLayoutSize.setHeight( ::tools::Long( aLayoutSize.Height() * propvalue[0] ) );
1193 aLayoutRect.SetPos(aLayoutPos);
1194 aLayoutRect.SetSize(aLayoutSize);
1198 return aLayoutRect;
1201 /**************************************************************************
1203 |* assign an AutoLayout
1205 \*************************************************************************/
1207 const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout
1208 const int VERTICAL = 0x8000;
1210 static constexpr PresObjKind operator|(PresObjKind e, int x)
1212 return static_cast<PresObjKind>(static_cast<int>(e) | x);
1215 namespace {
1217 struct LayoutDescriptor
1219 PresObjKind meKind[MAX_PRESOBJS];
1220 bool mbVertical[MAX_PRESOBJS];
1222 LayoutDescriptor( PresObjKind k0 = PresObjKind::NONE, PresObjKind k1 = PresObjKind::NONE, PresObjKind k2 = PresObjKind::NONE, PresObjKind k3 = PresObjKind::NONE, PresObjKind k4 = PresObjKind::NONE, PresObjKind k5 = PresObjKind::NONE, PresObjKind k6 = PresObjKind::NONE );
1227 LayoutDescriptor::LayoutDescriptor( PresObjKind k0, PresObjKind k1, PresObjKind k2, PresObjKind k3, PresObjKind k4, PresObjKind k5, PresObjKind k6 )
1229 auto removeVertical = [&] (PresObjKind k) { return static_cast<PresObjKind>(static_cast<int>(k) & ~VERTICAL); };
1230 auto isVertical = [&] (PresObjKind k) { return bool(static_cast<int>(k) & VERTICAL); };
1231 meKind[0] = removeVertical(k0); mbVertical[0] = isVertical(k0);
1232 meKind[1] = removeVertical(k1); mbVertical[1] = isVertical(k1);
1233 meKind[2] = removeVertical(k2); mbVertical[2] = isVertical(k2);
1234 meKind[3] = removeVertical(k3); mbVertical[3] = isVertical(k3);
1235 meKind[4] = removeVertical(k4); mbVertical[4] = isVertical(k4);
1236 meKind[5] = removeVertical(k5); mbVertical[5] = isVertical(k5);
1237 meKind[6] = removeVertical(k6); mbVertical[6] = isVertical(k6);
1240 static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
1242 static const LayoutDescriptor aLayouts[AUTOLAYOUT_END-AUTOLAYOUT_START] =
1244 LayoutDescriptor( PresObjKind::Title, PresObjKind::Text ), // AUTOLAYOUT_TITLE
1245 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline ), // AUTOLAYOUT_TITLE_CONTENT
1246 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline ), // AUTOLAYOUT_CHART
1247 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TITLE_2CONTENT
1248 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TEXTCHART
1249 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline ), // AUTOLAYOUT_ORG
1250 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TEXTCLbIP
1251 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_CHARTTEXT
1252 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline ), // AUTOLAYOUT_TAB
1253 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_CLIPTEXT
1254 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TEXTOBJ
1255 LayoutDescriptor( PresObjKind::Title, PresObjKind::Object ), // AUTOLAYOUT_OBJ
1256 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TITLE_CONTENT_2CONTENT
1257 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TEXTOBJ
1258 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT
1259 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TITLE_2CONTENT_CONTENT
1260 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT
1261 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline ), // AUTOLAYOUT_TEXTOVEROBJ
1262 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline, // AUTOLAYOUT_TITLE_4CONTENT
1263 PresObjKind::Outline, PresObjKind::Outline ),
1264 LayoutDescriptor( PresObjKind::Title, PresObjKind::NONE ), // AUTOLAYOUT_TITLE_ONLY
1265 LayoutDescriptor( PresObjKind::NONE ), // AUTOLAYOUT_NONE
1266 LayoutDescriptor( PresObjKind::Page, PresObjKind::Notes ), // AUTOLAYOUT_NOTES
1267 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT1
1268 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT2
1269 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT3
1270 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT4
1271 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT6
1272 LayoutDescriptor( PresObjKind::Title|VERTICAL, PresObjKind::Outline|VERTICAL, PresObjKind::Outline ),// AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT
1273 LayoutDescriptor( PresObjKind::Title|VERTICAL, PresObjKind::Outline|VERTICAL ), // AUTOLAYOUT_VTITLE_VCONTENT
1274 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline|VERTICAL ), // AUTOLAYOUT_TITLE_VCONTENT
1275 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline|VERTICAL, PresObjKind::Outline|VERTICAL ), // AUTOLAYOUT_TITLE_2VTEXT
1276 LayoutDescriptor( ), // AUTOLAYOUT_HANDOUT9
1277 LayoutDescriptor( PresObjKind::Text, PresObjKind::NONE ), // AUTOLAYOUT_ONLY_TEXT
1278 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline, // AUTOLAYOUT_4CLIPART
1279 PresObjKind::Graphic, PresObjKind::Graphic ),
1280 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline, // AUTOLAYOUT_TITLE_6CONTENT
1281 PresObjKind::Outline, PresObjKind::Outline, PresObjKind::Outline, PresObjKind::Outline )
1284 if( (eLayout < AUTOLAYOUT_START) || (eLayout >= AUTOLAYOUT_END) )
1285 eLayout = AUTOLAYOUT_NONE;
1287 return aLayouts[ eLayout - AUTOLAYOUT_START ];
1290 static OUString enumtoString(AutoLayout aut)
1292 OUString retstr;
1293 switch (aut)
1295 case AUTOLAYOUT_TITLE_CONTENT:
1296 retstr="AUTOLAYOUT_TITLE_CONTENT";
1297 break;
1298 case AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT:
1299 retstr="AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT";
1300 break;
1301 case AUTOLAYOUT_TITLE_CONTENT_2CONTENT:
1302 retstr="AUTOLAYOUT_TITLE_CONTENT_2CONTENT";
1303 break;
1304 case AUTOLAYOUT_TITLE_4CONTENT:
1305 retstr="AUTOLAYOUT_TITLE_4CONTENT";
1306 break;
1307 case AUTOLAYOUT_ONLY_TEXT:
1308 retstr="AUTOLAYOUT_ONLY_TEXT";
1309 break;
1310 case AUTOLAYOUT_TITLE_ONLY:
1311 retstr="AUTOLAYOUT_TITLE_ONLY";
1312 break;
1313 case AUTOLAYOUT_TITLE_6CONTENT:
1314 retstr="AUTOLAYOUT_TITLE_6CONTENT";
1315 break;
1316 case AUTOLAYOUT_START:
1317 retstr="AUTOLAYOUT_START";
1318 break;
1319 case AUTOLAYOUT_TITLE_2CONTENT_CONTENT:
1320 retstr="AUTOLAYOUT_TITLE_2CONTENT_CONTENT";
1321 break;
1322 case AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT:
1323 retstr="AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT";
1324 break;
1325 case AUTOLAYOUT_TITLE_2CONTENT:
1326 retstr="AUTOLAYOUT_TITLE_2CONTENT";
1327 break;
1328 case AUTOLAYOUT_VTITLE_VCONTENT:
1329 retstr="AUTOLAYOUT_VTITLE_VCONTENT";
1330 break;
1331 case AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT:
1332 retstr="AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT";
1333 break;
1334 case AUTOLAYOUT_TITLE_VCONTENT:
1335 retstr="AUTOLAYOUT_TITLE_VCONTENT";
1336 break;
1337 case AUTOLAYOUT_TITLE_2VTEXT:
1338 retstr="AUTOLAYOUT_TITLE_2VTEXT";
1339 break;
1340 default:
1341 retstr="unknown";
1342 break;
1343 // case AUTOLAYOUT_TITLE_4SCONTENT: return "AUTOLAYOUT_TITLE_4SCONTENT";
1345 return retstr;
1348 static void CalcAutoLayoutRectangles( SdPage const & rPage,::tools::Rectangle* rRectangle ,const OUString& sLayoutType )
1350 ::tools::Rectangle aTitleRect;
1351 ::tools::Rectangle aLayoutRect;
1353 if( rPage.GetPageKind() != PageKind::Handout )
1355 SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage());
1356 SdrObject* pMasterTitle = rMasterPage.GetPresObj( PresObjKind::Title );
1357 SdrObject* pMasterSubTitle = rMasterPage.GetPresObj( PresObjKind::Text );
1358 SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PageKind::Notes ? PresObjKind::Notes : PresObjKind::Outline );
1360 if( pMasterTitle )
1361 aTitleRect = pMasterTitle->GetLogicRect();
1363 if (aTitleRect.IsEmpty() )
1364 aTitleRect = rPage.GetTitleRect();
1365 if( pMasterSubTitle )
1366 aLayoutRect = pMasterSubTitle->GetLogicRect();
1367 else if( pMasterOutline )
1368 aLayoutRect = pMasterOutline->GetLogicRect();
1370 if (aLayoutRect.IsEmpty() )
1371 aLayoutRect = rPage.GetLayoutRect();
1374 rRectangle[0] = aTitleRect;
1375 for( int i = 1; i < MAX_PRESOBJS; i++ )
1376 rRectangle[i] = aLayoutRect;
1378 const Point aTitlePos( aTitleRect.TopLeft() );
1379 const Size aLayoutSize( aLayoutRect.GetSize() );
1380 const Point aLayoutPos( aLayoutRect.TopLeft() );
1381 double propvalue[] = {0,0,0,0};
1383 const std::vector< Reference<XNode> >& layoutInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetLayoutVector();
1384 auto aIter = std::find_if(layoutInfo.begin(), layoutInfo.end(),
1385 [&sLayoutType](const Reference<XNode>& layoutNode) {
1386 Reference<XNamedNodeMap> layoutAttrList = layoutNode->getAttributes();
1388 // get the attribute value of layout (i.e it's type)
1389 OUString sLayoutAttName = layoutAttrList->getNamedItem("type")->getNodeValue();
1390 return sLayoutAttName == sLayoutType;
1392 if (aIter == layoutInfo.end())
1393 return;
1395 int count=0;
1396 Reference<XNode> layoutNode = *aIter;
1397 Reference<XNodeList> layoutChildren = layoutNode->getChildNodes();
1398 const int presobjsize = layoutChildren->getLength();
1399 for( int j=0; j< presobjsize ; j++)
1401 OUString nodename;
1402 Reference<XNode> presobj = layoutChildren->item(j);
1403 nodename=presobj->getNodeName();
1405 //check whether child is blank 'text-node' or 'presobj' node
1406 if(nodename == "presobj")
1408 // TODO: rework sd to permit arbitrary number of presentation objects
1409 assert(count < MAX_PRESOBJS);
1411 Reference<XNamedNodeMap> presObjAttributes = presobj->getAttributes();
1413 Reference<XNode> presObjSizeHeight = presObjAttributes->getNamedItem("relative-height");
1414 OUString sValue = presObjSizeHeight->getNodeValue();
1415 propvalue[0] = sValue.toDouble();
1417 Reference<XNode> presObjSizeWidth = presObjAttributes->getNamedItem("relative-width");
1418 sValue = presObjSizeWidth->getNodeValue();
1419 propvalue[1] = sValue.toDouble();
1421 Reference<XNode> presObjPosX = presObjAttributes->getNamedItem("relative-posX");
1422 sValue = presObjPosX->getNodeValue();
1423 propvalue[2] = sValue.toDouble();
1425 Reference<XNode> presObjPosY = presObjAttributes->getNamedItem("relative-posY");
1426 sValue = presObjPosY->getNodeValue();
1427 propvalue[3] = sValue.toDouble();
1429 if(count == 0)
1431 Size aSize ( aTitleRect.GetSize() );
1432 aSize.setHeight( basegfx::fround(aSize.Height() * propvalue[0]) );
1433 aSize.setWidth( basegfx::fround(aSize.Width() * propvalue[1]) );
1434 Point aPos( basegfx::fround(aTitlePos.X() +(aSize.Width() * propvalue[2])),
1435 basegfx::fround(aTitlePos.Y() + (aSize.Height() * propvalue[3])) );
1436 rRectangle[count] = ::tools::Rectangle(aPos, aSize);
1437 count = count+1;
1439 else
1441 Size aSize( basegfx::fround(aLayoutSize.Width() * propvalue[1]),
1442 basegfx::fround(aLayoutSize.Height() * propvalue[0]) );
1443 Point aPos( basegfx::fround(aLayoutPos.X() +(aSize.Width() * propvalue[2])),
1444 basegfx::fround(aLayoutPos.Y() + (aSize.Height() * propvalue[3])) );
1445 rRectangle[count] = ::tools::Rectangle (aPos, aSize);
1446 count = count+1;
1452 static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::array<SdrObject*, MAX_PRESOBJS>& rShapes, bool bInit, bool bSwitchLayout )
1454 // init list of indexes for each presentation shape kind
1455 // this is used to find subsequent shapes with the same presentation shape kind
1456 o3tl::enumarray<PresObjKind,int> PresObjIndex;
1457 PresObjIndex.fill(1);
1459 bool bMissing = false;
1461 // for each entry in the layoutdescriptor, arrange a presentation shape
1462 for (int i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PresObjKind::NONE); i++)
1464 PresObjKind eKind = rDescriptor.meKind[i];
1465 SdrObject* pObj = nullptr;
1466 while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != nullptr )
1468 PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
1470 if( !bSwitchLayout || !pObj->IsEmptyPresObj() )
1472 rShapes[i] = pObj;
1473 break;
1477 if( !pObj )
1478 bMissing = true;
1481 if( !(bMissing && bInit) )
1482 return;
1484 // for each entry in the layoutdescriptor, look for an alternative shape
1485 for (int i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PresObjKind::NONE); i++)
1487 if( rShapes[i] )
1488 continue;
1490 PresObjKind eKind = rDescriptor.meKind[i];
1492 SdrObject* pObj = nullptr;
1493 bool bFound = false;
1495 const size_t nShapeCount = rPage.GetObjCount();
1496 for(size_t nShapeIndex = 0; nShapeIndex < nShapeCount && !bFound; ++nShapeIndex )
1498 pObj = rPage.GetObj(nShapeIndex);
1500 if( pObj->IsEmptyPresObj() )
1501 continue;
1503 if( pObj->GetObjInventor() != SdrInventor::Default )
1504 continue;
1506 // do not reuse shapes that are already part of the layout
1507 if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() )
1508 continue;
1510 bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SfxStyleFamily::Page);
1511 SdrObjKind eSdrObjKind = pObj->GetObjIdentifier();
1513 switch( eKind )
1515 case PresObjKind::Title:
1516 bFound = eSdrObjKind == OBJ_TITLETEXT;
1517 break;
1518 case PresObjKind::Table:
1519 bFound = eSdrObjKind == OBJ_TABLE;
1520 break;
1521 case PresObjKind::Media:
1522 bFound = eSdrObjKind == OBJ_MEDIA;
1523 break;
1524 case PresObjKind::Outline:
1525 bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
1526 ((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
1527 (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2);
1528 break;
1529 case PresObjKind::Graphic:
1530 bFound = eSdrObjKind == OBJ_GRAF;
1531 break;
1532 case PresObjKind::Object:
1533 if( eSdrObjKind == OBJ_OLE2 )
1535 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1536 if( pOle2 )
1538 if( pOle2->IsEmpty() )
1539 bFound = true;
1540 else
1542 ::comphelper::IEmbeddedHelper* pPersist(rPage.getSdrModelFromSdrPage().GetPersist());
1544 if( pPersist )
1546 uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
1547 GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
1549 // TODO CL->KA: Why is this not working anymore?
1550 if( xObject.is() )
1552 SvGlobalName aClassId( xObject->getClassID() );
1554 const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
1555 const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
1556 const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
1558 if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
1560 bFound = true;
1567 break;
1568 case PresObjKind::Chart:
1569 case PresObjKind::Calc:
1570 if( eSdrObjKind == OBJ_OLE2 )
1572 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1573 if( pOle2 )
1576 ((eKind == PresObjKind::Chart) &&
1577 ( pOle2->GetProgName() == "StarChart" || pOle2->IsChart() ) )
1579 ((eKind == PresObjKind::Calc) &&
1580 ( pOle2->GetProgName() == "StarCalc" || pOle2->IsCalc() ) ) )
1582 bFound = true;
1585 break;
1587 else if( eSdrObjKind == OBJ_TABLE )
1589 bFound = true;
1591 break;
1592 case PresObjKind::Page:
1593 case PresObjKind::Handout:
1594 bFound = eSdrObjKind == OBJ_PAGE;
1595 break;
1596 case PresObjKind::Notes:
1597 case PresObjKind::Text:
1598 bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT);
1599 break;
1600 default:
1601 break;
1605 if( bFound )
1606 rShapes[i] = pObj;
1610 void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
1612 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1614 const bool bSwitchLayout = eLayout != GetAutoLayout();
1616 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
1617 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
1619 meAutoLayout = eLayout;
1621 // if needed, creates and initialises the presentation shapes on this slides master page
1622 CreateTitleAndLayout(bInit, bCreate);
1624 if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster)
1626 // MasterPage or no layout and no presentation shapes available, nothing to do
1627 return;
1630 ::tools::Rectangle aRectangle[MAX_PRESOBJS];
1631 const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
1632 OUString sLayoutName( enumtoString(meAutoLayout) );
1633 CalcAutoLayoutRectangles( *this, aRectangle, sLayoutName);
1635 o3tl::sorted_vector< SdrObject* > aUsedPresentationObjects;
1637 std::array<SdrObject*, MAX_PRESOBJS > aLayoutShapes;
1638 aLayoutShapes.fill(nullptr);
1639 findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
1641 // for each entry in the layoutdescriptor, arrange a presentation shape
1642 for (int i = 0; (i < MAX_PRESOBJS) && (aDescriptor.meKind[i] != PresObjKind::NONE); i++)
1644 PresObjKind eKind = aDescriptor.meKind[i];
1645 SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );
1646 if( pObj )
1647 aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape
1650 // now delete all empty presentation objects that are no longer used by the new layout
1651 if( !bInit )
1652 return;
1654 SdrObject* pObj = nullptr;
1655 maPresentationShapeList.seekShape(0);
1657 while( (pObj = maPresentationShapeList.getNextShape()) )
1659 if( aUsedPresentationObjects.count(pObj) == 0 )
1662 if( pObj->IsEmptyPresObj() )
1664 if( bUndo )
1665 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
1667 RemoveObject( pObj->GetOrdNum() );
1669 if( !bUndo )
1670 SdrObject::Free( pObj );
1672 /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */
1677 /*************************************************************************
1679 |* insert object
1681 \************************************************************************/
1683 void SdPage::NbcInsertObject(SdrObject* pObj, size_t nPos)
1685 FmFormPage::NbcInsertObject(pObj, nPos);
1687 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).InsertObject(pObj);
1689 SdrLayerID nId = pObj->GetLayer();
1690 if( mbMaster )
1692 if( nId == SdrLayerID(0) )
1693 pObj->NbcSetLayer( SdrLayerID(2) ); // wrong layer. corrected to BackgroundObj layer
1695 else
1697 if( nId == SdrLayerID(2) )
1698 pObj->NbcSetLayer( SdrLayerID(0) ); // wrong layer. corrected to layout layer
1702 /*************************************************************************
1704 |* remove object
1706 \************************************************************************/
1708 SdrObject* SdPage::RemoveObject(size_t nObjNum)
1710 onRemoveObject(GetObj( nObjNum ));
1711 return FmFormPage::RemoveObject(nObjNum);
1714 /*************************************************************************
1716 |* remove object without broadcast
1718 \************************************************************************/
1720 SdrObject* SdPage::NbcRemoveObject(size_t nObjNum)
1722 onRemoveObject(GetObj( nObjNum ));
1723 return FmFormPage::NbcRemoveObject(nObjNum);
1726 // Also override ReplaceObject methods to realize when
1727 // objects are removed with this mechanism instead of RemoveObject
1728 SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
1730 onRemoveObject(GetObj( nObjNum ));
1731 return FmFormPage::ReplaceObject(pNewObj, nObjNum);
1734 // called after a shape is removed or replaced from this slide
1736 void SdPage::onRemoveObject( SdrObject* pObject )
1738 if( pObject )
1740 RemovePresObj(pObject);
1742 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).RemoveObject(pObject);
1744 removeAnimations( pObject );
1748 void SdPage::SetSize(const Size& aSize)
1750 Size aOldSize = GetSize();
1752 if (aSize != aOldSize)
1754 FmFormPage::SetSize(aSize);
1758 void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
1760 if (nLft != GetLeftBorder() || nUpp != GetUpperBorder() ||
1761 nRgt != GetRightBorder() || nLwr != GetLowerBorder() )
1763 FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
1767 void SdPage::SetLeftBorder(sal_Int32 nBorder)
1769 if (nBorder != GetLeftBorder() )
1771 FmFormPage::SetLeftBorder(nBorder);
1775 void SdPage::SetRightBorder(sal_Int32 nBorder)
1777 if (nBorder != GetRightBorder() )
1779 FmFormPage::SetRightBorder(nBorder);
1783 void SdPage::SetUpperBorder(sal_Int32 nBorder)
1785 if (nBorder != GetUpperBorder() )
1787 FmFormPage::SetUpperBorder(nBorder);
1791 void SdPage::SetLowerBorder(sal_Int32 nBorder)
1793 if (nBorder != GetLowerBorder() )
1795 FmFormPage::SetLowerBorder(nBorder);
1799 /*************************************************************************
1801 |* Sets BackgroundFullSize and then calls AdjustBackground
1803 \************************************************************************/
1805 void SdPage::SetBackgroundFullSize( bool bIn )
1807 if( bIn != mbBackgroundFullSize )
1809 mbBackgroundFullSize = bIn;
1813 /*************************************************************************
1815 |* Adjust all objects to new page size.
1817 |* bScaleAllObj: all objects are scaled into the new area within the page
1818 |* margins. We scale the position and size. For presentation objects on the
1819 |* master page, we also scale the font height of the presentation template.
1821 \************************************************************************/
1823 void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rNewBorderRect, bool bScaleAllObj)
1825 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement );
1827 mbScaleObjects = bScaleAllObj;
1828 SdrObject* pObj = nullptr;
1829 Point aRefPnt(0, 0);
1830 Size aNewPageSize(rNewPageSize);
1831 sal_Int32 nLeft = rNewBorderRect.Left();
1832 sal_Int32 nRight = rNewBorderRect.Right();
1833 sal_Int32 nUpper = rNewBorderRect.Top();
1834 sal_Int32 nLower = rNewBorderRect.Bottom();
1836 // negative values are fixed values
1837 // -> use up to date values
1838 if (aNewPageSize.Width() < 0)
1840 aNewPageSize.setWidth( GetWidth() );
1842 if (aNewPageSize.Height() < 0)
1844 aNewPageSize.setHeight( GetHeight() );
1846 if (nLeft < 0)
1848 nLeft = GetLeftBorder();
1850 if (nRight < 0)
1852 nRight = GetRightBorder();
1854 if (nUpper < 0)
1856 nUpper = GetUpperBorder();
1858 if (nLower < 0)
1860 nLower = GetLowerBorder();
1863 Size aBackgroundSize(aNewPageSize);
1865 if (mbScaleObjects)
1867 aBackgroundSize.AdjustWidth( -(nLeft + nRight) );
1868 aBackgroundSize.AdjustHeight( -(nUpper + nLower) );
1869 aNewPageSize = aBackgroundSize;
1872 ::tools::Long nOldWidth = GetWidth() - GetLeftBorder() - GetRightBorder();
1873 ::tools::Long nOldHeight = GetHeight() - GetUpperBorder() - GetLowerBorder();
1875 Fraction aFractX(aNewPageSize.Width(), nOldWidth);
1876 Fraction aFractY(aNewPageSize.Height(), nOldHeight);
1878 const size_t nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
1880 for (size_t nObj = 0; nObj < nObjCnt; ++nObj)
1882 bool bIsPresObjOnMaster = false;
1884 // all Objects
1885 pObj = GetObj(nObj);
1887 if (mbMaster && IsPresObj(pObj))
1889 // There is a presentation object on the master page
1890 bIsPresObjOnMaster = true;
1893 if (pObj)
1895 // remember aTopLeft as original TopLeft
1896 Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
1898 if (!pObj->IsEdgeObj())
1900 /**************************************************************
1901 * Scale objects
1902 **************************************************************/
1903 if (mbScaleObjects)
1905 // use aTopLeft as original TopLeft
1906 aRefPnt = aTopLeft;
1909 pObj->Resize(aRefPnt, aFractX, aFractY);
1911 if (mbScaleObjects)
1913 SdrObjKind eObjKind = pObj->GetObjIdentifier();
1915 if (bIsPresObjOnMaster)
1917 /**********************************************************
1918 * presentation template: adjust test height
1919 **********************************************************/
1921 if (pObj == GetPresObj(PresObjKind::Title, 0))
1923 SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PresObjKind::Title);
1925 if (pTitleSheet)
1927 SfxItemSet& rSet = pTitleSheet->GetItemSet();
1929 const SvxFontHeightItem& rOldHgt = rSet.Get(EE_CHAR_FONTHEIGHT);
1930 sal_uLong nFontHeight = rOldHgt.GetHeight();
1931 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1932 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1934 if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1936 const SvxFontHeightItem& rOldHgt2 = rSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1937 nFontHeight = rOldHgt2.GetHeight();
1938 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1939 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1942 if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1944 const SvxFontHeightItem& rOldHgt2 = rSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1945 nFontHeight = rOldHgt2.GetHeight();
1946 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1947 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1950 pTitleSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
1953 else if (pObj == GetPresObj(PresObjKind::Outline, 0))
1955 OUString aName(GetLayoutName() + " ");
1957 for (sal_Int32 i=1; i<=9; i++)
1959 OUString sLayoutName( aName + OUString::number( i ) );
1960 SfxStyleSheet* pOutlineSheet = static_cast<SfxStyleSheet*>(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetStyleSheetPool()->Find(sLayoutName, SfxStyleFamily::Page));
1962 if (pOutlineSheet)
1964 // Calculate new font height
1965 SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
1967 const SvxFontHeightItem& rOldHgt = aTempSet.Get(EE_CHAR_FONTHEIGHT);
1968 sal_uLong nFontHeight = rOldHgt.GetHeight();
1969 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1970 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1972 if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1974 const SvxFontHeightItem& rOldHgt2 = aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1975 nFontHeight = rOldHgt2.GetHeight();
1976 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1977 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1980 if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1982 const SvxFontHeightItem& rOldHgt2 = aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1983 nFontHeight = rOldHgt2.GetHeight();
1984 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1985 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1988 // adjust bullet
1989 static_cast<SdStyleSheet*>(pOutlineSheet)->AdjustToFontHeight(aTempSet, false);
1991 // Special treatment: reset the INVALIDS to
1992 // NULL pointer (otherwise we have INVALID's
1993 // or pointer to the DefaultItems in the
1994 // template; both would suppress the
1995 // attribute inheritance)
1996 aTempSet.ClearInvalidItems();
1998 // Special treatment: only the valid parts
1999 // of the BulletItems
2000 if (aTempSet.GetItemState(EE_PARA_BULLET) == SfxItemState::DEFAULT)
2002 SvxBulletItem aOldBulItem( pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET) );
2003 const SvxBulletItem& rNewBulItem = aTempSet.Get(EE_PARA_BULLET);
2004 aOldBulItem.CopyValidProperties(rNewBulItem);
2005 aTempSet.Put(aOldBulItem);
2008 pOutlineSheet->GetItemSet().Put(aTempSet);
2009 pOutlineSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
2013 else if (pObj == GetPresObj(PresObjKind::Notes, 0))
2015 SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PresObjKind::Notes);
2017 if (pNotesSheet)
2019 sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height();
2020 sal_uLong nFontHeight = static_cast<sal_uLong>(nHeight * 0.0741);
2021 SfxItemSet& rSet = pNotesSheet->GetItemSet();
2022 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
2023 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
2024 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
2025 pNotesSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
2029 else if ( eObjKind != OBJ_TITLETEXT &&
2030 eObjKind != OBJ_OUTLINETEXT &&
2031 dynamic_cast< const SdrTextObj *>( pObj ) != nullptr &&
2032 pObj->GetOutlinerParaObject() )
2034 /******************************************************
2035 * normal text object: adjust text height
2036 ******************************************************/
2037 SvtScriptType nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
2038 sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT;
2039 if ( nScriptType == SvtScriptType::ASIAN )
2040 nWhich = EE_CHAR_FONTHEIGHT_CJK;
2041 else if ( nScriptType == SvtScriptType::COMPLEX )
2042 nWhich = EE_CHAR_FONTHEIGHT_CTL;
2044 // use more modern method to scale the text height
2045 sal_uInt32 nFontHeight = static_cast<const SvxFontHeightItem&>(pObj->GetMergedItem(nWhich)).GetHeight();
2046 sal_uInt32 nNewFontHeight = sal_uInt32(static_cast<double>(nFontHeight) * static_cast<double>(aFractY));
2048 pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
2053 if (mbScaleObjects && !pObj->IsEdgeObj())
2055 /**************************************************************
2056 * scale object position
2057 **************************************************************/
2058 Point aNewPos;
2060 // corrected scaling; only distances may be scaled
2061 // use aTopLeft as original TopLeft
2062 aNewPos.setX( ::tools::Long((aTopLeft.X() - GetLeftBorder()) * static_cast<double>(aFractX)) + nLeft );
2063 aNewPos.setY( ::tools::Long((aTopLeft.Y() - GetUpperBorder()) * static_cast<double>(aFractY)) + nUpper );
2065 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
2067 if (aVec.Height() != 0 || aVec.Width() != 0)
2069 pObj->NbcMove(aVec);
2072 pObj->SetChanged();
2073 pObj->BroadcastObjectChange();
2079 static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect)
2081 SdDrawDocument& rModel(static_cast< SdDrawDocument& >(rPage.getSdrModelFromSdrPage()));
2082 if( !pSourceObj )
2083 return pSourceObj;
2085 SfxUndoManager* pUndoManager = rModel.GetUndoManager();
2086 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
2088 SdrObject* pNewObj = pSourceObj;
2089 if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) )
2091 pNewObj = rPage.CreatePresObj(PresObjKind::Outline, bVertical, rRect);
2093 // Set text of the subtitle into PRESOBJ_OUTLINE
2094 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2096 if(pOutlParaObj)
2098 // assign text
2099 SdOutliner* pOutl = rModel.GetInternalOutliner();
2100 pOutl->Clear();
2101 pOutl->SetText( *pOutlParaObj );
2102 std::unique_ptr<OutlinerParaObject> pNew = pOutl->CreateParaObject();
2103 pOutlParaObj = pNew.get();
2104 pNewObj->SetOutlinerParaObject( std::move(pNew) );
2105 pOutl->Clear();
2106 pNewObj->SetEmptyPresObj(false);
2108 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
2110 // assign new template
2111 OUString aName( rPage.GetLayoutName() + " " + OUString::number( nLevel ) );
2112 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( rModel.GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page) );
2114 if (pSheet && nLevel == 1)
2116 SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PresObjKind::Text);
2118 if (pSubtitleSheet)
2119 pOutlParaObj->ChangeStyleSheetName(SfxStyleFamily::Page, pSubtitleSheet->GetName(), pSheet->GetName());
2123 // Remove LRSpace item
2124 SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
2126 aSet.Put(pNewObj->GetMergedItemSet());
2128 aSet.ClearItem(EE_PARA_LRSPACE);
2130 pNewObj->SetMergedItemSet(aSet);
2132 if( bUndo )
2133 pUndoManager->AddUndoAction( rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
2135 // Remove outline shape from page
2136 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2138 if( !bUndo )
2139 SdrObject::Free( pSourceObj );
2142 else if((eObjKind == PresObjKind::Text) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) )
2144 // is there an outline shape we can use to replace empty subtitle shape?
2145 pNewObj = rPage.CreatePresObj(PresObjKind::Text, bVertical, rRect);
2147 // Set text of the outline object into PRESOBJ_TITLE
2148 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2150 if(pOutlParaObj)
2152 // assign text
2153 SdOutliner* pOutl = rModel.GetInternalOutliner();
2154 pOutl->Clear();
2155 pOutl->SetText( *pOutlParaObj );
2156 pNewObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
2157 pOutl->Clear();
2158 pNewObj->SetEmptyPresObj(false);
2160 // reset left indent
2161 SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
2163 aSet.Put(pNewObj->GetMergedItemSet());
2165 const SvxLRSpaceItem& rLRItem = aSet.Get(EE_PARA_LRSPACE);
2166 SvxLRSpaceItem aNewLRItem(rLRItem);
2167 aNewLRItem.SetTextLeft(0);
2168 aSet.Put(aNewLRItem);
2170 pNewObj->SetMergedItemSet(aSet);
2172 SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PresObjKind::Text);
2173 if (pSheet)
2174 pNewObj->SetStyleSheet(pSheet, true);
2176 // Remove subtitle shape from page
2177 if( bUndo )
2178 pUndoManager->AddUndoAction(rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
2180 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2182 if( !bUndo )
2183 SdrObject::Free( pSourceObj );
2186 else if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) )
2188 switch( pSourceObj->GetObjIdentifier() )
2190 case OBJ_TABLE: eObjKind = PresObjKind::Table; break;
2191 case OBJ_MEDIA: eObjKind = PresObjKind::Media; break;
2192 case OBJ_GRAF: eObjKind = PresObjKind::Graphic; break;
2193 case OBJ_OLE2: eObjKind = PresObjKind::Object; break;
2194 default: break;
2198 return pNewObj;
2201 /** reuses or creates a presentation shape for an auto layout that fits the given parameter
2203 @param eObjKind
2204 The kind of presentation shape we like to have
2205 @param nIndex
2206 If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while
2207 looking for an existing presentation shape
2208 @param bVertical
2209 If true, the shape is created vertical if bInit is true
2210 @param rRect
2211 The rectangle that should be used to transform the shape
2212 @param bInit
2213 If true the shape is created if not found
2214 @returns
2215 A presentation shape that was either found or created with the given parameters
2217 SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit)
2219 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
2220 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
2222 if (!pObj && bInit)
2224 pObj = CreatePresObj(eObjKind, bVertical, rRect);
2226 else if ( pObj && (pObj->GetUserCall() || bInit) )
2228 // convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2229 if( bInit )
2230 pObj = convertPresentationObjectImpl(*this, pObj, eObjKind, bVertical, rRect);
2232 if( bUndo )
2234 pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
2235 pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoAttrObject( *pObj, true, true ) );
2236 pUndoManager->AddUndoAction( std::make_unique<UndoObjectUserCall>( *pObj ) );
2239 pObj->AdjustToMaxRect(rRect);
2241 pObj->SetUserCall(this);
2243 SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj);
2244 if( pTextObject )
2246 if( pTextObject->IsVerticalWriting() != bVertical )
2248 pTextObject->SetVerticalWriting( bVertical );
2250 // here make sure the correct anchoring is used when the object
2251 // is re-used but orientation is changed
2252 if(PresObjKind::Outline == eObjKind)
2253 pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
2256 if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) )
2258 if ( pTextObject->IsAutoGrowHeight() )
2260 // switch off AutoGrowHeight, set new MinHeight
2261 SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2262 SdrMetricItem aMinHeight( makeSdrTextMinFrameHeightItem(rRect.GetSize().Height()) );
2263 aTempAttr.Put( aMinHeight );
2264 aTempAttr.Put( makeSdrTextAutoGrowHeightItem(false) );
2265 pTextObject->SetMergedItemSet(aTempAttr);
2266 pTextObject->SetLogicRect(rRect);
2268 // switch on AutoGrowHeight
2269 SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2270 aAttr.Put( makeSdrTextAutoGrowHeightItem(true) );
2272 pTextObject->SetMergedItemSet(aAttr);
2275 if ( pTextObject->IsAutoGrowWidth() )
2277 // switch off AutoGrowWidth , set new MinWidth
2278 SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2279 SdrMetricItem aMinWidth( makeSdrTextMinFrameWidthItem(rRect.GetSize().Width()) );
2280 aTempAttr.Put( aMinWidth );
2281 aTempAttr.Put( makeSdrTextAutoGrowWidthItem(false) );
2282 pTextObject->SetMergedItemSet(aTempAttr);
2283 pTextObject->SetLogicRect(rRect);
2285 // switch on AutoGrowWidth
2286 SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2287 aAttr.Put( makeSdrTextAutoGrowWidthItem(true) );
2288 pTextObject->SetMergedItemSet(aAttr);
2294 if(pObj && bInit )
2296 if( !IsPresObj( pObj ) )
2298 if( bUndo )
2299 pUndoManager->AddUndoAction( std::make_unique<UndoObjectPresentationKind>( *pObj ) );
2301 InsertPresObj( pObj, eObjKind );
2304 // make adjustments for vertical title and outline shapes
2305 if( bVertical && (( eObjKind == PresObjKind::Title) || (eObjKind == PresObjKind::Outline)))
2307 SfxItemSet aNewSet(pObj->GetMergedItemSet());
2308 aNewSet.Put( makeSdrTextAutoGrowWidthItem(true) );
2309 aNewSet.Put( makeSdrTextAutoGrowHeightItem(false) );
2310 if( eObjKind == PresObjKind::Outline )
2312 aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
2313 aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
2315 pObj->SetMergedItemSet(aNewSet);
2319 if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || dynamic_cast< const SdrGrafObj *>( pObj ) == nullptr ) )
2320 pObj->AdjustToMaxRect(rRect);
2322 return pObj;
2325 /*************************************************************************
2327 |* Returns the PresObjKind of an object
2329 \************************************************************************/
2331 PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const
2333 PresObjKind eKind = PresObjKind::NONE;
2334 if( (pObj != nullptr) && (maPresentationShapeList.hasShape(*pObj)) )
2336 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
2337 if( pInfo )
2338 eKind = pInfo->mePresObjKind;
2341 return eKind;
2344 bool SdPage::IsPresObj(const SdrObject* pObj)
2346 return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
2349 void SdPage::RemovePresObj(const SdrObject* pObj)
2351 if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
2353 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
2354 if( pInfo )
2355 pInfo->mePresObjKind = PresObjKind::NONE;
2356 maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
2360 void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
2362 DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2363 DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2364 if( pObj )
2366 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true);
2367 if( pInfo )
2368 pInfo->mePresObjKind = eKind;
2369 maPresentationShapeList.addShape(*pObj);
2373 /*************************************************************************
2375 |* Set the text of an object
2377 \************************************************************************/
2379 void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const OUString& rString )
2381 if ( !pObj )
2382 return;
2384 DBG_ASSERT( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr, "SetObjText: No SdrTextObj!" );
2385 ::Outliner* pOutl = pOutliner;
2387 if (!pOutliner)
2389 SfxItemPool* pPool(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDrawOutliner().GetEmptyItemSet().GetPool());
2390 pOutl = new ::Outliner( pPool, OutlinerMode::OutlineObject );
2391 pOutl->SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
2392 pOutl->SetEditTextObjectPool(pPool);
2393 pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool()));
2394 pOutl->EnableUndo(false);
2395 pOutl->SetUpdateMode( false );
2398 OutlinerMode nOutlMode = pOutl->GetMode();
2399 Size aPaperSize = pOutl->GetPaperSize();
2400 bool bUpdateMode = pOutl->GetUpdateMode();
2401 pOutl->SetUpdateMode(false);
2402 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2404 // Always set the object's StyleSheet at the Outliner to
2405 // use the current objects StyleSheet. Thus it's the same as in
2406 // SetText(...).
2407 // Moved this implementation from where SetObjText(...) was called
2408 // to inside this method to work even when outliner is fetched here.
2409 pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
2411 OUString aString;
2413 switch( eObjKind )
2415 case PresObjKind::Outline:
2417 pOutl->Init( OutlinerMode::OutlineObject );
2419 aString += "\t" + rString;
2421 if (mbMaster)
2423 pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
2424 aString += "\n\t\t" +
2425 SdResId(STR_PRESOBJ_MPOUTLLAYER2) +
2426 "\n\t\t\t" +
2427 SdResId(STR_PRESOBJ_MPOUTLLAYER3) +
2428 "\n\t\t\t\t" +
2429 SdResId(STR_PRESOBJ_MPOUTLLAYER4) +
2430 "\n\t\t\t\t\t" +
2431 SdResId(STR_PRESOBJ_MPOUTLLAYER5) +
2432 "\n\t\t\t\t\t\t" +
2433 SdResId(STR_PRESOBJ_MPOUTLLAYER6) +
2434 "\n\t\t\t\t\t\t\t" +
2435 SdResId(STR_PRESOBJ_MPOUTLLAYER7);
2439 break;
2441 case PresObjKind::Title:
2443 pOutl->Init( OutlinerMode::TitleObject );
2444 aString += rString;
2446 break;
2448 default:
2450 pOutl->Init( OutlinerMode::TextObject );
2451 aString += rString;
2453 // check if we need to add a text field
2454 std::unique_ptr<SvxFieldData> pData;
2456 switch( eObjKind )
2458 case PresObjKind::Header:
2459 pData.reset(new SvxHeaderField());
2460 break;
2461 case PresObjKind::Footer:
2462 pData .reset(new SvxFooterField());
2463 break;
2464 case PresObjKind::SlideNumber:
2465 pData.reset(new SvxPageField());
2466 break;
2467 case PresObjKind::DateTime:
2468 pData.reset(new SvxDateTimeField());
2469 break;
2470 default:
2471 break;
2474 if( pData )
2476 ESelection e;
2477 SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
2478 pOutl->QuickInsertField(aField,e);
2481 break;
2484 pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
2486 if( !aString.isEmpty() )
2487 pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
2489 pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
2491 if (!pOutliner)
2493 delete pOutl;
2494 pOutl = nullptr;
2496 else
2498 // restore the outliner
2499 pOutl->Init( nOutlMode );
2500 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2501 pOutl->SetUpdateMode( bUpdateMode );
2502 pOutl->SetPaperSize( aPaperSize );
2506 /*************************************************************************
2508 |* Set the name of the layout
2510 \************************************************************************/
2511 void SdPage::SetLayoutName(const OUString& aName)
2513 maLayoutName = aName;
2515 if( mbMaster )
2517 sal_Int32 nPos = maLayoutName.indexOf(SD_LT_SEPARATOR);
2518 if (nPos != -1)
2519 FmFormPage::SetName(maLayoutName.copy(0, nPos));
2523 /*************************************************************************
2525 |* Return the page name and generates it if necessary
2527 \************************************************************************/
2529 const OUString& SdPage::GetName() const
2531 OUString aCreatedPageName( maCreatedPageName );
2532 if (GetRealName().isEmpty())
2534 if ((mePageKind == PageKind::Standard || mePageKind == PageKind::Notes) && !mbMaster)
2536 // default name for handout pages
2537 sal_uInt16 nNum = (GetPageNum() + 1) / 2;
2539 aCreatedPageName = SdResId(STR_PAGE) + " ";
2540 if (static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()).GetDocumentType() == DocumentType::Draw )
2541 aCreatedPageName = SdResId(STR_PAGE_NAME) + " ";
2543 if( getSdrModelFromSdrPage().GetPageNumType() == css::style::NumberingType::NUMBER_NONE )
2545 // if the document has number none as a formatting
2546 // for page numbers we still default to arabic numbering
2547 // to keep the default page names unique
2548 aCreatedPageName += OUString::number( static_cast<sal_Int32>(nNum) );
2550 else
2552 aCreatedPageName += static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).CreatePageNumValue(nNum);
2555 else
2557 /******************************************************************
2558 * default name for note pages
2559 ******************************************************************/
2560 aCreatedPageName = SdResId(STR_LAYOUT_DEFAULT_NAME);
2563 else
2565 aCreatedPageName = GetRealName();
2568 if (mePageKind == PageKind::Notes)
2570 aCreatedPageName += " " + SdResId(STR_NOTES);
2572 else if (mePageKind == PageKind::Handout && mbMaster)
2574 aCreatedPageName += " (" + SdResId(STR_HANDOUT) + ")";
2577 const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
2578 return maCreatedPageName;
2581 void SdPage::SetOrientation( Orientation /*eOrient*/)
2583 // Do nothing
2586 Orientation SdPage::GetOrientation() const
2588 Size aSize = GetSize();
2589 if ( aSize.getWidth() > aSize.getHeight() )
2591 return Orientation::Landscape;
2593 else
2595 return Orientation::Portrait;
2599 /*************************************************************************
2601 |* returns the default text of a PresObjektes
2603 \************************************************************************/
2605 OUString SdPage::GetPresObjText(PresObjKind eObjKind) const
2607 OUString aString;
2609 #if defined(IOS) || defined(ANDROID)
2610 bool isMobileDevice = true;
2611 #else
2612 bool isMobileDevice = false;
2613 if (const SfxViewShell* pCurrentViewShell = SfxViewShell::Current())
2614 isMobileDevice = pCurrentViewShell->isLOKMobilePhone() || pCurrentViewShell->isLOKTablet();
2615 #endif
2617 if (eObjKind == PresObjKind::Title)
2619 if (mbMaster)
2621 if (mePageKind != PageKind::Notes)
2623 if (isMobileDevice)
2624 aString = SdResId(STR_PRESOBJ_MPTITLE_MOBILE);
2625 else
2626 aString = SdResId(STR_PRESOBJ_MPTITLE);
2628 else
2630 if (isMobileDevice)
2631 aString = SdResId(STR_PRESOBJ_MPNOTESTITLE_MOBILE);
2632 else
2633 aString = SdResId(STR_PRESOBJ_MPNOTESTITLE);
2636 else if (isMobileDevice)
2637 aString = SdResId(STR_PRESOBJ_TITLE_MOBILE);
2638 else
2639 aString = SdResId(STR_PRESOBJ_TITLE);
2641 else if (eObjKind == PresObjKind::Outline)
2643 if (mbMaster)
2645 if (isMobileDevice)
2646 aString = SdResId(STR_PRESOBJ_MPOUTLINE_MOBILE);
2647 else
2648 aString = SdResId(STR_PRESOBJ_MPOUTLINE);
2650 else if (isMobileDevice)
2651 aString = SdResId(STR_PRESOBJ_OUTLINE_MOBILE);
2652 else
2653 aString = SdResId(STR_PRESOBJ_OUTLINE);
2655 else if (eObjKind == PresObjKind::Notes)
2657 if (mbMaster)
2659 if (isMobileDevice)
2660 aString = SdResId(STR_PRESOBJ_MPNOTESTEXT_MOBILE);
2661 else
2662 aString = SdResId(STR_PRESOBJ_MPNOTESTEXT);
2664 else if (isMobileDevice)
2665 aString = SdResId(STR_PRESOBJ_NOTESTEXT_MOBILE);
2666 else
2667 aString = SdResId(STR_PRESOBJ_NOTESTEXT);
2669 else if (eObjKind == PresObjKind::Text)
2671 if (isMobileDevice)
2672 aString = SdResId(STR_PRESOBJ_TEXT_MOBILE);
2673 else
2674 aString = SdResId(STR_PRESOBJ_TEXT);
2676 else if (eObjKind == PresObjKind::Graphic)
2678 aString = SdResId( STR_PRESOBJ_GRAPHIC );
2680 else if (eObjKind == PresObjKind::Object)
2682 aString = SdResId( STR_PRESOBJ_OBJECT );
2684 else if (eObjKind == PresObjKind::Chart)
2686 aString = SdResId( STR_PRESOBJ_CHART );
2688 else if (eObjKind == PresObjKind::OrgChart)
2690 aString = SdResId( STR_PRESOBJ_ORGCHART );
2692 else if (eObjKind == PresObjKind::Calc)
2694 aString = SdResId( STR_PRESOBJ_TABLE );
2697 return aString;
2700 uno::Reference< uno::XInterface > SdPage::createUnoPage()
2702 return createUnoPageImpl( this );
2705 /** returns the SdPage implementation for the given XDrawPage or 0 if not available */
2706 SdPage* SdPage::getImplementation( const css::uno::Reference< css::drawing::XDrawPage >& xPage )
2710 auto pUnoPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>(xPage);
2711 if( pUnoPage )
2712 return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
2714 catch( css::uno::Exception& )
2716 OSL_FAIL("sd::SdPage::getImplementation(), exception caught!" );
2719 return nullptr;
2722 sal_Int64 SdPage::GetHashCode() const
2724 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
2727 void SdPage::SetName (const OUString& rName)
2729 OUString aOldName( GetName() );
2730 FmFormPage::SetName (rName);
2731 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).UpdatePageRelativeURLs(aOldName, rName);
2732 ActionChanged();
2735 const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
2737 if( mePageKind == PageKind::Handout && !mbMaster )
2739 return static_cast<SdPage&>(TRG_GetMasterPage()).maHeaderFooterSettings;
2741 else
2743 return maHeaderFooterSettings;
2747 void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings )
2749 if( mePageKind == PageKind::Handout && !mbMaster )
2751 static_cast<SdPage&>(TRG_GetMasterPage()).maHeaderFooterSettings = rNewSettings;
2753 else
2755 maHeaderFooterSettings = rNewSettings;
2758 SetChanged();
2760 if(!TRG_HasMasterPage())
2761 return;
2763 TRG_GetMasterPageDescriptorViewContact().ActionChanged();
2765 // #i119056# For HeaderFooterSettings SdrObjects are used, but the properties
2766 // used are not part of their model data, but kept in SD. This data is applied
2767 // using a 'backdoor' on primitive creation. Thus, the normal mechanism to detect
2768 // object changes does not work here. It is necessary to trigger updates here
2769 // directly. BroadcastObjectChange used for PagePreview invalidations,
2770 // flushViewObjectContacts used to invalidate and flush all visualizations in
2771 // edit views.
2772 SdPage* pMasterPage = dynamic_cast< SdPage* >(&TRG_GetMasterPage());
2774 if(!pMasterPage)
2775 return;
2777 SdrObject* pCandidate = pMasterPage->GetPresObj( PresObjKind::Header );
2779 if(pCandidate)
2781 pCandidate->BroadcastObjectChange();
2782 pCandidate->GetViewContact().flushViewObjectContacts();
2785 pCandidate = pMasterPage->GetPresObj( PresObjKind::DateTime );
2787 if(pCandidate)
2789 pCandidate->BroadcastObjectChange();
2790 pCandidate->GetViewContact().flushViewObjectContacts();
2793 pCandidate = pMasterPage->GetPresObj( PresObjKind::Footer );
2795 if(pCandidate)
2797 pCandidate->BroadcastObjectChange();
2798 pCandidate->GetViewContact().flushViewObjectContacts();
2801 pCandidate = pMasterPage->GetPresObj( PresObjKind::SlideNumber );
2803 if(pCandidate)
2805 pCandidate->BroadcastObjectChange();
2806 pCandidate->GetViewContact().flushViewObjectContacts();
2810 bool SdPage::checkVisibility(
2811 const sdr::contact::ViewObjectContact& rOriginal,
2812 const sdr::contact::DisplayInfo& rDisplayInfo,
2813 bool bEdit )
2815 if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
2816 return false;
2818 SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2819 if( pObj == nullptr )
2820 return false;
2822 const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
2823 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
2824 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
2825 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
2827 // empty presentation objects only visible during edit mode
2828 if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
2830 if( (pObj->GetObjInventor() != SdrInventor::Default) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
2831 return false;
2834 if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) )
2836 const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->getSdrPageFromSdrObject());
2838 if( pCheckPage )
2840 PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
2842 if((eKind == PresObjKind::Footer) || (eKind == PresObjKind::Header) || (eKind == PresObjKind::DateTime) || (eKind == PresObjKind::SlideNumber) )
2844 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
2846 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PageKind::Handout && bIsPrinting ) )
2848 // use the page that is currently processed
2849 const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
2851 if( pVisualizedSdPage )
2853 // if we are not on a masterpage, see if we have to draw this header&footer object at all
2854 const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
2856 switch( eKind )
2858 case PresObjKind::Footer:
2859 return rSettings.mbFooterVisible;
2860 case PresObjKind::Header:
2861 return rSettings.mbHeaderVisible;
2862 case PresObjKind::DateTime:
2863 return rSettings.mbDateTimeVisible;
2864 case PresObjKind::SlideNumber:
2865 return rSettings.mbSlideNumberVisible;
2866 default:
2867 break;
2871 } // check for placeholders on master
2872 else if( (eKind != PresObjKind::NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) )
2874 // presentation objects on master slide are always invisible if slide is shown.
2875 return false;
2880 // i63977, do not print SdrpageObjs from master pages
2881 if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) )
2883 if( pObj->getSdrPageFromSdrObject() && pObj->getSdrPageFromSdrObject()->IsMasterPage() )
2884 return false;
2887 return true;
2890 bool SdPage::RestoreDefaultText( SdrObject* pObj )
2892 bool bRet = false;
2894 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
2896 if( pTextObj )
2898 PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
2900 if (ePresObjKind == PresObjKind::Title ||
2901 ePresObjKind == PresObjKind::Outline ||
2902 ePresObjKind == PresObjKind::Notes ||
2903 ePresObjKind == PresObjKind::Text)
2905 OUString aString( GetPresObjText(ePresObjKind) );
2907 if (!aString.isEmpty())
2909 bool bVertical = false;
2910 OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
2911 if( pOldPara )
2912 bVertical = pOldPara->IsVertical(); // is old para object vertical?
2914 SetObjText( pTextObj, nullptr, ePresObjKind, aString );
2916 if( pOldPara )
2918 // Here, only the vertical flag for the
2919 // OutlinerParaObjects needs to be changed. The
2920 // AutoGrowWidth/Height items still exist in the
2921 // not changed object.
2922 if(pTextObj->GetOutlinerParaObject()
2923 && pTextObj->GetOutlinerParaObject()->IsVertical() != bVertical)
2925 ::tools::Rectangle aObjectRect = pTextObj->GetSnapRect();
2926 pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
2927 pTextObj->SetSnapRect(aObjectRect);
2931 pTextObj->SetTextEditOutliner( nullptr ); // to make stylesheet settings work
2932 pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), true );
2933 pTextObj->SetEmptyPresObj(true);
2934 bRet = true;
2938 return bRet;
2941 void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< ::tools::Rectangle >& rAreas )
2943 SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PageKind::Handout );
2945 static const sal_uInt16 aOffsets[5][9] =
2947 { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
2948 { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
2949 { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
2950 { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
2951 { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
2954 const sal_uInt16* pOffsets = aOffsets[0];
2956 Size aArea = rHandoutMaster.GetSize();
2957 const bool bLandscape = aArea.Width() > aArea.Height();
2959 if( eLayout == AUTOLAYOUT_NONE )
2961 // use layout from handout master
2962 SdrObjListIter aShapeIter(&rHandoutMaster);
2964 std::vector< ::tools::Rectangle > vSlidesAreas;
2965 while ( aShapeIter.IsMore() )
2967 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>( aShapeIter.Next() );
2968 // get slide rectangles
2969 if (pPageObj)
2970 vSlidesAreas.push_back( pPageObj->GetCurrentBoundRect() );
2973 if ( !bHorizontal || vSlidesAreas.size() < 4 )
2974 { // top to bottom, then right
2975 rAreas.swap( vSlidesAreas );
2977 else
2978 { // left to right, then down
2979 switch ( vSlidesAreas.size() )
2981 case 4:
2982 pOffsets = aOffsets[2];
2983 break;
2985 default:
2986 [[fallthrough]];
2987 case 6:
2988 pOffsets = aOffsets[ bLandscape ? 3 : 1 ];
2989 break;
2991 case 9:
2992 pOffsets = aOffsets[4];
2993 break;
2996 rAreas.resize( static_cast<size_t>(vSlidesAreas.size()) );
2998 for( const ::tools::Rectangle& rRect : vSlidesAreas )
3000 rAreas[*pOffsets++] = rRect;
3004 else
3006 const ::tools::Long nGapW = 1000; // gap is 1cm
3007 const ::tools::Long nGapH = 1000;
3009 ::tools::Long nLeftBorder = rHandoutMaster.GetLeftBorder();
3010 ::tools::Long nRightBorder = rHandoutMaster.GetRightBorder();
3011 ::tools::Long nTopBorder = rHandoutMaster.GetUpperBorder();
3012 ::tools::Long nBottomBorder = rHandoutMaster.GetLowerBorder();
3014 const ::tools::Long nHeaderFooterHeight = static_cast< ::tools::Long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05 );
3016 nTopBorder += nHeaderFooterHeight;
3017 nBottomBorder += nHeaderFooterHeight;
3019 ::tools::Long nX = nGapW + nLeftBorder;
3020 ::tools::Long nY = nGapH + nTopBorder;
3022 aArea.AdjustWidth( -(nGapW * 2 + nLeftBorder + nRightBorder) );
3023 aArea.AdjustHeight( -(nGapH * 2 + nTopBorder + nBottomBorder) );
3025 sal_uInt16 nColCnt = 0, nRowCnt = 0;
3026 switch ( eLayout )
3028 case AUTOLAYOUT_HANDOUT1:
3029 nColCnt = 1; nRowCnt = 1;
3030 break;
3032 case AUTOLAYOUT_HANDOUT2:
3033 if( bLandscape )
3035 nColCnt = 2; nRowCnt = 1;
3037 else
3039 nColCnt = 1; nRowCnt = 2;
3041 break;
3043 case AUTOLAYOUT_HANDOUT3:
3044 if( bLandscape )
3046 nColCnt = 3; nRowCnt = 2;
3048 else
3050 nColCnt = 2; nRowCnt = 3;
3052 pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
3053 break;
3055 case AUTOLAYOUT_HANDOUT4:
3056 nColCnt = 2; nRowCnt = 2;
3057 pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
3058 break;
3060 case AUTOLAYOUT_HANDOUT6:
3061 if( bLandscape )
3063 nColCnt = 3; nRowCnt = 2;
3065 else
3067 nColCnt = 2; nRowCnt = 3;
3069 if( !bHorizontal )
3070 pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
3071 break;
3073 default:
3074 case AUTOLAYOUT_HANDOUT9:
3075 nColCnt = 3; nRowCnt = 3;
3077 if( !bHorizontal )
3078 pOffsets = aOffsets[4];
3079 break;
3082 rAreas.resize(static_cast<size_t>(nColCnt) * nRowCnt);
3084 Size aPartArea, aSize;
3085 aPartArea.setWidth( (aArea.Width() - ((nColCnt-1) * nGapW) ) / nColCnt );
3086 aPartArea.setHeight( (aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt );
3088 SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PageKind::Standard);
3089 if (pFirstPage && pFirstPage->GetWidth() && pFirstPage->GetHeight())
3091 // scale actual size into handout rect
3092 double fScale = static_cast<double>(aPartArea.Width()) / static_cast<double>(pFirstPage->GetWidth());
3094 aSize.setHeight( static_cast<::tools::Long>(fScale * pFirstPage->GetHeight() ) );
3095 if( aSize.Height() > aPartArea.Height() )
3097 fScale = static_cast<double>(aPartArea.Height()) / static_cast<double>(pFirstPage->GetHeight());
3098 aSize.setHeight( aPartArea.Height() );
3099 aSize.setWidth( static_cast<::tools::Long>(fScale * pFirstPage->GetWidth()) );
3101 else
3103 aSize.setWidth( aPartArea.Width() );
3106 nX += (aPartArea.Width() - aSize.Width()) / 2;
3107 nY += (aPartArea.Height()- aSize.Height())/ 2;
3109 else
3111 aSize = aPartArea;
3114 Point aPos( nX, nY );
3116 const bool bRTL = rModel.GetDefaultWritingMode() == css::text::WritingMode_RL_TB;
3118 const ::tools::Long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
3119 const ::tools::Long nOffsetY = aPartArea.Height() + nGapH;
3120 const ::tools::Long nStartX = bRTL ? nOffsetX*(1 - nColCnt) + nX : nX;
3122 for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
3124 aPos.setX( nStartX );
3125 for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
3127 rAreas[*pOffsets++] = ::tools::Rectangle(aPos, aSize);
3128 aPos.AdjustX(nOffsetX );
3131 aPos.AdjustY(nOffsetY );
3136 void SdPage::SetPrecious (const bool bIsPrecious)
3138 mbIsPrecious = bIsPrecious;
3141 HeaderFooterSettings::HeaderFooterSettings()
3143 mbHeaderVisible = true;
3144 mbFooterVisible = true;
3145 mbSlideNumberVisible = false;
3146 mbDateTimeVisible = true;
3147 mbDateTimeIsFixed = true;
3148 meDateFormat = SvxDateFormat::A;
3149 meTimeFormat = SvxTimeFormat::AppDefault;
3152 bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
3154 return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
3155 (maHeaderText == rSettings.maHeaderText) &&
3156 (mbFooterVisible == rSettings.mbFooterVisible) &&
3157 (maFooterText == rSettings.maFooterText) &&
3158 (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
3159 (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
3160 (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
3161 (meDateFormat == rSettings.meDateFormat) &&
3162 (meTimeFormat == rSettings.meTimeFormat) &&
3163 (maDateTimeText == rSettings.maDateTimeText);
3166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */