[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Oct 25 16:15:06 UTC 2018
sw/qa/extras/htmlimport/data/reqif-page-style.xhtml | 1
sw/qa/extras/htmlimport/htmlimport.cxx | 8 +++++
sw/source/filter/html/swhtml.cxx | 31 ++++++++++++--------
sw/source/filter/html/swhtml.hxx | 6 +--
sw/source/filter/inc/fltini.hxx | 5 +++
5 files changed, 36 insertions(+), 15 deletions(-)
New commits:
commit 4168118731f5e89bd945c7504d14d30c77dea138
Author: Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Thu Oct 25 14:22:02 2018 +0200
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Oct 25 18:00:43 2018 +0200
sw HTML import: avoid custom default page style in reqif mode
Would be "HTML" by default, but reqif-html is mostly very simple
documents and the custom page styles is unexpected.
Reviewed-on: https://gerrit.libreoffice.org/62317
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins
(cherry picked from commit 094e7b6a1028620c2b1503de8b51dc6a2482e290)
Conflicts:
sw/source/filter/html/swhtml.cxx
sw/source/filter/html/swhtml.hxx
Change-Id: I3f1b293bcd074305cf5cc87f03248e934d5fac4d
diff --git a/sw/qa/extras/htmlimport/data/reqif-page-style.xhtml b/sw/qa/extras/htmlimport/data/reqif-page-style.xhtml
new file mode 100644
index 000000000000..36f5aa11768b
--- /dev/null
+++ b/sw/qa/extras/htmlimport/data/reqif-page-style.xhtml
@@ -0,0 +1 @@
+<reqif-xhtml:p>aaa<reqif-xhtml:br/>bbb</reqif-xhtml:p>
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index 91e33f863d07..4d5cdb5c37b6 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -269,6 +269,14 @@ DECLARE_HTMLIMPORT_TEST(testReqIfTable, "reqif-table.xhtml")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xCell, "BackColor"));
}
+DECLARE_HTMLIMPORT_TEST(testReqIfPageStyle, "reqif-page-style.xhtml")
+{
+ // Without the accompanying fix in place, this test would have failed with
+ // 'Expected: Standard, Actual : HTML'.
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+ getProperty<OUString>(getParagraph(1), "PageStyleName"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 2dc52ea140e9..1fa50556e127 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -198,6 +198,8 @@ bool HTMLReader::SetStrmStgPtr()
// Aufruf fuer die allg. Reader-Schnittstelle
sal_uLong HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, const OUString & rName )
{
+ SetupFilterOptions();
+
if( !pStrm )
{
OSL_ENSURE( pStrm, "HTML-Read without stream" );
@@ -210,7 +212,7 @@ sal_uLong HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam,
// Set the HTML page style, when it isn't a HTML document,
// otherwise it's already set.
- if( !rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
+ if( !rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && m_aNamespace != "reqif-xhtml" )
{
rDoc.getIDocumentContentOperations().InsertPoolItem( rPam, SwFormatPageDesc(
rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_HTML, false )) );
@@ -223,7 +225,7 @@ sal_uLong HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam,
tools::SvRef<SwHTMLParser> xParser = new SwHTMLParser( &rDoc, rPam, *pStrm,
rName, rBaseURL, !bInsertMode, pMedium,
IsReadUTF8(),
- bIgnoreHTMLComments );
+ bIgnoreHTMLComments, m_aNamespace );
SvParserState eState = xParser->CallParser();
@@ -247,7 +249,8 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
const OUString& rBaseURL,
bool bReadNewDoc,
SfxMedium* pMed, bool bReadUTF8,
- bool bNoHTMLComments )
+ bool bNoHTMLComments,
+ const OUString& rNamespace )
: SfxHTMLParser( rIn, bReadNewDoc, pMed ),
SwClient( nullptr ),
m_aPathToFile( rPath ),
@@ -415,7 +418,13 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
}
}
- SetupFilterOptions();
+ if (!rNamespace.isEmpty())
+ {
+ SetNamespace(rNamespace);
+ m_bXHTML = true;
+ if (rNamespace == "reqif-xhtml")
+ m_bReqIF = true;
+ }
}
SwHTMLParser::~SwHTMLParser()
@@ -5564,12 +5573,15 @@ void SwHTMLParser::AddMetaUserDefined( OUString const & i_rMetaName )
}
}
-void SwHTMLParser::SetupFilterOptions()
+void HTMLReader::SetupFilterOptions()
{
- if (!GetMedium())
+ // Reset state from previous Read() invocation.
+ m_aNamespace.clear();
+
+ if (!pMedium)
return;
- const SfxItemSet* pItemSet = GetMedium()->GetItemSet();
+ const SfxItemSet* pItemSet = pMedium->GetItemSet();
if (!pItemSet)
return;
@@ -5582,10 +5594,7 @@ void SwHTMLParser::SetupFilterOptions()
if (aFilterOptions.startsWith(aXhtmlNsKey))
{
OUString aNamespace = aFilterOptions.copy(aXhtmlNsKey.getLength());
- SetNamespace(aNamespace);
- m_bXHTML = true;
- if (aNamespace == "reqif-xhtml")
- m_bReqIF = true;
+ m_aNamespace = aNamespace;
}
}
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 05aa01fa6431..41ad4af41332 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -865,9 +865,6 @@ private:
bool HasCurrentParaFlys( bool bNoSurroundOnly = false,
bool bSurroundOnly = false ) const;
- /// Parse FilterOptions passed to the importer.
- void SetupFilterOptions();
-
public: // used in tables
// Create brush item (with new) or 0
@@ -894,7 +891,8 @@ public:
const OUString& rBaseURL,
bool bReadNewDoc,
SfxMedium* pMed = nullptr, bool bReadUTF8 = false,
- bool bIgnoreHTMLComments = false );
+ bool bIgnoreHTMLComments = false,
+ const OUString& rNamespace = OUString());
virtual SvParserState CallParser() override;
diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx
index 7e01449b1b3c..01db2ec737c7 100644
--- a/sw/source/filter/inc/fltini.hxx
+++ b/sw/source/filter/inc/fltini.hxx
@@ -35,6 +35,11 @@ class HTMLReader: public Reader
virtual bool SetStrmStgPtr() override;
virtual sal_uLong Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) override;
virtual OUString GetTemplateName(SwDoc& rDoc) const override;
+
+ /// Parse FilterOptions passed to the importer.
+ void SetupFilterOptions();
+
+ OUString m_aNamespace;
public:
HTMLReader();
};
More information about the Libreoffice-commits
mailing list