include/LibreOfficeKit/LibreOfficeKitEnums.h | 8 +- include/LibreOfficeKit/LibreOfficeKitGtk.h | 2 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 34 +++++++++- libreofficekit/source/gtk/lokdocview.cxx | 67 ++++++++++++++++++-- sd/qa/unit/tiledrendering/data/dummy.odp |binary sd/qa/unit/tiledrendering/tiledrendering.cxx | 49 ++++++++++++-- sd/source/ui/view/Outliner.cxx | 14 ++++ sw/source/core/view/viewsh.cxx | 10 ++ sw/source/uibase/uiview/view2.cxx | 2 sw/source/uibase/uno/unotxdoc.cxx | 5 + 10 files changed, 171 insertions(+), 20 deletions(-)
New commits: commit 3bc8e5f81b85b02a34cd6bb9080ba0fe1505bd33 Author: Henry Castro <hcas...@collabora.com> Date: Wed May 27 10:37:03 2015 +0200 sd LOKit callback for search not found Change-Id: Ide13a989005169cd6e8663f308d15f0e5984bd86 (cherry picked from commit c0cc9a8622a2cd0e3ba07e15a79dd65ca910b233) diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index aff2e76..60873d0 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -70,6 +70,7 @@ #include "framework/FrameworkHelper.hxx" #include <svx/svxids.hrc> #include <editeng/editerr.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1056,7 +1057,12 @@ void Outliner::ShowEndOfSearchDialog() if (mbStringFound) aString = SD_RESSTR(STR_END_SEARCHING); else + { aString = SD_RESSTR(STR_STRING_NOTFOUND); + mpDrawDocument->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_NOT_FOUND, + mpSearchItem->GetSearchString().toUtf8().getStr()); + + } } else { commit 2195aa2ce8a93895213bbbe2b25bb5a12d3c5160 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 27 17:12:28 2015 +0200 lokdocview: handle LOK_CALLBACK_DOCUMENT_SIZE_CHANGED Change-Id: Ib1b99221afbf9810bad5fd49fbf62c7a20fd28e4 (cherry picked from commit 8cbb94a2b79dcaf9675125da800b64a85bae52dc) diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 73dd15e..d01c743 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -170,6 +170,8 @@ struct LOKDocView_Impl * the tiles that intersect with pPartial. */ void renderDocument(GdkRectangle* pPartial); + /// Sets rWidth and rHeight from a "width, height" string. + void payloadToSize(const char* pPayload, long& rWidth, long& rHeight); /// Returns the GdkRectangle of a width,height,x,y string. static GdkRectangle payloadToRectangle(const char* pPayload); /// Returns the GdkRectangles of a w,h,x,y;w2,h2,x2,y2;... string. @@ -844,6 +846,21 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial) } } +void LOKDocView_Impl::payloadToSize(const char* pPayload, long& rWidth, long& rHeight) +{ + rWidth = rHeight = 0; + gchar** ppCoordinates = g_strsplit(pPayload, ", ", 2); + gchar** ppCoordinate = ppCoordinates; + if (!*ppCoordinate) + return; + rWidth = atoi(*ppCoordinate); + ++ppCoordinate; + if (!*ppCoordinate) + return; + rHeight = atoi(*ppCoordinate); + g_strfreev(ppCoordinates); +} + GdkRectangle LOKDocView_Impl::payloadToRectangle(const char* pPayload) { GdkRectangle aRet; @@ -913,8 +930,8 @@ const char* LOKDocView_Impl::callbackTypeToString(int nType) return "LOK_CALLBACK_STATUS_INDICATOR_FINISH"; case LOK_CALLBACK_SEARCH_NOT_FOUND: return "LOK_CALLBACK_SEARCH_NOT_FOUND"; - case LOK_CALLBACK_PAGE_COUNT_CHANGED: - return "LOK_CALLBACK_PAGE_COUNT_CHANGED"; + case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: + return "LOK_CALLBACK_DOCUMENT_SIZE_CHANGED"; case LOK_CALLBACK_SET_PART: return "LOK_CALLBACK_SET_PART"; } @@ -1014,9 +1031,9 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback) searchNotFound(pCallback->m_aPayload); } break; - case LOK_CALLBACK_PAGE_COUNT_CHANGED: + case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: { - m_pDocument->pClass->getDocumentSize(m_pDocument, &m_nDocumentWidthTwips, &m_nDocumentHeightTwips); + LOKDocView_Impl::payloadToSize(pCallback->m_aPayload.c_str(), m_nDocumentWidthTwips, m_nDocumentHeightTwips); } break; case LOK_CALLBACK_SET_PART: commit 50cb3a83fdafd37a4814b3cc6e6d1336274007a7 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 27 17:12:00 2015 +0200 LOK: change PAGE_COUNT to a more generic DOCUMENT_SIZE Change-Id: If94af4072c321358d7bd4d678eeed181dc0f44db (cherry picked from commit 63a40c45018ad2e6f4a660a520a5907beb1d7801) diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 9ad7636..5293aa9 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -146,12 +146,12 @@ typedef enum LOK_CALLBACK_SEARCH_NOT_FOUND, /** - * Number of pages changed in the document. + * Size of the document changed. * - * Clients should assume that data returned by an earlier - * lok::Document::getDocumentSize() call is no longer valid. + * Payload format is "width, height", i.e. clients get the new size without + * having to do an explicit lok::Document::getDocumentSize() call. */ - LOK_CALLBACK_PAGE_COUNT_CHANGED, + LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, /** * The current part number is changed. diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 37762b4..c6f374b 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -78,6 +78,7 @@ #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> #include <svx/sdrpaintwindow.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #if !HAVE_FEATURE_DESKTOP #include <vcl/sysdata.hxx> @@ -989,6 +990,15 @@ void SwViewShell::SizeChgNotify() const SvxNumberType& rNum = pPage->GetPageDesc()->GetNumType(); OUString sDisplay = rNum.GetNumStr( nVirtNum ); PageNumNotify( this, pCnt->GetPhyPageNum(), nVirtNum, sDisplay ); + + if (isTiledRendering()) + { + Size aDocSize = GetDocSize(); + std::stringstream ss; + ss << aDocSize.Width() + 2L * DOCUMENTBORDER << ", " << aDocSize.Height() + 2L * DOCUMENTBORDER; + OString sRect = ss.str().c_str(); + libreOfficeKitCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, sRect.getStr()); + } } } } diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index a8ce619..b6f947d 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -147,7 +147,6 @@ #include <vcl/settings.hxx> #include <boost/scoped_ptr.hpp> -#include <LibreOfficeKit/LibreOfficeKitEnums.h> const char sStatusDelim[] = " : "; const char sStatusComma[] = " , "; @@ -1281,7 +1280,6 @@ void SwView::Execute(SfxRequest &rReq) /// invalidate page numbering field void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr) { - GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_PAGE_COUNT_CHANGED, 0); OUString sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr )); const SfxStringItem aTmp( FN_STAT_PAGE, sTemp ); // Used to distinguish which tooltip to show commit 4d76e96a8caf86daa7055438c1fdb994c1687706 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 27 15:16:58 2015 +0200 SwXTextDocument::initializeForTiledRendering: allow having different defaults SetHardBlank() configures the gray background for non-breaking spaces. Change-Id: I779503189085cc6537b776deb3d30cb93b316acd (cherry picked from commit e3b0bae416b22f6dbf0a63efb645dadf75763a9c) diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 8a61199..a066c6f 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3167,6 +3167,11 @@ void SwXTextDocument::initializeForTiledRendering() return; pView->SetViewLayout(nColumns, bBookMode, true); + // Tiled rendering defaults. + SwViewOption aViewOption(*pViewShell->GetViewOptions()); + aViewOption.SetHardBlank(false); + pViewShell->ApplyViewOptions(aViewOption); + // Disable map mode, so that it's possible to send mouse event coordinates // directly in twips. SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin(); commit 84b35e1165f8cc7855204fb157adec0d345b1653 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 27 14:10:00 2015 +0200 CppunitTest_sd_tiledrendering: add search-not-found testcase Fails without commit c0cc9a8622a2cd0e3ba07e15a79dd65ca910b233 (sd LOKit callback for search not found, 2015-05-27). Change-Id: I26ce4eab3d0bf3abc4a59d0dd21d5f2f5de78017 (cherry picked from commit 436b4451c6f36ca23c966e2391cfcf94091b6db7) diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 9889015..b41c427 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -74,13 +74,15 @@ private: #if !defined(WNT) && !defined(MACOSX) Rectangle m_aInvalidation; std::vector<Rectangle> m_aSelection; + bool m_bFound; sal_Int32 m_nPart; #endif }; SdTiledRenderingTest::SdTiledRenderingTest() #if !defined(WNT) && !defined(MACOSX) - : m_nPart(0) + : m_bFound(true), + m_nPart(0) #endif { } @@ -167,6 +169,11 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload) } } break; + case LOK_CALLBACK_SEARCH_NOT_FOUND: + { + m_bFound = false; + } + break; case LOK_CALLBACK_SET_PART: { OUString aPayload = OUString::createFromAscii(pPayload); @@ -353,6 +360,12 @@ void SdTiledRenderingTest::testSearch() // Search for something on the second slide, and make sure that the set-part callback fired. lcl_search("bbb"); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart); + CPPUNIT_ASSERT_EQUAL(true, m_bFound); + + // This should trigger the not-found callback. + Application::EnableHeadlessMode(false); + lcl_search("ccc"); + CPPUNIT_ASSERT_EQUAL(false, m_bFound); } #endif commit 0de606737423db10a3591f8775a5ebacbdf67604 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 27 14:09:18 2015 +0200 sd tiled rendering: avoid showing wrap around dialog Change-Id: Id977c3a17f5e34d086ee3b68fa9ad2969f9d24c2 (cherry picked from commit 9328df9598286a94f0cf097462045a3c0a5721fc) diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index 277efb1..aff2e76 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -1092,6 +1092,14 @@ bool Outliner::ShowWrapArroundDialog() // Spell checking needs the dialog, too. bShowDialog = (meMode == SPELL); + boost::shared_ptr<ViewShell> pViewShell(mpWeakViewShell.lock()); + if (pViewShell && pViewShell->GetDoc()->isTiledRendering()) + { + // Wrap around without asking anything. + bShowDialog = false; + bDoWrapArround = true; + } + if (bShowDialog) { // The question text depends on the search direction. commit f953b28a945b7e61bc3407f2147e5afd3a11a2ff Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 27 11:59:00 2015 +0200 CppunitTest_sd_tiledrendering: add part switching testcase Fails with the last hunk of commit 67a37be9969d8b5a0bc8ae081bc1aba697ea6ba5 (sd: fix LOK search result highlight when result is not on the current slide, 2015-05-26) reverted. Change-Id: I5f8b57784ad1de1434113af7f94c9fde8672b4d5 (cherry picked from commit a0576aec8381ca8ea36d60c925e871587702c268) diff --git a/sd/qa/unit/tiledrendering/data/dummy.odp b/sd/qa/unit/tiledrendering/data/dummy.odp index e559de6..12cd679 100644 Binary files a/sd/qa/unit/tiledrendering/data/dummy.odp and b/sd/qa/unit/tiledrendering/data/dummy.odp differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index a55b026..9889015 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -37,6 +37,7 @@ static const char* DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/"; class SdTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { public: + SdTiledRenderingTest(); virtual void setUp() SAL_OVERRIDE; virtual void tearDown() SAL_OVERRIDE; @@ -73,9 +74,17 @@ private: #if !defined(WNT) && !defined(MACOSX) Rectangle m_aInvalidation; std::vector<Rectangle> m_aSelection; + sal_Int32 m_nPart; #endif }; +SdTiledRenderingTest::SdTiledRenderingTest() +#if !defined(WNT) && !defined(MACOSX) + : m_nPart(0) +#endif +{ +} + void SdTiledRenderingTest::setUp() { test::BootstrapFixture::setUp(); @@ -158,6 +167,12 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload) } } break; + case LOK_CALLBACK_SET_PART: + { + OUString aPayload = OUString::createFromAscii(pPayload); + m_nPart = aPayload.toInt32(); + } + break; } } @@ -306,6 +321,16 @@ void SdTiledRenderingTest::testResetSelection() CPPUNIT_ASSERT(!pView->GetTextEditObject()); } +static void lcl_search(const OUString& rKey) +{ + uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + {"SearchItem.SearchString", uno::makeAny(rKey)}, + {"SearchItem.Backward", uno::makeAny(false)} + })); + comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); +} + void SdTiledRenderingTest::testSearch() { SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); @@ -314,12 +339,7 @@ void SdTiledRenderingTest::testSearch() uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); xShape->setString("Aaa bbb."); - uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( - { - {"SearchItem.SearchString", uno::makeAny(OUString("bbb"))}, - {"SearchItem.Backward", uno::makeAny(false)} - })); - comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); + lcl_search("bbb"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdrView* pView = pViewShell->GetView(); @@ -329,6 +349,10 @@ void SdTiledRenderingTest::testSearch() // Did the selection callback fire? CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), m_aSelection.size()); + + // Search for something on the second slide, and make sure that the set-part callback fired. + lcl_search("bbb"); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart); } #endif commit d7bd82f9c268ec76df07e8b5d74effe19009484e Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed May 27 11:30:04 2015 +0200 lokdocview: fix not updated part selector when search changes part Change-Id: I337eed47c56dbbbebda4d7fe716eab6177936dc0 (cherry picked from commit c7ecbbbb6acf92af4ded4119da6abdddace39fe0) diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index cce580f..320121e 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -40,6 +40,7 @@ struct _LOKDocViewClass void (* edit_changed) (LOKDocView* pView, gboolean was_edit); void (* command_changed) (LOKDocView* pView, char* new_state); void (* search_not_found) (LOKDocView* pView, char* new_state); + void (* part_changed) (LOKDocView* pView, int new_part); }; guint lok_docview_get_type (void); diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index edd5006..ed2471f 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -45,6 +45,8 @@ static GtkWidget* pVBox; // GtkComboBox requires gtk 2.24 or later #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2 static GtkComboBoxText* pPartSelector; +/// Should the part selector avoid calling lok::Document::setPart()? +static bool g_bPartSelectorBroadcast = true; #endif GtkWidget* pFindbar; GtkWidget* pFindbarEntry; @@ -238,6 +240,15 @@ static void signalSearch(LOKDocView* /*pLOKDocView*/, char* /*pPayload*/, gpoint gtk_label_set_text(GTK_LABEL(pFindbarLabel), "Search key not found"); } +static void signalPart(LOKDocView* /*pLOKDocView*/, int nPart, gpointer /*pData*/) +{ +#if GTK_CHECK_VERSION(2,24,0) + g_bPartSelectorBroadcast = false; + gtk_combo_box_set_active(GTK_COMBO_BOX(pPartSelector), nPart); + g_bPartSelectorBroadcast = true; +#endif +} + /// User clicked on a cmmand button -> inform LOKDocView. static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/) { @@ -285,7 +296,7 @@ static void changePart( GtkWidget* pSelector, gpointer /* pItem */ ) { int nPart = gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) ); - if ( pDocView ) + if (g_bPartSelectorBroadcast && pDocView) { lok_docview_set_part( LOK_DOCVIEW(pDocView), nPart ); } @@ -443,6 +454,7 @@ int main( int argc, char* argv[] ) g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL); g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL); g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL); + g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL); // Input handling. g_signal_connect(pWindow, "key-press-event", G_CALLBACK(signalKey), pDocView); diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 874f96a..73dd15e 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -194,6 +194,8 @@ struct LOKDocView_Impl void commandChanged(const std::string& rPayload); /// Search did not find any matches. void searchNotFound(const std::string& rPayload); + /// LOK decided to change parts, need to update UI. + void setPart(const std::string& rPayload); }; namespace { @@ -1019,7 +1021,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback) break; case LOK_CALLBACK_SET_PART: { - renderDocument(0); + setPart(pCallback->m_aPayload); } break; default: @@ -1066,6 +1068,7 @@ enum EDIT_CHANGED, COMMAND_CHANGED, SEARCH_NOT_FOUND, + PART_CHANGED, LAST_SIGNAL }; @@ -1081,6 +1084,12 @@ void LOKDocView_Impl::searchNotFound(const std::string& rString) g_signal_emit(m_pDocView, docview_signals[SEARCH_NOT_FOUND], 0, rString.c_str()); } +void LOKDocView_Impl::setPart(const std::string& rString) +{ + g_signal_emit(m_pDocView, docview_signals[PART_CHANGED], 0, std::stoi(rString)); + renderDocument(0); +} + static void lok_docview_class_init( gpointer ptr ) { LOKDocViewClass* pClass = static_cast<LOKDocViewClass *>(ptr); @@ -1115,6 +1124,16 @@ static void lok_docview_class_init( gpointer ptr ) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + pClass->part_changed = 0; + docview_signals[PART_CHANGED] = + g_signal_new("part-changed", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(LOKDocViewClass, part_changed), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, + G_TYPE_INT); } static void lok_docview_init( GTypeInstance* pInstance, gpointer ) commit 8dbeb6368cdcb1605e6750771f96b5865e0c5e93 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 21 13:17:18 2015 +0100 gtktiledviewer: handle LOK_CALLBACK_SEARCH_NOT_FOUND Change-Id: Ic545bbd14d11a3b310f4d72ee02e51a7cb6f4f22 (cherry picked from commit cb0b7ff34dc193c37e89f4a968e1cb7502338230) diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index a517fca..cce580f 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -39,6 +39,7 @@ struct _LOKDocViewClass GtkScrolledWindowClass parent_class; void (* edit_changed) (LOKDocView* pView, gboolean was_edit); void (* command_changed) (LOKDocView* pView, char* new_state); + void (* search_not_found) (LOKDocView* pView, char* new_state); }; guint lok_docview_get_type (void); diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index aa1f3f6..edd5006 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -48,6 +48,7 @@ static GtkComboBoxText* pPartSelector; #endif GtkWidget* pFindbar; GtkWidget* pFindbarEntry; +GtkWidget* pFindbarLabel; static LibreOfficeKit* pOffice; @@ -177,6 +178,7 @@ static void signalSearchPrev(GtkWidget* /*pButton*/, gpointer /*pItem*/) /// Handles the key-press-event of the search entry widget. static gboolean signalFindbar(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer /*pData*/) { + gtk_label_set_text(GTK_LABEL(pFindbarLabel), ""); switch(pEvent->keyval) { case GDK_Return: @@ -230,6 +232,12 @@ static void signalCommand(LOKDocView* /*pLOKDocView*/, char* pPayload, gpointer } } +/// LOKDocView found no search matches -> set the search label accordingly. +static void signalSearch(LOKDocView* /*pLOKDocView*/, char* /*pPayload*/, gpointer /*pData*/) +{ + gtk_label_set_text(GTK_LABEL(pFindbarLabel), "Search key not found"); +} + /// User clicked on a cmmand button -> inform LOKDocView. static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/) { @@ -423,12 +431,18 @@ int main( int argc, char* argv[] ) gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarPrev, -1); g_signal_connect(G_OBJECT(pFindbarPrev), "clicked", G_CALLBACK(signalSearchPrev), NULL); + GtkToolItem* pFindbarLabelContainer = gtk_tool_item_new(); + pFindbarLabel = gtk_label_new(""); + gtk_container_add(GTK_CONTAINER(pFindbarLabelContainer), pFindbarLabel); + gtk_toolbar_insert(GTK_TOOLBAR(pFindbar), pFindbarLabelContainer, -1); + gtk_box_pack_end(GTK_BOX(pVBox), pFindbar, FALSE, FALSE, 0); // Docview pDocView = lok_docview_new( pOffice ); g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL); g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL); + g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL); // Input handling. g_signal_connect(pWindow, "key-press-event", G_CALLBACK(signalKey), pDocView); diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 7b2d4c9..874f96a 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -192,6 +192,8 @@ struct LOKDocView_Impl void globalCallbackWorkerImpl(int nType, const char* pPayload); /// Command state (various buttons like bold are toggled or not) is changed. void commandChanged(const std::string& rPayload); + /// Search did not find any matches. + void searchNotFound(const std::string& rPayload); }; namespace { @@ -1006,6 +1008,9 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback) } break; case LOK_CALLBACK_SEARCH_NOT_FOUND: + { + searchNotFound(pCallback->m_aPayload); + } break; case LOK_CALLBACK_PAGE_COUNT_CHANGED: { @@ -1060,6 +1065,7 @@ enum { EDIT_CHANGED, COMMAND_CHANGED, + SEARCH_NOT_FOUND, LAST_SIGNAL }; @@ -1070,6 +1076,11 @@ void LOKDocView_Impl::commandChanged(const std::string& rString) g_signal_emit(m_pDocView, docview_signals[COMMAND_CHANGED], 0, rString.c_str()); } +void LOKDocView_Impl::searchNotFound(const std::string& rString) +{ + g_signal_emit(m_pDocView, docview_signals[SEARCH_NOT_FOUND], 0, rString.c_str()); +} + static void lok_docview_class_init( gpointer ptr ) { LOKDocViewClass* pClass = static_cast<LOKDocViewClass *>(ptr); @@ -1094,6 +1105,16 @@ static void lok_docview_class_init( gpointer ptr ) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + pClass->search_not_found = 0; + docview_signals[SEARCH_NOT_FOUND] = + g_signal_new("search-not-found", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(LOKDocViewClass, search_not_found), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); } static void lok_docview_init( GTypeInstance* pInstance, gpointer ) commit 1c2f1892992a7193518f74fbbed78b456ae4a8b2 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sat May 23 11:08:07 2015 +0100 libreofficekit: fix Linux baseline build Change-Id: Ib0a076d78aacfec5e0625d7592ae24815e600ad6 (cherry picked from commit 5d9c2f2115dd8d3741501cbbc0313e4609bee896) diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 903c247..aa1f3f6 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -451,9 +451,9 @@ int main( int argc, char* argv[] ) populatePartModeSelector( GTK_COMBO_BOX_TEXT(pPartModeComboBox) ); // Connect these signals after populating the selectors, to avoid re-rendering on setting the default part/partmode. g_signal_connect(G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), 0); -#endif g_signal_connect(G_OBJECT(pPartSelector), "changed", G_CALLBACK(changePart), 0); +#endif gtk_main(); commit 134fa6a4999ccf0ed7b8cff7258bfa3d0e291b46 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri May 22 13:23:33 2015 +0100 gtktiledviewer: avoid a number of pointless re-rendering on startup Change-Id: Ia7f63a6fa7505da50e6580ea009975e06a0cb65c (cherry picked from commit 2807bcc186c976e55b6844d3459e2b0fbb92cdb8) diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 7509b2f..903c247 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -362,7 +362,6 @@ int main( int argc, char* argv[] ) GtkWidget* pComboBox = gtk_combo_box_text_new(); gtk_container_add( GTK_CONTAINER(pPartSelectorToolItem), pComboBox ); gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartSelectorToolItem, -1 ); - g_signal_connect( G_OBJECT(pComboBox), "changed", G_CALLBACK(changePart), NULL ); pPartSelector = GTK_COMBO_BOX_TEXT(pComboBox); @@ -373,7 +372,6 @@ int main( int argc, char* argv[] ) GtkWidget* pPartModeComboBox = gtk_combo_box_text_new(); gtk_container_add( GTK_CONTAINER(pPartModeSelectorToolItem), pPartModeComboBox ); gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartModeSelectorToolItem, -1 ); - g_signal_connect( G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), NULL ); #endif gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1); @@ -451,8 +449,12 @@ int main( int argc, char* argv[] ) #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2 populatePartSelector(); populatePartModeSelector( GTK_COMBO_BOX_TEXT(pPartModeComboBox) ); + // Connect these signals after populating the selectors, to avoid re-rendering on setting the default part/partmode. + g_signal_connect(G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), 0); #endif + g_signal_connect(G_OBJECT(pPartSelector), "changed", G_CALLBACK(changePart), 0); + gtk_main(); pOffice->pClass->destroy( pOffice ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits