summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-04-19 11:20:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-04-19 21:45:02 +0200
commit6e531f337b27e0979cce844c013352d05ef5281e (patch)
tree0c4820c1ce0b8e9f05707a3d0ff38d49f7016cdd
parentca8f4a66e44aed731646066241cf2225bb9f8c2a (diff)
SwBreakIt::m_xBreak is always available
this all is a hold over from the initial tentitive changeover to using it in the first place Change-Id: I70e28023798d8ea637c61f9fac252bc698e8100d Reviewed-on: https://gerrit.libreoffice.org/36683 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/core/access/accpara.cxx86
-rw-r--r--sw/source/core/access/accportions.cxx60
-rw-r--r--sw/source/core/crsr/callnk.cxx16
-rw-r--r--sw/source/core/crsr/findtxt.cxx3
-rw-r--r--sw/source/core/crsr/swcrsr.cxx20
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx26
-rw-r--r--sw/source/core/doc/docfmt.cxx13
-rw-r--r--sw/source/core/doc/docruby.cxx2
-rw-r--r--sw/source/core/doc/doctxm.cxx8
-rw-r--r--sw/source/core/docnode/node.cxx88
-rw-r--r--sw/source/core/edit/edattr.cxx2
-rw-r--r--sw/source/core/text/guess.cxx2
-rw-r--r--sw/source/core/text/itratr.cxx42
-rw-r--r--sw/source/core/text/porfld.cxx27
-rw-r--r--sw/source/core/text/porlay.cxx7
-rw-r--r--sw/source/core/text/portxt.cxx4
-rw-r--r--sw/source/core/text/redlnitr.cxx58
-rw-r--r--sw/source/core/text/txtdrop.cxx2
-rw-r--r--sw/source/core/text/txthyph.cxx3
-rw-r--r--sw/source/core/txtnode/fntcache.cxx26
-rw-r--r--sw/source/core/txtnode/fntcap.cxx3
-rw-r--r--sw/source/core/txtnode/txatritr.cxx76
-rw-r--r--sw/source/core/txtnode/txtedt.cxx66
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx9
-rw-r--r--sw/source/filter/ww8/writerwordglue.cxx27
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx6
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx22
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx13
-rw-r--r--sw/source/filter/ww8/ww8par.cxx6
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx7
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx12
31 files changed, 303 insertions, 439 deletions
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 2c3fe1c8ffb6..742505068514 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -743,38 +743,23 @@ bool SwAccessibleParagraph::GetWordBoundary(
const OUString& rText,
sal_Int32 nPos )
{
- bool bRet = false;
-
// now ask the Break-Iterator for the word
- OSL_ENSURE( g_pBreakIt != nullptr, "We always need a break." );
- OSL_ENSURE( g_pBreakIt->GetBreakIter().is(), "No break-iterator." );
- if( g_pBreakIt->GetBreakIter().is() )
- {
- // get locale for this position
- const sal_Int32 nModelPos = GetPortionData().GetModelPosition( nPos );
- lang::Locale aLocale = g_pBreakIt->GetLocale(
- GetTextNode()->GetLang( nModelPos ) );
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
- // which type of word are we interested in?
- // (DICTIONARY_WORD includes punctuation, ANY_WORD doesn't.)
- const sal_Int16 nWordType = i18n::WordType::ANY_WORD;
+ // get locale for this position
+ const sal_Int32 nModelPos = GetPortionData().GetModelPosition( nPos );
+ lang::Locale aLocale = g_pBreakIt->GetLocale(
+ GetTextNode()->GetLang( nModelPos ) );
- // get word boundary, as the Break-Iterator sees fit.
- rBound = g_pBreakIt->GetBreakIter()->getWordBoundary(
- rText, nPos, aLocale, nWordType, true );
+ // which type of word are we interested in?
+ // (DICTIONARY_WORD includes punctuation, ANY_WORD doesn't.)
+ const sal_Int16 nWordType = i18n::WordType::ANY_WORD;
- // If we have a break-iterator let's trust that it
- // does the right thing.
- bRet = true;
- }
- else
- {
- // no break Iterator -> no word
- rBound.startPos = nPos;
- rBound.endPos = nPos;
- }
+ // get word boundary, as the Break-Iterator sees fit.
+ rBound = g_pBreakIt->GetBreakIter()->getWordBoundary(
+ rText, nPos, aLocale, nWordType, true );
- return bRet;
+ return true;
}
bool SwAccessibleParagraph::GetSentenceBoundary(
@@ -829,36 +814,25 @@ bool SwAccessibleParagraph::GetGlyphBoundary(
const OUString& rText,
sal_Int32 nPos )
{
- bool bRet = false;
-
// ask the Break-Iterator for the glyph by moving one cell
// forward, and then one cell back
- OSL_ENSURE( g_pBreakIt != nullptr, "We always need a break." );
- OSL_ENSURE( g_pBreakIt->GetBreakIter().is(), "No break-iterator." );
- if( g_pBreakIt->GetBreakIter().is() )
- {
- // get locale for this position
- const sal_Int32 nModelPos = GetPortionData().GetModelPosition( nPos );
- lang::Locale aLocale = g_pBreakIt->GetLocale(
- GetTextNode()->GetLang( nModelPos ) );
-
- // get word boundary, as the Break-Iterator sees fit.
- const sal_Int16 nIterMode = i18n::CharacterIteratorMode::SKIPCELL;
- sal_Int32 nDone = 0;
- rBound.endPos = g_pBreakIt->GetBreakIter()->nextCharacters(
- rText, nPos, aLocale, nIterMode, 1, nDone );
- rBound.startPos = g_pBreakIt->GetBreakIter()->previousCharacters(
- rText, rBound.endPos, aLocale, nIterMode, 1, nDone );
- bRet = ((rBound.startPos <= nPos) && (nPos <= rBound.endPos));
- OSL_ENSURE( rBound.startPos <= nPos, "start pos too high" );
- OSL_ENSURE( rBound.endPos >= nPos, "end pos too low" );
- }
- else
- {
- // no break Iterator -> no glyph
- rBound.startPos = nPos;
- rBound.endPos = nPos;
- }
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+
+ // get locale for this position
+ const sal_Int32 nModelPos = GetPortionData().GetModelPosition( nPos );
+ lang::Locale aLocale = g_pBreakIt->GetLocale(
+ GetTextNode()->GetLang( nModelPos ) );
+
+ // get word boundary, as the Break-Iterator sees fit.
+ const sal_Int16 nIterMode = i18n::CharacterIteratorMode::SKIPCELL;
+ sal_Int32 nDone = 0;
+ rBound.endPos = g_pBreakIt->GetBreakIter()->nextCharacters(
+ rText, nPos, aLocale, nIterMode, 1, nDone );
+ rBound.startPos = g_pBreakIt->GetBreakIter()->previousCharacters(
+ rText, rBound.endPos, aLocale, nIterMode, 1, nDone );
+ bool bRet = ((rBound.startPos <= nPos) && (nPos <= rBound.endPos));
+ OSL_ENSURE( rBound.startPos <= nPos, "start pos too high" );
+ OSL_ENSURE( rBound.endPos >= nPos, "end pos too low" );
return bRet;
}
@@ -880,7 +854,7 @@ bool SwAccessibleParagraph::GetTextBoundary(
switch( nTextType )
{
case AccessibleTextType::WORD:
- bRet = GetWordBoundary( rBound, rText, nPos );
+ bRet = GetWordBoundary(rBound, rText, nPos);
break;
case AccessibleTextType::SENTENCE:
diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx
index 60caf0a05035..f188bcc9a134 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -475,47 +475,37 @@ void SwAccessiblePortionData::GetSentenceBoundary(
if( m_pSentences == nullptr )
{
- OSL_ENSURE( g_pBreakIt != nullptr, "We always need a break." );
- OSL_ENSURE( g_pBreakIt->GetBreakIter().is(), "No break-iterator." );
- if( g_pBreakIt->GetBreakIter().is() )
- {
- m_pSentences.reset( new Positions_t );
- m_pSentences->reserve(10);
-
- // use xBreak->endOfSentence to iterate over all words; store
- // positions in pSentences
- sal_Int32 nCurrent = 0;
- sal_Int32 nLength = m_sAccessibleString.getLength();
- do
- {
- m_pSentences->push_back( nCurrent );
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
- const sal_Int32 nModelPos = GetModelPosition( nCurrent );
+ m_pSentences.reset( new Positions_t );
+ m_pSentences->reserve(10);
- sal_Int32 nNew = g_pBreakIt->GetBreakIter()->endOfSentence(
- m_sAccessibleString, nCurrent,
- g_pBreakIt->GetLocale(m_pTextNode->GetLang(nModelPos)) ) + 1;
+ // use xBreak->endOfSentence to iterate over all words; store
+ // positions in pSentences
+ sal_Int32 nCurrent = 0;
+ sal_Int32 nLength = m_sAccessibleString.getLength();
+ do
+ {
+ m_pSentences->push_back( nCurrent );
- if( (nNew < 0) && (nNew > nLength) )
- nNew = nLength;
- else if (nNew <= nCurrent)
- nNew = nCurrent + 1; // ensure forward progress
+ const sal_Int32 nModelPos = GetModelPosition( nCurrent );
- nCurrent = nNew;
- }
- while (nCurrent < nLength);
+ sal_Int32 nNew = g_pBreakIt->GetBreakIter()->endOfSentence(
+ m_sAccessibleString, nCurrent,
+ g_pBreakIt->GetLocale(m_pTextNode->GetLang(nModelPos)) ) + 1;
- // finish with two terminators
- m_pSentences->push_back( nLength );
- m_pSentences->push_back( nLength );
- }
- else
- {
- // no break iterator -> empty word
- rBound.startPos = 0;
- rBound.endPos = 0;
- return;
+ if( (nNew < 0) && (nNew > nLength) )
+ nNew = nLength;
+ else if (nNew <= nCurrent)
+ nNew = nCurrent + 1; // ensure forward progress
+
+ nCurrent = nNew;
}
+ while (nCurrent < nLength);
+
+ // finish with two terminators
+ m_pSentences->push_back( nLength );
+ m_pSentences->push_back( nLength );
}
FillBoundary( rBound, *m_pSentences, FindBreak( *m_pSentences, nPos ) );
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index 230850ec5973..dbb7ec74714c 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -191,16 +191,14 @@ SwCallLink::~SwCallLink()
}
}
- if( g_pBreakIt->GetBreakIter().is() )
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ const OUString rText = pCNd->GetTextNode()->GetText();
+ if( !nCmp ||
+ g_pBreakIt->GetBreakIter()->getScriptType( rText, nContent )
+ != g_pBreakIt->GetBreakIter()->getScriptType(rText, nAktContent))
{
- const OUString rText = pCNd->GetTextNode()->GetText();
- if( !nCmp ||
- g_pBreakIt->GetBreakIter()->getScriptType( rText, nContent )
- != g_pBreakIt->GetBreakIter()->getScriptType(rText, nAktContent))
- {
- rShell.CallChgLnk();
- return;
- }
+ rShell.CallChgLnk();
+ return;
}
}
else
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 1ffffa9532aa..2522d36d9f21 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -513,8 +513,7 @@ bool SwPaM::DoSearch( const i18nutil::SearchOptions2& rSearchOpt, utl::TextSearc
sal_uInt16 nSearchScript = 0;
sal_uInt16 nCurrScript = 0;
- if ( SearchAlgorithms2::APPROXIMATE == rSearchOpt.AlgorithmType2 &&
- g_pBreakIt->GetBreakIter().is() )
+ if (SearchAlgorithms2::APPROXIMATE == rSearchOpt.AlgorithmType2)
{
pScriptIter = new SwScriptIterator( sCleanStr, nStart, bSrchForward );
nSearchScript = g_pBreakIt->GetRealScriptOfText( rSearchOpt.searchString, 0 );
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index c3a4c3816b91..3014a36324f0 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -1159,7 +1159,7 @@ bool SwCursor::IsStartWordWT( sal_Int16 nWordType ) const
{
bool bRet = false;
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
const sal_Int32 nPtPos = GetPoint()->nContent.GetIndex();
bRet = g_pBreakIt->GetBreakIter()->isBeginWord(
@@ -1174,7 +1174,7 @@ bool SwCursor::IsEndWordWT( sal_Int16 nWordType ) const
{
bool bRet = false;
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
const sal_Int32 nPtPos = GetPoint()->nContent.GetIndex();
bRet = g_pBreakIt->GetBreakIter()->isEndWord(
@@ -1190,7 +1190,7 @@ bool SwCursor::IsInWordWT( sal_Int16 nWordType ) const
{
bool bRet = false;
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
const sal_Int32 nPtPos = GetPoint()->nContent.GetIndex();
Boundary aBoundary = g_pBreakIt->GetBreakIter()->getWordBoundary(
@@ -1231,7 +1231,7 @@ bool SwCursor::GoStartWordWT( sal_Int16 nWordType )
{
bool bRet = false;
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
SwCursorSaveState aSave( *this );
sal_Int32 nPtPos = GetPoint()->nContent.GetIndex();
@@ -1255,7 +1255,7 @@ bool SwCursor::GoEndWordWT( sal_Int16 nWordType )
{
bool bRet = false;
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
SwCursorSaveState aSave( *this );
sal_Int32 nPtPos = GetPoint()->nContent.GetIndex();
@@ -1280,7 +1280,7 @@ bool SwCursor::GoNextWordWT( sal_Int16 nWordType )
{
bool bRet = false;
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
SwCursorSaveState aSave( *this );
sal_Int32 nPtPos = GetPoint()->nContent.GetIndex();
@@ -1304,7 +1304,7 @@ bool SwCursor::GoPrevWordWT( sal_Int16 nWordType )
{
bool bRet = false;
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
SwCursorSaveState aSave( *this );
sal_Int32 nPtPos = GetPoint()->nContent.GetIndex();
@@ -1342,7 +1342,7 @@ bool SwCursor::SelectWordWT( SwViewShell* pViewShell, sal_Int16 nWordType, const
}
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
// Should we select the whole fieldmark?
const IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( );
@@ -1457,7 +1457,7 @@ bool SwCursor::GoSentence( SentenceMoveType eMoveType )
{
bool bRet = false;
const SwTextNode* pTextNd = GetNode().GetTextNode();
- if( pTextNd && g_pBreakIt->GetBreakIter().is() )
+ if (pTextNd)
{
OUString sNodeText( lcl_MaskDeletedRedlines( pTextNd ) );
@@ -1520,7 +1520,7 @@ bool SwCursor::ExpandToSentenceBorders()
bool bRes = false;
const SwTextNode* pStartNd = Start()->nNode.GetNode().GetTextNode();
const SwTextNode* pEndNd = End()->nNode.GetNode().GetTextNode();
- if (pStartNd && pEndNd && g_pBreakIt->GetBreakIter().is())
+ if (pStartNd && pEndNd)
{
if (!HasMark())
SetMark();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 3ae5eb01b6dc..da2fe6dd85b2 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1339,13 +1339,12 @@ namespace //local functions originally from docfmt.cxx
}
else
{
- Boundary aBndry;
- if( g_pBreakIt->GetBreakIter().is() )
- aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
- pTextNd->GetText(), nPtPos,
- g_pBreakIt->GetLocale( pTextNd->GetLang( nPtPos ) ),
- WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
- true );
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ Boundary aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
+ pTextNd->GetText(), nPtPos,
+ g_pBreakIt->GetLocale( pTextNd->GetLang( nPtPos ) ),
+ WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
+ true);
if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
{
@@ -2565,13 +2564,12 @@ void DocumentContentOperationsManager::TransliterateText(
{
// set current word as 'area of effect'
- Boundary aBndry;
- if( g_pBreakIt->GetBreakIter().is() )
- aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
- pTNd->GetText(), nSttCnt,
- g_pBreakIt->GetLocale( pTNd->GetLang( nSttCnt ) ),
- WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
- true );
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ Boundary aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
+ pTNd->GetText(), nSttCnt,
+ g_pBreakIt->GetLocale( pTNd->GetLang( nSttCnt ) ),
+ WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
+ true);
if( aBndry.startPos < nSttCnt && nSttCnt < aBndry.endPos )
{
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 6da1589e257d..5dff133d929f 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -269,13 +269,12 @@ void SwDoc::ResetAttrs( const SwPaM &rRg,
}
else
{
- Boundary aBndry;
- if( g_pBreakIt->GetBreakIter().is() )
- aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
- pTextNd->GetText(), nPtPos,
- g_pBreakIt->GetLocale( pTextNd->GetLang( nPtPos ) ),
- WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
- true );
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ Boundary aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
+ pTextNd->GetText(), nPtPos,
+ g_pBreakIt->GetLocale( pTextNd->GetLang( nPtPos ) ),
+ WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
+ true);
if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
{
diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx
index 050e825bd8a6..980ce7ebe330 100644
--- a/sw/source/core/doc/docruby.cxx
+++ b/sw/source/core/doc/docruby.cxx
@@ -296,7 +296,7 @@ bool SwDoc::SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rEntry, sal_uInt1
{
rPam.SetMark();
bAlphaNum = bIsAlphaNum;
- if( bChkNxtWrd && g_pBreakIt->GetBreakIter().is() )
+ if (bChkNxtWrd)
{
// search the end of this word
nWordEnd = g_pBreakIt->GetBreakIter()->getWordBoundary(
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index aa6d3b15cf6a..9280edf5199e 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -1160,12 +1160,8 @@ void SwTOXBaseSection::UpdateMarks( const SwTOXInternational& rIntl,
if(TOX_INDEX == eTOXTyp)
{
// index entry mark
- lang::Locale aLocale;
- if ( g_pBreakIt->GetBreakIter().is() )
- {
- aLocale = g_pBreakIt->GetLocale(
- pTOXSrc->GetLang( pTextMark->GetStart() ) );
- }
+ assert(g_pBreakIt);
+ lang::Locale aLocale = g_pBreakIt->GetLocale(pTOXSrc->GetLang(pTextMark->GetStart()));
pBase = new SwTOXIndex( *pTOXSrc, pTextMark,
GetOptions(), FORM_ENTRY, rIntl, aLocale );
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 96ec1e018fcd..578e1a98e2ff 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1186,33 +1186,27 @@ bool SwContentNode::GoNext(SwIndex * pIdx, sal_uInt16 nMode ) const
{
const SwTextNode& rTNd = *GetTextNode();
sal_Int32 nPos = pIdx->GetIndex();
- if( g_pBreakIt->GetBreakIter().is() )
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ sal_Int32 nDone = 0;
+ sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ?
+ CharacterIteratorMode::SKIPCELL :
+ CharacterIteratorMode::SKIPCONTROLCHARACTER;
+ nPos = g_pBreakIt->GetBreakIter()->nextCharacters( rTNd.GetText(), nPos,
+ g_pBreakIt->GetLocale( rTNd.GetLang( nPos ) ),
+ nItrMode, 1, nDone );
+
+ // Check if nPos is inside hidden text range:
+ if ( CRSR_SKIP_HIDDEN & nMode )
{
- sal_Int32 nDone = 0;
- sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ?
- CharacterIteratorMode::SKIPCELL :
- CharacterIteratorMode::SKIPCONTROLCHARACTER;
- nPos = g_pBreakIt->GetBreakIter()->nextCharacters( rTNd.GetText(), nPos,
- g_pBreakIt->GetLocale( rTNd.GetLang( nPos ) ),
- nItrMode, 1, nDone );
-
- // Check if nPos is inside hidden text range:
- if ( CRSR_SKIP_HIDDEN & nMode )
- {
- sal_Int32 nHiddenStart;
- sal_Int32 nHiddenEnd;
- SwScriptInfo::GetBoundsOfHiddenRange( rTNd, nPos, nHiddenStart, nHiddenEnd );
- if ( nHiddenStart != COMPLETE_STRING && nHiddenStart != nPos )
- nPos = nHiddenEnd;
- }
-
- if( 1 == nDone )
- *pIdx = nPos;
- else
- bRet = false;
+ sal_Int32 nHiddenStart;
+ sal_Int32 nHiddenEnd;
+ SwScriptInfo::GetBoundsOfHiddenRange( rTNd, nPos, nHiddenStart, nHiddenEnd );
+ if ( nHiddenStart != COMPLETE_STRING && nHiddenStart != nPos )
+ nPos = nHiddenEnd;
}
- else if (nPos < rTNd.GetText().getLength())
- ++(*pIdx);
+
+ if( 1 == nDone )
+ *pIdx = nPos;
else
bRet = false;
}
@@ -1233,33 +1227,27 @@ bool SwContentNode::GoPrevious(SwIndex * pIdx, sal_uInt16 nMode ) const
{
const SwTextNode& rTNd = *GetTextNode();
sal_Int32 nPos = pIdx->GetIndex();
- if( g_pBreakIt->GetBreakIter().is() )
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ sal_Int32 nDone = 0;
+ sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ?
+ CharacterIteratorMode::SKIPCELL :
+ CharacterIteratorMode::SKIPCONTROLCHARACTER;
+ nPos = g_pBreakIt->GetBreakIter()->previousCharacters( rTNd.GetText(), nPos,
+ g_pBreakIt->GetLocale( rTNd.GetLang( nPos ) ),
+ nItrMode, 1, nDone );
+
+ // Check if nPos is inside hidden text range:
+ if ( CRSR_SKIP_HIDDEN & nMode )
{
- sal_Int32 nDone = 0;
- sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ?
- CharacterIteratorMode::SKIPCELL :
- CharacterIteratorMode::SKIPCONTROLCHARACTER;
- nPos = g_pBreakIt->GetBreakIter()->previousCharacters( rTNd.GetText(), nPos,
- g_pBreakIt->GetLocale( rTNd.GetLang( nPos ) ),
- nItrMode, 1, nDone );
-
- // Check if nPos is inside hidden text range:
- if ( CRSR_SKIP_HIDDEN & nMode )
- {
- sal_Int32 nHiddenStart;
- sal_Int32 nHiddenEnd;
- SwScriptInfo::GetBoundsOfHiddenRange( rTNd, nPos, nHiddenStart, nHiddenEnd );
- if ( nHiddenStart != COMPLETE_STRING )
- nPos = nHiddenStart;
- }
-
- if( 1 == nDone )
- *pIdx = nPos;
- else
- bRet = false;
+ sal_Int32 nHiddenStart;
+ sal_Int32 nHiddenEnd;
+ SwScriptInfo::GetBoundsOfHiddenRange( rTNd, nPos, nHiddenStart, nHiddenEnd );
+ if ( nHiddenStart != COMPLETE_STRING )
+ nPos = nHiddenStart;
}
- else if( nPos )
- --(*pIdx);
+
+ if( 1 == nDone )
+ *pIdx = nPos;
else
bRet = false;
}
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 9b181e84ff4b..1111ffaf62a4 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -677,7 +677,7 @@ SvtScriptType SwEditShell::GetScriptType() const
nRet |= lcl_SetScriptFlags( nScript );
}
}
- else if ( g_pBreakIt->GetBreakIter().is() )
+ else
{
sal_uLong nEndIdx = pEnd->nNode.GetIndex();
SwNodeIndex aIdx( pStt->nNode );
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index 3a6aa4abbc59..066d45a5a2fa 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -266,7 +266,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
nBreakStart = nCutPos;
}
- else if( g_pBreakIt->GetBreakIter().is() )
+ else
{
// New: We should have a look into the last portion, if it was a
// field portion. For this, we expand the text of the field portion
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 55fbbadeb126..1c8ef5182e9b 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -361,32 +361,19 @@ static bool lcl_MinMaxString( SwMinMaxArgs& rArg, SwFont* pFnt, const OUString &
sal_Int32 nStop = nIdx;
bool bClear = false;
LanguageType eLang = pFnt->GetLanguage();
- if( g_pBreakIt->GetBreakIter().is() )
- {
- bClear = CH_BLANK == rText[ nStop ];
- Boundary aBndry( g_pBreakIt->GetBreakIter()->getWordBoundary( rText, nIdx,
- g_pBreakIt->GetLocale( eLang ),
- WordType::DICTIONARY_WORD, true ) );
- nStop = aBndry.endPos;
- if( nIdx <= aBndry.startPos && nIdx && nIdx-1 != rArg.nNoLineBreak )
- rArg.NewWord();
- if( nStop == nIdx )
- ++nStop;
- if( nStop > nEnd )
- nStop = nEnd;
- }
- else
- {
- while( nStop < nEnd && CH_BLANK != rText[ nStop ] )
- ++nStop;
- bClear = nStop == nIdx;
- if ( bClear )
- {
- rArg.NewWord();
- while( nStop < nEnd && CH_BLANK == rText[ nStop ] )
- ++nStop;
- }
- }
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+
+ bClear = CH_BLANK == rText[ nStop ];
+ Boundary aBndry( g_pBreakIt->GetBreakIter()->getWordBoundary( rText, nIdx,
+ g_pBreakIt->GetLocale( eLang ),
+ WordType::DICTIONARY_WORD, true ) );
+ nStop = aBndry.endPos;
+ if( nIdx <= aBndry.startPos && nIdx && nIdx-1 != rArg.nNoLineBreak )
+ rArg.NewWord();
+ if( nStop == nIdx )
+ ++nStop;
+ if( nStop > nEnd )
+ nStop = nEnd;
SwDrawTextInfo aDrawInf( rArg.pSh, *rArg.pOut, nullptr, rText, nIdx, nStop - nIdx );
long nAktWidth = pFnt->GetTextSize_( aDrawInf ).Width();
@@ -807,8 +794,7 @@ sal_uInt16 SwTextNode::GetScalingOfSelectedText( sal_Int32 nStt, sal_Int32 nEnd
if ( nStt == nEnd )
{
- if ( !g_pBreakIt->GetBreakIter().is() )
- return 100;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
SwScriptInfo aScriptInfo;
SwAttrIter aIter( *const_cast<SwTextNode*>(this), aScriptInfo );
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 1a7a3bf402b6..3821625a238e 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -194,7 +194,7 @@ SwFieldSlot::~SwFieldSlot()
void SwFieldPortion::CheckScript( const SwTextSizeInfo &rInf )
{
OUString aText;
- if( GetExpText( rInf, aText ) && !aText.isEmpty() && g_pBreakIt->GetBreakIter().is() )
+ if (GetExpText(rInf, aText) && !aText.isEmpty())
{
SwFontScript nActual = pFnt ? pFnt->GetActual() : rInf.GetFont()->GetActual();
sal_uInt16 nScript = g_pBreakIt->GetBreakIter()->getScriptType( aText, 0 );
@@ -1074,24 +1074,19 @@ SwCombinedPortion::SwCombinedPortion( const OUString &rText )
// Initialization of the scripttype array,
// the arrays of width and position are filled by the format function
- if( g_pBreakIt->GetBreakIter().is() )
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+
+ SwFontScript nScr = SW_SCRIPTS;
+ for( sal_Int32 i = 0; i < rText.getLength(); ++i )
{
- SwFontScript nScr = SW_SCRIPTS;
- for( sal_Int32 i = 0; i < rText.getLength(); ++i )
- {
- switch ( g_pBreakIt->GetBreakIter()->getScriptType( rText, i ) ) {
- case i18n::ScriptType::LATIN : nScr = SwFontScript::Latin; break;
- case i18n::ScriptType::ASIAN : nScr = SwFontScript::CJK; break;
- case i18n::ScriptType::COMPLEX : nScr = SwFontScript::CTL; break;
- }
- aScrType[i] = nScr;
+ switch ( g_pBreakIt->GetBreakIter()->getScriptType( rText, i ) ) {
+ case i18n::ScriptType::LATIN : nScr = SwFontScript::Latin; break;
+ case i18n::ScriptType::ASIAN : nScr = SwFontScript::CJK; break;
+ case i18n::ScriptType::COMPLEX : nScr = SwFontScript::CTL; break;
}
+ aScrType[i] = nScr;
}
- else
- {
- for(SwFontScript & rn : aScrType)
- rn = SwFontScript::Latin;
- }
+
memset( &aWidth, 0, sizeof(aWidth) );
}
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index b1bc88582d67..53ef42eb8992 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -698,8 +698,7 @@ void SwScriptInfo::InitScriptInfo( const SwTextNode& rNode )
void SwScriptInfo::InitScriptInfo( const SwTextNode& rNode, bool bRTL )
{
- if( !g_pBreakIt->GetBreakIter().is() )
- return;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
const OUString& rText = rNode.GetText();
@@ -2215,7 +2214,7 @@ void SwScriptInfo::CalcHiddenRanges( const SwTextNode& rNode, MultiSelection& rH
sal_Int32 SwScriptInfo::CountCJKCharacters( const OUString &rText, sal_Int32 nPos, sal_Int32 nEnd, LanguageType aLang)
{
sal_Int32 nCount = 0;
- if ( nEnd > nPos && g_pBreakIt->GetBreakIter().is() )
+ if (nEnd > nPos)
{
sal_Int32 nDone = 0;
const lang::Locale &rLocale = g_pBreakIt->GetLocale( aLang );
@@ -2239,7 +2238,7 @@ void SwScriptInfo::CJKJustify( const OUString& rText, long* pKernArray,
long nSpaceAdd, bool bIsSpaceStop )
{
assert( pKernArray != nullptr && nStt >= 0 );
- if ( nLen > 0 && g_pBreakIt->GetBreakIter().is() )
+ if (nLen > 0)
{
long nSpaceSum = 0;
const lang::Locale &rLocale = g_pBreakIt->GetLocale( aLang );
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index cd508425cb94..bcdd4772cd31 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -75,7 +75,7 @@ static sal_Int32 lcl_AddSpace( const SwTextSizeInfo &rInf, const OUString* pStr,
// first we get the script type
if ( pSI )
nScript = pSI->ScriptType( nPos );
- else if ( g_pBreakIt->GetBreakIter().is() )
+ else
nScript = (sal_uInt8)g_pBreakIt->GetBreakIter()->getScriptType( *pStr, nPos );
// Note: rInf.GetIdx() can differ from nPos,
@@ -177,7 +177,7 @@ static sal_Int32 lcl_AddSpace( const SwTextSizeInfo &rInf, const OUString* pStr,
if ( pPor && pPor->IsKernPortion() )
pPor = pPor->GetPortion();
- if ( ! g_pBreakIt->GetBreakIter().is() || ! pPor || pPor->InFixMargGrp() )
+ if (!pPor || pPor->InFixMargGrp())
return nCnt;
// next character is inside a field?
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index ef9915ad4b6e..d5b5edc77e95 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -89,41 +89,35 @@ void SwAttrIter::CtorInitAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf,
if ( m_pScriptInfo->GetInvalidityA() != COMPLETE_STRING )
m_pScriptInfo->InitScriptInfo( rTextNode, bRTL );
- if ( g_pBreakIt->GetBreakIter().is() )
- {
- m_pFont->SetActual( SwScriptInfo::WhichFont( 0, nullptr, m_pScriptInfo ) );
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
- sal_Int32 nChg = 0;
- size_t nCnt = 0;
+ m_pFont->SetActual( SwScriptInfo::WhichFont( 0, nullptr, m_pScriptInfo ) );
- do
- {
- if ( nCnt >= m_pScriptInfo->CountScriptChg() )
- break;
- nChg = m_pScriptInfo->GetScriptChg( nCnt );
- SwFontScript nTmp = SW_SCRIPTS;
- switch ( m_pScriptInfo->GetScriptType( nCnt++ ) ) {
- case i18n::ScriptType::ASIAN :
- if( !m_aMagicNo[SwFontScript::CJK] ) nTmp = SwFontScript::CJK;
- break;
- case i18n::ScriptType::COMPLEX :
- if( !m_aMagicNo[SwFontScript::CTL] ) nTmp = SwFontScript::CTL;
- break;
- default:
- if( !m_aMagicNo[SwFontScript::Latin ] ) nTmp = SwFontScript::Latin;
- }
- if( nTmp < SW_SCRIPTS )
- {
- m_pFont->ChkMagic( m_pViewShell, nTmp );
- m_pFont->GetMagic( m_aMagicNo[ nTmp ], m_aFontIdx[ nTmp ], nTmp );
- }
- } while (nChg < rTextNode.GetText().getLength());
- }
- else
+ sal_Int32 nChg = 0;
+ size_t nCnt = 0;
+
+ do
{
- m_pFont->ChkMagic( m_pViewShell, SwFontScript::Latin );
- m_pFont->GetMagic( m_aMagicNo[ SwFontScript::Latin ], m_aFontIdx[ SwFontScript::Latin ], SwFontScript::Latin );
- }
+ if ( nCnt >= m_pScriptInfo->CountScriptChg() )
+ break;
+ nChg = m_pScriptInfo->GetScriptChg( nCnt );
+ SwFontScript nTmp = SW_SCRIPTS;
+ switch ( m_pScriptInfo->GetScriptType( nCnt++ ) ) {
+ case i18n::ScriptType::ASIAN :
+ if( !m_aMagicNo[SwFontScript::CJK] ) nTmp = SwFontScript::CJK;
+ break;
+ case i18n::ScriptType::COMPLEX :
+ if( !m_aMagicNo[SwFontScript::CTL] ) nTmp = SwFontScript::CTL;
+ break;
+ default:
+ if( !m_aMagicNo[SwFontScript::Latin ] ) nTmp = SwFontScript::Latin;
+ }
+ if( nTmp < SW_SCRIPTS )
+ {
+ m_pFont->ChkMagic( m_pViewShell, nTmp );
+ m_pFont->GetMagic( m_aMagicNo[ nTmp ], m_aFontIdx[ nTmp ], nTmp );
+ }
+ } while (nChg < rTextNode.GetText().getLength());
m_nStartIndex = m_nEndIndex = m_nPosition = m_nChgCnt = 0;
m_nPropFont = 0;
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index 157bfeef6719..be96cbc6bf81 100644
--- a/sw/source/core/text/txtdrop.cxx
+++ b/sw/source/core/text/txtdrop.cxx
@@ -127,7 +127,7 @@ sal_Int32 SwTextNode::GetDropLen( sal_Int32 nWishLen ) const
if( nWishLen && nWishLen < nEnd )
nEnd = nWishLen;
- if ( ! nWishLen && g_pBreakIt->GetBreakIter().is() )
+ if (! nWishLen)
{
// find first word
const SwAttrSet& rAttrSet = GetSwAttrSet();
diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx
index 6b5bd8470648..01940c21f79d 100644
--- a/sw/source/core/text/txthyph.cxx
+++ b/sw/source/core/text/txthyph.cxx
@@ -60,8 +60,7 @@ bool SwTextFrame::Hyphenate( SwInterHyphInfo &rHyphInf )
vcl::RenderContext* pRenderContext = getRootFrame()->GetCurrShell()->GetOut();
OSL_ENSURE( ! IsVertical() || ! IsSwapped(),"swapped frame at SwTextFrame::Hyphenate" );
- if( !g_pBreakIt->GetBreakIter().is() )
- return false;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
// We lock it, to start with
OSL_ENSURE( !IsLocked(), "SwTextFrame::Hyphenate: this is locked" );
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 44518377975f..03c201afb29e 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -2134,19 +2134,13 @@ sal_Int32 SwFntObj::GetCursorOfst( SwDrawTextInfo &rInf )
}
sal_Int32 nDone = 0;
- LanguageType aLang = LANGUAGE_NONE;
- bool bSkipCharacterCells = false;
sal_Int32 nIdx = rInf.GetIdx();
sal_Int32 nLastIdx = nIdx;
const sal_Int32 nEnd = rInf.GetIdx() + rInf.GetLen();
// #i105901#
// skip character cells for all script types
- if ( g_pBreakIt->GetBreakIter().is() )
- {
- aLang = rInf.GetFont()->GetLanguage();
- bSkipCharacterCells = true;
- }
+ LanguageType aLang = rInf.GetFont()->GetLanguage();
while ( ( nRight < long( rInf.GetOfst() ) ) && ( nIdx < nEnd ) )
{
@@ -2156,16 +2150,11 @@ sal_Int32 SwFntObj::GetCursorOfst( SwDrawTextInfo &rInf )
// go to next character (cell).
nLastIdx = nIdx;
- if ( bSkipCharacterCells )
- {
- nIdx = g_pBreakIt->GetBreakIter()->nextCharacters( rInf.GetText(),
- nIdx, g_pBreakIt->GetLocale( aLang ),
- i18n::CharacterIteratorMode::SKIPCELL, 1, nDone );
- if ( nIdx <= nLastIdx )
- break;
- }
- else
- ++nIdx;
+ nIdx = g_pBreakIt->GetBreakIter()->nextCharacters( rInf.GetText(),
+ nIdx, g_pBreakIt->GetLocale( aLang ),
+ i18n::CharacterIteratorMode::SKIPCELL, 1, nDone );
+ if ( nIdx <= nLastIdx )
+ break;
nLeft = nRight;
nRight = pKernArray[ nIdx - rInf.GetIdx() - 1 ] + nKernSum + nSpaceSum;
@@ -2398,8 +2387,7 @@ sal_Int32 SwFont::GetTextBreak( SwDrawTextInfo& rInf, long nTextWidth )
{
const OUString aSnippet(rInf.GetText().copy(rInf.GetIdx(), nLn));
aTmpText = m_aSub[m_nActual].CalcCaseMap( aSnippet );
- const bool bTitle = SvxCaseMap::Capitalize == m_aSub[m_nActual].GetCaseMap() &&
- g_pBreakIt->GetBreakIter().is();
+ const bool bTitle = SvxCaseMap::Capitalize == m_aSub[m_nActual].GetCaseMap();
// Uaaaaahhhh!!! In title case mode, we would get wrong results
if ( bTitle && nLn )
diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx
index 4713bfc61119..2965b496e2d2 100644
--- a/sw/source/core/txtnode/fntcap.cxx
+++ b/sw/source/core/txtnode/fntcap.cxx
@@ -66,8 +66,7 @@ sal_Int32 sw_CalcCaseMap( const SwFont& rFnt,
OSL_ENSURE( nEnd <= rOrigString.getLength(), "sw_CalcCaseMap: Wrong parameters" );
// special case for title case:
- const bool bTitle = SvxCaseMap::Capitalize == rFnt.GetCaseMap() &&
- g_pBreakIt->GetBreakIter().is();
+ const bool bTitle = SvxCaseMap::Capitalize == rFnt.GetCaseMap();
for ( sal_Int32 i = nOfst; i < nEnd; ++i )
{
OUString aTmp(rOrigString.copy(i, 1));
diff --git a/sw/source/core/txtnode/txatritr.cxx b/sw/source/core/txtnode/txatritr.cxx
index 9048fde21b2a..a977fc3df73c 100644
--- a/sw/source/core/txtnode/txatritr.cxx
+++ b/sw/source/core/txtnode/txatritr.cxx
@@ -35,61 +35,55 @@ SwScriptIterator::SwScriptIterator(
, nCurScript(i18n::ScriptType::WEAK)
, bForward(bFrwrd)
{
- if( g_pBreakIt->GetBreakIter().is() )
- {
- if ( ! bFrwrd && nStt )
- --nStt;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ if ( ! bFrwrd && nStt )
+ --nStt;
- sal_Int32 nPos = nStt;
- nCurScript = g_pBreakIt->GetBreakIter()->getScriptType(m_rText, nPos);
- if( i18n::ScriptType::WEAK == nCurScript )
+ sal_Int32 nPos = nStt;
+ nCurScript = g_pBreakIt->GetBreakIter()->getScriptType(m_rText, nPos);
+ if( i18n::ScriptType::WEAK == nCurScript )
+ {
+ if( nPos )
{
- if( nPos )
+ nPos = g_pBreakIt->GetBreakIter()->beginOfScript(
+ m_rText, nPos, nCurScript);
+ if (nPos > 0 && nPos < m_rText.getLength())
{
- nPos = g_pBreakIt->GetBreakIter()->beginOfScript(
- m_rText, nPos, nCurScript);
- if (nPos > 0 && nPos < m_rText.getLength())
- {
- nStt = --nPos;
- nCurScript =
- g_pBreakIt->GetBreakIter()->getScriptType(m_rText,nPos);
- }
+ nStt = --nPos;
+ nCurScript =
+ g_pBreakIt->GetBreakIter()->getScriptType(m_rText,nPos);
}
}
-
- m_nChgPos = (bForward)
- ? g_pBreakIt->GetBreakIter()->endOfScript(
- m_rText, nStt, nCurScript)
- : g_pBreakIt->GetBreakIter()->beginOfScript(
- m_rText, nStt, nCurScript);
}
+
+ m_nChgPos = (bForward)
+ ? g_pBreakIt->GetBreakIter()->endOfScript(
+ m_rText, nStt, nCurScript)
+ : g_pBreakIt->GetBreakIter()->beginOfScript(
+ m_rText, nStt, nCurScript);
}
bool SwScriptIterator::Next()
{
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
bool bRet = false;
- if( g_pBreakIt->GetBreakIter().is() )
+ if (bForward && m_nChgPos >= 0 && m_nChgPos < m_rText.getLength())
{
- if (bForward && m_nChgPos >= 0 && m_nChgPos < m_rText.getLength())
- {
- nCurScript =
- g_pBreakIt->GetBreakIter()->getScriptType(m_rText, m_nChgPos);
- m_nChgPos = g_pBreakIt->GetBreakIter()->endOfScript(
+ nCurScript =
+ g_pBreakIt->GetBreakIter()->getScriptType(m_rText, m_nChgPos);
+ m_nChgPos = g_pBreakIt->GetBreakIter()->endOfScript(
+ m_rText, m_nChgPos, nCurScript);
+ bRet = true;
+ }
+ else if (!bForward && m_nChgPos > 0)
+ {
+ --m_nChgPos;
+ nCurScript =
+ g_pBreakIt->GetBreakIter()->getScriptType(m_rText, m_nChgPos);
+ m_nChgPos = g_pBreakIt->GetBreakIter()->beginOfScript(
m_rText, m_nChgPos, nCurScript);
- bRet = true;
- }
- else if (!bForward && m_nChgPos > 0)
- {
- --m_nChgPos;
- nCurScript =
- g_pBreakIt->GetBreakIter()->getScriptType(m_rText, m_nChgPos);
- m_nChgPos = g_pBreakIt->GetBreakIter()->beginOfScript(
- m_rText, m_nChgPos, nCurScript);
- bRet = true;
- }
+ bRet = true;
}
- else
- m_nChgPos = m_rText.getLength();
return bRet;
}
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 5b5e44713adb..f509ffea7c54 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -699,26 +699,23 @@ OUString SwTextNode::GetCurWord( sal_Int32 nPos ) const
if (m_Text.isEmpty())
return m_Text;
- Boundary aBndry;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
const uno::Reference< XBreakIterator > &rxBreak = g_pBreakIt->GetBreakIter();
- if (rxBreak.is())
- {
- sal_Int16 nWordType = WordType::DICTIONARY_WORD;
- lang::Locale aLocale( g_pBreakIt->GetLocale( GetLang( nPos ) ) );
+ sal_Int16 nWordType = WordType::DICTIONARY_WORD;
+ lang::Locale aLocale( g_pBreakIt->GetLocale( GetLang( nPos ) ) );
#if OSL_DEBUG_LEVEL > 1
- sal_Bool bBegin = rxBreak->isBeginWord( m_Text, nPos, aLocale, nWordType );
- sal_Bool bEnd = rxBreak->isEndWord ( m_Text, nPos, aLocale, nWordType );
- (void)bBegin;
- (void)bEnd;
+ sal_Bool bBegin = rxBreak->isBeginWord( m_Text, nPos, aLocale, nWordType );
+ sal_Bool bEnd = rxBreak->isEndWord ( m_Text, nPos, aLocale, nWordType );
+ (void)bBegin;
+ (void)bEnd;
#endif
- aBndry =
- rxBreak->getWordBoundary( m_Text, nPos, aLocale, nWordType, true );
+ Boundary aBndry =
+ rxBreak->getWordBoundary( m_Text, nPos, aLocale, nWordType, true );
- // if no word was found use previous word (if any)
- if (aBndry.startPos == aBndry.endPos)
- {
- aBndry = rxBreak->previousWord( m_Text, nPos, aLocale, nWordType );
- }
+ // if no word was found use previous word (if any)
+ if (aBndry.startPos == aBndry.endPos)
+ {
+ aBndry = rxBreak->previousWord( m_Text, nPos, aLocale, nWordType );
}
// check if word was found and if it uses a symbol font, if so
@@ -1679,7 +1676,7 @@ void SwTextNode::TransliterateText(
sal_Int32 nStt, sal_Int32 nEnd,
SwUndoTransliterate* pUndo )
{
- if (nStt < nEnd && g_pBreakIt->GetBreakIter().is())
+ if (nStt < nEnd)
{
// since we don't use Hiragana/Katakana or half-width/full-width transliterations here
// it is fine to use ANYWORD_IGNOREWHITESPACES. (ANY_WORD btw is broken and will
@@ -2049,30 +2046,29 @@ bool SwTextNode::CountWords( SwDocStat& rStat,
// count words in masked and expanded text:
if (!aExpandText.isEmpty())
{
- if (g_pBreakIt->GetBreakIter().is())
- {
- // zero is NULL for pLanguage -----------v last param = true for clipping
- SwScanner aScanner( *this, aExpandText, nullptr, aConversionMap, i18n::WordType::WORD_COUNT,
- nExpandBegin, nExpandEnd, true );
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+
+ // zero is NULL for pLanguage -----------v last param = true for clipping
+ SwScanner aScanner( *this, aExpandText, nullptr, aConversionMap, i18n::WordType::WORD_COUNT,
+ nExpandBegin, nExpandEnd, true );
- // used to filter out scanner returning almost empty strings (len=1; unichar=0x0001)
- const OUString aBreakWord( CH_TXTATR_BREAKWORD );
+ // used to filter out scanner returning almost empty strings (len=1; unichar=0x0001)
+ const OUString aBreakWord( CH_TXTATR_BREAKWORD );
- while ( aScanner.NextWord() )
+ while ( aScanner.NextWord() )
+ {
+ if( !aExpandText.match(aBreakWord, aScanner.GetBegin() ))
{
- if( !aExpandText.match(aBreakWord, aScanner.GetBegin() ))
- {
- ++nTmpWords;
- const OUString &rWord = aScanner.GetWord();
- if (g_pBreakIt->GetBreakIter()->getScriptType(rWord, 0) == i18n::ScriptType::ASIAN)
- ++nTmpAsianWords;
- nTmpCharsExcludingSpaces += g_pBreakIt->getGraphemeCount(rWord);
- }
+ ++nTmpWords;
+ const OUString &rWord = aScanner.GetWord();
+ if (g_pBreakIt->GetBreakIter()->getScriptType(rWord, 0) == i18n::ScriptType::ASIAN)
+ ++nTmpAsianWords;
+ nTmpCharsExcludingSpaces += g_pBreakIt->getGraphemeCount(rWord);
}
-
- nTmpCharsExcludingSpaces += aScanner.getOverriddenDashCount();
}
+ nTmpCharsExcludingSpaces += aScanner.getOverriddenDashCount();
+
nTmpChars = g_pBreakIt->getGraphemeCount(aExpandText, nExpandBegin, nExpandEnd);
}
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 6385c73d009c..bb9bc38329d4 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -472,11 +472,8 @@ void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/,
other, so we make a guess based upon the first character of the text,
defaulting to asian.
*/
- sal_uInt16 nRubyScript;
- if (g_pBreakIt->GetBreakIter().is())
- nRubyScript = g_pBreakIt->GetBreakIter()->getScriptType(rRuby.GetText(), 0);
- else
- nRubyScript = i18n::ScriptType::ASIAN;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ sal_uInt16 nRubyScript = g_pBreakIt->GetBreakIter()->getScriptType(rRuby.GetText(), 0);
const SwTextRuby* pRubyText = rRuby.GetTextRuby();
const SwCharFormat* pFormat = pRubyText ? pRubyText->GetCharFormat() : nullptr;
@@ -516,7 +513,7 @@ void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/,
}
aStr += "(\\s\\up ";
- if (g_pBreakIt->GetBreakIter().is() && pRubyText)
+ if (pRubyText)
nRubyScript = g_pBreakIt->GetBreakIter()->getScriptType(rNode.GetText(),
pRubyText->GetStart());
else
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 4cea33ce6ed0..a2a6aa29c454 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -533,7 +533,8 @@ namespace sw
using namespace ::com::sun::star::i18n;
sal_uInt16 nScript = i18n::ScriptType::LATIN;
- if (!rText.isEmpty() && g_pBreakIt && g_pBreakIt->GetBreakIter().is())
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ if (!rText.isEmpty())
nScript = g_pBreakIt->GetBreakIter()->getScriptType(rText, 0);
rtl_TextEncoding eChrSet = ItemGet<SvxFontItem>(rTextNd,
@@ -591,21 +592,19 @@ namespace sw
}
ubidi_close(pBidi);
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
- if (g_pBreakIt && g_pBreakIt->GetBreakIter().is())
+ sal_Int32 nLen = rText.getLength();
+ sal_Int32 nPos = 0;
+ while (nPos < nLen)
{
- sal_Int32 nLen = rText.getLength();
- sal_Int32 nPos = 0;
- while (nPos < nLen)
- {
- sal_Int32 nEnd2 = g_pBreakIt->GetBreakIter()->endOfScript(rText, nPos,
- nScript);
- if (nEnd2 < 0)
- break;
- nPos = nEnd2;
- aScripts.push_back(ScriptEntry(nPos, nScript));
- nScript = g_pBreakIt->GetBreakIter()->getScriptType(rText, nPos);
- }
+ sal_Int32 nEnd2 = g_pBreakIt->GetBreakIter()->endOfScript(rText, nPos,
+ nScript);
+ if (nEnd2 < 0)
+ break;
+ nPos = nEnd2;
+ aScripts.push_back(ScriptEntry(nPos, nScript));
+ nScript = g_pBreakIt->GetBreakIter()->getScriptType(rText, nPos);
}
cDirIter aBiDiEnd = aDirChanges.end();
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 0e1ebe84c0e2..8bf4fc9eac0d 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1086,10 +1086,8 @@ void MSWord_SdrAttrIter::NextPara( sal_Int32 nPar )
pEditPool = aSet.GetPool();
eNdChrSet = ItemGet<SvxFontItem>(aSet,EE_CHAR_FONTINFO).GetCharSet();
- if( g_pBreakIt->GetBreakIter().is() )
- nScript = g_pBreakIt->GetBreakIter()->getScriptType( pEditObj->GetText(nPara), 0);
- else
- nScript = i18n::ScriptType::LATIN;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ nScript = g_pBreakIt->GetBreakIter()->getScriptType( pEditObj->GetText(nPara), 0);
pEditObj->GetCharAttribs( nPara, aTextAtrArr );
nAktSwPos = SearchNext( 1 );
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 6c83fae8a43d..d931cb8fab5f 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -805,11 +805,8 @@ void WW8AttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 /*nPos*/,
other, so we make a guess based upon the first character of the text,
defaulting to asian.
*/
- sal_uInt16 nRubyScript;
- if( g_pBreakIt->GetBreakIter().is() )
- nRubyScript = g_pBreakIt->GetBreakIter()->getScriptType( rRuby.GetText(), 0);
- else
- nRubyScript = i18n::ScriptType::ASIAN;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ sal_uInt16 nRubyScript = g_pBreakIt->GetBreakIter()->getScriptType( rRuby.GetText(), 0);
const SwTextRuby* pRubyText = rRuby.GetTextRuby();
const SwCharFormat* pFormat = pRubyText ? pRubyText->GetCharFormat() : nullptr;
@@ -853,11 +850,9 @@ void WW8AttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 /*nPos*/,
}
aStr += "(\\s\\up ";
- if ( g_pBreakIt->GetBreakIter().is() )
- nRubyScript = g_pBreakIt->GetBreakIter()->getScriptType( rNode.GetText(),
- pRubyText->GetStart() );
- else
- nRubyScript = i18n::ScriptType::ASIAN;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ nRubyScript = g_pBreakIt->GetBreakIter()->getScriptType( rNode.GetText(),
+ pRubyText->GetStart() );
const SwAttrSet& rSet = rNode.GetSwAttrSet();
const SvxFontHeightItem &rHeightItem =
@@ -1652,9 +1647,8 @@ OUString SwWW8AttrIter::GetSnippet(const OUString &rStr, sal_Int32 nAktPos,
if (SvxCaseMap::Capitalize == static_cast<const SvxCaseMapItem&>(rItem).GetValue())
{
- sal_uInt16 nScriptType = i18n::ScriptType::LATIN;
- if (g_pBreakIt->GetBreakIter().is())
- nScriptType = g_pBreakIt->GetBreakIter()->getScriptType(aSnippet, 0);
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ sal_uInt16 nScriptType = g_pBreakIt->GetBreakIter()->getScriptType(aSnippet, 0);
LanguageType nLanguage;
switch (nScriptType)
@@ -1679,7 +1673,7 @@ OUString SwWW8AttrIter::GetSnippet(const OUString &rStr, sal_Int32 nAktPos,
//If we weren't at the begin of a word undo the case change.
//not done before doing the casemap because the sequence might start
//with whitespace
- if (g_pBreakIt->GetBreakIter().is() && !g_pBreakIt->GetBreakIter()->isBeginWord(
+ if (!g_pBreakIt->GetBreakIter()->isBeginWord(
rStr, nAktPos, g_pBreakIt->GetLocale(nLanguage),
i18n::WordType::ANYWORD_IGNOREWHITESPACES ) )
{
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 92f2affe9db0..4c46be68f905 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2828,11 +2828,8 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
asian or western text based up on the first character and use the
font size of that script as our default.
*/
- sal_uInt16 nScript;
- if( g_pBreakIt->GetBreakIter().is() )
- nScript = g_pBreakIt->GetBreakIter()->getScriptType( pField->GetPar1(), 0);
- else
- nScript = i18n::ScriptType::ASIAN;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ sal_uInt16 nScript = g_pBreakIt->GetBreakIter()->getScriptType( pField->GetPar1(), 0);
long nHeight = static_cast<const SvxFontHeightItem&>((GetExport().GetItem(
GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript)))).GetHeight();
@@ -4313,11 +4310,7 @@ void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing )
{
const SwTextNode* pNd = static_cast<const SwTextNode*>(GetExport().m_pOutFormatNode);
pSet = &pNd->GetSwAttrSet();
- if ( g_pBreakIt->GetBreakIter().is() )
- {
- nScript = g_pBreakIt->GetBreakIter()->
- getScriptType(pNd->GetText(), 0);
- }
+ nScript = g_pBreakIt->GetBreakIter()->getScriptType(pNd->GetText(), 0);
}
OSL_ENSURE( pSet, "No attrset for lineheight :-(" );
if ( pSet )
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 2a52276d6359..fdd95eeb040f 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3195,11 +3195,7 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const OUString& rAddString
return;
uno::Reference<i18n::XBreakIterator> xBI(g_pBreakIt->GetBreakIter());
- if (!xBI.is())
- {
- simpleAddTextToParagraph(rAddString);
- return;
- }
+ assert(xBI.is());
sal_Int16 nScript = lcl_getScriptType(xBI, rAddString, 0);
sal_Int32 nLen = rAddString.getLength();
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 3c254f99dc71..01dbc987c4fa 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -2704,11 +2704,8 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam)
SwFormatRuby aRuby(sRuby);
const SwCharFormat *pCharFormat=nullptr;
//Make a guess at which of asian of western we should be setting
- sal_uInt16 nScript;
- if (g_pBreakIt->GetBreakIter().is())
- nScript = g_pBreakIt->GetBreakIter()->getScriptType(sRuby, 0);
- else
- nScript = i18n::ScriptType::ASIAN;
+ assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
+ sal_uInt16 nScript = g_pBreakIt->GetBreakIter()->getScriptType(sRuby, 0);
//Check to see if we already have a ruby charstyle that this fits
std::vector<const SwCharFormat*>::const_iterator aEnd =
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 017c719c81f7..355629a7f051 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -748,15 +748,13 @@ bool SwEditWin::IsInputSequenceCheckingRequired( const OUString &rText, const Sw
SwBreakIt *pBreakIter = SwBreakIt::Get();
uno::Reference < i18n::XBreakIterator > xBI = pBreakIter->GetBreakIter();
+ assert(xBI.is());
long nCTLScriptPos = -1;
- if (xBI.is())
- {
- if (xBI->getScriptType( rText, 0 ) == i18n::ScriptType::COMPLEX)
- nCTLScriptPos = 0;
- else
- nCTLScriptPos = xBI->nextScript( rText, 0, i18n::ScriptType::COMPLEX );
- }
+ if (xBI->getScriptType( rText, 0 ) == i18n::ScriptType::COMPLEX)
+ nCTLScriptPos = 0;
+ else
+ nCTLScriptPos = xBI->nextScript( rText, 0, i18n::ScriptType::COMPLEX );
return (0 <= nCTLScriptPos && nCTLScriptPos <= rText.getLength());
}