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

Generated by: LCOV version 1.10