desktop/source/lib/init.cxx | 6 - libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk | 3 libreofficekit/qa/unit/tiledrendering.cxx | 25 ++++ sd/source/ui/unoidl/unomodel.cxx | 65 ++++++++++-- 4 files changed, 87 insertions(+), 12 deletions(-)
New commits: commit b33469fc41b798cf151d26f27ced85d73663c459 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri Jul 11 16:10:58 2014 +0200 Impress: implement tiled rendering. However we cannot as of yet select between rendering just the slide, just the notes, or both combined -- this simply defaults to whatever mode the document was last opened in for now. Change-Id: Ia8ec0280aab75a36e430aa04c47cee4fea2db974 diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 74133b8..ec22916 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -87,6 +87,7 @@ #include <unokywds.hxx> #include "FrameView.hxx" #include "ClientView.hxx" +#include "DrawViewShell.hxx" #include "ViewShell.hxx" #include "app.hrc" #include <vcl/pdfextoutdevdata.hxx> @@ -108,6 +109,7 @@ using namespace ::osl; using namespace ::cppu; using namespace ::com::sun::star; +using namespace ::sd; class SdUnoForbiddenCharsTable : public SvxUnoForbiddenCharsTable, public SfxListener @@ -2190,33 +2192,76 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice, int nTilePosX, int nTilePosY, long nTileWidth, long nTileHeight ) { - (void) rDevice; - (void) nOutputWidth; - (void) nOutputHeight; - (void) nTilePosX; - (void) nTilePosY; - (void) nTileWidth; - (void) nTileHeight; + // Scaling. Must convert from pixels to twips. We know + // that VirtualDevices use a DPI of 96. + // We specifically calculate these scales first as we're still + // in TWIPs, and might as well minimise the number of conversions. + Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) / + Fraction( nTileWidth); + Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) / + Fraction( nTileHeight); + + // svx seems to be the only component that works natively in + // 100th mm rather than TWIP. It makes most sense just to + // convert here and in getDocumentSize, and leave the tiled + // rendering API working in TWIPs. + nTileWidth = nTileWidth * 2540l / 1440l; + nTileHeight = nTileHeight * 2540l / 1440l; + nTilePosX = nTilePosX * 2540l / 1440l; + nTilePosY = nTilePosY * 2540l / 1440l; + + MapMode aMapMode = rDevice.GetMapMode(); + aMapMode.SetMapUnit( MAP_100TH_MM ); + aMapMode.SetOrigin( Point( -nTilePosX, + -nTilePosY) ); + aMapMode.SetScaleX( scaleX ); + aMapMode.SetScaleY( scaleY ); + + rDevice.SetMapMode( aMapMode ); + + rDevice.SetOutputSizePixel( Size(nOutputWidth, nOutputHeight) ); + mpDoc->GetDocSh()->GetViewShell()->GetView()->CompleteRedraw( + &rDevice, + Region( + Rectangle( Point( nTilePosX, nTilePosY ), + Size( nTileWidth, nTileHeight ) ) ) ); + + // TODO: Set page kind in frameview? } void SdXImpressDocument::setPart( int nPart ) { - (void) nPart; + DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() ); + if (pViewSh) + { + pViewSh->SwitchPage( nPart ); + } } int SdXImpressDocument::getParts() { - return mpDoc->GetPageCount(); + // TODO: master pages? + // Read: drviews1.cxx + return mpDoc->GetSdPageCount(PK_STANDARD); } int SdXImpressDocument::getPart() { + DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() ); + if (pViewSh) + { + return pViewSh->GetCurPageId(); + } return 0; } Size SdXImpressDocument::getDocumentSize() { - return Size( 100, 100 ); + SdrPageView* pCurPageView = mpDoc->GetDocSh()->GetViewShell()->GetView()->GetSdrPageView(); + Size aSize = pCurPageView->GetPageRect().GetSize(); + // Convert the size in 100th mm to TWIP + // See paintTile above for further info. + return Size( aSize.getWidth() * 1440l / 2540l, aSize.getHeight() * 1440l / 2540l ); } commit 0ff0b9c0310d1541d1a7d02c2cc222da9191479b Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri Jul 11 16:09:30 2014 +0200 LOK: use solar mutex for setPart. Needed e.g. for changing slides in impress. Change-Id: I2f5de40d4efbacde910e27225768979a98ff1c0a diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 7b6197a..da551b4 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -461,7 +461,11 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart) return; } - pDoc->setPart( nPart ); + Application::AcquireSolarMutex(1); + { + pDoc->setPart( nPart ); + } + Application::ReleaseSolarMutex(); } void doc_paintTile (LibreOfficeKitDocument* pThis, commit b360f9e0864f9b370f917d7bb846746cf122d40b Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri Jul 11 10:23:15 2014 +0200 Add png dumping to LOK tiled rendering test. This allows for easier visual comparisons (i.e. currently the test would be failing for some tiles). Change-Id: I5b174375b57ffe0edd2700fdec411a83669e4a34 diff --git a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk index 3c41c0a..4b77fbf 100644 --- a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk +++ b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk @@ -21,9 +21,10 @@ $(eval $(call gb_CppunitTest_use_external,libreofficekit_tiledrendering,boost_he # our test specifically tests LOK only functionality which would otherwise not # require any normal LO api/libraries. $(eval $(call gb_CppunitTest_use_libraries,libreofficekit_tiledrendering, \ - test \ cppu \ sal \ + tl \ + test \ vcl \ $(gb_UWINAPI) \ )) diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx index 1cc93f7..3fda443 100644 --- a/libreofficekit/qa/unit/tiledrendering.cxx +++ b/libreofficekit/qa/unit/tiledrendering.cxx @@ -16,6 +16,10 @@ #include <string> #include <sal/types.h> +#include <tools/stream.hxx> +#include <vcl/salbtype.hxx> +#include <vcl/bmpacc.hxx> +#include <vcl/pngwrite.hxx> #define LOK_USE_UNSTABLE_API #include <LibreOfficeKit/LibreOfficeKit.hxx> @@ -39,6 +43,23 @@ public: CPPUNIT_TEST_SUITE_END(); }; +// Our dumped .png files end up in +// workdir/CppunitTest/libreofficekit_tiledrendering.test.core + +static void dumpRGBABitmap( const OUString& rPath, const unsigned char* pBuffer, + const int nWidth, const int nHeight ) +{ + Bitmap aBitmap( Size( nWidth, nHeight ), 32 ); + Bitmap::ScopedWriteAccess pWriteAccess( aBitmap ); + memcpy( pWriteAccess->GetBuffer(), pBuffer, 4*nWidth*nHeight ); + + BitmapEx aBitmapEx( aBitmap ); + vcl::PNGWriter aWriter( aBitmapEx ); + SvFileStream sOutput( rPath, STREAM_WRITE ); + aWriter.Write( sOutput ); + sOutput.Close(); +} + void TiledRenderingTest::testOverlay() { const string sSrcRoot = getenv( "SRC_ROOT" ); @@ -73,6 +94,8 @@ void TiledRenderingTest::testOverlay() pDocument->paintTile( pLarge.get(), nTotalWidthPix, nTotalHeightPix, &nRowStride, 0, 0, nTotalWidthDoc, nTotalHeightDoc ); + dumpRGBABitmap( "large.png", pLarge.get(), nTotalWidthPix, nTotalHeightPix ); + scoped_array< unsigned char > pSmall[4]; for ( int i = 0; i < 4; i++ ) { @@ -81,6 +104,8 @@ void TiledRenderingTest::testOverlay() // Tile 0/2: left. Tile 1/3: right. Tile 0/1: top. Tile 2/3: bottom ((i%2 == 0) ? 0 : nTotalWidthDoc / 2), ((i < 2 ) ? 0 : nTotalHeightDoc / 2), nTotalWidthDoc / 2, nTotalHeightDoc / 2); + dumpRGBABitmap( "small_" + OUString::number(i) + ".png", + pSmall[i].get(), nTotalWidthPix/2, nTotalHeightPix/2 ); } // Iterate over each pixel of the sub-tile, and compare that pixel for every _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits