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

Generated by: LCOV version 1.10