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: layermerge.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_BACKEND_LAYERMERGE_HXX
32 #define CONFIGMGR_BACKEND_LAYERMERGE_HXX
34 #include "mergedcomponentdata.hxx"
35 #include "componentdatahelper.hxx"
36 #include <com/sun/star/configuration/backend/XLayerHandler.hpp>
37 #include <cppuhelper/implbase1.hxx>
38 #include <com/sun/star/uno/XComponentContext.hpp>
42 // -----------------------------------------------------------------------------
43 class OTreeNodeFactory
;
44 // -----------------------------------------------------------------------------
47 // -----------------------------------------------------------------------------
48 namespace uno
= ::com::sun::star::uno
;
49 namespace lang
= ::com::sun::star::lang
;
51 namespace backenduno
= ::com::sun::star::configuration::backend
;
52 // -----------------------------------------------------------------------------
54 class LayerMergeHandler
55 : public cppu::WeakImplHelper1
<backenduno::XLayerHandler
>
59 LayerMergeHandler(uno::Reference
< uno::XComponentContext
> const & _xContext
, MergedComponentData
& _rData
, ITemplateDataProvider
* aTemplateProvider
= NULL
);
60 virtual ~LayerMergeHandler();
64 bool prepareSublayer(rtl::OUString
const & aLocale
);
66 // checking the result
67 bool isDone() const { return m_aContext
.isDone(); }
68 bool isInSublayer() const { return m_bSublayer
; }
74 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
78 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
81 overrideNode( const rtl::OUString
& aName
, sal_Int16 aAttributes
, sal_Bool bClear
)
82 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
85 addOrReplaceNode( const rtl::OUString
& aName
, sal_Int16 aAttributes
)
86 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
89 addOrReplaceNodeFromTemplate( const rtl::OUString
& aName
, const backenduno::TemplateIdentifier
& aTemplate
, sal_Int16 aAttributes
)
90 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
94 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
97 dropNode( const rtl::OUString
& aName
)
98 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
100 virtual void SAL_CALL
101 overrideProperty( const rtl::OUString
& aName
, sal_Int16 aAttributes
, const uno::Type
& aType
, sal_Bool bClear
)
102 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
104 virtual void SAL_CALL
105 addProperty( const rtl::OUString
& aName
, sal_Int16 aAttributes
, const uno::Type
& aType
)
106 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
108 virtual void SAL_CALL
109 addPropertyWithValue( const rtl::OUString
& aName
, sal_Int16 aAttributes
, const uno::Any
& aValue
)
110 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
112 virtual void SAL_CALL
114 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
116 virtual void SAL_CALL
117 setPropertyValue( const uno::Any
& aValue
)
118 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
120 virtual void SAL_CALL
121 setPropertyValueForLocale( const uno::Any
& aValue
, const rtl::OUString
& aLocale
)
122 throw (backenduno::MalformedDataException
, lang::WrappedTargetException
, uno::RuntimeException
);
125 void propagateAttributes(ISubtree
& _rParent
);
127 node::Attributes
makePropertyAttributes(sal_Int16 aSchemaAttributes
)
128 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
130 void checkPropertyType(uno::Type
const & _aType
)
131 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
133 void applyPropertyValue(uno::Any
const & _aValue
)
134 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
136 void applyPropertyValue(uno::Any
const & _aValue
, rtl::OUString
const & _aLocale
)
137 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
139 void applyAttributes(INode
* pNode
, sal_Int16 aNodeAttributes
)
140 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
142 void overrideLayerRoot( const rtl::OUString
& aName
, sal_Int16 aAttributes
, sal_Bool bClear
)
143 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
145 bool startOverride(INode
* pNode
, sal_Bool bClear
) /* check if writable, mark merged */
148 void implOverrideNode(
149 ISubtree
* node
, sal_Int16 attributes
, bool clear
);
151 void implAddOrReplaceNode(const rtl::OUString
& aName
, const backenduno::TemplateIdentifier
& aTemplate
, sal_Int16 aAttributes
)
152 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
154 void ensureUnchanged(INode
const * pNode
) const
155 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
157 void setLocalizedValue(ISubtree
* pProperty
, uno::Any
const & _aValue
, rtl::OUString
const & _aLocale
)
158 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
160 void setValueAndCheck(ValueNode
& _rValueNode
, uno::Any
const & _aValue
)
161 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException
, com::sun::star::uno::RuntimeException
));
163 void skipNode() { ++m_nSkipping
; }
164 bool isSkipping() const { return m_nSkipping
!= 0; }
165 bool leaveSkippedNode() { return m_nSkipping
&& m_nSkipping
--; }
168 MergedComponentData
& m_rData
;
169 DataBuilderContext m_aContext
;
170 ComponentDataFactory m_aFactory
;
171 rtl::OUString m_aLocale
;
173 Converter
* m_pConverter
;
175 sal_uInt32 m_nSkipping
;
178 // -----------------------------------------------------------------------------
180 /// change attributes and states of the tree to make it a proper default layer
181 void promoteToDefault(MergedComponentData
& _rTree
);
182 // -----------------------------------------------------------------------------
183 } // namespace backend
184 // -----------------------------------------------------------------------------
186 } // namespace configmgr