1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _XMLOFF_TOKENCONTEXT_HXX
21 #define _XMLOFF_TOKENCONTEXT_HXX
23 #include <xmloff/xmlictxt.hxx>
27 // forward declarations
30 namespace com
{ namespace sun
{ namespace star
{
31 namespace xml
{ namespace sax
{ class XAttributeList
; } }
32 namespace uno
{ template<typename T
> class Reference
; }
36 #define TOKEN_MAP_ENTRY(NAMESPACE,TOKEN) { XML_NAMESPACE_##NAMESPACE, xmloff::token::XML_##TOKEN, xmloff::token::XML_##TOKEN }
38 extern struct SvXMLTokenMapEntry aEmptyMap
[1];
40 /** handle attributes through an SvXMLTokenMap */
41 class TokenContext
: public SvXMLImportContext
44 const SvXMLTokenMapEntry
* mpAttributes
; /// static token map
45 const SvXMLTokenMapEntry
* mpChildren
; /// static token map
49 TokenContext( SvXMLImport
& rImport
,
51 const OUString
& rLocalName
,
52 const SvXMLTokenMapEntry
* pAttributes
= NULL
,
53 const SvXMLTokenMapEntry
* pChildren
= NULL
);
55 virtual ~TokenContext();
59 // implement SvXMLImportContext methods:
62 /** call HandleAttribute for each attribute in the token map;
63 * create a warning for all others. Classes that wish to override
64 * StartElement need to call the parent method. */
65 virtual void StartElement(
66 const com::sun::star::uno::Reference
<com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
68 /** call HandleChild for each child element in the token map;
69 * create a warning for all others. Classes that wish to override
70 * CreateChildCotnenxt may want to call the parent method for
71 * handling of defaults. */
72 virtual SvXMLImportContext
* CreateChildContext(
74 const OUString
& rLocalName
,
75 const com::sun::star::uno::Reference
<com::sun::star::xml::sax::XAttributeList
>& xAttrList
);
77 /** Create a warning for all non-namespace character
78 * content. Classes that wish to deal with character content have
79 * to overload this method anyway, and will thus get rid of the
81 virtual void Characters( const OUString
& rChars
);
84 /** will be called for each attribute */
85 virtual void HandleAttribute(
87 const OUString
& rValue
) = 0;
89 /** will be called for each child element */
90 virtual SvXMLImportContext
* HandleChild(
93 // the following attributes are mainly to be used for child
96 const OUString
& rLocalName
,
97 const com::sun::star::uno::Reference
<com::sun::star::xml::sax::XAttributeList
>& xAttrList
) = 0;
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */