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