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