comphelper/source/misc/string.cxx | 11 +++ desktop/CppunitTest_desktop_lib.mk | 3 desktop/qa/data/search.ods |binary desktop/qa/desktop_lib/test_desktop_lib.cxx | 89 +++++++++++++++++++++++++++- desktop/source/lib/init.cxx | 8 ++ editeng/source/editeng/impedit.cxx | 9 +- include/comphelper/string.hxx | 4 + sc/source/ui/inc/gridwin.hxx | 2 sc/source/ui/view/gridwin.cxx | 34 +++++++--- sc/source/ui/view/viewfun2.cxx | 30 ++++++++- sw/source/core/crsr/crsrsh.cxx | 16 +++-- sw/source/core/crsr/viscrs.cxx | 20 ++---- sw/source/uibase/uiview/viewsrch.cxx | 12 +-- 13 files changed, 191 insertions(+), 47 deletions(-)
New commits: commit 1b4d1bd39d2308adf22c1ee03fbbd0b21fb02f9b Author: Miklos Vajna <[email protected]> Date: Thu Oct 8 11:49:13 2015 +0200 sc tiled rendering: implement LOK_CALLBACK_SEARCH_RESULT_SELECTION Change-Id: Iaca2c1807a6e92cf7a87b0843000d65aea45fe7b (cherry picked from commit a42f582e0e8ee4118415632795184620c6b8058c) 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 e4bb56a..b8425a8 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -337,6 +337,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 1320e27..f24b42f 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5890,8 +5890,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; @@ -5911,9 +5915,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); @@ -6097,6 +6107,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 555492f..2be84a4 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -91,6 +91,7 @@ #include <boost/scoped_ptr.hpp> #include <vector> #include <memory> +#include <boost/property_tree/json_parser.hpp> using namespace com::sun::star; using ::editeng::SvxBorderLine; @@ -1838,20 +1839,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 commit 7e255ced7931ab80b19808864b8f718ea2a915ba Author: Miklos Vajna <[email protected]> Date: Thu Oct 8 10:56:49 2015 +0200 CppunitTest_desktop_lib: add Calc find-all testcase Fails without commit a31f95b180728c1c671930913b4b4ad96ebcda5f (sc tiled rendering: fix showing all search results, 2015-10-07). Change-Id: Ibc01d468168367f789b3f5046808104fa3f5ef18 (cherry picked from commit 97c414758d3d8aa3cc2233d52612cf0a33c24c34) diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk index be39460..0c963f9 100644 --- a/desktop/CppunitTest_desktop_lib.mk +++ b/desktop/CppunitTest_desktop_lib.mk @@ -56,11 +56,14 @@ $(eval $(call gb_CppunitTest_use_components,desktop_lib,\ svtools/util/svt \ sw/util/sw \ sw/util/swd \ + sc/util/sc \ + sc/util/scd \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ unoxml/source/service/unoxml \ xmloff/util/xo \ + i18npool/source/search/i18nsearch \ )) $(eval $(call gb_CppunitTest_use_configuration,desktop_lib)) diff --git a/desktop/qa/data/search.ods b/desktop/qa/data/search.ods new file mode 100644 index 0000000..ea1d731 Binary files /dev/null and b/desktop/qa/data/search.ods differ diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index a7696d8..3e00e59 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -16,6 +16,11 @@ #include <sfx2/objsh.hxx> #include <sfx2/lokhelper.hxx> #include <test/unoapi_test.hxx> +#include <comphelper/lok.hxx> +#include <comphelper/dispatchcommand.hxx> +#include <comphelper/propertysequence.hxx> +#include <svl/srchitem.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include "../../inc/lib/init.hxx" @@ -45,14 +50,17 @@ public: UnoApiTest::tearDown(); }; - LibLODocument_Impl* loadDoc(const char* pName); + LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType eType = LOK_DOCTYPE_TEXT); void closeDoc(); + static void callback(int nType, const char* pPayload, void* pData); + void callbackImpl(int nType, const char* pPayload); void testGetStyles(); void testGetFonts(); void testCreateView(); void testGetFilterTypes(); void testGetPartPageRectangles(); + void testSearchCalc(); CPPUNIT_TEST_SUITE(DesktopLOKTest); CPPUNIT_TEST(testGetStyles); @@ -60,16 +68,31 @@ public: CPPUNIT_TEST(testCreateView); CPPUNIT_TEST(testGetFilterTypes); CPPUNIT_TEST(testGetPartPageRectangles); + CPPUNIT_TEST(testSearchCalc); CPPUNIT_TEST_SUITE_END(); uno::Reference<lang::XComponent> mxComponent; + OString m_aTextSelection; }; -LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName) +LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType) { OUString aFileURL; createFileURL(OUString::createFromAscii(pName), aFileURL); - mxComponent = loadFromDesktop(aFileURL, "com.sun.star.text.TextDocument"); + OUString aService; + switch (eType) + { + case LOK_DOCTYPE_TEXT: + aService = "com.sun.star.text.TextDocument"; + break; + case LOK_DOCTYPE_SPREADSHEET: + aService = "com.sun.star.sheet.SpreadsheetDocument"; + break; + default: + CPPUNIT_ASSERT(false); + break; + } + mxComponent = loadFromDesktop(aFileURL, aService); if (!mxComponent.is()) { CPPUNIT_ASSERT(false); @@ -86,6 +109,23 @@ void DesktopLOKTest::closeDoc() } } +void DesktopLOKTest::callback(int nType, const char* pPayload, void* pData) +{ + static_cast<DesktopLOKTest*>(pData)->callbackImpl(nType, pPayload); +} + +void DesktopLOKTest::callbackImpl(int nType, const char* pPayload) +{ + switch (nType) + { + case LOK_CALLBACK_TEXT_SELECTION: + { + m_aTextSelection = pPayload; + } + break; + } +} + void DesktopLOKTest::testGetStyles() { LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); @@ -191,6 +231,36 @@ void DesktopLOKTest::testGetFilterTypes() free(pJSON); } +void DesktopLOKTest::testSearchCalc() +{ + LibLibreOffice_Impl aOffice; + comphelper::LibreOfficeKit::setActive(); + LibLODocument_Impl* pDocument = loadDoc("search.ods"); + pDocument->pClass->initializeForRendering(pDocument); + pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); + + uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + {"SearchItem.SearchString", uno::makeAny(OUString("foo"))}, + {"SearchItem.Backward", uno::makeAny(false)}, + {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))}, + })); + comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); + + std::vector<OString> aSelections; + sal_Int32 nIndex = 0; + do + { + OString aToken = m_aTextSelection.getToken(0, ';', nIndex); + aSelections.push_back(aToken); + } while (nIndex >= 0); + // This was 1, find-all only found one match. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aSelections.size()); + + closeDoc(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit c7e35d99c8a6c5ba1e8454f62a60aebf00568920 Author: Miklos Vajna <[email protected]> Date: Thu Oct 8 10:27:53 2015 +0200 lok::Document::initializeForRendering(): handle lack of lok_init() Normally lok_init() sets the component context, but not e.g. during unit testing. Change-Id: If3760f31af2e4b870f65e5aa7557607e8b6a1114 (cherry picked from commit de1f156c6a35757d74b0e337b02743f1962ff0ae) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 5f07d51..9681954 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -573,6 +573,14 @@ static void doc_iniUnoCommands () return; } + if (!xContext.is()) + xContext = comphelper::getProcessComponentContext(); + if (!xContext.is()) + { + SAL_WARN("lok", "iniUnoCommands: Component context is not available"); + return; + } + SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool(pViewFrame); uno::Reference<util::XURLTransformer> xParser(util::URLTransformer::create(xContext)); commit c2ab2f9a5a080db725dc94c63dcc917bf44f6847 Author: Miklos Vajna <[email protected]> Date: Thu Oct 8 10:07:46 2015 +0200 sc tiled rendering: no need to show this dialog And it just causes problems during unit testing. Change-Id: Ie8524b726ae2709bab707df9b2984f07357e3059 (cherry picked from commit dd7d97589bcbed22cf2dd12b574fc28baedf24af) diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 295d3db..555492f 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -86,6 +86,7 @@ #include <columnspanset.hxx> #include <rowheightcontext.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <comphelper/lok.hxx> #include <boost/scoped_ptr.hpp> #include <vector> @@ -1737,7 +1738,7 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, if (nCommand == SvxSearchCmd::FIND_ALL || nCommand == SvxSearchCmd::REPLACE_ALL) { SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - if (pViewFrm) + if (pViewFrm && !comphelper::LibreOfficeKit::isActive()) { pViewFrm->ShowChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId(), true); SfxChildWindow* pWnd = pViewFrm->GetChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId()); commit e5a15f403ee735bd3c63748006b5ff17cec5a84b Author: Miklos Vajna <[email protected]> Date: Thu Oct 8 08:37:12 2015 +0200 editeng, sw, sc: use comphelper::string::join() Change-Id: I9b0a32271a965bc4089720ccb61b26b67ceab7b2 (cherry picked from commit 1cb13d87b5d887718f6d81a842444b7251dc64cf) diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 08d990b..7fac113 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -46,6 +46,7 @@ #include <sot/exchange.hxx> #include <sot/formats.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <comphelper/string.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -351,17 +352,15 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, aEnd.toString().getStr()); } - std::stringstream ss; + std::vector<OString> v; for (size_t i = 0; i < aRectangles.size(); ++i) { Rectangle& rRectangle = aRectangles[i]; - if (i) - ss << "; "; if (bMm100ToTwip) rRectangle = OutputDevice::LogicToLogic(rRectangle, MAP_100TH_MM, MAP_TWIP); - ss << rRectangle.toString().getStr(); + v.push_back(rRectangle.toString().getStr()); } - sRectangle = ss.str().c_str(); + sRectangle = comphelper::string::join("; ", v); } libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr()); } diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index cfc0b5e..1320e27 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -134,6 +134,7 @@ #include <svx/sdr/overlay/overlaymanager.hxx> #include <vcl/svapp.hxx> #include <svx/sdr/overlay/overlayselection.hxx> +#include <comphelper/string.hxx> #define LOK_USE_UNSTABLE_API #include <LibreOfficeKit/LibreOfficeKitEnums.h> @@ -5899,9 +5900,8 @@ static void updateLibreOfficeKitSelection(ScViewData* pViewData, ScDrawLayer* pD double nPPTY = pViewData->GetPPTY(); Rectangle aBoundingBox; - std::stringstream ss; + std::vector<OString> aRectangles; - bool bIsFirst = true; for (auto aRectangle : rRectangles) { aRectangle.Right() += 1; @@ -5909,14 +5909,9 @@ static void updateLibreOfficeKitSelection(ScViewData* pViewData, ScDrawLayer* pD aBoundingBox.Union(aRectangle); - if (bIsFirst) - bIsFirst = false; - else - ss << "; "; - Rectangle aRect(aRectangle.Left() / nPPTX, aRectangle.Top() / nPPTY, aRectangle.Right() / nPPTX, aRectangle.Bottom() / nPPTY); - ss << aRect.toString().getStr(); + aRectangles.push_back(aRect.toString()); } // selection start handle @@ -5930,7 +5925,7 @@ static void updateLibreOfficeKitSelection(ScViewData* pViewData, ScDrawLayer* pD pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, aEnd.toString().getStr()); // the selection itself - pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, ss.str().c_str()); + pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, comphelper::string::join("; ", aRectangles).getStr()); } void ScGridWindow::UpdateCursorOverlay() diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index b23843c..9a11182 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -65,6 +65,7 @@ #include <IDocumentLayoutAccess.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> +#include <comphelper/string.hxx> using namespace com::sun::star; using namespace util; @@ -1205,14 +1206,19 @@ OUString SwCrsrShell::getPageRectangles() { CurrShell aCurr(this); SwRootFrm* pLayout = GetLayout(); - std::stringstream ss; + std::vector<OString> v; for (const SwFrm* pFrm = pLayout->GetLower(); pFrm; pFrm = pFrm->GetNext()) { - if (pFrm != pLayout->GetLower()) - ss << "; "; - ss << pFrm->Frm().Left() << ", " << pFrm->Frm().Top() << ", " << pFrm->Frm().Width() << ", " << pFrm->Frm().Height(); + std::vector<OString> aRectangle + { + OString::number(pFrm->Frm().Left()), + OString::number(pFrm->Frm().Top()), + OString::number(pFrm->Frm().Width()), + OString::number(pFrm->Frm().Height()) + }; + v.push_back(comphelper::string::join(", ", aRectangle)); } - return OUString::fromUtf8(ss.str().c_str()); + return OUString::fromUtf8(comphelper::string::join("; ", v).getStr()); } /// go to the next SSelection diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 8087561..ff37421 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -55,6 +55,7 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> +#include <comphelper/string.hxx> #include <paintfrm.hxx> // Here static members are defined. They will get changed on alteration of the @@ -392,15 +393,13 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles) } } - std::stringstream ss; + std::vector<OString> aRect; for (size_type i = 0; i < size(); ++i) { const SwRect& rRect = (*this)[i]; - if (i) - ss << "; "; - ss << rRect.SVRect().toString().getStr(); + aRect.push_back(rRect.SVRect().toString()); } - OString sRect = ss.str().c_str(); + OString sRect = comphelper::string::join("; ", aRect); if (!pSelectionRectangles) { if (comphelper::LibreOfficeKit::isViewCallback()) @@ -606,20 +605,15 @@ void SwShellCrsr::Show() if (comphelper::LibreOfficeKit::isActive()) { - std::stringstream ss; - bool bFirst = true; + std::vector<OString> aRect; for (size_t i = 0; i < aSelectionRectangles.size(); ++i) { const OString& rSelectionRectangle = aSelectionRectangles[i]; if (rSelectionRectangle.isEmpty()) continue; - if (bFirst) - bFirst = false; - else - ss << "; "; - ss << rSelectionRectangle.getStr(); + aRect.push_back(rSelectionRectangle); } - OString sRect = ss.str().c_str(); + OString sRect = comphelper::string::join("; ", aRect); if (comphelper::LibreOfficeKit::isViewCallback()) GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr()); else diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index c8d3e7a..6879dad 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -60,6 +60,7 @@ #include <unocrsr.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> +#include <comphelper/string.hxx> #include <view.hrc> #include <SwRewriter.hxx> @@ -118,20 +119,15 @@ static void lcl_emitSearchResultCallbacks(sal_uInt16 nFound, SvxSearchItem* pSea { std::vector<OString> aSelectionRectangles; pShellCrsr->SwSelPaintRects::Show(&aSelectionRectangles); - std::stringstream ss; - bool bFirst = true; + std::vector<OString> aRect; for (size_t i = 0; i < aSelectionRectangles.size(); ++i) { const OString& rSelectionRectangle = aSelectionRectangles[i]; if (rSelectionRectangle.isEmpty()) continue; - if (bFirst) - bFirst = false; - else - ss << "; "; - ss << rSelectionRectangle.getStr(); + aRect.push_back(rSelectionRectangle); } - OString sRect = ss.str().c_str(); + OString sRect = comphelper::string::join("; ", aRect); aMatches.push_back(sRect); } } commit 6d410a844e4383777fae69b6358e8ec3604713fd Author: Miklos Vajna <[email protected]> Date: Thu Oct 8 08:33:09 2015 +0200 comphelper: add string::join() If there is a need for it, this could be extended later to work with uno sequences and/or OUStrings as well. Change-Id: Id0af8b1755c8e4b668720563d10a052337e1b2c9 (cherry picked from commit fce720b3e4691eb3b7deef1d005d76b23123a5cb) diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx index 9839174..c6fa2fd 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -269,6 +269,17 @@ uno::Sequence< OUString > return kws; } +OString join(const OString& rSeparator, const std::vector<OString>& rSequence) +{ + OStringBuffer aBuffer; + for (size_t i = 0; i < rSequence.size(); ++i) + { + if (i != 0) + aBuffer.append(rSeparator); + aBuffer.append(rSequence[i]); + } + return aBuffer.makeStringAndClear(); +} sal_Int32 compareNatural( const OUString & rLHS, const OUString & rRHS, const uno::Reference< i18n::XCollator > &rCollator, diff --git a/include/comphelper/string.hxx b/include/comphelper/string.hxx index b968037..8d25522 100644 --- a/include/comphelper/string.hxx +++ b/include/comphelper/string.hxx @@ -23,6 +23,7 @@ #include <sal/config.h> #include <cstddef> +#include <vector> #include <comphelper/comphelperdllapi.h> #include <sal/types.h> #include <rtl/strbuf.hxx> @@ -310,6 +311,9 @@ COMPHELPER_DLLPUBLIC sal_Int32 indexOfAny(OUString const& rIn, COMPHELPER_DLLPUBLIC OUString convertCommaSeparated( ::com::sun::star::uno::Sequence< OUString > const & i_rSeq); +/// Return a string which is the concatenation of the strings in the sequence. +COMPHELPER_DLLPUBLIC OString join(const OString& rSeparator, const std::vector<OString>& rSequence); + /** Convert a decimal string to a number. The string must be base-10, no sign but can contain any commit df34ab576de1dd713ad83ad5d5a9fc8ae3a49d1d Author: Miklos Vajna <[email protected]> Date: Wed Oct 7 17:19:26 2015 +0200 sc tiled rendering: fix showing all search results Calc can have multiple cells selected, but there is only one cell which has the black border around the cell. Code in ScViewFunc::SearchAndReplace() assumed that the two are always the same, and that's how find-all always highlighted the first match only. Fix this by avoiding emitting LOK_CALLBACK_TEXT_SELECTION two times, at least in the find-all case. Change-Id: Ifce789c7f5f11e94fb2445846279823096ecb2dd (cherry picked from commit a31f95b180728c1c671930913b4b4ad96ebcda5f) diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 47b0ace..295d3db 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1837,7 +1837,8 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP ); SetCursor( nCol, nRow, true ); - if (rDoc.GetDrawLayer()->isTiledRendering()) + // 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) { Point aCurPos = GetViewData().GetScrPos(nCol, nRow, GetViewData().GetActivePart()); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
