2003-10-21 03:04:35 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 04:42:05 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-10-21 03:04:35 -05:00
|
|
|
*
|
2008-04-11 04:42:05 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2003-10-21 03:04:35 -05:00
|
|
|
*
|
2008-04-11 04:42:05 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-10-21 03:04:35 -05:00
|
|
|
*
|
2008-04-11 04:42:05 -05:00
|
|
|
* $RCSfile: cellbindinghelper.hxx,v $
|
|
|
|
* $Revision: 1.7 $
|
2003-10-21 03:04:35 -05:00
|
|
|
*
|
2008-04-11 04:42:05 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-10-21 03:04:35 -05:00
|
|
|
*
|
2008-04-11 04:42:05 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-10-21 03:04:35 -05:00
|
|
|
*
|
2008-04-11 04:42:05 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-10-21 03:04:35 -05:00
|
|
|
*
|
2008-04-11 04:42:05 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-10-21 03:04:35 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
|
|
|
|
#define EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
|
|
|
|
|
2004-11-16 05:03:22 -06:00
|
|
|
/** === begin UNO includes === **/
|
|
|
|
#include <com/sun/star/frame/XModel.hpp>
|
2003-10-21 03:04:35 -05:00
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
|
|
|
|
#include <com/sun/star/table/CellAddress.hpp>
|
|
|
|
#include <com/sun/star/table/CellRangeAddress.hpp>
|
2004-04-02 04:00:59 -06:00
|
|
|
#include <com/sun/star/form/binding/XValueBinding.hpp>
|
|
|
|
#include <com/sun/star/form/binding/XListEntrySource.hpp>
|
2003-10-21 03:04:35 -05:00
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
2004-11-16 05:03:22 -06:00
|
|
|
/** === end UNO includes === **/
|
2003-10-21 03:04:35 -05:00
|
|
|
|
|
|
|
//............................................................................
|
|
|
|
namespace pcr
|
|
|
|
{
|
|
|
|
//............................................................................
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
//= CellBindingHelper
|
|
|
|
//========================================================================
|
|
|
|
/** encapsulates functionality related to binding a form control to a spreadsheet cell
|
|
|
|
*/
|
|
|
|
class CellBindingHelper
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
|
|
|
|
m_xControlModel; // the model we work for
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
|
|
|
|
m_xDocument; // the document where the model lives
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** ctor
|
|
|
|
@param _rxControlModel
|
|
|
|
the control model which is or will be bound
|
|
|
|
*/
|
|
|
|
CellBindingHelper(
|
2004-11-16 05:03:22 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
|
2003-10-21 03:04:35 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
public:
|
2004-11-16 05:03:22 -06:00
|
|
|
/** determines whether the given model is a spreadsheet document model
|
|
|
|
|
2003-10-21 03:04:35 -05:00
|
|
|
<p>If this method returns <FALSE/>, you cannot instantiate a CellBindingHelper with
|
2004-11-16 05:03:22 -06:00
|
|
|
the document, since then no of it's functionality will be available.</p>
|
2003-10-21 03:04:35 -05:00
|
|
|
*/
|
2004-11-16 05:03:22 -06:00
|
|
|
static sal_Bool isSpreadsheetDocument(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
|
2003-10-21 03:04:35 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
/** gets a cell binding for the given address
|
|
|
|
@precond
|
|
|
|
isCellBindingAllowed returns <TRUE/>
|
|
|
|
*/
|
2004-04-02 04:00:59 -06:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
|
2003-10-21 03:04:35 -05:00
|
|
|
createCellBindingFromStringAddress(
|
|
|
|
const ::rtl::OUString& _rAddress,
|
|
|
|
bool _bSupportIntegerExchange = false
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/** creates a cell binding (supporting integer exchange, if requested) for
|
|
|
|
the given address object
|
|
|
|
*/
|
2004-04-02 04:00:59 -06:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
|
2003-10-21 03:04:35 -05:00
|
|
|
createCellBindingFromAddress(
|
|
|
|
const ::com::sun::star::table::CellAddress& _rAddress,
|
|
|
|
bool _bSupportIntegerExchange = false
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/** gets a cell range list source binding for the given address
|
|
|
|
*/
|
2004-04-02 04:00:59 -06:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
|
2003-10-21 03:04:35 -05:00
|
|
|
createCellListSourceFromStringAddress( const ::rtl::OUString& _rAddress ) const;
|
|
|
|
|
|
|
|
/** creates a string representation for the given value binding's address
|
|
|
|
|
|
|
|
<p>If the sheet of the bound cell is the same as the sheet which our control belongs
|
|
|
|
to, then the sheet name is omitted in the resulting string representation.</p>
|
|
|
|
|
|
|
|
@precond
|
|
|
|
The binding is a valid cell binding, or <NULL/>
|
|
|
|
@see isCellBinding
|
|
|
|
*/
|
|
|
|
::rtl::OUString getStringAddressFromCellBinding(
|
2004-04-02 04:00:59 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
|
2003-10-21 03:04:35 -05:00
|
|
|
) const;
|
|
|
|
|
|
|
|
/** creates an address object for the given value binding's address
|
|
|
|
|
|
|
|
@precond
|
|
|
|
The binding is a valid cell binding, or <NULL/>
|
|
|
|
@return
|
|
|
|
<FALSE/> if and only if an error occured and no valid address could be obtained
|
|
|
|
@see isCellBinding
|
|
|
|
*/
|
|
|
|
bool getAddressFromCellBinding(
|
2004-04-02 04:00:59 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding,
|
2003-10-21 03:04:35 -05:00
|
|
|
::com::sun::star::table::CellAddress& _rAddress
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/** creates a string representation for the given list source's range address
|
|
|
|
|
|
|
|
<p>If the sheet of the cell range which acts as list source is the same as the
|
|
|
|
sheet which our control belongs to, then the sheet name is omitted in the
|
|
|
|
resulting string representation.</p>
|
|
|
|
|
|
|
|
@precond
|
|
|
|
The object is a valid cell range list source, or <NULL/>
|
|
|
|
@see isCellRangeListSource
|
|
|
|
*/
|
|
|
|
::rtl::OUString getStringAddressFromCellListSource(
|
2004-04-02 04:00:59 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
|
2003-10-21 03:04:35 -05:00
|
|
|
) const;
|
|
|
|
|
|
|
|
/** returns the current binding of our control model, if any.
|
|
|
|
*/
|
2004-04-02 04:00:59 -06:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
|
2003-10-21 03:04:35 -05:00
|
|
|
getCurrentBinding( ) const;
|
|
|
|
|
|
|
|
/** returns the current external list source of the control model, if any
|
|
|
|
*/
|
2004-04-02 04:00:59 -06:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
|
2003-10-21 03:04:35 -05:00
|
|
|
getCurrentListSource( ) const;
|
|
|
|
|
|
|
|
/** sets a new binding for our control model
|
|
|
|
@precond
|
|
|
|
the control model is bindable (which is implied by <member>isCellBindingAllowed</member>
|
|
|
|
returning <TRUE/>)
|
|
|
|
*/
|
|
|
|
void setBinding(
|
2004-04-02 04:00:59 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
|
2003-10-21 03:04:35 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
/** sets a list source for our control model
|
|
|
|
@precond
|
|
|
|
the control model is a list sink (which is implied by <member>isListCellRangeAllowed</member>
|
|
|
|
returning <TRUE/>)
|
|
|
|
*/
|
|
|
|
void setListSource(
|
2004-04-02 04:00:59 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
|
2003-10-21 03:04:35 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
/** checks whether it's possible to bind the control model to a spreadsheet cell
|
|
|
|
*/
|
|
|
|
bool isCellBindingAllowed( ) const;
|
|
|
|
|
|
|
|
/** checks whether it's possible to bind the control model to a spreadsheet cell,
|
|
|
|
with exchanging integer values
|
|
|
|
*/
|
|
|
|
bool isCellIntegerBindingAllowed( ) const;
|
|
|
|
|
|
|
|
/** checks whether it's possible to bind the control model to range of spreadsheet cells
|
|
|
|
supplying the list entries
|
|
|
|
*/
|
|
|
|
bool isListCellRangeAllowed( ) const;
|
|
|
|
|
|
|
|
/** checks whether a given binding is a spreadsheet cell binding
|
|
|
|
*/
|
|
|
|
bool isCellBinding(
|
2004-04-02 04:00:59 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
|
2003-10-21 03:04:35 -05:00
|
|
|
) const;
|
|
|
|
|
|
|
|
/** checks whether a given binding is a spreadsheet cell binding, exchanging
|
|
|
|
integer values
|
|
|
|
*/
|
|
|
|
bool isCellIntegerBinding(
|
2004-04-02 04:00:59 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
|
2003-10-21 03:04:35 -05:00
|
|
|
) const;
|
|
|
|
|
|
|
|
/** checks whether a given list source is a spreadsheet cell list source
|
|
|
|
*/
|
|
|
|
bool isCellRangeListSource(
|
2004-04-02 04:00:59 -06:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
|
2003-10-21 03:04:35 -05:00
|
|
|
) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/** creates an address object from a string representation of a cell address
|
|
|
|
*/
|
|
|
|
bool convertStringAddress(
|
|
|
|
const ::rtl::OUString& _rAddressDescription,
|
|
|
|
::com::sun::star::table::CellAddress& /* [out] */ _rAddress
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/** creates an address range object from a string representation of a cell range address
|
|
|
|
*/
|
|
|
|
bool convertStringAddress(
|
|
|
|
const ::rtl::OUString& _rAddressDescription,
|
|
|
|
::com::sun::star::table::CellRangeAddress& /* [out] */ _rAddress
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/** retrieves the index of the sheet which our control belongs to
|
|
|
|
@return the index of the sheet which our control belongs to or -1, if an error occured
|
|
|
|
*/
|
|
|
|
sal_Int16 getControlSheetIndex( ) const;
|
|
|
|
|
|
|
|
/** determines if our document is a spreadsheet document, *and* can supply
|
|
|
|
the given service
|
|
|
|
*/
|
|
|
|
bool isSpreadsheetDocumentWhichSupplies( const ::rtl::OUString& _rService ) const;
|
|
|
|
|
|
|
|
/** checkes whether a given component supports a given servive
|
|
|
|
*/
|
|
|
|
bool doesComponentSupport(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
|
|
|
|
const ::rtl::OUString& _rService
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/** uses the document (it's factory interface, respectively) to create a component instance
|
|
|
|
@param _rService
|
|
|
|
the service name
|
|
|
|
@param _rArgumentName
|
|
|
|
the name of the single argument to pass during creation. May be empty, in this case
|
|
|
|
no arguments are passed
|
|
|
|
@param _rArgumentValue
|
|
|
|
the value of the instantiation argument. Not evaluated if <arg>_rArgumentName</arg>
|
|
|
|
is empty.
|
|
|
|
*/
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
|
|
|
|
createDocumentDependentInstance(
|
|
|
|
const ::rtl::OUString& _rService,
|
|
|
|
const ::rtl::OUString& _rArgumentName,
|
|
|
|
const ::com::sun::star::uno::Any& _rArgumentValue
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/** converts an address representation into another one
|
|
|
|
|
|
|
|
@param _rInputProperty
|
|
|
|
the input property name for the conversion service
|
|
|
|
@param _rInputValue
|
|
|
|
the input property value for the conversion service
|
|
|
|
@param _rOutputProperty
|
|
|
|
the output property name for the conversion service
|
|
|
|
@param _rOutputValue
|
|
|
|
the output property value for the conversion service
|
|
|
|
@param _bIsRange
|
|
|
|
if <TRUE/>, the RangeAddressConversion service will be used, else
|
|
|
|
the AddressConversion service
|
|
|
|
|
|
|
|
@return
|
|
|
|
<TRUE/> if any only if the conversion was successfull
|
|
|
|
|
|
|
|
@see com::sun::star::table::CellAddressConversion
|
|
|
|
@see com::sun::star::table::CellRangeAddressConversion
|
|
|
|
*/
|
|
|
|
bool doConvertAddressRepresentations(
|
|
|
|
const ::rtl::OUString& _rInputProperty,
|
|
|
|
const ::com::sun::star::uno::Any& _rInputValue,
|
|
|
|
const ::rtl::OUString& _rOutputProperty,
|
|
|
|
::com::sun::star::uno::Any& _rOutputValue,
|
|
|
|
bool _bIsRange
|
|
|
|
) const SAL_THROW(());
|
|
|
|
};
|
|
|
|
|
|
|
|
//............................................................................
|
|
|
|
} // namespace pcr
|
|
|
|
//............................................................................
|
|
|
|
|
2004-11-16 05:03:22 -06:00
|
|
|
#endif // EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
|