xref: /trunk/main/xmloff/source/transform/PersAttrListTContext.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_PERSATTRLISTTCONTEXT_HXX
29 #define _XMLOFF_PERSATTRLISTTCONTEXT_HXX
30 
31 #include <xmloff/xmltoken.hxx>
32 #include "TransformerContext.hxx"
33 
34 
35 class XMLPersAttrListTContext : public XMLTransformerContext
36 {
37 
38     ::com::sun::star::uno::Reference<
39         ::com::sun::star::xml::sax::XAttributeList > m_xAttrList;
40     ::rtl::OUString m_aElemQName;
41     sal_uInt16 m_nActionMap;
42 
43 protected:
44 
45     void SetExportQName( const ::rtl::OUString& r ) { m_aElemQName = r; }
46 
47 public:
48     TYPEINFO();
49 
50     // A contexts constructor does anything that is required if an element
51     // starts. Namespace processing has been done already.
52     // Note that virtual methods cannot be used inside constructors. Use
53     // StartElement instead if this is required.
54     XMLPersAttrListTContext( XMLTransformerBase& rTransformer,
55                            const ::rtl::OUString& rQName );
56 
57     // attr list persistence + attribute processing
58     XMLPersAttrListTContext( XMLTransformerBase& rTransformer,
59                            const ::rtl::OUString& rQName,
60                            sal_uInt16 nActionMap );
61 
62     // attr list persistence + renaming
63     XMLPersAttrListTContext( XMLTransformerBase& rTransformer,
64                            const ::rtl::OUString& rQName,
65                            sal_uInt16 nPrefix,
66                            ::xmloff::token::XMLTokenEnum eToken );
67 
68     // attr list persistence + renaming + attribute processing
69     XMLPersAttrListTContext( XMLTransformerBase& rTransformer,
70                            const ::rtl::OUString& rQName,
71                            sal_uInt16 nPrefix,
72                            ::xmloff::token::XMLTokenEnum eToken,
73                            sal_uInt16 nActionMap );
74 
75     // A contexts destructor does anything that is required if an element
76     // ends. By default, nothing is done.
77     // Note that virtual methods cannot be used inside destructors. Use
78     // EndElement instead if this is required.
79     virtual ~XMLPersAttrListTContext();
80 
81     // Create a childs element context. By default, the import's
82     // CreateContext method is called to create a new default context.
83     virtual XMLTransformerContext *CreateChildContext( sal_uInt16 nPrefix,
84                                    const ::rtl::OUString& rLocalName,
85                                    const ::rtl::OUString& rQName,
86                                    const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
87 
88     // StartElement is called after a context has been constructed and
89     // before a elements context is parsed. It may be used for actions that
90     // require virtual methods. The default is to do nothing.
91     virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
92 
93     // EndElement is called before a context will be destructed, but
94     // after a elements context has been parsed. It may be used for actions
95     // that require virtual methods. The default is to do nothing.
96     virtual void EndElement();
97 
98     // This method is called for all characters that are contained in the
99     // current element.
100     virtual void Characters( const ::rtl::OUString& rChars );
101 
102     virtual sal_Bool IsPersistent() const;
103     virtual void Export();
104     virtual void ExportContent();
105 
106     const ::rtl::OUString& GetExportQName() const { return m_aElemQName; }
107 
108     void AddAttribute( sal_uInt16 nAPrefix,
109         ::xmloff::token::XMLTokenEnum eAToken,
110         ::xmloff::token::XMLTokenEnum eVToken );
111 
112     void AddAttribute( sal_uInt16 nAPrefix,
113         ::xmloff::token::XMLTokenEnum eAToken,
114         const ::rtl::OUString & rValue );
115 
116     ::com::sun::star::uno::Reference<
117         ::com::sun::star::xml::sax::XAttributeList >
118         GetAttrList() const;
119 };
120 
121 #endif  //  _XMLOFF_PERSATTRLISTTCONTEXT_HXX
122 
123