xref: /trunk/main/desktop/source/migration/cfgfilter.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
93     // XLayer
94     virtual void SAL_CALL readData(
95         const NS_UNO::Reference< NS_CSS::configuration::backend::XLayerHandler >& layerHandler);
96 
97     // XLayerHandler
98     virtual void SAL_CALL startLayer();
99 
100     virtual void SAL_CALL endLayer();
101 
102     virtual void SAL_CALL overrideNode(
103             const rtl::OUString& aName,
104             sal_Int16 aAttributes,
105             sal_Bool bClear);
106 
107     virtual void SAL_CALL addOrReplaceNode(
108             const rtl::OUString& aName,
109             sal_Int16 aAttributes);
110 
111     virtual void SAL_CALL  addOrReplaceNodeFromTemplate(
112             const rtl::OUString& aName,
113             const NS_CSS::configuration::backend::TemplateIdentifier& aTemplate,
114             sal_Int16 aAttributes );
115 
116     virtual void SAL_CALL  endNode();
117 
118     virtual void SAL_CALL  dropNode(
119             const rtl::OUString& aName );
120 
121     virtual void SAL_CALL  overrideProperty(
122             const rtl::OUString& aName,
123             sal_Int16 aAttributes,
124             const NS_UNO::Type& aType,
125             sal_Bool bClear );
126 
127     virtual void SAL_CALL  setPropertyValue(
128             const NS_UNO::Any& aValue );
129 
130     virtual void SAL_CALL setPropertyValueForLocale(
131             const NS_UNO::Any& aValue,
132             const rtl::OUString& aLocale );
133 
134     virtual void SAL_CALL  endProperty();
135 
136     virtual void SAL_CALL  addProperty(
137             const rtl::OUString& aName,
138             sal_Int16 aAttributes,
139             const NS_UNO::Type& aType );
140 
141     virtual void SAL_CALL  addPropertyWithValue(
142             const rtl::OUString& aName,
143             sal_Int16 aAttributes,
144             const NS_UNO::Any& aValue );
145 
146 };
147 
148 } // namespace desktop
149 #undef NS_CSS
150 #undef NS_UNO
151 
152 #endif
153