/* -*- 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/.
*/
createScDoc("xlsx/tdf162948.xlsx");
verify();
saveAndReload(u"Calc Office Open XML"_ustr);
verify();
// FIXME: Error: tag name "calcext:icon-set" is not allowed. Possible tag names are: <color-scale>,<condition>,<data-bar>
skipValidation();
saveAndReload(u"calc8"_ustr); // tdf#163337
verify();
}
const ScFormatEntry* pEntry = pFormat->GetEntry(0);
CPPUNIT_ASSERT(pEntry);
CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Condition, pEntry->GetType()); const ScConditionEntry* pConditionEntry = static_cast<const ScConditionEntry*>(pEntry);
CPPUNIT_ASSERT_EQUAL(ScConditionMode::Direct, pConditionEntry->GetOperation()); // Without the fix in place, this test would have failed after the roundtrip with // - Expected: SUM($A$1:A1) > 10 // - Actual : SUM($A$1) > 10
CPPUNIT_ASSERT_EQUAL(u"SUM($A$1:A1) > 10"_ustr,
pConditionEntry->GetExpression(ScAddress(0, 0, 0), 0));
};
createScDoc("ods/tdf165383.ods");
verify();
saveAndReload(u"Calc Office Open XML"_ustr);
verify();
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testRotatedImageODS)
{ // Error was, that the length values in shapes were not // written in the given unit into the file.
css::uno::Reference<css::sheet::XGlobalSheetSettings> xGlobalSheetSettings
= css::sheet::GlobalSheetSettings::create(comphelper::getProcessComponentContext());
xGlobalSheetSettings->setMetric(static_cast<sal_Int16>(FieldUnit::MM));
// Without the fix in place, this test would have failed with // - Expected: 4.5 // - Actual : #N/A
CPPUNIT_ASSERT_EQUAL(u"4.5"_ustr, pDoc->GetString(ScAddress(2, 2, 0)));
}
// Without the fix in place, this test would have failed with // - Expected: 4 // - Actual : 1 // - Failed on filter: MS Excel 97
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), size_t(4), aList.size()); for (size_t j = 0; j < 4; ++j)
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), double(j + 1),
aList[j].GetValue());
}
}
ScDocument* pDoc = getScDoc(); // Without the fix in place, this test would have failed with // - Expected: 2021-08Aug-30Mon // - Actual : 2021-A-30Mon
CPPUNIT_ASSERT_EQUAL(u"2021-08Aug-30Mon"_ustr, pDoc->GetString(ScAddress(0, 0, 0)));
}
// Trying to save very small fractional default column width to XLS (where only integer values // between 0 and 255 are allowed as default) resulted in negative (-1) value after correction, // and was written as 65535 (invalid default width). As the result, all columns had large width // when reopened: 28415 (and Excel warned about invalid format). const sal_uInt16 nColumn0Width = pDoc->GetColWidth(SCCOL(0), SCTAB(0), false);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(45), nColumn0Width);
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf120502)
{ // Create an empty worksheet; resize last column on its first sheet; export to XLSX, and check // that the last exported column number is correct
createScDoc();
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf83779)
{ // Roundtripping TRUE/FALSE constants (not functions) must convert them to functions
createScDoc("xlsx/tdf83779.xlsx");
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf121715_FirstPageHeaderFooterXLSX)
{ // Check if first page header and footer are exported properly
createScDoc("xlsx/tdf121715.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDoc = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pDoc);
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf121716_ExportEvenHeaderFooterXLSX)
{ // Header and footer on even pages should be exported properly // If there are separate odd/even header, but only 1 footer for all pages (this is possible only in LibreOffice) // then the footer will be duplicated to have the same footer separately for even/odd pages
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf134459_HeaderFooterColorXLSX)
{ // Colors in header and footer should be exported, and imported properly
createScDoc("xlsx/tdf134459_HeaderFooterColor.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDoc = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pDoc);
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf134817_HeaderFooterTextWith2SectionXLSX)
{ // Header/footer text with multiple selection should be exported, and imported properly
createScDoc("xlsx/tdf134817_HeaderFooterTextWith2Section.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDoc = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pDoc);
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf121718_UseFirstPageNumberXLSX)
{ // If "First page number" is not checked then useFirstPageNumb, and firstPageNumber should not be exported.
createScDoc("ods/tdf121718_UseFirstPageNumber.ods");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDoc = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pDoc);
// Check if the user defined page style is present static constexpr OUString aTestPageStyle = u"TestPageStyle"_ustr;
ScDocument* pDoc = getScDoc();
CPPUNIT_ASSERT_EQUAL(aTestPageStyle, pDoc->GetPageStyle(0));
// Change page style to default so the user defined one is not used anymore
pDoc->SetPageStyle(0, ScResId(STR_STYLENAME_STANDARD));
// Save and reload the document to check if the unused page styles are still present
saveAndReload(u"calc8"_ustr);
pDoc = getScDoc();
// Without the accompanying fix in place, the unused page styles don't exist anymore
ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
CPPUNIT_ASSERT(pStylePool->Find(aTestPageStyle, SfxStyleFamily::Page));
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf135828_Shape_Rect)
{ if (!IsDefaultDPI()) return; // tdf#135828 Check that the width and the height of rectangle of the shape is correct. // tdf#123613 Check the positioning, and allow massive rounding errors because of the back and // forth conversion between emu and hmm.
createScDoc("xlsx/tdf135828_Shape_Rect.xlsx");
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf133688_precedents)
{ // tdf#133688 Check that we do not export detective shapes.
createScDoc("ods/tdf133688_dont_save_precedents_to_xlsx.ods");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDrawing = parseExport(u"xl/drawings/drawing1.xml"_ustr);
CPPUNIT_ASSERT(pDrawing);
// We do not export any shapes.
assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[1]", 0);
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf91251_missingOverflowRoundtrip)
{ // tdf#91251 check whether textBox overflow property (horzOverflow and vertOverflow) is // getting preserved after roundtrip
createScDoc("xlsx/tdf91251_missingOverflowRoundtrip.xlsx");
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf137000_handle_upright)
{ // Upright is an xml attribute of xdr:txBody/a:bodyPr. It is set when in a textbox menu we // choose, 'do not rotate this element'. Implementations are in tdf#106197 with followup // tdf#137000. tdf#149538, tdf#149551 improve the implementation to export 'upright' instead // of workaround 'rot'.
createScDoc("xlsx/tdf137000_export_upright.xlsx");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDrawing = parseExport(u"xl/drawings/drawing1.xml"_ustr);
CPPUNIT_ASSERT(pDrawing);
// load data from external links. (tdf76047_externalLinkSource.ods) // that file has to be in the same directory as tdf76047_externalLink.xlsx
ScDocShell* pDocSh = getScDocShell();
pDocSh->ReloadAllLinks();
ScDocument* pDoc = getScDoc();
// compare the data loaded from external links with the expected result stored in the test file for (int nCol = 1; nCol <= 5; nCol++)
{ for (int nRow = 3; nRow <= 5; nRow++)
{
OUString aStr1 = pDoc->GetString(ScAddress(nCol, nRow, 0));
OUString aStr2 = pDoc->GetString(ScAddress(nCol, nRow + 5, 0));
OUString aStr3 = pDoc->GetString(ScAddress(nCol, nRow + 11, 0));
// try to load data from external link: tdf132105_external.ods // that file has to be in the same directory as tdf87973_externalLinkSkipUnuseds.ods
ScDocShell* pDocSh = getScDocShell();
pDocSh->ReloadAllLinks();
ScDocument* pDoc = getScDoc();
// change external link to: 87973_externalSource.ods
OUString aFormula = pDoc->GetFormula(3, 1, 0); auto nIdxOfFilename = aFormula.indexOf("tdf132105_external.ods");
aFormula = aFormula.replaceAt(nIdxOfFilename, 22, u"87973_externalSource.ods"); auto nIdxOfFile = aFormula.indexOf("file");
// saveAndReload save the file to a temporary directory // the link must be changed to point to that directory
OUString aTempFilename = utl::CreateTempURL(); auto nIdxOfTmpFile = aTempFilename.lastIndexOf('/');
aTempFilename = aTempFilename.copy(0, nIdxOfTmpFile + 1);
// tdf#138832: test the same thing with singleref link
aFormula = pDoc->GetFormula(3, 2, 0);
nIdxOfFilename = aFormula.indexOf("tdf132105_external.ods");
aFormula = aFormula.replaceAt(nIdxOfFilename, 22, u"87973_externalSource.ods");
nIdxOfFile = aFormula.indexOf("file");
// save and load back
saveAndReload(u"Calc Office Open XML"_ustr);
// check if the new filename is present in the link (and not replaced by '[2]')
pDoc = getScDoc();
OUString aFormula2 = pDoc->GetFormula(3, 1, 0);
CPPUNIT_ASSERT(aFormula2.indexOf("tdf132105_external.ods") < 0);
CPPUNIT_ASSERT(aFormula2.indexOf("87973_externalSource.ods") >= 0);
aFormula2 = pDoc->GetFormula(3, 2, 0);
CPPUNIT_ASSERT(aFormula2.indexOf("tdf132105_external.ods") < 0);
CPPUNIT_ASSERT(aFormula2.indexOf("87973_externalSource.ods") >= 0);
}
// saveAndReload save the file to a temporary directory // the link must be changed to point to that parent directory
OUString aTempFilename = utl::CreateTempURL(); auto nIdxOfTmpFile = aTempFilename.lastIndexOf('/');
nIdxOfTmpFile = aTempFilename.lastIndexOf('/', nIdxOfTmpFile);
aTempFilename = aTempFilename.copy(0, nIdxOfTmpFile + 1);
// change external link to tmp directory
OUString aFormula = pDoc->GetFormula(3, 1, 0); auto nIdxOfFilename = aFormula.indexOf("tdf138824_externalSource.ods"); auto nIdxOfFile = aFormula.indexOf("file");
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDocXml = parseExport(u"xl/externalLinks/_rels/externalLink1.xml.rels"_ustr);
CPPUNIT_ASSERT(pDocXml);
// test also the Linux specific bug tdf#121472
assertXPath(pDocXml, "/rels:Relationships/rels:Relationship", "Target",
u"../tdf138824_externalSource.ods");
}
// Without the fix in place, this test would have failed with // - Expected: _xffff_ // - Actual :
CPPUNIT_ASSERT_EQUAL(u"_xffff_"_ustr, pDoc->GetString(0, 0, 0));
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf139258_rotated_image)
{ // Check that the topleft position of the image is correct.
createScDoc("ods/tdf139258_rotated_image.ods");
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf144642_RowHeightRounding)
{ // MS Excel round down row heights to 0.75pt // MS Excel can save a row height of 28.35pt, but will display it as a row height of 27.75pt. // Calc simulates this roundings but only if the xlsx file was saved in MS Excel.
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf145129_DefaultRowHeightRounding)
{ // MS Excel round down row heights to 0.75pt // Same as Tdf144642 but with default row height.
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf151755_stylesLostOnXLSXExport)
{ // Check if empty cells with custom style are exported, even if // there is other empty cells with default style, left of it.
createScDoc("xlsx/tdf151755_stylesLostOnXLSXExport.xlsx");
// Resave the xlsx file without any modification.
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
// Check if all the 3 empty cells with styles are saved, and have the same style id.
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c", 4);
OUString aCellStyleId = getXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[2]", "s");
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[2]", "s", aCellStyleId);
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[3]", "s", aCellStyleId);
assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[4]", "s", aCellStyleId);
}
// Resave the xlsx file without any modification.
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pStyles = parseExport(u"xl/styles.xml"_ustr);
CPPUNIT_ASSERT(pStyles);
// Check if conditional format border color is exported
assertXPath(pStyles, "/x:styleSheet/x:dxfs/x:dxf/x:border/x:left/x:color", "theme", u"5");
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testCheckboxFormControlXlsxExport)
{ if (!IsDefaultDPI()) return; // Given a document that has a checkbox form control:
createScDoc("xlsx/checkbox-form-control.xlsx");
// When exporting to XLSX:
save(u"Calc Office Open XML"_ustr);
// Then make sure its VML markup is written and it has a correct position + size:
xmlDocUniquePtr pDoc = parseExport(u"xl/drawings/vmlDrawing1.vml"_ustr); // Without the fix in place, this test would have failed as there was no such stream.
CPPUNIT_ASSERT(pDoc);
assertXPathContent(pDoc, "/xml/v:shape/xx:ClientData/xx:Anchor", u"1, 22, 3, 3, 3, 30, 6, 1");
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testButtonFormControlXlsxExport)
{ // Given a document that has a checkbox form control:
createScDoc("xlsx/button-form-control.xlsx");
// When exporting to XLSX:
save(u"Calc Office Open XML"_ustr);
// Then make sure its control markup is written and it has a correct position + size:
xmlDocUniquePtr pDoc = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pDoc); // Without the fix in place, this test would have failed with: // - XPath '//x:anchor/x:from/xdr:col' not found // i.e. the control markup was missing, the button was lost on export.
assertXPathContent(pDoc, "//x:anchor/x:from/xdr:col", u"1");
assertXPathContent(pDoc, "//x:anchor/x:from/xdr:row", u"3");
assertXPathContent(pDoc, "//x:anchor/x:to/xdr:col", u"3");
assertXPathContent(pDoc, "//x:anchor/x:to/xdr:row", u"7");
// Also make sure that an empty macro attribute is not written. // Without the fix in place, this test would have failed with: // - XPath '//x:controlPr' unexpected 'macro' attribute // i.e. macro in an xlsx file was not omitted, which is considered invalid by Excel.
assertXPathNoAttribute(pDoc, "//x:controlPr", "macro");
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf142929_filterLessThanXLSX)
{ // Document contains a standard filter with '<' condition.
createScDoc("xlsx/tdf142929.xlsx");
CPPUNIT_TEST_FIXTURE(ScExportTest4, testInvalidNamedRange)
{ // Given a document which has a named range (myname) that refers to the "1" external link, but // the link's type is xlPathMissing, when importing that document:
createScDoc("xlsx/invalid-named-range.xlsx");
// Then make sure that named range is ignored, as "1" can't be resolved, and exporting it back // to XLSX (without the xlPathMissing link) would corrupt the document:
uno::Reference<beans::XPropertySet> xDocProps(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xNamedRanges(
xDocProps->getPropertyValue(u"NamedRanges"_ustr), uno::UNO_QUERY); // Without the fix in place, this test would have failed, we didn't ignore the problematic named // range on import.
CPPUNIT_ASSERT(!xNamedRanges->hasByName(u"myname"_ustr));
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testExternalDefinedNameXLSX)
{
createScDoc("xlsx/tdf144397.xlsx");
saveAndReload(u"Calc Office Open XML"_ustr);
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pDoc = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pDoc);
// tdf#143220 link to sheet not valid without cell reference
assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink[@ref='A1']", "location", u"Sheet2!A1");
// tdf#145079 link with defined name target didn't work because Calc added "A1" at the end
assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink[@ref='A2']", "location", u"name");
assertXPath(pDoc, "/x:worksheet/x:hyperlinks/x:hyperlink[@ref='A3']", "location", u"db");
}
CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf142264ManyChartsToXLSX)
{ // The cache size for the test should be small enough, to make sure that some charts get // unloaded in the process, and then loaded on demand properly (default is currently 200)
comphelper::ScopeGuard g([]() {
std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::set(200, pBatch); return pBatch->commit();
});
std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::set(20, pBatch);
pBatch->commit();
createScDoc("ods/many_charts.ods");
saveAndReload(u"Calc Office Open XML"_ustr);
css::uno::Reference<css::drawing::XDrawPagesSupplier> xSupplier(mxComponent,
css::uno::UNO_QUERY_THROW); auto xDrawPages = xSupplier->getDrawPages();
// No charts (or other objects) on the first sheet, and resp. first draw page
css::uno::Reference<css::drawing::XDrawPage> xPage(xDrawPages->getByIndex(0),
css::uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xPage->getCount());
// 20 charts on the second sheet, and resp. second draw page
xPage.set(xDrawPages->getByIndex(1), css::uno::UNO_QUERY_THROW); // Without the fix in place, this test would have failed with // - Expected: 20 // - Actual : 0 // Because only the last 20 charts would get exported, all on the third sheet
CPPUNIT_ASSERT_EQUAL(sal_Int32(20), xPage->getCount()); for (sal_Int32 i = 0; i < xPage->getCount(); ++i)
{
css::uno::Reference<css::beans::XPropertySet> xProps(xPage->getByIndex(i),
css::uno::UNO_QUERY_THROW);
css::uno::Reference<css::chart2::XChartDocument> xChart(
xProps->getPropertyValue(u"Model"_ustr), css::uno::UNO_QUERY_THROW); constauto xDiagram = xChart->getFirstDiagram();
CPPUNIT_ASSERT(xDiagram);
// 20 charts on the third sheet, and resp. third draw page
xPage.set(xDrawPages->getByIndex(2), css::uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(sal_Int32(20), xPage->getCount()); for (sal_Int32 i = 0; i < xPage->getCount(); ++i)
{
css::uno::Reference<css::beans::XPropertySet> xProps(xPage->getByIndex(i),
css::uno::UNO_QUERY_THROW);
css::uno::Reference<css::chart2::XChartDocument> xChart(
xProps->getPropertyValue(u"Model"_ustr), css::uno::UNO_QUERY_THROW); constauto xDiagram = xChart->getFirstDiagram();
CPPUNIT_ASSERT(xDiagram);
// Without the fix in place, this would have failed with: // An uncaught exception of type com.sun.star.uno.RuntimeException // - unsatisfied query for interface of type com.sun.star.text.XTextColumns!
css::uno::Reference<css::text::XTextColumns> xCols(
xProps->getPropertyValue(u"TextColumns"_ustr), css::uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCols->getColumnCount());
css::uno::Reference<css::beans::XPropertySet> xColProps(xCols, css::uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(css::uno::Any(sal_Int32(1000)),
xColProps->getPropertyValue(u"AutomaticDistance"_ustr));
}
xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr);
CPPUNIT_ASSERT(pXmlDoc); // Without the fix in place, this would have failed with: // - Expected: 1 // - Actual : 0 // - In <>, XPath '/office:document-content/office:automatic-styles/style:style[@style:family='graphic']/ // style:graphic-properties/style:columns' number of nodes is incorrect
assertXPath(
pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='graphic']/" "style:graphic-properties/style:columns", "column-count", u"2"); // Only test that "column-gap" attribute exists, not its value that depends on locale (cm, in)
getXPath(
pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='graphic']/" "style:graphic-properties/style:columns", "column-gap");
}
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
// Get DxfId for color filter
sal_Int32 nDxfIdColorFilter
= getXPath(pSheet, "/x:worksheet/x:autoFilter/x:filterColumn/x:colorFilter", "dxfId")
.toInt32()
+ 1;
// Get DxfId for conditional formatting
sal_Int32 nDxfIdCondFormat
= getXPath(pSheet, "/x:worksheet/x:conditionalFormatting/x:cfRule", "dxfId").toInt32() + 1;
// Ensure they are using different dxfs
CPPUNIT_ASSERT_MESSAGE("dxfID's should be different!", nDxfIdColorFilter != nDxfIdCondFormat);
// Check colors used by these dxfs
xmlDocUniquePtr pStyles = parseExport(u"xl/styles.xml"_ustr);
CPPUNIT_ASSERT(pStyles);
// Resave the xlsx file without any modification.
save(u"Calc Office Open XML"_ustr);
xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr);
CPPUNIT_ASSERT(pSheet);
xmlDocUniquePtr pStyle = parseExport(u"xl/styles.xml"_ustr);
CPPUNIT_ASSERT(pStyle);
// Check to see whether the indents remain the same as the original ones:
// Get the style index number for cell A1
sal_Int32 nCellA1StyleIndex
= getXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]/x:c[1]", "s").toInt32() + 1; // The indent for cell A1 should be 0
OString sStyleA1XPath
= "/x:styleSheet/x:cellXfs/x:xf[" + OString::number(nCellA1StyleIndex) + "]/x:alignment"; // (if this assertion fails, you should first check whether there is no style index set for this cell)
assertXPath(pStyle, sStyleA1XPath, "indent", u"0");
sal_Int32 nCellA3StyleIndex
= getXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]/x:c[1]", "s").toInt32() + 1; // The indent for cell A3 should be 1
OString sStyleA3XPath
= "/x:styleSheet/x:cellXfs/x:xf[" + OString::number(nCellA3StyleIndex) + "]/x:alignment";
assertXPath(pStyle, sStyleA3XPath, "indent", u"1");
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.