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