1*c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c45d927aSAndrew Rist * distributed with this work for additional information 6*c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9*c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10*c45d927aSAndrew Rist * 11*c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*c45d927aSAndrew Rist * 13*c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c45d927aSAndrew Rist * software distributed under the License is distributed on an 15*c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17*c45d927aSAndrew Rist * specific language governing permissions and limitations 18*c45d927aSAndrew Rist * under the License. 19*c45d927aSAndrew Rist * 20*c45d927aSAndrew Rist *************************************************************/ 21*c45d927aSAndrew Rist 22*c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_FRAMEWORK_CONFIGURATION_CLASSIFIER_HXX 25cdf0e10cSrcweir #define SD_FRAMEWORK_CONFIGURATION_CLASSIFIER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfiguration.hpp> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <vector> 30cdf0e10cSrcweir 31cdf0e10cSrcweir namespace sd { namespace framework { 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** A ConfigurationClassifier object compares two configurations of 34cdf0e10cSrcweir resources and gives access to the differences. It is used mainly when 35cdf0e10cSrcweir changes to the current configuration have been requested and the various 36cdf0e10cSrcweir resource controllers have to be supplied with the set of resources that 37cdf0e10cSrcweir are to be activated or deactivated. 38cdf0e10cSrcweir */ 39cdf0e10cSrcweir class ConfigurationClassifier 40cdf0e10cSrcweir { 41cdf0e10cSrcweir public: 42cdf0e10cSrcweir /** Create a new ConfigurationClassifier object that will compare the 43cdf0e10cSrcweir two given configurations. 44cdf0e10cSrcweir */ 45cdf0e10cSrcweir ConfigurationClassifier ( 46cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 47cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration1, 48cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 49cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration2); 50cdf0e10cSrcweir 51cdf0e10cSrcweir /** Calculate three lists of resource ids. These contain the resources 52cdf0e10cSrcweir that belong to one configuration but not the other, or that belong 53cdf0e10cSrcweir to both configurations. 54cdf0e10cSrcweir @return 55cdf0e10cSrcweir When the two configurations differ then return <TRUE/>. When 56cdf0e10cSrcweir they are equivalent then return <FALSE/>. 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir bool Partition (void); 59cdf0e10cSrcweir 60cdf0e10cSrcweir typedef ::std::vector<com::sun::star::uno::Reference< 61cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> > ResourceIdVector; 62cdf0e10cSrcweir 63cdf0e10cSrcweir /** Return the resources that belong to the configuration given as 64cdf0e10cSrcweir rxConfiguration1 to the constructor but that do not belong to 65cdf0e10cSrcweir rxConfiguration2. 66cdf0e10cSrcweir @return 67cdf0e10cSrcweir A reference to the, possibly empty, list of resources is 68cdf0e10cSrcweir returned. This reference remains valid as long as the called 69cdf0e10cSrcweir ConfigurationClassifier object stays alive. 70cdf0e10cSrcweir */ 71cdf0e10cSrcweir const ResourceIdVector& GetC1minusC2 (void) const; 72cdf0e10cSrcweir 73cdf0e10cSrcweir /** Return the resources that belong to the configuration given as 74cdf0e10cSrcweir rxConfiguration2 to the constructor but that do not belong to 75cdf0e10cSrcweir rxConfiguration1. 76cdf0e10cSrcweir @return 77cdf0e10cSrcweir A reference to the, possibly empty, list of resources is 78cdf0e10cSrcweir returned. This reference remains valid as long as the called 79cdf0e10cSrcweir ConfigurationClassifier object stays alive. 80cdf0e10cSrcweir */ 81cdf0e10cSrcweir const ResourceIdVector& GetC2minusC1 (void) const; 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** Return the resources that belong to both the configurations that 84cdf0e10cSrcweir where given to the constructor. 85cdf0e10cSrcweir @return 86cdf0e10cSrcweir A reference to the, possibly empty, list of resources is 87cdf0e10cSrcweir returned. This reference remains valid as long as the called 88cdf0e10cSrcweir ConfigurationClassifier object stays alive. 89cdf0e10cSrcweir */ 90cdf0e10cSrcweir const ResourceIdVector& GetC1andC2 (void) const; 91cdf0e10cSrcweir 92cdf0e10cSrcweir void TraceResourceIdVector ( 93cdf0e10cSrcweir const sal_Char* pMessage, 94cdf0e10cSrcweir const ResourceIdVector& rResources) const; 95cdf0e10cSrcweir 96cdf0e10cSrcweir private: 97cdf0e10cSrcweir ::com::sun::star::uno::Reference< 98cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration1; 99cdf0e10cSrcweir ::com::sun::star::uno::Reference< 100cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration2; 101cdf0e10cSrcweir 102cdf0e10cSrcweir /** After the call to Classify() this vector holds all elements from 103cdf0e10cSrcweir mxConfiguration1 that are not in mxConfiguration2. 104cdf0e10cSrcweir */ 105cdf0e10cSrcweir ResourceIdVector maC1minusC2; 106cdf0e10cSrcweir 107cdf0e10cSrcweir /** After the call to Classify() this vector holds all elements from 108cdf0e10cSrcweir mxConfiguration2 that are not in mxConfiguration1. 109cdf0e10cSrcweir */ 110cdf0e10cSrcweir ResourceIdVector maC2minusC1; 111cdf0e10cSrcweir 112cdf0e10cSrcweir /** After the call to Classify() this vector holds all elements that are 113cdf0e10cSrcweir member both of mxConfiguration1 and mxConfiguration2. 114cdf0e10cSrcweir */ 115cdf0e10cSrcweir ResourceIdVector maC1andC2; 116cdf0e10cSrcweir 117cdf0e10cSrcweir /** Put all the elements in the two gven sequences of resource ids and 118cdf0e10cSrcweir copy them into one of the resource id result vectors maC1minusC2, 119cdf0e10cSrcweir maC2minusC1, and maC1andC2. This is done by using only the resource 120cdf0e10cSrcweir URLs for classification. Therefor this method calls itself 121cdf0e10cSrcweir recursively. 122cdf0e10cSrcweir @param rS1 123cdf0e10cSrcweir One sequence of XResourceId objects. 124cdf0e10cSrcweir @param rS2 125cdf0e10cSrcweir Another sequence of XResourceId objects. 126cdf0e10cSrcweir */ 127cdf0e10cSrcweir void PartitionResources ( 128cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 129cdf0e10cSrcweir ::com::sun::star::uno::Reference< 130cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> >& rS1, 131cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 132cdf0e10cSrcweir ::com::sun::star::uno::Reference< 133cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> >& rS2); 134cdf0e10cSrcweir 135cdf0e10cSrcweir /** Compare the given sequences of resource ids and put their elements 136cdf0e10cSrcweir in one of three vectors depending on whether an element belongs to 137cdf0e10cSrcweir both sequences or to one but not the other. Note that only the 138cdf0e10cSrcweir resource URLs of the XResourceId objects are used for the 139cdf0e10cSrcweir classification. 140cdf0e10cSrcweir @param rS1 141cdf0e10cSrcweir One sequence of XResourceId objects. 142cdf0e10cSrcweir @param rS2 143cdf0e10cSrcweir Another sequence of XResourceId objects. 144cdf0e10cSrcweir */ 145cdf0e10cSrcweir void ClassifyResources ( 146cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 147cdf0e10cSrcweir ::com::sun::star::uno::Reference< 148cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> >& rS1, 149cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 150cdf0e10cSrcweir ::com::sun::star::uno::Reference< 151cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> >& rS2, 152cdf0e10cSrcweir ResourceIdVector& rS1minusS2, 153cdf0e10cSrcweir ResourceIdVector& rS2minusS1, 154cdf0e10cSrcweir ResourceIdVector& rS1andS2); 155cdf0e10cSrcweir 156cdf0e10cSrcweir 157cdf0e10cSrcweir /** Copy the resources given in rSource to the list of resources 158cdf0e10cSrcweir specified by rTarget. Resources bound to the ones in rSource, 159cdf0e10cSrcweir either directly or indirectly, are copied as well. 160cdf0e10cSrcweir @param rSource 161cdf0e10cSrcweir All resources and the ones bound to them, either directly or 162cdf0e10cSrcweir indirectly, are copied. 163cdf0e10cSrcweir @param rxConfiguration 164cdf0e10cSrcweir This configuration is used to determine the resources bound to 165cdf0e10cSrcweir the ones in rSource. 166cdf0e10cSrcweir @param rTarget 167cdf0e10cSrcweir This list is filled with resources from rSource and the ones 168cdf0e10cSrcweir bound to them. 169cdf0e10cSrcweir */ 170cdf0e10cSrcweir void CopyResources ( 171cdf0e10cSrcweir const ResourceIdVector& rSource, 172cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 173cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration, 174cdf0e10cSrcweir ResourceIdVector& rTarget); 175cdf0e10cSrcweir }; 176cdf0e10cSrcweir 177cdf0e10cSrcweir } } // end of namespace sd::framework 178cdf0e10cSrcweir 179cdf0e10cSrcweir #endif 180