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 #include <oox/dllapi.h> 25 #include <sax/fshelper.hxx> 26 #include <svx/escherex.hxx> 27 28 namespace rtl { 29 class OString; 30 class OStringBuffer; 31 } 32 33 namespace oox { 34 35 namespace vml { 36 37 class OOX_DLLPUBLIC VMLExport : public EscherEx 38 { 39 /// Fast serializer to output the data 40 ::sax_fastparser::FSHelperPtr m_pSerializer; 41 42 /// Fill the shape attributes as they come. 43 ::sax_fastparser::FastAttributeList *m_pShapeAttrList; 44 45 /// Remember the shape type. 46 sal_uInt32 m_nShapeType; 47 48 /// Remember the shape flags. 49 sal_uInt32 m_nShapeFlags; 50 51 /// Remember style, the most important shape attribute ;-) 52 rtl::OStringBuffer *m_pShapeStyle; 53 54 /// Remember which shape types we had already written. 55 bool *m_pShapeTypeWritten; 56 57 public: 58 VMLExport( ::sax_fastparser::FSHelperPtr pSerializer ); 59 virtual ~VMLExport(); 60 61 ::sax_fastparser::FSHelperPtr GetFS()62 GetFS() { return m_pSerializer; } 63 64 /// Export the sdr object as VML. 65 /// 66 /// Call this when you need to export the object as VML. 67 using EscherEx::AddSdrObject; 68 69 protected: 70 /// Add an attribute to the generated <v:shape/> element. 71 /// 72 /// This should be called from within StartShape() to ensure that the 73 /// added attribute is preserved. 74 void AddShapeAttribute( sal_Int32 nAttribute, const rtl::OString& sValue ); 75 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 virtual sal_Int32 StartShape(); 80 81 /// End the shape. 82 /// 83 /// The parameter is just what we got from StartShape(). 84 virtual void EndShape( sal_Int32 nShapeElement ); 85 86 virtual void Commit( EscherPropertyContainer& rProps, const Rectangle& rRect ); 87 88 private: 89 90 virtual void OpenContainer( UINT16 nEscherContainer, int nRecInstance = 0 ); 91 virtual void CloseContainer(); 92 93 virtual UINT32 EnterGroup( const String& rShapeName, const Rectangle* pBoundRect = 0 ); 94 virtual void LeaveGroup(); 95 96 virtual void AddShape( UINT32 nShapeType, UINT32 nShapeFlags, UINT32 nShapeId = 0 ); 97 98 private: 99 /// Create an OString representing the id from a numerical id. 100 static rtl::OString ShapeIdString( sal_uInt32 nId ); 101 102 /// Add starting and ending point of a line to the m_pShapeAttrList. 103 void AddLineDimensions( const Rectangle& rRectangle ); 104 105 /// Add position and size to the OStringBuffer. 106 void AddRectangleDimensions( rtl::OStringBuffer& rBuffer, const Rectangle& rRectangle ); 107 }; 108 109 } // namespace vml 110 111 } // namespace oox 112