LCOV - code coverage report
Current view: top level - svl/source/items - ptitem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 57 0.0 %
Date: 2014-04-14 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/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           0 : TYPEINIT1_AUTOFACTORY(SfxPointItem, SfxPoolItem);
      33             : 
      34             : 
      35             : 
      36           0 : SfxPointItem::SfxPointItem()
      37             : {
      38           0 : }
      39             : 
      40             : 
      41             : 
      42           0 : SfxPointItem::SfxPointItem( sal_uInt16 nW, const Point& rVal ) :
      43             :     SfxPoolItem( nW ),
      44           0 :     aVal( rVal )
      45             : {
      46           0 : }
      47             : 
      48             : 
      49             : 
      50           0 : SfxPointItem::SfxPointItem( const SfxPointItem& rItem ) :
      51             :     SfxPoolItem( rItem ),
      52           0 :     aVal( rItem.aVal )
      53             : {
      54           0 : }
      55             : 
      56             : 
      57             : 
      58           0 : SfxItemPresentation 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 SFX_ITEM_PRESENTATION_NAMELESS;
      69             : }
      70             : 
      71             : 
      72             : 
      73           0 : bool SfxPointItem::operator==( const SfxPoolItem& rItem ) const
      74             : {
      75             :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
      76           0 :     return ((SfxPointItem&)rItem).aVal == aVal;
      77             : }
      78             : 
      79             : 
      80             : 
      81           0 : SfxPoolItem* SfxPointItem::Clone(SfxItemPool *) const
      82             : {
      83           0 :     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           0 : bool SfxPointItem::QueryValue( uno::Any& rVal,
     106             :                                sal_uInt8 nMemberId ) const
     107             : {
     108           0 :     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     109           0 :     awt::Point aTmp(aVal.X(), aVal.Y());
     110           0 :     if( bConvert )
     111             :     {
     112           0 :         aTmp.X = convertTwipToMm100(aTmp.X);
     113           0 :         aTmp.Y = convertTwipToMm100(aTmp.Y);
     114             :     }
     115           0 :     nMemberId &= ~CONVERT_TWIPS;
     116           0 :     switch ( nMemberId )
     117             :     {
     118           0 :         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           0 :     return true;
     125             : }
     126             : 
     127             : 
     128             : 
     129           0 : bool SfxPointItem::PutValue( const uno::Any& rVal,
     130             :                              sal_uInt8 nMemberId )
     131             : {
     132           0 :     bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
     133           0 :     nMemberId &= ~CONVERT_TWIPS;
     134           0 :     bool bRet = false;
     135           0 :     awt::Point aValue;
     136           0 :     sal_Int32 nVal = 0;
     137           0 :     if ( !nMemberId )
     138             :     {
     139           0 :         bRet = ( rVal >>= aValue );
     140           0 :         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           0 :     if ( bRet )
     154             :     {
     155           0 :         switch ( nMemberId )
     156             :         {
     157           0 :             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           0 :     return bRet;
     165             : }
     166             : 
     167             : 
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10