1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef _DESKTOP_CFGFILTER_HXX_
23 #define _DESKTOP_CFGFILTER_HXX_
24 
25 #include <stack>
26 
27 #include <sal/types.h>
28 #include <rtl/ustring.hxx>
29 
30 #include <cppuhelper/implbase2.hxx>
31 #include <cppuhelper/implbase3.hxx>
32 
33 #include <com/sun/star/uno/Reference.hxx>
34 #include <com/sun/star/uno/Any.hxx>
35 #include <com/sun/star/uno/Type.hxx>
36 
37 #include <com/sun/star/lang/XInitialization.hpp>
38 #include <com/sun/star/configuration/backend/XLayer.hpp>
39 #include <com/sun/star/configuration/backend/XLayerHandler.hpp>
40 #include <com/sun/star/configuration/backend/TemplateIdentifier.hpp>
41 
42 
43 #include "migration_impl.hxx"
44 
45 #define NS_CSS com::sun::star
46 #define NS_UNO com::sun::star::uno
47 
48 
49 namespace desktop {
50 
51 struct element
52 {
53     rtl::OUString name;
54     rtl::OUString path;
55     sal_Bool use;
56 
57 };
58 
59 typedef std::stack< element > element_stack;
60 
61 // XInitialization:
62 //  -> Source : XLayer
63 // XLayer
64 // XLayerHandler
65 class CConfigFilter : public cppu::WeakImplHelper3<
66     NS_CSS::configuration::backend::XLayer,
67     NS_CSS::configuration::backend::XLayerHandler,
68     NS_CSS::lang::XInitialization>
69 {
70 
71 private:
72     NS_UNO::Reference< NS_CSS::configuration::backend::XLayerHandler > m_xLayerHandler;
73     NS_UNO::Reference< NS_CSS::configuration::backend::XLayer > m_xSourceLayer;
74 
75     rtl::OUString m_aCurrentComponent;
76 
77     const strings_v *m_pvInclude;
78     const strings_v *m_pvExclude;
79 
80     element_stack m_elementStack;
81 
82     void pushElement(rtl::OUString aName, sal_Bool bUse = sal_True);
83     void popElement();
84     sal_Bool checkElement(rtl::OUString aName);
85     sal_Bool checkCurrentElement();
86 
87 public:
88     CConfigFilter(const strings_v* include,  const strings_v* exclude);
89 
90     // XInitialization
91     virtual void SAL_CALL initialize(const NS_UNO::Sequence< NS_UNO::Any >& seqArgs)
92         throw (NS_UNO::Exception);
93 
94     // XLayer
95     virtual void SAL_CALL readData(
96         const NS_UNO::Reference< NS_CSS::configuration::backend::XLayerHandler >& layerHandler)
97         throw (NS_CSS::lang::NullPointerException, NS_CSS::lang::WrappedTargetException,
98                NS_CSS::configuration::backend::MalformedDataException);
99 
100     // XLayerHandler
101     virtual void SAL_CALL startLayer()
102         throw(::com::sun::star::lang::WrappedTargetException);
103 
104     virtual void SAL_CALL endLayer()
105         throw(
106             ::com::sun::star::configuration::backend::MalformedDataException,
107             ::com::sun::star::lang::WrappedTargetException );
108 
109     virtual void SAL_CALL overrideNode(
110             const rtl::OUString& aName,
111             sal_Int16 aAttributes,
112             sal_Bool bClear)
113         throw(
114             ::com::sun::star::configuration::backend::MalformedDataException,
115             ::com::sun::star::lang::WrappedTargetException );
116 
117     virtual void SAL_CALL addOrReplaceNode(
118             const rtl::OUString& aName,
119             sal_Int16 aAttributes)
120         throw(
121             ::com::sun::star::configuration::backend::MalformedDataException,
122             ::com::sun::star::lang::WrappedTargetException );
123 
124     virtual void SAL_CALL  addOrReplaceNodeFromTemplate(
125             const rtl::OUString& aName,
126             const NS_CSS::configuration::backend::TemplateIdentifier& aTemplate,
127             sal_Int16 aAttributes )
128         throw(
129             ::com::sun::star::configuration::backend::MalformedDataException,
130             ::com::sun::star::lang::WrappedTargetException );
131 
132     virtual void SAL_CALL  endNode()
133         throw(
134             ::com::sun::star::configuration::backend::MalformedDataException,
135             ::com::sun::star::lang::WrappedTargetException );
136 
137     virtual void SAL_CALL  dropNode(
138             const rtl::OUString& aName )
139         throw(
140             ::com::sun::star::configuration::backend::MalformedDataException,
141             ::com::sun::star::lang::WrappedTargetException );
142 
143     virtual void SAL_CALL  overrideProperty(
144             const rtl::OUString& aName,
145             sal_Int16 aAttributes,
146             const NS_UNO::Type& aType,
147             sal_Bool bClear )
148         throw(
149             ::com::sun::star::configuration::backend::MalformedDataException,
150             ::com::sun::star::lang::WrappedTargetException );
151 
152     virtual void SAL_CALL  setPropertyValue(
153             const NS_UNO::Any& aValue )
154         throw(
155             ::com::sun::star::configuration::backend::MalformedDataException,
156             ::com::sun::star::lang::WrappedTargetException );
157 
158     virtual void SAL_CALL setPropertyValueForLocale(
159             const NS_UNO::Any& aValue,
160             const rtl::OUString& aLocale )
161         throw(
162             ::com::sun::star::configuration::backend::MalformedDataException,
163             ::com::sun::star::lang::WrappedTargetException );
164 
165     virtual void SAL_CALL  endProperty()
166         throw(
167             ::com::sun::star::configuration::backend::MalformedDataException,
168             ::com::sun::star::lang::WrappedTargetException );
169 
170     virtual void SAL_CALL  addProperty(
171             const rtl::OUString& aName,
172             sal_Int16 aAttributes,
173             const NS_UNO::Type& aType )
174         throw(
175             ::com::sun::star::configuration::backend::MalformedDataException,
176             ::com::sun::star::lang::WrappedTargetException );
177 
178     virtual void SAL_CALL  addPropertyWithValue(
179             const rtl::OUString& aName,
180             sal_Int16 aAttributes,
181             const NS_UNO::Any& aValue )
182         throw(
183             ::com::sun::star::configuration::backend::MalformedDataException,
184             ::com::sun::star::lang::WrappedTargetException );
185 
186 };
187 
188 } // namespace desktop
189 #undef NS_CSS
190 #undef NS_UNO
191 
192 #endif
193 
194 
195