tdf#129522 ww8import/export: allow char shadow_NONE overrides
An earlier patch did this for paragraphs. The same is needed
for character properties.
This also applies to borders - where a non-border needs to be
processed in order to override a style-defined border.
This export change doesn't affect DOCX immediately, because
DOCX will do nothing with a NONE-border/shadow until style
information is provided to it. So this change is safe to make
on it's own as far as DOCX is concerned.
RTF just exports the border, but since it doesn't do any of
this well, add in the logic so that RTF is unaffected...
Change-Id: Ia857dc0db7d7efc83145a14e4fe4052d32b539ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85760
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 231aaabe..103476d 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -305,7 +305,7 @@ DECLARE_WW8EXPORT_TEST(testTdf129522_removeShadowStyle, "tdf129522_removeShadowS
xStyleProps.set(characterStyles->getByName("CharShadow-removed"), uno::UNO_QUERY_THROW);
aShadow = getProperty<table::ShadowFormat>(xStyleProps, "CharShadowFormat");
//CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
}
DECLARE_WW8EXPORT_TEST(testBtlrCell, "btlr-cell.doc")
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 152f514..58b2e2c 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -101,7 +101,7 @@ static OString OutTBLBorderLine(RtfExport const& rExport, const editeng::SvxBord
const char* pStr)
{
OStringBuffer aRet;
if (!pLine->isEmpty())
if (pLine && !pLine->isEmpty())
{
aRet.append(pStr);
// single line
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 1cd428a..41a2d9c 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -5508,11 +5508,12 @@ void AttributeOutputBase::FormatCharBorder( const SvxBoxItem& rBox )
nDist = rBox.GetDistance( SvxBoxItemLine::RIGHT );
}
if( pBorderLine )
// RTF: avoid regressions since RTF doesn't know how to export a border_NONE style-override
if( pBorderLine || GetExport().GetExportFormat() != MSWordExportBase::ExportFormat::RTF )
{
const SfxPoolItem* pItem = GetExport().HasItem( RES_CHRATR_SHADOW );
const SvxShadowItem* pShadowItem = static_cast<const SvxShadowItem*>(pItem);
const bool bShadow =
const bool bShadow = pBorderLine &&
pShadowItem && pShadowItem->GetLocation() != SvxShadowLocation::NONE &&
pShadowItem->GetWidth() > 0;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index c402154..e33a691 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -5056,8 +5056,6 @@ void SwWW8ImplReader::Read_CharBorder(sal_uInt16 nId, const sal_uInt8* pData, sh
SetWW8_BRC(nBrcVer, aBrc, pData, nLen);
// Border style is none -> no border, no shadow
if( editeng::ConvertBorderStyleFromWord(aBrc.brcType()) != SvxBorderLineStyle::NONE )
{
Set1Border(*aBoxItem, aBrc, SvxBoxItemLine::TOP, 0, nullptr, true);
Set1Border(*aBoxItem, aBrc, SvxBoxItemLine::BOTTOM, 0, nullptr, true);
@@ -5067,8 +5065,10 @@ void SwWW8ImplReader::Read_CharBorder(sal_uInt16 nId, const sal_uInt8* pData, sh
short aSizeArray[WW8_RIGHT+1]={0}; aSizeArray[WW8_RIGHT] = 1;
SvxShadowItem aShadowItem(RES_CHRATR_SHADOW);
if( SetShadow( aShadowItem, &aSizeArray[0], aBrc ) )
NewAttr( aShadowItem );
// Word only allows shadows on visible borders
if ( aBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT ) )
SetShadow( aShadowItem, &aSizeArray[0], aBrc );
NewAttr( aShadowItem );
}
}
}