LibreOffice Module svx (master)  1
svdtext.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/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>
27 #include <memory>
28 
30 : mrObject( rObject )
31 , mbPortionInfoChecked( false )
32 {
33  OSL_ENSURE(&mrObject, "SdrText created without SdrTextObj (!)");
34 }
35 
37 {
38  clearWeak();
39 }
40 
42 {
44  return;
45 
46  // #i102062# no action when the Outliner is the HitTestOutliner,
47  // this will remove WrongList info at the OPO
49  return;
50 
51  // TODO: optimization: we could create a BigTextObject
53 
54  if(mpOutlinerParaObject!=nullptr && rOutliner.ShouldCreateBigTextObject())
55  {
56  // #i102062# MemoryLeak closed
58  }
59 }
60 
62 {
64  mpOutlinerParaObject->ClearPortionInfo();
65 }
66 
68 {
69  return const_cast< SdrText* >(this)->GetObjectItemSet();
70 }
71 
72 void SdrText::SetOutlinerParaObject( std::unique_ptr<OutlinerParaObject> pTextObject )
73 {
74  assert ( !mpOutlinerParaObject || (mpOutlinerParaObject.get() != pTextObject.get()) );
75 
76  // Update HitTestOutliner
78 
79  if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get())
80  {
82  }
83 
84  mpOutlinerParaObject = std::move(pTextObject);
85  mbPortionInfoChecked = false;
86 }
87 
89 {
90  return mpOutlinerParaObject.get();
91 }
92 
94 std::unique_ptr<OutlinerParaObject> SdrText::RemoveOutlinerParaObject()
95 {
96  // Update HitTestOutliner
98 
99  if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get())
100  {
102  }
103 
104  std::unique_ptr<OutlinerParaObject> pOPO = std::move(mpOutlinerParaObject);
105  mbPortionInfoChecked = false;
106 
107  return pOPO;
108 }
109 
111 {
113  return;
114 
115  std::unique_ptr<Outliner> pOutliner(
117  nOutlMode,
119 
120  if(pOutliner)
121  {
123  pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
124  pOutliner->SetStyleSheet( 0, GetStyleSheet());
125  SetOutlinerParaObject( pOutliner->CreateParaObject() );
126  }
127 }
128 
130 {
131  return mrObject.GetObjectItemSet();
132 }
133 
135 {
136  return mrObject.GetStyleSheet();
137 }
138 
140 {
141  xmlTextWriterStartElement(pWriter, BAD_CAST("SdrText"));
142  mpOutlinerParaObject->dumpAsXml(pWriter);
143  xmlTextWriterEndElement(pWriter);
144 }
145 
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrOutliner & GetDrawOutliner(const SdrTextObj *pObj=nullptr) const
Definition: svdmodel.cxx:694
const SfxItemSet & GetItemSet() const
Definition: svdtext.cxx:67
OutlinerMode
struct _xmlTextWriter * xmlTextWriterPtr
std::unique_ptr< OutlinerParaObject > RemoveOutlinerParaObject()
returns the current OutlinerParaObject and removes it from this instance
Definition: svdtext.cxx:94
bool mbPortionInfoChecked
Definition: svdtext.hxx:78
SdrText(SdrTextObj &rObject)
Definition: svdtext.cxx:29
std::unique_ptr< OutlinerParaObject > mpOutlinerParaObject
Definition: svdtext.hxx:76
virtual SfxStyleSheet * GetStyleSheet() const
Definition: svdtext.cxx:134
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const SfxItemSet & GetObjectItemSet() const
Definition: svdobj.cxx:1885
SfxStyleSheet * GetStyleSheet() const
Definition: svdobj.cxx:2141
SdrTextObj & mrObject
Definition: svdtext.hxx:77
SdrOutliner & GetHitTestOutliner() const
Definition: svdmodel.hxx:318
bool ShouldCreateBigTextObject() const
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:273
void ForceOutlinerParaObject(OutlinerMode nOutlMode)
Definition: svdtext.cxx:110
void CheckPortionInfo(SdrOutliner &rOutliner)
Definition: svdtext.cxx:41
std::unique_ptr< OutlinerParaObject > CreateParaObject(sal_Int32 nStartPara=0, sal_Int32 nParaCount=EE_PARA_ALL) const
void ReformatText()
Definition: svdtext.cxx:61
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
Definition: svdetc.cxx:328
virtual void SetOutlinerParaObject(std::unique_ptr< OutlinerParaObject > pTextObject)
Definition: svdtext.cxx:72
virtual ~SdrText() override
Definition: svdtext.cxx:36
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdtext.cxx:139
void SetTextObj(const SdrTextObj *pObj)
Definition: svdoutl.cxx:40
const SdrTextObj * GetTextObj() const
Definition: svdoutl.cxx:86
OutlinerParaObject * GetOutlinerParaObject() const
Definition: svdtext.cxx:88
virtual const SfxItemSet & GetObjectItemSet()
Definition: svdtext.cxx:129