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