summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-01-12 20:20:43 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-01-12 20:20:43 +0100
commit4fdd5eff7d4e10eb0a709c79b30b7411e4297d42 (patch)
tree59b024f9e767dcecac75c1e80b9336c45b0d3724 /libreofficekit
parent4b557ffbccf4062b0626ab8d068fa6103ba6a837 (diff)
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
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx20
-rw-r--r--libreofficekit/qa/tilebench/tilebench.cxx8
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx36
3 files changed, 32 insertions, 32 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
index 5db79514aa4a..75c4bae71df5 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx
@@ -137,7 +137,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)
@@ -219,9 +219,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,
@@ -515,9 +515,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)
{
@@ -598,9 +598,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 5002e7b0c4e7..b5b1ff433340 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -960,7 +960,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),
@@ -1589,8 +1589,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);
@@ -1672,7 +1672,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;
@@ -1683,15 +1683,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()];
@@ -1768,7 +1768,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),
@@ -1917,9 +1917,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)
@@ -3435,7 +3435,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),