[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 3 commits - include/svx libreofficekit/source svx/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Mar 26 06:40:46 PDT 2015
include/svx/sdr/table/tablecontroller.hxx | 2
include/svx/selectioncontroller.hxx | 2
libreofficekit/source/gtk/lokdocview.cxx | 64 +++++++++++++++---------------
svx/source/svdraw/selectioncontroller.cxx | 5 ++
svx/source/svdraw/svdmrkv.cxx | 11 +++++
svx/source/table/tablecontroller.cxx | 44 +++++++++++++++++---
6 files changed, 88 insertions(+), 40 deletions(-)
New commits:
commit 280d59e2967c6baa8738285501c15a7cc35379ff
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Mar 26 11:53:57 2015 +0100
SdrTableObj tiled rendering: implement selection callbacks
This makes selections of Impress tables visible. Double-click in an
empty cell doesn't select the cell yet, neither extending cell text
selections into table ones work, but it's a start.
Change-Id: Idb8921d980ac9d7ab363c68c91c1a9e6cf0918e3
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 119ff78..14f19f3 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -66,6 +66,7 @@
#include "tableundo.hxx"
#include "tablelayouter.hxx"
#include <vcl/msgbox.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <memory>
using ::editeng::SvxBorderLine;
@@ -2083,18 +2084,18 @@ void SvxTableController::updateSelectionOverlay()
{
sdr::overlay::OverlayObjectCell::RangeVector aRanges;
- Rectangle aRect;
+ Rectangle aStartRect, aEndRect;
CellPos aStart,aEnd;
getSelectedCells( aStart, aEnd );
- pTableObj->getCellBounds( aStart, aRect );
+ pTableObj->getCellBounds( aStart, aStartRect );
- basegfx::B2DRange a2DRange( basegfx::B2DPoint(aRect.Left(), aRect.Top()) );
- a2DRange.expand( basegfx::B2DPoint(aRect.Right(), aRect.Bottom()) );
+ basegfx::B2DRange a2DRange( basegfx::B2DPoint(aStartRect.Left(), aStartRect.Top()) );
+ a2DRange.expand( basegfx::B2DPoint(aStartRect.Right(), aStartRect.Bottom()) );
findMergeOrigin( aEnd );
- pTableObj->getCellBounds( aEnd, aRect );
- a2DRange.expand( basegfx::B2DPoint(aRect.Left(), aRect.Top()) );
- a2DRange.expand( basegfx::B2DPoint(aRect.Right(), aRect.Bottom()) );
+ pTableObj->getCellBounds( aEnd, aEndRect );
+ a2DRange.expand( basegfx::B2DPoint(aEndRect.Left(), aEndRect.Top()) );
+ a2DRange.expand( basegfx::B2DPoint(aEndRect.Right(), aEndRect.Bottom()) );
aRanges.push_back( a2DRange );
::Color aHighlight( COL_BLUE );
@@ -2122,6 +2123,27 @@ void SvxTableController::updateSelectionOverlay()
}
}
}
+
+ // If tiled rendering, emit callbacks for sdr table selection.
+ if (pOutDev && pTableObj->GetModel()->isTiledRendering())
+ {
+ // Left edge of aStartRect.
+ Rectangle aSelectionStart(aStartRect.Left(), aStartRect.Top(), aStartRect.Left(), aStartRect.Bottom());
+ // Right edge of aEndRect.
+ Rectangle aSelectionEnd(aEndRect.Right(), aEndRect.Top(), aEndRect.Right(), aEndRect.Bottom());
+ Rectangle aSelection(a2DRange.getMinX(), a2DRange.getMinY(), a2DRange.getMaxX(), a2DRange.getMaxY());
+
+ if (pOutDev->GetMapMode().GetMapUnit() == MAP_100TH_MM)
+ {
+ aSelectionStart = OutputDevice::LogicToLogic(aSelectionStart, MAP_100TH_MM, MAP_TWIP);
+ aSelectionEnd = OutputDevice::LogicToLogic(aSelectionEnd, MAP_100TH_MM, MAP_TWIP);
+ aSelection = OutputDevice::LogicToLogic(aSelection, MAP_100TH_MM, MAP_TWIP);
+ }
+
+ pTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, aSelectionStart.toString().getStr());
+ pTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, aSelectionEnd.toString().getStr());
+ pTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, aSelection.toString().getStr());
+ }
}
}
}
@@ -2134,6 +2156,14 @@ void SvxTableController::destroySelectionOverlay()
{
delete mpSelectionOverlay;
mpSelectionOverlay = 0;
+
+ if (mxTableObj->GetModel()->isTiledRendering())
+ {
+ // Clear the LOK text selection so far provided by this table.
+ mxTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, "EMPTY");
+ mxTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, "EMPTY");
+ mxTableObj->GetModel()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, "EMPTY");
+ }
}
}
commit de90fa0128675959b789ede5bb897b20bf74cb28
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Mar 26 14:22:55 2015 +0100
SdrMarkView tiled rendering: partially disable SdrTableObj graphic selection
If one or more cells are selected in an Impress table, then the shape
already provides its own text selection, don't overwrite it with the
generic graphic selection in this case.
Change-Id: I4f84a220df6cd9d225ed67d6f70ba2df6eff38af
diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx
index 92d893df..b6d610c 100644
--- a/include/svx/sdr/table/tablecontroller.hxx
+++ b/include/svx/sdr/table/tablecontroller.hxx
@@ -92,7 +92,7 @@ public:
SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage ) SAL_OVERRIDE;
SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel ) SAL_OVERRIDE;
- SVX_DLLPRIVATE bool hasSelectedCells() const { return mbCellSelectionMode || mpView->IsTextEdit(); }
+ SVX_DLLPRIVATE virtual bool hasSelectedCells() const SAL_OVERRIDE { return mbCellSelectionMode || mpView->IsTextEdit(); }
void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos );
void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
diff --git a/include/svx/selectioncontroller.hxx b/include/svx/selectioncontroller.hxx
index 6c15e28..f629b20 100644
--- a/include/svx/selectioncontroller.hxx
+++ b/include/svx/selectioncontroller.hxx
@@ -68,6 +68,8 @@ public:
if bNoParagraphFormats is true, no paragraph attributes are changed.
*/
virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
+ /// This is a table object, and one or more of its cells are selected.
+ virtual bool hasSelectedCells() const;
};
}
diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx
index 800d694..a2ff875 100644
--- a/svx/source/svdraw/selectioncontroller.cxx
+++ b/svx/source/svdraw/selectioncontroller.cxx
@@ -100,6 +100,11 @@ bool SelectionController::ApplyFormatPaintBrush( SfxItemSet& /*rFormatSet*/, boo
return false;
}
+bool SelectionController::hasSelectedCells() const
+{
+ return false;
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index fa03ab0..c40e76e 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -703,6 +703,17 @@ void SdrMarkView::SetMarkHandles()
{
return;
}
+
+ if (bTiledRendering && pMarkedObj->GetObjIdentifier() == OBJ_TABLE)
+ {
+ rtl::Reference<sdr::SelectionController> xController = static_cast<SdrView*>(this)->getSelectionController();
+ if (xController.is() && xController->hasSelectedCells())
+ {
+ // The table shape has selected cells, which provide text selection already -> no graphic selection.
+ GetModel()->libreOfficeKitCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY");
+ return;
+ }
+ }
}
Rectangle aRect(GetMarkedObjRect());
commit afc1d7fb98d58539ae6b6a954891a995fd37c8fd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Mar 26 09:45:41 2015 +0100
lokdocview: move motion handling to LOKDocView_Impl
Change-Id: Ibace4a943fb61e2f897c9571cc2c8814935b6e75
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 5793d7a..90fa014 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -121,9 +121,13 @@ struct LOKDocView_Impl
*/
static void getDragPoint(GdkRectangle* pHandle, GdkEventButton* pEvent, GdkPoint* pPoint);
/// Receives a button press event.
- static gboolean signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKDocView* pDocView);
+ static gboolean signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView* pDocView);
/// Implementation of button press event handler, invoked by signalButton().
gboolean signalButtonImpl(GdkEventButton* pEvent);
+ /// Receives a motion event.
+ static gboolean signalMotion(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocView* pDocView);
+ /// Implementation of motion event handler, invoked by signalMotion().
+ gboolean signalMotionImpl(GdkEventButton* pEvent);
};
LOKDocView_Impl::LOKDocView_Impl(LOKDocView* pDocView)
@@ -251,7 +255,7 @@ gboolean LOKDocView_Impl::signalButton(GtkWidget* /*pEventBox*/, GdkEventButton*
/// Receives a button press event.
gboolean LOKDocView_Impl::signalButtonImpl(GdkEventButton* pEvent)
{
- g_info("LOKDocView_Impl::ssignalButton: %d, %d (in twips: %d, %d)", (int)pEvent->x, (int)pEvent->y, (int)pixelToTwip(pEvent->x), (int)pixelToTwip(pEvent->y));
+ g_info("LOKDocView_Impl::signalButton: %d, %d (in twips: %d, %d)", (int)pEvent->x, (int)pEvent->y, (int)pixelToTwip(pEvent->x), (int)pixelToTwip(pEvent->y));
if (pEvent->type == GDK_BUTTON_RELEASE)
{
@@ -382,74 +386,70 @@ void LOKDocView_Impl::getDragPoint(GdkRectangle* pHandle, GdkEventButton* pEvent
pPoint->y = aCursor.y + (pEvent->y - aHandle.y);
}
-static void lok_docview_class_init( gpointer );
-static void lok_docview_init( GTypeInstance *, gpointer );
-static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpointer pData);
+gboolean LOKDocView_Impl::signalMotion(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKDocView* pDocView)
+{
+ return pDocView->m_pImpl->signalMotionImpl(pEvent);
+}
-gboolean lcl_signalMotion(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKDocView* pDocView)
+gboolean LOKDocView_Impl::signalMotionImpl(GdkEventButton* pEvent)
{
GdkPoint aPoint;
- if (pDocView->m_pImpl->m_bInDragMiddleHandle)
+ if (m_bInDragMiddleHandle)
{
g_info("lcl_signalMotion: dragging the middle handle");
- LOKDocView_Impl::getDragPoint(&pDocView->m_pImpl->m_aHandleMiddleRect, pEvent, &aPoint);
- pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
- pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_RESET,
- pDocView->m_pImpl->pixelToTwip(aPoint.x), pDocView->m_pImpl->pixelToTwip(aPoint.y));
+ LOKDocView_Impl::getDragPoint(&m_aHandleMiddleRect, pEvent, &aPoint);
+ m_pDocument->pClass->setTextSelection(m_pDocument, LOK_SETTEXTSELECTION_RESET, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
return FALSE;
}
- if (pDocView->m_pImpl->m_bInDragStartHandle)
+ if (m_bInDragStartHandle)
{
g_info("lcl_signalMotion: dragging the start handle");
- LOKDocView_Impl::getDragPoint(&pDocView->m_pImpl->m_aHandleStartRect, pEvent, &aPoint);
- pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
- pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_START,
- pDocView->m_pImpl->pixelToTwip(aPoint.x), pDocView->m_pImpl->pixelToTwip(aPoint.y));
+ LOKDocView_Impl::getDragPoint(&m_aHandleStartRect, pEvent, &aPoint);
+ m_pDocument->pClass->setTextSelection(m_pDocument, LOK_SETTEXTSELECTION_START, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
return FALSE;
}
- if (pDocView->m_pImpl->m_bInDragEndHandle)
+ if (m_bInDragEndHandle)
{
g_info("lcl_signalMotion: dragging the end handle");
- LOKDocView_Impl::getDragPoint(&pDocView->m_pImpl->m_aHandleEndRect, pEvent, &aPoint);
- pDocView->m_pImpl->m_pDocument->pClass->setTextSelection(
- pDocView->m_pImpl->m_pDocument, LOK_SETTEXTSELECTION_END,
- pDocView->m_pImpl->pixelToTwip(aPoint.x), pDocView->m_pImpl->pixelToTwip(aPoint.y));
+ LOKDocView_Impl::getDragPoint(&m_aHandleEndRect, pEvent, &aPoint);
+ m_pDocument->pClass->setTextSelection(m_pDocument, LOK_SETTEXTSELECTION_END, pixelToTwip(aPoint.x), pixelToTwip(aPoint.y));
return FALSE;
}
for (int i = 0; i < GRAPHIC_HANDLE_COUNT; ++i)
{
- if (pDocView->m_pImpl->m_bInDragGraphicHandles[i])
+ if (m_bInDragGraphicHandles[i])
{
g_info("lcl_signalMotion: dragging the graphic handle #%d", i);
return FALSE;
}
}
- if (pDocView->m_pImpl->m_bInDragGraphicSelection)
+ if (m_bInDragGraphicSelection)
{
g_info("lcl_signalMotion: dragging the graphic selection");
return FALSE;
}
GdkRectangle aMotionInTwipsInTwips;
- aMotionInTwipsInTwips.x = pDocView->m_pImpl->pixelToTwip(pEvent->x);
- aMotionInTwipsInTwips.y = pDocView->m_pImpl->pixelToTwip(pEvent->y);
+ aMotionInTwipsInTwips.x = pixelToTwip(pEvent->x);
+ aMotionInTwipsInTwips.y = pixelToTwip(pEvent->y);
aMotionInTwipsInTwips.width = 1;
aMotionInTwipsInTwips.height = 1;
- if (gdk_rectangle_intersect(&aMotionInTwipsInTwips, &pDocView->m_pImpl->m_aGraphicSelection, 0))
+ if (gdk_rectangle_intersect(&aMotionInTwipsInTwips, &m_aGraphicSelection, 0))
{
g_info("lcl_signalMotion: start of drag graphic selection");
- pDocView->m_pImpl->m_bInDragGraphicSelection = true;
- pDocView->m_pImpl->m_pDocument->pClass->setGraphicSelection(
- pDocView->m_pImpl->m_pDocument, LOK_SETGRAPHICSELECTION_START,
- pDocView->m_pImpl->pixelToTwip(pEvent->x),
- pDocView->m_pImpl->pixelToTwip(pEvent->y));
+ m_bInDragGraphicSelection = true;
+ m_pDocument->pClass->setGraphicSelection(m_pDocument, LOK_SETGRAPHICSELECTION_START, pixelToTwip(pEvent->x), pixelToTwip(pEvent->y));
return FALSE;
}
return FALSE;
}
+static void lok_docview_class_init( gpointer );
+static void lok_docview_init( GTypeInstance *, gpointer );
+static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpointer pData);
+
SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
{
static guint lok_docview_type = 0;
@@ -514,7 +514,7 @@ static void lok_docview_init( GTypeInstance* pInstance, gpointer )
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(LOKDocView_Impl::signalButton), pDocView);
gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "button-release-event", GTK_SIGNAL_FUNC(LOKDocView_Impl::signalButton), pDocView);
- gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "motion-notify-event", GTK_SIGNAL_FUNC(lcl_signalMotion), pDocView);
+ gtk_signal_connect(GTK_OBJECT(pDocView->m_pImpl->m_pEventBox), "motion-notify-event", GTK_SIGNAL_FUNC(LOKDocView_Impl::signalMotion), pDocView);
gtk_widget_show( pDocView->m_pImpl->m_pEventBox );
More information about the Libreoffice-commits
mailing list