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: elementparser.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 CONFIGMGR_XML_ELEMENTPARSER_HXX
32 #define CONFIGMGR_XML_ELEMENTPARSER_HXX
34 #include "elementinfo.hxx"
36 #include <com/sun/star/xml/sax/XAttributeList.hpp>
40 // -----------------------------------------------------------------------------
43 // -----------------------------------------------------------------------------
44 namespace uno
= ::com::sun::star::uno
;
45 namespace sax
= ::com::sun::star::xml::sax
;
47 // -----------------------------------------------------------------------------
54 rtl::OUString mMessage
;
56 BadValueType(rtl::OUString
const & aMessage
) : mMessage(aMessage
) {}
58 rtl::OUString
message() const { return mMessage
.getStr(); }
62 ElementParser(Logger
const & xLogger
)
66 Logger
const & logger() const { return mLogger
; }
68 /// reset the parser for a new document
72 /// retrieve the (almost) complete information for an element
73 ElementInfo
parseElementInfo(rtl::OUString
const& _sTag
, uno::Reference
< sax::XAttributeList
> const& _xAttribs
) const;
75 /// retrieve the node name for an element
76 ElementType::Enum
getNodeType(rtl::OUString
const& _sTag
, uno::Reference
< sax::XAttributeList
> const& xAttribs
) const;
78 /// retrieve the node name for an element
79 rtl::OUString
getName(rtl::OUString
const& _sTag
, uno::Reference
< sax::XAttributeList
> const& xAttribs
, ElementType::Enum eType
= ElementType::unknown
) const;
81 /// query whether the node has an operation
82 Operation::Enum
getOperation(uno::Reference
< sax::XAttributeList
> const& xAttribs
, ElementType::Enum _eType
) const;
84 /// retrieve the language (if any) stored in the attribute list
85 bool getLanguage(uno::Reference
< sax::XAttributeList
> const& xAttribs
, rtl::OUString
& _rsLanguage
) const;
87 /// reads attributes for nodes from the attribute list
88 sal_Int16
getNodeFlags(uno::Reference
< sax::XAttributeList
> const& xAttribs
, ElementType::Enum _eType
) const;
90 /// retrieve element type and associated module name of a set,
91 bool getSetElementType(uno::Reference
< sax::XAttributeList
> const& _xAttribs
, rtl::OUString
& _rsElementType
, rtl::OUString
& _rsElementTypeModule
) const;
93 /// retrieve the instance type and associated module name of a instance,
94 bool getInstanceType(uno::Reference
< sax::XAttributeList
> const& _xAttribs
, rtl::OUString
& _rsElementType
, rtl::OUString
& _rsElementTypeModule
) const;
96 /// retrieve the component for an import or uses element,
97 bool getImportComponent(uno::Reference
< sax::XAttributeList
> const& _xAttribs
, rtl::OUString
& _rsComponent
) const;
99 /// retrieve element type and associated module name of a set,
100 uno::Type
getPropertyValueType(uno::Reference
< sax::XAttributeList
> const& _xAttribs
) const;
101 // throw( BadValueType )
103 /// reads a value attribute from the attribute list
104 bool isNull(uno::Reference
< sax::XAttributeList
> const& _xAttribs
) const;
106 /// reads a value attribute from the attribute list
107 rtl::OUString
getSeparator(uno::Reference
< sax::XAttributeList
> const& _xAttribs
) const;
109 // low-level internal methods
111 /// checks for presence of a boolean attribute and assigns its value if it exists (and is a bool)
112 bool maybeGetAttribute(uno::Reference
< sax::XAttributeList
> const& _xAttribs
, rtl::OUString
const& _aAttributeName
, bool& _rbAttributeValue
) const;
114 /// checks for presence of an attribute and assigns its value if it exists
115 bool maybeGetAttribute(uno::Reference
< sax::XAttributeList
> const& _xAttribs
, rtl::OUString
const& _aAttributeName
, rtl::OUString
& _rsAttributeValue
) const;
117 // -----------------------------------------------------------------------------
119 // -----------------------------------------------------------------------------
121 // -----------------------------------------------------------------------------
122 } // namespace configmgr