diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-07-11 16:21:15 +0200 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-07-12 05:19:15 +0200 |
commit | f9d3dbe549ae87c5799173e52d2d6a684dbfc55a (patch) | |
tree | 346c49647b4bddf4a33e9b808a60d065d9a6436d /sd | |
parent | 01f43039aa083a127b595075837770b2ad38b8b9 (diff) |
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
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 66 |
1 files changed, 56 insertions, 10 deletions
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 74133b895988..f86e9cbbaf89 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,77 @@ 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 = convertTwipToMm100( nTileWidth ); + nTileHeight = convertTwipToMm100( nTileHeight ); + nTilePosX = convertTwipToMm100( nTilePosX ); + nTilePosY = convertTwipToMm100( nTilePosY ); + + 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( convertMm100ToTwip( aSize.getWidth() ), + convertMm100ToTwip( aSize.getHeight() ) ); } |