[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/qa writerfilter/source
Justin Luth
justin_luth at sil.org
Thu Jul 12 09:21:54 UTC 2018
sw/qa/extras/ooxmlexport/data/tdf118361_RTLfootnoteSeparator.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 6 +
sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 4 +
writerfilter/source/dmapper/PropertyIds.cxx | 1
writerfilter/source/dmapper/PropertyIds.hxx | 1
writerfilter/source/dmapper/PropertyMap.cxx | 32 ++++++++++
6 files changed, 44 insertions(+)
New commits:
commit 37a27823ad181387943a3193236f2cca6d3ec0d6
Author: Justin Luth <justin_luth at sil.org>
Date: Wed Jun 27 16:19:57 2018 +0300
tdf#118361 sw ooxmlimport: set footnote separator alignment
If RTL is defined in the default (Normal) paragraph style,
then the footnote separator should be right-aligned.
In MSWORD, the alignment is not a property that is stored
with the footnote separator definition, and it is not a
page property like it is in LO.
The reverse needs to happen for LTR default paragraph style.
Based on my MSWORD observations, the only place where you can
indirectly set RightToLeft is in the "Normal" paragraph style.
That option is disabled in all of the other styles.
In LibreOffice, this is typically handled by the locale properties.
The default PAGE style's Footnotes - Position is RIGHT for
RTL locales, but LEFT for LTR locales.
It is kinda interesting that no one from a RTL locale complained
about wrongly-right-aligned footnote separator
from imported LTR .docx's.
None of this belongs in export code, since MSO doesn't support
specifying the location - it is just a consequence of the
RTL/LTR settings.
Change-Id: I07d26640116cb12cb9157cd1d902b4c774dbba26
Reviewed-on: https://gerrit.libreoffice.org/56532
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
(cherry picked from commit 139750d7c295b84f4c42bf9409ccbdfb0c46b9f6)
Reviewed-on: https://gerrit.libreoffice.org/57214
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf118361_RTLfootnoteSeparator.docx b/sw/qa/extras/ooxmlexport/data/tdf118361_RTLfootnoteSeparator.docx
new file mode 100644
index 000000000000..8545cbf253d8
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf118361_RTLfootnoteSeparator.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index e086b1998aa7..9882bb943f7b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -84,6 +84,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112694, "tdf112694.docx")
CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf118361_RTLfootnoteSeparator, "tdf118361_RTLfootnoteSeparator.docx")
+{
+ uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Footnote separator RTL", sal_Int16(2), getProperty<sal_Int16>(aPageStyle, "FootnoteLineAdjust"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf115861, "tdf115861.docx")
{
// Second item in the paragraph enumeration was a table, 2nd paragraph was
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 096a711d113b..347a444f1cf7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -660,6 +660,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf82173_footnoteStyle, "tdf82173_footnoteStyle.doc
xPageStyle.set(getStyles("CharacterStyles")->getByName("Footnote anchor"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL( sal_Int32(58), getProperty< sal_Int32 >(xPageStyle, "CharEscapementHeight") );
CPPUNIT_ASSERT_EQUAL( sal_Int32(0x00FF00), getProperty< sal_Int32 >(xPageStyle, "CharColor") );
+
+ //tdf#118361 - in RTL locales, the footnote separator should still be left aligned.
+ uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Footnote separator LTR", sal_Int16(0), getProperty<sal_Int16>(aPageStyle, "FootnoteLineAdjust"));
}
DECLARE_OOXMLEXPORT_TEST(testTdf82173_endnoteStyle, "tdf82173_endnoteStyle.docx")
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 592063a4d312..f515d5118636 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -172,6 +172,7 @@ OUString getPropertyName( PropertyIds eId )
case PROP_FOOTER_IS_SHARED : sName = "FooterIsShared"; break;
case PROP_FOOTER_IS_ON : sName = "FooterIsOn"; break;
case PROP_FOOTNOTE_COUNTING : sName = "FootnoteCounting"; break;
+ case PROP_FOOTNOTE_LINE_ADJUST : sName = "FootnoteLineAdjust"; break;
case PROP_WIDTH : sName = "Width"; break;
case PROP_HEIGHT : sName = "Height"; break;
case PROP_TEXT_COLUMNS : sName = "TextColumns"; break;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index a3465fe8d98a..6d1d77bd743c 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -128,6 +128,7 @@ enum PropertyIds
,PROP_FOOTER_TEXT
,PROP_FOOTER_TEXT_LEFT
,PROP_FOOTNOTE_COUNTING
+ ,PROP_FOOTNOTE_LINE_ADJUST
,PROP_FORMAT
,PROP_FULL_NAME
,PROP_GAMMA
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 7289a744c3f4..ed7632b2551f 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -36,12 +36,15 @@
#include <com/sun/star/style/BreakType.hpp>
#include <com/sun/star/style/PageStyleLayout.hpp>
#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/HorizontalAdjust.hpp>
#include <com/sun/star/text/SizeType.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/WritingMode.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/TextGridMode.hpp>
@@ -1034,6 +1037,35 @@ void SectionPropertyMap::HandleMarginsHeaderFooter( bool bFirstPage, DomainMappe
// Set footnote line width to zero, document has no footnote separator.
Insert(PROP_FOOTNOTE_LINE_RELATIVE_WIDTH, uno::makeAny(sal_Int32(0)));
}
+ if ( rDM_Impl.m_bHasFtnSep )
+ {
+ //If default paragraph style is RTL, footnote separator should be right aligned
+ //and for RTL locales, LTR default paragraph style should present a left aligned footnote separator
+ try
+ {
+ uno::Reference<style::XStyleFamiliesSupplier> xStylesSupplier(rDM_Impl.GetTextDocument(), uno::UNO_QUERY);
+ if ( xStylesSupplier.is() )
+ {
+ uno::Reference<container::XNameAccess> xStyleFamilies = xStylesSupplier->getStyleFamilies();
+ uno::Reference<container::XNameAccess> xParagraphStyles;
+ if ( xStyleFamilies.is() )
+ xStyleFamilies->getByName("ParagraphStyles") >>= xParagraphStyles;
+ uno::Reference<beans::XPropertySet> xStandard;
+ if ( xParagraphStyles.is() )
+ xParagraphStyles->getByName("Standard") >>= xStandard;
+ if ( xStandard.is() )
+ {
+ sal_Int16 aWritingMode;
+ xStandard->getPropertyValue( getPropertyName(PROP_WRITING_MODE) ) >>= aWritingMode;
+ if( aWritingMode == text::WritingMode2::RL_TB )
+ Insert( PROP_FOOTNOTE_LINE_ADJUST, uno::makeAny( sal_Int16(text::HorizontalAdjust_RIGHT) ), false );
+ else
+ Insert( PROP_FOOTNOTE_LINE_ADJUST, uno::makeAny( sal_Int16(text::HorizontalAdjust_LEFT) ), false );
+ }
+ }
+ }
+ catch ( const uno::Exception& ) {}
+ }
/*** if headers/footers are available then the top/bottom margins of the
header/footer are copied to the top/bottom margin of the page
More information about the Libreoffice-commits
mailing list