sw/source/core/unocore/unostyle.cxx | 23 +++++++++++---------- sw/source/core/unocore/unotbl.cxx | 38 ++++++++++++++++++------------------ sw/source/core/view/viewsh.cxx | 6 ++--- sw/source/core/view/vprint.cxx | 2 - sw/source/filter/basflt/fltini.cxx | 6 ++--- sw/source/filter/basflt/shellio.cxx | 4 +-- 6 files changed, 40 insertions(+), 39 deletions(-)
New commits: commit 1848430d614e0f2f52e288363d0367c9207b0802 Author: Matteo Casalin <[email protected]> Date: Tue May 5 22:45:29 2015 +0200 Use more proper integer types Change-Id: If1515df57cd90451f2c912bf5c268fec8688c063 diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 4911902..cde2dcf 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -438,14 +438,15 @@ static bool lcl_GetHeaderFooterItem( } static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc, - SfxStyleFamily eFamily, OUString *pString, sal_uInt16 nIndex = USHRT_MAX) + SfxStyleFamily eFamily, OUString *pString, sal_Int32 nIndex = SAL_MAX_INT32) { sal_Int32 nCount = 0; switch( eFamily ) { case SFX_STYLE_FAMILY_CHAR: { - sal_uInt16 nBaseCount = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN + + const sal_Int32 nBaseCount = + RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN + RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN; nIndex = nIndex - nBaseCount; const size_t nArrLen = rDoc.GetCharFmts()->size(); @@ -474,7 +475,8 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc, break; case SFX_STYLE_FAMILY_PARA: { - sal_uInt16 nBaseCount = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN + + const sal_Int32 nBaseCount = + RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN + RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN + RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN + RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN + @@ -502,7 +504,7 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc, break; case SFX_STYLE_FAMILY_FRAME: { - sal_uInt16 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN; + const sal_Int32 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN; nIndex = nIndex - nBaseCount; const size_t nArrLen = rDoc.GetFrmFmts()->size(); for( size_t i = 0; i < nArrLen; ++i ) @@ -525,7 +527,7 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc, break; case SFX_STYLE_FAMILY_PAGE: { - sal_uInt16 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN; + const sal_Int32 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN; nIndex = nIndex - nBaseCount; const sal_uInt16 nArrLen = rDoc.GetPageDescCnt(); for(sal_uInt16 i = 0; i < nArrLen; ++i) @@ -547,7 +549,7 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc, break; case SFX_STYLE_FAMILY_PSEUDO: { - sal_uInt16 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN; + const sal_Int32 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN; nIndex = nIndex - nBaseCount; const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl(); for(size_t i = 0; i < rNumTbl.size(); ++i) @@ -581,14 +583,13 @@ sal_Int32 SwXStyleFamily::getCount() throw( uno::RuntimeException, std::exceptio return lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, NULL ); } -uno::Any SwXStyleFamily::getByIndex(sal_Int32 nTempIndex) +uno::Any SwXStyleFamily::getByIndex(sal_Int32 nIndex) throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; uno::Any aRet; - if ( nTempIndex >= 0 && nTempIndex < USHRT_MAX ) + if ( nIndex >= 0 ) { - sal_uInt16 nIndex = static_cast < sal_uInt16 > ( nTempIndex ); if(pBasePool) { OUString sStyleName; @@ -1065,7 +1066,7 @@ SwStyleProperties_Impl::~SwStyleProperties_Impl() bool SwStyleProperties_Impl::SetProperty(const OUString& rName, const uno::Any& rVal) { - sal_uInt16 nPos = 0; + sal_uInt32 nPos = 0; bool bRet = false; PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin(); while( aIt != aPropertyEntries.end() ) @@ -2250,7 +2251,7 @@ void SAL_CALL SwXStyle::SetPropertyValues_Impl( throw uno::RuntimeException(); } - for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); ++nProp) { const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pNames[nProp]); commit 3cc95ee73e029efbfeff3203f5a9a1b51105a1d9 Author: Matteo Casalin <[email protected]> Date: Mon May 4 23:10:39 2015 +0200 Store getColumnCount()/getRowCount() results in sal_Int32 instead of sal_uInt16, to match type preferred by following code. Also use size_t for calculating products, just to stay on the safe side Change-Id: Id875e01aa2087fc27e60536d5e3ef152b22aadc6 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 93c9072..7218bae 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3159,12 +3159,12 @@ SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, std::vector< uno::Reference< table::XCell > > SwXCellRange::getCells() { SwFrmFmt* const pFmt = GetFrmFmt(); - const size_t nRowCount(getRowCount()); - const size_t nColCount(getColumnCount()); + const sal_Int32 nRowCount(getRowCount()); + const sal_Int32 nColCount(getColumnCount()); std::vector< uno::Reference< table::XCell > > vResult; - vResult.reserve(nRowCount*nColCount); - for(sal_uInt16 nRow = 0; nRow < nRowCount; ++nRow) - for(sal_uInt16 nCol = 0; nCol < nColCount; ++nCol) + vResult.reserve(static_cast<size_t>(nRowCount)*static_cast<size_t>(nColCount)); + for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow) + for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol) vResult.push_back(uno::Reference< table::XCell >(lcl_CreateXCell(pFmt, aRgDesc.nLeft + nCol, aRgDesc.nTop + nRow))); return vResult; } @@ -3498,8 +3498,8 @@ void SwXCellRange::GetDataSequence( // compare to SwXCellRange::getDataArray (note different return types though) - const sal_uInt16 nRowCount = getRowCount(); - const sal_uInt16 nColCount = getColumnCount(); + const sal_Int32 nRowCount = getRowCount(); + const sal_Int32 nColCount = getColumnCount(); if(!nRowCount || !nColCount) { @@ -3508,7 +3508,7 @@ void SwXCellRange::GetDataSequence( throw aRuntime; } - sal_Int32 nSize = nRowCount * nColCount; + const size_t nSize = static_cast<size_t>(nRowCount) * static_cast<size_t>(nColCount); if (pAnySeq) pAnySeq->realloc( nSize ); else if (pTxtSeq) @@ -3524,7 +3524,7 @@ void SwXCellRange::GetDataSequence( OUString *pTxtData = pTxtSeq ? pTxtSeq->getArray() : 0; double *pDblData = pDblSeq ? pDblSeq->getArray() : 0; - sal_Int32 nDtaCnt = 0; + size_t nDtaCnt = 0; SwFrmFmt* pFmt = GetFrmFmt(); if(pFmt) { @@ -3532,9 +3532,9 @@ void SwXCellRange::GetDataSequence( ::rtl::math::setNan( & fNan ); uno::Reference< table::XCell > xCellRef; - for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++) + for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow) { - for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++) + for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol) { SwXCell * pXCell = lcl_CreateXCell(pFmt, aRgDesc.nLeft + nCol, @@ -3633,8 +3633,8 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray() throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - const sal_uInt16 nRowCount = getRowCount(); - const sal_uInt16 nColCount = getColumnCount(); + const sal_Int32 nRowCount = getRowCount(); + const sal_Int32 nColCount = getColumnCount(); if(!nRowCount || !nColCount) throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); @@ -3664,8 +3664,8 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray() void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray) throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - const sal_uInt16 nRowCount = getRowCount(); - const sal_uInt16 nColCount = getColumnCount(); + const sal_Int32 nRowCount = getRowCount(); + const sal_Int32 nColCount = getColumnCount(); if(!nRowCount || !nColCount) throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); SwFrmFmt* pFmt = GetFrmFmt(); @@ -3698,8 +3698,8 @@ void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno uno::Sequence< uno::Sequence< double > > SwXCellRange::getData() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - const sal_uInt16 nRowCount = getRowCount(); - const sal_uInt16 nColCount = getColumnCount(); + const sal_Int32 nRowCount = getRowCount(); + const sal_Int32 nColCount = getColumnCount(); if(!nRowCount || !nColCount) throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel) @@ -3727,8 +3727,8 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - const sal_uInt16 nRowCount = getRowCount(); - const sal_uInt16 nColCount = getColumnCount(); + const sal_Int32 nRowCount = getRowCount(); + const sal_Int32 nColCount = getColumnCount(); if(!nRowCount || !nColCount) throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel) commit 97911bf9cf1c3d27c9ff1fe7d98f9ae1bbce3c40 Author: Matteo Casalin <[email protected]> Date: Mon May 4 08:17:45 2015 +0200 Use more proper integer types Change-Id: I8200af6fcb111edd8a00cb77824e84e2231bee1b diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 5caa64d..378a79e 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -164,7 +164,7 @@ Reader* GetReader( ReaderWriterEnum eReader ) void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xRet ) { - for( sal_uInt16 n = 0; n < MAXFILTER; ++n ) + for( int n = 0; n < MAXFILTER; ++n ) if ( aFilterDetect[n].IsFilter( rFltName ) ) { aReaderWriter[n].GetWriter( rFltName, rBaseURL, xRet ); @@ -175,7 +175,7 @@ void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& x SwRead GetReader( const OUString& rFltName ) { SwRead pRead = 0; - for( sal_uInt16 n = 0; n < MAXFILTER; ++n ) + for( int n = 0; n < MAXFILTER; ++n ) { if ( aFilterDetect[n].IsFilter( rFltName ) ) { @@ -573,7 +573,7 @@ OUString NameFromCharSet(rtl_TextEncoding nChrSet) void SwAsciiOptions::ReadUserData( const OUString& rStr ) { sal_Int32 nToken = 0; - sal_uInt16 nCnt = 0; + int nCnt = 0; do { const OUString sToken = rStr.getToken( 0, ',', nToken ); if (!sToken.isEmpty()) diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 0d3796b..b934873 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -220,7 +220,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) rNd.FindFooterStartNode(); // search all new Fly's, and store them as individual Undo Objects - for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->size(); ++n ) + for( SwFrmFmts::size_type n = 0; n < pDoc->GetSpzFrmFmts()->size(); ++n ) { SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ n ]; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); @@ -628,7 +628,7 @@ void Reader::ResetFrmFmts( SwDoc& rDoc ) sal_uInt16 const s_ids[3] = { RES_POOLFRM_FRAME, RES_POOLFRM_GRAPHIC, RES_POOLFRM_OLE }; - for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(s_ids); ++i) + for (size_t i = 0; i < SAL_N_ELEMENTS(s_ids); ++i) { SwFrmFmt *const pFrmFmt = rDoc.getIDocumentStylePoolAccess().GetFrmFmtFromPool( s_ids[i] ); commit 6da921838f9756608553bd7dd231f4393ee0803d Author: Matteo Casalin <[email protected]> Date: Mon May 4 08:02:47 2015 +0200 Use more proper integer types and range-based for loops Change-Id: Icbda6c3ab23622e1d9f73d3a9a30ff0c278684cf diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 12591b9..bbed011 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -926,7 +926,7 @@ void SwViewShell::CalcLayout() const bool bEndProgress = SfxProgress::GetActiveProgress( GetDoc()->GetDocShell() ) == 0; if ( bEndProgress ) { - sal_uInt16 nEndPage = GetLayout()->GetPageNum(); + long nEndPage = GetLayout()->GetPageNum(); nEndPage += nEndPage * 10 / 100; ::StartProgress( STR_STATSTR_REFORMAT, 0, nEndPage, GetDoc()->GetDocShell() ); } @@ -1492,9 +1492,9 @@ void SwViewShell::_PaintDesktop( const SwRegionRects &rRegion ) GetOut()->Push( PushFlags::FILLCOLOR|PushFlags::LINECOLOR ); GetOut()->SetLineColor(); - for ( sal_uInt16 i = 0; i < rRegion.size(); ++i ) + for ( auto &rRgn : rRegion ) { - const Rectangle aRectangle(rRegion[i].SVRect()); + const Rectangle aRectangle(rRgn.SVRect()); // #i93170# // Here we have a real Problem. On the one hand we have the buffering for paint diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 4bc1c062..92ad716 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -378,7 +378,7 @@ SwDoc * SwViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) // get page descriptor - fall back to the first one if pPage could not be found const SwPageDesc* pPageDesc = pPage ? pPrtDoc->FindPageDesc( - pPage->GetPageDesc()->GetName() ) : &pPrtDoc->GetPageDesc( (sal_uInt16)0 ); + pPage->GetPageDesc()->GetName() ) : &pPrtDoc->GetPageDesc( 0 ); if( !pFESh->IsTableMode() && pActCrsr && pActCrsr->HasMark() ) { // Tweak paragraph attributes of last paragraph _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
