Author: orw
Date: Fri Jul 6 08:07:48 2012
New Revision: 1358065
URL: http://svn.apache.org/viewvc?rev=1358065&view=rev
Log:
#119567# - method <SwWW8WrGrf::WritePICFHeader(..)> - assure correct scaling in case
that the size is substituted.
Found by: Yan Ji <yanji.yj at gmail dot com>
Patch by: zjchen <zjchencdl at gmail dot com>
Review by: Oliver <orw at apache dot org>
Modified:
incubator/ooo/trunk/main/sw/source/filter/ww8/wrtww8gr.cxx
Modified: incubator/ooo/trunk/main/sw/source/filter/ww8/wrtww8gr.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/ww8/wrtww8gr.cxx?rev=1358065&r1=1358064&r2=1358065&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/ww8/wrtww8gr.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/ww8/wrtww8gr.cxx Fri Jul 6 08:07:48 2012
@@ -601,8 +601,9 @@ void SwWW8WrGrf::WritePICFHeader(SvStrea
substitute the final size and loose on retaining the scaling factor but
still keep the correct display size anyway.
*/
- if ( (aGrTwipSz.Width() > SHRT_MAX) || (aGrTwipSz.Height() > SHRT_MAX)
- || (aGrTwipSz.Width() < 0 ) || (aGrTwipSz.Height() < 0) )
+ const bool bIsSubstitutedSize = (aGrTwipSz.Width() > SHRT_MAX) || (aGrTwipSz.Height()
> SHRT_MAX) ||
+ (aGrTwipSz.Width() < 0 ) || (aGrTwipSz.Height() <
0);
+ if ( bIsSubstitutedSize )
{
aGrTwipSz.Width() = nWidth;
aGrTwipSz.Height() = nHeight;
@@ -617,26 +618,51 @@ void SwWW8WrGrf::WritePICFHeader(SvStrea
Set_UInt16(pArr, msword_cast<sal_uInt16>(aGrTwipSz.Width()));
Set_UInt16(pArr, msword_cast<sal_uInt16>(aGrTwipSz.Height()));
- if( aGrTwipSz.Width() + nXSizeAdd ) // set mx
+ if ( aGrTwipSz.Width() + nXSizeAdd ) // set mx
{
- double fVal = nWidth * 1000.0 / (aGrTwipSz.Width() + nXSizeAdd);
- Set_UInt16( pArr, (sal_uInt16)::rtl::math::round(fVal) );
+ if ( !bIsSubstitutedSize )
+ {
+ const double fVal = nWidth * 1000.0 / (aGrTwipSz.Width() + nXSizeAdd );
+ Set_UInt16( pArr, (sal_uInt16)::rtl::math::round(fVal) );
+ }
+ else
+ {
+ Set_UInt16( pArr, 1000 );
+ }
}
else
+ {
pArr += 2;
+ }
- if( aGrTwipSz.Height() + nYSizeAdd ) // set my
+ if ( aGrTwipSz.Height() + nYSizeAdd ) // set my
{
- double fVal = nHeight * 1000.0 / (aGrTwipSz.Height() + nYSizeAdd);
- Set_UInt16( pArr, (sal_uInt16)::rtl::math::round(fVal) );
+ if ( !bIsSubstitutedSize )
+ {
+ const double fVal = nHeight * 1000.0 / (aGrTwipSz.Height() + nYSizeAdd);
+ Set_UInt16( pArr, (sal_uInt16)::rtl::math::round(fVal) );
+ }
+ else
+ {
+ Set_UInt16( pArr, 1000 );
+ }
}
else
+ {
pArr += 2;
+ }
- Set_UInt16( pArr, nCropL ); // set dxaCropLeft
- Set_UInt16( pArr, nCropT ); // set dyaCropTop
- Set_UInt16( pArr, nCropR ); // set dxaCropRight
- Set_UInt16( pArr, nCropB ); // set dyaCropBottom
+ if ( !bIsSubstitutedSize )
+ {
+ Set_UInt16( pArr, nCropL ); // set dxaCropLeft
+ Set_UInt16( pArr, nCropT ); // set dyaCropTop
+ Set_UInt16( pArr, nCropR ); // set dxaCropRight
+ Set_UInt16( pArr, nCropB ); // set dyaCropBottom
+ }
+ else
+ {
+ pArr += 8;
+ }
rStrm.Write( aArr, nHdrLen );
}
|