LibreOffice Module extensions (master) 1
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
pcr::CellBindingHelper Class Referencefinal

encapsulates functionality related to binding a form control to a spreadsheet cell More...

#include <cellbindinghelper.hxx>

Public Member Functions

 CellBindingHelper (const css::uno::Reference< css::beans::XPropertySet > &_rxControlModel, const css::uno::Reference< css::frame::XModel > &_rxContextDocument)
 ctor More...
 
css::uno::Reference< css::form::binding::XValueBinding > createCellBindingFromStringAddress (const OUString &_rAddress, bool _bSupportIntegerExchange) const
 gets a cell binding for the given address @precond isCellBindingAllowed returns <TRUE> More...
 
css::uno::Reference< css::form::binding::XValueBinding > createCellBindingFromAddress (const css::table::CellAddress &_rAddress, bool _bSupportIntegerExchange) const
 creates a cell binding (supporting integer exchange, if requested) for the given address object More...
 
css::uno::Reference< css::form::binding::XListEntrySource > createCellListSourceFromStringAddress (const OUString &_rAddress) const
 gets a cell range list source binding for the given address More...
 
OUString getStringAddressFromCellBinding (const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding) const
 creates a string representation for the given value binding's address More...
 
bool getAddressFromCellBinding (const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding, css::table::CellAddress &_rAddress) const
 creates an address object for the given value binding's address More...
 
OUString getStringAddressFromCellListSource (const css::uno::Reference< css::form::binding::XListEntrySource > &_rxSource) const
 creates a string representation for the given list source's range address More...
 
css::uno::Reference< css::form::binding::XValueBinding > getCurrentBinding () const
 returns the current binding of our control model, if any. More...
 
css::uno::Reference< css::form::binding::XListEntrySource > getCurrentListSource () const
 returns the current external list source of the control model, if any More...
 
void setBinding (const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding)
 sets a new binding for our control model @precond the control model is bindable (which is implied by <member>isCellBindingAllowed</member> returning <TRUE>) More...
 
void setListSource (const css::uno::Reference< css::form::binding::XListEntrySource > &_rxSource)
 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>) More...
 
bool isCellBindingAllowed () const
 checks whether it's possible to bind the control model to a spreadsheet cell More...
 
bool isCellIntegerBindingAllowed () const
 checks whether it's possible to bind the control model to a spreadsheet cell, with exchanging integer values More...
 
bool isListCellRangeAllowed () const
 checks whether it's possible to bind the control model to range of spreadsheet cells supplying the list entries More...
 
sal_Int16 getControlSheetIndex (css::uno::Reference< css::sheet::XSpreadsheet > &_out_rxSheet) const
 retrieves the index of the sheet which our control belongs to More...
 

Static Public Member Functions

static bool isSpreadsheetDocument (const css::uno::Reference< css::frame::XModel > &_rxContextDocument)
 determines whether the given model is a spreadsheet document model More...
 
static bool isCellBinding (const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding)
 checks whether a given binding is a spreadsheet cell binding More...
 
static bool isCellIntegerBinding (const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding)
 checks whether a given binding is a spreadsheet cell binding, exchanging integer values More...
 
static bool isCellRangeListSource (const css::uno::Reference< css::form::binding::XListEntrySource > &_rxSource)
 checks whether a given list source is a spreadsheet cell list source More...
 

Private Member Functions

bool convertStringAddress (const OUString &_rAddressDescription, css::table::CellAddress &_rAddress) const
 creates an address object from a string representation of a cell address More...
 
bool convertStringAddress (const OUString &_rAddressDescription, css::table::CellRangeAddress &_rAddress) const
 creates an address range object from a string representation of a cell range address More...
 
bool isSpreadsheetDocumentWhichSupplies (const OUString &_rService) const
 determines if our document is a spreadsheet document, and can supply the given service More...
 
