20#include <com/sun/star/beans/XPropertySet.hpp>
25#include <svl/solar.hrc>
27#include <osl/diagnose.h>
35: m_aPropertyMap( pMap ),
36 mrItemPool( rItemPool )
59 if(!pMap || !pMap->
nWID)
65 if(
nullptr == pItem && pPool )
70 if( eMapUnit == MapUnit::Map100thMM )
71 nMemberId &= (~CONVERT_TWIPS);
76 if( pMap->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM )
78 if( eMapUnit != MapUnit::Map100thMM )
84 else if ( pMap->
aType.getTypeClass() == uno::TypeClass_ENUM &&
95 OSL_FAIL(
"No SfxPoolItem found for property!" );
104 if(!pMap || !pMap->
nWID)
113 if(eState < SfxItemState::DEFAULT || pItem ==
nullptr)
115 if( pPool ==
nullptr )
117 OSL_FAIL(
"No default item and no pool?" );
129 if ((pMap->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM) && eMapUnit != MapUnit::Map100thMM)
135 std::unique_ptr<SfxPoolItem> pNewItem(pItem->
Clone());
138 if (eMapUnit == MapUnit::Map100thMM)
139 nMemberId &= (~CONVERT_TWIPS);
141 if (pNewItem->PutValue(aValue, nMemberId))
144 pNewItem->SetWhich(pMap->
nWID);
160 if( eMapUnit == MapUnit::Map100thMM )
161 nMemberId &= (~CONVERT_TWIPS);
165 if( (pMap->
nWID < OWN_ATTR_VALUE_START) || (pMap->
nWID > OWN_ATTR_VALUE_END ) )
176 if(eState >= SfxItemState::DEFAULT && pItem)
184 if(pMap->
nMoreFlags & PropertyMoreFlags::METRIC_ITEM && eMapUnit != MapUnit::Map100thMM)
189 if ( pMap->
aType.getTypeClass() == uno::TypeClass_ENUM &&
230 switch(eSourceMapUnit)
232 case MapUnit::MapTwip :
234 switch( rMetric.getValueTypeClass() )
236 case uno::TypeClass_BYTE:
237 rMetric <<= static_cast<sal_Int8>(
convertTwipToMm100(*o3tl::forceAccess<sal_Int8>(rMetric)));
239 case uno::TypeClass_SHORT:
240 rMetric <<= static_cast<sal_Int16>(
convertTwipToMm100(*o3tl::forceAccess<sal_Int16>(rMetric)));
242 case uno::TypeClass_UNSIGNED_SHORT:
243 rMetric <<= static_cast<sal_uInt16>(
convertTwipToMm100(*o3tl::forceAccess<sal_uInt16>(rMetric)));
245 case uno::TypeClass_LONG:
246 rMetric <<= static_cast<sal_Int32>(
convertTwipToMm100(*o3tl::forceAccess<sal_Int32>(rMetric)));
248 case uno::TypeClass_UNSIGNED_LONG:
249 rMetric <<= static_cast<sal_uInt32>(
convertTwipToMm100(*o3tl::forceAccess<sal_uInt32>(rMetric)));
252 SAL_WARN(
"editeng",
"AW: Missing unit translation to 100th mm, " << OString::number(
static_cast<sal_Int32
>(rMetric.getValueTypeClass())));
259 OSL_FAIL(
"AW: Missing unit translation to 100th mm!");
268 switch(eDestinationMapUnit)
270 case MapUnit::MapTwip :
272 switch( rMetric.getValueTypeClass() )
274 case uno::TypeClass_BYTE:
275 rMetric <<= static_cast<sal_Int8>(
sanitiseMm100ToTwip(*o3tl::forceAccess<sal_Int8>(rMetric)));
277 case uno::TypeClass_SHORT:
278 rMetric <<= static_cast<sal_Int16>(
sanitiseMm100ToTwip(*o3tl::forceAccess<sal_Int16>(rMetric)));
280 case uno::TypeClass_UNSIGNED_SHORT:
281 rMetric <<= static_cast<sal_uInt16>(
sanitiseMm100ToTwip(*o3tl::forceAccess<sal_uInt16>(rMetric)));
283 case uno::TypeClass_LONG:
284 rMetric <<= static_cast<sal_Int32>(
sanitiseMm100ToTwip(*o3tl::forceAccess<sal_Int32>(rMetric)));
286 case uno::TypeClass_UNSIGNED_LONG:
287 rMetric <<= static_cast<sal_uInt32>(
sanitiseMm100ToTwip(*o3tl::forceAccess<sal_uInt32>(rMetric)));
290 OSL_FAIL(
"AW: Missing unit translation to 100th mm!");
296 OSL_FAIL(
"AW: Missing unit translation to PoolMetrics!");
312 if( rActual.nWID == entry.
nWID && rActual.memberId == entry.
nMemberId )
313 return const_cast<uno::Any*
>(&rActual.aAny);
constexpr sal_Int64 sanitiseMm100ToTwip(sal_Int64 n)
constexpr auto convertTwipToMm100(N n)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
static bool IsWhich(sal_uInt16 nId)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
SfxItemPool * GetPool() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
::std::vector< SvxIDPropertyCombine > aCombineList
SvxItemPropertySetUsrAnys()
css::uno::Any * GetUsrAnyForID(SfxItemPropertyMapEntry const &entry) const
void AddUsrAnyForID(const css::uno::Any &rAny, SfxItemPropertyMapEntry const &entry)
~SvxItemPropertySetUsrAnys()
SvxItemPropertySet(o3tl::span< const SfxItemPropertyMapEntry > pMap, SfxItemPool &rPool)
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
const SfxItemPropertyMapEntry * getPropertyMapEntry(std::u16string_view rName) const
static void setPropertyValue(const SfxItemPropertyMapEntry *pMap, const css::uno::Any &rVal, SfxItemSet &rSet, bool bDontConvertNegativeValues)
SfxItemPropertyMap m_aPropertyMap
css::uno::Reference< css::beans::XPropertySetInfo > m_xInfo
static css::uno::Any getPropertyValue(const SfxItemPropertyMapEntry *pMap, const SfxItemSet &rSet, bool bSearchInParent, bool bDontConvertNegativeValues)
css::uno::Type const & get()
#define SAL_WARN(area, stream)
PropertyMoreFlags nMoreFlags
void setValue(Type type, object value)
void SvxUnoConvertToMM(const MapUnit eSourceMapUnit, uno::Any &rMetric) noexcept
converts the given any with a metric to 100th/mm if needed
void SvxUnoConvertFromMM(const MapUnit eDestinationMapUnit, uno::Any &rMetric) noexcept
converts the given any with a metric from 100th/mm to the given metric if needed
static bool SvxUnoCheckForPositiveValue(const uno::Any &rVal)