LCOV - code coverage report
Current view: top level - sw/source/core/para - paratr.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 81 104 77.9 %
Date: 2014-04-11 Functions: 32 37 86.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 "hintids.hxx"
      21             : #include <swtypes.hxx>
      22             : #include "unomid.h"
      23             : #include <com/sun/star/style/LineSpacingMode.hpp>
      24             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      25             : #include <com/sun/star/style/DropCapFormat.hpp>
      26             : #include <com/sun/star/style/LineSpacing.hpp>
      27             : #include <com/sun/star/text/RelOrientation.hpp>
      28             : #include <com/sun/star/text/VertOrientation.hpp>
      29             : #include <com/sun/star/text/HorizontalAdjust.hpp>
      30             : #include <com/sun/star/text/DocumentStatistic.hpp>
      31             : #include <com/sun/star/text/HoriOrientation.hpp>
      32             : #include <com/sun/star/text/HoriOrientationFormat.hpp>
      33             : #include <com/sun/star/text/NotePrintMode.hpp>
      34             : #include <com/sun/star/text/SizeType.hpp>
      35             : #include <com/sun/star/text/VertOrientationFormat.hpp>
      36             : #include <com/sun/star/text/WrapTextMode.hpp>
      37             : #include <unostyle.hxx>
      38             : #include <SwStyleNameMapper.hxx>
      39             : #include "paratr.hxx"
      40             : #include "charfmt.hxx"
      41             : #include "cmdid.h"
      42             : 
      43             : using namespace ::com::sun::star;
      44             : 
      45        5786 : TYPEINIT2_AUTOFACTORY( SwFmtDrop, SfxPoolItem, SwClient);
      46        8950 : TYPEINIT1_AUTOFACTORY( SwRegisterItem, SfxBoolItem);
      47       90227 : TYPEINIT1_AUTOFACTORY( SwNumRuleItem, SfxStringItem);
      48        5655 : TYPEINIT1_AUTOFACTORY( SwParaConnectBorderItem, SfxBoolItem);
      49             : 
      50        1885 : SwFmtDrop::SwFmtDrop()
      51             :     : SfxPoolItem( RES_PARATR_DROP ),
      52             :     SwClient( 0 ),
      53             :     pDefinedIn( 0 ),
      54             :     nDistance( 0 ),
      55             :     nReadFmt( USHRT_MAX ),
      56             :     nLines( 0 ),
      57             :     nChars( 0 ),
      58        1885 :     bWholeWord( sal_False )
      59             : {
      60        1885 : }
      61             : 
      62       46778 : SwFmtDrop::SwFmtDrop( const SwFmtDrop &rCpy )
      63             :     : SfxPoolItem( RES_PARATR_DROP ),
      64             :     SwClient( rCpy.GetRegisteredInNonConst() ),
      65             :     pDefinedIn( 0 ),
      66       46778 :     nDistance( rCpy.GetDistance() ),
      67             :     nReadFmt( rCpy.nReadFmt ),
      68       46778 :     nLines( rCpy.GetLines() ),
      69       46778 :     nChars( rCpy.GetChars() ),
      70      187112 :     bWholeWord( rCpy.GetWholeWord() )
      71             : {
      72       46778 : }
      73             : 
      74       95478 : SwFmtDrop::~SwFmtDrop()
      75             : {
      76       95478 : }
      77             : 
      78           6 : void SwFmtDrop::SetCharFmt( SwCharFmt *pNew )
      79             : {
      80             :     // Rewire
      81           6 :     if ( GetRegisteredIn() )
      82           0 :         GetRegisteredInNonConst()->Remove( this );
      83           6 :     if(pNew)
      84           6 :         pNew->Add( this );
      85           6 :     nReadFmt = USHRT_MAX;
      86           6 : }
      87             : 
      88          12 : void SwFmtDrop::Modify( const SfxPoolItem*, const SfxPoolItem * )
      89             : {
      90          12 :     if( pDefinedIn )
      91             :     {
      92           6 :         if( !pDefinedIn->ISA( SwFmt ))
      93           6 :             pDefinedIn->ModifyNotification( this, this );
      94           0 :         else if( pDefinedIn->GetDepends() &&
      95           0 :                 !pDefinedIn->IsModifyLocked() )
      96             :         {
      97             :             // Notify those who are dependend on the format on our own.
      98             :             // The format itself wouldn't pass on the notify as it does not get past the check.
      99           0 :             pDefinedIn->ModifyBroadcast( this, this );
     100             :         }
     101             :     }
     102          12 : }
     103             : 
     104           4 : bool SwFmtDrop::GetInfo( SfxPoolItem& ) const
     105             : {
     106           4 :     return true; // Continue
     107             : }
     108             : 
     109          25 : bool SwFmtDrop::operator==( const SfxPoolItem& rAttr ) const
     110             : {
     111             :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "No mathing attributes" );
     112          50 :     return ( nLines == ((SwFmtDrop&)rAttr).GetLines() &&
     113          50 :              nChars == ((SwFmtDrop&)rAttr).GetChars() &&
     114          50 :              nDistance ==  ((SwFmtDrop&)rAttr).GetDistance() &&
     115          50 :              bWholeWord == ((SwFmtDrop&)rAttr).GetWholeWord() &&
     116          60 :              GetCharFmt() == ((SwFmtDrop&)rAttr).GetCharFmt() &&
     117          35 :              pDefinedIn == ((SwFmtDrop&)rAttr).pDefinedIn );
     118             : }
     119             : 
     120       46772 : SfxPoolItem* SwFmtDrop::Clone( SfxItemPool* ) const
     121             : {
     122       46772 :     return new SwFmtDrop( *this );
     123             : }
     124             : 
     125          37 : bool SwFmtDrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     126             : {
     127          37 :     switch(nMemberId&~CONVERT_TWIPS)
     128             :     {
     129           0 :         case MID_DROPCAP_LINES : rVal <<= (sal_Int16)nLines; break;
     130           0 :         case MID_DROPCAP_COUNT : rVal <<= (sal_Int16)nChars; break;
     131           0 :         case MID_DROPCAP_DISTANCE : rVal <<= (sal_Int16) TWIP_TO_MM100_UNSIGNED(nDistance); break;
     132             :         case MID_DROPCAP_FORMAT:
     133             :         {
     134          11 :              style::DropCapFormat aDrop;
     135          11 :             aDrop.Lines = nLines   ;
     136          11 :             aDrop.Count = nChars   ;
     137          11 :             aDrop.Distance  = TWIP_TO_MM100_UNSIGNED(nDistance);
     138          11 :             rVal.setValue(&aDrop, ::getCppuType((const style::DropCapFormat*)0));
     139             :         }
     140          11 :         break;
     141             :         case MID_DROPCAP_WHOLE_WORD:
     142          11 :             rVal.setValue(&bWholeWord, ::getBooleanCppuType());
     143          11 :         break;
     144             :         case MID_DROPCAP_CHAR_STYLE_NAME :
     145             :         {
     146          15 :             OUString sName;
     147          15 :             if(GetCharFmt())
     148             :                 sName = SwStyleNameMapper::GetProgName(
     149           8 :                         GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
     150          15 :             rVal <<= sName;
     151             :         }
     152          15 :         break;
     153             :     }
     154          37 :     return true;
     155             : }
     156             : 
     157          12 : bool SwFmtDrop::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     158             : {
     159          12 :     switch(nMemberId&~CONVERT_TWIPS)
     160             :     {
     161             :         case MID_DROPCAP_LINES :
     162             :         {
     163           0 :             sal_Int8 nTemp = 0;
     164           0 :             rVal >>= nTemp;
     165           0 :             if(nTemp >=1 && nTemp < 0x7f)
     166           0 :                 nLines = (sal_uInt8)nTemp;
     167             :         }
     168           0 :         break;
     169             :         case MID_DROPCAP_COUNT :
     170             :         {
     171           0 :             sal_Int16 nTemp = 0;
     172           0 :             rVal >>= nTemp;
     173           0 :             if(nTemp >=1 && nTemp < 0x7f)
     174           0 :                 nChars = (sal_uInt8)nTemp;
     175             :         }
     176           0 :         break;
     177             :         case MID_DROPCAP_DISTANCE :
     178             :         {
     179           0 :             sal_Int16 nVal = 0;
     180           0 :             if ( rVal >>= nVal )
     181           0 :                 nDistance = (sal_Int16) MM100_TO_TWIP((sal_Int32)nVal);
     182             :             else
     183           0 :                 return false;
     184           0 :             break;
     185             :         }
     186             :         case MID_DROPCAP_FORMAT:
     187             :         {
     188           6 :             if(rVal.getValueType()  == ::getCppuType((const style::DropCapFormat*)0))
     189             :             {
     190           6 :                 const style::DropCapFormat* pDrop = (const style::DropCapFormat*)rVal.getValue();
     191           6 :                 nLines      = pDrop->Lines;
     192           6 :                 nChars      = pDrop->Count;
     193           6 :                 nDistance   = MM100_TO_TWIP(pDrop->Distance);
     194             :             }
     195             :             else {
     196             :             }
     197             :         }
     198           6 :         break;
     199             :         case MID_DROPCAP_WHOLE_WORD:
     200           6 :             bWholeWord = *(sal_Bool*)rVal.getValue();
     201           6 :         break;
     202             :         case MID_DROPCAP_CHAR_STYLE_NAME :
     203             :             OSL_FAIL("char format cannot be set in PutValue()!");
     204           0 :         break;
     205             :     }
     206          12 :     return true;
     207             : }
     208             : 
     209             : /**
     210             :  * SwRegisterItem
     211             :  */
     212             : 
     213       14078 : SfxPoolItem* SwRegisterItem::Clone( SfxItemPool * ) const
     214             : {
     215       14078 :     return new SwRegisterItem( *this );
     216             : }
     217             : 
     218             : /**
     219             :  * SwNumRuleItem
     220             :  */
     221        1462 : SfxPoolItem* SwNumRuleItem::Clone( SfxItemPool * ) const
     222             : {
     223        1462 :     return new SwNumRuleItem( *this );
     224             : }
     225       17912 : bool SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const
     226             : {
     227             :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "No matching attributes" );
     228             : 
     229       17912 :     return GetValue() == ((SwNumRuleItem&)rAttr).GetValue();
     230             : }
     231             : 
     232         185 : bool    SwNumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
     233             : {
     234         185 :     OUString sRet = SwStyleNameMapper::GetProgName(GetValue(), nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
     235         185 :     rVal <<= sRet;
     236         185 :     return true;
     237             : }
     238             : 
     239          61 : bool    SwNumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 )
     240             : {
     241          61 :     OUString uName;
     242          61 :     rVal >>= uName;
     243          61 :     SetValue(SwStyleNameMapper::GetUIName(uName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE));
     244          61 :     return true;
     245             : }
     246             : 
     247           3 : SfxPoolItem* SwParaConnectBorderItem::Clone( SfxItemPool * ) const
     248             : {
     249           3 :     return new SwParaConnectBorderItem( *this );
     250             : }
     251             : 
     252             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10