diff options
author | Armin Le Grand <alg@apache.org> | 2013-09-02 12:13:37 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-02 16:34:38 +0100 |
commit | 89d01a7d8028ddb765e02c116d202a2435894217 (patch) | |
tree | 770da4b8baa79719213700d4e5e6ad3cb14d18c3 /svx | |
parent | d649afe84ba659df845d2c4733dfba3fa4c657a3 (diff) |
Resolves: #i122820# Corrected graphics creation...
allow bigger limits if directly requested
(cherry picked from commit 50f1445bda91cb44a1a1e8636ab0bcb6a8c4f381)
Conflicts:
svx/source/unodraw/UnoGraphicExporter.cxx
Change-Id: I33576ef9f95b9f8a9fa0ab6f6d83c93ecec8da9f
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/unodraw/UnoGraphicExporter.cxx | 91 |
1 files changed, 69 insertions, 22 deletions
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 6516929df7c9..7adf62f78df4 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -209,6 +209,7 @@ namespace svx { // use new primitive conversion tooling basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0)); + sal_uInt32 nMaximumQuadraticPixels(500000); if(pSize) { @@ -217,6 +218,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 { @@ -226,13 +231,42 @@ namespace svx aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); } - aBmpEx = convertMetafileToBitmapEx(rMtf, aRange); + aBmpEx = convertMetafileToBitmapEx(rMtf, aRange, nMaximumQuadraticPixels); } else { const SvtOptionsDrawinglayer aDrawinglayerOpt; + Size aTargetSize(0, 0); + + if(pSize) + { + // #i122820# 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()); @@ -413,26 +447,39 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid } pVDev->SetMapMode( aMM ); -#ifdef DBG_UTIL - 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 ) ); - - ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage ); - - pView->CompleteRedraw(pVDev, aRegion, &aRedirector); - - delete pView; + bool bSuccess(false); + + // #i122820# 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 ); + + pView->CompleteRedraw(pVDev, aRegion, &aRedirector); + delete pView; + } + else + { + OSL_ENSURE(false, "Could not get a VirtualDevice of requested size (!)"); + } + return pVDev; } |