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 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_RTFSDREXPORT_HXX 21 #define INCLUDED_SW_SOURCE_FILTER_WW8_RTFSDREXPORT_HXX 22 23 #include <filter/msfilter/escherex.hxx> 24 #include <editeng/outlobj.hxx> 25 #include <rtl/strbuf.hxx> 26 27 #include <map> 28 #include <memory> 29 30 #include "wrtww8.hxx" 31 32 class RtfExport; 33 class RtfAttributeOutput; 34 class SwFrameFormat; 35 36 /// Handles export of drawings using RTF markup 37 class RtfSdrExport final : public EscherEx 38 { 39 RtfExport& m_rExport; 40 41 RtfAttributeOutput& m_rAttrOutput; 42 43 const SdrObject* m_pSdrObject; 44 45 /// Remember the shape type. 46 sal_uInt32 m_nShapeType; 47 48 /// Remember the shape flags. 49 ShapeFlag m_nShapeFlags; 50 51 /// Remember style, the most important shape attribute ;-) 52 OStringBuffer m_aShapeStyle; 53 54 std::map<OString, OString> m_aShapeProps; 55 56 /// Remember which shape types we had already written. 57 std::unique_ptr<bool[]> m_pShapeTypeWritten; 58 59 bool m_bInGroup = false; 60 61 public: 62 explicit RtfSdrExport(RtfExport& rExport); 63 ~RtfSdrExport() override; 64 65 /// Export the sdr object as Sdr. 66 /// 67 /// Call this when you need to export the object as Sdr in RTF. 68 void AddSdrObject(const SdrObject& rObj); 69 70 /// Is this a standalone TextFrame, or used as a TextBox of a shape? 71 static bool isTextBox(const SwFrameFormat& rFrameFormat); 72 /// Write editeng text, e.g. shape or comment. 73 void WriteOutliner(const OutlinerParaObject& rParaObj, TextTypes eType); 74 75 private: 76 /// Start the shape for which we just collected the information. 77 /// 78 /// Returns the element's tag number, -1 means we wrote nothing. 79 using EscherEx::StartShape; 80 sal_Int32 StartShape(); 81 82 /// End the shape. 83 /// 84 /// The parameter is just what we got from StartShape(). 85 using EscherEx::EndShape; 86 void EndShape(sal_Int32 nShapeElement); 87 88 void Commit(EscherPropertyContainer& rProps, const tools::Rectangle& rRect) override; 89 90 void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance = 0) override; 91 void CloseContainer() override; 92 93 sal_uInt32 EnterGroup(const OUString& rShapeName, const tools::Rectangle* pBoundRect) override; 94 void LeaveGroup() override; 95 96 void AddShape(sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt32 nShapeId = 0) override; 97 98 /// Add starting and ending point of a line to the m_pShapeAttrList. 99 void AddLineDimensions(const tools::Rectangle& rRectangle); 100 101 /// Add position and size to the OStringBuffer. 102 void AddRectangleDimensions(OStringBuffer& rBuffer, const tools::Rectangle& rRectangle); 103 104 /// Exports the pib property of the shape 105 void impl_writeGraphic(); 106 }; 107 108 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_RTFSDREXPORT_HXX 109 110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 111