Kaydet (Commit) faf01b8d authored tarafından Stephan Bergmann's avatar Stephan Bergmann

More loplugin:cstylecast: hwpfilter

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: I463894b6c99fe1ebb56895c4aca8bd05a13b7c25
üst 6491c1a6
......@@ -48,7 +48,7 @@ struct AttributeListImpl_impl
sal_Int16 SAL_CALL AttributeListImpl::getLength()
{
return (sal_Int16)m_pImpl->vecAttribute.size();
return static_cast<sal_Int16>(m_pImpl->vecAttribute.size());
}
......
......@@ -60,7 +60,7 @@ int debug(const char *format, ...);
#define YYFLAG -32768
#define YYNTBASE 43
#define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 66)
#define YYTRANSLATE(x) (static_cast<unsigned>(x) <= 285 ? yytranslate[x] : 66)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
......
......@@ -154,7 +154,7 @@ hchar_string DateCode::GetString()
format[DATE_SIZE - 1] = 0;
fmt = format[0] ? format : defaultform;
for (; *fmt && ((int) ret.size() < DATE_SIZE); fmt++)
for (; *fmt && (static_cast<int>(ret.size()) < DATE_SIZE); fmt++)
{
form = add_zero ? "%02d" : "%d";
......
......@@ -1248,7 +1248,7 @@ char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar)
{
unsigned short red,green,blue;
switch( (int)color )
switch( static_cast<int>(color) )
{
case 0 : // black
red = 0xff * (100 - shade ) /100;
......
......@@ -184,7 +184,7 @@ size_t gz_read(gz_stream * file, voidp buf, unsigned len)
if (s->z_err == Z_STREAM_END)
{
/* Check CRC and original size */
s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start));
s->crc = crc32(s->crc, start, static_cast<uInt>(s->stream.next_out - start));
start = s->stream.next_out;
if (getLong(s) != s->crc || getLong(s) != s->stream.total_out)
......@@ -200,7 +200,7 @@ size_t gz_read(gz_stream * file, voidp buf, unsigned len)
if (s->z_err != Z_OK || s->z_eof)
break;
}
s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start));
s->crc = crc32(s->crc, start, static_cast<uInt>(s->stream.next_out - start));
return len - s->stream.avail_out;
}
......@@ -256,11 +256,11 @@ int gz_flush(gz_stream * file, int flush)
*/
static uLong getLong(gz_stream * s)
{
uLong x = (unsigned char) get_byte(s);
uLong x = static_cast<unsigned char>(get_byte(s));
x += ((unsigned char) get_byte(s)) << 8;
x += ((unsigned char) get_byte(s)) << 16;
x += ((unsigned char) get_byte(s)) << 24;
x += static_cast<unsigned char>(get_byte(s)) << 8;
x += static_cast<unsigned char>(get_byte(s)) << 16;
x += static_cast<unsigned char>(get_byte(s)) << 24;
if (s->z_eof)
{
s->z_err = Z_DATA_ERROR;
......
......@@ -176,7 +176,7 @@ bool HStreamIODev::read1b(unsigned char &out)
if (res < 1)
return false;
out = (unsigned char)rBuf[0];
out = static_cast<unsigned char>(rBuf[0]);
return true;
}
......@@ -196,7 +196,7 @@ bool HStreamIODev::read2b(unsigned short &out)
if (res < 2)
return false;
out = ((unsigned char) rBuf[1] << 8 | (unsigned char) rBuf[0]);
out = (static_cast<unsigned char>(rBuf[1]) << 8 | static_cast<unsigned char>(rBuf[0]));
return true;
}
......@@ -207,8 +207,8 @@ bool HStreamIODev::read4b(unsigned int &out)
if (res < 4)
return false;
out = ((unsigned char) rBuf[3] << 24 | (unsigned char) rBuf[2] << 16 |
(unsigned char) rBuf[1] << 8 | (unsigned char) rBuf[0]);
out = (static_cast<unsigned char>(rBuf[3]) << 24 | static_cast<unsigned char>(rBuf[2]) << 16 |
static_cast<unsigned char>(rBuf[1]) << 8 | static_cast<unsigned char>(rBuf[0]));
return true;
}
......
......@@ -501,7 +501,7 @@ static int next_token(MzString &white, MzString &token, istream *strm)
// read preceding ws
if( IS_WS(ch) ) {
do white << (char) ch;
do white << static_cast<char>(ch);
while( IS_WS(ch = strm->get()) );
}
......@@ -509,11 +509,11 @@ static int next_token(MzString &white, MzString &token, istream *strm)
|| (ch != std::istream::traits_type::eof() && rtl::isAsciiAlpha(ch)) )
{
if( ch == '\\' ) {
token << (char) ch;
token << static_cast<char>(ch);
ch = strm->get();
}
do {
token << (char) ch;
token << static_cast<char>(ch);
ch = strm->get();
} while( ch != std::istream::traits_type::eof()
&& (ch & 0x80 || rtl::isAsciiAlpha(ch)) ) ;
......@@ -536,19 +536,19 @@ static int next_token(MzString &white, MzString &token, istream *strm)
token = "^";
}
else if( IS_BINARY(ch) ) {
do token << (char) ch;
do token << static_cast<char>(ch);
while( IS_BINARY(ch = strm->get()) );
strm->putback(static_cast<char>(ch));
}
else if( ch != std::istream::traits_type::eof() && rtl::isAsciiDigit(ch) ) {
do {
token << (char) ch;
token << static_cast<char>(ch);
ch = strm->get();
} while( ch != std::istream::traits_type::eof() && rtl::isAsciiDigit(ch) );
strm->putback(static_cast<char>(ch));
}
else
token << (char) ch;
token << static_cast<char>(ch);
return token.length();
}
......@@ -565,7 +565,7 @@ static std::istream::int_type read_white_space(MzString& outs, istream *strm)
else {
std::istream::int_type ch;
while( IS_WS(ch = strm->get()) )
outs << (char )ch;
outs << static_cast<char>(ch);
strm->putback(static_cast<char>(ch));
result = ch;
}
......@@ -735,7 +735,7 @@ static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel)
sstr << token;
while( (ch = strm->get()) != std::istream::traits_type::eof()
&& IS_WS(ch) )
sstr << (char)ch;
sstr << static_cast<char>(ch);
if( ch != '{' )
sstr << "{}";
else {
......
......@@ -44,9 +44,9 @@
#define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false)
#define padd(x,y,z) mxList->addAttribute(x,y,z)
#define Double2Str(x) OUString::number(x)
#define WTI(x) ((double)(x) / 1800.) // unit => inch
#define WTMM(x) ((double)(x) / 1800. * 25.4) // unit => mm
#define WTSM(x) ((int)((x) / 1800. * 2540)) // unit ==> 1/100 mm
#define WTI(x) (static_cast<double>(x) / 1800.) // unit => inch
#define WTMM(x) (static_cast<double>(x) / 1800. * 25.4) // unit => mm
#define WTSM(x) (static_cast<int>((x) / 1800. * 2540)) // unit ==> 1/100 mm
#define PI 3.14159265358979323846
......@@ -129,7 +129,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportHWP(SvStream &rStream)
nRead = rStream.ReadBytes(aData, 32768);
if (nRead == 0)
break;
stream->addData(aData, (int)nRead);
stream->addData(aData, static_cast<int>(nRead));
}
HWPFile hwpfile;
......@@ -1351,7 +1351,7 @@ void HwpReader::parseCharShape(CharShape const * cshape)
OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
padd("style:text-scale", sXML_CDATA,
ascii(Int2Str((int)(cshape->ratio[0] * fRatio), "%d%%", buf)));
ascii(Int2Str(static_cast<int>(cshape->ratio[0] * fRatio), "%d%%", buf)));
double sspace = (cshape->size / 25) * cshape->space[0] / 100.;
......@@ -1429,7 +1429,7 @@ void HwpReader::parseParaShape(ParaShape const * pshape)
unsigned char set_align = 0;
switch ((int) pshape->arrange_type)
switch (static_cast<int>(pshape->arrange_type))
{
case 1:
strcpy(buf, "start");
......@@ -4049,20 +4049,20 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
rotate = -(PI/2);
}
else
rotate = atan((double)( pt[1].y - pt[0].y )/(pt[1].x - pt[0].x ));
rotate = atan(static_cast<double>( pt[1].y - pt[0].y )/(pt[1].x - pt[0].x ));
if( pt[1].x < pt[0].x )
rotate += PI;
for( i = 0 ; i < 3 ; i++){
r_pt[i].x = (int)(pt[i].x * cos(-rotate) - pt[i].y * sin(-rotate));
r_pt[i].y = (int)(pt[i].y * cos(-rotate) + pt[i].x * sin(-rotate));
r_pt[i].x = static_cast<int>(pt[i].x * cos(-rotate) - pt[i].y * sin(-rotate));
r_pt[i].y = static_cast<int>(pt[i].y * cos(-rotate) + pt[i].x * sin(-rotate));
}
/* 4 - Calculation of reflex angle */
if( r_pt[2].y == r_pt[1].y )
skewX = 0;
else
skewX = atan((double)(r_pt[2].x - r_pt[1].x )/( r_pt[2].y - r_pt[1].y ));
skewX = atan(static_cast<double>(r_pt[2].x - r_pt[1].x )/( r_pt[2].y - r_pt[1].y ));
if( skewX >= PI/2 )
skewX -= PI;
if( skewX <= -PI/2 )
......@@ -4089,8 +4089,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
bIsRotate = true;
}
if( bIsRotate ){
drawobj->extent.w = (int)sqrt(double(DBL(pt[1].x-pt[0].x)+DBL(pt[1].y-pt[0].y)));
drawobj->extent.h = (int)sqrt(double(DBL(pt[2].x-pt[1].x)+DBL(pt[2].y-pt[1].y)));
drawobj->extent.w = static_cast<int>(sqrt(double(DBL(pt[1].x-pt[0].x)+DBL(pt[1].y-pt[0].y))));
drawobj->extent.h = static_cast<int>(sqrt(double(DBL(pt[2].x-pt[1].x)+DBL(pt[2].y-pt[1].y))));
padd("draw:transform", sXML_CDATA, trans);
}
}
......@@ -4264,7 +4264,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
start_angle = 0.5 * PI;
}
else{
start_angle = atan((double)( pal->pt[0].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[0].x ));
start_angle = atan(static_cast<double>( pal->pt[0].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[0].x ));
if( pal->pt[1].x < pal->pt[0].x )
start_angle += PI;
}
......@@ -4275,7 +4275,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
end_angle = 0.5 * PI;
}
else{
end_angle = atan((double)( pal->pt[2].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[2].x ));
end_angle = atan(static_cast<double>( pal->pt[2].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[2].x ));
if( pal->pt[1].x < pal->pt[2].x )
end_angle += PI;
}
......@@ -4400,21 +4400,21 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
NaturalSpline(n, tarr, yarr, yb, carr, darr);
}
sprintf(buf, "M%d %dC%d %d", WTSM((int)xarr[0]), WTSM((int)yarr[0]),
WTSM((int)(xarr[0] + xb[0]/3)), WTSM((int)(yarr[0] + yb[0]/3)) );
sprintf(buf, "M%d %dC%d %d", WTSM(static_cast<int>(xarr[0])), WTSM(static_cast<int>(yarr[0])),
WTSM(static_cast<int>(xarr[0] + xb[0]/3)), WTSM(static_cast<int>(yarr[0] + yb[0]/3)) );
oustr += ascii(buf);
for( i = 1 ; i < n ; i++ ){
if( i == n -1 ){
sprintf(buf, " %d %d %d %dz",
WTSM((int)(xarr[i] - xb[i]/3)), WTSM((int)(yarr[i] - yb[i]/3)),
WTSM((int)xarr[i]), WTSM((int)yarr[i]) );
WTSM(static_cast<int>(xarr[i] - xb[i]/3)), WTSM(static_cast<int>(yarr[i] - yb[i]/3)),
WTSM(static_cast<int>(xarr[i])), WTSM(static_cast<int>(yarr[i])) );
}
else{
sprintf(buf, " %d %d %d %d %d %d",
WTSM((int)(xarr[i] - xb[i]/3)), WTSM((int)(yarr[i] - yb[i]/3)),
WTSM((int)xarr[i]), WTSM((int)yarr[i]),
WTSM((int)xarr[i] + xb[i]/3), WTSM((int)(yarr[i] + yb[i]/3)) );
WTSM(static_cast<int>(xarr[i] - xb[i]/3)), WTSM(static_cast<int>(yarr[i] - yb[i]/3)),
WTSM(static_cast<int>(xarr[i])), WTSM(static_cast<int>(yarr[i])),
WTSM(static_cast<int>(xarr[i]) + xb[i]/3), WTSM(static_cast<int>(yarr[i] + yb[i]/3)) );
}
oustr += ascii(buf);
......
......@@ -71,7 +71,7 @@
* we want to instead treat it as an 8-bit unsigned char, hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
#define YY_SC_TO_UI(c) (static_cast<unsigned int>(static_cast<unsigned char>(c)))
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state.
......@@ -220,7 +220,7 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
*/
#define YY_DO_BEFORE_ACTION \
yytext_ptr = yy_bp; \
yyleng = (int) (yy_cp - yy_bp); \
yyleng = static_cast<int>(yy_cp - yy_bp); \
yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yy_c_buf_p = yy_cp;
......@@ -1024,9 +1024,9 @@ YY_MALLOC_DECL
int c = '*', n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
buf[n] = static_cast<char>(c); \
if ( c == '\n' ) \
buf[n++] = (char) c; \
buf[n++] = static_cast<char>(c); \
if ( c == EOF && ferror( yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
......@@ -1125,11 +1125,11 @@ yy_match:
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
yy_current_state = static_cast<int>(yy_def[yy_current_state]);
if ( yy_current_state >= 994 )
yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[(unsigned int) yy_c]);
yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[static_cast<unsigned int>(yy_c)]);
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_current_state = yy_nxt[yy_base[yy_current_state] + static_cast<unsigned int>(yy_c)];
++yy_cp;
}
while ( yy_base[yy_current_state] != 1315 );
......@@ -1348,7 +1348,7 @@ case YY_STATE_EOF(INITIAL):
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
int yy_amount_of_matched_text = static_cast<int>(yy_cp - yytext_ptr) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = yy_hold_char;
......@@ -1516,7 +1516,7 @@ static int yy_get_next_buffer()
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
number_to_move = static_cast<int>(yy_c_buf_p - yytext_ptr) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
......@@ -1543,7 +1543,7 @@ static int yy_get_next_buffer()
YY_BUFFER_STATE b = yy_current_buffer;
int yy_c_buf_p_offset =
(int) (yy_c_buf_p - b->yy_ch_buf);
static_cast<int>(yy_c_buf_p - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
......@@ -1632,11 +1632,11 @@ static yy_state_type yy_get_previous_state()
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
yy_current_state = static_cast<int>(yy_def[yy_current_state]);
if ( yy_current_state >= 994 )
yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[(unsigned int) yy_c]);
yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[static_cast<unsigned int>(yy_c)]);
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_current_state = yy_nxt[yy_base[yy_current_state] + static_cast<unsigned int>(yy_c)];
}
return yy_current_state;
......@@ -1667,11 +1667,11 @@ yy_state_type yy_current_state;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
yy_current_state = static_cast<int>(yy_def[yy_current_state]);
if ( yy_current_state >= 994 )
yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[(unsigned int) yy_c]);
yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[static_cast<unsigned int>(yy_c)]);
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_current_state = yy_nxt[yy_base[yy_current_state] + static_cast<unsigned int>(yy_c)];
yy_is_jam = (yy_current_state == 993);
return yy_is_jam ? 0 : yy_current_state;
......
......@@ -96,10 +96,10 @@ class MzString
MzString &operator << (const char *);
MzString &operator << (char);
MzString &operator << (unsigned char c) { return *this<<(char)c; }
MzString &operator << (unsigned char c) { return *this<<static_cast<char>(c); }
MzString &operator << (int);
MzString &operator << (long);
MzString &operator << (short i) { return *this<<(int)i; }
MzString &operator << (short i) { return *this<<static_cast<int>(i); }
MzString &operator << (MzString const &);
/* MzString &operator << (MzString *s) { return *this<<*s; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment