LCOV - code coverage report
Current view: top level - svl/source/items - ptitem.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 34 57 59.6 %
Date: 2014-11-03 Functions: 12 15 80.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/ptitem.hxx>
      22             : #include <com/sun/star/uno/Any.hxx>
      23             : #include <com/sun/star/awt/Point.hpp>
      24             : #include <tools/stream.hxx>
      25             : #include <tools/mapunit.hxx>
      26             : 
      27             : #include <svl/poolitem.hxx>
      28             : #include <svl/memberid.hrc>
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32        2706 : TYPEINIT1_AUTOFACTORY(SfxPointItem, SfxPoolItem);
      33             : 
      34             : 
      35             : 
      36         205 : SfxPointItem::SfxPointItem()
      37             : {
      38         205 : }
      39             : 
      40             : 
      41             : 
      42        1212 : SfxPointItem::SfxPointItem( sal_uInt16 nW, const Point& rVal ) :
      43             :     SfxPoolItem( nW ),
      44        1212 :     aVal( rVal )
      45             : {
      46        1212 : }
      47             : 
      48             : 
      49             : 
      50         450 : SfxPointItem::SfxPointItem( const SfxPointItem& rItem ) :
      51             :     SfxPoolItem( rItem ),
      52         450 :     aVal( rItem.aVal )
      53             : {
      54         450 : }
      55             : 
      56             : 
      57             : 
      58           0 : bool SfxPointItem::GetPresentation
      59             : (
      60             :     SfxItemPresentation     /*ePresentation*/,
      61             :     SfxMapUnit              /*eCoreMetric*/,
      62             :     SfxMapUnit              /*ePresentationMetric*/,
      63             :     OUString&               rText,
      64             :     const IntlWrapper *
      65             : )   const
      66             : {
      67           0 :     rText = OUString::number(aVal.X()) + ", " + OUString::number(aVal.Y()) + ", ";
      68           0 :     return true;
      69             : }
      70             : 
      71             : 
      72             : 
      73           4 : bool SfxPointItem::operator==( const SfxPoolItem& rItem ) const
      74             : {
      75             :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
      76           4 :     return static_cast<const SfxPointItem&>(rItem).aVal == aVal;
      77             : }
      78             : 
      79             : 
      80             : 
      81         450 : SfxPoolItem* SfxPointItem::Clone(SfxItemPool *) const
      82             : {
      83         450 :     return new SfxPointItem( *this );
      84             : }
      85             : 
      86             : 
      87             : 
      88           0 : SfxPoolItem* SfxPointItem::Create(SvStream &rStream, sal_uInt16 ) const
      89             : {
      90           0 :     Point aStr;
      91           0 :     ReadPair( rStream, aStr );
      92           0 :     return new SfxPointItem(Which(), aStr);
      93             : }
      94             : 
      95             : 
      96             : 
      97           0 : SvStream& SfxPointItem::Store(SvStream &rStream, sal_uInt16 ) const
      98             : {
      99           0 :     WritePair( rStream, aVal );
     100           0 :     return rStream;
     101             : }
     102             : 
     103             : 
     104             : 
     105         205 : bool SfxPointItem::QueryValue( uno::Any& rVal,
     106             :                                sal_uInt8 nMemberId ) const
     107             : {
     108         205 :     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     109         205 :     awt::Point aTmp(aVal.X(), aVal.Y());
     110         205 :     if( bConvert )
     111             :     {
     112           0 :         aTmp.X = convertTwipToMm100(aTmp.X);
     113           0 :         aTmp.Y = convertTwipToMm100(aTmp.Y);
     114             :     }
     115         205 :     nMemberId &= ~CONVERT_TWIPS;
     116         205 :     switch ( nMemberId )
     117             :     {
     118         205 :         case 0: rVal <<= aTmp; break;
     119           0 :         case MID_X: rVal <<= aTmp.X; break;
     120           0 :         case MID_Y: rVal <<= aTmp.Y; break;
     121           0 :         default: OSL_FAIL("Wrong MemberId!"); return true;
     122             :     }
     123             : 
     124         205 :     return true;
     125             : }
     126             : 
     127             : 
     128             : 
     129         205 : bool SfxPointItem::PutValue( const uno::Any& rVal,
     130             :                              sal_uInt8 nMemberId )
     131             : {
     132         205 :     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     133         205 :     nMemberId &= ~CONVERT_TWIPS;
     134         205 :     bool bRet = false;
     135         205 :     awt::Point aValue;
     136         205 :     sal_Int32 nVal = 0;
     137         205 :     if ( !nMemberId )
     138             :     {
     139         205 :         bRet = ( rVal >>= aValue );
     140         205 :         if( bConvert )
     141             :         {
     142           0 :             aValue.X = convertMm100ToTwip(aValue.X);
     143           0 :             aValue.Y = convertMm100ToTwip(aValue.Y);
     144             :         }
     145             :     }
     146             :     else
     147             :     {
     148           0 :         bRet = ( rVal >>= nVal );
     149           0 :         if( bConvert )
     150           0 :             nVal = convertMm100ToTwip( nVal );
     151             :     }
     152             : 
     153         205 :     if ( bRet )
     154             :     {
     155         205 :         switch ( nMemberId )
     156             :         {
     157         205 :             case 0: aVal.setX( aValue.X ); aVal.setY( aValue.Y ); break;
     158           0 :             case MID_X: aVal.setX( nVal ); break;
     159           0 :             case MID_Y: aVal.setY( nVal ); break;
     160           0 :             default: OSL_FAIL("Wrong MemberId!"); return false;
     161             :         }
     162             :     }
     163             : 
     164         205 :     return bRet;
     165             : }
     166             : 
     167             : 
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10