LibreOffice Module svx (master)  1
svdmodel.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 <svx/svdmodel.hxx>
21 #include <cassert>
22 #include <math.h>
23 #include <sal/log.hxx>
24 #include <rtl/ustrbuf.hxx>
25 #include <com/sun/star/lang/XComponent.hpp>
26 #include <com/sun/star/document/XStorageBasedDocument.hpp>
27 #include <com/sun/star/embed/ElementModes.hpp>
28 #include <unotools/configmgr.hxx>
29 #include <unotools/pathoptions.hxx>
30 #include <svl/whiter.hxx>
31 #include <svl/asiancfg.hxx>
32 #include <svx/xbtmpit.hxx>
33 #include <svx/xlndsit.hxx>
34 #include <svx/xlnedit.hxx>
35 #include <svx/xflgrit.hxx>
36 #include <svx/xflftrit.hxx>
37 #include <svx/xflhtit.hxx>
38 #include <svx/xlnstit.hxx>
39 #include <editeng/editeng.hxx>
40 #include <svx/xtable.hxx>
41 #include <svx/svdtrans.hxx>
42 #include <svx/svdpage.hxx>
43 #include <svx/svdlayer.hxx>
44 #include <svx/svdundo.hxx>
45 #include <svx/svdpool.hxx>
46 #include <svx/svdobj.hxx>
47 #include <svx/svdotext.hxx>
48 #include <textchain.hxx>
49 #include <svx/svdetc.hxx>
50 #include <svx/svdoutl.hxx>
51 #include <svx/dialmgr.hxx>
52 #include <svx/strings.hrc>
53 #include <svdoutlinercache.hxx>
54 #include <svx/sdasitm.hxx>
55 #include <officecfg/Office/Common.hxx>
56 #include <editeng/fontitem.hxx>
57 #include <editeng/colritem.hxx>
58 #include <editeng/fhgtitem.hxx>
59 #include <svl/style.hxx>
64 #include <unotools/syslocale.hxx>
65 #include <editeng/eeitem.hxx>
66 #include <svl/itemset.hxx>
67 #include <vcl/settings.hxx>
68 #include <vcl/svapp.hxx>
69 #include <memory>
70 #include <libxml/xmlwriter.h>
71 #include <sfx2/viewsh.hxx>
72 #include <o3tl/enumrange.hxx>
73 #include <tools/diagnose_ex.h>
74 #include <tools/UnitConversion.hxx>
75 #include <svx/ColorSets.hxx>
76 
77 using namespace ::com::sun::star;
78 using namespace ::com::sun::star::uno;
79 using namespace ::com::sun::star::lang;
80 
81 
83 {
86  bool mbAnchoredTextOverflowLegacy; // tdf#99729 compatibility flag
87  std::unique_ptr<svx::Theme> mpTheme;
88 
90  : mpUndoManager(nullptr)
91  , mpUndoFactory(nullptr)
92  , mbAnchoredTextOverflowLegacy(false)
93  {}
94 };
95 
96 
97 SdrModel::SdrModel(SfxItemPool* pPool, comphelper::IEmbeddedHelper* pEmbeddedHelper, bool bDisablePropertyFiles)
98  : m_aObjUnit(SdrEngineDefaults::GetMapFraction())
99  , m_eObjUnit(SdrEngineDefaults::GetMapUnit())
100  , m_eUIUnit(FieldUnit::MM)
101  , m_aUIScale(Fraction(1,1))
102  , m_nUIUnitDecimalMark(0)
103  , m_pLayerAdmin(new SdrLayerAdmin)
104  , m_pItemPool(pPool)
105  , m_pEmbeddedHelper(pEmbeddedHelper)
106  , mnDefTextHgt(SdrEngineDefaults::GetFontHeight())
107  , m_pRefOutDev(nullptr)
108  , m_pDefaultStyleSheet(nullptr)
109  , mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(nullptr)
110  , m_pLinkManager(nullptr)
111  , m_nUndoLevel(0)
112  , m_bIsWriter(true)
113  , mbUndoEnabled(true)
114  , mbChanged(false)
115  , m_bPagNumsDirty(false)
116  , m_bMPgNumsDirty(false)
117  , m_bTransportContainer(false)
118  , m_bReadOnly(false)
119  , m_bTransparentTextFrames(false)
120  , m_bSwapGraphics(false)
121  , m_bPasteResize(false)
122  , m_bStarDrawPreviewMode(false)
123  , mbDisableTextEditUsesCommonUndoManager(false)
124  , mbVOCInvalidationIsReliable(false)
125  , m_nDefaultTabulator(0)
126  , m_nMaxUndoCount(16)
127  , m_pTextChain(new TextChain)
128  , mpImpl(new SdrModelImpl)
129  , mnCharCompressType(CharCompressType::NONE)
130  , mnHandoutPageCount(0)
131  , mbModelLocked(false)
132  , mbKernAsianPunctuation(false)
133  , mbAddExtLeading(false)
134  , mbInDestruction(false)
135 {
137  {
138  mnCharCompressType = static_cast<CharCompressType>(
139  officecfg::Office::Common::AsianLayout::CompressCharacterDistance::get());
140  }
141 
142  if (m_pItemPool == nullptr)
143  {
144  m_pItemPool = new SdrItemPool(nullptr);
145  // Outliner doesn't have its own Pool, so use the EditEngine's
147  // OutlinerPool as SecondaryPool of SdrPool
148  m_pItemPool->SetSecondaryPool(pOutlPool.get());
149  // remember that I created both pools myself
150  m_bIsWriter = false;
151  }
152  m_pItemPool->SetDefaultMetric(m_eObjUnit);
153 
154 // using static SdrEngineDefaults only if default SvxFontHeight item is not available
155  const SfxPoolItem* pPoolItem = m_pItemPool->GetPoolDefaultItem( EE_CHAR_FONTHEIGHT );
156  if (pPoolItem)
157  mnDefTextHgt = static_cast<const SvxFontHeightItem*>(pPoolItem)->GetHeight();
158 
159  m_pItemPool->SetPoolDefaultItem( makeSdrTextWordWrapItem( false ) );
160 
161  SetTextDefaults();
162  m_pLayerAdmin->SetModel(this);
163  ImpSetUIUnit();
164 
165  // can't create DrawOutliner OnDemand, because I can't get the Pool,
166  // then (only from 302 onwards!)
167  m_pDrawOutliner = SdrMakeOutliner(OutlinerMode::TextObject, *this);
168  ImpSetOutlinerDefaults(m_pDrawOutliner.get(), true);
169 
170  m_pHitTestOutliner = SdrMakeOutliner(OutlinerMode::TextObject, *this);
171  ImpSetOutlinerDefaults(m_pHitTestOutliner.get(), true);
172 
173  /* Start Text Chaining related code */
174  // Initialize Chaining Outliner
175  m_pChainingOutliner = SdrMakeOutliner( OutlinerMode::TextObject, *this );
176  ImpSetOutlinerDefaults(m_pChainingOutliner.get(), true);
177 
178  ImpCreateTables(bDisablePropertyFiles || utl::ConfigManager::IsFuzzing());
179 }
180 
182 {
183  mbInDestruction = true;
184 
186 
187  mpOutlinerCache.reset();
188 
189  ClearUndoBuffer();
190 #ifdef DBG_UTIL
191  SAL_WARN_IF(m_pCurrentUndoGroup, "svx", "In the Dtor of the SdrModel there is an open Undo left: \""
192  << m_pCurrentUndoGroup->GetComment() << '\"');
193 #endif
194  m_pCurrentUndoGroup.reset();
195 
196  ClearModel(true);
197 
198 #ifdef DBG_UTIL
199  // SdrObjectLifetimeWatchDog:
200  if(!maAllIncarnatedObjects.empty())
201  {
202  SAL_WARN("svx","SdrModel::~SdrModel: Not all incarnations of SdrObjects deleted, possible memory leak (!)");
203  const std::vector<const SdrObject*> maRemainingObjects(maAllIncarnatedObjects.begin(),
204  maAllIncarnatedObjects.end());
205  for (auto pSdrObject : maRemainingObjects)
206  {
207  SdrObject* pCandidate(const_cast<SdrObject*>(pSdrObject));
208  // calling SdrObject::Free will change maAllIncarnatedObjects, and potentially remove
209  // more than one, so check if the candidate is still in the updated list before Free
210  if (maAllIncarnatedObjects.find(pSdrObject) != maAllIncarnatedObjects.end())
211  SdrObject::Free(pCandidate);
212  }
213  }
214 #endif
215 
216  m_pLayerAdmin.reset();
217 
218  m_pTextChain.reset();
219  // Delete DrawOutliner only after deleting ItemPool, because ItemPool
220  // references Items of the DrawOutliner!
221  m_pChainingOutliner.reset();
222  m_pHitTestOutliner.reset();
223  m_pDrawOutliner.reset();
224 
225  // delete StyleSheetPool, derived classes should not do this since
226  // the DrawingEngine may need it in its destructor
227  if( mxStyleSheetPool.is() )
228  {
229  Reference< XComponent > xComponent( static_cast< cppu::OWeakObject* >( mxStyleSheetPool.get() ), UNO_QUERY );
230  if( xComponent.is() ) try
231  {
232  xComponent->dispose();
233  }
234  catch( RuntimeException& )
235  {
236  }
237  mxStyleSheetPool.clear();
238  }
239 
241 
242  delete mpImpl->mpUndoFactory;
243 }
244 
246 {
247  m_bSwapGraphics = true;
248 }
249 
251 {
252  return m_bReadOnly;
253 }
254 
255 void SdrModel::SetReadOnly(bool bYes)
256 {
257  m_bReadOnly=bYes;
258 }
259 
260 
261 void SdrModel::SetMaxUndoActionCount(sal_uInt32 nCount)
262 {
263  if (nCount<1) nCount=1;
264  m_nMaxUndoCount=nCount;
265  while (m_aUndoStack.size()>m_nMaxUndoCount)
266  m_aUndoStack.pop_back();
267 }
268 
270 {
271  m_aUndoStack.clear();
272  m_aRedoStack.clear();
273 }
274 
276 {
277  return !m_aUndoStack.empty();
278 }
279 
281 {
282  return !m_aRedoStack.empty();
283 }
284 
286 {
287  if( mpImpl->mpUndoManager )
288  {
289  OSL_FAIL("svx::SdrModel::Undo(), method not supported with application undo manager!");
290  }
291  else
292  {
293  if(HasUndoActions())
294  {
295  SfxUndoAction* pDo = m_aUndoStack.front().get();
296  const bool bWasUndoEnabled = mbUndoEnabled;
297  mbUndoEnabled = false;
298  pDo->Undo();
299  std::unique_ptr<SfxUndoAction> p = std::move(m_aUndoStack.front());
300  m_aUndoStack.pop_front();
301  m_aRedoStack.emplace_front(std::move(p));
302  mbUndoEnabled = bWasUndoEnabled;
303  }
304  }
305 }
306 
308 {
309  if( mpImpl->mpUndoManager )
310  {
311  OSL_FAIL("svx::SdrModel::Redo(), method not supported with application undo manager!");
312  }
313  else
314  {
315  if(HasRedoActions())
316  {
317  SfxUndoAction* pDo = m_aRedoStack.front().get();
318  const bool bWasUndoEnabled = mbUndoEnabled;
319  mbUndoEnabled = false;
320  pDo->Redo();
321  std::unique_ptr<SfxUndoAction> p = std::move(m_aRedoStack.front());
322  m_aRedoStack.pop_front();
323  m_aUndoStack.emplace_front(std::move(p));
324  mbUndoEnabled = bWasUndoEnabled;
325  }
326  }
327 }
328 
330 {
331  if( mpImpl->mpUndoManager )
332  {
333  OSL_FAIL("svx::SdrModel::Redo(), method not supported with application undo manager!");
334  }
335  else
336  {
337  if(HasUndoActions())
338  {
339  SfxUndoAction* pDo = m_aUndoStack.front().get();
340  if(pDo->CanRepeat(rView))
341  {
342  pDo->Repeat(rView);
343  }
344  }
345  }
346 }
347 
348 void SdrModel::ImpPostUndoAction(std::unique_ptr<SdrUndoAction> pUndo)
349 {
350  DBG_ASSERT( mpImpl->mpUndoManager == nullptr, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" );
351  if( !IsUndoEnabled() )
352  return;
353 
354  if (m_aUndoLink)
355  {
356  m_aUndoLink(std::move(pUndo));
357  }
358  else
359  {
360  m_aUndoStack.emplace_front(std::move(pUndo));
361  while (m_aUndoStack.size()>m_nMaxUndoCount)
362  {
363  m_aUndoStack.pop_back();
364  }
365  m_aRedoStack.clear();
366  }
367 }
368 
370 {
371  if( mpImpl->mpUndoManager )
372  {
373  ViewShellId nViewShellId(-1);
374  if (SfxViewShell* pViewShell = SfxViewShell::Current())
375  nViewShellId = pViewShell->GetViewShellId();
376  mpImpl->mpUndoManager->EnterListAction("","",0,nViewShellId);
377  m_nUndoLevel++;
378  }
379  else if( IsUndoEnabled() )
380  {
382  {
383  m_pCurrentUndoGroup.reset(new SdrUndoGroup(*this));
384  m_nUndoLevel=1;
385  }
386  else
387  {
388  m_nUndoLevel++;
389  }
390  }
391 }
392 
393 void SdrModel::BegUndo(const OUString& rComment)
394 {
395  if( mpImpl->mpUndoManager )
396  {
397  ViewShellId nViewShellId(-1);
398  if (SfxViewShell* pViewShell = SfxViewShell::Current())
399  nViewShellId = pViewShell->GetViewShellId();
400  mpImpl->mpUndoManager->EnterListAction( rComment, "", 0, nViewShellId );
401  m_nUndoLevel++;
402  }
403  else if( IsUndoEnabled() )
404  {
405  BegUndo();
406  if (m_nUndoLevel==1)
407  {
408  m_pCurrentUndoGroup->SetComment(rComment);
409  }
410  }
411 }
412 
413 void SdrModel::BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc)
414 {
415  if( mpImpl->mpUndoManager )
416  {
417  OUString aComment(rComment);
418  if( !aComment.isEmpty() && !rObjDescr.isEmpty() )
419  {
420  aComment = aComment.replaceFirst("%1", rObjDescr);
421  }
422  ViewShellId nViewShellId(-1);
423  if (SfxViewShell* pViewShell = SfxViewShell::Current())
424  nViewShellId = pViewShell->GetViewShellId();
425  mpImpl->mpUndoManager->EnterListAction( aComment,"",0,nViewShellId );
426  m_nUndoLevel++;
427  }
428  else if( IsUndoEnabled() )
429  {
430  BegUndo();
431  if (m_nUndoLevel==1)
432  {
433  m_pCurrentUndoGroup->SetComment(rComment);
434  m_pCurrentUndoGroup->SetObjDescription(rObjDescr);
435  m_pCurrentUndoGroup->SetRepeatFunction(eFunc);
436  }
437  }
438 }
439 
441 {
442  DBG_ASSERT(m_nUndoLevel!=0,"SdrModel::EndUndo(): UndoLevel is already 0!");
443  if( mpImpl->mpUndoManager )
444  {
445  if( m_nUndoLevel )
446  {
447  m_nUndoLevel--;
448  mpImpl->mpUndoManager->LeaveListAction();
449  }
450  }
451  else
452  {
453  if(m_pCurrentUndoGroup!=nullptr && IsUndoEnabled())
454  {
455  m_nUndoLevel--;
456  if(m_nUndoLevel==0)
457  {
458  if(m_pCurrentUndoGroup->GetActionCount()!=0)
459  {
461  }
462  else
463  {
464  // was empty
465  m_pCurrentUndoGroup.reset();
466  }
467  }
468  }
469  }
470 }
471 
472 void SdrModel::SetUndoComment(const OUString& rComment)
473 {
474  DBG_ASSERT(m_nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is already 0!");
475 
476  if( mpImpl->mpUndoManager )
477  {
478  OSL_FAIL("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
479  }
480  else if( IsUndoEnabled() && m_nUndoLevel==1)
481  {
482  m_pCurrentUndoGroup->SetComment(rComment);
483  }
484 }
485 
486 void SdrModel::SetUndoComment(const OUString& rComment, const OUString& rObjDescr)
487 {
488  DBG_ASSERT(m_nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is already 0!");
489  if( mpImpl->mpUndoManager )
490  {
491  OSL_FAIL("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
492  }
493  else
494  {
495  if (m_nUndoLevel==1)
496  {
497  m_pCurrentUndoGroup->SetComment(rComment);
498  m_pCurrentUndoGroup->SetObjDescription(rObjDescr);
499  }
500  }
501 }
502 
503 void SdrModel::AddUndo(std::unique_ptr<SdrUndoAction> pUndo)
504 {
505  if( mpImpl->mpUndoManager )
506  {
507  mpImpl->mpUndoManager->AddUndoAction( std::move(pUndo) );
508  }
509  else if( IsUndoEnabled() )
510  {
512  {
513  m_pCurrentUndoGroup->AddAction(std::move(pUndo));
514  }
515  else
516  {
517  ImpPostUndoAction(std::move(pUndo));
518  }
519  }
520 }
521 
522 void SdrModel::EnableUndo( bool bEnable )
523 {
524  if( mpImpl->mpUndoManager )
525  {
526  mpImpl->mpUndoManager->EnableUndo( bEnable );
527  }
528  else
529  {
530  mbUndoEnabled = bEnable;
531  }
532 }
533 
535 {
536  if( mpImpl->mpUndoManager )
537  {
538  return mpImpl->mpUndoManager->IsUndoEnabled();
539  }
540  else
541  {
542  return mbUndoEnabled;
543  }
544 }
545 
546 void SdrModel::ImpCreateTables(bool bDisablePropertyFiles)
547 {
548  // use standard path for initial construction
549  const OUString aTablePath(!bDisablePropertyFiles ? SvtPathOptions().GetPalettePath() : "");
550 
551  for( auto i : o3tl::enumrange<XPropertyListType>() )
552  {
553  maProperties[i] = XPropertyList::CreatePropertyList(i, aTablePath, ""/*TODO?*/ );
554  }
555 }
556 
557 void SdrModel::ClearModel(bool bCalledFromDestructor)
558 {
559  if(bCalledFromDestructor)
560  {
561  mbInDestruction = true;
562  }
563 
564  sal_Int32 i;
565  // delete all drawing pages
566  sal_Int32 nCount=GetPageCount();
567  for (i=nCount-1; i>=0; i--)
568  {
569  DeletePage( static_cast<sal_uInt16>(i) );
570  }
571  maPages.clear();
572  PageListChanged();
573 
574  // delete all Masterpages
575  nCount=GetMasterPageCount();
576  for(i=nCount-1; i>=0; i--)
577  {
578  DeleteMasterPage( static_cast<sal_uInt16>(i) );
579  }
580  maMasterPages.clear();
582 
583  m_pLayerAdmin->ClearLayers();
584 }
585 
587 {
588  SdrModel* pModel=new SdrModel();
590  return pModel;
591 }
592 
594 {
595  return new SdrPage(*this,bMasterPage);
596 }
597 
599 {
601 }
602 
603 void SdrModel::SetTextDefaults( SfxItemPool* pItemPool, sal_Int32 nDefTextHgt )
604 {
605  // set application-language specific dynamic pool language defaults
606  SvxFontItem aSvxFontItem( EE_CHAR_FONTINFO) ;
607  SvxFontItem aSvxFontItemCJK(EE_CHAR_FONTINFO_CJK);
608  SvxFontItem aSvxFontItemCTL(EE_CHAR_FONTINFO_CTL);
609  LanguageType nLanguage;
612  else
613  nLanguage = LANGUAGE_ENGLISH_US;
614 
615  // get DEFAULTFONT_LATIN_TEXT and set at pool as dynamic default
616  vcl::Font aFont(OutputDevice::GetDefaultFont(DefaultFontType::LATIN_TEXT, nLanguage, GetDefaultFontFlags::OnlyOne));
617  aSvxFontItem.SetFamily(aFont.GetFamilyType());
618  aSvxFontItem.SetFamilyName(aFont.GetFamilyName());
619  aSvxFontItem.SetStyleName(OUString());
620  aSvxFontItem.SetPitch( aFont.GetPitch());
621  aSvxFontItem.SetCharSet( aFont.GetCharSet() );
622  pItemPool->SetPoolDefaultItem(aSvxFontItem);
623 
624  // get DEFAULTFONT_CJK_TEXT and set at pool as dynamic default
625  vcl::Font aFontCJK(OutputDevice::GetDefaultFont(DefaultFontType::CJK_TEXT, nLanguage, GetDefaultFontFlags::OnlyOne));
626  aSvxFontItemCJK.SetFamily( aFontCJK.GetFamilyType());
627  aSvxFontItemCJK.SetFamilyName(aFontCJK.GetFamilyName());
628  aSvxFontItemCJK.SetStyleName(OUString());
629  aSvxFontItemCJK.SetPitch( aFontCJK.GetPitch());
630  aSvxFontItemCJK.SetCharSet( aFontCJK.GetCharSet());
631  pItemPool->SetPoolDefaultItem(aSvxFontItemCJK);
632 
633  // get DEFAULTFONT_CTL_TEXT and set at pool as dynamic default
634  vcl::Font aFontCTL(OutputDevice::GetDefaultFont(DefaultFontType::CTL_TEXT, nLanguage, GetDefaultFontFlags::OnlyOne));
635  aSvxFontItemCTL.SetFamily(aFontCTL.GetFamilyType());
636  aSvxFontItemCTL.SetFamilyName(aFontCTL.GetFamilyName());
637  aSvxFontItemCTL.SetStyleName(OUString());
638  aSvxFontItemCTL.SetPitch( aFontCTL.GetPitch() );
639  aSvxFontItemCTL.SetCharSet( aFontCTL.GetCharSet());
640  pItemPool->SetPoolDefaultItem(aSvxFontItemCTL);
641 
642  // set dynamic FontHeight defaults
643  pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT ) );
644  pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
645  pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
646 
647  // set FontColor defaults
649 }
650 
652 {
653  m_pDrawOutliner->SetTextObj(pObj);
654  return *m_pDrawOutliner;
655 }
656 
658 {
659  m_pChainingOutliner->SetTextObj(pObj);
660  return *m_pChainingOutliner;
661 }
662 
664 {
665  if (m_pDrawOutliner!=nullptr) {
666  return m_pDrawOutliner->GetTextObj();
667  }
668  return nullptr;
669 }
670 
672 {
673  // Initialization of the Outliners for drawing text and HitTest
674  if( bInit )
675  {
676  pOutliner->EraseVirtualDevice();
677  pOutliner->SetUpdateLayout(false);
678  pOutliner->SetEditTextObjectPool(m_pItemPool.get());
679  pOutliner->SetDefTab(m_nDefaultTabulator);
680  }
681 
682  pOutliner->SetRefDevice(GetRefDevice());
686  pOutliner->SetAddExtLeading( IsAddExtLeading() );
687 
688  if ( !GetRefDevice() )
689  {
690  MapMode aMapMode(m_eObjUnit, Point(0,0), m_aObjUnit, m_aObjUnit);
691  pOutliner->SetRefMapMode(aMapMode);
692  }
693 }
694 
696 {
697  m_pRefOutDev=pDev;
699  ImpSetOutlinerDefaults( m_pHitTestOutliner.get() );
701 }
702 
704 {
705  if( isLocked() )
706  return;
707 
708  sal_uInt16 nCount=GetMasterPageCount();
709  sal_uInt16 nNum;
710  for (nNum=0; nNum<nCount; nNum++) {
712  }
713  nCount=GetPageCount();
714  for (nNum=0; nNum<nCount; nNum++) {
716  }
717 }
718 
719 /* steps over all available pages and sends notify messages to
720  all edge objects that are connected to other objects so that
721  they may reposition themselves
722 */
724 {
725  if( isLocked() )
726  return;
727 
728  sal_uInt16 nCount=GetMasterPageCount();
729  sal_uInt16 nNum;
730  for (nNum=0; nNum<nCount; nNum++)
731  {
733  }
734  nCount=GetPageCount();
735  for (nNum=0; nNum<nCount; nNum++)
736  {
738  }
739 }
740 
741 uno::Reference<embed::XStorage> SdrModel::GetDocumentStorage() const
742 {
743  uno::Reference<document::XStorageBasedDocument> const xSBD(
744  const_cast<SdrModel*>(this)->getUnoModel(), uno::UNO_QUERY);
745  if (!xSBD.is())
746  {
747  SAL_WARN("svx", "no UNO model");
748  return nullptr;
749  }
750  return xSBD->getDocumentStorage();
751 }
752 
753 uno::Reference<io::XInputStream>
754 SdrModel::GetDocumentStream( OUString const& rURL,
755  ::comphelper::LifecycleProxy const & rProxy) const
756 {
757  uno::Reference<embed::XStorage> const xStorage(GetDocumentStorage());
758  if (!xStorage.is())
759  {
760  SAL_WARN("svx", "no storage?");
761  return nullptr;
762  }
763  try {
764  uno::Reference<io::XStream> const xStream(
766  xStorage, rURL, embed::ElementModes::READ, rProxy));
767  return (xStream.is()) ? xStream->getInputStream() : nullptr;
768  }
769  catch (container::NoSuchElementException const&)
770  {
771  SAL_INFO("svx", "not found");
772  }
773  catch (uno::Exception const&)
774  {
775  TOOLS_WARN_EXCEPTION("svx", "");
776  }
777  return nullptr;
778 }
779 
780 // convert template attributes from the string into "hard" attributes
782 {
783  sal_uInt16 nCount=GetMasterPageCount();
784  sal_uInt16 nNum;
785  for (nNum=0; nNum<nCount; nNum++) {
787  }
788  nCount=GetPageCount();
789  for (nNum=0; nNum<nCount; nNum++) {
791  }
792 }
793 
795 {
798 }
799 
800 void SdrModel::SetDefaultFontHeight(sal_Int32 nVal)
801 {
802  if (nVal!=mnDefTextHgt) {
803  mnDefTextHgt=nVal;
805  }
806 }
807 
808 void SdrModel::SetDefaultTabulator(sal_uInt16 nVal)
809 {
810  if (m_nDefaultTabulator!=nVal) {
811  m_nDefaultTabulator=nVal;
812  Outliner& rOutliner=GetDrawOutliner();
813  rOutliner.SetDefTab(nVal);
816  }
817 }
818 
820 {
821  if(0 == m_aUIScale.GetNumerator() || 0 == m_aUIScale.GetDenominator())
822  {
823  m_aUIScale = Fraction(1,1);
824  }
825 
827 
829  o3tl::Length eTo;
830 
831  switch (m_eUIUnit)
832  {
833  case FieldUnit::CHAR:
834  case FieldUnit::LINE:
835  eTo = o3tl::Length::invalid;
836  break;
837  case FieldUnit::PERCENT:
839  [[fallthrough]];
840  default:
842  } // switch
843 
844  sal_Int32 nMul = 1, nDiv = 1;
845  if (eFrom != o3tl::Length::invalid && eTo != o3tl::Length::invalid)
846  {
847  const auto& [mul, div] = o3tl::getConversionMulDiv(eFrom, eTo);
848  nMul = mul;
849  nDiv = div;
850  }
851  // #i89872# take Unit of Measurement into account
852  if(1 != m_aUIScale.GetDenominator() || 1 != m_aUIScale.GetNumerator())
853  {
854  // divide by UIScale
855  nMul *= m_aUIScale.GetDenominator();
856  nDiv *= m_aUIScale.GetNumerator();
857  }
858 
859  // shorten trailing zeros for dividend
860  while(0 == (nMul % 10))
861  {
863  nMul /= 10;
864  }
865 
866  // shorten trailing zeros for divisor
867  while(0 == (nDiv % 10))
868  {
870  nDiv /= 10;
871  }
872 
873  // end preparations, set member values
874  m_aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv));
876 }
877 
878 void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac)
879 {
880  if (m_eObjUnit!=eMap || m_aObjUnit!=rFrac) {
881  m_eObjUnit=eMap;
882  m_aObjUnit=rFrac;
883  m_pItemPool->SetDefaultMetric(m_eObjUnit);
884  ImpSetUIUnit();
886  ImpSetOutlinerDefaults( m_pHitTestOutliner.get() );
888  }
889 }
890 
892 {
893  if (m_eObjUnit!=eMap) {
894  m_eObjUnit=eMap;
895  m_pItemPool->SetDefaultMetric(m_eObjUnit);
896  ImpSetUIUnit();
898  ImpSetOutlinerDefaults( m_pHitTestOutliner.get() );
900  }
901 }
902 
904 {
905  if (m_aObjUnit!=rFrac) {
906  m_aObjUnit=rFrac;
907  ImpSetUIUnit();
909  ImpSetOutlinerDefaults( m_pHitTestOutliner.get() );
911  }
912 }
913 
915 {
916  if (m_eUIUnit!=eUnit) {
917  m_eUIUnit=eUnit;
918  ImpSetUIUnit();
920  }
921 }
922 
923 void SdrModel::SetUIScale(const Fraction& rScale)
924 {
925  if (m_aUIScale!=rScale) {
926  m_aUIScale=rScale;
927  ImpSetUIUnit();
929  }
930 }
931 
932 void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale)
933 {
934  if (m_eUIUnit!=eUnit || m_aUIScale!=rScale) {
935  m_eUIUnit=eUnit;
936  m_aUIScale=rScale;
937  ImpSetUIUnit();
939  }
940 }
941 
943 {
944  switch(eUnit)
945  {
946  default:
947  case FieldUnit::NONE :
948  case FieldUnit::CUSTOM :
949  return OUString();
950  case FieldUnit::MM_100TH:
951  return OUString{"/100mm"};
952  case FieldUnit::MM :
953  return OUString{"mm"};
954  case FieldUnit::CM :
955  return OUString{"cm"};
956  case FieldUnit::M :
957  return OUString{"m"};
958  case FieldUnit::KM :
959  return OUString{"km"};
960  case FieldUnit::TWIP :
961  return OUString{"twip"};
962  case FieldUnit::POINT :
963  return OUString{"pt"};
964  case FieldUnit::PICA :
965  return OUString{"pica"};
966  case FieldUnit::INCH :
967  return OUString{"\""};
968  case FieldUnit::FOOT :
969  return OUString{"ft"};
970  case FieldUnit::MILE :
971  return OUString{"mile(s)"};
972  case FieldUnit::PERCENT:
973  return OUString{"%"};
974  }
975 }
976 
977 OUString SdrModel::GetMetricString(tools::Long nVal, bool bNoUnitChars, sal_Int32 nNumDigits) const
978 {
979  // #i22167#
980  // change to double precision usage to not lose decimal places
981  const bool bNegative(nVal < 0);
982  SvtSysLocale aSysLoc;
983  const LocaleDataWrapper& rLoc(aSysLoc.GetLocaleData());
984  double fLocalValue(double(nVal) * double(m_aUIUnitFact));
985 
986  if(bNegative)
987  {
988  fLocalValue = -fLocalValue;
989  }
990 
991  if( -1 == nNumDigits )
992  {
993  nNumDigits = LocaleDataWrapper::getNumDigits();
994  }
995 
996  sal_Int32 nDecimalMark(m_nUIUnitDecimalMark);
997 
998  if(nDecimalMark > nNumDigits)
999  {
1000  const sal_Int32 nDiff(nDecimalMark - nNumDigits);
1001  const double fFactor(pow(10.0, static_cast<int>(nDiff)));
1002 
1003  fLocalValue /= fFactor;
1004  nDecimalMark = nNumDigits;
1005  }
1006  else if(nDecimalMark < nNumDigits)
1007  {
1008  const sal_Int32 nDiff(nNumDigits - nDecimalMark);
1009  const double fFactor(pow(10.0, static_cast<int>(nDiff)));
1010 
1011  fLocalValue *= fFactor;
1012  nDecimalMark = nNumDigits;
1013  }
1014 
1015  OUStringBuffer aBuf;
1016  aBuf.append(static_cast<sal_Int32>(fLocalValue + 0.5));
1017 
1018  if(nDecimalMark < 0)
1019  {
1020  // negative nDecimalMark (decimal point) means: add zeros
1021  sal_Int32 nCount(-nDecimalMark);
1022 
1023  for(sal_Int32 i=0; i<nCount; i++)
1024  aBuf.append('0');
1025 
1026  nDecimalMark = 0;
1027  }
1028 
1029  // the second condition needs to be <= since inside this loop
1030  // also the leading zero is inserted.
1031  if (nDecimalMark > 0 && aBuf.getLength() <= nDecimalMark)
1032  {
1033  // if necessary, add zeros before the decimal point
1034  sal_Int32 nCount = nDecimalMark - aBuf.getLength();
1035 
1036  if(nCount >= 0 && LocaleDataWrapper::isNumLeadingZero())
1037  nCount++;
1038 
1039  for(sal_Int32 i=0; i<nCount; i++)
1040  aBuf.insert(0, '0');
1041  }
1042 
1043  const sal_Unicode cDec( rLoc.getNumDecimalSep()[0] );
1044 
1045  // insert the decimal mark character
1046  sal_Int32 nBeforeDecimalMark = aBuf.getLength() - nDecimalMark;
1047 
1048  if(nDecimalMark > 0)
1049  aBuf.insert(nBeforeDecimalMark, cDec);
1050 
1052  {
1053  sal_Int32 aPos=aBuf.getLength()-1;
1054 
1055  // Remove all trailing zeros.
1056  while (aPos>=0 && aBuf[aPos]=='0')
1057  --aPos;
1058 
1059  // Remove decimal if it's the last character.
1060  if (aPos>=0 && aBuf[aPos]==cDec)
1061  --aPos;
1062 
1063  // Adjust aPos to index first char to be truncated, if any
1064  if (++aPos<aBuf.getLength())
1065  aBuf.truncate(aPos);
1066  }
1067 
1068  // if necessary, add separators before every third digit
1069  if( nBeforeDecimalMark > 3 )
1070  {
1071  const OUString& aThoSep( rLoc.getNumThousandSep() );
1072  if ( !aThoSep.isEmpty() )
1073  {
1074  sal_Unicode cTho( aThoSep[0] );
1075  sal_Int32 i(nBeforeDecimalMark - 3);
1076 
1077  while(i > 0)
1078  {
1079  aBuf.insert(i, cTho);
1080  i -= 3;
1081  }
1082  }
1083  }
1084 
1085  if (aBuf.isEmpty())
1086  aBuf.append("0");
1087 
1088  if(bNegative)
1089  {
1090  aBuf.insert(0, "-");
1091  }
1092 
1093  if(!bNoUnitChars)
1094  aBuf.append(m_aUIUnitStr);
1095 
1096  return aBuf.makeStringAndClear();
1097 }
1098 
1100 {
1101  bool bNeg = nAngle < 0_deg100;
1102 
1103  if(bNeg)
1104  nAngle = -nAngle;
1105 
1106  OUStringBuffer aBuf;
1107  aBuf.append(static_cast<sal_Int32>(nAngle));
1108 
1109  SvtSysLocale aSysLoc;
1110  const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData();
1111  sal_Int32 nCount = 2;
1112 
1114  nCount++;
1115 
1116  while(aBuf.getLength() < nCount)
1117  aBuf.insert(0, '0');
1118 
1119  aBuf.insert(aBuf.getLength()-2, rLoc.getNumDecimalSep()[0]);
1120 
1121  if(bNeg)
1122  aBuf.insert(0, '-');
1123 
1124  aBuf.append(DEGREE_CHAR);
1125 
1126  return aBuf.makeStringAndClear();
1127 }
1128 
1130 {
1131  sal_Int32 nMul(rVal.GetNumerator());
1132  sal_Int32 nDiv(rVal.GetDenominator());
1133  bool bNeg {false};
1134 
1135  if (nDiv < 0)
1136  {
1137  bNeg = !bNeg;
1138  nDiv = -nDiv;
1139  }
1140 
1141  if (nMul < 0)
1142  {
1143  bNeg = !bNeg;
1144  nMul = -nMul;
1145  }
1146 
1147  sal_Int32 nPct = ((nMul*100) + nDiv/2)/nDiv;
1148 
1149  if (bNeg)
1150  nPct = -nPct;
1151 
1152  return OUString::number(nPct) + "%";
1153 }
1154 
1155 void SdrModel::SetChanged(bool bFlg)
1156 {
1157  mbChanged = bFlg;
1158 }
1159 
1160 void SdrModel::RecalcPageNums(bool bMaster)
1161 {
1162  if(bMaster)
1163  {
1164  sal_uInt16 nCount=sal_uInt16(maMasterPages.size());
1165  sal_uInt16 i;
1166  for (i=0; i<nCount; i++) {
1167  SdrPage* pPg = maMasterPages[i].get();
1168  pPg->SetPageNum(i);
1169  }
1170  m_bMPgNumsDirty=false;
1171  }
1172  else
1173  {
1174  sal_uInt16 nCount=sal_uInt16(maPages.size());
1175  sal_uInt16 i;
1176  for (i=0; i<nCount; i++) {
1177  SdrPage* pPg = maPages[i].get();
1178  pPg->SetPageNum(i);
1179  }
1180  m_bPagNumsDirty=false;
1181  }
1182 }
1183 
1184 void SdrModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
1185 {
1186  sal_uInt16 nCount = GetPageCount();
1187  if (nPos > nCount)
1188  nPos = nCount;
1189 
1190  maPages.insert(maPages.begin() + nPos, pPage);
1191  PageListChanged();
1192  pPage->SetInserted();
1193  pPage->SetPageNum(nPos);
1194 
1196  pPage->MakePageObjectsNamesUnique();
1197 
1198  if (nPos<nCount) m_bPagNumsDirty=true;
1199  SetChanged();
1200  SdrHint aHint(SdrHintKind::PageOrderChange, pPage);
1201  Broadcast(aHint);
1202 }
1203 
1204 void SdrModel::DeletePage(sal_uInt16 nPgNum)
1205 {
1206  RemovePage(nPgNum);
1207 }
1208 
1210 {
1211  rtl::Reference<SdrPage> pPg = maPages[nPgNum];
1212  maPages.erase(maPages.begin()+nPgNum);
1213  PageListChanged();
1214  if (pPg) {
1215  pPg->SetInserted(false);
1216  }
1217  m_bPagNumsDirty=true;
1218  SetChanged();
1219  SdrHint aHint(SdrHintKind::PageOrderChange, pPg.get());
1220  Broadcast(aHint);
1221  return pPg;
1222 }
1223 
1224 void SdrModel::MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
1225 {
1226  rtl::Reference<SdrPage> pPg = std::move(maPages[nPgNum]);
1227  if (pPg) {
1228  maPages.erase(maPages.begin()+nPgNum); // shortcut to avoid two broadcasts
1229  PageListChanged();
1230  pPg->SetInserted(false);
1231  InsertPage(pPg.get(), nNewPos);
1232  }
1233  else
1234  RemovePage(nPgNum);
1235 }
1236 
1237 void SdrModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
1238 {
1239  sal_uInt16 nCount=GetMasterPageCount();
1240  if (nPos>nCount) nPos=nCount;
1241  maMasterPages.insert(maMasterPages.begin()+nPos,pPage);
1243  pPage->SetInserted();
1244  pPage->SetPageNum(nPos);
1245 
1246  if (nPos<nCount) {
1247  m_bMPgNumsDirty=true;
1248  }
1249 
1250  SetChanged();
1251  SdrHint aHint(SdrHintKind::PageOrderChange, pPage);
1252  Broadcast(aHint);
1253 }
1254 
1255 void SdrModel::DeleteMasterPage(sal_uInt16 nPgNum)
1256 {
1257  RemoveMasterPage(nPgNum);
1258 }
1259 
1261 {
1262  rtl::Reference<SdrPage> pRetPg = std::move(maMasterPages[nPgNum]);
1263  maMasterPages.erase(maMasterPages.begin()+nPgNum);
1265 
1266  if(pRetPg)
1267  {
1268  // Now delete the links from the normal drawing pages to the deleted master page.
1269  sal_uInt16 nPageCnt(GetPageCount());
1270 
1271  for(sal_uInt16 np(0); np < nPageCnt; np++)
1272  {
1273  GetPage(np)->TRG_ImpMasterPageRemoved(*pRetPg);
1274  }
1275 
1276  pRetPg->SetInserted(false);
1277  }
1278 
1279  m_bMPgNumsDirty=true;
1280  SetChanged();
1281  SdrHint aHint(SdrHintKind::PageOrderChange, pRetPg.get());
1282  Broadcast(aHint);
1283  return pRetPg;
1284 }
1285 
1286 void SdrModel::MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
1287 {
1288  rtl::Reference<SdrPage> pPg = std::move(maMasterPages[nPgNum]);
1289  maMasterPages.erase(maMasterPages.begin()+nPgNum);
1291  if (pPg) {
1292  pPg->SetInserted(false);
1293  maMasterPages.insert(maMasterPages.begin()+nNewPos,pPg);
1295  }
1296  m_bMPgNumsDirty=true;
1297  SetChanged();
1298  SdrHint aHint(SdrHintKind::PageOrderChange, pPg.get());
1299  Broadcast(aHint);
1300 }
1301 
1302 
1303 void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
1304  sal_uInt16 nDestPos,
1305  bool bUndo, bool bMoveNoCopy)
1306 {
1307  if( bUndo && !IsUndoEnabled() )
1308  bUndo = false;
1309 
1310  if( bUndo )
1311  BegUndo(SvxResId(STR_UndoMergeModel));
1312 
1313  sal_uInt16 nPageCnt=GetPageCount();
1314  sal_uInt16 nMaxPage=nPageCnt;
1315 
1316  if (nMaxPage!=0)
1317  nMaxPage--;
1318  if (nFirstPageNum>nMaxPage)
1319  nFirstPageNum=nMaxPage;
1320  if (nLastPageNum>nMaxPage)
1321  nLastPageNum =nMaxPage;
1322  bool bReverse=nLastPageNum<nFirstPageNum;
1323  if (nDestPos>nPageCnt)
1324  nDestPos=nPageCnt;
1325 
1326  // at first, save the pointers of the affected pages in an array
1327  sal_uInt16 nPageNum=nFirstPageNum;
1328  sal_uInt16 nCopyCnt=((!bReverse)?(nLastPageNum-nFirstPageNum):(nFirstPageNum-nLastPageNum))+1;
1329  std::unique_ptr<SdrPage*[]> pPagePtrs(new SdrPage*[nCopyCnt]);
1330  sal_uInt16 nCopyNum;
1331  for(nCopyNum=0; nCopyNum<nCopyCnt; nCopyNum++)
1332  {
1333  pPagePtrs[nCopyNum]=GetPage(nPageNum);
1334  if (bReverse)
1335  nPageNum--;
1336  else
1337  nPageNum++;
1338  }
1339 
1340  // now copy the pages
1341  sal_uInt16 nDestNum=nDestPos;
1342  for (nCopyNum=0; nCopyNum<nCopyCnt; nCopyNum++)
1343  {
1344  rtl::Reference<SdrPage> pPg = pPagePtrs[nCopyNum];
1345  sal_uInt16 nPageNum2=pPg->GetPageNum();
1346  if (!bMoveNoCopy)
1347  {
1348  const SdrPage* pPg1=GetPage(nPageNum2);
1349 
1350  // Clone to local model
1351  pPg = pPg1->CloneSdrPage(*this);
1352 
1353  InsertPage(pPg.get(), nDestNum);
1354  if (bUndo)
1355  AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg));
1356  nDestNum++;
1357  }
1358  else
1359  {
1360  // TODO: Move is untested!
1361  if (nDestNum>nPageNum2)
1362  nDestNum--;
1363 
1364  if(bUndo)
1365  AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*GetPage(nPageNum2),nPageNum2,nDestNum));
1366 
1367  pPg=RemovePage(nPageNum2);
1368  InsertPage(pPg.get(), nDestNum);
1369  nDestNum++;
1370  }
1371 
1372  if(bReverse)
1373  nPageNum2--;
1374  else
1375  nPageNum2++;
1376  }
1377 
1378  pPagePtrs.reset();
1379  if(bUndo)
1380  EndUndo();
1381 }
1382 
1383 void SdrModel::Merge(SdrModel& rSourceModel,
1384  sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
1385  sal_uInt16 nDestPos,
1386  bool bMergeMasterPages, bool bAllMasterPages,
1387  bool bUndo, bool bTreadSourceAsConst)
1388 {
1389  if (&rSourceModel==this)
1390  {
1391  CopyPages(nFirstPageNum,nLastPageNum,nDestPos,bUndo,!bTreadSourceAsConst);
1392  return;
1393  }
1394 
1395  if( bUndo && !IsUndoEnabled() )
1396  bUndo = false;
1397 
1398  if (bUndo)
1399  BegUndo(SvxResId(STR_UndoMergeModel));
1400 
1401  sal_uInt16 nSrcPageCnt=rSourceModel.GetPageCount();
1402  sal_uInt16 nSrcMasterPageCnt=rSourceModel.GetMasterPageCount();
1403  sal_uInt16 nDstMasterPageCnt=GetMasterPageCount();
1404  bool bInsPages=(nFirstPageNum<nSrcPageCnt || nLastPageNum<nSrcPageCnt);
1405  sal_uInt16 nMaxSrcPage=nSrcPageCnt; if (nMaxSrcPage!=0) nMaxSrcPage--;
1406  if (nFirstPageNum>nMaxSrcPage) nFirstPageNum=nMaxSrcPage;
1407  if (nLastPageNum>nMaxSrcPage) nLastPageNum =nMaxSrcPage;
1408  bool bReverse=nLastPageNum<nFirstPageNum;
1409 
1410  std::unique_ptr<sal_uInt16[]> pMasterMap;
1411  std::unique_ptr<bool[]> pMasterNeed;
1412  sal_uInt16 nMasterNeed=0;
1413  if (bMergeMasterPages && nSrcMasterPageCnt!=0) {
1414  // determine which MasterPages from rSrcModel we need
1415  pMasterMap.reset(new sal_uInt16[nSrcMasterPageCnt]);
1416  pMasterNeed.reset(new bool[nSrcMasterPageCnt]);
1417  memset(pMasterMap.get(),0xFF,nSrcMasterPageCnt*sizeof(sal_uInt16));
1418  if (bAllMasterPages) {
1419  memset(pMasterNeed.get(), true, nSrcMasterPageCnt * sizeof(bool));
1420  } else {
1421  memset(pMasterNeed.get(), false, nSrcMasterPageCnt * sizeof(bool));
1422  sal_uInt16 nStart= bReverse ? nLastPageNum : nFirstPageNum;
1423  sal_uInt16 nEnd= bReverse ? nFirstPageNum : nLastPageNum;
1424  for (sal_uInt16 i=nStart; i<=nEnd; i++) {
1425  const SdrPage* pPg=rSourceModel.GetPage(i);
1426  if(pPg->TRG_HasMasterPage())
1427  {
1428  SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
1429  sal_uInt16 nMPgNum(rMasterPage.GetPageNum());
1430 
1431  if(nMPgNum < nSrcMasterPageCnt)
1432  {
1433  pMasterNeed[nMPgNum] = true;
1434  }
1435  }
1436  }
1437  }
1438  // now determine the Mapping of the MasterPages
1439  sal_uInt16 nCurrentMaPagNum=nDstMasterPageCnt;
1440  for (sal_uInt16 i=0; i<nSrcMasterPageCnt; i++) {
1441  if (pMasterNeed[i]) {
1442  pMasterMap[i]=nCurrentMaPagNum;
1443  nCurrentMaPagNum++;
1444  nMasterNeed++;
1445  }
1446  }
1447  }
1448 
1449  // get the MasterPages
1450  if (pMasterMap && pMasterNeed && nMasterNeed!=0) {
1451  for (sal_uInt16 i=nSrcMasterPageCnt; i>0;) {
1452  i--;
1453  if (pMasterNeed[i])
1454  {
1455  // Always Clone to new model
1456  const SdrPage* pPg1(rSourceModel.GetMasterPage(i));
1457  rtl::Reference<SdrPage> pPg = pPg1->CloneSdrPage(*this);
1458 
1459  if(!bTreadSourceAsConst)
1460  {
1461  // if requested, delete original/modify original model
1462  rSourceModel.RemoveMasterPage(i);
1463  }
1464 
1465  if (pPg!=nullptr) {
1466  // Now append all of them to the end of the DstModel.
1467  // Don't use InsertMasterPage(), because everything is
1468  // inconsistent until all are in.
1469  maMasterPages.insert(maMasterPages.begin()+nDstMasterPageCnt, pPg);
1471  pPg->SetInserted();
1472  m_bMPgNumsDirty=true;
1473  if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
1474  } else {
1475  OSL_FAIL("SdrModel::Merge(): MasterPage not found in SourceModel.");
1476  }
1477  }
1478  }
1479  }
1480 
1481  // get the drawing pages
1482  if (bInsPages) {
1483  sal_uInt16 nSourcePos=nFirstPageNum;
1484  sal_uInt16 nMergeCount=sal_uInt16(std::abs(static_cast<tools::Long>(static_cast<tools::Long>(nFirstPageNum)-nLastPageNum))+1);
1485  if (nDestPos>GetPageCount()) nDestPos=GetPageCount();
1486  while (nMergeCount>0)
1487  {
1488  // Always Clone to new model
1489  const SdrPage* pPg1(rSourceModel.GetPage(nSourcePos));
1490  rtl::Reference<SdrPage> pPg = pPg1->CloneSdrPage(*this);
1491 
1492  if(!bTreadSourceAsConst)
1493  {
1494  // if requested, delete original/modify original model
1495  rSourceModel.RemovePage(nSourcePos);
1496  }
1497 
1498  if (pPg!=nullptr) {
1499  InsertPage(pPg.get(),nDestPos);
1500  if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
1501 
1502  if(pPg->TRG_HasMasterPage())
1503  {
1504  SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
1505  sal_uInt16 nMaPgNum(rMasterPage.GetPageNum());
1506 
1507  if (bMergeMasterPages)
1508  {
1509  sal_uInt16 nNewNum(0xFFFF);
1510 
1511  if(pMasterMap)
1512  {
1513  nNewNum = pMasterMap[nMaPgNum];
1514  }
1515 
1516  if(nNewNum != 0xFFFF)
1517  {
1518  // tdf#90357 here pPg and the to-be-set new masterpage are parts of the new model
1519  // already, but the currently set masterpage is part of the old model. Remove master
1520  // page from already cloned page to prevent creating wrong undo action that can
1521  // eventually crash the app.
1522  // Do *not* remove it directly after cloning - the old masterpage is still needed
1523  // later to find the new to-be-set masterpage.
1524  pPg->TRG_ClearMasterPage();
1525 
1526  if(bUndo)
1527  {
1528  AddUndo(GetSdrUndoFactory().CreateUndoPageChangeMasterPage(*pPg));
1529  }
1530 
1531  pPg->TRG_SetMasterPage(*GetMasterPage(nNewNum));
1532  }
1533  DBG_ASSERT(nNewNum!=0xFFFF,"SdrModel::Merge(): Something is crooked with the mapping of the MasterPages.");
1534  } else {
1535  if (nMaPgNum>=nDstMasterPageCnt) {
1536  // This is outside of the original area of the MasterPage of the DstModel.
1537  pPg->TRG_ClearMasterPage();
1538  }
1539  }
1540  }
1541 
1542  } else {
1543  OSL_FAIL("SdrModel::Merge(): Drawing page not found in SourceModel.");
1544  }
1545  nDestPos++;
1546  if (bReverse) nSourcePos--;
1547  else if (bTreadSourceAsConst) nSourcePos++;
1548  nMergeCount--;
1549  }
1550  }
1551 
1552  pMasterMap.reset();
1553  pMasterNeed.reset();
1554 
1555  m_bMPgNumsDirty=true;
1556  m_bPagNumsDirty=true;
1557 
1558  SetChanged();
1559  // TODO: Missing: merging and mapping of layers
1560  // at the objects as well as at the MasterPageDescriptors
1561  if (bUndo) EndUndo();
1562 }
1563 
1565 {
1566  if (!bPreview && m_bStarDrawPreviewMode && GetPageCount())
1567  {
1568  // Resetting is not allowed, because the Model might not be loaded completely
1569  SAL_WARN("svx", "SdrModel::SetStarDrawPreviewMode(): Resetting not allowed, because Model might not be complete.");
1570  }
1571  else
1572  {
1573  m_bStarDrawPreviewMode = bPreview;
1574  }
1575 }
1576 
1577 void SdrModel::SetTheme(std::unique_ptr<svx::Theme> pTheme) { mpImpl->mpTheme = std::move(pTheme); }
1578 
1579 svx::Theme* SdrModel::GetTheme() { return mpImpl->mpTheme.get(); }
1580 
1581 uno::Reference< uno::XInterface > const & SdrModel::getUnoModel()
1582 {
1583  if( !mxUnoModel.is() )
1585 
1586  return mxUnoModel;
1587 }
1588 
1589 void SdrModel::setUnoModel( const css::uno::Reference< css::uno::XInterface >& xModel )
1590 {
1591  mxUnoModel = xModel;
1592 }
1593 
1595  const Size& /*rNewSize*/,
1596  tools::Long /*nLeft*/,
1597  tools::Long /*nRight*/,
1598  tools::Long /*nUpper*/,
1599  tools::Long /*nLower*/)
1600 {
1601  // base implementation does currently nothing. It may be added if needed,
1602  // but we are on SdrModel level here, thus probably have not enough information
1603  // to do this for higher-level (derived) Models (e.g. Draw/Impress)
1604 }
1605 
1606 uno::Reference< uno::XInterface > SdrModel::createUnoModel()
1607 {
1608  OSL_FAIL( "SdrModel::createUnoModel() - base implementation should not be called!" );
1609  css::uno::Reference< css::uno::XInterface > xInt;
1610  return xInt;
1611 }
1612 
1613 void SdrModel::setLock( bool bLock )
1614 {
1615  if( mbModelLocked != bLock )
1616  {
1617  // #i120437# need to set first, else ImpReformatAllEdgeObjects will do nothing
1618  mbModelLocked = bLock;
1619 
1620  if( !bLock )
1621  {
1623  }
1624  }
1625 }
1626 
1627 
1628 void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModelel )
1629 {
1630  assert(pNewModelel != nullptr);
1631  if( !(pSourceSet && pDestSet && (pSourceSet != pDestSet )) )
1632  return;
1633 
1634  SfxWhichIter aWhichIter(*pSourceSet);
1635  sal_uInt16 nWhich(aWhichIter.FirstWhich());
1636  const SfxPoolItem *pPoolItem;
1637 
1638  while(nWhich)
1639  {
1640  if(SfxItemState::SET == pSourceSet->GetItemState(nWhich, false, &pPoolItem))
1641  {
1642  std::unique_ptr<SfxPoolItem> pResultItem;
1643 
1644  switch( nWhich )
1645  {
1646  case XATTR_FILLBITMAP:
1647  pResultItem = static_cast<const XFillBitmapItem*>(pPoolItem)->checkForUniqueItem( pNewModelel );
1648  break;
1649  case XATTR_LINEDASH:
1650  pResultItem = static_cast<const XLineDashItem*>(pPoolItem)->checkForUniqueItem( pNewModelel );
1651  break;
1652  case XATTR_LINESTART:
1653  pResultItem = static_cast<const XLineStartItem*>(pPoolItem)->checkForUniqueItem( pNewModelel );
1654  break;
1655  case XATTR_LINEEND:
1656  pResultItem = static_cast<const XLineEndItem*>(pPoolItem)->checkForUniqueItem( pNewModelel );
1657  break;
1658  case XATTR_FILLGRADIENT:
1659  pResultItem = static_cast<const XFillGradientItem*>(pPoolItem)->checkForUniqueItem( pNewModelel );
1660  break;
1662  // allow all kinds of XFillFloatTransparenceItem to be set
1663  pResultItem = static_cast<const XFillFloatTransparenceItem*>(pPoolItem)->checkForUniqueItem( pNewModelel );
1664  break;
1665  case XATTR_FILLHATCH:
1666  pResultItem = static_cast<const XFillHatchItem*>(pPoolItem)->checkForUniqueItem( pNewModelel );
1667  break;
1668  }
1669 
1670  // set item
1671  if( pResultItem )
1672  {
1673  pDestSet->Put(*pResultItem);
1674  pResultItem.reset();
1675  }
1676  else
1677  pDestSet->Put(*pPoolItem);
1678  }
1679  nWhich = aWhichIter.NextWhich();
1680  }
1681 }
1682 
1683 
1684 void SdrModel::SetForbiddenCharsTable(const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars)
1685 {
1686  mpForbiddenCharactersTable = xForbiddenChars;
1687 
1689  ImpSetOutlinerDefaults( m_pHitTestOutliner.get() );
1690 }
1691 
1692 
1694 {
1695  if( nType != mnCharCompressType )
1696  {
1697  mnCharCompressType = nType;
1699  ImpSetOutlinerDefaults( m_pHitTestOutliner.get() );
1700  }
1701 }
1702 
1704 {
1705  if( mbKernAsianPunctuation != bEnabled )
1706  {
1707  mbKernAsianPunctuation = bEnabled;
1709  ImpSetOutlinerDefaults( m_pHitTestOutliner.get() );
1710  }
1711 }
1712 
1713 void SdrModel::SetAddExtLeading( bool bEnabled )
1714 {
1715  if( mbAddExtLeading != bEnabled )
1716  {
1717  mbAddExtLeading = bEnabled;
1719  ImpSetOutlinerDefaults( m_pHitTestOutliner.get() );
1720  }
1721 }
1722 
1724 {
1725  mpImpl->mbAnchoredTextOverflowLegacy = bEnabled;
1726 }
1727 
1729 {
1730  return mpImpl->mbAnchoredTextOverflowLegacy;
1731 }
1732 
1734 {
1736 }
1737 
1738 std::unique_ptr<SdrOutliner> SdrModel::createOutliner( OutlinerMode nOutlinerMode )
1739 {
1740  if( !mpOutlinerCache )
1741  mpOutlinerCache.reset(new SdrOutlinerCache(this));
1742 
1743  return mpOutlinerCache->createOutliner( nOutlinerMode );
1744 }
1745 
1746 std::vector<SdrOutliner*> SdrModel::GetActiveOutliners() const
1747 {
1748  std::vector< SdrOutliner* > aRet(mpOutlinerCache ? mpOutlinerCache->GetActiveOutliners() : std::vector< SdrOutliner* >());
1749  aRet.push_back(m_pDrawOutliner.get());
1750  aRet.push_back(m_pHitTestOutliner.get());
1751 
1752  return aRet;
1753 }
1754 
1755 void SdrModel::disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner )
1756 {
1757  if( mpOutlinerCache )
1758  mpOutlinerCache->disposeOutliner( std::move(pOutliner) );
1759 }
1760 
1762 {
1763  return SVX_NUM_ARABIC;
1764 }
1765 
1766 void SdrModel::ReadUserDataSequenceValue(const css::beans::PropertyValue* pValue)
1767 {
1768  if (pValue->Name == "AnchoredTextOverflowLegacy")
1769  {
1770  bool bBool = false;
1771  if (pValue->Value >>= bBool)
1772  {
1773  mpImpl->mbAnchoredTextOverflowLegacy = bBool;
1774  }
1775  }
1776 }
1777 
1778 template <typename T>
1779 static void addPair(std::vector< std::pair< OUString, Any > >& aUserData, const OUString& name, const T val)
1780 {
1781  aUserData.push_back(std::pair< OUString, Any >(name, css::uno::makeAny(val)));
1782 }
1783 
1784 void SdrModel::WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues)
1785 {
1786  std::vector< std::pair< OUString, Any > > aUserData;
1787  addPair(aUserData, "AnchoredTextOverflowLegacy", IsAnchoredTextOverflowLegacy());
1788 
1789  const sal_Int32 nOldLength = rValues.getLength();
1790  rValues.realloc(nOldLength + aUserData.size());
1791 
1792  css::beans::PropertyValue* pValue = &(rValues.getArray()[nOldLength]);
1793 
1794  for (const auto &aIter : aUserData)
1795  {
1796  pValue->Name = aIter.first;
1797  pValue->Value = aIter.second;
1798  ++pValue;
1799  }
1800 }
1801 
1802 const SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum) const
1803 {
1804  return nPgNum < maPages.size() ? maPages[nPgNum].get() : nullptr;
1805 }
1806 
1807 SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum)
1808 {
1809  return nPgNum < maPages.size() ? maPages[nPgNum].get() : nullptr;
1810 }
1811 
1812 sal_uInt16 SdrModel::GetPageCount() const
1813 {
1814  return sal_uInt16(maPages.size());
1815 }
1816 
1818 {
1819 }
1820 
1822 {
1823  return m_pTextChain.get();
1824 }
1825 
1826 const SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum) const
1827 {
1828  DBG_ASSERT(nPgNum < maMasterPages.size(), "SdrModel::GetMasterPage: Access out of range (!)");
1829  return maMasterPages[nPgNum].get();
1830 }
1831 
1833 {
1834  DBG_ASSERT(nPgNum < maMasterPages.size(), "SdrModel::GetMasterPage: Access out of range (!)");
1835  return maMasterPages[nPgNum].get();
1836 }
1837 
1839 {
1840  return sal_uInt16(maMasterPages.size());
1841 }
1842 
1844 {
1845 }
1846 
1848 {
1849  mpImpl->mpUndoManager = pUndoManager;
1850 }
1851 
1853 {
1854  return mpImpl->mpUndoManager;
1855 }
1856 
1858 {
1859  if( !mpImpl->mpUndoFactory )
1860  mpImpl->mpUndoFactory = new SdrUndoFactory;
1861  return *mpImpl->mpUndoFactory;
1862 }
1863 
1865 {
1866  if( pUndoFactory && (pUndoFactory != mpImpl->mpUndoFactory) )
1867  {
1868  delete mpImpl->mpUndoFactory;
1869  mpImpl->mpUndoFactory = pUndoFactory;
1870  }
1871 }
1872 
1874 {
1875  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SdrModel"));
1876  (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1877 
1878  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("maMasterPages"));
1879  for (size_t i = 0; i < maMasterPages.size(); ++i)
1880  {
1881  if (const SdrPage* pPage = maMasterPages[i].get())
1882  {
1883  pPage->dumpAsXml(pWriter);
1884  }
1885  }
1886  (void)xmlTextWriterEndElement(pWriter);
1887 
1888  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("maPages"));
1889  for (size_t i = 0; i < maPages.size(); ++i)
1890  {
1891  if (const SdrPage* pPage = maPages[i].get())
1892  {
1893  pPage->dumpAsXml(pWriter);
1894  }
1895  }
1896  (void)xmlTextWriterEndElement(pWriter);
1897 
1898  if (mpImpl->mpTheme)
1899  {
1900  mpImpl->mpTheme->dumpAsXml(pWriter);
1901  }
1902 
1903  (void)xmlTextWriterEndElement(pWriter);
1904 }
1905 
1906 const css::uno::Sequence< sal_Int8 >& SdrModel::getUnoTunnelId()
1907 {
1908  static const comphelper::UnoIdInit theSdrModelUnoTunnelImplementationId;
1909  return theSdrModelUnoTunnelImplementationId.getSeq();
1910 }
1911 
1912 
1915  meHint(eNewHint),
1916  mpObj(nullptr),
1917  mpPage(nullptr)
1918 {
1919 }
1920 
1921 SdrHint::SdrHint(SdrHintKind eNewHint, const SdrObject& rNewObj)
1923  meHint(eNewHint),
1924  mpObj(&rNewObj),
1925  mpPage(rNewObj.getSdrPageFromSdrObject())
1926 {
1927 }
1928 
1929 SdrHint::SdrHint(SdrHintKind eNewHint, const SdrPage* pPage)
1931  meHint(eNewHint),
1932  mpObj(nullptr),
1933  mpPage(pPage)
1934 {
1935 }
1936 
1937 SdrHint::SdrHint(SdrHintKind eNewHint, const SdrObject& rNewObj, const SdrPage* pPage)
1939  meHint(eNewHint),
1940  mpObj(&rNewObj),
1941  mpPage(pPage)
1942 {
1943 }
1944 
1945 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrOutliner & GetDrawOutliner(const SdrTextObj *pObj=nullptr) const
Definition: svdmodel.cxx:651
std::deque< std::unique_ptr< SfxUndoAction > > m_aUndoStack
Definition: svdmodel.hxx:197
SdrPage & TRG_GetMasterPage() const
Definition: svdpage.cxx:1653
virtual rtl::Reference< SdrPage > RemoveMasterPage(sal_uInt16 nPgNum)
Definition: svdmodel.cxx:1260
void SetCharSet(rtl_TextEncoding _eEncoding)
std::vector< rtl::Reference< SdrPage > > maPages
Definition: svdmodel.hxx:174
bool IsAnchoredTextOverflowLegacy() const
Definition: svdmodel.cxx:1728
void MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
Definition: svdmodel.cxx:1286
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
FieldUnit
SfxHintId
TextChain * GetTextChain() const
Definition: svdmodel.cxx:1821
SdrOutliner & GetChainingOutliner(const SdrTextObj *pObj) const
Definition: svdmodel.cxx:657
void SetStyleName(const OUString &rStyleName)
OutlinerMode
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
std::unique_ptr< svx::Theme > mpTheme
Definition: svdmodel.cxx:87
SVX_DLLPRIVATE void ImpSetUIUnit()
Definition: svdmodel.cxx:819
const OUString & GetFamilyName() const
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)
constexpr const sal_Unicode DEGREE_CHAR
Definition: svdmodel.hxx:98
virtual rtl::Reference< SdrPage > AllocPage(bool bMasterPage)
Definition: svdmodel.cxx:593
struct _xmlTextWriter * xmlTextWriterPtr
#define LANGUAGE_ENGLISH_US
bool IsKernAsianPunctuation() const
Definition: svdmodel.hxx:568
Global default settings for the DrawingEngine.
Definition: svdetc.hxx:65
static void addPair(std::vector< std::pair< OUString, Any > > &aUserData, const OUString &name, const T val)
Definition: svdmodel.cxx:1779
virtual void InsertMasterPage(SdrPage *pPage, sal_uInt16 nPos=0xFFFF)
Definition: svdmodel.cxx:1237
void SetPitch(FontPitch _ePitch)
LanguageType getLanguageType(bool bResolveSystem=true) const
void SetForbiddenCharsTable(const std::shared_ptr< SvxForbiddenCharactersTable > &xForbiddenChars)
Definition: svdmodel.cxx:1684
static OUString GetAngleString(Degree100 nAngle)
Definition: svdmodel.cxx:1099
virtual css::uno::Reference< css::uno::XInterface > createUnoModel()
Definition: svdmodel.cxx:1606
std::unique_ptr< SdrUndoGroup > m_pCurrentUndoGroup
Definition: svdmodel.hxx:199
long Long
virtual void InsertPage(SdrPage *pPage, sal_uInt16 nPos=0xFFFF)
Definition: svdmodel.cxx:1184
static const AllSettings & GetSettings()
virtual rtl::Reference< SdrPage > CloneSdrPage(SdrModel &rTargetModel) const
Definition: svdpage.cxx:1416
virtual void adaptSizeAndBorderForAllPages(const Size &rNewSize, tools::Long nLeft=0, tools::Long nRight=0, tools::Long nUpper=0, tools::Long nLower=0)
Definition: svdmodel.cxx:1594
virtual void Undo()
SdrHintKind
Definition: svdmodel.hxx:101
rtl::Reference< SfxStyleSheetBasePool > mxStyleSheetPool
Definition: svdmodel.hxx:193
void RecalcPageNums(bool bMaster)
Definition: svdmodel.cxx:1160
std::unique_ptr< SdrOutlinerCache > mpOutlinerCache
Definition: svdmodel.hxx:223
aBuf
void SetFamily(FontFamily _eFamily)
void MakePageObjectsNamesUnique()
Definition: svdpage.cxx:1689
Color GetFontColor()
Definition: svdetc.hxx:68
void SetSwapGraphics()
Definition: svdmodel.cxx:245
sal_uInt16 FirstWhich()
constexpr o3tl::Length FieldToO3tlLength(FieldUnit eU, o3tl::Length ePixelValue=o3tl::Length::px)
static sal_uInt16 getNumDigits()
static bool isNumLeadingZero()
SdrOnOffItem makeSdrTextWordWrapItem(bool bAuto)
Definition: sdasitm.hxx:96
void SetCharCompressType(CharCompressType nType)
Definition: svdmodel.cxx:1693
const SdrPage * GetMasterPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1826
css::uno::Reference< css::uno::XInterface > const & getUnoModel()
Definition: svdmodel.cxx:1581
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
static void Free(SdrObject *&_rpObject)
Definition: svdobj.cxx:472
bool m_bMPgNumsDirty
Definition: svdmodel.hxx:205
void SetSdrUndoManager(SfxUndoManager *pUndoManager)
application can set its own undo manager, BegUndo, EndUndo and AddUndoAction calls are routed to this...
Definition: svdmodel.cxx:1847
void SetRefMapMode(const MapMode &)
void BurnInStyleSheetAttributes()
Definition: svdmodel.cxx:781
void BegUndo()
Definition: svdmodel.cxx:369
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
virtual void MasterPageListChanged()
Definition: svdmodel.cxx:1843
sal_uInt16 m_nUndoLevel
Definition: svdmodel.hxx:200
bool mbMakePageObjectsNamesUnique
Definition: svdmodel.hxx:267
OutputDevice * GetRefDevice() const
Definition: svdmodel.hxx:333
FontFamily GetFamilyType()
sal_uInt16 NextWhich()
SvxNumType
void SetFamilyName(const OUString &rFamilyName)
NONE
static rtl::Reference< SfxItemPool > CreatePool()
void SetDefaultTabulator(sal_uInt16 nVal)
Definition: svdmodel.cxx:808
sal_uInt16 sal_Unicode
const LocaleDataWrapper & GetLocaleData() const
std::unique_ptr< SdrOutliner > m_pDrawOutliner
Definition: svdmodel.hxx:188
VclPtr< OutputDevice > m_pRefOutDev
Definition: svdmodel.hxx:192
SdrRepeatFunc
Definition: svdtypes.hxx:65
void EnableUndo(bool bEnable)
enables (true) or disables (false) recording of undo actions If undo actions are added while undo is ...
Definition: svdmodel.cxx:522
Reference< XInputStream > xStream
void Undo()
Definition: svdmodel.cxx:285
void ReformatAllTextObjects()
Definition: svdmodel.cxx:1733
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
void SetTheme(std::unique_ptr< svx::Theme > pTheme)
Definition: svdmodel.cxx:1577
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdmodel.cxx:503
static bool IsFuzzing()
int nCount
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
void CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum, sal_uInt16 nDestPos, bool bUndo, bool bMoveNoCopy)
Definition: svdmodel.cxx:1303
css::uno::Reference< css::uno::XInterface > mxUnoModel
Definition: svdmodel.hxx:264
SVX_NUM_ARABIC
static SfxViewShell * Current()
std::function< void(std::unique_ptr< SdrUndoAction >)> m_aUndoLink
Definition: svdmodel.hxx:175
Fraction m_aObjUnit
Definition: svdmodel.hxx:177
void SetKernAsianPunctuation(bool bEnabled)
bool isLocked() const
Definition: svdmodel.hxx:558
SdrModel(const SdrModel &rSrcModel)=delete
bool mbUndoEnabled
Definition: svdmodel.hxx:202
void ReformatAllTextObjects()
Definition: svdpage.cxx:770
std::unique_ptr< SdrOutliner > createOutliner(OutlinerMode nOutlinerMode)
Definition: svdmodel.cxx:1738
sal_uInt32 m_nMaxUndoCount
Definition: svdmodel.hxx:215
SfxUndoManager * mpUndoManager
Definition: svdmodel.cxx:84
SVX_DLLPRIVATE void ImpPostUndoAction(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdmodel.cxx:348
virtual void SetChanged(bool bFlg=true)
Definition: svdmodel.cxx:1155
virtual rtl::Reference< SdrPage > RemovePage(sal_uInt16 nPgNum)
Definition: svdmodel.cxx:1209
svx::Theme * GetTheme()
Definition: svdmodel.cxx:1579
int m_nUIUnitDecimalMark
Definition: svdmodel.hxx:183
void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &rValues)
Definition: svdmodel.cxx:1784
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdmodel.cxx:1873
const LanguageTag & GetLanguageTag() const
void ReformatAllEdgeObjects()
#103122# reformats all edge objects that are connected to other objects
Definition: svdpage.cxx:779
const css::uno::Sequence< sal_Int8 > & getSeq() const
void setUnoModel(const css::uno::Reference< css::uno::XInterface > &xModel)
Definition: svdmodel.cxx:1589
virtual void DeletePage(sal_uInt16 nPgNum)
Definition: svdmodel.cxx:1204
void SetPageNum(sal_uInt16 nNew)
Definition: svdpage.cxx:1586
std::unordered_set< const SdrObject * > maAllIncarnatedObjects
Definition: svdmodel.hxx:170
bool mbKernAsianPunctuation
Definition: svdmodel.hxx:230
const OUString & getNumDecimalSep() const
bool m_bReadOnly
Definition: svdmodel.hxx:207
#define TOOLS_WARN_EXCEPTION(area, stream)
void SetTextDefaults() const
Definition: svdmodel.cxx:598
std::unique_ptr< TextChain > m_pTextChain
Definition: svdmodel.hxx:217
static bool isNumTrailingZeros()
void SetScaleFraction(const Fraction &rFrac)
Definition: svdmodel.cxx:903
FontPitch GetPitch()
sal_uInt16 GetMasterPageCount() const
Definition: svdmodel.cxx:1838
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
std::vector< SdrOutliner * > GetActiveOutliners() const
Definition: svdmodel.cxx:1746
#define DBG_ASSERT(sCon, aError)
void Repeat(SfxRepeatTarget &)
Definition: svdmodel.cxx:329
SfxUndoManager * GetSdrUndoManager() const
Definition: svdmodel.cxx:1852
int i
FPDF_PAGE mpPage
static OUString GetUnitString(FieldUnit eUnit)
Definition: svdmodel.cxx:942
rtl::Reference< SfxItemPool > m_pItemPool
Definition: svdmodel.hxx:186
bool IsAddExtLeading() const
Definition: svdmodel.hxx:571
CharCompressType
SVX_DLLPRIVATE void ImpCreateTables(bool bDisablePropertyFiles)
Definition: svdmodel.cxx:546
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
bool IsUndoEnabled() const
returns true if undo is currently enabled This returns false if undo was disabled using EnableUndo( f...
Definition: svdmodel.cxx:534
void SetRefDevice(OutputDevice *pDev)
Definition: svdmodel.cxx:695
virtual SvxNumType GetPageNumType() const
returns the numbering type that is used to format page fields in drawing shapes
Definition: svdmodel.cxx:1761
bool mbAddExtLeading
Definition: svdmodel.hxx:231
void SetReadOnly(bool bYes)
Definition: svdmodel.cxx:255
bool m_bStarDrawPreviewMode
Definition: svdmodel.hxx:211
void RefDeviceChanged()
Definition: svdmodel.cxx:794
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1802
SVX_DLLPRIVATE void ImpReformatAllEdgeObjects()
Definition: svdmodel.cxx:723
const SdrTextObj * GetFormattingTextObj() const
Definition: svdmodel.cxx:663
The SdrUndoFactory can be set and retrieved from the SdrModel.
Definition: svdundo.hxx:718
static void MigrateItemSet(const SfxItemSet *pSourceSet, SfxItemSet *pDestSet, SdrModel *pNewModel)
copies the items from the source set to the destination set.
Definition: svdmodel.cxx:1628
void SetSdrUndoFactory(SdrUndoFactory *pUndoFactory)
applications can set their own undo factory to override creation of undo actions. ...
Definition: svdmodel.cxx:1864
Fraction GetMapFraction()
Definition: svdetc.hxx:82
void SetUndoComment(const OUString &rComment)
Definition: svdmodel.cxx:472
Fraction m_aUIScale
Definition: svdmodel.hxx:180
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
Definition: xtable.cxx:315
static bool bInit
Definition: objfac3d.cxx:30
void DeleteMasterPage(sal_uInt16 nPgNum)
Definition: svdmodel.cxx:1255
void SetDefaultFontHeight(sal_Int32 nVal)
Definition: svdmodel.cxx:800
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:495
bool m_bSwapGraphics
Definition: svdmodel.hxx:209
std::shared_ptr< SvxForbiddenCharactersTable > mpForbiddenCharactersTable
Definition: svdmodel.hxx:221
Abstract DrawObject.
Definition: svdobj.hxx:260
void SetKernAsianPunctuation(bool bEnabled)
Definition: svdmodel.cxx:1703
SdrHint(SdrHintKind eNewHint)
Definition: svdmodel.cxx:1913
sal_uInt16 m_nDefaultTabulator
Definition: svdmodel.hxx:214
virtual ~SdrModel() override
Definition: svdmodel.cxx:181
SdrUndoFactory & GetSdrUndoFactory() const
returns the models undo factory.
Definition: svdmodel.cxx:1857
static css::uno::Reference< css::io::XStream > GetStreamAtPackageURL(const css::uno::Reference< css::embed::XStorage > &xStorage, const OUString &rURL, sal_uInt32 const nOpenMode, LifecycleProxy const &rNastiness)
bool mbInDestruction
Definition: svdmodel.hxx:232
SdrUndoFactory * mpUndoFactory
Definition: svdmodel.cxx:85
void SetStarDrawPreviewMode(bool bPreview)
Definition: svdmodel.cxx:1564
Aggregation of arbitrarily many UndoActions to a single UndoAction.
Definition: svdundo.hxx:88
MapUnit GetMapUnit()
Definition: svdetc.hxx:79
bool mbModelLocked
Definition: svdmodel.hxx:229
void EndUndo()
Definition: svdmodel.cxx:440
std::vector< rtl::Reference< SdrPage > > maMasterPages
Definition: svdmodel.hxx:173
void SetDefTab(sal_uInt16 nTab)
void setLock(bool bLock)
Definition: svdmodel.cxx:1613
const std::shared_ptr< SvxForbiddenCharactersTable > & GetForbiddenCharsTable() const
Definition: svdmodel.hxx:562
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
MapUnit m_eObjUnit
Definition: svdmodel.hxx:178
void SetUIScale(const Fraction &rScale)
Definition: svdmodel.cxx:923
void Broadcast(const SfxHint &rHint)
virtual bool IsReadOnly() const
Definition: svdmodel.cxx:250
void SetInserted(bool bNew=true)
Definition: svdpage.cxx:1736
bool HasRedoActions() const
Definition: svdmodel.cxx:280
bool mbAnchoredTextOverflowLegacy
Definition: svdmodel.cxx:86
constexpr TypedWhichId< XFillFloatTransparenceItem > XATTR_FILLFLOATTRANSPARENCE(XATTR_FILL_FIRST+11)
A named theme has a named color set.
Definition: ColorSets.hxx:73
void BurnInStyleSheetAttributes()
convert attributes of the style to hard formatting
Definition: svdpage.cxx:795
std::unique_ptr< SdrOutliner > m_pChainingOutliner
Definition: svdmodel.hxx:190
sal_Int32 GetDenominator() const
void TRG_ImpMasterPageRemoved(const SdrPage &rRemovedPage)
Definition: svdpage.cxx:1678
FieldUnit m_eUIUnit
Definition: svdmodel.hxx:179
virtual SdrModel * AllocModel() const
Definition: svdmodel.cxx:586
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
size_t GetFontHeight()
Definition: svdetc.hxx:74
void SetAddExtLeading(bool bEnabled)
Definition: svdmodel.cxx:1713
#define SAL_WARN_IF(condition, area, stream)
CharCompressType mnCharCompressType
Definition: svdmodel.hxx:227
constexpr o3tl::Length MapToO3tlLength(MapUnit eU, o3tl::Length ePixelValue=o3tl::Length::px)
#define SAL_INFO(area, stream)
std::unique_ptr< SdrModelImpl > mpImpl
Definition: svdmodel.hxx:226
Fraction m_aUIUnitFact
Definition: svdmodel.hxx:182
SVX_DLLPRIVATE void ImpReformatAllTextObjects()
Definition: svdmodel.cxx:703
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
bool mbChanged
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
Definition: svdetc.cxx:333
static void SetForbiddenCharsTable(const std::shared_ptr< SvxForbiddenCharactersTable > &xForbiddenChars)
virtual void Repeat(SfxRepeatTarget &)
void SetRefDevice(OutputDevice *pRefDev)
void * p
sal_Int32 GetNumerator() const
std::unique_ptr< SdrLayerAdmin > m_pLayerAdmin
Definition: svdmodel.hxx:185
void SetMaxUndoActionCount(sal_uInt32 nCount)
Definition: svdmodel.cxx:261
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
virtual void PageListChanged()
Definition: svdmodel.cxx:1817
bool SetUpdateLayout(bool bUpdate)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: svdmodel.cxx:1906
void SetAnchoredTextOverflowLegacy(bool bEnabled)
Definition: svdmodel.cxx:1723
bool m_bReadOnly
void Redo()
Definition: svdmodel.cxx:307
virtual void MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
Definition: svdmodel.cxx:1224
void SetEditTextObjectPool(SfxItemPool *pPool)
virtual bool CanRepeat(SfxRepeatTarget &) const
void SetTextObj(const SdrTextObj *pObj)
Definition: svdoutl.cxx:40
std::deque< std::unique_ptr< SfxUndoAction > > m_aRedoStack
Definition: svdmodel.hxx:198
MapUnit
void SetAsianCompressionMode(CharCompressType nCompressionMode)
#define SAL_WARN(area, stream)
void SetUIUnit(FieldUnit eUnit)
Definition: svdmodel.cxx:914
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
bool m_bPagNumsDirty
Definition: svdmodel.hxx:204
SVX_DLLPRIVATE void ImpSetOutlinerDefaults(SdrOutliner *pOutliner, bool bInit=false)
Definition: svdmodel.cxx:671
OUString GetMetricString(tools::Long nVal, bool bNoUnitChars=false, sal_Int32 nNumDigits=-1) const
Definition: svdmodel.cxx:977
void SetScaleUnit(MapUnit eMap)
Definition: svdmodel.cxx:891
void EraseVirtualDevice()
static OUString GetPercentString(const Fraction &rVal)
Definition: svdmodel.cxx:1129
void disposeOutliner(std::unique_ptr< SdrOutliner > pOutliner)
Definition: svdmodel.cxx:1755
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:373
virtual void Merge(SdrModel &rSourceModel, sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum, sal_uInt16 nDestPos, bool bMergeMasterPages, bool bAllMasterPages, bool bUndo=true, bool bTreadSourceAsConst=false)
Definition: svdmodel.cxx:1383
void ClearUndoBuffer()
Definition: svdmodel.cxx:269
void SetAddExtLeading(bool b)
bool mbChanged
Definition: svdmodel.hxx:203
virtual void Redo()
sal_uInt16 GetPageNum() const
Definition: svdpage.cxx:1598
bool HasUndoActions() const
Definition: svdmodel.cxx:275
void ClearModel(bool bCalledFromDestructor)
Definition: svdmodel.cxx:557
virtual css::uno::Reference< css::embed::XStorage > GetDocumentStorage() const
Definition: svdmodel.cxx:741
void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue)
Definition: svdmodel.cxx:1766
css::uno::Reference< css::io::XInputStream > GetDocumentStream(OUString const &rURL,::comphelper::LifecycleProxy const &rProxy) const
Definition: svdmodel.cxx:754
double div(const double &fNumerator, const double &fDenominator)
rtl_TextEncoding GetCharSet() const
sal_uInt16 GetPageCount() const
Definition: svdmodel.cxx:1812
o3tl::enumarray< XPropertyListType, XPropertyListRef > maProperties
Definition: svdmodel.hxx:235
sal_Int32 mnDefTextHgt
Definition: svdmodel.hxx:191
void SetPoolDefaultItem(const SfxPoolItem &)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
OUString m_aUIUnitStr
Definition: svdmodel.hxx:181