sw/inc/anchoredobject.hxx | 2 sw/inc/crstate.hxx | 2 sw/inc/expfld.hxx | 2 sw/inc/modeltoviewhelper.hxx | 12 - sw/inc/reffld.hxx | 2 sw/source/core/access/accportions.cxx | 2 sw/source/core/crsr/crstrvl.cxx | 2 sw/source/core/doc/docedt.cxx | 4 sw/source/core/edit/edlingu.cxx | 4 sw/source/core/fields/expfld.cxx | 4 sw/source/core/fields/reffld.cxx | 39 ++--- sw/source/core/text/txtfrm.cxx | 45 ++---- sw/source/core/txtnode/modeltoviewhelper.cxx | 183 ++++++++++++++++++++++++--- sw/source/core/txtnode/ndtxt.cxx | 136 -------------------- sw/source/core/txtnode/txtedt.cxx | 14 -- sw/source/core/unocore/unotextmarkup.cxx | 12 - 16 files changed, 228 insertions(+), 237 deletions(-)
New commits: commit 5170b4e49afd113567d4bbdd8f7b6be9eaa66888 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Dec 1 18:04:38 2013 +0100 Move functions to right file, prefer sal_Int32 to sal_uInt32 as index Change-Id: Ie5dca349acf2e163fdb6a47b0ba7af27220f2b2d diff --git a/sw/inc/modeltoviewhelper.hxx b/sw/inc/modeltoviewhelper.hxx index b22262b..d67110a 100644 --- a/sw/inc/modeltoviewhelper.hxx +++ b/sw/inc/modeltoviewhelper.hxx @@ -74,7 +74,7 @@ class ModelToViewHelper position in the view string. The last entry in the conversion map denotes the lengths of the model resp. view string. */ - typedef std::pair< sal_uInt32 , sal_uInt32 > ConversionMapEntry; + typedef std::pair< sal_Int32 , sal_Int32 > ConversionMapEntry; typedef std::vector< ConversionMapEntry > ConversionMap; ConversionMap m_aMap; @@ -91,14 +91,14 @@ public: */ struct ModelPosition { - sal_uInt32 mnPos; - sal_uInt32 mnSubPos; + sal_Int32 mnPos; + sal_Int32 mnSubPos; bool mbIsField; ModelPosition() : mnPos(0), mnSubPos(0), mbIsField(false) {} }; - ModelToViewHelper(const SwTxtNode &rNode, int eMode = EXPANDFIELDS); + ModelToViewHelper(const SwTxtNode &rNode, sal_uInt16 eMode = EXPANDFIELDS); ModelToViewHelper() //pass through filter, view == model { } @@ -116,7 +116,7 @@ public: nPos is behind the last entry in the conversion map) nPos will be returned. */ - sal_uInt32 ConvertToViewPosition( sal_uInt32 nModelPos ) const; + sal_Int32 ConvertToViewPosition( sal_Int32 nModelPos ) const; /** Converts a view position into a model position @@ -131,7 +131,7 @@ public: model position with mnPos = nPos and mnIsField = false will be returned. */ - ModelPosition ConvertToModelPosition( sal_uInt32 nViewPos ) const; + ModelPosition ConvertToModelPosition( sal_Int32 nViewPos ) const; OUString getViewText() const { return m_aRetText; } }; diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 35d6291..79fbd43 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -1799,8 +1799,8 @@ static void lcl_syncGrammarError( SwTxtNode &rTxtNode, linguistic2::Proofreading for( i = 0; i < rResult.aErrors.getLength(); ++i ) { const linguistic2::SingleProofreadingError &rError = rResult.aErrors[i]; - xub_StrLen nStart = (xub_StrLen)rConversionMap.ConvertToModelPosition( rError.nErrorStart ).mnPos; - xub_StrLen nEnd = (xub_StrLen)rConversionMap.ConvertToModelPosition( rError.nErrorStart + rError.nErrorLength ).mnPos; + const sal_Int32 nStart = rConversionMap.ConvertToModelPosition( rError.nErrorStart ).mnPos; + const sal_Int32 nEnd = rConversionMap.ConvertToModelPosition( rError.nErrorStart + rError.nErrorLength ).mnPos; if( i != j ) pArray[j] = pArray[i]; if( pWrong->LookForEntry( nStart, nEnd ) ) diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index c9f9b56..93d036f 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -1427,8 +1427,8 @@ bool SwSpellIter::SpellSentence(::svx::SpellPortions& rPortions, bool bIsGrammar { const ModelToViewHelper aConversionMap(*(SwTxtNode*)pCrsr->GetNode()); OUString aExpandText = aConversionMap.getViewText(); - sal_Int32 nSentenceEnd = static_cast<sal_Int32>( - aConversionMap.ConvertToViewPosition( aGrammarResult.nBehindEndOfSentencePosition )); + sal_Int32 nSentenceEnd = + aConversionMap.ConvertToViewPosition( aGrammarResult.nBehindEndOfSentencePosition ); // remove trailing space if( aExpandText[nSentenceEnd - 1] == ' ' ) --nSentenceEnd; diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx b/sw/source/core/txtnode/modeltoviewhelper.cxx index 861583d..db37048 100644 --- a/sw/source/core/txtnode/modeltoviewhelper.cxx +++ b/sw/source/core/txtnode/modeltoviewhelper.cxx @@ -18,35 +18,178 @@ */ #include <modeltoviewhelper.hxx> +#include <fldbas.hxx> +#include <fmtfld.hxx> +#include <fmtftn.hxx> +#include <ndtxt.hxx> +#include <txatbase.hxx> +#include <txtfld.hxx> +#include <txtftn.hxx> + +#include <tools/multisel.hxx> + +#include <scriptinfo.hxx> + +struct block +{ + sal_Int32 m_nStart; + sal_Int32 m_nLen; + bool m_bVisible; + std::vector<const SwTxtAttr*> m_aAttrs; + block(sal_Int32 nStart, sal_Int32 nLen, bool bVisible) + : m_nStart(nStart), m_nLen(nLen), m_bVisible(bVisible) + { + } +}; + +struct containsPos +{ + const sal_Int32 m_nPos; + containsPos(const sal_Int32 nPos) + : m_nPos(nPos) + { + } + bool operator() (const block& rIn) const + { + return m_nPos >= rIn.m_nStart && m_nPos < rIn.m_nStart + rIn.m_nLen; + } +}; + +ModelToViewHelper::ModelToViewHelper(const SwTxtNode &rNode, sal_uInt16 eMode) +{ + const OUString& rNodeText = rNode.GetTxt(); + m_aRetText = rNodeText; + + if (eMode == PASSTHROUGH) + return; + + Range aRange( 0, rNodeText.isEmpty() ? 0 : rNodeText.getLength() - 1); + MultiSelection aHiddenMulti(aRange); + + if (eMode & HIDEINVISIBLE) + SwScriptInfo::selectHiddenTextProperty(rNode, aHiddenMulti); + + if (eMode & HIDEREDLINED) + SwScriptInfo::selectRedLineDeleted(rNode, aHiddenMulti); + + std::vector<block> aBlocks; + + sal_Int32 nShownStart = 0; + for (size_t i = 0; i < aHiddenMulti.GetRangeCount(); ++i) + { + const Range& rRange = aHiddenMulti.GetRange(i); + const sal_Int32 nHiddenStart = rRange.Min(); + const sal_Int32 nHiddenEnd = rRange.Max() + 1; + const sal_Int32 nHiddenLen = nHiddenEnd - nHiddenStart; + + const sal_Int32 nShownEnd = nHiddenStart; + const sal_Int32 nShownLen = nShownEnd - nShownStart; + + if (nShownLen) + aBlocks.push_back(block(nShownStart, nShownLen, true)); + + if (nHiddenLen) + aBlocks.push_back(block(nHiddenStart, nHiddenLen, false)); + + nShownStart = nHiddenEnd; + } + + sal_Int32 nTrailingShownLen = rNodeText.getLength() - nShownStart; + if (nTrailingShownLen) + aBlocks.push_back(block(nShownStart, nTrailingShownLen, true)); + + if (eMode & EXPANDFIELDS) + { + const SwpHints* pSwpHints2 = rNode.GetpSwpHints(); + for ( sal_uInt16 i = 0; pSwpHints2 && i < pSwpHints2->Count(); ++i ) + { + const SwTxtAttr* pAttr = (*pSwpHints2)[i]; + if (pAttr->HasDummyChar()) + { + const sal_Int32 nDummyCharPos = *pAttr->GetStart(); + if (aHiddenMulti.IsSelected(nDummyCharPos)) + continue; + std::vector<block>::iterator aFind = std::find_if(aBlocks.begin(), aBlocks.end(), containsPos(nDummyCharPos)); + if (aFind != aBlocks.end()) + { + aFind->m_aAttrs.push_back(pAttr); + } + } + } + } + + sal_Int32 nOffset = 0; + for (std::vector<block>::iterator i = aBlocks.begin(); i != aBlocks.end(); ++i) + { + if (!i->m_bVisible) + { + const sal_Int32 nHiddenStart = i->m_nStart; + const sal_Int32 nHiddenLen = i->m_nLen; + + m_aRetText = m_aRetText.replaceAt( nOffset + nHiddenStart, nHiddenLen, OUString() ); + m_aMap.push_back( ConversionMapEntry( nHiddenStart, nOffset + nHiddenStart ) ); + nOffset -= nHiddenLen; + } + else + { + for (std::vector<const SwTxtAttr*>::iterator j = i->m_aAttrs.begin(); j != i->m_aAttrs.end(); ++j) + { + const SwTxtAttr* pAttr = *j; + const sal_Int32 nFieldPos = *pAttr->GetStart(); + OUString aExpand; + switch (pAttr->Which()) + { + case RES_TXTATR_FIELD: + aExpand = + static_cast<SwTxtFld const*>(pAttr)->GetFmtFld().GetField() + ->ExpandField(true); + break; + case RES_TXTATR_FTN: + { + const SwFmtFtn& rFtn = static_cast<SwTxtFtn const*>(pAttr)->GetFtn(); + const SwDoc *pDoc = rNode.GetDoc(); + aExpand = rFtn.GetViewNumStr(*pDoc); + } + break; + default: + break; + } + m_aRetText = m_aRetText.replaceAt( nOffset + nFieldPos, 1, aExpand ); + m_aMap.push_back( ConversionMapEntry( nFieldPos, nOffset + nFieldPos ) ); + nOffset += aExpand.getLength() - 1; + } + } + } + + if ( !m_aMap.empty() ) + m_aMap.push_back( ConversionMapEntry( rNodeText.getLength()+1, m_aRetText.getLength()+1 ) ); +} /** Converts a model position into a view position */ -sal_uInt32 ModelToViewHelper::ConvertToViewPosition( sal_uInt32 nModelPos ) const +sal_Int32 ModelToViewHelper::ConvertToViewPosition( sal_Int32 nModelPos ) const { - sal_uInt32 nRet = nModelPos; - // Search for entry after nPos: ConversionMap::const_iterator aIter; for ( aIter = m_aMap.begin(); aIter != m_aMap.end(); ++aIter ) { if ( (*aIter).first >= nModelPos ) { - const sal_uInt32 nPosModel = (*aIter).first; - const sal_uInt32 nPosExpand = (*aIter).second; + const sal_Int32 nPosModel = (*aIter).first; + const sal_Int32 nPosExpand = (*aIter).second; - const sal_uInt32 nDistToNextModel = nPosModel - nModelPos; - nRet = nPosExpand - nDistToNextModel; - break; + const sal_Int32 nDistToNextModel = nPosModel - nModelPos; + return nPosExpand - nDistToNextModel; } } - return nRet; + return nModelPos; } /** Converts a view position into a model position */ -ModelToViewHelper::ModelPosition ModelToViewHelper::ConvertToModelPosition( sal_uInt32 nViewPos ) const +ModelToViewHelper::ModelPosition ModelToViewHelper::ConvertToModelPosition( sal_Int32 nViewPos ) const { ModelPosition aRet; aRet.mnPos = nViewPos; @@ -57,8 +200,8 @@ ModelToViewHelper::ModelPosition ModelToViewHelper::ConvertToModelPosition( sal_ { if ( (*aIter).second > nViewPos ) { - const sal_uInt32 nPosModel = (*aIter).first; - const sal_uInt32 nPosExpand = (*aIter).second; + const sal_Int32 nPosModel = (*aIter).first; + const sal_Int32 nPosExpand = (*aIter).second; // If nViewPos is in front of first field, we are finished. if ( aIter == m_aMap.begin() ) @@ -67,21 +210,21 @@ ModelToViewHelper::ModelPosition ModelToViewHelper::ConvertToModelPosition( sal_ --aIter; // nPrevPosModel is the field position - const sal_uInt32 nPrevPosModel = (*aIter).first; - const sal_uInt32 nPrevPosExpand = (*aIter).second; + const sal_Int32 nPrevPosModel = (*aIter).first; + const sal_Int32 nPrevPosExpand = (*aIter).second; - const sal_uInt32 nLengthModel = nPosModel - nPrevPosModel; - const sal_uInt32 nLengthExpand = nPosExpand - nPrevPosExpand; + const sal_Int32 nLengthModel = nPosModel - nPrevPosModel; + const sal_Int32 nLengthExpand = nPosExpand - nPrevPosExpand; - const sal_uInt32 nFieldLengthExpand = nLengthExpand - nLengthModel + 1; - const sal_uInt32 nFieldEndExpand = nPrevPosExpand + nFieldLengthExpand; + const sal_Int32 nFieldLengthExpand = nLengthExpand - nLengthModel + 1; + const sal_Int32 nFieldEndExpand = nPrevPosExpand + nFieldLengthExpand; // Check if nPos is outside of field: if ( nFieldEndExpand <= nViewPos ) { // nPos is outside of field: - const sal_uInt32 nDistToField = nViewPos - nFieldEndExpand + 1; - aRet.mnPos = nPrevPosModel + nDistToField; + const sal_Int32 nDistToField = nViewPos - nFieldEndExpand + 1; + aRet.mnPos = nPrevPosModel + nDistToField; } else { diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index cc2b5de..8f1a892 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -29,7 +29,6 @@ #include <editeng/tstpitem.hxx> #include <svl/urihelper.hxx> #include <svl/ctloptions.hxx> -#include <tools/multisel.hxx> #include <swmodule.hxx> #include <txtfld.hxx> #include <txtinet.hxx> @@ -3309,141 +3308,6 @@ bool SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, return true; } -struct block -{ - sal_Int32 m_nStart; - sal_Int32 m_nLen; - bool m_bVisible; - std::vector<const SwTxtAttr*> m_aAttrs; - block(sal_Int32 nStart, sal_Int32 nLen, bool bVisible) - : m_nStart(nStart), m_nLen(nLen), m_bVisible(bVisible) - { - } -}; - -struct containsPos -{ - const sal_Int32 m_nPos; - containsPos(const sal_Int32 nPos) - : m_nPos(nPos) - { - } - bool operator() (const block& rIn) const - { - return m_nPos >= rIn.m_nStart && m_nPos < rIn.m_nStart + rIn.m_nLen; - } -}; - -ModelToViewHelper::ModelToViewHelper(const SwTxtNode &rNode, int eMode) -{ - const OUString& rNodeText = rNode.GetTxt(); - m_aRetText = rNodeText; - - if (eMode == PASSTHROUGH) - return; - - Range aRange( 0, rNodeText.isEmpty() ? 0 : rNodeText.getLength() - 1); - MultiSelection aHiddenMulti(aRange); - - if (eMode & HIDEINVISIBLE) - SwScriptInfo::selectHiddenTextProperty(rNode, aHiddenMulti); - - if (eMode & HIDEREDLINED) - SwScriptInfo::selectRedLineDeleted(rNode, aHiddenMulti); - - std::vector<block> aBlocks; - - sal_Int32 nShownStart = 0; - for (size_t i = 0; i < aHiddenMulti.GetRangeCount(); ++i) - { - const Range& rRange = aHiddenMulti.GetRange(i); - sal_Int32 nHiddenStart = rRange.Min(); - sal_Int32 nHiddenEnd = rRange.Max() + 1; - sal_Int32 nHiddenLen = nHiddenEnd - nHiddenStart; - - sal_Int32 nShownEnd = nHiddenStart; - sal_Int32 nShownLen = nShownEnd - nShownStart; - - if (nShownLen) - aBlocks.push_back(block(nShownStart, nShownLen, true)); - - if (nHiddenLen) - aBlocks.push_back(block(nHiddenStart, nHiddenLen, false)); - - nShownStart = nHiddenEnd; - } - - sal_Int32 nTrailingShownLen = rNodeText.getLength() - nShownStart; - if (nTrailingShownLen) - aBlocks.push_back(block(nShownStart, nTrailingShownLen, true)); - - if (eMode & EXPANDFIELDS) - { - const SwpHints* pSwpHints2 = rNode.GetpSwpHints(); - for ( sal_uInt16 i = 0; pSwpHints2 && i < pSwpHints2->Count(); ++i ) - { - const SwTxtAttr* pAttr = (*pSwpHints2)[i]; - if (pAttr->HasDummyChar()) - { - const sal_Int32 nDummyCharPos = *pAttr->GetStart(); - if (aHiddenMulti.IsSelected(nDummyCharPos)) - continue; - std::vector<block>::iterator aFind = std::find_if(aBlocks.begin(), aBlocks.end(), containsPos(nDummyCharPos)); - if (aFind != aBlocks.end()) - { - aFind->m_aAttrs.push_back(pAttr); - } - } - } - } - - sal_Int32 nOffset = 0; - for (std::vector<block>::iterator i = aBlocks.begin(); i != aBlocks.end(); ++i) - { - if (!i->m_bVisible) - { - const sal_Int32 nHiddenStart = i->m_nStart; - const sal_Int32 nHiddenLen = i->m_nLen; - - m_aRetText = m_aRetText.replaceAt( nOffset + nHiddenStart, nHiddenLen, OUString() ); - m_aMap.push_back( ConversionMapEntry( nHiddenStart, nOffset + nHiddenStart ) ); - nOffset -= nHiddenLen; - } - else - { - for (std::vector<const SwTxtAttr*>::iterator j = i->m_aAttrs.begin(); j != i->m_aAttrs.end(); ++j) - { - const SwTxtAttr* pAttr = *j; - const sal_Int32 nFieldPos = *pAttr->GetStart(); - OUString aExpand; - switch (pAttr->Which()) - { - case RES_TXTATR_FIELD: - aExpand = - static_cast<SwTxtFld const*>(pAttr)->GetFmtFld().GetField() - ->ExpandField(true); - break; - case RES_TXTATR_FTN: - { - const SwFmtFtn& rFtn = static_cast<SwTxtFtn const*>(pAttr)->GetFtn(); - const SwDoc *pDoc = rNode.GetDoc(); - aExpand = rFtn.GetViewNumStr(*pDoc); - } - break; - default: - break; - } - m_aRetText = m_aRetText.replaceAt( nOffset + nFieldPos, 1, aExpand ); - m_aMap.push_back( ConversionMapEntry( nFieldPos, nOffset + nFieldPos ) ); - nOffset += ( aExpand.getLength() - 1 ); - } - } - } - - if ( !m_aMap.empty() ) - m_aMap.push_back( ConversionMapEntry( rNodeText.getLength()+1, m_aRetText.getLength()+1 ) ); -} - OUString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, sal_Bool bExpandFlds, sal_Bool bWithNum ) const { diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index e1eb5c3..4a31aef 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -741,8 +741,7 @@ SwScanner::SwScanner( const SwTxtNode& rNd, const OUString& rTxt, else { ModelToViewHelper::ModelPosition aModelBeginPos = rConversionMap.ConvertToModelPosition( nBegin ); - const sal_Int32 nModelBeginPos = aModelBeginPos.mnPos; - aCurrLang = rNd.GetLang( nModelBeginPos ); + aCurrLang = rNd.GetLang( aModelBeginPos.mnPos ); } } @@ -803,8 +802,7 @@ sal_Bool SwScanner::NextWord() { const sal_uInt16 nNextScriptType = g_pBreakIt->GetBreakIter()->getScriptType( aText, nBegin ); ModelToViewHelper::ModelPosition aModelBeginPos = rConversionMap.ConvertToModelPosition( nBegin ); - const sal_Int32 nBeginModelPos = aModelBeginPos.mnPos; - aCurrLang = rNode.GetLang( nBeginModelPos, 1, nNextScriptType ); + aCurrLang = rNode.GetLang( aModelBeginPos.mnPos, 1, nNextScriptType ); } if ( nWordType != i18n::WordType::WORD_COUNT ) @@ -1480,8 +1478,8 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNode* /*pActNode*/, xub_StrLen /*nActPos*/ const com::sun::star::lang::Locale aLocale = g_pBreakIt->GetLocale( nLang ); nLangEnd = std::min( nEnd, aIter.GetChgPos() ); - const sal_uInt32 nExpandBegin = aConversionMap.ConvertToViewPosition( nLangBegin ); - const sal_uInt32 nExpandEnd = aConversionMap.ConvertToViewPosition( nLangEnd ); + const sal_Int32 nExpandBegin = aConversionMap.ConvertToViewPosition( nLangBegin ); + const sal_Int32 nExpandEnd = aConversionMap.ConvertToViewPosition( nLangEnd ); rSmartTagMgr.RecognizeString(aExpandText, xTextMarkup, xController, aLocale, nExpandBegin, nExpandEnd - nExpandBegin ); @@ -1983,8 +1981,8 @@ bool SwTxtNode::CountWords( SwDocStat& rStat, OUString aExpandText = aConversionMap.getViewText(); // map start and end points onto the ConversionMap - const sal_uInt32 nExpandBegin = aConversionMap.ConvertToViewPosition( nStt ); - const sal_uInt32 nExpandEnd = aConversionMap.ConvertToViewPosition( nEnd ); + const sal_Int32 nExpandBegin = aConversionMap.ConvertToViewPosition( nStt ); + const sal_Int32 nExpandEnd = aConversionMap.ConvertToViewPosition( nEnd ); if (aExpandText.isEmpty() && !bCountNumbering) { diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx index 8976a657..dc7b04b 100644 --- a/sw/source/core/unocore/unotextmarkup.cxx +++ b/sw/source/core/unocore/unotextmarkup.cxx @@ -225,8 +225,8 @@ void SAL_CALL SwXTextMarkup::commitStringMarkup( pSubList = new SwGrammarMarkUp(); pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList ); } - const sal_uInt32 nTmpStart = maConversionMap.ConvertToViewPosition( aStartPos.mnPos ); - const sal_uInt32 nTmpLen = maConversionMap.ConvertToViewPosition( aStartPos.mnPos + 1 ) + const sal_Int32 nTmpStart = maConversionMap.ConvertToViewPosition( aStartPos.mnPos ); + const sal_Int32 nTmpLen = maConversionMap.ConvertToViewPosition( aStartPos.mnPos + 1 ) - nTmpStart - aStartPos.mnSubPos; if( nTmpLen > 0 ) { @@ -251,7 +251,7 @@ void SAL_CALL SwXTextMarkup::commitStringMarkup( pSubList = new SwGrammarMarkUp(); pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList ); } - const sal_uInt32 nTmpLen = aEndPos.mnSubPos + 1; + const sal_Int32 nTmpLen = aEndPos.mnSubPos + 1; pSubList->Insert( rIdentifier, xMarkupInfoContainer, 0, static_cast< xub_StrLen >(nTmpLen) ); } else @@ -332,8 +332,8 @@ static void lcl_commitGrammarMarkUp( pSubList = new SwGrammarMarkUp(); pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList ); } - const sal_uInt32 nTmpStart = rConversionMap.ConvertToViewPosition( aStartPos.mnPos ); - const sal_uInt32 nTmpLen = rConversionMap.ConvertToViewPosition( aStartPos.mnPos + 1 ) + const sal_Int32 nTmpStart = rConversionMap.ConvertToViewPosition( aStartPos.mnPos ); + const sal_Int32 nTmpLen = rConversionMap.ConvertToViewPosition( aStartPos.mnPos + 1 ) - nTmpStart - aStartPos.mnSubPos; if( nTmpLen > 0 ) pSubList->Insert( rIdentifier, xMarkupInfoContainer, @@ -350,7 +350,7 @@ static void lcl_commitGrammarMarkUp( pSubList = new SwGrammarMarkUp(); pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList ); } - const sal_uInt32 nTmpLen = aEndPos.mnSubPos + 1; + const sal_Int32 nTmpLen = aEndPos.mnSubPos + 1; pSubList->Insert( rIdentifier, xMarkupInfoContainer, 0, static_cast< xub_StrLen >(nTmpLen) ); } else commit e40fd5b9f1a544aa3d1f8a254682d403c4ce4b7c Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Nov 30 12:09:22 2013 +0100 Don't obscure local function calls with #defines Change-Id: I8a0851fac3e77f1ad101a422191bf80bfea7eafe diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index c7179dc..b00a588 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -810,14 +810,6 @@ void SwTxtFrm::CalcLineSpace() } } -// -// SET_WRONG( nPos, nCnt, bMove ) -// -#define SET_WRONG( nPos, nCnt, bMove ) \ -{ \ - lcl_SetWrong( *this, nPos, nCnt, bMove ); \ -} - static void lcl_SetWrong( SwTxtFrm& rFrm, sal_Int32 nPos, long nCnt, bool bMove ) { if ( !rFrm.IsFollow() ) @@ -884,13 +876,6 @@ static void lcl_SetWrong( SwTxtFrm& rFrm, sal_Int32 nPos, long nCnt, bool bMove } } -// -// SET_SCRIPT_INVAL( nPos ) -// - -#define SET_SCRIPT_INVAL( nPos )\ - lcl_SetScriptInval( *this, nPos ); - static void lcl_SetScriptInval( SwTxtFrm& rFrm, sal_Int32 nPos ) { if( rFrm.GetPara() ) @@ -933,7 +918,7 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) // Collection hat sich geaendert Prepare( PREP_CLEAR ); _InvalidatePrt(); - SET_WRONG( 0, STRING_LEN, false ); + lcl_SetWrong( *this, 0, STRING_LEN, false ); SetDerivedR2L( sal_False ); CheckDirChange(); // OD 09.12.2002 #105576# - Force complete paint due to existing @@ -979,8 +964,8 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) else _InvalidateRange( SwCharRange( nPos, nLen ), nLen ); } - SET_WRONG( nPos, nLen, true ) - SET_SCRIPT_INVAL( nPos ) + lcl_SetWrong( *this, nPos, nLen, true ); + lcl_SetScriptInval( *this, nPos ); bSetFldsDirty = true; if( HasFollow() ) lcl_ModifyOfst( this, nPos, nLen ); @@ -990,8 +975,8 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) { nPos = ((SwDelChr*)pNew)->nPos; InvalidateRange( SwCharRange( nPos, 1 ), -1 ); - SET_WRONG( nPos, -1, true ) - SET_SCRIPT_INVAL( nPos ) + lcl_SetWrong( *this, nPos, -1, true ); + lcl_SetScriptInval( *this, nPos ); bSetFldsDirty = bRecalcFtnFlag = true; if( HasFollow() ) lcl_ModifyOfst( this, nPos, STRING_LEN ); @@ -1010,8 +995,8 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) else InvalidateRange( SwCharRange( nPos, 1 ), m ); } - SET_WRONG( nPos, m, true ) - SET_SCRIPT_INVAL( nPos ) + lcl_SetWrong( *this, nPos, m, true ); + lcl_SetScriptInval( *this, nPos ); bSetFldsDirty = bRecalcFtnFlag = true; if( HasFollow() ) lcl_ModifyOfst( this, nPos, nLen ); @@ -1038,8 +1023,8 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_AUTOFMT == nTmp || RES_FMT_CHG == nTmp || RES_ATTRSET_CHG == nTmp ) { - SET_WRONG( nPos, nPos + nLen, false ) - SET_SCRIPT_INVAL( nPos ) + lcl_SetWrong( *this, nPos, nPos + nLen, false ); + lcl_SetScriptInval( *this, nPos ); } } @@ -1093,7 +1078,7 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) bSetFldsDirty = true; // ST2 if ( SwSmartTagMgr::Get().IsSmartTagsEnabled() ) - SET_WRONG( nPos, nPos + 1, false ) + lcl_SetWrong( *this, nPos, nPos + 1, false ); } break; case RES_TXTATR_FTN : @@ -1223,8 +1208,8 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) if ( SFX_ITEM_SET == rNewSet.GetItemState( RES_TXTATR_CHARFMT, sal_False ) ) { - SET_WRONG( 0, STRING_LEN, false ) - SET_SCRIPT_INVAL( 0 ) + lcl_SetWrong( *this, 0, STRING_LEN, false ); + lcl_SetScriptInval( *this, 0 ); } else if ( SFX_ITEM_SET == rNewSet.GetItemState( RES_CHRATR_LANGUAGE, sal_False ) || @@ -1232,14 +1217,14 @@ void SwTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) rNewSet.GetItemState( RES_CHRATR_CJK_LANGUAGE, sal_False ) || SFX_ITEM_SET == rNewSet.GetItemState( RES_CHRATR_CTL_LANGUAGE, sal_False ) ) - SET_WRONG( 0, STRING_LEN, false ) + lcl_SetWrong( *this, 0, STRING_LEN, false ); else if ( SFX_ITEM_SET == rNewSet.GetItemState( RES_CHRATR_FONT, sal_False ) || SFX_ITEM_SET == rNewSet.GetItemState( RES_CHRATR_CJK_FONT, sal_False ) || SFX_ITEM_SET == rNewSet.GetItemState( RES_CHRATR_CTL_FONT, sal_False ) ) - SET_SCRIPT_INVAL( 0 ) + lcl_SetScriptInval( *this, 0 ); else if ( SFX_ITEM_SET == rNewSet.GetItemState( RES_FRAMEDIR, sal_False ) ) { commit 20c91a72a190bbe071d85e38fd9d4d1023b78b59 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon Nov 25 16:20:19 2013 +0100 xub_StrLen to sal_Int32 Change-Id: Ie2c18baa3ab6a3a7c6f2ac83b6d2d5bd8ecf5811 diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx index 6fded12..0738e21 100644 --- a/sw/inc/reffld.hxx +++ b/sw/inc/reffld.hxx @@ -74,7 +74,7 @@ public: static SwTxtNode* FindAnchor( SwDoc* pDoc, const OUString& rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo, - sal_uInt16* pStt, sal_uInt16* pEnd = 0 ); + sal_Int32* pStt, sal_Int32* pEnd = 0 ); }; diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 33d77d2..1d5f42e 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -1096,7 +1096,7 @@ sal_Bool SwCrsrShell::GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType SwCallLink aLk( *this ); // watch Crsr-Moves SwCrsrSaveState aSaveState( *m_pCurCrsr ); - sal_uInt16 nPos; + sal_Int32 nPos = -1; SwTxtNode* pTxtNd = SwGetRefFieldType::FindAnchor( GetDoc(), rRefMark, nSubType, nSeqNo, &nPos ); if( pTxtNd && pTxtNd->GetNodes().IsDocNodes() ) diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 6189446..9351441 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -239,7 +239,7 @@ bool SwGetRefField::IsRefToNumItemCrossRefBookmark() const const SwTxtNode* SwGetRefField::GetReferencedTxtNode() const { SwDoc* pDoc = dynamic_cast<SwGetRefFieldType*>(GetTyp())->GetDoc(); - sal_uInt16 nDummy = USHRT_MAX; + sal_Int32 nDummy = -1; return SwGetRefFieldType::FindAnchor( pDoc, sSetRefName, nSubType, nSeqNo, &nDummy ); } @@ -274,7 +274,8 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) SwDoc* pDoc = ((SwGetRefFieldType*)GetTyp())->GetDoc(); // finding the reference target (the number) - sal_uInt16 nNumStart, nNumEnd; + sal_Int32 nNumStart = -1; + sal_Int32 nNumEnd = -1; SwTxtNode* pTxtNd = SwGetRefFieldType::FindAnchor( pDoc, sSetRefName, nSubType, nSeqNo, &nNumStart, &nNumEnd ); @@ -314,8 +315,8 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) // "Category and Number" case REF_ONLYNUMBER: if (bHasCat) { - nStart = std::min<unsigned>(nNumStart, nCatStart); - nEnd = std::max<unsigned>(nNumEnd, nCatEnd); + nStart = std::min(nNumStart, nCatStart); + nEnd = std::max(nNumEnd, nCatEnd); } else { nStart = nNumStart; nEnd = nNumEnd; @@ -329,14 +330,14 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) pTxtNd->GetTxtAttrForCharAt(nNumStart, RES_TXTATR_FIELD) ) { // start searching from nFrom - const sal_Int32 nFrom = bHasCat ? - std::max<unsigned>(nNumStart + 1, nCatEnd) : nNumStart + 1; + const sal_Int32 nFrom = bHasCat + ? std::max(nNumStart + 1, nCatEnd) + : nNumStart + 1; nStart = SwGetExpField::GetReferenceTextPos( pTxtAttr->GetFmtFld(), *pDoc, nFrom ); } else { - nStart = bHasCat ? - std::max<unsigned>(nNumEnd, nCatEnd) : nNumEnd; + nStart = bHasCat ? std::max(nNumEnd, nCatEnd) : nNumEnd; } nEnd = nLen; break; @@ -360,7 +361,7 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) nStart = nNumStart; // Text steht ueber verschiedene Nodes verteilt. // Gesamten Text oder nur bis zum Ende vom Node? - nEnd = nNumEnd == USHRT_MAX ? nLen : nNumEnd; + nEnd = nNumEnd<0 ? nLen : nNumEnd; break; case REF_OUTLINE: @@ -815,7 +816,7 @@ void SwGetRefFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo, - sal_uInt16* pStt, sal_uInt16* pEnd ) + sal_Int32* pStt, sal_Int32* pEnd ) { OSL_ENSURE( pStt, "Why did noone check the StartPos?" ); @@ -885,7 +886,7 @@ SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark, else if(pBkmk->GetOtherMarkPos().nNode == pBkmk->GetMarkPos().nNode) *pEnd = pBkmk->GetMarkEnd().nContent.GetIndex(); else - *pEnd = USHRT_MAX; + *pEnd = -1; } } } commit 4420650bb08794506bcc476994e628986d079991 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon Nov 25 15:35:08 2013 +0100 xub_StrLen/unsigned to sal_Int32 Change-Id: I6d89f19ef2ee3aa83f3e74a416c41cd42dd448fa diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx index 2944589..65b9beb 100644 --- a/sw/inc/expfld.hxx +++ b/sw/inc/expfld.hxx @@ -124,7 +124,7 @@ public: virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); - static xub_StrLen GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc, unsigned nHint = 0); + static sal_Int32 GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc, sal_Int32 nHint = 0); // #i82544# void SetLateInitialization() { bLateInitialization = true;} }; diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index e25dd31..bb5a398 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -866,13 +866,13 @@ void SwGetExpField::SetValue( const double& rAny ) * @param nHint search starting position after the current field (or 0 if default) * @return */ -xub_StrLen SwGetExpField::GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc, unsigned nHint) +sal_Int32 SwGetExpField::GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc, sal_Int32 nHint) { // const SwTxtFld* pTxtFld = rFmt.GetTxtFld(); const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode(); // - xub_StrLen nRet = nHint ? nHint : *pTxtFld->GetStart() + 1; + sal_Int32 nRet = nHint ? nHint : *pTxtFld->GetStart() + 1; OUString sNodeText = rTxtNode.GetTxt(); if(nRet<sNodeText.getLength()) diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 96de783..6189446 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -285,14 +285,13 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) return ; } // where is the category name (e.g. "Illustration")? - OUString const Text = pTxtNd->GetTxt(); - unsigned const nCatStart = Text.indexOf(sSetRefName); - unsigned const nCatEnd = nCatStart == unsigned(-1) ? - unsigned(-1) : nCatStart + sSetRefName.getLength(); - bool const bHasCat = nCatStart != unsigned(-1); + OUString const sText = pTxtNd->GetTxt(); + const sal_Int32 nCatStart = sText.indexOf(sSetRefName); + const bool bHasCat = nCatStart>=0; + const sal_Int32 nCatEnd = bHasCat ? nCatStart + sSetRefName.getLength() : -1; // length of the referenced text - unsigned const nLen = Text.getLength(); + const sal_Int32 nLen = sText.getLength(); // which format? switch( GetFormat() ) @@ -303,7 +302,8 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) case REF_ONLYSEQNO: { // needed part of Text - unsigned nStart, nEnd; + sal_Int32 nStart; + sal_Int32 nEnd; switch( nSubType ) { @@ -329,7 +329,7 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) pTxtNd->GetTxtAttrForCharAt(nNumStart, RES_TXTATR_FIELD) ) { // start searching from nFrom - unsigned const nFrom = bHasCat ? + const sal_Int32 nFrom = bHasCat ? std::max<unsigned>(nNumStart + 1, nCatEnd) : nNumStart + 1; nStart = SwGetExpField::GetReferenceTextPos( pTxtAttr->GetFmtFld(), *pDoc, nFrom @@ -345,7 +345,7 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) // "Numbering" case REF_ONLYSEQNO: nStart = nNumStart; - nEnd = std::min<unsigned>(nStart + 1, nLen); + nEnd = std::min(nStart + 1, nLen); break; // "Reference" (whole Text) commit 8a4c452058001c99ce06464af8357832aaa8f019 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon Nov 25 14:21:54 2013 +0100 xub_StrLen to sal_Int32 Change-Id: Id00f298c638b14b0e78b898373978f94b43804d9 diff --git a/sw/inc/crstate.hxx b/sw/inc/crstate.hxx index 0adcdd2..96dbddf 100644 --- a/sw/inc/crstate.hxx +++ b/sw/inc/crstate.hxx @@ -101,7 +101,7 @@ struct Sw2LinesPos struct SwSpecialPos { - xub_StrLen nCharOfst; + sal_Int32 nCharOfst; sal_uInt16 nLineOfst; sal_uInt8 nExtendRange; diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx index 51fda46..fba412d 100644 --- a/sw/source/core/access/accportions.cxx +++ b/sw/source/core/access/accportions.cxx @@ -666,7 +666,7 @@ sal_uInt16 SwAccessiblePortionData::FillSpecialPos( nRefPos = aLineBreaks[ nMyLine ]; // fill char offset and 'special position' - rPos.nCharOfst = static_cast<sal_uInt16>( nPos - nRefPos ); + rPos.nCharOfst = nPos - nRefPos; rPos.nExtendRange = nExtend; rPos.nLineOfst = nLineOffset; } commit ea0d3041a9d27361fb816480ecc59dd12b14a10d Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Mon Nov 25 00:12:32 2013 +0100 xub_StrLen to sal_Int32 Change-Id: Ifd4f78d422eb3ed04407e9c9edb30ef319cae2cb diff --git a/sw/inc/anchoredobject.hxx b/sw/inc/anchoredobject.hxx index da66dca..7ed66ca 100644 --- a/sw/inc/anchoredobject.hxx +++ b/sw/inc/anchoredobject.hxx @@ -170,7 +170,7 @@ class SW_DLLPUBLIC SwAnchoredObject // object positioning friend bool sw_HideObj( const SwTxtFrm& _rFrm, const RndStdIds _eAnchorType, - const xub_StrLen _nObjAnchorPos, + const sal_Int32 _nObjAnchorPos, SwAnchoredObject* _pAnchoredObj ); protected: SwAnchoredObject(); diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index db2f479..c7179dc 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -495,7 +495,7 @@ void SwTxtFrm::HideFootnotes( xub_StrLen nStart, xub_StrLen nEnd ) // (c) the anchor character is an as-character anchored graphic. bool sw_HideObj( const SwTxtFrm& _rFrm, const RndStdIds _eAnchorType, - const xub_StrLen _nObjAnchorPos, + const sal_Int32 _nObjAnchorPos, SwAnchoredObject* _pAnchoredObj ) { bool bRet( true ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits