diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-10-08 11:49:13 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-10-08 11:49:13 +0200 |
commit | a42f582e0e8ee4118415632795184620c6b8058c (patch) | |
tree | 5cc105f23c42ae55c6ef6212b40b49eeb9744df0 /sc | |
parent | 06d253ef3a3339300eff4fd38db728301516bf4d (diff) |
sc tiled rendering: implement LOK_CALLBACK_SEARCH_RESULT_SELECTION
Change-Id: Iaca2c1807a6e92cf7a87b0843000d65aea45fe7b
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 23 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 30 |
3 files changed, 49 insertions, 6 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index ae2bc5d6f0bb..689b8d5c8e2b 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 395c4b5c4a0d..5c6cb5e24e13 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 dc0ef0930f06..36b23114e1c5 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 |