LCOV - code coverage report
Current view: top level - include/oox/export - vmlexport.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 3 66.7 %
Date: 2015-06-13 12:38:46 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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_VMLEXPORT_HXX
      21             : #define INCLUDED_OOX_EXPORT_VMLEXPORT_HXX
      22             : 
      23             : #include <oox/dllapi.h>
      24             : #include <oox/export/drawingml.hxx>
      25             : #include <sax/fshelper.hxx>
      26             : #include <filter/msfilter/escherex.hxx>
      27             : #include <editeng/outlobj.hxx>
      28             : 
      29             : 
      30             : namespace oox {
      31             : 
      32             : namespace vml {
      33             : 
      34             : /// Interface to be implemented by the parent exporter that knows how to handle shape text.
      35             : class OOX_DLLPUBLIC VMLTextExport
      36             : {
      37             : public:
      38             :     virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
      39             :     virtual oox::drawingml::DrawingML& GetDrawingML() = 0;
      40             :     /// Write the contents of the textbox that is associated to this shape in VML format.
      41             :     virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
      42             : protected:
      43         482 :     VMLTextExport() {}
      44         482 :     virtual ~VMLTextExport() {}
      45             : };
      46             : 
      47             : class OOX_DLLPUBLIC VMLExport : public EscherEx
      48             : {
      49             :     /// Fast serializer to output the data
      50             :     ::sax_fastparser::FSHelperPtr m_pSerializer;
      51             : 
      52             :     /// Parent exporter, used for text callback.
      53             :     VMLTextExport* m_pTextExport;
      54             : 
      55             :     /// Anchoring.
      56             :     sal_Int16 m_eHOri, m_eVOri, m_eHRel, m_eVRel;
      57             : 
      58             :     /// Parent position.
      59             :     const Point* m_pNdTopLeft;
      60             : 
      61             :     /// The object we're exporting.
      62             :     const SdrObject* m_pSdrObject;
      63             : 
      64             :     /// Fill the shape attributes as they come.
      65             :     ::sax_fastparser::FastAttributeList *m_pShapeAttrList;
      66             : 
      67             :     /// Remember the shape type.
      68             :     sal_uInt32 m_nShapeType;
      69             : 
      70             :     /// Remember the shape flags.
      71             :     sal_uInt32 m_nShapeFlags;
      72             : 
      73             :     /// Remember style, the most important shape attribute ;-)
      74             :     OStringBuffer *m_pShapeStyle;
      75             : 
      76             :     /// Remember which shape types we had already written.
      77             :     bool *m_pShapeTypeWritten;
      78             : 
      79             : public:
      80             :                         VMLExport( ::sax_fastparser::FSHelperPtr pSerializer, VMLTextExport* pTextExport = 0 );
      81             :     virtual             ~VMLExport();
      82             : 
      83             :     ::sax_fastparser::FSHelperPtr
      84           0 :                         GetFS() { return m_pSerializer; }
      85             : 
      86             :     void SetFS(::sax_fastparser::FSHelperPtr pSerializer);
      87             : 
      88             :     /// Export the sdr object as VML.
      89             :     ///
      90             :     /// Call this when you need to export the object as VML.
      91             :     sal_uInt32 AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri = -1,
      92             :             sal_Int16 eVOri = -1, sal_Int16 eHRel = -1,
      93             :             sal_Int16 eVRel = -1, const Point* pNdTopLeft = 0, const bool bOOxmlExport = false );
      94             :     virtual void  AddSdrObjectVMLObject( const SdrObject& rObj) SAL_OVERRIDE;
      95             :     static bool IsWaterMarkShape(const OUString& rStr);
      96             : protected:
      97             :     /// Add an attribute to the generated <v:shape/> element.
      98             :     ///
      99             :     /// This should be called from within StartShape() to ensure that the
     100             :     /// added attribute is preserved.
     101             :     void                AddShapeAttribute( sal_Int32 nAttribute, const OString& sValue );
     102             : 
     103             :     using EscherEx::StartShape;
     104             :     using EscherEx::EndShape;
     105             : 
     106             :     /// Start the shape for which we just collected the information.
     107             :     ///
     108             :     /// Returns the element's tag number, -1 means we wrote nothing.
     109             :     virtual sal_Int32   StartShape();
     110             : 
     111             :     /// End the shape.
     112             :     ///
     113             :     /// The parameter is just what we got from StartShape().
     114             :     virtual void        EndShape( sal_Int32 nShapeElement );
     115             :     virtual void        Commit( EscherPropertyContainer& rProps, const Rectangle& rRect ) SAL_OVERRIDE;
     116             : 
     117             : private:
     118             : 
     119             :     virtual void OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance = 0 ) SAL_OVERRIDE;
     120             :     virtual void CloseContainer() SAL_OVERRIDE;
     121             : 
     122             :     virtual sal_uInt32 EnterGroup( const OUString& rShapeName, const Rectangle* pBoundRect = 0 ) SAL_OVERRIDE;
     123             :     virtual void LeaveGroup() SAL_OVERRIDE;
     124             : 
     125             :     virtual void AddShape( sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 nShapeId = 0 ) SAL_OVERRIDE;
     126             : 
     127             : private:
     128             :     /// Create an OString representing the id from a numerical id.
     129             :     static OString ShapeIdString( sal_uInt32 nId );
     130             : 
     131             :     /// Add flip X and\or flip Y
     132             :     void AddFlipXY( );
     133             : 
     134             :     /// Add starting and ending point of a line to the m_pShapeAttrList.
     135             :     void AddLineDimensions( const Rectangle& rRectangle );
     136             : 
     137             :     /// Add position and size to the OStringBuffer.
     138             :     void AddRectangleDimensions( OStringBuffer& rBuffer, const Rectangle& rRectangle, bool rbAbsolutePos = true );
     139             : };
     140             : 
     141             : } // namespace vml
     142             : 
     143             : } // namespace oox
     144             : 
     145             : #endif
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11