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

Generated by: LCOV version 1.11