LCOV - code coverage report
Current view: top level - editeng/source/outliner - outlobj.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 77 105 73.3 %
Date: 2014-04-11 Functions: 21 25 84.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      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>
      27             : 
      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>
      34             : 
      35             : 
      36             : 
      37             : class ImplOutlinerParaObject
      38             : {
      39             : public:
      40             :     // data members
      41             :     EditTextObject*                 mpEditTextObject;
      42             :     ParagraphDataVector             maParagraphDataVector;
      43             :     bool                            mbIsEditDoc;
      44             : 
      45             :     // refcounter
      46             :     sal_uInt32                      mnRefCount;
      47             : 
      48             :     // constuctor
      49       65575 :     ImplOutlinerParaObject(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
      50             :     :   mpEditTextObject(pEditTextObject),
      51             :         maParagraphDataVector(rParagraphDataVector),
      52             :         mbIsEditDoc(bIsEditDoc),
      53       65575 :         mnRefCount(0)
      54             :     {
      55       65575 :         if( maParagraphDataVector.empty() && (pEditTextObject->GetParagraphCount() != 0) )
      56          97 :             maParagraphDataVector.resize(pEditTextObject->GetParagraphCount());
      57       65575 :     }
      58             : 
      59             :     // destructor
      60       63360 :     ~ImplOutlinerParaObject()
      61       63360 :     {
      62       63360 :         delete mpEditTextObject;
      63       63360 :     }
      64             : 
      65        1909 :     bool operator==(const ImplOutlinerParaObject& rCandidate) const
      66             :     {
      67        1909 :         return (*mpEditTextObject == *rCandidate.mpEditTextObject
      68         901 :             && maParagraphDataVector == rCandidate.maParagraphDataVector
      69        2802 :             && mbIsEditDoc == rCandidate.mbIsEditDoc);
      70             :     }
      71             : 
      72             :     // #i102062#
      73         893 :     bool isWrongListEqual(const ImplOutlinerParaObject& rCompare) const
      74             :     {
      75         893 :         return mpEditTextObject->isWrongListEqual(*rCompare.mpEditTextObject);
      76             :     }
      77             : };
      78             : 
      79             : 
      80             : 
      81       70961 : void OutlinerParaObject::ImplMakeUnique()
      82             : {
      83       70961 :     if(mpImplOutlinerParaObject->mnRefCount)
      84             :     {
      85             :         ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject(
      86          37 :             mpImplOutlinerParaObject->mpEditTextObject->Clone(),
      87             :             mpImplOutlinerParaObject->maParagraphDataVector,
      88          37 :             mpImplOutlinerParaObject->mbIsEditDoc);
      89          37 :         mpImplOutlinerParaObject->mnRefCount--;
      90          37 :         mpImplOutlinerParaObject = pNew;
      91             :     }
      92       70961 : }
      93             : 
      94       65441 : OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
      95       65441 : :   mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc))
      96             : {
      97       65441 : }
      98             : 
      99          97 : OutlinerParaObject::OutlinerParaObject( const EditTextObject& rEditTextObject)
     100          97 : :   mpImplOutlinerParaObject( new ImplOutlinerParaObject( rEditTextObject.Clone(), ParagraphDataVector(), true))
     101          97 : {}
     102             : 
     103       40911 : OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate)
     104       40911 : :   mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject)
     105             : {
     106       40911 :     mpImplOutlinerParaObject->mnRefCount++;
     107       40911 : }
     108             : 
     109      100731 : OutlinerParaObject::~OutlinerParaObject()
     110             : {
     111      100731 :     if(mpImplOutlinerParaObject->mnRefCount)
     112             :     {
     113       37371 :         mpImplOutlinerParaObject->mnRefCount--;
     114             :     }
     115             :     else
     116             :     {
     117       63360 :         delete mpImplOutlinerParaObject;
     118             :     }
     119      100731 : }
     120             : 
     121           0 : OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate)
     122             : {
     123           0 :     if(rCandidate.mpImplOutlinerParaObject != mpImplOutlinerParaObject)
     124             :     {
     125           0 :         if(mpImplOutlinerParaObject->mnRefCount)
     126             :         {
     127           0 :             mpImplOutlinerParaObject->mnRefCount--;
     128             :         }
     129             :         else
     130             :         {
     131           0 :             delete mpImplOutlinerParaObject;
     132             :         }
     133             : 
     134           0 :         mpImplOutlinerParaObject = rCandidate.mpImplOutlinerParaObject;
     135           0 :         mpImplOutlinerParaObject->mnRefCount++;
     136             :     }
     137             : 
     138           0 :     return *this;
     139             : }
     140             : 
     141        7967 : bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const
     142             : {
     143        7967 :     if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
     144             :     {
     145        6058 :         return true;
     146             :     }
     147             : 
     148        1909 :     return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject);
     149             : }
     150             : 
     151             : // #i102062#
     152        6951 : bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const
     153             : {
     154        6951 :     if(rCompare.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
     155             :     {
     156        6058 :         return true;
     157             :     }
     158             : 
     159         893 :     return mpImplOutlinerParaObject->isWrongListEqual(*rCompare.mpImplOutlinerParaObject);
     160             : }
     161             : 
     162      156637 : sal_uInt16 OutlinerParaObject::GetOutlinerMode() const
     163             : {
     164      156637 :     return mpImplOutlinerParaObject->mpEditTextObject->GetUserType();
     165             : }
     166             : 
     167       65538 : void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew)
     168             : {
     169       65538 :     if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew)
     170             :     {
     171       65538 :         ImplMakeUnique();
     172       65538 :         mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew);
     173             :     }
     174       65538 : }
     175             : 
     176      182279 : bool OutlinerParaObject::IsVertical() const
     177             : {
     178      182279 :     return mpImplOutlinerParaObject->mpEditTextObject->IsVertical();
     179             : }
     180             : 
     181          70 : void OutlinerParaObject::SetVertical(bool bNew)
     182             : {
     183          70 :     if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew)
     184             :     {
     185           2 :         ImplMakeUnique();
     186           2 :         mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew);
     187             :     }
     188          70 : }
     189             : 
     190      320383 : sal_Int32 OutlinerParaObject::Count() const
     191             : {
     192      320383 :     size_t nSize = mpImplOutlinerParaObject->maParagraphDataVector.size();
     193      320383 :     if (nSize > EE_PARA_MAX_COUNT)
     194             :     {
     195             :         SAL_WARN( "editeng", "OutlinerParaObject::Count - overflow " << nSize);
     196           0 :         return EE_PARA_MAX_COUNT;
     197             :     }
     198      320383 :     return static_cast<sal_Int32>(nSize);
     199             : }
     200             : 
     201           0 : sal_Int16 OutlinerParaObject::GetDepth(sal_Int32 nPara) const
     202             : {
     203           0 :     if(0 <= nPara && static_cast<size_t>(nPara) < mpImplOutlinerParaObject->maParagraphDataVector.size())
     204             :     {
     205           0 :         return mpImplOutlinerParaObject->maParagraphDataVector[nPara].getDepth();
     206             :     }
     207             :     else
     208             :     {
     209           0 :         return -1;
     210             :     }
     211             : }
     212             : 
     213      260229 : const EditTextObject& OutlinerParaObject::GetTextObject() const
     214             : {
     215      260229 :     return *mpImplOutlinerParaObject->mpEditTextObject;
     216             : }
     217             : 
     218       58237 : bool OutlinerParaObject::IsEditDoc() const
     219             : {
     220       58237 :     return mpImplOutlinerParaObject->mbIsEditDoc;
     221             : }
     222             : 
     223      163739 : const ParagraphData& OutlinerParaObject::GetParagraphData(sal_Int32 nIndex) const
     224             : {
     225      163739 :     if(0 <= nIndex && static_cast<size_t>(nIndex) < mpImplOutlinerParaObject->maParagraphDataVector.size())
     226             :     {
     227      163739 :         return mpImplOutlinerParaObject->maParagraphDataVector[nIndex];
     228             :     }
     229             :     else
     230             :     {
     231             :         OSL_FAIL("OutlinerParaObject::GetParagraphData: Access out of range (!)");
     232           0 :         static ParagraphData aEmptyParagraphData;
     233           0 :         return aEmptyParagraphData;
     234             :     }
     235             : }
     236             : 
     237           3 : void OutlinerParaObject::ClearPortionInfo()
     238             : {
     239           3 :     ImplMakeUnique();
     240           3 :     mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo();
     241           3 : }
     242             : 
     243        5418 : bool OutlinerParaObject::ChangeStyleSheets(const OUString& rOldName,
     244             :     SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily)
     245             : {
     246        5418 :     ImplMakeUnique();
     247        5418 :     return mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily);
     248             : }
     249             : 
     250           0 : void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily,
     251             :     const OUString& rOldName, const OUString& rNewName)
     252             : {
     253           0 :     ImplMakeUnique();
     254           0 :     mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName);
     255           0 : }
     256             : 
     257           0 : void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const OUString& rNewName,
     258             :     const SfxStyleFamily& rNewFamily)
     259             : {
     260           0 :     const sal_Int32 nCount(Count());
     261             : 
     262           0 :     if(nCount)
     263             :     {
     264           0 :         ImplMakeUnique();
     265           0 :         sal_Int32 nDecrementer(nCount);
     266             : 
     267           0 :         for(;nDecrementer;)
     268             :         {
     269           0 :             if(GetDepth(--nDecrementer) == nLevel)
     270             :             {
     271           0 :                 mpImplOutlinerParaObject->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily);
     272             :             }
     273             :         }
     274             :     }
     275           0 : }
     276             : 
     277             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10