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