update dev300-m58
[ooovba.git] / svx / source / outliner / outlobj.cxx
blob72601d9d7e46f42b628b07080710e60d964abc7e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outlobj.cxx,v $
10 * $Revision: 1.12.78.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <outl_pch.hxx>
36 #define _OUTLINER_CXX
37 #include <svx/outliner.hxx>
38 #include <svx/outlobj.hxx>
39 #include <outleeng.hxx>
40 #include <svx/editobj.hxx>
41 #include <vcl/bitmap.hxx>
42 #include <tools/stream.hxx>
44 //////////////////////////////////////////////////////////////////////////////
46 class ImplOutlinerParaObject
48 public:
49 // data members
50 EditTextObject* mpEditTextObject;
51 ParagraphDataVector maParagraphDataVector;
52 bool mbIsEditDoc;
54 // refcounter
55 sal_uInt32 mnRefCount;
57 // constuctor
58 ImplOutlinerParaObject(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
59 : mpEditTextObject(pEditTextObject),
60 maParagraphDataVector(rParagraphDataVector),
61 mbIsEditDoc(bIsEditDoc),
62 mnRefCount(0)
64 if( (maParagraphDataVector.size() == 0) && (pEditTextObject->GetParagraphCount() != 0) )
65 maParagraphDataVector.resize(pEditTextObject->GetParagraphCount());
68 // destructor
69 ~ImplOutlinerParaObject()
71 delete mpEditTextObject;
74 bool operator==(const ImplOutlinerParaObject& rCandidate) const
76 return (*mpEditTextObject == *rCandidate.mpEditTextObject
77 && maParagraphDataVector == rCandidate.maParagraphDataVector
78 && mbIsEditDoc == rCandidate.mbIsEditDoc);
81 // #i102062#
82 bool isWrongListEqual(const ImplOutlinerParaObject& rCompare) const
84 return mpEditTextObject->isWrongListEqual(*rCompare.mpEditTextObject);
88 //////////////////////////////////////////////////////////////////////////////
90 void OutlinerParaObject::ImplMakeUnique()
92 if(mpImplOutlinerParaObject->mnRefCount)
94 ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject(
95 mpImplOutlinerParaObject->mpEditTextObject->Clone(),
96 mpImplOutlinerParaObject->maParagraphDataVector,
97 mpImplOutlinerParaObject->mbIsEditDoc);
98 mpImplOutlinerParaObject->mnRefCount--;
99 mpImplOutlinerParaObject = pNew;
103 OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
104 : mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc))
108 OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate)
109 : mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject)
111 mpImplOutlinerParaObject->mnRefCount++;
114 OutlinerParaObject::~OutlinerParaObject()
116 if(mpImplOutlinerParaObject->mnRefCount)
118 mpImplOutlinerParaObject->mnRefCount--;
120 else
122 delete mpImplOutlinerParaObject;
126 OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate)
128 if(rCandidate.mpImplOutlinerParaObject != mpImplOutlinerParaObject)
130 if(mpImplOutlinerParaObject->mnRefCount)
132 mpImplOutlinerParaObject->mnRefCount--;
134 else
136 delete mpImplOutlinerParaObject;
139 mpImplOutlinerParaObject = rCandidate.mpImplOutlinerParaObject;
140 mpImplOutlinerParaObject->mnRefCount++;
143 return *this;
146 bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const
148 if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
150 return true;
153 return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject);
156 // #i102062#
157 bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const
159 if(rCompare.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
161 return true;
164 return mpImplOutlinerParaObject->isWrongListEqual(*rCompare.mpImplOutlinerParaObject);
167 sal_uInt16 OutlinerParaObject::GetOutlinerMode() const
169 return mpImplOutlinerParaObject->mpEditTextObject->GetUserType();
172 void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew)
174 if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew)
176 ImplMakeUnique();
177 mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew);
181 bool OutlinerParaObject::IsVertical() const
183 return mpImplOutlinerParaObject->mpEditTextObject->IsVertical();
186 void OutlinerParaObject::SetVertical(bool bNew)
188 if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew)
190 ImplMakeUnique();
191 mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew);
195 sal_uInt32 OutlinerParaObject::Count() const
197 return mpImplOutlinerParaObject->maParagraphDataVector.size();
200 sal_Int16 OutlinerParaObject::GetDepth(sal_uInt16 nPara) const
202 if(nPara < mpImplOutlinerParaObject->maParagraphDataVector.size())
204 return mpImplOutlinerParaObject->maParagraphDataVector[nPara].getDepth();
206 else
208 return -1;
212 const EditTextObject& OutlinerParaObject::GetTextObject() const
214 return *mpImplOutlinerParaObject->mpEditTextObject;
217 bool OutlinerParaObject::IsEditDoc() const
219 return mpImplOutlinerParaObject->mbIsEditDoc;
222 const ParagraphData& OutlinerParaObject::GetParagraphData(sal_uInt32 nIndex) const
224 if(nIndex < mpImplOutlinerParaObject->maParagraphDataVector.size())
226 return mpImplOutlinerParaObject->maParagraphDataVector[nIndex];
228 else
230 OSL_ENSURE(false, "OutlinerParaObject::GetParagraphData: Access out of range (!)");
231 static ParagraphData aEmptyParagraphData;
232 return aEmptyParagraphData;
236 void OutlinerParaObject::ClearPortionInfo()
238 ImplMakeUnique();
239 mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo();
242 bool OutlinerParaObject::ChangeStyleSheets(const XubString& rOldName, SfxStyleFamily eOldFamily, const XubString& rNewName, SfxStyleFamily eNewFamily)
244 ImplMakeUnique();
245 return mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
248 void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName)
250 ImplMakeUnique();
251 mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
254 void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const XubString rNewName, const SfxStyleFamily& rNewFamily)
256 const sal_uInt32 nCount(mpImplOutlinerParaObject->maParagraphDataVector.size());
258 if(nCount)
260 ImplMakeUnique();
261 sal_uInt16 nDecrementer(sal::static_int_cast< sal_uInt16 >(nCount));
263 for(;nDecrementer;)
265 if(GetDepth(--nDecrementer) == nLevel)
267 mpImplOutlinerParaObject->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
273 //////////////////////////////////////////////////////////////////////////////
274 // eof