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: TokenContext.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_TOKENCONTEXT_HXX
32 #define _XMLOFF_TOKENCONTEXT_HXX
36 // include for parent class and members
39 #include <xmloff/xmlictxt.hxx>
43 // forward declarations
46 namespace com
{ namespace sun
{ namespace star
{
47 namespace xml
{ namespace sax
{ class XAttributeList
; } }
48 namespace uno
{ template<typename T
> class Reference
; }
50 namespace rtl
{ class OUString
; }
53 #define TOKEN_MAP_ENTRY(NAMESPACE,TOKEN) { XML_NAMESPACE_##NAMESPACE, xmloff::token::XML_##TOKEN, xmloff::token::XML_##TOKEN }
55 extern struct SvXMLTokenMapEntry aEmptyMap
[1];
57 /** handle attributes through an SvXMLTokenMap */
58 class TokenContext
: public SvXMLImportContext
61 const SvXMLTokenMapEntry
* mpAttributes
; /// static token map
62 const SvXMLTokenMapEntry
* mpChildren
; /// static token map
66 TokenContext( SvXMLImport
& rImport
,
68 const ::rtl::OUString
& rLocalName
,
69 const SvXMLTokenMapEntry
* pAttributes
= NULL
,
70 const SvXMLTokenMapEntry
* pChildren
= NULL
);
72 virtual ~TokenContext();
76 // implement SvXMLImportContext methods:
79 /** call HandleAttribute for each attribute in the token map;
80 * create a warning for all others. Classes that wish to override
81 * StartElement need to call the parent method. */
82 virtual void StartElement(
83 const com::sun::star::uno::Reference
<com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
85 /** call HandleChild for each child element in the token map;
86 * create a warning for all others. Classes that wish to override
87 * CreateChildCotnenxt may want to call the parent method for
88 * handling of defaults. */
89 virtual SvXMLImportContext
* CreateChildContext(
91 const rtl::OUString
& rLocalName
,
92 const com::sun::star::uno::Reference
<com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
94 /** Create a warning for all non-namespace character
95 * content. Classes that wish to deal with character content have
96 * to overload this method anyway, and will thus get rid of the
98 virtual void Characters( const ::rtl::OUString
& rChars
);
101 /** will be called for each attribute */
102 virtual void HandleAttribute(
104 const rtl::OUString
& rValue
) = 0;
106 /** will be called for each child element */
107 virtual SvXMLImportContext
* HandleChild(
110 // the following attributes are mainly to be used for child
113 const rtl::OUString
& rLocalName
,
114 const com::sun::star::uno::Reference
<com::sun::star::xml::sax::XAttributeList
>& xAttrList
) = 0;