Kaydet (Commit) bce2c9d4 authored tarafından Matteo Casalin's avatar Matteo Casalin

Reduce scope and avoid casts at each call-place

Change-Id: Iade7f5e174b74ea156c0e0bafc5c7c72e4b86dbd
üst 6f8a2666
...@@ -136,7 +136,7 @@ bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, ...@@ -136,7 +136,7 @@ bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
// save maximum width for later use // save maximum width for later use
if ( nMaxSizeDiff ) if ( nMaxSizeDiff )
rInf.SetMaxWidthDiff( (sal_uLong)&rPor, nMaxSizeDiff ); rInf.SetMaxWidthDiff( &rPor, nMaxSizeDiff );
nBreakWidth += nLeftRightBorderSpace; nBreakWidth += nLeftRightBorderSpace;
...@@ -188,7 +188,7 @@ bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, ...@@ -188,7 +188,7 @@ bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
// save maximum width for later use // save maximum width for later use
if ( nMaxSizeDiff ) if ( nMaxSizeDiff )
rInf.SetMaxWidthDiff( (sal_uLong)&rPor, nMaxSizeDiff ); rInf.SetMaxWidthDiff( &rPor, nMaxSizeDiff );
nBreakWidth += nLeftRightBorderSpace; nBreakWidth += nLeftRightBorderSpace;
...@@ -508,7 +508,7 @@ bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, ...@@ -508,7 +508,7 @@ bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
// save maximum width for later use // save maximum width for later use
if ( nMaxSizeDiff ) if ( nMaxSizeDiff )
rInf.SetMaxWidthDiff( (sal_uLong)&rPor, nMaxSizeDiff ); rInf.SetMaxWidthDiff( &rPor, nMaxSizeDiff );
nBreakWidth += nItalic + nLeftRightBorderSpace; nBreakWidth += nItalic + nLeftRightBorderSpace;
} }
......
...@@ -140,10 +140,11 @@ public: ...@@ -140,10 +140,11 @@ public:
friend SvStream & WriteSwTxtInfo( SvStream &rOS, const SwTxtInfo &rInf ); friend SvStream & WriteSwTxtInfo( SvStream &rOS, const SwTxtInfo &rInf );
}; };
typedef ::std::map< sal_uLong, sal_IntPtr > SwTxtPortionMap;
class SwTxtSizeInfo : public SwTxtInfo class SwTxtSizeInfo : public SwTxtInfo
{ {
private:
typedef ::std::map< sal_uIntPtr, sal_uInt16 > SwTxtPortionMap;
protected: protected:
// during formatting, a small database is built, mapping portion pointers // during formatting, a small database is built, mapping portion pointers
// to their maximum size (used for kana compression) // to their maximum size (used for kana compression)
...@@ -337,13 +338,13 @@ public: ...@@ -337,13 +338,13 @@ public:
// space among compressed kanas. // space among compressed kanas.
// During formatting, the maximum values of compressable portions are // During formatting, the maximum values of compressable portions are
// stored in m_aMaxWidth and discarded after a line has been formatted. // stored in m_aMaxWidth and discarded after a line has been formatted.
inline void SetMaxWidthDiff( sal_uLong nKey, sal_uInt16 nVal ) inline void SetMaxWidthDiff( const void *nKey, sal_uInt16 nVal )
{ {
m_aMaxWidth.insert( ::std::make_pair( nKey, nVal ) ); m_aMaxWidth.insert( ::std::make_pair( reinterpret_cast<sal_uIntPtr>(nKey), nVal ) );
}; };
inline sal_uInt16 GetMaxWidthDiff( sal_uLong nKey ) inline sal_uInt16 GetMaxWidthDiff( const void *nKey )
{ {
SwTxtPortionMap::iterator it = m_aMaxWidth.find( nKey ); SwTxtPortionMap::iterator it = m_aMaxWidth.find( reinterpret_cast<sal_uIntPtr>(nKey) );
if( it != m_aMaxWidth.end() ) if( it != m_aMaxWidth.end() )
return it->second; return it->second;
......
...@@ -421,11 +421,11 @@ SwTwips SwTxtAdjuster::CalcKanaAdj( SwLineLayout* pCurrent ) ...@@ -421,11 +421,11 @@ SwTwips SwTxtAdjuster::CalcKanaAdj( SwLineLayout* pCurrent )
{ {
// get maximum portion width from info structure, calculated // get maximum portion width from info structure, calculated
// during text formatting // during text formatting
sal_uInt16 nMaxWidthDiff = GetInfo().GetMaxWidthDiff( (sal_uLong)pPos ); sal_uInt16 nMaxWidthDiff = GetInfo().GetMaxWidthDiff( pPos );
// check, if information is stored under other key // check, if information is stored under other key
if ( !nMaxWidthDiff && pPos == pCurrent->GetFirstPortion() ) if ( !nMaxWidthDiff && pPos == pCurrent->GetFirstPortion() )
nMaxWidthDiff = GetInfo().GetMaxWidthDiff( (sal_uLong)pCurrent ); nMaxWidthDiff = GetInfo().GetMaxWidthDiff( pCurrent );
// calculate difference between portion width and max. width // calculate difference between portion width and max. width
nKanaDiffSum += nMaxWidthDiff; nKanaDiffSum += nMaxWidthDiff;
...@@ -501,11 +501,11 @@ SwTwips SwTxtAdjuster::CalcKanaAdj( SwLineLayout* pCurrent ) ...@@ -501,11 +501,11 @@ SwTwips SwTxtAdjuster::CalcKanaAdj( SwLineLayout* pCurrent )
// get maximum portion width from info structure, calculated // get maximum portion width from info structure, calculated
// during text formatting // during text formatting
sal_uInt16 nMaxWidthDiff = GetInfo().GetMaxWidthDiff( (sal_uLong)pPos ); sal_uInt16 nMaxWidthDiff = GetInfo().GetMaxWidthDiff( pPos );
// check, if information is stored under other key // check, if information is stored under other key
if ( !nMaxWidthDiff && pPos == pCurrent->GetFirstPortion() ) if ( !nMaxWidthDiff && pPos == pCurrent->GetFirstPortion() )
nMaxWidthDiff = GetInfo().GetMaxWidthDiff( (sal_uLong)pCurrent ); nMaxWidthDiff = GetInfo().GetMaxWidthDiff( pCurrent );
nKanaDiffSum += nMaxWidthDiff; nKanaDiffSum += nMaxWidthDiff;
pPos->Width( nMinWidth + pPos->Width( nMinWidth +
( ( 10000 - nCompress ) * nMaxWidthDiff ) / 10000 ); ( ( 10000 - nCompress ) * nMaxWidthDiff ) / 10000 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment