Author: alg
Date: Mon Sep 2 12:13:37 2013
New Revision: 1519406
URL: http://svn.apache.org/r1519406
Log:
i122820 Corrected graphics creation, allow bigger limits if directly requested
Modified:
openoffice/trunk/main/svx/source/unodraw/UnoGraphicExporter.cxx
Modified: openoffice/trunk/main/svx/source/unodraw/UnoGraphicExporter.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/unodraw/UnoGraphicExporter.cxx?rev=1519406&r1=1519405&r2=1519406&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/unodraw/UnoGraphicExporter.cxx (original)
+++ openoffice/trunk/main/svx/source/unodraw/UnoGraphicExporter.cxx Mon Sep 2
12:13:37 2013
@@ -225,6 +225,7 @@ namespace svx
{
// use new primitive conversion tooling
basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0));
+ sal_uInt32 nMaximumQuadraticPixels(500000);
if(pSize)
{
@@ -233,6 +234,10 @@ namespace svx
const Size
aSize100th(Application::GetDefaultDevice()->PixelToLogic(*pSize,
MapMode(MAP_100TH_MM)));
aRange.expand(basegfx::B2DPoint(aSize100th.Width(),
aSize100th.Height()));
+
+ // when explicitely pixels are requested from the
GraphicExporter, use a *very* high limit
+ // of 16gb (4096x4096 pixels), else use the default for the
converters
+ nMaximumQuadraticPixels = std::min(sal_uInt32(4096 * 4096),
sal_uInt32(pSize->Width() * pSize->Height()));
}
else
{
@@ -242,13 +247,42 @@ namespace svx
aRange.expand(basegfx::B2DPoint(aSize100th.Width(),
aSize100th.Height()));
}
- aBmpEx = convertMetafileToBitmapEx(rMtf, aRange);
- }
- else
+ aBmpEx = convertMetafileToBitmapEx(rMtf, aRange,
nMaximumQuadraticPixels);
+ }
+ else
{
const SvtOptionsDrawinglayer aDrawinglayerOpt;
+ Size aTargetSize(0, 0);
+
+ if(pSize)
+ {
+ // #122820# If a concrete target size in pixels is given, use
it
+ aTargetSize = *pSize;
+
+ // get hairline and full bound rect to evtl. reduce given
target pixel size when
+ // it is known that it will be expanded to get the right and
bottom hairlines right
+ Rectangle aHairlineRect;
+ const Rectangle
aRect(rMtf.GetBoundRect(*Application::GetDefaultDevice(), &aHairlineRect));
+
+ if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty())
+ {
+ if(aRect.Right() == aHairlineRect.Right() ||
aRect.Bottom() == aHairlineRect.Bottom())
+ {
+ if(aTargetSize.Width())
+ {
+ aTargetSize.Width() -= 1;
+ }
+
+ if(aTargetSize.Height())
+ {
+ aTargetSize.Height() -= 1;
+ }
+ }
+ }
+ }
+
const GraphicConversionParameters aParameters(
- pSize ? *pSize : Size(0, 0),
+ aTargetSize,
true, // allow unlimited size
aDrawinglayerOpt.IsAntiAliasing(),
aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete());
@@ -429,26 +463,39 @@ VirtualDevice* GraphicExporter::CreatePa
}
pVDev->SetMapMode( aMM );
-#ifdef DBG_UTIL
- sal_Bool bAbort = !
-#endif
- pVDev->SetOutputSize(aPageSize);
- DBG_ASSERT(!bAbort, "virt. Device nicht korrekt erzeugt");
-
- SdrView* pView = new SdrView(mpDoc, pVDev);
- pView->SetPageVisible( sal_False );
- pView->SetBordVisible( sal_False );
- pView->SetGridVisible( sal_False );
- pView->SetHlplVisible( sal_False );
- pView->SetGlueVisible( sal_False );
- pView->ShowSdrPage(pPage);
- Region aRegion (Rectangle( aPoint, aPageSize ) );
+ bool bSuccess(false);
+
+ // #122820# If available, use pixel size directly
+ if(nWidthPixel && nHeightPixel)
+ {
+ bSuccess = pVDev->SetOutputSizePixel(Size(nWidthPixel, nHeightPixel));
+ }
+ else
+ {
+ bSuccess = pVDev->SetOutputSize(aPageSize);
+ }
+
+ if(bSuccess)
+ {
+ SdrView* pView = new SdrView(mpDoc, pVDev);
+ pView->SetPageVisible( sal_False );
+ pView->SetBordVisible( sal_False );
+ pView->SetGridVisible( sal_False );
+ pView->SetHlplVisible( sal_False );
+ pView->SetGlueVisible( sal_False );
+ pView->ShowSdrPage(pPage);
+ Region aRegion (Rectangle( aPoint, aPageSize ) );
- ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
+ ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
- pView->CompleteRedraw(pVDev, aRegion, &aRedirector);
+ pView->CompleteRedraw(pVDev, aRegion, &aRedirector);
+ delete pView;
+ }
+ else
+ {
+ OSL_ENSURE(false, "Could not get a VirtualDevice of requested size
(!)");
+ }
- delete pView;
return pVDev;
}