summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2018-05-10 15:36:11 +0300
committerMiklos Vajna <vmiklos@collabora.com>2020-05-18 12:36:49 +0200
commit18d709afb444a245b3ef7d036f559d5bb4c43d28 (patch)
treec8f41b3896a048b143298c8d6d426a600ce3ae1b
parent4afd0c5935655d5073495b3461123a2ce5de87c1 (diff)
tdf#117504 ooxmlimport: check paragraph props for actual style
m_sCurrentParaStyleName sounds like a nice idea, and has been around since the initial fork, but by the time finishParagraph() rolls around, the chances that it is still accurate are rather low. Anything that contains a paragraph (like comments, textboxes, shapes, tables, flys etc) might have modified that value. This fix queries the current paragraph itself to see if PROP_PARA_STYLE_NAME is set, which it typically is by lcl_startParagraphGroup() except when IsInShape(). If it isn't specified, then fallback to the previous result, which still may not be accurate, but at least it won't be a regression. It is too late in the development cycle to look into fully eliminating m_sCurrentParaStyleName. I hope to investigate that in the 6.2 development cycle. (cherry picked from commit 8920d865ee148518bf71f71ce1866b24cc17c07e) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport12.cxx Change-Id: I124688d864f553dd5778b3593f511cc41d31c262
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf117504_numberingIndent.docxbin0 -> 17711 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx6
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx11
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx4
4 files changed, 19 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf117504_numberingIndent.docx b/sw/qa/extras/ooxmlexport/data/tdf117504_numberingIndent.docx
new file mode 100644
index 000000000000..091718984540
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf117504_numberingIndent.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index a4e435c62f78..2d62c3f9f003 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -456,6 +456,12 @@ DECLARE_OOXMLIMPORT_TEST(testTdf128207, "tdf128207.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(12), getProperty<sal_Int32>(getShape(1), "HoriOrientPosition"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf117504_numberingIndent, "tdf117504_numberingIndent.docx")
+{
+ OUString sName = getProperty<OUString>(getParagraph(1), "NumberingStyleName");
+ CPPUNIT_ASSERT_MESSAGE("Paragraph has numbering style", !sName.isEmpty());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index cdc0fadaef64..3cc02e469b00 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -650,6 +650,17 @@ uno::Sequence< style::TabStop > DomainMapper_Impl::GetCurrentTabStopAndClear()
return comphelper::containerToSequence(aRet);
}
+const OUString DomainMapper_Impl::GetCurrentParaStyleName()
+{
+ // use saved currParaStyleName as a fallback, in case no particular para style name applied.
+ OUString sName = m_sCurrentParaStyleName;
+ PropertyMapPtr pParaContext = GetTopContextOfType(CONTEXT_PARAGRAPH);
+ if ( pParaContext && pParaContext->isSet(PROP_PARA_STYLE_NAME) )
+ pParaContext->getProperty(PROP_PARA_STYLE_NAME)->second >>= sName;
+
+ return sName;
+}
+
/*-------------------------------------------------------------------------
returns a the value from the current paragraph style - if available
TODO: What about parent styles?
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 6a54487e1818..1b04f0a18f67 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -474,7 +474,7 @@ private:
PropertyMapPtr m_pLastCharacterContext;
::std::vector<DeletableTabStop> m_aCurrentTabStops;
- OUString m_sCurrentParaStyleName;
+ OUString m_sCurrentParaStyleName; //highly inaccurate. Overwritten by "overlapping" paragraphs like comments, flys.
bool m_bInStyleSheetImport; //in import of fonts, styles, lists or lfos
bool m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
bool m_bInHeaderFooterImport;
@@ -694,7 +694,7 @@ public:
css::uno::Sequence<css::style::TabStop> GetCurrentTabStopAndClear();
void SetCurrentParaStyleName(const OUString& sStringValue) {m_sCurrentParaStyleName = sStringValue;}
- const OUString& GetCurrentParaStyleName() const {return m_sCurrentParaStyleName;}
+ const OUString GetCurrentParaStyleName();
css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId);
void SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}