include/oox/ole/axbinarywriter.hxx       |    2 +-
 include/oox/ole/axfontdata.hxx           |    8 ++++----
 oox/source/ole/axcontrol.cxx             |   14 +++++++-------
 oox/source/ole/axfontdata.cxx            |   10 ++++++----
 sc/source/filter/oox/drawingfragment.cxx |    8 ++++----
 5 files changed, 22 insertions(+), 20 deletions(-)

New commits:
commit 4f55dfb564e56515b6ebb4d10b089f67ad628fb6
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Wed Apr 12 13:24:09 2017 +0200

    convert AX_FONTDATA constants to scoped enum
    
    Change-Id: I0de365c8f654973f483d09fc9170f40bda7cbd9e
    Reviewed-on: https://gerrit.libreoffice.org/36457
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/oox/ole/axbinarywriter.hxx 
b/include/oox/ole/axbinarywriter.hxx
index d1fe1a23fcea..c8b1bdb29158 100644
--- a/include/oox/ole/axbinarywriter.hxx
+++ b/include/oox/ole/axbinarywriter.hxx
@@ -85,7 +85,7 @@ public:
     /** Write an integer property value to the stream, the
         respective flag in the property mask is set. */
     template< typename StreamType, typename DataType >
-    void                writeIntProperty( DataType& ornValue )
+    void                writeIntProperty( DataType ornValue )
                             { if( startNextProperty() ) 
maOutStrm.writeAligned< StreamType >( ornValue ); }
     /** Write a boolean property value to the stream, the
         respective flag in the property mask is set. */
diff --git a/include/oox/ole/axfontdata.hxx b/include/oox/ole/axfontdata.hxx
index 3e01af488da4..c255747357fa 100644
--- a/include/oox/ole/axfontdata.hxx
+++ b/include/oox/ole/axfontdata.hxx
@@ -39,9 +39,9 @@ const sal_uInt32 AX_FONTDATA_STRIKEOUT      = 0x00000008;
 const sal_uInt32 AX_FONTDATA_DISABLED       = 0x00002000;
 const sal_uInt32 AX_FONTDATA_AUTOCOLOR      = 0x40000000;
 
-const sal_Int32 AX_FONTDATA_LEFT            = 1;
-const sal_Int32 AX_FONTDATA_RIGHT           = 2;
-const sal_Int32 AX_FONTDATA_CENTER          = 3;
+enum class AxHorizontalAlign {
+    Left = 1, Right = 2, Center = 3
+};
 
 /** All entries of a font property. */
 struct OOX_DLLPUBLIC AxFontData
@@ -50,7 +50,7 @@ struct OOX_DLLPUBLIC AxFontData
     sal_uInt32          mnFontEffects;      ///< Font effect flags.
     sal_Int32           mnFontHeight;       ///< Height of the font (not 
really twips, see code).
     sal_Int32           mnFontCharSet;      ///< Windows character set of the 
font.
-    sal_Int32           mnHorAlign;         ///< Horizontal text alignment.
+    AxHorizontalAlign   mnHorAlign;         ///< Horizontal text alignment.
     bool                mbDblUnderline;     ///< True = double underline style 
(legacy VML drawing controls only).
 
     explicit            AxFontData();
diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx
index 889c7ad7ae05..283c0e48dc61 100644
--- a/oox/source/ole/axcontrol.cxx
+++ b/oox/source/ole/axcontrol.cxx
@@ -854,7 +854,7 @@ void AxFontDataModel::importProperty( sal_Int32 nPropId, 
const OUString& rValue
         case XML_FontEffects:       maFontData.mnFontEffects = 
AttributeConversion::decodeUnsigned( rValue );   break;
         case XML_FontHeight:        maFontData.mnFontHeight = 
AttributeConversion::decodeInteger( rValue );     break;
         case XML_FontCharSet:       maFontData.mnFontCharSet = 
AttributeConversion::decodeInteger( rValue );    break;
-        case XML_ParagraphAlign:    maFontData.mnHorAlign = 
AttributeConversion::decodeInteger( rValue );       break;
+        case XML_ParagraphAlign:    maFontData.mnHorAlign = 
static_cast<AxHorizontalAlign>(AttributeConversion::decodeInteger( rValue )); 
break;
         default:                    AxControlModelBase::importProperty( 
nPropId, rValue );
     }
 }
