[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sw/source
Caolán McNamara
caolanm at redhat.com
Wed Aug 26 08:43:13 PDT 2015
sw/source/filter/ww8/ww8glsy.cxx | 12 +++++-------
sw/source/filter/ww8/ww8par.cxx | 27 +++++++++++++++------------
sw/source/filter/ww8/ww8par.hxx | 11 ++++++-----
3 files changed, 26 insertions(+), 24 deletions(-)
New commits:
commit f77ae2fb07ad1fc832f71c3056a351322e743a02
Author: Caolán McNamara <caolanm at 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/18018
Reviewed-by: David Tardon <dtardon at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index ff27a37..dcf97b2 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -209,9 +209,7 @@ bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool bSaveRelFile )
SfxObjectShellLock xDocSh(new SwDocShell(SFX_CREATE_MODE_INTERNAL));
if (xDocSh->DoInitNew(0))
{
- SwDoc *pD = ((SwDocShell*)(&xDocSh))->GetDoc();
- SwWW8ImplReader* pRdr = new SwWW8ImplReader(pGlossary->nVersion,
- xStg, &rStrm, *pD, rBlocks.GetBaseURL(), true);
+ SwDoc *pD = static_cast<SwDocShell*>((&xDocSh))->GetDoc();
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().GetCntntNode(),
0);
- pRdr->LoadDoc(aPamo,this);
-
+ std::unique_ptr<SwWW8ImplReader> xRdr(new SwWW8ImplReader(
+ pGlossary->nVersion, xStg, &rStrm, *pD, rBlocks.GetBaseURL(),
+ true, *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 e922037..de84a15 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4124,7 +4124,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
}
SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage,
- SvStream* pSt, SwDoc& rD, const OUString& rBaseURL, bool bNewDoc)
+ SvStream* pSt, SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, SwPosition &rPos)
: mpDocShell(rD.GetDocShell())
, pStg(pStorage)
, pStrm(pSt)
@@ -4260,6 +4260,8 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage,
{
pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
maApos.push_back(false);
+
+ mpCrsr.reset(rDoc.CreateUnoCrsr(rPos));
}
void SwWW8ImplReader::DeleteStk(SwFltControlStack* pStck)
@@ -4876,7 +4878,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;
@@ -4912,7 +4914,7 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
pDocShell->SetReadOnlyUI(true);
}
- pPaM = rDoc.CreateUnoCrsr(rPos);
+ pPaM = mpCrsr.get();
pCtrlStck = new SwWW8FltControlStack( &rDoc, nFieldFlags, *this );
@@ -5349,7 +5351,8 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
SAL_WARN_IF(mpTableEndPaM, "sw.ww8", "document ended without table ending");
mpTableEndPaM.reset(); //ensure this is deleted before pPaM
- delete pPaM, pPaM = 0;
+ mpCrsr.reset();
+ pPaM = nullptr;
mpLastAnchorPos.reset();//ensure this is deleted before UpdatePageDescs
UpdatePageDescs(rDoc, nPageDescOffset);
@@ -5578,7 +5581,7 @@ namespace
}
}
-sal_uLong SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss)
+sal_uLong SwWW8ImplReader::LoadThroughDecryption(WW8Glossary *pGloss)
{
sal_uLong nErrRet = 0;
if (pGloss)
@@ -5748,7 +5751,7 @@ sal_uLong SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGlos
}
if (!nErrRet)
- nErrRet = CoreLoad(pGloss, *rPaM.GetPoint());
+ nErrRet = CoreLoad(pGloss);
delete pTempMain;
delete pTempTable;
@@ -5945,7 +5948,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;
@@ -6020,7 +6023,7 @@ sal_uLong SwWW8ImplReader::LoadDoc( SwPaM& rPaM,WW8Glossary *pGloss)
}
if (!nErrRet)
- nErrRet = LoadThroughDecryption(rPaM ,pGloss);
+ nErrRet = LoadThroughDecryption(pGloss);
rDoc.PropagateOutlineRule();
@@ -6053,7 +6056,7 @@ sal_uLong WW8Reader::OpenMainStream( SvStorageStreamRef& rRef, sal_uInt16& rBuff
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)
@@ -6096,16 +6099,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, *rPaM.GetPoint());
if (bNew)
{
// Remove Frame and offsets from Frame Template
Reader::ResetFrmFmts( rDoc );
}
- SwWW8ImplReader* pRdr = new SwWW8ImplReader(nVersion, pStg, pIn, rDoc,
- rBaseURL, bNew);
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 475c70c..4b49754 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1112,6 +1112,7 @@ private:
// allgemeines
SwDoc& rDoc;
+ std::shared_ptr<SwUnoCrsr> mpCrsr;
SwPaM* pPaM;
SwWW8FltControlStack* pCtrlStck; // Stack fuer die Attribute
@@ -1552,9 +1553,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(SvStorageStreamRef &rTableStream, SvStorageStreamRef &rDataStream);
- sal_uLong CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos);
+ sal_uLong CoreLoad(WW8Glossary *pGloss);
void ReadDocVars();
@@ -1911,11 +1912,11 @@ public: // eigentlich private, geht aber leider nur public
static ColorData GetCol(sal_uInt8 nIco);
SwWW8ImplReader( sal_uInt8 nVersionPara, SvStorage* pStorage, SvStream* pSt,
- SwDoc& rD, const OUString& rBaseURL, bool bNewDoc );
+ SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, SwPosition &rPos );
const OUString& GetBaseURL() const { return 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();
More information about the Libreoffice-commits
mailing list