[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/qa sc/source
Attila Szűcs (via logerrit)
logerrit at kemper.freedesktop.org
Thu Feb 18 11:19:39 UTC 2021
sc/qa/unit/data/ods/tdf121718_UseFirstPageNumber.ods |binary
sc/qa/unit/subsequent_export-test.cxx | 27 +++++++++++++++++++
sc/source/filter/excel/xepage.cxx | 8 ++++-
3 files changed, 33 insertions(+), 2 deletions(-)
New commits:
commit de14b8ad2cabf857c510d78e6d21a0ab1fb84b9e
Author: Attila Szűcs <szucs.attila3 at nisz.hu>
AuthorDate: Thu Aug 6 10:35:06 2020 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Feb 18 12:18:58 2021 +0100
tdf#121718 XLSX export: fix first page number
Changed code to not save 'useFirstPageNumber' and 'firstPageNumber'
if "First page number" is not checked.
It was needed because Excel does not care about 'useFirstPageNumber',
and blindly load 'firstPageNumber' even if that had an invalid value
(that could happen when useFirstPageNumber==false).
Co-authored-by: Tibor Nagy (NISZ)
Change-Id: I69c9ed0fd4fdca1794d4bbc197713ac687eb4005
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100203
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 790c0aeab258f770eb94f2d2cceceebfeaceb825)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111133
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sc/qa/unit/data/ods/tdf121718_UseFirstPageNumber.ods b/sc/qa/unit/data/ods/tdf121718_UseFirstPageNumber.ods
new file mode 100644
index 000000000000..0726e4cb1edc
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf121718_UseFirstPageNumber.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index e84a464ab886..d387221d4156 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -260,6 +260,7 @@ public:
void testTdf121716_ExportEvenHeaderFooterXLSX();
void testTdf134459_HeaderFooterColorXLSX();
void testTdf134817_HeaderFooterTextWith2SectionXLSX();
+ void testTdf121718_UseFirstPageNumberXLSX();
void testHeaderFontStyleXLSX();
void testTdf135828_Shape_Rect();
void testTdf123353();
@@ -418,6 +419,7 @@ public:
CPPUNIT_TEST(testTdf121716_ExportEvenHeaderFooterXLSX);
CPPUNIT_TEST(testTdf134817_HeaderFooterTextWith2SectionXLSX);
CPPUNIT_TEST(testTdf134459_HeaderFooterColorXLSX);
+ CPPUNIT_TEST(testTdf121718_UseFirstPageNumberXLSX);
CPPUNIT_TEST(testHeaderFontStyleXLSX);
CPPUNIT_TEST(testTdf135828_Shape_Rect);
CPPUNIT_TEST(testTdf123353);
@@ -5267,6 +5269,31 @@ void ScExportTest::testTdf134817_HeaderFooterTextWith2SectionXLSX()
xDocSh->DoClose();
}
+void ScExportTest::testTdf121718_UseFirstPageNumberXLSX()
+{
+ // If "First page number" is not checked then useFirstPageNumb, and firstPageNumber should not be exported.
+ ScDocShellRef xShell = loadDoc("tdf121718_UseFirstPageNumber.", FORMAT_ODS);
+ CPPUNIT_ASSERT(xShell.is());
+
+ ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX);
+ CPPUNIT_ASSERT(xDocSh.is());
+
+ std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX);
+ xmlDocUniquePtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+ CPPUNIT_ASSERT(pDoc);
+
+ assertXPath(pDoc, "/x:worksheet/x:pageSetup", "useFirstPageNumber", "true");
+ assertXPath(pDoc, "/x:worksheet/x:pageSetup", "firstPageNumber", "10");
+
+ pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet2.xml");
+ CPPUNIT_ASSERT(pDoc);
+
+ assertXPathNoAttribute(pDoc, "/x:worksheet/x:pageSetup", "useFirstPageNumber");
+ assertXPathNoAttribute(pDoc, "/x:worksheet/x:pageSetup", "firstPageNumber");
+
+ xDocSh->DoClose();
+}
+
void ScExportTest::testHeaderFontStyleXLSX()
{
ScDocShellRef xShell = loadDoc("tdf134826.", FORMAT_XLSX);
diff --git a/sc/source/filter/excel/xepage.cxx b/sc/source/filter/excel/xepage.cxx
index 3941bd191f92..64d671a3acba 100644
--- a/sc/source/filter/excel/xepage.cxx
+++ b/sc/source/filter/excel/xepage.cxx
@@ -107,7 +107,6 @@ void XclExpSetup::SaveXml( XclExpXmlStream& rStrm )
// pAttrList->add( XML_paperUnits, "mm" );
}
pAttrList->add( XML_scale, OString::number( mrData.mnScaling ).getStr() );
- pAttrList->add( XML_firstPageNumber, OString::number( mrData.mnStartPage ).getStr() );
pAttrList->add( XML_fitToWidth, OString::number( mrData.mnFitToWidth ).getStr() );
pAttrList->add( XML_fitToHeight, OString::number( mrData.mnFitToHeight ).getStr() );
pAttrList->add( XML_pageOrder, mrData.mbPrintInRows ? "overThenDown" : "downThenOver" );
@@ -119,7 +118,12 @@ void XclExpSetup::SaveXml( XclExpXmlStream& rStrm )
pAttrList->add( XML_blackAndWhite, ToPsz( mrData.mbBlackWhite ) );
pAttrList->add( XML_draft, ToPsz( mrData.mbDraftQuality ) );
pAttrList->add( XML_cellComments, mrData.mbPrintNotes ? "atEnd" : "none" ); // OOXTODO: "asDisplayed"?
- pAttrList->add( XML_useFirstPageNumber, ToPsz( mrData.mbManualStart ) );
+
+ if ( mrData.mbManualStart )
+ {
+ pAttrList->add( XML_firstPageNumber, OString::number( mrData.mnStartPage ).getStr() );
+ pAttrList->add( XML_useFirstPageNumber, ToPsz( mrData.mbManualStart ) );
+ }
// OOXTODO: XML_errors, // == displayed|blank|dash|NA
pAttrList->add( XML_horizontalDpi, OString::number( mrData.mnHorPrintRes ).getStr() );
pAttrList->add( XML_verticalDpi, OString::number( mrData.mnVerPrintRes ).getStr() );
More information about the Libreoffice-commits
mailing list