1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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>
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
50 EditTextObject
* mpEditTextObject
;
51 ParagraphDataVector maParagraphDataVector
;
55 sal_uInt32 mnRefCount
;
58 ImplOutlinerParaObject(EditTextObject
* pEditTextObject
, const ParagraphDataVector
& rParagraphDataVector
, bool bIsEditDoc
)
59 : mpEditTextObject(pEditTextObject
),
60 maParagraphDataVector(rParagraphDataVector
),
61 mbIsEditDoc(bIsEditDoc
),
64 if( (maParagraphDataVector
.size() == 0) && (pEditTextObject
->GetParagraphCount() != 0) )
65 maParagraphDataVector
.resize(pEditTextObject
->GetParagraphCount());
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
);
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
--;
122 delete mpImplOutlinerParaObject
;
126 OutlinerParaObject
& OutlinerParaObject::operator=(const OutlinerParaObject
& rCandidate
)
128 if(rCandidate
.mpImplOutlinerParaObject
!= mpImplOutlinerParaObject
)
130 if(mpImplOutlinerParaObject
->mnRefCount
)
132 mpImplOutlinerParaObject
->mnRefCount
--;
136 delete mpImplOutlinerParaObject
;
139 mpImplOutlinerParaObject
= rCandidate
.mpImplOutlinerParaObject
;
140 mpImplOutlinerParaObject
->mnRefCount
++;
146 bool OutlinerParaObject::operator==(const OutlinerParaObject
& rCandidate
) const
148 if(rCandidate
.mpImplOutlinerParaObject
== mpImplOutlinerParaObject
)
153 return (*rCandidate
.mpImplOutlinerParaObject
== *mpImplOutlinerParaObject
);
157 bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject
& rCompare
) const
159 if(rCompare
.mpImplOutlinerParaObject
== mpImplOutlinerParaObject
)
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
)
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
)
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();
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
];
230 OSL_ENSURE(false, "OutlinerParaObject::GetParagraphData: Access out of range (!)");
231 static ParagraphData aEmptyParagraphData
;
232 return aEmptyParagraphData
;
236 void OutlinerParaObject::ClearPortionInfo()
239 mpImplOutlinerParaObject
->mpEditTextObject
->ClearPortionInfo();
242 bool OutlinerParaObject::ChangeStyleSheets(const XubString
& rOldName
, SfxStyleFamily eOldFamily
, const XubString
& rNewName
, SfxStyleFamily eNewFamily
)
245 return mpImplOutlinerParaObject
->mpEditTextObject
->ChangeStyleSheets(rOldName
, eOldFamily
, rNewName
, eNewFamily
);
248 void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily
, const XubString
& rOldName
, const XubString
& rNewName
)
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());
261 sal_uInt16
nDecrementer(sal::static_int_cast
< sal_uInt16
>(nCount
));
265 if(GetDepth(--nDecrementer
) == nLevel
)
267 mpImplOutlinerParaObject
->mpEditTextObject
->SetStyleSheet(nDecrementer
, rNewName
, rNewFamily
);
273 //////////////////////////////////////////////////////////////////////////////