LCOV - code coverage report
Current view: top level - chart2/source/inc - InternalDataProvider.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1 0.0 %
Date: 2014-04-14 Functions: 0 1 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             : #ifndef INCLUDED_CHART2_SOURCE_INC_INTERNALDATAPROVIDER_HXX
      20             : #define INCLUDED_CHART2_SOURCE_INC_INTERNALDATAPROVIDER_HXX
      21             : 
      22             : #include "InternalData.hxx"
      23             : 
      24             : #include <com/sun/star/lang/XServiceInfo.hpp>
      25             : #include <com/sun/star/chart/XDateCategories.hpp>
      26             : #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
      27             : #include <com/sun/star/chart2/data/XDataProvider.hpp>
      28             : #include <com/sun/star/chart2/XInternalDataProvider.hpp>
      29             : #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
      30             : #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
      31             : #include <com/sun/star/chart2/XChartDocument.hpp>
      32             : #include <com/sun/star/lang/XInitialization.hpp>
      33             : #include <com/sun/star/util/XCloneable.hpp>
      34             : #include <cppuhelper/implbase7.hxx>
      35             : #include "ServiceMacros.hxx"
      36             : 
      37             : #include "CachedDataSequence.hxx"
      38             : 
      39             : #include <map>
      40             : 
      41             : namespace chart
      42             : {
      43             : 
      44             : namespace impl
      45             : {
      46             : 
      47             : typedef ::cppu::WeakImplHelper7<
      48             :         ::com::sun::star::chart2::XInternalDataProvider,
      49             :         ::com::sun::star::chart2::data::XRangeXMLConversion,
      50             :         ::com::sun::star::chart2::XAnyDescriptionAccess,
      51             :         ::com::sun::star::chart::XDateCategories,
      52             :         ::com::sun::star::util::XCloneable,
      53             :         ::com::sun::star::lang::XInitialization,
      54             :         ::com::sun::star::lang::XServiceInfo >
      55             :     InternalDataProvider_Base;
      56             : }
      57             : 
      58             : /** Data provider that handles data internally.  This is used for charts with
      59             :     their own data.
      60             : 
      61             :     <p>The format for single ranges is "categories|label n|n" where n is a
      62             :     non-negative number. Meaning return all categories, the label of sequence n,
      63             :     or the data of sequence n.</p>
      64             : 
      65             :     <p>The format for a complete range is "all". (Do we need more than
      66             :     that?)</p>
      67             :  */
      68             : class InternalDataProvider :
      69             :         public impl::InternalDataProvider_Base
      70             : {
      71             : public:
      72             :     explicit InternalDataProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _xContext);
      73             : 
      74             :     // #i120559# allow handing over a default for data orientation
      75             :     // (DataInColumns) that will be used when no data is available
      76             :     explicit InternalDataProvider(
      77             :         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc,
      78             :         bool bConnectToModel,
      79             :         bool bDefaultDataInColumns );
      80             :     explicit InternalDataProvider( const InternalDataProvider & rOther );
      81             :     virtual ~InternalDataProvider();
      82             : 
      83             :     void createDefaultData();
      84             : 
      85             :     /// declare XServiceInfo methods
      86             :     APPHELPER_XSERVICEINFO_DECL()
      87           0 :     APPHELPER_SERVICE_FACTORY_HELPER(InternalDataProvider)
      88             : 
      89             :     // ____ XInternalDataProvider ____
      90             :     virtual sal_Bool SAL_CALL hasDataByRangeRepresentation( const OUString& aRange )
      91             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      92             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
      93             :         getDataByRangeRepresentation( const OUString& aRange )
      94             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      95             :     virtual void SAL_CALL setDataByRangeRepresentation(
      96             :         const OUString& aRange,
      97             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aNewData )
      98             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      99             :     virtual void SAL_CALL insertSequence( ::sal_Int32 nAfterIndex )
     100             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     101             :     virtual void SAL_CALL deleteSequence( ::sal_Int32 nAtIndex )
     102             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     103             :     virtual void SAL_CALL appendSequence()
     104             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             :     virtual void SAL_CALL insertComplexCategoryLevel( ::sal_Int32 nLevel )
     106             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     107             :     virtual void SAL_CALL deleteComplexCategoryLevel( ::sal_Int32 nLevel )
     108             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     109             :     virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
     110             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     111             :     virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
     112             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             :     virtual void SAL_CALL swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
     114             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             :     virtual void SAL_CALL registerDataSequenceForChanges(
     116             :         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xSeq )
     117             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     118             : 
     119             :     // ____ XDataProvider (base of XInternalDataProvider) ____
     120             :     virtual sal_Bool SAL_CALL createDataSourcePossible(
     121             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
     122             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > SAL_CALL createDataSource(
     124             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
     125             :         throw (::com::sun::star::lang::IllegalArgumentException,
     126             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(
     128             :         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource )
     129             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             :     virtual sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(
     131             :         const OUString& aRangeRepresentation )
     132             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(
     134             :         const OUString& aRangeRepresentation )
     135             :         throw (::com::sun::star::lang::IllegalArgumentException,
     136             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     137             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
     138             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     139             : 
     140             :     // ____ XRangeXMLConversion ____
     141             :     virtual OUString SAL_CALL convertRangeToXML(
     142             :         const OUString& aRangeRepresentation )
     143             :         throw (::com::sun::star::lang::IllegalArgumentException,
     144             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             :     virtual OUString SAL_CALL convertRangeFromXML(
     146             :         const OUString& aXMLRange )
     147             :         throw (::com::sun::star::lang::IllegalArgumentException,
     148             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     149             : 
     150             :     // ____ XDateCategories ____
     151             :     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     152             :     virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     153             : 
     154             :     // ____ XAnyDescriptionAccess ____
     155             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
     156             :         getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     157             :     virtual void SAL_CALL setAnyRowDescriptions(
     158             :         const ::com::sun::star::uno::Sequence<
     159             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions )
     160             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     161             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
     162             :         getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     163             :     virtual void SAL_CALL setAnyColumnDescriptions(
     164             :         const ::com::sun::star::uno::Sequence<
     165             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions )
     166             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             : 
     168             :     // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____
     169             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > SAL_CALL
     170             :         getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             :     virtual void SAL_CALL setComplexRowDescriptions(
     172             :         const ::com::sun::star::uno::Sequence<
     173             :         ::com::sun::star::uno::Sequence< OUString > >& aRowDescriptions )
     174             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     175             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > SAL_CALL
     176             :         getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     177             :     virtual void SAL_CALL setComplexColumnDescriptions(
     178             :         const ::com::sun::star::uno::Sequence<
     179             :         ::com::sun::star::uno::Sequence< OUString > >& aColumnDescriptions )
     180             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     181             : 
     182             :     // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
     183             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()
     184             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     185             :     virtual void SAL_CALL setData(
     186             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData )
     187             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     188             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getRowDescriptions()
     189             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     190             :     virtual void SAL_CALL setRowDescriptions(
     191             :         const ::com::sun::star::uno::Sequence< OUString >& aRowDescriptions )
     192             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     193             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getColumnDescriptions()
     194             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     195             :     virtual void SAL_CALL setColumnDescriptions(
     196             :         const ::com::sun::star::uno::Sequence< OUString >& aColumnDescriptions )
     197             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     198             : 
     199             :     // ____ XChartData (base of XChartDataArray) ____
     200             :     virtual void SAL_CALL addChartDataChangeEventListener(
     201             :         const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
     202             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             :     virtual void SAL_CALL removeChartDataChangeEventListener(
     204             :         const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
     205             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     206             :     virtual double SAL_CALL getNotANumber()
     207             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     208             :     virtual sal_Bool SAL_CALL isNotANumber(
     209             :         double nNumber )
     210             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     211             : 
     212             :     // ____ XCloneable ____
     213             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
     214             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     215             :     // ::com::sun::star::lang::XInitialization:
     216             :     virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments)
     217             :         throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     218             : 
     219             : private:
     220             :     void lcl_addDataSequenceToMap(
     221             :         const OUString & rRangeRepresentation,
     222             :         const ::com::sun::star::uno::Reference<
     223             :             ::com::sun::star::chart2::data::XDataSequence > & xSequence );
     224             : 
     225             :     ::com::sun::star::uno::Reference<
     226             :             ::com::sun::star::chart2::data::XDataSequence >
     227             :         lcl_createDataSequenceAndAddToMap( const OUString & rRangeRepresentation,
     228             :                                        const OUString & rRole );
     229             :     ::com::sun::star::uno::Reference<
     230             :             ::com::sun::star::chart2::data::XDataSequence >
     231             :         lcl_createDataSequenceAndAddToMap( const OUString & rRangeRepresentation );
     232             : 
     233             :     void lcl_deleteMapReferences( const OUString & rRangeRepresentation );
     234             : 
     235             :     void lcl_adaptMapReferences(
     236             :         const OUString & rOldRangeRepresentation,
     237             :         const OUString & rNewRangeRepresentation );
     238             : 
     239             :     void lcl_increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
     240             :     void lcl_decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
     241             : 
     242             :     typedef ::std::multimap< OUString,
     243             :             ::com::sun::star::uno::WeakReference< ::com::sun::star::chart2::data::XDataSequence > >
     244             :         tSequenceMap;
     245             :     typedef ::std::pair< tSequenceMap::iterator, tSequenceMap::iterator > tSequenceMapRange;
     246             :     typedef ::std::pair< tSequenceMap::const_iterator, tSequenceMap::const_iterator > tConstSequenceMapRange;
     247             : 
     248             :     /** cache for all sequences that have been returned.
     249             : 
     250             :         If the range-representation of a sequence changes and it is still
     251             :         referred to by some component (weak reference is valid), the range will
     252             :         be adapted.
     253             :      */
     254             :     tSequenceMap m_aSequenceMap;
     255             :     InternalData m_aInternalData;
     256             :     bool m_bDataInColumns;
     257             : };
     258             : 
     259             : } //  namespace chart
     260             : 
     261             : // INCLUDED_CHART2_SOURCE_INC_INTERNALDATAPROVIDER_HXX
     262             : #endif
     263             : 
     264             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10