summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-10 20:47:32 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-11 11:20:43 +0200
commit2d582244680e7f6dec6e4a466e276f93ccb01dc9 (patch)
treeb0e880ddfb3ce1ea2f47151b648e7fbb55132f08 /libreofficekit
parent74012c48d99634a7556a86f77e9522024f2afdb2 (diff)
loplugin:flatten
Change-Id: I6560756eb63856a22b43e3e65a7b7843cd2d5376 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100447 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx68
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx36
-rw-r--r--libreofficekit/qa/tilebench/tilebench.cxx46
-rw-r--r--libreofficekit/source/gtk/tilebuffer.cxx28
4 files changed, 89 insertions, 89 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 794774acfe52..90b96e57488a 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -52,44 +52,44 @@ void LOKDocViewSigHandlers::commandChanged(LOKDocView* pDocView, char* pPayload,
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
std::string aPayload(pPayload);
size_t nPosition = aPayload.find('=');
- if (nPosition != std::string::npos)
+ if (nPosition == std::string::npos)
+ return;
+
+ const std::string aKey = aPayload.substr(0, nPosition);
+ const std::string aValue = aPayload.substr(nPosition + 1);
+ GtkToolItem* pItem = gtv_application_window_find_tool_by_unocommand(window, aKey);
+ if (pItem != nullptr)
{
- const std::string aKey = aPayload.substr(0, nPosition);
- const std::string aValue = aPayload.substr(nPosition + 1);
- GtkToolItem* pItem = gtv_application_window_find_tool_by_unocommand(window, aKey);
- if (pItem != nullptr)
- {
- if (aValue == "true" || aValue == "false") {
- bool bEdit = aValue == "true";
- if (bool(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pItem))) != bEdit)
- {
- // Avoid invoking lok_doc_view_post_command().
- // FIXME: maybe block/unblock the signal (see
- // g_signal_handlers_block_by_func) ?
- gtv_application_window_set_toolbar_broadcast(window, false);
- gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pItem), bEdit);
- gtv_application_window_set_toolbar_broadcast(window, true);
+ if (aValue == "true" || aValue == "false") {
+ bool bEdit = aValue == "true";
+ if (bool(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pItem))) != bEdit)
+ {
+ // Avoid invoking lok_doc_view_post_command().
+ // FIXME: maybe block/unblock the signal (see
+ // g_signal_handlers_block_by_func) ?
+ gtv_application_window_set_toolbar_broadcast(window, false);
+ gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pItem), bEdit);
+ gtv_application_window_set_toolbar_broadcast(window, true);
- }
- } else if (aValue == "enabled" || aValue == "disabled") {
- bool bSensitive = aValue == "enabled";
- gtk_widget_set_sensitive(GTK_WIDGET(pItem), bSensitive);
-
- // Remember state, so in case edit is disable and enabled
- // later, the correct sensitivity can be restored.
- GtvMainToolbar* pMainToolbar = gtv_application_window_get_main_toolbar(window);
- gtv_main_toolbar_set_sensitive_internal(pMainToolbar, pItem, bSensitive);
}
+ } else if (aValue == "enabled" || aValue == "disabled") {
+ bool bSensitive = aValue == "enabled";
+ gtk_widget_set_sensitive(GTK_WIDGET(pItem), bSensitive);
+
+ // Remember state, so in case edit is disable and enabled
+ // later, the correct sensitivity can be restored.
+ GtvMainToolbar* pMainToolbar = gtv_application_window_get_main_toolbar(window);
+ gtv_main_toolbar_set_sensitive_internal(pMainToolbar, pItem, bSensitive);
}
- else if (aKey == ".uno:TrackedChangeIndex")
- {
- std::string aText("Current redline: ");
- if (aValue.empty())
- aText += "none";
- else
- aText += aValue;
- gtk_label_set_text(GTK_LABEL(window->redlinelabel), aText.c_str());
- }
+ }
+ else if (aKey == ".uno:TrackedChangeIndex")
+ {
+ std::string aText("Current redline: ");
+ if (aValue.empty())
+ aText += "none";
+ else
+ aText += aValue;
+ gtk_label_set_text(GTK_LABEL(window->redlinelabel), aText.c_str());
}
}
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
index df4146628cc1..fef712ceef0a 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
@@ -27,28 +27,28 @@ void btn_clicked(GtkWidget* pButton, gpointer)
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(pButton));
GtkToolButton* pItem = GTK_TOOL_BUTTON(pButton);
const gchar* label = gtk_tool_button_get_label(pItem);
- if (gtv_application_window_get_toolbar_broadcast(window) && g_str_has_prefix(label, ".uno:"))
- {
- std::string aArguments;
- if (g_strcmp0(label, ".uno:InsertAnnotation") == 0)
- {
- std::map<std::string, std::string> aEntries;
- aEntries["Text"] = "";
- GtvHelpers::userPromptDialog(GTK_WINDOW(window), "Insert Comment", aEntries);
+ if (!(gtv_application_window_get_toolbar_broadcast(window) && g_str_has_prefix(label, ".uno:")))
+ return;
- boost::property_tree::ptree aTree;
- aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "type", nullptr), '/'), "string");
- aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "value", nullptr), '/'), aEntries["Text"]);
+ std::string aArguments;
+ if (g_strcmp0(label, ".uno:InsertAnnotation") == 0)
+ {
+ std::map<std::string, std::string> aEntries;
+ aEntries["Text"] = "";
+ GtvHelpers::userPromptDialog(GTK_WINDOW(window), "Insert Comment", aEntries);
- std::stringstream aStream;
- boost::property_tree::write_json(aStream, aTree);
- aArguments = aStream.str();
- }
+ boost::property_tree::ptree aTree;
+ aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "type", nullptr), '/'), "string");
+ aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "value", nullptr), '/'), aEntries["Text"]);
- bool bNotify = g_strcmp0(label, ".uno:Save") == 0;
- if (window->lokdocview)
- lok_doc_view_post_command(LOK_DOC_VIEW(window->lokdocview), label, aArguments.c_str(), bNotify);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ aArguments = aStream.str();
}
+
+ bool bNotify = g_strcmp0(label, ".uno:Save") == 0;
+ if (window->lokdocview)
+ lok_doc_view_post_command(LOK_DOC_VIEW(window->lokdocview), label, aArguments.c_str(), bNotify);
}
void doCopy(GtkWidget* pButton, gpointer /*pItem*/)
diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx
index 8f06cc16b2fd..978b7aa5eaa0 100644
--- a/libreofficekit/qa/tilebench/tilebench.cxx
+++ b/libreofficekit/qa/tilebench/tilebench.cxx
@@ -488,33 +488,33 @@ static void kitCallback(int nType, const char* pPayload, void* pData)
nDialogId = aRoot.get<unsigned>("id");
const std::string aAction = aRoot.get<std::string>("action");
- if (aAction == "created")
- {
- const std::string aType = aRoot.get<std::string>("type");
- const std::string aSize = aRoot.get<std::string>("size");
- int nWidth = atoi(aSize.c_str());
- int nHeight = 400;
- const char *pComma = strstr(aSize.c_str(), ", ");
- if (pComma)
- nHeight = atoi(pComma + 2);
- std::cerr << "Size " << aSize << " is " << nWidth << ", " << nHeight << "\n";
-
- if (aType == "dialog")
- {
- aTimes.emplace_back(); // complete wait for dialog
+ if (aAction != "created")
+ return;
- unsigned char *pBuffer = new unsigned char[nWidth * nHeight * 4];
+ const std::string aType = aRoot.get<std::string>("type");
+ const std::string aSize = aRoot.get<std::string>("size");
+ int nWidth = atoi(aSize.c_str());
+ int nHeight = 400;
+ const char *pComma = strstr(aSize.c_str(), ", ");
+ if (pComma)
+ nHeight = atoi(pComma + 2);
+ std::cerr << "Size " << aSize << " is " << nWidth << ", " << nHeight << "\n";
- aTimes.emplace_back("render dialog");
- pDocument->paintWindow(nDialogId, pBuffer, 0, 0, nWidth, nHeight);
- dumpTile("dialog", nWidth, nHeight, pDocument->getTileMode(), pBuffer);
- aTimes.emplace_back();
+ if (aType != "dialog")
+ return;
- delete[] pBuffer;
+ aTimes.emplace_back(); // complete wait for dialog
- bDialogRendered = true;
- }
- }
+ unsigned char *pBuffer = new unsigned char[nWidth * nHeight * 4];
+
+ aTimes.emplace_back("render dialog");
+ pDocument->paintWindow(nDialogId, pBuffer, 0, 0, nWidth, nHeight);
+ dumpTile("dialog", nWidth, nHeight, pDocument->getTileMode(), pBuffer);
+ aTimes.emplace_back();
+
+ delete[] pBuffer;
+
+ bDialogRendered = true;
}
static void testDialog( Document *pDocument, const char *uno_cmd )
diff --git a/libreofficekit/source/gtk/tilebuffer.cxx b/libreofficekit/source/gtk/tilebuffer.cxx
index 82f0253d9e82..6836031661bc 100644
--- a/libreofficekit/source/gtk/tilebuffer.cxx
+++ b/libreofficekit/source/gtk/tilebuffer.cxx
@@ -61,21 +61,21 @@ void TileBuffer::setInvalid(int x, int y, float fZoom, GTask* task,
{
int index = x * m_nWidth + y;
GError* error = nullptr;
- if (m_mTiles.find(index) != m_mTiles.end())
- {
- m_mTiles[index].valid = false;
+ if (m_mTiles.find(index) == m_mTiles.end())
+ return;
- LOEvent* pLOEvent = new LOEvent(LOK_PAINT_TILE);
- pLOEvent->m_nPaintTileX = x;
- pLOEvent->m_nPaintTileY = y;
- pLOEvent->m_fPaintTileZoom = fZoom;
- g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
- g_thread_pool_push(lokThreadPool, g_object_ref(task), &error);
- if (error != nullptr)
- {
- g_warning("Unable to call LOK_PAINT_TILE: %s", error->message);
- g_clear_error(&error);
- }
+ m_mTiles[index].valid = false;
+
+ LOEvent* pLOEvent = new LOEvent(LOK_PAINT_TILE);
+ pLOEvent->m_nPaintTileX = x;
+ pLOEvent->m_nPaintTileY = y;
+ pLOEvent->m_fPaintTileZoom = fZoom;
+ g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
+ g_thread_pool_push(lokThreadPool, g_object_ref(task), &error);
+ if (error != nullptr)
+ {
+ g_warning("Unable to call LOK_PAINT_TILE: %s", error->message);
+ g_clear_error(&error);
}
}