[Libreoffice-commits] core.git: sd/qa sd/source

Pranav Kant pranavk at collabora.co.uk
Sat Mar 17 03:19:22 UTC 2018


 sd/qa/unit/tiledrendering/tiledrendering.cxx |   20 ++++++++++++++++++++
 sd/source/ui/inc/ViewShell.hxx               |    2 ++
 sd/source/ui/unoidl/unomodel.cxx             |   14 ++++++++++++--
 sd/source/ui/view/viewshe2.cxx               |   12 ++++++++++++
 4 files changed, 46 insertions(+), 2 deletions(-)

New commits:
commit 21f56ccbd22ffa347edf931b7ed93c99988fbb8a
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Thu Mar 15 20:09:26 2018 +0530

    sd lok: Set the view size to full page size + fix unit tests
    
    ... such that during insertion of objects when sd calculates the center
    of the view to place the object, it is the center of the whole slide,
    not the center of the default rectangle of 800x600.
    
    It's also important to hide rulers, scrollbars so that correct center is
    calculated; we don't need them anyways in LOK.
    
    Change-Id: I2d1577bc963d324959b272ed3174571ab197d014
    Reviewed-on: https://gerrit.libreoffice.org/51416
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index b0ea2340574a..94f5e1b52e0d 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -339,6 +339,7 @@ xmlDocPtr SdTiledRenderingTest::parseXmlDump()
 
 void SdTiledRenderingTest::testRegisterCallback()
 {
+    comphelper::LibreOfficeKit::setActive();
     SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this);
