1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_editeng.hxx"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski #include <outl_pch.hxx>
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski #define _OUTLINER_CXX
30*b1cdbd2cSJim Jagielski #include <editeng/outliner.hxx>
31*b1cdbd2cSJim Jagielski #include <editeng/outlobj.hxx>
32*b1cdbd2cSJim Jagielski #include <outleeng.hxx>
33*b1cdbd2cSJim Jagielski #include <editeng/editobj.hxx>
34*b1cdbd2cSJim Jagielski #include <vcl/bitmap.hxx>
35*b1cdbd2cSJim Jagielski #include <tools/stream.hxx>
36*b1cdbd2cSJim Jagielski
37*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
38*b1cdbd2cSJim Jagielski
39*b1cdbd2cSJim Jagielski class ImplOutlinerParaObject
40*b1cdbd2cSJim Jagielski {
41*b1cdbd2cSJim Jagielski public:
42*b1cdbd2cSJim Jagielski // data members
43*b1cdbd2cSJim Jagielski EditTextObject* mpEditTextObject;
44*b1cdbd2cSJim Jagielski ParagraphDataVector maParagraphDataVector;
45*b1cdbd2cSJim Jagielski bool mbIsEditDoc;
46*b1cdbd2cSJim Jagielski
47*b1cdbd2cSJim Jagielski // refcounter
48*b1cdbd2cSJim Jagielski sal_uInt32 mnRefCount;
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim Jagielski // constuctor
ImplOutlinerParaObject(EditTextObject * pEditTextObject,const ParagraphDataVector & rParagraphDataVector,bool bIsEditDoc)51*b1cdbd2cSJim Jagielski ImplOutlinerParaObject(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
52*b1cdbd2cSJim Jagielski : mpEditTextObject(pEditTextObject),
53*b1cdbd2cSJim Jagielski maParagraphDataVector(rParagraphDataVector),
54*b1cdbd2cSJim Jagielski mbIsEditDoc(bIsEditDoc),
55*b1cdbd2cSJim Jagielski mnRefCount(0)
56*b1cdbd2cSJim Jagielski {
57*b1cdbd2cSJim Jagielski if( (maParagraphDataVector.size() == 0) && (pEditTextObject->GetParagraphCount() != 0) )
58*b1cdbd2cSJim Jagielski maParagraphDataVector.resize(pEditTextObject->GetParagraphCount());
59*b1cdbd2cSJim Jagielski }
60*b1cdbd2cSJim Jagielski
61*b1cdbd2cSJim Jagielski // destructor
~ImplOutlinerParaObject()62*b1cdbd2cSJim Jagielski ~ImplOutlinerParaObject()
63*b1cdbd2cSJim Jagielski {
64*b1cdbd2cSJim Jagielski delete mpEditTextObject;
65*b1cdbd2cSJim Jagielski }
66*b1cdbd2cSJim Jagielski
operator ==(const ImplOutlinerParaObject & rCandidate) const67*b1cdbd2cSJim Jagielski bool operator==(const ImplOutlinerParaObject& rCandidate) const
68*b1cdbd2cSJim Jagielski {
69*b1cdbd2cSJim Jagielski return (*mpEditTextObject == *rCandidate.mpEditTextObject
70*b1cdbd2cSJim Jagielski && maParagraphDataVector == rCandidate.maParagraphDataVector
71*b1cdbd2cSJim Jagielski && mbIsEditDoc == rCandidate.mbIsEditDoc);
72*b1cdbd2cSJim Jagielski }
73*b1cdbd2cSJim Jagielski
74*b1cdbd2cSJim Jagielski // #i102062#
isWrongListEqual(const ImplOutlinerParaObject & rCompare) const75*b1cdbd2cSJim Jagielski bool isWrongListEqual(const ImplOutlinerParaObject& rCompare) const
76*b1cdbd2cSJim Jagielski {
77*b1cdbd2cSJim Jagielski return mpEditTextObject->isWrongListEqual(*rCompare.mpEditTextObject);
78*b1cdbd2cSJim Jagielski }
79*b1cdbd2cSJim Jagielski };
80*b1cdbd2cSJim Jagielski
81*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
82*b1cdbd2cSJim Jagielski
ImplMakeUnique()83*b1cdbd2cSJim Jagielski void OutlinerParaObject::ImplMakeUnique()
84*b1cdbd2cSJim Jagielski {
85*b1cdbd2cSJim Jagielski if(mpImplOutlinerParaObject->mnRefCount)
86*b1cdbd2cSJim Jagielski {
87*b1cdbd2cSJim Jagielski ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject(
88*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mpEditTextObject->Clone(),
89*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->maParagraphDataVector,
90*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mbIsEditDoc);
91*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mnRefCount--;
92*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject = pNew;
93*b1cdbd2cSJim Jagielski }
94*b1cdbd2cSJim Jagielski }
95*b1cdbd2cSJim Jagielski
OutlinerParaObject(const EditTextObject & rEditTextObject,const ParagraphDataVector & rParagraphDataVector,bool bIsEditDoc)96*b1cdbd2cSJim Jagielski OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
97*b1cdbd2cSJim Jagielski : mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc))
98*b1cdbd2cSJim Jagielski {
99*b1cdbd2cSJim Jagielski }
100*b1cdbd2cSJim Jagielski
OutlinerParaObject(const EditTextObject & rEditTextObject)101*b1cdbd2cSJim Jagielski OutlinerParaObject::OutlinerParaObject( const EditTextObject& rEditTextObject)
102*b1cdbd2cSJim Jagielski : mpImplOutlinerParaObject( new ImplOutlinerParaObject( rEditTextObject.Clone(), ParagraphDataVector(), true))
103*b1cdbd2cSJim Jagielski {}
104*b1cdbd2cSJim Jagielski
OutlinerParaObject(const OutlinerParaObject & rCandidate)105*b1cdbd2cSJim Jagielski OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate)
106*b1cdbd2cSJim Jagielski : mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject)
107*b1cdbd2cSJim Jagielski {
108*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mnRefCount++;
109*b1cdbd2cSJim Jagielski }
110*b1cdbd2cSJim Jagielski
~OutlinerParaObject()111*b1cdbd2cSJim Jagielski OutlinerParaObject::~OutlinerParaObject()
112*b1cdbd2cSJim Jagielski {
113*b1cdbd2cSJim Jagielski if(mpImplOutlinerParaObject->mnRefCount)
114*b1cdbd2cSJim Jagielski {
115*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mnRefCount--;
116*b1cdbd2cSJim Jagielski }
117*b1cdbd2cSJim Jagielski else
118*b1cdbd2cSJim Jagielski {
119*b1cdbd2cSJim Jagielski delete mpImplOutlinerParaObject;
120*b1cdbd2cSJim Jagielski }
121*b1cdbd2cSJim Jagielski }
122*b1cdbd2cSJim Jagielski
operator =(const OutlinerParaObject & rCandidate)123*b1cdbd2cSJim Jagielski OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate)
124*b1cdbd2cSJim Jagielski {
125*b1cdbd2cSJim Jagielski if(rCandidate.mpImplOutlinerParaObject != mpImplOutlinerParaObject)
126*b1cdbd2cSJim Jagielski {
127*b1cdbd2cSJim Jagielski if(mpImplOutlinerParaObject->mnRefCount)
128*b1cdbd2cSJim Jagielski {
129*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mnRefCount--;
130*b1cdbd2cSJim Jagielski }
131*b1cdbd2cSJim Jagielski else
132*b1cdbd2cSJim Jagielski {
133*b1cdbd2cSJim Jagielski delete mpImplOutlinerParaObject;
134*b1cdbd2cSJim Jagielski }
135*b1cdbd2cSJim Jagielski
136*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject = rCandidate.mpImplOutlinerParaObject;
137*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mnRefCount++;
138*b1cdbd2cSJim Jagielski }
139*b1cdbd2cSJim Jagielski
140*b1cdbd2cSJim Jagielski return *this;
141*b1cdbd2cSJim Jagielski }
142*b1cdbd2cSJim Jagielski
operator ==(const OutlinerParaObject & rCandidate) const143*b1cdbd2cSJim Jagielski bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const
144*b1cdbd2cSJim Jagielski {
145*b1cdbd2cSJim Jagielski if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
146*b1cdbd2cSJim Jagielski {
147*b1cdbd2cSJim Jagielski return true;
148*b1cdbd2cSJim Jagielski }
149*b1cdbd2cSJim Jagielski
150*b1cdbd2cSJim Jagielski return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject);
151*b1cdbd2cSJim Jagielski }
152*b1cdbd2cSJim Jagielski
153*b1cdbd2cSJim Jagielski // #i102062#
isWrongListEqual(const OutlinerParaObject & rCompare) const154*b1cdbd2cSJim Jagielski bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const
155*b1cdbd2cSJim Jagielski {
156*b1cdbd2cSJim Jagielski if(rCompare.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
157*b1cdbd2cSJim Jagielski {
158*b1cdbd2cSJim Jagielski return true;
159*b1cdbd2cSJim Jagielski }
160*b1cdbd2cSJim Jagielski
161*b1cdbd2cSJim Jagielski return mpImplOutlinerParaObject->isWrongListEqual(*rCompare.mpImplOutlinerParaObject);
162*b1cdbd2cSJim Jagielski }
163*b1cdbd2cSJim Jagielski
GetOutlinerMode() const164*b1cdbd2cSJim Jagielski sal_uInt16 OutlinerParaObject::GetOutlinerMode() const
165*b1cdbd2cSJim Jagielski {
166*b1cdbd2cSJim Jagielski return mpImplOutlinerParaObject->mpEditTextObject->GetUserType();
167*b1cdbd2cSJim Jagielski }
168*b1cdbd2cSJim Jagielski
SetOutlinerMode(sal_uInt16 nNew)169*b1cdbd2cSJim Jagielski void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew)
170*b1cdbd2cSJim Jagielski {
171*b1cdbd2cSJim Jagielski if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew)
172*b1cdbd2cSJim Jagielski {
173*b1cdbd2cSJim Jagielski ImplMakeUnique();
174*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew);
175*b1cdbd2cSJim Jagielski }
176*b1cdbd2cSJim Jagielski }
177*b1cdbd2cSJim Jagielski
IsVertical() const178*b1cdbd2cSJim Jagielski bool OutlinerParaObject::IsVertical() const
179*b1cdbd2cSJim Jagielski {
180*b1cdbd2cSJim Jagielski return mpImplOutlinerParaObject->mpEditTextObject->IsVertical();
181*b1cdbd2cSJim Jagielski }
182*b1cdbd2cSJim Jagielski
SetVertical(bool bNew)183*b1cdbd2cSJim Jagielski void OutlinerParaObject::SetVertical(bool bNew)
184*b1cdbd2cSJim Jagielski {
185*b1cdbd2cSJim Jagielski if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew)
186*b1cdbd2cSJim Jagielski {
187*b1cdbd2cSJim Jagielski ImplMakeUnique();
188*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew);
189*b1cdbd2cSJim Jagielski }
190*b1cdbd2cSJim Jagielski }
191*b1cdbd2cSJim Jagielski
Count() const192*b1cdbd2cSJim Jagielski sal_uInt32 OutlinerParaObject::Count() const
193*b1cdbd2cSJim Jagielski {
194*b1cdbd2cSJim Jagielski return mpImplOutlinerParaObject->maParagraphDataVector.size();
195*b1cdbd2cSJim Jagielski }
196*b1cdbd2cSJim Jagielski
GetDepth(sal_uInt16 nPara) const197*b1cdbd2cSJim Jagielski sal_Int16 OutlinerParaObject::GetDepth(sal_uInt16 nPara) const
198*b1cdbd2cSJim Jagielski {
199*b1cdbd2cSJim Jagielski if(nPara < mpImplOutlinerParaObject->maParagraphDataVector.size())
200*b1cdbd2cSJim Jagielski {
201*b1cdbd2cSJim Jagielski return mpImplOutlinerParaObject->maParagraphDataVector[nPara].getDepth();
202*b1cdbd2cSJim Jagielski }
203*b1cdbd2cSJim Jagielski else
204*b1cdbd2cSJim Jagielski {
205*b1cdbd2cSJim Jagielski return -1;
206*b1cdbd2cSJim Jagielski }
207*b1cdbd2cSJim Jagielski }
208*b1cdbd2cSJim Jagielski
GetTextObject() const209*b1cdbd2cSJim Jagielski const EditTextObject& OutlinerParaObject::GetTextObject() const
210*b1cdbd2cSJim Jagielski {
211*b1cdbd2cSJim Jagielski return *mpImplOutlinerParaObject->mpEditTextObject;
212*b1cdbd2cSJim Jagielski }
213*b1cdbd2cSJim Jagielski
IsEditDoc() const214*b1cdbd2cSJim Jagielski bool OutlinerParaObject::IsEditDoc() const
215*b1cdbd2cSJim Jagielski {
216*b1cdbd2cSJim Jagielski return mpImplOutlinerParaObject->mbIsEditDoc;
217*b1cdbd2cSJim Jagielski }
218*b1cdbd2cSJim Jagielski
GetParagraphData(sal_uInt32 nIndex) const219*b1cdbd2cSJim Jagielski const ParagraphData& OutlinerParaObject::GetParagraphData(sal_uInt32 nIndex) const
220*b1cdbd2cSJim Jagielski {
221*b1cdbd2cSJim Jagielski if(nIndex < mpImplOutlinerParaObject->maParagraphDataVector.size())
222*b1cdbd2cSJim Jagielski {
223*b1cdbd2cSJim Jagielski return mpImplOutlinerParaObject->maParagraphDataVector[nIndex];
224*b1cdbd2cSJim Jagielski }
225*b1cdbd2cSJim Jagielski else
226*b1cdbd2cSJim Jagielski {
227*b1cdbd2cSJim Jagielski OSL_ENSURE(false, "OutlinerParaObject::GetParagraphData: Access out of range (!)");
228*b1cdbd2cSJim Jagielski static ParagraphData aEmptyParagraphData;
229*b1cdbd2cSJim Jagielski return aEmptyParagraphData;
230*b1cdbd2cSJim Jagielski }
231*b1cdbd2cSJim Jagielski }
232*b1cdbd2cSJim Jagielski
ClearPortionInfo()233*b1cdbd2cSJim Jagielski void OutlinerParaObject::ClearPortionInfo()
234*b1cdbd2cSJim Jagielski {
235*b1cdbd2cSJim Jagielski ImplMakeUnique();
236*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo();
237*b1cdbd2cSJim Jagielski }
238*b1cdbd2cSJim Jagielski
ChangeStyleSheets(const XubString & rOldName,SfxStyleFamily eOldFamily,const XubString & rNewName,SfxStyleFamily eNewFamily)239*b1cdbd2cSJim Jagielski bool OutlinerParaObject::ChangeStyleSheets(const XubString& rOldName, SfxStyleFamily eOldFamily, const XubString& rNewName, SfxStyleFamily eNewFamily)
240*b1cdbd2cSJim Jagielski {
241*b1cdbd2cSJim Jagielski ImplMakeUnique();
242*b1cdbd2cSJim Jagielski return mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
243*b1cdbd2cSJim Jagielski }
244*b1cdbd2cSJim Jagielski
ChangeStyleSheetName(SfxStyleFamily eFamily,const XubString & rOldName,const XubString & rNewName)245*b1cdbd2cSJim Jagielski void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName)
246*b1cdbd2cSJim Jagielski {
247*b1cdbd2cSJim Jagielski ImplMakeUnique();
248*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
249*b1cdbd2cSJim Jagielski }
250*b1cdbd2cSJim Jagielski
SetStyleSheets(sal_uInt16 nLevel,const XubString rNewName,const SfxStyleFamily & rNewFamily)251*b1cdbd2cSJim Jagielski void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const XubString rNewName, const SfxStyleFamily& rNewFamily)
252*b1cdbd2cSJim Jagielski {
253*b1cdbd2cSJim Jagielski const sal_uInt32 nCount(mpImplOutlinerParaObject->maParagraphDataVector.size());
254*b1cdbd2cSJim Jagielski
255*b1cdbd2cSJim Jagielski if(nCount)
256*b1cdbd2cSJim Jagielski {
257*b1cdbd2cSJim Jagielski ImplMakeUnique();
258*b1cdbd2cSJim Jagielski sal_uInt16 nDecrementer(sal::static_int_cast< sal_uInt16 >(nCount));
259*b1cdbd2cSJim Jagielski
260*b1cdbd2cSJim Jagielski for(;nDecrementer;)
261*b1cdbd2cSJim Jagielski {
262*b1cdbd2cSJim Jagielski if(GetDepth(--nDecrementer) == nLevel)
263*b1cdbd2cSJim Jagielski {
264*b1cdbd2cSJim Jagielski mpImplOutlinerParaObject->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
265*b1cdbd2cSJim Jagielski }
266*b1cdbd2cSJim Jagielski }
267*b1cdbd2cSJim Jagielski }
268*b1cdbd2cSJim Jagielski }
269*b1cdbd2cSJim Jagielski
270*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
271*b1cdbd2cSJim Jagielski // eof
272