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