@@ -354,6 +355,7 @@ void SdTiledRenderingTest::testRegisterCallback()
     CPPUNIT_ASSERT(!m_aInvalidation.IsEmpty());
     ::tools::Rectangle aTopLeft(0, 0, 256*15, 256*15); // 1 px = 15 twips, assuming 96 DPI.
     CPPUNIT_ASSERT(m_aInvalidation.IsOver(aTopLeft));
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testPostKeyEvent()
@@ -423,6 +425,7 @@ void SdTiledRenderingTest::testPostMouseEvent()
 
 void SdTiledRenderingTest::testSetTextSelection()
 {
+    comphelper::LibreOfficeKit::setActive();
     SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
     uno::Reference<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
@@ -447,10 +450,12 @@ void SdTiledRenderingTest::testSetTextSelection()
     pXImpressDocument->setTextSelection(LOK_SETTEXTSELECTION_END, aEnd.getX(), aEnd.getY());
     // The new selection must include the ending dot, too -- but not the first word.
     CPPUNIT_ASSERT_EQUAL(OUString("bbb."), rEditView.GetSelected());
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testGetTextSelection()
 {
+    comphelper::LibreOfficeKit::setActive();
     SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
     uno::Reference<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
@@ -471,10 +476,12 @@ void SdTiledRenderingTest::testGetTextSelection()
 
     // Make sure returned RTF is not empty.
     CPPUNIT_ASSERT(!pXImpressDocument->getTextSelection("text/rtf", aUsedFormat).isEmpty());
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testSetGraphicSelection()
 {
+    comphelper::LibreOfficeKit::setActive();
     SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     SdPage* pPage = pViewShell->GetActualPage();
@@ -504,10 +511,13 @@ void SdTiledRenderingTest::testSetGraphicSelection()
     // Check that a resize happened, but aspect ratio is not kept.
     CPPUNIT_ASSERT_EQUAL(aShapeBefore.getWidth(), aShapeAfter.getWidth());
     CPPUNIT_ASSERT(aShapeBefore.getHeight() < aShapeAfter.getHeight());
+
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testUndoShells()
 {
+    comphelper::LibreOfficeKit::setActive();
     // Load a document and set the page size.
     SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
     uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
@@ -525,10 +535,12 @@ void SdTiledRenderingTest::testUndoShells()
     sal_Int32 nView1 = SfxLokHelper::getView();
     // This was -1, SdUndoGroup did not track what view shell created it.
     CPPUNIT_ASSERT_EQUAL(ViewShellId(nView1), pUndoManager->GetUndoAction()->GetViewShellId());
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testResetSelection()
 {
+    comphelper::LibreOfficeKit::setActive();
     SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
     uno::Reference<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
@@ -549,6 +561,7 @@ void SdTiledRenderingTest::testResetSelection()
     // Now use resetSelection() to reset the selection.
     pXImpressDocument->resetSelection();
     CPPUNIT_ASSERT(!pView->GetTextEditObject());
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 static void lcl_search(const OUString& rKey, bool bFindAll = false)
@@ -662,6 +675,7 @@ void SdTiledRenderingTest::testSearchAllFollowedBySearch()
     // This used to give wrong result: 'search' after 'search all' still
     // returned 'third'
     CPPUNIT_ASSERT_EQUAL(OString("match"), pXImpressDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat));
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testDontSearchInMasterPages()
@@ -1555,6 +1569,7 @@ void SdTiledRenderingTest::testTdf104405()
 
 void SdTiledRenderingTest::testTdf81754()
 {
+    comphelper::LibreOfficeKit::setActive();
     SdXImpressDocument* pXImpressDocument = createDoc("tdf81754.pptx");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     SdPage* pActualPage = pViewShell->GetActualPage();
@@ -1584,6 +1599,7 @@ void SdTiledRenderingTest::testTdf81754()
     CPPUNIT_ASSERT_EQUAL(OUString("Somethingxx"), aEdit.GetText(0));
 
     xDocShRef->DoClose();
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testTdf105502()
@@ -2136,6 +2152,7 @@ void SdTiledRenderingTest::testPasteTextOnSlide()
 
 void SdTiledRenderingTest::testTdf115873()
 {
+    comphelper::LibreOfficeKit::setActive();
     // Initialize the navigator.
     SdXImpressDocument* pXImpressDocument = createDoc("tdf115873.fodp");
     SfxViewShell* pViewShell = SfxViewShell::Current();
@@ -2167,10 +2184,12 @@ void SdTiledRenderingTest::testTdf115873()
     // This failed, single-click did not result in a shape selection (only
     // double-click did).
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rMarkList.GetMarkCount());
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testTdf115873Group()
 {
+    comphelper::LibreOfficeKit::setActive();
     // Initialize the navigator.
     SdXImpressDocument* pXImpressDocument = createDoc("tdf115873-group.fodp");
     SfxViewShell* pViewShell = SfxViewShell::Current();
@@ -2182,6 +2201,7 @@ void SdTiledRenderingTest::testTdf115873Group()
     // This failed, Fill() and IsEqualToDoc() were out of sync for group
     // shapes.
     CPPUNIT_ASSERT(pObjects->IsEqualToDoc(pXImpressDocument->GetDoc()));
+    comphelper::LibreOfficeKit::setActive(false);
 }
 
 void SdTiledRenderingTest::testCutSelectionChange()
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx
index c3219dd4db52..a3d82ba4f0c6 100644
--- a/sd/source/ui/inc/ViewShell.hxx
+++ b/sd/source/ui/inc/ViewShell.hxx
@@ -197,6 +197,8 @@ public:
 
     bool HasRuler() { return mbHasRulers;}
     void SetRuler(bool bRuler);
+    // Hides horizontal, vertical scrollbar as well as scrollbox
+    void SetScrollBarsVisible(bool bVisible);
 
     /** Set internal values of all scroll bars that determine thumb size and
         position.  The external values like size and position of the scroll
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 8c8569a1a009..afe7ede9bde5 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2446,11 +2446,21 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs
         SdOptions* pOptions = SD_MOD()->GetSdOptions(mpDoc->GetDocumentType());
         pOptions->SetShowComments(comphelper::LibreOfficeKit::isTiledAnnotations());
 
-        // Disable map mode, so that it's possible to send mouse event coordinates
-        // in logic units.
+        pViewShell->SetRuler(false);
+        pViewShell->SetScrollBarsVisible(false);
+
         if (sd::Window* pWindow = pViewShell->GetActiveWindow())
         {
+            // get the full page size in pixels
+            pWindow->EnableMapMode();
+            Size aSize(pWindow->LogicToPixel(pDrawView->GetSdrPageView()->GetPage()->GetSize()));
+            // Disable map mode, so that it's possible to send mouse event
+            // coordinates in logic units
             pWindow->EnableMapMode(false);
+
+            // arrange UI elements again with new view size
+            pViewShell->GetParentWindow()->SetSizePixel(aSize);
+            pViewShell->Resize();
         }
 
         // Forces all images to be swapped in synchronously, this
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
index b7fe8861223e..f20469071b72 100644
--- a/sd/source/ui/view/viewshe2.cxx
+++ b/sd/source/ui/view/viewshe2.cxx
@@ -938,6 +938,18 @@ void ViewShell::SetRuler(bool bRuler)
         GetViewShell()->InvalidateBorder();
 }
 
+void ViewShell::SetScrollBarsVisible(bool bVisible)
+{
+    if (mpVerticalScrollBar.get() != nullptr)
+        mpVerticalScrollBar->Show( bVisible );
+
+    if (mpHorizontalScrollBar.get() != nullptr)
+        mpHorizontalScrollBar->Show( bVisible );
+
+    if (mpScrollBarBox.get() != nullptr)
+        mpScrollBarBox->Show(bVisible);
+}
+
 sal_Int8 ViewShell::AcceptDrop (
     const AcceptDropEvent& rEvt,
     DropTargetHelper& rTargetHelper,


More information about the Libreoffice-commits mailing list