LCOV - code coverage report
Current view: top level - sw/source/ui/utlui - uiitems.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 69 144 47.9 %
Date: 2012-08-25 Functions: 8 27 29.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 49 149 32.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 <editeng/itemtype.hxx>
      30                 :            : #include <unosett.hxx>
      31                 :            : 
      32                 :            : #include "swtypes.hxx"
      33                 :            : #include "cmdid.h"
      34                 :            : #include "uiitems.hxx"
      35                 :            : 
      36                 :            : #include "utlui.hrc"
      37                 :            : #include "attrdesc.hrc"
      38                 :            : #include <unomid.h>
      39                 :            : #include <numrule.hxx>
      40                 :            : 
      41                 :            : using namespace ::com::sun::star;
      42                 :            : using namespace ::com::sun::star::uno;
      43                 :            : 
      44                 :       2822 : SwPageFtnInfoItem::SwPageFtnInfoItem( const sal_uInt16 nId, SwPageFtnInfo& rInfo) :
      45                 :            :     SfxPoolItem( nId ),
      46         [ +  - ]:       2822 :     aFtnInfo(rInfo)
      47                 :            : {
      48                 :       2822 : }
      49                 :            : 
      50                 :            : 
      51                 :       6080 : SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem& rItem ) :
      52                 :            :     SfxPoolItem( rItem ),
      53         [ +  - ]:       6080 :     aFtnInfo(rItem.GetPageFtnInfo())
      54                 :            : {
      55                 :       6080 : }
      56                 :            : 
      57                 :            : 
      58                 :       8902 :  SwPageFtnInfoItem::~SwPageFtnInfoItem()
      59                 :            : {
      60         [ -  + ]:      14982 : }
      61                 :            : 
      62                 :            : 
      63                 :       6080 : SfxPoolItem*  SwPageFtnInfoItem::Clone( SfxItemPool * /*pPool*/ ) const
      64                 :            : {
      65         [ +  - ]:       6080 :     return new SwPageFtnInfoItem( *this );
      66                 :            : }
      67                 :            : 
      68                 :            : 
      69                 :        952 : int  SwPageFtnInfoItem::operator==( const SfxPoolItem& rAttr ) const
      70                 :            : {
      71                 :            :     OSL_ENSURE( Which() == rAttr.Which(), "keine gleichen Attribute" );
      72                 :        952 :     return ( aFtnInfo == ((SwPageFtnInfoItem&)rAttr).GetPageFtnInfo());
      73                 :            : }
      74                 :            : 
      75                 :            : 
      76                 :          0 : SfxItemPresentation  SwPageFtnInfoItem::GetPresentation
      77                 :            : (
      78                 :            :     SfxItemPresentation ePres,
      79                 :            :     SfxMapUnit          eCoreUnit,
      80                 :            :     SfxMapUnit          ePresUnit,
      81                 :            :     String&             rText,
      82                 :            :     const IntlWrapper*    pIntl
      83                 :            : )   const
      84                 :            : {
      85      [ #  #  # ]:          0 :     switch ( ePres )
      86                 :            :     {
      87                 :            :         case SFX_ITEM_PRESENTATION_NONE:
      88                 :          0 :             rText.Erase();
      89                 :          0 :             return SFX_ITEM_PRESENTATION_NONE;
      90                 :            :         case SFX_ITEM_PRESENTATION_NAMELESS:
      91                 :            :         case SFX_ITEM_PRESENTATION_COMPLETE:
      92                 :            :         {
      93                 :          0 :             sal_uInt16 nHght = (sal_uInt16) GetPageFtnInfo().GetHeight();
      94         [ #  # ]:          0 :             if ( nHght )
      95                 :            :             {
      96 [ #  # ][ #  # ]:          0 :                 rText = SW_RESSTR( STR_MAX_FTN_HEIGHT );
      97                 :          0 :                 rText += ' ';
      98         [ #  # ]:          0 :                 rText += ::GetMetricText( nHght, eCoreUnit, ePresUnit, pIntl );
      99         [ #  # ]:          0 :                 rText += ::GetSvxString( ::GetMetricId( ePresUnit ) );
     100                 :            :             }
     101                 :          0 :             return ePres;
     102                 :            :         }
     103                 :            :         default:; //prevent warning
     104                 :            :     }
     105                 :          0 :     return SFX_ITEM_PRESENTATION_NONE;
     106                 :            : }
     107                 :            : 
     108                 :        224 : bool SwPageFtnInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
     109                 :            : {
     110                 :        224 :     bool bRet = true;
     111   [ +  +  +  +  :        224 :     switch(nMemberId & ~CONVERT_TWIPS)
             +  +  +  +  
                      - ]
     112                 :            :     {
     113 [ +  - ][ +  - ]:         28 :         case MID_FTN_HEIGHT        :     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetHeight());break;
     114         [ +  - ]:         28 :         case MID_LINE_WEIGHT       :     rVal <<= (sal_Int16)TWIP_TO_MM100_UNSIGNED(aFtnInfo.GetLineWidth());break;
     115         [ +  - ]:         28 :         case MID_LINE_COLOR        :     rVal <<= (sal_Int32)aFtnInfo.GetLineColor().GetColor();break;
     116                 :            :         case MID_LINE_RELWIDTH     :
     117                 :            :         {
     118         [ +  - ]:         28 :             Fraction aTmp( 100, 1 );
     119         [ +  - ]:         28 :             aTmp *= aFtnInfo.GetWidth();
     120 [ +  - ][ +  - ]:         28 :             rVal <<= (sal_Int8)(long)aTmp;
     121                 :            :         }
     122                 :         28 :         break;
     123         [ +  - ]:         28 :         case MID_LINE_ADJUST       :     rVal <<= (sal_Int16)aFtnInfo.GetAdj();break;//text::HorizontalAdjust
     124 [ +  - ][ +  - ]:         28 :         case MID_LINE_TEXT_DIST    :     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetTopDist());break;
     125 [ +  - ][ +  - ]:         28 :         case MID_LINE_FOOTNOTE_DIST:     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetBottomDist());break;
     126                 :            :         case MID_FTN_LINE_STYLE    :
     127                 :            :         {
     128   [ +  +  -  - ]:         28 :             switch ( aFtnInfo.GetLineStyle( ) )
     129                 :            :             {
     130                 :            :                 default:
     131         [ +  - ]:          6 :                 case table::BorderLineStyle::NONE : rVal <<= sal_Int8(0); break;
     132         [ +  - ]:         22 :                 case table::BorderLineStyle::SOLID: rVal <<= sal_Int8(1); break;
     133         [ #  # ]:          0 :                 case table::BorderLineStyle::DOTTED: rVal <<= sal_Int8(2); break;
     134         [ #  # ]:          0 :                 case table::BorderLineStyle::DASHED: rVal <<= sal_Int8(3); break;
     135                 :            :             }
     136                 :         28 :             break;
     137                 :            :         }
     138                 :            :         default:
     139                 :          0 :             bRet = false;
     140                 :            :     }
     141                 :        224 :     return bRet;
     142                 :            : }
     143                 :            : 
     144                 :        952 : bool SwPageFtnInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId)
     145                 :            : {
     146                 :        952 :     sal_Int32 nSet32 = 0;
     147                 :        952 :     bool bRet = true;
     148   [ +  +  +  +  :        952 :     switch(nMemberId  & ~CONVERT_TWIPS)
                +  +  - ]
     149                 :            :     {
     150                 :            :         case MID_LINE_COLOR        :
     151                 :        119 :             rVal >>= nSet32;
     152                 :        119 :             aFtnInfo.SetLineColor(nSet32);
     153                 :        119 :         break;
     154                 :            :         case MID_FTN_HEIGHT:
     155                 :            :         case MID_LINE_TEXT_DIST    :
     156                 :            :         case MID_LINE_FOOTNOTE_DIST:
     157                 :        357 :                 rVal >>= nSet32;
     158         [ -  + ]:        357 :                 if(nSet32 < 0)
     159                 :          0 :                     bRet = false;
     160                 :            :                 else
     161                 :            :                 {
     162         [ +  - ]:        357 :                     nSet32 = MM100_TO_TWIP(nSet32);
     163   [ +  +  +  - ]:        357 :                     switch(nMemberId & ~CONVERT_TWIPS)
     164                 :            :                     {
     165                 :        119 :                         case MID_FTN_HEIGHT:            aFtnInfo.SetHeight(nSet32);    break;
     166                 :        119 :                         case MID_LINE_TEXT_DIST:        aFtnInfo.SetTopDist(nSet32);break;
     167                 :        119 :                         case MID_LINE_FOOTNOTE_DIST:    aFtnInfo.SetBottomDist(nSet32);break;
     168                 :            :                     }
     169                 :            :                 }
     170                 :        357 :         break;
     171                 :            :         case MID_LINE_WEIGHT       :
     172                 :            :         {
     173                 :        119 :             sal_Int16 nSet = 0;
     174                 :        119 :             rVal >>= nSet;
     175         [ +  - ]:        119 :             if(nSet >= 0)
     176         [ +  - ]:        119 :                 aFtnInfo.SetLineWidth(MM100_TO_TWIP(nSet));
     177                 :            :             else
     178                 :          0 :                 bRet = false;
     179                 :            :         }
     180                 :        119 :         break;
     181                 :            :         case MID_LINE_RELWIDTH     :
     182                 :            :         {
     183                 :        119 :             sal_Int8 nSet = 0;
     184                 :        119 :             rVal >>= nSet;
     185         [ -  + ]:        119 :             if(nSet < 0)
     186                 :          0 :                 bRet = false;
     187                 :            :             else
     188 [ +  - ][ +  - ]:        119 :                 aFtnInfo.SetWidth(Fraction(nSet, 100));
     189                 :            :         }
     190                 :        119 :         break;
     191                 :            :         case MID_LINE_ADJUST       :
     192                 :            :         {
     193                 :        119 :             sal_Int16 nSet = 0;
     194                 :        119 :             rVal >>= nSet;
     195 [ +  - ][ +  - ]:        119 :             if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust
     196                 :        119 :                 aFtnInfo.SetAdj((SwFtnAdj)nSet);
     197                 :            :             else
     198                 :        119 :                 bRet = false;
     199                 :            :         }
     200                 :            :         case MID_FTN_LINE_STYLE:
     201                 :            :         {
     202                 :        238 :             ::editeng::SvxBorderStyle eStyle = table::BorderLineStyle::NONE;
     203                 :        238 :             sal_Int8 nSet = 0;
     204                 :        238 :             rVal >>= nSet;
     205   [ +  -  -  + ]:        238 :             switch ( nSet )
     206                 :            :             {
     207                 :         61 :                 case 1: eStyle = table::BorderLineStyle::SOLID; break;
     208                 :          0 :                 case 2: eStyle = table::BorderLineStyle::DOTTED; break;
     209                 :          0 :                 case 3: eStyle = table::BorderLineStyle::DASHED; break;
     210                 :        177 :                 default: break;
     211                 :            :             }
     212                 :        238 :             aFtnInfo.SetLineStyle( eStyle );
     213                 :            :         }
     214                 :        238 :         break;
     215                 :            :         default:
     216                 :          0 :             bRet = false;
     217                 :            :     }
     218                 :        952 :     return bRet;
     219                 :            : }
     220                 :            : 
     221                 :          0 : SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) :
     222                 :            :     SfxPoolItem( nId ),
     223                 :          0 :     pMisc(pPtr)
     224                 :            : {
     225                 :          0 : }
     226                 :            : 
     227                 :            : /*--------------------------------------------------------------------
     228                 :            :     Beschreibung: Copy-Konstruktor
     229                 :            :  --------------------------------------------------------------------*/
     230                 :            : 
     231                 :            : 
     232                 :          0 : SwPtrItem::SwPtrItem( const SwPtrItem& rItem ) : SfxPoolItem( rItem )
     233                 :            : {
     234                 :          0 :     pMisc = rItem.pMisc;
     235                 :          0 : }
     236                 :            : 
     237                 :            : /*--------------------------------------------------------------------
     238                 :            :     Beschreibung: Clonen
     239                 :            :  --------------------------------------------------------------------*/
     240                 :            : 
     241                 :            : 
     242                 :          0 : SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const
     243                 :            : {
     244         [ #  # ]:          0 :     return new SwPtrItem( *this );
     245                 :            : }
     246                 :            : 
     247                 :          0 : int SwPtrItem::operator==( const SfxPoolItem& rAttr ) const
     248                 :            : {
     249                 :            :     OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
     250                 :          0 :     const SwPtrItem& rItem = (SwPtrItem&)rAttr;
     251                 :          0 :     return ( pMisc == rItem.pMisc );
     252                 :            : }
     253                 :            : 
     254                 :            : 
     255                 :            : /*--------------------------------------------------------------
     256                 :            :  SwUINumRuleItem fuer die NumTabPages der FormatNumRule/Stylisten
     257                 :            : ---------------------------------------------------------------*/
     258                 :          0 : SwUINumRuleItem::SwUINumRuleItem( const SwNumRule& rRul, const sal_uInt16 nId )
     259 [ #  # ][ #  # ]:          0 :     : SfxPoolItem( nId ), pRule( new SwNumRule( rRul ) )
     260                 :            : {
     261                 :          0 : }
     262                 :            : 
     263                 :          0 : SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem )
     264                 :            :     : SfxPoolItem( rItem ),
     265 [ #  # ][ #  # ]:          0 :     pRule( new SwNumRule( *rItem.pRule ))
     266                 :            : {
     267                 :          0 : }
     268                 :            : 
     269                 :          0 :  SwUINumRuleItem::~SwUINumRuleItem()
     270                 :            : {
     271 [ #  # ][ #  # ]:          0 :     delete pRule;
     272         [ #  # ]:          0 : }
     273                 :            : 
     274                 :            : 
     275                 :          0 : SfxPoolItem*  SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const
     276                 :            : {
     277         [ #  # ]:          0 :     return new SwUINumRuleItem( *this );
     278                 :            : }
     279                 :            : 
     280                 :          0 : int  SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const
     281                 :            : {
     282                 :            :     OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
     283                 :          0 :     return *pRule == *((SwUINumRuleItem&)rAttr).pRule;
     284                 :            : }
     285                 :            : 
     286                 :          0 : bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
     287                 :            : {
     288 [ #  # ][ #  # ]:          0 :     uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*pRule);
                 [ #  # ]
     289         [ #  # ]:          0 :     rVal.setValue(&xRules, ::getCppuType((uno::Reference< container::XIndexReplace>*)0));
     290                 :          0 :     return true;
     291                 :            : }
     292                 :          0 : bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
     293                 :            : {
     294                 :          0 :     uno::Reference< container::XIndexReplace> xRulesRef;
     295 [ #  # ][ #  # ]:          0 :     if(rVal >>= xRulesRef)
     296                 :            :     {
     297         [ #  # ]:          0 :         uno::Reference< lang::XUnoTunnel > xTunnel(xRulesRef, uno::UNO_QUERY);
     298                 :          0 :         SwXNumberingRules* pSwXRules = xTunnel.is() ? reinterpret_cast<SwXNumberingRules*>(
     299 [ #  # ][ #  # ]:          0 :                     xTunnel->getSomething(SwXNumberingRules::getUnoTunnelId())) : 0;
         [ #  # ][ #  # ]
     300         [ #  # ]:          0 :         if(pSwXRules)
     301                 :            :         {
     302         [ #  # ]:          0 :             *pRule = *pSwXRules->GetNumRule();
     303                 :          0 :         }
     304                 :            :     }
     305                 :          0 :     return true;
     306                 :            : }
     307                 :            : 
     308                 :          0 : SwBackgroundDestinationItem::SwBackgroundDestinationItem(sal_uInt16  _nWhich, sal_uInt16 nValue) :
     309                 :          0 :     SfxUInt16Item(_nWhich, nValue)
     310                 :            : {
     311                 :          0 : }
     312                 :            : 
     313                 :          0 : SfxPoolItem*     SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) const
     314                 :            : {
     315         [ #  # ]:          0 :     return new SwBackgroundDestinationItem(Which(), GetValue());
     316                 :            : }
     317                 :            : 
     318                 :            : 
     319                 :          0 : SwPaMItem::SwPaMItem( const sal_uInt16 nId, SwPaM* pPaM ) :
     320                 :            :     SfxPoolItem( nId ),
     321                 :          0 :     m_pPaM(pPaM)
     322                 :            : {
     323                 :          0 : }
     324                 :            : 
     325                 :            : 
     326                 :          0 : SwPaMItem::SwPaMItem( const SwPaMItem& rItem ) : SfxPoolItem( rItem )
     327                 :            : {
     328                 :          0 :     m_pPaM = rItem.m_pPaM;
     329                 :          0 : }
     330                 :            : 
     331                 :            : 
     332                 :          0 : SfxPoolItem* SwPaMItem::Clone( SfxItemPool * /*pPool*/ ) const
     333                 :            : {
     334         [ #  # ]:          0 :     return new SwPaMItem( *this );
     335                 :            : }
     336                 :            : 
     337                 :          0 : int SwPaMItem::operator==( const SfxPoolItem& rAttr ) const
     338                 :            : {
     339                 :            :     OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
     340                 :          0 :     const SwPaMItem& rItem = (SwPaMItem&)rAttr;
     341                 :          0 :     return ( m_pPaM == rItem.m_pPaM );
     342                 :            : }
     343                 :            : 
     344                 :            : 
     345                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10