Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLSTREAMIMPL_HXX
20 : #define INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLSTREAMIMPL_HXX
21 :
22 : #include <map>
23 :
24 : #include <ooxml/OOXMLDocument.hxx>
25 : #include <comphelper/storagehelper.hxx>
26 : #include <com/sun/star/embed/XRelationshipAccess.hpp>
27 : #include <com/sun/star/io/XStream.hpp>
28 :
29 : extern OUString customTarget;
30 : extern OUString embeddingsTarget;
31 :
32 : namespace writerfilter {
33 : namespace ooxml
34 : {
35 :
36 : class OOXMLStreamImpl : public OOXMLStream
37 : {
38 : void init();
39 :
40 : css::uno::Reference<css::uno::XComponentContext> mxContext;
41 : css::uno::Reference<css::io::XInputStream> mxStorageStream;
42 : css::uno::Reference<css::embed::XStorage> mxStorage;
43 : css::uno::Reference<css::embed::XRelationshipAccess> mxRelationshipAccess;
44 : css::uno::Reference<css::io::XStream> mxDocumentStream;
45 : css::uno::Reference<css::xml::sax::XFastParser> mxFastParser;
46 : css::uno::Reference<css::xml::sax::XFastTokenHandler> mxFastTokenHandler;
47 :
48 : StreamType_t mnStreamType;
49 :
50 : OUString msId;
51 : OUString msPath;
52 : OUString msTarget;
53 :
54 : /// Cache holding an Id <-> Target map of external relations.
55 : std::map<OUString, OUString> maIdCache;
56 :
57 : bool lcl_getTarget(css::uno::Reference<css::embed::XRelationshipAccess>
58 : xRelationshipAccess,
59 : StreamType_t nStreamType,
60 : const OUString & rId,
61 : OUString & rDocumentTarget);
62 : public:
63 : typedef std::shared_ptr<OOXMLStreamImpl> Pointer_t;
64 :
65 : OOXMLStreamImpl
66 : (OOXMLStreamImpl & rStream, StreamType_t nType);
67 : OOXMLStreamImpl
68 : (css::uno::Reference<css::uno::XComponentContext> xContext,
69 : css::uno::Reference<css::io::XInputStream> xStorageStream,
70 : StreamType_t nType, bool bRepairStorage);
71 : OOXMLStreamImpl(OOXMLStreamImpl & rStream, const OUString & rId);
72 :
73 : virtual ~OOXMLStreamImpl();
74 :
75 : virtual css::uno::Reference<css::xml::sax::XParser> getParser() SAL_OVERRIDE;
76 : virtual css::uno::Reference<css::xml::sax::XFastParser> getFastParser() SAL_OVERRIDE;
77 : virtual css::uno::Reference<css::io::XInputStream> getDocumentStream() SAL_OVERRIDE;
78 : virtual css::uno::Reference<css::io::XInputStream> getStorageStream() SAL_OVERRIDE;
79 : virtual css::uno::Reference<css::uno::XComponentContext> getContext() SAL_OVERRIDE;
80 : virtual OUString getTargetForId(const OUString & rId) SAL_OVERRIDE;
81 : virtual const OUString & getTarget() const SAL_OVERRIDE;
82 :
83 : virtual css::uno::Reference<css::xml::sax::XFastTokenHandler> getFastTokenHandler() SAL_OVERRIDE;
84 :
85 : void setInputStream(css::uno::Reference<css::io::XInputStream> rxInputStream);
86 : // Giving access to mxDocumentStream. It is needed by resolving custom xml to get list of customxml's used in document.
87 10127 : css::uno::Reference<css::io::XStream> accessDocumentStream() { return mxDocumentStream;}
88 : };
89 : }}
90 : #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLSTREAMIMPL_HXX
91 :
92 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|