LibreOffice Module filter (master) 1
OleHandler.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 * This file is part of the LibreOffice project.
5 *
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 */
10
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>
25
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>
37
38using namespace ::com::sun::star::uno;
39using namespace ::com::sun::star::lang;
40using namespace ::com::sun::star::container;
41using namespace ::com::sun::star::io;
42
43namespace XSLT
44{
45 /*
46 * OleHandler provides implementations for the XSLT extension functions used by the WordML 2003 XSLT filters.
47 *
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.
50 *
51 * The implementation is ported from the former Java based implementation XSLTOleExtrater (sic)
52 *
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.
55 *
56 */
58 {
59 public:
60 OleHandler(css::uno::Reference<XComponentContext> xContext)
61 : m_xContext(std::move(xContext))
62 , m_tcontext(nullptr)
63 {
64 }
66 {
67 if (m_tcontext)
68 m_tcontext->_private = nullptr;
69 }
70 void insertByName(const OUString& streamName, std::string_view content);
71 OString getByName(const OUString& streamName);
72 void registercontext(xsltTransformContextPtr context)
73 {
74 assert(context);
75 m_tcontext = context;
76 m_tcontext->_private = this;
77 }
78
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;
84
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();
90 };
91}
92
93/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OleHandler(css::uno::Reference< XComponentContext > xContext)
Definition: OleHandler.hxx:60
OString getByName(const OUString &streamName)
Definition: OleHandler.cxx:147
xsltTransformContextPtr m_tcontext
Definition: OleHandler.hxx:83
css::uno::Reference< XComponentContext > m_xContext
Definition: OleHandler.hxx:80
void registercontext(xsltTransformContextPtr context)
Definition: OleHandler.hxx:72
css::uno::Reference< XStream > createTempFile()
Definition: OleHandler.cxx:39
OString encodeSubStorage(const OUString &streamName)
Definition: OleHandler.cxx:81
void ensureCreateRootStorage()
Definition: OleHandler.cxx:45
void insertByName(const OUString &streamName, std::string_view content)
Definition: OleHandler.cxx:133
void initRootStorageFromBase64(std::string_view content)
Definition: OleHandler.cxx:59
css::uno::Reference< XNameContainer > m_storage
Definition: OleHandler.hxx:81
void insertSubStorage(const OUString &streamName, std::string_view content)
Definition: OleHandler.cxx:168
css::uno::Reference< XStream > m_rootStream
Definition: OleHandler.hxx:82