1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SVTOOLS_INC_IMAGERESOURCEACCESS_HXX
25 #define SVTOOLS_INC_IMAGERESOURCEACCESS_HXX
26 
27 #include "svtools/svtdllapi.h"
28 
29 /** === begin UNO includes === **/
30 #include <com/sun/star/io/XInputStream.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 /** === end UNO includes === **/
33 
34 class SvStream;
35 //........................................................................
36 namespace svt
37 {
38 //........................................................................
39 
40     //====================================================================
41     //= GraphicAccess
42     //====================================================================
43     /** helper class for obtaining streams (which also can be used with the ImageProducer)
44         from a resource
45     */
46     class GraphicAccess
47     {
48     private:
49         GraphicAccess();    // never implemented
50 
51     public:
52         /** determines whether the given URL denotes an image within a resource
53          ( or an image specified by a vnd.sun.star.GraphicObject scheme URL )
54         */
55         SVT_DLLPUBLIC static  bool        isSupportedURL( const ::rtl::OUString& _rURL );
56 
57         /** for a given URL of an image within a resource ( or an image specified by a vnd.sun.star.GraphicObject scheme URL ), this method retrieves
58             an SvStream for this image.
59 
60             This method works for arbitrary URLs denoting an image, since the
61             <type scope="com::sun::star::graphics">GraphicsProvider</type> service is used
62             to resolve the URL. However, obtaining the stream is expensive (since
63             the image must be copied), so you are strongly encouraged to only use it
64             when you know that the image is small enough.
65         */
66         SVT_DLLPUBLIC static  SvStream*   getImageStream(
67                     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
68                     const ::rtl::OUString& _rImageResourceURL
69                 );
70 
71         /** for a given URL of an image within a resource ( or an image specified by a vnd.sun.star.GraphicObject scheme URL ), this method retrieves
72             an <type scope="com::sun::star::io">XInputStream</type> for this image.
73         */
74         SVT_DLLPUBLIC static  ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
75                 getImageXStream(
76                     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
77                     const ::rtl::OUString& _rImageResourceURL
78                 );
79     };
80 
81 //........................................................................
82 } // namespace svt
83 //........................................................................
84 
85 #endif // DBA14_SVTOOLS_INC_IMAGERESOURCEACCESS_HXX
86 
87