[Libreoffice-commits] core.git: Branch 'feature/calctiledrendering3' - sd/source

Andrzej Hunt andrzej.hunt at collabora.com
Fri Jul 11 07:21:17 PDT 2014


Rebased ref, commits from common ancestor:
commit 9d749da778b98fe76d49300c2c001cbd9fa29941
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Jul 11 16:21:15 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..f86e9cb 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() ) );
 }
 
 


More information about the Libreoffice-commits mailing list