LCOV - code coverage report
Current view: top level - oox/inc/drawingml/chart - chartdrawingfragment.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 4 75.0 %
Date: 2015-06-13 12:38:46 Functions: 3 4 75.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_DRAWINGML_CHART_CHARTDRAWINGFRAGMENT_HXX
      21             : #define INCLUDED_OOX_DRAWINGML_CHART_CHARTDRAWINGFRAGMENT_HXX
      22             : 
      23             : #include <oox/core/fragmenthandler2.hxx>
      24             : #include <oox/drawingml/shape.hxx>
      25             : 
      26             : namespace oox {
      27             : namespace drawingml {
      28             : namespace chart {
      29             : 
      30             : 
      31             : 
      32             : /** Relative shape position in a chart object. */
      33             : struct AnchorPosModel
      34             : {
      35             :     double              mfX;                /// X coordinate relative to chart object (0.0 to 1.0).
      36             :     double              mfY;                /// Y coordinate relative to chart object (0.0 to 1.0).
      37             : 
      38           2 :                  AnchorPosModel() : mfX( -1.0 ), mfY( -1.0 ) {}
      39           2 :     bool         isValid() const { return (0.0 <= mfX) && (mfX <= 1.0) && (0.0 <= mfY) && (mfY <= 1.0); }
      40             : };
      41             : 
      42             : 
      43             : 
      44             : /** Absolute shape size in a chart object (in EMUs). */
      45             : struct AnchorSizeModel : public EmuSize
      46             : {
      47           1 :                  AnchorSizeModel() : EmuSize( -1, -1 ) {}
      48           0 :     bool         isValid() const { return (Width >= 0) && (Height >= 0); }
      49             : };
      50             : 
      51             : 
      52             : 
      53             : /** Contains the position of a shape in the chart object. Supports different
      54             :     shape anchor modes (absolute, relative).
      55             :  */
      56             : class ShapeAnchor
      57             : {
      58             : public:
      59             :     explicit            ShapeAnchor( bool bRelSize );
      60             : 
      61             :     /** Imports the absolute anchor size from the cdr:ext element. */
      62             :     void                importExt( const AttributeList& rAttribs );
      63             :     /** Sets an the relative anchor position from the cdr:from or cdr:to element. */
      64             :     void                setPos( sal_Int32 nElement, sal_Int32 nParentContext, const OUString& rValue );
      65             : 
      66             :     /** Calculates the resulting shape anchor in EMUs. */
      67             :     EmuRectangle        calcAnchorRectEmu( const EmuRectangle& rChartRect ) const;
      68             : 
      69             : private:
      70             :     AnchorPosModel      maFrom;             /// Top-left position relative to chart object.
      71             :     AnchorPosModel      maTo;               /// Bottom-right position relative to chart object.
      72             :     AnchorSizeModel     maSize;             /// Shape size, if anchor has absolute size.
      73             :     bool                mbRelSize;          /// True = relative size, false = absolute size.
      74             : };
      75             : 
      76             : typedef std::shared_ptr< ShapeAnchor > ShapeAnchorRef;
      77             : 
      78             : 
      79             : 
      80             : /** Handler for a chart drawing fragment (c:userShapes root element).
      81             :  */
      82             : class ChartDrawingFragment : public ::oox::core::FragmentHandler2
      83             : {
      84             : public:
      85             :     explicit            ChartDrawingFragment(
      86             :                             ::oox::core::XmlFilterBase& rFilter,
      87             :                             const OUString& rFragmentPath,
      88             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxDrawPage,
      89             :                             const ::com::sun::star::awt::Size& rChartSize,
      90             :                             const ::com::sun::star::awt::Point& rShapesOffset,
      91             :                             bool bOleSupport );
      92             :     virtual             ~ChartDrawingFragment();
      93             : 
      94             :     virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
      95             :     virtual void        onCharacters( const OUString& rChars ) SAL_OVERRIDE;
      96             :     virtual void        onEndElement() SAL_OVERRIDE;
      97             : 
      98             : private:
      99             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
     100             :                         mxDrawPage;             /// Drawing page of this sheet.
     101             :     ::oox::drawingml::ShapePtr mxShape;         /// Current top-level shape.
     102             :     ShapeAnchorRef      mxAnchor;               /// Current anchor of top-level shape.
     103             :     EmuRectangle        maChartRectEmu;         /// Position and size of the chart object for embedded shapes (in EMUs).
     104             :     bool                mbOleSupport;           /// True = allow to insert OLE objects into the drawing page.
     105             : };
     106             : 
     107             : 
     108             : 
     109             : } // namespace chart
     110             : } // namespace drawingml
     111             : } // namespace oox
     112             : 
     113             : #endif
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11