1*190118d0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*190118d0SAndrew Rist * distributed with this work for additional information 6*190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*190118d0SAndrew Rist * "License"); you may not use this file except in compliance 9*190118d0SAndrew Rist * with the License. You may obtain a copy of the License at 10*190118d0SAndrew Rist * 11*190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*190118d0SAndrew Rist * 13*190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*190118d0SAndrew Rist * software distributed under the License is distributed on an 15*190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*190118d0SAndrew Rist * KIND, either express or implied. See the License for the 17*190118d0SAndrew Rist * specific language governing permissions and limitations 18*190118d0SAndrew Rist * under the License. 19*190118d0SAndrew Rist * 20*190118d0SAndrew Rist *************************************************************/ 21*190118d0SAndrew Rist 22*190118d0SAndrew 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 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 62cdf0e10cSrcweir ~ImplOutlinerParaObject() 63cdf0e10cSrcweir { 64cdf0e10cSrcweir delete mpEditTextObject; 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir bool operator==(const ImplOutlinerParaObject& rCandidate) const 68cdf0e10cSrcweir { 69cdf0e10cSrcweir return (*mpEditTextObject == *rCandidate.mpEditTextObject 70cdf0e10cSrcweir && maParagraphDataVector == rCandidate.maParagraphDataVector 71cdf0e10cSrcweir && mbIsEditDoc == rCandidate.mbIsEditDoc); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir // #i102062# 75cdf0e10cSrcweir bool isWrongListEqual(const ImplOutlinerParaObject& rCompare) const 76cdf0e10cSrcweir { 77cdf0e10cSrcweir return mpEditTextObject->isWrongListEqual(*rCompare.mpEditTextObject); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir 81cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 82cdf0e10cSrcweir 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 96cdf0e10cSrcweir OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc) 97cdf0e10cSrcweir : mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc)) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate) 102cdf0e10cSrcweir : mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir mpImplOutlinerParaObject->mnRefCount++; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir OutlinerParaObject::~OutlinerParaObject() 108cdf0e10cSrcweir { 109cdf0e10cSrcweir if(mpImplOutlinerParaObject->mnRefCount) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir mpImplOutlinerParaObject->mnRefCount--; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir else 114cdf0e10cSrcweir { 115cdf0e10cSrcweir delete mpImplOutlinerParaObject; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir if(rCandidate.mpImplOutlinerParaObject != mpImplOutlinerParaObject) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir if(mpImplOutlinerParaObject->mnRefCount) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir mpImplOutlinerParaObject->mnRefCount--; 126cdf0e10cSrcweir } 127cdf0e10cSrcweir else 128cdf0e10cSrcweir { 129cdf0e10cSrcweir delete mpImplOutlinerParaObject; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir mpImplOutlinerParaObject = rCandidate.mpImplOutlinerParaObject; 133cdf0e10cSrcweir mpImplOutlinerParaObject->mnRefCount++; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir return *this; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const 140cdf0e10cSrcweir { 141cdf0e10cSrcweir if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir return true; 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir // #i102062# 150cdf0e10cSrcweir bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const 151cdf0e10cSrcweir { 152cdf0e10cSrcweir if(rCompare.mpImplOutlinerParaObject == mpImplOutlinerParaObject) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir return true; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir return mpImplOutlinerParaObject->isWrongListEqual(*rCompare.mpImplOutlinerParaObject); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir sal_uInt16 OutlinerParaObject::GetOutlinerMode() const 161cdf0e10cSrcweir { 162cdf0e10cSrcweir return mpImplOutlinerParaObject->mpEditTextObject->GetUserType(); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir ImplMakeUnique(); 170cdf0e10cSrcweir mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir bool OutlinerParaObject::IsVertical() const 175cdf0e10cSrcweir { 176cdf0e10cSrcweir return mpImplOutlinerParaObject->mpEditTextObject->IsVertical(); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir void OutlinerParaObject::SetVertical(bool bNew) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir ImplMakeUnique(); 184cdf0e10cSrcweir mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir sal_uInt32 OutlinerParaObject::Count() const 189cdf0e10cSrcweir { 190cdf0e10cSrcweir return mpImplOutlinerParaObject->maParagraphDataVector.size(); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir sal_Int16 OutlinerParaObject::GetDepth(sal_uInt16 nPara) const 194cdf0e10cSrcweir { 195cdf0e10cSrcweir if(nPara < mpImplOutlinerParaObject->maParagraphDataVector.size()) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir return mpImplOutlinerParaObject->maParagraphDataVector[nPara].getDepth(); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir else 200cdf0e10cSrcweir { 201cdf0e10cSrcweir return -1; 202cdf0e10cSrcweir } 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir const EditTextObject& OutlinerParaObject::GetTextObject() const 206cdf0e10cSrcweir { 207cdf0e10cSrcweir return *mpImplOutlinerParaObject->mpEditTextObject; 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir bool OutlinerParaObject::IsEditDoc() const 211cdf0e10cSrcweir { 212cdf0e10cSrcweir return mpImplOutlinerParaObject->mbIsEditDoc; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir const ParagraphData& OutlinerParaObject::GetParagraphData(sal_uInt32 nIndex) const 216cdf0e10cSrcweir { 217cdf0e10cSrcweir if(nIndex < mpImplOutlinerParaObject->maParagraphDataVector.size()) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir return mpImplOutlinerParaObject->maParagraphDataVector[nIndex]; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir else 222cdf0e10cSrcweir { 223cdf0e10cSrcweir OSL_ENSURE(false, "OutlinerParaObject::GetParagraphData: Access out of range (!)"); 224cdf0e10cSrcweir static ParagraphData aEmptyParagraphData; 225cdf0e10cSrcweir return aEmptyParagraphData; 226cdf0e10cSrcweir } 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir void OutlinerParaObject::ClearPortionInfo() 230cdf0e10cSrcweir { 231cdf0e10cSrcweir ImplMakeUnique(); 232cdf0e10cSrcweir mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo(); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir bool OutlinerParaObject::ChangeStyleSheets(const XubString& rOldName, SfxStyleFamily eOldFamily, const XubString& rNewName, SfxStyleFamily eNewFamily) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir ImplMakeUnique(); 238cdf0e10cSrcweir return mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir ImplMakeUnique(); 244cdf0e10cSrcweir mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName); 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const XubString rNewName, const SfxStyleFamily& rNewFamily) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir const sal_uInt32 nCount(mpImplOutlinerParaObject->maParagraphDataVector.size()); 250cdf0e10cSrcweir 251cdf0e10cSrcweir if(nCount) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir ImplMakeUnique(); 254cdf0e10cSrcweir sal_uInt16 nDecrementer(sal::static_int_cast< sal_uInt16 >(nCount)); 255cdf0e10cSrcweir 256cdf0e10cSrcweir for(;nDecrementer;) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir if(GetDepth(--nDecrementer) == nLevel) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir mpImplOutlinerParaObject->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir } 263cdf0e10cSrcweir } 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 267cdf0e10cSrcweir // eof 268