1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _OOX_EXPORT_SHAPES_HXX_ 25 #define _OOX_EXPORT_SHAPES_HXX_ 26 27 #include <oox/dllapi.h> 28 #include <com/sun/star/uno/XReference.hpp> 29 #include <oox/export/drawingml.hxx> 30 #include <sax/fshelper.hxx> 31 #include <vcl/mapmod.hxx> 32 #include <hash_map> 33 34 namespace com { namespace sun { namespace star { 35 namespace beans { 36 class XPropertySet; 37 } 38 namespace drawing { 39 class XShape; 40 class XShapes; 41 } 42 }}} 43 44 namespace oox { namespace drawingml { 45 46 class OOX_DLLPUBLIC ShapeExport : public DrawingML { 47 private: 48 sal_Int32 mnXmlNamespace; 49 sal_Int32 mnShapeIdMax, mnPictureIdMax; 50 Fraction maFraction; 51 MapMode maMapModeSrc, maMapModeDest; 52 53 ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& ) const; 54 55 struct ShapeCheck 56 { operator ()oox::drawingml::ShapeExport::ShapeCheck57 bool operator()( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> s1, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> s2 ) const 58 { 59 return s1 == s2; 60 } 61 }; 62 63 struct ShapeHash 64 { 65 rtl::CStringHash maHashFunction; 66 67 size_t operator()( const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > ) const; 68 }; 69 70 typedef std::hash_map< const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>, sal_Int32, ShapeHash, ShapeCheck> ShapeHashMap; 71 ShapeHashMap maShapeMap; 72 73 public: 74 ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX ); ~ShapeExport()75 virtual ~ShapeExport() {} 76 77 sal_Int32 GetXmlNamespace() const; 78 ShapeExport& SetXmlNamespace( sal_Int32 nXmlNamespace ); 79 80 static sal_Bool NonEmptyText( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 81 82 virtual ShapeExport& 83 WriteBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, sal_Bool bClosed ); 84 virtual ShapeExport& 85 WriteClosedBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 86 virtual ShapeExport& 87 WriteConnectorShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 88 virtual ShapeExport& 89 WriteCustomShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 90 virtual ShapeExport& 91 WriteEllipseShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 92 virtual ShapeExport& 93 WriteFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet ); 94 virtual ShapeExport& 95 WriteGraphicObjectShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 96 virtual ShapeExport& 97 WriteLineShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 98 virtual ShapeExport& 99 WriteNonVisualDrawingProperties( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const char* sName ); 100 virtual ShapeExport& 101 WriteNonVisualProperties( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 102 virtual ShapeExport& 103 WriteOpenBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 104 virtual ShapeExport& 105 WriteRectangleShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 106 107 /** 108 * Write the DrawingML for a particular shape. 109 * 110 * <p>This is the member function you want. It performs the type lookup and 111 * invokes the appropriate corresponding Write*() method for the specific 112 * type.</p> 113 * 114 * <p>To write an XShape, XShape::getShapeType() is called to determine 115 * the shape type, and the corresponding method in this table is 116 * invoked:</p> 117 * 118 * <table> 119 * <tr><th>Shape Type</th><th>Method</th></tr> 120 * <tr><td><tt>com.sun.star.drawing.ClosedBezierShape</tt></td> <td>ShapeExport::WriteClosedBezierShape</td></tr> 121 * <tr><td><tt>com.sun.star.drawing.CustomShape</tt></td> <td>ShapeExport::WriteCustomShape</td></tr> 122 * <tr><td><tt>com.sun.star.drawing.EllipseShape</tt></td> <td>ShapeExport::WriteEllipseShape</td></tr> 123 * <tr><td><tt>com.sun.star.drawing.GraphicObjectShape</tt></td> <td>ShapeExport::WriteGraphicObjectShape</td></tr> 124 * <tr><td><tt>com.sun.star.drawing.LineShape</tt></td> <td>ShapeExport::WriteLineShape</td></tr> 125 * <tr><td><tt>com.sun.star.drawing.OpenBezierShape</tt></td> <td>ShapeExport::WriteOpenBezierShape</td></tr> 126 * <tr><td><tt>com.sun.star.drawing.RectangleShape</tt></td> <td>ShapeExport::WriteRectangleShape</td></tr> 127 * <tr><td><tt>com.sun.star.drawing.TextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr> 128 * <tr><td><tt>com.sun.star.presentation.DateTimeShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr> 129 * <tr><td><tt>com.sun.star.presentation.FooterShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr> 130 * <tr><td><tt>com.sun.star.presentation.HeaderShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr> 131 * <tr><td><tt>com.sun.star.presentation.NotesShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr> 132 * <tr><td><tt>com.sun.star.presentation.OutlinerShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr> 133 * <tr><td><tt>com.sun.star.presentation.SlideNumberShape</tt></td><td>ShapeExport::WriteTextShape</td></tr> 134 * <tr><td><tt>com.sun.star.presentation.TitleTextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr> 135 * </table> 136 * 137 * <p>If the shape type is not recognized, then 138 * <tt>ShapeExport::WriteUnknownShape</tt> is called.</p> 139 * 140 * @param xShape The shape to export as DrawingML. 141 * @return <tt>*this</tt> 142 */ 143 virtual ShapeExport& 144 WriteShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 145 virtual ShapeExport& 146 WriteTextBox( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 147 virtual ShapeExport& 148 WriteTextShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 149 virtual ShapeExport& 150 WriteUnknownShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); 151 152 sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape ); 153 sal_Int32 GetShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape ); 154 }; 155 156 }} 157 158 #endif /* ndef _OOX_EXPORT_SHAPES_HXX_ */ 159