LCOV - code coverage report
Current view: top level - sw/source/core/uibase/utlui - uiitems.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 68 143 47.6 %
Date: 2014-04-11 Functions: 8 27 29.6 %
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             : #include <editeng/itemtype.hxx>
      21             : #include <unosett.hxx>
      22             : 
      23             : #include "swtypes.hxx"
      24             : #include "cmdid.h"
      25             : #include "uiitems.hxx"
      26             : 
      27             : #include "utlui.hrc"
      28             : #include "attrdesc.hrc"
      29             : #include <unomid.h>
      30             : #include <numrule.hxx>
      31             : 
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::uno;
      34             : 
      35        7478 : SwPageFtnInfoItem::SwPageFtnInfoItem( const sal_uInt16 nId, SwPageFtnInfo& rInfo) :
      36             :     SfxPoolItem( nId ),
      37        7478 :     aFtnInfo(rInfo)
      38             : {
      39        7478 : }
      40             : 
      41       18744 : SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem& rItem ) :
      42             :     SfxPoolItem( rItem ),
      43       18744 :     aFtnInfo(rItem.GetPageFtnInfo())
      44             : {
      45       18744 : }
      46             : 
      47       44966 :  SwPageFtnInfoItem::~SwPageFtnInfoItem()
      48             : {
      49       44966 : }
      50             : 
      51       18744 : SfxPoolItem*  SwPageFtnInfoItem::Clone( SfxItemPool * /*pPool*/ ) const
      52             : {
      53       18744 :     return new SwPageFtnInfoItem( *this );
      54             : }
      55             : 
      56        3226 : bool SwPageFtnInfoItem::operator==( const SfxPoolItem& rAttr ) const
      57             : {
      58             :     OSL_ENSURE( Which() == rAttr.Which(), "no equal attributes" );
      59        3226 :     return ( aFtnInfo == ((SwPageFtnInfoItem&)rAttr).GetPageFtnInfo());
      60             : }
      61             : 
      62           0 : SfxItemPresentation  SwPageFtnInfoItem::GetPresentation
      63             : (
      64             :     SfxItemPresentation ePres,
      65             :     SfxMapUnit          eCoreUnit,
      66             :     SfxMapUnit          ePresUnit,
      67             :     OUString&           rText,
      68             :     const IntlWrapper*  pIntl
      69             : )   const
      70             : {
      71           0 :     switch ( ePres )
      72             :     {
      73             :         case SFX_ITEM_PRESENTATION_NONE:
      74           0 :             rText = OUString();
      75           0 :             return SFX_ITEM_PRESENTATION_NONE;
      76             :         case SFX_ITEM_PRESENTATION_NAMELESS:
      77             :         case SFX_ITEM_PRESENTATION_COMPLETE:
      78             :         {
      79           0 :             sal_uInt16 nHght = (sal_uInt16) GetPageFtnInfo().GetHeight();
      80           0 :             if ( nHght )
      81             :             {
      82           0 :                 rText = SW_RESSTR( STR_MAX_FTN_HEIGHT ) + " " +
      83           0 :                         ::GetMetricText( nHght, eCoreUnit, ePresUnit, pIntl ) + " " +
      84           0 :                         ::GetSvxString( ::GetMetricId( ePresUnit ) );
      85             :             }
      86           0 :             return ePres;
      87             :         }
      88             :         default:; //prevent warning
      89             :     }
      90           0 :     return SFX_ITEM_PRESENTATION_NONE;
      91             : }
      92             : 
      93         212 : bool SwPageFtnInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
      94             : {
      95         212 :     bool bRet = true;
      96         212 :     switch(nMemberId & ~CONVERT_TWIPS)
      97             :     {
      98          26 :         case MID_FTN_HEIGHT        :     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetHeight());break;
      99          26 :         case MID_LINE_WEIGHT       :     rVal <<= (sal_Int16)TWIP_TO_MM100_UNSIGNED(aFtnInfo.GetLineWidth());break;
     100          26 :         case MID_LINE_COLOR        :     rVal <<= (sal_Int32)aFtnInfo.GetLineColor().GetColor();break;
     101             :         case MID_LINE_RELWIDTH     :
     102             :         {
     103          30 :             Fraction aTmp( 100, 1 );
     104          30 :             aTmp *= aFtnInfo.GetWidth();
     105          30 :             rVal <<= (sal_Int8)(long)aTmp;
     106             :         }
     107          30 :         break;
     108          26 :         case MID_LINE_ADJUST       :     rVal <<= (sal_Int16)aFtnInfo.GetAdj();break;//text::HorizontalAdjust
     109          26 :         case MID_LINE_TEXT_DIST    :     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetTopDist());break;
     110          26 :         case MID_LINE_FOOTNOTE_DIST:     rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetBottomDist());break;
     111             :         case MID_FTN_LINE_STYLE    :
     112             :         {
     113          26 :             switch ( aFtnInfo.GetLineStyle( ) )
     114             :             {
     115             :                 default:
     116           3 :                 case table::BorderLineStyle::NONE : rVal <<= sal_Int8(0); break;
     117          23 :                 case table::BorderLineStyle::SOLID: rVal <<= sal_Int8(1); break;
     118           0 :                 case table::BorderLineStyle::DOTTED: rVal <<= sal_Int8(2); break;
     119           0 :                 case table::BorderLineStyle::DASHED: rVal <<= sal_Int8(3); break;
     120             :             }
     121          26 :             break;
     122             :         }
     123             :         default:
     124           0 :             bRet = false;
     125             :     }
     126         212 :     return bRet;
     127             : }
     128             : 
     129        3012 : bool SwPageFtnInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId)
     130             : {
     131        3012 :     sal_Int32 nSet32 = 0;
     132        3012 :     bool bRet = true;
     133        3012 :     switch(nMemberId  & ~CONVERT_TWIPS)
     134             :     {
     135             :         case MID_LINE_COLOR        :
     136         213 :             rVal >>= nSet32;
     137         213 :             aFtnInfo.SetLineColor(nSet32);
     138         213 :         break;
     139             :         case MID_FTN_HEIGHT:
     140             :         case MID_LINE_TEXT_DIST    :
     141             :         case MID_LINE_FOOTNOTE_DIST:
     142         639 :                 rVal >>= nSet32;
     143         639 :                 if(nSet32 < 0)
     144           0 :                     bRet = false;
     145             :                 else
     146             :                 {
     147         639 :                     nSet32 = MM100_TO_TWIP(nSet32);
     148         639 :                     switch(nMemberId & ~CONVERT_TWIPS)
     149             :                     {
     150         213 :                         case MID_FTN_HEIGHT:            aFtnInfo.SetHeight(nSet32);    break;
     151         213 :                         case MID_LINE_TEXT_DIST:        aFtnInfo.SetTopDist(nSet32);break;
     152         213 :                         case MID_LINE_FOOTNOTE_DIST:    aFtnInfo.SetBottomDist(nSet32);break;
     153             :                     }
     154             :                 }
     155         639 :         break;
     156             :         case MID_LINE_WEIGHT       :
     157             :         {
     158         213 :             sal_Int16 nSet = 0;
     159         213 :             rVal >>= nSet;
     160         213 :             if(nSet >= 0)
     161         213 :                 aFtnInfo.SetLineWidth(MM100_TO_TWIP(nSet));
     162             :             else
     163           0 :                 bRet = false;
     164             :         }
     165         213 :         break;
     166             :         case MID_LINE_RELWIDTH     :
     167             :         {
     168        1521 :             sal_Int8 nSet = 0;
     169        1521 :             rVal >>= nSet;
     170        1521 :             if(nSet < 0)
     171           0 :                 bRet = false;
     172             :             else
     173        1521 :                 aFtnInfo.SetWidth(Fraction(nSet, 100));
     174             :         }
     175        1521 :         break;
     176             :         case MID_LINE_ADJUST       :
     177             :         {
     178         213 :             sal_Int16 nSet = 0;
     179         213 :             rVal >>= nSet;
     180         213 :             if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust
     181         213 :                 aFtnInfo.SetAdj((SwFtnAdj)nSet);
     182             :             else
     183           0 :                 bRet = false;
     184             :         }
     185             :         case MID_FTN_LINE_STYLE:
     186             :         {
     187         426 :             ::editeng::SvxBorderStyle eStyle = table::BorderLineStyle::NONE;
     188         426 :             sal_Int8 nSet = 0;
     189         426 :             rVal >>= nSet;
     190         426 :             switch ( nSet )
     191             :             {
     192         114 :                 case 1: eStyle = table::BorderLineStyle::SOLID; break;
     193           0 :                 case 2: eStyle = table::BorderLineStyle::DOTTED; break;
     194           0 :                 case 3: eStyle = table::BorderLineStyle::DASHED; break;
     195         312 :                 default: break;
     196             :             }
     197         426 :             aFtnInfo.SetLineStyle( eStyle );
     198             :         }
     199         426 :         break;
     200             :         default:
     201           0 :             bRet = false;
     202             :     }
     203        3012 :     return bRet;
     204             : }
     205             : 
     206           0 : SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) :
     207             :     SfxPoolItem( nId ),
     208           0 :     pMisc(pPtr)
     209             : {
     210           0 : }
     211             : 
     212             : // Copy constructor
     213             : 
     214           0 : SwPtrItem::SwPtrItem( const SwPtrItem& rItem ) : SfxPoolItem( rItem )
     215             : {
     216           0 :     pMisc = rItem.pMisc;
     217           0 : }
     218             : 
     219             : // Cloning
     220             : 
     221           0 : SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const
     222             : {
     223           0 :     return new SwPtrItem( *this );
     224             : }
     225             : 
     226           0 : bool SwPtrItem::operator==( const SfxPoolItem& rAttr ) const
     227             : {
     228             :     OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
     229           0 :     const SwPtrItem& rItem = (SwPtrItem&)rAttr;
     230           0 :     return ( pMisc == rItem.pMisc );
     231             : }
     232             : 
     233             : // SwUINumRuleItem for the NumTabPages of the FormatNumRule/Styleists
     234             : 
     235           0 : SwUINumRuleItem::SwUINumRuleItem( const SwNumRule& rRul, const sal_uInt16 nId )
     236           0 :     : SfxPoolItem( nId ), pRule( new SwNumRule( rRul ) )
     237             : {
     238           0 : }
     239             : 
     240           0 : SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem )
     241             :     : SfxPoolItem( rItem ),
     242           0 :     pRule( new SwNumRule( *rItem.pRule ))
     243             : {
     244           0 : }
     245             : 
     246           0 :  SwUINumRuleItem::~SwUINumRuleItem()
     247             : {
     248           0 :     delete pRule;
     249           0 : }
     250             : 
     251           0 : SfxPoolItem*  SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const
     252             : {
     253           0 :     return new SwUINumRuleItem( *this );
     254             : }
     255             : 
     256           0 : bool SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const
     257             : {
     258             :     OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
     259           0 :     return *pRule == *((SwUINumRuleItem&)rAttr).pRule;
     260             : }
     261             : 
     262           0 : bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
     263             : {
     264           0 :     uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*pRule);
     265           0 :     rVal.setValue(&xRules, ::getCppuType((uno::Reference< container::XIndexReplace>*)0));
     266           0 :     return true;
     267             : }
     268           0 : bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
     269             : {
     270           0 :     uno::Reference< container::XIndexReplace> xRulesRef;
     271           0 :     if(rVal >>= xRulesRef)
     272             :     {
     273           0 :         uno::Reference< lang::XUnoTunnel > xTunnel(xRulesRef, uno::UNO_QUERY);
     274           0 :         SwXNumberingRules* pSwXRules = xTunnel.is() ? reinterpret_cast<SwXNumberingRules*>(
     275           0 :                     xTunnel->getSomething(SwXNumberingRules::getUnoTunnelId())) : 0;
     276           0 :         if(pSwXRules)
     277             :         {
     278           0 :             *pRule = *pSwXRules->GetNumRule();
     279           0 :         }
     280             :     }
     281           0 :     return true;
     282             : }
     283             : 
     284           0 : SwBackgroundDestinationItem::SwBackgroundDestinationItem(sal_uInt16  _nWhich, sal_uInt16 nValue) :
     285           0 :     SfxUInt16Item(_nWhich, nValue)
     286             : {
     287           0 : }
     288             : 
     289           0 : SfxPoolItem*     SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) const
     290             : {
     291           0 :     return new SwBackgroundDestinationItem(Which(), GetValue());
     292             : }
     293             : 
     294           0 : SwPaMItem::SwPaMItem( const sal_uInt16 nId, SwPaM* pPaM ) :
     295             :     SfxPoolItem( nId ),
     296           0 :     m_pPaM(pPaM)
     297             : {
     298           0 : }
     299             : 
     300           0 : SwPaMItem::SwPaMItem( const SwPaMItem& rItem ) : SfxPoolItem( rItem )
     301             : {
     302           0 :     m_pPaM = rItem.m_pPaM;
     303           0 : }
     304             : 
     305           0 : SfxPoolItem* SwPaMItem::Clone( SfxItemPool * /*pPool*/ ) const
     306             : {
     307           0 :     return new SwPaMItem( *this );
     308             : }
     309             : 
     310           0 : bool SwPaMItem::operator==( const SfxPoolItem& rAttr ) const
     311             : {
     312             :     OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
     313           0 :     const SwPaMItem& rItem = (SwPaMItem&)rAttr;
     314           0 :     return ( m_pPaM == rItem.m_pPaM );
     315             : }
     316             : 
     317             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10