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