1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27 #include <svx/svxids.hrc>
28 #include <hintids.hxx>
29 #include <vos/mutex.hxx>
30 #include <vcl/svapp.hxx>
31 #include <svl/smplhint.hxx>
32 #include <svtools/ctrltool.hxx>
33 #include <svl/style.hxx>
34 #include <svl/itemiter.hxx>
35 #include <svx/pageitem.hxx>
36 #include <editeng/sizeitem.hxx>
37 #include <editeng/ulspitem.hxx>
38 #include <editeng/lrspitem.hxx>
39 #include <editeng/boxitem.hxx>
40 #include <editeng/shaditem.hxx>
41 #include <editeng/brshitem.hxx>
42 #include <editeng/flstitem.hxx>
43 #include <editeng/paperinf.hxx>
44 #include <pagedesc.hxx>
45 #include <doc.hxx>
46 #include <IDocumentUndoRedo.hxx>
47 #include <docary.hxx>
48 #include <charfmt.hxx>
49 #include <cmdid.h>
50 #include <unostyle.hxx>
51 #include <unosett.hxx>
52 #include <docsh.hxx>
53 #include <swstyle.h>
54 #include <paratr.hxx>
55 #include <unoprnms.hxx>
56 #include <shellio.hxx>
57 #include <docstyle.hxx>
58 #include <unotextbodyhf.hxx>
59 #include <fmthdft.hxx>
60 #include <fmtpdsc.hxx>
61 #include <tools/urlobj.hxx>
62 #include <poolfmt.hrc>
63 #include <poolfmt.hxx>
64 #include "unoevent.hxx"
65 #include <fmtruby.hxx>
66 #include <SwStyleNameMapper.hxx>
67 #include <sfx2/printer.hxx>
68 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
69 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
70 #include <com/sun/star/beans/PropertyAttribute.hpp>
71 #include <com/sun/star/beans/NamedValue.hpp>
72 #include <istyleaccess.hxx>
73 #include <GetMetricVal.hxx>
74 #include <fmtfsize.hxx>
75 #include <numrule.hxx>
76
77 #include <boost/shared_ptr.hpp>
78
79 #include "ccoll.hxx"
80 #include "unocore.hrc"
81
82 #include <set>
83
84 #define STYLE_FAMILY_COUNT 5 // we have 5 style families
85 #define TYPE_BOOL 0
86 #define TYPE_SIZE 1
87 #define TYPE_BRUSH 2
88 #define TYPE_ULSPACE 3
89 #define TYPE_SHADOW 4
90 #define TYPE_LRSPACE 5
91 #define TYPE_BOX 6
92
93 const unsigned short aStyleByIndex[] =
94 {
95 SFX_STYLE_FAMILY_CHAR,
96 SFX_STYLE_FAMILY_PARA,
97 SFX_STYLE_FAMILY_PAGE ,
98 SFX_STYLE_FAMILY_FRAME ,
99 SFX_STYLE_FAMILY_PSEUDO
100 };
101
102 // Already implemented autostyle families: 3
103 #define AUTOSTYLE_FAMILY_COUNT 3
104 const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] =
105 {
106 IStyleAccess::AUTO_STYLE_CHAR,
107 IStyleAccess::AUTO_STYLE_RUBY,
108 IStyleAccess::AUTO_STYLE_PARA
109 };
110
111 using namespace ::com::sun::star;
112 using ::rtl::OUString;
113
114 /******************************************************************************
115 *
116 ******************************************************************************/
117
118 //convert FN_... to RES_ in header and footer itemset
lcl_ConvertFNToRES(sal_uInt16 nFNId)119 sal_uInt16 lcl_ConvertFNToRES(sal_uInt16 nFNId)
120 {
121 sal_uInt16 nRes = USHRT_MAX;
122 switch(nFNId)
123 {
124 case FN_UNO_FOOTER_ON:
125 case FN_UNO_HEADER_ON:
126 break;
127 case FN_UNO_FOOTER_BACKGROUND:
128 case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND;
129 break;
130 case FN_UNO_FOOTER_BOX:
131 case FN_UNO_HEADER_BOX: nRes = RES_BOX;
132 break;
133 case FN_UNO_FOOTER_LR_SPACE:
134 case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;
135 break;
136 case FN_UNO_FOOTER_SHADOW:
137 case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;
138 break;
139 case FN_UNO_FOOTER_BODY_DISTANCE:
140 case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;
141 break;
142 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
143 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
144 break;
145 case FN_UNO_FOOTER_SHARE_CONTENT:
146 case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED;
147 break;
148 case FN_UNO_FOOTER_HEIGHT:
149 case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;
150 break;
151 case FN_UNO_FOOTER_EAT_SPACING:
152 case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;
153 break;
154 }
155 return nRes;
156
157 }
158
lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)159 SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum ( SfxStyleFamily eFamily )
160 {
161 switch ( eFamily )
162 {
163 case SFX_STYLE_FAMILY_CHAR:
164 return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
165 case SFX_STYLE_FAMILY_PARA:
166 return nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
167 case SFX_STYLE_FAMILY_FRAME:
168 return nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
169 case SFX_STYLE_FAMILY_PAGE:
170 return nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC;
171 case SFX_STYLE_FAMILY_PSEUDO:
172 return nsSwGetPoolIdFromName::GET_POOLID_NUMRULE;
173 default:
174 DBG_ASSERT(sal_False, "someone asking for all styles in unostyle.cxx!" );
175 return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
176 }
177 }
178
179 class SwAutoStylesEnumImpl
180 {
181 std::vector<SfxItemSet_Pointer_t> mAutoStyles;
182 std::vector<SfxItemSet_Pointer_t>::iterator aIter;
183 SwDoc* pDoc;
184 IStyleAccess::SwAutoStyleFamily eFamily;
185 public:
186 SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam );
hasMoreElements()187 ::sal_Bool hasMoreElements() { return aIter != mAutoStyles.end(); }
nextElement()188 SfxItemSet_Pointer_t nextElement() { return *(aIter++); }
getFamily() const189 IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; }
getDoc() const190 SwDoc* getDoc() const { return pDoc; }
191 };
192
193
194 /******************************************************************
195 * SwXStyleFamilies
196 ******************************************************************/
197 /* -----------------------------06.04.00 11:24--------------------------------
198
199 ---------------------------------------------------------------------------*/
getImplementationName(void)200 OUString SwXStyleFamilies::getImplementationName(void) throw( uno::RuntimeException )
201 {
202 return C2U("SwXStyleFamilies");
203 }
204 /* -----------------------------06.04.00 11:24--------------------------------
205
206 ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)207 sal_Bool SwXStyleFamilies::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
208 {
209 return C2U("com.sun.star.style.StyleFamilies") == rServiceName;
210 }
211 /* -----------------------------06.04.00 11:24--------------------------------
212
213 ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)214 uno::Sequence< OUString > SwXStyleFamilies::getSupportedServiceNames(void) throw( uno::RuntimeException )
215 {
216 uno::Sequence< OUString > aRet(1);
217 OUString* pArray = aRet.getArray();
218 pArray[0] = C2U("com.sun.star.style.StyleFamilies");
219 return aRet;
220 }
221 /*-- 16.12.98 15:13:26---------------------------------------------------
222
223 -----------------------------------------------------------------------*/
SwXStyleFamilies(SwDocShell & rDocShell)224 SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) :
225 SwUnoCollection(rDocShell.GetDoc()),
226 pDocShell(&rDocShell),
227 pxCharStyles(0),
228 pxParaStyles(0),
229 pxFrameStyles(0),
230 pxPageStyles(0),
231 pxNumberingStyles(0)
232 {
233
234 }
235 /*-- 16.12.98 15:13:26---------------------------------------------------
236
237 -----------------------------------------------------------------------*/
~SwXStyleFamilies()238 SwXStyleFamilies::~SwXStyleFamilies()
239 {
240 delete pxCharStyles;
241 delete pxParaStyles;
242 delete pxFrameStyles;
243 delete pxPageStyles;
244 delete pxNumberingStyles;
245 }
246 /*-- 21.12.98 12:05:22---------------------------------------------------
247
248 -----------------------------------------------------------------------*/
getByName(const OUString & Name)249 uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name)
250 throw(
251 container::NoSuchElementException,
252 lang::WrappedTargetException,
253 uno::RuntimeException )
254 {
255 vos::OGuard aGuard(Application::GetSolarMutex());
256 // der Index kommt aus const unsigned short aStyleByIndex[] =
257 uno::Any aRet;
258 if(!IsValid())
259 throw uno::RuntimeException();
260 if(Name.compareToAscii("CharacterStyles") == 0 )
261 aRet = getByIndex(0);
262 else if(Name.compareToAscii("ParagraphStyles") == 0)
263 aRet = getByIndex(1);
264 else if(Name.compareToAscii("FrameStyles") == 0 )
265 aRet = getByIndex(3);
266 else if(Name.compareToAscii("PageStyles") == 0 )
267 aRet = getByIndex(2);
268 else if(Name.compareToAscii("NumberingStyles") == 0 )
269 aRet = getByIndex(4);
270 else
271 throw container::NoSuchElementException();
272 return aRet;
273 }
274 /*-- 21.12.98 12:05:22---------------------------------------------------
275
276 -----------------------------------------------------------------------*/
getElementNames(void)277 uno::Sequence< OUString > SwXStyleFamilies::getElementNames(void) throw( uno::RuntimeException )
278 {
279 uno::Sequence< OUString > aNames(STYLE_FAMILY_COUNT);
280 OUString* pNames = aNames.getArray();
281 pNames[0] = C2U("CharacterStyles");
282 pNames[1] = C2U("ParagraphStyles");
283 pNames[2] = C2U("FrameStyles");
284 pNames[3] = C2U("PageStyles");
285 pNames[4] = C2U("NumberingStyles");
286 return aNames;
287 }
288 /*-- 21.12.98 12:05:22---------------------------------------------------
289
290 -----------------------------------------------------------------------*/
hasByName(const OUString & Name)291 sal_Bool SwXStyleFamilies::hasByName(const OUString& Name) throw( uno::RuntimeException )
292 {
293 if( Name.compareToAscii("CharacterStyles") == 0 ||
294 Name.compareToAscii("ParagraphStyles") == 0 ||
295 Name.compareToAscii("FrameStyles") == 0 ||
296 Name.compareToAscii("PageStyles") == 0 ||
297 Name.compareToAscii("NumberingStyles") == 0 )
298 return sal_True;
299 else
300 return sal_False;
301 }
302 /*-- 16.12.98 15:13:27---------------------------------------------------
303
304 -----------------------------------------------------------------------*/
getCount(void)305 sal_Int32 SwXStyleFamilies::getCount(void) throw( uno::RuntimeException )
306 {
307 return STYLE_FAMILY_COUNT;
308 }
309 /*-- 16.12.98 15:13:27---------------------------------------------------
310
311 -----------------------------------------------------------------------*/
getByIndex(sal_Int32 nIndex)312 uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
313 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
314 {
315 vos::OGuard aGuard(Application::GetSolarMutex());
316 uno::Any aRet;
317 if(nIndex < 0 || nIndex >= STYLE_FAMILY_COUNT)
318 throw lang::IndexOutOfBoundsException();
319 if(IsValid())
320 {
321 uno::Reference< container::XNameContainer > aRef;
322 sal_uInt16 nType = aStyleByIndex[nIndex];
323 switch( nType )
324 {
325 case SFX_STYLE_FAMILY_CHAR:
326 {
327 if(!pxCharStyles)
328 {
329 ((SwXStyleFamilies*)this)->pxCharStyles = new uno::Reference< container::XNameContainer > ();
330 *pxCharStyles = new SwXStyleFamily(pDocShell, nType);
331 }
332 aRef = *pxCharStyles;
333 }
334 break;
335 case SFX_STYLE_FAMILY_PARA:
336 {
337 if(!pxParaStyles)
338 {
339 ((SwXStyleFamilies*)this)->pxParaStyles = new uno::Reference< container::XNameContainer > ();
340 *pxParaStyles = new SwXStyleFamily(pDocShell, nType);
341 }
342 aRef = *pxParaStyles;
343 }
344 break;
345 case SFX_STYLE_FAMILY_PAGE :
346 {
347 if(!pxPageStyles)
348 {
349 ((SwXStyleFamilies*)this)->pxPageStyles = new uno::Reference< container::XNameContainer > ();
350 *pxPageStyles = new SwXStyleFamily(pDocShell, nType);
351 }
352 aRef = *pxPageStyles;
353 }
354 break;
355 case SFX_STYLE_FAMILY_FRAME :
356 {
357 if(!pxFrameStyles)
358 {
359 ((SwXStyleFamilies*)this)->pxFrameStyles = new uno::Reference< container::XNameContainer > ();
360 *pxFrameStyles = new SwXStyleFamily(pDocShell, nType);
361 }
362 aRef = *pxFrameStyles;
363 }
364 break;
365 case SFX_STYLE_FAMILY_PSEUDO:
366 {
367 if(!pxNumberingStyles)
368 {
369 ((SwXStyleFamilies*)this)->pxNumberingStyles = new uno::Reference< container::XNameContainer > ();
370 *pxNumberingStyles = new SwXStyleFamily(pDocShell, nType);
371 }
372 aRef = *pxNumberingStyles;
373 }
374 break;
375 }
376 aRet.setValue(&aRef, ::getCppuType((const uno::Reference<container::XNameContainer>*)0));
377 }
378 else
379 throw uno::RuntimeException();
380 return aRet;
381 }
382 /*-- 16.12.98 15:13:27---------------------------------------------------
383
384 -----------------------------------------------------------------------*/
getElementType(void)385 uno::Type SwXStyleFamilies::getElementType(void)
386 throw( uno::RuntimeException )
387 {
388 return ::getCppuType((const uno::Reference<container::XNameContainer>*)0);
389
390 }
391 /*-- 16.12.98 15:13:28---------------------------------------------------
392
393 -----------------------------------------------------------------------*/
hasElements(void)394 sal_Bool SwXStyleFamilies::hasElements(void) throw( uno::RuntimeException )
395 {
396 return sal_True;
397 }
398 /*-- 16.12.98 15:13:28---------------------------------------------------
399
400 -----------------------------------------------------------------------*/
loadStylesFromURL(const OUString & rURL,const uno::Sequence<beans::PropertyValue> & aOptions)401 void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL,
402 const uno::Sequence< beans::PropertyValue >& aOptions)
403 throw( io::IOException, uno::RuntimeException )
404 {
405 vos::OGuard aGuard(Application::GetSolarMutex());
406 sal_Bool bLoadStyleText = sal_True;
407 sal_Bool bLoadStylePage = sal_True;
408 sal_Bool bLoadStyleOverwrite = sal_True;
409 sal_Bool bLoadStyleNumbering = sal_True;
410 sal_Bool bLoadStyleFrame = sal_True;
411 if(IsValid() && rURL.getLength())
412 {
413 const uno::Any* pVal;
414 int nCount = aOptions.getLength();
415 const beans::PropertyValue* pArray = aOptions.getConstArray();
416 for(int i = 0; i < nCount; i++)
417 if( ( pVal = &pArray[i].Value)->getValueType() ==
418 ::getBooleanCppuType() )
419 {
420 String sName = pArray[i].Name;
421 sal_Bool bVal = *(sal_Bool*)pVal->getValue();
422 if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_OVERWRITE_STYLES )))
423 bLoadStyleOverwrite = bVal;
424 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_NUMBERING_STYLES )))
425 bLoadStyleNumbering = bVal;
426 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_PAGE_STYLES )))
427 bLoadStylePage = bVal;
428 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_FRAME_STYLES )))
429 bLoadStyleFrame = bVal;
430 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_TEXT_STYLES )))
431 bLoadStyleText = bVal;
432 }
433
434 SwgReaderOption aOpt;
435 aOpt.SetFrmFmts( bLoadStyleFrame );
436 aOpt.SetTxtFmts( bLoadStyleText );
437 aOpt.SetPageDescs( bLoadStylePage );
438 aOpt.SetNumRules( bLoadStyleNumbering );
439 aOpt.SetMerge( !bLoadStyleOverwrite );
440
441 sal_uLong nErr = pDocShell->LoadStylesFromFile( rURL, aOpt, sal_True );
442 if( nErr )
443 throw io::IOException();
444 }
445 else
446 throw uno::RuntimeException();
447 }
448 /*-- 16.12.98 15:13:28---------------------------------------------------
449
450 -----------------------------------------------------------------------*/
getStyleLoaderOptions(void)451 uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions(void)
452 throw( uno::RuntimeException )
453 {
454 vos::OGuard aGuard(Application::GetSolarMutex());
455 uno::Sequence< beans::PropertyValue > aSeq(5);
456 beans::PropertyValue* pArray = aSeq.getArray();
457 uno::Any aVal;
458 sal_Bool bTemp = sal_True;
459 aVal.setValue(&bTemp, ::getCppuBooleanType());
460 pArray[0] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_TEXT_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
461 aVal.setValue(&bTemp, ::getCppuBooleanType());
462 pArray[1] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_FRAME_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
463 aVal.setValue(&bTemp, ::getCppuBooleanType());
464 pArray[2] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_PAGE_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
465 aVal.setValue(&bTemp, ::getCppuBooleanType());
466 pArray[3] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_NUMBERING_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
467 aVal.setValue(&bTemp, ::getCppuBooleanType());
468 pArray[4] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_OVERWRITE_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
469 return aSeq;
470 }
471
472 /******************************************************************
473 * SwXStyleFamily
474 ******************************************************************/
475 /* -----------------------------06.04.00 11:24--------------------------------
476
477 ---------------------------------------------------------------------------*/
getImplementationName(void)478 OUString SwXStyleFamily::getImplementationName(void) throw( uno::RuntimeException )
479 {
480 return C2U("SwXStyleFamily");
481 }
482 /* -----------------------------06.04.00 11:24--------------------------------
483
484 ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)485 sal_Bool SwXStyleFamily::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
486 {
487 return C2U("com.sun.star.style.StyleFamily") == rServiceName;
488 }
489 /* -----------------------------06.04.00 11:24--------------------------------
490
491 ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)492 uno::Sequence< OUString > SwXStyleFamily::getSupportedServiceNames(void) throw( uno::RuntimeException )
493 {
494 uno::Sequence< OUString > aRet(1);
495 OUString* pArray = aRet.getArray();
496 pArray[0] = C2U("com.sun.star.style.StyleFamily");
497 return aRet;
498 }
499 /*-- 16.12.98 16:03:56---------------------------------------------------
500
501 -----------------------------------------------------------------------*/
SwXStyleFamily(SwDocShell * pDocSh,sal_uInt16 nFamily)502 SwXStyleFamily::SwXStyleFamily(SwDocShell* pDocSh, sal_uInt16 nFamily) :
503 eFamily((SfxStyleFamily)nFamily),
504 pBasePool(pDocSh->GetStyleSheetPool()),
505 pDocShell(pDocSh)
506 {
507 /* switch( nFamily )
508 {
509 case SFX_STYLE_FAMILY_CHAR:
510 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_CHAR_STYLE);
511 break;
512 case SFX_STYLE_FAMILY_PARA:
513 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PARA_STYLE);
514 break;
515 case SFX_STYLE_FAMILY_PAGE:
516 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PAGE_STYLE);
517 break;
518 case SFX_STYLE_FAMILY_FRAME:
519 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_FRAME_STYLE);
520 break;
521 case SFX_STYLE_FAMILY_PSEUDO:
522 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_NUM_STYLE);
523 break;
524 }*/
525 StartListening(*pBasePool);
526 }
527 /*-- 16.12.98 16:03:56---------------------------------------------------
528
529 -----------------------------------------------------------------------*/
~SwXStyleFamily()530 SwXStyleFamily::~SwXStyleFamily()
531 {
532
533 }
lcl_GetCountOrName(const SwDoc & rDoc,SfxStyleFamily eFamily,String * pString,sal_uInt16 nIndex=USHRT_MAX)534 sal_Int32 lcl_GetCountOrName ( const SwDoc &rDoc, SfxStyleFamily eFamily, String *pString, sal_uInt16 nIndex = USHRT_MAX )
535 {
536 sal_Int32 nCount = 0;
537 switch( eFamily )
538 {
539 case SFX_STYLE_FAMILY_CHAR:
540 {
541 sal_uInt16 nBaseCount = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
542 RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
543 nIndex = nIndex - nBaseCount;
544 const sal_uInt16 nArrLen = rDoc.GetCharFmts()->Count();
545 for( sal_uInt16 i = 0; i < nArrLen; i++ )
546 {
547 SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
548 if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() )
549 continue;
550 if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
551 {
552 if ( nIndex == nCount )
553 {
554 // the default character format needs to be set to "Default!"
555 if(rDoc.GetDfltCharFmt() == pFmt)
556 SwStyleNameMapper::FillUIName(
557 RES_POOLCOLL_STANDARD, *pString );
558 else
559 *pString = pFmt->GetName();
560 break;
561 }
562 nCount++;
563 }
564 }
565 nCount += nBaseCount;
566 }
567 break;
568 case SFX_STYLE_FAMILY_PARA:
569 {
570 sal_uInt16 nBaseCount = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
571 RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
572 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
573 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
574 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
575 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
576 nIndex = nIndex - nBaseCount;
577 const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count();
578 for ( sal_uInt16 i = 0; i < nArrLen; i++ )
579 {
580 SwTxtFmtColl * pColl = (*rDoc.GetTxtFmtColls())[i];
581 if ( pColl->IsDefault() )
582 continue;
583 if ( IsPoolUserFmt ( pColl->GetPoolFmtId() ) )
584 {
585 if ( nIndex == nCount )
586 {
587 *pString = pColl->GetName();
588 break;
589 }
590 nCount++;
591 }
592 }
593 nCount += nBaseCount;
594 }
595 break;
596 case SFX_STYLE_FAMILY_FRAME:
597 {
598 sal_uInt16 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
599 nIndex = nIndex - nBaseCount;
600 const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->Count();
601 for( sal_uInt16 i = 0; i < nArrLen; i++ )
602 {
603 SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
604 if(pFmt->IsDefault() || pFmt->IsAuto())
605 continue;
606 if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
607 {
608 if ( nIndex == nCount )
609 {
610 *pString = pFmt->GetName();
611 break;
612 }
613 nCount++;
614 }
615 }
616 nCount += nBaseCount;
617 }
618 break;
619 case SFX_STYLE_FAMILY_PAGE:
620 {
621 sal_uInt16 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
622 nIndex = nIndex - nBaseCount;
623 const sal_uInt16 nArrLen = rDoc.GetPageDescCnt();
624 for(sal_uInt16 i = 0; i < nArrLen; ++i)
625 {
626 const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
627
628 /*if(rDesc.IsDefault() || rDesc.IsAuto())
629 continue;*/
630 if ( IsPoolUserFmt ( rDesc.GetPoolFmtId() ) )
631 {
632 if ( nIndex == nCount )
633 {
634 *pString = rDesc.GetName();
635 break;
636 }
637 nCount++;
638 }
639 }
640 nCount += nBaseCount;
641 }
642 break;
643 case SFX_STYLE_FAMILY_PSEUDO:
644 {
645 sal_uInt16 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
646 nIndex = nIndex - nBaseCount;
647 const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
648 for(sal_uInt16 i = 0; i < rNumTbl.Count(); ++i)
649 {
650 const SwNumRule& rRule = *rNumTbl[ i ];
651 if( rRule.IsAutoRule() )
652 continue;
653 if ( IsPoolUserFmt ( rRule.GetPoolFmtId() ) )
654 {
655 if ( nIndex == nCount )
656 {
657 *pString = rRule.GetName();
658 break;
659 }
660 nCount++;
661 }
662 }
663 nCount += nBaseCount;
664 }
665 break;
666
667 default:
668 ;
669 }
670 return nCount;
671 }
672 /*-- 16.12.98 16:03:57---------------------------------------------------
673
674 -----------------------------------------------------------------------*/
getCount(void)675 sal_Int32 SwXStyleFamily::getCount(void) throw( uno::RuntimeException )
676 {
677 vos::OGuard aGuard(Application::GetSolarMutex());
678 return lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, NULL );
679 }
680 /*-- 16.12.98 16:03:57---------------------------------------------------
681
682 -----------------------------------------------------------------------*/
getByIndex(sal_Int32 nTempIndex)683 uno::Any SwXStyleFamily::getByIndex(sal_Int32 nTempIndex)
684 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
685 {
686 vos::OGuard aGuard(Application::GetSolarMutex());
687 uno::Any aRet;
688 if ( nTempIndex >= 0 && nTempIndex < USHRT_MAX )
689 {
690 sal_uInt16 nIndex = static_cast < sal_uInt16 > ( nTempIndex );
691 if(pBasePool)
692 {
693 String sStyleName;
694 switch( eFamily )
695 {
696 case SFX_STYLE_FAMILY_CHAR:
697 {
698 if ( nIndex < ( RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
699 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName );
700 else if ( nIndex < ( RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
701 RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
702 SwStyleNameMapper::FillUIName ( RES_POOLCHR_HTML_BEGIN
703 - RES_POOLCHR_NORMAL_END + RES_POOLCHR_NORMAL_BEGIN
704 + nIndex, sStyleName );
705 }
706 break;
707 case SFX_STYLE_FAMILY_PARA:
708 {
709 if ( nIndex < ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
710 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_TEXT_BEGIN + nIndex), sStyleName );
711 else if ( nIndex < ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
712 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
713 SwStyleNameMapper::FillUIName ( RES_POOLCOLL_LISTS_BEGIN
714 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
715 + nIndex, sStyleName );
716 else if ( nIndex < ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
717 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
718 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
719 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_EXTRA_BEGIN
720 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
721 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
722 + nIndex), sStyleName );
723 else if ( nIndex < ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
724 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
725 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
726 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
727 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_REGISTER_BEGIN
728 - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
729 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
730 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
731 + nIndex), sStyleName );
732 else if ( nIndex < ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
733 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
734 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
735 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
736 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
737 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_DOC_BEGIN
738 - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
739 - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
740 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
741 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
742 + nIndex), sStyleName );
743 else if ( nIndex < ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
744 RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
745 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
746 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
747 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
748 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
749 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_HTML_BEGIN
750 - RES_POOLCOLL_DOC_END + RES_POOLCOLL_DOC_BEGIN
751 - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
752 - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
753 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
754 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
755 + nIndex), sStyleName );
756 }
757 break;
758 case SFX_STYLE_FAMILY_FRAME:
759 {
760 if ( nIndex < ( RES_POOLFRM_END - RES_POOLFRM_BEGIN ) )
761 {
762 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLFRM_BEGIN + nIndex), sStyleName );
763 }
764 }
765 break;
766 case SFX_STYLE_FAMILY_PAGE:
767 {
768 if ( nIndex < ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN ) )
769 {
770 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + nIndex), sStyleName );
771 }
772 }
773 break;
774 case SFX_STYLE_FAMILY_PSEUDO:
775 {
776 if ( nIndex < ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN ) )
777 {
778 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName );
779 }
780 }
781 break;
782
783 default:
784 ;
785 }
786 if ( !sStyleName.Len() )
787 lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, &sStyleName, nIndex );
788
789 if ( sStyleName.Len() )
790 {
791 SfxStyleSheetBase* pBase = pBasePool->Find( sStyleName, eFamily );
792 if(pBase)
793 {
794 uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
795 if(!xStyle.is())
796 {
797 xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
798 new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
799 eFamily == SFX_STYLE_FAMILY_FRAME ?
800 new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
801 new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
802 }
803 aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
804 }
805 else
806 throw container::NoSuchElementException();
807 }
808 else
809 throw lang::IndexOutOfBoundsException();
810 }
811 else
812 throw uno::RuntimeException();
813 }
814 else
815 throw lang::IndexOutOfBoundsException();
816
817 return aRet;
818 }
819 /*-- 16.12.98 16:03:57---------------------------------------------------
820
821 -----------------------------------------------------------------------*/
getByName(const OUString & rName)822 uno::Any SwXStyleFamily::getByName(const OUString& rName)
823 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
824 {
825 vos::OGuard aGuard(Application::GetSolarMutex());
826 uno::Any aRet;
827 String sStyleName;
828 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
829 if(pBasePool)
830 {
831 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
832 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
833 if(pBase)
834 {
835 uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
836 if(!xStyle.is())
837 {
838 xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
839 new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
840 eFamily == SFX_STYLE_FAMILY_FRAME ?
841 new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
842 new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
843 }
844 aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
845 }
846 else
847 throw container::NoSuchElementException();
848 }
849 else
850 throw uno::RuntimeException();
851 return aRet;
852
853 }
854 /*-- 16.12.98 16:03:57---------------------------------------------------
855
856 -----------------------------------------------------------------------*/
getElementNames(void)857 uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException )
858 {
859 vos::OGuard aGuard(Application::GetSolarMutex());
860 uno::Sequence< OUString > aRet;
861 if(pBasePool)
862 {
863 SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, 0xffff);
864 sal_uInt16 nCount = pIterator->Count();
865 aRet.realloc(nCount);
866 OUString* pArray = aRet.getArray();
867 String aString;
868 for(sal_uInt16 i = 0; i < nCount; i++)
869 {
870 SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
871 pArray[i] = OUString ( aString );
872 }
873 }
874 else
875 throw uno::RuntimeException();
876 return aRet;
877 }
878 /*-- 16.12.98 16:03:57---------------------------------------------------
879
880 -----------------------------------------------------------------------*/
hasByName(const OUString & rName)881 sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException )
882 {
883 vos::OGuard aGuard(Application::GetSolarMutex());
884 sal_Bool bRet = sal_False;
885 if(pBasePool)
886 {
887 String sStyleName;
888 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
889 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
890 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
891 bRet = 0 != pBase;
892 }
893 else
894 throw uno::RuntimeException();
895 return bRet;
896
897 }
898 /*-- 16.12.98 16:03:58---------------------------------------------------
899
900 -----------------------------------------------------------------------*/
getElementType(void)901 uno::Type SwXStyleFamily::getElementType(void) throw( uno::RuntimeException )
902 {
903 return ::getCppuType((const uno::Reference<style::XStyle>*)0);
904
905 }
906 /*-- 16.12.98 16:03:58---------------------------------------------------
907
908 -----------------------------------------------------------------------*/
hasElements(void)909 sal_Bool SwXStyleFamily::hasElements(void) throw( uno::RuntimeException )
910 {
911 if(!pBasePool)
912 throw uno::RuntimeException();
913 return sal_True;
914 }
915 /*-- 16.12.98 16:03:58---------------------------------------------------
916
917 -----------------------------------------------------------------------*/
insertByName(const OUString & rName,const uno::Any & rElement)918 void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
919 throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
920 {
921 vos::OGuard aGuard(Application::GetSolarMutex());
922 if(pBasePool)
923 {
924 String sStyleName;
925 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
926 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
927 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
928 SfxStyleSheetBase* pUINameBase = pBasePool->Find( sStyleName );
929 if(pBase || pUINameBase)
930 throw container::ElementExistException();
931 else
932 {
933 if(rElement.getValueType().getTypeClass() ==
934 uno::TypeClass_INTERFACE)
935 {
936 uno::Reference< uno::XInterface > * pxRef =
937 (uno::Reference< uno::XInterface > *)rElement.getValue();
938
939 uno::Reference<lang::XUnoTunnel> xStyleTunnel( *pxRef, uno::UNO_QUERY);
940
941 SwXStyle* pNewStyle = 0;
942 if(xStyleTunnel.is())
943 {
944 pNewStyle = reinterpret_cast< SwXStyle * >(
945 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
946 }
947 if(!pNewStyle || !pNewStyle->IsDescriptor() ||
948 pNewStyle->GetFamily() != eFamily)
949 throw lang::IllegalArgumentException();
950 if(pNewStyle)
951 {
952 sal_uInt16 nMask = 0xffff;
953 if(eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional())
954 nMask &= ~SWSTYLEBIT_CONDCOLL;
955 #if OSL_DEBUG_LEVEL > 1
956 SfxStyleSheetBase& rNewBase =
957 #endif
958 pBasePool->Make(sStyleName, eFamily, nMask);
959 pNewStyle->SetDoc(pDocShell->GetDoc(), pBasePool);
960 pNewStyle->SetStyleName(sStyleName);
961 String sParentStyleName(pNewStyle->GetParentStyleName());
962 if(sParentStyleName.Len())
963 {
964 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
965 SfxStyleSheetBase* pParentBase = pBasePool->Find(sParentStyleName);
966 if(pParentBase && pParentBase->GetFamily() == eFamily &&
967 &pParentBase->GetPool() == pBasePool)
968 pBasePool->SetParent( eFamily, sStyleName, sParentStyleName );
969
970 }
971 #if OSL_DEBUG_LEVEL > 1
972 (void)rNewBase;
973 #endif
974 //so, jetzt sollten noch die Properties des Descriptors angewandt werden
975 pNewStyle->ApplyDescriptorProperties();
976 }
977 else
978 throw lang::IllegalArgumentException();
979 }
980 else
981 throw lang::IllegalArgumentException();
982 }
983 }
984 else
985 throw uno::RuntimeException();
986 }
987 /*-- 16.12.98 16:03:59---------------------------------------------------
988
989 -----------------------------------------------------------------------*/
replaceByName(const OUString & rName,const uno::Any & rElement)990 void SwXStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement)
991 throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
992 {
993 vos::OGuard aGuard(Application::GetSolarMutex());
994 if(pBasePool)
995 {
996 pBasePool->SetSearchMask(eFamily);
997 SfxStyleSheetBase* pBase = pBasePool->Find(rName);
998 //Ersetzung geht nur fuer benutzerdefinierte Styles
999 if(!pBase)
1000 throw container::NoSuchElementException();
1001 if(!pBase->IsUserDefined())
1002 throw lang::IllegalArgumentException();
1003 //if theres an object available to this style then it must be invalidated
1004 uno::Reference< style::XStyle > xStyle = _FindStyle(pBase->GetName());
1005 if(xStyle.is())
1006 {
1007 uno::Reference<lang::XUnoTunnel> xTunnel( xStyle, uno::UNO_QUERY);
1008 if(xTunnel.is())
1009 {
1010 SwXStyle* pStyle = reinterpret_cast< SwXStyle * >(
1011 sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
1012 pStyle->Invalidate();
1013 }
1014 }
1015
1016 pBasePool->Remove(pBase);
1017 insertByName(rName, rElement);
1018 }
1019 else
1020 throw uno::RuntimeException();
1021 }
1022 /*-- 16.12.98 16:03:59---------------------------------------------------
1023
1024 -----------------------------------------------------------------------*/
removeByName(const OUString & rName)1025 void SwXStyleFamily::removeByName(const OUString& rName) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
1026 {
1027 vos::OGuard aGuard(Application::GetSolarMutex());
1028 if(pBasePool)
1029 {
1030 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1031 String aString;
1032 SwStyleNameMapper::FillUIName(rName, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1033
1034 SfxStyleSheetBase* pBase = pBasePool->Find( aString );
1035 if(pBase)
1036 pBasePool->Remove(pBase);
1037 else
1038 throw container::NoSuchElementException();
1039 }
1040 else
1041 throw uno::RuntimeException();
1042 }
1043
getPropertySetInfo()1044 uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXStyleFamily::getPropertySetInfo( ) throw (uno::RuntimeException)
1045 {
1046 OSL_ENSURE( 0, "###unexpected!" );
1047 return uno::Reference< beans::XPropertySetInfo >();
1048 }
1049
setPropertyValue(const::rtl::OUString &,const uno::Any &)1050 void SAL_CALL SwXStyleFamily::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
1051 {
1052 OSL_ENSURE( 0, "###unexpected!" );
1053 }
1054
getPropertyValue(const::rtl::OUString & sPropertyName)1055 uno::Any SAL_CALL SwXStyleFamily::getPropertyValue( const ::rtl::OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1056 {
1057 uno::Any aRet;
1058
1059 if ( sPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ) )
1060 {
1061 vos::OGuard aGuard(Application::GetSolarMutex());
1062 sal_uInt32 nResId = 0;
1063 switch ( eFamily )
1064 {
1065 case SFX_STYLE_FAMILY_CHAR:
1066 nResId = STR_STYLE_FAMILY_CHARACTER; break;
1067 case SFX_STYLE_FAMILY_PARA:
1068 nResId = STR_STYLE_FAMILY_PARAGRAPH; break;
1069 case SFX_STYLE_FAMILY_FRAME:
1070 nResId = STR_STYLE_FAMILY_FRAME; break;
1071 case SFX_STYLE_FAMILY_PAGE:
1072 nResId = STR_STYLE_FAMILY_PAGE; break;
1073 case SFX_STYLE_FAMILY_PSEUDO:
1074 nResId = STR_STYLE_FAMILY_NUMBERING; break;
1075 default:
1076 OSL_ENSURE( 0, "SwXStyleFamily::getPropertyValue(): invalid family" );
1077 }
1078 if ( nResId > 0 )
1079 {
1080 OUString sDisplayName( String( SW_RES( nResId ) ) );
1081 aRet = uno::makeAny( sDisplayName );
1082 }
1083 }
1084 else
1085 {
1086 throw beans::UnknownPropertyException( OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + sPropertyName, static_cast<OWeakObject *>(this) );
1087 }
1088
1089 return aRet;
1090 }
1091
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1092 void SAL_CALL SwXStyleFamily::addPropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1093 {
1094 OSL_ENSURE( 0, "###unexpected!" );
1095 }
1096
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1097 void SAL_CALL SwXStyleFamily::removePropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1098 {
1099 OSL_ENSURE( 0, "###unexpected!" );
1100 }
1101
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1102 void SAL_CALL SwXStyleFamily::addVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1103 {
1104 OSL_ENSURE( 0, "###unexpected!" );
1105 }
1106
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1107 void SAL_CALL SwXStyleFamily::removeVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1108 {
1109 OSL_ENSURE( 0, "###unexpected!" );
1110 }
1111
1112
1113 /*-- 16.12.98 16:03:59---------------------------------------------------
1114
1115 -----------------------------------------------------------------------*/
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1116 void SwXStyleFamily::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1117 {
1118 SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
1119 if( pHint && ( pHint->GetId() & SFX_HINT_DYING ) )
1120 {
1121 pBasePool = 0;
1122 pDocShell = 0;
1123 EndListening(rBC);
1124 }
1125 }
1126 /*-- 16.12.98 16:03:59---------------------------------------------------
1127
1128 -----------------------------------------------------------------------*/
_FindStyle(const String & rStyleName) const1129 SwXStyle* SwXStyleFamily::_FindStyle(const String& rStyleName)const
1130 {
1131 sal_uInt16 nLCount = pBasePool->GetListenerCount();
1132 SfxListener* pListener = 0;
1133 for( sal_uInt16 i = 0; i < nLCount; i++)
1134 {
1135 pListener = pBasePool->GetListener( i );
1136 SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>( pListener );
1137 if(pTempStyle && pTempStyle->GetFamily() == eFamily && pTempStyle->GetStyleName() == rStyleName)
1138 {
1139 return pTempStyle;
1140 }
1141 }
1142 return 0;
1143 }
1144 /******************************************************************
1145 *
1146 ******************************************************************/
1147 class SwStyleProperties_Impl
1148 {
1149 const PropertyEntryVector_t aPropertyEntries;
1150 uno::Any** pAnyArr;
1151 sal_uInt32 nArrLen;
1152
1153 public:
1154 SwStyleProperties_Impl(const SfxItemPropertyMap* _pMap);
1155 ~SwStyleProperties_Impl();
1156
1157 sal_Bool SetProperty(const ::rtl::OUString& rName, uno::Any aVal);
1158 sal_Bool GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny);
1159 sal_Bool ClearProperty( const ::rtl::OUString& rPropertyName );
1160 void ClearAllProperties( );
1161 void GetProperty(const ::rtl::OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny );
1162
GetPropertyVector() const1163 const PropertyEntryVector_t& GetPropertyVector() const {return aPropertyEntries; }
1164
1165 };
1166 //--------------------------------------------------------------------
1167 //--------------------------------------------------------------------
SwStyleProperties_Impl(const SfxItemPropertyMap * pMap)1168 SwStyleProperties_Impl::SwStyleProperties_Impl(const SfxItemPropertyMap* pMap) :
1169 // _pMap(pMap),
1170 aPropertyEntries( pMap->getPropertyEntries() ),
1171 nArrLen(0)
1172 {
1173 nArrLen = aPropertyEntries.size();
1174 //const SfxItemPropertyMap* pTmp = _pMap;
1175
1176 pAnyArr = new uno::Any* [nArrLen];
1177 for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
1178 pAnyArr[i] = 0;
1179 }
1180 //--------------------------------------------------------------------
1181 //--------------------------------------------------------------------
~SwStyleProperties_Impl()1182 SwStyleProperties_Impl::~SwStyleProperties_Impl()
1183 {
1184 for ( sal_uInt16 i =0 ; i < nArrLen; i++ )
1185 delete pAnyArr[i];
1186 delete[] pAnyArr;
1187 }
1188
1189 //--------------------------------------------------------------------
1190 //--------------------------------------------------------------------
SetProperty(const::rtl::OUString & rName,uno::Any aVal)1191 sal_Bool SwStyleProperties_Impl::SetProperty(const ::rtl::OUString& rName, uno::Any aVal)
1192 {
1193 sal_uInt16 nPos = 0;
1194 sal_Bool bRet = sal_False;
1195 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1196 while( aIt != aPropertyEntries.end() )
1197 {
1198 if(rName == aIt->sName)
1199 {
1200 delete pAnyArr[nPos];
1201 pAnyArr[nPos] = new uno::Any ( aVal );
1202 bRet = sal_True;
1203 break;
1204 }
1205 ++nPos;
1206 ++aIt;
1207 }
1208 return bRet;
1209 }
1210
ClearProperty(const OUString & rName)1211 sal_Bool SwStyleProperties_Impl::ClearProperty( const OUString& rName )
1212 {
1213 sal_Bool bRet = sal_False;
1214 sal_uInt16 nPos = 0;
1215 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1216 while( aIt != aPropertyEntries.end() )
1217 {
1218 if( rName == aIt->sName )
1219 {
1220 delete pAnyArr[nPos];
1221 pAnyArr[ nPos ] = 0;
1222 bRet = sal_True;
1223 break;
1224 }
1225 ++nPos;
1226 ++aIt;
1227 }
1228 return bRet;
1229 }
ClearAllProperties()1230 void SwStyleProperties_Impl::ClearAllProperties( )
1231 {
1232 for ( sal_uInt16 i = 0; i < nArrLen; i++ )
1233 {
1234 delete pAnyArr[i];
1235 pAnyArr[ i ] = 0;
1236 }
1237 }
1238 //--------------------------------------------------------------------
1239 //--------------------------------------------------------------------
GetProperty(const::rtl::OUString & rName,uno::Any * & rpAny)1240 sal_Bool SwStyleProperties_Impl::GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny )
1241 {
1242 sal_Bool bRet = sal_False;
1243 sal_uInt16 nPos = 0;
1244 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1245 while( aIt != aPropertyEntries.end() )
1246 {
1247 if( rName == aIt->sName )
1248 {
1249 rpAny = pAnyArr[nPos];
1250 bRet = sal_True;
1251 break;
1252 }
1253 ++nPos;
1254 ++aIt;
1255 }
1256
1257 return bRet;
1258 }
1259
GetProperty(const OUString & rPropertyName,const uno::Reference<beans::XPropertySet> & rxPropertySet,uno::Any & rAny)1260 void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any & rAny )
1261 {
1262 rAny = rxPropertySet->getPropertyValue( rPropertyName );
1263 }
1264
1265 /******************************************************************
1266 *
1267 ******************************************************************/
1268 /* -----------------------------10.03.00 18:02--------------------------------
1269
1270 ---------------------------------------------------------------------------*/
getUnoTunnelId()1271 const uno::Sequence< sal_Int8 > & SwXStyle::getUnoTunnelId()
1272 {
1273 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
1274 return aSeq;
1275 }
1276 /* -----------------------------10.03.00 18:04--------------------------------
1277
1278 ---------------------------------------------------------------------------*/
getSomething(const uno::Sequence<sal_Int8> & rId)1279 sal_Int64 SAL_CALL SwXStyle::getSomething( const uno::Sequence< sal_Int8 >& rId )
1280 throw(uno::RuntimeException)
1281 {
1282 if( rId.getLength() == 16
1283 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1284 rId.getConstArray(), 16 ) )
1285 {
1286 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
1287 }
1288 return 0;
1289 }
1290
1291 TYPEINIT1(SwXStyle, SfxListener);
1292 /* -----------------------------06.04.00 11:24--------------------------------
1293
1294 ---------------------------------------------------------------------------*/
getImplementationName(void)1295 OUString SwXStyle::getImplementationName(void) throw( uno::RuntimeException )
1296 {
1297 return C2U("SwXStyle");
1298 }
1299 /* -----------------------------06.04.00 11:24--------------------------------
1300
1301 ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)1302 sal_Bool SwXStyle::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
1303 {
1304 sal_Bool bRet = C2U("com.sun.star.style.Style") == rServiceName;
1305 if(!bRet && SFX_STYLE_FAMILY_CHAR == eFamily)
1306 bRet = !rServiceName.compareToAscii("com.sun.star.style.CharacterStyle")||
1307 !rServiceName.compareToAscii("com.sun.star.style.CharacterProperties")||
1308 !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesAsian")||
1309 !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesComplex");
1310 if(!bRet && SFX_STYLE_FAMILY_PARA == eFamily)
1311 bRet = (C2U("com.sun.star.style.ParagraphStyle") == rServiceName)||
1312 (C2U("com.sun.star.style.ParagraphProperties") == rServiceName) ||
1313 (C2U("com.sun.star.style.ParagraphPropertiesAsian") == rServiceName) ||
1314 (C2U("com.sun.star.style.ParagraphPropertiesComplex") == rServiceName);
1315 if(!bRet && SFX_STYLE_FAMILY_PAGE == eFamily)
1316 bRet = (C2U("com.sun.star.style.PageStyle") == rServiceName)||
1317 (C2U("com.sun.star.style.PageProperties") == rServiceName);
1318
1319 return bRet;
1320 }
1321 /* -----------------------------06.04.00 11:24--------------------------------
1322
1323 ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)1324 uno::Sequence< OUString > SwXStyle::getSupportedServiceNames(void) throw( uno::RuntimeException )
1325 {
1326 long nCount = 1;
1327 if(SFX_STYLE_FAMILY_PARA == eFamily)
1328 {
1329 nCount = 5;
1330 if(bIsConditional)
1331 nCount++;
1332 }
1333 else if(SFX_STYLE_FAMILY_CHAR == eFamily)
1334 nCount = 5;
1335 else if(SFX_STYLE_FAMILY_PAGE == eFamily)
1336 nCount = 3;
1337 uno::Sequence< OUString > aRet(nCount);
1338 OUString* pArray = aRet.getArray();
1339 pArray[0] = C2U("com.sun.star.style.Style");
1340 switch(eFamily)
1341 {
1342 case SFX_STYLE_FAMILY_CHAR:
1343 pArray[1] = C2U("com.sun.star.style.CharacterStyle");
1344 pArray[2] = C2U("com.sun.star.style.CharacterProperties");
1345 pArray[3] = C2U("com.sun.star.style.CharacterPropertiesAsian");
1346 pArray[4] = C2U("com.sun.star.style.CharacterPropertiesComplex");
1347 break;
1348 case SFX_STYLE_FAMILY_PAGE:
1349 pArray[1] = C2U("com.sun.star.style.PageStyle");
1350 pArray[2] = C2U("com.sun.star.style.PageProperties");
1351 break;
1352 case SFX_STYLE_FAMILY_PARA:
1353 pArray[1] = C2U("com.sun.star.style.ParagraphStyle");
1354 pArray[2] = C2U("com.sun.star.style.ParagraphProperties");
1355 pArray[3] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
1356 pArray[4] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
1357 if(bIsConditional)
1358 pArray[5] = C2U("com.sun.star.style.ConditionalParagraphStyle");
1359 break;
1360
1361 default:
1362 ;
1363 }
1364 return aRet;
1365 }
1366 /*-- 17.12.98 08:26:49---------------------------------------------------
1367
1368 -----------------------------------------------------------------------*/
SwXStyle(SwDoc * pDoc,SfxStyleFamily eFam,sal_Bool bConditional)1369 SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, sal_Bool bConditional) :
1370 m_pDoc( pDoc ),
1371 pBasePool(0),
1372 eFamily(eFam),
1373 bIsDescriptor(sal_True),
1374 bIsConditional(bConditional)
1375 {
1376 // Register ourselves as a listener to the document (via the page descriptor)
1377 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1378 // get the property set for the default style data
1379 // First get the model
1380 uno::Reference < frame::XModel > xModel = pDoc->GetDocShell()->GetBaseModel();
1381 // Ask the model for it's family supplier interface
1382 uno::Reference < style::XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY );
1383 // Get the style families
1384 uno::Reference < container::XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies();
1385
1386 uno::Any aAny;
1387 sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE;
1388 switch( eFamily )
1389 {
1390 case SFX_STYLE_FAMILY_CHAR:
1391 {
1392 nMapId = PROPERTY_MAP_CHAR_STYLE;
1393 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "CharacterStyles" ) ) );
1394 // Get the Frame family (and keep it for later)
1395 aAny >>= mxStyleFamily;
1396 //aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1397 //aAny >>= mxStyleData;
1398 }
1399 break;
1400 case SFX_STYLE_FAMILY_PARA:
1401 {
1402 nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
1403 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ParagraphStyles" ) ) );
1404 // Get the Frame family (and keep it for later)
1405 aAny >>= mxStyleFamily;
1406 aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1407 aAny >>= mxStyleData;
1408 }
1409 break;
1410 case SFX_STYLE_FAMILY_PAGE:
1411 {
1412 nMapId = PROPERTY_MAP_PAGE_STYLE;
1413 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "PageStyles" ) ) );
1414 // Get the Frame family (and keep it for later)
1415 aAny >>= mxStyleFamily;
1416 aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1417 aAny >>= mxStyleData;
1418 }
1419 break;
1420 case SFX_STYLE_FAMILY_FRAME :
1421 {
1422 nMapId = PROPERTY_MAP_FRAME_STYLE;
1423 }
1424 break;
1425 case SFX_STYLE_FAMILY_PSEUDO:
1426 {
1427 nMapId = PROPERTY_MAP_NUM_STYLE;
1428 }
1429 break;
1430
1431 default:
1432 ;
1433 }
1434 pPropImpl = new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap());
1435 }
1436
1437
SwXStyle(SfxStyleSheetBasePool & rPool,SfxStyleFamily eFam,SwDoc * pDoc,const String & rStyleName)1438 SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam,
1439 SwDoc* pDoc, const String& rStyleName) :
1440 m_pDoc(pDoc),
1441 sStyleName(rStyleName),
1442 pBasePool(&rPool),
1443 eFamily(eFam),
1444 bIsDescriptor(sal_False),
1445 bIsConditional(sal_False),
1446 pPropImpl(0)
1447 {
1448 StartListening(rPool);
1449 if(eFam == SFX_STYLE_FAMILY_PARA)
1450 {
1451 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1452 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1453 DBG_ASSERT(pBase, "where is the style?" );
1454 if(pBase)
1455 {
1456 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
1457 if(nId != USHRT_MAX)
1458 bIsConditional = ::IsConditionalByPoolId( nId );
1459 else
1460 bIsConditional = RES_CONDTXTFMTCOLL == ((SwDocStyleSheet*)pBase)->GetCollection()->Which();
1461 }
1462 }
1463 }
1464 /*-- 17.12.98 08:26:50---------------------------------------------------
1465
1466 -----------------------------------------------------------------------*/
~SwXStyle()1467 SwXStyle::~SwXStyle()
1468 {
1469 if(pBasePool)
1470 EndListening(*pBasePool);
1471 delete pPropImpl;
1472 }
1473 /*-- 17.12.98 08:26:51---------------------------------------------------
1474
1475 -----------------------------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)1476 void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
1477 {
1478 ClientModify(this, pOld, pNew);
1479 if(!GetRegisteredIn())
1480 {
1481 m_pDoc = 0;
1482 mxStyleData.clear();
1483 mxStyleFamily.clear();
1484 }
1485 }
getName(void)1486 OUString SwXStyle::getName(void) throw( uno::RuntimeException )
1487 {
1488 vos::OGuard aGuard(Application::GetSolarMutex());
1489 String aString;
1490 if(pBasePool)
1491 {
1492 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1493 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1494 DBG_ASSERT(pBase, "where is the style?" );
1495 if(!pBase)
1496 throw uno::RuntimeException();
1497 SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
1498 }
1499 else
1500 aString = sStyleName;
1501 return OUString (aString);
1502 }
1503 /*-- 17.12.98 08:26:51---------------------------------------------------
1504
1505 -----------------------------------------------------------------------*/
setName(const OUString & rName)1506 void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException )
1507 {
1508 vos::OGuard aGuard(Application::GetSolarMutex());
1509 if(pBasePool)
1510 {
1511 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1512 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1513 DBG_ASSERT(pBase, "where is the style?" );
1514 sal_Bool bExcept = sal_True;
1515 if(pBase && pBase->IsUserDefined())
1516 {
1517 rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
1518 bExcept = !xTmp->SetName(rName);
1519 if(!bExcept)
1520 sStyleName = String(rName);
1521 }
1522 if(bExcept)
1523 throw uno::RuntimeException();
1524 }
1525 else
1526 sStyleName = String(rName);
1527 }
1528 /*-- 17.12.98 08:26:51---------------------------------------------------
1529
1530 -----------------------------------------------------------------------*/
isUserDefined(void)1531 sal_Bool SwXStyle::isUserDefined(void) throw( uno::RuntimeException )
1532 {
1533 vos::OGuard aGuard(Application::GetSolarMutex());
1534 sal_Bool bRet = sal_False;
1535 if(pBasePool)
1536 {
1537 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1538 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1539 //if it is not found it must be non user defined
1540 if(pBase)
1541 bRet = pBase->IsUserDefined();
1542 }
1543 else
1544 throw uno::RuntimeException();
1545 return bRet;
1546 }
1547 /*-- 17.12.98 08:26:51---------------------------------------------------
1548
1549 -----------------------------------------------------------------------*/
isInUse(void)1550 sal_Bool SwXStyle::isInUse(void) throw( uno::RuntimeException )
1551 {
1552 vos::OGuard aGuard(Application::GetSolarMutex());
1553 sal_Bool bRet = sal_False;
1554 if(pBasePool)
1555 {
1556 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_USED);
1557 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1558 if(pBase)
1559 bRet = pBase->IsUsed();
1560 }
1561 else
1562 throw uno::RuntimeException();
1563 return bRet;
1564 }
1565 /*-- 17.12.98 08:26:52---------------------------------------------------
1566
1567 -----------------------------------------------------------------------*/
getParentStyle(void)1568 OUString SwXStyle::getParentStyle(void) throw( uno::RuntimeException )
1569 {
1570 vos::OGuard aGuard(Application::GetSolarMutex());
1571 String aString;
1572 if(pBasePool)
1573 {
1574 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL);
1575 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1576 if(pBase)
1577 aString = pBase->GetParent();
1578 }
1579 else if(bIsDescriptor)
1580 aString = sParentStyleName;
1581 else
1582 throw uno::RuntimeException();
1583 SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1584 return OUString ( aString );
1585 }
1586 /*-- 17.12.98 08:26:52---------------------------------------------------
1587
1588 -----------------------------------------------------------------------*/
setParentStyle(const OUString & rParentStyle)1589 void SwXStyle::setParentStyle(const OUString& rParentStyle)
1590 throw( container::NoSuchElementException, uno::RuntimeException )
1591 {
1592 vos::OGuard aGuard(Application::GetSolarMutex());
1593 String sParentStyle;
1594 SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1595 if(pBasePool)
1596 {
1597 pBasePool->SetSearchMask(eFamily);
1598 sal_Bool bExcept = sal_False;
1599 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1600 if(pBase)
1601 {
1602 rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
1603 //make it a 'real' style - necessary for pooled styles
1604 xBase->GetItemSet();
1605 if(xBase->GetParent() != sParentStyle)
1606 {
1607 bExcept = !xBase->SetParent(sParentStyle);
1608 }
1609 }
1610 else
1611 bExcept = sal_True;
1612 if(bExcept)
1613 throw uno::RuntimeException();
1614 }
1615 else if(bIsDescriptor)
1616 {
1617 sParentStyleName = String(sParentStyle);
1618 try
1619 {
1620 uno::Any aAny = mxStyleFamily->getByName ( sParentStyle );
1621 aAny >>= mxStyleData;
1622 }
1623 catch ( container::NoSuchElementException& )
1624 {
1625 }
1626 catch ( lang::WrappedTargetException& )
1627 {
1628 }
1629 catch ( uno::RuntimeException& )
1630 {
1631 }
1632 }
1633 else
1634 throw uno::RuntimeException();
1635 }
1636 /*-- 17.12.98 08:26:52---------------------------------------------------
1637
1638 -----------------------------------------------------------------------*/
1639
lcl_getPropertySetInfo(SfxStyleFamily eFamily,sal_Bool bIsConditional)1640 uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, sal_Bool bIsConditional )
1641 {
1642 uno::Reference< beans::XPropertySetInfo > xRet;
1643 switch( eFamily )
1644 {
1645 case SFX_STYLE_FAMILY_CHAR:
1646 {
1647 static uno::Reference< beans::XPropertySetInfo > xCharRef;
1648 if(!xCharRef.is())
1649 {
1650 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_STYLE)->getPropertySetInfo();
1651 }
1652 xRet = xCharRef;
1653 }
1654 break;
1655 case SFX_STYLE_FAMILY_PARA:
1656 {
1657 static uno::Reference< beans::XPropertySetInfo > xParaRef;
1658 if(!xParaRef.is())
1659 {
1660 sal_uInt16 nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
1661 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
1662 }
1663 xRet = xParaRef;
1664 }
1665 break;
1666 case SFX_STYLE_FAMILY_PAGE :
1667 {
1668 static uno::Reference< beans::XPropertySetInfo > xPageRef;
1669 if(!xPageRef.is())
1670 {
1671 xPageRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE)->getPropertySetInfo();
1672 }
1673 xRet = xPageRef;
1674 }
1675 break;
1676 case SFX_STYLE_FAMILY_FRAME :
1677 {
1678 static uno::Reference< beans::XPropertySetInfo > xFrameRef;
1679 if(!xFrameRef.is())
1680 {
1681 xFrameRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FRAME_STYLE)->getPropertySetInfo();
1682 }
1683 xRet = xFrameRef;
1684 }
1685 break;
1686 case SFX_STYLE_FAMILY_PSEUDO:
1687 {
1688 static uno::Reference< beans::XPropertySetInfo > xNumRef;
1689 if(!xNumRef.is())
1690 {
1691 xNumRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_NUM_STYLE)->getPropertySetInfo();
1692 }
1693 xRet = xNumRef;
1694 }
1695 break;
1696
1697 default:
1698 ;
1699 }
1700 return xRet;
1701 }
1702
getPropertySetInfo(void)1703 uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo(void)
1704 throw( uno::RuntimeException )
1705 {
1706 return lcl_getPropertySetInfo( eFamily, bIsConditional );
1707 }
1708 /* -----------------23.04.99 13:28-------------------
1709 *
1710 * --------------------------------------------------*/
ApplyDescriptorProperties()1711 void SwXStyle::ApplyDescriptorProperties()
1712 {
1713 bIsDescriptor = sal_False;
1714 mxStyleData.clear();
1715 mxStyleFamily.clear();
1716
1717 const PropertyEntryVector_t& rPropertyVector = pPropImpl->GetPropertyVector();
1718 PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin();
1719 while(aIt != rPropertyVector.end())
1720 {
1721 uno::Any* pAny;
1722 pPropImpl->GetProperty(aIt->sName, pAny);
1723 if(pAny)
1724 setPropertyValue(aIt->sName, *pAny);
1725 ++aIt;
1726 }
1727 }
1728
1729 /*-- 18.04.01 13:07:27---------------------------------------------------
1730
1731 -----------------------------------------------------------------------*/
1732 struct SwStyleBase_Impl
1733 {
1734 SwDoc& rDoc;
1735
1736 const SwPageDesc* pOldPageDesc;
1737
1738 rtl::Reference< SwDocStyleSheet > mxNewBase;
1739 SfxItemSet* pItemSet;
1740
1741 const String& rStyleName;
1742 sal_uInt16 nPDescPos;
1743
SwStyleBase_ImplSwStyleBase_Impl1744 SwStyleBase_Impl(SwDoc& rSwDoc, const String& rName) :
1745 rDoc(rSwDoc),
1746 pOldPageDesc(0),
1747 pItemSet(0),
1748 rStyleName(rName),
1749 nPDescPos(0xffff)
1750 {}
1751
~SwStyleBase_ImplSwStyleBase_Impl1752 ~SwStyleBase_Impl(){ delete pItemSet; }
1753
HasItemSetSwStyleBase_Impl1754 sal_Bool HasItemSet() {return mxNewBase.is();}
GetItemSetSwStyleBase_Impl1755 SfxItemSet& GetItemSet()
1756 {
1757 DBG_ASSERT(mxNewBase.is(), "no SwDocStyleSheet available");
1758 if(!pItemSet)
1759 pItemSet = new SfxItemSet(mxNewBase->GetItemSet());
1760 return *pItemSet;
1761 }
1762
1763 const SwPageDesc& GetOldPageDesc();
1764 };
1765 /* -----------------------------25.04.01 12:44--------------------------------
1766
1767 ---------------------------------------------------------------------------*/
GetOldPageDesc()1768 const SwPageDesc& SwStyleBase_Impl::GetOldPageDesc()
1769 {
1770 if(!pOldPageDesc)
1771 {
1772 sal_uInt16 i;
1773 sal_uInt16 nPDescCount = rDoc.GetPageDescCnt();
1774 for(i = 0; i < nPDescCount; i++)
1775 {
1776 const SwPageDesc& rDesc =
1777 const_cast<const SwDoc &>(rDoc).GetPageDesc( i );
1778 if(rDesc.GetName() == rStyleName)
1779 {
1780 pOldPageDesc = & rDesc;
1781 nPDescPos = i;
1782 break;
1783 }
1784 }
1785 if(!pOldPageDesc)
1786 {
1787 for(i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i)
1788 {
1789 const String aFmtName(SW_RES(i));
1790 if(aFmtName == rStyleName)
1791 {
1792 pOldPageDesc = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) );
1793 break;
1794 }
1795 }
1796 for(i = 0; i < nPDescCount + 1; i++)
1797 {
1798 const SwPageDesc& rDesc =
1799 const_cast<const SwDoc &>(rDoc).GetPageDesc( i );
1800 if(rDesc.GetName() == rStyleName)
1801 {
1802 nPDescPos = i;
1803 break;
1804 }
1805 }
1806 }
1807 }
1808 return *pOldPageDesc;
1809 }
1810
1811 /* -----------------------------19.04.01 09:44--------------------------------
1812
1813 ---------------------------------------------------------------------------*/
1814
lcl_SetStyleProperty(const SfxItemPropertySimpleEntry & rEntry,const SfxItemPropertySet & rPropSet,const uno::Any & rValue,SwStyleBase_Impl & rBase,SfxStyleSheetBasePool * pBasePool,SwDoc * pDoc,SfxStyleFamily eFamily)1815 void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
1816 const SfxItemPropertySet& rPropSet,
1817 const uno::Any& rValue,
1818 SwStyleBase_Impl& rBase,
1819 SfxStyleSheetBasePool* pBasePool,
1820 SwDoc* pDoc,
1821 SfxStyleFamily eFamily)
1822 throw(beans::PropertyVetoException, lang::IllegalArgumentException,
1823 lang::WrappedTargetException, uno::RuntimeException)
1824
1825 {
1826 switch(rEntry.nWID)
1827 {
1828 case RES_PAPER_BIN:
1829 {
1830 SfxPrinter *pPrinter = pDoc->getPrinter( true );
1831 OUString sTmp;
1832 sal_uInt16 nBin = USHRT_MAX;
1833 if ( !( rValue >>= sTmp ) )
1834 throw lang::IllegalArgumentException();
1835 if ( sTmp.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "[From printer settings]" ) ) )
1836 nBin = USHRT_MAX-1;
1837 else if ( pPrinter )
1838 {
1839 for (sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; i++ )
1840 {
1841 if (sTmp == OUString ( pPrinter->GetPaperBinName ( i ) ) )
1842 {
1843 nBin = i;
1844 break;
1845 }
1846 }
1847 }
1848 if ( nBin == USHRT_MAX )
1849 throw lang::IllegalArgumentException();
1850 else
1851 {
1852 SfxItemSet& rStyleSet = rBase.GetItemSet();
1853 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
1854 aSet.SetParent(&rStyleSet);
1855 rPropSet.setPropertyValue(rEntry, uno::makeAny ( static_cast < sal_Int8 > ( nBin == USHRT_MAX-1 ? -1 : nBin ) ), aSet);
1856 rStyleSet.Put(aSet);
1857 }
1858 }
1859 break;
1860 case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem:
1861 {
1862 if(rValue.getValueType() == ::getCppuType((uno::Reference< container::XIndexReplace>*)0) )
1863 {
1864 uno::Reference< container::XIndexReplace > * pxRulesRef =
1865 (uno::Reference< container::XIndexReplace > *)rValue.getValue();
1866
1867 uno::Reference<lang::XUnoTunnel> xNumberTunnel( *pxRulesRef, uno::UNO_QUERY);
1868
1869 SwXNumberingRules* pSwXRules = 0;
1870 if(xNumberTunnel.is())
1871 {
1872 pSwXRules = reinterpret_cast< SwXNumberingRules * >(
1873 sal::static_int_cast< sal_IntPtr >(xNumberTunnel->getSomething( SwXNumberingRules::getUnoTunnelId()) ));
1874 }
1875 if(pSwXRules)
1876 {
1877 const String* pCharStyleNames = pSwXRules->GetNewCharStyleNames();
1878 const String* pBulletFontNames = pSwXRules->GetBulletFontNames();
1879
1880 SwNumRule aSetRule(*pSwXRules->GetNumRule());
1881 const SwCharFmts* pFmts = pDoc->GetCharFmts();
1882 sal_uInt16 nChCount = pFmts->Count();
1883 for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1884 {
1885
1886 const SwNumFmt* pFmt = aSetRule.GetNumFmt( i );
1887 if(pFmt)
1888 {
1889 SwNumFmt aFmt(*pFmt);
1890 if(
1891 pCharStyleNames[i] != SwXNumberingRules::GetInvalidStyle() &&
1892 ((pCharStyleNames[i].Len() && !pFmt->GetCharFmt()) ||
1893 (pCharStyleNames[i].Len() &&
1894 pFmt->GetCharFmt()->GetName() != pCharStyleNames[i]) ))
1895 {
1896
1897 SwCharFmt* pCharFmt = 0;
1898 if(pCharStyleNames[i].Len())
1899 {
1900 for(sal_uInt16 j = 0; j< nChCount; j++)
1901 {
1902 SwCharFmt* pTmp = (*pFmts)[j];
1903 if(pTmp->GetName() == pCharStyleNames[i])
1904 {
1905 pCharFmt = pTmp;
1906 break;
1907 }
1908 }
1909 if(!pCharFmt)
1910 {
1911
1912 SfxStyleSheetBase* pBase;
1913 pBase = ((SfxStyleSheetBasePool*)pBasePool)->Find(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
1914 if(!pBase)
1915 pBase = &pBasePool->Make(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
1916 pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
1917
1918 }
1919
1920 aFmt.SetCharFmt( pCharFmt );
1921 }
1922 }
1923 //jetzt nochmal fuer Fonts
1924 if(pBulletFontNames[i] != SwXNumberingRules::GetInvalidStyle() &&
1925 ((pBulletFontNames[i].Len() && !pFmt->GetBulletFont()) ||
1926 (pBulletFontNames[i].Len() &&
1927 pFmt->GetBulletFont()->GetName() != pBulletFontNames[i]) ))
1928 {
1929 const SvxFontListItem* pFontListItem =
1930 (const SvxFontListItem* )pDoc->GetDocShell()
1931 ->GetItem( SID_ATTR_CHAR_FONTLIST );
1932 const FontList* pList = pFontListItem->GetFontList();
1933 FontInfo aInfo = pList->Get(
1934 pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE);
1935 Font aFont(aInfo);
1936 aFmt.SetBulletFont(&aFont);
1937 }
1938 aSetRule.Set( i, &aFmt );
1939 }
1940 }
1941 rBase.mxNewBase->SetNumRule(aSetRule);
1942 }
1943 }
1944 else
1945 throw lang::IllegalArgumentException();
1946 }
1947 break;
1948
1949 case RES_PARATR_OUTLINELEVEL:
1950 {
1951 sal_Int16 nLevel = 0;
1952 rValue >>= nLevel;
1953 if( 0 <= nLevel && nLevel <= MAXLEVEL)
1954 rBase.mxNewBase->GetCollection()->SetAttrOutlineLevel( nLevel );
1955 }
1956 break;
1957
1958 case FN_UNO_FOLLOW_STYLE:
1959 {
1960 OUString sTmp;
1961 rValue >>= sTmp;
1962 String aString;
1963 SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ) ;
1964 rBase.mxNewBase->SetFollow( aString );
1965 }
1966 break;
1967 case RES_PAGEDESC :
1968 if( MID_PAGEDESC_PAGEDESCNAME != rEntry.nMemberId)
1969 goto put_itemset;
1970 {
1971 // Sonderbehandlung RES_PAGEDESC
1972 if(rValue.getValueType() != ::getCppuType((const OUString*)0))
1973 throw lang::IllegalArgumentException();
1974 SfxItemSet& rStyleSet = rBase.GetItemSet();
1975
1976 SwFmtPageDesc* pNewDesc = 0;
1977 const SfxPoolItem* pItem;
1978 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
1979 {
1980 pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem));
1981 }
1982 if(!pNewDesc)
1983 pNewDesc = new SwFmtPageDesc();
1984 OUString uDescName;
1985 rValue >>= uDescName;
1986 String sDescName;
1987 SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
1988 if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName)
1989 {
1990 //sal_uInt16 nCount = pDoc->GetPageDescCnt();
1991 sal_Bool bPut = sal_False;
1992 if(sDescName.Len())
1993 {
1994 SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName);
1995 if(pPageDesc)
1996 {
1997 pNewDesc->RegisterToPageDesc( *pPageDesc );
1998 bPut = sal_True;
1999 }
2000 else
2001 {
2002 throw lang::IllegalArgumentException();
2003 }
2004 }
2005 if(!bPut)
2006 {
2007 rStyleSet.ClearItem(RES_BREAK);
2008 rStyleSet.Put(SwFmtPageDesc());
2009 }
2010 else
2011 rStyleSet.Put(*pNewDesc);
2012 }
2013 delete pNewDesc;
2014 }
2015 break;
2016 case FN_UNO_IS_AUTO_UPDATE:
2017 {
2018 sal_Bool bAuto = *(sal_Bool*)rValue.getValue();
2019 if(SFX_STYLE_FAMILY_PARA == eFamily)
2020 rBase.mxNewBase->GetCollection()->SetAutoUpdateFmt(bAuto);
2021 else if(SFX_STYLE_FAMILY_FRAME == eFamily)
2022 rBase.mxNewBase->GetFrmFmt()->SetAutoUpdateFmt(bAuto);
2023 }
2024 break;
2025 case FN_UNO_PARA_STYLE_CONDITIONS:
2026 {
2027 uno::Sequence< beans::NamedValue > aSeq;
2028 if (!(rValue >>= aSeq))
2029 throw lang::IllegalArgumentException();
2030
2031 DBG_ASSERT(COND_COMMAND_COUNT == 28,
2032 "invalid size of comman count?");
2033 const beans::NamedValue *pSeq = aSeq.getConstArray();
2034 sal_Int32 nLen = aSeq.getLength();
2035
2036 sal_Bool bFailed = sal_False;
2037 SwCondCollItem aCondItem;
2038 for(sal_uInt16 i = 0; i < nLen; i++)
2039 {
2040 OUString aTmp;
2041 if ((pSeq[i].Value >>= aTmp))
2042 {
2043 // get UI style name from programmatic style name
2044 String aStyleName;
2045 SwStyleNameMapper::FillUIName( aTmp, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
2046
2047 //
2048 // check for correct context and style name
2049 //
2050 sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name );
2051 //
2052 pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
2053 sal_Bool bStyleFound = sal_False;
2054 const SfxStyleSheetBase* pBase = pBasePool->First();
2055 while (pBase && !bStyleFound)
2056 {
2057 if(pBase->GetName() == aStyleName)
2058 bStyleFound = sal_True;
2059 pBase = pBasePool->Next();
2060 }
2061 //
2062 if (nIdx == -1 || !bStyleFound)
2063 {
2064 bFailed = sal_True;
2065 break;
2066 }
2067
2068 aCondItem.SetStyle( &aStyleName, nIdx);
2069 }
2070 else
2071 bFailed = sal_True;
2072 }
2073 if (bFailed)
2074 throw lang::IllegalArgumentException();
2075 rBase.GetItemSet().Put( aCondItem );
2076 }
2077 break;
2078 case FN_UNO_CATEGORY:
2079 {
2080 if(!rBase.mxNewBase->IsUserDefined())
2081 throw lang::IllegalArgumentException();
2082 short nSet = 0;
2083 rValue >>= nSet;
2084
2085 sal_uInt16 nId;
2086 switch( nSet )
2087 {
2088 case style::ParagraphStyleCategory::TEXT:
2089 nId = SWSTYLEBIT_TEXT;
2090 break;
2091 case style::ParagraphStyleCategory::CHAPTER:
2092 nId = SWSTYLEBIT_CHAPTER;
2093 break;
2094 case style::ParagraphStyleCategory::LIST:
2095 nId = SWSTYLEBIT_LIST;
2096 break;
2097 case style::ParagraphStyleCategory::INDEX:
2098 nId = SWSTYLEBIT_IDX;
2099 break;
2100 case style::ParagraphStyleCategory::EXTRA:
2101 nId = SWSTYLEBIT_EXTRA;
2102 break;
2103 case style::ParagraphStyleCategory::HTML:
2104 nId = SWSTYLEBIT_HTML;
2105 break;
2106 default: throw lang::IllegalArgumentException();
2107 }
2108 rBase.mxNewBase->SetMask( nId|SFXSTYLEBIT_USERDEF );
2109 }
2110 break;
2111 case SID_SWREGISTER_COLLECTION:
2112 {
2113 OUString sName;
2114 rValue >>= sName;
2115 SwRegisterItem aReg( sName.getLength() != 0);
2116 aReg.SetWhich(SID_SWREGISTER_MODE);
2117 rBase.GetItemSet().Put(aReg);
2118 String aString;
2119 SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
2120
2121 rBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
2122 }
2123 break;
2124 case RES_TXTATR_CJK_RUBY:
2125 if(MID_RUBY_CHARSTYLE == rEntry.nMemberId )
2126 {
2127 OUString sTmp;
2128 if(rValue >>= sTmp)
2129 {
2130 SfxItemSet& rStyleSet = rBase.GetItemSet();
2131 SwFmtRuby* pRuby = 0;
2132 const SfxPoolItem* pItem;
2133 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) )
2134 pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem));
2135 if(!pRuby)
2136 pRuby = new SwFmtRuby(aEmptyStr);
2137 String sStyle;
2138 SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
2139 pRuby->SetCharFmtName( sTmp );
2140 pRuby->SetCharFmtId( 0 );
2141 if(sTmp.getLength())
2142 {
2143 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
2144 pRuby->SetCharFmtId(nId);
2145 }
2146 rStyleSet.Put(*pRuby);
2147 delete pRuby;
2148 }
2149 else
2150 throw lang::IllegalArgumentException();
2151 }
2152 goto put_itemset;
2153 //break;
2154 case RES_PARATR_DROP:
2155 {
2156 if( MID_DROPCAP_CHAR_STYLE_NAME == rEntry.nMemberId)
2157 {
2158 if(rValue.getValueType() == ::getCppuType((const OUString*)0))
2159 {
2160 SfxItemSet& rStyleSet = rBase.GetItemSet();
2161
2162 SwFmtDrop* pDrop = 0;
2163 const SfxPoolItem* pItem;
2164 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) )
2165 pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem));
2166 if(!pDrop)
2167 pDrop = new SwFmtDrop();
2168 OUString uStyle;
2169 rValue >>= uStyle;
2170 String sStyle;
2171 SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
2172 SwDocStyleSheet* pStyle =
2173 (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR);
2174 if(pStyle)
2175 pDrop->SetCharFmt(pStyle->GetCharFmt());
2176 else
2177 throw lang::IllegalArgumentException();
2178 rStyleSet.Put(*pDrop);
2179 delete pDrop;
2180 }
2181 else
2182 throw lang::IllegalArgumentException();
2183 break;
2184 }
2185 }
2186 //no break!
2187 default:
2188 put_itemset:
2189 {
2190 SfxItemSet& rStyleSet = rBase.GetItemSet();
2191 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
2192 aSet.SetParent(&rStyleSet);
2193 rPropSet.setPropertyValue(rEntry, rValue, aSet);
2194 rStyleSet.Put(aSet);
2195 // --> OD 2006-10-18 #i70223#
2196 if ( SFX_STYLE_FAMILY_PARA == eFamily &&
2197 rEntry.nWID == RES_PARATR_NUMRULE &&
2198 rBase.mxNewBase.is() && rBase.mxNewBase->GetCollection() &&
2199 //rBase.mxNewBase->GetCollection()->GetOutlineLevel() < MAXLEVEL /* assigned to list level of outline style */) //#outline level,removed by zhaojianwei
2200 rBase.mxNewBase->GetCollection()->IsAssignedToListLevelOfOutlineStyle() ) ////<-end,add by zhaojianwei
2201
2202 {
2203 OUString sNewNumberingRuleName;
2204 rValue >>= sNewNumberingRuleName;
2205 String sTmp( sNewNumberingRuleName );
2206 if ( sNewNumberingRuleName.getLength() == 0 ||
2207 sTmp != pDoc->GetOutlineNumRule()->GetName() )
2208 {
2209 // delete assignment to list level of outline style.
2210 //rBase.mxNewBase->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei
2211 rBase.mxNewBase->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,adde by zhaojianwei
2212 }
2213 }
2214 }
2215 }
2216 }
2217 /* -----------------------------18.04.01 13:29--------------------------------
2218
2219 ---------------------------------------------------------------------------*/
SetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)2220 void SAL_CALL SwXStyle::SetPropertyValues_Impl(
2221 const uno::Sequence< OUString >& rPropertyNames,
2222 const uno::Sequence< uno::Any >& rValues )
2223 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
2224 lang::WrappedTargetException, uno::RuntimeException)
2225 {
2226 if ( !m_pDoc )
2227 throw uno::RuntimeException();
2228 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2229 switch(eFamily)
2230 {
2231 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2232 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2233 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break;
2234 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2235 default:
2236 ;
2237 }
2238 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2239 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2240
2241 if(rPropertyNames.getLength() != rValues.getLength())
2242 throw lang::IllegalArgumentException();
2243
2244 const OUString* pNames = rPropertyNames.getConstArray();
2245 const uno::Any* pValues = rValues.getConstArray();
2246
2247 SwStyleBase_Impl aBaseImpl(*m_pDoc, sStyleName);
2248 if(pBasePool)
2249 {
2250 sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2251 pBasePool->SetSearchMask(eFamily);
2252 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2253 pBasePool->SetSearchMask(eFamily, nSaveMask );
2254 DBG_ASSERT(pBase, "where is the style?" );
2255 if(pBase)
2256 aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase);
2257 else
2258 throw uno::RuntimeException();
2259 }
2260
2261 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2262 {
2263 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]);
2264
2265 if(!pEntry ||
2266 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS))))
2267 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2268 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2269 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2270 if(aBaseImpl.mxNewBase.is())
2271 {
2272 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl,
2273 pBasePool, m_pDoc, eFamily);
2274 }
2275 else if(bIsDescriptor)
2276 {
2277 if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp]))
2278 throw lang::IllegalArgumentException();
2279 }
2280 else
2281 throw uno::RuntimeException();
2282 }
2283 if(aBaseImpl.HasItemSet())
2284 aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet());
2285 }
2286
setPropertyValues(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)2287 void SwXStyle::setPropertyValues(
2288 const uno::Sequence< OUString >& rPropertyNames,
2289 const uno::Sequence< uno::Any >& rValues )
2290 throw(beans::PropertyVetoException, lang::IllegalArgumentException,
2291 lang::WrappedTargetException, uno::RuntimeException)
2292 {
2293 vos::OGuard aGuard(Application::GetSolarMutex());
2294
2295 // workaround for bad designed API
2296 try
2297 {
2298 SetPropertyValues_Impl( rPropertyNames, rValues );
2299 }
2300 catch (beans::UnknownPropertyException &rException)
2301 {
2302 // wrap the original (here not allowed) exception in
2303 // a lang::WrappedTargetException that gets thrown instead.
2304 lang::WrappedTargetException aWExc;
2305 aWExc.TargetException <<= rException;
2306 throw aWExc;
2307 }
2308 }
2309
2310
lcl_GetStyleProperty(const SfxItemPropertySimpleEntry & rEntry,const SfxItemPropertySet & rPropSet,SwStyleBase_Impl & rBase,SfxStyleSheetBase * pBase,SfxStyleFamily eFamily,SwDoc * pDoc)2311 uno::Any lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
2312 const SfxItemPropertySet& rPropSet,
2313 SwStyleBase_Impl& rBase,
2314 SfxStyleSheetBase* pBase,
2315 SfxStyleFamily eFamily,
2316 SwDoc *pDoc) throw(uno::RuntimeException)
2317 {
2318 uno::Any aRet;
2319 if(FN_UNO_IS_PHYSICAL == rEntry.nWID)
2320 {
2321 sal_Bool bPhys = pBase != 0;
2322 if(pBase)
2323 {
2324 bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical();
2325 // The standard character format is not existing physically
2326 if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily &&
2327 ((SwDocStyleSheet*)pBase)->GetCharFmt() &&
2328 ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() )
2329 bPhys = sal_False;
2330 }
2331 aRet.setValue(&bPhys, ::getBooleanCppuType());
2332 }
2333 else if(pBase)
2334 {
2335 if(!rBase.mxNewBase.is())
2336 rBase.mxNewBase = new SwDocStyleSheet( *(SwDocStyleSheet*)pBase );
2337 switch(rEntry.nWID)
2338 {
2339 case RES_PAPER_BIN:
2340 {
2341 SfxItemSet& rSet = rBase.GetItemSet();
2342 rPropSet.getPropertyValue(rEntry, rSet, aRet);
2343 sal_Int8 nBin = 0;
2344 aRet >>= nBin;
2345 if ( nBin == -1 )
2346 aRet <<= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "[From printer settings]" ) );
2347 else
2348 {
2349 SfxPrinter *pPrinter = pDoc->getPrinter( false );
2350 OUString sTmp;
2351 if (pPrinter )
2352 sTmp = pPrinter->GetPaperBinName ( nBin );
2353 aRet <<= sTmp;
2354 }
2355 }
2356 break;
2357 case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem:
2358 {
2359 const SwNumRule* pRule = rBase.mxNewBase->GetNumRule();
2360 DBG_ASSERT(pRule, "Wo ist die NumRule?");
2361 uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule);
2362 aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0));
2363 }
2364 break;
2365 //case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei
2366 //{
2367 // DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
2368 // sal_uInt8 nLevel = rBase.mxNewBase->GetCollection()->GetOutlineLevel();
2369 // if( nLevel != NO_NUMBERING )
2370 // aRet <<= static_cast<sal_Int8>( nLevel );
2371 //}
2372 //break;
2373 case RES_PARATR_OUTLINELEVEL: //add by zahojianwei
2374 {
2375 DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
2376 int nLevel = rBase.mxNewBase->GetCollection()->GetAttrOutlineLevel();
2377 aRet <<= static_cast<sal_Int16>( nLevel );
2378 }
2379 break; //<-end,zhaojianwei
2380 case FN_UNO_FOLLOW_STYLE:
2381 {
2382 String aString;
2383 SwStyleNameMapper::FillProgName(rBase.mxNewBase->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
2384 aRet <<= OUString( aString );
2385 }
2386 break;
2387 case RES_PAGEDESC :
2388 if( MID_PAGEDESC_PAGEDESCNAME != rEntry.nMemberId)
2389 goto query_itemset;
2390 {
2391 // Sonderbehandlung RES_PAGEDESC
2392 const SfxPoolItem* pItem;
2393 if(SFX_ITEM_SET == rBase.GetItemSet().GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
2394 {
2395 const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc();
2396 if(pDesc)
2397 {
2398 String aString;
2399 SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
2400 aRet <<= OUString( aString );
2401 }
2402 }
2403 }
2404 break;
2405 case FN_UNO_IS_AUTO_UPDATE:
2406 {
2407 sal_Bool bAuto = sal_False;
2408 if(SFX_STYLE_FAMILY_PARA == eFamily)
2409 bAuto = rBase.mxNewBase->GetCollection()->IsAutoUpdateFmt();
2410 else if(SFX_STYLE_FAMILY_FRAME == eFamily)
2411 bAuto = rBase.mxNewBase->GetFrmFmt()->IsAutoUpdateFmt();
2412 aRet.setValue(&bAuto, ::getBooleanCppuType());
2413 }
2414 break;
2415 case FN_UNO_DISPLAY_NAME:
2416 {
2417 OUString sName(rBase.mxNewBase->GetDisplayName());
2418 aRet <<= sName;
2419 }
2420 break;
2421 case FN_UNO_PARA_STYLE_CONDITIONS:
2422 {
2423 DBG_ASSERT(COND_COMMAND_COUNT == 28,
2424 "invalid size of comman count?");
2425 //SfxItemSet& rStyleSet = rBase.GetItemSet();
2426 uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT);
2427 beans::NamedValue *pSeq = aSeq.getArray();
2428
2429 SwFmt *pFmt = ((SwDocStyleSheet*)pBase)->GetCollection();
2430 const CommandStruct *pCmds = SwCondCollItem::GetCmds();
2431 for (sal_uInt16 n = 0; n < COND_COMMAND_COUNT; ++n)
2432 {
2433 String aStyleName;
2434
2435 const SwCollCondition* pCond = 0;
2436 if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() &&
2437 0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)->
2438 HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) )
2439 && pCond->GetTxtFmtColl() )
2440 {
2441 // get programmatic style name from UI style name
2442 aStyleName = pCond->GetTxtFmtColl()->GetName();
2443 SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
2444 }
2445
2446 pSeq[n].Name = GetCommandContextByIndex(n);
2447 pSeq[n].Value <<= rtl::OUString( aStyleName );
2448 }
2449 aRet <<= aSeq;
2450 }
2451 break;
2452 case FN_UNO_CATEGORY:
2453 {
2454 sal_uInt16 nPoolId = rBase.mxNewBase->GetCollection()->GetPoolFmtId();
2455 short nRet = -1;
2456 switch ( COLL_GET_RANGE_BITS & nPoolId )
2457 {
2458 case COLL_TEXT_BITS:
2459 nRet = style::ParagraphStyleCategory::TEXT;
2460 break;
2461 case COLL_DOC_BITS:
2462 nRet = style::ParagraphStyleCategory::CHAPTER;
2463 break;
2464 case COLL_LISTS_BITS:
2465 nRet = style::ParagraphStyleCategory::LIST;
2466 break;
2467 case COLL_REGISTER_BITS:
2468 nRet = style::ParagraphStyleCategory::INDEX;
2469 break;
2470 case COLL_EXTRA_BITS:
2471 nRet = style::ParagraphStyleCategory::EXTRA;
2472 break;
2473 case COLL_HTML_BITS:
2474 nRet = style::ParagraphStyleCategory::HTML;
2475 break;
2476 }
2477 aRet <<= nRet;
2478 }
2479 break;
2480 case SID_SWREGISTER_COLLECTION:
2481 {
2482 const SwPageDesc *pPageDesc = rBase.mxNewBase->GetPageDesc();
2483 const SwTxtFmtColl* pCol = 0;
2484 String aString;
2485 if( pPageDesc )
2486 pCol = pPageDesc->GetRegisterFmtColl();
2487 if( pCol )
2488 SwStyleNameMapper::FillProgName(
2489 pCol->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
2490 aRet <<= OUString ( aString );
2491 }
2492 break;
2493 default:
2494 query_itemset:
2495 {
2496 SfxItemSet& rSet = rBase.GetItemSet();
2497 rPropSet.getPropertyValue(rEntry, rSet, aRet);
2498 }
2499 }
2500 }
2501 else
2502 throw uno::RuntimeException();
2503 return aRet;
2504 }
2505 /* -----------------------------19.04.01 09:26--------------------------------
2506
2507 ---------------------------------------------------------------------------*/
GetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames)2508 uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl(
2509 const uno::Sequence< OUString > & rPropertyNames )
2510 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2511 {
2512 if ( !m_pDoc )
2513 throw uno::RuntimeException();
2514 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2515 switch(eFamily)
2516 {
2517 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2518 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2519 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break;
2520 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2521 default:
2522 ;
2523 }
2524 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2525 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2526
2527 const OUString* pNames = rPropertyNames.getConstArray();
2528 uno::Sequence< uno::Any > aRet(rPropertyNames.getLength());
2529 uno::Any* pRet = aRet.getArray();
2530 SwStyleBase_Impl aBase(*m_pDoc, sStyleName);
2531 SfxStyleSheetBase* pBase = 0;
2532 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2533 {
2534 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]);
2535 if(!pEntry ||
2536 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS))))
2537 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2538 if(pBasePool)
2539 {
2540 if(!pBase)
2541 {
2542 sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2543 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
2544 pBase = pBasePool->Find(sStyleName);
2545 pBasePool->SetSearchMask(eFamily, nSaveMask );
2546 }
2547 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, eFamily, GetDoc() );
2548 }
2549 else if(bIsDescriptor)
2550 {
2551 uno::Any *pAny = 0;
2552 pPropImpl->GetProperty ( pNames[nProp], pAny );
2553 if( !pAny )
2554 {
2555 sal_Bool bExcept = sal_False;
2556 switch( eFamily )
2557 {
2558 case SFX_STYLE_FAMILY_PSEUDO:
2559 bExcept = sal_True;
2560 break;
2561 case SFX_STYLE_FAMILY_PARA:
2562 case SFX_STYLE_FAMILY_PAGE:
2563 pPropImpl->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] );
2564 break;
2565 case SFX_STYLE_FAMILY_CHAR:
2566 case SFX_STYLE_FAMILY_FRAME :
2567 {
2568 if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END )
2569 {
2570 SwFmt * pFmt;
2571 if ( eFamily == SFX_STYLE_FAMILY_CHAR )
2572 pFmt = m_pDoc->GetDfltCharFmt();
2573 else
2574 pFmt = m_pDoc->GetDfltFrmFmt();
2575 const SwAttrPool * pPool = pFmt->GetAttrSet().GetPool();
2576 const SfxPoolItem & rItem = pPool->GetDefaultItem ( pEntry->nWID );
2577 rItem.QueryValue ( pRet[nProp], pEntry->nMemberId );
2578 }
2579 else
2580 bExcept = sal_True;
2581 }
2582 break;
2583
2584 default:
2585 ;
2586 }
2587 if (bExcept )
2588 {
2589 uno::RuntimeException aExcept;
2590 aExcept.Message = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "No default value for: " ) ) + pNames[nProp];
2591 throw aExcept;
2592 }
2593 }
2594 else
2595 pRet [ nProp ] = *pAny;
2596 }
2597 else
2598 throw uno::RuntimeException();
2599 }
2600 return aRet;
2601 }
2602 /* -----------------------------04.11.03 09:26--------------------------------
2603
2604 ---------------------------------------------------------------------------*/
getPropertyValues(const uno::Sequence<OUString> & rPropertyNames)2605 uno::Sequence< uno::Any > SwXStyle::getPropertyValues(
2606 const uno::Sequence< OUString >& rPropertyNames ) throw(uno::RuntimeException)
2607 {
2608 vos::OGuard aGuard(Application::GetSolarMutex());
2609 uno::Sequence< uno::Any > aValues;
2610
2611 // workaround for bad designed API
2612 try
2613 {
2614 aValues = GetPropertyValues_Impl( rPropertyNames );
2615 }
2616 catch (beans::UnknownPropertyException &)
2617 {
2618 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2619 }
2620 catch (lang::WrappedTargetException &)
2621 {
2622 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2623 }
2624
2625 return aValues;
2626 }
2627 /*-- 18.04.01 13:07:29---------------------------------------------------
2628 -----------------------------------------------------------------------*/
addPropertiesChangeListener(const uno::Sequence<OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)2629 void SwXStyle::addPropertiesChangeListener(
2630 const uno::Sequence< OUString >& /*aPropertyNames*/,
2631 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2632 throw(uno::RuntimeException)
2633 {
2634 }
2635 /*-- 18.04.01 13:07:30---------------------------------------------------
2636
2637 -----------------------------------------------------------------------*/
removePropertiesChangeListener(const uno::Reference<beans::XPropertiesChangeListener> &)2638 void SwXStyle::removePropertiesChangeListener(
2639 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2640 throw(uno::RuntimeException)
2641 {
2642 }
2643 /*-- 18.04.01 13:07:30---------------------------------------------------
2644
2645 -----------------------------------------------------------------------*/
firePropertiesChangeEvent(const uno::Sequence<OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)2646 void SwXStyle::firePropertiesChangeEvent(
2647 const uno::Sequence< OUString >& /*aPropertyNames*/,
2648 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2649 throw(uno::RuntimeException)
2650 {
2651 }
2652 /*-- 17.12.98 08:26:53---------------------------------------------------
2653
2654 -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const uno::Any & rValue)2655 void SwXStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue)
2656 throw( beans::UnknownPropertyException,
2657 beans::PropertyVetoException,
2658 lang::IllegalArgumentException,
2659 lang::WrappedTargetException,
2660 uno::RuntimeException)
2661 {
2662 vos::OGuard aGuard(Application::GetSolarMutex());
2663 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2664 const uno::Sequence<uno::Any> aValues(&rValue, 1);
2665 SetPropertyValues_Impl( aProperties, aValues );
2666 }
2667 /*-- 17.12.98 08:26:53---------------------------------------------------
2668
2669 -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)2670 uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName)
2671 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2672 {
2673 vos::OGuard aGuard(Application::GetSolarMutex());
2674 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2675 return GetPropertyValues_Impl(aProperties).getConstArray()[0];
2676
2677 }
2678 /*-- 17.12.98 08:26:53---------------------------------------------------
2679
2680 -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)2681 void SwXStyle::addPropertyChangeListener(const OUString& /*rPropertyName*/,
2682 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2683 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2684 {
2685 DBG_WARNING("not implemented");
2686 }
2687 /*-- 17.12.98 08:26:54---------------------------------------------------
2688
2689 -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)2690 void SwXStyle::removePropertyChangeListener(const OUString& /*rPropertyName*/,
2691 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2692 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2693 {
2694 DBG_WARNING("not implemented");
2695 }
2696 /*-- 17.12.98 08:26:54---------------------------------------------------
2697
2698 -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)2699 void SwXStyle::addVetoableChangeListener(const OUString& /*rPropertyName*/,
2700 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2701 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2702 {
2703 DBG_WARNING("not implemented");
2704 }
2705 /*-- 17.12.98 08:26:54---------------------------------------------------
2706
2707 -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)2708 void SwXStyle::removeVetoableChangeListener(const OUString& /*rPropertyName*/,
2709 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2710 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2711 {
2712 DBG_WARNING("not implemented");
2713 }
2714
2715 /*-- 08.03.99 10:50:26---------------------------------------------------
2716
2717 -----------------------------------------------------------------------*/
getPropertyState(const OUString & rPropertyName)2718 beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName)
2719 throw( beans::UnknownPropertyException, uno::RuntimeException )
2720 {
2721 vos::OGuard aGuard(Application::GetSolarMutex());
2722
2723 uno::Sequence< OUString > aNames(1);
2724 OUString* pNames = aNames.getArray();
2725 pNames[0] = rPropertyName;
2726 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
2727 return aStates.getConstArray()[0];
2728 }
2729 /*-- 08.03.99 10:50:27---------------------------------------------------
2730
2731 -----------------------------------------------------------------------*/
getPropertyStates(const uno::Sequence<OUString> & rPropertyNames)2732 uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates(
2733 const uno::Sequence< OUString >& rPropertyNames)
2734 throw( beans::UnknownPropertyException, uno::RuntimeException )
2735 {
2736 vos::OGuard aGuard(Application::GetSolarMutex());
2737 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
2738 beans::PropertyState* pStates = aRet.getArray();
2739 if(pBasePool)
2740 {
2741 pBasePool->SetSearchMask(eFamily );
2742 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2743 DBG_ASSERT(pBase, "where is the style?" );
2744
2745 if(pBase)
2746 {
2747 const OUString* pNames = rPropertyNames.getConstArray();
2748 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2749 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2750 switch(eFamily)
2751 {
2752 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2753 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2754 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
2755 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2756 default:
2757 ;
2758 }
2759 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2760 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2761
2762 SfxItemSet aSet = xStyle->GetItemSet();
2763 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
2764 {
2765 const String& rPropName = pNames[i];
2766 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName);
2767 if(!pEntry)
2768 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
2769 if( FN_UNO_NUM_RULES == pEntry->nWID ||
2770 FN_UNO_FOLLOW_STYLE == pEntry->nWID )
2771 {
2772 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2773 }
2774 // else if( FN_UNO_DEFAULT_OUTLINE_LEVEL == pEntry->nWID ) //#outline level,removed by zahojianwei
2775 // {
2776 // pStates[i] =
2777 // ( xStyle->GetCollection()->GetOutlineLevel()
2778 // == NO_NUMBERING )
2779 // ? beans::PropertyState_DEFAULT_VALUE
2780 // : beans::PropertyState_DIRECT_VALUE;
2781 // } //<-end,zhaojianwei
2782 else if(SFX_STYLE_FAMILY_PAGE == eFamily &&
2783 (rPropName.EqualsAscii("Header", 0, 6)
2784 || rPropName.EqualsAscii("Footer", 0, 6)))
2785 {
2786 sal_uInt16 nResId = lcl_ConvertFNToRES(pEntry->nWID);
2787 sal_Bool bFooter = rPropName.EqualsAscii("Footer", 0, 6);
2788 const SvxSetItem* pSetItem;
2789 if(SFX_ITEM_SET == aSet.GetItemState(
2790 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
2791 sal_False, (const SfxPoolItem**)&pSetItem))
2792 {
2793 const SfxItemSet& rSet = pSetItem->GetItemSet();
2794 SfxItemState eState = rSet.GetItemState(nResId, sal_False);
2795 if(SFX_ITEM_SET == eState)
2796 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2797 else
2798 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2799 }
2800 else
2801 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
2802 }
2803 else
2804 {
2805 pStates[i] = pPropSet->getPropertyState(*pEntry, aSet);
2806 if( SFX_STYLE_FAMILY_PAGE == eFamily &&
2807 SID_ATTR_PAGE_SIZE == pEntry->nWID &&
2808 beans::PropertyState_DIRECT_VALUE == pStates[i] )
2809 {
2810 const SvxSizeItem& rSize =
2811 static_cast < const SvxSizeItem& >(
2812 aSet.Get(SID_ATTR_PAGE_SIZE) );
2813 sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f;
2814 if( ( LONG_MAX == rSize.GetSize().Width() &&
2815 (MID_SIZE_WIDTH == nMemberId ||
2816 MID_SIZE_SIZE == nMemberId ) ) ||
2817 ( LONG_MAX == rSize.GetSize().Height() &&
2818 MID_SIZE_HEIGHT == nMemberId ) )
2819 {
2820 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2821 }
2822 }
2823 }
2824 }
2825 }
2826 else
2827 throw uno::RuntimeException();
2828 }
2829 else
2830 throw uno::RuntimeException();
2831 return aRet;
2832 }
2833 /*-- 08.03.99 10:50:27---------------------------------------------------
2834
2835 -----------------------------------------------------------------------*/
setPropertyToDefault(const OUString & rPropertyName)2836 void SwXStyle::setPropertyToDefault(const OUString& rPropertyName)
2837 throw( beans::UnknownPropertyException, uno::RuntimeException )
2838 {
2839 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2840 setPropertiesToDefault ( aSequence );
2841 }
2842
setPropertiesToDefault(const uno::Sequence<OUString> & aPropertyNames)2843 void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
2844 throw (beans::UnknownPropertyException, uno::RuntimeException)
2845 {
2846 vos::OGuard aGuard(Application::GetSolarMutex());
2847 SwFmt *pTargetFmt = 0;
2848
2849 if(pBasePool)
2850 {
2851 pBasePool->SetSearchMask(eFamily);
2852 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2853 DBG_ASSERT(pBase, "Where is the style?");
2854
2855 if(pBase)
2856 {
2857 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2858 switch(eFamily)
2859 {
2860 case SFX_STYLE_FAMILY_CHAR: pTargetFmt = xStyle->GetCharFmt(); break;
2861 case SFX_STYLE_FAMILY_PARA: pTargetFmt = xStyle->GetCollection(); break;
2862 case SFX_STYLE_FAMILY_FRAME: pTargetFmt = xStyle->GetFrmFmt(); break;
2863 case SFX_STYLE_FAMILY_PAGE:
2864 {
2865 sal_uInt16 nPgDscPos = USHRT_MAX;
2866 SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos );
2867 if( pDesc )
2868 pTargetFmt = &pDesc->GetMaster();
2869 }
2870 break;
2871 case SFX_STYLE_FAMILY_PSEUDO:
2872 break;
2873 default:
2874 ;
2875 }
2876 }
2877 }
2878 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2879 switch(eFamily)
2880 {
2881 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2882 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
2883 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
2884 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
2885 default:
2886 ;
2887 }
2888 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2889 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2890
2891 const OUString* pNames = aPropertyNames.getConstArray();
2892
2893 if ( pTargetFmt )
2894 {
2895 for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ )
2896 {
2897 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] );
2898 if( !pEntry )
2899 throw beans::UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is unknown: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2900 if ( pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES )
2901 throw uno::RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Cannot reset: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2902 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY )
2903 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertiesToDefault: property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2904
2905 //if( pEntry->nWID == FN_UNO_DEFAULT_OUTLINE_LEVEL ) //#outline level, removed by zhaojianwei
2906 // static_cast<SwTxtFmtColl*>(pTargetFmt)->SetOutlineLevel( NO_NUMBERING );
2907 //else
2908 // pTargetFmt->ResetFmtAttr( pEntry->nWID );
2909 if( pEntry->nWID == RES_PARATR_OUTLINELEVEL ) //add by zhaojianwei
2910 static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle();
2911 else
2912 pTargetFmt->ResetFmtAttr( pEntry->nWID ); //<-end,zhaojianwei
2913 }
2914 }
2915 else if ( bIsDescriptor )
2916 {
2917 for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ )
2918 pPropImpl->ClearProperty ( pNames[ nProp ] );
2919 }
2920 }
2921
setAllPropertiesToDefault()2922 void SAL_CALL SwXStyle::setAllPropertiesToDefault( )
2923 throw (uno::RuntimeException)
2924 {
2925 vos::OGuard aGuard(Application::GetSolarMutex());
2926 if(pBasePool)
2927 {
2928 pBasePool->SetSearchMask(eFamily);
2929 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2930 DBG_ASSERT(pBase, "where is the style, you fiend!?");
2931
2932 if(pBase)
2933 {
2934 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2935
2936 SwFmt *pTargetFmt = 0;
2937 sal_uInt16 nPgDscPos = USHRT_MAX;
2938 switch( eFamily )
2939 {
2940 case SFX_STYLE_FAMILY_CHAR :
2941 pTargetFmt = xStyle->GetCharFmt();
2942 break;
2943 case SFX_STYLE_FAMILY_PARA :
2944 {
2945 pTargetFmt = xStyle->GetCollection();
2946 // --> OD 2007-07-25 #132402# - make code robust
2947 if ( xStyle->GetCollection() )
2948 {
2949 // xStyle->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei
2950 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,add by zhaojianwei
2951 }
2952 // <--
2953 }
2954 break;
2955 case SFX_STYLE_FAMILY_FRAME:
2956 pTargetFmt = xStyle->GetFrmFmt();
2957 break;
2958 case SFX_STYLE_FAMILY_PAGE:
2959 {
2960 SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos );
2961 if( pDesc )
2962 {
2963 pTargetFmt = &pDesc->GetMaster();
2964 pDesc->SetUseOn ( nsUseOnPage::PD_ALL );
2965 }
2966 }
2967 break;
2968 case SFX_STYLE_FAMILY_PSEUDO:
2969 break;
2970
2971 default:
2972 ;
2973 }
2974 if( pTargetFmt )
2975 {
2976 if( USHRT_MAX != nPgDscPos )
2977 {
2978 SwPageDesc& rPageDesc = m_pDoc->_GetPageDesc(nPgDscPos);
2979 rPageDesc.ResetAllMasterAttr();
2980
2981 SvxLRSpaceItem aLR(RES_LR_SPACE);
2982 sal_Int32 nSize = GetMetricVal ( CM_1) * 2;
2983 aLR.SetLeft ( nSize );
2984 aLR.SetLeft ( nSize );
2985 SvxULSpaceItem aUL( RES_UL_SPACE );
2986 aUL.SetUpper ( static_cast < sal_uInt16 > ( nSize ) );
2987 aUL.SetLower ( static_cast < sal_uInt16 > ( nSize ) );
2988 pTargetFmt->SetFmtAttr( aLR );
2989 pTargetFmt->SetFmtAttr( aUL );
2990
2991 SwPageDesc* pStdPgDsc = m_pDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
2992 SwFmtFrmSize aFrmSz( ATT_FIX_SIZE );
2993 if( RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId() )
2994 {
2995 if( m_pDoc->getPrinter( false ) )
2996 {
2997 const Size aPhysSize( SvxPaperInfo::GetPaperSize(
2998 static_cast<Printer*>( m_pDoc->getPrinter( false ) )) );
2999 aFrmSz.SetSize( aPhysSize );
3000 }
3001 else
3002 {
3003 // --> OD 2008-07-25 #i91928#
3004 // aFrmSz.SetWidth( LONG_MAX );
3005 // aFrmSz.SetHeight( LONG_MAX );
3006 aFrmSz.SetSize( SvxPaperInfo::GetDefaultPaperSize() );
3007 // <--
3008 }
3009
3010 }
3011 else
3012 {
3013 aFrmSz = pStdPgDsc->GetMaster().GetFrmSize();
3014 }
3015 if( pStdPgDsc->GetLandscape() )
3016 {
3017 SwTwips nTmp = aFrmSz.GetHeight();
3018 aFrmSz.SetHeight( aFrmSz.GetWidth() );
3019 aFrmSz.SetWidth( nTmp );
3020 }
3021 pTargetFmt->SetFmtAttr( aFrmSz );
3022 }
3023 else
3024 {
3025 // --> OD 2007-01-25 #i73790# - method renamed
3026 pTargetFmt->ResetAllFmtAttr();
3027 // <--
3028 }
3029
3030 if( USHRT_MAX != nPgDscPos )
3031 m_pDoc->ChgPageDesc( nPgDscPos,
3032 const_cast<const SwDoc *>(m_pDoc)
3033 ->GetPageDesc(nPgDscPos) );
3034 }
3035
3036 }
3037 else
3038 throw uno::RuntimeException();
3039 }
3040 else if ( bIsDescriptor )
3041 pPropImpl->ClearAllProperties();
3042 else
3043 throw uno::RuntimeException();
3044 }
3045
getPropertyDefaults(const uno::Sequence<OUString> & aPropertyNames)3046 uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
3047 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
3048 {
3049 vos::OGuard aGuard(Application::GetSolarMutex());
3050 sal_Int32 nCount = aPropertyNames.getLength();
3051 uno::Sequence < uno::Any > aRet ( nCount );
3052 if ( nCount )
3053 {
3054 if( pBasePool)
3055 {
3056 pBasePool->SetSearchMask(eFamily);
3057 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
3058 DBG_ASSERT(pBase, "Doesn't seem to be a style!");
3059
3060 if(pBase)
3061 {
3062 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3063 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
3064 switch(eFamily)
3065 {
3066 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
3067 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
3068 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
3069 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
3070 default:
3071 ;
3072 }
3073 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
3074 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
3075
3076 const SfxItemSet &rSet = xStyle->GetItemSet(), *pParentSet = rSet.GetParent();
3077 const OUString *pNames = aPropertyNames.getConstArray();
3078 uno::Any *pRet = aRet.getArray();
3079 for ( sal_Int32 i = 0 ; i < nCount; i++)
3080 {
3081 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[i] );
3082 if ( !pEntry )
3083 throw beans::UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) );
3084
3085 if( pParentSet )
3086 aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i], *pParentSet, pRet[i]);
3087 else if( pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID) )
3088 {
3089 const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID);
3090 rItem.QueryValue(pRet[i], pEntry->nMemberId);
3091 }
3092 }
3093 }
3094 else
3095 throw uno::RuntimeException();
3096 }
3097 else
3098 throw uno::RuntimeException();
3099 }
3100 return aRet;
3101 }
3102 /*-- 08.03.99 10:50:27---------------------------------------------------
3103
3104 -----------------------------------------------------------------------*/
getPropertyDefault(const OUString & rPropertyName)3105 uno::Any SwXStyle::getPropertyDefault(const OUString& rPropertyName)
3106 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3107 {
3108 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
3109 return getPropertyDefaults ( aSequence ).getConstArray()[0];
3110 }
3111 /* -----------------21.01.99 13:08-------------------
3112 *
3113 * --------------------------------------------------*/
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)3114 void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
3115 {
3116 SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
3117 if( pHint )
3118 {
3119 if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED))
3120 {
3121 pBasePool = 0;
3122 EndListening(rBC);
3123 }
3124 else if( pHint->GetId() &(SFX_STYLESHEET_CHANGED|SFX_STYLESHEET_ERASED) )
3125 {
3126 ((SfxStyleSheetBasePool&)rBC).SetSearchMask(eFamily);
3127 SfxStyleSheetBase* pOwnBase = ((SfxStyleSheetBasePool&)rBC).Find(sStyleName);
3128 if(!pOwnBase)
3129 {
3130 EndListening(rBC);
3131 Invalidate();
3132 }
3133 }
3134 }
3135 }
3136 /* -----------------------------15.08.00 11:35--------------------------------
3137
3138 ---------------------------------------------------------------------------*/
Invalidate()3139 void SwXStyle::Invalidate()
3140 {
3141 sStyleName.Erase();
3142 pBasePool = 0;
3143 m_pDoc = 0;
3144 mxStyleData.clear();
3145 mxStyleFamily.clear();
3146 }
3147
3148
3149 /******************************************************************
3150 * SwXPageStyle
3151 ******************************************************************/
3152 /*-- 17.12.98 08:43:35---------------------------------------------------
3153
3154 -----------------------------------------------------------------------*/
SwXPageStyle(SfxStyleSheetBasePool & rPool,SwDocShell * pDocSh,SfxStyleFamily eFam,const String & rStyleName)3155 SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool,
3156 SwDocShell* pDocSh, SfxStyleFamily eFam,
3157 const String& rStyleName)://, const SfxItemPropertyMap* _pMap) :
3158 SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName),//, _pMap),
3159 pDocShell(pDocSh)
3160 {
3161
3162 }
3163 /* -----------------23.08.99 15:52-------------------
3164
3165 --------------------------------------------------*/
SwXPageStyle(SwDocShell * pDocSh)3166 SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) :
3167 SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE),
3168 pDocShell(pDocSh)
3169 {
3170 }
3171
3172 /*-- 17.12.98 08:43:35---------------------------------------------------
3173
3174 -----------------------------------------------------------------------*/
~SwXPageStyle()3175 SwXPageStyle::~SwXPageStyle()
3176 {
3177
3178 }
3179 /* -----------------------------18.04.01 13:50--------------------------------
3180
3181 ---------------------------------------------------------------------------*/
SetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)3182 void SAL_CALL SwXPageStyle::SetPropertyValues_Impl(
3183 const uno::Sequence< OUString >& rPropertyNames,
3184 const uno::Sequence< uno::Any >& rValues )
3185 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
3186 lang::WrappedTargetException, uno::RuntimeException)
3187 {
3188 if(!GetDoc())
3189 throw uno::RuntimeException();
3190
3191 if(rPropertyNames.getLength() != rValues.getLength())
3192 throw lang::IllegalArgumentException();
3193
3194 const OUString* pNames = rPropertyNames.getConstArray();
3195 const uno::Any* pValues = rValues.getConstArray();
3196 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3197 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
3198 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName());
3199 if(GetBasePool())
3200 {
3201 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3202 GetBasePool()->SetSearchMask(GetFamily());
3203 SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName());
3204 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3205 DBG_ASSERT(pBase, "where is the style?" );
3206 if(pBase)
3207 aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase);
3208 else
3209 throw uno::RuntimeException();
3210 }
3211
3212 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
3213 {
3214 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] );
3215 if (!pEntry)
3216 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3217 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
3218 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3219
3220 if(GetBasePool())
3221 {
3222 switch(pEntry->nWID)
3223 {
3224 case FN_UNO_HEADER_ON:
3225 case FN_UNO_HEADER_BACKGROUND:
3226 case FN_UNO_HEADER_BOX:
3227 case FN_UNO_HEADER_LR_SPACE:
3228 case FN_UNO_HEADER_SHADOW:
3229 case FN_UNO_HEADER_BODY_DISTANCE:
3230 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE:
3231 case FN_UNO_HEADER_SHARE_CONTENT:
3232 case FN_UNO_HEADER_HEIGHT:
3233 case FN_UNO_HEADER_EAT_SPACING:
3234
3235 case FN_UNO_FOOTER_ON:
3236 case FN_UNO_FOOTER_BACKGROUND:
3237 case FN_UNO_FOOTER_BOX:
3238 case FN_UNO_FOOTER_LR_SPACE:
3239 case FN_UNO_FOOTER_SHADOW:
3240 case FN_UNO_FOOTER_BODY_DISTANCE:
3241 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
3242 case FN_UNO_FOOTER_SHARE_CONTENT:
3243 case FN_UNO_FOOTER_HEIGHT:
3244 case FN_UNO_FOOTER_EAT_SPACING:
3245 {
3246 sal_Bool bSetItem = sal_False;
3247 sal_Bool bFooter = sal_False;
3248 sal_uInt16 nItemType = TYPE_BOOL;
3249 sal_uInt16 nRes = 0;
3250 switch(pEntry->nWID)
3251 {
3252 case FN_UNO_FOOTER_ON: bFooter = sal_True;
3253 //kein break;
3254 case FN_UNO_HEADER_ON: nRes = SID_ATTR_PAGE_ON;
3255 break;
3256 case FN_UNO_FOOTER_BACKGROUND: bFooter = sal_True;
3257 // kein break;
3258 case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND; nItemType = TYPE_BRUSH;
3259 break;
3260 case FN_UNO_FOOTER_BOX: bFooter = sal_True;
3261 // kein break;
3262 case FN_UNO_HEADER_BOX: nRes = RES_BOX; nItemType = TYPE_BOX;
3263 break;
3264 case FN_UNO_FOOTER_LR_SPACE: bFooter = sal_True;
3265 // kein break;
3266 case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;nItemType = TYPE_LRSPACE;
3267 break;
3268 case FN_UNO_FOOTER_SHADOW: bFooter = sal_True;
3269 // kein break;
3270 case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;nItemType = TYPE_SHADOW;
3271 break;
3272 case FN_UNO_FOOTER_BODY_DISTANCE: bFooter = sal_True;
3273 // kein break;
3274 case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;nItemType = TYPE_ULSPACE;
3275 break;
3276 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = sal_True;
3277 // kein break;
3278 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
3279 break;
3280 case FN_UNO_FOOTER_SHARE_CONTENT: bFooter = sal_True;
3281 // kein break;
3282 case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED;
3283 break;
3284 case FN_UNO_FOOTER_HEIGHT: bFooter = sal_True;
3285 // kein break;
3286 case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;nItemType = TYPE_SIZE;
3287 break;
3288 case FN_UNO_FOOTER_EAT_SPACING: bFooter = sal_True;
3289 // kein break;
3290 case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;nItemType = TYPE_SIZE;
3291 break;
3292 }
3293 const SvxSetItem* pSetItem;
3294 if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(
3295 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3296 sal_False, (const SfxPoolItem**)&pSetItem))
3297 {
3298 SvxSetItem* pNewSetItem = (SvxSetItem*)pSetItem->Clone();
3299 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
3300 const SfxPoolItem* pItem = 0;
3301 SfxPoolItem* pNewItem = 0;
3302 rSetSet.GetItemState(nRes, sal_True, &pItem);
3303 if(!pItem && nRes != rSetSet.GetPool()->GetSlotId(nRes))
3304 pItem = &rSetSet.GetPool()->GetDefaultItem(nRes);
3305 if(pItem)
3306 {
3307 pNewItem = pItem->Clone();
3308 }
3309 else
3310 {
3311 switch(nItemType)
3312 {
3313 case TYPE_BOOL: pNewItem = new SfxBoolItem(nRes); break;
3314 case TYPE_SIZE: pNewItem = new SvxSizeItem(nRes); break;
3315 case TYPE_BRUSH: pNewItem = new SvxBrushItem(nRes); break;
3316 case TYPE_ULSPACE: pNewItem = new SvxULSpaceItem(nRes); break;
3317 case TYPE_SHADOW : pNewItem = new SvxShadowItem(nRes); break;
3318 case TYPE_LRSPACE: pNewItem = new SvxLRSpaceItem(nRes); break;
3319 case TYPE_BOX: pNewItem = new SvxBoxItem(nRes); break;
3320 }
3321 }
3322 bSetItem = pNewItem->PutValue(pValues[nProp], pEntry->nMemberId);
3323 rSetSet.Put(*pNewItem);
3324 aBaseImpl.GetItemSet().Put(*pNewSetItem);
3325 delete pNewItem;
3326 delete pNewSetItem;
3327 }
3328 else if(SID_ATTR_PAGE_ON == nRes )
3329 {
3330 sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue();
3331 if(bVal)
3332 {
3333 SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(),
3334 RES_BACKGROUND, RES_SHADOW,
3335 RES_LR_SPACE, RES_UL_SPACE,
3336 nRes, nRes,
3337 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
3338 SID_ATTR_PAGE_DYNAMIC, SID_ATTR_PAGE_DYNAMIC,
3339 SID_ATTR_PAGE_SHARED, SID_ATTR_PAGE_SHARED,
3340 0 );
3341 aTempSet.Put(SfxBoolItem(nRes, sal_True));
3342 aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50)));
3343 aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE));
3344 aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE));
3345 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, sal_True));
3346 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, sal_True));
3347
3348 SvxSetItem aNewSetItem( bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3349 aTempSet);
3350 aBaseImpl.GetItemSet().Put(aNewSetItem);
3351 }
3352 }
3353 }
3354 break;
3355 case FN_PARAM_FTN_INFO :
3356 {
3357 const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO);
3358 SfxPoolItem* pNewFtnItem = rItem.Clone();
3359 sal_Bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId);
3360 aBaseImpl.GetItemSet().Put(*pNewFtnItem);
3361 delete pNewFtnItem;
3362 if(!bPut)
3363 throw lang::IllegalArgumentException();
3364 }
3365 break;
3366 case FN_UNO_HEADER :
3367 case FN_UNO_HEADER_LEFT :
3368 case FN_UNO_HEADER_RIGHT :
3369 case FN_UNO_FOOTER :
3370 case FN_UNO_FOOTER_LEFT :
3371 case FN_UNO_FOOTER_RIGHT :
3372 throw lang::IllegalArgumentException();
3373 //break;
3374 default:
3375 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl,
3376 GetBasePool(), GetDoc(), GetFamily());
3377 }
3378 }
3379 else if(IsDescriptor())
3380 {
3381 if(!GetPropImpl()->SetProperty(pNames[nProp], pValues[nProp]))
3382 throw lang::IllegalArgumentException();
3383 }
3384 else
3385 throw uno::RuntimeException();
3386 }
3387 if(aBaseImpl.HasItemSet())
3388 {
3389 ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
3390 if (undoGuard.UndoWasEnabled())
3391 {
3392 // Fix i64460: as long as Undo of page styles with header/footer causes trouble...
3393 GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
3394 }
3395 aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet());
3396 }
3397 }
3398
setPropertyValues(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)3399 void SwXPageStyle::setPropertyValues(
3400 const uno::Sequence< OUString >& rPropertyNames,
3401 const uno::Sequence< uno::Any >& rValues )
3402 throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
3403 {
3404 vos::OGuard aGuard(Application::GetSolarMutex());
3405
3406 // workaround for bad designed API
3407 try
3408 {
3409 SetPropertyValues_Impl( rPropertyNames, rValues );
3410 }
3411 catch (beans::UnknownPropertyException &rException)
3412 {
3413 // wrap the original (here not allowed) exception in
3414 // a lang::WrappedTargetException that gets thrown instead.
3415 lang::WrappedTargetException aWExc;
3416 aWExc.TargetException <<= rException;
3417 throw aWExc;
3418 }
3419 }
3420 /* -----------------------------04.11.03 13:50--------------------------------
3421
3422 ---------------------------------------------------------------------------*/
3423 static uno::Reference<text::XText>
lcl_makeHeaderFooter(const sal_uInt16 nRes,const bool bHeader,SwFrmFmt const * const pFrmFmt)3424 lcl_makeHeaderFooter(
3425 const sal_uInt16 nRes, const bool bHeader, SwFrmFmt const*const pFrmFmt)
3426 {
3427 if (!pFrmFmt) { return 0; }
3428
3429 const SfxItemSet& rSet = pFrmFmt->GetAttrSet();
3430 const SfxPoolItem* pItem;
3431 if (SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem))
3432 {
3433 SwFrmFmt *const pHeadFootFmt = (bHeader)
3434 ? static_cast<SwFmtHeader*>(const_cast<SfxPoolItem*>(pItem))->
3435 GetHeaderFmt()
3436 : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))->
3437 GetFooterFmt();
3438 if (pHeadFootFmt)
3439 {
3440 return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader);
3441 }
3442 }
3443 return 0;
3444 }
3445
GetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames)3446 uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
3447 const uno::Sequence< OUString >& rPropertyNames )
3448 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3449 {
3450 if(!GetDoc())
3451 throw uno::RuntimeException();
3452
3453 sal_Int32 nLength = rPropertyNames.getLength();
3454 const OUString* pNames = rPropertyNames.getConstArray();
3455 uno::Sequence< uno::Any > aRet ( nLength );
3456
3457 uno::Any* pRet = aRet.getArray();
3458 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3459 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
3460 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName());
3461 SfxStyleSheetBase* pBase = 0;
3462 for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
3463 {
3464 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] );
3465 if (!pEntry)
3466 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3467
3468 if(GetBasePool())
3469 {
3470 if(!pBase)
3471 {
3472 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3473 GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL );
3474 pBase = GetBasePool()->Find(GetStyleName());
3475 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3476 }
3477 sal_uInt16 nRes = 0;
3478 bool bHeader = false;
3479 sal_Bool bAll = sal_False, bLeft = sal_False, bRight = sal_False;
3480 switch(pEntry->nWID)
3481 {
3482 case FN_UNO_HEADER_ON:
3483 case FN_UNO_HEADER_BACKGROUND:
3484 case FN_UNO_HEADER_BOX:
3485 case FN_UNO_HEADER_LR_SPACE:
3486 case FN_UNO_HEADER_SHADOW:
3487 case FN_UNO_HEADER_BODY_DISTANCE:
3488 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE:
3489 case FN_UNO_HEADER_SHARE_CONTENT:
3490 case FN_UNO_HEADER_HEIGHT:
3491 case FN_UNO_HEADER_EAT_SPACING:
3492
3493 case FN_UNO_FOOTER_ON:
3494 case FN_UNO_FOOTER_BACKGROUND:
3495 case FN_UNO_FOOTER_BOX:
3496 case FN_UNO_FOOTER_LR_SPACE:
3497 case FN_UNO_FOOTER_SHADOW:
3498 case FN_UNO_FOOTER_BODY_DISTANCE:
3499 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
3500 case FN_UNO_FOOTER_SHARE_CONTENT:
3501 case FN_UNO_FOOTER_HEIGHT:
3502 case FN_UNO_FOOTER_EAT_SPACING:
3503 {
3504 SfxStyleSheetBasePool* pBasePool2 = ((SwXPageStyle*)this)->GetBasePool();
3505 pBasePool2->SetSearchMask(GetFamily());
3506 SfxStyleSheetBase* pBase2 = pBasePool2->Find(GetStyleName());
3507 if(pBase2)
3508 {
3509 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3510 const SfxItemSet& rSet = xStyle->GetItemSet();
3511 sal_Bool bFooter = sal_False;
3512 switch(pEntry->nWID)
3513 {
3514 case FN_UNO_FOOTER_ON:
3515 bFooter = sal_True;
3516 // kein break!
3517 case FN_UNO_HEADER_ON:
3518 {
3519 //falls das SetItem nicht da ist, dann ist der Wert sal_False
3520 sal_Bool bRet = sal_False;
3521 pRet[nProp].setValue(&bRet, ::getCppuBooleanType());
3522 nRes = SID_ATTR_PAGE_ON;
3523 }
3524 break;
3525 case FN_UNO_FOOTER_BACKGROUND: bFooter = sal_True;
3526 // kein break;
3527 case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND;
3528 break;
3529 case FN_UNO_FOOTER_BOX: bFooter = sal_True;
3530 // kein break;
3531 case FN_UNO_HEADER_BOX: nRes = RES_BOX;
3532 break;
3533 case FN_UNO_FOOTER_LR_SPACE: bFooter = sal_True;
3534 // kein break;
3535 case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;
3536 break;
3537 case FN_UNO_FOOTER_SHADOW: bFooter = sal_True;
3538 // kein break;
3539 case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;
3540 break;
3541 case FN_UNO_FOOTER_BODY_DISTANCE: bFooter = sal_True;
3542 // kein break;
3543 case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;
3544 break;
3545 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = sal_True;
3546 // kein break;
3547 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
3548 break;
3549 case FN_UNO_FOOTER_SHARE_CONTENT: bFooter = sal_True;
3550 // kein break;
3551 case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED;
3552 break;
3553 case FN_UNO_FOOTER_HEIGHT: bFooter = sal_True;
3554 // kein break;
3555 case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;
3556 break;
3557 case FN_UNO_FOOTER_EAT_SPACING: bFooter = sal_True;
3558 // kein break;
3559 case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;
3560 break;
3561 }
3562 const SvxSetItem* pSetItem;
3563 if(SFX_ITEM_SET == rSet.GetItemState(
3564 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3565 sal_False, (const SfxPoolItem**)&pSetItem))
3566 {
3567 const SfxItemSet& rTmpSet = pSetItem->GetItemSet();
3568 const SfxPoolItem* pItem = 0;
3569 rTmpSet.GetItemState(nRes, sal_True, &pItem);
3570 if(!pItem && nRes != rTmpSet.GetPool()->GetSlotId(nRes))
3571 pItem = &rTmpSet.GetPool()->GetDefaultItem(nRes);
3572 if(pItem)
3573 pItem->QueryValue(pRet[nProp], pEntry->nMemberId);
3574 }
3575 }
3576 }
3577 break;
3578 case FN_UNO_HEADER :
3579 bAll = sal_True; goto Header;
3580 case FN_UNO_HEADER_LEFT :
3581 bLeft = sal_True; goto Header;
3582 case FN_UNO_HEADER_RIGHT :
3583 bRight = sal_True; goto Header;
3584 Header:
3585 bHeader = true;
3586 nRes = RES_HEADER; goto MakeObject;
3587 case FN_UNO_FOOTER :
3588 bAll = sal_True; goto Footer;
3589 case FN_UNO_FOOTER_LEFT :
3590 bLeft = sal_True; goto Footer;
3591 case FN_UNO_FOOTER_RIGHT :
3592 bRight = sal_True;
3593 Footer:
3594 nRes = RES_FOOTER;
3595 MakeObject:
3596 {
3597 const SwPageDesc& rDesc = aBase.GetOldPageDesc();
3598 const SwFrmFmt* pFrmFmt = 0;
3599 sal_Bool bShare = (bHeader && rDesc.IsHeaderShared())||
3600 (!bHeader && rDesc.IsFooterShared());
3601 // TextLeft returns the left content if there is one,
3602 // Text and TextRight return the master content.
3603 // TextRight does the same as Text and is for
3604 // comptability only.
3605 if( bLeft && !bShare )
3606 {
3607 pFrmFmt = &rDesc.GetLeft();
3608 }
3609 else
3610 {
3611 pFrmFmt = &rDesc.GetMaster();
3612 }
3613 const uno::Reference< text::XText > xRet =
3614 lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt);
3615 if (xRet.is())
3616 {
3617 pRet[nProp] <<= xRet;
3618 }
3619 }
3620 break;
3621 case FN_PARAM_FTN_INFO :
3622 {
3623 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3624 const SfxItemSet& rSet = xStyle->GetItemSet();
3625 const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO);
3626 rItem.QueryValue(pRet[nProp], pEntry->nMemberId);
3627 }
3628 break;
3629 default:
3630 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
3631 }
3632 }
3633 else if(IsDescriptor())
3634 {
3635 uno::Any* pAny = 0;
3636 GetPropImpl()->GetProperty(pNames[nProp], pAny);
3637 if ( !pAny )
3638 GetPropImpl()->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] );
3639 else
3640 pRet[nProp] = *pAny;
3641 }
3642 else
3643 throw uno::RuntimeException();
3644 }
3645 return aRet;
3646 }
3647 /* -----------------------------18.04.01 13:50--------------------------------
3648
3649 ---------------------------------------------------------------------------*/
getPropertyValues(const uno::Sequence<OUString> & rPropertyNames)3650 uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues(
3651 const uno::Sequence< OUString >& rPropertyNames )
3652 throw(uno::RuntimeException)
3653 {
3654 vos::OGuard aGuard(Application::GetSolarMutex());
3655 uno::Sequence< uno::Any > aValues;
3656
3657 // workaround for bad designed API
3658 try
3659 {
3660 aValues = GetPropertyValues_Impl( rPropertyNames );
3661 }
3662 catch (beans::UnknownPropertyException &)
3663 {
3664 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
3665 }
3666 catch (lang::WrappedTargetException &)
3667 {
3668 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
3669 }
3670
3671 return aValues;
3672 }
3673 /*-- 17.12.98 08:43:36---------------------------------------------------
3674
3675 -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)3676 uno::Any SwXPageStyle::getPropertyValue(const OUString& rPropertyName) throw(
3677 beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
3678 {
3679 vos::OGuard aGuard(Application::GetSolarMutex());
3680 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3681 return GetPropertyValues_Impl(aProperties).getConstArray()[0];
3682 }
3683 /*-- 17.12.98 08:43:36---------------------------------------------------
3684
3685 -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const uno::Any & rValue)3686 void SwXPageStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue)
3687 throw( beans::UnknownPropertyException,
3688 beans::PropertyVetoException,
3689 lang::IllegalArgumentException,
3690 lang::WrappedTargetException,
3691 uno::RuntimeException)
3692 {
3693 vos::OGuard aGuard(Application::GetSolarMutex());
3694 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3695 const uno::Sequence<uno::Any> aValues(&rValue, 1);
3696 SetPropertyValues_Impl( aProperties, aValues );
3697 }
3698
SwXFrameStyle(SwDoc * pDoc)3699 SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc )
3700 : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, sal_False)
3701 {
3702 }
3703 /* -----------------------------15.12.00 15:45--------------------------------
3704
3705 ---------------------------------------------------------------------------*/
~SwXFrameStyle()3706 SwXFrameStyle::~SwXFrameStyle()
3707 {
3708 }
3709 /* -----------------------------15.12.00 14:30--------------------------------
3710
3711 ---------------------------------------------------------------------------*/
getTypes()3712 uno::Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(uno::RuntimeException)
3713 {
3714 uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes();
3715 sal_Int32 nLen = aTypes.getLength();
3716 aTypes.realloc(nLen + 1);
3717 aTypes.getArray()[nLen] = ::getCppuType((uno::Reference<XEventsSupplier>*)0);
3718 return aTypes;
3719 }
3720 /* -----------------------------15.12.00 14:30--------------------------------
3721
3722 ---------------------------------------------------------------------------*/
queryInterface(const uno::Type & rType)3723 uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
3724 {
3725 uno::Any aRet;
3726 if(rType == ::getCppuType((uno::Reference<XEventsSupplier>*)0))
3727 aRet <<= uno::Reference<XEventsSupplier>(this);
3728 else
3729 aRet = SwXStyle::queryInterface(rType);
3730 return aRet;
3731 }
3732 /* -----------------------------15.12.00 14:30--------------------------------
3733
3734 ---------------------------------------------------------------------------*/
getEvents()3735 uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno::RuntimeException)
3736 {
3737 return new SwFrameStyleEventDescriptor( *this );
3738 }
3739 /*-- 19.05.2006 11:23:55---------------------------------------------------
3740
3741 -----------------------------------------------------------------------*/
SwXAutoStyles(SwDocShell & rDocShell)3742 SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) :
3743 SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell )
3744 {
3745 }
3746 /*-- 19.05.2006 11:23:56---------------------------------------------------
3747
3748 -----------------------------------------------------------------------*/
~SwXAutoStyles()3749 SwXAutoStyles::~SwXAutoStyles()
3750 {
3751 }
3752 /*-- 19.05.2006 11:23:57---------------------------------------------------
3753
3754 -----------------------------------------------------------------------*/
getCount(void)3755 sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException )
3756 {
3757 return AUTOSTYLE_FAMILY_COUNT;
3758 }
3759 /*-- 19.05.2006 11:23:57---------------------------------------------------
3760
3761 -----------------------------------------------------------------------*/
getByIndex(sal_Int32 nIndex)3762 uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex)
3763 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
3764 uno::RuntimeException )
3765 {
3766 vos::OGuard aGuard(Application::GetSolarMutex());
3767 uno::Any aRet;
3768 if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT)
3769 throw lang::IndexOutOfBoundsException();
3770 if(IsValid())
3771 {
3772 uno::Reference< style::XAutoStyleFamily > aRef;
3773 IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex];
3774 switch( nType )
3775 {
3776 case IStyleAccess::AUTO_STYLE_CHAR:
3777 {
3778 if(!xAutoCharStyles.is())
3779 xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType);
3780 aRef = xAutoCharStyles;
3781 }
3782 break;
3783 case IStyleAccess::AUTO_STYLE_RUBY:
3784 {
3785 if(!xAutoRubyStyles.is())
3786 xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType );
3787 aRef = xAutoRubyStyles;
3788 }
3789 break;
3790 case IStyleAccess::AUTO_STYLE_PARA:
3791 {
3792 if(!xAutoParaStyles.is())
3793 xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType );
3794 aRef = xAutoParaStyles;
3795 }
3796 break;
3797
3798 default:
3799 ;
3800 }
3801 aRet.setValue(&aRef, ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0));
3802 }
3803 else
3804 throw uno::RuntimeException();
3805 return aRet;
3806 }
3807 /*-- 19.05.2006 11:23:57---------------------------------------------------
3808
3809 -----------------------------------------------------------------------*/
getElementType()3810 uno::Type SwXAutoStyles::getElementType( ) throw(uno::RuntimeException)
3811 {
3812 return ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0);
3813 }
3814 /*-- 19.05.2006 11:23:58---------------------------------------------------
3815
3816 -----------------------------------------------------------------------*/
hasElements()3817 sal_Bool SwXAutoStyles::hasElements( ) throw(uno::RuntimeException)
3818 {
3819 return sal_True;
3820 }
3821 /*-- 19.05.2006 11:23:58---------------------------------------------------
3822
3823 -----------------------------------------------------------------------*/
getByName(const rtl::OUString & Name)3824 uno::Any SwXAutoStyles::getByName(const rtl::OUString& Name)
3825 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
3826 {
3827 uno::Any aRet;
3828 if(Name.compareToAscii("CharacterStyles") == 0 )
3829 aRet = getByIndex(0);
3830 else if(Name.compareToAscii("RubyStyles") == 0 )
3831 aRet = getByIndex(1);
3832 else if(Name.compareToAscii("ParagraphStyles") == 0 )
3833 aRet = getByIndex(2);
3834 else
3835 throw container::NoSuchElementException();
3836 return aRet;
3837 }
3838 /*-- 19.05.2006 11:23:59---------------------------------------------------
3839
3840 -----------------------------------------------------------------------*/
getElementNames(void)3841 uno::Sequence< rtl::OUString > SwXAutoStyles::getElementNames(void)
3842 throw( uno::RuntimeException )
3843 {
3844 uno::Sequence< OUString > aNames(AUTOSTYLE_FAMILY_COUNT);
3845 OUString* pNames = aNames.getArray();
3846 pNames[0] = C2U("CharacterStyles");
3847 pNames[1] = C2U("RubyStyles");
3848 pNames[2] = C2U("ParagraphStyles");
3849 return aNames;
3850 }
3851 /*-- 19.05.2006 11:24:00---------------------------------------------------
3852
3853 -----------------------------------------------------------------------*/
hasByName(const rtl::OUString & Name)3854 sal_Bool SwXAutoStyles::hasByName(const rtl::OUString& Name)
3855 throw( uno::RuntimeException )
3856 {
3857 if( Name.compareToAscii("CharacterStyles") == 0 ||
3858 Name.compareToAscii("RubyStyles") == 0 ||
3859 Name.compareToAscii("ParagraphStyles") == 0 )
3860 return sal_True;
3861 else
3862 return sal_False;
3863 }
3864
3865 /*-- 19.05.2006 11:24:02---------------------------------------------------
3866
3867 -----------------------------------------------------------------------*/
SwXAutoStyleFamily(SwDocShell * pDocSh,IStyleAccess::SwAutoStyleFamily nFamily)3868 SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) :
3869 pDocShell( pDocSh ), eFamily(nFamily)
3870 {
3871 // Register ourselves as a listener to the document (via the page descriptor)
3872 pDocSh->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
3873 }
3874 /*-- 19.05.2006 11:24:02---------------------------------------------------
3875
3876 -----------------------------------------------------------------------*/
~SwXAutoStyleFamily()3877 SwXAutoStyleFamily::~SwXAutoStyleFamily()
3878 {
3879 }
3880
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)3881 void SwXAutoStyleFamily::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
3882 {
3883 ClientModify(this, pOld, pNew);
3884 if(!GetRegisteredIn())
3885 pDocShell = 0;
3886 }
3887
3888 /*-- 31.05.2006 11:24:02---------------------------------------------------
3889
3890 -----------------------------------------------------------------------*/
insertStyle(const uno::Sequence<beans::PropertyValue> & Values)3891 uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle(
3892 const uno::Sequence< beans::PropertyValue >& Values )
3893 throw (uno::RuntimeException)
3894 {
3895 if( !pDocShell )
3896 throw uno::RuntimeException();
3897 const sal_uInt16* pRange = 0;
3898 const SfxItemPropertySet* pPropSet = 0;
3899 switch( eFamily )
3900 {
3901 case IStyleAccess::AUTO_STYLE_CHAR:
3902 {
3903 pRange = aCharAutoFmtSetRange;
3904 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE);
3905 }
3906 break;
3907 case IStyleAccess::AUTO_STYLE_RUBY:
3908 {
3909 pRange = 0;//aTxtNodeSetRange;
3910 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE);
3911 }
3912 break;
3913 case IStyleAccess::AUTO_STYLE_PARA:
3914 {
3915 pRange = aTxtNodeSetRange;
3916 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE);
3917 }
3918 break;
3919
3920 default:
3921 ;
3922 }
3923 SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange );
3924 const beans::PropertyValue* pSeq = Values.getConstArray();
3925 sal_Int32 nLen = Values.getLength();
3926 for( sal_Int32 i = 0; i < nLen; ++i )
3927 {
3928 try
3929 {
3930 pPropSet->setPropertyValue( pSeq[i].Name, pSeq[i].Value, aSet );
3931 }
3932 catch (beans::UnknownPropertyException &)
3933 {
3934 ASSERT( false, "Unknown property" );
3935 }
3936 catch (lang::IllegalArgumentException &)
3937 {
3938 ASSERT( false, "Illegal argument" );
3939 }
3940 }
3941
3942 SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily );
3943 uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily);
3944 return xRet;
3945 }
3946 /*-- 31.05.2006 11:24:02---------------------------------------------------
3947
3948 -----------------------------------------------------------------------*/
createEnumeration()3949 uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( )
3950 throw (uno::RuntimeException)
3951 {
3952 if( !pDocShell )
3953 throw uno::RuntimeException();
3954 return uno::Reference< container::XEnumeration >
3955 (new SwXAutoStylesEnumerator( pDocShell->GetDoc(), eFamily ));
3956 }
3957 /*-- 19.05.2006 11:24:03---------------------------------------------------
3958
3959 -----------------------------------------------------------------------*/
getElementType()3960 uno::Type SwXAutoStyleFamily::getElementType( ) throw(uno::RuntimeException)
3961 {
3962 return ::getCppuType((const uno::Reference<style::XAutoStyle>*)0);
3963 }
3964 /*-- 19.05.2006 11:24:04---------------------------------------------------
3965
3966 -----------------------------------------------------------------------*/
hasElements()3967 sal_Bool SwXAutoStyleFamily::hasElements( ) throw(uno::RuntimeException)
3968 {
3969 return sal_False;
3970 }
3971
3972 /*-- 31.05.2006 11:24:05---------------------------------------------------
3973
3974 -----------------------------------------------------------------------*/
SwAutoStylesEnumImpl(SwDoc * pInitDoc,IStyleAccess::SwAutoStyleFamily eFam)3975 SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam )
3976 : pDoc( pInitDoc ), eFamily( eFam )
3977 {
3978 // special case for ruby auto styles:
3979 if ( IStyleAccess::AUTO_STYLE_RUBY == eFam )
3980 {
3981 std::set< std::pair< sal_uInt16, sal_uInt16 > > aRubyMap;
3982 SwAttrPool& rAttrPool = pDoc->GetAttrPool();
3983 sal_uInt32 nCount = rAttrPool.GetItemCount2( RES_TXTATR_CJK_RUBY );
3984
3985 for ( sal_uInt32 nI = 0; nI < nCount; ++nI )
3986 {
3987 const SwFmtRuby* pItem = static_cast<const SwFmtRuby*>(rAttrPool.GetItem2( RES_TXTATR_CJK_RUBY, nI ));
3988 if ( pItem && pItem->GetTxtRuby() )
3989 {
3990 std::pair< sal_uInt16, sal_uInt16 > aPair( pItem->GetPosition(), pItem->GetAdjustment() );
3991 if ( aRubyMap.find( aPair ) == aRubyMap.end() )
3992 {
3993 aRubyMap.insert( aPair );
3994 SfxItemSet_Pointer_t pItemSet( new SfxItemSet( rAttrPool, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY ) );
3995 pItemSet->Put( *pItem );
3996 mAutoStyles.push_back( pItemSet );
3997 }
3998 }
3999 }
4000 }
4001 else
4002 {
4003 pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily );
4004 }
4005
4006 aIter = mAutoStyles.begin();
4007 }
4008
4009 /*-- 31.05.2006 11:24:05---------------------------------------------------
4010
4011 -----------------------------------------------------------------------*/
SwXAutoStylesEnumerator(SwDoc * pDoc,IStyleAccess::SwAutoStyleFamily eFam)4012 SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam )
4013 : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) )
4014 {
4015 // Register ourselves as a listener to the document (via the page descriptor)
4016 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4017 }
4018 /*-- 31.05.2006 11:24:05---------------------------------------------------
4019
4020 -----------------------------------------------------------------------*/
~SwXAutoStylesEnumerator()4021 SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator()
4022 {
4023 delete pImpl;
4024 }
4025
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)4026 void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
4027 {
4028 ClientModify(this, pOld, pNew);
4029 if(!GetRegisteredIn())
4030 {
4031 delete pImpl;
4032 pImpl = 0;
4033 }
4034 }
4035
4036
4037 /*-- 31.05.2006 11:24:05---------------------------------------------------
4038
4039 -----------------------------------------------------------------------*/
hasMoreElements()4040 ::sal_Bool SwXAutoStylesEnumerator::hasMoreElements( )
4041 throw (uno::RuntimeException)
4042 {
4043 if( !pImpl )
4044 throw uno::RuntimeException();
4045 return pImpl->hasMoreElements();
4046 }
4047 /*-- 31.05.2006 11:24:05---------------------------------------------------
4048
4049 -----------------------------------------------------------------------*/
nextElement()4050 uno::Any SwXAutoStylesEnumerator::nextElement( )
4051 throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
4052 {
4053 if( !pImpl )
4054 throw uno::RuntimeException();
4055 uno::Any aRet;
4056 if( pImpl->hasMoreElements() )
4057 {
4058 SfxItemSet_Pointer_t pNextSet = pImpl->nextElement();
4059 uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(),
4060 pNextSet, pImpl->getFamily());
4061 aRet.setValue(&xAutoStyle, ::getCppuType((uno::Reference<style::XAutoStyle>*)0));
4062 }
4063 return aRet;
4064 }
4065 /*-- 19.05.2006 11:24:09---------------------------------------------------
4066
4067 -----------------------------------------------------------------------*/
SwXAutoStyle(SwDoc * pDoc,SfxItemSet_Pointer_t pInitSet,IStyleAccess::SwAutoStyleFamily eFam)4068 SwXAutoStyle::SwXAutoStyle( SwDoc* pDoc, SfxItemSet_Pointer_t pInitSet, IStyleAccess::SwAutoStyleFamily eFam )
4069 : pSet( pInitSet ), eFamily( eFam )
4070 {
4071 // Register ourselves as a listener to the document (via the page descriptor)
4072 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4073 }
4074
4075 /*-- 19.05.2006 11:24:09---------------------------------------------------
4076
4077 -----------------------------------------------------------------------*/
~SwXAutoStyle()4078 SwXAutoStyle::~SwXAutoStyle()
4079 {
4080 }
4081
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)4082 void SwXAutoStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
4083 {
4084 ClientModify(this, pOld, pNew);
4085 if(!GetRegisteredIn())
4086 pSet.reset();
4087 }
4088
4089 /*-- 19.05.2006 11:24:09---------------------------------------------------
4090
4091 -----------------------------------------------------------------------*/
getPropertySetInfo()4092 uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo( )
4093 throw (uno::RuntimeException)
4094 {
4095 uno::Reference< beans::XPropertySetInfo > xRet;
4096 switch( eFamily )
4097 {
4098 case IStyleAccess::AUTO_STYLE_CHAR:
4099 {
4100 static uno::Reference< beans::XPropertySetInfo > xCharRef;
4101 if(!xCharRef.is())
4102 {
4103 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE)->getPropertySetInfo();
4104 }
4105 xRet = xCharRef;
4106 }
4107 break;
4108 case IStyleAccess::AUTO_STYLE_RUBY:
4109 {
4110 static uno::Reference< beans::XPropertySetInfo > xRubyRef;
4111 if(!xRubyRef.is())
4112 {
4113 sal_uInt16 nMapId = PROPERTY_MAP_RUBY_AUTO_STYLE;
4114 xRubyRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
4115 }
4116 xRet = xRubyRef;
4117 }
4118 break;
4119 case IStyleAccess::AUTO_STYLE_PARA:
4120 {
4121 static uno::Reference< beans::XPropertySetInfo > xParaRef;
4122 if(!xParaRef.is())
4123 {
4124 sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE;
4125 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
4126 }
4127 xRet = xParaRef;
4128 }
4129 break;
4130
4131 default:
4132 ;
4133 }
4134
4135 return xRet;
4136 }
4137
4138 /*-- 19.05.2006 11:24:09---------------------------------------------------
4139
4140 -----------------------------------------------------------------------*/
setPropertyValue(const OUString &,const uno::Any &)4141 void SwXAutoStyle::setPropertyValue( const OUString& /*rPropertyName*/, const uno::Any& /*rValue*/ )
4142 throw( beans::UnknownPropertyException,
4143 beans::PropertyVetoException,
4144 lang::IllegalArgumentException,
4145 lang::WrappedTargetException,
4146 uno::RuntimeException)
4147 {
4148 }
4149
4150 /*-- 19.05.2006 11:24:09---------------------------------------------------
4151
4152 -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)4153 uno::Any SwXAutoStyle::getPropertyValue( const OUString& rPropertyName )
4154 throw( beans::UnknownPropertyException,
4155 lang::WrappedTargetException,
4156 uno::RuntimeException )
4157 {
4158 vos::OGuard aGuard(Application::GetSolarMutex());
4159 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
4160 return GetPropertyValues_Impl(aProperties).getConstArray()[0];
4161 }
4162
4163 /*-- 19.05.2006 11:24:09---------------------------------------------------
4164
4165 -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)4166 void SwXAutoStyle::addPropertyChangeListener( const OUString& /*aPropertyName*/,
4167 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
4168 throw( beans::UnknownPropertyException,
4169 lang::WrappedTargetException,
4170 uno::RuntimeException )
4171 {
4172 }
4173
4174 /*-- 19.05.2006 11:24:09---------------------------------------------------
4175
4176 -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)4177 void SwXAutoStyle::removePropertyChangeListener( const OUString& /*aPropertyName*/,
4178 const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
4179 throw( beans::UnknownPropertyException,
4180 lang::WrappedTargetException,
4181 uno::RuntimeException )
4182 {
4183 }
4184
4185 /*-- 19.05.2006 11:24:09---------------------------------------------------
4186
4187 -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)4188 void SwXAutoStyle::addVetoableChangeListener( const OUString& /*PropertyName*/,
4189 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
4190 throw( beans::UnknownPropertyException,
4191 lang::WrappedTargetException,
4192 uno::RuntimeException )
4193 {
4194 }
4195
4196 /*-- 19.05.2006 11:24:09---------------------------------------------------
4197
4198 -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)4199 void SwXAutoStyle::removeVetoableChangeListener( const OUString& /*PropertyName*/,
4200 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
4201 throw( beans::UnknownPropertyException,
4202 lang::WrappedTargetException,
4203 uno::RuntimeException )
4204 {
4205 }
4206
4207 /*-- 19.05.2006 11:24:09---------------------------------------------------
4208
4209 -----------------------------------------------------------------------*/
setPropertyValues(const uno::Sequence<::rtl::OUString> &,const uno::Sequence<uno::Any> &)4210 void SwXAutoStyle::setPropertyValues(
4211 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
4212 const uno::Sequence< uno::Any >& /*aValues*/ )
4213 throw (beans::PropertyVetoException, lang::IllegalArgumentException,
4214 lang::WrappedTargetException, uno::RuntimeException)
4215 {
4216 }
4217
4218 /*-- 19.05.2006 11:24:09---------------------------------------------------
4219
4220 -----------------------------------------------------------------------*/
GetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames)4221 uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl(
4222 const uno::Sequence< OUString > & rPropertyNames )
4223 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4224 {
4225 if( !pSet.get() )
4226 throw uno::RuntimeException();
4227 // query_item
4228
4229 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
4230 switch(eFamily)
4231 {
4232 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4233 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4234 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4235 default:
4236 ;
4237 }
4238
4239 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4240 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
4241 const OUString* pNames = rPropertyNames.getConstArray();
4242
4243 sal_Int32 nLen = rPropertyNames.getLength();
4244 uno::Sequence< uno::Any > aRet( nLen );
4245 uno::Any* pValues = aRet.getArray();
4246
4247 SfxItemSet& rSet = *pSet.get();
4248
4249 for( sal_Int32 i = 0; i < nLen; ++i )
4250 {
4251 const String& rPropName = pNames[i];
4252 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName);
4253 if(!pEntry)
4254 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
4255 else if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID )
4256 {
4257 OUString sName(StylePool::nameOf( pSet ));
4258 pValues[i] <<= sName;
4259 }
4260 else
4261 pPropSet->getPropertyValue( *pEntry, rSet, pValues[i] );
4262 }
4263 return aRet;
4264 }
4265
4266 /*-- 19.05.2006 11:24:09---------------------------------------------------
4267
4268 -----------------------------------------------------------------------*/
getPropertyValues(const uno::Sequence<::rtl::OUString> & rPropertyNames)4269 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues (
4270 const uno::Sequence< ::rtl::OUString >& rPropertyNames )
4271 throw (uno::RuntimeException)
4272 {
4273 vos::OGuard aGuard(Application::GetSolarMutex());
4274 uno::Sequence< uno::Any > aValues;
4275
4276 // workaround for bad designed API
4277 try
4278 {
4279 aValues = GetPropertyValues_Impl( rPropertyNames );
4280 }
4281 catch (beans::UnknownPropertyException &)
4282 {
4283 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
4284 }
4285 catch (lang::WrappedTargetException &)
4286 {
4287 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
4288 }
4289
4290 return aValues;
4291 }
4292
4293 /*-- 19.05.2006 11:24:10---------------------------------------------------
4294
4295 -----------------------------------------------------------------------*/
addPropertiesChangeListener(const uno::Sequence<::rtl::OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)4296 void SwXAutoStyle::addPropertiesChangeListener(
4297 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
4298 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4299 throw (uno::RuntimeException)
4300 {
4301 }
4302
4303 /*-- 19.05.2006 11:24:10---------------------------------------------------
4304
4305 -----------------------------------------------------------------------*/
removePropertiesChangeListener(const uno::Reference<beans::XPropertiesChangeListener> &)4306 void SwXAutoStyle::removePropertiesChangeListener(
4307 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4308 throw (uno::RuntimeException)
4309 {
4310 }
4311
4312 /*-- 19.05.2006 11:24:11---------------------------------------------------
4313
4314 -----------------------------------------------------------------------*/
firePropertiesChangeEvent(const uno::Sequence<::rtl::OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)4315 void SwXAutoStyle::firePropertiesChangeEvent(
4316 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
4317 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4318 throw (uno::RuntimeException)
4319 {
4320 }
4321
4322 /*-- 19.05.2006 11:24:11---------------------------------------------------
4323
4324 -----------------------------------------------------------------------*/
getPropertyState(const OUString & rPropertyName)4325 beans::PropertyState SwXAutoStyle::getPropertyState( const OUString& rPropertyName )
4326 throw( beans::UnknownPropertyException,
4327 uno::RuntimeException)
4328 {
4329 vos::OGuard aGuard(Application::GetSolarMutex());
4330
4331 uno::Sequence< OUString > aNames(1);
4332 OUString* pNames = aNames.getArray();
4333 pNames[0] = rPropertyName;
4334 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
4335 return aStates.getConstArray()[0];
4336 }
4337
4338 /*-- 19.05.2006 11:24:11---------------------------------------------------
4339
4340 -----------------------------------------------------------------------*/
setPropertyToDefault(const OUString &)4341 void SwXAutoStyle::setPropertyToDefault( const OUString& /*PropertyName*/ )
4342 throw( beans::UnknownPropertyException,
4343 uno::RuntimeException )
4344 {
4345 }
4346
4347 /*-- 19.05.2006 11:24:11---------------------------------------------------
4348
4349 -----------------------------------------------------------------------*/
getPropertyDefault(const OUString & rPropertyName)4350 uno::Any SwXAutoStyle::getPropertyDefault( const OUString& rPropertyName )
4351 throw( beans::UnknownPropertyException,
4352 lang::WrappedTargetException,
4353 uno::RuntimeException)
4354 {
4355 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
4356 return getPropertyDefaults ( aSequence ).getConstArray()[0];
4357 }
4358
4359 /*-- 19.05.2006 11:24:12---------------------------------------------------
4360
4361 -----------------------------------------------------------------------*/
getPropertyStates(const uno::Sequence<::rtl::OUString> & rPropertyNames)4362 uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates(
4363 const uno::Sequence< ::rtl::OUString >& rPropertyNames )
4364 throw (beans::UnknownPropertyException, uno::RuntimeException)
4365 {
4366 if( !pSet.get() )
4367 throw uno::RuntimeException();
4368 vos::OGuard aGuard(Application::GetSolarMutex());
4369 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
4370 beans::PropertyState* pStates = aRet.getArray();
4371 const OUString* pNames = rPropertyNames.getConstArray();
4372
4373 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
4374 switch(eFamily)
4375 {
4376 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4377 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4378 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4379 default:
4380 ;
4381 }
4382
4383 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4384 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
4385 SfxItemSet& rSet = *pSet.get();
4386 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
4387 {
4388 const String& rPropName = pNames[i];
4389 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName);
4390 if(!pEntry)
4391 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
4392 pStates[i] = pPropSet->getPropertyState(*pEntry, rSet );
4393 }
4394 return aRet;
4395 }
4396
4397 /*-- 19.05.2006 11:24:12---------------------------------------------------
4398
4399 -----------------------------------------------------------------------*/
setAllPropertiesToDefault()4400 void SwXAutoStyle::setAllPropertiesToDefault( )
4401 throw (uno::RuntimeException)
4402 {
4403 }
4404
4405 /*-- 19.05.2006 11:24:13---------------------------------------------------
4406
4407 -----------------------------------------------------------------------*/
setPropertiesToDefault(const uno::Sequence<::rtl::OUString> &)4408 void SwXAutoStyle::setPropertiesToDefault(
4409 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ )
4410 throw (beans::UnknownPropertyException, uno::RuntimeException)
4411 {
4412 }
4413
4414 /*-- 19.05.2006 11:24:14---------------------------------------------------
4415
4416 -----------------------------------------------------------------------*/
getPropertyDefaults(const uno::Sequence<::rtl::OUString> &)4417 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyDefaults(
4418 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ )
4419 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
4420 uno::RuntimeException)
4421 {
4422 uno::Sequence< uno::Any > aRet(0);
4423 return aRet;
4424 }
4425
4426 /*-- 19.05.2006 11:24:14---------------------------------------------------
4427
4428 -----------------------------------------------------------------------*/
getProperties()4429 uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() throw (uno::RuntimeException)
4430 {
4431 if( !pSet.get() )
4432 throw uno::RuntimeException();
4433 vos::OGuard aGuard(Application::GetSolarMutex());
4434 std::vector< beans::PropertyValue > aPropertyVector;
4435
4436 sal_Int8 nPropSetId = 0;
4437 switch(eFamily)
4438 {
4439 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4440 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4441 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4442 default:
4443 ;
4444 }
4445
4446 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4447 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
4448 PropertyEntryVector_t aPropVector = pMap->getPropertyEntries();
4449 // struct compareWhichIds
4450 // {
4451 // bool operator()(const sal_uInt16 w1, const sal_uInt16 w2) const
4452 // {
4453 // return w1 < w2;
4454 // }
4455 // };
4456 // typedef std::map<const sal_uInt16, SfxItemPropertyNamedEntry, compareWhichIds> PropertyMap_t;
4457 // PropertyMap_t aPropMap;
4458 // aPropMap.reserve( aPropVector.size() );
4459 // PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
4460 // while( aIt != aPropertyEntries.end() )
4461 // {
4462 // aPropMap[aIt->nWID] = *aIt;
4463 // ++aIt;
4464 // }
4465
4466 SfxItemSet& rSet = *pSet.get();
4467 SfxItemIter aIter(rSet);
4468 const SfxPoolItem* pItem = aIter.FirstItem();
4469
4470 while ( pItem )
4471 {
4472 const sal_uInt16 nWID = pItem->Which();
4473
4474 // PropertyMap_t::const_iterator aMapIt = aPropMap[nWID];
4475 // if( aMapIt != aPropMap.getEnd() )
4476 // {
4477 // beans::PropertyValue aPropertyValue;
4478 // aPropertyValue.Name = aIt->sName;
4479 // pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
4480 // aPropertyVector.push_back( aPropertyValue );
4481 // }
4482 // TODO: Optimize - and fix! the old iteration filled each WhichId
4483 // only once but there are more properties than WhichIds
4484 PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
4485 while( aIt != aPropVector.end() )
4486 {
4487 if ( aIt->nWID == nWID )
4488 {
4489 beans::PropertyValue aPropertyValue;
4490 aPropertyValue.Name = aIt->sName;
4491 pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
4492 aPropertyVector.push_back( aPropertyValue );
4493 }
4494 ++aIt;
4495 }
4496 /* int i = 0;
4497 while ( pMap[i].nWID != 0 )
4498 {
4499 if ( pMap[i].nWID == nWID )
4500 {
4501 beans::PropertyValue aPropertyValue;
4502 String sString( OUString::createFromAscii( pMap[i].pName ) );
4503 aPropertyValue.Name = sString;
4504 pItem->QueryValue( aPropertyValue.Value, pMap[i].nMemberId );
4505 aPropertyVector.push_back( aPropertyValue );
4506 break;
4507 }
4508 ++i;
4509 }*/
4510 pItem = aIter.NextItem();
4511 }
4512
4513 const sal_Int32 nCount = aPropertyVector.size();
4514 uno::Sequence< beans::PropertyValue > aRet( nCount );
4515 beans::PropertyValue* pProps = aRet.getArray();
4516
4517 for ( int i = 0; i < nCount; ++i, pProps++ )
4518 {
4519 *pProps = aPropertyVector[i];
4520 }
4521
4522 return aRet;
4523 }
4524