Kaydet (Commit) 0ab6b1fc authored tarafından Michael Stahl's avatar Michael Stahl

sw: shove 2 global variables into SwHyphIter

Change-Id: I0cb6112b0353a5fd0b4dd571d65f2d656e39ba74
üst 655248f1
......@@ -22,12 +22,15 @@
#include <i18nlangtag/lang.h>
#include <tools/solar.h>
#include <tools/gen.hxx>
#include <limits.h>
#include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
#include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
#include <functional>
#include <limits.h>
class SwTextFrm;
class SwTextNode;
class SwIndex;
namespace vcl { class Font; }
......@@ -152,6 +155,14 @@ public:
}
};
namespace sw {
SwTextFrm *
SwHyphIterCacheLastTxtFrm(SwTextNode *, std::function<SwTextFrm * ()>);
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -155,11 +155,16 @@ public:
class SwHyphIter : public SwLinguIter
{
// With that we save a GetFrm() in Hyphenate //TODO: does it actually matter?
const SwTextNode *m_pLastNode;
SwTextFrm *m_pLastFrm;
friend SwTextFrm * sw::SwHyphIterCacheLastTxtFrm(SwTextNode *, std::function<SwTextFrm * ()>);
bool bOldIdle;
static void DelSoftHyph( SwPaM &rPam );
public:
SwHyphIter() : bOldIdle(false) {}
SwHyphIter() : m_pLastNode(nullptr), m_pLastFrm(nullptr), bOldIdle(false) {}
void Start( SwEditShell *pSh, SwDocPositions eStart, SwDocPositions eEnd );
void End();
......@@ -177,11 +182,6 @@ static SwSpellIter* g_pSpellIter = nullptr;
static SwConvIter* g_pConvIter = nullptr;
static SwHyphIter* g_pHyphIter = nullptr;
// With that we save a GetFrm() in Hyphenate.
// Caution: There are external declaration to these pointers in txtedt.cxx!
const SwTextNode *pLinguNode;
SwTextFrm *pLinguFrm;
SwLinguIter::SwLinguIter()
: pSh(nullptr)
, pStart(nullptr)
......@@ -249,9 +249,6 @@ void SwLinguIter::_Start( SwEditShell *pShell, SwDocPositions eStart,
}
pCrsr->SetMark();
pLinguFrm = nullptr;
pLinguNode = nullptr;
}
void SwLinguIter::_End(bool bRestoreSelection)
......@@ -572,6 +569,23 @@ void SwHyphIter::InsertSoftHyph( const sal_Int32 nHyphPos )
pCrsr->SetMark();
}
namespace sw {
SwTextFrm *
SwHyphIterCacheLastTxtFrm(SwTextNode *const pNode,
std::function<SwTextFrm * ()> const create)
{
assert(g_pHyphIter);
if (pNode != g_pHyphIter->m_pLastNode || !g_pHyphIter->m_pLastFrm)
{
g_pHyphIter->m_pLastNode = pNode;
g_pHyphIter->m_pLastFrm = create();
}
return g_pHyphIter->m_pLastFrm;
}
}
bool SwEditShell::HasLastSentenceGotGrammarChecked()
{
bool bTextWasGrammarChecked = false;
......
......@@ -1618,12 +1618,12 @@ bool SwTextNode::Hyphenate( SwInterHyphInfo &rHyphInf )
return false;
}
if( pLinguNode != this )
{
pLinguNode = this;
pLinguFrm = static_cast<SwTextFrm*>(getLayoutFrm( GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(), rHyphInf.GetCrsrPos() ));
}
SwTextFrm *pFrm = pLinguFrm;
SwTextFrm *pFrm = ::sw::SwHyphIterCacheLastTxtFrm(this,
[&rHyphInf, this]() {
return static_cast<SwTextFrm*>(this->getLayoutFrm(
this->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(),
rHyphInf.GetCrsrPos()));
});
if( pFrm )
pFrm = &(pFrm->GetFrmAtOfst( rHyphInf.nStart ));
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment