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