25#include <com/sun/star/form/binding/XValueBinding.hpp>
26#include <com/sun/star/lang/NullPointerException.hpp>
27#include <com/sun/star/table/CellAddress.hpp>
28#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
44 using namespace ::com::sun::star::form::binding;
56 return "com.sun.star.comp.extensions.CellBindingPropertyHandler";
62 return {
"com.sun.star.form.inspection.CellBindingPropertyHandler" };
71 DBG_ASSERT( xDocument.is(),
"CellBindingPropertyHandler::onNewComponent: no document!" );
87 return aInterestingProperties;
93 ::osl::MutexGuard aGuard(
m_aMutex );
96 "CellBindingPropertyHandler::actuatingPropertyChanged: inconsistency!");
99 OSL_PRECOND( _rxInspectorUI.is(),
"FormComponentPropertyHandler::actuatingPropertyChanged: no access to the UI!" );
100 if ( !_rxInspectorUI.is() )
101 throw NullPointerException();
103 std::vector< PropertyId > aDependentProperties;
105 switch ( nActuatingPropId )
112 Reference< XValueBinding > xBinding;
113 _rNewValue >>= xBinding;
127 if ( !xBinding.is() &&
m_pHelper->getCurrentBinding().is() )
142 Reference< XListEntrySource > xSource;
143 _rNewValue >>= xSource;
153 if ( !_bFirstTimeInit )
166 "extensions.propctrlr",
167 "ListCellRange: caught an exception while resetting the string items!");
176 OUString sControlSource;
177 _rNewValue >>= sControlSource;
184 OSL_FAIL(
"CellBindingPropertyHandler::actuatingPropertyChanged: did not register for this property!" );
187 for (
auto const& dependentProperty : aDependentProperties)
217 TOOLS_WARN_EXCEPTION(
"extensions.propctrlr",
"CellBindingPropertyHandler::impl_updateDependentProperty_nothrow" );
224 ::osl::MutexGuard aGuard(
m_aMutex );
227 OSL_ENSURE(
m_pHelper,
"CellBindingPropertyHandler::getPropertyValue: inconsistency!");
235 Reference< XValueBinding > xBinding(
m_pHelper->getCurrentBinding() );
239 aReturn <<= xBinding;
245 Reference< XListEntrySource > xSource(
m_pHelper->getCurrentListSource() );
255 Reference< XValueBinding > xBinding(
m_pHelper->getCurrentBinding() );
261 OSL_FAIL(
"CellBindingPropertyHandler::getPropertyValue: cannot handle this!" );
270 ::osl::MutexGuard aGuard(
m_aMutex );
273 OSL_ENSURE(
m_pHelper,
"CellBindingPropertyHandler::setPropertyValue: inconsistency!");
284 Reference< XValueBinding > xBinding;
285 _rValue >>= xBinding;
292 Reference< XListEntrySource > xSource;
300 sal_Int16 nExchangeType = 0;
301 OSL_VERIFY( _rValue >>= nExchangeType );
303 Reference< XValueBinding > xBinding =
m_pHelper->getCurrentBinding( );
306 bool bNeedIntegerBinding = ( nExchangeType == 1 );
309 CellAddress aAddress;
310 if (
m_pHelper->getAddressFromCellBinding( xBinding, aAddress ) )
312 xBinding =
m_pHelper->createCellBindingFromAddress( aAddress, bNeedIntegerBinding );
321 OSL_FAIL(
"CellBindingPropertyHandler::setPropertyValue: cannot handle this!" );
342 ::osl::MutexGuard aGuard(
m_aMutex );
347 "CellBindingPropertyHandler::convertToPropertyValue: we have no SupportedProperties!");
349 return aPropertyValue;
353 OUString sControlValue;
354 OSL_VERIFY( _rControlValue >>= sControlValue );
358 aPropertyValue <<=
m_pHelper->createCellListSourceFromStringAddress( sControlValue );
366 bool bIntegerBinding =
false;
367 if (
m_pHelper->isCellIntegerBindingAllowed() )
369 sal_Int16 nCurrentBindingType = 0;
371 bIntegerBinding = ( nCurrentBindingType != 0 );
373 aPropertyValue <<=
m_pHelper->createCellBindingFromStringAddress( sControlValue, bIntegerBinding );
382 OSL_FAIL(
"CellBindingPropertyHandler::convertToPropertyValue: cannot handle this!" );
386 return aPropertyValue;
391 const Any& _rPropertyValue,
const Type& )
393 ::osl::MutexGuard aGuard(
m_aMutex );
398 "CellBindingPropertyHandler::convertToControlValue: we have no SupportedProperties!");
400 return aControlValue;
408 Reference< XValueBinding > xBinding;
409 bool bSuccess = _rPropertyValue >>= xBinding;
410 OSL_ENSURE( bSuccess,
"CellBindingPropertyHandler::convertToControlValue: invalid value (1)!" );
413 aControlValue <<=
m_pHelper->getStringAddressFromCellBinding( xBinding );
419 Reference< XListEntrySource > xSource;
420 bool bSuccess = _rPropertyValue >>= xSource;
421 OSL_ENSURE( bSuccess,
"CellBindingPropertyHandler::convertToControlValue: invalid value (2)!" );
424 aControlValue <<=
m_pHelper->getStringAddressFromCellListSource( xSource );
433 OSL_FAIL(
"CellBindingPropertyHandler::convertToControlValue: cannot handle this!" );
437 return aControlValue;
448 if ( bAllowCellLinking || bAllowListCellRange || bAllowCellIntLinking )
450 sal_Int32
nPos = ( bAllowCellLinking ? 1 : 0 )
451 + ( bAllowListCellRange ? 1 : 0 )
452 + ( bAllowCellIntLinking ? 1 : 0 );
455 if ( bAllowCellLinking )
460 if ( bAllowCellIntLinking )
465 if ( bAllowListCellRange )
473 return Sequence< Property >();
480extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
482 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any>
const&)
PropertiesInfo aProperties
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * extensions_propctrlr_CellBindingPropertyHandler_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
mutable::osl::Mutex m_aMutex
encapsulates functionality related to binding a form control to a spreadsheet cell
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
static bool isCellRangeListSource(const css::uno::Reference< css::form::binding::XListEntrySource > &_rxSource)
checks whether a given list source is a spreadsheet cell list source
static bool isCellBinding(const css::uno::Reference< css::form::binding::XValueBinding > &_rxBinding)
checks whether a given binding is a spreadsheet cell binding
static bool isSpreadsheetDocument(const css::uno::Reference< css::frame::XModel > &_rxContextDocument)
determines whether the given model is a spreadsheet document model
virtual void SAL_CALL actuatingPropertyChanged(const OUString &_rActuatingPropertyName, const css::uno::Any &_rNewValue, const css::uno::Any &_rOldValue, const css::uno::Reference< css::inspection::XObjectInspectorUI > &_rxInspectorUI, sal_Bool _bFirstTimeInit) override
virtual css::uno::Any SAL_CALL convertToControlValue(const OUString &_rPropertyName, const css::uno::Any &_rPropertyValue, const css::uno::Type &_rControlValueType) override
void impl_updateDependentProperty_nothrow(PropertyId _nPropId, const css::uno::Reference< css::inspection::XObjectInspectorUI > &_rxInspectorUI) const
updates a property (UI) whose state depends on more than one other property
virtual ~CellBindingPropertyHandler() override
virtual OUString SAL_CALL getImplementationName() override
std::unique_ptr< CellBindingHelper > m_pHelper
virtual css::uno::Sequence< css::beans::Property > doDescribeSupportedProperties() const override
virtual void onNewComponent() override
called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect
virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override
virtual void SAL_CALL setPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rValue) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &_rPropertyName) override
virtual css::uno::Any SAL_CALL convertToPropertyValue(const OUString &_rPropertyName, const css::uno::Any &_rControlValue) override
::rtl::Reference< IPropertyEnumRepresentation > m_pCellExchangeConverter
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
CellBindingPropertyHandler(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
an implementation of the IPropertyEnumRepresentation
PropertyHandler implementation which additionally supports XServiceInfo.
std::unique_ptr< OPropertyInfoService > m_pInfoService
access to property meta data
virtual void onNewComponent()
called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect
bool impl_isSupportedProperty_nothrow(PropertyId _nPropId) const
determines whether a given property id is part of our supported properties
void firePropertyChange(const OUString &_rPropName, PropertyId _nPropId, const css::uno::Any &_rOldValue, const css::uno::Any &_rNewValue)
fires the change in a property value to our listener (if any)
bool impl_componentHasProperty_throw(const OUString &_rPropName) const
determines whether our component has a given property
PropertyId impl_getPropertyId_throwUnknownProperty(const OUString &_rPropertyName) const
retrieves the property id for a given property name
css::uno::Reference< css::beans::XPropertySet > m_xComponent
the component we're inspecting
PropertyId impl_getPropertyId_throwRuntime(const OUString &_rPropertyName) const
retrieves the property id for a given property name
void impl_setContextDocumentModified_nothrow() const
marks the context document as modified
css::uno::Reference< css::frame::XModel > impl_getContextDocument_nothrow() const
returns the value of the ContextDocument property in the ComponentContext which was used to create th...
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
a property handler for any virtual string properties
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)