Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #include "DataProviderHandler.hxx"
20 : #include <com/sun/star/lang/XInitialization.hpp>
21 : #include <comphelper/namedvaluecollection.hxx>
22 : #include <comphelper/sequence.hxx>
23 : #include <comphelper/property.hxx>
24 : #include <comphelper/types.hxx>
25 : #include "uistrings.hrc"
26 : #include <toolkit/helper/vclunohelper.hxx>
27 : #include <unotools/syslocale.hxx>
28 : #include <com/sun/star/inspection/PropertyControlType.hpp>
29 : #include <com/sun/star/inspection/PropertyLineElement.hpp>
30 : #include <com/sun/star/chart/ChartDataRowSource.hpp>
31 : #include <com/sun/star/chart2/XDiagram.hpp>
32 : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
33 : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
34 : #include <com/sun/star/chart2/XChartType.hpp>
35 : #include <com/sun/star/chart2/XFormattedString.hpp>
36 : #include <com/sun/star/chart2/XTitled.hpp>
37 : #include <com/sun/star/chart2/XTitle.hpp>
38 : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
39 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
40 : #include <com/sun/star/report/XReportDefinition.hpp>
41 : #include <com/sun/star/report/XSection.hpp>
42 : #include <com/sun/star/script/Converter.hpp>
43 : #include <com/sun/star/inspection/XNumericControl.hpp>
44 : #include <com/sun/star/container/XNameContainer.hpp>
45 : #include <com/sun/star/util/MeasureUnit.hpp>
46 : #include <tools/fldunit.hxx>
47 : #include "metadata.hxx"
48 : #include <vcl/svapp.hxx>
49 : #include <osl/mutex.hxx>
50 : #include "helpids.hrc"
51 : #include "uistrings.hrc"
52 : #include "RptResId.hrc"
53 : #include "PropertyForward.hxx"
54 : //........................................................................
55 : namespace rptui
56 : {
57 : //........................................................................
58 : using namespace ::com::sun::star;
59 :
60 0 : DataProviderHandler::DataProviderHandler(uno::Reference< uno::XComponentContext > const & context)
61 : :DataProviderHandler_Base(m_aMutex)
62 : ,m_xContext(context)
63 0 : ,m_pInfoService( new OPropertyInfoService() )
64 : {
65 : try
66 : {
67 0 : m_xFormComponentHandler.set(m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.inspection.FormComponentPropertyHandler")),m_xContext),uno::UNO_QUERY_THROW);
68 0 : m_xTypeConverter.set(script::Converter::create(m_xContext));
69 :
70 0 : }catch(const uno::Exception &)
71 : {
72 : }
73 0 : }
74 :
75 : //------------------------------------------------------------------------
76 0 : ::rtl::OUString SAL_CALL DataProviderHandler::getImplementationName( ) throw(uno::RuntimeException)
77 : {
78 0 : return getImplementationName_Static();
79 : }
80 :
81 : //------------------------------------------------------------------------
82 0 : sal_Bool SAL_CALL DataProviderHandler::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
83 : {
84 0 : return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
85 : }
86 :
87 : //------------------------------------------------------------------------
88 0 : uno::Sequence< ::rtl::OUString > SAL_CALL DataProviderHandler::getSupportedServiceNames( ) throw(uno::RuntimeException)
89 : {
90 0 : return getSupportedServiceNames_static();
91 : }
92 :
93 : //------------------------------------------------------------------------
94 0 : ::rtl::OUString DataProviderHandler::getImplementationName_Static( ) throw(uno::RuntimeException)
95 : {
96 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.DataProviderHandler"));
97 : }
98 :
99 : //------------------------------------------------------------------------
100 0 : uno::Sequence< ::rtl::OUString > DataProviderHandler::getSupportedServiceNames_static( ) throw(uno::RuntimeException)
101 : {
102 0 : uno::Sequence< ::rtl::OUString > aSupported(1);
103 0 : aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.inspection.DataProviderHandler"));
104 0 : return aSupported;
105 : }
106 :
107 : //------------------------------------------------------------------------
108 0 : uno::Reference< uno::XInterface > SAL_CALL DataProviderHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
109 : {
110 0 : return *(new DataProviderHandler( _rxContext ));
111 : }
112 : // overload WeakComponentImplHelperBase::disposing()
113 : // This function is called upon disposing the component,
114 : // if your component needs special work when it becomes
115 : // disposed, do it here.
116 0 : void SAL_CALL DataProviderHandler::disposing()
117 : {
118 0 : ::comphelper::disposeComponent(m_xFormComponentHandler);
119 0 : ::comphelper::disposeComponent( m_xMasterDetails );
120 0 : ::comphelper::disposeComponent(m_xTypeConverter);
121 0 : }
122 0 : void SAL_CALL DataProviderHandler::addEventListener(const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException)
123 : {
124 0 : m_xFormComponentHandler->addEventListener(xListener);
125 0 : }
126 :
127 0 : void SAL_CALL DataProviderHandler::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw (uno::RuntimeException)
128 : {
129 0 : m_xFormComponentHandler->removeEventListener(aListener);
130 0 : }
131 :
132 : // inspection::XPropertyHandler:
133 :
134 : /********************************************************************************/
135 0 : void SAL_CALL DataProviderHandler::inspect(const uno::Reference< uno::XInterface > & Component) throw (uno::RuntimeException, lang::NullPointerException)
136 : {
137 : try
138 : {
139 0 : uno::Reference< container::XNameContainer > xNameCont(Component,uno::UNO_QUERY);
140 0 : const ::rtl::OUString sFormComponent(RTL_CONSTASCII_USTRINGPARAM("FormComponent"));
141 0 : if ( xNameCont->hasByName(sFormComponent) )
142 : {
143 0 : uno::Reference<beans::XPropertySet> xProp(xNameCont->getByName(sFormComponent),uno::UNO_QUERY);
144 0 : const ::rtl::OUString sModel(RTL_CONSTASCII_USTRINGPARAM("Model"));
145 0 : if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(sModel) )
146 : {
147 0 : m_xChartModel.set(xProp->getPropertyValue(sModel),uno::UNO_QUERY);
148 0 : if ( m_xChartModel.is() )
149 0 : m_xFormComponent = m_xChartModel->getDataProvider();
150 0 : }
151 : }
152 0 : m_xDataProvider.set(m_xFormComponent,uno::UNO_QUERY);
153 0 : m_xReportComponent.set( xNameCont->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReportComponent" ) ) ), uno::UNO_QUERY );
154 0 : if ( m_xDataProvider.is() )
155 : {
156 0 : ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
157 0 : TPropertyNamePair aPropertyMediation;
158 0 : aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_MASTERFIELDS, TPropertyConverter(PROPERTY_MASTERFIELDS,aNoConverter) ) );
159 0 : aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_DETAILFIELDS, TPropertyConverter(PROPERTY_DETAILFIELDS,aNoConverter) ) );
160 :
161 0 : m_xMasterDetails = new OPropertyMediator( m_xDataProvider.get(), m_xReportComponent.get(), aPropertyMediation,sal_True );
162 0 : }
163 : }
164 0 : catch(const uno::Exception &)
165 : {
166 0 : throw lang::NullPointerException();
167 : }
168 0 : if ( m_xFormComponent.is() )
169 : {
170 0 : m_xFormComponentHandler->inspect(m_xFormComponent);
171 : }
172 0 : }
173 :
174 0 : uno::Any SAL_CALL DataProviderHandler::getPropertyValue(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
175 : {
176 0 : ::osl::MutexGuard aGuard( m_aMutex );
177 0 : uno::Any aPropertyValue;
178 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
179 0 : switch(nId)
180 : {
181 : case PROPERTY_ID_CHARTTYPE:
182 : // TODO: We need a possiblity to get the UI of the selected chart type
183 : //if( m_xChartModel.is() )
184 : //{
185 : // uno::Reference< chart2::XDiagram > xDiagram( m_xChartModel->getFirstDiagram() );
186 : // if( xDiagram.is() )
187 : // {
188 : // ::rtl::OUString sChartTypes;
189 : // uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW );
190 : // const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
191 : // const uno::Reference< chart2::XCoordinateSystem >* pIter = aCooSysSeq.getConstArray();
192 : // const uno::Reference< chart2::XCoordinateSystem >* pEnd = pIter + aCooSysSeq.getLength();
193 : // for(;pIter != pEnd;++pIter)
194 : // {
195 : // const uno::Reference< chart2::XChartTypeContainer > xCTCnt( *pIter, uno::UNO_QUERY_THROW );
196 : // const uno::Sequence< uno::Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
197 : // const uno::Reference< chart2::XChartType >* pChartTypeIter = aCTSeq.getConstArray();
198 : // const uno::Reference< chart2::XChartType >* pChartTypeEnd = pChartTypeIter + aCTSeq.getLength();
199 : // for(;pChartTypeIter != pChartTypeEnd;++pChartTypeIter)
200 : // {
201 : // sChartTypes += (*pChartTypeIter)->getChartType();
202 : // sChartTypes += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
203 : // }
204 : // }
205 : // aPropertyValue;// <<= sChartTypes;
206 : // }
207 : //}
208 0 : break;
209 : case PROPERTY_ID_PREVIEW_COUNT:
210 0 : aPropertyValue <<= m_xDataProvider->getRowLimit();
211 0 : break;
212 : default:
213 0 : aPropertyValue = m_xFormComponentHandler->getPropertyValue( PropertyName );
214 0 : break;
215 : }
216 0 : return aPropertyValue;
217 : }
218 :
219 0 : void SAL_CALL DataProviderHandler::setPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & Value) throw (uno::RuntimeException, beans::UnknownPropertyException)
220 : {
221 0 : ::osl::MutexGuard aGuard( m_aMutex );
222 0 : uno::Any aPropertyValue;
223 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
224 0 : switch(nId)
225 : {
226 : case PROPERTY_ID_CHARTTYPE:
227 0 : break;
228 : case PROPERTY_ID_PREVIEW_COUNT:
229 0 : m_xDataProvider->setPropertyValue(PropertyName,Value);
230 0 : break;
231 : default:
232 0 : m_xFormComponentHandler->setPropertyValue(PropertyName, Value);
233 0 : break;
234 0 : }
235 0 : }
236 : // -----------------------------------------------------------------------------
237 0 : void DataProviderHandler::impl_updateChartTitle_throw(const uno::Any& _aValue)
238 : {
239 0 : uno::Reference<chart2::XTitled> xTitled(m_xChartModel,uno::UNO_QUERY);
240 0 : if ( xTitled.is() )
241 : {
242 0 : uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
243 0 : if ( !xTitle.is() )
244 : {
245 0 : xTitle.set(m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.Title")),m_xContext),uno::UNO_QUERY);
246 0 : xTitled->setTitleObject(xTitle);
247 : }
248 0 : if ( xTitle.is() )
249 : {
250 0 : uno::Reference< chart2::XFormattedString> xFormatted(m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.FormattedString")),m_xContext),uno::UNO_QUERY);
251 0 : ::rtl::OUString sStr;
252 0 : _aValue>>= sStr;
253 0 : xFormatted->setString(sStr);
254 0 : uno::Sequence< uno::Reference< chart2::XFormattedString> > aArgs(1);
255 0 : aArgs[0] = xFormatted;
256 0 : xTitle->setText(aArgs);
257 0 : }
258 0 : }
259 0 : }
260 :
261 0 : beans::PropertyState SAL_CALL DataProviderHandler::getPropertyState(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
262 : {
263 0 : return m_xFormComponentHandler->getPropertyState(PropertyName);
264 : }
265 :
266 0 : inspection::LineDescriptor SAL_CALL DataProviderHandler::describePropertyLine(const ::rtl::OUString & PropertyName, const uno::Reference< inspection::XPropertyControlFactory > & _xControlFactory) throw (beans::UnknownPropertyException, lang::NullPointerException,uno::RuntimeException)
267 : {
268 0 : inspection::LineDescriptor aOut;
269 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
270 0 : switch(nId)
271 : {
272 : case PROPERTY_ID_CHARTTYPE:
273 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_PROP_CHARTTYPE_DLG);
274 0 : aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::TextField , sal_True);
275 0 : aOut.HasPrimaryButton = sal_True;
276 0 : break;
277 : case PROPERTY_ID_PREVIEW_COUNT:
278 0 : aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::NumericField , sal_False);
279 0 : break;
280 : case PROPERTY_ID_MASTERFIELDS:
281 : case PROPERTY_ID_DETAILFIELDS:
282 0 : aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::StringListField , sal_False);
283 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_PROP_DLG_LINKFIELDS);
284 0 : aOut.HasPrimaryButton = sal_True;
285 0 : break;
286 : default:
287 0 : aOut = m_xFormComponentHandler->describePropertyLine(PropertyName, _xControlFactory);
288 : }
289 0 : if ( nId != -1 )
290 : {
291 0 : aOut.Category = ((m_pInfoService->getPropertyUIFlags(nId ) & PROP_FLAG_DATA_PROPERTY) != 0) ?
292 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data"))
293 : :
294 0 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("General"));
295 0 : aOut.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nId ) );
296 0 : aOut.DisplayName = m_pInfoService->getPropertyTranslation(nId);
297 : }
298 0 : return aOut;
299 : }
300 :
301 0 : uno::Any SAL_CALL DataProviderHandler::convertToPropertyValue(const ::rtl::OUString & _rPropertyValue, const uno::Any & _rControlValue) throw (uno::RuntimeException, beans::UnknownPropertyException)
302 : {
303 0 : ::osl::MutexGuard aGuard( m_aMutex );
304 0 : uno::Any aPropertyValue( _rControlValue );
305 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(_rPropertyValue);
306 0 : switch(nId)
307 : {
308 : case PROPERTY_ID_CHARTTYPE:
309 0 : break;
310 : case PROPERTY_ID_PREVIEW_COUNT:
311 : try
312 : {
313 0 : aPropertyValue = m_xTypeConverter->convertTo( _rControlValue, ::getCppuType((const sal_Int32*)0));
314 : }
315 0 : catch( const uno::Exception& )
316 : {
317 : OSL_FAIL( "DataProviderHandler::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
318 : }
319 0 : break;
320 : case PROPERTY_ID_MASTERFIELDS:
321 : case PROPERTY_ID_DETAILFIELDS:
322 0 : break;
323 : default:
324 0 : aPropertyValue = m_xFormComponentHandler->convertToPropertyValue(_rPropertyValue, _rControlValue);
325 : }
326 0 : return aPropertyValue;
327 : }
328 :
329 0 : uno::Any SAL_CALL DataProviderHandler::convertToControlValue(const ::rtl::OUString & _rPropertyName, const uno::Any & _rPropertyValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, beans::UnknownPropertyException)
330 : {
331 0 : uno::Any aControlValue( _rPropertyValue );
332 0 : if ( !aControlValue.hasValue() )
333 : // NULL is converted to NULL
334 : return aControlValue;
335 :
336 0 : ::osl::MutexGuard aGuard( m_aMutex );
337 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(_rPropertyName);
338 0 : switch(nId)
339 : {
340 : case PROPERTY_ID_CHARTTYPE:
341 0 : break;
342 : case PROPERTY_ID_MASTERFIELDS:
343 : case PROPERTY_ID_DETAILFIELDS:
344 : case PROPERTY_ID_PREVIEW_COUNT:
345 : try
346 : {
347 0 : aControlValue = m_xTypeConverter->convertTo( _rPropertyValue, ControlValueType);
348 : }
349 0 : catch( const uno::Exception& )
350 : {
351 : OSL_FAIL( "GeometryHandler::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
352 : }
353 0 : break;
354 : default:
355 0 : aControlValue = m_xFormComponentHandler->convertToControlValue(_rPropertyName, _rPropertyValue, ControlValueType);
356 : }
357 0 : return aControlValue;
358 : }
359 :
360 0 : void SAL_CALL DataProviderHandler::addPropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & Listener) throw (uno::RuntimeException, lang::NullPointerException)
361 : {
362 0 : m_xFormComponentHandler->addPropertyChangeListener(Listener);
363 0 : }
364 :
365 0 : void SAL_CALL DataProviderHandler::removePropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException)
366 : {
367 0 : m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
368 0 : }
369 :
370 0 : uno::Sequence< beans::Property > SAL_CALL DataProviderHandler::getSupportedProperties() throw (uno::RuntimeException)
371 : {
372 0 : ::std::vector< beans::Property > aNewProps;
373 0 : if( m_xChartModel.is() )
374 : {
375 0 : m_pInfoService->getExcludeProperties( aNewProps, m_xFormComponentHandler );
376 0 : beans::Property aValue;
377 : static const ::rtl::OUString s_pProperties[] =
378 : {
379 : PROPERTY_CHARTTYPE
380 : ,PROPERTY_MASTERFIELDS
381 : ,PROPERTY_DETAILFIELDS
382 : ,PROPERTY_PREVIEW_COUNT
383 0 : };
384 :
385 0 : for (size_t nPos = 0; nPos < sizeof(s_pProperties)/sizeof(s_pProperties[0]) ;++nPos )
386 : {
387 0 : aValue.Name = s_pProperties[nPos];
388 0 : aNewProps.push_back(aValue);
389 0 : }
390 : }
391 0 : return aNewProps.empty() ? uno::Sequence< beans::Property > () : uno::Sequence< beans::Property > (&(*aNewProps.begin()),aNewProps.size());
392 : }
393 :
394 0 : uno::Sequence< ::rtl::OUString > SAL_CALL DataProviderHandler::getSupersededProperties() throw (uno::RuntimeException)
395 : {
396 0 : uno::Sequence< ::rtl::OUString > aRet(1);
397 0 : aRet[0] = PROPERTY_TITLE; // have a look at OPropertyInfoService::getExcludeProperties
398 0 : return aRet;
399 : }
400 :
401 0 : uno::Sequence< ::rtl::OUString > SAL_CALL DataProviderHandler::getActuatingProperties() throw (uno::RuntimeException)
402 : {
403 0 : ::osl::MutexGuard aGuard( m_aMutex );
404 :
405 0 : uno::Sequence< ::rtl::OUString > aSeq(1);
406 0 : aSeq[0] = PROPERTY_TITLE;
407 0 : return ::comphelper::concatSequences(m_xFormComponentHandler->getActuatingProperties(),aSeq);
408 : }
409 :
410 0 : ::sal_Bool SAL_CALL DataProviderHandler::isComposable( const ::rtl::OUString& _rPropertyName ) throw (uno::RuntimeException, beans::UnknownPropertyException)
411 : {
412 0 : return m_pInfoService->isComposable( _rPropertyName, m_xFormComponentHandler );
413 : }
414 :
415 0 : inspection::InteractiveSelectionResult SAL_CALL DataProviderHandler::onInteractivePropertySelection(const ::rtl::OUString & PropertyName, ::sal_Bool Primary, uno::Any & out_Data, const uno::Reference< inspection::XObjectInspectorUI > & _rxInspectorUI) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::NullPointerException)
416 : {
417 0 : if ( !_rxInspectorUI.is() )
418 0 : throw lang::NullPointerException();
419 :
420 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
421 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
422 :
423 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
424 0 : switch(nId)
425 : {
426 : case PROPERTY_ID_CHARTTYPE:
427 0 : if ( impl_dialogChartType_nothrow(aGuard) )
428 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
429 0 : break;
430 : case PROPERTY_ID_MASTERFIELDS:
431 : case PROPERTY_ID_DETAILFIELDS:
432 0 : if ( impl_dialogLinkedFields_nothrow( aGuard ) )
433 0 : eResult = inspection::InteractiveSelectionResult_Success;
434 0 : break;
435 : default:
436 0 : eResult = m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, out_Data, _rxInspectorUI);
437 : }
438 :
439 0 : return eResult;
440 : }
441 :
442 0 : void SAL_CALL DataProviderHandler::actuatingPropertyChanged(const ::rtl::OUString & ActuatingPropertyName, const uno::Any & NewValue, const uno::Any & OldValue, const uno::Reference< inspection::XObjectInspectorUI > & InspectorUI, ::sal_Bool FirstTimeInit) throw (uno::RuntimeException, lang::NullPointerException)
443 : {
444 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
445 :
446 0 : if ( ActuatingPropertyName == PROPERTY_COMMAND )
447 : {
448 0 : if ( NewValue != OldValue )
449 : {
450 0 : uno::Reference< report::XReportDefinition> xReport = m_xReportComponent->getSection()->getReportDefinition();
451 0 : bool bDoEnableMasterDetailFields = xReport.is() && !xReport->getCommand().isEmpty() && !m_xDataProvider->getCommand().isEmpty();
452 0 : InspectorUI->enablePropertyUIElements( PROPERTY_DETAILFIELDS, inspection::PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
453 0 : InspectorUI->enablePropertyUIElements( PROPERTY_MASTERFIELDS, inspection::PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
454 :
455 0 : sal_Bool bModified = xReport->isModified();
456 : // this fills the chart again
457 0 : ::comphelper::NamedValueCollection aArgs;
458 0 : aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) );
459 0 : aArgs.put( "HasCategories", uno::makeAny( sal_True ) );
460 0 : aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
461 0 : aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
462 0 : uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xChartModel,uno::UNO_QUERY_THROW);
463 0 : xReceiver->setArguments( aArgs.getPropertyValues() );
464 0 : if ( !bModified )
465 0 : xReport->setModified(sal_False);
466 : }
467 0 : m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
468 : }
469 0 : else if ( ActuatingPropertyName == PROPERTY_TITLE )
470 : {
471 0 : if ( NewValue != OldValue )
472 0 : impl_updateChartTitle_throw(NewValue);
473 : }
474 : else
475 : {
476 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(ActuatingPropertyName);
477 0 : switch(nId)
478 : {
479 :
480 : case PROPERTY_ID_MASTERFIELDS:
481 0 : break;
482 : case PROPERTY_ID_DETAILFIELDS:
483 0 : break;
484 : default:
485 0 : m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
486 : }
487 0 : }
488 0 : }
489 :
490 0 : ::sal_Bool SAL_CALL DataProviderHandler::suspend(::sal_Bool Suspend) throw (uno::RuntimeException)
491 : {
492 0 : return m_xFormComponentHandler->suspend(Suspend);
493 : }
494 0 : bool DataProviderHandler::impl_dialogLinkedFields_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
495 : {
496 0 : uno::Sequence<uno::Any> aSeq(6);
497 0 : beans::PropertyValue aParam;
498 0 : aParam.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow"));
499 0 : aParam.Value <<= m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow")));
500 0 : aSeq[0] <<= aParam;
501 0 : aParam.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Detail"));
502 0 : aParam.Value <<= m_xDataProvider;
503 0 : aSeq[1] <<= aParam;
504 0 : aParam.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Master"));
505 0 : aParam.Value <<= m_xReportComponent->getSection()->getReportDefinition();
506 0 : aSeq[2] <<= aParam;
507 :
508 0 : aParam.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Explanation"));
509 0 : aParam.Value <<= ::rtl::OUString(String(ModuleRes(RID_STR_EXPLANATION)));
510 0 : aSeq[3] <<= aParam;
511 0 : aParam.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DetailLabel"));
512 0 : aParam.Value <<= ::rtl::OUString(String(ModuleRes(RID_STR_DETAILLABEL)));
513 0 : aSeq[4] <<= aParam;
514 0 : aParam.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MasterLabel"));
515 0 : aParam.Value <<= ::rtl::OUString(String(ModuleRes(RID_STR_MASTERLABEL)));
516 0 : aSeq[5] <<= aParam;
517 :
518 : uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
519 0 : m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
520 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.form.ui.MasterDetailLinkDialog")),aSeq
521 0 : , m_xContext), uno::UNO_QUERY);
522 :
523 0 : _rClearBeforeDialog.clear();
524 0 : return ( xDialog->execute() != 0 );
525 : }
526 : // -----------------------------------------------------------------------------
527 0 : bool DataProviderHandler::impl_dialogChartType_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
528 : {
529 0 : uno::Sequence<uno::Any> aSeq(2);
530 0 : beans::PropertyValue aParam;
531 0 : aParam.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow"));
532 0 : aParam.Value <<= m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow")));
533 0 : aSeq[0] <<= aParam;
534 0 : aParam.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ChartModel"));
535 0 : aParam.Value <<= m_xChartModel;
536 0 : aSeq[1] <<= aParam;
537 :
538 : uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
539 0 : m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
540 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart2.ChartTypeDialog")),aSeq
541 0 : , m_xContext), uno::UNO_QUERY);
542 :
543 0 : _rClearBeforeDialog.clear();
544 0 : return ( xDialog->execute() != 0 );
545 : }
546 : //........................................................................
547 : } // namespace rptui
548 : //........................................................................
549 :
550 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|