1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/svdotext.hxx>
21 #include <svx/svdetc.hxx>
22 #include <editeng/outlobj.hxx>
23 #include <svx/svdoutl.hxx>
24 #include <svx/svdmodel.hxx>
25 #include <svl/itemset.hxx>
26 #include <osl/diagnose.h>
27 #include <libxml/xmlwriter.h>
30 SdrText::SdrText( SdrTextObj
& rObject
)
32 , mbPortionInfoChecked( false )
34 OSL_ENSURE(&mrObject
, "SdrText created without SdrTextObj (!)");
41 void SdrText::CheckPortionInfo( const SdrOutliner
& rOutliner
)
43 if(mbPortionInfoChecked
)
46 // #i102062# no action when the Outliner is the HitTestOutliner,
47 // this will remove WrongList info at the OPO
48 if(&rOutliner
== &mrObject
.getSdrModelFromSdrObject().GetHitTestOutliner())
51 // TODO: optimization: we could create a BigTextObject
52 mbPortionInfoChecked
=true;
54 if(mpOutlinerParaObject
&& rOutliner
.ShouldCreateBigTextObject())
56 // #i102062# MemoryLeak closed
57 mpOutlinerParaObject
= rOutliner
.CreateParaObject();
61 void SdrText::ReformatText()
63 mbPortionInfoChecked
=false;
64 mpOutlinerParaObject
->ClearPortionInfo();
67 const SfxItemSet
& SdrText::GetItemSet() const
69 return const_cast< SdrText
* >(this)->GetObjectItemSet();
72 void SdrText::SetOutlinerParaObject( std::optional
<OutlinerParaObject
> pTextObject
)
74 mpOutlinerParaObject
= std::move(pTextObject
);
75 mbPortionInfoChecked
= false;
78 OutlinerParaObject
* SdrText::GetOutlinerParaObject()
80 return mpOutlinerParaObject
? &*mpOutlinerParaObject
: nullptr;
83 const OutlinerParaObject
* SdrText::GetOutlinerParaObject() const
85 return mpOutlinerParaObject
? &*mpOutlinerParaObject
: nullptr;
88 /** returns the current OutlinerParaObject and removes it from this instance */
89 std::optional
<OutlinerParaObject
> SdrText::RemoveOutlinerParaObject()
91 std::optional
<OutlinerParaObject
> pOPO
= std::move(mpOutlinerParaObject
);
92 mbPortionInfoChecked
= false;
96 void SdrText::ForceOutlinerParaObject( OutlinerMode nOutlMode
)
98 if(mpOutlinerParaObject
)
101 std::unique_ptr
<Outliner
> pOutliner(
104 mrObject
.getSdrModelFromSdrObject()));
108 Outliner
& aDrawOutliner(mrObject
.getSdrModelFromSdrObject().GetDrawOutliner());
109 pOutliner
->SetCalcFieldValueHdl( aDrawOutliner
.GetCalcFieldValueHdl() );
110 pOutliner
->SetStyleSheet( 0, GetStyleSheet());
111 SetOutlinerParaObject( pOutliner
->CreateParaObject() );
115 const SfxItemSet
& SdrText::GetObjectItemSet()
117 return mrObject
.GetObjectItemSet();
120 SfxStyleSheet
* SdrText::GetStyleSheet() const
122 return mrObject
.GetStyleSheet();
125 void SdrText::dumpAsXml(xmlTextWriterPtr pWriter
) const
127 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SdrText"));
128 mpOutlinerParaObject
->dumpAsXml(pWriter
);
129 (void)xmlTextWriterEndElement(pWriter
);
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */