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 #include <xmloff/xmlexp.hxx> 23 #include <xmloff/xmltoken.hxx> 24 25 class SfxMedium; 26 class SmNode; 27 class SmVerticalBraceNode; 28 namespace com::sun::star 29 { 30 namespace io 31 { 32 class XOutputStream; 33 } 34 namespace beans 35 { 36 class XPropertySet; 37 } 38 } 39 40 class SmXMLExportWrapper 41 { 42 css::uno::Reference<css::frame::XModel> xModel; 43 bool bFlat; //set true for export to flat .mml, set false for 44 //export to a .sxm (or whatever) package 45 46 private: 47 // Use customized entities 48 bool m_bUseHTMLMLEntities; 49 50 public: 51 explicit SmXMLExportWrapper(css::uno::Reference<css::frame::XModel> const& rRef) 52 : xModel(rRef) 53 , bFlat(true) 54 , m_bUseHTMLMLEntities(false) 55 { 56 } 57 58 bool Export(SfxMedium& rMedium); 59 void SetFlat(bool bIn) { bFlat = bIn; } 60 61 bool IsUseHTMLMLEntities() const { return m_bUseHTMLMLEntities; } 62 void SetUseHTMLMLEntities(bool bUseHTMLMLEntities) 63 { 64 m_bUseHTMLMLEntities = bUseHTMLMLEntities; 65 } 66 67 bool WriteThroughComponent(const css::uno::Reference<css::io::XOutputStream>& xOutputStream, 68 const css::uno::Reference<css::lang::XComponent>& xComponent, 69 css::uno::Reference<css::uno::XComponentContext> const& rxContext, 70 css::uno::Reference<css::beans::XPropertySet> const& rPropSet, 71 const char* pComponentName); 72 73 bool WriteThroughComponent(const css::uno::Reference<css::embed::XStorage>& xStor, 74 const css::uno::Reference<css::lang::XComponent>& xComponent, 75 const char* pStreamName, 76 css::uno::Reference<css::uno::XComponentContext> const& rxContext, 77 css::uno::Reference<css::beans::XPropertySet> const& rPropSet, 78 const char* pComponentName); 79 }; 80 81 class SmXMLExport final : public SvXMLExport 82 { 83 const SmNode* pTree; 84 OUString aText; 85 bool bSuccess; 86 87 void ExportNodes(const SmNode* pNode, int nLevel); 88 void ExportTable(const SmNode* pNode, int nLevel); 89 void ExportLine(const SmNode* pNode, int nLevel); 90 void ExportExpression(const SmNode* pNode, int nLevel, bool bNoMrowContainer = false); 91 void ExportText(const SmNode* pNode); 92 void ExportMath(const SmNode* pNode); 93 void ExportBinaryHorizontal(const SmNode* pNode, int nLevel); 94 void ExportUnaryHorizontal(const SmNode* pNode, int nLevel); 95 void ExportBrace(const SmNode* pNode, int nLevel); 96 void ExportBinaryVertical(const SmNode* pNode, int nLevel); 97 void ExportBinaryDiagonal(const SmNode* pNode, int nLevel); 98 void ExportSubSupScript(const SmNode* pNode, int nLevel); 99 void ExportRoot(const SmNode* pNode, int nLevel); 100 void ExportOperator(const SmNode* pNode, int nLevel); 101 void ExportAttributes(const SmNode* pNode, int nLevel); 102 void ExportFont(const SmNode* pNode, int nLevel); 103 void ExportVerticalBrace(const SmVerticalBraceNode* pNode, int nLevel); 104 void ExportMatrix(const SmNode* pNode, int nLevel); 105 void ExportBlank(const SmNode* pNode); 106 107 public: 108 SmXMLExport(const css::uno::Reference<css::uno::XComponentContext>& rContext, 109 OUString const& implementationName, SvXMLExportFlags nExportFlags); 110 111 // XUnoTunnel 112 sal_Int64 SAL_CALL getSomething(const css::uno::Sequence<sal_Int8>& rId) override; 113 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() noexcept; 114 115 void ExportAutoStyles_() override {} 116 void ExportMasterStyles_() override {} 117 void ExportContent_() override; 118 ErrCode exportDoc(enum ::xmloff::token::XMLTokenEnum eClass 119 = ::xmloff::token::XML_TOKEN_INVALID) override; 120 121 virtual void GetViewSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override; 122 virtual void 123 GetConfigurationSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override; 124 125 bool GetSuccess() const { return bSuccess; } 126 }; 127 128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 129
