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