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 #ifndef INCLUDED_OOXML_STREAM_IMPL_HXX
24 #define INCLUDED_OOXML_STREAM_IMPL_HXX
25 
26 #include <ooxml/OOXMLDocument.hxx>
27 #include <comphelper/storagehelper.hxx>
28 #include <com/sun/star/embed/XRelationshipAccess.hpp>
29 #include <com/sun/star/io/XStream.hpp>
30 
31 namespace writerfilter {
32 namespace ooxml
33 {
34 
35 using namespace com::sun::star;
36 
37 class OOXMLStreamImpl : public OOXMLStream
38 {
39     void init() throw (uno::Exception);
40 
41     uno::Reference<uno::XComponentContext> mxContext;
42     uno::Reference<io::XInputStream> mxStorageStream;
43     uno::Reference<embed::XStorage> mxStorage;
44     uno::Reference<embed::XRelationshipAccess> mxRelationshipAccess;
45     uno::Reference<io::XStream> mxDocumentStream;
46     uno::Reference<xml::sax::XFastParser> mxFastParser;
47     uno::Reference<xml::sax::XFastTokenHandler> mxFastTokenHandler;
48 
49     StreamType_t mnStreamType;
50 
51     rtl::OUString msId;
52     rtl::OUString msPath;
53     rtl::OUString msTarget;
54 
55     bool lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
56                        xRelationshipAccess,
57                        StreamType_t nStreamType,
58                        const ::rtl::OUString & rId,
59                        ::rtl::OUString & rDocumentTarget);
60 public:
61     typedef boost::shared_ptr<OOXMLStreamImpl> Pointer_t;
62 
63     OOXMLStreamImpl
64     (OOXMLStreamImpl & rStream, StreamType_t nType)
65     throw (uno::Exception);
66 
67     OOXMLStreamImpl
68     (uno::Reference<uno::XComponentContext> xContext,
69      uno::Reference<io::XInputStream> xStorageStream,
70      StreamType_t nType)
71     throw (uno::Exception);
72 
73     OOXMLStreamImpl(OOXMLStreamImpl & rStream, const rtl::OUString & rId)
74     throw (uno::Exception);
75 
76     virtual ~OOXMLStreamImpl();
77 
78     virtual uno::Reference<xml::sax::XParser> getParser();
79     virtual uno::Reference<xml::sax::XFastParser> getFastParser();
80     virtual uno::Reference<io::XInputStream> getDocumentStream();
81     virtual uno::Reference<io::XInputStream> getStorageStream();
82     virtual uno::Reference<uno::XComponentContext> getContext();
83     virtual ::rtl::OUString getTargetForId(const ::rtl::OUString & rId);
84     virtual const ::rtl::OUString & getTarget() const;
85 
86     virtual uno::Reference<xml::sax::XFastTokenHandler>
87     getFastTokenHandler(uno::Reference<uno::XComponentContext> rContext);
88 
89     void setInputStream(uno::Reference<io::XInputStream> rxInputStream);
90 };
91 }}
92 #endif // INCLUDED_OOXML_STREAM_IMPL_HXX
93