diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-11-21 22:11:02 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-11-21 23:06:09 +0100 |
commit | dfdfdedfff1444963cae4d4d85ddf99f3ee2f02d (patch) | |
tree | 813db7f6b5d9b86ac8d4fb22b9d56d3b0d60c98e | |
parent | b7574264b5a554683bfbf9316cf4b5a502e90575 (diff) |
CppunitTest_sw_mailmerge: remaining MM methods from header file
Change-Id: I74e5ebd0d879ce6864707b28b002672e5fb78f74
-rw-r--r-- | sw/qa/extras/inc/swmodeltestbase.hxx | 53 | ||||
-rw-r--r-- | sw/qa/extras/mailmerge/mailmerge.cxx | 69 |
2 files changed, 66 insertions, 56 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 3452950fc7b8..e5966e31ff69 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -27,7 +27,6 @@ #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/XDocumentDataSource.hpp> -#include <com/sun/star/text/MailMergeType.hpp> #include <test/bootstrapfixture.hxx> #include <test/xmltesttools.hxx> @@ -157,9 +156,6 @@ private: protected: uno::Reference< lang::XComponent > mxComponent; - uno::Reference< lang::XComponent > mxMMComponent; - uno::Reference< com::sun::star::task::XJob > mxJob; - uno::Sequence< beans::NamedValue > mSeqMailMergeArgs; xmlBufferPtr mpXmlBuffer; const char* mpTestDocumentPath; @@ -175,9 +171,6 @@ protected: sal_uInt32 mnStartTime; utl::TempFile maTempFile; bool mbExported; ///< Does maTempFile already contain something useful? - sal_Int16 nCurOutputType; - OUString mailMergeOutputURL; - OUString mailMergeOutputPrefix; protected: virtual OUString getTestName() { return OUString(); } @@ -198,7 +191,6 @@ public: , mpFilter(pFilter) , mnStartTime(0) , mbExported(false) - , nCurOutputType(0) { maTempFile.EnableKillingFile(); } @@ -217,17 +209,6 @@ public: { if (mxComponent.is()) mxComponent->dispose(); - if (mxMMComponent.is()) - { - if (nCurOutputType == text::MailMergeType::SHELL) - { - SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument*>(mxMMComponent.get()); - CPPUNIT_ASSERT(pTxtDoc); - pTxtDoc->GetDocShell()->DoClose(); - } - else - mxMMComponent->dispose(); - } test::BootstrapFixture::tearDown(); } @@ -356,6 +337,7 @@ private: xmlFreeTextWriter(pXmlWriter); } +protected: void discardDumpedLayout() { if (mpXmlBuffer) @@ -373,7 +355,6 @@ private: pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); } -protected: /// Get the length of the whole document. int getLength() { @@ -618,26 +599,6 @@ protected: calcLayout(); } - /** - Loads number-th document from mail merge. Requires file output from mail merge. - */ - void loadMailMergeDocument( int number ) - { - assert( nCurOutputType == text::MailMergeType::FILE ); - if (mxComponent.is()) - mxComponent->dispose(); - OUString name = mailMergeOutputPrefix + OUString::number( number ) + ".odt"; - // Output name early, so in the case of a hang, the name of the hanging input file is visible. - std::cout << name << ","; - mnStartTime = osl_getGlobalTimer(); - mxComponent = loadFromDesktop(mailMergeOutputURL + "/" + name, "com.sun.star.text.TextDocument"); - CPPUNIT_ASSERT( mxComponent.is()); - OString name2 = OUStringToOString( name, RTL_TEXTENCODING_UTF8 ); - discardDumpedLayout(); - if (mustCalcLayoutOf(name2.getStr())) - calcLayout(); - } - void reload(const char* pFilter, const char* filename) { uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); @@ -712,18 +673,6 @@ protected: return parseExportInternal( maTempFile.GetURL(), rStreamName ); } - /** - * Like parseExport(), but for given mail merge document. - */ - xmlDocPtr parseMailMergeExport(int number, const OUString& rStreamName = OUString("word/document.xml")) - { - if (nCurOutputType != text::MailMergeType::FILE) - return 0; - - OUString name = mailMergeOutputPrefix + OUString::number( number ) + ".odt"; - return parseExportInternal( mailMergeOutputURL + "/" + name, rStreamName ); - } - xmlDocPtr parseExportInternal( const OUString& url, const OUString& rStreamName ) { // Read the XML stream we're interested in. diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index d17c835dedf6..9fa68bb075a8 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -40,7 +40,24 @@ DBuriMap aDBuriMap; class MMTest : public SwModelTestBase { public: - MMTest() : SwModelTestBase("/sw/qa/extras/mailmerge/data/", "writer8") {} + MMTest(); + + virtual void tearDown() SAL_OVERRIDE + { + if (mxMMComponent.is()) + { + if (mnCurOutputType == text::MailMergeType::SHELL) + { + SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument*>(mxMMComponent.get()); + CPPUNIT_ASSERT(pTxtDoc); + pTxtDoc->GetDocShell()->DoClose(); + } + else + mxMMComponent->dispose(); + } + SwModelTestBase::tearDown(); + } + /** * Helper func used by each unit test to test the 'mail merge' code. * @@ -67,7 +84,7 @@ public: finish(); ::utl::removeTree(aWorkDir); - nCurOutputType = 0; + mnCurOutputType = 0; } OUString registerDBsource( const OUString &aURI, const OUString &aWorkDir ) @@ -131,12 +148,12 @@ public: else if (rName == UNO_NAME_FILE_NAME_PREFIX) bOk &= rValue >>= mailMergeOutputPrefix; else if (rName == UNO_NAME_OUTPUT_TYPE) - bOk &= rValue >>= nCurOutputType; + bOk &= rValue >>= mnCurOutputType; } CPPUNIT_ASSERT(bOk); - if (nCurOutputType == text::MailMergeType::SHELL) + if (mnCurOutputType == text::MailMergeType::SHELL) { CPPUNIT_ASSERT(res >>= mxMMComponent); CPPUNIT_ASSERT(mxMMComponent.is()); @@ -148,9 +165,48 @@ public: } } + /** + * Like parseExport(), but for given mail merge document. + */ + xmlDocPtr parseMailMergeExport(int number, const OUString& rStreamName = OUString("word/document.xml")) + { + if (mnCurOutputType != text::MailMergeType::FILE) + return 0; + + OUString name = mailMergeOutputPrefix + OUString::number( number ) + ".odt"; + return parseExportInternal( mailMergeOutputURL + "/" + name, rStreamName ); + } + + /** + Loads number-th document from mail merge. Requires file output from mail merge. + */ + void loadMailMergeDocument( int number ) + { + assert( mnCurOutputType == text::MailMergeType::FILE ); + if (mxComponent.is()) + mxComponent->dispose(); + OUString name = mailMergeOutputPrefix + OUString::number( number ) + ".odt"; + // Output name early, so in the case of a hang, the name of the hanging input file is visible. + std::cout << name << ","; + mnStartTime = osl_getGlobalTimer(); + mxComponent = loadFromDesktop(mailMergeOutputURL + "/" + name, "com.sun.star.text.TextDocument"); + CPPUNIT_ASSERT( mxComponent.is()); + OString name2 = OUStringToOString( name, RTL_TEXTENCODING_UTF8 ); + discardDumpedLayout(); + if (mustCalcLayoutOf(name2.getStr())) + calcLayout(); + } + protected: // Returns page number of the first page of a MM document inside the large MM document (used in the SHELL case). int documentStartPageNumber( int document ) const; + + uno::Reference< com::sun::star::task::XJob > mxJob; + uno::Sequence< beans::NamedValue > mSeqMailMergeArgs; + OUString mailMergeOutputURL; + OUString mailMergeOutputPrefix; + sal_Int16 mnCurOutputType; + uno::Reference< lang::XComponent > mxMMComponent; }; #define DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, file, BaseClass) \ @@ -201,6 +257,11 @@ int MMTest::documentStartPageNumber( int document ) const shell->Pop(false); return page; } +MMTest::MMTest() + : SwModelTestBase("/sw/qa/extras/mailmerge/data/", "writer8") + , mnCurOutputType(0) +{ +} DECLARE_SHELL_MAILMERGE_TEST(testMultiPageAnchoredDraws, "multiple-page-anchored-draws.odt", "4_v01.ods", "Tabelle1") { |