[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - libreofficekit/qa libreofficekit/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 17 15:08:33 UTC 2018


 libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx |   20 +++++------
 libreofficekit/qa/tilebench/tilebench.cxx           |    8 ++--
 libreofficekit/source/gtk/lokdocview.cxx            |   36 ++++++++++----------
 3 files changed, 32 insertions(+), 32 deletions(-)

New commits:
commit 14044919204296f01d48bfe79eda2cd35cf50eb2
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Jan 12 20:20:43 2018 +0100
Commit:     pranavk <pranavk at collabora.co.uk>
CommitDate: Tue Jul 17 17:08:10 2018 +0200

    More loplugin:cstylecast: libreofficekit
    
    auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable
    loplugin:cstylecast for some more cases" plus
    solenv/clang-format/reformat-formatted-files
    
    Change-Id: Iaa166a248f5c1e9fcf62834f65475265403e4322
    (cherry picked from commit 4fdd5eff7d4e10eb0a709c79b30b7411e4297d42)
    Reviewed-on: https://gerrit.libreoffice.org/57574
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 54c54848d20e..1d7a2482c069 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -143,7 +143,7 @@ gtv_lok_dialog_signal_button(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
 
     g_info("lok_dialog_signal_button (type: %s): %d, %d",
            aEventType.c_str(),
-           (int)pEvent->x, (int)pEvent->y);
+           static_cast<int>(pEvent->x), static_cast<int>(pEvent->y));
     gtk_widget_grab_focus(pDialogDrawingArea);
 
     switch (pEvent->type)
@@ -225,9 +225,9 @@ gtv_lok_dialog_signal_motion(GtkWidget* pDialogDrawingArea, GdkEventButton* pEve
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(window->lokdocview));
 
     g_info("lok_dialog_signal_motion: %d, %d (in twips: %d, %d)",
-           (int)pEvent->x, (int)pEvent->y,
-           (int)pixelToTwip(pEvent->x),
-           (int)pixelToTwip(pEvent->y));
+           static_cast<int>(pEvent->x), static_cast<int>(pEvent->y),
+           static_cast<int>(pixelToTwip(pEvent->x)),
+           static_cast<int>(pixelToTwip(pEvent->y)));
 
     pDocument->pClass->postWindowMouseEvent(pDocument,
                                             priv->dialogid,
@@ -521,9 +521,9 @@ gtv_lok_dialog_floating_win_signal_button(GtkWidget* /*pDialogChildDrawingArea*/
 
     g_info("lok_dialog_floating_win_signal_button (type: %s): %d, %d (in twips: %d, %d)",
            aEventType.c_str(),
-           (int)pEvent->x, (int)pEvent->y,
-           (int)pixelToTwip(pEvent->x),
-           (int)pixelToTwip(pEvent->y));
+           static_cast<int>(pEvent->x), static_cast<int>(pEvent->y),
+           static_cast<int>(pixelToTwip(pEvent->x)),
+           static_cast<int>(pixelToTwip(pEvent->y)));
 
     switch (pEvent->type)
     {
@@ -604,9 +604,9 @@ gtv_lok_dialog_floating_win_signal_motion(GtkWidget* /*pDialogDrawingArea*/, Gdk
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(window->lokdocview));
 
     g_info("lok_dialog_floating_win_signal_motion: %d, %d (in twips: %d, %d)",
-           (int)pEvent->x, (int)pEvent->y,
-           (int)pixelToTwip(pEvent->x),
-           (int)pixelToTwip(pEvent->y));
+           static_cast<int>(pEvent->x), static_cast<int>(pEvent->y),
+           static_cast<int>(pixelToTwip(pEvent->x)),
+           static_cast<int>(pixelToTwip(pEvent->y)));
 
     pDocument->pClass->postWindowMouseEvent(pDocument,
                                             priv->m_nChildId,
diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx
index 61bc562ae9a7..751fb179169f 100644
--- a/libreofficekit/qa/tilebench/tilebench.cxx
+++ b/libreofficekit/qa/tilebench/tilebench.cxx
@@ -33,8 +33,8 @@ static double getTimeNow()
 {
     TimeValue aValue;
     osl_getSystemTime(&aValue);
-    return (double)aValue.Seconds +
-           (double)aValue.Nanosec / (1000*1000*1000);
+    return static_cast<double>(aValue.Seconds) +
+           static_cast<double>(aValue.Nanosec) / (1000*1000*1000);
 }
 
 /// Dump an array of RGBA or BGRA to an RGB PPM file.
@@ -149,7 +149,7 @@ int main( int argc, char* argv[] )
 
         // Estimate the maximum tiles based on the number of parts requested, if Writer.
         if (pDocument->getDocumentType() == LOK_DOCTYPE_TEXT)
-            max_tiles = (int)ceil(max_parts * 16128. / nTilePixelHeight) * ceil((double)nWidth / nTilePixelWidth);
+            max_tiles = static_cast<int>(ceil(max_parts * 16128. / nTilePixelHeight)) * ceil(static_cast<double>(nWidth) / nTilePixelWidth);
         fprintf(stderr, "Parts to render: %d, Total Parts: %d, Max parts: %d, Max tiles: %d\n", nParts, nTotalParts, max_parts, max_tiles);
 
         std::vector<unsigned char> vBuffer(nTilePixelWidth * nTilePixelHeight * 4);
@@ -204,7 +204,7 @@ int main( int argc, char* argv[] )
                 aTimes.emplace_back("render sub-regions at scale");
                 int nMaxTiles = max_tiles;
                 if (pDocument->getDocumentType() == LOK_DOCTYPE_TEXT)
-                    nMaxTiles = (int)ceil(max_parts * 16128. / nTileTwipHeight) * ceil((double)nWidth / nTileTwipWidth);
+                    nMaxTiles = static_cast<int>(ceil(max_parts * 16128. / nTileTwipHeight)) * ceil(static_cast<double>(nWidth) / nTileTwipWidth);
                 int nTiles = 0;
                 for (int nY = 0; nY < nHeight - 1; nY += nTileTwipHeight)
                 {
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index a48026a7b796..2db7674c5b34 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -962,7 +962,7 @@ static gboolean postDocumentLoad(gpointer pData)
     long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips, zoom);
     long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips, zoom);
     // Total number of columns in this document.
-    guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
+    guint nColumns = ceil(static_cast<double>(nDocumentWidthPixels) / nTileSizePixels);
 
     priv->m_pTileBuffer = std::unique_ptr<TileBuffer>(new TileBuffer(nColumns));
     gtk_widget_set_size_request(GTK_WIDGET(pLOKDocView),
@@ -1606,8 +1606,8 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
     long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, priv->m_fZoom);
     long nDocumentHeightPixels = twipToPixel(priv->m_nDocumentHeightTwips, priv->m_fZoom);
     // Total number of rows / columns in this document.
-    guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
-    guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
+    guint nRows = ceil(static_cast<double>(nDocumentHeightPixels) / nTileSizePixels);
+    guint nColumns = ceil(static_cast<double>(nDocumentWidthPixels) / nTileSizePixels);
 
     gdk_cairo_get_clip_rectangle (pCairo, &aVisibleArea);
     aVisibleArea.x = pixelToTwip (aVisibleArea.x, priv->m_fZoom);
@@ -1689,7 +1689,7 @@ static const GdkRGBA& getDarkColor(int nViewId, LOKDocViewPrivate& priv)
         {
             const std::string& rName = rValue.second.get<std::string>("name");
             guint32 nColor = rValue.second.get<guint32>("color");
-            GdkRGBA aColor{((double)((guint8)(nColor>>16)))/255, ((double)((guint8)(((guint16)nColor) >> 8)))/255, ((double)((guint8)nColor))/255, 0};
+            GdkRGBA aColor{static_cast<double>(static_cast<guint8>(nColor>>16))/255, static_cast<double>(static_cast<guint8>(static_cast<guint16>(nColor) >> 8))/255, static_cast<double>(static_cast<guint8>(nColor))/255, 0};
             auto itAuthorViews = g_aAuthorViews.find(rName);
             if (itAuthorViews != g_aAuthorViews.end())
                 aColorMap[itAuthorViews->second] = aColor;
@@ -1700,15 +1700,15 @@ static const GdkRGBA& getDarkColor(int nViewId, LOKDocViewPrivate& priv)
         // Based on tools/colordata.hxx, COL_AUTHOR1_DARK..COL_AUTHOR9_DARK.
         static std::vector<GdkRGBA> aColors =
         {
-            {((double)198)/255, ((double)146)/255, ((double)0)/255, 0},
-            {((double)6)/255, ((double)70)/255, ((double)162)/255, 0},
-            {((double)87)/255, ((double)157)/255, ((double)28)/255, 0},
-            {((double)105)/255, ((double)43)/255, ((double)157)/255, 0},
-            {((double)197)/255, ((double)0)/255, ((double)11)/255, 0},
-            {((double)0)/255, ((double)128)/255, ((double)128)/255, 0},
-            {((double)140)/255, ((double)132)/255, ((double)0)/255, 0},
-            {((double)43)/255, ((double)85)/255, ((double)107)/255, 0},
-            {((double)209)/255, ((double)118)/255, ((double)0)/255, 0},
+            {(double(198))/255, (double(146))/255, (double(0))/255, 0},
+            {(double(6))/255, (double(70))/255, (double(162))/255, 0},
+            {(double(87))/255, (double(157))/255, (double(28))/255, 0},
+            {(double(105))/255, (double(43))/255, (double(157))/255, 0},
+            {(double(197))/255, (double(0))/255, (double(11))/255, 0},
+            {(double(0))/255, (double(128))/255, (double(128))/255, 0},
+            {(double(140))/255, (double(132))/255, (double(0))/255, 0},
+            {(double(43))/255, (double(85))/255, (double(107))/255, 0},
+            {(double(209))/255, (double(118))/255, (double(0))/255, 0},
         };
         static int nColorCounter = 0;
         GdkRGBA aColor = aColors[nColorCounter++ % aColors.size()];
@@ -1785,7 +1785,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
         for (GdkRectangle& rRectangle : priv->m_aTextSelectionRectangles)
         {
             // Blue with 75% transparency.
-            cairo_set_source_rgba(pCairo, ((double)0x43)/255, ((double)0xac)/255, ((double)0xe8)/255, 0.25);
+            cairo_set_source_rgba(pCairo, (double(0x43))/255, (double(0xac))/255, (double(0xe8))/255, 0.25);
             cairo_rectangle(pCairo,
                             twipToPixel(rRectangle.x, priv->m_fZoom),
                             twipToPixel(rRectangle.y, priv->m_fZoom),
@@ -1934,9 +1934,9 @@ lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
     GError* error = nullptr;
 
     g_info("LOKDocView_Impl::signalButton: %d, %d (in twips: %d, %d)",
-           (int)pEvent->x, (int)pEvent->y,
-           (int)pixelToTwip(pEvent->x, priv->m_fZoom),
-           (int)pixelToTwip(pEvent->y, priv->m_fZoom));
+           static_cast<int>(pEvent->x), static_cast<int>(pEvent->y),
+           static_cast<int>(pixelToTwip(pEvent->x, priv->m_fZoom)),
+           static_cast<int>(pixelToTwip(pEvent->y, priv->m_fZoom)));
     gtk_widget_grab_focus(GTK_WIDGET(pDocView));
 
     switch (pEvent->type)
@@ -3480,7 +3480,7 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
     long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, fZoom);
     long nDocumentHeightPixels = twipToPixel(priv->m_nDocumentHeightTwips, fZoom);
     // Total number of columns in this document.
-    guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
+    guint nColumns = ceil(static_cast<double>(nDocumentWidthPixels) / nTileSizePixels);
 
     priv->m_pTileBuffer = std::unique_ptr<TileBuffer>(new TileBuffer(nColumns));
     gtk_widget_set_size_request(GTK_WIDGET(pDocView),


More information about the Libreoffice-commits mailing list