LCOV - code coverage report
Current view: top level - svl/source/items - szitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 61 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 40 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include <svl/szitem.hxx>
      22                 :            : #include <com/sun/star/uno/Any.hxx>
      23                 :            : #include <com/sun/star/awt/Size.hpp>
      24                 :            : #include <tools/stream.hxx>
      25                 :            : #include <tools/gen.hxx>
      26                 :            : 
      27                 :            : #include <svl/poolitem.hxx>
      28                 :            : #include <svl/memberid.hrc>
      29                 :            : 
      30                 :            : // STATIC DATA -----------------------------------------------------------
      31                 :            : 
      32                 :            : DBG_NAME(SfxSizeItem)
      33                 :            : 
      34                 :            : // -----------------------------------------------------------------------
      35                 :            : 
      36 [ #  # ][ #  # ]:          0 : TYPEINIT1_AUTOFACTORY(SfxSizeItem, SfxPoolItem);
                 [ #  # ]
      37                 :            : 
      38                 :            : // -----------------------------------------------------------------------
      39                 :            : 
      40                 :          0 : SfxSizeItem::SfxSizeItem()
      41                 :            : {
      42                 :            :     DBG_CTOR(SfxSizeItem, 0);
      43                 :          0 : }
      44                 :            : 
      45                 :            : // -----------------------------------------------------------------------
      46                 :            : 
      47                 :          0 : SfxSizeItem::SfxSizeItem( sal_uInt16 nW, const Size& rVal ) :
      48                 :            :     SfxPoolItem( nW ),
      49                 :          0 :     aVal( rVal )
      50                 :            : {
      51                 :            :     DBG_CTOR(SfxSizeItem, 0);
      52                 :          0 : }
      53                 :            : 
      54                 :            : // -----------------------------------------------------------------------
      55                 :            : 
      56                 :          0 : SfxSizeItem::SfxSizeItem( const SfxSizeItem& rItem ) :
      57                 :            :     SfxPoolItem( rItem ),
      58                 :          0 :     aVal( rItem.aVal )
      59                 :            : {
      60                 :            :     DBG_CTOR(SfxSizeItem, 0);
      61                 :          0 : }
      62                 :            : 
      63                 :            : // -----------------------------------------------------------------------
      64                 :            : 
      65                 :          0 : SfxItemPresentation SfxSizeItem::GetPresentation
      66                 :            : (
      67                 :            :     SfxItemPresentation     /*ePresentation*/,
      68                 :            :     SfxMapUnit              /*eCoreMetric*/,
      69                 :            :     SfxMapUnit              /*ePresentationMetric*/,
      70                 :            :     XubString&              rText,
      71                 :            :     const IntlWrapper *
      72                 :            : )   const
      73                 :            : {
      74                 :            :     DBG_CHKTHIS(SfxSizeItem, 0);
      75         [ #  # ]:          0 :     rText = UniString::CreateFromInt32(aVal.Width());
      76                 :          0 :     rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
      77         [ #  # ]:          0 :     rText += UniString::CreateFromInt32(aVal.Height());
      78                 :          0 :     rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
      79                 :          0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
      80                 :            : }
      81                 :            : 
      82                 :            : // -----------------------------------------------------------------------
      83                 :            : 
      84                 :          0 : int SfxSizeItem::operator==( const SfxPoolItem& rItem ) const
      85                 :            : {
      86                 :            :     DBG_CHKTHIS(SfxSizeItem, 0);
      87                 :            :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
      88                 :          0 :     return ((SfxSizeItem&)rItem).aVal == aVal;
      89                 :            : }
      90                 :            : 
      91                 :            : // -----------------------------------------------------------------------
      92                 :            : 
      93                 :          0 : SfxPoolItem* SfxSizeItem::Clone(SfxItemPool *) const
      94                 :            : {
      95                 :            :     DBG_CHKTHIS(SfxSizeItem, 0);
      96         [ #  # ]:          0 :     return new SfxSizeItem( *this );
      97                 :            : }
      98                 :            : 
      99                 :            : // -----------------------------------------------------------------------
     100                 :            : 
     101                 :          0 : SfxPoolItem* SfxSizeItem::Create(SvStream &rStream, sal_uInt16 ) const
     102                 :            : {
     103                 :            :     DBG_CHKTHIS(SfxSizeItem, 0);
     104                 :          0 :     Size aStr;
     105         [ #  # ]:          0 :     rStream >> aStr;
     106 [ #  # ][ #  # ]:          0 :     return new SfxSizeItem(Which(), aStr);
     107                 :            : }
     108                 :            : 
     109                 :            : // -----------------------------------------------------------------------
     110                 :            : 
     111                 :          0 : SvStream& SfxSizeItem::Store(SvStream &rStream, sal_uInt16 ) const
     112                 :            : {
     113                 :            :     DBG_CHKTHIS(SfxSizeItem, 0);
     114                 :          0 :     rStream << aVal;
     115                 :          0 :     return rStream;
     116                 :            : }
     117                 :            : 
     118                 :            : // -----------------------------------------------------------------------
     119                 :          0 : bool  SfxSizeItem::QueryValue( com::sun::star::uno::Any& rVal,
     120                 :            :                                sal_uInt8 nMemberId ) const
     121                 :            : {
     122                 :          0 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     123                 :          0 :     nMemberId &= ~CONVERT_TWIPS;
     124                 :            : 
     125                 :          0 :     Size aTmp(aVal);
     126         [ #  # ]:          0 :     if( bConvert )
     127                 :            :     {
     128                 :          0 :         aTmp.Height() = ( aTmp.Height() * 127 + 36) / 72;
     129                 :          0 :         aTmp.Width() = ( aTmp.Width() * 127 + 36) / 72;
     130                 :            :     }
     131                 :            : 
     132   [ #  #  #  # ]:          0 :     switch ( nMemberId )
     133                 :            :     {
     134                 :            :         case 0:
     135                 :            :         {
     136         [ #  # ]:          0 :             rVal <<= com::sun::star::awt::Size( aTmp.getWidth(), aTmp.getHeight() );
     137                 :          0 :             break;
     138                 :            :         }
     139                 :            :         case MID_WIDTH:
     140         [ #  # ]:          0 :             rVal <<= aTmp.getWidth(); break;
     141                 :            :         case MID_HEIGHT:
     142         [ #  # ]:          0 :             rVal <<= aTmp.getHeight(); break;
     143                 :          0 :     default: OSL_FAIL("Wrong MemberId!"); return false;
     144                 :            :     }
     145                 :            : 
     146                 :          0 :     return true;
     147                 :            : }
     148                 :            : 
     149                 :            : // -----------------------------------------------------------------------
     150                 :          0 : bool SfxSizeItem::PutValue( const com::sun::star::uno::Any& rVal,
     151                 :            :                             sal_uInt8 nMemberId )
     152                 :            : {
     153                 :          0 :     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     154                 :          0 :     nMemberId &= ~CONVERT_TWIPS;
     155                 :            : 
     156                 :          0 :     bool bRet = false;
     157                 :          0 :     com::sun::star::awt::Size aValue;
     158         [ #  # ]:          0 :     if ( !nMemberId )
     159         [ #  # ]:          0 :         bRet = ( rVal >>= aValue );
     160                 :            :     else
     161                 :            :     {
     162                 :          0 :         sal_Int32 nVal = 0;
     163                 :          0 :         bRet = ( rVal >>= nVal );
     164         [ #  # ]:          0 :         if ( nMemberId == MID_WIDTH )
     165                 :            :         {
     166                 :          0 :             aValue.Width = nVal;
     167                 :          0 :             aValue.Height = aVal.Height();
     168                 :            :         }
     169                 :            :         else
     170                 :            :         {
     171                 :          0 :             aValue.Height = nVal;
     172                 :          0 :             aValue.Width = aVal.Width();
     173                 :            :         }
     174                 :            :     }
     175                 :            : 
     176         [ #  # ]:          0 :     if ( bRet )
     177                 :            :     {
     178                 :          0 :         Size aTmp( aValue.Width, aValue.Height );
     179         [ #  # ]:          0 :         if( bConvert )
     180                 :            :         {
     181                 :          0 :             aTmp.Height() = ( aTmp.Height() * 72 + 63) / 127;
     182                 :          0 :             aTmp.Width() = ( aTmp.Width() * 72 + 63) / 127;
     183                 :            :         }
     184                 :            : 
     185                 :          0 :         aVal = aTmp;
     186                 :            :     }
     187                 :            : 
     188                 :          0 :     return bRet;
     189                 :            : }
     190                 :            : 
     191                 :            : 
     192                 :            : 
     193                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10