LCOV - code coverage report
Current view: top level - svx/source/items - pageitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 51 132 38.6 %
Date: 2012-08-25 Functions: 13 22 59.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 26 184 14.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                 :            : #include <tools/stream.hxx>
      30                 :            : 
      31                 :            : 
      32                 :            : #include <svx/pageitem.hxx>
      33                 :            : #include <editeng/itemtype.hxx>
      34                 :            : #include <svx/unomid.hxx>
      35                 :            : #include <com/sun/star/style/PageStyleLayout.hpp>
      36                 :            : #include <com/sun/star/style/BreakType.hpp>
      37                 :            : #include <svl/itemset.hxx>
      38                 :            : #include <svx/svxitems.hrc>
      39                 :            : #include <svx/dialmgr.hxx>
      40                 :            : 
      41                 :            : using namespace ::rtl;
      42                 :            : using namespace ::com::sun::star;
      43                 :            : 
      44                 :            : // STATIC DATA -----------------------------------------------------------
      45                 :            : 
      46 [ -  + ][ -  + ]:       5443 : TYPEINIT1_FACTORY( SvxPageItem, SfxPoolItem , new  SvxPageItem(0));
                 [ #  # ]
      47                 :            : 
      48                 :            : /*--------------------------------------------------------------------
      49                 :            :     Beschreibung: Konstruktor
      50                 :            :  --------------------------------------------------------------------*/
      51                 :            : 
      52                 :       6753 : SvxPageItem::SvxPageItem( const sal_uInt16 nId ) : SfxPoolItem( nId ),
      53                 :            : 
      54                 :            :     eNumType    ( SVX_ARABIC ),
      55                 :            :     bLandscape  ( sal_False ),
      56         [ +  - ]:       6753 :     eUse        ( SVX_PAGE_ALL )
      57                 :            : {
      58                 :       6753 : }
      59                 :            : 
      60                 :            : /*--------------------------------------------------------------------
      61                 :            :     Beschreibung: Copy-Konstruktor
      62                 :            :  --------------------------------------------------------------------*/
      63                 :            : 
      64                 :      11059 : SvxPageItem::SvxPageItem( const SvxPageItem& rItem )
      65         [ +  - ]:      11059 :     : SfxPoolItem( rItem )
      66                 :            : {
      67                 :      11059 :     eNumType    = rItem.eNumType;
      68                 :      11059 :     bLandscape  = rItem.bLandscape;
      69                 :      11059 :     eUse        = rItem.eUse;
      70                 :      11059 : }
      71                 :            : 
      72                 :            : /*--------------------------------------------------------------------
      73                 :            :     Beschreibung: Clonen
      74                 :            :  --------------------------------------------------------------------*/
      75                 :            : 
      76                 :      10919 : SfxPoolItem* SvxPageItem::Clone( SfxItemPool * ) const
      77                 :            : {
      78         [ +  - ]:      10919 :     return new SvxPageItem( *this );
      79                 :            : }
      80                 :            : 
      81                 :            : /*--------------------------------------------------------------------
      82                 :            :     Beschreibung: Abfrage auf Gleichheit
      83                 :            :  --------------------------------------------------------------------*/
      84                 :            : 
      85                 :       1079 : int SvxPageItem::operator==( const SfxPoolItem& rAttr ) const
      86                 :            : {
      87                 :            :     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
      88                 :       1079 :     const SvxPageItem& rItem = (SvxPageItem&)rAttr;
      89                 :            :     return ( eNumType   == rItem.eNumType   &&
      90                 :            :              bLandscape == rItem.bLandscape &&
      91 [ +  - ][ +  + ]:       1079 :              eUse       == rItem.eUse );
                 [ +  + ]
      92                 :            : }
      93                 :            : 
      94                 :          0 : inline XubString GetUsageText( const sal_uInt16 eU )
      95                 :            : {
      96         [ #  # ]:          0 :     if ( eU & SVX_PAGE_LEFT )
      97 [ #  # ][ #  # ]:          0 :         return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT);
      98         [ #  # ]:          0 :     if ( eU & SVX_PAGE_RIGHT )
      99 [ #  # ][ #  # ]:          0 :         return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT);
     100         [ #  # ]:          0 :     if ( eU & SVX_PAGE_ALL )
     101 [ #  # ][ #  # ]:          0 :         return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL);
     102         [ #  # ]:          0 :     if ( eU & SVX_PAGE_MIRROR )
     103 [ #  # ][ #  # ]:          0 :         return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR);
     104                 :          0 :     return String();
     105                 :            : }
     106                 :            : 
     107                 :            : //------------------------------------------------------------------------
     108                 :            : 
     109                 :          0 : SfxItemPresentation SvxPageItem::GetPresentation
     110                 :            : (
     111                 :            :     SfxItemPresentation ePres,
     112                 :            :     SfxMapUnit          /*eCoreUnit*/,
     113                 :            :     SfxMapUnit          /*ePresUnit*/,
     114                 :            :     XubString&          rText, const IntlWrapper *
     115                 :            : )   const
     116                 :            : {
     117                 :          0 :     rText.Erase();
     118                 :            : 
     119   [ #  #  #  # ]:          0 :     switch ( ePres )
     120                 :            :     {
     121                 :            :         case SFX_ITEM_PRESENTATION_NONE:
     122                 :          0 :             return SFX_ITEM_PRESENTATION_NONE;
     123                 :            :         case SFX_ITEM_PRESENTATION_NAMELESS:
     124                 :            :         {
     125         [ #  # ]:          0 :             if ( aDescName.Len() )
     126                 :            :             {
     127         [ #  # ]:          0 :                 rText = aDescName;
     128         [ #  # ]:          0 :                 rText += cpDelim;
     129                 :            :             }
     130                 :            :             DBG_ASSERT( eNumType <= SVX_NUMBER_NONE, "enum overflow" );
     131 [ #  # ][ #  # ]:          0 :             rText += SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN + eNumType);
                 [ #  # ]
     132         [ #  # ]:          0 :             rText += cpDelim;
     133         [ #  # ]:          0 :             if ( bLandscape )
     134 [ #  # ][ #  # ]:          0 :                 rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE);
                 [ #  # ]
     135                 :            :             else
     136 [ #  # ][ #  # ]:          0 :                 rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE);
                 [ #  # ]
     137         [ #  # ]:          0 :             String aUsageText = GetUsageText( eUse );
     138         [ #  # ]:          0 :             if (aUsageText.Len())
     139                 :            :             {
     140         [ #  # ]:          0 :                 rText += cpDelim;
     141         [ #  # ]:          0 :                 rText += aUsageText;
     142                 :            :             }
     143         [ #  # ]:          0 :             return SFX_ITEM_PRESENTATION_NAMELESS;
     144                 :            :         }
     145                 :            :         case SFX_ITEM_PRESENTATION_COMPLETE:
     146                 :            :         {
     147 [ #  # ][ #  # ]:          0 :             rText += SVX_RESSTR(RID_SVXITEMS_PAGE_COMPLETE);
                 [ #  # ]
     148         [ #  # ]:          0 :             if ( aDescName.Len() )
     149                 :            :             {
     150         [ #  # ]:          0 :                 rText += aDescName;
     151         [ #  # ]:          0 :                 rText += cpDelim;
     152                 :            :             }
     153                 :            :             DBG_ASSERT( eNumType <= SVX_NUMBER_NONE, "enum overflow" );
     154 [ #  # ][ #  # ]:          0 :             rText += SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN + eNumType);
                 [ #  # ]
     155         [ #  # ]:          0 :             rText += cpDelim;
     156         [ #  # ]:          0 :             if ( bLandscape )
     157 [ #  # ][ #  # ]:          0 :                 rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE);
                 [ #  # ]
     158                 :            :             else
     159 [ #  # ][ #  # ]:          0 :                 rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE);
                 [ #  # ]
     160         [ #  # ]:          0 :             String aUsageText = GetUsageText( eUse );
     161         [ #  # ]:          0 :             if (aUsageText.Len())
     162                 :            :             {
     163         [ #  # ]:          0 :                 rText += cpDelim;
     164         [ #  # ]:          0 :                 rText += aUsageText;
     165                 :            :             }
     166         [ #  # ]:          0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
     167                 :            :         }
     168                 :            :         default: ;//prevent warning
     169                 :            :     }
     170                 :          0 :     return SFX_ITEM_PRESENTATION_NONE;
     171                 :            : }
     172                 :            : 
     173                 :            : //------------------------------------------------------------------------
     174                 :        105 : bool SvxPageItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     175                 :            : {
     176                 :            : //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     177                 :        105 :     nMemberId &= ~CONVERT_TWIPS;
     178   [ +  +  +  - ]:        105 :     switch( nMemberId )
     179                 :            :     {
     180                 :            :         case MID_PAGE_NUMTYPE:
     181                 :            :         {
     182                 :            :             //! die Konstanten sind nicht mehr in den IDLs ?!?
     183         [ +  - ]:         32 :             rVal <<= (sal_Int16)( eNumType );
     184                 :            :         }
     185                 :         32 :         break;
     186                 :            :         case MID_PAGE_ORIENTATION:
     187                 :            :             //Landscape= sal_True
     188                 :         41 :             rVal = Bool2Any(bLandscape);
     189                 :         41 :         break;
     190                 :            :         case MID_PAGE_LAYOUT     :
     191                 :            :         {
     192                 :            :             style::PageStyleLayout eRet;
     193   [ -  -  -  +  :         32 :             switch(eUse & 0x0f)
                      - ]
     194                 :            :             {
     195                 :          0 :                 case SVX_PAGE_LEFT  : eRet = style::PageStyleLayout_LEFT;      break;
     196                 :          0 :                 case SVX_PAGE_RIGHT : eRet = style::PageStyleLayout_RIGHT;     break;
     197                 :          0 :                 case SVX_PAGE_ALL   : eRet = style::PageStyleLayout_ALL;       break;
     198                 :         32 :                 case SVX_PAGE_MIRROR: eRet = style::PageStyleLayout_MIRRORED; break;
     199                 :            :                 default:
     200                 :            :                     OSL_FAIL("was fuer ein Layout ist das?");
     201                 :          0 :                     return sal_False;
     202                 :            :             }
     203         [ +  - ]:         32 :             rVal <<= eRet;
     204                 :            :         }
     205                 :         32 :         break;
     206                 :            :     }
     207                 :            : 
     208                 :        105 :     return true;
     209                 :            : }
     210                 :            : //------------------------------------------------------------------------
     211                 :       1046 : bool SvxPageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     212                 :            : {
     213   [ +  +  +  - ]:       1046 :     switch( nMemberId )
     214                 :            :     {
     215                 :            :         case MID_PAGE_NUMTYPE:
     216                 :            :         {
     217                 :        183 :             sal_Int32 nValue = 0;
     218         [ -  + ]:        183 :             if(!(rVal >>= nValue))
     219                 :          0 :                 return false;
     220                 :            : 
     221                 :        183 :             eNumType = (SvxNumType)nValue;
     222                 :            :         }
     223                 :        183 :         break;
     224                 :            :         case MID_PAGE_ORIENTATION:
     225                 :        752 :             bLandscape = Any2Bool(rVal);
     226                 :        752 :         break;
     227                 :            :         case MID_PAGE_LAYOUT     :
     228                 :            :         {
     229                 :            :             style::PageStyleLayout eLayout;
     230 [ +  - ][ -  + ]:        111 :             if(!(rVal >>= eLayout))
     231                 :            :             {
     232                 :          0 :                 sal_Int32 nValue = 0;
     233         [ #  # ]:          0 :                 if(!(rVal >>= nValue))
     234                 :          0 :                     return sal_False;
     235                 :          0 :                 eLayout = (style::PageStyleLayout)nValue;
     236                 :            :             }
     237                 :        111 :             eUse &= 0xfff0;
     238   [ +  +  -  +  :        111 :             switch( eLayout )
                      - ]
     239                 :            :             {
     240                 :         10 :                 case style::PageStyleLayout_LEFT     : eUse |= SVX_PAGE_LEFT ; break;
     241                 :         10 :                 case style::PageStyleLayout_RIGHT   : eUse |= SVX_PAGE_RIGHT; break;
     242                 :          0 :                 case style::PageStyleLayout_ALL     : eUse |= SVX_PAGE_ALL  ; break;
     243                 :         91 :                 case style::PageStyleLayout_MIRRORED: eUse |= SVX_PAGE_MIRROR;break;
     244                 :            :                 default: ;//prevent warning
     245                 :            :             }
     246                 :            :         }
     247                 :        111 :         break;
     248                 :            :     }
     249                 :       1046 :     return true;
     250                 :            : }
     251                 :            : 
     252                 :            : //------------------------------------------------------------------------
     253                 :            : 
     254                 :          0 : SfxPoolItem* SvxPageItem::Create( SvStream& rStream, sal_uInt16 ) const
     255                 :            : {
     256                 :            :     sal_uInt8 eType;
     257                 :            :     sal_Bool bLand;
     258                 :            :     sal_uInt16 nUse;
     259                 :            : 
     260                 :            :     // UNICODE: rStream >> sStr;
     261 [ #  # ][ #  # ]:          0 :     XubString sStr = rStream.ReadUniOrByteString( rStream.GetStreamCharSet() );
     262                 :            : 
     263         [ #  # ]:          0 :     rStream >> eType;
     264         [ #  # ]:          0 :     rStream >> bLand;
     265         [ #  # ]:          0 :     rStream >> nUse;
     266                 :            : 
     267 [ #  # ][ #  # ]:          0 :     SvxPageItem* pPage = new SvxPageItem( Which() );
     268         [ #  # ]:          0 :     pPage->SetDescName( sStr );
     269                 :          0 :     pPage->SetNumType( (SvxNumType)eType );
     270                 :          0 :     pPage->SetLandscape( bLand );
     271                 :          0 :     pPage->SetPageUsage( nUse );
     272         [ #  # ]:          0 :     return pPage;
     273                 :            : }
     274                 :            : 
     275                 :            : //------------------------------------------------------------------------
     276                 :            : 
     277                 :          0 : SvStream& SvxPageItem::Store( SvStream &rStrm, sal_uInt16 /*nItemVersion*/ ) const
     278                 :            : {
     279                 :            :     // UNICODE: rStrm << aDescName;
     280         [ #  # ]:          0 :     rStrm.WriteUniOrByteString(aDescName, rStrm.GetStreamCharSet());
     281                 :            : 
     282                 :          0 :     rStrm << (sal_uInt8)eNumType << bLandscape << eUse;
     283                 :          0 :     return rStrm;
     284                 :            : }
     285                 :            : 
     286                 :            : /*--------------------------------------------------------------------
     287                 :            :     Beschreibung:   HeaderFooterSet
     288                 :            :  --------------------------------------------------------------------*/
     289                 :            : 
     290                 :       3008 : SvxSetItem::SvxSetItem( const sal_uInt16 nId, const SfxItemSet& rSet ) :
     291                 :            : 
     292                 :       3008 :     SfxSetItem( nId, rSet )
     293                 :            : {
     294                 :       3008 : }
     295                 :            : 
     296                 :      20584 : SvxSetItem::SvxSetItem( const SvxSetItem& rItem ) :
     297                 :            : 
     298                 :      20584 :     SfxSetItem( rItem )
     299                 :            : {
     300                 :      20584 : }
     301                 :            : 
     302                 :          0 : SvxSetItem::SvxSetItem( const sal_uInt16 nId, SfxItemSet* _pSet ) :
     303                 :            : 
     304                 :          0 :     SfxSetItem( nId, _pSet )
     305                 :            : {
     306                 :          0 : }
     307                 :            : 
     308                 :      10371 : SfxPoolItem* SvxSetItem::Clone( SfxItemPool * ) const
     309                 :            : {
     310         [ +  - ]:      10371 :     return new SvxSetItem(*this);
     311                 :            : }
     312                 :            : 
     313                 :            : //------------------------------------------------------------------------
     314                 :            : 
     315                 :          0 : SfxItemPresentation SvxSetItem::GetPresentation
     316                 :            : (
     317                 :            :     SfxItemPresentation /*ePres*/,
     318                 :            :     SfxMapUnit          /*eCoreUnit*/,
     319                 :            :     SfxMapUnit          /*ePresUnit*/,
     320                 :            :     XubString&          rText, const IntlWrapper *
     321                 :            : )   const
     322                 :            : {
     323                 :          0 :     rText.Erase();
     324                 :          0 :     return SFX_ITEM_PRESENTATION_NONE;
     325                 :            : }
     326                 :            : 
     327                 :          0 : SfxPoolItem* SvxSetItem::Create(SvStream &rStrm, sal_uInt16 /*nVersion*/) const
     328                 :            : {
     329                 :          0 :     SfxItemSet* _pSet = new SfxItemSet( *GetItemSet().GetPool(),
     330         [ #  # ]:          0 :                                        GetItemSet().GetRanges() );
     331                 :            : 
     332                 :          0 :     _pSet->Load( rStrm );
     333                 :            : 
     334         [ #  # ]:          0 :     return new SvxSetItem( Which(), *_pSet );
     335                 :            : }
     336                 :            : 
     337                 :          0 : SvStream& SvxSetItem::Store(SvStream &rStrm, sal_uInt16 nItemVersion) const
     338                 :            : {
     339                 :          0 :     GetItemSet().Store( rStrm, nItemVersion );
     340                 :            : 
     341                 :          0 :     return rStrm;
     342                 :            : }
     343                 :            : 
     344                 :            : 
     345                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10