summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-07-06 11:55:08 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-07-06 16:40:55 +0200
commita9efcef2c586b50ae36b20b34fa2b0fe21af0d8a (patch)
tree4eb1682c584c543d751c6bd4d7ec2b9e112dc324 /sw
parent1cab72b41b761084258871bc39cfb583986c2395 (diff)
ofz#2469 docshell leaks if progress bar is not stopped
Change-Id: I2595833dd3c6c9e05a32b70c880444128d66c4d3 Reviewed-on: https://gerrit.libreoffice.org/39643 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/ww8par.cxx32
-rw-r--r--sw/source/filter/ww8/ww8par.hxx15
2 files changed, 39 insertions, 8 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index d99fb2dd96b0..68f241eaf240 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4068,7 +4068,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
if ((nCrCount++ & 0x40) == 0 && nType == MAN_MAINTEXT)
{
m_nProgress = (sal_uInt16)( l * 100 / nTextLen );
- ::SetProgressState(m_nProgress, m_pDocShell); // Update
+ m_xProgress->Update(m_nProgress); // Update
}
}
@@ -4848,6 +4848,22 @@ void SwWW8ImplReader::ReadGlobalTemplateSettings( const OUString& sCreatedFrom,
}
}
+ImportProgress::ImportProgress(SwDocShell *pDocShell)
+ : m_pDocShell(pDocShell)
+{
+ ::StartProgress(STR_STATSTR_W4WREAD, 0, 100, m_pDocShell);
+}
+
+void ImportProgress::Update(sal_uInt16 nProgress)
+{
+ ::SetProgressState(nProgress, m_pDocShell); // Update
+}
+
+ImportProgress::~ImportProgress()
+{
+ ::EndProgress(m_pDocShell);
+}
+
ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
{
m_rDoc.SetDocumentType( SwDoc::DOCTYPE_MSWORD );
@@ -4936,7 +4952,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
if (!m_bNewDoc)
aSttNdIdx = m_pPaM->GetPoint()->nNode;
- ::StartProgress(STR_STATSTR_W4WREAD, 0, 100, m_pDocShell);
+ m_xProgress.reset(new ImportProgress(m_pDocShell));
// read Font Table
m_xFonts.reset(new WW8Fonts(*m_pTableStream, *m_xWwFib));
@@ -4980,7 +4996,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
ReadDocVars(); // import document variables as meta information.
- ::SetProgressState(m_nProgress, m_pDocShell); // Update
+ m_xProgress->Update(m_nProgress); // Update
m_xLstManager.reset(new WW8ListManager(*m_pTableStream, *this));
@@ -4988,7 +5004,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
first (1) import all styles (see WW8PAR2.CXX)
BEFORE the import of the lists !!
*/
- ::SetProgressState(m_nProgress, m_pDocShell); // Update
+ m_xProgress->Update(m_nProgress); // Update
m_xStyles.reset(new WW8RStyle(*m_xWwFib, this)); // Styles
m_xStyles->Import();
@@ -4998,7 +5014,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
Go through all Styles and attach respective List Format
AFTER we imported the Styles and AFTER we imported the Lists!
*/
- ::SetProgressState(m_nProgress, m_pDocShell); // Update
+ m_xProgress->Update(m_nProgress); // Update
m_xStyles->PostProcessStyles();
if (!m_vColl.empty())
@@ -5073,7 +5089,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
m_rDoc.GetNodes().GetEndOfInserts().StartOfSectionIndex() < nNd );
}
- ::SetProgressState(m_nProgress, m_pDocShell); // Update
+ m_xProgress->Update(m_nProgress); // Update
// loop for each glossary entry and add dummy section node
if (pGloss)
@@ -5155,7 +5171,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
m_bOnLoadingMain = false;
}
- ::SetProgressState(m_nProgress, m_pDocShell); // Update
+ m_xProgress->Update(m_nProgress); // Update
if (m_pDrawPg && m_pMSDffManager && m_pMSDffManager->GetShapeOrders())
{
@@ -5243,7 +5259,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
m_xFonts.reset();
delete m_pAtnNames;
m_xSprmParser.reset();
- ::EndProgress(m_pDocShell);
+ m_xProgress.reset();
m_pDataStream = nullptr;
m_pTableStream = nullptr;
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 575655fa3994..73e2341d3e65 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1053,6 +1053,16 @@ struct WW8TabBandDesc
typedef std::set<WW8_CP> cp_set;
typedef std::vector<WW8_CP> cp_vector;
+class ImportProgress
+{
+private:
+ SwDocShell *m_pDocShell;
+public:
+ ImportProgress(SwDocShell *pDocShell);
+ void Update(sal_uInt16 nProgress);
+ ~ImportProgress();
+};
+
class SwWW8ImplReader
{
private:
@@ -1175,6 +1185,11 @@ private:
std::stack<rtl_TextEncoding> m_aFontSrcCharSets;
std::stack<rtl_TextEncoding> m_aFontSrcCJKCharSets;
+ /*
+ Progress bar
+ */
+ std::unique_ptr<ImportProgress> m_xProgress;
+
SwMSConvertControls *m_pFormImpl; // Control-Implementierung
SwFlyFrameFormat* m_pFlyFormatOfJustInsertedGraphic;