update dev300-m58
[ooovba.git] / configmgr / source / xml / layerwriter.hxx
blobf05c0041464ad70ecaa0647ff730d11d595a313c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: layerwriter.hxx,v $
10 * $Revision: 1.13 $
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_LAYERWRITER_HXX
32 #define CONFIGMGR_XML_LAYERWRITER_HXX
34 #include "writersvc.hxx"
35 #include "elementformatter.hxx"
36 #include "stack.hxx"
37 #include <com/sun/star/configuration/backend/XLayerHandler.hpp>
39 namespace com { namespace sun { namespace star { namespace script {
40 class XTypeConverter;
41 } } } }
43 namespace configmgr
45 // -----------------------------------------------------------------------------
46 namespace xml
48 // -----------------------------------------------------------------------------
49 namespace uno = ::com::sun::star::uno;
50 namespace lang = ::com::sun::star::lang;
52 namespace sax = ::com::sun::star::xml::sax;
53 namespace backenduno = ::com::sun::star::configuration::backend;
55 // -----------------------------------------------------------------------------
58 class LayerWriter : public WriterService< ::com::sun::star::configuration::backend::XLayerHandler >
60 public:
61 explicit
62 LayerWriter(uno::Reference< uno::XComponentContext > const & _xContext);
63 virtual ~LayerWriter();
65 // XLayerHandler
66 public:
67 virtual void SAL_CALL
68 startLayer( )
69 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
70 uno::RuntimeException);
72 virtual void SAL_CALL
73 endLayer( )
74 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
75 uno::RuntimeException);
77 virtual void SAL_CALL
78 overrideNode( const rtl::OUString& aName, sal_Int16 aAttributes, sal_Bool bClear )
79 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
80 uno::RuntimeException);
82 virtual void SAL_CALL
83 addOrReplaceNode( const rtl::OUString& aName, sal_Int16 aAttributes )
84 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
85 uno::RuntimeException);
87 virtual void SAL_CALL
88 addOrReplaceNodeFromTemplate( const rtl::OUString& aName, const backenduno::TemplateIdentifier& aTemplate, sal_Int16 aAttributes )
89 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
90 uno::RuntimeException);
92 virtual void SAL_CALL
93 endNode( )
94 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
95 uno::RuntimeException);
97 virtual void SAL_CALL
98 dropNode( const rtl::OUString& aName )
99 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
100 uno::RuntimeException);
102 virtual void SAL_CALL
103 overrideProperty( const rtl::OUString& aName, sal_Int16 aAttributes, const uno::Type& aType, sal_Bool bClear )
104 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
105 uno::RuntimeException);
107 virtual void SAL_CALL
108 addProperty( const rtl::OUString& aName, sal_Int16 aAttributes, const uno::Type& aType )
109 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
110 uno::RuntimeException);
112 virtual void SAL_CALL
113 addPropertyWithValue( const rtl::OUString& aName, sal_Int16 aAttributes, const uno::Any& aValue )
114 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
115 uno::RuntimeException);
117 virtual void SAL_CALL
118 endProperty( )
119 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
120 uno::RuntimeException);
122 virtual void SAL_CALL
123 setPropertyValue( const uno::Any& aValue )
124 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
125 uno::RuntimeException);
127 virtual void SAL_CALL
128 setPropertyValueForLocale( const uno::Any& aValue, const rtl::OUString& aLocale )
129 throw (backenduno::MalformedDataException, lang::WrappedTargetException,
130 uno::RuntimeException);
132 private:
133 bool isInElement() const;
134 void checkInElement(bool bInElement, bool bInProperty = false);
136 void startNode();
137 void startProp(uno::Type const & _aType, bool bNeedType);
139 void endElement();
141 void writeValue(uno::Any const & _aValue);
142 void writeValue(uno::Any const & _aValue, rtl::OUString const & _aLocale);
144 void outputValue(uno::Any const & _aValue);
146 void raiseMalformedDataException(sal_Char const * pMsg);
147 void raiseIllegalTypeException(sal_Char const * pMsg);
149 void prepareAddOrReplaceElement(
150 rtl::OUString const & name, sal_Int16 attributes);
152 private:
153 uno::Reference< com::sun::star::script::XTypeConverter > m_xTCV;
154 Stack< rtl::OUString > m_aTagStack;
155 ElementFormatter m_aFormatter;
156 uno::Type m_aPropertyType;
157 bool m_bInProperty;
158 bool m_bStartedDocument;
160 // -----------------------------------------------------------------------------
161 } // namespace xml
162 // -----------------------------------------------------------------------------
164 } // namespace configmgr
165 #endif