1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unonrule.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #define PROPERTY_NONE 0
36 #include <com/sun/star/text/HoriOrientation.hpp>
37 #include <com/sun/star/lang/XUnoTunnel.hpp>
38 #include <com/sun/star/awt/XBitmap.hpp>
39 #include <com/sun/star/beans/PropertyValue.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/util/XCloneable.hpp>
43 #include <cppuhelper/implbase1.hxx>
44 #include <cppuhelper/implbase5.hxx>
46 #include <svtools/itempool.hxx>
47 #include <goodies/grfmgr.hxx>
49 #include <vcl/svapp.hxx>
50 #include <vos/mutex.hxx>
51 #include <vcl/graph.hxx>
53 #include <comphelper/servicehelper.hxx>
54 #include <toolkit/unohlp.hxx>
56 #include <rtl/memory.h>
58 #include <svx/brshitem.hxx>
59 #include <svx/unoprnms.hxx>
60 #include <svx/numitem.hxx>
61 #include <svx/eeitem.hxx>
62 #include <svx/unotext.hxx>
63 #include <svx/svdmodel.hxx>
64 #include <svx/numitem.hxx>
65 #include "unofdesc.hxx"
66 #include "unonrule.hxx"
69 using ::rtl::OUString
;
70 using ::com::sun::star::util::XCloneable
;
71 using ::com::sun::star::ucb::XAnyCompare
;
74 using namespace ::vos
;
75 using namespace ::std
;
76 using namespace ::com::sun::star
;
77 using namespace ::com::sun::star::uno
;
78 using namespace ::com::sun::star::lang
;
79 using namespace ::com::sun::star::container
;
81 const SvxAdjust aUnoToSvxAdjust
[] =
92 const unsigned short aSvxToUnoAdjust
[] =
94 text::HoriOrientation::LEFT
,
95 text::HoriOrientation::RIGHT
,
96 text::HoriOrientation::FULL
,
97 text::HoriOrientation::CENTER
,
98 text::HoriOrientation::FULL
,
99 text::HoriOrientation::LEFT
102 SvxAdjust
ConvertUnoAdjust( unsigned short nAdjust
)
104 DBG_ASSERT( nAdjust
<= 7, "Enum hat sich geaendert! [CL]" );
105 return aUnoToSvxAdjust
[nAdjust
];
108 unsigned short ConvertUnoAdjust( SvxAdjust eAdjust
)
110 DBG_ASSERT( eAdjust
<= 6, "Enum hat sich geaendert! [CL]" );
111 return aSvxToUnoAdjust
[eAdjust
];
116 /******************************************************************
117 * SvxUnoNumberingRules
118 ******************************************************************/
120 class SvxUnoNumberingRules
: public ::cppu::WeakAggImplHelper5
< XIndexReplace
, XAnyCompare
, XUnoTunnel
, XCloneable
, XServiceInfo
>
125 SvxUnoNumberingRules( const SvxNumRule
& rRule
) throw();
126 virtual ~SvxUnoNumberingRules() throw();
128 UNO3_GETIMPLEMENTATION_DECL( SvxUnoNumberingRules
)
131 virtual void SAL_CALL
replaceByIndex( sal_Int32 Index
, const Any
& Element
) throw(IllegalArgumentException
, IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
);
134 virtual sal_Int32 SAL_CALL
getCount() throw(RuntimeException
) ;
135 virtual Any SAL_CALL
getByIndex( sal_Int32 Index
) throw(IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
);
138 virtual Type SAL_CALL
getElementType() throw(RuntimeException
);
139 virtual sal_Bool SAL_CALL
hasElements() throw(RuntimeException
);
142 virtual sal_Int16 SAL_CALL
compare( const Any
& Any1
, const Any
& Any2
) throw(RuntimeException
);
145 virtual Reference
< XCloneable
> SAL_CALL
createClone( ) throw (RuntimeException
);
148 virtual OUString SAL_CALL
getImplementationName( ) throw(RuntimeException
);
149 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(RuntimeException
);
150 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw(RuntimeException
);
153 Sequence
<beans::PropertyValue
> getNumberingRuleByIndex( sal_Int32 nIndex
) const throw();
154 void setNumberingRuleByIndex( const Sequence
< beans::PropertyValue
>& rProperties
, sal_Int32 nIndex
) throw( RuntimeException
, IllegalArgumentException
);
156 static sal_Int16
Compare( const Any
& rAny1
, const Any
& rAny2
);
158 const SvxNumRule
& getNumRule() const { return maRule
; }
161 UNO3_GETIMPLEMENTATION_IMPL( SvxUnoNumberingRules
);
163 SvxUnoNumberingRules::SvxUnoNumberingRules( const SvxNumRule
& rRule
) throw()
168 SvxUnoNumberingRules::~SvxUnoNumberingRules() throw()
173 void SAL_CALL
SvxUnoNumberingRules::replaceByIndex( sal_Int32 Index
, const uno::Any
& Element
)
174 throw( IllegalArgumentException
, IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
)
176 OGuard
aGuard( Application::GetSolarMutex() );
178 if( Index
< 0 || Index
>= maRule
.GetLevelCount() )
179 throw IndexOutOfBoundsException();
181 Sequence
< beans::PropertyValue
> aSeq
;
183 if( !( Element
>>= aSeq
) )
184 throw IllegalArgumentException();
185 setNumberingRuleByIndex( aSeq
, Index
);
189 sal_Int32 SAL_CALL
SvxUnoNumberingRules::getCount() throw( RuntimeException
)
191 OGuard
aGuard( Application::GetSolarMutex() );
193 return maRule
.GetLevelCount();
196 Any SAL_CALL
SvxUnoNumberingRules::getByIndex( sal_Int32 Index
)
197 throw( IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
)
199 OGuard
aGuard( Application::GetSolarMutex() );
201 if( Index
< 0 || Index
>= maRule
.GetLevelCount() )
202 throw IndexOutOfBoundsException();
204 return Any( getNumberingRuleByIndex(Index
) );
208 Type SAL_CALL
SvxUnoNumberingRules::getElementType()
209 throw( RuntimeException
)
211 return ::getCppuType(( const Sequence
< beans::PropertyValue
>*)0);
214 sal_Bool SAL_CALL
SvxUnoNumberingRules::hasElements() throw( RuntimeException
)
220 sal_Int16 SAL_CALL
SvxUnoNumberingRules::compare( const Any
& rAny1
, const Any
& rAny2
) throw(RuntimeException
)
222 return SvxUnoNumberingRules::Compare( rAny1
, rAny2
);
226 Reference
< XCloneable
> SAL_CALL
SvxUnoNumberingRules::createClone( ) throw (RuntimeException
)
228 return new SvxUnoNumberingRules(maRule
);
232 sal_Char pSvxUnoNumberingRulesService
[sizeof("com.sun.star.text.NumberingRules")] = "com.sun.star.text.NumberingRules";
234 OUString SAL_CALL
SvxUnoNumberingRules::getImplementationName( ) throw(RuntimeException
)
236 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoNumberingRules" ) );
239 sal_Bool SAL_CALL
SvxUnoNumberingRules::supportsService( const OUString
& ServiceName
) throw(RuntimeException
)
241 return ServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoNumberingRulesService
) );
244 Sequence
< OUString
> SAL_CALL
SvxUnoNumberingRules::getSupportedServiceNames( ) throw(RuntimeException
)
246 OUString
aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoNumberingRulesService
) );
247 Sequence
< OUString
> aSeq( &aService
, 1 );
251 Sequence
<beans::PropertyValue
> SvxUnoNumberingRules::getNumberingRuleByIndex( sal_Int32 nIndex
) const throw()
253 // NumberingRule aRule;
254 const SvxNumberFormat
& rFmt
= maRule
.GetLevel((sal_uInt16
) nIndex
);
257 const int nProps
= 15;
258 beans::PropertyValue
* pArray
= new beans::PropertyValue
[nProps
];
262 aVal
<<= rFmt
.GetNumberingType();
263 beans::PropertyValue
aAlignProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
264 pArray
[nIdx
++] = aAlignProp
;
268 SvxAdjust eAdj
= rFmt
.GetNumAdjust();
269 aVal
<<= ConvertUnoAdjust(eAdj
);
270 pArray
[nIdx
++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_ADJUST
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
274 aVal
<<= OUString(rFmt
.GetPrefix());
275 beans::PropertyValue
aPrefixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_PREFIX
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
276 pArray
[nIdx
++] = aPrefixProp
;
280 aVal
<<= OUString(rFmt
.GetSuffix());
281 beans::PropertyValue
aSuffixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_SUFFIX
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
282 pArray
[nIdx
++] = aSuffixProp
;
286 sal_Unicode nCode
= rFmt
.GetBulletChar();
287 OUString
aStr( &nCode
, 1 );
289 beans::PropertyValue
aBulletProp( OUString(RTL_CONSTASCII_USTRINGPARAM("BulletChar")), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
290 pArray
[nIdx
++] = aBulletProp
;
293 if( rFmt
.GetBulletFont() )
295 awt::FontDescriptor aDesc
;
296 SvxUnoFontDescriptor::ConvertFromFont( *rFmt
.GetBulletFont(), aDesc
);
297 aVal
.setValue(&aDesc
, ::getCppuType((const awt::FontDescriptor
*)0));
298 pArray
[nIdx
++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_FONT
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
302 const SvxBrushItem
* pBrush
= rFmt
.GetBrush();
303 if(pBrush
&& pBrush
->GetGraphicObject())
305 const GraphicObject
* pGrafObj
= pBrush
->GetGraphicObject();
306 OUString
aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX
));
307 aURL
+= OUString::createFromAscii( pGrafObj
->GetUniqueID().GetBuffer() );
310 const beans::PropertyValue
aGraphicProp( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
311 pArray
[nIdx
++] = aGraphicProp
;
316 const Size
aSize( rFmt
.GetGraphicSize() );
317 const awt::Size
aUnoSize( aSize
.Width(), aSize
.Height() );
319 const beans::PropertyValue
aGraphicSizeProp(OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicSize")), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
320 pArray
[nIdx
++] = aGraphicSizeProp
;
323 aVal
<<= (sal_Int16
)rFmt
.GetStart();
324 pArray
[nIdx
++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_START_WITH
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
326 aVal
<<= (sal_Int32
)rFmt
.GetAbsLSpace();
327 pArray
[nIdx
++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
329 aVal
<<= (sal_Int32
)rFmt
.GetFirstLineOffset();
330 pArray
[nIdx
++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
332 pArray
[nIdx
++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolTextDistance")), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
334 aVal
<<= (sal_Int32
)rFmt
.GetBulletColor().GetColor();
335 pArray
[nIdx
++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
337 aVal
<<= (sal_Int16
)rFmt
.GetBulletRelSize();
338 pArray
[nIdx
++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE
)), -1, aVal
, beans::PropertyState_DIRECT_VALUE
);
340 DBG_ASSERT( nIdx
<= nProps
, "FixMe: Array uebergelaufen!!!! [CL]" );
341 Sequence
< beans::PropertyValue
> aSeq(pArray
, nIdx
);
347 void SvxUnoNumberingRules::setNumberingRuleByIndex( const Sequence
< beans::PropertyValue
>& rProperties
, sal_Int32 nIndex
)
348 throw( RuntimeException
, IllegalArgumentException
)
350 SvxNumberFormat
aFmt(maRule
.GetLevel( (sal_uInt16
)nIndex
));
351 const beans::PropertyValue
* pPropArray
= rProperties
.getConstArray();
352 for(int i
= 0; i
< rProperties
.getLength(); i
++)
354 const beans::PropertyValue
& rProp
= pPropArray
[i
];
355 const OUString
& rPropName
= rProp
.Name
;
356 const Any
& aVal
= rProp
.Value
;
358 if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE
)))
360 sal_Int16 nSet
= sal_Int16();
366 case SVX_NUM_CHAR_SPECIAL
:
367 case SVX_NUM_ROMAN_UPPER
:
368 case SVX_NUM_ROMAN_LOWER
:
369 case SVX_NUM_CHARS_UPPER_LETTER
:
370 case SVX_NUM_CHARS_LOWER_LETTER
:
372 case SVX_NUM_NUMBER_NONE
:
373 case SVX_NUM_CHARS_UPPER_LETTER_N
:
374 case SVX_NUM_CHARS_LOWER_LETTER_N
:
375 aFmt
.SetNumberingType(nSet
);
379 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_PREFIX
)))
382 if( aVal
>>= aPrefix
)
384 aFmt
.SetPrefix(aPrefix
);
388 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_SUFFIX
)))
391 if( aVal
>>= aSuffix
)
393 aFmt
.SetSuffix(aSuffix
);
397 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLETID
)))
399 sal_Int16 nSet
= sal_Int16();
404 aFmt
.SetBulletChar(nSet
);
409 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("BulletChar")))
416 aFmt
.SetBulletChar(aStr
[0]);
420 aFmt
.SetBulletChar(0);
425 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_ADJUST
)))
427 sal_Int16 nAdjust
= sal_Int16();
428 if( aVal
>>= nAdjust
)
430 aFmt
.SetNumAdjust(ConvertUnoAdjust( (unsigned short)nAdjust
));
434 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_FONT
)))
436 awt::FontDescriptor aDesc
;
440 SvxUnoFontDescriptor::ConvertToFont( aDesc
, aFont
);
441 aFmt
.SetBulletFont(&aFont
);
445 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Graphic")))
447 Reference
< awt::XBitmap
> xBmp
;
450 Graphic
aGraf( VCLUnoHelper::GetBitmap( xBmp
) );
451 SvxBrushItem
aBrushItem(aGraf
, GPOS_AREA
, SID_ATTR_BRUSH
);
452 aFmt
.SetGraphicBrush( &aBrushItem
);
456 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicURL")))
461 GraphicObject
aGrafObj( CreateGraphicObjectFromURL( aURL
) );
462 SvxBrushItem
aBrushItem( aGrafObj
, GPOS_AREA
, SID_ATTR_BRUSH
);
463 aFmt
.SetGraphicBrush( &aBrushItem
);
467 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicSize")))
470 if( aVal
>>= aUnoSize
)
472 aFmt
.SetGraphicSize( Size( aUnoSize
.Width
, aUnoSize
.Height
) );
476 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_START_WITH
)))
478 sal_Int16 nStart
= sal_Int16();
479 if( aVal
>>= nStart
)
481 aFmt
.SetStart( nStart
);
485 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN
)))
487 sal_Int32 nMargin
= 0;
488 if( aVal
>>= nMargin
)
490 aFmt
.SetAbsLSpace((sal_uInt16
)nMargin
);
494 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET
)))
496 sal_Int32 nMargin
= 0;
497 if( aVal
>>= nMargin
)
499 aFmt
.SetFirstLineOffset((sal_uInt16
)nMargin
);
503 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SymbolTextDistance")))
505 sal_Int32 nTextDistance
= 0;
506 if( aVal
>>= nTextDistance
)
508 aFmt
.SetCharTextDistance((sal_uInt16
)nTextDistance
);
512 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR
)))
514 sal_Int32 nColor
= 0;
515 if( aVal
>>= nColor
)
517 aFmt
.SetBulletColor( (Color
) nColor
);
521 else if(rPropName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE
)))
523 sal_Int16 nSize
= sal_Int16();
526 aFmt
.SetBulletRelSize( (short)nSize
);
535 throw IllegalArgumentException();
538 // check that we always have a brush item for bitmap numbering
539 if( aFmt
.GetNumberingType() == SVX_NUM_BITMAP
)
541 if( NULL
== aFmt
.GetBrush() )
543 GraphicObject aGrafObj
;
544 SvxBrushItem
aBrushItem( aGrafObj
, GPOS_AREA
, SID_ATTR_BRUSH
);
545 aFmt
.SetGraphicBrush( &aBrushItem
);
548 maRule
.SetLevel( (sal_uInt16
)nIndex
, aFmt
);
551 ///////////////////////////////////////////////////////////////////////
553 const SvxNumRule
& SvxGetNumRule( Reference
< XIndexReplace
> xRule
) throw( IllegalArgumentException
)
555 SvxUnoNumberingRules
* pRule
= SvxUnoNumberingRules::getImplementation( xRule
);
557 throw IllegalArgumentException();
559 return pRule
->getNumRule();
562 bool SvxGetNumRule( Reference
< XIndexReplace
> xRule
, SvxNumRule
& rNumRule
)
564 SvxUnoNumberingRules
* pRule
= SvxUnoNumberingRules::getImplementation( xRule
);
567 rNumRule
= pRule
->getNumRule();
569 else if( xRule
.is() )
573 pRule
= new SvxUnoNumberingRules( rNumRule
);
575 Reference
< XIndexReplace
> xDestRule( pRule
);
577 const sal_Int32 nCount
= min( xRule
->getCount(), xDestRule
->getCount() );
579 for( nLevel
= 0; nLevel
< nCount
; nLevel
++ )
581 xDestRule
->replaceByIndex( nLevel
, xRule
->getByIndex( nLevel
) );
584 rNumRule
= pRule
->getNumRule();
599 ///////////////////////////////////////////////////////////////////////
601 Reference
< XIndexReplace
> SvxCreateNumRule( const SvxNumRule
* pRule
) throw()
603 DBG_ASSERT( pRule
, "No default SvxNumRule!" );
606 return new SvxUnoNumberingRules( *pRule
);
610 SvxNumRule
aDefaultRule( NUM_BULLET_REL_SIZE
|NUM_BULLET_COLOR
|NUM_CHAR_TEXT_DISTANCE
, 10 , FALSE
);
611 return new SvxUnoNumberingRules( aDefaultRule
);
615 ///////////////////////////////////////////////////////////////////////
617 Reference
< XIndexReplace
> SvxCreateNumRule( SdrModel
* pModel
) throw()
619 SvxNumRule
* pDefaultRule
= NULL
;
622 SvxNumBulletItem
* pItem
= (SvxNumBulletItem
*) pModel
->GetItemPool().GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET
);
625 pDefaultRule
= pItem
->GetNumRule();
631 return SvxCreateNumRule( pDefaultRule
);
635 SvxNumRule
aTempRule( 0, 10, false );
636 return SvxCreateNumRule( &aTempRule
);
640 ///////////////////////////////////////////////////////////////////////
642 class SvxUnoNumberingRulesCompare
: public ::cppu::WeakAggImplHelper1
< XAnyCompare
>
645 virtual sal_Int16 SAL_CALL
compare( const Any
& Any1
, const Any
& Any2
) throw(RuntimeException
);
648 sal_Int16 SAL_CALL
SvxUnoNumberingRulesCompare::compare( const Any
& Any1
, const Any
& Any2
) throw(RuntimeException
)
650 return SvxUnoNumberingRules::Compare( Any1
, Any2
);
653 sal_Int16
SvxUnoNumberingRules::Compare( const Any
& Any1
, const Any
& Any2
)
655 Reference
< XIndexReplace
> x1( Any1
, UNO_QUERY
), x2( Any2
, UNO_QUERY
);
656 if( x1
.is() && x2
.is() )
658 if( x1
.get() == x2
.get() )
661 SvxUnoNumberingRules
* pRule1
= SvxUnoNumberingRules::getImplementation( x1
);
664 SvxUnoNumberingRules
* pRule2
= SvxUnoNumberingRules::getImplementation( x2
);
667 const SvxNumRule
& rRule1
= pRule1
->getNumRule();
668 const SvxNumRule
& rRule2
= pRule2
->getNumRule();
670 const USHORT nLevelCount1
= rRule1
.GetLevelCount();
671 const USHORT nLevelCount2
= rRule2
.GetLevelCount();
673 if( nLevelCount1
== 0 || nLevelCount2
== 0 )
676 for( USHORT i
= 0; (i
< nLevelCount1
) && (i
< nLevelCount2
); i
++ )
678 if( rRule1
.GetLevel(i
) != rRule2
.GetLevel(i
) )
689 Reference
< XAnyCompare
> SvxCreateNumRuleCompare() throw()
691 return new SvxUnoNumberingRulesCompare();