LCOV - code coverage report
Current view: top level - sw/source/core/graphic - grfatr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 106 128 82.8 %
Date: 2012-08-25 Functions: 34 41 82.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 62 117 53.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/text/RelOrientation.hpp>
      30                 :            : #include <com/sun/star/text/VertOrientation.hpp>
      31                 :            : #include <com/sun/star/text/HorizontalAdjust.hpp>
      32                 :            : #include <com/sun/star/text/DocumentStatistic.hpp>
      33                 :            : #include <com/sun/star/text/HoriOrientation.hpp>
      34                 :            : #include <com/sun/star/text/HoriOrientationFormat.hpp>
      35                 :            : #include <com/sun/star/text/NotePrintMode.hpp>
      36                 :            : #include <com/sun/star/text/SizeType.hpp>
      37                 :            : #include <com/sun/star/text/VertOrientationFormat.hpp>
      38                 :            : #include <com/sun/star/text/WrapTextMode.hpp>
      39                 :            : #include <com/sun/star/text/GraphicCrop.hpp>
      40                 :            : #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
      41                 :            : #include <com/sun/star/drawing/ColorMode.hpp>
      42                 :            : #include <svtools/grfmgr.hxx>
      43                 :            : #include <swtypes.hxx>
      44                 :            : #include <grfatr.hxx>
      45                 :            : #include <swunohelper.hxx>
      46                 :            : 
      47                 :            : #include <cmdid.h>
      48                 :            : #include <unomid.h>
      49                 :            : 
      50                 :            : using namespace ::com::sun::star;
      51                 :            : 
      52 [ -  + ][ -  + ]:       4597 : TYPEINIT1_AUTOFACTORY(SwCropGrf, SfxPoolItem)
                 [ #  # ]
      53 [ -  + ][ -  + ]:       4717 : TYPEINIT1_AUTOFACTORY(SwGammaGrf, SfxPoolItem)
                 [ #  # ]
      54                 :            : 
      55                 :            : /******************************************************************************
      56                 :            :  *  Implementierung     class SwMirrorGrf
      57                 :            :  ******************************************************************************/
      58                 :            : 
      59                 :         26 : SfxPoolItem* SwMirrorGrf::Clone( SfxItemPool* ) const
      60                 :            : {
      61         [ +  - ]:         26 :     return new SwMirrorGrf( *this );
      62                 :            : }
      63                 :            : 
      64                 :          0 : sal_uInt16 SwMirrorGrf::GetValueCount() const
      65                 :            : {
      66                 :          0 :     return RES_MIRROR_GRAPH_END - RES_MIRROR_GRAPH_BEGIN;
      67                 :            : }
      68                 :            : 
      69                 :        106 : int SwMirrorGrf::operator==( const SfxPoolItem& rItem) const
      70                 :            : {
      71                 :        106 :     return SfxEnumItem::operator==(rItem) &&
      72 [ +  + ][ +  + ]:        106 :             ((SwMirrorGrf&)rItem).IsGrfToggle() == IsGrfToggle();
      73                 :            : }
      74                 :            : 
      75                 :          8 : sal_Bool lcl_IsHoriOnEvenPages(int nEnum, sal_Bool bToggle)
      76                 :            : {
      77                 :            :     sal_Bool bEnum = nEnum == RES_MIRROR_GRAPH_VERT ||
      78 [ +  - ][ -  + ]:          8 :                    nEnum == RES_MIRROR_GRAPH_BOTH;
      79                 :          8 :             return bEnum != bToggle;
      80                 :            : }
      81                 :          8 : sal_Bool lcl_IsHoriOnOddPages(int nEnum)
      82                 :            : {
      83                 :            :     sal_Bool bEnum = nEnum == RES_MIRROR_GRAPH_VERT ||
      84 [ +  + ][ -  + ]:          8 :                    nEnum == RES_MIRROR_GRAPH_BOTH;
      85                 :          8 :             return bEnum;
      86                 :            : }
      87                 :         12 : bool SwMirrorGrf::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
      88                 :            : {
      89                 :         12 :     bool bRet = true;
      90                 :            :     sal_Bool bVal;
      91                 :            :     // Vertikal und Horizontal sind mal getauscht worden!
      92                 :         12 :     nMemberId &= ~CONVERT_TWIPS;
      93   [ +  +  +  - ]:         12 :     switch ( nMemberId )
      94                 :            :     {
      95                 :            :         case MID_MIRROR_HORZ_EVEN_PAGES:
      96                 :          4 :             bVal = lcl_IsHoriOnEvenPages(GetValue(), IsGrfToggle());
      97                 :          4 :         break;
      98                 :            :         case MID_MIRROR_HORZ_ODD_PAGES:
      99                 :          4 :             bVal = lcl_IsHoriOnOddPages(GetValue());
     100                 :          4 :         break;
     101                 :            :         case MID_MIRROR_VERT:
     102                 :          4 :             bVal = GetValue() == RES_MIRROR_GRAPH_HOR ||
     103 [ +  + ][ +  - ]:          4 :                    GetValue() == RES_MIRROR_GRAPH_BOTH;
     104                 :          4 :             break;
     105                 :            :         default:
     106                 :            :             OSL_ENSURE( !this, "unknown MemberId" );
     107                 :          0 :             bRet = false;
     108                 :            :     }
     109         [ +  - ]:         12 :     rVal.setValue( &bVal, ::getBooleanCppuType() );
     110                 :         12 :     return bRet;
     111                 :            : }
     112                 :            : 
     113                 :         12 : bool SwMirrorGrf::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     114                 :            : {
     115                 :         12 :     bool bRet = true;
     116                 :         12 :     sal_Bool bVal = *(sal_Bool*)rVal.getValue();
     117                 :            :     // Vertikal und Horizontal sind mal getauscht worden!
     118                 :         12 :     nMemberId &= ~CONVERT_TWIPS;
     119      [ +  +  - ]:         12 :     switch ( nMemberId )
     120                 :            :     {
     121                 :            :         case MID_MIRROR_HORZ_EVEN_PAGES:
     122                 :            :         case MID_MIRROR_HORZ_ODD_PAGES:
     123                 :            :         {
     124                 :          8 :             sal_Bool bIsVert = GetValue() == RES_MIRROR_GRAPH_HOR ||
     125 [ -  + ][ +  - ]:          8 :                                 GetValue() == RES_MIRROR_GRAPH_BOTH;
     126                 :            :             sal_Bool bOnOddPages = nMemberId == MID_MIRROR_HORZ_EVEN_PAGES ?
     127         [ +  + ]:          8 :                                     lcl_IsHoriOnOddPages(GetValue()) : bVal;
     128                 :            :             sal_Bool bOnEvenPages = nMemberId == MID_MIRROR_HORZ_ODD_PAGES ?
     129         [ +  + ]:          8 :                                        lcl_IsHoriOnEvenPages(GetValue(), IsGrfToggle()) : bVal;
     130                 :            :             MirrorGraph nEnum = bOnOddPages ?
     131                 :            :                     bIsVert ? RES_MIRROR_GRAPH_BOTH : RES_MIRROR_GRAPH_VERT :
     132 [ +  + ][ -  + ]:          8 :                         bIsVert ? RES_MIRROR_GRAPH_HOR : RES_MIRROR_GRAPH_DONT;
                 [ -  + ]
     133                 :          8 :             sal_Bool bToggle = bOnOddPages != bOnEvenPages;
     134                 :          8 :             SetValue(static_cast<sal_uInt16>(nEnum));
     135                 :          8 :             SetGrfToggle( bToggle );
     136                 :            :         }
     137                 :          8 :         break;
     138                 :            :         case MID_MIRROR_VERT:
     139         [ +  + ]:          4 :             if ( bVal )
     140                 :            :             {
     141         [ +  - ]:          2 :                 if ( GetValue() == RES_MIRROR_GRAPH_VERT )
     142                 :          2 :                     SetValue( RES_MIRROR_GRAPH_BOTH );
     143         [ #  # ]:          0 :                 else if ( GetValue() != RES_MIRROR_GRAPH_BOTH )
     144                 :          0 :                     SetValue( RES_MIRROR_GRAPH_HOR );
     145                 :            :             }
     146                 :            :             else
     147                 :            :             {
     148         [ -  + ]:          2 :                 if ( GetValue() == RES_MIRROR_GRAPH_BOTH )
     149                 :          0 :                     SetValue( RES_MIRROR_GRAPH_VERT );
     150         [ -  + ]:          2 :                 else if ( GetValue() == RES_MIRROR_GRAPH_HOR )
     151                 :          0 :                     SetValue( RES_MIRROR_GRAPH_DONT );
     152                 :            :             }
     153                 :          4 :             break;
     154                 :            :         default:
     155                 :            :             OSL_ENSURE( !this, "unknown MemberId" );
     156                 :          0 :             bRet = false;
     157                 :            :     }
     158                 :         12 :     return bRet;
     159                 :            : }
     160                 :            : 
     161                 :            : 
     162                 :            : /******************************************************************************
     163                 :            :  *  Implementierung     class SwCropGrf
     164                 :            :  ******************************************************************************/
     165                 :            : 
     166                 :         73 : SwCropGrf::SwCropGrf()
     167                 :         73 :     : SvxGrfCrop( RES_GRFATR_CROPGRF )
     168                 :         73 : {}
     169                 :            : 
     170                 :          0 : SwCropGrf::SwCropGrf(sal_Int32 nL, sal_Int32 nR, sal_Int32 nT, sal_Int32 nB )
     171                 :          0 :     : SvxGrfCrop( nL, nR, nT, nB, RES_GRFATR_CROPGRF )
     172                 :          0 : {}
     173                 :            : 
     174                 :         20 : SfxPoolItem* SwCropGrf::Clone( SfxItemPool* ) const
     175                 :            : {
     176         [ +  - ]:         20 :     return new SwCropGrf( *this );
     177                 :            : }
     178                 :            : 
     179                 :            : // ------------------------------------------------------------------
     180                 :            : 
     181                 :          6 : SfxPoolItem* SwRotationGrf::Clone( SfxItemPool * ) const
     182                 :            : {
     183         [ +  - ]:          6 :     return new SwRotationGrf( GetValue(), aUnrotatedSize );
     184                 :            : }
     185                 :            : 
     186                 :            : 
     187                 :          0 : int SwRotationGrf::operator==( const SfxPoolItem& rCmp ) const
     188                 :            : {
     189                 :          0 :     return SfxUInt16Item::operator==( rCmp ) &&
     190 [ #  # ][ #  # ]:          0 :         GetUnrotatedSize() == ((SwRotationGrf&)rCmp).GetUnrotatedSize();
     191                 :            : }
     192                 :            : 
     193                 :            : 
     194                 :          0 : bool SwRotationGrf::QueryValue( uno::Any& rVal, sal_uInt8 ) const
     195                 :            : {
     196                 :            :     // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
     197                 :            :     // where we still want this to be a sal_Int16
     198         [ #  # ]:          0 :     rVal <<= (sal_Int16)GetValue();
     199                 :          0 :     return true;
     200                 :            : }
     201                 :            : 
     202                 :          2 : bool SwRotationGrf::PutValue( const uno::Any& rVal, sal_uInt8 )
     203                 :            : {
     204                 :            :     // SfxUInt16Item::QueryValue returns sal_Int32 in Any now... (srx642w)
     205                 :            :     // where we still want this to be a sal_Int16
     206                 :          2 :     sal_Int16 nValue = 0;
     207         [ +  - ]:          2 :     if (rVal >>= nValue)
     208                 :            :     {
     209                 :            :         // sal_uInt16 argument needed
     210                 :          2 :         SetValue( (sal_uInt16) nValue );
     211                 :          2 :         return true;
     212                 :            :     }
     213                 :            : 
     214                 :            :     OSL_FAIL( "SwRotationGrf::PutValue - Wrong type!" );
     215                 :          2 :     return false;
     216                 :            : }
     217                 :            : 
     218                 :            : // ------------------------------------------------------------------
     219                 :            : 
     220                 :         45 : SfxPoolItem* SwLuminanceGrf::Clone( SfxItemPool * ) const
     221                 :            : {
     222         [ +  - ]:         45 :     return new SwLuminanceGrf( *this );
     223                 :            : }
     224                 :            : 
     225                 :            : // ------------------------------------------------------------------
     226                 :            : 
     227                 :         45 : SfxPoolItem* SwContrastGrf::Clone( SfxItemPool * ) const
     228                 :            : {
     229         [ +  - ]:         45 :     return new SwContrastGrf( *this );
     230                 :            : }
     231                 :            : 
     232                 :            : // ------------------------------------------------------------------
     233                 :            : 
     234                 :         12 : SfxPoolItem* SwChannelRGrf::Clone( SfxItemPool * ) const
     235                 :            : {
     236         [ +  - ]:         12 :     return new SwChannelRGrf( *this );
     237                 :            : }
     238                 :            : 
     239                 :            : // ------------------------------------------------------------------
     240                 :            : 
     241                 :         12 : SfxPoolItem* SwChannelGGrf::Clone( SfxItemPool * ) const
     242                 :            : {
     243         [ +  - ]:         12 :     return new SwChannelGGrf( *this );
     244                 :            : }
     245                 :            : 
     246                 :            : // ------------------------------------------------------------------
     247                 :            : 
     248                 :         12 : SfxPoolItem* SwChannelBGrf::Clone( SfxItemPool * ) const
     249                 :            : {
     250         [ +  - ]:         12 :     return new SwChannelBGrf( *this );
     251                 :            : }
     252                 :            : 
     253                 :            : // ------------------------------------------------------------------
     254                 :            : 
     255                 :         48 : SfxPoolItem* SwGammaGrf::Clone( SfxItemPool * ) const
     256                 :            : {
     257         [ +  - ]:         48 :     return new SwGammaGrf( *this );
     258                 :            : }
     259                 :            : 
     260                 :         60 : int SwGammaGrf::operator==( const SfxPoolItem& rCmp ) const
     261                 :            : {
     262                 :         60 :     return SfxPoolItem::operator==( rCmp ) &&
     263 [ +  - ][ +  - ]:         60 :         nValue == ((SwGammaGrf&)rCmp).GetValue();
     264                 :            : }
     265                 :            : 
     266                 :          4 : bool SwGammaGrf::QueryValue( uno::Any& rVal, sal_uInt8 ) const
     267                 :            : {
     268                 :          4 :     rVal <<= nValue;
     269                 :          4 :     return true;
     270                 :            : }
     271                 :            : 
     272                 :          4 : bool SwGammaGrf::PutValue( const uno::Any& rVal, sal_uInt8 )
     273                 :            : {
     274                 :          4 :     return rVal >>= nValue;
     275                 :            : }
     276                 :            : 
     277                 :            : // ------------------------------------------------------------------
     278                 :            : 
     279                 :         12 : SfxPoolItem* SwInvertGrf::Clone( SfxItemPool * ) const
     280                 :            : {
     281         [ +  - ]:         12 :     return new SwInvertGrf( *this );
     282                 :            : }
     283                 :            : 
     284                 :            : // ------------------------------------------------------------------
     285                 :            : 
     286                 :         12 : SfxPoolItem* SwTransparencyGrf::Clone( SfxItemPool * ) const
     287                 :            : {
     288         [ +  - ]:         12 :     return new SwTransparencyGrf( *this );
     289                 :            : }
     290                 :            : // ------------------------------------------------------------------
     291                 :          4 : bool SwTransparencyGrf::QueryValue( uno::Any& rVal,
     292                 :            :                                         sal_uInt8 ) const
     293                 :            : {
     294                 :            :     OSL_ENSURE(ISA(SfxByteItem),"Put/QueryValue should be removed!");
     295                 :          4 :     sal_Int16 nRet = GetValue();
     296                 :            :     OSL_ENSURE( 0 <= nRet && nRet <= 100, "value out of range" );
     297         [ +  - ]:          4 :     rVal <<= nRet;
     298                 :          4 :     return true;
     299                 :            : }
     300                 :            : // ------------------------------------------------------------------
     301                 :          4 : bool SwTransparencyGrf::PutValue( const uno::Any& rVal,
     302                 :            :                                         sal_uInt8 )
     303                 :            : {
     304                 :            :     //temporary conversion until this is a SfxInt16Item!
     305                 :            :     OSL_ENSURE(ISA(SfxByteItem),"Put/QueryValue should be removed!");
     306                 :          4 :     sal_Int16 nVal = 0;
     307 [ +  - ][ +  - ]:          4 :     if(!(rVal >>= nVal) || nVal < -100 || nVal > 100)
         [ -  + ][ -  + ]
     308                 :          0 :         return false;
     309         [ -  + ]:          4 :     if(nVal < 0)
     310                 :            :     {
     311                 :            :         // for compatibility with old documents
     312                 :            :         // introduce rounding as for SO 6.0 PP2
     313                 :          0 :         nVal = ( ( nVal * 128 ) - (99/2) ) / 100;
     314                 :          0 :         nVal += 128;
     315                 :            :     }
     316                 :            :     OSL_ENSURE( 0 <= nVal && nVal <= 100, "value out of range" );
     317                 :          4 :     SetValue(static_cast<sal_uInt8>(nVal));
     318                 :          4 :     return true;
     319                 :            : }
     320                 :            : 
     321                 :            : // ------------------------------------------------------------------
     322                 :            : 
     323                 :         12 : SfxPoolItem* SwDrawModeGrf::Clone( SfxItemPool * ) const
     324                 :            : {
     325         [ +  - ]:         12 :     return new SwDrawModeGrf( *this );
     326                 :            : }
     327                 :            : 
     328                 :          0 : sal_uInt16 SwDrawModeGrf::GetValueCount() const
     329                 :            : {
     330                 :          0 :     return GRAPHICDRAWMODE_WATERMARK + 1;
     331                 :            : }
     332                 :            : 
     333                 :          4 : bool SwDrawModeGrf::QueryValue( uno::Any& rVal,
     334                 :            :                                 sal_uInt8 ) const
     335                 :            : {
     336         [ +  - ]:          4 :     drawing::ColorMode eRet = (drawing::ColorMode)GetEnumValue();
     337         [ +  - ]:          4 :     rVal <<= eRet;
     338                 :          4 :     return true;
     339                 :            : }
     340                 :            : 
     341                 :          4 : bool SwDrawModeGrf::PutValue( const uno::Any& rVal,
     342                 :            :                                 sal_uInt8 )
     343                 :            : {
     344                 :          4 :     sal_Int32 eVal = SWUnoHelper::GetEnumAsInt32( rVal );
     345 [ +  - ][ +  - ]:          4 :     if(eVal >= 0 && eVal <= GRAPHICDRAWMODE_WATERMARK)
     346                 :            :     {
     347                 :          4 :         SetEnumValue((sal_uInt16)eVal);
     348                 :          4 :         return true;
     349                 :            :     }
     350                 :          4 :     return false;
     351                 :            : }
     352                 :            : 
     353                 :            : 
     354                 :            : 
     355                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10