[Libreoffice-commits] core.git: svx/source sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jan 18 16:17:39 UTC 2019
svx/source/dialog/srchdlg.cxx | 19 +++++--------------
sw/source/uibase/uiview/viewsrch.cxx | 24 +++++-------------------
2 files changed, 10 insertions(+), 33 deletions(-)
New commits:
commit dba14e6a75b56b75c32cb7f07a56cfc7f13112e5
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Jan 18 16:23:18 2019 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Jan 18 17:17:13 2019 +0100
Ensure itemset ranges are sorted
What used to create sorted range automatically in FID_SEARCH_SEARCHSET
handler in SwView::ExecSearch, over time turned into unsorted. this
prevents using MergeRange on the sets created from the range list; see
https://ci.libreoffice.org/job/gerrit_linux_clang_dbgutil/24448/consoleFull
> svl/source/items/itemset.cxx:641:
> void SfxItemSet::MergeRange(sal_uInt16, sal_uInt16):
> Assertion `!pRange[2] || (pRange[2] > pRange[1] && pRange[2] - pRange[1] > 1)' failed.
So let's just use MergeRange in the SwView::ExecSearch itself, which
would ensure early detection if the initial list gets unsorted.
Change-Id: Id0232190f850e3feb463adfcb3153eafbaad7d9b
Reviewed-on: https://gerrit.libreoffice.org/66607
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index 91f62a0eebae..d005a1f5869a 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -1999,23 +1999,14 @@ IMPL_LINK_NOARG(SvxSearchDialog, FormatHdl_Impl, Button*, void)
if ( !pSh || !pImpl->pRanges )
return;
- std::vector<sal_uInt16> aWhRanges;
-
- const sal_uInt16* pPtr = pImpl->pRanges.get();
- while (*pPtr)
- {
- aWhRanges.push_back(*pPtr++);
- }
+ SfxItemPool& rPool = pSh->GetPool();
+ SfxItemSet aSet(rPool, pImpl->pRanges.get());
- aWhRanges.push_back(SID_ATTR_PARA_MODEL);
- aWhRanges.push_back(SID_ATTR_PARA_MODEL);
+ aSet.MergeRange(SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL);
sal_uInt16 nBrushWhich = pSh->GetPool().GetWhich(SID_ATTR_BRUSH);
- aWhRanges.push_back(nBrushWhich);
- aWhRanges.push_back(nBrushWhich);
- aWhRanges.push_back(0);
- SfxItemPool& rPool = pSh->GetPool();
- SfxItemSet aSet(rPool, aWhRanges.data());
+ aSet.MergeRange(nBrushWhich, nBrushWhich);
+
OUString aTxt;
aSet.InvalidateAllItems();
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index a127c1a12241..94eb878621ef 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -442,7 +442,6 @@ void SwView::ExecSearch(SfxRequest& rReq)
/*10 */ RES_CHRATR_ROTATE, RES_CHRATR_ROTATE,
/*12 */ RES_CHRATR_SCALEW, RES_CHRATR_RELIEF,
/*14 */ RES_CHRATR_OVERLINE, RES_CHRATR_OVERLINE,
-// insert position for CJK/CTL attributes!
/*16 */ RES_PARATR_LINESPACING, RES_PARATR_HYPHENZONE,
/*18 */ RES_PARATR_REGISTER, RES_PARATR_REGISTER,
/*20 */ RES_PARATR_VERTALIGN, RES_PARATR_VERTALIGN,
@@ -451,33 +450,20 @@ void SwView::ExecSearch(SfxRequest& rReq)
/*26 */ 0
};
- static const sal_uInt16 aCJKAttr[] =
- {
- RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_WEIGHT,
- RES_CHRATR_EMPHASIS_MARK, RES_CHRATR_TWO_LINES,
- RES_PARATR_SCRIPTSPACE, RES_PARATR_FORBIDDEN_RULES
- };
- static const sal_uInt16 aCTLAttr[] =
- {
- RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_WEIGHT
- };
+ SfxItemSet aSet(m_pWrtShell->GetAttrPool(), aNormalAttr);
- std::vector<sal_uInt16> aArr;
- aArr.insert( aArr.begin(), aNormalAttr,
- aNormalAttr + SAL_N_ELEMENTS( aNormalAttr ));
if( SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
{
- aArr.insert( aArr.begin() + 16, aCTLAttr,
- aCTLAttr + SAL_N_ELEMENTS( aCTLAttr ));
+ aSet.MergeRange(RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_WEIGHT);
}
SvtCJKOptions aCJKOpt;
if( aCJKOpt.IsAnyEnabled() )
{
- aArr.insert( aArr.begin() + 16, aCJKAttr,
- aCJKAttr + SAL_N_ELEMENTS( aCJKAttr ));
+ aSet.MergeRange(RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_WEIGHT);
+ aSet.MergeRange(RES_CHRATR_EMPHASIS_MARK, RES_CHRATR_TWO_LINES);
+ aSet.MergeRange(RES_PARATR_SCRIPTSPACE, RES_PARATR_FORBIDDEN_RULES);
}
- SfxItemSet aSet( m_pWrtShell->GetAttrPool(), &aArr[0] );
sal_uInt16 nWhich = SID_SEARCH_SEARCHSET;
if ( FID_SEARCH_REPLACESET == nSlot )
More information about the Libreoffice-commits
mailing list