xref: /trunk/main/oox/inc/oox/ole/olestorage.hxx (revision 67e470da)
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 OOX_OLE_OLESTORAGE_HXX
25 #define OOX_OLE_OLESTORAGE_HXX
26 
27 #include "oox/helper/storagebase.hxx"
28 
29 namespace com { namespace sun { namespace star {
30     namespace container { class XNameContainer; }
31     namespace uno { class XComponentContext; }
32 } } }
33 
34 namespace oox {
35 namespace ole {
36 
37 // ============================================================================
38 
39 /** Implements stream access for binary OLE storages. */
40 class OleStorage : public StorageBase
41 {
42 public:
43     explicit            OleStorage(
44                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
45                             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream,
46                             bool bBaseStreamAccess );
47 
48     explicit            OleStorage(
49                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
50                             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream,
51                             bool bBaseStreamAccess );
52 
53     virtual             ~OleStorage();
54 
55 private:
56     explicit            OleStorage(
57                             const OleStorage& rParentStorage,
58                             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxStorage,
59                             const ::rtl::OUString& rElementName,
60                             bool bReadOnly );
61     explicit            OleStorage(
62                             const OleStorage& rParentStorage,
63                             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream,
64                             const ::rtl::OUString& rElementName );
65 
66     /** Initializes the API storage object for input. */
67     void                initStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream );
68     /** Initializes the API storage object for input/output. */
69     void                initStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream );
70 
71     /** Returns true, if the object represents a valid storage. */
72     virtual bool        implIsStorage() const;
73 
74     /** Returns the com.sun.star.embed.XStorage interface of the current storage.
75 
76         @attention
77             This function is not implemented for binary OLE storages.
78      */
79     virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
80                         implGetXStorage() const;
81 
82     /** Returns the names of all elements of this storage. */
83     virtual void        implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const;
84 
85     /** Opens and returns the specified sub storage from the storage. */
86     virtual StorageRef  implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing );
87 
88     /** Opens and returns the specified input stream from the storage. */
89     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
90                         implOpenInputStream( const ::rtl::OUString& rElementName );
91 
92     /** Opens and returns the specified output stream from the storage. */
93     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
94                         implOpenOutputStream( const ::rtl::OUString& rElementName );
95 
96     /** Commits the current storage. */
97     virtual void        implCommit() const;
98 
99 private:
100     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
101                         mxContext;          /// Component context with service manager.
102     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
103                         mxStorage;          /// Access to elements of this sub storage.
104     const OleStorage*   mpParentStorage;    /// Parent OLE storage that contains this storage.
105 };
106 
107 // ============================================================================
108 
109 } // namespace ole
110 } // namespace oox
111 
112 #endif
113