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_RESOURCE_ID_HXX 29*cdf0e10cSrcweir #define SD_FRAMEWORK_RESOURCE_ID_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 34*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 35*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir namespace css = ::com::sun::star; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir namespace { 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir typedef ::cppu::WeakImplHelper2 < 43*cdf0e10cSrcweir css::drawing::framework::XResourceId, 44*cdf0e10cSrcweir css::lang::XInitialization 45*cdf0e10cSrcweir > ResourceIdInterfaceBase; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir } // end of anonymous namespace. 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir namespace sd { namespace framework { 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir /** Implementation of the css::drawing::framework::ResourceId 55*cdf0e10cSrcweir service and the css::drawing::framework::XResourceId 56*cdf0e10cSrcweir interface. 57*cdf0e10cSrcweir */ 58*cdf0e10cSrcweir class ResourceId 59*cdf0e10cSrcweir : public ResourceIdInterfaceBase 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir public: 62*cdf0e10cSrcweir /** Create a new, empty resource id. 63*cdf0e10cSrcweir */ 64*cdf0e10cSrcweir ResourceId (void); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir /** Create a new resource id that is described by the given URLs. 67*cdf0e10cSrcweir @param rsResourceURLs 68*cdf0e10cSrcweir The first URL specifies the type of resource. The other URLs 69*cdf0e10cSrcweir describe its anchor. 70*cdf0e10cSrcweir The set of URLs may be empty. The result is then the same as 71*cdf0e10cSrcweir returned by ResourceId() default constructor. 72*cdf0e10cSrcweir */ 73*cdf0e10cSrcweir ResourceId (const ::std::vector<rtl::OUString>& rsResourceURLs); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir /** Create a new resource id that has an empty anchor. 76*cdf0e10cSrcweir @param rsResourceURL 77*cdf0e10cSrcweir When this resource URL is empty then the resulting ResourceId 78*cdf0e10cSrcweir object is identical to when the ResourceId() default constructor 79*cdf0e10cSrcweir had been called. 80*cdf0e10cSrcweir */ 81*cdf0e10cSrcweir ResourceId ( 82*cdf0e10cSrcweir const ::rtl::OUString& rsResourceURL); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir /** Create a new resource id for the given resource type and an anchor 85*cdf0e10cSrcweir that is specified by a single URL. This constructor can be used for 86*cdf0e10cSrcweir example for views that are bound to panes. 87*cdf0e10cSrcweir @param rsResourceURL 88*cdf0e10cSrcweir The URL of the actual resource. 89*cdf0e10cSrcweir @param rsAnchorURL 90*cdf0e10cSrcweir The single URL of the anchor. 91*cdf0e10cSrcweir */ 92*cdf0e10cSrcweir ResourceId ( 93*cdf0e10cSrcweir const ::rtl::OUString& rsResourceURL, 94*cdf0e10cSrcweir const ::rtl::OUString& rsAnchorURL); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir /** Create a new resource id for the specified resource type and the 97*cdf0e10cSrcweir given list of anchor URLs. 98*cdf0e10cSrcweir @param rsResourceURL 99*cdf0e10cSrcweir The URL of the actual resource. 100*cdf0e10cSrcweir @param rsAnchorURLs 101*cdf0e10cSrcweir The possibly empty list of anchor URLs. 102*cdf0e10cSrcweir */ 103*cdf0e10cSrcweir ResourceId ( 104*cdf0e10cSrcweir const ::rtl::OUString& rsResourceURL, 105*cdf0e10cSrcweir const ::std::vector<rtl::OUString>& rAnchorURLs); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir /** Create a new resource id with an anchor that consists of a sequence 108*cdf0e10cSrcweir of URLs that is extended by a further URL. 109*cdf0e10cSrcweir @param rsResourceURL 110*cdf0e10cSrcweir The URL of the actual resource. 111*cdf0e10cSrcweir @param rsFirstAnchorURL 112*cdf0e10cSrcweir This URL extends the anchor given by rAnchorURLs. 113*cdf0e10cSrcweir @param rAnchorURLs 114*cdf0e10cSrcweir An anchor as it is returned by XResourceId::getAnchorURLs(). 115*cdf0e10cSrcweir */ 116*cdf0e10cSrcweir ResourceId ( 117*cdf0e10cSrcweir const ::rtl::OUString& rsResourceURL, 118*cdf0e10cSrcweir const ::rtl::OUString& rsFirstAnchorURL, 119*cdf0e10cSrcweir const css::uno::Sequence<rtl::OUString>& rAnchorURLs); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir virtual ~ResourceId (void); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir /** Return the list of URLs of both the resource URL and the anchor 124*cdf0e10cSrcweir URLs. 125*cdf0e10cSrcweir */ 126*cdf0e10cSrcweir const ::std::vector<rtl::OUString>& GetResourceURLs (void) const; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir //===== XResourceId ======================================================= 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 131*cdf0e10cSrcweir getResourceURL (void) 132*cdf0e10cSrcweir throw(css::uno::RuntimeException); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir virtual css::util::URL SAL_CALL 135*cdf0e10cSrcweir getFullResourceURL (void) 136*cdf0e10cSrcweir throw(css::uno::RuntimeException); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 139*cdf0e10cSrcweir hasAnchor (void) 140*cdf0e10cSrcweir throw (css::uno::RuntimeException); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir virtual css::uno::Reference< 143*cdf0e10cSrcweir css::drawing::framework::XResourceId> SAL_CALL 144*cdf0e10cSrcweir getAnchor (void) 145*cdf0e10cSrcweir throw (css::uno::RuntimeException); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir virtual css::uno::Sequence<rtl::OUString> SAL_CALL 148*cdf0e10cSrcweir getAnchorURLs (void) 149*cdf0e10cSrcweir throw (css::uno::RuntimeException); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 152*cdf0e10cSrcweir getResourceTypePrefix (void) 153*cdf0e10cSrcweir throw (css::uno::RuntimeException); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL 156*cdf0e10cSrcweir compareTo (const css::uno::Reference< 157*cdf0e10cSrcweir css::drawing::framework::XResourceId>& rxResourceId) 158*cdf0e10cSrcweir throw (css::uno::RuntimeException); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 161*cdf0e10cSrcweir isBoundTo ( 162*cdf0e10cSrcweir const css::uno::Reference< 163*cdf0e10cSrcweir css::drawing::framework::XResourceId>& rxResourceId, 164*cdf0e10cSrcweir css::drawing::framework::AnchorBindingMode eMode) 165*cdf0e10cSrcweir throw(css::uno::RuntimeException); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 168*cdf0e10cSrcweir isBoundToURL ( 169*cdf0e10cSrcweir const ::rtl::OUString& rsAnchorURL, 170*cdf0e10cSrcweir css::drawing::framework::AnchorBindingMode eMode) 171*cdf0e10cSrcweir throw (css::uno::RuntimeException); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir virtual css::uno::Reference< 174*cdf0e10cSrcweir css::drawing::framework::XResourceId> SAL_CALL 175*cdf0e10cSrcweir clone (void) 176*cdf0e10cSrcweir throw(css::uno::RuntimeException); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir //===== XInitialization =================================================== 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir void SAL_CALL initialize ( 181*cdf0e10cSrcweir const css::uno::Sequence<css::uno::Any>& aArguments) 182*cdf0e10cSrcweir throw (css::uno::RuntimeException); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir private: 185*cdf0e10cSrcweir /** The set of URLs that consist of the resource URL at index 0 and the 186*cdf0e10cSrcweir anchor URLs and indices 1 and above. 187*cdf0e10cSrcweir */ 188*cdf0e10cSrcweir ::std::vector<rtl::OUString> maResourceURLs; 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir ::boost::scoped_ptr<css::util::URL> mpURL; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir static css::uno::WeakReference<css::util::XURLTransformer> mxURLTransformerWeak; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir /** Compare the called ResourceId object to the given ResourceId object. 195*cdf0e10cSrcweir This uses the implementation of both objects to speed up the 196*cdf0e10cSrcweir comparison. 197*cdf0e10cSrcweir */ 198*cdf0e10cSrcweir sal_Int16 CompareToLocalImplementation (const ResourceId& rId) const; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir /** Compare the called ResourceId object to the given XResourceId object 201*cdf0e10cSrcweir reference. The comparison is done via the UNO interface. Namely, 202*cdf0e10cSrcweir it uses the getResourceURL() and the getAnchorURLs() methods to get 203*cdf0e10cSrcweir access to the URLs of the given objec. 204*cdf0e10cSrcweir */ 205*cdf0e10cSrcweir sal_Int16 CompareToExternalImplementation (const css::uno::Reference< 206*cdf0e10cSrcweir css::drawing::framework::XResourceId>& rxId) const; 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir /** Return whether the called ResourceId object is bound to the anchor 209*cdf0e10cSrcweir consisting of the URLs given by psFirstAnchorURL and paAnchorURLs. 210*cdf0e10cSrcweir @param psFirstAnchorURL 211*cdf0e10cSrcweir Optional first URL of the anchor. This can be missing or present 212*cdf0e10cSrcweir independently of paAnchorURLs. 213*cdf0e10cSrcweir @param paAnchorURLs 214*cdf0e10cSrcweir Optional set of additional anchor URLs. This can be missing or 215*cdf0e10cSrcweir present independently of psFirstAnchorURL. 216*cdf0e10cSrcweir @param eMode 217*cdf0e10cSrcweir This specifies whether the called resource has to be directly 218*cdf0e10cSrcweir bound to the given anchor in order to return <TRUE/> or whether 219*cdf0e10cSrcweir it can be bound indirectly, too. 220*cdf0e10cSrcweir */ 221*cdf0e10cSrcweir bool IsBoundToAnchor ( 222*cdf0e10cSrcweir const rtl::OUString* psFirstAnchorURL, 223*cdf0e10cSrcweir const css::uno::Sequence<rtl::OUString>* paAnchorURLs, 224*cdf0e10cSrcweir css::drawing::framework::AnchorBindingMode eMode) const; 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir /** Return whether the called ResourceId object is bound to the anchor 227*cdf0e10cSrcweir consisting of the URLs in rResourceURLs. 228*cdf0e10cSrcweir @param rResourceURLs 229*cdf0e10cSrcweir A possibly empty list of anchor URLs. 230*cdf0e10cSrcweir @param eMode 231*cdf0e10cSrcweir This specifies whether the called resource has to be directly 232*cdf0e10cSrcweir bound to the given anchor in order to return <TRUE/> or whether 233*cdf0e10cSrcweir it can be bound indirectly, too. 234*cdf0e10cSrcweir */ 235*cdf0e10cSrcweir bool IsBoundToAnchor ( 236*cdf0e10cSrcweir const ::std::vector<rtl::OUString>& rResourceURLs, 237*cdf0e10cSrcweir css::drawing::framework::AnchorBindingMode eMode) const; 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir void ParseResourceURL (void); 240*cdf0e10cSrcweir }; 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir } } // end of namespace sd::framework 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir #endif 245