sw reqif-xhtml export: fix non-well-formed output on Chinese text
And also search for the '"<" OOO_something' pattern, and fix up all cases where we forgot to call GetNamespace() when opening an element. Change-Id: I015e807c1ad0f96c7c4aaa97f7f61ae134cf3754 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86701 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
parent
b3185eb977
commit
186ef501a3
10 changed files with 40 additions and 19 deletions
BIN
sw/qa/extras/htmlexport/data/reqif-chinese.odt
Normal file
BIN
sw/qa/extras/htmlexport/data/reqif-chinese.odt
Normal file
Binary file not shown.
|
@ -761,6 +761,28 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testRTFOLEMimeType)
|
|||
aType);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testChinese)
|
||||
{
|
||||
// Load a document with Chinese text in it.
|
||||
OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "reqif-chinese.odt";
|
||||
mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument", {});
|
||||
|
||||
// Export it.
|
||||
uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
|
||||
uno::Sequence<beans::PropertyValue> aStoreProperties = {
|
||||
comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")),
|
||||
comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")),
|
||||
};
|
||||
xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties);
|
||||
SvMemoryStream aStream;
|
||||
HtmlExportTest::wrapFragment(maTempFile, aStream);
|
||||
xmlDocPtr pDoc = parseXmlStream(&aStream);
|
||||
|
||||
// Without the accompanying fix in place, this test would have failed as the output was not
|
||||
// well-formed.
|
||||
CPPUNIT_ASSERT(pDoc);
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -781,7 +781,7 @@ static void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
|
|||
// The align=... attribute does behave strange in netscape
|
||||
// if there are controls in a paragraph, because the control and
|
||||
// all text behind the control does not recognize this attribute.
|
||||
OString sOut = "<" OOO_STRING_SVTOOLS_HTML_division;
|
||||
OString sOut = "<" + rHWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_division;
|
||||
rWrt.Strm().WriteOString( sOut );
|
||||
|
||||
rHWrt.m_bTextAttr = false;
|
||||
|
@ -2648,7 +2648,7 @@ static Writer& OutHTML_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
|
|||
}
|
||||
else
|
||||
{
|
||||
OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font " "
|
||||
OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font " "
|
||||
OOO_STRING_SVTOOLS_HTML_O_color "=";
|
||||
rWrt.Strm().WriteOString( sOut );
|
||||
HTMLOutFuncs::Out_Color( rWrt.Strm(), aColor ).WriteChar( '>' );
|
||||
|
@ -2708,7 +2708,7 @@ static Writer& OutHTML_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
|
|||
}
|
||||
else
|
||||
{
|
||||
OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font " "
|
||||
OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font " "
|
||||
OOO_STRING_SVTOOLS_HTML_O_face "=\"";
|
||||
rWrt.Strm().WriteOString( sOut );
|
||||
HTMLOutFuncs::Out_String( rWrt.Strm(), aNames, rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters )
|
||||
|
@ -2748,7 +2748,7 @@ static Writer& OutHTML_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
|
|||
}
|
||||
else
|
||||
{
|
||||
OString sOut = "<" OOO_STRING_SVTOOLS_HTML_font;
|
||||
OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_font;
|
||||
|
||||
sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
|
||||
sal_uInt16 nSize = rHTMLWrt.GetHTMLFontSize( nHeight );
|
||||
|
@ -2788,7 +2788,7 @@ static Writer& OutHTML_SvxLanguage( Writer& rWrt, const SfxPoolItem& rHt )
|
|||
|
||||
if( rHTMLWrt.m_bTagOn )
|
||||
{
|
||||
OString sOut = "<" OOO_STRING_SVTOOLS_HTML_span;
|
||||
OString sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span;
|
||||
rWrt.Strm().WriteOString( sOut );
|
||||
rHTMLWrt.OutLanguage( static_cast<const SvxLanguageItem &>(rHt).GetLanguage() );
|
||||
rWrt.Strm().WriteChar( '>' );
|
||||
|
|
|
@ -245,7 +245,7 @@ void SwHTMLParser::InsertBasicDocEvent( const OUString& aEvent, const OUString&
|
|||
pDocSh );
|
||||
}
|
||||
|
||||
void SwHTMLWriter::OutBasic()
|
||||
void SwHTMLWriter::OutBasic(SwHTMLWriter & rHTMLWrt)
|
||||
{
|
||||
#if HAVE_FEATURE_SCRIPTING
|
||||
if( !m_bCfgStarBasic )
|
||||
|
@ -274,7 +274,7 @@ void SwHTMLWriter::OutBasic()
|
|||
bFirst = false;
|
||||
OutNewLine();
|
||||
OString sOut =
|
||||
"<" OOO_STRING_SVTOOLS_HTML_meta
|
||||
"<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_meta
|
||||
" " OOO_STRING_SVTOOLS_HTML_O_httpequiv
|
||||
"=\""
|
||||
OOO_STRING_SVTOOLS_HTML_META_content_script_type
|
||||
|
|
|
@ -442,6 +442,7 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pField,
|
|||
|
||||
Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
|
||||
{
|
||||
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
|
||||
const SwFormatField & rField = static_cast<const SwFormatField&>(rHt);
|
||||
const SwField* pField = rField.GetField();
|
||||
const SwFieldType* pFieldTyp = pField->GetTyp();
|
||||
|
@ -509,7 +510,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
|
|||
OUString sComment(convertLineEnd(rComment, GetSystemLineEnd()));
|
||||
// TODO: ???
|
||||
OString sOut =
|
||||
"<" OOO_STRING_SVTOOLS_HTML_comment
|
||||
"<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_comment
|
||||
" " +
|
||||
OUStringToOString(sComment, static_cast<SwHTMLWriter&>(rWrt).m_eDestEnc) +
|
||||
" -->";
|
||||
|
@ -518,7 +519,6 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
|
|||
}
|
||||
else if( SwFieldIds::Script == pFieldTyp->Which() )
|
||||
{
|
||||
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
|
||||
if( rHTMLWrt.m_bLFPossible )
|
||||
rHTMLWrt.OutNewLine( true );
|
||||
|
||||
|
@ -544,7 +544,6 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt )
|
|||
OSL_ENSURE( pTextField, "Where is the txt fld?" );
|
||||
if( pTextField )
|
||||
{
|
||||
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
|
||||
// ReqIF-XHTML doesn't allow specifying a background color.
|
||||
bool bFieldShadings = SwViewOption::IsFieldShadings() && !rHTMLWrt.mbReqIF;
|
||||
if (bFieldShadings)
|
||||
|
|
|
@ -1657,7 +1657,7 @@ static Writer& OutHTML_FrameFormatAsSpacer( Writer& rWrt, const SwFrameFormat& r
|
|||
rHTMLWrt.OutNewLine( true );
|
||||
|
||||
OString sOut =
|
||||
"<" OOO_STRING_SVTOOLS_HTML_spacer " "
|
||||
"<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_spacer " "
|
||||
OOO_STRING_SVTOOLS_HTML_O_type "=\""
|
||||
OOO_STRING_SVTOOLS_HTML_SPTYPE_block "\"";
|
||||
rWrt.Strm().WriteOString( sOut );
|
||||
|
|
|
@ -444,7 +444,7 @@ void SwHTMLWriter::OutForm( bool bOn,
|
|||
// the new form is opened
|
||||
if( m_bLFPossible )
|
||||
OutNewLine();
|
||||
OString sOut = "<" OOO_STRING_SVTOOLS_HTML_form;
|
||||
OString sOut = "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_form;
|
||||
|
||||
uno::Reference< beans::XPropertySet > xFormPropSet( rFormComps, uno::UNO_QUERY );
|
||||
|
||||
|
@ -573,7 +573,7 @@ void SwHTMLWriter::OutHiddenControls(
|
|||
{
|
||||
if( m_bLFPossible )
|
||||
OutNewLine( true );
|
||||
OString sOut = "<" OOO_STRING_SVTOOLS_HTML_input " "
|
||||
OString sOut = "<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_input " "
|
||||
OOO_STRING_SVTOOLS_HTML_O_type "=\""
|
||||
OOO_STRING_SVTOOLS_HTML_IT_hidden "\"";
|
||||
|
||||
|
@ -1200,7 +1200,7 @@ Writer& OutHTML_DrawFrameFormatAsControl( Writer& rWrt,
|
|||
nSel++;
|
||||
|
||||
rHTMLWrt.OutNewLine(); // every Option gets its own line
|
||||
sOut = "<" OOO_STRING_SVTOOLS_HTML_option;
|
||||
sOut = "<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_option;
|
||||
if( !sVal.isEmpty() || bEmptyVal )
|
||||
{
|
||||
sOut += " " OOO_STRING_SVTOOLS_HTML_O_value "=\"";
|
||||
|
|
|
@ -327,7 +327,7 @@ void SwHTMLWriter::OutFootEndNotes()
|
|||
if( m_bLFPossible )
|
||||
OutNewLine();
|
||||
OString sOut =
|
||||
"<" OOO_STRING_SVTOOLS_HTML_division
|
||||
"<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_division
|
||||
" " OOO_STRING_SVTOOLS_HTML_O_id "=\"";
|
||||
Strm().WriteOString( sOut );
|
||||
HTMLOutFuncs::Out_String( Strm(), sFootnoteName, m_eDestEnc, &m_aNonConvertableCharacters );
|
||||
|
@ -504,7 +504,7 @@ static void lcl_html_outFootEndNoteInfo( Writer& rWrt, OUString const *pParts,
|
|||
|
||||
rHTMLWrt.OutNewLine();
|
||||
OString sOut =
|
||||
"<" OOO_STRING_SVTOOLS_HTML_meta " "
|
||||
"<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_meta " "
|
||||
OOO_STRING_SVTOOLS_HTML_O_name "=\"" + rtl::OStringView(pName) +
|
||||
"\" " OOO_STRING_SVTOOLS_HTML_O_content "=\"";
|
||||
rWrt.Strm().WriteOString( sOut );
|
||||
|
|
|
@ -418,7 +418,7 @@ ErrCode SwHTMLWriter::WriteStream()
|
|||
&m_aNonConvertableCharacters );
|
||||
|
||||
aStartTags =
|
||||
"<" OOO_STRING_SVTOOLS_HTML_division
|
||||
"<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_division
|
||||
" " OOO_STRING_SVTOOLS_HTML_O_id
|
||||
"=\"" + aName + "\">" +
|
||||
aStartTags;
|
||||
|
@ -1053,7 +1053,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
|
|||
|
||||
// and now ... the BASIC and JavaScript!
|
||||
if( m_pDoc->GetDocShell() ) // only with DocShell BASIC is possible
|
||||
OutBasic();
|
||||
OutBasic(*this);
|
||||
|
||||
DecIndentLevel(); // indent content of <HEAD>
|
||||
OutNewLine();
|
||||
|
|
|
@ -445,7 +445,7 @@ public:
|
|||
void OutFootEndNoteSym( const SwFormatFootnote& rFormatFootnote, const OUString& rNum,
|
||||
sal_uInt16 nScript );
|
||||
|
||||
void OutBasic();
|
||||
void OutBasic(SwHTMLWriter& rHTMLWrt);
|
||||
|
||||
void OutAndSetDefList( sal_uInt16 nNewLvl );
|
||||
|
||||
|
|
Loading…
Reference in a new issue