sw/source/filter/ww8/ww8glsy.cxx |   10 ++++------
 sw/source/filter/ww8/ww8par.cxx  |   27 +++++++++++++++------------
 sw/source/filter/ww8/ww8par.hxx  |   11 ++++++-----
 3 files changed, 25 insertions(+), 23 deletions(-)

New commits:
commit 16479c8d88c63f6762dd202120439b190beacaae
Author: Caolán McNamara <caol...@redhat.com>
Date:   Tue Aug 25 13:30:12 2015 +0100

    we only need the PaM for its Point and only to create a uno cursor
    
    so do that in the ctor and drop the arg from a bunch of places
    
    (cherry picked from commit 3d992d77d8ae319b31dca808e8c08f439a1bc9c3)
    
    Change-Id: Iaad71e9854b38d8632df057dfe9c96468d1d0098
    Reviewed-on: https://gerrit.libreoffice.org/17997
    Reviewed-by: David Tardon <dtar...@redhat.com>
    Tested-by: David Tardon <dtar...@redhat.com>

diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index 7a8d0f4..f125f69 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -210,8 +210,6 @@ bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool 
bSaveRelFile )
             if (xDocSh->DoInitNew(0))
             {
                 SwDoc *pD =  static_cast<SwDocShell*>((&xDocSh))->GetDoc();
-                SwWW8ImplReader* pRdr = new 
SwWW8ImplReader(pGlossary->nVersion,
-                    xStg, &rStrm, *pD, rBlocks.GetBaseURL(), true, false);
 
                 SwNodeIndex aIdx(
                     *pD->GetNodes().GetEndOfContent().StartOfSectionNode(), 1);
@@ -223,11 +221,11 @@ bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool 
bSaveRelFile )
                 SwPaM aPamo( aIdx );
                 
aPamo.GetPoint()->nContent.Assign(aIdx.GetNode().GetContentNode(),
                     0);
-                pRdr->LoadDoc(aPamo,this);
-
+                std::unique_ptr<SwWW8ImplReader> xRdr(new SwWW8ImplReader(
+                    pGlossary->nVersion, xStg, &rStrm, *pD, 
rBlocks.GetBaseURL(),
+                    true, false, *aPamo.GetPoint()));
+                xRdr->LoadDoc(this);
                 bRet = MakeEntries(pD, rBlocks, bSaveRelFile, aStrings, aData);
-
-                delete pRdr;
             }
             xDocSh->DoClose();
             rBlocks.EndPutMuchBlockEntries();
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 583d876..464db40 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4125,7 +4125,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP 
nTextLen, ManTypes nType)
 }
 
 SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
-    SvStream* pSt, SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, bool 
bSkipImages)
+    SvStream* pSt, SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, bool 
bSkipImages, SwPosition &rPos)
     : m_pDocShell(rD.GetDocShell())
     , m_pStg(pStorage)
     , m_pStrm(pSt)
@@ -4261,6 +4261,8 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, 
SotStorage* pStorage,
 {
     m_pStrm->SetEndian( SvStreamEndian::LITTLE );
     m_aApos.push_back(false);
+
+    mpCrsr.reset(m_rDoc.CreateUnoCrsr(rPos));
 }
 
 void SwWW8ImplReader::DeleteStk(SwFltControlStack* pStck)
@@ -4879,7 +4881,7 @@ bool SwWW8ImplReader::ReadGlobalTemplateSettings( const 
OUString& sCreatedFrom,
     return bRes;
 }
 
-sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition 
&rPos)
+sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
 {
     sal_uLong nErrRet = 0;
 
@@ -4915,7 +4917,7 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, 
const SwPosition &rPos)
             pDocShell->SetReadOnlyUI(true);
     }
 
-    m_pPaM = m_rDoc.CreateUnoCrsr(rPos);
+    m_pPaM = mpCrsr.get();
 
     m_pCtrlStck = new SwWW8FltControlStack( &m_rDoc, m_nFieldFlags, *this );
 
@@ -5359,7 +5361,8 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, 
const SwPosition &rPos)
 
     SAL_WARN_IF(m_pTableEndPaM, "sw.ww8", "document ended without table 
ending");
     m_pTableEndPaM.reset();  //ensure this is deleted before pPaM
-    delete m_pPaM, m_pPaM = 0;
+    mpCrsr.reset();
+    m_pPaM = nullptr;
     m_pLastAnchorPos.reset();//ensure this is deleted before UpdatePageDescs
 
     UpdatePageDescs(m_rDoc, nPageDescOffset);
@@ -5588,7 +5591,7 @@ namespace
     }
 }
 