css::uno::Reference< css::uno::XInterface > createDocumentDependentInstance (const OUString &_rService, const OUString &_rArgumentName, const css::uno::Any &_rArgumentValue) const
 uses the document (it's factory interface, respectively) to create a component instance More...
 
bool doConvertAddressRepresentations (const OUString &_rInputProperty, const css::uno::Any &_rInputValue, const OUString &_rOutputProperty, css::uno::Any &_rOutputValue, bool _bIsRange) const
 converts an address representation into another one More...
 

Static Private Member Functions

static bool doesComponentSupport (const css::uno::Reference< css::uno::XInterface > &_rxComponent, const OUString &_rService)
 checks whether a given component supports a given service More...
 

Private Attributes

css::uno::Reference< css::beans::XPropertySetm_xControlModel
 
css::uno::Reference< css::sheet::XSpreadsheetDocument > m_xDocument
 

Detailed Description

encapsulates functionality related to binding a form control to a spreadsheet cell

Definition at line 37 of file cellbindinghelper.hxx.

Constructor & Destructor Documentation

◆ CellBindingHelper()

pcr::CellBindingHelper::CellBindingHelper ( const css::uno::Reference< css::beans::XPropertySet > &  _rxControlModel,
const css::uno::Reference< css::frame::XModel > &  _rxContextDocument 
)

ctor

Parameters
_rxControlModelthe control model which is or will be bound

Definition at line 77 of file cellbindinghelper.cxx.

References isSpreadsheetDocumentWhichSupplies(), m_xControlModel, m_xDocument, and SERVICE_ADDRESS_CONVERSION.

Member Function Documentation

◆ convertStringAddress() [1/2]

bool pcr::CellBindingHelper::convertStringAddress ( const OUString &  _rAddressDescription,
css::table::CellAddress &  _rAddress 
) const
private

creates an address object from a string representation of a cell address

Referenced by createCellBindingFromStringAddress(), and createCellListSourceFromStringAddress().

◆ convertStringAddress() [2/2]

bool pcr::CellBindingHelper::convertStringAddress ( const OUString &  _rAddressDescription,
css::table::CellRangeAddress &  _rAddress 
) const
private

creates an address range object from a string representation of a cell range address

◆ createCellBindingFromAddress()

Reference< XValueBinding > pcr::CellBindingHelper::createCellBindingFromAddress ( const css::table::CellAddress &  _rAddress,
bool  _bSupportIntegerExchange 
) const

creates a cell binding (supporting integer exchange, if requested) for the given address object

Definition at line 208 of file cellbindinghelper.cxx.

References Any, createDocumentDependentInstance(), PROPERTY_BOUND_CELL, SERVICE_SHEET_CELL_BINDING, and SERVICE_SHEET_CELL_INT_BINDING.

Referenced by createCellBindingFromStringAddress().

◆ createCellBindingFromStringAddress()

Reference< XValueBinding > pcr::CellBindingHelper::createCellBindingFromStringAddress ( const OUString &  _rAddress,
bool  _bSupportIntegerExchange 
) const

gets a cell binding for the given address @precond isCellBindingAllowed returns <TRUE>

Definition at line 220 of file cellbindinghelper.cxx.

References convertStringAddress(), createCellBindingFromAddress(), and m_xDocument.

◆ createCellListSourceFromStringAddress()

Reference< XListEntrySource > pcr::CellBindingHelper::createCellListSourceFromStringAddress ( const OUString &  _rAddress) const

gets a cell range list source binding for the given address

Definition at line 236 of file cellbindinghelper.cxx.

References Any, convertStringAddress(), createDocumentDependentInstance(), PROPERTY_LIST_CELL_RANGE, and SERVICE_SHEET_CELLRANGE_LISTSOURCE.

◆ createDocumentDependentInstance()

Reference< XInterface > pcr::CellBindingHelper::createDocumentDependentInstance ( const OUString &  _rService,
const OUString &  _rArgumentName,
const css::uno::Any &  _rArgumentValue 
) const
private

uses the document (it's factory interface, respectively) to create a component instance

Parameters
_rServicethe service name
_rArgumentNamethe name of the single argument to pass during creation. May be empty, in this case no arguments are passed
_rArgumentValuethe value of the instantiation argument. Not evaluated if <arg>_rArgumentName</arg> is empty.

Definition at line 255 of file cellbindinghelper.cxx.

References Any, Exception, m_xDocument, and Sequence.

Referenced by createCellBindingFromAddress(), createCellListSourceFromStringAddress(), and doConvertAddressRepresentations().

◆ doConvertAddressRepresentations()

bool pcr::CellBindingHelper::doConvertAddressRepresentations ( const OUString &  _rInputProperty,
const css::uno::Any &  _rInputValue,
const OUString &  _rOutputProperty,
css::uno::Any &  _rOutputValue,
bool  _bIsRange 
) const
private

converts an address representation into another one

Parameters
_rInputPropertythe input property name for the conversion service
_rInputValuethe input property value for the conversion service
_rOutputPropertythe output property name for the conversion service
_rOutputValuethe output property value for the conversion service
_bIsRangeif <TRUE>, the RangeAddressConversion service will be used, else the AddressConversion service
Returns
<TRUE> if any only if the conversion was successful
See also
css::table::CellAddressConversion
css::table::CellRangeAddressConversion

Definition at line 159 of file cellbindinghelper.cxx.

References Any, createDocumentDependentInstance(), Exception, getControlSheetIndex(), PROPERTY_REFERENCE_SHEET, SERVICE_ADDRESS_CONVERSION, SERVICE_RANGEADDRESS_CONVERSION, TOOLS_WARN_EXCEPTION, and xConverter.

Referenced by getStringAddressFromCellBinding(), and getStringAddressFromCellListSource().

◆ doesComponentSupport()

bool pcr::CellBindingHelper::doesComponentSupport ( const css::uno::Reference< css::uno::XInterface > &  _rxComponent,
const OUString &  _rService 
)
staticprivate

checks whether a given component supports a given service

Definition at line 492 of file cellbindinghelper.cxx.

Referenced by isCellBinding(), isCellIntegerBinding(), and isCellRangeListSource().

◆ getAddressFromCellBinding()

bool pcr::CellBindingHelper::getAddressFromCellBinding ( const css::uno::Reference< css::form::binding::XValueBinding > &  _rxBinding,
css::table::CellAddress &  _rAddress 
) const

creates an address object for the given value binding's address

@precond The binding is a valid cell binding, or <NULL>

Returns
<FALSE> if and only if an error occurred and no valid address could be obtained
See also
isCellBinding

Definition at line 285 of file cellbindinghelper.cxx.

References Exception, isCellBinding(), m_xDocument, PROPERTY_BOUND_CELL, and TOOLS_WARN_EXCEPTION.

Referenced by getStringAddressFromCellBinding().

◆ getControlSheetIndex()

sal_Int16 pcr::CellBindingHelper::getControlSheetIndex ( css::uno::Reference< css::sheet::XSpreadsheet > &  _out_rxSheet) const

retrieves the index of the sheet which our control belongs to

Returns
the index of the sheet which our control belongs to or -1, if an error occurred

Definition at line 96 of file cellbindinghelper.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, i, m_xControlModel, and m_xDocument.

Referenced by doConvertAddressRepresentations().

◆ getCurrentBinding()

Reference< XValueBinding > pcr::CellBindingHelper::getCurrentBinding ( ) const

returns the current binding of our control model, if any.

Definition at line 500 of file cellbindinghelper.cxx.

References m_xControlModel.

◆ getCurrentListSource()

Reference< XListEntrySource > pcr::CellBindingHelper::getCurrentListSource ( ) const

returns the current external list source of the control model, if any

Definition at line 510 of file cellbindinghelper.cxx.

References m_xControlModel, and xSink.

◆ getStringAddressFromCellBinding()

OUString pcr::CellBindingHelper::getStringAddressFromCellBinding ( const css::uno::Reference< css::form::binding::XValueBinding > &  _rxBinding) const

creates a string representation for the given value binding's address

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.

@precond The binding is a valid cell binding, or <NULL>

See also
isCellBinding

Definition at line 313 of file cellbindinghelper.cxx.

References Any, doConvertAddressRepresentations(), getAddressFromCellBinding(), PROPERTY_ADDRESS, and PROPERTY_UI_REPRESENTATION.

◆ getStringAddressFromCellListSource()

OUString pcr::CellBindingHelper::getStringAddressFromCellListSource ( const css::uno::Reference< css::form::binding::XListEntrySource > &  _rxSource) const

creates a string representation for the given list source's range address

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.

@precond The object is a valid cell range list source, or <NULL>

See also
isCellRangeListSource

Definition at line 330 of file cellbindinghelper.cxx.

References Any, doConvertAddressRepresentations(), Exception, isCellRangeListSource(), m_xDocument, PROPERTY_ADDRESS, PROPERTY_LIST_CELL_RANGE, PROPERTY_UI_REPRESENTATION, and TOOLS_WARN_EXCEPTION.

◆ isCellBinding()

bool pcr::CellBindingHelper::isCellBinding ( const css::uno::Reference< css::form::binding::XValueBinding > &  _rxBinding)
static

checks whether a given binding is a spreadsheet cell binding

Definition at line 474 of file cellbindinghelper.cxx.

References doesComponentSupport(), and SERVICE_SHEET_CELL_BINDING.

Referenced by getAddressFromCellBinding(), and pcr::CellBindingPropertyHandler::getPropertyValue().

◆ isCellBindingAllowed()

bool pcr::CellBindingHelper::isCellBindingAllowed ( ) const

checks whether it's possible to bind the control model to a spreadsheet cell

Definition at line 440 of file cellbindinghelper.cxx.

References Exception, isSpreadsheetDocumentWhichSupplies(), m_xControlModel, PROPERTY_CLASSID, SERVICE_SHEET_CELL_BINDING, and TOOLS_WARN_EXCEPTION.

◆ isCellIntegerBinding()

bool pcr::CellBindingHelper::isCellIntegerBinding ( const css::uno::Reference< css::form::binding::XValueBinding > &  _rxBinding)
static

checks whether a given binding is a spreadsheet cell binding, exchanging integer values

Definition at line 480 of file cellbindinghelper.cxx.

References doesComponentSupport(), and SERVICE_SHEET_CELL_INT_BINDING.

Referenced by pcr::CellBindingPropertyHandler::getPropertyValue(), and pcr::CellBindingPropertyHandler::setPropertyValue().

◆ isCellIntegerBindingAllowed()

bool pcr::CellBindingHelper::isCellIntegerBindingAllowed ( ) const

checks whether it's possible to bind the control model to a spreadsheet cell, with exchanging integer values

Definition at line 403 of file cellbindinghelper.cxx.

References Exception, isSpreadsheetDocumentWhichSupplies(), m_xControlModel, PROPERTY_CLASSID, SERVICE_SHEET_CELL_INT_BINDING, and TOOLS_WARN_EXCEPTION.

◆ isCellRangeListSource()

bool pcr::CellBindingHelper::isCellRangeListSource ( const css::uno::Reference< css::form::binding::XListEntrySource > &  _rxSource)
static

checks whether a given list source is a spreadsheet cell list source

Definition at line 486 of file cellbindinghelper.cxx.

References doesComponentSupport(), and SERVICE_SHEET_CELLRANGE_LISTSOURCE.

Referenced by pcr::CellBindingPropertyHandler::getPropertyValue(), and getStringAddressFromCellListSource().

◆ isListCellRangeAllowed()

bool pcr::CellBindingHelper::isListCellRangeAllowed ( ) const

checks whether it's possible to bind the control model to range of spreadsheet cells supplying the list entries

Definition at line 389 of file cellbindinghelper.cxx.

References isSpreadsheetDocumentWhichSupplies(), m_xControlModel, SERVICE_SHEET_CELLRANGE_LISTSOURCE, and xSink.

◆ isSpreadsheetDocument()

bool pcr::CellBindingHelper::isSpreadsheetDocument ( const css::uno::Reference< css::frame::XModel > &  _rxContextDocument)
static

determines whether the given model is a spreadsheet document model

If this method returns <FALSE>, you cannot instantiate a CellBindingHelper with the document, since then no of its functionality will be available.

Definition at line 90 of file cellbindinghelper.cxx.

Referenced by pcr::CellBindingPropertyHandler::onNewComponent().

◆ isSpreadsheetDocumentWhichSupplies()

bool pcr::CellBindingHelper::isSpreadsheetDocumentWhichSupplies ( const OUString &  _rService) const
private

determines if our document is a spreadsheet document, and can supply the given service

Definition at line 363 of file cellbindinghelper.cxx.

References m_xDocument, and SERVICE_SPREADSHEET_DOCUMENT.

Referenced by CellBindingHelper(), isCellBindingAllowed(), isCellIntegerBindingAllowed(), and isListCellRangeAllowed().

◆ setBinding()

void pcr::CellBindingHelper::setBinding ( const css::uno::Reference< css::form::binding::XValueBinding > &  _rxBinding)

sets a new binding for our control model @precond the control model is bindable (which is implied by <member>isCellBindingAllowed</member> returning <TRUE>)

Definition at line 520 of file cellbindinghelper.cxx.

References m_xControlModel.

◆ setListSource()

void pcr::CellBindingHelper::setListSource ( const css::uno::Reference< css::form::binding::XListEntrySource > &  _rxSource)

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>)

Definition at line 529 of file cellbindinghelper.cxx.

References m_xControlModel, and xSink.

Member Data Documentation

◆ m_xControlModel

css::uno::Reference< css::beans::XPropertySet > pcr::CellBindingHelper::m_xControlModel
private

◆ m_xDocument

css::uno::Reference< css::sheet::XSpreadsheetDocument > pcr::CellBindingHelper::m_xDocument
private

The documentation for this class was generated from the following files: