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