@@ -894,9 +894,9 @@ void AxFontDataModel::convertProperties( PropertyMap& 
rPropMap, const ControlCon
         sal_Int32 nAlign = awt::TextAlign::LEFT;
         switch( maFontData.mnHorAlign )
         {
-            case AX_FONTDATA_LEFT:      nAlign = awt::TextAlign::LEFT;   break;
-            case AX_FONTDATA_RIGHT:     nAlign = awt::TextAlign::RIGHT;  break;
-            case AX_FONTDATA_CENTER:    nAlign = awt::TextAlign::CENTER; break;
+            case AxHorizontalAlign::Left:      nAlign = awt::TextAlign::LEFT;  
 break;
+            case AxHorizontalAlign::Right:     nAlign = awt::TextAlign::RIGHT; 
 break;
+            case AxHorizontalAlign::Center:    nAlign = 
awt::TextAlign::CENTER; break;
             default:    OSL_FAIL( "AxFontDataModel::convertProperties - 
unknown text alignment" );
         }
         // form controls expect short value
@@ -934,9 +934,9 @@ void AxFontDataModel::convertFromProperties( PropertySet& 
rPropSet, const Contro
     {
         switch ( nAlign )
         {
-            case awt::TextAlign::LEFT: maFontData.mnHorAlign = 
AX_FONTDATA_LEFT;   break;
-            case awt::TextAlign::RIGHT: maFontData.mnHorAlign = 
AX_FONTDATA_RIGHT;  break;
-            case awt::TextAlign::CENTER: maFontData.mnHorAlign = 
AX_FONTDATA_CENTER; break;
+            case awt::TextAlign::LEFT: maFontData.mnHorAlign = 
AxHorizontalAlign::Left;   break;
+            case awt::TextAlign::RIGHT: maFontData.mnHorAlign = 
AxHorizontalAlign::Right;  break;
+            case awt::TextAlign::CENTER: maFontData.mnHorAlign = 
AxHorizontalAlign::Center; break;
             default:    OSL_FAIL( "AxFontDataModel::convertFromProperties - 
unknown text alignment" );
         }
     }
diff --git a/oox/source/ole/axfontdata.cxx b/oox/source/ole/axfontdata.cxx
index 549d807a0e36..22a31b0e15e5 100644
--- a/oox/source/ole/axfontdata.cxx
+++ b/oox/source/ole/axfontdata.cxx
@@ -29,7 +29,7 @@ AxFontData::AxFontData() :
     mnFontEffects( 0 ),
     mnFontHeight( 160 ),
     mnFontCharSet( WINDOWS_CHARSET_DEFAULT ),
-    mnHorAlign( AX_FONTDATA_LEFT ),
+    mnHorAlign( AxHorizontalAlign::Left ),
     mbDblUnderline( false )
 {
 }
@@ -56,7 +56,9 @@ bool AxFontData::importBinaryModel( BinaryInputStream& 
rInStrm )
     aReader.skipIntProperty< sal_Int32 >(); // font offset
     aReader.readIntProperty< sal_uInt8 >( mnFontCharSet );
     aReader.skipIntProperty< sal_uInt8 >(); // font pitch/family
-    aReader.readIntProperty< sal_uInt8 >( mnHorAlign );
+    sal_uInt8 nTmp = 0;
+    aReader.readIntProperty< sal_uInt8 >( nTmp );
+    mnHorAlign = static_cast<AxHorizontalAlign>(nTmp);
     aReader.skipIntProperty< sal_uInt16 >(); // font weight
     mbDblUnderline = false;
     return aReader.finalizeImport();
@@ -73,7 +75,7 @@ void AxFontData::exportBinaryModel( BinaryOutputStream& 
rOutStrm )
     aWriter.writeIntProperty< sal_uInt8 >( mnFontCharSet );
     aWriter.skipProperty(); // font pitch/family
 
-    aWriter.writeIntProperty< sal_uInt8 >( mnHorAlign );
+    aWriter.writeIntProperty< sal_uInt8 >( static_cast<sal_uInt8>(mnHorAlign) 
);
     aWriter.skipProperty(); // font weight
     aWriter.finalizeExport();
 }
@@ -93,7 +95,7 @@ bool AxFontData::importStdFont( BinaryInputStream& rInStrm )
         // StdFont stores font height in 1/10,000 of points
         setHeightPoints( getLimitedValue< sal_Int16, sal_Int32 >( 
aFontInfo.mnHeight / 10000, 0, SAL_MAX_INT16 ) );
         mnFontCharSet = aFontInfo.mnCharSet;
-        mnHorAlign = AX_FONTDATA_LEFT;
+        mnHorAlign = AxHorizontalAlign::Left;
         return true;
     }
     return false;
diff --git a/sc/source/filter/oox/drawingfragment.cxx 
b/sc/source/filter/oox/drawingfragment.cxx
index d22c06163240..6f34a89c3c54 100644
--- a/sc/source/filter/oox/drawingfragment.cxx
+++ b/sc/source/filter/oox/drawingfragment.cxx
@@ -735,10 +735,10 @@ void VmlDrawing::convertControlText( AxFontData& 
rAxFontData, sal_uInt32& rnOleT
 
     switch( nTextHAlign )
     {
-        case XML_Left:      rAxFontData.mnHorAlign = AX_FONTDATA_LEFT;      
break;
-        case XML_Center:    rAxFontData.mnHorAlign = AX_FONTDATA_CENTER;    
break;
-        case XML_Right:     rAxFontData.mnHorAlign = AX_FONTDATA_RIGHT;     
break;
-        default:            rAxFontData.mnHorAlign = AX_FONTDATA_LEFT;
+        case XML_Left:      rAxFontData.mnHorAlign = AxHorizontalAlign::Left;  
    break;
+        case XML_Center:    rAxFontData.mnHorAlign = 
AxHorizontalAlign::Center;    break;
+        case XML_Right:     rAxFontData.mnHorAlign = AxHorizontalAlign::Right; 
    break;
+        default:            rAxFontData.mnHorAlign = AxHorizontalAlign::Left;
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to