summaryrefslogtreecommitdiffstats
path: root/sw/qa/core
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:27:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:27:30 +0000
commita2baea7faff31d26459dab3668a39eae85e4991b (patch)
treeeaa2048ce9c715481f932dcfe20368e252b77d2f /sw/qa/core
parentAdding upstream version 4:24.2.0. (diff)
downloadlibreoffice-upstream/4%24.2.1.tar.xz
libreoffice-upstream/4%24.2.1.zip
Adding upstream version 4:24.2.1.upstream/4%24.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/core')
-rw-r--r--sw/qa/core/header_footer/HeaderFooterTest.cxx6
-rw-r--r--sw/qa/core/layout/data/floattable-not-wrapped-by-table.docxbin0 -> 12994 bytes
-rw-r--r--sw/qa/core/layout/tabfrm.cxx22
-rw-r--r--sw/qa/core/text/data/tdf159336.odtbin0 -> 9417 bytes
-rw-r--r--sw/qa/core/text/itrform2.cxx40
-rw-r--r--sw/qa/core/text/text.cxx37
6 files changed, 100 insertions, 5 deletions
diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx b/sw/qa/core/header_footer/HeaderFooterTest.cxx
index 6bb5fd6167..4d2938ef28 100644
--- a/sw/qa/core/header_footer/HeaderFooterTest.cxx
+++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx
@@ -467,10 +467,8 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf112694)
auto verify = [this]() {
uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard");
// Header was on when header for file was for explicit first pages only
- // (marked via <w:titlePg>).
- //CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn"));
- // TODO - can't disable headers/footers selectively (only fo first page)
- CPPUNIT_ASSERT(getProperty<bool>(aPageStyle, "HeaderIsOn"));
+ // but <w:titlePg> was missing.
+ CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn"));
};
createSwDoc("tdf112694.docx");
diff --git a/sw/qa/core/layout/data/floattable-not-wrapped-by-table.docx b/sw/qa/core/layout/data/floattable-not-wrapped-by-table.docx
new file mode 100644
index 0000000000..2c255148d3
--- /dev/null
+++ b/sw/qa/core/layout/data/floattable-not-wrapped-by-table.docx
Binary files differ
diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx
index 9357fc2df1..61b1a25109 100644
--- a/sw/qa/core/layout/tabfrm.cxx
+++ b/sw/qa/core/layout/tabfrm.cxx
@@ -199,6 +199,28 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWrappedByTable)
// i.e. the inline table was under the floating one, not on the right of it.
CPPUNIT_ASSERT_LESS(nFloatingBottom, nInlineTop);
}
+
+CPPUNIT_TEST_FIXTURE(Test, testInlineTableThenSplitFly)
+{
+ // Given a document with a floating table ("right") and an inline table ("left"):
+ // When laying out the document:
+ createSwDoc("floattable-not-wrapped-by-table.docx");
+
+ // Then make sure the inline table is on the left (small negative offset):
+ SwDoc* pDoc = getSwDoc();
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ auto pPage = pLayout->Lower()->DynCastPageFrame();
+ CPPUNIT_ASSERT(pPage);
+ SwFrame* pBody = pPage->FindBodyCont();
+ auto pTab = pBody->GetLower()->GetNext()->DynCastTabFrame();
+ SwTwips nInlineLeft = pTab->getFramePrintArea().Left();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected less than: 0
+ // - Actual : 6958
+ // i.e. "left" was on the right, its horizontal margin was not a small negative value but a
+ // large positive one.
+ CPPUNIT_ASSERT_LESS(static_cast<SwTwips>(0), nInlineLeft);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/text/data/tdf159336.odt b/sw/qa/core/text/data/tdf159336.odt
new file mode 100644
index 0000000000..4f396e4f2a
--- /dev/null
+++ b/sw/qa/core/text/data/tdf159336.odt
Binary files differ
diff --git a/sw/qa/core/text/itrform2.cxx b/sw/qa/core/text/itrform2.cxx
index fc8e981dcf..6d59140f97 100644
--- a/sw/qa/core/text/itrform2.cxx
+++ b/sw/qa/core/text/itrform2.cxx
@@ -16,6 +16,10 @@
#include <sortedobjs.hxx>
#include <pagefrm.hxx>
#include <cntfrm.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <formatcontentcontrol.hxx>
+#include <textcontentcontrol.hxx>
namespace
{
@@ -166,6 +170,42 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyAnchorLeftMargin)
// i.e. the left margin was lost.
CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(6480), pLastPara->getFramePrintArea().Left());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testCheckedCheckboxContentControlPDF)
+{
+ std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+ if (!pPDFium)
+ return;
+
+ // Given a file with a checked checkbox content control:
+ createSwDoc();
+ SwDoc* pDoc = getSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->InsertContentControl(SwContentControlType::CHECKBOX);
+ // Toggle it, so we get a checked one:
+ SwTextContentControl* pTextContentControl = pWrtShell->CursorInsideContentControl();
+ const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl();
+ pWrtShell->GotoContentControl(rFormatContentControl);
+
+ // When exporting to PDF:
+ save("writer_pdf_Export");
+
+ // Then make sure that a checked checkbox form widget is emitted:
+ std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
+ std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0);
+ CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
+ std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0);
+ CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, pAnnotation->getSubType());
+ CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::CheckBox,
+ pAnnotation->getFormFieldType(pPdfDocument.get()));
+ OUString aActual = pAnnotation->getFormFieldValue(pPdfDocument.get());
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: Yes
+ // - Actual : Off
+ // i.e. the /AP -> /N key of the checkbox widget annotation object didn't have a sub-key that
+ // would match /V, leading to not showing the checked state.
+ CPPUNIT_ASSERT_EQUAL(OUString("Yes"), aActual);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 666e6d29f2..690fc333af 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -20,6 +20,7 @@
#include <vcl/gdimtf.hxx>
#include <vcl/metaact.hxx>
#include <vcl/filter/PDFiumLibrary.hxx>
+#include <vcl/filter/pdfdocument.hxx>
#include <comphelper/propertyvalue.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/wghtitem.hxx>
@@ -115,6 +116,40 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLastBibliographyPdfExport)
CPPUNIT_ASSERT(true);
}
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf159336)
+{
+ createSwDoc("tdf159336.odt");
+ save("writer_pdf_Export");
+
+ vcl::filter::PDFDocument aDocument;
+ SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
+ CPPUNIT_ASSERT(aDocument.Read(aStream));
+
+ // The document has one page.
+ std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size());
+
+ auto pAnnots = dynamic_cast<vcl::filter::PDFArrayElement*>(aPages[0]->Lookup("Annots"_ostr));
+ CPPUNIT_ASSERT(pAnnots);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pAnnots->GetElements().size());
+ auto pAnnotReference
+ = dynamic_cast<vcl::filter::PDFReferenceElement*>(pAnnots->GetElements()[0]);
+ CPPUNIT_ASSERT(pAnnotReference);
+ vcl::filter::PDFObjectElement* pAnnot = pAnnotReference->LookupObject();
+ CPPUNIT_ASSERT(pAnnot);
+ CPPUNIT_ASSERT_EQUAL(
+ "Annot"_ostr,
+ static_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"_ostr))->GetValue());
+ CPPUNIT_ASSERT_EQUAL(
+ "Widget"_ostr,
+ static_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Subtype"_ostr))->GetValue());
+ // Ff = multiline
+ auto pFf = dynamic_cast<vcl::filter::PDFNumberElement*>(pAnnot->Lookup("Ff"_ostr));
+ CPPUNIT_ASSERT(pFf);
+ CPPUNIT_ASSERT_EQUAL(4096.0, pFf->GetValue());
+}
+
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport)
{
// Given a document with a bibliography entry field:
@@ -767,7 +802,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testAsCharImageDocModelFromViewPoint)
const SwSortedObjs& rSortedObjs = *pTextFrame->GetDrawObjs();
const SwAnchoredObject* pAnchoredObject = rSortedObjs[0];
// The content points to the start node, the next node is the graphic node.
- SwNodeIndex aGraphicNode = *pAnchoredObject->GetFrameFormat().GetContent().GetContentIdx();
+ SwNodeIndex aGraphicNode = *pAnchoredObject->GetFrameFormat()->GetContent().GetContentIdx();
++aGraphicNode;
tools::Rectangle aFlyFrame = pAnchoredObject->GetDrawObj()->GetLastBoundRect();
Point aDocPos = aFlyFrame.Center();