Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svl/intitem.hxx>
30 : : #include <editeng/editeng.hxx>
31 : : #include <editeng/editview.hxx>
32 : : #include <editeng/editdata.hxx>
33 : : #include <editeng/eerdll.hxx>
34 : : #include <editeng/lrspitem.hxx>
35 : : #include <editeng/fhgtitem.hxx>
36 : :
37 : : #define _OUTLINER_CXX
38 : : #include <editeng/outliner.hxx>
39 : : #include <editeng/outlobj.hxx>
40 : : #include <outleeng.hxx>
41 : : #include <editeng/editobj.hxx>
42 : : #include <vcl/bitmap.hxx>
43 : : #include <tools/stream.hxx>
44 : :
45 : : //////////////////////////////////////////////////////////////////////////////
46 : :
47 : : class ImplOutlinerParaObject
48 : : {
49 : : public:
50 : : // data members
51 : : EditTextObject* mpEditTextObject;
52 : : ParagraphDataVector maParagraphDataVector;
53 : : bool mbIsEditDoc;
54 : :
55 : : // refcounter
56 : : sal_uInt32 mnRefCount;
57 : :
58 : : // constuctor
59 : 54098 : ImplOutlinerParaObject(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
60 : : : mpEditTextObject(pEditTextObject),
61 : : maParagraphDataVector(rParagraphDataVector),
62 : : mbIsEditDoc(bIsEditDoc),
63 : 54098 : mnRefCount(0)
64 : : {
65 [ + - ][ + - ]: 54098 : if( maParagraphDataVector.empty() && (pEditTextObject->GetParagraphCount() != 0) )
[ + + ][ + + ]
66 [ + - ][ + - ]: 180 : maParagraphDataVector.resize(pEditTextObject->GetParagraphCount());
67 : 54098 : }
68 : :
69 : : // destructor
70 : 54029 : ~ImplOutlinerParaObject()
71 : 54029 : {
72 [ + - ][ + - ]: 54029 : delete mpEditTextObject;
73 : 54029 : }
74 : :
75 : 1544 : bool operator==(const ImplOutlinerParaObject& rCandidate) const
76 : : {
77 : 1544 : return (*mpEditTextObject == *rCandidate.mpEditTextObject
78 : 219 : && maParagraphDataVector == rCandidate.maParagraphDataVector
79 [ + - ]: 1763 : && mbIsEditDoc == rCandidate.mbIsEditDoc);
[ + + + + ]
80 : : }
81 : :
82 : : // #i102062#
83 : 201 : bool isWrongListEqual(const ImplOutlinerParaObject& rCompare) const
84 : : {
85 : 201 : return mpEditTextObject->isWrongListEqual(*rCompare.mpEditTextObject);
86 : : }
87 : : };
88 : :
89 : : //////////////////////////////////////////////////////////////////////////////
90 : :
91 : 55791 : void OutlinerParaObject::ImplMakeUnique()
92 : : {
93 [ + + ]: 55791 : if(mpImplOutlinerParaObject->mnRefCount)
94 : : {
95 : : ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject(
96 : 1 : mpImplOutlinerParaObject->mpEditTextObject->Clone(),
97 : : mpImplOutlinerParaObject->maParagraphDataVector,
98 [ + - ]: 1 : mpImplOutlinerParaObject->mbIsEditDoc);
99 : 1 : mpImplOutlinerParaObject->mnRefCount--;
100 : 1 : mpImplOutlinerParaObject = pNew;
101 : : }
102 : 55791 : }
103 : :
104 : 54097 : OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
105 [ + - ]: 54097 : : mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc))
106 : : {
107 : 54097 : }
108 : :
109 : 70317 : OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate)
110 : 70317 : : mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject)
111 : : {
112 : 70317 : mpImplOutlinerParaObject->mnRefCount++;
113 : 70317 : }
114 : :
115 : 124273 : OutlinerParaObject::~OutlinerParaObject()
116 : : {
117 [ + + ]: 124273 : if(mpImplOutlinerParaObject->mnRefCount)
118 : : {
119 : 70244 : mpImplOutlinerParaObject->mnRefCount--;
120 : : }
121 : : else
122 : : {
123 [ + - ]: 54029 : delete mpImplOutlinerParaObject;
124 : : }
125 : 124273 : }
126 : :
127 : 0 : OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate)
128 : : {
129 [ # # ]: 0 : if(rCandidate.mpImplOutlinerParaObject != mpImplOutlinerParaObject)
130 : : {
131 [ # # ]: 0 : if(mpImplOutlinerParaObject->mnRefCount)
132 : : {
133 : 0 : mpImplOutlinerParaObject->mnRefCount--;
134 : : }
135 : : else
136 : : {
137 [ # # ]: 0 : delete mpImplOutlinerParaObject;
138 : : }
139 : :
140 : 0 : mpImplOutlinerParaObject = rCandidate.mpImplOutlinerParaObject;
141 : 0 : mpImplOutlinerParaObject->mnRefCount++;
142 : : }
143 : :
144 : 0 : return *this;
145 : : }
146 : :
147 : 16471 : bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const
148 : : {
149 [ + + ]: 16471 : if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
150 : : {
151 : 14927 : return true;
152 : : }
153 : :
154 : 16471 : return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject);
155 : : }
156 : :
157 : : // #i102062#
158 : 15128 : bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const
159 : : {
160 [ + + ]: 15128 : if(rCompare.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
161 : : {
162 : 14927 : return true;
163 : : }
164 : :
165 : 15128 : return mpImplOutlinerParaObject->isWrongListEqual(*rCompare.mpImplOutlinerParaObject);
166 : : }
167 : :
168 : 126621 : sal_uInt16 OutlinerParaObject::GetOutlinerMode() const
169 : : {
170 : 126621 : return mpImplOutlinerParaObject->mpEditTextObject->GetUserType();
171 : : }
172 : :
173 : 54097 : void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew)
174 : : {
175 [ + - ]: 54097 : if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew)
176 : : {
177 : 54097 : ImplMakeUnique();
178 : 54097 : mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew);
179 : : }
180 : 54097 : }
181 : :
182 : 143920 : bool OutlinerParaObject::IsVertical() const
183 : : {
184 : 143920 : return mpImplOutlinerParaObject->mpEditTextObject->IsVertical();
185 : : }
186 : :
187 : 144 : void OutlinerParaObject::SetVertical(bool bNew)
188 : : {
189 [ - + ]: 144 : if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew)
190 : : {
191 : 0 : ImplMakeUnique();
192 : 0 : mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew);
193 : : }
194 : 144 : }
195 : :
196 : 389256 : sal_uInt32 OutlinerParaObject::Count() const
197 : : {
198 : 389256 : return mpImplOutlinerParaObject->maParagraphDataVector.size();
199 : : }
200 : :
201 : 0 : sal_Int16 OutlinerParaObject::GetDepth(sal_uInt16 nPara) const
202 : : {
203 [ # # ]: 0 : if(nPara < mpImplOutlinerParaObject->maParagraphDataVector.size())
204 : : {
205 : 0 : return mpImplOutlinerParaObject->maParagraphDataVector[nPara].getDepth();
206 : : }
207 : : else
208 : : {
209 : 0 : return -1;
210 : : }
211 : : }
212 : :
213 : 209702 : const EditTextObject& OutlinerParaObject::GetTextObject() const
214 : : {
215 : 209702 : return *mpImplOutlinerParaObject->mpEditTextObject;
216 : : }
217 : :
218 : 53249 : bool OutlinerParaObject::IsEditDoc() const
219 : : {
220 : 53249 : return mpImplOutlinerParaObject->mbIsEditDoc;
221 : : }
222 : :
223 : 136014 : const ParagraphData& OutlinerParaObject::GetParagraphData(sal_uInt32 nIndex) const
224 : : {
225 [ + - ]: 136014 : if(nIndex < mpImplOutlinerParaObject->maParagraphDataVector.size())
226 : : {
227 : 136014 : return mpImplOutlinerParaObject->maParagraphDataVector[nIndex];
228 : : }
229 : : else
230 : : {
231 : : OSL_FAIL("OutlinerParaObject::GetParagraphData: Access out of range (!)");
232 [ # # ][ # # ]: 0 : static ParagraphData aEmptyParagraphData;
[ # # ][ # # ]
233 : 136014 : return aEmptyParagraphData;
234 : : }
235 : : }
236 : :
237 : 0 : void OutlinerParaObject::ClearPortionInfo()
238 : : {
239 : 0 : ImplMakeUnique();
240 : 0 : mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo();
241 : 0 : }
242 : :
243 : 1694 : bool OutlinerParaObject::ChangeStyleSheets(const XubString& rOldName, SfxStyleFamily eOldFamily, const XubString& rNewName, SfxStyleFamily eNewFamily)
244 : : {
245 : 1694 : ImplMakeUnique();
246 : 1694 : return mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
247 : : }
248 : :
249 : 0 : void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName)
250 : : {
251 : 0 : ImplMakeUnique();
252 : 0 : mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
253 : 0 : }
254 : :
255 : 0 : void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const XubString rNewName, const SfxStyleFamily& rNewFamily)
256 : : {
257 : 0 : const sal_uInt32 nCount(mpImplOutlinerParaObject->maParagraphDataVector.size());
258 : :
259 [ # # ]: 0 : if(nCount)
260 : : {
261 : 0 : ImplMakeUnique();
262 : 0 : sal_uInt16 nDecrementer(sal::static_int_cast< sal_uInt16 >(nCount));
263 : :
264 [ # # ]: 0 : for(;nDecrementer;)
265 : : {
266 [ # # ]: 0 : if(GetDepth(--nDecrementer) == nLevel)
267 : : {
268 : 0 : mpImplOutlinerParaObject->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
269 : : }
270 : : }
271 : : }
272 : 0 : }
273 : :
274 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|