LCOV - code coverage report
Current view: top level - libreoffice/editeng/source/uno - unonrule.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 108 248 43.5 %
Date: 2012-12-27 Functions: 16 29 55.2 %
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 <com/sun/star/text/HoriOrientation.hpp>
      21             : #include <com/sun/star/awt/XBitmap.hpp>
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : #include <osl/mutex.hxx>
      25             : #include <vcl/graph.hxx>
      26             : #include <svtools/grfmgr.hxx>
      27             : #include <toolkit/unohlp.hxx>
      28             : 
      29             : #include <editeng/brshitem.hxx>
      30             : #include <editeng/unoprnms.hxx>
      31             : #include <editeng/numitem.hxx>
      32             : #include <editeng/eeitem.hxx>
      33             : #include <editeng/unotext.hxx>
      34             : #include <editeng/unofdesc.hxx>
      35             : #include <editeng/unonrule.hxx>
      36             : #include <editeng/editids.hrc>
      37             : 
      38             : using ::rtl::OUString;
      39             : using ::com::sun::star::util::XCloneable;
      40             : using ::com::sun::star::ucb::XAnyCompare;
      41             : 
      42             : 
      43             : using namespace ::std;
      44             : using namespace ::com::sun::star;
      45             : using namespace ::com::sun::star::uno;
      46             : using namespace ::com::sun::star::lang;
      47             : using namespace ::com::sun::star::container;
      48             : 
      49             : const SvxAdjust aUnoToSvxAdjust[] =
      50             : {
      51             :     SVX_ADJUST_LEFT,
      52             :     SVX_ADJUST_RIGHT,
      53             :     SVX_ADJUST_CENTER,
      54             :     SVX_ADJUST_LEFT,
      55             :     SVX_ADJUST_LEFT,
      56             :     SVX_ADJUST_LEFT,
      57             :     SVX_ADJUST_BLOCK
      58             : };
      59             : 
      60             : const unsigned short aSvxToUnoAdjust[] =
      61             : {
      62             :     text::HoriOrientation::LEFT,
      63             :     text::HoriOrientation::RIGHT,
      64             :     text::HoriOrientation::FULL,
      65             :     text::HoriOrientation::CENTER,
      66             :     text::HoriOrientation::FULL,
      67             :     text::HoriOrientation::LEFT
      68             : };
      69             : 
      70         108 : SvxAdjust ConvertUnoAdjust( unsigned short nAdjust )
      71             : {
      72             :     DBG_ASSERT( nAdjust <= 7, "Enum hat sich geaendert! [CL]" );
      73         108 :     return aUnoToSvxAdjust[nAdjust];
      74             : }
      75             : 
      76           0 : unsigned short ConvertUnoAdjust( SvxAdjust eAdjust )
      77             : {
      78             :     DBG_ASSERT( eAdjust <= 6, "Enum hat sich geaendert! [CL]" );
      79           0 :     return aSvxToUnoAdjust[eAdjust];
      80             : }
      81             : 
      82             : /******************************************************************
      83             :  * SvxUnoNumberingRules
      84             :  ******************************************************************/
      85             : 
      86         180 : UNO3_GETIMPLEMENTATION_IMPL( SvxUnoNumberingRules );
      87             : 
      88         279 : SvxUnoNumberingRules::SvxUnoNumberingRules( const SvxNumRule& rRule ) throw()
      89         279 : : maRule( rRule )
      90             : {
      91         279 : }
      92             : 
      93         558 : SvxUnoNumberingRules::~SvxUnoNumberingRules() throw()
      94             : {
      95         558 : }
      96             : 
      97             : //XIndexReplace
      98         111 : void SAL_CALL SvxUnoNumberingRules::replaceByIndex( sal_Int32 Index, const uno::Any& Element )
      99             :     throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
     100             : {
     101         111 :     SolarMutexGuard aGuard;
     102             : 
     103         111 :     if( Index < 0 || Index >= maRule.GetLevelCount() )
     104           3 :         throw IndexOutOfBoundsException();
     105             : 
     106         108 :     Sequence< beans::PropertyValue > aSeq;
     107             : 
     108         108 :     if( !( Element >>= aSeq) )
     109           0 :         throw IllegalArgumentException();
     110         108 :     setNumberingRuleByIndex( aSeq, Index );
     111         108 : }
     112             : 
     113             : // XIndexAccess
     114           9 : sal_Int32 SAL_CALL SvxUnoNumberingRules::getCount() throw( RuntimeException )
     115             : {
     116           9 :     SolarMutexGuard aGuard;
     117             : 
     118           9 :     return maRule.GetLevelCount();
     119             : }
     120             : 
     121           0 : Any SAL_CALL SvxUnoNumberingRules::getByIndex( sal_Int32 Index )
     122             :     throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
     123             : {
     124           0 :     SolarMutexGuard aGuard;
     125             : 
     126           0 :     if( Index < 0 || Index >= maRule.GetLevelCount() )
     127           0 :         throw IndexOutOfBoundsException();
     128             : 
     129           0 :     return Any( getNumberingRuleByIndex(Index) );
     130             : }
     131             : 
     132             : //XElementAccess
     133           0 : Type SAL_CALL SvxUnoNumberingRules::getElementType()
     134             :     throw( RuntimeException )
     135             : {
     136           0 :     return ::getCppuType(( const Sequence< beans::PropertyValue >*)0);
     137             : }
     138             : 
     139           0 : sal_Bool SAL_CALL SvxUnoNumberingRules::hasElements() throw( RuntimeException )
     140             : {
     141           0 :     return sal_True;
     142             : }
     143             : 
     144             : // XAnyCompare
     145           0 : sal_Int16 SAL_CALL SvxUnoNumberingRules::compare( const Any& rAny1, const Any& rAny2 ) throw(RuntimeException)
     146             : {
     147           0 :     return SvxUnoNumberingRules::Compare( rAny1, rAny2 );
     148             : }
     149             : 
     150             : // XCloneable
     151           0 : Reference< XCloneable > SAL_CALL SvxUnoNumberingRules::createClone(  ) throw (RuntimeException)
     152             : {
     153           0 :     return new SvxUnoNumberingRules(maRule);
     154             : }
     155             : 
     156             : // XServiceInfo
     157             : const char pSvxUnoNumberingRulesService[] = "com.sun.star.text.NumberingRules";
     158             : 
     159           0 : OUString SAL_CALL SvxUnoNumberingRules::getImplementationName(  ) throw(RuntimeException)
     160             : {
     161           0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoNumberingRules" ) );
     162             : }
     163             : 
     164           0 : sal_Bool SAL_CALL SvxUnoNumberingRules::supportsService( const OUString& ServiceName ) throw(RuntimeException)
     165             : {
     166           0 :     return ServiceName == pSvxUnoNumberingRulesService;
     167             : }
     168             : 
     169           0 : Sequence< OUString > SAL_CALL SvxUnoNumberingRules::getSupportedServiceNames(  ) throw(RuntimeException)
     170             : {
     171           0 :     OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoNumberingRulesService ) );
     172           0 :     Sequence< OUString > aSeq( &aService, 1 );
     173           0 :     return aSeq;
     174             : }
     175             : 
     176           0 : Sequence<beans::PropertyValue> SvxUnoNumberingRules::getNumberingRuleByIndex( sal_Int32 nIndex) const throw()
     177             : {
     178             :     //  NumberingRule aRule;
     179           0 :     const SvxNumberFormat& rFmt = maRule.GetLevel((sal_uInt16) nIndex);
     180           0 :     sal_uInt16 nIdx = 0;
     181             : 
     182           0 :     const int nProps = 15;
     183           0 :     beans::PropertyValue* pArray = new beans::PropertyValue[nProps];
     184             : 
     185           0 :     Any aVal;
     186             :     {
     187           0 :         aVal <<= rFmt.GetNumberingType();
     188           0 :         beans::PropertyValue aAlignProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     189           0 :         pArray[nIdx++] = aAlignProp;
     190             :     }
     191             : 
     192             :     {
     193           0 :         SvxAdjust eAdj = rFmt.GetNumAdjust();
     194           0 :         aVal <<= ConvertUnoAdjust(eAdj);
     195           0 :         pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_ADJUST)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     196             :     }
     197             : 
     198             :     {
     199           0 :         aVal <<= OUString(rFmt.GetPrefix());
     200           0 :         beans::PropertyValue aPrefixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_PREFIX)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     201           0 :         pArray[nIdx++] = aPrefixProp;
     202             :     }
     203             : 
     204             :     {
     205           0 :         aVal <<= OUString(rFmt.GetSuffix());
     206           0 :         beans::PropertyValue aSuffixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_SUFFIX)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     207           0 :         pArray[nIdx++] = aSuffixProp;
     208             :     }
     209             : 
     210             :     {
     211           0 :         sal_Unicode nCode = rFmt.GetBulletChar();
     212           0 :         OUString aStr( &nCode, 1 );
     213           0 :         aVal <<= aStr;
     214           0 :         beans::PropertyValue aBulletProp( OUString(RTL_CONSTASCII_USTRINGPARAM("BulletChar")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     215           0 :         pArray[nIdx++] = aBulletProp;
     216             :     }
     217             : 
     218           0 :     if( rFmt.GetBulletFont() )
     219             :     {
     220           0 :         awt::FontDescriptor aDesc;
     221           0 :         SvxUnoFontDescriptor::ConvertFromFont( *rFmt.GetBulletFont(), aDesc );
     222           0 :         aVal.setValue(&aDesc, ::getCppuType((const awt::FontDescriptor*)0));
     223           0 :         pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_FONT)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     224             :     }
     225             : 
     226             :     {
     227           0 :         const SvxBrushItem* pBrush = rFmt.GetBrush();
     228           0 :         if(pBrush && pBrush->GetGraphicObject())
     229             :         {
     230           0 :             const GraphicObject* pGrafObj = pBrush->GetGraphicObject();
     231           0 :             OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
     232             :             aURL += OStringToOUString(pGrafObj->GetUniqueID(),
     233           0 :                 RTL_TEXTENCODING_ASCII_US);
     234             : 
     235           0 :             aVal <<= aURL;
     236           0 :             const beans::PropertyValue aGraphicProp( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     237           0 :             pArray[nIdx++] = aGraphicProp;
     238             :         }
     239             :     }
     240             : 
     241             :     {
     242           0 :         const Size aSize( rFmt.GetGraphicSize() );
     243           0 :         const awt::Size aUnoSize( aSize.Width(), aSize.Height() );
     244           0 :         aVal <<= aUnoSize;
     245           0 :         const beans::PropertyValue aGraphicSizeProp(OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicSize")), -1, aVal, beans::PropertyState_DIRECT_VALUE );
     246           0 :         pArray[nIdx++] = aGraphicSizeProp;
     247             :     }
     248             : 
     249           0 :     aVal <<= (sal_Int16)rFmt.GetStart();
     250           0 :     pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_START_WITH)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     251             : 
     252           0 :     aVal <<= (sal_Int32)rFmt.GetAbsLSpace();
     253           0 :     pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     254             : 
     255           0 :     aVal <<= (sal_Int32)rFmt.GetFirstLineOffset();
     256           0 :     pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     257             : 
     258           0 :     pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolTextDistance")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     259             : 
     260           0 :     aVal <<= (sal_Int32)rFmt.GetBulletColor().GetColor();
     261           0 :     pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     262             : 
     263           0 :     aVal <<= (sal_Int16)rFmt.GetBulletRelSize();
     264           0 :     pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
     265             : 
     266             :     DBG_ASSERT( nIdx <= nProps, "FixMe: overflow in Array!!! [CL]" );
     267           0 :     Sequence< beans::PropertyValue> aSeq(pArray, nIdx);
     268             : 
     269           0 :     delete [] pArray;
     270           0 :     return aSeq;
     271             : }
     272             : 
     273         108 : void SvxUnoNumberingRules::setNumberingRuleByIndex( const Sequence< beans::PropertyValue >& rProperties, sal_Int32 nIndex)
     274             :     throw( RuntimeException, IllegalArgumentException )
     275             : {
     276         108 :     SvxNumberFormat aFmt(maRule.GetLevel( (sal_uInt16)nIndex ));
     277         108 :     const beans::PropertyValue* pPropArray = rProperties.getConstArray();
     278        1489 :     for(int i = 0; i < rProperties.getLength(); i++)
     279             :     {
     280        1381 :         const beans::PropertyValue& rProp = pPropArray[i];
     281        1381 :         const OUString& rPropName = rProp.Name;
     282        1381 :         const Any& aVal = rProp.Value;
     283             : 
     284        1381 :         if ( rPropName == UNO_NAME_NRULE_NUMBERINGTYPE )
     285             :         {
     286          93 :             sal_Int16 nSet = sal_Int16();
     287          93 :             aVal >>= nSet;
     288             : 
     289          93 :             switch(nSet)
     290             :             {
     291             :             case SVX_NUM_BITMAP:
     292             :             case SVX_NUM_CHAR_SPECIAL:
     293             :             case SVX_NUM_ROMAN_UPPER:
     294             :             case SVX_NUM_ROMAN_LOWER:
     295             :             case SVX_NUM_CHARS_UPPER_LETTER:
     296             :             case SVX_NUM_CHARS_LOWER_LETTER:
     297             :             case SVX_NUM_ARABIC:
     298             :             case SVX_NUM_NUMBER_NONE:
     299             :             case SVX_NUM_CHARS_UPPER_LETTER_N:
     300             :             case SVX_NUM_CHARS_LOWER_LETTER_N:
     301          93 :                 aFmt.SetNumberingType(nSet);
     302          93 :                 continue;
     303             :             }
     304             :         }
     305        1288 :         else if ( rPropName == UNO_NAME_NRULE_PREFIX )
     306             :         {
     307          70 :             OUString aPrefix;
     308          70 :             if( aVal >>= aPrefix )
     309             :             {
     310          70 :                 aFmt.SetPrefix(aPrefix);
     311          70 :                 continue;
     312          70 :             }
     313             :         }
     314        1218 :         else if ( rPropName == UNO_NAME_NRULE_SUFFIX )
     315             :         {
     316          70 :             OUString aSuffix;
     317          70 :             if( aVal >>= aSuffix )
     318             :             {
     319          70 :                 aFmt.SetSuffix(aSuffix);
     320          70 :                 continue;
     321          70 :             }
     322             :         }
     323        1148 :         else if ( rPropName == UNO_NAME_NRULE_BULLETID )
     324             :         {
     325           0 :             sal_Int16 nSet = sal_Int16();
     326           0 :             if( aVal >>= nSet )
     327             :             {
     328           0 :                 if(nSet < 0x100)
     329             :                 {
     330           0 :                     aFmt.SetBulletChar(nSet);
     331           0 :                     continue;
     332             :                 }
     333             :             }
     334             :         }
     335        1148 :         else if ( rPropName == "BulletChar" )
     336             :         {
     337          91 :             OUString aStr;
     338          91 :             if( aVal >>= aStr )
     339             :             {
     340          91 :                 if(!aStr.isEmpty())
     341             :                 {
     342          91 :                     aFmt.SetBulletChar(aStr[0]);
     343             :                 }
     344             :                 else
     345             :                 {
     346           0 :                     aFmt.SetBulletChar(0);
     347             :                 }
     348          91 :                 continue;
     349          91 :             }
     350             :         }
     351        1057 :         else if ( rPropName == UNO_NAME_NRULE_ADJUST )
     352             :         {
     353         108 :             sal_Int16 nAdjust = sal_Int16();
     354         108 :             if( aVal >>= nAdjust )
     355             :             {
     356         108 :                 aFmt.SetNumAdjust(ConvertUnoAdjust( (unsigned short)nAdjust ));
     357         108 :                 continue;
     358             :             }
     359             :         }
     360         949 :         else if ( rPropName == UNO_NAME_NRULE_BULLET_FONT )
     361             :         {
     362          73 :             awt::FontDescriptor aDesc;
     363          73 :             if( aVal >>= aDesc )
     364             :             {
     365          73 :                 Font aFont;
     366          73 :                 SvxUnoFontDescriptor::ConvertToFont( aDesc, aFont );
     367          73 :                 aFmt.SetBulletFont(&aFont);
     368          73 :                 continue;
     369          73 :             }
     370             :         }
     371         876 :         else if ( rPropName == "Graphic" )
     372             :         {
     373           0 :             Reference< awt::XBitmap > xBmp;
     374           0 :             if( aVal >>= xBmp )
     375             :             {
     376           0 :                 Graphic aGraf( VCLUnoHelper::GetBitmap( xBmp ) );
     377           0 :                 SvxBrushItem aBrushItem(aGraf, GPOS_AREA, SID_ATTR_BRUSH);
     378           0 :                 aFmt.SetGraphicBrush( &aBrushItem );
     379           0 :                 continue;
     380           0 :             }
     381             :         }
     382         876 :         else if ( rPropName == "GraphicURL" )
     383             :         {
     384           0 :             OUString aURL;
     385           0 :             if( aVal >>= aURL )
     386             :             {
     387           0 :                 GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) );
     388           0 :                 SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH );
     389           0 :                 aFmt.SetGraphicBrush( &aBrushItem );
     390           0 :                 continue;
     391           0 :             }
     392             :         }
     393         876 :         else if ( rPropName == "GraphicSize" )
     394             :         {
     395           0 :             awt::Size aUnoSize;
     396           0 :             if( aVal >>= aUnoSize )
     397             :             {
     398           0 :                 aFmt.SetGraphicSize( Size( aUnoSize.Width, aUnoSize.Height ) );
     399           0 :                 continue;
     400             :             }
     401             :         }
     402         876 :         else if ( rPropName == UNO_NAME_NRULE_START_WITH )
     403             :         {
     404           0 :             sal_Int16 nStart = sal_Int16();
     405           0 :             if( aVal >>= nStart )
     406             :             {
     407           0 :                 aFmt.SetStart( nStart );
     408           0 :                 continue;
     409             :             }
     410             :         }
     411         876 :         else if ( rPropName == UNO_NAME_NRULE_LEFT_MARGIN )
     412             :         {
     413          79 :             sal_Int32 nMargin = 0;
     414          79 :             if( aVal >>= nMargin )
     415             :             {
     416          79 :                 aFmt.SetAbsLSpace((sal_uInt16)nMargin);
     417          79 :                 continue;
     418             :             }
     419             :         }
     420         797 :         else if ( rPropName == UNO_NAME_NRULE_FIRST_LINE_OFFSET )
     421             :         {
     422          79 :             sal_Int32 nMargin = 0;
     423          79 :             if( aVal >>= nMargin )
     424             :             {
     425          79 :                 aFmt.SetFirstLineOffset((sal_uInt16)nMargin);
     426          79 :                 continue;
     427             :             }
     428             :         }
     429         718 :         else if ( rPropName == "SymbolTextDistance" )
     430             :         {
     431          70 :             sal_Int32 nTextDistance = 0;
     432          70 :             if( aVal >>= nTextDistance )
     433             :             {
     434          70 :                 aFmt.SetCharTextDistance((sal_uInt16)nTextDistance);
     435          70 :                 continue;
     436             :             }
     437             :         }
     438         648 :         else if ( rPropName == UNO_NAME_NRULE_BULLET_COLOR )
     439             :         {
     440          79 :             sal_Int32 nColor = 0;
     441          79 :             if( aVal >>= nColor )
     442             :             {
     443          79 :                 aFmt.SetBulletColor( (Color) nColor );
     444          79 :                 continue;
     445             :             }
     446             :         }
     447         569 :         else if ( rPropName == UNO_NAME_NRULE_BULLET_RELSIZE )
     448             :         {
     449         108 :             sal_Int16 nSize = sal_Int16();
     450         108 :             if( aVal >>= nSize )
     451             :             {
     452         108 :                 aFmt.SetBulletRelSize( (short)nSize );
     453         108 :                 continue;
     454             :             }
     455             :         }
     456             :         else
     457             :         {
     458         461 :             continue;
     459             :         }
     460             : 
     461           0 :         throw IllegalArgumentException();
     462             :     }
     463             : 
     464             :     // check that we always have a brush item for bitmap numbering
     465         108 :     if( aFmt.GetNumberingType() == SVX_NUM_BITMAP )
     466             :     {
     467           0 :         if( NULL == aFmt.GetBrush() )
     468             :         {
     469           0 :             GraphicObject aGrafObj;
     470           0 :             SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH );
     471           0 :             aFmt.SetGraphicBrush( &aBrushItem );
     472             :         }
     473             :     }
     474         108 :     maRule.SetLevel( (sal_uInt16)nIndex, aFmt );
     475         108 : }
     476             : 
     477             : ///////////////////////////////////////////////////////////////////////
     478             : 
     479          45 : const SvxNumRule& SvxGetNumRule( Reference< XIndexReplace > xRule ) throw( IllegalArgumentException )
     480             : {
     481          45 :     SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule );
     482          45 :     if( pRule == NULL )
     483           0 :         throw IllegalArgumentException();
     484             : 
     485          45 :     return pRule->getNumRule();
     486             : }
     487             : 
     488         279 : com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( const SvxNumRule* pRule ) throw()
     489             : {
     490             :     DBG_ASSERT( pRule, "No default SvxNumRule!" );
     491         279 :     if( pRule )
     492             :     {
     493         279 :         return new SvxUnoNumberingRules( *pRule );
     494             :     }
     495             :     else
     496             :     {
     497           0 :         SvxNumRule aDefaultRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, 10 , sal_False);
     498           0 :         return new SvxUnoNumberingRules( aDefaultRule );
     499             :     }
     500             : }
     501             : 
     502             : 
     503             : ///////////////////////////////////////////////////////////////////////
     504             : 
     505          33 : class SvxUnoNumberingRulesCompare : public ::cppu::WeakAggImplHelper1< XAnyCompare >
     506             : {
     507             : public:
     508             :     virtual sal_Int16 SAL_CALL compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException);
     509             : };
     510             : 
     511           0 : sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException)
     512             : {
     513           0 :     return SvxUnoNumberingRules::Compare( Any1, Any2 );
     514             : }
     515             : 
     516           0 : sal_Int16 SvxUnoNumberingRules::Compare( const Any& Any1, const Any& Any2 )
     517             : {
     518           0 :     Reference< XIndexReplace > x1( Any1, UNO_QUERY ), x2( Any2, UNO_QUERY );
     519           0 :     if( x1.is() && x2.is() )
     520             :     {
     521           0 :         if( x1.get() == x2.get() )
     522           0 :             return 0;
     523             : 
     524           0 :         SvxUnoNumberingRules* pRule1 = SvxUnoNumberingRules::getImplementation( x1 );
     525           0 :         if( pRule1 )
     526             :         {
     527           0 :             SvxUnoNumberingRules* pRule2 = SvxUnoNumberingRules::getImplementation( x2 );
     528           0 :             if( pRule2 )
     529             :             {
     530           0 :                 const SvxNumRule& rRule1 = pRule1->getNumRule();
     531           0 :                 const SvxNumRule& rRule2 = pRule2->getNumRule();
     532             : 
     533           0 :                 const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount();
     534           0 :                 const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount();
     535             : 
     536           0 :                 if( nLevelCount1 == 0 || nLevelCount2 == 0 )
     537           0 :                     return -1;
     538             : 
     539           0 :                 for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ )
     540             :                 {
     541           0 :                     if( rRule1.GetLevel(i) != rRule2.GetLevel(i) )
     542           0 :                         return -1;
     543             :                 }
     544           0 :                 return  0;
     545             :             }
     546             :         }
     547             :     }
     548             : 
     549           0 :     return -1;
     550             : }
     551             : 
     552          11 : Reference< XAnyCompare > SvxCreateNumRuleCompare() throw()
     553             : {
     554          11 :     return new SvxUnoNumberingRulesCompare();
     555             : }
     556             : 
     557           0 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > SvxCreateNumRule() throw()
     558             : {
     559           0 :     SvxNumRule aTempRule( 0, 10, false );
     560           0 :     return SvxCreateNumRule( &aTempRule );
     561             : }
     562             : 
     563             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10