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 "GeometryHandler.hxx"
29 : :
30 : : #include <comphelper/sequence.hxx>
31 : : #include <comphelper/types.hxx>
32 : : #include <comphelper/property.hxx>
33 : : #include <comphelper/mimeconfighelper.hxx>
34 : :
35 : : #include "uistrings.hrc"
36 : : #include "reportformula.hxx"
37 : :
38 : : #include <unotools/textsearch.hxx>
39 : : #include <unotools/configmgr.hxx>
40 : :
41 : : #include <toolkit/helper/vclunohelper.hxx>
42 : : #include <unotools/syslocale.hxx>
43 : : #include <tools/diagnose_ex.h>
44 : : #include <tools/StringListResource.hxx>
45 : : #include <com/sun/star/lang/XInitialization.hpp>
46 : : #include "com/sun/star/inspection/StringRepresentation.hpp"
47 : : #include <com/sun/star/inspection/PropertyLineElement.hpp>
48 : : #include <com/sun/star/inspection/PropertyControlType.hpp>
49 : : #include <com/sun/star/inspection/XStringListControl.hpp>
50 : : #include <com/sun/star/report/Function.hpp>
51 : : #include <com/sun/star/report/XReportDefinition.hpp>
52 : : #include <com/sun/star/report/XShape.hpp>
53 : : #include <com/sun/star/report/XSection.hpp>
54 : : #include <com/sun/star/report/XFormattedField.hpp>
55 : : #include <com/sun/star/report/XFixedLine.hpp>
56 : : #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
57 : : #include <com/sun/star/sdb/CommandType.hpp>
58 : : #include <com/sun/star/sdb/SQLContext.hpp>
59 : : #include <com/sun/star/sdbc/XConnection.hpp>
60 : : #include <com/sun/star/util/SearchOptions.hpp>
61 : : #include <com/sun/star/util/MeasureUnit.hpp>
62 : : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
63 : : #include <com/sun/star/container/XNameContainer.hpp>
64 : : #include <com/sun/star/inspection/XNumericControl.hpp>
65 : : #include <com/sun/star/style/ParagraphAdjust.hpp>
66 : :
67 : : #include <vcl/msgbox.hxx>
68 : : #include <vcl/waitobj.hxx>
69 : : #include <tools/fldunit.hxx>
70 : : #include <vcl/stdtext.hxx>
71 : :
72 : : #include "ModuleHelper.hxx"
73 : : #include "RptResId.hrc"
74 : : #include "RptDef.hxx"
75 : : #include "UITools.hxx"
76 : :
77 : : #include <connectivity/dbexception.hxx>
78 : : #include <connectivity/dbconversion.hxx>
79 : : #include <connectivity/dbtools.hxx>
80 : :
81 : : #include <boost/bind.hpp>
82 : : #include <tools/string.hxx>
83 : : #include "metadata.hxx"
84 : : #include <svl/itempool.hxx>
85 : : #include <svl/itemset.hxx>
86 : :
87 : : #define ITEMID_COLOR_TABLE SID_COLOR_TABLE
88 : : #define ITEMID_DASH_LIST SID_DASH_LIST
89 : : #define ITEMID_LINEEND_LIST SID_LINEEND_LIST
90 : : #include <svx/xdef.hxx>
91 : : #include <svx/xpool.hxx>
92 : : #include <svx/xtable.hxx>
93 : : #include <svx/xlnwtit.hxx>
94 : : #include <svx/xlntrit.hxx>
95 : : #include <svx/xlnclit.hxx>
96 : : #include <svx/xlnstit.hxx>
97 : : #include <svx/xlnedit.hxx>
98 : : #include <svx/xlnstwit.hxx>
99 : : #include <svx/xlnedwit.hxx>
100 : : #include <svx/xlnstcit.hxx>
101 : : #include <svx/xlnedcit.hxx>
102 : : #include <svx/xlndsit.hxx>
103 : : #include <svx/xlineit0.hxx>
104 : : #include <svx/svxids.hrc>
105 : :
106 : : #define ITEMID_COLOR_TABLE SID_COLOR_TABLE
107 : : #define ITEMID_DASH_LIST SID_DASH_LIST
108 : : #define ITEMID_LINEEND_LIST SID_LINEEND_LIST
109 : : #include <svx/drawitem.hxx>
110 : : #define ITEMID_BRUSH SID_ATTR_BRUSH
111 : : #include <editeng/brshitem.hxx>
112 : : #include <sfx2/docfilt.hxx>
113 : :
114 : : #include "dlgpage.hxx"
115 : : #include "helpids.hrc"
116 : : #include <toolkit/helper/convert.hxx>
117 : :
118 : : #include <o3tl/compat_functional.hxx>
119 : :
120 : : #define DATA_OR_FORMULA 0
121 : : #define FUNCTION 1
122 : : #define COUNTER 2
123 : : #define USER_DEF_FUNCTION 3
124 : : #define UNDEF_DATA 4
125 : :
126 : : //........................................................................
127 : : namespace rptui
128 : : {
129 : : //........................................................................
130 : : using namespace ::com::sun::star;
131 : :
132 : : namespace{
133 : : // comparing two property instances
134 : : struct PropertyCompare : public ::std::binary_function< beans::Property, ::rtl::OUString , bool >
135 : : {
136 : 0 : bool operator() (const beans::Property& x, const ::rtl::OUString& y) const
137 : : {
138 : 0 : return x.Name.equals(y);
139 : : }
140 : : bool operator() (const ::rtl::OUString& x,const beans::Property& y) const
141 : : {
142 : : return x.equals(y.Name);
143 : : }
144 : : };
145 : :
146 : : // -----------------------------------------------------------------------------
147 : 0 : ::rtl::OUString lcl_getQuotedFunctionName(const ::rtl::OUString& _sFunction)
148 : : {
149 : 0 : ::rtl::OUString sQuotedFunctionName(RTL_CONSTASCII_USTRINGPARAM("["));
150 : 0 : sQuotedFunctionName += _sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("]"));
151 : 0 : return sQuotedFunctionName;
152 : : }
153 : : // -----------------------------------------------------------------------------
154 : 0 : ::rtl::OUString lcl_getQuotedFunctionName(const uno::Reference< report::XFunction>& _xFunction)
155 : : {
156 : 0 : return lcl_getQuotedFunctionName(_xFunction->getName());
157 : : }
158 : : // -----------------------------------------------------------------------------
159 : 0 : void lcl_collectFunctionNames(const uno::Reference< report::XFunctions>& _xFunctions,TFunctions& _rFunctionNames)
160 : : {
161 : 0 : uno::Reference< report::XFunctionsSupplier> xParent(_xFunctions->getParent(),uno::UNO_QUERY_THROW);
162 : 0 : const sal_Int32 nCount = _xFunctions->getCount();
163 : 0 : for (sal_Int32 i = 0; i < nCount ; ++i)
164 : : {
165 : 0 : uno::Reference< report::XFunction > xFunction(_xFunctions->getByIndex(i),uno::UNO_QUERY_THROW);
166 : 0 : _rFunctionNames.insert(TFunctions::value_type(lcl_getQuotedFunctionName(xFunction),TFunctionPair(xFunction,xParent)));
167 : 0 : }
168 : 0 : }
169 : : // -----------------------------------------------------------------------------
170 : 0 : void lcl_collectFunctionNames(const uno::Reference< report::XSection>& _xSection,TFunctions& _rFunctionNames)
171 : : {
172 : 0 : const uno::Reference< report::XReportDefinition> xReportDefinition = _xSection->getReportDefinition();
173 : 0 : const uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
174 : 0 : sal_Int32 nPos = -1;
175 : 0 : uno::Reference< report::XGroup> xGroup = _xSection->getGroup();
176 : 0 : if ( xGroup.is() )
177 : 0 : nPos = getPositionInIndexAccess(xGroups.get(),xGroup);
178 : 0 : else if ( _xSection == xReportDefinition->getDetail() )
179 : 0 : nPos = xGroups->getCount()-1;
180 : :
181 : 0 : for (sal_Int32 i = 0 ; i <= nPos ; ++i)
182 : : {
183 : 0 : xGroup.set(xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
184 : 0 : lcl_collectFunctionNames(xGroup->getFunctions(),_rFunctionNames);
185 : : }
186 : 0 : lcl_collectFunctionNames(xReportDefinition->getFunctions(),_rFunctionNames);
187 : 0 : }
188 : : // -----------------------------------------------------------------------------
189 : 0 : void lcl_convertFormulaTo(const uno::Any& _aPropertyValue,uno::Any& _rControlValue)
190 : : {
191 : 0 : ::rtl::OUString sName;
192 : 0 : _aPropertyValue >>= sName;
193 : 0 : const sal_Int32 nLen = sName.getLength();
194 : 0 : if ( nLen )
195 : : {
196 : 0 : ReportFormula aFormula( sName );
197 : 0 : _rControlValue <<= aFormula.getUndecoratedContent();
198 : 0 : }
199 : 0 : }
200 : :
201 : : // return value rounded to the nearest multiple of base
202 : : // if equidistant of two multiples, round up (for positive numbers)
203 : : // T is assumed to be an integer type
204 : 0 : template <typename T, T base> T lcl_round(T value)
205 : : {
206 : : OSL_ENSURE(value >= 0, "lcl_round: positive numbers only please");
207 : 0 : const T threshold = (base % 2 == 0) ? (base/2) : (base/2 + 1);
208 : 0 : const T rest = value % base;
209 : 0 : if ( rest >= threshold )
210 : 0 : return value + (base - rest);
211 : : else
212 : 0 : return value - rest;
213 : : }
214 : :
215 : : } // anonymous namespace
216 : : // -----------------------------------------------------------------------------
217 : 0 : bool GeometryHandler::impl_isDataField(const ::rtl::OUString& _sName) const
218 : : {
219 : 0 : const ::rtl::OUString* pEnd = m_aFieldNames.getConstArray() + m_aFieldNames.getLength();
220 : 0 : bool bIsField = ( ::std::find( m_aFieldNames.getConstArray(), pEnd, _sName ) != pEnd );
221 : :
222 : 0 : if ( !bIsField )
223 : : {
224 : 0 : pEnd = m_aParamNames.getConstArray() + m_aParamNames.getLength();
225 : 0 : bIsField = ( ::std::find( m_aParamNames.getConstArray(), pEnd, _sName ) != pEnd );
226 : : }
227 : 0 : return bIsField;
228 : : }
229 : : // -----------------------------------------------------------------------------
230 : 0 : ::rtl::OUString GeometryHandler::impl_convertToFormula( const uno::Any& _rControlValue )
231 : : {
232 : 0 : ::rtl::OUString sName;
233 : 0 : _rControlValue >>= sName;
234 : :
235 : 0 : if ( sName.isEmpty() )
236 : 0 : return sName;
237 : :
238 : 0 : ReportFormula aParser( sName );
239 : 0 : if ( aParser.isValid() )
240 : 0 : return sName;
241 : :
242 : 0 : aParser = ReportFormula( impl_isDataField(sName) ? ReportFormula::Field : ReportFormula::Expression, sName );
243 : 0 : return aParser.getCompleteFormula();
244 : : }
245 : : DBG_NAME(rpt_GeometryHandler)
246 : 0 : GeometryHandler::GeometryHandler(uno::Reference< uno::XComponentContext > const & context) :
247 : : GeometryHandler_Base(m_aMutex)
248 : : ,m_aPropertyListeners( m_aMutex )
249 : : ,m_xContext(context)
250 : 0 : ,m_pInfoService(new OPropertyInfoService())
251 : : ,m_nDataFieldType(0)
252 : 0 : ,m_bIn(false)
253 : : {
254 : : DBG_CTOR(rpt_GeometryHandler,NULL);
255 : : try
256 : : {
257 : 0 : const uno::Reference< lang::XMultiComponentFactory > xFac = m_xContext->getServiceManager();
258 : 0 : m_xFormComponentHandler.set(xFac->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.inspection.FormComponentPropertyHandler")),m_xContext),uno::UNO_QUERY_THROW);
259 : 0 : m_xTypeConverter.set(xFac->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter" )),m_xContext),uno::UNO_QUERY_THROW);
260 : 0 : loadDefaultFunctions();
261 : : }
262 : 0 : catch(const uno::Exception&)
263 : : {
264 : : }
265 : 0 : }
266 : : // -----------------------------------------------------------------------------
267 : 0 : GeometryHandler::~GeometryHandler()
268 : : {
269 : : DBG_DTOR(rpt_GeometryHandler,NULL);
270 : 0 : }
271 : : //------------------------------------------------------------------------
272 : 0 : ::rtl::OUString SAL_CALL GeometryHandler::getImplementationName( ) throw(uno::RuntimeException)
273 : : {
274 : 0 : return getImplementationName_Static();
275 : : }
276 : :
277 : : //------------------------------------------------------------------------
278 : 0 : sal_Bool SAL_CALL GeometryHandler::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
279 : : {
280 : 0 : return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
281 : : }
282 : :
283 : : //------------------------------------------------------------------------
284 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL GeometryHandler::getSupportedServiceNames( ) throw(uno::RuntimeException)
285 : : {
286 : 0 : return getSupportedServiceNames_static();
287 : : }
288 : :
289 : : //------------------------------------------------------------------------
290 : 0 : ::rtl::OUString GeometryHandler::getImplementationName_Static( ) throw(uno::RuntimeException)
291 : : {
292 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.GeometryHandler"));
293 : : }
294 : :
295 : : //------------------------------------------------------------------------
296 : 0 : uno::Sequence< ::rtl::OUString > GeometryHandler::getSupportedServiceNames_static( ) throw(uno::RuntimeException)
297 : : {
298 : 0 : uno::Sequence< ::rtl::OUString > aSupported(1);
299 : 0 : aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.inspection.GeometryHandler"));
300 : 0 : return aSupported;
301 : : }
302 : :
303 : : //------------------------------------------------------------------------
304 : 0 : uno::Reference< uno::XInterface > SAL_CALL GeometryHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
305 : : {
306 : 0 : return *(new GeometryHandler( _rxContext ));
307 : : }
308 : : // overload WeakComponentImplHelperBase::disposing()
309 : : // This function is called upon disposing the component,
310 : : // if your component needs special work when it becomes
311 : : // disposed, do it here.
312 : 0 : void SAL_CALL GeometryHandler::disposing()
313 : : {
314 : : try
315 : : {
316 : 0 : ::comphelper::disposeComponent(m_xFormComponentHandler);
317 : 0 : ::comphelper::disposeComponent(m_xTypeConverter);
318 : 0 : if ( m_xReportComponent.is() && m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
319 : 0 : m_xReportComponent->removePropertyChangeListener(PROPERTY_DATAFIELD,static_cast< beans::XPropertyChangeListener* >( this ));
320 : :
321 : 0 : m_xReportComponent.clear();
322 : 0 : m_xRowSet.clear();
323 : 0 : m_aPropertyListeners.clear();
324 : : }
325 : 0 : catch(uno::Exception&)
326 : : {}
327 : 0 : }
328 : 0 : void SAL_CALL GeometryHandler::addEventListener(const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException)
329 : : {
330 : 0 : m_xFormComponentHandler->addEventListener(xListener);
331 : 0 : }
332 : :
333 : 0 : void SAL_CALL GeometryHandler::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw (uno::RuntimeException)
334 : : {
335 : 0 : m_xFormComponentHandler->removeEventListener(aListener);
336 : 0 : }
337 : :
338 : : // inspection::XPropertyHandler:
339 : :
340 : : /********************************************************************************/
341 : 0 : void SAL_CALL GeometryHandler::inspect( const uno::Reference< uno::XInterface > & _rxInspectee ) throw (uno::RuntimeException, lang::NullPointerException)
342 : : {
343 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
344 : 0 : m_sScope = m_sDefaultFunction = ::rtl::OUString();
345 : 0 : m_bNewFunction = false;
346 : 0 : m_nDataFieldType = 0;
347 : 0 : m_xFunction.clear();
348 : 0 : m_aFunctionNames.clear();
349 : : try
350 : : {
351 : 0 : if ( m_xReportComponent.is() && m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
352 : 0 : m_xReportComponent->removePropertyChangeListener(PROPERTY_DATAFIELD,static_cast< beans::XPropertyChangeListener* >( this ));
353 : :
354 : 0 : const uno::Reference< container::XNameContainer > xObjectAsContainer( _rxInspectee, uno::UNO_QUERY );
355 : 0 : m_xReportComponent.set( xObjectAsContainer->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReportComponent" ) ) ), uno::UNO_QUERY );
356 : :
357 : 0 : const ::rtl::OUString sRowSet(RTL_CONSTASCII_USTRINGPARAM("RowSet"));
358 : 0 : if ( xObjectAsContainer->hasByName( sRowSet ) )
359 : : {
360 : 0 : const uno::Any aRowSet( xObjectAsContainer->getByName(sRowSet) );
361 : 0 : aRowSet >>= m_xRowSet;
362 : : // forward the rowset to our delegator handler
363 : 0 : uno::Reference< beans::XPropertySet > xProp( m_xFormComponentHandler,uno::UNO_QUERY );
364 : 0 : xProp->setPropertyValue( sRowSet, aRowSet );
365 : :
366 : 0 : m_aParamNames = getParameterNames( m_xRowSet );
367 : 0 : impl_initFieldList_nothrow(m_aFieldNames);
368 : 0 : if ( m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
369 : 0 : m_xReportComponent->addPropertyChangeListener(PROPERTY_DATAFIELD,static_cast< beans::XPropertyChangeListener* >( this ));
370 : : }
371 : :
372 : 0 : const uno::Reference< report::XReportComponent> xReportComponent( m_xReportComponent, uno::UNO_QUERY);
373 : 0 : uno::Reference< report::XSection> xSection( m_xReportComponent, uno::UNO_QUERY );
374 : 0 : if ( !xSection.is() && xReportComponent.is() )
375 : 0 : xSection = xReportComponent->getSection();
376 : 0 : if ( xSection.is() )
377 : 0 : lcl_collectFunctionNames( xSection, m_aFunctionNames );
378 : : }
379 : 0 : catch(const uno::Exception &)
380 : : {
381 : 0 : throw lang::NullPointerException();
382 : : }
383 : 0 : m_xFormComponentHandler->inspect(m_xReportComponent);
384 : 0 : }
385 : :
386 : 0 : uno::Any SAL_CALL GeometryHandler::getPropertyValue(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
387 : : {
388 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
389 : 0 : uno::Any aPropertyValue;
390 : 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
391 : 0 : switch(nId)
392 : : {
393 : : case PROPERTY_ID_CONDITIONALPRINTEXPRESSION:
394 : : case PROPERTY_ID_INITIALFORMULA:
395 : : case PROPERTY_ID_FORMULA:
396 : : case PROPERTY_ID_DATAFIELD:
397 : 0 : aPropertyValue = m_xReportComponent->getPropertyValue( PropertyName );
398 : 0 : lcl_convertFormulaTo(aPropertyValue,aPropertyValue);
399 : 0 : if ( PROPERTY_ID_DATAFIELD == nId )
400 : : {
401 : 0 : ::rtl::OUString sDataField;
402 : 0 : aPropertyValue >>= sDataField;
403 : 0 : switch(m_nDataFieldType)
404 : : {
405 : : case DATA_OR_FORMULA:
406 : 0 : break;
407 : : case FUNCTION:
408 : 0 : if ( isDefaultFunction(sDataField,sDataField) )
409 : 0 : aPropertyValue <<= sDataField;
410 : 0 : else if ( sDataField.isEmpty() )
411 : 0 : aPropertyValue = uno::Any();
412 : 0 : break;
413 : : case COUNTER:
414 : : case USER_DEF_FUNCTION:
415 : 0 : aPropertyValue = uno::Any();
416 : 0 : break;
417 : 0 : }
418 : :
419 : : }
420 : 0 : break;
421 : : case PROPERTY_ID_TYPE:
422 : : {
423 : 0 : const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
424 : 0 : m_nDataFieldType = impl_getDataFieldType_throw();
425 : 0 : if ( UNDEF_DATA == m_nDataFieldType )
426 : 0 : m_nDataFieldType = nOldDataFieldType;
427 : 0 : aPropertyValue <<= m_nDataFieldType;
428 : : }
429 : 0 : break;
430 : : case PROPERTY_ID_FORMULALIST:
431 : : case PROPERTY_ID_SCOPE:
432 : : {
433 : 0 : uno::Any aDataField = m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD );
434 : 0 : lcl_convertFormulaTo(aDataField,aDataField);
435 : 0 : ::rtl::OUString sDataField;
436 : 0 : aDataField >>= sDataField;
437 : 0 : switch(m_nDataFieldType)
438 : : {
439 : : case DATA_OR_FORMULA:
440 : 0 : break;
441 : : case FUNCTION:
442 : 0 : if ( isDefaultFunction(sDataField,sDataField,uno::Reference< report::XFunctionsSupplier>(),true) )
443 : 0 : aPropertyValue <<= (PROPERTY_ID_FORMULALIST == nId ? m_sDefaultFunction : m_sScope);
444 : 0 : break;
445 : : case USER_DEF_FUNCTION:
446 : 0 : if ( !sDataField.isEmpty() && PROPERTY_ID_FORMULALIST == nId )
447 : 0 : aPropertyValue = aDataField;
448 : 0 : break;
449 : : case COUNTER:
450 : 0 : if ( PROPERTY_ID_SCOPE == nId && impl_isCounterFunction_throw(sDataField,m_sScope) )
451 : 0 : aPropertyValue <<= m_sScope;
452 : 0 : break;
453 : 0 : }
454 : :
455 : : }
456 : 0 : break;
457 : : case PROPERTY_ID_BACKCOLOR:
458 : : case PROPERTY_ID_CONTROLBACKGROUND:
459 : : {
460 : 0 : aPropertyValue = m_xReportComponent->getPropertyValue( PropertyName );
461 : 0 : sal_Int32 nColor = COL_TRANSPARENT;
462 : 0 : if ( (aPropertyValue >>= nColor) && static_cast<sal_Int32>(COL_TRANSPARENT) == nColor )
463 : 0 : aPropertyValue.clear();
464 : : }
465 : 0 : break;
466 : : case PROPERTY_ID_MIMETYPE:
467 : : {
468 : 0 : ::rtl::OUString sValue;
469 : 0 : m_xReportComponent->getPropertyValue( PropertyName ) >>= sValue;
470 : 0 : aPropertyValue <<= impl_ConvertMimeTypeToUI_nothrow(sValue);
471 : : }
472 : 0 : break;
473 : : default:
474 : 0 : aPropertyValue = m_xReportComponent->getPropertyValue( PropertyName );
475 : 0 : break;
476 : : }
477 : 0 : return aPropertyValue;
478 : : }
479 : :
480 : 0 : void SAL_CALL GeometryHandler::setPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & Value) throw (uno::RuntimeException, beans::UnknownPropertyException)
481 : : {
482 : 0 : ::osl::ResettableMutexGuard aGuard( m_aMutex );
483 : 0 : uno::Any aNewValue = Value;
484 : 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
485 : 0 : bool bHandled = false;
486 : 0 : switch(nId)
487 : : {
488 : : case PROPERTY_ID_INITIALFORMULA:
489 : : case PROPERTY_ID_FORMULA:
490 : 0 : break;
491 : : case PROPERTY_ID_DATAFIELD:
492 : : {
493 : 0 : OBlocker aBlocker(m_bIn);
494 : 0 : m_xReportComponent->setPropertyValue(PropertyName, aNewValue);
495 : 0 : bHandled = true;
496 : 0 : const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
497 : 0 : const ::rtl::OUString sOldScope = m_sScope;
498 : :
499 : 0 : uno::Any aPropertyValue;
500 : 0 : lcl_convertFormulaTo(Value,aPropertyValue);
501 : 0 : ::rtl::OUString sDataField;
502 : 0 : aPropertyValue >>= sDataField;
503 : :
504 : 0 : m_sScope = m_sDefaultFunction = ::rtl::OUString();
505 : 0 : m_xFunction.clear();
506 : 0 : const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
507 : 0 : if ( !sDataField.isEmpty() )
508 : : {
509 : 0 : if ( isDefaultFunction(sDataField,sDataField,uno::Reference< report::XFunctionsSupplier>(),true) )
510 : 0 : m_nDataFieldType = FUNCTION;
511 : 0 : else if ( m_aFunctionNames.find(sDataField) != m_aFunctionNames.end() )
512 : 0 : m_nDataFieldType = USER_DEF_FUNCTION;
513 : : }
514 : :
515 : 0 : resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType);
516 : : }
517 : 0 : break;
518 : : case PROPERTY_ID_TYPE:
519 : : {
520 : 0 : bHandled = true;
521 : 0 : Value >>= m_nDataFieldType;
522 : :
523 : 0 : const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
524 : 0 : const ::rtl::OUString sOldScope = m_sScope;
525 : 0 : m_sDefaultFunction = m_sScope = ::rtl::OUString();
526 : :
527 : 0 : if ( m_nDataFieldType == COUNTER )
528 : : {
529 : 0 : impl_setCounterFunction_throw();
530 : : }
531 : : else
532 : : {
533 : 0 : if ( m_bNewFunction )
534 : 0 : removeFunction();
535 : 0 : m_xFunction.clear();
536 : 0 : OBlocker aBlocker(m_bIn);
537 : 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(::rtl::OUString()));
538 : : }
539 : 0 : resetOwnProperties(aGuard,sOldFunctionName,sOldScope,m_nDataFieldType);
540 : : }
541 : 0 : break;
542 : : case PROPERTY_ID_FORMULALIST:
543 : : {
544 : 0 : bHandled = true;
545 : 0 : ::rtl::OUString sFunction;
546 : 0 : if ( !(Value >>= sFunction) || sFunction.isEmpty() )
547 : : {
548 : 0 : if ( m_nDataFieldType == FUNCTION )
549 : : {
550 : 0 : m_sDefaultFunction = ::rtl::OUString();
551 : 0 : if ( m_bNewFunction )
552 : 0 : removeFunction();
553 : 0 : m_xFunction.clear();
554 : :
555 : 0 : beans::PropertyChangeEvent aEvent;
556 : 0 : aEvent.PropertyName = PROPERTY_SCOPE;
557 : 0 : aEvent.OldValue <<= m_sScope;
558 : 0 : m_sScope = ::rtl::OUString();
559 : 0 : aEvent.NewValue <<= m_sScope;
560 : 0 : aGuard.clear();
561 : 0 : m_aPropertyListeners.notify( aEvent, &beans::XPropertyChangeListener::propertyChange );
562 : : }
563 : 0 : else if ( m_nDataFieldType == USER_DEF_FUNCTION )
564 : : {
565 : 0 : OBlocker aBlocker(m_bIn);
566 : 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(::rtl::OUString()));
567 : : }
568 : : }
569 : 0 : else if ( m_nDataFieldType == USER_DEF_FUNCTION )
570 : : {
571 : 0 : ::rtl::OUString sDataField;
572 : 0 : OBlocker aBlocker(m_bIn);
573 : 0 : const sal_uInt32 nNewDataType = impl_getDataFieldType_throw(sFunction);
574 : 0 : if ( nNewDataType != UNDEF_DATA && nNewDataType != m_nDataFieldType )
575 : : {
576 : 0 : const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
577 : 0 : const ::rtl::OUString sOldScope = m_sScope;
578 : 0 : m_sScope = m_sDefaultFunction = ::rtl::OUString();
579 : 0 : m_xFunction.clear();
580 : 0 : if ( nNewDataType == COUNTER )
581 : 0 : impl_isCounterFunction_throw(sFunction,m_sScope);
582 : : else
583 : : {
584 : 0 : ::rtl::OUString sNamePostFix;
585 : 0 : const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostFix);
586 : 0 : isDefaultFunction(sFunction,sDataField,xFunctionsSupplier,true);
587 : : }
588 : 0 : const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
589 : 0 : m_nDataFieldType = nNewDataType;
590 : 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula( uno::makeAny(sFunction))));
591 : 0 : resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType);
592 : : }
593 : : else
594 : 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula( uno::makeAny(sFunction))));
595 : : }
596 : 0 : else if ( m_nDataFieldType == FUNCTION )
597 : : {
598 : 0 : uno::Any aPropertyValue = m_xReportComponent->getPropertyValue(PROPERTY_DATAFIELD);
599 : 0 : lcl_convertFormulaTo(aPropertyValue,aPropertyValue);
600 : 0 : ::rtl::OUString sDataField;
601 : 0 : aPropertyValue >>= sDataField;
602 : 0 : if ( m_nDataFieldType == FUNCTION && (!isDefaultFunction(sDataField,sDataField) || m_sDefaultFunction != sFunction) )
603 : : {
604 : 0 : if ( m_bNewFunction )
605 : 0 : removeFunction();
606 : : // function currently does not exist
607 : 0 : createDefaultFunction(aGuard,sFunction,sDataField);
608 : 0 : m_sDefaultFunction = sFunction;
609 : 0 : }
610 : 0 : }
611 : : }
612 : :
613 : 0 : break;
614 : : case PROPERTY_ID_SCOPE:
615 : 0 : if ( !(Value >>= m_sScope) )
616 : 0 : m_sScope = ::rtl::OUString();
617 : : else
618 : : {
619 : 0 : if ( m_bNewFunction )
620 : 0 : removeFunction();
621 : 0 : if ( m_nDataFieldType == COUNTER )
622 : 0 : impl_setCounterFunction_throw();
623 : : else
624 : : {
625 : : OSL_ENSURE(m_xFunction.is(),"Where is my function gone!");
626 : :
627 : 0 : ::rtl::OUString sNamePostFix;
628 : 0 : const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostFix);
629 : :
630 : 0 : ::rtl::OUString sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction));
631 : 0 : if ( isDefaultFunction(sQuotedFunctionName,sQuotedFunctionName,xFunctionsSupplier,true) )
632 : 0 : m_bNewFunction = false;
633 : : else
634 : : {
635 : 0 : ::rtl::OUString sDefaultFunctionName;
636 : 0 : ::rtl::OUString sDataField;
637 : 0 : OSL_VERIFY( impl_isDefaultFunction_nothrow(m_xFunction,sDataField,sDefaultFunctionName) );
638 : 0 : m_sDefaultFunction = sDefaultFunctionName;
639 : 0 : createDefaultFunction(aGuard,m_sDefaultFunction,sDataField);
640 : 0 : }
641 : : }
642 : : }
643 : 0 : bHandled = true;
644 : 0 : break;
645 : : case PROPERTY_ID_POSITIONX:
646 : : case PROPERTY_ID_POSITIONY:
647 : : case PROPERTY_ID_HEIGHT:
648 : : case PROPERTY_ID_WIDTH:
649 : : {
650 : 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
651 : 0 : if ( xSourceReportComponent.is() ) // check only report components
652 : : {
653 : 0 : sal_Int32 nNewValue = 0;
654 : 0 : Value >>= nNewValue;
655 : : OSL_ENSURE(nNewValue >= 0, "A position/dimension should not be negative!");
656 : 0 : nNewValue = lcl_round<sal_Int32, 10>(nNewValue);
657 : 0 : awt::Point aAwtPoint = xSourceReportComponent->getPosition();
658 : 0 : awt::Size aAwtSize = xSourceReportComponent->getSize();
659 : 0 : if ( nId == PROPERTY_ID_POSITIONX )
660 : 0 : aAwtPoint.X = nNewValue;
661 : 0 : else if ( nId == PROPERTY_ID_POSITIONY )
662 : 0 : aAwtPoint.Y = nNewValue;
663 : 0 : else if ( nId == PROPERTY_ID_HEIGHT )
664 : 0 : aAwtSize.Height = nNewValue;
665 : 0 : else if ( nId == PROPERTY_ID_WIDTH )
666 : 0 : aAwtSize.Width = nNewValue;
667 : :
668 : 0 : checkPosAndSize(aAwtPoint,aAwtSize);
669 : 0 : }
670 : : }
671 : 0 : break;
672 : : case PROPERTY_ID_FONT:
673 : : {
674 : 0 : const uno::Reference< report::XReportControlFormat > xReportControlFormat( m_xReportComponent,uno::UNO_QUERY_THROW );
675 : 0 : uno::Sequence< beans::NamedValue > aFontSettings;
676 : 0 : OSL_VERIFY( Value >>= aFontSettings );
677 : 0 : applyCharacterSettings( xReportControlFormat, aFontSettings );
678 : 0 : bHandled = true;
679 : : }
680 : 0 : break;
681 : : case PROPERTY_ID_MIMETYPE:
682 : : {
683 : 0 : ::rtl::OUString sValue;
684 : 0 : Value >>= sValue;
685 : 0 : aNewValue <<= impl_ConvertUIToMimeType_nothrow(sValue);
686 : : }
687 : : default:
688 : 0 : break;
689 : : }
690 : :
691 : 0 : if ( !bHandled )
692 : 0 : m_xReportComponent->setPropertyValue(PropertyName, aNewValue);
693 : 0 : }
694 : :
695 : : // -----------------------------------------------------------------------------
696 : 0 : beans::PropertyState SAL_CALL GeometryHandler::getPropertyState(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
697 : : {
698 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
699 : 0 : return m_xFormComponentHandler->getPropertyState(PropertyName);
700 : : }
701 : : // -----------------------------------------------------------------------------
702 : 0 : void GeometryHandler::implCreateListLikeControl(
703 : : const uno::Reference< inspection::XPropertyControlFactory >& _rxControlFactory
704 : : ,inspection::LineDescriptor & out_Descriptor
705 : : ,sal_uInt16 _nResId
706 : : ,sal_Bool _bReadOnlyControl
707 : : ,sal_Bool _bTrueIfListBoxFalseIfComboBox
708 : : )
709 : : {
710 : 0 : ::std::vector< ::rtl::OUString > aList;
711 : 0 : tools::StringListResource aRes(ModuleRes(_nResId),aList);
712 : :
713 : 0 : implCreateListLikeControl(_rxControlFactory,out_Descriptor,aList,_bReadOnlyControl,_bTrueIfListBoxFalseIfComboBox);
714 : 0 : }
715 : : // -----------------------------------------------------------------------------
716 : 0 : void GeometryHandler::implCreateListLikeControl(
717 : : const uno::Reference< inspection::XPropertyControlFactory >& _rxControlFactory
718 : : ,inspection::LineDescriptor & out_Descriptor
719 : : ,const ::std::vector< ::rtl::OUString>& _aEntries
720 : : ,sal_Bool _bReadOnlyControl
721 : : ,sal_Bool _bTrueIfListBoxFalseIfComboBox
722 : : )
723 : : {
724 : : const uno::Reference< inspection::XStringListControl > xListControl(
725 : 0 : _rxControlFactory->createPropertyControl(
726 : : _bTrueIfListBoxFalseIfComboBox ? inspection::PropertyControlType::ListBox : inspection::PropertyControlType::ComboBox, _bReadOnlyControl
727 : 0 : ),
728 : : uno::UNO_QUERY_THROW
729 : 0 : );
730 : :
731 : 0 : out_Descriptor.Control = xListControl.get();
732 : 0 : ::std::for_each( _aEntries.begin(), _aEntries.end(),::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl,_1 ));
733 : 0 : }
734 : : // -----------------------------------------------------------------------------
735 : :
736 : 0 : inspection::LineDescriptor SAL_CALL GeometryHandler::describePropertyLine(const ::rtl::OUString & PropertyName, const uno::Reference< inspection::XPropertyControlFactory > & _xControlFactory) throw (beans::UnknownPropertyException, lang::NullPointerException,uno::RuntimeException)
737 : : {
738 : 0 : inspection::LineDescriptor aOut;
739 : 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
740 : 0 : switch(nId)
741 : : {
742 : : case PROPERTY_ID_FORCENEWPAGE:
743 : : case PROPERTY_ID_NEWROWORCOL:
744 : 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_FORCENEWPAGE_CONST,sal_False,sal_True);
745 : 0 : break;
746 : : case PROPERTY_ID_GROUPKEEPTOGETHER:
747 : 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_GROUPKEEPTOGETHER_CONST,sal_False,sal_True);
748 : 0 : break;
749 : : case PROPERTY_ID_PAGEHEADEROPTION:
750 : : case PROPERTY_ID_PAGEFOOTEROPTION:
751 : 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_REPORTPRINTOPTION_CONST,sal_False,sal_True);
752 : 0 : break;
753 : : case PROPERTY_ID_FORMULALIST:
754 : : {
755 : 0 : ::std::vector< ::rtl::OUString > aList;
756 : 0 : impl_fillFormulaList_nothrow(aList);
757 : 0 : implCreateListLikeControl(_xControlFactory,aOut,aList,sal_False,sal_True);
758 : : }
759 : 0 : break;
760 : : case PROPERTY_ID_SCOPE:
761 : : {
762 : 0 : ::std::vector< ::rtl::OUString > aList;
763 : 0 : impl_fillScopeList_nothrow(aList);
764 : 0 : implCreateListLikeControl(_xControlFactory,aOut,aList,sal_False,sal_True);
765 : : }
766 : 0 : break;
767 : : case PROPERTY_ID_MIMETYPE:
768 : : {
769 : 0 : ::std::vector< ::rtl::OUString > aList;
770 : 0 : impl_fillMimeTypes_nothrow(aList);
771 : 0 : implCreateListLikeControl(_xControlFactory,aOut,aList,sal_False,sal_True);
772 : : }
773 : 0 : break;
774 : : case PROPERTY_ID_TYPE:
775 : 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_TYPE_CONST,sal_False,sal_True);
776 : 0 : break;
777 : : case PROPERTY_ID_VISIBLE:
778 : : case PROPERTY_ID_CANGROW:
779 : : case PROPERTY_ID_CANSHRINK:
780 : : case PROPERTY_ID_REPEATSECTION:
781 : : case PROPERTY_ID_PRINTREPEATEDVALUES:
782 : : case PROPERTY_ID_STARTNEWCOLUMN:
783 : : case PROPERTY_ID_RESETPAGENUMBER:
784 : : case PROPERTY_ID_PRINTWHENGROUPCHANGE:
785 : : case PROPERTY_ID_KEEPTOGETHER:
786 : : case PROPERTY_ID_DEEPTRAVERSING:
787 : : case PROPERTY_ID_PREEVALUATED:
788 : : case PROPERTY_ID_PRESERVEIRI:
789 : : case PROPERTY_ID_BACKTRANSPARENT:
790 : : case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT:
791 : : {
792 : 0 : sal_uInt16 nResId = RID_STR_BOOL;
793 : 0 : if ( PROPERTY_ID_KEEPTOGETHER == nId && uno::Reference< report::XGroup>(m_xReportComponent,uno::UNO_QUERY).is())
794 : 0 : nResId = RID_STR_KEEPTOGETHER_CONST;
795 : 0 : implCreateListLikeControl(_xControlFactory,aOut,nResId,sal_False,sal_True);
796 : : }
797 : 0 : break;
798 : : case PROPERTY_ID_INITIALFORMULA:
799 : : case PROPERTY_ID_FORMULA:
800 : 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_PROP_FORMULA);
801 : 0 : aOut.HasPrimaryButton = sal_True;
802 : 0 : aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::MultiLineTextField , sal_False);
803 : 0 : break;
804 : : case PROPERTY_ID_CONDITIONALPRINTEXPRESSION:
805 : 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_PROP_FORMULA);
806 : 0 : aOut.HasPrimaryButton = sal_True;
807 : 0 : aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::MultiLineTextField , sal_False);
808 : 0 : break;
809 : : case PROPERTY_ID_DATAFIELD:
810 : : {
811 : : uno::Reference< inspection::XStringListControl > xListControl(
812 : 0 : _xControlFactory->createPropertyControl(
813 : : m_nDataFieldType == DATA_OR_FORMULA ? inspection::PropertyControlType::ComboBox : inspection::PropertyControlType::ListBox, sal_False
814 : 0 : ),
815 : : uno::UNO_QUERY_THROW
816 : 0 : );
817 : :
818 : 0 : if ( m_nDataFieldType == DATA_OR_FORMULA )
819 : : {
820 : 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_PROP_FORMULA);
821 : 0 : aOut.HasPrimaryButton = sal_True;
822 : : }
823 : :
824 : 0 : aOut.Control = xListControl.get();
825 : 0 : if ( m_nDataFieldType == USER_DEF_FUNCTION )
826 : : {
827 : : // add function names
828 : : ::std::for_each( m_aFunctionNames.begin(), m_aFunctionNames.end(),
829 : : ::o3tl::compose1(
830 : : ::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl,_1 ),
831 : 0 : ::o3tl::select1st<TFunctions::value_type>()));
832 : : }
833 : : else
834 : : {
835 : 0 : ::std::for_each( m_aFieldNames.getConstArray(), m_aFieldNames.getConstArray() + m_aFieldNames.getLength(),
836 : 0 : ::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl, _1 ) );
837 : 0 : ::std::for_each( m_aParamNames.getConstArray(), m_aParamNames.getConstArray() + m_aParamNames.getLength(),
838 : 0 : ::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl, _1 ) );
839 : 0 : }
840 : : }
841 : 0 : break;
842 : : case PROPERTY_ID_BACKCOLOR:
843 : : case PROPERTY_ID_CONTROLBACKGROUND:
844 : 0 : aOut.Control = _xControlFactory->createPropertyControl( inspection::PropertyControlType::ColorListBox, sal_False );
845 : 0 : break;
846 : : case PROPERTY_ID_FONT:
847 : 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_RPT_PROP_DLG_FONT_TYPE);
848 : 0 : aOut.Control = _xControlFactory->createPropertyControl( inspection::PropertyControlType::TextField, sal_True );
849 : 0 : aOut.HasPrimaryButton = sal_True;
850 : 0 : break;
851 : : case PROPERTY_ID_AREA:
852 : 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_RPT_PROP_DLG_AREA);
853 : 0 : aOut.Control = _xControlFactory->createPropertyControl( inspection::PropertyControlType::TextField, sal_True );
854 : 0 : aOut.HasPrimaryButton = sal_True;
855 : 0 : break;
856 : : case PROPERTY_ID_VERTICALALIGN:
857 : 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_VERTICAL_ALIGN_CONST,sal_False,sal_True);
858 : 0 : break;
859 : : case PROPERTY_ID_PARAADJUST:
860 : 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_PARAADJUST_CONST,sal_False,sal_True);
861 : 0 : break;
862 : : default:
863 : : {
864 : 0 : aOut = m_xFormComponentHandler->describePropertyLine(PropertyName, _xControlFactory);
865 : : }
866 : : }
867 : :
868 : 0 : if ( nId != -1 )
869 : : {
870 : 0 : aOut.Category = ((m_pInfoService->getPropertyUIFlags(nId ) & PROP_FLAG_DATA_PROPERTY) != 0) ?
871 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data"))
872 : : :
873 : 0 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("General"));
874 : 0 : aOut.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nId ) );
875 : 0 : aOut.DisplayName = m_pInfoService->getPropertyTranslation(nId);
876 : : }
877 : :
878 : 0 : if ( ( nId == PROPERTY_ID_POSITIONX )
879 : : || ( nId == PROPERTY_ID_POSITIONY )
880 : : || ( nId == PROPERTY_ID_WIDTH )
881 : : || ( nId == PROPERTY_ID_HEIGHT )
882 : : )
883 : : {
884 : 0 : const MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
885 : 0 : const sal_Int16 nDisplayUnit = VCLUnoHelper::ConvertToMeasurementUnit( MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH, 1 );
886 : 0 : uno::Reference< inspection::XNumericControl > xNumericControl(aOut.Control,uno::UNO_QUERY);
887 : 0 : xNumericControl->setDecimalDigits( 2 );
888 : 0 : xNumericControl->setValueUnit( util::MeasureUnit::MM_100TH );
889 : 0 : uno::Reference< drawing::XShapeDescriptor> xShapeDesc(m_xReportComponent,uno::UNO_QUERY);
890 : 0 : bool bSetMin = !xShapeDesc.is() || xShapeDesc->getShapeType() != ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CustomShape"));
891 : 0 : if ( bSetMin )
892 : 0 : xNumericControl->setMinValue(beans::Optional<double>(sal_True,0.0));
893 : 0 : if ( nDisplayUnit != -1 )
894 : 0 : xNumericControl->setDisplayUnit( nDisplayUnit );
895 : 0 : uno::Reference< report::XReportComponent> xComp(m_xReportComponent,uno::UNO_QUERY);
896 : 0 : if ( xComp.is() && xComp->getSection().is() )
897 : : {
898 : 0 : uno::Reference< report::XReportDefinition > xReport = xComp->getSection()->getReportDefinition();
899 : : OSL_ENSURE(xReport.is(),"Why is the report definition NULL!");
900 : 0 : if ( xReport.is() )
901 : : {
902 : 0 : const awt::Size aSize = getStyleProperty<awt::Size>(xReport,PROPERTY_PAPERSIZE);
903 : 0 : const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReport,PROPERTY_LEFTMARGIN);
904 : 0 : const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReport,PROPERTY_RIGHTMARGIN);
905 : 0 : switch(nId)
906 : : {
907 : : case PROPERTY_ID_POSITIONX:
908 : : case PROPERTY_ID_POSITIONY:
909 : : case PROPERTY_ID_WIDTH:
910 : 0 : if ( bSetMin )
911 : 0 : xNumericControl->setMinValue(beans::Optional<double>(sal_True,0.0));
912 : 0 : xNumericControl->setMaxValue(beans::Optional<double>(sal_True,double(aSize.Width - nLeftMargin - nRightMargin)));
913 : 0 : if ( PROPERTY_ID_WIDTH == nId )
914 : : {
915 : 0 : uno::Reference<report::XFixedLine> xFixedLine(m_xReportComponent,uno::UNO_QUERY);
916 : 0 : if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical
917 : 0 : xNumericControl->setMinValue(beans::Optional<double>(sal_True,0.08 ));
918 : : }
919 : 0 : break;
920 : : default:
921 : 0 : break;
922 : : }
923 : 0 : }
924 : : }
925 : 0 : else if ( PROPERTY_ID_HEIGHT == nId )
926 : : {
927 : 0 : const uno::Reference< report::XSection> xSection(m_xReportComponent,uno::UNO_QUERY);
928 : 0 : if ( xSection.is() )
929 : : {
930 : 0 : sal_Int32 nHeight = 0;
931 : 0 : const sal_Int32 nCount = xSection->getCount();
932 : 0 : for (sal_Int32 i = 0; i < nCount; ++i)
933 : : {
934 : 0 : uno::Reference<drawing::XShape> xShape(xSection->getByIndex(i),uno::UNO_QUERY);
935 : 0 : nHeight = ::std::max<sal_Int32>(nHeight,xShape->getPosition().Y + xShape->getSize().Height);
936 : 0 : }
937 : 0 : xNumericControl->setMinValue(beans::Optional<double>(sal_True,nHeight ));
938 : 0 : }
939 : 0 : }
940 : : }
941 : 0 : return aOut;
942 : : }
943 : : // -----------------------------------------------------------------------------
944 : 0 : beans::Property GeometryHandler::getProperty(const ::rtl::OUString & PropertyName)
945 : : {
946 : 0 : uno::Sequence< beans::Property > aProps = getSupportedProperties();
947 : 0 : const beans::Property* pIter = aProps.getConstArray();
948 : 0 : const beans::Property* pEnd = pIter + aProps.getLength();
949 : 0 : const beans::Property* pFind = ::std::find_if(pIter,pEnd,::std::bind2nd(PropertyCompare(),boost::cref(PropertyName)));
950 : 0 : if ( pFind == pEnd )
951 : 0 : return beans::Property();
952 : 0 : return *pFind;
953 : : }
954 : 0 : uno::Any GeometryHandler::getConstantValue(sal_Bool _bToControlValue,sal_uInt16 _nResId,const uno::Any& _aValue,const ::rtl::OUString& _sConstantName,const ::rtl::OUString & PropertyName )
955 : : {
956 : 0 : ::std::vector< ::rtl::OUString > aList;
957 : 0 : tools::StringListResource aRes(ModuleRes(_nResId),aList);
958 : 0 : uno::Sequence< ::rtl::OUString > aSeq(aList.size());
959 : 0 : ::std::copy( aList.begin(), aList.end(), aSeq.getArray() );
960 : :
961 : 0 : uno::Reference< inspection::XStringRepresentation > xConversionHelper = inspection::StringRepresentation::createConstant( m_xContext,m_xTypeConverter,_sConstantName,aSeq);
962 : 0 : if ( _bToControlValue )
963 : : {
964 : 0 : return uno::makeAny( xConversionHelper->convertToControlValue( _aValue ) );
965 : : }
966 : : else
967 : : {
968 : 0 : ::rtl::OUString sControlValue;
969 : 0 : _aValue >>= sControlValue;
970 : 0 : const beans::Property aProp = getProperty(PropertyName);
971 : 0 : return xConversionHelper->convertToPropertyValue( sControlValue, aProp.Type );
972 : 0 : }
973 : : }
974 : :
975 : 0 : uno::Any SAL_CALL GeometryHandler::convertToPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & _rControlValue) throw (uno::RuntimeException, beans::UnknownPropertyException)
976 : : {
977 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
978 : 0 : uno::Any aPropertyValue( _rControlValue );
979 : 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
980 : 0 : switch(nId)
981 : : {
982 : : case PROPERTY_ID_FORCENEWPAGE:
983 : : case PROPERTY_ID_NEWROWORCOL:
984 : 0 : aPropertyValue = getConstantValue(sal_False,RID_STR_FORCENEWPAGE_CONST,_rControlValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ForceNewPage")),PropertyName);
985 : 0 : break;
986 : : case PROPERTY_ID_GROUPKEEPTOGETHER:
987 : 0 : aPropertyValue = getConstantValue(sal_False,RID_STR_GROUPKEEPTOGETHER_CONST,_rControlValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.GroupKeepTogether")),PropertyName);
988 : 0 : break;
989 : : case PROPERTY_ID_PAGEHEADEROPTION:
990 : : case PROPERTY_ID_PAGEFOOTEROPTION:
991 : 0 : aPropertyValue = getConstantValue(sal_False,RID_STR_REPORTPRINTOPTION_CONST,_rControlValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ReportPrintOption")),PropertyName);
992 : 0 : break;
993 : : case PROPERTY_ID_BACKCOLOR:
994 : : case PROPERTY_ID_CONTROLBACKGROUND:
995 : 0 : if ( !_rControlValue.hasValue() )
996 : : {
997 : 0 : aPropertyValue <<= static_cast<sal_Int32>(COL_TRANSPARENT);
998 : 0 : break;
999 : : }
1000 : : // run through
1001 : :
1002 : : case PROPERTY_ID_KEEPTOGETHER:
1003 : 0 : if ( uno::Reference< report::XGroup>(m_xReportComponent,uno::UNO_QUERY).is())
1004 : : {
1005 : 0 : aPropertyValue = getConstantValue(sal_False,RID_STR_KEEPTOGETHER_CONST,_rControlValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.KeepTogether")),PropertyName);
1006 : 0 : break;
1007 : : }
1008 : : // run through
1009 : :
1010 : : case PROPERTY_ID_VISIBLE:
1011 : : case PROPERTY_ID_CANGROW:
1012 : : case PROPERTY_ID_CANSHRINK:
1013 : : case PROPERTY_ID_REPEATSECTION:
1014 : : case PROPERTY_ID_PRINTREPEATEDVALUES:
1015 : : case PROPERTY_ID_STARTNEWCOLUMN:
1016 : : case PROPERTY_ID_RESETPAGENUMBER:
1017 : : case PROPERTY_ID_PRINTWHENGROUPCHANGE:
1018 : : case PROPERTY_ID_DEEPTRAVERSING:
1019 : : case PROPERTY_ID_PREEVALUATED:
1020 : : case PROPERTY_ID_PRESERVEIRI:
1021 : : case PROPERTY_ID_BACKTRANSPARENT:
1022 : : case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT:
1023 : : {
1024 : 0 : if ( aPropertyValue.hasValue() )
1025 : : {
1026 : 0 : const beans::Property aProp = getProperty(PropertyName);
1027 : 0 : if ( aPropertyValue.getValueType().equals( aProp.Type ) )
1028 : : // nothing to do, type is already as desired
1029 : 0 : return aPropertyValue;
1030 : :
1031 : 0 : if ( _rControlValue.getValueType().getTypeClass() == uno::TypeClass_STRING )
1032 : : {
1033 : 0 : ::rtl::OUString sControlValue;
1034 : 0 : _rControlValue >>= sControlValue;
1035 : :
1036 : 0 : const uno::Reference< inspection::XStringRepresentation > xConversionHelper = inspection::StringRepresentation::create( m_xContext,m_xTypeConverter );
1037 : 0 : aPropertyValue = xConversionHelper->convertToPropertyValue( sControlValue, aProp.Type );
1038 : : }
1039 : : else
1040 : : {
1041 : : try
1042 : : {
1043 : 0 : aPropertyValue = m_xTypeConverter->convertTo( _rControlValue, aProp.Type );
1044 : : }
1045 : 0 : catch( const uno::Exception& )
1046 : : {
1047 : : OSL_FAIL( "GeometryHandler::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
1048 : : }
1049 : 0 : }
1050 : : }
1051 : :
1052 : 0 : break;
1053 : : }
1054 : : case PROPERTY_ID_CONDITIONALPRINTEXPRESSION:
1055 : : case PROPERTY_ID_INITIALFORMULA:
1056 : : case PROPERTY_ID_FORMULA:
1057 : 0 : return uno::makeAny( impl_convertToFormula( _rControlValue ) );
1058 : : case PROPERTY_ID_DATAFIELD:
1059 : : {
1060 : 0 : ::rtl::OUString sDataField;
1061 : 0 : _rControlValue >>= sDataField;
1062 : 0 : if ( isDefaultFunction(sDataField,sDataField) )
1063 : : {
1064 : : OSL_ENSURE(m_xFunction.is(),"No function set!");
1065 : 0 : aPropertyValue <<= impl_convertToFormula( uno::makeAny(lcl_getQuotedFunctionName(m_xFunction)) );
1066 : : }
1067 : : else
1068 : 0 : aPropertyValue <<= impl_convertToFormula( _rControlValue );
1069 : : }
1070 : 0 : break;
1071 : : case PROPERTY_ID_POSITIONX:
1072 : : {
1073 : 0 : aPropertyValue = m_xFormComponentHandler->convertToPropertyValue(PropertyName, _rControlValue);
1074 : 0 : sal_Int32 nPosX = 0;
1075 : 0 : aPropertyValue >>= nPosX;
1076 : 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
1077 : 0 : if ( xSourceReportComponent->getSection().is() )
1078 : 0 : nPosX += getStyleProperty<sal_Int32>(xSourceReportComponent->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN);
1079 : 0 : aPropertyValue <<= nPosX;
1080 : : }
1081 : 0 : break;
1082 : : case PROPERTY_ID_FONT:
1083 : 0 : aPropertyValue = m_xFormComponentHandler->convertToPropertyValue(PROPERTY_FONT, _rControlValue);
1084 : 0 : break;
1085 : : case PROPERTY_ID_SCOPE:
1086 : : case PROPERTY_ID_FORMULALIST:
1087 : : case PROPERTY_ID_AREA:
1088 : 0 : aPropertyValue = _rControlValue;
1089 : 0 : break;
1090 : : case PROPERTY_ID_TYPE:
1091 : : {
1092 : 0 : ::rtl::OUString sValue;
1093 : 0 : _rControlValue >>= sValue;
1094 : 0 : ::std::vector< ::rtl::OUString > aList;
1095 : 0 : tools::StringListResource aRes(ModuleRes(RID_STR_TYPE_CONST),aList);
1096 : 0 : ::std::vector< ::rtl::OUString >::iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
1097 : 0 : if ( aFind != aList.end() )
1098 : 0 : aPropertyValue <<= static_cast<sal_uInt32>(aFind - aList.begin());
1099 : : }
1100 : 0 : break;
1101 : : case PROPERTY_ID_MIMETYPE:
1102 : 0 : aPropertyValue = _rControlValue;
1103 : 0 : break;
1104 : : case PROPERTY_ID_VERTICALALIGN:
1105 : : {
1106 : 0 : ::rtl::OUString sValue;
1107 : 0 : _rControlValue >>= sValue;
1108 : 0 : ::std::vector< ::rtl::OUString > aList;
1109 : 0 : tools::StringListResource aRes(ModuleRes(RID_STR_VERTICAL_ALIGN_CONST),aList);
1110 : 0 : ::std::vector< ::rtl::OUString >::iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
1111 : 0 : if ( aFind != aList.end() )
1112 : 0 : aPropertyValue <<= static_cast<style::VerticalAlignment>(aFind - aList.begin());
1113 : : }
1114 : 0 : break;
1115 : : case PROPERTY_ID_PARAADJUST:
1116 : : {
1117 : 0 : ::rtl::OUString sValue;
1118 : 0 : _rControlValue >>= sValue;
1119 : 0 : ::std::vector< ::rtl::OUString > aList;
1120 : 0 : tools::StringListResource aRes(ModuleRes(RID_STR_PARAADJUST_CONST),aList);
1121 : 0 : ::std::vector< ::rtl::OUString >::iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
1122 : 0 : if ( aFind != aList.end() )
1123 : 0 : aPropertyValue <<= static_cast<sal_Int16>(aFind - aList.begin());
1124 : : }
1125 : 0 : break;
1126 : : default:
1127 : 0 : return m_xFormComponentHandler->convertToPropertyValue(PropertyName, _rControlValue);
1128 : : }
1129 : 0 : return aPropertyValue;
1130 : : }
1131 : :
1132 : 0 : uno::Any SAL_CALL GeometryHandler::convertToControlValue(const ::rtl::OUString & PropertyName, const uno::Any & _rPropertyValue, const uno::Type & _rControlValueType) throw (uno::RuntimeException, beans::UnknownPropertyException)
1133 : : {
1134 : 0 : uno::Any aControlValue( _rPropertyValue );
1135 : 0 : if ( !aControlValue.hasValue() )
1136 : : // NULL is converted to NULL
1137 : : return aControlValue;
1138 : :
1139 : 0 : uno::Any aPropertyValue(_rPropertyValue);
1140 : :
1141 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
1142 : 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
1143 : 0 : switch(nId)
1144 : : {
1145 : : case PROPERTY_ID_AREA:
1146 : 0 : break;
1147 : : case PROPERTY_ID_FORCENEWPAGE:
1148 : : case PROPERTY_ID_NEWROWORCOL:
1149 : 0 : aControlValue = getConstantValue(sal_True,RID_STR_FORCENEWPAGE_CONST,aPropertyValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ForceNewPage")),PropertyName);
1150 : 0 : break;
1151 : : case PROPERTY_ID_GROUPKEEPTOGETHER:
1152 : 0 : aControlValue = getConstantValue(sal_True,RID_STR_GROUPKEEPTOGETHER_CONST,aPropertyValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.GroupKeepTogether")),PropertyName);
1153 : 0 : break;
1154 : : case PROPERTY_ID_PAGEHEADEROPTION:
1155 : : case PROPERTY_ID_PAGEFOOTEROPTION:
1156 : 0 : aControlValue = getConstantValue(sal_True,RID_STR_REPORTPRINTOPTION_CONST,aPropertyValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ReportPrintOption")),PropertyName);
1157 : 0 : break;
1158 : : case PROPERTY_ID_KEEPTOGETHER:
1159 : 0 : if ( uno::Reference< report::XGroup>(m_xReportComponent,uno::UNO_QUERY).is())
1160 : : {
1161 : 0 : aControlValue = getConstantValue(sal_True,RID_STR_KEEPTOGETHER_CONST,aPropertyValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.KeepTogether")),PropertyName);
1162 : 0 : break;
1163 : : }
1164 : : // run through
1165 : : case PROPERTY_ID_VISIBLE:
1166 : : case PROPERTY_ID_CANGROW:
1167 : : case PROPERTY_ID_CANSHRINK:
1168 : : case PROPERTY_ID_REPEATSECTION:
1169 : : case PROPERTY_ID_PRINTREPEATEDVALUES:
1170 : : case PROPERTY_ID_STARTNEWCOLUMN:
1171 : : case PROPERTY_ID_RESETPAGENUMBER:
1172 : : case PROPERTY_ID_PRINTWHENGROUPCHANGE:
1173 : : case PROPERTY_ID_DEEPTRAVERSING:
1174 : : case PROPERTY_ID_PREEVALUATED:
1175 : : case PROPERTY_ID_PRESERVEIRI:
1176 : : case PROPERTY_ID_BACKTRANSPARENT:
1177 : : case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT:
1178 : : {
1179 : 0 : if ( _rControlValueType.getTypeClass() == uno::TypeClass_STRING )
1180 : : {
1181 : 0 : const uno::Reference< inspection::XStringRepresentation > xConversionHelper = inspection::StringRepresentation::create( m_xContext,m_xTypeConverter );
1182 : 0 : aControlValue <<= xConversionHelper->convertToControlValue( aPropertyValue );
1183 : : }
1184 : : else
1185 : : {
1186 : : try
1187 : : {
1188 : 0 : aControlValue = m_xTypeConverter->convertTo( aPropertyValue, _rControlValueType );
1189 : : }
1190 : 0 : catch( const uno::Exception& )
1191 : : {
1192 : : OSL_FAIL( "GeometryHandler::convertToControlValue: caught an exception while converting via TypeConverter!" );
1193 : : }
1194 : : }
1195 : 0 : break;
1196 : : }
1197 : : case PROPERTY_ID_CONDITIONALPRINTEXPRESSION:
1198 : : case PROPERTY_ID_INITIALFORMULA:
1199 : : case PROPERTY_ID_FORMULA:
1200 : 0 : lcl_convertFormulaTo(aPropertyValue,aControlValue);
1201 : 0 : break;
1202 : : case PROPERTY_ID_DATAFIELD:
1203 : : {
1204 : 0 : ::rtl::OUString sValue;
1205 : 0 : aControlValue >>= sValue;
1206 : 0 : if ( isDefaultFunction(sValue,sValue) )
1207 : 0 : aControlValue <<= sValue;
1208 : : else
1209 : 0 : lcl_convertFormulaTo(aPropertyValue,aControlValue);
1210 : : }
1211 : 0 : break;
1212 : : case PROPERTY_ID_FONT:
1213 : 0 : aControlValue = m_xFormComponentHandler->convertToControlValue(PROPERTY_FONT, aPropertyValue, _rControlValueType);
1214 : 0 : break;
1215 : : case PROPERTY_ID_POSITIONX:
1216 : : {
1217 : 0 : sal_Int32 nPosX = 0;
1218 : 0 : aPropertyValue >>= nPosX;
1219 : 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
1220 : 0 : if ( xSourceReportComponent->getSection().is() )
1221 : 0 : nPosX -= getStyleProperty<sal_Int32>(xSourceReportComponent->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN);
1222 : 0 : aPropertyValue <<= nPosX;
1223 : 0 : aControlValue = m_xFormComponentHandler->convertToControlValue(PropertyName, aPropertyValue, _rControlValueType);
1224 : : }
1225 : 0 : break;
1226 : : case PROPERTY_ID_FORMULALIST:
1227 : 0 : aControlValue <<= m_sDefaultFunction;
1228 : 0 : break;
1229 : : case PROPERTY_ID_SCOPE:
1230 : 0 : aControlValue <<= m_sScope;
1231 : 0 : break;
1232 : : case PROPERTY_ID_MIMETYPE:
1233 : 0 : aControlValue = aPropertyValue;
1234 : 0 : break;
1235 : : case PROPERTY_ID_TYPE:
1236 : : {
1237 : 0 : ::std::vector< ::rtl::OUString > aList;
1238 : 0 : tools::StringListResource aRes(ModuleRes(RID_STR_TYPE_CONST),aList);
1239 : 0 : if ( m_nDataFieldType < aList.size() )
1240 : 0 : aControlValue <<= aList[m_nDataFieldType];
1241 : : }
1242 : 0 : break;
1243 : : case PROPERTY_ID_VERTICALALIGN:
1244 : : {
1245 : 0 : style::VerticalAlignment nParagraphVertAlign = style::VerticalAlignment_TOP;
1246 : 0 : aPropertyValue >>= nParagraphVertAlign;
1247 : 0 : ::std::vector< ::rtl::OUString > aList;
1248 : 0 : tools::StringListResource aRes(ModuleRes(RID_STR_VERTICAL_ALIGN_CONST),aList);
1249 : 0 : if ( static_cast<sal_Int16>(nParagraphVertAlign) < static_cast<sal_Int16>(aList.size()) )
1250 : 0 : aControlValue <<= aList[nParagraphVertAlign];
1251 : : }
1252 : 0 : break;
1253 : : case PROPERTY_ID_PARAADJUST:
1254 : : {
1255 : 0 : sal_Int16 nParagraphAdjust = style::ParagraphAdjust_LEFT;
1256 : 0 : aPropertyValue >>= nParagraphAdjust;
1257 : 0 : ::std::vector< ::rtl::OUString > aList;
1258 : 0 : tools::StringListResource aRes(ModuleRes(RID_STR_PARAADJUST_CONST),aList);
1259 : 0 : if ( nParagraphAdjust < static_cast<sal_Int16>(aList.size()) )
1260 : 0 : aControlValue <<= aList[nParagraphAdjust];
1261 : : }
1262 : 0 : break;
1263 : : case PROPERTY_ID_BACKCOLOR:
1264 : : case PROPERTY_ID_CONTROLBACKGROUND:
1265 : : {
1266 : 0 : sal_Int32 nColor = COL_TRANSPARENT;
1267 : 0 : if ( (aPropertyValue >>= nColor) && static_cast<sal_Int32>(COL_TRANSPARENT) == nColor )
1268 : 0 : aPropertyValue.clear();
1269 : : }
1270 : : // run through
1271 : : default:
1272 : 0 : aControlValue = m_xFormComponentHandler->convertToControlValue(PropertyName, aPropertyValue, _rControlValueType);
1273 : : }
1274 : 0 : return aControlValue;
1275 : : }
1276 : 0 : void SAL_CALL GeometryHandler::addPropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException, lang::NullPointerException)
1277 : : {
1278 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
1279 : 0 : m_aPropertyListeners.addListener( _rxListener );
1280 : 0 : m_xFormComponentHandler->addPropertyChangeListener(_rxListener);
1281 : 0 : }
1282 : :
1283 : 0 : void SAL_CALL GeometryHandler::removePropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException)
1284 : : {
1285 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
1286 : 0 : m_aPropertyListeners.removeListener( _rxListener );
1287 : 0 : m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
1288 : 0 : }
1289 : : // -----------------------------------------------------------------------------
1290 : : //--------------------------------------------------------------------------
1291 : 0 : uno::Sequence< beans::Property > SAL_CALL GeometryHandler::getSupportedProperties() throw (uno::RuntimeException)
1292 : : {
1293 : 0 : ::std::vector< beans::Property > aNewProps;
1294 : 0 : aNewProps.reserve(20); // only a guess
1295 : 0 : m_pInfoService->getExcludeProperties( aNewProps, m_xFormComponentHandler );
1296 : :
1297 : : const ::rtl::OUString pIncludeProperties[] =
1298 : : {
1299 : : PROPERTY_FORCENEWPAGE
1300 : : ,PROPERTY_KEEPTOGETHER
1301 : : ,PROPERTY_CANGROW
1302 : : ,PROPERTY_CANSHRINK
1303 : : ,PROPERTY_REPEATSECTION
1304 : : ,PROPERTY_PRINTREPEATEDVALUES
1305 : : ,PROPERTY_CONDITIONALPRINTEXPRESSION
1306 : : ,PROPERTY_STARTNEWCOLUMN
1307 : : ,PROPERTY_RESETPAGENUMBER
1308 : : ,PROPERTY_PRINTWHENGROUPCHANGE
1309 : : ,PROPERTY_VISIBLE
1310 : : ,PROPERTY_PAGEHEADEROPTION
1311 : : ,PROPERTY_PAGEFOOTEROPTION
1312 : : ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlLabel"))
1313 : : ,PROPERTY_POSITIONX
1314 : : ,PROPERTY_POSITIONY
1315 : : ,PROPERTY_WIDTH
1316 : : ,PROPERTY_HEIGHT
1317 : : ,PROPERTY_PREEVALUATED
1318 : : ,PROPERTY_DEEPTRAVERSING
1319 : : ,PROPERTY_FORMULA
1320 : : ,PROPERTY_INITIALFORMULA
1321 : : ,PROPERTY_PRESERVEIRI
1322 : : ,PROPERTY_DATAFIELD
1323 : : ,PROPERTY_FONT
1324 : : ,PROPERTY_BACKCOLOR
1325 : : ,PROPERTY_BACKTRANSPARENT
1326 : : ,PROPERTY_CONTROLBACKGROUND
1327 : : ,PROPERTY_CONTROLBACKGROUNDTRANSPARENT
1328 : : ,PROPERTY_LABEL
1329 : : ,PROPERTY_MIMETYPE
1330 : : ,PROPERTY_VERTICALALIGN
1331 : : ,PROPERTY_PARAADJUST
1332 : 0 : };
1333 : 0 : const uno::Reference < beans::XPropertySetInfo > xInfo = m_xReportComponent->getPropertySetInfo();
1334 : 0 : const uno::Sequence< beans::Property> aSeq = xInfo->getProperties();
1335 : 0 : for (size_t i = 0; i < sizeof(pIncludeProperties)/sizeof(pIncludeProperties[0]) ;++i )
1336 : : {
1337 : 0 : const beans::Property* pIter = aSeq.getConstArray();
1338 : 0 : const beans::Property* pEnd = pIter + aSeq.getLength();
1339 : 0 : const beans::Property* pFind = ::std::find_if(pIter,pEnd,::std::bind2nd(PropertyCompare(),boost::cref(pIncludeProperties[i])));
1340 : 0 : if ( pFind != pEnd )
1341 : : {
1342 : : // special case for controls which contain a data field
1343 : 0 : if ( PROPERTY_DATAFIELD == pIncludeProperties[i] )
1344 : : {
1345 : 0 : beans::Property aValue;
1346 : 0 : aValue.Name = PROPERTY_FORMULALIST;
1347 : 0 : aNewProps.push_back(aValue);
1348 : 0 : aValue.Name = PROPERTY_SCOPE;
1349 : 0 : aNewProps.push_back(aValue);
1350 : 0 : aValue.Name = PROPERTY_TYPE;
1351 : 0 : aNewProps.push_back(aValue);
1352 : : }
1353 : 0 : aNewProps.push_back(*pFind);
1354 : : }
1355 : : }
1356 : :
1357 : : // special property for shapes
1358 : : // if ( uno::Reference< report::XShape>(m_xReportComponent,uno::UNO_QUERY).is() )
1359 : : // {
1360 : : // beans::Property aValue;
1361 : : // aValue.Name = PROPERTY_AREA;
1362 : : // aNewProps.push_back(aValue);
1363 : : // }
1364 : : // re-enable when the remaining issues of #i88727# are fixed
1365 : :
1366 : 0 : return uno::Sequence< beans::Property > (&(*aNewProps.begin()),aNewProps.size());
1367 : : }
1368 : :
1369 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL GeometryHandler::getSupersededProperties() throw (uno::RuntimeException)
1370 : : {
1371 : 0 : uno::Sequence< ::rtl::OUString > aRet;
1372 : 0 : const uno::Reference<report::XReportDefinition> xReport(m_xReportComponent,uno::UNO_QUERY);
1373 : 0 : if ( xReport.is() && !uno::Reference< report::XSection>(xReport->getParent(),uno::UNO_QUERY).is() )
1374 : : {
1375 : 0 : aRet.realloc(5);
1376 : 0 : ::rtl::OUString* pIter = aRet.getArray();
1377 : 0 : *pIter++ = PROPERTY_POSITIONX;
1378 : 0 : *pIter++ = PROPERTY_POSITIONY;
1379 : 0 : *pIter++ = PROPERTY_WIDTH;
1380 : 0 : *pIter++ = PROPERTY_HEIGHT;
1381 : 0 : *pIter++ = PROPERTY_DATAFIELD;
1382 : : }
1383 : 0 : return aRet;
1384 : : }
1385 : :
1386 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL GeometryHandler::getActuatingProperties() throw (uno::RuntimeException)
1387 : : {
1388 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
1389 : :
1390 : 0 : uno::Sequence< ::rtl::OUString > aSeq(5);
1391 : 0 : aSeq[0] = PROPERTY_BACKTRANSPARENT;
1392 : 0 : aSeq[1] = PROPERTY_CONTROLBACKGROUNDTRANSPARENT;
1393 : 0 : aSeq[2] = PROPERTY_FORMULALIST;
1394 : 0 : aSeq[3] = PROPERTY_TYPE;
1395 : 0 : aSeq[4] = PROPERTY_DATAFIELD;
1396 : :
1397 : 0 : return ::comphelper::concatSequences(m_xFormComponentHandler->getActuatingProperties(),aSeq);
1398 : : }
1399 : :
1400 : 0 : ::sal_Bool SAL_CALL GeometryHandler::isComposable(const ::rtl::OUString & _rPropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
1401 : : {
1402 : 0 : return m_pInfoService->isComposable( _rPropertyName, m_xFormComponentHandler );
1403 : : }
1404 : :
1405 : 0 : inspection::InteractiveSelectionResult SAL_CALL GeometryHandler::onInteractivePropertySelection(const ::rtl::OUString & PropertyName, ::sal_Bool Primary, uno::Any & _rData, const uno::Reference< inspection::XObjectInspectorUI > & _rxInspectorUI) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::NullPointerException)
1406 : : {
1407 : 0 : if ( !_rxInspectorUI.is() )
1408 : 0 : throw lang::NullPointerException();
1409 : 0 : if (PropertyName.equalsAsciiL(PROPERTY_FILTER.ascii, PROPERTY_FILTER.length))
1410 : : {
1411 : 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1412 : :
1413 : 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
1414 : 0 : ::rtl::OUString sClause;
1415 : 0 : if ( impl_dialogFilter_nothrow( sClause, aGuard ) )
1416 : : {
1417 : 0 : _rData <<= sClause;
1418 : 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
1419 : : }
1420 : 0 : return eResult;
1421 : : }
1422 : 0 : else if (PropertyName.equalsAsciiL(PROPERTY_FONT.ascii, PROPERTY_FONT.length))
1423 : : {
1424 : 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1425 : :
1426 : 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
1427 : 0 : const uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
1428 : 0 : const uno::Reference< report::XReportControlFormat> xReportControlFormat(m_xReportComponent,uno::UNO_QUERY);
1429 : 0 : aGuard.clear();
1430 : :
1431 : 0 : uno::Sequence< beans::NamedValue > aFontSettings;
1432 : 0 : if ( rptui::openCharDialog( xReportControlFormat, xInspectorWindow, aFontSettings ) )
1433 : : {
1434 : 0 : _rData <<= aFontSettings;
1435 : 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
1436 : : }
1437 : 0 : return eResult;
1438 : : }
1439 : 0 : else if ( PropertyName.equalsAsciiL(PROPERTY_FORMULA.ascii, PROPERTY_FORMULA.length)
1440 : 0 : || PropertyName.equalsAsciiL(PROPERTY_INITIALFORMULA.ascii, PROPERTY_INITIALFORMULA.length)
1441 : 0 : || PropertyName.equalsAsciiL(PROPERTY_DATAFIELD.ascii, PROPERTY_INITIALFORMULA.length)
1442 : 0 : || PropertyName.equalsAsciiL(PROPERTY_CONDITIONALPRINTEXPRESSION.ascii, PROPERTY_CONDITIONALPRINTEXPRESSION.length))
1443 : : {
1444 : 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1445 : :
1446 : :
1447 : 0 : ::rtl::OUString sFormula;
1448 : 0 : m_xReportComponent->getPropertyValue(PropertyName) >>= sFormula;
1449 : 0 : const uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
1450 : 0 : uno::Reference< uno::XComponentContext > xContext = m_xContext;
1451 : 0 : uno::Reference< beans::XPropertySet > xRowSet( m_xRowSet,uno::UNO_QUERY);
1452 : 0 : aGuard.clear();
1453 : :
1454 : 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
1455 : 0 : if ( rptui::openDialogFormula_nothrow( sFormula, xContext,xInspectorWindow,xRowSet ) )
1456 : : {
1457 : 0 : _rData <<= sFormula;
1458 : 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
1459 : : }
1460 : 0 : return eResult;
1461 : : }
1462 : 0 : else if (PropertyName.equalsAsciiL(PROPERTY_AREA.ascii, PROPERTY_AREA.length))
1463 : : {
1464 : 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1465 : :
1466 : 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
1467 : 0 : const uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
1468 : 0 : const uno::Reference< report::XShape> xShape(m_xReportComponent,uno::UNO_QUERY);
1469 : 0 : aGuard.clear();
1470 : :
1471 : 0 : if ( rptui::openAreaDialog( xShape, xInspectorWindow) )
1472 : : {
1473 : 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
1474 : 0 : beans::PropertyChangeEvent aScopeEvent;
1475 : 0 : aScopeEvent.PropertyName = PROPERTY_FILLCOLOR;
1476 : 0 : aScopeEvent.NewValue <<= xShape->getPropertyValue(PROPERTY_FILLCOLOR);
1477 : 0 : m_aPropertyListeners.notify( aScopeEvent, &beans::XPropertyChangeListener::propertyChange );
1478 : : }
1479 : 0 : return eResult;
1480 : : }
1481 : :
1482 : :
1483 : 0 : return m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, _rData, _rxInspectorUI);
1484 : : }
1485 : :
1486 : 0 : void SAL_CALL GeometryHandler::actuatingPropertyChanged(const ::rtl::OUString & ActuatingPropertyName, const uno::Any & NewValue, const uno::Any & OldValue, const uno::Reference< inspection::XObjectInspectorUI > & _rxInspectorUI, ::sal_Bool _bFirstTimeInit) throw (uno::RuntimeException, lang::NullPointerException)
1487 : : {
1488 : 0 : if ( !_rxInspectorUI.is() )
1489 : 0 : throw lang::NullPointerException();
1490 : :
1491 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
1492 : 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(ActuatingPropertyName);
1493 : 0 : switch(nId)
1494 : : {
1495 : : case PROPERTY_ID_TYPE:
1496 : : {
1497 : 0 : sal_uInt32 nNewVal = 0;
1498 : 0 : NewValue >>= nNewVal;
1499 : 0 : switch(nNewVal)
1500 : : {
1501 : : case DATA_OR_FORMULA:
1502 : 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
1503 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True);
1504 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False);
1505 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False);
1506 : : OSL_ENSURE(m_sDefaultFunction.isEmpty(),"Why is the m_sDefaultFunction set?");
1507 : : OSL_ENSURE(m_sScope.isEmpty(),"Why is the m_sScope set?");
1508 : 0 : break;
1509 : : case FUNCTION:
1510 : 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
1511 : 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST);
1512 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True);
1513 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,!m_sDefaultFunction.isEmpty());
1514 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,!m_sScope.isEmpty());
1515 : 0 : break;
1516 : : case USER_DEF_FUNCTION:
1517 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False);
1518 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_True);
1519 : 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST);
1520 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False);
1521 : 0 : break;
1522 : : case COUNTER:
1523 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False);
1524 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False);
1525 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_True);
1526 : 0 : break;
1527 : : }
1528 : : }
1529 : 0 : break;
1530 : : case PROPERTY_ID_DATAFIELD:
1531 : : {
1532 : 0 : sal_Bool bEnable = (m_nDataFieldType != DATA_OR_FORMULA && m_nDataFieldType != COUNTER );
1533 : 0 : if ( bEnable )
1534 : : {
1535 : 0 : ::rtl::OUString sValue;
1536 : 0 : m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ) >>= sValue;
1537 : 0 : bEnable = !sValue.isEmpty();
1538 : : }
1539 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,bEnable);
1540 : 0 : if ( bEnable )
1541 : : {
1542 : 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
1543 : 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST);
1544 : : }
1545 : 0 : m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, _rxInspectorUI, _bFirstTimeInit);
1546 : : }
1547 : 0 : break;
1548 : : case PROPERTY_ID_FORMULALIST:
1549 : : {
1550 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_nDataFieldType == FUNCTION || m_nDataFieldType == COUNTER);
1551 : : }
1552 : 0 : break;
1553 : : case PROPERTY_ID_BACKTRANSPARENT:
1554 : : case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT:
1555 : : {
1556 : 0 : sal_Bool bValue = sal_False;
1557 : 0 : NewValue >>= bValue;
1558 : 0 : bValue = !bValue;
1559 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_BACKCOLOR,bValue);
1560 : 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_CONTROLBACKGROUND,bValue);
1561 : : }
1562 : 0 : break;
1563 : : default:
1564 : 0 : m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, _rxInspectorUI, _bFirstTimeInit);
1565 : 0 : break;
1566 : 0 : }
1567 : 0 : }
1568 : :
1569 : 0 : ::sal_Bool SAL_CALL GeometryHandler::suspend(::sal_Bool Suspend) throw (uno::RuntimeException)
1570 : : {
1571 : 0 : return m_xFormComponentHandler->suspend(Suspend);
1572 : : }
1573 : : // -----------------------------------------------------------------------------
1574 : 0 : bool GeometryHandler::impl_dialogFilter_nothrow( ::rtl::OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
1575 : : {
1576 : 0 : _out_rSelectedClause = ::rtl::OUString();
1577 : 0 : bool bSuccess = false;
1578 : 0 : ::dbtools::SQLExceptionInfo aErrorInfo;
1579 : 0 : uno::Reference< awt::XWindow > xInspectorWindow;
1580 : 0 : uno::Reference< lang::XMultiComponentFactory > xFactory;
1581 : 0 : uno::Reference<lang::XMultiServiceFactory> xServiceFactory;
1582 : : try
1583 : : {
1584 : 0 : xFactory = m_xContext->getServiceManager();
1585 : 0 : xServiceFactory.set(xFactory,uno::UNO_QUERY);
1586 : 0 : xInspectorWindow.set(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
1587 : 0 : uno::Reference<sdbc::XConnection> xCon(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection"))) ,uno::UNO_QUERY);
1588 : 0 : if ( !xCon.is() )
1589 : 0 : return false;
1590 : :
1591 : 0 : uno::Reference< beans::XPropertySet> xRowSetProp(m_xRowSet,uno::UNO_QUERY);
1592 : 0 : if ( !m_xRowSet.is() )
1593 : : {
1594 : 0 : m_xRowSet.set(xFactory->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.RowSet")),m_xContext),uno::UNO_QUERY);
1595 : 0 : xRowSetProp.set(m_xRowSet,uno::UNO_QUERY);
1596 : 0 : xRowSetProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,uno::makeAny(xCon));
1597 : 0 : ::comphelper::copyProperties(m_xReportComponent,xRowSetProp);
1598 : : }
1599 : :
1600 : : // get a composer for the statement which the form is currently based on
1601 : 0 : uno::Reference< sdb::XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( xRowSetProp, xServiceFactory ) );
1602 : : OSL_ENSURE( xComposer.is(), "GeometryHandler::impl_dialogFilter_nothrow: could not obtain a composer!" );
1603 : 0 : if ( !xComposer.is() )
1604 : 0 : return false;
1605 : :
1606 : : // create the dialog
1607 : 0 : uno::Reference< ui::dialogs::XExecutableDialog > xDialog(xFactory->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.FilterDialog")),m_xContext),uno::UNO_QUERY);
1608 : 0 : if ( !xDialog.is() )
1609 : : {
1610 : 0 : Window* pInspectorWindow = VCLUnoHelper::GetWindow( xInspectorWindow );
1611 : 0 : ShowServiceNotAvailableError( pInspectorWindow, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.FilterDialog")), sal_True );
1612 : 0 : return false;
1613 : : }
1614 : :
1615 : 0 : const String aGcc3WorkaroundTemporary( ModuleRes(RID_STR_FILTER));
1616 : 0 : const ::rtl::OUString sPropertyUIName( aGcc3WorkaroundTemporary );
1617 : : // initialize the dialog
1618 : 0 : uno::Reference< beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY_THROW );
1619 : 0 : xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "QueryComposer" ) ), uno::makeAny( xComposer ) );
1620 : 0 : xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowSet" ) ), uno::makeAny( m_xRowSet ) );
1621 : 0 : xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ), uno::makeAny( xInspectorWindow ) );
1622 : 0 : xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), uno::makeAny( sPropertyUIName ) );
1623 : :
1624 : 0 : _rClearBeforeDialog.clear();
1625 : 0 : bSuccess = ( xDialog->execute() != 0 );
1626 : 0 : if ( bSuccess )
1627 : 0 : _out_rSelectedClause = xComposer->getFilter();
1628 : : }
1629 : 0 : catch (const sdb::SQLContext& e) { aErrorInfo = e; }
1630 : 0 : catch (const sdbc::SQLWarning& e) { aErrorInfo = e; }
1631 : 0 : catch (const sdbc::SQLException& e) { aErrorInfo = e; }
1632 : 0 : catch( const uno::Exception& )
1633 : : {
1634 : : OSL_FAIL( "GeometryHandler::impl_dialogFilter_nothrow: caught an exception!" );
1635 : : }
1636 : :
1637 : 0 : if ( aErrorInfo.isValid() )
1638 : 0 : ::dbtools::showError( aErrorInfo, xInspectorWindow, xServiceFactory );
1639 : :
1640 : 0 : return bSuccess;
1641 : : }
1642 : : // -----------------------------------------------------------------------------
1643 : 0 : void GeometryHandler::checkPosAndSize( const awt::Point& _aNewPos,
1644 : : const awt::Size& _aSize)
1645 : : {
1646 : 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
1647 : 0 : const uno::Reference< report::XSection> xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY);
1648 : 0 : if ( !xSection.is() || uno::Reference< report::XShape>(xSourceReportComponent,uno::UNO_QUERY).is() ) // shapes can overlap.
1649 : 0 : return;
1650 : :
1651 : 0 : ::Point aPos(VCLPoint(_aNewPos));
1652 : 0 : if ( aPos.X() < 0 || aPos.Y() < 0 ) // TODO: have to check size with pos aka || (aPos.X() + aAwtSize.Width) > m_xSection->getReportDefinition()->
1653 : 0 : throw beans::PropertyVetoException(String(ModuleRes(RID_STR_ILLEGAL_POSITION)),xSourceReportComponent);
1654 : :
1655 : 0 : ::Rectangle aSourceRect(aPos,VCLSize(_aSize));
1656 : :
1657 : 0 : const sal_Int32 nCount = xSection->getCount();
1658 : 0 : for (sal_Int32 i = 0; i < nCount ; ++i)
1659 : : {
1660 : 0 : const uno::Reference< report::XReportComponent> xReportComponent(xSection->getByIndex(i),uno::UNO_QUERY);
1661 : 0 : if ( xReportComponent.is() && xReportComponent != xSourceReportComponent )
1662 : : {
1663 : 0 : const ::Rectangle aBoundRect(VCLPoint(xReportComponent->getPosition()),VCLSize(xReportComponent->getSize()));
1664 : 0 : const ::Rectangle aRect = aSourceRect.GetIntersection(aBoundRect);
1665 : 0 : if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
1666 : 0 : throw beans::PropertyVetoException(String(ModuleRes( RID_STR_OVERLAP_OTHER_CONTROL)),xSourceReportComponent);
1667 : : }
1668 : 0 : }
1669 : : }
1670 : : // -----------------------------------------------------------------------------
1671 : 0 : void GeometryHandler::impl_fillFormulaList_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const
1672 : : {
1673 : 0 : if ( m_nDataFieldType == FUNCTION )
1674 : 0 : ::std::transform(m_aDefaultFunctions.begin(),m_aDefaultFunctions.end(),::std::back_inserter(_out_rList),::boost::bind( &DefaultFunction::getName, _1 ));
1675 : 0 : else if ( m_nDataFieldType == USER_DEF_FUNCTION )
1676 : 0 : ::std::transform(m_aFunctionNames.begin(),m_aFunctionNames.end(),::std::back_inserter(_out_rList),::o3tl::select1st<TFunctions::value_type>());
1677 : 0 : }
1678 : : // -----------------------------------------------------------------------------
1679 : 0 : ::rtl::OUString GeometryHandler::impl_ConvertUIToMimeType_nothrow(const ::rtl::OUString& _sUIName) const
1680 : : {
1681 : 0 : ::std::vector< ::rtl::OUString > aList;
1682 : 0 : impl_fillMimeTypes_nothrow(aList);
1683 : 0 : ::rtl::OUString sRet;
1684 : 0 : ::std::vector< ::rtl::OUString >::const_iterator aFind = ::std::find(aList.begin(),aList.end(),_sUIName);
1685 : 0 : if ( aFind != aList.end() )
1686 : : {
1687 : 0 : const sal_Size nPos = aFind - aList.begin();
1688 : 0 : const uno::Reference< report::XReportDefinition> xReportDefinition(m_xReportComponent,uno::UNO_QUERY);
1689 : 0 : if ( xReportDefinition.is() )
1690 : : {
1691 : 0 : const uno::Sequence< ::rtl::OUString > aMimeTypes( xReportDefinition->getAvailableMimeTypes() );
1692 : 0 : sRet = aMimeTypes[nPos];
1693 : 0 : }
1694 : : }
1695 : 0 : return sRet;
1696 : : }
1697 : : // -----------------------------------------------------------------------------
1698 : 0 : ::rtl::OUString GeometryHandler::impl_ConvertMimeTypeToUI_nothrow(const ::rtl::OUString& _sMimetype) const
1699 : : {
1700 : 0 : uno::Reference<lang::XMultiServiceFactory> xServiceFactory(m_xContext->getServiceManager(),uno::UNO_QUERY_THROW);
1701 : 0 : ::comphelper::MimeConfigurationHelper aMimeHelper(xServiceFactory);
1702 : 0 : ::rtl::OUString sRet;
1703 : 0 : const SfxFilter* pFilter = SfxFilter::GetDefaultFilter( aMimeHelper.GetDocServiceNameFromMediaType(_sMimetype) );
1704 : 0 : if ( pFilter )
1705 : 0 : sRet = pFilter->GetUIName();
1706 : 0 : if ( sRet.isEmpty() )
1707 : 0 : sRet = _sMimetype;
1708 : 0 : return sRet;
1709 : : }
1710 : : // -----------------------------------------------------------------------------
1711 : 0 : void GeometryHandler::impl_fillMimeTypes_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const
1712 : : {
1713 : : try
1714 : : {
1715 : 0 : const uno::Reference< report::XReportDefinition> xReportDefinition(m_xReportComponent,uno::UNO_QUERY);
1716 : 0 : if ( xReportDefinition.is() )
1717 : : {
1718 : 0 : uno::Sequence< ::rtl::OUString > aMimeTypes( xReportDefinition->getAvailableMimeTypes() );
1719 : 0 : const ::rtl::OUString* pIter = aMimeTypes.getConstArray();
1720 : 0 : const ::rtl::OUString* pEnd = pIter + aMimeTypes.getLength();
1721 : 0 : for(;pIter != pEnd; ++pIter)
1722 : : {
1723 : 0 : const ::rtl::OUString sDocName( impl_ConvertMimeTypeToUI_nothrow(*pIter) );
1724 : 0 : if ( !sDocName.isEmpty() )
1725 : 0 : _out_rList.push_back(sDocName);
1726 : 0 : }
1727 : 0 : }
1728 : : }
1729 : 0 : catch(uno::Exception&)
1730 : : {
1731 : : OSL_FAIL("Exception caught!");
1732 : : }
1733 : 0 : }
1734 : : // -----------------------------------------------------------------------------
1735 : 0 : void GeometryHandler::impl_fillScopeList_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const
1736 : : {
1737 : : try
1738 : : {
1739 : 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY_THROW);
1740 : 0 : const uno::Reference< report::XSection> xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY_THROW);
1741 : :
1742 : 0 : const uno::Reference< report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
1743 : 0 : const uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
1744 : 0 : sal_Int32 nPos = -1;
1745 : 0 : uno::Reference< report::XGroup> xGroup = xSection->getGroup();
1746 : 0 : if ( xGroup.is() )
1747 : 0 : nPos = getPositionInIndexAccess(xGroups.get(),xGroup);
1748 : 0 : else if ( xSection == xReportDefinition->getDetail() )
1749 : 0 : nPos = xGroups->getCount()-1;
1750 : :
1751 : 0 : const String sGroup = String(ModuleRes(RID_STR_SCOPE_GROUP));
1752 : 0 : for (sal_Int32 i = 0 ; i <= nPos ; ++i)
1753 : : {
1754 : 0 : xGroup.set(xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
1755 : 0 : String sGroupName = sGroup;
1756 : 0 : sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
1757 : 0 : _out_rList.push_back(sGroupName);
1758 : 0 : }
1759 : 0 : _out_rList.push_back(xReportDefinition->getName());
1760 : : }
1761 : 0 : catch(uno::Exception&)
1762 : : {
1763 : : OSL_FAIL("Exception caught!");
1764 : : }
1765 : 0 : }
1766 : : // -----------------------------------------------------------------------------
1767 : 0 : uno::Reference< report::XFunctionsSupplier> GeometryHandler::fillScope_throw(::rtl::OUString& _rsNamePostFix)
1768 : : {
1769 : 0 : uno::Reference< report::XFunctionsSupplier> xReturn;
1770 : :
1771 : 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY_THROW);
1772 : 0 : const uno::Reference< report::XSection> xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY_THROW);
1773 : 0 : const uno::Reference< report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
1774 : 0 : if ( m_sScope.isEmpty() )
1775 : : {
1776 : 0 : const uno::Reference< report::XGroup> xGroup(xSection->getGroup(),uno::UNO_QUERY);
1777 : 0 : if ( xGroup.is() )
1778 : : {
1779 : 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
1780 : 0 : _rsNamePostFix = xGroup->getExpression();
1781 : 0 : sGroupName.SearchAndReplaceAscii("%1",_rsNamePostFix);
1782 : 0 : m_sScope = sGroupName;
1783 : 0 : xReturn = xGroup.get();
1784 : : }
1785 : 0 : else if ( xSection == xReportDefinition->getDetail() )
1786 : : {
1787 : 0 : const uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
1788 : 0 : const sal_Int32 nCount = xGroups->getCount();
1789 : 0 : if ( nCount )
1790 : : {
1791 : 0 : const uno::Reference< report::XGroup> xGroup2(xGroups->getByIndex(nCount - 1),uno::UNO_QUERY_THROW);
1792 : 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
1793 : 0 : _rsNamePostFix = xGroup2->getExpression();
1794 : 0 : sGroupName.SearchAndReplaceAscii("%1",_rsNamePostFix);
1795 : 0 : m_sScope = sGroupName;
1796 : 0 : xReturn = xGroup2.get();
1797 : 0 : }
1798 : : }
1799 : 0 : if ( m_sScope.isEmpty() )
1800 : : {
1801 : 0 : xReturn = xReportDefinition.get();
1802 : 0 : _rsNamePostFix = m_sScope = xReportDefinition->getName();
1803 : 0 : }
1804 : : }
1805 : 0 : else if ( m_sScope == xReportDefinition->getName() )
1806 : : {
1807 : 0 : xReturn = xReportDefinition.get();
1808 : 0 : _rsNamePostFix = m_sScope;
1809 : : }
1810 : : else
1811 : : {
1812 : 0 : uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
1813 : 0 : const sal_Int32 nCount = xGroups->getCount();
1814 : :
1815 : 0 : for (sal_Int32 i = 0 ; i < nCount; ++i)
1816 : : {
1817 : 0 : const uno::Reference< report::XGroup> xGroup(xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
1818 : 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
1819 : 0 : sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
1820 : 0 : if ( m_sScope == ::rtl::OUString(sGroupName) )
1821 : : {
1822 : 0 : _rsNamePostFix = xGroup->getExpression();
1823 : 0 : xReturn = xGroup.get();
1824 : : break;
1825 : : }
1826 : 0 : }
1827 : :
1828 : : }
1829 : : OSL_ENSURE(xReturn.is(),"Why don't we have a functionssupplier here!");
1830 : :
1831 : 0 : return xReturn;
1832 : : }
1833 : : // -----------------------------------------------------------------------------
1834 : 0 : sal_Bool GeometryHandler::isDefaultFunction( const ::rtl::OUString& _sQuotedFunction
1835 : : ,::rtl::OUString& _rDataField
1836 : : ,const uno::Reference< report::XFunctionsSupplier>& _xFunctionsSupplier
1837 : : ,bool _bSet) const
1838 : : {
1839 : 0 : sal_Bool bDefaultFunction = sal_False;
1840 : : try
1841 : : {
1842 : 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY_THROW);
1843 : 0 : const uno::Reference< report::XSection> xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY_THROW);
1844 : 0 : const uno::Reference< report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
1845 : :
1846 : 0 : ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = m_aFunctionNames.equal_range(_sQuotedFunction);
1847 : 0 : while ( aFind.first != aFind.second )
1848 : : {
1849 : 0 : if ( !_xFunctionsSupplier.is() || _xFunctionsSupplier == aFind.first->second.second )
1850 : : {
1851 : 0 : const beans::Optional< ::rtl::OUString> aInitalFormula = aFind.first->second.first->getInitialFormula();
1852 : 0 : if ( aInitalFormula.IsPresent )
1853 : : {
1854 : 0 : ::rtl::OUString sDefaultFunctionName;
1855 : 0 : bDefaultFunction = impl_isDefaultFunction_nothrow(aFind.first->second.first,_rDataField,sDefaultFunctionName);
1856 : 0 : if ( bDefaultFunction )
1857 : : {
1858 : 0 : m_xFunction = aFind.first->second.first;
1859 : 0 : if ( _bSet )
1860 : : {
1861 : 0 : m_sDefaultFunction = sDefaultFunctionName;
1862 : 0 : uno::Reference< report::XGroup> xGroup(aFind.first->second.second,uno::UNO_QUERY);
1863 : 0 : if ( xGroup.is() )
1864 : : {
1865 : 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
1866 : 0 : sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
1867 : 0 : m_sScope = sGroupName;
1868 : : }
1869 : : else
1870 : 0 : m_sScope = xReportDefinition->getName();
1871 : : }
1872 : : }
1873 : 0 : break;
1874 : 0 : }
1875 : : }
1876 : 0 : ++(aFind.first);
1877 : 0 : }
1878 : : }
1879 : 0 : catch(uno::Exception&)
1880 : : {
1881 : : OSL_FAIL("Exception caught!");
1882 : : }
1883 : 0 : return bDefaultFunction;
1884 : : }
1885 : : // -----------------------------------------------------------------------------
1886 : 0 : sal_Bool GeometryHandler::impl_isDefaultFunction_nothrow( const uno::Reference< report::XFunction>& _xFunction
1887 : : ,::rtl::OUString& _rDataField
1888 : : ,::rtl::OUString& _rsDefaultFunctionName) const
1889 : : {
1890 : 0 : sal_Bool bDefaultFunction = sal_False;
1891 : : try
1892 : : {
1893 : 0 : const String sFormula( _xFunction->getFormula() );
1894 : 0 : util::SearchOptions aSearchOptions;
1895 : 0 : aSearchOptions.algorithmType = util::SearchAlgorithms_REGEXP;
1896 : 0 : aSearchOptions.searchFlag = 0x00000100;
1897 : 0 : ::std::vector< DefaultFunction >::const_iterator aIter = m_aDefaultFunctions.begin();
1898 : 0 : ::std::vector< DefaultFunction >::const_iterator aDeEnd = m_aDefaultFunctions.end();
1899 : 0 : for (; aIter != aDeEnd; ++aIter)
1900 : : {
1901 : 0 : aSearchOptions.searchString = aIter->m_sSearchString;
1902 : 0 : utl::TextSearch aTextSearch(aSearchOptions);
1903 : 0 : xub_StrLen start = 0;
1904 : 0 : xub_StrLen end = sFormula.Len();
1905 : 0 : if ( aTextSearch.SearchFrwrd(sFormula,&start,&end) && start == 0 && end == sFormula.Len()) // default function found
1906 : : {
1907 : 0 : aSearchOptions.searchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]"));
1908 : 0 : utl::TextSearch aDataSearch(aSearchOptions);
1909 : 0 : aDataSearch.SearchFrwrd(sFormula,&start,&end );
1910 : 0 : ++start;
1911 : 0 : _rDataField = sFormula.Copy(start,end-start-1);
1912 : 0 : _rsDefaultFunctionName = aIter->m_sName;
1913 : 0 : break;
1914 : : }
1915 : 0 : }
1916 : :
1917 : 0 : bDefaultFunction = aIter != aDeEnd;
1918 : : }
1919 : 0 : catch(uno::Exception&)
1920 : : {
1921 : : OSL_FAIL("Exception caught!");
1922 : : }
1923 : 0 : return bDefaultFunction;
1924 : : }
1925 : : // -----------------------------------------------------------------------------
1926 : 0 : void GeometryHandler::loadDefaultFunctions()
1927 : : {
1928 : 0 : if ( m_aDefaultFunctions.empty() )
1929 : : {
1930 : 0 : m_aCounterFunction.m_bPreEvaluated = sal_False;
1931 : 0 : m_aCounterFunction.m_bDeepTraversing = sal_False;
1932 : 0 : m_aCounterFunction.m_sName = String(ModuleRes(RID_STR_F_COUNTER));
1933 : 0 : m_aCounterFunction.m_sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%FunctionName] + 1"));
1934 : 0 : m_aCounterFunction.m_sSearchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*[:digit:]*"));
1935 : 0 : m_aCounterFunction.m_sInitialFormula.IsPresent = sal_True;
1936 : 0 : m_aCounterFunction.m_sInitialFormula.Value = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:1"));
1937 : :
1938 : 0 : DefaultFunction aDefault;
1939 : 0 : aDefault.m_bDeepTraversing = sal_False;
1940 : :
1941 : 0 : aDefault.m_bPreEvaluated = sal_True;
1942 : :
1943 : 0 : aDefault.m_sName = String(ModuleRes(RID_STR_F_ACCUMULATION));
1944 : 0 : aDefault.m_sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column] + [%FunctionName]"));
1945 : 0 : aDefault.m_sSearchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]"));
1946 : 0 : aDefault.m_sInitialFormula.IsPresent = sal_True;
1947 : 0 : aDefault.m_sInitialFormula.Value = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
1948 : 0 : m_aDefaultFunctions.push_back(aDefault);
1949 : :
1950 : 0 : aDefault.m_sName = String(ModuleRes(RID_STR_F_MINIMUM));
1951 : 0 : aDefault.m_sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF([%Column] < [%FunctionName];[%Column];[%FunctionName])"));
1952 : 0 : aDefault.m_sSearchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*<[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"));
1953 : 0 : aDefault.m_sInitialFormula.IsPresent = sal_True;
1954 : 0 : aDefault.m_sInitialFormula.Value = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
1955 : 0 : m_aDefaultFunctions.push_back(aDefault);
1956 : :
1957 : 0 : aDefault.m_sName = String(ModuleRes(RID_STR_F_MAXIMUM));
1958 : 0 : aDefault.m_sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF([%Column] > [%FunctionName];[%Column];[%FunctionName])"));
1959 : 0 : aDefault.m_sSearchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*>[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"));
1960 : 0 : aDefault.m_sInitialFormula.IsPresent = sal_True;
1961 : 0 : aDefault.m_sInitialFormula.Value = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
1962 : 0 : m_aDefaultFunctions.push_back(aDefault);
1963 : : }
1964 : 0 : }
1965 : : // -----------------------------------------------------------------------------
1966 : 0 : void GeometryHandler::createDefaultFunction(::osl::ResettableMutexGuard& _aGuard ,const ::rtl::OUString& _sFunction,const ::rtl::OUString& _sDataField)
1967 : : {
1968 : : try
1969 : : {
1970 : 0 : ::rtl::OUString sNamePostFix;
1971 : 0 : const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostFix);
1972 : :
1973 : 0 : ::std::vector< DefaultFunction >::const_iterator aIter = m_aDefaultFunctions.begin();
1974 : 0 : ::std::vector< DefaultFunction >::const_iterator aDeEnd = m_aDefaultFunctions.end();
1975 : 0 : for (; aIter != aDeEnd; ++aIter)
1976 : : {
1977 : 0 : if ( aIter->m_sName == _sFunction )
1978 : : {
1979 : 0 : const ::rtl::OUString sFunctionName( _sFunction + _sDataField + sNamePostFix);
1980 : 0 : const ::rtl::OUString sQuotedFunctionName(lcl_getQuotedFunctionName(sFunctionName));
1981 : :
1982 : 0 : beans::PropertyChangeEvent aEvent;
1983 : 0 : aEvent.PropertyName = PROPERTY_SCOPE;
1984 : 0 : aEvent.OldValue <<= m_sScope;
1985 : :
1986 : 0 : ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = m_aFunctionNames.equal_range(sQuotedFunctionName);
1987 : 0 : while ( aFind.first != aFind.second )
1988 : : {
1989 : 0 : if ( xFunctionsSupplier == aFind.first->second.second )
1990 : : {
1991 : 0 : m_xFunction = aFind.first->second.first;
1992 : 0 : ::rtl::OUString sTemp;
1993 : 0 : isDefaultFunction(sQuotedFunctionName,sTemp,uno::Reference< report::XFunctionsSupplier>(),true); // implicitly sets the m_sScope
1994 : 0 : break;
1995 : : }
1996 : 0 : ++(aFind.first);
1997 : : }
1998 : 0 : if ( aFind.first == aFind.second )
1999 : 0 : impl_createFunction(sFunctionName,_sDataField,*aIter);
2000 : :
2001 : 0 : OBlocker aBlocker(m_bIn);
2002 : 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny( impl_convertToFormula( uno::makeAny(sQuotedFunctionName) )));
2003 : 0 : aEvent.NewValue <<= m_sScope;
2004 : 0 : _aGuard.clear();
2005 : 0 : m_aPropertyListeners.notify( aEvent, &beans::XPropertyChangeListener::propertyChange );
2006 : 0 : break;
2007 : : }
2008 : 0 : }
2009 : : }
2010 : 0 : catch(uno::Exception&)
2011 : : {
2012 : : OSL_FAIL("Exception caught!");
2013 : : }
2014 : 0 : }
2015 : : // -----------------------------------------------------------------------------
2016 : 0 : void GeometryHandler::removeFunction()
2017 : : {
2018 : 0 : if ( m_xFunction.is() )
2019 : : {
2020 : 0 : const ::rtl::OUString sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction));
2021 : 0 : ::std::pair<TFunctions::iterator,TFunctions::iterator> aFind = m_aFunctionNames.equal_range(sQuotedFunctionName);
2022 : 0 : while ( aFind.first != aFind.second )
2023 : : {
2024 : 0 : if ( aFind.first->second.first == m_xFunction )
2025 : : {
2026 : 0 : uno::Reference< report::XFunctions> xFunctions = aFind.first->second.second->getFunctions();
2027 : 0 : xFunctions->removeByIndex(xFunctions->getCount() - 1 ); /// TODO: insert new method in XFunctions: removeFunction(xfunction)
2028 : 0 : m_aFunctionNames.erase(aFind.first);
2029 : 0 : m_bNewFunction = false;
2030 : 0 : break;
2031 : : }
2032 : 0 : ++(aFind.first);
2033 : 0 : }
2034 : : }
2035 : 0 : }
2036 : : // -----------------------------------------------------------------------------
2037 : 0 : void GeometryHandler::resetOwnProperties(::osl::ResettableMutexGuard& _aGuard,const ::rtl::OUString& _sOldFunctionName,const ::rtl::OUString& _sOldScope,const sal_uInt32 _nOldDataFieldType)
2038 : : {
2039 : 0 : const ::rtl::OUString sNewFunction = m_sDefaultFunction;
2040 : 0 : const ::rtl::OUString sNewScope = m_sScope;
2041 : 0 : const sal_uInt32 nNewDataFieldType = m_nDataFieldType;
2042 : 0 : _aGuard.clear();
2043 : 0 : if ( _nOldDataFieldType != nNewDataFieldType )
2044 : : {
2045 : 0 : beans::PropertyChangeEvent aScopeEvent;
2046 : 0 : aScopeEvent.PropertyName = PROPERTY_TYPE;
2047 : 0 : aScopeEvent.OldValue <<= _nOldDataFieldType;
2048 : 0 : aScopeEvent.NewValue <<= nNewDataFieldType;
2049 : 0 : m_aPropertyListeners.notify( aScopeEvent, &beans::XPropertyChangeListener::propertyChange );
2050 : : }
2051 : 0 : if ( _sOldFunctionName != sNewFunction )
2052 : : {
2053 : 0 : beans::PropertyChangeEvent aFormulaEvent;
2054 : 0 : aFormulaEvent.PropertyName = PROPERTY_FORMULALIST;
2055 : 0 : aFormulaEvent.OldValue <<= _sOldFunctionName;
2056 : 0 : aFormulaEvent.NewValue <<= sNewFunction;
2057 : :
2058 : 0 : m_aPropertyListeners.notify( aFormulaEvent, &beans::XPropertyChangeListener::propertyChange );
2059 : : }
2060 : 0 : if ( _sOldScope != sNewScope )
2061 : : {
2062 : 0 : beans::PropertyChangeEvent aScopeEvent;
2063 : 0 : aScopeEvent.PropertyName = PROPERTY_SCOPE;
2064 : 0 : aScopeEvent.OldValue <<= _sOldScope;
2065 : 0 : aScopeEvent.NewValue <<= sNewScope;
2066 : 0 : m_aPropertyListeners.notify( aScopeEvent, &beans::XPropertyChangeListener::propertyChange );
2067 : : }
2068 : :
2069 : 0 : _aGuard.reset();
2070 : 0 : }
2071 : : //------------------------------------------------------------------------
2072 : 0 : void GeometryHandler::impl_initFieldList_nothrow( uno::Sequence< ::rtl::OUString >& _rFieldNames ) const
2073 : : {
2074 : 0 : _rFieldNames.realloc(0);
2075 : : try
2076 : : {
2077 : 0 : uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
2078 : 0 : Window* pInspectorWindow = VCLUnoHelper::GetWindow( xInspectorWindow );
2079 : 0 : WaitObject aWaitCursor( pInspectorWindow );
2080 : :
2081 : 0 : uno::Reference< sdbc::XPreparedStatement > xStatement;
2082 : :
2083 : : // get the form of the control we're inspecting
2084 : 0 : uno::Reference< beans::XPropertySet > xFormSet( m_xRowSet, uno::UNO_QUERY );
2085 : 0 : if ( !xFormSet.is() )
2086 : 0 : return;
2087 : :
2088 : 0 : ::rtl::OUString sObjectName;
2089 : 0 : OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMAND ) >>= sObjectName );
2090 : : // when there is no command we don't need to ask for columns
2091 : 0 : uno::Reference<sdbc::XConnection> xCon(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection"))) ,uno::UNO_QUERY);
2092 : 0 : if ( !sObjectName.isEmpty() && xCon.is() )
2093 : : {
2094 : 0 : sal_Int32 nObjectType = sdb::CommandType::COMMAND;
2095 : 0 : OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nObjectType );
2096 : :
2097 : 0 : _rFieldNames = ::dbtools::getFieldNamesByCommandDescriptor( xCon, nObjectType, sObjectName );
2098 : 0 : }
2099 : : }
2100 : 0 : catch (uno::Exception&)
2101 : : {
2102 : : OSL_FAIL( "GeometryHandler::impl_initFieldList_nothrow: caught an exception!" );
2103 : : }
2104 : : }
2105 : : // -----------------------------------------------------------------------------
2106 : 0 : bool GeometryHandler::impl_isCounterFunction_throw(const ::rtl::OUString& _sQuotedFunctionName,::rtl::OUString& _Out_sScope) const
2107 : : {
2108 : 0 : ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = m_aFunctionNames.equal_range(_sQuotedFunctionName);
2109 : 0 : while ( aFind.first != aFind.second )
2110 : : {
2111 : 0 : const beans::Optional< ::rtl::OUString> aInitalFormula = aFind.first->second.first->getInitialFormula();
2112 : 0 : if ( aInitalFormula.IsPresent )
2113 : : {
2114 : 0 : const String sFormula( aFind.first->second.first->getFormula() );
2115 : 0 : util::SearchOptions aSearchOptions;
2116 : 0 : aSearchOptions.algorithmType = util::SearchAlgorithms_REGEXP;
2117 : 0 : aSearchOptions.searchFlag = 0x00000100;
2118 : 0 : aSearchOptions.searchString = m_aCounterFunction.m_sSearchString;
2119 : 0 : utl::TextSearch aTextSearch(aSearchOptions);
2120 : 0 : xub_StrLen start = 0;
2121 : 0 : xub_StrLen end = sFormula.Len();
2122 : 0 : if ( aTextSearch.SearchFrwrd(sFormula,&start,&end) && start == 0 && end == sFormula.Len()) // counter function found
2123 : : {
2124 : 0 : const uno::Reference< report::XGroup > xGroup(aFind.first->second.second,uno::UNO_QUERY);
2125 : 0 : if ( xGroup.is() )
2126 : : {
2127 : 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
2128 : 0 : sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
2129 : 0 : _Out_sScope = sGroupName;
2130 : : }
2131 : : else
2132 : 0 : _Out_sScope = uno::Reference< report::XReportDefinition >(aFind.first->second.second,uno::UNO_QUERY_THROW)->getName();
2133 : 0 : break;
2134 : 0 : }
2135 : : }
2136 : 0 : ++(aFind.first);
2137 : 0 : }
2138 : 0 : return aFind.first != aFind.second;
2139 : : }
2140 : : // -----------------------------------------------------------------------------
2141 : 0 : void GeometryHandler::impl_createFunction(const ::rtl::OUString& _sFunctionName,const ::rtl::OUString& _sDataField,const DefaultFunction& _aFunction)
2142 : : {
2143 : 0 : if ( m_bNewFunction )
2144 : 0 : removeFunction();
2145 : :
2146 : 0 : const ::rtl::OUString sQuotedFunctionName(lcl_getQuotedFunctionName(_sFunctionName));
2147 : 0 : m_xFunction.set(report::Function::create(m_xContext));
2148 : 0 : m_xFunction->setName( _sFunctionName );
2149 : :
2150 : 0 : const String sPlaceHolder1(RTL_CONSTASCII_USTRINGPARAM("%Column"));
2151 : 0 : const String sPlaceHolder2(RTL_CONSTASCII_USTRINGPARAM("%FunctionName"));
2152 : 0 : String sFormula(_aFunction.m_sFormula);
2153 : 0 : sFormula.SearchAndReplaceAll(sPlaceHolder1,_sDataField);
2154 : 0 : sFormula.SearchAndReplaceAll(sPlaceHolder2,_sFunctionName);
2155 : :
2156 : 0 : m_xFunction->setFormula(sFormula);
2157 : 0 : m_xFunction->setPreEvaluated(_aFunction.m_bPreEvaluated);
2158 : 0 : m_xFunction->setDeepTraversing(_aFunction.m_bDeepTraversing);
2159 : 0 : if ( _aFunction.m_sInitialFormula.IsPresent )
2160 : : {
2161 : 0 : beans::Optional< ::rtl::OUString> aInitialFormula = _aFunction.m_sInitialFormula;
2162 : 0 : String sInitialFormula = aInitialFormula.Value;
2163 : 0 : sInitialFormula.SearchAndReplaceAll(sPlaceHolder1,_sDataField);
2164 : 0 : sInitialFormula.SearchAndReplaceAll(sPlaceHolder2,_sFunctionName);
2165 : 0 : aInitialFormula.Value = sInitialFormula;
2166 : 0 : m_xFunction->setInitialFormula( aInitialFormula );
2167 : : }
2168 : 0 : ::rtl::OUString sNamePostFix;
2169 : 0 : const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostFix);
2170 : 0 : const uno::Reference< container::XIndexContainer> xFunctions(xFunctionsSupplier->getFunctions(),uno::UNO_QUERY_THROW);
2171 : 0 : xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(m_xFunction));
2172 : 0 : m_aFunctionNames.insert(TFunctions::value_type(sQuotedFunctionName,TFunctionPair(m_xFunction,xFunctionsSupplier)));
2173 : 0 : m_bNewFunction = true;
2174 : 0 : }
2175 : : // -----------------------------------------------------------------------------
2176 : 0 : void GeometryHandler::impl_setCounterFunction_throw()
2177 : : {
2178 : 0 : ::rtl::OUString sNamePostFix;
2179 : 0 : fillScope_throw(sNamePostFix);
2180 : 0 : ::rtl::OUString sFunctionName = m_aCounterFunction.m_sName;
2181 : 0 : sFunctionName += sNamePostFix;
2182 : 0 : const ::rtl::OUString sQuotedFunctionName = lcl_getQuotedFunctionName(sFunctionName);
2183 : 0 : ::rtl::OUString sScope;
2184 : 0 : if ( !(!sFunctionName.isEmpty() && m_aFunctionNames.find(sQuotedFunctionName) != m_aFunctionNames.end() && impl_isCounterFunction_throw(sQuotedFunctionName,sScope)) )
2185 : 0 : impl_createFunction(sFunctionName,::rtl::OUString(),m_aCounterFunction);
2186 : :
2187 : 0 : OBlocker aBlocker(m_bIn);
2188 : 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula( uno::makeAny(sQuotedFunctionName))));
2189 : 0 : }
2190 : : // -----------------------------------------------------------------------------
2191 : 0 : sal_uInt32 GeometryHandler::impl_getDataFieldType_throw(const ::rtl::OUString& _sDataField) const
2192 : : {
2193 : 0 : sal_uInt32 nDataFieldType = UNDEF_DATA;
2194 : 0 : ::rtl::OUString sDataField;
2195 : 0 : if ( !_sDataField.isEmpty() )
2196 : 0 : sDataField = _sDataField;
2197 : : else
2198 : : {
2199 : 0 : uno::Any aDataField( m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ) );
2200 : 0 : lcl_convertFormulaTo(aDataField,aDataField);
2201 : 0 : aDataField >>= sDataField;
2202 : : }
2203 : :
2204 : 0 : if ( !sDataField.isEmpty() )
2205 : : {
2206 : 0 : if ( impl_isDataField(sDataField) )
2207 : 0 : nDataFieldType = DATA_OR_FORMULA;
2208 : 0 : else if ( isDefaultFunction(sDataField,sDataField) )
2209 : 0 : nDataFieldType = FUNCTION;
2210 : 0 : else if ( m_aFunctionNames.find(sDataField) != m_aFunctionNames.end() )
2211 : : {
2212 : 0 : nDataFieldType = USER_DEF_FUNCTION;
2213 : 0 : ::rtl::OUString sScope;
2214 : 0 : if ( impl_isCounterFunction_throw(sDataField,sScope) )
2215 : 0 : nDataFieldType = COUNTER;
2216 : : }
2217 : : else
2218 : 0 : nDataFieldType = DATA_OR_FORMULA;
2219 : : }
2220 : 0 : return nDataFieldType;
2221 : : }
2222 : : // -----------------------------------------------------------------------------
2223 : : // XEventListener
2224 : 0 : void SAL_CALL GeometryHandler::disposing(const lang::EventObject& ) throw( uno::RuntimeException )
2225 : : {
2226 : 0 : }
2227 : : // XPropertyChangeListener
2228 : 0 : void SAL_CALL GeometryHandler::propertyChange(const beans::PropertyChangeEvent& /*evt*/) throw(uno::RuntimeException)
2229 : : {
2230 : 0 : ::osl::ResettableMutexGuard aGuard( m_aMutex );
2231 : 0 : if ( !m_bIn )
2232 : : {
2233 : 0 : const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
2234 : 0 : const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
2235 : 0 : const ::rtl::OUString sOldScope = m_sScope;
2236 : 0 : m_sDefaultFunction = m_sScope = ::rtl::OUString();
2237 : 0 : m_nDataFieldType = impl_getDataFieldType_throw();
2238 : 0 : if ( UNDEF_DATA == m_nDataFieldType )
2239 : 0 : m_nDataFieldType = nOldDataFieldType;
2240 : 0 : uno::Any aDataField = m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD );
2241 : 0 : lcl_convertFormulaTo(aDataField,aDataField);
2242 : 0 : ::rtl::OUString sDataField;
2243 : 0 : aDataField >>= sDataField;
2244 : 0 : switch(m_nDataFieldType)
2245 : : {
2246 : : case FUNCTION:
2247 : 0 : isDefaultFunction(sDataField,sDataField,uno::Reference< report::XFunctionsSupplier>(),true);
2248 : 0 : break;
2249 : : case COUNTER:
2250 : 0 : impl_isCounterFunction_throw(sDataField,m_sScope);
2251 : 0 : break;
2252 : : default:
2253 : : ;
2254 : : }
2255 : :
2256 : 0 : resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType);
2257 : 0 : }
2258 : 0 : }
2259 : : //........................................................................
2260 : 0 : } // namespace rptui
2261 : : //........................................................................
2262 : :
2263 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|