xref: /aoo41x/main/editeng/source/uno/unonrule.cxx (revision 4d7c9de0)
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
10190118d0SAndrew Rist  *
11190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12190118d0SAndrew Rist  *
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.
19190118d0SAndrew Rist  *
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 
ConvertUnoAdjust(unsigned short nAdjust)83cdf0e10cSrcweir SvxAdjust ConvertUnoAdjust( unsigned short nAdjust )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	DBG_ASSERT( nAdjust <= 7, "Enum hat sich geaendert! [CL]" );
86cdf0e10cSrcweir 	return aUnoToSvxAdjust[nAdjust];
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
ConvertUnoAdjust(SvxAdjust eAdjust)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 
SvxUnoNumberingRules(const SvxNumRule & rRule)101cdf0e10cSrcweir SvxUnoNumberingRules::SvxUnoNumberingRules( const SvxNumRule& rRule ) throw()
102cdf0e10cSrcweir : maRule( rRule )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
~SvxUnoNumberingRules()106cdf0e10cSrcweir SvxUnoNumberingRules::~SvxUnoNumberingRules() throw()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //XIndexReplace
replaceByIndex(sal_Int32 Index,const uno::Any & Element)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
getCount()127cdf0e10cSrcweir sal_Int32 SAL_CALL SvxUnoNumberingRules::getCount() throw( RuntimeException )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	return maRule.GetLevelCount();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
getByIndex(sal_Int32 Index)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
getElementType()146cdf0e10cSrcweir Type SAL_CALL SvxUnoNumberingRules::getElementType()
147cdf0e10cSrcweir 	throw( RuntimeException )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir 	return ::getCppuType(( const Sequence< beans::PropertyValue >*)0);
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
hasElements()152cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoNumberingRules::hasElements() throw( RuntimeException )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	return sal_True;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir // XAnyCompare
compare(const Any & rAny1,const Any & rAny2)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
createClone()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 
getImplementationName()172cdf0e10cSrcweir OUString SAL_CALL SvxUnoNumberingRules::getImplementationName(  ) throw(RuntimeException)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoNumberingRules" ) );
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
supportsService(const OUString & ServiceName)177cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoNumberingRules::supportsService( const OUString& ServiceName ) throw(RuntimeException)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir 	return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoNumberingRulesService ) );
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
getSupportedServiceNames()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 
getNumberingRuleByIndex(sal_Int32 nIndex) const189cdf0e10cSrcweir 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 		if(SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
225*9b8096d0SSteve Yin 		{
226cdf0e10cSrcweir 		sal_Unicode nCode = rFmt.GetBulletChar();
227cdf0e10cSrcweir 		OUString aStr( &nCode, 1 );
228cdf0e10cSrcweir 		aVal <<= aStr;
229cdf0e10cSrcweir 		beans::PropertyValue aBulletProp( OUString(RTL_CONSTASCII_USTRINGPARAM("BulletChar")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
230cdf0e10cSrcweir 		pArray[nIdx++] = aBulletProp;
231*9b8096d0SSteve Yin 		}
232cdf0e10cSrcweir 	}
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	if( rFmt.GetBulletFont() )
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		awt::FontDescriptor aDesc;
237cdf0e10cSrcweir 		SvxUnoFontDescriptor::ConvertFromFont( *rFmt.GetBulletFont(), aDesc );
238cdf0e10cSrcweir 		aVal.setValue(&aDesc, ::getCppuType((const awt::FontDescriptor*)0));
239cdf0e10cSrcweir 		pArray[nIdx++] = beans::PropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_FONT)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
240cdf0e10cSrcweir 	}
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 	{
243cdf0e10cSrcweir 		const SvxBrushItem* pBrush = rFmt.GetBrush();
244cdf0e10cSrcweir 		if(pBrush && pBrush->GetGraphicObject())
245cdf0e10cSrcweir 		{
246cdf0e10cSrcweir 			const GraphicObject* pGrafObj = pBrush->GetGraphicObject();
247cdf0e10cSrcweir 			OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
248cdf0e10cSrcweir 			aURL += OUString::createFromAscii( pGrafObj->GetUniqueID().GetBuffer() );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 			aVal <<= aURL;
251cdf0e10cSrcweir 			const beans::PropertyValue aGraphicProp( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
252cdf0e10cSrcweir 			pArray[nIdx++] = aGraphicProp;
253cdf0e10cSrcweir 		}
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	{
257cdf0e10cSrcweir 		const Size aSize( rFmt.GetGraphicSize() );
258cdf0e10cSrcweir 		const awt::Size aUnoSize( aSize.Width(), aSize.Height() );
259cdf0e10cSrcweir 		aVal <<= aUnoSize;
260cdf0e10cSrcweir 		const beans::PropertyValue aGraphicSizeProp(OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicSize")), -1, aVal, beans::PropertyState_DIRECT_VALUE );
261cdf0e10cSrcweir 		pArray[nIdx++] = aGraphicSizeProp;
262cdf0e10cSrcweir 	}
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	aVal <<= (sal_Int16)rFmt.GetStart();
265cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_START_WITH)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	aVal <<= (sal_Int32)rFmt.GetAbsLSpace();
268cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	aVal <<= (sal_Int32)rFmt.GetFirstLineOffset();
271cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SymbolTextDistance")), -1, aVal, beans::PropertyState_DIRECT_VALUE);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	aVal <<= (sal_Int32)rFmt.GetBulletColor().GetColor();
276cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 	aVal <<= (sal_Int16)rFmt.GetBulletRelSize();
279cdf0e10cSrcweir 	pArray[nIdx++] = beans::PropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	DBG_ASSERT( nIdx <= nProps, "FixMe: Array uebergelaufen!!!! [CL]" );
282cdf0e10cSrcweir 	Sequence< beans::PropertyValue> aSeq(pArray, nIdx);
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 	delete [] pArray;
285cdf0e10cSrcweir 	return aSeq;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
setNumberingRuleByIndex(const Sequence<beans::PropertyValue> & rProperties,sal_Int32 nIndex)288cdf0e10cSrcweir void SvxUnoNumberingRules::setNumberingRuleByIndex(	const Sequence< beans::PropertyValue >& rProperties, sal_Int32 nIndex)
289cdf0e10cSrcweir 	throw( RuntimeException, IllegalArgumentException )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	SvxNumberFormat aFmt(maRule.GetLevel( (sal_uInt16)nIndex ));
292cdf0e10cSrcweir 	const beans::PropertyValue* pPropArray = rProperties.getConstArray();
293cdf0e10cSrcweir 	for(int i = 0; i < rProperties.getLength(); i++)
294cdf0e10cSrcweir 	{
295cdf0e10cSrcweir 		const beans::PropertyValue& rProp = pPropArray[i];
296cdf0e10cSrcweir 		const OUString& rPropName = rProp.Name;
297cdf0e10cSrcweir 		const Any& aVal = rProp.Value;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 		if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_NUMBERINGTYPE)))
300cdf0e10cSrcweir 		{
301cdf0e10cSrcweir 			sal_Int16 nSet = sal_Int16();
302cdf0e10cSrcweir 			aVal >>= nSet;
303cdf0e10cSrcweir 
30494a565f3SAndre Fischer 			// There is no reason to limit numbering types.
30594a565f3SAndre Fischer 			if ( nSet>=0 )
306cdf0e10cSrcweir 			{
307cdf0e10cSrcweir 				aFmt.SetNumberingType(nSet);
308cdf0e10cSrcweir 				continue;
309cdf0e10cSrcweir 			}
310cdf0e10cSrcweir 		}
311cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_PREFIX)))
312cdf0e10cSrcweir 		{
313cdf0e10cSrcweir 			OUString aPrefix;
314cdf0e10cSrcweir 			if( aVal >>= aPrefix )
315cdf0e10cSrcweir 			{
316cdf0e10cSrcweir 				aFmt.SetPrefix(aPrefix);
317cdf0e10cSrcweir 				continue;
318cdf0e10cSrcweir 			}
319cdf0e10cSrcweir 		}
320cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_SUFFIX)))
321cdf0e10cSrcweir 		{
322cdf0e10cSrcweir 			OUString aSuffix;
323cdf0e10cSrcweir 			if( aVal >>= aSuffix )
324cdf0e10cSrcweir 			{
325cdf0e10cSrcweir 				aFmt.SetSuffix(aSuffix);
326cdf0e10cSrcweir 				continue;
327cdf0e10cSrcweir 			}
328cdf0e10cSrcweir 		}
329cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLETID)))
330cdf0e10cSrcweir 		{
331cdf0e10cSrcweir 			sal_Int16 nSet = sal_Int16();
332cdf0e10cSrcweir 			if( aVal >>= nSet )
333cdf0e10cSrcweir 			{
334cdf0e10cSrcweir 				if(nSet < 0x100)
335cdf0e10cSrcweir 				{
336cdf0e10cSrcweir 					aFmt.SetBulletChar(nSet);
337cdf0e10cSrcweir 					continue;
338cdf0e10cSrcweir 				}
339cdf0e10cSrcweir 			}
340cdf0e10cSrcweir 		}
341cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("BulletChar")))
342cdf0e10cSrcweir 		{
343cdf0e10cSrcweir 			OUString aStr;
344cdf0e10cSrcweir 			if( aVal >>= aStr )
345cdf0e10cSrcweir 			{
346cdf0e10cSrcweir 				if(aStr.getLength())
347cdf0e10cSrcweir 				{
348cdf0e10cSrcweir 					aFmt.SetBulletChar(aStr[0]);
349cdf0e10cSrcweir 				}
350cdf0e10cSrcweir 				else
351cdf0e10cSrcweir 				{
352cdf0e10cSrcweir 					aFmt.SetBulletChar(0);
353cdf0e10cSrcweir 				}
354cdf0e10cSrcweir 				continue;
355cdf0e10cSrcweir 			}
356cdf0e10cSrcweir 		}
357cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_ADJUST)))
358cdf0e10cSrcweir 		{
359cdf0e10cSrcweir 			sal_Int16 nAdjust = sal_Int16();
360cdf0e10cSrcweir 			if( aVal >>= nAdjust )
361cdf0e10cSrcweir 			{
362cdf0e10cSrcweir 				aFmt.SetNumAdjust(ConvertUnoAdjust( (unsigned short)nAdjust ));
363cdf0e10cSrcweir 				continue;
364cdf0e10cSrcweir 			}
365cdf0e10cSrcweir 		}
366cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_FONT)))
367cdf0e10cSrcweir 		{
368cdf0e10cSrcweir 			awt::FontDescriptor aDesc;
369cdf0e10cSrcweir 			if( aVal >>= aDesc )
370cdf0e10cSrcweir 			{
371cdf0e10cSrcweir 				Font aFont;
372cdf0e10cSrcweir 				SvxUnoFontDescriptor::ConvertToFont( aDesc, aFont );
373cdf0e10cSrcweir 				aFmt.SetBulletFont(&aFont);
374cdf0e10cSrcweir 				continue;
375cdf0e10cSrcweir 			}
376cdf0e10cSrcweir 		}
377cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Graphic")))
378cdf0e10cSrcweir 		{
379cdf0e10cSrcweir 			Reference< awt::XBitmap > xBmp;
380cdf0e10cSrcweir 			if( aVal >>= xBmp )
381cdf0e10cSrcweir 			{
382cdf0e10cSrcweir 				Graphic aGraf( VCLUnoHelper::GetBitmap( xBmp ) );
383cdf0e10cSrcweir                 SvxBrushItem aBrushItem(aGraf, GPOS_AREA, SID_ATTR_BRUSH);
384cdf0e10cSrcweir 				aFmt.SetGraphicBrush( &aBrushItem );
385cdf0e10cSrcweir 				continue;
386cdf0e10cSrcweir 			}
387cdf0e10cSrcweir 		}
388cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicURL")))
389cdf0e10cSrcweir 		{
390cdf0e10cSrcweir 			OUString aURL;
391cdf0e10cSrcweir 			if( aVal >>= aURL )
392cdf0e10cSrcweir 			{
393cdf0e10cSrcweir 				GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) );
394cdf0e10cSrcweir                 SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH );
395cdf0e10cSrcweir 				aFmt.SetGraphicBrush( &aBrushItem );
396cdf0e10cSrcweir 				continue;
397cdf0e10cSrcweir 			}
398cdf0e10cSrcweir 		}
399cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("GraphicSize")))
400cdf0e10cSrcweir 		{
401cdf0e10cSrcweir 			awt::Size aUnoSize;
402cdf0e10cSrcweir 			if( aVal >>= aUnoSize )
403cdf0e10cSrcweir 			{
404cdf0e10cSrcweir 				aFmt.SetGraphicSize( Size( aUnoSize.Width, aUnoSize.Height ) );
405cdf0e10cSrcweir 				continue;
406cdf0e10cSrcweir 			}
407cdf0e10cSrcweir 		}
408cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_START_WITH)))
409cdf0e10cSrcweir 		{
410cdf0e10cSrcweir 			sal_Int16 nStart = sal_Int16();
411cdf0e10cSrcweir 			if( aVal >>= nStart )
412cdf0e10cSrcweir 			{
413cdf0e10cSrcweir 				aFmt.SetStart( nStart );
414cdf0e10cSrcweir 				continue;
415cdf0e10cSrcweir 			}
416cdf0e10cSrcweir 		}
417cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_LEFT_MARGIN)))
418cdf0e10cSrcweir 		{
419cdf0e10cSrcweir 			sal_Int32 nMargin = 0;
420cdf0e10cSrcweir 			if( aVal >>= nMargin )
421cdf0e10cSrcweir 			{
422cdf0e10cSrcweir 				aFmt.SetAbsLSpace((sal_uInt16)nMargin);
423cdf0e10cSrcweir 				continue;
424cdf0e10cSrcweir 			}
425cdf0e10cSrcweir 		}
426cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_FIRST_LINE_OFFSET)))
427cdf0e10cSrcweir 		{
428cdf0e10cSrcweir 			sal_Int32 nMargin = 0;
429cdf0e10cSrcweir 			if( aVal >>= nMargin )
430cdf0e10cSrcweir 			{
431cdf0e10cSrcweir 				aFmt.SetFirstLineOffset((sal_uInt16)nMargin);
432cdf0e10cSrcweir 				continue;
433cdf0e10cSrcweir 			}
434cdf0e10cSrcweir 		}
435cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SymbolTextDistance")))
436cdf0e10cSrcweir 		{
437cdf0e10cSrcweir 			sal_Int32 nTextDistance = 0;
438cdf0e10cSrcweir 			if( aVal >>= nTextDistance )
439cdf0e10cSrcweir 			{
440cdf0e10cSrcweir 				aFmt.SetCharTextDistance((sal_uInt16)nTextDistance);
441cdf0e10cSrcweir 				continue;
442cdf0e10cSrcweir 			}
443cdf0e10cSrcweir 		}
444cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_COLOR)))
445cdf0e10cSrcweir 		{
446cdf0e10cSrcweir 			sal_Int32 nColor = 0;
447cdf0e10cSrcweir 			if( aVal >>= nColor )
448cdf0e10cSrcweir 			{
449cdf0e10cSrcweir 				aFmt.SetBulletColor( (Color) nColor );
450cdf0e10cSrcweir 				continue;
451cdf0e10cSrcweir 			}
452cdf0e10cSrcweir 		}
453cdf0e10cSrcweir 		else if(rPropName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_NAME_NRULE_BULLET_RELSIZE)))
454cdf0e10cSrcweir 		{
455cdf0e10cSrcweir 			sal_Int16 nSize = sal_Int16();
456cdf0e10cSrcweir 			if( aVal >>= nSize )
457cdf0e10cSrcweir 			{
4586de4612aSArmin Le Grand                 // [Bug 120650] the slide content corrupt when open in Aoo
4596de4612aSArmin Le Grand                 if ((nSize>250)||(nSize<=0))
4606de4612aSArmin Le Grand                 {
4616de4612aSArmin Le Grand                     nSize = 100;
4626de4612aSArmin Le Grand                 }
4636de4612aSArmin Le Grand 
464cdf0e10cSrcweir 				aFmt.SetBulletRelSize( (short)nSize );
465cdf0e10cSrcweir 				continue;
466cdf0e10cSrcweir 			}
467cdf0e10cSrcweir 		}
468cdf0e10cSrcweir 		else
469cdf0e10cSrcweir 		{
470cdf0e10cSrcweir 			continue;
471cdf0e10cSrcweir 		}
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 		throw IllegalArgumentException();
474cdf0e10cSrcweir 	}
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 	// check that we always have a brush item for bitmap numbering
477cdf0e10cSrcweir 	if( aFmt.GetNumberingType() == SVX_NUM_BITMAP )
478cdf0e10cSrcweir 	{
479cdf0e10cSrcweir 		if( NULL == aFmt.GetBrush() )
480cdf0e10cSrcweir 		{
481cdf0e10cSrcweir 			GraphicObject aGrafObj;
482cdf0e10cSrcweir             SvxBrushItem aBrushItem( aGrafObj, GPOS_AREA, SID_ATTR_BRUSH );
483cdf0e10cSrcweir 			aFmt.SetGraphicBrush( &aBrushItem );
484cdf0e10cSrcweir 		}
485cdf0e10cSrcweir 	}
486cdf0e10cSrcweir 	maRule.SetLevel( (sal_uInt16)nIndex, aFmt );
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
489cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
490cdf0e10cSrcweir 
SvxGetNumRule(Reference<XIndexReplace> xRule)491cdf0e10cSrcweir const SvxNumRule& SvxGetNumRule( Reference< XIndexReplace > xRule ) throw( IllegalArgumentException )
492cdf0e10cSrcweir {
493cdf0e10cSrcweir 	SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule );
494cdf0e10cSrcweir 	if( pRule == NULL )
495cdf0e10cSrcweir 		throw IllegalArgumentException();
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 	return pRule->getNumRule();
498cdf0e10cSrcweir }
499cdf0e10cSrcweir 
SvxGetNumRule(Reference<XIndexReplace> xRule,SvxNumRule & rNumRule)500cdf0e10cSrcweir bool SvxGetNumRule( Reference< XIndexReplace > xRule, SvxNumRule& rNumRule )
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	SvxUnoNumberingRules* pRule = SvxUnoNumberingRules::getImplementation( xRule );
503cdf0e10cSrcweir 	if( pRule )
504cdf0e10cSrcweir 	{
505cdf0e10cSrcweir 		rNumRule = pRule->getNumRule();
506cdf0e10cSrcweir 	}
507cdf0e10cSrcweir 	else if( xRule.is() )
508cdf0e10cSrcweir 	{
509cdf0e10cSrcweir 		try
510cdf0e10cSrcweir 		{
511cdf0e10cSrcweir 			pRule = new SvxUnoNumberingRules( rNumRule );
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 			Reference< XIndexReplace > xDestRule( pRule );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 			const sal_Int32 nCount = min( xRule->getCount(), xDestRule->getCount() );
516cdf0e10cSrcweir 			sal_Int32 nLevel;
517cdf0e10cSrcweir 			for( nLevel = 0; nLevel < nCount; nLevel++ )
518cdf0e10cSrcweir 			{
519cdf0e10cSrcweir 				xDestRule->replaceByIndex( nLevel, xRule->getByIndex( nLevel ) );
520cdf0e10cSrcweir 			}
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 			rNumRule = pRule->getNumRule();
523cdf0e10cSrcweir 		}
524cdf0e10cSrcweir 		catch( Exception& )
525cdf0e10cSrcweir 		{
526cdf0e10cSrcweir 			return false;
527cdf0e10cSrcweir 		}
528cdf0e10cSrcweir 	}
529cdf0e10cSrcweir 	else
530cdf0e10cSrcweir 	{
531cdf0e10cSrcweir 		return false;
532cdf0e10cSrcweir 	}
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 	return true;
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
SvxCreateNumRule(const SvxNumRule * pRule)538cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( const SvxNumRule* pRule ) throw()
539cdf0e10cSrcweir {
540cdf0e10cSrcweir 	DBG_ASSERT( pRule, "No default SvxNumRule!" );
541cdf0e10cSrcweir 	if( pRule )
542cdf0e10cSrcweir 	{
543cdf0e10cSrcweir 		return new SvxUnoNumberingRules( *pRule );
544cdf0e10cSrcweir 	}
545cdf0e10cSrcweir 	else
546cdf0e10cSrcweir 	{
547cdf0e10cSrcweir 		SvxNumRule aDefaultRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, 10 , sal_False);
548cdf0e10cSrcweir 		return new SvxUnoNumberingRules( aDefaultRule );
549cdf0e10cSrcweir 	}
550cdf0e10cSrcweir }
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 
553cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
554cdf0e10cSrcweir 
555cdf0e10cSrcweir class SvxUnoNumberingRulesCompare : public ::cppu::WeakAggImplHelper1< XAnyCompare >
556cdf0e10cSrcweir {
557cdf0e10cSrcweir public:
558cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException);
559cdf0e10cSrcweir };
560cdf0e10cSrcweir 
compare(const Any & Any1,const Any & Any2)561cdf0e10cSrcweir sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare( const Any& Any1, const Any& Any2 ) throw(RuntimeException)
562cdf0e10cSrcweir {
563cdf0e10cSrcweir     return SvxUnoNumberingRules::Compare( Any1, Any2 );
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
Compare(const Any & Any1,const Any & Any2)566cdf0e10cSrcweir sal_Int16 SvxUnoNumberingRules::Compare( const Any& Any1, const Any& Any2 )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir 	Reference< XIndexReplace > x1( Any1, UNO_QUERY ), x2( Any2, UNO_QUERY );
569cdf0e10cSrcweir 	if( x1.is() && x2.is() )
570cdf0e10cSrcweir 	{
571cdf0e10cSrcweir 		if( x1.get() == x2.get() )
572cdf0e10cSrcweir 			return 0;
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 		SvxUnoNumberingRules* pRule1 = SvxUnoNumberingRules::getImplementation( x1 );
575cdf0e10cSrcweir 		if( pRule1 )
576cdf0e10cSrcweir 		{
577cdf0e10cSrcweir 			SvxUnoNumberingRules* pRule2 = SvxUnoNumberingRules::getImplementation( x2 );
578cdf0e10cSrcweir 			if( pRule2 )
579cdf0e10cSrcweir 			{
580cdf0e10cSrcweir 				const SvxNumRule& rRule1 = pRule1->getNumRule();
581cdf0e10cSrcweir 				const SvxNumRule& rRule2 = pRule2->getNumRule();
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 				const sal_uInt16 nLevelCount1 = rRule1.GetLevelCount();
584cdf0e10cSrcweir 				const sal_uInt16 nLevelCount2 = rRule2.GetLevelCount();
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 				if( nLevelCount1 == 0 || nLevelCount2 == 0 )
587cdf0e10cSrcweir 					return -1;
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 				for( sal_uInt16 i = 0; (i < nLevelCount1) && (i < nLevelCount2); i++ )
590cdf0e10cSrcweir 				{
591cdf0e10cSrcweir 					if( rRule1.GetLevel(i) != rRule2.GetLevel(i) )
592cdf0e10cSrcweir 						return -1;
593cdf0e10cSrcweir 				}
594cdf0e10cSrcweir 				return  0;
595cdf0e10cSrcweir 			}
596cdf0e10cSrcweir 		}
597cdf0e10cSrcweir 	}
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 	return -1;
600cdf0e10cSrcweir }
601cdf0e10cSrcweir 
SvxCreateNumRuleCompare()602cdf0e10cSrcweir Reference< XAnyCompare > SvxCreateNumRuleCompare() throw()
603cdf0e10cSrcweir {
604cdf0e10cSrcweir 	return new SvxUnoNumberingRulesCompare();
605cdf0e10cSrcweir }
606cdf0e10cSrcweir 
SvxCreateNumRule()607cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace > SvxCreateNumRule() throw()
608cdf0e10cSrcweir {
609cdf0e10cSrcweir 	SvxNumRule aTempRule( 0, 10, false );
610cdf0e10cSrcweir 	return SvxCreateNumRule( &aTempRule );
611cdf0e10cSrcweir }
612