diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-18 09:57:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-18 15:19:04 +0200 |
commit | 5d86154f49d713dada4aaa541755076cfeefa2c6 (patch) | |
tree | 25c34f4a032526de9798e6f3a69a76d993d739db /sc | |
parent | 469892f65d9717fcee7996a040b32d713a83b412 (diff) |
loplugin:unusedfields improve search for unused collection fields
look for collection-like fields that are never added to, and are
therefore effectively unused
Change-Id: Id52c5500ea5e3d2436fb5915aebb86278bf2d925
Reviewed-on: https://gerrit.libreoffice.org/60661
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/html/htmlpars.cxx | 24 | ||||
-rw-r--r-- | sc/source/filter/inc/defnamesbuffer.hxx | 3 | ||||
-rw-r--r-- | sc/source/filter/inc/workbooksettings.hxx | 1 | ||||
-rw-r--r-- | sc/source/filter/oox/defnamesbuffer.cxx | 80 | ||||
-rw-r--r-- | sc/source/filter/oox/formulaparser.cxx | 18 | ||||
-rw-r--r-- | sc/source/filter/oox/workbooksettings.cxx | 5 |
6 files changed, 5 insertions, 126 deletions
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index ec86f6ec778e..b0613e294c9f 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -3039,15 +3039,11 @@ class CSSHandler } }; - typedef std::pair<MemStr, MemStr> SelectorName; // element : class - typedef std::vector<SelectorName> SelectorNames; - SelectorNames maSelectorNames; /// current selector names. MemStr maPropName; /// current property name. MemStr maPropValue; /// current property value. - ScHTMLStyles& mrStyles; public: - explicit CSSHandler(ScHTMLStyles& rStyles) : mrStyles(rStyles) {} + explicit CSSHandler() {} static void at_rule_name(const char* /*p*/, size_t /*n*/) { @@ -3070,26 +3066,12 @@ public: static void begin_block() {} - void end_block() - { - maSelectorNames.clear(); - } + static void end_block() {} static void begin_property() {} void end_property() { - SelectorNames::const_iterator itr = maSelectorNames.begin(), itrEnd = maSelectorNames.end(); - for (; itr != itrEnd; ++itr) - { - // Add this property to the collection for each selector. - const SelectorName& rSelName = *itr; - const MemStr& rElem = rSelName.first; - const MemStr& rClass = rSelName.second; - OUString aName(maPropName.mp, maPropName.mn, RTL_TEXTENCODING_UTF8); - OUString aValue(maPropValue.mp, maPropValue.mn, RTL_TEXTENCODING_UTF8); - mrStyles.add(rElem.mp, rElem.mn, rClass.mp, rClass.mn, aName, aValue); - } maPropName = MemStr(); maPropValue = MemStr(); } @@ -3128,7 +3110,7 @@ public: void ScHTMLQueryParser::ParseStyle(const OUString& rStrm) { OString aStr = OUStringToOString(rStrm, RTL_TEXTENCODING_UTF8); - CSSHandler aHdl(GetStyles()); + CSSHandler aHdl; orcus::css_parser<CSSHandler> aParser(aStr.getStr(), aStr.getLength(), aHdl); try { diff --git a/sc/source/filter/inc/defnamesbuffer.hxx b/sc/source/filter/inc/defnamesbuffer.hxx index d4ff3b4a3e7c..45078929e7c8 100644 --- a/sc/source/filter/inc/defnamesbuffer.hxx +++ b/sc/source/filter/inc/defnamesbuffer.hxx @@ -78,14 +78,11 @@ public: /** Returns the original name as imported from or exported to the file. */ const OUString& getUpcaseModelName() const; - /** Returns an Any with a SingleReference or ComplexReference, or an empty Any. */ - css::uno::Any getReference( const ScAddress& rBaseAddr ) const; protected: DefinedNameModel maModel; /// Model data for this defined name. mutable OUString maUpModelName; /// Model name converted to uppercase ASCII. OUString maCalcName; /// Final name used in the Calc document. - css::uno::Any maRefAny; /// Single cell/range reference. }; class DefinedName : public DefinedNameBase diff --git a/sc/source/filter/inc/workbooksettings.hxx b/sc/source/filter/inc/workbooksettings.hxx index 2477ab8d6c8d..5a02c02c228d 100644 --- a/sc/source/filter/inc/workbooksettings.hxx +++ b/sc/source/filter/inc/workbooksettings.hxx @@ -75,7 +75,6 @@ struct CalcSettingsModel bool mbFullPrecision; /// True = use full precision on calculation. bool mbIterate; /// True = allow circular references. bool mbConcurrent; /// True = concurrent calculation enabled. - bool mbUseNlr; /// True = use natural language references in formulas. explicit CalcSettingsModel(); }; diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx index 5bd2e56759b3..82cb436dd075 100644 --- a/sc/source/filter/oox/defnamesbuffer.cxx +++ b/sc/source/filter/oox/defnamesbuffer.cxx @@ -58,11 +58,6 @@ const sal_uInt32 BIFF12_DEFNAME_VBNAME = 0x00000004; const sal_uInt32 BIFF12_DEFNAME_MACRO = 0x00000008; const sal_uInt32 BIFF12_DEFNAME_BUILTIN = 0x00000020; -const sal_uInt16 BIFF_REFFLAG_COL1REL = 0x0001; -const sal_uInt16 BIFF_REFFLAG_ROW1REL = 0x0002; -const sal_uInt16 BIFF_REFFLAG_COL2REL = 0x0004; -const sal_uInt16 BIFF_REFFLAG_ROW2REL = 0x0008; - const OUStringLiteral spcOoxPrefix("_xlnm."); const sal_Char* const sppcBaseNames[] = @@ -130,53 +125,6 @@ OUString lclGetUpcaseModelName( const OUString& rModelName ) return rModelName.toAsciiUpperCase(); } -void lclConvertRefFlags( sal_Int32& ornFlags, sal_Int32& ornAbsPos, sal_Int32& ornRelPos, sal_Int32 nBasePos, sal_Int32 nApiRelFlag, bool bRel ) -{ - if( getFlag( ornFlags, nApiRelFlag ) && !bRel ) - { - // convert relative to absolute - setFlag( ornFlags, nApiRelFlag, false ); - ornAbsPos = nBasePos + ornRelPos; - } - else if( !getFlag( ornFlags, nApiRelFlag ) && bRel ) - { - // convert absolute to relative - setFlag( ornFlags, nApiRelFlag, true ); - ornRelPos = ornAbsPos - nBasePos; - } -} - -void lclConvertSingleRefFlags( SingleReference& orApiRef, const ScAddress& rBaseAddr, bool bColRel, bool bRowRel ) -{ - using namespace ::com::sun::star::sheet::ReferenceFlags; - lclConvertRefFlags( - orApiRef.Flags, orApiRef.Column, orApiRef.RelativeColumn, - sal_Int32( rBaseAddr.Col() ), COLUMN_RELATIVE, bColRel ); - lclConvertRefFlags( - orApiRef.Flags, orApiRef.Row, orApiRef.RelativeRow, - rBaseAddr.Row(), ROW_RELATIVE, bRowRel ); -} - -Any lclConvertReference( const Any& rRefAny, const ScAddress& rBaseAddr, sal_uInt16 nRelFlags ) -{ - if( rRefAny.has< SingleReference >() && !getFlag( nRelFlags, BIFF_REFFLAG_COL2REL ) && !getFlag( nRelFlags, BIFF_REFFLAG_ROW2REL ) ) - { - SingleReference aApiRef; - rRefAny >>= aApiRef; - lclConvertSingleRefFlags( aApiRef, rBaseAddr, getFlag( nRelFlags, BIFF_REFFLAG_COL1REL ), getFlag( nRelFlags, BIFF_REFFLAG_ROW1REL ) ); - return Any( aApiRef ); - } - if( rRefAny.has< ComplexReference >() ) - { - ComplexReference aApiRef; - rRefAny >>= aApiRef; - lclConvertSingleRefFlags( aApiRef.Reference1, rBaseAddr, getFlag( nRelFlags, BIFF_REFFLAG_COL1REL ), getFlag( nRelFlags, BIFF_REFFLAG_ROW1REL ) ); - lclConvertSingleRefFlags( aApiRef.Reference2, rBaseAddr, getFlag( nRelFlags, BIFF_REFFLAG_COL2REL ), getFlag( nRelFlags, BIFF_REFFLAG_ROW2REL ) ); - return Any( aApiRef ); - } - return Any(); -} - } // namespace DefinedNameModel::DefinedNameModel() : @@ -201,34 +149,6 @@ const OUString& DefinedNameBase::getUpcaseModelName() const return maUpModelName; } -Any DefinedNameBase::getReference( const ScAddress& rBaseAddr ) const -{ - if( maRefAny.hasValue() && (maModel.maName.getLength() >= 2) && (maModel.maName[ 0 ] == '\x01') ) - { - sal_Unicode cFlagsChar = getUpcaseModelName()[ 1 ]; - if( ('A' <= cFlagsChar) && (cFlagsChar <= 'P') ) - { - sal_uInt16 nRelFlags = static_cast< sal_uInt16 >( cFlagsChar - 'A' ); - if( maRefAny.has< ExternalReference >() ) - { - ExternalReference aApiExtRef; - maRefAny >>= aApiExtRef; - Any aRefAny = lclConvertReference( aApiExtRef.Reference, rBaseAddr, nRelFlags ); - if( aRefAny.hasValue() ) - { - aApiExtRef.Reference = aRefAny; - return Any( aApiExtRef ); - } - } - else - { - return lclConvertReference( maRefAny, rBaseAddr, nRelFlags ); - } - } - } - return Any(); -} - DefinedName::DefinedName( const WorkbookHelper& rHelper ) : DefinedNameBase( rHelper ), mpScRangeData(nullptr), diff --git a/sc/source/filter/oox/formulaparser.cxx b/sc/source/filter/oox/formulaparser.cxx index 85ae9fa786cc..888f0465a53d 100644 --- a/sc/source/filter/oox/formulaparser.cxx +++ b/sc/source/filter/oox/formulaparser.cxx @@ -465,7 +465,6 @@ protected: ApiToken& getOperandToken( size_t nOpIndex, size_t nTokenIndex ); bool pushOperandToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = nullptr ); - bool pushAnyOperandToken( const Any& rAny, sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = nullptr ); template< typename Type > bool pushValueOperandToken( const Type& rValue, sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = nullptr ); template< typename Type > @@ -480,7 +479,6 @@ protected: bool pushFunctionOperatorToken( const FunctionInfo& rFuncInfo, size_t nParamCount, const WhiteSpaceVec* pLeadingSpaces = nullptr, const WhiteSpaceVec* pClosingSpaces = nullptr ); bool pushOperand( sal_Int32 nOpCode ); - bool pushAnyOperand( const Any& rAny, sal_Int32 nOpCode ); template< typename Type > bool pushValueOperand( const Type& rValue, sal_Int32 nOpCode ); template< typename Type > @@ -734,14 +732,6 @@ bool FormulaParserImpl::pushOperandToken( sal_Int32 nOpCode, const WhiteSpaceVec return true; } -bool FormulaParserImpl::pushAnyOperandToken( const Any& rAny, sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces ) -{ - size_t nSpacesSize = appendWhiteSpaceTokens( pSpaces ); - appendRawToken( nOpCode ) = rAny; - pushOperandSize( nSpacesSize + 1 ); - return true; -} - template< typename Type > bool FormulaParserImpl::pushValueOperandToken( const Type& rValue, sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces ) { @@ -853,11 +843,6 @@ bool FormulaParserImpl::pushOperand( sal_Int32 nOpCode ) return pushOperandToken( nOpCode, &maLeadingSpaces ) && resetSpaces(); } -bool FormulaParserImpl::pushAnyOperand( const Any& rAny, sal_Int32 nOpCode ) -{ - return pushAnyOperandToken( rAny, nOpCode, &maLeadingSpaces ) && resetSpaces(); -} - template< typename Type > bool FormulaParserImpl::pushValueOperand( const Type& rValue, sal_Int32 nOpCode ) { @@ -946,9 +931,6 @@ bool FormulaParserImpl::pushReferenceOperand( const LinkSheetRange& rSheetRange, bool FormulaParserImpl::pushEmbeddedRefOperand( const DefinedNameBase& rName, bool bPushBadToken ) { - Any aRefAny = rName.getReference( maBaseAddr ); - if( aRefAny.hasValue() ) - return pushAnyOperand( aRefAny, OPCODE_PUSH ); if( bPushBadToken && !rName.getModelName().isEmpty() && (rName.getModelName()[ 0 ] >= ' ') ) return pushValueOperand( rName.getModelName(), OPCODE_BAD ); return pushBiffErrorOperand( BIFF_ERR_NAME ); diff --git a/sc/source/filter/oox/workbooksettings.cxx b/sc/source/filter/oox/workbooksettings.cxx index b328b6516ff0..cc7366ffd83f 100644 --- a/sc/source/filter/oox/workbooksettings.cxx +++ b/sc/source/filter/oox/workbooksettings.cxx @@ -97,8 +97,7 @@ CalcSettingsModel::CalcSettingsModel() : mbCalcCompleted( true ), mbFullPrecision( true ), mbIterate( false ), - mbConcurrent( true ), - mbUseNlr( false ) + mbConcurrent( true ) { } @@ -233,7 +232,7 @@ void WorkbookSettings::finalizeImport() aPropSet.setProperty( PROP_IterationCount, maCalcSettings.mnIterateCount ); aPropSet.setProperty( PROP_IterationEpsilon, maCalcSettings.mfIterateDelta ); aPropSet.setProperty( PROP_CalcAsShown, !maCalcSettings.mbFullPrecision ); - aPropSet.setProperty( PROP_LookUpLabels, maCalcSettings.mbUseNlr ); + aPropSet.setProperty( PROP_LookUpLabels, false ); Reference< XNumberFormatsSupplier > xNumFmtsSupp( getDocument(), UNO_QUERY ); if( xNumFmtsSupp.is() ) |