LCOV - code coverage report
Current view: top level - sw/source/core/para - paratr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 49 103 47.6 %
Date: 2012-08-25 Functions: 26 37 70.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 128 23.4 %

           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 <swtypes.hxx>
      32                 :            : #include "unomid.h"
      33                 :            : #include <com/sun/star/style/LineSpacingMode.hpp>
      34                 :            : #include <com/sun/star/style/ParagraphAdjust.hpp>
      35                 :            : #include <com/sun/star/style/DropCapFormat.hpp>
      36                 :            : #include <com/sun/star/style/LineSpacing.hpp>
      37                 :            : #include <com/sun/star/text/RelOrientation.hpp>
      38                 :            : #include <com/sun/star/text/VertOrientation.hpp>
      39                 :            : #include <com/sun/star/text/HorizontalAdjust.hpp>
      40                 :            : #include <com/sun/star/text/DocumentStatistic.hpp>
      41                 :            : #include <com/sun/star/text/HoriOrientation.hpp>
      42                 :            : #include <com/sun/star/text/HoriOrientationFormat.hpp>
      43                 :            : #include <com/sun/star/text/NotePrintMode.hpp>
      44                 :            : #include <com/sun/star/text/SizeType.hpp>
      45                 :            : #include <com/sun/star/text/VertOrientationFormat.hpp>
      46                 :            : #include <com/sun/star/text/WrapTextMode.hpp>
      47                 :            : #include <unostyle.hxx>
      48                 :            : #include <SwStyleNameMapper.hxx>
      49                 :            : #include "paratr.hxx"
      50                 :            : #include "charfmt.hxx"
      51                 :            : #include "cmdid.h"
      52                 :            : 
      53                 :            : using namespace ::com::sun::star;
      54                 :            : 
      55 [ -  + ][ -  + ]:       4666 : TYPEINIT2_AUTOFACTORY( SwFmtDrop, SfxPoolItem, SwClient);
         [ -  + ][ #  # ]
      56 [ -  + ][ -  + ]:       5613 : TYPEINIT1_AUTOFACTORY( SwRegisterItem, SfxBoolItem);
                 [ #  # ]
      57 [ -  + ][ -  + ]:      48540 : TYPEINIT1_AUTOFACTORY( SwNumRuleItem, SfxStringItem);
                 [ #  # ]
      58 [ -  + ][ -  + ]:       4593 : TYPEINIT1_AUTOFACTORY( SwParaConnectBorderItem, SfxBoolItem);
                 [ #  # ]
      59                 :            : 
      60                 :            : /*************************************************************************
      61                 :            : |*    Beschreibung      Methoden von SwFmtDrop
      62                 :            : *************************************************************************/
      63                 :            : 
      64                 :            : 
      65                 :            : 
      66                 :       1531 : SwFmtDrop::SwFmtDrop()
      67                 :            :     : SfxPoolItem( RES_PARATR_DROP ),
      68                 :            :     SwClient( 0 ),
      69                 :            :     pDefinedIn( 0 ),
      70                 :            :     nDistance( 0 ),
      71                 :            :     nReadFmt( USHRT_MAX ),
      72                 :            :     nLines( 0 ),
      73                 :            :     nChars( 0 ),
      74         [ +  - ]:       1531 :     bWholeWord( sal_False )
      75                 :            : {
      76                 :       1531 : }
      77                 :            : 
      78                 :            : 
      79                 :            : 
      80                 :      28362 : SwFmtDrop::SwFmtDrop( const SwFmtDrop &rCpy )
      81                 :            :     : SfxPoolItem( RES_PARATR_DROP ),
      82                 :            :     SwClient( rCpy.GetRegisteredInNonConst() ),
      83                 :            :     pDefinedIn( 0 ),
      84                 :      28362 :     nDistance( rCpy.GetDistance() ),
      85                 :            :     nReadFmt( rCpy.nReadFmt ),
      86                 :      28362 :     nLines( rCpy.GetLines() ),
      87                 :      28362 :     nChars( rCpy.GetChars() ),
      88         [ +  - ]:      56724 :     bWholeWord( rCpy.GetWholeWord() )
      89                 :            : {
      90                 :      28362 : }
      91                 :            : 
      92                 :            : 
      93                 :            : 
      94         [ +  - ]:      29893 : SwFmtDrop::~SwFmtDrop()
      95                 :            : {
      96         [ -  + ]:      58328 : }
      97                 :            : 
      98                 :            : 
      99                 :            : 
     100                 :          0 : void SwFmtDrop::SetCharFmt( SwCharFmt *pNew )
     101                 :            : {
     102                 :            :     //Ummelden
     103         [ #  # ]:          0 :     if ( GetRegisteredIn() )
     104                 :          0 :         GetRegisteredInNonConst()->Remove( this );
     105         [ #  # ]:          0 :     if(pNew)
     106                 :          0 :         pNew->Add( this );
     107                 :          0 :     nReadFmt = USHRT_MAX;
     108                 :          0 : }
     109                 :            : 
     110                 :            : 
     111                 :            : 
     112                 :          0 : void SwFmtDrop::Modify( const SfxPoolItem*, const SfxPoolItem * )
     113                 :            : {
     114         [ #  # ]:          0 :     if( pDefinedIn )
     115                 :            :     {
     116         [ #  # ]:          0 :         if( !pDefinedIn->ISA( SwFmt ))
     117                 :          0 :             pDefinedIn->ModifyNotification( this, this );
     118   [ #  #  #  # ]:          0 :         else if( pDefinedIn->GetDepends() &&
                 [ #  # ]
     119                 :          0 :                 !pDefinedIn->IsModifyLocked() )
     120                 :            :         {
     121                 :            :             // selbst den Abhaengigen vom Format bescheid sagen. Das
     122                 :            :             // Format selbst wuerde es nicht weitergeben, weil es ueber
     123                 :            :             // die Abpruefung nicht hinauskommt.
     124                 :          0 :             pDefinedIn->ModifyBroadcast( this, this );
     125                 :            :         }
     126                 :            :     }
     127                 :          0 : }
     128                 :            : 
     129                 :          0 : sal_Bool SwFmtDrop::GetInfo( SfxPoolItem& ) const
     130                 :            : {
     131                 :          0 :     return sal_True;    // weiter
     132                 :            : }
     133                 :            : 
     134                 :          0 : int SwFmtDrop::operator==( const SfxPoolItem& rAttr ) const
     135                 :            : {
     136                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
     137                 :          0 :     return ( nLines == ((SwFmtDrop&)rAttr).GetLines() &&
     138                 :          0 :              nChars == ((SwFmtDrop&)rAttr).GetChars() &&
     139                 :          0 :              nDistance ==  ((SwFmtDrop&)rAttr).GetDistance() &&
     140                 :          0 :              bWholeWord == ((SwFmtDrop&)rAttr).GetWholeWord() &&
     141                 :          0 :              GetCharFmt() == ((SwFmtDrop&)rAttr).GetCharFmt() &&
     142 [ #  # ][ #  #  :          0 :              pDefinedIn == ((SwFmtDrop&)rAttr).pDefinedIn );
          #  #  #  #  #  
                #  #  # ]
     143                 :            : }
     144                 :            : 
     145                 :      28362 : SfxPoolItem* SwFmtDrop::Clone( SfxItemPool* ) const
     146                 :            : {
     147         [ +  - ]:      28362 :     return new SwFmtDrop( *this );
     148                 :            : }
     149                 :            : 
     150                 :         18 : bool SwFmtDrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     151                 :            : {
     152   [ -  -  -  +  :         18 :     switch(nMemberId&~CONVERT_TWIPS)
                +  +  - ]
     153                 :            :     {
     154         [ #  # ]:          0 :         case MID_DROPCAP_LINES : rVal <<= (sal_Int16)nLines; break;
     155         [ #  # ]:          0 :         case MID_DROPCAP_COUNT : rVal <<= (sal_Int16)nChars; break;
     156         [ #  # ]:          0 :         case MID_DROPCAP_DISTANCE : rVal <<= (sal_Int16) TWIP_TO_MM100_UNSIGNED(nDistance); break;
     157                 :            :         case MID_DROPCAP_FORMAT:
     158                 :            :         {
     159                 :          6 :              style::DropCapFormat aDrop;
     160                 :          6 :             aDrop.Lines = nLines   ;
     161                 :          6 :             aDrop.Count = nChars   ;
     162                 :          6 :             aDrop.Distance  = TWIP_TO_MM100_UNSIGNED(nDistance);
     163         [ +  - ]:          6 :             rVal.setValue(&aDrop, ::getCppuType((const style::DropCapFormat*)0));
     164                 :            :         }
     165                 :          6 :         break;
     166                 :            :         case MID_DROPCAP_WHOLE_WORD:
     167                 :          6 :             rVal.setValue(&bWholeWord, ::getBooleanCppuType());
     168                 :          6 :         break;
     169                 :            :         case MID_DROPCAP_CHAR_STYLE_NAME :
     170                 :            :         {
     171                 :          6 :             rtl::OUString sName;
     172         [ -  + ]:          6 :             if(GetCharFmt())
     173                 :            :                 sName = SwStyleNameMapper::GetProgName(
     174 [ #  # ][ #  # ]:          0 :                         GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
     175         [ +  - ]:          6 :             rVal <<= sName;
     176                 :            :         }
     177                 :          6 :         break;
     178                 :            :     }
     179                 :         18 :     return true;
     180                 :            : }
     181                 :            : 
     182                 :          0 : bool SwFmtDrop::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     183                 :            : {
     184   [ #  #  #  #  :          0 :     switch(nMemberId&~CONVERT_TWIPS)
                #  #  # ]
     185                 :            :     {
     186                 :            :         case MID_DROPCAP_LINES :
     187                 :            :         {
     188                 :          0 :             sal_Int8 nTemp = 0;
     189                 :          0 :             rVal >>= nTemp;
     190 [ #  # ][ #  # ]:          0 :             if(nTemp >=1 && nTemp < 0x7f)
     191                 :          0 :                 nLines = (sal_uInt8)nTemp;
     192                 :            :         }
     193                 :          0 :         break;
     194                 :            :         case MID_DROPCAP_COUNT :
     195                 :            :         {
     196                 :          0 :             sal_Int16 nTemp = 0;
     197                 :          0 :             rVal >>= nTemp;
     198 [ #  # ][ #  # ]:          0 :             if(nTemp >=1 && nTemp < 0x7f)
     199                 :          0 :                 nChars = (sal_uInt8)nTemp;
     200                 :            :         }
     201                 :          0 :         break;
     202                 :            :         case MID_DROPCAP_DISTANCE :
     203                 :            :         {
     204                 :          0 :             sal_Int16 nVal = 0;
     205         [ #  # ]:          0 :             if ( rVal >>= nVal )
     206         [ #  # ]:          0 :                 nDistance = (sal_Int16) MM100_TO_TWIP((sal_Int32)nVal);
     207                 :            :             else
     208                 :          0 :                 return false;
     209                 :            :             break;
     210                 :            :         }
     211                 :            :         case MID_DROPCAP_FORMAT:
     212                 :            :         {
     213         [ #  # ]:          0 :             if(rVal.getValueType()  == ::getCppuType((const style::DropCapFormat*)0))
     214                 :            :             {
     215                 :          0 :                 const style::DropCapFormat* pDrop = (const style::DropCapFormat*)rVal.getValue();
     216                 :          0 :                 nLines      = pDrop->Lines;
     217                 :          0 :                 nChars      = pDrop->Count;
     218         [ #  # ]:          0 :                 nDistance   = MM100_TO_TWIP(pDrop->Distance);
     219                 :            :             }
     220                 :            :             else {
     221                 :            :             }
     222                 :            :         }
     223                 :          0 :         break;
     224                 :            :         case MID_DROPCAP_WHOLE_WORD:
     225                 :          0 :             bWholeWord = *(sal_Bool*)rVal.getValue();
     226                 :          0 :         break;
     227                 :            :         case MID_DROPCAP_CHAR_STYLE_NAME :
     228                 :            :             OSL_FAIL("char format cannot be set in PutValue()!");
     229                 :          0 :         break;
     230                 :            :     }
     231                 :          0 :     return true;
     232                 :            : }
     233                 :            : 
     234                 :            : // class SwRegisterItem -------------------------------------------------
     235                 :            : 
     236                 :            : 
     237                 :       4950 : SfxPoolItem* SwRegisterItem::Clone( SfxItemPool * ) const
     238                 :            : {
     239         [ +  - ]:       4950 :     return new SwRegisterItem( *this );
     240                 :            : }
     241                 :            : 
     242                 :            : // class SwNumRuleItem -------------------------------------------------
     243                 :       1032 : SfxPoolItem* SwNumRuleItem::Clone( SfxItemPool * ) const
     244                 :            : {
     245         [ +  - ]:       1032 :     return new SwNumRuleItem( *this );
     246                 :            : }
     247                 :       9990 : int SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const
     248                 :            : {
     249                 :            :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
     250                 :            : 
     251                 :       9990 :     return GetValue() == ((SwNumRuleItem&)rAttr).GetValue();
     252                 :            : }
     253                 :            : 
     254                 :        189 : bool    SwNumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
     255                 :            : {
     256 [ +  - ][ +  - ]:        189 :     rtl::OUString sRet = SwStyleNameMapper::GetProgName(GetValue(), nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
     257         [ +  - ]:        189 :     rVal <<= sRet;
     258                 :        189 :     return true;
     259                 :            : }
     260                 :            : 
     261                 :         45 : bool    SwNumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 )
     262                 :            : {
     263                 :         45 :     rtl::OUString uName;
     264                 :         45 :     rVal >>= uName;
     265 [ +  - ][ +  - ]:         45 :     SetValue(SwStyleNameMapper::GetUIName(uName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE));
         [ +  - ][ +  - ]
     266                 :         45 :     return true;
     267                 :            : }
     268                 :            : 
     269                 :          2 : SfxPoolItem* SwParaConnectBorderItem::Clone( SfxItemPool * ) const
     270                 :            : {
     271         [ +  - ]:          2 :     return new SwParaConnectBorderItem( *this );
     272                 :            : }
     273                 :            : 
     274                 :            : 
     275                 :            : 
     276                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10