LibreOffice Module oox (master)  1
shapes.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 #ifndef INCLUDED_OOX_EXPORT_SHAPES_HXX
21 #define INCLUDED_OOX_EXPORT_SHAPES_HXX
22 
23 #include <cstddef>
24 #include <memory>
25 #include <string_view>
26 #include <unordered_map>
27 
28 #include <com/sun/star/awt/Size.hpp>
29 #include <com/sun/star/table/BorderLine2.hpp>
30 #include <com/sun/star/uno/Reference.hxx>
31 #include <oox/dllapi.h>
32 #include <oox/export/drawingml.hxx>
33 #include <oox/export/utils.hxx>
34 #include <rtl/ustring.hxx>
35 #include <sal/types.h>
36 #include <sax/fshelper.hxx>
37 #include <tools/fract.hxx>
38 #include <vcl/mapmod.hxx>
39 
40 namespace com::sun::star {
41 namespace beans {
42  class XPropertySet;
43 }
44 namespace drawing {
45  class XShape;
46 }
47 
48 namespace embed {
49  class XEmbeddedObject;
50 }
51 namespace io {
52  class XInputStream;
53 }
54 namespace uno {
55  class XComponentContext;
56  class XInterface;
57 }
58 }
59 
60 namespace oox::core {
61  class XmlFilterBase;
62 }
63 
64 class Graphic;
65 
66 namespace oox {
67 
68 OOX_DLLPUBLIC css::uno::Reference<css::io::XInputStream> GetOLEObjectStream(
69  css::uno::Reference<css::uno::XComponentContext> const& xContext,
70  css::uno::Reference<css::embed::XEmbeddedObject> const& xObj,
71  std::u16string_view i_rProgID,
72  OUString & o_rMediaType,
73  OUString & o_rRelationType,
74  OUString & o_rSuffix,
75  const char *& o_rpProgID);
76 
77 }
78 
79 namespace oox::drawingml {
80 
82 
83 private:
85 
86 public:
87  typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32> ShapeHashMap;
88 
89 protected:
90  sal_Int32 mnShapeIdMax;
91  bool mbUserShapes; // for chart's embedded usershapes
92 
93  void WriteGraphicObjectShapePart( const css::uno::Reference< css::drawing::XShape >& xShape, const Graphic *pGraphic=nullptr );
94 
95  OUString GetShapeName(const css::uno::Reference< css::drawing::XShape >& xShape);
96 
97 private:
98  sal_Int32 mnXmlNamespace;
99  MapMode maMapModeSrc, maMapModeDest;
100  std::shared_ptr<URLTransformer> mpURLTransformer;
101 
102  css::awt::Size MapSize( const css::awt::Size& ) const;
103 
104  ShapeHashMap maShapeMap;
105  ShapeHashMap* mpShapeMap;
106 
107 public:
108 
109  ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS,
110  ShapeHashMap* pShapeMap, ::oox::core::XmlFilterBase* pFB,
111  DocumentType eDocumentType = DOCUMENT_PPTX,
112  DMLTextExport* pTextExport = nullptr,
113  bool bUserShapes = false );
114  virtual ~ShapeExport() {}
115 
116  void SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer);
117 
118  static bool NonEmptyText( const css::uno::Reference< css::uno::XInterface >& xIface );
119 
120  ShapeExport&
121  WritePolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape, bool bClosed );
122  ShapeExport&
123  WriteClosedPolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape );
124  ShapeExport&
125  WriteConnectorShape( const css::uno::Reference< css::drawing::XShape >& xShape );
126  ShapeExport&
127  WriteCustomShape( const css::uno::Reference< css::drawing::XShape >& xShape );
128  ShapeExport&
129  WriteEllipseShape( const css::uno::Reference< css::drawing::XShape >& xShape );
130  ShapeExport&
131  WriteGraphicObjectShape( const css::uno::Reference< css::drawing::XShape >& xShape );
132  ShapeExport&
133  WriteGroupShape( const css::uno::Reference< css::drawing::XShape >& xShape );
134  ShapeExport&
135  WriteLineShape( const css::uno::Reference< css::drawing::XShape >& xShape );
136  ShapeExport&
137  WriteNonVisualDrawingProperties( const css::uno::Reference< css::drawing::XShape >& xShape, const char* sName );
138  virtual ShapeExport&
139  WriteNonVisualProperties( const css::uno::Reference< css::drawing::XShape >& xShape );
140  ShapeExport&
141  WriteOpenPolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape );
142  ShapeExport&
143  WriteRectangleShape( const css::uno::Reference< css::drawing::XShape >& xShape );
144 
184  ShapeExport& WriteShape( const css::uno::Reference< css::drawing::XShape >& xShape );
185  ShapeExport& WriteTextBox( const css::uno::Reference< css::uno::XInterface >& xIface, sal_Int32 nXmlNamespace, bool bWritePropertiesAsLstStyles = false );
186  virtual ShapeExport&
187  WriteTextShape( const css::uno::Reference< css::drawing::XShape >& xShape );
188  ShapeExport&
189  WriteTableShape( const css::uno::Reference< css::drawing::XShape >& xShape );
190  void WriteMathShape(css::uno::Reference<css::drawing::XShape> const& xShape);
191  ShapeExport&
192  WriteOLE2Shape( const css::uno::Reference< css::drawing::XShape >& xShape );
193  virtual ShapeExport&
194  WriteUnknownShape( const css::uno::Reference< css::drawing::XShape >& xShape );
195 
196  void WriteTable( const css::uno::Reference< css::drawing::XShape >& rXShape );
197 
198  void WriteTableCellProperties(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
199 
200  void WriteBorderLine(const sal_Int32 XML_line, const css::table::BorderLine2& rBorderLine);
201  void WriteTableCellBorders(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
202 
203  sal_Int32 GetNewShapeID( const css::uno::Reference< css::drawing::XShape >& rShape );
204  sal_Int32 GetNewShapeID( const css::uno::Reference< css::drawing::XShape >& rShape, ::oox::core::XmlFilterBase* pFB );
205  sal_Int32 GetShapeID( const css::uno::Reference< css::drawing::XShape >& rShape );
206  static sal_Int32 GetShapeID( const css::uno::Reference< css::drawing::XShape >& rShape, ShapeHashMap* pShapeMap );
207 };
208 
209 }
210 
211 #endif // INCLUDED_OOX_EXPORT_SHAPES_HXX
212 
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface to be implemented by the parent exporter that knows how to handle shape text...
Definition: drawingml.hxx:122
const char * sName
Definition: olehelper.cxx:92
exports com.sun.star. io
exports com.sun.star. embed
std::shared_ptr< URLTransformer > mpURLTransformer
Definition: shapes.hxx:100
exports com.sun.star. drawing
class SAL_NO_VTABLE XPropertySet
uno::Reference< io::XInputStream > GetOLEObjectStream(uno::Reference< uno::XComponentContext > const &xContext, uno::Reference< embed::XEmbeddedObject > const &xObj, std::u16string_view i_rProgID, OUString &o_rMediaType, OUString &o_rRelationType, OUString &o_rSuffix, const char *&o_rpProgID)
Definition: shapes.cxx:277
std::shared_ptr< FastSerializerHelper > FSHelperPtr
exports com.sun.star. beans
ShapeHashMap * mpShapeMap
Definition: shapes.hxx:105
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
std::unordered_map< css::uno::Reference< css::drawing::XShape >, sal_Int32 > ShapeHashMap
Definition: shapes.hxx:87