[Libreoffice-commits] core.git: desktop/qa sc/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Oct 8 02:50:16 PDT 2015
desktop/qa/desktop_lib/test_desktop_lib.cxx | 13 ++++++++++++
sc/source/ui/inc/gridwin.hxx | 2 +
sc/source/ui/view/gridwin.cxx | 23 ++++++++++++++++++---
sc/source/ui/view/viewfun2.cxx | 30 +++++++++++++++++++++++++---
4 files changed, 62 insertions(+), 6 deletions(-)
New commits:
commit a42f582e0e8ee4118415632795184620c6b8058c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Oct 8 11:49:13 2015 +0200
sc tiled rendering: implement LOK_CALLBACK_SEARCH_RESULT_SELECTION
Change-Id: Iaca2c1807a6e92cf7a87b0843000d65aea45fe7b
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3e00e59..e77bc89 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -73,6 +73,7 @@ public:
uno::Reference<lang::XComponent> mxComponent;
OString m_aTextSelection;
+ std::vector<OString> m_aSearchResultSelection;
};
LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType)
@@ -123,6 +124,16 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
m_aTextSelection = pPayload;
}
break;
+ case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
+ {
+ m_aSearchResultSelection.clear();
+ boost::property_tree::ptree aTree;
+ std::stringstream aStream(pPayload);
+ boost::property_tree::read_json(aStream, aTree);
+ for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("searchResultSelection"))
+ m_aSearchResultSelection.push_back(rValue.second.data().c_str());
+ }
+ break;
}
}
@@ -256,6 +267,8 @@ void DesktopLOKTest::testSearchCalc()
} while (nIndex >= 0);
// This was 1, find-all only found one match.
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aSelections.size());
+ // Make sure that we get exactly as many rectangle lists as matches.
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSearchResultSelection.size());
closeDoc();
comphelper::LibreOfficeKit::setActive(false);
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index ae2bc5d..689b8d5 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -336,6 +336,8 @@ public:
/// @see vcl::ITiledRenderable::setTextSelection() for the values of nType.
/// Coordinates are in pixels.
void SetCellSelectionPixel(int nType, int nPixelX, int nPixelY);
+ /// Get the cell selection, coordinates are in logic units.
+ void GetCellSelection(std::vector<Rectangle>& rLogicRects);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 395c4b5..5c6cb5e 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5886,8 +5886,12 @@ void ScGridWindow::UpdateCopySourceOverlay()
SetMapMode( aOldMode );
}
-/// Turn the selection ranges rRectangles into the LibreOfficeKit selection, and call the callback.
-static void updateLibreOfficeKitSelection(ScViewData* pViewData, ScDrawLayer* pDrawLayer, const std::vector<Rectangle>& rRectangles)
+/**
+ * Turn the selection ranges rRectangles into the LibreOfficeKit selection, and call the callback.
+ *
+ * @param pLogicRects - if not 0, then don't invoke the callback, just collect the rectangles in the pointed vector.
+ */
+static void updateLibreOfficeKitSelection(ScViewData* pViewData, ScDrawLayer* pDrawLayer, const std::vector<Rectangle>& rRectangles, std::vector<Rectangle>* pLogicRects = 0)
{
if (!pDrawLayer->isTiledRendering())
return;
@@ -5907,9 +5911,15 @@ static void updateLibreOfficeKitSelection(ScViewData* pViewData, ScDrawLayer* pD
Rectangle aRect(aRectangle.Left() / nPPTX, aRectangle.Top() / nPPTY,
aRectangle.Right() / nPPTX, aRectangle.Bottom() / nPPTY);
- aRectangles.push_back(aRect.toString());
+ if (pLogicRects)
+ pLogicRects->push_back(aRect);
+ else
+ aRectangles.push_back(aRect.toString());
}
+ if (pLogicRects)
+ return;
+
// selection start handle
Rectangle aStart(aBoundingBox.Left() / nPPTX, aBoundingBox.Top() / nPPTY,
aBoundingBox.Left() / nPPTX, (aBoundingBox.Top() / nPPTY) + 256);
@@ -6093,6 +6103,13 @@ void ScGridWindow::UpdateCursorOverlay()
SetMapMode( aOldMode );
}
+void ScGridWindow::GetCellSelection(std::vector<Rectangle>& rLogicRects)
+{
+ std::vector<Rectangle> aPixelRects;
+ GetSelectionRects(aPixelRects);
+ updateLibreOfficeKitSelection(pViewData, pViewData->GetDocument()->GetDrawLayer(), aPixelRects, &rLogicRects);
+}
+
void ScGridWindow::DeleteSelectionOverlay()
{
mpOOSelection.reset();
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index dc0ef09..36b2311 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -89,6 +89,7 @@
#include <vector>
#include <memory>
+#include <boost/property_tree/json_parser.hpp>
using namespace com::sun::star;
using ::editeng::SvxBorderLine;
@@ -1837,20 +1838,43 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
SetCursor( nCol, nRow, true );
- // Don't move cell selection handles for find-all: selection of all but the first result would be lost.
- if (rDoc.GetDrawLayer()->isTiledRendering() && nCommand == SvxSearchCmd::FIND)
+ if (rDoc.GetDrawLayer()->isTiledRendering())
{
Point aCurPos = GetViewData().GetScrPos(nCol, nRow, GetViewData().GetActivePart());
// just update the cell selection
ScGridWindow* pGridWindow = GetViewData().GetActiveWin();
- if (pGridWindow)
+ // Don't move cell selection handles for find-all: selection of all but the first result would be lost.
+ if (pGridWindow && nCommand == SvxSearchCmd::FIND)
{
// move the cell selection handles
pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_RESET, aCurPos.X(), aCurPos.Y());
pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_START, aCurPos.X(), aCurPos.Y());
pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_END, aCurPos.X(), aCurPos.Y());
}
+
+ if (pGridWindow)
+ {
+ std::vector<Rectangle> aLogicRects;
+ pGridWindow->GetCellSelection(aLogicRects);
+
+ boost::property_tree::ptree aTree;
+ aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr());
+
+ boost::property_tree::ptree aSelections;
+ for (const Rectangle& rLogicRect : aLogicRects)
+ {
+ boost::property_tree::ptree aSelection;
+ aSelection.put("", rLogicRect.toString().getStr());
+ aSelections.push_back(std::make_pair("", aSelection));
+ }
+ aTree.add_child("searchResultSelection", aSelections);
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ OString aPayload = aStream.str().c_str();
+ rDoc.GetDrawLayer()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
+ }
}
if ( nCommand == SvxSearchCmd::REPLACE
More information about the Libreoffice-commits
mailing list