LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/oox/vml - vmldrawing.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 6 66.7 %
Date: 2012-12-27 Functions: 4 8 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 OOX_VML_VMLDRAWING_HXX
      21             : #define OOX_VML_VMLDRAWING_HXX
      22             : 
      23             : #include <map>
      24             : #include <memory>
      25             : #include <vector>
      26             : #include <oox/ole/axcontrol.hxx>
      27             : #include <oox/ole/oleobjecthelper.hxx>
      28             : #include <oox/vml/vmlshapecontainer.hxx>
      29             : #include "oox/dllapi.h"
      30             : 
      31             : namespace com { namespace sun { namespace star {
      32             :     namespace awt { struct Rectangle; }
      33             :     namespace awt { class XControlModel; }
      34             :     namespace drawing { class XDrawPage; }
      35             :     namespace drawing { class XShape; }
      36             :     namespace drawing { class XShapes; }
      37             : } } }
      38             : 
      39             : namespace oox {
      40             :     namespace core { class XmlFilterBase; }
      41             :     namespace ole { class EmbeddedControl; }
      42             : }
      43             : 
      44             : namespace oox {
      45             : namespace vml {
      46             : 
      47             : class ShapeBase;
      48             : struct ClientData;
      49             : 
      50             : // ============================================================================
      51             : 
      52             : /** Enumerates different types of VML drawings. */
      53             : enum DrawingType
      54             : {
      55             :     VMLDRAWING_WORD,            ///< Word: One shape per drawing.
      56             :     VMLDRAWING_EXCEL,           ///< Excel: OLE objects are part of VML.
      57             :     VMLDRAWING_POWERPOINT       ///< PowerPoint: OLE objects are part of DrawingML.
      58             : };
      59             : 
      60             : // ============================================================================
      61             : 
      62             : /** Contains information about an OLE object embedded in a draw page. */
      63           0 : struct OOX_DLLPUBLIC OleObjectInfo : public ::oox::ole::OleObjectInfo
      64             : {
      65             :     ::rtl::OUString     maShapeId;          ///< Shape identifier for shape lookup.
      66             :     ::rtl::OUString     maName;             ///< Programmatical name of the OLE object.
      67             :     bool                mbAutoLoad;
      68             :     const bool          mbDmlShape;         ///< True = DrawingML shape (PowerPoint), false = VML shape (Excel/Word).
      69             : 
      70             :     explicit            OleObjectInfo( bool bDmlShape = false );
      71             : 
      72             :     /** Sets the string representation of the passed numeric shape identifier. */
      73             :     void                setShapeId( sal_Int32 nShapeId );
      74             : };
      75             : 
      76             : // =========================================/===================================
      77             : 
      78             : /** Contains information about a form control embedded in a draw page. */
      79           0 : struct OOX_DLLPUBLIC ControlInfo
      80             : {
      81             :     ::rtl::OUString     maShapeId;          ///< Shape identifier for shape lookup.
      82             :     ::rtl::OUString     maFragmentPath;     ///< Path to the fragment describing the form control properties.
      83             :     ::rtl::OUString     maName;             ///< Programmatical name of the form control.
      84             : 
      85             :     explicit            ControlInfo();
      86             : 
      87             :     /** Sets the string representation of the passed numeric shape identifier. */
      88             :     void                setShapeId( sal_Int32 nShapeId );
      89             : };
      90             : 
      91             : // ============================================================================
      92             : 
      93             : /** Represents the collection of VML shapes for a complete draw page. */
      94             : class OOX_DLLPUBLIC Drawing
      95             : {
      96             : public:
      97             :     explicit            Drawing(
      98             :                             ::oox::core::XmlFilterBase& rFilter,
      99             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage,
     100             :                             DrawingType eType );
     101             : 
     102             :     virtual             ~Drawing();
     103             : 
     104             :     /** Returns the filter object that imports/exports this VML drawing. */
     105          96 :     inline ::oox::core::XmlFilterBase& getFilter() const { return mrFilter; }
     106             :     /** Returns the application type containing the drawing. */
     107          38 :     inline DrawingType  getType() const { return meType; }
     108             :     /** Returns read/write access to the container of shapes and templates. */
     109         117 :     inline ShapeContainer& getShapes() { return *mxShapes; }
     110             :     /** Returns read access to the container of shapes and templates. */
     111           1 :     inline const ShapeContainer& getShapes() const { return *mxShapes; }
     112             :     /** Returns the form object used to process ActiveX form controls. */
     113             :     ::oox::ole::EmbeddedForm& getControlForm() const;
     114             : 
     115             :     /** Registers a block of shape identifiers reserved by this drawing. Block
     116             :         size is 1024, shape identifiers are one-based (block 1 => 1025-2048). */
     117             :     void                registerBlockId( sal_Int32 nBlockId );
     118             :     /** Registers the passed embedded OLE object. The related shape will then
     119             :         load the OLE object data from the specified fragment. */
     120             :     void                registerOleObject( const OleObjectInfo& rOleObject );
     121             :     /** Registers the passed embedded form control. The related shape will then
     122             :         load the control properties from the specified fragment. */
     123             :     void                registerControl( const ControlInfo& rControl );
     124             : 
     125             :     /** Final processing after import of the fragment. */
     126             :     void                finalizeFragmentImport();
     127             : 
     128             :     /** Creates and inserts all UNO shapes into the draw page. The virtual
     129             :         function notifyXShapeInserted() will be called for each new shape. */
     130             :     void                convertAndInsert() const;
     131             : 
     132             :     /** Returns the local shape index from the passed global shape identifier. */
     133             :     sal_Int32           getLocalShapeIndex( const ::rtl::OUString& rShapeId ) const;
     134             :     /** Returns the registered info structure for an OLE object, if extant. */
     135             :     const OleObjectInfo* getOleObjectInfo( const ::rtl::OUString& rShapeId ) const;
     136             :     /** Returns the registered info structure for a form control, if extant. */
     137             :     const ControlInfo*  getControlInfo( const ::rtl::OUString& rShapeId ) const;
     138             : 
     139             :     /** Creates a new UNO shape object, inserts it into the passed UNO shape
     140             :         container, and sets the shape position and size. */
     141             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     142             :                         createAndInsertXShape(
     143             :                             const ::rtl::OUString& rService,
     144             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     145             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
     146             : 
     147             :     /** Creates a new UNO shape object for a form control, inserts the control
     148             :         model into the form, and the shape into the passed UNO shape container. */
     149             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     150             :                         createAndInsertXControlShape(
     151             :                             const ::oox::ole::EmbeddedControl& rControl,
     152             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     153             :                             const ::com::sun::star::awt::Rectangle& rShapeRect,
     154             :                             sal_Int32& rnCtrlIndex ) const;
     155             : 
     156             :     /** Derived classes may disable conversion of specific shapes. */
     157             :     virtual bool        isShapeSupported( const ShapeBase& rShape ) const;
     158             : 
     159             :     /** Derived classes may return additional base names for automatic shape
     160             :         name creation. */
     161             :     virtual ::rtl::OUString getShapeBaseName( const ShapeBase& rShape ) const;
     162             : 
     163             :     /** Derived classes may calculate the shape rectangle from a non-standard
     164             :         anchor information string. */
     165             :     virtual bool        convertClientAnchor(
     166             :                             ::com::sun::star::awt::Rectangle& orShapeRect,
     167             :                             const ::rtl::OUString& rShapeAnchor ) const;
     168             : 
     169             :     /** Derived classes create a UNO shape according to the passed shape model.
     170             :         Called for shape models that specify being under host control. */
     171             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     172             :                         createAndInsertClientXShape(
     173             :                             const ShapeBase& rShape,
     174             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     175             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
     176             : 
     177             :     /** Derived classes may want to know that a UNO shape has been inserted.
     178             :         Will be called from the convertAndInsert() implementation.
     179             :         @param bGroupChild  True = inserted into a group shape,
     180             :             false = inserted directly into this drawing. */
     181             :     virtual void        notifyXShapeInserted(
     182             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
     183             :                             const ::com::sun::star::awt::Rectangle& rShapeRect,
     184             :                             const ShapeBase& rShape, bool bGroupChild );
     185             : 
     186             : private:
     187             :     typedef ::std::vector< sal_Int32 >                      BlockIdVector;
     188             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     189             :     typedef ::std::auto_ptr< ::oox::ole::EmbeddedForm >     EmbeddedFormPtr;
     190             :     typedef ::std::auto_ptr< ShapeContainer >               ShapeContainerPtr;
     191             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     192             :     typedef ::std::map< ::rtl::OUString, OleObjectInfo >    OleObjectInfoMap;
     193             :     typedef ::std::map< ::rtl::OUString, ControlInfo >      ControlInfoMap;
     194             : 
     195             :     ::oox::core::XmlFilterBase& mrFilter;   ///< Filter object that imports/exports the VML drawing.
     196             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
     197             :                         mxDrawPage;         ///< UNO draw page used to insert the shapes.
     198             :     mutable EmbeddedFormPtr mxCtrlForm;     ///< The control form used to process embedded controls.
     199             :     mutable BlockIdVector maBlockIds;       ///< Block identifiers used by this drawing.
     200             :     ShapeContainerPtr   mxShapes;           ///< All shapes and shape templates.
     201             :     OleObjectInfoMap    maOleObjects;       ///< Info about all embedded OLE objects, mapped by shape id.
     202             :     ControlInfoMap      maControls;         ///< Info about all embedded form controls, mapped by control name.
     203             :     const DrawingType   meType;             ///< Application type containing the drawing.
     204             : };
     205             : 
     206             : // ============================================================================
     207             : 
     208             : } // namespace vml
     209             : } // namespace oox
     210             : 
     211             : #endif
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10