[Libreoffice-commits] core.git: 45 commits - android/Bootstrap android/experimental android/README configure.ac editeng/source include/editeng include/LibreOfficeKit include/tools include/vcl libreofficekit/Executable_gtktiledviewer.mk libreofficekit/qa libreofficekit/source README.Android README.cross sc/source sd/source sfx2/source solenv/bin svx/source sw/qa sw/source tools/source vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Mon Mar 23 01:20:52 PDT 2015
README.Android | 113 -
README.cross | 27
android/Bootstrap/Makefile.shared | 2
android/README | 114 +
android/experimental/LOAndroid3/Makefile | 5
android/experimental/LOAndroid3/src/java/com/polites/android/Animation.java | 28
android/experimental/LOAndroid3/src/java/com/polites/android/Animator.java | 91 -
android/experimental/LOAndroid3/src/java/com/polites/android/FlingAnimation.java | 70
android/experimental/LOAndroid3/src/java/com/polites/android/FlingAnimationListener.java | 24
android/experimental/LOAndroid3/src/java/com/polites/android/FlingListener.java | 40
android/experimental/LOAndroid3/src/java/com/polites/android/GestureImageView.java | 712 ----------
android/experimental/LOAndroid3/src/java/com/polites/android/GestureImageViewListener.java | 26
android/experimental/LOAndroid3/src/java/com/polites/android/GestureImageViewTouchListener.java | 540 -------
android/experimental/LOAndroid3/src/java/com/polites/android/MathUtils.java | 76 -
android/experimental/LOAndroid3/src/java/com/polites/android/MoveAnimation.java | 102 -
android/experimental/LOAndroid3/src/java/com/polites/android/MoveAnimationListener.java | 22
android/experimental/LOAndroid3/src/java/com/polites/android/VectorF.java | 63
android/experimental/LOAndroid3/src/java/com/polites/android/ZoomAnimation.java | 162 --
android/experimental/LOAndroid3/src/java/com/polites/android/ZoomAnimationListener.java | 21
android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartView.java | 10
android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartViewListAdapter.java | 10
android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java | 66
android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java | 13
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitInputConnectionHandler.java | 28
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java | 10
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java | 56
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 102 +
android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java | 7
android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java | 18
android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorLayer.java | 134 -
android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java | 208 --
android/experimental/LOAndroid3/src/java/org/libreoffice/ThumbnailCreator.java | 10
android/experimental/LOAndroid3/src/java/org/libreoffice/TileIdentifier.java | 24
android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java | 35
android/experimental/LOAndroid3/src/java/org/libreoffice/TileProviderFactory.java | 15
android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java | 21
android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java | 75 +
android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java | 67
android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java | 175 ++
android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java | 351 ++++
android/experimental/LOAndroid3/src/java/org/libreoffice/ui/FolderIconView.java | 10
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/OnSlideSwipeListener.java | 8
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/TextSelection.java | 23
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/TextSelectionHandle.java | 3
android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/RenderControllerThread.java | 4
configure.ac | 12
editeng/source/editeng/editview.cxx | 25
editeng/source/editeng/impedit.cxx | 43
include/LibreOfficeKit/LibreOfficeKitGtk.h | 68
include/editeng/editview.hxx | 2
include/tools/gen.hxx | 1
include/vcl/outdev.hxx | 6
libreofficekit/Executable_gtktiledviewer.mk | 4
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 67
libreofficekit/qa/lokdocview_quad/lokdocview_quad.c | 246 ---
libreofficekit/qa/lokdocview_quad/lokdocview_quad.h | 66
libreofficekit/source/gtk/lokdocview.cxx | 564 ++++---
sc/source/ui/inc/gridwin.hxx | 2
sc/source/ui/view/gridwin4.cxx | 39
sd/source/ui/inc/Window.hxx | 2
sd/source/ui/unoidl/unomodel.cxx | 18
sd/source/ui/view/sdwindow.cxx | 40
sd/source/ui/view/viewshe2.cxx | 6
sd/source/ui/view/viewshel.cxx | 6
sfx2/source/appl/appdata.cxx | 2
sfx2/source/appl/appdde.cxx | 2
solenv/bin/native-code.py | 27
svx/source/svdraw/svdhdl.cxx | 16
svx/source/svdraw/svdmrkv.cxx | 3
sw/qa/extras/tiledrendering/data/dummy.fodt | 8
sw/qa/extras/tiledrendering/data/set-text-selection.fodt | 8
sw/qa/extras/tiledrendering/tiledrendering.cxx | 67
sw/source/uibase/docvw/edtwin.cxx | 35
sw/source/uibase/inc/edtwin.hxx | 8
sw/source/uibase/uno/unotxdoc.cxx | 6
tools/source/generic/gen.cxx | 2
vcl/source/window/paint.cxx | 17
77 files changed, 1879 insertions(+), 3260 deletions(-)
New commits:
commit a9fd1afd3b30fc365a92ad98f073fb7ccbdb50da
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Mon Mar 23 17:01:37 2015 +0900
android: reorganize (overlay, canvas packages), move classes
Added new packages:
* overlay - overlay elements like TextCursor*
* canvas - classes that its only purpose is to draw to canvas
Change-Id: I0dec06e76819231dacae26d24e43bb6315bba6e4
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
index 1e8c2d9..359f0ca 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
@@ -5,6 +5,7 @@ import android.graphics.RectF;
import android.net.Uri;
import org.libreoffice.kit.Document;
+import org.libreoffice.overlay.TextCursorLayer;
import org.mozilla.gecko.TextSelection;
import org.mozilla.gecko.TextSelectionHandle;
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 3c57301..c054143 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -8,7 +8,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
-import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
@@ -17,9 +16,8 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ListView;
-import android.widget.RelativeLayout;
-import android.widget.Toast;
+import org.libreoffice.overlay.TextCursorLayer;
import org.mozilla.gecko.TextSelection;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.gfx.GeckoLayerClient;
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementGraphicSelection.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java
similarity index 74%
rename from android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementGraphicSelection.java
rename to android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java
index e4319fc..5adf8d3 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementGraphicSelection.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java
@@ -1,4 +1,12 @@
-package org.libreoffice;
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+package org.libreoffice.canvas;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -9,7 +17,7 @@ import android.graphics.RectF;
* This class is responsible to draw and reposition the selection
* rectangle.
*/
-public class DrawElementGraphicSelection {
+public class GraphicSelectionCanvasElement {
private final Paint mGraphicSelectionPaint;
public RectF mRectangle = new RectF();
public RectF mScaledRectangle = new RectF();
@@ -17,7 +25,7 @@ public class DrawElementGraphicSelection {
private DragType mType = DragType.NONE;
private PointF mStartDragPosition;
- public DrawElementGraphicSelection(Paint graphicSelectionPaint) {
+ public GraphicSelectionCanvasElement(Paint graphicSelectionPaint) {
mGraphicSelectionPaint = graphicSelectionPaint;
}
@@ -58,9 +66,10 @@ public class DrawElementGraphicSelection {
mDrawRectangle = mScaledRectangle;
}
- enum DragType {
+ public enum DragType {
NONE,
MOVE,
EXTEND
}
}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementHandle.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java
similarity index 91%
rename from android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementHandle.java
rename to android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java
index 1912d01..64d369f 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementHandle.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java
@@ -6,7 +6,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-package org.libreoffice;
+package org.libreoffice.canvas;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -14,14 +14,12 @@ import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.RectF;
-import org.mozilla.gecko.gfx.RectUtils;
-
/**
* This class is responsible to draw the selection handles, track the handle
* position and perform a hit test to determine if the selection handle was
* touched.
*/
-public class DrawElementHandle {
+public class GraphicSelectionHandleCanvasElement {
public PointF mPosition = new PointF();
private float mRadius = 20.0f;
private Paint mGraphicHandleFillPaint = new Paint();
@@ -29,7 +27,7 @@ public class DrawElementHandle {
private Paint mGraphicHandleSelectedFillPaint = new Paint();
private RectF mHitRect = new RectF();
- public DrawElementHandle(Paint graphicSelectionPaint) {
+ public GraphicSelectionHandleCanvasElement(Paint graphicSelectionPaint) {
mGraphicSelectionPaint = graphicSelectionPaint;
mGraphicHandleFillPaint.setStyle(Paint.Style.FILL);
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorLayer.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java
similarity index 98%
rename from android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorLayer.java
rename to android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java
index 8c044ed..dc7650b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorLayer.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorLayer.java
@@ -6,13 +6,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-package org.libreoffice;
+package org.libreoffice.overlay;
import android.app.Activity;
import android.graphics.RectF;
import android.util.Log;
-import android.view.View;
+import org.libreoffice.LOKitShell;
+import org.libreoffice.R;
import org.mozilla.gecko.gfx.Layer;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.util.FloatUtils;
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
similarity index 86%
rename from android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java
rename to android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
index 320cffc..d952b80 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
@@ -6,21 +6,22 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-package org.libreoffice;
+package org.libreoffice.overlay;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
-import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
-import android.widget.RelativeLayout;
+import org.libreoffice.LOKitShell;
+import org.libreoffice.canvas.GraphicSelectionCanvasElement;
+import org.libreoffice.canvas.GraphicSelectionHandleCanvasElement;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.gfx.RectUtils;
@@ -50,7 +51,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
private Paint mGraphicSelectionPaint = new Paint();
- private DrawElementGraphicSelection mGraphicSelection;
+ private GraphicSelectionCanvasElement mGraphicSelection;
private PointF mTouchStart = new PointF();
private PointF mDeltaPoint = new PointF();
@@ -60,8 +61,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
private LayerView mLayerView;
- private DrawElementHandle mHandles[] = new DrawElementHandle[8];
- private DrawElementHandle mDragHandle = null;
+ private GraphicSelectionHandleCanvasElement mHandles[] = new GraphicSelectionHandleCanvasElement[8];
+ private GraphicSelectionHandleCanvasElement mDragHandle = null;
public TextCursorView(Context context) {
super(context);
@@ -97,18 +98,18 @@ public class TextCursorView extends View implements View.OnTouchListener {
mGraphicSelectionPaint.setColor(Color.BLACK);
mGraphicSelectionPaint.setStrokeWidth(2);
- mGraphicSelection = new DrawElementGraphicSelection(mGraphicSelectionPaint);
+ mGraphicSelection = new GraphicSelectionCanvasElement(mGraphicSelectionPaint);
mGraphicSelectionVisible = false;
- mHandles[0] = new DrawElementHandle(mGraphicSelectionPaint);
- mHandles[1] = new DrawElementHandle(mGraphicSelectionPaint);
- mHandles[2] = new DrawElementHandle(mGraphicSelectionPaint);
- mHandles[3] = new DrawElementHandle(mGraphicSelectionPaint);
- mHandles[4] = new DrawElementHandle(mGraphicSelectionPaint);
- mHandles[5] = new DrawElementHandle(mGraphicSelectionPaint);
- mHandles[6] = new DrawElementHandle(mGraphicSelectionPaint);
- mHandles[7] = new DrawElementHandle(mGraphicSelectionPaint);
+ mHandles[0] = new GraphicSelectionHandleCanvasElement(mGraphicSelectionPaint);
+ mHandles[1] = new GraphicSelectionHandleCanvasElement(mGraphicSelectionPaint);
+ mHandles[2] = new GraphicSelectionHandleCanvasElement(mGraphicSelectionPaint);
+ mHandles[3] = new GraphicSelectionHandleCanvasElement(mGraphicSelectionPaint);
+ mHandles[4] = new GraphicSelectionHandleCanvasElement(mGraphicSelectionPaint);
+ mHandles[5] = new GraphicSelectionHandleCanvasElement(mGraphicSelectionPaint);
+ mHandles[6] = new GraphicSelectionHandleCanvasElement(mGraphicSelectionPaint);
+ mHandles[7] = new GraphicSelectionHandleCanvasElement(mGraphicSelectionPaint);
postDelayed(cursorAnimation, CURSOR_BLINK_TIME);
@@ -201,7 +202,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
mGraphicSelection.draw(canvas);
if (mGraphicSelectionMove) {
- for (DrawElementHandle handle : mHandles) {
+ for (GraphicSelectionHandleCanvasElement handle : mHandles) {
if (mDragHandle == handle) {
handle.drawSelected(canvas);
} else {
@@ -209,7 +210,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
}
}
} else {
- for (DrawElementHandle handle : mHandles) {
+ for (GraphicSelectionHandleCanvasElement handle : mHandles) {
handle.draw(canvas);
}
}
@@ -296,11 +297,11 @@ public class TextCursorView extends View implements View.OnTouchListener {
private boolean checkIfGraphicSelectionWasHit() {
// Check if handle was hit
mDragHandle = null;
- for (DrawElementHandle handle : mHandles) {
+ for (GraphicSelectionHandleCanvasElement handle : mHandles) {
if (handle.contains(mTouchStart.x, mTouchStart.y)) {
mDragHandle = handle;
mGraphicSelectionMove = true;
- mGraphicSelection.dragStart(DrawElementGraphicSelection.DragType.EXTEND, mTouchStart);
+ mGraphicSelection.dragStart(GraphicSelectionCanvasElement.DragType.EXTEND, mTouchStart);
sendGraphicSelectionStart(handle.mPosition);
return true;
}
@@ -308,7 +309,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
// Check if inside graphic selection was hit
if (mGraphicSelection.contains(mTouchStart.x, mTouchStart.y)) {
mGraphicSelectionMove = true;
- mGraphicSelection.dragStart(DrawElementGraphicSelection.DragType.MOVE, mTouchStart);
+ mGraphicSelection.dragStart(GraphicSelectionCanvasElement.DragType.MOVE, mTouchStart);
sendGraphicSelectionStart(mTouchStart);
return true;
}
commit 205b69526c1a8d79da08929b1832ffb5de6c61b2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Mon Mar 23 16:51:47 2015 +0900
android: extract drawing of selection into its own class
Change-Id: I8e94edeafbf5b7fd5f02a1429893c4b803c71afa
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementGraphicSelection.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementGraphicSelection.java
new file mode 100644
index 0000000..e4319fc
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementGraphicSelection.java
@@ -0,0 +1,66 @@
+package org.libreoffice;
+
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.PointF;
+import android.graphics.RectF;
+
+/**
+ * This class is responsible to draw and reposition the selection
+ * rectangle.
+ */
+public class DrawElementGraphicSelection {
+ private final Paint mGraphicSelectionPaint;
+ public RectF mRectangle = new RectF();
+ public RectF mScaledRectangle = new RectF();
+ private RectF mDrawRectangle = new RectF();
+ private DragType mType = DragType.NONE;
+ private PointF mStartDragPosition;
+
+ public DrawElementGraphicSelection(Paint graphicSelectionPaint) {
+ mGraphicSelectionPaint = graphicSelectionPaint;
+ }
+
+ public void reposition(RectF scaledRectangle) {
+ mScaledRectangle = scaledRectangle;
+ mDrawRectangle = scaledRectangle;
+ }
+
+ public boolean contains(float x, float y) {
+ return mScaledRectangle.contains(x, y);
+ }
+
+ public void draw(Canvas canvas) {
+ canvas.drawRect(mDrawRectangle, mGraphicSelectionPaint);
+ }
+
+ public void dragStart(DragType type, PointF position) {
+ mType = type;
+ mStartDragPosition = position;
+ }
+
+ public void dragging(PointF position) {
+ if (mType == DragType.MOVE) {
+
+ float deltaX = position.x - mStartDragPosition.x;
+ float deltaY = position.y - mStartDragPosition.y;
+
+ mDrawRectangle = new RectF(mScaledRectangle);
+ mDrawRectangle.offset(deltaX, deltaY);
+ } else if (mType == DragType.EXTEND) {
+ mDrawRectangle = new RectF(mScaledRectangle);
+ mDrawRectangle.union(position.x, position.y);
+ }
+ }
+
+ public void dragEnd() {
+ mType = DragType.NONE;
+ mDrawRectangle = mScaledRectangle;
+ }
+
+ enum DragType {
+ NONE,
+ MOVE,
+ EXTEND
+ }
+}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java
index 26eb215..320cffc 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java
@@ -48,14 +48,16 @@ public class TextCursorView extends View implements View.OnTouchListener {
private Paint mSelectionPaint = new Paint();
private boolean mSelectionsVisible;
- private RectF mGraphicSelection = new RectF();
- private RectF mGraphicScaledSelection = new RectF();
private Paint mGraphicSelectionPaint = new Paint();
- private boolean mGraphicSelectionVisible;
+ private DrawElementGraphicSelection mGraphicSelection;
+
private PointF mTouchStart = new PointF();
private PointF mDeltaPoint = new PointF();
+
+ private boolean mGraphicSelectionVisible;
private boolean mGraphicSelectionMove = false;
+
private LayerView mLayerView;
private DrawElementHandle mHandles[] = new DrawElementHandle[8];
@@ -94,6 +96,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
mGraphicSelectionPaint.setStyle(Paint.Style.STROKE);
mGraphicSelectionPaint.setColor(Color.BLACK);
mGraphicSelectionPaint.setStrokeWidth(2);
+
+ mGraphicSelection = new DrawElementGraphicSelection(mGraphicSelectionPaint);
+
mGraphicSelectionVisible = false;
mHandles[0] = new DrawElementHandle(mGraphicSelectionPaint);
@@ -144,39 +149,43 @@ public class TextCursorView extends View implements View.OnTouchListener {
return;
}
- mGraphicSelection = rectangle;
+ mGraphicSelection.mRectangle = rectangle;
ImmutableViewportMetrics metrics = layerView.getViewportMetrics();
repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor);
}
public void repositionWithViewport(float x, float y, float zoom) {
- mCursorScaledPosition = RectUtils.scale(mCursorPosition, zoom);
- mCursorScaledPosition.offset(-x, -y);
+ mCursorScaledPosition = convertPosition(mCursorPosition, x, y, zoom);
mCursorScaledPosition.right = mCursorScaledPosition.left + CURSOR_WIDTH;
mScaledSelections.clear();
for (RectF selection : mSelections) {
- RectF scaledSelection = RectUtils.scale(selection, zoom);
- scaledSelection.offset(-x, -y);
+ RectF scaledSelection = convertPosition(selection, x, y, zoom);
mScaledSelections.add(scaledSelection);
}
- mGraphicScaledSelection = RectUtils.scale(mGraphicSelection, zoom);
- mGraphicScaledSelection.offset(-x, -y);
+ RectF scaledGraphicSelection = convertPosition(mGraphicSelection.mRectangle, x, y, zoom);
+ mGraphicSelection.reposition(scaledGraphicSelection);
- mHandles[0].reposition(mGraphicScaledSelection.left, mGraphicScaledSelection.top);
- mHandles[1].reposition(mGraphicScaledSelection.centerX(), mGraphicScaledSelection.top);
- mHandles[2].reposition(mGraphicScaledSelection.right, mGraphicScaledSelection.top);
- mHandles[3].reposition(mGraphicScaledSelection.left, mGraphicScaledSelection.centerY());
- mHandles[4].reposition(mGraphicScaledSelection.right, mGraphicScaledSelection.centerY());
- mHandles[5].reposition(mGraphicScaledSelection.left, mGraphicScaledSelection.bottom);
- mHandles[6].reposition(mGraphicScaledSelection.centerX(), mGraphicScaledSelection.bottom);
- mHandles[7].reposition(mGraphicScaledSelection.right, mGraphicScaledSelection.bottom);
+ mHandles[0].reposition(scaledGraphicSelection.left, scaledGraphicSelection.top);
+ mHandles[1].reposition(scaledGraphicSelection.centerX(), scaledGraphicSelection.top);
+ mHandles[2].reposition(scaledGraphicSelection.right, scaledGraphicSelection.top);
+ mHandles[3].reposition(scaledGraphicSelection.left, scaledGraphicSelection.centerY());
+ mHandles[4].reposition(scaledGraphicSelection.right, scaledGraphicSelection.centerY());
+ mHandles[5].reposition(scaledGraphicSelection.left, scaledGraphicSelection.bottom);
+ mHandles[6].reposition(scaledGraphicSelection.centerX(), scaledGraphicSelection.bottom);
+ mHandles[7].reposition(scaledGraphicSelection.right, scaledGraphicSelection.bottom);
invalidate();
}
+ private RectF convertPosition(RectF cursorPosition, float x, float y, float zoom) {
+ RectF cursor = RectUtils.scale(cursorPosition, zoom);
+ cursor.offset(-x, -y);
+ return cursor;
+ }
+
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
@@ -189,6 +198,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
}
}
if (mGraphicSelectionVisible) {
+ mGraphicSelection.draw(canvas);
+
if (mGraphicSelectionMove) {
for (DrawElementHandle handle : mHandles) {
if (mDragHandle == handle) {
@@ -197,20 +208,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
handle.draw(canvas);
}
}
-
- RectF selectionRect = new RectF(mGraphicScaledSelection);
- if (mDragHandle != null) {
- PointF dragPosition = new PointF(mDragHandle.mPosition.x, mDragHandle.mPosition.y);
- dragPosition.offset(mDeltaPoint.x, mDeltaPoint.y);
- selectionRect.union(dragPosition.x, dragPosition.y);
- canvas.drawRect(selectionRect, mGraphicSelectionPaint);
- } else {
- selectionRect.offset(mDeltaPoint.x, mDeltaPoint.y);
- canvas.drawRect(selectionRect, mGraphicSelectionPaint);
- }
} else {
- canvas.drawRect(mGraphicScaledSelection, mGraphicSelectionPaint);
-
for (DrawElementHandle handle : mHandles) {
handle.draw(canvas);
}
@@ -286,6 +284,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
if (mGraphicSelectionVisible && mGraphicSelectionMove) {
mDeltaPoint.x = event.getX() - mTouchStart.x;
mDeltaPoint.y = event.getY() - mTouchStart.y;
+ mGraphicSelection.dragging(new PointF(event.getX(), event.getY()));
invalidate();
return true;
}
@@ -301,13 +300,15 @@ public class TextCursorView extends View implements View.OnTouchListener {
if (handle.contains(mTouchStart.x, mTouchStart.y)) {
mDragHandle = handle;
mGraphicSelectionMove = true;
+ mGraphicSelection.dragStart(DrawElementGraphicSelection.DragType.EXTEND, mTouchStart);
sendGraphicSelectionStart(handle.mPosition);
return true;
}
}
// Check if inside graphic selection was hit
- if (mGraphicScaledSelection.contains(mTouchStart.x, mTouchStart.y)) {
+ if (mGraphicSelection.contains(mTouchStart.x, mTouchStart.y)) {
mGraphicSelectionMove = true;
+ mGraphicSelection.dragStart(DrawElementGraphicSelection.DragType.MOVE, mTouchStart);
sendGraphicSelectionStart(mTouchStart);
return true;
}
@@ -316,6 +317,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
private boolean stopGraphicSelection() {
mGraphicSelectionMove = false;
+
PointF point = new PointF();
if (mDragHandle != null) {
point.x = mDragHandle.mPosition.x;
@@ -326,6 +328,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
}
point.offset(mDeltaPoint.x, mDeltaPoint.y);
sendGraphicSelectionEnd(point);
+
+ mGraphicSelection.dragEnd();
invalidate();
return true;
}
commit 19c59a34eb2c106ded992a0152cd9bbe8c9b70cb
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Mon Mar 23 16:06:38 2015 +0900
android: remove import android.util.Log from InvalidationHandler
Change-Id: Ie944ca77abf13c4ac2c3b9c492d56878bfffba55
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
index 805ed9c..1e8c2d9 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
@@ -3,7 +3,6 @@ package org.libreoffice;
import android.content.Intent;
import android.graphics.RectF;
import android.net.Uri;
-import android.util.Log;
import org.libreoffice.kit.Document;
import org.mozilla.gecko.TextSelection;
commit 7b8a59807806dbf6ec759a836c873b435e09e907
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Mar 20 17:35:17 2015 +0100
sd: when tiled rendering, disable map mode early
This brings sd in sync with sw, that does the same for some time
already. With this, we no longer do a complete repaint 6 times after
every postMouseEvent().
Change-Id: I38754f4bdbb977abbdbb0f32e1460ab2f6290f87
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 574cfd4..7593b80 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -922,7 +922,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
Rectangle aRect(rPos.getX(), rPos.getY(), rPos.getX() + GetCursor()->GetWidth(), rPos.getY() + GetCursor()->GetHeight());
// LOK output is always in twips, convert from mm100 if necessary.
- if (pOutWin->IsMapModeEnabled() && pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM)
+ if (pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM)
aRect = OutputDevice::LogicToLogic(aRect, MAP_100TH_MM, MAP_TWIP);
// Let the LOK client decide the cursor width.
aRect.setWidth(0);
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 2070791..ac41220 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -90,6 +90,7 @@
#include "ClientView.hxx"
#include "DrawViewShell.hxx"
#include "ViewShell.hxx"
+#include "Window.hxx"
#include "app.hrc"
#include <vcl/pdfextoutdevdata.hxx>
#include <com/sun/star/presentation/AnimationEffect.hpp>
@@ -2359,6 +2360,16 @@ void SdXImpressDocument::initializeForTiledRendering()
mpDocShell->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_VIEWSHELL0, SfxCallMode::SYNCHRON | SfxCallMode::RECORD);
mpDoc->setTiledRendering(true);
+
+ // Disable map mode, so that it's possible to send mouse event coordinates
+ // in logic units.
+ if (DrawViewShell* pViewShell = GetViewShell())
+ {
+ if (sd::Window* pWindow = pViewShell->GetActiveWindow())
+ {
+ pWindow->EnableMapMode(false);
+ }
+ }
}
void SdXImpressDocument::registerCallback(LibreOfficeKitCallback pCallback, void* pData)
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index 20e3086..1268596 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -324,10 +324,13 @@ long Window::SetZoomFactor(long nZoom)
nZoom = mnMinZoom;
// Set the zoom factor at the window's map mode.
- MapMode aMap(GetMapMode());
- aMap.SetScaleX(Fraction(nZoom, 100));
- aMap.SetScaleY(Fraction(nZoom, 100));
- SetMapMode(aMap);
+ if (!mpViewShell || !mpViewShell->GetDoc()->isTiledRendering())
+ {
+ MapMode aMap(GetMapMode());
+ aMap.SetScaleX(Fraction(nZoom, 100));
+ aMap.SetScaleY(Fraction(nZoom, 100));
+ SetMapMode(aMap);
+ }
// invalidate previous size - it was relative to the old scaling
maPrevSize = Size(-1,-1);
@@ -559,7 +562,8 @@ void Window::UpdateMapOrigin(bool bInvalidate)
maPrevSize = aWinSize;
- if (bChanged && bInvalidate)
+ // When tiled rendering, the above UpdateMapMode() call doesn't touch the map mode.
+ if (bChanged && bInvalidate && (!mpViewShell || !mpViewShell->GetDoc()->isTiledRendering()))
Invalidate();
}
@@ -599,9 +603,12 @@ void Window::UpdateMapMode (void)
Point aNewOrigin (-maWinPos.X(), -maWinPos.Y());
maWinPos += maViewOrigin;
- MapMode aMap(GetMapMode());
- aMap.SetOrigin(aNewOrigin);
- SetMapMode(aMap);
+ if (!mpViewShell || !mpViewShell->GetDoc()->isTiledRendering())
+ {
+ MapMode aMap(GetMapMode());
+ aMap.SetOrigin(aNewOrigin);
+ SetMapMode(aMap);
+ }
}
/**
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
index 71d26c5..f6d25df 100644
--- a/sd/source/ui/view/viewshe2.cxx
+++ b/sd/source/ui/view/viewshe2.cxx
@@ -392,8 +392,10 @@ void ViewShell::SetZoomRect(const Rectangle& rZoomRect)
mpContentWindow->SetWinViewPos(aNewPos);
mpContentWindow->UpdateMapOrigin();
- // #i74769# see above
- mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
+ // When tiled rendering, UpdateMapOrigin() doesn't touch the map mode.
+ if (!GetDoc()->isTiledRendering())
+ // #i74769# see above
+ mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
}
Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index 1fe42c7..ce01af2 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -510,15 +510,12 @@ void ViewShell::LogicMouseButtonDown(const MouseEvent& rMouseEvent)
// When we're not doing tiled rendering, then positions must be passed as pixels.
assert(GetDoc()->isTiledRendering());
- bool bMap = mpActiveWindow->IsMapModeEnabled();
- mpActiveWindow->EnableMapMode(false);
Point aPoint = mpActiveWindow->GetPointerPosPixel();
mpActiveWindow->SetLastMousePos(rMouseEvent.GetPosPixel());
MouseButtonDown(rMouseEvent, 0);
mpActiveWindow->SetPointerPosPixel(aPoint);
- mpActiveWindow->EnableMapMode(bMap);
}
void ViewShell::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
@@ -526,15 +523,12 @@ void ViewShell::LogicMouseButtonUp(const MouseEvent& rMouseEvent)
// When we're not doing tiled rendering, then positions must be passed as pixels.
assert(GetDoc()->isTiledRendering());
- bool bMap = mpActiveWindow->IsMapModeEnabled();
- mpActiveWindow->EnableMapMode(false);
Point aPoint = mpActiveWindow->GetPointerPosPixel();
mpActiveWindow->SetPointerPosPixel(rMouseEvent.GetPosPixel());
MouseButtonUp(rMouseEvent, 0);
mpActiveWindow->SetPointerPosPixel(aPoint);
- mpActiveWindow->EnableMapMode(bMap);
}
void ViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
commit 35cf00e20ad5826f715f5d5bbc48d486228774ca
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Mar 20 15:48:04 2015 +0100
OutputDevice::LogicInvalidate: take a Rectangle
At the end this gets exported in the LOK API as a rectangle anyway, so
better to convert the vcl::Regions into a Rectangle, and not the other
way around.
Change-Id: I81fede6e30af112d17bb74328801915d90474863
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 30c8c83..c3adbbf 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1732,11 +1732,11 @@ public:
protected:
/**
- * Notification about some region of the output device got invalidated.
+ * Notification about some rectangle of the output device got invalidated.
*
- * @param pRegion If 0, that means the whole area, otherwise the area in logic coordinates.
+ * @param pRectangle If 0, that means the whole area, otherwise the area in logic coordinates.
*/
- virtual void LogicInvalidate(const vcl::Region* /*pRegion*/) { }
+ virtual void LogicInvalidate(const Rectangle* /*pRectangle*/) { }
private:
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index ac158bf..36a7e5c 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -322,7 +322,7 @@ public:
long nTileWidth, long nTileHeight );
/// @see OutputDevice::LogicInvalidate().
- void LogicInvalidate(const ::vcl::Region* pRegion) SAL_OVERRIDE;
+ void LogicInvalidate(const Rectangle* pRectangle) SAL_OVERRIDE;
/// Same as MouseButtonDown(), but coordinates are in logic unit.
void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index cf72fc3..cdef76d 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -978,13 +978,13 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
pSdrPageView->RemovePaintWindowFromPageView(aTemporaryPaintWindow);
}
-void ScGridWindow::LogicInvalidate(const ::vcl::Region* pRegion)
+void ScGridWindow::LogicInvalidate(const Rectangle* pRectangle)
{
OString sRectangle;
- if (!pRegion)
+ if (!pRectangle)
sRectangle = "EMPTY";
else
- sRectangle = pRegion->GetBoundRect().toString();
+ sRectangle = pRectangle->toString();
pViewData->GetDocument()->GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
diff --git a/sd/source/ui/inc/Window.hxx b/sd/source/ui/inc/Window.hxx
index 9055037..be2bb1a 100644
--- a/sd/source/ui/inc/Window.hxx
+++ b/sd/source/ui/inc/Window.hxx
@@ -193,7 +193,7 @@ protected:
OUString GetSurroundingText() const SAL_OVERRIDE;
Selection GetSurroundingTextSelection() const SAL_OVERRIDE;
/// @see OutputDevice::LogicInvalidate().
- void LogicInvalidate(const ::vcl::Region* pRegion) SAL_OVERRIDE;
+ void LogicInvalidate(const Rectangle* pRectangle) SAL_OVERRIDE;
};
} // end of namespace sd
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index 727eca9..20e3086 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -990,13 +990,13 @@ Selection Window::GetSurroundingTextSelection() const
}
}
-void Window::LogicInvalidate(const ::vcl::Region* pRegion)
+void Window::LogicInvalidate(const Rectangle* pRectangle)
{
OString sRectangle;
- if (!pRegion)
+ if (!pRectangle)
sRectangle = "EMPTY";
else
- sRectangle = pRegion->GetBoundRect().toString();
+ sRectangle = pRectangle->toString();
mpViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index ca5f9e9..6356b98 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6248,13 +6248,13 @@ Selection SwEditWin::GetSurroundingTextSelection() const
}
}
-void SwEditWin::LogicInvalidate(const vcl::Region* pRegion)
+void SwEditWin::LogicInvalidate(const Rectangle* pRectangle)
{
OString sRectangle;
- if (!pRegion)
+ if (!pRectangle)
sRectangle = "EMPTY";
else
- sRectangle = pRegion->GetBoundRect().toString();
+ sRectangle = pRectangle->toString();
m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index b89b049..b9d00f9 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -296,12 +296,8 @@ public:
SwEditWin(vcl::Window *pParent, SwView &);
virtual ~SwEditWin();
- /**
- * Notification about some region of the output device got invalidated.
- *
- * @param pRegion If 0, that means the whole area, otherwise the area in logic coordinates.
- */
- void LogicInvalidate(const vcl::Region* pRegion) SAL_OVERRIDE;
+ /// @see OutputDevice::LogicInvalidate().
+ void LogicInvalidate(const Rectangle* pRectangle) SAL_OVERRIDE;
/// Same as MouseButtonDown(), but coordinates are in logic unit.
void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
/// Same as MouseButtonUp(), but coordinates are in logic unit.
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 7180d79..480f389 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -859,18 +859,11 @@ void Window::Invalidate( sal_uInt16 nFlags )
LogicInvalidate(0);
}
-/// Converts rRegion from MM100 to twips based on the map mode of rWindow.
-void lcl_toTwips(Window& rWindow, vcl::Region& rRegion)
+/// Converts rRectangle from MM100 to twips based on the map mode of rWindow.
+void lcl_toTwips(const Window& rWindow, Rectangle& rRectangle)
{
if (rWindow.IsMapModeEnabled() && rWindow.GetMapMode().GetMapUnit() == MAP_100TH_MM)
- {
- Rectangle aRectangle = rRegion.GetBoundRect();
- aRectangle.Left() = convertMm100ToTwip(aRectangle.Left());
- aRectangle.Top() = convertMm100ToTwip(aRectangle.Top());
- aRectangle.Right() = convertMm100ToTwip(aRectangle.Right());
- aRectangle.Bottom() = convertMm100ToTwip(aRectangle.Bottom());
- rRegion = aRectangle;
- }
+ rRectangle = OutputDevice::LogicToLogic(rRectangle, MAP_100TH_MM, MAP_TWIP);
}
void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
@@ -885,9 +878,9 @@ void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
{
vcl::Region aRegion( aRect );
ImplInvalidate( &aRegion, nFlags );
- vcl::Region aLogicRegion(rRect);
- lcl_toTwips(*this, aLogicRegion);
- LogicInvalidate(&aLogicRegion);
+ Rectangle aLogicRectangle(rRect);
+ lcl_toTwips(*this, aLogicRectangle);
+ LogicInvalidate(&aLogicRectangle);
}
}
@@ -908,9 +901,9 @@ void Window::Invalidate( const vcl::Region& rRegion, sal_uInt16 nFlags )
if ( !aRegion.IsEmpty() )
{
ImplInvalidate( &aRegion, nFlags );
- vcl::Region aLogicRegion(rRegion);
- lcl_toTwips(*this, aLogicRegion);
- LogicInvalidate(&aLogicRegion);
+ Rectangle aLogicRectangle = rRegion.GetBoundRect();
+ lcl_toTwips(*this, aLogicRectangle);
+ LogicInvalidate(&aLogicRectangle);
}
}
}
commit 97ea96fed5a189e59982f97f57119938448296e2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Mar 20 14:12:57 2015 +0100
ImpEditView::ShowCursor: don't assume map mode is twips
This makes the blinking cursor appear at the expected position in
Impress when editing shape text.
Change-Id: I71ad9d10f40f1ae290dc235ae26072955af84a2d
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 8435e0d..574cfd4 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -920,6 +920,13 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
{
const Point& rPos = GetCursor()->GetPos();
Rectangle aRect(rPos.getX(), rPos.getY(), rPos.getX() + GetCursor()->GetWidth(), rPos.getY() + GetCursor()->GetHeight());
+
+ // LOK output is always in twips, convert from mm100 if necessary.
+ if (pOutWin->IsMapModeEnabled() && pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM)
+ aRect = OutputDevice::LogicToLogic(aRect, MAP_100TH_MM, MAP_TWIP);
+ // Let the LOK client decide the cursor width.
+ aRect.setWidth(0);
+
OString sRect = aRect.toString();
libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
}
commit f9c9f57e6901ce6a55a153962d0852324d9cadcf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Mar 20 12:37:26 2015 +0100
OutputDevice::LogicInvalidate: clean up sc/sd duplication
Writer is not affected, as there the map mode is disabled and everything
is in twips internally.
Change-Id: I3b5289f82e89be5943a0b14a5167b33132cf78d0
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 630a0c8..cf72fc3 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -984,18 +984,7 @@ void ScGridWindow::LogicInvalidate(const ::vcl::Region* pRegion)
if (!pRegion)
sRectangle = "EMPTY";
else
- {
- Rectangle aRectangle = pRegion->GetBoundRect();
- if (GetMapMode().GetMapUnit() == MAP_100TH_MM)
- {
- // Conversion to twips is necessary.
- aRectangle.Left() = convertMm100ToTwip(aRectangle.Left());
- aRectangle.Top() = convertMm100ToTwip(aRectangle.Top());
- aRectangle.Right() = convertMm100ToTwip(aRectangle.Right());
- aRectangle.Bottom() = convertMm100ToTwip(aRectangle.Bottom());
- }
- sRectangle = aRectangle.toString();
- }
+ sRectangle = pRegion->GetBoundRect().toString();
pViewData->GetDocument()->GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index 8a79750..727eca9 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -996,18 +996,7 @@ void Window::LogicInvalidate(const ::vcl::Region* pRegion)
if (!pRegion)
sRectangle = "EMPTY";
else
- {
- Rectangle aRectangle = pRegion->GetBoundRect();
- if (GetMapMode().GetMapUnit() == MAP_100TH_MM)
- {
- // Conversion to twips is necessary.
- aRectangle.Left() = convertMm100ToTwip(aRectangle.Left());
- aRectangle.Top() = convertMm100ToTwip(aRectangle.Top());
- aRectangle.Right() = convertMm100ToTwip(aRectangle.Right());
- aRectangle.Bottom() = convertMm100ToTwip(aRectangle.Bottom());
- }
- sRectangle = aRectangle.toString();
- }
+ sRectangle = pRegion->GetBoundRect().toString();
mpViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 4d47dec..7180d79 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -859,6 +859,20 @@ void Window::Invalidate( sal_uInt16 nFlags )
LogicInvalidate(0);
}
+/// Converts rRegion from MM100 to twips based on the map mode of rWindow.
+void lcl_toTwips(Window& rWindow, vcl::Region& rRegion)
+{
+ if (rWindow.IsMapModeEnabled() && rWindow.GetMapMode().GetMapUnit() == MAP_100TH_MM)
+ {
+ Rectangle aRectangle = rRegion.GetBoundRect();
+ aRectangle.Left() = convertMm100ToTwip(aRectangle.Left());
+ aRectangle.Top() = convertMm100ToTwip(aRectangle.Top());
+ aRectangle.Right() = convertMm100ToTwip(aRectangle.Right());
+ aRectangle.Bottom() = convertMm100ToTwip(aRectangle.Bottom());
+ rRegion = aRectangle;
+ }
+}
+
void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
{
@@ -872,6 +886,7 @@ void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
vcl::Region aRegion( aRect );
ImplInvalidate( &aRegion, nFlags );
vcl::Region aLogicRegion(rRect);
+ lcl_toTwips(*this, aLogicRegion);
LogicInvalidate(&aLogicRegion);
}
}
@@ -894,6 +909,7 @@ void Window::Invalidate( const vcl::Region& rRegion, sal_uInt16 nFlags )
{
ImplInvalidate( &aRegion, nFlags );
vcl::Region aLogicRegion(rRegion);
+ lcl_toTwips(*this, aLogicRegion);
LogicInvalidate(&aLogicRegion);
}
}
commit 355f1199fdd552cfd4fa167b345f37649ae76d80
Author: Henry Castro <hcastro at collabora.com>
Date: Fri Mar 20 12:22:09 2015 +0100
sc tiled rendering: add missing mm100 -> twips conversion
Change-Id: Id0b1d88d0852e9333538ca9cecf4605c06440494
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 6324933..630a0c8 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -984,7 +984,19 @@ void ScGridWindow::LogicInvalidate(const ::vcl::Region* pRegion)
if (!pRegion)
sRectangle = "EMPTY";
else
- sRectangle = pRegion->GetBoundRect().toString();
+ {
+ Rectangle aRectangle = pRegion->GetBoundRect();
+ if (GetMapMode().GetMapUnit() == MAP_100TH_MM)
+ {
+ // Conversion to twips is necessary.
+ aRectangle.Left() = convertMm100ToTwip(aRectangle.Left());
+ aRectangle.Top() = convertMm100ToTwip(aRectangle.Top());
+ aRectangle.Right() = convertMm100ToTwip(aRectangle.Right());
+ aRectangle.Bottom() = convertMm100ToTwip(aRectangle.Bottom());
+ }
+ sRectangle = aRectangle.toString();
+ }
+
pViewData->GetDocument()->GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
commit 2730944192b84c8c0fc384c773f867e765790b58
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Mar 20 10:16:07 2015 +0100
lokdocview: add lok_docview_get_document()
And move private data out of LibreOfficeKitGtk.h, so that clients are
forced to use the getter/setter functions.
Change-Id: I6565312b5ec5a8e882c3763164ff5aa81ed9720c
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index f088f49..1a5b932 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -30,68 +30,8 @@ typedef struct _LOKDocViewClass LOKDocViewClass;
struct _LOKDocView
{
- GtkScrolledWindow scrollWindow;
-
- GtkWidget* pEventBox;
- GtkWidget* pTable;
- GtkWidget** pCanvas;
-
- float fZoom;
-
- LibreOfficeKit* pOffice;
- LibreOfficeKitDocument* pDocument;
- /// View or edit mode.
- gboolean m_bEdit;
- /// Position and size of the visible cursor.
- GdkRectangle m_aVisibleCursor;
- /// Cursor overlay is visible or hidden (for blinking).
- gboolean m_bCursorOverlayVisible;
- /// Cursor is visible or hidden (e.g. for graphic selection).
- gboolean m_bCursorVisible;
- /// Time of the last button press.
- guint32 m_nLastButtonPressTime;
- /// Time of the last button release.
- guint32 m_nLastButtonReleaseTime;
- /// Rectangles of the current text selection.
- GList* m_pTextSelectionRectangles;
- /// Position and size of the selection start (as if there would be a cursor caret there).
- GdkRectangle m_aTextSelectionStart;
- /// Position and size of the selection end.
- GdkRectangle m_aTextSelectionEnd;
- GdkRectangle m_aGraphicSelection;
- gboolean m_bInDragGraphicSelection;
-
- /// @name Start/middle/end handle.
- ///@{
- /// Bitmap of the text selection start handle.
- cairo_surface_t* m_pHandleStart;
- /// Rectangle of the text selection start handle, to know if the user clicked on it or not
- GdkRectangle m_aHandleStartRect;
- /// If we are in the middle of a drag of the text selection end handle.
- gboolean m_bInDragStartHandle;
- /// Bitmap of the text selection middle handle.
- cairo_surface_t* m_pHandleMiddle;
- /// Rectangle of the text selection middle handle, to know if the user clicked on it or not
- GdkRectangle m_aHandleMiddleRect;
- /// If we are in the middle of a drag of the text selection middle handle.
- gboolean m_bInDragMiddleHandle;
- /// Bitmap of the text selection end handle.
- cairo_surface_t* m_pHandleEnd;
- /// Rectangle of the text selection end handle, to know if the user clicked on it or not
- GdkRectangle m_aHandleEndRect;
- /// If we are in the middle of a drag of the text selection end handle.
- gboolean m_bInDragEndHandle;
- ///@}
-
- /// @name Graphic handles.
- ///@{
- /// Bitmap of a graphic selection handle.
- cairo_surface_t* m_pGraphicHandle;
- /// Rectangle of a graphic selection handle, to know if the user clicked on it or not.
- GdkRectangle m_aGraphicHandleRects[8];
- /// If we are in the middle of a drag of a graphic selection handle.
- gboolean m_bInDragGraphicHandles[8];
- ///@}
+ GtkScrolledWindow aScrollWindow;
+ struct LOKDocView_Impl* m_pImpl;
};
struct _LOKDocViewClass
@@ -104,6 +44,10 @@ guint lok_docview_get_type (void);
GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice );
gboolean lok_docview_open_document (LOKDocView* pDocView,
char* pPath);
+
+/// Gets the document the viewer displays.
+LibreOfficeKitDocument* lok_docview_get_document(LOKDocView* pDocView);
+
void lok_docview_set_zoom (LOKDocView* pDocView,
float fZoom);
float lok_docview_get_zoom (LOKDocView* pDocView);
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index e9aeed6..94433f1 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -126,7 +126,7 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD
int nCharCode = 0;
int nKeyCode = 0;
- if (!pLOKDocView->m_bEdit)
+ if (!lok_docview_get_edit(pLOKDocView))
{
g_info("signalKey: not in edit mode, ignore");
return;
@@ -171,10 +171,11 @@ static void signalKey(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pD
if (pEvent->state & GDK_SHIFT_MASK)
nKeyCode |= KEY_SHIFT;
+ LibreOfficeKitDocument* pDocument = lok_docview_get_document(pLOKDocView);
if (pEvent->type == GDK_KEY_RELEASE)
- pLOKDocView->pDocument->pClass->postKeyEvent(pLOKDocView->pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode);
else
- pLOKDocView->pDocument->pClass->postKeyEvent(pLOKDocView->pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode);
}
// GtkComboBox requires gtk 2.24 or later
@@ -340,7 +341,7 @@ int main( int argc, char* argv[] )
int bOpened = lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
if (!bOpened)
g_error("main: lok_docview_open_document() failed with '%s'", pOffice->pClass->getError(pOffice));
- assert( LOK_DOCVIEW(pDocView)->pDocument );
+ assert(lok_docview_get_document(LOK_DOCVIEW(pDocView)));
// GtkComboBox requires gtk 2.24 or later
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index af5db19..db61812 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -29,6 +29,71 @@
// Number of handles around a graphic selection.
#define GRAPHIC_HANDLE_COUNT 8
+/// Holds data used by LOKDocView only.
+struct LOKDocView_Impl
+{
+ GtkWidget* m_pEventBox;
+ GtkWidget* m_pTable;
+ GtkWidget** m_pCanvas;
+
+ float m_fZoom;
+
+ LibreOfficeKit* m_pOffice;
+ LibreOfficeKitDocument* m_pDocument;
+ /// View or edit mode.
+ bool m_bEdit;
+ /// Position and size of the visible cursor.
+ GdkRectangle m_aVisibleCursor;
+ /// Cursor overlay is visible or hidden (for blinking).
+ bool m_bCursorOverlayVisible;
+ /// Cursor is visible or hidden (e.g. for graphic selection).
+ bool m_bCursorVisible;
+ /// Time of the last button press.
+ guint32 m_nLastButtonPressTime;
+ /// Time of the last button release.
+ guint32 m_nLastButtonReleaseTime;
+ /// Rectangles of the current text selection.
+ GList* m_pTextSelectionRectangles;
+ /// Position and size of the selection start (as if there would be a cursor caret there).
+ GdkRectangle m_aTextSelectionStart;
+ /// Position and size of the selection end.
+ GdkRectangle m_aTextSelectionEnd;
+ GdkRectangle m_aGraphicSelection;
+ bool m_bInDragGraphicSelection;
+
+ /// @name Start/middle/end handle.
+ ///@{
+ /// Bitmap of the text selection start handle.
+ cairo_surface_t* m_pHandleStart;
+ /// Rectangle of the text selection start handle, to know if the user clicked on it or not
+ GdkRectangle m_aHandleStartRect;
+ /// If we are in the middle of a drag of the text selection end handle.
+ bool m_bInDragStartHandle;
+ /// Bitmap of the text selection middle handle.
+ cairo_surface_t* m_pHandleMiddle;
+ /// Rectangle of the text selection middle handle, to know if the user clicked on it or not
+ GdkRectangle m_aHandleMiddleRect;
+ /// If we are in the middle of a drag of the text selection middle handle.
+ bool m_bInDragMiddleHandle;
+ /// Bitmap of the text selection end handle.
+ cairo_surface_t* m_pHandleEnd;
+ /// Rectangle of the text selection end handle, to know if the user clicked on it or not
+ GdkRectangle m_aHandleEndRect;
+ /// If we are in the middle of a drag of the text selection end handle.
+ bool m_bInDragEndHandle;
+ ///@}
+
+ /// @name Graphic handles.
+ ///@{
+ /// Bitmap of a graphic selection handle.
+ cairo_surface_t* m_pGraphicHandle;
+ /// Rectangle of a graphic selection handle, to know if the user clicked on it or not.
+ GdkRectangle m_aGraphicHandleRects[8];
+ /// If we are in the middle of a drag of a graphic selection handle.
+ bool m_bInDragGraphicHandles[8];
+ ///@}
+};
+
static void lok_docview_class_init( gpointer );
static void lok_docview_init( GTypeInstance *, gpointer );
static float pixelToTwip(float nInput);
@@ -36,12 +101,12 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint
// We specifically need to destroy the document when closing in order to ensure
// that lock files etc. are cleaned up.
-void lcl_onDestroy( LOKDocView* pDocView, gpointer pData )
+void lcl_onDestroy(LOKDocView* pDocView, gpointer /*pData*/)
{
- (void) pData;
- if ( pDocView->pDocument )
- pDocView->pDocument->pClass->destroy( pDocView->pDocument );
- pDocView->pDocument = NULL;
+ if (pDocView->m_pImpl->m_pDocument)
+ pDocView->m_pImpl->m_pDocument->pClass->destroy(pDocView->m_pImpl->m_pDocument);
+ pDocView->m_pImpl->m_pDocument = 0;
+ delete pDocView->m_pImpl;
}
/**
@@ -71,42 +136,42 @@ gboolean lcl_signalMotion(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
{
GdkPoint aPoint;
- if (pDocView->m_bInDragMiddleHandle)
+ if (pDocView->m_pImpl->m_bInDragMiddleHandle)
{
g_info("lcl_signalMotion: dragging the middle handle");
- lcl_getDragPoint(&pDocView->m_aHandleMiddleRect, pEvent, &aPoint);
- pDocView->pDocument->pClass->setTextSelection(
- pDocView->pDocument, LOK_SETTEXTSELECTION_RESET,
- pixelToTwip(aPoint.x) / pDocView->fZoom, pixelToTwip(aPoint.y) / pDocView->fZoom);
+ lcl_getDragPoint(&pDocView->m_pImpl->m_aHandleMiddleRect, pEvent, &aPoint);
+ pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
+ pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_RESET,
+ pixelToTwip(aPoint.x) / pDocView->m_pImpl->m_fZoom, pixelToTwip(aPoint.y) / pDocView->m_pImpl->m_fZoom);
return FALSE;
}
- if (pDocView->m_bInDragStartHandle)
+ if (pDocView->m_pImpl->m_bInDragStartHandle)
{
g_info("lcl_signalMotion: dragging the start handle");
- lcl_getDragPoint(&pDocView->m_aHandleStartRect, pEvent, &aPoint);
- pDocView->pDocument->pClass->setTextSelection(
- pDocView->pDocument, LOK_SETTEXTSELECTION_START,
- pixelToTwip(aPoint.x) / pDocView->fZoom, pixelToTwip(aPoint.y) / pDocView->fZoom);
+ lcl_getDragPoint(&pDocView->m_pImpl->m_aHandleStartRect, pEvent, &aPoint);
+ pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
+ pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_START,
+ pixelToTwip(aPoint.x) / pDocView->m_pImpl->m_fZoom, pixelToTwip(aPoint.y) / pDocView->m_pImpl->m_fZoom);
return FALSE;
}
- if (pDocView->m_bInDragEndHandle)
+ if (pDocView->m_pImpl->m_bInDragEndHandle)
{
g_info("lcl_signalMotion: dragging the end handle");
- lcl_getDragPoint(&pDocView->m_aHandleEndRect, pEvent, &aPoint);
- pDocView->pDocument->pClass->setTextSelection(
- pDocView->pDocument, LOK_SETTEXTSELECTION_END,
- pixelToTwip(aPoint.x) / pDocView->fZoom, pixelToTwip(aPoint.y) / pDocView->fZoom);
+ lcl_getDragPoint(&pDocView->m_pImpl->m_aHandleEndRect, pEvent, &aPoint);
+ pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
+ pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_END,
+ pixelToTwip(aPoint.x) / pDocView->m_pImpl->m_fZoom, pixelToTwip(aPoint.y) / pDocView->m_pImpl->m_fZoom);
return FALSE;
}
for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
{
- if (pDocView->m_bInDragGraphicHandles[i])
+ if (pDocView->m_pImpl->m_bInDragGraphicHandles[i])
{
g_info("lcl_signalMotion: dragging the graphic handle #%d", i);
return FALSE;
}
}
- if (pDocView->m_bInDragGraphicSelection)
+ if (pDocView->m_pImpl->m_bInDragGraphicSelection)
{
g_info("lcl_signalMotion: dragging the graphic selection");
return FALSE;
@@ -119,21 +184,21 @@ bool lcl_isOnBorders(LOKDocView* pDocView, GdkPoint* pClick)
{
// Handles are on the corners / edges of the shape:
// Let aSelection be the bounding box of all handles (a bit larger than the graphic selection).
- int nHandleWidth = pixelToTwip(pDocView->m_aGraphicHandleRects[0].width) / pDocView->fZoom;
- int nHandleHeight = pixelToTwip(pDocView->m_aGraphicHandleRects[0].height) / pDocView->fZoom;
+ int nHandleWidth = pixelToTwip(pDocView->m_pImpl->m_aGraphicHandleRects[0].width) / pDocView->m_pImpl->m_fZoom;
+ int nHandleHeight = pixelToTwip(pDocView->m_pImpl->m_aGraphicHandleRects[0].height) / pDocView->m_pImpl->m_fZoom;
GdkRectangle aSelection;
- aSelection.x = pDocView->m_aGraphicSelection.x - nHandleWidth / 2;
- aSelection.y = pDocView->m_aGraphicSelection.y - nHandleHeight / 2;
- aSelection.width = pDocView->m_aGraphicSelection.width + nHandleWidth;
- aSelection.height = pDocView->m_aGraphicSelection.height + nHandleHeight;
+ aSelection.x = pDocView->m_pImpl->m_aGraphicSelection.x - nHandleWidth / 2;
+ aSelection.y = pDocView->m_pImpl->m_aGraphicSelection.y - nHandleHeight / 2;
+ aSelection.width = pDocView->m_pImpl->m_aGraphicSelection.width + nHandleWidth;
+ aSelection.height = pDocView->m_pImpl->m_aGraphicSelection.height + nHandleHeight;
GdkRegion* pSelection = gdk_region_rectangle(&aSelection);
// Let aInsideBorder be the shape without the handles (a bit smaller than the graphic selection).
GdkRectangle aInsideBorder;
- aInsideBorder.x = pDocView->m_aGraphicSelection.x + nHandleWidth / 2;
- aInsideBorder.y = pDocView->m_aGraphicSelection.y + nHandleHeight / 2;
- aInsideBorder.width = pDocView->m_aGraphicSelection.width - nHandleWidth;
- aInsideBorder.height = pDocView->m_aGraphicSelection.height - nHandleHeight;
+ aInsideBorder.x = pDocView->m_pImpl->m_aGraphicSelection.x + nHandleWidth / 2;
+ aInsideBorder.y = pDocView->m_pImpl->m_aGraphicSelection.y + nHandleHeight / 2;
+ aInsideBorder.width = pDocView->m_pImpl->m_aGraphicSelection.width - nHandleWidth;
+ aInsideBorder.height = pDocView->m_pImpl->m_aGraphicSelection.height - nHandleHeight;
GdkRegion* pInsideBorder = gdk_region_rectangle(&aInsideBorder);
// Did we click on the border?
@@ -152,51 +217,51 @@ gboolean lcl_signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
if (pEvent->type == GDK_BUTTON_RELEASE)
{
- if (pDocView->m_bInDragStartHandle)
+ if (pDocView->m_pImpl->m_bInDragStartHandle)
{
g_info("lcl_signalButton: end of drag start handle");
- pDocView->m_bInDragStartHandle = FALSE;
+ pDocView->m_pImpl->m_bInDragStartHandle = false;
return FALSE;
}
- else if (pDocView->m_bInDragMiddleHandle)
+ else if (pDocView->m_pImpl->m_bInDragMiddleHandle)
{
g_info("lcl_signalButton: end of drag middle handle");
- pDocView->m_bInDragMiddleHandle = FALSE;
+ pDocView->m_pImpl->m_bInDragMiddleHandle = false;
return FALSE;
}
- else if (pDocView->m_bInDragEndHandle)
+ else if (pDocView->m_pImpl->m_bInDragEndHandle)
{
g_info("lcl_signalButton: end of drag end handle");
- pDocView->m_bInDragEndHandle = FALSE;
+ pDocView->m_pImpl->m_bInDragEndHandle = false;
return FALSE;
}
for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
{
- if (pDocView->m_bInDragGraphicHandles[i])
+ if (pDocView->m_pImpl->m_bInDragGraphicHandles[i])
{
g_info("lcl_signalButton: end of drag graphic handle #%d", i);
- pDocView->m_bInDragGraphicHandles[i] = FALSE;
- pDocView->pDocument->pClass->setGraphicSelection(
- pDocView->pDocument, LOK_SETGRAPHICSELECTION_END,
- pixelToTwip(pEvent->x) / pDocView->fZoom, pixelToTwip(pEvent->y) / pDocView->fZoom);
+ pDocView->m_pImpl->m_bInDragGraphicHandles[i] = false;
+ pDocView->m_pImpl->m_pDocument->pClass->setGraphicSelection(
+ pDocView->m_pImpl->m_pDocument, LOK_SETGRAPHICSELECTION_END,
+ pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom, pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom);
return FALSE;
}
}
- if (pDocView->m_bInDragGraphicSelection)
+ if (pDocView->m_pImpl->m_bInDragGraphicSelection)
{
g_info("lcl_signalButton: end of drag graphic selection");
- pDocView->m_bInDragGraphicSelection = FALSE;
- pDocView->pDocument->pClass->setGraphicSelection(
- pDocView->pDocument, LOK_SETGRAPHICSELECTION_END,
- pixelToTwip(pEvent->x) / pDocView->fZoom,
- pixelToTwip(pEvent->y) / pDocView->fZoom);
+ pDocView->m_pImpl->m_bInDragGraphicSelection = false;
+ pDocView->m_pImpl->m_pDocument->pClass->setGraphicSelection(
+ pDocView->m_pImpl->m_pDocument, LOK_SETGRAPHICSELECTION_END,
+ pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom,
+ pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom);
return FALSE;
}
}
- if (pDocView->m_bEdit)
+ if (pDocView->m_pImpl->m_bEdit)
{
GdkRectangle aClick;
aClick.x = pEvent->x;
@@ -205,56 +270,56 @@ gboolean lcl_signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
aClick.height = 1;
if (pEvent->type == GDK_BUTTON_PRESS)
{
- if (gdk_rectangle_intersect(&aClick, &pDocView->m_aHandleStartRect, NULL))
+ if (gdk_rectangle_intersect(&aClick, &pDocView->m_pImpl->m_aHandleStartRect, NULL))
{
g_info("lcl_signalButton: start of drag start handle");
- pDocView->m_bInDragStartHandle = TRUE;
+ pDocView->m_pImpl->m_bInDragStartHandle = true;
return FALSE;
}
- else if (gdk_rectangle_intersect(&aClick, &pDocView->m_aHandleMiddleRect, NULL))
+ else if (gdk_rectangle_intersect(&aClick, &pDocView->m_pImpl->m_aHandleMiddleRect, NULL))
{
g_info("lcl_signalButton: start of drag middle handle");
- pDocView->m_bInDragMiddleHandle = TRUE;
+ pDocView->m_pImpl->m_bInDragMiddleHandle = true;
return FALSE;
}
- else if (gdk_rectangle_intersect(&aClick, &pDocView->m_aHandleEndRect, NULL))
+ else if (gdk_rectangle_intersect(&aClick, &pDocView->m_pImpl->m_aHandleEndRect, NULL))
{
g_info("lcl_signalButton: start of drag end handle");
- pDocView->m_bInDragEndHandle = TRUE;
+ pDocView->m_pImpl->m_bInDragEndHandle = true;
return FALSE;
}
for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
{
- if (gdk_rectangle_intersect(&aClick, &pDocView->m_aGraphicHandleRects[i], NULL))
+ if (gdk_rectangle_intersect(&aClick, &pDocView->m_pImpl->m_aGraphicHandleRects[i], NULL))
{
g_info("lcl_signalButton: start of drag graphic handle #%d", i);
- pDocView->m_bInDragGraphicHandles[i] = TRUE;
- pDocView->pDocument->pClass->setGraphicSelection(
- pDocView->pDocument, LOK_SETGRAPHICSELECTION_START,
- pixelToTwip(pDocView->m_aGraphicHandleRects[i].x + pDocView->m_aGraphicHandleRects[i].width / 2) / pDocView->fZoom,
- pixelToTwip(pDocView->m_aGraphicHandleRects[i].y + pDocView->m_aGraphicHandleRects[i].height / 2) / pDocView->fZoom);
+ pDocView->m_pImpl->m_bInDragGraphicHandles[i] = true;
+ pDocView->m_pImpl->m_pDocument->pClass->setGraphicSelection(
+ pDocView->m_pImpl->m_pDocument, LOK_SETGRAPHICSELECTION_START,
+ pixelToTwip(pDocView->m_pImpl->m_aGraphicHandleRects[i].x + pDocView->m_pImpl->m_aGraphicHandleRects[i].width / 2) / pDocView->m_pImpl->m_fZoom,
+ pixelToTwip(pDocView->m_pImpl->m_aGraphicHandleRects[i].y + pDocView->m_pImpl->m_aGraphicHandleRects[i].height / 2) / pDocView->m_pImpl->m_fZoom);
return FALSE;
}
}
GdkPoint aClickInTwips;
- aClickInTwips.x = pixelToTwip(pEvent->x) / pDocView->fZoom;
- aClickInTwips.y = pixelToTwip(pEvent->y) / pDocView->fZoom;
+ aClickInTwips.x = pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom;
+ aClickInTwips.y = pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom;
if (lcl_isOnBorders(pDocView, &aClickInTwips))
{
g_info("lcl_signalButton: start of drag graphic selection");
- pDocView->m_bInDragGraphicSelection = TRUE;
- pDocView->pDocument->pClass->setGraphicSelection(
- pDocView->pDocument, LOK_SETGRAPHICSELECTION_START,
- pixelToTwip(pEvent->x) / pDocView->fZoom,
- pixelToTwip(pEvent->y) / pDocView->fZoom);
+ pDocView->m_pImpl->m_bInDragGraphicSelection = true;
+ pDocView->m_pImpl->m_pDocument->pClass->setGraphicSelection(
+ pDocView->m_pImpl->m_pDocument, LOK_SETGRAPHICSELECTION_START,
+ pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom,
+ pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom);
return FALSE;
}
}
}
- if (!pDocView->m_bEdit)
+ if (!pDocView->m_pImpl->m_bEdit)
lok_docview_set_edit(pDocView, TRUE);
switch (pEvent->type)
@@ -262,25 +327,25 @@ gboolean lcl_signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
case GDK_BUTTON_PRESS:
{
int nCount = 1;
- if ((pEvent->time - pDocView->m_nLastButtonPressTime) < 250)
+ if ((pEvent->time - pDocView->m_pImpl->m_nLastButtonPressTime) < 250)
nCount++;
- pDocView->m_nLastButtonPressTime = pEvent->time;
- pDocView->pDocument->pClass->postMouseEvent(
- pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
- pixelToTwip(pEvent->x) / pDocView->fZoom,
- pixelToTwip(pEvent->y) / pDocView->fZoom, nCount);
+ pDocView->m_pImpl->m_nLastButtonPressTime = pEvent->time;
+ pDocView->m_pImpl->m_pDocument->pClass->postMouseEvent(
+ pDocView->m_pImpl->m_pDocument, LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom,
+ pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom, nCount);
break;
}
case GDK_BUTTON_RELEASE:
{
int nCount = 1;
- if ((pEvent->time - pDocView->m_nLastButtonReleaseTime) < 250)
+ if ((pEvent->time - pDocView->m_pImpl->m_nLastButtonReleaseTime) < 250)
nCount++;
- pDocView->m_nLastButtonReleaseTime = pEvent->time;
- pDocView->pDocument->pClass->postMouseEvent(
- pDocView->pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP,
- pixelToTwip(pEvent->x) / pDocView->fZoom,
- pixelToTwip(pEvent->y) / pDocView->fZoom, nCount);
+ pDocView->m_pImpl->m_nLastButtonReleaseTime = pEvent->time;
+ pDocView->m_pImpl->m_pDocument->pClass->postMouseEvent(
+ pDocView->m_pImpl->m_pDocument, LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom,
+ pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom, nCount);
break;
}
default:
@@ -346,62 +411,62 @@ static void lok_docview_init( GTypeInstance* pInstance, gpointer )
gtk_scrolled_window_set_hadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL );
gtk_scrolled_window_set_vadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL );
- pDocView->pEventBox = gtk_event_box_new();
+ pDocView->m_pImpl = new LOKDocView_Impl();
+ pDocView->m_pImpl->m_pEventBox = gtk_event_box_new();
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
- pDocView->pEventBox );
-
- gtk_widget_set_events(pDocView->pEventBox, GDK_BUTTON_PRESS_MASK); // So that drag doesn't try to move the whole window.
- gtk_signal_connect(GTK_OBJECT(pDocView->pEventBox), "button-press-event", GTK_SIGNAL_FUNC(lcl_signalButton), pDocView);
- gtk_signal_connect(GTK_OBJECT(pDocView->pEventBox), "button-release-event", GTK_SIGNAL_FUNC(lcl_signalButton), pDocView);
- gtk_signal_connect(GTK_OBJECT(pDocView->pEventBox), "motion-notify-event", GTK_SIGNAL_FUNC(lcl_signalMotion), pDocView);
-
- gtk_widget_show( pDocView->pEventBox );
-
- pDocView->pTable = 0;
- pDocView->pCanvas = 0;
-
- // TODO: figure out a clever view of getting paths set up.
- pDocView->pOffice = 0;
- pDocView->pDocument = 0;
-
- pDocView->fZoom = 1;
- pDocView->m_bEdit = FALSE;
- memset(&pDocView->m_aVisibleCursor, 0, sizeof(pDocView->m_aVisibleCursor));
- pDocView->m_bCursorOverlayVisible = FALSE;
- pDocView->m_bCursorVisible = TRUE;
- pDocView->m_nLastButtonPressTime = 0;
- pDocView->m_nLastButtonReleaseTime = 0;
- pDocView->m_pTextSelectionRectangles = NULL;
- memset(&pDocView->m_aTextSelectionStart, 0, sizeof(pDocView->m_aTextSelectionStart));
- memset(&pDocView->m_aTextSelectionEnd, 0, sizeof(pDocView->m_aTextSelectionEnd));
- memset(&pDocView->m_aGraphicSelection, 0, sizeof(pDocView->m_aGraphicSelection));
- pDocView->m_bInDragGraphicSelection = FALSE;
+ pDocView->m_pImpl->m_pEventBox );
+
+ gtk_widget_set_events(pDocView->m_pImpl->m_pEventBox, GDK_BUTTON_PRESS_MASK); // So that drag doesn't try to move the whole window.
+ gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "button-press-event", GTK_SIGNAL_FUNC(lcl_signalButton), pDocView);
+ gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "button-release-event", GTK_SIGNAL_FUNC(lcl_signalButton), pDocView);
+ gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "motion-notify-event", GTK_SIGNAL_FUNC(lcl_signalMotion), pDocView);
+
+ gtk_widget_show( pDocView->m_pImpl->m_pEventBox );
+
+ pDocView->m_pImpl->m_pTable = 0;
+ pDocView->m_pImpl->m_pCanvas = 0;
+
+ pDocView->m_pImpl->m_pOffice = 0;
+ pDocView->m_pImpl->m_pDocument = 0;
+
+ pDocView->m_pImpl->m_fZoom = 1;
+ pDocView->m_pImpl->m_bEdit = false;
+ memset(&pDocView->m_pImpl->m_aVisibleCursor, 0, sizeof(pDocView->m_pImpl->m_aVisibleCursor));
+ pDocView->m_pImpl->m_bCursorOverlayVisible = false;
+ pDocView->m_pImpl->m_bCursorVisible = true;
+ pDocView->m_pImpl->m_nLastButtonPressTime = 0;
+ pDocView->m_pImpl->m_nLastButtonReleaseTime = 0;
+ pDocView->m_pImpl->m_pTextSelectionRectangles = 0;
+ memset(&pDocView->m_pImpl->m_aTextSelectionStart, 0, sizeof(pDocView->m_pImpl->m_aTextSelectionStart));
+ memset(&pDocView->m_pImpl->m_aTextSelectionEnd, 0, sizeof(pDocView->m_pImpl->m_aTextSelectionEnd));
+ memset(&pDocView->m_pImpl->m_aGraphicSelection, 0, sizeof(pDocView->m_pImpl->m_aGraphicSelection));
+ pDocView->m_pImpl->m_bInDragGraphicSelection = false;
// Start/middle/end handle.
- pDocView->m_pHandleStart = NULL;
- memset(&pDocView->m_aHandleStartRect, 0, sizeof(pDocView->m_aHandleStartRect));
- pDocView->m_bInDragStartHandle = FALSE;
- pDocView->m_pHandleMiddle = NULL;
- memset(&pDocView->m_aHandleMiddleRect, 0, sizeof(pDocView->m_aHandleMiddleRect));
- pDocView->m_bInDragMiddleHandle = FALSE;
- pDocView->m_pHandleEnd = NULL;
- memset(&pDocView->m_aHandleEndRect, 0, sizeof(pDocView->m_aHandleEndRect));
- pDocView->m_bInDragEndHandle = FALSE;
-
- pDocView->m_pGraphicHandle = NULL;
- memset(&pDocView->m_aGraphicHandleRects, 0, sizeof(pDocView->m_aGraphicHandleRects));
- memset(&pDocView->m_bInDragGraphicHandles, 0, sizeof(pDocView->m_bInDragGraphicHandles));
+ pDocView->m_pImpl->m_pHandleStart = 0;
+ memset(&pDocView->m_pImpl->m_aHandleStartRect, 0, sizeof(pDocView->m_pImpl->m_aHandleStartRect));
+ pDocView->m_pImpl->m_bInDragStartHandle = false;
+ pDocView->m_pImpl->m_pHandleMiddle = 0;
+ memset(&pDocView->m_pImpl->m_aHandleMiddleRect, 0, sizeof(pDocView->m_pImpl->m_aHandleMiddleRect));
+ pDocView->m_pImpl->m_bInDragMiddleHandle = false;
+ pDocView->m_pImpl->m_pHandleEnd = 0;
+ memset(&pDocView->m_pImpl->m_aHandleEndRect, 0, sizeof(pDocView->m_pImpl->m_aHandleEndRect));
+ pDocView->m_pImpl->m_bInDragEndHandle = false;
+
+ pDocView->m_pImpl->m_pGraphicHandle = 0;
+ memset(&pDocView->m_pImpl->m_aGraphicHandleRects, 0, sizeof(pDocView->m_pImpl->m_aGraphicHandleRects));
+ memset(&pDocView->m_pImpl->m_bInDragGraphicHandles, 0, sizeof(pDocView->m_pImpl->m_bInDragGraphicHandles));
gtk_signal_connect( GTK_OBJECT(pDocView), "destroy",
GTK_SIGNAL_FUNC(lcl_onDestroy), NULL );
- g_signal_connect_after(pDocView->pEventBox, "expose-event",
+ g_signal_connect_after(pDocView->m_pImpl->m_pEventBox, "expose-event",
G_CALLBACK(renderOverlay), pDocView);
}
SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
{
LOKDocView* pDocView = LOK_DOCVIEW(gtk_type_new(lok_docview_get_type()));
- pDocView->pOffice = pOffice;
+ pDocView->m_pImpl->m_pOffice = pOffice;
return GTK_WIDGET( pDocView );
}
@@ -430,13 +495,13 @@ static gboolean lcl_handleTimeout(gpointer pData)
{
LOKDocView* pDocView = LOK_DOCVIEW(pData);
- if (pDocView->m_bEdit)
+ if (pDocView->m_pImpl->m_bEdit)
{
- if (pDocView->m_bCursorOverlayVisible)
- pDocView->m_bCursorOverlayVisible = FALSE;
+ if (pDocView->m_pImpl->m_bCursorOverlayVisible)
+ pDocView->m_pImpl->m_bCursorOverlayVisible = false;
else
- pDocView->m_bCursorOverlayVisible = TRUE;
- gtk_widget_queue_draw(GTK_WIDGET(pDocView->pEventBox));
+ pDocView->m_pImpl->m_bCursorOverlayVisible = true;
+ gtk_widget_queue_draw(GTK_WIDGET(pDocView->m_pImpl->m_pEventBox));
}
return G_SOURCE_CONTINUE;
@@ -543,77 +608,74 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* /*pEvent*/, gp
{
#if GTK_CHECK_VERSION(2,14,0) // we need gtk_widget_get_window()
LOKDocView* pDocView = LOK_DOCVIEW(pData);
- cairo_t* pCairo;
+ cairo_t* pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
- pCairo = gdk_cairo_create(gtk_widget_get_window(pWidget));
-
- if (pDocView->m_bEdit && pDocView->m_bCursorVisible && pDocView->m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor))
+ if (pDocView->m_pImpl->m_bEdit && pDocView->m_pImpl->m_bCursorVisible && pDocView->m_pImpl->m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aVisibleCursor))
{
- if (pDocView->m_aVisibleCursor.width < 30)
+ if (pDocView->m_pImpl->m_aVisibleCursor.width < 30)
// Set a minimal width if it would be 0.
- pDocView->m_aVisibleCursor.width = 30;
+ pDocView->m_pImpl->m_aVisibleCursor.width = 30;
cairo_set_source_rgb(pCairo, 0, 0, 0);
cairo_rectangle(pCairo,
- twipToPixel(pDocView->m_aVisibleCursor.x) * pDocView->fZoom,
- twipToPixel(pDocView->m_aVisibleCursor.y) * pDocView->fZoom,
- twipToPixel(pDocView->m_aVisibleCursor.width) * pDocView->fZoom,
- twipToPixel(pDocView->m_aVisibleCursor.height) * pDocView->fZoom);
+ twipToPixel(pDocView->m_pImpl->m_aVisibleCursor.x) * pDocView->m_pImpl->m_fZoom,
+ twipToPixel(pDocView->m_pImpl->m_aVisibleCursor.y) * pDocView->m_pImpl->m_fZoom,
+ twipToPixel(pDocView->m_pImpl->m_aVisibleCursor.width) * pDocView->m_pImpl->m_fZoom,
+ twipToPixel(pDocView->m_pImpl->m_aVisibleCursor.height) * pDocView->m_pImpl->m_fZoom);
cairo_fill(pCairo);
-
}
- if (pDocView->m_bEdit && pDocView->m_bCursorVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor) && !pDocView->m_pTextSelectionRectangles)
+ if (pDocView->m_pImpl->m_bEdit && pDocView->m_pImpl->m_bCursorVisible && !lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aVisibleCursor) && !pDocView->m_pImpl->m_pTextSelectionRectangles)
{
// Have a cursor, but no selection: we need the middle handle.
- if (!pDocView->m_pHandleMiddle)
- pDocView->m_pHandleMiddle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_middle.png");
- lcl_renderHandle(pCairo, &pDocView->m_aVisibleCursor,
- pDocView->m_pHandleMiddle, &pDocView->m_aHandleMiddleRect,
- pDocView->fZoom);
+ if (!pDocView->m_pImpl->m_pHandleMiddle)
+ pDocView->m_pImpl->m_pHandleMiddle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_middle.png");
+ lcl_renderHandle(pCairo, &pDocView->m_pImpl->m_aVisibleCursor,
+ pDocView->m_pImpl->m_pHandleMiddle, &pDocView->m_pImpl->m_aHandleMiddleRect,
+ pDocView->m_pImpl->m_fZoom);
}
- if (pDocView->m_pTextSelectionRectangles)
+ if (pDocView->m_pImpl->m_pTextSelectionRectangles)
{
- for (GList* i = pDocView->m_pTextSelectionRectangles; i != NULL; i = i->next)
+ for (GList* i = pDocView->m_pImpl->m_pTextSelectionRectangles; i != NULL; i = i->next)
{
GdkRectangle* pRectangle = static_cast<GdkRectangle*>(i->data);
// Blue with 75% transparency.
cairo_set_source_rgba(pCairo, ((double)0x43)/255, ((double)0xac)/255, ((double)0xe8)/255, 0.25);
cairo_rectangle(pCairo,
- twipToPixel(pRectangle->x) * pDocView->fZoom,
- twipToPixel(pRectangle->y) * pDocView->fZoom,
- twipToPixel(pRectangle->width) * pDocView->fZoom,
- twipToPixel(pRectangle->height) * pDocView->fZoom);
+ twipToPixel(pRectangle->x) * pDocView->m_pImpl->m_fZoom,
+ twipToPixel(pRectangle->y) * pDocView->m_pImpl->m_fZoom,
+ twipToPixel(pRectangle->width) * pDocView->m_pImpl->m_fZoom,
+ twipToPixel(pRectangle->height) * pDocView->m_pImpl->m_fZoom);
cairo_fill(pCairo);
}
// Handles
- if (!lcl_isEmptyRectangle(&pDocView->m_aTextSelectionStart))
+ if (!lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aTextSelectionStart))
{
// Have a start position: we need a start handle.
- if (!pDocView->m_pHandleStart)
- pDocView->m_pHandleStart = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_start.png");
- lcl_renderHandle(pCairo, &pDocView->m_aTextSelectionStart,
- pDocView->m_pHandleStart, &pDocView->m_aHandleStartRect,
- pDocView->fZoom);
+ if (!pDocView->m_pImpl->m_pHandleStart)
+ pDocView->m_pImpl->m_pHandleStart = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_start.png");
+ lcl_renderHandle(pCairo, &pDocView->m_pImpl->m_aTextSelectionStart,
+ pDocView->m_pImpl->m_pHandleStart, &pDocView->m_pImpl->m_aHandleStartRect,
+ pDocView->m_pImpl->m_fZoom);
}
- if (!lcl_isEmptyRectangle(&pDocView->m_aTextSelectionEnd))
+ if (!lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aTextSelectionEnd))
{
// Have a start position: we need an end handle.
- if (!pDocView->m_pHandleEnd)
- pDocView->m_pHandleEnd = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_end.png");
- lcl_renderHandle(pCairo, &pDocView->m_aTextSelectionEnd,
- pDocView->m_pHandleEnd, &pDocView->m_aHandleEndRect,
- pDocView->fZoom);
+ if (!pDocView->m_pImpl->m_pHandleEnd)
+ pDocView->m_pImpl->m_pHandleEnd = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_end.png");
+ lcl_renderHandle(pCairo, &pDocView->m_pImpl->m_aTextSelectionEnd,
+ pDocView->m_pImpl->m_pHandleEnd, &pDocView->m_pImpl->m_aHandleEndRect,
+ pDocView->m_pImpl->m_fZoom);
}
}
- if (!lcl_isEmptyRectangle(&pDocView->m_aGraphicSelection))
+ if (!lcl_isEmptyRectangle(&pDocView->m_pImpl->m_aGraphicSelection))
{
- if (!pDocView->m_pGraphicHandle)
- pDocView->m_pGraphicHandle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_graphic.png");
- lcl_renderGraphicHandle(pCairo, &pDocView->m_aGraphicSelection, pDocView->m_pGraphicHandle, pDocView->m_aGraphicHandleRects, pDocView->fZoom);
+ if (!pDocView->m_pImpl->m_pGraphicHandle)
+ pDocView->m_pImpl->m_pGraphicHandle = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_graphic.png");
+ lcl_renderGraphicHandle(pCairo, &pDocView->m_pImpl->m_aGraphicSelection, pDocView->m_pImpl->m_pGraphicHandle, pDocView->m_pImpl->m_aGraphicHandleRects, pDocView->m_pImpl->m_fZoom);
}
cairo_destroy(pCairo);
@@ -627,40 +689,40 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
// Get document size and find out how many rows / columns we need.
long nDocumentWidthTwips, nDocumentHeightTwips;
- pDocView->pDocument->pClass->getDocumentSize(pDocView->pDocument, &nDocumentWidthTwips, &nDocumentHeightTwips);
- long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips) * pDocView->fZoom;
- long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips) * pDocView->fZoom;
+ pDocView->m_pImpl->m_pDocument->pClass->getDocumentSize(pDocView->m_pImpl->m_pDocument, &nDocumentWidthTwips, &nDocumentHeightTwips);
+ long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips) * pDocView->m_pImpl->m_fZoom;
+ long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips) * pDocView->m_pImpl->m_fZoom;
// Total number of rows / columns in this document.
guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
// Set up our table and the tile pointers.
- if (!pDocView->pTable)
- pPartial = NULL;
+ if (!pDocView->m_pImpl->m_pTable)
+ pPartial = 0;
if (pPartial)
{
// Same as nRows / nColumns, but from the previous renderDocument() call.
guint nOldRows, nOldColumns;
#if GTK_CHECK_VERSION(2,22,0)
- gtk_table_get_size(GTK_TABLE(pDocView->pTable), &nOldRows, &nOldColumns);
+ gtk_table_get_size(GTK_TABLE(pDocView->m_pImpl->m_pTable), &nOldRows, &nOldColumns);
if (nOldRows != nRows || nOldColumns != nColumns)
// Can't do partial rendering, document size changed.
- pPartial = NULL;
+ pPartial = 0;
#else
- pPartial = NULL;
+ pPartial = 0;
#endif
}
if (!pPartial)
{
- if (pDocView->pTable)
- gtk_container_remove(GTK_CONTAINER(pDocView->pEventBox), pDocView->pTable);
- pDocView->pTable = gtk_table_new(nRows, nColumns, FALSE);
- gtk_container_add(GTK_CONTAINER(pDocView->pEventBox), pDocView->pTable);
- gtk_widget_show(pDocView->pTable);
- if (pDocView->pCanvas)
- g_free(pDocView->pCanvas);
- pDocView->pCanvas = static_cast<GtkWidget**>(g_malloc0(sizeof(GtkWidget*) * nRows * nColumns));
+ if (pDocView->m_pImpl->m_pTable)
+ gtk_container_remove(GTK_CONTAINER(pDocView->m_pImpl->m_pEventBox), pDocView->m_pImpl->m_pTable);
+ pDocView->m_pImpl->m_pTable = gtk_table_new(nRows, nColumns, FALSE);
+ gtk_container_add(GTK_CONTAINER(pDocView->m_pImpl->m_pEventBox), pDocView->m_pImpl->m_pTable);
+ gtk_widget_show(pDocView->m_pImpl->m_pTable);
+ if (pDocView->m_pImpl->m_pCanvas)
+ g_free(pDocView->m_pImpl->m_pCanvas);
+ pDocView->m_pImpl->m_pCanvas = static_cast<GtkWidget**>(g_malloc0(sizeof(GtkWidget*) * nRows * nColumns));
}
// Render the tiles.
@@ -669,7 +731,7 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
for (guint nColumn = 0; nColumn < nColumns; ++nColumn)
{
GdkRectangle aTileRectangleTwips, aTileRectanglePixels;
- gboolean bPaint = TRUE;
+ bool bPaint = true;
// Determine size of the tile: the rightmost/bottommost tiles may be smaller and we need the size to decide if we need to repaint.
if (nColumn == nColumns - 1)
@@ -682,12 +744,12 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
aTileRectanglePixels.height = nTileSizePixels;
// Determine size and position of the tile in document coordinates, so we can decide if we can skip painting for partial rendering.
- aTileRectangleTwips.x = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nColumn;
- aTileRectangleTwips.y = pixelToTwip(nTileSizePixels) / pDocView->fZoom * nRow;
- aTileRectangleTwips.width = pixelToTwip(aTileRectanglePixels.width) / pDocView->fZoom;
- aTileRectangleTwips.height = pixelToTwip(aTileRectanglePixels.height) / pDocView->fZoom;
- if (pPartial && !gdk_rectangle_intersect(pPartial, &aTileRectangleTwips, NULL))
- bPaint = FALSE;
+ aTileRectangleTwips.x = pixelToTwip(nTileSizePixels) / pDocView->m_pImpl->m_fZoom * nColumn;
+ aTileRectangleTwips.y = pixelToTwip(nTileSizePixels) / pDocView->m_pImpl->m_fZoom * nRow;
+ aTileRectangleTwips.width = pixelToTwip(aTileRectanglePixels.width) / pDocView->m_pImpl->m_fZoom;
+ aTileRectangleTwips.height = pixelToTwip(aTileRectanglePixels.height) / pDocView->m_pImpl->m_fZoom;
+ if (pPartial && !gdk_rectangle_intersect(pPartial, &aTileRectangleTwips, 0))
+ bPaint = false;
if (bPaint)
{
@@ -697,7 +759,7 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
GdkPixbuf* pPixBuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, aTileRectanglePixels.width, aTileRectanglePixels.height);
unsigned char* pBuffer = gdk_pixbuf_get_pixels(pPixBuf);
g_info("renderDocument: paintTile(%d, %d)", nRow, nColumn);
- pDocView->pDocument->pClass->paintTile(pDocView->pDocument,
+ pDocView->m_pImpl->m_pDocument->pClass->paintTile(pDocView->m_pImpl->m_pDocument,
// Buffer and its size, depends on the position only.
pBuffer,
aTileRectanglePixels.width, aTileRectanglePixels.height,
@@ -706,14 +768,14 @@ void renderDocument(LOKDocView* pDocView, GdkRectangle* pPartial)
// Size of the tile, depends on the zoom factor and the tile position only.
aTileRectangleTwips.width, aTileRectangleTwips.height);
- if (pDocView->pCanvas[nTile])
- gtk_widget_destroy(GTK_WIDGET(pDocView->pCanvas[nTile]));
- pDocView->pCanvas[nTile] = gtk_image_new();
- gtk_image_set_from_pixbuf(GTK_IMAGE(pDocView->pCanvas[nTile]), pPixBuf);
+ if (pDocView->m_pImpl->m_pCanvas[nTile])
+ gtk_widget_destroy(GTK_WIDGET(pDocView->m_pImpl->m_pCanvas[nTile]));
+ pDocView->m_pImpl->m_pCanvas[nTile] = gtk_image_new();
+ gtk_image_set_from_pixbuf(GTK_IMAGE(pDocView->m_pImpl->m_pCanvas[nTile]), pPixBuf);
g_object_unref(G_OBJECT(pPixBuf));
- gtk_widget_show(pDocView->pCanvas[nTile]);
- gtk_table_attach(GTK_TABLE(pDocView->pTable),
- pDocView->pCanvas[nTile],
+ gtk_widget_show(pDocView->m_pImpl->m_pCanvas[nTile]);
+ gtk_table_attach(GTK_TABLE(pDocView->m_pImpl->m_pTable),
+ pDocView->m_pImpl->m_pCanvas[nTile],
nColumn, nColumn + 1, nRow, nRow + 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
}
@@ -820,54 +882,54 @@ static gboolean lok_docview_callback(gpointer pData)
break;
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
{
- pCallback->m_pDocView->m_aVisibleCursor = lcl_payloadToRectangle(pCallback->m_pPayload);
- pCallback->m_pDocView->m_bCursorOverlayVisible = TRUE;
- gtk_widget_queue_draw(GTK_WIDGET(pCallback->m_pDocView->pEventBox));
+ pCallback->m_pDocView->m_pImpl->m_aVisibleCursor = lcl_payloadToRectangle(pCallback->m_pPayload);
+ pCallback->m_pDocView->m_pImpl->m_bCursorOverlayVisible = true;
+ gtk_widget_queue_draw(GTK_WIDGET(pCallback->m_pDocView->m_pImpl->m_pEventBox));
}
break;
case LOK_CALLBACK_TEXT_SELECTION:
{
LOKDocView* pDocView = pCallback->m_pDocView;
GList* pRectangles = lcl_payloadToRectangles(pCallback->m_pPayload);
- if (pDocView->m_pTextSelectionRectangles)
- g_list_free_full(pDocView->m_pTextSelectionRectangles, g_free);
- pDocView->m_pTextSelectionRectangles = pRectangles;
+ if (pDocView->m_pImpl->m_pTextSelectionRectangles)
+ g_list_free_full(pDocView->m_pImpl->m_pTextSelectionRectangles, g_free);
+ pDocView->m_pImpl->m_pTextSelectionRectangles = pRectangles;
// In case the selection is empty, then we get no LOK_CALLBACK_TEXT_SELECTION_START/END events.
if (pRectangles == NULL)
{
- memset(&pDocView->m_aTextSelectionStart, 0, sizeof(pDocView->m_aTextSelectionStart));
- memset(&pDocView->m_aHandleStartRect, 0, sizeof(pDocView->m_aHandleStartRect));
- memset(&pDocView->m_aTextSelectionEnd, 0, sizeof(pDocView->m_aTextSelectionEnd));
- memset(&pDocView->m_aHandleEndRect, 0, sizeof(pDocView->m_aHandleEndRect));
+ memset(&pDocView->m_pImpl->m_aTextSelectionStart, 0, sizeof(pDocView->m_pImpl->m_aTextSelectionStart));
+ memset(&pDocView->m_pImpl->m_aHandleStartRect, 0, sizeof(pDocView->m_pImpl->m_aHandleStartRect));
+ memset(&pDocView->m_pImpl->m_aTextSelectionEnd, 0, sizeof(pDocView->m_pImpl->m_aTextSelectionEnd));
+ memset(&pDocView->m_pImpl->m_aHandleEndRect, 0, sizeof(pDocView->m_pImpl->m_aHandleEndRect));
}
else
- memset(&pDocView->m_aHandleMiddleRect, 0, sizeof(pDocView->m_aHandleMiddleRect));
- gtk_widget_queue_draw(GTK_WIDGET(pDocView->pEventBox));
+ memset(&pDocView->m_pImpl->m_aHandleMiddleRect, 0, sizeof(pDocView->m_pImpl->m_aHandleMiddleRect));
+ gtk_widget_queue_draw(GTK_WIDGET(pDocView->m_pImpl->m_pEventBox));
}
break;
case LOK_CALLBACK_TEXT_SELECTION_START:
{
- pCallback->m_pDocView->m_aTextSelectionStart = lcl_payloadToRectangle(pCallback->m_pPayload);
+ pCallback->m_pDocView->m_pImpl->m_aTextSelectionStart = lcl_payloadToRectangle(pCallback->m_pPayload);
}
break;
case LOK_CALLBACK_TEXT_SELECTION_END:
{
- pCallback->m_pDocView->m_aTextSelectionEnd = lcl_payloadToRectangle(pCallback->m_pPayload);
+ pCallback->m_pDocView->m_pImpl->m_aTextSelectionEnd = lcl_payloadToRectangle(pCallback->m_pPayload);
}
break;
case LOK_CALLBACK_CURSOR_VISIBLE:
{
- pCallback->m_pDocView->m_bCursorVisible = strcmp(pCallback->m_pPayload, "true") == 0;
+ pCallback->m_pDocView->m_pImpl->m_bCursorVisible = strcmp(pCallback->m_pPayload, "true") == 0;
}
break;
case LOK_CALLBACK_GRAPHIC_SELECTION:
{
if (strcmp(pCallback->m_pPayload, "EMPTY") != 0)
- pCallback->m_pDocView->m_aGraphicSelection = lcl_payloadToRectangle(pCallback->m_pPayload);
+ pCallback->m_pDocView->m_pImpl->m_aGraphicSelection = lcl_payloadToRectangle(pCallback->m_pPayload);
else
- memset(&pCallback->m_pDocView->m_aGraphicSelection, 0, sizeof(pCallback->m_pDocView->m_aGraphicSelection));
- gtk_widget_queue_draw(GTK_WIDGET(pCallback->m_pDocView->pEventBox));
+ memset(&pCallback->m_pDocView->m_pImpl->m_aGraphicSelection, 0, sizeof(pCallback->m_pDocView->m_pImpl->m_aGraphicSelection));
+ gtk_widget_queue_draw(GTK_WIDGET(pCallback->m_pDocView->m_pImpl->m_pEventBox));
}
break;
case LOK_CALLBACK_HYPERLINK_CLICKED:
@@ -906,25 +968,25 @@ static void lok_docview_callback_worker(int nType, const char* pPayload, void* p
SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
{
- if ( pDocView->pDocument )
+ if ( pDocView->m_pImpl->m_pDocument )
{
- pDocView->pDocument->pClass->destroy( pDocView->pDocument );
- pDocView->pDocument = NULL;
+ pDocView->m_pImpl->m_pDocument->pClass->destroy( pDocView->m_pImpl->m_pDocument );
+ pDocView->m_pImpl->m_pDocument = 0;
}
- pDocView->pDocument = pDocView->pOffice->pClass->documentLoad( pDocView->pOffice,
+ pDocView->m_pImpl->m_pDocument = pDocView->m_pImpl->m_pOffice->pClass->documentLoad( pDocView->m_pImpl->m_pOffice,
pPath );
- if ( !pDocView->pDocument )
+ if ( !pDocView->m_pImpl->m_pDocument )
{
// FIXME: should have a GError parameter and populate it.
- char *pError = pDocView->pOffice->pClass->getError( pDocView->pOffice );
+ char *pError = pDocView->m_pImpl->m_pOffice->pClass->getError( pDocView->m_pImpl->m_pOffice );
fprintf( stderr, "Error opening document '%s'\n", pError );
return FALSE;
}
else
{
- pDocView->pDocument->pClass->initializeForRendering(pDocView->pDocument);
- pDocView->pDocument->pClass->registerCallback(pDocView->pDocument, &lok_docview_callback_worker, pDocView);
+ pDocView->m_pImpl->m_pDocument->pClass->initializeForRendering(pDocView->m_pImpl->m_pDocument);
+ pDocView->m_pImpl->m_pDocument->pClass->registerCallback(pDocView->m_pImpl->m_pDocument, &lok_docview_callback_worker, pDocView);
g_timeout_add(600, &lcl_handleTimeout, pDocView);
renderDocument(pDocView, NULL);
}
@@ -932,75 +994,79 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
return TRUE;
}
+SAL_DLLPUBLIC_EXPORT LibreOfficeKitDocument* lok_docview_get_document(LOKDocView* pDocView)
+{
+ return pDocView->m_pImpl->m_pDocument;
+}
+
SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZoom )
{
- pDocView->fZoom = fZoom;
+ pDocView->m_pImpl->m_fZoom = fZoom;
- if ( pDocView->pDocument )
+ if ( pDocView->m_pImpl->m_pDocument )
{
- renderDocument(pDocView, NULL);
+ renderDocument(pDocView, 0);
}
- // TODO: maybe remember and reset positiong?
}
SAL_DLLPUBLIC_EXPORT float lok_docview_get_zoom ( LOKDocView* pDocView )
{
- return pDocView->fZoom;
+ return pDocView->m_pImpl->m_fZoom;
}
SAL_DLLPUBLIC_EXPORT int lok_docview_get_parts( LOKDocView* pDocView )
{
- return pDocView->pDocument->pClass->getParts( pDocView->pDocument );
+ return pDocView->m_pImpl->m_pDocument->pClass->getParts( pDocView->m_pImpl->m_pDocument );
}
SAL_DLLPUBLIC_EXPORT int lok_docview_get_part( LOKDocView* pDocView )
{
- return pDocView->pDocument->pClass->getPart( pDocView->pDocument );
+ return pDocView->m_pImpl->m_pDocument->pClass->getPart( pDocView->m_pImpl->m_pDocument );
}
SAL_DLLPUBLIC_EXPORT void lok_docview_set_part( LOKDocView* pDocView, int nPart)
{
- pDocView->pDocument->pClass->setPart( pDocView->pDocument, nPart );
+ pDocView->m_pImpl->m_pDocument->pClass->setPart( pDocView->m_pImpl->m_pDocument, nPart );
renderDocument(pDocView, NULL);
}
SAL_DLLPUBLIC_EXPORT char* lok_docview_get_part_name( LOKDocView* pDocView, int nPart )
{
- return pDocView->pDocument->pClass->getPartName( pDocView->pDocument, nPart );
+ return pDocView->m_pImpl->m_pDocument->pClass->getPartName( pDocView->m_pImpl->m_pDocument, nPart );
}
SAL_DLLPUBLIC_EXPORT void lok_docview_set_partmode( LOKDocView* pDocView,
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list