1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TransformerContext.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_TRANSFORMERCONTEXT_HXX
32 #define _XMLOFF_TRANSFORMERCONTEXT_HXX
34 #include <com/sun/star/xml/sax/XAttributeList.hpp>
35 #include <tools/solar.h>
36 #include <salhelper/simplereferenceobject.hxx>
37 #include <rtl/ustring.hxx>
38 #include <tools/rtti.hxx>
39 #include <xmloff/xmltoken.hxx>
41 class SvXMLNamespaceMap
;
42 class XMLTransformerBase
;
44 class XMLTransformerContext
: public ::salhelper::SimpleReferenceObject
46 friend class XMLTransformerBase
;
48 XMLTransformerBase
& m_rTransformer
;
50 ::rtl::OUString m_aQName
;
52 SvXMLNamespaceMap
*m_pRewindMap
;
54 SvXMLNamespaceMap
*GetRewindMap() const { return m_pRewindMap
; }
55 void SetRewindMap( SvXMLNamespaceMap
*p
) { m_pRewindMap
= p
; }
59 XMLTransformerBase
& GetTransformer() { return m_rTransformer
; }
60 const XMLTransformerBase
& GetTransformer() const { return m_rTransformer
; }
62 void SetQName( const ::rtl::OUString
& rQName
) { m_aQName
= rQName
; }
67 const ::rtl::OUString
& GetQName() const { return m_aQName
; }
68 sal_Bool
HasQName( sal_uInt16 nPrefix
,
69 ::xmloff::token::XMLTokenEnum eToken
) const;
70 sal_Bool
HasNamespace( sal_uInt16 nPrefix
) const;
72 // A contexts constructor does anything that is required if an element
73 // starts. Namespace processing has been done already.
74 // Note that virtual methods cannot be used inside constructors. Use
75 // StartElement instead if this is required.
76 XMLTransformerContext( XMLTransformerBase
& rTransformer
,
77 const ::rtl::OUString
& rQName
);
79 // A contexts destructor does anything that is required if an element
80 // ends. By default, nothing is done.
81 // Note that virtual methods cannot be used inside destructors. Use
82 // EndElement instead if this is required.
83 virtual ~XMLTransformerContext();
85 // Create a childs element context. By default, the import's
86 // CreateContext method is called to create a new default context.
87 virtual XMLTransformerContext
*CreateChildContext( sal_uInt16 nPrefix
,
88 const ::rtl::OUString
& rLocalName
,
89 const ::rtl::OUString
& rQName
,
90 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
92 // StartElement is called after a context has been constructed and
93 // before a elements context is parsed. It may be used for actions that
94 // require virtual methods. The default is to do nothing.
95 virtual void StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
97 // EndElement is called before a context will be destructed, but
98 // after a elements context has been parsed. It may be used for actions
99 // that require virtual methods. The default is to do nothing.
100 virtual void EndElement();
102 // This method is called for all characters that are contained in the
103 // current element. The default is to ignore them.
104 virtual void Characters( const ::rtl::OUString
& rChars
);
106 // Is the current context a persistent one (i.e. one that saves is content
107 // rather than exporting it directly?
108 virtual sal_Bool
IsPersistent() const;
110 // Export the whole element. By default, nothing is done here
111 virtual void Export();
113 // Export the element content. By default, nothing is done here
114 virtual void ExportContent();
118 #endif // _XMLOFF_TRANSFORMERCONTEXT_HXX