LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - Chart2ModelContact.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 138 0.0 %
Date: 2014-04-14 Functions: 0 26 0.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             : #include "Chart2ModelContact.hxx"
      21             : #include "ChartModelHelper.hxx"
      22             : #include "LegendHelper.hxx"
      23             : #include "CommonConverters.hxx"
      24             : #include "macros.hxx"
      25             : #include "servicenames.hxx"
      26             : #include "ObjectIdentifier.hxx"
      27             : #include "chartview/ExplicitValueProvider.hxx"
      28             : #include "chartview/DrawModelWrapper.hxx"
      29             : #include "AxisHelper.hxx"
      30             : #include "DiagramHelper.hxx"
      31             : 
      32             : #include "ChartModel.hxx"
      33             : 
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::chart2;
      36             : 
      37             : using ::com::sun::star::uno::Reference;
      38             : using ::com::sun::star::uno::Sequence;
      39             : 
      40             : namespace chart
      41             : {
      42             : namespace wrapper
      43             : {
      44             : 
      45           0 : Chart2ModelContact::Chart2ModelContact(
      46             :     const Reference< uno::XComponentContext > & xContext ) :
      47             :         m_xContext( xContext ),
      48             :         m_xChartModel( 0 ),
      49             :         mpModel( NULL ),
      50           0 :         m_xChartView(0)
      51             : {
      52           0 : }
      53             : 
      54           0 : Chart2ModelContact::~Chart2ModelContact()
      55             : {
      56           0 :     this->clear();
      57           0 : }
      58             : 
      59           0 : void Chart2ModelContact::setModel( const ::com::sun::star::uno::Reference<
      60             :                        ::com::sun::star::frame::XModel >& xChartModel )
      61             : {
      62           0 :     this->clear();
      63           0 :     m_xChartModel = xChartModel;
      64           0 :     mpModel = dynamic_cast<ChartModel*>(xChartModel.get());
      65           0 :     uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartModel, uno::UNO_QUERY );
      66           0 :     if( xTableFactory.is() )
      67             :     {
      68           0 :         uno::Reference< container::XNameContainer > xDashTable( xTableFactory->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY );
      69           0 :         uno::Reference< container::XNameContainer > xGradientTable( xTableFactory->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
      70           0 :         uno::Reference< container::XNameContainer > xHatchTable( xTableFactory->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY );
      71           0 :         uno::Reference< container::XNameContainer > xBitmapTable( xTableFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
      72           0 :         uno::Reference< container::XNameContainer > xTransparencyGradientTable( xTableFactory->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY );
      73           0 :         m_aTableMap["LineDashName"] = xDashTable;
      74           0 :         m_aTableMap["FillGradientName"] = xGradientTable;
      75           0 :         m_aTableMap["FillHatchName"] = xHatchTable;
      76           0 :         m_aTableMap["FillBitmapName"] = xBitmapTable;
      77           0 :         m_aTableMap["FillTransparenceGradientName"] = xTransparencyGradientTable;
      78           0 :     }
      79           0 : }
      80             : 
      81           0 : void Chart2ModelContact::clear()
      82             : {
      83           0 :     m_xChartModel = uno::WeakReference< frame::XModel >(0);
      84           0 :     m_xChartView.clear();
      85           0 :     mpModel = NULL;
      86           0 : }
      87             : 
      88           0 : Reference< frame::XModel > Chart2ModelContact::getChartModel() const
      89             : {
      90           0 :     return Reference< frame::XModel >( m_xChartModel.get(), uno::UNO_QUERY );
      91             : }
      92             : 
      93           0 : ChartModel* Chart2ModelContact::getModel() const
      94             : {
      95           0 :     return mpModel;
      96             : }
      97             : 
      98           0 : Reference< chart2::XChartDocument > Chart2ModelContact::getChart2Document() const
      99             : {
     100           0 :     return Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY );
     101             : }
     102             : 
     103           0 : Reference< chart2::XDiagram > Chart2ModelContact::getChart2Diagram() const
     104             : {
     105           0 :     return ChartModelHelper::findDiagram( this->getChartModel() );
     106             : }
     107             : 
     108           0 : uno::Reference< lang::XUnoTunnel > Chart2ModelContact::getChartView() const
     109             : {
     110           0 :     if(!m_xChartView.is())
     111             :     {
     112             :         // get the chart view
     113           0 :         Reference<frame::XModel> xModel(m_xChartModel);
     114           0 :         uno::Reference< lang::XMultiServiceFactory > xFact( xModel, uno::UNO_QUERY );
     115           0 :         if( xFact.is() )
     116           0 :             m_xChartView = Reference< lang::XUnoTunnel >( xFact->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
     117             :     }
     118           0 :     return m_xChartView;
     119             : }
     120             : 
     121           0 : ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const
     122             : {
     123           0 :     getChartView();
     124           0 :     if(!m_xChartView.is())
     125           0 :         return 0;
     126             : 
     127             :     //obtain the ExplicitValueProvider from the chart view
     128           0 :     ExplicitValueProvider* pProvider = reinterpret_cast<ExplicitValueProvider*>(m_xChartView->getSomething(
     129           0 :         ExplicitValueProvider::getUnoTunnelId() ));
     130           0 :     return pProvider;
     131             : }
     132             : 
     133           0 : uno::Reference< drawing::XDrawPage > Chart2ModelContact::getDrawPage()
     134             : {
     135           0 :     uno::Reference< drawing::XDrawPage > xResult;
     136           0 :     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     137           0 :     if( pProvider )
     138             :     {
     139           0 :         xResult.set( pProvider->getDrawModelWrapper()->getMainDrawPage() );
     140             :     }
     141           0 :     return xResult;
     142             : }
     143             : 
     144           0 : sal_Bool Chart2ModelContact::getExplicitValuesForAxis(
     145             :     const Reference< XAxis > & xAxis,
     146             :     ExplicitScaleData &  rOutExplicitScale,
     147             :     ExplicitIncrementData & rOutExplicitIncrement )
     148             : {
     149           0 :     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     150           0 :     if( pProvider )
     151             :     {
     152             :         return pProvider->getExplicitValuesForAxis(
     153           0 :             xAxis, rOutExplicitScale, rOutExplicitIncrement );
     154             :     }
     155           0 :     return sal_False;
     156             : }
     157             : 
     158           0 : sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForAxis(
     159             :             const Reference< chart2::XAxis >& xAxis )
     160             : {
     161             :     Reference< chart2::XCoordinateSystem > xCooSys(
     162             :         AxisHelper::getCoordinateSystemOfAxis(
     163           0 :               xAxis, ChartModelHelper::findDiagram( m_xChartModel ) ) );
     164             : 
     165             :     return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( xAxis, xCooSys
     166           0 :               , Reference< util::XNumberFormatsSupplier >( m_xChartModel.get(), uno::UNO_QUERY ) );
     167             : }
     168             : 
     169           0 : sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForSeries(
     170             :             const Reference< chart2::XDataSeries >& xSeries )
     171             : {
     172             :     return ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
     173             :         uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ),
     174             :         xSeries,
     175             :         -1 /*-1 for whole series*/,
     176             :         ChartModelHelper::findDiagram( m_xChartModel )
     177           0 :         );
     178             : }
     179             : 
     180           0 : awt::Size Chart2ModelContact::GetPageSize() const
     181             : {
     182           0 :     return ChartModelHelper::getPageSize(m_xChartModel);
     183             : }
     184             : 
     185           0 : awt::Rectangle Chart2ModelContact::SubstractAxisTitleSizes( const awt::Rectangle& rPositionRect )
     186             : {
     187             :     awt::Rectangle aRect = ExplicitValueProvider::substractAxisTitleSizes(
     188           0 :         *mpModel, getChartView(), rPositionRect );
     189           0 :     return aRect;
     190             : }
     191             : 
     192           0 : awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const
     193             : {
     194           0 :     awt::Rectangle aRect( GetDiagramRectangleIncludingAxes() );
     195             : 
     196             :     //add axis title sizes to the diagram size
     197             :     aRect = ExplicitValueProvider::addAxisTitleSizes(
     198           0 :         *mpModel, getChartView(), aRect );
     199             : 
     200           0 :     return aRect;
     201             : }
     202             : 
     203           0 : awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const
     204             : {
     205           0 :     awt::Rectangle aRect(0,0,0,0);
     206           0 :     uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
     207             : 
     208           0 :     if( DiagramPositioningMode_INCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ) )
     209           0 :         aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel);
     210             :     else
     211             :     {
     212           0 :         ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     213           0 :         if( pProvider )
     214           0 :             aRect = pProvider->getRectangleOfObject("PlotAreaIncludingAxes");
     215             :     }
     216           0 :     return aRect;
     217             : }
     218             : 
     219           0 : awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const
     220             : {
     221           0 :     awt::Rectangle aRect(0,0,0,0);
     222           0 :     uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
     223             : 
     224           0 :     if( DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ) )
     225           0 :         aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel);
     226             :     else
     227             :     {
     228           0 :         ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     229           0 :         if( pProvider )
     230           0 :             aRect = pProvider->getDiagramRectangleExcludingAxes();
     231             :     }
     232           0 :     return aRect;
     233             : }
     234             : 
     235           0 : awt::Size Chart2ModelContact::GetLegendSize() const
     236             : {
     237           0 :     awt::Size aSize;
     238           0 :     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     239           0 :     if( pProvider )
     240             :     {
     241           0 :         uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *mpModel ) );
     242           0 :         OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, *mpModel ) );
     243           0 :         aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
     244             :     }
     245           0 :     return aSize;
     246             : }
     247             : 
     248           0 : awt::Point Chart2ModelContact::GetLegendPosition() const
     249             : {
     250           0 :     awt::Point aPoint;
     251           0 :     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     252           0 :     if( pProvider )
     253             :     {
     254           0 :         uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *mpModel ) );
     255           0 :         OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, *mpModel ) );
     256           0 :         aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
     257             :     }
     258           0 :     return aPoint;
     259             : }
     260             : 
     261           0 : awt::Size Chart2ModelContact::GetTitleSize( const uno::Reference<
     262             :         ::com::sun::star::chart2::XTitle > & xTitle ) const
     263             : {
     264           0 :     awt::Size aSize;
     265           0 :     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     266           0 :     if( pProvider && xTitle.is() )
     267             :     {
     268           0 :         OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) );
     269           0 :         aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
     270             :     }
     271           0 :     return aSize;
     272             : }
     273             : 
     274           0 : awt::Point Chart2ModelContact::GetTitlePosition( const uno::Reference<
     275             :         ::com::sun::star::chart2::XTitle > & xTitle ) const
     276             : {
     277           0 :     awt::Point aPoint;
     278           0 :     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     279           0 :     if( pProvider && xTitle.is() )
     280             :     {
     281           0 :         OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) );
     282           0 :         aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
     283             :     }
     284           0 :     return aPoint;
     285             : }
     286             : 
     287           0 : awt::Size Chart2ModelContact::GetAxisSize( const uno::Reference<
     288             :         ::com::sun::star::chart2::XAxis > & xAxis ) const
     289             : {
     290           0 :     awt::Size aSize;
     291           0 :     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     292           0 :     if( pProvider && xAxis.is() )
     293             :     {
     294           0 :         OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel ) );
     295           0 :         aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
     296             :     }
     297           0 :     return aSize;
     298             : }
     299             : 
     300           0 : awt::Point Chart2ModelContact::GetAxisPosition( const uno::Reference<
     301             :         ::com::sun::star::chart2::XAxis > & xAxis ) const
     302             : {
     303           0 :     awt::Point aPoint;
     304           0 :     ExplicitValueProvider* pProvider( getExplicitValueProvider() );
     305           0 :     if( pProvider && xAxis.is() )
     306             :     {
     307           0 :         OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel ) );
     308           0 :         aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
     309             :     }
     310           0 :     return aPoint;
     311             : }
     312             : 
     313             : } //  namespace wrapper
     314             : } //  namespace chart
     315             : 
     316             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10