sw/inc/viewsh.hxx | 5 +++++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 18 ++++++++++++++++++ sw/source/uibase/ribbar/drawbase.cxx | 23 ++++++++++++++++------- sw/source/uibase/uno/unotxdoc.cxx | 14 +++++++++----- 4 files changed, 48 insertions(+), 12 deletions(-)
New commits: commit f6f4d69f8349a97ab301190675645b6ad3c8068c Author: Jan Holesovsky <[email protected]> AuthorDate: Thu Jan 17 14:46:47 2019 +0100 Commit: Jan Holesovsky <[email protected]> CommitDate: Tue Oct 8 16:51:58 2019 +0200 lok sw: When inserting shapes, do that in the middle of the visible area. Instead of in the middle of the entire document, which may be far away. Change-Id: I50a1a5f159b73a3803cd7a549939b73a366e7dc5 Reviewed-on: https://gerrit.libreoffice.org/66584 Tested-by: Jenkins Reviewed-by: Jan Holesovsky <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/80258 Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 66382ecc216c..8488b9482d3f 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -168,6 +168,7 @@ protected: static vcl::DeleteOnDeinit< std::shared_ptr<weld::Window> > mpCareDialog; ///< Avoid this window. SwRect maVisArea; ///< The modern version of VisArea. + tools::Rectangle maLOKVisibleArea;///< The visible area in the LibreOfficeKit client. rtl::Reference<SwDoc> mxDoc; ///< The document; never 0. sal_uInt16 mnStartAction; ///< != 0 if at least one Action is active. @@ -245,6 +246,10 @@ public: const SwRect& VisArea() const; + /// The visible area in the client (set by setClientVisibleArea). + const tools::Rectangle getLOKVisibleArea() const { return maLOKVisibleArea; } + void setLOKVisibleArea(const tools::Rectangle& rArea) { maLOKVisibleArea = rArea; } + // If necessary scroll until passed Rect is situated in visible sector. void MakeVisible( const SwRect & ); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 16373bbf2a67..3a13c1649576 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -67,6 +67,7 @@ public: void testGetTextSelection(); void testSetGraphicSelection(); void testResetSelection(); + void testInsertShape(); void testSearch(); void testSearchViewArea(); void testSearchTextFrame(); @@ -126,6 +127,7 @@ public: CPPUNIT_TEST(testGetTextSelection); CPPUNIT_TEST(testSetGraphicSelection); CPPUNIT_TEST(testResetSelection); + CPPUNIT_TEST(testInsertShape); CPPUNIT_TEST(testSearch); CPPUNIT_TEST(testSearchViewArea); CPPUNIT_TEST(testSearchTextFrame); @@ -487,6 +489,22 @@ void SwTiledRenderingTest::testResetSelection() CPPUNIT_ASSERT(!pWrtShell->IsSelFrameMode()); } +void SwTiledRenderingTest::testInsertShape() +{ + comphelper::LibreOfficeKit::setActive(); + + SwXTextDocument* pXTextDocument = createDoc("2-pages.odt"); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + + pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000)); + comphelper::dispatchCommand(".uno:BasicShapes.circle", uno::Sequence<beans::PropertyValue>()); + + // check that the shape was inserted in the visible area, not outside + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(2736, 868, 7264, 3132), pObject->GetSnapRect()); +} + static void lcl_search(bool bBackward) { uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( diff --git a/sw/source/uibase/ribbar/drawbase.cxx b/sw/source/uibase/ribbar/drawbase.cxx index fdd09bab6dc9..4aa0bdeedd64 100644 --- a/sw/source/uibase/ribbar/drawbase.cxx +++ b/sw/source/uibase/ribbar/drawbase.cxx @@ -18,6 +18,7 @@ */ #include <hintids.hxx> +#include <comphelper/lok.hxx> #include <svx/svdview.hxx> #include <svx/svdobj.hxx> #include <svl/ptitem.hxx> @@ -524,13 +525,21 @@ void SwDrawBase::CreateDefaultObject() Point SwDrawBase::GetDefaultCenterPos() { Size aDocSz(m_pSh->GetDocSize()); - const SwRect& rVisArea = m_pSh->VisArea(); - Point aStartPos = rVisArea.Center(); - if(rVisArea.Width() > aDocSz.Width()) - aStartPos.setX( aDocSz.Width() / 2 + rVisArea.Left() ); - if(rVisArea.Height() > aDocSz.Height()) - aStartPos.setY( aDocSz.Height() / 2 + rVisArea.Top() ); - return aStartPos; + + SwRect aVisArea(m_pSh->VisArea()); + if (comphelper::LibreOfficeKit::isActive()) + { + aVisArea = m_pSh->getLOKVisibleArea(); + aVisArea.Intersection(SwRect(Point(), aDocSz)); + } + + Point aCenter = aVisArea.Center(); + if (aVisArea.Width() > aDocSz.Width()) + aCenter.setX(aDocSz.Width() / 2 + aVisArea.Left()); + if (aVisArea.Height() > aDocSz.Height()) + aCenter.setY(aDocSz.Height() / 2 + aVisArea.Top()); + + return aCenter; } // #i33136# diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index bcecd3d0b05f..b747e52a1f12 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3238,12 +3238,16 @@ bool SwXTextDocument::isMimeTypeSupported() void SwXTextDocument::setClientVisibleArea(const tools::Rectangle& rRectangle) { - SwView* pView = pDocShell->GetView(); - if (!pView) - return; + if (SwView* pView = pDocShell->GetView()) + { + // set the PgUp/PgDown offset + pView->ForcePageUpDownOffset(2 * rRectangle.GetHeight() / 3); + } - // set the PgUp/PgDown offset - pView->ForcePageUpDownOffset(2 * rRectangle.GetHeight() / 3); + if (SwViewShell* pViewShell = pDocShell->GetWrtShell()) + { + pViewShell->setLOKVisibleArea(rRectangle); + } } void SwXTextDocument::setClientZoom(int nTilePixelWidth_, int /*nTilePixelHeight_*/, _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
