LCOV - code coverage report
Current view: top level - chart2/source/inc - InternalDataProvider.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 1 0.0 %
Date: 2014-11-03 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             : 
     138             :     virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
     139             :         createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation )
     140             :             throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             : 
     142             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
     143             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     144             : 
     145             :     // ____ XRangeXMLConversion ____
     146             :     virtual OUString SAL_CALL convertRangeToXML(
     147             :         const OUString& aRangeRepresentation )
     148             :         throw (::com::sun::star::lang::IllegalArgumentException,
     149             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     150             :     virtual OUString SAL_CALL convertRangeFromXML(
     151             :         const OUString& aXMLRange )
     152             :         throw (::com::sun::star::lang::IllegalArgumentException,
     153             :                ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     154             : 
     155             :     // ____ XDateCategories ____
     156             :     virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     157             :     virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     158             : 
     159             :     // ____ XAnyDescriptionAccess ____
     160             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
     161             :         getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             :     virtual void SAL_CALL setAnyRowDescriptions(
     163             :         const ::com::sun::star::uno::Sequence<
     164             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions )
     165             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL
     167             :         getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     168             :     virtual void SAL_CALL setAnyColumnDescriptions(
     169             :         const ::com::sun::star::uno::Sequence<
     170             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions )
     171             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             : 
     173             :     // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____
     174             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > SAL_CALL
     175             :         getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     176             :     virtual void SAL_CALL setComplexRowDescriptions(
     177             :         const ::com::sun::star::uno::Sequence<
     178             :         ::com::sun::star::uno::Sequence< OUString > >& aRowDescriptions )
     179             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     180             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > SAL_CALL
     181             :         getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     182             :     virtual void SAL_CALL setComplexColumnDescriptions(
     183             :         const ::com::sun::star::uno::Sequence<
     184             :         ::com::sun::star::uno::Sequence< OUString > >& aColumnDescriptions )
     185             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     186             : 
     187             :     // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
     188             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()
     189             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     190             :     virtual void SAL_CALL setData(
     191             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData )
     192             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     193             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getRowDescriptions()
     194             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     195             :     virtual void SAL_CALL setRowDescriptions(
     196             :         const ::com::sun::star::uno::Sequence< OUString >& aRowDescriptions )
     197             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     198             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getColumnDescriptions()
     199             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     200             :     virtual void SAL_CALL setColumnDescriptions(
     201             :         const ::com::sun::star::uno::Sequence< OUString >& aColumnDescriptions )
     202             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     203             : 
     204             :     // ____ XChartData (base of XChartDataArray) ____
     205             :     virtual void SAL_CALL addChartDataChangeEventListener(
     206             :         const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
     207             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     208             :     virtual void SAL_CALL removeChartDataChangeEventListener(
     209             :         const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
     210             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     211             :     virtual double SAL_CALL getNotANumber()
     212             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     213             :     virtual sal_Bool SAL_CALL isNotANumber(
     214             :         double nNumber )
     215             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     216             : 
     217             :     // ____ XCloneable ____
     218             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
     219             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     220             :     // ::com::sun::star::lang::XInitialization:
     221             :     virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments)
     222             :         throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     223             : 
     224             : private:
     225             :     void addDataSequenceToMap(
     226             :         const OUString & rRangeRepresentation,
     227             :         const ::com::sun::star::uno::Reference<
     228             :             ::com::sun::star::chart2::data::XDataSequence > & xSequence );
     229             : 
     230             :     ::com::sun::star::uno::Reference<
     231             :             ::com::sun::star::chart2::data::XDataSequence >
     232             :         createDataSequenceAndAddToMap( const OUString & rRangeRepresentation,
     233             :                                        const OUString & rRole );
     234             :     ::com::sun::star::uno::Reference<
     235             :             ::com::sun::star::chart2::data::XDataSequence >
     236             :         createDataSequenceAndAddToMap( const OUString & rRangeRepresentation );
     237             : 
     238             :     css::uno::Reference<css::chart2::data::XDataSequence>
     239             :         createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole );
     240             : 
     241             :     void deleteMapReferences( const OUString & rRangeRepresentation );
     242             : 
     243             :     void adaptMapReferences(
     244             :         const OUString & rOldRangeRepresentation,
     245             :         const OUString & rNewRangeRepresentation );
     246             : 
     247             :     void increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
     248             :     void decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
     249             : 
     250             :     typedef ::std::multimap< OUString,
     251             :             ::com::sun::star::uno::WeakReference< ::com::sun::star::chart2::data::XDataSequence > >
     252             :         tSequenceMap;
     253             :     typedef ::std::pair< tSequenceMap::iterator, tSequenceMap::iterator > tSequenceMapRange;
     254             :     typedef ::std::pair< tSequenceMap::const_iterator, tSequenceMap::const_iterator > tConstSequenceMapRange;
     255             : 
     256             :     /** cache for all sequences that have been returned.
     257             : 
     258             :         If the range-representation of a sequence changes and it is still
     259             :         referred to by some component (weak reference is valid), the range will
     260             :         be adapted.
     261             :      */
     262             :     tSequenceMap m_aSequenceMap;
     263             :     InternalData m_aInternalData;
     264             :     bool m_bDataInColumns;
     265             : };
     266             : 
     267             : } //  namespace chart
     268             : 
     269             : // INCLUDED_CHART2_SOURCE_INC_INTERNALDATAPROVIDER_HXX
     270             : #endif
     271             : 
     272             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10