Line data Source code
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 <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"
26 :
27 : #include <functional>
28 : #include <algorithm>
29 :
30 :
31 : namespace rptui
32 : {
33 :
34 :
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star;
37 :
38 :
39 : //= OPropertyInfoImpl
40 :
41 0 : struct OPropertyInfoImpl
42 : {
43 : OUString sName;
44 : OUString sTranslation;
45 : OString sHelpId;
46 : sal_Int32 nId;
47 : sal_uInt32 nUIFlags;
48 :
49 : OPropertyInfoImpl(
50 : const OUString& rName,
51 : sal_Int32 _nId,
52 : const OUString& aTranslation,
53 : const OString& _sHelpId,
54 : sal_uInt32 _nUIFlags);
55 : };
56 :
57 :
58 0 : 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 0 : ,nUIFlags(_nUIFlags)
65 : {
66 0 : }
67 :
68 :
69 : // Vergleichen von PropertyInfo
70 : struct PropertyInfoLessByName : public ::std::binary_function< OPropertyInfoImpl, OPropertyInfoImpl, bool >
71 : {
72 0 : bool operator()( const OPropertyInfoImpl& _lhs, const OPropertyInfoImpl& _rhs )
73 : {
74 0 : return _lhs.sName < _rhs.sName;
75 : }
76 : };
77 :
78 :
79 : //= OPropertyInfoService
80 :
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 )
84 :
85 : #define DEF_INFO_1( ident, uinameres, helpid, flag1 ) \
86 : DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 )
87 :
88 : #define DEF_INFO_2( ident, uinameres, helpid, flag1, flag2 ) \
89 : DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 )
90 :
91 : sal_uInt16 OPropertyInfoService::s_nCount = 0;
92 : OPropertyInfoImpl* OPropertyInfoService::s_pPropertyInfos = NULL;
93 :
94 0 : const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo()
95 : {
96 0 : if ( s_pPropertyInfos )
97 0 : return s_pPropertyInfos;
98 :
99 0 : OModuleClient aResourceAccess;
100 : // this ensures that we have our resource file loaded
101 :
102 : static OPropertyInfoImpl aPropertyInfos[] =
103 : {
104 : /*
105 : DEF_INFO_?( propname and id, resoure id, help id, flags ),
106 : */
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 )
149 0 : };
150 :
151 0 : s_pPropertyInfos = aPropertyInfos;
152 0 : s_nCount = SAL_N_ELEMENTS(aPropertyInfos);
153 0 : ::std::sort( aPropertyInfos, aPropertyInfos + SAL_N_ELEMENTS(aPropertyInfos), PropertyInfoLessByName() );
154 :
155 0 : return s_pPropertyInfos;
156 : }
157 :
158 :
159 0 : sal_Int32 OPropertyInfoService::getPropertyId(const OUString& _rName)
160 : {
161 0 : const OPropertyInfoImpl* pInfo = getPropertyInfo(_rName);
162 0 : return pInfo ? pInfo->nId : -1;
163 : }
164 :
165 :
166 0 : OUString OPropertyInfoService::getPropertyTranslation(sal_Int32 _nId)
167 : {
168 0 : const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
169 0 : return (pInfo) ? pInfo->sTranslation : OUString();
170 : }
171 :
172 :
173 0 : OString OPropertyInfoService::getPropertyHelpId(sal_Int32 _nId)
174 : {
175 0 : const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
176 0 : return (pInfo) ? pInfo->sHelpId : OString();
177 : }
178 :
179 :
180 0 : sal_uInt32 OPropertyInfoService::getPropertyUIFlags(sal_Int32 _nId)
181 : {
182 0 : const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
183 0 : return (pInfo) ? pInfo->nUIFlags : 0;
184 : }
185 :
186 :
187 0 : const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(const OUString& _rName)
188 : {
189 : // intialisierung
190 0 : if(!s_pPropertyInfos)
191 0 : getPropertyInfo();
192 0 : OPropertyInfoImpl aSearch(_rName, 0L, OUString(), "", 0);
193 :
194 : const OPropertyInfoImpl* pPropInfo = ::std::lower_bound(
195 0 : s_pPropertyInfos, s_pPropertyInfos + s_nCount, aSearch, PropertyInfoLessByName() );
196 :
197 0 : if ( ( pPropInfo < s_pPropertyInfos + s_nCount ) && pPropInfo->sName == _rName )
198 0 : return pPropInfo;
199 :
200 0 : return NULL;
201 : }
202 :
203 :
204 :
205 0 : const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(sal_Int32 _nId)
206 : {
207 : // intialisierung
208 0 : if(!s_pPropertyInfos)
209 0 : getPropertyInfo();
210 :
211 : // TODO: a real structure which allows quick access by name as well as by id
212 0 : for (sal_uInt16 i = 0; i < s_nCount; i++)
213 0 : if (s_pPropertyInfos[i].nId == _nId)
214 0 : return &s_pPropertyInfos[i];
215 :
216 0 : return NULL;
217 : }
218 :
219 :
220 0 : bool OPropertyInfoService::isComposable( const OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxFormComponentHandler )
221 : {
222 0 : sal_Int32 nId = getPropertyId( _rPropertyName );
223 0 : if ( nId != -1 )
224 : {
225 0 : sal_uInt32 nFlags = getPropertyUIFlags( nId );
226 0 : return ( nFlags & PROP_FLAG_COMPOSEABLE ) != 0;
227 : }
228 :
229 0 : return _rxFormComponentHandler->isComposable( _rPropertyName );
230 : }
231 :
232 :
233 0 : void OPropertyInfoService::getExcludeProperties(::std::vector< beans::Property >& _rExcludeProperties,const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _xFormComponentHandler)
234 : {
235 0 : uno::Sequence< beans::Property > aProps = _xFormComponentHandler->getSupportedProperties();
236 : static const OUString pExcludeProperties[] =
237 : {
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)
291 0 : };
292 :
293 0 : beans::Property* pPropsIter = aProps.getArray();
294 0 : beans::Property* pPropsEnd = pPropsIter + aProps.getLength();
295 0 : for (; pPropsIter != pPropsEnd; ++pPropsIter)
296 : {
297 0 : size_t nPos = 0;
298 0 : for (; nPos < sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) && pExcludeProperties[nPos] != pPropsIter->Name;++nPos )
299 : ;
300 0 : if ( nPos == sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) )
301 0 : _rExcludeProperties.push_back(*pPropsIter);
302 0 : }
303 0 : }
304 :
305 :
306 :
307 : } // namespace pcr
308 :
309 :
310 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|