xref: /aoo4110/main/oox/inc/oox/helper/zipstorage.hxx (revision b1cdbd2c)
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_HELPER_ZIPSTORAGE_HXX
25 #define OOX_HELPER_ZIPSTORAGE_HXX
26 
27 #include "oox/helper/storagebase.hxx"
28 
29 namespace com { namespace sun { namespace star {
30     namespace uno { class XComponentContext; }
31 } } }
32 
33 namespace oox {
34 
35 // ============================================================================
36 
37 /** Implements stream access for ZIP storages containing XML streams. */
38 class ZipStorage : public StorageBase
39 {
40 public:
41     explicit            ZipStorage(
42                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
43                             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream );
44 
45     explicit            ZipStorage(
46                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
47                             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxStream );
48 
49     virtual             ~ZipStorage();
50 
51 private:
52     explicit            ZipStorage(
53                             const ZipStorage& rParentStorage,
54                             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage,
55                             const ::rtl::OUString& rElementName );
56 
57     /** Returns true, if the object represents a valid storage. */
58     virtual bool        implIsStorage() const;
59 
60     /** Returns the com.sun.star.embed.XStorage interface of the current storage. */
61     virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
62                         implGetXStorage() const;
63 
64     /** Returns the names of all elements of this storage. */
65     virtual void        implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const;
66 
67     /** Opens and returns the specified sub storage from the storage. */
68     virtual StorageRef  implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing );
69 
70     /** Opens and returns the specified input stream from the storage. */
71     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
72                         implOpenInputStream( const ::rtl::OUString& rElementName );
73 
74     /** Opens and returns the specified output stream from the storage. */
75     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
76                         implOpenOutputStream( const ::rtl::OUString& rElementName );
77 
78     /** Commits the current storage. */
79     virtual void        implCommit() const;
80 
81 private:
82     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
83                         mxStorage;      /// Storage based on input or output stream.
84 };
85 
86 // ============================================================================
87 
88 } // namespace oox
89 
90 #endif
91