Kaydet (Commit) bab27533 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:unusedenumconstants in EEControlBits

(*) remove effectivly unused enum constants

(*) tweak the plugins heuristics some more to remove false+ in this enum

(*) twweak the python post-processing step to avoid a KeyError

Change-Id: I2943ec94c00f71dcd049f5c9ef33db259c005ba3
Reviewed-on: https://gerrit.libreoffice.org/63709
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 2e6a38b7
......@@ -27,10 +27,12 @@ enum class BrowseMode
{
Modules = 0x01, // expected-error {{read Modules [loplugin:unusedenumconstants]}}
Top = 0x02, // expected-error {{write Top [loplugin:unusedenumconstants]}}
Bottom = 0x04, // expected-error {{read Bottom [loplugin:unusedenumconstants]}}
Left = 0x04, // expected-error {{write Left [loplugin:unusedenumconstants]}}
};
namespace o3tl
{
template <> struct typed_flags<BrowseMode> : is_typed_flags<BrowseMode, 0x3>
template <> struct typed_flags<BrowseMode> : is_typed_flags<BrowseMode, 0xf>
{
};
}
......@@ -42,6 +44,8 @@ int test2(BrowseMode nMode)
g_flags |= BrowseMode::Top;
return 0;
}
bool test2b(BrowseMode nMode) { return bool(nMode & BrowseMode::Bottom); }
BrowseMode test2c() { return BrowseMode::Left; }
enum class Enum3
{
......
......@@ -188,11 +188,20 @@ walk_up:
}
else if (const CXXMemberCallExpr * memberCall = dyn_cast<CXXMemberCallExpr>(parent))
{
//memberCall->getImplicitObjectArgument()->dump();
//child->dump();
// happens a lot with o3tl::typed_flags
if (*memberCall->child_begin() == child)
{
if (auto conversionDecl = dyn_cast<CXXConversionDecl>(memberCall->getMethodDecl()))
{
if (conversionDecl->getConversionType()->isSpecificBuiltinType(clang::BuiltinType::Bool))
bRead = true;
else
goto walk_up;
}
else
goto walk_up;
}
else
bWrite = true;
}
else if (isa<CallExpr>(parent) || isa<InitListExpr>(parent) || isa<ArraySubscriptExpr>(parent)
......
......@@ -205,6 +205,9 @@ writeonlySet = set()
for d in writeSet:
if d in readSet:
continue
# can happen with stuff in workdir or external
if d not in definitionSet:
continue
srcLoc = definitionToSourceLocationMap[d];
if (is_ignore(srcLoc)):
continue
......@@ -214,6 +217,9 @@ readonlySet = set()
for d in readSet:
if d in writeSet:
continue
# can happen with stuff in workdir or external
if d not in definitionSet:
continue
srcLoc = definitionToSourceLocationMap[d];
if (is_ignore(srcLoc)):
continue
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1208,12 +1208,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
if ( !bReadOnly && !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
{
bool bShift = rKeyEvent.GetKeyCode().IsShift();
if ( pImpEditEngine->GetStatus().DoTabIndenting() &&
( aCurSel.Min().GetNode() != aCurSel.Max().GetNode() ) )
{
pImpEditEngine->IndentBlock( pEditView, !bShift );
}
else if ( !bShift )
if ( !bShift )
{
bool bSel = pEditView->HasSelection();
if ( bSel )
......@@ -1854,18 +1849,15 @@ void EditEngine::SetControlWord( EEControlBits nWord )
{
// possibly reformat:
if ( ( nChanges & EEControlBits::USECHARATTRIBS ) ||
( nChanges & EEControlBits::USEPARAATTRIBS ) ||
( nChanges & EEControlBits::ONECHARPERLINE ) ||
( nChanges & EEControlBits::STRETCHING ) ||
( nChanges & EEControlBits::OUTLINER ) ||
( nChanges & EEControlBits::NOCOLORS ) ||
( nChanges & EEControlBits::OUTLINER2 ) )
{
if ( ( nChanges & EEControlBits::USECHARATTRIBS ) ||
( nChanges & EEControlBits::USEPARAATTRIBS ) )
if ( nChanges & EEControlBits::USECHARATTRIBS )
{
bool bUseCharAttribs = bool( nWord & EEControlBits::USECHARATTRIBS );
pImpEditEngine->GetEditDoc().CreateDefFont( bUseCharAttribs );
pImpEditEngine->GetEditDoc().CreateDefFont( true );
}
pImpEditEngine->FormatFullDoc();
......
......@@ -81,9 +81,6 @@ public:
bool MarkUrlFields() const
{ return bool( nControlBits & EEControlBits::MARKURLFIELDS ); }
bool DoRestoreFont() const
{ return bool( nControlBits & EEControlBits::RESTOREFONT ); }
bool DoImportRTFStyleSheets() const
{ return bool( nControlBits & EEControlBits::RTFSTYLESHEETS ); }
......@@ -93,17 +90,11 @@ public:
bool DoAutoComplete() const
{ return bool( nControlBits & EEControlBits::AUTOCOMPLETE ); }
bool DoTabIndenting() const
{ return bool( nControlBits & EEControlBits::TABINDENTING ); }
bool DoFormat100() const
{ return bool( nControlBits & EEControlBits::FORMAT100 ); }
bool ULSpaceSummation() const
{ return bool( nControlBits & EEControlBits::ULSPACESUMMATION ); }
bool ULSpaceFirstParagraph() const
{ return bool( nControlBits & EEControlBits::ULSPACEFIRSTPARA ); }
};
#endif // INCLUDED_EDITENG_SOURCE_EDITENG_EDITSTT2_HXX
......
......@@ -4111,7 +4111,7 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
}
sal_Int32 nPortion = GetParaPortions().GetPos( pPortion );
if ( nPortion || aStatus.ULSpaceFirstParagraph() )
if ( nPortion )
{
sal_uInt16 nUpper = GetYValue( rULItem.GetUpper() );
pPortion->nHeight += nUpper;
......
......@@ -462,8 +462,6 @@ void ImpEditEngine::FormatDoc()
}
}
if ( aStatus.DoRestoreFont() )
GetRefDevice()->SetFont( aOldFont );
bIsFormatting = false;
bFormatted = true;
......@@ -3337,8 +3335,6 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, tools::Rectangle aClipRect, Po
vcl::Font _aOldFont( GetRefDevice()->GetFont() );
aTmpFont.SetPhysFont( GetRefDevice() );
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen, pTmpDXArray.get() );
if ( aStatus.DoRestoreFont() )
GetRefDevice()->SetFont( _aOldFont );
// add a meta file comment if we record to a metafile
if( bMetafileValid )
......@@ -3367,8 +3363,6 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, tools::Rectangle aClipRect, Po
vcl::Font _aOldFont( GetRefDevice()->GetFont() );
aTmpFont.SetPhysFont( GetRefDevice() );
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(), pTmpDXArray.get() );
if ( aStatus.DoRestoreFont() )
GetRefDevice()->SetFont( _aOldFont );
}
long nTxtWidth = rTextPortion.GetSize().Width();
......@@ -3823,8 +3817,6 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, tools::Rectangle aClipRect, Po
if (IsVertical() && !IsTopToBottom() && ( aStartPos.X() > aClipRect.Right() ) )
break;
}
if ( aStatus.DoRestoreFont() )
pOutDev->SetFont( aOldFont );
}
void ImpEditEngine::Paint( ImpEditView* pView, const tools::Rectangle& rRect, OutputDevice* pTargetDevice )
......@@ -3964,8 +3956,6 @@ void ImpEditEngine::ShowParagraph( sal_Int32 nParagraph, bool bShow )
{
vcl::Font aOldFont( GetRefDevice()->GetFont() );
CreateLines( nParagraph, 0 ); // 0: No TextRanger
if ( aStatus.DoRestoreFont() )
GetRefDevice()->SetFont( aOldFont );
}
else
{
......
......@@ -29,7 +29,6 @@ enum class EEControlBits
{
NONE = 0x00000000,
USECHARATTRIBS = 0x00000001, // Use of hard character attributes
USEPARAATTRIBS = 0x00000002, // Using paragraph attributes.
CRSRLEFTPARA = 0x00000004, // Cursor is moved to another paragraph
DOIDLEFORMAT = 0x00000008, // Formatting idle
PASTESPECIAL = 0x00000010, // Allow PasteSpecial
......@@ -45,21 +44,18 @@ enum class EEControlBits
MARKNONURLFIELDS = 0x00004000, // Mark fields other than URL with color
MARKURLFIELDS = 0x00008000, // Mark URL fields with color
MARKFIELDS = (MARKNONURLFIELDS | MARKURLFIELDS),
RESTOREFONT = 0x00010000, // Restore Font in OutDev
RTFSTYLESHEETS = 0x00020000, // Use Stylesheets when imported
AUTOCORRECT = 0x00080000, // AutoCorrect
AUTOCOMPLETE = 0x00100000, // AutoComplete
AUTOPAGESIZEX = 0x00200000, // Adjust paper width to Text
AUTOPAGESIZEY = 0x00400000, // Adjust paper height to Text
AUTOPAGESIZE = (AUTOPAGESIZEX | AUTOPAGESIZEY),
TABINDENTING = 0x00800000, // Indent with tab
FORMAT100 = 0x01000000, // Always format to 100%
ULSPACESUMMATION = 0x02000000, // MS Compat: sum SA and SB, not maximum value
ULSPACEFIRSTPARA = 0x04000000, // MS Compat: evaluate also at the first paragraph
};
namespace o3tl
{
template<> struct typed_flags<EEControlBits> : is_typed_flags<EEControlBits, 0x07ffffff> {};
template<> struct typed_flags<EEControlBits> : is_typed_flags<EEControlBits, 0x037efffd> {};
}
enum class EVControlBits
......
......@@ -247,7 +247,6 @@ bool ImplSdPPTImport::Import()
SdrOutliner& rOutl = mpDoc->GetDrawOutliner();
EEControlBits nControlWord = rOutl.GetEditEngine().GetControlWord();
nControlWord |= EEControlBits::ULSPACESUMMATION;
nControlWord &= ~EEControlBits::ULSPACEFIRSTPARA;
const_cast<EditEngine&>(rOutl.GetEditEngine()).SetControlWord( nControlWord );
SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin();
......
......@@ -403,7 +403,6 @@ bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
SdrOutliner& rOutl = mpDoc->GetDrawOutliner();
EEControlBits nControlWord = rOutl.GetEditEngine().GetControlWord();
nControlWord |= EEControlBits::ULSPACESUMMATION;
nControlWord &=~ EEControlBits::ULSPACEFIRSTPARA;
const_cast<EditEngine&>(rOutl.GetEditEngine()).SetControlWord( nControlWord );
mpDoc->SetSummationOfParagraphs();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment