LibreOffice Module sd (master) 1
sdpage.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <algorithm>
21#include <array>
22
25
26#include <sfx2/viewsh.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>
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 <editeng/pbinitem.hxx>
41#include <svx/svdundo.hxx>
42#include <svl/hint.hxx>
44#include <editeng/editobj.hxx>
45#include <svx/unopage.hxx>
46#include <editeng/flditem.hxx>
48#include <svx/svditer.hxx>
49#include <svx/svdlayer.hxx>
50#include <svx/sdtmfitm.hxx>
51#include <svx/sdtagitm.hxx>
52#include <svx/sdtcfitm.hxx>
53#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>
67#include <xmloff/autolayout.hxx>
68
69#include <Outliner.hxx>
70#include <app.hrc>
71#include <createunopageimpl.hxx>
72#include <drawdoc.hxx>
73#include <sdmod.hxx>
74#include <sdpage.hxx>
75#include <sdresid.hxx>
76#include <stlsheet.hxx>
77#include <strings.hrc>
78#include <strings.hxx>
79#include <bitmaps.hlst>
80#include <glob.hxx>
81#include <anminfo.hxx>
82#include <undo/undomanager.hxx>
83#include <undo/undoobjects.hxx>
87#include <svx/unoapi.hxx>
88#include <unokywds.hxx>
89
90using namespace ::sd;
91using namespace ::com::sun::star;
92using namespace ::com::sun::star::uno;
93using namespace com::sun::star::xml::dom;
94using ::com::sun::star::uno::Reference;
95
96
97sal_uInt16 SdPage::mnLastPageId = 1;
98
99/*************************************************************************
100|*
101|* Ctor
102|*
103\************************************************************************/
104
105SdPage::SdPage(SdDrawDocument& rNewDoc, bool bMasterPage)
106: FmFormPage(rNewDoc, bMasterPage)
108, mePageKind(PageKind::Standard)
109, meAutoLayout(AUTOLAYOUT_NONE)
110, mbSelected(false)
111, mePresChange(PresChange::Manual)
112, mfTime(1.0)
113, mbSoundOn(false)
114, mbExcluded(false)
115, mbLoopSound(false)
116, mbStopSound(false)
117, mbScaleObjects(true)
118, meCharSet(osl_getThreadTextEncoding())
119, mnPaperBin(PAPERBIN_PRINTER_SETTINGS)
120, mpPageLink(nullptr)
122, mnTransitionSubtype(0)
123, mbTransitionDirection(true)
125, mfTransitionDuration(2.0)
126, mbIsPrecious(true)
127, mnPageId(mnLastPageId++)
128{
129 // The name of the layout of the page is used by SVDRAW to determine the
130 // presentation template of the outline objects. Therefore, it already
131 // contains the designator for the outline (STR_LAYOUT_OUTLINE).
132 maLayoutName = SdResId(STR_LAYOUT_DEFAULT_NAME)+ SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE;
133
134 // Stuff that former SetModel did also:
135 ConnectLink();
136}
137
138namespace
139{
140 void clearChildNodes(css::uno::Reference<css::animations::XAnimationNode> const & rAnimationNode)
141 {
142 css::uno::Reference<css::container::XEnumerationAccess > xEnumerationAccess(rAnimationNode, UNO_QUERY);
143 if (!xEnumerationAccess.is())
144 return;
145 css::uno::Reference<css::container::XEnumeration> xEnumeration = xEnumerationAccess->createEnumeration();
146 if (!xEnumeration.is())
147 return;
148 while (xEnumeration->hasMoreElements())
149 {
150 css::uno::Reference<css::animations::XAnimationNode> xChildNode(xEnumeration->nextElement(), UNO_QUERY);
151 if (!xChildNode.is())
152 continue;
153 clearChildNodes(xChildNode);
154 css::uno::Reference<css::animations::XTimeContainer> xAnimationNode(rAnimationNode, UNO_QUERY);
155 if (!xAnimationNode.is())
156 {
157 SAL_WARN("sd.core", "can't remove node child, possible leak");
158 continue;
159 }
160 xAnimationNode->removeChild(xChildNode);
161 }
162 }
163}
164
165/*************************************************************************
166|*
167|* Dtor
168|*
169\************************************************************************/
170
172{
174
176
177 clearChildNodes(mxAnimationNode);
178
179 // disconnect the UserCall link, so we don't get calls
180 // back into this dying object when the child objects die
181 SdrObjListIter aIter( this, SdrIterMode::DeepWithGroups );
182 while( aIter.IsMore() )
183 {
184 SdrObject* pChild = aIter.Next();
185 if( pChild->GetUserCall() == this )
186 pChild->SetUserCall(nullptr);
187 }
188}
189
190namespace {
191
192struct OrdNumSorter
193{
194 bool operator()( SdrObject const * p1, SdrObject const * p2 )
195 {
196 return p1->GetOrdNum() < p2->GetOrdNum();
197 }
198};
199
200}
201
203SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ )
204{
205 // first sort all matching shapes with z-order
206 std::vector< SdrObject* > aMatches;
207
208 SdrObject* pObj = nullptr;
210
211 while( (pObj = maPresentationShapeList.getNextShape()) )
212 {
214 if( pInfo )
215 {
216 bool bFound = false;
217 if( pInfo->mePresObjKind == eObjKind )
218 {
219 bFound = true;
220 }
221 else if( bFuzzySearch && (eObjKind == PresObjKind::Outline) )
222 {
223 switch( pInfo->mePresObjKind )
224 {
232 bFound = true;
233 break;
234 default:
235 break;
236 }
237 }
238 if( bFound )
239 {
240 aMatches.push_back( pObj );
241 }
242 }
243 }
244
245 if( nIndex > 0 )
246 nIndex--;
247
248 if( (nIndex >= 0) && ( aMatches.size() > o3tl::make_unsigned(nIndex)) )
249 {
250 if( aMatches.size() > 1 )
251 std::nth_element( aMatches.begin(), aMatches.begin() + nIndex, aMatches.end(),
252 OrdNumSorter() );
253 return aMatches[nIndex];
254 }
255
256 return nullptr;
257}
258
261{
262 if(!mbMaster)
263 return;
264
265 // no hard attributes on MasterPage attributes
268
269 if(pSheetForPresObj)
270 {
271 // set StyleSheet for background fill attributes
272 getSdrPageProperties().SetStyleSheet(pSheetForPresObj);
273 }
274 else
275 {
276 // no style found, assert and set at least drawing::FillStyle_NONE
277 OSL_FAIL("No Style for MasterPageBackground fill found (!)");
278 getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE));
279 }
280}
281
284SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect )
285{
286 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
287 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
288
290
291 bool bForceText = false; // forces the shape text to be set even if it's empty
292 bool bEmptyPresObj = true;
293
294 switch( eObjKind )
295 {
297 {
298 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::TitleText);
299
300 if (mbMaster)
301 {
302 pSdrObj->SetNotVisibleAsMaster(true);
303 }
304 }
305 break;
306
308 {
309 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::OutlineText);
310
311 if (mbMaster)
312 {
313 pSdrObj->SetNotVisibleAsMaster(true);
314 }
315 }
316 break;
317
319 {
320 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::Text);
321
322 if (mbMaster)
323 {
324 pSdrObj->SetNotVisibleAsMaster(true);
325 }
326 }
327 break;
328
330 {
331 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::Text);
332 }
333 break;
334
336 {
337 BitmapEx aBmpEx(BMP_PRESOBJ_GRAPHIC);
338 Graphic aGraphic( aBmpEx );
340 aOutDev.Push();
341
342 aOutDev.SetMapMode( aGraphic.GetPrefMapMode() );
343 Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() );
344 aOutDev.SetMapMode(MapMode(MapUnit::Map100thMM));
345
346 Size aSize = aOutDev.PixelToLogic(aSizePix);
347 Point aPnt (0, 0);
348 ::tools::Rectangle aRect (aPnt, aSize);
349 pSdrObj = new SdrGrafObj(getSdrModelFromSdrPage(), aGraphic, aRect);
350 aOutDev.Pop();
351 }
352 break;
353
356 {
357 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
358 BitmapEx aBmpEx(BMP_PRESOBJ_OBJECT);
359 Graphic aGraphic( aBmpEx );
360 static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic);
361 }
362 break;
363
365 {
366 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
367 static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarChart" );
368 BitmapEx aBmpEx(BMP_PRESOBJ_CHART);
369 Graphic aGraphic( aBmpEx );
370 static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic);
371 }
372 break;
373
375 {
376 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
377 static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarOrg" );
378 BitmapEx aBmpEx(BMP_PRESOBJ_ORGCHART);
379 Graphic aGraphic( aBmpEx );
380 static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic);
381 }
382 break;
383
386 {
387 pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
388 static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarCalc" );
389 BitmapEx aBmpEx(BMP_PRESOBJ_TABLE);
390 Graphic aGraphic( aBmpEx );
391 static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic);
392 }
393 break;
394
396 {
397 // Save the first standard page at SdrPageObj
398 // #i105146# We want no content to be displayed for PageKind::Handout,
399 // so just never set a page as content
400 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), nullptr);
401 }
402 break;
403
405 {
406 // Save note pages at SdrPageObj
407 sal_uInt16 nDestPageNum(GetPageNum());
408
409 if(nDestPageNum)
410 {
411 // decrement only when != 0, else we get a 0xffff
412 nDestPageNum -= 1;
413 }
414
415 if (nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
416 {
417 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), getSdrModelFromSdrPage().GetPage(nDestPageNum));
418 }
419 else
420 {
421 pSdrObj = new SdrPageObj(getSdrModelFromSdrPage());
422 }
423
424 pSdrObj->SetResizeProtect(true);
425 }
426 break;
427
432 {
433 pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::Text);
434 bEmptyPresObj = false;
435 bForceText = true;
436 }
437 break;
438 default:
439 break;
440 }
441
442 if (pSdrObj)
443 {
444 pSdrObj->SetEmptyPresObj(bEmptyPresObj);
445 pSdrObj->SetLogicRect(rRect);
446
447 InsertObject(pSdrObj.get());
448
449 if ( auto pTextObj = DynCastSdrTextObj( pSdrObj.get() ) )
450 {
451 // Tell the object EARLY that it is vertical to have the
452 // defaults for AutoGrowWidth/Height reversed
453 if(bVertical)
454 pTextObj->SetVerticalWriting(true);
455
456 SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
457 if( bVertical )
458 aTempAttr.Put( makeSdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
459 else
460 aTempAttr.Put( makeSdrTextMinFrameHeightItem( rRect.GetSize().Height() ) );
461
462 if (mbMaster)
463 {
464 // The size of presentation objects on the master page have to
465 // be freely selectable by the user.
466
467 // potential problem: This action was still NOT
468 // adapted for vertical text. This sure needs to be done.
469 if(bVertical)
470 aTempAttr.Put(makeSdrTextAutoGrowWidthItem(false));
471 else
472 aTempAttr.Put(makeSdrTextAutoGrowHeightItem(false));
473 }
474
475 // check if we need another vertical adjustment than the default
477
478 if( (eObjKind == PresObjKind::Footer) && (mePageKind != PageKind::Standard) )
479 {
481 }
482 else if( (eObjKind == PresObjKind::SlideNumber) && (mePageKind != PageKind::Standard) )
483 {
485 }
486
487 if( eV != SDRTEXTVERTADJUST_TOP )
488 aTempAttr.Put(SdrTextVertAdjustItem(eV));
489
490 pSdrObj->SetMergedItemSet(aTempAttr);
491
492 pSdrObj->SetLogicRect(rRect);
493 }
494
495 OUString aString = GetPresObjText(eObjKind);
496 if(!aString.isEmpty() || bForceText)
497 if (auto pTextObj = DynCastSdrTextObj( pSdrObj.get() ) )
498 {
499 SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
500
501 OutlinerMode nOutlMode = pOutliner->GetOutlinerMode();
502 pOutliner->Init( OutlinerMode::TextObject );
503 pOutliner->SetStyleSheet( 0, nullptr );
504 pOutliner->SetVertical( bVertical );
505
506 SetObjText( pTextObj, pOutliner, eObjKind, aString );
507
508 pOutliner->Init( nOutlMode );
509 pOutliner->SetStyleSheet( 0, nullptr );
510 }
511
512 if( (eObjKind == PresObjKind::Header) || (eObjKind == PresObjKind::Footer) || (eObjKind == PresObjKind::SlideNumber) || (eObjKind == PresObjKind::DateTime) )
513 {
514 SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
515 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
516 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
517 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
518
519 SvxAdjust eH = SvxAdjust::Left;
520
521 if( (eObjKind == PresObjKind::DateTime) && (mePageKind != PageKind::Standard ) )
522 {
523 eH = SvxAdjust::Right;
524 }
525 else if( (eObjKind == PresObjKind::Footer) && (mePageKind == PageKind::Standard ) )
526 {
527 eH = SvxAdjust::Center;
528 }
529 else if( eObjKind == PresObjKind::SlideNumber )
530 {
531 eH = SvxAdjust::Right;
532 }
533
534 if( eH != SvxAdjust::Left )
535 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST ));
536
537 pSdrObj->SetMergedItemSet(aTempAttr);
538 }
539
540 if (mbMaster)
541 {
543
544 // background objects of the master page
545 pSdrObj->SetLayer( rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects) );
546 }
547
548 // Subscribe object at the style sheet
549 // Set style only when one was found (as in 5.2)
551 {
552 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind);
553 if(pSheetForPresObj)
554 pSdrObj->SetStyleSheet(pSheetForPresObj, false);
555 }
556
557 if (eObjKind == PresObjKind::Outline)
558 {
559 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
560 {
561 OUString aName( maLayoutName + " " + OUString::number( nLevel ) );
562 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page));
563 DBG_ASSERT(pSheet, "StyleSheet for outline object not found");
564 if (pSheet)
565 pSdrObj->StartListening(*pSheet, DuplicateHandling::Allow);
566 }
567 }
568
569 if ( eObjKind == PresObjKind::Object ||
570 eObjKind == PresObjKind::Chart ||
571 eObjKind == PresObjKind::OrgChart ||
572 eObjKind == PresObjKind::Calc ||
573 eObjKind == PresObjKind::Graphic )
574 {
575 SfxItemSet aSet( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
576 aSet.Put( makeSdrTextContourFrameItem( true ) );
577 aSet.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
578
579 pSdrObj->SetMergedItemSet(aSet);
580 }
581
582 if( bUndo )
583 {
584 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
585
586 pUndoManager->AddUndoAction( std::make_unique<UndoObjectPresentationKind>( *pSdrObj ) );
587 pUndoManager->AddUndoAction( std::make_unique<UndoObjectUserCall>(*pSdrObj) );
588 }
589
590 InsertPresObj(pSdrObj.get(), eObjKind);
591 pSdrObj->SetUserCall(this);
592
593 pSdrObj->RecalcBoundRect();
594 }
595
596 return pSdrObj.get();
597}
598
599/*************************************************************************
600|*
601|* Creates presentation objects on the master page.
602|* All presentation objects get a UserCall to the page.
603|*
604\************************************************************************/
605
607{
608 OUString aName(GetLayoutName());
609 OUString aSep( SD_LT_SEPARATOR );
610 sal_Int32 nPos = aName.indexOf(aSep);
611
612 if (nPos != -1)
613 {
614 nPos = nPos + aSep.getLength();
615 aName = aName.copy(0, nPos);
616 }
617
619
621 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SfxStyleFamily::Page);
622 return static_cast<SfxStyleSheet*>(pResult);
623}
624
626{
627 OUString aName(GetLayoutName());
628 OUString aSep( SD_LT_SEPARATOR );
629 sal_Int32 nPos = aName.indexOf(aSep);
630 if (nPos != -1)
631 {
632 nPos = nPos + aSep.getLength();
633 aName = aName.copy(0, nPos);
634 }
635
636 switch (eObjKind)
637 {
639 {
640 aName = GetLayoutName() + " " + OUString::number( 1 );
641 }
642 break;
643
646 break;
647
650 break;
651
654 break;
655
661 break;
662
663 default:
664 break;
665 }
666
668 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SfxStyleFamily::Page);
669 return static_cast<SfxStyleSheet*>(pResult);
670}
671
674SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
675{
676 OUString aStyleName( GetLayoutName() );
677 const OUString aSep( SD_LT_SEPARATOR );
678 sal_Int32 nIndex = aStyleName.indexOf(aSep);
679 if( nIndex != -1 )
680 aStyleName = aStyleName.copy(0, nIndex + aSep.getLength());
681
682 OUString pNameId;
683 bool bOutline = false;
684 switch( nHelpId )
685 {
686 case HID_PSEUDOSHEET_TITLE: pNameId = STR_LAYOUT_TITLE; break;
687 case HID_PSEUDOSHEET_SUBTITLE: pNameId = STR_LAYOUT_SUBTITLE; break;
688 case HID_PSEUDOSHEET_OUTLINE1:
689 case HID_PSEUDOSHEET_OUTLINE2:
690 case HID_PSEUDOSHEET_OUTLINE3:
691 case HID_PSEUDOSHEET_OUTLINE4:
692 case HID_PSEUDOSHEET_OUTLINE5:
693 case HID_PSEUDOSHEET_OUTLINE6:
694 case HID_PSEUDOSHEET_OUTLINE7:
695 case HID_PSEUDOSHEET_OUTLINE8:
696 case HID_PSEUDOSHEET_OUTLINE9: pNameId = STR_LAYOUT_OUTLINE; bOutline = true; break;
697 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: pNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break;
698 case HID_PSEUDOSHEET_BACKGROUND: pNameId = STR_LAYOUT_BACKGROUND; break;
699 case HID_PSEUDOSHEET_NOTES: pNameId = STR_LAYOUT_NOTES; break;
700
701 default:
702 OSL_FAIL( "SdPage::getPresentationStyle(), illegal argument!" );
703 return nullptr;
704 }
705 aStyleName += pNameId;
706 if (bOutline)
707 {
708 aStyleName += " " +
709 OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ));
710 }
711
713 SfxStyleSheetBase* pResult = pStShPool->Find(aStyleName, SfxStyleFamily::Page);
714 return dynamic_cast<SdStyleSheet*>(pResult);
715}
716
717/*************************************************************************
718|*
719|* The presentation object rObj has changed and is no longer referenced by the
720|* presentation object of the master page.
721|* The UserCall is deleted.
722|*
723\************************************************************************/
724
725void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools::Rectangle& )
726{
728 return;
729
730 switch (eType)
731 {
732 case SdrUserCallType::MoveOnly:
733 case SdrUserCallType::Resize:
734 {
735 if ( getSdrModelFromSdrPage().isLocked())
736 break;
737
738 if (!mbMaster)
739 {
740 if (rObj.GetUserCall())
741 {
742 SdrObject& _rObj = const_cast<SdrObject&>(rObj);
743 SfxUndoManager* pUndoManager
744 = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
745 .GetUndoManager();
746 const bool bUndo
747 = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
748
749 if (bUndo)
750 pUndoManager->AddUndoAction(
751 std::make_unique<UndoObjectUserCall>(_rObj));
752
753 // Object was resized by user and does not listen to its slide anymore
754 _rObj.SetUserCall(nullptr);
755 }
756 }
757 else
758 {
759 // Object of the master page changed, therefore adjust
760 // object on all pages
761 sal_uInt16 nPageCount = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
762 .GetSdPageCount(mePageKind);
763
764 for (sal_uInt16 i = 0; i < nPageCount; i++)
765 {
766 SdPage* pLoopPage = static_cast<SdDrawDocument&>(getSdrModelFromSdrPage())
767 .GetSdPage(i, mePageKind);
768
769 if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
770 {
771 // Page listens to this master page, therefore
772 // adjust AutoLayout
773 pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout());
774 }
775 }
776 }
777 }
778 break;
779
780 case SdrUserCallType::Delete:
781 case SdrUserCallType::Removed:
782 default:
783 break;
784 }
785}
786
787/*************************************************************************
788|*
789|* Creates on a master page: background, title- and layout area
790|*
791\************************************************************************/
792
793void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
794{
795 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
796 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
797
798 SdPage* pMasterPage = this;
799
800 if (!mbMaster)
801 {
802 pMasterPage = static_cast<SdPage*>(&(TRG_GetMasterPage()));
803 }
804
805 if (!pMasterPage)
806 {
807 return;
808 }
809
810 /**************************************************************************
811 * create background, title- and layout area
812 **************************************************************************/
814 {
816 }
817
818 if (static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocumentType() != DocumentType::Impress)
819 return;
820
821 if( mePageKind == PageKind::Handout && bInit )
822 {
823 // handout template
824
825 // delete all available handout presentation objects
827 while( (pObj = pMasterPage->GetPresObj(PresObjKind::Handout)) )
828 {
829 pMasterPage->RemoveObject(pObj->GetOrdNum());
830
831 if( bUndo )
832 {
834 }
835 pObj.clear();
836 }
837
838 std::vector< ::tools::Rectangle > aAreas;
839 CalculateHandoutAreas( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()), pMasterPage->GetAutoLayout(), false, aAreas );
840
841 const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
842 std::vector< ::tools::Rectangle >::iterator iter( aAreas.begin() );
843
844 while( iter != aAreas.end() )
845 {
846 SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PresObjKind::Handout, false, (*iter++)) );
847 // #i105146# We want no content to be displayed for PageKind::Handout,
848 // so just never set a page as content
849 pPageObj->SetReferencedPage(nullptr);
850
851 if( bSkip && iter != aAreas.end() )
852 ++iter;
853 }
854 }
855
857 {
858 SdrObject* pMasterTitle = pMasterPage->GetPresObj( PresObjKind::Title );
859 if( pMasterTitle == nullptr )
861
863 if( pMasterOutline == nullptr )
865 }
866
867 // create header&footer objects
868
869 if( !bCreate )
870 return;
871
873 {
874 SdrObject* pHeader = pMasterPage->GetPresObj( PresObjKind::Header );
875 if( pHeader == nullptr )
877 }
878
879 SdrObject* pDate = pMasterPage->GetPresObj( PresObjKind::DateTime );
880 if( pDate == nullptr )
882
883 SdrObject* pFooter = pMasterPage->GetPresObj( PresObjKind::Footer );
884 if( pFooter == nullptr )
886
887 SdrObject* pNumber = pMasterPage->GetPresObj( PresObjKind::SlideNumber );
888 if( pNumber == nullptr )
890}
891
892namespace {
893
894const o3tl::enumarray<PageKind, char const *> PageKindVector = {
895 "PageKind::Standard", "PageKind::Notes", "PageKind::Handout"
896};
897
898const o3tl::enumarray<PresObjKind, const char*> PresObjKindVector = {
899 "PRESOBJ_NONE", "PRESOBJ_TITLE", "PRESOBJ_OUTLINE",
900 "PRESOBJ_TEXT" ,"PRESOBJ_GRAPHIC" , "PRESOBJ_OBJECT",
901 "PRESOBJ_CHART", "PRESOBJ_ORGCHART", "PRESOBJ_TABLE",
902 "PRESOBJ_PAGE", "PRESOBJ_HANDOUT",
903 "PRESOBJ_NOTES","PRESOBJ_HEADER", "PRESOBJ_FOOTER",
904 "PRESOBJ_DATETIME", "PRESOBJ_SLIDENUMBER", "PRESOBJ_CALC",
905 "PRESOBJ_MEDIA"
906};
907
908void getPresObjProp( const SdPage& rPage, const char* sObjKind, const char* sPageKind, double presObjPropValue[] )
909{
910 bool bNoObjectFound = true; //used to break from outer loop
911
912 const std::vector< Reference<XNode> >& objectInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetObjectVector();
913 for( const Reference<XNode>& objectNode : objectInfo )
914 {
915 if(bNoObjectFound)
916 {
917 Reference<XNamedNodeMap> objectattrlist = objectNode->getAttributes();
918 Reference<XNode> objectattr = objectattrlist->getNamedItem("type");
919 OUString sObjType = objectattr->getNodeValue();
920
921 if (sObjType.equalsAscii(sObjKind))
922 {
923 Reference<XNodeList> objectChildren = objectNode->getChildNodes();
924 const int objSize = objectChildren->getLength();
925
926 for( int j=0; j< objSize; j++)
927 {
928 Reference<XNode> obj = objectChildren->item(j);
929 OUString nodename = obj->getNodeName();
930
931 //check whether child is blank 'text-node' or 'object-prop' node
932 if(nodename == "object-prop")
933 {
934 Reference<XNamedNodeMap> ObjAttributes = obj->getAttributes();
935 Reference<XNode> ObjPageKind = ObjAttributes->getNamedItem("pagekind");
936 OUString sObjPageKind = ObjPageKind->getNodeValue();
937
938 if (sObjPageKind.equalsAscii(sPageKind))
939 {
940 Reference<XNode> ObjSizeHeight = ObjAttributes->getNamedItem("relative-height");
941 OUString sValue = ObjSizeHeight->getNodeValue();
942 presObjPropValue[0] = sValue.toDouble();
943
944 Reference<XNode> ObjSizeWidth = ObjAttributes->getNamedItem("relative-width");
945 sValue = ObjSizeWidth->getNodeValue();
946 presObjPropValue[1] = sValue.toDouble();
947
948 Reference<XNode> ObjPosX = ObjAttributes->getNamedItem("relative-posX");
949 sValue = ObjPosX->getNodeValue();
950 presObjPropValue[2] = sValue.toDouble();
951
952 Reference<XNode> ObjPosY = ObjAttributes->getNamedItem("relative-posY");
953 sValue = ObjPosY->getNodeValue();
954 presObjPropValue[3] = sValue.toDouble();
955
956 bNoObjectFound = false;
957 break;
958 }
959 }
960 }
961 }
962 }
963 else
964 break;
965 }
966}
967
968}
969
971{
972 if( eObjKind == PresObjKind::Title )
973 {
974 ::tools::Rectangle aTitleRect( GetTitleRect() );
975 return CreatePresObj(PresObjKind::Title, false, aTitleRect);
976 }
977 else if( eObjKind == PresObjKind::Outline )
978 {
979 ::tools::Rectangle aLayoutRect( GetLayoutRect() );
980 return CreatePresObj( PresObjKind::Outline, false, aLayoutRect);
981 }
982 else if( eObjKind == PresObjKind::Notes )
983 {
984 ::tools::Rectangle aLayoutRect( GetLayoutRect() );
985 return CreatePresObj( PresObjKind::Notes, false, aLayoutRect);
986 }
987 else if( (eObjKind == PresObjKind::Footer) || (eObjKind == PresObjKind::DateTime) || (eObjKind == PresObjKind::SlideNumber) || (eObjKind == PresObjKind::Header ) )
988 {
989 double propvalue[] = {0,0,0,0};
990 const char* sObjKind = PresObjKindVector[eObjKind];
991 const char* sPageKind = PageKindVector[mePageKind];
992 // create footer objects for standard master page
994 {
995 const ::tools::Long nLftBorder = GetLeftBorder();
996 const ::tools::Long nUppBorder = GetUpperBorder();
997
998 Point aPos ( nLftBorder, nUppBorder );
999 Size aSize ( GetSize() );
1000
1001 aSize.AdjustWidth( -(nLftBorder + GetRightBorder()) );
1002 aSize.AdjustHeight( -(nUppBorder + GetLowerBorder()) );
1003
1004 getPresObjProp( *this, sObjKind, sPageKind, propvalue);
1005 aPos.AdjustX(::tools::Long( aSize.Width() * propvalue[2] ) );
1006 aPos.AdjustY(::tools::Long( aSize.Height() * propvalue[3] ) );
1007 aSize.setWidth( ::tools::Long( aSize.Width() * propvalue[1] ) );
1008 aSize.setHeight( ::tools::Long( aSize.Height() * propvalue[0] ) );
1009
1010 if(eObjKind == PresObjKind::Header )
1011 {
1012 OSL_FAIL( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a master slide" );
1013 return nullptr;
1014 }
1015 else
1016 {
1017 ::tools::Rectangle aRect( aPos, aSize );
1018 return CreatePresObj( eObjKind, false, aRect );
1019 }
1020 }
1021 else
1022 {
1023 // create header&footer objects for handout and notes master
1024 Size aPageSize ( GetSize() );
1025 aPageSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
1026 aPageSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
1027
1028 Point aPosition ( GetLeftBorder(), GetUpperBorder() );
1029
1030 getPresObjProp( *this, sObjKind, sPageKind, propvalue);
1031 int NOTES_HEADER_FOOTER_WIDTH = ::tools::Long(aPageSize.Width() * propvalue[1]);
1032 int NOTES_HEADER_FOOTER_HEIGHT = ::tools::Long(aPageSize.Height() * propvalue[0]);
1033 Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT );
1034 Point aPos ( 0 ,0 );
1035 if( propvalue[2] == 0 )
1036 aPos.setX( aPosition.X() );
1037 else
1038 aPos.setX( aPosition.X() + ::tools::Long( aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH ) );
1039 if( propvalue[3] == 0 )
1040 aPos.setY( aPosition.Y() );
1041 else
1042 aPos.setY( aPosition.Y() + ::tools::Long( aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT ) );
1043
1044 ::tools::Rectangle aRect( aPos, aSize );
1045 return CreatePresObj( eObjKind, false, aRect );
1046 }
1047 }
1048 else
1049 {
1050 OSL_FAIL("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" );
1051 return nullptr;
1052 }
1053}
1054
1056{
1057 SdrObject* pObject = GetPresObj( eObjKind );
1058
1059 if( pObject )
1060 {
1061 SdDrawDocument* pDoc(static_cast< SdDrawDocument* >(&getSdrModelFromSdrPage()));
1062 const bool bUndo = pDoc->IsUndoEnabled();
1063 if( bUndo )
1065 SdrObjList* pOL = pObject->getParentSdrObjListFromSdrObject();
1066 pOL->RemoveObject(pObject->GetOrdNumDirect());
1067 }
1068}
1069
1070/*************************************************************************
1071|*
1072|* return title area
1073|*
1074\************************************************************************/
1075
1077{
1078 ::tools::Rectangle aTitleRect;
1079
1081 {
1082 double propvalue[] = {0,0,0,0};
1083
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];
1092
1094 {
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] ) );
1100 }
1101 else if (mePageKind == PageKind::Notes)
1102 {
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] ) );
1107
1108 // limit height
1109 aTitleSize.setHeight( ::tools::Long( aTitleSize.Height() * propvalue[0] ) );
1110 aTitleSize.setWidth( ::tools::Long( aTitleSize.Width() * propvalue[1] ) );
1111
1112 Size aPartArea = aTitleSize;
1113 Size aSize;
1114 sal_uInt16 nDestPageNum(GetPageNum());
1115 SdrPage* pRefPage = nullptr;
1116
1117 if(nDestPageNum)
1118 {
1119 // only decrement if != 0, else we get 0xffff
1120 nDestPageNum -= 1;
1121 }
1122
1123 if(nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
1124 {
1125 pRefPage = getSdrModelFromSdrPage().GetPage(nDestPageNum);
1126 }
1127
1128 if ( pRefPage )
1129 {
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();
1135
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()) );
1140
1141 aPos.AdjustX((aPartArea.Width() - aSize.Width()) / 2 );
1142 aPos.AdjustY((aPartArea.Height()- aSize.Height())/ 2 );
1143 }
1144
1145 aTitlePos = aPos;
1146 aTitleSize = aSize;
1147 }
1148
1149 aTitleRect.SetPos(aTitlePos);
1150 aTitleRect.SetSize(aTitleSize);
1151 }
1152
1153 return aTitleRect;
1154}
1155
1156/*************************************************************************
1157|*
1158|* return outline area
1159|*
1160\************************************************************************/
1161
1163{
1164 ::tools::Rectangle aLayoutRect;
1165
1167 {
1168 double propvalue[] = {0,0,0,0};
1169
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];
1175
1177 {
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);
1185 }
1186 else if (mePageKind == PageKind::Notes)
1187 {
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);
1195 }
1196 }
1197
1198 return aLayoutRect;
1199}
1200
1201/**************************************************************************
1202|*
1203|* assign an AutoLayout
1204|*
1205\*************************************************************************/
1206
1207const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout
1208const int VERTICAL = 0x8000;
1209
1210static constexpr PresObjKind operator|(PresObjKind e, int x)
1211{
1212 return static_cast<PresObjKind>(static_cast<int>(e) | x);
1213}
1214
1215namespace {
1216
1217struct LayoutDescriptor
1218{
1219 PresObjKind meKind[MAX_PRESOBJS];
1220 bool mbVertical[MAX_PRESOBJS];
1221
1223};
1224
1225}
1226
1227LayoutDescriptor::LayoutDescriptor( PresObjKind k0, PresObjKind k1, PresObjKind k2, PresObjKind k3, PresObjKind k4, PresObjKind k5, PresObjKind k6 )
1228{
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);
1238}
1239
1240static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout )
1241{
1242 static const LayoutDescriptor aLayouts[AUTOLAYOUT_END-AUTOLAYOUT_START] =
1243 {
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
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
1280 LayoutDescriptor( PresObjKind::Title, PresObjKind::Outline, PresObjKind::Outline, // AUTOLAYOUT_TITLE_6CONTENT
1282 };
1283
1284 if( (eLayout < AUTOLAYOUT_START) || (eLayout >= AUTOLAYOUT_END) )
1285 eLayout = AUTOLAYOUT_NONE;
1286
1287 return aLayouts[ eLayout - AUTOLAYOUT_START ];
1288}
1289
1290static OUString enumtoString(AutoLayout aut)
1291{
1292 OUString retstr;
1293 switch (aut)
1294 {
1296 retstr="AUTOLAYOUT_TITLE_CONTENT";
1297 break;
1299 retstr="AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT";
1300 break;
1302 retstr="AUTOLAYOUT_TITLE_CONTENT_2CONTENT";
1303 break;
1305 retstr="AUTOLAYOUT_TITLE_4CONTENT";
1306 break;
1308 retstr="AUTOLAYOUT_ONLY_TEXT";
1309 break;
1311 retstr="AUTOLAYOUT_TITLE_ONLY";
1312 break;
1314 retstr="AUTOLAYOUT_TITLE_6CONTENT";
1315 break;
1316 case AUTOLAYOUT_START:
1317 retstr="AUTOLAYOUT_START";
1318 break;
1320 retstr="AUTOLAYOUT_TITLE_2CONTENT_CONTENT";
1321 break;
1323 retstr="AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT";
1324 break;
1326 retstr="AUTOLAYOUT_TITLE_2CONTENT";
1327 break;
1329 retstr="AUTOLAYOUT_VTITLE_VCONTENT";
1330 break;
1332 retstr="AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT";
1333 break;
1335 retstr="AUTOLAYOUT_TITLE_VCONTENT";
1336 break;
1338 retstr="AUTOLAYOUT_TITLE_2VTEXT";
1339 break;
1340 default:
1341 retstr="unknown";
1342 break;
1343 // case AUTOLAYOUT_TITLE_4SCONTENT: return "AUTOLAYOUT_TITLE_4SCONTENT";
1344 }
1345 return retstr;
1346}
1347
1348static void CalcAutoLayoutRectangles( SdPage const & rPage,::tools::Rectangle* rRectangle ,const OUString& sLayoutType )
1349{
1350 ::tools::Rectangle aTitleRect;
1351 ::tools::Rectangle aLayoutRect;
1352
1353 if( rPage.GetPageKind() != PageKind::Handout )
1354 {
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 );
1359
1360 if( pMasterTitle )
1361 aTitleRect = pMasterTitle->GetLogicRect();
1362
1363 if (aTitleRect.IsEmpty() )
1364 aTitleRect = rPage.GetTitleRect();
1365 if( pMasterSubTitle )
1366 aLayoutRect = pMasterSubTitle->GetLogicRect();
1367 else if( pMasterOutline )
1368 aLayoutRect = pMasterOutline->GetLogicRect();
1369
1370 if (aLayoutRect.IsEmpty() )
1371 aLayoutRect = rPage.GetLayoutRect();
1372 }
1373
1374 rRectangle[0] = aTitleRect;
1375 for( int i = 1; i < MAX_PRESOBJS; i++ )
1376 rRectangle[i] = aLayoutRect;
1377
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};
1382
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();
1387
1388 // get the attribute value of layout (i.e it's type)
1389 OUString sLayoutAttName = layoutAttrList->getNamedItem("type")->getNodeValue();
1390 return sLayoutAttName == sLayoutType;
1391 });
1392 if (aIter == layoutInfo.end())
1393 return;
1394
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++)
1400 {
1401 OUString nodename;
1402 Reference<XNode> presobj = layoutChildren->item(j);
1403 nodename=presobj->getNodeName();
1404
1405 //check whether child is blank 'text-node' or 'presobj' node
1406 if(nodename == "presobj")
1407 {
1408 // TODO: rework sd to permit arbitrary number of presentation objects
1409 assert(count < MAX_PRESOBJS);
1410
1411 Reference<XNamedNodeMap> presObjAttributes = presobj->getAttributes();
1412
1413 Reference<XNode> presObjSizeHeight = presObjAttributes->getNamedItem("relative-height");
1414 OUString sValue = presObjSizeHeight->getNodeValue();
1415 propvalue[0] = sValue.toDouble();
1416
1417 Reference<XNode> presObjSizeWidth = presObjAttributes->getNamedItem("relative-width");
1418 sValue = presObjSizeWidth->getNodeValue();
1419 propvalue[1] = sValue.toDouble();
1420
1421 Reference<XNode> presObjPosX = presObjAttributes->getNamedItem("relative-posX");
1422 sValue = presObjPosX->getNodeValue();
1423 propvalue[2] = sValue.toDouble();
1424
1425 Reference<XNode> presObjPosY = presObjAttributes->getNamedItem("relative-posY");
1426 sValue = presObjPosY->getNodeValue();
1427 propvalue[3] = sValue.toDouble();
1428
1429 if(count == 0)
1430 {
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;
1438 }
1439 else
1440 {
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;
1447 }
1448 }
1449 }
1450}
1451
1452static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::array<SdrObject*, MAX_PRESOBJS>& rShapes, bool bInit, bool bSwitchLayout )
1453{
1454 // init list of indexes for each presentation shape kind
1455 // this is used to find subsequent shapes with the same presentation shape kind
1457 PresObjIndex.fill(1);
1458
1459 bool bMissing = false;
1460
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++)
1463 {
1464 PresObjKind eKind = rDescriptor.meKind[i];
1465 SdrObject* pObj = nullptr;
1466 while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != nullptr )
1467 {
1468 PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
1469
1470 if( !bSwitchLayout || !pObj->IsEmptyPresObj() )
1471 {
1472 rShapes[i] = pObj;
1473 break;
1474 }
1475 }
1476
1477 if( !pObj )
1478 bMissing = true;
1479 }
1480
1481 if( !(bMissing && bInit) )
1482 return;
1483
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++)
1486 {
1487 if( rShapes[i] )
1488 continue;
1489
1490 PresObjKind eKind = rDescriptor.meKind[i];
1491
1492 SdrObject* pObj = nullptr;
1493 bool bFound = false;
1494
1495 const size_t nShapeCount = rPage.GetObjCount();
1496 for(size_t nShapeIndex = 0; nShapeIndex < nShapeCount && !bFound; ++nShapeIndex )
1497 {
1498 pObj = rPage.GetObj(nShapeIndex);
1499
1500 if( pObj->IsEmptyPresObj() )
1501 continue;
1502
1503 if( pObj->GetObjInventor() != SdrInventor::Default )
1504 continue;
1505
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;
1509
1510 bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SfxStyleFamily::Page);
1511 SdrObjKind eSdrObjKind = pObj->GetObjIdentifier();
1512
1513 switch( eKind )
1514 {
1515 case PresObjKind::Title:
1516 bFound = eSdrObjKind == SdrObjKind::TitleText;
1517 break;
1518 case PresObjKind::Table:
1519 bFound = eSdrObjKind == SdrObjKind::Table;
1520 break;
1521 case PresObjKind::Media:
1522 bFound = eSdrObjKind == SdrObjKind::Media;
1523 break;
1525 bFound = (eSdrObjKind == SdrObjKind::OutlineText) ||
1526 ((eSdrObjKind == SdrObjKind::Text) && bPresStyle) ||
1527 (eSdrObjKind == SdrObjKind::Table) || (eSdrObjKind == SdrObjKind::Media) || (eSdrObjKind == SdrObjKind::Graphic) || (eSdrObjKind == SdrObjKind::OLE2);
1528 break;
1530 bFound = eSdrObjKind == SdrObjKind::Graphic;
1531 break;
1533 if( eSdrObjKind == SdrObjKind::OLE2 )
1534 {
1535 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1536 if( pOle2 )
1537 {
1538 if( pOle2->IsEmpty() )
1539 bFound = true;
1540 else
1541 {
1543
1544 if( pPersist )
1545 {
1546 uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
1547 GetEmbeddedObject( pOle2->GetPersistName() );
1548
1549 // TODO CL->KA: Why is this not working anymore?
1550 if( xObject.is() )
1551 {
1552 SvGlobalName aClassId( xObject->getClassID() );
1553
1554 const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
1555 const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
1556 const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
1557
1558 if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId )
1559 {
1560 bFound = true;
1561 }
1562 }
1563 }
1564 }
1565 }
1566 }
1567 break;
1568 case PresObjKind::Chart:
1569 case PresObjKind::Calc:
1570 if( eSdrObjKind == SdrObjKind::OLE2 )
1571 {
1572 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
1573 if( pOle2 )
1574 {
1575 if(
1576 ((eKind == PresObjKind::Chart) &&
1577 ( pOle2->GetProgName() == "StarChart" || pOle2->IsChart() ) )
1578 ||
1579 ((eKind == PresObjKind::Calc) &&
1580 ( pOle2->GetProgName() == "StarCalc" || pOle2->IsCalc() ) ) )
1581 {
1582 bFound = true;
1583 }
1584 }
1585 break;
1586 }
1587 else if( eSdrObjKind == SdrObjKind::Table )
1588 {
1589 bFound = true;
1590 }
1591 break;
1592 case PresObjKind::Page:
1594 bFound = eSdrObjKind == SdrObjKind::Page;
1595 break;
1596 case PresObjKind::Notes:
1597 case PresObjKind::Text:
1598 bFound = (bPresStyle && (eSdrObjKind == SdrObjKind::Text)) || (eSdrObjKind == SdrObjKind::OutlineText);
1599 break;
1600 default:
1601 break;
1602 }
1603 }
1604
1605 if( bFound )
1606 rShapes[i] = pObj;
1607 }
1608}
1609
1610void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
1611{
1613
1614 const bool bSwitchLayout = eLayout != GetAutoLayout();
1615
1616 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
1617 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
1618
1619 meAutoLayout = eLayout;
1620
1621 // if needed, creates and initialises the presentation shapes on this slides master page
1622 CreateTitleAndLayout(bInit, bCreate);
1623
1625 {
1626 // MasterPage or no layout and no presentation shapes available, nothing to do
1627 return;
1628 }
1629
1630 ::tools::Rectangle aRectangle[MAX_PRESOBJS];
1631 const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout );
1632 OUString sLayoutName( enumtoString(meAutoLayout) );
1633 CalcAutoLayoutRectangles( *this, aRectangle, sLayoutName);
1634
1635 o3tl::sorted_vector< SdrObject* > aUsedPresentationObjects;
1636
1637 std::array<SdrObject*, MAX_PRESOBJS > aLayoutShapes;
1638 aLayoutShapes.fill(nullptr);
1639 findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
1640
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++)
1643 {
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
1648 }
1649
1650 // now delete all empty presentation objects that are no longer used by the new layout
1651 if( !bInit )
1652 return;
1653
1655
1657 while( (pObj = maPresentationShapeList.getNextShape()) )
1658 {
1659 if( aUsedPresentationObjects.count(pObj.get()) == 0 )
1660 {
1661
1662 if( pObj->IsEmptyPresObj() )
1663 {
1664 if( bUndo )
1665 pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
1666
1667 RemoveObject( pObj->GetOrdNum() );
1668 pObj.clear();
1669 }
1670/* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */
1671 }
1672 }
1673}
1674
1675/*************************************************************************
1676|*
1677|* insert object
1678|*
1679\************************************************************************/
1680
1681void SdPage::NbcInsertObject(SdrObject* pObj, size_t nPos)
1682{
1684
1685 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).InsertObject(pObj);
1686
1687 SdrLayerID nId = pObj->GetLayer();
1688 if( mbMaster )
1689 {
1690 if( nId == SdrLayerID(0) )
1691 pObj->NbcSetLayer( SdrLayerID(2) ); // wrong layer. corrected to BackgroundObj layer
1692 }
1693 else
1694 {
1695 if( nId == SdrLayerID(2) )
1696 pObj->NbcSetLayer( SdrLayerID(0) ); // wrong layer. corrected to layout layer
1697 }
1698}
1699
1700/*************************************************************************
1701|*
1702|* remove object
1703|*
1704\************************************************************************/
1705
1707{
1708 onRemoveObject(GetObj( nObjNum ));
1709 return FmFormPage::RemoveObject(nObjNum);
1710}
1711
1712/*************************************************************************
1713|*
1714|* remove object without broadcast
1715|*
1716\************************************************************************/
1717
1719{
1720 onRemoveObject(GetObj( nObjNum ));
1721 return FmFormPage::NbcRemoveObject(nObjNum);
1722}
1723
1724// Also override ReplaceObject methods to realize when
1725// objects are removed with this mechanism instead of RemoveObject
1727{
1728 onRemoveObject(GetObj( nObjNum ));
1729 return FmFormPage::ReplaceObject(pNewObj, nObjNum);
1730}
1731
1732// called after a shape is removed or replaced from this slide
1733
1735{
1736 if( pObject )
1737 {
1739
1741
1743 }
1744}
1745
1746void SdPage::SetSize(const Size& aSize)
1747{
1748 Size aOldSize = GetSize();
1749
1750 if (aSize != aOldSize)
1751 {
1752 FmFormPage::SetSize(aSize);
1753 }
1754}
1755
1756void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr)
1757{
1758 if (nLft != GetLeftBorder() || nUpp != GetUpperBorder() ||
1759 nRgt != GetRightBorder() || nLwr != GetLowerBorder() )
1760 {
1761 FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
1762 }
1763}
1764
1765void SdPage::SetLeftBorder(sal_Int32 nBorder)
1766{
1767 if (nBorder != GetLeftBorder() )
1768 {
1770 }
1771}
1772
1773void SdPage::SetRightBorder(sal_Int32 nBorder)
1774{
1775 if (nBorder != GetRightBorder() )
1776 {
1778 }
1779}
1780
1781void SdPage::SetUpperBorder(sal_Int32 nBorder)
1782{
1783 if (nBorder != GetUpperBorder() )
1784 {
1786 }
1787}
1788
1789void SdPage::SetLowerBorder(sal_Int32 nBorder)
1790{
1791 if (nBorder != GetLowerBorder() )
1792 {
1794 }
1795}
1796
1797/*************************************************************************
1798|*
1799|* Adjust all objects to new page size.
1800|*
1801|* bScaleAllObj: all objects are scaled into the new area within the page
1802|* margins. We scale the position and size. For presentation objects on the
1803|* master page, we also scale the font height of the presentation template.
1804|*
1805\************************************************************************/
1806
1807void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rNewBorderRect, bool bScaleAllObj)
1808{
1810
1811 mbScaleObjects = bScaleAllObj;
1812 SdrObject* pObj = nullptr;
1813 Point aRefPnt(0, 0);
1814 Size aNewPageSize(rNewPageSize);
1815 sal_Int32 nLeft = rNewBorderRect.Left();
1816 sal_Int32 nRight = rNewBorderRect.Right();
1817 sal_Int32 nUpper = rNewBorderRect.Top();
1818 sal_Int32 nLower = rNewBorderRect.Bottom();
1819
1820 // negative values are fixed values
1821 // -> use up to date values
1822 if (aNewPageSize.Width() < 0)
1823 {
1824 aNewPageSize.setWidth( GetWidth() );
1825 }
1826 if (aNewPageSize.Height() < 0)
1827 {
1828 aNewPageSize.setHeight( GetHeight() );
1829 }
1830 if (nLeft < 0)
1831 {
1832 nLeft = GetLeftBorder();
1833 }
1834 if (nRight < 0)
1835 {
1836 nRight = GetRightBorder();
1837 }
1838 if (nUpper < 0)
1839 {
1840 nUpper = GetUpperBorder();
1841 }
1842 if (nLower < 0)
1843 {
1844 nLower = GetLowerBorder();
1845 }
1846
1847 Size aBackgroundSize(aNewPageSize);
1848
1849 if (mbScaleObjects)
1850 {
1851 aBackgroundSize.AdjustWidth( -(nLeft + nRight) );
1852 aBackgroundSize.AdjustHeight( -(nUpper + nLower) );
1853 aNewPageSize = aBackgroundSize;
1854 }
1855
1856 ::tools::Long nOldWidth = GetWidth() - GetLeftBorder() - GetRightBorder();
1858
1859 Fraction aFractX(aNewPageSize.Width(), nOldWidth);
1860 Fraction aFractY(aNewPageSize.Height(), nOldHeight);
1861
1862 const size_t nObjCnt = (mbScaleObjects ? GetObjCount() : 0);
1863
1864 for (size_t nObj = 0; nObj < nObjCnt; ++nObj)
1865 {
1866 bool bIsPresObjOnMaster = false;
1867
1868 // all Objects
1869 pObj = GetObj(nObj);
1870
1871 if (mbMaster && IsPresObj(pObj))
1872 {
1873 // There is a presentation object on the master page
1874 bIsPresObjOnMaster = true;
1875 }
1876
1877 if (pObj)
1878 {
1879 // remember aTopLeft as original TopLeft
1880 Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft());
1881
1882 if (!pObj->IsEdgeObj())
1883 {
1884 /**************************************************************
1885 * Scale objects
1886 **************************************************************/
1887 if (mbScaleObjects)
1888 {
1889 // use aTopLeft as original TopLeft
1890 aRefPnt = aTopLeft;
1891 }
1892
1893 pObj->Resize(aRefPnt, aFractX, aFractY);
1894
1895 if (mbScaleObjects)
1896 {
1897 SdrObjKind eObjKind = pObj->GetObjIdentifier();
1898
1899 if (bIsPresObjOnMaster)
1900 {
1901 /**********************************************************
1902 * presentation template: adjust test height
1903 **********************************************************/
1904
1905 if (pObj == GetPresObj(PresObjKind::Title, 0))
1906 {
1908
1909 if (pTitleSheet)
1910 {
1911 SfxItemSet& rSet = pTitleSheet->GetItemSet();
1912
1913 const SvxFontHeightItem& rOldHgt = rSet.Get(EE_CHAR_FONTHEIGHT);
1914 sal_uLong nFontHeight = rOldHgt.GetHeight();
1915 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1916 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1917
1918 if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1919 {
1921 nFontHeight = rOldHgt2.GetHeight();
1922 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1924 }
1925
1926 if( SfxItemState::DEFAULT == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1927 {
1929 nFontHeight = rOldHgt2.GetHeight();
1930 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1932 }
1933
1934 pTitleSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
1935 }
1936 }
1937 else if (pObj == GetPresObj(PresObjKind::Outline, 0))
1938 {
1939 OUString aName(GetLayoutName() + " ");
1940
1941 for (sal_Int32 i=1; i<=9; i++)
1942 {
1943 OUString sLayoutName( aName + OUString::number( i ) );
1944 SfxStyleSheet* pOutlineSheet = static_cast<SfxStyleSheet*>(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetStyleSheetPool()->Find(sLayoutName, SfxStyleFamily::Page));
1945
1946 if (pOutlineSheet)
1947 {
1948 // Calculate new font height
1949 SfxItemSet aTempSet(pOutlineSheet->GetItemSet());
1950
1951 const SvxFontHeightItem& rOldHgt = aTempSet.Get(EE_CHAR_FONTHEIGHT);
1952 sal_uLong nFontHeight = rOldHgt.GetHeight();
1953 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1954 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT));
1955
1956 if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) )
1957 {
1958 const SvxFontHeightItem& rOldHgt2 = aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK);
1959 nFontHeight = rOldHgt2.GetHeight();
1960 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1961 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK));
1962 }
1963
1964 if( SfxItemState::DEFAULT == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) )
1965 {
1966 const SvxFontHeightItem& rOldHgt2 = aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL);
1967 nFontHeight = rOldHgt2.GetHeight();
1968 nFontHeight = ::tools::Long(nFontHeight * static_cast<double>(aFractY));
1969 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL));
1970 }
1971
1972 // adjust bullet
1973 static_cast<SdStyleSheet*>(pOutlineSheet)->AdjustToFontHeight(aTempSet, false);
1974
1975 // Special treatment: reset the INVALIDS to
1976 // NULL pointer (otherwise we have INVALID's
1977 // or pointer to the DefaultItems in the
1978 // template; both would suppress the
1979 // attribute inheritance)
1980 aTempSet.ClearInvalidItems();
1981
1982 // Special treatment: only the valid parts
1983 // of the BulletItems
1984 if (aTempSet.GetItemState(EE_PARA_BULLET) == SfxItemState::DEFAULT)
1985 {
1986 SvxBulletItem aOldBulItem( pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET) );
1987 const SvxBulletItem& rNewBulItem = aTempSet.Get(EE_PARA_BULLET);
1988 aOldBulItem.CopyValidProperties(rNewBulItem);
1989 aTempSet.Put(aOldBulItem);
1990 }
1991
1992 pOutlineSheet->GetItemSet().Put(aTempSet);
1993 pOutlineSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
1994 }
1995 }
1996 }
1997 else if (pObj == GetPresObj(PresObjKind::Notes, 0))
1998 {
2000
2001 if (pNotesSheet)
2002 {
2003 sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height();
2004 sal_uLong nFontHeight = static_cast<sal_uLong>(nHeight * 0.0741);
2005 SfxItemSet& rSet = pNotesSheet->GetItemSet();
2006 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT ));
2007 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK ));
2008 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL ));
2009 pNotesSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
2010 }
2011 }
2012 }
2013 else if ( eObjKind != SdrObjKind::TitleText &&
2014 eObjKind != SdrObjKind::OutlineText &&
2015 DynCastSdrTextObj( pObj ) != nullptr &&
2016 pObj->GetOutlinerParaObject() )
2017 {
2018 /******************************************************
2019 * normal text object: adjust text height
2020 ******************************************************/
2022 sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT;
2023 if ( nScriptType == SvtScriptType::ASIAN )
2024 nWhich = EE_CHAR_FONTHEIGHT_CJK;
2025 else if ( nScriptType == SvtScriptType::COMPLEX )
2026 nWhich = EE_CHAR_FONTHEIGHT_CTL;
2027
2028 // use more modern method to scale the text height
2029 sal_uInt32 nFontHeight = static_cast<const SvxFontHeightItem&>(pObj->GetMergedItem(nWhich)).GetHeight();
2030 sal_uInt32 nNewFontHeight = sal_uInt32(static_cast<double>(nFontHeight) * static_cast<double>(aFractY));
2031
2032 pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich));
2033 }
2034 }
2035 }
2036
2037 if (mbScaleObjects && !pObj->IsEdgeObj())
2038 {
2039 /**************************************************************
2040 * scale object position
2041 **************************************************************/
2042 Point aNewPos;
2043
2044 // corrected scaling; only distances may be scaled
2045 // use aTopLeft as original TopLeft
2046 aNewPos.setX( ::tools::Long((aTopLeft.X() - GetLeftBorder()) * static_cast<double>(aFractX)) + nLeft );
2047 aNewPos.setY( ::tools::Long((aTopLeft.Y() - GetUpperBorder()) * static_cast<double>(aFractY)) + nUpper );
2048
2049 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y());
2050
2051 if (aVec.Height() != 0 || aVec.Width() != 0)
2052 {
2053 pObj->NbcMove(aVec);
2054 }
2055
2056 pObj->SetChanged();
2057 pObj->BroadcastObjectChange();
2058 }
2059 }
2060 }
2061}
2062
2063static rtl::Reference<SdrObject> convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect)
2064{
2065 SdDrawDocument& rModel(static_cast< SdDrawDocument& >(rPage.getSdrModelFromSdrPage()));
2066 if( !pSourceObj )
2067 return pSourceObj;
2068
2069 SfxUndoManager* pUndoManager = rModel.GetUndoManager();
2070 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
2071
2072 rtl::Reference<SdrObject> pNewObj = pSourceObj;
2073 if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() == SdrObjKind::Text) )
2074 {
2075 pNewObj = rPage.CreatePresObj(PresObjKind::Outline, bVertical, rRect);
2076
2077 // Set text of the subtitle into PRESOBJ_OUTLINE
2078 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2079
2080 if(pOutlParaObj)
2081 {
2082 // assign text
2083 SdOutliner* pOutl = rModel.GetInternalOutliner();
2084 pOutl->Clear();
2085 pOutl->SetText( *pOutlParaObj );
2086 pNewObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
2087 pOutlParaObj = pNewObj->GetOutlinerParaObject();
2088 pOutl->Clear();
2089 pNewObj->SetEmptyPresObj(false);
2090
2091 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
2092 {
2093 // assign new template
2094 OUString aName( rPage.GetLayoutName() + " " + OUString::number( nLevel ) );
2095 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( rModel.GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page) );
2096
2097 if (pSheet && nLevel == 1)
2098 {
2100
2101 if (pSubtitleSheet)
2102 pOutlParaObj->ChangeStyleSheetName(SfxStyleFamily::Page, pSubtitleSheet->GetName(), pSheet->GetName());
2103 }
2104 }
2105
2106 // Remove LRSpace item
2108
2109 aSet.Put(pNewObj->GetMergedItemSet());
2110
2112
2113 pNewObj->SetMergedItemSet(aSet);
2114
2115 if( bUndo )
2116 pUndoManager->AddUndoAction( rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
2117
2118 // Remove outline shape from page
2119 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2120 }
2121 }
2122 else if((eObjKind == PresObjKind::Text) && (pSourceObj->GetObjIdentifier() == SdrObjKind::OutlineText) )
2123 {
2124 // is there an outline shape we can use to replace empty subtitle shape?
2125 pNewObj = rPage.CreatePresObj(PresObjKind::Text, bVertical, rRect);
2126
2127 // Set text of the outline object into PRESOBJ_TITLE
2128 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject();
2129
2130 if(pOutlParaObj)
2131 {
2132 // assign text
2133 SdOutliner* pOutl = rModel.GetInternalOutliner();
2134 pOutl->Clear();
2135 pOutl->SetText( *pOutlParaObj );
2136 pNewObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
2137 pOutl->Clear();
2138 pNewObj->SetEmptyPresObj(false);
2139
2140 // reset left indent
2142
2143 aSet.Put(pNewObj->GetMergedItemSet());
2144
2145 const SvxLRSpaceItem& rLRItem = aSet.Get(EE_PARA_LRSPACE);
2146 SvxLRSpaceItem aNewLRItem(rLRItem);
2147 aNewLRItem.SetTextLeft(0);
2148 aSet.Put(aNewLRItem);
2149
2150 pNewObj->SetMergedItemSet(aSet);
2151
2153 if (pSheet)
2154 pNewObj->SetStyleSheet(pSheet, true);
2155
2156 // Remove subtitle shape from page
2157 if( bUndo )
2158 pUndoManager->AddUndoAction(rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
2159
2160 rPage.RemoveObject( pSourceObj->GetOrdNum() );
2161 }
2162 }
2163 else if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() != SdrObjKind::OutlineText) )
2164 {
2165 switch( pSourceObj->GetObjIdentifier() )
2166 {
2167 case SdrObjKind::Table: eObjKind = PresObjKind::Table; break;
2168 case SdrObjKind::Media: eObjKind = PresObjKind::Media; break;
2169 case SdrObjKind::Graphic: eObjKind = PresObjKind::Graphic; break;
2170 case SdrObjKind::OLE2: eObjKind = PresObjKind::Object; break;
2171 default: break;
2172 }
2173 }
2174
2175 return pNewObj;
2176}
2177
2194SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj1, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit)
2195{
2196 rtl::Reference<SdrObject> pObj = pObj1;
2197 SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
2198 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
2199
2200 if (!pObj && bInit)
2201 {
2202 pObj = CreatePresObj(eObjKind, bVertical, rRect);
2203 }
2204 else if ( pObj && (pObj->GetUserCall() || bInit) )
2205 {
2206 // convert object if shape type does not match kind (f.e. converting outline text to subtitle text)
2207 if( bInit )
2208 pObj = convertPresentationObjectImpl(*this, pObj.get(), eObjKind, bVertical, rRect);
2209
2210 if( bUndo )
2211 {
2212 pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
2213 pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoAttrObject( *pObj, true, true ) );
2214 pUndoManager->AddUndoAction( std::make_unique<UndoObjectUserCall>( *pObj ) );
2215 }
2216
2217 pObj->AdjustToMaxRect(rRect);
2218
2219 pObj->SetUserCall(this);
2220
2221 SdrTextObj* pTextObject = DynCastSdrTextObj(pObj.get());
2222 if( pTextObject )
2223 {
2224 if( pTextObject->IsVerticalWriting() != bVertical )
2225 {
2226 pTextObject->SetVerticalWriting( bVertical );
2227
2228 // here make sure the correct anchoring is used when the object
2229 // is re-used but orientation is changed
2230 if(PresObjKind::Outline == eObjKind)
2232 }
2233
2234 if( !mbMaster && (pTextObject->GetObjIdentifier() != SdrObjKind::Table) )
2235 {
2236 if ( pTextObject->IsAutoGrowHeight() )
2237 {
2238 // switch off AutoGrowHeight, set new MinHeight
2239 SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2240 SdrMetricItem aMinHeight( makeSdrTextMinFrameHeightItem(rRect.GetSize().Height()) );
2241 aTempAttr.Put( aMinHeight );
2242 aTempAttr.Put( makeSdrTextAutoGrowHeightItem(false) );
2243 pTextObject->SetMergedItemSet(aTempAttr);
2244 pTextObject->SetLogicRect(rRect);
2245
2246 // switch on AutoGrowHeight
2247 SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2248 aAttr.Put( makeSdrTextAutoGrowHeightItem(true) );
2249
2250 pTextObject->SetMergedItemSet(aAttr);
2251 }
2252
2253 if ( pTextObject->IsAutoGrowWidth() )
2254 {
2255 // switch off AutoGrowWidth , set new MinWidth
2256 SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2257 SdrMetricItem aMinWidth( makeSdrTextMinFrameWidthItem(rRect.GetSize().Width()) );
2258 aTempAttr.Put( aMinWidth );
2259 aTempAttr.Put( makeSdrTextAutoGrowWidthItem(false) );
2260 pTextObject->SetMergedItemSet(aTempAttr);
2261 pTextObject->SetLogicRect(rRect);
2262
2263 // switch on AutoGrowWidth
2264 SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
2265 aAttr.Put( makeSdrTextAutoGrowWidthItem(true) );
2266 pTextObject->SetMergedItemSet(aAttr);
2267 }
2268 }
2269 }
2270 }
2271
2272 if(pObj && bInit )
2273 {
2274 if( !IsPresObj( pObj.get() ) )
2275 {
2276 if( bUndo )
2277 pUndoManager->AddUndoAction( std::make_unique<UndoObjectPresentationKind>( *pObj ) );
2278
2279 InsertPresObj( pObj.get(), eObjKind );
2280 }
2281
2282 // make adjustments for vertical title and outline shapes
2283 if( bVertical && (( eObjKind == PresObjKind::Title) || (eObjKind == PresObjKind::Outline)))
2284 {
2285 SfxItemSet aNewSet(pObj->GetMergedItemSet());
2286 aNewSet.Put( makeSdrTextAutoGrowWidthItem(true) );
2287 aNewSet.Put( makeSdrTextAutoGrowHeightItem(false) );
2288 if( eObjKind == PresObjKind::Outline )
2289 {
2292 }
2293 pObj->SetMergedItemSet(aNewSet);
2294 }
2295 }
2296
2297 if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || dynamic_cast< const SdrGrafObj *>( pObj.get() ) == nullptr ) )
2298 pObj->AdjustToMaxRect(rRect);
2299
2300 return pObj.get();
2301}
2302
2303/*************************************************************************
2304|*
2305|* Returns the PresObjKind of an object
2306|*
2307\************************************************************************/
2308
2310{
2312 if( (pObj != nullptr) && (maPresentationShapeList.hasShape(*pObj)) )
2313 {
2315 if( pInfo )
2316 eKind = pInfo->mePresObjKind;
2317 }
2318
2319 return eKind;
2320}
2321
2323{
2324 return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) );
2325}
2326
2328{
2329 if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) )
2330 {
2331 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj));
2332 if( pInfo )
2334 maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj));
2335 }
2336}
2337
2339{
2340 DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" );
2341 DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" );
2342 if( pObj )
2343 {
2345 if( pInfo )
2346 pInfo->mePresObjKind = eKind;
2348 }
2349}
2350
2351/*************************************************************************
2352|*
2353|* Set the text of an object
2354|*
2355\************************************************************************/
2356
2357void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, std::u16string_view rString )
2358{
2359 if ( !pObj )
2360 return;
2361
2362 ::Outliner* pOutl = pOutliner;
2363
2364 if (!pOutliner)
2365 {
2366 SfxItemPool* pPool(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDrawOutliner().GetEmptyItemSet().GetPool());
2367 pOutl = new ::Outliner( pPool, OutlinerMode::OutlineObject );
2368 pOutl->SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
2369 pOutl->SetEditTextObjectPool(pPool);
2370 pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool()));
2371 pOutl->EnableUndo(false);
2372 pOutl->SetUpdateLayout( false );
2373 }
2374
2375 OutlinerMode nOutlMode = pOutl->GetOutlinerMode();
2376 Size aPaperSize = pOutl->GetPaperSize();
2377 bool bUpdateMode = pOutl->SetUpdateLayout(false);
2378 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2379
2380 // Always set the object's StyleSheet at the Outliner to
2381 // use the current objects StyleSheet. Thus it's the same as in
2382 // SetText(...).
2383 // Moved this implementation from where SetObjText(...) was called
2384 // to inside this method to work even when outliner is fetched here.
2385 pOutl->SetStyleSheet(0, pObj->GetStyleSheet());
2386
2387 OUString aString;
2388
2389 switch( eObjKind )
2390 {
2392 {
2393 pOutl->Init( OutlinerMode::OutlineObject );
2394
2395 aString += OUString::Concat("\t") + rString;
2396
2397 if (mbMaster)
2398 {
2399 pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) );
2400 aString += "\n\t\t" +
2401 SdResId(STR_PRESOBJ_MPOUTLLAYER2) +
2402 "\n\t\t\t" +
2403 SdResId(STR_PRESOBJ_MPOUTLLAYER3) +
2404 "\n\t\t\t\t" +
2405 SdResId(STR_PRESOBJ_MPOUTLLAYER4) +
2406 "\n\t\t\t\t\t" +
2407 SdResId(STR_PRESOBJ_MPOUTLLAYER5) +
2408 "\n\t\t\t\t\t\t" +
2409 SdResId(STR_PRESOBJ_MPOUTLLAYER6) +
2410 "\n\t\t\t\t\t\t\t" +
2411 SdResId(STR_PRESOBJ_MPOUTLLAYER7);
2412
2413 }
2414 }
2415 break;
2416
2417 case PresObjKind::Title:
2418 {
2419 pOutl->Init( OutlinerMode::TitleObject );
2420 aString += rString;
2421 }
2422 break;
2423
2424 default:
2425 {
2426 pOutl->Init( OutlinerMode::TextObject );
2427 aString += rString;
2428
2429 // check if we need to add a text field
2430 std::unique_ptr<SvxFieldData> pData;
2431
2432 switch( eObjKind )
2433 {
2435 pData.reset(new SvxHeaderField());
2436 break;
2438 pData .reset(new SvxFooterField());
2439 break;
2441 pData.reset(new SvxPageField());
2442 break;
2444 pData.reset(new SvxDateTimeField());
2445 break;
2446 default:
2447 break;
2448 }
2449
2450 if( pData )
2451 {
2452 ESelection e;
2454 pOutl->QuickInsertField(aField,e);
2455 }
2456 }
2457 break;
2458 }
2459
2460 pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() );
2461
2462 if( !aString.isEmpty() )
2463 pOutl->SetText( aString, pOutl->GetParagraph( 0 ) );
2464
2465 pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
2466
2467 if (!pOutliner)
2468 {
2469 delete pOutl;
2470 pOutl = nullptr;
2471 }
2472 else
2473 {
2474 // restore the outliner
2475 pOutl->Init( nOutlMode );
2476 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() );
2477 pOutl->SetUpdateLayout( bUpdateMode );
2478 pOutl->SetPaperSize( aPaperSize );
2479 }
2480}
2481
2482/*************************************************************************
2483|*
2484|* Set the name of the layout
2485|*
2486\************************************************************************/
2487void SdPage::SetLayoutName(const OUString& aName)
2488{
2490
2491 if( mbMaster )
2492 {
2493 sal_Int32 nPos = maLayoutName.indexOf(SD_LT_SEPARATOR);
2494 if (nPos != -1)
2496 }
2497}
2498
2499/*************************************************************************
2500|*
2501|* Return the page name and generates it if necessary
2502|*
2503\************************************************************************/
2504
2505const OUString& SdPage::GetName() const
2506{
2507 OUString aCreatedPageName( maCreatedPageName );
2508 if (GetRealName().isEmpty())
2509 {
2511 {
2512 // default name for handout pages
2513 sal_uInt16 nNum = (GetPageNum() + 1) / 2;
2514
2515 aCreatedPageName = SdResId(STR_PAGE) + " ";
2516 if (static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()).GetDocumentType() == DocumentType::Draw )
2517 aCreatedPageName = SdResId(STR_PAGE_NAME) + " ";
2518
2519 if( getSdrModelFromSdrPage().GetPageNumType() == css::style::NumberingType::NUMBER_NONE )
2520 {
2521 // if the document has number none as a formatting
2522 // for page numbers we still default to arabic numbering
2523 // to keep the default page names unique
2524 aCreatedPageName += OUString::number( static_cast<sal_Int32>(nNum) );
2525 }
2526 else
2527 {
2528 aCreatedPageName += static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).CreatePageNumValue(nNum);
2529 }
2530 }
2531 else
2532 {
2533 /******************************************************************
2534 * default name for note pages
2535 ******************************************************************/
2536 aCreatedPageName = SdResId(STR_LAYOUT_DEFAULT_NAME);
2537 }
2538 }
2539 else
2540 {
2541 aCreatedPageName = GetRealName();
2542 }
2543
2545 {
2546 aCreatedPageName += " " + SdResId(STR_NOTES);
2547 }
2548 else if (mePageKind == PageKind::Handout && mbMaster)
2549 {
2550 aCreatedPageName += " (" + SdResId(STR_HANDOUT) + ")";
2551 }
2552
2553 const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName;
2554 return maCreatedPageName;
2555}
2556
2558{
2559 // Do nothing
2560}
2561
2563{
2564 Size aSize = GetSize();
2565 if ( aSize.getWidth() > aSize.getHeight() )
2566 {
2567 return Orientation::Landscape;
2568 }
2569 else
2570 {
2571 return Orientation::Portrait;
2572 }
2573}
2574
2575/*************************************************************************
2576|*
2577|* returns the default text of a PresObjektes
2578|*
2579\************************************************************************/
2580
2581OUString SdPage::GetPresObjText(PresObjKind eObjKind) const
2582{
2583 OUString aString;
2584
2585#if defined(IOS) || defined(ANDROID)
2586 bool isMobileDevice = true;
2587#else
2588 bool isMobileDevice = false;
2589 if (const SfxViewShell* pCurrentViewShell = SfxViewShell::Current())
2590 isMobileDevice = pCurrentViewShell->isLOKMobilePhone() || pCurrentViewShell->isLOKTablet();
2591#endif
2592
2593 if (eObjKind == PresObjKind::Title)
2594 {
2595 if (mbMaster)
2596 {
2598 {
2599 if (isMobileDevice)
2600 aString = SdResId(STR_PRESOBJ_MPTITLE_MOBILE);
2601 else
2602 aString = SdResId(STR_PRESOBJ_MPTITLE);
2603 }
2604 else
2605 {
2606 if (isMobileDevice)
2607 aString = SdResId(STR_PRESOBJ_MPNOTESTITLE_MOBILE);
2608 else
2609 aString = SdResId(STR_PRESOBJ_MPNOTESTITLE);
2610 }
2611 }
2612 else if (isMobileDevice)
2613 aString = SdResId(STR_PRESOBJ_TITLE_MOBILE);
2614 else
2615 aString = SdResId(STR_PRESOBJ_TITLE);
2616 }
2617 else if (eObjKind == PresObjKind::Outline)
2618 {
2619 if (mbMaster)
2620 {
2621 if (isMobileDevice)
2622 aString = SdResId(STR_PRESOBJ_MPOUTLINE_MOBILE);
2623 else
2624 aString = SdResId(STR_PRESOBJ_MPOUTLINE);
2625 }
2626 else if (isMobileDevice)
2627 aString = SdResId(STR_PRESOBJ_OUTLINE_MOBILE);
2628 else
2629 aString = SdResId(STR_PRESOBJ_OUTLINE);
2630 }
2631 else if (eObjKind == PresObjKind::Notes)
2632 {
2633 if (mbMaster)
2634 {
2635 if (isMobileDevice)
2636 aString = SdResId(STR_PRESOBJ_MPNOTESTEXT_MOBILE);
2637 else
2638 aString = SdResId(STR_PRESOBJ_MPNOTESTEXT);
2639 }
2640 else if (isMobileDevice)
2641 aString = SdResId(STR_PRESOBJ_NOTESTEXT_MOBILE);
2642 else
2643 aString = SdResId(STR_PRESOBJ_NOTESTEXT);
2644 }
2645 else if (eObjKind == PresObjKind::Text)
2646 {
2647 if (isMobileDevice)
2648 aString = SdResId(STR_PRESOBJ_TEXT_MOBILE);
2649 else
2650 aString = SdResId(STR_PRESOBJ_TEXT);
2651 }
2652 else if (eObjKind == PresObjKind::Graphic)
2653 {
2654 aString = SdResId( STR_PRESOBJ_GRAPHIC );
2655 }
2656 else if (eObjKind == PresObjKind::Object)
2657 {
2658 aString = SdResId( STR_PRESOBJ_OBJECT );
2659 }
2660 else if (eObjKind == PresObjKind::Chart)
2661 {
2662 aString = SdResId( STR_PRESOBJ_CHART );
2663 }
2664 else if (eObjKind == PresObjKind::OrgChart)
2665 {
2666 aString = SdResId( STR_PRESOBJ_ORGCHART );
2667 }
2668 else if (eObjKind == PresObjKind::Calc)
2669 {
2670 aString = SdResId( STR_PRESOBJ_TABLE );
2671 }
2672
2673 return aString;
2674}
2675
2676uno::Reference< uno::XInterface > SdPage::createUnoPage()
2677{
2678 return createUnoPageImpl( this );
2679}
2680
2682SdPage* SdPage::getImplementation( const css::uno::Reference< css::drawing::XDrawPage >& xPage )
2683{
2684 try
2685 {
2686 auto pUnoPage = comphelper::getFromUnoTunnel<SvxDrawPage>(xPage);
2687 if( pUnoPage )
2688 return static_cast< SdPage* >( pUnoPage->GetSdrPage() );
2689 }
2690 catch( css::uno::Exception& )
2691 {
2692 TOOLS_WARN_EXCEPTION( "sd", "sd::SdPage::getImplementation()" );
2693 }
2694
2695 return nullptr;
2696}
2697
2698sal_Int64 SdPage::GetHashCode() const
2699{
2700 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
2701}
2702
2703void SdPage::SetName (const OUString& rName)
2704{
2705 OUString aOldName( GetName() );
2706 FmFormPage::SetName (rName);
2707 static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).UpdatePageRelativeURLs(aOldName, rName);
2708 ActionChanged();
2709}
2710
2711const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const
2712{
2714 {
2715 return static_cast<SdPage&>(TRG_GetMasterPage()).maHeaderFooterSettings;
2716 }
2717 else
2718 {
2720 }
2721}
2722
2724{
2726 {
2727 static_cast<SdPage&>(TRG_GetMasterPage()).maHeaderFooterSettings = rNewSettings;
2728 }
2729 else
2730 {
2731 maHeaderFooterSettings = rNewSettings;
2732 }
2733
2734 SetChanged();
2735
2736 if(!TRG_HasMasterPage())
2737 return;
2738
2740
2741 // #i119056# For HeaderFooterSettings SdrObjects are used, but the properties
2742 // used are not part of their model data, but kept in SD. This data is applied
2743 // using a 'backdoor' on primitive creation. Thus, the normal mechanism to detect
2744 // object changes does not work here. It is necessary to trigger updates here
2745 // directly. BroadcastObjectChange used for PagePreview invalidations,
2746 // flushViewObjectContacts used to invalidate and flush all visualizations in
2747 // edit views.
2748 SdPage* pMasterPage = dynamic_cast< SdPage* >(&TRG_GetMasterPage());
2749
2750 if(!pMasterPage)
2751 return;
2752
2753 SdrObject* pCandidate = pMasterPage->GetPresObj( PresObjKind::Header );
2754
2755 if(pCandidate)
2756 {
2757 pCandidate->BroadcastObjectChange();
2759 }
2760
2761 pCandidate = pMasterPage->GetPresObj( PresObjKind::DateTime );
2762
2763 if(pCandidate)
2764 {
2765 pCandidate->BroadcastObjectChange();
2767 }
2768
2769 pCandidate = pMasterPage->GetPresObj( PresObjKind::Footer );
2770
2771 if(pCandidate)
2772 {
2773 pCandidate->BroadcastObjectChange();
2775 }
2776
2777 pCandidate = pMasterPage->GetPresObj( PresObjKind::SlideNumber );
2778
2779 if(pCandidate)
2780 {
2781 pCandidate->BroadcastObjectChange();
2783 }
2784}
2785
2787 const sdr::contact::ViewObjectContact& rOriginal,
2788 const sdr::contact::DisplayInfo& rDisplayInfo,
2789 bool bEdit )
2790{
2791 if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) )
2792 return false;
2793
2794 SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
2795 if( pObj == nullptr )
2796 return false;
2797
2799 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile());
2800 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
2801 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
2802
2803 // empty presentation objects only visible during edit mode
2804 if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() )
2805 {
2806 if( (pObj->GetObjInventor() != SdrInventor::Default) || ( (pObj->GetObjIdentifier() != SdrObjKind::Rectangle) && (pObj->GetObjIdentifier() != SdrObjKind::Page) ) )
2807 return false;
2808 }
2809
2810 if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == SdrObjKind::Text ) )
2811 {
2812 const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->getSdrPageFromSdrObject());
2813
2814 if( pCheckPage )
2815 {
2816 PresObjKind eKind = pCheckPage->GetPresObjKind(pObj);
2817
2818 if((eKind == PresObjKind::Footer) || (eKind == PresObjKind::Header) || (eKind == PresObjKind::DateTime) || (eKind == PresObjKind::SlideNumber) )
2819 {
2820 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
2821
2822 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PageKind::Handout && bIsPrinting ) )
2823 {
2824 // use the page that is currently processed
2825 const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage);
2826
2827 if( pVisualizedSdPage )
2828 {
2829 // if we are not on a masterpage, see if we have to draw this header&footer object at all
2830 const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings();
2831
2832 switch( eKind )
2833 {
2835 return rSettings.mbFooterVisible;
2837 return rSettings.mbHeaderVisible;
2839 return rSettings.mbDateTimeVisible;
2841 return rSettings.mbSlideNumberVisible;
2842 default:
2843 break;
2844 }
2845 }
2846 }
2847 } // check for placeholders on master
2848 else if( (eKind != PresObjKind::NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) )
2849 {
2850 // presentation objects on master slide are always invisible if slide is shown.
2851 return false;
2852 }
2853 }
2854 }
2855
2856 // i63977, do not print SdrpageObjs from master pages
2857 if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == SdrObjKind::Page ) )
2858 {
2860 return false;
2861 }
2862
2863 return true;
2864}
2865
2867{
2868 bool bRet = false;
2869
2870 SdrTextObj* pTextObj = DynCastSdrTextObj( pObj );
2871
2872 if( pTextObj )
2873 {
2874 PresObjKind ePresObjKind = GetPresObjKind(pTextObj);
2875
2876 if (ePresObjKind == PresObjKind::Title ||
2877 ePresObjKind == PresObjKind::Outline ||
2878 ePresObjKind == PresObjKind::Notes ||
2879 ePresObjKind == PresObjKind::Text)
2880 {
2881 OUString aString( GetPresObjText(ePresObjKind) );
2882
2883 if (!aString.isEmpty())
2884 {
2885 bool bVertical = false;
2886 OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject();
2887 if( pOldPara )
2888 bVertical = pOldPara->IsEffectivelyVertical(); // is old para object vertical?
2889
2890 SetObjText( pTextObj, nullptr, ePresObjKind, aString );
2891
2892 if( pOldPara )
2893 {
2894 // Here, only the vertical flag for the
2895 // OutlinerParaObjects needs to be changed. The
2896 // AutoGrowWidth/Height items still exist in the
2897 // not changed object.
2898 if(pTextObj->GetOutlinerParaObject()
2899 && pTextObj->GetOutlinerParaObject()->IsEffectivelyVertical() != bVertical)
2900 {
2901 ::tools::Rectangle aObjectRect = pTextObj->GetSnapRect();
2902 pTextObj->GetOutlinerParaObject()->SetVertical(bVertical);
2903 pTextObj->SetSnapRect(aObjectRect);
2904 }
2905 }
2906
2907 pTextObj->SetTextEditOutliner( nullptr ); // to make stylesheet settings work
2908 pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), true );
2909 pTextObj->SetEmptyPresObj(true);
2910 bRet = true;
2911 }
2912 }
2913 }
2914 return bRet;
2915}
2916
2917void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< ::tools::Rectangle >& rAreas )
2918{
2919 SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PageKind::Handout );
2920
2921 static const sal_uInt16 aOffsets[5][9] =
2922 {
2923 { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order
2924 { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical
2925 { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical
2926 { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical
2927 { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical
2928 };
2929
2930 const sal_uInt16* pOffsets = aOffsets[0];
2931
2932 Size aArea = rHandoutMaster.GetSize();
2933 const bool bLandscape = aArea.Width() > aArea.Height();
2934
2935 if( eLayout == AUTOLAYOUT_NONE )
2936 {
2937 // use layout from handout master
2938 SdrObjListIter aShapeIter(&rHandoutMaster);
2939
2940 std::vector< ::tools::Rectangle > vSlidesAreas;
2941 while ( aShapeIter.IsMore() )
2942 {
2943 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>( aShapeIter.Next() );
2944 // get slide rectangles
2945 if (pPageObj)
2946 vSlidesAreas.push_back( pPageObj->GetCurrentBoundRect() );
2947 }
2948
2949 if ( !bHorizontal || vSlidesAreas.size() < 4 )
2950 { // top to bottom, then right
2951 rAreas.swap( vSlidesAreas );
2952 }
2953 else
2954 { // left to right, then down
2955 switch ( vSlidesAreas.size() )
2956 {
2957 case 4:
2958 pOffsets = aOffsets[2];
2959 break;
2960
2961 default:
2962 [[fallthrough]];
2963 case 6:
2964 pOffsets = aOffsets[ bLandscape ? 3 : 1 ];
2965 break;
2966
2967 case 9:
2968 pOffsets = aOffsets[4];
2969 break;
2970 }
2971
2972 rAreas.resize( static_cast<size_t>(vSlidesAreas.size()) );
2973
2974 for( const ::tools::Rectangle& rRect : vSlidesAreas )
2975 {
2976 rAreas[*pOffsets++] = rRect;
2977 }
2978 }
2979 }
2980 else
2981 {
2982 const ::tools::Long nGapW = 1000; // gap is 1cm
2983 const ::tools::Long nGapH = 1000;
2984
2985 ::tools::Long nLeftBorder = rHandoutMaster.GetLeftBorder();
2986 ::tools::Long nRightBorder = rHandoutMaster.GetRightBorder();
2987 ::tools::Long nTopBorder = rHandoutMaster.GetUpperBorder();
2988 ::tools::Long nBottomBorder = rHandoutMaster.GetLowerBorder();
2989
2990 const ::tools::Long nHeaderFooterHeight = static_cast< ::tools::Long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05 );
2991
2992 nTopBorder += nHeaderFooterHeight;
2993 nBottomBorder += nHeaderFooterHeight;
2994
2995 ::tools::Long nX = nGapW + nLeftBorder;
2996 ::tools::Long nY = nGapH + nTopBorder;
2997
2998 aArea.AdjustWidth( -(nGapW * 2 + nLeftBorder + nRightBorder) );
2999 aArea.AdjustHeight( -(nGapH * 2 + nTopBorder + nBottomBorder) );
3000
3001 sal_uInt16 nColCnt = 0, nRowCnt = 0;
3002 switch ( eLayout )
3003 {
3005 nColCnt = 1; nRowCnt = 1;
3006 break;
3007
3009 if( bLandscape )
3010 {
3011 nColCnt = 2; nRowCnt = 1;
3012 }
3013 else
3014 {
3015 nColCnt = 1; nRowCnt = 2;
3016 }
3017 break;
3018
3020 if( bLandscape )
3021 {
3022 nColCnt = 3; nRowCnt = 2;
3023 }
3024 else
3025 {
3026 nColCnt = 2; nRowCnt = 3;
3027 }
3028 pOffsets = aOffsets[ bLandscape ? 1 : 0 ];
3029 break;
3030
3032 nColCnt = 2; nRowCnt = 2;
3033 pOffsets = aOffsets[ bHorizontal ? 0 : 2 ];
3034 break;
3035
3037 if( bLandscape )
3038 {
3039 nColCnt = 3; nRowCnt = 2;
3040 }
3041 else
3042 {
3043 nColCnt = 2; nRowCnt = 3;
3044 }
3045 if( !bHorizontal )
3046 pOffsets = aOffsets[ bLandscape ? 1 : 3 ];
3047 break;
3048
3049 default:
3051 nColCnt = 3; nRowCnt = 3;
3052
3053 if( !bHorizontal )
3054 pOffsets = aOffsets[4];
3055 break;
3056 }
3057
3058 rAreas.resize(static_cast<size_t>(nColCnt) * nRowCnt);
3059
3060 Size aPartArea, aSize;
3061 aPartArea.setWidth( (aArea.Width() - ((nColCnt-1) * nGapW) ) / nColCnt );
3062 aPartArea.setHeight( (aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt );
3063
3064 SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PageKind::Standard);
3065 if (pFirstPage && pFirstPage->GetWidth() && pFirstPage->GetHeight())
3066 {
3067 // scale actual size into handout rect
3068 double fScale = static_cast<double>(aPartArea.Width()) / static_cast<double>(pFirstPage->GetWidth());
3069
3070 aSize.setHeight( static_cast<::tools::Long>(fScale * pFirstPage->GetHeight() ) );
3071 if( aSize.Height() > aPartArea.Height() )
3072 {
3073 fScale = static_cast<double>(aPartArea.Height()) / static_cast<double>(pFirstPage->GetHeight());
3074 aSize.setHeight( aPartArea.Height() );
3075 aSize.setWidth( static_cast<::tools::Long>(fScale * pFirstPage->GetWidth()) );
3076 }
3077 else
3078 {
3079 aSize.setWidth( aPartArea.Width() );
3080 }
3081
3082 nX += (aPartArea.Width() - aSize.Width()) / 2;
3083 nY += (aPartArea.Height()- aSize.Height())/ 2;
3084 }
3085 else
3086 {
3087 aSize = aPartArea;
3088 }
3089
3090 Point aPos( nX, nY );
3091
3092 const bool bRTL = rModel.GetDefaultWritingMode() == css::text::WritingMode_RL_TB;
3093
3094 const ::tools::Long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1);
3095 const ::tools::Long nOffsetY = aPartArea.Height() + nGapH;
3096 const ::tools::Long nStartX = bRTL ? nOffsetX*(1 - nColCnt) + nX : nX;
3097
3098 for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++)
3099 {
3100 aPos.setX( nStartX );
3101 for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++)
3102 {
3103 rAreas[*pOffsets++] = ::tools::Rectangle(aPos, aSize);
3104 aPos.AdjustX(nOffsetX );
3105 }
3106
3107 aPos.AdjustY(nOffsetY );
3108 }
3109 }
3110}
3111
3112void SdPage::SetPrecious (const bool bIsPrecious)
3113{
3114 mbIsPrecious = bIsPrecious;
3115}
3116
3117HeaderFooterSettings::HeaderFooterSettings()
3118{
3119 mbHeaderVisible = true;
3120 mbFooterVisible = true;
3121 mbSlideNumberVisible = false;
3122 mbDateTimeVisible = true;
3123 mbDateTimeIsFixed = true;
3124 meDateFormat = SvxDateFormat::A;
3125 meTimeFormat = SvxTimeFormat::AppDefault;
3126}
3127
3128bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const
3129{
3130 return (mbHeaderVisible == rSettings.mbHeaderVisible) &&
3131 (maHeaderText == rSettings.maHeaderText) &&
3132 (mbFooterVisible == rSettings.mbFooterVisible) &&
3133 (maFooterText == rSettings.maFooterText) &&
3134 (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) &&
3135 (mbDateTimeVisible == rSettings.mbDateTimeVisible) &&
3136 (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) &&
3137 (meDateFormat == rSettings.meDateFormat) &&
3138 (meTimeFormat == rSettings.meTimeFormat) &&
3139 (maDateTimeText == rSettings.maDateTimeText);
3140}
3141
3142/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AutoLayout
AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT
AUTOLAYOUT_HANDOUT1
AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT
AUTOLAYOUT_TITLE_2VTEXT
AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT
AUTOLAYOUT_VTITLE_VCONTENT
AUTOLAYOUT_TITLE_ONLY
AUTOLAYOUT_TITLE_2CONTENT
AUTOLAYOUT_ONLY_TEXT
AUTOLAYOUT_TITLE_6CONTENT
AUTOLAYOUT_HANDOUT9
AUTOLAYOUT_TITLE_2CONTENT_CONTENT
AUTOLAYOUT_HANDOUT2
AUTOLAYOUT_TITLE_CONTENT_2CONTENT
AUTOLAYOUT_HANDOUT4
AUTOLAYOUT_START
AUTOLAYOUT_NONE
AUTOLAYOUT_END
AUTOLAYOUT_HANDOUT6
AUTOLAYOUT_TITLE_CONTENT
AUTOLAYOUT_HANDOUT3
AUTOLAYOUT_TITLE_VCONTENT
AUTOLAYOUT_TITLE_4CONTENT
static OutputDevice * GetDefaultDevice()
virtual SvtScriptType GetScriptType() const=0
void SetName(const OUString &rName)
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE) override
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum) override
Size GetPrefSize() const
MapMode GetPrefMapMode() const
const EditTextObject & GetTextObject() const
void SetVertical(bool bNew)
void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString &rNewName)
bool IsEffectivelyVertical() const
void SetText(const OutlinerParaObject &)
const Size & GetPaperSize() const
OutlinerMode GetOutlinerMode() const
const SfxItemSet & GetEmptyItemSet() const
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
std::optional< OutlinerParaObject > CreateParaObject(sal_Int32 nStartPara=0, sal_Int32 nParaCount=EE_PARA_ALL) const
void SetPaperSize(const Size &rSize)
void SetStyleSheet(sal_Int32 nPara, SfxStyleSheet *pStyle)
bool SetUpdateLayout(bool bUpdate)
void SetEditTextObjectPool(SfxItemPool *pPool)
void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &)
void SetStyleSheetPool(SfxStyleSheetPool *pSPool)
void SetRefDevice(OutputDevice *pRefDev)
void Init(OutlinerMode nMode)
void EnableUndo(bool bEnable)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void SetMapMode()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
PresObjKind mePresObjKind
Definition: anminfo.hxx:33
static SdAnimationInfo * GetShapeUserData(SdrObject &rObject, bool bCreate=false)
Definition: drawdoc2.cxx:959
sd::UndoManager * GetUndoManager() const
Definition: drawdoc2.cxx:1377
SAL_DLLPRIVATE SfxItemPool & GetPool()
Definition: drawdoc.hxx:237
SdOutliner * GetInternalOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:930
SdPage * GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
Definition: drawdoc2.cxx:217
css::text::WritingMode GetDefaultWritingMode() const
Definition: drawdoc4.cxx:1184
The main purpose of this class is searching and replacing as well as spelling of impress documents.
Definition: Outliner.hxx:123
SdrObject * GetPresObj(PresObjKind eObjKind, int nIndex=1, bool bFuzzySearch=false)
returns the nIndex'th object from the given PresObjKind, index starts with 1
Definition: sdpage.cxx:203
virtual void SetOrientation(Orientation eOrient) override
Definition: sdpage.cxx:2557
AutoLayout meAutoLayout
AutoLayout.
Definition: sdpage.hxx:106
virtual Orientation GetOrientation() const override
Definition: sdpage.cxx:2562
SdrObject * CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle &rRect)
creates a presentation object with the given PresObjKind on this page.
Definition: sdpage.cxx:284
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum) override
Definition: sdpage.cxx:1706
bool IsPresObj(const SdrObject *pObj)
Definition: sdpage.cxx:2322
SdStyleSheet * getPresentationStyle(sal_uInt32 nHelpId) const
returns the presentation style with the given helpid from this masterpage or this slides masterpage
Definition: sdpage.cxx:674
bool mbScaleObjects
Objects should be scaled.
Definition: sdpage.hxx:121
void ConnectLink()
Definition: sdpage2.cxx:291
void RemovePresObj(const SdrObject *pObj)
removes the given SdrObject from the presentation object list
Definition: sdpage.cxx:2327
PageKind GetPageKind() const
Definition: sdpage.hxx:205
SfxStyleSheet * GetStyleSheetForMasterPageBackground() const
Definition: sdpage.cxx:606
void SetObjText(SdrTextObj *pObj, SdrOutliner *pOutliner, PresObjKind eObjKind, std::u16string_view rStr)
Definition: sdpage.cxx:2357
virtual rtl::Reference< SdrObject > NbcRemoveObject(size_t nObjNum) override
Definition: sdpage.cxx:1718
OUString maLayoutName
Name of the layout.
Definition: sdpage.hxx:114
static sal_uInt16 mnLastPageId
Definition: sdpage.hxx:384
void CreateTitleAndLayout(bool bInit=false, bool bCreate=false)
Definition: sdpage.cxx:793
virtual rtl::Reference< SdrObject > ReplaceObject(SdrObject *pNewObj, size_t nObjNum) override
Also override ReplaceObject methods to realize when objects are removed with this mechanism instead o...
Definition: sdpage.cxx:1726
virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr) override
Definition: sdpage.cxx:1756
rtl::Reference< SdrObject > CreateDefaultPresObj(PresObjKind eObjKind)
Definition: sdpage.cxx:970
sd::ScopeLock maLockAutoLayoutArrangement
Definition: sdpage.hxx:108
void DestroyDefaultPresObj(PresObjKind eObjKind)
Definition: sdpage.cxx:1055
OUString GetPresObjText(PresObjKind eObjKind) const
Definition: sdpage.cxx:2581
OUString const & GetRealName() const
Definition: sdpage.hxx:269
virtual css::uno::Reference< css::uno::XInterface > createUnoPage() override
Definition: sdpage.cxx:2676
const sd::HeaderFooterSettings & getHeaderFooterSettings() const
Definition: sdpage.cxx:2711
void onRemoveObject(SdrObject *pObject)
called before a shape is removed or replaced from this slide
Definition: sdpage.cxx:1734
SfxStyleSheet * GetStyleSheetForPresObj(PresObjKind eObjKind) const
Definition: sdpage.cxx:625
PageKind mePageKind
page type
Definition: sdpage.hxx:105
OUString maCreatedPageName
generated page name by GetPageName.
Definition: sdpage.hxx:118
static void CalculateHandoutAreas(SdDrawDocument &rModel, AutoLayout eLayout, bool bHorizontal, std::vector< ::tools::Rectangle > &rAreas)
Definition: sdpage.cxx:2917
virtual void SetUpperBorder(sal_Int32 nBorder) override
Definition: sdpage.cxx:1781
static SdPage * getImplementation(const css::uno::Reference< css::drawing::XDrawPage > &xPage)
returns the SdPage implementation for the given XDrawPage or 0 if not available
Definition: sdpage.cxx:2682
sd::HeaderFooterSettings maHeaderFooterSettings
Definition: sdpage.hxx:140
::tools::Rectangle GetLayoutRect() const
Definition: sdpage.cxx:1162
PresObjKind GetPresObjKind(SdrObject *pObj) const
Definition: sdpage.cxx:2309
void DisconnectLink()
Definition: sdpage2.cxx:323
virtual ~SdPage() override
Definition: sdpage.cxx:171
css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode
holds the smil animation sequences for this page
Definition: sdpage.hxx:129
void SetLayoutName(const OUString &aName)
Definition: sdpage.cxx:2487
void EndListenOutlineText()
Definition: sdpage2.cxx:250
void SetAutoLayout(AutoLayout eLayout, bool bInit=false, bool bCreate=false)
Definition: sdpage.cxx:1610
void ScaleObjects(const Size &rNewPageSize, const ::tools::Rectangle &rNewBorderRect, bool bScaleAllObj)
Definition: sdpage.cxx:1807
virtual bool checkVisibility(const sdr::contact::ViewObjectContact &rOriginal, const sdr::contact::DisplayInfo &rDisplayInfo, bool bEdit) override
Definition: sdpage.cxx:2786
SdPage(const SdPage &)=delete
void InsertPresObj(SdrObject *pObj, PresObjKind eKind)
inserts the given SdrObject into the presentation object list
Definition: sdpage.cxx:2338
virtual OUString GetLayoutName() const override
Definition: sdpage.hxx:255
SdrObject * InsertAutoLayoutShape(SdrObject *pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle &rRect, bool bInit)
reuses or creates a presentation shape for an auto layout that fits the given parameter
Definition: sdpage.cxx:2194
void removeAnimations(const SdrObject *pObj)
removes all custom animations for the given shape
const OUString & GetName() const
Definition: sdpage.cxx:2505
virtual void SetRightBorder(sal_Int32 nBorder) override
Definition: sdpage.cxx:1773
virtual void SetLowerBorder(sal_Int32 nBorder) override
Definition: sdpage.cxx:1789
virtual void SetLeftBorder(sal_Int32 nBorder) override
Definition: sdpage.cxx:1765
virtual void NbcInsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE) override
Definition: sdpage.cxx:1681
void setHeaderFooterSettings(const sd::HeaderFooterSettings &rNewSettings)
Definition: sdpage.cxx:2723
void EnsureMasterPageDefaultBackground()
create background properties
Definition: sdpage.cxx:260
void SetPrecious(const bool bIsPrecious)
Set the "precious" flag to the given value.
Definition: sdpage.cxx:3112
void SetName(const OUString &rName)
Set the name of the page and broadcast a model change.
Definition: sdpage.cxx:2703
::tools::Rectangle GetTitleRect() const
Definition: sdpage.cxx:1076
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const ::tools::Rectangle &rOldBoundRect) override
Definition: sdpage.cxx:725
AutoLayout GetAutoLayout() const
Definition: sdpage.hxx:190
sal_Int64 GetHashCode() const
Definition: sdpage.cxx:2698
bool RestoreDefaultText(SdrObject *pObj)
Definition: sdpage.cxx:2866
virtual void SetSize(const Size &aSize) override
Definition: sdpage.cxx:1746
bool mbIsPrecious
Definition: sdpage.hxx:387
sd::ShapeList maPresentationShapeList
presentation objects
Definition: sdpage.hxx:107
virtual const tools::Rectangle & GetSnapRect() const override
SdrLayerID GetLayerID(const OUString &rName) const
::comphelper::IEmbeddedHelper * GetPersist() const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
SfxStyleSheetBasePool * GetStyleSheetPool() const
SdrUndoFactory & GetSdrUndoFactory() const
bool IsUndoEnabled() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrObject * Next()
bool IsMore() const
virtual rtl::Reference< SdrObject > ReplaceObject(SdrObject *pNewObj, size_t nObjNum)
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
virtual void NbcInsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
virtual rtl::Reference< SdrObject > NbcRemoveObject(size_t nObjNum)
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
const SfxPoolItem & GetMergedItem(const sal_uInt16 nWhich) const
SdrObjUserCall * GetUserCall() const
virtual void NbcSetLayer(SdrLayerID nLayer)
void SetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject)
void BroadcastObjectChange() const
bool IsEdgeObj() const
void SetUserCall(SdrObjUserCall *pUser)
void SetEmptyPresObj(bool bEpt)
virtual SdrInventor GetObjInventor() const
virtual OutlinerParaObject * GetOutlinerParaObject() const
sal_uInt32 GetOrdNum() const
bool IsEmptyPresObj() const
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
void NbcSetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr)
virtual const tools::Rectangle & GetCurrentBoundRect() const
virtual void SetLogicRect(const tools::Rectangle &rRect)
SfxStyleSheet * GetStyleSheet() const
sdr::contact::ViewContact & GetViewContact() const
virtual void SetChanged()
virtual SdrObjKind GetObjIdentifier() const
SdrPage * getSdrPageFromSdrObject() const
virtual void SetSnapRect(const tools::Rectangle &rRect)
virtual SdrLayerID GetLayer() const
void SetMergedItem(const SfxPoolItem &rItem)
virtual void NbcMove(const Size &rSiz)
virtual const tools::Rectangle & GetLogicRect() const
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true)
bool IsEmpty() const
const OUString & GetProgName() const
const OUString & GetPersistName() const
bool IsChart() const
bool IsCalc() const
void SetReferencedPage(SdrPage *pNewPage)
void SetStyleSheet(SfxStyleSheet *pStyleSheet)
void PutItem(const SfxPoolItem &rItem)
void ClearItem(const sal_uInt16 nWhich=0)
SdrPage * GetPage() const
virtual void SetLeftBorder(sal_Int32 nBorder)
void ActionChanged()
bool IsInserted() const
SdrPage & TRG_GetMasterPage() const
sal_uInt16 GetPageNum() const
virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr)
virtual void SetLowerBorder(sal_Int32 nBorder)
const SdrLayerAdmin & GetLayerAdmin() const
bool mbMaster
bool IsMasterPage() const
Size GetSize() const
sal_Int32 GetUpperBorder() const
virtual void SetRightBorder(sal_Int32 nBorder)
virtual void SetUpperBorder(sal_Int32 nBorder)
virtual bool checkVisibility(const sdr::contact::ViewObjectContact &rOriginal, const sdr::contact::DisplayInfo &rDisplayInfo, bool bEdit)
sal_Int32 GetRightBorder() const
sal_Int32 GetLeftBorder() const
sdr::contact::ViewContact & TRG_GetMasterPageDescriptorViewContact() const
bool TRG_HasMasterPage() const
SdrPageProperties & getSdrPageProperties()
void SetChanged()
SdrModel & getSdrModelFromSdrPage() const
sal_Int32 GetLowerBorder() const
tools::Long GetHeight() const
virtual void SetSize(const Size &aSiz)
tools::Long GetWidth() const
void SetTextEditOutliner(SdrOutliner *pOutl)
virtual bool IsAutoGrowWidth() const
virtual OutlinerParaObject * GetOutlinerParaObject() const override
virtual bool IsAutoGrowHeight() const
virtual const tools::Rectangle & GetLogicRect() const override
virtual void SetVerticalWriting(bool bVertical)
virtual SdrObjKind GetObjIdentifier() const override
virtual bool IsVerticalWriting() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoDeleteObject(SdrObject &rObject, bool bOrdNumDirect=false)
void Broadcast(const SfxHint &rHint)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
void ClearInvalidItems()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
const OUString & GetName() const
SfxStyleFamily GetFamily() const
virtual SfxItemSet & GetItemSet()
bool IsInListAction() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
void CopyValidProperties(const SvxBulletItem &rCopyFrom)
sal_uInt32 GetHeight() const
void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp=100)
virtual EmbeddedObjectContainer & getEmbeddedObjectContainer() const=0
const css::uno::Reference< css::drawing::XDrawPage > & getVisualizedPage() const
#define SO3_PLUGIN_CLASSID
#define SO3_IFRAME_CLASSID
#define SO3_APPLET_CLASSID
void fill(V val)
size_type count(const Value &v) const
std::pair< const_iterator, bool > insert(Value &&x)
bool isLocked() const
Definition: scopelock.hxx:32
void addShape(SdrObject &rObject)
adds the given shape to this list
Definition: shapelist.cxx:39
void removeShape(SdrObject &rObject)
removes the shape from this list
Definition: shapelist.cxx:54
bool isEmpty() const
returns true if this list is empty
Definition: shapelist.cxx:87
bool hasShape(SdrObject &rObject) const
returns true if given shape is part of this list
Definition: shapelist.cxx:93
SdrObject * getNextShape()
returns the shape the internal iterator points to, or 0 if the list end is reached.
Definition: shapelist.cxx:116
void seekShape(sal_uInt32 nIndex)
Sets the internal iterator to the shape at given index.
Definition: shapelist.cxx:128
bool GetSubContentActive() const
virtual SdrPageView * TryToGetSdrPageView() const
virtual bool isOutputToPDFFile() const
virtual bool isOutputToPrinter() const
const drawinglayer::geometry::ViewInformation2D & getViewInformation2D() const
virtual SdrObject * TryToGetSdrObject() const
void flushViewObjectContacts(bool bWithHierarchy=true)
virtual void ActionChanged()
ViewContact & GetViewContact() const
ObjectContact & GetObjectContact() const
void SetSize(const Size &)
constexpr Point TopLeft() const
void SetPos(const Point &rPoint)
constexpr Size GetSize() const
constexpr bool IsEmpty() const
#define DBG_ASSERT(sCon, aError)
PresChange
Definition: diadef.h:23
#define TOOLS_WARN_EXCEPTION(area, stream)
float x
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxLRSpaceItem > EE_PARA_LRSPACE(EE_PARA_START+13)
constexpr TypedWhichId< SvxBulletItem > EE_PARA_BULLET(EE_PARA_START+12)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
EmbeddedObjectRef * pObject
DocumentType eType
constexpr OUStringLiteral SD_LT_SEPARATOR
Definition: glob.hxx:49
sal_Int32 nIndex
OUString aName
SvtScriptType
sal_uInt16 nPos
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
tools::Long const nBorder
B2IRange fround(const B2DRange &rRange)
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
long Long
sal_Int16 nId
OutlinerMode
#define PAPERBIN_PRINTER_SETTINGS
PresObjKind
Definition: pres.hxx:22
PageKind
Definition: pres.hxx:45
Orientation
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
const int VERTICAL
Definition: sdpage.cxx:1208
static void findAutoLayoutShapesImpl(SdPage &rPage, const LayoutDescriptor &rDescriptor, std::array< SdrObject *, MAX_PRESOBJS > &rShapes, bool bInit, bool bSwitchLayout)
Definition: sdpage.cxx:1452
static void CalcAutoLayoutRectangles(SdPage const &rPage,::tools::Rectangle *rRectangle, const OUString &sLayoutType)
Definition: sdpage.cxx:1348
const int MAX_PRESOBJS
Definition: sdpage.cxx:1207
static OUString enumtoString(AutoLayout aut)
Definition: sdpage.cxx:1290
static constexpr PresObjKind operator|(PresObjKind e, int x)
Definition: sdpage.cxx:1210
static rtl::Reference< SdrObject > convertPresentationObjectImpl(SdPage &rPage, SdrObject *pSourceObj, PresObjKind &eObjKind, bool bVertical, const ::tools::Rectangle &rRect)
Definition: sdpage.cxx:2063
static const LayoutDescriptor & GetLayoutDescriptor(AutoLayout eLayout)
Definition: sdpage.cxx:1240
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
SdrTextVertAdjust
SDRTEXTVERTADJUST_BOTTOM
SDRTEXTVERTADJUST_TOP
SDRTEXTHORZADJUST_BLOCK
SDRTEXTHORZADJUST_RIGHT
SdrOnOffItem makeSdrTextContourFrameItem(bool bOn)
SdrMetricItem makeSdrTextMinFrameHeightItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextMinFrameWidthItem(tools::Long mnWidth)
static SfxItemSet & rSet
sal_Int16 mnTransitionType
RGBColor mnTransitionFadeColor
sal_uIntPtr sal_uLong
constexpr OUStringLiteral STR_LAYOUT_TITLE
Definition: strings.hxx:15
constexpr OUStringLiteral STR_LAYOUT_OUTLINE
Definition: strings.hxx:16
constexpr OUStringLiteral STR_LAYOUT_SUBTITLE
Definition: strings.hxx:20
constexpr OUStringLiteral STR_LAYOUT_BACKGROUNDOBJECTS
Definition: strings.hxx:18
constexpr OUStringLiteral STR_LAYOUT_NOTES
Definition: strings.hxx:19
constexpr OUStringLiteral STR_LAYOUT_BACKGROUND
Definition: strings.hxx:17
SvxTimeFormat meTimeFormat
Definition: sdpage.hxx:75
SvxDateFormat meDateFormat
Definition: sdpage.hxx:74
SdrUserCallType
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SdrObjKind
SvxAdjust
SVXCORE_DLLPUBLIC SdrPage * GetSdrPageFromXDrawPage(const css::uno::Reference< css::drawing::XDrawPage > &xDrawPage) noexcept
constexpr OUStringLiteral sUNO_LayerName_background_objects
Definition: unokywds.hxx:30
Reference< uno::XInterface > createUnoPageImpl(SdPage *pPage)
Definition: unopage.cxx:3063