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