LCOV - code coverage report
Current view: top level - sw/source/core/doc - DocumentChartDataProviderManager.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 35 68.6 %
Date: 2015-06-13 12:38:46 Functions: 8 8 100.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 <DocumentChartDataProviderManager.hxx>
      21             : 
      22             : #include <doc.hxx>
      23             : #include <IDocumentLayoutAccess.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <swtable.hxx>
      26             : #include <unochart.hxx>
      27             : #include <frmfmt.hxx>
      28             : #include <ndole.hxx>
      29             : #include <com/sun/star/chart2/XChartDocument.hpp>
      30             : 
      31             : 
      32             : using namespace com::sun::star;
      33             : using namespace com::sun::star::uno;
      34             : 
      35             : namespace sw {
      36             : 
      37        2958 : DocumentChartDataProviderManager::DocumentChartDataProviderManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
      38             :                                                                                         maChartDataProviderImplRef(),
      39        2958 :                                                                                         mpChartControllerHelper( 0 )
      40             : {
      41             : 
      42        2958 : }
      43             : 
      44        2958 : SwChartDataProvider * DocumentChartDataProviderManager::GetChartDataProvider( bool bCreate ) const
      45             : {
      46             :     // since there must be only one instance of this object per document
      47             :     // we need a mutex here
      48        2958 :     SolarMutexGuard aGuard;
      49             : 
      50        2958 :     if (bCreate && !maChartDataProviderImplRef.is())
      51             :     {
      52           3 :         maChartDataProviderImplRef = new SwChartDataProvider( & m_rDoc );
      53             :     }
      54        2958 :     return maChartDataProviderImplRef.get();
      55             : }
      56             : 
      57           1 : void DocumentChartDataProviderManager::CreateChartInternalDataProviders( const SwTable *pTable )
      58             : {
      59           1 :     if (pTable)
      60             :     {
      61           1 :         OUString aName( pTable->GetFrameFormat()->GetName() );
      62             :         SwOLENode *pONd;
      63             :         SwStartNode *pStNd;
      64           2 :         SwNodeIndex aIdx( *m_rDoc.GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
      65           2 :         while (0 != (pStNd = aIdx.GetNode().GetStartNode()))
      66             :         {
      67           0 :             ++aIdx;
      68           0 :             if( 0 != ( pONd = aIdx.GetNode().GetOLENode() ) &&
      69           0 :                 aName == pONd->GetChartTableName() /* OLE node is chart? */ &&
      70           0 :                 0 != (pONd->getLayoutFrm( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() )) /* chart frame is not hidden */ )
      71             :             {
      72           0 :                 uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
      73           0 :                 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
      74             :                 {
      75           0 :                     uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
      76           0 :                     if (xChart.is())
      77           0 :                         xChart->createInternalDataProvider( sal_True );
      78             : 
      79             :                     // there may be more than one chart for each table thus we need to continue the loop...
      80           0 :                 }
      81             :             }
      82           0 :             aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
      83           1 :         }
      84             :     }
      85           1 : }
      86             : 
      87        2947 : SwChartLockController_Helper & DocumentChartDataProviderManager::GetChartControllerHelper()
      88             : {
      89        2947 :     if (!mpChartControllerHelper)
      90             :     {
      91        2947 :         mpChartControllerHelper = new SwChartLockController_Helper( & m_rDoc );
      92             :     }
      93        2947 :     return *mpChartControllerHelper;
      94             : }
      95             : 
      96        8847 : DocumentChartDataProviderManager::~DocumentChartDataProviderManager()
      97             : {
      98             :     // clean up chart related structures...
      99             :     // Note: the chart data provider gets already disposed in ~SwDocShell
     100             :     // since all UNO API related functionality requires an existing SwDocShell
     101             :     // this assures that dipose gets called if there is need for it.
     102        2949 :     maChartDataProviderImplRef.clear();
     103        2949 :     delete mpChartControllerHelper;
     104        5898 : }
     105             : 
     106         177 : }
     107             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11