/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
CPPUNIT_TEST_FIXTURE(ScExportTest, testFontColorWithMultipleAttributesDefined)
{ // Related: TDF #113271 // Test font color where "rgb" and "theme" attribute is defined and // is imported and exported correctly. Theme should have priority, // so LO is fine to ignore "rgb" at export.
createScDoc("xlsx/tdf113271.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDoc = parseExport(u"xl/styles.xml"_ustr);
CPPUNIT_ASSERT(pDoc);
// Expect "theme" attribute to be set correctly
assertXPath(pDoc, "/x:styleSheet/x:fonts/x:font[1]/x:color", "theme", u"1"); // We don't export "rgb" attribute
assertXPathNoAttribute(pDoc, "/x:styleSheet/x:fonts/x:font[1]/x:color", "rgb"); // Just making sure the checked font is the correct one
assertXPath(pDoc, "/x:styleSheet/x:fonts/x:font[1]/x:name", "val", u"Calibri");
}
// Document is saved to the temporary directory, relative path should be different than original one
CPPUNIT_ASSERT(sTarget != "../xls/bug-fixes.xls");
}
// Excel can't open corrupt file if the list is longer than 255 characters
std::vector<ScTypedStrData> aList;
pData->FillSelectionList(aList, ScAddress(0, 1, 1));
CPPUNIT_ASSERT_EQUAL(size_t(18), aList.size());
CPPUNIT_ASSERT_EQUAL(u"18 Missis"_ustr, aList[17].GetString());
}
// we can't assume that the user entered the password; check that we // round-trip the password as-is
save(u"calc8"_ustr);
xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and " "@table:protection-key='vbnhxyBKtPHCA1wB21zG1Oha8ZA=' and " "@table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha1']");
assertXPath(pXmlDoc, "//table:table[@table:protected='true' and " "@table:protection-key='vbnhxyBKtPHCA1wB21zG1Oha8ZA=' and " "@table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha1']");
}
// we can't assume that the user entered the password; check that we // round-trip the password as-is
save(u"calc8"_ustr);
xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and " "@table:protection-key='nLHas0RIwepGDaH4c2hpyIUvIS8=' and " "@table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha1']");
assertXPath(pXmlDoc, "//table:table[@table:protected='true' and " "@table:protection-key='nLHas0RIwepGDaH4c2hpyIUvIS8=' and " "@table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha1']");
}
// we can't assume that the user entered the password; check that we // round-trip the password as-is
save(u"calc8"_ustr);
xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(
pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and " "@table:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=' and " "@table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256']");
assertXPath(
pXmlDoc, "//table:table[@table:protected='true' and " "@table:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=' and " "@table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256']");
}
// we can't assume that the user entered the password; check that we // round-trip the password as-is
save(u"calc8"_ustr);
xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(
pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and " "@table:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=' and " "@table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256']");
assertXPath(
pXmlDoc, "//table:table[@table:protected='true' and " "@table:protection-key='1tnJohagR2T0yF/v69hLPuumSTsj32CumW97nkKGuSQ=' and " "@table:protection-key-digest-algorithm='http://www.w3.org/2000/09/xmldsig#sha256']");
}
// we can't assume that the user entered the password; check that we // round-trip the password as-is
save(u"calc8"_ustr);
xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
assertXPath(
pXmlDoc, "//office:spreadsheet[@table:structure-protected='true' and " "@table:protection-key='OX3WkEe79fv1PE+FUmfOLdwVoqI=' and " "@table:protection-key-digest-algorithm='http://docs.oasis-open.org/office/ns/table/" "legacy-hash-excel' and " "@loext:protection-key-digest-algorithm-2='http://www.w3.org/2000/09/xmldsig#sha1']");
assertXPath(
pXmlDoc, "//table:table[@table:protected='true' and " "@table:protection-key='OX3WkEe79fv1PE+FUmfOLdwVoqI=' and " "@table:protection-key-digest-algorithm='http://docs.oasis-open.org/office/ns/table/" "legacy-hash-excel' and " "@loext:protection-key-digest-algorithm-2='http://www.w3.org/2000/09/xmldsig#sha1']");
}
CPPUNIT_TEST_FIXTURE(ScExportTest, testCommentExportXLSX)
{ //tdf#104729 FILESAVE OpenOffice do not save author of the comment during export to .xlsx
createScDoc("ods/comment.ods");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pComments = parseExport(u"xl/comments1.xml"_ustr);
CPPUNIT_ASSERT(pComments);
//tdf#117274 fix MSO interoperability with the secret VML shape type id
assertXPath(pVmlDrawing, "/xml/v:shapetype", "id", u"_x0000_t202");
assertXPath(pVmlDrawing, "/xml/v:shape", "type", u"#_x0000_t202");
}
CPPUNIT_TEST_FIXTURE(ScExportTest, testCommentExportXLSX_2_XLSX)
{ //tdf#117287 FILESAVE XLSX: Comments always disappear after opening the exported XLSX file with Excel
createScDoc("xlsx/tdf117287_comment.xlsx");
#if HAVE_MORE_FONTS
CPPUNIT_TEST_FIXTURE(ScExportTest, testCustomColumnWidthExportXLSX)
{ //tdf#100946 FILESAVE Excel on macOS ignored column widths in XLSX last saved by LO
createScDoc("ods/custom_column_width.ods");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
// tdf#124741: check that we export default width, otherwise the skipped columns would have // wrong width. Previously defaultColWidth attribute was missing double nDefWidth
= getXPath(pSheet, "/x:worksheet/x:sheetFormatPr", "defaultColWidth").toDouble();
CPPUNIT_ASSERT_DOUBLES_EQUAL(11.53515625, nDefWidth, 0.01);
// First column, has everything default (width in Calc: 1280), skipped
CPPUNIT_TEST_FIXTURE(ScExportTest, testXfDefaultValuesXLSX)
{ //tdf#70565 FORMATTING: User Defined Custom Formatting is not applied during importing XLSX documents
createScDoc("xlsx/xf_default_values.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/styles.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
// cellStyleXfs don't need xfId, so we need to make sure it is not saved
assertXPathNoAttribute(pSheet, "/x:styleSheet/x:cellStyleXfs/x:xf[1]", "xfId");
// Because numFmtId fontId fillId borderId xfId are not existing during import // it should be created during export, with values set to "0"
assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf[1]", "xfId", u"0");
assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf[2]", "xfId", u"0");
assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf[3]", "xfId", u"0");
assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf[4]", "xfId", u"0");
// We expected that exactly 15 cellXfs:xf Nodes will be produced
assertXPath(pSheet, "/x:styleSheet/x:cellXfs/x:xf", 14);
}
CPPUNIT_TEST_FIXTURE(ScExportTest, testColumnWidthResaveXLSX)
{ // tdf#91475 FILESAVE: Column width is not preserved in XLSX / after round trip. // Test if after resave .xlsx file, columns width is identical with previous one
createScDoc("xlsx/different-column-width-excel2010.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
// In original Excel document the width is "24"
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "width", u"24");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "customWidth", u"true");
// In original Excel document the width is "12"
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[2]", "width", u"12");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[2]", "customWidth", u"true");
// In original Excel document the width is "6"
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[3]", "width", u"6");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[3]", "customWidth", u"true");
// In original Excel document the width is "1"
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[4]", "width", u"1");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[4]", "customWidth", u"true");
// In original Excel document the width is "250"
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[5]", "width", u"250");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[5]", "customWidth", u"true");
#if HAVE_MORE_FONTS
CPPUNIT_TEST_FIXTURE(ScExportTest, testColumnWidthExportFromODStoXLSX)
{ // tdf#91475 FILESAVE: Column width is not preserved in XLSX / after round trip. // Test if after export .ods to .xlsx format, displayed columns width // is identical with previous (.ods) one
CPPUNIT_TEST_FIXTURE(ScExportTest, testOutlineExportXLSX)
{ //tdf#100347 FILESAVE FILEOPEN after exporting to .xlsx format grouping are lost //tdf#51524 FILESAVE .xlsx and.xls looses width information for hidden/collapsed grouped columns
createScDoc("ods/outline.ods");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
// Maximum Outline Row is 4 for this document
assertXPath(pSheet, "/x:worksheet/x:sheetFormatPr", "outlineLevelRow", u"4"); // Maximum Outline Column is 4 for this document
assertXPath(pSheet, "/x:worksheet/x:sheetFormatPr", "outlineLevelCol", u"4");
// First XML node, creates two columns (from min=1 to max=2)
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "hidden", u"false");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "outlineLevel", u"1");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "collapsed", u"false");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "min", u"1");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[1]", "max", u"2");
// Column 4 has custom width and it is hidden. We need to make sure that it is created
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[3]", "hidden", u"true");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[3]", "outlineLevel", u"2");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[3]", "collapsed", u"false");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[3]", "min", u"4");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[3]", "max", u"4");
// Column 8 has custom width and it is hidden. We need to make sure that it is created
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[6]", "hidden", u"true");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[6]", "outlineLevel", u"4");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[6]", "collapsed", u"false");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[6]", "min", u"8");
assertXPath(pSheet, "/x:worksheet/x:cols/x:col[6]", "max", u"8");
CPPUNIT_TEST_FIXTURE(ScExportTest, testHiddenEmptyRowsXLSX)
{ //tdf#98106 FILESAVE: Hidden and empty rows became visible when export to .XLSX
createScDoc("ods/hidden-empty-rows.ods");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
CPPUNIT_TEST_FIXTURE(ScExportTest, testHiddenEmptyColsODS)
{ //tdf#98106 FILESAVE: Hidden and empty rows became visible when export to .XLSX
createScDoc("ods/tdf128895_emptyHiddenCols.ods");
CPPUNIT_TEST_FIXTURE(ScExportTest, testLandscapeOrientationXLSX)
{ //tdf#48767 - Landscape page orientation is not loaded from .xlsx format with MS Excel, after export with Libre Office
createScDoc("ods/hidden-empty-rows.ods");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
// the usePrinterDefaults cannot be saved to allow opening sheets in Landscape mode via MS Excel
assertXPathNoAttribute(pSheet, "/x:worksheet/x:pageSetup", "usePrinterDefaults");
assertXPath(pSheet, "/x:worksheet/x:pageSetup", "orientation", u"landscape");
}
staticconst TestParam::RowData EmptyRepeatRowData[] = { // rows 0-4, 5-10, 17-20 are all set at various // heights, there is no content in the rows, there // was a bug where only the first row ( of repeated rows ) // was set after export
{ 0, 4, 0, 529, 0, false },
{ 5, 10, 0, 1058, 0, false },
{ 17, 20, 0, 1767, 0, false },
};
TestParam aTestValues[] = { // Checks that some distributed ( non-empty ) heights remain set after export (roundtrip) // additionally there is effectively a default row height ( 5.29 mm ). So we test the // unset rows at the end of the document to ensure the effective xlsx default height // is set there too.
{ u"xlsx/miscrowheights.xlsx", u"Calc Office Open XML"_ustr, SAL_N_ELEMENTS(DfltRowData),
DfltRowData }, // Checks that some distributed ( non-empty ) heights remain set after export (to xls)
{ u"xlsx/miscrowheights.xlsx", u"MS Excel 97"_ustr, SAL_N_ELEMENTS(DfltRowData),
DfltRowData }, // Checks that repeated rows ( of various heights ) remain set after export ( to xlsx )
{ u"ods/miscemptyrepeatedrowheights.ods", u"Calc Office Open XML"_ustr,
SAL_N_ELEMENTS(EmptyRepeatRowData), EmptyRepeatRowData }, // Checks that repeated rows ( of various heights ) remain set after export ( to xls )
{ u"ods/miscemptyrepeatedrowheights.ods", u"MS Excel 97"_ustr,
SAL_N_ELEMENTS(EmptyRepeatRowData), EmptyRepeatRowData },
};
miscRowHeightsTest(aTestValues, SAL_N_ELEMENTS(aTestValues));
}
CPPUNIT_TEST_FIXTURE(ScExportTest, testNamedRangeBugfdo62729)
{ #if !defined(MACOSX) // FIXME: infinite loop on jenkins' mac
createScDoc("ods/fdo62729.ods");
ScDocument* pDoc = getScDoc();
ScRangeName* pNames = pDoc->GetRangeName(); //should be just a single named range
CPPUNIT_ASSERT_EQUAL(size_t(1), pNames->size());
pDoc->DeleteTab(0); //should be still a single named range
CPPUNIT_ASSERT_EQUAL(size_t(1), pNames->size());
saveAndReload(u"calc8"_ustr);
pDoc = getScDoc();
pNames = pDoc->GetRangeName(); //after reload should still have a named range
CPPUNIT_ASSERT_EQUAL(size_t(1), pNames->size()); #endif
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.