update credits
[LibreOffice.git] / editeng / source / outliner / outlobj.cxx
blob32b76de5300f1aa4d7e0d55c781ad66c91e1b3e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svl/intitem.hxx>
21 #include <editeng/editeng.hxx>
22 #include <editeng/editview.hxx>
23 #include <editeng/editdata.hxx>
24 #include <editeng/eerdll.hxx>
25 #include <editeng/lrspitem.hxx>
26 #include <editeng/fhgtitem.hxx>
28 #include <editeng/outliner.hxx>
29 #include <editeng/outlobj.hxx>
30 #include <outleeng.hxx>
31 #include <editeng/editobj.hxx>
32 #include <vcl/bitmap.hxx>
33 #include <tools/stream.hxx>
35 //////////////////////////////////////////////////////////////////////////////
37 class ImplOutlinerParaObject
39 public:
40 // data members
41 EditTextObject* mpEditTextObject;
42 ParagraphDataVector maParagraphDataVector;
43 bool mbIsEditDoc;
45 // refcounter
46 sal_uInt32 mnRefCount;
48 // constuctor
49 ImplOutlinerParaObject(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
50 : mpEditTextObject(pEditTextObject),
51 maParagraphDataVector(rParagraphDataVector),
52 mbIsEditDoc(bIsEditDoc),
53 mnRefCount(0)
55 if( maParagraphDataVector.empty() && (pEditTextObject->GetParagraphCount() != 0) )
56 maParagraphDataVector.resize(pEditTextObject->GetParagraphCount());
59 // destructor
60 ~ImplOutlinerParaObject()
62 delete mpEditTextObject;
65 bool operator==(const ImplOutlinerParaObject& rCandidate) const
67 return (*mpEditTextObject == *rCandidate.mpEditTextObject
68 && maParagraphDataVector == rCandidate.maParagraphDataVector
69 && mbIsEditDoc == rCandidate.mbIsEditDoc);
72 // #i102062#
73 bool isWrongListEqual(const ImplOutlinerParaObject& rCompare) const
75 return mpEditTextObject->isWrongListEqual(*rCompare.mpEditTextObject);
79 //////////////////////////////////////////////////////////////////////////////
81 void OutlinerParaObject::ImplMakeUnique()
83 if(mpImplOutlinerParaObject->mnRefCount)
85 ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject(
86 mpImplOutlinerParaObject->mpEditTextObject->Clone(),
87 mpImplOutlinerParaObject->maParagraphDataVector,
88 mpImplOutlinerParaObject->mbIsEditDoc);
89 mpImplOutlinerParaObject->mnRefCount--;
90 mpImplOutlinerParaObject = pNew;
94 OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
95 : mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc))
99 OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate)
100 : mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject)
102 mpImplOutlinerParaObject->mnRefCount++;
105 OutlinerParaObject::~OutlinerParaObject()
107 if(mpImplOutlinerParaObject->mnRefCount)
109 mpImplOutlinerParaObject->mnRefCount--;
111 else
113 delete mpImplOutlinerParaObject;
117 OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate)
119 if(rCandidate.mpImplOutlinerParaObject != mpImplOutlinerParaObject)
121 if(mpImplOutlinerParaObject->mnRefCount)
123 mpImplOutlinerParaObject->mnRefCount--;
125 else
127 delete mpImplOutlinerParaObject;
130 mpImplOutlinerParaObject = rCandidate.mpImplOutlinerParaObject;
131 mpImplOutlinerParaObject->mnRefCount++;
134 return *this;
137 bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const
139 if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
141 return true;
144 return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject);
147 // #i102062#
148 bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const
150 if(rCompare.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
152 return true;
155 return mpImplOutlinerParaObject->isWrongListEqual(*rCompare.mpImplOutlinerParaObject);
158 sal_uInt16 OutlinerParaObject::GetOutlinerMode() const
160 return mpImplOutlinerParaObject->mpEditTextObject->GetUserType();
163 void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew)
165 if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew)
167 ImplMakeUnique();
168 mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew);
172 bool OutlinerParaObject::IsVertical() const
174 return mpImplOutlinerParaObject->mpEditTextObject->IsVertical();
177 void OutlinerParaObject::SetVertical(bool bNew)
179 if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew)
181 ImplMakeUnique();
182 mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew);
186 sal_Int32 OutlinerParaObject::Count() const
188 size_t nSize = mpImplOutlinerParaObject->maParagraphDataVector.size();
189 if (nSize > EE_PARA_MAX_COUNT)
191 SAL_WARN( "editeng", "OutlinerParaObject::Count - overflow " << nSize);
192 return EE_PARA_MAX_COUNT;
194 return static_cast<sal_Int32>(nSize);
197 sal_Int16 OutlinerParaObject::GetDepth(sal_Int32 nPara) const
199 if(0 <= nPara && static_cast<size_t>(nPara) < mpImplOutlinerParaObject->maParagraphDataVector.size())
201 return mpImplOutlinerParaObject->maParagraphDataVector[nPara].getDepth();
203 else
205 return -1;
209 const EditTextObject& OutlinerParaObject::GetTextObject() const
211 return *mpImplOutlinerParaObject->mpEditTextObject;
214 bool OutlinerParaObject::IsEditDoc() const
216 return mpImplOutlinerParaObject->mbIsEditDoc;
219 const ParagraphData& OutlinerParaObject::GetParagraphData(sal_Int32 nIndex) const
221 if(0 <= nIndex && static_cast<size_t>(nIndex) < mpImplOutlinerParaObject->maParagraphDataVector.size())
223 return mpImplOutlinerParaObject->maParagraphDataVector[nIndex];
225 else
227 OSL_FAIL("OutlinerParaObject::GetParagraphData: Access out of range (!)");
228 static ParagraphData aEmptyParagraphData;
229 return aEmptyParagraphData;
233 void OutlinerParaObject::ClearPortionInfo()
235 ImplMakeUnique();
236 mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo();
239 bool OutlinerParaObject::ChangeStyleSheets(const OUString& rOldName,
240 SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily)
242 ImplMakeUnique();
243 return mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
246 void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily,
247 const OUString& rOldName, const OUString& rNewName)
249 ImplMakeUnique();
250 mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
253 void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const OUString rNewName,
254 const SfxStyleFamily& rNewFamily)
256 const sal_Int32 nCount(Count());
258 if(nCount)
260 ImplMakeUnique();
261 sal_Int32 nDecrementer(nCount);
263 for(;nDecrementer;)
265 if(GetDepth(--nDecrementer) == nLevel)
267 mpImplOutlinerParaObject->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */