tdf#158624 - Improve warning dialogue for non-recommended formats during save
[LibreOffice.git] / filter / source / xsltfilter / OleHandler.hxx
blobd59429aacf4d10e38b3ed1f88d2d8af941e13b64
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /*
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
12 #include <cstdio>
13 #include <cstring>
14 #include <map>
15 #include <string_view>
16 #include <utility>
17 #include <vector>
18 #include <iostream>
19 #include <libxml/parser.h>
20 #include <libxml/tree.h>
21 #include <libxml/xmlIO.h>
22 #include <libxslt/transform.h>
23 #include <libxslt/xsltutils.h>
24 #include <libxslt/variables.h>
26 #include <cppuhelper/factory.hxx>
27 #include <osl/module.h>
28 #include <osl/file.hxx>
29 #include <osl/process.h>
30 #include <com/sun/star/lang/XComponent.hpp>
31 #include <com/sun/star/lang/XInitialization.hpp>
32 #include <com/sun/star/beans/NamedValue.hpp>
33 #include <com/sun/star/container/XNameContainer.hpp>
34 #include <com/sun/star/io/XInputStream.hpp>
35 #include <com/sun/star/io/XOutputStream.hpp>
36 #include <com/sun/star/io/XStream.hpp>
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::container;
41 using namespace ::com::sun::star::io;
43 namespace XSLT
46 * OleHandler provides implementations for the XSLT extension functions used by the WordML 2003 XSLT filters.
48 * The extension functions takes base64 encoded string representations of embedded OLE objects provided by the XML filter framework,
49 * stores them into a com.sun.star.embed.OLESimpleStorage and retrieves them later as individual base64 OLE objects.
51 * The implementation is ported from the former Java based implementation XSLTOleExtrater (sic)
53 * I believe the whole thing should provide round-trip editing of embedded OLE objects.
54 * I'm not sure if it currently does anything meaningful, because the Java implementation seems to be broken both in OOo and LibO.
57 class OleHandler
59 public:
60 OleHandler(css::uno::Reference<XComponentContext> xContext)
61 : m_xContext(std::move(xContext))
62 , m_tcontext(nullptr)
65 ~OleHandler()
67 if (m_tcontext)
68 m_tcontext->_private = nullptr;
70 void insertByName(const OUString& streamName, std::string_view content);
71 OString getByName(const OUString& streamName);
72 void registercontext(xsltTransformContextPtr context)
74 assert(context);
75 m_tcontext = context;
76 m_tcontext->_private = this;
79 private:
80 css::uno::Reference<XComponentContext> m_xContext;
81 css::uno::Reference<XNameContainer> m_storage;
82 css::uno::Reference<XStream> m_rootStream;
83 xsltTransformContextPtr m_tcontext;
85 void ensureCreateRootStorage();
86 OString encodeSubStorage(const OUString& streamName);
87 void insertSubStorage(const OUString& streamName, std::string_view content);
88 void initRootStorageFromBase64(std::string_view content);
89 css::uno::Reference<XStream> createTempFile();
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */