[Libreoffice-commits] core.git: include/svx svx/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Feb 2 10:12:26 UTC 2018


 include/svx/sdr/properties/properties.hxx    |    5 +++++
 svx/source/sdr/properties/textproperties.cxx |   14 +++++++-------
 svx/source/table/cell.cxx                    |   12 ++++++------
 3 files changed, 18 insertions(+), 13 deletions(-)

New commits:
commit cc45c96770def8fb3cc8c6d6c3d385c592806ae9
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Feb 2 08:48:36 2018 +0200

    use TypedWhichId in BaseProperties::GetItem
    
    Change-Id: Ic359d33d92928f5baa89cd98debe1a6a9d6a52f3
    Reviewed-on: https://gerrit.libreoffice.org/49128
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/sdr/properties/properties.hxx b/include/svx/sdr/properties/properties.hxx
index 7755f4fbc3fb..ef6cccb3103d 100644
--- a/include/svx/sdr/properties/properties.hxx
+++ b/include/svx/sdr/properties/properties.hxx
@@ -26,6 +26,7 @@
 
 #include <sal/types.h>
 #include <svx/svxdllapi.h>
+#include <svl/typedwhich.hxx>
 
 class SdrObject;
 class SfxItemSet;
@@ -164,6 +165,10 @@ namespace sdr
 
             // Just a convenient shortcut for GetObjectItemSet().Get(nWhich).
             const SfxPoolItem& GetItem(const sal_uInt16 nWhich) const;
+            template<class T> const T& GetItem(TypedWhichId<T> nWhich) const
+            {
+                return static_cast<const T&>(GetItem(sal_uInt16(nWhich)));
+            }
 
             // support for convenient broadcasting. Used from SetMergedItemAndBroadcast(),
             // ClearItemAndBroadcast() and SetItemSetAndBroadcast(), see above.
diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx
index 706950690277..9356f1a0cf15 100644
--- a/svx/source/sdr/properties/textproperties.cxx
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -157,7 +157,7 @@ namespace sdr
 
             if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange())
             {
-                nOldLineWidth = static_cast<const XLineWidthItem&>(GetItem(XATTR_LINEWIDTH)).GetValue();
+                nOldLineWidth = GetItem(XATTR_LINEWIDTH).GetValue();
             }
 
             if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
@@ -202,19 +202,19 @@ namespace sdr
             // #i25616#
             if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange())
             {
-                const sal_Int32 nNewLineWidth(static_cast<const XLineWidthItem&>(GetItem(XATTR_LINEWIDTH)).GetValue());
+                const sal_Int32 nNewLineWidth(GetItem(XATTR_LINEWIDTH).GetValue());
                 const sal_Int32 nDifference((nNewLineWidth - nOldLineWidth) / 2);
 
                 if(nDifference)
                 {
-                    const bool bLineVisible(drawing::LineStyle_NONE != static_cast<const XLineStyleItem&>(GetItem(XATTR_LINESTYLE)).GetValue());
+                    const bool bLineVisible(drawing::LineStyle_NONE != GetItem(XATTR_LINESTYLE).GetValue());
 
                     if(bLineVisible)
                     {
-                        const sal_Int32 nLeftDist(static_cast<const SdrMetricItem&>(GetItem(SDRATTR_TEXT_LEFTDIST)).GetValue());
-                        const sal_Int32 nRightDist(static_cast<const SdrMetricItem&>(GetItem(SDRATTR_TEXT_RIGHTDIST)).GetValue());
-                        const sal_Int32 nUpperDist(static_cast<const SdrMetricItem&>(GetItem(SDRATTR_TEXT_UPPERDIST)).GetValue());
-                        const sal_Int32 nLowerDist(static_cast<const SdrMetricItem&>(GetItem(SDRATTR_TEXT_LOWERDIST)).GetValue());
+                        const sal_Int32 nLeftDist(GetItem(SDRATTR_TEXT_LEFTDIST).GetValue());
+                        const sal_Int32 nRightDist(GetItem(SDRATTR_TEXT_RIGHTDIST).GetValue());
+                        const sal_Int32 nUpperDist(GetItem(SDRATTR_TEXT_UPPERDIST).GetValue());
+                        const sal_Int32 nLowerDist(GetItem(SDRATTR_TEXT_LOWERDIST).GetValue());
 
                         SetObjectItemDirect(makeSdrTextLeftDistItem(nLeftDist + nDifference));
                         SetObjectItemDirect(makeSdrTextRightDistItem(nRightDist + nDifference));
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index cd59528ae818..b76f39e51f6f 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -1186,10 +1186,10 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
         }
         case OWN_ATTR_TABLEBORDER:
         {
-            const SvxBoxInfoItem& rBoxInfoItem = static_cast<const SvxBoxInfoItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER_INNER));
-            const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER));
+            const SvxBoxInfoItem& rBoxInfoItem = mpProperties->GetItem(SDRATTR_TABLE_BORDER_INNER);
+            const SvxBoxItem& rBox = mpProperties->GetItem(SDRATTR_TABLE_BORDER);
 
-             TableBorder aTableBorder;
+            TableBorder aTableBorder;
             aTableBorder.TopLine                = SvxBoxItem::SvxLineToLine(rBox.GetTop(), false);
             aTableBorder.IsTopLineValid         = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::TOP);
             aTableBorder.BottomLine             = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), false);
@@ -1209,8 +1209,8 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
         }
         case OWN_ATTR_FILLBMP_MODE:
         {
-            const XFillBmpStretchItem& rStretchItem = static_cast<const XFillBmpStretchItem&>(mpProperties->GetItem(XATTR_FILLBMP_STRETCH));
-            const XFillBmpTileItem& rTileItem = static_cast<const XFillBmpTileItem&>(mpProperties->GetItem(XATTR_FILLBMP_TILE));
+            const XFillBmpStretchItem& rStretchItem = mpProperties->GetItem(XATTR_FILLBMP_STRETCH);
+            const XFillBmpTileItem& rTileItem = mpProperties->GetItem(XATTR_FILLBMP_TILE);
             if( rTileItem.GetValue() )
             {
                 return Any( BitmapMode_REPEAT );
@@ -1226,7 +1226,7 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
         }
         case SDRATTR_TABLE_TEXT_ROTATION:
         {
-            const SvxTextRotateItem& rTextRotate = static_cast<const SvxTextRotateItem&>(mpProperties->GetItem(SDRATTR_TABLE_TEXT_ROTATION));
+            const SvxTextRotateItem& rTextRotate = mpProperties->GetItem(SDRATTR_TABLE_TEXT_ROTATION);
             return Any(sal_Int32(rTextRotate.GetValue() * 10));
         }
         default:


More information about the Libreoffice-commits mailing list