31#include <com/sun/star/form/inspection/FormComponentPropertyHandler.hpp>
32#include <com/sun/star/inspection/PropertyControlType.hpp>
33#include <com/sun/star/inspection/PropertyLineElement.hpp>
34#include <com/sun/star/lang/NullPointerException.hpp>
35#include <com/sun/star/chart/ChartDataRowSource.hpp>
36#include <com/sun/star/chart2/FormattedString.hpp>
37#include <com/sun/star/chart2/XTitled.hpp>
38#include <com/sun/star/chart2/XTitle.hpp>
39#include <com/sun/star/chart2/data/XDataReceiver.hpp>
40#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
41#include <com/sun/star/report/XReportDefinition.hpp>
42#include <com/sun/star/script/Converter.hpp>
43#include <com/sun/star/container/XNameContainer.hpp>
45#include <osl/mutex.hxx>
47#include <core_resource.hxx>
50#include <PropertyForward.hxx>
64 m_xFormComponentHandler = form::inspection::FormComponentPropertyHandler::create(m_xContext);
65 m_xTypeConverter = script::Converter::create(m_xContext);
67 }
catch(
const uno::Exception &)
72OUString SAL_CALL DataProviderHandler::getImplementationName( )
74 return "com.sun.star.comp.report.DataProviderHandler";
77sal_Bool SAL_CALL DataProviderHandler::supportsService(
const OUString& ServiceName )
82uno::Sequence< OUString > SAL_CALL DataProviderHandler::getSupportedServiceNames( )
84 return {
"com.sun.star.report.inspection.DataProviderHandler" };
91void SAL_CALL DataProviderHandler::disposing()
93 ::comphelper::disposeComponent(m_xFormComponentHandler);
94 ::comphelper::disposeComponent( m_xMasterDetails );
95 ::comphelper::disposeComponent(m_xTypeConverter);
97void SAL_CALL DataProviderHandler::addEventListener(
const uno::Reference< lang::XEventListener > & xListener)
99 m_xFormComponentHandler->addEventListener(xListener);
102void SAL_CALL DataProviderHandler::removeEventListener(
const uno::Reference< lang::XEventListener > & aListener)
104 m_xFormComponentHandler->removeEventListener(aListener);
110void SAL_CALL DataProviderHandler::inspect(
const uno::Reference< uno::XInterface > &
Component)
114 uno::Reference< container::XNameContainer > xNameCont(
Component,uno::UNO_QUERY);
115 static constexpr OUStringLiteral sFormComponent(
u"FormComponent");
116 if ( xNameCont->hasByName(sFormComponent) )
118 uno::Reference<beans::XPropertySet> xProp(xNameCont->getByName(sFormComponent),uno::UNO_QUERY);
119 static constexpr OUStringLiteral
sModel(
u"Model");
120 if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(
sModel) )
122 m_xChartModel.set(xProp->getPropertyValue(
sModel),uno::UNO_QUERY);
123 if ( m_xChartModel.is() )
124 m_xFormComponent = m_xChartModel->getDataProvider();
127 m_xDataProvider.set(m_xFormComponent,uno::UNO_QUERY);
128 m_xReportComponent.set( xNameCont->getByName(
"ReportComponent"), uno::UNO_QUERY );
129 if ( m_xDataProvider.is() )
131 auto aNoConverter = std::make_shared<AnyConverter>();
136 m_xMasterDetails =
new OPropertyMediator( m_xDataProvider, m_xReportComponent, std::move(aPropertyMediation),
true );
139 catch(
const uno::Exception &)
141 throw lang::NullPointerException();
143 if ( m_xFormComponent.is() )
145 m_xFormComponentHandler->inspect(m_xFormComponent);
149uno::Any SAL_CALL DataProviderHandler::getPropertyValue(
const OUString & PropertyName)
151 ::osl::MutexGuard aGuard(
m_aMutex );
153 const sal_Int32
nId = OPropertyInfoService::getPropertyId(PropertyName);
187 aPropertyValue <<= m_xDataProvider->getRowLimit();
190 aPropertyValue = m_xFormComponentHandler->getPropertyValue( PropertyName );
193 return aPropertyValue;
196void SAL_CALL DataProviderHandler::setPropertyValue(
const OUString & PropertyName,
const uno::Any & Value)
198 ::osl::MutexGuard aGuard(
m_aMutex );
199 const sal_Int32
nId = OPropertyInfoService::getPropertyId(PropertyName);
205 m_xDataProvider->setPropertyValue(PropertyName,
Value);
208 m_xFormComponentHandler->setPropertyValue(PropertyName,
Value);
213void DataProviderHandler::impl_updateChartTitle_throw(
const uno::Any& _aValue)
215 uno::Reference<chart2::XTitled> xTitled(m_xChartModel,uno::UNO_QUERY);
219 uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
222 xTitle.set(
m_xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.chart2.Title",
m_xContext),uno::UNO_QUERY);
223 xTitled->setTitleObject(xTitle);
227 uno::Reference< chart2::XFormattedString2> xFormatted = chart2::FormattedString::create(
m_xContext);
230 xFormatted->setString(sStr);
231 xTitle->setText({ xFormatted });
235beans::PropertyState SAL_CALL DataProviderHandler::getPropertyState(
const OUString & PropertyName)
237 return m_xFormComponentHandler->getPropertyState(PropertyName);
240inspection::LineDescriptor SAL_CALL DataProviderHandler::describePropertyLine(
const OUString & PropertyName,
const uno::Reference< inspection::XPropertyControlFactory > & _xControlFactory)
242 inspection::LineDescriptor aOut;
243 const sal_Int32
nId = OPropertyInfoService::getPropertyId(PropertyName);
248 aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::TextField ,
true);
249 aOut.HasPrimaryButton =
true;
252 aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::NumericField ,
false);
256 aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::StringListField ,
false);
258 aOut.HasPrimaryButton =
true;
261 aOut = m_xFormComponentHandler->describePropertyLine(PropertyName, _xControlFactory);
266 std::u16string_view(
u"Data")
268 std::u16string_view(
u"General");
269 aOut.HelpURL = HelpIdUrl::getHelpURL( OPropertyInfoService::getPropertyHelpId(
nId ) );
270 aOut.DisplayName = OPropertyInfoService::getPropertyTranslation(
nId);
275uno::Any SAL_CALL DataProviderHandler::convertToPropertyValue(
const OUString & _rPropertyValue,
const uno::Any & _rControlValue)
277 ::osl::MutexGuard aGuard(
m_aMutex );
278 uno::Any aPropertyValue( _rControlValue );
279 const sal_Int32
nId = OPropertyInfoService::getPropertyId(_rPropertyValue);
289 catch(
const uno::Exception& )
291 TOOLS_WARN_EXCEPTION(
"reportdesign",
"DataProviderHandler::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
298 aPropertyValue = m_xFormComponentHandler->convertToPropertyValue(_rPropertyValue, _rControlValue);
300 return aPropertyValue;
303uno::Any SAL_CALL DataProviderHandler::convertToControlValue(
const OUString & _rPropertyName,
const uno::Any & _rPropertyValue,
const uno::Type & ControlValueType)
305 uno::Any aControlValue( _rPropertyValue );
308 return aControlValue;
310 ::osl::MutexGuard aGuard(
m_aMutex );
311 const sal_Int32
nId = OPropertyInfoService::getPropertyId(_rPropertyName);
321 aControlValue = m_xTypeConverter->convertTo( _rPropertyValue, ControlValueType);
323 catch(
const uno::Exception& )
325 TOOLS_WARN_EXCEPTION(
"reportdesign",
"GeometryHandler::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
329 aControlValue = m_xFormComponentHandler->convertToControlValue(_rPropertyName, _rPropertyValue, ControlValueType);
331 return aControlValue;
334void SAL_CALL DataProviderHandler::addPropertyChangeListener(
const uno::Reference< beans::XPropertyChangeListener > & Listener)
336 m_xFormComponentHandler->addPropertyChangeListener(Listener);
339void SAL_CALL DataProviderHandler::removePropertyChangeListener(
const uno::Reference< beans::XPropertyChangeListener > & _rxListener)
341 m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
344uno::Sequence< beans::Property > SAL_CALL DataProviderHandler::getSupportedProperties()
346 ::std::vector< beans::Property > aNewProps;
347 if( m_xChartModel.is() )
350 beans::Property aValue;
351 static const rtl::OUStringConstExpr s_pProperties[] =
359 for (
const auto & rName : s_pProperties)
362 aNewProps.push_back(aValue);
365 return uno::Sequence< beans::Property >(aNewProps.data(), aNewProps.size());
368uno::Sequence< OUString > SAL_CALL DataProviderHandler::getSupersededProperties()
374uno::Sequence< OUString > SAL_CALL DataProviderHandler::getActuatingProperties()
376 ::osl::MutexGuard aGuard(
m_aMutex );
379 return ::comphelper::concatSequences(m_xFormComponentHandler->getActuatingProperties(),
aSeq);
382sal_Bool SAL_CALL DataProviderHandler::isComposable(
const OUString& _rPropertyName )
384 return OPropertyInfoService::isComposable( _rPropertyName, m_xFormComponentHandler );
387inspection::InteractiveSelectionResult SAL_CALL DataProviderHandler::onInteractivePropertySelection(
const OUString & PropertyName,
sal_Bool Primary,
uno::Any & out_Data,
const uno::Reference< inspection::XObjectInspectorUI > & _rxInspectorUI)
389 if ( !_rxInspectorUI.is() )
390 throw lang::NullPointerException();
392 inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
393 ::osl::ClearableMutexGuard aGuard(
m_aMutex );
395 const sal_Int32
nId = OPropertyInfoService::getPropertyId(PropertyName);
399 if ( impl_dialogChartType_nothrow(aGuard) )
400 eResult = inspection::InteractiveSelectionResult_ObtainedValue;
404 if ( impl_dialogLinkedFields_nothrow( aGuard ) )
405 eResult = inspection::InteractiveSelectionResult_Success;
408 eResult = m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, out_Data, _rxInspectorUI);
414void SAL_CALL DataProviderHandler::actuatingPropertyChanged(
const OUString & ActuatingPropertyName,
const uno::Any & NewValue,
const uno::Any & OldValue,
const uno::Reference< inspection::XObjectInspectorUI > & InspectorUI,
sal_Bool FirstTimeInit)
420 if ( NewValue != OldValue )
422 uno::Reference< report::XReportDefinition> xReport = m_xReportComponent->getSection()->getReportDefinition();
423 bool bDoEnableMasterDetailFields = xReport.is() && !xReport->getCommand().isEmpty() && !m_xDataProvider->getCommand().isEmpty();
424 InspectorUI->enablePropertyUIElements(
PROPERTY_DETAILFIELDS, inspection::PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
425 InspectorUI->enablePropertyUIElements(
PROPERTY_MASTERFIELDS, inspection::PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
427 bool bModified = xReport->isModified();
430 aArgs.
put(
"CellRangeRepresentation",
uno::Any( OUString(
"all" ) ) );
433 aArgs.
put(
"DataRowSource",
uno::Any( chart::ChartDataRowSource_COLUMNS ) );
434 uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xChartModel,uno::UNO_QUERY_THROW);
437 xReport->setModified(
false);
439 m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
443 if ( NewValue != OldValue )
444 impl_updateChartTitle_throw(NewValue);
448 const sal_Int32
nId = OPropertyInfoService::getPropertyId(ActuatingPropertyName);
457 m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
464 return m_xFormComponentHandler->suspend(Suspend);
466bool DataProviderHandler::impl_dialogLinkedFields_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog )
const
470 {
"ParentWindow",
m_xContext->getValueByName(
"DialogParentWindow")},
471 {
"Detail",
uno::Any(m_xDataProvider)},
472 {
"Master",
uno::Any(m_xReportComponent->getSection()->getReportDefinition())},
478 uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
479 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
480 "org.openoffice.comp.form.ui.MasterDetailLinkDialog",
aSeq,
m_xContext),
483 _rClearBeforeDialog.clear();
484 return ( xDialog->execute() != 0 );
487bool DataProviderHandler::impl_dialogChartType_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog )
const
491 {
"ParentWindow",
m_xContext->getValueByName(
"DialogParentWindow")},
492 {
"ChartModel",
uno::Any(m_xChartModel)}
495 uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
496 m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
500 _rClearBeforeDialog.clear();
501 return ( xDialog->execute() != 0 );
507extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
509 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_DataProviderHandler_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Reference< XComponentContext > m_xContext
constexpr OUStringLiteral sModel
bool put(const OUString &_rValueName, const VALUE_TYPE &_rValue)
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues() const
DataProviderHandler(css::uno::Reference< css::uno::XComponentContext > context)
static void getExcludeProperties(::std::vector< css::beans::Property > &_rExcludeProperties, const css::uno::Reference< css::inspection::XPropertyHandler > &_xFormComponentHandler)
OUString RptResId(TranslateId aId)
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr OUStringLiteral UID_RPT_PROP_DLG_LINKFIELDS
constexpr OUStringLiteral UID_RPT_PROP_CHARTTYPE_DLG
Sequence< sal_Int8 > aSeq
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
::cppu::WeakComponentImplHelper< css::inspection::XPropertyHandler, css::lang::XServiceInfo > DataProviderHandler_Base
std::map< OUString, TPropertyConverter > TPropertyNamePair
::std::pair< OUString, std::shared_ptr< AnyConverter > > TPropertyConverter
constexpr OUStringLiteral PROPERTY_TITLE
constexpr OUStringLiteral PROPERTY_CHARTTYPE
constexpr OUStringLiteral PROPERTY_COMMAND
constexpr OUStringLiteral PROPERTY_DETAILFIELDS
constexpr OUStringLiteral PROPERTY_MASTERFIELDS
constexpr OUStringLiteral PROPERTY_PREVIEW_COUNT
::std::pair< MetaAction *, int > Component