xref: /aoo42x/main/sw/source/core/unocore/unosett.cxx (revision 28f5a95a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <svx/svxids.hrc>
28 #include <editeng/memberids.hrc>
29 #include <swtypes.hxx>
30 #include <cmdid.h>
31 #include <hintids.hxx>
32 #include "poolfmt.hrc"
33 #include "poolfmt.hxx"
34 #include <fmtcol.hxx>
35 #include <unomap.hxx>
36 #include <unostyle.hxx>
37 #include <unosett.hxx>
38 #include <unoprnms.hxx>
39 #include <ftninfo.hxx>
40 #include <doc.hxx>
41 #include <pagedesc.hxx>
42 #include <charfmt.hxx>
43 #include <lineinfo.hxx>
44 #include <docsh.hxx>
45 #include <docary.hxx>
46 #include <docstyle.hxx>
47 #include <fmtclds.hxx>
48 #include <editeng/brshitem.hxx>
49 #include <com/sun/star/text/XFootnotesSettingsSupplier.hpp>
50 #include <com/sun/star/text/XFootnote.hpp>
51 #include <com/sun/star/text/XFootnotesSupplier.hpp>
52 #include <com/sun/star/text/XEndnotesSupplier.hpp>
53 #include <com/sun/star/text/XEndnotesSettingsSupplier.hpp>
54 #include <com/sun/star/text/FootnoteNumbering.hpp>
55 #include <com/sun/star/text/HoriOrientation.hpp>
56 #include <com/sun/star/style/LineNumberPosition.hpp>
57 #include <com/sun/star/awt/XBitmap.hpp>
58 #include <com/sun/star/beans/PropertyAttribute.hpp>
59 #include <com/sun/star/style/VerticalAlignment.hpp>
60 #include <vcl/font.hxx>
61 #include <editeng/flstitem.hxx>
62 #include <vcl/metric.hxx>
63 #include <svtools/ctrltool.hxx>
64 #include <vos/mutex.hxx>
65 #include <vcl/svapp.hxx>
66 #include <toolkit/helper/vclunohelper.hxx>
67 #include <editeng/unofdesc.hxx>
68 #include <fmtornt.hxx>
69 #include <SwStyleNameMapper.hxx>
70 // --> OD 2008-01-15 #newlistlevelattrs#
71 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
72 #include <com/sun/star/text/LabelFollow.hpp>
73 // <--
74 #include <numrule.hxx>
75 
76 using ::rtl::OUString;
77 using namespace ::com::sun::star;
78 using namespace ::com::sun::star::uno;
79 using namespace ::com::sun::star::lang;
80 using namespace ::com::sun::star::beans;
81 using namespace ::com::sun::star::text;
82 using namespace ::com::sun::star::style;
83 
84 struct PropValData
85 {
86 	uno::Any 		aVal;
87 	OUString			sPropName;
PropValDataPropValData88 	PropValData(void* pVal, const char* cPropName, uno::Type aType ) :
89 		aVal(pVal, aType),
90 		sPropName(OUString::createFromAscii(cPropName))
91 		{}
PropValDataPropValData92 	PropValData(const uno::Any& rVal, const OUString& rPropName) :
93 		aVal(rVal),
94 		sPropName(rPropName)
95 		{}
96 };
97 
98 typedef PropValData* PropValDataPtr;
99 SV_DECL_PTRARR(PropValDataArr, PropValDataPtr, 5, 5 )
SV_IMPL_PTRARR(PropValDataArr,PropValDataPtr) const100 SV_IMPL_PTRARR(PropValDataArr, PropValDataPtr)
101 
102 
103 #define WID_PREFIX						0
104 #define WID_SUFFIX  					1
105 #define WID_NUMBERING_TYPE              2
106 #define WID_START_AT                    3
107 #define WID_FOOTNOTE_COUNTING 			4
108 #define WID_PARAGRAPH_STYLE             5
109 #define WID_PAGE_STYLE                  6
110 #define WID_CHARACTER_STYLE             7
111 #define WID_POSITION_END_OF_DOC         8
112 #define WID_END_NOTICE                  9
113 #define WID_BEGIN_NOTICE                10
114 #define WID_ANCHOR_CHARACTER_STYLE		11
115 
116 const SfxItemPropertySet* GetFootnoteSet()
117 {
118     static SfxItemPropertyMapEntry aFootnoteMap_Impl[] =
119 	{
120 		{ SW_PROP_NAME(UNO_NAME_ANCHOR_CHAR_STYLE_NAME),WID_ANCHOR_CHARACTER_STYLE, &::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
121 		{ SW_PROP_NAME(UNO_NAME_BEGIN_NOTICE),  		WID_BEGIN_NOTICE, 		&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
122 		{ SW_PROP_NAME(UNO_NAME_CHAR_STYLE_NAME),  		WID_CHARACTER_STYLE, 	&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
123 		{ SW_PROP_NAME(UNO_NAME_END_NOTICE),  			WID_END_NOTICE ,  		&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
124 		{ SW_PROP_NAME(UNO_NAME_FOOTNOTE_COUNTING), 	WID_FOOTNOTE_COUNTING, 	&::getCppuType((const sal_Int16*)0), PROPERTY_NONE,  	0},
125 		{ SW_PROP_NAME(UNO_NAME_NUMBERING_TYPE),		WID_NUMBERING_TYPE, 	&::getCppuType((const sal_Int16*)0), PROPERTY_NONE,     	0},
126 		{ SW_PROP_NAME(UNO_NAME_PAGE_STYLE_NAME),  		WID_PAGE_STYLE, 		&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
127 		{ SW_PROP_NAME(UNO_NAME_PARA_STYLE_NAME),  		WID_PARAGRAPH_STYLE, 	&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
128 		{ SW_PROP_NAME(UNO_NAME_POSITION_END_OF_DOC), 	WID_POSITION_END_OF_DOC,&::getBooleanCppuType(), PROPERTY_NONE,     	0},
129 		{ SW_PROP_NAME(UNO_NAME_PREFIX),				WID_PREFIX, 			&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
130 		{ SW_PROP_NAME(UNO_NAME_START_AT),  			WID_START_AT , 			&::getCppuType((const sal_Int16*)0), PROPERTY_NONE,     	0},
131 		{ SW_PROP_NAME(UNO_NAME_SUFFIX),  				WID_SUFFIX, 			&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
132 		{0,0,0,0,0,0}
133 	};
134     static SfxItemPropertySet aFootnoteSet_Impl(aFootnoteMap_Impl);
135 	return &aFootnoteSet_Impl;
136 }
GetEndnoteSet()137 const SfxItemPropertySet* GetEndnoteSet()
138 {
139     static SfxItemPropertyMapEntry aEndnoteMap_Impl[] =
140 	{
141 		{ SW_PROP_NAME(UNO_NAME_ANCHOR_CHAR_STYLE_NAME),WID_ANCHOR_CHARACTER_STYLE, &::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
142 		{ SW_PROP_NAME(UNO_NAME_CHAR_STYLE_NAME),  		WID_CHARACTER_STYLE, 	&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
143 		{ SW_PROP_NAME(UNO_NAME_NUMBERING_TYPE),		WID_NUMBERING_TYPE, 	&::getCppuType((const sal_Int16*)0), PROPERTY_NONE,     	0},
144 		{ SW_PROP_NAME(UNO_NAME_PAGE_STYLE_NAME),  		WID_PAGE_STYLE, 		&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
145 		{ SW_PROP_NAME(UNO_NAME_PARA_STYLE_NAME),  		WID_PARAGRAPH_STYLE, 	&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
146 		{ SW_PROP_NAME(UNO_NAME_PREFIX),				WID_PREFIX, 	&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
147 		{ SW_PROP_NAME(UNO_NAME_START_AT),  			WID_START_AT , 			&::getCppuType((const sal_Int16*)0), PROPERTY_NONE,     	0},
148 		{ SW_PROP_NAME(UNO_NAME_SUFFIX),  				WID_SUFFIX, 	&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
149 		{0,0,0,0,0,0}
150 	};
151     static SfxItemPropertySet aEndnoteSet_Impl(aEndnoteMap_Impl);
152 	return &aEndnoteSet_Impl;
153 }
GetNumberingRulesSet()154 const SfxItemPropertySet* GetNumberingRulesSet()
155 {
156     static SfxItemPropertyMapEntry aNumberingRulesMap_Impl[] =
157 	{
158 		{ SW_PROP_NAME(UNO_NAME_IS_ABSOLUTE_MARGINS),		WID_IS_ABS_MARGINS,	&::getBooleanCppuType(), 			PROPERTY_NONE,     0},
159 		{ SW_PROP_NAME(UNO_NAME_IS_AUTOMATIC),  			WID_IS_AUTOMATIC,	&::getBooleanCppuType(), 			PROPERTY_NONE,     0},
160 		{ SW_PROP_NAME(UNO_NAME_IS_CONTINUOUS_NUMBERING),  	WID_CONTINUOUS, 	&::getBooleanCppuType(), 			PROPERTY_NONE,     0},
161 		{ SW_PROP_NAME(UNO_NAME_NAME),  					WID_RULE_NAME	, 	&::getCppuType((const OUString*)0), PropertyAttribute::READONLY,     0},
162 		{ SW_PROP_NAME(UNO_NAME_NUMBERING_IS_OUTLINE),		WID_IS_OUTLINE,	&::getBooleanCppuType(), 			PROPERTY_NONE,     0},
163         { SW_PROP_NAME(UNO_NAME_DEFAULT_LIST_ID),           WID_DEFAULT_LIST_ID, &::getCppuType((const OUString*)0), PropertyAttribute::READONLY, 0},
164 		{0,0,0,0,0,0}
165 	};
166 	static SfxItemPropertySet  aNumberingRulesSet_Impl( aNumberingRulesMap_Impl );
167     return &aNumberingRulesSet_Impl;
168 }
169 #define WID_NUM_ON						0
170 #define WID_SEPARATOR_INTERVAL          1
171 #define WID_NUMBERING_TYPE              2
172 #define WID_NUMBER_POSITION             3
173 #define WID_DISTANCE                    4
174 #define WID_INTERVAL                    5
175 #define WID_SEPARATOR_TEXT              6
176 //#define WID_CHARACTER_STYLE             7
177 #define WID_COUNT_EMPTY_LINES           8
178 #define WID_COUNT_LINES_IN_FRAMES       9
179 #define WID_RESTART_AT_EACH_PAGE		10
180 
GetLineNumberingSet()181 const SfxItemPropertySet* GetLineNumberingSet()
182 {
183     static SfxItemPropertyMapEntry aLineNumberingMap_Impl[] =
184 	{
185 		{ SW_PROP_NAME(UNO_NAME_CHAR_STYLE_NAME),         WID_CHARACTER_STYLE,    &::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
186 		{ SW_PROP_NAME(UNO_NAME_COUNT_EMPTY_LINES),		  WID_COUNT_EMPTY_LINES , &::getBooleanCppuType(),PROPERTY_NONE,     0},
187 		{ SW_PROP_NAME(UNO_NAME_COUNT_LINES_IN_FRAMES),   WID_COUNT_LINES_IN_FRAMES, &::getBooleanCppuType(),PROPERTY_NONE,     0},
188 		{ SW_PROP_NAME(UNO_NAME_DISTANCE       ),         WID_DISTANCE       ,    &::getCppuType((const sal_Int32*)0),PROPERTY_NONE,     0},
189 		{ SW_PROP_NAME(UNO_NAME_IS_ON), 					WID_NUM_ON, 			&::getBooleanCppuType()  ,  		PROPERTY_NONE,     0},
190 		{ SW_PROP_NAME(UNO_NAME_INTERVAL  ),              WID_INTERVAL  ,    	&::getCppuType((const sal_Int16*)0),PROPERTY_NONE,     0},
191 		{ SW_PROP_NAME(UNO_NAME_SEPARATOR_TEXT ),         WID_SEPARATOR_TEXT, 	&::getCppuType((const OUString*)0), PROPERTY_NONE,     0},
192 		{ SW_PROP_NAME(UNO_NAME_NUMBER_POSITION),         WID_NUMBER_POSITION,    &::getCppuType((const sal_Int16*)0),PROPERTY_NONE,     0},
193 		{ SW_PROP_NAME(UNO_NAME_NUMBERING_TYPE),          WID_NUMBERING_TYPE ,    &::getCppuType((const sal_Int16*)0),PROPERTY_NONE,     0},
194 		{ SW_PROP_NAME(UNO_NAME_RESTART_AT_EACH_PAGE), 	  WID_RESTART_AT_EACH_PAGE, &::getBooleanCppuType()  ,  		PROPERTY_NONE,     0},
195 		{ SW_PROP_NAME(UNO_NAME_SEPARATOR_INTERVAL), 	  WID_SEPARATOR_INTERVAL, &::getCppuType((const sal_Int16*)0),PROPERTY_NONE,     0},
196 		{0,0,0,0,0,0}
197 	};
198     static SfxItemPropertySet aLineNumberingSet_Impl(aLineNumberingMap_Impl);
199 	return &aLineNumberingSet_Impl;
200 }
201 
202 /* -----------------05.05.98 08:30-------------------
203  *
204  * --------------------------------------------------*/
lcl_getCharFmt(SwDoc * pDoc,const uno::Any & aValue)205 SwCharFmt* lcl_getCharFmt(SwDoc* pDoc, const uno::Any& aValue)
206 {
207 	SwCharFmt* pRet = 0;
208 	String sStandard(SW_RES(STR_POOLCOLL_STANDARD));
209 	OUString uTmp;
210 	aValue >>= uTmp;
211 	String sCharFmt;
212 	SwStyleNameMapper::FillUIName(uTmp, sCharFmt, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True);
213 	if(sStandard != sCharFmt)
214 	{
215 		pRet = pDoc->FindCharFmtByName( sCharFmt );
216 	}
217 	if(!pRet)
218 	{
219 		sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(sCharFmt, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
220 		if(USHRT_MAX != nId)
221 			pRet = pDoc->GetCharFmtFromPool( nId );
222 	}
223 	return pRet;
224 }
225 /* -----------------05.05.98 08:30-------------------
226  *
227  * --------------------------------------------------*/
lcl_GetParaStyle(SwDoc * pDoc,const uno::Any & aValue)228 SwTxtFmtColl* lcl_GetParaStyle(SwDoc* pDoc, const uno::Any& aValue)
229 {
230 	OUString uTmp;
231 	aValue >>= uTmp;
232 	String sParaStyle;
233 	SwStyleNameMapper::FillUIName(uTmp, sParaStyle, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
234 	SwTxtFmtColl* pRet = pDoc->FindTxtFmtCollByName( sParaStyle );
235 	if( !pRet  )
236 	{
237 		sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sParaStyle, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
238 		if( USHRT_MAX != nId  )
239 			pRet = pDoc->GetTxtCollFromPool( nId );
240 	}
241 	return pRet;
242 }
243 /* -----------------05.05.98 08:30-------------------
244  *
245  * --------------------------------------------------*/
lcl_GetPageDesc(SwDoc * pDoc,const uno::Any & aValue)246 SwPageDesc* lcl_GetPageDesc(SwDoc* pDoc, const uno::Any& aValue)
247 {
248 	SwPageDesc* pRet = 0;
249 	sal_uInt16 nCount = pDoc->GetPageDescCnt();
250 	OUString uTmp;
251 	aValue >>= uTmp;
252 	String sPageDesc;
253 	SwStyleNameMapper::FillUIName(uTmp, sPageDesc, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
254 	for( sal_uInt16 i = 0; i < nCount; i++)
255 	{
256 		const SwPageDesc& rDesc = const_cast<const SwDoc *>(pDoc)
257             ->GetPageDesc( i );
258 		if(rDesc.GetName() == sPageDesc)
259 		{
260 			pRet = (SwPageDesc*)&rDesc;
261 			break;
262 		}
263 	}
264 	if(!pRet)
265 	{
266 		sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(sPageDesc, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC);
267 		if(USHRT_MAX != nId)
268 			pRet = pDoc->GetPageDescFromPool( nId );
269 	}
270 	return pRet;
271 }
272 /******************************************************************************
273  *
274  ******************************************************************************/
275 // Numerierung
276 const unsigned short aSvxToUnoAdjust[] =
277 {
278     text::HoriOrientation::LEFT,    //3
279     text::HoriOrientation::RIGHT,  //1
280 	USHRT_MAX,
281     text::HoriOrientation::CENTER, //2
282 	USHRT_MAX,
283 	USHRT_MAX
284 };
285 
286 const unsigned short aUnoToSvxAdjust[] =
287 {
288 	USHRT_MAX,
289 	SVX_ADJUST_RIGHT,       // 1
290 	SVX_ADJUST_CENTER,      // 3
291 	SVX_ADJUST_LEFT,		// 0
292 	USHRT_MAX,
293 	USHRT_MAX
294 };
295 
296 /******************************************************************
297  * SwXFootnoteProperties
298  ******************************************************************/
299 /* -----------------------------06.04.00 11:43--------------------------------
300 
301  ---------------------------------------------------------------------------*/
getImplementationName(void)302 OUString SwXFootnoteProperties::getImplementationName(void) throw( RuntimeException )
303 {
304 	return C2U("SwXFootnoteProperties");
305 }
306 /* -----------------------------06.04.00 11:43--------------------------------
307 
308  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)309 sal_Bool SwXFootnoteProperties::supportsService(const OUString& rServiceName) throw( RuntimeException )
310 {
311 	return C2U("com.sun.star.text.FootnoteSettings") == rServiceName;
312 }
313 /* -----------------------------06.04.00 11:43--------------------------------
314 
315  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)316 Sequence< OUString > SwXFootnoteProperties::getSupportedServiceNames(void) throw( RuntimeException )
317 {
318 	Sequence< OUString > aRet(1);
319 	OUString* pArray = aRet.getArray();
320 	pArray[0] = C2U("com.sun.star.text.FootnoteSettings");
321 	return aRet;
322 }
323 /*-- 14.12.98 14:03:20---------------------------------------------------
324 
325   -----------------------------------------------------------------------*/
SwXFootnoteProperties(SwDoc * pDc)326 SwXFootnoteProperties::SwXFootnoteProperties(SwDoc* pDc) :
327 	pDoc(pDc),
328     m_pPropertySet(GetFootnoteSet())
329 {
330 }
331 /*-- 14.12.98 14:03:20---------------------------------------------------
332 
333   -----------------------------------------------------------------------*/
~SwXFootnoteProperties()334 SwXFootnoteProperties::~SwXFootnoteProperties()
335 {
336 
337 }
338 /*-- 14.12.98 14:03:20---------------------------------------------------
339 
340   -----------------------------------------------------------------------*/
getPropertySetInfo(void)341 uno::Reference< beans::XPropertySetInfo >  SwXFootnoteProperties::getPropertySetInfo(void)
342 																throw( uno::RuntimeException )
343 {
344     static uno::Reference< beans::XPropertySetInfo >  aRef = m_pPropertySet->getPropertySetInfo();
345 	return aRef;
346 }
347 /*-- 14.12.98 14:03:20---------------------------------------------------
348 
349   -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const uno::Any & aValue)350 void SwXFootnoteProperties::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
351 	throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
352 {
353 	vos::OGuard aGuard(Application::GetSolarMutex());
354 	if(pDoc)
355 	{
356         const SfxItemPropertySimpleEntry*  pEntry = m_pPropertySet->getPropertyMap()->getByName( rPropertyName );
357         if(pEntry)
358 		{
359             if ( pEntry->nFlags & PropertyAttribute::READONLY)
360                 throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
361 			SwFtnInfo aFtnInfo(pDoc->GetFtnInfo());
362             switch(pEntry->nWID)
363 			{
364 				case WID_PREFIX:
365 				{
366 					OUString uTmp;
367 					aValue >>= uTmp;
368 					aFtnInfo.SetPrefix(uTmp);
369 				}
370 				break;
371 				case WID_SUFFIX:
372 				{
373 					OUString uTmp;
374 					aValue >>= uTmp;
375 					aFtnInfo.SetSuffix(uTmp);
376 				}
377 				break;
378 				case  WID_NUMBERING_TYPE :
379 				{
380 					sal_Int16 nTmp = 0;
381 					aValue >>= nTmp;
382 					if(nTmp >= 0 &&
383 						(nTmp <= SVX_NUM_ARABIC ||
384                             nTmp > SVX_NUM_BITMAP))
385 						aFtnInfo.aFmt.SetNumberingType(nTmp);
386 					else
387 						throw lang::IllegalArgumentException();
388 				}
389 				break;
390 				case  WID_START_AT:
391 				{
392 					sal_Int16 nTmp = 0;
393 					aValue >>= nTmp;
394 					aFtnInfo.nFtnOffset = nTmp;
395 				}
396 				break;
397 				case  WID_FOOTNOTE_COUNTING  :
398 				{
399 					sal_Int16 nTmp = 0;
400 					aValue >>= nTmp;
401 					switch(nTmp)
402 					{
403 						case  FootnoteNumbering::PER_PAGE:
404 							aFtnInfo.eNum = FTNNUM_PAGE;
405 						break;
406 						case  FootnoteNumbering::PER_CHAPTER:
407 							aFtnInfo.eNum = FTNNUM_CHAPTER;
408 						break;
409 						case  FootnoteNumbering::PER_DOCUMENT:
410 							aFtnInfo.eNum = FTNNUM_DOC;
411 						break;
412 					}
413 				}
414 				break;
415 				case  WID_PARAGRAPH_STYLE    :
416 				{
417 					SwTxtFmtColl* pColl = lcl_GetParaStyle(pDoc, aValue);
418 					if(pColl)
419 						aFtnInfo.SetFtnTxtColl(*pColl);
420 				}
421 				break;
422 				case  WID_PAGE_STYLE :
423 				{
424 					SwPageDesc* pDesc = lcl_GetPageDesc(pDoc, aValue);
425 					if(pDesc)
426 						aFtnInfo.ChgPageDesc( pDesc );
427 				}
428 				break;
429 				case WID_ANCHOR_CHARACTER_STYLE:
430 				case  WID_CHARACTER_STYLE    :
431 				{
432 					SwCharFmt* pFmt = lcl_getCharFmt(pDoc, aValue);
433 					if(pFmt)
434 					{
435                         if(pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE)
436 							aFtnInfo.SetAnchorCharFmt(pFmt);
437 						else
438 							aFtnInfo.SetCharFmt(pFmt);
439 					}
440 				}
441 				break;
442 				case  WID_POSITION_END_OF_DOC:
443 				{
444 					sal_Bool bVal = *(sal_Bool*)aValue.getValue();
445 					aFtnInfo.ePos = bVal ? FTNPOS_CHAPTER : FTNPOS_PAGE;
446 				}
447 				break;
448 				case  WID_END_NOTICE         :
449 				{
450 					OUString uTmp;
451 					aValue >>= uTmp;
452 					aFtnInfo.aQuoVadis = String(uTmp);
453 				}
454 				break;
455 				case  WID_BEGIN_NOTICE       :
456 				{
457 					OUString uTmp;
458 					aValue >>= uTmp;
459 					aFtnInfo.aErgoSum = String(uTmp);
460 				}
461 				break;
462 			}
463 			pDoc->SetFtnInfo(aFtnInfo);
464 		}
465 		else
466 	        throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
467 	}
468 	else
469 		throw uno::RuntimeException();
470 }
471 /*-- 14.12.98 14:03:21---------------------------------------------------
472 
473   -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)474 uno::Any SwXFootnoteProperties::getPropertyValue(const OUString& rPropertyName)
475 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
476 {
477 	vos::OGuard aGuard(Application::GetSolarMutex());
478 	uno::Any aRet;
479 	if(pDoc)
480 	{
481         const SfxItemPropertySimpleEntry*  pEntry = m_pPropertySet->getPropertyMap()->getByName( rPropertyName );
482         if(pEntry)
483 		{
484 			const SwFtnInfo& rFtnInfo = pDoc->GetFtnInfo();
485             switch(pEntry->nWID)
486 			{
487 				case WID_PREFIX:
488 				{
489 					aRet <<= OUString(rFtnInfo.GetPrefix());
490 				}
491 				break;
492 				case WID_SUFFIX:
493 				{
494 					aRet <<= OUString(rFtnInfo.GetSuffix());
495 				}
496 				break;
497 				case  WID_NUMBERING_TYPE :
498 				{
499 					aRet <<= rFtnInfo.aFmt.GetNumberingType();
500 				}
501 				break;
502 				case  WID_START_AT:
503 					aRet <<= (sal_Int16)rFtnInfo.nFtnOffset;
504 				break;
505 				case  WID_FOOTNOTE_COUNTING  :
506 				{
507 					sal_Int16 nRet = 0;
508 					switch(rFtnInfo.eNum)
509 					{
510 						case  FTNNUM_PAGE:
511 							nRet = FootnoteNumbering::PER_PAGE;
512 						break;
513 						case  FTNNUM_CHAPTER:
514 							nRet = FootnoteNumbering::PER_CHAPTER;
515 						break;
516 						case  FTNNUM_DOC:
517 							nRet = FootnoteNumbering::PER_DOCUMENT;
518 						break;
519 					}
520 					aRet <<= nRet;
521 				}
522 				break;
523 				case  WID_PARAGRAPH_STYLE    :
524 				{
525 					SwTxtFmtColl* pColl = rFtnInfo.GetFtnTxtColl();
526 					String aString;
527 					if(pColl)
528 						aString = String ( pColl->GetName() );
529 					SwStyleNameMapper::FillProgName(aString, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
530 					aRet <<= OUString ( aString );
531 				}
532 				break;
533 				case  WID_PAGE_STYLE :
534 				{
535 					String aString;
536 					if( rFtnInfo.KnowsPageDesc() )
537 					{
538 						SwStyleNameMapper::FillProgName(
539 								rFtnInfo.GetPageDesc( *pDoc )->GetName(),
540 								aString,
541 								nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC,
542 								sal_True);
543 					}
544 					aRet <<= OUString ( aString );
545 				}
546 				break;
547 				case WID_ANCHOR_CHARACTER_STYLE:
548 				case WID_CHARACTER_STYLE:
549 				{
550 					String aString;
551 					const SwCharFmt* pCharFmt = 0;
552                     if( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE )
553 					{
554 						if( rFtnInfo.GetAnchorCharFmtDep()->GetRegisteredIn() )
555 							pCharFmt = rFtnInfo.GetAnchorCharFmt(*pDoc);
556 					}
557 					else
558 					{
559 						if( rFtnInfo.GetCharFmtDep()->GetRegisteredIn() )
560 							pCharFmt = rFtnInfo.GetCharFmt(*pDoc);
561 					}
562 					if( pCharFmt )
563 					{
564 						SwStyleNameMapper::FillProgName(
565 								pCharFmt->GetName(),
566 								aString,
567 								nsSwGetPoolIdFromName::GET_POOLID_CHRFMT,
568 								sal_True);
569 					}
570 					aRet <<= OUString ( aString );
571 				}
572 				break;
573 				case  WID_POSITION_END_OF_DOC:
574 				{
575 					sal_Bool bTemp = FTNPOS_CHAPTER == rFtnInfo.ePos;
576 					aRet.setValue(&bTemp, ::getCppuBooleanType());
577 				}
578 				break;
579 				case  WID_END_NOTICE         :
580 					aRet <<= OUString(rFtnInfo.aQuoVadis);
581 				break;
582 				case  WID_BEGIN_NOTICE       :
583 					aRet <<= OUString(rFtnInfo.aErgoSum);
584 				break;
585 			}
586 		}
587 		else
588 	        throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
589 	}
590 	else
591 		throw uno::RuntimeException();
592 	return aRet;
593 }
594 /*-- 14.12.98 14:03:21---------------------------------------------------
595 
596   -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)597 void SwXFootnoteProperties::addPropertyChangeListener(
598 	const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
599 		throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
600 {
601 	DBG_WARNING("not implemented");
602 }
603 /*-- 14.12.98 14:03:21---------------------------------------------------
604 
605   -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)606 void SwXFootnoteProperties::removePropertyChangeListener(
607 	const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
608 		throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
609 {
610 	DBG_WARNING("not implemented");
611 }
612 /*-- 14.12.98 14:03:21---------------------------------------------------
613 
614   -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)615 void SwXFootnoteProperties::addVetoableChangeListener(
616 	const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
617 		throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
618 {
619 	DBG_WARNING("not implemented");
620 }
621 /*-- 14.12.98 14:03:22---------------------------------------------------
622 
623   -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)624 void SwXFootnoteProperties::removeVetoableChangeListener(
625 	const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
626 		throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
627 {
628 	DBG_WARNING("not implemented");
629 }
630 
631 /******************************************************************
632  * SwXEndnoteProperties
633  ******************************************************************/
634 /* -----------------------------06.04.00 11:45--------------------------------
635 
636  ---------------------------------------------------------------------------*/
getImplementationName(void)637 OUString SwXEndnoteProperties::getImplementationName(void) throw( RuntimeException )
638 {
639 	return C2U("SwXEndnoteProperties");
640 }
641 /* -----------------------------06.04.00 11:45--------------------------------
642 
643  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)644 sal_Bool SwXEndnoteProperties::supportsService(const OUString& rServiceName) throw( RuntimeException )
645 {
646 	return C2U("com.sun.star.text.FootnoteSettings") == rServiceName;
647 }
648 /* -----------------------------06.04.00 11:45--------------------------------
649 
650  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)651 Sequence< OUString > SwXEndnoteProperties::getSupportedServiceNames(void) throw( RuntimeException )
652 {
653 	Sequence< OUString > aRet(1);
654 	OUString* pArray = aRet.getArray();
655 	pArray[0] = C2U("com.sun.star.text.FootnoteSettings");
656 	return aRet;
657 }
658 /*-- 14.12.98 14:27:39---------------------------------------------------
659 
660   -----------------------------------------------------------------------*/
SwXEndnoteProperties(SwDoc * pDc)661 SwXEndnoteProperties::SwXEndnoteProperties(SwDoc* pDc) :
662 	pDoc(pDc),
663     m_pPropertySet(GetEndnoteSet())
664 {
665 
666 }
667 /*-- 14.12.98 14:27:39---------------------------------------------------
668 
669   -----------------------------------------------------------------------*/
~SwXEndnoteProperties()670 SwXEndnoteProperties::~SwXEndnoteProperties()
671 {
672 
673 }
674 /*-- 14.12.98 14:27:40---------------------------------------------------
675 
676   -----------------------------------------------------------------------*/
getPropertySetInfo(void)677 uno::Reference< beans::XPropertySetInfo >  SwXEndnoteProperties::getPropertySetInfo(void) throw( uno::RuntimeException )
678 {
679     static uno::Reference< beans::XPropertySetInfo >  aRef = m_pPropertySet->getPropertySetInfo();
680 	return aRef;
681 }
682 /*-- 14.12.98 14:27:40---------------------------------------------------
683 
684   -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const uno::Any & aValue)685 void SwXEndnoteProperties::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
686 	throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
687 		lang::WrappedTargetException, uno::RuntimeException )
688 {
689 	vos::OGuard aGuard(Application::GetSolarMutex());
690 	if(pDoc)
691 	{
692         const SfxItemPropertySimpleEntry*  pEntry = m_pPropertySet->getPropertyMap()->getByName( rPropertyName );
693         if(pEntry)
694 		{
695             if ( pEntry->nFlags & PropertyAttribute::READONLY)
696                 throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
697 			SwEndNoteInfo aEndInfo(pDoc->GetEndNoteInfo());
698             switch(pEntry->nWID)
699 			{
700 				case WID_PREFIX:
701 				{
702 					OUString uTmp;
703 					aValue >>= uTmp;
704 					aEndInfo.SetPrefix(uTmp);
705 				}
706 				break;
707 				case WID_SUFFIX:
708 				{
709 					OUString uTmp;
710 					aValue >>= uTmp;
711 					aEndInfo.SetSuffix(uTmp);
712 				}
713 				break;
714 				case  WID_NUMBERING_TYPE :
715 				{
716 					sal_Int16 nTmp = 0;
717 					aValue >>= nTmp;
718 					aEndInfo.aFmt.SetNumberingType(nTmp);
719 				}
720 				break;
721 				case  WID_START_AT:
722 				{
723 					sal_Int16 nTmp = 0;
724 					aValue >>= nTmp;
725 					aEndInfo.nFtnOffset = nTmp;
726 				}
727 				break;
728 				case  WID_PARAGRAPH_STYLE    :
729 				{
730 					SwTxtFmtColl* pColl = lcl_GetParaStyle(pDoc, aValue);
731 					if(pColl)
732 						aEndInfo.SetFtnTxtColl(*pColl);
733 				}
734 				break;
735 				case  WID_PAGE_STYLE :
736 				{
737 					SwPageDesc* pDesc = lcl_GetPageDesc(pDoc, aValue);
738 					if(pDesc)
739 						aEndInfo.ChgPageDesc( pDesc );
740 				}
741 				break;
742 				case WID_ANCHOR_CHARACTER_STYLE:
743 				case  WID_CHARACTER_STYLE    :
744 				{
745 					SwCharFmt* pFmt = lcl_getCharFmt(pDoc, aValue);
746 					if(pFmt)
747 					{
748                         if(pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE)
749 							aEndInfo.SetAnchorCharFmt(pFmt);
750 						else
751 							aEndInfo.SetCharFmt(pFmt);
752 					}
753 				}
754 				break;
755 			}
756 			pDoc->SetEndNoteInfo(aEndInfo);
757 		}
758 		else
759 	        throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
760 	}
761 }
762 /*-- 14.12.98 14:27:41---------------------------------------------------
763 
764   -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)765 uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName)
766 	throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
767 {
768 	vos::OGuard aGuard(Application::GetSolarMutex());
769 	uno::Any aRet;
770 	if(pDoc)
771 	{
772         const SfxItemPropertySimpleEntry*  pEntry = m_pPropertySet->getPropertyMap()->getByName( rPropertyName );
773         if(pEntry)
774 		{
775 			const SwEndNoteInfo& rEndInfo = pDoc->GetEndNoteInfo();
776             switch(pEntry->nWID)
777 			{
778 				case WID_PREFIX:
779 					aRet <<= OUString(rEndInfo.GetPrefix());
780 				break;
781 				case WID_SUFFIX:
782 					aRet <<= OUString(rEndInfo.GetSuffix());
783 				break;
784 				case  WID_NUMBERING_TYPE :
785 					aRet <<= rEndInfo.aFmt.GetNumberingType();
786 				break;
787 				case  WID_START_AT:
788 					aRet <<= (sal_Int16)rEndInfo.nFtnOffset;
789 				break;
790 				case  WID_PARAGRAPH_STYLE    :
791 				{
792 					SwTxtFmtColl* pColl = rEndInfo.GetFtnTxtColl();
793 					String aString;
794 					if(pColl)
795 						aString = pColl->GetName();
796 					SwStyleNameMapper::FillProgName(
797 							aString,
798 							aString,
799 							nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
800 							sal_True);
801 					aRet <<= OUString ( aString );
802 
803 				}
804 				break;
805 				case  WID_PAGE_STYLE :
806 				{
807 					String aString;
808 					if( rEndInfo.KnowsPageDesc() )
809 					{
810 						SwStyleNameMapper::FillProgName(
811 							rEndInfo.GetPageDesc( *pDoc )->GetName(),
812 							aString,
813 							nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC,
814 							sal_True );
815 					}
816 					aRet <<= OUString ( aString );
817 				}
818 				break;
819 				case WID_ANCHOR_CHARACTER_STYLE:
820 				case WID_CHARACTER_STYLE:
821 				{
822 					String aString;
823 					const SwCharFmt* pCharFmt = 0;
824                     if( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE )
825 					{
826 						if( rEndInfo.GetAnchorCharFmtDep()->GetRegisteredIn() )
827 							pCharFmt = rEndInfo.GetAnchorCharFmt(*pDoc);
828 					}
829 					else
830 					{
831 						if( rEndInfo.GetCharFmtDep()->GetRegisteredIn() )
832 							pCharFmt = rEndInfo.GetCharFmt(*pDoc);
833 					}
834 					if( pCharFmt )
835 					{
836 						SwStyleNameMapper::FillProgName(
837 								pCharFmt->GetName(),
838 								aString,
839 								nsSwGetPoolIdFromName::GET_POOLID_CHRFMT,
840 								sal_True );
841 					}
842 					aRet <<= OUString ( aString );
843 				}
844 				break;
845 			}
846 		}
847 		else
848  	       throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
849 	}
850 	return aRet;
851 }
852 /*-- 14.12.98 14:27:41---------------------------------------------------
853 
854   -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)855 void SwXEndnoteProperties::addPropertyChangeListener(
856 	const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
857 {
858 	DBG_WARNING("not implemented");
859 }
860 /*-- 14.12.98 14:27:41---------------------------------------------------
861 
862   -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)863 void SwXEndnoteProperties::removePropertyChangeListener(const OUString& /*PropertyName*/,
864 		const uno:: Reference< beans::XPropertyChangeListener > & /*xListener*/)
865 		throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
866 {
867 	DBG_WARNING("not implemented");
868 }
869 /*-- 14.12.98 14:27:41---------------------------------------------------
870 
871   -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)872 void SwXEndnoteProperties::addVetoableChangeListener(const OUString& /*PropertyName*/,
873 	const uno:: Reference< beans::XVetoableChangeListener > & /*xListener*/)
874 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
875 {
876 	DBG_WARNING("not implemented");
877 }
878 /*-- 14.12.98 14:27:42---------------------------------------------------
879 
880   -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)881 void SwXEndnoteProperties::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno:: Reference< beans::XVetoableChangeListener > & /*xListener*/)
882 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
883 {
884 	DBG_WARNING("not implemented");
885 }
886 /******************************************************************
887  * SwXLineNumberingProperties
888  ******************************************************************/
889 /* -----------------------------06.04.00 11:47--------------------------------
890 
891  ---------------------------------------------------------------------------*/
getImplementationName(void)892 OUString SwXLineNumberingProperties::getImplementationName(void) throw( RuntimeException )
893 {
894 	return C2U("SwXLineNumberingProperties");
895 }
896 /* -----------------------------06.04.00 11:47--------------------------------
897 
898  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)899 sal_Bool SwXLineNumberingProperties::supportsService(const OUString& rServiceName) throw( RuntimeException )
900 {
901 	return C2U("com.sun.star.text.LineNumberingProperties") == rServiceName;
902 }
903 /* -----------------------------06.04.00 11:47--------------------------------
904 
905  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)906 Sequence< OUString > SwXLineNumberingProperties::getSupportedServiceNames(void) throw( RuntimeException )
907 {
908 	Sequence< OUString > aRet(1);
909 	OUString* pArray = aRet.getArray();
910 	pArray[0] = C2U("com.sun.star.text.LineNumberingProperties");
911 	return aRet;
912 }
913 /*-- 14.12.98 14:33:36---------------------------------------------------
914 
915   -----------------------------------------------------------------------*/
SwXLineNumberingProperties(SwDoc * pDc)916 SwXLineNumberingProperties::SwXLineNumberingProperties(SwDoc* pDc) :
917 	pDoc(pDc),
918     m_pPropertySet(GetLineNumberingSet())
919 {
920 
921 }
922 /*-- 14.12.98 14:33:37---------------------------------------------------
923 
924   -----------------------------------------------------------------------*/
~SwXLineNumberingProperties()925 SwXLineNumberingProperties::~SwXLineNumberingProperties()
926 {
927 
928 }
929 /*-- 14.12.98 14:33:37---------------------------------------------------
930 
931   -----------------------------------------------------------------------*/
getPropertySetInfo(void)932 uno::Reference< beans::XPropertySetInfo >  SwXLineNumberingProperties::getPropertySetInfo(void) throw( uno::RuntimeException )
933 {
934     static uno::Reference< beans::XPropertySetInfo >  aRef = m_pPropertySet->getPropertySetInfo();
935 	return aRef;
936 }
937 /*-- 14.12.98 14:33:37---------------------------------------------------
938 
939   -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const Any & aValue)940 void SwXLineNumberingProperties::setPropertyValue(
941 	const OUString& rPropertyName, const Any& aValue)
942 		throw( UnknownPropertyException, PropertyVetoException,
943 				IllegalArgumentException, WrappedTargetException, RuntimeException )
944 {
945 	vos::OGuard aGuard(Application::GetSolarMutex());
946 	if(pDoc)
947 	{
948         const SfxItemPropertySimpleEntry*  pEntry = m_pPropertySet->getPropertyMap()->getByName( rPropertyName );
949         if(pEntry)
950 		{
951             if ( pEntry->nFlags & PropertyAttribute::READONLY)
952                 throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
953 			SwLineNumberInfo  aInfo(pDoc->GetLineNumberInfo());
954             switch(pEntry->nWID)
955 			{
956 				case WID_NUM_ON:
957 				{
958 					sal_Bool bVal = *(sal_Bool*)aValue.getValue();
959 					aInfo.SetPaintLineNumbers(bVal);
960 				}
961 				break;
962 				case WID_CHARACTER_STYLE :
963 				{
964 					SwCharFmt* pFmt = lcl_getCharFmt(pDoc, aValue);
965 					if(pFmt)
966 						aInfo.SetCharFmt(pFmt);
967 				}
968 				break;
969 				case WID_NUMBERING_TYPE  :
970 				{
971 					SvxNumberType aNumType(aInfo.GetNumType());
972 					sal_Int16 nTmp = 0;
973 					aValue >>= nTmp;
974 					aNumType.SetNumberingType(nTmp);
975 					aInfo.SetNumType(aNumType);
976 				}
977 				break;
978 				case WID_NUMBER_POSITION :
979 				{
980 					sal_Int16 nTmp = 0;
981 					aValue >>= nTmp;
982 					switch(nTmp)
983 					{
984 						case  style::LineNumberPosition::LEFT:
985 							 aInfo.SetPos(LINENUMBER_POS_LEFT); ;
986 						break;
987 						case style::LineNumberPosition::RIGHT :
988 							 aInfo.SetPos(LINENUMBER_POS_RIGHT);       ;
989 						break;
990 						case  style::LineNumberPosition::INSIDE:
991 							aInfo.SetPos(LINENUMBER_POS_INSIDE);      ;
992 						break;
993 						case  style::LineNumberPosition::OUTSIDE:
994 							aInfo.SetPos(LINENUMBER_POS_OUTSIDE);
995 						break;
996 					}
997 				}
998 				break;
999 				case WID_DISTANCE        :
1000 				{
1001 					sal_Int32 nVal = 0;
1002 					aValue >>= nVal;
1003                     sal_Int32 nTmp = MM100_TO_TWIP(nVal);
1004                     if (nTmp > USHRT_MAX)
1005                         nTmp = USHRT_MAX;
1006                     aInfo.SetPosFromLeft( static_cast< sal_uInt16 >(nTmp) );
1007 				}
1008 				break;
1009 				case WID_INTERVAL   :
1010 				{
1011 					sal_Int16 nTmp = 0;
1012                     aValue >>= nTmp;
1013                     if( nTmp > 0)
1014 					    aInfo.SetCountBy(nTmp);
1015 				}
1016 				break;
1017 				case WID_SEPARATOR_TEXT  :
1018 				{
1019 					OUString uTmp;
1020 					aValue >>= uTmp;
1021 					aInfo.SetDivider(uTmp);
1022 				}
1023 				break;
1024 				case WID_SEPARATOR_INTERVAL:
1025 				{
1026 					sal_Int16 nTmp = 0;
1027 					aValue >>= nTmp;
1028                     if( nTmp >= 0)
1029 					    aInfo.SetDividerCountBy(nTmp);
1030 				}
1031 				break;
1032 				case WID_COUNT_EMPTY_LINES :
1033 				{
1034 					sal_Bool bVal = *(sal_Bool*)aValue.getValue();
1035 					aInfo.SetCountBlankLines(bVal);
1036 				}
1037 				break;
1038 				case WID_COUNT_LINES_IN_FRAMES :
1039 				{
1040 					sal_Bool bVal = *(sal_Bool*)aValue.getValue();
1041 					aInfo.SetCountInFlys(bVal);
1042 				}
1043 				break;
1044 				case WID_RESTART_AT_EACH_PAGE :
1045 				{
1046 					sal_Bool bVal = *(sal_Bool*)aValue.getValue();
1047 					aInfo.SetRestartEachPage(bVal);
1048 				}
1049 				break;
1050 			}
1051 			pDoc->SetLineNumberInfo(aInfo);
1052 		}
1053 		else
1054 	        throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1055 	}
1056 	else
1057 		throw uno::RuntimeException();
1058 }
1059 /*-- 14.12.98 14:33:38---------------------------------------------------
1060 
1061   -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)1062 Any SwXLineNumberingProperties::getPropertyValue(const OUString& rPropertyName)
1063 	throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
1064 {
1065 	vos::OGuard aGuard(Application::GetSolarMutex());
1066 	Any aRet;
1067 	if(pDoc)
1068 	{
1069         const SfxItemPropertySimpleEntry*  pEntry = m_pPropertySet->getPropertyMap()->getByName( rPropertyName );
1070         if(pEntry)
1071 		{
1072 			const SwLineNumberInfo& rInfo = pDoc->GetLineNumberInfo();
1073             switch(pEntry->nWID)
1074 			{
1075 				case WID_NUM_ON:
1076 				{
1077 					sal_Bool bTemp = rInfo.IsPaintLineNumbers();
1078 					aRet.setValue(&bTemp, ::getCppuBooleanType());
1079 				}
1080 				break;
1081 				case WID_CHARACTER_STYLE :
1082                 {
1083                     String aString;
1084                     // return empty string if no char format is set
1085                     // otherwise it would be created here
1086                     if(rInfo.HasCharFormat())
1087                     {
1088                         SwStyleNameMapper::FillProgName(
1089                                     rInfo.GetCharFmt(*pDoc)->GetName(),
1090 									aString,
1091                                     nsSwGetPoolIdFromName::GET_POOLID_CHRFMT,
1092 									sal_True);
1093                     }
1094                     aRet <<= OUString ( aString );
1095                 }
1096                 break;
1097 				case WID_NUMBERING_TYPE  :
1098 					aRet <<= rInfo.GetNumType().GetNumberingType();
1099 				break;
1100 				case WID_NUMBER_POSITION :
1101 				{
1102 					sal_Int16 nRet = 0;
1103 					switch(rInfo.GetPos())
1104 					{
1105 						case  LINENUMBER_POS_LEFT:
1106 							nRet = style::LineNumberPosition::LEFT;
1107 						break;
1108 						case LINENUMBER_POS_RIGHT :
1109 							nRet = style::LineNumberPosition::RIGHT      ;
1110 						break;
1111 						case  LINENUMBER_POS_INSIDE:
1112 							nRet = style::LineNumberPosition::INSIDE     ;
1113 						break;
1114 						case LINENUMBER_POS_OUTSIDE :
1115 							nRet = style::LineNumberPosition::OUTSIDE    ;
1116 						break;
1117 					}
1118 					aRet <<= nRet;
1119 				}
1120 				break;
1121 				case WID_DISTANCE        :
1122 				{
1123 					sal_uInt32 nPos = rInfo.GetPosFromLeft();
1124 					if(USHRT_MAX == nPos)
1125 						nPos = 0;
1126 					aRet <<= static_cast < sal_Int32 >(TWIP_TO_MM100_UNSIGNED(nPos));
1127 				}
1128 				break;
1129 				case WID_INTERVAL   :
1130 					aRet <<= (sal_Int16)rInfo.GetCountBy();
1131 				break;
1132 				case WID_SEPARATOR_TEXT  :
1133 					aRet <<= OUString(rInfo.GetDivider());
1134 				break;
1135 				case WID_SEPARATOR_INTERVAL:
1136 					aRet <<= (sal_Int16)rInfo.GetDividerCountBy();
1137 				break;
1138 				case WID_COUNT_EMPTY_LINES :
1139 				{
1140 					sal_Bool bTemp = rInfo.IsCountBlankLines();
1141 					aRet.setValue(&bTemp, ::getCppuBooleanType());
1142 				}
1143 				break;
1144 				case WID_COUNT_LINES_IN_FRAMES :
1145 				{
1146 					sal_Bool bTemp = rInfo.IsCountInFlys();
1147 					aRet.setValue(&bTemp, ::getCppuBooleanType());
1148 				}
1149 				break;
1150 				case WID_RESTART_AT_EACH_PAGE :
1151 				{
1152 					sal_Bool bTemp = rInfo.IsRestartEachPage();
1153 					aRet.setValue(&bTemp, ::getCppuBooleanType());
1154 				}
1155 				break;
1156 			}
1157 		}
1158 		else
1159 	        throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1160 	}
1161 	else
1162 		throw uno::RuntimeException();
1163 	return aRet;
1164 }
1165 /*-- 14.12.98 14:33:38---------------------------------------------------
1166 
1167   -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1168 void SwXLineNumberingProperties::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno:: Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1169 {
1170 DBG_WARNING("not implemented");
1171 }
1172 /*-- 14.12.98 14:33:38---------------------------------------------------
1173 
1174   -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1175 void SwXLineNumberingProperties::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno:: Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1176 {
1177 DBG_WARNING("not implemented");
1178 }
1179 /*-- 14.12.98 14:33:39---------------------------------------------------
1180 
1181   -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1182 void SwXLineNumberingProperties::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno:: Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1183 {
1184 DBG_WARNING("not implemented");
1185 }
1186 /*-- 14.12.98 14:33:39---------------------------------------------------
1187 
1188   -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1189 void SwXLineNumberingProperties::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno:: Reference< beans::XVetoableChangeListener > & /*xListener*/)
1190 	throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1191 {
1192 DBG_WARNING("not implemented");
1193 }
1194 /******************************************************************
1195  * SwXNumberingRules
1196  ******************************************************************/
1197 String	SwXNumberingRules::sInvalidStyle(String::CreateFromAscii("__XXX___invalid"));
1198 
GetInvalidStyle()1199 const String&	SwXNumberingRules::GetInvalidStyle()
1200 {
1201 	return sInvalidStyle;
1202 }
1203 /* -----------------------------10.03.00 17:05--------------------------------
1204 
1205  ---------------------------------------------------------------------------*/
getUnoTunnelId()1206 const uno::Sequence< sal_Int8 > & SwXNumberingRules::getUnoTunnelId()
1207 {
1208     static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
1209 	return aSeq;
1210 }
1211 /* -----------------------------10.03.00 17:05--------------------------------
1212 
1213  ---------------------------------------------------------------------------*/
1214 // return implementation specific data
getSomething(const uno::Sequence<sal_Int8> & rId)1215 sal_Int64 SwXNumberingRules::getSomething( const uno::Sequence< sal_Int8 > & rId ) throw(uno::RuntimeException)
1216 {
1217     if( rId.getLength() == 16
1218         && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1219 										rId.getConstArray(), 16 ) )
1220 	{
1221 		return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
1222 	}
1223 	return 0;
1224 }
1225 
1226 /* -----------------------------06.04.00 11:47--------------------------------
1227 
1228  ---------------------------------------------------------------------------*/
getImplementationName(void)1229 OUString SwXNumberingRules::getImplementationName(void) throw( RuntimeException )
1230 {
1231 	return C2U("SwXNumberingRules");
1232 }
1233 /* -----------------------------06.04.00 11:47--------------------------------
1234 
1235  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)1236 sal_Bool SwXNumberingRules::supportsService(const OUString& rServiceName) throw( RuntimeException )
1237 {
1238 	return C2U("com.sun.star.text.NumberingRules") == rServiceName;
1239 }
1240 /* -----------------------------06.04.00 11:47--------------------------------
1241 
1242  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)1243 Sequence< OUString > SwXNumberingRules::getSupportedServiceNames(void) throw( RuntimeException )
1244 {
1245 	Sequence< OUString > aRet(1);
1246 	OUString* pArray = aRet.getArray();
1247 	pArray[0] = C2U("com.sun.star.text.NumberingRules");
1248 	return aRet;
1249 }
1250 
1251 /*-- 14.12.98 14:57:57---------------------------------------------------
1252 
1253   -----------------------------------------------------------------------*/
SwXNumberingRules(const SwNumRule & rRule)1254 SwXNumberingRules::SwXNumberingRules(const SwNumRule& rRule) :
1255 	pDoc(0),
1256 	pDocShell(0),
1257 	pNumRule(new SwNumRule(rRule)),
1258     m_pPropertySet(GetNumberingRulesSet()),
1259 	bOwnNumRuleCreated(sal_True)
1260 {
1261 	sal_uInt16 i;
1262 
1263 	//erstmal das Doc organisieren; es haengt an den gesetzten Zeichenvorlagen - wenn
1264 	// keine gesetzt sind, muss es auch ohne gehen
1265 	for( i = 0; i < MAXLEVEL; i++)
1266 	{
1267 		SwNumFmt rFmt(pNumRule->Get(i));
1268 		SwCharFmt* pCharFmt = rFmt.GetCharFmt();
1269 		if(pCharFmt)
1270 		{
1271 			pDoc = pCharFmt->GetDoc();
1272 			break;
1273 		}
1274 	}
1275 	if(pDoc)
1276 		pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1277 	for(i = 0; i < MAXLEVEL; i++)
1278 	{
1279 		sNewCharStyleNames[i] = SwXNumberingRules::GetInvalidStyle();
1280 		sNewBulletFontNames[i] = SwXNumberingRules::GetInvalidStyle();
1281 	}
1282 }
1283 /* -----------------22.02.99 16:35-------------------
1284  *
1285  * --------------------------------------------------*/
SwXNumberingRules(SwDocShell & rDocSh)1286 SwXNumberingRules::SwXNumberingRules(SwDocShell& rDocSh) :
1287 	pDoc(0),
1288 	pDocShell(&rDocSh),
1289 	pNumRule(0),
1290     m_pPropertySet(GetNumberingRulesSet()),
1291 	bOwnNumRuleCreated(sal_False)
1292 {
1293 	pDocShell->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1294 }
1295 /* -----------------------------24.08.00 11:36--------------------------------
1296 
1297  ---------------------------------------------------------------------------*/
SwXNumberingRules(SwDoc & rDoc)1298 SwXNumberingRules::SwXNumberingRules(SwDoc& rDoc) :
1299 	pDoc(&rDoc),
1300 	pDocShell(0),
1301 	pNumRule(0),
1302     m_pPropertySet(GetNumberingRulesSet()),
1303 	bOwnNumRuleCreated(sal_False)
1304 {
1305 	rDoc.GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1306 	sCreatedNumRuleName = rDoc.GetUniqueNumRuleName();
1307 #if OSL_DEBUG_LEVEL > 1
1308 	sal_uInt16 nIndex =
1309 #endif
1310     // --> OD 2008-02-11 #newlistlevelattrs#
1311     rDoc.MakeNumRule( sCreatedNumRuleName, 0, sal_False,
1312                       // --> OD 2008-06-06 #i89178#
1313                       numfunc::GetDefaultPositionAndSpaceMode() );
1314                       // <--
1315     // <--
1316 #if OSL_DEBUG_LEVEL > 1
1317     (void)nIndex;
1318 #endif
1319 }
1320 /*-- 14.12.98 14:57:57---------------------------------------------------
1321 
1322   -----------------------------------------------------------------------*/
~SwXNumberingRules()1323 SwXNumberingRules::~SwXNumberingRules()
1324 {
1325     vos::OGuard aGuard(Application::GetSolarMutex());
1326     if(pDoc && sCreatedNumRuleName.Len())
1327 		pDoc->DelNumRule( sCreatedNumRuleName );
1328 	if( pNumRule && bOwnNumRuleCreated )
1329 		delete pNumRule;
1330 }
1331 /*-- 14.12.98 14:57:58---------------------------------------------------
1332 
1333   -----------------------------------------------------------------------*/
replaceByIndex(sal_Int32 nIndex,const uno::Any & rElement)1334 void SwXNumberingRules::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElement)
1335 	throw( lang::IllegalArgumentException, lang::IndexOutOfBoundsException,
1336  				 lang::WrappedTargetException, uno::RuntimeException)
1337 {
1338 	vos::OGuard aGuard(Application::GetSolarMutex());
1339     if(nIndex < 0 || MAXLEVEL <= nIndex)
1340 		throw lang::IndexOutOfBoundsException();
1341 
1342 	if(rElement.getValueType().getTypeClass() != uno::TypeClass_SEQUENCE)
1343 		throw lang::IllegalArgumentException();
1344 	const uno::Sequence<beans::PropertyValue>& rProperties =
1345 					*(const uno::Sequence<beans::PropertyValue>*)rElement.getValue();
1346 	SwNumRule* pRule = 0;
1347 	if(pNumRule)
1348 		SwXNumberingRules::SetNumberingRuleByIndex( *pNumRule,
1349 							rProperties, nIndex);
1350 	else if(pDocShell)
1351 	{
1352         // --> OD 2008-04-21 #i87650# - correction of cws swwarnings:
1353         // Do not set member <pNumRule>
1354 //        pNumRule = pDocShell->GetDoc()->GetOutlineNumRule();
1355 //        SwNumRule aNumRule(*pNumRule);
1356         SwNumRule aNumRule( *(pDocShell->GetDoc()->GetOutlineNumRule()) );
1357         // <--
1358 		SwXNumberingRules::SetNumberingRuleByIndex( aNumRule,
1359 							rProperties, nIndex);
1360 		//hier noch die Zeichenformate bei Bedarf setzen
1361 		const SwCharFmts* pFmts = pDocShell->GetDoc()->GetCharFmts();
1362 		sal_uInt16 nChCount = pFmts->Count();
1363 		for(sal_uInt16 i = 0; i < MAXLEVEL;i++)
1364 		{
1365 			SwNumFmt aFmt(aNumRule.Get( i ));
1366 			if(sNewCharStyleNames[i].Len() &&
1367 				!sNewCharStyleNames[i].EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_CHARACTER_FORMAT_NONE)) &&
1368 				   (!aFmt.GetCharFmt() ||
1369 					aFmt.GetCharFmt()->GetName()!= sNewCharStyleNames[i] ))
1370 			{
1371 				SwCharFmt* pCharFmt = 0;
1372 				for(sal_uInt16 j = 0; j< nChCount; j++)
1373 				{
1374 					SwCharFmt* pTmp = (*pFmts)[j];
1375 					if(pTmp->GetName() == sNewCharStyleNames[i])
1376 					{
1377 						pCharFmt = pTmp;
1378 						break;
1379 					}
1380 				}
1381 				if(!pCharFmt)
1382 				{
1383 					SfxStyleSheetBase* pBase;
1384 					pBase = pDocShell->GetStyleSheetPool()->Find(sNewCharStyleNames[i],
1385 																	SFX_STYLE_FAMILY_CHAR);
1386 					if(!pBase)
1387 						pBase = &pDocShell->GetStyleSheetPool()->Make(sNewCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
1388 					pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
1389 
1390 				}
1391 				aFmt.SetCharFmt( pCharFmt );
1392 				aNumRule.Set( i, aFmt );
1393 			}
1394 		}
1395 		pDocShell->GetDoc()->SetOutlineNumRule( aNumRule );
1396 	}
1397 	else if(!pNumRule && pDoc && sCreatedNumRuleName.Len() &&
1398 		0 != (pRule = pDoc->FindNumRulePtr( sCreatedNumRuleName )))
1399 	{
1400 		SwXNumberingRules::SetNumberingRuleByIndex( *pRule,
1401 							rProperties, nIndex);
1402 
1403 		pRule->Validate();
1404 	}
1405 	else
1406 		throw uno::RuntimeException();
1407 
1408 }
1409 /*-- 14.12.98 14:57:58---------------------------------------------------
1410 
1411   -----------------------------------------------------------------------*/
getCount(void)1412 sal_Int32 SwXNumberingRules::getCount(void) throw( uno::RuntimeException )
1413 {
1414 	return MAXLEVEL;
1415 }
1416 /*-- 14.12.98 14:57:58---------------------------------------------------
1417 
1418   -----------------------------------------------------------------------*/
getByIndex(sal_Int32 nIndex)1419 uno::Any SwXNumberingRules::getByIndex(sal_Int32 nIndex)
1420 	throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
1421 			uno::RuntimeException )
1422 {
1423 	vos::OGuard aGuard(Application::GetSolarMutex());
1424     if(nIndex < 0 || MAXLEVEL <= nIndex)
1425 		throw lang::IndexOutOfBoundsException();
1426 
1427 	uno::Any aVal;
1428 	const SwNumRule* pRule = pNumRule;
1429 	if(!pRule && pDoc && sCreatedNumRuleName.Len())
1430 		pRule = pDoc->FindNumRulePtr( sCreatedNumRuleName );
1431 	if(pRule)
1432 	{
1433 		uno::Sequence<beans::PropertyValue> aRet = GetNumberingRuleByIndex(
1434 										*pRule, nIndex);
1435 		aVal.setValue(&aRet, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0));
1436 
1437 	}
1438 	else if(pDocShell)
1439 	{
1440 		uno::Sequence<beans::PropertyValue> aRet = GetNumberingRuleByIndex(
1441 				*pDocShell->GetDoc()->GetOutlineNumRule(), nIndex);
1442 		aVal.setValue(&aRet, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0));
1443 	}
1444 	else
1445 		throw uno::RuntimeException();
1446 	return aVal;
1447 }
1448 /*-- 14.12.98 14:57:59---------------------------------------------------
1449 
1450   -----------------------------------------------------------------------*/
getElementType(void)1451 uno::Type SwXNumberingRules::getElementType(void)
1452 	throw( uno::RuntimeException )
1453 {
1454 	return ::getCppuType((uno::Sequence<beans::PropertyValue>*)0);
1455 }
1456 /*-- 14.12.98 14:57:59---------------------------------------------------
1457 
1458   -----------------------------------------------------------------------*/
hasElements(void)1459 sal_Bool SwXNumberingRules::hasElements(void) throw( uno::RuntimeException )
1460 {
1461 	return sal_True;
1462 }
1463 /*-- 14.12.98 14:57:59---------------------------------------------------
1464 
1465   -----------------------------------------------------------------------*/
GetNumberingRuleByIndex(const SwNumRule & rNumRule,sal_Int32 nIndex) const1466 uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetNumberingRuleByIndex(
1467 				const SwNumRule& rNumRule, sal_Int32 nIndex) const
1468 {
1469 	vos::OGuard aGuard(Application::GetSolarMutex());
1470 	DBG_ASSERT( 0 <= nIndex && nIndex < MAXLEVEL, "index out of range" );
1471 
1472 	const SwNumFmt& rFmt = rNumRule.Get( (sal_uInt16)nIndex );
1473 
1474 	sal_Bool bChapterNum = pDocShell != 0;
1475 
1476 	PropValDataArr	aPropertyValues;
1477 	//fill all properties into the array
1478 
1479 	//adjust
1480 	SvxAdjust eAdj = rFmt.GetNumAdjust();
1481 	sal_Int16 nINT16 = aSvxToUnoAdjust[(sal_uInt16)eAdj];
1482 	PropValData* pData = new PropValData((void*)&nINT16, "Adjust", ::getCppuType((const sal_Int16*)0) );
1483 	aPropertyValues.Insert(pData, aPropertyValues.Count());
1484 
1485 	//parentnumbering
1486 	nINT16 = rFmt.GetIncludeUpperLevels();
1487 	pData = new PropValData((void*)&nINT16, "ParentNumbering", ::getCppuType((const sal_Int16*)0));
1488 	aPropertyValues.Insert(pData, aPropertyValues.Count());
1489 
1490 	//prefix
1491 	OUString aUString = rFmt.GetPrefix();
1492 	pData = new PropValData((void*)&aUString, "Prefix", ::getCppuType((const OUString*)0));
1493 	aPropertyValues.Insert(pData, aPropertyValues.Count());
1494 
1495 	//suffix
1496 	aUString = rFmt.GetSuffix();
1497 	pData = new PropValData((void*)&aUString, "Suffix", ::getCppuType((const OUString*)0));
1498 	aPropertyValues.Insert(pData, aPropertyValues.Count());
1499 
1500 	//char style name
1501 	SwCharFmt* pCharFmt = rFmt.GetCharFmt();
1502 	String CharStyleName;
1503 	if(pCharFmt)
1504 		CharStyleName = pCharFmt->GetName();
1505 	//egal ob ein Style vorhanden ist oder nicht ueberschreibt der Array-Eintrag diesen String
1506 	if(sNewCharStyleNames[(sal_uInt16)nIndex].Len() &&
1507 		SwXNumberingRules::sInvalidStyle != sNewCharStyleNames[(sal_uInt16)nIndex])
1508 		CharStyleName = sNewCharStyleNames[(sal_uInt16)nIndex];
1509 
1510 	String aString;
1511 	SwStyleNameMapper::FillProgName( CharStyleName, aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
1512 	aUString = aString;
1513 	pData = new PropValData((void*)&aUString, "CharStyleName", ::getCppuType((const OUString*)0));
1514 	aPropertyValues.Insert(pData, aPropertyValues.Count());
1515 
1516 	//startvalue
1517 	nINT16 = rFmt.GetStart();
1518 	pData = new PropValData((void*)&nINT16, "StartWith", ::getCppuType((const sal_Int16*)0));
1519 	aPropertyValues.Insert(pData, aPropertyValues.Count());
1520 
1521     // --> OD 2008-01-23 #newlistlevelattrs#
1522     if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1523     {
1524         //leftmargin
1525         sal_Int32 nINT32 = TWIP_TO_MM100(rFmt.GetAbsLSpace());
1526         pData = new PropValData((void*)&nINT32, SW_PROP_NAME_STR(UNO_NAME_LEFT_MARGIN), ::getCppuType((const sal_Int32*)0));
1527         aPropertyValues.Insert(pData, aPropertyValues.Count());
1528 
1529         //chartextoffset
1530         nINT32 = TWIP_TO_MM100(rFmt.GetCharTextDistance());
1531         pData = new PropValData((void*)&nINT32, SW_PROP_NAME_STR(UNO_NAME_SYMBOL_TEXT_DISTANCE), ::getCppuType((const sal_Int32*)0));
1532         aPropertyValues.Insert(pData, aPropertyValues.Count());
1533 
1534         //firstlineoffset
1535         nINT32 = TWIP_TO_MM100(rFmt.GetFirstLineOffset());
1536         pData = new PropValData((void*)&nINT32, SW_PROP_NAME_STR(UNO_NAME_FIRST_LINE_OFFSET), ::getCppuType((const sal_Int32*)0));
1537         aPropertyValues.Insert(pData, aPropertyValues.Count());
1538     }
1539     // <--
1540 
1541     // --> OD 2008-01-15 #newlistlevelattrs#
1542     // PositionAndSpaceMode
1543     nINT16 = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
1544     if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1545     {
1546         nINT16 = PositionAndSpaceMode::LABEL_ALIGNMENT;
1547     }
1548     pData = new PropValData( (void*)&nINT16,
1549                              SW_PROP_NAME_STR(UNO_NAME_POSITION_AND_SPACE_MODE),
1550                              ::getCppuType((const sal_Int16*)0) );
1551     aPropertyValues.Insert(pData, aPropertyValues.Count());
1552 
1553     if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1554     {
1555         // LabelFollowedBy
1556         nINT16 = LabelFollow::LISTTAB;
1557         if ( rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE )
1558         {
1559             nINT16 = LabelFollow::SPACE;
1560         }
1561         else if ( rFmt.GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
1562         {
1563             nINT16 = LabelFollow::NOTHING;
1564         }
1565         pData = new PropValData( (void*)&nINT16,
1566                                  SW_PROP_NAME_STR(UNO_NAME_LABEL_FOLLOWED_BY),
1567                                  ::getCppuType((const sal_Int16*)0) );
1568         aPropertyValues.Insert(pData, aPropertyValues.Count());
1569 
1570         // ListtabStopPosition
1571         sal_Int32 nINT32 = TWIP_TO_MM100(rFmt.GetListtabPos());
1572         pData = new PropValData( (void*)&nINT32,
1573                                  SW_PROP_NAME_STR(UNO_NAME_LISTTAB_STOP_POSITION),
1574                                  ::getCppuType((const sal_Int32*)0));
1575         aPropertyValues.Insert(pData, aPropertyValues.Count());
1576 
1577         // FirstLineIndent
1578         nINT32 = TWIP_TO_MM100(rFmt.GetFirstLineIndent());
1579         pData = new PropValData( (void*)&nINT32,
1580                                  SW_PROP_NAME_STR(UNO_NAME_FIRST_LINE_INDENT),
1581                                  ::getCppuType((const sal_Int32*)0));
1582         aPropertyValues.Insert(pData, aPropertyValues.Count());
1583 
1584         // IndentAt
1585         nINT32 = TWIP_TO_MM100(rFmt.GetIndentAt());
1586         pData = new PropValData( (void*)&nINT32,
1587                                  SW_PROP_NAME_STR(UNO_NAME_INDENT_AT),
1588                                  ::getCppuType((const sal_Int32*)0));
1589         aPropertyValues.Insert(pData, aPropertyValues.Count());
1590     }
1591     // <--
1592 
1593     //numberingtype
1594 	nINT16 = rFmt.GetNumberingType();
1595 	pData = new PropValData((void*)&nINT16, "NumberingType", ::getCppuType((const sal_Int16*)0));
1596 	aPropertyValues.Insert(pData, aPropertyValues.Count());
1597 
1598 	if(!bChapterNum)
1599 	{
1600 		if(SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
1601 		{
1602 			//BulletId
1603 			nINT16 = rFmt.GetBulletChar();
1604 			pData = new PropValData((void*)&nINT16, "BulletId", ::getCppuType((const sal_Int16*)0));
1605 			aPropertyValues.Insert(pData, aPropertyValues.Count());
1606 
1607 			const Font* pFont = rFmt.GetBulletFont();
1608 
1609 			//BulletChar
1610 			aUString = OUString(rFmt.GetBulletChar());
1611 			pData = new PropValData((void*)&aUString, "BulletChar", ::getCppuType((const OUString*)0));
1612 			aPropertyValues.Insert(pData, aPropertyValues.Count());
1613 
1614 			//BulletFontName
1615 			String sBulletFontName;
1616 			if(pFont)
1617 				sBulletFontName = pFont->GetStyleName();
1618 			aUString = sBulletFontName;
1619 			pData = new PropValData((void*)&aUString, "BulletFontName", ::getCppuType((const OUString*)0));
1620 			aPropertyValues.Insert(pData, aPropertyValues.Count());
1621 
1622 			//BulletFont
1623 			if(pFont)
1624 			{
1625 			 	awt::FontDescriptor aDesc;
1626 				SvxUnoFontDescriptor::ConvertFromFont( *pFont, aDesc );
1627 				pData = new PropValData((void*)&aDesc, SW_PROP_NAME_STR(UNO_NAME_BULLET_FONT), ::getCppuType((const awt::FontDescriptor*)0));
1628 				aPropertyValues.Insert(pData, aPropertyValues.Count());
1629 			}
1630 		}
1631 		if(SVX_NUM_BITMAP == rFmt.GetNumberingType())
1632 		{
1633 			//GraphicURL
1634 			const SvxBrushItem* pBrush = rFmt.GetBrush();
1635 			if(pBrush)
1636 			{
1637 				Any aAny;
1638 				pBrush->QueryValue( aAny, MID_GRAPHIC_URL );
1639 				aAny >>= aUString;
1640 			}
1641 			else
1642 				aUString = aEmptyStr;
1643 			pData = new PropValData((void*)&aUString, SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_URL), ::getCppuType((const OUString*)0));
1644 			aPropertyValues.Insert(pData, aPropertyValues.Count());
1645 
1646 			//graphicbitmap
1647 			const Graphic* pGraphic = 0;
1648 			if(pBrush )
1649 				pGraphic = pBrush->GetGraphic();
1650 			if(pGraphic)
1651 			{
1652 				uno::Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( pGraphic->GetBitmapEx() );
1653 				pData = new PropValData((void*)&xBmp, SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_BITMAP),
1654 								::getCppuType((const uno::Reference<awt::XBitmap>*)0));
1655 				aPropertyValues.Insert(pData, aPropertyValues.Count());
1656 			}
1657 		 	Size aSize = rFmt.GetGraphicSize();
1658             // --> OD 2010-05-04 #i101131# - applying patch from CMC
1659             // adjust conversion due to type mismatch between <Size> and <awt::Size>
1660 //            aSize.Width() = TWIP_TO_MM100( aSize.Width() );
1661 //            aSize.Height() = TWIP_TO_MM100( aSize.Height() );
1662 //            pData = new PropValData((void*)&aSize, SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_SIZE), ::getCppuType((const awt::Size*)0));
1663             awt::Size aAwtSize(TWIP_TO_MM100(aSize.Width()), TWIP_TO_MM100(aSize.Height()));
1664             pData = new PropValData((void*)&aAwtSize, SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_SIZE), ::getCppuType((const awt::Size*)0));
1665             // <--
1666 			aPropertyValues.Insert(pData, aPropertyValues.Count());
1667 
1668 			const SwFmtVertOrient* pOrient = rFmt.GetGraphicOrientation();
1669 			if(pOrient)
1670 			{
1671 				pData = new PropValData((void*)0, SW_PROP_NAME_STR(UNO_NAME_VERT_ORIENT), ::getCppuType((const sal_Int16*)0));
1672 				((const SfxPoolItem*)pOrient)->QueryValue(pData->aVal, MID_VERTORIENT_ORIENT);
1673 				aPropertyValues.Insert(pData, aPropertyValues.Count());
1674 			}
1675 		}
1676 
1677 	}
1678 	else
1679 	{
1680 		//Vorlagenname
1681 		String sValue(SW_RES(STR_POOLCOLL_HEADLINE1 + nIndex));
1682 		const SwTxtFmtColls* pColls = pDocShell->GetDoc()->GetTxtFmtColls();
1683 		const sal_uInt16 nCount = pColls->Count();
1684 		for(sal_uInt16 i = 0; i < nCount;++i)
1685 		{
1686 			SwTxtFmtColl &rTxtColl = *pColls->operator[](i);
1687 			if(rTxtColl.IsDefault())
1688 				continue;
1689 
1690 			//sal_Int8 nOutLevel = rTxtColl.GetOutlineLevel();		//#outline level,zhaojianwei
1691             const sal_Int16 nOutLevel = rTxtColl.IsAssignedToListLevelOfOutlineStyle()
1692                                         ? static_cast<sal_Int16>(rTxtColl.GetAssignedOutlineStyleLevel())
1693                                         : MAXLEVEL;					//<-end,zhaojianwei
1694             if ( nOutLevel == nIndex )
1695 			{
1696 				sValue = rTxtColl.GetName();
1697 				break; // the style for the level in question has been found
1698 			}
1699 			else if( sValue==rTxtColl.GetName() )
1700 			{
1701 				// if the default for the level is existing, but its
1702 				// level is different, then it cannot be the default.
1703 				sValue.Erase();
1704 			}
1705 		}
1706 		String aName;
1707 		SwStyleNameMapper::FillProgName(sValue, aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
1708 		aUString = aName;
1709 
1710 		pData = new PropValData((void*)&aUString, SW_PROP_NAME_STR(UNO_NAME_HEADING_STYLE_NAME), ::getCppuType((const OUString*)0));
1711 		aPropertyValues.Insert(pData, aPropertyValues.Count());
1712 	}
1713 
1714 	uno::Sequence<beans::PropertyValue> aSeq(aPropertyValues.Count());
1715 	beans::PropertyValue* pArray = aSeq.getArray();
1716 
1717 	for(sal_uInt16 i = 0; i < aPropertyValues.Count(); i++)
1718 	{
1719 		pData = aPropertyValues.GetObject(i);
1720 		pArray[i].Value = pData->aVal;
1721 		pArray[i].Name = pData->sPropName;
1722 		pArray[i].Handle = -1;
1723 	}
1724 	aPropertyValues.DeleteAndDestroy(0, aPropertyValues.Count());
1725 	return aSeq;
1726 }
1727 /*-- 14.12.98 14:57:59---------------------------------------------------
1728 
1729   -----------------------------------------------------------------------*/
lcl_FindProperty(const char * cName,PropValDataArr & rPropertyValues)1730 PropValData* lcl_FindProperty(const char* cName, PropValDataArr&	rPropertyValues)
1731 {
1732 	OUString sCmp = C2U(cName);
1733 	for(sal_uInt16 i = 0; i < rPropertyValues.Count(); i++)
1734 	{
1735 		PropValData* pTemp = rPropertyValues.GetObject(i);
1736 		if(sCmp == pTemp->sPropName)
1737 			return pTemp;
1738 	}
1739 	return 0;
1740 }
1741 //-----------------------------------------------------------------------
1742 
SetNumberingRuleByIndex(SwNumRule & rNumRule,const uno::Sequence<beans::PropertyValue> & rProperties,sal_Int32 nIndex)1743 void SwXNumberingRules::SetNumberingRuleByIndex(
1744 			SwNumRule& rNumRule,
1745 			const uno::Sequence<beans::PropertyValue>& rProperties, sal_Int32 nIndex)
1746 	throw( uno::RuntimeException, lang::IllegalArgumentException )
1747 {
1748 	vos::OGuard aGuard(Application::GetSolarMutex());
1749 	DBG_ASSERT( 0 <= nIndex && nIndex < MAXLEVEL, "index out of range" );
1750 
1751 	// the order of the names is important!
1752 	static const char* aNumPropertyNames[] =
1753 	{
1754 		"Adjust",  								//0
1755 		"ParentNumbering",                      //1
1756 		"Prefix",                               //2
1757 		"Suffix",                               //3
1758 		"CharStyleName",                        //4
1759 		"StartWith",                            //5
1760 		SW_PROP_NAME_STR(UNO_NAME_LEFT_MARGIN),                   //6
1761 		SW_PROP_NAME_STR(UNO_NAME_SYMBOL_TEXT_DISTANCE),          //7
1762 		SW_PROP_NAME_STR(UNO_NAME_FIRST_LINE_OFFSET),             //8
1763         // --> OD 2008-01-15 #newlistlevelattrs#
1764         SW_PROP_NAME_STR(UNO_NAME_POSITION_AND_SPACE_MODE), //9
1765         SW_PROP_NAME_STR(UNO_NAME_LABEL_FOLLOWED_BY),       //10
1766         SW_PROP_NAME_STR(UNO_NAME_LISTTAB_STOP_POSITION),   //11
1767         SW_PROP_NAME_STR(UNO_NAME_FIRST_LINE_INDENT),       //12
1768         SW_PROP_NAME_STR(UNO_NAME_INDENT_AT),               //13
1769         // <--
1770         "NumberingType",                        //14
1771         "BulletId",                             //15
1772         SW_PROP_NAME_STR(UNO_NAME_BULLET_FONT), //16
1773         "BulletFontName",                       //17
1774         "BulletChar",                           //18
1775         SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_URL),    //19
1776         SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_BITMAP), //20
1777         SW_PROP_NAME_STR(UNO_NAME_GRAPHIC_SIZE),   //21
1778         SW_PROP_NAME_STR(UNO_NAME_VERT_ORIENT),    //22
1779         SW_PROP_NAME_STR(UNO_NAME_HEADING_STYLE_NAME) //23
1780 	};
1781     // --> OD 2008-01-15 #newlistlevelattrs#
1782     const sal_uInt16 nPropNameCount = 24;
1783     const sal_uInt16 nNotInChapter = 15;
1784     // <--
1785 
1786 	const beans::PropertyValue* pPropArray = rProperties.getConstArray();
1787     PropValDataArr aPropertyValues;
1788 	sal_Bool bExcept = sal_False;
1789 	for(int i = 0; i < rProperties.getLength() && !bExcept; i++)
1790 	{
1791 		const beans::PropertyValue& rProp = pPropArray[i];
1792 		bExcept = sal_True;
1793 		for(sal_uInt16 j = 0; j < (pDocShell ? nPropNameCount : nPropNameCount - 1); j++)
1794 		{
1795 			//some values not in chapter numbering
1796 			if(pDocShell && j == nNotInChapter)
1797 				j = nPropNameCount - 1;
1798 			if(COMPARE_EQUAL == rProp.Name.compareToAscii(aNumPropertyNames[j]))
1799 			{
1800 				bExcept = sal_False;
1801 				break;
1802 			}
1803 		}
1804 		if(bExcept &&
1805 			(rProp.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("BulletRelSize")) ||
1806 			 rProp.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("BulletColor")) ) )
1807         {
1808 			bExcept = sal_False;
1809         }
1810 		PropValData* pData = new PropValData(rProp.Value, rProp.Name );
1811 		aPropertyValues.Insert(pData, aPropertyValues.Count());
1812 	}
1813 
1814     SwNumFmt aFmt(rNumRule.Get( (sal_uInt16)nIndex ));
1815     sal_Bool bWrongArg = sal_False;
1816 	if(!bExcept)
1817    	{
1818 		SvxBrushItem* pSetBrush = 0;
1819 		Size* pSetSize = 0;
1820 		SwFmtVertOrient* pSetVOrient = 0;
1821         sal_Bool bCharStyleNameSet = sal_False;
1822 
1823 		for(sal_uInt16 i = 0; i < nPropNameCount && !bExcept && !bWrongArg; i++)
1824 		{
1825 			PropValData* pData = lcl_FindProperty(aNumPropertyNames[i], aPropertyValues);
1826 			if(!pData)
1827 				continue;
1828 			switch(i)
1829 			{
1830 				case 0: //"Adjust"
1831 				{
1832 					sal_Int16 nValue = 0;
1833 					pData->aVal >>= nValue;
1834 					if(nValue > 0 &&
1835                         nValue <= text::HoriOrientation::LEFT &&
1836 							USHRT_MAX != aUnoToSvxAdjust[nValue])
1837 					{
1838 						aFmt.SetNumAdjust((SvxAdjust)aUnoToSvxAdjust[nValue]);
1839 					}
1840 					else
1841 						bWrongArg = sal_True;
1842 				}
1843 				break;
1844 				case 1: //"ParentNumbering",
1845 				{
1846 					sal_Int16 nSet = 0;
1847 					pData->aVal >>= nSet;
1848 					if(nSet >= 0 && MAXLEVEL >= nSet)
1849                         aFmt.SetIncludeUpperLevels( static_cast< sal_uInt8 >(nSet) );
1850 				}
1851 				break;
1852 				case 2: //"Prefix",
1853 				{
1854 					OUString uTmp;
1855 					pData->aVal >>= uTmp;
1856 					aFmt.SetPrefix(uTmp);
1857 				}
1858 				break;
1859 				case 3: //"Suffix",
1860 				{
1861 					OUString uTmp;
1862 					pData->aVal >>= uTmp;
1863 					aFmt.SetSuffix(uTmp);
1864 				}
1865 				break;
1866 				case 4: //"CharStyleName",
1867 				{
1868                     bCharStyleNameSet = sal_True;
1869                     OUString uTmp;
1870 					pData->aVal >>= uTmp;
1871 					String sCharFmtName;
1872 					SwStyleNameMapper::FillUIName( uTmp, sCharFmtName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
1873 					if(sCharFmtName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_CHARACTER_FORMAT_NONE)))
1874 					{
1875 						sNewCharStyleNames[(sal_uInt16)nIndex] = SwXNumberingRules::GetInvalidStyle();
1876 						aFmt.SetCharFmt(0);
1877 					}
1878 					else if(pDocShell || pDoc)
1879 					{
1880 						SwDoc* pLocalDoc = pDoc ? pDoc : pDocShell->GetDoc();
1881 						const SwCharFmts* pFmts = pLocalDoc->GetCharFmts();
1882 						sal_uInt16 nChCount = pFmts->Count();
1883 
1884 						SwCharFmt* pCharFmt = 0;
1885 						if(sCharFmtName.Len())
1886 						{
1887 							for(sal_uInt16 j = 0; j< nChCount; j++)
1888 							{
1889 								SwCharFmt* pTmp = (*pFmts)[j];
1890 								if(pTmp->GetName() == sCharFmtName)
1891 								{
1892 									pCharFmt = pTmp;
1893 									break;
1894 								}
1895 							}
1896 							if(!pCharFmt)
1897 							{
1898 
1899 								SfxStyleSheetBase* pBase;
1900 								SfxStyleSheetBasePool* pPool = pLocalDoc->GetDocShell()->GetStyleSheetPool();
1901 								pBase = ((SfxStyleSheetBasePool*)pPool)->Find(sCharFmtName, SFX_STYLE_FAMILY_CHAR);
1902 								if(!pBase)
1903 									pBase = &pPool->Make(sCharFmtName, SFX_STYLE_FAMILY_CHAR);
1904 								pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
1905 							}
1906 						}
1907 						aFmt.SetCharFmt( pCharFmt );
1908 						// os 2005-08-22 #i51842#
1909 						// If the character format has been found it's name should not be in the
1910 						// char style names array
1911                         //sNewCharStyleNames[(sal_uInt16)nIndex] = sCharFmtName;
1912 						sNewCharStyleNames[(sal_uInt16)nIndex].Erase();
1913  					}
1914 					else
1915 						sNewCharStyleNames[(sal_uInt16)nIndex] = sCharFmtName;
1916 				}
1917 				break;
1918 				case 5: //"StartWith",
1919 				{
1920 					sal_Int16 nVal = 0;
1921 					pData->aVal >>= nVal;
1922 					aFmt.SetStart(nVal);
1923 				}
1924 				break;
1925 				case 6: //UNO_NAME_LEFT_MARGIN,
1926 				{
1927 					sal_Int32 nValue = 0;
1928 					pData->aVal >>= nValue;
1929                     // #i23727# nValue can be negative
1930                     aFmt.SetAbsLSpace((sal_uInt16) MM100_TO_TWIP(nValue));
1931 				}
1932 				break;
1933 				case 7: //UNO_NAME_SYMBOL_TEXT_DISTANCE,
1934 				{
1935 					sal_Int32 nValue = 0;
1936 					pData->aVal >>= nValue;
1937 					if(nValue >= 0)
1938 						aFmt.SetCharTextDistance((sal_uInt16) MM100_TO_TWIP(nValue));
1939 					else
1940 						bWrongArg = sal_True;
1941 				}
1942 				break;
1943 				case 8: //UNO_NAME_FIRST_LINE_OFFSET,
1944 				{
1945 					sal_Int32 nValue = 0;
1946 					pData->aVal >>= nValue;
1947                     // #i23727# nValue can be positive
1948                     nValue = MM100_TO_TWIP(nValue);
1949                     aFmt.SetFirstLineOffset((short)nValue);
1950 				}
1951 				break;
1952                 // --> OD 2008-01-15 #newlistlevelattrs#
1953                 case 9: // UNO_NAME_POSITION_AND_SPACE_MODE
1954                 {
1955                     sal_Int16 nValue = 0;
1956                     pData->aVal >>= nValue;
1957                     if ( nValue == 0 )
1958                     {
1959                         aFmt.SetPositionAndSpaceMode( SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
1960                     }
1961                     else if ( nValue == 1 )
1962                     {
1963                         aFmt.SetPositionAndSpaceMode( SvxNumberFormat::LABEL_ALIGNMENT );
1964                     }
1965                     else
1966                     {
1967                         bWrongArg = sal_True;
1968                     }
1969                 }
1970                 break;
1971                 case 10: // UNO_NAME_LABEL_FOLLOWED_BY
1972                 {
1973                     sal_Int16 nValue = 0;
1974                     pData->aVal >>= nValue;
1975                     if ( nValue == 0 )
1976                     {
1977                         aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
1978                     }
1979                     else if ( nValue == 1 )
1980                     {
1981                         aFmt.SetLabelFollowedBy( SvxNumberFormat::SPACE );
1982                     }
1983                     else if ( nValue == 2 )
1984                     {
1985                         aFmt.SetLabelFollowedBy( SvxNumberFormat::NOTHING );
1986                     }
1987                     else
1988                     {
1989                         bWrongArg = sal_True;
1990                     }
1991                 }
1992                 break;
1993                 case 11: // UNO_NAME_LISTTAB_STOP_POSITION
1994                 {
1995                     sal_Int32 nValue = 0;
1996                     pData->aVal >>= nValue;
1997                     nValue = MM100_TO_TWIP(nValue);
1998                     if ( nValue >= 0 )
1999                     {
2000                         aFmt.SetListtabPos( nValue );
2001                     }
2002                     else
2003                     {
2004                         bWrongArg = sal_True;
2005                     }
2006                 }
2007                 break;
2008                 case 12: // UNO_NAME_FIRST_LINE_INDENT
2009                 {
2010                     sal_Int32 nValue = 0;
2011                     pData->aVal >>= nValue;
2012                     nValue = MM100_TO_TWIP(nValue);
2013                     aFmt.SetFirstLineIndent( nValue );
2014                 }
2015                 break;
2016                 case 13: // UNO_NAME_INDENT_AT
2017                 {
2018                     sal_Int32 nValue = 0;
2019                     pData->aVal >>= nValue;
2020                     nValue = MM100_TO_TWIP(nValue);
2021                     aFmt.SetIndentAt( nValue );
2022                 }
2023                 break;
2024                 // <--
2025                 case 14: //"NumberingType"
2026 				{
2027 					sal_Int16 nSet = 0;
2028 					pData->aVal >>= nSet;
2029                     if(nSet >= 0)
2030 						aFmt.SetNumberingType(nSet);
2031 					else
2032 						bWrongArg = sal_True;
2033 				}
2034 				break;
2035                 case 15: //"BulletId",
2036 				{
2037                     sal_Int16 nSet = 0;
2038                     if( pData->aVal >>= nSet )
2039 						aFmt.SetBulletChar(nSet);
2040 					else
2041 						bWrongArg = sal_True;
2042 				}
2043 				break;
2044                 case 16: //UNO_NAME_BULLET_FONT,
2045 				{
2046 				 	awt::FontDescriptor* pDesc =  (awt::FontDescriptor*)pData->aVal.getValue();
2047 					if(pDesc)
2048 					{
2049                         // --> OD 2008-09-11 #i93725#
2050                         // do not accept "empty" font
2051                         if ( pDesc->Name.getLength() > 0 )
2052                         {
2053                             Font aFont;
2054                             SvxUnoFontDescriptor::ConvertToFont( *pDesc, aFont );
2055                             aFmt.SetBulletFont(&aFont);
2056                         }
2057                         // <--
2058 					}
2059 					else
2060 						bWrongArg = sal_True;
2061 				}
2062 				break;
2063                 case 17: //"BulletFontName",
2064 				{
2065 					OUString uTmp;
2066 					pData->aVal >>= uTmp;
2067 					String sBulletFontName(uTmp);
2068                     SwDocShell* pLclDocShell = pDocShell ? pDocShell : pDoc ? pDoc->GetDocShell() : 0;
2069                     if( sBulletFontName.Len() && pLclDocShell )
2070                     {
2071                         const SvxFontListItem* pFontListItem =
2072                                 (const SvxFontListItem* )pLclDocShell
2073                                                     ->GetItem( SID_ATTR_CHAR_FONTLIST );
2074                         const FontList*  pList = pFontListItem->GetFontList();
2075                         FontInfo aInfo = pList->Get(
2076                             sBulletFontName, WEIGHT_NORMAL, ITALIC_NONE);
2077                         Font aFont(aInfo);
2078                         aFmt.SetBulletFont(&aFont);
2079                     }
2080                     else
2081                         sNewBulletFontNames[(sal_uInt16)nIndex] = sBulletFontName;
2082 				}
2083 				break;
2084                 case 18: //"BulletChar",
2085 				{
2086 					OUString aChar;
2087 					pData->aVal >>= aChar;
2088 					if(aChar.getLength() == 1)
2089 					{
2090 						aFmt.SetBulletChar(aChar.toChar());
2091 					}
2092 					else
2093 						bWrongArg = sal_True;
2094 				}
2095 				break;
2096                 case 19: //UNO_NAME_GRAPHIC_URL,
2097 				{
2098 					OUString sBrushURL;
2099 					pData->aVal >>= sBrushURL;
2100 					if(!pSetBrush)
2101 					{
2102 						const SvxBrushItem* pOrigBrush = aFmt.GetBrush();
2103 						if(pOrigBrush)
2104 						{
2105                             pSetBrush = new SvxBrushItem(*pOrigBrush);
2106 						}
2107 						else
2108                             pSetBrush = new SvxBrushItem(aEmptyStr, aEmptyStr, GPOS_AREA, RES_BACKGROUND);
2109 					}
2110 					pSetBrush->PutValue( pData->aVal, MID_GRAPHIC_URL );
2111 				}
2112 				break;
2113                 case 20: //UNO_NAME_GRAPHIC_BITMAP,
2114 				{
2115 					uno::Reference< awt::XBitmap >* pBitmap = (uno::Reference< awt::XBitmap > *)pData->aVal.getValue();
2116 					if(pBitmap)
2117 					{
2118 						if(!pSetBrush)
2119 						{
2120 							const SvxBrushItem* pOrigBrush = aFmt.GetBrush();
2121 							if(pOrigBrush)
2122 							{
2123                                 pSetBrush = new SvxBrushItem(*pOrigBrush);
2124 							}
2125 							else
2126                                 pSetBrush = new SvxBrushItem(aEmptyStr, aEmptyStr, GPOS_AREA, RES_BACKGROUND);
2127 						}
2128 
2129 						BitmapEx aBmp = VCLUnoHelper::GetBitmap( *pBitmap );
2130 						Graphic aNewGr(aBmp);
2131 						pSetBrush->SetGraphic( aNewGr );
2132 					}
2133 					else
2134 						bWrongArg = sal_True;
2135 				}
2136 				break;
2137                 case 21: //UNO_NAME_GRAPHIC_SIZE,
2138 				{
2139 					if(!pSetSize)
2140 						pSetSize = new Size;
2141 					if(pData->aVal.getValueType() == ::getCppuType((awt::Size*)0))
2142 					{
2143 				 		awt::Size* pSize =  (awt::Size*)pData->aVal.getValue();
2144 						pSize->Width = MM100_TO_TWIP(pSize->Width);
2145 						pSize->Height = MM100_TO_TWIP(pSize->Height);
2146 						pSetSize->Width() = pSize->Width;
2147 						pSetSize->Height() = pSize->Height;
2148 					}
2149 					else
2150 						bWrongArg = sal_True;
2151 				}
2152 				break;
2153                 case 22: //VertOrient
2154 				{
2155 					if(!pSetVOrient)
2156 					{
2157 						if(aFmt.GetGraphicOrientation())
2158 							pSetVOrient = (SwFmtVertOrient*)aFmt.GetGraphicOrientation()->Clone();
2159 						else
2160 							pSetVOrient = new SwFmtVertOrient;
2161 					}
2162 					((SfxPoolItem*)pSetVOrient)->PutValue(pData->aVal, MID_VERTORIENT_ORIENT);
2163 				}
2164 				break;
2165                 case 23: //"HeadingStyleName"
2166                 {
2167                     OUString uTmp;
2168                     pData->aVal >>= uTmp;
2169                     String sStyleName;
2170                     SwStyleNameMapper::FillUIName( uTmp, sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
2171                     const SwTxtFmtColls* pColls = pDocShell->GetDoc()->GetTxtFmtColls();
2172                     const sal_uInt16 nCount = pColls->Count();
2173                     for ( sal_uInt16 k = 0; k < nCount; ++k )
2174                     {
2175                         SwTxtFmtColl &rTxtColl = *( ( *pColls )[k] );
2176                         if ( rTxtColl.IsDefault() )
2177                             continue;
2178                         if ( rTxtColl.IsAssignedToListLevelOfOutlineStyle()
2179                              && rTxtColl.GetAssignedOutlineStyleLevel() == nIndex
2180                              && rTxtColl.GetName() != sStyleName )
2181                         {
2182                             rTxtColl.DeleteAssignmentToListLevelOfOutlineStyle();
2183                         }
2184                         else if ( rTxtColl.GetName() == sStyleName )
2185                         {
2186                             rTxtColl.AssignToListLevelOfOutlineStyle( nIndex );
2187                         }
2188                     }
2189                 }
2190                 break;
2191                 case 24: // BulletRelSize - unsupported - only available in Impress
2192                 break;
2193             }
2194         }
2195 		if(!bExcept && !bWrongArg && (pSetBrush || pSetSize || pSetVOrient))
2196 		{
2197 			if(!pSetBrush && aFmt.GetBrush())
2198                 pSetBrush = new SvxBrushItem(*aFmt.GetBrush());
2199 
2200 			if(pSetBrush)
2201 			{
2202 				if(!pSetVOrient && aFmt.GetGraphicOrientation())
2203 					pSetVOrient = new SwFmtVertOrient(*aFmt.GetGraphicOrientation());
2204 
2205 				if(!pSetSize)
2206 				{
2207 					pSetSize = new Size(aFmt.GetGraphicSize());
2208 					if(!pSetSize->Width() || !pSetSize->Height())
2209 					{
2210 						const Graphic* pGraphic = pSetBrush->GetGraphic();
2211 						if(pGraphic)
2212 							*pSetSize = ::GetGraphicSizeTwip(*pGraphic, 0);
2213 					}
2214 				}
2215                 sal_Int16 eOrient = pSetVOrient ?
2216                     (sal_Int16)pSetVOrient->GetVertOrient() : text::VertOrientation::NONE;
2217                 aFmt.SetGraphicBrush( pSetBrush, pSetSize, text::VertOrientation::NONE == eOrient ? 0 : &eOrient );
2218 			}
2219 		}
2220         if((!bCharStyleNameSet || !sNewCharStyleNames[(sal_uInt16)nIndex].Len()) &&
2221                 aFmt.GetNumberingType() == NumberingType::BITMAP && !aFmt.GetCharFmt()
2222                     && SwXNumberingRules::GetInvalidStyle() != sNewCharStyleNames[(sal_uInt16)nIndex])
2223         {
2224 			SwStyleNameMapper::FillProgName ( RES_POOLCHR_BUL_LEVEL, sNewCharStyleNames[(sal_uInt16)nIndex] );
2225         }
2226 		delete pSetBrush;
2227 		delete pSetSize;
2228 		delete pSetVOrient;
2229   	}
2230 	aPropertyValues.DeleteAndDestroy(0, aPropertyValues.Count());
2231 
2232 	if(bWrongArg)
2233 		throw lang::IllegalArgumentException();
2234 	else if(bExcept)
2235 		throw uno::RuntimeException();
2236 	rNumRule.Set( (sal_uInt16)nIndex, aFmt );
2237 
2238 }
2239 /*-- 19.07.00 07:49:17---------------------------------------------------
2240 
2241   -----------------------------------------------------------------------*/
getPropertySetInfo()2242 uno::Reference< XPropertySetInfo > SwXNumberingRules::getPropertySetInfo()
2243 	throw(RuntimeException)
2244 {
2245     static uno::Reference< beans::XPropertySetInfo >  aRef = m_pPropertySet->getPropertySetInfo();
2246 	return aRef;
2247 }
2248 /*-- 19.07.00 07:49:17---------------------------------------------------
2249 
2250   -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const Any & rValue)2251 void SwXNumberingRules::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
2252 	throw(UnknownPropertyException, PropertyVetoException,
2253 		IllegalArgumentException, WrappedTargetException, RuntimeException)
2254 {
2255 	Any aRet;
2256 	SwNumRule* pDocRule = 0;
2257 	SwNumRule* pCreatedRule = 0;
2258 	if(!pNumRule)
2259 	{
2260 		if(!pNumRule && pDocShell)
2261 		{
2262 			pDocRule = new SwNumRule(*pDocShell->GetDoc()->GetOutlineNumRule());
2263 		}
2264 		else if(pDoc && sCreatedNumRuleName.Len())
2265 		{
2266 			pCreatedRule = pDoc->FindNumRulePtr( sCreatedNumRuleName);
2267 		}
2268 
2269 	}
2270 	if(!pNumRule && !pDocRule && !pCreatedRule)
2271 		throw RuntimeException();
2272 
2273 
2274 	if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_AUTOMATIC)))
2275 	{
2276 		sal_Bool bVal = *(sal_Bool*)rValue.getValue();
2277 		if(!pCreatedRule)
2278 			pDocRule ? pDocRule->SetAutoRule(bVal) : pNumRule->SetAutoRule(bVal);
2279 	}
2280 	else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_CONTINUOUS_NUMBERING)))
2281 	{
2282 		sal_Bool bVal = *(sal_Bool*)rValue.getValue();
2283 		pDocRule ? pDocRule->SetContinusNum(bVal) :
2284 			pCreatedRule ? pCreatedRule->SetContinusNum(bVal) : pNumRule->SetContinusNum(bVal);
2285 	}
2286 	else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NAME)))
2287 	{
2288 		delete pDocRule;
2289 		throw IllegalArgumentException();
2290 	}
2291 	else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_ABSOLUTE_MARGINS)))
2292 	{
2293 		sal_Bool bVal = *(sal_Bool*)rValue.getValue();
2294 		pDocRule ? pDocRule->SetAbsSpaces(bVal) :
2295 			pCreatedRule ? pCreatedRule->SetAbsSpaces(bVal) : pNumRule->SetAbsSpaces(bVal);
2296 	}
2297 	else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NUMBERING_IS_OUTLINE)))
2298 	{
2299 		sal_Bool bVal = *(sal_Bool*)rValue.getValue();
2300         SwNumRuleType eNumRuleType = bVal ? OUTLINE_RULE : NUM_RULE;
2301 		pDocRule ? pDocRule->SetRuleType(eNumRuleType) :
2302 			pCreatedRule ? pCreatedRule->SetRuleType(eNumRuleType) : pNumRule->SetRuleType(eNumRuleType);
2303 	}
2304     // --> OD 2008-04-23 #refactorlists#
2305     else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DEFAULT_LIST_ID)))
2306     {
2307         delete pDocRule;
2308         throw IllegalArgumentException();
2309     }
2310     // <--
2311 	else
2312 		throw UnknownPropertyException();
2313 
2314 	if(pDocRule)
2315 	{
2316 		pDocShell->GetDoc()->SetOutlineNumRule(*pDocRule);
2317 		delete pDocRule;
2318 	}
2319 	else if(pCreatedRule)
2320 	{
2321         pCreatedRule->Validate();
2322 	}
2323 }
2324 /*-- 19.07.00 07:49:18---------------------------------------------------
2325 
2326   -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)2327 Any SwXNumberingRules::getPropertyValue( const OUString& rPropertyName )
2328 	throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2329 {
2330 	Any aRet;
2331 	const SwNumRule* pRule = pNumRule;
2332 	if(!pRule && pDocShell)
2333 		pRule = pDocShell->GetDoc()->GetOutlineNumRule();
2334 	else if(pDoc && sCreatedNumRuleName.Len())
2335 		pRule = pDoc->FindNumRulePtr( sCreatedNumRuleName );
2336 	if(!pRule)
2337 		throw RuntimeException();
2338 
2339 	if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_AUTOMATIC)))
2340 	{
2341 		sal_Bool bVal = pRule->IsAutoRule();
2342 		aRet.setValue(&bVal, ::getBooleanCppuType());
2343 	}
2344 	else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_CONTINUOUS_NUMBERING)))
2345 	{
2346 		sal_Bool bVal = pRule->IsContinusNum();
2347 		aRet.setValue(&bVal, ::getBooleanCppuType());
2348 	}
2349 	else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NAME)))
2350 		aRet <<= OUString(pRule->GetName());
2351 	else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_ABSOLUTE_MARGINS)))
2352 	{
2353 		sal_Bool bVal = pRule->IsAbsSpaces();
2354 		aRet.setValue(&bVal, ::getBooleanCppuType());
2355 	}
2356 	else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NUMBERING_IS_OUTLINE)))
2357 	{
2358 		sal_Bool bVal = pRule->IsOutlineRule();
2359 		aRet.setValue(&bVal, ::getBooleanCppuType());
2360 	}
2361     // --> OD 2008-04-23 #refactorlists#
2362     else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DEFAULT_LIST_ID)))
2363     {
2364         ASSERT( pRule->GetDefaultListId().Len() != 0,
2365                 "<SwXNumberingRules::getPropertyValue(..)> - no default list id found. Serious defect -> please inform OD." );
2366         aRet <<= OUString(pRule->GetDefaultListId());
2367     }
2368     // <--
2369 	else
2370 		throw UnknownPropertyException();
2371 	return aRet;
2372 }
2373 /*-- 19.07.00 07:49:18---------------------------------------------------
2374 
2375   -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<XPropertyChangeListener> &)2376 void SwXNumberingRules::addPropertyChangeListener(
2377 	const OUString& /*rPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
2378 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2379 {
2380 }
2381 /*-- 19.07.00 07:49:18---------------------------------------------------
2382 
2383   -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<XPropertyChangeListener> &)2384 void SwXNumberingRules::removePropertyChangeListener(
2385 	const OUString& /*rPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
2386 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2387 {
2388 }
2389 /*-- 19.07.00 07:49:18---------------------------------------------------
2390 
2391   -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<XVetoableChangeListener> &)2392 void SwXNumberingRules::addVetoableChangeListener(
2393 	const OUString& /*rPropertyName*/, const uno::Reference< XVetoableChangeListener >& /*xListener*/ )
2394 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2395 {
2396 }
2397 /*-- 19.07.00 07:49:18---------------------------------------------------
2398 
2399   -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<XVetoableChangeListener> &)2400 void SwXNumberingRules::removeVetoableChangeListener(
2401 	const OUString& /*rPropertyName*/, const uno::Reference< XVetoableChangeListener >& /*xListener*/ )
2402 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2403 {
2404 }
2405 /* -----------------------------17.10.00 14:23--------------------------------
2406 
2407  ---------------------------------------------------------------------------*/
getName()2408 OUString SwXNumberingRules::getName() throw( RuntimeException )
2409 {
2410 	String aString;
2411 	if(pNumRule)
2412 	{
2413 		SwStyleNameMapper::FillProgName(pNumRule->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, sal_True );
2414 		return OUString ( aString );
2415 	}
2416     // --> OD 2005-10-25 #126347# - consider chapter numbering <SwXNumberingRules>
2417     else if ( pDocShell )
2418     {
2419         SwStyleNameMapper::FillProgName( pDocShell->GetDoc()->GetOutlineNumRule()->GetName(),
2420                                          aString, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, sal_True );
2421         return OUString ( aString );
2422     }
2423     // <--
2424 	else
2425 		return sCreatedNumRuleName;
2426 }
2427 /* -----------------------------17.10.00 14:23--------------------------------
2428 
2429  ---------------------------------------------------------------------------*/
setName(const OUString &)2430 void SwXNumberingRules::setName(const OUString& /*rName*/) throw( RuntimeException )
2431 {
2432 	RuntimeException aExcept;
2433 	aExcept.Message = C2U("readonly");
2434 	throw aExcept;
2435 }
2436 /*-- 14.12.98 14:58:00---------------------------------------------------
2437 
2438   -----------------------------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)2439 void SwXNumberingRules::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
2440 {
2441 	ClientModify(this, pOld, pNew);
2442 	if(!GetRegisteredIn())
2443 	{
2444 		if(bOwnNumRuleCreated)
2445 			delete pNumRule;
2446 		pNumRule = 0;
2447 		pDoc = 0;
2448 	}
2449 }
2450 /* -----------------------------06.04.00 11:47--------------------------------
2451 
2452  ---------------------------------------------------------------------------*/
getImplementationName(void)2453 OUString SwXChapterNumbering::getImplementationName(void) throw( RuntimeException )
2454 {
2455 	return C2U("SwXChapterNumbering");
2456 }
2457 /* -----------------------------06.04.00 11:47--------------------------------
2458 
2459  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)2460 sal_Bool SwXChapterNumbering::supportsService(const OUString& rServiceName) throw( RuntimeException )
2461 {
2462 	String sServiceName(rServiceName);
2463 	return sServiceName.EqualsAscii("com.sun.star.text.ChapterNumbering") ||
2464 			sServiceName.EqualsAscii("com.sun.star.text.NumberingRules");
2465 }
2466 /* -----------------------------06.04.00 11:47--------------------------------
2467 
2468  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)2469 Sequence< OUString > SwXChapterNumbering::getSupportedServiceNames(void) throw( RuntimeException )
2470 {
2471 	Sequence< OUString > aRet(2);
2472 	OUString* pArray = aRet.getArray();
2473 	pArray[0] = C2U("com.sun.star.text.ChapterNumbering");
2474 	pArray[1] = C2U("com.sun.star.text.NumberingRules");
2475 	return aRet;
2476 }
2477 /* -----------------22.02.99 16:33-------------------
2478  *
2479  * --------------------------------------------------*/
SwXChapterNumbering(SwDocShell & rDocSh)2480 SwXChapterNumbering::SwXChapterNumbering(SwDocShell& rDocSh) :
2481 	SwXNumberingRules(rDocSh)
2482 {
2483 }
2484 /* -----------------22.02.99 16:33-------------------
2485  *
2486  * --------------------------------------------------*/
~SwXChapterNumbering()2487 SwXChapterNumbering::~SwXChapterNumbering()
2488 {
2489 }
2490 
2491 /******************************************************************
2492  * SwXTextColumns
2493  ******************************************************************/
2494 /* -----------------------------06.04.00 11:47--------------------------------
2495 
2496  ---------------------------------------------------------------------------*/
getImplementationName(void)2497 OUString SwXTextColumns::getImplementationName(void) throw( RuntimeException )
2498 {
2499 	return C2U("SwXTextColumns");
2500 }
2501 /* -----------------------------06.04.00 11:47--------------------------------
2502 
2503  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)2504 sal_Bool SwXTextColumns::supportsService(const OUString& rServiceName) throw( RuntimeException )
2505 {
2506 	return C2U("com.sun.star.text.TextColumns") == rServiceName;
2507 }
2508 /* -----------------------------06.04.00 11:47--------------------------------
2509 
2510  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)2511 Sequence< OUString > SwXTextColumns::getSupportedServiceNames(void) throw( RuntimeException )
2512 {
2513 	Sequence< OUString > aRet(1);
2514 	OUString* pArray = aRet.getArray();
2515 	pArray[0] = C2U("com.sun.star.text.TextColumns");
2516 	return aRet;
2517 }
2518 /* -----------------------------24.10.00 16:45--------------------------------
2519 
2520  ---------------------------------------------------------------------------*/
SwXTextColumns(sal_uInt16 nColCount)2521 SwXTextColumns::SwXTextColumns(sal_uInt16 nColCount) :
2522 	nReference(0),
2523     bIsAutomaticWidth(sal_True),
2524     nAutoDistance(0),
2525     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_COLUMS)),
2526 	nSepLineWidth(0),
2527 	nSepLineColor(0), //black
2528 	nSepLineHeightRelative(100),//full height
2529 	nSepLineVertAlign(style::VerticalAlignment_MIDDLE),
2530 	bSepLineIsOn(sal_False)
2531 {
2532 	if(nColCount)
2533 		setColumnCount(nColCount);
2534 }
2535 /*-- 16.12.98 14:06:53---------------------------------------------------
2536 
2537   -----------------------------------------------------------------------*/
SwXTextColumns(const SwFmtCol & rFmtCol)2538 SwXTextColumns::SwXTextColumns(const SwFmtCol& rFmtCol) :
2539 	nReference(0),
2540 	aTextColumns(rFmtCol.GetNumCols()),
2541     bIsAutomaticWidth(rFmtCol.IsOrtho()),
2542     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_COLUMS))
2543 {
2544     sal_uInt16 nItemGutterWidth = rFmtCol.GetGutterWidth();
2545     nAutoDistance = bIsAutomaticWidth ?
2546                         USHRT_MAX == nItemGutterWidth ? DEF_GUTTER_WIDTH : (sal_Int32)nItemGutterWidth
2547                         : 0;
2548     nAutoDistance = TWIP_TO_MM100(nAutoDistance);
2549 
2550     TextColumn* pColumns = aTextColumns.getArray();
2551 	const SwColumns& rCols = rFmtCol.GetColumns();
2552 	for(sal_uInt16 i = 0; i < aTextColumns.getLength(); i++)
2553 	{
2554 		SwColumn* pCol = rCols[i];
2555 
2556 		pColumns[i].Width = pCol->GetWishWidth();
2557 		nReference += pColumns[i].Width;
2558 		pColumns[i].LeftMargin = 	TWIP_TO_MM100_UNSIGNED(pCol->GetLeft ());
2559 		pColumns[i].RightMargin = 	TWIP_TO_MM100_UNSIGNED(pCol->GetRight());
2560 	}
2561 	if(!aTextColumns.getLength())
2562 		nReference = USHRT_MAX;
2563 
2564 	nSepLineWidth = rFmtCol.GetLineWidth();
2565 	nSepLineColor = rFmtCol.GetLineColor().GetColor();
2566 	nSepLineHeightRelative = rFmtCol.GetLineHeight();
2567 	bSepLineIsOn = rFmtCol.GetLineAdj() != COLADJ_NONE;
2568 	switch(rFmtCol.GetLineAdj())
2569 	{
2570 		case COLADJ_TOP: 	nSepLineVertAlign = style::VerticalAlignment_TOP; 	break;
2571 		case COLADJ_BOTTOM: nSepLineVertAlign = style::VerticalAlignment_BOTTOM;	break;
2572 		case COLADJ_CENTER:
2573 		case COLADJ_NONE:	nSepLineVertAlign = style::VerticalAlignment_MIDDLE;
2574 	}
2575 }
2576 /*-- 16.12.98 14:06:54---------------------------------------------------
2577 
2578   -----------------------------------------------------------------------*/
~SwXTextColumns()2579 SwXTextColumns::~SwXTextColumns()
2580 {
2581 
2582 }
2583 /*-- 16.12.98 14:06:54---------------------------------------------------
2584 
2585   -----------------------------------------------------------------------*/
getReferenceValue(void)2586 sal_Int32 SwXTextColumns::getReferenceValue(void) throw( uno::RuntimeException )
2587 {
2588 	vos::OGuard aGuard(Application::GetSolarMutex());
2589 	return nReference;
2590 }
2591 /*-- 16.12.98 14:06:55---------------------------------------------------
2592 
2593   -----------------------------------------------------------------------*/
getColumnCount(void)2594 sal_Int16 SwXTextColumns::getColumnCount(void) throw( uno::RuntimeException )
2595 {
2596 	vos::OGuard aGuard(Application::GetSolarMutex());
2597     return static_cast< sal_Int16>( aTextColumns.getLength() );
2598 }
2599 /*-- 16.12.98 14:06:55---------------------------------------------------
2600 
2601   -----------------------------------------------------------------------*/
setColumnCount(sal_Int16 nColumns)2602 void SwXTextColumns::setColumnCount(sal_Int16 nColumns) throw( uno::RuntimeException )
2603 {
2604 	vos::OGuard aGuard(Application::GetSolarMutex());
2605 	if(nColumns <= 0)
2606 		throw uno::RuntimeException();
2607     bIsAutomaticWidth = sal_True;
2608     aTextColumns.realloc(nColumns);
2609  	TextColumn* pCols = aTextColumns.getArray();
2610 	nReference = USHRT_MAX;
2611     sal_Int32 nWidth = nReference / nColumns;
2612     sal_Int32 nDiff = nReference - nWidth * nColumns;
2613     sal_Int32 nDist = nAutoDistance / 2;
2614     for(sal_Int16 i = 0; i < nColumns; i++)
2615 	{
2616 		pCols[i].Width = nWidth;
2617         pCols[i].LeftMargin = i == 0 ? 0 : nDist;
2618         pCols[i].RightMargin = i == nColumns - 1 ? 0 : nDist;
2619 	}
2620 	pCols[nColumns - 1].Width += nDiff;
2621 }
2622 /*-- 16.12.98 14:06:55---------------------------------------------------
2623 
2624   -----------------------------------------------------------------------*/
getColumns(void)2625 uno::Sequence< TextColumn > SwXTextColumns::getColumns(void) throw( uno::RuntimeException )
2626 {
2627 	vos::OGuard aGuard(Application::GetSolarMutex());
2628 	return aTextColumns;
2629 }
2630 /*-- 16.12.98 14:06:56---------------------------------------------------
2631 
2632   -----------------------------------------------------------------------*/
setColumns(const uno::Sequence<TextColumn> & rColumns)2633 void SwXTextColumns::setColumns(const uno::Sequence< TextColumn >& rColumns)
2634 			throw( uno::RuntimeException )
2635 {
2636 	vos::OGuard aGuard(Application::GetSolarMutex());
2637     sal_Int32 nReferenceTemp = 0;
2638 	const TextColumn* prCols = rColumns.getConstArray();
2639 	for(long i = 0; i < rColumns.getLength(); i++)
2640 	{
2641 		nReferenceTemp += prCols[i].Width;
2642 	}
2643     bIsAutomaticWidth = sal_False;
2644 	nReference = !nReferenceTemp ? USHRT_MAX : nReferenceTemp;
2645 	aTextColumns = rColumns;
2646 }
2647 /*-- 25.10.00 10:15:39---------------------------------------------------
2648 
2649   -----------------------------------------------------------------------*/
getPropertySetInfo()2650 uno::Reference< XPropertySetInfo > SwXTextColumns::getPropertySetInfo(  ) throw(RuntimeException)
2651 {
2652     static uno::Reference< beans::XPropertySetInfo >  aRef = m_pPropSet->getPropertySetInfo();
2653 	return aRef;
2654 }
2655 /*-- 25.10.00 10:15:39---------------------------------------------------
2656 
2657   -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const Any & aValue)2658 void SwXTextColumns::setPropertyValue( const OUString& rPropertyName, const Any& aValue )
2659 		throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
2660 			WrappedTargetException, RuntimeException)
2661 {
2662     const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
2663     if (!pEntry)
2664         throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2665     if ( pEntry->nFlags & PropertyAttribute::READONLY)
2666         throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2667 
2668     switch(pEntry->nWID)
2669 	{
2670 		case WID_TXTCOL_LINE_WIDTH:
2671 		{
2672 			sal_Int32 nTmp = 0;
2673 			aValue >>= nTmp;
2674 			if(nTmp < 0)
2675 				throw IllegalArgumentException();
2676 			nSepLineWidth = MM100_TO_TWIP(nTmp);
2677 		}
2678 		break;
2679 		case WID_TXTCOL_LINE_COLOR:
2680 			aValue >>= nSepLineColor;
2681 		break;
2682 		case WID_TXTCOL_LINE_REL_HGT:
2683 		{
2684 			sal_Int8 nTmp = 0;
2685 			aValue >>= nTmp;
2686 			if(nTmp < 0)
2687 				throw IllegalArgumentException();
2688 			nSepLineHeightRelative = nTmp;
2689 		}
2690 		break;
2691 		case WID_TXTCOL_LINE_ALIGN:
2692 		{
2693 			style::VerticalAlignment eAlign;
2694 			if(!(aValue >>= eAlign) )
2695 			{
2696 				sal_Int8 nTmp = 0;
2697 				if (! ( aValue >>= nTmp ) )
2698 					throw IllegalArgumentException();
2699 				else
2700                     nSepLineVertAlign = nTmp;
2701 			}
2702 			else
2703                 nSepLineVertAlign = static_cast< sal_Int8 >(eAlign);
2704 		}
2705 		break;
2706 		case WID_TXTCOL_LINE_IS_ON:
2707 			bSepLineIsOn = *(sal_Bool*)aValue.getValue();
2708 		break;
2709         case WID_TXTCOL_AUTO_DISTANCE:
2710         {
2711             sal_Int32 nTmp = 0;
2712             aValue >>= nTmp;
2713             if(nTmp < 0 || nTmp >= nReference)
2714                 throw IllegalArgumentException();
2715             nAutoDistance = nTmp;
2716             sal_Int32 nColumns = aTextColumns.getLength();
2717             TextColumn* pCols = aTextColumns.getArray();
2718             sal_Int32 nDist = nAutoDistance / 2;
2719             for(sal_Int32 i = 0; i < nColumns; i++)
2720             {
2721                 pCols[i].LeftMargin = i == 0 ? 0 : nDist;
2722                 pCols[i].RightMargin = i == nColumns - 1 ? 0 : nDist;
2723             }
2724         }
2725         break;
2726 	}
2727 }
2728 /*-- 25.10.00 10:15:40---------------------------------------------------
2729 
2730   -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)2731 Any SwXTextColumns::getPropertyValue( const OUString& rPropertyName )
2732 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2733 {
2734     const SfxItemPropertySimpleEntry*  pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
2735     if (!pEntry)
2736         throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2737 
2738 	Any aRet;
2739     switch(pEntry->nWID)
2740 	{
2741 		case WID_TXTCOL_LINE_WIDTH:
2742 			aRet <<= static_cast < sal_Int32 >(TWIP_TO_MM100(nSepLineWidth));
2743 		break;
2744 		case WID_TXTCOL_LINE_COLOR:
2745 			aRet <<= nSepLineColor;
2746 		break;
2747 		case WID_TXTCOL_LINE_REL_HGT:
2748 			aRet <<= nSepLineHeightRelative;
2749 		break;
2750 		case WID_TXTCOL_LINE_ALIGN:
2751 			aRet <<= (style::VerticalAlignment)nSepLineVertAlign;
2752 		break;
2753 		case WID_TXTCOL_LINE_IS_ON:
2754 			aRet.setValue(&bSepLineIsOn, ::getBooleanCppuType());
2755 		break;
2756         case WID_TXTCOL_IS_AUTOMATIC :
2757             aRet.setValue(&bIsAutomaticWidth, ::getBooleanCppuType());
2758         break;
2759         case WID_TXTCOL_AUTO_DISTANCE:
2760             aRet <<= nAutoDistance;
2761         break;
2762     }
2763 	return aRet;
2764 }
2765 /*-- 25.10.00 10:15:40---------------------------------------------------
2766 
2767   -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<XPropertyChangeListener> &)2768 void SwXTextColumns::addPropertyChangeListener(
2769 	const OUString& /*rPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
2770 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2771 {
2772 }
2773 /*-- 25.10.00 10:15:40---------------------------------------------------
2774 
2775   -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<XPropertyChangeListener> &)2776 void SwXTextColumns::removePropertyChangeListener(
2777 	const OUString& /*rPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
2778 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2779 {
2780 }
2781 /*-- 25.10.00 10:15:40---------------------------------------------------
2782 
2783   -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<XVetoableChangeListener> &)2784 void SwXTextColumns::addVetoableChangeListener(
2785 	const OUString& /*rPropertyName*/, const uno::Reference< XVetoableChangeListener >& /*xListener*/ )
2786 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2787 {
2788 }
2789 /*-- 25.10.00 10:15:40---------------------------------------------------
2790 
2791   -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<XVetoableChangeListener> &)2792 void SwXTextColumns::removeVetoableChangeListener(
2793 	const OUString& /*rPropertyName*/, const uno::Reference< XVetoableChangeListener >& /*xListener*/ )
2794 		throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
2795 {
2796 }
2797 /* -----------------------------25.10.00 11:04--------------------------------
2798 
2799  ---------------------------------------------------------------------------*/
getUnoTunnelId()2800 const uno::Sequence< sal_Int8 > & SwXTextColumns::getUnoTunnelId()
2801 {
2802     static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
2803 	return aSeq;
2804 }
2805 /* -----------------------------10.03.00 18:04--------------------------------
2806 
2807  ---------------------------------------------------------------------------*/
getSomething(const uno::Sequence<sal_Int8> & rId)2808 sal_Int64 SAL_CALL SwXTextColumns::getSomething( const uno::Sequence< sal_Int8 >& rId )
2809 	throw(uno::RuntimeException)
2810 {
2811     if( rId.getLength() == 16
2812         && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2813 										rId.getConstArray(), 16 ) )
2814     {
2815 		return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
2816     }
2817 	return 0;
2818 }
2819 
2820