Turn BorderHandler::BorderPosition into scoped enum
...to avoid -Werror,-Wshadow from Clang trunk with <https://reviews.llvm.org/D52400> "Improve -Wshadow warnings with enumerators", warning about shadowing of BORDER_TOP/LEFT/BOTTOM/RIGHT in enum BorderPosition in writerfilter/source/dmapper/PropertyMap.hxx. Also, BorderPosition can apparently be made a private member of BorderHandler, which gives extra confidence that any other uses of BORDER_TOP/LEFT/BOTTOM/RIGHT across writerfilter/source/dmapper/ indeed meant to reference the other enum BorderPosition. And change BorderHandler::lcl_sprm to return early in default case, to avoid having to come up with some new BorderPosition sentinel value to represent "invalid pos". Change-Id: I31e535326627cec25a17b99485bf7cf56f4c66d3 Reviewed-on: https://gerrit.libreoffice.org/61896 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include "PropertyMap.hxx"
|
||||
#include "ConversionHelper.hxx"
|
||||
#include <com/sun/star/table/BorderLine2.hpp>
|
||||
#include <o3tl/enumarray.hxx>
|
||||
#include <o3tl/enumrange.hxx>
|
||||
#include <ooxml/resourceids.hxx>
|
||||
#include <filter/msfilter/util.hxx>
|
||||
#include <comphelper/sequence.hxx>
|
||||
@@ -42,9 +44,8 @@ m_nLineDistance(0),
|
||||
m_bShadow(false),
|
||||
m_bOOXML( bOOXML )
|
||||
{
|
||||
const int nBorderCount(BORDER_COUNT);
|
||||
std::fill_n(m_aFilledLines, nBorderCount, false);
|
||||
std::fill_n(m_aBorderLines, nBorderCount, table::BorderLine2());
|
||||
m_aFilledLines.fill(false);
|
||||
m_aBorderLines.fill(table::BorderLine2());
|
||||
}
|
||||
|
||||
BorderHandler::~BorderHandler()
|
||||
@@ -90,73 +91,70 @@ void BorderHandler::lcl_attribute(Id rName, Value & rVal)
|
||||
|
||||
void BorderHandler::lcl_sprm(Sprm & rSprm)
|
||||
{
|
||||
BorderPosition pos = BORDER_COUNT; // invalid pos
|
||||
BorderPosition pos;
|
||||
const bool rtl = false; // TODO detect
|
||||
OUString aBorderPos;
|
||||
switch( rSprm.getId())
|
||||
{
|
||||
case NS_ooxml::LN_CT_TblBorders_top:
|
||||
pos = BORDER_TOP;
|
||||
pos = BorderPosition::Top;
|
||||
aBorderPos = "top";
|
||||
break;
|
||||
case NS_ooxml::LN_CT_TblBorders_start:
|
||||
pos = rtl ? BORDER_RIGHT : BORDER_LEFT;
|
||||
pos = rtl ? BorderPosition::Right : BorderPosition::Left;
|
||||
aBorderPos = "start";
|
||||
break;
|
||||
case NS_ooxml::LN_CT_TblBorders_left:
|
||||
pos = BORDER_LEFT;
|
||||
pos = BorderPosition::Left;
|
||||
aBorderPos = "left";
|
||||
break;
|
||||
case NS_ooxml::LN_CT_TblBorders_bottom:
|
||||
pos = BORDER_BOTTOM;
|
||||
pos = BorderPosition::Bottom;
|
||||
aBorderPos = "bottom";
|
||||
break;
|
||||
case NS_ooxml::LN_CT_TblBorders_end:
|
||||
pos = rtl ? BORDER_LEFT : BORDER_RIGHT;
|
||||
pos = rtl ? BorderPosition::Left : BorderPosition::Right;
|
||||
aBorderPos = "end";
|
||||
break;
|
||||
case NS_ooxml::LN_CT_TblBorders_right:
|
||||
pos = BORDER_RIGHT;
|
||||
pos = BorderPosition::Right;
|
||||
aBorderPos = "right";
|
||||
break;
|
||||
case NS_ooxml::LN_CT_TblBorders_insideH:
|
||||
pos = BORDER_HORIZONTAL;
|
||||
pos = BorderPosition::Horizontal;
|
||||
aBorderPos = "insideH";
|
||||
break;
|
||||
case NS_ooxml::LN_CT_TblBorders_insideV:
|
||||
pos = BORDER_VERTICAL;
|
||||
pos = BorderPosition::Vertical;
|
||||
aBorderPos = "insideV";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
return;
|
||||
}
|
||||
if( pos != BORDER_COUNT )
|
||||
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
|
||||
if( pProperties.get())
|
||||
{
|
||||
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
|
||||
if( pProperties.get())
|
||||
std::vector<beans::PropertyValue> aSavedGrabBag;
|
||||
if (!m_aInteropGrabBagName.isEmpty())
|
||||
{
|
||||
std::vector<beans::PropertyValue> aSavedGrabBag;
|
||||
if (!m_aInteropGrabBagName.isEmpty())
|
||||
{
|
||||
aSavedGrabBag = m_aInteropGrabBag;
|
||||
m_aInteropGrabBag.clear();
|
||||
}
|
||||
pProperties->resolve(*this);
|
||||
if (!m_aInteropGrabBagName.isEmpty())
|
||||
{
|
||||
aSavedGrabBag.push_back(getInteropGrabBag(aBorderPos));
|
||||
m_aInteropGrabBag = aSavedGrabBag;
|
||||
}
|
||||
aSavedGrabBag = m_aInteropGrabBag;
|
||||
m_aInteropGrabBag.clear();
|
||||
}
|
||||
pProperties->resolve(*this);
|
||||
if (!m_aInteropGrabBagName.isEmpty())
|
||||
{
|
||||
aSavedGrabBag.push_back(getInteropGrabBag(aBorderPos));
|
||||
m_aInteropGrabBag = aSavedGrabBag;
|
||||
}
|
||||
ConversionHelper::MakeBorderLine( m_nLineWidth, m_nLineType, m_nLineColor,
|
||||
m_aBorderLines[ pos ], m_bOOXML );
|
||||
m_aFilledLines[ pos ] = true;
|
||||
}
|
||||
ConversionHelper::MakeBorderLine( m_nLineWidth, m_nLineType, m_nLineColor,
|
||||
m_aBorderLines[ pos ], m_bOOXML );
|
||||
m_aFilledLines[ pos ] = true;
|
||||
}
|
||||
|
||||
PropertyMapPtr BorderHandler::getProperties()
|
||||
{
|
||||
static const PropertyIds aPropNames[BORDER_COUNT] =
|
||||
static const o3tl::enumarray<BorderPosition, PropertyIds> aPropNames =
|
||||
{
|
||||
PROP_TOP_BORDER,
|
||||
PROP_LEFT_BORDER,
|
||||
@@ -169,7 +167,7 @@ PropertyMapPtr BorderHandler::getProperties()
|
||||
// don't fill in default properties
|
||||
if( m_bOOXML )
|
||||
{
|
||||
for( sal_Int32 nProp = 0; nProp < BORDER_COUNT; ++nProp)
|
||||
for( auto nProp: o3tl::enumrange<BorderPosition>())
|
||||
{
|
||||
if ( m_aFilledLines[nProp] ) {
|
||||
pPropertyMap->Insert( aPropNames[nProp], uno::makeAny( m_aBorderLines[nProp] ) );
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <memory>
|
||||
#include <com/sun/star/table/BorderLine2.hpp>
|
||||
#include <com/sun/star/beans/PropertyValue.hpp>
|
||||
#include <o3tl/enumarray.hxx>
|
||||
|
||||
namespace writerfilter {
|
||||
namespace dmapper
|
||||
@@ -31,20 +32,19 @@ namespace dmapper
|
||||
class PropertyMap;
|
||||
class BorderHandler : public LoggedProperties
|
||||
{
|
||||
public:
|
||||
private:
|
||||
//todo: order is a guess
|
||||
enum BorderPosition
|
||||
enum class BorderPosition
|
||||
{
|
||||
BORDER_TOP,
|
||||
BORDER_LEFT,
|
||||
BORDER_BOTTOM,
|
||||
BORDER_RIGHT,
|
||||
BORDER_HORIZONTAL,
|
||||
BORDER_VERTICAL,
|
||||
BORDER_COUNT
|
||||
Top,
|
||||
Left,
|
||||
Bottom,
|
||||
Right,
|
||||
Horizontal,
|
||||
Vertical,
|
||||
LAST = Vertical
|
||||
};
|
||||
|
||||
private:
|
||||
//values of the current border
|
||||
sal_Int32 m_nLineWidth;
|
||||
sal_Int32 m_nLineType;
|
||||
@@ -53,8 +53,8 @@ private:
|
||||
bool m_bShadow;
|
||||
bool const m_bOOXML;
|
||||
|
||||
bool m_aFilledLines[BORDER_COUNT];
|
||||
css::table::BorderLine2 m_aBorderLines[BORDER_COUNT];
|
||||
o3tl::enumarray<BorderPosition, bool> m_aFilledLines;
|
||||
o3tl::enumarray<BorderPosition, css::table::BorderLine2> m_aBorderLines;
|
||||
OUString m_aInteropGrabBagName;
|
||||
std::vector<css::beans::PropertyValue> m_aInteropGrabBag;
|
||||
void appendGrabBag(const OUString& aKey, const OUString& aValue);
|
||||
|
||||
Reference in New Issue
Block a user