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