-sal_uLong SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary 
*pGloss)
+sal_uLong SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss)
 {
     sal_uLong nErrRet = 0;
     if (pGloss)
@@ -5758,7 +5761,7 @@ sal_uLong SwWW8ImplReader::LoadThroughDecryption(SwPaM& 
rPaM ,WW8Glossary *pGlos
     }
 
     if (!nErrRet)
-        nErrRet = CoreLoad(pGloss, *rPaM.GetPoint());
+        nErrRet = CoreLoad(pGloss);
 
     delete pTempMain;
     delete pTempTable;
@@ -5955,7 +5958,7 @@ const OUString* 
SwWW8ImplReader::GetAnnotationAuthor(sal_uInt16 nIdx)
     return pRet;
 }
 
-sal_uLong SwWW8ImplReader::LoadDoc( SwPaM& rPaM,WW8Glossary *pGloss)
+sal_uLong SwWW8ImplReader::LoadDoc(WW8Glossary *pGloss)
 {
     sal_uLong nErrRet = 0;
 
@@ -6030,7 +6033,7 @@ sal_uLong SwWW8ImplReader::LoadDoc( SwPaM& 
rPaM,WW8Glossary *pGloss)
     }
 
     if (!nErrRet)
-        nErrRet = LoadThroughDecryption(rPaM ,pGloss);
+        nErrRet = LoadThroughDecryption(pGloss);
 
     m_rDoc.PropagateOutlineRule();
 
@@ -6063,7 +6066,7 @@ sal_uLong WW8Reader::OpenMainStream( 
tools::SvRef<SotStorageStream>& rRef, sal_u
     return nRet;
 }
 
-sal_uLong WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam, 
const OUString & /* FileName */)
+sal_uLong WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, 
const OUString & /* FileName */)
 {
     sal_uInt16 nOldBuffSize = 32768;
     bool bNew = !bInsertMode; // New Doc (no inserting)
@@ -6106,16 +6109,16 @@ sal_uLong WW8Reader::Read(SwDoc &rDoc, const OUString& 
rBaseURL, SwPaM &rPam, co
 
     if( !nRet )
     {
+        SwWW8ImplReader* pRdr = new SwWW8ImplReader(nVersion, pStg, pIn, rDoc,
+            rBaseURL, bNew, bSkipImages, *rPaM.GetPoint());
         if (bNew)
         {
             // Remove Frame and offsets from Frame Template
             Reader::ResetFrameFormats( rDoc );
         }
-        SwWW8ImplReader* pRdr = new SwWW8ImplReader(nVersion, pStg, pIn, rDoc,
-            rBaseURL, bNew, bSkipImages);
         try
         {
-            nRet = pRdr->LoadDoc( rPam );
+            nRet = pRdr->LoadDoc();
         }
         catch( const std::exception& )
         {
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index c8f8032..0723912 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1094,6 +1094,7 @@ private:
 
 // allgemeines
     SwDoc& m_rDoc;
+    std::shared_ptr<SwUnoCrsr> mpCrsr;
     SwPaM* m_pPaM;
 
     SwWW8FltControlStack* m_pCtrlStck;    // Stack fuer die Attribute
@@ -1536,9 +1537,9 @@ private:
     //This converts MS Asian Typography information into OOo's
     void ImportDopTypography(const WW8DopTypography &rTypo);
 
-    sal_uLong LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss);
+    sal_uLong LoadThroughDecryption(WW8Glossary *pGloss);
     sal_uLong SetSubStreams(tools::SvRef<SotStorageStream> &rTableStream, 
tools::SvRef<SotStorageStream> &rDataStream);
-    sal_uLong CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos);
+    sal_uLong CoreLoad(WW8Glossary *pGloss);
 
     void ReadDocVars();
 
@@ -1884,11 +1885,11 @@ public:     // eigentlich private, geht aber leider nur 
public
     static ColorData GetCol(sal_uInt8 nIco);
 
     SwWW8ImplReader( sal_uInt8 nVersionPara, SotStorage* pStorage, SvStream* 
pSt,
-        SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, bool bSkipImages );
+        SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, bool bSkipImages, 
SwPosition &rPos );
 
     const OUString& GetBaseURL() const { return m_sBaseURL; }
-    // Laden eines kompletten DocFiles
-    sal_uLong LoadDoc( SwPaM&,WW8Glossary *pGloss=0);
+    // load a complete doc file
+    sal_uLong LoadDoc(WW8Glossary *pGloss=0);
     rtl_TextEncoding GetCurrentCharSet();
     rtl_TextEncoding GetCurrentCJKCharSet();
     rtl_TextEncoding GetCharSetFromLanguage();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to