LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - cellbindinghelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1 0.0 %
Date: 2012-08-25 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
      30                 :            : #define EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/frame/XModel.hpp>
      33                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      34                 :            : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      35                 :            : #include <com/sun/star/table/CellAddress.hpp>
      36                 :            : #include <com/sun/star/table/CellRangeAddress.hpp>
      37                 :            : #include <com/sun/star/form/binding/XValueBinding.hpp>
      38                 :            : #include <com/sun/star/form/binding/XListEntrySource.hpp>
      39                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      40                 :            : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      41                 :            : 
      42                 :            : //............................................................................
      43                 :            : namespace pcr
      44                 :            : {
      45                 :            : //............................................................................
      46                 :            : 
      47                 :            :     //========================================================================
      48                 :            :     //= CellBindingHelper
      49                 :            :     //========================================================================
      50                 :            :     /** encapsulates functionality related to binding a form control to a spreadsheet cell
      51                 :            :     */
      52                 :          0 :     class CellBindingHelper
      53                 :            :     {
      54                 :            :     protected:
      55                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
      56                 :            :                     m_xControlModel;    // the model we work for
      57                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
      58                 :            :                     m_xDocument;        // the document where the model lives
      59                 :            : 
      60                 :            :     public:
      61                 :            :         /** ctor
      62                 :            :             @param _rxControlModel
      63                 :            :                 the control model which is or will be bound
      64                 :            :         */
      65                 :            :         CellBindingHelper(
      66                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
      67                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
      68                 :            :         );
      69                 :            : 
      70                 :            :     public:
      71                 :            :         /** determines whether the given model is a spreadsheet document model
      72                 :            : 
      73                 :            :             <p>If this method returns <FALSE/>, you cannot instantiate a CellBindingHelper with
      74                 :            :             the document, since then no of it's functionality will be available.</p>
      75                 :            :         */
      76                 :            :         static  sal_Bool    isSpreadsheetDocument(
      77                 :            :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
      78                 :            :                             );
      79                 :            : 
      80                 :            :         /** gets a cell binding for the given address
      81                 :            :             @precond
      82                 :            :                 isCellBindingAllowed returns <TRUE/>
      83                 :            :         */
      84                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
      85                 :            :                         createCellBindingFromStringAddress(
      86                 :            :                             const ::rtl::OUString& _rAddress,
      87                 :            :                             bool _bSupportIntegerExchange = false
      88                 :            :                         ) const;
      89                 :            : 
      90                 :            :         /** creates a cell binding (supporting integer exchange, if requested) for
      91                 :            :             the given address object
      92                 :            :         */
      93                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
      94                 :            :                         createCellBindingFromAddress(
      95                 :            :                             const ::com::sun::star::table::CellAddress& _rAddress,
      96                 :            :                             bool _bSupportIntegerExchange = false
      97                 :            :                         ) const;
      98                 :            : 
      99                 :            :         /** gets a cell range list source binding for the given address
     100                 :            :         */
     101                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
     102                 :            :                         createCellListSourceFromStringAddress( const ::rtl::OUString& _rAddress ) const;
     103                 :            : 
     104                 :            :         /** creates a string representation for the given value binding's address
     105                 :            : 
     106                 :            :             <p>If the sheet of the bound cell is the same as the sheet which our control belongs
     107                 :            :             to, then the sheet name is omitted in the resulting string representation.</p>
     108                 :            : 
     109                 :            :             @precond
     110                 :            :                 The binding is a valid cell binding, or <NULL/>
     111                 :            :             @see isCellBinding
     112                 :            :         */
     113                 :            :         ::rtl::OUString getStringAddressFromCellBinding(
     114                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
     115                 :            :                         ) const;
     116                 :            : 
     117                 :            :         /** creates an address object for the given value binding's address
     118                 :            : 
     119                 :            :             @precond
     120                 :            :                 The binding is a valid cell binding, or <NULL/>
     121                 :            :             @return
     122                 :            :                 <FALSE/> if and only if an error occurred and no valid address could be obtained
     123                 :            :             @see isCellBinding
     124                 :            :         */
     125                 :            :         bool            getAddressFromCellBinding(
     126                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding,
     127                 :            :                             ::com::sun::star::table::CellAddress& _rAddress
     128                 :            :                         ) const;
     129                 :            : 
     130                 :            :         /** creates a string representation for the given list source's range address
     131                 :            : 
     132                 :            :             <p>If the sheet of the cell range which acts as list source is the same as the
     133                 :            :             sheet which our control belongs to, then the sheet name is omitted in the
     134                 :            :             resulting string representation.</p>
     135                 :            : 
     136                 :            :             @precond
     137                 :            :                 The object is a valid cell range list source, or <NULL/>
     138                 :            :             @see isCellRangeListSource
     139                 :            :         */
     140                 :            :         ::rtl::OUString getStringAddressFromCellListSource(
     141                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
     142                 :            :                         ) const;
     143                 :            : 
     144                 :            :         /** returns the current binding of our control model, if any.
     145                 :            :         */
     146                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
     147                 :            :                         getCurrentBinding( ) const;
     148                 :            : 
     149                 :            :         /** returns the current external list source of the control model, if any
     150                 :            :         */
     151                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
     152                 :            :                         getCurrentListSource( ) const;
     153                 :            : 
     154                 :            :         /** sets a new binding for our control model
     155                 :            :             @precond
     156                 :            :                 the control model is bindable (which is implied by <member>isCellBindingAllowed</member>
     157                 :            :                 returning <TRUE/>)
     158                 :            :         */
     159                 :            :         void            setBinding(
     160                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
     161                 :            :                         );
     162                 :            : 
     163                 :            :         /** sets a list source for our control model
     164                 :            :             @precond
     165                 :            :                 the control model is a list sink (which is implied by <member>isListCellRangeAllowed</member>
     166                 :            :                 returning <TRUE/>)
     167                 :            :         */
     168                 :            :         void            setListSource(
     169                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
     170                 :            :                         );
     171                 :            : 
     172                 :            :         /** checks whether it's possible to bind the control model to a spreadsheet cell
     173                 :            :         */
     174                 :            :         bool            isCellBindingAllowed( ) const;
     175                 :            : 
     176                 :            :         /** checks whether it's possible to bind the control model to a spreadsheet cell,
     177                 :            :             with exchanging integer values
     178                 :            :         */
     179                 :            :         bool            isCellIntegerBindingAllowed( ) const;
     180                 :            : 
     181                 :            :         /** checks whether it's possible to bind the control model to range of spreadsheet cells
     182                 :            :             supplying the list entries
     183                 :            :         */
     184                 :            :         bool            isListCellRangeAllowed( ) const;
     185                 :            : 
     186                 :            :         /** checks whether a given binding is a spreadsheet cell binding
     187                 :            :         */
     188                 :            :         bool            isCellBinding(
     189                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
     190                 :            :                         ) const;
     191                 :            : 
     192                 :            :         /** checks whether a given binding is a spreadsheet cell binding, exchanging
     193                 :            :             integer values
     194                 :            :         */
     195                 :            :         bool            isCellIntegerBinding(
     196                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
     197                 :            :                         ) const;
     198                 :            : 
     199                 :            :         /** checks whether a given list source is a spreadsheet cell list source
     200                 :            :         */
     201                 :            :         bool            isCellRangeListSource(
     202                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
     203                 :            :                         ) const;
     204                 :            : 
     205                 :            :         /** retrieves the index of the sheet which our control belongs to
     206                 :            :             @return the index of the sheet which our control belongs to or -1, if an error occurred
     207                 :            :         */
     208                 :            :         sal_Int16       getControlSheetIndex(
     209                 :            :                             ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >& _out_rxSheet
     210                 :            :                         ) const;
     211                 :            : 
     212                 :            :     protected:
     213                 :            :         /** creates an address object from a string representation of a cell address
     214                 :            :         */
     215                 :            :         bool            convertStringAddress(
     216                 :            :                             const ::rtl::OUString& _rAddressDescription,
     217                 :            :                             ::com::sun::star::table::CellAddress& /* [out] */ _rAddress
     218                 :            :                         ) const;
     219                 :            : 
     220                 :            :         /** creates an address range object from a string representation of a cell range address
     221                 :            :         */
     222                 :            :         bool            convertStringAddress(
     223                 :            :                             const ::rtl::OUString& _rAddressDescription,
     224                 :            :                             ::com::sun::star::table::CellRangeAddress& /* [out] */ _rAddress
     225                 :            :                         ) const;
     226                 :            : 
     227                 :            :         /** determines if our document is a spreadsheet document, *and* can supply
     228                 :            :             the given service
     229                 :            :         */
     230                 :            :         bool            isSpreadsheetDocumentWhichSupplies( const ::rtl::OUString& _rService ) const;
     231                 :            : 
     232                 :            :         /** checkes whether a given component supports a given servive
     233                 :            :         */
     234                 :            :         bool            doesComponentSupport(
     235                 :            :                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
     236                 :            :                             const ::rtl::OUString& _rService
     237                 :            :                         ) const;
     238                 :            : 
     239                 :            :         /** uses the document (it's factory interface, respectively) to create a component instance
     240                 :            :             @param _rService
     241                 :            :                 the service name
     242                 :            :             @param _rArgumentName
     243                 :            :                 the name of the single argument to pass during creation. May be empty, in this case
     244                 :            :                 no arguments are passed
     245                 :            :             @param _rArgumentValue
     246                 :            :                 the value of the instantiation argument. Not evaluated if <arg>_rArgumentName</arg>
     247                 :            :                 is empty.
     248                 :            :         */
     249                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     250                 :            :                         createDocumentDependentInstance(
     251                 :            :                             const ::rtl::OUString& _rService,
     252                 :            :                             const ::rtl::OUString& _rArgumentName,
     253                 :            :                             const ::com::sun::star::uno::Any& _rArgumentValue
     254                 :            :                         ) const;
     255                 :            : 
     256                 :            :         /** converts an address representation into another one
     257                 :            : 
     258                 :            :             @param _rInputProperty
     259                 :            :                 the input property name for the conversion service
     260                 :            :             @param _rInputValue
     261                 :            :                 the input property value for the conversion service
     262                 :            :             @param _rOutputProperty
     263                 :            :                 the output property name for the conversion service
     264                 :            :             @param _rOutputValue
     265                 :            :                 the output property value for the conversion service
     266                 :            :             @param _bIsRange
     267                 :            :                 if <TRUE/>, the RangeAddressConversion service will be used, else
     268                 :            :                 the AddressConversion service
     269                 :            : 
     270                 :            :             @return
     271                 :            :                 <TRUE/> if any only if the conversion was successfull
     272                 :            : 
     273                 :            :             @see com::sun::star::table::CellAddressConversion
     274                 :            :             @see com::sun::star::table::CellRangeAddressConversion
     275                 :            :         */
     276                 :            :         bool            doConvertAddressRepresentations(
     277                 :            :                             const ::rtl::OUString& _rInputProperty,
     278                 :            :                             const ::com::sun::star::uno::Any& _rInputValue,
     279                 :            :                             const ::rtl::OUString& _rOutputProperty,
     280                 :            :                                   ::com::sun::star::uno::Any& _rOutputValue,
     281                 :            :                             bool _bIsRange
     282                 :            :                         ) const SAL_THROW(());
     283                 :            :     };
     284                 :            : 
     285                 :            : //............................................................................
     286                 :            : }   // namespace pcr
     287                 :            : //............................................................................
     288                 :            : 
     289                 :            : #endif // EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
     290                 :            : 
     291                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10