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