xref: /aoo4110/main/sd/inc/stlpool.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SD_STLPOOL_HXX
25 #define _SD_STLPOOL_HXX
26 
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/container/XIndexAccess.hpp>
29 #include <com/sun/star/container/XNameContainer.hpp>
30 #include <com/sun/star/container/XNamed.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/lang/XComponent.hpp>
33 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34 
35 #include <cppuhelper/implbase4.hxx>
36 #include <cppuhelper/implbase7.hxx>
37 #include <map>
38 #include <vector>
39 
40 #include <stlfamily.hxx>
41 #include <stlsheet.hxx>
42 
43 #include <sddllapi.h>
44 
45 class SdStyleSheet;
46 class SdDrawDocument;
47 class SdPage;
48 
49 typedef std::map< const SdPage*, SdStyleFamilyRef > SdStyleFamilyMap;
50 
51 typedef ::cppu::ImplInheritanceHelper4< SfxStyleSheetPool,
52 										::com::sun::star::lang::XServiceInfo,
53 										::com::sun::star::container::XIndexAccess,
54 										::com::sun::star::container::XNameAccess,
55 										::com::sun::star::lang::XComponent > SdStyleSheetPoolBase;
56 
57 class SdStyleSheetPool : public SdStyleSheetPoolBase, public SfxListener
58 {
59     friend class SdDrawDocument;
60 public:
61 						SdStyleSheetPool(SfxItemPool const& rPool, SdDrawDocument* pDocument);
62 
SetActualStyleSheet(SfxStyleSheetBase * pActStyleSheet)63 	void				SetActualStyleSheet(SfxStyleSheetBase* pActStyleSheet)	{ mpActualStyleSheet = pActStyleSheet; }
GetActualStyleSheet()64 	SfxStyleSheetBase*	GetActualStyleSheet()									{ return mpActualStyleSheet; }
65 
66 	SfxStyleSheetBase*  GetTitleSheet(const String& rLayoutName);
67 
68 						// Caller muss Liste loeschen
69 	List*               CreateOutlineSheetList(const String& rLayoutName);
70 
71 	/** creates all layout style sheets for the givin layout name if they
72 		don't exist yet.
73 
74 		@param rLayoutName	Must be the name of a master page
75 		@param bCheck		If set to true, the debug version will assert if a style
76 							had to be created. This is used to assert errors in documents
77 							when styles are missing.
78 	*/
79 	SD_DLLPUBLIC void                CreateLayoutStyleSheets(const String& rLayoutName, sal_Bool bCheck = sal_False );
80 	List*               CreateLayoutSheetNames(const String& rLayoutName) const;
81 	void				CreateLayoutSheetList(const String& rLayoutName, SdStyleSheetVector& rLayoutSheets);
82 	void                CopyLayoutSheets(const String& rLayoutName, SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets );
83 	void                CopyGraphicSheets(SdStyleSheetPool& rSourcePool);
84 	void                CopyCellSheets(SdStyleSheetPool& rSourcePool);
85 	void                CopyTableStyles(SdStyleSheetPool& rSourcePool);
86 
87 	void                CreatePseudosIfNecessary();
88 	void				UpdateStdNames();
89 	static void			PutNumBulletItem( SfxStyleSheetBase* pSheet, Font& rBulletFont );
90 	Font                GetBulletFont() const;
91 
GetDoc() const92 	SdDrawDocument* 	GetDoc() const { return mpDoc; }
93 
94 	static 	SdStyleSheetVector CreateChildList( SdStyleSheet* pSheet );
95 
96 
97 public:
98 	void throwIfDisposed() throw(::com::sun::star::uno::RuntimeException);
99 
100     // XServiceInfo
101     virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
102     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
103     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
104 
105 	// XNameAccess
106     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
107     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException);
108     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
109 
110 	// XElementAccess
111     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
112     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
113 
114 	// XIndexAccess
115     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
116     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
117 
118 	// XComponent
119     virtual void SAL_CALL dispose(  ) throw (::com::sun::star::uno::RuntimeException);
120     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
121     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
122 
123 	virtual void SAL_CALL acquire (void) throw ();
124     virtual void SAL_CALL release (void) throw ();
125 protected:
126 	void CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily );
127 
128 	virtual SfxStyleSheetBase* Create(const String& rName, SfxStyleFamily eFamily, sal_uInt16 nMask);
129 	virtual SfxStyleSheetBase* Create(const SdStyleSheet& rStyle);
130 
131 	using  SfxStyleSheetPool::Create;
132 	virtual ~SdStyleSheetPool();
133 
134 	void AddStyleFamily( const SdPage* pPage );
135 	void RemoveStyleFamily( const SdPage* pPage );
136 
137 private:
138 	SfxStyleSheetBase*		mpActualStyleSheet;
139 	SdDrawDocument*			mpDoc;
140 	SdStyleFamilyRef		mxGraphicFamily;
141 	SdStyleFamilyRef		mxCellFamily;
142 	SdStyleFamilyMap		maStyleFamilyMap;
143 	::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxTableFamily;
144 	rtl::OUString			msTableFamilyName;
145 };
146 
147 #endif	   // _SD_STLPOOL_HXX
148