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