summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx18
-rw-r--r--sw/qa/extras/inc/swmodeltestbase.hxx34
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx22
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx15
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx19
5 files changed, 71 insertions, 37 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 64bc4cf5510f..f951a0a57006 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -41,7 +41,7 @@ private:
return OString(filename) != "fdo62336.docx";
}
- void preTest(const char* filename) override
+ virtual std::unique_ptr<Resetter> preTest(const char* filename) override
{
if (getTestName().indexOf("SkipImage") != -1)
setFilterOptions("SkipImages");
@@ -50,22 +50,22 @@ private:
if (OString(filename) == "charborder.odt")
{
+
// FIXME if padding-top gets exported as inches, not cms, we get rounding errors.
SwGlobals::ensure(); // make sure that SW_MOD() is not 0
+ std::unique_ptr<Resetter> pResetter(new Resetter(
+ [this] () {
+ SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false));
+ pPref->SetMetric(this->m_eUnit);
+ }));
SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false));
m_eUnit = pPref->GetMetric();
pPref->SetMetric(FUNIT_CM);
+ return pResetter;
}
+ return nullptr;
}
- void postTest(const char* filename) override
- {
- if (OString(filename) == "charborder.odt")
- {
- SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false));
- pPref->SetMetric(m_eUnit);
- }
- }
};
#define DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, HtmlExportTest)
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index b154efebef6d..95eee3514266 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -149,6 +149,31 @@ protected:
bool mbExported; ///< Does maTempFile already contain something useful?
protected:
+
+ class Resetter
+ {
+ private:
+ std::function<void ()> m_Func;
+
+ public:
+ Resetter(std::function<void ()> const& rFunc)
+ : m_Func(rFunc)
+ {
+ }
+ ~Resetter()
+ {
+ try
+ {
+ m_Func();
+ }
+ catch (...) // has to be reliable
+ {
+ fprintf(stderr, "resetter failed with exception\n");
+ abort();
+ }
+ }
+ };
+
virtual OUString getTestName() { return OUString(); }
public:
@@ -197,7 +222,7 @@ protected:
{
maTempFile.EnableKillingFile(false);
header();
- preTest(filename);
+ std::unique_ptr<Resetter> const pChanges(preTest(filename));
load(mpTestDocumentPath, filename);
postTest(filename);
verify();
@@ -215,7 +240,7 @@ protected:
{
maTempFile.EnableKillingFile(false);
header();
- preTest(filename);
+ std::unique_ptr<Resetter> const pChanges(preTest(filename));
load(mpTestDocumentPath, filename);
postLoad(filename);
reload(mpFilter, filename);
@@ -235,7 +260,7 @@ protected:
{
maTempFile.EnableKillingFile(false);
header();
- preTest(filename);
+ std::unique_ptr<Resetter> const pChanges(preTest(filename));
load(mpTestDocumentPath, filename);
save(OUString::createFromAscii(mpFilter), maTempFile);
maTempFile.EnableKillingFile(false);
@@ -263,8 +288,9 @@ protected:
/**
* Override this function if some special filename-specific setup is needed
*/
- virtual void preTest(const char* /*filename*/)
+ virtual std::unique_ptr<Resetter> preTest(const char* /*filename*/)
{
+ return nullptr;
}
/// Override this function if some special file-specific setup is needed during export test: after load, but before save.
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index a5b18472d055..4b713cd04525 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -56,24 +56,24 @@ public:
return std::find(aBlacklist.begin(), aBlacklist.end(), filename) == aBlacklist.end();
}
- virtual void preTest(const char* pFilename) override
+ virtual std::unique_ptr<Resetter> preTest(const char* pFilename) override
{
if (OString(pFilename) == "fdo58949.docx")
{
- std::shared_ptr<comphelper::ConfigurationChanges> pBatch(comphelper::ConfigurationChanges::create());
- officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(false, pBatch);
- pBatch->commit();
- }
- }
+ std::unique_ptr<Resetter> pResetter(new Resetter(
+ [] () {
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(true, pBatch);
+ return pBatch->commit();
+ }));
- virtual void postTest(const char* pFilename) override
- {
- if (OString(pFilename) == "fdo58949.docx")
- {
std::shared_ptr<comphelper::ConfigurationChanges> pBatch(comphelper::ConfigurationChanges::create());
- officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(true, pBatch);
+ officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(false, pBatch);
pBatch->commit();
+ return pResetter;
}
+ return nullptr;
}
};
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index f21037037d0a..df0f695a8714 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -91,17 +91,20 @@ public:
{
}
- virtual void preTest(const char* filename) override
+ virtual std::unique_ptr<Resetter> preTest(const char* filename) override
{
if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx" || OString(filename) == "fdo87488.docx")
+ {
+ std::unique_ptr<Resetter> pResetter(new Resetter(
+ [] () {
+ SvtFilterOptions::Get().SetSmartArt2Shape(false);
+ }));
SvtFilterOptions::Get().SetSmartArt2Shape(true);
+ return pResetter;
+ }
+ return nullptr;
}
- virtual void postTest(const char* filename) override
- {
- if (OString(filename) == "smartart.docx" || OString(filename) == "strict-smartart.docx" || OString(filename) == "fdo87488.docx")
- SvtFilterOptions::Get().SetSmartArt2Shape(false);
- }
protected:
/// Copy&paste helper.
bool paste(const OUString& rFilename, const uno::Reference<text::XTextRange>& xTextRange)
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index b5216c98af48..a5264d3c1b53 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -66,27 +66,32 @@ public:
{
}
- virtual void preTest(const char* filename) override
+ virtual std::unique_ptr<Resetter> preTest(const char* filename) override
{
m_aSavedSettings = Application::GetSettings();
if (OString(filename) == "fdo48023.rtf" || OString(filename) == "fdo72031.rtf")
{
+ std::unique_ptr<Resetter> pResetter(new Resetter(
+ [this] () {
+ Application::SetSettings(this->m_aSavedSettings);
+ }));
AllSettings aSettings(m_aSavedSettings);
aSettings.SetLanguageTag(LanguageTag("ru"));
Application::SetSettings(aSettings);
+ return pResetter;
}
else if (OString(filename) == "fdo44211.rtf")
{
+ std::unique_ptr<Resetter> pResetter(new Resetter(
+ [this] () {
+ Application::SetSettings(this->m_aSavedSettings);
+ }));
AllSettings aSettings(m_aSavedSettings);
aSettings.SetLanguageTag(LanguageTag("lt"));
Application::SetSettings(aSettings);
+ return pResetter;
}
- }
-
- virtual void postTest(const char* filename) override
- {
- if (OString(filename) == "fdo48023.rtf" || OString(filename) == "fdo72031.rtf" || OString(filename) == "fdo44211.rtf")
- Application::SetSettings(m_aSavedSettings);
+ return nullptr;
}
protected: