1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include <svx/svxids.hrc>
26cdf0e10cSrcweir #include <hintids.hxx>
27cdf0e10cSrcweir #include <vos/mutex.hxx>
28cdf0e10cSrcweir #include <vcl/svapp.hxx>
29cdf0e10cSrcweir #include <svl/smplhint.hxx>
30cdf0e10cSrcweir #include <svtools/ctrltool.hxx>
31cdf0e10cSrcweir #include <svl/style.hxx>
32cdf0e10cSrcweir #include <svl/itemiter.hxx>
33cdf0e10cSrcweir #include <svx/pageitem.hxx>
34cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
35cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
36cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
37cdf0e10cSrcweir #include <editeng/boxitem.hxx>
38cdf0e10cSrcweir #include <editeng/shaditem.hxx>
39cdf0e10cSrcweir #include <editeng/brshitem.hxx>
40cdf0e10cSrcweir #include <editeng/flstitem.hxx>
41cdf0e10cSrcweir #include <editeng/paperinf.hxx>
42cdf0e10cSrcweir #include <pagedesc.hxx>
43cdf0e10cSrcweir #include <doc.hxx>
44cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
45cdf0e10cSrcweir #include <docary.hxx>
46cdf0e10cSrcweir #include <charfmt.hxx>
47cdf0e10cSrcweir #include <cmdid.h>
48cdf0e10cSrcweir #include <unostyle.hxx>
49cdf0e10cSrcweir #include <unosett.hxx>
50cdf0e10cSrcweir #include <docsh.hxx>
51cdf0e10cSrcweir #include <swstyle.h>
52cdf0e10cSrcweir #include <paratr.hxx>
53cdf0e10cSrcweir #include <unoprnms.hxx>
54cdf0e10cSrcweir #include <shellio.hxx>
55cdf0e10cSrcweir #include <docstyle.hxx>
56cdf0e10cSrcweir #include <unotextbodyhf.hxx>
57cdf0e10cSrcweir #include <fmthdft.hxx>
58cdf0e10cSrcweir #include <fmtpdsc.hxx>
59cdf0e10cSrcweir #include <tools/urlobj.hxx>
60cdf0e10cSrcweir #include <poolfmt.hrc>
61cdf0e10cSrcweir #include <poolfmt.hxx>
62cdf0e10cSrcweir #include "unoevent.hxx"
63cdf0e10cSrcweir #include <fmtruby.hxx>
64cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
65cdf0e10cSrcweir #include <sfx2/printer.hxx>
66cdf0e10cSrcweir #include <com/sun/star/style/ParagraphStyleCategory.hpp>
67cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
68cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
69cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
703f09c2ceSJürgen Schmidt #include <com/sun/star/drawing/BitmapMode.hpp>
71cdf0e10cSrcweir #include <istyleaccess.hxx>
72cdf0e10cSrcweir #include <GetMetricVal.hxx>
73cdf0e10cSrcweir #include <fmtfsize.hxx>
74cdf0e10cSrcweir #include <numrule.hxx>
75cdf0e10cSrcweir
7664b14621SArmin Le Grand //UUUU
7756b35d86SArmin Le Grand #include <svx/unobrushitemhelper.hxx>
7864b14621SArmin Le Grand #include <editeng/unoipset.hxx>
7964b14621SArmin Le Grand #include <editeng/memberids.hrc>
8064b14621SArmin Le Grand #include <svx/unoshape.hxx>
8164b14621SArmin Le Grand #include <svx/xflbstit.hxx>
8264b14621SArmin Le Grand #include <svx/xflbmtit.hxx>
8356b35d86SArmin Le Grand #include <swunohelper.hxx>
8456b35d86SArmin Le Grand #include <svx/xbtmpit.hxx>
8564b14621SArmin Le Grand
86cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
87cdf0e10cSrcweir
88cdf0e10cSrcweir #include "ccoll.hxx"
89cdf0e10cSrcweir #include "unocore.hrc"
90cdf0e10cSrcweir
91cdf0e10cSrcweir #include <set>
92cdf0e10cSrcweir
93cdf0e10cSrcweir #define STYLE_FAMILY_COUNT 5 // we have 5 style families
94cdf0e10cSrcweir #define TYPE_BOOL 0
95cdf0e10cSrcweir #define TYPE_SIZE 1
96cdf0e10cSrcweir #define TYPE_BRUSH 2
97cdf0e10cSrcweir #define TYPE_ULSPACE 3
98cdf0e10cSrcweir #define TYPE_SHADOW 4
99cdf0e10cSrcweir #define TYPE_LRSPACE 5
100cdf0e10cSrcweir #define TYPE_BOX 6
101cdf0e10cSrcweir
102cdf0e10cSrcweir const unsigned short aStyleByIndex[] =
103cdf0e10cSrcweir {
104cdf0e10cSrcweir SFX_STYLE_FAMILY_CHAR,
105cdf0e10cSrcweir SFX_STYLE_FAMILY_PARA,
106cdf0e10cSrcweir SFX_STYLE_FAMILY_PAGE ,
107cdf0e10cSrcweir SFX_STYLE_FAMILY_FRAME ,
108cdf0e10cSrcweir SFX_STYLE_FAMILY_PSEUDO
109cdf0e10cSrcweir };
110cdf0e10cSrcweir
111cdf0e10cSrcweir // Already implemented autostyle families: 3
112cdf0e10cSrcweir #define AUTOSTYLE_FAMILY_COUNT 3
113cdf0e10cSrcweir const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] =
114cdf0e10cSrcweir {
115cdf0e10cSrcweir IStyleAccess::AUTO_STYLE_CHAR,
116cdf0e10cSrcweir IStyleAccess::AUTO_STYLE_RUBY,
117cdf0e10cSrcweir IStyleAccess::AUTO_STYLE_PARA
118cdf0e10cSrcweir };
119cdf0e10cSrcweir
120cdf0e10cSrcweir using namespace ::com::sun::star;
121cdf0e10cSrcweir using ::rtl::OUString;
122cdf0e10cSrcweir
123cdf0e10cSrcweir /******************************************************************************
124cdf0e10cSrcweir *
125cdf0e10cSrcweir ******************************************************************************/
126cdf0e10cSrcweir
lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)127cdf0e10cSrcweir SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum ( SfxStyleFamily eFamily )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir switch ( eFamily )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
132cdf0e10cSrcweir return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
133cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
134cdf0e10cSrcweir return nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
135cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME:
136cdf0e10cSrcweir return nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
137cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
138cdf0e10cSrcweir return nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC;
139cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
140cdf0e10cSrcweir return nsSwGetPoolIdFromName::GET_POOLID_NUMRULE;
141cdf0e10cSrcweir default:
142cdf0e10cSrcweir DBG_ASSERT(sal_False, "someone asking for all styles in unostyle.cxx!" );
143cdf0e10cSrcweir return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
147cdf0e10cSrcweir class SwAutoStylesEnumImpl
148cdf0e10cSrcweir {
149cdf0e10cSrcweir std::vector<SfxItemSet_Pointer_t> mAutoStyles;
150cdf0e10cSrcweir std::vector<SfxItemSet_Pointer_t>::iterator aIter;
151cdf0e10cSrcweir SwDoc* pDoc;
152cdf0e10cSrcweir IStyleAccess::SwAutoStyleFamily eFamily;
153cdf0e10cSrcweir public:
154cdf0e10cSrcweir SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam );
hasMoreElements()155cdf0e10cSrcweir ::sal_Bool hasMoreElements() { return aIter != mAutoStyles.end(); }
nextElement()156cdf0e10cSrcweir SfxItemSet_Pointer_t nextElement() { return *(aIter++); }
getFamily() const157cdf0e10cSrcweir IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; }
getDoc() const158cdf0e10cSrcweir SwDoc* getDoc() const { return pDoc; }
159cdf0e10cSrcweir };
160cdf0e10cSrcweir
161cdf0e10cSrcweir
162cdf0e10cSrcweir /******************************************************************
163cdf0e10cSrcweir * SwXStyleFamilies
164cdf0e10cSrcweir ******************************************************************/
165cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
166cdf0e10cSrcweir
167cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getImplementationName(void)168cdf0e10cSrcweir OUString SwXStyleFamilies::getImplementationName(void) throw( uno::RuntimeException )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir return C2U("SwXStyleFamilies");
171cdf0e10cSrcweir }
172cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
173cdf0e10cSrcweir
174cdf0e10cSrcweir ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)175cdf0e10cSrcweir sal_Bool SwXStyleFamilies::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir return C2U("com.sun.star.style.StyleFamilies") == rServiceName;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
180cdf0e10cSrcweir
181cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)182cdf0e10cSrcweir uno::Sequence< OUString > SwXStyleFamilies::getSupportedServiceNames(void) throw( uno::RuntimeException )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir uno::Sequence< OUString > aRet(1);
185cdf0e10cSrcweir OUString* pArray = aRet.getArray();
186cdf0e10cSrcweir pArray[0] = C2U("com.sun.star.style.StyleFamilies");
187cdf0e10cSrcweir return aRet;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir /*-- 16.12.98 15:13:26---------------------------------------------------
190cdf0e10cSrcweir
191cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXStyleFamilies(SwDocShell & rDocShell)192cdf0e10cSrcweir SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) :
193cdf0e10cSrcweir SwUnoCollection(rDocShell.GetDoc()),
194cdf0e10cSrcweir pDocShell(&rDocShell),
195cdf0e10cSrcweir pxCharStyles(0),
196cdf0e10cSrcweir pxParaStyles(0),
197cdf0e10cSrcweir pxFrameStyles(0),
198cdf0e10cSrcweir pxPageStyles(0),
199cdf0e10cSrcweir pxNumberingStyles(0)
200cdf0e10cSrcweir {
201cdf0e10cSrcweir
202cdf0e10cSrcweir }
203cdf0e10cSrcweir /*-- 16.12.98 15:13:26---------------------------------------------------
204cdf0e10cSrcweir
205cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXStyleFamilies()206cdf0e10cSrcweir SwXStyleFamilies::~SwXStyleFamilies()
207cdf0e10cSrcweir {
208cdf0e10cSrcweir delete pxCharStyles;
209cdf0e10cSrcweir delete pxParaStyles;
210cdf0e10cSrcweir delete pxFrameStyles;
211cdf0e10cSrcweir delete pxPageStyles;
212cdf0e10cSrcweir delete pxNumberingStyles;
213cdf0e10cSrcweir }
214cdf0e10cSrcweir /*-- 21.12.98 12:05:22---------------------------------------------------
215cdf0e10cSrcweir
216cdf0e10cSrcweir -----------------------------------------------------------------------*/
getByName(const OUString & Name)217cdf0e10cSrcweir uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name)
218cdf0e10cSrcweir throw(
219cdf0e10cSrcweir container::NoSuchElementException,
220cdf0e10cSrcweir lang::WrappedTargetException,
221cdf0e10cSrcweir uno::RuntimeException )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
224cdf0e10cSrcweir // der Index kommt aus const unsigned short aStyleByIndex[] =
225cdf0e10cSrcweir uno::Any aRet;
226cdf0e10cSrcweir if(!IsValid())
227cdf0e10cSrcweir throw uno::RuntimeException();
228cdf0e10cSrcweir if(Name.compareToAscii("CharacterStyles") == 0 )
229cdf0e10cSrcweir aRet = getByIndex(0);
230cdf0e10cSrcweir else if(Name.compareToAscii("ParagraphStyles") == 0)
231cdf0e10cSrcweir aRet = getByIndex(1);
232cdf0e10cSrcweir else if(Name.compareToAscii("FrameStyles") == 0 )
233cdf0e10cSrcweir aRet = getByIndex(3);
234cdf0e10cSrcweir else if(Name.compareToAscii("PageStyles") == 0 )
235cdf0e10cSrcweir aRet = getByIndex(2);
236cdf0e10cSrcweir else if(Name.compareToAscii("NumberingStyles") == 0 )
237cdf0e10cSrcweir aRet = getByIndex(4);
238cdf0e10cSrcweir else
239cdf0e10cSrcweir throw container::NoSuchElementException();
240cdf0e10cSrcweir return aRet;
241cdf0e10cSrcweir }
242cdf0e10cSrcweir /*-- 21.12.98 12:05:22---------------------------------------------------
243cdf0e10cSrcweir
244cdf0e10cSrcweir -----------------------------------------------------------------------*/
getElementNames(void)245cdf0e10cSrcweir uno::Sequence< OUString > SwXStyleFamilies::getElementNames(void) throw( uno::RuntimeException )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir uno::Sequence< OUString > aNames(STYLE_FAMILY_COUNT);
248cdf0e10cSrcweir OUString* pNames = aNames.getArray();
249cdf0e10cSrcweir pNames[0] = C2U("CharacterStyles");
250cdf0e10cSrcweir pNames[1] = C2U("ParagraphStyles");
251cdf0e10cSrcweir pNames[2] = C2U("FrameStyles");
252cdf0e10cSrcweir pNames[3] = C2U("PageStyles");
253cdf0e10cSrcweir pNames[4] = C2U("NumberingStyles");
254cdf0e10cSrcweir return aNames;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir /*-- 21.12.98 12:05:22---------------------------------------------------
257cdf0e10cSrcweir
258cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasByName(const OUString & Name)259cdf0e10cSrcweir sal_Bool SwXStyleFamilies::hasByName(const OUString& Name) throw( uno::RuntimeException )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir if( Name.compareToAscii("CharacterStyles") == 0 ||
262cdf0e10cSrcweir Name.compareToAscii("ParagraphStyles") == 0 ||
263cdf0e10cSrcweir Name.compareToAscii("FrameStyles") == 0 ||
264cdf0e10cSrcweir Name.compareToAscii("PageStyles") == 0 ||
265cdf0e10cSrcweir Name.compareToAscii("NumberingStyles") == 0 )
266cdf0e10cSrcweir return sal_True;
267cdf0e10cSrcweir else
268cdf0e10cSrcweir return sal_False;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir /*-- 16.12.98 15:13:27---------------------------------------------------
271cdf0e10cSrcweir
272cdf0e10cSrcweir -----------------------------------------------------------------------*/
getCount(void)273cdf0e10cSrcweir sal_Int32 SwXStyleFamilies::getCount(void) throw( uno::RuntimeException )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir return STYLE_FAMILY_COUNT;
276cdf0e10cSrcweir }
277cdf0e10cSrcweir /*-- 16.12.98 15:13:27---------------------------------------------------
278cdf0e10cSrcweir
279cdf0e10cSrcweir -----------------------------------------------------------------------*/
getByIndex(sal_Int32 nIndex)280cdf0e10cSrcweir uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
281cdf0e10cSrcweir throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
284cdf0e10cSrcweir uno::Any aRet;
285cdf0e10cSrcweir if(nIndex < 0 || nIndex >= STYLE_FAMILY_COUNT)
286cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
287cdf0e10cSrcweir if(IsValid())
288cdf0e10cSrcweir {
289cdf0e10cSrcweir uno::Reference< container::XNameContainer > aRef;
290cdf0e10cSrcweir sal_uInt16 nType = aStyleByIndex[nIndex];
291cdf0e10cSrcweir switch( nType )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
294cdf0e10cSrcweir {
295cdf0e10cSrcweir if(!pxCharStyles)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir ((SwXStyleFamilies*)this)->pxCharStyles = new uno::Reference< container::XNameContainer > ();
298cdf0e10cSrcweir *pxCharStyles = new SwXStyleFamily(pDocShell, nType);
299cdf0e10cSrcweir }
300cdf0e10cSrcweir aRef = *pxCharStyles;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir break;
303cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
304cdf0e10cSrcweir {
305cdf0e10cSrcweir if(!pxParaStyles)
306cdf0e10cSrcweir {
307cdf0e10cSrcweir ((SwXStyleFamilies*)this)->pxParaStyles = new uno::Reference< container::XNameContainer > ();
308cdf0e10cSrcweir *pxParaStyles = new SwXStyleFamily(pDocShell, nType);
309cdf0e10cSrcweir }
310cdf0e10cSrcweir aRef = *pxParaStyles;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir break;
313cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE :
314cdf0e10cSrcweir {
315cdf0e10cSrcweir if(!pxPageStyles)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir ((SwXStyleFamilies*)this)->pxPageStyles = new uno::Reference< container::XNameContainer > ();
318cdf0e10cSrcweir *pxPageStyles = new SwXStyleFamily(pDocShell, nType);
319cdf0e10cSrcweir }
320cdf0e10cSrcweir aRef = *pxPageStyles;
321cdf0e10cSrcweir }
322cdf0e10cSrcweir break;
323cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME :
324cdf0e10cSrcweir {
325cdf0e10cSrcweir if(!pxFrameStyles)
326cdf0e10cSrcweir {
327cdf0e10cSrcweir ((SwXStyleFamilies*)this)->pxFrameStyles = new uno::Reference< container::XNameContainer > ();
328cdf0e10cSrcweir *pxFrameStyles = new SwXStyleFamily(pDocShell, nType);
329cdf0e10cSrcweir }
330cdf0e10cSrcweir aRef = *pxFrameStyles;
331cdf0e10cSrcweir }
332cdf0e10cSrcweir break;
333cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
334cdf0e10cSrcweir {
335cdf0e10cSrcweir if(!pxNumberingStyles)
336cdf0e10cSrcweir {
337cdf0e10cSrcweir ((SwXStyleFamilies*)this)->pxNumberingStyles = new uno::Reference< container::XNameContainer > ();
338cdf0e10cSrcweir *pxNumberingStyles = new SwXStyleFamily(pDocShell, nType);
339cdf0e10cSrcweir }
340cdf0e10cSrcweir aRef = *pxNumberingStyles;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir break;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir aRet.setValue(&aRef, ::getCppuType((const uno::Reference<container::XNameContainer>*)0));
345cdf0e10cSrcweir }
346cdf0e10cSrcweir else
347cdf0e10cSrcweir throw uno::RuntimeException();
348cdf0e10cSrcweir return aRet;
349cdf0e10cSrcweir }
350cdf0e10cSrcweir /*-- 16.12.98 15:13:27---------------------------------------------------
351cdf0e10cSrcweir
352cdf0e10cSrcweir -----------------------------------------------------------------------*/
getElementType(void)353cdf0e10cSrcweir uno::Type SwXStyleFamilies::getElementType(void)
354cdf0e10cSrcweir throw( uno::RuntimeException )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir return ::getCppuType((const uno::Reference<container::XNameContainer>*)0);
357cdf0e10cSrcweir
358cdf0e10cSrcweir }
359cdf0e10cSrcweir /*-- 16.12.98 15:13:28---------------------------------------------------
360cdf0e10cSrcweir
361cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasElements(void)362cdf0e10cSrcweir sal_Bool SwXStyleFamilies::hasElements(void) throw( uno::RuntimeException )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir return sal_True;
365cdf0e10cSrcweir }
366cdf0e10cSrcweir /*-- 16.12.98 15:13:28---------------------------------------------------
367cdf0e10cSrcweir
368cdf0e10cSrcweir -----------------------------------------------------------------------*/
loadStylesFromURL(const OUString & rURL,const uno::Sequence<beans::PropertyValue> & aOptions)369cdf0e10cSrcweir void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL,
370cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& aOptions)
371cdf0e10cSrcweir throw( io::IOException, uno::RuntimeException )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
374cdf0e10cSrcweir sal_Bool bLoadStyleText = sal_True;
375cdf0e10cSrcweir sal_Bool bLoadStylePage = sal_True;
376cdf0e10cSrcweir sal_Bool bLoadStyleOverwrite = sal_True;
377cdf0e10cSrcweir sal_Bool bLoadStyleNumbering = sal_True;
378cdf0e10cSrcweir sal_Bool bLoadStyleFrame = sal_True;
379cdf0e10cSrcweir if(IsValid() && rURL.getLength())
380cdf0e10cSrcweir {
381cdf0e10cSrcweir const uno::Any* pVal;
382cdf0e10cSrcweir int nCount = aOptions.getLength();
383cdf0e10cSrcweir const beans::PropertyValue* pArray = aOptions.getConstArray();
384cdf0e10cSrcweir for(int i = 0; i < nCount; i++)
385cdf0e10cSrcweir if( ( pVal = &pArray[i].Value)->getValueType() ==
386cdf0e10cSrcweir ::getBooleanCppuType() )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir String sName = pArray[i].Name;
389cdf0e10cSrcweir sal_Bool bVal = *(sal_Bool*)pVal->getValue();
390cdf0e10cSrcweir if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_OVERWRITE_STYLES )))
391cdf0e10cSrcweir bLoadStyleOverwrite = bVal;
392cdf0e10cSrcweir else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_NUMBERING_STYLES )))
393cdf0e10cSrcweir bLoadStyleNumbering = bVal;
394cdf0e10cSrcweir else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_PAGE_STYLES )))
395cdf0e10cSrcweir bLoadStylePage = bVal;
396cdf0e10cSrcweir else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_FRAME_STYLES )))
397cdf0e10cSrcweir bLoadStyleFrame = bVal;
398cdf0e10cSrcweir else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_TEXT_STYLES )))
399cdf0e10cSrcweir bLoadStyleText = bVal;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
402cdf0e10cSrcweir SwgReaderOption aOpt;
403cdf0e10cSrcweir aOpt.SetFrmFmts( bLoadStyleFrame );
404cdf0e10cSrcweir aOpt.SetTxtFmts( bLoadStyleText );
405cdf0e10cSrcweir aOpt.SetPageDescs( bLoadStylePage );
406cdf0e10cSrcweir aOpt.SetNumRules( bLoadStyleNumbering );
407cdf0e10cSrcweir aOpt.SetMerge( !bLoadStyleOverwrite );
408cdf0e10cSrcweir
409cdf0e10cSrcweir sal_uLong nErr = pDocShell->LoadStylesFromFile( rURL, aOpt, sal_True );
410cdf0e10cSrcweir if( nErr )
411cdf0e10cSrcweir throw io::IOException();
412cdf0e10cSrcweir }
413cdf0e10cSrcweir else
414cdf0e10cSrcweir throw uno::RuntimeException();
415cdf0e10cSrcweir }
416cdf0e10cSrcweir /*-- 16.12.98 15:13:28---------------------------------------------------
417cdf0e10cSrcweir
418cdf0e10cSrcweir -----------------------------------------------------------------------*/
getStyleLoaderOptions(void)419cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions(void)
420cdf0e10cSrcweir throw( uno::RuntimeException )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
423cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aSeq(5);
424cdf0e10cSrcweir beans::PropertyValue* pArray = aSeq.getArray();
425cdf0e10cSrcweir uno::Any aVal;
426cdf0e10cSrcweir sal_Bool bTemp = sal_True;
427cdf0e10cSrcweir aVal.setValue(&bTemp, ::getCppuBooleanType());
428cdf0e10cSrcweir pArray[0] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_TEXT_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
429cdf0e10cSrcweir aVal.setValue(&bTemp, ::getCppuBooleanType());
430cdf0e10cSrcweir pArray[1] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_FRAME_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
431cdf0e10cSrcweir aVal.setValue(&bTemp, ::getCppuBooleanType());
432cdf0e10cSrcweir pArray[2] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_PAGE_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
433cdf0e10cSrcweir aVal.setValue(&bTemp, ::getCppuBooleanType());
434cdf0e10cSrcweir pArray[3] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_NUMBERING_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
435cdf0e10cSrcweir aVal.setValue(&bTemp, ::getCppuBooleanType());
436cdf0e10cSrcweir pArray[4] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_OVERWRITE_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
437cdf0e10cSrcweir return aSeq;
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
440cdf0e10cSrcweir /******************************************************************
441cdf0e10cSrcweir * SwXStyleFamily
442cdf0e10cSrcweir ******************************************************************/
443cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
444cdf0e10cSrcweir
445cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getImplementationName(void)446cdf0e10cSrcweir OUString SwXStyleFamily::getImplementationName(void) throw( uno::RuntimeException )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir return C2U("SwXStyleFamily");
449cdf0e10cSrcweir }
450cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
451cdf0e10cSrcweir
452cdf0e10cSrcweir ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)453cdf0e10cSrcweir sal_Bool SwXStyleFamily::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
454cdf0e10cSrcweir {
455cdf0e10cSrcweir return C2U("com.sun.star.style.StyleFamily") == rServiceName;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
458cdf0e10cSrcweir
459cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)460cdf0e10cSrcweir uno::Sequence< OUString > SwXStyleFamily::getSupportedServiceNames(void) throw( uno::RuntimeException )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir uno::Sequence< OUString > aRet(1);
463cdf0e10cSrcweir OUString* pArray = aRet.getArray();
464cdf0e10cSrcweir pArray[0] = C2U("com.sun.star.style.StyleFamily");
465cdf0e10cSrcweir return aRet;
466cdf0e10cSrcweir }
467cdf0e10cSrcweir /*-- 16.12.98 16:03:56---------------------------------------------------
468cdf0e10cSrcweir
469cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXStyleFamily(SwDocShell * pDocSh,sal_uInt16 nFamily)470cdf0e10cSrcweir SwXStyleFamily::SwXStyleFamily(SwDocShell* pDocSh, sal_uInt16 nFamily) :
471cdf0e10cSrcweir eFamily((SfxStyleFamily)nFamily),
472cdf0e10cSrcweir pBasePool(pDocSh->GetStyleSheetPool()),
473cdf0e10cSrcweir pDocShell(pDocSh)
474cdf0e10cSrcweir {
475cdf0e10cSrcweir /* switch( nFamily )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
478cdf0e10cSrcweir _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_CHAR_STYLE);
479cdf0e10cSrcweir break;
480cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
481cdf0e10cSrcweir _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PARA_STYLE);
482cdf0e10cSrcweir break;
483cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
484cdf0e10cSrcweir _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PAGE_STYLE);
485cdf0e10cSrcweir break;
486cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME:
487cdf0e10cSrcweir _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_FRAME_STYLE);
488cdf0e10cSrcweir break;
489cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
490cdf0e10cSrcweir _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_NUM_STYLE);
491cdf0e10cSrcweir break;
492cdf0e10cSrcweir }*/
493cdf0e10cSrcweir StartListening(*pBasePool);
494cdf0e10cSrcweir }
495cdf0e10cSrcweir /*-- 16.12.98 16:03:56---------------------------------------------------
496cdf0e10cSrcweir
497cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXStyleFamily()498cdf0e10cSrcweir SwXStyleFamily::~SwXStyleFamily()
499cdf0e10cSrcweir {
500cdf0e10cSrcweir
501cdf0e10cSrcweir }
lcl_GetCountOrName(const SwDoc & rDoc,SfxStyleFamily eFamily,String * pString,sal_uInt16 nIndex=USHRT_MAX)502cdf0e10cSrcweir sal_Int32 lcl_GetCountOrName ( const SwDoc &rDoc, SfxStyleFamily eFamily, String *pString, sal_uInt16 nIndex = USHRT_MAX )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir sal_Int32 nCount = 0;
505cdf0e10cSrcweir switch( eFamily )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
508cdf0e10cSrcweir {
509cdf0e10cSrcweir sal_uInt16 nBaseCount = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
510cdf0e10cSrcweir RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
511cdf0e10cSrcweir nIndex = nIndex - nBaseCount;
512cdf0e10cSrcweir const sal_uInt16 nArrLen = rDoc.GetCharFmts()->Count();
513cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nArrLen; i++ )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
516cdf0e10cSrcweir if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() )
517cdf0e10cSrcweir continue;
518cdf0e10cSrcweir if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir if ( nIndex == nCount )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir // the default character format needs to be set to "Default!"
523cdf0e10cSrcweir if(rDoc.GetDfltCharFmt() == pFmt)
524cdf0e10cSrcweir SwStyleNameMapper::FillUIName(
525cdf0e10cSrcweir RES_POOLCOLL_STANDARD, *pString );
526cdf0e10cSrcweir else
527cdf0e10cSrcweir *pString = pFmt->GetName();
528cdf0e10cSrcweir break;
529cdf0e10cSrcweir }
530cdf0e10cSrcweir nCount++;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir }
533cdf0e10cSrcweir nCount += nBaseCount;
534cdf0e10cSrcweir }
535cdf0e10cSrcweir break;
536cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
537cdf0e10cSrcweir {
538cdf0e10cSrcweir sal_uInt16 nBaseCount = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
539cdf0e10cSrcweir RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
540cdf0e10cSrcweir RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
541cdf0e10cSrcweir RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
542cdf0e10cSrcweir RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
543cdf0e10cSrcweir RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
544cdf0e10cSrcweir nIndex = nIndex - nBaseCount;
545cdf0e10cSrcweir const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count();
546cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nArrLen; i++ )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir SwTxtFmtColl * pColl = (*rDoc.GetTxtFmtColls())[i];
549cdf0e10cSrcweir if ( pColl->IsDefault() )
550cdf0e10cSrcweir continue;
551cdf0e10cSrcweir if ( IsPoolUserFmt ( pColl->GetPoolFmtId() ) )
552cdf0e10cSrcweir {
553cdf0e10cSrcweir if ( nIndex == nCount )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir *pString = pColl->GetName();
556cdf0e10cSrcweir break;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir nCount++;
559cdf0e10cSrcweir }
560cdf0e10cSrcweir }
561cdf0e10cSrcweir nCount += nBaseCount;
562cdf0e10cSrcweir }
563cdf0e10cSrcweir break;
564cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME:
565cdf0e10cSrcweir {
566cdf0e10cSrcweir sal_uInt16 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
567cdf0e10cSrcweir nIndex = nIndex - nBaseCount;
568cdf0e10cSrcweir const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->Count();
569cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nArrLen; i++ )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
572cdf0e10cSrcweir if(pFmt->IsDefault() || pFmt->IsAuto())
573cdf0e10cSrcweir continue;
574cdf0e10cSrcweir if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
575cdf0e10cSrcweir {
576cdf0e10cSrcweir if ( nIndex == nCount )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir *pString = pFmt->GetName();
579cdf0e10cSrcweir break;
580cdf0e10cSrcweir }
581cdf0e10cSrcweir nCount++;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir }
584cdf0e10cSrcweir nCount += nBaseCount;
585cdf0e10cSrcweir }
586cdf0e10cSrcweir break;
587cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
588cdf0e10cSrcweir {
589cdf0e10cSrcweir sal_uInt16 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
590cdf0e10cSrcweir nIndex = nIndex - nBaseCount;
591cdf0e10cSrcweir const sal_uInt16 nArrLen = rDoc.GetPageDescCnt();
592cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nArrLen; ++i)
593cdf0e10cSrcweir {
594cdf0e10cSrcweir const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
595cdf0e10cSrcweir
596cdf0e10cSrcweir /*if(rDesc.IsDefault() || rDesc.IsAuto())
597cdf0e10cSrcweir continue;*/
598cdf0e10cSrcweir if ( IsPoolUserFmt ( rDesc.GetPoolFmtId() ) )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir if ( nIndex == nCount )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir *pString = rDesc.GetName();
603cdf0e10cSrcweir break;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir nCount++;
606cdf0e10cSrcweir }
607cdf0e10cSrcweir }
608cdf0e10cSrcweir nCount += nBaseCount;
609cdf0e10cSrcweir }
610cdf0e10cSrcweir break;
611cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
612cdf0e10cSrcweir {
613cdf0e10cSrcweir sal_uInt16 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
614cdf0e10cSrcweir nIndex = nIndex - nBaseCount;
615cdf0e10cSrcweir const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
616cdf0e10cSrcweir for(sal_uInt16 i = 0; i < rNumTbl.Count(); ++i)
617cdf0e10cSrcweir {
618cdf0e10cSrcweir const SwNumRule& rRule = *rNumTbl[ i ];
619cdf0e10cSrcweir if( rRule.IsAutoRule() )
620cdf0e10cSrcweir continue;
621cdf0e10cSrcweir if ( IsPoolUserFmt ( rRule.GetPoolFmtId() ) )
622cdf0e10cSrcweir {
623cdf0e10cSrcweir if ( nIndex == nCount )
624cdf0e10cSrcweir {
625cdf0e10cSrcweir *pString = rRule.GetName();
626cdf0e10cSrcweir break;
627cdf0e10cSrcweir }
628cdf0e10cSrcweir nCount++;
629cdf0e10cSrcweir }
630cdf0e10cSrcweir }
631cdf0e10cSrcweir nCount += nBaseCount;
632cdf0e10cSrcweir }
633cdf0e10cSrcweir break;
634cdf0e10cSrcweir
635cdf0e10cSrcweir default:
636cdf0e10cSrcweir ;
637cdf0e10cSrcweir }
638cdf0e10cSrcweir return nCount;
639cdf0e10cSrcweir }
640cdf0e10cSrcweir /*-- 16.12.98 16:03:57---------------------------------------------------
641cdf0e10cSrcweir
642cdf0e10cSrcweir -----------------------------------------------------------------------*/
getCount(void)643cdf0e10cSrcweir sal_Int32 SwXStyleFamily::getCount(void) throw( uno::RuntimeException )
644cdf0e10cSrcweir {
645cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
646cdf0e10cSrcweir return lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, NULL );
647cdf0e10cSrcweir }
648cdf0e10cSrcweir /*-- 16.12.98 16:03:57---------------------------------------------------
649cdf0e10cSrcweir
650cdf0e10cSrcweir -----------------------------------------------------------------------*/
getByIndex(sal_Int32 nTempIndex)651cdf0e10cSrcweir uno::Any SwXStyleFamily::getByIndex(sal_Int32 nTempIndex)
652cdf0e10cSrcweir throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
655cdf0e10cSrcweir uno::Any aRet;
656cdf0e10cSrcweir if ( nTempIndex >= 0 && nTempIndex < USHRT_MAX )
657cdf0e10cSrcweir {
658cdf0e10cSrcweir sal_uInt16 nIndex = static_cast < sal_uInt16 > ( nTempIndex );
659cdf0e10cSrcweir if(pBasePool)
660cdf0e10cSrcweir {
661cdf0e10cSrcweir String sStyleName;
662cdf0e10cSrcweir switch( eFamily )
663cdf0e10cSrcweir {
664cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
665cdf0e10cSrcweir {
666cdf0e10cSrcweir if ( nIndex < ( RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
667cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName );
668cdf0e10cSrcweir else if ( nIndex < ( RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
669cdf0e10cSrcweir RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
670cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( RES_POOLCHR_HTML_BEGIN
671cdf0e10cSrcweir - RES_POOLCHR_NORMAL_END + RES_POOLCHR_NORMAL_BEGIN
672cdf0e10cSrcweir + nIndex, sStyleName );
673cdf0e10cSrcweir }
674cdf0e10cSrcweir break;
675cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
676cdf0e10cSrcweir {
677cdf0e10cSrcweir if ( nIndex < ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
678cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_TEXT_BEGIN + nIndex), sStyleName );
679cdf0e10cSrcweir else if ( nIndex < ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
680cdf0e10cSrcweir RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
681cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( RES_POOLCOLL_LISTS_BEGIN
682cdf0e10cSrcweir - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
683cdf0e10cSrcweir + nIndex, sStyleName );
684cdf0e10cSrcweir else if ( nIndex < ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
685cdf0e10cSrcweir RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
686cdf0e10cSrcweir RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
687cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_EXTRA_BEGIN
688cdf0e10cSrcweir - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
689cdf0e10cSrcweir - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
690cdf0e10cSrcweir + nIndex), sStyleName );
691cdf0e10cSrcweir else if ( nIndex < ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
692cdf0e10cSrcweir RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
693cdf0e10cSrcweir RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
694cdf0e10cSrcweir RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
695cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_REGISTER_BEGIN
696cdf0e10cSrcweir - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
697cdf0e10cSrcweir - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
698cdf0e10cSrcweir - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
699cdf0e10cSrcweir + nIndex), sStyleName );
700cdf0e10cSrcweir else if ( nIndex < ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
701cdf0e10cSrcweir RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
702cdf0e10cSrcweir RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
703cdf0e10cSrcweir RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
704cdf0e10cSrcweir RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
705cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_DOC_BEGIN
706cdf0e10cSrcweir - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
707cdf0e10cSrcweir - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
708cdf0e10cSrcweir - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
709cdf0e10cSrcweir - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
710cdf0e10cSrcweir + nIndex), sStyleName );
711cdf0e10cSrcweir else if ( nIndex < ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
712cdf0e10cSrcweir RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
713cdf0e10cSrcweir RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
714cdf0e10cSrcweir RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
715cdf0e10cSrcweir RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
716cdf0e10cSrcweir RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
717cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_HTML_BEGIN
718cdf0e10cSrcweir - RES_POOLCOLL_DOC_END + RES_POOLCOLL_DOC_BEGIN
719cdf0e10cSrcweir - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
720cdf0e10cSrcweir - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
721cdf0e10cSrcweir - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
722cdf0e10cSrcweir - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
723cdf0e10cSrcweir + nIndex), sStyleName );
724cdf0e10cSrcweir }
725cdf0e10cSrcweir break;
726cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME:
727cdf0e10cSrcweir {
728cdf0e10cSrcweir if ( nIndex < ( RES_POOLFRM_END - RES_POOLFRM_BEGIN ) )
729cdf0e10cSrcweir {
730cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLFRM_BEGIN + nIndex), sStyleName );
731cdf0e10cSrcweir }
732cdf0e10cSrcweir }
733cdf0e10cSrcweir break;
734cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
735cdf0e10cSrcweir {
736cdf0e10cSrcweir if ( nIndex < ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN ) )
737cdf0e10cSrcweir {
738cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + nIndex), sStyleName );
739cdf0e10cSrcweir }
740cdf0e10cSrcweir }
741cdf0e10cSrcweir break;
742cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
743cdf0e10cSrcweir {
744cdf0e10cSrcweir if ( nIndex < ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN ) )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName );
747cdf0e10cSrcweir }
748cdf0e10cSrcweir }
749cdf0e10cSrcweir break;
750cdf0e10cSrcweir
751cdf0e10cSrcweir default:
752cdf0e10cSrcweir ;
753cdf0e10cSrcweir }
754cdf0e10cSrcweir if ( !sStyleName.Len() )
755cdf0e10cSrcweir lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, &sStyleName, nIndex );
756cdf0e10cSrcweir
757cdf0e10cSrcweir if ( sStyleName.Len() )
758cdf0e10cSrcweir {
759cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find( sStyleName, eFamily );
760cdf0e10cSrcweir if(pBase)
761cdf0e10cSrcweir {
762cdf0e10cSrcweir uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
763cdf0e10cSrcweir if(!xStyle.is())
764cdf0e10cSrcweir {
765cdf0e10cSrcweir xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
766cdf0e10cSrcweir new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
767cdf0e10cSrcweir eFamily == SFX_STYLE_FAMILY_FRAME ?
768cdf0e10cSrcweir new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
769cdf0e10cSrcweir new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
770cdf0e10cSrcweir }
771cdf0e10cSrcweir aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
772cdf0e10cSrcweir }
773cdf0e10cSrcweir else
774cdf0e10cSrcweir throw container::NoSuchElementException();
775cdf0e10cSrcweir }
776cdf0e10cSrcweir else
777cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
778cdf0e10cSrcweir }
779cdf0e10cSrcweir else
780cdf0e10cSrcweir throw uno::RuntimeException();
781cdf0e10cSrcweir }
782cdf0e10cSrcweir else
783cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
784cdf0e10cSrcweir
785cdf0e10cSrcweir return aRet;
786cdf0e10cSrcweir }
787cdf0e10cSrcweir /*-- 16.12.98 16:03:57---------------------------------------------------
788cdf0e10cSrcweir
789cdf0e10cSrcweir -----------------------------------------------------------------------*/
getByName(const OUString & rName)790cdf0e10cSrcweir uno::Any SwXStyleFamily::getByName(const OUString& rName)
791cdf0e10cSrcweir throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
792cdf0e10cSrcweir {
793cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
794cdf0e10cSrcweir uno::Any aRet;
795cdf0e10cSrcweir String sStyleName;
796cdf0e10cSrcweir SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
797cdf0e10cSrcweir if(pBasePool)
798cdf0e10cSrcweir {
799cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
800cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
801cdf0e10cSrcweir if(pBase)
802cdf0e10cSrcweir {
803cdf0e10cSrcweir uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
804cdf0e10cSrcweir if(!xStyle.is())
805cdf0e10cSrcweir {
806cdf0e10cSrcweir xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
807cdf0e10cSrcweir new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
808cdf0e10cSrcweir eFamily == SFX_STYLE_FAMILY_FRAME ?
809cdf0e10cSrcweir new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
810cdf0e10cSrcweir new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
811cdf0e10cSrcweir }
812cdf0e10cSrcweir aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
813cdf0e10cSrcweir }
814cdf0e10cSrcweir else
815cdf0e10cSrcweir throw container::NoSuchElementException();
816cdf0e10cSrcweir }
817cdf0e10cSrcweir else
818cdf0e10cSrcweir throw uno::RuntimeException();
819cdf0e10cSrcweir return aRet;
820cdf0e10cSrcweir
821cdf0e10cSrcweir }
822cdf0e10cSrcweir /*-- 16.12.98 16:03:57---------------------------------------------------
823cdf0e10cSrcweir
824cdf0e10cSrcweir -----------------------------------------------------------------------*/
getElementNames(void)825cdf0e10cSrcweir uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException )
826cdf0e10cSrcweir {
827cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
828cdf0e10cSrcweir uno::Sequence< OUString > aRet;
829cdf0e10cSrcweir if(pBasePool)
830cdf0e10cSrcweir {
83149bd4d4bSArmin Le Grand SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, 0xffff);
83249bd4d4bSArmin Le Grand sal_uInt16 nCount = pIterator->Count();
833cdf0e10cSrcweir aRet.realloc(nCount);
834cdf0e10cSrcweir OUString* pArray = aRet.getArray();
835cdf0e10cSrcweir String aString;
836cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; i++)
837cdf0e10cSrcweir {
83849bd4d4bSArmin Le Grand SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
839cdf0e10cSrcweir pArray[i] = OUString ( aString );
840cdf0e10cSrcweir }
841cdf0e10cSrcweir }
842cdf0e10cSrcweir else
843cdf0e10cSrcweir throw uno::RuntimeException();
844cdf0e10cSrcweir return aRet;
845cdf0e10cSrcweir }
846cdf0e10cSrcweir /*-- 16.12.98 16:03:57---------------------------------------------------
847cdf0e10cSrcweir
848cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasByName(const OUString & rName)849cdf0e10cSrcweir sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException )
850cdf0e10cSrcweir {
851cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
852cdf0e10cSrcweir sal_Bool bRet = sal_False;
853cdf0e10cSrcweir if(pBasePool)
854cdf0e10cSrcweir {
855cdf0e10cSrcweir String sStyleName;
856cdf0e10cSrcweir SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
857cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
858cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
859cdf0e10cSrcweir bRet = 0 != pBase;
860cdf0e10cSrcweir }
861cdf0e10cSrcweir else
862cdf0e10cSrcweir throw uno::RuntimeException();
863cdf0e10cSrcweir return bRet;
864cdf0e10cSrcweir
865cdf0e10cSrcweir }
866cdf0e10cSrcweir /*-- 16.12.98 16:03:58---------------------------------------------------
867cdf0e10cSrcweir
868cdf0e10cSrcweir -----------------------------------------------------------------------*/
getElementType(void)869cdf0e10cSrcweir uno::Type SwXStyleFamily::getElementType(void) throw( uno::RuntimeException )
870cdf0e10cSrcweir {
871cdf0e10cSrcweir return ::getCppuType((const uno::Reference<style::XStyle>*)0);
872cdf0e10cSrcweir
873cdf0e10cSrcweir }
874cdf0e10cSrcweir /*-- 16.12.98 16:03:58---------------------------------------------------
875cdf0e10cSrcweir
876cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasElements(void)877cdf0e10cSrcweir sal_Bool SwXStyleFamily::hasElements(void) throw( uno::RuntimeException )
878cdf0e10cSrcweir {
879cdf0e10cSrcweir if(!pBasePool)
880cdf0e10cSrcweir throw uno::RuntimeException();
881cdf0e10cSrcweir return sal_True;
882cdf0e10cSrcweir }
883cdf0e10cSrcweir /*-- 16.12.98 16:03:58---------------------------------------------------
884cdf0e10cSrcweir
885cdf0e10cSrcweir -----------------------------------------------------------------------*/
insertByName(const OUString & rName,const uno::Any & rElement)886cdf0e10cSrcweir void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
887cdf0e10cSrcweir throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
888cdf0e10cSrcweir {
889cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
890cdf0e10cSrcweir if(pBasePool)
891cdf0e10cSrcweir {
892cdf0e10cSrcweir String sStyleName;
893cdf0e10cSrcweir SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
894cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
895cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
896cdf0e10cSrcweir SfxStyleSheetBase* pUINameBase = pBasePool->Find( sStyleName );
897cdf0e10cSrcweir if(pBase || pUINameBase)
898cdf0e10cSrcweir throw container::ElementExistException();
899cdf0e10cSrcweir else
900cdf0e10cSrcweir {
901cdf0e10cSrcweir if(rElement.getValueType().getTypeClass() ==
902cdf0e10cSrcweir uno::TypeClass_INTERFACE)
903cdf0e10cSrcweir {
904cdf0e10cSrcweir uno::Reference< uno::XInterface > * pxRef =
905cdf0e10cSrcweir (uno::Reference< uno::XInterface > *)rElement.getValue();
906cdf0e10cSrcweir
907cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xStyleTunnel( *pxRef, uno::UNO_QUERY);
908cdf0e10cSrcweir
909cdf0e10cSrcweir SwXStyle* pNewStyle = 0;
910cdf0e10cSrcweir if(xStyleTunnel.is())
911cdf0e10cSrcweir {
912cdf0e10cSrcweir pNewStyle = reinterpret_cast< SwXStyle * >(
913cdf0e10cSrcweir sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
914cdf0e10cSrcweir }
915cdf0e10cSrcweir if(!pNewStyle || !pNewStyle->IsDescriptor() ||
916cdf0e10cSrcweir pNewStyle->GetFamily() != eFamily)
917cdf0e10cSrcweir throw lang::IllegalArgumentException();
918cdf0e10cSrcweir if(pNewStyle)
919cdf0e10cSrcweir {
920cdf0e10cSrcweir sal_uInt16 nMask = 0xffff;
921cdf0e10cSrcweir if(eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional())
922cdf0e10cSrcweir nMask &= ~SWSTYLEBIT_CONDCOLL;
923cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
924cdf0e10cSrcweir SfxStyleSheetBase& rNewBase =
925cdf0e10cSrcweir #endif
926cdf0e10cSrcweir pBasePool->Make(sStyleName, eFamily, nMask);
927cdf0e10cSrcweir pNewStyle->SetDoc(pDocShell->GetDoc(), pBasePool);
928cdf0e10cSrcweir pNewStyle->SetStyleName(sStyleName);
929cdf0e10cSrcweir String sParentStyleName(pNewStyle->GetParentStyleName());
930cdf0e10cSrcweir if(sParentStyleName.Len())
931cdf0e10cSrcweir {
932cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
933cdf0e10cSrcweir SfxStyleSheetBase* pParentBase = pBasePool->Find(sParentStyleName);
934cdf0e10cSrcweir if(pParentBase && pParentBase->GetFamily() == eFamily &&
935cdf0e10cSrcweir &pParentBase->GetPool() == pBasePool)
936cdf0e10cSrcweir pBasePool->SetParent( eFamily, sStyleName, sParentStyleName );
937cdf0e10cSrcweir
938cdf0e10cSrcweir }
939cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
940cdf0e10cSrcweir (void)rNewBase;
941cdf0e10cSrcweir #endif
942cdf0e10cSrcweir //so, jetzt sollten noch die Properties des Descriptors angewandt werden
943cdf0e10cSrcweir pNewStyle->ApplyDescriptorProperties();
944cdf0e10cSrcweir }
945cdf0e10cSrcweir else
946cdf0e10cSrcweir throw lang::IllegalArgumentException();
947cdf0e10cSrcweir }
948cdf0e10cSrcweir else
949cdf0e10cSrcweir throw lang::IllegalArgumentException();
950cdf0e10cSrcweir }
951cdf0e10cSrcweir }
952cdf0e10cSrcweir else
953cdf0e10cSrcweir throw uno::RuntimeException();
954cdf0e10cSrcweir }
955cdf0e10cSrcweir /*-- 16.12.98 16:03:59---------------------------------------------------
956cdf0e10cSrcweir
957cdf0e10cSrcweir -----------------------------------------------------------------------*/
replaceByName(const OUString & rName,const uno::Any & rElement)958cdf0e10cSrcweir void SwXStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement)
959cdf0e10cSrcweir throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
960cdf0e10cSrcweir {
961cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
962cdf0e10cSrcweir if(pBasePool)
963cdf0e10cSrcweir {
964cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily);
965cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(rName);
966cdf0e10cSrcweir //Ersetzung geht nur fuer benutzerdefinierte Styles
967cdf0e10cSrcweir if(!pBase)
968cdf0e10cSrcweir throw container::NoSuchElementException();
969cdf0e10cSrcweir if(!pBase->IsUserDefined())
970cdf0e10cSrcweir throw lang::IllegalArgumentException();
971cdf0e10cSrcweir //if theres an object available to this style then it must be invalidated
972cdf0e10cSrcweir uno::Reference< style::XStyle > xStyle = _FindStyle(pBase->GetName());
973cdf0e10cSrcweir if(xStyle.is())
974cdf0e10cSrcweir {
975cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xTunnel( xStyle, uno::UNO_QUERY);
976cdf0e10cSrcweir if(xTunnel.is())
977cdf0e10cSrcweir {
978cdf0e10cSrcweir SwXStyle* pStyle = reinterpret_cast< SwXStyle * >(
979cdf0e10cSrcweir sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
980cdf0e10cSrcweir pStyle->Invalidate();
981cdf0e10cSrcweir }
982cdf0e10cSrcweir }
983cdf0e10cSrcweir
984cdf0e10cSrcweir pBasePool->Remove(pBase);
985cdf0e10cSrcweir insertByName(rName, rElement);
986cdf0e10cSrcweir }
987cdf0e10cSrcweir else
988cdf0e10cSrcweir throw uno::RuntimeException();
989cdf0e10cSrcweir }
990cdf0e10cSrcweir /*-- 16.12.98 16:03:59---------------------------------------------------
991cdf0e10cSrcweir
992cdf0e10cSrcweir -----------------------------------------------------------------------*/
removeByName(const OUString & rName)993cdf0e10cSrcweir void SwXStyleFamily::removeByName(const OUString& rName) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
994cdf0e10cSrcweir {
995cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
996cdf0e10cSrcweir if(pBasePool)
997cdf0e10cSrcweir {
998cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
999cdf0e10cSrcweir String aString;
1000cdf0e10cSrcweir SwStyleNameMapper::FillUIName(rName, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find( aString );
1003cdf0e10cSrcweir if(pBase)
1004cdf0e10cSrcweir pBasePool->Remove(pBase);
1005cdf0e10cSrcweir else
1006cdf0e10cSrcweir throw container::NoSuchElementException();
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir else
1009cdf0e10cSrcweir throw uno::RuntimeException();
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir
getPropertySetInfo()1012cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXStyleFamily::getPropertySetInfo( ) throw (uno::RuntimeException)
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir OSL_ENSURE( 0, "###unexpected!" );
1015cdf0e10cSrcweir return uno::Reference< beans::XPropertySetInfo >();
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir
setPropertyValue(const::rtl::OUString &,const uno::Any &)1018cdf0e10cSrcweir void SAL_CALL SwXStyleFamily::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir OSL_ENSURE( 0, "###unexpected!" );
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir
getPropertyValue(const::rtl::OUString & sPropertyName)1023cdf0e10cSrcweir uno::Any SAL_CALL SwXStyleFamily::getPropertyValue( const ::rtl::OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1024cdf0e10cSrcweir {
1025cdf0e10cSrcweir uno::Any aRet;
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir if ( sPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ) )
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1030cdf0e10cSrcweir sal_uInt32 nResId = 0;
1031cdf0e10cSrcweir switch ( eFamily )
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
1034cdf0e10cSrcweir nResId = STR_STYLE_FAMILY_CHARACTER; break;
1035cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
1036cdf0e10cSrcweir nResId = STR_STYLE_FAMILY_PARAGRAPH; break;
1037cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME:
1038cdf0e10cSrcweir nResId = STR_STYLE_FAMILY_FRAME; break;
1039cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
1040cdf0e10cSrcweir nResId = STR_STYLE_FAMILY_PAGE; break;
1041cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
1042cdf0e10cSrcweir nResId = STR_STYLE_FAMILY_NUMBERING; break;
1043cdf0e10cSrcweir default:
1044cdf0e10cSrcweir OSL_ENSURE( 0, "SwXStyleFamily::getPropertyValue(): invalid family" );
1045cdf0e10cSrcweir }
1046cdf0e10cSrcweir if ( nResId > 0 )
1047cdf0e10cSrcweir {
1048cdf0e10cSrcweir OUString sDisplayName( String( SW_RES( nResId ) ) );
1049cdf0e10cSrcweir aRet = uno::makeAny( sDisplayName );
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir else
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir throw beans::UnknownPropertyException( OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + sPropertyName, static_cast<OWeakObject *>(this) );
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir
1057cdf0e10cSrcweir return aRet;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1060cdf0e10cSrcweir void SAL_CALL SwXStyleFamily::addPropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir OSL_ENSURE( 0, "###unexpected!" );
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1065cdf0e10cSrcweir void SAL_CALL SwXStyleFamily::removePropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir OSL_ENSURE( 0, "###unexpected!" );
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1070cdf0e10cSrcweir void SAL_CALL SwXStyleFamily::addVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir OSL_ENSURE( 0, "###unexpected!" );
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1075cdf0e10cSrcweir void SAL_CALL SwXStyleFamily::removeVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1076cdf0e10cSrcweir {
1077cdf0e10cSrcweir OSL_ENSURE( 0, "###unexpected!" );
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir /*-- 16.12.98 16:03:59---------------------------------------------------
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir -----------------------------------------------------------------------*/
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)1084cdf0e10cSrcweir void SwXStyleFamily::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
1087cdf0e10cSrcweir if( pHint && ( pHint->GetId() & SFX_HINT_DYING ) )
1088cdf0e10cSrcweir {
1089cdf0e10cSrcweir pBasePool = 0;
1090cdf0e10cSrcweir pDocShell = 0;
1091cdf0e10cSrcweir EndListening(rBC);
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir /*-- 16.12.98 16:03:59---------------------------------------------------
1095cdf0e10cSrcweir
1096cdf0e10cSrcweir -----------------------------------------------------------------------*/
_FindStyle(const String & rStyleName) const1097cdf0e10cSrcweir SwXStyle* SwXStyleFamily::_FindStyle(const String& rStyleName)const
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir sal_uInt16 nLCount = pBasePool->GetListenerCount();
1100cdf0e10cSrcweir SfxListener* pListener = 0;
1101cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nLCount; i++)
1102cdf0e10cSrcweir {
1103cdf0e10cSrcweir pListener = pBasePool->GetListener( i );
1104cdf0e10cSrcweir SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>( pListener );
1105cdf0e10cSrcweir if(pTempStyle && pTempStyle->GetFamily() == eFamily && pTempStyle->GetStyleName() == rStyleName)
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir return pTempStyle;
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir return 0;
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir /******************************************************************
1113cdf0e10cSrcweir *
1114cdf0e10cSrcweir ******************************************************************/
1115cdf0e10cSrcweir class SwStyleProperties_Impl
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir const PropertyEntryVector_t aPropertyEntries;
1118cdf0e10cSrcweir uno::Any** pAnyArr;
1119cdf0e10cSrcweir sal_uInt32 nArrLen;
1120cdf0e10cSrcweir
1121cdf0e10cSrcweir public:
1122cdf0e10cSrcweir SwStyleProperties_Impl(const SfxItemPropertyMap* _pMap);
1123cdf0e10cSrcweir ~SwStyleProperties_Impl();
1124cdf0e10cSrcweir
1125cdf0e10cSrcweir sal_Bool SetProperty(const ::rtl::OUString& rName, uno::Any aVal);
1126cdf0e10cSrcweir sal_Bool GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny);
1127cdf0e10cSrcweir sal_Bool ClearProperty( const ::rtl::OUString& rPropertyName );
1128cdf0e10cSrcweir void ClearAllProperties( );
1129cdf0e10cSrcweir void GetProperty(const ::rtl::OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny );
1130cdf0e10cSrcweir
GetPropertyVector() const1131cdf0e10cSrcweir const PropertyEntryVector_t& GetPropertyVector() const {return aPropertyEntries; }
1132cdf0e10cSrcweir
1133cdf0e10cSrcweir };
1134cdf0e10cSrcweir //--------------------------------------------------------------------
1135cdf0e10cSrcweir //--------------------------------------------------------------------
SwStyleProperties_Impl(const SfxItemPropertyMap * pMap)1136cdf0e10cSrcweir SwStyleProperties_Impl::SwStyleProperties_Impl(const SfxItemPropertyMap* pMap) :
1137cdf0e10cSrcweir // _pMap(pMap),
1138cdf0e10cSrcweir aPropertyEntries( pMap->getPropertyEntries() ),
1139cdf0e10cSrcweir nArrLen(0)
1140cdf0e10cSrcweir {
1141cdf0e10cSrcweir nArrLen = aPropertyEntries.size();
1142cdf0e10cSrcweir //const SfxItemPropertyMap* pTmp = _pMap;
1143cdf0e10cSrcweir
1144cdf0e10cSrcweir pAnyArr = new uno::Any* [nArrLen];
1145cdf0e10cSrcweir for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
1146cdf0e10cSrcweir pAnyArr[i] = 0;
1147cdf0e10cSrcweir }
1148cdf0e10cSrcweir //--------------------------------------------------------------------
1149cdf0e10cSrcweir //--------------------------------------------------------------------
~SwStyleProperties_Impl()1150cdf0e10cSrcweir SwStyleProperties_Impl::~SwStyleProperties_Impl()
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir for ( sal_uInt16 i =0 ; i < nArrLen; i++ )
1153cdf0e10cSrcweir delete pAnyArr[i];
1154cdf0e10cSrcweir delete[] pAnyArr;
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir //--------------------------------------------------------------------
1158cdf0e10cSrcweir //--------------------------------------------------------------------
SetProperty(const::rtl::OUString & rName,uno::Any aVal)1159cdf0e10cSrcweir sal_Bool SwStyleProperties_Impl::SetProperty(const ::rtl::OUString& rName, uno::Any aVal)
1160cdf0e10cSrcweir {
1161cdf0e10cSrcweir sal_uInt16 nPos = 0;
1162cdf0e10cSrcweir sal_Bool bRet = sal_False;
1163cdf0e10cSrcweir PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1164cdf0e10cSrcweir while( aIt != aPropertyEntries.end() )
1165cdf0e10cSrcweir {
1166cdf0e10cSrcweir if(rName == aIt->sName)
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir delete pAnyArr[nPos];
1169cdf0e10cSrcweir pAnyArr[nPos] = new uno::Any ( aVal );
1170cdf0e10cSrcweir bRet = sal_True;
1171cdf0e10cSrcweir break;
1172cdf0e10cSrcweir }
1173cdf0e10cSrcweir ++nPos;
1174cdf0e10cSrcweir ++aIt;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir return bRet;
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir
ClearProperty(const OUString & rName)1179cdf0e10cSrcweir sal_Bool SwStyleProperties_Impl::ClearProperty( const OUString& rName )
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir sal_Bool bRet = sal_False;
1182cdf0e10cSrcweir sal_uInt16 nPos = 0;
1183cdf0e10cSrcweir PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1184cdf0e10cSrcweir while( aIt != aPropertyEntries.end() )
1185cdf0e10cSrcweir {
1186cdf0e10cSrcweir if( rName == aIt->sName )
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir delete pAnyArr[nPos];
1189cdf0e10cSrcweir pAnyArr[ nPos ] = 0;
1190cdf0e10cSrcweir bRet = sal_True;
1191cdf0e10cSrcweir break;
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir ++nPos;
1194cdf0e10cSrcweir ++aIt;
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir return bRet;
1197cdf0e10cSrcweir }
ClearAllProperties()1198cdf0e10cSrcweir void SwStyleProperties_Impl::ClearAllProperties( )
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nArrLen; i++ )
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir delete pAnyArr[i];
1203cdf0e10cSrcweir pAnyArr[ i ] = 0;
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir }
1206cdf0e10cSrcweir //--------------------------------------------------------------------
1207cdf0e10cSrcweir //--------------------------------------------------------------------
GetProperty(const::rtl::OUString & rName,uno::Any * & rpAny)1208cdf0e10cSrcweir sal_Bool SwStyleProperties_Impl::GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny )
1209cdf0e10cSrcweir {
1210cdf0e10cSrcweir sal_Bool bRet = sal_False;
1211cdf0e10cSrcweir sal_uInt16 nPos = 0;
1212cdf0e10cSrcweir PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1213cdf0e10cSrcweir while( aIt != aPropertyEntries.end() )
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir if( rName == aIt->sName )
1216cdf0e10cSrcweir {
1217cdf0e10cSrcweir rpAny = pAnyArr[nPos];
1218cdf0e10cSrcweir bRet = sal_True;
1219cdf0e10cSrcweir break;
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir ++nPos;
1222cdf0e10cSrcweir ++aIt;
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir
1225cdf0e10cSrcweir return bRet;
1226cdf0e10cSrcweir }
1227cdf0e10cSrcweir
GetProperty(const OUString & rPropertyName,const uno::Reference<beans::XPropertySet> & rxPropertySet,uno::Any & rAny)1228cdf0e10cSrcweir void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any & rAny )
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir rAny = rxPropertySet->getPropertyValue( rPropertyName );
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir /******************************************************************
1234cdf0e10cSrcweir *
1235cdf0e10cSrcweir ******************************************************************/
1236cdf0e10cSrcweir /* -----------------------------10.03.00 18:02--------------------------------
1237cdf0e10cSrcweir
1238cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getUnoTunnelId()1239cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SwXStyle::getUnoTunnelId()
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
1242cdf0e10cSrcweir return aSeq;
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir /* -----------------------------10.03.00 18:04--------------------------------
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getSomething(const uno::Sequence<sal_Int8> & rId)1247cdf0e10cSrcweir sal_Int64 SAL_CALL SwXStyle::getSomething( const uno::Sequence< sal_Int8 >& rId )
1248cdf0e10cSrcweir throw(uno::RuntimeException)
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir if( rId.getLength() == 16
1251cdf0e10cSrcweir && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1252cdf0e10cSrcweir rId.getConstArray(), 16 ) )
1253cdf0e10cSrcweir {
1254cdf0e10cSrcweir return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir return 0;
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir TYPEINIT1(SwXStyle, SfxListener);
1260cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getImplementationName(void)1263cdf0e10cSrcweir OUString SwXStyle::getImplementationName(void) throw( uno::RuntimeException )
1264cdf0e10cSrcweir {
1265cdf0e10cSrcweir return C2U("SwXStyle");
1266cdf0e10cSrcweir }
1267cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)1270cdf0e10cSrcweir sal_Bool SwXStyle::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir sal_Bool bRet = C2U("com.sun.star.style.Style") == rServiceName;
1273cdf0e10cSrcweir if(!bRet && SFX_STYLE_FAMILY_CHAR == eFamily)
1274cdf0e10cSrcweir bRet = !rServiceName.compareToAscii("com.sun.star.style.CharacterStyle")||
1275cdf0e10cSrcweir !rServiceName.compareToAscii("com.sun.star.style.CharacterProperties")||
1276cdf0e10cSrcweir !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesAsian")||
1277cdf0e10cSrcweir !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesComplex");
1278cdf0e10cSrcweir if(!bRet && SFX_STYLE_FAMILY_PARA == eFamily)
1279cdf0e10cSrcweir bRet = (C2U("com.sun.star.style.ParagraphStyle") == rServiceName)||
1280cdf0e10cSrcweir (C2U("com.sun.star.style.ParagraphProperties") == rServiceName) ||
1281cdf0e10cSrcweir (C2U("com.sun.star.style.ParagraphPropertiesAsian") == rServiceName) ||
1282cdf0e10cSrcweir (C2U("com.sun.star.style.ParagraphPropertiesComplex") == rServiceName);
1283cdf0e10cSrcweir if(!bRet && SFX_STYLE_FAMILY_PAGE == eFamily)
1284cdf0e10cSrcweir bRet = (C2U("com.sun.star.style.PageStyle") == rServiceName)||
1285cdf0e10cSrcweir (C2U("com.sun.star.style.PageProperties") == rServiceName);
1286cdf0e10cSrcweir
1287cdf0e10cSrcweir return bRet;
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir /* -----------------------------06.04.00 11:24--------------------------------
1290cdf0e10cSrcweir
1291cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)1292cdf0e10cSrcweir uno::Sequence< OUString > SwXStyle::getSupportedServiceNames(void) throw( uno::RuntimeException )
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir long nCount = 1;
1295cdf0e10cSrcweir if(SFX_STYLE_FAMILY_PARA == eFamily)
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir nCount = 5;
1298cdf0e10cSrcweir if(bIsConditional)
1299cdf0e10cSrcweir nCount++;
1300cdf0e10cSrcweir }
1301cdf0e10cSrcweir else if(SFX_STYLE_FAMILY_CHAR == eFamily)
1302cdf0e10cSrcweir nCount = 5;
1303cdf0e10cSrcweir else if(SFX_STYLE_FAMILY_PAGE == eFamily)
1304cdf0e10cSrcweir nCount = 3;
1305cdf0e10cSrcweir uno::Sequence< OUString > aRet(nCount);
1306cdf0e10cSrcweir OUString* pArray = aRet.getArray();
1307cdf0e10cSrcweir pArray[0] = C2U("com.sun.star.style.Style");
1308cdf0e10cSrcweir switch(eFamily)
1309cdf0e10cSrcweir {
1310cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
1311cdf0e10cSrcweir pArray[1] = C2U("com.sun.star.style.CharacterStyle");
1312cdf0e10cSrcweir pArray[2] = C2U("com.sun.star.style.CharacterProperties");
1313cdf0e10cSrcweir pArray[3] = C2U("com.sun.star.style.CharacterPropertiesAsian");
1314cdf0e10cSrcweir pArray[4] = C2U("com.sun.star.style.CharacterPropertiesComplex");
1315cdf0e10cSrcweir break;
1316cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
1317cdf0e10cSrcweir pArray[1] = C2U("com.sun.star.style.PageStyle");
1318cdf0e10cSrcweir pArray[2] = C2U("com.sun.star.style.PageProperties");
1319cdf0e10cSrcweir break;
1320cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
1321cdf0e10cSrcweir pArray[1] = C2U("com.sun.star.style.ParagraphStyle");
1322cdf0e10cSrcweir pArray[2] = C2U("com.sun.star.style.ParagraphProperties");
1323cdf0e10cSrcweir pArray[3] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
1324cdf0e10cSrcweir pArray[4] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
1325cdf0e10cSrcweir if(bIsConditional)
1326cdf0e10cSrcweir pArray[5] = C2U("com.sun.star.style.ConditionalParagraphStyle");
1327cdf0e10cSrcweir break;
1328cdf0e10cSrcweir
1329cdf0e10cSrcweir default:
1330cdf0e10cSrcweir ;
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir return aRet;
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir /*-- 17.12.98 08:26:49---------------------------------------------------
1335cdf0e10cSrcweir
1336cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXStyle(SwDoc * pDoc,SfxStyleFamily eFam,sal_Bool bConditional)1337cdf0e10cSrcweir SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, sal_Bool bConditional) :
1338cdf0e10cSrcweir m_pDoc( pDoc ),
1339cdf0e10cSrcweir pBasePool(0),
1340cdf0e10cSrcweir eFamily(eFam),
1341cdf0e10cSrcweir bIsDescriptor(sal_True),
1342cdf0e10cSrcweir bIsConditional(bConditional)
1343cdf0e10cSrcweir {
1344cdf0e10cSrcweir // Register ourselves as a listener to the document (via the page descriptor)
1345cdf0e10cSrcweir pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1346cdf0e10cSrcweir // get the property set for the default style data
1347cdf0e10cSrcweir // First get the model
1348cdf0e10cSrcweir uno::Reference < frame::XModel > xModel = pDoc->GetDocShell()->GetBaseModel();
1349cdf0e10cSrcweir // Ask the model for it's family supplier interface
1350cdf0e10cSrcweir uno::Reference < style::XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY );
1351cdf0e10cSrcweir // Get the style families
1352cdf0e10cSrcweir uno::Reference < container::XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies();
1353cdf0e10cSrcweir
1354cdf0e10cSrcweir uno::Any aAny;
1355cdf0e10cSrcweir sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE;
1356cdf0e10cSrcweir switch( eFamily )
1357cdf0e10cSrcweir {
1358cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir nMapId = PROPERTY_MAP_CHAR_STYLE;
1361cdf0e10cSrcweir aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "CharacterStyles" ) ) );
1362cdf0e10cSrcweir // Get the Frame family (and keep it for later)
1363cdf0e10cSrcweir aAny >>= mxStyleFamily;
1364cdf0e10cSrcweir //aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1365cdf0e10cSrcweir //aAny >>= mxStyleData;
1366cdf0e10cSrcweir }
1367cdf0e10cSrcweir break;
1368cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
1371cdf0e10cSrcweir aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ParagraphStyles" ) ) );
1372cdf0e10cSrcweir // Get the Frame family (and keep it for later)
1373cdf0e10cSrcweir aAny >>= mxStyleFamily;
1374cdf0e10cSrcweir aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1375cdf0e10cSrcweir aAny >>= mxStyleData;
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir break;
1378cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir nMapId = PROPERTY_MAP_PAGE_STYLE;
1381cdf0e10cSrcweir aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "PageStyles" ) ) );
1382cdf0e10cSrcweir // Get the Frame family (and keep it for later)
1383cdf0e10cSrcweir aAny >>= mxStyleFamily;
1384cdf0e10cSrcweir aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1385cdf0e10cSrcweir aAny >>= mxStyleData;
1386cdf0e10cSrcweir }
1387cdf0e10cSrcweir break;
1388cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME :
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir nMapId = PROPERTY_MAP_FRAME_STYLE;
1391cdf0e10cSrcweir }
1392cdf0e10cSrcweir break;
1393cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
1394cdf0e10cSrcweir {
1395cdf0e10cSrcweir nMapId = PROPERTY_MAP_NUM_STYLE;
1396cdf0e10cSrcweir }
1397cdf0e10cSrcweir break;
1398cdf0e10cSrcweir
1399cdf0e10cSrcweir default:
1400cdf0e10cSrcweir ;
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir pPropImpl = new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap());
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir
1405cdf0e10cSrcweir
SwXStyle(SfxStyleSheetBasePool & rPool,SfxStyleFamily eFam,SwDoc * pDoc,const String & rStyleName)1406cdf0e10cSrcweir SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam,
1407cdf0e10cSrcweir SwDoc* pDoc, const String& rStyleName) :
1408cdf0e10cSrcweir m_pDoc(pDoc),
1409cdf0e10cSrcweir sStyleName(rStyleName),
1410cdf0e10cSrcweir pBasePool(&rPool),
1411cdf0e10cSrcweir eFamily(eFam),
1412cdf0e10cSrcweir bIsDescriptor(sal_False),
1413cdf0e10cSrcweir bIsConditional(sal_False),
1414cdf0e10cSrcweir pPropImpl(0)
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir StartListening(rPool);
1417cdf0e10cSrcweir if(eFam == SFX_STYLE_FAMILY_PARA)
1418cdf0e10cSrcweir {
1419cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1420cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1421cdf0e10cSrcweir DBG_ASSERT(pBase, "where is the style?" );
1422cdf0e10cSrcweir if(pBase)
1423cdf0e10cSrcweir {
1424cdf0e10cSrcweir const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
1425cdf0e10cSrcweir if(nId != USHRT_MAX)
1426cdf0e10cSrcweir bIsConditional = ::IsConditionalByPoolId( nId );
1427cdf0e10cSrcweir else
1428cdf0e10cSrcweir bIsConditional = RES_CONDTXTFMTCOLL == ((SwDocStyleSheet*)pBase)->GetCollection()->Which();
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir }
1432cdf0e10cSrcweir /*-- 17.12.98 08:26:50---------------------------------------------------
1433cdf0e10cSrcweir
1434cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXStyle()1435cdf0e10cSrcweir SwXStyle::~SwXStyle()
1436cdf0e10cSrcweir {
1437cdf0e10cSrcweir if(pBasePool)
1438cdf0e10cSrcweir EndListening(*pBasePool);
1439cdf0e10cSrcweir delete pPropImpl;
1440cdf0e10cSrcweir }
1441cdf0e10cSrcweir /*-- 17.12.98 08:26:51---------------------------------------------------
1442cdf0e10cSrcweir
1443cdf0e10cSrcweir -----------------------------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)1444cdf0e10cSrcweir void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir ClientModify(this, pOld, pNew);
1447cdf0e10cSrcweir if(!GetRegisteredIn())
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir m_pDoc = 0;
1450cdf0e10cSrcweir mxStyleData.clear();
1451cdf0e10cSrcweir mxStyleFamily.clear();
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir }
getName(void)1454cdf0e10cSrcweir OUString SwXStyle::getName(void) throw( uno::RuntimeException )
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1457cdf0e10cSrcweir String aString;
1458cdf0e10cSrcweir if(pBasePool)
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1461cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1462cdf0e10cSrcweir DBG_ASSERT(pBase, "where is the style?" );
1463cdf0e10cSrcweir if(!pBase)
1464cdf0e10cSrcweir throw uno::RuntimeException();
1465cdf0e10cSrcweir SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
1466cdf0e10cSrcweir }
1467cdf0e10cSrcweir else
1468cdf0e10cSrcweir aString = sStyleName;
1469cdf0e10cSrcweir return OUString (aString);
1470cdf0e10cSrcweir }
1471cdf0e10cSrcweir /*-- 17.12.98 08:26:51---------------------------------------------------
1472cdf0e10cSrcweir
1473cdf0e10cSrcweir -----------------------------------------------------------------------*/
setName(const OUString & rName)1474cdf0e10cSrcweir void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException )
1475cdf0e10cSrcweir {
1476cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1477cdf0e10cSrcweir if(pBasePool)
1478cdf0e10cSrcweir {
1479cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1480cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1481cdf0e10cSrcweir DBG_ASSERT(pBase, "where is the style?" );
1482cdf0e10cSrcweir sal_Bool bExcept = sal_True;
1483cdf0e10cSrcweir if(pBase && pBase->IsUserDefined())
1484cdf0e10cSrcweir {
1485cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
1486cdf0e10cSrcweir bExcept = !xTmp->SetName(rName);
1487cdf0e10cSrcweir if(!bExcept)
1488cdf0e10cSrcweir sStyleName = String(rName);
1489cdf0e10cSrcweir }
1490cdf0e10cSrcweir if(bExcept)
1491cdf0e10cSrcweir throw uno::RuntimeException();
1492cdf0e10cSrcweir }
1493cdf0e10cSrcweir else
1494cdf0e10cSrcweir sStyleName = String(rName);
1495cdf0e10cSrcweir }
1496cdf0e10cSrcweir /*-- 17.12.98 08:26:51---------------------------------------------------
1497cdf0e10cSrcweir
1498cdf0e10cSrcweir -----------------------------------------------------------------------*/
isUserDefined(void)1499cdf0e10cSrcweir sal_Bool SwXStyle::isUserDefined(void) throw( uno::RuntimeException )
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1502cdf0e10cSrcweir sal_Bool bRet = sal_False;
1503cdf0e10cSrcweir if(pBasePool)
1504cdf0e10cSrcweir {
1505cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1506cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1507cdf0e10cSrcweir //if it is not found it must be non user defined
1508cdf0e10cSrcweir if(pBase)
1509cdf0e10cSrcweir bRet = pBase->IsUserDefined();
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir else
1512cdf0e10cSrcweir throw uno::RuntimeException();
1513cdf0e10cSrcweir return bRet;
1514cdf0e10cSrcweir }
1515cdf0e10cSrcweir /*-- 17.12.98 08:26:51---------------------------------------------------
1516cdf0e10cSrcweir
1517cdf0e10cSrcweir -----------------------------------------------------------------------*/
isInUse(void)1518cdf0e10cSrcweir sal_Bool SwXStyle::isInUse(void) throw( uno::RuntimeException )
1519cdf0e10cSrcweir {
1520cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1521cdf0e10cSrcweir sal_Bool bRet = sal_False;
1522cdf0e10cSrcweir if(pBasePool)
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_USED);
1525cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1526cdf0e10cSrcweir if(pBase)
1527cdf0e10cSrcweir bRet = pBase->IsUsed();
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir else
1530cdf0e10cSrcweir throw uno::RuntimeException();
1531cdf0e10cSrcweir return bRet;
1532cdf0e10cSrcweir }
1533cdf0e10cSrcweir /*-- 17.12.98 08:26:52---------------------------------------------------
1534cdf0e10cSrcweir
1535cdf0e10cSrcweir -----------------------------------------------------------------------*/
getParentStyle(void)1536cdf0e10cSrcweir OUString SwXStyle::getParentStyle(void) throw( uno::RuntimeException )
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1539cdf0e10cSrcweir String aString;
1540cdf0e10cSrcweir if(pBasePool)
1541cdf0e10cSrcweir {
1542cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL);
1543cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1544cdf0e10cSrcweir if(pBase)
1545cdf0e10cSrcweir aString = pBase->GetParent();
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir else if(bIsDescriptor)
1548cdf0e10cSrcweir aString = sParentStyleName;
1549cdf0e10cSrcweir else
1550cdf0e10cSrcweir throw uno::RuntimeException();
1551cdf0e10cSrcweir SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1552cdf0e10cSrcweir return OUString ( aString );
1553cdf0e10cSrcweir }
1554cdf0e10cSrcweir /*-- 17.12.98 08:26:52---------------------------------------------------
1555cdf0e10cSrcweir
1556cdf0e10cSrcweir -----------------------------------------------------------------------*/
setParentStyle(const OUString & rParentStyle)1557cdf0e10cSrcweir void SwXStyle::setParentStyle(const OUString& rParentStyle)
1558cdf0e10cSrcweir throw( container::NoSuchElementException, uno::RuntimeException )
1559cdf0e10cSrcweir {
1560cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1561cdf0e10cSrcweir String sParentStyle;
1562cdf0e10cSrcweir SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1563cdf0e10cSrcweir if(pBasePool)
1564cdf0e10cSrcweir {
1565cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily);
1566cdf0e10cSrcweir sal_Bool bExcept = sal_False;
1567cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1568cdf0e10cSrcweir if(pBase)
1569cdf0e10cSrcweir {
1570cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
1571cdf0e10cSrcweir //make it a 'real' style - necessary for pooled styles
1572cdf0e10cSrcweir xBase->GetItemSet();
1573cdf0e10cSrcweir if(xBase->GetParent() != sParentStyle)
1574cdf0e10cSrcweir {
1575cdf0e10cSrcweir bExcept = !xBase->SetParent(sParentStyle);
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir else
1579cdf0e10cSrcweir bExcept = sal_True;
1580cdf0e10cSrcweir if(bExcept)
1581cdf0e10cSrcweir throw uno::RuntimeException();
1582cdf0e10cSrcweir }
1583cdf0e10cSrcweir else if(bIsDescriptor)
1584cdf0e10cSrcweir {
1585cdf0e10cSrcweir sParentStyleName = String(sParentStyle);
1586cdf0e10cSrcweir try
1587cdf0e10cSrcweir {
1588cdf0e10cSrcweir uno::Any aAny = mxStyleFamily->getByName ( sParentStyle );
1589cdf0e10cSrcweir aAny >>= mxStyleData;
1590cdf0e10cSrcweir }
1591cdf0e10cSrcweir catch ( container::NoSuchElementException& )
1592cdf0e10cSrcweir {
1593cdf0e10cSrcweir }
1594cdf0e10cSrcweir catch ( lang::WrappedTargetException& )
1595cdf0e10cSrcweir {
1596cdf0e10cSrcweir }
1597cdf0e10cSrcweir catch ( uno::RuntimeException& )
1598cdf0e10cSrcweir {
1599cdf0e10cSrcweir }
1600cdf0e10cSrcweir }
1601cdf0e10cSrcweir else
1602cdf0e10cSrcweir throw uno::RuntimeException();
1603cdf0e10cSrcweir }
1604cdf0e10cSrcweir /*-- 17.12.98 08:26:52---------------------------------------------------
1605cdf0e10cSrcweir
1606cdf0e10cSrcweir -----------------------------------------------------------------------*/
1607cdf0e10cSrcweir
lcl_getPropertySetInfo(SfxStyleFamily eFamily,sal_Bool bIsConditional)1608cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, sal_Bool bIsConditional )
1609cdf0e10cSrcweir {
1610cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xRet;
1611cdf0e10cSrcweir switch( eFamily )
1612cdf0e10cSrcweir {
1613cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
1614cdf0e10cSrcweir {
1615cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xCharRef;
1616cdf0e10cSrcweir if(!xCharRef.is())
1617cdf0e10cSrcweir {
1618cdf0e10cSrcweir xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_STYLE)->getPropertySetInfo();
1619cdf0e10cSrcweir }
1620cdf0e10cSrcweir xRet = xCharRef;
1621cdf0e10cSrcweir }
1622cdf0e10cSrcweir break;
1623cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
1624cdf0e10cSrcweir {
1625cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xParaRef;
1626cdf0e10cSrcweir if(!xParaRef.is())
1627cdf0e10cSrcweir {
1628cdf0e10cSrcweir sal_uInt16 nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
1629cdf0e10cSrcweir xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir xRet = xParaRef;
1632cdf0e10cSrcweir }
1633cdf0e10cSrcweir break;
1634cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE :
1635cdf0e10cSrcweir {
1636cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xPageRef;
1637cdf0e10cSrcweir if(!xPageRef.is())
1638cdf0e10cSrcweir {
1639cdf0e10cSrcweir xPageRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE)->getPropertySetInfo();
1640cdf0e10cSrcweir }
1641cdf0e10cSrcweir xRet = xPageRef;
1642cdf0e10cSrcweir }
1643cdf0e10cSrcweir break;
1644cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME :
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xFrameRef;
1647cdf0e10cSrcweir if(!xFrameRef.is())
1648cdf0e10cSrcweir {
1649cdf0e10cSrcweir xFrameRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FRAME_STYLE)->getPropertySetInfo();
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir xRet = xFrameRef;
1652cdf0e10cSrcweir }
1653cdf0e10cSrcweir break;
1654cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
1655cdf0e10cSrcweir {
1656cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xNumRef;
1657cdf0e10cSrcweir if(!xNumRef.is())
1658cdf0e10cSrcweir {
1659cdf0e10cSrcweir xNumRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_NUM_STYLE)->getPropertySetInfo();
1660cdf0e10cSrcweir }
1661cdf0e10cSrcweir xRet = xNumRef;
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir break;
1664cdf0e10cSrcweir
1665cdf0e10cSrcweir default:
1666cdf0e10cSrcweir ;
1667cdf0e10cSrcweir }
1668cdf0e10cSrcweir return xRet;
1669cdf0e10cSrcweir }
1670cdf0e10cSrcweir
getPropertySetInfo(void)1671cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo(void)
1672cdf0e10cSrcweir throw( uno::RuntimeException )
1673cdf0e10cSrcweir {
1674cdf0e10cSrcweir return lcl_getPropertySetInfo( eFamily, bIsConditional );
1675cdf0e10cSrcweir }
1676cdf0e10cSrcweir /* -----------------23.04.99 13:28-------------------
1677cdf0e10cSrcweir *
1678cdf0e10cSrcweir * --------------------------------------------------*/
ApplyDescriptorProperties()1679cdf0e10cSrcweir void SwXStyle::ApplyDescriptorProperties()
1680cdf0e10cSrcweir {
1681cdf0e10cSrcweir bIsDescriptor = sal_False;
1682cdf0e10cSrcweir mxStyleData.clear();
1683cdf0e10cSrcweir mxStyleFamily.clear();
1684cdf0e10cSrcweir
1685cdf0e10cSrcweir const PropertyEntryVector_t& rPropertyVector = pPropImpl->GetPropertyVector();
1686cdf0e10cSrcweir PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin();
1687cdf0e10cSrcweir while(aIt != rPropertyVector.end())
1688cdf0e10cSrcweir {
1689cdf0e10cSrcweir uno::Any* pAny;
1690cdf0e10cSrcweir pPropImpl->GetProperty(aIt->sName, pAny);
1691cdf0e10cSrcweir if(pAny)
1692cdf0e10cSrcweir setPropertyValue(aIt->sName, *pAny);
1693cdf0e10cSrcweir ++aIt;
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir }
1696cdf0e10cSrcweir
1697cdf0e10cSrcweir /*-- 18.04.01 13:07:27---------------------------------------------------
1698cdf0e10cSrcweir
1699cdf0e10cSrcweir -----------------------------------------------------------------------*/
170056b35d86SArmin Le Grand class SwStyleBase_Impl
1701cdf0e10cSrcweir {
170256b35d86SArmin Le Grand private:
170356b35d86SArmin Le Grand SwDoc& mrDoc;
170456b35d86SArmin Le Grand const SwPageDesc* mpOldPageDesc;
1705cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > mxNewBase;
170656b35d86SArmin Le Grand SfxItemSet* mpItemSet;
170756b35d86SArmin Le Grand const String& mrStyleName;
170856b35d86SArmin Le Grand sal_uInt16 mnPDescPos;
170956b35d86SArmin Le Grand const SwAttrSet* mpParentStyle;
1710cdf0e10cSrcweir
171156b35d86SArmin Le Grand public:
SwStyleBase_Impl(SwDoc & rSwDoc,const String & rName,const SwAttrSet * pParentStyle)171256b35d86SArmin Le Grand SwStyleBase_Impl(
171356b35d86SArmin Le Grand SwDoc& rSwDoc,
171456b35d86SArmin Le Grand const String& rName,
171556b35d86SArmin Le Grand const SwAttrSet* pParentStyle)
171656b35d86SArmin Le Grand : mrDoc(rSwDoc),
171756b35d86SArmin Le Grand mpOldPageDesc(0),
171856b35d86SArmin Le Grand mxNewBase(),
171956b35d86SArmin Le Grand mpItemSet(0),
172056b35d86SArmin Le Grand mrStyleName(rName),
172156b35d86SArmin Le Grand mnPDescPos(0xffff),
172256b35d86SArmin Le Grand mpParentStyle(pParentStyle)
172356b35d86SArmin Le Grand {
172456b35d86SArmin Le Grand }
1725cdf0e10cSrcweir
~SwStyleBase_Impl()172656b35d86SArmin Le Grand ~SwStyleBase_Impl()
172756b35d86SArmin Le Grand {
172856b35d86SArmin Le Grand delete mpItemSet;
172956b35d86SArmin Le Grand }
1730cdf0e10cSrcweir
getNewBase()173156b35d86SArmin Le Grand rtl::Reference< SwDocStyleSheet >& getNewBase()
173256b35d86SArmin Le Grand {
173356b35d86SArmin Le Grand return mxNewBase;
173456b35d86SArmin Le Grand }
1735cdf0e10cSrcweir
setNewBase(SwDocStyleSheet * pNew)173656b35d86SArmin Le Grand void setNewBase(SwDocStyleSheet* pNew)
173756b35d86SArmin Le Grand {
173856b35d86SArmin Le Grand mxNewBase = pNew;
173956b35d86SArmin Le Grand }
174056b35d86SArmin Le Grand
HasItemSet()174156b35d86SArmin Le Grand sal_Bool HasItemSet()
174256b35d86SArmin Le Grand {
174356b35d86SArmin Le Grand return mxNewBase.is();
174456b35d86SArmin Le Grand }
174556b35d86SArmin Le Grand
replaceItemSet(SfxItemSet * pNew)174656b35d86SArmin Le Grand SfxItemSet* replaceItemSet(SfxItemSet* pNew)
174756b35d86SArmin Le Grand {
174856b35d86SArmin Le Grand SfxItemSet* pRetval = mpItemSet;
174956b35d86SArmin Le Grand mpItemSet = pNew;
175056b35d86SArmin Le Grand return pRetval;
175156b35d86SArmin Le Grand }
175256b35d86SArmin Le Grand
GetItemSet()1753cdf0e10cSrcweir SfxItemSet& GetItemSet()
1754cdf0e10cSrcweir {
1755cdf0e10cSrcweir DBG_ASSERT(mxNewBase.is(), "no SwDocStyleSheet available");
175656b35d86SArmin Le Grand
175756b35d86SArmin Le Grand if(!mpItemSet)
175856b35d86SArmin Le Grand {
175956b35d86SArmin Le Grand mpItemSet = new SfxItemSet(mxNewBase->GetItemSet());
176056b35d86SArmin Le Grand
176156b35d86SArmin Le Grand //UUUU set parent style to have the correct XFillStyle setting as XFILL_NONE
176256b35d86SArmin Le Grand if(!mpItemSet->GetParent() && mpParentStyle)
176356b35d86SArmin Le Grand {
176456b35d86SArmin Le Grand mpItemSet->SetParent(mpParentStyle);
176556b35d86SArmin Le Grand }
176656b35d86SArmin Le Grand }
176756b35d86SArmin Le Grand
176856b35d86SArmin Le Grand return *mpItemSet;
1769cdf0e10cSrcweir }
1770cdf0e10cSrcweir
1771cdf0e10cSrcweir const SwPageDesc& GetOldPageDesc();
1772cdf0e10cSrcweir };
1773cdf0e10cSrcweir /* -----------------------------25.04.01 12:44--------------------------------
1774cdf0e10cSrcweir
1775cdf0e10cSrcweir ---------------------------------------------------------------------------*/
GetOldPageDesc()1776cdf0e10cSrcweir const SwPageDesc& SwStyleBase_Impl::GetOldPageDesc()
1777cdf0e10cSrcweir {
177856b35d86SArmin Le Grand if(!mpOldPageDesc)
1779cdf0e10cSrcweir {
1780cdf0e10cSrcweir sal_uInt16 i;
178156b35d86SArmin Le Grand sal_uInt16 nPDescCount = mrDoc.GetPageDescCnt();
1782cdf0e10cSrcweir for(i = 0; i < nPDescCount; i++)
1783cdf0e10cSrcweir {
1784cdf0e10cSrcweir const SwPageDesc& rDesc =
178556b35d86SArmin Le Grand const_cast<const SwDoc &>(mrDoc).GetPageDesc( i );
178656b35d86SArmin Le Grand if(rDesc.GetName() == mrStyleName)
1787cdf0e10cSrcweir {
178856b35d86SArmin Le Grand mpOldPageDesc = & rDesc;
178956b35d86SArmin Le Grand mnPDescPos = i;
1790cdf0e10cSrcweir break;
1791cdf0e10cSrcweir }
1792cdf0e10cSrcweir }
179356b35d86SArmin Le Grand if(!mpOldPageDesc)
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir for(i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i)
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir const String aFmtName(SW_RES(i));
179856b35d86SArmin Le Grand if(aFmtName == mrStyleName)
1799cdf0e10cSrcweir {
180056b35d86SArmin Le Grand mpOldPageDesc = mrDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) );
1801cdf0e10cSrcweir break;
1802cdf0e10cSrcweir }
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir for(i = 0; i < nPDescCount + 1; i++)
1805cdf0e10cSrcweir {
1806cdf0e10cSrcweir const SwPageDesc& rDesc =
180756b35d86SArmin Le Grand const_cast<const SwDoc &>(mrDoc).GetPageDesc( i );
180856b35d86SArmin Le Grand if(rDesc.GetName() == mrStyleName)
1809cdf0e10cSrcweir {
181056b35d86SArmin Le Grand mnPDescPos = i;
1811cdf0e10cSrcweir break;
1812cdf0e10cSrcweir }
1813cdf0e10cSrcweir }
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir }
181656b35d86SArmin Le Grand return *mpOldPageDesc;
1817cdf0e10cSrcweir }
1818cdf0e10cSrcweir
1819cdf0e10cSrcweir /* -----------------------------19.04.01 09:44--------------------------------
1820cdf0e10cSrcweir
1821cdf0e10cSrcweir ---------------------------------------------------------------------------*/
1822cdf0e10cSrcweir
lcl_SetStyleProperty(const SfxItemPropertySimpleEntry & rEntry,const SfxItemPropertySet & rPropSet,const uno::Any & rValue,SwStyleBase_Impl & rBase,SfxStyleSheetBasePool * pBasePool,SwDoc * pDoc,SfxStyleFamily eFamily)182356b35d86SArmin Le Grand void lcl_SetStyleProperty(
182456b35d86SArmin Le Grand const SfxItemPropertySimpleEntry& rEntry,
1825cdf0e10cSrcweir const SfxItemPropertySet& rPropSet,
1826cdf0e10cSrcweir const uno::Any& rValue,
1827cdf0e10cSrcweir SwStyleBase_Impl& rBase,
1828cdf0e10cSrcweir SfxStyleSheetBasePool* pBasePool,
1829cdf0e10cSrcweir SwDoc* pDoc,
1830cdf0e10cSrcweir SfxStyleFamily eFamily)
183156b35d86SArmin Le Grand throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
1832cdf0e10cSrcweir {
183364b14621SArmin Le Grand //UUUU adapted switch logic to a more readable state; removed goto's and made
183464b14621SArmin Le Grand // execution of standard setting of proerty in ItemSet dependent of this variable
183564b14621SArmin Le Grand bool bDone(false);
183664b14621SArmin Le Grand
183764b14621SArmin Le Grand //UUUU
183864b14621SArmin Le Grand const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
183964b14621SArmin Le Grand uno::Any aValue(rValue);
184064b14621SArmin Le Grand
184164b14621SArmin Le Grand //UUUU check for needed metric translation
184264b14621SArmin Le Grand if(rEntry.nMemberId & SFX_METRIC_ITEM)
184364b14621SArmin Le Grand {
184464b14621SArmin Le Grand bool bDoIt(true);
184564b14621SArmin Le Grand
184664b14621SArmin Le Grand if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
184764b14621SArmin Le Grand {
184864b14621SArmin Le Grand // exception: If these ItemTypes are used, do not convert when these are negative
184964b14621SArmin Le Grand // since this means they are intended as percent values
185064b14621SArmin Le Grand sal_Int32 nValue = 0;
185164b14621SArmin Le Grand
185264b14621SArmin Le Grand if(aValue >>= nValue)
185364b14621SArmin Le Grand {
185464b14621SArmin Le Grand bDoIt = nValue > 0;
185564b14621SArmin Le Grand }
185664b14621SArmin Le Grand }
185764b14621SArmin Le Grand
185864b14621SArmin Le Grand if(bDoIt && pDoc)
185964b14621SArmin Le Grand {
186064b14621SArmin Le Grand const SfxItemPool& rPool = pDoc->GetAttrPool();
186164b14621SArmin Le Grand const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID));
186264b14621SArmin Le Grand
186364b14621SArmin Le Grand if(eMapUnit != SFX_MAPUNIT_100TH_MM)
186464b14621SArmin Le Grand {
186564b14621SArmin Le Grand SvxUnoConvertFromMM(eMapUnit, aValue);
186664b14621SArmin Le Grand }
186764b14621SArmin Le Grand }
186864b14621SArmin Le Grand }
186964b14621SArmin Le Grand
1870cdf0e10cSrcweir switch(rEntry.nWID)
1871cdf0e10cSrcweir {
187264b14621SArmin Le Grand case XATTR_FILLGRADIENT:
187364b14621SArmin Le Grand case XATTR_FILLHATCH:
187456b35d86SArmin Le Grand case XATTR_FILLBITMAP:
187564b14621SArmin Le Grand case XATTR_FILLFLOATTRANSPARENCE:
187664b14621SArmin Le Grand // not yet needed; activate when LineStyle support may be added
187764b14621SArmin Le Grand // case XATTR_LINESTART:
187864b14621SArmin Le Grand // case XATTR_LINEEND:
187964b14621SArmin Le Grand // case XATTR_LINEDASH:
188064b14621SArmin Le Grand {
188164b14621SArmin Le Grand if(MID_NAME == nMemberId)
188264b14621SArmin Le Grand {
188356b35d86SArmin Le Grand //UUUU add set commands for FillName items
188464b14621SArmin Le Grand OUString aTempName;
188564b14621SArmin Le Grand SfxItemSet& rStyleSet = rBase.GetItemSet();
188664b14621SArmin Le Grand
188764b14621SArmin Le Grand if(!(aValue >>= aTempName))
188864b14621SArmin Le Grand {
188964b14621SArmin Le Grand throw lang::IllegalArgumentException();
189064b14621SArmin Le Grand }
189164b14621SArmin Le Grand
189264b14621SArmin Le Grand SvxShape::SetFillAttribute(rEntry.nWID, aTempName, rStyleSet);
189364b14621SArmin Le Grand bDone = true;
189464b14621SArmin Le Grand }
189556b35d86SArmin Le Grand else if(MID_GRAFURL == nMemberId)
189656b35d86SArmin Le Grand {
189756b35d86SArmin Le Grand if(XATTR_FILLBITMAP == rEntry.nWID)
189856b35d86SArmin Le Grand {
189956b35d86SArmin Le Grand //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used
190056b35d86SArmin Le Grand const Graphic aNullGraphic;
190156b35d86SArmin Le Grand SfxItemSet& rStyleSet = rBase.GetItemSet();
190256b35d86SArmin Le Grand XFillBitmapItem aXFillBitmapItem(rStyleSet.GetPool(), aNullGraphic);
190356b35d86SArmin Le Grand
190456b35d86SArmin Le Grand aXFillBitmapItem.PutValue(aValue, nMemberId);
190556b35d86SArmin Le Grand rStyleSet.Put(aXFillBitmapItem);
190656b35d86SArmin Le Grand bDone = true;
190756b35d86SArmin Le Grand }
190856b35d86SArmin Le Grand }
190964b14621SArmin Le Grand
191064b14621SArmin Le Grand break;
191164b14621SArmin Le Grand }
191264b14621SArmin Le Grand case RES_BACKGROUND:
191364b14621SArmin Le Grand {
191464b14621SArmin Le Grand //UUUU
191564b14621SArmin Le Grand SfxItemSet& rStyleSet = rBase.GetItemSet();
191656b35d86SArmin Le Grand const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rStyleSet, RES_BACKGROUND));
191764b14621SArmin Le Grand SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
191864b14621SArmin Le Grand
191964b14621SArmin Le Grand aChangedBrushItem.PutValue(aValue, nMemberId);
192064b14621SArmin Le Grand
192164b14621SArmin Le Grand if(!(aChangedBrushItem == aOriginalBrushItem))
192264b14621SArmin Le Grand {
192364b14621SArmin Le Grand setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, rStyleSet);
192464b14621SArmin Le Grand }
192564b14621SArmin Le Grand
192664b14621SArmin Le Grand bDone = true;
192764b14621SArmin Le Grand break;
192864b14621SArmin Le Grand }
192964b14621SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
193064b14621SArmin Le Grand {
193164b14621SArmin Le Grand //UUUU
193264b14621SArmin Le Grand drawing::BitmapMode eMode;
193364b14621SArmin Le Grand
193464b14621SArmin Le Grand if(!(aValue >>= eMode))
193564b14621SArmin Le Grand {
193664b14621SArmin Le Grand sal_Int32 nMode = 0;
193764b14621SArmin Le Grand
193864b14621SArmin Le Grand if(!(aValue >>= nMode))
193964b14621SArmin Le Grand {
194064b14621SArmin Le Grand throw lang::IllegalArgumentException();
194164b14621SArmin Le Grand }
194264b14621SArmin Le Grand
194364b14621SArmin Le Grand eMode = (drawing::BitmapMode)nMode;
194464b14621SArmin Le Grand }
194564b14621SArmin Le Grand
194664b14621SArmin Le Grand SfxItemSet& rStyleSet = rBase.GetItemSet();
194764b14621SArmin Le Grand
194864b14621SArmin Le Grand rStyleSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode));
194964b14621SArmin Le Grand rStyleSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode));
195064b14621SArmin Le Grand
195164b14621SArmin Le Grand bDone = true;
195264b14621SArmin Le Grand break;
195364b14621SArmin Le Grand }
1954cdf0e10cSrcweir case RES_PAPER_BIN:
1955cdf0e10cSrcweir {
1956cdf0e10cSrcweir SfxPrinter *pPrinter = pDoc->getPrinter( true );
1957cdf0e10cSrcweir OUString sTmp;
1958cdf0e10cSrcweir sal_uInt16 nBin = USHRT_MAX;
195964b14621SArmin Le Grand if ( !( aValue >>= sTmp ) )
1960cdf0e10cSrcweir throw lang::IllegalArgumentException();
1961cdf0e10cSrcweir if ( sTmp.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "[From printer settings]" ) ) )
1962cdf0e10cSrcweir nBin = USHRT_MAX-1;
1963cdf0e10cSrcweir else if ( pPrinter )
1964cdf0e10cSrcweir {
1965cdf0e10cSrcweir for (sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; i++ )
1966cdf0e10cSrcweir {
1967cdf0e10cSrcweir if (sTmp == OUString ( pPrinter->GetPaperBinName ( i ) ) )
1968cdf0e10cSrcweir {
1969cdf0e10cSrcweir nBin = i;
1970cdf0e10cSrcweir break;
1971cdf0e10cSrcweir }
1972cdf0e10cSrcweir }
1973cdf0e10cSrcweir }
1974cdf0e10cSrcweir if ( nBin == USHRT_MAX )
1975cdf0e10cSrcweir throw lang::IllegalArgumentException();
1976cdf0e10cSrcweir else
1977cdf0e10cSrcweir {
1978cdf0e10cSrcweir SfxItemSet& rStyleSet = rBase.GetItemSet();
1979cdf0e10cSrcweir SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
1980cdf0e10cSrcweir aSet.SetParent(&rStyleSet);
1981cdf0e10cSrcweir rPropSet.setPropertyValue(rEntry, uno::makeAny ( static_cast < sal_Int8 > ( nBin == USHRT_MAX-1 ? -1 : nBin ) ), aSet);
1982cdf0e10cSrcweir rStyleSet.Put(aSet);
1983cdf0e10cSrcweir }
198464b14621SArmin Le Grand
198564b14621SArmin Le Grand bDone = true;
1986cdf0e10cSrcweir break;
198764b14621SArmin Le Grand }
1988cdf0e10cSrcweir case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem:
1989cdf0e10cSrcweir {
199064b14621SArmin Le Grand if(aValue.getValueType() == ::getCppuType((uno::Reference< container::XIndexReplace>*)0) )
1991cdf0e10cSrcweir {
1992cdf0e10cSrcweir uno::Reference< container::XIndexReplace > * pxRulesRef =
199364b14621SArmin Le Grand (uno::Reference< container::XIndexReplace > *)aValue.getValue();
1994cdf0e10cSrcweir
1995cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xNumberTunnel( *pxRulesRef, uno::UNO_QUERY);
1996cdf0e10cSrcweir
1997cdf0e10cSrcweir SwXNumberingRules* pSwXRules = 0;
1998cdf0e10cSrcweir if(xNumberTunnel.is())
1999cdf0e10cSrcweir {
2000cdf0e10cSrcweir pSwXRules = reinterpret_cast< SwXNumberingRules * >(
2001cdf0e10cSrcweir sal::static_int_cast< sal_IntPtr >(xNumberTunnel->getSomething( SwXNumberingRules::getUnoTunnelId()) ));
2002cdf0e10cSrcweir }
2003cdf0e10cSrcweir if(pSwXRules)
2004cdf0e10cSrcweir {
2005cdf0e10cSrcweir const String* pCharStyleNames = pSwXRules->GetNewCharStyleNames();
2006cdf0e10cSrcweir const String* pBulletFontNames = pSwXRules->GetBulletFontNames();
2007cdf0e10cSrcweir
2008cdf0e10cSrcweir SwNumRule aSetRule(*pSwXRules->GetNumRule());
2009cdf0e10cSrcweir const SwCharFmts* pFmts = pDoc->GetCharFmts();
2010cdf0e10cSrcweir sal_uInt16 nChCount = pFmts->Count();
2011cdf0e10cSrcweir for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
2012cdf0e10cSrcweir {
2013cdf0e10cSrcweir
2014cdf0e10cSrcweir const SwNumFmt* pFmt = aSetRule.GetNumFmt( i );
2015cdf0e10cSrcweir if(pFmt)
2016cdf0e10cSrcweir {
2017cdf0e10cSrcweir SwNumFmt aFmt(*pFmt);
2018cdf0e10cSrcweir if(
2019cdf0e10cSrcweir pCharStyleNames[i] != SwXNumberingRules::GetInvalidStyle() &&
2020cdf0e10cSrcweir ((pCharStyleNames[i].Len() && !pFmt->GetCharFmt()) ||
2021cdf0e10cSrcweir (pCharStyleNames[i].Len() &&
2022cdf0e10cSrcweir pFmt->GetCharFmt()->GetName() != pCharStyleNames[i]) ))
2023cdf0e10cSrcweir {
2024cdf0e10cSrcweir
2025cdf0e10cSrcweir SwCharFmt* pCharFmt = 0;
2026cdf0e10cSrcweir if(pCharStyleNames[i].Len())
2027cdf0e10cSrcweir {
2028cdf0e10cSrcweir for(sal_uInt16 j = 0; j< nChCount; j++)
2029cdf0e10cSrcweir {
2030cdf0e10cSrcweir SwCharFmt* pTmp = (*pFmts)[j];
2031cdf0e10cSrcweir if(pTmp->GetName() == pCharStyleNames[i])
2032cdf0e10cSrcweir {
2033cdf0e10cSrcweir pCharFmt = pTmp;
2034cdf0e10cSrcweir break;
2035cdf0e10cSrcweir }
2036cdf0e10cSrcweir }
2037cdf0e10cSrcweir if(!pCharFmt)
2038cdf0e10cSrcweir {
2039cdf0e10cSrcweir
2040cdf0e10cSrcweir SfxStyleSheetBase* pBase;
2041cdf0e10cSrcweir pBase = ((SfxStyleSheetBasePool*)pBasePool)->Find(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
2042cdf0e10cSrcweir if(!pBase)
2043cdf0e10cSrcweir pBase = &pBasePool->Make(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
2044cdf0e10cSrcweir pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
2045cdf0e10cSrcweir
2046cdf0e10cSrcweir }
2047cdf0e10cSrcweir
2048cdf0e10cSrcweir aFmt.SetCharFmt( pCharFmt );
2049cdf0e10cSrcweir }
2050cdf0e10cSrcweir }
2051cdf0e10cSrcweir //jetzt nochmal fuer Fonts
2052cdf0e10cSrcweir if(pBulletFontNames[i] != SwXNumberingRules::GetInvalidStyle() &&
2053cdf0e10cSrcweir ((pBulletFontNames[i].Len() && !pFmt->GetBulletFont()) ||
2054cdf0e10cSrcweir (pBulletFontNames[i].Len() &&
2055cdf0e10cSrcweir pFmt->GetBulletFont()->GetName() != pBulletFontNames[i]) ))
2056cdf0e10cSrcweir {
2057cdf0e10cSrcweir const SvxFontListItem* pFontListItem =
2058cdf0e10cSrcweir (const SvxFontListItem* )pDoc->GetDocShell()
2059cdf0e10cSrcweir ->GetItem( SID_ATTR_CHAR_FONTLIST );
2060cdf0e10cSrcweir const FontList* pList = pFontListItem->GetFontList();
2061cdf0e10cSrcweir FontInfo aInfo = pList->Get(
2062cdf0e10cSrcweir pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE);
2063cdf0e10cSrcweir Font aFont(aInfo);
2064cdf0e10cSrcweir aFmt.SetBulletFont(&aFont);
2065cdf0e10cSrcweir }
2066cdf0e10cSrcweir aSetRule.Set( i, &aFmt );
2067cdf0e10cSrcweir }
2068cdf0e10cSrcweir }
206956b35d86SArmin Le Grand rBase.getNewBase()->SetNumRule(aSetRule);
2070cdf0e10cSrcweir }
2071cdf0e10cSrcweir }
2072cdf0e10cSrcweir else
2073cdf0e10cSrcweir throw lang::IllegalArgumentException();
207464b14621SArmin Le Grand
207564b14621SArmin Le Grand bDone = true;
2076cdf0e10cSrcweir break;
207764b14621SArmin Le Grand }
207828f5a95aSOliver-Rainer Wittmann
207928f5a95aSOliver-Rainer Wittmann case RES_PARATR_OUTLINELEVEL:
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir sal_Int16 nLevel = 0;
208264b14621SArmin Le Grand aValue >>= nLevel;
2083cdf0e10cSrcweir if( 0 <= nLevel && nLevel <= MAXLEVEL)
208456b35d86SArmin Le Grand rBase.getNewBase()->GetCollection()->SetAttrOutlineLevel( nLevel );
208564b14621SArmin Le Grand
208664b14621SArmin Le Grand bDone = true;
208728f5a95aSOliver-Rainer Wittmann break;
208864b14621SArmin Le Grand }
208928f5a95aSOliver-Rainer Wittmann
2090cdf0e10cSrcweir case FN_UNO_FOLLOW_STYLE:
2091cdf0e10cSrcweir {
2092cdf0e10cSrcweir OUString sTmp;
209364b14621SArmin Le Grand aValue >>= sTmp;
2094cdf0e10cSrcweir String aString;
2095cdf0e10cSrcweir SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ) ;
209656b35d86SArmin Le Grand rBase.getNewBase()->SetFollow( aString );
209764b14621SArmin Le Grand
209864b14621SArmin Le Grand bDone = true;
2099cdf0e10cSrcweir break;
210064b14621SArmin Le Grand }
2101cdf0e10cSrcweir case RES_PAGEDESC :
210264b14621SArmin Le Grand {
210364b14621SArmin Le Grand if( MID_PAGEDESC_PAGEDESCNAME == nMemberId)
2104cdf0e10cSrcweir {
2105cdf0e10cSrcweir // Sonderbehandlung RES_PAGEDESC
210664b14621SArmin Le Grand if(aValue.getValueType() != ::getCppuType((const OUString*)0))
2107cdf0e10cSrcweir throw lang::IllegalArgumentException();
2108cdf0e10cSrcweir SfxItemSet& rStyleSet = rBase.GetItemSet();
2109cdf0e10cSrcweir
2110cdf0e10cSrcweir SwFmtPageDesc* pNewDesc = 0;
2111cdf0e10cSrcweir const SfxPoolItem* pItem;
2112cdf0e10cSrcweir if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
2113cdf0e10cSrcweir {
2114cdf0e10cSrcweir pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem));
2115cdf0e10cSrcweir }
2116cdf0e10cSrcweir if(!pNewDesc)
2117cdf0e10cSrcweir pNewDesc = new SwFmtPageDesc();
2118cdf0e10cSrcweir OUString uDescName;
211964b14621SArmin Le Grand aValue >>= uDescName;
2120cdf0e10cSrcweir String sDescName;
2121cdf0e10cSrcweir SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
2122cdf0e10cSrcweir if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName)
2123cdf0e10cSrcweir {
2124cdf0e10cSrcweir //sal_uInt16 nCount = pDoc->GetPageDescCnt();
2125cdf0e10cSrcweir sal_Bool bPut = sal_False;
2126cdf0e10cSrcweir if(sDescName.Len())
2127cdf0e10cSrcweir {
2128cdf0e10cSrcweir SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName);
2129cdf0e10cSrcweir if(pPageDesc)
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir pNewDesc->RegisterToPageDesc( *pPageDesc );
2132cdf0e10cSrcweir bPut = sal_True;
2133cdf0e10cSrcweir }
2134cdf0e10cSrcweir else
2135cdf0e10cSrcweir {
2136cdf0e10cSrcweir throw lang::IllegalArgumentException();
2137cdf0e10cSrcweir }
2138cdf0e10cSrcweir }
2139cdf0e10cSrcweir if(!bPut)
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir rStyleSet.ClearItem(RES_BREAK);
2142cdf0e10cSrcweir rStyleSet.Put(SwFmtPageDesc());
2143cdf0e10cSrcweir }
2144cdf0e10cSrcweir else
2145cdf0e10cSrcweir rStyleSet.Put(*pNewDesc);
2146cdf0e10cSrcweir }
214764b14621SArmin Le Grand
2148cdf0e10cSrcweir delete pNewDesc;
214964b14621SArmin Le Grand bDone = true;
2150cdf0e10cSrcweir }
215164b14621SArmin Le Grand
2152cdf0e10cSrcweir break;
215364b14621SArmin Le Grand }
2154cdf0e10cSrcweir case FN_UNO_IS_AUTO_UPDATE:
2155cdf0e10cSrcweir {
215664b14621SArmin Le Grand sal_Bool bAuto = *(sal_Bool*)aValue.getValue();
2157cdf0e10cSrcweir if(SFX_STYLE_FAMILY_PARA == eFamily)
215856b35d86SArmin Le Grand rBase.getNewBase()->GetCollection()->SetAutoUpdateFmt(bAuto);
2159cdf0e10cSrcweir else if(SFX_STYLE_FAMILY_FRAME == eFamily)
216056b35d86SArmin Le Grand rBase.getNewBase()->GetFrmFmt()->SetAutoUpdateFmt(bAuto);
216164b14621SArmin Le Grand
216264b14621SArmin Le Grand bDone = true;
2163cdf0e10cSrcweir break;
216464b14621SArmin Le Grand }
2165cdf0e10cSrcweir case FN_UNO_PARA_STYLE_CONDITIONS:
2166cdf0e10cSrcweir {
2167cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aSeq;
216864b14621SArmin Le Grand if (!(aValue >>= aSeq))
2169cdf0e10cSrcweir throw lang::IllegalArgumentException();
2170cdf0e10cSrcweir
2171cdf0e10cSrcweir DBG_ASSERT(COND_COMMAND_COUNT == 28,
2172cdf0e10cSrcweir "invalid size of comman count?");
2173cdf0e10cSrcweir const beans::NamedValue *pSeq = aSeq.getConstArray();
2174cdf0e10cSrcweir sal_Int32 nLen = aSeq.getLength();
2175cdf0e10cSrcweir
2176cdf0e10cSrcweir sal_Bool bFailed = sal_False;
2177cdf0e10cSrcweir SwCondCollItem aCondItem;
2178cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nLen; i++)
2179cdf0e10cSrcweir {
2180cdf0e10cSrcweir OUString aTmp;
2181cdf0e10cSrcweir if ((pSeq[i].Value >>= aTmp))
2182cdf0e10cSrcweir {
2183cdf0e10cSrcweir // get UI style name from programmatic style name
2184cdf0e10cSrcweir String aStyleName;
2185cdf0e10cSrcweir SwStyleNameMapper::FillUIName( aTmp, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
2186cdf0e10cSrcweir
2187cdf0e10cSrcweir //
2188cdf0e10cSrcweir // check for correct context and style name
2189cdf0e10cSrcweir //
2190cdf0e10cSrcweir sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name );
2191cdf0e10cSrcweir //
2192cdf0e10cSrcweir pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
2193cdf0e10cSrcweir sal_Bool bStyleFound = sal_False;
2194cdf0e10cSrcweir const SfxStyleSheetBase* pBase = pBasePool->First();
2195cdf0e10cSrcweir while (pBase && !bStyleFound)
2196cdf0e10cSrcweir {
2197cdf0e10cSrcweir if(pBase->GetName() == aStyleName)
2198cdf0e10cSrcweir bStyleFound = sal_True;
2199cdf0e10cSrcweir pBase = pBasePool->Next();
2200cdf0e10cSrcweir }
2201cdf0e10cSrcweir //
2202cdf0e10cSrcweir if (nIdx == -1 || !bStyleFound)
2203cdf0e10cSrcweir {
2204cdf0e10cSrcweir bFailed = sal_True;
2205cdf0e10cSrcweir break;
2206cdf0e10cSrcweir }
2207cdf0e10cSrcweir
2208cdf0e10cSrcweir aCondItem.SetStyle( &aStyleName, nIdx);
2209cdf0e10cSrcweir }
2210cdf0e10cSrcweir else
2211cdf0e10cSrcweir bFailed = sal_True;
2212cdf0e10cSrcweir }
2213cdf0e10cSrcweir if (bFailed)
2214cdf0e10cSrcweir throw lang::IllegalArgumentException();
2215cdf0e10cSrcweir rBase.GetItemSet().Put( aCondItem );
221664b14621SArmin Le Grand bDone = true;
2217cdf0e10cSrcweir break;
221864b14621SArmin Le Grand }
2219cdf0e10cSrcweir case FN_UNO_CATEGORY:
2220cdf0e10cSrcweir {
222156b35d86SArmin Le Grand if(!rBase.getNewBase()->IsUserDefined())
2222cdf0e10cSrcweir throw lang::IllegalArgumentException();
2223cdf0e10cSrcweir short nSet = 0;
222464b14621SArmin Le Grand aValue >>= nSet;
2225cdf0e10cSrcweir
2226cdf0e10cSrcweir sal_uInt16 nId;
2227cdf0e10cSrcweir switch( nSet )
2228cdf0e10cSrcweir {
2229cdf0e10cSrcweir case style::ParagraphStyleCategory::TEXT:
2230cdf0e10cSrcweir nId = SWSTYLEBIT_TEXT;
2231cdf0e10cSrcweir break;
2232cdf0e10cSrcweir case style::ParagraphStyleCategory::CHAPTER:
2233cdf0e10cSrcweir nId = SWSTYLEBIT_CHAPTER;
2234cdf0e10cSrcweir break;
2235cdf0e10cSrcweir case style::ParagraphStyleCategory::LIST:
2236cdf0e10cSrcweir nId = SWSTYLEBIT_LIST;
2237cdf0e10cSrcweir break;
2238cdf0e10cSrcweir case style::ParagraphStyleCategory::INDEX:
2239cdf0e10cSrcweir nId = SWSTYLEBIT_IDX;
2240cdf0e10cSrcweir break;
2241cdf0e10cSrcweir case style::ParagraphStyleCategory::EXTRA:
2242cdf0e10cSrcweir nId = SWSTYLEBIT_EXTRA;
2243cdf0e10cSrcweir break;
2244cdf0e10cSrcweir case style::ParagraphStyleCategory::HTML:
2245cdf0e10cSrcweir nId = SWSTYLEBIT_HTML;
2246cdf0e10cSrcweir break;
2247cdf0e10cSrcweir default: throw lang::IllegalArgumentException();
2248cdf0e10cSrcweir }
224964b14621SArmin Le Grand
225056b35d86SArmin Le Grand rBase.getNewBase()->SetMask( nId|SFXSTYLEBIT_USERDEF );
225164b14621SArmin Le Grand bDone = true;
2252cdf0e10cSrcweir break;
225364b14621SArmin Le Grand }
2254cdf0e10cSrcweir case SID_SWREGISTER_COLLECTION:
2255cdf0e10cSrcweir {
2256cdf0e10cSrcweir OUString sName;
225764b14621SArmin Le Grand aValue >>= sName;
2258cdf0e10cSrcweir SwRegisterItem aReg( sName.getLength() != 0);
2259cdf0e10cSrcweir aReg.SetWhich(SID_SWREGISTER_MODE);
2260cdf0e10cSrcweir rBase.GetItemSet().Put(aReg);
2261cdf0e10cSrcweir String aString;
2262cdf0e10cSrcweir SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
2263cdf0e10cSrcweir
2264cdf0e10cSrcweir rBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
226564b14621SArmin Le Grand bDone = true;
2266cdf0e10cSrcweir break;
226764b14621SArmin Le Grand }
2268cdf0e10cSrcweir case RES_TXTATR_CJK_RUBY:
226964b14621SArmin Le Grand {
227064b14621SArmin Le Grand if(MID_RUBY_CHARSTYLE == nMemberId )
2271cdf0e10cSrcweir {
2272cdf0e10cSrcweir OUString sTmp;
227364b14621SArmin Le Grand if(aValue >>= sTmp)
2274cdf0e10cSrcweir {
2275cdf0e10cSrcweir SfxItemSet& rStyleSet = rBase.GetItemSet();
2276cdf0e10cSrcweir SwFmtRuby* pRuby = 0;
2277cdf0e10cSrcweir const SfxPoolItem* pItem;
2278cdf0e10cSrcweir if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) )
2279cdf0e10cSrcweir pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem));
2280cdf0e10cSrcweir if(!pRuby)
2281cdf0e10cSrcweir pRuby = new SwFmtRuby(aEmptyStr);
2282cdf0e10cSrcweir String sStyle;
2283cdf0e10cSrcweir SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
2284cdf0e10cSrcweir pRuby->SetCharFmtName( sTmp );
2285cdf0e10cSrcweir pRuby->SetCharFmtId( 0 );
2286cdf0e10cSrcweir if(sTmp.getLength())
2287cdf0e10cSrcweir {
2288cdf0e10cSrcweir sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
2289cdf0e10cSrcweir pRuby->SetCharFmtId(nId);
2290cdf0e10cSrcweir }
2291cdf0e10cSrcweir rStyleSet.Put(*pRuby);
2292cdf0e10cSrcweir delete pRuby;
2293cdf0e10cSrcweir }
2294cdf0e10cSrcweir else
2295cdf0e10cSrcweir throw lang::IllegalArgumentException();
2296cdf0e10cSrcweir }
229764b14621SArmin Le Grand break;
229864b14621SArmin Le Grand }
2299cdf0e10cSrcweir case RES_PARATR_DROP:
2300cdf0e10cSrcweir {
230164b14621SArmin Le Grand if( MID_DROPCAP_CHAR_STYLE_NAME == nMemberId)
2302cdf0e10cSrcweir {
230364b14621SArmin Le Grand if(aValue.getValueType() == ::getCppuType((const OUString*)0))
2304cdf0e10cSrcweir {
2305cdf0e10cSrcweir SfxItemSet& rStyleSet = rBase.GetItemSet();
2306cdf0e10cSrcweir
2307cdf0e10cSrcweir SwFmtDrop* pDrop = 0;
2308cdf0e10cSrcweir const SfxPoolItem* pItem;
2309cdf0e10cSrcweir if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) )
2310cdf0e10cSrcweir pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem));
2311cdf0e10cSrcweir if(!pDrop)
2312cdf0e10cSrcweir pDrop = new SwFmtDrop();
2313cdf0e10cSrcweir OUString uStyle;
231464b14621SArmin Le Grand aValue >>= uStyle;
2315cdf0e10cSrcweir String sStyle;
2316cdf0e10cSrcweir SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
2317cdf0e10cSrcweir SwDocStyleSheet* pStyle =
2318cdf0e10cSrcweir (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR);
2319cdf0e10cSrcweir if(pStyle)
2320cdf0e10cSrcweir pDrop->SetCharFmt(pStyle->GetCharFmt());
2321cdf0e10cSrcweir else
2322cdf0e10cSrcweir throw lang::IllegalArgumentException();
2323cdf0e10cSrcweir rStyleSet.Put(*pDrop);
2324cdf0e10cSrcweir delete pDrop;
2325cdf0e10cSrcweir }
2326cdf0e10cSrcweir else
2327cdf0e10cSrcweir throw lang::IllegalArgumentException();
232864b14621SArmin Le Grand
232964b14621SArmin Le Grand bDone = true;
233064b14621SArmin Le Grand }
233164b14621SArmin Le Grand break;
233264b14621SArmin Le Grand }
233364b14621SArmin Le Grand default:
233464b14621SArmin Le Grand {
233564b14621SArmin Le Grand // nothing to do
2336cdf0e10cSrcweir break;
2337cdf0e10cSrcweir }
2338cdf0e10cSrcweir }
233964b14621SArmin Le Grand
234064b14621SArmin Le Grand if(!bDone)
2341cdf0e10cSrcweir {
234264b14621SArmin Le Grand // default ItemSet handling
2343cdf0e10cSrcweir SfxItemSet& rStyleSet = rBase.GetItemSet();
2344cdf0e10cSrcweir SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
2345cdf0e10cSrcweir aSet.SetParent(&rStyleSet);
234664b14621SArmin Le Grand rPropSet.setPropertyValue(rEntry, aValue, aSet);
2347cdf0e10cSrcweir rStyleSet.Put(aSet);
234864b14621SArmin Le Grand
2349cdf0e10cSrcweir // --> OD 2006-10-18 #i70223#
2350cdf0e10cSrcweir if ( SFX_STYLE_FAMILY_PARA == eFamily &&
2351cdf0e10cSrcweir rEntry.nWID == RES_PARATR_NUMRULE &&
235256b35d86SArmin Le Grand rBase.getNewBase().is() && rBase.getNewBase()->GetCollection() &&
235356b35d86SArmin Le Grand //rBase.getNewBase()->GetCollection()->GetOutlineLevel() < MAXLEVEL /* assigned to list level of outline style */) //#outline level,removed by zhaojianwei
235456b35d86SArmin Le Grand rBase.getNewBase()->GetCollection()->IsAssignedToListLevelOfOutlineStyle() ) ////<-end,add by zhaojianwei
2355cdf0e10cSrcweir {
2356cdf0e10cSrcweir OUString sNewNumberingRuleName;
235764b14621SArmin Le Grand aValue >>= sNewNumberingRuleName;
2358cdf0e10cSrcweir String sTmp( sNewNumberingRuleName );
235964b14621SArmin Le Grand if ( sNewNumberingRuleName.getLength() == 0 || sTmp != pDoc->GetOutlineNumRule()->GetName() )
2360cdf0e10cSrcweir {
2361cdf0e10cSrcweir // delete assignment to list level of outline style.
236256b35d86SArmin Le Grand //rBase.getNewBase()->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei
236356b35d86SArmin Le Grand rBase.getNewBase()->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,adde by zhaojianwei
2364cdf0e10cSrcweir }
2365cdf0e10cSrcweir }
2366cdf0e10cSrcweir }
2367cdf0e10cSrcweir }
2368cdf0e10cSrcweir /* -----------------------------18.04.01 13:29--------------------------------
2369cdf0e10cSrcweir
2370cdf0e10cSrcweir ---------------------------------------------------------------------------*/
SetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)2371cdf0e10cSrcweir void SAL_CALL SwXStyle::SetPropertyValues_Impl(
2372cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames,
2373cdf0e10cSrcweir const uno::Sequence< uno::Any >& rValues )
237456b35d86SArmin Le Grand throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
2375cdf0e10cSrcweir {
2376cdf0e10cSrcweir if ( !m_pDoc )
2377cdf0e10cSrcweir throw uno::RuntimeException();
237856b35d86SArmin Le Grand
2379cdf0e10cSrcweir sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
238056b35d86SArmin Le Grand
2381cdf0e10cSrcweir switch(eFamily)
2382cdf0e10cSrcweir {
2383cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2384cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2385cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break;
2386cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
238756b35d86SArmin Le Grand default: ;
2388cdf0e10cSrcweir }
238956b35d86SArmin Le Grand
2390cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2391cdf0e10cSrcweir const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2392cdf0e10cSrcweir
2393cdf0e10cSrcweir if(rPropertyNames.getLength() != rValues.getLength())
239456b35d86SArmin Le Grand {
2395cdf0e10cSrcweir throw lang::IllegalArgumentException();
239656b35d86SArmin Le Grand }
2397cdf0e10cSrcweir
2398cdf0e10cSrcweir const OUString* pNames = rPropertyNames.getConstArray();
2399cdf0e10cSrcweir const uno::Any* pValues = rValues.getConstArray();
240056b35d86SArmin Le Grand SwStyleBase_Impl aBaseImpl(*m_pDoc, sStyleName, &GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); //UUUU add pDfltTxtFmtColl as parent
2401cdf0e10cSrcweir
2402cdf0e10cSrcweir if(pBasePool)
2403cdf0e10cSrcweir {
2404cdf0e10cSrcweir sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2405cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily);
2406cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2407cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, nSaveMask );
2408cdf0e10cSrcweir DBG_ASSERT(pBase, "where is the style?" );
240956b35d86SArmin Le Grand
2410cdf0e10cSrcweir if(pBase)
241156b35d86SArmin Le Grand aBaseImpl.setNewBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
2412cdf0e10cSrcweir else
2413cdf0e10cSrcweir throw uno::RuntimeException();
2414cdf0e10cSrcweir }
2415cdf0e10cSrcweir
2416cdf0e10cSrcweir for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2417cdf0e10cSrcweir {
2418cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[nProp]);
2419cdf0e10cSrcweir
2420cdf0e10cSrcweir if(!pEntry ||
2421cdf0e10cSrcweir (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS))))
2422cdf0e10cSrcweir throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2423cdf0e10cSrcweir if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2424cdf0e10cSrcweir throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
242556b35d86SArmin Le Grand
242656b35d86SArmin Le Grand if(aBaseImpl.getNewBase().is())
2427cdf0e10cSrcweir {
242856b35d86SArmin Le Grand lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, pBasePool, m_pDoc, eFamily);
2429cdf0e10cSrcweir }
2430cdf0e10cSrcweir else if(bIsDescriptor)
2431cdf0e10cSrcweir {
2432cdf0e10cSrcweir if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp]))
243356b35d86SArmin Le Grand {
2434cdf0e10cSrcweir throw lang::IllegalArgumentException();
2435cdf0e10cSrcweir }
243656b35d86SArmin Le Grand }
2437cdf0e10cSrcweir else
243856b35d86SArmin Le Grand {
2439cdf0e10cSrcweir throw uno::RuntimeException();
2440cdf0e10cSrcweir }
244156b35d86SArmin Le Grand }
244256b35d86SArmin Le Grand
2443cdf0e10cSrcweir if(aBaseImpl.HasItemSet())
244456b35d86SArmin Le Grand {
244556b35d86SArmin Le Grand aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
244656b35d86SArmin Le Grand }
2447cdf0e10cSrcweir }
2448cdf0e10cSrcweir
setPropertyValues(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)2449cdf0e10cSrcweir void SwXStyle::setPropertyValues(
2450cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames,
2451cdf0e10cSrcweir const uno::Sequence< uno::Any >& rValues )
245256b35d86SArmin Le Grand throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
2453cdf0e10cSrcweir {
2454cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2455cdf0e10cSrcweir
2456cdf0e10cSrcweir // workaround for bad designed API
2457cdf0e10cSrcweir try
2458cdf0e10cSrcweir {
2459cdf0e10cSrcweir SetPropertyValues_Impl( rPropertyNames, rValues );
2460cdf0e10cSrcweir }
2461cdf0e10cSrcweir catch (beans::UnknownPropertyException &rException)
2462cdf0e10cSrcweir {
2463cdf0e10cSrcweir // wrap the original (here not allowed) exception in
2464cdf0e10cSrcweir // a lang::WrappedTargetException that gets thrown instead.
2465cdf0e10cSrcweir lang::WrappedTargetException aWExc;
2466cdf0e10cSrcweir aWExc.TargetException <<= rException;
2467cdf0e10cSrcweir throw aWExc;
2468cdf0e10cSrcweir }
2469cdf0e10cSrcweir }
2470cdf0e10cSrcweir
2471cdf0e10cSrcweir
lcl_GetStyleProperty(const SfxItemPropertySimpleEntry & rEntry,const SfxItemPropertySet & rPropSet,SwStyleBase_Impl & rBase,SfxStyleSheetBase * pBase,SfxStyleFamily eFamily,SwDoc * pDoc)247256b35d86SArmin Le Grand uno::Any lcl_GetStyleProperty(
247356b35d86SArmin Le Grand const SfxItemPropertySimpleEntry& rEntry,
2474cdf0e10cSrcweir const SfxItemPropertySet& rPropSet,
2475cdf0e10cSrcweir SwStyleBase_Impl& rBase,
2476cdf0e10cSrcweir SfxStyleSheetBase* pBase,
2477cdf0e10cSrcweir SfxStyleFamily eFamily,
247856b35d86SArmin Le Grand SwDoc *pDoc)
247956b35d86SArmin Le Grand throw(uno::RuntimeException)
2480cdf0e10cSrcweir {
2481cdf0e10cSrcweir uno::Any aRet;
248264b14621SArmin Le Grand
2483cdf0e10cSrcweir if(FN_UNO_IS_PHYSICAL == rEntry.nWID)
2484cdf0e10cSrcweir {
2485cdf0e10cSrcweir sal_Bool bPhys = pBase != 0;
2486cdf0e10cSrcweir if(pBase)
2487cdf0e10cSrcweir {
2488cdf0e10cSrcweir bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical();
2489cdf0e10cSrcweir // The standard character format is not existing physically
2490cdf0e10cSrcweir if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily &&
2491cdf0e10cSrcweir ((SwDocStyleSheet*)pBase)->GetCharFmt() &&
2492cdf0e10cSrcweir ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() )
2493cdf0e10cSrcweir bPhys = sal_False;
2494cdf0e10cSrcweir }
2495cdf0e10cSrcweir aRet.setValue(&bPhys, ::getBooleanCppuType());
2496cdf0e10cSrcweir }
2497cdf0e10cSrcweir else if(pBase)
2498cdf0e10cSrcweir {
249956b35d86SArmin Le Grand if(!rBase.getNewBase().is())
250064b14621SArmin Le Grand {
250156b35d86SArmin Le Grand rBase.setNewBase(new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ));
250264b14621SArmin Le Grand }
250364b14621SArmin Le Grand
250464b14621SArmin Le Grand //UUUU
250564b14621SArmin Le Grand const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
250664b14621SArmin Le Grand
250764b14621SArmin Le Grand //UUUU adapted switch logic to a more readable state; removed goto's and made
250864b14621SArmin Le Grand // execution of standard setting of proerty in ItemSet dependent of this variable
250964b14621SArmin Le Grand bool bDone(false);
251064b14621SArmin Le Grand
2511cdf0e10cSrcweir switch(rEntry.nWID)
2512cdf0e10cSrcweir {
2513cdf0e10cSrcweir case RES_PAPER_BIN:
2514cdf0e10cSrcweir {
2515cdf0e10cSrcweir SfxItemSet& rSet = rBase.GetItemSet();
2516cdf0e10cSrcweir rPropSet.getPropertyValue(rEntry, rSet, aRet);
2517cdf0e10cSrcweir sal_Int8 nBin = 0;
2518cdf0e10cSrcweir aRet >>= nBin;
2519cdf0e10cSrcweir if ( nBin == -1 )
2520cdf0e10cSrcweir aRet <<= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "[From printer settings]" ) );
2521cdf0e10cSrcweir else
2522cdf0e10cSrcweir {
2523cdf0e10cSrcweir SfxPrinter *pPrinter = pDoc->getPrinter( false );
2524cdf0e10cSrcweir OUString sTmp;
2525cdf0e10cSrcweir if (pPrinter )
2526cdf0e10cSrcweir sTmp = pPrinter->GetPaperBinName ( nBin );
2527cdf0e10cSrcweir aRet <<= sTmp;
2528cdf0e10cSrcweir }
252964b14621SArmin Le Grand
253064b14621SArmin Le Grand bDone = true;
2531cdf0e10cSrcweir break;
253264b14621SArmin Le Grand }
2533cdf0e10cSrcweir case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem:
2534cdf0e10cSrcweir {
253556b35d86SArmin Le Grand const SwNumRule* pRule = rBase.getNewBase()->GetNumRule();
2536cdf0e10cSrcweir DBG_ASSERT(pRule, "Wo ist die NumRule?");
2537cdf0e10cSrcweir uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule);
253864b14621SArmin Le Grand
2539cdf0e10cSrcweir aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0));
254064b14621SArmin Le Grand bDone = true;
254164b14621SArmin Le Grand break;
2542cdf0e10cSrcweir }
2543cdf0e10cSrcweir break;
2544cdf0e10cSrcweir //case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei
2545cdf0e10cSrcweir //{
2546cdf0e10cSrcweir // DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
254756b35d86SArmin Le Grand // sal_uInt8 nLevel = rBase.getNewBase()->GetCollection()->GetOutlineLevel();
2548cdf0e10cSrcweir // if( nLevel != NO_NUMBERING )
2549cdf0e10cSrcweir // aRet <<= static_cast<sal_Int8>( nLevel );
255064b14621SArmin Le Grand // bDone = true;
2551cdf0e10cSrcweir // break;
255264b14621SArmin Le Grand //}
2553cdf0e10cSrcweir case RES_PARATR_OUTLINELEVEL: //add by zahojianwei
2554cdf0e10cSrcweir {
2555cdf0e10cSrcweir DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
255656b35d86SArmin Le Grand int nLevel = rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel();
255764b14621SArmin Le Grand
2558cdf0e10cSrcweir aRet <<= static_cast<sal_Int16>( nLevel );
255964b14621SArmin Le Grand bDone = true;
256064b14621SArmin Le Grand break;
256164b14621SArmin Le Grand } //<-end,zhaojianwei
2562cdf0e10cSrcweir case FN_UNO_FOLLOW_STYLE:
2563cdf0e10cSrcweir {
2564cdf0e10cSrcweir String aString;
256564b14621SArmin Le Grand
256656b35d86SArmin Le Grand SwStyleNameMapper::FillProgName(rBase.getNewBase()->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
2567cdf0e10cSrcweir aRet <<= OUString( aString );
256864b14621SArmin Le Grand bDone = true;
2569cdf0e10cSrcweir break;
257064b14621SArmin Le Grand }
2571cdf0e10cSrcweir case RES_PAGEDESC :
257264b14621SArmin Le Grand {
257364b14621SArmin Le Grand if( MID_PAGEDESC_PAGEDESCNAME == nMemberId)
2574cdf0e10cSrcweir {
2575cdf0e10cSrcweir // Sonderbehandlung RES_PAGEDESC
2576cdf0e10cSrcweir const SfxPoolItem* pItem;
2577cdf0e10cSrcweir if(SFX_ITEM_SET == rBase.GetItemSet().GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
2578cdf0e10cSrcweir {
2579cdf0e10cSrcweir const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc();
2580cdf0e10cSrcweir if(pDesc)
2581cdf0e10cSrcweir {
2582cdf0e10cSrcweir String aString;
2583cdf0e10cSrcweir SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
2584cdf0e10cSrcweir aRet <<= OUString( aString );
2585cdf0e10cSrcweir }
2586cdf0e10cSrcweir }
258764b14621SArmin Le Grand
258864b14621SArmin Le Grand bDone = true;
2589cdf0e10cSrcweir }
259064b14621SArmin Le Grand
2591cdf0e10cSrcweir break;
259264b14621SArmin Le Grand }
2593cdf0e10cSrcweir case FN_UNO_IS_AUTO_UPDATE:
2594cdf0e10cSrcweir {
2595cdf0e10cSrcweir sal_Bool bAuto = sal_False;
2596cdf0e10cSrcweir if(SFX_STYLE_FAMILY_PARA == eFamily)
259756b35d86SArmin Le Grand bAuto = rBase.getNewBase()->GetCollection()->IsAutoUpdateFmt();
2598cdf0e10cSrcweir else if(SFX_STYLE_FAMILY_FRAME == eFamily)
259956b35d86SArmin Le Grand bAuto = rBase.getNewBase()->GetFrmFmt()->IsAutoUpdateFmt();
2600cdf0e10cSrcweir aRet.setValue(&bAuto, ::getBooleanCppuType());
260164b14621SArmin Le Grand
260264b14621SArmin Le Grand bDone = true;
2603cdf0e10cSrcweir break;
260464b14621SArmin Le Grand }
2605cdf0e10cSrcweir case FN_UNO_DISPLAY_NAME:
2606cdf0e10cSrcweir {
260756b35d86SArmin Le Grand OUString sName(rBase.getNewBase()->GetDisplayName());
2608cdf0e10cSrcweir aRet <<= sName;
260964b14621SArmin Le Grand
261064b14621SArmin Le Grand bDone = true;
2611cdf0e10cSrcweir break;
261264b14621SArmin Le Grand }
2613cdf0e10cSrcweir case FN_UNO_PARA_STYLE_CONDITIONS:
2614cdf0e10cSrcweir {
2615cdf0e10cSrcweir DBG_ASSERT(COND_COMMAND_COUNT == 28,
2616cdf0e10cSrcweir "invalid size of comman count?");
2617cdf0e10cSrcweir //SfxItemSet& rStyleSet = rBase.GetItemSet();
2618cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT);
2619cdf0e10cSrcweir beans::NamedValue *pSeq = aSeq.getArray();
2620cdf0e10cSrcweir
2621cdf0e10cSrcweir SwFmt *pFmt = ((SwDocStyleSheet*)pBase)->GetCollection();
2622cdf0e10cSrcweir const CommandStruct *pCmds = SwCondCollItem::GetCmds();
2623cdf0e10cSrcweir for (sal_uInt16 n = 0; n < COND_COMMAND_COUNT; ++n)
2624cdf0e10cSrcweir {
2625cdf0e10cSrcweir String aStyleName;
2626cdf0e10cSrcweir
2627cdf0e10cSrcweir const SwCollCondition* pCond = 0;
2628cdf0e10cSrcweir if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() &&
2629cdf0e10cSrcweir 0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)->
2630cdf0e10cSrcweir HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) )
2631cdf0e10cSrcweir && pCond->GetTxtFmtColl() )
2632cdf0e10cSrcweir {
2633cdf0e10cSrcweir // get programmatic style name from UI style name
2634cdf0e10cSrcweir aStyleName = pCond->GetTxtFmtColl()->GetName();
2635cdf0e10cSrcweir SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
2636cdf0e10cSrcweir }
2637cdf0e10cSrcweir
2638cdf0e10cSrcweir pSeq[n].Name = GetCommandContextByIndex(n);
2639cdf0e10cSrcweir pSeq[n].Value <<= rtl::OUString( aStyleName );
2640cdf0e10cSrcweir }
2641cdf0e10cSrcweir aRet <<= aSeq;
264264b14621SArmin Le Grand
264364b14621SArmin Le Grand bDone = true;
2644cdf0e10cSrcweir break;
264564b14621SArmin Le Grand }
2646cdf0e10cSrcweir case FN_UNO_CATEGORY:
2647cdf0e10cSrcweir {
264856b35d86SArmin Le Grand sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFmtId();
2649cdf0e10cSrcweir short nRet = -1;
265064b14621SArmin Le Grand
2651cdf0e10cSrcweir switch ( COLL_GET_RANGE_BITS & nPoolId )
2652cdf0e10cSrcweir {
2653cdf0e10cSrcweir case COLL_TEXT_BITS:
2654cdf0e10cSrcweir nRet = style::ParagraphStyleCategory::TEXT;
2655cdf0e10cSrcweir break;
2656cdf0e10cSrcweir case COLL_DOC_BITS:
2657cdf0e10cSrcweir nRet = style::ParagraphStyleCategory::CHAPTER;
2658cdf0e10cSrcweir break;
2659cdf0e10cSrcweir case COLL_LISTS_BITS:
2660cdf0e10cSrcweir nRet = style::ParagraphStyleCategory::LIST;
2661cdf0e10cSrcweir break;
2662cdf0e10cSrcweir case COLL_REGISTER_BITS:
2663cdf0e10cSrcweir nRet = style::ParagraphStyleCategory::INDEX;
2664cdf0e10cSrcweir break;
2665cdf0e10cSrcweir case COLL_EXTRA_BITS:
2666cdf0e10cSrcweir nRet = style::ParagraphStyleCategory::EXTRA;
2667cdf0e10cSrcweir break;
2668cdf0e10cSrcweir case COLL_HTML_BITS:
2669cdf0e10cSrcweir nRet = style::ParagraphStyleCategory::HTML;
2670cdf0e10cSrcweir break;
2671cdf0e10cSrcweir }
267264b14621SArmin Le Grand
2673cdf0e10cSrcweir aRet <<= nRet;
267464b14621SArmin Le Grand bDone = true;
2675cdf0e10cSrcweir break;
267664b14621SArmin Le Grand }
2677cdf0e10cSrcweir case SID_SWREGISTER_COLLECTION:
2678cdf0e10cSrcweir {
267956b35d86SArmin Le Grand const SwPageDesc *pPageDesc = rBase.getNewBase()->GetPageDesc();
2680cdf0e10cSrcweir const SwTxtFmtColl* pCol = 0;
2681cdf0e10cSrcweir String aString;
2682cdf0e10cSrcweir if( pPageDesc )
2683cdf0e10cSrcweir pCol = pPageDesc->GetRegisterFmtColl();
2684cdf0e10cSrcweir if( pCol )
2685cdf0e10cSrcweir SwStyleNameMapper::FillProgName(
2686cdf0e10cSrcweir pCol->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
268764b14621SArmin Le Grand
2688cdf0e10cSrcweir aRet <<= OUString ( aString );
268964b14621SArmin Le Grand bDone = true;
2690cdf0e10cSrcweir break;
269164b14621SArmin Le Grand }
269264b14621SArmin Le Grand case RES_BACKGROUND:
269364b14621SArmin Le Grand {
269464b14621SArmin Le Grand //UUUU
269564b14621SArmin Le Grand const SfxItemSet& rSet = rBase.GetItemSet();
269656b35d86SArmin Le Grand const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
269764b14621SArmin Le Grand
269864b14621SArmin Le Grand if(!aOriginalBrushItem.QueryValue(aRet, nMemberId))
269964b14621SArmin Le Grand {
270064b14621SArmin Le Grand OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
270164b14621SArmin Le Grand }
270264b14621SArmin Le Grand
270364b14621SArmin Le Grand bDone = true;
270464b14621SArmin Le Grand break;
270564b14621SArmin Le Grand }
270664b14621SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
270764b14621SArmin Le Grand {
270864b14621SArmin Le Grand //UUUU
270964b14621SArmin Le Grand const SfxItemSet& rSet = rBase.GetItemSet();
271064b14621SArmin Le Grand const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH));
271164b14621SArmin Le Grand const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE));
271264b14621SArmin Le Grand
271364b14621SArmin Le Grand if( pTileItem && pTileItem->GetValue() )
271464b14621SArmin Le Grand {
271564b14621SArmin Le Grand aRet <<= drawing::BitmapMode_REPEAT;
271664b14621SArmin Le Grand }
271764b14621SArmin Le Grand else if( pStretchItem && pStretchItem->GetValue() )
271864b14621SArmin Le Grand {
271964b14621SArmin Le Grand aRet <<= drawing::BitmapMode_STRETCH;
272064b14621SArmin Le Grand }
272164b14621SArmin Le Grand else
272264b14621SArmin Le Grand {
272364b14621SArmin Le Grand aRet <<= drawing::BitmapMode_NO_REPEAT;
272464b14621SArmin Le Grand }
272564b14621SArmin Le Grand
272664b14621SArmin Le Grand bDone = true;
272764b14621SArmin Le Grand break;
272864b14621SArmin Le Grand }
2729cdf0e10cSrcweir default:
273064b14621SArmin Le Grand {
273164b14621SArmin Le Grand // nothing to do as default
273264b14621SArmin Le Grand break;
273364b14621SArmin Le Grand }
273464b14621SArmin Le Grand }
273564b14621SArmin Le Grand
273664b14621SArmin Le Grand if(!bDone)
2737cdf0e10cSrcweir {
2738cdf0e10cSrcweir SfxItemSet& rSet = rBase.GetItemSet();
2739cdf0e10cSrcweir rPropSet.getPropertyValue(rEntry, rSet, aRet);
274064b14621SArmin Le Grand
274164b14621SArmin Le Grand //UUUU
274264b14621SArmin Le Grand if(rEntry.pType && *(rEntry.pType) == ::getCppuType((const sal_Int16*)0) && *(rEntry.pType) != aRet.getValueType())
274364b14621SArmin Le Grand {
274464b14621SArmin Le Grand // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
274564b14621SArmin Le Grand sal_Int32 nValue = 0;
274664b14621SArmin Le Grand aRet >>= nValue;
274764b14621SArmin Le Grand aRet <<= (sal_Int16)nValue;
274864b14621SArmin Le Grand }
274964b14621SArmin Le Grand
275064b14621SArmin Le Grand //UUUU check for needed metric translation
275164b14621SArmin Le Grand if(rEntry.nMemberId & SFX_METRIC_ITEM)
275264b14621SArmin Le Grand {
275364b14621SArmin Le Grand bool bDoIt(true);
275464b14621SArmin Le Grand
275564b14621SArmin Le Grand if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
275664b14621SArmin Le Grand {
275764b14621SArmin Le Grand // exception: If these ItemTypes are used, do not convert when these are negative
275864b14621SArmin Le Grand // since this means they are intended as percent values
275964b14621SArmin Le Grand sal_Int32 nValue = 0;
276064b14621SArmin Le Grand
276164b14621SArmin Le Grand if(aRet >>= nValue)
276264b14621SArmin Le Grand {
276364b14621SArmin Le Grand bDoIt = nValue > 0;
276464b14621SArmin Le Grand }
276564b14621SArmin Le Grand }
276664b14621SArmin Le Grand
276764b14621SArmin Le Grand if(bDoIt && pDoc)
276864b14621SArmin Le Grand {
276964b14621SArmin Le Grand const SfxItemPool& rPool = pDoc->GetAttrPool();
277064b14621SArmin Le Grand const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID));
277164b14621SArmin Le Grand
277264b14621SArmin Le Grand if(eMapUnit != SFX_MAPUNIT_100TH_MM)
277364b14621SArmin Le Grand {
277464b14621SArmin Le Grand SvxUnoConvertToMM(eMapUnit, aRet);
277564b14621SArmin Le Grand }
277664b14621SArmin Le Grand }
2777cdf0e10cSrcweir }
2778cdf0e10cSrcweir }
2779cdf0e10cSrcweir }
2780cdf0e10cSrcweir else
278164b14621SArmin Le Grand {
2782cdf0e10cSrcweir throw uno::RuntimeException();
278364b14621SArmin Le Grand }
278464b14621SArmin Le Grand
2785cdf0e10cSrcweir return aRet;
2786cdf0e10cSrcweir }
2787cdf0e10cSrcweir /* -----------------------------19.04.01 09:26--------------------------------
2788cdf0e10cSrcweir
2789cdf0e10cSrcweir ---------------------------------------------------------------------------*/
GetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames)2790cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl(
2791cdf0e10cSrcweir const uno::Sequence< OUString > & rPropertyNames )
2792cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2793cdf0e10cSrcweir {
2794cdf0e10cSrcweir if ( !m_pDoc )
2795cdf0e10cSrcweir throw uno::RuntimeException();
279656b35d86SArmin Le Grand
2797cdf0e10cSrcweir sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
279856b35d86SArmin Le Grand
2799cdf0e10cSrcweir switch(eFamily)
2800cdf0e10cSrcweir {
2801cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2802cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2803cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break;
2804cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
280556b35d86SArmin Le Grand default: ;
2806cdf0e10cSrcweir }
280756b35d86SArmin Le Grand
2808cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2809cdf0e10cSrcweir const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2810cdf0e10cSrcweir const OUString* pNames = rPropertyNames.getConstArray();
2811cdf0e10cSrcweir uno::Sequence< uno::Any > aRet(rPropertyNames.getLength());
2812cdf0e10cSrcweir uno::Any* pRet = aRet.getArray();
281356b35d86SArmin Le Grand SwStyleBase_Impl aBase(*m_pDoc, sStyleName, &GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); //UUUU add pDfltTxtFmtColl as parent
2814cdf0e10cSrcweir SfxStyleSheetBase* pBase = 0;
281556b35d86SArmin Le Grand
2816cdf0e10cSrcweir for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2817cdf0e10cSrcweir {
2818cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]);
2819cdf0e10cSrcweir if(!pEntry ||
2820cdf0e10cSrcweir (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS))))
2821cdf0e10cSrcweir throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
282256b35d86SArmin Le Grand
2823cdf0e10cSrcweir if(pBasePool)
2824cdf0e10cSrcweir {
2825cdf0e10cSrcweir if(!pBase)
2826cdf0e10cSrcweir {
2827cdf0e10cSrcweir sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2828cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
2829cdf0e10cSrcweir pBase = pBasePool->Find(sStyleName);
2830cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily, nSaveMask );
2831cdf0e10cSrcweir }
283256b35d86SArmin Le Grand
2833cdf0e10cSrcweir pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, eFamily, GetDoc() );
2834cdf0e10cSrcweir }
2835cdf0e10cSrcweir else if(bIsDescriptor)
2836cdf0e10cSrcweir {
2837cdf0e10cSrcweir uno::Any *pAny = 0;
2838cdf0e10cSrcweir pPropImpl->GetProperty ( pNames[nProp], pAny );
2839cdf0e10cSrcweir if( !pAny )
2840cdf0e10cSrcweir {
2841cdf0e10cSrcweir sal_Bool bExcept = sal_False;
2842cdf0e10cSrcweir switch( eFamily )
2843cdf0e10cSrcweir {
2844cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
2845cdf0e10cSrcweir bExcept = sal_True;
2846cdf0e10cSrcweir break;
2847cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
2848cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
2849cdf0e10cSrcweir pPropImpl->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] );
2850cdf0e10cSrcweir break;
2851cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
2852cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME :
2853cdf0e10cSrcweir {
2854cdf0e10cSrcweir if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END )
2855cdf0e10cSrcweir {
2856cdf0e10cSrcweir SwFmt * pFmt;
2857cdf0e10cSrcweir if ( eFamily == SFX_STYLE_FAMILY_CHAR )
2858cdf0e10cSrcweir pFmt = m_pDoc->GetDfltCharFmt();
2859cdf0e10cSrcweir else
2860cdf0e10cSrcweir pFmt = m_pDoc->GetDfltFrmFmt();
2861cdf0e10cSrcweir const SwAttrPool * pPool = pFmt->GetAttrSet().GetPool();
2862cdf0e10cSrcweir const SfxPoolItem & rItem = pPool->GetDefaultItem ( pEntry->nWID );
2863cdf0e10cSrcweir rItem.QueryValue ( pRet[nProp], pEntry->nMemberId );
2864cdf0e10cSrcweir }
2865cdf0e10cSrcweir else
2866cdf0e10cSrcweir bExcept = sal_True;
2867cdf0e10cSrcweir }
2868cdf0e10cSrcweir break;
2869cdf0e10cSrcweir
2870cdf0e10cSrcweir default:
2871cdf0e10cSrcweir ;
2872cdf0e10cSrcweir }
2873cdf0e10cSrcweir if (bExcept )
2874cdf0e10cSrcweir {
2875cdf0e10cSrcweir uno::RuntimeException aExcept;
2876cdf0e10cSrcweir aExcept.Message = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "No default value for: " ) ) + pNames[nProp];
2877cdf0e10cSrcweir throw aExcept;
2878cdf0e10cSrcweir }
2879cdf0e10cSrcweir }
2880cdf0e10cSrcweir else
2881cdf0e10cSrcweir pRet [ nProp ] = *pAny;
2882cdf0e10cSrcweir }
2883cdf0e10cSrcweir else
2884cdf0e10cSrcweir throw uno::RuntimeException();
2885cdf0e10cSrcweir }
2886cdf0e10cSrcweir return aRet;
2887cdf0e10cSrcweir }
2888cdf0e10cSrcweir /* -----------------------------04.11.03 09:26--------------------------------
2889cdf0e10cSrcweir
2890cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getPropertyValues(const uno::Sequence<OUString> & rPropertyNames)2891cdf0e10cSrcweir uno::Sequence< uno::Any > SwXStyle::getPropertyValues(
289256b35d86SArmin Le Grand const uno::Sequence< OUString >& rPropertyNames )
289356b35d86SArmin Le Grand throw(uno::RuntimeException)
2894cdf0e10cSrcweir {
2895cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2896cdf0e10cSrcweir uno::Sequence< uno::Any > aValues;
2897cdf0e10cSrcweir
2898cdf0e10cSrcweir // workaround for bad designed API
2899cdf0e10cSrcweir try
2900cdf0e10cSrcweir {
2901cdf0e10cSrcweir aValues = GetPropertyValues_Impl( rPropertyNames );
2902cdf0e10cSrcweir }
2903cdf0e10cSrcweir catch (beans::UnknownPropertyException &)
2904cdf0e10cSrcweir {
2905cdf0e10cSrcweir throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2906cdf0e10cSrcweir }
2907cdf0e10cSrcweir catch (lang::WrappedTargetException &)
2908cdf0e10cSrcweir {
2909cdf0e10cSrcweir throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2910cdf0e10cSrcweir }
2911cdf0e10cSrcweir
2912cdf0e10cSrcweir return aValues;
2913cdf0e10cSrcweir }
2914cdf0e10cSrcweir /*-- 18.04.01 13:07:29---------------------------------------------------
2915cdf0e10cSrcweir -----------------------------------------------------------------------*/
addPropertiesChangeListener(const uno::Sequence<OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)2916cdf0e10cSrcweir void SwXStyle::addPropertiesChangeListener(
2917cdf0e10cSrcweir const uno::Sequence< OUString >& /*aPropertyNames*/,
2918cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2919cdf0e10cSrcweir throw(uno::RuntimeException)
2920cdf0e10cSrcweir {
2921cdf0e10cSrcweir }
2922cdf0e10cSrcweir /*-- 18.04.01 13:07:30---------------------------------------------------
2923cdf0e10cSrcweir
2924cdf0e10cSrcweir -----------------------------------------------------------------------*/
removePropertiesChangeListener(const uno::Reference<beans::XPropertiesChangeListener> &)2925cdf0e10cSrcweir void SwXStyle::removePropertiesChangeListener(
2926cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2927cdf0e10cSrcweir throw(uno::RuntimeException)
2928cdf0e10cSrcweir {
2929cdf0e10cSrcweir }
2930cdf0e10cSrcweir /*-- 18.04.01 13:07:30---------------------------------------------------
2931cdf0e10cSrcweir
2932cdf0e10cSrcweir -----------------------------------------------------------------------*/
firePropertiesChangeEvent(const uno::Sequence<OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)2933cdf0e10cSrcweir void SwXStyle::firePropertiesChangeEvent(
2934cdf0e10cSrcweir const uno::Sequence< OUString >& /*aPropertyNames*/,
2935cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2936cdf0e10cSrcweir throw(uno::RuntimeException)
2937cdf0e10cSrcweir {
2938cdf0e10cSrcweir }
2939cdf0e10cSrcweir /*-- 17.12.98 08:26:53---------------------------------------------------
2940cdf0e10cSrcweir
2941cdf0e10cSrcweir -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const uno::Any & rValue)294256b35d86SArmin Le Grand void SwXStyle::setPropertyValue(
294356b35d86SArmin Le Grand const OUString& rPropertyName,
294456b35d86SArmin Le Grand const uno::Any& rValue)
294556b35d86SArmin Le Grand throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
2946cdf0e10cSrcweir {
2947cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2948cdf0e10cSrcweir const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2949cdf0e10cSrcweir const uno::Sequence<uno::Any> aValues(&rValue, 1);
295056b35d86SArmin Le Grand
2951cdf0e10cSrcweir SetPropertyValues_Impl( aProperties, aValues );
2952cdf0e10cSrcweir }
2953cdf0e10cSrcweir /*-- 17.12.98 08:26:53---------------------------------------------------
2954cdf0e10cSrcweir
2955cdf0e10cSrcweir -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)295656b35d86SArmin Le Grand uno::Any SwXStyle::getPropertyValue(
295756b35d86SArmin Le Grand const OUString& rPropertyName)
2958cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2959cdf0e10cSrcweir {
2960cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
2961cdf0e10cSrcweir const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2962cdf0e10cSrcweir return GetPropertyValues_Impl(aProperties).getConstArray()[0];
2963cdf0e10cSrcweir
2964cdf0e10cSrcweir }
2965cdf0e10cSrcweir /*-- 17.12.98 08:26:53---------------------------------------------------
2966cdf0e10cSrcweir
2967cdf0e10cSrcweir -----------------------------------------------------------------------*/
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)296856b35d86SArmin Le Grand void SwXStyle::addPropertyChangeListener(
296956b35d86SArmin Le Grand const OUString& /*rPropertyName*/,
2970cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2971cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2972cdf0e10cSrcweir {
2973cdf0e10cSrcweir DBG_WARNING("not implemented");
2974cdf0e10cSrcweir }
2975cdf0e10cSrcweir /*-- 17.12.98 08:26:54---------------------------------------------------
2976cdf0e10cSrcweir
2977cdf0e10cSrcweir -----------------------------------------------------------------------*/
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)297856b35d86SArmin Le Grand void SwXStyle::removePropertyChangeListener(
297956b35d86SArmin Le Grand const OUString& /*rPropertyName*/,
2980cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2981cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2982cdf0e10cSrcweir {
2983cdf0e10cSrcweir DBG_WARNING("not implemented");
2984cdf0e10cSrcweir }
2985cdf0e10cSrcweir /*-- 17.12.98 08:26:54---------------------------------------------------
2986cdf0e10cSrcweir
2987cdf0e10cSrcweir -----------------------------------------------------------------------*/
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)298856b35d86SArmin Le Grand void SwXStyle::addVetoableChangeListener(
298956b35d86SArmin Le Grand const OUString& /*rPropertyName*/,
2990cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2991cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2992cdf0e10cSrcweir {
2993cdf0e10cSrcweir DBG_WARNING("not implemented");
2994cdf0e10cSrcweir }
2995cdf0e10cSrcweir /*-- 17.12.98 08:26:54---------------------------------------------------
2996cdf0e10cSrcweir
2997cdf0e10cSrcweir -----------------------------------------------------------------------*/
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)299856b35d86SArmin Le Grand void SwXStyle::removeVetoableChangeListener(
299956b35d86SArmin Le Grand const OUString& /*rPropertyName*/,
3000cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
3001cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3002cdf0e10cSrcweir {
3003cdf0e10cSrcweir DBG_WARNING("not implemented");
3004cdf0e10cSrcweir }
3005cdf0e10cSrcweir
3006cdf0e10cSrcweir /*-- 08.03.99 10:50:26---------------------------------------------------
3007cdf0e10cSrcweir
3008cdf0e10cSrcweir -----------------------------------------------------------------------*/
getPropertyState(const OUString & rPropertyName)300956b35d86SArmin Le Grand beans::PropertyState SwXStyle::getPropertyState(
301056b35d86SArmin Le Grand const OUString& rPropertyName)
3011cdf0e10cSrcweir throw( beans::UnknownPropertyException, uno::RuntimeException )
3012cdf0e10cSrcweir {
3013cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
3014cdf0e10cSrcweir uno::Sequence< OUString > aNames(1);
3015cdf0e10cSrcweir OUString* pNames = aNames.getArray();
3016cdf0e10cSrcweir pNames[0] = rPropertyName;
3017cdf0e10cSrcweir uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
3018cdf0e10cSrcweir return aStates.getConstArray()[0];
3019cdf0e10cSrcweir }
3020cdf0e10cSrcweir /*-- 08.03.99 10:50:27---------------------------------------------------
3021cdf0e10cSrcweir
3022cdf0e10cSrcweir -----------------------------------------------------------------------*/
302356b35d86SArmin Le Grand
getPropertyStates(const uno::Sequence<OUString> & rPropertyNames)3024cdf0e10cSrcweir uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates(
3025cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames)
3026cdf0e10cSrcweir throw( beans::UnknownPropertyException, uno::RuntimeException )
3027cdf0e10cSrcweir {
3028cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
3029cdf0e10cSrcweir uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
3030cdf0e10cSrcweir beans::PropertyState* pStates = aRet.getArray();
303156b35d86SArmin Le Grand
3032cdf0e10cSrcweir if(pBasePool)
3033cdf0e10cSrcweir {
3034cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily );
3035cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
3036cdf0e10cSrcweir DBG_ASSERT(pBase, "where is the style?" );
3037cdf0e10cSrcweir
3038cdf0e10cSrcweir if(pBase)
3039cdf0e10cSrcweir {
3040cdf0e10cSrcweir const OUString* pNames = rPropertyNames.getConstArray();
3041cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3042cdf0e10cSrcweir sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
304356b35d86SArmin Le Grand
3044cdf0e10cSrcweir switch(eFamily)
3045cdf0e10cSrcweir {
3046cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
3047cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
3048cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
3049cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
305056b35d86SArmin Le Grand default: ;
3051cdf0e10cSrcweir }
305256b35d86SArmin Le Grand
3053cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
3054cdf0e10cSrcweir const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
305556b35d86SArmin Le Grand const SfxItemSet& rSet = xStyle->GetItemSet();
3056cdf0e10cSrcweir
3057cdf0e10cSrcweir for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
3058cdf0e10cSrcweir {
3059cdf0e10cSrcweir const String& rPropName = pNames[i];
3060cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName);
306156b35d86SArmin Le Grand bool bDone(false);
306256b35d86SArmin Le Grand
3063cdf0e10cSrcweir if(!pEntry)
306456b35d86SArmin Le Grand {
3065cdf0e10cSrcweir throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
3066cdf0e10cSrcweir }
306756b35d86SArmin Le Grand
306856b35d86SArmin Le Grand if( FN_UNO_NUM_RULES == pEntry->nWID || FN_UNO_FOLLOW_STYLE == pEntry->nWID )
3069cdf0e10cSrcweir {
307056b35d86SArmin Le Grand // handle NumRules first, done
307156b35d86SArmin Le Grand pStates[i] = beans::PropertyState_DIRECT_VALUE;
307256b35d86SArmin Le Grand bDone = true;
307356b35d86SArmin Le Grand }
307456b35d86SArmin Le Grand
307556b35d86SArmin Le Grand // allow to retarget the SfxItemSet working on, default correctly. Only
307656b35d86SArmin Le Grand // use pSourceSet below this point (except in header/footer processing)
307756b35d86SArmin Le Grand const SfxItemSet* pSourceSet = &rSet;
307856b35d86SArmin Le Grand
307956b35d86SArmin Le Grand if(!bDone)
308056b35d86SArmin Le Grand {
308156b35d86SArmin Le Grand // check for Header/Footer entry
308256b35d86SArmin Le Grand const bool bHeader(SFX_STYLE_FAMILY_PAGE == eFamily && rPropName.EqualsAscii("Header", 0, 6));
308356b35d86SArmin Le Grand const bool bFooter(SFX_STYLE_FAMILY_PAGE == eFamily && rPropName.EqualsAscii("Footer", 0, 6));
308456b35d86SArmin Le Grand
308556b35d86SArmin Le Grand if(bHeader || bFooter)
308656b35d86SArmin Le Grand {
3087cdf0e10cSrcweir const SvxSetItem* pSetItem;
308856b35d86SArmin Le Grand
308956b35d86SArmin Le Grand if(SFX_ITEM_SET == rSet.GetItemState(
3090cdf0e10cSrcweir bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
309156b35d86SArmin Le Grand sal_False,
309256b35d86SArmin Le Grand (const SfxPoolItem**)&pSetItem))
3093cdf0e10cSrcweir {
309456b35d86SArmin Le Grand // retarget the SfxItemSet to the HeaderFooter SfxSetItem's SfxItenSet
309556b35d86SArmin Le Grand pSourceSet = &pSetItem->GetItemSet();
3096cdf0e10cSrcweir }
3097cdf0e10cSrcweir else
309856b35d86SArmin Le Grand {
309956b35d86SArmin Le Grand // if no SetItem, value is ambigous and we are done
310056b35d86SArmin Le Grand pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
310156b35d86SArmin Le Grand bDone = true;
310256b35d86SArmin Le Grand }
310356b35d86SArmin Le Grand }
310456b35d86SArmin Le Grand }
310556b35d86SArmin Le Grand
310656b35d86SArmin Le Grand if(!bDone && OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
310756b35d86SArmin Le Grand {
310856b35d86SArmin Le Grand //UUUU
310956b35d86SArmin Le Grand if(SFX_ITEM_SET == pSourceSet->GetItemState(XATTR_FILLBMP_STRETCH, false)
311056b35d86SArmin Le Grand || SFX_ITEM_SET == pSourceSet->GetItemState(XATTR_FILLBMP_TILE, false))
311156b35d86SArmin Le Grand {
311256b35d86SArmin Le Grand pStates[i] = beans::PropertyState_DIRECT_VALUE;
311356b35d86SArmin Le Grand }
311456b35d86SArmin Le Grand else
311556b35d86SArmin Le Grand {
3116cdf0e10cSrcweir pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
3117cdf0e10cSrcweir }
311856b35d86SArmin Le Grand
311956b35d86SArmin Le Grand bDone = true;
312056b35d86SArmin Le Grand }
312156b35d86SArmin Le Grand
312256b35d86SArmin Le Grand //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND
312356b35d86SArmin Le Grand // as beans::PropertyState_DIRECT_VALUE to let users of this property call
312456b35d86SArmin Le Grand // getPropertyValue where the member properties will be mapped from the
312556b35d86SArmin Le Grand // fill attributes to the according SvxBrushItem entries
312656b35d86SArmin Le Grand if(!bDone && RES_BACKGROUND == pEntry->nWID
312756b35d86SArmin Le Grand && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet))
3128cdf0e10cSrcweir {
312956b35d86SArmin Le Grand pStates[i] = beans::PropertyState_DIRECT_VALUE;
313056b35d86SArmin Le Grand bDone = true;
313156b35d86SArmin Le Grand }
313256b35d86SArmin Le Grand
313356b35d86SArmin Le Grand if(!bDone)
3134cdf0e10cSrcweir {
313556b35d86SArmin Le Grand pStates[i] = pPropSet->getPropertyState(*pEntry, *pSourceSet);
313656b35d86SArmin Le Grand
313756b35d86SArmin Le Grand if(SFX_STYLE_FAMILY_PAGE == eFamily && SID_ATTR_PAGE_SIZE == pEntry->nWID && beans::PropertyState_DIRECT_VALUE == pStates[i])
313856b35d86SArmin Le Grand {
313956b35d86SArmin Le Grand const SvxSizeItem& rSize = static_cast <const SvxSizeItem&>( rSet.Get(SID_ATTR_PAGE_SIZE));
3140cdf0e10cSrcweir sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f;
314156b35d86SArmin Le Grand
3142cdf0e10cSrcweir if((LONG_MAX == rSize.GetSize().Width() &&
3143cdf0e10cSrcweir (MID_SIZE_WIDTH == nMemberId ||
3144cdf0e10cSrcweir MID_SIZE_SIZE == nMemberId)) ||
3145cdf0e10cSrcweir (LONG_MAX == rSize.GetSize().Height() &&
3146cdf0e10cSrcweir MID_SIZE_HEIGHT == nMemberId))
3147cdf0e10cSrcweir {
3148cdf0e10cSrcweir pStates[i] = beans::PropertyState_DEFAULT_VALUE;
3149cdf0e10cSrcweir }
3150cdf0e10cSrcweir }
3151cdf0e10cSrcweir }
3152cdf0e10cSrcweir }
3153cdf0e10cSrcweir }
3154cdf0e10cSrcweir else
315556b35d86SArmin Le Grand {
3156cdf0e10cSrcweir throw uno::RuntimeException();
3157cdf0e10cSrcweir }
315856b35d86SArmin Le Grand }
3159cdf0e10cSrcweir else
316056b35d86SArmin Le Grand {
3161cdf0e10cSrcweir throw uno::RuntimeException();
316256b35d86SArmin Le Grand }
316356b35d86SArmin Le Grand
3164cdf0e10cSrcweir return aRet;
3165cdf0e10cSrcweir }
3166cdf0e10cSrcweir /*-- 08.03.99 10:50:27---------------------------------------------------
3167cdf0e10cSrcweir
3168cdf0e10cSrcweir -----------------------------------------------------------------------*/
setPropertyToDefault(const OUString & rPropertyName)316956b35d86SArmin Le Grand void SwXStyle::setPropertyToDefault(
317056b35d86SArmin Le Grand const OUString& rPropertyName)
3171cdf0e10cSrcweir throw( beans::UnknownPropertyException, uno::RuntimeException )
3172cdf0e10cSrcweir {
3173cdf0e10cSrcweir const uno::Sequence < OUString > aSequence(&rPropertyName,1);
3174cdf0e10cSrcweir setPropertiesToDefault(aSequence);
3175cdf0e10cSrcweir }
3176cdf0e10cSrcweir
setPropertiesToDefault(const uno::Sequence<OUString> & aPropertyNames)317756b35d86SArmin Le Grand void SAL_CALL SwXStyle::setPropertiesToDefault(
317856b35d86SArmin Le Grand const uno::Sequence< OUString >& aPropertyNames )
3179cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
3180cdf0e10cSrcweir {
3181cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
3182cdf0e10cSrcweir SwFmt *pTargetFmt = 0;
3183cdf0e10cSrcweir
3184cdf0e10cSrcweir if(pBasePool)
3185cdf0e10cSrcweir {
3186cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily);
3187cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
3188cdf0e10cSrcweir DBG_ASSERT(pBase, "Where is the style?");
3189cdf0e10cSrcweir
3190cdf0e10cSrcweir if(pBase)
3191cdf0e10cSrcweir {
3192cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
3193cdf0e10cSrcweir switch(eFamily)
3194cdf0e10cSrcweir {
319556b35d86SArmin Le Grand case SFX_STYLE_FAMILY_CHAR:
319656b35d86SArmin Le Grand pTargetFmt = xStyle->GetCharFmt();
319756b35d86SArmin Le Grand break;
319856b35d86SArmin Le Grand
319956b35d86SArmin Le Grand case SFX_STYLE_FAMILY_PARA:
320056b35d86SArmin Le Grand pTargetFmt = xStyle->GetCollection();
320156b35d86SArmin Le Grand break;
320256b35d86SArmin Le Grand
320356b35d86SArmin Le Grand case SFX_STYLE_FAMILY_FRAME:
320456b35d86SArmin Le Grand pTargetFmt = xStyle->GetFrmFmt();
320556b35d86SArmin Le Grand break;
320656b35d86SArmin Le Grand
3207cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
3208cdf0e10cSrcweir {
3209cdf0e10cSrcweir sal_uInt16 nPgDscPos = USHRT_MAX;
3210cdf0e10cSrcweir SwPageDesc *pDesc = m_pDoc->FindPageDescByName(xStyle->GetPageDesc()->GetName(),&nPgDscPos);
321156b35d86SArmin Le Grand
3212cdf0e10cSrcweir if(pDesc)
321356b35d86SArmin Le Grand {
3214cdf0e10cSrcweir pTargetFmt = &pDesc->GetMaster();
3215cdf0e10cSrcweir }
3216cdf0e10cSrcweir break;
321756b35d86SArmin Le Grand }
3218cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
3219cdf0e10cSrcweir break;
322056b35d86SArmin Le Grand default: ;
3221cdf0e10cSrcweir }
3222cdf0e10cSrcweir }
3223cdf0e10cSrcweir }
322456b35d86SArmin Le Grand
3225cdf0e10cSrcweir sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
322656b35d86SArmin Le Grand
3227cdf0e10cSrcweir switch(eFamily)
3228cdf0e10cSrcweir {
3229cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
3230cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME: nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
3231cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE: nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
3232cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
323356b35d86SArmin Le Grand default: ;
3234cdf0e10cSrcweir }
323556b35d86SArmin Le Grand
3236cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
3237cdf0e10cSrcweir const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
3238cdf0e10cSrcweir const OUString* pNames = aPropertyNames.getConstArray();
3239cdf0e10cSrcweir
3240cdf0e10cSrcweir if(pTargetFmt)
3241cdf0e10cSrcweir {
3242cdf0e10cSrcweir for(sal_Int32 nProp = 0,nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++)
3243cdf0e10cSrcweir {
3244cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[nProp]);
3245cdf0e10cSrcweir
324656b35d86SArmin Le Grand if(!pEntry)
324756b35d86SArmin Le Grand {
324856b35d86SArmin Le Grand throw beans::UnknownPropertyException(OUString(RTL_CONSTASCII_USTRINGPARAM("Property is unknown: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this));
324956b35d86SArmin Le Grand }
325056b35d86SArmin Le Grand
325156b35d86SArmin Le Grand if(pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES)
325256b35d86SArmin Le Grand {
325356b35d86SArmin Le Grand throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot reset: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this));
325456b35d86SArmin Le Grand }
325556b35d86SArmin Le Grand
325656b35d86SArmin Le Grand if(pEntry->nFlags & beans::PropertyAttribute::READONLY)
325756b35d86SArmin Le Grand {
325856b35d86SArmin Le Grand throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("setPropertiesToDefault: property is read-only: ")) + pNames[nProp],static_cast <cppu::OWeakObject *> (this));
325956b35d86SArmin Le Grand }
326056b35d86SArmin Le Grand
326156b35d86SArmin Le Grand if(pEntry->nWID == RES_PARATR_OUTLINELEVEL)
326256b35d86SArmin Le Grand {
3263cdf0e10cSrcweir static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle();
326456b35d86SArmin Le Grand }
3265cdf0e10cSrcweir else
326656b35d86SArmin Le Grand {
326756b35d86SArmin Le Grand pTargetFmt->ResetFmtAttr(pEntry->nWID);
326856b35d86SArmin Le Grand }
326956b35d86SArmin Le Grand
327056b35d86SArmin Le Grand if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
327156b35d86SArmin Le Grand {
327256b35d86SArmin Le Grand //UUUU
327356b35d86SArmin Le Grand SwDoc* pDoc = pTargetFmt->GetDoc();
327456b35d86SArmin Le Grand SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
327556b35d86SArmin Le Grand aSet.SetParent(&pTargetFmt->GetAttrSet());
327656b35d86SArmin Le Grand
327756b35d86SArmin Le Grand aSet.ClearItem(XATTR_FILLBMP_STRETCH);
327856b35d86SArmin Le Grand aSet.ClearItem(XATTR_FILLBMP_TILE);
327956b35d86SArmin Le Grand
328056b35d86SArmin Le Grand pTargetFmt->SetFmtAttr(aSet);
328156b35d86SArmin Le Grand }
3282cdf0e10cSrcweir }
3283cdf0e10cSrcweir }
3284cdf0e10cSrcweir else if(bIsDescriptor)
3285cdf0e10cSrcweir {
3286cdf0e10cSrcweir for(sal_Int32 nProp = 0,nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++)
328756b35d86SArmin Le Grand {
3288cdf0e10cSrcweir pPropImpl->ClearProperty(pNames[nProp]);
3289cdf0e10cSrcweir }
3290cdf0e10cSrcweir }
329156b35d86SArmin Le Grand }
3292cdf0e10cSrcweir
setAllPropertiesToDefault()3293cdf0e10cSrcweir void SAL_CALL SwXStyle::setAllPropertiesToDefault()
3294cdf0e10cSrcweir throw (uno::RuntimeException)
3295cdf0e10cSrcweir {
3296cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
329756b35d86SArmin Le Grand
3298cdf0e10cSrcweir if(pBasePool)
3299cdf0e10cSrcweir {
3300cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily);
3301cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
3302cdf0e10cSrcweir DBG_ASSERT(pBase, "where is the style, you fiend!?");
3303cdf0e10cSrcweir
3304cdf0e10cSrcweir if(pBase)
3305cdf0e10cSrcweir {
3306cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3307cdf0e10cSrcweir SwFmt *pTargetFmt = 0;
3308cdf0e10cSrcweir sal_uInt16 nPgDscPos = USHRT_MAX;
330956b35d86SArmin Le Grand
3310cdf0e10cSrcweir switch(eFamily)
3311cdf0e10cSrcweir {
3312cdf0e10cSrcweir case SFX_STYLE_FAMILY_CHAR:
3313cdf0e10cSrcweir pTargetFmt = xStyle->GetCharFmt();
3314cdf0e10cSrcweir break;
331556b35d86SArmin Le Grand
3316cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA:
3317cdf0e10cSrcweir {
3318cdf0e10cSrcweir pTargetFmt = xStyle->GetCollection();
331956b35d86SArmin Le Grand
3320cdf0e10cSrcweir if(xStyle->GetCollection())
3321cdf0e10cSrcweir {
3322cdf0e10cSrcweir // xStyle->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei
3323cdf0e10cSrcweir xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,add by zhaojianwei
3324cdf0e10cSrcweir }
3325cdf0e10cSrcweir break;
332656b35d86SArmin Le Grand }
332756b35d86SArmin Le Grand
3328cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME:
3329cdf0e10cSrcweir pTargetFmt = xStyle->GetFrmFmt();
3330cdf0e10cSrcweir break;
333156b35d86SArmin Le Grand
3332cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE:
3333cdf0e10cSrcweir {
3334cdf0e10cSrcweir SwPageDesc *pDesc = m_pDoc->FindPageDescByName(xStyle->GetPageDesc()->GetName(),&nPgDscPos);
333556b35d86SArmin Le Grand
3336cdf0e10cSrcweir if(pDesc)
3337cdf0e10cSrcweir {
3338cdf0e10cSrcweir pTargetFmt = &pDesc->GetMaster();
3339cdf0e10cSrcweir pDesc->SetUseOn(nsUseOnPage::PD_ALL);
3340cdf0e10cSrcweir }
3341cdf0e10cSrcweir break;
334256b35d86SArmin Le Grand }
334356b35d86SArmin Le Grand
3344cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO:
3345cdf0e10cSrcweir break;
3346cdf0e10cSrcweir
334756b35d86SArmin Le Grand default: ;
3348cdf0e10cSrcweir }
334956b35d86SArmin Le Grand
3350cdf0e10cSrcweir if(pTargetFmt)
3351cdf0e10cSrcweir {
3352cdf0e10cSrcweir if(USHRT_MAX != nPgDscPos)
3353cdf0e10cSrcweir {
3354cdf0e10cSrcweir SwPageDesc& rPageDesc = m_pDoc->_GetPageDesc(nPgDscPos);
3355cdf0e10cSrcweir rPageDesc.ResetAllMasterAttr();
3356cdf0e10cSrcweir
3357cdf0e10cSrcweir SvxLRSpaceItem aLR(RES_LR_SPACE);
3358cdf0e10cSrcweir sal_Int32 nSize = GetMetricVal(CM_1) * 2;
3359cdf0e10cSrcweir aLR.SetLeft(nSize);
3360cdf0e10cSrcweir aLR.SetLeft(nSize);
3361cdf0e10cSrcweir SvxULSpaceItem aUL(RES_UL_SPACE);
3362cdf0e10cSrcweir aUL.SetUpper(static_cast <sal_uInt16> (nSize));
3363cdf0e10cSrcweir aUL.SetLower(static_cast <sal_uInt16> (nSize));
3364cdf0e10cSrcweir pTargetFmt->SetFmtAttr(aLR);
3365cdf0e10cSrcweir pTargetFmt->SetFmtAttr(aUL);
3366cdf0e10cSrcweir SwPageDesc* pStdPgDsc = m_pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD);
3367cdf0e10cSrcweir SwFmtFrmSize aFrmSz(ATT_FIX_SIZE);
336856b35d86SArmin Le Grand
3369cdf0e10cSrcweir if(RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId())
3370cdf0e10cSrcweir {
3371cdf0e10cSrcweir if(m_pDoc->getPrinter(false))
3372cdf0e10cSrcweir {
3373cdf0e10cSrcweir const Size aPhysSize(SvxPaperInfo::GetPaperSize(
3374cdf0e10cSrcweir static_cast<Printer*>(m_pDoc->getPrinter(false))));
3375cdf0e10cSrcweir aFrmSz.SetSize(aPhysSize);
3376cdf0e10cSrcweir }
3377cdf0e10cSrcweir else
3378cdf0e10cSrcweir {
3379cdf0e10cSrcweir // --> OD 2008-07-25 #i91928#
3380cdf0e10cSrcweir // aFrmSz.SetWidth( LONG_MAX );
3381cdf0e10cSrcweir // aFrmSz.SetHeight( LONG_MAX );
3382cdf0e10cSrcweir aFrmSz.SetSize(SvxPaperInfo::GetDefaultPaperSize());
3383cdf0e10cSrcweir // <--
3384cdf0e10cSrcweir }
3385cdf0e10cSrcweir
3386cdf0e10cSrcweir }
3387cdf0e10cSrcweir else
3388cdf0e10cSrcweir {
3389cdf0e10cSrcweir aFrmSz = pStdPgDsc->GetMaster().GetFrmSize();
3390cdf0e10cSrcweir }
339156b35d86SArmin Le Grand
3392cdf0e10cSrcweir if(pStdPgDsc->GetLandscape())
3393cdf0e10cSrcweir {
3394cdf0e10cSrcweir SwTwips nTmp = aFrmSz.GetHeight();
3395cdf0e10cSrcweir aFrmSz.SetHeight(aFrmSz.GetWidth());
3396cdf0e10cSrcweir aFrmSz.SetWidth(nTmp);
3397cdf0e10cSrcweir }
339856b35d86SArmin Le Grand
3399cdf0e10cSrcweir pTargetFmt->SetFmtAttr(aFrmSz);
3400cdf0e10cSrcweir }
3401cdf0e10cSrcweir else
3402cdf0e10cSrcweir {
3403cdf0e10cSrcweir // --> OD 2007-01-25 #i73790# - method renamed
3404cdf0e10cSrcweir pTargetFmt->ResetAllFmtAttr();
3405cdf0e10cSrcweir // <--
3406cdf0e10cSrcweir }
3407cdf0e10cSrcweir
3408cdf0e10cSrcweir if(USHRT_MAX != nPgDscPos)
340956b35d86SArmin Le Grand {
341056b35d86SArmin Le Grand m_pDoc->ChgPageDesc(nPgDscPos, const_cast<const SwDoc *>(m_pDoc)->GetPageDesc(nPgDscPos));
341156b35d86SArmin Le Grand }
3412cdf0e10cSrcweir }
3413cdf0e10cSrcweir
3414cdf0e10cSrcweir }
3415cdf0e10cSrcweir else
341656b35d86SArmin Le Grand {
3417cdf0e10cSrcweir throw uno::RuntimeException();
3418cdf0e10cSrcweir }
341956b35d86SArmin Le Grand }
3420cdf0e10cSrcweir else if(bIsDescriptor)
342156b35d86SArmin Le Grand {
3422cdf0e10cSrcweir pPropImpl->ClearAllProperties();
342356b35d86SArmin Le Grand }
3424cdf0e10cSrcweir else
342556b35d86SArmin Le Grand {
3426cdf0e10cSrcweir throw uno::RuntimeException();
3427cdf0e10cSrcweir }
342856b35d86SArmin Le Grand }
3429cdf0e10cSrcweir
getPropertyDefaults(const uno::Sequence<OUString> & aPropertyNames)343056b35d86SArmin Le Grand uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults(
343156b35d86SArmin Le Grand const uno::Sequence< OUString >& aPropertyNames )
3432cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
3433cdf0e10cSrcweir {
3434cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
3435cdf0e10cSrcweir sal_Int32 nCount = aPropertyNames.getLength();
3436cdf0e10cSrcweir uno::Sequence < uno::Any > aRet(nCount);
343756b35d86SArmin Le Grand
3438cdf0e10cSrcweir if(nCount)
3439cdf0e10cSrcweir {
3440cdf0e10cSrcweir if(pBasePool)
3441cdf0e10cSrcweir {
3442cdf0e10cSrcweir pBasePool->SetSearchMask(eFamily);
3443cdf0e10cSrcweir SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
3444cdf0e10cSrcweir DBG_ASSERT(pBase,"Doesn't seem to be a style!");
3445cdf0e10cSrcweir
3446cdf0e10cSrcweir if(pBase)
3447cdf0e10cSrcweir {
3448cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
3449cdf0e10cSrcweir sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
345056b35d86SArmin Le Grand
3451cdf0e10cSrcweir switch(eFamily)
3452cdf0e10cSrcweir {
3453cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
3454cdf0e10cSrcweir case SFX_STYLE_FAMILY_FRAME: nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
3455cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE: nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
3456cdf0e10cSrcweir case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
345756b35d86SArmin Le Grand default: ;
3458cdf0e10cSrcweir }
345956b35d86SArmin Le Grand
3460cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
3461cdf0e10cSrcweir const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
3462cdf0e10cSrcweir const SfxItemSet &rSet = xStyle->GetItemSet(),*pParentSet = rSet.GetParent();
3463cdf0e10cSrcweir const OUString *pNames = aPropertyNames.getConstArray();
3464cdf0e10cSrcweir uno::Any *pRet = aRet.getArray();
346556b35d86SArmin Le Grand
3466cdf0e10cSrcweir for(sal_Int32 i = 0; i < nCount; i++)
3467cdf0e10cSrcweir {
3468cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(pNames[i]);
346956b35d86SArmin Le Grand
3470cdf0e10cSrcweir if(!pEntry)
347156b35d86SArmin Le Grand {
3472cdf0e10cSrcweir throw beans::UnknownPropertyException(OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + pNames[i],static_cast <cppu::OWeakObject *> (this));
347356b35d86SArmin Le Grand }
3474cdf0e10cSrcweir
3475cdf0e10cSrcweir if(pParentSet)
347656b35d86SArmin Le Grand {
3477cdf0e10cSrcweir aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i],*pParentSet,pRet[i]);
347856b35d86SArmin Le Grand }
3479cdf0e10cSrcweir else if(pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID))
3480cdf0e10cSrcweir {
3481cdf0e10cSrcweir const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID);
348256b35d86SArmin Le Grand
3483cdf0e10cSrcweir rItem.QueryValue(pRet[i], pEntry->nMemberId);
3484cdf0e10cSrcweir }
3485cdf0e10cSrcweir }
3486cdf0e10cSrcweir }
3487cdf0e10cSrcweir else
348856b35d86SArmin Le Grand {
3489cdf0e10cSrcweir throw uno::RuntimeException();
3490cdf0e10cSrcweir }
349156b35d86SArmin Le Grand }
3492cdf0e10cSrcweir else
349356b35d86SArmin Le Grand {
3494cdf0e10cSrcweir throw uno::RuntimeException();
3495cdf0e10cSrcweir }
349656b35d86SArmin Le Grand }
3497cdf0e10cSrcweir return aRet;
3498cdf0e10cSrcweir }
3499cdf0e10cSrcweir /*-- 08.03.99 10:50:27---------------------------------------------------
3500cdf0e10cSrcweir
3501cdf0e10cSrcweir -----------------------------------------------------------------------*/
getPropertyDefault(const OUString & rPropertyName)350256b35d86SArmin Le Grand uno::Any SwXStyle::getPropertyDefault(
350356b35d86SArmin Le Grand const OUString& rPropertyName)
3504cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3505cdf0e10cSrcweir {
3506cdf0e10cSrcweir const uno::Sequence < OUString > aSequence(&rPropertyName,1);
3507cdf0e10cSrcweir return getPropertyDefaults(aSequence).getConstArray()[0];
3508cdf0e10cSrcweir }
3509cdf0e10cSrcweir /* -----------------21.01.99 13:08-------------------
3510cdf0e10cSrcweir *
3511cdf0e10cSrcweir * --------------------------------------------------*/
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)3512cdf0e10cSrcweir void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
3513cdf0e10cSrcweir {
3514cdf0e10cSrcweir SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
3515cdf0e10cSrcweir if( pHint )
3516cdf0e10cSrcweir {
3517cdf0e10cSrcweir if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED))
3518cdf0e10cSrcweir {
3519cdf0e10cSrcweir pBasePool = 0;
3520cdf0e10cSrcweir EndListening(rBC);
3521cdf0e10cSrcweir }
3522cdf0e10cSrcweir else if( pHint->GetId() &(SFX_STYLESHEET_CHANGED|SFX_STYLESHEET_ERASED) )
3523cdf0e10cSrcweir {
3524cdf0e10cSrcweir ((SfxStyleSheetBasePool&)rBC).SetSearchMask(eFamily);
3525cdf0e10cSrcweir SfxStyleSheetBase* pOwnBase = ((SfxStyleSheetBasePool&)rBC).Find(sStyleName);
3526cdf0e10cSrcweir if(!pOwnBase)
3527cdf0e10cSrcweir {
3528cdf0e10cSrcweir EndListening(rBC);
3529cdf0e10cSrcweir Invalidate();
3530cdf0e10cSrcweir }
3531cdf0e10cSrcweir }
3532cdf0e10cSrcweir }
3533cdf0e10cSrcweir }
3534cdf0e10cSrcweir /* -----------------------------15.08.00 11:35--------------------------------
3535cdf0e10cSrcweir
3536cdf0e10cSrcweir ---------------------------------------------------------------------------*/
Invalidate()3537cdf0e10cSrcweir void SwXStyle::Invalidate()
3538cdf0e10cSrcweir {
3539cdf0e10cSrcweir sStyleName.Erase();
3540cdf0e10cSrcweir pBasePool = 0;
3541cdf0e10cSrcweir m_pDoc = 0;
3542cdf0e10cSrcweir mxStyleData.clear();
3543cdf0e10cSrcweir mxStyleFamily.clear();
3544cdf0e10cSrcweir }
3545cdf0e10cSrcweir
3546cdf0e10cSrcweir
3547cdf0e10cSrcweir /******************************************************************
3548cdf0e10cSrcweir * SwXPageStyle
3549cdf0e10cSrcweir ******************************************************************/
3550cdf0e10cSrcweir /*-- 17.12.98 08:43:35---------------------------------------------------
3551cdf0e10cSrcweir
3552cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXPageStyle(SfxStyleSheetBasePool & rPool,SwDocShell * pDocSh,SfxStyleFamily eFam,const String & rStyleName)355356b35d86SArmin Le Grand SwXPageStyle::SwXPageStyle(
355456b35d86SArmin Le Grand SfxStyleSheetBasePool& rPool,
3555cdf0e10cSrcweir SwDocShell* pDocSh, SfxStyleFamily eFam,
355656b35d86SArmin Le Grand const String& rStyleName)
355756b35d86SArmin Le Grand : SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName),
3558cdf0e10cSrcweir pDocShell(pDocSh)
3559cdf0e10cSrcweir {
3560cdf0e10cSrcweir }
3561cdf0e10cSrcweir /* -----------------23.08.99 15:52-------------------
3562cdf0e10cSrcweir
3563cdf0e10cSrcweir --------------------------------------------------*/
SwXPageStyle(SwDocShell * pDocSh)356456b35d86SArmin Le Grand SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh)
356556b35d86SArmin Le Grand : SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE),
3566cdf0e10cSrcweir pDocShell(pDocSh)
3567cdf0e10cSrcweir {
3568cdf0e10cSrcweir }
3569cdf0e10cSrcweir
3570cdf0e10cSrcweir /*-- 17.12.98 08:43:35---------------------------------------------------
3571cdf0e10cSrcweir
3572cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXPageStyle()3573cdf0e10cSrcweir SwXPageStyle::~SwXPageStyle()
3574cdf0e10cSrcweir {
3575cdf0e10cSrcweir
3576cdf0e10cSrcweir }
3577cdf0e10cSrcweir /* -----------------------------18.04.01 13:50--------------------------------
3578cdf0e10cSrcweir
3579cdf0e10cSrcweir ---------------------------------------------------------------------------*/
SetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)3580cdf0e10cSrcweir void SAL_CALL SwXPageStyle::SetPropertyValues_Impl(
3581cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames,
3582cdf0e10cSrcweir const uno::Sequence< uno::Any >& rValues )
358356b35d86SArmin Le Grand throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
3584cdf0e10cSrcweir {
3585cdf0e10cSrcweir if(!GetDoc())
3586cdf0e10cSrcweir throw uno::RuntimeException();
3587cdf0e10cSrcweir
3588cdf0e10cSrcweir if(rPropertyNames.getLength() != rValues.getLength())
3589cdf0e10cSrcweir throw lang::IllegalArgumentException();
3590cdf0e10cSrcweir
3591cdf0e10cSrcweir const OUString* pNames = rPropertyNames.getConstArray();
3592cdf0e10cSrcweir const uno::Any* pValues = rValues.getConstArray();
3593cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3594cdf0e10cSrcweir const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
359556b35d86SArmin Le Grand SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrmFmt()->GetAttrSet()); //UUUU add pDfltFrmFmt as parent
359656b35d86SArmin Le Grand
3597cdf0e10cSrcweir if(GetBasePool())
3598cdf0e10cSrcweir {
3599cdf0e10cSrcweir sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3600cdf0e10cSrcweir GetBasePool()->SetSearchMask(GetFamily());
3601cdf0e10cSrcweir SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName());
3602cdf0e10cSrcweir GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3603cdf0e10cSrcweir DBG_ASSERT(pBase, "where is the style?" );
360456b35d86SArmin Le Grand
3605cdf0e10cSrcweir if(pBase)
360656b35d86SArmin Le Grand {
360756b35d86SArmin Le Grand aBaseImpl.setNewBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
360856b35d86SArmin Le Grand }
3609cdf0e10cSrcweir else
361056b35d86SArmin Le Grand {
3611cdf0e10cSrcweir throw uno::RuntimeException();
3612cdf0e10cSrcweir }
361356b35d86SArmin Le Grand }
3614cdf0e10cSrcweir
3615cdf0e10cSrcweir for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
3616cdf0e10cSrcweir {
361756b35d86SArmin Le Grand const String& rPropName = pNames[nProp];
361856b35d86SArmin Le Grand const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName );
361956b35d86SArmin Le Grand
3620cdf0e10cSrcweir if (!pEntry)
362156b35d86SArmin Le Grand {
362256b35d86SArmin Le Grand throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
362356b35d86SArmin Le Grand }
362456b35d86SArmin Le Grand
3625cdf0e10cSrcweir if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
362656b35d86SArmin Le Grand {
362756b35d86SArmin Le Grand throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
362856b35d86SArmin Le Grand }
3629cdf0e10cSrcweir
3630cdf0e10cSrcweir if(GetBasePool())
3631cdf0e10cSrcweir {
3632cdf0e10cSrcweir switch(pEntry->nWID)
3633cdf0e10cSrcweir {
363456b35d86SArmin Le Grand case SID_ATTR_PAGE_ON:
363556b35d86SArmin Le Grand case RES_BACKGROUND:
363656b35d86SArmin Le Grand case RES_BOX:
363756b35d86SArmin Le Grand case RES_LR_SPACE:
363856b35d86SArmin Le Grand case RES_SHADOW:
363956b35d86SArmin Le Grand case RES_UL_SPACE:
364056b35d86SArmin Le Grand case SID_ATTR_PAGE_DYNAMIC:
364156b35d86SArmin Le Grand case SID_ATTR_PAGE_SHARED:
364256b35d86SArmin Le Grand case SID_ATTR_PAGE_SIZE:
364356b35d86SArmin Le Grand case RES_HEADER_FOOTER_EAT_SPACING:
364456b35d86SArmin Le Grand {
364556b35d86SArmin Le Grand // these entries are used in Header, Footer and (partially) in the PageStyle itself.
364656b35d86SArmin Le Grand // Check for Header/Footer entry
364756b35d86SArmin Le Grand const bool bHeader(rPropName.EqualsAscii("Header", 0, 6));
364856b35d86SArmin Le Grand const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6));
3649cdf0e10cSrcweir
365056b35d86SArmin Le Grand if(bHeader || bFooter)
3651cdf0e10cSrcweir {
365256b35d86SArmin Le Grand // it is a Header/Footer entry, access the SvxSetItem containing it's information
365356b35d86SArmin Le Grand const SvxSetItem* pSetItem = 0;
365456b35d86SArmin Le Grand
365556b35d86SArmin Le Grand if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem))
3656cdf0e10cSrcweir {
365756b35d86SArmin Le Grand // create a new SvxSetItem and get it's ItemSet as new target
365856b35d86SArmin Le Grand SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone());
3659cdf0e10cSrcweir SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
366056b35d86SArmin Le Grand
366156b35d86SArmin Le Grand // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem
366256b35d86SArmin Le Grand rSetSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet());
366356b35d86SArmin Le Grand
366456b35d86SArmin Le Grand // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the
366556b35d86SArmin Le Grand // default method to set the property
366656b35d86SArmin Le Grand SfxItemSet* pRememberItemSet = aBaseImpl.replaceItemSet(&rSetSet);
366756b35d86SArmin Le Grand lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
366856b35d86SArmin Le Grand aBaseImpl.replaceItemSet(pRememberItemSet);
366956b35d86SArmin Le Grand
367056b35d86SArmin Le Grand // reset paret at ItemSet from SetItem
367156b35d86SArmin Le Grand rSetSet.SetParent(0);
367256b35d86SArmin Le Grand
367356b35d86SArmin Le Grand // set the new SvxSetItem at the real target and delete it
3674cdf0e10cSrcweir aBaseImpl.GetItemSet().Put(*pNewSetItem);
3675cdf0e10cSrcweir delete pNewSetItem;
3676cdf0e10cSrcweir }
367756b35d86SArmin Le Grand else if(pEntry->nWID == SID_ATTR_PAGE_ON)
3678cdf0e10cSrcweir {
3679cdf0e10cSrcweir sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue();
368056b35d86SArmin Le Grand
3681cdf0e10cSrcweir if(bVal)
3682cdf0e10cSrcweir {
3683*6e2947abSJohn Bampton // Header/footer gets switched on, create defaults and the needed SfxSetItem
3684cdf0e10cSrcweir SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(),
368556b35d86SArmin Le Grand RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82
368656b35d86SArmin Le Grand
368756b35d86SArmin Le Grand //UUUU FillAttribute support
368856b35d86SArmin Le Grand XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014
368956b35d86SArmin Le Grand
369056b35d86SArmin Le Grand SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023
369156b35d86SArmin Le Grand SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051
369256b35d86SArmin Le Grand SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060
3693cdf0e10cSrcweir 0);
369456b35d86SArmin Le Grand
369556b35d86SArmin Le Grand //UUUU set correct parent to get the XFILL_NONE FillStyle as needed
369656b35d86SArmin Le Grand aTempSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet());
369756b35d86SArmin Le Grand
369856b35d86SArmin Le Grand aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_ON, sal_True));
3699cdf0e10cSrcweir aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50)));
3700cdf0e10cSrcweir aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE));
3701cdf0e10cSrcweir aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE));
3702cdf0e10cSrcweir aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, sal_True));
3703cdf0e10cSrcweir aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, sal_True));
3704cdf0e10cSrcweir
370556b35d86SArmin Le Grand SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet);
3706cdf0e10cSrcweir aBaseImpl.GetItemSet().Put(aNewSetItem);
3707cdf0e10cSrcweir }
3708cdf0e10cSrcweir }
3709cdf0e10cSrcweir }
371056b35d86SArmin Le Grand else
371156b35d86SArmin Le Grand {
371256b35d86SArmin Le Grand switch(pEntry->nWID)
371356b35d86SArmin Le Grand {
371456b35d86SArmin Le Grand case SID_ATTR_PAGE_DYNAMIC:
371556b35d86SArmin Le Grand case SID_ATTR_PAGE_SHARED:
371656b35d86SArmin Le Grand case SID_ATTR_PAGE_ON:
371756b35d86SArmin Le Grand case RES_HEADER_FOOTER_EAT_SPACING:
371856b35d86SArmin Le Grand {
371956b35d86SArmin Le Grand // these slots are exclusive to Header/Footer, thus this is an error
372056b35d86SArmin Le Grand throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
3721cdf0e10cSrcweir break;
372256b35d86SArmin Le Grand }
372356b35d86SArmin Le Grand default:
372456b35d86SArmin Le Grand {
372556b35d86SArmin Le Grand // part of PageStyle, fallback to default
372656b35d86SArmin Le Grand lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
372756b35d86SArmin Le Grand }
372856b35d86SArmin Le Grand }
372956b35d86SArmin Le Grand }
373056b35d86SArmin Le Grand
373156b35d86SArmin Le Grand break;
373256b35d86SArmin Le Grand }
373356b35d86SArmin Le Grand
373456b35d86SArmin Le Grand case XATTR_FILLBMP_SIZELOG:
373556b35d86SArmin Le Grand case XATTR_FILLBMP_TILEOFFSETX:
373656b35d86SArmin Le Grand case XATTR_FILLBMP_TILEOFFSETY:
373756b35d86SArmin Le Grand case XATTR_FILLBMP_POSOFFSETX:
373856b35d86SArmin Le Grand case XATTR_FILLBMP_POSOFFSETY:
373956b35d86SArmin Le Grand case XATTR_FILLBMP_POS:
374056b35d86SArmin Le Grand case XATTR_FILLBMP_SIZEX:
374156b35d86SArmin Le Grand case XATTR_FILLBMP_SIZEY:
374256b35d86SArmin Le Grand case XATTR_FILLBMP_STRETCH:
374356b35d86SArmin Le Grand case XATTR_FILLBMP_TILE:
374456b35d86SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
374556b35d86SArmin Le Grand case XATTR_FILLCOLOR:
374656b35d86SArmin Le Grand case XATTR_FILLBACKGROUND:
374756b35d86SArmin Le Grand case XATTR_FILLBITMAP:
374856b35d86SArmin Le Grand case XATTR_GRADIENTSTEPCOUNT:
374956b35d86SArmin Le Grand case XATTR_FILLGRADIENT:
375056b35d86SArmin Le Grand case XATTR_FILLHATCH:
375156b35d86SArmin Le Grand case XATTR_FILLSTYLE:
375256b35d86SArmin Le Grand case XATTR_FILLTRANSPARENCE:
375356b35d86SArmin Le Grand case XATTR_FILLFLOATTRANSPARENCE:
375456b35d86SArmin Le Grand case XATTR_SECONDARYFILLCOLOR:
375556b35d86SArmin Le Grand {
375656b35d86SArmin Le Grand // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle
375756b35d86SArmin Le Grand // itself, so decide what to do using the name
375856b35d86SArmin Le Grand const bool bHeader(rPropName.EqualsAscii("Header", 0, 6));
375956b35d86SArmin Le Grand const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6));
376056b35d86SArmin Le Grand
376156b35d86SArmin Le Grand if(bHeader || bFooter)
376256b35d86SArmin Le Grand {
376356b35d86SArmin Le Grand const SvxSetItem* pSetItem = 0;
376456b35d86SArmin Le Grand
376556b35d86SArmin Le Grand if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem))
376656b35d86SArmin Le Grand {
376756b35d86SArmin Le Grand // create a new SvxSetItem and get it's ItemSet as new target
376856b35d86SArmin Le Grand SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone());
376956b35d86SArmin Le Grand SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
377056b35d86SArmin Le Grand
377156b35d86SArmin Le Grand // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem
377256b35d86SArmin Le Grand rSetSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet());
377356b35d86SArmin Le Grand
377456b35d86SArmin Le Grand // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the
377556b35d86SArmin Le Grand // default method to set the property
377656b35d86SArmin Le Grand SfxItemSet* pRememberItemSet = aBaseImpl.replaceItemSet(&rSetSet);
377756b35d86SArmin Le Grand lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
377856b35d86SArmin Le Grand aBaseImpl.replaceItemSet(pRememberItemSet);
377956b35d86SArmin Le Grand
378056b35d86SArmin Le Grand // reset paret at ItemSet from SetItem
378156b35d86SArmin Le Grand rSetSet.SetParent(0);
378256b35d86SArmin Le Grand
378356b35d86SArmin Le Grand // set the new SvxSetItem at the real target and delete it
378456b35d86SArmin Le Grand aBaseImpl.GetItemSet().Put(*pNewSetItem);
378556b35d86SArmin Le Grand delete pNewSetItem;
378656b35d86SArmin Le Grand }
378756b35d86SArmin Le Grand }
378856b35d86SArmin Le Grand else
378956b35d86SArmin Le Grand {
379056b35d86SArmin Le Grand // part of PageStyle, fallback to default
379156b35d86SArmin Le Grand lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
379256b35d86SArmin Le Grand }
379356b35d86SArmin Le Grand
379456b35d86SArmin Le Grand break;
379556b35d86SArmin Le Grand }
379656b35d86SArmin Le Grand
3797cdf0e10cSrcweir case FN_PARAM_FTN_INFO :
3798cdf0e10cSrcweir {
3799cdf0e10cSrcweir const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO);
3800cdf0e10cSrcweir SfxPoolItem* pNewFtnItem = rItem.Clone();
3801cdf0e10cSrcweir sal_Bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId);
3802cdf0e10cSrcweir aBaseImpl.GetItemSet().Put(*pNewFtnItem);
3803cdf0e10cSrcweir delete pNewFtnItem;
3804cdf0e10cSrcweir if(!bPut)
3805cdf0e10cSrcweir throw lang::IllegalArgumentException();
380656b35d86SArmin Le Grand
3807cdf0e10cSrcweir break;
380856b35d86SArmin Le Grand }
380956b35d86SArmin Le Grand
3810cdf0e10cSrcweir case FN_UNO_HEADER :
3811cdf0e10cSrcweir case FN_UNO_HEADER_LEFT :
3812cdf0e10cSrcweir case FN_UNO_HEADER_RIGHT :
3813cdf0e10cSrcweir case FN_UNO_FOOTER :
3814cdf0e10cSrcweir case FN_UNO_FOOTER_LEFT :
3815cdf0e10cSrcweir case FN_UNO_FOOTER_RIGHT :
381656b35d86SArmin Le Grand {
3817cdf0e10cSrcweir throw lang::IllegalArgumentException();
381856b35d86SArmin Le Grand break;
381956b35d86SArmin Le Grand }
382056b35d86SArmin Le Grand
3821cdf0e10cSrcweir default:
382256b35d86SArmin Le Grand {
382356b35d86SArmin Le Grand //UUUU
382456b35d86SArmin Le Grand lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
382556b35d86SArmin Le Grand break;
382656b35d86SArmin Le Grand }
3827cdf0e10cSrcweir }
3828cdf0e10cSrcweir }
3829cdf0e10cSrcweir else if(IsDescriptor())
3830cdf0e10cSrcweir {
383156b35d86SArmin Le Grand if(!GetPropImpl()->SetProperty(rPropName, pValues[nProp]))
3832cdf0e10cSrcweir throw lang::IllegalArgumentException();
3833cdf0e10cSrcweir }
3834cdf0e10cSrcweir else
383556b35d86SArmin Le Grand {
3836cdf0e10cSrcweir throw uno::RuntimeException();
3837cdf0e10cSrcweir }
383856b35d86SArmin Le Grand }
383956b35d86SArmin Le Grand
3840cdf0e10cSrcweir if(aBaseImpl.HasItemSet())
3841cdf0e10cSrcweir {
3842cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
384356b35d86SArmin Le Grand
3844cdf0e10cSrcweir if (undoGuard.UndoWasEnabled())
3845cdf0e10cSrcweir {
3846cdf0e10cSrcweir // Fix i64460: as long as Undo of page styles with header/footer causes trouble...
3847cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
3848cdf0e10cSrcweir }
384956b35d86SArmin Le Grand
385056b35d86SArmin Le Grand aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
3851cdf0e10cSrcweir }
3852cdf0e10cSrcweir }
3853cdf0e10cSrcweir
setPropertyValues(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)3854cdf0e10cSrcweir void SwXPageStyle::setPropertyValues(
3855cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames,
3856cdf0e10cSrcweir const uno::Sequence< uno::Any >& rValues )
3857cdf0e10cSrcweir throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
3858cdf0e10cSrcweir {
3859cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
3860cdf0e10cSrcweir
3861cdf0e10cSrcweir // workaround for bad designed API
3862cdf0e10cSrcweir try
3863cdf0e10cSrcweir {
3864cdf0e10cSrcweir SetPropertyValues_Impl( rPropertyNames, rValues );
3865cdf0e10cSrcweir }
3866cdf0e10cSrcweir catch (beans::UnknownPropertyException &rException)
3867cdf0e10cSrcweir {
3868cdf0e10cSrcweir // wrap the original (here not allowed) exception in
3869cdf0e10cSrcweir // a lang::WrappedTargetException that gets thrown instead.
3870cdf0e10cSrcweir lang::WrappedTargetException aWExc;
3871cdf0e10cSrcweir aWExc.TargetException <<= rException;
3872cdf0e10cSrcweir throw aWExc;
3873cdf0e10cSrcweir }
3874cdf0e10cSrcweir }
3875cdf0e10cSrcweir /* -----------------------------04.11.03 13:50--------------------------------
3876cdf0e10cSrcweir
3877cdf0e10cSrcweir ---------------------------------------------------------------------------*/
lcl_makeHeaderFooter(const sal_uInt16 nRes,const bool bHeader,SwFrmFmt const * const pFrmFmt)387856b35d86SArmin Le Grand static uno::Reference<text::XText> lcl_makeHeaderFooter(
387956b35d86SArmin Le Grand const sal_uInt16 nRes,
388056b35d86SArmin Le Grand const bool bHeader,
388156b35d86SArmin Le Grand SwFrmFmt const*const pFrmFmt)
3882cdf0e10cSrcweir {
3883cdf0e10cSrcweir if (!pFrmFmt) { return 0; }
3884cdf0e10cSrcweir
3885cdf0e10cSrcweir const SfxItemSet& rSet = pFrmFmt->GetAttrSet();
3886cdf0e10cSrcweir const SfxPoolItem* pItem;
3887cdf0e10cSrcweir if (SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem))
3888cdf0e10cSrcweir {
3889cdf0e10cSrcweir SwFrmFmt *const pHeadFootFmt = (bHeader)
3890cdf0e10cSrcweir ? static_cast<SwFmtHeader*>(const_cast<SfxPoolItem*>(pItem))->
3891cdf0e10cSrcweir GetHeaderFmt()
3892cdf0e10cSrcweir : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))->
3893cdf0e10cSrcweir GetFooterFmt();
3894cdf0e10cSrcweir if (pHeadFootFmt)
3895cdf0e10cSrcweir {
3896cdf0e10cSrcweir return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader);
3897cdf0e10cSrcweir }
3898cdf0e10cSrcweir }
3899cdf0e10cSrcweir return 0;
3900cdf0e10cSrcweir }
3901cdf0e10cSrcweir
GetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames)3902cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
3903cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames )
3904cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3905cdf0e10cSrcweir {
3906cdf0e10cSrcweir if(!GetDoc())
3907cdf0e10cSrcweir throw uno::RuntimeException();
3908cdf0e10cSrcweir
3909cdf0e10cSrcweir sal_Int32 nLength = rPropertyNames.getLength();
3910cdf0e10cSrcweir const OUString* pNames = rPropertyNames.getConstArray();
3911cdf0e10cSrcweir uno::Sequence< uno::Any > aRet ( nLength );
3912cdf0e10cSrcweir uno::Any* pRet = aRet.getArray();
3913cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3914cdf0e10cSrcweir const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
391556b35d86SArmin Le Grand SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrmFmt()->GetAttrSet()); //UUUU add pDfltFrmFmt as parent
3916cdf0e10cSrcweir SfxStyleSheetBase* pBase = 0;
391756b35d86SArmin Le Grand
3918cdf0e10cSrcweir for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
3919cdf0e10cSrcweir {
392056b35d86SArmin Le Grand const String& rPropName = pNames[nProp];
392156b35d86SArmin Le Grand const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName );
392256b35d86SArmin Le Grand
3923cdf0e10cSrcweir if (!pEntry)
392456b35d86SArmin Le Grand {
392556b35d86SArmin Le Grand throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
392656b35d86SArmin Le Grand }
3927cdf0e10cSrcweir
3928cdf0e10cSrcweir if(GetBasePool())
3929cdf0e10cSrcweir {
3930cdf0e10cSrcweir if(!pBase)
3931cdf0e10cSrcweir {
3932cdf0e10cSrcweir sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3933cdf0e10cSrcweir GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL );
3934cdf0e10cSrcweir pBase = GetBasePool()->Find(GetStyleName());
3935cdf0e10cSrcweir GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3936cdf0e10cSrcweir }
393756b35d86SArmin Le Grand
3938cdf0e10cSrcweir sal_uInt16 nRes = 0;
3939cdf0e10cSrcweir sal_Bool bAll = sal_False, bLeft = sal_False, bRight = sal_False;
394056b35d86SArmin Le Grand const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
394156b35d86SArmin Le Grand
3942cdf0e10cSrcweir switch(pEntry->nWID)
3943cdf0e10cSrcweir {
394456b35d86SArmin Le Grand case SID_ATTR_PAGE_ON:
394556b35d86SArmin Le Grand case RES_BACKGROUND:
394656b35d86SArmin Le Grand case RES_BOX:
394756b35d86SArmin Le Grand case RES_LR_SPACE:
394856b35d86SArmin Le Grand case RES_SHADOW:
394956b35d86SArmin Le Grand case RES_UL_SPACE:
395056b35d86SArmin Le Grand case SID_ATTR_PAGE_DYNAMIC:
395156b35d86SArmin Le Grand case SID_ATTR_PAGE_SHARED:
395256b35d86SArmin Le Grand case SID_ATTR_PAGE_SIZE:
395356b35d86SArmin Le Grand case RES_HEADER_FOOTER_EAT_SPACING:
3954cdf0e10cSrcweir {
395556b35d86SArmin Le Grand // These slots are used for Header, Footer and (partially) for PageStyle directly.
395656b35d86SArmin Le Grand // Check for Header/Footer entry
395756b35d86SArmin Le Grand const bool bHeader(rPropName.EqualsAscii("Header", 0, 6));
395856b35d86SArmin Le Grand const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6));
395956b35d86SArmin Le Grand
396056b35d86SArmin Le Grand if(bHeader || bFooter)
396156b35d86SArmin Le Grand {
396256b35d86SArmin Le Grand // slot is a Header/Footer slot
396356b35d86SArmin Le Grand rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
396456b35d86SArmin Le Grand const SfxItemSet& rSet = xStyle->GetItemSet();
396556b35d86SArmin Le Grand const SvxSetItem* pSetItem;
396656b35d86SArmin Le Grand
396756b35d86SArmin Le Grand if(SFX_ITEM_SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem))
396856b35d86SArmin Le Grand {
396956b35d86SArmin Le Grand // get from SfxItemSet of the corresponding SfxSetItem
397056b35d86SArmin Le Grand const SfxItemSet& rSetSet = pSetItem->GetItemSet();
397156b35d86SArmin Le Grand SfxItemSet* pRememberItemSet = aBase.replaceItemSet(&const_cast< SfxItemSet& >(rSetSet));
397256b35d86SArmin Le Grand pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
397356b35d86SArmin Le Grand aBase.replaceItemSet(pRememberItemSet);
397456b35d86SArmin Le Grand }
397556b35d86SArmin Le Grand else if(pEntry->nWID == SID_ATTR_PAGE_ON)
397656b35d86SArmin Le Grand {
397756b35d86SArmin Le Grand // header/footer is not available, thus off. Default is sal_False, though
397856b35d86SArmin Le Grand sal_Bool bRet = sal_False;
397956b35d86SArmin Le Grand pRet[nProp].setValue(&bRet, ::getCppuBooleanType());
398056b35d86SArmin Le Grand }
398156b35d86SArmin Le Grand }
398256b35d86SArmin Le Grand else
398356b35d86SArmin Le Grand {
398456b35d86SArmin Le Grand switch(pEntry->nWID)
398556b35d86SArmin Le Grand {
398656b35d86SArmin Le Grand case SID_ATTR_PAGE_DYNAMIC:
398756b35d86SArmin Le Grand case SID_ATTR_PAGE_SHARED:
398856b35d86SArmin Le Grand case SID_ATTR_PAGE_ON:
398956b35d86SArmin Le Grand case RES_HEADER_FOOTER_EAT_SPACING:
399056b35d86SArmin Le Grand {
399156b35d86SArmin Le Grand // these slots are exclusive to Header/Footer, thus this is an error
399256b35d86SArmin Le Grand throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
399356b35d86SArmin Le Grand break;
399456b35d86SArmin Le Grand }
399556b35d86SArmin Le Grand default:
399656b35d86SArmin Le Grand {
399756b35d86SArmin Le Grand // part of PageStyle, fallback to default
399856b35d86SArmin Le Grand pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
399956b35d86SArmin Le Grand }
400056b35d86SArmin Le Grand }
400156b35d86SArmin Le Grand }
400256b35d86SArmin Le Grand
400356b35d86SArmin Le Grand break;
400456b35d86SArmin Le Grand }
400556b35d86SArmin Le Grand
400656b35d86SArmin Le Grand case XATTR_FILLBMP_SIZELOG:
400756b35d86SArmin Le Grand case XATTR_FILLBMP_TILEOFFSETX:
400856b35d86SArmin Le Grand case XATTR_FILLBMP_TILEOFFSETY:
400956b35d86SArmin Le Grand case XATTR_FILLBMP_POSOFFSETX:
401056b35d86SArmin Le Grand case XATTR_FILLBMP_POSOFFSETY:
401156b35d86SArmin Le Grand case XATTR_FILLBMP_POS:
401256b35d86SArmin Le Grand case XATTR_FILLBMP_SIZEX:
401356b35d86SArmin Le Grand case XATTR_FILLBMP_SIZEY:
401456b35d86SArmin Le Grand case XATTR_FILLBMP_STRETCH:
401556b35d86SArmin Le Grand case XATTR_FILLBMP_TILE:
401656b35d86SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
401756b35d86SArmin Le Grand case XATTR_FILLCOLOR:
401856b35d86SArmin Le Grand case XATTR_FILLBACKGROUND:
401956b35d86SArmin Le Grand case XATTR_FILLBITMAP:
402056b35d86SArmin Le Grand case XATTR_GRADIENTSTEPCOUNT:
402156b35d86SArmin Le Grand case XATTR_FILLGRADIENT:
402256b35d86SArmin Le Grand case XATTR_FILLHATCH:
402356b35d86SArmin Le Grand case XATTR_FILLSTYLE:
402456b35d86SArmin Le Grand case XATTR_FILLTRANSPARENCE:
402556b35d86SArmin Le Grand case XATTR_FILLFLOATTRANSPARENCE:
402656b35d86SArmin Le Grand case XATTR_SECONDARYFILLCOLOR:
402756b35d86SArmin Le Grand {
402856b35d86SArmin Le Grand // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle
402956b35d86SArmin Le Grand // itself, so decide what to do using the name
403056b35d86SArmin Le Grand const bool bHeader(rPropName.EqualsAscii("Header", 0, 6));
403156b35d86SArmin Le Grand const bool bFooter(rPropName.EqualsAscii("Footer", 0, 6));
403256b35d86SArmin Le Grand
403356b35d86SArmin Le Grand if(bHeader || bFooter)
4034cdf0e10cSrcweir {
4035cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
4036cdf0e10cSrcweir const SfxItemSet& rSet = xStyle->GetItemSet();
403756b35d86SArmin Le Grand const SvxSetItem* pSetItem;
403856b35d86SArmin Le Grand
403956b35d86SArmin Le Grand if(SFX_ITEM_SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem))
404056b35d86SArmin Le Grand {
404156b35d86SArmin Le Grand // set at SfxItemSet of the corresponding SfxSetItem
404256b35d86SArmin Le Grand const SfxItemSet& rSetSet = pSetItem->GetItemSet();
404356b35d86SArmin Le Grand SfxItemSet* pRememberItemSet = aBase.replaceItemSet(&const_cast< SfxItemSet& >(rSetSet));
404456b35d86SArmin Le Grand pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
404556b35d86SArmin Le Grand aBase.replaceItemSet(pRememberItemSet);
404656b35d86SArmin Le Grand }
404756b35d86SArmin Le Grand }
404856b35d86SArmin Le Grand else
404956b35d86SArmin Le Grand {
405056b35d86SArmin Le Grand // part of PageStyle, fallback to default
405156b35d86SArmin Le Grand pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
405256b35d86SArmin Le Grand }
405356b35d86SArmin Le Grand
405456b35d86SArmin Le Grand break;
405556b35d86SArmin Le Grand }
405656b35d86SArmin Le Grand
405756b35d86SArmin Le Grand case FN_UNO_HEADER:
405856b35d86SArmin Le Grand case FN_UNO_HEADER_LEFT:
405956b35d86SArmin Le Grand case FN_UNO_HEADER_RIGHT:
406056b35d86SArmin Le Grand case FN_UNO_FOOTER:
406156b35d86SArmin Le Grand case FN_UNO_FOOTER_LEFT:
406256b35d86SArmin Le Grand case FN_UNO_FOOTER_RIGHT:
406356b35d86SArmin Le Grand {
406456b35d86SArmin Le Grand //UUUU cleanups for readability (undos removed, rearranged)
406556b35d86SArmin Le Grand bool bHeader(false);
406656b35d86SArmin Le Grand
4067cdf0e10cSrcweir switch(pEntry->nWID)
4068cdf0e10cSrcweir {
406956b35d86SArmin Le Grand case FN_UNO_HEADER: bHeader = true; nRes = RES_HEADER; bAll = sal_True; break;
407056b35d86SArmin Le Grand case FN_UNO_HEADER_LEFT: bHeader = true; nRes = RES_HEADER; bLeft = sal_True; break;
407156b35d86SArmin Le Grand case FN_UNO_HEADER_RIGHT: bHeader = true; nRes = RES_HEADER; bRight = sal_True; break;
407256b35d86SArmin Le Grand case FN_UNO_FOOTER: bHeader = false; nRes = RES_FOOTER; bAll = sal_True; break;
407356b35d86SArmin Le Grand case FN_UNO_FOOTER_LEFT: bHeader = false; nRes = RES_FOOTER; bLeft = sal_True; break;
407456b35d86SArmin Le Grand case FN_UNO_FOOTER_RIGHT: bHeader = false; nRes = RES_FOOTER; bRight = sal_True; break;
407556b35d86SArmin Le Grand default: break;
4076cdf0e10cSrcweir }
407756b35d86SArmin Le Grand
4078cdf0e10cSrcweir const SwPageDesc& rDesc = aBase.GetOldPageDesc();
4079cdf0e10cSrcweir const SwFrmFmt* pFrmFmt = 0;
408056b35d86SArmin Le Grand sal_Bool bShare = (bHeader && rDesc.IsHeaderShared()) || (!bHeader && rDesc.IsFooterShared());
4081cdf0e10cSrcweir // TextLeft returns the left content if there is one,
4082cdf0e10cSrcweir // Text and TextRight return the master content.
4083cdf0e10cSrcweir // TextRight does the same as Text and is for
4084cdf0e10cSrcweir // comptability only.
4085cdf0e10cSrcweir if( bLeft && !bShare )
4086cdf0e10cSrcweir {
4087cdf0e10cSrcweir pFrmFmt = &rDesc.GetLeft();
4088cdf0e10cSrcweir }
4089cdf0e10cSrcweir else
4090cdf0e10cSrcweir {
4091cdf0e10cSrcweir pFrmFmt = &rDesc.GetMaster();
4092cdf0e10cSrcweir }
4093cdf0e10cSrcweir const uno::Reference< text::XText > xRet =
4094cdf0e10cSrcweir lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt);
4095cdf0e10cSrcweir if (xRet.is())
4096cdf0e10cSrcweir {
4097cdf0e10cSrcweir pRet[nProp] <<= xRet;
4098cdf0e10cSrcweir }
409956b35d86SArmin Le Grand
4100cdf0e10cSrcweir break;
410156b35d86SArmin Le Grand }
410256b35d86SArmin Le Grand
4103cdf0e10cSrcweir case FN_PARAM_FTN_INFO :
4104cdf0e10cSrcweir {
4105cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
4106cdf0e10cSrcweir const SfxItemSet& rSet = xStyle->GetItemSet();
4107cdf0e10cSrcweir const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO);
410856b35d86SArmin Le Grand rItem.QueryValue(pRet[nProp], nMemberId);
4109cdf0e10cSrcweir break;
411056b35d86SArmin Le Grand }
411156b35d86SArmin Le Grand
4112cdf0e10cSrcweir default:
411356b35d86SArmin Le Grand {
411456b35d86SArmin Le Grand //UUUU
4115cdf0e10cSrcweir pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
411656b35d86SArmin Le Grand break;
411756b35d86SArmin Le Grand }
4118cdf0e10cSrcweir }
4119cdf0e10cSrcweir }
4120cdf0e10cSrcweir else if(IsDescriptor())
4121cdf0e10cSrcweir {
4122cdf0e10cSrcweir uno::Any* pAny = 0;
412356b35d86SArmin Le Grand GetPropImpl()->GetProperty(rPropName, pAny);
412456b35d86SArmin Le Grand
4125cdf0e10cSrcweir if ( !pAny )
412656b35d86SArmin Le Grand {
412756b35d86SArmin Le Grand GetPropImpl()->GetProperty ( rPropName, mxStyleData, pRet[ nProp ] );
412856b35d86SArmin Le Grand }
4129cdf0e10cSrcweir else
413056b35d86SArmin Le Grand {
4131cdf0e10cSrcweir pRet[nProp] = *pAny;
4132cdf0e10cSrcweir }
413356b35d86SArmin Le Grand }
4134cdf0e10cSrcweir else
413556b35d86SArmin Le Grand {
4136cdf0e10cSrcweir throw uno::RuntimeException();
4137cdf0e10cSrcweir }
413856b35d86SArmin Le Grand }
413956b35d86SArmin Le Grand
4140cdf0e10cSrcweir return aRet;
4141cdf0e10cSrcweir }
4142cdf0e10cSrcweir /* -----------------------------18.04.01 13:50--------------------------------
4143cdf0e10cSrcweir
4144cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getPropertyValues(const uno::Sequence<OUString> & rPropertyNames)4145cdf0e10cSrcweir uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues(
4146cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames )
4147cdf0e10cSrcweir throw(uno::RuntimeException)
4148cdf0e10cSrcweir {
4149cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
4150cdf0e10cSrcweir uno::Sequence< uno::Any > aValues;
4151cdf0e10cSrcweir
4152cdf0e10cSrcweir // workaround for bad designed API
4153cdf0e10cSrcweir try
4154cdf0e10cSrcweir {
4155cdf0e10cSrcweir aValues = GetPropertyValues_Impl( rPropertyNames );
4156cdf0e10cSrcweir }
4157cdf0e10cSrcweir catch (beans::UnknownPropertyException &)
4158cdf0e10cSrcweir {
4159cdf0e10cSrcweir throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
4160cdf0e10cSrcweir }
4161cdf0e10cSrcweir catch (lang::WrappedTargetException &)
4162cdf0e10cSrcweir {
4163cdf0e10cSrcweir throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
4164cdf0e10cSrcweir }
4165cdf0e10cSrcweir
4166cdf0e10cSrcweir return aValues;
4167cdf0e10cSrcweir }
4168cdf0e10cSrcweir /*-- 17.12.98 08:43:36---------------------------------------------------
4169cdf0e10cSrcweir
4170cdf0e10cSrcweir -----------------------------------------------------------------------*/
getPropertyValue(const OUString & rPropertyName)417156b35d86SArmin Le Grand uno::Any SwXPageStyle::getPropertyValue(
417256b35d86SArmin Le Grand const OUString& rPropertyName)
417356b35d86SArmin Le Grand throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
4174cdf0e10cSrcweir {
4175cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
4176cdf0e10cSrcweir const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
417756b35d86SArmin Le Grand
4178cdf0e10cSrcweir return GetPropertyValues_Impl(aProperties).getConstArray()[0];
4179cdf0e10cSrcweir }
4180cdf0e10cSrcweir /*-- 17.12.98 08:43:36---------------------------------------------------
4181cdf0e10cSrcweir
4182cdf0e10cSrcweir -----------------------------------------------------------------------*/
setPropertyValue(const OUString & rPropertyName,const uno::Any & rValue)418356b35d86SArmin Le Grand void SwXPageStyle::setPropertyValue(
418456b35d86SArmin Le Grand const OUString& rPropertyName,
418556b35d86SArmin Le Grand const uno::Any& rValue)
418656b35d86SArmin Le Grand throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
4187cdf0e10cSrcweir {
4188cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
4189cdf0e10cSrcweir const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
4190cdf0e10cSrcweir const uno::Sequence<uno::Any> aValues(&rValue, 1);
419156b35d86SArmin Le Grand
4192cdf0e10cSrcweir SetPropertyValues_Impl( aProperties, aValues );
4193cdf0e10cSrcweir }
4194cdf0e10cSrcweir
SwXFrameStyle(SwDoc * pDoc)4195cdf0e10cSrcweir SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc )
4196cdf0e10cSrcweir : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, sal_False)
4197cdf0e10cSrcweir {
4198cdf0e10cSrcweir }
4199cdf0e10cSrcweir /* -----------------------------15.12.00 15:45--------------------------------
4200cdf0e10cSrcweir
4201cdf0e10cSrcweir ---------------------------------------------------------------------------*/
~SwXFrameStyle()4202cdf0e10cSrcweir SwXFrameStyle::~SwXFrameStyle()
4203cdf0e10cSrcweir {
4204cdf0e10cSrcweir }
4205cdf0e10cSrcweir /* -----------------------------15.12.00 14:30--------------------------------
4206cdf0e10cSrcweir
4207cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getTypes()4208cdf0e10cSrcweir uno::Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(uno::RuntimeException)
4209cdf0e10cSrcweir {
4210cdf0e10cSrcweir uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes();
4211cdf0e10cSrcweir sal_Int32 nLen = aTypes.getLength();
4212cdf0e10cSrcweir aTypes.realloc(nLen + 1);
4213cdf0e10cSrcweir aTypes.getArray()[nLen] = ::getCppuType((uno::Reference<XEventsSupplier>*)0);
4214cdf0e10cSrcweir return aTypes;
4215cdf0e10cSrcweir }
4216cdf0e10cSrcweir /* -----------------------------15.12.00 14:30--------------------------------
4217cdf0e10cSrcweir
4218cdf0e10cSrcweir ---------------------------------------------------------------------------*/
queryInterface(const uno::Type & rType)4219cdf0e10cSrcweir uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
4220cdf0e10cSrcweir {
4221cdf0e10cSrcweir uno::Any aRet;
4222cdf0e10cSrcweir if(rType == ::getCppuType((uno::Reference<XEventsSupplier>*)0))
4223cdf0e10cSrcweir aRet <<= uno::Reference<XEventsSupplier>(this);
4224cdf0e10cSrcweir else
4225cdf0e10cSrcweir aRet = SwXStyle::queryInterface(rType);
4226cdf0e10cSrcweir return aRet;
4227cdf0e10cSrcweir }
4228cdf0e10cSrcweir /* -----------------------------15.12.00 14:30--------------------------------
4229cdf0e10cSrcweir
4230cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getEvents()4231cdf0e10cSrcweir uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno::RuntimeException)
4232cdf0e10cSrcweir {
4233cdf0e10cSrcweir return new SwFrameStyleEventDescriptor( *this );
4234cdf0e10cSrcweir }
4235cdf0e10cSrcweir /*-- 19.05.2006 11:23:55---------------------------------------------------
4236cdf0e10cSrcweir
4237cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXAutoStyles(SwDocShell & rDocShell)4238cdf0e10cSrcweir SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) :
4239cdf0e10cSrcweir SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell )
4240cdf0e10cSrcweir {
4241cdf0e10cSrcweir }
4242cdf0e10cSrcweir /*-- 19.05.2006 11:23:56---------------------------------------------------
4243cdf0e10cSrcweir
4244cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXAutoStyles()4245cdf0e10cSrcweir SwXAutoStyles::~SwXAutoStyles()
4246cdf0e10cSrcweir {
4247cdf0e10cSrcweir }
4248cdf0e10cSrcweir /*-- 19.05.2006 11:23:57---------------------------------------------------
4249cdf0e10cSrcweir
4250cdf0e10cSrcweir -----------------------------------------------------------------------*/
getCount(void)4251cdf0e10cSrcweir sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException )
4252cdf0e10cSrcweir {
4253cdf0e10cSrcweir return AUTOSTYLE_FAMILY_COUNT;
4254cdf0e10cSrcweir }
4255cdf0e10cSrcweir /*-- 19.05.2006 11:23:57---------------------------------------------------
4256cdf0e10cSrcweir
4257cdf0e10cSrcweir -----------------------------------------------------------------------*/
getByIndex(sal_Int32 nIndex)4258cdf0e10cSrcweir uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex)
4259cdf0e10cSrcweir throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
4260cdf0e10cSrcweir uno::RuntimeException )
4261cdf0e10cSrcweir {
4262cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
4263cdf0e10cSrcweir uno::Any aRet;
4264cdf0e10cSrcweir if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT)
4265cdf0e10cSrcweir throw lang::IndexOutOfBoundsException();
4266cdf0e10cSrcweir if(IsValid())
4267cdf0e10cSrcweir {
4268cdf0e10cSrcweir uno::Reference< style::XAutoStyleFamily > aRef;
4269cdf0e10cSrcweir IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex];
4270cdf0e10cSrcweir switch( nType )
4271cdf0e10cSrcweir {
4272cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_CHAR:
4273cdf0e10cSrcweir {
4274cdf0e10cSrcweir if(!xAutoCharStyles.is())
4275cdf0e10cSrcweir xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType);
4276cdf0e10cSrcweir aRef = xAutoCharStyles;
4277cdf0e10cSrcweir }
4278cdf0e10cSrcweir break;
4279cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_RUBY:
4280cdf0e10cSrcweir {
4281cdf0e10cSrcweir if(!xAutoRubyStyles.is())
4282cdf0e10cSrcweir xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType );
4283cdf0e10cSrcweir aRef = xAutoRubyStyles;
4284cdf0e10cSrcweir }
4285cdf0e10cSrcweir break;
4286cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_PARA:
4287cdf0e10cSrcweir {
4288cdf0e10cSrcweir if(!xAutoParaStyles.is())
4289cdf0e10cSrcweir xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType );
4290cdf0e10cSrcweir aRef = xAutoParaStyles;
4291cdf0e10cSrcweir }
4292cdf0e10cSrcweir break;
4293cdf0e10cSrcweir
4294cdf0e10cSrcweir default:
4295cdf0e10cSrcweir ;
4296cdf0e10cSrcweir }
4297cdf0e10cSrcweir aRet.setValue(&aRef, ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0));
4298cdf0e10cSrcweir }
4299cdf0e10cSrcweir else
4300cdf0e10cSrcweir throw uno::RuntimeException();
4301cdf0e10cSrcweir return aRet;
4302cdf0e10cSrcweir }
4303cdf0e10cSrcweir /*-- 19.05.2006 11:23:57---------------------------------------------------
4304cdf0e10cSrcweir
4305cdf0e10cSrcweir -----------------------------------------------------------------------*/
getElementType()4306cdf0e10cSrcweir uno::Type SwXAutoStyles::getElementType( ) throw(uno::RuntimeException)
4307cdf0e10cSrcweir {
4308cdf0e10cSrcweir return ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0);
4309cdf0e10cSrcweir }
4310cdf0e10cSrcweir /*-- 19.05.2006 11:23:58---------------------------------------------------
4311cdf0e10cSrcweir
4312cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasElements()4313cdf0e10cSrcweir sal_Bool SwXAutoStyles::hasElements( ) throw(uno::RuntimeException)
4314cdf0e10cSrcweir {
4315cdf0e10cSrcweir return sal_True;
4316cdf0e10cSrcweir }
4317cdf0e10cSrcweir /*-- 19.05.2006 11:23:58---------------------------------------------------
4318cdf0e10cSrcweir
4319cdf0e10cSrcweir -----------------------------------------------------------------------*/
getByName(const rtl::OUString & Name)4320cdf0e10cSrcweir uno::Any SwXAutoStyles::getByName(const rtl::OUString& Name)
4321cdf0e10cSrcweir throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
4322cdf0e10cSrcweir {
4323cdf0e10cSrcweir uno::Any aRet;
4324cdf0e10cSrcweir if(Name.compareToAscii("CharacterStyles") == 0 )
4325cdf0e10cSrcweir aRet = getByIndex(0);
4326cdf0e10cSrcweir else if(Name.compareToAscii("RubyStyles") == 0 )
4327cdf0e10cSrcweir aRet = getByIndex(1);
4328cdf0e10cSrcweir else if(Name.compareToAscii("ParagraphStyles") == 0 )
4329cdf0e10cSrcweir aRet = getByIndex(2);
4330cdf0e10cSrcweir else
4331cdf0e10cSrcweir throw container::NoSuchElementException();
4332cdf0e10cSrcweir return aRet;
4333cdf0e10cSrcweir }
4334cdf0e10cSrcweir /*-- 19.05.2006 11:23:59---------------------------------------------------
4335cdf0e10cSrcweir
4336cdf0e10cSrcweir -----------------------------------------------------------------------*/
getElementNames(void)4337cdf0e10cSrcweir uno::Sequence< rtl::OUString > SwXAutoStyles::getElementNames(void)
4338cdf0e10cSrcweir throw( uno::RuntimeException )
4339cdf0e10cSrcweir {
4340cdf0e10cSrcweir uno::Sequence< OUString > aNames(AUTOSTYLE_FAMILY_COUNT);
4341cdf0e10cSrcweir OUString* pNames = aNames.getArray();
4342cdf0e10cSrcweir pNames[0] = C2U("CharacterStyles");
4343cdf0e10cSrcweir pNames[1] = C2U("RubyStyles");
4344cdf0e10cSrcweir pNames[2] = C2U("ParagraphStyles");
4345cdf0e10cSrcweir return aNames;
4346cdf0e10cSrcweir }
4347cdf0e10cSrcweir /*-- 19.05.2006 11:24:00---------------------------------------------------
4348cdf0e10cSrcweir
4349cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasByName(const rtl::OUString & Name)4350cdf0e10cSrcweir sal_Bool SwXAutoStyles::hasByName(const rtl::OUString& Name)
4351cdf0e10cSrcweir throw( uno::RuntimeException )
4352cdf0e10cSrcweir {
4353cdf0e10cSrcweir if( Name.compareToAscii("CharacterStyles") == 0 ||
4354cdf0e10cSrcweir Name.compareToAscii("RubyStyles") == 0 ||
4355cdf0e10cSrcweir Name.compareToAscii("ParagraphStyles") == 0 )
4356cdf0e10cSrcweir return sal_True;
4357cdf0e10cSrcweir else
4358cdf0e10cSrcweir return sal_False;
4359cdf0e10cSrcweir }
4360cdf0e10cSrcweir
4361cdf0e10cSrcweir /*-- 19.05.2006 11:24:02---------------------------------------------------
4362cdf0e10cSrcweir
4363cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXAutoStyleFamily(SwDocShell * pDocSh,IStyleAccess::SwAutoStyleFamily nFamily)4364cdf0e10cSrcweir SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) :
4365cdf0e10cSrcweir pDocShell( pDocSh ), eFamily(nFamily)
4366cdf0e10cSrcweir {
4367cdf0e10cSrcweir // Register ourselves as a listener to the document (via the page descriptor)
4368cdf0e10cSrcweir pDocSh->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4369cdf0e10cSrcweir }
4370cdf0e10cSrcweir /*-- 19.05.2006 11:24:02---------------------------------------------------
4371cdf0e10cSrcweir
4372cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXAutoStyleFamily()4373cdf0e10cSrcweir SwXAutoStyleFamily::~SwXAutoStyleFamily()
4374cdf0e10cSrcweir {
4375cdf0e10cSrcweir }
4376cdf0e10cSrcweir
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)4377cdf0e10cSrcweir void SwXAutoStyleFamily::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
4378cdf0e10cSrcweir {
4379cdf0e10cSrcweir ClientModify(this, pOld, pNew);
4380cdf0e10cSrcweir if(!GetRegisteredIn())
4381cdf0e10cSrcweir pDocShell = 0;
4382cdf0e10cSrcweir }
4383cdf0e10cSrcweir
4384cdf0e10cSrcweir /*-- 31.05.2006 11:24:02---------------------------------------------------
4385cdf0e10cSrcweir
4386cdf0e10cSrcweir -----------------------------------------------------------------------*/
insertStyle(const uno::Sequence<beans::PropertyValue> & Values)4387cdf0e10cSrcweir uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle(
4388cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& Values )
4389cdf0e10cSrcweir throw (uno::RuntimeException)
4390cdf0e10cSrcweir {
4391cdf0e10cSrcweir if( !pDocShell )
439256b35d86SArmin Le Grand {
4393cdf0e10cSrcweir throw uno::RuntimeException();
439456b35d86SArmin Le Grand }
439556b35d86SArmin Le Grand
4396cdf0e10cSrcweir const sal_uInt16* pRange = 0;
4397cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = 0;
439856b35d86SArmin Le Grand
4399cdf0e10cSrcweir switch( eFamily )
4400cdf0e10cSrcweir {
4401cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_CHAR:
4402cdf0e10cSrcweir {
4403cdf0e10cSrcweir pRange = aCharAutoFmtSetRange;
4404cdf0e10cSrcweir pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE);
4405cdf0e10cSrcweir break;
440656b35d86SArmin Le Grand }
4407cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_RUBY:
4408cdf0e10cSrcweir {
4409cdf0e10cSrcweir pRange = 0;//aTxtNodeSetRange;
4410cdf0e10cSrcweir pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE);
4411cdf0e10cSrcweir break;
441256b35d86SArmin Le Grand }
4413cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_PARA:
4414cdf0e10cSrcweir {
441556b35d86SArmin Le Grand pRange = aTxtNodeSetRange; //UUUU checked, already added support for [XATTR_FILL_FIRST, XATTR_FILL_LAST]
4416cdf0e10cSrcweir pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE);
4417cdf0e10cSrcweir break;
4418cdf0e10cSrcweir }
441956b35d86SArmin Le Grand
442056b35d86SArmin Le Grand default: break;
442156b35d86SArmin Le Grand }
442256b35d86SArmin Le Grand
4423cdf0e10cSrcweir SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange );
4424cdf0e10cSrcweir const beans::PropertyValue* pSeq = Values.getConstArray();
4425cdf0e10cSrcweir sal_Int32 nLen = Values.getLength();
442656b35d86SArmin Le Grand const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == eFamily);
442756b35d86SArmin Le Grand
442856b35d86SArmin Le Grand if(!bTakeCareOfDrawingLayerFillStyle)
442956b35d86SArmin Le Grand {
4430cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLen; ++i )
4431cdf0e10cSrcweir {
4432cdf0e10cSrcweir try
4433cdf0e10cSrcweir {
4434cdf0e10cSrcweir pPropSet->setPropertyValue( pSeq[i].Name, pSeq[i].Value, aSet );
4435cdf0e10cSrcweir }
4436cdf0e10cSrcweir catch (beans::UnknownPropertyException &)
4437cdf0e10cSrcweir {
4438cdf0e10cSrcweir ASSERT( false, "Unknown property" );
4439cdf0e10cSrcweir }
4440cdf0e10cSrcweir catch (lang::IllegalArgumentException &)
4441cdf0e10cSrcweir {
4442cdf0e10cSrcweir ASSERT( false, "Illegal argument" );
4443cdf0e10cSrcweir }
4444cdf0e10cSrcweir }
444556b35d86SArmin Le Grand }
444656b35d86SArmin Le Grand else
444756b35d86SArmin Le Grand {
444856b35d86SArmin Le Grand //UUUU set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem
444956b35d86SArmin Le Grand // to make cases in RES_BACKGROUND work correct; target *is* a style
445056b35d86SArmin Le Grand // where this is the case
445156b35d86SArmin Le Grand aSet.SetParent(&pDocShell->GetDoc()->GetDfltTxtFmtColl()->GetAttrSet());
4452cdf0e10cSrcweir
445356b35d86SArmin Le Grand //UUUU here the used DrawingLayer FillStyles are imported when family is
445456b35d86SArmin Le Grand // equal to IStyleAccess::AUTO_STYLE_PARA, thus we will need to serve the
445556b35d86SArmin Le Grand // used slots functionality here to do this correctly
445656b35d86SArmin Le Grand const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
445756b35d86SArmin Le Grand
445856b35d86SArmin Le Grand for( sal_Int32 i = 0; i < nLen; ++i )
445956b35d86SArmin Le Grand {
446056b35d86SArmin Le Grand const OUString& rPropName = pSeq[i].Name;
446156b35d86SArmin Le Grand uno::Any aValue(pSeq[i].Value);
446256b35d86SArmin Le Grand const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName);
446356b35d86SArmin Le Grand
446456b35d86SArmin Le Grand if(!pEntry)
446556b35d86SArmin Le Grand {
446656b35d86SArmin Le Grand throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
446756b35d86SArmin Le Grand }
446856b35d86SArmin Le Grand
446956b35d86SArmin Le Grand const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
447056b35d86SArmin Le Grand bool bDone(false);
447156b35d86SArmin Le Grand
447256b35d86SArmin Le Grand // check for needed metric translation
447356b35d86SArmin Le Grand if(pEntry->nMemberId & SFX_METRIC_ITEM)
447456b35d86SArmin Le Grand {
447556b35d86SArmin Le Grand bool bDoIt(true);
447656b35d86SArmin Le Grand
447756b35d86SArmin Le Grand if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID)
447856b35d86SArmin Le Grand {
447956b35d86SArmin Le Grand // exception: If these ItemTypes are used, do not convert when these are negative
448056b35d86SArmin Le Grand // since this means they are intended as percent values
448156b35d86SArmin Le Grand sal_Int32 nValue = 0;
448256b35d86SArmin Le Grand
448356b35d86SArmin Le Grand if(aValue >>= nValue)
448456b35d86SArmin Le Grand {
448556b35d86SArmin Le Grand bDoIt = nValue > 0;
448656b35d86SArmin Le Grand }
448756b35d86SArmin Le Grand }
448856b35d86SArmin Le Grand
448956b35d86SArmin Le Grand if(bDoIt)
449056b35d86SArmin Le Grand {
449156b35d86SArmin Le Grand const SfxItemPool& rPool = pDocShell->GetDoc()->GetAttrPool();
449256b35d86SArmin Le Grand const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID));
449356b35d86SArmin Le Grand
449456b35d86SArmin Le Grand if(eMapUnit != SFX_MAPUNIT_100TH_MM)
449556b35d86SArmin Le Grand {
449656b35d86SArmin Le Grand SvxUnoConvertFromMM(eMapUnit, aValue);
449756b35d86SArmin Le Grand }
449856b35d86SArmin Le Grand }
449956b35d86SArmin Le Grand }
450056b35d86SArmin Le Grand
450156b35d86SArmin Le Grand switch(pEntry->nWID)
450256b35d86SArmin Le Grand {
450356b35d86SArmin Le Grand case XATTR_FILLGRADIENT:
450456b35d86SArmin Le Grand case XATTR_FILLHATCH:
450556b35d86SArmin Le Grand case XATTR_FILLBITMAP:
450656b35d86SArmin Le Grand case XATTR_FILLFLOATTRANSPARENCE:
450756b35d86SArmin Le Grand // not yet needed; activate when LineStyle support may be added
450856b35d86SArmin Le Grand // case XATTR_LINESTART:
450956b35d86SArmin Le Grand // case XATTR_LINEEND:
451056b35d86SArmin Le Grand // case XATTR_LINEDASH:
451156b35d86SArmin Le Grand {
451256b35d86SArmin Le Grand if(MID_NAME == nMemberId)
451356b35d86SArmin Le Grand {
451456b35d86SArmin Le Grand //UUUU add set commands for FillName items
451556b35d86SArmin Le Grand OUString aTempName;
451656b35d86SArmin Le Grand
451756b35d86SArmin Le Grand if(!(aValue >>= aTempName))
451856b35d86SArmin Le Grand {
451956b35d86SArmin Le Grand throw lang::IllegalArgumentException();
452056b35d86SArmin Le Grand }
452156b35d86SArmin Le Grand
452256b35d86SArmin Le Grand SvxShape::SetFillAttribute(pEntry->nWID, aTempName, aSet);
452356b35d86SArmin Le Grand bDone = true;
452456b35d86SArmin Le Grand }
452556b35d86SArmin Le Grand else if(MID_GRAFURL == nMemberId)
452656b35d86SArmin Le Grand {
452756b35d86SArmin Le Grand if(XATTR_FILLBITMAP == pEntry->nWID)
452856b35d86SArmin Le Grand {
452956b35d86SArmin Le Grand //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used
453056b35d86SArmin Le Grand const Graphic aNullGraphic;
453156b35d86SArmin Le Grand XFillBitmapItem aXFillBitmapItem(aSet.GetPool(), aNullGraphic);
453256b35d86SArmin Le Grand
453356b35d86SArmin Le Grand aXFillBitmapItem.PutValue(aValue, nMemberId);
453456b35d86SArmin Le Grand aSet.Put(aXFillBitmapItem);
453556b35d86SArmin Le Grand bDone = true;
453656b35d86SArmin Le Grand }
453756b35d86SArmin Le Grand }
453856b35d86SArmin Le Grand
453956b35d86SArmin Le Grand break;
454056b35d86SArmin Le Grand }
454156b35d86SArmin Le Grand case RES_BACKGROUND:
454256b35d86SArmin Le Grand {
454356b35d86SArmin Le Grand //UUUU
454456b35d86SArmin Le Grand const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND));
454556b35d86SArmin Le Grand SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
454656b35d86SArmin Le Grand
454756b35d86SArmin Le Grand aChangedBrushItem.PutValue(aValue, nMemberId);
454856b35d86SArmin Le Grand
454956b35d86SArmin Le Grand if(!(aChangedBrushItem == aOriginalBrushItem))
455056b35d86SArmin Le Grand {
455156b35d86SArmin Le Grand setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, aSet);
455256b35d86SArmin Le Grand }
455356b35d86SArmin Le Grand
455456b35d86SArmin Le Grand bDone = true;
455556b35d86SArmin Le Grand break;
455656b35d86SArmin Le Grand }
455756b35d86SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
455856b35d86SArmin Le Grand {
455956b35d86SArmin Le Grand //UUUU
456056b35d86SArmin Le Grand drawing::BitmapMode eMode;
456156b35d86SArmin Le Grand
456256b35d86SArmin Le Grand if(!(aValue >>= eMode))
456356b35d86SArmin Le Grand {
456456b35d86SArmin Le Grand sal_Int32 nMode = 0;
456556b35d86SArmin Le Grand
456656b35d86SArmin Le Grand if(!(aValue >>= nMode))
456756b35d86SArmin Le Grand {
456856b35d86SArmin Le Grand throw lang::IllegalArgumentException();
456956b35d86SArmin Le Grand }
457056b35d86SArmin Le Grand
457156b35d86SArmin Le Grand eMode = (drawing::BitmapMode)nMode;
457256b35d86SArmin Le Grand }
457356b35d86SArmin Le Grand
457456b35d86SArmin Le Grand aSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode));
457556b35d86SArmin Le Grand aSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode));
457656b35d86SArmin Le Grand
457756b35d86SArmin Le Grand bDone = true;
457856b35d86SArmin Le Grand break;
457956b35d86SArmin Le Grand }
458056b35d86SArmin Le Grand default: break;
458156b35d86SArmin Le Grand }
458256b35d86SArmin Le Grand
458356b35d86SArmin Le Grand if(!bDone)
458456b35d86SArmin Le Grand {
458556b35d86SArmin Le Grand pPropSet->setPropertyValue( rPropName, aValue, aSet );
458656b35d86SArmin Le Grand }
458756b35d86SArmin Le Grand }
458856b35d86SArmin Le Grand
458956b35d86SArmin Le Grand //UUUU clear parent again
459056b35d86SArmin Le Grand aSet.SetParent(0);
459156b35d86SArmin Le Grand }
459256b35d86SArmin Le Grand
459356b35d86SArmin Le Grand //UUUU need to ensure uniqueness of evtl. added NameOrIndex items
459456b35d86SArmin Le Grand // currently in principle only needed when bTakeCareOfDrawingLayerFillStyle,
459556b35d86SArmin Le Grand // but does not hurt and is easily forgotten later eventually, so keep it
459656b35d86SArmin Le Grand // as common case
459756b35d86SArmin Le Grand pDocShell->GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aSet);
459856b35d86SArmin Le Grand
459956b35d86SArmin Le Grand // AutomaticStyle creation
4600cdf0e10cSrcweir SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily );
4601cdf0e10cSrcweir uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily);
460256b35d86SArmin Le Grand
4603cdf0e10cSrcweir return xRet;
4604cdf0e10cSrcweir }
4605cdf0e10cSrcweir /*-- 31.05.2006 11:24:02---------------------------------------------------
4606cdf0e10cSrcweir
4607cdf0e10cSrcweir -----------------------------------------------------------------------*/
createEnumeration()4608cdf0e10cSrcweir uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( )
4609cdf0e10cSrcweir throw (uno::RuntimeException)
4610cdf0e10cSrcweir {
4611cdf0e10cSrcweir if( !pDocShell )
4612cdf0e10cSrcweir throw uno::RuntimeException();
4613cdf0e10cSrcweir return uno::Reference< container::XEnumeration >
4614cdf0e10cSrcweir (new SwXAutoStylesEnumerator( pDocShell->GetDoc(), eFamily ));
4615cdf0e10cSrcweir }
4616cdf0e10cSrcweir /*-- 19.05.2006 11:24:03---------------------------------------------------
4617cdf0e10cSrcweir
4618cdf0e10cSrcweir -----------------------------------------------------------------------*/
getElementType()4619cdf0e10cSrcweir uno::Type SwXAutoStyleFamily::getElementType( ) throw(uno::RuntimeException)
4620cdf0e10cSrcweir {
4621cdf0e10cSrcweir return ::getCppuType((const uno::Reference<style::XAutoStyle>*)0);
4622cdf0e10cSrcweir }
4623cdf0e10cSrcweir /*-- 19.05.2006 11:24:04---------------------------------------------------
4624cdf0e10cSrcweir
4625cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasElements()4626cdf0e10cSrcweir sal_Bool SwXAutoStyleFamily::hasElements( ) throw(uno::RuntimeException)
4627cdf0e10cSrcweir {
4628cdf0e10cSrcweir return sal_False;
4629cdf0e10cSrcweir }
4630cdf0e10cSrcweir
4631cdf0e10cSrcweir /*-- 31.05.2006 11:24:05---------------------------------------------------
4632cdf0e10cSrcweir
4633cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwAutoStylesEnumImpl(SwDoc * pInitDoc,IStyleAccess::SwAutoStyleFamily eFam)4634cdf0e10cSrcweir SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam )
4635cdf0e10cSrcweir : pDoc( pInitDoc ), eFamily( eFam )
4636cdf0e10cSrcweir {
4637cdf0e10cSrcweir // special case for ruby auto styles:
4638cdf0e10cSrcweir if ( IStyleAccess::AUTO_STYLE_RUBY == eFam )
4639cdf0e10cSrcweir {
4640cdf0e10cSrcweir std::set< std::pair< sal_uInt16, sal_uInt16 > > aRubyMap;
4641cdf0e10cSrcweir SwAttrPool& rAttrPool = pDoc->GetAttrPool();
4642cdf0e10cSrcweir sal_uInt32 nCount = rAttrPool.GetItemCount2( RES_TXTATR_CJK_RUBY );
4643cdf0e10cSrcweir
4644cdf0e10cSrcweir for ( sal_uInt32 nI = 0; nI < nCount; ++nI )
4645cdf0e10cSrcweir {
4646cdf0e10cSrcweir const SwFmtRuby* pItem = static_cast<const SwFmtRuby*>(rAttrPool.GetItem2( RES_TXTATR_CJK_RUBY, nI ));
4647cdf0e10cSrcweir if ( pItem && pItem->GetTxtRuby() )
4648cdf0e10cSrcweir {
4649cdf0e10cSrcweir std::pair< sal_uInt16, sal_uInt16 > aPair( pItem->GetPosition(), pItem->GetAdjustment() );
4650cdf0e10cSrcweir if ( aRubyMap.find( aPair ) == aRubyMap.end() )
4651cdf0e10cSrcweir {
4652cdf0e10cSrcweir aRubyMap.insert( aPair );
4653cdf0e10cSrcweir SfxItemSet_Pointer_t pItemSet( new SfxItemSet( rAttrPool, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY ) );
4654cdf0e10cSrcweir pItemSet->Put( *pItem );
4655cdf0e10cSrcweir mAutoStyles.push_back( pItemSet );
4656cdf0e10cSrcweir }
4657cdf0e10cSrcweir }
4658cdf0e10cSrcweir }
4659cdf0e10cSrcweir }
4660cdf0e10cSrcweir else
4661cdf0e10cSrcweir {
4662cdf0e10cSrcweir pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily );
4663cdf0e10cSrcweir }
4664cdf0e10cSrcweir
4665cdf0e10cSrcweir aIter = mAutoStyles.begin();
4666cdf0e10cSrcweir }
4667cdf0e10cSrcweir
4668cdf0e10cSrcweir /*-- 31.05.2006 11:24:05---------------------------------------------------
4669cdf0e10cSrcweir
4670cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXAutoStylesEnumerator(SwDoc * pDoc,IStyleAccess::SwAutoStyleFamily eFam)4671cdf0e10cSrcweir SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam )
4672cdf0e10cSrcweir : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) )
4673cdf0e10cSrcweir {
4674cdf0e10cSrcweir // Register ourselves as a listener to the document (via the page descriptor)
4675cdf0e10cSrcweir pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4676cdf0e10cSrcweir }
4677cdf0e10cSrcweir /*-- 31.05.2006 11:24:05---------------------------------------------------
4678cdf0e10cSrcweir
4679cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXAutoStylesEnumerator()4680cdf0e10cSrcweir SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator()
4681cdf0e10cSrcweir {
4682cdf0e10cSrcweir delete pImpl;
4683cdf0e10cSrcweir }
4684cdf0e10cSrcweir
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)4685cdf0e10cSrcweir void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
4686cdf0e10cSrcweir {
4687cdf0e10cSrcweir ClientModify(this, pOld, pNew);
4688cdf0e10cSrcweir if(!GetRegisteredIn())
4689cdf0e10cSrcweir {
4690cdf0e10cSrcweir delete pImpl;
4691cdf0e10cSrcweir pImpl = 0;
4692cdf0e10cSrcweir }
4693cdf0e10cSrcweir }
4694cdf0e10cSrcweir
4695cdf0e10cSrcweir
4696cdf0e10cSrcweir /*-- 31.05.2006 11:24:05---------------------------------------------------
4697cdf0e10cSrcweir
4698cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasMoreElements()4699cdf0e10cSrcweir ::sal_Bool SwXAutoStylesEnumerator::hasMoreElements( )
4700cdf0e10cSrcweir throw (uno::RuntimeException)
4701cdf0e10cSrcweir {
4702cdf0e10cSrcweir if( !pImpl )
4703cdf0e10cSrcweir throw uno::RuntimeException();
4704cdf0e10cSrcweir return pImpl->hasMoreElements();
4705cdf0e10cSrcweir }
4706cdf0e10cSrcweir /*-- 31.05.2006 11:24:05---------------------------------------------------
4707cdf0e10cSrcweir
4708cdf0e10cSrcweir -----------------------------------------------------------------------*/
nextElement()4709cdf0e10cSrcweir uno::Any SwXAutoStylesEnumerator::nextElement( )
4710cdf0e10cSrcweir throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
4711cdf0e10cSrcweir {
4712cdf0e10cSrcweir if( !pImpl )
4713cdf0e10cSrcweir throw uno::RuntimeException();
4714cdf0e10cSrcweir uno::Any aRet;
4715cdf0e10cSrcweir if( pImpl->hasMoreElements() )
4716cdf0e10cSrcweir {
4717cdf0e10cSrcweir SfxItemSet_Pointer_t pNextSet = pImpl->nextElement();
4718cdf0e10cSrcweir uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(),
4719cdf0e10cSrcweir pNextSet, pImpl->getFamily());
4720cdf0e10cSrcweir aRet.setValue(&xAutoStyle, ::getCppuType((uno::Reference<style::XAutoStyle>*)0));
4721cdf0e10cSrcweir }
4722cdf0e10cSrcweir return aRet;
4723cdf0e10cSrcweir }
4724cdf0e10cSrcweir
472556b35d86SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
472656b35d86SArmin Le Grand //UUUU SwXAutoStyle with the family IStyleAccess::AUTO_STYLE_PARA (or
472756b35d86SArmin Le Grand // PROPERTY_MAP_PARA_AUTO_STYLE) now uses DrawingLayer FillStyles to allow
472856b35d86SArmin Le Grand // unified paragraph background fill, thus the UNO API implementation has to
472956b35d86SArmin Le Grand // support the needed slots for these. This seems to be used only for reading
473056b35d86SArmin Le Grand // (no setPropertyValue implementation here), so maybe specialized for saving
473156b35d86SArmin Le Grand // the Writer Doc to ODF
473256b35d86SArmin Le Grand
SwXAutoStyle(SwDoc * pDoc,SfxItemSet_Pointer_t pInitSet,IStyleAccess::SwAutoStyleFamily eFam)473356b35d86SArmin Le Grand SwXAutoStyle::SwXAutoStyle(
473456b35d86SArmin Le Grand SwDoc* pDoc,
473556b35d86SArmin Le Grand SfxItemSet_Pointer_t pInitSet,
473656b35d86SArmin Le Grand IStyleAccess::SwAutoStyleFamily eFam)
473756b35d86SArmin Le Grand : mpSet(pInitSet),
473856b35d86SArmin Le Grand meFamily(eFam),
473956b35d86SArmin Le Grand mrDoc(*pDoc)
4740cdf0e10cSrcweir {
4741cdf0e10cSrcweir // Register ourselves as a listener to the document (via the page descriptor)
474256b35d86SArmin Le Grand mrDoc.GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4743cdf0e10cSrcweir }
4744cdf0e10cSrcweir
~SwXAutoStyle()4745cdf0e10cSrcweir SwXAutoStyle::~SwXAutoStyle()
4746cdf0e10cSrcweir {
4747cdf0e10cSrcweir }
4748cdf0e10cSrcweir
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)474956b35d86SArmin Le Grand void SwXAutoStyle::Modify(
475056b35d86SArmin Le Grand const SfxPoolItem* pOld,
475156b35d86SArmin Le Grand const SfxPoolItem *pNew)
4752cdf0e10cSrcweir {
4753cdf0e10cSrcweir ClientModify(this, pOld, pNew);
475456b35d86SArmin Le Grand
4755cdf0e10cSrcweir if(!GetRegisteredIn())
475656b35d86SArmin Le Grand {
475756b35d86SArmin Le Grand mpSet.reset();
475856b35d86SArmin Le Grand }
4759cdf0e10cSrcweir }
4760cdf0e10cSrcweir
getPropertySetInfo()4761cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo()
4762cdf0e10cSrcweir throw (uno::RuntimeException)
4763cdf0e10cSrcweir {
4764cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xRet;
476556b35d86SArmin Le Grand switch( meFamily )
4766cdf0e10cSrcweir {
4767cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_CHAR:
4768cdf0e10cSrcweir {
4769cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xCharRef;
4770cdf0e10cSrcweir if(!xCharRef.is())
4771cdf0e10cSrcweir {
4772cdf0e10cSrcweir xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE)->getPropertySetInfo();
4773cdf0e10cSrcweir }
4774cdf0e10cSrcweir xRet = xCharRef;
4775cdf0e10cSrcweir }
4776cdf0e10cSrcweir break;
4777cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_RUBY:
4778cdf0e10cSrcweir {
4779cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xRubyRef;
4780cdf0e10cSrcweir if(!xRubyRef.is())
4781cdf0e10cSrcweir {
4782cdf0e10cSrcweir sal_uInt16 nMapId = PROPERTY_MAP_RUBY_AUTO_STYLE;
4783cdf0e10cSrcweir xRubyRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
4784cdf0e10cSrcweir }
4785cdf0e10cSrcweir xRet = xRubyRef;
4786cdf0e10cSrcweir }
4787cdf0e10cSrcweir break;
4788cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_PARA:
4789cdf0e10cSrcweir {
4790cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xParaRef;
4791cdf0e10cSrcweir if(!xParaRef.is())
4792cdf0e10cSrcweir {
4793cdf0e10cSrcweir sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE;
4794cdf0e10cSrcweir xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
4795cdf0e10cSrcweir }
4796cdf0e10cSrcweir xRet = xParaRef;
4797cdf0e10cSrcweir }
4798cdf0e10cSrcweir break;
4799cdf0e10cSrcweir
4800cdf0e10cSrcweir default:
4801cdf0e10cSrcweir ;
4802cdf0e10cSrcweir }
4803cdf0e10cSrcweir
4804cdf0e10cSrcweir return xRet;
4805cdf0e10cSrcweir }
4806cdf0e10cSrcweir
setPropertyValue(const OUString &,const uno::Any &)480756b35d86SArmin Le Grand void SwXAutoStyle::setPropertyValue(
480856b35d86SArmin Le Grand const OUString& /*rPropertyName*/,
480956b35d86SArmin Le Grand const uno::Any& /*rValue*/ )
481056b35d86SArmin Le Grand throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
4811cdf0e10cSrcweir {
4812cdf0e10cSrcweir }
4813cdf0e10cSrcweir
getPropertyValue(const OUString & rPropertyName)481456b35d86SArmin Le Grand uno::Any SwXAutoStyle::getPropertyValue(
481556b35d86SArmin Le Grand const OUString& rPropertyName )
481656b35d86SArmin Le Grand throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4817cdf0e10cSrcweir {
4818cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
4819cdf0e10cSrcweir const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
482056b35d86SArmin Le Grand
4821cdf0e10cSrcweir return GetPropertyValues_Impl(aProperties).getConstArray()[0];
4822cdf0e10cSrcweir }
4823cdf0e10cSrcweir
addPropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)482456b35d86SArmin Le Grand void SwXAutoStyle::addPropertyChangeListener(
482556b35d86SArmin Le Grand const OUString& /*aPropertyName*/,
4826cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
482756b35d86SArmin Le Grand throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4828cdf0e10cSrcweir {
4829cdf0e10cSrcweir }
4830cdf0e10cSrcweir
removePropertyChangeListener(const OUString &,const uno::Reference<beans::XPropertyChangeListener> &)483156b35d86SArmin Le Grand void SwXAutoStyle::removePropertyChangeListener(
483256b35d86SArmin Le Grand const OUString& /*aPropertyName*/,
4833cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
483456b35d86SArmin Le Grand throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4835cdf0e10cSrcweir {
4836cdf0e10cSrcweir }
4837cdf0e10cSrcweir
addVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)483856b35d86SArmin Le Grand void SwXAutoStyle::addVetoableChangeListener(
483956b35d86SArmin Le Grand const OUString& /*PropertyName*/,
4840cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
484156b35d86SArmin Le Grand throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4842cdf0e10cSrcweir {
4843cdf0e10cSrcweir }
4844cdf0e10cSrcweir
removeVetoableChangeListener(const OUString &,const uno::Reference<beans::XVetoableChangeListener> &)484556b35d86SArmin Le Grand void SwXAutoStyle::removeVetoableChangeListener(
484656b35d86SArmin Le Grand const OUString& /*PropertyName*/,
4847cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
484856b35d86SArmin Le Grand throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4849cdf0e10cSrcweir {
4850cdf0e10cSrcweir }
4851cdf0e10cSrcweir
setPropertyValues(const uno::Sequence<::rtl::OUString> &,const uno::Sequence<uno::Any> &)4852cdf0e10cSrcweir void SwXAutoStyle::setPropertyValues(
4853cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
4854cdf0e10cSrcweir const uno::Sequence< uno::Any >& /*aValues*/ )
485556b35d86SArmin Le Grand throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
4856cdf0e10cSrcweir {
4857cdf0e10cSrcweir }
4858cdf0e10cSrcweir
GetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames)4859cdf0e10cSrcweir uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl(
4860cdf0e10cSrcweir const uno::Sequence< OUString > & rPropertyNames )
4861cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4862cdf0e10cSrcweir {
486356b35d86SArmin Le Grand if( !mpSet.get() )
486456b35d86SArmin Le Grand {
4865cdf0e10cSrcweir throw uno::RuntimeException();
486656b35d86SArmin Le Grand }
4867cdf0e10cSrcweir
486856b35d86SArmin Le Grand // query_item
4869cdf0e10cSrcweir sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
487056b35d86SArmin Le Grand
487156b35d86SArmin Le Grand switch(meFamily)
4872cdf0e10cSrcweir {
4873cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4874cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4875cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
487656b35d86SArmin Le Grand default: ;
4877cdf0e10cSrcweir }
4878cdf0e10cSrcweir
4879cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4880cdf0e10cSrcweir const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
4881cdf0e10cSrcweir const OUString* pNames = rPropertyNames.getConstArray();
488256b35d86SArmin Le Grand const sal_Int32 nLen(rPropertyNames.getLength());
4883cdf0e10cSrcweir uno::Sequence< uno::Any > aRet( nLen );
4884cdf0e10cSrcweir uno::Any* pValues = aRet.getArray();
488556b35d86SArmin Le Grand const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily);
4886cdf0e10cSrcweir
4887cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLen; ++i )
4888cdf0e10cSrcweir {
488956b35d86SArmin Le Grand const OUString& rPropName = pNames[i];
4890cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName);
489156b35d86SArmin Le Grand
4892cdf0e10cSrcweir if(!pEntry)
4893cdf0e10cSrcweir {
489456b35d86SArmin Le Grand throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
489556b35d86SArmin Le Grand }
489656b35d86SArmin Le Grand
489756b35d86SArmin Le Grand uno::Any aTarget;
489856b35d86SArmin Le Grand bool bDone(false);
489956b35d86SArmin Le Grand
490056b35d86SArmin Le Grand if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID )
490156b35d86SArmin Le Grand {
490256b35d86SArmin Le Grand OUString sName(StylePool::nameOf( mpSet ));
490356b35d86SArmin Le Grand aTarget <<= sName;
490456b35d86SArmin Le Grand bDone = true;
490556b35d86SArmin Le Grand }
490656b35d86SArmin Le Grand else if(bTakeCareOfDrawingLayerFillStyle)
490756b35d86SArmin Le Grand {
490856b35d86SArmin Le Grand //UUUU add support for DrawingLayer FillStyle slots
490956b35d86SArmin Le Grand switch(pEntry->nWID)
491056b35d86SArmin Le Grand {
491156b35d86SArmin Le Grand case RES_BACKGROUND:
491256b35d86SArmin Le Grand {
491356b35d86SArmin Le Grand const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(*mpSet, RES_BACKGROUND));
491456b35d86SArmin Le Grand const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
491556b35d86SArmin Le Grand
491656b35d86SArmin Le Grand if(!aOriginalBrushItem.QueryValue(aTarget, nMemberId))
491756b35d86SArmin Le Grand {
491856b35d86SArmin Le Grand OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
491956b35d86SArmin Le Grand }
492056b35d86SArmin Le Grand
492156b35d86SArmin Le Grand bDone = true;
492256b35d86SArmin Le Grand break;
492356b35d86SArmin Le Grand }
492456b35d86SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
492556b35d86SArmin Le Grand {
492656b35d86SArmin Le Grand const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&mpSet->Get(XATTR_FILLBMP_STRETCH));
492756b35d86SArmin Le Grand const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&mpSet->Get(XATTR_FILLBMP_TILE));
492856b35d86SArmin Le Grand
492956b35d86SArmin Le Grand if( pTileItem && pTileItem->GetValue() )
493056b35d86SArmin Le Grand {
493156b35d86SArmin Le Grand aTarget <<= drawing::BitmapMode_REPEAT;
493256b35d86SArmin Le Grand }
493356b35d86SArmin Le Grand else if( pStretchItem && pStretchItem->GetValue() )
493456b35d86SArmin Le Grand {
493556b35d86SArmin Le Grand aTarget <<= drawing::BitmapMode_STRETCH;
4936cdf0e10cSrcweir }
4937cdf0e10cSrcweir else
493856b35d86SArmin Le Grand {
493956b35d86SArmin Le Grand aTarget <<= drawing::BitmapMode_NO_REPEAT;
4940cdf0e10cSrcweir }
494156b35d86SArmin Le Grand
494256b35d86SArmin Le Grand bDone = true;
494356b35d86SArmin Le Grand break;
494456b35d86SArmin Le Grand }
494556b35d86SArmin Le Grand }
494656b35d86SArmin Le Grand }
494756b35d86SArmin Le Grand
494856b35d86SArmin Le Grand if(!bDone)
494956b35d86SArmin Le Grand {
495056b35d86SArmin Le Grand pPropSet->getPropertyValue( *pEntry, *mpSet, aTarget );
495156b35d86SArmin Le Grand }
495256b35d86SArmin Le Grand
495356b35d86SArmin Le Grand if(bTakeCareOfDrawingLayerFillStyle)
495456b35d86SArmin Le Grand {
495556b35d86SArmin Le Grand if(pEntry->pType && *(pEntry->pType) == ::getCppuType((const sal_Int16*)0) && *(pEntry->pType) != aTarget.getValueType())
495656b35d86SArmin Le Grand {
495756b35d86SArmin Le Grand // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
495856b35d86SArmin Le Grand sal_Int32 nValue = 0;
495956b35d86SArmin Le Grand aTarget >>= nValue;
496056b35d86SArmin Le Grand aTarget <<= (sal_Int16)nValue;
496156b35d86SArmin Le Grand }
496256b35d86SArmin Le Grand
496356b35d86SArmin Le Grand // check for needed metric translation
496456b35d86SArmin Le Grand if(pEntry->nMemberId & SFX_METRIC_ITEM)
496556b35d86SArmin Le Grand {
496656b35d86SArmin Le Grand bool bDoIt(true);
496756b35d86SArmin Le Grand
496856b35d86SArmin Le Grand if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID)
496956b35d86SArmin Le Grand {
497056b35d86SArmin Le Grand // exception: If these ItemTypes are used, do not convert when these are negative
497156b35d86SArmin Le Grand // since this means they are intended as percent values
497256b35d86SArmin Le Grand sal_Int32 nValue = 0;
497356b35d86SArmin Le Grand
497456b35d86SArmin Le Grand if(aTarget >>= nValue)
497556b35d86SArmin Le Grand {
497656b35d86SArmin Le Grand bDoIt = nValue > 0;
497756b35d86SArmin Le Grand }
497856b35d86SArmin Le Grand }
497956b35d86SArmin Le Grand
498056b35d86SArmin Le Grand if(bDoIt)
498156b35d86SArmin Le Grand {
498256b35d86SArmin Le Grand const SfxItemPool& rPool = mrDoc.GetAttrPool();
498356b35d86SArmin Le Grand const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID));
498456b35d86SArmin Le Grand
498556b35d86SArmin Le Grand if(eMapUnit != SFX_MAPUNIT_100TH_MM)
498656b35d86SArmin Le Grand {
498756b35d86SArmin Le Grand SvxUnoConvertToMM(eMapUnit, aTarget);
498856b35d86SArmin Le Grand }
498956b35d86SArmin Le Grand }
499056b35d86SArmin Le Grand }
499156b35d86SArmin Le Grand }
499256b35d86SArmin Le Grand
499356b35d86SArmin Le Grand // add value
499456b35d86SArmin Le Grand pValues[i] = aTarget;
499556b35d86SArmin Le Grand }
499656b35d86SArmin Le Grand
4997cdf0e10cSrcweir return aRet;
4998cdf0e10cSrcweir }
4999cdf0e10cSrcweir
getPropertyValues(const uno::Sequence<::rtl::OUString> & rPropertyNames)5000cdf0e10cSrcweir uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues (
5001cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rPropertyNames )
5002cdf0e10cSrcweir throw (uno::RuntimeException)
5003cdf0e10cSrcweir {
5004cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
5005cdf0e10cSrcweir uno::Sequence< uno::Any > aValues;
5006cdf0e10cSrcweir
5007cdf0e10cSrcweir // workaround for bad designed API
5008cdf0e10cSrcweir try
5009cdf0e10cSrcweir {
5010cdf0e10cSrcweir aValues = GetPropertyValues_Impl( rPropertyNames );
5011cdf0e10cSrcweir }
5012cdf0e10cSrcweir catch (beans::UnknownPropertyException &)
5013cdf0e10cSrcweir {
5014cdf0e10cSrcweir throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
5015cdf0e10cSrcweir }
5016cdf0e10cSrcweir catch (lang::WrappedTargetException &)
5017cdf0e10cSrcweir {
5018cdf0e10cSrcweir throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
5019cdf0e10cSrcweir }
5020cdf0e10cSrcweir
5021cdf0e10cSrcweir return aValues;
5022cdf0e10cSrcweir }
5023cdf0e10cSrcweir
addPropertiesChangeListener(const uno::Sequence<::rtl::OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)5024cdf0e10cSrcweir void SwXAutoStyle::addPropertiesChangeListener(
5025cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
5026cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
5027cdf0e10cSrcweir throw (uno::RuntimeException)
5028cdf0e10cSrcweir {
5029cdf0e10cSrcweir }
5030cdf0e10cSrcweir
removePropertiesChangeListener(const uno::Reference<beans::XPropertiesChangeListener> &)5031cdf0e10cSrcweir void SwXAutoStyle::removePropertiesChangeListener(
5032cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
5033cdf0e10cSrcweir throw (uno::RuntimeException)
5034cdf0e10cSrcweir {
5035cdf0e10cSrcweir }
5036cdf0e10cSrcweir
firePropertiesChangeEvent(const uno::Sequence<::rtl::OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)5037cdf0e10cSrcweir void SwXAutoStyle::firePropertiesChangeEvent(
5038cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
5039cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
5040cdf0e10cSrcweir throw (uno::RuntimeException)
5041cdf0e10cSrcweir {
5042cdf0e10cSrcweir }
5043cdf0e10cSrcweir
getPropertyState(const OUString & rPropertyName)504456b35d86SArmin Le Grand beans::PropertyState SwXAutoStyle::getPropertyState(
504556b35d86SArmin Le Grand const OUString& rPropertyName )
504656b35d86SArmin Le Grand throw( beans::UnknownPropertyException, uno::RuntimeException)
5047cdf0e10cSrcweir {
5048cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
5049cdf0e10cSrcweir
5050cdf0e10cSrcweir uno::Sequence< OUString > aNames(1);
5051cdf0e10cSrcweir OUString* pNames = aNames.getArray();
5052cdf0e10cSrcweir pNames[0] = rPropertyName;
5053cdf0e10cSrcweir uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
5054cdf0e10cSrcweir return aStates.getConstArray()[0];
5055cdf0e10cSrcweir }
5056cdf0e10cSrcweir
setPropertyToDefault(const OUString &)505756b35d86SArmin Le Grand void SwXAutoStyle::setPropertyToDefault(
505856b35d86SArmin Le Grand const OUString& /*PropertyName*/ )
505956b35d86SArmin Le Grand throw( beans::UnknownPropertyException, uno::RuntimeException )
5060cdf0e10cSrcweir {
5061cdf0e10cSrcweir }
5062cdf0e10cSrcweir
getPropertyDefault(const OUString & rPropertyName)506356b35d86SArmin Le Grand uno::Any SwXAutoStyle::getPropertyDefault(
506456b35d86SArmin Le Grand const OUString& rPropertyName )
506556b35d86SArmin Le Grand throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
5066cdf0e10cSrcweir {
5067cdf0e10cSrcweir const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
506856b35d86SArmin Le Grand
5069cdf0e10cSrcweir return getPropertyDefaults ( aSequence ).getConstArray()[0];
5070cdf0e10cSrcweir }
5071cdf0e10cSrcweir
getPropertyStates(const uno::Sequence<::rtl::OUString> & rPropertyNames)5072cdf0e10cSrcweir uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates(
5073cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rPropertyNames )
5074cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
5075cdf0e10cSrcweir {
507656b35d86SArmin Le Grand if( !mpSet.get() )
507756b35d86SArmin Le Grand {
5078cdf0e10cSrcweir throw uno::RuntimeException();
507956b35d86SArmin Le Grand }
508056b35d86SArmin Le Grand
5081cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
5082cdf0e10cSrcweir uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
5083cdf0e10cSrcweir beans::PropertyState* pStates = aRet.getArray();
5084cdf0e10cSrcweir const OUString* pNames = rPropertyNames.getConstArray();
5085cdf0e10cSrcweir sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
508656b35d86SArmin Le Grand
508756b35d86SArmin Le Grand switch(meFamily)
5088cdf0e10cSrcweir {
5089cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
5090cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
5091cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
509256b35d86SArmin Le Grand default: ;
5093cdf0e10cSrcweir }
5094cdf0e10cSrcweir
5095cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
5096cdf0e10cSrcweir const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
509756b35d86SArmin Le Grand const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily);
509856b35d86SArmin Le Grand
5099cdf0e10cSrcweir for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
5100cdf0e10cSrcweir {
510156b35d86SArmin Le Grand const OUString& rPropName = pNames[i];
5102cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName);
510356b35d86SArmin Le Grand
5104cdf0e10cSrcweir if(!pEntry)
510556b35d86SArmin Le Grand {
5106cdf0e10cSrcweir throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
5107cdf0e10cSrcweir }
510856b35d86SArmin Le Grand
510956b35d86SArmin Le Grand bool bDone(false);
511056b35d86SArmin Le Grand
511156b35d86SArmin Le Grand if(bTakeCareOfDrawingLayerFillStyle)
511256b35d86SArmin Le Grand {
511356b35d86SArmin Le Grand //UUUU DrawingLayer PropertyStyle support
511456b35d86SArmin Le Grand switch(pEntry->nWID)
511556b35d86SArmin Le Grand {
511656b35d86SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
511756b35d86SArmin Le Grand {
511856b35d86SArmin Le Grand if(SFX_ITEM_SET == mpSet->GetItemState(XATTR_FILLBMP_STRETCH, false)
511956b35d86SArmin Le Grand || SFX_ITEM_SET == mpSet->GetItemState(XATTR_FILLBMP_TILE, false))
512056b35d86SArmin Le Grand {
512156b35d86SArmin Le Grand pStates[i] = beans::PropertyState_DIRECT_VALUE;
512256b35d86SArmin Le Grand }
512356b35d86SArmin Le Grand else
512456b35d86SArmin Le Grand {
512556b35d86SArmin Le Grand pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
512656b35d86SArmin Le Grand }
512756b35d86SArmin Le Grand
512856b35d86SArmin Le Grand bDone = true;
512956b35d86SArmin Le Grand break;
513056b35d86SArmin Le Grand }
513156b35d86SArmin Le Grand case RES_BACKGROUND:
513256b35d86SArmin Le Grand {
513356b35d86SArmin Le Grand if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*mpSet))
513456b35d86SArmin Le Grand {
513556b35d86SArmin Le Grand pStates[i] = beans::PropertyState_DIRECT_VALUE;
513656b35d86SArmin Le Grand bDone = true;
513756b35d86SArmin Le Grand }
513856b35d86SArmin Le Grand
513956b35d86SArmin Le Grand break;
514056b35d86SArmin Le Grand }
514156b35d86SArmin Le Grand }
514256b35d86SArmin Le Grand }
514356b35d86SArmin Le Grand
514456b35d86SArmin Le Grand if(!bDone)
514556b35d86SArmin Le Grand {
514656b35d86SArmin Le Grand pStates[i] = pPropSet->getPropertyState(*pEntry, *mpSet );
514756b35d86SArmin Le Grand }
514856b35d86SArmin Le Grand }
514956b35d86SArmin Le Grand
5150cdf0e10cSrcweir return aRet;
5151cdf0e10cSrcweir }
5152cdf0e10cSrcweir
setAllPropertiesToDefault()5153cdf0e10cSrcweir void SwXAutoStyle::setAllPropertiesToDefault( )
5154cdf0e10cSrcweir throw (uno::RuntimeException)
5155cdf0e10cSrcweir {
5156cdf0e10cSrcweir }
5157cdf0e10cSrcweir
setPropertiesToDefault(const uno::Sequence<::rtl::OUString> & rPropertyNames)5158cdf0e10cSrcweir void SwXAutoStyle::setPropertiesToDefault(
515956b35d86SArmin Le Grand const uno::Sequence< ::rtl::OUString >& rPropertyNames )
5160cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
5161cdf0e10cSrcweir {
516256b35d86SArmin Le Grand if( !mpSet.get() )
516356b35d86SArmin Le Grand {
516456b35d86SArmin Le Grand throw uno::RuntimeException();
5165cdf0e10cSrcweir }
5166cdf0e10cSrcweir
516756b35d86SArmin Le Grand const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily);
5168cdf0e10cSrcweir
516956b35d86SArmin Le Grand if(!bTakeCareOfDrawingLayerFillStyle)
517056b35d86SArmin Le Grand {
517156b35d86SArmin Le Grand return;
517256b35d86SArmin Le Grand }
517356b35d86SArmin Le Grand
517456b35d86SArmin Le Grand //UUUU support DrawingLayer FillStyle slots from here on
517556b35d86SArmin Le Grand vos::OGuard aGuard(Application::GetSolarMutex());
517656b35d86SArmin Le Grand const OUString* pNames = rPropertyNames.getConstArray();
517756b35d86SArmin Le Grand sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
517856b35d86SArmin Le Grand
517956b35d86SArmin Le Grand switch(meFamily)
518056b35d86SArmin Le Grand {
518156b35d86SArmin Le Grand case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
518256b35d86SArmin Le Grand case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
518356b35d86SArmin Le Grand case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
518456b35d86SArmin Le Grand default: ;
518556b35d86SArmin Le Grand }
518656b35d86SArmin Le Grand
518756b35d86SArmin Le Grand const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
518856b35d86SArmin Le Grand const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
518956b35d86SArmin Le Grand
519056b35d86SArmin Le Grand for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
519156b35d86SArmin Le Grand {
519256b35d86SArmin Le Grand const OUString& rPropName = pNames[i];
519356b35d86SArmin Le Grand const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName);
519456b35d86SArmin Le Grand
519556b35d86SArmin Le Grand if(!pEntry)
519656b35d86SArmin Le Grand {
519756b35d86SArmin Le Grand throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
519856b35d86SArmin Le Grand }
519956b35d86SArmin Le Grand
520056b35d86SArmin Le Grand switch(pEntry->nWID)
520156b35d86SArmin Le Grand {
520256b35d86SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
520356b35d86SArmin Le Grand {
520456b35d86SArmin Le Grand mpSet->ClearItem(XATTR_FILLBMP_STRETCH);
520556b35d86SArmin Le Grand mpSet->ClearItem(XATTR_FILLBMP_TILE);
520656b35d86SArmin Le Grand }
520756b35d86SArmin Le Grand }
520856b35d86SArmin Le Grand }
520956b35d86SArmin Le Grand }
521056b35d86SArmin Le Grand
getPropertyDefaults(const uno::Sequence<::rtl::OUString> &)5211cdf0e10cSrcweir uno::Sequence< uno::Any > SwXAutoStyle::getPropertyDefaults(
5212cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ )
521356b35d86SArmin Le Grand throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
5214cdf0e10cSrcweir {
5215cdf0e10cSrcweir uno::Sequence< uno::Any > aRet(0);
521656b35d86SArmin Le Grand
5217cdf0e10cSrcweir return aRet;
5218cdf0e10cSrcweir }
5219cdf0e10cSrcweir
getProperties()522056b35d86SArmin Le Grand uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties()
522156b35d86SArmin Le Grand throw (uno::RuntimeException)
5222cdf0e10cSrcweir {
522356b35d86SArmin Le Grand if( !mpSet.get() )
5224cdf0e10cSrcweir throw uno::RuntimeException();
5225cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
5226cdf0e10cSrcweir std::vector< beans::PropertyValue > aPropertyVector;
5227cdf0e10cSrcweir
5228cdf0e10cSrcweir sal_Int8 nPropSetId = 0;
522956b35d86SArmin Le Grand switch(meFamily)
5230cdf0e10cSrcweir {
5231cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
5232cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
5233cdf0e10cSrcweir case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
5234cdf0e10cSrcweir default:
5235cdf0e10cSrcweir ;
5236cdf0e10cSrcweir }
5237cdf0e10cSrcweir
5238cdf0e10cSrcweir const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
5239cdf0e10cSrcweir const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
5240cdf0e10cSrcweir PropertyEntryVector_t aPropVector = pMap->getPropertyEntries();
5241cdf0e10cSrcweir // struct compareWhichIds
5242cdf0e10cSrcweir // {
5243cdf0e10cSrcweir // bool operator()(const sal_uInt16 w1, const sal_uInt16 w2) const
5244cdf0e10cSrcweir // {
5245cdf0e10cSrcweir // return w1 < w2;
5246cdf0e10cSrcweir // }
5247cdf0e10cSrcweir // };
5248cdf0e10cSrcweir // typedef std::map<const sal_uInt16, SfxItemPropertyNamedEntry, compareWhichIds> PropertyMap_t;
5249cdf0e10cSrcweir // PropertyMap_t aPropMap;
5250cdf0e10cSrcweir // aPropMap.reserve( aPropVector.size() );
5251cdf0e10cSrcweir // PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
5252cdf0e10cSrcweir // while( aIt != aPropertyEntries.end() )
5253cdf0e10cSrcweir // {
5254cdf0e10cSrcweir // aPropMap[aIt->nWID] = *aIt;
5255cdf0e10cSrcweir // ++aIt;
5256cdf0e10cSrcweir // }
5257cdf0e10cSrcweir
525856b35d86SArmin Le Grand SfxItemSet& rSet = *mpSet.get();
5259cdf0e10cSrcweir SfxItemIter aIter(rSet);
5260cdf0e10cSrcweir const SfxPoolItem* pItem = aIter.FirstItem();
5261cdf0e10cSrcweir
5262cdf0e10cSrcweir while ( pItem )
5263cdf0e10cSrcweir {
5264cdf0e10cSrcweir const sal_uInt16 nWID = pItem->Which();
5265cdf0e10cSrcweir
5266cdf0e10cSrcweir // PropertyMap_t::const_iterator aMapIt = aPropMap[nWID];
5267cdf0e10cSrcweir // if( aMapIt != aPropMap.getEnd() )
5268cdf0e10cSrcweir // {
5269cdf0e10cSrcweir // beans::PropertyValue aPropertyValue;
5270cdf0e10cSrcweir // aPropertyValue.Name = aIt->sName;
5271cdf0e10cSrcweir // pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
5272cdf0e10cSrcweir // aPropertyVector.push_back( aPropertyValue );
5273cdf0e10cSrcweir // }
5274cdf0e10cSrcweir // TODO: Optimize - and fix! the old iteration filled each WhichId
5275cdf0e10cSrcweir // only once but there are more properties than WhichIds
5276cdf0e10cSrcweir PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
5277cdf0e10cSrcweir while( aIt != aPropVector.end() )
5278cdf0e10cSrcweir {
5279cdf0e10cSrcweir if ( aIt->nWID == nWID )
5280cdf0e10cSrcweir {
5281cdf0e10cSrcweir beans::PropertyValue aPropertyValue;
5282cdf0e10cSrcweir aPropertyValue.Name = aIt->sName;
5283cdf0e10cSrcweir pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
5284cdf0e10cSrcweir aPropertyVector.push_back( aPropertyValue );
5285cdf0e10cSrcweir }
5286cdf0e10cSrcweir ++aIt;
5287cdf0e10cSrcweir }
5288cdf0e10cSrcweir /* int i = 0;
5289cdf0e10cSrcweir while ( pMap[i].nWID != 0 )
5290cdf0e10cSrcweir {
5291cdf0e10cSrcweir if ( pMap[i].nWID == nWID )
5292cdf0e10cSrcweir {
5293cdf0e10cSrcweir beans::PropertyValue aPropertyValue;
5294cdf0e10cSrcweir String sString( OUString::createFromAscii( pMap[i].pName ) );
5295cdf0e10cSrcweir aPropertyValue.Name = sString;
5296cdf0e10cSrcweir pItem->QueryValue( aPropertyValue.Value, pMap[i].nMemberId );
5297cdf0e10cSrcweir aPropertyVector.push_back( aPropertyValue );
5298cdf0e10cSrcweir break;
5299cdf0e10cSrcweir }
5300cdf0e10cSrcweir ++i;
5301cdf0e10cSrcweir }*/
5302cdf0e10cSrcweir pItem = aIter.NextItem();
5303cdf0e10cSrcweir }
5304cdf0e10cSrcweir
5305cdf0e10cSrcweir const sal_Int32 nCount = aPropertyVector.size();
5306cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aRet( nCount );
5307cdf0e10cSrcweir beans::PropertyValue* pProps = aRet.getArray();
5308cdf0e10cSrcweir
5309cdf0e10cSrcweir for ( int i = 0; i < nCount; ++i, pProps++ )
5310cdf0e10cSrcweir {
5311cdf0e10cSrcweir *pProps = aPropertyVector[i];
5312cdf0e10cSrcweir }
5313cdf0e10cSrcweir
5314cdf0e10cSrcweir return aRet;
5315cdf0e10cSrcweir }
531656b35d86SArmin Le Grand
531756b35d86SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
531856b35d86SArmin Le Grand //eof
5319