aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2021-02-24 10:07:08 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-02-25 10:57:04 +0100
commit861ca1f5030f2f6b7fbdc3bb3ded3d11130673ed (patch)
tree86a3b9efd2c64ab798c6e01389b07ce509d065ca
parente469c262e289ad86e3e2fa2857f8388b7b16df47 (diff)
tdf#140572 writerfilter: ignore position in docDefaults
Despite the documentation saying that anything in docDefaults should apply everywhere unless it is overridden in a higher priority style, the subscript/superscript setting in docDefaults seems to be ignored. Makes sense in a way, but perhaps document those exceptions? I looked for documentation in both "docDefaults" and "position" and didn't see anything suggesting why it is ignored. Change-Id: If676415b112921e4cb8f7306b8c8ad93a6fd8cde Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111442 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport16.cxx4
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx9
-rw-r--r--writerfilter/source/dmapper/DomainMapper.hxx1
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx1
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx3
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx10
6 files changed, 27 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 6da14ef1a005..046721c53f59 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -18,6 +18,7 @@
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
+#include <editeng/escapementitem.hxx>
constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/ooxmlexport/data/";
@@ -111,6 +112,9 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFooterMarginLost, "footer-margin-lost.do
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf140572_docDefault_superscript, "tdf140572_docDefault_superscript.docx")
{
// A round-trip was crashing.
+
+ // Without the fix, everything was DFLT_ESC_AUTO_SUPER (default superscript)
+ CPPUNIT_ASSERT_EQUAL( sal_Int16(0), getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharEscapement") );
}
DECLARE_OOXMLEXPORT_TEST(testTdf138953, "croppedAndRotated.odt")
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index a3b04a014ca8..964abf0e58fd 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1811,8 +1811,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
{
if ( !IsStyleSheetImport() )
m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue ));
- else
+ else if (!m_pImpl->IsDocDefaultsImport())
{
+ // For some undocumented reason, MS Word seems to ignore this in docDefaults
+
// DON'T FIXME: Truly calculating this for Character Styles will be tricky,
// because it depends on the final fontsize - regardless of
// where it is set. So at the style level,
@@ -4023,6 +4025,11 @@ OUString DomainMapper::GetListStyleName(sal_Int32 nListId) const
return m_pImpl->GetListStyleName( nListId );
}
+void DomainMapper::SetDocDefaultsImport(bool bSet)
+{
+ m_pImpl->SetDocDefaultsImport(bSet);
+}
+
bool DomainMapper::IsStyleSheetImport() const
{
return m_pImpl->IsStyleSheetImport();
diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx
index d2e08a0041aa..46bbd2b39018 100644
--- a/writerfilter/source/dmapper/DomainMapper.hxx
+++ b/writerfilter/source/dmapper/DomainMapper.hxx
@@ -112,6 +112,7 @@ public:
bool IsInHeaderFooter() const;
bool IsInTable() const;
+ void SetDocDefaultsImport(bool bSet);
bool IsStyleSheetImport() const;
bool IsInShape() const;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d0ddb431c4d7..8ace7179ad18 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -299,6 +299,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_pLastCharacterContext(),
m_sCurrentParaStyleName(),
m_sDefaultParaStyleName(),
+ m_bInDocDefaultsImport(false),
m_bInStyleSheetImport( false ),
m_bInAnyTableImport( false ),
m_eInHeaderFooterImport( HeaderFooterImportState::none ),
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 1a6d27381db0..581d2dba6692 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -519,6 +519,7 @@ private:
::std::vector<DeletableTabStop> m_aCurrentTabStops;
OUString m_sCurrentParaStyleName; //highly inaccurate. Overwritten by "overlapping" paragraphs like comments, flys.
OUString m_sDefaultParaStyleName; //caches the ConvertedStyleName of the default paragraph style
+ bool m_bInDocDefaultsImport;
bool m_bInStyleSheetImport; //in import of fonts, styles, lists or lfos
bool m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
enum class HeaderFooterImportState
@@ -780,6 +781,8 @@ public:
css::uno::Any GetPropertyFromCharStyleSheet(PropertyIds eId, const PropertyMapPtr& rContext);
// get property first from the given context, or secondly via inheritance from styles/docDefaults
css::uno::Any GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext);
+ void SetDocDefaultsImport( bool bSet ) { m_bInDocDefaultsImport = bSet;}
+ bool IsDocDefaultsImport()const { return m_bInDocDefaultsImport;}
void SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}
bool IsStyleSheetImport()const { return m_bInStyleSheetImport;}
void SetAnyTableImport( bool bSet ) { m_bInAnyTableImport = bSet;}
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 731facdaff84..083288bc16b6 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -689,6 +689,9 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
}
case NS_ooxml::LN_CT_PPrDefault_pPr:
case NS_ooxml::LN_CT_DocDefaults_pPrDefault:
+ if (nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault)
+ m_pImpl->m_rDMapper.SetDocDefaultsImport(true);
+
m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pDefaultParaProps );
resolveSprmProps( m_pImpl->m_rDMapper, rSprm );
if ( nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault && m_pImpl->m_pDefaultParaProps &&
@@ -699,13 +702,20 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
m_pImpl->m_rDMapper.PopStyleSheetProperties();
applyDefaults( true );
m_pImpl->m_bHasImportedDefaultParaProps = true;
+ if (nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault)
+ m_pImpl->m_rDMapper.SetDocDefaultsImport(false);
break;
case NS_ooxml::LN_CT_RPrDefault_rPr:
case NS_ooxml::LN_CT_DocDefaults_rPrDefault:
+ if (nSprmId == NS_ooxml::LN_CT_DocDefaults_rPrDefault)
+ m_pImpl->m_rDMapper.SetDocDefaultsImport(true);
+
m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pDefaultCharProps );
resolveSprmProps( m_pImpl->m_rDMapper, rSprm );
m_pImpl->m_rDMapper.PopStyleSheetProperties();
applyDefaults( false );
+ if (nSprmId == NS_ooxml::LN_CT_DocDefaults_rPrDefault)
+ m_pImpl->m_rDMapper.SetDocDefaultsImport(false);
break;
case NS_ooxml::LN_CT_TblPrBase_jc: //table alignment - row properties!
m_pImpl->m_pCurrentEntry->pProperties->Insert( PROP_HORI_ORIENT,