Drop SwExportFormFieldsGuard, and use ScopedConfigValue instead

Change-Id: I1c0582ba9f4851096c9ffd138cd8b36a6822446d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198503
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2026-02-02 08:43:08 +01:00
parent 9fe65e5c3e
commit 6437d0c99f
4 changed files with 18 additions and 44 deletions
+5 -3
View File
@@ -21,6 +21,8 @@
#include <vcl/pdf/PDFAnnotationSubType.hxx>
#include <vcl/pdf/PDFFormFieldType.hxx>
#include <vcl/pdf/PDFPageObjectType.hxx>
#include <officecfg/Office/Common.hxx>
#include <test/commontesttools.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <rootfrm.hxx>
@@ -208,7 +210,7 @@ CPPUNIT_TEST_FIXTURE(Test, testCheckedCheckboxContentControlPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a checked checkbox content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -244,7 +246,7 @@ CPPUNIT_TEST_FIXTURE(Test, testContentControlPDFFontColor)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a document with a custom orange font color and a content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -277,7 +279,7 @@ CPPUNIT_TEST_FIXTURE(Test, testContentControlPDFDropDownText)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a document with a dropdown: custom default text and 3 items:
createSwDoc();
uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY);
+13 -11
View File
@@ -29,6 +29,8 @@
#include <comphelper/sequenceashashmap.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/wghtitem.hxx>
#include <officecfg/Office/Common.hxx>
#include <test/commontesttools.hxx>
#include <docsh.hxx>
#include <unotxdoc.hxx>
@@ -220,7 +222,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf159924)
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf159336)
{
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
createSwDoc("tdf159336.odt");
save(TestFilter::PDF_WRITER);
@@ -1036,7 +1038,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1083,7 +1085,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPlaceholderPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a content control, in placeholder mode:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1111,7 +1113,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testCheckboxContentControlPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a checkbox content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1141,7 +1143,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDropdownContentControlPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a dropdown content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1171,7 +1173,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDropdownContentControlPDF2)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
createSwDoc("tdf153040.docx");
save(TestFilter::PDF_WRITER);
@@ -1196,7 +1198,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDateContentControlPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a date content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1229,7 +1231,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDFFont)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a document with a custom 24pt font size and a content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1261,7 +1263,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testComboContentControlPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a combo box content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1292,7 +1294,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRichContentControlPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a rich content control, its value set to "xxx<b>yyy</b>":
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
@@ -1328,7 +1330,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testPlaceholderFieldPDF)
if (!pPDFium)
return;
SwExportFormFieldsGuard g;
ScopedConfigValue<officecfg::Office::Common::Filter::PDF::Export::ExportFormFields> aCfg(true);
// Given a file with a text-type placeholder field:
createSwDoc("placeholder.fodt");
-14
View File
@@ -47,10 +47,6 @@
#define DECLARE_WW8EXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, TestFilter::DOC)
class SwXTextDocument;
namespace comphelper
{
class ConfigurationChanges;
}
namespace vcl
{
namespace pdf
@@ -59,16 +55,6 @@ class PDFiumDocument;
}
}
/// Temporarily enables the ExportFormFields setting.
class SWQAHELPER_DLLPUBLIC SwExportFormFieldsGuard
{
std::shared_ptr<comphelper::ConfigurationChanges> m_pBatch;
bool m_bValue;
public:
SwExportFormFieldsGuard();
~SwExportFormFieldsGuard();
};
/// Base class for filter tests loading or roundtripping a document, then asserting the document model.
class SWQAHELPER_DLLPUBLIC SwModelTestBase : public UnoApiXmlTest
{
-16
View File
@@ -24,8 +24,6 @@
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/scheduler.hxx>
#include <comphelper/configuration.hxx>
#include <officecfg/Office/Writer.hxx>
#include <officecfg/Office/Common.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <docsh.hxx>
@@ -485,18 +483,4 @@ void SwModelTestBase::emulateTyping(std::u16string_view rStr)
}
}
SwExportFormFieldsGuard::SwExportFormFieldsGuard()
{
m_pBatch = comphelper::ConfigurationChanges::create();
m_bValue = officecfg::Office::Common::Filter::PDF::Export::ExportFormFields::get();
officecfg::Office::Common::Filter::PDF::Export::ExportFormFields::set(true, m_pBatch);
m_pBatch->commit();
}
SwExportFormFieldsGuard::~SwExportFormFieldsGuard()
{
officecfg::Office::Common::Filter::PDF::Export::ExportFormFields::set(m_bValue, m_pBatch);
m_pBatch->commit();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */