LCOV - code coverage report
Current view: top level - sw/source/core/txtnode - fmtatr2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 284 355 80.0 %
Date: 2012-08-25 Functions: 73 83 88.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 251 533 47.1 %

           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                 :            : 
      30                 :            : #include "hintids.hxx"
      31                 :            : #include "unomid.h"
      32                 :            : 
      33                 :            : #include <basic/sbxvar.hxx>
      34                 :            : #include <svl/macitem.hxx>
      35                 :            : #include <svl/stritem.hxx>
      36                 :            : #include <svl/stylepool.hxx>
      37                 :            : #include <fmtautofmt.hxx>
      38                 :            : #include <fchrfmt.hxx>
      39                 :            : #include <fmtinfmt.hxx>
      40                 :            : #include <txtatr.hxx>
      41                 :            : #include <fmtruby.hxx>
      42                 :            : #include <charfmt.hxx>
      43                 :            : #include <hints.hxx>        // SwUpdateAttr
      44                 :            : #include <unostyle.hxx>
      45                 :            : #include <unoevent.hxx>     // SwHyperlinkEventDescriptor
      46                 :            : #include <com/sun/star/text/RubyAdjust.hpp>
      47                 :            : 
      48                 :            : #include <cmdid.h>
      49                 :            : #include <com/sun/star/uno/Any.h>
      50                 :            : #include <SwStyleNameMapper.hxx>
      51                 :            : 
      52                 :            : #include <fmtmeta.hxx>
      53                 :            : #include <ndtxt.hxx> // for meta
      54                 :            : #include <doc.hxx> // for meta
      55                 :            : #include <unometa.hxx>
      56                 :            : #include <docsh.hxx>
      57                 :            : #include <svl/zforlist.hxx> // GetNumberFormat
      58                 :            : 
      59                 :            : #include <boost/bind.hpp>
      60                 :            : #include <algorithm>
      61                 :            : 
      62                 :            : 
      63                 :            : using namespace ::com::sun::star;
      64                 :            : using ::rtl::OUString;
      65                 :            : 
      66 [ -  + ][ -  + ]:       5058 : TYPEINIT1_AUTOFACTORY(SwFmtINetFmt, SfxPoolItem);
                 [ #  # ]
      67 [ -  + ][ -  + ]:       9337 : TYPEINIT1_AUTOFACTORY(SwFmtAutoFmt, SfxPoolItem);
                 [ #  # ]
      68                 :            : 
      69                 :            : /*************************************************************************
      70                 :            : |*
      71                 :            : |*    class SwFmtCharFmt
      72                 :            : |*
      73                 :            : *************************************************************************/
      74                 :            : 
      75                 :       1623 : SwFmtCharFmt::SwFmtCharFmt( SwCharFmt *pFmt )
      76                 :            :     : SfxPoolItem( RES_TXTATR_CHARFMT ),
      77                 :            :     SwClient(pFmt),
      78         [ +  - ]:       1623 :     pTxtAttr( 0 )
      79                 :            : {
      80                 :       1623 : }
      81                 :            : 
      82                 :            : 
      83                 :            : 
      84                 :      33874 : SwFmtCharFmt::SwFmtCharFmt( const SwFmtCharFmt& rAttr )
      85                 :            :     : SfxPoolItem( RES_TXTATR_CHARFMT ),
      86                 :      33874 :     SwClient( rAttr.GetCharFmt() ),
      87         [ +  - ]:      67748 :     pTxtAttr( 0 )
      88                 :            : {
      89                 :      33874 : }
      90                 :            : 
      91                 :            : 
      92                 :            : 
      93 [ +  - ][ -  + ]:      69448 : SwFmtCharFmt::~SwFmtCharFmt() {}
      94                 :            : 
      95                 :            : 
      96                 :            : 
      97                 :          0 : int SwFmtCharFmt::operator==( const SfxPoolItem& rAttr ) const
      98                 :            : {
      99                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
     100                 :          0 :     return GetCharFmt() == ((SwFmtCharFmt&)rAttr).GetCharFmt();
     101                 :            : }
     102                 :            : 
     103                 :            : 
     104                 :            : 
     105                 :      33874 : SfxPoolItem* SwFmtCharFmt::Clone( SfxItemPool* ) const
     106                 :            : {
     107         [ +  - ]:      33874 :     return new SwFmtCharFmt( *this );
     108                 :            : }
     109                 :            : 
     110                 :            : 
     111                 :            : 
     112                 :            : // weiterleiten an das TextAttribut
     113                 :        508 : void SwFmtCharFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     114                 :            : {
     115         [ +  + ]:        508 :     if( pTxtAttr )
     116                 :        264 :         pTxtAttr->ModifyNotification( pOld, pNew );
     117                 :        508 : }
     118                 :            : 
     119                 :            : 
     120                 :            : 
     121                 :            : // weiterleiten an das TextAttribut
     122                 :          4 : sal_Bool SwFmtCharFmt::GetInfo( SfxPoolItem& rInfo ) const
     123                 :            : {
     124         [ +  - ]:          4 :     return pTxtAttr ? pTxtAttr->GetInfo( rInfo ) : sal_False;
     125                 :            : }
     126                 :         10 : bool SwFmtCharFmt::QueryValue( uno::Any& rVal, sal_uInt8 ) const
     127                 :            : {
     128         [ +  - ]:         10 :     String sCharFmtName;
     129         [ +  + ]:         10 :     if(GetCharFmt())
     130         [ +  - ]:          4 :         SwStyleNameMapper::FillProgName(GetCharFmt()->GetName(), sCharFmtName,  nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
     131 [ +  - ][ +  - ]:         10 :     rVal <<= OUString( sCharFmtName );
     132         [ +  - ]:         10 :     return true;
     133                 :            : }
     134                 :          0 : bool SwFmtCharFmt::PutValue( const uno::Any& , sal_uInt8   )
     135                 :            : {
     136                 :            :     OSL_FAIL("Zeichenvorlage kann mit PutValue nicht gesetzt werden!");
     137                 :          0 :     return false;
     138                 :            : }
     139                 :            : 
     140                 :            : /*************************************************************************
     141                 :            : |*
     142                 :            : |*    class SwFmtAutoFmt
     143                 :            : |*
     144                 :            : *************************************************************************/
     145                 :            : 
     146                 :      25743 : SwFmtAutoFmt::SwFmtAutoFmt( sal_uInt16 nInitWhich )
     147         [ +  - ]:      25743 :     : SfxPoolItem( nInitWhich )
     148                 :            : {
     149                 :      25743 : }
     150                 :            : 
     151                 :      21236 : SwFmtAutoFmt::SwFmtAutoFmt( const SwFmtAutoFmt& rAttr )
     152         [ +  - ]:      21236 :     : SfxPoolItem( rAttr.Which() ), mpHandle( rAttr.mpHandle )
     153                 :            : {
     154                 :      21236 : }
     155                 :            : 
     156         [ +  - ]:      46973 : SwFmtAutoFmt::~SwFmtAutoFmt()
     157                 :            : {
     158         [ -  + ]:      68349 : }
     159                 :            : 
     160                 :      79411 : int SwFmtAutoFmt::operator==( const SfxPoolItem& rAttr ) const
     161                 :            : {
     162                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "different attributes" );
     163                 :      79411 :     return mpHandle == ((SwFmtAutoFmt&)rAttr).mpHandle;
     164                 :            : }
     165                 :            : 
     166                 :      21236 : SfxPoolItem* SwFmtAutoFmt::Clone( SfxItemPool* ) const
     167                 :            : {
     168         [ +  - ]:      21236 :     return new SwFmtAutoFmt( *this );
     169                 :            : }
     170                 :            : 
     171                 :          4 : bool SwFmtAutoFmt::QueryValue( uno::Any& rVal, sal_uInt8 ) const
     172                 :            : {
     173 [ +  - ][ +  - ]:          4 :     String sCharFmtName = StylePool::nameOf( mpHandle );
         [ +  - ][ +  - ]
     174 [ +  - ][ +  - ]:          4 :     rVal <<= OUString( sCharFmtName );
     175         [ +  - ]:          4 :     return true;
     176                 :            : }
     177                 :            : 
     178                 :          0 : bool SwFmtAutoFmt::PutValue( const uno::Any& , sal_uInt8 )
     179                 :            : {
     180                 :            :     //the format is not renameable via API
     181                 :          0 :     return false;
     182                 :            : }
     183                 :            : 
     184                 :            : /*************************************************************************
     185                 :            : |*
     186                 :            : |*    class SwFmtINetFmt
     187                 :            : |*
     188                 :            : *************************************************************************/
     189                 :            : 
     190                 :          0 : SwFmtINetFmt::SwFmtINetFmt()
     191                 :            :     : SfxPoolItem( RES_TXTATR_INETFMT ),
     192                 :            :     pMacroTbl( 0 ),
     193                 :            :     pTxtAttr( 0 ),
     194                 :            :     nINetId( 0 ),
     195 [ #  # ][ #  # ]:          0 :     nVisitedId( 0 )
         [ #  # ][ #  # ]
                 [ #  # ]
     196                 :          0 : {}
     197                 :            : 
     198                 :         82 : SwFmtINetFmt::SwFmtINetFmt( const XubString& rURL, const XubString& rTarget )
     199                 :            :     : SfxPoolItem( RES_TXTATR_INETFMT ),
     200                 :            :     aURL( rURL ),
     201                 :            :     aTargetFrame( rTarget ),
     202                 :            :     pMacroTbl( 0 ),
     203                 :            :     pTxtAttr( 0 ),
     204                 :            :     nINetId( 0 ),
     205 [ +  - ][ +  - ]:         82 :     nVisitedId( 0 )
         [ +  - ][ +  - ]
                 [ +  - ]
     206                 :            : {
     207                 :         82 : }
     208                 :            : 
     209                 :       1001 : SwFmtINetFmt::SwFmtINetFmt( const SwFmtINetFmt& rAttr )
     210                 :            :     : SfxPoolItem( RES_TXTATR_INETFMT ),
     211                 :       1001 :     aURL( rAttr.GetValue() ),
     212                 :            :     aTargetFrame( rAttr.aTargetFrame ),
     213                 :            :     aINetFmt( rAttr.aINetFmt ),
     214                 :            :     aVisitedFmt( rAttr.aVisitedFmt ),
     215                 :            :     aName( rAttr.aName ),
     216                 :            :     pMacroTbl( 0 ),
     217                 :            :     pTxtAttr( 0 ),
     218                 :            :     nINetId( rAttr.nINetId ),
     219 [ +  - ][ +  - ]:       2002 :     nVisitedId( rAttr.nVisitedId )
         [ +  - ][ +  - ]
                 [ +  - ]
     220                 :            : {
     221         [ -  + ]:       1001 :     if( rAttr.GetMacroTbl() )
     222 [ #  # ][ #  # ]:          0 :         pMacroTbl = new SvxMacroTableDtor( *rAttr.GetMacroTbl() );
     223                 :       1001 : }
     224                 :            : 
     225 [ +  - ][ +  - ]:       1083 : SwFmtINetFmt::~SwFmtINetFmt()
         [ +  - ][ +  - ]
                 [ +  - ]
     226                 :            : {
     227         [ -  + ]:       1083 :     delete pMacroTbl;
     228         [ -  + ]:       2157 : }
     229                 :            : 
     230                 :            : 
     231                 :            : 
     232                 :         44 : int SwFmtINetFmt::operator==( const SfxPoolItem& rAttr ) const
     233                 :            : {
     234                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
     235                 :         44 :     sal_Bool bRet = SfxPoolItem::operator==( (SfxPoolItem&) rAttr )
     236                 :         44 :                 && aURL == ((SwFmtINetFmt&)rAttr).aURL
     237                 :         22 :                 && aName == ((SwFmtINetFmt&)rAttr).aName
     238                 :         18 :                 && aTargetFrame == ((SwFmtINetFmt&)rAttr).aTargetFrame
     239                 :         14 :                 && aINetFmt == ((SwFmtINetFmt&)rAttr).aINetFmt
     240                 :         10 :                 && aVisitedFmt == ((SwFmtINetFmt&)rAttr).aVisitedFmt
     241                 :            :                 && nINetId == ((SwFmtINetFmt&)rAttr).nINetId
     242 [ +  - ][ +  - ]:        152 :                 && nVisitedId == ((SwFmtINetFmt&)rAttr).nVisitedId;
           [ +  -  +  +  
          +  +  +  +  +  
                +  +  + ]
     243                 :            : 
     244         [ +  + ]:         44 :     if( !bRet )
     245                 :         38 :         return sal_False;
     246                 :            : 
     247                 :          6 :     const SvxMacroTableDtor* pOther = ((SwFmtINetFmt&)rAttr).pMacroTbl;
     248         [ +  - ]:          6 :     if( !pMacroTbl )
     249 [ -  + ][ #  # ]:          6 :         return ( !pOther || pOther->empty() );
     250         [ #  # ]:          0 :     if( !pOther )
     251                 :          0 :         return pMacroTbl->empty();
     252                 :            : 
     253                 :          0 :     const SvxMacroTableDtor& rOwn = *pMacroTbl;
     254                 :          0 :     const SvxMacroTableDtor& rOther = *pOther;
     255                 :            : 
     256                 :         44 :     return rOwn == rOther;
     257                 :            : }
     258                 :            : 
     259                 :            : 
     260                 :            : 
     261                 :       1001 : SfxPoolItem* SwFmtINetFmt::Clone( SfxItemPool* ) const
     262                 :            : {
     263         [ +  - ]:       1001 :     return new SwFmtINetFmt( *this );
     264                 :            : }
     265                 :            : 
     266                 :            : 
     267                 :            : 
     268                 :          0 : void SwFmtINetFmt::SetMacroTbl( const SvxMacroTableDtor* pNewTbl )
     269                 :            : {
     270         [ #  # ]:          0 :     if( pNewTbl )
     271                 :            :     {
     272         [ #  # ]:          0 :         if( pMacroTbl )
     273                 :          0 :             *pMacroTbl = *pNewTbl;
     274                 :            :         else
     275         [ #  # ]:          0 :             pMacroTbl = new SvxMacroTableDtor( *pNewTbl );
     276                 :            :     }
     277                 :            :     else
     278         [ #  # ]:          0 :         delete pMacroTbl, pMacroTbl = 0;
     279                 :          0 : }
     280                 :            : 
     281                 :            : 
     282                 :            : 
     283                 :          0 : void SwFmtINetFmt::SetMacro( sal_uInt16 nEvent, const SvxMacro& rMacro )
     284                 :            : {
     285         [ #  # ]:          0 :     if( !pMacroTbl )
     286         [ #  # ]:          0 :         pMacroTbl = new SvxMacroTableDtor;
     287                 :            : 
     288                 :          0 :      pMacroTbl->Insert( nEvent, rMacro );
     289                 :          0 : }
     290                 :            : 
     291                 :            : 
     292                 :            : 
     293                 :          6 : const SvxMacro* SwFmtINetFmt::GetMacro( sal_uInt16 nEvent ) const
     294                 :            : {
     295                 :          6 :     const SvxMacro* pRet = 0;
     296 [ -  + ][ #  # ]:          6 :     if( pMacroTbl && pMacroTbl->IsKeyValid( nEvent ) )
                 [ -  + ]
     297                 :          0 :         pRet = pMacroTbl->Get( nEvent );
     298                 :          6 :     return pRet;
     299                 :            : }
     300                 :            : 
     301                 :            : 
     302                 :            : 
     303                 :        997 : bool SwFmtINetFmt::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     304                 :            : {
     305                 :        997 :     bool bRet = true;
     306         [ +  - ]:        997 :     XubString sVal;
     307                 :        997 :     nMemberId &= ~CONVERT_TWIPS;
     308   [ +  +  +  +  :        997 :     switch(nMemberId)
                +  +  - ]
     309                 :            :     {
     310                 :            :         case MID_URL_URL:
     311         [ +  - ]:        953 :             sVal = aURL;
     312                 :        953 :         break;
     313                 :            :         case MID_URL_TARGET:
     314         [ +  - ]:         10 :             sVal = aTargetFrame;
     315                 :         10 :         break;
     316                 :            :         case MID_URL_HYPERLINKNAME:
     317         [ +  - ]:         10 :             sVal = aName;
     318                 :         10 :         break;
     319                 :            :         case MID_URL_VISITED_FMT:
     320         [ +  - ]:         12 :             sVal = aVisitedFmt;
     321 [ +  + ][ -  + ]:         12 :             if( !sVal.Len() && nVisitedId != 0 )
                 [ -  + ]
     322         [ #  # ]:          0 :                 SwStyleNameMapper::FillUIName( nVisitedId, sVal );
     323         [ +  + ]:         12 :             if( sVal.Len() )
     324         [ +  - ]:          4 :                 SwStyleNameMapper::FillProgName( sVal, sVal, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
     325                 :         12 :         break;
     326                 :            :         case MID_URL_UNVISITED_FMT:
     327         [ +  - ]:         10 :             sVal = aINetFmt;
     328 [ +  + ][ -  + ]:         10 :             if( !sVal.Len() && nINetId != 0 )
                 [ -  + ]
     329         [ #  # ]:          0 :                 SwStyleNameMapper::FillUIName( nINetId, sVal );
     330         [ +  + ]:         10 :             if( sVal.Len() )
     331         [ +  - ]:          4 :                 SwStyleNameMapper::FillProgName( sVal, sVal, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
     332                 :         10 :         break;
     333                 :            :         case MID_URL_HYPERLINKEVENTS:
     334                 :            :         {
     335                 :            :             // create (and return) event descriptor
     336                 :            :             SwHyperlinkEventDescriptor* pEvents =
     337         [ +  - ]:          2 :                 new SwHyperlinkEventDescriptor();
     338         [ +  - ]:          2 :             pEvents->copyMacrosFromINetFmt(*this);
     339 [ +  - ][ +  - ]:          2 :             uno::Reference<container::XNameReplace> xNameReplace(pEvents);
     340                 :            : 
     341                 :            :             // all others return a string; so we just set rVal here and exit
     342         [ +  - ]:          2 :             rVal <<= xNameReplace;
     343                 :          2 :             return bRet;
     344                 :            :         }
     345                 :            :         default:
     346                 :          0 :         break;
     347                 :            :     }
     348 [ +  - ][ +  - ]:        995 :     rVal <<= OUString(sVal);
     349         [ +  - ]:        997 :     return bRet;
     350                 :            : }
     351                 :         80 : bool SwFmtINetFmt::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId  )
     352                 :            : {
     353                 :         80 :     bool bRet = true;
     354                 :         80 :     nMemberId &= ~CONVERT_TWIPS;
     355                 :            : 
     356                 :            :     // all properties except HyperlinkEvents are of type string, hence
     357                 :            :     // we treat HyperlinkEvents specially
     358         [ -  + ]:         80 :     if (MID_URL_HYPERLINKEVENTS == nMemberId)
     359                 :            :     {
     360                 :          0 :         uno::Reference<container::XNameReplace> xReplace;
     361         [ #  # ]:          0 :         rVal >>= xReplace;
     362         [ #  # ]:          0 :         if (xReplace.is())
     363                 :            :         {
     364                 :            :             // Create hyperlink event descriptor. Then copy events
     365                 :            :             // from argument into descriptor. Then copy events from
     366                 :            :             // the descriptor into the format.
     367         [ #  # ]:          0 :             SwHyperlinkEventDescriptor* pEvents = new SwHyperlinkEventDescriptor();
     368 [ #  # ][ #  # ]:          0 :             uno::Reference< lang::XServiceInfo> xHold = pEvents;
     369         [ #  # ]:          0 :             pEvents->copyMacrosFromNameReplace(xReplace);
     370         [ #  # ]:          0 :             pEvents->copyMacrosIntoINetFmt(*this);
     371                 :            :         }
     372                 :            :         else
     373                 :            :         {
     374                 :            :             // wrong type!
     375                 :          0 :             bRet = false;
     376                 :          0 :         }
     377                 :            :     }
     378                 :            :     else
     379                 :            :     {
     380                 :            :         // all string properties:
     381 [ +  - ][ -  + ]:         80 :         if(rVal.getValueType() != ::getCppuType((rtl::OUString*)0))
     382                 :          0 :             return false;
     383         [ +  - ]:         80 :         XubString sVal = *(rtl::OUString*)rVal.getValue();
     384   [ +  +  +  +  :         80 :         switch(nMemberId)
                   +  - ]
     385                 :            :         {
     386                 :            :             case MID_URL_URL:
     387         [ +  - ]:         58 :                 aURL = sVal;
     388                 :         58 :                 break;
     389                 :            :             case MID_URL_TARGET:
     390         [ +  - ]:          7 :                 aTargetFrame = sVal;
     391                 :          7 :                 break;
     392                 :            :             case MID_URL_HYPERLINKNAME:
     393         [ +  - ]:          7 :                 aName = sVal;
     394                 :          7 :                 break;
     395                 :            :             case MID_URL_VISITED_FMT:
     396                 :            :             {
     397         [ +  - ]:          4 :                 String aString;
     398         [ +  - ]:          4 :                 SwStyleNameMapper::FillUIName( sVal, aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
     399 [ +  - ][ +  - ]:          4 :                 aVisitedFmt = OUString ( aString );
     400                 :            :                 nVisitedId = SwStyleNameMapper::GetPoolIdFromUIName( aVisitedFmt,
     401 [ +  - ][ +  - ]:          4 :                                                nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
     402                 :            :             }
     403                 :          4 :             break;
     404                 :            :             case MID_URL_UNVISITED_FMT:
     405                 :            :             {
     406         [ +  - ]:          4 :                 String aString;
     407         [ +  - ]:          4 :                 SwStyleNameMapper::FillUIName( sVal, aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
     408 [ +  - ][ +  - ]:          4 :                 aINetFmt = OUString ( aString );
     409 [ +  - ][ +  - ]:          4 :                 nINetId = SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
     410                 :            :             }
     411                 :          4 :             break;
     412                 :            :             default:
     413                 :          0 :                 bRet = false;
     414         [ +  - ]:         80 :         }
     415                 :            :     }
     416                 :         80 :     return bRet;
     417                 :            : }
     418                 :            : 
     419                 :            : 
     420                 :            : /*************************************************************************
     421                 :            : |*    class SwFmtRuby
     422                 :            : *************************************************************************/
     423                 :            : 
     424                 :         73 : SwFmtRuby::SwFmtRuby( const String& rRubyTxt )
     425                 :            :     : SfxPoolItem( RES_TXTATR_CJK_RUBY ),
     426                 :            :     sRubyTxt( rRubyTxt ),
     427                 :            :     pTxtAttr( 0 ),
     428                 :            :     nCharFmtId( 0 ),
     429                 :            :     nPosition( 0 ),
     430 [ +  - ][ +  - ]:         73 :     nAdjustment( 0 )
     431                 :            : {
     432                 :         73 : }
     433                 :            : 
     434                 :       3938 : SwFmtRuby::SwFmtRuby( const SwFmtRuby& rAttr )
     435                 :            :     : SfxPoolItem( RES_TXTATR_CJK_RUBY ),
     436                 :            :     sRubyTxt( rAttr.sRubyTxt ),
     437                 :            :     sCharFmtName( rAttr.sCharFmtName ),
     438                 :            :     pTxtAttr( 0 ),
     439                 :            :     nCharFmtId( rAttr.nCharFmtId),
     440                 :            :     nPosition( rAttr.nPosition ),
     441 [ +  - ][ +  - ]:       3938 :     nAdjustment( rAttr.nAdjustment )
     442                 :            : {
     443                 :       3938 : }
     444                 :            : 
     445 [ +  - ][ +  - ]:       4011 : SwFmtRuby::~SwFmtRuby()
     446                 :            : {
     447         [ -  + ]:       8022 : }
     448                 :            : 
     449                 :          0 : SwFmtRuby& SwFmtRuby::operator=( const SwFmtRuby& rAttr )
     450                 :            : {
     451                 :          0 :     sRubyTxt = rAttr.sRubyTxt;
     452                 :          0 :     sCharFmtName = rAttr.sCharFmtName;
     453                 :          0 :     nCharFmtId = rAttr.nCharFmtId;
     454                 :          0 :     nPosition = rAttr.nPosition;
     455                 :          0 :     nAdjustment = rAttr.nAdjustment;
     456                 :          0 :     pTxtAttr =  0;
     457                 :          0 :     return *this;
     458                 :            : }
     459                 :            : 
     460                 :       1166 : int SwFmtRuby::operator==( const SfxPoolItem& rAttr ) const
     461                 :            : {
     462                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
     463                 :       1166 :     return sRubyTxt == ((SwFmtRuby&)rAttr).sRubyTxt &&
     464                 :       1136 :            sCharFmtName == ((SwFmtRuby&)rAttr).sCharFmtName &&
     465                 :            :            nCharFmtId == ((SwFmtRuby&)rAttr).nCharFmtId &&
     466                 :            :            nPosition == ((SwFmtRuby&)rAttr).nPosition &&
     467 [ +  - ][ +  + ]:       2302 :            nAdjustment == ((SwFmtRuby&)rAttr).nAdjustment;
                 [ +  + ]
           [ +  +  +  + ]
     468                 :            : }
     469                 :            : 
     470                 :       3930 : SfxPoolItem* SwFmtRuby::Clone( SfxItemPool* ) const
     471                 :            : {
     472         [ +  - ]:       3930 :     return new SwFmtRuby( *this );
     473                 :            : }
     474                 :            : 
     475                 :       1052 : bool SwFmtRuby::QueryValue( uno::Any& rVal,
     476                 :            :                             sal_uInt8 nMemberId ) const
     477                 :            : {
     478                 :       1052 :     bool bRet = true;
     479                 :       1052 :     nMemberId &= ~CONVERT_TWIPS;
     480   [ +  +  +  +  :       1052 :     switch( nMemberId )
                      - ]
     481                 :            :     {
     482         [ +  - ]:        262 :         case MID_RUBY_TEXT: rVal <<= (OUString)sRubyTxt;                    break;
     483         [ +  - ]:        264 :          case MID_RUBY_ADJUST:  rVal <<= (sal_Int16)nAdjustment;    break;
     484                 :            :         case MID_RUBY_CHARSTYLE:
     485                 :            :         {
     486         [ +  - ]:        262 :             String aString;
     487         [ +  - ]:        262 :             SwStyleNameMapper::FillProgName(sCharFmtName, aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
     488 [ +  - ][ +  - ]:        262 :             rVal <<= OUString ( aString );
                 [ +  - ]
     489                 :            :         }
     490                 :        262 :         break;
     491                 :            :         case MID_RUBY_ABOVE:
     492                 :            :         {
     493                 :        264 :             sal_Bool bAbove = !nPosition;
     494         [ +  - ]:        264 :             rVal.setValue(&bAbove, ::getBooleanCppuType());
     495                 :            :         }
     496                 :        264 :         break;
     497                 :            :         default:
     498                 :          0 :             bRet = false;
     499                 :            :     }
     500                 :       1052 :     return bRet;
     501                 :            : }
     502                 :        168 : bool SwFmtRuby::PutValue( const uno::Any& rVal,
     503                 :            :                             sal_uInt8 nMemberId  )
     504                 :            : {
     505                 :        168 :     bool bRet = true;
     506                 :        168 :     nMemberId &= ~CONVERT_TWIPS;
     507   [ +  +  +  -  :        168 :     switch( nMemberId )
                      - ]
     508                 :            :     {
     509                 :            :         case MID_RUBY_TEXT:
     510                 :            :         {
     511                 :        104 :             OUString sTmp;
     512                 :        104 :             bRet = rVal >>= sTmp;
     513         [ +  - ]:        104 :             sRubyTxt = sTmp;
     514                 :            :         }
     515                 :        104 :         break;
     516                 :            :          case MID_RUBY_ADJUST:
     517                 :            :         {
     518                 :         32 :             sal_Int16 nSet = 0;
     519                 :         32 :             rVal >>= nSet;
     520 [ +  - ][ +  - ]:         32 :             if(nSet >= 0 && nSet <= text::RubyAdjust_INDENT_BLOCK)
     521                 :         32 :                 nAdjustment = nSet;
     522                 :            :             else
     523                 :          0 :                 bRet = false;
     524                 :            :         }
     525                 :         32 :         break;
     526                 :            :         case MID_RUBY_ABOVE:
     527                 :            :         {
     528                 :         32 :             const uno::Type& rType = ::getBooleanCppuType();
     529 [ +  - ][ +  - ]:         32 :             if(rVal.hasValue() && rVal.getValueType() == rType)
                 [ +  - ]
     530                 :            :             {
     531                 :         32 :                 sal_Bool bAbove = *(sal_Bool*)rVal.getValue();
     532                 :         32 :                 nPosition = bAbove ? 0 : 1;
     533                 :            :             }
     534                 :            :         }
     535                 :         32 :         break;
     536                 :            :         case MID_RUBY_CHARSTYLE:
     537                 :            :         {
     538                 :          0 :             OUString sTmp;
     539                 :          0 :             bRet = rVal >>= sTmp;
     540         [ #  # ]:          0 :             if(bRet)
     541 [ #  # ][ #  # ]:          0 :                 sCharFmtName = SwStyleNameMapper::GetUIName(sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
         [ #  # ][ #  # ]
     542                 :            :         }
     543                 :          0 :         break;
     544                 :            :         default:
     545                 :          0 :             bRet = false;
     546                 :            :     }
     547                 :        168 :     return bRet;
     548                 :            : }
     549                 :            : 
     550                 :            : 
     551                 :            : /*************************************************************************
     552                 :            :  class SwFmtMeta
     553                 :            :  ************************************************************************/
     554                 :            : 
     555                 :        146 : SwFmtMeta * SwFmtMeta::CreatePoolDefault(const sal_uInt16 i_nWhich)
     556                 :            : {
     557         [ +  - ]:        146 :     return new SwFmtMeta(i_nWhich);
     558                 :            : }
     559                 :            : 
     560                 :        146 : SwFmtMeta::SwFmtMeta(const sal_uInt16 i_nWhich)
     561                 :            :     : SfxPoolItem( i_nWhich )
     562                 :            :     , m_pMeta()
     563         [ +  - ]:        146 :     , m_pTxtAttr( 0 )
     564                 :            : {
     565                 :            :    OSL_ENSURE((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich),
     566                 :            :             "ERROR: SwFmtMeta: invalid which id!");
     567                 :        146 : }
     568                 :            : 
     569                 :       1994 : SwFmtMeta::SwFmtMeta( ::boost::shared_ptr< ::sw::Meta > const & i_pMeta,
     570                 :            :                         const sal_uInt16 i_nWhich )
     571                 :            :     : SfxPoolItem( i_nWhich )
     572                 :            :     , m_pMeta( i_pMeta )
     573         [ +  - ]:       1994 :     , m_pTxtAttr( 0 )
     574                 :            : {
     575                 :            :    OSL_ENSURE((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich),
     576                 :            :             "ERROR: SwFmtMeta: invalid which id!");
     577                 :            :     OSL_ENSURE(m_pMeta, "SwFmtMeta: no Meta ?");
     578                 :            :     // DO NOT call m_pMeta->SetFmtMeta(this) here; only from SetTxtAttr!
     579                 :       1994 : }
     580                 :            : 
     581         [ +  - ]:       2140 : SwFmtMeta::~SwFmtMeta()
     582                 :            : {
     583 [ +  + ][ -  + ]:       2140 :     if (m_pMeta && (m_pMeta->GetFmtMeta() == this))
                 [ -  + ]
     584                 :            :     {
     585         [ #  # ]:          0 :         NotifyChangeTxtNode(0);
     586                 :          0 :         m_pMeta->SetFmtMeta(0);
     587                 :            :     }
     588         [ -  + ]:       4086 : }
     589                 :            : 
     590                 :        138 : int SwFmtMeta::operator==( const SfxPoolItem & i_rOther ) const
     591                 :            : {
     592                 :            :     OSL_ENSURE( SfxPoolItem::operator==( i_rOther ), "i just copied this assert" );
     593                 :        138 :     return SfxPoolItem::operator==( i_rOther )
     594 [ -  + ][ +  - ]:        138 :         && (m_pMeta == static_cast<SwFmtMeta const &>( i_rOther ).m_pMeta);
     595                 :            : }
     596                 :            : 
     597                 :       1800 : SfxPoolItem * SwFmtMeta::Clone( SfxItemPool * /*pPool*/ ) const
     598                 :            : {
     599                 :            :     // if this is indeed a copy, then DoCopy must be called later!
     600                 :            :     return (m_pMeta) // #i105148# pool default may be cloned also!
     601 [ +  - ][ +  - ]:       1800 :         ? new SwFmtMeta( m_pMeta, Which() ) : new SwFmtMeta( Which() );
                 [ #  # ]
     602                 :            : }
     603                 :            : 
     604                 :        388 : void SwFmtMeta::SetTxtAttr(SwTxtMeta * const i_pTxtAttr)
     605                 :            : {
     606                 :            :     OSL_ENSURE(!(m_pTxtAttr && i_pTxtAttr),
     607                 :            :         "SwFmtMeta::SetTxtAttr: already has text attribute?");
     608                 :            :     OSL_ENSURE(  m_pTxtAttr || i_pTxtAttr ,
     609                 :            :         "SwFmtMeta::SetTxtAttr: no attribute to remove?");
     610                 :        388 :     m_pTxtAttr = i_pTxtAttr;
     611                 :            :     OSL_ENSURE(m_pMeta, "inserted SwFmtMeta has no sw::Meta?");
     612                 :            :     // the sw::Meta must be able to find the current text attribute!
     613         [ +  - ]:        388 :     if (m_pMeta)
     614                 :            :     {
     615         [ +  + ]:        388 :         if (i_pTxtAttr)
     616                 :            :         {
     617                 :        194 :             m_pMeta->SetFmtMeta(this);
     618                 :            :         }
     619         [ +  - ]:        194 :         else if (m_pMeta->GetFmtMeta() == this)
     620                 :            :         {   // text attribute gone => de-register from text node!
     621                 :        194 :             NotifyChangeTxtNode(0);
     622                 :        194 :             m_pMeta->SetFmtMeta(0);
     623                 :            :         }
     624                 :            :     }
     625                 :        388 : }
     626                 :            : 
     627                 :        582 : void SwFmtMeta::NotifyChangeTxtNode(SwTxtNode *const pTxtNode)
     628                 :            : {
     629                 :            :     // N.B.: do not reset m_pTxtAttr here: see call in nodes.cxx,
     630                 :            :     // where the hint is not deleted!
     631                 :            :     OSL_ENSURE(m_pMeta, "SwFmtMeta::NotifyChangeTxtNode: no Meta?");
     632 [ +  - ][ +  - ]:        582 :     if (m_pMeta && (m_pMeta->GetFmtMeta() == this))
                 [ +  - ]
     633                 :            :     {   // do not call Modify, that would call SwXMeta::Modify!
     634                 :        582 :         m_pMeta->NotifyChangeTxtNode(pTxtNode);
     635                 :            :     }
     636                 :        582 : }
     637                 :            : 
     638                 :            : // this SwFmtMeta has been cloned and points at the same sw::Meta as the source
     639                 :            : // this method copies the sw::Meta
     640                 :          0 : void SwFmtMeta::DoCopy(::sw::MetaFieldManager & i_rTargetDocManager,
     641                 :            :         SwTxtNode & i_rTargetTxtNode)
     642                 :            : {
     643                 :            :     OSL_ENSURE(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?");
     644         [ #  # ]:          0 :     if (m_pMeta)
     645                 :            :     {
     646         [ #  # ]:          0 :         const ::boost::shared_ptr< ::sw::Meta> pOriginal( m_pMeta );
     647         [ #  # ]:          0 :         if (RES_TXTATR_META == Which())
     648                 :            :         {
     649 [ #  # ][ #  # ]:          0 :             m_pMeta.reset( new ::sw::Meta(this) );
                 [ #  # ]
     650                 :            :         }
     651                 :            :         else
     652                 :            :         {
     653                 :            :             ::sw::MetaField *const pMetaField(
     654                 :          0 :                 static_cast< ::sw::MetaField* >(pOriginal.get()));
     655                 :            :             m_pMeta = i_rTargetDocManager.makeMetaField( this,
     656 [ #  # ][ #  # ]:          0 :                 pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() );
                 [ #  # ]
     657                 :            :         }
     658                 :            :         // Meta must have a text node before calling RegisterAsCopyOf
     659         [ #  # ]:          0 :         m_pMeta->NotifyChangeTxtNode(& i_rTargetTxtNode);
     660                 :            :         // this cannot be done in Clone: a Clone is not necessarily a copy!
     661 [ #  # ][ #  # ]:          0 :         m_pMeta->RegisterAsCopyOf(*pOriginal);
     662                 :            :     }
     663                 :          0 : }
     664                 :            : 
     665                 :            : 
     666                 :            : namespace sw {
     667                 :            : 
     668                 :            : /*************************************************************************
     669                 :            :  class sw::Meta
     670                 :            :  ************************************************************************/
     671                 :            : 
     672                 :        194 : Meta::Meta(SwFmtMeta * const i_pFmt)
     673                 :            :     : ::sfx2::Metadatable()
     674                 :            :     , SwModify()
     675 [ +  - ][ +  - ]:        194 :     , m_pFmt( i_pFmt )
     676                 :            : {
     677                 :        194 : }
     678                 :            : 
     679 [ +  - ][ +  - ]:        194 : Meta::~Meta()
     680                 :            : {
     681         [ -  + ]:        336 : }
     682                 :            : 
     683                 :       1616 : SwTxtMeta * Meta::GetTxtAttr() const
     684                 :            : {
     685         [ +  + ]:       1616 :     return (m_pFmt) ? m_pFmt->GetTxtAttr() : 0;
     686                 :            : }
     687                 :            : 
     688                 :       4013 : SwTxtNode * Meta::GetTxtNode() const
     689                 :            : {
     690                 :       4013 :     return m_pTxtNode;
     691                 :            : }
     692                 :            : 
     693                 :        582 : void Meta::NotifyChangeTxtNodeImpl()
     694                 :            : {
     695 [ +  + ][ +  - ]:        582 :     if (m_pTxtNode && (GetRegisteredIn() != m_pTxtNode))
                 [ +  + ]
     696                 :            :     {
     697                 :        194 :         m_pTxtNode->Add(this);
     698                 :            :     }
     699 [ +  - ][ +  + ]:        388 :     else if (!m_pTxtNode && GetRegisteredIn())
                 [ +  + ]
     700                 :            :     {
     701                 :        194 :         GetRegisteredInNonConst()->Remove(this);
     702                 :            :     }
     703                 :        582 : }
     704                 :            : 
     705                 :        582 : void Meta::NotifyChangeTxtNode(SwTxtNode *const pTxtNode)
     706                 :            : {
     707                 :        582 :     m_pTxtNode = pTxtNode;
     708                 :        582 :     NotifyChangeTxtNodeImpl();
     709         [ +  + ]:        582 :     if (!pTxtNode) // text node gone? invalidate UNO object!
     710                 :            :     {
     711                 :            :         SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT,
     712         [ +  - ]:        388 :             &static_cast<SwModify&>(*this) ); // cast to base class!
     713 [ +  - ][ +  - ]:        388 :         this->Modify(&aMsgHint, &aMsgHint);
     714                 :            :     }
     715                 :        582 : }
     716                 :            : 
     717                 :            : // SwClient
     718                 :       4268 : void Meta::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew )
     719                 :            : {
     720                 :       4268 :     NotifyClients(pOld, pNew);
     721 [ +  + ][ +  + ]:       4268 :     if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
                 [ +  + ]
     722                 :            :     {   // invalidate cached uno object
     723         [ +  - ]:        388 :         SetXMeta(uno::Reference<rdf::XMetadatable>(0));
     724                 :            :     }
     725                 :       4268 : }
     726                 :            : 
     727                 :            : // sfx2::Metadatable
     728                 :        188 : ::sfx2::IXmlIdRegistry& Meta::GetRegistry()
     729                 :            : {
     730                 :        188 :     SwTxtNode * const pTxtNode( GetTxtNode() );
     731                 :            :     // GetRegistry may only be called on a meta that is actually in the
     732                 :            :     // document, which means it has a pointer to its text node
     733                 :            :     OSL_ENSURE(pTxtNode, "ERROR: GetRegistry: no text node?");
     734         [ -  + ]:        188 :     if (!pTxtNode)
     735         [ #  # ]:          0 :         throw uno::RuntimeException();
     736                 :        188 :     return pTxtNode->GetRegistry();
     737                 :            : }
     738                 :            : 
     739                 :        846 : bool Meta::IsInClipboard() const
     740                 :            : {
     741                 :        846 :     const SwTxtNode * const pTxtNode( GetTxtNode() );
     742                 :            : // no text node: in UNDO  OSL_ENSURE(pTxtNode, "IsInClipboard: no text node?");
     743         [ +  - ]:        846 :     return (pTxtNode) ? pTxtNode->IsInClipboard() : false;
     744                 :            : }
     745                 :            : 
     746                 :        866 : bool Meta::IsInUndo() const
     747                 :            : {
     748                 :        866 :     const SwTxtNode * const pTxtNode( GetTxtNode() );
     749                 :            : // no text node: in UNDO  OSL_ENSURE(pTxtNode, "IsInUndo: no text node?");
     750         [ +  - ]:        866 :     return (pTxtNode) ? pTxtNode->IsInUndo() : true;
     751                 :            : }
     752                 :            : 
     753                 :        228 : bool Meta::IsInContent() const
     754                 :            : {
     755                 :        228 :     const SwTxtNode * const pTxtNode( GetTxtNode() );
     756                 :            :     OSL_ENSURE(pTxtNode, "IsInContent: no text node?");
     757         [ +  - ]:        228 :     return (pTxtNode) ? pTxtNode->IsInContent() : true;
     758                 :            : }
     759                 :            : 
     760                 :            : ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable >
     761                 :        132 : Meta::MakeUnoObject()
     762                 :            : {
     763 [ +  - ][ +  - ]:        132 :     return SwXMeta::CreateXMeta(*this);
     764                 :            : }
     765                 :            : 
     766                 :            : /*************************************************************************
     767                 :            :  class sw::MetaField
     768                 :            :  ************************************************************************/
     769                 :            : 
     770                 :         52 : MetaField::MetaField(SwFmtMeta * const i_pFmt,
     771                 :            :             const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
     772                 :            :     : Meta(i_pFmt)
     773                 :            :     , m_nNumberFormat( nNumberFormat )
     774                 :         52 :     , m_bIsFixedLanguage( bIsFixedLanguage )
     775                 :            : {
     776                 :         52 : }
     777                 :            : 
     778                 :         80 : void MetaField::GetPrefixAndSuffix(
     779                 :            :         ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix)
     780                 :            : {
     781                 :            :     try
     782                 :            :     {
     783         [ +  - ]:         80 :         const uno::Reference<rdf::XMetadatable> xMetaField( MakeUnoObject() );
     784                 :            :         OSL_ENSURE(dynamic_cast<SwXMetaField*>(xMetaField.get()),
     785                 :            :                 "GetPrefixAndSuffix: no SwXMetaField?");
     786         [ +  - ]:         80 :         if (xMetaField.is())
     787                 :            :         {
     788                 :         80 :             SwTxtNode * const pTxtNode( GetTxtNode() );
     789                 :         80 :             SwDocShell const * const pShell(pTxtNode->GetDoc()->GetDocShell());
     790                 :            :             const uno::Reference<frame::XModel> xModel(
     791 [ +  - ][ #  # ]:         80 :                 (pShell) ? pShell->GetModel() : 0,  uno::UNO_SET_THROW);
         [ +  - ][ +  - ]
     792         [ +  - ]:         80 :             getPrefixAndSuffix(xModel, xMetaField, o_pPrefix, o_pSuffix);
     793         [ #  # ]:         80 :         }
     794                 :            :     }
     795                 :          0 :     catch (const uno::Exception&)
     796                 :            :     {
     797                 :            :         OSL_FAIL("exception?");
     798                 :            :     }
     799                 :         80 : }
     800                 :            : 
     801                 :         48 : sal_uInt32 MetaField::GetNumberFormat(::rtl::OUString const & rContent) const
     802                 :            : {
     803                 :            :     //TODO: this probably lacks treatment for some special cases
     804                 :         48 :     sal_uInt32 nNumberFormat( m_nNumberFormat );
     805                 :         48 :     SwTxtNode * const pTxtNode( GetTxtNode() );
     806         [ +  - ]:         48 :     if (pTxtNode)
     807                 :            :     {
     808                 :            :         SvNumberFormatter *const pNumberFormatter(
     809         [ +  - ]:         48 :                 pTxtNode->GetDoc()->GetNumberFormatter() );
     810                 :            :         double number;
     811                 :            :         (void) pNumberFormatter->IsNumberFormat(
     812 [ +  - ][ +  - ]:         48 :                 rContent, nNumberFormat, number );
                 [ +  - ]
     813                 :            :     }
     814                 :         48 :     return nNumberFormat;
     815                 :            : }
     816                 :            : 
     817                 :         10 : void MetaField::SetNumberFormat(sal_uInt32 nNumberFormat)
     818                 :            : {
     819                 :            :     // effectively, the member is only a default:
     820                 :            :     // GetNumberFormat checks if the text actually conforms
     821                 :         10 :     m_nNumberFormat = nNumberFormat;
     822                 :         10 : }
     823                 :            : 
     824                 :            : 
     825                 :            : /*************************************************************************
     826                 :            :  class sw::MetaFieldManager
     827                 :            :  ************************************************************************/
     828                 :            : 
     829                 :            : 
     830         [ +  - ]:       1549 : MetaFieldManager::MetaFieldManager()
     831                 :            : {
     832                 :       1549 : }
     833                 :            : 
     834                 :            : ::boost::shared_ptr<MetaField>
     835                 :         52 : MetaFieldManager::makeMetaField(SwFmtMeta * const i_pFmt,
     836                 :            :         const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage)
     837                 :            : {
     838                 :            :     const ::boost::shared_ptr<MetaField> pMetaField(
     839 [ +  - ][ +  - ]:         52 :         new MetaField(i_pFmt, nNumberFormat, bIsFixedLanguage) );
     840 [ +  - ][ +  - ]:         52 :     m_MetaFields.push_back(pMetaField);
                 [ +  - ]
     841                 :         52 :     return pMetaField;
     842                 :            : }
     843                 :            : 
     844                 :            : struct IsInUndo
     845                 :            : {
     846                 :         20 :     bool operator()(::boost::weak_ptr<MetaField> const & pMetaField) {
     847         [ +  - ]:         20 :         return pMetaField.lock()->IsInUndo();
     848                 :            :     }
     849                 :            : };
     850                 :            : 
     851                 :            : struct MakeUnoObject
     852                 :            : {
     853                 :            :     uno::Reference<text::XTextField>
     854                 :         20 :     operator()(::boost::weak_ptr<MetaField> const & pMetaField) {
     855                 :            :         return uno::Reference<text::XTextField>(
     856 [ +  - ][ +  - ]:         20 :                 pMetaField.lock()->MakeUnoObject(), uno::UNO_QUERY);
     857                 :            :     }
     858                 :            : };
     859                 :            : 
     860                 :            : ::std::vector< uno::Reference<text::XTextField> >
     861                 :        556 : MetaFieldManager::getMetaFields()
     862                 :            : {
     863                 :            :     // erase deleted fields
     864                 :            :     const MetaFieldList_t::iterator iter(
     865                 :            :         ::std::remove_if(m_MetaFields.begin(), m_MetaFields.end(),
     866 [ +  - ][ +  - ]:        556 :             ::boost::bind(&::boost::weak_ptr<MetaField>::expired, _1)));
     867         [ +  - ]:        556 :     m_MetaFields.erase(iter, m_MetaFields.end());
     868                 :            :     // filter out fields in UNDO
     869         [ +  - ]:        556 :     MetaFieldList_t filtered(m_MetaFields.size());
     870                 :            :     const MetaFieldList_t::iterator iter2(
     871                 :            :     ::std::remove_copy_if(m_MetaFields.begin(), m_MetaFields.end(),
     872         [ +  - ]:        556 :         filtered.begin(), IsInUndo()));
     873         [ +  - ]:        556 :     filtered.erase(iter2, filtered.end());
     874                 :            :     // create uno objects
     875         [ +  - ]:        556 :     ::std::vector< uno::Reference<text::XTextField> > ret(filtered.size());
     876                 :            :     ::std::transform(filtered.begin(), filtered.end(), ret.begin(),
     877         [ +  - ]:        556 :             MakeUnoObject());
     878                 :        556 :     return ret;
     879                 :            : }
     880                 :            : 
     881 [ +  - ][ +  - ]:        219 : } // namespace sw
     882                 :            : 
     883                 :            : 
     884                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10