[Libreoffice-commits] core.git: include/oox oox/source sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Apr 13 10:02:46 UTC 2017
include/oox/ole/axfontdata.hxx | 25 ++++++++++++++++---------
oox/source/ole/axcontrol.cxx | 27 +++++++++++++++++----------
oox/source/ole/axfontdata.cxx | 18 ++++++++++--------
sc/source/filter/oox/drawingfragment.cxx | 10 +++++-----
4 files changed, 48 insertions(+), 32 deletions(-)
New commits:
commit 7bf1e66ac51a582527b35b852586cf7474bc7ba8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Apr 12 14:03:04 2017 +0200
convert AX_FONTDATA to o3tl::typed_flags
Change-Id: If51119fbdde4b1d923b794d126fdae99ca238f81
Reviewed-on: https://gerrit.libreoffice.org/36463
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/oox/ole/axfontdata.hxx b/include/oox/ole/axfontdata.hxx
index c255747357fa..fa79aef9d1a9 100644
--- a/include/oox/ole/axfontdata.hxx
+++ b/include/oox/ole/axfontdata.hxx
@@ -23,22 +23,29 @@
#include <oox/dllapi.h>
#include <rtl/ustring.hxx>
#include <sal/types.h>
+#include <o3tl/typed_flags_set.hxx>
namespace oox {
class BinaryInputStream;
class BinaryOutputStream;
}
+enum class AxFontFlags {
+ NONE = 0x00000000,
+ Bold = 0x00000001,
+ Italic = 0x00000002,
+ Underline = 0x00000004,
+ Strikeout = 0x00000008,
+ Disabled = 0x00002000,
+ AutoColor = 0x40000000,
+};
+namespace o3tl {
+ template<> struct typed_flags<AxFontFlags> : is_typed_flags<AxFontFlags, 0x4000200f> {};
+}
+
namespace oox {
namespace ole {
-const sal_uInt32 AX_FONTDATA_BOLD = 0x00000001;
-const sal_uInt32 AX_FONTDATA_ITALIC = 0x00000002;
-const sal_uInt32 AX_FONTDATA_UNDERLINE = 0x00000004;
-const sal_uInt32 AX_FONTDATA_STRIKEOUT = 0x00000008;
-const sal_uInt32 AX_FONTDATA_DISABLED = 0x00002000;
-const sal_uInt32 AX_FONTDATA_AUTOCOLOR = 0x40000000;
-
enum class AxHorizontalAlign {
Left = 1, Right = 2, Center = 3
};
@@ -46,8 +53,8 @@ enum class AxHorizontalAlign {
/** All entries of a font property. */
struct OOX_DLLPUBLIC AxFontData
{
- OUString maFontName; ///< Name of the used font.
- sal_uInt32 mnFontEffects; ///< Font effect flags.
+ OUString maFontName; ///< Name of the used font.
+ AxFontFlags 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.
AxHorizontalAlign mnHorAlign; ///< Horizontal text alignment.
diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx
index 283c0e48dc61..24b33d842840 100644
--- a/oox/source/ole/axcontrol.cxx
+++ b/oox/source/ole/axcontrol.cxx
@@ -851,10 +851,14 @@ void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue
switch( nPropId )
{
case XML_FontName: maFontData.maFontName = rValue; break;
- case XML_FontEffects: maFontData.mnFontEffects = AttributeConversion::decodeUnsigned( rValue ); break;
+ case XML_FontEffects:
+ maFontData.mnFontEffects = static_cast<AxFontFlags>(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 = static_cast<AxHorizontalAlign>(AttributeConversion::decodeInteger( rValue )); break;
+ case XML_ParagraphAlign:
+ maFontData.mnHorAlign = static_cast<AxHorizontalAlign>(AttributeConversion::decodeInteger( rValue ));
+ break;
default: AxControlModelBase::importProperty( nPropId, rValue );
}
}
@@ -875,10 +879,13 @@ void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlCon
rPropMap.setProperty( PROP_FontName, maFontData.maFontName );
// font effects
- rPropMap.setProperty( PROP_FontWeight, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_BOLD, awt::FontWeight::BOLD, awt::FontWeight::NORMAL ) );
- rPropMap.setProperty( PROP_FontSlant, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, FontSlant_ITALIC, FontSlant_NONE ) );
- rPropMap.setProperty( PROP_FontUnderline, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, maFontData.mbDblUnderline ? awt::FontUnderline::DOUBLE : awt::FontUnderline::SINGLE, awt::FontUnderline::NONE ) );
- rPropMap.setProperty( PROP_FontStrikeout, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, awt::FontStrikeout::SINGLE, awt::FontStrikeout::NONE ) );
+ rPropMap.setProperty( PROP_FontWeight, maFontData.mnFontEffects & AxFontFlags::Bold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL );
+ rPropMap.setProperty( PROP_FontSlant, maFontData.mnFontEffects & AxFontFlags::Italic ? FontSlant_ITALIC : FontSlant_NONE );
+ if (maFontData.mnFontEffects & AxFontFlags::Underline)
+ rPropMap.setProperty( PROP_FontUnderline, maFontData.mbDblUnderline ? awt::FontUnderline::DOUBLE : awt::FontUnderline::SINGLE );
+ else
+ rPropMap.setProperty( PROP_FontUnderline, awt::FontUnderline::NONE );
+ rPropMap.setProperty( PROP_FontStrikeout, maFontData.mnFontEffects & AxFontFlags::Strikeout ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE );
rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() );
// font character set
@@ -912,17 +919,17 @@ void AxFontDataModel::convertFromProperties( PropertySet& rPropSet, const Contro
rPropSet.getProperty( maFontData.maFontName, PROP_FontName );
float fontWeight = (float)0;
if ( rPropSet.getProperty(fontWeight, PROP_FontWeight ) )
- setFlag( maFontData.mnFontEffects, AX_FONTDATA_BOLD, ( fontWeight == awt::FontWeight::BOLD ) );
+ setFlag( maFontData.mnFontEffects, AxFontFlags::Bold, ( fontWeight == awt::FontWeight::BOLD ) );
FontSlant nSlant = FontSlant_NONE;
if ( rPropSet.getProperty( nSlant, PROP_FontSlant ) )
- setFlag( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, ( nSlant == FontSlant_ITALIC ) );
+ setFlag( maFontData.mnFontEffects, AxFontFlags::Italic, ( nSlant == FontSlant_ITALIC ) );
sal_Int16 nUnderLine = awt::FontUnderline::NONE;
if ( rPropSet.getProperty( nUnderLine, PROP_FontUnderline ) )
- setFlag( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, nUnderLine != awt::FontUnderline::NONE );
+ setFlag( maFontData.mnFontEffects, AxFontFlags::Underline, nUnderLine != awt::FontUnderline::NONE );
sal_Int16 nStrikeout = awt::FontStrikeout::NONE ;
if ( rPropSet.getProperty( nStrikeout, PROP_FontStrikeout ) )
- setFlag( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, nStrikeout != awt::FontStrikeout::NONE );
+ setFlag( maFontData.mnFontEffects, AxFontFlags::Strikeout, nStrikeout != awt::FontStrikeout::NONE );
float fontHeight = 0.0;
if ( rPropSet.getProperty( fontHeight, PROP_FontHeight ) )
diff --git a/oox/source/ole/axfontdata.cxx b/oox/source/ole/axfontdata.cxx
index 22a31b0e15e5..b3da64439a04 100644
--- a/oox/source/ole/axfontdata.cxx
+++ b/oox/source/ole/axfontdata.cxx
@@ -26,7 +26,7 @@ namespace oox {
namespace ole {
AxFontData::AxFontData() :
- mnFontEffects( 0 ),
+ mnFontEffects( AxFontFlags::NONE ),
mnFontHeight( 160 ),
mnFontCharSet( WINDOWS_CHARSET_DEFAULT ),
mnHorAlign( AxHorizontalAlign::Left ),
@@ -51,7 +51,9 @@ bool AxFontData::importBinaryModel( BinaryInputStream& rInStrm )
{
AxBinaryPropertyReader aReader( rInStrm );
aReader.readStringProperty( maFontName );
- aReader.readIntProperty< sal_uInt32 >( mnFontEffects );
+ sal_uInt32 nTmp32 = 0;
+ aReader.readIntProperty< sal_uInt32 >( nTmp32 );
+ mnFontEffects = static_cast<AxFontFlags>(nTmp32);
aReader.readIntProperty< sal_Int32 >( mnFontHeight );
aReader.skipIntProperty< sal_Int32 >(); // font offset
aReader.readIntProperty< sal_uInt8 >( mnFontCharSet );
@@ -68,7 +70,7 @@ void AxFontData::exportBinaryModel( BinaryOutputStream& rOutStrm )
{
AxBinaryPropertyWriter aWriter( rOutStrm );
aWriter.writeStringProperty( maFontName );
- aWriter.writeIntProperty< sal_uInt32 >( mnFontEffects );
+ aWriter.writeIntProperty< sal_uInt32 >( static_cast<sal_uInt32>(mnFontEffects) );
aWriter.writeIntProperty< sal_Int32 >( mnFontHeight );
aWriter.skipProperty(); // font offset
// TODO make AxFontDataModel::convertFromProperties convert the textencoding
@@ -86,11 +88,11 @@ bool AxFontData::importStdFont( BinaryInputStream& rInStrm )
if( OleHelper::importStdFont( aFontInfo, rInStrm, false ) )
{
maFontName = aFontInfo.maName;
- mnFontEffects = 0;
- setFlag( mnFontEffects, AX_FONTDATA_BOLD, aFontInfo.mnWeight >= OLE_STDFONT_BOLD );
- setFlag( mnFontEffects, AX_FONTDATA_ITALIC, getFlag( aFontInfo.mnFlags, OLE_STDFONT_ITALIC ) );
- setFlag( mnFontEffects, AX_FONTDATA_UNDERLINE, getFlag( aFontInfo.mnFlags, OLE_STDFONT_UNDERLINE ) );
- setFlag( mnFontEffects, AX_FONTDATA_STRIKEOUT, getFlag( aFontInfo.mnFlags,OLE_STDFONT_STRIKE ) );
+ mnFontEffects = AxFontFlags::NONE;
+ setFlag( mnFontEffects, AxFontFlags::Bold, aFontInfo.mnWeight >= OLE_STDFONT_BOLD );
+ setFlag( mnFontEffects, AxFontFlags::Italic, getFlag( aFontInfo.mnFlags, OLE_STDFONT_ITALIC ) );
+ setFlag( mnFontEffects, AxFontFlags::Underline, getFlag( aFontInfo.mnFlags, OLE_STDFONT_UNDERLINE ) );
+ setFlag( mnFontEffects, AxFontFlags::Strikeout, getFlag( aFontInfo.mnFlags,OLE_STDFONT_STRIKE ) );
mbDblUnderline = false;
// StdFont stores font height in 1/10,000 of points
setHeightPoints( getLimitedValue< sal_Int16, sal_Int32 >( aFontInfo.mnHeight / 10000, 0, SAL_MAX_INT16 ) );
diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx
index 6f34a89c3c54..9675067d168b 100644
--- a/sc/source/filter/oox/drawingfragment.cxx
+++ b/sc/source/filter/oox/drawingfragment.cxx
@@ -711,12 +711,12 @@ void VmlDrawing::convertControlFontData( AxFontData& rAxFontData, sal_uInt32& rn
rAxFontData.setHeightPoints( static_cast< sal_Int16 >( (rFontModel.monSize.get( 200 ) + 10) / 20 ) );
// font effects
- rAxFontData.mnFontEffects = 0;
- setFlag( rAxFontData.mnFontEffects, AX_FONTDATA_BOLD, rFontModel.mobBold.get( false ) );
- setFlag( rAxFontData.mnFontEffects, AX_FONTDATA_ITALIC, rFontModel.mobItalic.get( false ) );
- setFlag( rAxFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, rFontModel.mobStrikeout.get( false ) );
+ rAxFontData.mnFontEffects = AxFontFlags::NONE;
+ setFlag( rAxFontData.mnFontEffects, AxFontFlags::Bold, rFontModel.mobBold.get( false ) );
+ setFlag( rAxFontData.mnFontEffects, AxFontFlags::Italic, rFontModel.mobItalic.get( false ) );
+ setFlag( rAxFontData.mnFontEffects, AxFontFlags::Strikeout, rFontModel.mobStrikeout.get( false ) );
sal_Int32 nUnderline = rFontModel.monUnderline.get( XML_none );
- setFlag( rAxFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, nUnderline != XML_none );
+ setFlag( rAxFontData.mnFontEffects, AxFontFlags::Underline, nUnderline != XML_none );
rAxFontData.mbDblUnderline = nUnderline == XML_double;
// font color
More information about the Libreoffice-commits
mailing list