1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <ooxml/OOXMLDocument.hxx>
23 #include <com/sun/star/xml/dom/XDocument.hpp>
24 #include <com/sun/star/graphic/XGraphicMapper.hpp>
26 #include <oox/drawingml/drawingmltypes.hxx>
27 #include <oox/drawingml/ThemeFilterBase.hxx>
29 #include "OOXMLPropertySet.hxx"
34 namespace writerfilter::ooxml
37 class OOXMLDocumentImpl
: public OOXMLDocument
39 OOXMLStream::Pointer_t mpStream
;
40 css::uno::Reference
<css::task::XStatusIndicator
> mxStatusIndicator
;
41 writerfilter::Reference
<Stream
>::Pointer_t mpXFootnoteStream
;
42 writerfilter::Reference
<Stream
>::Pointer_t mpXEndnoteStream
;
45 css::uno::Reference
<css::frame::XModel
> mxModel
;
46 css::uno::Reference
<css::drawing::XDrawPage
> mxDrawPage
;
47 css::uno::Reference
<css::xml::dom::XDocument
> mxGlossaryDocDom
;
48 css::uno::Sequence
< css::uno::Sequence
< css::beans::NamedValue
> > mxGlossaryDomList
;
49 /// Stack of shape contexts, 1 element for VML, 1 element / nesting level for drawingML.
50 std::stack
< rtl::Reference
<oox::shape::ShapeContextHandler
> > maShapeContexts
;
51 css::uno::Reference
<css::xml::dom::XDocument
> mxThemeDom
;
52 css::uno::Sequence
<css::uno::Reference
<css::xml::dom::XDocument
> > mxCustomXmlDomList
;
53 css::uno::Sequence
<css::uno::Reference
<css::xml::dom::XDocument
> > mxCustomXmlDomPropsList
;
54 css::uno::Reference
<css::xml::dom::XDocument
> mxCustomXmlProsDom
;
55 css::uno::Reference
<css::io::XInputStream
> mxEmbeddings
;
56 css::uno::Sequence
< css::beans::PropertyValue
> mxEmbeddingsList
;
57 std::vector
<css::beans::PropertyValue
> m_aEmbeddings
;
60 /// How many paragraphs equal to 1 percent?
61 sal_Int32 mnPercentSize
;
62 /// Position progress when it was last updated, possibly not after every paragraph in case of large documents.
63 sal_Int32 mnProgressLastPos
;
64 /// Current position progress, updated after every paragraph.
65 sal_Int32 mnProgressCurrentPos
;
66 /// End position, i.e. the estimated number of paragraphs.
67 sal_Int32 mnProgressEndPos
;
70 css::uno::Sequence
<css::beans::PropertyValue
> maMediaDescriptor
;
72 css::uno::Reference
<css::graphic::XGraphicMapper
> mxGraphicMapper
;
73 // For a document there is a single theme in document.xml.rels
74 // and the same is used by header and footer as well.
75 oox::drawingml::ThemePtr mpTheme
;
76 rtl::Reference
<oox::shape::ShapeFilterBase
> mxShapeFilterBase
;
77 rtl::Reference
<oox::drawingml::ThemeFilterBase
> mxThemeFilterBase
;
79 bool mbCommentsExtendedResolved
= false;
82 void resolveFastSubStream(Stream
& rStream
,
83 OOXMLStream::StreamType_t nType
);
85 static void resolveFastSubStreamWithId(Stream
& rStream
,
86 const writerfilter::Reference
<Stream
>::Pointer_t
& pStream
,
89 css::uno::Reference
<css::xml::dom::XDocument
> importSubStream(OOXMLStream::StreamType_t nType
);
91 void importSubStreamRelations(const OOXMLStream::Pointer_t
& pStream
, OOXMLStream::StreamType_t nType
);
93 writerfilter::Reference
<Stream
>::Pointer_t
94 getSubStream(const OUString
& rId
);
96 writerfilter::Reference
<Stream
>::Pointer_t
97 getXNoteStream(OOXMLStream::StreamType_t nType
, const sal_Int32 nNoteId
);
99 void resolveCustomXmlStream(Stream
& rStream
);
100 void resolveGlossaryStream(Stream
& rStream
);
101 void resolveEmbeddingsStream(const OOXMLStream::Pointer_t
& pStream
);
102 void resolveCommentsExtendedStream(Stream
& rStream
);
105 OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream
, css::uno::Reference
<css::task::XStatusIndicator
> xStatusIndicator
, bool bSkipImages
, const css::uno::Sequence
<css::beans::PropertyValue
>& rDescriptor
);
106 virtual ~OOXMLDocumentImpl() override
;
108 virtual void resolve(Stream
& rStream
) override
;
110 virtual void resolveFootnote(Stream
& rStream
,
112 const sal_Int32 nNoteId
) override
;
113 virtual void resolveEndnote(Stream
& rStream
,
115 const sal_Int32 nNoteId
) override
;
116 virtual void resolveHeader(Stream
& rStream
,
117 const sal_Int32 type
,
118 const OUString
& rId
) override
;
119 virtual void resolveFooter(Stream
& rStream
,
120 const sal_Int32 type
,
121 const OUString
& rId
) override
;
123 virtual void resolveComment(Stream
& rStream
, const sal_Int32 nId
) override
;
125 OOXMLPropertySet
* getPicturePropSet(const OUString
& rId
);
126 virtual void resolvePicture(Stream
& rStream
, const OUString
& rId
) override
;
128 virtual OUString
getTargetForId(const OUString
& rId
) override
;
130 virtual void setModel(css::uno::Reference
<css::frame::XModel
> xModel
) override
;
131 virtual css::uno::Reference
<css::frame::XModel
> getModel() override
;
132 virtual void setDrawPage(css::uno::Reference
<css::drawing::XDrawPage
> xDrawPage
) override
;
133 virtual css::uno::Reference
<css::drawing::XDrawPage
> getDrawPage() override
;
134 virtual css::uno::Reference
<css::io::XInputStream
> getInputStreamForId(const OUString
& rId
) override
;
135 virtual void setXNoteId(const sal_Int32 nId
) override
;
136 virtual sal_Int32
getXNoteId() const override
;
137 virtual const OUString
& getTarget() const override
;
138 virtual rtl::Reference
<oox::shape::ShapeContextHandler
> getShapeContext( ) override
;
139 virtual void setShapeContext( rtl::Reference
<oox::shape::ShapeContextHandler
> xContext
) override
;
140 virtual const oox::drawingml::ThemePtr
& getTheme() const override
144 void pushShapeContext() override
;
145 void popShapeContext() override
;
146 virtual css::uno::Reference
<css::xml::dom::XDocument
> getThemeDom() override
;
147 virtual css::uno::Sequence
<css::uno::Reference
<css::xml::dom::XDocument
> > getCustomXmlDomList() override
;
148 virtual css::uno::Sequence
<css::uno::Reference
<css::xml::dom::XDocument
> > getCustomXmlDomPropsList() override
;
149 virtual css::uno::Reference
<css::xml::dom::XDocument
> getGlossaryDocDom() override
;
150 virtual css::uno::Sequence
<css::uno::Sequence
< css::beans::NamedValue
> > getGlossaryDomList() override
;
151 virtual css::uno::Sequence
<css::beans::PropertyValue
> getEmbeddingsList() override
;
153 void incrementProgress();
154 bool IsSkipImages() const { return mbSkipImages
; };
155 OUString
const& GetDocumentBaseURL() const { return m_rBaseURL
; };
156 const css::uno::Sequence
<css::beans::PropertyValue
>& getMediaDescriptor() const;
158 const css::uno::Reference
<css::graphic::XGraphicMapper
>& getGraphicMapper() const
160 return mxGraphicMapper
;
163 void setTheme(const oox::drawingml::ThemePtr
& pTheme
) { mpTheme
= pTheme
; }
165 const rtl::Reference
<oox::shape::ShapeFilterBase
> & getShapeFilterBase();
166 const rtl::Reference
<oox::drawingml::ThemeFilterBase
> & getThemeFilterBase();
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */