editeng/source/uno/unoipset.cxx     |    9 ++++-----
 include/svx/lathe3d.hxx             |    2 +-
 include/svx/svddef.hxx              |    2 +-
 include/svx/svx3ditems.hxx          |    4 ++--
 sc/qa/unit/helper/qahelper.cxx      |    4 ++--
 svl/source/items/cenumitm.cxx       |    2 +-
 svl/source/items/cintitem.cxx       |   15 +++++++++------
 svl/source/items/itemprop.cxx       |    8 ++++----
 svx/source/engine3d/float3d.cxx     |    2 +-
 svx/source/svdraw/svdattr.cxx       |    2 +-
 svx/source/unodraw/unoshape.cxx     |   30 ++++++++----------------------
 sw/inc/tgrditem.hxx                 |    6 +++---
 sw/source/core/unocore/unostyle.cxx |   13 -------------
 sw/source/ui/misc/pggrid.cxx        |    2 +-
 14 files changed, 38 insertions(+), 63 deletions(-)

New commits:
commit b2204eb7ed35c14dffc51e53391b3e505b5efd06
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Jun 8 10:35:00 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Jun 9 13:19:56 2025 +0200

    Return Any(sal_uInt16) from CntUInt16Item::QueryValue
    
    At some point, obviously, it was changed to return a sal_Int32; at least,
    commit 8aa0b22b69a0051277c123bbec7ca20ee5a23063 (#99054# correct UINT16
    items to sal_Int16, 2002-05-06) mentioned that in a comment. But I could
    not find the actual change implementing that; the current code was like
    this since commit 70fd6a409ebdfce6c6c234e0e8d09b98176a1379 (INTEGRATION:
    CWS visibility03 (1.1.2); FILE ADDED, 2005-04-13).
    
    I don't see a reason to do this. Any(sal_uInt16) can extract its value
    into sal_Int32.
    
    This revealed a couple of properties, that used inconsistent underlying
    types, which was masked previously by the automatic conversion; now this
    change normalizes these.
    
    CntUInt16Item::PutValue continues to accept sal_Int32, because there may
    be users relying on that. ScModelTestBase::insertNewSheet was an example
    of that.
    
    Change-Id: Iebbcd197f6e20bb373b38dd6a47a072b8cd0ca11
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186256
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx
index 60d73b7653fb..0a2e379f20aa 100644
--- a/editeng/source/uno/unoipset.cxx
+++ b/editeng/source/uno/unoipset.cxx
@@ -81,13 +81,12 @@ uno::Any SvxItemPropertySet::getPropertyValue( const 
SfxItemPropertyMapEntry* pM
                     SvxUnoConvertToMM( eMapUnit, aVal );
             }
         }
-        else if ( pMap->aType.getTypeClass() == uno::TypeClass_ENUM &&
-              aVal.getValueType() == ::cppu::UnoType<sal_Int32>::get() )
+        else if (pMap->aType.getTypeClass() == uno::TypeClass_ENUM
+                 && pMap->aType.getTypeClass() != aVal.getValueTypeClass())
         {
             // convert typeless SfxEnumItem to enum type
-            sal_Int32 nEnum;
-            aVal >>= nEnum;
-            aVal.setValue( &nEnum, pMap->aType );
+            if (sal_Int32 nEnum; aVal >>= nEnum)
+                aVal.setValue( &nEnum, pMap->aType );
         }
     }
     else
diff --git a/include/svx/lathe3d.hxx b/include/svx/lathe3d.hxx
index c21be66cdc5e..d442119ad430 100644
--- a/include/svx/lathe3d.hxx
+++ b/include/svx/lathe3d.hxx
@@ -76,7 +76,7 @@ public:
         { return GetObjectItemSet().Get(SDRATTR_3DOBJ_BACKSCALE).GetValue(); }
 
     // EndAngle: 0..10000
-    sal_uInt32 GetEndAngle() const
+    sal_uInt16 GetEndAngle() const
         { return GetObjectItemSet().Get(SDRATTR_3DOBJ_END_ANGLE).GetValue(); }
 
     // #107245# GetSmoothNormals() for bLatheSmoothed
