summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2017-05-07 21:48:45 +0200
committerJochen Nitschke <j.nitschke+logerrit@ok.de>2017-05-09 17:51:56 +0200
commit67ab5337cd253671a241f1f045287c31986497b1 (patch)
tree025f8dd9fc65dc4387aa5be6770d63840d2eab51 /sw/qa
parent2de355e71617da2474ec2e4bf92db86dbdf83fdb (diff)
silence cppcheck memleak in unit test
line 825: Memory leak 'pGlossary' Change-Id: Id7f103c4e6f8bd4b4941edfe815508305d9a5f55 Reviewed-on: https://gerrit.libreoffice.org/37377 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx17
1 files changed, 9 insertions, 8 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 62958cfbac8e..57e41ebf5765 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -86,6 +86,7 @@
#include "com/sun/star/text/TextMarkupType.hpp"
#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
+#include <o3tl/make_unique.hxx>
#include <osl/file.hxx>
#include <paratr.hxx>
#include <drawfont.hxx>
@@ -376,7 +377,7 @@ public:
private:
SwDoc* createDoc(const char* pName = nullptr);
- SwTextBlocks* readDOCXAutotext(const OUString& sFileName, bool bEmpty = false);
+ std::unique_ptr<SwTextBlocks> readDOCXAutotext(const OUString& sFileName, bool bEmpty = false);
};
SwDoc* SwUiWriterTest::createDoc(const char* pName)
@@ -391,16 +392,16 @@ SwDoc* SwUiWriterTest::createDoc(const char* pName)
return pTextDoc->GetDocShell()->GetDoc();
}
-SwTextBlocks* SwUiWriterTest::readDOCXAutotext(const OUString& sFileName, bool bEmpty)
+std::unique_ptr<SwTextBlocks> SwUiWriterTest::readDOCXAutotext(const OUString& sFileName, bool bEmpty)
{
OUString rURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + sFileName;
- SfxMedium* pSrcMed = new SfxMedium(rURL, StreamMode::STD_READ);
+ SfxMedium aSrcMed(rURL, StreamMode::STD_READ);
SwDoc* pDoc = createDoc();
- SwReader aReader(*pSrcMed, rURL, pDoc);
+ SwReader aReader(aSrcMed, rURL, pDoc);
Reader* pDOCXReader = SwReaderWriter::GetDOCXReader();
- SwTextBlocks* pGlossary = new SwTextBlocks(rURL);
+ auto pGlossary = o3tl::make_unique<SwTextBlocks>(rURL);
CPPUNIT_ASSERT(pDOCXReader != nullptr);
CPPUNIT_ASSERT_EQUAL(!bEmpty, aReader.ReadGlossaries(*pDOCXReader, *pGlossary, false));
@@ -772,14 +773,14 @@ void SwUiWriterTest::testExportRTF()
void SwUiWriterTest::testDOCXAutoTextEmpty()
{
// file contains normal content but no AutoText
- SwTextBlocks* pGlossary = readDOCXAutotext("autotext-empty.dotx", true);
+ std::unique_ptr<SwTextBlocks> pGlossary = readDOCXAutotext("autotext-empty.dotx", true);
CPPUNIT_ASSERT(pGlossary != nullptr);
}
void SwUiWriterTest::testDOCXAutoTextMultiple()
{
// file contains three AutoText entries
- SwTextBlocks* pGlossary = readDOCXAutotext("autotext-multiple.dotx");
+ std::unique_ptr<SwTextBlocks> pGlossary = readDOCXAutotext("autotext-multiple.dotx");
// check entries count
CPPUNIT_ASSERT_EQUAL((sal_uInt16)3, pGlossary->GetCount());
@@ -812,7 +813,7 @@ void SwUiWriterTest::testDOTMAutoText()
{
// this is dotm file difference is that in the dotm
// there are no empty paragraphs at the end of each entry
- SwTextBlocks* pGlossary = readDOCXAutotext("autotext-dotm.dotm");
+ std::unique_ptr<SwTextBlocks> pGlossary = readDOCXAutotext("autotext-dotm.dotm");
SwDoc* pDoc = pGlossary->GetDoc();
CPPUNIT_ASSERT(pDoc != nullptr);