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