LibreOffice Module starmath (master) 1
export.hxx
Go to the documentation of this file.
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
20#pragma once
21
22// Our mathml
23#include "element.hxx"
24
25// Xml tools
26#include <utility>
28#include <xmloff/xmlexp.hxx>
29#include <xmloff/xmltoken.hxx>
30
31// Extras
32#include <com/sun/star/io/XOutputStream.hpp>
33
34class SfxMedium;
35class SmDocShell;
36class SmModel;
37
39{
40private:
41 // Model
43 // Save as a flat document ( mml, fodf ... )
44 bool m_bFlat;
45 // Use html / mathml entities
47 // Mathmml tree to parse
49 // Export xmlns tag
51
52public:
55 void setFlat(bool bFlat) { m_bFlat = bFlat; }
56
59 bool getFlat() const { return m_bFlat; }
60
63 void setUseHTMLMLEntities(bool bUseHTMLMLEntities)
64 {
65 m_bUseHTMLMLEntities = bUseHTMLMLEntities;
66 }
67
71
74 bool getUseExportTag() const { return m_bUseExportTag; }
75
78 void setUseExportTag(bool bUseExportTag) { m_bUseExportTag = bUseExportTag; }
79
80public:
82 : m_xModel(std::move(xRef))
83 , m_bFlat(true)
85 , m_pElementTree(nullptr)
86 , m_bUseExportTag(false)
87 {
88 }
89
92 bool Export(SfxMedium& rMedium);
93
96 OUString Export(SmMlElement* pElementTree);
97
98 // Making this protected we can keep it from getting trash as input
99protected:
102 bool WriteThroughComponentOS(const css::uno::Reference<css::io::XOutputStream>& xOutputStream,
103 const css::uno::Reference<css::lang::XComponent>& xComponent,
104 css::uno::Reference<css::uno::XComponentContext> const& rxContext,
105 css::uno::Reference<css::beans::XPropertySet> const& rPropSet,
106 const char16_t* pComponentName, int_fast16_t nSyntaxVersion);
107
110 bool WriteThroughComponentS(const css::uno::Reference<css::embed::XStorage>& xStor,
111 const css::uno::Reference<css::lang::XComponent>& xComponent,
112 const char16_t* pStreamName,
113 css::uno::Reference<css::uno::XComponentContext> const& rxContext,
114 css::uno::Reference<css::beans::XPropertySet> const& rPropSet,
115 const char16_t* pComponentName, int_fast16_t nSyntaxVersion);
116
119 OUString
120 WriteThroughComponentMS(const css::uno::Reference<css::lang::XComponent>& xComponent,
121 css::uno::Reference<css::uno::XComponentContext> const& rxContext,
122 css::uno::Reference<css::beans::XPropertySet> const& rPropSet);
123};
124
125class SmMLExport final : public SvXMLExport
126{
127private:
131
132public:
135 bool getSuccess() const { return m_bSuccess; }
136
139 bool getUseExportTag() const { return m_bUseExportTag; }
140
143 void setUseExportTag(bool bUseExportTag) { m_bUseExportTag = bUseExportTag; }
144
148 void setElementTree(SmMlElement* pElementTree) { m_pElementTree = pElementTree; }
149
150private:
154 {
155 // We can't afford to ignore white spaces. They are part of the code.
156 return new SvXMLElementExport(*this, XML_NAMESPACE_MATH, nElement, false, false);
157 }
158
162 xmloff::token::XMLTokenEnum pAttributeValue)
163 {
164 AddAttribute(XML_NAMESPACE_MATH, pAttribute, pAttributeValue);
165 }
166
169 void addAttribute(xmloff::token::XMLTokenEnum pAttribute, const OUString& pAttributeValue)
170 {
171 AddAttribute(XML_NAMESPACE_MATH, pAttribute, pAttributeValue);
172 }
173
174public:
178 const SmLengthValue& aLengthValue);
179
182 void exportMlAttributes(const SmMlElement* pMlElement);
183
187
190 void exportMlElementTree();
191
194 void declareMlError();
195
196public:
199 SmMLExport(const css::uno::Reference<css::uno::XComponentContext>& rContext,
200 OUString const& implementationName, SvXMLExportFlags nExportFlags);
201
202private:
206
207public:
211 void ExportAutoStyles_() override {}
212
216 void ExportMasterStyles_() override {}
217
221 void ExportContent_() override { exportMlElementTree(); };
222
226 ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass
227 = ::xmloff::token::XML_TOKEN_INVALID) override;
228
231 virtual void GetViewSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override;
232
235 virtual void
236 GetConfigurationSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override;
237};
238
239/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setUseExportTag(bool bUseExportTag)
Set's if xmlns field is added.
Definition: export.hxx:78
SmMLExportWrapper(rtl::Reference< SmModel > xRef)
Definition: export.hxx:81
bool WriteThroughComponentS(const css::uno::Reference< css::embed::XStorage > &xStor, const css::uno::Reference< css::lang::XComponent > &xComponent, const char16_t *pStreamName, css::uno::Reference< css::uno::XComponentContext > const &rxContext, css::uno::Reference< css::beans::XPropertySet > const &rPropSet, const char16_t *pComponentName, int_fast16_t nSyntaxVersion)
export through an XML exporter component (storage version)
Definition: export.cxx:354
bool Export(SfxMedium &rMedium)
Export to an archive.
Definition: export.cxx:68
rtl::Reference< SmModel > m_xModel
Definition: export.hxx:42
bool getUseExportTag() const
Get's if xmlns field is added.
Definition: export.hxx:74
OUString WriteThroughComponentMS(const css::uno::Reference< css::lang::XComponent > &xComponent, css::uno::Reference< css::uno::XComponentContext > const &rxContext, css::uno::Reference< css::beans::XPropertySet > const &rPropSet)
export through an XML exporter component (memory stream version)
Definition: export.cxx:400
bool m_bUseHTMLMLEntities
Definition: export.hxx:46
bool getUseHTMLMLEntities() const
Activates the use of HTML / MathML entities such as &infinity;.
Definition: export.hxx:70
bool WriteThroughComponentOS(const css::uno::Reference< css::io::XOutputStream > &xOutputStream, const css::uno::Reference< css::lang::XComponent > &xComponent, css::uno::Reference< css::uno::XComponentContext > const &rxContext, css::uno::Reference< css::beans::XPropertySet > const &rPropSet, const char16_t *pComponentName, int_fast16_t nSyntaxVersion)
export through an XML exporter component (output stream version)
Definition: export.cxx:282
bool getFlat() const
Checks if the writer is set to export to flat document.
Definition: export.hxx:59
void setUseHTMLMLEntities(bool bUseHTMLMLEntities)
Checks the use of HTML / MathML entities such as &infinity;.
Definition: export.hxx:63
bool m_bUseExportTag
Definition: export.hxx:50
SmMlElement * m_pElementTree
Definition: export.hxx:48
void setFlat(bool bFlat)
Set's the writer to export to flat document.
Definition: export.hxx:55
void setUseExportTag(bool bUseExportTag)
Set's if xmlns field is added.
Definition: export.hxx:143
SmMLExport(const css::uno::Reference< css::uno::XComponentContext > &rContext, OUString const &implementationName, SvXMLExportFlags nExportFlags)
Constructor.
Definition: export.cxx:588
void setElementTree(SmMlElement *pElementTree)
Set's the element tree to be exported.
Definition: export.hxx:148
ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass=::xmloff::token::XML_TOKEN_INVALID) override
Exports the document If m_pElementTree isn't null then exports m_pElementTree.
Definition: export.cxx:474
void exportMlElementTree()
Exports an element tree.
Definition: export.cxx:1083
void ExportMasterStyles_() override
Exports master styles However math doesn't have any.
Definition: export.hxx:216
void declareMlError()
Handles an error on the mathml structure.
Definition: export.cxx:600
void ExportContent_() override
Exports formula Handler used from exportDoc.
Definition: export.hxx:221
virtual void GetConfigurationSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps) override
Get's configuration settings and prepares them to export.
Definition: export.cxx:550
SvXMLElementExport * createElementExport(xmloff::token::XMLTokenEnum nElement)
Adds an element.
Definition: export.hxx:153
bool getUseExportTag() const
Get's if xmlns field is added.
Definition: export.hxx:139
bool m_bSuccess
Definition: export.hxx:129
SvXMLElementExport * exportMlElement(const SmMlElement *pMlElement)
Exports an element and all it's attributes.
Definition: export.cxx:981
virtual void GetViewSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps) override
Get's view settings and prepares them to export.
Definition: export.cxx:520
bool getSuccess() const
Everything was allright.
Definition: export.hxx:135
void exportMlAttributes(const SmMlElement *pMlElement)
Exports attributes of an element.
Definition: export.cxx:656
SmDocShell * getSmDocShell()
Get's document shell.
Definition: export.cxx:466
void exportMlAttributeLength(xmloff::token::XMLTokenEnum pAttribute, const SmLengthValue &aLengthValue)
Exports an attribute of type "length".
Definition: export.cxx:606
SmMlElement * m_pElementTree
Definition: export.hxx:128
bool m_bUseExportTag
Definition: export.hxx:130
void addAttribute(xmloff::token::XMLTokenEnum pAttribute, const OUString &pAttributeValue)
Adds an attribute.
Definition: export.hxx:169
void ExportAutoStyles_() override
Exports auto styles However math doesn't have any.
Definition: export.hxx:211
void addAttribute(xmloff::token::XMLTokenEnum pAttribute, xmloff::token::XMLTokenEnum pAttributeValue)
Adds an attribute.
Definition: export.hxx:161
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
SvXMLExportFlags
constexpr sal_uInt16 XML_NAMESPACE_MATH