diff --git a/include/svx/svddef.hxx b/include/svx/svddef.hxx
index 42747477ba89..115b60a0ae3c 100644
--- a/include/svx/svddef.hxx
+++ b/include/svx/svddef.hxx
@@ -343,7 +343,7 @@ inline constexpr TypedWhichId<SfxUInt16Item>               
SDRATTR_3DOBJ_BACKSCA
 inline constexpr TypedWhichId<SfxUInt32Item>               SDRATTR_3DOBJ_DEPTH 
                 (SDRATTR_3DOBJ_FIRST + 2);   // 1179
 inline constexpr TypedWhichId<SfxUInt32Item>               
SDRATTR_3DOBJ_HORZ_SEGS              (SDRATTR_3DOBJ_FIRST + 3);   // 1180
 inline constexpr TypedWhichId<SfxUInt32Item>               
SDRATTR_3DOBJ_VERT_SEGS              (SDRATTR_3DOBJ_FIRST + 4);   // 1181
-inline constexpr TypedWhichId<SfxUInt32Item>               
SDRATTR_3DOBJ_END_ANGLE              (SDRATTR_3DOBJ_FIRST + 5);   // 1182
+inline constexpr TypedWhichId<SfxUInt16Item>               
SDRATTR_3DOBJ_END_ANGLE              (SDRATTR_3DOBJ_FIRST + 5);   // 1182
 inline constexpr TypedWhichId<SfxBoolItem>                 
SDRATTR_3DOBJ_DOUBLE_SIDED           (SDRATTR_3DOBJ_FIRST + 6);   // 1183
 inline constexpr TypedWhichId<Svx3DNormalsKindItem>        
SDRATTR_3DOBJ_NORMALS_KIND           (SDRATTR_3DOBJ_FIRST + 7);   // 1184
 inline constexpr TypedWhichId<SfxBoolItem>                 
SDRATTR_3DOBJ_NORMALS_INVERT         (SDRATTR_3DOBJ_FIRST + 8);   // 1185
diff --git a/include/svx/svx3ditems.hxx b/include/svx/svx3ditems.hxx
index bd46e04eeff0..57b63e34799e 100644
--- a/include/svx/svx3ditems.hxx
+++ b/include/svx/svx3ditems.hxx
@@ -51,8 +51,8 @@ inline SfxUInt32Item makeSvx3DVerticalSegmentsItem(sal_uInt32 
nVal) {
     return SfxUInt32Item(SDRATTR_3DOBJ_VERT_SEGS, nVal);
 }
 
