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

Generated by: LCOV version 1.11