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