bump product version to 5.0.4.1
[LibreOffice.git] / reportdesign / source / ui / inspection / metadata.cxx
blob1cf9fc76907477b924cf3b736ba2daaadd2c2aed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "metadata.hxx"
20 #include <svtools/localresaccess.hxx>
21 #include <com/sun/star/inspection/XPropertyHandler.hpp>
22 #include <comphelper/extract.hxx>
23 #include "helpids.hrc"
24 #include "RptResId.hrc"
25 #include "uistrings.hrc"
27 #include <functional>
28 #include <algorithm>
31 namespace rptui
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star;
39 //= OPropertyInfoImpl
41 struct OPropertyInfoImpl
43 OUString sName;
44 OUString sTranslation;
45 OString sHelpId;
46 sal_Int32 nId;
47 sal_uInt32 nUIFlags;
49 OPropertyInfoImpl(
50 const OUString& rName,
51 sal_Int32 _nId,
52 const OUString& aTranslation,
53 const OString& _sHelpId,
54 sal_uInt32 _nUIFlags);
58 OPropertyInfoImpl::OPropertyInfoImpl(const OUString& _rName, sal_Int32 _nId,
59 const OUString& aString, const OString& sHid, sal_uInt32 _nUIFlags)
60 :sName(_rName)
61 ,sTranslation(aString)
62 ,sHelpId(sHid)
63 ,nId(_nId)
64 ,nUIFlags(_nUIFlags)
69 // Vergleichen von PropertyInfo
70 struct PropertyInfoLessByName : public ::std::binary_function< OPropertyInfoImpl, OPropertyInfoImpl, bool >
72 bool operator()( const OPropertyInfoImpl& _lhs, const OPropertyInfoImpl& _rhs )
74 return _lhs.sName < _rhs.sName;
79 //= OPropertyInfoService
81 #define DEF_INFO( ident, uinameres, helpid, flags ) \
82 OPropertyInfoImpl( PROPERTY_##ident, PROPERTY_ID_##ident, \
83 OUString( ModuleRes( RID_STR_##uinameres ) ), HID_RPT_PROP_##helpid, flags )
85 #define DEF_INFO_1( ident, uinameres, helpid, flag1 ) \
86 DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 )
88 #define DEF_INFO_2( ident, uinameres, helpid, flag1, flag2 ) \
89 DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 )
91 sal_uInt16 OPropertyInfoService::s_nCount = 0;
92 OPropertyInfoImpl* OPropertyInfoService::s_pPropertyInfos = NULL;
94 const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo()
96 if ( s_pPropertyInfos )
97 return s_pPropertyInfos;
99 OModuleClient aResourceAccess;
100 // this ensures that we have our resource file loaded
102 static OPropertyInfoImpl aPropertyInfos[] =
105 DEF_INFO_?( propname and id, resoure id, help id, flags ),
107 DEF_INFO_1( FORCENEWPAGE, FORCENEWPAGE, FORCENEWPAGE, COMPOSEABLE )
108 ,DEF_INFO_1( NEWROWORCOL, NEWROWORCOL, NEWROWORCOL, COMPOSEABLE )
109 ,DEF_INFO_1( KEEPTOGETHER, KEEPTOGETHER, KEEPTOGETHER, COMPOSEABLE )
110 ,DEF_INFO_1( CANGROW, CANGROW, CANGROW, COMPOSEABLE )
111 ,DEF_INFO_1( CANSHRINK, CANSHRINK, CANSHRINK, COMPOSEABLE )
112 ,DEF_INFO_1( REPEATSECTION, REPEATSECTION, REPEATSECTION, COMPOSEABLE )
113 ,DEF_INFO_1( PRINTREPEATEDVALUES, PRINTREPEATEDVALUES, PRINTREPEATEDVALUES, COMPOSEABLE )
114 ,DEF_INFO_1( CONDITIONALPRINTEXPRESSION, CONDITIONALPRINTEXPRESSION, CONDITIONALPRINTEXPRESSION, COMPOSEABLE )
115 ,DEF_INFO_1( STARTNEWCOLUMN, STARTNEWCOLUMN, STARTNEWCOLUMN, COMPOSEABLE )
116 ,DEF_INFO_1( RESETPAGENUMBER, RESETPAGENUMBER, RESETPAGENUMBER, COMPOSEABLE )
117 ,DEF_INFO_1( PRINTWHENGROUPCHANGE, PRINTWHENGROUPCHANGE, PRINTWHENGROUPCHANGE, COMPOSEABLE )
118 ,DEF_INFO_1( VISIBLE, VISIBLE, VISIBLE, COMPOSEABLE )
119 ,DEF_INFO_1( GROUPKEEPTOGETHER, GROUPKEEPTOGETHER, GROUPKEEPTOGETHER, COMPOSEABLE )
120 ,DEF_INFO_1( PAGEHEADEROPTION, PAGEHEADEROPTION, PAGEHEADEROPTION, COMPOSEABLE )
121 ,DEF_INFO_1( PAGEFOOTEROPTION, PAGEFOOTEROPTION, PAGEFOOTEROPTION, COMPOSEABLE )
122 ,DEF_INFO_1( POSITIONX, POSITIONX, RPT_POSITIONX, COMPOSEABLE )
123 ,DEF_INFO_1( POSITIONY, POSITIONY, RPT_POSITIONY, COMPOSEABLE )
124 ,DEF_INFO_1( WIDTH, WIDTH, RPT_WIDTH, COMPOSEABLE )
125 ,DEF_INFO_1( HEIGHT, HEIGHT, RPT_HEIGHT, COMPOSEABLE )
126 ,DEF_INFO_1( FONT, FONT, RPT_FONT, COMPOSEABLE )
127 ,DEF_INFO_1( PREEVALUATED, PREEVALUATED, PREEVALUATED, COMPOSEABLE )
128 ,DEF_INFO_1( DEEPTRAVERSING, DEEPTRAVERSING, DEEPTRAVERSING, COMPOSEABLE )
129 ,DEF_INFO_1( FORMULA, FORMULA, FORMULA, COMPOSEABLE )
130 ,DEF_INFO_1( INITIALFORMULA, INITIALFORMULA, INITIALFORMULA, COMPOSEABLE )
131 ,DEF_INFO_2( TYPE, TYPE, TYPE, COMPOSEABLE,DATA_PROPERTY )
132 ,DEF_INFO_2( DATAFIELD, DATAFIELD, DATAFIELD, COMPOSEABLE,DATA_PROPERTY )
133 ,DEF_INFO_2( FORMULALIST, FORMULALIST, FORMULALIST, COMPOSEABLE,DATA_PROPERTY )
134 ,DEF_INFO_2( SCOPE, SCOPE, SCOPE, COMPOSEABLE,DATA_PROPERTY )
135 ,DEF_INFO_1( PRESERVEIRI, PRESERVEIRI, PRESERVEIRI, COMPOSEABLE )
136 ,DEF_INFO_1( BACKCOLOR, BACKCOLOR, BACKCOLOR, COMPOSEABLE )
137 ,DEF_INFO_1( CONTROLBACKGROUND, BACKCOLOR, BACKCOLOR, COMPOSEABLE )
138 ,DEF_INFO_1( BACKTRANSPARENT, BACKTRANSPARENT, BACKTRANSPARENT, COMPOSEABLE )
139 ,DEF_INFO_1( CONTROLBACKGROUNDTRANSPARENT, CONTROLBACKGROUNDTRANSPARENT,
140 CONTROLBACKGROUNDTRANSPARENT, COMPOSEABLE )
141 ,DEF_INFO_1( CHARTTYPE, CHARTTYPE, CHARTTYPE, COMPOSEABLE )
142 ,DEF_INFO_1( PREVIEW_COUNT, PREVIEW_COUNT, PREVIEW_COUNT, COMPOSEABLE )
143 ,DEF_INFO_2( MASTERFIELDS, MASTERFIELDS, MASTERFIELDS, COMPOSEABLE,DATA_PROPERTY )
144 ,DEF_INFO_2( DETAILFIELDS, DETAILFIELDS, DETAILFIELDS, COMPOSEABLE,DATA_PROPERTY)
145 ,DEF_INFO_1( AREA, AREA, AREA, COMPOSEABLE )
146 ,DEF_INFO_2( MIMETYPE, MIMETYPE, MIMETYPE, COMPOSEABLE,DATA_PROPERTY )
147 ,DEF_INFO_1( PARAADJUST, PARAADJUST, PARAADJUST, COMPOSEABLE )
148 ,DEF_INFO_1( VERTICALALIGN, VERTICALALIGN, VERTICALALIGN, COMPOSEABLE )
151 s_pPropertyInfos = aPropertyInfos;
152 s_nCount = SAL_N_ELEMENTS(aPropertyInfos);
153 ::std::sort( aPropertyInfos, aPropertyInfos + SAL_N_ELEMENTS(aPropertyInfos), PropertyInfoLessByName() );
155 return s_pPropertyInfos;
159 sal_Int32 OPropertyInfoService::getPropertyId(const OUString& _rName)
161 const OPropertyInfoImpl* pInfo = getPropertyInfo(_rName);
162 return pInfo ? pInfo->nId : -1;
166 OUString OPropertyInfoService::getPropertyTranslation(sal_Int32 _nId)
168 const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
169 return (pInfo) ? pInfo->sTranslation : OUString();
173 OString OPropertyInfoService::getPropertyHelpId(sal_Int32 _nId)
175 const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
176 return (pInfo) ? pInfo->sHelpId : OString();
180 sal_uInt32 OPropertyInfoService::getPropertyUIFlags(sal_Int32 _nId)
182 const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
183 return (pInfo) ? pInfo->nUIFlags : 0;
187 const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(const OUString& _rName)
189 // intialisierung
190 if(!s_pPropertyInfos)
191 getPropertyInfo();
192 OPropertyInfoImpl aSearch(_rName, 0L, OUString(), "", 0);
194 const OPropertyInfoImpl* pPropInfo = ::std::lower_bound(
195 s_pPropertyInfos, s_pPropertyInfos + s_nCount, aSearch, PropertyInfoLessByName() );
197 if ( ( pPropInfo < s_pPropertyInfos + s_nCount ) && pPropInfo->sName == _rName )
198 return pPropInfo;
200 return NULL;
205 const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(sal_Int32 _nId)
207 // intialisierung
208 if(!s_pPropertyInfos)
209 getPropertyInfo();
211 // TODO: a real structure which allows quick access by name as well as by id
212 for (sal_uInt16 i = 0; i < s_nCount; i++)
213 if (s_pPropertyInfos[i].nId == _nId)
214 return &s_pPropertyInfos[i];
216 return NULL;
220 bool OPropertyInfoService::isComposable( const OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxFormComponentHandler )
222 sal_Int32 nId = getPropertyId( _rPropertyName );
223 if ( nId != -1 )
225 sal_uInt32 nFlags = getPropertyUIFlags( nId );
226 return ( nFlags & PROP_FLAG_COMPOSEABLE ) != 0;
229 return _rxFormComponentHandler->isComposable( _rPropertyName );
233 void OPropertyInfoService::getExcludeProperties(::std::vector< beans::Property >& _rExcludeProperties,const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _xFormComponentHandler)
235 uno::Sequence< beans::Property > aProps = _xFormComponentHandler->getSupportedProperties();
236 static const OUString pExcludeProperties[] =
238 OUString("Enabled"),
239 OUString("Printable"),
240 OUString("WordBreak"),
241 OUString("MultiLine"),
242 OUString("Tag"),
243 OUString("HelpText"),
244 OUString("HelpURL"),
245 OUString("MaxTextLen"),
246 OUString("ReadOnly"),
247 OUString("Tabstop"),
248 OUString("TabIndex"),
249 OUString("ValueMin"),
250 OUString("ValueMax"),
251 OUString("Spin"),
252 OUString("SpinValue"),
253 OUString("SpinValueMin"),
254 OUString("SpinValueMax"),
255 OUString("DefaultSpinValue"),
256 OUString("SpinIncrement"),
257 OUString("Repeat"),
258 OUString("RepeatDelay"),
259 OUString("ControlLabel"), /// TODO: has to be checked
260 OUString("LabelControl"),
261 OUString("Title"), // comment this out if you want to have title feature for charts
262 OUString(PROPERTY_MAXTEXTLEN),
263 OUString(PROPERTY_EFFECTIVEDEFAULT),
264 OUString(PROPERTY_EFFECTIVEMAX),
265 OUString(PROPERTY_EFFECTIVEMIN),
266 OUString("HideInactiveSelection"),
267 OUString("SubmitAction"),
268 OUString("InputRequired"),
269 OUString("VerticalAlign"),
270 OUString(PROPERTY_ALIGN),
271 OUString(PROPERTY_EMPTY_IS_NULL),
272 OUString(PROPERTY_FILTERPROPOSAL)
273 ,OUString(PROPERTY_POSITIONX)
274 ,OUString(PROPERTY_POSITIONY)
275 ,OUString(PROPERTY_WIDTH)
276 ,OUString(PROPERTY_HEIGHT)
277 ,OUString(PROPERTY_FONT)
278 ,OUString(PROPERTY_LABEL)
279 ,OUString(PROPERTY_LINECOLOR)
280 ,OUString(PROPERTY_BORDER)
281 ,OUString(PROPERTY_BORDERCOLOR)
282 ,OUString(PROPERTY_BACKTRANSPARENT)
283 ,OUString(PROPERTY_CONTROLBACKGROUND)
284 ,OUString(PROPERTY_BACKGROUNDCOLOR)
285 ,OUString(PROPERTY_CONTROLBACKGROUNDTRANSPARENT)
286 ,OUString(PROPERTY_FORMULALIST)
287 ,OUString(PROPERTY_SCOPE)
288 ,OUString(PROPERTY_TYPE)
289 ,OUString(PROPERTY_DATASOURCENAME)
290 ,OUString(PROPERTY_VERTICALALIGN)
293 beans::Property* pPropsIter = aProps.getArray();
294 beans::Property* pPropsEnd = pPropsIter + aProps.getLength();
295 for (; pPropsIter != pPropsEnd; ++pPropsIter)
297 size_t nPos = 0;
298 for (; nPos < sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) && pExcludeProperties[nPos] != pPropsIter->Name;++nPos )
300 if ( nPos == sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) )
301 _rExcludeProperties.push_back(*pPropsIter);
307 } // namespace pcr
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */