xref: /aoo41x/main/sd/inc/stlpool.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SD_STLPOOL_HXX
29 #define _SD_STLPOOL_HXX
30 
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/container/XIndexAccess.hpp>
33 #include <com/sun/star/container/XNameContainer.hpp>
34 #include <com/sun/star/container/XNamed.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/lang/XComponent.hpp>
37 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 
39 #include <cppuhelper/implbase4.hxx>
40 #include <cppuhelper/implbase7.hxx>
41 #include <map>
42 #include <vector>
43 
44 #include <stlfamily.hxx>
45 #include <stlsheet.hxx>
46 
47 #include <sddllapi.h>
48 
49 class SdStyleSheet;
50 class SdDrawDocument;
51 class SdPage;
52 
53 typedef std::map< const SdPage*, SdStyleFamilyRef > SdStyleFamilyMap;
54 
55 typedef ::cppu::ImplInheritanceHelper4< SfxStyleSheetPool,
56 										::com::sun::star::lang::XServiceInfo,
57 										::com::sun::star::container::XIndexAccess,
58 										::com::sun::star::container::XNameAccess,
59 										::com::sun::star::lang::XComponent > SdStyleSheetPoolBase;
60 
61 class SdStyleSheetPool : public SdStyleSheetPoolBase, public SfxListener
62 {
63     friend class SdDrawDocument;
64 public:
65 						SdStyleSheetPool(SfxItemPool const& rPool, SdDrawDocument* pDocument);
66 
67 	void				SetActualStyleSheet(SfxStyleSheetBase* pActStyleSheet)	{ mpActualStyleSheet = pActStyleSheet; }
68 	SfxStyleSheetBase*	GetActualStyleSheet()									{ return mpActualStyleSheet; }
69 
70 	SfxStyleSheetBase*  GetTitleSheet(const String& rLayoutName);
71 
72 						// Caller muss Liste loeschen
73 	List*               CreateOutlineSheetList(const String& rLayoutName);
74 
75 	/** creates all layout style sheets for the givin layout name if they
76 		don't exist yet.
77 
78 		@param rLayoutName	Must be the name of a master page
79 		@param bCheck		If set to true, the debug version will assert if a style
80 							had to be created. This is used to assert errors in documents
81 							when styles are missing.
82 	*/
83 	SD_DLLPUBLIC void                CreateLayoutStyleSheets(const String& rLayoutName, sal_Bool bCheck = sal_False );
84 	List*               CreateLayoutSheetNames(const String& rLayoutName) const;
85 	void				CreateLayoutSheetList(const String& rLayoutName, SdStyleSheetVector& rLayoutSheets);
86 	void                CopyLayoutSheets(const String& rLayoutName, SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets );
87 	void                CopyGraphicSheets(SdStyleSheetPool& rSourcePool);
88 	void                CopyCellSheets(SdStyleSheetPool& rSourcePool);
89 	void                CopyTableStyles(SdStyleSheetPool& rSourcePool);
90 
91 	void                CreatePseudosIfNecessary();
92 	void				UpdateStdNames();
93 	static void			PutNumBulletItem( SfxStyleSheetBase* pSheet, Font& rBulletFont );
94 	Font                GetBulletFont() const;
95 
96 	SdDrawDocument* 	GetDoc() const { return mpDoc; }
97 
98 	static 	SdStyleSheetVector CreateChildList( SdStyleSheet* pSheet );
99 
100 
101 public:
102 	void throwIfDisposed() throw(::com::sun::star::uno::RuntimeException);
103 
104     // XServiceInfo
105     virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
106     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
107     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
108 
109 	// XNameAccess
110     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);
111     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException);
112     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
113 
114 	// XElementAccess
115     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
116     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
117 
118 	// XIndexAccess
119     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
120     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);
121 
122 	// XComponent
123     virtual void SAL_CALL dispose(  ) throw (::com::sun::star::uno::RuntimeException);
124     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
125     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
126 
127 	virtual void SAL_CALL acquire (void) throw ();
128     virtual void SAL_CALL release (void) throw ();
129 protected:
130 	void CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily );
131 
132 	virtual SfxStyleSheetBase* Create(const String& rName, SfxStyleFamily eFamily, sal_uInt16 nMask);
133 	virtual SfxStyleSheetBase* Create(const SdStyleSheet& rStyle);
134 
135 	using  SfxStyleSheetPool::Create;
136 	virtual ~SdStyleSheetPool();
137 
138 	void AddStyleFamily( const SdPage* pPage );
139 	void RemoveStyleFamily( const SdPage* pPage );
140 
141 private:
142 	SfxStyleSheetBase*		mpActualStyleSheet;
143 	SdDrawDocument*			mpDoc;
144 	SdStyleFamilyRef		mxGraphicFamily;
145 	SdStyleFamilyRef		mxCellFamily;
146 	SdStyleFamilyMap		maStyleFamilyMap;
147 	::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxTableFamily;
148 	rtl::OUString			msTableFamilyName;
149 };
150 
151 #endif	   // _SD_STLPOOL_HXX
152