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