xref: /AOO41X/main/editeng/source/uno/unonrule.cxx (revision 9b8096d048072d5e312699b7e51b3b8a9f64fe9a)
1190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5190118d0SAndrew Rist  * distributed with this work for additional information
6190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14190118d0SAndrew Rist  * software distributed under the License is distributed on an
15190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17190118d0SAndrew Rist  * specific language governing permissions and limitations
18190118d0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20190118d0SAndrew Rist  *************************************************************/
21190118d0SAndrew Rist 
22190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define PROPERTY_NONE 0
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <vcl/svapp.hxx>
33cdf0e10cSrcweir #include <vos/mutex.hxx>
34cdf0e10cSrcweir #include <vcl/graph.hxx>
35cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
36cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
37cdf0e10cSrcweir #include <rtl/uuid.h>
38cdf0e10cSrcweir #include <rtl/memory.h>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <editeng/brshitem.hxx>
41cdf0e10cSrcweir #include <editeng/unoprnms.hxx>
42cdf0e10cSrcweir #include <editeng/numitem.hxx>
43cdf0e10cSrcweir #include <editeng/eeitem.hxx>
44cdf0e10cSrcweir #include <editeng/unotext.hxx>
45cdf0e10cSrcweir #include <editeng/numitem.hxx>
46cdf0e10cSrcweir #include <editeng/unofdesc.hxx>
47cdf0e10cSrcweir #include <editeng/unonrule.hxx>
48cdf0e10cSrcweir #include <editeng/editids.hrc>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir using ::rtl::OUString;
51cdf0e10cSrcweir using ::com::sun::star::util::XCloneable;
52cdf0e10cSrcweir using ::com::sun::star::ucb::XAnyCompare;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir using namespace ::vos;
56cdf0e10cSrcweir using namespace ::std;
57cdf0e10cSrcweir using namespace ::com::sun::star;
58cdf0e10cSrcweir using namespace ::com::sun::star::uno;
59cdf0e10cSrcweir using namespace ::com::sun::star::lang;
60cdf0e10cSrcweir using namespace ::com::sun::star::container;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir const SvxAdjust aUnoToSvxAdjust[] =
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	SVX_ADJUST_LEFT,
65cdf0e10cSrcweir 	SVX_ADJUST_RIGHT,
66cdf0e10cSrcweir 	SVX_ADJUST_CENTER,
67cdf0e10cSrcweir 	SVX_ADJUST_LEFT,
68cdf0e10cSrcweir 	SVX_ADJUST_LEFT,
69cdf0e10cSrcweir 	SVX_ADJUST_LEFT,
70cdf0e10cSrcweir 	SVX_ADJUST_BLOCK
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir const unsigned short aSvxToUnoAdjust[] =
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	text::HoriOrientation::LEFT,
76cdf0e10cSrcweir 	text::HoriOrientation::RIGHT,
77cdf0e10cSrcweir 	text::HoriOrientation::FULL,
78cdf0e10cSrcweir 	text::HoriOrientation::CENTER,
79cdf0e10cSrcweir 	text::HoriOrientation::FULL,
80cdf0e10cSrcweir 	text::HoriOrientation::LEFT
81cdf0e10cSrcweir };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir SvxAdjust ConvertUnoAdjust( unsigned short nAdjust )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	DBG_ASSERT( nAdjust <= 7, "Enum hat sich geaendert! [CL]" );
86cdf0e10cSrcweir 	return aUnoToSvxAdjust[nAdjust];
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir unsigned short ConvertUnoAdjust( SvxAdjust eAdjust )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	DBG_ASSERT( eAdjust <= 6, "Enum hat sich geaendert! [CL]" );
92cdf0e10cSrcweir 	return aSvxToUnoAdjust[eAdjust];
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /******************************************************************
96cdf0e10cSrcweir  * SvxUnoNumberingRules
97cdf0e10cSrcweir  ******************************************************************/
98cdf0e10cSrcweir 
99cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SvxUnoNumberingRules );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir SvxUnoNumberingRules::SvxUnoNumberingRules( const SvxNumRule& rRule ) throw()
102cdf0e10cSrcweir : maRule( rRule )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir SvxUnoNumberingRules::~SvxUnoNumberingRules() throw()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //XIndexReplace
111cdf0e10cSrcweir void SAL_CALL SvxUnoNumberingRules::replaceByIndex( sal_Int32 Index, const uno::Any& Element )
112cdf0e10cSrcweir 	throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	if( Index < 0 || Index >= maRule.GetLevelCount() )
117cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	Sequence< beans::PropertyValue > aSeq;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	if( !( Element >>= aSeq) )
122cdf0e10cSrcweir 		throw IllegalArgumentException();
123cdf0e10cSrcweir 	setNumberingRuleByIndex( aSeq, Index );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir // XIndexAccess
127cdf0e10cSrcweir sal_Int32 SAL_CALL SvxUnoNumberingRules::getCount() throw( RuntimeException )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	return maRule.GetLevelCount();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir Any SAL_CALL SvxUnoNumberingRules::getByIndex( sal_Int32 Index )
135cdf0e10cSrcweir 	throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	if( Index < 0 || Index >= maRule.GetLevelCount() )
140cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	return Any( getNumberingRuleByIndex(Index) );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir //XElementAccess
146cdf0e10cSrcweir Type SAL_CALL SvxUnoNumberingRules::getElementType()
147cdf0e10cSrcweir 	throw( RuntimeException )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir 	return ::getCppuType(( const Sequence< beans::PropertyValue >*)0);
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoNumberingRules::hasElements() throw( RuntimeException )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	return sal_True;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir // XAnyCompare
158cdf0e10cSrcweir sal_Int16 SAL_CALL SvxUnoNumberingRules::compare( const Any& rAny1, const Any& rAny2 ) throw(RuntimeException)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir     return SvxUnoNumberingRules::Compare( rAny1, rAny2 );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir // XCloneable
164cdf0e10cSrcweir Reference< XCloneable > SAL_CALL SvxUnoNumberingRules::createClone(  ) throw (RuntimeException)
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     return new SvxUnoNumberingRules(maRule);
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // XServiceInfo
170cdf0e10cSrcweir sal_Char pSvxUnoNumberingRulesService[sizeof("com.sun.star.text.NumberingRules")] = "com.sun.star.text.NumberingRules";
171cdf0e10cSrcweir 
172cdf0e10cSrcweir OUString SAL_CALL SvxUnoNumberingRules::getImplementationName(  ) throw(RuntimeException)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoNumberingRules" ) );
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoNumberingRules::supportsService( const OUString& ServiceName ) throw(RuntimeException)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir 	return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoNumberingRulesService ) );
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir Sequence< OUString > SAL_CALL SvxUnoNumberingRules::getSupportedServiceNames(  ) throw(RuntimeException)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoNumberingRulesService ) );
185cdf0e10cSrcweir 	Sequence< OUString > aSeq( &aService, 1 );
186cdf0e10cSrcweir 	return aSeq;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir Sequence<beans::PropertyValue> SvxUnoNumberingRules::getNumberingRuleByIndex( sal_Int32 nIndex) const throw()
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	//	NumberingRule aRule;
192cdf0e10cSrcweir 	const SvxNumberFormat& rFmt = maRule.GetLevel((sal_uInt16) nIndex);
193cdf0e10cSrcweir 	sal_uInt16 nIdx = 0;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	const int nProps = 15;
196cdf0e10cSrcweir 	beans::PropertyValue* pArray = new beans::PropertyValue[nProps];
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	Any aVal;
199cdf0e10cSrcweir 	{
200cdf0e10cSrcweir 		aVal <<= rFmt.GetNumberingType();
201cdf0e10cSrcweir 		beans::PropertyValue aAlignProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
202cdf0e10cSrcweir 		pArray[nIdx++] = aAlignProp;
203cdf0e10cSrcweir 	}
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	{
206cdf0e10cSrcweir 		SvxAdjust eAdj = rFmt.GetNumAdjust();
207cdf0e10cSrcweir 		aVal <<= ConvertUnoAdjust(eAdj);
208cdf0e10cSrcweir 		pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_ADJUST)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
209cdf0e10cSrcweir 	}
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	{
212cdf0e10cSrcweir 		aVal <<= OUString(rFmt.GetPrefix());
213cdf0e10cSrcweir 		beans::PropertyValue aPrefixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_PREFIX)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
214cdf0e10cSrcweir 		pArray[nIdx++] = aPrefixProp;
215cdf0e10cSrcweir 	}
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	{
218cdf0e10cSrcweir 		aVal <<= OUString(rFmt.GetSuffix());
219cdf0e10cSrcweir 		beans::PropertyValue aSuffixProp( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_SUFFIX)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
220cdf0e10cSrcweir 		pArray[nIdx++] = aSuffixProp;
221cdf0e10cSrcweir 	}
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	{
224*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
225*9b8096d0SSteve Yin 		if(SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
226*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
227*9b8096d0SSteve Yin 		{
228cdf0e10cSrcweir 		sal_Unicode nCode = rFmt.GetBulletChar();
229cdf0e10cSrcweir 		OUString aStr( &nCode, 1 );
230cdf0e10cSrcweir 		aVal <<= aStr;
231cdf0e10cSrcweir 		beans::PropertyValue aBulletProp( OUString(RTL_CONSTASCII_USTRINGPARAM("BulletChar")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
232cdf0e10cSrcweir 		pArray[nIdx++] = aBulletProp;
233cdf0e10cSrcweir 		}
234*9b8096d0SSteve Yin 	}
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	if( rFmt.GetBulletFont() )
237cdf0e10cSrcweir 	{
238cdf0e10cSrcweir 		awt::FontDescriptor aDesc;
239cdf0e10cSrcweir 		SvxUnoFontDescriptor::ConvertFromFont( *rFmt.GetBulletFont(), aDesc );
240cdf0e10cSrcweir 		aVal.setValue(&aDesc, ::getCppuType((const awt::FontDescriptor*)0));
241cdf0e10cSrcweir 		pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_FONT)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
242cdf0e10cSrcweir 	}
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 		const SvxBrushItem* pBrush = rFmt.GetBrush();
246cdf0e10cSrcweir 		if(pBrush && pBrush->GetGraphicObject())
247cdf0e10cSrcweir 		{
248cdf0e10cSrcweir 			const GraphicObject* pGrafObj = pBrush->GetGraphicObject();
249cdf0e10cSrcweir 			OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
250cdf0e10cSrcweir 			aURL += OUString::createFromAscii( pGrafObj->GetUniqueID().GetBuffer() );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 			aVal <<= aURL;
253cdf0e10cSrcweir 			const beans::PropertyValue aGraphicProp( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
254cdf0e10cSrcweir 			pArray[nIdx++] = aGraphicProp;
255cdf0e10cSrcweir 		}
256cdf0e10cSrcweir 	}
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	{
259cdf0e10cSrcweir 		const Size aSize( rFmt.GetGraphicSize() );
260cdf0e10cSrcweir 		const awt::Size aUnoSize( aSize.Width(), aSize.Height() );
261cdf0e10cSrcweir 		aVal <<= aUnoSize;
262cdf0e10cSrcweir 		const beans::PropertyValue aGraphicSizeProp(OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicSize")), -1, aVal, beans::PropertyState_DIRECT_VALUE );
263cdf0e10cSrcweir 		pArray[nIdx++] = aGraphicSizeProp;
264cdf0e10cSrcweir 	}
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	aVal <<= (sal_Int16)rFmt.GetStart();
267cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_START_WITH)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 	aVal <<= (sal_Int32)rFmt.GetAbsLSpace();
270cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	aVal <<= (sal_Int32)rFmt.GetFirstLineOffset();
273cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolTextDistance")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 	aVal <<= (sal_Int32)rFmt.GetBulletColor().GetColor();
278cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	aVal <<= (sal_Int16)rFmt.GetBulletRelSize();
281cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	DBG_ASSERT( nIdx <= nProps, "FixMe: Array uebergelaufen!!!! [CL]" );
284cdf0e10cSrcweir 	Sequence< beans::PropertyValue> aSeq(pArray, nIdx);
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	delete [] pArray;
287cdf0e10cSrcweir 	return aSeq;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir void SvxUnoNumberingRules::setNumberingRuleByIndex(	const Sequence< beans::PropertyValue >& rProperties, sal_Int32 nIndex)
291cdf0e10cSrcweir 	throw( RuntimeException, IllegalArgumentException )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir 	SvxNumberFormat aFmt(maRule.GetLevel( (sal_uInt16)nIndex ));
294cdf0e10cSrcweir 	const beans::PropertyValue* pPropArray = rProperties.getConstArray();
295cdf0e10cSrcweir 	for(int i = 0; i < rProperties.getLength(); i++)
296cdf0e10cSrcweir 	{
297cdf0e10cSrcweir 		const beans::PropertyValue& rProp = pPropArray[i];
298cdf0e10cSrcweir 		const OUString& rPropName = rProp.Name;
299cdf0e10cSrcweir 		const Any& aVal = rProp.Value;
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 		if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE)))
302cdf0e10cSrcweir 		{
303cdf0e10cSrcweir 			sal_Int16 nSet = sal_Int16();
304cdf0e10cSrcweir 			aVal >>= nSet;
305cdf0e10cSrcweir 
30694a565f3SAndre Fischer 			// There is no reason to limit numbering types.
30794a565f3SAndre Fischer 			if ( nSet>=0 )
308cdf0e10cSrcweir 			{
309cdf0e10cSrcweir 				aFmt.SetNumberingType(nSet);
310cdf0e10cSrcweir 				continue;
311cdf0e10cSrcweir 			}
312cdf0e10cSrcweir 		}
313cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_PREFIX)))
314cdf0e10cSrcweir 		{
315cdf0e10cSrcweir 			OUString aPrefix;
316cdf0e10cSrcweir 			if( aVal >>= aPrefix )
317cdf0e10cSrcweir 			{
318cdf0e10cSrcweir 				aFmt.SetPrefix(aPrefix);
319cdf0e10cSrcweir 				continue;
320cdf0e10cSrcweir 			}
321cdf0e10cSrcweir 		}
322cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_SUFFIX)))
323cdf0e10cSrcweir 		{
324cdf0e10cSrcweir 			OUString aSuffix;
325cdf0e10cSrcweir 			if( aVal >>= aSuffix )
326cdf0e10cSrcweir 			{
327cdf0e10cSrcweir 				aFmt.SetSuffix(aSuffix);
328cdf0e10cSrcweir 				continue;
329cdf0e10cSrcweir 			}
330cdf0e10cSrcweir 		}
331cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLETID)))
332cdf0e10cSrcweir 		{
333cdf0e10cSrcweir 			sal_Int16 nSet = sal_Int16();
334cdf0e10cSrcweir 			if( aVal >>= nSet )
335cdf0e10cSrcweir 			{
336cdf0e10cSrcweir 				if(nSet < 0x100)
337cdf0e10cSrcweir 				{
338cdf0e10cSrcweir 					aFmt.SetBulletChar(nSet);
339cdf0e10cSrcweir 					continue;
340cdf0e10cSrcweir 				}
341cdf0e10cSrcweir 			}
342cdf0e10cSrcweir 		}
343cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("BulletChar")))
344cdf0e10cSrcweir 		{
345cdf0e10cSrcweir 			OUString aStr;
346cdf0e10cSrcweir 			if( aVal >>= aStr )
347cdf0e10cSrcweir 			{
348cdf0e10cSrcweir 				if(aStr.getLength())
349cdf0e10cSrcweir 				{
350cdf0e10cSrcweir 					aFmt.SetBulletChar(aStr[0]);
351cdf0e10cSrcweir 				}
352cdf0e10cSrcweir 				else
353cdf0e10cSrcweir 				{
354cdf0e10cSrcweir 					aFmt.SetBulletChar(0);
355cdf0e10cSrcweir 				}
356cdf0e10cSrcweir 				continue;
357cdf0e10cSrcweir 			}
358cdf0e10cSrcweir 		}
359cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_ADJUST)))
360cdf0e10cSrcweir 		{
361cdf0e10cSrcweir 			sal_Int16 nAdjust = sal_Int16();
362cdf0e10cSrcweir 			if( aVal >>= nAdjust )
363cdf0e10cSrcweir 			{
364cdf0e10cSrcweir 				aFmt.SetNumAdjust(ConvertUnoAdjust( (unsigned short)nAdjust ));
365cdf0e10cSrcweir 				continue;
366cdf0e10cSrcweir 			}
367cdf0e10cSrcweir 		}
368cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_FONT)))
369cdf0e10cSrcweir 		{
370cdf0e10cSrcweir 			awt::FontDescriptor aDesc;
371cdf0e10cSrcweir 			if( aVal >>= aDesc )
372cdf0e10cSrcweir 			{
373cdf0e10cSrcweir 				Font aFont;
374cdf0e10cSrcweir 				SvxUnoFontDescriptor::ConvertToFont( aDesc, aFont );
375cdf0e10cSrcweir 				aFmt.SetBulletFont(&aFont);
376cdf0e10cSrcweir 				continue;
377cdf0e10cSrcweir 			}
378cdf0e10cSrcweir 		}
379cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Graphic")))
380cdf0e10cSrcweir 		{
381cdf0e10cSrcweir 			Reference< awt::XBitmap > xBmp;
382cdf0e10cSrcweir 			if( aVal >>= xBmp )
383cdf0e10cSrcweir 			{
384cdf0e10cSrcweir 				Graphic aGraf( VCLUnoHelper::GetBitmap( xBmp ) );
385cdf0e10cSrcweir                 SvxBrushItem aBrushItem(aGraf, GPOS_AREA, SID_ATTR_BRUSH);
386cdf0e10cSrcweir 				aFmt.SetGraphicBrush( &aBrushItem );
387cdf0e10cSrcweir 				continue;
388cdf0e10cSrcweir 			}
389cdf0e10cSrcweir 		}
390cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicURL")))
391cdf0e10cSrcweir 		{
392cdf0e10cSrcweir 			OUString aURL;
393cdf0e10cSrcweir 			if( aVal >>= aURL )
394cdf0e10cSrcweir 			{
395cdf0e10cSrcweir 				GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) );
396cdf0e10cSrcweir                 SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH );
397cdf0e10cSrcweir 				aFmt.SetGraphicBrush( &aBrushItem );
398cdf0e10cSrcweir 				continue;
399cdf0e10cSrcweir 			}
400cdf0e10cSrcweir 		}
401cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicSize")))
402cdf0e10cSrcweir 		{
403cdf0e10cSrcweir 			awt::Size aUnoSize;
404cdf0e10cSrcweir 			if( aVal >>= aUnoSize )
405cdf0e10cSrcweir 			{
406cdf0e10cSrcweir 				aFmt.SetGraphicSize( Size( aUnoSize.Width, aUnoSize.Height ) );
407cdf0e10cSrcweir 				continue;
408cdf0e10cSrcweir 			}
409cdf0e10cSrcweir 		}
410cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_START_WITH)))
411cdf0e10cSrcweir 		{
412cdf0e10cSrcweir 			sal_Int16 nStart = sal_Int16();
413cdf0e10cSrcweir 			if( aVal >>= nStart )
414cdf0e10cSrcweir 			{
415cdf0e10cSrcweir 				aFmt.SetStart( nStart );
416cdf0e10cSrcweir 				continue;
417cdf0e10cSrcweir 			}
418cdf0e10cSrcweir 		}
419cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN)))
420cdf0e10cSrcweir 		{
421cdf0e10cSrcweir 			sal_Int32 nMargin = 0;
422cdf0e10cSrcweir 			if( aVal >>= nMargin )
423cdf0e10cSrcweir 			{
424cdf0e10cSrcweir 				aFmt.SetAbsLSpace((sal_uInt16)nMargin);
425cdf0e10cSrcweir 				continue;
426cdf0e10cSrcweir 			}
427cdf0e10cSrcweir 		}
428cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET)))
429cdf0e10cSrcweir 		{
430cdf0e10cSrcweir 			sal_Int32 nMargin = 0;
431cdf0e10cSrcweir 			if( aVal >>= nMargin )
432cdf0e10cSrcweir 			{
433cdf0e10cSrcweir 				aFmt.SetFirstLineOffset((sal_uInt16)nMargin);
434cdf0e10cSrcweir 				continue;
435cdf0e10cSrcweir 			}
436cdf0e10cSrcweir 		}
437cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SymbolTextDistance")))
438cdf0e10cSrcweir 		{
439cdf0e10cSrcweir 			sal_Int32 nTextDistance = 0;
440cdf0e10cSrcweir 			if( aVal >>= nTextDistance )
441cdf0e10cSrcweir 			{
442cdf0e10cSrcweir 				aFmt.SetCharTextDistance((sal_uInt16)nTextDistance);
443cdf0e10cSrcweir 				continue;
444cdf0e10cSrcweir 			}
445cdf0e10cSrcweir 		}
446cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR)))
447cdf0e10cSrcweir 		{
448cdf0e10cSrcweir 			sal_Int32 nColor = 0;
449cdf0e10cSrcweir 			if( aVal >>= nColor )
450cdf0e10cSrcweir 			{
451cdf0e10cSrcweir 				aFmt.SetBulletColor( (Color) nColor );
452cdf0e10cSrcweir 				continue;
453cdf0e10cSrcweir 			}
454cdf0e10cSrcweir 		}
455cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE)))
456cdf0e10cSrcweir 		{
457cdf0e10cSrcweir 			sal_Int16 nSize = sal_Int16();
458cdf0e10cSrcweir 			if( aVal >>= nSize )
459cdf0e10cSrcweir 			{
4606de4612aSArmin Le Grand                 // [Bug 120650] the slide content corrupt when open in Aoo
4616de4612aSArmin Le Grand                 if ((nSize>250)||(nSize<=0))
4626de4612aSArmin Le Grand                 {
4636de4612aSArmin Le Grand                     nSize = 100;
4646de4612aSArmin Le Grand                 }
4656de4612aSArmin Le Grand 
466cdf0e10cSrcweir 				aFmt.SetBulletRelSize( (short)nSize );
467cdf0e10cSrcweir 				continue;
468cdf0e10cSrcweir 			}
469cdf0e10cSrcweir 		}
470cdf0e10cSrcweir 		else
471cdf0e10cSrcweir 		{
472cdf0e10cSrcweir 			continue;
473cdf0e10cSrcweir 		}
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 		throw IllegalArgumentException();
476cdf0e10cSrcweir 	}
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 	// check that we always have a brush item for bitmap numbering
479cdf0e10cSrcweir 	if( aFmt.GetNumberingType() == SVX_NUM_BITMAP )
480cdf0e10cSrcweir 	{
481cdf0e10cSrcweir 		if( NULL == aFmt.GetBrush() )
482cdf0e10cSrcweir 		{
483cdf0e10cSrcweir 			GraphicObject aGrafObj;
484cdf0e10cSrcweir             SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH );
485cdf0e10cSrcweir 			aFmt.SetGraphicBrush( &aBrushItem );
486cdf0e10cSrcweir 		}
487cdf0e10cSrcweir 	}
488cdf0e10cSrcweir 	maRule.SetLevel( (sal_uInt16)nIndex, aFmt );
489cdf0e10cSrcweir }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
492cdf0e10cSrcweir 
493cdf0e10cSrcweir const SvxNumRule& SvxGetNumRule( Reference< XIndexReplace > xRule ) throw( IllegalArgumentException )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir 	SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule );
496cdf0e10cSrcweir 	if( pRule == NULL )
497cdf0e10cSrcweir 		throw IllegalArgumentException();
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 	return pRule->getNumRule();
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir bool SvxGetNumRule( Reference< XIndexReplace > xRule, SvxNumRule& rNumRule )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir 	SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule );
505cdf0e10cSrcweir 	if( pRule )
506cdf0e10cSrcweir 	{
507cdf0e10cSrcweir 		rNumRule = pRule->getNumRule();
508cdf0e10cSrcweir 	}
509cdf0e10cSrcweir 	else if( xRule.is() )
510cdf0e10cSrcweir 	{
511cdf0e10cSrcweir 		try
512cdf0e10cSrcweir 		{
513cdf0e10cSrcweir 			pRule = new SvxUnoNumberingRules( rNumRule );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 			Reference< XIndexReplace > xDestRule( pRule );
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 			const sal_Int32 nCount = min( xRule->getCount(), xDestRule->getCount() );
518cdf0e10cSrcweir 			sal_Int32 nLevel;
519cdf0e10cSrcweir 			for( nLevel = 0; nLevel < nCount; nLevel++ )
520cdf0e10cSrcweir 			{
521cdf0e10cSrcweir 				xDestRule->replaceByIndex( nLevel, xRule->getByIndex( nLevel ) );
522cdf0e10cSrcweir 			}
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 			rNumRule = pRule->getNumRule();
525cdf0e10cSrcweir 		}
526cdf0e10cSrcweir 		catch( Exception& )
527cdf0e10cSrcweir 		{
528cdf0e10cSrcweir 			return false;
529cdf0e10cSrcweir 		}
530cdf0e10cSrcweir 	}
531cdf0e10cSrcweir 	else
532cdf0e10cSrcweir 	{
533cdf0e10cSrcweir 		return false;
534cdf0e10cSrcweir 	}
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 	return true;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir 
539cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
540cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( const SvxNumRule* pRule ) throw()
541cdf0e10cSrcweir {
542cdf0e10cSrcweir 	DBG_ASSERT( pRule, "No default SvxNumRule!" );
543cdf0e10cSrcweir 	if( pRule )
544cdf0e10cSrcweir 	{
545cdf0e10cSrcweir 		return new SvxUnoNumberingRules( *pRule );
546cdf0e10cSrcweir 	}
547cdf0e10cSrcweir 	else
548cdf0e10cSrcweir 	{
549cdf0e10cSrcweir 		SvxNumRule aDefaultRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, 10 , sal_False);
550cdf0e10cSrcweir 		return new SvxUnoNumberingRules( aDefaultRule );
551cdf0e10cSrcweir 	}
552cdf0e10cSrcweir }
553cdf0e10cSrcweir 
554cdf0e10cSrcweir 
555cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
556cdf0e10cSrcweir 
557cdf0e10cSrcweir class SvxUnoNumberingRulesCompare : public ::cppu::WeakAggImplHelper1< XAnyCompare >
558cdf0e10cSrcweir {
559cdf0e10cSrcweir public:
560cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException);
561cdf0e10cSrcweir };
562cdf0e10cSrcweir 
563cdf0e10cSrcweir sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException)
564cdf0e10cSrcweir {
565cdf0e10cSrcweir     return SvxUnoNumberingRules::Compare( Any1, Any2 );
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir sal_Int16 SvxUnoNumberingRules::Compare( const Any& Any1, const Any& Any2 )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir 	Reference< XIndexReplace > x1( Any1, UNO_QUERY ), x2( Any2, UNO_QUERY );
571cdf0e10cSrcweir 	if( x1.is() && x2.is() )
572cdf0e10cSrcweir 	{
573cdf0e10cSrcweir 		if( x1.get() == x2.get() )
574cdf0e10cSrcweir 			return 0;
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 		SvxUnoNumberingRules* pRule1 = SvxUnoNumberingRules::getImplementation( x1 );
577cdf0e10cSrcweir 		if( pRule1 )
578cdf0e10cSrcweir 		{
579cdf0e10cSrcweir 			SvxUnoNumberingRules* pRule2 = SvxUnoNumberingRules::getImplementation( x2 );
580cdf0e10cSrcweir 			if( pRule2 )
581cdf0e10cSrcweir 			{
582cdf0e10cSrcweir 				const SvxNumRule& rRule1 = pRule1->getNumRule();
583cdf0e10cSrcweir 				const SvxNumRule& rRule2 = pRule2->getNumRule();
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 				const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount();
586cdf0e10cSrcweir 				const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount();
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 				if( nLevelCount1 == 0 || nLevelCount2 == 0 )
589cdf0e10cSrcweir 					return -1;
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 				for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ )
592cdf0e10cSrcweir 				{
593cdf0e10cSrcweir 					if( rRule1.GetLevel(i) != rRule2.GetLevel(i) )
594cdf0e10cSrcweir 						return -1;
595cdf0e10cSrcweir 				}
596cdf0e10cSrcweir 				return  0;
597cdf0e10cSrcweir 			}
598cdf0e10cSrcweir 		}
599cdf0e10cSrcweir 	}
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 	return -1;
602cdf0e10cSrcweir }
603cdf0e10cSrcweir 
604cdf0e10cSrcweir Reference< XAnyCompare > SvxCreateNumRuleCompare() throw()
605cdf0e10cSrcweir {
606cdf0e10cSrcweir 	return new SvxUnoNumberingRulesCompare();
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
609cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > SvxCreateNumRule() throw()
610cdf0e10cSrcweir {
611cdf0e10cSrcweir 	SvxNumRule aTempRule( 0, 10, false );
612cdf0e10cSrcweir 	return SvxCreateNumRule( &aTempRule );
613cdf0e10cSrcweir }
614