LCOV - code coverage report
Current view: top level - oox/inc/drawingml/chart - converterbase.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 6 6 100.0 %
Date: 2014-11-03 Functions: 50 73 68.5 %
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_CONVERTERBASE_HXX
      21             : #define INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
      22             : 
      23             : #include <drawingml/chart/chartcontextbase.hxx>
      24             : #include <drawingml/chart/objectformatter.hxx>
      25             : 
      26             : namespace com { namespace sun { namespace star {
      27             :     namespace awt { struct Rectangle; }
      28             :     namespace awt { struct Size; }
      29             :     namespace chart2 { class XChartDocument; }
      30             :     namespace chart2 { class XTitle; }
      31             :     namespace drawing { class XShape; }
      32             :     namespace uno { class XComponentContext; }
      33             : } } }
      34             : 
      35             : namespace oox { namespace core {
      36             :     class XmlFilterBase;
      37             : } }
      38             : 
      39             : namespace oox {
      40             : namespace drawingml {
      41             : namespace chart {
      42             : 
      43             : class ChartConverter;
      44             : struct ChartSpaceModel;
      45             : struct ConverterData;
      46             : 
      47             : 
      48             : 
      49             : const sal_Int32 API_PRIM_AXESSET = 0;
      50             : const sal_Int32 API_SECN_AXESSET = 1;
      51             : 
      52             : const sal_Int32 API_X_AXIS = 0;
      53             : const sal_Int32 API_Y_AXIS = 1;
      54             : const sal_Int32 API_Z_AXIS = 2;
      55             : 
      56             : 
      57             : 
      58        7128 : class ConverterRoot
      59             : {
      60             : public:
      61             :     explicit            ConverterRoot(
      62             :                             ::oox::core::XmlFilterBase& rFilter,
      63             :                             ChartConverter& rChartConverter,
      64             :                             const ChartSpaceModel& rChartModel,
      65             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& rxChartDoc,
      66             :                             const ::com::sun::star::awt::Size& rChartSize );
      67             :     virtual             ~ConverterRoot();
      68             : 
      69             :     /** Creates an instance for the passed service name, using the process service factory. */
      70             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
      71             :                         createInstance( const OUString& rServiceName ) const;
      72             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
      73             :                         getComponentContext() const;
      74             : 
      75             : protected:
      76             :     /** Returns the filter object of the imported/exported document. */
      77             :     ::oox::core::XmlFilterBase& getFilter() const;
      78             :     /** Returns the chart converter. */
      79             :     ChartConverter*     getChartConverter() const;
      80             :     /** Returns the API chart document model. */
      81             :     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >
      82             :                         getChartDocument() const;
      83             :     /** Returns the position and size of the chart shape in 1/100 mm. */
      84             :     const ::com::sun::star::awt::Size& getChartSize() const;
      85             :     /** Returns the object formatter. */
      86             :     ObjectFormatter&    getFormatter() const;
      87             : 
      88             :     /** Registers a title object and its layout data, needed for conversion of
      89             :         the title position using the old Chart1 API. */
      90             :     void                registerTitleLayout(
      91             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >& rxTitle,
      92             :                             const ModelRef< LayoutModel >& rxLayout, ObjectType eObjType,
      93             :                             sal_Int32 nMainIdx = -1, sal_Int32 nSubIdx = -1 );
      94             :     /** Converts the positions of the main title and all axis titles. */
      95             :     void                convertTitlePositions();
      96             : 
      97             : private:
      98             :     ::boost::shared_ptr< ConverterData > mxData;
      99             : };
     100             : 
     101             : 
     102             : 
     103             : /** Base class of all converter classes. Holds a reference to a model structure
     104             :     of the specified type.
     105             :  */
     106             : template< typename ModelType >
     107             : class ConverterBase : public ConverterRoot
     108             : {
     109             : public:
     110        1298 :     const ModelType& getModel() const { return mrModel; }
     111             : 
     112             : protected:
     113        7128 :     explicit            ConverterBase( const ConverterRoot& rParent, ModelType& rModel ) :
     114        7128 :                             ConverterRoot( rParent ), mrModel( rModel ) {}
     115        7128 :     virtual             ~ConverterBase() {}
     116             : 
     117             : protected:
     118             :     ModelType&          mrModel;
     119             : };
     120             : 
     121             : 
     122             : 
     123             : /** A layout converter calculates positions and sizes for various chart objects.
     124             :  */
     125             : class LayoutConverter : public ConverterBase< LayoutModel >
     126             : {
     127             : public:
     128             :     explicit            LayoutConverter( const ConverterRoot& rParent, LayoutModel& rModel );
     129             :     virtual             ~LayoutConverter();
     130             : 
     131             :     /** Tries to calculate the absolute position and size from the contained
     132             :         OOXML layout model. Returns true, if returned rectangle is valid. */
     133             :     bool                calcAbsRectangle( ::com::sun::star::awt::Rectangle& orRect ) const;
     134             : 
     135             :     /** Tries to set the position and size from the contained OOXML layout model.
     136             :         Returns true, if a manual position and size could be calculated. */
     137             :     bool                convertFromModel( PropertySet& rPropSet );
     138             : 
     139             :     /** Tries to set the position from the contained OOXML layout model.
     140             :         Returns true, if a manual position could be calculated. */
     141             :     bool                convertFromModel(
     142             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
     143             :                             double fRotationAngle );
     144          82 :     bool getAutoLayout(){return mrModel.mbAutoLayout;}
     145             : };
     146             : 
     147             : 
     148             : 
     149             : } // namespace chart
     150             : } // namespace drawingml
     151             : } // namespace oox
     152             : 
     153             : #endif
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10