21#include <com/sun/star/form/binding/XBindableValue.hpp>
22#include <com/sun/star/form/binding/XValueBinding.hpp>
23#include <com/sun/star/form/binding/XListEntrySink.hpp>
24#include <com/sun/star/form/binding/XListEntrySource.hpp>
25#include <com/sun/star/frame/XModel.hpp>
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/container/XNameAccess.hpp>
28#include <com/sun/star/table/CellRangeAddress.hpp>
29#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
30#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
31#include <com/sun/star/lang/XMultiServiceFactory.hpp>
32#include <com/sun/star/table/CellAddress.hpp>
33#include <com/sun/star/beans/NamedValue.hpp>
42static bool lcl_isNamedRange(
const OUString& sAddress,
const uno::Reference< frame::XModel >& xModel, css::table::CellRangeAddress& aAddress )
45 uno::Reference< sheet::XCellRangeReferrer > xReferrer;
48 uno::Reference< beans::XPropertySet > xPropSet(
xModel, uno::UNO_QUERY_THROW );
49 uno::Reference< container::XNameAccess > xNamed( xPropSet->getPropertyValue(
"NamedRanges" ), uno::UNO_QUERY_THROW );
50 xReferrer.set ( xNamed->getByName( sAddress ), uno::UNO_QUERY );
52 catch( uno::Exception& )
58 uno::Reference< sheet::XCellRangeAddressable > xRangeAddressable( xReferrer->getReferredCells(), uno::UNO_QUERY );
59 if ( xRangeAddressable.is() )
61 aAddress = xRangeAddressable->getRangeAddress();
73 uno::Reference< lang::XMultiServiceFactory > xFac;
75 xFac.set(
xModel, uno::UNO_QUERY );
76 uno::Reference< form::binding::XBindableValue > xBindable( rObj, uno::UNO_QUERY );
77 if ( xFac.is() && rsCtrlSource.getLength() && xBindable.is() )
84 uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance(
"com.sun.star.table.CellAddressConversion"), uno::UNO_QUERY );
85 css::table::CellAddress aAddress;
86 if ( xConvertor.is() )
90 xConvertor->setPropertyValue(
"ReferenceSheet",
uno::Any( nRefTab ) );
91 xConvertor->setPropertyValue(
"XLA1Representation",
uno::Any( rsCtrlSource ) );
92 xConvertor->getPropertyValue(
"Address" ) >>= aAddress;
95 beans::NamedValue aArg1;
96 aArg1.Name =
"BoundCell";
97 aArg1.Value <<= aAddress;
99 uno::Sequence< uno::Any > aArgs{
uno::Any(aArg1) };
100 uno::Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments(
"com.sun.star.table.CellValueBinding", aArgs ), uno::UNO_QUERY );
101 xBindable->setValueBinding( xBinding );
103 else if ( xBindable.is() )
104 xBindable->setValueBinding( uno::Reference< form::binding::XValueBinding >() );
105 uno::Reference< form::binding::XListEntrySink > xListEntrySink( rObj, uno::UNO_QUERY );
106 if ( xFac.is() && rsRowSource.getLength() && xListEntrySink.is() )
113 uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance(
"com.sun.star.table.CellRangeAddressConversion"), uno::UNO_QUERY );
114 css::table::CellRangeAddress aAddress;
115 if ( xConvertor.is() )
121 xConvertor->setPropertyValue(
"ReferenceSheet",
uno::Any( nRefTab ) );
122 xConvertor->setPropertyValue(
"XLA1Representation",
uno::Any( rsRowSource ) );
123 xConvertor->getPropertyValue(
"Address" ) >>= aAddress;
127 beans::NamedValue aArg1;
128 aArg1.Name =
"CellRange";
129 aArg1.Value <<= aAddress;
131 uno::Sequence< uno::Any > aArgs{
uno::Any(aArg1) };
132 uno::Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments(
"com.sun.star.table.CellRangeListSource", aArgs ), uno::UNO_QUERY );
133 xListEntrySink->setListEntrySource( xSource );
135 else if ( xListEntrySink.is() )
136 xListEntrySink->setListEntrySource( uno::Reference< form::binding::XListEntrySource >() );
SVT_DLLPUBLIC void ApplyListSourceAndBindableData(const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::uno::XInterface > &rObj, const OUString &rsCtrlSource, const OUString &rsRowSource, sal_uInt16 nRefTab=0)
static bool lcl_isNamedRange(const OUString &sAddress, const uno::Reference< frame::XModel > &xModel, css::table::CellRangeAddress &aAddress)
Reference< XModel > xModel