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