[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide' - 664 commits - accessibility/inc accessibility/source basctl/source basegfx/source basic/qa basic/source bin/check-elf-dynamic-objects bin/gbuild-to-ide bridges/source chart2/qa chart2/source compilerplugins/clang config_host/config_features.h.in config_host/config_firebird.h.in config_host/config_java.h.in config_host/config_libnumbertext.h.in config_host.mk.in configmgr/source configure.ac connectivity/source cppu/source cui/inc cui/source cui/uiconfig dbaccess/CppunitTest_dbaccess_hsqldb_test.mk dbaccess/CppunitTest_dbaccess_RowSetClones.mk dbaccess/Library_dba.mk dbaccess/Library_dbu.mk dbaccess/source desktop/Package_branding.mk desktop/source desktop/unx dictionaries distro-configs/LibreOfficeVanillaMacAppStore.conf download.lst drawinglayer/source dtrans/source editeng/inc editeng/qa editeng/source embeddedobj/source extensions/Library_ldapbe2.mk extensions/Library_WinUserInfoBe.mk extensions/Module_extensions.mk extensio ns/source external/boost external/curl external/epoxy external/libassuan external/libcmis external/libepubgen external/libgpg-error external/libnumbertext external/libstaroffice external/libtommath external/libwps external/mdds external/Module_external.mk external/more_fonts external/xmlsec extras/source filter/Configuration_filter.mk filter/qa filter/source forms/source formula/source fpicker/source framework/inc framework/source helpcontent2 i18nlangtag/source i18npool/inc i18npool/source icon-themes/colibre icon-themes/colibre_svg icon-themes/galaxy icon-themes/README icon-themes/tango include/basegfx include/comphelper include/connectivity include/editeng include/filter include/formula include/i18nlangtag include/o3tl include/sal include/sfx2 include/svl include/svtools include/svx include/test include/tools include/unotools include/vcl include/xmloff instsetoo_native/inc_common instsetoo_native/util l10ntools/source libreofficekit/qa lingucomponent/Library_numbertext.mk linguco mponent/Module_lingucomponent.mk lingucomponent/source lotuswordpro/qa lotuswordpro/source Makefile.fetch Makefile.in mysqlc/Extension_mysql-connector-ooo.mk odk/build-examples_common.mk odk/CustomTarget_build-examples_java.mk odk/CustomTarget_build-examples.mk odk/examples offapi/com offapi/type_reference offapi/UnoApi_offapi.mk officecfg/Configuration_officecfg.mk officecfg/Package_misc.mk officecfg/registry oox/source postprocess/CustomTarget_registry.mk postprocess/Rdb_services.mk qadevOOo/objdsc qadevOOo/runner qadevOOo/tests readlicense_oo/license registry/source reportdesign/inc reportdesign/source RepositoryExternal.mk Repository.mk sal/osl sal/rtl sc/CppunitTest_sc_bugfix_test.mk sc/CppunitTest_sc_chart2dataprovider.mk sc/CppunitTest_sc_copypaste.mk sc/CppunitTest_sc_parallelism.mk sc/CppunitTest_sc_pivottable_filters_test.mk sc/CppunitTest_sc_subsequent_export_test.mk sc/CppunitTest_sc_subsequent_filters_test.mk sc/inc sc/IwyuFilter_sc.yaml scp2/macros scp2/source sc/qa sc ripting/astyle.options scripting/examples scripting/source sc/source sc/uiconfig sc/UIConfig_scalc.mk sd/inc sd/qa sd/source sd/uiconfig sd/UIConfig_sdraw.mk sd/workben setup_native/source sfx2/source slideshow/source solenv/bin solenv/clang-format solenv/flatpak-manifest.in solenv/gbuild solenv/sanitizers starmath/inc starmath/source starmath/uiconfig store/source svl/source svtools/inc svtools/source svx/inc svx/source svx/uiconfig svx/util sw/CppunitTest_sw_apitests.mk sw/CppunitTest_sw_macros_test.mk sw/CppunitTest_sw_odfexport.mk sw/CppunitTest_sw_ooxmlimport2.mk sw/inc sw/IwyuFilter_sw.yaml sw/Module_sw.mk sw/qa sw/source sw/uiconfig sysui/desktop test/inc test/Library_subsequenttest.mk test/Library_test.mk test/source toolkit/inc toolkit/qa toolkit/source tools/CppunitTest_tools_test.mk tools/inc tools/Library_tl.mk tools/qa tools/source uitest/impress_tests uitest/writer_tests unotest/source unotools/source vcl/CppunitTest_vcl_complextext.mk vcl/CppunitTest_vcl_fontmetric.mk vcl/CppunitTest_vcl_graphic_test.mk vcl/Executable_vcldemo.mk vcl/headless vcl/inc vcl/Library_vcl.mk vcl/Library_vclplug_kde4.mk vcl/Library_vclplug_qt5.mk vcl/Module_vcl.mk vcl/opengl vcl/qa vcl/qt5 vcl/quartz vcl/source vcl/uiconfig vcl/unx vcl/win vcl/workben wizards/source writerfilter/source writerperfect/inc writerperfect/qa writerperfect/source xmloff/dtd xmloff/qa xmloff/source xmlscript/source xmlsecurity/Library_xsec_xmlsec.mk xmlsecurity/qa xmlsecurity/source xmlsecurity/util
Michael Stahl
Michael.Stahl at cib.de
Mon May 14 17:16:22 UTC 2018
Rebased ref, commits from common ancestor:
commit c5e066e6c158ed9933adba5abe5d56575df1c4f9
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 17:47:08 2018 +0200
sw_redlinehide: don't need SwAttrIter::m_pFirstNode
Change-Id: Icdadd3d9daa5c0031c044004032723d7108d71ab
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 003b3348e140..52f9dd338edd 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -144,8 +144,9 @@ bool SwAttrIter::IsSymbol(TextFrameIndex const nNewPos)
bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFont )
{
+ SwTextNode const*const pFirstTextNode(m_pMergedPara ? m_pMergedPara->pFirstNode : m_pTextNode);
if ( m_pRedline && m_pRedline->ExtOn() )
- m_pRedline->LeaveExtend(*m_pFont, m_pFirstTextNode->GetIndex(), 0);
+ m_pRedline->LeaveExtend(*m_pFont, pFirstTextNode->GetIndex(), 0);
// reset font to its original state
m_aAttrHandler.Reset();
@@ -161,7 +162,7 @@ bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFo
{
m_pRedline->Clear( m_pFont );
if( !bParaFont )
- m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, m_pFirstTextNode->GetIndex(), 0, COMPLETE_STRING);
+ m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, pFirstTextNode->GetIndex(), 0, COMPLETE_STRING);
else
m_pRedline->Reset();
}
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index d144b72339e9..c518033197d6 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -60,8 +60,6 @@ private:
/// input: the current text node
const SwTextNode* m_pTextNode;
sw::MergedPara const* m_pMergedPara;
- /// the 1st one, for reset
- const SwTextNode* m_pFirstTextNode;
/// from view (text frame) index to current node index
sal_Int32 m_nCurrentIndexOffset;
@@ -87,7 +85,6 @@ protected:
, m_nPropFont(0)
, m_pTextNode(pTextNode)
, m_pMergedPara(nullptr)
- , m_pFirstTextNode(pTextNode)
, m_nCurrentIndexOffset(0)
{
m_aMagicNo[SwFontScript::Latin] = m_aMagicNo[SwFontScript::CJK] = m_aMagicNo[SwFontScript::CTL] = nullptr;
@@ -98,7 +95,6 @@ public:
SwAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf )
: m_pViewShell(nullptr), m_pFont(nullptr), m_pHints(nullptr), m_pScriptInfo(nullptr), m_pLastOut(nullptr), m_nChgCnt(0), m_pRedline(nullptr),m_nPropFont(0), m_pTextNode(&rTextNode)
, m_pMergedPara(nullptr)
- , m_pFirstTextNode(&rTextNode)
, m_nCurrentIndexOffset(0)
// TODO the clients here don't have a para-portion?
{ CtorInitAttrIter( rTextNode, rScrInf ); }
commit dec0783c6b648e4953c2d21f6a78631ca17b3404
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 17:42:39 2018 +0200
sw_redlinehide: add MergedPara member to SwAttrIter
Change-Id: I304c333bb6aaca8933606b662743a1642c655de5
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index 5b80a17b577e..d144b72339e9 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -24,6 +24,7 @@
#include <swfont.hxx>
#include "porlay.hxx"
+namespace sw { struct MergedPara; }
class OutputDevice;
class SwFont;
class SwpHints;
@@ -58,6 +59,7 @@ private:
o3tl::enumarray<SwFontScript, sal_uInt16> m_aFontIdx;
/// input: the current text node
const SwTextNode* m_pTextNode;
+ sw::MergedPara const* m_pMergedPara;
/// the 1st one, for reset
const SwTextNode* m_pFirstTextNode;
/// from view (text frame) index to current node index
@@ -84,6 +86,7 @@ protected:
, m_nPosition(0)
, m_nPropFont(0)
, m_pTextNode(pTextNode)
+ , m_pMergedPara(nullptr)
, m_pFirstTextNode(pTextNode)
, m_nCurrentIndexOffset(0)
{
@@ -94,6 +97,7 @@ public:
// Constructor, destructor
SwAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf )
: m_pViewShell(nullptr), m_pFont(nullptr), m_pHints(nullptr), m_pScriptInfo(nullptr), m_pLastOut(nullptr), m_nChgCnt(0), m_pRedline(nullptr),m_nPropFont(0), m_pTextNode(&rTextNode)
+ , m_pMergedPara(nullptr)
, m_pFirstTextNode(&rTextNode)
, m_nCurrentIndexOffset(0)
// TODO the clients here don't have a para-portion?
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index e024e71cb9c5..a159d403d8f8 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -133,7 +133,6 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// set font to vertical if frame layout is vertical
bool bVertLayout = false;
bool bRTL = false;
- sw::MergedPara const* pMerged(nullptr);
if ( pFrame )
{
if ( pFrame->IsVertical() )
@@ -142,7 +141,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
m_pFont->SetVertical( m_pFont->GetOrientation(), true );
}
bRTL = pFrame->IsRightToLeft();
- pMerged = pFrame->GetMergedPara();
+ m_pMergedPara = pFrame->GetMergedPara();
}
// Initialize the default attribute of the attribute handler
@@ -200,10 +199,10 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// the node. It's not clear whether there can be more than 1 PaM in the
// Ring, and this code doesn't handle that case; neither did the old code.
const SwExtTextInput* pExtInp = pDoc->GetExtTextInput( rTextNode );
- if (!pExtInp && pMerged)
+ if (!pExtInp && m_pMergedPara)
{
SwTextNode const* pNode(&rTextNode);
- for (auto const& rExtent : pMerged->extents)
+ for (auto const& rExtent : m_pMergedPara->extents)
{
if (rExtent.pNode != pNode)
{
@@ -215,16 +214,31 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
}
}
const bool bShow = IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() );
- if (pExtInp || pMerged || bShow)
+ if (pExtInp || m_pMergedPara || bShow)
{
- const SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
- if (pExtInp || pMerged || SwRedlineTable::npos != nRedlPos)
+ SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
+ if (SwRedlineTable::npos == nRedlPos && m_pMergedPara)
+ {
+ SwTextNode const* pNode(&rTextNode);
+ for (auto const& rExtent : m_pMergedPara->extents)
+ { // note: have to search because extents based only on Delete
+ if (rExtent.pNode != pNode)
+ {
+ pNode = rExtent.pNode;
+ nRedlPos = rIDRA.GetRedlinePos(*pNode, USHRT_MAX);
+ if (SwRedlineTable::npos != nRedlPos)
+ break;
+ }
+ }
+ assert(SwRedlineTable::npos != nRedlPos);
+ }
+ if (pExtInp || m_pMergedPara || SwRedlineTable::npos != nRedlPos)
{
const std::vector<ExtTextInputAttr> *pArr = nullptr;
if( pExtInp )
{
pArr = &pExtInp->GetAttrs();
- Seek( 0 );
+ Seek( TextFrameIndex(0) );
}
m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
commit 211bacb6b1a9c0035c62522e71aa8d7a4d3c8ac1
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 17:39:32 2018 +0200
sw_redlinehide: SwRedlineItr::m_nNdIdx can be const
Change-Id: I6231e25dd1cae8360b2561051cc06fb16788398a
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index be4047049603..310fd067ca23 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -74,7 +74,8 @@ class SwRedlineItr
SwAttrHandler& m_rAttrHandler;
std::unique_ptr<SfxItemSet> m_pSet;
SwExtend *m_pExt;
- sal_uLong m_nNdIdx;
+ // note: this isn't actually used in the merged-para (Hide) case
+ sal_uLong const m_nNdIdx;
SwRedlineTable::size_type const m_nFirst;
SwRedlineTable::size_type m_nAct;
sal_Int32 m_nStart;
commit a6289aa9383e3c2ff897337c9986d2d6fdd6161b
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 16:25:19 2018 +0200
sw_redlinehide: add 3rd mode to SwRedlineItr
So it can work both in the old ignore-redlines mode and in the new
hide-redlines mode.
Change-Id: I29b23c6749a0f314aff5e9b2342fb389b53bd107
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index a036e2d1e964..1ba4b8588d91 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -485,7 +485,7 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const
SwAttrHandler aAttrHandler;
aAttrHandler.Init( rTextNode.GetSwAttrSet(),
*rTextNode.getIDocumentSettingAccess() );
- SwRedlineItr aRedln( rTextNode, *pFnt, aAttrHandler, nRedlPos, true );
+ SwRedlineItr aRedln(rTextNode, *pFnt, aAttrHandler, nRedlPos, SwRedlineItr::Mode::Show);
}
}
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index a162577879f8..5d85adbf3c6d 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -259,7 +259,7 @@ SwTwips SwTextFrame::EmptyHeight() const
aAttrHandler.Init( GetTextNode()->GetSwAttrSet(),
*GetTextNode()->getIDocumentSettingAccess() );
SwRedlineItr aRedln( rTextNode, *pFnt, aAttrHandler,
- nRedlPos, true );
+ nRedlPos, SwRedlineItr::Mode::Show);
}
}
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 1d7bba7fa197..e024e71cb9c5 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -228,7 +228,12 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
}
m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
- bShow, pArr, pExtInp ? pExtInp->Start() : nullptr);
+ bShow
+ ? SwRedlineItr::Mode::Show
+ : m_pMergedPara
+ ? SwRedlineItr::Mode::Hide
+ : SwRedlineItr::Mode::Ignore,
+ pArr, pExtInp ? pExtInp->Start() : nullptr);
if( m_pRedline->IsOn() )
++m_nChgCnt;
@@ -249,7 +254,8 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// If m_nAct is set to SwRedlineTable::npos (via Reset()), then currently no
// Redline is active, m_nStart and m_nEnd are invalid.
SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
- SwAttrHandler& rAH, sal_Int32 nRed, bool bShow,
+ SwAttrHandler& rAH, sal_Int32 nRed,
+ Mode const mode,
const std::vector<ExtTextInputAttr> *pArr,
SwPosition const*const pExtInputStart)
: m_rDoc( *rTextNd.GetDoc() )
@@ -258,7 +264,7 @@ SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
, m_nFirst( nRed )
, m_nAct( SwRedlineTable::npos )
, m_bOn( false )
- , m_bShow( bShow )
+ , m_eMode( mode )
{
if( pArr )
{
@@ -286,7 +292,8 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const n
if( ExtOn() )
return 0; // Abbreviation: if we're within an ExtendTextInputs
// there can't be other changes of attributes (not even by redlining)
- if (m_bShow)
+ assert(m_eMode == Mode::Hide || m_nNdIdx == nNode);
+ if (m_eMode == Mode::Show)
{
if (m_bOn)
{
@@ -390,7 +397,7 @@ void SwRedlineItr::ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bCh
{
OSL_ENSURE( IsOn(), "SwRedlineItr::ChangeTextAttr: Off?" );
- if (!m_bShow && !m_pExt)
+ if (m_eMode != Mode::Show && !m_pExt)
return;
if( bChg )
@@ -429,7 +436,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
sal_Int32 nStart(m_nStart);
sal_Int32 nEnd(m_nEnd);
nNext = NextExtend(pNode->GetIndex(), nNext);
- if (!m_bShow || SwRedlineTable::npos == m_nFirst)
+ if (m_eMode == Mode::Ignore || SwRedlineTable::npos == m_nFirst)
return std::make_pair(nNext, nullptr);
if (SwRedlineTable::npos == rAct)
{
@@ -448,7 +455,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
else if (nStart <= nNext)
{
nNext = nStart;
- if (!m_bShow)
+ if (m_eMode == Mode::Hide)
{
SwRangeRedline const* pRedline = m_rDoc.getIDocumentRedlineAccess().GetRedlineTable()[rAct];
if (pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
@@ -496,7 +503,7 @@ bool SwRedlineItr::CheckLine(
{
// note: previously this would return true in the (!m_bShow && m_pExt)
// case, but surely that was a bug?
- if (m_nFirst == SwRedlineTable::npos || !m_bShow)
+ if (m_nFirst == SwRedlineTable::npos || m_eMode != Mode::Show)
return false;
assert(nStartNode == nEndNode);
if( nChkEnd == nChkStart ) // empty lines look one char further
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 9cb6ad3af0d8..be4047049603 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -80,7 +80,10 @@ class SwRedlineItr
sal_Int32 m_nStart;
sal_Int32 m_nEnd;
bool m_bOn;
- bool m_bShow;
+public:
+ enum class Mode { Show, Ignore, Hide };
+private:
+ Mode const m_eMode;
void Clear_( SwFont* pFnt );
bool ChkSpecialUnderline_() const;
@@ -98,7 +101,8 @@ class SwRedlineItr
}
public:
SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt, SwAttrHandler& rAH,
- sal_Int32 nRedlPos, bool bShw, const std::vector<ExtTextInputAttr> *pArr = nullptr,
+ sal_Int32 nRedlPos, Mode mode,
+ const std::vector<ExtTextInputAttr> *pArr = nullptr,
SwPosition const* pExtInputStart = nullptr);
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE;
SwRedlineTable::size_type GetAct() const { return m_nAct; }
@@ -107,7 +111,7 @@ public:
void ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bChg );
short Seek(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew, sal_Int32 nOld)
{
- if (m_bShow || m_pExt) return Seek_(rFnt, nNode, nNew, nOld);
+ if (m_eMode != Mode::Hide || m_pExt) return Seek_(rFnt, nNode, nNew, nOld);
return 0;
}
void Reset() {
commit f9a4791e08a8a3cfb693c30447bb92c6dcbfb4ed
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Mon May 14 14:38:08 2018 +0200
sw_redlinehide: SwRedlineItr::CheckLine()
... should just return early... but keep the changed interface.
Change-Id: I6da6f62ebd66f1017946abac60c5f20d2dbb1fc5
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index e8fb45c23b86..454a5a5116e2 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -566,8 +566,13 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
Width( nLineWidth );
SAL_WARN_IF( nLineWidth < Width(), "sw.core", "SwLineLayout::CalcLine: line is bursting" );
SetDummy( bTmpDummy );
+ std::pair<SwTextNode const*, sal_Int32> const start(
+ rInf.GetTextFrame()->MapViewToModel(rLine.GetStart()));
+ std::pair<SwTextNode const*, sal_Int32> const end(
+ rInf.GetTextFrame()->MapViewToModel(rLine.GetEnd()));
SetRedline( rLine.GetRedln() &&
- rLine.GetRedln()->CheckLine( rLine.GetStart(), rLine.GetEnd() ) );
+ rLine.GetRedln()->CheckLine(start.first->GetIndex(), start.second,
+ end.first->GetIndex(), end.second) );
}
// #i47162# - add optional parameter <_bNoFlyCntPorAndLinePor>
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 4a440df311bd..1d7bba7fa197 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -490,10 +490,15 @@ bool SwRedlineItr::ChkSpecialUnderline_() const
return false;
}
-bool SwRedlineItr::CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd )
+bool SwRedlineItr::CheckLine(
+ sal_uLong const nStartNode, sal_Int32 const nChkStart,
+ sal_uLong const nEndNode, sal_Int32 nChkEnd)
{
- if (m_nFirst == SwRedlineTable::npos)
+ // note: previously this would return true in the (!m_bShow && m_pExt)
+ // case, but surely that was a bug?
+ if (m_nFirst == SwRedlineTable::npos || !m_bShow)
return false;
+ assert(nStartNode == nEndNode);
if( nChkEnd == nChkStart ) // empty lines look one char further
++nChkEnd;
sal_Int32 nOldStart = m_nStart;
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 3deeb16bd2ae..9cb6ad3af0d8 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -123,7 +123,7 @@ public:
#endif
bool ChkSpecialUnderline() const
{ return IsOn() && ChkSpecialUnderline_(); }
- bool CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd );
+ bool CheckLine(sal_uLong nStartNode, sal_Int32 nChkStart, sal_uLong nEndNode, sal_Int32 nChkEnd);
bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
{ return m_pExt->Leave(rFnt, nNode, nNew); }
bool ExtOn() {
commit ad11312fe4f1b0967650bad2549c53bc671c73f0
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 18:48:12 2018 +0200
sw_redlinehide: adapt SwExtend to merged paragraph
It needs a new member to know what node it's in, plus all the methods
need a node passed in to compare.
Change-Id: Ibcc5a1fb7031fbdc048cc6716bb5b74cd4b8f0bf
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index ce8aef57a744..003b3348e140 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -145,7 +145,7 @@ bool SwAttrIter::IsSymbol(TextFrameIndex const nNewPos)
bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFont )
{
if ( m_pRedline && m_pRedline->ExtOn() )
- m_pRedline->LeaveExtend( *m_pFont, 0 );
+ m_pRedline->LeaveExtend(*m_pFont, m_pFirstTextNode->GetIndex(), 0);
// reset font to its original state
m_aAttrHandler.Reset();
@@ -161,7 +161,7 @@ bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFo
{
m_pRedline->Clear( m_pFont );
if( !bParaFont )
- m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, 0, COMPLETE_STRING);
+ m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, m_pFirstTextNode->GetIndex(), 0, COMPLETE_STRING);
else
m_pRedline->Reset();
}
@@ -241,8 +241,14 @@ void SwAttrIter::SeekFwd( const sal_Int32 nNewPos )
bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
{
+ // note: nNewPos isn't necessarily a index returned from GetNextAttr
+ sw::MergedPara * pMerged(nullptr); // FIXME
+ std::pair<SwTextNode const*, sal_Int32> const newPos( pMerged
+ ? sw::MapViewToModel(*pMerged, nNewPos)
+ : std::make_pair(m_pTextNode, nNewPos));
+
if ( m_pRedline && m_pRedline->ExtOn() )
- m_pRedline->LeaveExtend( *m_pFont, nNewPos );
+ m_pRedline->LeaveExtend(*m_pFont, newPos.first->GetIndex(), newPos.second);
if( m_pHints )
{
@@ -277,7 +283,7 @@ bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
m_pFont->SetActual( SwScriptInfo::WhichFont( nNewPos, nullptr, m_pScriptInfo ) );
if( m_pRedline )
- m_nChgCnt = m_nChgCnt + m_pRedline->Seek( *m_pFont, nNewPos, m_nPosition );
+ m_nChgCnt = m_nChgCnt + m_pRedline->Seek(*m_pFont, newPos.first->GetIndex(), newPos.second, m_nPosition);
m_nPosition = nNewPos;
if( m_nPropFont )
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index cc98272947d1..2037eed2ec68 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -317,10 +317,17 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
SeekAndChgBefore( GetInfo() );
else if ( pPor->IsQuoVadisPortion() )
{
+ // A remark on QuoVadis/ErgoSum:
+ // We use the Font set for the Paragraph for these portions.
+ // Thus, we initialize:
TextFrameIndex nOffset = GetInfo().GetIdx();
SeekStartAndChg( GetInfo(), true );
if( GetRedln() && m_pCurr->HasRedline() )
- GetRedln()->Seek( *m_pFont, nOffset, 0 );
+ {
+ std::pair<SwTextNode const*, sal_Int32> const pos(
+ GetTextFrame()->MapViewToModel(nOffset));
+ GetRedln()->Seek(*m_pFont, pos.first->GetIndex(), pos.second, 0);
+ }
}
else if( pPor->InTextGrp() || pPor->InFieldGrp() || pPor->InTabGrp() )
SeekAndChg( GetInfo() );
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 66a8918588d5..4a440df311bd 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -268,7 +268,7 @@ SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
}
else
m_pExt = nullptr;
- Seek (rFnt, 0, COMPLETE_STRING);
+ Seek(rFnt, m_nNdIdx, 0, COMPLETE_STRING);
}
SwRedlineItr::~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
@@ -279,7 +279,8 @@ SwRedlineItr::~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
// The return value of SwRedlineItr::Seek tells you if the current font
// has been manipulated by leaving (-1) or accessing (+1) of a section
-short SwRedlineItr::Seek_(SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld)
+short SwRedlineItr::Seek_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew, sal_Int32 const nOld)
+ //TODO use nNode to compare
{
short nRet = 0;
if( ExtOn() )
@@ -302,10 +303,10 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld)
if (m_nAct > m_nFirst)
m_nAct = m_nFirst; // the test has to run from the beginning
else
- return nRet + EnterExtend( rFnt, nNew ); // There's none prior to us
+ return nRet + EnterExtend(rFnt, nNode, nNew); // There's none prior to us
}
else
- return nRet + EnterExtend( rFnt, nNew ); // We stayed in the same section
+ return nRet + EnterExtend(rFnt, nNode, nNew); // We stayed in the same section
}
if (SwRedlineTable::npos == m_nAct || nOld > nNew)
m_nAct = m_nFirst;
@@ -363,7 +364,7 @@ short SwRedlineItr::Seek_(SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld)
m_nEnd = COMPLETE_STRING;
}
}
- return nRet + EnterExtend( rFnt, nNew );
+ return nRet + EnterExtend(rFnt, nNode, nNew);
}
void SwRedlineItr::FillHints( std::size_t nAuthor, RedlineType_t eType )
@@ -427,7 +428,7 @@ SwRedlineItr::GetNextRedln(sal_Int32 nNext, SwTextNode const*const pNode, SwRedl
{
sal_Int32 nStart(m_nStart);
sal_Int32 nEnd(m_nEnd);
- nNext = NextExtend( nNext );
+ nNext = NextExtend(pNode->GetIndex(), nNext);
if (!m_bShow || SwRedlineTable::npos == m_nFirst)
return std::make_pair(nNext, nullptr);
if (SwRedlineTable::npos == rAct)
@@ -542,10 +543,12 @@ void SwExtend::ActualizeFont( SwFont &rFnt, ExtTextInputAttr nAttr )
rFnt.SetGreyWave( true );
}
-short SwExtend::Enter(SwFont& rFnt, sal_Int32 nNew)
+short SwExtend::Enter(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
{
- OSL_ENSURE( !Inside(), "SwExtend: Enter without Leave" );
OSL_ENSURE( !m_pFont, "SwExtend: Enter with Font" );
+ if (nNode != m_nNode)
+ return 0;
+ OSL_ENSURE( !Inside(), "SwExtend: Enter without Leave" );
m_nPos = nNew;
if( Inside() )
{
@@ -556,9 +559,11 @@ short SwExtend::Enter(SwFont& rFnt, sal_Int32 nNew)
return 0;
}
-bool SwExtend::Leave_(SwFont& rFnt, sal_Int32 nNew)
+bool SwExtend::Leave_(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
{
- OSL_ENSURE( Inside(), "SwExtend: Leave without Enter" );
+ OSL_ENSURE(nNode == m_nNode && Inside(), "SwExtend: Leave without Enter");
+ if (nNode != m_nNode)
+ return true;
const ExtTextInputAttr nOldAttr = m_rArr[m_nPos - m_nStart];
m_nPos = nNew;
if( Inside() )
@@ -579,9 +584,10 @@ bool SwExtend::Leave_(SwFont& rFnt, sal_Int32 nNew)
return false;
}
-sal_Int32 SwExtend::Next( sal_Int32 nNext )
+sal_Int32 SwExtend::Next(sal_uLong const nNode, sal_Int32 nNext)
{
- (void) m_nNode; // TODO use it here
+ if (nNode != m_nNode)
+ return nNext;
if (m_nPos < m_nStart)
{
if (nNext > m_nStart)
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 65f22be44f2b..3deeb16bd2ae 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -38,11 +38,14 @@ class SwExtend
{
std::unique_ptr<SwFont> m_pFont;
const std::vector<ExtTextInputAttr> &m_rArr;
- sal_uLong m_nNode;
- sal_Int32 m_nStart;
+ /// position of start of SwExtTextInput
+ sal_uLong const m_nNode;
+ sal_Int32 const m_nStart;
+ /// current position (inside)
sal_Int32 m_nPos;
- sal_Int32 m_nEnd;
- bool Leave_( SwFont& rFnt, sal_Int32 nNew );
+ /// position of end of SwExtTextInput (in same node as start)
+ sal_Int32 const m_nEnd;
+ bool Leave_(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew);
bool Inside() const { return (m_nPos >= m_nStart && m_nPos < m_nEnd); }
static void ActualizeFont( SwFont &rFnt, ExtTextInputAttr nAttr );
public:
@@ -56,10 +59,10 @@ public:
{}
bool IsOn() const { return m_pFont != nullptr; }
void Reset() { m_pFont.reset(); m_nPos = COMPLETE_STRING; }
- bool Leave( SwFont& rFnt, sal_Int32 nNew )
- { return m_pFont && Leave_( rFnt, nNew ); }
- short Enter( SwFont& rFnt, sal_Int32 nNew );
- sal_Int32 Next( sal_Int32 nNext );
+ bool Leave(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
+ { return m_pFont && Leave_(rFnt, nNode, nNew); }
+ short Enter(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew);
+ sal_Int32 Next(sal_uLong nNode, sal_Int32 nNext);
SwFont* GetFont() { return m_pFont.get(); }
void UpdateFont(SwFont &rFont) { ActualizeFont(rFont, m_rArr[m_nPos - m_nStart]); }
};
@@ -82,14 +85,15 @@ class SwRedlineItr
void Clear_( SwFont* pFnt );
bool ChkSpecialUnderline_() const;
void FillHints( std::size_t nAuthor, RedlineType_t eType );
- short Seek_( SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld );
+ short Seek_(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew, sal_Int32 nOld);
// sal_Int32 GetNextRedln_( sal_Int32 nNext );
- short EnterExtend( SwFont& rFnt, sal_Int32 nNew ) {
- if (m_pExt) return m_pExt->Enter( rFnt, nNew );
+ short EnterExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
+ {
+ if (m_pExt) return m_pExt->Enter(rFnt, nNode, nNew);
return 0;
}
- sal_Int32 NextExtend( sal_Int32 nNext ) {
- if (m_pExt) return m_pExt->Next( nNext );
+ sal_Int32 NextExtend(sal_uLong const nNode, sal_Int32 const nNext) {
+ if (m_pExt) return m_pExt->Next(nNode, nNext);
return nNext;
}
public:
@@ -101,8 +105,9 @@ public:
bool IsOn() const { return m_bOn || (m_pExt && m_pExt->IsOn()); }
void Clear( SwFont* pFnt ) { if (m_bOn) Clear_( pFnt ); }
void ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bChg );
- short Seek( SwFont& rFnt, sal_Int32 nNew, sal_Int32 nOld ) {
- if (m_bShow || m_pExt) return Seek_( rFnt, nNew, nOld );
+ short Seek(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew, sal_Int32 nOld)
+ {
+ if (m_bShow || m_pExt) return Seek_(rFnt, nNode, nNew, nOld);
return 0;
}
void Reset() {
@@ -119,8 +124,8 @@ public:
bool ChkSpecialUnderline() const
{ return IsOn() && ChkSpecialUnderline_(); }
bool CheckLine( sal_Int32 nChkStart, sal_Int32 nChkEnd );
- bool LeaveExtend( SwFont& rFnt, sal_Int32 nNew )
- { return m_pExt->Leave(rFnt, nNew ); }
+ bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
+ { return m_pExt->Leave(rFnt, nNode, nNew); }
bool ExtOn() {
if (m_pExt) return m_pExt->IsOn();
return false;
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 34b353b10f80..1ccfd5fbecc0 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -1032,7 +1032,11 @@ TextFrameIndex SwTextFormatter::FormatQuoVadis(TextFrameIndex const nOffset)
FeedInf( rInf );
SeekStartAndChg( rInf, true );
if( GetRedln() && m_pCurr->HasRedline() )
- GetRedln()->Seek( *m_pFont, nOffset, 0 );
+ {
+ std::pair<SwTextNode const*, sal_Int32> const pos(
+ GetTextFrame()->MapViewToModel(nOffset));
+ GetRedln()->Seek(*m_pFont, pos.first->GetIndex(), pos.second, 0);
+ }
// A tricky special case: Flyfrms extend into the Line and are at the
// position we want to insert the Quovadis text
commit 2b322907dcec30be4520b8e715709b068bd673f0
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 18:42:44 2018 +0200
itratr header
Change-Id: Ib8a0e8bd01ef6dfa4c0e9f9c00c83ba935fca2fb
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 1525c41bd0df..ce8aef57a744 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -239,7 +239,7 @@ void SwAttrIter::SeekFwd( const sal_Int32 nNewPos )
}
-bool SwAttrIter::Seek( const sal_Int32 nNewPos )
+bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
{
if ( m_pRedline && m_pRedline->ExtOn() )
m_pRedline->LeaveExtend( *m_pFont, nNewPos );
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index 3586b0fbb62e..5b80a17b577e 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -104,7 +104,7 @@ public:
SwRedlineItr *GetRedln() { return m_pRedline; }
// The parameter returns the position of the next change before or at the
// char position.
- sal_Int32 GetNextAttr( ) const;
+ TextFrameIndex GetNextAttr() const;
/// Enables the attributes used at char pos nPos in the logical font
bool Seek(TextFrameIndex nPos);
// Creates the font at the specified position via Seek() and checks
commit 6c1061f5bfa8ec5cadbee8d2829a1b630885ddd6
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 18:35:48 2018 +0200
sw_redlinehide: SwExtend needs a node index for merged para
Change-Id: I0742eea80e881f1a5f3714e283f4b913260c46ee
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index bccb653ae19b..66a8918588d5 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -133,6 +133,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
// set font to vertical if frame layout is vertical
bool bVertLayout = false;
bool bRTL = false;
+ sw::MergedPara const* pMerged(nullptr);
if ( pFrame )
{
if ( pFrame->IsVertical() )
@@ -141,6 +142,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
m_pFont->SetVertical( m_pFont->GetOrientation(), true );
}
bRTL = pFrame->IsRightToLeft();
+ pMerged = pFrame->GetMergedPara();
}
// Initialize the default attribute of the attribute handler
@@ -194,24 +196,39 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
SwDoc* pDoc = rTextNode.GetDoc();
const IDocumentRedlineAccess& rIDRA = rTextNode.getIDocumentRedlineAccess();
+ // sw_redlinehide: this is a Ring - pExtInp is the first PaM that's inside
+ // the node. It's not clear whether there can be more than 1 PaM in the
+ // Ring, and this code doesn't handle that case; neither did the old code.
const SwExtTextInput* pExtInp = pDoc->GetExtTextInput( rTextNode );
+ if (!pExtInp && pMerged)
+ {
+ SwTextNode const* pNode(&rTextNode);
+ for (auto const& rExtent : pMerged->extents)
+ {
+ if (rExtent.pNode != pNode)
+ {
+ pNode = rExtent.pNode;
+ pExtInp = pDoc->GetExtTextInput(*pNode);
+ if (pExtInp)
+ break;
+ }
+ }
+ }
const bool bShow = IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() );
- if( pExtInp || bShow )
+ if (pExtInp || pMerged || bShow)
{
const SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, USHRT_MAX );
- if( pExtInp || SwRedlineTable::npos != nRedlPos )
+ if (pExtInp || pMerged || SwRedlineTable::npos != nRedlPos)
{
const std::vector<ExtTextInputAttr> *pArr = nullptr;
- sal_Int32 nInputStt = 0;
if( pExtInp )
{
pArr = &pExtInp->GetAttrs();
- nInputStt = pExtInp->Start()->nContent.GetIndex();
Seek( 0 );
}
m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
- bShow, pArr, nInputStt );
+ bShow, pArr, pExtInp ? pExtInp->Start() : nullptr);
if( m_pRedline->IsOn() )
++m_nChgCnt;
@@ -234,7 +251,7 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
SwAttrHandler& rAH, sal_Int32 nRed, bool bShow,
const std::vector<ExtTextInputAttr> *pArr,
- sal_Int32 nExtStart )
+ SwPosition const*const pExtInputStart)
: m_rDoc( *rTextNd.GetDoc() )
, m_rAttrHandler( rAH )
, m_nNdIdx( rTextNd.GetIndex() )
@@ -244,7 +261,11 @@ SwRedlineItr::SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt,
, m_bShow( bShow )
{
if( pArr )
- m_pExt = new SwExtend( *pArr, nExtStart );
+ {
+ assert(pExtInputStart);
+ m_pExt = new SwExtend(*pArr, pExtInputStart->nNode.GetIndex(),
+ pExtInputStart->nContent.GetIndex());
+ }
else
m_pExt = nullptr;
Seek (rFnt, 0, COMPLETE_STRING);
@@ -560,6 +581,7 @@ bool SwExtend::Leave_(SwFont& rFnt, sal_Int32 nNew)
sal_Int32 SwExtend::Next( sal_Int32 nNext )
{
+ (void) m_nNode; // TODO use it here
if (m_nPos < m_nStart)
{
if (nNext > m_nStart)
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 2cf419046b4d..65f22be44f2b 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -38,6 +38,7 @@ class SwExtend
{
std::unique_ptr<SwFont> m_pFont;
const std::vector<ExtTextInputAttr> &m_rArr;
+ sal_uLong m_nNode;
sal_Int32 m_nStart;
sal_Int32 m_nPos;
sal_Int32 m_nEnd;
@@ -45,8 +46,10 @@ class SwExtend
bool Inside() const { return (m_nPos >= m_nStart && m_nPos < m_nEnd); }
static void ActualizeFont( SwFont &rFnt, ExtTextInputAttr nAttr );
public:
- SwExtend(const std::vector<ExtTextInputAttr> &rArr, sal_Int32 const nStart)
+ SwExtend(const std::vector<ExtTextInputAttr> &rArr,
+ sal_uLong const nNode, sal_Int32 const nStart)
: m_rArr(rArr)
+ , m_nNode(nNode)
, m_nStart(nStart)
, m_nPos(COMPLETE_STRING)
, m_nEnd(m_nStart + rArr.size())
@@ -92,7 +95,7 @@ class SwRedlineItr
public:
SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt, SwAttrHandler& rAH,
sal_Int32 nRedlPos, bool bShw, const std::vector<ExtTextInputAttr> *pArr = nullptr,
- sal_Int32 nExtStart = COMPLETE_STRING );
+ SwPosition const* pExtInputStart = nullptr);
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE;
SwRedlineTable::size_type GetAct() const { return m_nAct; }
bool IsOn() const { return m_bOn || (m_pExt && m_pExt->IsOn()); }
commit 321872cca6889ceced901204d2d3ab620b449aa4
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 17:35:28 2018 +0200
sw_redlinehide: SwAttrIter::GetHints only used to check if there are
hints, so replace it with something less dangerous.
Change-Id: If35cf8157e6b88ee6873789847ed9c5ceea6e37e
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index 36f93e4344b4..3586b0fbb62e 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -123,7 +123,7 @@ public:
// Returns the attribute for a position
SwTextAttr *GetAttr(TextFrameIndex nPos) const;
- const SwpHints *GetHints() const { return m_pHints; }
+ bool HaveHints() const { return m_pHints != nullptr; }
SwFont *GetFnt() { return m_pFont; }
const SwFont *GetFnt() const { return m_pFont; }
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index 002eaf932fb4..63305a185566 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -322,7 +322,7 @@ void SwTextIter::TruncLines( bool bNoteFollow )
if( pDel )
{
m_pCurr->SetNext( nullptr );
- if( GetHints() && bNoteFollow )
+ if (HaveHints() && bNoteFollow)
{
GetInfo().GetParaPortion()->SetFollowField( pDel->IsRest() ||
lcl_NeedsFieldRest( m_pCurr ) );
@@ -367,7 +367,7 @@ void SwTextIter::TruncLines( bool bNoteFollow )
{
m_pCurr->SetRealHeight( 1 );
}
- if( GetHints() )
+ if (HaveHints())
m_pFrame->RemoveFootnote( nEnd );
}
commit 68364fe67021351ace644f1a35ab2466888c51aa
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Fri May 11 12:47:16 2018 +0200
itratr: GetNextAttr return TextFrameIndex
Change-Id: I2b519f5379815abc943e05a79db609b3e93f82fc
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 80c9e138d489..1525c41bd0df 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -571,7 +571,7 @@ sal_Int32 GetNextAttrImpl(SwTextNode const*const pTextNode, size_t nStartIndex,
return nNext;
}
-sal_Int32 SwAttrIter::GetNextAttr() const
+TextFrameIndex SwAttrIter::GetNextAttr() const
{
size_t nStartIndex(m_nStartIndex);
size_t nEndIndex(m_nEndIndex);
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index 7fe78a504df3..36f93e4344b4 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -106,7 +106,7 @@ public:
// char position.
sal_Int32 GetNextAttr( ) const;
/// Enables the attributes used at char pos nPos in the logical font
- bool Seek( const sal_Int32 nPos );
+ bool Seek(TextFrameIndex nPos);
// Creates the font at the specified position via Seek() and checks
// if it's a symbol font.
bool IsSymbol(TextFrameIndex nPos);
commit 31bc56b0d449188fde7eb12cfcff6179e782bcea
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 18:40:21 2018 +0200
sw_redlinehide: trivial conversions in objectpositioning/
Change-Id: Ice9c49596d478bd02728827dbd0dc2c77d7a13db
diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
index 4144f8241154..43070b3547f1 100644
--- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
@@ -223,7 +223,7 @@ void SwToContentAnchoredObjectPosition::CalcPosition()
// #i22341# - get top of line, in which the anchor character is.
mnToCharTopOfLine = GetAnchoredObj().GetLastTopOfLine();
pOrientFrame = &(const_cast<SwTextFrame&>(rAnchorTextFrame).GetFrameAtOfst(
- rAnch.GetContentAnchor()->nContent.GetIndex() ) );
+ rAnchorTextFrame.MapModelToViewPos(*rAnch.GetContentAnchor())));
mpToCharOrientFrame = pOrientFrame;
}
}
commit 733a76e49ee94fc9afdce5cb5c2321f5fd9ab32b
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 18:39:59 2018 +0200
sw_redlinehide: trivial conversions in trvlfrm.cxx
Change-Id: I812ba7a03b9bd25134dab2e85fcead1c7bed617a
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 1586d7e5753d..d4c1e5c002c9 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1013,10 +1013,9 @@ sal_uInt16 SwRootFrame::SetCurrPage( SwCursor* pToSet, sal_uInt16 nPageNum )
pContent = pContent->GetNextContentFrame();
if ( pContent )
{
- SwContentNode* pCNd = const_cast<SwContentNode*>(pContent->GetNode());
- pToSet->GetPoint()->nNode = *pCNd;
- pCNd->MakeStartIndex( &pToSet->GetPoint()->nContent );
- pToSet->GetPoint()->nContent = static_cast<const SwTextFrame*>(pContent)->GetOfst();
+ assert(pContent->IsTextFrame());
+ SwTextFrame const*const pFrame(static_cast<const SwTextFrame*>(pContent));
+ *pToSet->GetPoint() = pFrame->MapViewToModelPos(pFrame->GetOfst());
SwShellCursor* pSCursor = dynamic_cast<SwShellCursor*>(pToSet);
if( pSCursor )
@@ -1110,15 +1109,14 @@ bool GetFrameInPage( const SwContentFrame *pCnt, SwWhichPage fnWhichPage,
}
}
- SwContentNode *pCNd = const_cast<SwContentNode*>(pCnt->GetNode());
- pPam->GetPoint()->nNode = *pCNd;
- sal_Int32 nIdx;
- if( fnPosPage == GetFirstSub )
- nIdx = static_cast<const SwTextFrame*>(pCnt)->GetOfst();
- else
- nIdx = pCnt->GetFollow() ?
- static_cast<const SwTextFrame*>(pCnt)->GetFollow()->GetOfst()-1 : pCNd->Len();
- pPam->GetPoint()->nContent.Assign( pCNd, nIdx );
+ assert(pCnt->IsTextFrame());
+ SwTextFrame const*const pFrame(static_cast<const SwTextFrame*>(pCnt));
+ TextFrameIndex const nIdx((fnPosPage == GetFirstSub)
+ ? pFrame->GetOfst()
+ : (pFrame->GetFollow())
+ ? pFrame->GetFollow()->GetOfst() - TextFrameIndex(1)
+ : TextFrameIndex(pFrame->GetText().getLength()));
+ *pPam->GetPoint() = pFrame->MapViewToModelPos(nIdx);
return true;
}
}
commit 2513d0f3082ee99fc9e960fae04b7611f42439b3
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 18:39:09 2018 +0200
sw_redlinehide: trivial conversions in softpagebreak.cxx
Still a bit TODO here wrt. finding the frame from every node...
Change-Id: Icff33d2fae3afee77c4329db0938b444f0e47537
diff --git a/sw/source/core/layout/softpagebreak.cxx b/sw/source/core/layout/softpagebreak.cxx
index 051364d935e4..109730e8cfa0 100644
--- a/sw/source/core/layout/softpagebreak.cxx
+++ b/sw/source/core/layout/softpagebreak.cxx
@@ -79,7 +79,11 @@ void SwTextNode::fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const
if( pFirst2 == pFrame )
{ // Here we are: a first content inside a cell
// inside the splitted row => soft page break
- rBreak.insert( pFrame->GetOfst() );
+ auto const pos(pFrame->MapViewToModel(pFrame->GetOfst()));
+ if (pos.first == this)
+ {
+ rBreak.insert(pos.second);
+ }
break;
}
pCell = pCell->GetNext();
@@ -88,7 +92,14 @@ void SwTextNode::fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const
}
else // No soft page break if there's a "hard" page break attribute
if( pFirst2 == pFrame && !pFrame->IsPageBreak( true ) )
- rBreak.insert( pFrame->GetOfst() );
+ {
+ auto const pos(pFrame->MapViewToModel(pFrame->GetOfst()));
+ if (pos.first == this)
+ { // in the !Show case, we have to iterate over the merged
+ // SwTextFrame for every node
+ rBreak.insert(pos.second);
+ }
+ }
}
}
}
commit cfbcd058dc9e0b143e97ecb97cf2c69fb939f54c
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 18:38:03 2018 +0200
sw_redlinehide: trivial conversions in layout/
Change-Id: I5ce4590af52b3bfc08f89915999e86f4973fa9e3
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index aaf96027e7aa..0a4292638342 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -572,7 +572,7 @@ void SwAnchoredDrawObject::InvalidateObjPos()
(GetFrameFormat().GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) )
{
SwTextFrame* pAnchorTextFrame( static_cast<SwTextFrame*>(AnchorFrame()) );
- if (pAnchorTextFrame->CalcFlyPos(&GetFrameFormat()) != COMPLETE_STRING)
+ if (pAnchorTextFrame->CalcFlyPos(&GetFrameFormat()) != TextFrameIndex(COMPLETE_STRING))
{
AnchorFrame()->Prepare( PREP_FLY_ATTR_CHG, &GetFrameFormat() );
}
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index 0145389eab9e..5958f29085bc 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -545,7 +545,7 @@ bool SwAnchoredObject::HasClearedEnvironment() const
const SwTextFrame* pTmpTextFrame = static_cast<const SwTextFrame*>(pTmpFrame);
if ( pTmpTextFrame->IsUndersized() ||
( pTmpTextFrame->GetFollow() &&
- pTmpTextFrame->GetFollow()->GetOfst() == 0 ) )
+ pTmpTextFrame->GetFollow()->GetOfst() == TextFrameIndex(0)))
{
bHasClearedEnvironment = true;
}
@@ -716,8 +716,9 @@ SwTextFrame* SwAnchoredObject::FindAnchorCharFrame()
if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) ||
(rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR))
{
- pAnchorCharFrame = &(static_cast<SwTextFrame*>(AnchorFrame())->
- GetFrameAtOfst( rAnch.GetContentAnchor()->nContent.GetIndex() ));
+ SwTextFrame *const pFrame(static_cast<SwTextFrame*>(AnchorFrame()));
+ TextFrameIndex const nOffset(pFrame->MapModelToViewPos(*rAnch.GetContentAnchor()));
+ pAnchorCharFrame = &pFrame->GetFrameAtOfst(nOffset);
}
}
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 41f4e2a72f82..5a3e5b73b837 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -1403,7 +1403,8 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/)
const SwTwips nHDiff = nOldH - aRectFnSet.GetHeight(getFrameArea());
const bool bNoPrepAdjustFrame =
nHDiff > 0 && IsInTab() && GetFollow() &&
- ( 1 == static_cast<SwTextFrame*>(GetFollow())->GetLineCount( COMPLETE_STRING ) || aRectFnSet.GetWidth(static_cast<SwTextFrame*>(GetFollow())->getFrameArea()) < 0 ) &&
+ (1 == static_cast<SwTextFrame*>(GetFollow())->GetLineCount(TextFrameIndex(COMPLETE_STRING))
+ || aRectFnSet.GetWidth(static_cast<SwTextFrame*>(GetFollow())->getFrameArea()) < 0) &&
GetFollow()->CalcAddLowerSpaceAsLastInTableCell() == nHDiff;
if ( !bNoPrepAdjustFrame )
{
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 1c5ebadcdca1..8fdbcf9c0efc 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1088,10 +1088,10 @@ void SwFlyFrame::ChgRelPos( const Point &rNewPos )
if( LONG_MAX != nNewY )
{
aVert.SetVertOrient( text::VertOrientation::NONE );
- sal_Int32 nOfs =
- pFormat->GetAnchor().GetContentAnchor()->nContent.GetIndex();
- OSL_ENSURE( GetAnchorFrame()->IsTextFrame(), "TextFrame expected" );
+ assert(GetAnchorFrame()->IsTextFrame());
pAutoFrame = static_cast<const SwTextFrame*>(GetAnchorFrame());
+ TextFrameIndex const nOfs(pAutoFrame->MapModelToViewPos(
+ *pFormat->GetAnchor().GetContentAnchor()));
while( pAutoFrame->GetFollow() &&
pAutoFrame->GetFollow()->GetOfst() <= nOfs )
{
@@ -1144,10 +1144,10 @@ void SwFlyFrame::ChgRelPos( const Point &rNewPos )
{
if( !pAutoFrame )
{
- sal_Int32 nOfs = pFormat->GetAnchor().GetContentAnchor()
- ->nContent.GetIndex();
- OSL_ENSURE( GetAnchorFrame()->IsTextFrame(), "TextFrame expected");
+ assert(GetAnchorFrame()->IsTextFrame());
pAutoFrame = static_cast<const SwTextFrame*>(GetAnchorFrame());
+ TextFrameIndex const nOfs(pAutoFrame->MapModelToViewPos(
+ *pFormat->GetAnchor().GetContentAnchor()));
while( pAutoFrame->GetFollow() &&
pAutoFrame->GetFollow()->GetOfst() <= nOfs )
pAutoFrame = pAutoFrame->GetFollow();
diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx
index 954b77913b67..1af4476d4946 100644
--- a/sw/source/core/layout/objectformattertxtfrm.cxx
+++ b/sw/source/core/layout/objectformattertxtfrm.cxx
@@ -272,7 +272,7 @@ bool SwObjectFormatterTextFrame::DoFormatObj( SwAnchoredObject& _rAnchoredObj,
// objects under the condition, that its follow contains all its text.
else if ( !mrAnchorTextFrame.IsFollow() &&
mrAnchorTextFrame.GetFollow() &&
- mrAnchorTextFrame.GetFollow()->GetOfst() == 0 )
+ mrAnchorTextFrame.GetFollow()->GetOfst() == TextFrameIndex(0))
{
SwLayouter::RemoveMovedFwdFrame(
*(mrAnchorTextFrame.FindPageFrame()->GetFormat()->GetDoc()),
@@ -440,7 +440,7 @@ bool SwObjectFormatterTextFrame::DoFormatObjs()
// objects under the condition, that its follow contains all its text.
else if ( !mrAnchorTextFrame.IsFollow() &&
mrAnchorTextFrame.GetFollow() &&
- mrAnchorTextFrame.GetFollow()->GetOfst() == 0 )
+ mrAnchorTextFrame.GetFollow()->GetOfst() == TextFrameIndex(0))
{
SwLayouter::RemoveMovedFwdFrame(
*(mrAnchorTextFrame.FindPageFrame()->GetFormat()->GetDoc()),
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 96612798d990..90cc289b2b21 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -5461,7 +5461,7 @@ static SwTwips lcl_CalcHeightOfFirstContentLine( const SwRowFrame& rSourceLine )
// would have no follow and thus would add this space.
if ( pTmp->IsTextFrame() &&
const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pTmp))
- ->GetLineCount( COMPLETE_STRING ) == 1 )
+ ->GetLineCount(TextFrameIndex(COMPLETE_STRING)) == 1)
{
nTmpHeight += SwFlowFrame::CastFlowFrame(pTmp)
->CalcAddLowerSpaceAsLastInTableCell();
commit 3c609a7e912a27cd8c020cac858f81b5cdd93a95
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:36:39 2018 +0200
sw_redlinehide: convert SwTextIter::TruncLines() to MergedAttrIter
Change-Id: I84d405df29139361dc521b490a50c16c95d10efa
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index d90186c05c1d..002eaf932fb4 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -342,16 +342,16 @@ void SwTextIter::TruncLines( bool bNoteFollow )
pLine = pLine->GetNext();
}
- SwpHints* pTmpHints = GetTextFrame()->GetTextNode()->GetpSwpHints();
-
// examine hints in range nEnd - (nEnd + nRangeChar)
- for( size_t i = 0; i < pTmpHints->Count(); ++i )
+ SwTextNode const* pNode(nullptr);
+ sw::MergedAttrIter iter(*GetTextFrame());
+ for (SwTextAttr const* pHt = iter.NextAttr(&pNode); pHt; pHt = iter.NextAttr(&pNode))
{
- const SwTextAttr* pHt = pTmpHints->Get( i );
if( RES_TXTATR_FLYCNT == pHt->Which() )
{
- // check, if hint is in our range
- const sal_Int32 nTmpPos = pHt->GetStart();
+ // check if hint is in our range
+ TextFrameIndex const nTmpPos(
+ GetTextFrame()->MapModelToView(pNode, pHt->GetStart()));
if ( nEnd <= nTmpPos && nTmpPos < nRangeEnd )
pFollow->InvalidateRange_(
SwCharRange( nTmpPos, nTmpPos ) );
commit a27f86ae0ccfbbcd15624d112b57bacb9d176dda
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:30:32 2018 +0200
sw_redlinehide: trivial conversions in itrtxt.cxx
Change-Id: Ia61fbdff0aa87669e643fa7d3d3fe08e23becd74
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index c842251e73ee..d90186c05c1d 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -206,7 +206,7 @@ const SwLineLayout *SwTextCursor::CharCursorToLine(TextFrameIndex const nPositio
bRightMargin = false;
bool bPrevious = bRightMargin && m_pCurr->GetLen() && GetPrev() &&
GetPrev()->GetLen();
- if( bPrevious && nPosition && CH_BREAK == GetInfo().GetChar( nPosition-1 ) )
+ if (bPrevious && nPosition && CH_BREAK == GetInfo().GetChar(nPosition - TextFrameIndex(1)))
bPrevious = false;
return bPrevious ? PrevLine() : m_pCurr;
}
@@ -317,7 +317,7 @@ static bool lcl_NeedsFieldRest( const SwLineLayout* pCurr )
void SwTextIter::TruncLines( bool bNoteFollow )
{
SwLineLayout *pDel = m_pCurr->GetNext();
- const sal_Int32 nEnd = m_nStart + m_pCurr->GetLen();
+ TextFrameIndex const nEnd = m_nStart + m_pCurr->GetLen();
if( pDel )
{
@@ -332,7 +332,7 @@ void SwTextIter::TruncLines( bool bNoteFollow )
if ( pFollow && ! pFollow->IsLocked() &&
nEnd == pFollow->GetOfst() )
{
- sal_Int32 nRangeEnd = nEnd;
+ TextFrameIndex nRangeEnd = nEnd;
SwLineLayout* pLine = pDel;
// determine range to be searched for flys anchored as characters
@@ -363,8 +363,10 @@ void SwTextIter::TruncLines( bool bNoteFollow )
}
if( m_pCurr->IsDummy() &&
!m_pCurr->GetLen() &&
- m_nStart < GetTextFrame()->GetText().getLength() )
+ m_nStart < TextFrameIndex(GetTextFrame()->GetText().getLength()))
+ {
m_pCurr->SetRealHeight( 1 );
+ }
if( GetHints() )
m_pFrame->RemoveFootnote( nEnd );
}
commit a474d2773423f7ee8d2b2d98cd3a7c325e9791a5
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:24:01 2018 +0200
sw_redlinehide: trivial conversions in xmldump.cxx
Change-Id: I37015a42cc1efdc324ccf7ac92423d9dbfb50be1
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 484f52405dd3..0f951cd6f033 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -31,7 +31,7 @@ class XmlPortionDumper:public SwPortionHandler
{
private:
xmlTextWriterPtr writer;
- sal_Int32 ofs;
+ TextFrameIndex ofs;
static const char* getTypeName( sal_uInt16 nType )
{
@@ -115,7 +115,7 @@ class XmlPortionDumper:public SwPortionHandler
@param rText
text which is painted on-screen
*/
- virtual void Text( sal_Int32 nLength,
+ virtual void Text( TextFrameIndex nLength,
sal_uInt16 nType,
sal_Int32 nHeight,
sal_Int32 nWidth) override
@@ -146,7 +146,7 @@ class XmlPortionDumper:public SwPortionHandler
@param nHeight
font size of the painted text
*/
- virtual void Special( sal_Int32 nLength,
+ virtual void Special( TextFrameIndex nLength,
const OUString & rText,
sal_uInt16 nType,
sal_Int32 nHeight,
@@ -191,7 +191,7 @@ class XmlPortionDumper:public SwPortionHandler
* @param nLength
* number of 'model string' characters to be skipped
*/
- virtual void Skip( sal_Int32 nLength ) override
+ virtual void Skip( TextFrameIndex nLength ) override
{
xmlTextWriterStartElement( writer, BAD_CAST( "Skip" ) );
xmlTextWriterWriteFormatAttribute( writer,
commit f33a54353dbc652fb96bb62f2cfee6197f161f2d
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 17:17:57 2018 +0200
sw_redlinehide: trivial conversions in itrpaint.cxx
Change-Id: I12cdc805c3e07840b5b914397026a48a589785ea
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 47769b372ef8..cc98272947d1 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -317,7 +317,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
SeekAndChgBefore( GetInfo() );
else if ( pPor->IsQuoVadisPortion() )
{
- sal_Int32 nOffset = GetInfo().GetIdx();
+ TextFrameIndex nOffset = GetInfo().GetIdx();
SeekStartAndChg( GetInfo(), true );
if( GetRedln() && m_pCurr->HasRedline() )
GetRedln()->Seek( *m_pFont, nOffset, 0 );
@@ -428,7 +428,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
if( !GetNextLine() &&
GetInfo().GetVsh() && !GetInfo().GetVsh()->IsPreview() &&
GetInfo().GetOpt().IsParagraph() && !GetTextFrame()->GetFollow() &&
- GetInfo().GetIdx() >= GetInfo().GetText().getLength() )
+ GetInfo().GetIdx() >= TextFrameIndex(GetInfo().GetText().getLength()))
{
const SwTmpEndPortion aEnd( *pEndTempl );
GetFnt()->ChgPhysFnt( GetInfo().GetVsh(), *pOut );
@@ -460,7 +460,7 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
// GetInfo().Y() must be current baseline
SwTwips nDiff = GetInfo().Y() + nTmpHeight - nTmpAscent - GetTextFrame()->getFrameArea().Bottom();
if( ( nDiff > 0 &&
- ( GetEnd() < GetInfo().GetText().getLength() ||
+ (GetEnd() < TextFrameIndex(GetInfo().GetText().getLength()) ||
( nDiff > nTmpHeight/2 && GetPrevLine() ) ) ) ||
(nDiff >= 0 && bNextUndersized) )
@@ -490,7 +490,8 @@ void SwTextPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
return;
}
// Reuse calculated underline font as much as possible.
- if ( GetInfo().GetUnderFnt() && GetInfo().GetIdx() + pPor->GetLen() <= GetInfo().GetUnderFnt()->GetEnd() + 1 )
+ if (GetInfo().GetUnderFnt() &&
+ GetInfo().GetIdx() + pPor->GetLen() <= GetInfo().GetUnderFnt()->GetEnd() + TextFrameIndex(1))
{
SwFont &rFont = GetInfo().GetUnderFnt()->GetFont();
const Color aColor = GetUnderColor( GetInfo().GetFont() );
@@ -536,47 +537,47 @@ void SwTextPainter::CheckSpecialUnderline( const SwLinePortion* pPor,
}
}
- const sal_Int32 nIndx = GetInfo().GetIdx();
- long nUnderEnd = 0;
+ const TextFrameIndex nIndx = GetInfo().GetIdx();
+ TextFrameIndex nUnderEnd(0);
const size_t nCnt = aUnderMulti.GetRangeCount();
// find the underline range the current portion is contained in
for( size_t i = 0; i < nCnt; ++i )
{
const Range& rRange = aUnderMulti.GetRange( i );
- if( nUnderEnd == rRange.Min() )
- nUnderEnd = rRange.Max();
- else if( nIndx >= rRange.Min() )
+ if (nUnderEnd == TextFrameIndex(rRange.Min()))
+ nUnderEnd = TextFrameIndex(rRange.Max());
+ else if (nIndx >= TextFrameIndex(rRange.Min()))
{
- nUnderEnd = rRange.Max();
+ nUnderEnd = TextFrameIndex(rRange.Max());
}
else
break;
}
if ( GetEnd() && GetEnd() <= nUnderEnd )
- nUnderEnd = GetEnd() - 1;
+ nUnderEnd = GetEnd() - TextFrameIndex(1);
// calculate the new common underline font
SwFont* pUnderlineFnt = nullptr;
Point aCommonBaseLine;
// check, if underlining is not isolated
- if ( nIndx + GetInfo().GetLen() < nUnderEnd + 1 )
+ if (nIndx + GetInfo().GetLen() < nUnderEnd + TextFrameIndex(1))
{
// here starts the algorithm for calculating the underline font
SwScriptInfo& rScriptInfo = GetInfo().GetParaPortion()->GetScriptInfo();
SwAttrIter aIter( *GetInfo().GetTextFrame()->GetTextNode(),
rScriptInfo );
- sal_Int32 nTmpIdx = nIndx;
+ TextFrameIndex nTmpIdx = nIndx;
sal_uLong nSumWidth = 0;
sal_uLong nSumHeight = 0;
sal_uLong nBold = 0;
sal_uInt16 nMaxBaseLineOfst = 0;
int nNumberOfPortions = 0;
- while( sal::static_int_cast<long>(nTmpIdx) <= nUnderEnd && pPor )
+ while (nTmpIdx <= nUnderEnd && pPor)
{
if ( pPor->IsFlyPortion() || pPor->IsFlyCntPortion() ||
pPor->IsBreakPortion() || pPor->IsMarginPortion() ||
commit 3dee2e45d8df3dfeb360dd505ffd784a19fe5f3c
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 16:46:46 2018 +0200
sw_redlinehide: trivial conversions in itrform2.cxx
Change-Id: I83c0dd85f2f6c68edb7a48928db68fb4e84e5387
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index c776d63ef553..260cf6705154 100755
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -68,10 +68,10 @@ namespace {
//! Calculates and sets optimal repaint offset for the current line
long lcl_CalcOptRepaint( SwTextFormatter &rThis,
SwLineLayout const &rCurr,
- const sal_Int32 nOldLineEnd,
+ TextFrameIndex nOldLineEnd,
const std::vector<long> &rFlyStarts );
//! Determine if we need to build hidden portions
- bool lcl_BuildHiddenPortion( const SwTextSizeInfo& rInf, sal_Int32 &rPos );
+ bool lcl_BuildHiddenPortion(const SwTextSizeInfo& rInf, TextFrameIndex &rPos);
// Check whether the two font has the same border
bool lcl_HasSameBorder(const SwFont& rFirst, const SwFont& rSecond);
@@ -95,15 +95,15 @@ void SwTextFormatter::CtorInitTextFormatter( SwTextFrame *pNewFrame, SwTextForma
bTruncLines = false;
nCntEndHyph = 0;
nCntMidHyph = 0;
- nLeftScanIdx = COMPLETE_STRING;
- nRightScanIdx = 0;
+ nLeftScanIdx = TextFrameIndex(COMPLETE_STRING);
+ nRightScanIdx = TextFrameIndex(0);
m_nHintEndIndex = 0;
m_pFirstOfBorderMerge = nullptr;
- if( m_nStart > GetInfo().GetText().getLength() )
+ if (m_nStart > TextFrameIndex(GetInfo().GetText().getLength()))
{
OSL_ENSURE( false, "+SwTextFormatter::CTOR: bad offset" );
- m_nStart = GetInfo().GetText().getLength();
+ m_nStart = TextFrameIndex(GetInfo().GetText().getLength());
}
}
@@ -159,8 +159,8 @@ SwLinePortion *SwTextFormatter::Underflow( SwTextFormatInfo &rInf )
// line again.
// Can be seen in 8081.sdw, if you enter text in the first line
- const sal_Int32 nSoftHyphPos = rInf.GetSoftHyphPos();
- const sal_Int32 nUnderScorePos = rInf.GetUnderScorePos();
+ TextFrameIndex const nSoftHyphPos = rInf.GetSoftHyphPos();
+ TextFrameIndex const nUnderScorePos = rInf.GetUnderScorePos();
// Save flys and set to 0, or else segmentation fault
// Not ClearFly(rInf) !
@@ -398,8 +398,8 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
while( pPor && !rInf.IsStop() )
{
- OSL_ENSURE( rInf.GetLen() < COMPLETE_STRING &&
- rInf.GetIdx() <= rInf.GetText().getLength(),
+ OSL_ENSURE(rInf.GetLen() < TextFrameIndex(COMPLETE_STRING) &&
+ rInf.GetIdx() <= TextFrameIndex(rInf.GetText().getLength()),
"SwTextFormatter::BuildPortions: bad length in info" );
// We have to check the script for fields in order to set the
@@ -435,7 +435,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
else
{
const OUString& rText = rInf.GetText();
- sal_Int32 nIdx = rInf.GetIdx();
+ sal_Int32 nIdx = sal_Int32(rInf.GetIdx());
bAllowBehind = nIdx < rText.getLength() && rCC.isLetterNumeric(rText, nIdx);
}
@@ -462,10 +462,10 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
}
else if ( rInf.GetIdx() )
{
- bAllowBefore = rCC.isLetterNumeric( rInf.GetText(), rInf.GetIdx() - 1 );
+ bAllowBefore = rCC.isLetterNumeric(rInf.GetText(), sal_Int32(rInf.GetIdx()) - 1);
// Note: ScriptType returns values in [1,4]
if ( bAllowBefore )
- nLstActual = SwFontScript(m_pScriptInfo->ScriptType( rInf.GetIdx() - 1 ) - 1);
+ nLstActual = SwFontScript(m_pScriptInfo->ScriptType(rInf.GetIdx() - TextFrameIndex(1)) - 1);
}
nLstHeight /= 5;
@@ -758,7 +758,7 @@ void SwTextFormatter::CalcAscent( SwTextFormatInfo &rInf, SwLinePortion *pPor )
// i#89179
// tab portion representing the list tab of a list label gets the
// same height and ascent as the corresponding number portion
- else if ( pPor->InTabGrp() && pPor->GetLen() == 0 &&
+ else if ( pPor->InTabGrp() && pPor->GetLen() == TextFrameIndex(0) &&
rInf.GetLast() && rInf.GetLast()->InNumberGrp() &&
static_cast<const SwNumberPortion*>(rInf.GetLast())->HasFont() )
{
@@ -886,17 +886,16 @@ SwTextPortion *SwTextFormatter::WhichTextPor( SwTextFormatInfo &rInf ) const
// Only at the End!
// If pCurr does not have a width, it can however already have content.
// E.g. for non-displayable characters
- if (rInf.GetText()[rInf.GetIdx()]==CH_TXT_ATR_FIELDSTART)
+ auto const ch(rInf.GetText()[sal_Int32(rInf.GetIdx())]);
+ if (ch == CH_TXT_ATR_FIELDSTART)
pPor = new SwFieldMarkPortion();
- else if (rInf.GetText()[rInf.GetIdx()]==CH_TXT_ATR_FIELDEND)
+ else if (ch == CH_TXT_ATR_FIELDEND)
pPor = new SwFieldMarkPortion();
- else if (rInf.GetText()[rInf.GetIdx()]==CH_TXT_ATR_FORMELEMENT)
+ else if (ch == CH_TXT_ATR_FORMELEMENT)
{
- SwTextNode *pNd = rInf.GetTextFrame()->GetTextNode();
- const SwDoc *doc = pNd->GetDoc();
- SwIndex aIndex(pNd, rInf.GetIdx());
- SwPosition aPosition(*pNd, aIndex);
- sw::mark::IFieldmark *pBM = doc->getIDocumentMarkAccess()->getFieldmarkFor(aPosition);
+ SwTextFrame const*const pFrame(rInf.GetTextFrame());
+ SwPosition aPosition(pFrame->MapViewToModelPos(rInf.GetIdx()));
+ sw::mark::IFieldmark *pBM = pFrame->GetDoc().getIDocumentMarkAccess()->getFieldmarkFor(aPosition);
OSL_ENSURE(pBM != nullptr, "Where is my form field bookmark???");
if (pBM != nullptr)
{
@@ -947,8 +946,8 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf )
SwTextPortion *pPor = WhichTextPor( rInf );
// until next attribute change:
- const sal_Int32 nNextAttr = GetNextAttr();
- sal_Int32 nNextChg = std::min( nNextAttr, rInf.GetText().getLength() );
+ const TextFrameIndex nNextAttr = GetNextAttr();
+ TextFrameIndex nNextChg = std::min(nNextAttr, TextFrameIndex(rInf.GetText().getLength()));
// end of script type:
const sal_Int32 nNextScript = m_pScriptInfo->NextScriptChg( rInf.GetIdx() );
@@ -971,7 +970,7 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf )
// It follows that a line with a lot of blanks is processed incorrectly.
// Therefore we increase from factor 2 to 8 (due to negative kerning).
- pPor->SetLen(1);
+ pPor->SetLen(TextFrameIndex(1));
CalcAscent( rInf, pPor );
const SwFont* pTmpFnt = rInf.GetFont();
@@ -979,9 +978,9 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf )
sal_Int32( pPor->GetAscent() ) ) / 8;
if ( !nExpect )
nExpect = 1;
- nExpect = rInf.GetIdx() + (rInf.GetLineWidth() / nExpect);
- if( nExpect > rInf.GetIdx() && nNextChg > nExpect )
- nNextChg = std::min( nExpect, rInf.GetText().getLength() );
+ nExpect = sal_Int32(rInf.GetIdx()) + (rInf.GetLineWidth() / nExpect);
+ if (TextFrameIndex(nExpect) > rInf.GetIdx() && nNextChg > TextFrameIndex(nExpect))
+ nNextChg = TextFrameIndex(std::min(nExpect, rInf.GetText().getLength()));
// we keep an invariant during method calls:
// there are no portion ending characters like hard spaces
@@ -1231,7 +1230,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
// Check for Hidden Portion:
if ( !pPor )
{
- sal_Int32 nEnd = rInf.GetIdx();
+ TextFrameIndex nEnd = rInf.GetIdx();
if ( ::lcl_BuildHiddenPortion( rInf, nEnd ) )
pPor = new SwHiddenTextPortion( nEnd - rInf.GetIdx() );
}
@@ -1245,7 +1244,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
{
// We open a multiportion part, if we enter a multi-line part
// of the paragraph.
- sal_Int32 nEnd = rInf.GetIdx();
+ TextFrameIndex nEnd = rInf.GetIdx();
SwMultiCreator* pCreate = rInf.GetMultiCreator( nEnd, pMulti );
if( pCreate )
{
@@ -1257,7 +1256,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
{
pTmp = new SwRubyPortion( *pCreate, *rInf.GetFont(),
*GetTextFrame()->GetTextNode()->getIDocumentSettingAccess(),
- nEnd, 0, rInf );
+ nEnd, TextFrameIndex(0), rInf );
}
else if( SwMultiCreatorId::Rotate == pCreate->nId )
pTmp = new SwRotatedPortion( *pCreate, nEnd,
@@ -1287,7 +1286,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
}
else
{
- if( rInf.GetIdx() >= rInf.GetText().getLength() )
+ if (rInf.GetIdx() >= TextFrameIndex(rInf.GetText().getLength()))
{
rInf.SetFull(true);
CalcFlyWidth( rInf );
@@ -1370,7 +1369,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
// if a portion is created despite there being a pending RestPortion,
// then it is a field which has been split (e.g. because it contains a Tab)
if( pPor && rInf.GetRest() )
- pPor->SetLen( 0 );
+ pPor->SetLen(TextFrameIndex(0));
// robust:
if( !pPor || rInf.IsStop() )
@@ -1409,9 +1408,10 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
if ( 0 != nDir )
{
delete pPor;
- pPor = new SwRotatedPortion( rInf.GetIdx() + 1, 900 == nDir ?
- DIR_BOTTOM2TOP :
- DIR_TOP2BOTTOM );
+ pPor = new SwRotatedPortion(rInf.GetIdx() + TextFrameIndex(1),
+ 900 == nDir
+ ? DIR_BOTTOM2TOP
+ : DIR_TOP2BOTTOM );
}
}
}
@@ -1425,9 +1425,9 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf )
if ( 0 != nDir )
{
delete pPor;
- pPor = new SwRotatedPortion( 0, 900 == nDir ?
- DIR_BOTTOM2TOP :
- DIR_TOP2BOTTOM );
+ pPor = new SwRotatedPortion(TextFrameIndex(0), 900 == nDir
+ ? DIR_BOTTOM2TOP
+ : DIR_TOP2BOTTOM );
rInf.SetNumDone( false );
rInf.SetFootnoteDone( false );
@@ -1470,8 +1470,8 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
// For the formatting routines, we set pOut to the reference device.
SwHookOut aHook( GetInfo() );
- if( GetInfo().GetLen() < GetInfo().GetText().getLength() )
- GetInfo().SetLen( GetInfo().GetText().getLength() );
+ if (GetInfo().GetLen() < TextFrameIndex(GetInfo().GetText().getLength()))
+ GetInfo().SetLen(TextFrameIndex(GetInfo().GetText().getLength()));
bool bBuild = true;
SetFlyInCntBase( false );
@@ -1497,7 +1497,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
// for an optimal repaint rectangle, we want to compare fly portions
// before and after the BuildPortions call
const bool bOptimizeRepaint = AllowRepaintOpt();
- const sal_Int32 nOldLineEnd = nStartPos + m_pCurr->GetLen();
+ TextFrameIndex const nOldLineEnd = nStartPos + m_pCurr->GetLen();
std::vector<long> flyStarts;
// these are the conditions for a fly position comparison
@@ -1539,7 +1539,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
if( GetInfo().IsStop() )
{
- m_pCurr->SetLen( 0 );
+ m_pCurr->SetLen(TextFrameIndex(0));
m_pCurr->Height( GetFrameRstHeight() + 1 );
m_pCurr->SetRealHeight( GetFrameRstHeight() + 1 );
m_pCurr->Width(0);
@@ -1594,7 +1594,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
if ( xSaveField )
GetInfo().SetRest( new SwFieldPortion( *xSaveField ) );
- m_pCurr->SetLen( 0 );
+ m_pCurr->SetLen(TextFrameIndex(0));
m_pCurr->Width(0);
m_pCurr->Truncate();
}
@@ -1639,7 +1639,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos)
// delete master copy of rest portion
xSaveField.reset();
- sal_Int32 nNewStart = nStartPos + m_pCurr->GetLen();
+ TextFrameIndex const nNewStart = nStartPos + m_pCurr->GetLen();
// adjust text if kana compression is enabled
if ( GetInfo().CompressLine() )
@@ -1723,8 +1723,9 @@ void SwTextFormatter::CalcRealHeight( bool bNewLine )
// consider register-true and so on. Unfortunately an empty line can be at
// the end of a paragraph (empty paragraphs or behind a Shift-Return),
// which should consider the register.
- if( !m_pCurr->IsDummy() || ( !m_pCurr->GetNext() &&
- GetStart() >= GetTextFrame()->GetText().getLength() && !bNewLine ) )
+ if (!m_pCurr->IsDummy() || (!m_pCurr->GetNext()
+ && GetStart() >= TextFrameIndex(GetTextFrame()->GetText().getLength())
+ && !bNewLine))
{
const SvxLineSpacingItem *pSpace = m_aLineInf.GetLineSpacing();
if( pSpace )
@@ -1953,10 +1954,12 @@ bool SwTextFormatter::AllowRepaintOpt() const
}
// Again another special case: invisible SoftHyphs
- const sal_Int32 nReformat = GetInfo().GetReformatStart();
- if( bOptimizeRepaint && COMPLETE_STRING != nReformat )
+ const TextFrameIndex nReformat = GetInfo().GetReformatStart();
+ if (bOptimizeRepaint && TextFrameIndex(COMPLETE_STRING) != nReformat)
{
- const sal_Unicode cCh = nReformat >= GetInfo().GetText().getLength() ? 0 : GetInfo().GetText()[ nReformat ];
+ const sal_Unicode cCh = nReformat >= TextFrameIndex(GetInfo().GetText().getLength())
+ ? 0
+ : GetInfo().GetText()[ sal_Int32(nReformat) ];
bOptimizeRepaint = ( CH_TXTATR_BREAKWORD != cCh && CH_TXTATR_INWORD != cCh )
|| ! GetInfo().HasHint( nReformat );
}
@@ -2083,7 +2086,7 @@ void SwTextFormatter::UpdatePos( SwLineLayout *pCurrent, Point aStart,
// jump to end of the bidi portion
aSt.AdjustX(pLay->Width() );
- sal_Int32 nStIdx = aTmpInf.GetIdx();
+ TextFrameIndex nStIdx = aTmpInf.GetIdx();
do
{
UpdatePos( pLay, aSt, nStIdx, bAlways );
@@ -2343,7 +2346,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
// Although no text is left, we need to format another line,
// because also empty lines need to avoid a Fly with no wrapping.
- if( bFullLine && rInf.GetIdx() == rInf.GetText().getLength() )
+ if (bFullLine && rInf.GetIdx() == TextFrameIndex(rInf.GetText().getLength()))
{
rInf.SetNewLine( true );
// We know that for dummies, it holds ascent == height
@@ -2394,7 +2397,7 @@ void SwTextFormatter::CalcFlyWidth( SwTextFormatInfo &rInf )
}
else
{
- if( rInf.GetIdx() == rInf.GetText().getLength() )
+ if (rInf.GetIdx() == TextFrameIndex(rInf.GetText().getLength()))
{
// Don't use nHeight, or we have a huge descent
pFly->Height( pLast->Height() );
@@ -2590,9 +2593,11 @@ void SwTextFormatter::MergeCharacterBorder( SwLinePortion& rPortion, SwLinePorti
// Get next portion's font
bool bSeek = false;
- if( !rInf.IsFull() && // Not the last portion of the line (in case of line break)
- rInf.GetIdx() + rPortion.GetLen() != rInf.GetText().getLength() ) // Not the last portion of the paragraph
+ if (!rInf.IsFull() && // Not the last portion of the line (in case of line break)
+ rInf.GetIdx() + rPortion.GetLen() != TextFrameIndex(rInf.GetText().getLength())) // Not the last portion of the paragraph
+ {
bSeek = Seek(rInf.GetIdx() + rPortion.GetLen());
+ }
// Don't join the next portion if SwKernPortion sits between two different boxes.
bool bDisconnect = rPortion.IsKernPortion() && !rPortion.GetJoinBorderWithPrev();
// If next portion has the same border then merge
@@ -2660,7 +2665,7 @@ namespace {
// calculates and sets optimal repaint offset for the current line
long lcl_CalcOptRepaint( SwTextFormatter &rThis,
SwLineLayout const &rCurr,
- const sal_Int32 nOldLineEnd,
+ TextFrameIndex const nOldLineEnd,
const std::vector<long> &rFlyStarts )
{
SwTextFormatInfo& txtFormatInfo = rThis.GetInfo();
@@ -2669,7 +2674,7 @@ namespace {
// something of our text has moved to the next line
return 0;
- sal_Int32 nReformat = std::min<sal_Int32>( txtFormatInfo.GetReformatStart(), nOldLineEnd );
+ TextFrameIndex nReformat = std::min(txtFormatInfo.GetReformatStart(), nOldLineEnd);
// in case we do not have any fly in our line, our repaint position
// is the changed position - 1
@@ -2681,16 +2686,16 @@ namespace {
// limit for the repaint offset
const long nFormatRepaint = txtFormatInfo.GetPaintOfst();
- if ( nReformat < txtFormatInfo.GetLineStart() + 3 )
+ if (nReformat < txtFormatInfo.GetLineStart() + TextFrameIndex(3))
return 0;
// step back two positions for smoother repaint
- nReformat -= 2;
+ nReformat -= TextFrameIndex(2);
// i#28795, i#34607, i#38388
// step back more characters, this is required by complex scripts
// e.g., for Khmer (thank you, Javier!)
- static const sal_Int32 nMaxContext = 10;
+ static const TextFrameIndex nMaxContext(10);
if (nReformat > txtFormatInfo.GetLineStart() + nMaxContext)
nReformat = nReformat - nMaxContext;
else
@@ -2729,7 +2734,7 @@ namespace {
long nPOfst = 0;
size_t nCnt = 0;
long nX = 0;
- sal_Int32 nIdx = rThis.GetInfo().GetLineStart();
+ TextFrameIndex nIdx = rThis.GetInfo().GetLineStart();
SwLinePortion* pPor = rCurr.GetFirstPortion();
while ( pPor )
@@ -2758,7 +2763,7 @@ namespace {
}
// Determine if we need to build hidden portions
- bool lcl_BuildHiddenPortion( const SwTextSizeInfo& rInf, sal_Int32 &rPos )
+ bool lcl_BuildHiddenPortion(const SwTextSizeInfo& rInf, TextFrameIndex & rPos)
{
// Only if hidden text should not be shown:
// if ( rInf.GetVsh() && rInf.GetVsh()->GetWin() && rInf.GetOpt().IsShowHiddenChar() )
@@ -2768,8 +2773,8 @@ namespace {
return false;
const SwScriptInfo& rSI = rInf.GetParaPortion()->GetScriptInfo();
- sal_Int32 nHiddenStart;
- sal_Int32 nHiddenEnd;
+ TextFrameIndex nHiddenStart;
+ TextFrameIndex nHiddenEnd;
rSI.GetBoundsOfHiddenRange( rPos, nHiddenStart, nHiddenEnd );
if ( nHiddenEnd )
{
commit 6f64288ce44fc3232cb0a48060de3c259e260723
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 16:00:22 2018 +0200
sw_redlinehide: trivial conversions in itrcrsr.cxx
Change-Id: Ic402f6f2d8bbe92b7cfa65f5f4018ad47f44eed8
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 143f959fb85c..44c9212ff233 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -101,8 +101,8 @@ static void lcl_GetCharRectInsideField( SwTextSizeInfo& rInf, SwRect& rOrig,
// get script for field portion
rInf.GetFont()->SetActual( SwScriptInfo::WhichFont( 0, pString, nullptr ) );
- sal_Int32 nOldLen = pPor->GetLen();
- const_cast<SwLinePortion*>(pPor)->SetLen( nLen - 1 );
+ TextFrameIndex const nOldLen = pPor->GetLen();
+ const_cast<SwLinePortion*>(pPor)->SetLen(TextFrameIndex(nLen - 1));
const SwTwips nX1 = pPor->GetLen() ?
pPor->GetTextSize( rInf ).Width() :
0;
@@ -110,7 +110,7 @@ static void lcl_GetCharRectInsideField( SwTextSizeInfo& rInf, SwRect& rOrig,
SwTwips nX2 = 0;
if ( rCMS.m_bRealWidth )
{
- const_cast<SwLinePortion*>(pPor)->SetLen( nLen );
+ const_cast<SwLinePortion*>(pPor)->SetLen(TextFrameIndex(nLen));
nX2 = pPor->GetTextSize( rInf ).Width();
}
@@ -403,7 +403,7 @@ bool SwTextCursor::GetEndCharRect(SwRect* pOrig, const TextFrameIndex nOfst,
{
// 8810: Master line RightMargin, after that LeftMargin
const bool bRet = GetCharRect( pOrig, nOfst, pCMS, nMax );
- bRightMargin = nOfst >= GetEnd() && nOfst < GetInfo().GetText().getLength();
+ bRightMargin = nOfst >= GetEnd() && nOfst < TextFrameIndex(GetInfo().GetText().getLength());
return bRet;
}
@@ -502,7 +502,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
SwTwips nTmpFirst = 0;
SwLinePortion *pPor = m_pCurr->GetFirstPortion();
SwBidiPortion* pLastBidiPor = nullptr;
- sal_Int32 nLastBidiIdx = -1;
+ TextFrameIndex nLastBidiIdx(-1);
SwTwips nLastBidiPorWidth = 0;
std::deque<sal_uInt16>* pKanaComp = m_pCurr->GetpKanaComp();
sal_uInt16 nSpaceIdx = 0;
@@ -593,9 +593,10 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
// For common portions (including BidiPortions) we want to add
// the portion width to nX. For MultiPortions, nExtra = 0,
// therefore we go to the 'else' branch and start a recursion.
- const sal_Int32 nExtra = pPor->IsMultiPortion() &&
- ! static_cast<SwMultiPortion*>(pPor)->IsBidi() &&
- ! bWidth ? 0 : 1;
+ const TextFrameIndex nExtra( (pPor->IsMultiPortion()
+ && !static_cast<SwMultiPortion*>(pPor)->IsBidi()
+ && !bWidth)
+ ? 0 : 1 );
if ( aInf.GetIdx() + pPor->GetLen() < nOfst + nExtra )
{
if ( pPor->InSpaceGrp() && nSpaceAdd )
@@ -703,7 +704,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
// In a multi-portion we use GetCharRect()-function
// recursively and must add the x-position
// of the multi-portion.
- sal_Int32 nOldStart = m_nStart;
+ TextFrameIndex const nOldStart = m_nStart;
SwTwips nOldY = m_nY;
sal_uInt8 nOldProp = GetPropFont();
m_nStart = aInf.GetIdx();
@@ -872,7 +873,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
}
if ( pPor->PrtWidth() )
{
- sal_Int32 nOldLen = pPor->GetLen();
+ TextFrameIndex const nOldLen = pPor->GetLen();
pPor->SetLen( nOfst - aInf.GetIdx() );
aInf.SetLen( pPor->GetLen() );
if( nX || !pPor->InNumberGrp() )
@@ -889,7 +890,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
nX += pPor->CalcSpacing( nSpaceAdd, aInf );
if( bWidth )
{
- pPor->SetLen( pPor->GetLen() + 1 );
+ pPor->SetLen(pPor->GetLen() + TextFrameIndex(1));
aInf.SetLen( pPor->GetLen() );
aInf.SetOnWin( false ); // no BULLETs!
nTmp += pPor->GetTextSize( aInf ).Width();
@@ -910,7 +911,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
{
SwDropPortion* pDrop = static_cast<SwDropPortion*>(pPor);
const SwDropPortionPart* pCurrPart = pDrop->GetPart();
- sal_Int16 nSumLength = 0;
+ TextFrameIndex nSumLength(0);
while( pCurrPart && (nSumLength += pCurrPart->GetLen()) < nOfst - aInf.GetIdx() )
{
pCurrPart = pCurrPart->GetFollow();
@@ -1057,7 +1058,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
nPorAscent = pPor->GetAscent();
}
SwTwips nTmp;
- if( 2 > pPor->GetLen() )
+ if (TextFrameIndex(2) > pPor->GetLen())
{
nTmp = pPor->Width();
if ( pPor->InSpaceGrp() && nSpaceAdd )
@@ -1066,8 +1067,8 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
else
{
const bool bOldOnWin = aInf.OnWin();
- sal_Int32 nOldLen = pPor->GetLen();
- pPor->SetLen( 1 );
+ TextFrameIndex const nOldLen = pPor->GetLen();
+ pPor->SetLen( TextFrameIndex(1) );
aInf.SetLen( pPor->GetLen() );
SeekAndChg( aInf );
aInf.SetOnWin( false ); // no BULLETs!
@@ -1124,7 +1125,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst,
{
OSL_ENSURE( static_cast<const SwMultiPortion*>(pLast)->IsBidi(),
"Non-BidiPortion inside BidiPortion" );
- sal_Int32 nIdx = aInf.GetIdx();
+ TextFrameIndex const nIdx = aInf.GetIdx();
// correct the index before using CalcSpacing.
aInf.SetIdx(nLastBidiIdx);
pOrig->Pos().AdjustX(pLast->Width() +
@@ -1173,7 +1174,7 @@ bool SwTextCursor::GetCharRect( SwRect* pOrig, TextFrameIndex const nOfst,
// Indicates that a position inside a special portion (field, number portion)
// is requested.
const bool bSpecialPos = pCMS && pCMS->m_pSpecialPos;
- sal_Int32 nFindOfst = nOfst;
+ TextFrameIndex nFindOfst = nOfst;
if ( bSpecialPos )
{
@@ -1260,7 +1261,7 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
GetAdjusted();
const OUString &rText = GetInfo().GetText();
- sal_Int32 nOffset = 0;
+ TextFrameIndex nOffset(0);
// x is the horizontal offset within the line.
SwTwips x = rPoint.X();
@@ -1287,12 +1288,12 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
// If there are attribute changes in the line, search for the paragraph,
// in which nX is situated.
SwLinePortion *pPor = m_pCurr->GetFirstPortion();
- sal_Int32 nCurrStart = m_nStart;
+ TextFrameIndex nCurrStart = m_nStart;
bool bHolePortion = false;
bool bLastHyph = false;
std::deque<sal_uInt16> *pKanaComp = m_pCurr->GetpKanaComp();
- sal_Int32 nOldIdx = GetInfo().GetIdx();
+ TextFrameIndex const nOldIdx = GetInfo().GetIdx();
sal_uInt16 nSpaceIdx = 0;
size_t nKanaIdx = 0;
long nSpaceAdd = m_pCurr->IsSpaceAdd() ? m_pCurr->GetLLSpaceAdd( 0 ) : 0;
@@ -1403,7 +1404,7 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
const_cast<SwTextSizeInfo&>(GetInfo()).SetIdx( nOldIdx );
- sal_Int32 nLength = pPor->GetLen();
+ TextFrameIndex nLength = pPor->GetLen();
const bool bFieldInfo = pCMS && pCMS->m_bFieldInfo;
@@ -1445,14 +1446,14 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
}
}
if( !nCurrStart )
- return 0;
+ return TextFrameIndex(0);
// 7849, 7816: pPor->GetHyphPortion is mandatory!
if( bHolePortion || ( !bRightAllowed && bLastHyph ) ||
( pPor->IsMarginPortion() && !pPor->GetPortion() &&
// 46598: Consider the situation: We might end up behind the last character,
// in the last line of a centered paragraph
- nCurrStart < rText.getLength() ) )
+ nCurrStart < TextFrameIndex(rText.getLength())))
--nCurrStart;
else if( pPor->InFieldGrp() && static_cast<SwFieldPortion*>(pPor)->IsFollow()
&& nWidth > nX )
@@ -1470,7 +1471,7 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
}
return nCurrStart;
}
- if ( 1 == nLength )
+ if (TextFrameIndex(1) == nLength)
{
if ( nWidth )
{
@@ -1525,7 +1526,7 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
// Skip space at the end of the line
if( bLastPortion && (m_pCurr->GetNext() || m_pFrame->GetFollow() )
- && rText[nCurrStart + nLength - 1] == ' ' )
+ && rText[sal_Int32(nCurrStart + nLength) - 1] == ' ' )
--nLength;
if( nWidth > nX ||
@@ -1618,14 +1619,14 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
sal_uInt16 nSumWidth = 0;
sal_uInt16 nSumBorderWidth = 0;
// Shift offset with the right and left border of previous parts and left border of actual one
- while( pCurrPart && nSumWidth <= nX - nCurrStart )
+ while (pCurrPart && nSumWidth <= nX - sal_Int32(nCurrStart))
{
nSumWidth += pCurrPart->GetWidth();
if( pCurrPart->GetFont().GetLeftBorder() && !pCurrPart->GetJoinBorderWithPrev() )
{
nSumBorderWidth += pCurrPart->GetFont().GetLeftBorderSpace();
}
- if( nSumWidth <= nX - nCurrStart && pCurrPart->GetFont().GetRightBorder() &&
+ if (nSumWidth <= nX - sal_Int32(nCurrStart) && pCurrPart->GetFont().GetRightBorder() &&
!pCurrPart->GetJoinBorderWithNext() )
{
nSumBorderWidth += pCurrPart->GetFont().GetRightBorderSpace();
@@ -1644,7 +1645,7 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
if ( nSpaceAdd )
{
- sal_Int32 nCharCnt = 0;
+ TextFrameIndex nCharCnt(0);
// #i41860# Thai justified alignment needs some
// additional information:
aDrawInf.SetNumberOfBlanks( pPor->InTextGrp() ?
@@ -1672,7 +1673,7 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
if ( pPor->InFieldGrp() && pCMS && pCMS->m_pSpecialPos )
{
pCMS->m_pSpecialPos->nCharOfst = nLength;
- nLength = 0;
+ nLength = TextFrameIndex(0);
}
// set cursor bidi level
@@ -1719,7 +1720,7 @@ TextFrameIndex SwTextCursor::GetCursorOfst( SwPosition *pPos, const Point &rPoin
// 6776: The pIter->GetCursorOfst is returning here
// from a nesting with COMPLETE_STRING.
- return COMPLETE_STRING;
+ return TextFrameIndex(COMPLETE_STRING);
}
}
else
commit 12951ece4074315a651d0c48e06eaf72dd735e72
Author: Michael Stahl <Michael.Stahl at cib.de>
Date: Wed May 9 14:57:26 2018 +0200
sw_redlinehide: trivial conversions in itradj.cxx
Change-Id: Ifc9cc3187e16e63aa468e31efa454c70fd907f50
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index ee37e1785040..524454d7a093 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -44,7 +44,7 @@ void SwTextAdjuster::FormatBlock( )
const SwLinePortion *pFly = nullptr;
bool bSkip = !IsLastBlock() &&
- m_nStart + m_pCurr->GetLen() >= GetInfo().GetText().getLength();
+ m_nStart + m_pCurr->GetLen() >= TextFrameIndex(GetInfo().GetText().getLength());
// Multi-line fields are tricky, because we need to check whether there are
// any other text portions in the paragraph.
@@ -102,7 +102,7 @@ void SwTextAdjuster::FormatBlock( )
}
}
- const sal_Int32 nOldIdx = GetInfo().GetIdx();
+ const TextFrameIndex nOldIdx = GetInfo().GetIdx();
GetInfo().SetIdx( m_nStart );
CalcNewBlock( m_pCurr, pFly );
GetInfo().SetIdx( nOldIdx );
@@ -110,14 +110,14 @@ void SwTextAdjuster::FormatBlock( )
}
static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf, SwTextIter& rItr,
- sal_Int32& rKashidas, sal_Int32& nGluePortion )
+ sal_Int32& rKashidas, TextFrameIndex& nGluePortion)
{
if ( rInf.GetOut()->GetMinKashida() <= 0 )
return false;
// i60594 validate Kashida justification
- sal_Int32 nIdx = rItr.GetStart();
- sal_Int32 nEnd = rItr.GetEnd();
+ TextFrameIndex nIdx = rItr.GetStart();
+ TextFrameIndex nEnd = rItr.GetEnd();
// Note on calling KashidaJustify():
// Kashida positions may be marked as invalid. Therefore KashidaJustify may return the clean
@@ -138,7 +138,7 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
while ( rKashidas && nIdx < nEnd )
{
rItr.SeekAndChgAttrIter( nIdx, rInf.GetOut() );
- sal_Int32 nNext = rItr.GetNextAttr();
+ TextFrameIndex nNext = rItr.GetNextAttr();
// is there also a script change before?
// if there is, nNext should point to the script change
@@ -146,7 +146,7 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
if( nNextScript < nNext )
nNext = nNextScript;
- if ( nNext == COMPLETE_STRING || nNext > nEnd )
+ if (nNext == TextFrameIndex(COMPLETE_STRING) || nNext > nEnd)
nNext = nEnd;
sal_Int32 nKashidasInAttr = rSI.KashidaJustify ( nullptr, nullptr, nIdx, nNext - nIdx );
if (nKashidasInAttr > 0)
@@ -182,7 +182,7 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
}
static bool lcl_CheckKashidaWidth ( SwScriptInfo& rSI, SwTextSizeInfo& rInf, SwTextIter& rItr, sal_Int32& rKashidas,
- sal_Int32& nGluePortion, const long nGluePortionWidth, long& nSpaceAdd )
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list