[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 5 commits - vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Sun Jul 20 04:51:32 PDT 2014
vcl/source/filter/wmf/enhwmf.cxx | 2
vcl/source/filter/wmf/winmtf.cxx | 32 ++++++-------
vcl/source/filter/wmf/winwmf.cxx | 90 ++++++++++++++++++++++++++++-----------
3 files changed, 82 insertions(+), 42 deletions(-)
New commits:
commit 2243edc6e9136f5fbbeb5a876993944ffad64dac
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun May 18 23:30:39 2014 +0200
fdo#72590 scale or map only when EMR_EXTSELECTCLIPRGN action
Conflicts:
vcl/source/filter/wmf/enhwmf.cxx
vcl/source/filter/wmf/winmtf.cxx
Change-Id: Ie42c855e696922b38760876d4090d572deaa689a
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index e487d73..c4e062b 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -990,7 +990,7 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
PolyPolygon aPolyPoly;
if ( cbRgnData )
ImplReadRegion( aPolyPoly, *pWMF, nRecSize );
- pOut->SetClipPath( aPolyPoly, iMode, sal_True );
+ pOut->SetClipPath( aPolyPoly, iMode, sal_False );
}
break;
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index f21d54a..f87336c 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -304,14 +304,11 @@ Color WinMtf::ReadColor()
Point WinMtfOutput::ImplScale( const Point& rPt) // Hack to set varying defaults for incompletely defined files.
{
- if (mbIsMapDevSet)
- return rPt; //fdo#73764
-
- if (mbIsMapWinSet)
+ if (!mbIsMapDevSet)
return Point(rPt.X() * UNDOCUMENTED_WIN_RCL_RELATION - mrclFrame.Left(),
rPt.Y() * UNDOCUMENTED_WIN_RCL_RELATION - mrclFrame.Top());
-
- return ImplMap(rPt);
+ else
+ return rPt;
}
@@ -816,17 +813,18 @@ void WinMtfOutput::MoveClipRegion( const Size& rSize )
void WinMtfOutput::SetClipPath( const PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode, sal_Bool bIsMapped )
{
- mbClipNeedsUpdate=true;
- if ( bIsMapped )
- {
- PolyPolygon aPP( rPolyPolygon );
- aClipPath.setClipPath( ImplScale( aPP ), nClippingMode );
- }
- else
+
+ mbClipNeedsUpdate = true;
+ PolyPolygon aPolyPolygon(rPolyPolygon);
+
+ if (!bIsMapped)
{
- PolyPolygon aPP( rPolyPolygon );
- aClipPath.setClipPath( ImplMap( aPP ), nClippingMode );
+ if (!mbIsMapDevSet && (mnMapMode == MM_ISOTROPIC || mnMapMode == MM_ANISOTROPIC))
+ aPolyPolygon = ImplScale(aPolyPolygon);
+ else
+ aPolyPolygon = ImplMap(aPolyPolygon);
}
+ aClipPath.setClipPath(aPolyPolygon, nClippingMode);
}
commit 668d28b19508ec313e6a771e5c118e742e463a8a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Thu May 15 16:28:45 2014 +0200
wmf: assume WinOrg/ViewportOrg = (0,0) if they are not provided
Conflicts:
vcl/source/filter/wmf/winwmf.cxx
Change-Id: Ia8a91a565118d102ff769da8bca65f16b5dfece2
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index 6438b8f..3a633fc 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -1346,10 +1346,10 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
pStm->Seek( nPos );
- boost::optional<Point> aWinOrg;
+ Point aWinOrg(0,0);
boost::optional<Size> aWinExt;
- boost::optional<Point> aViewportOrg;
+ Point aViewportOrg(0,0);
boost::optional<Size> aViewportExt;
if( nEnd - nPos )
@@ -1588,13 +1588,13 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
if (bRet)
{
- if (aWinOrg && aWinExt)
+ if (aWinExt)
{
- rPlaceableBound = Rectangle(*aWinOrg, *aWinExt);
+ rPlaceableBound = Rectangle(aWinOrg, *aWinExt);
}
- else if (aViewportOrg && aViewportExt)
+ else if (aViewportExt)
{
- rPlaceableBound = Rectangle(*aViewportOrg, *aViewportExt);
+ rPlaceableBound = Rectangle(aViewportOrg, *aViewportExt);
}
else
{
commit 14e326516512e3999ca3f7217e5b2a0f1730ca35
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Thu May 15 13:52:21 2014 +0200
fdo#78603 mixup (Left->Top) in Rectangle construction
Conflicts:
vcl/source/filter/wmf/winwmf.cxx
Change-Id: I7fa566e036508d43b153c7983dc89fc6660718e7
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index e02606e..6438b8f 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -1152,6 +1152,21 @@ sal_Bool WMFReader::ReadHeader()
{
pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the metaactions
GetPlaceableBound( aPlaceableBound, pWMF );
+
+ // The image size is not known so normalize the calculated bounds so that the
+ // resulting image is not too big
+ const long aMaxWidth = 1024;
+ const double fMaxWidth = static_cast<double>(aMaxWidth);
+ if (aPlaceableBound.GetWidth() > aMaxWidth)
+ {
+ double fRatio = aPlaceableBound.GetWidth() / fMaxWidth;
+
+ aPlaceableBound = Rectangle(
+ aPlaceableBound.Left() / fRatio,
+ aPlaceableBound.Top() / fRatio,
+ aPlaceableBound.Right() / fRatio,
+ aPlaceableBound.Bottom() / fRatio);
+ }
}
pWMF->Seek( nStrmPos );
commit 56f24911ce90f1ad9f56c72d9c87840ea94eb590
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed May 7 21:18:24 2014 +0200
vcl WMF: in non-placable images use SETWINDOW{ORG,EXT} for Bounds
If the image is non-placable the image bounds are bounds of all
elements. Special cases are when both SETWINDOWEXT and SETWINDOWORG
or SETVIEWPORTORG and SETVIEWPORTEXT are available - in those two
cases use those bounds bounds instead.
Conflicts:
vcl/source/filter/wmf/winwmf.cxx
Change-Id: I60e53cf6c47ccfc0f1139a11a866392f3e8e3ed1
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index a9a85c5..e02606e 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -19,7 +19,9 @@
#include "winmtf.hxx"
+
#include <boost/scoped_array.hpp>
+#include <boost/optional.hpp>
#include <vcl/gdimtf.hxx>
#include <vcl/wmf.hxx>
#include <rtl/crc.h>
@@ -1132,7 +1134,12 @@ sal_Bool WMFReader::ReadHeader()
else
{
nUnitsPerInch = 96;
- if ( pExternalHeader != NULL && ( pExternalHeader->mapMode == MM_ISOTROPIC || pExternalHeader->mapMode == MM_ANISOTROPIC ) )
+
+
+ if ( pExternalHeader != NULL
+ && pExternalHeader->xExt > 0
+ && pExternalHeader->yExt > 0
+ && (pExternalHeader->mapMode == MM_ISOTROPIC || pExternalHeader->mapMode == MM_ANISOTROPIC))
{
// #n417818#: If we have an external header then overwrite the bounds!
Rectangle aExtRect(0, 0,
@@ -1313,16 +1320,23 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
{
sal_Bool bRet = sal_True;
- rPlaceableBound.Left() = RECT_MAX;
- rPlaceableBound.Top() = RECT_MAX;
- rPlaceableBound.Right() = RECT_MIN;
- rPlaceableBound.Bottom() = RECT_MIN;
+ Rectangle aBound;
+ aBound.Left() = RECT_MAX;
+ aBound.Top() = RECT_MAX;
+ aBound.Right() = RECT_MIN;
+ aBound.Bottom() = RECT_MIN;
sal_uInt32 nPos = pStm->Tell();
sal_uInt32 nEnd = pStm->Seek( STREAM_SEEK_TO_END );
pStm->Seek( nPos );
+ boost::optional<Point> aWinOrg;
+ boost::optional<Size> aWinExt;
+
+ boost::optional<Point> aViewportOrg;
+ boost::optional<Size> aViewportExt;
+
if( nEnd - nPos )
{
sal_Int16 nMapMode = MM_ANISOTROPIC;
@@ -1346,9 +1360,7 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
{
case W_META_SETWINDOWORG:
{
- Point aWinOrg;
aWinOrg = ReadYX();
- rPlaceableBound.SetPos( aWinOrg );
}
break;
@@ -1362,17 +1374,15 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
case W_META_SETVIEWPORTORG:
{
- Point aWinOrg;
- aWinOrg = ReadYX();
- rPlaceableBound.SetPos( aWinOrg );
+ aViewportOrg = ReadYX();
}
break;
case W_META_SETVIEWPORTEXT:
{
sal_Int16 nWidth(0), nHeight(0);
- *pStm >> nHeight >> nWidth;
- rPlaceableBound.SetSize( Size( nWidth, nHeight ) );
+ *pStm >> nHeight >> nWidth;
+ aViewportExt = Size(nWidth, nHeight);
}
break;
@@ -1382,19 +1392,19 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
case W_META_MOVETO:
case W_META_LINETO:
- GetWinExtMax( ReadYX(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadYX(), aBound, nMapMode );
break;
case W_META_RECTANGLE:
case W_META_INTERSECTCLIPRECT:
case W_META_EXCLUDECLIPRECT :
case W_META_ELLIPSE:
- GetWinExtMax( ReadRectangle(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadRectangle(), aBound, nMapMode );
break;
case W_META_ROUNDRECT:
ReadYXExt(); // size
- GetWinExtMax( ReadRectangle(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadRectangle(), aBound, nMapMode );
break;
case W_META_ARC:
@@ -1402,7 +1412,7 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
case W_META_CHORD:
ReadYX(); // end
ReadYX(); // start
- GetWinExtMax( ReadRectangle(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadRectangle(), aBound, nMapMode );
break;
case W_META_POLYGON:
@@ -1410,7 +1420,7 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
sal_uInt16 nPoints;
*pStm >> nPoints;
for(sal_uInt16 i = 0; i < nPoints; i++ )
- GetWinExtMax( ReadPoint(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadPoint(), aBound, nMapMode );
}
break;
@@ -1443,7 +1453,7 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
}
for (sal_uInt16 i = 0; i < nPoints; i++ )
- GetWinExtMax( ReadPoint(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadPoint(), aBound, nMapMode );
bRecordOk &= pStm->good();
@@ -1461,14 +1471,14 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
sal_uInt16 nPoints;
*pStm >> nPoints;
for(sal_uInt16 i = 0; i < nPoints; i++ )
- GetWinExtMax( ReadPoint(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadPoint(), aBound, nMapMode );
}
break;
case W_META_SETPIXEL:
{
ReadColor();
- GetWinExtMax( ReadYX(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadYX(), aBound, nMapMode );
}
break;
@@ -1480,7 +1490,7 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
if ( nLength )
{
pStm->SeekRel( ( nLength + 1 ) &~ 1 );
- GetWinExtMax( ReadYX(), rPlaceableBound, nMapMode );
+ GetWinExtMax( ReadYX(), aBound, nMapMode );
}
}
break;
@@ -1494,7 +1504,7 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
*pStm >> nLen >> nOptions;
// todo: we also have to take care of the text width
if( nLen )
- GetWinExtMax( aPosition, rPlaceableBound, nMapMode );
+ GetWinExtMax( aPosition, aBound, nMapMode );
}
break;
case W_META_BITBLT:
@@ -1529,7 +1539,7 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
if ( aDestSize.Width() && aDestSize.Height() ) // #92623# do not try to read buggy bitmaps
{
Rectangle aDestRect( ReadYX(), aDestSize );
- GetWinExtMax( aDestRect, rPlaceableBound, nMapMode );
+ GetWinExtMax( aDestRect, aBound, nMapMode );
}
}
}
@@ -1540,7 +1550,7 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
sal_uInt32 nROP;
*pStm >> nROP;
Size aSize = ReadYXExt();
- GetWinExtMax( Rectangle( ReadYX(), aSize ), rPlaceableBound, nMapMode );
+ GetWinExtMax( Rectangle( ReadYX(), aSize ), aBound, nMapMode );
}
break;
}
@@ -1560,6 +1570,23 @@ sal_Bool WMFReader::GetPlaceableBound( Rectangle& rPlaceableBound, SvStream* pSt
pStm->SetError( SVSTREAM_GENERALERROR );
bRet = sal_False;
}
+
+ if (bRet)
+ {
+ if (aWinOrg && aWinExt)
+ {
+ rPlaceableBound = Rectangle(*aWinOrg, *aWinExt);
+ }
+ else if (aViewportOrg && aViewportExt)
+ {
+ rPlaceableBound = Rectangle(*aViewportOrg, *aViewportExt);
+ }
+ else
+ {
+ rPlaceableBound = aBound;
+ }
+ }
+
return bRet;
}
commit cdc102f1153ee61cb53d2da7e4acfe4074da8935
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed May 7 21:04:32 2014 +0200
fdo#70498 work-around scaling in SetClipPath
Scaling needed to be worked-around again so that the image in the
bug report could be drawn correctly. The issue needs some more
investigation how to detect what are the exact conditions that
scaling is needed.
Change-Id: Icd3f57a8ded92c49848feea92dc5a14362718874
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index c21d5e8..f21d54a 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -304,14 +304,14 @@ Color WinMtf::ReadColor()
Point WinMtfOutput::ImplScale( const Point& rPt) // Hack to set varying defaults for incompletely defined files.
{
- if (mbIsMapDevSet && mbIsMapWinSet)
- {
- return rPt; //fdo#73764
- }
- else
- {
- return Point((rPt.X())*UNDOCUMENTED_WIN_RCL_RELATION-mrclFrame.Left(),(rPt.Y())*UNDOCUMENTED_WIN_RCL_RELATION-mrclFrame.Top());
- }
+ if (mbIsMapDevSet)
+ return rPt; //fdo#73764
+
+ if (mbIsMapWinSet)
+ return Point(rPt.X() * UNDOCUMENTED_WIN_RCL_RELATION - mrclFrame.Left(),
+ rPt.Y() * UNDOCUMENTED_WIN_RCL_RELATION - mrclFrame.Top());
+
+ return ImplMap(rPt);
}
More information about the Libreoffice-commits
mailing list