23#include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
24#include <com/sun/star/uri/UriReferenceFactory.hpp>
34(uno::Reference<uno::XComponentContext>
const & xContext,
35 uno::Reference<io::XInputStream> xStorageStream,
36 StreamType_t nType,
bool bRepairStorage)
37:
mxContext(xContext), mxStorageStream(
std::move(xStorageStream)), mnStreamType(
nType)
41 (OFOPXML_STORAGE_FORMAT_STRING, mxStorageStream, xContext, bRepairStorage));
42 mxRelationshipAccess.set(mxStorage, uno::UNO_QUERY_THROW);
47OOXMLStreamImpl::OOXMLStreamImpl
50 mxStorageStream(rOOXMLStream.mxStorageStream),
52 mnStreamType(nStreamType),
53 msPath(rOOXMLStream.msPath)
63 mxStorageStream(rOOXMLStream.mxStorageStream),
67 msPath(rOOXMLStream.msPath)
87 OUString & rDocumentTarget)
89 static const char sId[] =
"Id";
90 static const char sTarget[] =
"Target";
91 static const char sTargetMode[] =
"TargetMode";
92 static const char sExternal[] =
"External";
101 bool bExternal =
false;
102 for (
const beans::StringPair& rPair : rSeq)
104 if (rPair.First ==
sId)
106 else if (rPair.First == sTarget)
107 aTarget = rPair.Second;
108 else if (rPair.First == sTargetMode && rPair.Second == sExternal)
112 if (bExternal || aTarget.startsWith(
"#"))
130 static const char sType[] =
"Type";
131 static constexpr OUStringLiteral sDocumentType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
132 static constexpr OUStringLiteral sStylesType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
133 static constexpr OUStringLiteral sNumberingType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
134 static constexpr OUStringLiteral sFonttableType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable";
135 static constexpr OUStringLiteral sFootnotesType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes";
136 static constexpr OUStringLiteral sEndnotesType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes";
137 static constexpr OUStringLiteral sCommentsType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
138 static constexpr OUStringLiteral sThemeType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
139 static constexpr OUStringLiteral sCustomType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml";
140 static constexpr OUStringLiteral sCustomPropsType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";
141 static constexpr OUStringLiteral sGlossaryType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument";
142 static constexpr OUStringLiteral sWebSettings =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings";
143 static constexpr OUStringLiteral sSettingsType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings";
144 static constexpr OUStringLiteral sChartType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
145 static constexpr OUStringLiteral sEmbeddingsType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
146 static constexpr OUStringLiteral sFooterType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";
147 static constexpr OUStringLiteral sHeaderType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
148 static constexpr OUStringLiteral sOleObjectType =
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
149 static constexpr OUStringLiteral sCommentsExtendedType =
u"http://schemas.microsoft.com/office/2011/relationships/commentsExtended";
151 static constexpr OUStringLiteral sDocumentTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument";
152 static constexpr OUStringLiteral sStylesTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/styles";
153 static constexpr OUStringLiteral sNumberingTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/numbering";
154 static constexpr OUStringLiteral sFonttableTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/fontTable";
155 static constexpr OUStringLiteral sFootnotesTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/footnotes";
156 static constexpr OUStringLiteral sEndnotesTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/endnotes";
157 static constexpr OUStringLiteral sCommentsTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/comments";
158 static constexpr OUStringLiteral sThemeTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/theme";
159 static constexpr OUStringLiteral sCustomTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/customXml";
160 static constexpr OUStringLiteral sCustomPropsTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/customXmlProps";
161 static constexpr OUStringLiteral sGlossaryTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/glossaryDocument";
162 static constexpr OUStringLiteral sWebSettingsStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/webSettings";
163 static constexpr OUStringLiteral sSettingsTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/settings";
164 static constexpr OUStringLiteral sChartTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/chart";
165 static constexpr OUStringLiteral sEmbeddingsTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/package";
166 static constexpr OUStringLiteral sFootersTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/footer";
167 static constexpr OUStringLiteral sHeaderTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/header";
168 static constexpr OUStringLiteral sOleObjectTypeStrict =
u"http://purl.oclc.org/ooxml/officeDocument/relationships/oleObject";
169 static constexpr OUStringLiteral sVBAProjectType =
u"http://schemas.microsoft.com/office/2006/relationships/vbaProject";
170 static constexpr OUStringLiteral sVBADataType =
u"http://schemas.microsoft.com/office/2006/relationships/wordVbaData";
172 OUString sStreamType;
173 OUString sStreamTypeStrict;
178 sStreamType = sVBAProjectType;
179 sStreamTypeStrict = sVBAProjectType;
182 sStreamType = sVBADataType;
183 sStreamTypeStrict = sVBADataType;
186 sStreamType = sDocumentType;
187 sStreamTypeStrict = sDocumentTypeStrict;
190 sStreamType = sStylesType;
191 sStreamTypeStrict = sStylesTypeStrict;
194 sStreamType = sNumberingType;
195 sStreamTypeStrict = sNumberingTypeStrict;
198 sStreamType = sFonttableType;
199 sStreamTypeStrict = sFonttableTypeStrict;
202 sStreamType = sFootnotesType;
203 sStreamTypeStrict = sFootnotesTypeStrict;
206 sStreamType = sEndnotesType;
207 sStreamTypeStrict = sEndnotesTypeStrict;
210 sStreamType = sCommentsType;
211 sStreamTypeStrict = sCommentsTypeStrict;
214 sStreamType = sThemeType;
215 sStreamTypeStrict = sThemeTypeStrict;
218 sStreamType = sCustomType;
219 sStreamTypeStrict = sCustomTypeStrict;
222 sStreamType = sCustomPropsType;
223 sStreamTypeStrict = sCustomPropsTypeStrict;
226 sStreamType = sSettingsType;
227 sStreamTypeStrict = sSettingsTypeStrict;
230 sStreamType = sGlossaryType;
231 sStreamTypeStrict = sGlossaryTypeStrict;
234 sStreamType = sWebSettings;
235 sStreamTypeStrict = sWebSettingsStrict;
238 sStreamType = sChartType;
239 sStreamTypeStrict = sChartTypeStrict;
242 sStreamType = sEmbeddingsType;
243 sStreamTypeStrict = sEmbeddingsTypeStrict;
246 sStreamType = sFooterType;
247 sStreamTypeStrict = sFootersTypeStrict;
250 sStreamType = sHeaderType;
251 sStreamTypeStrict = sHeaderTypeStrict;
254 sStreamType = sCommentsExtendedType;
255 sStreamTypeStrict = sCommentsExtendedType;
261 if (xRelationshipAccess.is())
264 xRelationshipAccess->getAllRelationships();
268 bool bExternalTarget =
false;
270 for (
const beans::StringPair &rPair : rSeq)
272 if (rPair.First ==
sType &&
273 ( rPair.Second == sStreamType ||
274 rPair.Second == sStreamTypeStrict ))
276 else if(rPair.First ==
sType &&
277 ((rPair.Second == sOleObjectType ||
278 rPair.Second == sOleObjectTypeStrict) &&
283 else if (rPair.First ==
sId &&
286 else if (rPair.First == sTarget)
289 if(
customTarget != rPair.Second && (sStreamType == sCustomType || sStreamType == sChartType || sStreamType == sFooterType || sStreamType == sHeaderType))
295 sMyTarget = rPair.Second;
298 else if (rPair.First == sTargetMode &&
299 rPair.Second == sExternal)
300 bExternalTarget =
true;
306 rDocumentTarget = sMyTarget;
322 rDocumentTarget = xAbs->getPath();
325 rDocumentTarget = rDocumentTarget.copy( 1 );
326 if(sStreamType == sEmbeddingsType)
360 sal_Int32 nLastIndex =
msTarget.lastIndexOf(
'/');
365 xHierarchicalStorageAccess(
mxStorage, uno::UNO_QUERY);
367 if (xHierarchicalStorageAccess.is())
369 uno::Any aAny(xHierarchicalStorageAccess->
370 openStreamElementByHierarchicalName
371 (
msTarget, embed::ElementModes::SEEKABLEREAD));
OUString embeddingsTarget
FILE * init(int, char **)
static css::uno::Reference< css::embed::XStorage > GetStorageOfFormatFromInputStream(const OUString &aFormat, const css::uno::Reference< css::io::XInputStream > &xStream, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >(), bool bRepairStorage=false)
static OOXMLStream::Pointer_t createStream(const css::uno::Reference< css::uno::XComponentContext > &rContext, const css::uno::Reference< css::io::XInputStream > &rStream, bool bRepairStorage)
css::uno::Reference< css::embed::XRelationshipAccess > mxRelationshipAccess
virtual ~OOXMLStreamImpl() override
bool lcl_getTarget(const css::uno::Reference< css::embed::XRelationshipAccess > &xRelationshipAccess, StreamType_t nStreamType, const OUString &rId, OUString &rDocumentTarget)
css::uno::Reference< css::io::XStream > mxDocumentStream
OOXMLStreamImpl(OOXMLStreamImpl const &rStream, StreamType_t nType)
virtual css::uno::Reference< css::io::XInputStream > getDocumentStream() override
StreamType_t mnStreamType
virtual css::uno::Reference< css::uno::XComponentContext > getContext() override
Returns component context for this stream.
virtual const OUString & getTarget() const override
css::uno::Reference< css::xml::sax::XFastTokenHandler > mxFastTokenHandler
std::map< OUString, OUString > maIdCache
Cache holding an Id <-> Target map of external relations.
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::Reference< css::embed::XStorage > mxStorage
virtual css::uno::Reference< css::xml::sax::XFastTokenHandler > getFastTokenHandler() override
virtual OUString getTargetForId(const OUString &rId) override
Returns target URL from relationships for a given id.
tools::SvRef< OOXMLStream > Pointer_t
Reference< XNameContainer > mxStorage