sd/source/core/drawdoc.cxx | 4 - sw/inc/viewopt.hxx | 3 sw/qa/extras/tiledrendering/tiledrendering.cxx | 7 + sw/source/uibase/config/viewopt.cxx | 8 ++ sw/source/uibase/uiview/viewsrch.cxx | 92 +++++++++++++------------ 5 files changed, 69 insertions(+), 45 deletions(-)
New commits: commit 2af2b87c0ba14bdd810988f347c37dc15b3daf01 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Oct 6 14:17:43 2015 +0200 sw tiled rendering: emit LOK_CALLBACK_SEARCH_RESULT* for normal search We used to emit these for find-all only, for no good reason. Change-Id: Id07dc7649f9a8528b9d4ec16d5f7c651fd607111 (cherry picked from commit 58c38e7ea5debc5440f1d81acf38d8d6ad0883d8) diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 2fd27dd..1eb57de 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -342,7 +342,10 @@ void lcl_search(bool bBackward) void SwTiledRenderingTest::testSearch() { #if !defined(WNT) && !defined(MACOSX) + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("search.odt"); + pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); size_t nNode = pWrtShell->getShellCrsr(false)->Start()->nNode.GetNode().GetIndex(); @@ -351,6 +354,8 @@ void SwTiledRenderingTest::testSearch() CPPUNIT_ASSERT(!pWrtShell->GetDrawView()->GetTextEditObject()); size_t nActual = pWrtShell->getShellCrsr(false)->Start()->nNode.GetNode().GetIndex(); CPPUNIT_ASSERT_EQUAL(nNode + 1, nActual); + /// Make sure we get search result selection for normal find as well, not only find all. + CPPUNIT_ASSERT(!m_aSearchResultSelection.empty()); // Next hit, in the shape. lcl_search(false); @@ -375,6 +380,8 @@ void SwTiledRenderingTest::testSearch() CPPUNIT_ASSERT(!pWrtShell->GetDrawView()->GetTextEditObject()); nActual = pWrtShell->getShellCrsr(false)->Start()->nNode.GetNode().GetIndex(); CPPUNIT_ASSERT_EQUAL(nNode + 1, nActual); + + comphelper::LibreOfficeKit::setActive(false); #endif } diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index a22cbdb..c8d3e7a 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -253,7 +253,11 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage) { bool bRet = SearchAndWrap(bApi); if( bRet ) + { Scroll(m_pWrtShell->GetCharRect().SVRect()); + if (comphelper::LibreOfficeKit::isActive()) + lcl_emitSearchResultCallbacks(1, m_pSrchItem, m_pWrtShell); + } rReq.SetReturnValue(SfxBoolItem(nSlot, bRet)); #if HAVE_FEATURE_DESKTOP { commit 88e5154b9af6a5385d37d97fa22de2c131a214eb Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Oct 6 12:29:33 2015 +0200 sw: extract lcl_emitSearchResultCallbacks() from SwView::ExecSearch() Change-Id: I9c6b7540bcae85d6529e5cc195a7e86f58ee5713 (cherry picked from commit ca8016c3a317a7ba1f03e117d575fb78a572b4b3) diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 570fade..a22cbdb 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -102,6 +102,51 @@ static void lcl_addContainerToJson(boost::property_tree::ptree& rTree, const OSt rTree.add_child(rKey.getStr(), aChildren); } +/// Emits LOK callbacks (count, selection) for search results. +static void lcl_emitSearchResultCallbacks(sal_uInt16 nFound, SvxSearchItem* pSearchItem, SwWrtShell* pWrtShell) +{ + OString aPayload = OString::number(nFound) + ";" + pSearchItem->GetSearchString().toUtf8(); + pWrtShell->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_COUNT, aPayload.getStr()); + + // Emit a callback also about the selection rectangles, grouped by matches. + if (SwPaM* pPaM = pWrtShell->GetCrsr()) + { + std::vector<OString> aMatches; + for (SwPaM& rPaM : pPaM->GetRingContainer()) + { + if (SwShellCrsr* pShellCrsr = dynamic_cast<SwShellCrsr*>(&rPaM)) + { + std::vector<OString> aSelectionRectangles; + pShellCrsr->SwSelPaintRects::Show(&aSelectionRectangles); + std::stringstream ss; + bool bFirst = true; + 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(); + } + OString sRect = ss.str().c_str(); + aMatches.push_back(sRect); + } + } + boost::property_tree::ptree aTree; + aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr()); + lcl_addContainerToJson(aTree, "searchResultSelection", aMatches); + + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree); + aPayload = aStream.str().c_str(); + + pWrtShell->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr()); + } +} + void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage) { const SfxItemSet* pArgs = rReq.GetArgs(); @@ -241,48 +286,7 @@ void SwView::ExecSearch(SfxRequest& rReq, bool bNoMessage) m_bFound = false; } else if (comphelper::LibreOfficeKit::isActive()) - { - OString aPayload = OString::number(nFound) + ";" + m_pSrchItem->GetSearchString().toUtf8(); - m_pWrtShell->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_COUNT, aPayload.getStr()); - - // Emit a callback also about the selection rectangles, grouped by matches. - if (SwPaM* pPaM = m_pWrtShell->GetCrsr()) - { - std::vector<OString> aMatches; - for (SwPaM& rPaM : pPaM->GetRingContainer()) - { - if (SwShellCrsr* pShellCrsr = dynamic_cast<SwShellCrsr*>(&rPaM)) - { - std::vector<OString> aSelectionRectangles; - pShellCrsr->SwSelPaintRects::Show(&aSelectionRectangles); - std::stringstream ss; - bool bFirst = true; - 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(); - } - OString sRect = ss.str().c_str(); - aMatches.push_back(sRect); - } - } - boost::property_tree::ptree aTree; - aTree.put("searchString", m_pSrchItem->GetSearchString().toUtf8().getStr()); - lcl_addContainerToJson(aTree, "searchResultSelection", aMatches); - - std::stringstream aStream; - boost::property_tree::write_json(aStream, aTree); - aPayload = aStream.str().c_str(); - - m_pWrtShell->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr()); - } - } + lcl_emitSearchResultCallbacks(nFound, m_pSrchItem, m_pWrtShell); rReq.SetReturnValue(SfxBoolItem(nSlot, bRet)); #if HAVE_FEATURE_DESKTOP { commit a0e0d907a96e098e77396b6972327bb70fe59523 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Oct 6 12:05:14 2015 +0200 Disable spellcheck when LOK is active It's not useful when viewing, and for editing probably a dedicated overlay would be better (like the one we have for cursor/selections already). Disable for sw/sd explicitly, sc had it disabled implicitly already. Change-Id: I7134f5d1a1546787c22019e6b1abdc0dd887f888 (cherry picked from commit c92ebc850345924619a12327f36cc6ac9c0b09d1) diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index fcf678e..f820fab 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -97,6 +97,7 @@ #include <tools/tenccvt.hxx> #include <vcl/settings.hxx> +#include <comphelper/lok.hxx> using namespace ::sd; using namespace ::com::sun::star; @@ -229,7 +230,8 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX), EE_CHAR_LANGUAGE_CTL ); - mbOnlineSpell = aOptions.bIsSpellAuto; + if (!comphelper::LibreOfficeKit::isActive()) + mbOnlineSpell = aOptions.bIsSpellAuto; } LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage ); diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx index c5080e8..77c716a 100644 --- a/sw/source/uibase/config/viewopt.cxx +++ b/sw/source/uibase/config/viewopt.cxx @@ -314,6 +314,9 @@ bool SwViewOption::IsAutoCompleteWords() void SwViewOption::SetOnlineSpell(bool b) { + if (comphelper::LibreOfficeKit::isActive()) + return; + b ? (nCoreOptions |= VIEWOPT_1_ONLINESPELL ) : ( nCoreOptions &= ~VIEWOPT_1_ONLINESPELL); } commit c925a3217a8f2178f6d54abbce0b40628c3ef480 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Oct 6 11:13:54 2015 +0200 sw: outline SwViewOption::SetOnlineSpell() Change-Id: Ic81b039e9a1b592ca52ab684ddb45ee44c7714df (cherry picked from commit 0cf63ba224cb01377e3e6da68b0e72a3ed7e30af) diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index 64c1e26..dee2189 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -300,8 +300,7 @@ public: inline bool IsOnlineSpell() const { return !bReadonly && (nCoreOptions & VIEWOPT_1_ONLINESPELL) != 0; } - inline void SetOnlineSpell( bool b ) - { b ? (nCoreOptions |= VIEWOPT_1_ONLINESPELL ) : ( nCoreOptions &= ~VIEWOPT_1_ONLINESPELL); } + void SetOnlineSpell( bool b ); inline bool IsViewMetaChars() const { return !bReadonly && (nCoreOptions & VIEWOPT_1_VIEWMETACHARS) != 0; } diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx index 7597589..c5080e8 100644 --- a/sw/source/uibase/config/viewopt.cxx +++ b/sw/source/uibase/config/viewopt.cxx @@ -312,6 +312,11 @@ bool SwViewOption::IsAutoCompleteWords() return rFlags.bAutoCmpltCollectWords; } +void SwViewOption::SetOnlineSpell(bool b) +{ + b ? (nCoreOptions |= VIEWOPT_1_ONLINESPELL ) : ( nCoreOptions &= ~VIEWOPT_1_ONLINESPELL); +} + AuthorCharAttr::AuthorCharAttr() : nItemId (SID_ATTR_CHAR_UNDERLINE), nAttr (UNDERLINE_SINGLE), _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits