1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <com/sun/star/inspection/XPropertyHandler.hpp>
21 #include <core_resource.hxx>
23 #include <strings.hrc>
24 #include <strings.hxx>
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star
;
39 struct OPropertyInfoImpl
42 OUString sTranslation
;
48 const OUString
& rName
,
50 const OUString
& aTranslation
,
51 const OString
& _sHelpId
,
52 PropUIFlags _nUIFlags
);
56 OPropertyInfoImpl::OPropertyInfoImpl(const OUString
& _rName
, sal_Int32 _nId
,
57 const OUString
& aString
, const OString
& sHid
, PropUIFlags _nUIFlags
)
59 ,sTranslation(aString
)
67 // compare PropertyInfo
68 struct PropertyInfoLessByName
70 bool operator()( const OPropertyInfoImpl
& _lhs
, const OPropertyInfoImpl
& _rhs
)
72 return _lhs
.sName
< _rhs
.sName
;
77 //= OPropertyInfoService
79 #define DEF_INFO( ident, uinameres, helpid, flags ) \
80 OPropertyInfoImpl( PROPERTY_##ident, PROPERTY_ID_##ident, \
81 RptResId( RID_STR_##uinameres ), HID_RPT_PROP_##helpid, flags )
83 #define DEF_INFO_1( ident, uinameres, helpid, flag1 ) \
84 DEF_INFO( ident, uinameres, helpid, PropUIFlags::flag1 )
86 #define DEF_INFO_2( ident, uinameres, helpid, flag1, flag2 ) \
87 DEF_INFO( ident, uinameres, helpid, PropUIFlags::flag1 | PropUIFlags::flag2 )
89 sal_uInt16
OPropertyInfoService::s_nCount
= 0;
90 OPropertyInfoImpl
* OPropertyInfoService::s_pPropertyInfos
= nullptr;
92 const OPropertyInfoImpl
* OPropertyInfoService::getPropertyInfo()
94 if ( s_pPropertyInfos
)
95 return s_pPropertyInfos
;
97 static OPropertyInfoImpl aPropertyInfos
[] =
100 DEF_INFO_?( propname and id, resource id, help id, flags ),
102 DEF_INFO_1( FORCENEWPAGE
, FORCENEWPAGE
, FORCENEWPAGE
, Composeable
)
103 ,DEF_INFO_1( NEWROWORCOL
, NEWROWORCOL
, NEWROWORCOL
, Composeable
)
104 ,DEF_INFO_1( KEEPTOGETHER
, KEEPTOGETHER
, KEEPTOGETHER
, Composeable
)
105 ,DEF_INFO_1( CANGROW
, CANGROW
, CANGROW
, Composeable
)
106 ,DEF_INFO_1( CANSHRINK
, CANSHRINK
, CANSHRINK
, Composeable
)
107 ,DEF_INFO_1( REPEATSECTION
, REPEATSECTION
, REPEATSECTION
, Composeable
)
108 ,DEF_INFO_1( PRINTREPEATEDVALUES
, PRINTREPEATEDVALUES
, PRINTREPEATEDVALUES
, Composeable
)
109 ,DEF_INFO_1( CONDITIONALPRINTEXPRESSION
, CONDITIONALPRINTEXPRESSION
, CONDITIONALPRINTEXPRESSION
, Composeable
)
110 ,DEF_INFO_1( STARTNEWCOLUMN
, STARTNEWCOLUMN
, STARTNEWCOLUMN
, Composeable
)
111 ,DEF_INFO_1( RESETPAGENUMBER
, RESETPAGENUMBER
, RESETPAGENUMBER
, Composeable
)
112 ,DEF_INFO_1( PRINTWHENGROUPCHANGE
, PRINTWHENGROUPCHANGE
, PRINTWHENGROUPCHANGE
, Composeable
)
113 ,DEF_INFO_1( VISIBLE
, VISIBLE
, VISIBLE
, Composeable
)
114 ,DEF_INFO_1( GROUPKEEPTOGETHER
, GROUPKEEPTOGETHER
, GROUPKEEPTOGETHER
, Composeable
)
115 ,DEF_INFO_1( PAGEHEADEROPTION
, PAGEHEADEROPTION
, PAGEHEADEROPTION
, Composeable
)
116 ,DEF_INFO_1( PAGEFOOTEROPTION
, PAGEFOOTEROPTION
, PAGEFOOTEROPTION
, Composeable
)
117 ,DEF_INFO_1( POSITIONX
, POSITIONX
, RPT_POSITIONX
, Composeable
)
118 ,DEF_INFO_1( POSITIONY
, POSITIONY
, RPT_POSITIONY
, Composeable
)
119 ,DEF_INFO_1( WIDTH
, WIDTH
, RPT_WIDTH
, Composeable
)
120 ,DEF_INFO_1( HEIGHT
, HEIGHT
, RPT_HEIGHT
, Composeable
)
121 ,DEF_INFO_1( FONT
, FONT
, RPT_FONT
, Composeable
)
122 ,DEF_INFO_1( PREEVALUATED
, PREEVALUATED
, PREEVALUATED
, Composeable
)
123 ,DEF_INFO_1( DEEPTRAVERSING
, DEEPTRAVERSING
, DEEPTRAVERSING
, Composeable
)
124 ,DEF_INFO_1( FORMULA
, FORMULA
, FORMULA
, Composeable
)
125 ,DEF_INFO_1( INITIALFORMULA
, INITIALFORMULA
, INITIALFORMULA
, Composeable
)
126 ,DEF_INFO_2( TYPE
, TYPE
, TYPE
, Composeable
,DataProperty
)
127 ,DEF_INFO_2( DATAFIELD
, DATAFIELD
, DATAFIELD
, Composeable
,DataProperty
)
128 ,DEF_INFO_2( FORMULALIST
, FORMULALIST
, FORMULALIST
, Composeable
,DataProperty
)
129 ,DEF_INFO_2( SCOPE
, SCOPE
, SCOPE
, Composeable
,DataProperty
)
130 ,DEF_INFO_1( PRESERVEIRI
, PRESERVEIRI
, PRESERVEIRI
, Composeable
)
131 ,DEF_INFO_1( BACKCOLOR
, BACKCOLOR
, BACKCOLOR
, Composeable
)
132 ,DEF_INFO_1( CONTROLBACKGROUND
, BACKCOLOR
, BACKCOLOR
, Composeable
)
133 ,DEF_INFO_1( BACKTRANSPARENT
, BACKTRANSPARENT
, BACKTRANSPARENT
, Composeable
)
134 ,DEF_INFO_1( CONTROLBACKGROUNDTRANSPARENT
, CONTROLBACKGROUNDTRANSPARENT
,
135 CONTROLBACKGROUNDTRANSPARENT
, Composeable
)
136 ,DEF_INFO_1( CHARTTYPE
, CHARTTYPE
, CHARTTYPE
, Composeable
)
137 ,DEF_INFO_1( PREVIEW_COUNT
, PREVIEW_COUNT
, PREVIEW_COUNT
, Composeable
)
138 ,DEF_INFO_2( MASTERFIELDS
, MASTERFIELDS
, MASTERFIELDS
, Composeable
,DataProperty
)
139 ,DEF_INFO_2( DETAILFIELDS
, DETAILFIELDS
, DETAILFIELDS
, Composeable
,DataProperty
)
140 ,DEF_INFO_1( AREA
, AREA
, AREA
, Composeable
)
141 ,DEF_INFO_2( MIMETYPE
, MIMETYPE
, MIMETYPE
, Composeable
,DataProperty
)
142 ,DEF_INFO_1( PARAADJUST
, PARAADJUST
, PARAADJUST
, Composeable
)
143 ,DEF_INFO_1( VERTICALALIGN
, VERTICALALIGN
, VERTICALALIGN
, Composeable
)
146 s_pPropertyInfos
= aPropertyInfos
;
147 s_nCount
= SAL_N_ELEMENTS(aPropertyInfos
);
148 ::std::sort( aPropertyInfos
, aPropertyInfos
+ SAL_N_ELEMENTS(aPropertyInfos
), PropertyInfoLessByName() );
150 return s_pPropertyInfos
;
154 sal_Int32
OPropertyInfoService::getPropertyId(const OUString
& _rName
)
156 const OPropertyInfoImpl
* pInfo
= getPropertyInfo(_rName
);
157 return pInfo
? pInfo
->nId
: -1;
161 OUString
OPropertyInfoService::getPropertyTranslation(sal_Int32 _nId
)
163 const OPropertyInfoImpl
* pInfo
= getPropertyInfo(_nId
);
164 return pInfo
? pInfo
->sTranslation
: OUString();
168 OString
OPropertyInfoService::getPropertyHelpId(sal_Int32 _nId
)
170 const OPropertyInfoImpl
* pInfo
= getPropertyInfo(_nId
);
171 return pInfo
? pInfo
->sHelpId
: OString();
175 PropUIFlags
OPropertyInfoService::getPropertyUIFlags(sal_Int32 _nId
)
177 const OPropertyInfoImpl
* pInfo
= getPropertyInfo(_nId
);
178 return pInfo
? pInfo
->nUIFlags
: PropUIFlags::NONE
;
182 const OPropertyInfoImpl
* OPropertyInfoService::getPropertyInfo(const OUString
& _rName
)
185 if(!s_pPropertyInfos
)
187 OPropertyInfoImpl
aSearch(_rName
, 0L, OUString(), "", PropUIFlags::NONE
);
189 const OPropertyInfoImpl
* pPropInfo
= ::std::lower_bound(
190 s_pPropertyInfos
, s_pPropertyInfos
+ s_nCount
, aSearch
, PropertyInfoLessByName() );
192 if ( ( pPropInfo
< s_pPropertyInfos
+ s_nCount
) && pPropInfo
->sName
== _rName
)
199 const OPropertyInfoImpl
* OPropertyInfoService::getPropertyInfo(sal_Int32 _nId
)
202 if(!s_pPropertyInfos
)
205 // TODO: a real structure which allows quick access by name as well as by id
206 for (sal_uInt16 i
= 0; i
< s_nCount
; i
++)
207 if (s_pPropertyInfos
[i
].nId
== _nId
)
208 return &s_pPropertyInfos
[i
];
214 bool OPropertyInfoService::isComposable( const OUString
& _rPropertyName
, const css::uno::Reference
< css::inspection::XPropertyHandler
>& _rxFormComponentHandler
)
216 sal_Int32 nId
= getPropertyId( _rPropertyName
);
219 PropUIFlags nFlags
= getPropertyUIFlags( nId
);
220 return bool( nFlags
& PropUIFlags::Composeable
);
223 return _rxFormComponentHandler
->isComposable( _rPropertyName
);
227 void OPropertyInfoService::getExcludeProperties(::std::vector
< beans::Property
>& _rExcludeProperties
,const css::uno::Reference
< css::inspection::XPropertyHandler
>& _xFormComponentHandler
)
229 uno::Sequence
< beans::Property
> aProps
= _xFormComponentHandler
->getSupportedProperties();
230 static const OUStringLiteral pExcludeProperties
[] =
253 "ControlLabel", /// TODO: has to be checked
255 "Title", // comment this out if you want to have title feature for charts
257 PROPERTY_EFFECTIVEDEFAULT
,
258 PROPERTY_EFFECTIVEMAX
,
259 PROPERTY_EFFECTIVEMIN
,
260 "HideInactiveSelection",
265 PROPERTY_EMPTY_IS_NULL
,
266 PROPERTY_FILTERPROPOSAL
275 ,PROPERTY_BORDERCOLOR
276 ,PROPERTY_BACKTRANSPARENT
277 ,PROPERTY_CONTROLBACKGROUND
278 ,PROPERTY_BACKGROUNDCOLOR
279 ,PROPERTY_CONTROLBACKGROUNDTRANSPARENT
280 ,PROPERTY_FORMULALIST
283 ,PROPERTY_DATASOURCENAME
284 ,PROPERTY_VERTICALALIGN
287 for (beans::Property
const & prop
: aProps
)
290 for (; nPos
< SAL_N_ELEMENTS(pExcludeProperties
) && pExcludeProperties
[nPos
] != prop
.Name
; ++nPos
)
292 if ( nPos
== SAL_N_ELEMENTS(pExcludeProperties
) )
293 _rExcludeProperties
.push_back(prop
);
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */