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 <libxml/xmlwriter.h>
29 SdrText::SdrText( SdrTextObj
& rObject
)
31 , mbPortionInfoChecked( false )
33 OSL_ENSURE(&mrObject
, "SdrText created without SdrTextObj (!)");
41 void SdrText::CheckPortionInfo( 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
!=nullptr && 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::unique_ptr
<OutlinerParaObject
> pTextObject
)
74 assert ( !mpOutlinerParaObject
|| (mpOutlinerParaObject
.get() != pTextObject
.get()) );
76 // Update HitTestOutliner
77 const SdrTextObj
* pTestObj(mrObject
.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
79 if(pTestObj
&& pTestObj
->GetOutlinerParaObject() == mpOutlinerParaObject
.get())
81 mrObject
.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
84 mpOutlinerParaObject
= std::move(pTextObject
);
85 mbPortionInfoChecked
= false;
88 OutlinerParaObject
* SdrText::GetOutlinerParaObject() const
90 return mpOutlinerParaObject
.get();
93 /** returns the current OutlinerParaObject and removes it from this instance */
94 std::unique_ptr
<OutlinerParaObject
> SdrText::RemoveOutlinerParaObject()
96 // Update HitTestOutliner
97 const SdrTextObj
* pTestObj(mrObject
.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
99 if(pTestObj
&& pTestObj
->GetOutlinerParaObject() == mpOutlinerParaObject
.get())
101 mrObject
.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
104 std::unique_ptr
<OutlinerParaObject
> pOPO
= std::move(mpOutlinerParaObject
);
105 mbPortionInfoChecked
= false;
110 void SdrText::ForceOutlinerParaObject( OutlinerMode nOutlMode
)
112 if(mpOutlinerParaObject
)
115 std::unique_ptr
<Outliner
> pOutliner(
118 mrObject
.getSdrModelFromSdrObject()));
122 Outliner
& aDrawOutliner(mrObject
.getSdrModelFromSdrObject().GetDrawOutliner());
123 pOutliner
->SetCalcFieldValueHdl( aDrawOutliner
.GetCalcFieldValueHdl() );
124 pOutliner
->SetStyleSheet( 0, GetStyleSheet());
125 SetOutlinerParaObject( pOutliner
->CreateParaObject() );
129 const SfxItemSet
& SdrText::GetObjectItemSet()
131 return mrObject
.GetObjectItemSet();
134 SfxStyleSheet
* SdrText::GetStyleSheet() const
136 return mrObject
.GetStyleSheet();
139 void SdrText::dumpAsXml(xmlTextWriterPtr pWriter
) const
141 xmlTextWriterStartElement(pWriter
, BAD_CAST("SdrText"));
142 mpOutlinerParaObject
->dumpAsXml(pWriter
);
143 xmlTextWriterEndElement(pWriter
);
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */