sw: only load one document per test

Change-Id: I3277454a2f2b73fffcff79ad17b2a9d32e02847d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198979
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Xisco Fauli
2026-02-16 22:42:57 +01:00
parent 86ef1791b2
commit fe2eae0cde
22 changed files with 763 additions and 619 deletions
@@ -340,7 +340,7 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testStylesWithHeader)
// Text contrast tests
// see https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html
CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTextContrast)
CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTextContrast_Fail)
{
// first test doc has these issues:
// * normal text with contrast < 4.5
@@ -355,7 +355,10 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTextContrast)
CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_CONTRAST, aIssues[0]->m_eIssueID);
CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_CONTRAST, aIssues[1]->m_eIssueID);
CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_CONTRAST, aIssues[2]->m_eIssueID);
}
CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTextContrast_Ok)
{
// second test doc has large text with contrast between 3.0 and 4.5,
// which is sufficient for large text
// both of these are considered large text according to the spec:
+2
View File
@@ -1409,6 +1409,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf41652NBSPWidth)
nSectionAfterNBSPX_legacy_leftAligned = getXPath(pXmlDoc, "//textarray[4]", "x").toInt32();
nSectionAfterNBSPX_legacy_justified = getXPath(pXmlDoc, "//textarray[10]", "x").toInt32();
dispose();
}
// Measure the X of sections after NBSPs in a file with the option enabled
@@ -1423,6 +1424,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf41652NBSPWidth)
= getXPath(pXmlDoc, "//textarray[4]", "x").toInt32();
nSectionAfterNBSPX_optionDisabled_justified
= getXPath(pXmlDoc, "//textarray[10]", "x").toInt32();
dispose();
}
// Measure the X of the sections after NBSPs in a file with the option enabled
+1
View File
@@ -619,6 +619,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testTdf162715_ownTransferable)
css::uno::Reference<css::datatransfer::XTransferableSupplier> xTS(
xModel->getCurrentController(), css::uno::UNO_QUERY_THROW);
xTransferable = xTS->getTransferable();
dispose();
}
{
// Open another document with another custom theme:
+140 -141
View File
@@ -169,179 +169,178 @@ CPPUNIT_TEST_FIXTURE(Test, testOpenODTWithRestrictedEmbeddedFont)
{
// The ODT has a restricted embedded font, referenced both from styles.xml and content.xml.
// Test its loading without and with approval; and check that there are no double requests
{
// 1. Load and do not approve the restricted font
FontMappingUseListener fontMappingData;
rtl::Reference xInteraction(new FontInteractionHandler(false));
createSwDoc("embed-restricted-style+autostyle.odt",
{ comphelper::makePropertyValue(
u"InteractionHandler"_ustr,
uno::Reference<task::XInteractionHandler>(xInteraction)) });
// 1. Load and do not approve the restricted font
FontMappingUseListener fontMappingData;
rtl::Reference xInteraction(new FontInteractionHandler(false));
createSwDoc(
"embed-restricted-style+autostyle.odt",
{ comphelper::makePropertyValue(u"InteractionHandler"_ustr,
uno::Reference<task::XInteractionHandler>(xInteraction)) });
// It asked exactly once, even though both styles.xml and content.xml requested the font:
CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount());
// It requested the expected font
CPPUNIT_ASSERT_EQUAL(u"Naftalene"_ustr, xInteraction->getRequestedFontName().trim());
// The document is editable:
CPPUNIT_ASSERT(!getSwDocShell()->IsReadOnly());
// It asked exactly once, even though both styles.xml and content.xml requested the font:
CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount());
// It requested the expected font
CPPUNIT_ASSERT_EQUAL(u"Naftalene"_ustr, xInteraction->getRequestedFontName().trim());
// The document is editable:
CPPUNIT_ASSERT(!getSwDocShell()->IsReadOnly());
fontMappingData.checkpoint();
// The request was disapproved, and the font didn't load; so it was substituted:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(fontMappingData.wasSubstituted(u"Naftalene"));
fontMappingData.checkpoint();
// The request was disapproved, and the font didn't load; so it was substituted:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(fontMappingData.wasSubstituted(u"Naftalene"));
// Make sure that saving doesn't somehow embed the font
save(TestFilter::ODT);
xmlDocUniquePtr pXml = parseExport(u"content.xml"_ustr);
assertXPath(pXml, "//style:font-face[@style:name='Naftalene']");
assertXPath(pXml, "//style:font-face[@style:name='Naftalene']/svg:font-face-src", 0);
// Make sure that saving doesn't somehow embed the font
save(TestFilter::ODT);
xmlDocUniquePtr pXml = parseExport(u"content.xml"_ustr);
assertXPath(pXml, "//style:font-face[@style:name='Naftalene']");
assertXPath(pXml, "//style:font-face[@style:name='Naftalene']/svg:font-face-src", 0);
auto xZipFile = packages::zip::ZipFileAccess::createWithURL(
comphelper::getProcessComponentContext(), maTempFile.GetURL());
CPPUNIT_ASSERT(xZipFile);
for (const OUString& name : xZipFile->getElementNames())
CPPUNIT_ASSERT(name.indexOf("Naftalene") < 0);
}
auto xZipFile = packages::zip::ZipFileAccess::createWithURL(
comphelper::getProcessComponentContext(), maTempFile.GetURL());
CPPUNIT_ASSERT(xZipFile);
for (const OUString& name : xZipFile->getElementNames())
CPPUNIT_ASSERT(name.indexOf("Naftalene") < 0);
}
{
// 2. Load and approve the restricted font
FontMappingUseListener fontMappingData;
rtl::Reference xInteraction(new FontInteractionHandler(true));
createSwDoc("embed-restricted-style+autostyle.odt",
{ comphelper::makePropertyValue(
u"InteractionHandler"_ustr,
uno::Reference<task::XInteractionHandler>(xInteraction)) });
CPPUNIT_TEST_FIXTURE(Test, testOpenODTWithRestrictedEmbeddedFont2)
{
// 2. Load and approve the restricted font
FontMappingUseListener fontMappingData;
rtl::Reference xInteraction(new FontInteractionHandler(true));
createSwDoc(
"embed-restricted-style+autostyle.odt",
{ comphelper::makePropertyValue(u"InteractionHandler"_ustr,
uno::Reference<task::XInteractionHandler>(xInteraction)) });
// It asked exactly once, even though both styles.xml and content.xml requested the font:
CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount());
// It requested the expected font
CPPUNIT_ASSERT_EQUAL(u"Naftalene"_ustr, xInteraction->getRequestedFontName().trim());
// The document loaded read-only:
CPPUNIT_ASSERT(getSwDocShell()->IsReadOnly());
// It asked exactly once, even though both styles.xml and content.xml requested the font:
CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount());
// It requested the expected font
CPPUNIT_ASSERT_EQUAL(u"Naftalene"_ustr, xInteraction->getRequestedFontName().trim());
// The document loaded read-only:
CPPUNIT_ASSERT(getSwDocShell()->IsReadOnly());
fontMappingData.checkpoint();
// The request was approved, and the font loaded; no substitution happened:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Naftalene"));
fontMappingData.checkpoint();
// The request was approved, and the font loaded; no substitution happened:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Naftalene"));
// Make sure that saving doesn't somehow embed the font
save(TestFilter::ODT);
xmlDocUniquePtr pXml = parseExport(u"content.xml"_ustr);
assertXPath(pXml, "//style:font-face[@style:name='Naftalene']");
assertXPath(pXml, "//style:font-face[@style:name='Naftalene']/svg:font-face-src", 0);
// Make sure that saving doesn't somehow embed the font
save(TestFilter::ODT);
xmlDocUniquePtr pXml = parseExport(u"content.xml"_ustr);
assertXPath(pXml, "//style:font-face[@style:name='Naftalene']");
assertXPath(pXml, "//style:font-face[@style:name='Naftalene']/svg:font-face-src", 0);
auto xZipFile = packages::zip::ZipFileAccess::createWithURL(
comphelper::getProcessComponentContext(), maTempFile.GetURL());
CPPUNIT_ASSERT(xZipFile);
for (const OUString& name : xZipFile->getElementNames())
CPPUNIT_ASSERT(name.indexOf("Naftalene") < 0);
}
auto xZipFile = packages::zip::ZipFileAccess::createWithURL(
comphelper::getProcessComponentContext(), maTempFile.GetURL());
CPPUNIT_ASSERT(xZipFile);
for (const OUString& name : xZipFile->getElementNames())
CPPUNIT_ASSERT(name.indexOf("Naftalene") < 0);
}
CPPUNIT_TEST_FIXTURE(Test, testOpenDOCXWithRestrictedEmbeddedFont)
{
// The DOCX has two embedded fonts, one restricted (Naftalene), one unrestricted (Unsteady
// Oversteer). Test without interaction handler, and with handler (without and with approval).
{
// 1. Load without interaction handler. It must not load the restricted font;
// unrestricted one must load.
FontMappingUseListener fontMappingData;
loadFromFile(u"embed-restricted+unrestricted.docx");
// 1. Load without interaction handler. It must not load the restricted font;
// unrestricted one must load.
FontMappingUseListener fontMappingData;
loadFromFile(u"embed-restricted+unrestricted.docx");
// The document is editable:
CPPUNIT_ASSERT(!getSwDocShell()->IsReadOnly());
// The document is editable:
CPPUNIT_ASSERT(!getSwDocShell()->IsReadOnly());
fontMappingData.checkpoint();
fontMappingData.checkpoint();
// Interaction handler was absent, and the restricted font didn't load; it was substituted:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(fontMappingData.wasSubstituted(u"Naftalene"));
// Interaction handler was absent, and the restricted font didn't load; it was substituted:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(fontMappingData.wasSubstituted(u"Naftalene"));
// Unrestricted font was loaded and used without substitution:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Unsteady Oversteer"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Unsteady Oversteer"));
// Unrestricted font was loaded and used without substitution:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Unsteady Oversteer"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Unsteady Oversteer"));
// Make sure that saving doesn't somehow embed the font
save(TestFilter::DOCX);
xmlDocUniquePtr pXml = parseExport(u"word/fontTable.xml"_ustr);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']");
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedRegular", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBold", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedItalic", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBoldItalic", 0);
}
// Make sure that saving doesn't somehow embed the font
save(TestFilter::DOCX);
xmlDocUniquePtr pXml = parseExport(u"word/fontTable.xml"_ustr);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']");
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedRegular", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBold", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedItalic", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBoldItalic", 0);
}
{
// 2. Load and do not approve the restricted font. It must not load the restricted font;
// unrestricted one must load.
FontMappingUseListener fontMappingData;
rtl::Reference xInteraction(new FontInteractionHandler(false));
createSwDoc("embed-restricted+unrestricted.docx",
{ comphelper::makePropertyValue(
u"InteractionHandler"_ustr,
uno::Reference<task::XInteractionHandler>(xInteraction)) });
CPPUNIT_TEST_FIXTURE(Test, testOpenDOCXWithRestrictedEmbeddedFont2)
{
// 2. Load and do not approve the restricted font. It must not load the restricted font;
// unrestricted one must load.
FontMappingUseListener fontMappingData;
rtl::Reference xInteraction(new FontInteractionHandler(false));
createSwDoc(
"embed-restricted+unrestricted.docx",
{ comphelper::makePropertyValue(u"InteractionHandler"_ustr,
uno::Reference<task::XInteractionHandler>(xInteraction)) });
CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount());
// It requested only the expected font (no requests for 'Unsteady Oversteer')
CPPUNIT_ASSERT_EQUAL(u"Naftalene"_ustr, xInteraction->getRequestedFontName().trim());
// The document is editable:
CPPUNIT_ASSERT(!getSwDocShell()->IsReadOnly());
CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount());
// It requested only the expected font (no requests for 'Unsteady Oversteer')
CPPUNIT_ASSERT_EQUAL(u"Naftalene"_ustr, xInteraction->getRequestedFontName().trim());
// The document is editable:
CPPUNIT_ASSERT(!getSwDocShell()->IsReadOnly());
fontMappingData.checkpoint();
fontMappingData.checkpoint();
// The request was disapproved, and the font didn't load; so it was substituted:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(fontMappingData.wasSubstituted(u"Naftalene"));
// The request was disapproved, and the font didn't load; so it was substituted:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(fontMappingData.wasSubstituted(u"Naftalene"));
// Unrestricted font was loaded and used without substitution:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Unsteady Oversteer"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Unsteady Oversteer"));
// Unrestricted font was loaded and used without substitution:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Unsteady Oversteer"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Unsteady Oversteer"));
// Make sure that saving doesn't somehow embed the font
save(TestFilter::DOCX);
xmlDocUniquePtr pXml = parseExport(u"word/fontTable.xml"_ustr);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']");
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedRegular", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBold", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedItalic", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBoldItalic", 0);
}
// Make sure that saving doesn't somehow embed the font
save(TestFilter::DOCX);
xmlDocUniquePtr pXml = parseExport(u"word/fontTable.xml"_ustr);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']");
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedRegular", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBold", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedItalic", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBoldItalic", 0);
}
{
// 3. Load and approve the restricted font. It must load both fonts, and open in read-only
// mode.
FontMappingUseListener fontMappingData;
rtl::Reference xInteraction(new FontInteractionHandler(true));
createSwDoc("embed-restricted+unrestricted.docx",
{ comphelper::makePropertyValue(
u"InteractionHandler"_ustr,
uno::Reference<task::XInteractionHandler>(xInteraction)) });
CPPUNIT_TEST_FIXTURE(Test, testOpenDOCXWithRestrictedEmbeddedFont3)
{
// 3. Load and approve the restricted font. It must load both fonts, and open in read-only
// mode.
FontMappingUseListener fontMappingData;
rtl::Reference xInteraction(new FontInteractionHandler(true));
createSwDoc(
"embed-restricted+unrestricted.docx",
{ comphelper::makePropertyValue(u"InteractionHandler"_ustr,
uno::Reference<task::XInteractionHandler>(xInteraction)) });
CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount());
// It requested the expected font
CPPUNIT_ASSERT_EQUAL(u"Naftalene"_ustr, xInteraction->getRequestedFontName().trim());
// The document loaded read-only:
CPPUNIT_ASSERT(getSwDocShell()->IsReadOnly());
CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount());
// It requested the expected font
CPPUNIT_ASSERT_EQUAL(u"Naftalene"_ustr, xInteraction->getRequestedFontName().trim());
// The document loaded read-only:
CPPUNIT_ASSERT(getSwDocShell()->IsReadOnly());
fontMappingData.checkpoint();
fontMappingData.checkpoint();
// The request was approved, and the restricted font loaded; no substitution:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Naftalene"));
// The request was approved, and the restricted font loaded; no substitution:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Naftalene"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Naftalene"));
// Unrestricted font was loaded and used without substitution:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Unsteady Oversteer"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Unsteady Oversteer"));
// Unrestricted font was loaded and used without substitution:
CPPUNIT_ASSERT(fontMappingData.wasUsed(u"Unsteady Oversteer"));
CPPUNIT_ASSERT(!fontMappingData.wasSubstituted(u"Unsteady Oversteer"));
// Make sure that saving doesn't somehow embed the font
save(TestFilter::DOCX);
xmlDocUniquePtr pXml = parseExport(u"word/fontTable.xml"_ustr);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']");
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedRegular", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBold", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedItalic", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBoldItalic", 0);
}
// Make sure that saving doesn't somehow embed the font
save(TestFilter::DOCX);
xmlDocUniquePtr pXml = parseExport(u"word/fontTable.xml"_ustr);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']");
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedRegular", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBold", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedItalic", 0);
assertXPath(pXml, "/w:fonts/w:font[@w:name='Naftalene']/w:embedBoldItalic", 0);
}
#if !defined(MACOSX)
+9 -5
View File
@@ -593,8 +593,8 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIfPngImg)
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true),
};
save(TestFilter::HTML_WRITER, aStoreProperties);
ImportFromReqif(maTempFile.GetURL());
setImportFilterName(TestFilter::HTML_WRITER);
saveAndReload(TestFilter::HTML_WRITER, aStoreProperties);
verify(/*bExported=*/true);
}
@@ -1081,7 +1081,12 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifOle1PDF)
// Save to reqif-xhtml.
createSwDoc("pdf-ole.odt");
ExportToReqif();
setImportFilterName(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
OUString aRtfUrl = GetOlePath();
SvMemoryStream aOle1;
ParseOle1FromRtfUrl(aRtfUrl, aOle1);
@@ -1096,8 +1101,7 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifOle1PDF)
// OLE1-in-OLE2 data, resulting in additional size.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0x99ed), aOle1Reader.m_nNativeDataSize);
// Now import this back and check the ODT result.
ImportFromReqif(maTempFile.GetURL());
// Now check the ODT result.
save(TestFilter::ODT);
uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
+36 -41
View File
@@ -375,7 +375,12 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTrailingLineBreak)
pWrtShell->Insert(u"test\n"_ustr);
// When exporting to reqif-xhtml:
ExportToReqif();
setImportFilterName(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
// Then make sure that we still have a single line-break:
xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
@@ -388,8 +393,6 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTrailingLineBreak)
// Then test the import side:
// Given an empty document:
// When importing a <br> from reqif-xhtml:
ImportFromReqif(maTempFile.GetURL());
// Then make sure that line-break is not lost:
pWrtShell = getSwDocShell()->GetWrtShell();
OUString aActual = pWrtShell->GetCursor()->GetPointNode().GetTextNode()->GetText();
@@ -926,12 +929,16 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf156647_CellPaddingRoundtrip)
CPPUNIT_ASSERT(aTableBorder.IsDistanceValid);
}
// When exporting to reqif-xhtml:
ExportToReqif();
setImportFilterName(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
});
// Make sure that we export it:
xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
assertXPath(pXmlDoc, "//reqif-xhtml:table", "cellpadding", u"48"); // px
// Now import it
ImportFromReqif(maTempFile.GetURL());
// Then make sure that padding is not lost:
{
auto xTable = getParagraphOrTable(1);
@@ -965,9 +972,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_PreserveSpaces)
pWrtShell->Insert(paraText);
// When exporting to plain HTML, using PreserveSpaces:
save(TestFilter::HTML_WRITER, {
comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true),
});
setImportFilterName(TestFilter::HTML_WRITER);
saveAndReload(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true),
});
// Then make sure that "white-space: pre-wrap" is written into the paragraph's style:
htmlDocUniquePtr pHtmlDoc = parseHtml(maTempFile);
@@ -978,9 +987,6 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_PreserveSpaces)
assertXPathContent(pHtmlDoc, "/html/body/p", paraText);
// Test import
setImportFilterName(TestFilter::HTML_WRITER);
loadFromURL(maTempFile.GetURL());
CPPUNIT_ASSERT_EQUAL(paraText, getParagraph(1)->getString());
}
@@ -993,11 +999,13 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_PreserveSpaces)
pWrtShell->Insert(paraText);
// When exporting to ReqIF, using PreserveSpaces:
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true),
});
setImportFilterName(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true),
});
// Then make sure that xml:space="preserve" attribute exists in the paragraph element:
xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
@@ -1006,12 +1014,6 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_PreserveSpaces)
assertXPathContent(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p", paraText);
// Test import
setImportFilterName(TestFilter::HTML_WRITER);
loadFromURL(maTempFile.GetURL(), {
comphelper::makePropertyValue(u"FilterOptions"_ustr,
u"xhtmlns=reqif-xhtml"_ustr),
});
CPPUNIT_ASSERT_EQUAL(paraText, getParagraph(1)->getString());
}
@@ -1042,9 +1044,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_NoPreserveSpaces)
createSwDoc("test_no_space_preserve.fodt");
// Export to plain HTML, using PreserveSpaces:
save(TestFilter::HTML_WRITER, {
comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true),
});
setImportFilterName(TestFilter::HTML_WRITER);
saveAndReload(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true),
});
htmlDocUniquePtr pHtmlDoc = parseHtml(maTempFile);
CPPUNIT_ASSERT(pHtmlDoc);
@@ -1073,10 +1077,6 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_NoPreserveSpaces)
assertXPath_NoWhiteSpaceInStyle(pHtmlDoc, "/html/body/p[11]");
// Test import
setImportFilterName(TestFilter::HTML_WRITER);
loadFromURL(maTempFile.GetURL());
CPPUNIT_ASSERT_EQUAL(u"No special spaces"_ustr, getParagraph(1)->getString());
CPPUNIT_ASSERT_EQUAL(u" Leading space"_ustr, getParagraph(2)->getString());
CPPUNIT_ASSERT_EQUAL(u"Trailing space "_ustr, getParagraph(3)->getString());
@@ -1100,11 +1100,13 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_NoPreserveSpaces)
createSwDoc("test_no_space_preserve.fodt");
// Export to ReqIF, using PreserveSpaces:
save(TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true),
});
setImportFilterName(TestFilter::HTML_WRITER);
saveAndReload(
TestFilter::HTML_WRITER,
{
comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr),
comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true),
});
xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
@@ -1137,13 +1139,6 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_NoPreserveSpaces)
assertXPathNoAttribute(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p[11]", "space");
// Test import
setImportFilterName(TestFilter::HTML_WRITER);
loadFromURL(maTempFile.GetURL(), {
comphelper::makePropertyValue(u"FilterOptions"_ustr,
u"xhtmlns=reqif-xhtml"_ustr),
});
CPPUNIT_ASSERT_EQUAL(u"No special spaces"_ustr, getParagraph(1)->getString());
CPPUNIT_ASSERT_EQUAL(u" Leading space"_ustr, getParagraph(2)->getString());
CPPUNIT_ASSERT_EQUAL(u"Trailing space "_ustr, getParagraph(3)->getString());
+3 -5
View File
@@ -3633,11 +3633,9 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92)
}
//just care it doesn't crash/assert
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93)
{
createSwDoc("forcepoint93-1.rtf");
createSwDoc("forcepoint93-2.rtf");
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93_1) { createSwDoc("forcepoint93-1.rtf"); }
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93_2) { createSwDoc("forcepoint93-2.rtf"); }
//just care it doesn't crash/assert
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) { createSwWebDoc("forcepoint94.html"); }
+31 -14
View File
@@ -638,7 +638,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf134548)
}
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf124423)
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf124423_DOCX)
{
createSwDoc("tdf124423.docx");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
@@ -649,12 +649,17 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf124423)
sal_Int32 nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", "width").toInt32();
CPPUNIT_ASSERT_EQUAL(nPageWidth, nFly2Width);
CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf124423_ODT)
{
createSwDoc("tdf124423.odt");
pXmlDoc = parseLayoutDump();
nFly1Width = getXPath(pXmlDoc, "(//anchored/fly)[1]/infos/prtBounds", "width").toInt32();
nFly2Width = getXPath(pXmlDoc, "(//anchored/fly)[2]/infos/prtBounds", "width").toInt32();
nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", "width").toInt32();
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 nFly1Width
= getXPath(pXmlDoc, "(//anchored/fly)[1]/infos/prtBounds", "width").toInt32();
sal_Int32 nFly2Width
= getXPath(pXmlDoc, "(//anchored/fly)[2]/infos/prtBounds", "width").toInt32();
sal_Int32 nPageWidth = getXPath(pXmlDoc, "//page/infos/prtBounds", "width").toInt32();
CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly2Width);
CPPUNIT_ASSERT_LESS(nPageWidth / 2, nFly1Width);
}
@@ -714,7 +719,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf138782)
.toInt32());
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf135035)
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf135035_DOCX)
{
createSwDoc("tdf135035.docx");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
@@ -728,13 +733,19 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf135035)
CPPUNIT_ASSERT_EQUAL(nParentWidth, nFly2Width);
CPPUNIT_ASSERT_EQUAL(nParentWidth, nFly3Width);
CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly1Width);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf135035_ODT)
{
createSwDoc("tdf135035.odt");
pXmlDoc = parseLayoutDump();
nFly1Width = getXPath(pXmlDoc, "(//anchored/fly)[1]/infos/prtBounds", "width").toInt32();
nFly2Width = getXPath(pXmlDoc, "(//anchored/fly)[2]/infos/prtBounds", "width").toInt32();
nFly3Width = getXPath(pXmlDoc, "(//anchored/fly)[3]/infos/prtBounds", "width").toInt32();
nParentWidth = getXPath(pXmlDoc, "(//txt)[1]/infos/prtBounds", "width").toInt32();
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
sal_Int32 nFly1Width
= getXPath(pXmlDoc, "(//anchored/fly)[1]/infos/prtBounds", "width").toInt32();
sal_Int32 nFly2Width
= getXPath(pXmlDoc, "(//anchored/fly)[2]/infos/prtBounds", "width").toInt32();
sal_Int32 nFly3Width
= getXPath(pXmlDoc, "(//anchored/fly)[3]/infos/prtBounds", "width").toInt32();
sal_Int32 nParentWidth = getXPath(pXmlDoc, "(//txt)[1]/infos/prtBounds", "width").toInt32();
CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly2Width);
CPPUNIT_ASSERT_LESS(nParentWidth / 2, nFly1Width);
CPPUNIT_ASSERT_GREATER(nParentWidth, nFly3Width);
@@ -760,7 +771,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf139336_ColumnsWithFootnoteDoNotOccu
assertXPath(pXmlDoc, "/root/page", 2);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage)
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_Old)
{
// Old odt files should keep their original layout, as it was before Tdf139336 fix.
// The new odt file is only 1 page long, while the old odt file (with the same content)
@@ -774,9 +785,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf54465_ColumnsWithFootnoteDoNotOccup
xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
CPPUNIT_ASSERT_GREATER(1, xmlXPathNodeSetGetLength(pXmlNodes));
xmlXPathFreeObject(pXmlObj);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, testTdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_New)
{
createSwDoc("tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_New.odt");
pXmlDoc = parseLayoutDump();
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "/root/page", 1);
}
@@ -1828,12 +1842,15 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, TestTdf162614)
// - Expected: 770
// - Actual : 267
assertXPath(pXmlDoc, "//page[2]/body/tab[2]/infos/bounds", "height", u"770");
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter4, TestTdf162614_2)
{
// Now a test for a case that took me some time to fix when creating the patch.
// It is the greatly simplified tdf124795-5.
createSwDoc("C4_must_start_on_p1.fodt");
pXmlDoc = parseLayoutDump();
auto pXmlDoc = parseLayoutDump();
// The first line of C4 text must start on the first page - the initial version of the fix
// moved it to page 2.
+4 -1
View File
@@ -2137,7 +2137,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf72341GrowAllScripts)
CPPUNIT_ASSERT_GREATER(nWidthAlephInitial, nWidthAlephResized);
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf168858)
CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf168858_singleHiddenSection)
{
// Both test documents have no content outside of hidden sections.
// Each test checks, that the document loads OK, sections in the document load with correct
@@ -2186,7 +2186,10 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf168858)
assertXPath(pXmlDoc, "//page['pass 2']/body/section", "formatName", u"abc");
assertXPath(pXmlDoc, "//page['pass 2']/body/section/infos/bounds", "height", u"0");
}
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf168858_nestedHiddenSection)
{
// 2. A conditionally hidden section inside another hidden section
{
createSwDoc("tdf168858_nested_hidden_section.fodt");
+1
View File
@@ -340,6 +340,7 @@ DECLARE_FILE_MAILMERGE_TEST(testTdf102010, "empty.odt", "10-testing-addresses.od
// Generate correct mail merge result filename
executeMailMerge();
dispose();
// Don't overwrite previous result
executeMailMerge( true );
loadMailMergeDocument( 1 );
@@ -260,6 +260,7 @@ public:
void loadMailMergeDocument(const OUString& filename)
{
assert(mnCurOutputType == text::MailMergeType::FILE);
dispose();
// Output name early, so in the case of a hang, the name of the hanging input file is visible.
std::cout << filename << ",";
loadFromURL(msMailMergeOutputURL + "/" + filename);
+70 -56
View File
@@ -83,65 +83,64 @@ CPPUNIT_TEST_FIXTURE(Test, tdf150927)
"/office:document-styles/office:automatic-styles/style:style[@style:family='table']", 2);
}
CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaData)
CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaDataAndKeepUserInformation)
{
ScopedConfigValue<ScriptingCfg::RemovePersonalInfoOnSaving> aCfg1(true);
{
// 1. Remove personal info, keep user info
ScopedConfigValue<ScriptingCfg::KeepDocUserInfoOnSaving> aCfg2(true);
// 1. Remove personal info, keep user info
ScopedConfigValue<ScriptingCfg::KeepDocUserInfoOnSaving> aCfg2(true);
createSwDoc("personalmetadata.odt");
saveAndReload(TestFilter::ODT);
xmlDocUniquePtr pXmlDoc = parseExport(u"meta.xml"_ustr);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:initial-creator", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:creation-date", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/dc:date", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/dc:creator", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:printed-by", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:print-date", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:editing-duration", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:editing-cycles", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:template", 0);
pXmlDoc = parseExport(u"settings.xml"_ustr);
assertXPath(pXmlDoc,
"/office:document-settings/office:settings/config:config-item-set[2]/"
"config:config-item[@config:name='PrinterName']",
0);
assertXPath(pXmlDoc,
"/office:document-settings/office:settings/config:config-item-set[2]/"
"config:config-item[@config:name='PrinterSetup']",
0);
}
{
// 2. Remove user info too
ScopedConfigValue<ScriptingCfg::KeepDocUserInfoOnSaving> aCfg2(false);
createSwDoc("personalmetadata.odt");
saveAndReload(TestFilter::ODT);
xmlDocUniquePtr pXmlDoc = parseExport(u"meta.xml"_ustr);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:initial-creator", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:creation-date", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/dc:date", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/dc:creator", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:printed-by", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:print-date", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:editing-duration", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:editing-cycles", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:template", 0);
pXmlDoc = parseExport(u"settings.xml"_ustr);
assertXPath(pXmlDoc,
"/office:document-settings/office:settings/config:config-item-set[2]/"
"config:config-item[@config:name='PrinterName']",
0);
assertXPath(pXmlDoc,
"/office:document-settings/office:settings/config:config-item-set[2]/"
"config:config-item[@config:name='PrinterSetup']",
0);
}
createSwDoc("personalmetadata.odt");
saveAndReload(TestFilter::ODT);
xmlDocUniquePtr pXmlDoc = parseExport(u"meta.xml"_ustr);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:initial-creator", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:creation-date", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/dc:date", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/dc:creator", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:printed-by", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:print-date", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:editing-duration", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:editing-cycles", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:template", 0);
pXmlDoc = parseExport(u"settings.xml"_ustr);
assertXPath(pXmlDoc,
"/office:document-settings/office:settings/config:config-item-set[2]/"
"config:config-item[@config:name='PrinterName']",
0);
assertXPath(pXmlDoc,
"/office:document-settings/office:settings/config:config-item-set[2]/"
"config:config-item[@config:name='PrinterSetup']",
0);
}
CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData)
CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaData)
{
// 1. Remove all personal info
ScopedConfigValue<ScriptingCfg::RemovePersonalInfoOnSaving> aCfg1(true);
createSwDoc("personalmetadata.odt");
saveAndReload(TestFilter::ODT);
xmlDocUniquePtr pXmlDoc = parseExport(u"meta.xml"_ustr);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:initial-creator", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:creation-date", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/dc:date", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/dc:creator", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:printed-by", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:print-date", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:editing-duration", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:editing-cycles", 0);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/meta:template", 0);
pXmlDoc = parseExport(u"settings.xml"_ustr);
assertXPath(pXmlDoc,
"/office:document-settings/office:settings/config:config-item-set[2]/"
"config:config-item[@config:name='PrinterName']",
0);
assertXPath(pXmlDoc,
"/office:document-settings/office:settings/config:config-item-set[2]/"
"config:config-item[@config:name='PrinterSetup']",
0);
}
CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData_Disabled)
{
// 1. Check we have the original edit time info
createSwDoc("personalmetadata.odt");
@@ -149,14 +148,17 @@ CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData)
xmlDocUniquePtr pXmlDoc = parseExport(u"meta.xml"_ustr);
assertXPathContent(pXmlDoc, "/office:document-meta/office:meta/meta:editing-duration",
u"PT21M22S");
}
CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData_Enabled)
{
// Set config RemoveEditingTimeOnSaving to true
ScopedConfigValue<ScriptingCfg::RemoveEditingTimeOnSaving> aCfg(true);
// 2. Check edit time info is 0
createSwDoc("personalmetadata.odt");
save(TestFilter::ODT);
pXmlDoc = parseExport(u"meta.xml"_ustr);
xmlDocUniquePtr pXmlDoc = parseExport(u"meta.xml"_ustr);
assertXPathContent(pXmlDoc, "/office:document-meta/office:meta/meta:editing-duration", u"P0D");
}
@@ -898,7 +900,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf150408_IsLegal)
"is-legal", u"true");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf159382)
CPPUNIT_TEST_FIXTURE(Test, testTdf159382_DOCX)
{
// Testing NoGapAfterNoteNumber compat option
@@ -945,7 +947,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf159382)
CPPUNIT_ASSERT(width);
CPPUNIT_ASSERT_LESS(sal_Int32(100), width);
}
}
CPPUNIT_TEST_FIXTURE(Test, testTdf159382_DOC)
{
createSwDoc("footnote_spacing_hanging_para.doc");
// 3. Make sure that DOC import sets NoGapAfterNoteNumber option, and creates
// correct layout
@@ -965,7 +970,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf159382)
CPPUNIT_ASSERT(width);
CPPUNIT_ASSERT_LESS(sal_Int32(100), width);
}
}
CPPUNIT_TEST_FIXTURE(Test, testTdf159382_RTF)
{
createSwDoc("footnote_spacing_hanging_para.rtf");
// 4. Make sure that RTF import sets NoGapAfterNoteNumber option, and creates
// correct layout
@@ -985,7 +993,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf159382)
CPPUNIT_ASSERT(width);
CPPUNIT_ASSERT_LESS(sal_Int32(100), width);
}
}
CPPUNIT_TEST_FIXTURE(Test, testTdf159382_NewDocument)
{
createSwDoc();
// 5. Make sure that a new Writer document has this setting set to false
{
@@ -1520,7 +1531,10 @@ CPPUNIT_TEST_FIXTURE(Test, testMsWordUlTrailSpace)
CPPUNIT_ASSERT_EQUAL(uno::Any(false),
xSettings->getPropertyValue(u"MsWordUlTrailSpace"_ustr));
}
}
CPPUNIT_TEST_FIXTURE(Test, testMsWordUlTrailSpace_NewDocument)
{
createSwDoc();
// 5. Make sure that a new Writer document has this setting set to false
{
+1
View File
@@ -390,6 +390,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf149978)
{
createSwDoc("tdf149978.fodt");
// on Linux the bug only reproduces if a document has been loaded previously
dispose();
createSwDoc("tdf149978.fodt");
// this was nondeterministic so try 10 times
for (int i = 1; i <= 10; ++i)
@@ -72,6 +72,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf128197)
xmlDocUniquePtr pLayout14 = parseLayoutDump();
sal_Int32 nHeight14 = getXPath(pLayout14, "//page[1]/body/txt[1]/infos/bounds", "height").toInt32();
dispose();
createSwDoc("128197_compat15.docx");
xmlDocUniquePtr pLayout15 = parseLayoutDump();
sal_Int32 nHeight15 = getXPath(pLayout15, "//page[1]/body/txt[1]/infos/bounds", "height").toInt32();
+14 -4
View File
@@ -800,6 +800,13 @@ CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaData)
assertXPath(pCoreDoc, "/cp:coreProperties/cp:lastModifiedBy", 0);
assertXPath(pCoreDoc, "/cp:coreProperties/cp:lastPrinted", 0);
assertXPath(pCoreDoc, "/cp:coreProperties/cp:revision", 0);
}
CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaDataAndKeepUserInformation)
{
// 1. Remove all personal info
ScopedConfigValue<officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving>
aCfg1(true);
// 2. Remove personal information, keep user information
ScopedConfigValue<officecfg::Office::Common::Security::Scripting::KeepDocUserInfoOnSaving>
@@ -808,10 +815,10 @@ CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaData)
createSwDoc("personalmetadata.docx");
save(TestFilter::DOCX);
pAppDoc = parseExport(u"docProps/app.xml"_ustr);
xmlDocUniquePtr pAppDoc = parseExport(u"docProps/app.xml"_ustr);
assertXPath(pAppDoc, "/extended-properties:Properties/extended-properties:Template", 0);
assertXPath(pAppDoc, "/extended-properties:Properties/extended-properties:TotalTime", 0);
pCoreDoc = parseExport(u"docProps/core.xml"_ustr);
xmlDocUniquePtr pCoreDoc = parseExport(u"docProps/core.xml"_ustr);
assertXPath(pCoreDoc, "/cp:coreProperties/dcterms:created", 1);
assertXPath(pCoreDoc, "/cp:coreProperties/dcterms:modified", 1);
assertXPath(pCoreDoc, "/cp:coreProperties/dc:creator", 1);
@@ -834,14 +841,17 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf169072_illegalDates)
assertXPath(pXmlCore, "/cp:coreProperties/cp:lastPrinted", 0); // was 1600-12-31T00:00:52Z
}
CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData)
CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData_Disabled)
{
// 1. Check we have the original edit time info
createSwDoc("personalmetadata.docx");
save(TestFilter::DOCX);
xmlDocUniquePtr pAppDoc = parseExport(u"docProps/app.xml"_ustr);
assertXPath(pAppDoc, "/extended-properties:Properties/extended-properties:TotalTime", 1);
}
CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData_Enabled)
{
// Set config RemoveEditingTimeOnSaving to true
ScopedConfigValue<officecfg::Office::Common::Security::Scripting::RemoveEditingTimeOnSaving>
aCfg(true);
@@ -849,7 +859,7 @@ CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData)
// 2. Check edit time info is removed
createSwDoc("personalmetadata.docx");
save(TestFilter::DOCX);
pAppDoc = parseExport(u"docProps/app.xml"_ustr);
xmlDocUniquePtr pAppDoc = parseExport(u"docProps/app.xml"_ustr);
assertXPath(pAppDoc, "/extended-properties:Properties/extended-properties:TotalTime", 0);
}
+103 -67
View File
@@ -86,6 +86,7 @@ public:
std::unique_ptr<SwTextBlocks> readDOCXAutotext(
std::u16string_view sFileName, bool bEmpty = false);
void testRedlineFrame(char const*const file);
void testWatermarkPosition(int nAdditionalPagesCount, bool bChangeHeader);
};
std::unique_ptr<SwTextBlocks> SwUiWriterTest::readDOCXAutotext(std::u16string_view sFileName, bool bEmpty)
@@ -387,6 +388,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testCopyPastePageBreak)
pWrtShell->SelAll();
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
dispose();
createSwDoc("pagebreak-target.fodt");
SwDoc* pDoc = getSwDoc();
pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1011,81 +1013,115 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkDOCX)
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), pWatermark->GetTransparency());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition1)
{
testWatermarkPosition(0, true);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition2)
{
testWatermarkPosition(0, false);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition3)
{
testWatermarkPosition(1, true);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition4)
{
testWatermarkPosition(1, false);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition5)
{
testWatermarkPosition(5, true);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition6)
{
testWatermarkPosition(5, false);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition7)
{
testWatermarkPosition(20, true);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition8)
{
testWatermarkPosition(20, false);
}
void SwUiWriterTest::testWatermarkPosition(int nAdditionalPagesCount, bool bChangeHeader)
{
// tdf#108494 Watermark inserted in the document with page break was outside the first page
const int aPagesInDocument = 2;
const int aAdditionalPagesCount[] = { 0, 0, 1, 1, 5, 5, 20, 20 };
const bool aChangeHeader[] = { true, false, true, false, true, false, true, false };
int aPages = aPagesInDocument + nAdditionalPagesCount;
for (tools::ULong i = 0; i < sizeof(aAdditionalPagesCount) / sizeof(int); ++i)
// Empty document with one Page Break
createSwDoc("watermark-position.odt");
SwDoc* pDoc = getSwDoc();
SwEditShell* pEditShell = pDoc->GetEditShell();
CPPUNIT_ASSERT(pEditShell);
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
// 1. Add additional page breaks
for (int j = 0; j < nAdditionalPagesCount; ++j)
pWrtShell->InsertPageBreak();
// 2. Change header state (On, Off, On)
if (bChangeHeader)
{
int aPages = aPagesInDocument + aAdditionalPagesCount[i];
SwPageDesc aDesc(pDoc->GetPageDesc(0));
SwFrameFormat& rMaster = aDesc.GetMaster();
rMaster.SetFormatAttr(SwFormatHeader(true));
pDoc->ChgPageDesc(0, aDesc);
// Empty document with one Page Break
createSwDoc("watermark-position.odt");
SwDoc* pDoc = getSwDoc();
SwEditShell* pEditShell = pDoc->GetEditShell();
CPPUNIT_ASSERT(pEditShell);
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
aDesc = pDoc->GetPageDesc(0);
SwFrameFormat& rMaster2 = aDesc.GetMaster();
rMaster2.SetFormatAttr(SwFormatHeader(false));
pDoc->ChgPageDesc(0, aDesc);
// 1. Add additional page breaks
for (int j = 0; j < aAdditionalPagesCount[i]; ++j)
pWrtShell->InsertPageBreak();
// 2. Change header state (On, Off, On)
if (aChangeHeader[i])
{
SwPageDesc aDesc(pDoc->GetPageDesc(0));
SwFrameFormat& rMaster = aDesc.GetMaster();
rMaster.SetFormatAttr(SwFormatHeader(true));
pDoc->ChgPageDesc(0, aDesc);
aDesc = pDoc->GetPageDesc(0);
SwFrameFormat& rMaster2 = aDesc.GetMaster();
rMaster2.SetFormatAttr(SwFormatHeader(false));
pDoc->ChgPageDesc(0, aDesc);
aDesc = pDoc->GetPageDesc(0);
SwFrameFormat& rMaster3 = aDesc.GetMaster();
rMaster3.SetFormatAttr(SwFormatHeader(true));
pDoc->ChgPageDesc(0, aDesc);
}
// 3. Insert Watermark
SfxWatermarkItem aWatermark;
aWatermark.SetText(u"Watermark"_ustr);
aWatermark.SetFont(u"DejaVu Sans"_ustr);
pEditShell->SetWatermark(aWatermark);
uno::Reference<css::drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT(xShape.is());
SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
// Get Watermark object
SdrObject* pObject = pPage->GetObj(0);
pObject->RecalcBoundRect();
const tools::Rectangle& rRect = pObject->GetSnapRect();
Size rSize = pPage->GetSize();
// Page break, calculate height of a page
const int nPageHeight = rSize.getHeight() / aPages;
std::stringstream aMessage;
aMessage << "Case: " << i << ", nPageHeight = " << nPageHeight << ", rRect.Bottom = " << rRect.Bottom();
// Check if Watermark is inside a page
CPPUNIT_ASSERT_MESSAGE(aMessage.str(), nPageHeight >= rRect.Bottom());
// Check if Watermark is centered
CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(xShape, u"HoriOrient"_ustr));
CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty<sal_Int16>(xShape, u"VertOrient"_ustr));
aDesc = pDoc->GetPageDesc(0);
SwFrameFormat& rMaster3 = aDesc.GetMaster();
rMaster3.SetFormatAttr(SwFormatHeader(true));
pDoc->ChgPageDesc(0, aDesc);
}
// 3. Insert Watermark
SfxWatermarkItem aWatermark;
aWatermark.SetText(u"Watermark"_ustr);
aWatermark.SetFont(u"DejaVu Sans"_ustr);
pEditShell->SetWatermark(aWatermark);
uno::Reference<css::drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT(xShape.is());
SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
// Get Watermark object
SdrObject* pObject = pPage->GetObj(0);
pObject->RecalcBoundRect();
const tools::Rectangle& rRect = pObject->GetSnapRect();
Size rSize = pPage->GetSize();
// Page break, calculate height of a page
const int nPageHeight = rSize.getHeight() / aPages;
std::stringstream aMessage;
aMessage << ", nPageHeight = " << nPageHeight << ", rRect.Bottom = " << rRect.Bottom();
// Check if Watermark is inside a page
CPPUNIT_ASSERT_MESSAGE(aMessage.str(), nPageHeight >= rRect.Bottom());
// Check if Watermark is centered
CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(xShape, u"HoriOrient"_ustr));
CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty<sal_Int16>(xShape, u"VertOrient"_ustr));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testFdo74981)
+239 -239
View File
@@ -96,290 +96,290 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf113213_addToList)
CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(getParagraph(6), "ListLabelString"));
}
SwPostItMgr* getPostItMgr(SwDocShell* pDocShell)
{
CPPUNIT_ASSERT(pDocShell);
SwView* pView = pDocShell->GetView();
CPPUNIT_ASSERT(pView);
SwPostItMgr* pPostItMgr = pView->GetPostItMgr();
CPPUNIT_ASSERT(pPostItMgr);
return pPostItMgr;
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791)
{
auto getPostItMgr = [](SwDocShell* pDocShell) {
CPPUNIT_ASSERT(pDocShell);
SwView* pView = pDocShell->GetView();
CPPUNIT_ASSERT(pView);
SwPostItMgr* pPostItMgr = pView->GetPostItMgr();
CPPUNIT_ASSERT(pPostItMgr);
return pPostItMgr;
};
// Given a document with tracked changes enabled, having some threads of comments:
createSwDoc("tdf108791_comments_with_tracked_changes.fodt");
// Test "Delete Comment": the selected comment must be marked as deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
// Test "Delete Comment": the selected comment must be marked as deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Comment thread 1 reply 2"_ustr, pPostItField->GetText());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteComment"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(i == 2 ? SwPostItHelper::SwLayoutStatus::DELETED
: SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// load it anew
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Comment thread 1 reply 2"_ustr, pPostItField->GetText());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteComment"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(i == 2 ? SwPostItHelper::SwLayoutStatus::DELETED
: SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791_2)
{
createSwDoc("tdf108791_comments_with_tracked_changes.fodt");
// Test "Delete Comment Thread": the comment, and all its thread, must be marked as deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
// Test "Delete Comment Thread": the comment, and all its thread, must be marked as deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Comment thread 1 reply 2"_ustr, pPostItField->GetText());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteCommentThread"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(i <= 2 ? SwPostItHelper::SwLayoutStatus::DELETED
: SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// load it anew
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Comment thread 1 reply 2"_ustr, pPostItField->GetText());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteCommentThread"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(i <= 2 ? SwPostItHelper::SwLayoutStatus::DELETED
: SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791_3)
{
createSwDoc("tdf108791_comments_with_tracked_changes.fodt");
// Test "Delete Comments by Author3": the author's comments must be marked as deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
// Test "Delete Comments by Author3": the author's comments must be marked as deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Author3"_ustr, pPostItField->GetPar1());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteAuthor"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt);
pPostItField = aPostItFields[i]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(pPostItField->GetPar1() == "Author3"
? SwPostItHelper::SwLayoutStatus::DELETED
: SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// load it anew
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Author3"_ustr, pPostItField->GetPar1());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteAuthor"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt);
pPostItField = aPostItFields[i]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(pPostItField->GetPar1() == "Author3"
? SwPostItHelper::SwLayoutStatus::DELETED
: SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791_4)
{
createSwDoc("tdf108791_comments_with_tracked_changes.fodt");
// Test "Delete All Comments": all comments must be marked as deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
// Test "Delete All Comments": all comments must be marked as deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select any comment
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteAllNotes"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::DELETED,
aPostItFields[i]->mLayoutStatus);
}
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select any comment
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteAllNotes"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::DELETED,
aPostItFields[i]->mLayoutStatus);
}
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791_5)
{
// Now test the same with an equivalent DOCX: comment deletion must delete immediately
createSwDoc("tdf108791_comments_with_tracked_changes.docx");
// Test "Delete Comment": the selected comment must be deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
// Test "Delete Comment": the selected comment must be deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Comment thread 1 reply 2"_ustr, pPostItField->GetText());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteComment"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(5), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt->GetPostItField());
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt->GetPostItField()->GetText()
!= "Comment thread 1 reply 2");
}
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// load it anew
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Comment thread 1 reply 2"_ustr, pPostItField->GetText());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteComment"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(5), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt->GetPostItField());
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt->GetPostItField()->GetText()
!= "Comment thread 1 reply 2");
}
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791_6)
{
createSwDoc("tdf108791_comments_with_tracked_changes.docx");
// Test "Delete Comment Thread": the comment, and all its thread, must be deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
// Test "Delete Comment Thread": the comment, and all its thread, must be deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Comment thread 1 reply 2"_ustr, pPostItField->GetText());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteCommentThread"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(3), aPostItFields.size());
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// load it anew
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Comment thread 1 reply 2"_ustr, pPostItField->GetText());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteCommentThread"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(3), aPostItFields.size());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791_7)
{
createSwDoc("tdf108791_comments_with_tracked_changes.docx");
// Test "Delete Comments by Author3": the author's comments must be deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
// Test "Delete Comments by Author3": the author's comments must be deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Author3"_ustr, pPostItField->GetPar1());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteAuthor"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(4), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt->GetPostItField());
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt->GetPostItField()->GetPar1() != "Author3");
}
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// load it anew
// Select "Comment thread 1 reply 2"
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
const SwPostItField* pPostItField = aPostItFields[2]->mpPostIt->GetPostItField();
CPPUNIT_ASSERT(pPostItField);
CPPUNIT_ASSERT_EQUAL(u"Author3"_ustr, pPostItField->GetPar1());
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteAuthor"_ustr, {});
CPPUNIT_ASSERT_EQUAL(size_t(4), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt);
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt->GetPostItField());
CPPUNIT_ASSERT(aPostItFields[i]->mpPostIt->GetPostItField()->GetPar1() != "Author3");
}
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791_8)
{
createSwDoc("tdf108791_comments_with_tracked_changes.docx");
// Test "Delete All Comments": all comments must be deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
// Test "Delete All Comments": all comments must be deleted
SwPostItMgr* pPostItMgr = getPostItMgr(getSwDocShell());
auto& aPostItFields = pPostItMgr->GetPostItFields();
CPPUNIT_ASSERT_EQUAL(size_t(6), aPostItFields.size());
for (size_t i = 0; i < aPostItFields.size(); ++i)
{
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select any comment
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteAllNotes"_ustr, {});
CPPUNIT_ASSERT(aPostItFields.empty());
CPPUNIT_ASSERT(aPostItFields[i]);
CPPUNIT_ASSERT_EQUAL(SwPostItHelper::SwLayoutStatus::VISIBLE,
aPostItFields[i]->mLayoutStatus);
}
// Select any comment
CPPUNIT_ASSERT(aPostItFields[2]->mpPostIt);
pPostItMgr->SetActiveSidebarWin(aPostItFields[2]->mpPostIt);
dispatchCommand(mxComponent, u".uno:DeleteAllNotes"_ustr, {});
CPPUNIT_ASSERT(aPostItFields.empty());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf162120AutoRTL)
+4
View File
@@ -62,6 +62,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testPlaceholderHTMLPaste)
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
}
dispose();
createSwDoc("placeholder-bold.fodt");
// select placeholder field
@@ -148,6 +149,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testPlaceholderHTMLPasteStyleOverride)
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
}
dispose();
createSwDoc("placeholder-bold-style-override.fodt");
// select placeholder field
@@ -1027,6 +1029,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf128375)
dispatchCommand(mxComponent, u".uno:Cut"_ustr, {});
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
dispose();
}
}
@@ -2796,6 +2799,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf140061)
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
dispose();
createSwDoc();
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
+43 -18
View File
@@ -443,16 +443,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf148148)
lcl_translitTest(*pDoc, *pCursor, TF::LOWERCASE_UPPERCASE));
CPPUNIT_ASSERT_EQUAL(u" text"_ustr,
lcl_translitTest(*pDoc, *pCursor, TF::UPPERCASE_LOWERCASE));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf148148_2)
{
using TF = TransliterationFlags;
/* Test what happens when node contains text but selection does not contain any text */
createSwDoc();
pDoc = getSwDoc();
pWrtShell = getSwDocShell()->GetWrtShell();
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(/*bStt=*/false);
pWrtShell->Insert(u"text "_ustr);
pWrtShell->StartOfSection();
pCursor = pWrtShell->getShellCursor(false);
SwShellCursor* pCursor = pWrtShell->getShellCursor(false);
for (int i = 0; i < 4; i++)
{
pCursor->Move(fnMoveForward);
@@ -469,16 +473,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf148148)
lcl_translitTest(*pDoc, *pCursor, TF::LOWERCASE_UPPERCASE));
CPPUNIT_ASSERT_EQUAL(u"text "_ustr,
lcl_translitTest(*pDoc, *pCursor, TF::UPPERCASE_LOWERCASE));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf148148_3)
{
using TF = TransliterationFlags;
/* Test what happens when node contains only non-word text but selection does not contain any text */
createSwDoc();
pDoc = getSwDoc();
pWrtShell = getSwDocShell()->GetWrtShell();
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(/*bStt=*/false);
pWrtShell->Insert(u"-1 "_ustr);
pWrtShell->StartOfSection();
pCursor = pWrtShell->getShellCursor(false);
SwShellCursor* pCursor = pWrtShell->getShellCursor(false);
for (int i = 0; i < 2; i++)
{
pCursor->Move(fnMoveForward);
@@ -493,15 +501,19 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf148148)
CPPUNIT_ASSERT_EQUAL(u"-1 "_ustr, lcl_translitTest(*pDoc, *pCursor, TF::TITLE_CASE));
CPPUNIT_ASSERT_EQUAL(u"-1 "_ustr, lcl_translitTest(*pDoc, *pCursor, TF::LOWERCASE_UPPERCASE));
CPPUNIT_ASSERT_EQUAL(u"-1 "_ustr, lcl_translitTest(*pDoc, *pCursor, TF::UPPERCASE_LOWERCASE));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf148148_4)
{
using TF = TransliterationFlags;
createSwDoc();
pDoc = getSwDoc();
pWrtShell = getSwDocShell()->GetWrtShell();
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(/*bStt=*/false);
pWrtShell->Insert(u" -1"_ustr);
pWrtShell->StartOfSection();
pCursor = pWrtShell->getShellCursor(false);
SwShellCursor* pCursor = pWrtShell->getShellCursor(false);
pCursor->SetMark();
for (int i = 0; i < 2; i++)
{
@@ -512,16 +524,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf148148)
CPPUNIT_ASSERT_EQUAL(u" -1"_ustr, lcl_translitTest(*pDoc, *pCursor, TF::TITLE_CASE));
CPPUNIT_ASSERT_EQUAL(u" -1"_ustr, lcl_translitTest(*pDoc, *pCursor, TF::LOWERCASE_UPPERCASE));
CPPUNIT_ASSERT_EQUAL(u" -1"_ustr, lcl_translitTest(*pDoc, *pCursor, TF::UPPERCASE_LOWERCASE));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf148148_5)
{
using TF = TransliterationFlags;
/* Test what happens when node and selection contains only non-word text */
createSwDoc();
pDoc = getSwDoc();
pWrtShell = getSwDocShell()->GetWrtShell();
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(/*bStt=*/false);
pWrtShell->Insert(u" -1"_ustr);
pWrtShell->StartOfSection();
pCursor = pWrtShell->getShellCursor(false);
SwShellCursor* pCursor = pWrtShell->getShellCursor(false);
pCursor->SetMark();
for (int i = 0; i < 5; i++)
{
@@ -1046,7 +1062,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testSmallCaps)
{
// Create a document, add some characters and select them.
createSwDoc();
createSwDoc();
SwDocShell* pDocShell = getSwDocShell();
SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
pWrtShell->Insert(u"text"_ustr);
@@ -2095,7 +2110,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf106736)
CPPUNIT_ASSERT_MESSAGE("Left Tab width is ~103", nWidth < 150);
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testMsWordCompTrailingBlanks)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testMsWordCompTrailingBlanks_True)
{
// The option is true in settings.xml
createSwDoc("MsWordCompTrailingBlanksTrue.odt");
@@ -2161,14 +2176,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testMsWordCompTrailingBlanks)
u"PortionType::Hole");
assertXPath(pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout/child::*[4]", "portion",
u" "); // All the trailing blanks
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testMsWordCompTrailingBlanks_false)
{
// The option is false in settings.xml
createSwDoc("MsWordCompTrailingBlanksFalse.odt");
pDoc = getSwDoc();
SwDoc* pDoc = getSwDoc();
CPPUNIT_ASSERT_EQUAL(false, pDoc->getIDocumentSettingAccess().get(
DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS));
calcLayout();
pXmlDoc = parseLayoutDump();
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Check that trailing spaces spans are put into Text portions if option is disabled
assertXPath(pXmlDoc, "/root/page/body/txt", 3);
@@ -2238,16 +2256,22 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testMsWordCompTrailingBlanks)
u"PortionType::Text");
assertXPath(pXmlDoc, "/root/page/body/txt[3]/SwParaPortion/SwLineLayout/child::*[5]", "portion",
u" "); // third colored trailing blank span here
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testMsWordCompTrailingBlanks_EmptyDocument)
{
// MsWordCompTrailingBlanks option should be false by default in new documents
createSwDoc();
pDoc = getSwDoc();
SwDoc* pDoc = getSwDoc();
CPPUNIT_ASSERT_EQUAL(false, pDoc->getIDocumentSettingAccess().get(
DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS));
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testMsWordCompTrailingBlanks_Docx)
{
// The option should be true if a .docx, .doc or .rtf document is opened
createSwDoc("MsWordCompTrailingBlanks.docx");
pDoc = getSwDoc();
SwDoc* pDoc = getSwDoc();
CPPUNIT_ASSERT_EQUAL(true, pDoc->getIDocumentSettingAccess().get(
DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS));
}
@@ -2585,6 +2609,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf143320)
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
// Create a new document
dispose();
createSwDoc();
pWrtShell = getSwDocShell()->GetWrtShell();
CPPUNIT_ASSERT(pWrtShell);
+4
View File
@@ -1360,6 +1360,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf156546)
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
// create another document
dispose();
createSwDoc();
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
@@ -1544,6 +1545,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf121546)
CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
// Create a new document
dispose();
createSwDoc();
dispatchCommand(mxComponent, u".uno:Paste"_ustr, {});
@@ -1600,6 +1602,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf134626)
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
// Create a new document
dispose();
createSwDoc();
pWrtShell = getSwDocShell()->GetWrtShell();
CPPUNIT_ASSERT(pWrtShell);
@@ -3095,6 +3098,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157129)
dispatchCommand(mxComponent, u".uno:Copy"_ustr, {});
// Create a new document
dispose();
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+51 -26
View File
@@ -164,37 +164,62 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf68364InsertConditionalFieldWithTwoDots)
CPPUNIT_ASSERT_EQUAL(u"19.12.2023"_ustr, pWrtShell->GetCurField()->ExpandField(true, nullptr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf170392FilenameFormatConstantsIdl)
CPPUNIT_TEST_FIXTURE(Test, testTdf170392FilenameFormatConstantsIdl_Name)
{
SwFileNameFormat aFormats[] = { SwFileNameFormat::Name, SwFileNameFormat::Path };
for (SwFileNameFormat eFormat : aFormats)
{
// Create an empty document
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
// Create an empty document
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
// Insert a filename field containing a specific format
SwFieldMgr aFieldMgr(pWrtShell);
SwInsertField_Data aFieldData(SwFieldTypesEnum::Filename, 0, u""_ustr, u""_ustr,
static_cast<sal_uInt32>(eFormat));
CPPUNIT_ASSERT(aFieldMgr.InsertField(aFieldData));
// Insert a filename field containing a specific format
SwFieldMgr aFieldMgr(pWrtShell);
SwInsertField_Data aFieldData(SwFieldTypesEnum::Filename, 0, u""_ustr, u""_ustr,
static_cast<sal_uInt32>(SwFileNameFormat::Name));
CPPUNIT_ASSERT(aFieldMgr.InsertField(aFieldData));
// First reload in order to get a value for the filename field
saveAndReload(TestFilter::ODT);
pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(true);
const auto aExpandedField = pWrtShell->GetCurField()->ExpandField(true, nullptr);
// First reload in order to get a value for the filename field
saveAndReload(TestFilter::ODT);
pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(true);
const auto aExpandedField = pWrtShell->GetCurField()->ExpandField(true, nullptr);
// Second reload in order to check consistency for the filename field
saveAndReload(TestFilter::ODT);
pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(true);
// Second reload in order to check consistency for the filename field
saveAndReload(TestFilter::ODT);
pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(true);
// Without the accompanying fix in place, this test would have failed with:
// - Expected: filename field is the same
// - Actual : filename field differ since the filename format constants differ
CPPUNIT_ASSERT_EQUAL(aExpandedField, pWrtShell->GetCurField()->ExpandField(true, nullptr));
}
// Without the accompanying fix in place, this test would have failed with:
// - Expected: filename field is the same
// - Actual : filename field differ since the filename format constants differ
CPPUNIT_ASSERT_EQUAL(aExpandedField, pWrtShell->GetCurField()->ExpandField(true, nullptr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf170392FilenameFormatConstantsIdl_Path)
{
// Create an empty document
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
// Insert a filename field containing a specific format
SwFieldMgr aFieldMgr(pWrtShell);
SwInsertField_Data aFieldData(SwFieldTypesEnum::Filename, 0, u""_ustr, u""_ustr,
static_cast<sal_uInt32>(SwFileNameFormat::Path));
CPPUNIT_ASSERT(aFieldMgr.InsertField(aFieldData));
// First reload in order to get a value for the filename field
saveAndReload(TestFilter::ODT);
pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(true);
const auto aExpandedField = pWrtShell->GetCurField()->ExpandField(true, nullptr);
// Second reload in order to check consistency for the filename field
saveAndReload(TestFilter::ODT);
pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->SttEndDoc(true);
// Without the accompanying fix in place, this test would have failed with:
// - Expected: filename field is the same
// - Actual : filename field differ since the filename format constants differ
CPPUNIT_ASSERT_EQUAL(aExpandedField, pWrtShell->GetCurField()->ExpandField(true, nullptr));
}
CPPUNIT_TEST_FIXTURE(Test, testInsertRefmarkSelection)
+1 -1
View File
@@ -391,7 +391,7 @@ void SwModelTestBase::saveAndReload(TestFilter eFilter,
const char* pPassword)
{
save(eFilter, rParams, pPassword);
dispose();
loadURL(maTempFile.GetURL(), rParams, pPassword);
}