Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "metadata.hxx"
29 : : #include <svtools/localresaccess.hxx>
30 : : #include "com/sun/star/inspection/XPropertyHandler.hpp"
31 : : #include <comphelper/extract.hxx>
32 : : #include "helpids.hrc"
33 : : #include "RptResId.hrc"
34 : : #include "uistrings.hrc"
35 : :
36 : : #include <functional>
37 : : #include <algorithm>
38 : :
39 : : //............................................................................
40 : : namespace rptui
41 : : {
42 : : //............................................................................
43 : :
44 : : using namespace ::com::sun::star::uno;
45 : : using namespace ::com::sun::star;
46 : :
47 : : //========================================================================
48 : : //= OPropertyInfoImpl
49 : : //========================================================================
50 : 0 : struct OPropertyInfoImpl
51 : : {
52 : : String sName;
53 : : String sTranslation;
54 : : rtl::OString sHelpId;
55 : : sal_Int32 nId;
56 : : sal_uInt16 nPos;
57 : : sal_uInt32 nUIFlags;
58 : :
59 : : OPropertyInfoImpl(
60 : : const ::rtl::OUString& rName,
61 : : sal_Int32 _nId,
62 : : const String& aTranslation,
63 : : sal_uInt16 nPosId,
64 : : const rtl::OString& _sHelpId,
65 : : sal_uInt32 _nUIFlags);
66 : : };
67 : :
68 : : //------------------------------------------------------------------------
69 : 0 : OPropertyInfoImpl::OPropertyInfoImpl(const ::rtl::OUString& _rName, sal_Int32 _nId,
70 : : const String& aString, sal_uInt16 nP, const rtl::OString& sHid, sal_uInt32 _nUIFlags)
71 : : :sName(_rName)
72 : : ,sTranslation(aString)
73 : : ,sHelpId(sHid)
74 : : ,nId(_nId)
75 : : ,nPos(nP)
76 : 0 : ,nUIFlags(_nUIFlags)
77 : : {
78 : 0 : }
79 : :
80 : : //------------------------------------------------------------------------
81 : : // Vergleichen von PropertyInfo
82 : : struct PropertyInfoLessByName : public ::std::binary_function< OPropertyInfoImpl, OPropertyInfoImpl, bool >
83 : : {
84 : 0 : bool operator()( const OPropertyInfoImpl& _lhs, const OPropertyInfoImpl& _rhs )
85 : : {
86 : 0 : return _lhs.sName < _rhs.sName;
87 : : }
88 : : };
89 : :
90 : : //========================================================================
91 : : //= OPropertyInfoService
92 : : //========================================================================
93 : : #define DEF_INFO( ident, uinameres, helpid, flags ) \
94 : : OPropertyInfoImpl( PROPERTY_##ident, PROPERTY_ID_##ident, \
95 : : String( ModuleRes( RID_STR_##uinameres ) ), nPos++, HID_RPT_PROP_##helpid, flags )
96 : :
97 : : #define DEF_INFO_1( ident, uinameres, helpid, flag1 ) \
98 : : DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 )
99 : :
100 : : #define DEF_INFO_2( ident, uinameres, helpid, flag1, flag2 ) \
101 : : DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 )
102 : :
103 : : #define DEF_INFO_3( ident, uinameres, helpid, flag1, flag2, flag3 ) \
104 : : DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 )
105 : :
106 : : #define DEF_INFO_4( ident, uinameres, helpid, flag1, flag2, flag3, flag4 ) \
107 : : DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 )
108 : :
109 : : #define DEF_INFO_5( ident, uinameres, helpid, flag1, flag2, flag3, flag4, flag5 ) \
110 : : DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 | PROP_FLAG_##flag5 )
111 : :
112 : : sal_uInt16 OPropertyInfoService::s_nCount = 0;
113 : : OPropertyInfoImpl* OPropertyInfoService::s_pPropertyInfos = NULL;
114 : : //------------------------------------------------------------------------
115 : 0 : const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo()
116 : : {
117 : 0 : if ( s_pPropertyInfos )
118 : 0 : return s_pPropertyInfos;
119 : :
120 : 0 : OModuleClient aResourceAccess;
121 : : // this ensures that we have our resource file loaded
122 : :
123 : 0 : sal_uInt16 nPos = 1;
124 : : static OPropertyInfoImpl aPropertyInfos[] =
125 : : {
126 : : /*
127 : : DEF_INFO_?( propname and id, resoure id, help id, flags ),
128 : : */
129 : : DEF_INFO_1( FORCENEWPAGE, FORCENEWPAGE, FORCENEWPAGE, COMPOSEABLE )
130 : : ,DEF_INFO_1( NEWROWORCOL, NEWROWORCOL, NEWROWORCOL, COMPOSEABLE )
131 : : ,DEF_INFO_1( KEEPTOGETHER, KEEPTOGETHER, KEEPTOGETHER, COMPOSEABLE )
132 : : ,DEF_INFO_1( CANGROW, CANGROW, CANGROW, COMPOSEABLE )
133 : : ,DEF_INFO_1( CANSHRINK, CANSHRINK, CANSHRINK, COMPOSEABLE )
134 : : ,DEF_INFO_1( REPEATSECTION, REPEATSECTION, REPEATSECTION, COMPOSEABLE )
135 : : ,DEF_INFO_1( PRINTREPEATEDVALUES, PRINTREPEATEDVALUES, PRINTREPEATEDVALUES, COMPOSEABLE )
136 : : ,DEF_INFO_1( CONDITIONALPRINTEXPRESSION, CONDITIONALPRINTEXPRESSION, CONDITIONALPRINTEXPRESSION, COMPOSEABLE )
137 : : ,DEF_INFO_1( STARTNEWCOLUMN, STARTNEWCOLUMN, STARTNEWCOLUMN, COMPOSEABLE )
138 : : ,DEF_INFO_1( RESETPAGENUMBER, RESETPAGENUMBER, RESETPAGENUMBER, COMPOSEABLE )
139 : : ,DEF_INFO_1( PRINTWHENGROUPCHANGE, PRINTWHENGROUPCHANGE, PRINTWHENGROUPCHANGE, COMPOSEABLE )
140 : : ,DEF_INFO_1( VISIBLE, VISIBLE, VISIBLE, COMPOSEABLE )
141 : : ,DEF_INFO_1( GROUPKEEPTOGETHER, GROUPKEEPTOGETHER, GROUPKEEPTOGETHER, COMPOSEABLE )
142 : : ,DEF_INFO_1( PAGEHEADEROPTION, PAGEHEADEROPTION, PAGEHEADEROPTION, COMPOSEABLE )
143 : : ,DEF_INFO_1( PAGEFOOTEROPTION, PAGEFOOTEROPTION, PAGEFOOTEROPTION, COMPOSEABLE )
144 : : ,DEF_INFO_1( POSITIONX, POSITIONX, RPT_POSITIONX, COMPOSEABLE )
145 : : ,DEF_INFO_1( POSITIONY, POSITIONY, RPT_POSITIONY, COMPOSEABLE )
146 : : ,DEF_INFO_1( WIDTH, WIDTH, RPT_WIDTH, COMPOSEABLE )
147 : : ,DEF_INFO_1( HEIGHT, HEIGHT, RPT_HEIGHT, COMPOSEABLE )
148 : : ,DEF_INFO_1( FONT, FONT, RPT_FONT, COMPOSEABLE )
149 : : ,DEF_INFO_1( PREEVALUATED, PREEVALUATED, PREEVALUATED, COMPOSEABLE )
150 : : ,DEF_INFO_1( DEEPTRAVERSING, DEEPTRAVERSING, DEEPTRAVERSING, COMPOSEABLE )
151 : : ,DEF_INFO_1( FORMULA, FORMULA, FORMULA, COMPOSEABLE )
152 : : ,DEF_INFO_1( INITIALFORMULA, INITIALFORMULA, INITIALFORMULA, COMPOSEABLE )
153 : : ,DEF_INFO_2( TYPE, TYPE, TYPE, COMPOSEABLE,DATA_PROPERTY )
154 : : ,DEF_INFO_2( DATAFIELD, DATAFIELD, DATAFIELD, COMPOSEABLE,DATA_PROPERTY )
155 : : ,DEF_INFO_2( FORMULALIST, FORMULALIST, FORMULALIST, COMPOSEABLE,DATA_PROPERTY )
156 : : ,DEF_INFO_2( SCOPE, SCOPE, SCOPE, COMPOSEABLE,DATA_PROPERTY )
157 : : ,DEF_INFO_1( PRESERVEIRI, PRESERVEIRI, PRESERVEIRI, COMPOSEABLE )
158 : : ,DEF_INFO_1( BACKCOLOR, BACKCOLOR, BACKCOLOR, COMPOSEABLE )
159 : : ,DEF_INFO_1( CONTROLBACKGROUND, BACKCOLOR, BACKCOLOR, COMPOSEABLE )
160 : : ,DEF_INFO_1( BACKTRANSPARENT, BACKTRANSPARENT, BACKTRANSPARENT, COMPOSEABLE )
161 : : ,DEF_INFO_1( CONTROLBACKGROUNDTRANSPARENT, CONTROLBACKGROUNDTRANSPARENT
162 : : ,CONTROLBACKGROUNDTRANSPARENT, COMPOSEABLE )
163 : : ,DEF_INFO_1( CHARTTYPE, CHARTTYPE, CHARTTYPE, COMPOSEABLE )
164 : : ,DEF_INFO_1( PREVIEW_COUNT, PREVIEW_COUNT, PREVIEW_COUNT, COMPOSEABLE )
165 : : ,DEF_INFO_2( MASTERFIELDS, MASTERFIELDS, MASTERFIELDS, COMPOSEABLE,DATA_PROPERTY )
166 : : ,DEF_INFO_2( DETAILFIELDS, DETAILFIELDS, DETAILFIELDS, COMPOSEABLE,DATA_PROPERTY)
167 : : ,DEF_INFO_1( AREA, AREA, AREA, COMPOSEABLE )
168 : : ,DEF_INFO_2( MIMETYPE, MIMETYPE, MIMETYPE, COMPOSEABLE,DATA_PROPERTY )
169 : : ,DEF_INFO_1( PARAADJUST, PARAADJUST, PARAADJUST, COMPOSEABLE )
170 : : ,DEF_INFO_1( VERTICALALIGN, VERTICALALIGN, VERTICALALIGN, COMPOSEABLE )
171 : 0 : };
172 : :
173 : 0 : s_pPropertyInfos = aPropertyInfos;
174 : 0 : s_nCount = SAL_N_ELEMENTS(aPropertyInfos);
175 : 0 : ::std::sort( aPropertyInfos, aPropertyInfos + SAL_N_ELEMENTS(aPropertyInfos), PropertyInfoLessByName() );
176 : :
177 : 0 : return s_pPropertyInfos;
178 : : }
179 : :
180 : : //------------------------------------------------------------------------
181 : 0 : sal_Int32 OPropertyInfoService::getPropertyId(const String& _rName) const
182 : : {
183 : 0 : const OPropertyInfoImpl* pInfo = getPropertyInfo(_rName);
184 : 0 : return pInfo ? pInfo->nId : -1;
185 : : }
186 : :
187 : : //------------------------------------------------------------------------
188 : 0 : String OPropertyInfoService::getPropertyTranslation(sal_Int32 _nId) const
189 : : {
190 : 0 : const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
191 : 0 : return (pInfo) ? pInfo->sTranslation : String();
192 : : }
193 : :
194 : : //------------------------------------------------------------------------
195 : 0 : rtl::OString OPropertyInfoService::getPropertyHelpId(sal_Int32 _nId) const
196 : : {
197 : 0 : const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
198 : 0 : return (pInfo) ? pInfo->sHelpId : rtl::OString();
199 : : }
200 : :
201 : : //------------------------------------------------------------------------
202 : 0 : sal_uInt32 OPropertyInfoService::getPropertyUIFlags(sal_Int32 _nId) const
203 : : {
204 : 0 : const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
205 : 0 : return (pInfo) ? pInfo->nUIFlags : 0;
206 : : }
207 : :
208 : : //------------------------------------------------------------------------
209 : 0 : const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(const String& _rName)
210 : : {
211 : : // intialisierung
212 : 0 : if(!s_pPropertyInfos)
213 : 0 : getPropertyInfo();
214 : 0 : OPropertyInfoImpl aSearch(_rName, 0L, String(), 0, "", 0);
215 : :
216 : : const OPropertyInfoImpl* pPropInfo = ::std::lower_bound(
217 : 0 : s_pPropertyInfos, s_pPropertyInfos + s_nCount, aSearch, PropertyInfoLessByName() );
218 : :
219 : 0 : if ( ( pPropInfo < s_pPropertyInfos + s_nCount ) && pPropInfo->sName == _rName )
220 : 0 : return pPropInfo;
221 : :
222 : 0 : return NULL;
223 : : }
224 : :
225 : :
226 : : //------------------------------------------------------------------------
227 : 0 : const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(sal_Int32 _nId)
228 : : {
229 : : // intialisierung
230 : 0 : if(!s_pPropertyInfos)
231 : 0 : getPropertyInfo();
232 : :
233 : : // TODO: a real structure which allows quick access by name as well as by id
234 : 0 : for (sal_uInt16 i = 0; i < s_nCount; i++)
235 : 0 : if (s_pPropertyInfos[i].nId == _nId)
236 : 0 : return &s_pPropertyInfos[i];
237 : :
238 : 0 : return NULL;
239 : : }
240 : :
241 : : //------------------------------------------------------------------------
242 : 0 : bool OPropertyInfoService::isComposable( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxFormComponentHandler )
243 : : {
244 : 0 : sal_Int32 nId = getPropertyId( _rPropertyName );
245 : 0 : if ( nId != -1 )
246 : : {
247 : 0 : sal_uInt32 nFlags = getPropertyUIFlags( nId );
248 : 0 : return ( nFlags & PROP_FLAG_COMPOSEABLE ) != 0;
249 : : }
250 : :
251 : 0 : return _rxFormComponentHandler->isComposable( _rPropertyName );
252 : : }
253 : :
254 : : //------------------------------------------------------------------------
255 : 0 : void OPropertyInfoService::getExcludeProperties(::std::vector< beans::Property >& _rExcludeProperties,const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _xFormComponentHandler)
256 : : {
257 : 0 : uno::Sequence< beans::Property > aProps = _xFormComponentHandler->getSupportedProperties();
258 : : static const ::rtl::OUString pExcludeProperties[] =
259 : : {
260 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Enabled")),
261 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Printable")),
262 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WordBreak")),
263 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MultiLine")),
264 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tag")),
265 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpText")),
266 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpURL")),
267 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxTextLen")),
268 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly")),
269 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tabstop")),
270 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TabIndex")),
271 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ValueMin")),
272 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ValueMax")),
273 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Spin")),
274 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SpinValue")),
275 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SpinValueMin")),
276 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SpinValueMax")),
277 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultSpinValue")),
278 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SpinIncrement")),
279 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Repeat")),
280 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RepeatDelay")),
281 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlLabel")), /// TODO: has to be checked
282 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LabelControl")),
283 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")), // comment this out if you want to have title feature for charts
284 : : PROPERTY_MAXTEXTLEN,
285 : : PROPERTY_EFFECTIVEDEFAULT,
286 : : PROPERTY_EFFECTIVEMAX,
287 : : PROPERTY_EFFECTIVEMIN,
288 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HideInactiveSelection")),
289 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SubmitAction")),
290 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputRequired")),
291 : : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VerticalAlign")),
292 : : PROPERTY_ALIGN,
293 : : PROPERTY_EMPTY_IS_NULL,
294 : : PROPERTY_FILTERPROPOSAL
295 : : ,PROPERTY_POSITIONX
296 : : ,PROPERTY_POSITIONY
297 : : ,PROPERTY_WIDTH
298 : : ,PROPERTY_HEIGHT
299 : : ,PROPERTY_FONT
300 : : ,PROPERTY_LABEL
301 : : ,PROPERTY_LINECOLOR
302 : : ,PROPERTY_BORDER
303 : : ,PROPERTY_BORDERCOLOR
304 : : ,PROPERTY_BACKTRANSPARENT
305 : : ,PROPERTY_CONTROLBACKGROUND
306 : : ,PROPERTY_BACKGROUNDCOLOR
307 : : ,PROPERTY_CONTROLBACKGROUNDTRANSPARENT
308 : : ,PROPERTY_FORMULALIST
309 : : ,PROPERTY_SCOPE
310 : : ,PROPERTY_TYPE
311 : : ,PROPERTY_DATASOURCENAME
312 : : ,PROPERTY_VERTICALALIGN
313 : 0 : };
314 : :
315 : 0 : beans::Property* pPropsIter = aProps.getArray();
316 : 0 : beans::Property* pPropsEnd = pPropsIter + aProps.getLength();
317 : 0 : for (; pPropsIter != pPropsEnd; ++pPropsIter)
318 : : {
319 : 0 : size_t nPos = 0;
320 : 0 : for (; nPos < sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) && pExcludeProperties[nPos] != pPropsIter->Name;++nPos )
321 : : ;
322 : 0 : if ( nPos == sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) )
323 : 0 : _rExcludeProperties.push_back(*pPropsIter);
324 : 0 : }
325 : 0 : }
326 : :
327 : :
328 : : //............................................................................
329 : : } // namespace pcr
330 : : //............................................................................
331 : :
332 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|