xref: /aoo41x/main/xmloff/inc/xmloff/xmlaustp.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 _XMLOFF_XMLASTPLP_HXX
29 #define _XMLOFF_XMLASTPLP_HXX
30 
31 #include "sal/config.h"
32 #include "xmloff/dllapi.h"
33 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
34 #include <xmloff/xmlprmap.hxx>
35 #include <xmloff/uniref.hxx>
36 
37 class SvXMLExportPropertyMapper;
38 class SvXMLNamespaceMap;
39 class SvXMLAutoStylePoolP_Impl;
40 class SvXMLAttributeList;
41 class SvXMLExport;
42 namespace com { namespace sun { namespace star { namespace uno
43     { template<typename A> class Sequence; }
44 } } }
45 
46 class XMLOFF_DLLPUBLIC SvXMLAutoStylePoolP : public UniRefBase
47 {
48 	friend class SvXMLAutoStylePoolP_Impl;
49 
50 	SvXMLAutoStylePoolP_Impl	*pImpl;
51 
52 protected:
53 
54 	virtual void exportStyleAttributes(
55 			SvXMLAttributeList& rAttrList,
56 			sal_Int32 nFamily,
57 			const ::std::vector< XMLPropertyState >& rProperties,
58 			const SvXMLExportPropertyMapper& rPropExp
59 			, const SvXMLUnitConverter& rUnitConverter,
60 			const SvXMLNamespaceMap& rNamespaceMap
61             ) const;
62 
63 // this methode is executed after Properties Export, so you can e.g. export a map or so on
64 	virtual void exportStyleContent(
65 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
66 			sal_Int32 nFamily,
67 			const ::std::vector< XMLPropertyState >& rProperties,
68 			const SvXMLExportPropertyMapper& rPropExp
69 			, const SvXMLUnitConverter& rUnitConverter,
70 			const SvXMLNamespaceMap& rNamespaceMap
71             ) const;
72 
73 
74 public:
75 
76 	SvXMLAutoStylePoolP( SvXMLExport& rExport);
77 
78 	SvXMLAutoStylePoolP();
79 	virtual ~SvXMLAutoStylePoolP();
80 
81     SvXMLExport& GetExport() const;
82 
83 	/** register a new family with its appropriate instance of a derivation of XMLPropertySetMapper
84 		for family numbers see families.hxx
85 		if bAsFamily is sal_False, the family name is used as element name
86 	 */
87 	// TODO: Remove this ugly method as soon as possible
88 	void AddFamily( sal_Int32 nFamily, const ::rtl::OUString& rStrName, SvXMLExportPropertyMapper* pMapper, ::rtl::OUString aStrPrefix, sal_Bool bAsFamily = sal_True );
89 	void AddFamily( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
90 					const UniReference< SvXMLExportPropertyMapper >& rMapper,
91 					const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
92 
93 	/// Register a name that must not be used as a generated name.
94 	void RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName );
95 
96     /// retrieve the registered names (names + families)
97     void GetRegisteredNames(
98         com::sun::star::uno::Sequence<sal_Int32>& aFamilies,
99         com::sun::star::uno::Sequence<rtl::OUString>& aNames );
100 
101     /// register (families + names)
102     void RegisterNames(
103         com::sun::star::uno::Sequence<sal_Int32>& aFamilies,
104         com::sun::star::uno::Sequence<rtl::OUString>& aNames );
105 
106 	/// Add an item set to the pool and return its generated name.
107 	::rtl::OUString Add( sal_Int32 nFamily, const ::std::vector< XMLPropertyState >& rProperties );
108     ::rtl::OUString Add( sal_Int32 nFamily, const ::rtl::OUString& rParent, const ::std::vector< XMLPropertyState >& rProperties, bool bDontSeek = false );
109 	sal_Bool		Add( ::rtl::OUString& rName, sal_Int32 nFamily, const ::std::vector< XMLPropertyState >& rProperties );
110 	sal_Bool		Add( ::rtl::OUString& rName, sal_Int32 nFamily, const ::rtl::OUString& rParent, const ::std::vector< XMLPropertyState >& rProperties );
111 
112     /// Add an item set with a pre-defined name (needed for saving sheets separately in Calc).
113     sal_Bool        AddNamed( const ::rtl::OUString& rName, sal_Int32 nFamily, const ::rtl::OUString& rParent,
114                               const ::std::vector< XMLPropertyState >& rProperties );
115 
116 	/// Find an item set's name.
117 	::rtl::OUString Find( sal_Int32 nFamily, const ::std::vector< XMLPropertyState >& rProperties ) const;
118 	::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent, const ::std::vector< XMLPropertyState >& rProperties ) const;
119 
120 	// Add a property set to the pool and cache its name.
121 	::rtl::OUString AddAndCache( sal_Int32 nFamily, const ::std::vector< XMLPropertyState >& rProperties );
122 	::rtl::OUString AddAndCache( sal_Int32 nFamily, const ::rtl::OUString& rParent, const ::std::vector< XMLPropertyState >& rProperties );
123 	::rtl::OUString AddAndCache( sal_Int32 nFamily, const ::rtl::OUString& rParent );
124 
125 	::rtl::OUString FindAndRemoveCached( sal_Int32 nFamily ) const;
126 
127 	/** Export all item sets ofs a certain class in the order in that they have been added. */
128 	void exportXML( sal_Int32 nFamily
129 		, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
130 		const SvXMLUnitConverter& rUnitConverter,
131 		const SvXMLNamespaceMap& rNamespaceMap
132         ) const;
133 
134 	void ClearEntries();
135 };
136 
137 #endif	//  _XMLOFF_XMLASTPLP_HXX
138