INTEGRATION: CWS thb09 (1.10.8); FILE MERGED

2005/08/22 17:01:30 thb 1.10.8.4: #i52608# VCL rect clips always include one pixel more to the right and the bottom - correctly converting to polygon now.
2005/08/22 16:59:52 thb 1.10.8.3: #i52608# Always setting up font matrix, also if mapmode scales anisotrophically
2005/08/22 16:58:55 thb 1.10.8.2: #i51558# Correctly scaling EPS action, when rendering to XCanvas
2005/08/22 16:48:15 thb 1.10.8.1: #i47157# Implementing TEXTRECT meta action
This commit is contained in:
Jens-Heiner Rechtien
2005-09-23 13:30:27 +00:00
parent 7ac00ce9ed
commit 5a4a42e63e

View File

@@ -4,9 +4,9 @@
* *
* $RCSfile: implrenderer.cxx,v $ * $RCSfile: implrenderer.cxx,v $
* *
* $Revision: 1.11 $ * $Revision: 1.12 $
* *
* last change: $Author: rt $ $Date: 2005-09-08 08:18:25 $ * last change: $Author: hr $ $Date: 2005-09-23 14:30:27 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
@@ -881,10 +881,6 @@ namespace cppcanvas
rParms.maFontLetterForm.getValue() : rParms.maFontLetterForm.getValue() :
(rFont.GetItalic() == ITALIC_NONE) ? 0 : 9; (rFont.GetItalic() == ITALIC_NONE) ? 0 : 9;
// TODO(F2): use correct scale direction, font
// height might be width or anything else
aFontRequest.CellSize = rVDev.LogicToPixel( rFont.GetSize() ).Height();
// setup state-local text transformation, // setup state-local text transformation,
// if the font be rotated // if the font be rotated
const short nFontAngle( rFont.GetOrientation() ); const short nFontAngle( rFont.GetOrientation() );
@@ -902,18 +898,41 @@ namespace cppcanvas
geometry::Matrix2D aFontMatrix; geometry::Matrix2D aFontMatrix;
::canvas::tools::setIdentityMatrix2D( aFontMatrix ); ::canvas::tools::setIdentityMatrix2D( aFontMatrix );
// check if the font is stretched or squeezed // TODO(F2): use correct scale direction, font
long nFontWidth = rFont.GetSize().Width(); // height might be width or anything else
if( nFontWidth != 0 ) const ::Size rFontSizeLog( rFont.GetSize() );
const sal_Int32 nFontWidthLog = rFontSizeLog.Width();
if( nFontWidthLog != 0 )
{ {
::Font aTestFont = rFont; ::Font aTestFont = rFont;
aTestFont.SetWidth( 0 ); aTestFont.SetWidth( 0 );
int nNormalWidth = rVDev.GetFontMetric( aTestFont ).GetWidth(); sal_Int32 nNormalWidth = rVDev.GetFontMetric( aTestFont ).GetWidth();
if( nNormalWidth != nFontWidth ) if( nNormalWidth != nFontWidthLog )
if( nNormalWidth ) if( nNormalWidth )
aFontMatrix.m00 = (double)nFontWidth / nNormalWidth; aFontMatrix.m00 = (double)nFontWidthLog / nNormalWidth;
} }
// #i52608# apply map mode scale also to font matrix - an
// anisotrophic mapmode must be reflected in an
// anisotrophic font matrix scale.
const ::Size& rScale10000(
rVDev.LogicToPixel( Size(100000L,
100000L) ) );
const sal_Int32 nWidth( rScale10000.Width() );
const sal_Int32 nHeight( rScale10000.Height() );
if( nWidth != nHeight )
{
// note: no reason to check for division by zero, we
// always have the value closer (or equal) to zero as
// the nominator.
if( abs(nWidth) < abs(nHeight) )
aFontMatrix.m00 *= (double)nWidth / nHeight;
else
aFontMatrix.m11 *= (double)nHeight / nWidth;
}
aFontRequest.CellSize = rVDev.LogicToPixel( rFontSizeLog ).Height();
return rCanvas->getUNOCanvas()->createFont( aFontRequest, return rCanvas->getUNOCanvas()->createFont( aFontRequest,
uno::Sequence< beans::PropertyValue >(), uno::Sequence< beans::PropertyValue >(),
aFontMatrix ); aFontMatrix );
@@ -1054,10 +1073,13 @@ namespace cppcanvas
// to general polygon clipping here. // to general polygon clipping here.
rState.clip = ::basegfx::B2DPolyPolygon( rState.clip = ::basegfx::B2DPolyPolygon(
::basegfx::tools::createPolygonFromRect( ::basegfx::tools::createPolygonFromRect(
// #121100# VCL rectangular clips always
// include one more pixel to the right
// and the bottom
::basegfx::B2DRectangle( rState.clipRect.Left(), ::basegfx::B2DRectangle( rState.clipRect.Left(),
rState.clipRect.Top(), rState.clipRect.Top(),
rState.clipRect.Right(), rState.clipRect.Right()+1,
rState.clipRect.Bottom() ) ) ); rState.clipRect.Bottom()+1 ) ) );
} }
rState.clip = ::basegfx::tools::correctOrientations( rState.clip ); rState.clip = ::basegfx::tools::correctOrientations( rState.clip );
@@ -1089,10 +1111,13 @@ namespace cppcanvas
rCanvas->getUNOCanvas()->getDevice(), rCanvas->getUNOCanvas()->getDevice(),
::basegfx::B2DPolyPolygon( ::basegfx::B2DPolyPolygon(
::basegfx::tools::createPolygonFromRect( ::basegfx::tools::createPolygonFromRect(
// #121100# VCL rectangular clips
// always include one more pixel to
// the right and the bottom
::basegfx::B2DRectangle( rState.clipRect.Left(), ::basegfx::B2DRectangle( rState.clipRect.Left(),
rState.clipRect.Top(), rState.clipRect.Top(),
rState.clipRect.Right(), rState.clipRect.Right()+1,
rState.clipRect.Bottom() ) ) ) ); rState.clipRect.Bottom()+1 ) ) ) );
} }
} }
else else
@@ -1171,10 +1196,13 @@ namespace cppcanvas
rCanvas->getUNOCanvas()->getDevice(), rCanvas->getUNOCanvas()->getDevice(),
::basegfx::B2DPolyPolygon( ::basegfx::B2DPolyPolygon(
::basegfx::tools::createPolygonFromRect( ::basegfx::tools::createPolygonFromRect(
// #121100# VCL rectangular clips
// always include one more pixel to
// the right and the bottom
::basegfx::B2DRectangle( rState.clipRect.Left(), ::basegfx::B2DRectangle( rState.clipRect.Left(),
rState.clipRect.Top(), rState.clipRect.Top(),
rState.clipRect.Right(), rState.clipRect.Right()+1,
rState.clipRect.Bottom() ) ) ) ); rState.clipRect.Bottom()+1 ) ) ) );
} }
} }
else else
@@ -1196,7 +1224,6 @@ namespace cppcanvas
/* TODO(P2): interpret mtf-comments /* TODO(P2): interpret mtf-comments
================================ ================================
- bitmap fillings (do that via comments)
- gradient fillings (do that via comments) - gradient fillings (do that via comments)
- think about mapping. _If_ we do everything in logical - think about mapping. _If_ we do everything in logical
@@ -1530,36 +1557,46 @@ namespace cppcanvas
case META_EPS_ACTION: case META_EPS_ACTION:
{ {
MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pCurrAct); MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pCurrAct);
const GDIMetaFile& pSubstitute = pAct->GetSubstitute(); const GDIMetaFile& rSubstitute = pAct->GetSubstitute();
const Size aMtfSizePix( rVDev.LogicToPixel( pSubstitute.GetPrefSize(), const Size aMtfSize( rSubstitute.GetPrefSize() );
pSubstitute.GetPrefMapMode() ) ); const Size aMtfSizePixPre( rVDev.LogicToPixel( aMtfSize,
rSubstitute.GetPrefMapMode() ) );
// skip null-sized output // #i44110# correct null-sized output - there
if( aMtfSizePix.Width() != 0 && // are metafiles which have zero size in at
aMtfSizePix.Height() != 0 ) // least one dimension
{ const Size aMtfSizePix( ::std::max( aMtfSizePixPre.Width(), 1L ),
const Point aEmptyPt; ::std::max( aMtfSizePixPre.Height(), 1L ) );
const Point aMtfOriginPix( rVDev.LogicToPixel( aEmptyPt,
pSubstitute.GetPrefMapMode() ) );
// Setup local transform, such that the const Point aEmptyPt;
// metafile renders itself into the given const Point aMtfOriginPix( rVDev.LogicToPixel( aEmptyPt,
// output rectangle rSubstitute.GetPrefMapMode() ) );
pushState( rStates, PUSH_ALL );
getState( rStates ).transform.translate( -aMtfOriginPix.X(), -aMtfOriginPix.Y() ); // Setup local transform, such that the
getState( rStates ).transform.scale( 1.0 / aMtfSizePix.Width(), // metafile renders itself into the given
1.0 / aMtfSizePix.Height() ); // output rectangle
pushState( rStates, PUSH_ALL );
createActions( rCanvas, rVDev, const ::Point& rPos( rVDev.LogicToPixel( pAct->GetPoint() ) );
const_cast<GDIMetaFile&>(pAct->GetSubstitute()), const ::Size& rSize( rVDev.LogicToPixel( pAct->GetSize() ) );
rStates, rParms,
bSubsettableActions,
io_rCurrActionIndex );
popState( rStates ); getState( rStates ).transform.translate( rPos.X(),
} rPos.Y() );
getState( rStates ).transform.scale( (double)rSize.Width() / aMtfSizePix.Width(),
(double)rSize.Height() / aMtfSizePix.Height() );
rVDev.Push();
rVDev.SetMapMode( rSubstitute.GetPrefMapMode() );
createActions( rCanvas, rVDev,
const_cast<GDIMetaFile&>(pAct->GetSubstitute()),
rStates, rParms,
bSubsettableActions,
io_rCurrActionIndex );
rVDev.Pop();
popState( rStates );
} }
break; break;
@@ -1850,12 +1887,22 @@ namespace cppcanvas
break; break;
case META_RECT_ACTION: case META_RECT_ACTION:
{
Rectangle aPixelRect(
rVDev.LogicToPixel( static_cast<MetaRectAction*>(pCurrAct)->GetRect() ) );
// #121100# OutputDevice::DrawRect() fills
// rectangles Apple-like, i.e. with one
// additional pixel to the right and bottom.
aPixelRect.setWidth( aPixelRect.getWidth()+1 );
aPixelRect.setHeight( aPixelRect.getHeight()+1 );
createFillAndStroke( ::PolyPolygon( createFillAndStroke( ::PolyPolygon(
::Polygon( ::Polygon( aPixelRect ) ),
rVDev.LogicToPixel( static_cast<MetaRectAction*>(pCurrAct)->GetRect() ) ) ),
rCanvas, io_rCurrActionIndex, rCanvas, io_rCurrActionIndex,
rStates ); rStates );
break; break;
}
case META_ROUNDRECT_ACTION: case META_ROUNDRECT_ACTION:
createFillAndStroke( rVDev.LogicToPixel( Polygon( static_cast<MetaRoundRectAction*>(pCurrAct)->GetRect(), createFillAndStroke( rVDev.LogicToPixel( Polygon( static_cast<MetaRoundRectAction*>(pCurrAct)->GetRect(),
@@ -2387,10 +2434,27 @@ namespace cppcanvas
break; break;
case META_TEXTRECT_ACTION: case META_TEXTRECT_ACTION:
// TODO(F2): NYI {
OSL_ENSURE( false, MetaTextRectAction* pAct = static_cast<MetaTextRectAction*>(pCurrAct);
"META_TEXTRECT not yet supported" );
pushState( rStates, PUSH_ALL );
// use the VDev to break up the text rect
// action into readily formatted lines
GDIMetaFile aTmpMtf;
rVDev.AddTextRectActions( pAct->GetRect(),
pAct->GetText(),
pAct->GetStyle(),
aTmpMtf );
createActions( rCanvas, rVDev, aTmpMtf, rStates,
rParms, bSubsettableActions,
io_rCurrActionIndex );
popState( rStates );
break; break;
}
case META_STRETCHTEXT_ACTION: case META_STRETCHTEXT_ACTION:
{ {