summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx13
-rw-r--r--sw/source/filter/html/css1atr.cxx33
-rw-r--r--sw/source/filter/html/htmltabw.cxx11
-rw-r--r--sw/source/filter/html/wrthtml.hxx4
4 files changed, 34 insertions, 27 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 6eb45ff90882..f659eba0b1c8 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -468,12 +468,9 @@ DECLARE_HTMLEXPORT_TEST(testReqIfTable, "reqif-table.xhtml")
// <div> was missing, so the XHTML fragment wasn't a valid
// xhtml.BlkStruct.class type anymore.
assertXPath(pDoc, "/html/body/div/table/tr/th", 1);
- OUString aStyle = getXPath(pDoc, "/html/body/div/table/tr/th", "style");
- CPPUNIT_ASSERT(aStyle.indexOf("background") != -1);
- // This failed, there were 2 style attributes, so as a best effort the
- // parser took the value of the first.
- CPPUNIT_ASSERT(aStyle.indexOf("border") != -1);
-
+ // The attribute was present to contain "background" and "border", which is
+ // ignored in reqif-xhtml.
+ assertXPathNoAttribute(pDoc, "/html/body/div/table/tr/th", "style");
// The attribute was present, which is not valid in reqif-xhtml.
assertXPathNoAttribute(pDoc, "/html/body/div/table/tr/th", "bgcolor");
}
@@ -488,6 +485,10 @@ DECLARE_HTMLEXPORT_TEST(testReqIfList, "reqif-list.xhtml")
OString aStream(read_uInt8s_ToOString(*pStream, nLength));
// This failed, <ul> was written.
CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:ul>") != -1);
+
+ // This failed, the 'style' attribute was written, even if the input did
+ // not had one.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), aStream.indexOf(" style=\""));
}
DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOle2, "reqif-ole2.xhtml")
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index b3125aff5e75..b0cceca051d1 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -190,6 +190,21 @@ OString lclGetCSS1Color(const Color& rColor)
return "#" + lclConvToHex(rColor.GetRed()) + lclConvToHex(rColor.GetGreen()) + lclConvToHex(rColor.GetBlue());
}
+/// Determines if rProperty has to be suppressed due to ReqIF mode.
+bool IgnorePropertyForReqIF(bool bReqIF, const OString& rProperty)
+{
+ if (!bReqIF)
+ return false;
+
+ // Only allow these two keys, nothing else in ReqIF mode.
+ if (rProperty == sCSS1_P_text_decoration)
+ return false;
+
+ if (rProperty == sCSS1_P_color)
+ return false;
+
+ return true;
+}
}
class SwCSS1OutMode
@@ -220,6 +235,9 @@ void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
const sal_Char *pVal,
const OUString *pSVal )
{
+ if (IgnorePropertyForReqIF(mbReqIF, pProp))
+ return;
+
OStringBuffer sOut;
if( m_bFirstCSS1Rule && (m_nCSS1OutMode & CSS1_OUTMODE_RULE_ON)!=0 )
@@ -1818,7 +1836,7 @@ Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
}
// Wrapper for Table background
-Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt, bool bClose )
+Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
@@ -1827,7 +1845,7 @@ Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt, bool bClo
CSS1_OUTMODE_TABLEBOX, nullptr );
OutCSS1_SvxBrush( rWrt, rHt, Css1Background::Table, nullptr );
- if( !rHTMLWrt.m_bFirstCSS1Property && bClose )
+ if( !rHTMLWrt.m_bFirstCSS1Property )
rWrt.Strm().WriteChar( '\"' );
return rWrt;
@@ -2085,19 +2103,12 @@ void SwHTMLWriter::OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameF
Strm().WriteChar( '\"' );
}
-void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrameFormat const& rFrameFormat, bool bClose)
+void SwHTMLWriter::OutCSS1_TableCellBorderHack(SwFrameFormat const& rFrameFormat)
{
- bool bFirstCSS1Property = m_bFirstCSS1Property;
-
SwCSS1OutMode const aMode( *this,
CSS1_OUTMODE_STYLE_OPT_ON|CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_TABLEBOX, nullptr );
-
- if (!bFirstCSS1Property)
- // Don't start the style attribute again if it was started already.
- m_bFirstCSS1Property = bFirstCSS1Property;
-
OutCSS1_SvxBox(*this, rFrameFormat.GetBox());
- if (!m_bFirstCSS1Property && bClose)
+ if (!m_bFirstCSS1Property)
{
Strm().WriteChar( cCSS1_style_opt_end );
}
diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx
index 60a913e1ac7a..c47680ad763e 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -410,7 +410,6 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
if( !pBrushItem )
pBrushItem = pCell->GetBackground();
- // Start writing the style attribute.
if( pBrushItem )
{
// output background
@@ -419,14 +418,10 @@ void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
rWrt.OutBackground( pBrushItem, false );
if( rWrt.m_bCfgOutStyles )
- OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem, /*bClose=*/false );
+ OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
}
- rWrt.OutCSS1_TableCellBorderHack(*pBox->GetFrameFormat(), /*bClose=*/false);
-
- // Now is the time to end the style attribute.
- if (!rWrt.m_bFirstCSS1Property)
- rWrt.Strm().WriteChar('\"');
+ rWrt.OutCSS1_TableCellBorderHack(*pBox->GetFrameFormat());
sal_uInt32 nNumFormat = 0;
double nValue = 0.0;
@@ -530,7 +525,7 @@ void SwHTMLWrtTable::OutTableCells( SwHTMLWriter& rWrt,
rWrt.m_bTextAttr = false;
rWrt.m_bOutOpts = true;
if( rWrt.m_bCfgOutStyles )
- OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem, /*bClose=*/true );
+ OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
}
if( text::VertOrientation::TOP==eRowVertOri || text::VertOrientation::BOTTOM==eRowVertOri )
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 8b3725dfce4f..cb7808a8f26d 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -477,7 +477,7 @@ public:
void writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameFormat& rFrameFormat, const OUString& rAltText, HtmlFrmOpts nFrameOpts);
void OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameFormat );
- void OutCSS1_TableCellBorderHack(const SwFrameFormat& rFrameFormat, bool bClose);
+ void OutCSS1_TableCellBorderHack(const SwFrameFormat& rFrameFormat);
void OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, const SwFormatCol *pCol );
void OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat, HtmlFrmOpts nFrameOpts,
const SdrObject *pSdrObj=nullptr,
@@ -675,7 +675,7 @@ Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet );
Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt );
Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
-Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt, bool bClose );
+Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt );
Writer& OutCSS1_NumBulListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
sal_uInt8 nLevel );