[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sw/inc sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jan 18 10:56:29 UTC 2019
sw/inc/viewsh.hxx | 5 +++++
sw/qa/extras/tiledrendering/tiledrendering.cxx | 20 ++++++++++++++++++++
sw/source/uibase/ribbar/drawbase.cxx | 23 ++++++++++++++++-------
sw/source/uibase/uno/unotxdoc.cxx | 14 +++++++++-----
4 files changed, 50 insertions(+), 12 deletions(-)
New commits:
commit 099705cb1f8547532e863f97111e0cc34af28611
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Thu Jan 17 14:46:47 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 18 11:56:03 2019 +0100
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/66581
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index df0f28c702ac..6f2f747cabdb 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -183,6 +183,7 @@ protected:
static vcl::DeleteOnDeinit< VclPtr<vcl::Window> > mpCareWindow; ///< 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.
@@ -260,6 +261,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 5a653ba48b47..21c78e9ce24b 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();
@@ -116,6 +117,7 @@ public:
CPPUNIT_TEST(testGetTextSelection);
CPPUNIT_TEST(testSetGraphicSelection);
CPPUNIT_TEST(testResetSelection);
+ CPPUNIT_TEST(testInsertShape);
CPPUNIT_TEST(testSearch);
CPPUNIT_TEST(testSearchViewArea);
CPPUNIT_TEST(testSearchTextFrame);
@@ -453,6 +455,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);
+}
+
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 a32ee16bb905..93ebb733a265 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>
@@ -609,13 +610,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.X() = aDocSz.Width() / 2 + rVisArea.Left();
- if(rVisArea.Height() > aDocSz.Height())
- aStartPos.Y() = 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.X() = aDocSz.Width() / 2 + aVisArea.Left();
+ if (aVisArea.Height() > aDocSz.Height())
+ aCenter.Y() = 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 ff57d4dfd850..358f57a2dc76 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3230,12 +3230,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_*/,
More information about the Libreoffice-commits
mailing list