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