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