LCOV - code coverage report
Current view: top level - svl/source/items - rectitem.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 20 61 32.8 %
Date: 2015-06-13 12:38:46 Functions: 9 15 60.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/rectitem.hxx>
      22             : #include <com/sun/star/uno/Any.hxx>
      23             : #include <com/sun/star/awt/Rectangle.hpp>
      24             : #include <osl/diagnose.h>
      25             : #include <tools/stream.hxx>
      26             : 
      27             : #include <svl/poolitem.hxx>
      28             : #include <svl/memberid.hrc>
      29             : 
      30        5900 : TYPEINIT1_AUTOFACTORY(SfxRectangleItem, SfxPoolItem);
      31             : 
      32             : 
      33             : 
      34           0 : SfxRectangleItem::SfxRectangleItem()
      35             : {
      36           0 : }
      37             : 
      38             : 
      39             : 
      40         636 : SfxRectangleItem::SfxRectangleItem( sal_uInt16 nW, const Rectangle& rVal ) :
      41             :     SfxPoolItem( nW ),
      42         636 :     aVal( rVal )
      43             : {
      44         636 : }
      45             : 
      46             : 
      47             : 
      48        1948 : SfxRectangleItem::SfxRectangleItem( const SfxRectangleItem& rItem ) :
      49             :     SfxPoolItem( rItem ),
      50        1948 :     aVal( rItem.aVal )
      51             : {
      52        1948 : }
      53             : 
      54             : 
      55             : 
      56           0 : bool SfxRectangleItem::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.Top())    + ", " +
      66           0 :             OUString::number(aVal.Left())   + ", " +
      67           0 :             OUString::number(aVal.Bottom()) + ", " +
      68           0 :             OUString::number(aVal.Right());
      69           0 :     return true;
      70             : }
      71             : 
      72             : 
      73             : 
      74         305 : bool SfxRectangleItem::operator==( const SfxPoolItem& rItem ) const
      75             : {
      76             :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
      77         305 :     return static_cast<const SfxRectangleItem&>(rItem).aVal == aVal;
      78             : }
      79             : 
      80             : 
      81             : 
      82        1307 : SfxPoolItem* SfxRectangleItem::Clone(SfxItemPool *) const
      83             : {
      84        1307 :     return new SfxRectangleItem( *this );
      85             : }
      86             : 
      87             : 
      88             : 
      89           0 : SfxPoolItem* SfxRectangleItem::Create(SvStream &rStream, sal_uInt16 ) const
      90             : {
      91           0 :     Rectangle aStr;
      92           0 :     ReadRectangle( rStream, aStr );
      93           0 :     return new SfxRectangleItem(Which(), aStr);
      94             : }
      95             : 
      96             : 
      97             : 
      98           0 : SvStream& SfxRectangleItem::Store(SvStream &rStream, sal_uInt16 ) const
      99             : {
     100           0 :     WriteRectangle( rStream, aVal );
     101           0 :     return rStream;
     102             : }
     103             : 
     104             : 
     105             : 
     106         334 : bool SfxRectangleItem::QueryValue( com::sun::star::uno::Any& rVal,
     107             :                                    sal_uInt8 nMemberId) const
     108             : {
     109         334 :     nMemberId &= ~CONVERT_TWIPS;
     110         334 :     switch ( nMemberId )
     111             :     {
     112             :         case 0:
     113             :         {
     114        1336 :             rVal <<= com::sun::star::awt::Rectangle( aVal.getX(),
     115         334 :                                              aVal.getY(),
     116         334 :                                              aVal.getWidth(),
     117         668 :                                              aVal.getHeight() );
     118         334 :             break;
     119             :         }
     120           0 :         case MID_RECT_LEFT:  rVal <<= aVal.getX(); break;
     121           0 :         case MID_RECT_RIGHT: rVal <<= aVal.getY(); break;
     122           0 :         case MID_WIDTH: rVal <<= aVal.getWidth(); break;
     123           0 :         case MID_HEIGHT: rVal <<= aVal.getHeight(); break;
     124           0 :         default: OSL_FAIL("Wrong MemberID!"); return false;
     125             :     }
     126             : 
     127         334 :     return true;
     128             : }
     129             : 
     130             : 
     131           0 : bool SfxRectangleItem::PutValue( const com::sun::star::uno::Any& rVal,
     132             :                                  sal_uInt8 nMemberId  )
     133             : {
     134           0 :     bool bRet = false;
     135           0 :     nMemberId &= ~CONVERT_TWIPS;
     136           0 :     com::sun::star::awt::Rectangle aValue;
     137           0 :     sal_Int32 nVal = 0;
     138           0 :     if ( !nMemberId )
     139           0 :         bRet = (rVal >>= aValue);
     140             :     else
     141           0 :         bRet = (rVal >>= nVal);
     142             : 
     143           0 :     if ( bRet )
     144             :     {
     145           0 :         switch ( nMemberId )
     146             :         {
     147             :             case 0:
     148           0 :                 aVal.setX( aValue.X );
     149           0 :                 aVal.setY( aValue.Y );
     150           0 :                 aVal.setWidth( aValue.Width );
     151           0 :                 aVal.setHeight( aValue.Height );
     152           0 :                 break;
     153           0 :             case MID_RECT_LEFT:  aVal.setX( nVal ); break;
     154           0 :             case MID_RECT_RIGHT: aVal.setY( nVal ); break;
     155           0 :             case MID_WIDTH: aVal.setWidth( nVal ); break;
     156           0 :             case MID_HEIGHT: aVal.setHeight( nVal ); break;
     157           0 :             default: OSL_FAIL("Wrong MemberID!"); return false;
     158             :         }
     159             :     }
     160             : 
     161           0 :     return bRet;
     162             : }
     163             : 
     164             : 
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11