LCOV - code coverage report
Current view: top level - editeng/source/outliner - outlobj.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 105 0.0 %
Date: 2014-04-14 Functions: 0 25 0.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           0 :     ImplOutlinerParaObject(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
      50             :     :   mpEditTextObject(pEditTextObject),
      51             :         maParagraphDataVector(rParagraphDataVector),
      52             :         mbIsEditDoc(bIsEditDoc),
      53           0 :         mnRefCount(0)
      54             :     {
      55           0 :         if( maParagraphDataVector.empty() && (pEditTextObject->GetParagraphCount() != 0) )
      56           0 :             maParagraphDataVector.resize(pEditTextObject->GetParagraphCount());
      57           0 :     }
      58             : 
      59             :     // destructor
      60           0 :     ~ImplOutlinerParaObject()
      61           0 :     {
      62           0 :         delete mpEditTextObject;
      63           0 :     }
      64             : 
      65           0 :     bool operator==(const ImplOutlinerParaObject& rCandidate) const
      66             :     {
      67           0 :         return (*mpEditTextObject == *rCandidate.mpEditTextObject
      68           0 :             && maParagraphDataVector == rCandidate.maParagraphDataVector
      69           0 :             && mbIsEditDoc == rCandidate.mbIsEditDoc);
      70             :     }
      71             : 
      72             :     // #i102062#
      73           0 :     bool isWrongListEqual(const ImplOutlinerParaObject& rCompare) const
      74             :     {
      75           0 :         return mpEditTextObject->isWrongListEqual(*rCompare.mpEditTextObject);
      76             :     }
      77             : };
      78             : 
      79             : 
      80             : 
      81           0 : void OutlinerParaObject::ImplMakeUnique()
      82             : {
      83           0 :     if(mpImplOutlinerParaObject->mnRefCount)
      84             :     {
      85             :         ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject(
      86           0 :             mpImplOutlinerParaObject->mpEditTextObject->Clone(),
      87             :             mpImplOutlinerParaObject->maParagraphDataVector,
      88           0 :             mpImplOutlinerParaObject->mbIsEditDoc);
      89           0 :         mpImplOutlinerParaObject->mnRefCount--;
      90           0 :         mpImplOutlinerParaObject = pNew;
      91             :     }
      92           0 : }
      93             : 
      94           0 : OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc)
      95           0 : :   mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc))
      96             : {
      97           0 : }
      98             : 
      99           0 : OutlinerParaObject::OutlinerParaObject( const EditTextObject& rEditTextObject)
     100           0 : :   mpImplOutlinerParaObject( new ImplOutlinerParaObject( rEditTextObject.Clone(), ParagraphDataVector(), true))
     101           0 : {}
     102             : 
     103           0 : OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate)
     104           0 : :   mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject)
     105             : {
     106           0 :     mpImplOutlinerParaObject->mnRefCount++;
     107           0 : }
     108             : 
     109           0 : OutlinerParaObject::~OutlinerParaObject()
     110             : {
     111           0 :     if(mpImplOutlinerParaObject->mnRefCount)
     112             :     {
     113           0 :         mpImplOutlinerParaObject->mnRefCount--;
     114             :     }
     115             :     else
     116             :     {
     117           0 :         delete mpImplOutlinerParaObject;
     118             :     }
     119           0 : }
     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           0 : bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const
     142             : {
     143           0 :     if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
     144             :     {
     145           0 :         return true;
     146             :     }
     147             : 
     148           0 :     return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject);
     149             : }
     150             : 
     151             : // #i102062#
     152           0 : bool OutlinerParaObject::isWrongListEqual(const OutlinerParaObject& rCompare) const
     153             : {
     154           0 :     if(rCompare.mpImplOutlinerParaObject == mpImplOutlinerParaObject)
     155             :     {
     156           0 :         return true;
     157             :     }
     158             : 
     159           0 :     return mpImplOutlinerParaObject->isWrongListEqual(*rCompare.mpImplOutlinerParaObject);
     160             : }
     161             : 
     162           0 : sal_uInt16 OutlinerParaObject::GetOutlinerMode() const
     163             : {
     164           0 :     return mpImplOutlinerParaObject->mpEditTextObject->GetUserType();
     165             : }
     166             : 
     167           0 : void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew)
     168             : {
     169           0 :     if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew)
     170             :     {
     171           0 :         ImplMakeUnique();
     172           0 :         mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew);
     173             :     }
     174           0 : }
     175             : 
     176           0 : bool OutlinerParaObject::IsVertical() const
     177             : {
     178           0 :     return mpImplOutlinerParaObject->mpEditTextObject->IsVertical();
     179             : }
     180             : 
     181           0 : void OutlinerParaObject::SetVertical(bool bNew)
     182             : {
     183           0 :     if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew)
     184             :     {
     185           0 :         ImplMakeUnique();
     186           0 :         mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew);
     187             :     }
     188           0 : }
     189             : 
     190           0 : sal_Int32 OutlinerParaObject::Count() const
     191             : {
     192           0 :     size_t nSize = mpImplOutlinerParaObject->maParagraphDataVector.size();
     193           0 :     if (nSize > EE_PARA_MAX_COUNT)
     194             :     {
     195             :         SAL_WARN( "editeng", "OutlinerParaObject::Count - overflow " << nSize);
     196           0 :         return EE_PARA_MAX_COUNT;
     197             :     }
     198           0 :     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           0 : const EditTextObject& OutlinerParaObject::GetTextObject() const
     214             : {
     215           0 :     return *mpImplOutlinerParaObject->mpEditTextObject;
     216             : }
     217             : 
     218           0 : bool OutlinerParaObject::IsEditDoc() const
     219             : {
     220           0 :     return mpImplOutlinerParaObject->mbIsEditDoc;
     221             : }
     222             : 
     223           0 : const ParagraphData& OutlinerParaObject::GetParagraphData(sal_Int32 nIndex) const
     224             : {
     225           0 :     if(0 <= nIndex && static_cast<size_t>(nIndex) < mpImplOutlinerParaObject->maParagraphDataVector.size())
     226             :     {
     227           0 :         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           0 : void OutlinerParaObject::ClearPortionInfo()
     238             : {
     239           0 :     ImplMakeUnique();
     240           0 :     mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo();
     241           0 : }
     242             : 
     243           0 : bool OutlinerParaObject::ChangeStyleSheets(const OUString& rOldName,
     244             :     SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily)
     245             : {
     246           0 :     ImplMakeUnique();
     247           0 :     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