winhlp32: Rework and rename HLPFILE_HalfPointsToTwips.

HLPFILE_HalfPointsToTwips was performing a useless transformation of the
RTF measures, using a hardcoded 72 DPI. As winhlp32 makes use of the
richedit component, it is counter productive to transform the measures,
as this is taken care of by richedit himself.

Signed-off-by: Jean-Christophe Cardot <wine@cardot.net>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Jean-Christophe Cardot 2016-04-10 22:06:11 +02:00 committed by Alexandre Julliard
parent 5200dc9b05
commit a01c003007
1 changed files with 16 additions and 23 deletions

View File

@ -1199,16 +1199,9 @@ static HLPFILE_LINK* HLPFILE_AllocLink(struct RtfData* rd, int cookie,
return link; return link;
} }
static unsigned HLPFILE_HalfPointsToTwips(unsigned pts) static unsigned HLPFILE_HalfPointsScale(HLPFILE_PAGE* page, unsigned pts)
{ {
static unsigned logPxY; return pts * page->file->scale - page->file->rounderr;
if (!logPxY)
{
HDC hdc = GetDC(NULL);
logPxY = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
}
return MulDiv(pts, 72 * 10, logPxY);
} }
/*********************************************************************** /***********************************************************************
@ -1289,10 +1282,10 @@ static BOOL HLPFILE_BrowseParagraph(HLPFILE_PAGE* page, struct RtfData* rd,
{ {
int pos; int pos;
sprintf(tmp, "\\trgaph%d\\trleft%d", sprintf(tmp, "\\trgaph%d\\trleft%d",
HLPFILE_HalfPointsToTwips(MulDiv(GET_SHORT(format, 6), table_width, 32767)), HLPFILE_HalfPointsScale(page, MulDiv(GET_SHORT(format, 6), table_width, 32767)),
HLPFILE_HalfPointsToTwips(MulDiv(GET_SHORT(format, 0), table_width, 32767))); HLPFILE_HalfPointsScale(page, MulDiv(GET_SHORT(format, 0), table_width, 32767)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
pos = HLPFILE_HalfPointsToTwips(MulDiv(GET_SHORT(format, 6) / 2, table_width, 32767)); pos = HLPFILE_HalfPointsScale(page, MulDiv(GET_SHORT(format, 6) / 2, table_width, 32767));
for (nc = 0; nc < ncol; nc++) for (nc = 0; nc < ncol; nc++)
{ {
WINE_TRACE("column(%d/%d) gap=%d width=%d\n", WINE_TRACE("column(%d/%d) gap=%d width=%d\n",
@ -1300,7 +1293,7 @@ static BOOL HLPFILE_BrowseParagraph(HLPFILE_PAGE* page, struct RtfData* rd,
GET_SHORT(format, nc*4+2)); GET_SHORT(format, nc*4+2));
pos += GET_SHORT(format, nc * 4) + GET_SHORT(format, nc * 4 + 2); pos += GET_SHORT(format, nc * 4) + GET_SHORT(format, nc * 4 + 2);
sprintf(tmp, "\\cellx%d", sprintf(tmp, "\\cellx%d",
HLPFILE_HalfPointsToTwips(MulDiv(pos, table_width, 32767))); HLPFILE_HalfPointsScale(page, MulDiv(pos, table_width, 32767)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
} }
@ -1309,8 +1302,8 @@ static BOOL HLPFILE_BrowseParagraph(HLPFILE_PAGE* page, struct RtfData* rd,
WINE_TRACE("column(0/%d) gap=%d width=%d\n", WINE_TRACE("column(0/%d) gap=%d width=%d\n",
ncol, GET_SHORT(format, 0), GET_SHORT(format, 2)); ncol, GET_SHORT(format, 0), GET_SHORT(format, 2));
sprintf(tmp, "\\trleft%d\\cellx%d ", sprintf(tmp, "\\trleft%d\\cellx%d ",
HLPFILE_HalfPointsToTwips(MulDiv(GET_SHORT(format, 0), table_width, 32767)), HLPFILE_HalfPointsScale(page, MulDiv(GET_SHORT(format, 0), table_width, 32767)),
HLPFILE_HalfPointsToTwips(MulDiv(GET_SHORT(format, 0) + GET_SHORT(format, 2), HLPFILE_HalfPointsScale(page, MulDiv(GET_SHORT(format, 0) + GET_SHORT(format, 2),
table_width, 32767))); table_width, 32767)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
@ -1337,32 +1330,32 @@ static BOOL HLPFILE_BrowseParagraph(HLPFILE_PAGE* page, struct RtfData* rd,
if (bits & 0x0001) fetch_long(&format); if (bits & 0x0001) fetch_long(&format);
if (bits & 0x0002) if (bits & 0x0002)
{ {
sprintf(tmp, "\\sb%d", HLPFILE_HalfPointsToTwips(fetch_short(&format))); sprintf(tmp, "\\sb%d", HLPFILE_HalfPointsScale(page, fetch_short(&format)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
if (bits & 0x0004) if (bits & 0x0004)
{ {
sprintf(tmp, "\\sa%d", HLPFILE_HalfPointsToTwips(fetch_short(&format))); sprintf(tmp, "\\sa%d", HLPFILE_HalfPointsScale(page, fetch_short(&format)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
if (bits & 0x0008) if (bits & 0x0008)
{ {
sprintf(tmp, "\\sl%d", HLPFILE_HalfPointsToTwips(fetch_short(&format))); sprintf(tmp, "\\sl%d", HLPFILE_HalfPointsScale(page, fetch_short(&format)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
if (bits & 0x0010) if (bits & 0x0010)
{ {
sprintf(tmp, "\\li%d", HLPFILE_HalfPointsToTwips(fetch_short(&format))); sprintf(tmp, "\\li%d", HLPFILE_HalfPointsScale(page, fetch_short(&format)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
if (bits & 0x0020) if (bits & 0x0020)
{ {
sprintf(tmp, "\\ri%d", HLPFILE_HalfPointsToTwips(fetch_short(&format))); sprintf(tmp, "\\ri%d", HLPFILE_HalfPointsScale(page, fetch_short(&format)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
if (bits & 0x0040) if (bits & 0x0040)
{ {
sprintf(tmp, "\\fi%d", HLPFILE_HalfPointsToTwips(fetch_short(&format))); sprintf(tmp, "\\fi%d", HLPFILE_HalfPointsScale(page, fetch_short(&format)));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
if (bits & 0x0100) if (bits & 0x0100)
@ -1383,7 +1376,7 @@ static BOOL HLPFILE_BrowseParagraph(HLPFILE_PAGE* page, struct RtfData* rd,
w = GET_SHORT(format, 0); format += 2; w = GET_SHORT(format, 0); format += 2;
if (w) if (w)
{ {
sprintf(tmp, "\\brdrw%d", HLPFILE_HalfPointsToTwips(w)); sprintf(tmp, "\\brdrw%d", HLPFILE_HalfPointsScale(page, w));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
} }
@ -1407,7 +1400,7 @@ static BOOL HLPFILE_BrowseParagraph(HLPFILE_PAGE* page, struct RtfData* rd,
} }
/* FIXME: do kind */ /* FIXME: do kind */
sprintf(tmp, "%s\\tx%d", sprintf(tmp, "%s\\tx%d",
kind, HLPFILE_HalfPointsToTwips(tab & 0x3FFF)); kind, HLPFILE_HalfPointsScale(page, tab & 0x3FFF));
if (!HLPFILE_RtfAddControl(rd, tmp)) goto done; if (!HLPFILE_RtfAddControl(rd, tmp)) goto done;
} }
} }