1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef SD_FRAMEWORK_CONFIGURATION_CLASSIFIER_HXX 29*cdf0e10cSrcweir #define SD_FRAMEWORK_CONFIGURATION_CLASSIFIER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfiguration.hpp> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <vector> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir namespace sd { namespace framework { 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir /** A ConfigurationClassifier object compares two configurations of 38*cdf0e10cSrcweir resources and gives access to the differences. It is used mainly when 39*cdf0e10cSrcweir changes to the current configuration have been requested and the various 40*cdf0e10cSrcweir resource controllers have to be supplied with the set of resources that 41*cdf0e10cSrcweir are to be activated or deactivated. 42*cdf0e10cSrcweir */ 43*cdf0e10cSrcweir class ConfigurationClassifier 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir public: 46*cdf0e10cSrcweir /** Create a new ConfigurationClassifier object that will compare the 47*cdf0e10cSrcweir two given configurations. 48*cdf0e10cSrcweir */ 49*cdf0e10cSrcweir ConfigurationClassifier ( 50*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 51*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration1, 52*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 53*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration2); 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir /** Calculate three lists of resource ids. These contain the resources 56*cdf0e10cSrcweir that belong to one configuration but not the other, or that belong 57*cdf0e10cSrcweir to both configurations. 58*cdf0e10cSrcweir @return 59*cdf0e10cSrcweir When the two configurations differ then return <TRUE/>. When 60*cdf0e10cSrcweir they are equivalent then return <FALSE/>. 61*cdf0e10cSrcweir */ 62*cdf0e10cSrcweir bool Partition (void); 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir typedef ::std::vector<com::sun::star::uno::Reference< 65*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> > ResourceIdVector; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir /** Return the resources that belong to the configuration given as 68*cdf0e10cSrcweir rxConfiguration1 to the constructor but that do not belong to 69*cdf0e10cSrcweir rxConfiguration2. 70*cdf0e10cSrcweir @return 71*cdf0e10cSrcweir A reference to the, possibly empty, list of resources is 72*cdf0e10cSrcweir returned. This reference remains valid as long as the called 73*cdf0e10cSrcweir ConfigurationClassifier object stays alive. 74*cdf0e10cSrcweir */ 75*cdf0e10cSrcweir const ResourceIdVector& GetC1minusC2 (void) const; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir /** Return the resources that belong to the configuration given as 78*cdf0e10cSrcweir rxConfiguration2 to the constructor but that do not belong to 79*cdf0e10cSrcweir rxConfiguration1. 80*cdf0e10cSrcweir @return 81*cdf0e10cSrcweir A reference to the, possibly empty, list of resources is 82*cdf0e10cSrcweir returned. This reference remains valid as long as the called 83*cdf0e10cSrcweir ConfigurationClassifier object stays alive. 84*cdf0e10cSrcweir */ 85*cdf0e10cSrcweir const ResourceIdVector& GetC2minusC1 (void) const; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir /** Return the resources that belong to both the configurations that 88*cdf0e10cSrcweir where given to the constructor. 89*cdf0e10cSrcweir @return 90*cdf0e10cSrcweir A reference to the, possibly empty, list of resources is 91*cdf0e10cSrcweir returned. This reference remains valid as long as the called 92*cdf0e10cSrcweir ConfigurationClassifier object stays alive. 93*cdf0e10cSrcweir */ 94*cdf0e10cSrcweir const ResourceIdVector& GetC1andC2 (void) const; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir void TraceResourceIdVector ( 97*cdf0e10cSrcweir const sal_Char* pMessage, 98*cdf0e10cSrcweir const ResourceIdVector& rResources) const; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir private: 101*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 102*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration1; 103*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 104*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration> mxConfiguration2; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir /** After the call to Classify() this vector holds all elements from 107*cdf0e10cSrcweir mxConfiguration1 that are not in mxConfiguration2. 108*cdf0e10cSrcweir */ 109*cdf0e10cSrcweir ResourceIdVector maC1minusC2; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir /** After the call to Classify() this vector holds all elements from 112*cdf0e10cSrcweir mxConfiguration2 that are not in mxConfiguration1. 113*cdf0e10cSrcweir */ 114*cdf0e10cSrcweir ResourceIdVector maC2minusC1; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir /** After the call to Classify() this vector holds all elements that are 117*cdf0e10cSrcweir member both of mxConfiguration1 and mxConfiguration2. 118*cdf0e10cSrcweir */ 119*cdf0e10cSrcweir ResourceIdVector maC1andC2; 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir /** Put all the elements in the two gven sequences of resource ids and 122*cdf0e10cSrcweir copy them into one of the resource id result vectors maC1minusC2, 123*cdf0e10cSrcweir maC2minusC1, and maC1andC2. This is done by using only the resource 124*cdf0e10cSrcweir URLs for classification. Therefor this method calls itself 125*cdf0e10cSrcweir recursively. 126*cdf0e10cSrcweir @param rS1 127*cdf0e10cSrcweir One sequence of XResourceId objects. 128*cdf0e10cSrcweir @param rS2 129*cdf0e10cSrcweir Another sequence of XResourceId objects. 130*cdf0e10cSrcweir */ 131*cdf0e10cSrcweir void PartitionResources ( 132*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 133*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 134*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> >& rS1, 135*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 136*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 137*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> >& rS2); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir /** Compare the given sequences of resource ids and put their elements 140*cdf0e10cSrcweir in one of three vectors depending on whether an element belongs to 141*cdf0e10cSrcweir both sequences or to one but not the other. Note that only the 142*cdf0e10cSrcweir resource URLs of the XResourceId objects are used for the 143*cdf0e10cSrcweir classification. 144*cdf0e10cSrcweir @param rS1 145*cdf0e10cSrcweir One sequence of XResourceId objects. 146*cdf0e10cSrcweir @param rS2 147*cdf0e10cSrcweir Another sequence of XResourceId objects. 148*cdf0e10cSrcweir */ 149*cdf0e10cSrcweir void ClassifyResources ( 150*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 151*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 152*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> >& rS1, 153*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 154*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 155*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId> >& rS2, 156*cdf0e10cSrcweir ResourceIdVector& rS1minusS2, 157*cdf0e10cSrcweir ResourceIdVector& rS2minusS1, 158*cdf0e10cSrcweir ResourceIdVector& rS1andS2); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir /** Copy the resources given in rSource to the list of resources 162*cdf0e10cSrcweir specified by rTarget. Resources bound to the ones in rSource, 163*cdf0e10cSrcweir either directly or indirectly, are copied as well. 164*cdf0e10cSrcweir @param rSource 165*cdf0e10cSrcweir All resources and the ones bound to them, either directly or 166*cdf0e10cSrcweir indirectly, are copied. 167*cdf0e10cSrcweir @param rxConfiguration 168*cdf0e10cSrcweir This configuration is used to determine the resources bound to 169*cdf0e10cSrcweir the ones in rSource. 170*cdf0e10cSrcweir @param rTarget 171*cdf0e10cSrcweir This list is filled with resources from rSource and the ones 172*cdf0e10cSrcweir bound to them. 173*cdf0e10cSrcweir */ 174*cdf0e10cSrcweir void CopyResources ( 175*cdf0e10cSrcweir const ResourceIdVector& rSource, 176*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 177*cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfiguration>& rxConfiguration, 178*cdf0e10cSrcweir ResourceIdVector& rTarget); 179*cdf0e10cSrcweir }; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir } } // end of namespace sd::framework 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir #endif 184