-inline SfxUInt32Item makeSvx3DEndAngleItem(sal_uInt32 nVal) {
-    return SfxUInt32Item(SDRATTR_3DOBJ_END_ANGLE, nVal);
+inline SfxUInt16Item makeSvx3DEndAngleItem(sal_uInt16 nVal) {
+    return SfxUInt16Item(SDRATTR_3DOBJ_END_ANGLE, nVal);
 }
 
 inline SfxBoolItem makeSvx3DDoubleSidedItem(bool bVal) {
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 85d483245b68..ff635f4f12b7 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -337,10 +337,10 @@ void ScModelTestBase::insertArrayToCell(const OUString& 
rCell, std::u16string_vi
 
 void ScModelTestBase::insertNewSheet(ScDocument& rDoc)
 {
-    sal_Int32 nTabs = static_cast<sal_Int32>(rDoc.GetTableCount());
+    sal_Int16 nTabs = rDoc.GetTableCount();
 
     uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
-        { { "Name", uno::Any(u"NewTab"_ustr) }, { "Index", uno::Any(nTabs + 1) 
} }));
+        { { "Name", uno::Any(u"NewTab"_ustr) }, { "Index", 
uno::Any(sal_Int16(nTabs + 1)) } }));
     dispatchCommand(mxComponent, u".uno:Insert"_ustr, aArgs);
 
     CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(nTabs + 1), rDoc.GetTableCount());
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx
index dbf3b4baa75e..8da04d98df67 100644
--- a/svl/source/items/cenumitm.cxx
+++ b/svl/source/items/cenumitm.cxx
@@ -48,7 +48,7 @@ bool 
SfxEnumItemInterface::GetPresentation(SfxItemPresentation, MapUnit,
 bool SfxEnumItemInterface::QueryValue(css::uno::Any& rVal, sal_uInt8)
     const
 {
-    rVal <<= sal_Int32(GetEnumValue());
+    rVal <<= GetEnumValue();
     return true;
 }
 
diff --git a/svl/source/items/cintitem.cxx b/svl/source/items/cintitem.cxx
index 3063af33e66d..616cff09d421 100644
--- a/svl/source/items/cintitem.cxx
+++ b/svl/source/items/cintitem.cxx
@@ -118,22 +118,25 @@ bool CntUInt16Item::GetPresentation(SfxItemPresentation,
 // virtual
 bool CntUInt16Item::QueryValue(css::uno::Any& rVal, sal_uInt8) const
 {
-    sal_Int32 nValue = m_nValue;
-    rVal <<= nValue;
+    rVal <<= m_nValue;
     return true;
 }
 
 // virtual
 bool CntUInt16Item::PutValue(const css::uno::Any& rVal, sal_uInt8)
 {
-    sal_Int32 nValue = 0;
-    if (rVal >>= nValue)
+    if (rVal >>= m_nValue)
+        return true;
+    // Legacy: for a long time, CntUInt16Item::PutValue accepted sal_Int32; 
play safe and accept
+    // if someone passes that
+    if (sal_Int32 nValue; rVal >>= nValue)
     {
-        SAL_WARN_IF(nValue < 0 || nValue > SAL_MAX_UINT16, "svl.items", 
"Overflow in UInt16 value!");
+        SAL_WARN("svl.items", "Passing sal_uInt16 in sal_Int32!");
+        SAL_WARN_IF(nValue < 0 || nValue > SAL_MAX_UINT16, "svl.items",
+                    "Overflow in UInt16 value!");
         m_nValue = static_cast<sal_uInt16>(nValue);
         return true;
     }
-
     SAL_WARN("svl.items", "CntUInt16Item::PutValue - Wrong type!");
     return false;
 }
diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx
index 128bc190c390..01a76c637b7f 100644
--- a/svl/source/items/itemprop.cxx
+++ b/svl/source/items/itemprop.cxx
@@ -134,11 +134,11 @@ void SfxItemPropertySet::getPropertyValue( const 
SfxItemPropertyMapEntry& rEntry
     }
 
     // convert general SfxEnumItem values to specific values
-    if( rEntry.aType.getTypeClass() == TypeClass_ENUM &&
-         rAny.getValueTypeClass() == TypeClass_LONG )
+    if (rEntry.aType.getTypeClass() == TypeClass_ENUM
+        && rEntry.aType.getTypeClass() != rAny.getValueTypeClass())
     {
-        sal_Int32 nTmp = *o3tl::forceAccess<sal_Int32>(rAny);
-        rAny.setValue( &nTmp, rEntry.aType );
+        if (sal_Int32 nTmp; rAny >>= nTmp)
+            rAny.setValue(&nTmp, rEntry.aType);
     }
 }
 
diff --git a/svx/source/engine3d/float3d.cxx b/svx/source/engine3d/float3d.cxx
index 06dccc7536f1..e48c9f52f961 100644
--- a/svx/source/engine3d/float3d.cxx
+++ b/svx/source/engine3d/float3d.cxx
@@ -731,7 +731,7 @@ void Svx3DWin::Update( SfxItemSet const & rAttrs )
         eState = rAttrs.GetItemState(SDRATTR_3DOBJ_END_ANGLE);
         if( eState != SfxItemState::INVALID )
         {
-            sal_Int32 nValue = rAttrs.Get(SDRATTR_3DOBJ_END_ANGLE).GetValue();
+            sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_END_ANGLE).GetValue();
             if( nValue != m_xMtrEndAngle->get_value(FieldUnit::DEGREE) )
             {
                 m_xMtrEndAngle->set_value(nValue, FieldUnit::DEGREE);
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 27990fd7a031..413f149452d0 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -359,7 +359,7 @@ static ItemInfoPackage& getItemInfoPackageSdr()
             { SDRATTR_3DOBJ_DEPTH, new SfxUInt32Item(SDRATTR_3DOBJ_DEPTH, 
1000), 0, SFX_ITEMINFOFLAG_NONE },
             { SDRATTR_3DOBJ_HORZ_SEGS, new 
SfxUInt32Item(SDRATTR_3DOBJ_HORZ_SEGS, 24), 0, SFX_ITEMINFOFLAG_NONE },
             { SDRATTR_3DOBJ_VERT_SEGS, new 
SfxUInt32Item(SDRATTR_3DOBJ_VERT_SEGS, 24), 0, SFX_ITEMINFOFLAG_NONE },
-            { SDRATTR_3DOBJ_END_ANGLE, new 
SfxUInt32Item(SDRATTR_3DOBJ_END_ANGLE, 3600), 0, SFX_ITEMINFOFLAG_NONE },
+            { SDRATTR_3DOBJ_END_ANGLE, new 
SfxUInt16Item(SDRATTR_3DOBJ_END_ANGLE, 3600), 0, SFX_ITEMINFOFLAG_NONE },
             { SDRATTR_3DOBJ_DOUBLE_SIDED, new 
SfxBoolItem(SDRATTR_3DOBJ_DOUBLE_SIDED, false), 0, SFX_ITEMINFOFLAG_NONE },
             { SDRATTR_3DOBJ_NORMALS_KIND, new Svx3DNormalsKindItem, 0, 
SFX_ITEMINFOFLAG_NONE },
             { SDRATTR_3DOBJ_NORMALS_INVERT, new 
SfxBoolItem(SDRATTR_3DOBJ_NORMALS_INVERT, false), 0, SFX_ITEMINFOFLAG_NONE },
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 5aad40042f12..30c81d9326ad 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -1854,28 +1854,14 @@ uno::Any SvxShape::GetAnyForItem( SfxItemSet const & 
aSet, const SfxItemProperty
         // get value from ItemSet
         aAny = SvxItemPropertySet_getPropertyValue( pMap, aSet );
 
-        if( pMap->aType != aAny.getValueType() )
-        {
-            // since the sfx uint16 item now exports a sal_Int32, we may have 
to fix this here
-            if( ( pMap->aType == ::cppu::UnoType<sal_Int16>::get()) && 
aAny.getValueType() == ::cppu::UnoType<sal_Int32>::get() )
-            {
-                sal_Int32 nValue = 0;
-                aAny >>= nValue;
-                aAny <<= static_cast<sal_Int16>(nValue);
-            }
-            else
-            {
-                SAL_WARN_IF(!pMap->aType.isAssignableFrom(aAny.getValueType())
-                                && aAny.getValueType() != 
cppu::UnoType<void>::get()
-                                && !(pMap->nWID == XATTR_FILLBITMAP && 
pMap->nMemberId == MID_BITMAP
-                                     && aAny.getValueType() == 
cppu::UnoType<css::awt::XBitmap>::get()),
-                            "svx",
-                            "SvxShape::GetAnyForItem() Return value for 
property "
-                                << pMap->aName << " has wrong Type, " << 
pMap->aType
-                                << " != " << aAny.getValueType());
-            }
-        }
-
+        SAL_WARN_IF(!pMap->aType.isAssignableFrom(aAny.getValueType())
+                        && aAny.getValueType() != cppu::UnoType<void>::get()
+                        && !(pMap->nWID == XATTR_FILLBITMAP && pMap->nMemberId 
== MID_BITMAP
+                             && aAny.getValueType() == 
cppu::UnoType<css::awt::XBitmap>::get()),
+                    "svx",
+                    "SvxShape::GetAnyForItem() Return value for property "
+                        << pMap->aName << " has wrong Type, " << pMap->aType
+                        << " != " << aAny.getValueType());
     }
     }
 
diff --git a/sw/inc/tgrditem.hxx b/sw/inc/tgrditem.hxx
index f039a3156896..e06ad3ebd556 100644
--- a/sw/inc/tgrditem.hxx
+++ b/sw/inc/tgrditem.hxx
@@ -31,7 +31,7 @@ class SW_DLLPUBLIC SwTextGridItem final : public SfxPoolItem
 {
 private:
     Color m_aColor;
-    sal_Int32 m_nLines;
+    sal_Int16 m_nLines;
     sal_uInt16 m_nBaseHeight;
     sal_uInt16 m_nRubyHeight;
     SwTextGrid m_eGridType;
@@ -68,8 +68,8 @@ public:
     const Color& GetColor() const { return m_aColor; }
     void SetColor( const Color& rCol )  { m_aColor = rCol; }
 
-    sal_Int32 GetLines() const { return m_nLines; }
-    void SetLines( sal_Int32 nNew ) { m_nLines = nNew; }
+    sal_Int16 GetLines() const { return m_nLines; }
+    void SetLines( sal_Int16 nNew ) { m_nLines = nNew; }
 
     sal_uInt16 GetBaseHeight() const { return m_nBaseHeight; }
     void SetBaseHeight( sal_uInt16 nNew ) { m_nBaseHeight = nNew; }
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 9c79c2abc3c0..41aaddc3d1ea 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -2335,9 +2335,6 @@ uno::Any SwXStyle::GetStyleProperty<HINT_BEGIN>(const 
SfxItemPropertyMapEntry& r
     uno::Any aResult;
     SfxItemPropertySet::getPropertyValue(rEntry, rSet, aResult);
     //
-    // since the sfx uint16 item now exports a sal_Int32, we may have to fix 
this here
-    if(rEntry.aType == cppu::UnoType<sal_Int16>::get() && 
aResult.getValueType() == cppu::UnoType<sal_Int32>::get())
-        aResult <<= static_cast<sal_Int16>(aResult.get<sal_Int32>());
     // check for needed metric translation
     if(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM && GetDoc())
     {
@@ -4166,16 +4163,6 @@ uno::Sequence< uno::Any > 
SwXAutoStyle::GetPropertyValues_Impl(
 
         if(bTakeCareOfDrawingLayerFillStyle)
         {
-            if(pEntry->aType == cppu::UnoType<sal_Int16>::get() && 
pEntry->aType != aTarget.getValueType())
-            {
-                // since the sfx uint16 item now exports a sal_Int32, we may 
have to fix this here
-                sal_Int32 nValue = 0;
-                if (aTarget >>= nValue)
-                {
-                    aTarget <<= static_cast<sal_Int16>(nValue);
-                }
-            }
-
             // check for needed metric translation
             if(pEntry->nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
             {
diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx
index c6677cb56255..41614fc4cae2 100644
--- a/sw/source/ui/misc/pggrid.cxx
+++ b/sw/source/ui/misc/pggrid.cxx
@@ -230,7 +230,7 @@ void SwTextGridPage::PutGridItem(SfxItemSet& rSet)
     aGridItem.SetGridType(m_xNoGridRB->get_active() ? SwTextGrid::NONE :
         m_xLinesGridRB->get_active() ? SwTextGrid::LinesOnly : 
SwTextGrid::LinesAndChars );
     aGridItem.SetSnapToChars(m_xSnapToCharsCB->get_active());
-    aGridItem.SetLines( static_cast< sal_Int32 
>(m_xLinesPerPageNF->get_value()) );
+    aGridItem.SetLines(m_xLinesPerPageNF->get_value());
     aGridItem.SetBaseHeight( static_cast< sal_uInt16 >(
         m_bRubyUserValue ? m_nRubyUserValue :
             
m_xTextSizeMF->denormalize(m_xTextSizeMF->get_value(FieldUnit::TWIP))) );

Reply via email to