summaryrefslogtreecommitdiff
path: root/vcl/source/gdi
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-11-15 10:18:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-11-15 12:13:42 +0100
commit5b74eb68113d3721e1a3f9fa40024bf9b2a15f0c (patch)
tree1c959ccc7769fd8530a16cc904b5424d04faa208 /vcl/source/gdi
parentb4aa631867638b993fda98b1c4fcfc47e5c6a1aa (diff)
loplugin:flatten in vcl
Change-Id: I3527477277a9ae96eaf9fd068232f672da7c28c3 Reviewed-on: https://gerrit.libreoffice.org/44753 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r--vcl/source/gdi/gdimtf.cxx963
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx487
-rw-r--r--vcl/source/gdi/pdfwriter_impl2.cxx307
-rw-r--r--vcl/source/gdi/print.cxx137
4 files changed, 952 insertions, 942 deletions
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index a7c691fc1863..ca9df62fdc36 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -449,61 +449,62 @@ void GDIMetaFile::Play( OutputDevice* pOut, const Point& rPos,
MapMode aDrawMap( GetPrefMapMode() );
Size aDestSize( pOut->LogicToPixel( rSize ) );
- if( aDestSize.Width() && aDestSize.Height() )
- {
- GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
+ if( !aDestSize.Width() || !aDestSize.Height() )
+ return;
- if( ImplPlayWithRenderer( pOut, rPos, rSize ) )
- return;
+ GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
- Size aTmpPrefSize( pOut->LogicToPixel( GetPrefSize(), aDrawMap ) );
+ if( ImplPlayWithRenderer( pOut, rPos, rSize ) )
+ return;
- if( !aTmpPrefSize.Width() )
- aTmpPrefSize.Width() = aDestSize.Width();
+ Size aTmpPrefSize( pOut->LogicToPixel( GetPrefSize(), aDrawMap ) );
- if( !aTmpPrefSize.Height() )
- aTmpPrefSize.Height() = aDestSize.Height();
+ if( !aTmpPrefSize.Width() )
+ aTmpPrefSize.Width() = aDestSize.Width();
- Fraction aScaleX( aDestSize.Width(), aTmpPrefSize.Width() );
- Fraction aScaleY( aDestSize.Height(), aTmpPrefSize.Height() );
+ if( !aTmpPrefSize.Height() )
+ aTmpPrefSize.Height() = aDestSize.Height();
- aScaleX *= aDrawMap.GetScaleX(); aDrawMap.SetScaleX( aScaleX );
- aScaleY *= aDrawMap.GetScaleY(); aDrawMap.SetScaleY( aScaleY );
+ Fraction aScaleX( aDestSize.Width(), aTmpPrefSize.Width() );
+ Fraction aScaleY( aDestSize.Height(), aTmpPrefSize.Height() );
- // #i47260# Convert logical output position to offset within
- // the metafile's mapmode. Therefore, disable pixel offset on
- // outdev, it's inverse mnOutOffLogicX/Y is calculated for a
- // different mapmode (the one currently set on pOut, that is)
- // - thus, aDrawMap's origin would generally be wrong. And
- // even _if_ aDrawMap is similar to pOutDev's current mapmode,
- // it's _still_ undesirable to have pixel offset unequal zero,
- // because one would still get round-off errors (the
- // round-trip error for LogicToPixel( PixelToLogic() ) was the
- // reason for having pixel offset in the first place).
- const Size& rOldOffset( pOut->GetPixelOffset() );
- const Size aEmptySize;
- pOut->SetPixelOffset( aEmptySize );
- aDrawMap.SetOrigin( pOut->PixelToLogic( pOut->LogicToPixel( rPos ), aDrawMap ) );
- pOut->SetPixelOffset( rOldOffset );
+ aScaleX *= aDrawMap.GetScaleX(); aDrawMap.SetScaleX( aScaleX );
+ aScaleY *= aDrawMap.GetScaleY(); aDrawMap.SetScaleY( aScaleY );
- pOut->Push();
+ // #i47260# Convert logical output position to offset within
+ // the metafile's mapmode. Therefore, disable pixel offset on
+ // outdev, it's inverse mnOutOffLogicX/Y is calculated for a
+ // different mapmode (the one currently set on pOut, that is)
+ // - thus, aDrawMap's origin would generally be wrong. And
+ // even _if_ aDrawMap is similar to pOutDev's current mapmode,
+ // it's _still_ undesirable to have pixel offset unequal zero,
+ // because one would still get round-off errors (the
+ // round-trip error for LogicToPixel( PixelToLogic() ) was the
+ // reason for having pixel offset in the first place).
+ const Size& rOldOffset( pOut->GetPixelOffset() );
+ const Size aEmptySize;
+ pOut->SetPixelOffset( aEmptySize );
+ aDrawMap.SetOrigin( pOut->PixelToLogic( pOut->LogicToPixel( rPos ), aDrawMap ) );
+ pOut->SetPixelOffset( rOldOffset );
- if ( pMtf && pMtf->IsRecord() && ( pOut->GetOutDevType() != OUTDEV_PRINTER ) )
- pOut->SetRelativeMapMode( aDrawMap );
- else
- pOut->SetMapMode( aDrawMap );
+ pOut->Push();
- // #i23407# Set backwards-compatible text language and layout mode
- // This is necessary, since old metafiles don't even know of these
- // recent add-ons. Newer metafiles must of course explicitly set
- // those states.
- pOut->SetLayoutMode( ComplexTextLayoutFlags::Default );
- pOut->SetDigitLanguage( LANGUAGE_SYSTEM );
+ if ( pMtf && pMtf->IsRecord() && ( pOut->GetOutDevType() != OUTDEV_PRINTER ) )
+ pOut->SetRelativeMapMode( aDrawMap );
+ else
+ pOut->SetMapMode( aDrawMap );
- Play( pOut );
+ // #i23407# Set backwards-compatible text language and layout mode
+ // This is necessary, since old metafiles don't even know of these
+ // recent add-ons. Newer metafiles must of course explicitly set
+ // those states.
+ pOut->SetLayoutMode( ComplexTextLayoutFlags::Default );
+ pOut->SetDigitLanguage( LANGUAGE_SYSTEM );
+
+ Play( pOut );
+
+ pOut->Pop();
- pOut->Pop();
- }
}
void GDIMetaFile::Pause( bool _bPause )
@@ -839,462 +840,463 @@ void GDIMetaFile::Rotate( long nAngle10 )
nAngle10 %= 3600;
nAngle10 = ( nAngle10 < 0 ) ? ( 3599 + nAngle10 ) : nAngle10;
- if( nAngle10 )
- {
- GDIMetaFile aMtf;
- ScopedVclPtrInstance< VirtualDevice > aMapVDev;
- const double fAngle = F_PI1800 * nAngle10;
- const double fSin = sin( fAngle );
- const double fCos = cos( fAngle );
- tools::Rectangle aRect=tools::Rectangle( Point(), GetPrefSize() );
- tools::Polygon aPoly( aRect );
+ if( !nAngle10 )
+ return;
+
+ GDIMetaFile aMtf;
+ ScopedVclPtrInstance< VirtualDevice > aMapVDev;
+ const double fAngle = F_PI1800 * nAngle10;
+ const double fSin = sin( fAngle );
+ const double fCos = cos( fAngle );
+ tools::Rectangle aRect=tools::Rectangle( Point(), GetPrefSize() );
+ tools::Polygon aPoly( aRect );
- aPoly.Rotate( Point(), fSin, fCos );
+ aPoly.Rotate( Point(), fSin, fCos );
- aMapVDev->EnableOutput( false );
- aMapVDev->SetMapMode( GetPrefMapMode() );
+ aMapVDev->EnableOutput( false );
+ aMapVDev->SetMapMode( GetPrefMapMode() );
- const tools::Rectangle aNewBound( aPoly.GetBoundRect() );
+ const tools::Rectangle aNewBound( aPoly.GetBoundRect() );
- const Point aOrigin( GetPrefMapMode().GetOrigin().X(), GetPrefMapMode().GetOrigin().Y() );
- const Size aOffset( -aNewBound.Left(), -aNewBound.Top() );
+ const Point aOrigin( GetPrefMapMode().GetOrigin().X(), GetPrefMapMode().GetOrigin().Y() );
+ const Size aOffset( -aNewBound.Left(), -aNewBound.Top() );
- Point aRotAnchor( aOrigin );
- Size aRotOffset( aOffset );
+ Point aRotAnchor( aOrigin );
+ Size aRotOffset( aOffset );
+
+ for( MetaAction* pAction = FirstAction(); pAction; pAction = NextAction() )
+ {
+ const MetaActionType nActionType = pAction->GetType();
- for( MetaAction* pAction = FirstAction(); pAction; pAction = NextAction() )
+ switch( nActionType )
{
- const MetaActionType nActionType = pAction->GetType();
+ case MetaActionType::PIXEL:
+ {
+ MetaPixelAction* pAct = static_cast<MetaPixelAction*>(pAction);
+ aMtf.AddAction( new MetaPixelAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetColor() ) );
+ }
+ break;
- switch( nActionType )
+ case MetaActionType::POINT:
{
- case MetaActionType::PIXEL:
- {
- MetaPixelAction* pAct = static_cast<MetaPixelAction*>(pAction);
- aMtf.AddAction( new MetaPixelAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetColor() ) );
- }
- break;
+ MetaPointAction* pAct = static_cast<MetaPointAction*>(pAction);
+ aMtf.AddAction( new MetaPointAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- case MetaActionType::POINT:
- {
- MetaPointAction* pAct = static_cast<MetaPointAction*>(pAction);
- aMtf.AddAction( new MetaPointAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::LINE:
+ {
+ MetaLineAction* pAct = static_cast<MetaLineAction*>(pAction);
+ aMtf.AddAction( new MetaLineAction( ImplGetRotatedPoint( pAct->GetStartPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
+ ImplGetRotatedPoint( pAct->GetEndPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetLineInfo() ) );
+ }
+ break;
- case MetaActionType::LINE:
- {
- MetaLineAction* pAct = static_cast<MetaLineAction*>(pAction);
- aMtf.AddAction( new MetaLineAction( ImplGetRotatedPoint( pAct->GetStartPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
- ImplGetRotatedPoint( pAct->GetEndPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetLineInfo() ) );
- }
- break;
+ case MetaActionType::RECT:
+ {
+ MetaRectAction* pAct = static_cast<MetaRectAction*>(pAction);
+ aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- case MetaActionType::RECT:
- {
- MetaRectAction* pAct = static_cast<MetaRectAction*>(pAction);
- aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::ROUNDRECT:
+ {
+ MetaRoundRectAction* pAct = static_cast<MetaRoundRectAction*>(pAction);
+ const tools::Polygon aRoundRectPoly( pAct->GetRect(), pAct->GetHorzRound(), pAct->GetVertRound() );
- case MetaActionType::ROUNDRECT:
- {
- MetaRoundRectAction* pAct = static_cast<MetaRoundRectAction*>(pAction);
- const tools::Polygon aRoundRectPoly( pAct->GetRect(), pAct->GetHorzRound(), pAct->GetVertRound() );
+ aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aRoundRectPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aRoundRectPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::ELLIPSE:
+ {
+ MetaEllipseAction* pAct = static_cast<MetaEllipseAction*>(pAction);
+ const tools::Polygon aEllipsePoly( pAct->GetRect().Center(), pAct->GetRect().GetWidth() >> 1, pAct->GetRect().GetHeight() >> 1 );
- case MetaActionType::ELLIPSE:
- {
- MetaEllipseAction* pAct = static_cast<MetaEllipseAction*>(pAction);
- const tools::Polygon aEllipsePoly( pAct->GetRect().Center(), pAct->GetRect().GetWidth() >> 1, pAct->GetRect().GetHeight() >> 1 );
+ aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aEllipsePoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aEllipsePoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::ARC:
+ {
+ MetaArcAction* pAct = static_cast<MetaArcAction*>(pAction);
+ const tools::Polygon aArcPoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Arc );
- case MetaActionType::ARC:
- {
- MetaArcAction* pAct = static_cast<MetaArcAction*>(pAction);
- const tools::Polygon aArcPoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Arc );
+ aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aArcPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aArcPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::PIE:
+ {
+ MetaPieAction* pAct = static_cast<MetaPieAction*>(pAction);
+ const tools::Polygon aPiePoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Pie );
- case MetaActionType::PIE:
- {
- MetaPieAction* pAct = static_cast<MetaPieAction*>(pAction);
- const tools::Polygon aPiePoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Pie );
+ aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aPiePoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aPiePoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::CHORD:
+ {
+ MetaChordAction* pAct = static_cast<MetaChordAction*>(pAction);
+ const tools::Polygon aChordPoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Chord );
- case MetaActionType::CHORD:
- {
- MetaChordAction* pAct = static_cast<MetaChordAction*>(pAction);
- const tools::Polygon aChordPoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Chord );
+ aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aChordPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( aChordPoly, aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::POLYLINE:
+ {
+ MetaPolyLineAction* pAct = static_cast<MetaPolyLineAction*>(pAction);
+ aMtf.AddAction( new MetaPolyLineAction( ImplGetRotatedPolygon( pAct->GetPolygon(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->GetLineInfo() ) );
+ }
+ break;
- case MetaActionType::POLYLINE:
- {
- MetaPolyLineAction* pAct = static_cast<MetaPolyLineAction*>(pAction);
- aMtf.AddAction( new MetaPolyLineAction( ImplGetRotatedPolygon( pAct->GetPolygon(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->GetLineInfo() ) );
- }
- break;
+ case MetaActionType::POLYGON:
+ {
+ MetaPolygonAction* pAct = static_cast<MetaPolygonAction*>(pAction);
+ aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( pAct->GetPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- case MetaActionType::POLYGON:
- {
- MetaPolygonAction* pAct = static_cast<MetaPolygonAction*>(pAction);
- aMtf.AddAction( new MetaPolygonAction( ImplGetRotatedPolygon( pAct->GetPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::POLYPOLYGON:
+ {
+ MetaPolyPolygonAction* pAct = static_cast<MetaPolyPolygonAction*>(pAction);
+ aMtf.AddAction( new MetaPolyPolygonAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
+ }
+ break;
- case MetaActionType::POLYPOLYGON:
- {
- MetaPolyPolygonAction* pAct = static_cast<MetaPolyPolygonAction*>(pAction);
- aMtf.AddAction( new MetaPolyPolygonAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) );
- }
- break;
+ case MetaActionType::TEXT:
+ {
+ MetaTextAction* pAct = static_cast<MetaTextAction*>(pAction);
+ aMtf.AddAction( new MetaTextAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetText(), pAct->GetIndex(), pAct->GetLen() ) );
+ }
+ break;
- case MetaActionType::TEXT:
- {
- MetaTextAction* pAct = static_cast<MetaTextAction*>(pAction);
- aMtf.AddAction( new MetaTextAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetText(), pAct->GetIndex(), pAct->GetLen() ) );
- }
- break;
+ case MetaActionType::TEXTARRAY:
+ {
+ MetaTextArrayAction* pAct = static_cast<MetaTextArrayAction*>(pAction);
+ aMtf.AddAction( new MetaTextArrayAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetText(), pAct->GetDXArray(), pAct->GetIndex(), pAct->GetLen() ) );
+ }
+ break;
- case MetaActionType::TEXTARRAY:
- {
- MetaTextArrayAction* pAct = static_cast<MetaTextArrayAction*>(pAction);
- aMtf.AddAction( new MetaTextArrayAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetText(), pAct->GetDXArray(), pAct->GetIndex(), pAct->GetLen() ) );
- }
- break;
+ case MetaActionType::STRETCHTEXT:
+ {
+ MetaStretchTextAction* pAct = static_cast<MetaStretchTextAction*>(pAction);
+ aMtf.AddAction( new MetaStretchTextAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetWidth(), pAct->GetText(), pAct->GetIndex(), pAct->GetLen() ) );
+ }
+ break;
- case MetaActionType::STRETCHTEXT:
- {
- MetaStretchTextAction* pAct = static_cast<MetaStretchTextAction*>(pAction);
- aMtf.AddAction( new MetaStretchTextAction( ImplGetRotatedPoint( pAct->GetPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetWidth(), pAct->GetText(), pAct->GetIndex(), pAct->GetLen() ) );
- }
- break;
+ case MetaActionType::TEXTLINE:
+ {
+ MetaTextLineAction* pAct = static_cast<MetaTextLineAction*>(pAction);
+ aMtf.AddAction( new MetaTextLineAction( ImplGetRotatedPoint( pAct->GetStartPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetWidth(), pAct->GetStrikeout(), pAct->GetUnderline(), pAct->GetOverline() ) );
+ }
+ break;
- case MetaActionType::TEXTLINE:
- {
- MetaTextLineAction* pAct = static_cast<MetaTextLineAction*>(pAction);
- aMtf.AddAction( new MetaTextLineAction( ImplGetRotatedPoint( pAct->GetStartPoint(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetWidth(), pAct->GetStrikeout(), pAct->GetUnderline(), pAct->GetOverline() ) );
- }
- break;
+ case MetaActionType::BMPSCALE:
+ {
+ MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
+ tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
+ tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
+ BitmapEx aBmpEx( pAct->GetBitmap() );
- case MetaActionType::BMPSCALE:
- {
- MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
- tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
- tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
- BitmapEx aBmpEx( pAct->GetBitmap() );
-
- aBmpEx.Rotate( nAngle10, Color( COL_TRANSPARENT ) );
- aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(),
- aBmpEx ) );
- }
- break;
+ aBmpEx.Rotate( nAngle10, Color( COL_TRANSPARENT ) );
+ aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(),
+ aBmpEx ) );
+ }
+ break;
- case MetaActionType::BMPSCALEPART:
- {
- MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
- tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetDestPoint(), pAct->GetDestSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
- tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
- BitmapEx aBmpEx( pAct->GetBitmap() );
+ case MetaActionType::BMPSCALEPART:
+ {
+ MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
+ tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetDestPoint(), pAct->GetDestSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
+ tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
+ BitmapEx aBmpEx( pAct->GetBitmap() );
- aBmpEx.Crop( tools::Rectangle( pAct->GetSrcPoint(), pAct->GetSrcSize() ) );
- aBmpEx.Rotate( nAngle10, Color( COL_TRANSPARENT ) );
+ aBmpEx.Crop( tools::Rectangle( pAct->GetSrcPoint(), pAct->GetSrcSize() ) );
+ aBmpEx.Rotate( nAngle10, Color( COL_TRANSPARENT ) );
- aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
- }
- break;
+ aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
+ }
+ break;
- case MetaActionType::BMPEXSCALE:
- {
- MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction);
- tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
- tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
- BitmapEx aBmpEx( pAct->GetBitmapEx() );
+ case MetaActionType::BMPEXSCALE:
+ {
+ MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pAction);
+ tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
+ tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
+ BitmapEx aBmpEx( pAct->GetBitmapEx() );
- aBmpEx.Rotate( nAngle10, Color( COL_TRANSPARENT ) );
+ aBmpEx.Rotate( nAngle10, Color( COL_TRANSPARENT ) );
- aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
- }
- break;
+ aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
+ }
+ break;
- case MetaActionType::BMPEXSCALEPART:
- {
- MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction);
- tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetDestPoint(), pAct->GetDestSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
- tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
- BitmapEx aBmpEx( pAct->GetBitmapEx() );
+ case MetaActionType::BMPEXSCALEPART:
+ {
+ MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pAction);
+ tools::Polygon aBmpPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetDestPoint(), pAct->GetDestSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
+ tools::Rectangle aBmpRect( aBmpPoly.GetBoundRect() );
+ BitmapEx aBmpEx( pAct->GetBitmapEx() );
- aBmpEx.Crop( tools::Rectangle( pAct->GetSrcPoint(), pAct->GetSrcSize() ) );
- aBmpEx.Rotate( nAngle10, Color( COL_TRANSPARENT ) );
+ aBmpEx.Crop( tools::Rectangle( pAct->GetSrcPoint(), pAct->GetSrcSize() ) );
+ aBmpEx.Rotate( nAngle10, Color( COL_TRANSPARENT ) );
- aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
- }
- break;
+ aMtf.AddAction( new MetaBmpExScaleAction( aBmpRect.TopLeft(), aBmpRect.GetSize(), aBmpEx ) );
+ }
+ break;
- case MetaActionType::GRADIENT:
- {
- MetaGradientAction* pAct = static_cast<MetaGradientAction*>(pAction);
+ case MetaActionType::GRADIENT:
+ {
+ MetaGradientAction* pAct = static_cast<MetaGradientAction*>(pAction);
- ImplAddGradientEx( aMtf, *aMapVDev.get(),
- ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetGradient() );
- }
- break;
+ ImplAddGradientEx( aMtf, *aMapVDev.get(),
+ ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetGradient() );
+ }
+ break;
- case MetaActionType::GRADIENTEX:
- {
- MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
- aMtf.AddAction( new MetaGradientExAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetGradient() ) );
- }
- break;
+ case MetaActionType::GRADIENTEX:
+ {
+ MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
+ aMtf.AddAction( new MetaGradientExAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetGradient() ) );
+ }
+ break;
- // Handle gradientex comment block correctly
- case MetaActionType::COMMENT:
+ // Handle gradientex comment block correctly
+ case MetaActionType::COMMENT:
+ {
+ MetaCommentAction* pCommentAct = static_cast<MetaCommentAction*>(pAction);
+ if( pCommentAct->GetComment() == "XGRAD_SEQ_BEGIN" )
{
- MetaCommentAction* pCommentAct = static_cast<MetaCommentAction*>(pAction);
- if( pCommentAct->GetComment() == "XGRAD_SEQ_BEGIN" )
+ int nBeginComments( 1 );
+ pAction = NextAction();
+
+ // skip everything, except gradientex action
+ while( pAction )
{
- int nBeginComments( 1 );
- pAction = NextAction();
+ const MetaActionType nType = pAction->GetType();
- // skip everything, except gradientex action
- while( pAction )
+ if( MetaActionType::GRADIENTEX == nType )
{
- const MetaActionType nType = pAction->GetType();
-
- if( MetaActionType::GRADIENTEX == nType )
+ // Add rotated gradientex
+ MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
+ ImplAddGradientEx( aMtf, *aMapVDev.get(),
+ ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetGradient() );
+ }
+ else if( MetaActionType::COMMENT == nType)
+ {
+ MetaCommentAction* pAct = static_cast<MetaCommentAction*>(pAction);
+ if( pAct->GetComment() == "XGRAD_SEQ_END" )
{
- // Add rotated gradientex
- MetaGradientExAction* pAct = static_cast<MetaGradientExAction*>(pAction);
- ImplAddGradientEx( aMtf, *aMapVDev.get(),
- ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetGradient() );
+ // handle nested blocks
+ --nBeginComments;
+
+ // gradientex comment block: end reached, done.
+ if( !nBeginComments )
+ break;
}
- else if( MetaActionType::COMMENT == nType)
+ else if( pAct->GetComment() == "XGRAD_SEQ_BEGIN" )
{
- MetaCommentAction* pAct = static_cast<MetaCommentAction*>(pAction);
- if( pAct->GetComment() == "XGRAD_SEQ_END" )
- {
- // handle nested blocks
- --nBeginComments;
-
- // gradientex comment block: end reached, done.
- if( !nBeginComments )
- break;
- }
- else if( pAct->GetComment() == "XGRAD_SEQ_BEGIN" )
- {
- // handle nested blocks
- ++nBeginComments;
- }
-
+ // handle nested blocks
+ ++nBeginComments;
}
- pAction =NextAction();
}
+
+ pAction =NextAction();
}
- else
+ }
+ else
+ {
+ bool bPathStroke = (pCommentAct->GetComment() == "XPATHSTROKE_SEQ_BEGIN");
+ if ( bPathStroke || pCommentAct->GetComment() == "XPATHFILL_SEQ_BEGIN" )
{
- bool bPathStroke = (pCommentAct->GetComment() == "XPATHSTROKE_SEQ_BEGIN");
- if ( bPathStroke || pCommentAct->GetComment() == "XPATHFILL_SEQ_BEGIN" )
+ if ( pCommentAct->GetDataSize() )
{
- if ( pCommentAct->GetDataSize() )
+ SvMemoryStream aMemStm( const_cast<sal_uInt8 *>(pCommentAct->GetData()), pCommentAct->GetDataSize(), StreamMode::READ );
+ SvMemoryStream aDest;
+ if ( bPathStroke )
{
- SvMemoryStream aMemStm( const_cast<sal_uInt8 *>(pCommentAct->GetData()), pCommentAct->GetDataSize(), StreamMode::READ );
- SvMemoryStream aDest;
- if ( bPathStroke )
- {
- SvtGraphicStroke aStroke;
- ReadSvtGraphicStroke( aMemStm, aStroke );
- tools::Polygon aPath;
- aStroke.getPath( aPath );
- aStroke.setPath( ImplGetRotatedPolygon( aPath, aRotAnchor, aRotOffset, fSin, fCos ) );
- WriteSvtGraphicStroke( aDest, aStroke );
- aMtf.AddAction( new MetaCommentAction( "XPATHSTROKE_SEQ_BEGIN", 0,
- static_cast<const sal_uInt8*>( aDest.GetData()), aDest.Tell() ) );
- }
- else
- {
- SvtGraphicFill aFill;
- ReadSvtGraphicFill( aMemStm, aFill );
- tools::PolyPolygon aPath;
- aFill.getPath( aPath );
- aFill.setPath( ImplGetRotatedPolyPolygon( aPath, aRotAnchor, aRotOffset, fSin, fCos ) );
- WriteSvtGraphicFill( aDest, aFill );
- aMtf.AddAction( new MetaCommentAction( "XPATHFILL_SEQ_BEGIN", 0,
- static_cast<const sal_uInt8*>( aDest.GetData()), aDest.Tell() ) );
- }
+ SvtGraphicStroke aStroke;
+ ReadSvtGraphicStroke( aMemStm, aStroke );
+ tools::Polygon aPath;
+ aStroke.getPath( aPath );
+ aStroke.setPath( ImplGetRotatedPolygon( aPath, aRotAnchor, aRotOffset, fSin, fCos ) );
+ WriteSvtGraphicStroke( aDest, aStroke );
+ aMtf.AddAction( new MetaCommentAction( "XPATHSTROKE_SEQ_BEGIN", 0,
+ static_cast<const sal_uInt8*>( aDest.GetData()), aDest.Tell() ) );
+ }
+ else
+ {
+ SvtGraphicFill aFill;
+ ReadSvtGraphicFill( aMemStm, aFill );
+ tools::PolyPolygon aPath;
+ aFill.getPath( aPath );
+ aFill.setPath( ImplGetRotatedPolyPolygon( aPath, aRotAnchor, aRotOffset, fSin, fCos ) );
+ WriteSvtGraphicFill( aDest, aFill );
+ aMtf.AddAction( new MetaCommentAction( "XPATHFILL_SEQ_BEGIN", 0,
+ static_cast<const sal_uInt8*>( aDest.GetData()), aDest.Tell() ) );
}
- }
- else if ( pCommentAct->GetComment() == "XPATHSTROKE_SEQ_END"
- || pCommentAct->GetComment() == "XPATHFILL_SEQ_END" )
- {
- pAction->Execute( aMapVDev.get() );
- pAction->Duplicate();
- aMtf.AddAction( pAction );
}
}
+ else if ( pCommentAct->GetComment() == "XPATHSTROKE_SEQ_END"
+ || pCommentAct->GetComment() == "XPATHFILL_SEQ_END" )
+ {
+ pAction->Execute( aMapVDev.get() );
+ pAction->Duplicate();
+ aMtf.AddAction( pAction );
+ }
}
- break;
+ }
+ break;
- case MetaActionType::HATCH:
- {
- MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction);
- Hatch aHatch( pAct->GetHatch() );
+ case MetaActionType::HATCH:
+ {
+ MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction);
+ Hatch aHatch( pAct->GetHatch() );
- aHatch.SetAngle( aHatch.GetAngle() + (sal_uInt16) nAngle10 );
- aMtf.AddAction( new MetaHatchAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
- aHatch ) );
- }
- break;
+ aHatch.SetAngle( aHatch.GetAngle() + (sal_uInt16) nAngle10 );
+ aMtf.AddAction( new MetaHatchAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
+ aHatch ) );
+ }
+ break;
- case MetaActionType::Transparent:
- {
- MetaTransparentAction* pAct = static_cast<MetaTransparentAction*>(pAction);
- aMtf.AddAction( new MetaTransparentAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
- pAct->GetTransparence() ) );
- }
- break;
+ case MetaActionType::Transparent:
+ {
+ MetaTransparentAction* pAct = static_cast<MetaTransparentAction*>(pAction);
+ aMtf.AddAction( new MetaTransparentAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ),
+ pAct->GetTransparence() ) );
+ }
+ break;
- case MetaActionType::FLOATTRANSPARENT:
- {
- MetaFloatTransparentAction* pAct = static_cast<MetaFloatTransparentAction*>(pAction);
- GDIMetaFile aTransMtf( pAct->GetGDIMetaFile() );
- tools::Polygon aMtfPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
- tools::Rectangle aMtfRect( aMtfPoly.GetBoundRect() );
-
- aTransMtf.Rotate( nAngle10 );
- aMtf.AddAction( new MetaFloatTransparentAction( aTransMtf, aMtfRect.TopLeft(), aMtfRect.GetSize(),
- pAct->GetGradient() ) );
- }
- break;
+ case MetaActionType::FLOATTRANSPARENT:
+ {
+ MetaFloatTransparentAction* pAct = static_cast<MetaFloatTransparentAction*>(pAction);
+ GDIMetaFile aTransMtf( pAct->GetGDIMetaFile() );
+ tools::Polygon aMtfPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
+ tools::Rectangle aMtfRect( aMtfPoly.GetBoundRect() );
- case MetaActionType::EPS:
- {
- MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction);
- GDIMetaFile aEPSMtf( pAct->GetSubstitute() );
- tools::Polygon aEPSPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
- tools::Rectangle aEPSRect( aEPSPoly.GetBoundRect() );
-
- aEPSMtf.Rotate( nAngle10 );
- aMtf.AddAction( new MetaEPSAction( aEPSRect.TopLeft(), aEPSRect.GetSize(),
- pAct->GetLink(), aEPSMtf ) );
- }
- break;
+ aTransMtf.Rotate( nAngle10 );
+ aMtf.AddAction( new MetaFloatTransparentAction( aTransMtf, aMtfRect.TopLeft(), aMtfRect.GetSize(),
+ pAct->GetGradient() ) );
+ }
+ break;
- case MetaActionType::CLIPREGION:
- {
- MetaClipRegionAction* pAct = static_cast<MetaClipRegionAction*>(pAction);
+ case MetaActionType::EPS:
+ {
+ MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pAction);
+ GDIMetaFile aEPSMtf( pAct->GetSubstitute() );
+ tools::Polygon aEPSPoly( ImplGetRotatedPolygon( tools::Rectangle( pAct->GetPoint(), pAct->GetSize() ), aRotAnchor, aRotOffset, fSin, fCos ) );
+ tools::Rectangle aEPSRect( aEPSPoly.GetBoundRect() );
- if( pAct->IsClipping() && pAct->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
- aMtf.AddAction( new MetaClipRegionAction( vcl::Region( ImplGetRotatedPolyPolygon( pAct->GetRegion().GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ), true ) );
- else
- {
- pAction->Duplicate();
- aMtf.AddAction( pAction );
- }
- }
- break;
+ aEPSMtf.Rotate( nAngle10 );
+ aMtf.AddAction( new MetaEPSAction( aEPSRect.TopLeft(), aEPSRect.GetSize(),
+ pAct->GetLink(), aEPSMtf ) );
+ }
+ break;
- case MetaActionType::ISECTRECTCLIPREGION:
+ case MetaActionType::CLIPREGION:
+ {
+ MetaClipRegionAction* pAct = static_cast<MetaClipRegionAction*>(pAction);
+
+ if( pAct->IsClipping() && pAct->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
+ aMtf.AddAction( new MetaClipRegionAction( vcl::Region( ImplGetRotatedPolyPolygon( pAct->GetRegion().GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ), true ) );
+ else
{
- MetaISectRectClipRegionAction* pAct = static_cast<MetaISectRectClipRegionAction*>(pAction);
- aMtf.AddAction( new MetaISectRegionClipRegionAction(vcl::Region(
- ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor,
- aRotOffset, fSin, fCos )) ) );
+ pAction->Duplicate();
+ aMtf.AddAction( pAction );
}
- break;
+ }
+ break;
- case MetaActionType::ISECTREGIONCLIPREGION:
- {
- MetaISectRegionClipRegionAction* pAct = static_cast<MetaISectRegionClipRegionAction*>(pAction);
- const vcl::Region& rRegion = pAct->GetRegion();
+ case MetaActionType::ISECTRECTCLIPREGION:
+ {
+ MetaISectRectClipRegionAction* pAct = static_cast<MetaISectRectClipRegionAction*>(pAction);
+ aMtf.AddAction( new MetaISectRegionClipRegionAction(vcl::Region(
+ ImplGetRotatedPolygon( pAct->GetRect(), aRotAnchor,
+ aRotOffset, fSin, fCos )) ) );
+ }
+ break;
- if( rRegion.HasPolyPolygonOrB2DPolyPolygon() )
- aMtf.AddAction( new MetaISectRegionClipRegionAction( vcl::Region( ImplGetRotatedPolyPolygon( rRegion.GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) ) );
- else
- {
- pAction->Duplicate();
- aMtf.AddAction( pAction );
- }
- }
- break;
+ case MetaActionType::ISECTREGIONCLIPREGION:
+ {
+ MetaISectRegionClipRegionAction* pAct = static_cast<MetaISectRegionClipRegionAction*>(pAction);
+ const vcl::Region& rRegion = pAct->GetRegion();
- case MetaActionType::REFPOINT:
+ if( rRegion.HasPolyPolygonOrB2DPolyPolygon() )
+ aMtf.AddAction( new MetaISectRegionClipRegionAction( vcl::Region( ImplGetRotatedPolyPolygon( rRegion.GetAsPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ) ) ) );
+ else
{
- MetaRefPointAction* pAct = static_cast<MetaRefPointAction*>(pAction);
- aMtf.AddAction( new MetaRefPointAction( ImplGetRotatedPoint( pAct->GetRefPoint(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->IsSetting() ) );
+ pAction->Duplicate();
+ aMtf.AddAction( pAction );
}
- break;
+ }
+ break;
- case MetaActionType::FONT:
- {
- MetaFontAction* pAct = static_cast<MetaFontAction*>(pAction);
- vcl::Font aFont( pAct->GetFont() );
+ case MetaActionType::REFPOINT:
+ {
+ MetaRefPointAction* pAct = static_cast<MetaRefPointAction*>(pAction);
+ aMtf.AddAction( new MetaRefPointAction( ImplGetRotatedPoint( pAct->GetRefPoint(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->IsSetting() ) );
+ }
+ break;
- aFont.SetOrientation( aFont.GetOrientation() + (sal_uInt16) nAngle10 );
- aMtf.AddAction( new MetaFontAction( aFont ) );
- }
- break;
+ case MetaActionType::FONT:
+ {
+ MetaFontAction* pAct = static_cast<MetaFontAction*>(pAction);
+ vcl::Font aFont( pAct->GetFont() );
- case MetaActionType::BMP:
- case MetaActionType::BMPEX:
- case MetaActionType::MASK:
- case MetaActionType::MASKSCALE:
- case MetaActionType::MASKSCALEPART:
- case MetaActionType::WALLPAPER:
- case MetaActionType::TEXTRECT:
- case MetaActionType::MOVECLIPREGION:
- {
- OSL_FAIL( "GDIMetaFile::Rotate(): unsupported action" );
- }
- break;
+ aFont.SetOrientation( aFont.GetOrientation() + (sal_uInt16) nAngle10 );
+ aMtf.AddAction( new MetaFontAction( aFont ) );
+ }
+ break;
- default:
- {
- pAction->Execute( aMapVDev.get() );
- pAction->Duplicate();
- aMtf.AddAction( pAction );
+ case MetaActionType::BMP:
+ case MetaActionType::BMPEX:
+ case MetaActionType::MASK:
+ case MetaActionType::MASKSCALE:
+ case MetaActionType::MASKSCALEPART:
+ case MetaActionType::WALLPAPER:
+ case MetaActionType::TEXTRECT:
+ case MetaActionType::MOVECLIPREGION:
+ {
+ OSL_FAIL( "GDIMetaFile::Rotate(): unsupported action" );
+ }
+ break;
- // update rotation point and offset, if necessary
- if( ( MetaActionType::MAPMODE == nActionType ) ||
- ( MetaActionType::PUSH == nActionType ) ||
- ( MetaActionType::POP == nActionType ) )
- {
- aRotAnchor = OutputDevice::LogicToLogic( aOrigin, m_aPrefMapMode, aMapVDev->GetMapMode() );
- aRotOffset = OutputDevice::LogicToLogic( aOffset, m_aPrefMapMode, aMapVDev->GetMapMode() );
- }
+ default:
+ {
+ pAction->Execute( aMapVDev.get() );
+ pAction->Duplicate();
+ aMtf.AddAction( pAction );
+
+ // update rotation point and offset, if necessary
+ if( ( MetaActionType::MAPMODE == nActionType ) ||
+ ( MetaActionType::PUSH == nActionType ) ||
+ ( MetaActionType::POP == nActionType ) )
+ {
+ aRotAnchor = OutputDevice::LogicToLogic( aOrigin, m_aPrefMapMode, aMapVDev->GetMapMode() );
+ aRotOffset = OutputDevice::LogicToLogic( aOffset, m_aPrefMapMode, aMapVDev->GetMapMode() );
}
- break;
}
+ break;
}
+ }
- aMtf.m_aPrefMapMode = m_aPrefMapMode;
- aMtf.m_aPrefSize = aNewBound.GetSize();
+ aMtf.m_aPrefMapMode = m_aPrefMapMode;
+ aMtf.m_aPrefSize = aNewBound.GetSize();
+
+ *this = aMtf;
- *this = aMtf;
- }
}
static void ImplActionBounds( tools::Rectangle& o_rOutBounds,
@@ -2107,84 +2109,85 @@ void GDIMetaFile::Adjust( short nLuminancePercent, short nContrastPercent,
short nChannelBPercent, double fGamma, bool bInvert, bool msoBrightness )
{
// nothing to do? => return quickly
- if( nLuminancePercent || nContrastPercent ||
- nChannelRPercent || nChannelGPercent || nChannelBPercent ||
- ( fGamma != 1.0 ) || bInvert )
- {
- double fM, fROff, fGOff, fBOff, fOff;
- ImplColAdjustParam aColParam;
- ImplBmpAdjustParam aBmpParam;
+ if( !(nLuminancePercent || nContrastPercent ||
+ nChannelRPercent || nChannelGPercent || nChannelBPercent ||
+ ( fGamma != 1.0 ) || bInvert) )
+ return;
+
+ double fM, fROff, fGOff, fBOff, fOff;
+ ImplColAdjustParam aColParam;
+ ImplBmpAdjustParam aBmpParam;
+
+ aColParam.pMapR = new sal_uInt8[ 256 ];
+ aColParam.pMapG = new sal_uInt8[ 256 ];
+ aColParam.pMapB = new sal_uInt8[ 256 ];
+
+ // calculate slope
+ if( nContrastPercent >= 0 )
+ fM = 128.0 / ( 128.0 - 1.27 * MinMax( nContrastPercent, 0, 100 ) );
+ else
+ fM = ( 128.0 + 1.27 * MinMax( nContrastPercent, -100, 0 ) ) / 128.0;
- aColParam.pMapR = new sal_uInt8[ 256 ];
- aColParam.pMapG = new sal_uInt8[ 256 ];
- aColParam.pMapB = new sal_uInt8[ 256 ];
+ if(!msoBrightness)
+ // total offset = luminance offset + contrast offset
+ fOff = MinMax( nLuminancePercent, -100, 100 ) * 2.55 + 128.0 - fM * 128.0;
+ else
+ fOff = MinMax( nLuminancePercent, -100, 100 ) * 2.55;
- // calculate slope
- if( nContrastPercent >= 0 )
- fM = 128.0 / ( 128.0 - 1.27 * MinMax( nContrastPercent, 0, 100 ) );
- else
- fM = ( 128.0 + 1.27 * MinMax( nContrastPercent, -100, 0 ) ) / 128.0;
+ // channel offset = channel offset + total offset
+ fROff = nChannelRPercent * 2.55 + fOff;
+ fGOff = nChannelGPercent * 2.55 + fOff;
+ fBOff = nChannelBPercent * 2.55 + fOff;
+ // calculate gamma value
+ fGamma = ( fGamma <= 0.0 || fGamma > 10.0 ) ? 1.0 : ( 1.0 / fGamma );
+ const bool bGamma = ( fGamma != 1.0 );
+
+ // create mapping table
+ for( long nX = 0; nX < 256; nX++ )
+ {
if(!msoBrightness)
- // total offset = luminance offset + contrast offset
- fOff = MinMax( nLuminancePercent, -100, 100 ) * 2.55 + 128.0 - fM * 128.0;
+ {
+ aColParam.pMapR[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fROff ), 0, 255 );
+ aColParam.pMapG[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fGOff ), 0, 255 );
+ aColParam.pMapB[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fBOff ), 0, 255 );
+ }
else
- fOff = MinMax( nLuminancePercent, -100, 100 ) * 2.55;
-
- // channel offset = channel offset + total offset
- fROff = nChannelRPercent * 2.55 + fOff;
- fGOff = nChannelGPercent * 2.55 + fOff;
- fBOff = nChannelBPercent * 2.55 + fOff;
-
- // calculate gamma value
- fGamma = ( fGamma <= 0.0 || fGamma > 10.0 ) ? 1.0 : ( 1.0 / fGamma );
- const bool bGamma = ( fGamma != 1.0 );
-
- // create mapping table
- for( long nX = 0; nX < 256; nX++ )
{
- if(!msoBrightness)
- {
- aColParam.pMapR[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fROff ), 0, 255 );
- aColParam.pMapG[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fGOff ), 0, 255 );
- aColParam.pMapB[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fBOff ), 0, 255 );
- }
- else
- {
- aColParam.pMapR[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 );
- aColParam.pMapG[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 );
- aColParam.pMapB[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 );
- }
- if( bGamma )
- {
- aColParam.pMapR[ nX ] = GAMMA( aColParam.pMapR[ nX ], fGamma );
- aColParam.pMapG[ nX ] = GAMMA( aColParam.pMapG[ nX ], fGamma );
- aColParam.pMapB[ nX ] = GAMMA( aColParam.pMapB[ nX ], fGamma );
- }
+ aColParam.pMapR[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 );
+ aColParam.pMapG[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 );
+ aColParam.pMapB[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 );
+ }
+ if( bGamma )
+ {
+ aColParam.pMapR[ nX ] = GAMMA( aColParam.pMapR[ nX ], fGamma );
+ aColParam.pMapG[ nX ] = GAMMA( aColParam.pMapG[ nX ], fGamma );
+ aColParam.pMapB[ nX ] = GAMMA( aColParam.pMapB[ nX ], fGamma );
+ }
- if( bInvert )
- {
- aColParam.pMapR[ nX ] = ~aColParam.pMapR[ nX ];
- aColParam.pMapG[ nX ] = ~aColParam.pMapG[ nX ];
- aColParam.pMapB[ nX ] = ~aColParam.pMapB[ nX ];
- }
+ if( bInvert )
+ {
+ aColParam.pMapR[ nX ] = ~aColParam.pMapR[ nX ];
+ aColParam.pMapG[ nX ] = ~aColParam.pMapG[ nX ];
+ aColParam.pMapB[ nX ] = ~aColParam.pMapB[ nX ];
}
+ }
- aBmpParam.nLuminancePercent = nLuminancePercent;
- aBmpParam.nContrastPercent = nContrastPercent;
- aBmpParam.nChannelRPercent = nChannelRPercent;
- aBmpParam.nChannelGPercent = nChannelGPercent;
- aBmpParam.nChannelBPercent = nChannelBPercent;
- aBmpParam.fGamma = fGamma;
- aBmpParam.bInvert = bInvert;
+ aBmpParam.nLuminancePercent = nLuminancePercent;
+ aBmpParam.nContrastPercent = nContrastPercent;
+ aBmpParam.nChannelRPercent = nChannelRPercent;
+ aBmpParam.nChannelGPercent = nChannelGPercent;
+ aBmpParam.nChannelBPercent = nChannelBPercent;
+ aBmpParam.fGamma = fGamma;
+ aBmpParam.bInvert = bInvert;
- // do color adjustment
- ImplExchangeColors( ImplColAdjustFnc, &aColParam, ImplBmpAdjustFnc, &aBmpParam );
+ // do color adjustment
+ ImplExchangeColors( ImplColAdjustFnc, &aColParam, ImplBmpAdjustFnc, &aBmpParam );
+
+ delete[] aColParam.pMapR;
+ delete[] aColParam.pMapG;
+ delete[] aColParam.pMapB;
- delete[] aColParam.pMapR;
- delete[] aColParam.pMapG;
- delete[] aColParam.pMapB;
- }
}
void GDIMetaFile::Convert( MtfConversion eConversion )
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 33ea6b0f194e..2fdd577f2e9b 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2254,64 +2254,65 @@ void PDFWriterImpl::newPage( double nPageWidth, double nPageHeight, PDFWriter::O
void PDFWriterImpl::endPage()
{
- if( !m_aPages.empty() )
- {
- // close eventual MC sequence
- endStructureElementMCSeq();
+ if( m_aPages.empty() )
+ return;
- // sanity check
- if( !m_aOutputStreams.empty() )
- {
- OSL_FAIL( "redirection across pages !!!" );
- m_aOutputStreams.clear(); // leak !
- m_aMapMode.SetOrigin( Point() );
- }
+ // close eventual MC sequence
+ endStructureElementMCSeq();
- m_aGraphicsStack.clear();
- m_aGraphicsStack.emplace_back( );
+ // sanity check
+ if( !m_aOutputStreams.empty() )
+ {
+ OSL_FAIL( "redirection across pages !!!" );
+ m_aOutputStreams.clear(); // leak !
+ m_aMapMode.SetOrigin( Point() );
+ }
- // this should pop the PDF graphics stack if necessary
- updateGraphicsState();
+ m_aGraphicsStack.clear();
+ m_aGraphicsStack.emplace_back( );
- m_aPages.back().endStream();
+ // this should pop the PDF graphics stack if necessary
+ updateGraphicsState();
- // reset the default font
- Font aFont;
- aFont.SetFamilyName( "Times" );
- aFont.SetFontSize( Size( 0, 12 ) );
+ m_aPages.back().endStream();
- m_aCurrentPDFState = m_aGraphicsStack.front();
- m_aGraphicsStack.front().m_aFont = aFont;
+ // reset the default font
+ Font aFont;
+ aFont.SetFamilyName( "Times" );
+ aFont.SetFontSize( Size( 0, 12 ) );
- for( std::list<BitmapEmit>::iterator it = m_aBitmaps.begin();
- it != m_aBitmaps.end(); ++it )
+ m_aCurrentPDFState = m_aGraphicsStack.front();
+ m_aGraphicsStack.front().m_aFont = aFont;
+
+ for( std::list<BitmapEmit>::iterator it = m_aBitmaps.begin();
+ it != m_aBitmaps.end(); ++it )
+ {
+ if( ! it->m_aBitmap.IsEmpty() )
{
- if( ! it->m_aBitmap.IsEmpty() )
- {
- writeBitmapObject( *it );
- it->m_aBitmap = BitmapEx();
- }
+ writeBitmapObject( *it );
+ it->m_aBitmap = BitmapEx();
}
- for( std::list<JPGEmit>::iterator jpeg = m_aJPGs.begin(); jpeg != m_aJPGs.end(); ++jpeg )
+ }
+ for( std::list<JPGEmit>::iterator jpeg = m_aJPGs.begin(); jpeg != m_aJPGs.end(); ++jpeg )
+ {
+ if( jpeg->m_pStream )
{
- if( jpeg->m_pStream )
- {
- writeJPG( *jpeg );
- jpeg->m_pStream.reset();
- jpeg->m_aMask = Bitmap();
- }
+ writeJPG( *jpeg );
+ jpeg->m_pStream.reset();
+ jpeg->m_aMask = Bitmap();
}
- for( std::list<TransparencyEmit>::iterator t = m_aTransparentObjects.begin();
- t != m_aTransparentObjects.end(); ++t )
+ }
+ for( std::list<TransparencyEmit>::iterator t = m_aTransparentObjects.begin();
+ t != m_aTransparentObjects.end(); ++t )
+ {
+ if( t->m_pContentStream )
{
- if( t->m_pContentStream )
- {
- writeTransparentObject( *t );
- delete t->m_pContentStream;
- t->m_pContentStream = nullptr;
- }
+ writeTransparentObject( *t );
+ delete t->m_pContentStream;
+ t->m_pContentStream = nullptr;
}
}
+
}
sal_Int32 PDFWriterImpl::createObject()
@@ -6909,87 +6910,88 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool
}
// write eventual emphasis marks
- if( m_aCurrentPDFState.m_aFont.GetEmphasisMark() & FontEmphasisMark::Style )
- {
- tools::PolyPolygon aEmphPoly;
- tools::Rectangle aEmphRect1;
- tools::Rectangle aEmphRect2;
- long nEmphYOff;
- long nEmphWidth;
- long nEmphHeight;
- bool bEmphPolyLine;
- FontEmphasisMark nEmphMark;
+ if( !(m_aCurrentPDFState.m_aFont.GetEmphasisMark() & FontEmphasisMark::Style) )
+ return;
- push( PushFlags::ALL );
+ tools::PolyPolygon aEmphPoly;
+ tools::Rectangle aEmphRect1;
+ tools::Rectangle aEmphRect2;
+ long nEmphYOff;
+ long nEmphWidth;
+ long nEmphHeight;
+ bool bEmphPolyLine;
+ FontEmphasisMark nEmphMark;
- aLine.setLength( 0 );
- aLine.append( "q\n" );
+ push( PushFlags::ALL );
- nEmphMark = OutputDevice::ImplGetEmphasisMarkStyle( m_aCurrentPDFState.m_aFont );
- if ( nEmphMark & FontEmphasisMark::PosBelow )
- nEmphHeight = m_pReferenceDevice->mnEmphasisDescent;
- else
- nEmphHeight = m_pReferenceDevice->mnEmphasisAscent;
- m_pReferenceDevice->ImplGetEmphasisMark( aEmphPoly,
- bEmphPolyLine,
- aEmphRect1,
- aEmphRect2,
- nEmphYOff,
- nEmphWidth,
- nEmphMark,
- m_pReferenceDevice->ImplDevicePixelToLogicWidth(nEmphHeight) );
- if ( bEmphPolyLine )
- {
- setLineColor( m_aCurrentPDFState.m_aFont.GetColor() );
- setFillColor( Color( COL_TRANSPARENT ) );
- }
- else
- {
- setFillColor( m_aCurrentPDFState.m_aFont.GetColor() );
- setLineColor( Color( COL_TRANSPARENT ) );
- }
- writeBuffer( aLine.getStr(), aLine.getLength() );
+ aLine.setLength( 0 );
+ aLine.append( "q\n" );
- Point aOffset = Point(0,0);
+ nEmphMark = OutputDevice::ImplGetEmphasisMarkStyle( m_aCurrentPDFState.m_aFont );
+ if ( nEmphMark & FontEmphasisMark::PosBelow )
+ nEmphHeight = m_pReferenceDevice->mnEmphasisDescent;
+ else
+ nEmphHeight = m_pReferenceDevice->mnEmphasisAscent;
+ m_pReferenceDevice->ImplGetEmphasisMark( aEmphPoly,
+ bEmphPolyLine,
+ aEmphRect1,
+ aEmphRect2,
+ nEmphYOff,
+ nEmphWidth,
+ nEmphMark,
+ m_pReferenceDevice->ImplDevicePixelToLogicWidth(nEmphHeight) );
+ if ( bEmphPolyLine )
+ {
+ setLineColor( m_aCurrentPDFState.m_aFont.GetColor() );
+ setFillColor( Color( COL_TRANSPARENT ) );
+ }
+ else
+ {
+ setFillColor( m_aCurrentPDFState.m_aFont.GetColor() );
+ setLineColor( Color( COL_TRANSPARENT ) );
+ }
+ writeBuffer( aLine.getStr(), aLine.getLength() );
- if ( nEmphMark & FontEmphasisMark::PosBelow )
- aOffset.Y() += m_pReferenceDevice->mpFontInstance->mxFontMetric->GetDescent() + nEmphYOff;
- else
- aOffset.Y() -= m_pReferenceDevice->mpFontInstance->mxFontMetric->GetAscent() + nEmphYOff;
+ Point aOffset = Point(0,0);
- long nEmphWidth2 = nEmphWidth / 2;
- long nEmphHeight2 = nEmphHeight / 2;
- aOffset += Point( nEmphWidth2, nEmphHeight2 );
+ if ( nEmphMark & FontEmphasisMark::PosBelow )
+ aOffset.Y() += m_pReferenceDevice->mpFontInstance->mxFontMetric->GetDescent() + nEmphYOff;
+ else
+ aOffset.Y() -= m_pReferenceDevice->mpFontInstance->mxFontMetric->GetAscent() + nEmphYOff;
+
+ long nEmphWidth2 = nEmphWidth / 2;
+ long nEmphHeight2 = nEmphHeight / 2;
+ aOffset += Point( nEmphWidth2, nEmphHeight2 );
- if ( eAlign == ALIGN_BOTTOM )
- aOffset.Y() -= m_pReferenceDevice->mpFontInstance->mxFontMetric->GetDescent();
- else if ( eAlign == ALIGN_TOP )
- aOffset.Y() += m_pReferenceDevice->mpFontInstance->mxFontMetric->GetAscent();
+ if ( eAlign == ALIGN_BOTTOM )
+ aOffset.Y() -= m_pReferenceDevice->mpFontInstance->mxFontMetric->GetDescent();
+ else if ( eAlign == ALIGN_TOP )
+ aOffset.Y() += m_pReferenceDevice->mpFontInstance->mxFontMetric->GetAscent();
- Point aPos;
- const GlyphItem* pGlyph;
- int nStart = 0;
- while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart))
+ Point aPos;
+ const GlyphItem* pGlyph;
+ int nStart = 0;
+ while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart))
+ {
+ if (pGlyph->IsSpacing())
{
- if (pGlyph->IsSpacing())
- {
- Point aAdjOffset = aOffset;
- aAdjOffset.X() += (pGlyph->mnNewWidth - nEmphWidth) / 2;
- aAdjOffset = aRotScale.transform( aAdjOffset );
+ Point aAdjOffset = aOffset;
+ aAdjOffset.X() += (pGlyph->mnNewWidth - nEmphWidth) / 2;
+ aAdjOffset = aRotScale.transform( aAdjOffset );
- aAdjOffset -= Point( nEmphWidth2, nEmphHeight2 );
+ aAdjOffset -= Point( nEmphWidth2, nEmphHeight2 );
- aPos += aAdjOffset;
- aPos = m_pReferenceDevice->PixelToLogic( aPos );
- drawEmphasisMark( aPos.X(), aPos.Y(),
- aEmphPoly, bEmphPolyLine,
- aEmphRect1, aEmphRect2 );
- }
+ aPos += aAdjOffset;
+ aPos = m_pReferenceDevice->PixelToLogic( aPos );
+ drawEmphasisMark( aPos.X(), aPos.Y(),
+ aEmphPoly, bEmphPolyLine,
+ aEmphRect1, aEmphRect2 );
}
-
- writeBuffer( "Q\n", 2 );
- pop();
}
+
+ writeBuffer( "Q\n", 2 );
+ pop();
+
}
void PDFWriterImpl::drawEmphasisMark( long nX, long nY,
@@ -7412,96 +7414,97 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon
break;
}
- if ( nLineHeight )
+ if ( !nLineHeight )
+ return;
+
+ m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine );
+ aLine.append( " w " );
+ appendStrokingColor( aColor, aLine );
+ aLine.append( "\n" );
+
+ switch ( eTextLine )
{
- m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine );
- aLine.append( " w " );
- appendStrokingColor( aColor, aLine );
- aLine.append( "\n" );
+ case LINESTYLE_DOTTED:
+ case LINESTYLE_BOLDDOTTED:
+ aLine.append( "[ " );
+ m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false );
+ aLine.append( " ] 0 d\n" );
+ break;
+ case LINESTYLE_DASH:
+ case LINESTYLE_LONGDASH:
+ case LINESTYLE_BOLDDASH:
+ case LINESTYLE_BOLDLONGDASH:
+ {
+ sal_Int32 nDashLength = 4*nLineHeight;
+ sal_Int32 nVoidLength = 2*nLineHeight;
+ if ( ( eTextLine == LINESTYLE_LONGDASH ) || ( eTextLine == LINESTYLE_BOLDLONGDASH ) )
+ nDashLength = 8*nLineHeight;
- switch ( eTextLine )
- {
- case LINESTYLE_DOTTED:
- case LINESTYLE_BOLDDOTTED:
aLine.append( "[ " );
+ m_aPages.back().appendMappedLength( nDashLength, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
+ aLine.append( " ] 0 d\n" );
+ }
+ break;
+ case LINESTYLE_DASHDOT:
+ case LINESTYLE_BOLDDASHDOT:
+ {
+ sal_Int32 nDashLength = 4*nLineHeight;
+ sal_Int32 nVoidLength = 2*nLineHeight;
+ aLine.append( "[ " );
+ m_aPages.back().appendMappedLength( nDashLength, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
+ aLine.append( ' ' );
m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
aLine.append( " ] 0 d\n" );
- break;
- case LINESTYLE_DASH:
- case LINESTYLE_LONGDASH:
- case LINESTYLE_BOLDDASH:
- case LINESTYLE_BOLDLONGDASH:
- {
- sal_Int32 nDashLength = 4*nLineHeight;
- sal_Int32 nVoidLength = 2*nLineHeight;
- if ( ( eTextLine == LINESTYLE_LONGDASH ) || ( eTextLine == LINESTYLE_BOLDLONGDASH ) )
- nDashLength = 8*nLineHeight;
-
- aLine.append( "[ " );
- m_aPages.back().appendMappedLength( nDashLength, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
- aLine.append( " ] 0 d\n" );
- }
- break;
- case LINESTYLE_DASHDOT:
- case LINESTYLE_BOLDDASHDOT:
- {
- sal_Int32 nDashLength = 4*nLineHeight;
- sal_Int32 nVoidLength = 2*nLineHeight;
- aLine.append( "[ " );
- m_aPages.back().appendMappedLength( nDashLength, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
- aLine.append( " ] 0 d\n" );
- }
- break;
- case LINESTYLE_DASHDOTDOT:
- case LINESTYLE_BOLDDASHDOTDOT:
- {
- sal_Int32 nDashLength = 4*nLineHeight;
- sal_Int32 nVoidLength = 2*nLineHeight;
- aLine.append( "[ " );
- m_aPages.back().appendMappedLength( nDashLength, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
- aLine.append( " ] 0 d\n" );
- }
- break;
- default:
- break;
- }
+ }
+ break;
+ case LINESTYLE_DASHDOTDOT:
+ case LINESTYLE_BOLDDASHDOTDOT:
+ {
+ sal_Int32 nDashLength = 4*nLineHeight;
+ sal_Int32 nVoidLength = 2*nLineHeight;
+ aLine.append( "[ " );
+ m_aPages.back().appendMappedLength( nDashLength, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( nVoidLength, aLine, false );
+ aLine.append( " ] 0 d\n" );
+ }
+ break;
+ default:
+ break;
+ }
+ aLine.append( "0 " );
+ m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine );
+ aLine.append( " m " );
+ m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine, false );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine );
+ aLine.append( " l S\n" );
+ if ( eTextLine == LINESTYLE_DOUBLE )
+ {
aLine.append( "0 " );
- m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine );
+ m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine );
aLine.append( " m " );
m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine, false );
aLine.append( ' ' );
- m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine );
+ m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine );
aLine.append( " l S\n" );
- if ( eTextLine == LINESTYLE_DOUBLE )
- {
- aLine.append( "0 " );
- m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine );
- aLine.append( " m " );
- m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine, false );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine );
- aLine.append( " l S\n" );
- }
}
+
}
void PDFWriterImpl::drawStrikeoutLine( OStringBuffer& aLine, long nWidth, FontStrikeout eStrikeout, Color aColor )
@@ -7540,32 +7543,33 @@ void PDFWriterImpl::drawStrikeoutLine( OStringBuffer& aLine, long nWidth, FontSt
break;
}
- if ( nLineHeight )
- {
- m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine );
- aLine.append( " w " );
- appendStrokingColor( aColor, aLine );
- aLine.append( "\n" );
+ if ( !nLineHeight )
+ return;
+
+ m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine );
+ aLine.append( " w " );
+ appendStrokingColor( aColor, aLine );
+ aLine.append( "\n" );
+
+ aLine.append( "0 " );
+ m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine );
+ aLine.append( " m " );
+ m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine );
+ aLine.append( ' ' );
+ m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine );
+ aLine.append( " l S\n" );
+ if ( eStrikeout == STRIKEOUT_DOUBLE )
+ {
aLine.append( "0 " );
- m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine );
+ m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine );
aLine.append( " m " );
m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine );
aLine.append( ' ' );
- m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine );
+ m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine );
aLine.append( " l S\n" );
-
- if ( eStrikeout == STRIKEOUT_DOUBLE )
- {
- aLine.append( "0 " );
- m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine );
- aLine.append( " m " );
- m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine );
- aLine.append( ' ' );
- m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine );
- aLine.append( " l S\n" );
- }
}
+
}
void PDFWriterImpl::drawStrikeoutChar( const Point& rPos, long nWidth, FontStrikeout eStrikeout )
@@ -7925,39 +7929,40 @@ void PDFWriterImpl::endTransparencyGroup( const tools::Rectangle& rBoundingBox,
SAL_WARN_IF( nTransparentPercent > 100, "vcl.pdfwriter", "invalid alpha value" );
nTransparentPercent = nTransparentPercent % 100;
- if( m_aContext.Version >= PDFWriter::PDFVersion::PDF_1_4 )
- {
- // create XObject
- m_aTransparentObjects.emplace_back( );
- m_aTransparentObjects.back().m_aBoundRect = rBoundingBox;
- // convert rectangle to default user space
- m_aPages.back().convertRect( m_aTransparentObjects.back().m_aBoundRect );
- m_aTransparentObjects.back().m_nObject = createObject();
- m_aTransparentObjects.back().m_fAlpha = (double)(100-nTransparentPercent) / 100.0;
- // get XObject's content stream
- m_aTransparentObjects.back().m_pContentStream = static_cast<SvMemoryStream*>(endRedirect());
- m_aTransparentObjects.back().m_nExtGStateObject = createObject();
-
- OStringBuffer aObjName( 16 );
- aObjName.append( "Tr" );
- aObjName.append( m_aTransparentObjects.back().m_nObject );
- OString aTrName( aObjName.makeStringAndClear() );
- aObjName.append( "EGS" );
- aObjName.append( m_aTransparentObjects.back().m_nExtGStateObject );
- OString aExtName( aObjName.makeStringAndClear() );
-
- OStringBuffer aLine( 80 );
- // insert XObject
- aLine.append( "q /" );
- aLine.append( aExtName );
- aLine.append( " gs /" );
- aLine.append( aTrName );
- aLine.append( " Do Q\n" );
- writeBuffer( aLine.getStr(), aLine.getLength() );
+ if( !(m_aContext.Version >= PDFWriter::PDFVersion::PDF_1_4) )
+ return;
+
+ // create XObject
+ m_aTransparentObjects.emplace_back( );
+ m_aTransparentObjects.back().m_aBoundRect = rBoundingBox;
+ // convert rectangle to default user space
+ m_aPages.back().convertRect( m_aTransparentObjects.back().m_aBoundRect );
+ m_aTransparentObjects.back().m_nObject = createObject();
+ m_aTransparentObjects.back().m_fAlpha = (double)(100-nTransparentPercent) / 100.0;
+ // get XObject's content stream
+ m_aTransparentObjects.back().m_pContentStream = static_cast<SvMemoryStream*>(endRedirect());
+ m_aTransparentObjects.back().m_nExtGStateObject = createObject();
+
+ OStringBuffer aObjName( 16 );
+ aObjName.append( "Tr" );
+ aObjName.append( m_aTransparentObjects.back().m_nObject );
+ OString aTrName( aObjName.makeStringAndClear() );
+ aObjName.append( "EGS" );
+ aObjName.append( m_aTransparentObjects.back().m_nExtGStateObject );
+ OString aExtName( aObjName.makeStringAndClear() );
+
+ OStringBuffer aLine( 80 );
+ // insert XObject
+ aLine.append( "q /" );
+ aLine.append( aExtName );
+ aLine.append( " gs /" );
+ aLine.append( aTrName );
+ aLine.append( " Do Q\n" );
+ writeBuffer( aLine.getStr(), aLine.getLength() );
+
+ pushResource( ResXObject, aTrName, m_aTransparentObjects.back().m_nObject );
+ pushResource( ResExtGState, aExtName, m_aTransparentObjects.back().m_nExtGStateObject );
- pushResource( ResXObject, aTrName, m_aTransparentObjects.back().m_nObject );
- pushResource( ResExtGState, aExtName, m_aTransparentObjects.back().m_nExtGStateObject );
- }
}
void PDFWriterImpl::drawRectangle( const tools::Rectangle& rRect )
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index dc47a65b6554..18ff07afc556 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -68,186 +68,187 @@ void PDFWriterImpl::implWriteGradient( const tools::PolyPolygon& i_rPolyPoly, co
void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSize, const BitmapEx& i_rBitmapEx, const Graphic& i_Graphic,
VirtualDevice const * i_pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& i_rContext )
{
- if ( !i_rBitmapEx.IsEmpty() && i_rSize.Width() && i_rSize.Height() )
+ if ( i_rBitmapEx.IsEmpty() || !i_rSize.Width() || !i_rSize.Height() )
+ return;
+
+ BitmapEx aBitmapEx( i_rBitmapEx );
+ Point aPoint( i_rPoint );
+ Size aSize( i_rSize );
+
+ // #i19065# Negative sizes have mirror semantics on
+ // OutputDevice. BitmapEx and co. have no idea about that, so
+ // perform that _before_ doing anything with aBitmapEx.
+ BmpMirrorFlags nMirrorFlags(BmpMirrorFlags::NONE);
+ if( aSize.Width() < 0 )
{
- BitmapEx aBitmapEx( i_rBitmapEx );
- Point aPoint( i_rPoint );
- Size aSize( i_rSize );
-
- // #i19065# Negative sizes have mirror semantics on
- // OutputDevice. BitmapEx and co. have no idea about that, so
- // perform that _before_ doing anything with aBitmapEx.
- BmpMirrorFlags nMirrorFlags(BmpMirrorFlags::NONE);
- if( aSize.Width() < 0 )
- {
- aSize.Width() *= -1;
- aPoint.X() -= aSize.Width();
- nMirrorFlags |= BmpMirrorFlags::Horizontal;
- }
- if( aSize.Height() < 0 )
- {
- aSize.Height() *= -1;
- aPoint.Y() -= aSize.Height();
- nMirrorFlags |= BmpMirrorFlags::Vertical;
- }
+ aSize.Width() *= -1;
+ aPoint.X() -= aSize.Width();
+ nMirrorFlags |= BmpMirrorFlags::Horizontal;
+ }
+ if( aSize.Height() < 0 )
+ {
+ aSize.Height() *= -1;
+ aPoint.Y() -= aSize.Height();
+ nMirrorFlags |= BmpMirrorFlags::Vertical;
+ }
- if( nMirrorFlags != BmpMirrorFlags::NONE )
- {
- aBitmapEx.Mirror( nMirrorFlags );
- }
+ if( nMirrorFlags != BmpMirrorFlags::NONE )
+ {
+ aBitmapEx.Mirror( nMirrorFlags );
+ }
- bool bIsJpeg = false, bIsPng = false;
- if( i_Graphic.GetType() != GraphicType::NONE && i_Graphic.GetBitmapEx() == aBitmapEx )
- {
- GfxLinkType eType = i_Graphic.GetLink().GetType();
- bIsJpeg = (eType == GfxLinkType::NativeJpg);
- bIsPng = (eType == GfxLinkType::NativePng);
- }
+ bool bIsJpeg = false, bIsPng = false;
+ if( i_Graphic.GetType() != GraphicType::NONE && i_Graphic.GetBitmapEx() == aBitmapEx )
+ {
+ GfxLinkType eType = i_Graphic.GetLink().GetType();
+ bIsJpeg = (eType == GfxLinkType::NativeJpg);
+ bIsPng = (eType == GfxLinkType::NativePng);
+ }
- if( i_rContext.m_nMaxImageResolution > 50 )
+ if( i_rContext.m_nMaxImageResolution > 50 )
+ {
+ // do downsampling if necessary
+ const Size aDstSizeTwip( i_pDummyVDev->PixelToLogic(i_pDummyVDev->LogicToPixel(aSize), MapMode(MapUnit::MapTwip)) );
+ const Size aBmpSize( aBitmapEx.GetSizePixel() );
+ const double fBmpPixelX = aBmpSize.Width();
+ const double fBmpPixelY = aBmpSize.Height();
+ const double fMaxPixelX = aDstSizeTwip.Width() * i_rContext.m_nMaxImageResolution / 1440.0;
+ const double fMaxPixelY = aDstSizeTwip.Height() * i_rContext.m_nMaxImageResolution / 1440.0;
+
+ // check, if the bitmap DPI exceeds the maximum DPI (allow 4 pixel rounding tolerance)
+ if( ( ( fBmpPixelX > ( fMaxPixelX + 4 ) ) ||
+ ( fBmpPixelY > ( fMaxPixelY + 4 ) ) ) &&
+ ( fBmpPixelY > 0.0 ) && ( fMaxPixelY > 0.0 ) )
{
- // do downsampling if necessary
- const Size aDstSizeTwip( i_pDummyVDev->PixelToLogic(i_pDummyVDev->LogicToPixel(aSize), MapMode(MapUnit::MapTwip)) );
- const Size aBmpSize( aBitmapEx.GetSizePixel() );
- const double fBmpPixelX = aBmpSize.Width();
- const double fBmpPixelY = aBmpSize.Height();
- const double fMaxPixelX = aDstSizeTwip.Width() * i_rContext.m_nMaxImageResolution / 1440.0;
- const double fMaxPixelY = aDstSizeTwip.Height() * i_rContext.m_nMaxImageResolution / 1440.0;
-
- // check, if the bitmap DPI exceeds the maximum DPI (allow 4 pixel rounding tolerance)
- if( ( ( fBmpPixelX > ( fMaxPixelX + 4 ) ) ||
- ( fBmpPixelY > ( fMaxPixelY + 4 ) ) ) &&
- ( fBmpPixelY > 0.0 ) && ( fMaxPixelY > 0.0 ) )
- {
- // do scaling
- Size aNewBmpSize;
- const double fBmpWH = fBmpPixelX / fBmpPixelY;
- const double fMaxWH = fMaxPixelX / fMaxPixelY;
+ // do scaling
+ Size aNewBmpSize;
+ const double fBmpWH = fBmpPixelX / fBmpPixelY;
+ const double fMaxWH = fMaxPixelX / fMaxPixelY;
- if( fBmpWH < fMaxWH )
- {
- aNewBmpSize.Width() = FRound( fMaxPixelY * fBmpWH );
- aNewBmpSize.Height() = FRound( fMaxPixelY );
- }
- else if( fBmpWH > 0.0 )
- {
- aNewBmpSize.Width() = FRound( fMaxPixelX );
- aNewBmpSize.Height() = FRound( fMaxPixelX / fBmpWH);
- }
+ if( fBmpWH < fMaxWH )
+ {
+ aNewBmpSize.Width() = FRound( fMaxPixelY * fBmpWH );
+ aNewBmpSize.Height() = FRound( fMaxPixelY );
+ }
+ else if( fBmpWH > 0.0 )
+ {
+ aNewBmpSize.Width() = FRound( fMaxPixelX );
+ aNewBmpSize.Height() = FRound( fMaxPixelX / fBmpWH);
+ }
- if( aNewBmpSize.Width() && aNewBmpSize.Height() )
- {
- // #i121233# Use best quality for PDF exports
- aBitmapEx.Scale( aNewBmpSize, BmpScaleFlag::BestQuality );
- }
- else
- {
- aBitmapEx.SetEmpty();
- }
+ if( aNewBmpSize.Width() && aNewBmpSize.Height() )
+ {
+ // #i121233# Use best quality for PDF exports
+ aBitmapEx.Scale( aNewBmpSize, BmpScaleFlag::BestQuality );
+ }
+ else
+ {
+ aBitmapEx.SetEmpty();
}
}
+ }
- const Size aSizePixel( aBitmapEx.GetSizePixel() );
- if ( aSizePixel.Width() && aSizePixel.Height() )
+ const Size aSizePixel( aBitmapEx.GetSizePixel() );
+ if ( aSizePixel.Width() && aSizePixel.Height() )
+ {
+ if( m_aContext.ColorMode == PDFWriter::DrawGreyscale )
{
- if( m_aContext.ColorMode == PDFWriter::DrawGreyscale )
+ BmpConversion eConv = BmpConversion::N8BitGreys;
+ int nDepth = aBitmapEx.GetBitmap().GetBitCount();
+ if( nDepth <= 4 )
+ eConv = BmpConversion::N4BitGreys;
+ if( nDepth > 1 )
+ aBitmapEx.Convert( eConv );
+ }
+ bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression;
+ if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
+ bUseJPGCompression = false;
+
+ SvMemoryStream aStrm;
+ Bitmap aMask;
+
+ bool bTrueColorJPG = true;
+ if ( bUseJPGCompression )
+ {
+
+ sal_uInt32 nZippedFileSize = 0; // sj: we will calculate the filesize of a zipped bitmap
+ if ( !bIsJpeg ) // to determine if jpeg compression is useful
{
- BmpConversion eConv = BmpConversion::N8BitGreys;
- int nDepth = aBitmapEx.GetBitmap().GetBitCount();
- if( nDepth <= 4 )
- eConv = BmpConversion::N4BitGreys;
- if( nDepth > 1 )
- aBitmapEx.Convert( eConv );
+ SvMemoryStream aTemp;
+ aTemp.SetCompressMode( aTemp.GetCompressMode() | SvStreamCompressFlags::ZBITMAP );
+ aTemp.SetVersion( SOFFICE_FILEFORMAT_40 ); // sj: up from version 40 our bitmap stream operator
+ WriteDIBBitmapEx(aBitmapEx, aTemp); // is capable of zlib stream compression
+ aTemp.Seek( STREAM_SEEK_TO_END );
+ nZippedFileSize = aTemp.Tell();
}
- bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression;
- if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
- bUseJPGCompression = false;
+ if ( aBitmapEx.IsTransparent() )
+ {
+ if ( aBitmapEx.IsAlpha() )
+ aMask = aBitmapEx.GetAlpha().GetBitmap();
+ else
+ aMask = aBitmapEx.GetMask();
+ }
+ Graphic aGraphic( aBitmapEx.GetBitmap() );
- SvMemoryStream aStrm;
- Bitmap aMask;
+ Sequence< PropertyValue > aFilterData( 2 );
+ aFilterData[ 0 ].Name = "Quality";
+ aFilterData[ 0 ].Value <<= sal_Int32(i_rContext.m_nJPEGQuality);
+ aFilterData[ 1 ].Name = "ColorMode";
+ aFilterData[ 1 ].Value <<= sal_Int32(0);
- bool bTrueColorJPG = true;
- if ( bUseJPGCompression )
+ try
{
-
- sal_uInt32 nZippedFileSize = 0; // sj: we will calculate the filesize of a zipped bitmap
- if ( !bIsJpeg ) // to determine if jpeg compression is useful
+ uno::Reference < io::XStream > xStream = new utl::OStreamWrapper( aStrm );
+ uno::Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
+ uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(xContext) );
+ uno::Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() );
+ uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() );
+ uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 );
+ aOutMediaProperties[0].Name = "OutputStream";
+ aOutMediaProperties[0].Value <<= xOut;
+ aOutMediaProperties[1].Name = "MimeType";
+ aOutMediaProperties[1].Value <<= OUString("image/jpeg");
+ aOutMediaProperties[2].Name = "FilterData";
+ aOutMediaProperties[2].Value <<= aFilterData;
+ xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties );
+ xOut->flush();
+ if ( !bIsJpeg && xSeekable->getLength() > nZippedFileSize )
{
- SvMemoryStream aTemp;
- aTemp.SetCompressMode( aTemp.GetCompressMode() | SvStreamCompressFlags::ZBITMAP );
- aTemp.SetVersion( SOFFICE_FILEFORMAT_40 ); // sj: up from version 40 our bitmap stream operator
- WriteDIBBitmapEx(aBitmapEx, aTemp); // is capable of zlib stream compression
- aTemp.Seek( STREAM_SEEK_TO_END );
- nZippedFileSize = aTemp.Tell();
- }
- if ( aBitmapEx.IsTransparent() )
- {
- if ( aBitmapEx.IsAlpha() )
- aMask = aBitmapEx.GetAlpha().GetBitmap();
- else
- aMask = aBitmapEx.GetMask();
+ bUseJPGCompression = false;
}
- Graphic aGraphic( aBitmapEx.GetBitmap() );
-
- Sequence< PropertyValue > aFilterData( 2 );
- aFilterData[ 0 ].Name = "Quality";
- aFilterData[ 0 ].Value <<= sal_Int32(i_rContext.m_nJPEGQuality);
- aFilterData[ 1 ].Name = "ColorMode";
- aFilterData[ 1 ].Value <<= sal_Int32(0);
-
- try
+ else
{
- uno::Reference < io::XStream > xStream = new utl::OStreamWrapper( aStrm );
- uno::Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW );
- uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
- uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(xContext) );
- uno::Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() );
- uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() );
- uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 );
- aOutMediaProperties[0].Name = "OutputStream";
- aOutMediaProperties[0].Value <<= xOut;
- aOutMediaProperties[1].Name = "MimeType";
- aOutMediaProperties[1].Value <<= OUString("image/jpeg");
- aOutMediaProperties[2].Name = "FilterData";
- aOutMediaProperties[2].Value <<= aFilterData;
- xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties );
- xOut->flush();
- if ( !bIsJpeg && xSeekable->getLength() > nZippedFileSize )
+ aStrm.Seek( STREAM_SEEK_TO_END );
+
+ xSeekable->seek( 0 );
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[ 0 ].Name = "InputStream";
+ aArgs[ 0 ].Value <<= xStream;
+ uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) );
+ if ( xPropSet.is() )
{
- bUseJPGCompression = false;
- }
- else
- {
- aStrm.Seek( STREAM_SEEK_TO_END );
-
- xSeekable->seek( 0 );
- Sequence< PropertyValue > aArgs( 1 );
- aArgs[ 0 ].Name = "InputStream";
- aArgs[ 0 ].Value <<= xStream;
- uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) );
- if ( xPropSet.is() )
+ sal_Int16 nBitsPerPixel = 24;
+ if ( xPropSet->getPropertyValue("BitsPerPixel") >>= nBitsPerPixel )
{
- sal_Int16 nBitsPerPixel = 24;
- if ( xPropSet->getPropertyValue("BitsPerPixel") >>= nBitsPerPixel )
- {
- bTrueColorJPG = nBitsPerPixel != 8;
- }
+ bTrueColorJPG = nBitsPerPixel != 8;
}
}
}
- catch( uno::Exception& )
- {
- bUseJPGCompression = false;
- }
}
- if ( bUseJPGCompression )
- m_rOuterFace.DrawJPGBitmap( aStrm, bTrueColorJPG, aSizePixel, tools::Rectangle( aPoint, aSize ), aMask, i_Graphic );
- else if ( aBitmapEx.IsTransparent() )
- m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx );
- else
- m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap(), i_Graphic );
+ catch( uno::Exception& )
+ {
+ bUseJPGCompression = false;
+ }
}
+ if ( bUseJPGCompression )
+ m_rOuterFace.DrawJPGBitmap( aStrm, bTrueColorJPG, aSizePixel, tools::Rectangle( aPoint, aSize ), aMask, i_Graphic );
+ else if ( aBitmapEx.IsTransparent() )
+ m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx );
+ else
+ m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap(), i_Graphic );
}
+
}
void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevData* i_pOutDevData, const vcl::PDFWriter::PlayMetafileContext& i_rContext, VirtualDevice* pDummyVDev )
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 55f4b3fa3be9..62a12325847f 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -741,82 +741,83 @@ void Printer::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
aSrcRect.Justify();
- if( !rMask.IsEmpty() && aSrcRect.GetWidth() && aSrcRect.GetHeight() && aDestSz.Width() && aDestSz.Height() )
+ if( !(!rMask.IsEmpty() && aSrcRect.GetWidth() && aSrcRect.GetHeight() && aDestSz.Width() && aDestSz.Height()) )
+ return;
+
+ Bitmap aMask( rMask );
+ BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE;
+
+ if( aMask.GetBitCount() > 1 )
+ aMask.Convert( BmpConversion::N1BitThreshold );
+
+ // mirrored horizontically
+ if( aDestSz.Width() < 0 )
{
- Bitmap aMask( rMask );
- BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE;
+ aDestSz.Width() = -aDestSz.Width();
+ aDestPt.X() -= ( aDestSz.Width() - 1 );
+ nMirrFlags |= BmpMirrorFlags::Horizontal;
+ }
- if( aMask.GetBitCount() > 1 )
- aMask.Convert( BmpConversion::N1BitThreshold );
+ // mirrored vertically
+ if( aDestSz.Height() < 0 )
+ {
+ aDestSz.Height() = -aDestSz.Height();
+ aDestPt.Y() -= ( aDestSz.Height() - 1 );
+ nMirrFlags |= BmpMirrorFlags::Vertical;
+ }
- // mirrored horizontically
- if( aDestSz.Width() < 0 )
- {
- aDestSz.Width() = -aDestSz.Width();
- aDestPt.X() -= ( aDestSz.Width() - 1 );
- nMirrFlags |= BmpMirrorFlags::Horizontal;
- }
+ // source cropped?
+ if( aSrcRect != tools::Rectangle( aPt, aMask.GetSizePixel() ) )
+ aMask.Crop( aSrcRect );
- // mirrored vertically
- if( aDestSz.Height() < 0 )
- {
- aDestSz.Height() = -aDestSz.Height();
- aDestPt.Y() -= ( aDestSz.Height() - 1 );
- nMirrFlags |= BmpMirrorFlags::Vertical;
- }
+ // destination mirrored
+ if( nMirrFlags != BmpMirrorFlags::NONE)
+ aMask.Mirror( nMirrFlags );
- // source cropped?
- if( aSrcRect != tools::Rectangle( aPt, aMask.GetSizePixel() ) )
- aMask.Crop( aSrcRect );
-
- // destination mirrored
- if( nMirrFlags != BmpMirrorFlags::NONE)
- aMask.Mirror( nMirrFlags );
-
- // do painting
- const long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
- long nX, nY; //, nWorkX, nWorkY, nWorkWidth, nWorkHeight;
- long* pMapX = new long[ nSrcWidth + 1 ];
- long* pMapY = new long[ nSrcHeight + 1 ];
- GDIMetaFile* pOldMetaFile = mpMetaFile;
- const bool bOldMap = mbMap;
-
- mpMetaFile = nullptr;
- mbMap = false;
- Push( PushFlags::FILLCOLOR | PushFlags::LINECOLOR );
- SetLineColor( rMaskColor );
- SetFillColor( rMaskColor );
- InitLineColor();
- InitFillColor();
-
- // create forward mapping tables
- for( nX = 0; nX <= nSrcWidth; nX++ )
- pMapX[ nX ] = aDestPt.X() + FRound( (double) aDestSz.Width() * nX / nSrcWidth );
-
- for( nY = 0; nY <= nSrcHeight; nY++ )
- pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight );
-
- // walk through all rectangles of mask
- const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel())));
- RectangleVector aRectangles;
- aWorkRgn.GetRegionRectangles(aRectangles);
-
- for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
- {
- const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]);
- const Size aMapSz(
- pMapX[aRectIter->Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
- pMapY[aRectIter->Bottom() + 1] - aMapPt.Y()); // same for Y
+ // do painting
+ const long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
+ long nX, nY; //, nWorkX, nWorkY, nWorkWidth, nWorkHeight;
+ long* pMapX = new long[ nSrcWidth + 1 ];
+ long* pMapY = new long[ nSrcHeight + 1 ];
+ GDIMetaFile* pOldMetaFile = mpMetaFile;
+ const bool bOldMap = mbMap;
- DrawRect(tools::Rectangle(aMapPt, aMapSz));
- }
+ mpMetaFile = nullptr;
+ mbMap = false;
+ Push( PushFlags::FILLCOLOR | PushFlags::LINECOLOR );
+ SetLineColor( rMaskColor );
+ SetFillColor( rMaskColor );
+ InitLineColor();
+ InitFillColor();
+
+ // create forward mapping tables
+ for( nX = 0; nX <= nSrcWidth; nX++ )
+ pMapX[ nX ] = aDestPt.X() + FRound( (double) aDestSz.Width() * nX / nSrcWidth );
+
+ for( nY = 0; nY <= nSrcHeight; nY++ )
+ pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight );
+
+ // walk through all rectangles of mask
+ const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel())));
+ RectangleVector aRectangles;
+ aWorkRgn.GetRegionRectangles(aRectangles);
+
+ for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
+ {
+ const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]);
+ const Size aMapSz(
+ pMapX[aRectIter->Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
+ pMapY[aRectIter->Bottom() + 1] - aMapPt.Y()); // same for Y
- Pop();
- delete[] pMapX;
- delete[] pMapY;
- mbMap = bOldMap;
- mpMetaFile = pOldMetaFile;
+ DrawRect(tools::Rectangle(aMapPt, aMapSz));
}
+
+ Pop();
+ delete[] pMapX;
+ delete[] pMapY;
+ mbMap = bOldMap;
+ mpMetaFile = pOldMetaFile;
+
}
SalPrinterQueueInfo* Printer::ImplGetQueueInfo( const OUString& rPrinterName,