summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2019-01-17 14:46:47 +0100
committerJan Holesovsky <kendy@collabora.com>2019-01-18 15:39:05 +0100
commit74b23279c342f2484cdad64b211fb1972644d5a5 (patch)
tree33dafc263ff0ff95fa35cc91a14a320b2f10150a
parenta40f12c3f18e4262336fcd51d26dd099eae1e070 (diff)
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 <kendy@collabora.com>
-rw-r--r--sw/inc/viewsh.hxx5
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx20
-rw-r--r--sw/source/uibase/ribbar/drawbase.cxx23
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx14
4 files changed, 50 insertions, 12 deletions
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 6b9ade855bcc..695347db06c6 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 44489a1494ec..6bd016702026 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -62,6 +62,7 @@ public:
void testGetTextSelection();
void testSetGraphicSelection();
void testResetSelection();
+ void testInsertShape();
void testSearch();
void testSearchViewArea();
void testSearchTextFrame();
@@ -117,6 +118,7 @@ public:
CPPUNIT_TEST(testGetTextSelection);
CPPUNIT_TEST(testSetGraphicSelection);
CPPUNIT_TEST(testResetSelection);
+ CPPUNIT_TEST(testInsertShape);
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchViewArea);
CPPUNIT_TEST(testSearchTextFrame);
@@ -457,6 +459,24 @@ 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());
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
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 49f6e4172c6a..a1324b36422d 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3266,12 +3266,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_*/,