diff options
author | Noel <noelgrandin@gmail.com> | 2020-09-30 09:38:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-09-30 12:32:18 +0200 |
commit | 9373320fc88c1582a2ad25bda9c5264c7c58a97e (patch) | |
tree | ee2df8944d7af2080498b991ed46429e0a020947 /sw/source | |
parent | 37b81dd54a915223780a6b5efa54ce45db332604 (diff) |
loplugin:reducevarscope in sw
Change-Id: Ifed7220c6acf7049b2985f1911a806b37a54d794
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103646
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
39 files changed, 129 insertions, 161 deletions
diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index 53a974acc96a..cf59efdb21ce 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -524,15 +524,13 @@ uno::Any SAL_CALL SwAccessibleDocument::getExtendedAttributes() SwFEShell* pFEShell = dynamic_cast<const SwFEShell*>( pCursorShell) != nullptr ? static_cast<SwFEShell*>( pCursorShell ) : nullptr; - OUString sValue; - sal_uInt16 nPage, nLogPage; - OUString sDisplay; - if( pFEShell ) { + OUString sDisplay; + sal_uInt16 nPage, nLogPage; pFEShell->GetPageNumber(-1,true,nPage,nLogPage,sDisplay); - sValue = "page-name:" + sDisplay + + OUString sValue = "page-name:" + sDisplay + ";page-number:" + OUString::number( nPage ) + ";total-pages:" + diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index 35f711297789..e2c96e069879 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -368,11 +368,10 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const std::unique_ptr< SfxItemSet > tmpSet; - const SwPageDesc* pPgDesc; if( pSrcDoc != pDstDoc && SfxItemState::SET == GetItemState( RES_PAGEDESC, false, &pItem )) { - pPgDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc(); + const SwPageDesc* pPgDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc(); if( pPgDesc ) { tmpSet.reset(new SfxItemSet(*this)); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 7c7471b081b5..db3106707482 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -193,11 +193,10 @@ SwPaM* SwCursorShell::GetCursor( bool bMakeTableCursor ) const if( bMakeTableCursor && m_pTableCursor->IsCursorMovedUpdate() ) { //don't re-create 'parked' cursors - const SwContentNode* pCNd; if( m_pTableCursor->GetPoint()->nNode.GetIndex() && m_pTableCursor->GetMark()->nNode.GetIndex() ) { - pCNd = m_pTableCursor->GetContentNode(); + const SwContentNode* pCNd = m_pTableCursor->GetContentNode(); if( pCNd && pCNd->getLayoutFrame( GetLayout() ) ) { pCNd = m_pTableCursor->GetContentNode(false); diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 804bdab8a05a..7e27e1ee899a 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -438,13 +438,12 @@ bool SwCursorShell::GotoNxtPrvTableFormula( bool bNext, bool bOnlyErrors ) ( !bOnlyErrors || !pFormulaItem->HasValidBoxes() ) ) { - const SwContentFrame* pCFrame; SwNodeIndex aIdx( *pTBox->GetSttNd() ); const SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aIdx ); std::pair<Point, bool> const tmp(aPt, false); if (pCNd) { - pCFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp); + const SwContentFrame* pCFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp); if (pCFrame && (IsReadOnlyAvailable() || !pCFrame->IsProtected() )) { SetGetExpField aCmp( *pTBox ); @@ -1258,8 +1257,6 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt, SwPosition aPos( *m_pCurrentCursor->GetPoint() ); SwTextNode* pTextNd; - SwContentFrame *pFrame(nullptr); - SwTextAttr* pTextAttr; SwCursorMoveState aTmpState; aTmpState.m_bFieldInfo = true; aTmpState.m_bExactOnly = !( IsAttrAtPos::Outline & rContentAtPos.eContentAtPos ); @@ -1305,8 +1302,10 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt, } else if( bCursorFoundExact && pTextNd ) { + SwContentFrame *pFrame(nullptr); if( !aTmpState.m_bPosCorr ) { + SwTextAttr* pTextAttr; if ( IsAttrAtPos::SmartTag & rContentAtPos.eContentAtPos && !aTmpState.m_bFootnoteNoInfo ) { @@ -2425,11 +2424,10 @@ bool SwCursorShell::SelectNxtPrvHyperlink( bool bNext ) if( aCurPos.GetNode() < nBodySttNdIdx ) { const SwContentNode* pCNd = aCurPos.GetNodeFromContent()->GetContentNode(); - SwContentFrame* pFrame; std::pair<Point, bool> tmp(aPt, true); if (pCNd) { - pFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp); + SwContentFrame* pFrame = pCNd->getLayoutFrame(GetLayout(), nullptr, &tmp); if( pFrame ) aCurPos.SetBodyPos( *pFrame ); } @@ -2451,11 +2449,10 @@ bool SwCursorShell::SelectNxtPrvHyperlink( bool bNext ) SwTextINetFormat& rAttr = *pFnd; SwPosition aTmpPos( *pTextNd ); SetGetExpField aPos( aTmpPos.nNode, rAttr ); - SwContentFrame* pFrame; if (pTextNd->GetIndex() < nBodySttNdIdx) { std::pair<Point, bool> tmp(aPt, true); - pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp); + SwContentFrame* pFrame = pTextNd->getLayoutFrame(GetLayout(), nullptr, &tmp); if (pFrame) { aPos.SetBodyPos( *pFrame ); diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index 0e732759def1..db76efdfcd45 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -810,7 +810,6 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) if( pTableNd->GetIndex() < m_rDoc.GetNodes().GetEndOfExtras().GetIndex() ) { // is in the special section, that's expensive! - Point aPt; // return the first frame of the layout - Tab.Headline!! SwNodeIndex aCNdIdx( *pTableNd, +2 ); SwContentNode* pCNd = aCNdIdx.GetNode().GetContentNode(); if( !pCNd ) @@ -818,6 +817,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) if (pCNd) { + Point aPt; // return the first frame of the layout - Tab.Headline!! std::pair<Point, bool> const tmp(aPt, true); pFrame = pCNd->getLayoutFrame(pLayout, nullptr, &tmp); if( pFrame ) diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx index c5ca5b11eae6..85a4d3a12856 100644 --- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx +++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx @@ -483,15 +483,13 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr, } else if( sCmp == "frame" ) { - SwNodeIndex* pIdx; - SwNode* pNd; const SwFlyFrameFormat* pFlyFormat = m_rDoc.FindFlyByName( sName ); if( pFlyFormat ) { - pIdx = const_cast<SwNodeIndex*>(pFlyFormat->GetContent().GetContentIdx()); + SwNodeIndex* pIdx = const_cast<SwNodeIndex*>(pFlyFormat->GetContent().GetContentIdx()); if( pIdx ) { - pNd = &pIdx->GetNode(); + SwNode* pNd = &pIdx->GetNode(); if( !pNd->IsNoTextNode() ) { rpRange.reset(new SwNodeRange( *pNd, 1, *pNd->EndOfSectionNode() )); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 0f03a9265670..c1b5d550ca1f 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1525,11 +1525,9 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext, pNd = aIdx.GetNode().GetTextNode(); const SwNumRule* pRule = pNd->GetNumRule(); - sal_uInt8 nTmpNum; - if( pRule ) { - nTmpNum = static_cast<sal_uInt8>(pNd->GetActualListLevel()); + sal_uInt8 nTmpNum = static_cast<sal_uInt8>(pNd->GetActualListLevel()); if( pNd->IsCountedInList() || (nTmpNum < nSrchNum ) ) break; // found it! } diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 5162c68db6f7..c700d39d731d 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -656,7 +656,7 @@ SwRedlineTable::size_type SwRedlineTable::FindPrevOfSeqNo( size_type nSttPos ) c /// We can limit the search using look ahead (0 searches the whole array). SwRedlineTable::size_type SwRedlineTable::FindNextSeqNo( sal_uInt16 nSeqNo, size_type nSttPos ) const { - auto const nLookahead = 20; + auto constexpr nLookahead = 20; size_type nRet = npos; if( nSeqNo && nSttPos < size() ) { @@ -679,7 +679,7 @@ SwRedlineTable::size_type SwRedlineTable::FindNextSeqNo( sal_uInt16 nSeqNo, size SwRedlineTable::size_type SwRedlineTable::FindPrevSeqNo( sal_uInt16 nSeqNo, size_type nSttPos ) const { - auto const nLookahead = 20; + auto constexpr nLookahead = 20; size_type nRet = npos; if( nSeqNo && nSttPos < size() ) { diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index c62bbf5b7a35..e98d44c14e80 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -250,9 +250,9 @@ static void lcl_CopyCol( FndBox_ & rFndBox, CpyPara *const pCpyPara) SwTableBox* pBox = rFndBox.GetBox(); CpyTabFrame aFindFrame(pBox->GetFrameFormat()); - sal_uInt16 nFndPos; if( pCpyPara->nCpyCnt ) { + sal_uInt16 nFndPos; CpyTabFrames::const_iterator itFind = pCpyPara->rTabFrameArr.lower_bound( aFindFrame ); nFndPos = itFind - pCpyPara->rTabFrameArr.begin(); if( itFind == pCpyPara->rTabFrameArr.end() || !(*itFind == aFindFrame) ) diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index c9c3e4546b8d..3c66f9d43b86 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -4443,11 +4443,10 @@ bool SwDoc::UnProtectTableCells( SwTable& rTable ) void SwDoc::UnProtectCells( const OUString& rName ) { - bool bChgd = false; SwTableFormat* pFormat = FindTableFormatByName( rName ); if( pFormat ) { - bChgd = UnProtectTableCells( *SwTable::FindTable( pFormat ) ); + bool bChgd = UnProtectTableCells( *SwTable::FindTable( pFormat ) ); if( bChgd ) getIDocumentState().SetModified(); } diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 0f352dc28e69..94beca340c78 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -116,10 +116,10 @@ static void SetParent( std::shared_ptr<const SfxItemSet>& rpAttrSet, aNewSet.SetParent( pParentSet ); aNewSet.ClearItem( RES_FRMATR_STYLE_NAME ); aNewSet.ClearItem( RES_FRMATR_CONDITIONAL_STYLE_NAME ); - OUString sVal; if ( pParentFormat ) { + OUString sVal; SwStyleNameMapper::FillProgName( pParentFormat->GetName(), sVal, SwGetPoolIdFromName::TxtColl ); const SfxStringItem aAnyFormatColl( RES_FRMATR_STYLE_NAME, sVal ); aNewSet.Put( aAnyFormatColl ); diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 00e4a6ef3419..b932744fb588 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -518,20 +518,18 @@ OUString SwValueFieldType::ExpandValue( const double& rVal, if( nFormat < SV_COUNTRY_LANGUAGE_OFFSET && LANGUAGE_SYSTEM != nFormatLng ) { - SvNumFormatType nType = SvNumFormatType::DEFINED; - sal_Int32 nDummy; - const SvNumberformat* pEntry = pFormatter->GetEntry(nFormat); if (pEntry && nLng != pEntry->GetLanguage()) { sal_uInt32 nNewFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nFormat, nFormatLng); - if (nNewFormat == nFormat) { // probably user-defined format OUString sFormat(pEntry->GetFormatstring()); + sal_Int32 nDummy; + SvNumFormatType nType = SvNumFormatType::DEFINED; pFormatter->PutandConvertEntry(sFormat, nDummy, nType, nFormat, pEntry->GetLanguage(), nFormatLng, false); diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index d8714479ba75..30633ba4bd2d 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -338,9 +338,9 @@ bool SwPageFrame::GetModelPositionForViewPoint( SwPosition *pPos, Point &rPoint, { // FIXME There are still cases were we don't have the proper node here. SwContentFrame* pBackFrame = pBackNd->getLayoutFrame( getRootFrame( ) ); - SwRect rBackRect; if (pBackFrame) { + SwRect rBackRect; pBackFrame->GetCharRect( rBackRect, aBackPos ); nBackDistance = lcl_getDistance( rBackRect, rPoint ); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index d5d9621670c5..2efac690cf89 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -487,7 +487,6 @@ void SwTaggedPDFHelper::EndTag() // Sets the attributes according to the structure type. void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) { - vcl::PDFWriter::StructAttributeValue eVal; sal_Int32 nVal; /* @@ -495,6 +494,7 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) */ if ( mpFrameInfo ) { + vcl::PDFWriter::StructAttributeValue eVal; const SwFrame* pFrame = &mpFrameInfo->mrFrame; SwRectFnSet aRectFnSet(pFrame); diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index b278484fc955..a2c1fb739255 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -295,11 +295,11 @@ void SwFieldPortion::CheckScript( const SwTextSizeInfo &rInf ) bool SwFieldPortion::Format( SwTextFormatInfo &rInf ) { // Scope wegen aDiffText::DTOR! - TextFrameIndex nRest; bool bFull = false; bool bEOL = false; TextFrameIndex const nTextRest = TextFrameIndex(rInf.GetText().getLength()) - rInf.GetIdx(); { + TextFrameIndex nRest; SwFieldSlot aDiffText( &rInf, this ); SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); aLayoutModeModifier.SetAuto(); diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 42c4b9876c53..666ed4a3dd57 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -279,14 +279,13 @@ static bool GetTableAndCellsFromRangeRep( // parse range representation for table name and cell/range names // accepted format sth like: "Table1.A2:C5" , "Table2.A2.1:B3.2" OUString aTableName; // table name - OUString aRange; // cell range OUString aStartCell; // name of top left cell OUString aEndCell; // name of bottom right cell sal_Int32 nIdx = rRangeRepresentation.indexOf( '.' ); if (nIdx >= 0) { aTableName = rRangeRepresentation.copy( 0, nIdx ); - aRange = rRangeRepresentation.copy( nIdx + 1 ); + OUString aRange = rRangeRepresentation.copy( nIdx + 1 ); // cell range sal_Int32 nPos = aRange.indexOf( ':' ); if (nPos >= 0) // a cell-range like "Table1.A2:D4" { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 5c7bffdc8663..e8461393ea6f 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2462,7 +2462,6 @@ void SwXFrame::setPropertyToDefault( const OUString& rPropertyName ) if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) throw uno::RuntimeException("setPropertyToDefault: property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - bool bNextFrame; if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) { SwDoc* pDoc = pFormat->GetDoc(); @@ -2521,7 +2520,7 @@ void SwXFrame::setPropertyToDefault( const OUString& rPropertyName ) } else { - bNextFrame = rPropertyName == UNO_NAME_CHAIN_NEXT_NAME; + bool bNextFrame = rPropertyName == UNO_NAME_CHAIN_NEXT_NAME; if( bNextFrame || rPropertyName == UNO_NAME_CHAIN_PREV_NAME ) { SwDoc* pDoc = pFormat->GetDoc(); diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 9b3b40202ffb..8cb32cc97e4e 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -3136,7 +3136,6 @@ static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt, // and now the Graphic OUString aGraphicInBase64; - OUString aGraphicAsLink; // Embedded Graphic -> export WriteEmbedded const Graphic* pGrf = nullptr; @@ -3154,7 +3153,7 @@ static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt, } else if( !pGraphicName && rHTMLWrt.m_bCfgCpyLinkedGrfs ) { - aGraphicAsLink = aLink; + OUString aGraphicAsLink = aLink; rWrt.CopyLocalFileToINet( aGraphicAsLink ); aLink = aGraphicAsLink; } diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index d89515215236..c72b7ee4d14f 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -1282,13 +1282,13 @@ void SwHTMLWriter::OutBackground( const SvxBrushItem *pBrushItem, bool bGraphic if( !bGraphic ) return; - OUString aGraphicInBase64; const Graphic* pGrf = pBrushItem->GetGraphic(); OUString GraphicURL = pBrushItem->GetGraphicLink(); if( mbEmbedImages || GraphicURL.isEmpty()) { if( pGrf ) { + OUString aGraphicInBase64; if( !XOutBitmap::GraphicToBase64(*pGrf, aGraphicInBase64) ) { m_nWarn = WARN_SWG_POOR_LOAD; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 8142c6f0a667..88b92ab460dd 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2136,82 +2136,79 @@ void DocxAttributeOutput::DoWriteCmd( const OUString& rCmd ) void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun ) { - bool bWriteCombChars(false); - // Write the Field instruction + if ( bWriteRun ) { - if ( bWriteRun ) - { - m_pSerializer->startElementNS(XML_w, XML_r); + bool bWriteCombChars(false); + m_pSerializer->startElementNS(XML_w, XML_r); - if (rInfos.eType == ww::eEQ) - bWriteCombChars = true; + if (rInfos.eType == ww::eEQ) + bWriteCombChars = true; - DoWriteFieldRunProperties( pNode, nPos, bWriteCombChars ); - } + DoWriteFieldRunProperties( pNode, nPos, bWriteCombChars ); + } - sal_Int32 nIdx { rInfos.sCmd.isEmpty() ? -1 : 0 }; - while ( nIdx >= 0 ) + sal_Int32 nIdx { rInfos.sCmd.isEmpty() ? -1 : 0 }; + while ( nIdx >= 0 ) + { + OUString sToken = rInfos.sCmd.getToken( 0, '\t', nIdx ); + if ( rInfos.eType == ww::eCREATEDATE + || rInfos.eType == ww::eSAVEDATE + || rInfos.eType == ww::ePRINTDATE + || rInfos.eType == ww::eDATE + || rInfos.eType == ww::eTIME ) { - OUString sToken = rInfos.sCmd.getToken( 0, '\t', nIdx ); - if ( rInfos.eType == ww::eCREATEDATE - || rInfos.eType == ww::eSAVEDATE - || rInfos.eType == ww::ePRINTDATE - || rInfos.eType == ww::eDATE - || rInfos.eType == ww::eTIME ) - { - sToken = sToken.replaceAll("NNNN", "dddd"); - sToken = sToken.replaceAll("NN", "ddd"); - } - else if ( rInfos.eType == ww::eEquals ) + sToken = sToken.replaceAll("NNNN", "dddd"); + sToken = sToken.replaceAll("NN", "ddd"); + } + else if ( rInfos.eType == ww::eEquals ) + { + // Use original OOXML formula, if it exists and its conversion hasn't been changed + bool bIsChanged = true; + if ( pNode->GetTableBox() ) { - // Use original OOXML formula, if it exists and its conversion hasn't been changed - bool bIsChanged = true; - if ( pNode->GetTableBox() ) + if ( const SfxGrabBagItem* pItem = pNode->GetTableBox()->GetFrameFormat()->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG) ) { - if ( const SfxGrabBagItem* pItem = pNode->GetTableBox()->GetFrameFormat()->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG) ) + OUString sActualFormula = sToken.trim(); + const std::map<OUString, uno::Any>& rGrabBag = pItem->GetGrabBag(); + std::map<OUString, uno::Any>::const_iterator aStoredFormula = rGrabBag.find("CellFormulaConverted"); + if ( aStoredFormula != rGrabBag.end() && sActualFormula.indexOf('=') == 0 && + sActualFormula.copy(1).trim() == aStoredFormula->second.get<OUString>().trim() ) { - OUString sActualFormula = sToken.trim(); - const std::map<OUString, uno::Any>& rGrabBag = pItem->GetGrabBag(); - std::map<OUString, uno::Any>::const_iterator aStoredFormula = rGrabBag.find("CellFormulaConverted"); - if ( aStoredFormula != rGrabBag.end() && sActualFormula.indexOf('=') == 0 && - sActualFormula.copy(1).trim() == aStoredFormula->second.get<OUString>().trim() ) + aStoredFormula = rGrabBag.find("CellFormula"); + if ( aStoredFormula != rGrabBag.end() ) { - aStoredFormula = rGrabBag.find("CellFormula"); - if ( aStoredFormula != rGrabBag.end() ) - { - sToken = " =" + aStoredFormula->second.get<OUString>(); - bIsChanged = false; - } + sToken = " =" + aStoredFormula->second.get<OUString>(); + bIsChanged = false; } } } + } - if ( bIsChanged ) - { - UErrorCode nErr(U_ZERO_ERROR); - icu::UnicodeString sInput(sToken.getStr()); - // remove < and > around cell references, e.g. <A1> to A1, <A1:B2> to A1:B2 - icu::RegexMatcher aMatcher("<([A-Z]{1,3}[0-9]+(:[A-Z]{1,3}[0-9]+)?)>", sInput, 0, nErr); - sInput = aMatcher.replaceAll(icu::UnicodeString("$1"), nErr); - // convert MEAN to AVERAGE - icu::RegexMatcher aMatcher2("\\bMEAN\\b", sInput, UREGEX_CASE_INSENSITIVE, nErr); - sToken = aMatcher2.replaceAll(icu::UnicodeString("AVERAGE"), nErr).getTerminatedBuffer(); - } + if ( bIsChanged ) + { + UErrorCode nErr(U_ZERO_ERROR); + icu::UnicodeString sInput(sToken.getStr()); + // remove < and > around cell references, e.g. <A1> to A1, <A1:B2> to A1:B2 + icu::RegexMatcher aMatcher("<([A-Z]{1,3}[0-9]+(:[A-Z]{1,3}[0-9]+)?)>", sInput, 0, nErr); + sInput = aMatcher.replaceAll(icu::UnicodeString("$1"), nErr); + // convert MEAN to AVERAGE + icu::RegexMatcher aMatcher2("\\bMEAN\\b", sInput, UREGEX_CASE_INSENSITIVE, nErr); + sToken = aMatcher2.replaceAll(icu::UnicodeString("AVERAGE"), nErr).getTerminatedBuffer(); } + } - // Write the Field command - DoWriteCmd( sToken ); + // Write the Field command + DoWriteCmd( sToken ); - // Replace tabs by </instrText><tab/><instrText> - if ( nIdx > 0 ) // Is another token expected? - RunText( "\t" ); - } + // Replace tabs by </instrText><tab/><instrText> + if ( nIdx > 0 ) // Is another token expected? + RunText( "\t" ); + } - if ( bWriteRun ) - { - m_pSerializer->endElementNS( XML_w, XML_r ); - } + if ( bWriteRun ) + { + m_pSerializer->endElementNS( XML_w, XML_r ); } } @@ -5106,11 +5103,10 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size m_pSerializer->startElementNS(XML_a, XML_blip, FSNS(XML_r, nImageType), aRelId); pItem = nullptr; - GraphicDrawMode nMode = GraphicDrawMode::Standard; if ( pGrfNode && SfxItemState::SET == pGrfNode->GetSwAttrSet().GetItemState(RES_GRFATR_DRAWMODE, true, &pItem)) { - nMode = static_cast<GraphicDrawMode>(static_cast<const SfxEnumItemInterface*>(pItem)->GetEnumValue()); + GraphicDrawMode nMode = static_cast<GraphicDrawMode>(static_cast<const SfxEnumItemInterface*>(pItem)->GetEnumValue()); if (nMode == GraphicDrawMode::Greys) m_pSerializer->singleElementNS (XML_a, XML_grayscl); else if (nMode == GraphicDrawMode::Mono) //black/white has a 0,5 threshold in LibreOffice @@ -5270,9 +5266,9 @@ bool DocxAttributeOutput::WriteOLEMath( const SwOLENode& rOLENode ,const sal_Int if( !SotExchange::IsMath(aObjName) ) return false; - PostponedMathObjects aPostponedMathObject; try { + PostponedMathObjects aPostponedMathObject; aPostponedMathObject.pMathObject = const_cast<SwOLENode*>( &rOLENode); aPostponedMathObject.nMathObjAlignment = nAlign; m_aPostponedMaths.push_back(aPostponedMathObject); @@ -5613,10 +5609,9 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S if ( sDrawAspect == "Content" ) { - awt::Size aSize; try { - aSize = xObj->getVisualAreaSize( rNode.GetAspect() ); + awt::Size aSize = xObj->getVisualAreaSize( rNode.GetAspect() ); MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( rNode.GetAspect() ) ); Size aOriginalSize( OutputDevice::LogicToLogic(Size( aSize.Width, aSize.Height), diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index e045f5bb235e..f1870277a7fd 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1104,7 +1104,6 @@ void DocxExport::WriteSettings() bool bWriterWantsToProtect = false; bool bWriterWantsToProtectForm = false; bool bWriterWantsToProtectRedline = false; - bool bHasRedlineProtectionKey = false; bool bHasDummyRedlineProtectionKey = false; bool bReadOnlyStatusUnchanged = true; uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); @@ -1117,7 +1116,7 @@ void DocxExport::WriteSettings() { uno::Sequence<sal_Int8> aKey; xPropSet->getPropertyValue( "RedlineProtectionKey" ) >>= aKey; - bHasRedlineProtectionKey = aKey.hasElements(); + bool bHasRedlineProtectionKey = aKey.hasElements(); bHasDummyRedlineProtectionKey = aKey.getLength() == 1 && aKey[0] == 1; if ( bHasRedlineProtectionKey && !bHasDummyRedlineProtectionKey ) bWriterWantsToProtect = bWriterWantsToProtectRedline = true; diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 30d08a8cb2e5..04fdb17b67da 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -1029,10 +1029,10 @@ bool DocxSdrExport::Impl::isSupportedDMLShape(const uno::Reference<drawing::XSha return false; // For signature line shapes, we don't want DML, just the VML shape. - bool bIsSignatureLineShape = false; if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape")) { uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY); + bool bIsSignatureLineShape = false; xShapeProperties->getPropertyValue("IsSignatureLine") >>= bIsSignatureLineShape; if (bIsSignatureLineShape) return false; diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 7c24d92e81ba..fa8be14f70cc 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -181,11 +181,11 @@ void SwBasicEscherEx::WriteHyperlinkWithinFly( SvMemoryStream& rStrm, const SwFo 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //const sal_uInt18 WW8_ID_HLINK = 0x01B8; - const sal_uInt32 WW8_HLINK_BODY = 0x00000001; /// Contains file link or URL. - const sal_uInt32 WW8_HLINK_ABS = 0x00000002; /// Absolute path. + constexpr sal_uInt32 WW8_HLINK_BODY = 0x00000001; /// Contains file link or URL. + constexpr sal_uInt32 WW8_HLINK_ABS = 0x00000002; /// Absolute path. //const sal_uInt32 WW8_HLINK_DESCR = 0x00000014; /// Description. - const sal_uInt32 WW8_HLINK_MARK = 0x00000008; /// Text mark. - const sal_uInt32 WW8_HLINK_FRAME = 0x00000080; /// Target frame. + constexpr sal_uInt32 WW8_HLINK_MARK = 0x00000008; /// Text mark. + constexpr sal_uInt32 WW8_HLINK_FRAME = 0x00000080; /// Target frame. //const sal_uInt32 WW8_HLINK_UNC = 0x00000100; /// UNC path. SvMemoryStream tmpStrm; OUString tmpTextMark; @@ -1986,8 +1986,8 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, { const SvxShadowItem* pSI = static_cast<const SvxShadowItem*>(pShadItem); - const sal_uInt16 nCstScale = 635; // unit scale between AOO and MS Word - const sal_uInt32 nShadowType = 131074; // shadow type of ms word. need to set the default value. + constexpr sal_uInt16 nCstScale = 635; // unit scale between AOO and MS Word + constexpr sal_uInt32 nShadowType = 131074; // shadow type of ms word. need to set the default value. Color nColor = pSI->GetColor(); sal_Int32 nOffX = pSI->GetWidth() * nCstScale; diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index b3d9752f215e..95004ec747c7 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -220,12 +220,12 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS { // (0x01B8) HLINK // const sal_uInt16 WW8_ID_HLINK = 0x01B8; - const sal_uInt32 WW8_HLINK_BODY = 0x00000001; /// Contains file link or URL. - const sal_uInt32 WW8_HLINK_ABS = 0x00000002; /// Absolute path. - const sal_uInt32 WW8_HLINK_DESCR = 0x00000014; /// Description. - const sal_uInt32 WW8_HLINK_MARK = 0x00000008; /// Text mark. - const sal_uInt32 WW8_HLINK_FRAME = 0x00000080; /// Target frame. - const sal_uInt32 WW8_HLINK_UNC = 0x00000100; /// UNC path. + constexpr sal_uInt32 WW8_HLINK_BODY = 0x00000001; /// Contains file link or URL. + constexpr sal_uInt32 WW8_HLINK_ABS = 0x00000002; /// Absolute path. + constexpr sal_uInt32 WW8_HLINK_DESCR = 0x00000014; /// Description. + constexpr sal_uInt32 WW8_HLINK_MARK = 0x00000008; /// Text mark. + constexpr sal_uInt32 WW8_HLINK_FRAME = 0x00000080; /// Target frame. + constexpr sal_uInt32 WW8_HLINK_UNC = 0x00000100; /// UNC path. //sal_uInt8 maGuidStdLink[ 16 ] ={ // 0xD0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B }; @@ -243,7 +243,6 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS rStrm.SeekRel( 4 ); rStrm.ReadUInt32( nFlags ); - sal_uInt16 nLevel = 0; // counter for level to climb down in path std::unique_ptr< OUString > xLongName; // link / file name std::unique_ptr< OUString > xShortName; // 8.3-representation of file name std::unique_ptr< OUString > xTextMark; // text mark @@ -279,6 +278,7 @@ void SwWW8ImplReader::ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocS if( memcmp(aGuid, aGuidFileMoniker, 16) == 0 ) { + sal_uInt16 nLevel = 0; // counter for level to climb down in path rStrm.ReadUInt16( nLevel ); // MS-OSHARED: An unsigned integer that specifies the number of // ANSI characters in ansiPath, including the terminating NULL character @@ -1106,7 +1106,6 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, { SvMemoryStream aMemStream; struct HyperLinksTable hlStr; - sal_uInt16 nRawRecId,nRawRecSize; aMemStream.WriteUInt16( 0 ).WriteUInt16( nBufferSize ); // copy from DFF stream to memory stream @@ -1117,6 +1116,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, sal_uInt8 nStreamSize = aMemStream.TellEnd(); aMemStream.Seek( STREAM_SEEK_TO_BEGIN ); bool bRet = 4 <= nStreamSize; + sal_uInt16 nRawRecId,nRawRecSize; if( bRet ) aMemStream.ReadUInt16( nRawRecId ).ReadUInt16( nRawRecSize ); SwDocShell* pDocShell = rReader.m_pDocShell; @@ -3596,12 +3596,12 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) if (!checkSeek(*m_pStrm, nRequestedPos)) return false; - sal_uInt8 nBCode(0); sal_uInt16 nWCharVal(0); if( m_bIsUnicode ) m_pStrm->ReadUInt16( nWCharVal ); // unicode --> read 2 bytes else { + sal_uInt8 nBCode(0); m_pStrm -> ReadUChar( nBCode ); // old code --> read 1 byte nWCharVal = nBCode; } @@ -4825,13 +4825,12 @@ void SwWW8ImplReader::ReadDocInfo() if ( m_xWwFib->m_fDot ) { - OUString sTemplateURL; SfxMedium* pMedium = m_pDocShell->GetMedium(); if ( pMedium ) { const OUString& aName = pMedium->GetName(); INetURLObject aURL( aName ); - sTemplateURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::ToIUri); + OUString sTemplateURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::ToIUri); if ( !sTemplateURL.isEmpty() ) xDocProps->setTemplateURL( sTemplateURL ); } @@ -4877,11 +4876,10 @@ static void lcl_createTemplateToProjectEntry( const uno::Reference< container::X try { OUString templateNameWithExt = aObj.GetLastName(); - OUString templateName; sal_Int32 nIndex = templateNameWithExt.lastIndexOf( '.' ); if ( nIndex != -1 ) { - templateName = templateNameWithExt.copy( 0, nIndex ); + OUString templateName = templateNameWithExt.copy( 0, nIndex ); xPrjNameCache->insertByName( templateName, uno::makeAny( sVBAProjName ) ); } } diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx index aab0a0069273..1a0978bc9bbd 100644 --- a/sw/source/filter/xml/xmlimpit.cxx +++ b/sw/source/filter/xml/xmlimpit.cxx @@ -953,9 +953,9 @@ bool SvXMLImportItemMapper::PutXMLValue( break; } - sal_Int32 nValue; if( bSetHeight || bSetWidth ) { + sal_Int32 nValue; bOk = rUnitConverter.convertMeasureToCore(nValue, rValue, nMin, USHRT_MAX ); if( bOk ) diff --git a/sw/source/ui/chrdlg/numpara.cxx b/sw/source/ui/chrdlg/numpara.cxx index 17b436d5135b..9a8d7e8c87d9 100644 --- a/sw/source/ui/chrdlg/numpara.cxx +++ b/sw/source/ui/chrdlg/numpara.cxx @@ -165,10 +165,9 @@ void SwParagraphNumTabPage::Reset(const SfxItemSet* rSet) SfxItemState eItemState = rSet->GetItemState( GetWhich(SID_ATTR_PARA_OUTLINE_LEVEL) ); - sal_Int16 nOutlineLv; if( eItemState >= SfxItemState::DEFAULT ) { - nOutlineLv = static_cast<const SfxUInt16Item &>(rSet->Get( GetWhich(SID_ATTR_PARA_OUTLINE_LEVEL) )).GetValue(); + sal_Int16 nOutlineLv = static_cast<const SfxUInt16Item &>(rSet->Get( GetWhich(SID_ATTR_PARA_OUTLINE_LEVEL) )).GetValue(); m_xOutlineLvLB->set_active(nOutlineLv) ; } else diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index e05e881e45cb..dc02888cf0fb 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -80,11 +80,11 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( weld::Window* pParent, SwDocShell& rDocSh, const OUString sFindNm = OUString::createFromAscii( pStream ? sDialogImpExtraData : sDialogExpExtraData); - sal_Int32 nEnd, nStt = m_sExtraData.indexOf( sFindNm ); + sal_Int32 nStt = m_sExtraData.indexOf( sFindNm ); if( -1 != nStt ) { nStt += nDialogExtraDataLen; - nEnd = m_sExtraData.indexOf( cDialogExtraDataClose, nStt ); + sal_Int32 nEnd = m_sExtraData.indexOf( cDialogExtraDataClose, nStt ); if( -1 != nEnd ) { aOpt.ReadUserData(m_sExtraData.copy(nStt, nEnd - nStt)); @@ -282,11 +282,11 @@ void SwAsciiFilterDlg::FillOptions( SwAsciiOptions& rOptions ) const OUString sFindNm = OUString::createFromAscii( m_xFontLB->get_visible() ? sDialogImpExtraData : sDialogExpExtraData); - sal_Int32 nEnd, nStt = m_sExtraData.indexOf( sFindNm ); + sal_Int32 nStt = m_sExtraData.indexOf( sFindNm ); if( -1 != nStt ) { // called twice, so remove "old" settings - nEnd = m_sExtraData.indexOf( cDialogExtraDataClose, + sal_Int32 nEnd = m_sExtraData.indexOf( cDialogExtraDataClose, nStt + nDialogExtraDataLen ); if( -1 != nEnd ) m_sExtraData = m_sExtraData.replaceAt( nStt, nEnd - nStt + 1, "" ); diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index fa2b9ac9d63e..13c15a461832 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -520,7 +520,6 @@ void SwDocShell::Execute(SfxRequest& rReq) static bool bPage = false; static bool bNum = false; static bool bMerge = false; - sal_uInt16 nRet = USHRT_MAX; SfxTemplateFlags nFlags = bFrame ? SfxTemplateFlags::LOAD_FRAME_STYLES : SfxTemplateFlags::NONE; if(bPage) @@ -550,7 +549,7 @@ void SwDocShell::Execute(SfxRequest& rReq) SfxNewFileDialog aNewFileDlg(GetView()->GetFrameWeld(), SfxNewFileDialogMode::LoadTemplate); aNewFileDlg.SetTemplateFlags(nFlags); - nRet = aNewFileDlg.run(); + sal_uInt16 nRet = aNewFileDlg.run(); if(RET_TEMPLATE_LOAD == nRet) { FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE, diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index cf1150f72a55..e4f398a42ac4 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -1169,11 +1169,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, std::unique_ptr< utl::TempFile > aTempFile; sal_uInt16 nStartingPageNo = 0; - vcl::Window *pSourceWindow = nullptr; std::shared_ptr<weld::GenericDialogController> xProgressDlg; try { + vcl::Window *pSourceWindow = nullptr; if( !bIsMergeSilent ) { // construct the process dialog @@ -1317,12 +1317,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, } } - OUString sPasswordColumnData; uno::Sequence< beans::PropertyValue > aSaveToFilterDataOptions( rMergeDescriptor.aSaveToFilterData ); if( bMT_EMAIL || bPasswordColumnName ) { - sPasswordColumnData = GetDBField( xPasswordColumnProp, aColumnDBFormat ); + OUString sPasswordColumnData = GetDBField( xPasswordColumnProp, aColumnDBFormat ); lcl_PrepareSaveFilterDataOptions( rMergeDescriptor.aSaveToFilterData, aSaveToFilterDataOptions, sPasswordColumnData ); } diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 745731327a09..c530bca6d61f 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1391,7 +1391,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt { SwPasteContext aPasteContext(rSh); - sal_uInt8 nEventAction, nAction=0; + sal_uInt8 nAction=0; SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh ); SotClipboardFormatId nFormat = SotClipboardFormatId::NONE; SotExchangeActionFlags nActionFlags = SotExchangeActionFlags::NONE; @@ -1411,6 +1411,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt ? EXCHG_IN_ACTION_COPY : EXCHG_IN_ACTION_MOVE); uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() ); + sal_uInt8 nEventAction; nAction = SotExchange::GetExchangeAction( rData.GetDataFlavorExVector(), nDestination, @@ -3308,9 +3309,10 @@ bool SwTransferable::PasteFormat( SwWrtShell& rSh, bool SwTransferable::TestAllowedFormat( const TransferableDataHelper& rData, SotClipboardFormatId nFormat, SotExchangeDest nDestination ) { - sal_uInt8 nAction = EXCHG_INOUT_ACTION_NONE, nEventAction; + sal_uInt8 nAction = EXCHG_INOUT_ACTION_NONE; if( rData.HasFormat( nFormat )) { uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() ); + sal_uInt8 nEventAction; nAction = SotExchange::GetExchangeAction( rData.GetDataFlavorExVector(), nDestination, EXCHG_IN_ACTION_COPY, diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx index 59d4e2555d97..d103de0b74f4 100644 --- a/sw/source/uibase/docvw/srcedtw.cxx +++ b/sw/source/uibase/docvw/srcedtw.cxx @@ -87,9 +87,9 @@ static void lcl_Highlight(const OUString& rSource, TextPortions& aPortionList) TextPortion aText; while(nActPos < nStrLen) { - svtools::ColorConfigEntry eFoundType = svtools::HTMLUNKNOWN; if((nActPos < nStrLen - 2) && (rSource[nActPos] == cOpenBracket)) { + svtools::ColorConfigEntry eFoundType = svtools::HTMLUNKNOWN; // insert 'empty' portion if(nPortEnd < nActPos - 1 ) { diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 96fe6e375627..a761111bacb5 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1217,13 +1217,12 @@ bool SwFieldMgr::InsertField( // extract DBName from rData.m_sPar1. Format: DBName.TableName.CommandType.ExpStrg sal_Int32 nTablePos = rData.m_sPar1.indexOf(DB_DELIM); - sal_Int32 nCmdTypePos = -1; sal_Int32 nExpPos = -1; if (nTablePos>=0) { aDBData.sDataSource = rData.m_sPar1.copy(0, nTablePos++); - nCmdTypePos = rData.m_sPar1.indexOf(DB_DELIM, nTablePos); + sal_Int32 nCmdTypePos = rData.m_sPar1.indexOf(DB_DELIM, nTablePos); if (nCmdTypePos>=0) { aDBData.sCommand = rData.m_sPar1.copy(nTablePos, nCmdTypePos++ - nTablePos); diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx index 36d231bc4dde..80fb24123c8f 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -212,12 +212,11 @@ namespace void lcl_convertStringArguments(sal_uInt16 nSlot, std::unique_ptr<SfxItemSet>& pArgs) { Color aColor; - OUString sColor; const SfxPoolItem* pItem = nullptr; if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pItem)) { - sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); + OUString sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); if (sColor == "transparent") aColor = COL_TRANSPARENT; diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 2a4ff0a32f2e..09a0017e3ec3 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1182,7 +1182,6 @@ void SwTextShell::Execute(SfxRequest &rReq) case SID_ATTR_CHAR_COLOR2: { Color aSet; - OUString sColor; const SfxPoolItem* pColorStringItem = nullptr; bool bHasItem = false; @@ -1193,7 +1192,7 @@ void SwTextShell::Execute(SfxRequest &rReq) } else if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem)) { - sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); + OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); aSet = Color(sColor.toInt32(16)); bHasItem = true; } @@ -1220,12 +1219,11 @@ void SwTextShell::Execute(SfxRequest &rReq) case SID_ATTR_CHAR_COLOR_EXT: { Color aSet; - OUString sColor; const SfxPoolItem* pColorStringItem = nullptr; if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem)) { - sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); + OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); if (sColor == "transparent") aSet = COL_TRANSPARENT; else @@ -2053,10 +2051,9 @@ void SwTextShell::GetState( SfxItemSet &rSet ) case FN_OUTLINE_RULE_INDEX: { SwNumRule* pCurRule = const_cast<SwNumRule*>(GetShell().GetNumRuleAtCurrCursorPos()); - sal_uInt16 nActNumLvl = USHRT_MAX; if( pCurRule ) { - nActNumLvl = GetShell().GetNumLevel(); + sal_uInt16 nActNumLvl = GetShell().GetNumLevel(); if( nActNumLvl < MAXLEVEL ) { nActNumLvl = 1<<nActNumLvl; diff --git a/sw/source/uibase/sidebar/PageColumnControl.cxx b/sw/source/uibase/sidebar/PageColumnControl.cxx index 1675867acd8d..8b979af19668 100644 --- a/sw/source/uibase/sidebar/PageColumnControl.cxx +++ b/sw/source/uibase/sidebar/PageColumnControl.cxx @@ -37,9 +37,9 @@ PageColumnControl::PageColumnControl(PageColumnPopup* pControl, weld::Widget* pP , m_xControl(pControl) { bool bLandscape = false; - const SfxPoolItem *pItem; if ( SfxViewFrame::Current() ) { + const SfxPoolItem *pItem; SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); } diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx index 065588eda318..2ef8b200aae4 100644 --- a/sw/source/uibase/sidebar/PageMarginControl.cxx +++ b/sw/source/uibase/sidebar/PageMarginControl.cxx @@ -127,12 +127,12 @@ PageMarginControl::PageMarginControl(PageMarginPopup* pControl, weld::Widget* pP SetFieldUnit( *m_xWidthHeightField, lcl_GetFieldUnit() ); bool bLandscape = false; - const SfxPoolItem* pItem; const SvxSizeItem* pSize = nullptr; const SvxLongLRSpaceItem* pLRItem = nullptr; const SvxLongULSpaceItem* pULItem = nullptr; if ( SfxViewFrame::Current() ) { + const SfxPoolItem* pItem; SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); bLandscape = static_cast<const SvxPageItem*>( pItem )->IsLandscape(); m_bMirrored = static_cast<const SvxPageItem*>( pItem )->GetPageUsage() == SvxPageUsage::Mirror; diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx index 00bcfc0a6a3d..7fa49f4f75c3 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.cxx +++ b/sw/source/uibase/sidebar/PageSizeControl.cxx @@ -120,10 +120,10 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, weld::Widget* pParent) } bool bLandscape = false; - const SfxPoolItem* pItem; const SvxSizeItem* pSize = nullptr; if ( SfxViewFrame::Current() ) { + const SfxPoolItem* pItem; SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pItem ); diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index cb8c44e143c1..362b08bfc54d 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -839,11 +839,10 @@ void SwPagePreview::Execute( SfxRequest &rReq ) } case SID_JUMP_TO_SPECIFIC_PAGE: { - sal_uInt16 nPageNum = 1; const SfxItemSet *pArgs = rReq.GetArgs(); if( pArgs && pArgs->Count()) { - nPageNum = static_cast<const SfxUInt16Item &>(pArgs->Get(SID_JUMP_TO_SPECIFIC_PAGE)).GetValue(); + sal_uInt16 nPageNum = static_cast<const SfxUInt16Item &>(pArgs->Get(SID_JUMP_TO_SPECIFIC_PAGE)).GetValue(); if( nPageNum > 0 && nPageNum <= mnPageCount ) { diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 422133559c45..88f9f0979919 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -2369,9 +2369,9 @@ void SwContentTree::ToggleToRoot() { std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator()); bool bEntry = m_xTreeView->get_cursor(xEntry.get()); - const SwContentType* pCntType; if (bEntry) { + const SwContentType* pCntType; if (lcl_IsContentType(*xEntry, *m_xTreeView)) { assert(dynamic_cast<SwContentType*>(reinterpret_cast<SwTypeNumber*>(m_xTreeView->get_id(*xEntry).toInt64()))); |