[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Dec 26 06:32:22 UTC 2018
sw/source/core/txtnode/ndtxt.cxx | 141 ++++++++-------------------------------
1 file changed, 30 insertions(+), 111 deletions(-)
New commits:
commit 6374249da32976a3375fa3d098da467578ffb4c1
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Tue Dec 25 20:40:16 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Wed Dec 26 07:32:02 2018 +0100
sw txtnode: code cleanup - triplicated code -> function
Since before if an invalid nWhich2 was given,
it just checked the value in nWhich1,
just set nWhich2 to nWhich1 in that case,
which really simplifies the logic.
Change-Id: I75f52566aa5260f629398076e817d778e0fd545a
Reviewed-on: https://gerrit.libreoffice.org/65599
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 3b15a3318180..07a69d87b0e7 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -4949,7 +4949,7 @@ namespace {
public:
HandleResetAttrAtTextNode( SwTextNode& rTextNode,
const sal_uInt16 nWhich1,
- const sal_uInt16 nWhich2 );
+ sal_uInt16 nWhich2 );
HandleResetAttrAtTextNode( SwTextNode& rTextNode,
const std::vector<sal_uInt16>& rWhichArr );
explicit HandleResetAttrAtTextNode( SwTextNode& rTextNode );
@@ -4962,105 +4962,26 @@ namespace {
bool mbUpdateListLevel;
bool mbUpdateListRestart;
bool mbUpdateListCount;
+
+ void init( const std::vector<sal_uInt16>& rWhichArr );
};
HandleResetAttrAtTextNode::HandleResetAttrAtTextNode( SwTextNode& rTextNode,
const sal_uInt16 nWhich1,
- const sal_uInt16 nWhich2 )
+ sal_uInt16 nWhich2 )
: mrTextNode( rTextNode ),
mbListStyleOrIdReset( false ),
mbUpdateListLevel( false ),
mbUpdateListRestart( false ),
mbUpdateListCount( false )
{
- bool bRemoveFromList( false );
- if ( nWhich2 != 0 && nWhich2 > nWhich1 )
- {
- // RES_PARATR_NUMRULE and RES_PARATR_LIST_ID
- if ( nWhich1 <= RES_PARATR_NUMRULE && RES_PARATR_NUMRULE <= nWhich2 )
- {
- bRemoveFromList = mrTextNode.GetNumRule() != nullptr;
- mbListStyleOrIdReset = true;
- }
- else if ( nWhich1 <= RES_PARATR_LIST_ID && RES_PARATR_LIST_ID <= nWhich2 )
- {
- bRemoveFromList = mrTextNode.GetpSwAttrSet() &&
- mrTextNode.GetpSwAttrSet()->GetItemState( RES_PARATR_LIST_ID, false ) == SfxItemState::SET;
- // #i92898#
- mbListStyleOrIdReset = true;
- }
-
- if ( !bRemoveFromList )
- {
- // RES_PARATR_LIST_LEVEL
- mbUpdateListLevel = ( nWhich1 <= RES_PARATR_LIST_LEVEL &&
- RES_PARATR_LIST_LEVEL <= nWhich2 &&
- mrTextNode.HasAttrListLevel() );
-
- // RES_PARATR_LIST_ISRESTART and RES_PARATR_LIST_RESTARTVALUE
- mbUpdateListRestart =
- ( nWhich1 <= RES_PARATR_LIST_ISRESTART && RES_PARATR_LIST_ISRESTART <= nWhich2 &&
- mrTextNode.IsListRestart() ) ||
- ( nWhich1 <= RES_PARATR_LIST_RESTARTVALUE && RES_PARATR_LIST_RESTARTVALUE <= nWhich2 &&
- mrTextNode.HasAttrListRestartValue() );
+ if ( nWhich2 < nWhich1 )
+ nWhich2 = nWhich1;
+ std::vector<sal_uInt16> rWhichArr;
+ for ( sal_uInt16 nWhich = nWhich1; nWhich <= nWhich2; ++nWhich )
+ rWhichArr.push_back( nWhich );
- // RES_PARATR_LIST_ISCOUNTED
- mbUpdateListCount =
- ( nWhich1 <= RES_PARATR_LIST_ISCOUNTED && RES_PARATR_LIST_ISCOUNTED <= nWhich2 &&
- !mrTextNode.IsCountedInList() );
- }
-
- // #i70748#
- // RES_PARATR_OUTLINELEVEL
- if ( nWhich1 <= RES_PARATR_OUTLINELEVEL && RES_PARATR_OUTLINELEVEL <= nWhich2 )
- {
- mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
- }
- }
- else
- {
- // RES_PARATR_NUMRULE and RES_PARATR_LIST_ID
- if ( nWhich1 == RES_PARATR_NUMRULE )
- {
- bRemoveFromList = mrTextNode.GetNumRule() != nullptr;
- mbListStyleOrIdReset = true;
- }
- else if ( nWhich1 == RES_PARATR_LIST_ID )
- {
- bRemoveFromList = mrTextNode.GetpSwAttrSet() &&
- mrTextNode.GetpSwAttrSet()->GetItemState( RES_PARATR_LIST_ID, false ) == SfxItemState::SET;
- // #i92898#
- mbListStyleOrIdReset = true;
- }
- // #i70748#
- // RES_PARATR_OUTLINELEVEL
- else if ( nWhich1 == RES_PARATR_OUTLINELEVEL )
- {
- mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
- }
-
- if ( !bRemoveFromList )
- {
- // RES_PARATR_LIST_LEVEL
- mbUpdateListLevel = nWhich1 == RES_PARATR_LIST_LEVEL &&
- mrTextNode.HasAttrListLevel();
-
- // RES_PARATR_LIST_ISRESTART and RES_PARATR_LIST_RESTARTVALUE
- mbUpdateListRestart = ( nWhich1 == RES_PARATR_LIST_ISRESTART &&
- mrTextNode.IsListRestart() ) ||
- ( nWhich1 == RES_PARATR_LIST_RESTARTVALUE &&
- mrTextNode.HasAttrListRestartValue() );
-
- // RES_PARATR_LIST_ISCOUNTED
- mbUpdateListCount = nWhich1 == RES_PARATR_LIST_ISCOUNTED &&
- !mrTextNode.IsCountedInList();
- }
- }
-
- if ( bRemoveFromList && mrTextNode.IsInList() )
- {
- mrTextNode.RemoveFromList();
- }
+ init( rWhichArr );
}
HandleResetAttrAtTextNode::HandleResetAttrAtTextNode( SwTextNode& rTextNode,
@@ -5071,11 +4992,30 @@ namespace {
mbUpdateListRestart( false ),
mbUpdateListCount( false )
{
+ init( rWhichArr );
+ }
+
+ HandleResetAttrAtTextNode::HandleResetAttrAtTextNode( SwTextNode& rTextNode )
+ : mrTextNode( rTextNode ),
+ mbListStyleOrIdReset( true ),
+ mbUpdateListLevel( false ),
+ mbUpdateListRestart( false ),
+ mbUpdateListCount( false )
+ {
+ if ( rTextNode.IsInList() )
+ {
+ rTextNode.RemoveFromList();
+ }
+ // #i70748#
+ mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
+ }
+
+ void HandleResetAttrAtTextNode::init( const std::vector<sal_uInt16>& rWhichArr )
+ {
bool bRemoveFromList( false );
{
for (const auto& rWhich : rWhichArr)
{
- // RES_PARATR_NUMRULE and RES_PARATR_LIST_ID
if ( rWhich == RES_PARATR_NUMRULE )
{
bRemoveFromList = bRemoveFromList ||
@@ -5087,15 +5027,10 @@ namespace {
bRemoveFromList = bRemoveFromList ||
( mrTextNode.GetpSwAttrSet() &&
mrTextNode.GetpSwAttrSet()->GetItemState( RES_PARATR_LIST_ID, false ) == SfxItemState::SET );
- // #i92898#
mbListStyleOrIdReset = true;
}
- // #i70748#
- // RES_PARATR_OUTLINELEVEL
else if ( rWhich == RES_PARATR_OUTLINELEVEL )
- {
mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
- }
if ( !bRemoveFromList )
{
@@ -5125,22 +5060,6 @@ namespace {
}
}
- HandleResetAttrAtTextNode::HandleResetAttrAtTextNode( SwTextNode& rTextNode )
- : mrTextNode( rTextNode ),
- mbListStyleOrIdReset( false ),
- mbUpdateListLevel( false ),
- mbUpdateListRestart( false ),
- mbUpdateListCount( false )
- {
- mbListStyleOrIdReset = true;
- if ( rTextNode.IsInList() )
- {
- rTextNode.RemoveFromList();
- }
- // #i70748#
- mrTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr();
- }
-
HandleResetAttrAtTextNode::~HandleResetAttrAtTextNode() COVERITY_NOEXCEPT_FALSE
{
if ( mbListStyleOrIdReset && !mrTextNode.IsInList() )
More information about the Libreoffice-commits
mailing list