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