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