LibreOffice Module reportdesign (master)  1
metadata.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 #include <metadata.hxx>
20 #include <com/sun/star/inspection/XPropertyHandler.hpp>
21 #include <core_resource.hxx>
22 #include <helpids.h>
23 #include <strings.hrc>
24 #include <strings.hxx>
25 
26 #include <algorithm>
27 #include <string_view>
28 
29 namespace rptui
30 {
31 
32 
33  using namespace ::com::sun::star::uno;
34  using namespace ::com::sun::star;
35 
36 
37  //= OPropertyInfoImpl
38 
40  {
41  OUString sName;
42  OUString sTranslation;
43  OString sHelpId;
44  sal_Int32 nId;
46 
48  const OUString& rName,
49  sal_Int32 _nId,
50  const OUString& aTranslation,
51  const OString& _sHelpId,
52  PropUIFlags _nUIFlags);
53  };
54 
55 
56  OPropertyInfoImpl::OPropertyInfoImpl(const OUString& _rName, sal_Int32 _nId,
57  const OUString& aString, const OString& sHid, PropUIFlags _nUIFlags)
58  :sName(_rName)
59  ,sTranslation(aString)
60  ,sHelpId(sHid)
61  ,nId(_nId)
62  ,nUIFlags(_nUIFlags)
63  {
64  }
65 
66  namespace {
67 
68  // compare PropertyInfo
69  struct PropertyInfoLessByName
70  {
71  bool operator()( const OPropertyInfoImpl& _lhs, const OPropertyInfoImpl& _rhs )
72  {
73  return _lhs.sName < _rhs.sName;
74  }
75  };
76 
77  }
78 
79  //= OPropertyInfoService
80 
81  sal_uInt16 OPropertyInfoService::s_nCount = 0;
82  OPropertyInfoImpl* OPropertyInfoService::s_pPropertyInfos = nullptr;
83 
85  {
86  if ( s_pPropertyInfos )
87  return s_pPropertyInfos;
88 
89  static OPropertyInfoImpl aPropertyInfos[] =
90  {
135  };
136 
137  s_pPropertyInfos = aPropertyInfos;
138  s_nCount = SAL_N_ELEMENTS(aPropertyInfos);
139  ::std::sort( aPropertyInfos, aPropertyInfos + SAL_N_ELEMENTS(aPropertyInfos), PropertyInfoLessByName() );
140 
141  return s_pPropertyInfos;
142  }
143 
144 
145  sal_Int32 OPropertyInfoService::getPropertyId(const OUString& _rName)
146  {
147  const OPropertyInfoImpl* pInfo = getPropertyInfo(_rName);
148  return pInfo ? pInfo->nId : -1;
149  }
150 
151 
153  {
154  const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
155  return pInfo ? pInfo->sTranslation : OUString();
156  }
157 
158 
160  {
161  const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
162  return pInfo ? pInfo->sHelpId : OString();
163  }
164 
165 
167  {
168  const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
169  return pInfo ? pInfo->nUIFlags : PropUIFlags::NONE;
170  }
171 
172 
174  {
175  // initialization
176  if(!s_pPropertyInfos)
177  getPropertyInfo();
178  OPropertyInfoImpl aSearch(_rName, 0, OUString(), "", PropUIFlags::NONE);
179 
180  const OPropertyInfoImpl* pPropInfo = ::std::lower_bound(
181  s_pPropertyInfos, s_pPropertyInfos + s_nCount, aSearch, PropertyInfoLessByName() );
182 
183  if ( ( pPropInfo < s_pPropertyInfos + s_nCount ) && pPropInfo->sName == _rName )
184  return pPropInfo;
185 
186  return nullptr;
187  }
188 
189 
191  {
192  // initialization
193  if(!s_pPropertyInfos)
194  getPropertyInfo();
195 
196  // TODO: a real structure which allows quick access by name as well as by id
197  for (sal_uInt16 i = 0; i < s_nCount; i++)
198  if (s_pPropertyInfos[i].nId == _nId)
199  return &s_pPropertyInfos[i];
200 
201  return nullptr;
202  }
203 
204 
205  bool OPropertyInfoService::isComposable( const OUString& _rPropertyName, const css::uno::Reference< css::inspection::XPropertyHandler >& _rxFormComponentHandler )
206  {
207  sal_Int32 nId = getPropertyId( _rPropertyName );
208  if ( nId != -1 )
209  {
210  PropUIFlags nFlags = getPropertyUIFlags( nId );
211  return bool( nFlags & PropUIFlags::Composeable );
212  }
213 
214  return _rxFormComponentHandler->isComposable( _rPropertyName );
215  }
216 
217 
218  void OPropertyInfoService::getExcludeProperties(::std::vector< beans::Property >& _rExcludeProperties,const css::uno::Reference< css::inspection::XPropertyHandler >& _xFormComponentHandler)
219  {
220  const uno::Sequence< beans::Property > aProps = _xFormComponentHandler->getSupportedProperties();
221  static const std::u16string_view pExcludeProperties[] =
222  {
223  u"Enabled",
224  u"Printable",
225  u"WordBreak",
226  u"MultiLine",
227  u"Tag",
228  u"HelpText",
229  u"HelpURL",
230  u"MaxTextLen",
231  u"ReadOnly",
232  u"Tabstop",
233  u"TabIndex",
234  u"ValueMin",
235  u"ValueMax",
236  u"Spin",
237  u"SpinValue",
238  u"SpinValueMin",
239  u"SpinValueMax",
240  u"DefaultSpinValue",
241  u"SpinIncrement",
242  u"Repeat",
243  u"RepeatDelay",
244  u"ControlLabel",
245  u"LabelControl",
246  u"Title", // comment this out if you want to have title feature for charts
251  u"HideInactiveSelection",
252  u"SubmitAction",
253  u"InputRequired",
254  u"VerticalAlign",
255  u"" PROPERTY_ALIGN,
258  ,u"" PROPERTY_POSITIONX
259  ,u"" PROPERTY_POSITIONY
260  ,u"" PROPERTY_WIDTH
261  ,u"" PROPERTY_HEIGHT
262  ,u"" PROPERTY_AUTOGROW
263  ,u"" PROPERTY_FONT
264  ,u"" PROPERTY_LABEL
265  ,u"" PROPERTY_LINECOLOR
266  ,u"" PROPERTY_BORDER
273  ,u"" PROPERTY_SCOPE
274  ,u"" PROPERTY_TYPE
277  };
278 
279  for (beans::Property const & prop : aProps)
280  {
281  size_t nPos = 0;
282  for (; nPos < SAL_N_ELEMENTS(pExcludeProperties) && pExcludeProperties[nPos] != prop.Name; ++nPos )
283  ;
284  if ( nPos == SAL_N_ELEMENTS(pExcludeProperties) )
285  _rExcludeProperties.push_back(prop);
286  }
287  }
288 
289 
290 } // namespace pcr
291 
292 
293 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OStringLiteral HID_RPT_PROP_PAGEHEADEROPTION
Definition: helpids.h:63
#define PROPERTY_MASTERFIELDS
Definition: strings.hxx:56
#define PROPERTY_DEEPTRAVERSING
Definition: strings.hxx:192
static OUString getPropertyTranslation(sal_Int32 _nId)
Definition: metadata.cxx:152
#define PROPERTY_LABEL
Definition: strings.hxx:89
static OString getPropertyHelpId(sal_Int32 _nId)
Definition: metadata.cxx:159
#define PROPERTY_ID_CANSHRINK
Definition: metadata.hxx:99
constexpr OStringLiteral HID_RPT_PROP_PARAADJUST
Definition: helpids.h:56
#define PROPERTY_ID_CONTROLBACKGROUND
Definition: metadata.hxx:126
#define PROPERTY_AUTOGROW
Definition: strings.hxx:76
#define PROPERTY_ID_AREA
Definition: metadata.hxx:135
constexpr OStringLiteral HID_RPT_PROP_PAGEFOOTEROPTION
Definition: helpids.h:64
#define PROPERTY_DETAILFIELDS
Definition: strings.hxx:57
PropUIFlags
Definition: metadata.hxx:30
#define PROPERTY_ID_BACKTRANSPARENT
Definition: metadata.hxx:123
#define PROPERTY_ID_FORMULA
Definition: metadata.hxx:111
#define PROPERTY_PREVIEW_COUNT
Definition: strings.hxx:264
#define PROPERTY_FORMULALIST
Definition: strings.hxx:261
#define PROPERTY_VISIBLE
Definition: strings.hxx:35
#define PROPERTY_PRESERVEIRI
Definition: strings.hxx:213
#define PROPERTY_PRINTREPEATEDVALUES
Definition: strings.hxx:107
#define PROPERTY_ID_PAGEHEADEROPTION
Definition: metadata.hxx:104
#define PROPERTY_ID_MIMETYPE
Definition: metadata.hxx:136
#define PROPERTY_FONT
Definition: strings.hxx:121
constexpr OStringLiteral HID_RPT_PROP_PRINTREPEATEDVALUES
Definition: helpids.h:51
sal_Int16 nId
constexpr OStringLiteral HID_RPT_PROP_RPT_POSITIONX
Definition: helpids.h:68
constexpr OStringLiteral HID_RPT_PROP_PREEVALUATED
Definition: helpids.h:74
#define PROPERTY_POSITIONY
Definition: strings.hxx:75
#define PROPERTY_CANSHRINK
Definition: strings.hxx:46
constexpr OStringLiteral HID_RPT_PROP_CANGROW
Definition: helpids.h:39
#define PROPERTY_ID_STARTNEWCOLUMN
Definition: metadata.hxx:116
#define PROPERTY_ID_DETAILFIELDS
Definition: metadata.hxx:133
constexpr OStringLiteral HID_RPT_PROP_TYPE
Definition: helpids.h:44
#define PROPERTY_PRINTWHENGROUPCHANGE
Definition: strings.hxx:111
constexpr OStringLiteral HID_RPT_PROP_BACKCOLOR
Definition: helpids.h:67
#define PROPERTY_WIDTH
Definition: strings.hxx:73
#define PROPERTY_ID_MASTERFIELDS
Definition: metadata.hxx:132
constexpr OStringLiteral HID_RPT_PROP_PRESERVEIRI
Definition: helpids.h:79
#define PROPERTY_DATASOURCENAME
Definition: strings.hxx:188
#define PROPERTY_AREA
Definition: strings.hxx:266
#define PROPERTY_RESETPAGENUMBER
Definition: strings.hxx:110
#define PROPERTY_PAGEFOOTEROPTION
Definition: strings.hxx:65
#define PROPERTY_ID_PARAADJUST
Definition: metadata.hxx:139
#define PROPERTY_REPEATSECTION
Definition: strings.hxx:47
#define PROPERTY_NEWROWORCOL
Definition: strings.hxx:43
constexpr OStringLiteral HID_RPT_PROP_RPT_HEIGHT
Definition: helpids.h:71
#define PROPERTY_DATAFIELD
Definition: strings.hxx:78
#define PROPERTY_GROUPKEEPTOGETHER
Definition: strings.hxx:63
constexpr OStringLiteral HID_RPT_PROP_DEEPTRAVERSING
Definition: helpids.h:73
constexpr OStringLiteral HID_RPT_PROP_CONDITIONALPRINTEXPRESSION
Definition: helpids.h:52
constexpr OStringLiteral HID_RPT_PROP_RPT_WIDTH
Definition: helpids.h:70
#define PROPERTY_BORDERCOLOR
Definition: strings.hxx:99
#define PROPERTY_ID_PREEVALUATED
Definition: metadata.hxx:121
static sal_Int32 getPropertyId(const OUString &_rName)
Definition: metadata.cxx:145
#define PROPERTY_ID_VISIBLE
Definition: metadata.hxx:102
#define PROPERTY_TYPE
Definition: strings.hxx:211
#define PROPERTY_ID_FORMULALIST
Definition: metadata.hxx:128
#define PROPERTY_STARTNEWCOLUMN
Definition: strings.hxx:109
#define PROPERTY_CONTROLBACKGROUNDTRANSPARENT
Definition: strings.hxx:41
#define PROPERTY_VERTICALALIGN
Definition: strings.hxx:86
#define PROPERTY_ID_REPEATSECTION
Definition: metadata.hxx:100
#define PROPERTY_ID_RESETPAGENUMBER
Definition: metadata.hxx:130
const char * sName
constexpr OStringLiteral HID_RPT_PROP_STARTNEWCOLUMN
Definition: helpids.h:54
static bool isComposable(const OUString &_rPropertyName, const css::uno::Reference< css::inspection::XPropertyHandler > &_xFormComponentHandler)
Definition: metadata.cxx:205
#define SAL_N_ELEMENTS(arr)
constexpr OStringLiteral HID_RPT_PROP_NEWROWORCOL
Definition: helpids.h:37
OPropertyInfoImpl(const OUString &rName, sal_Int32 _nId, const OUString &aTranslation, const OString &_sHelpId, PropUIFlags _nUIFlags)
Definition: metadata.cxx:56
constexpr OStringLiteral HID_RPT_PROP_CONTROLBACKGROUNDTRANSPARENT
Definition: helpids.h:81
#define PROPERTY_CONTROLBACKGROUND
Definition: strings.hxx:40
constexpr OStringLiteral HID_RPT_PROP_RPT_AUTOGROW
Definition: helpids.h:72
#define PROPERTY_EFFECTIVEDEFAULT
Definition: strings.hxx:90
OUString RptResId(TranslateId aId)
#define PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
Definition: metadata.hxx:124
static sal_uInt16 s_nCount
Definition: metadata.hxx:75
constexpr OStringLiteral HID_RPT_PROP_FORMULA
Definition: helpids.h:76
int i
constexpr OStringLiteral HID_RPT_PROP_DETAILFIELDS
Definition: helpids.h:46
constexpr OStringLiteral HID_RPT_PROP_DATAFIELD
Definition: helpids.h:66
#define PROPERTY_CANGROW
Definition: strings.hxx:45
constexpr OStringLiteral HID_RPT_PROP_CHARTTYPE
Definition: helpids.h:58
constexpr OStringLiteral HID_RPT_PROP_VERTICALALIGN
Definition: helpids.h:53
constexpr OStringLiteral HID_RPT_PROP_GROUPKEEPTOGETHER
Definition: helpids.h:62
constexpr OStringLiteral HID_RPT_PROP_FORMULALIST
Definition: helpids.h:42
#define PROPERTY_ID_FORCENEWPAGE
Definition: metadata.hxx:95
#define PROPERTY_ID_PRINTWHENGROUPCHANGE
Definition: metadata.hxx:114
#define PROPERTY_FORMULA
Definition: strings.hxx:189
#define PROPERTY_BACKTRANSPARENT
Definition: strings.hxx:39
float u
#define PROPERTY_ALIGN
Definition: strings.hxx:210
#define PROPERTY_ID_CONDITIONALPRINTEXPRESSION
Definition: metadata.hxx:112
#define PROPERTY_SCOPE
Definition: strings.hxx:262
#define PROPERTY_CHARTTYPE
Definition: strings.hxx:263
#define PROPERTY_PARAADJUST
Definition: strings.hxx:79
#define PROPERTY_EFFECTIVEMAX
Definition: strings.hxx:91
#define PROPERTY_EFFECTIVEMIN
Definition: strings.hxx:92
static const OPropertyInfoImpl * getPropertyInfo()
Definition: metadata.cxx:84
#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:218
#define PROPERTY_POSITIONX
Definition: strings.hxx:74
#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_MAXTEXTLEN
Definition: strings.hxx:94
#define PROPERTY_MIMETYPE
Definition: strings.hxx:193
#define PROPERTY_ID_PRESERVEIRI
Definition: metadata.hxx:101
constexpr OStringLiteral HID_RPT_PROP_RPT_POSITIONY
Definition: helpids.h:69
#define PROPERTY_ID_PRINTREPEATEDVALUES
Definition: metadata.hxx:113
#define PROPERTY_ID_TYPE
Definition: metadata.hxx:117
#define PROPERTY_ID_POSITIONX
Definition: metadata.hxx:106
#define PROPERTY_ID_AUTOGROW
Definition: metadata.hxx:110
#define PROPERTY_LINECOLOR
Definition: strings.hxx:218
constexpr OStringLiteral HID_RPT_PROP_INITIALFORMULA
Definition: helpids.h:77
constexpr OStringLiteral HID_RPT_PROP_AREA
Definition: helpids.h:47
#define PROPERTY_FORCENEWPAGE
Definition: strings.hxx:42
constexpr OStringLiteral HID_RPT_PROP_MIMETYPE
Definition: helpids.h:48
#define PROPERTY_HEIGHT
Definition: strings.hxx:37
constexpr OStringLiteral HID_RPT_PROP_SCOPE
Definition: helpids.h:43
constexpr OStringLiteral HID_RPT_PROP_KEEPTOGETHER
Definition: helpids.h:38
constexpr OStringLiteral HID_RPT_PROP_MASTERFIELDS
Definition: helpids.h:45
constexpr OStringLiteral HID_RPT_PROP_RPT_FONT
Definition: helpids.h:78
#define PROPERTY_ID_WIDTH
Definition: xmlColumn.cxx:37
#define PROPERTY_ID_DEEPTRAVERSING
Definition: metadata.hxx:120
static PropUIFlags getPropertyUIFlags(sal_Int32 _nId)
Definition: metadata.cxx:166
#define PROPERTY_PREEVALUATED
Definition: strings.hxx:191
#define PROPERTY_ID_POSITIONY
Definition: metadata.hxx:107
#define PROPERTY_PAGEHEADEROPTION
Definition: strings.hxx:64
constexpr OStringLiteral HID_RPT_PROP_FORCENEWPAGE
Definition: helpids.h:36
constexpr OStringLiteral HID_RPT_PROP_PRINTWHENGROUPCHANGE
Definition: helpids.h:57
#define PROPERTY_ID_FONT
Definition: metadata.hxx:138
constexpr OStringLiteral HID_RPT_PROP_BACKTRANSPARENT
Definition: helpids.h:80
static OPropertyInfoImpl * s_pPropertyInfos
Definition: metadata.hxx:76
#define PROPERTY_BACKCOLOR
Definition: strings.hxx:38
#define PROPERTY_CONDITIONALPRINTEXPRESSION
Definition: strings.hxx:108
#define PROPERTY_FILTERPROPOSAL
Definition: strings.hxx:256
#define PROPERTY_ID_VERTICALALIGN
Definition: metadata.hxx:140
#define PROPERTY_ID_HEIGHT
Definition: xmlColumn.cxx:38
constexpr OStringLiteral HID_RPT_PROP_RESETPAGENUMBER
Definition: helpids.h:55
#define PROPERTY_EMPTY_IS_NULL
Definition: strings.hxx:255
#define PROPERTY_ID_INITIALFORMULA
Definition: metadata.hxx:115
#define PROPERTY_KEEPTOGETHER
Definition: strings.hxx:44
#define PROPERTY_ID_PAGEFOOTEROPTION
Definition: metadata.hxx:105
#define PROPERTY_BORDER
Definition: strings.hxx:98
constexpr OStringLiteral HID_RPT_PROP_VISIBLE
Definition: helpids.h:61
#define PROPERTY_ID_PREVIEW_COUNT
Definition: metadata.hxx:134
#define PROPERTY_ID_SCOPE
Definition: metadata.hxx:129
constexpr OStringLiteral HID_RPT_PROP_REPEATSECTION
Definition: helpids.h:41
#define PROPERTY_INITIALFORMULA
Definition: strings.hxx:190
sal_uInt16 nPos
#define PROPERTY_ID_CHARTTYPE
Definition: metadata.hxx:131
constexpr OStringLiteral HID_RPT_PROP_CANSHRINK
Definition: helpids.h:40
#define PROPERTY_BACKGROUNDCOLOR
Definition: strings.hxx:194
#define PROPERTY_ID_CANGROW
Definition: metadata.hxx:98
#define PROPERTY_ID_KEEPTOGETHER
Definition: metadata.hxx:97
constexpr OStringLiteral HID_RPT_PROP_PREVIEW_COUNT
Definition: helpids.h:65