1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CONFIGURATIONCLASSIFIER_HXX
21 #define INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CONFIGURATIONCLASSIFIER_HXX
23 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
27 namespace sd
{ namespace framework
{
29 /** A ConfigurationClassifier object compares two configurations of
30 resources and gives access to the differences. It is used mainly when
31 changes to the current configuration have been requested and the various
32 resource controllers have to be supplied with the set of resources that
33 are to be activated or deactivated.
35 class ConfigurationClassifier
38 /** Create a new ConfigurationClassifier object that will compare the
39 two given configurations.
41 ConfigurationClassifier (
42 const ::com::sun::star::uno::Reference
<
43 ::com::sun::star::drawing::framework::XConfiguration
>& rxConfiguration1
,
44 const ::com::sun::star::uno::Reference
<
45 ::com::sun::star::drawing::framework::XConfiguration
>& rxConfiguration2
);
47 /** Calculate three lists of resource ids. These contain the resources
48 that belong to one configuration but not the other, or that belong
49 to both configurations.
51 When the two configurations differ then return <TRUE/>. When
52 they are equivalent then return <FALSE/>.
56 typedef ::std::vector
<com::sun::star::uno::Reference
<
57 ::com::sun::star::drawing::framework::XResourceId
> > ResourceIdVector
;
59 /** Return the resources that belong to the configuration given as
60 rxConfiguration1 to the constructor but that do not belong to
63 A reference to the, possibly empty, list of resources is
64 returned. This reference remains valid as long as the called
65 ConfigurationClassifier object stays alive.
67 const ResourceIdVector
& GetC1minusC2() const { return maC1minusC2
;}
69 /** Return the resources that belong to the configuration given as
70 rxConfiguration2 to the constructor but that do not belong to
73 A reference to the, possibly empty, list of resources is
74 returned. This reference remains valid as long as the called
75 ConfigurationClassifier object stays alive.
77 const ResourceIdVector
& GetC2minusC1() const { return maC2minusC1
;}
79 /** Return the resources that belong to both the configurations that
80 where given to the constructor.
82 A reference to the, possibly empty, list of resources is
83 returned. This reference remains valid as long as the called
84 ConfigurationClassifier object stays alive.
86 const ResourceIdVector
& GetC1andC2() const { return maC1andC2
;}
88 static void TraceResourceIdVector (
89 const sal_Char
* pMessage
,
90 const ResourceIdVector
& rResources
);
93 ::com::sun::star::uno::Reference
<
94 ::com::sun::star::drawing::framework::XConfiguration
> mxConfiguration1
;
95 ::com::sun::star::uno::Reference
<
96 ::com::sun::star::drawing::framework::XConfiguration
> mxConfiguration2
;
98 /** After the call to Classify() this vector holds all elements from
99 mxConfiguration1 that are not in mxConfiguration2.
101 ResourceIdVector maC1minusC2
;
103 /** After the call to Classify() this vector holds all elements from
104 mxConfiguration2 that are not in mxConfiguration1.
106 ResourceIdVector maC2minusC1
;
108 /** After the call to Classify() this vector holds all elements that are
109 member both of mxConfiguration1 and mxConfiguration2.
111 ResourceIdVector maC1andC2
;
113 /** Put all the elements in the two given sequences of resource ids and
114 copy them into one of the resource id result vectors maC1minusC2,
115 maC2minusC1, and maC1andC2. This is done by using only the resource
116 URLs for classification. Therefore this method calls itself
119 One sequence of XResourceId objects.
121 Another sequence of XResourceId objects.
123 void PartitionResources (
124 const ::com::sun::star::uno::Sequence
<
125 ::com::sun::star::uno::Reference
<
126 ::com::sun::star::drawing::framework::XResourceId
> >& rS1
,
127 const ::com::sun::star::uno::Sequence
<
128 ::com::sun::star::uno::Reference
<
129 ::com::sun::star::drawing::framework::XResourceId
> >& rS2
);
131 /** Compare the given sequences of resource ids and put their elements
132 in one of three vectors depending on whether an element belongs to
133 both sequences or to one but not the other. Note that only the
134 resource URLs of the XResourceId objects are used for the
137 One sequence of XResourceId objects.
139 Another sequence of XResourceId objects.
141 static void ClassifyResources (
142 const ::com::sun::star::uno::Sequence
<
143 ::com::sun::star::uno::Reference
<
144 ::com::sun::star::drawing::framework::XResourceId
> >& rS1
,
145 const ::com::sun::star::uno::Sequence
<
146 ::com::sun::star::uno::Reference
<
147 ::com::sun::star::drawing::framework::XResourceId
> >& rS2
,
148 ResourceIdVector
& rS1minusS2
,
149 ResourceIdVector
& rS2minusS1
,
150 ResourceIdVector
& rS1andS2
);
152 /** Copy the resources given in rSource to the list of resources
153 specified by rTarget. Resources bound to the ones in rSource,
154 either directly or indirectly, are copied as well.
156 All resources and the ones bound to them, either directly or
157 indirectly, are copied.
158 @param rxConfiguration
159 This configuration is used to determine the resources bound to
162 This list is filled with resources from rSource and the ones
165 static void CopyResources (
166 const ResourceIdVector
& rSource
,
167 const ::com::sun::star::uno::Reference
<
168 ::com::sun::star::drawing::framework::XConfiguration
>& rxConfiguration
,
169 ResourceIdVector
& rTarget
);
172 } } // end of namespace sd::framework
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */