LCOV - code coverage report
Current view: top level - editeng/source/editeng - editobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 297 731 40.6 %
Date: 2012-08-25 Functions: 43 108 39.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 235 943 24.9 %

           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 <comphelper/string.hxx>
      30                 :            : #include <rtl/strbuf.hxx>
      31                 :            : #include <vcl/wrkwin.hxx>
      32                 :            : #include <vcl/dialog.hxx>
      33                 :            : #include <vcl/msgbox.hxx>
      34                 :            : #include <vcl/svapp.hxx>
      35                 :            : 
      36                 :            : #include <tools/stream.hxx>
      37                 :            : 
      38                 :            : #include "editeng/fieldupdater.hxx"
      39                 :            : #include <editobj2.hxx>
      40                 :            : #include <editeng/editdata.hxx>
      41                 :            : #include <editattr.hxx>
      42                 :            : #include <editeng/editeng.hxx>
      43                 :            : #include <editeng/fontitem.hxx>
      44                 :            : #include <editeng/cscoitem.hxx>
      45                 :            : #include <editeng/flditem.hxx>
      46                 :            : #include <editeng/lrspitem.hxx>
      47                 :            : #include <editeng/tstpitem.hxx>
      48                 :            : #include <editeng/bulitem.hxx>
      49                 :            : #include <editeng/numitem.hxx>
      50                 :            : #include <editeng/brshitem.hxx>
      51                 :            : #include <vcl/graph.hxx>
      52                 :            : #include <svl/intitem.hxx>
      53                 :            : #include <unotools/fontcvt.hxx>
      54                 :            : #include <tools/tenccvt.hxx>
      55                 :            : 
      56                 :            : DBG_NAME( EE_EditTextObject )
      57                 :            : DBG_NAME( XEditAttribute )
      58                 :            : 
      59                 :            : //--------------------------------------------------------------
      60                 :            : 
      61                 :     132559 : XEditAttribute* MakeXEditAttribute( SfxItemPool& rPool, const SfxPoolItem& rItem, sal_uInt16 nStart, sal_uInt16 nEnd )
      62                 :            : {
      63                 :            :     // Create thw new attribute in the pool
      64                 :     132559 :     const SfxPoolItem& rNew = rPool.Put( rItem );
      65                 :            : 
      66                 :     132559 :     XEditAttribute* pNew = new XEditAttribute( rNew, nStart, nEnd );
      67                 :     132559 :     return pNew;
      68                 :            : }
      69                 :            : 
      70                 :     132559 : XEditAttribute::XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE )
      71                 :            : {
      72                 :            :     DBG_CTOR( XEditAttribute, 0 );
      73                 :     132559 :     pItem = &rAttr;
      74                 :     132559 :     nStart = nS;
      75                 :     132559 :     nEnd = nE;
      76                 :     132559 : }
      77                 :            : 
      78                 :     129053 : XEditAttribute::~XEditAttribute()
      79                 :            : {
      80                 :            :     DBG_DTOR( XEditAttribute, 0 );
      81                 :     129053 :     pItem = 0;  // belongs to the Pool.
      82                 :     129053 : }
      83                 :            : 
      84                 :          0 : bool XEditAttribute::IsFeature() const
      85                 :            : {
      86                 :          0 :     sal_uInt16 nWhich = pItem->Which();
      87 [ #  # ][ #  # ]:          0 :     return  ((nWhich >= EE_FEATURE_START) && (nWhich <=  EE_FEATURE_END));
      88                 :            : }
      89                 :            : 
      90                 :          0 : void XEditAttribute::SetItem(const SfxPoolItem& rNew)
      91                 :            : {
      92                 :          0 :     pItem = &rNew;
      93                 :          0 : }
      94                 :            : 
      95                 :          0 : XParaPortionList::XParaPortionList(
      96                 :            :     OutputDevice* pRefDev, sal_uLong nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY) :
      97         [ #  # ]:          0 :     aRefMapMode(pRefDev->GetMapMode()), nStretchX(_nStretchX), nStretchY(_nStretchY)
      98                 :            : {
      99                 :          0 :     nRefDevPtr = (sal_uIntPtr)pRefDev; nPaperWidth = nPW;
     100                 :          0 :     eRefDevType = pRefDev->GetOutDevType();
     101                 :          0 : }
     102                 :            : 
     103                 :          0 : void XParaPortionList::push_back(XParaPortion* p)
     104                 :            : {
     105                 :          0 :     maList.push_back(p);
     106                 :          0 : }
     107                 :            : 
     108                 :          0 : const XParaPortion& XParaPortionList::operator [](size_t i) const
     109                 :            : {
     110                 :          0 :     return maList[i];
     111                 :            : }
     112                 :            : 
     113 [ +  - ][ +  - ]:      69230 : ContentInfo::ContentInfo( SfxItemPool& rPool ) : aParaAttribs( rPool, EE_PARA_START, EE_CHAR_END )
                 [ +  - ]
     114                 :            : {
     115                 :      69230 :     eFamily = SFX_STYLE_FAMILY_PARA;
     116                 :      69230 :     pWrongs = NULL;
     117                 :      69230 : }
     118                 :            : 
     119                 :            : // the real Copy constructor is nonsens, since I have to work with another Pool!
     120                 :      74575 : ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse )
     121                 :            :     : aParaAttribs( rPoolToUse, EE_PARA_START, EE_CHAR_END )
     122 [ +  - ][ +  - ]:      74575 :     , pWrongs(0)
                 [ +  - ]
     123                 :            : {
     124                 :            :     // this should ensure that the Items end up in the correct Pool!
     125         [ +  - ]:      74575 :     aParaAttribs.Set( rCopyFrom.GetParaAttribs() );
     126         [ +  - ]:      74575 :     aText = rCopyFrom.GetText();
     127         [ +  - ]:      74575 :     aStyle = rCopyFrom.GetStyle();
     128                 :      74575 :     eFamily = rCopyFrom.GetFamily();
     129                 :            : 
     130         [ +  + ]:     144760 :     for (size_t i = 0; i < rCopyFrom.aAttribs.size(); ++i)
     131                 :            :     {
     132         [ +  - ]:      70185 :         const XEditAttribute& rAttr = rCopyFrom.aAttribs[i];
     133                 :            :         XEditAttribute* pMyAttr = MakeXEditAttribute(
     134         [ +  - ]:      70185 :             rPoolToUse, *rAttr.GetItem(), rAttr.GetStart(), rAttr.GetEnd());
     135         [ +  - ]:      70185 :         aAttribs.push_back(pMyAttr);
     136                 :            :     }
     137                 :            : 
     138         [ +  + ]:      74575 :     if ( rCopyFrom.GetWrongList() )
     139         [ +  - ]:       5120 :         pWrongs = rCopyFrom.GetWrongList()->Clone();
     140                 :      74575 : }
     141                 :            : 
     142 [ +  - ][ +  - ]:     140949 : ContentInfo::~ContentInfo()
                 [ +  - ]
     143                 :            : {
     144 [ +  - ][ +  - ]:     140949 :     XEditAttributesType::iterator it = aAttribs.begin(), itEnd = aAttribs.end();
     145 [ +  - ][ +  - ]:     270002 :     for (; it != itEnd; ++it)
                 [ +  + ]
     146 [ +  - ][ +  - ]:     129053 :         aParaAttribs.GetPool()->Remove(*it->GetItem());
     147         [ +  - ]:     140949 :     aAttribs.clear();
     148                 :            : 
     149 [ +  + ][ +  - ]:     140949 :     delete pWrongs;
     150                 :     140949 : }
     151                 :            : 
     152                 :            : // #i102062#
     153                 :        792 : bool ContentInfo::isWrongListEqual(const ContentInfo& rCompare) const
     154                 :            : {
     155         [ +  - ]:        792 :     if(GetWrongList() == rCompare.GetWrongList())
     156                 :        792 :         return true;
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 :     if(!GetWrongList() || !rCompare.GetWrongList())
                 [ #  # ]
     159                 :          0 :         return false;
     160                 :            : 
     161                 :        792 :     return (*GetWrongList() == *rCompare.GetWrongList());
     162                 :            : }
     163                 :            : 
     164                 :       2440 : bool ContentInfo::operator==( const ContentInfo& rCompare ) const
     165                 :            : {
     166   [ +  +  +  +  :       8764 :     if( (aText == rCompare.aText) &&
                   +  + ]
           [ +  -  +  + ]
                 [ +  + ]
     167                 :       2384 :             (aStyle == rCompare.aStyle ) &&
     168                 :       2065 :             (aAttribs.size() == rCompare.aAttribs.size()) &&
     169                 :            :             (eFamily == rCompare.eFamily ) &&
     170                 :       1875 :             (aParaAttribs == rCompare.aParaAttribs ) )
     171                 :            :     {
     172         [ +  + ]:      24359 :         for (size_t i = 0, n = aAttribs.size(); i < n; ++i)
     173                 :            :         {
     174         [ +  + ]:      23182 :             if (aAttribs[i] != rCompare.aAttribs[i])
     175                 :         98 :                 return false;
     176                 :            :         }
     177                 :            : 
     178                 :       1177 :         return true;
     179                 :            :     }
     180                 :            : 
     181                 :       2440 :     return false;
     182                 :            : }
     183                 :            : 
     184                 :       2440 : bool ContentInfo::operator!=(const ContentInfo& rCompare) const
     185                 :            : {
     186                 :       2440 :     return !operator==(rCompare);
     187                 :            : }
     188                 :            : 
     189                 :      63193 : EditTextObject::EditTextObject( sal_uInt16 n)
     190                 :            : {
     191                 :            :     DBG_CTOR( EE_EditTextObject, 0 );
     192                 :      63193 :     nWhich = n;
     193                 :      63193 : }
     194                 :            : 
     195                 :      69674 : EditTextObject::EditTextObject( const EditTextObject& r )
     196                 :            : {
     197                 :            :     DBG_CTOR( EE_EditTextObject, 0 );
     198                 :      69674 :     nWhich = r.nWhich;
     199                 :      69674 : }
     200                 :            : 
     201                 :     130035 : EditTextObject::~EditTextObject()
     202                 :            : {
     203                 :            :     DBG_DTOR( EE_EditTextObject, 0 );
     204         [ -  + ]:     130035 : }
     205                 :            : 
     206                 :          0 : size_t EditTextObject::GetParagraphCount() const
     207                 :            : {
     208                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     209                 :          0 :     return 0;
     210                 :            : }
     211                 :            : 
     212                 :          0 : String EditTextObject::GetText(size_t /* nParagraph */) const
     213                 :            : {
     214                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     215                 :          0 :     return String();
     216                 :            : }
     217                 :            : 
     218                 :          0 : void EditTextObject::Insert(const EditTextObject& /* rObj */, size_t /* nPara */)
     219                 :            : {
     220                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     221                 :          0 : }
     222                 :            : 
     223                 :          0 : EditTextObject* EditTextObject::CreateTextObject(size_t /*nPara*/, size_t /*nParas*/) const
     224                 :            : {
     225                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     226                 :          0 :     return 0;
     227                 :            : }
     228                 :            : 
     229                 :          0 : void EditTextObject::RemoveParagraph(size_t /*nPara*/)
     230                 :            : {
     231                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     232                 :          0 : }
     233                 :            : 
     234                 :          0 : sal_Bool EditTextObject::HasPortionInfo() const
     235                 :            : {
     236                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     237                 :          0 :     return false;
     238                 :            : }
     239                 :            : 
     240                 :          0 : void EditTextObject::ClearPortionInfo()
     241                 :            : {
     242                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     243                 :          0 : }
     244                 :            : 
     245                 :          0 : sal_Bool EditTextObject::HasOnlineSpellErrors() const
     246                 :            : {
     247                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     248                 :          0 :     return false;
     249                 :            : }
     250                 :            : 
     251                 :          0 : sal_Bool EditTextObject::HasCharAttribs( sal_uInt16 ) const
     252                 :            : {
     253                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     254                 :          0 :     return false;
     255                 :            : }
     256                 :            : 
     257                 :          0 : void EditTextObject::GetCharAttribs( sal_uInt16 /*nPara*/, std::vector<EECharAttrib>& /*rLst*/ ) const
     258                 :            : {
     259                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     260                 :          0 : }
     261                 :            : 
     262                 :          0 : void EditTextObject::MergeParaAttribs( const SfxItemSet& /*rAttribs*/, sal_uInt16 /*nStart*/, sal_uInt16 /*nEnd*/ )
     263                 :            : {
     264                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     265                 :          0 : }
     266                 :            : 
     267                 :          0 : sal_Bool EditTextObject::IsFieldObject() const
     268                 :            : {
     269                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     270                 :          0 :     return false;
     271                 :            : }
     272                 :            : 
     273                 :          0 : const SvxFieldItem* EditTextObject::GetField() const
     274                 :            : {
     275                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     276                 :          0 :     return 0;
     277                 :            : }
     278                 :            : 
     279                 :          0 : sal_Bool EditTextObject::HasField( TypeId /*aType*/ ) const
     280                 :            : {
     281                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     282                 :          0 :     return false;
     283                 :            : }
     284                 :            : 
     285                 :          0 : SfxItemSet EditTextObject::GetParaAttribs(size_t /*nPara*/) const
     286                 :            : {
     287                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     288                 :          0 :     return SfxItemSet( *(SfxItemPool*)NULL );
     289                 :            : }
     290                 :            : 
     291                 :          0 : void EditTextObject::SetParaAttribs(size_t /*nPara*/, const SfxItemSet& /*rAttribs*/)
     292                 :            : {
     293                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     294                 :          0 : }
     295                 :            : 
     296                 :          0 : sal_Bool EditTextObject::RemoveCharAttribs( sal_uInt16 /*nWhich*/ )
     297                 :            : {
     298                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     299                 :          0 :     return false;
     300                 :            : }
     301                 :            : 
     302                 :          0 : sal_Bool EditTextObject::RemoveParaAttribs( sal_uInt16 /*nWhich*/ )
     303                 :            : {
     304                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     305                 :          0 :     return false;
     306                 :            : }
     307                 :            : 
     308                 :          0 : sal_Bool EditTextObject::HasStyleSheet( const XubString& /*rName*/, SfxStyleFamily /*eFamily*/ ) const
     309                 :            : {
     310                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     311                 :          0 :     return false;
     312                 :            : }
     313                 :            : 
     314                 :          0 : void EditTextObject::GetStyleSheet(size_t /*nPara*/, String& /*rName*/, SfxStyleFamily& /*eFamily*/) const
     315                 :            : {
     316                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     317                 :          0 : }
     318                 :            : 
     319                 :          0 : void EditTextObject::SetStyleSheet(size_t /*nPara*/, const String& /*rName*/, const SfxStyleFamily& /*eFamily*/)
     320                 :            : {
     321                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     322                 :          0 : }
     323                 :            : 
     324                 :          0 : sal_Bool EditTextObject::ChangeStyleSheets( const XubString&, SfxStyleFamily,
     325                 :            :                                             const XubString&, SfxStyleFamily )
     326                 :            : {
     327                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     328                 :          0 :     return false;
     329                 :            : }
     330                 :            : 
     331                 :          0 : void EditTextObject::ChangeStyleSheetName( SfxStyleFamily /*eFamily*/,
     332                 :            :                 const XubString& /*rOldName*/, const XubString& /*rNewName*/ )
     333                 :            : {
     334                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     335                 :          0 : }
     336                 :            : 
     337                 :          0 : sal_uInt16 EditTextObject::GetUserType() const
     338                 :            : {
     339                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     340                 :          0 :     return 0;
     341                 :            : }
     342                 :            : 
     343                 :          0 : void EditTextObject::SetUserType( sal_uInt16 )
     344                 :            : {
     345                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     346                 :          0 : }
     347                 :            : 
     348                 :          0 : sal_uLong EditTextObject::GetObjectSettings() const
     349                 :            : {
     350                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     351                 :          0 :     return 0;
     352                 :            : }
     353                 :            : 
     354                 :          0 : void EditTextObject::SetObjectSettings( sal_uLong )
     355                 :            : {
     356                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     357                 :          0 : }
     358                 :            : 
     359                 :          0 : bool EditTextObject::IsVertical() const
     360                 :            : {
     361                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     362                 :          0 :     return false;
     363                 :            : }
     364                 :            : 
     365                 :          0 : void EditTextObject::SetVertical( bool bVertical )
     366                 :            : {
     367                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     368                 :          0 :     ((BinTextObject*)this)->SetVertical( bVertical );
     369                 :          0 : }
     370                 :            : 
     371                 :          0 : sal_uInt16 EditTextObject::GetScriptType() const
     372                 :            : {
     373                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     374                 :          0 :     return ((const BinTextObject*)this)->GetScriptType();
     375                 :            : }
     376                 :            : 
     377                 :            : 
     378                 :       3606 : sal_Bool EditTextObject::Store( SvStream& rOStream ) const
     379                 :            : {
     380         [ -  + ]:       3606 :     if ( rOStream.GetError() )
     381                 :          0 :         return false;
     382                 :            : 
     383                 :       3606 :     sal_Size nStartPos = rOStream.Tell();
     384                 :            : 
     385                 :       3606 :     rOStream << (sal_uInt16)Which();
     386                 :            : 
     387                 :       3606 :     sal_uInt32 nStructSz = 0;
     388                 :       3606 :     rOStream << nStructSz;
     389                 :            : 
     390                 :       3606 :     StoreData( rOStream );
     391                 :            : 
     392                 :       3606 :     sal_Size nEndPos = rOStream.Tell();
     393                 :       3606 :     nStructSz = nEndPos - nStartPos - sizeof( nWhich ) - sizeof( nStructSz );
     394                 :       3606 :     rOStream.Seek( nStartPos + sizeof( nWhich ) );
     395                 :       3606 :     rOStream << nStructSz;
     396                 :       3606 :     rOStream.Seek( nEndPos );
     397                 :            : 
     398                 :       3606 :     return rOStream.GetError() ? false : true;
     399                 :            : }
     400                 :            : 
     401                 :          0 : EditTextObject* EditTextObject::Create( SvStream& rIStream, SfxItemPool* pGlobalTextObjectPool )
     402                 :            : {
     403                 :          0 :     sal_uLong nStartPos = rIStream.Tell();
     404                 :            : 
     405                 :            :     // First check what type of Object...
     406                 :            :     sal_uInt16 nWhich;
     407         [ #  # ]:          0 :     rIStream >> nWhich;
     408                 :            : 
     409                 :            :     sal_uInt32 nStructSz;
     410         [ #  # ]:          0 :     rIStream >> nStructSz;
     411                 :            : 
     412                 :            :     DBG_ASSERT( ( nWhich == 0x22 /*EE_FORMAT_BIN300*/ ) || ( nWhich == EE_FORMAT_BIN ), "CreateTextObject: Unknown Object!" );
     413                 :            : 
     414         [ #  # ]:          0 :     if ( rIStream.GetError() )
     415                 :          0 :         return NULL;
     416                 :            : 
     417                 :          0 :     EditTextObject* pTxtObj = NULL;
     418      [ #  #  # ]:          0 :     switch ( nWhich )
     419                 :            :     {
     420 [ #  # ][ #  # ]:          0 :         case 0x22 /*BIN300*/:       pTxtObj = new BinTextObject( 0 );
     421         [ #  # ]:          0 :                                     ((BinTextObject*)pTxtObj)->CreateData300( rIStream );
     422                 :          0 :                                     break;
     423 [ #  # ][ #  # ]:          0 :         case EE_FORMAT_BIN:         pTxtObj = new BinTextObject( pGlobalTextObjectPool );
     424         [ #  # ]:          0 :                                     pTxtObj->CreateData( rIStream );
     425                 :          0 :                                     break;
     426                 :            :         default:
     427                 :            :         {
     428                 :            :             // If I do not know the format, I overwrite the contents:
     429         [ #  # ]:          0 :             rIStream.SetError( EE_READWRITE_WRONGFORMAT );
     430                 :            :         }
     431                 :            :     }
     432                 :            : 
     433                 :            :     // Make sure that the stream is left at the correct place.
     434                 :          0 :     sal_Size nFullSz = sizeof( nWhich ) + sizeof( nStructSz ) + nStructSz;
     435         [ #  # ]:          0 :     rIStream.Seek( nStartPos + nFullSz );
     436                 :          0 :     return pTxtObj;
     437                 :            : }
     438                 :            : 
     439                 :          0 : void EditTextObject::StoreData( SvStream& ) const
     440                 :            : {
     441                 :            :     OSL_FAIL( "StoreData: Base class!" );
     442                 :          0 : }
     443                 :            : 
     444                 :          0 : void EditTextObject::CreateData( SvStream& )
     445                 :            : {
     446                 :            :     OSL_FAIL( "CreateData: Base class!" );
     447                 :          0 : }
     448                 :            : 
     449                 :          0 : sal_uInt16 EditTextObject::GetVersion() const
     450                 :            : {
     451                 :            :     OSL_FAIL( "Virtual method direct from EditTextObject!" );
     452                 :          0 :     return 0;
     453                 :            : }
     454                 :            : 
     455                 :       1544 : bool EditTextObject::operator==( const EditTextObject& rCompare ) const
     456                 :            : {
     457                 :       1544 :     return static_cast< const BinTextObject* >( this )->operator==( static_cast< const BinTextObject& >( rCompare ) );
     458                 :            : }
     459                 :            : 
     460                 :            : // #i102062#
     461                 :        201 : bool EditTextObject::isWrongListEqual(const EditTextObject& rCompare) const
     462                 :            : {
     463                 :        201 :     return static_cast< const BinTextObject* >(this)->isWrongListEqual(static_cast< const BinTextObject& >(rCompare));
     464                 :            : }
     465                 :            : 
     466                 :            : // from SfxItemPoolUser
     467                 :          1 : void BinTextObject::ObjectInDestruction(const SfxItemPool& rSfxItemPool)
     468                 :            : {
     469 [ +  - ][ +  - ]:          1 :     if(!bOwnerOfPool && pPool && pPool == &rSfxItemPool)
                 [ +  - ]
     470                 :            :     {
     471                 :            :         // The pool we are based on gets destructed; get owner of pool by creating own one.
     472                 :            :         // No need to call RemoveSfxItemPoolUser(), this is done from the pool's destructor
     473                 :            :         // Base new pool on EditEnginePool; it would also be possible to clone the used
     474                 :            :         // pool if needed, but only text attributes should be used.
     475         [ +  - ]:          1 :         SfxItemPool* pNewPool = EditEngine::CreatePool();
     476                 :            : 
     477         [ +  - ]:          1 :         if(pPool)
     478                 :            :         {
     479 [ +  - ][ +  - ]:          1 :             pNewPool->SetDefaultMetric(pPool->GetMetric(DEF_METRIC));
     480                 :            :         }
     481                 :            : 
     482         [ +  - ]:          1 :         ContentInfosType aReplaced;
     483         [ +  - ]:          1 :         aReplaced.reserve(aContents.size());
     484 [ +  - ][ +  - ]:          1 :         ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
         [ +  - ][ +  - ]
     485 [ +  - ][ +  - ]:          2 :         for (; it != itEnd; ++it)
                 [ +  + ]
     486 [ +  - ][ +  - ]:          1 :             aReplaced.push_back(new ContentInfo(*it, *pNewPool));
         [ +  - ][ +  - ]
     487                 :          1 :         aReplaced.swap(aContents);
     488                 :            : 
     489                 :            :         // set local variables
     490                 :          1 :         pPool = pNewPool;
     491         [ +  - ]:          1 :         bOwnerOfPool = true;
     492                 :            :     }
     493                 :          1 : }
     494                 :            : 
     495                 :      63193 : EditEngineItemPool* getEditEngineItemPool(SfxItemPool* pPool)
     496                 :            : {
     497         [ +  + ]:      63193 :     EditEngineItemPool* pRetval = dynamic_cast< EditEngineItemPool* >(pPool);
     498                 :            : 
     499 [ +  + ][ +  + ]:     117347 :     while(!pRetval && pPool && pPool->GetSecondaryPool())
         [ +  - ][ +  + ]
     500                 :            :     {
     501                 :      54154 :         pPool = pPool->GetSecondaryPool();
     502                 :            : 
     503         [ +  - ]:      54154 :         if(pPool)
     504                 :            :         {
     505         [ -  + ]:      54154 :             pRetval = dynamic_cast< EditEngineItemPool* >(pPool);
     506                 :            :         }
     507                 :            :     }
     508                 :            : 
     509                 :      63193 :     return pRetval;
     510                 :            : }
     511                 :            : 
     512                 :      63193 : BinTextObject::BinTextObject( SfxItemPool* pP ) :
     513                 :            :     EditTextObject( EE_FORMAT_BIN ),
     514         [ +  - ]:      63193 :     SfxItemPoolUser()
     515                 :            : {
     516                 :      63193 :     nVersion = 0;
     517                 :      63193 :     nMetric = 0xFFFF;
     518                 :      63193 :     nUserType = 0;
     519                 :      63193 :     nObjSettings = 0;
     520                 :      63193 :     pPortionInfo = 0;
     521                 :            : 
     522                 :            :     // #i101239# ensure target is a EditEngineItemPool, else
     523                 :            :     // fallback to pool ownership. This is needed to ensure that at
     524                 :            :     // pool destruction time of an alien pool, the pool is still alive.
     525                 :            :     // When registering would happen at an alien pool which just uses an
     526                 :            :     // EditEngineItemPool as some sub-pool, that pool could already
     527                 :            :     // be decoupled and deleted whcih would lead to crashes.
     528         [ +  - ]:      63193 :     pPool = getEditEngineItemPool(pP);
     529                 :            : 
     530         [ +  + ]:      63193 :     if ( pPool )
     531                 :            :     {
     532                 :      54602 :         bOwnerOfPool = false;
     533                 :            :     }
     534                 :            :     else
     535                 :            :     {
     536         [ +  - ]:       8591 :         pPool = EditEngine::CreatePool();
     537                 :       8591 :         bOwnerOfPool =  true;
     538                 :            :     }
     539                 :            : 
     540 [ +  + ][ +  - ]:      63193 :     if(!bOwnerOfPool && pPool)
     541                 :            :     {
     542                 :            :         // it is sure now that the pool is an EditEngineItemPool
     543         [ +  - ]:      54602 :         pPool->AddSfxItemPoolUser(*this);
     544                 :            :     }
     545                 :            : 
     546                 :      63193 :     bVertical = false;
     547                 :      63193 :     bStoreUnicodeStrings = false;
     548                 :      63193 :     nScriptType = 0;
     549                 :      63193 : }
     550                 :            : 
     551                 :      69674 : BinTextObject::BinTextObject( const BinTextObject& r ) :
     552                 :            :     EditTextObject( r ),
     553         [ +  - ]:      69674 :     SfxItemPoolUser()
     554                 :            : {
     555                 :      69674 :     nVersion = r.nVersion;
     556                 :      69674 :     nMetric = r.nMetric;
     557                 :      69674 :     nUserType = r.nUserType;
     558                 :      69674 :     nObjSettings = r.nObjSettings;
     559                 :      69674 :     bVertical = r.bVertical;
     560                 :      69674 :     nScriptType = r.nScriptType;
     561                 :      69674 :     pPortionInfo = NULL;    // Do not copy PortionInfo
     562                 :      69674 :     bStoreUnicodeStrings = false;
     563                 :            : 
     564         [ +  + ]:      69674 :     if ( !r.bOwnerOfPool )
     565                 :            :     {
     566                 :            :         // reuse alien pool; this must be a EditEngineItemPool
     567                 :            :         // since there is no other way to construct a BinTextObject
     568                 :            :         // than it's regular constructor where that is ensured
     569                 :      54905 :         pPool = r.pPool;
     570                 :      54905 :         bOwnerOfPool = false;
     571                 :            :     }
     572                 :            :     else
     573                 :            :     {
     574         [ +  - ]:      14769 :         pPool = EditEngine::CreatePool();
     575                 :      14769 :         bOwnerOfPool =  true;
     576                 :            : 
     577                 :            :     }
     578                 :            : 
     579 [ +  + ][ +  - ]:      69674 :     if(!bOwnerOfPool && pPool)
     580                 :            :     {
     581                 :            :         // it is sure now that the pool is an EditEngineItemPool
     582         [ +  - ]:      54905 :         pPool->AddSfxItemPoolUser(*this);
     583                 :            :     }
     584                 :            : 
     585 [ +  + ][ +  - ]:      69674 :     if ( bOwnerOfPool && pPool && r.pPool )
                 [ +  - ]
     586 [ +  - ][ +  - ]:      14769 :         pPool->SetDefaultMetric( r.pPool->GetMetric( DEF_METRIC ) );
     587                 :            : 
     588         [ +  - ]:      69674 :     aContents.reserve(r.aContents.size());
     589 [ +  - ][ +  - ]:      69674 :     ContentInfosType::const_iterator it = r.aContents.begin(), itEnd = r.aContents.end();
     590 [ +  - ][ +  - ]:     144248 :     for (; it != itEnd; ++it)
                 [ +  + ]
     591 [ +  - ][ +  - ]:      74574 :         aContents.push_back(new ContentInfo(*it, *pPool));
         [ +  - ][ +  - ]
     592                 :      69674 : }
     593                 :            : 
     594         [ +  - ]:     130035 : BinTextObject::~BinTextObject()
     595                 :            : {
     596 [ +  + ][ +  - ]:     130035 :     if(!bOwnerOfPool && pPool)
     597                 :            :     {
     598         [ +  - ]:     109455 :         pPool->RemoveSfxItemPoolUser(*this);
     599                 :            :     }
     600                 :            : 
     601         [ +  - ]:     130035 :     ClearPortionInfo();
     602                 :            : 
     603                 :            :     // Remove contents before deleting the pool instance since each content
     604                 :            :     // has to access the pool instance in its destructor.
     605         [ +  - ]:     130035 :     aContents.clear();
     606         [ +  + ]:     130035 :     if ( bOwnerOfPool )
     607                 :            :     {
     608         [ +  - ]:      20580 :         SfxItemPool::Free(pPool);
     609                 :            :     }
     610         [ -  + ]:     260070 : }
     611                 :            : 
     612                 :     180718 : sal_uInt16 BinTextObject::GetUserType() const
     613                 :            : {
     614                 :     180718 :     return nUserType;
     615                 :            : }
     616                 :            : 
     617                 :      54097 : void BinTextObject::SetUserType( sal_uInt16 n )
     618                 :            : {
     619                 :      54097 :     nUserType = n;
     620                 :      54097 : }
     621                 :            : 
     622                 :          0 : sal_uLong BinTextObject::GetObjectSettings() const
     623                 :            : {
     624                 :          0 :     return nObjSettings;
     625                 :            : }
     626                 :            : 
     627                 :          0 : void BinTextObject::SetObjectSettings( sal_uLong n )
     628                 :            : {
     629                 :          0 :     nObjSettings = n;
     630                 :          0 : }
     631                 :            : 
     632                 :     276409 : bool BinTextObject::IsVertical() const
     633                 :            : {
     634                 :     276409 :     return bVertical;
     635                 :            : }
     636                 :            : 
     637                 :      63412 : void BinTextObject::SetVertical( bool b )
     638                 :            : {
     639         [ -  + ]:      63412 :     if ( b != bVertical )
     640                 :            :     {
     641                 :          0 :         bVertical = b;
     642                 :          0 :         ClearPortionInfo();
     643                 :            :     }
     644                 :      63412 : }
     645                 :            : 
     646                 :          0 : sal_uInt16 BinTextObject::GetScriptType() const
     647                 :            : {
     648                 :          0 :     return nScriptType;
     649                 :            : }
     650                 :            : 
     651                 :      63193 : void BinTextObject::SetScriptType( sal_uInt16 nType )
     652                 :            : {
     653                 :      63193 :     nScriptType = nType;
     654                 :      63193 : }
     655                 :            : 
     656                 :      69674 : EditTextObject* BinTextObject::Clone() const
     657                 :            : {
     658         [ +  - ]:      69674 :     return new BinTextObject( *this );
     659                 :            : }
     660                 :            : 
     661                 :      62374 : XEditAttribute* BinTextObject::CreateAttrib( const SfxPoolItem& rItem, sal_uInt16 nStart, sal_uInt16 nEnd )
     662                 :            : {
     663                 :      62374 :     return MakeXEditAttribute( *pPool, rItem, nStart, nEnd );
     664                 :            : }
     665                 :            : 
     666                 :          0 : void BinTextObject::DestroyAttrib( XEditAttribute* pAttr )
     667                 :            : {
     668                 :          0 :     pPool->Remove( *pAttr->GetItem() );
     669         [ #  # ]:          0 :     delete pAttr;
     670                 :          0 : }
     671                 :            : 
     672                 :     274739 : BinTextObject::ContentInfosType& BinTextObject::GetContents()
     673                 :            : {
     674                 :     274739 :     return aContents;
     675                 :            : }
     676                 :            : 
     677                 :          0 : const BinTextObject::ContentInfosType& BinTextObject::GetContents() const
     678                 :            : {
     679                 :          0 :     return aContents;
     680                 :            : }
     681                 :            : 
     682                 :      69230 : ContentInfo* BinTextObject::CreateAndInsertContent()
     683                 :            : {
     684         [ +  - ]:      69230 :     aContents.push_back(new ContentInfo(*pPool));
     685                 :      69230 :     return &aContents.back();
     686                 :            : }
     687                 :            : 
     688                 :      23341 : size_t BinTextObject::GetParagraphCount() const
     689                 :            : {
     690                 :      23341 :     return aContents.size();
     691                 :            : }
     692                 :            : 
     693                 :      17659 : String BinTextObject::GetText(size_t nPara) const
     694                 :            : {
     695         [ -  + ]:      17659 :     if (nPara >= aContents.size())
     696                 :          0 :         return String();
     697                 :            : 
     698                 :      17659 :     return aContents[nPara].GetText();
     699                 :            : }
     700                 :            : 
     701                 :          0 : void BinTextObject::Insert(const EditTextObject& rObj, size_t nDestPara)
     702                 :            : {
     703                 :            :     DBG_ASSERT( rObj.Which() == EE_FORMAT_BIN, "UTO: unknown Textobjekt" );
     704                 :            : 
     705                 :          0 :     const BinTextObject& rBinObj = (const BinTextObject&)rObj;
     706                 :            : 
     707         [ #  # ]:          0 :     if (nDestPara > aContents.size())
     708                 :          0 :         nDestPara = aContents.size();
     709                 :            : 
     710                 :          0 :     const ContentInfosType& rCIs = rBinObj.aContents;
     711         [ #  # ]:          0 :     for (size_t i = 0, n = rCIs.size(); i < n; ++i)
     712                 :            :     {
     713                 :          0 :         const ContentInfo& rC = rCIs[i];
     714                 :          0 :         size_t nPos = nDestPara + i;
     715                 :            :         aContents.insert(
     716         [ #  # ]:          0 :             aContents.begin()+nPos, new ContentInfo(rC, *GetPool()));
     717                 :            :     }
     718                 :            : 
     719                 :          0 :     ClearPortionInfo();
     720                 :          0 : }
     721                 :            : 
     722                 :          0 : EditTextObject* BinTextObject::CreateTextObject(size_t nPara, size_t nParas) const
     723                 :            : {
     724 [ #  # ][ #  # ]:          0 :     if (nPara >= aContents.size() || !nParas)
                 [ #  # ]
     725                 :          0 :         return NULL;
     726                 :            : 
     727                 :            :     // Only split the Pool, when a the Pool is set externally.
     728 [ #  # ][ #  # ]:          0 :     BinTextObject* pObj = new BinTextObject( bOwnerOfPool ? 0 : pPool );
     729 [ #  # ][ #  # ]:          0 :     if ( bOwnerOfPool && pPool )
     730                 :          0 :         pObj->GetPool()->SetDefaultMetric( pPool->GetMetric( DEF_METRIC ) );
     731                 :            : 
     732                 :            :     // If complete text is only one ScriptType, this is valid.
     733                 :            :     // If text contains different ScriptTypes, this shouldn't be a problem...
     734                 :          0 :     pObj->nScriptType = nScriptType;
     735                 :            : 
     736                 :          0 :     const size_t nEndPara = nPara+nParas-1;
     737         [ #  # ]:          0 :     for (size_t i = nPara; i <= nEndPara; ++i)
     738                 :            :     {
     739                 :          0 :         const ContentInfo& rC = aContents[i];
     740         [ #  # ]:          0 :         ContentInfo* pNew = new ContentInfo(rC, *pObj->GetPool());
     741                 :          0 :         pObj->aContents.push_back(pNew);
     742                 :            :     }
     743                 :          0 :     return pObj;
     744                 :            : }
     745                 :            : 
     746                 :          0 : void BinTextObject::RemoveParagraph(size_t nPara)
     747                 :            : {
     748                 :            :     DBG_ASSERT( nPara < aContents.size(), "BinTextObject::GetText: Paragraph does not exist!" );
     749         [ #  # ]:          0 :     if (nPara >= aContents.size())
     750                 :          0 :         return;
     751                 :            : 
     752         [ #  # ]:          0 :     ContentInfosType::iterator it = aContents.begin();
     753         [ #  # ]:          0 :     std::advance(it, nPara);
     754         [ #  # ]:          0 :     aContents.erase(it);
     755         [ #  # ]:          0 :     ClearPortionInfo();
     756                 :            : }
     757                 :            : 
     758                 :          0 : sal_Bool BinTextObject::HasPortionInfo() const
     759                 :            : {
     760                 :          0 :     return pPortionInfo ? true : false;
     761                 :            : }
     762                 :            : 
     763                 :     130120 : void BinTextObject::ClearPortionInfo()
     764                 :            : {
     765         [ -  + ]:     130120 :     if ( pPortionInfo )
     766                 :            :     {
     767         [ #  # ]:          0 :         delete pPortionInfo;
     768                 :          0 :         pPortionInfo = NULL;
     769                 :            :     }
     770                 :     130120 : }
     771                 :            : 
     772                 :          0 : sal_Bool BinTextObject::HasOnlineSpellErrors() const
     773                 :            : {
     774 [ #  # ][ #  # ]:          0 :     ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
     775 [ #  # ][ #  # ]:          0 :     for (; it != itEnd; ++it)
                 [ #  # ]
     776                 :            :     {
     777 [ #  # ][ #  # ]:          0 :         if ( it->GetWrongList() && !it->GetWrongList()->empty() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     778                 :          0 :             return true;
     779                 :            :     }
     780                 :          0 :     return false;
     781                 :            : }
     782                 :            : 
     783                 :          0 : sal_Bool BinTextObject::HasCharAttribs( sal_uInt16 _nWhich ) const
     784                 :            : {
     785         [ #  # ]:          0 :     for (size_t nPara = aContents.size(); nPara; )
     786                 :            :     {
     787                 :          0 :         const ContentInfo& rC = aContents[--nPara];
     788                 :            : 
     789                 :          0 :         size_t nAttribs = rC.aAttribs.size();
     790 [ #  # ][ #  # ]:          0 :         if ( nAttribs && !_nWhich )
     791                 :          0 :             return true;
     792                 :            : 
     793         [ #  # ]:          0 :         for (size_t nAttr = nAttribs; nAttr; )
     794                 :            :         {
     795                 :          0 :             const XEditAttribute& rX = rC.aAttribs[--nAttr];
     796         [ #  # ]:          0 :             if (rX.GetItem()->Which() == _nWhich)
     797                 :          0 :                 return true;
     798                 :            :         }
     799                 :            :     }
     800                 :          0 :     return false;
     801                 :            : }
     802                 :            : 
     803                 :          6 : void BinTextObject::GetCharAttribs( sal_uInt16 nPara, std::vector<EECharAttrib>& rLst ) const
     804                 :            : {
     805                 :          6 :     rLst.clear();
     806                 :          6 :     const ContentInfo& rC = aContents[nPara];
     807         [ +  + ]:         63 :     for (size_t nAttr = 0; nAttr < rC.aAttribs.size(); ++nAttr)
     808                 :            :     {
     809         [ +  - ]:         57 :         const XEditAttribute& rAttr = rC.aAttribs[nAttr];
     810                 :            :         EECharAttrib aEEAttr;
     811                 :         57 :         aEEAttr.pAttr = rAttr.GetItem();
     812                 :         57 :         aEEAttr.nPara = nPara;
     813                 :         57 :         aEEAttr.nStart = rAttr.GetStart();
     814                 :         57 :         aEEAttr.nEnd = rAttr.GetEnd();
     815         [ +  - ]:         57 :         rLst.push_back(aEEAttr);
     816                 :            :     }
     817                 :          6 : }
     818                 :            : 
     819                 :          0 : void BinTextObject::MergeParaAttribs( const SfxItemSet& rAttribs, sal_uInt16 nStart, sal_uInt16 nEnd )
     820                 :            : {
     821                 :          0 :     bool bChanged = false;
     822                 :            : 
     823         [ #  # ]:          0 :     for (size_t nPara = aContents.size(); nPara; )
     824                 :            :     {
     825                 :          0 :         ContentInfo& rC = aContents[--nPara];
     826                 :            : 
     827         [ #  # ]:          0 :         for ( sal_uInt16 nW = nStart; nW <= nEnd; nW++ )
     828                 :            :         {
     829   [ #  #  #  # ]:          0 :             if ( ( rC.GetParaAttribs().GetItemState( nW, false ) != SFX_ITEM_ON )
                 [ #  # ]
     830                 :          0 :                     && ( rAttribs.GetItemState( nW, false ) == SFX_ITEM_ON ) )
     831                 :            :             {
     832                 :          0 :                 rC.GetParaAttribs().Put( rAttribs.Get( nW ) );
     833                 :          0 :                 bChanged = true;
     834                 :            :             }
     835                 :            :         }
     836                 :            :     }
     837                 :            : 
     838         [ #  # ]:          0 :     if ( bChanged )
     839                 :          0 :         ClearPortionInfo();
     840                 :          0 : }
     841                 :            : 
     842                 :          0 : sal_Bool BinTextObject::IsFieldObject() const
     843                 :            : {
     844                 :          0 :     return BinTextObject::GetField() ? true : false;
     845                 :            : }
     846                 :            : 
     847                 :          0 : const SvxFieldItem* BinTextObject::GetField() const
     848                 :            : {
     849         [ #  # ]:          0 :     if (aContents.size() == 1)
     850                 :            :     {
     851                 :          0 :         const ContentInfo& rC = aContents[0];
     852         [ #  # ]:          0 :         if (rC.GetText().Len() == 1)
     853                 :            :         {
     854                 :          0 :             size_t nAttribs = rC.aAttribs.size();
     855         [ #  # ]:          0 :             for (size_t nAttr = nAttribs; nAttr; )
     856                 :            :             {
     857                 :          0 :                 const XEditAttribute& rX = rC.aAttribs[--nAttr];
     858         [ #  # ]:          0 :                 if (rX.GetItem()->Which() == EE_FEATURE_FIELD)
     859                 :          0 :                     return static_cast<const SvxFieldItem*>(rX.GetItem());
     860                 :            :             }
     861                 :            :         }
     862                 :            :     }
     863                 :          0 :     return 0;
     864                 :            : }
     865                 :            : 
     866                 :     289058 : sal_Bool BinTextObject::HasField( TypeId aType ) const
     867                 :            : {
     868                 :     289058 :     size_t nParagraphs = aContents.size();
     869         [ +  + ]:     604036 :     for (size_t nPara = 0; nPara < nParagraphs; ++nPara)
     870                 :            :     {
     871                 :     317562 :         const ContentInfo& rC = aContents[nPara];
     872                 :     317562 :         size_t nAttrs = rC.aAttribs.size();
     873         [ +  + ]:     545179 :         for (size_t nAttr = 0; nAttr < nAttrs; ++nAttr)
     874                 :            :         {
     875                 :     230201 :             const XEditAttribute& rAttr = rC.aAttribs[nAttr];
     876         [ +  + ]:     230201 :             if (rAttr.GetItem()->Which() == EE_FEATURE_FIELD)
     877                 :            :             {
     878         [ -  + ]:       8173 :                 if ( !aType )
     879                 :          0 :                     return true;
     880                 :            : 
     881                 :       8173 :                 const SvxFieldData* pFldData = static_cast<const SvxFieldItem*>(rAttr.GetItem())->GetField();
     882 [ +  + ][ +  + ]:       8173 :                 if ( pFldData && pFldData->IsA( aType ) )
                 [ +  - ]
     883                 :       2584 :                     return true;
     884                 :            :             }
     885                 :            :         }
     886                 :            :     }
     887                 :     289058 :     return false;
     888                 :            : }
     889                 :            : 
     890                 :          9 : SfxItemSet BinTextObject::GetParaAttribs(size_t nPara) const
     891                 :            : {
     892                 :          9 :     const ContentInfo& rC = aContents[nPara];
     893                 :          9 :     return rC.GetParaAttribs();
     894                 :            : }
     895                 :            : 
     896                 :          0 : void BinTextObject::SetParaAttribs(size_t nPara, const SfxItemSet& rAttribs)
     897                 :            : {
     898                 :          0 :     ContentInfo& rC = aContents[nPara];
     899                 :          0 :     rC.GetParaAttribs().Set(rAttribs);
     900                 :          0 :     ClearPortionInfo();
     901                 :          0 : }
     902                 :            : 
     903                 :          0 : sal_Bool BinTextObject::RemoveCharAttribs( sal_uInt16 _nWhich )
     904                 :            : {
     905                 :          0 :     sal_Bool bChanged = false;
     906                 :            : 
     907         [ #  # ]:          0 :     for ( sal_uInt16 nPara = aContents.size(); nPara; )
     908                 :            :     {
     909                 :          0 :         ContentInfo& rC = aContents[--nPara];
     910                 :            : 
     911         [ #  # ]:          0 :         for (size_t nAttr = rC.aAttribs.size(); nAttr; )
     912                 :            :         {
     913                 :          0 :             XEditAttribute& rAttr = rC.aAttribs[--nAttr];
     914 [ #  # ][ #  # ]:          0 :             if ( !_nWhich || (rAttr.GetItem()->Which() == _nWhich) )
                 [ #  # ]
     915                 :            :             {
     916                 :          0 :                 pPool->Remove(*rAttr.GetItem());
     917                 :          0 :                 rC.aAttribs.erase(rC.aAttribs.begin()+nAttr);
     918                 :          0 :                 bChanged = true;
     919                 :            :             }
     920                 :            :         }
     921                 :            :     }
     922                 :            : 
     923         [ #  # ]:          0 :     if ( bChanged )
     924                 :          0 :         ClearPortionInfo();
     925                 :            : 
     926                 :          0 :     return bChanged;
     927                 :            : }
     928                 :            : 
     929                 :          0 : sal_Bool BinTextObject::RemoveParaAttribs( sal_uInt16 _nWhich )
     930                 :            : {
     931                 :          0 :     bool bChanged = false;
     932                 :            : 
     933         [ #  # ]:          0 :     for (size_t nPara = aContents.size(); nPara; )
     934                 :            :     {
     935                 :          0 :         ContentInfo& rC = aContents[--nPara];
     936                 :            : 
     937         [ #  # ]:          0 :         if ( !_nWhich )
     938                 :            :         {
     939         [ #  # ]:          0 :             if (rC.GetParaAttribs().Count())
     940                 :          0 :                 bChanged = true;
     941                 :          0 :             rC.GetParaAttribs().ClearItem();
     942                 :            :         }
     943                 :            :         else
     944                 :            :         {
     945         [ #  # ]:          0 :             if (rC.GetParaAttribs().GetItemState(_nWhich) == SFX_ITEM_ON)
     946                 :            :             {
     947                 :          0 :                 rC.GetParaAttribs().ClearItem(_nWhich);
     948                 :          0 :                 bChanged = true;
     949                 :            :             }
     950                 :            :         }
     951                 :            :     }
     952                 :            : 
     953         [ #  # ]:          0 :     if ( bChanged )
     954                 :          0 :         ClearPortionInfo();
     955                 :            : 
     956                 :          0 :     return bChanged;
     957                 :            : }
     958                 :            : 
     959                 :          0 : sal_Bool BinTextObject::HasStyleSheet( const XubString& rName, SfxStyleFamily eFamily ) const
     960                 :            : {
     961                 :          0 :     size_t nParagraphs = aContents.size();
     962         [ #  # ]:          0 :     for (size_t nPara = 0; nPara < nParagraphs; ++nPara)
     963                 :            :     {
     964                 :          0 :         const ContentInfo& rC = aContents[nPara];
     965 [ #  # ][ #  # ]:          0 :         if (rC.GetFamily() == eFamily && rC.GetStyle() == rName)
                 [ #  # ]
     966                 :          0 :             return true;
     967                 :            :     }
     968                 :          0 :     return false;
     969                 :            : }
     970                 :            : 
     971                 :       8387 : void BinTextObject::GetStyleSheet(size_t nPara, String& rName, SfxStyleFamily& rFamily) const
     972                 :            : {
     973         [ -  + ]:       8387 :     if (nPara >= aContents.size())
     974                 :       8387 :         return;
     975                 :            : 
     976                 :       8387 :     const ContentInfo& rC = aContents[nPara];
     977                 :       8387 :     rName = rC.GetStyle();
     978                 :       8387 :     rFamily = rC.GetFamily();
     979                 :            : }
     980                 :            : 
     981                 :          0 : void BinTextObject::SetStyleSheet(size_t nPara, const String& rName, const SfxStyleFamily& rFamily)
     982                 :            : {
     983         [ #  # ]:          0 :     if (nPara >= aContents.size())
     984                 :          0 :         return;
     985                 :            : 
     986                 :          0 :     ContentInfo& rC = aContents[nPara];
     987                 :          0 :     rC.GetStyle() = rName;
     988                 :          0 :     rC.GetFamily() = rFamily;
     989                 :            : }
     990                 :            : 
     991                 :       1694 : sal_Bool BinTextObject::ImpChangeStyleSheets(
     992                 :            :                     const XubString& rOldName, SfxStyleFamily eOldFamily,
     993                 :            :                     const XubString& rNewName, SfxStyleFamily eNewFamily )
     994                 :            : {
     995                 :       1694 :     const size_t nParagraphs = aContents.size();
     996                 :       1694 :     bool bChanges = false;
     997                 :            : 
     998         [ +  + ]:       3388 :     for (size_t nPara = 0; nPara < nParagraphs; ++nPara)
     999                 :            :     {
    1000                 :       1694 :         ContentInfo& rC = aContents[nPara];
    1001         [ +  + ]:       1694 :         if ( rC.GetFamily() == eOldFamily )
    1002                 :            :         {
    1003         [ +  + ]:       1190 :             if ( rC.GetStyle() == rOldName )
    1004                 :            :             {
    1005                 :         85 :                 rC.GetStyle() = rNewName;
    1006                 :         85 :                 rC.GetFamily() = eNewFamily;
    1007                 :         85 :                 bChanges = true;
    1008                 :            :             }
    1009                 :            :         }
    1010                 :            :     }
    1011                 :       1694 :     return bChanges;
    1012                 :            : }
    1013                 :            : 
    1014                 :       1694 : sal_Bool BinTextObject::ChangeStyleSheets(
    1015                 :            :                     const XubString& rOldName, SfxStyleFamily eOldFamily,
    1016                 :            :                     const XubString& rNewName, SfxStyleFamily eNewFamily )
    1017                 :            : {
    1018                 :       1694 :     sal_Bool bChanges = ImpChangeStyleSheets( rOldName, eOldFamily, rNewName, eNewFamily );
    1019         [ +  + ]:       1694 :     if ( bChanges )
    1020                 :         85 :         ClearPortionInfo();
    1021                 :            : 
    1022                 :       1694 :     return bChanges;
    1023                 :            : }
    1024                 :            : 
    1025                 :          0 : void BinTextObject::ChangeStyleSheetName( SfxStyleFamily eFamily,
    1026                 :            :                 const XubString& rOldName, const XubString& rNewName )
    1027                 :            : {
    1028                 :          0 :     ImpChangeStyleSheets( rOldName, eFamily, rNewName, eFamily );
    1029                 :          0 : }
    1030                 :            : 
    1031                 :        389 : editeng::FieldUpdater BinTextObject::GetFieldUpdater()
    1032                 :            : {
    1033                 :        389 :     return editeng::FieldUpdater(*this);
    1034                 :            : }
    1035                 :            : 
    1036                 :            : namespace {
    1037                 :            : 
    1038                 :            : class FindAttribByChar : public std::unary_function<XEditAttribute, bool>
    1039                 :            : {
    1040                 :            :     sal_uInt16 mnWhich;
    1041                 :            :     sal_uInt16 mnChar;
    1042                 :            : public:
    1043                 :          0 :     FindAttribByChar(sal_uInt16 nWhich, sal_uInt16 nChar) : mnWhich(nWhich), mnChar(nChar) {}
    1044                 :          0 :     bool operator() (const XEditAttribute& rAttr) const
    1045                 :            :     {
    1046 [ #  # ][ #  # ]:          0 :         return (rAttr.GetItem()->Which() == mnWhich) && (rAttr.GetStart() <= mnChar) && (rAttr.GetEnd() > mnChar);
                 [ #  # ]
    1047                 :            :     }
    1048                 :            : };
    1049                 :            : 
    1050                 :            : }
    1051                 :            : 
    1052                 :       3606 : void BinTextObject::StoreData( SvStream& rOStream ) const
    1053                 :            : {
    1054                 :       3606 :     sal_uInt16 nVer = 602;
    1055         [ +  - ]:       3606 :     rOStream << nVer;
    1056                 :            : 
    1057         [ +  - ]:       3606 :     rOStream << static_cast<sal_Bool>(bOwnerOfPool);
    1058                 :            : 
    1059                 :            :     // First store the pool, later only the Surregate
    1060         [ +  + ]:       3606 :     if ( bOwnerOfPool )
    1061                 :            :     {
    1062         [ +  - ]:       3558 :         GetPool()->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 );
    1063         [ +  - ]:       3558 :         GetPool()->Store( rOStream );
    1064                 :            :     }
    1065                 :            : 
    1066                 :            :     // Store Current text encoding ...
    1067 [ +  - ][ +  - ]:       3606 :     rtl_TextEncoding eEncoding = GetSOStoreTextEncoding( osl_getThreadTextEncoding() );
    1068         [ +  - ]:       3606 :     rOStream << (sal_uInt16) eEncoding;
    1069                 :            : 
    1070                 :            :     // The number of paragraphs ...
    1071                 :       3606 :     size_t nParagraphs = aContents.size();
    1072         [ +  - ]:       3606 :     rOStream << static_cast<sal_uInt16>(nParagraphs);
    1073                 :            : 
    1074                 :       3606 :     sal_Unicode nUniChar = CH_FEATURE;
    1075         [ +  - ]:       3606 :     char cFeatureConverted = rtl::OString(&nUniChar, 1, eEncoding).toChar();
    1076                 :            : 
    1077                 :            :     // The individual paragraphs ...
    1078         [ +  + ]:       7212 :     for (size_t nPara = 0; nPara < nParagraphs; ++nPara)
    1079                 :            :     {
    1080         [ +  - ]:       3606 :         const ContentInfo& rC = aContents[nPara];
    1081                 :            : 
    1082                 :            :         // Text...
    1083 [ +  - ][ +  - ]:       3606 :         rtl::OStringBuffer aBuffer(rtl::OUStringToOString(rC.GetText(), eEncoding));
                 [ +  - ]
    1084                 :            : 
    1085                 :            :         // Symbols?
    1086                 :       3606 :         bool bSymbolPara = false;
    1087 [ +  + ][ +  - ]:       3606 :         if (rC.GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SFX_ITEM_ON)
    1088                 :            :         {
    1089         [ +  - ]:        446 :             const SvxFontItem& rFontItem = (const SvxFontItem&)rC.GetParaAttribs().Get(EE_CHAR_FONTINFO);
    1090         [ -  + ]:        446 :             if ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
    1091                 :            :             {
    1092 [ #  # ][ #  # ]:          0 :                 aBuffer = rtl::OStringBuffer(rtl::OUStringToOString(rC.GetText(), RTL_TEXTENCODING_SYMBOL));
         [ #  # ][ #  # ]
    1093                 :          0 :                 bSymbolPara = true;
    1094                 :            :             }
    1095                 :            :         }
    1096         [ +  + ]:      11166 :         for (size_t nA = 0; nA < rC.aAttribs.size(); ++nA)
    1097                 :            :         {
    1098         [ +  - ]:       7560 :             const XEditAttribute& rAttr = rC.aAttribs[nA];
    1099                 :            : 
    1100         [ +  + ]:       7560 :             if (rAttr.GetItem()->Which() == EE_CHAR_FONTINFO)
    1101                 :            :             {
    1102                 :        434 :                 const SvxFontItem& rFontItem = (const SvxFontItem&)*rAttr.GetItem();
    1103         [ +  - ]:        434 :                 if ( ( !bSymbolPara && ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) )
           [ -  +  #  # ]
         [ -  + ][ +  - ]
    1104                 :          0 :                       || ( bSymbolPara && ( rFontItem.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
    1105                 :            :                 {
    1106                 :            :                     // Not correctly converted
    1107         [ #  # ]:          0 :                     String aPart( rC.GetText(), rAttr.GetStart(), rAttr.GetEnd() - rAttr.GetStart() );
    1108 [ #  # ][ #  # ]:          0 :                     rtl::OString aNew(rtl::OUStringToOString(aPart, rFontItem.GetCharSet()));
    1109         [ #  # ]:          0 :                     aBuffer.remove(rAttr.GetStart(), rAttr.GetEnd() - rAttr.GetStart());
    1110 [ #  # ][ #  # ]:          0 :                     aBuffer.insert(rAttr.GetStart(), aNew);
    1111                 :            :                 }
    1112                 :            : 
    1113                 :            :                 // Convert StarSymbol back to StarBats
    1114         [ +  - ]:        434 :                 FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
    1115         [ -  + ]:        434 :                 if ( hConv )
    1116                 :            :                 {
    1117                 :            :                     // Don't create a new Attrib with StarBats font, MBR changed the
    1118                 :            :                     // SvxFontItem::Store() to store StarBats instead of StarSymbol!
    1119         [ #  # ]:          0 :                     for (sal_uInt16 nChar = rAttr.GetStart(); nChar < rAttr.GetEnd(); ++nChar)
    1120                 :            :                     {
    1121                 :          0 :                         sal_Unicode cOld = rC.GetText().GetChar( nChar );
    1122 [ #  # ][ #  # ]:          0 :                         char cConv = rtl::OUStringToOString(rtl::OUString(ConvertFontToSubsFontChar(hConv, cOld)), RTL_TEXTENCODING_SYMBOL).toChar();
    1123         [ #  # ]:          0 :                         if ( cConv )
    1124                 :          0 :                             aBuffer[nChar] = cConv;
    1125                 :            :                     }
    1126                 :            : 
    1127         [ #  # ]:          0 :                     DestroyFontToSubsFontConverter( hConv );
    1128                 :            :                 }
    1129                 :            :             }
    1130                 :            :         }
    1131                 :            : 
    1132                 :            :         // Convert StarSymbol back to StarBats
    1133                 :            :         // StarSymbol as paragraph attribute or in StyleSheet?
    1134                 :            : 
    1135                 :       3606 :         FontToSubsFontConverter hConv = NULL;
    1136 [ +  - ][ +  + ]:       3606 :         if (rC.GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SFX_ITEM_ON)
    1137                 :            :         {
    1138 [ +  - ][ +  - ]:        446 :             hConv = CreateFontToSubsFontConverter( ((const SvxFontItem&)rC.GetParaAttribs().Get( EE_CHAR_FONTINFO )).GetFamilyName(), FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
    1139                 :            :         }
    1140         [ -  + ]:       3606 :         if ( hConv )
    1141                 :            :         {
    1142         [ #  # ]:          0 :             for ( sal_uInt16 nChar = 0; nChar < rC.GetText().Len(); nChar++ )
    1143                 :            :             {
    1144                 :          0 :                 const ContentInfo::XEditAttributesType& rAttribs = rC.aAttribs;
    1145                 :            :                 ContentInfo::XEditAttributesType::const_iterator it =
    1146                 :            :                     std::find_if(rAttribs.begin(), rAttribs.end(),
    1147 [ #  # ][ #  # ]:          0 :                                  FindAttribByChar(EE_CHAR_FONTINFO, nChar));
                 [ #  # ]
    1148                 :            : 
    1149 [ #  # ][ #  # ]:          0 :                 if (it == rAttribs.end())
                 [ #  # ]
    1150                 :            :                 {
    1151                 :          0 :                     sal_Unicode cOld = rC.GetText().GetChar( nChar );
    1152 [ #  # ][ #  # ]:          0 :                     char cConv = rtl::OUStringToOString(rtl::OUString(ConvertFontToSubsFontChar(hConv, cOld)), RTL_TEXTENCODING_SYMBOL).toChar();
    1153         [ #  # ]:          0 :                     if ( cConv )
    1154                 :          0 :                         aBuffer[nChar] = cConv;
    1155                 :            :                 }
    1156                 :            :             }
    1157                 :            : 
    1158         [ #  # ]:          0 :             DestroyFontToSubsFontConverter( hConv );
    1159                 :            : 
    1160                 :            :         }
    1161                 :            : 
    1162                 :            : 
    1163                 :            :         // Convert CH_FEATURE to CH_FEATURE_OLD
    1164                 :       3606 :         rtl::OString aText = aBuffer.makeStringAndClear().replace(cFeatureConverted, CH_FEATURE_OLD);
    1165         [ +  - ]:       3606 :         write_lenPrefixed_uInt8s_FromOString<sal_uInt16>(rOStream, aText);
    1166                 :            : 
    1167                 :            :         // StyleName and Family...
    1168 [ +  - ][ +  - ]:       3606 :         write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStream, rC.GetStyle(), eEncoding);
    1169         [ +  - ]:       3606 :         rOStream << static_cast<sal_uInt16>(rC.GetFamily());
    1170                 :            : 
    1171                 :            :         // Paragraph attributes ...
    1172         [ +  - ]:       3606 :         rC.GetParaAttribs().Store( rOStream );
    1173                 :            : 
    1174                 :            :         // The number of attributes ...
    1175                 :       3606 :         size_t nAttribs = rC.aAttribs.size();
    1176         [ +  - ]:       3606 :         rOStream << static_cast<sal_uInt16>(nAttribs);
    1177                 :            : 
    1178                 :            :         // And the individual attributes
    1179                 :            :         // Items as Surregate => always 8 bytes per Attribute
    1180                 :            :         // Which = 2; Surregat = 2; Start = 2; End = 2;
    1181         [ +  + ]:      11166 :         for (size_t nAttr = 0; nAttr < nAttribs; ++nAttr)
    1182                 :            :         {
    1183         [ +  - ]:       7560 :             const XEditAttribute& rX = rC.aAttribs[nAttr];
    1184                 :            : 
    1185         [ +  - ]:       7560 :             rOStream << rX.GetItem()->Which();
    1186         [ +  - ]:       7560 :             GetPool()->StoreSurrogate(rOStream, rX.GetItem());
    1187         [ +  - ]:       7560 :             rOStream << rX.GetStart();
    1188         [ +  - ]:       7560 :             rOStream << rX.GetEnd();
    1189                 :            :         }
    1190                 :       3606 :     }
    1191                 :            : 
    1192         [ +  - ]:       3606 :     rOStream << nMetric;
    1193                 :            : 
    1194         [ +  - ]:       3606 :     rOStream << nUserType;
    1195         [ +  - ]:       3606 :     rOStream << nObjSettings;
    1196                 :            : 
    1197         [ +  - ]:       3606 :     rOStream << static_cast<sal_Bool>(bVertical);
    1198         [ +  - ]:       3606 :     rOStream << nScriptType;
    1199                 :            : 
    1200         [ +  - ]:       3606 :     rOStream << static_cast<sal_Bool>(bStoreUnicodeStrings);
    1201         [ -  + ]:       3606 :     if ( bStoreUnicodeStrings )
    1202                 :            :     {
    1203         [ #  # ]:          0 :         for ( sal_uInt16 nPara = 0; nPara < nParagraphs; nPara++ )
    1204                 :            :         {
    1205         [ #  # ]:          0 :             const ContentInfo& rC = aContents[nPara];
    1206                 :          0 :             sal_uInt16 nL = rC.GetText().Len();
    1207         [ #  # ]:          0 :             rOStream << nL;
    1208         [ #  # ]:          0 :             rOStream.Write(rC.GetText().GetBuffer(), nL*sizeof(sal_Unicode));
    1209                 :            : 
    1210                 :            :             // StyleSheetName must be Unicode too!
    1211                 :            :             // Copy/Paste from EA3 to BETA or from BETA to EA3 not possible, not needed...
    1212                 :            :             // If needed, change nL back to sal_uLong and increase version...
    1213                 :          0 :             nL = rC.GetStyle().Len();
    1214         [ #  # ]:          0 :             rOStream << nL;
    1215         [ #  # ]:          0 :             rOStream.Write(rC.GetStyle().GetBuffer(), nL*sizeof(sal_Unicode));
    1216                 :            :         }
    1217                 :            :     }
    1218                 :       3606 : }
    1219                 :            : 
    1220                 :          0 : void BinTextObject::CreateData( SvStream& rIStream )
    1221                 :            : {
    1222         [ #  # ]:          0 :     rIStream >> nVersion;
    1223                 :            : 
    1224                 :            :     // The text object was first created with the current setting of
    1225                 :            :     // pTextObjectPool.
    1226                 :          0 :     sal_Bool bOwnerOfCurrent = bOwnerOfPool;
    1227                 :            :     sal_Bool b;
    1228         [ #  # ]:          0 :     rIStream >> b;
    1229                 :          0 :     bOwnerOfPool = b;
    1230                 :            : 
    1231 [ #  # ][ #  # ]:          0 :     if ( bOwnerOfCurrent && !bOwnerOfPool )
    1232                 :            :     {
    1233                 :            :         // A global Pool was used, but not handed over to me, but I need it!
    1234                 :            :         OSL_FAIL( "Give me the global TextObjectPool!" );
    1235                 :          0 :         return;
    1236                 :            :     }
    1237 [ #  # ][ #  # ]:          0 :     else if ( !bOwnerOfCurrent && bOwnerOfPool )
    1238                 :            :     {
    1239                 :            :         // A global Pool should be used, but this Textobject has its own.
    1240         [ #  # ]:          0 :         pPool = EditEngine::CreatePool();
    1241                 :            :     }
    1242                 :            : 
    1243         [ #  # ]:          0 :     if ( bOwnerOfPool )
    1244         [ #  # ]:          0 :         GetPool()->Load( rIStream );
    1245                 :            : 
    1246                 :            :     // CharSet, in which it was saved:
    1247                 :            :     sal_uInt16 nCharSet;
    1248         [ #  # ]:          0 :     rIStream >> nCharSet;
    1249                 :            : 
    1250         [ #  # ]:          0 :     rtl_TextEncoding eSrcEncoding = GetSOLoadTextEncoding( (rtl_TextEncoding)nCharSet );
    1251                 :            : 
    1252                 :            :     // The number of paragraphs ...
    1253                 :            :     sal_uInt16 nParagraphs;
    1254         [ #  # ]:          0 :     rIStream >> nParagraphs;
    1255                 :            : 
    1256                 :            :     // The individual paragraphs ...
    1257         [ #  # ]:          0 :     for ( sal_uLong nPara = 0; nPara < nParagraphs; nPara++ )
    1258                 :            :     {
    1259         [ #  # ]:          0 :         ContentInfo* pC = CreateAndInsertContent();
    1260                 :            : 
    1261                 :            :         // The Text...
    1262         [ #  # ]:          0 :         rtl::OString aByteString = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIStream);
    1263 [ #  # ][ #  # ]:          0 :         pC->GetText() = rtl::OStringToOUString(aByteString, eSrcEncoding);
    1264                 :            : 
    1265                 :            :         // StyleName and Family...
    1266 [ #  # ][ #  # ]:          0 :         pC->GetStyle() = rIStream.ReadUniOrByteString(eSrcEncoding);
    1267                 :            :         sal_uInt16 nStyleFamily;
    1268         [ #  # ]:          0 :         rIStream >> nStyleFamily;
    1269                 :          0 :         pC->GetFamily() = (SfxStyleFamily)nStyleFamily;
    1270                 :            : 
    1271                 :            :         // Paragraph attributes ...
    1272         [ #  # ]:          0 :         pC->GetParaAttribs().Load( rIStream );
    1273                 :            : 
    1274                 :            :         // The number of attributes ...
    1275                 :            :         sal_uInt16 nTmp16;
    1276         [ #  # ]:          0 :         rIStream >> nTmp16;
    1277                 :          0 :         size_t nAttribs = nTmp16;
    1278                 :            : 
    1279                 :            :         // And the individual attributes
    1280                 :            :         // Items as Surregate => always 8 bytes per Attributes
    1281                 :            :         // Which = 2; Surregat = 2; Start = 2; End = 2;
    1282                 :            :         size_t nAttr;
    1283         [ #  # ]:          0 :         for (nAttr = 0; nAttr < nAttribs; ++nAttr)
    1284                 :            :         {
    1285                 :            :             sal_uInt16 _nWhich, nStart, nEnd;
    1286                 :            :             const SfxPoolItem* pItem;
    1287                 :            : 
    1288         [ #  # ]:          0 :             rIStream >> _nWhich;
    1289         [ #  # ]:          0 :             _nWhich = pPool->GetNewWhich( _nWhich );
    1290         [ #  # ]:          0 :             pItem = pPool->LoadSurrogate( rIStream, _nWhich, 0 );
    1291         [ #  # ]:          0 :             rIStream >> nStart;
    1292         [ #  # ]:          0 :             rIStream >> nEnd;
    1293         [ #  # ]:          0 :             if ( pItem )
    1294                 :            :             {
    1295         [ #  # ]:          0 :                 if ( pItem->Which() == EE_FEATURE_NOTCONV )
    1296                 :            :                 {
    1297                 :          0 :                     sal_Char cEncodedChar = aByteString[nStart];
    1298                 :            :                     sal_Unicode cChar = rtl::OUString(&cEncodedChar, 1,
    1299         [ #  # ]:          0 :                         ((SvxCharSetColorItem*)pItem)->GetCharSet()).toChar();
    1300         [ #  # ]:          0 :                     pC->GetText().SetChar(nStart, cChar);
    1301                 :            :                 }
    1302                 :            :                 else
    1303                 :            :                 {
    1304         [ #  # ]:          0 :                     XEditAttribute* pAttr = new XEditAttribute( *pItem, nStart, nEnd );
    1305         [ #  # ]:          0 :                     pC->aAttribs.push_back(pAttr);
    1306                 :            : 
    1307 [ #  # ][ #  # ]:          0 :                     if ( ( _nWhich >= EE_FEATURE_START ) && ( _nWhich <= EE_FEATURE_END ) )
    1308                 :            :                     {
    1309                 :            :                         // Convert CH_FEATURE to CH_FEATURE_OLD
    1310                 :            :                         DBG_ASSERT( (sal_uInt8) aByteString[nStart] == CH_FEATURE_OLD, "CreateData: CH_FEATURE expected!" );
    1311         [ #  # ]:          0 :                         if ( (sal_uInt8) aByteString[nStart] == CH_FEATURE_OLD )
    1312         [ #  # ]:          0 :                             pC->GetText().SetChar( nStart, CH_FEATURE );
    1313                 :            :                     }
    1314                 :            :                 }
    1315                 :            :             }
    1316                 :            :         }
    1317                 :            : 
    1318                 :            :         // But check for paragraph and character symbol attribs here,
    1319                 :            :         // FinishLoad will not be called in OpenOffice Calc, no StyleSheets...
    1320                 :            : 
    1321                 :          0 :         sal_Bool bSymbolPara = false;
    1322 [ #  # ][ #  # ]:          0 :         if ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SFX_ITEM_ON )
    1323                 :            :         {
    1324         [ #  # ]:          0 :             const SvxFontItem& rFontItem = (const SvxFontItem&)pC->GetParaAttribs().Get( EE_CHAR_FONTINFO );
    1325         [ #  # ]:          0 :             if ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
    1326                 :            :             {
    1327 [ #  # ][ #  # ]:          0 :                 pC->GetText() = rtl::OStringToOUString(aByteString, RTL_TEXTENCODING_SYMBOL);
    1328                 :          0 :                 bSymbolPara = true;
    1329                 :            :             }
    1330                 :            :         }
    1331                 :            : 
    1332         [ #  # ]:          0 :         for (nAttr = pC->aAttribs.size(); nAttr; )
    1333                 :            :         {
    1334         [ #  # ]:          0 :             const XEditAttribute& rAttr = pC->aAttribs[--nAttr];
    1335         [ #  # ]:          0 :             if ( rAttr.GetItem()->Which() == EE_CHAR_FONTINFO )
    1336                 :            :             {
    1337                 :          0 :                 const SvxFontItem& rFontItem = (const SvxFontItem&)*rAttr.GetItem();
    1338         [ #  # ]:          0 :                 if ( ( !bSymbolPara && ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) )
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    1339                 :          0 :                       || ( bSymbolPara && ( rFontItem.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
    1340                 :            :                 {
    1341                 :            :                     // Not correctly converted
    1342                 :          0 :                     rtl::OString aPart(aByteString.copy(rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart()));
    1343         [ #  # ]:          0 :                     rtl::OUString aNew(rtl::OStringToOUString(aPart, rFontItem.GetCharSet()));
    1344         [ #  # ]:          0 :                     pC->GetText().Erase( rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart() );
    1345 [ #  # ][ #  # ]:          0 :                     pC->GetText().Insert( aNew, rAttr.GetStart() );
                 [ #  # ]
    1346                 :            :                 }
    1347                 :            : 
    1348                 :            :                 // Convert StarMath and StarBats to StarSymbol
    1349         [ #  # ]:          0 :                 FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
    1350         [ #  # ]:          0 :                 if ( hConv )
    1351                 :            :                 {
    1352         [ #  # ]:          0 :                     SvxFontItem aNewFontItem( rFontItem );
    1353 [ #  # ][ #  # ]:          0 :                     aNewFontItem.SetFamilyName( GetFontToSubsFontName( hConv ) );
                 [ #  # ]
    1354                 :            : 
    1355                 :            :                     // Replace the existing attribute with a new one.
    1356         [ #  # ]:          0 :                     XEditAttribute* pNewAttr = CreateAttrib(aNewFontItem, rAttr.GetStart(), rAttr.GetEnd());
    1357                 :            : 
    1358         [ #  # ]:          0 :                     pPool->Remove(*rAttr.GetItem());
    1359 [ #  # ][ #  # ]:          0 :                     pC->aAttribs.erase(pC->aAttribs.begin()+nAttr);
                 [ #  # ]
    1360 [ #  # ][ #  # ]:          0 :                     pC->aAttribs.insert(pC->aAttribs.begin()+nAttr, pNewAttr);
                 [ #  # ]
    1361                 :            : 
    1362         [ #  # ]:          0 :                     for ( sal_uInt16 nChar = pNewAttr->GetStart(); nChar < pNewAttr->GetEnd(); nChar++ )
    1363                 :            :                     {
    1364                 :          0 :                         sal_Unicode cOld = pC->GetText().GetChar( nChar );
    1365                 :            :                         DBG_ASSERT( cOld >= 0xF000, "cOld not converted?!" );
    1366         [ #  # ]:          0 :                         sal_Unicode cConv = ConvertFontToSubsFontChar( hConv, cOld );
    1367         [ #  # ]:          0 :                         if ( cConv )
    1368         [ #  # ]:          0 :                             pC->GetText().SetChar( nChar, cConv );
    1369                 :            :                     }
    1370                 :            : 
    1371 [ #  # ][ #  # ]:          0 :                     DestroyFontToSubsFontConverter( hConv );
    1372                 :            :                 }
    1373                 :            :             }
    1374                 :            :         }
    1375                 :            : 
    1376                 :            : 
    1377                 :            :         // Convert StarMath and StarBats to StarSymbol
    1378                 :            :         // Maybe old symbol font as paragraph attribute?
    1379 [ #  # ][ #  # ]:          0 :         if ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SFX_ITEM_ON )
    1380                 :            :         {
    1381         [ #  # ]:          0 :             const SvxFontItem& rFontItem = (const SvxFontItem&)pC->GetParaAttribs().Get( EE_CHAR_FONTINFO );
    1382         [ #  # ]:          0 :             FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS );
    1383         [ #  # ]:          0 :             if ( hConv )
    1384                 :            :             {
    1385         [ #  # ]:          0 :                 SvxFontItem aNewFontItem( rFontItem );
    1386 [ #  # ][ #  # ]:          0 :                 aNewFontItem.SetFamilyName( GetFontToSubsFontName( hConv ) );
                 [ #  # ]
    1387         [ #  # ]:          0 :                 pC->GetParaAttribs().Put( aNewFontItem );
    1388                 :            : 
    1389         [ #  # ]:          0 :                 for ( sal_uInt16 nChar = 0; nChar < pC->GetText().Len(); nChar++ )
    1390                 :            :                 {
    1391                 :          0 :                     const ContentInfo::XEditAttributesType& rAttribs = pC->aAttribs;
    1392                 :            :                     ContentInfo::XEditAttributesType::const_iterator it =
    1393                 :            :                         std::find_if(rAttribs.begin(), rAttribs.end(),
    1394 [ #  # ][ #  # ]:          0 :                                      FindAttribByChar(EE_CHAR_FONTINFO, nChar));
                 [ #  # ]
    1395                 :            : 
    1396 [ #  # ][ #  # ]:          0 :                     if (it == rAttribs.end())
                 [ #  # ]
    1397                 :            :                     {
    1398                 :          0 :                         sal_Unicode cOld = pC->GetText().GetChar( nChar );
    1399                 :            :                         DBG_ASSERT( cOld >= 0xF000, "cOld not converted?!" );
    1400         [ #  # ]:          0 :                         sal_Unicode cConv = ConvertFontToSubsFontChar( hConv, cOld );
    1401         [ #  # ]:          0 :                         if ( cConv )
    1402         [ #  # ]:          0 :                             pC->GetText().SetChar( nChar, cConv );
    1403                 :            :                     }
    1404                 :            :                 }
    1405                 :            : 
    1406 [ #  # ][ #  # ]:          0 :                 DestroyFontToSubsFontConverter( hConv );
    1407                 :            :             }
    1408                 :            :         }
    1409                 :          0 :     }
    1410                 :            : 
    1411                 :            :     // From 400 also the DefMetric:
    1412         [ #  # ]:          0 :     if ( nVersion >= 400 )
    1413                 :            :     {
    1414                 :            :         sal_uInt16 nTmpMetric;
    1415         [ #  # ]:          0 :         rIStream >> nTmpMetric;
    1416         [ #  # ]:          0 :         if ( nVersion >= 401 )
    1417                 :            :         {
    1418                 :            :             // In the 400 there was a bug in text objects with the own Pool,
    1419                 :            :             // therefore evaluate only from 401
    1420                 :          0 :             nMetric = nTmpMetric;
    1421 [ #  # ][ #  # ]:          0 :             if ( bOwnerOfPool && pPool && ( nMetric != 0xFFFF ) )
                 [ #  # ]
    1422         [ #  # ]:          0 :                 pPool->SetDefaultMetric( (SfxMapUnit)nMetric );
    1423                 :            :         }
    1424                 :            :     }
    1425                 :            : 
    1426         [ #  # ]:          0 :     if ( nVersion >= 600 )
    1427                 :            :     {
    1428         [ #  # ]:          0 :         rIStream >> nUserType;
    1429         [ #  # ]:          0 :         rIStream >> nObjSettings;
    1430                 :            :     }
    1431                 :            : 
    1432         [ #  # ]:          0 :     if ( nVersion >= 601 )
    1433                 :            :     {
    1434                 :            :         sal_Bool bTmp;
    1435         [ #  # ]:          0 :         rIStream >> bTmp;
    1436                 :          0 :         bVertical = bTmp;
    1437                 :            :     }
    1438                 :            : 
    1439         [ #  # ]:          0 :     if ( nVersion >= 602 )
    1440                 :            :     {
    1441         [ #  # ]:          0 :         rIStream >> nScriptType;
    1442                 :            : 
    1443                 :            :         sal_Bool bUnicodeStrings;
    1444         [ #  # ]:          0 :         rIStream >> bUnicodeStrings;
    1445         [ #  # ]:          0 :         if ( bUnicodeStrings )
    1446                 :            :         {
    1447                 :            :             using comphelper::string::rtl_uString_alloc;
    1448                 :            : 
    1449         [ #  # ]:          0 :             for ( sal_uInt16 nPara = 0; nPara < nParagraphs; nPara++ )
    1450                 :            :             {
    1451         [ #  # ]:          0 :                 ContentInfo& rC = aContents[nPara];
    1452                 :            :                 sal_uInt16 nL;
    1453                 :            : 
    1454                 :            :                 // Text
    1455         [ #  # ]:          0 :                 rIStream >> nL;
    1456         [ #  # ]:          0 :                 if ( nL )
    1457                 :            :                 {
    1458         [ #  # ]:          0 :                     rtl_uString *pStr = rtl_uString_alloc(nL);
    1459         [ #  # ]:          0 :                     rIStream.Read(pStr->buffer, nL*sizeof(sal_Unicode));
    1460         [ #  # ]:          0 :                     rC.GetText() = rtl::OUString(pStr, SAL_NO_ACQUIRE);
    1461                 :            :                 }
    1462                 :            : 
    1463                 :            :                 // StyleSheetName
    1464         [ #  # ]:          0 :                 rIStream >> nL;
    1465         [ #  # ]:          0 :                 if ( nL )
    1466                 :            :                 {
    1467         [ #  # ]:          0 :                     rtl_uString *pStr = rtl_uString_alloc(nL);
    1468         [ #  # ]:          0 :                     rIStream.Read(pStr->buffer, nL*sizeof(sal_Unicode) );
    1469         [ #  # ]:          0 :                     rC.GetStyle() = rtl::OUString(pStr, SAL_NO_ACQUIRE);
    1470                 :            :                 }
    1471                 :            :             }
    1472                 :            :         }
    1473                 :            :     }
    1474                 :            : 
    1475                 :            : 
    1476                 :            :     // from 500 the tabs are interpreted differently: TabPos + LI, previously only TabPos.
    1477                 :            :     // Works only if tab positions are set, not when DefTab.
    1478         [ #  # ]:          0 :     if ( nVersion < 500 )
    1479                 :            :     {
    1480         [ #  # ]:          0 :         for (size_t i = 0, n = aContents.size(); i < n; ++i)
    1481                 :            :         {
    1482         [ #  # ]:          0 :             ContentInfo& rC = aContents[i];
    1483         [ #  # ]:          0 :             const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(rC.GetParaAttribs().Get(EE_PARA_LRSPACE));
    1484 [ #  # ][ #  # ]:          0 :             if ( rLRSpace.GetTxtLeft() && ( rC.GetParaAttribs().GetItemState( EE_PARA_TABS ) == SFX_ITEM_ON ) )
         [ #  # ][ #  # ]
    1485                 :            :             {
    1486         [ #  # ]:          0 :                 const SvxTabStopItem& rTabs = static_cast<const SvxTabStopItem&>(rC.GetParaAttribs().Get(EE_PARA_TABS));
    1487         [ #  # ]:          0 :                 SvxTabStopItem aNewTabs( 0, 0, SVX_TAB_ADJUST_LEFT, EE_PARA_TABS );
    1488         [ #  # ]:          0 :                 for ( sal_uInt16 t = 0; t < rTabs.Count(); t++ )
    1489                 :            :                 {
    1490         [ #  # ]:          0 :                     const SvxTabStop& rT = rTabs[ t ];
    1491                 :          0 :                     aNewTabs.Insert( SvxTabStop( rT.GetTabPos() - rLRSpace.GetTxtLeft(),
    1492 [ #  # ][ #  # ]:          0 :                                 rT.GetAdjustment(), rT.GetDecimal(), rT.GetFill() ) );
                 [ #  # ]
    1493                 :            :                 }
    1494 [ #  # ][ #  # ]:          0 :                 rC.GetParaAttribs().Put( aNewTabs );
    1495                 :            :             }
    1496                 :            :         }
    1497                 :            :     }
    1498                 :            : }
    1499                 :            : 
    1500                 :          0 : sal_uInt16 BinTextObject::GetVersion() const
    1501                 :            : {
    1502                 :          0 :     return nVersion;
    1503                 :            : }
    1504                 :            : 
    1505                 :       1544 : bool BinTextObject::operator==( const BinTextObject& rCompare ) const
    1506                 :            : {
    1507         [ -  + ]:       1544 :     if( this == &rCompare )
    1508                 :          0 :         return true;
    1509                 :            : 
    1510 [ +  + ][ +  - ]:       1544 :     if( ( aContents.size() != rCompare.aContents.size() ) ||
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
                 [ +  + ]
    1511                 :            :             ( pPool != rCompare.pPool ) ||
    1512                 :            :             ( nMetric != rCompare.nMetric ) ||
    1513                 :            :             ( nUserType!= rCompare.nUserType ) ||
    1514                 :            :             ( nScriptType != rCompare.nScriptType ) ||
    1515                 :            :             ( bVertical != rCompare.bVertical ) )
    1516                 :         62 :         return false;
    1517                 :            : 
    1518         [ +  + ]:       2659 :     for (size_t i = 0, n = aContents.size(); i < n; ++i)
    1519                 :            :     {
    1520         [ +  + ]:       2440 :         if (aContents[i] != rCompare.aContents[i])
    1521                 :       1263 :             return false;
    1522                 :            :     }
    1523                 :            : 
    1524                 :       1544 :     return true;
    1525                 :            : }
    1526                 :            : 
    1527                 :            : // #i102062#
    1528                 :        201 : bool BinTextObject::isWrongListEqual(const BinTextObject& rCompare) const
    1529                 :            : {
    1530         [ -  + ]:        201 :     if (aContents.size() != rCompare.aContents.size())
    1531                 :            :     {
    1532                 :          0 :         return false;
    1533                 :            :     }
    1534                 :            : 
    1535         [ +  + ]:        993 :     for (size_t i = 0, n = aContents.size(); i < n; ++i)
    1536                 :            :     {
    1537                 :        792 :         const ContentInfo& rCandA = aContents[i];
    1538                 :        792 :         const ContentInfo& rCandB = rCompare.aContents[i];
    1539                 :            : 
    1540         [ -  + ]:        792 :         if(!rCandA.isWrongListEqual(rCandB))
    1541                 :            :         {
    1542                 :          0 :             return false;
    1543                 :            :         }
    1544                 :            :     }
    1545                 :            : 
    1546                 :        201 :     return true;
    1547                 :            : }
    1548                 :            : 
    1549                 :            : #define CHARSETMARKER   0x9999
    1550                 :            : 
    1551                 :          0 : void BinTextObject::CreateData300( SvStream& rIStream )
    1552                 :            : {
    1553                 :            :     // For forward compatibility.
    1554                 :            : 
    1555                 :            :     // First load the Pool...
    1556                 :            :     // Is always saved in the 300!
    1557         [ #  # ]:          0 :     GetPool()->Load( rIStream );
    1558                 :            : 
    1559                 :            :     // The number of paragraphs ...
    1560                 :            :     sal_uInt32 nParagraphs;
    1561         [ #  # ]:          0 :     rIStream >> nParagraphs;
    1562                 :            : 
    1563                 :            :     // The individual paragraphs...
    1564         [ #  # ]:          0 :     for ( sal_uLong nPara = 0; nPara < nParagraphs; nPara++ )
    1565                 :            :     {
    1566         [ #  # ]:          0 :         ContentInfo* pC = CreateAndInsertContent();
    1567                 :            : 
    1568                 :            :         // The Text...
    1569 [ #  # ][ #  # ]:          0 :         pC->GetText() = rIStream.ReadUniOrByteString(rIStream.GetStreamCharSet());
    1570                 :            : 
    1571                 :            :         // StyleName and Family...
    1572 [ #  # ][ #  # ]:          0 :         pC->GetStyle() = rIStream.ReadUniOrByteString(rIStream.GetStreamCharSet());
    1573                 :            :         sal_uInt16 nStyleFamily;
    1574         [ #  # ]:          0 :         rIStream >> nStyleFamily;
    1575                 :          0 :         pC->GetFamily() = (SfxStyleFamily)nStyleFamily;
    1576                 :            : 
    1577                 :            :         // Paragraph attributes ...
    1578         [ #  # ]:          0 :         pC->GetParaAttribs().Load( rIStream );
    1579                 :            : 
    1580                 :            :         // The number of attributes ...
    1581                 :            :         sal_uInt32 nAttribs;
    1582         [ #  # ]:          0 :         rIStream >> nAttribs;
    1583                 :            : 
    1584                 :            :         // And the individual attributes
    1585                 :            :         // Items as Surregate => always 8 bytes per Attribute
    1586                 :            :         // Which = 2; Surregat = 2; Start = 2; End = 2;
    1587         [ #  # ]:          0 :         for ( sal_uLong nAttr = 0; nAttr < nAttribs; nAttr++ )
    1588                 :            :         {
    1589                 :            :             sal_uInt16 _nWhich, nStart, nEnd;
    1590                 :            :             const SfxPoolItem* pItem;
    1591                 :            : 
    1592         [ #  # ]:          0 :             rIStream >> _nWhich;
    1593         [ #  # ]:          0 :             _nWhich = pPool->GetNewWhich( _nWhich );
    1594         [ #  # ]:          0 :             pItem = pPool->LoadSurrogate( rIStream, _nWhich, 0 );
    1595         [ #  # ]:          0 :             rIStream >> nStart;
    1596         [ #  # ]:          0 :             rIStream >> nEnd;
    1597         [ #  # ]:          0 :             if ( pItem )
    1598                 :            :             {
    1599         [ #  # ]:          0 :                 XEditAttribute* pAttr = new XEditAttribute( *pItem, nStart, nEnd );
    1600         [ #  # ]:          0 :                 pC->aAttribs.push_back(pAttr);
    1601                 :            :             }
    1602                 :            :         }
    1603                 :            :     }
    1604                 :            : 
    1605                 :            :     // Check whether a font was saved
    1606                 :            :     sal_uInt16 nCharSetMarker;
    1607         [ #  # ]:          0 :     rIStream >> nCharSetMarker;
    1608         [ #  # ]:          0 :     if ( nCharSetMarker == CHARSETMARKER )
    1609                 :            :     {
    1610                 :            :         sal_uInt16 nCharSet;
    1611         [ #  # ]:          0 :         rIStream >> nCharSet;
    1612                 :            :     }
    1613                 :          0 : }
    1614                 :            : 
    1615                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10