[Libreoffice-commits] core.git: 3 commits - desktop/CppunitTest_desktop_lib.mk desktop/qa desktop/source sc/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Oct 8 01:57:34 PDT 2015
desktop/CppunitTest_desktop_lib.mk | 3 +
desktop/qa/data/search.ods |binary
desktop/qa/desktop_lib/test_desktop_lib.cxx | 76 ++++++++++++++++++++++++++--
desktop/source/lib/init.cxx | 8 ++
sc/source/ui/view/viewfun2.cxx | 3 -
5 files changed, 86 insertions(+), 4 deletions(-)
New commits:
commit 97c414758d3d8aa3cc2233d52612cf0a33c24c34
Author: Miklos Vajna <vmiklos at collabora.co.uk>
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
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 de1f156c6a35757d74b0e337b02743f1962ff0ae
Author: Miklos Vajna <vmiklos at collabora.co.uk>
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
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5883857..dc738921 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -569,6 +569,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 dd7d97589bcbed22cf2dd12b574fc28baedf24af
Author: Miklos Vajna <vmiklos at collabora.co.uk>
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
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 3bd8543..dc0ef09 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -85,6 +85,7 @@
#include <columnspanset.hxx>
#include <rowheightcontext.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
#include <vector>
#include <memory>
@@ -1736,7 +1737,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());
SfxChildWindow* pWnd = pViewFrm->GetChildWindow(sc::SearchResultsDlgWrapper::GetChildWindowId());
More information about the Libreoffice-commits
mailing list