LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svl/source/items - rectitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 61 18.0 %
Date: 2013-07-09 Functions: 8 15 53.3 %
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 <tools/stream.hxx>
      25             : 
      26             : #include <svl/poolitem.hxx>
      27             : #include <svl/memberid.hrc>
      28             : 
      29             : // STATIC DATA -----------------------------------------------------------
      30             : 
      31             : DBG_NAME(SfxRectangleItem)
      32             : 
      33             : 
      34             : // -----------------------------------------------------------------------
      35             : 
      36        3322 : TYPEINIT1_AUTOFACTORY(SfxRectangleItem, SfxPoolItem);
      37             : 
      38             : // -----------------------------------------------------------------------
      39             : 
      40           0 : SfxRectangleItem::SfxRectangleItem()
      41             : {
      42             :     DBG_CTOR(SfxRectangleItem, 0);
      43           0 : }
      44             : 
      45             : // -----------------------------------------------------------------------
      46             : 
      47         317 : SfxRectangleItem::SfxRectangleItem( sal_uInt16 nW, const Rectangle& rVal ) :
      48             :     SfxPoolItem( nW ),
      49         317 :     aVal( rVal )
      50             : {
      51             :     DBG_CTOR(SfxRectangleItem, 0);
      52         317 : }
      53             : 
      54             : // -----------------------------------------------------------------------
      55             : 
      56        1358 : SfxRectangleItem::SfxRectangleItem( const SfxRectangleItem& rItem ) :
      57             :     SfxPoolItem( rItem ),
      58        1358 :     aVal( rItem.aVal )
      59             : {
      60             :     DBG_CTOR(SfxRectangleItem, 0);
      61        1358 : }
      62             : 
      63             : // -----------------------------------------------------------------------
      64             : 
      65           0 : SfxItemPresentation SfxRectangleItem::GetPresentation
      66             : (
      67             :     SfxItemPresentation     /*ePresentation*/,
      68             :     SfxMapUnit              /*eCoreMetric*/,
      69             :     SfxMapUnit              /*ePresentationMetric*/,
      70             :     OUString&               rText,
      71             :     const IntlWrapper *
      72             : )   const
      73             : {
      74             :     DBG_CHKTHIS(SfxRectangleItem, 0);
      75           0 :     rText = OUString::number(aVal.Top())    + ", " +
      76           0 :             OUString::number(aVal.Left())   + ", " +
      77           0 :             OUString::number(aVal.Bottom()) + ", " +
      78           0 :             OUString::number(aVal.Right());
      79           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
      80             : }
      81             : 
      82             : // -----------------------------------------------------------------------
      83             : 
      84          57 : int SfxRectangleItem::operator==( const SfxPoolItem& rItem ) const
      85             : {
      86             :     DBG_CHKTHIS(SfxRectangleItem, 0);
      87             :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
      88          57 :     return ((SfxRectangleItem&)rItem).aVal == aVal;
      89             : }
      90             : 
      91             : // -----------------------------------------------------------------------
      92             : 
      93         844 : SfxPoolItem* SfxRectangleItem::Clone(SfxItemPool *) const
      94             : {
      95             :     DBG_CHKTHIS(SfxRectangleItem, 0);
      96         844 :     return new SfxRectangleItem( *this );
      97             : }
      98             : 
      99             : // -----------------------------------------------------------------------
     100             : 
     101           0 : SfxPoolItem* SfxRectangleItem::Create(SvStream &rStream, sal_uInt16 ) const
     102             : {
     103             :     DBG_CHKTHIS(SfxRectangleItem, 0);
     104           0 :     Rectangle aStr;
     105           0 :     rStream >> aStr;
     106           0 :     return new SfxRectangleItem(Which(), aStr);
     107             : }
     108             : 
     109             : // -----------------------------------------------------------------------
     110             : 
     111           0 : SvStream& SfxRectangleItem::Store(SvStream &rStream, sal_uInt16 ) const
     112             : {
     113             :     DBG_CHKTHIS(SfxRectangleItem, 0);
     114           0 :     rStream << aVal;
     115           0 :     return rStream;
     116             : }
     117             : 
     118             : 
     119             : // -----------------------------------------------------------------------
     120           0 : bool SfxRectangleItem::QueryValue( com::sun::star::uno::Any& rVal,
     121             :                                    sal_uInt8 nMemberId) const
     122             : {
     123           0 :     nMemberId &= ~CONVERT_TWIPS;
     124           0 :     switch ( nMemberId )
     125             :     {
     126             :         case 0:
     127             :         {
     128           0 :             rVal <<= com::sun::star::awt::Rectangle( aVal.getX(),
     129           0 :                                              aVal.getY(),
     130           0 :                                              aVal.getWidth(),
     131           0 :                                              aVal.getHeight() );
     132           0 :             break;
     133             :         }
     134           0 :         case MID_RECT_LEFT:  rVal <<= aVal.getX(); break;
     135           0 :         case MID_RECT_RIGHT: rVal <<= aVal.getY(); break;
     136           0 :         case MID_WIDTH: rVal <<= aVal.getWidth(); break;
     137           0 :         case MID_HEIGHT: rVal <<= aVal.getHeight(); break;
     138           0 :         default: OSL_FAIL("Wrong MemberID!"); return false;
     139             :     }
     140             : 
     141           0 :     return true;
     142             : }
     143             : 
     144             : // -----------------------------------------------------------------------
     145           0 : bool SfxRectangleItem::PutValue( const com::sun::star::uno::Any& rVal,
     146             :                                  sal_uInt8 nMemberId  )
     147             : {
     148           0 :     bool bRet = false;
     149           0 :     nMemberId &= ~CONVERT_TWIPS;
     150           0 :     com::sun::star::awt::Rectangle aValue;
     151           0 :     sal_Int32 nVal = 0;
     152           0 :     if ( !nMemberId )
     153           0 :         bRet = (rVal >>= aValue);
     154             :     else
     155           0 :         bRet = (rVal >>= nVal);
     156             : 
     157           0 :     if ( bRet )
     158             :     {
     159           0 :         switch ( nMemberId )
     160             :         {
     161             :             case 0:
     162           0 :                 aVal.setX( aValue.X );
     163           0 :                 aVal.setY( aValue.Y );
     164           0 :                 aVal.setWidth( aValue.Width );
     165           0 :                 aVal.setHeight( aValue.Height );
     166           0 :                 break;
     167           0 :             case MID_RECT_LEFT:  aVal.setX( nVal ); break;
     168           0 :             case MID_RECT_RIGHT: aVal.setY( nVal ); break;
     169           0 :             case MID_WIDTH: aVal.setWidth( nVal ); break;
     170           0 :             case MID_HEIGHT: aVal.setHeight( nVal ); break;
     171           0 :             default: OSL_FAIL("Wrong MemberID!"); return false;
     172             :         }
     173             :     }
     174             : 
     175           0 :     return bRet;
     176             : }
     177             : 
     178             : 
     179             : 
     180             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10