[Libreoffice-commits] core.git: 3 commits - editeng/source include/editeng sd/qa sd/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Oct 13 07:43:13 PDT 2015
editeng/source/editeng/editview.cxx | 5 +++++
editeng/source/editeng/impedit.cxx | 22 +++++++++++++++++-----
editeng/source/editeng/impedit.hxx | 1 +
editeng/source/outliner/outlvw.cxx | 5 +++++
include/editeng/editview.hxx | 2 ++
include/editeng/outliner.hxx | 1 +
sd/qa/unit/tiledrendering/tiledrendering.cxx | 20 +++++++++++++++++---
sd/source/ui/view/Outliner.cxx | 25 ++++++++++++++++++++++++-
8 files changed, 72 insertions(+), 9 deletions(-)
New commits:
commit 28a5d4b5d3641837f3be8bc39ead111f9bba7015
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Oct 13 16:38:37 2015 +0200
CppunitTest_sd_tiledrendering: CALLBACK_SEARCH_RESULT_SELECTION testcase
Change-Id: I8a2fcaad5806ef204cdac0f6eaac615d50d6d9e8
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 2065dd8..1313b0a 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -7,6 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <test/xmltesttools.hxx>
+#include <boost/property_tree/json_parser.hpp>
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <com/sun/star/frame/Desktop.hpp>
@@ -19,9 +23,6 @@
#include <editeng/outliner.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
-#include <test/bootstrapfixture.hxx>
-#include <test/xmltesttools.hxx>
-#include <unotest/macros_test.hxx>
#include <DrawDocShell.hxx>
#include <ViewShell.hxx>
@@ -78,6 +79,7 @@ private:
std::vector<Rectangle> m_aSelection;
bool m_bFound;
sal_Int32 m_nPart;
+ std::vector<OString> m_aSearchResultSelection;
#endif
};
@@ -182,6 +184,16 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
m_nPart = aPayload.toInt32();
}
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;
}
}
@@ -387,6 +399,8 @@ void SdTiledRenderingTest::testSearch()
lcl_search("bbb");
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart);
CPPUNIT_ASSERT_EQUAL(true, m_bFound);
+ // This was 0; should be 1 match for "find".
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), m_aSearchResultSelection.size());
// This should trigger the not-found callback.
lcl_search("ccc");
commit 395cfab05752b87ae419304789d894c0fe9a98c2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Oct 13 15:55:55 2015 +0200
sd tiled rendering: implement LOK_CALLBACK_SEARCH_RESULT_SELECTION
Given that sd doesn't support find-all yet, this works for normal find
only at the moment (so it may report multiple rectangles, but always a
single match).
Change-Id: I47bd0d0161b9d1dc843bb503f5521f311fc158c4
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index f080488..e905284 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -18,6 +18,7 @@
*/
#include "Outliner.hxx"
+#include <boost/property_tree/json_parser.hpp>
#include <vcl/wrkwin.hxx>
#include <vcl/settings.hxx>
@@ -71,6 +72,7 @@
#include <svx/svxids.hrc>
#include <editeng/editerr.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/string.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -714,11 +716,32 @@ bool Outliner::SearchAndReplaceOnce()
mpDrawDocument->GetDocSh()->SetWaitCursor( false );
- // notify LibreOfficeKit about changed page
if (pViewShell && pViewShell->GetDoc()->isTiledRendering() && mbStringFound)
{
+ // notify LibreOfficeKit about changed page
OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
+
+ // also about search result selections
+ std::vector<Rectangle> aLogicRects;
+ pOutlinerView->GetSelectionRectangles(aLogicRects);
+
+ boost::property_tree::ptree aTree;
+ aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
+
+ std::vector<OString> aLogicRectStrings;
+ std::transform(aLogicRects.begin(), aLogicRects.end(), std::back_inserter(aLogicRectStrings), [](const Rectangle& rRectangle) { return rRectangle.toString(); });
+ OString sRectangles = comphelper::string::join("; ", aLogicRectStrings);
+ boost::property_tree::ptree aChildren;
+ boost::property_tree::ptree aChild;
+ aChild.put("", sRectangles.getStr());
+ aChildren.push_back(std::make_pair("", aChild));
+ aTree.add_child("searchResultSelection", aChildren);
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ aPayload = aStream.str().c_str();
+ pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
}
return mbEndOfSearch;
commit f7764214f2ab8aff030aaeb29efd693275822761
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Oct 13 15:54:56 2015 +0200
editeng: add EditView::GetSelectionRectangles()
This gives sd access to the selection rectangles as well (as opposed
only to the document model positions of selections).
Change-Id: Icb903e91f9e868573403b360bbe839705ddf2916
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 4e36573..45790d1 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -264,6 +264,11 @@ SvtScriptType EditView::GetSelectedScriptType() const
return pImpEditView->pEditEngine->GetScriptType( pImpEditView->GetEditSelection() );
}
+void EditView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const
+{
+ return pImpEditView->GetSelectionRectangles(rLogicRects);
+}
+
void EditView::Paint( const Rectangle& rRect, OutputDevice* pTargetDevice )
{
pImpEditView->pEditEngine->pImpEditEngine->Paint( pImpEditView, rRect, pTargetDevice );
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 83e30ff..4b41e79 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -185,12 +185,10 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
// pRegion: When not NULL, then only calculate Region.
+ vcl::Region* pOldRegion = pRegion;
vcl::Region aRegion;
- if (isTiledRendering())
- {
- assert(!pRegion);
+ if (isTiledRendering() && !pRegion)
pRegion = &aRegion;
- }
tools::PolyPolygon* pPolyPoly = NULL;
if ( pRegion )
@@ -326,7 +324,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
{
*pRegion = vcl::Region( *pPolyPoly );
- if (isTiledRendering())
+ if (isTiledRendering() && !pOldRegion)
{
bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM;
OString sRectangle;
@@ -378,6 +376,20 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
}
}
+void ImpEditView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects)
+{
+ bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM;
+ vcl::Region aRegion;
+ DrawSelection(aEditSelection, &aRegion);
+ aRegion.GetRegionRectangles(rLogicRects);
+
+ for (Rectangle& rRectangle : rLogicRects)
+ {
+ if (bMm100ToTwip)
+ rRectangle = OutputDevice::LogicToLogic(rRectangle, MAP_100TH_MM, MAP_TWIP);
+ }
+}
+
void ImpEditView::ImplDrawHighlightRect( OutputDevice* _pTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, tools::PolyPolygon* pPolyPoly )
{
if ( rDocPosTopLeft.X() != rDocPosBottomRight.X() )
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 29c0a99..0160619 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -319,6 +319,7 @@ public:
void DrawSelection() { DrawSelection( aEditSelection ); }
void DrawSelection( EditSelection, vcl::Region* pRegion = NULL, OutputDevice* pTargetDevice = NULL );
+ void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects);
vcl::Window* GetWindow() const { return pOutWin; }
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index e2399dd..902d6a0 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1222,6 +1222,11 @@ void OutlinerView::SetSelection( const ESelection& rSel )
pEditView->SetSelection( rSel );
}
+void OutlinerView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const
+{
+ pEditView->GetSelectionRectangles(rLogicRects);
+}
+
void OutlinerView::SetReadOnly( bool bReadOnly )
{
pEditView->SetReadOnly( bReadOnly );
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 835e540..d6b21f2 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -122,6 +122,8 @@ public:
ESelection GetSelection() const;
void SetSelection( const ESelection& rNewSel );
bool SelectCurrentWord( sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
+ /// Returns the rectangles of the current selection in TWIPs.
+ void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const;
bool IsInsertMode() const;
void SetInsertMode( bool bInsert );
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index b996ef2..d797f9d 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -314,6 +314,7 @@ public:
void SetVisArea( const Rectangle& rRect );
void SetSelection( const ESelection& );
+ void GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const;
void RemoveAttribs( bool bRemoveParaAttribs = false, sal_uInt16 nWhich = 0, bool bKeepLanguages = false );
void RemoveAttribsKeepLanguages( bool bRemoveParaAttribs );
More information about the Libreoffice-commits
mailing list