merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / framework / configuration / ConfigurationClassifier.hxx
blob59e8d0ec227a3471e00a4f3183aae7abb00698d0
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: ConfigurationClassifier.hxx,v $
10 * $Revision: 1.3 $
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 SD_FRAMEWORK_CONFIGURATION_CLASSIFIER_HXX
32 #define SD_FRAMEWORK_CONFIGURATION_CLASSIFIER_HXX
34 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
36 #include <vector>
38 namespace sd { namespace framework {
40 /** A ConfigurationClassifier object compares two configurations of
41 resources and gives access to the differences. It is used mainly when
42 changes to the current configuration have been requested and the various
43 resource controllers have to be supplied with the set of resources that
44 are to be activated or deactivated.
46 class ConfigurationClassifier
48 public:
49 /** Create a new ConfigurationClassifier object that will compare the
50 two given configurations.
52 ConfigurationClassifier (
53 const ::com::sun::star::uno::Reference<
54 ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration1,
55 const ::com::sun::star::uno::Reference<
56 ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration2);
58 /** Calculate three lists of resource ids. These contain the resources
59 that belong to one configuration but not the other, or that belong
60 to both configurations.
61 @return
62 When the two configurations differ then return <TRUE/>. When
63 they are equivalent then return <FALSE/>.
65 bool Partition (void);
67 typedef ::std::vector<com::sun::star::uno::Reference<
68 ::com::sun::star::drawing::framework::XResourceId> > ResourceIdVector;
70 /** Return the resources that belong to the configuration given as
71 rxConfiguration1 to the constructor but that do not belong to
72 rxConfiguration2.
73 @return
74 A reference to the, possibly empty, list of resources is
75 returned. This reference remains valid as long as the called
76 ConfigurationClassifier object stays alive.
78 const ResourceIdVector& GetC1minusC2 (void) const;
80 /** Return the resources that belong to the configuration given as
81 rxConfiguration2 to the constructor but that do not belong to
82 rxConfiguration1.
83 @return
84 A reference to the, possibly empty, list of resources is
85 returned. This reference remains valid as long as the called
86 ConfigurationClassifier object stays alive.
88 const ResourceIdVector& GetC2minusC1 (void) const;
90 /** Return the resources that belong to both the configurations that
91 where given to the constructor.
92 @return
93 A reference to the, possibly empty, list of resources is
94 returned. This reference remains valid as long as the called
95 ConfigurationClassifier object stays alive.
97 const ResourceIdVector& GetC1andC2 (void) const;
99 void TraceResourceIdVector (
100 const sal_Char* pMessage,
101 const ResourceIdVector& rResources) const;
103 private:
104 ::com::sun::star::uno::Reference<
105 ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration1;
106 ::com::sun::star::uno::Reference<
107 ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration2;
109 /** After the call to Classify() this vector holds all elements from
110 mxConfiguration1 that are not in mxConfiguration2.
112 ResourceIdVector maC1minusC2;
114 /** After the call to Classify() this vector holds all elements from
115 mxConfiguration2 that are not in mxConfiguration1.
117 ResourceIdVector maC2minusC1;
119 /** After the call to Classify() this vector holds all elements that are
120 member both of mxConfiguration1 and mxConfiguration2.
122 ResourceIdVector maC1andC2;
124 /** Put all the elements in the two gven sequences of resource ids and
125 copy them into one of the resource id result vectors maC1minusC2,
126 maC2minusC1, and maC1andC2. This is done by using only the resource
127 URLs for classification. Therefor this method calls itself
128 recursively.
129 @param rS1
130 One sequence of XResourceId objects.
131 @param rS2
132 Another sequence of XResourceId objects.
134 void PartitionResources (
135 const ::com::sun::star::uno::Sequence<
136 ::com::sun::star::uno::Reference<
137 ::com::sun::star::drawing::framework::XResourceId> >& rS1,
138 const ::com::sun::star::uno::Sequence<
139 ::com::sun::star::uno::Reference<
140 ::com::sun::star::drawing::framework::XResourceId> >& rS2);
142 /** Compare the given sequences of resource ids and put their elements
143 in one of three vectors depending on whether an element belongs to
144 both sequences or to one but not the other. Note that only the
145 resource URLs of the XResourceId objects are used for the
146 classification.
147 @param rS1
148 One sequence of XResourceId objects.
149 @param rS2
150 Another sequence of XResourceId objects.
152 void ClassifyResources (
153 const ::com::sun::star::uno::Sequence<
154 ::com::sun::star::uno::Reference<
155 ::com::sun::star::drawing::framework::XResourceId> >& rS1,
156 const ::com::sun::star::uno::Sequence<
157 ::com::sun::star::uno::Reference<
158 ::com::sun::star::drawing::framework::XResourceId> >& rS2,
159 ResourceIdVector& rS1minusS2,
160 ResourceIdVector& rS2minusS1,
161 ResourceIdVector& rS1andS2);
164 /** Copy the resources given in rSource to the list of resources
165 specified by rTarget. Resources bound to the ones in rSource,
166 either directly or indirectly, are copied as well.
167 @param rSource
168 All resources and the ones bound to them, either directly or
169 indirectly, are copied.
170 @param rxConfiguration
171 This configuration is used to determine the resources bound to
172 the ones in rSource.
173 @param rTarget
174 This list is filled with resources from rSource and the ones
175 bound to them.
177 void CopyResources (
178 const ResourceIdVector& rSource,
179 const ::com::sun::star::uno::Reference<
180 ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration,
181 ResourceIdVector& rTarget);
184 } } // end of namespace sd::framework
186 #endif