LCOV - code coverage report
Current view: top level - svl/source/items - szitem.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 58 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          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 <osl/diagnose.h>
      25             : #include <tools/stream.hxx>
      26             : 
      27             : #include <svl/poolitem.hxx>
      28             : #include <svl/memberid.hrc>
      29             : 
      30           0 : TYPEINIT1_AUTOFACTORY(SfxSizeItem, SfxPoolItem);
      31             : 
      32             : 
      33             : 
      34           0 : SfxSizeItem::SfxSizeItem()
      35             : {
      36           0 : }
      37             : 
      38             : 
      39             : 
      40           0 : SfxSizeItem::SfxSizeItem( sal_uInt16 nW, const Size& rVal ) :
      41             :     SfxPoolItem( nW ),
      42           0 :     aVal( rVal )
      43             : {
      44           0 : }
      45             : 
      46             : 
      47             : 
      48           0 : SfxSizeItem::SfxSizeItem( const SfxSizeItem& rItem ) :
      49             :     SfxPoolItem( rItem ),
      50           0 :     aVal( rItem.aVal )
      51             : {
      52           0 : }
      53             : 
      54             : 
      55             : 
      56           0 : bool SfxSizeItem::GetPresentation
      57             : (
      58             :     SfxItemPresentation     /*ePresentation*/,
      59             :     SfxMapUnit              /*eCoreMetric*/,
      60             :     SfxMapUnit              /*ePresentationMetric*/,
      61             :     OUString&               rText,
      62             :     const IntlWrapper *
      63             : )   const
      64             : {
      65           0 :     rText = OUString::number(aVal.Width()) + ", " + OUString::number(aVal.Height()) + ", ";
      66           0 :     return true;
      67             : }
      68             : 
      69             : 
      70             : 
      71           0 : bool SfxSizeItem::operator==( const SfxPoolItem& rItem ) const
      72             : {
      73             :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
      74           0 :     return static_cast<const SfxSizeItem&>(rItem).aVal == aVal;
      75             : }
      76             : 
      77             : 
      78             : 
      79           0 : SfxPoolItem* SfxSizeItem::Clone(SfxItemPool *) const
      80             : {
      81           0 :     return new SfxSizeItem( *this );
      82             : }
      83             : 
      84             : 
      85             : 
      86           0 : SfxPoolItem* SfxSizeItem::Create(SvStream &rStream, sal_uInt16 ) const
      87             : {
      88           0 :     Size aStr;
      89           0 :     ReadPair( rStream, aStr );
      90           0 :     return new SfxSizeItem(Which(), aStr);
      91             : }
      92             : 
      93             : 
      94             : 
      95           0 : SvStream& SfxSizeItem::Store(SvStream &rStream, sal_uInt16 ) const
      96             : {
      97           0 :     WritePair( rStream, aVal );
      98           0 :     return rStream;
      99             : }
     100             : 
     101             : 
     102           0 : bool  SfxSizeItem::QueryValue( com::sun::star::uno::Any& rVal,
     103             :                                sal_uInt8 nMemberId ) const
     104             : {
     105           0 :     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     106           0 :     nMemberId &= ~CONVERT_TWIPS;
     107             : 
     108           0 :     Size aTmp(aVal);
     109           0 :     if( bConvert )
     110             :     {
     111           0 :         aTmp.Height() = ( aTmp.Height() * 127 + 36) / 72;
     112           0 :         aTmp.Width() = ( aTmp.Width() * 127 + 36) / 72;
     113             :     }
     114             : 
     115           0 :     switch ( nMemberId )
     116             :     {
     117             :         case 0:
     118             :         {
     119           0 :             rVal <<= com::sun::star::awt::Size( aTmp.getWidth(), aTmp.getHeight() );
     120           0 :             break;
     121             :         }
     122             :         case MID_WIDTH:
     123           0 :             rVal <<= aTmp.getWidth(); break;
     124             :         case MID_HEIGHT:
     125           0 :             rVal <<= aTmp.getHeight(); break;
     126           0 :     default: OSL_FAIL("Wrong MemberId!"); return false;
     127             :     }
     128             : 
     129           0 :     return true;
     130             : }
     131             : 
     132             : 
     133           0 : bool SfxSizeItem::PutValue( const com::sun::star::uno::Any& rVal,
     134             :                             sal_uInt8 nMemberId )
     135             : {
     136           0 :     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     137           0 :     nMemberId &= ~CONVERT_TWIPS;
     138             : 
     139           0 :     bool bRet = false;
     140           0 :     com::sun::star::awt::Size aValue;
     141           0 :     if ( !nMemberId )
     142           0 :         bRet = ( rVal >>= aValue );
     143             :     else
     144             :     {
     145           0 :         sal_Int32 nVal = 0;
     146           0 :         bRet = ( rVal >>= nVal );
     147           0 :         if ( nMemberId == MID_WIDTH )
     148             :         {
     149           0 :             aValue.Width = nVal;
     150           0 :             aValue.Height = aVal.Height();
     151             :         }
     152             :         else
     153             :         {
     154           0 :             aValue.Height = nVal;
     155           0 :             aValue.Width = aVal.Width();
     156             :         }
     157             :     }
     158             : 
     159           0 :     if ( bRet )
     160             :     {
     161           0 :         Size aTmp( aValue.Width, aValue.Height );
     162           0 :         if( bConvert )
     163             :         {
     164           0 :             aTmp.Height() = ( aTmp.Height() * 72 + 63) / 127;
     165           0 :             aTmp.Width() = ( aTmp.Width() * 72 + 63) / 127;
     166             :         }
     167             : 
     168           0 :         aVal = aTmp;
     169             :     }
     170             : 
     171           0 :     return bRet;
     172             : }
     173             : 
     174             : 
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11