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