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