LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - cellbindinghelper.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             : 
      20             : #ifndef EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
      21             : #define EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
      22             : 
      23             : #include <com/sun/star/frame/XModel.hpp>
      24             : #include <com/sun/star/beans/XPropertySet.hpp>
      25             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      26             : #include <com/sun/star/table/CellAddress.hpp>
      27             : #include <com/sun/star/table/CellRangeAddress.hpp>
      28             : #include <com/sun/star/form/binding/XValueBinding.hpp>
      29             : #include <com/sun/star/form/binding/XListEntrySource.hpp>
      30             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      31             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      32             : 
      33             : 
      34             : namespace pcr
      35             : {
      36             : 
      37             : 
      38             : 
      39             :     //= CellBindingHelper
      40             : 
      41             :     /** encapsulates functionality related to binding a form control to a spreadsheet cell
      42             :     */
      43           0 :     class CellBindingHelper
      44             :     {
      45             :     protected:
      46             :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
      47             :                     m_xControlModel;    // the model we work for
      48             :         ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
      49             :                     m_xDocument;        // the document where the model lives
      50             : 
      51             :     public:
      52             :         /** ctor
      53             :             @param _rxControlModel
      54             :                 the control model which is or will be bound
      55             :         */
      56             :         CellBindingHelper(
      57             :             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
      58             :             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
      59             :         );
      60             : 
      61             :     public:
      62             :         /** determines whether the given model is a spreadsheet document model
      63             : 
      64             :             <p>If this method returns <FALSE/>, you cannot instantiate a CellBindingHelper with
      65             :             the document, since then no of it's functionality will be available.</p>
      66             :         */
      67             :         static  sal_Bool    isSpreadsheetDocument(
      68             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
      69             :                             );
      70             : 
      71             :         /** gets a cell binding for the given address
      72             :             @precond
      73             :                 isCellBindingAllowed returns <TRUE/>
      74             :         */
      75             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
      76             :                         createCellBindingFromStringAddress(
      77             :                             const OUString& _rAddress,
      78             :                             bool _bSupportIntegerExchange = false
      79             :                         ) const;
      80             : 
      81             :         /** creates a cell binding (supporting integer exchange, if requested) for
      82             :             the given address object
      83             :         */
      84             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
      85             :                         createCellBindingFromAddress(
      86             :                             const ::com::sun::star::table::CellAddress& _rAddress,
      87             :                             bool _bSupportIntegerExchange = false
      88             :                         ) const;
      89             : 
      90             :         /** gets a cell range list source binding for the given address
      91             :         */
      92             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
      93             :                         createCellListSourceFromStringAddress( const OUString& _rAddress ) const;
      94             : 
      95             :         /** creates a string representation for the given value binding's address
      96             : 
      97             :             <p>If the sheet of the bound cell is the same as the sheet which our control belongs
      98             :             to, then the sheet name is omitted in the resulting string representation.</p>
      99             : 
     100             :             @precond
     101             :                 The binding is a valid cell binding, or <NULL/>
     102             :             @see isCellBinding
     103             :         */
     104             :         OUString getStringAddressFromCellBinding(
     105             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
     106             :                         ) const;
     107             : 
     108             :         /** creates an address object for the given value binding's address
     109             : 
     110             :             @precond
     111             :                 The binding is a valid cell binding, or <NULL/>
     112             :             @return
     113             :                 <FALSE/> if and only if an error occurred and no valid address could be obtained
     114             :             @see isCellBinding
     115             :         */
     116             :         bool            getAddressFromCellBinding(
     117             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding,
     118             :                             ::com::sun::star::table::CellAddress& _rAddress
     119             :                         ) const;
     120             : 
     121             :         /** creates a string representation for the given list source's range address
     122             : 
     123             :             <p>If the sheet of the cell range which acts as list source is the same as the
     124             :             sheet which our control belongs to, then the sheet name is omitted in the
     125             :             resulting string representation.</p>
     126             : 
     127             :             @precond
     128             :                 The object is a valid cell range list source, or <NULL/>
     129             :             @see isCellRangeListSource
     130             :         */
     131             :         OUString getStringAddressFromCellListSource(
     132             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
     133             :                         ) const;
     134             : 
     135             :         /** returns the current binding of our control model, if any.
     136             :         */
     137             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
     138             :                         getCurrentBinding( ) const;
     139             : 
     140             :         /** returns the current external list source of the control model, if any
     141             :         */
     142             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
     143             :                         getCurrentListSource( ) const;
     144             : 
     145             :         /** sets a new binding for our control model
     146             :             @precond
     147             :                 the control model is bindable (which is implied by <member>isCellBindingAllowed</member>
     148             :                 returning <TRUE/>)
     149             :         */
     150             :         void            setBinding(
     151             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
     152             :                         );
     153             : 
     154             :         /** sets a list source for our control model
     155             :             @precond
     156             :                 the control model is a list sink (which is implied by <member>isListCellRangeAllowed</member>
     157             :                 returning <TRUE/>)
     158             :         */
     159             :         void            setListSource(
     160             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
     161             :                         );
     162             : 
     163             :         /** checks whether it's possible to bind the control model to a spreadsheet cell
     164             :         */
     165             :         bool            isCellBindingAllowed( ) const;
     166             : 
     167             :         /** checks whether it's possible to bind the control model to a spreadsheet cell,
     168             :             with exchanging integer values
     169             :         */
     170             :         bool            isCellIntegerBindingAllowed( ) const;
     171             : 
     172             :         /** checks whether it's possible to bind the control model to range of spreadsheet cells
     173             :             supplying the list entries
     174             :         */
     175             :         bool            isListCellRangeAllowed( ) const;
     176             : 
     177             :         /** checks whether a given binding is a spreadsheet cell binding
     178             :         */
     179             :         bool            isCellBinding(
     180             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
     181             :                         ) const;
     182             : 
     183             :         /** checks whether a given binding is a spreadsheet cell binding, exchanging
     184             :             integer values
     185             :         */
     186             :         bool            isCellIntegerBinding(
     187             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
     188             :                         ) const;
     189             : 
     190             :         /** checks whether a given list source is a spreadsheet cell list source
     191             :         */
     192             :         bool            isCellRangeListSource(
     193             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
     194             :                         ) const;
     195             : 
     196             :         /** retrieves the index of the sheet which our control belongs to
     197             :             @return the index of the sheet which our control belongs to or -1, if an error occurred
     198             :         */
     199             :         sal_Int16       getControlSheetIndex(
     200             :                             ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >& _out_rxSheet
     201             :                         ) const;
     202             : 
     203             :     protected:
     204             :         /** creates an address object from a string representation of a cell address
     205             :         */
     206             :         bool            convertStringAddress(
     207             :                             const OUString& _rAddressDescription,
     208             :                             ::com::sun::star::table::CellAddress& /* [out] */ _rAddress
     209             :                         ) const;
     210             : 
     211             :         /** creates an address range object from a string representation of a cell range address
     212             :         */
     213             :         bool            convertStringAddress(
     214             :                             const OUString& _rAddressDescription,
     215             :                             ::com::sun::star::table::CellRangeAddress& /* [out] */ _rAddress
     216             :                         ) const;
     217             : 
     218             :         /** determines if our document is a spreadsheet document, *and* can supply
     219             :             the given service
     220             :         */
     221             :         bool            isSpreadsheetDocumentWhichSupplies( const OUString& _rService ) const;
     222             : 
     223             :         /** checkes whether a given component supports a given servive
     224             :         */
     225             :         bool            doesComponentSupport(
     226             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
     227             :                             const OUString& _rService
     228             :                         ) const;
     229             : 
     230             :         /** uses the document (it's factory interface, respectively) to create a component instance
     231             :             @param _rService
     232             :                 the service name
     233             :             @param _rArgumentName
     234             :                 the name of the single argument to pass during creation. May be empty, in this case
     235             :                 no arguments are passed
     236             :             @param _rArgumentValue
     237             :                 the value of the instantiation argument. Not evaluated if <arg>_rArgumentName</arg>
     238             :                 is empty.
     239             :         */
     240             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     241             :                         createDocumentDependentInstance(
     242             :                             const OUString& _rService,
     243             :                             const OUString& _rArgumentName,
     244             :                             const ::com::sun::star::uno::Any& _rArgumentValue
     245             :                         ) const;
     246             : 
     247             :         /** converts an address representation into another one
     248             : 
     249             :             @param _rInputProperty
     250             :                 the input property name for the conversion service
     251             :             @param _rInputValue
     252             :                 the input property value for the conversion service
     253             :             @param _rOutputProperty
     254             :                 the output property name for the conversion service
     255             :             @param _rOutputValue
     256             :                 the output property value for the conversion service
     257             :             @param _bIsRange
     258             :                 if <TRUE/>, the RangeAddressConversion service will be used, else
     259             :                 the AddressConversion service
     260             : 
     261             :             @return
     262             :                 <TRUE/> if any only if the conversion was successful
     263             : 
     264             :             @see com::sun::star::table::CellAddressConversion
     265             :             @see com::sun::star::table::CellRangeAddressConversion
     266             :         */
     267             :         bool            doConvertAddressRepresentations(
     268             :                             const OUString& _rInputProperty,
     269             :                             const ::com::sun::star::uno::Any& _rInputValue,
     270             :                             const OUString& _rOutputProperty,
     271             :                                   ::com::sun::star::uno::Any& _rOutputValue,
     272             :                             bool _bIsRange
     273             :                         ) const SAL_THROW(());
     274             :     };
     275             : 
     276             : 
     277             : }   // namespace pcr
     278             : 
     279             : 
     280             : #endif // EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
     281             : 
     282             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10