Commit 86f077b1 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Add an explicit run length member and use it rather than accessing the string length.

parent f24ba125
......@@ -236,7 +236,7 @@ ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
assert(run);
assert(run->type == diRun);
sz = ME_GetRunSize(&c, &para->member.para,
&run->member.run, run->member.run.strText->nLen,
&run->member.run, run->member.run.len,
row->member.row.nLMargin);
}
}
......@@ -317,11 +317,11 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
/* We aren't deleting anything in this run, so we will go back to the
* last run we are deleting text in. */
ME_PrevRun(&c.pPara, &c.pRun);
c.nOffset = c.pRun->member.run.strText->nLen;
c.nOffset = c.pRun->member.run.len;
}
run = &c.pRun->member.run;
if (run->nFlags & MERF_ENDPARA) {
int eollen = c.pRun->member.run.strText->nLen;
int eollen = c.pRun->member.run.len;
BOOL keepFirstParaFormat;
if (!ME_FindItemFwd(c.pRun, diParagraph))
......@@ -376,15 +376,16 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
shift -= nCharsToDelete;
TRACE("Deleting %d (remaning %d) chars at %d in %s (%d)\n",
nCharsToDelete, nChars, c.nOffset,
debugstr_run( run ), run->strText->nLen);
debugstr_run( run ), run->len);
/* nOfs is a character offset (from the start of the document
to the current (deleted) run */
add_undo_insert_run( editor, nOfs + nChars, get_text( run, c.nOffset ), nCharsToDelete, run->nFlags, run->style );
TRACE("Post deletion string: %s (%d)\n", debugstr_run( run ), run->strText->nLen);
TRACE("Shift value: %d\n", shift);
ME_StrDeleteV(run->strText, c.nOffset, nCharsToDelete);
run->len -= nCharsToDelete;
TRACE("Post deletion string: %s (%d)\n", debugstr_run( run ), run->len);
TRACE("Shift value: %d\n", shift);
/* update cursors (including c) */
for (i=-1; i<editor->nCursors; i++) {
......@@ -397,9 +398,9 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
else
pThisCur->nOffset -= nCharsToDelete;
assert(pThisCur->nOffset >= 0);
assert(pThisCur->nOffset <= run->strText->nLen);
assert(pThisCur->nOffset <= run->len);
}
if (pThisCur->nOffset == run->strText->nLen)
if (pThisCur->nOffset == run->len)
{
pThisCur->pRun = ME_FindItemFwd(pThisCur->pRun, diRunOrParagraphOrEnd);
assert(pThisCur->pRun->type == diRun);
......@@ -415,9 +416,9 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
else
ME_PropagateCharOffset(c.pRun, shift);
if (!cursor.pRun->member.run.strText->nLen)
if (!cursor.pRun->member.run.len)
{
TRACE("Removing useless run\n");
TRACE("Removing empty run\n");
ME_Remove(cursor.pRun);
ME_DestroyDisplayItem(cursor.pRun);
}
......@@ -625,7 +626,7 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
cursor->pRun = ME_FindItemBack(cursor->pRun, diRun);
}
cursor->nOffset -= cursor->pRun->member.run.nCharOfs;
} else if (cursor->nOffset >= cursor->pRun->member.run.strText->nLen) {
} else if (cursor->nOffset >= cursor->pRun->member.run.len) {
ME_DisplayItem *next_para;
int new_offset;
......@@ -635,9 +636,9 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
{
/* new offset in the same paragraph */
do {
cursor->nOffset -= cursor->pRun->member.run.strText->nLen;
cursor->nOffset -= cursor->pRun->member.run.len;
cursor->pRun = ME_FindItemFwd(cursor->pRun, diRun);
} while (cursor->nOffset >= cursor->pRun->member.run.strText->nLen);
} while (cursor->nOffset >= cursor->pRun->member.run.len);
return nRelOfs;
}
......@@ -657,9 +658,9 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
cursor->nOffset = new_offset - cursor->pPara->member.para.nCharOfs;
cursor->pRun = ME_FindItemFwd(cursor->pPara, diRun);
while (cursor->nOffset >= cursor->pRun->member.run.strText->nLen)
while (cursor->nOffset >= cursor->pRun->member.run.len)
{
cursor->nOffset -= cursor->pRun->member.run.strText->nLen;
cursor->nOffset -= cursor->pRun->member.run.len;
cursor->pRun = ME_FindItemFwd(cursor->pRun, diRun);
}
} /* else new offset is in the same run */
......@@ -687,7 +688,7 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
if (pOtherRun->type == diRun)
{
if (ME_CallWordBreakProc(editor, pOtherRun->member.run.strText,
pOtherRun->member.run.strText->nLen - 1,
pOtherRun->member.run.len - 1,
WB_ISDELIMITER)
&& !(pRun->member.run.nFlags & MERF_ENDPARA)
&& !(cursor->pRun == pRun && cursor->nOffset == 0)
......@@ -695,7 +696,7 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
WB_ISDELIMITER))
break;
pRun = pOtherRun;
nOffset = pOtherRun->member.run.strText->nLen;
nOffset = pOtherRun->member.run.len;
}
else if (pOtherRun->type == diParagraph)
{
......@@ -728,7 +729,7 @@ ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
break;
nOffset = ME_CallWordBreakProc(editor, pRun->member.run.strText,
nOffset, WB_MOVEWORDRIGHT);
if (nOffset < pRun->member.run.strText->nLen)
if (nOffset < pRun->member.run.len)
break;
pOtherRun = ME_FindItemFwd(pRun, diRunOrParagraphOrEnd);
if (pOtherRun->type == diRun)
......@@ -878,7 +879,7 @@ static BOOL ME_ReturnFoundPos(ME_TextEditor *editor, ME_DisplayItem *found,
rx = 0;
result->pRun = found;
result->nOffset = ME_CharFromPointCursor(editor, rx, &found->member.run);
if (result->nOffset == found->member.run.strText->nLen && rx)
if (result->nOffset == found->member.run.len && rx)
{
result->pRun = ME_FindItemFwd(result->pRun, diRun);
result->nOffset = 0;
......@@ -1199,8 +1200,7 @@ static ME_DisplayItem *ME_FindRunInRow(ME_TextEditor *editor, ME_DisplayItem *pR
if (x >= run_x && x < run_x+width)
{
int ch = ME_CharFromPointCursor(editor, x-run_x, &pNext->member.run);
ME_String *s = pNext->member.run.strText;
if (ch < s->nLen) {
if (ch < pNext->member.run.len) {
if (pOffset)
*pOffset = ch;
return pNext;
......
......@@ -1750,7 +1750,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
/* Check to see if next character is a whitespace */
if (flags & FR_WHOLEWORD)
{
if (nCurStart + nMatched == pCurItem->member.run.strText->nLen)
if (nCurStart + nMatched == pCurItem->member.run.len)
{
pNextItem = ME_FindItemFwd(pCurItem, diRun);
nNextStart = -nMatched;
......@@ -1774,7 +1774,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
TRACE("found at %d-%d\n", cursor.nOffset, cursor.nOffset + nLen);
return cursor.nOffset;
}
if (nCurStart + nMatched == pCurItem->member.run.strText->nLen)
if (nCurStart + nMatched == pCurItem->member.run.len)
{
pCurItem = ME_FindItemFwd(pCurItem, diRun);
nCurStart = -nMatched;
......@@ -1786,7 +1786,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
wLastChar = ' ';
cursor.nOffset++;
if (cursor.nOffset == cursor.pRun->member.run.strText->nLen)
if (cursor.nOffset == cursor.pRun->member.run.len)
{
ME_NextRun(&cursor.pPara, &cursor.pRun);
cursor.nOffset = 0;
......@@ -1815,7 +1815,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
if (nCurEnd == 0)
{
ME_PrevRun(&pCurPara, &pCurItem);
nCurEnd = pCurItem->member.run.strText->nLen + nMatched;
nCurEnd = pCurItem->member.run.len + nMatched;
}
while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run, nCurEnd - nMatched - 1 ),
......@@ -1839,7 +1839,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
{
pPrevItem = ME_FindItemBack(pCurItem, diRun);
if (pPrevItem)
nPrevEnd = pPrevItem->member.run.strText->nLen + nMatched;
nPrevEnd = pPrevItem->member.run.len + nMatched;
}
if (pPrevItem)
......@@ -1866,7 +1866,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
ME_PrevRun(&pCurPara, &pCurItem);
/* Don't care about pCurItem becoming NULL here; it's already taken
* care of in the exterior loop condition */
nCurEnd = pCurItem->member.run.strText->nLen + nMatched;
nCurEnd = pCurItem->member.run.len + nMatched;
}
}
if (pCurItem)
......@@ -1878,7 +1878,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
if (cursor.nOffset < 0)
{
ME_PrevRun(&cursor.pPara, &cursor.pRun);
cursor.nOffset = cursor.pRun->member.run.strText->nLen;
cursor.nOffset = cursor.pRun->member.run.len;
}
}
}
......@@ -3011,7 +3011,7 @@ static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM
info.lParam = lParam;
cursor.nOffset = 0;
info.chrg.cpMin = ME_GetCursorOfs(&cursor);
info.chrg.cpMax = info.chrg.cpMin + cursor.pRun->member.run.strText->nLen;
info.chrg.cpMax = info.chrg.cpMin + cursor.pRun->member.run.len;
ITextHost_TxNotify(editor->texthost, info.nmhdr.code, &info);
}
}
......@@ -3708,7 +3708,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
WCHAR *str = get_text( &run->member.run, 0 );
unsigned int nCopy;
nCopy = min(nCharsLeft, run->member.run.strText->nLen);
nCopy = min(nCharsLeft, run->member.run.len);
if (unicode)
memcpy(dest, str, nCopy * sizeof(WCHAR));
......@@ -3755,7 +3755,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
assert(last_para->member.run.nFlags & MERF_ENDPARA);
if (editor->bEmulateVersion10 && prev_para &&
last_para->member.run.nCharOfs == 0 &&
prev_para->member.run.strText->nLen == 1 &&
prev_para->member.run.len == 1 &&
*get_text( &prev_para->member.run, 0 ) == '\r')
{
/* In 1.0 emulation, the last solitary \r at the very end of the text
......@@ -3820,7 +3820,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
} else {
ME_DisplayItem *endRun = ME_FindItemBack(item_end, diRun);
assert(endRun && endRun->member.run.nFlags & MERF_ENDPARA);
nNextLineOfs = item_end->member.para.nCharOfs - endRun->member.run.strText->nLen;
nNextLineOfs = item_end->member.para.nCharOfs - endRun->member.run.len;
}
nChars = nNextLineOfs - nThisLineOfs;
TRACE("EM_LINELENGTH(%ld)==%d\n",wParam, nChars);
......@@ -4604,7 +4604,7 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen,
assert(pRun);
pNextRun = ME_FindItemFwd(pRun, diRun);
nLen = pRun->member.run.strText->nLen - start->nOffset;
nLen = pRun->member.run.len - start->nOffset;
str = get_text( &pRun->member.run, start->nOffset );
/* No '\r' is appended to the last paragraph. */
......@@ -4636,7 +4636,7 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen,
pRun = pNextRun;
pNextRun = ME_FindItemFwd(pRun, diRun);
nLen = pRun->member.run.strText->nLen;
nLen = pRun->member.run.len;
str = get_text( &pRun->member.run, 0 );
}
*buffer = 0;
......@@ -4779,7 +4779,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
{
WCHAR *strStart = get_text( &cursor.pRun->member.run, 0 );
WCHAR *str = strStart + cursor.nOffset;
int nLen = cursor.pRun->member.run.strText->nLen - cursor.nOffset;
int nLen = cursor.pRun->member.run.len - cursor.nOffset;
nChars -= nLen;
if (~cursor.pRun->member.run.nFlags & MERF_ENDPARA)
......@@ -4953,9 +4953,9 @@ static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int
/* Update candidateEnd since setting character formats may split
* runs, which can cause a cursor to be at an invalid offset within
* a split run. */
while (candidateEnd.nOffset >= candidateEnd.pRun->member.run.strText->nLen)
while (candidateEnd.nOffset >= candidateEnd.pRun->member.run.len)
{
candidateEnd.nOffset -= candidateEnd.pRun->member.run.strText->nLen;
candidateEnd.nOffset -= candidateEnd.pRun->member.run.len;
candidateEnd.pRun = ME_FindItemFwd(candidateEnd.pRun, diRun);
}
modified = TRUE;
......
......@@ -145,6 +145,7 @@ typedef struct tagME_Run
ME_Style *style;
struct tagME_Paragraph *para; /* ptr to the run's paragraph */
int nCharOfs; /* relative to para's offset */
int len; /* length of run's text */
int nWidth; /* width of full run, width of leading&trailing ws */
int nFlags;
int nAscent, nDescent; /* pixels above/below baseline */
......
......@@ -425,7 +425,7 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
{
if (c->editor->cPasswordMask)
{
ME_String *szMasked = ME_MakeStringR(c->editor->cPasswordMask, run->strText->nLen);
ME_String *szMasked = ME_MakeStringR(c->editor->cPasswordMask, run->len);
ME_DrawTextWithStyle(c, x, y,
szMasked->szData, szMasked->nLen, run->style, run->nWidth,
nSelFrom-runofs,nSelTo-runofs,
......@@ -435,7 +435,7 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
}
else
ME_DrawTextWithStyle(c, x, y,
get_text( run, 0 ), run->strText->nLen, run->style, run->nWidth,
get_text( run, 0 ), run->len, run->style, run->nWidth,
nSelFrom-runofs,nSelTo-runofs,
c->pt.y + para->pt.y + start->member.row.pt.y,
start->member.row.nHeight);
......
......@@ -341,7 +341,7 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
assert(pRun->type == diRun);
assert(pRun->member.run.nFlags & MERF_ENDPARA);
end_len = pRun->member.run.strText->nLen;
end_len = pRun->member.run.len;
/* null char format operation to store the original char format for the ENDPARA run */
ME_InitCharFormat2W(&fmt);
......
......@@ -123,12 +123,12 @@ void ME_CheckCharOffsets(ME_TextEditor *editor)
case diRun:
TRACE_(richedit_check)("run, real ofs = %d (+ofsp = %d), counted = %d, len = %d, txt = %s, flags=%08x, fx&mask = %08x\n",
p->member.run.nCharOfs, p->member.run.nCharOfs+ofsp, ofsp+ofs,
p->member.run.strText->nLen, debugstr_run( &p->member.run ),
p->member.run.len, debugstr_run( &p->member.run ),
p->member.run.nFlags,
p->member.run.style->fmt.dwMask & p->member.run.style->fmt.dwEffects);
assert(ofs == p->member.run.nCharOfs);
assert(p->member.run.strText->nLen);
ofs += p->member.run.strText->nLen;
assert(p->member.run.len);
ofs += p->member.run.len;
break;
case diCell:
TRACE_(richedit_check)("cell\n");
......@@ -226,11 +226,12 @@ void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p)
for (i=0; i<editor->nCursors; i++) {
if (editor->pCursors[i].pRun == pNext) {
editor->pCursors[i].pRun = p;
editor->pCursors[i].nOffset += p->member.run.strText->nLen;
editor->pCursors[i].nOffset += p->member.run.len;
}
}
ME_AppendString(p->member.run.strText, pNext->member.run.strText);
p->member.run.len += pNext->member.run.len;
ME_Remove(pNext);
ME_DestroyDisplayItem(pNext);
ME_UpdateRunFlags(editor, &p->member.run);
......@@ -308,7 +309,7 @@ ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_Cursor *cursor)
new_run = ME_MakeRun(run->member.run.style,
ME_VSplitString(run->member.run.strText, nOffset),
run->member.run.nFlags & MERF_SPLITMASK);
run->member.run.len = nOffset;
new_run->member.run.nCharOfs = run->member.run.nCharOfs + nOffset;
new_run->member.run.para = run->member.run.para;
cursor->pRun = new_run;
......@@ -342,6 +343,7 @@ ME_DisplayItem *ME_MakeRun(ME_Style *s, ME_String *strData, int nFlags)
item->member.run.strText = strData;
item->member.run.nFlags = nFlags;
item->member.run.nCharOfs = -1;
item->member.run.len = strData->nLen;
item->member.run.para = NULL;
ME_AddRefStyle(s);
return item;
......@@ -379,10 +381,10 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
static BOOL run_is_splittable( const ME_Run *run )
{
WCHAR *str = get_text( run, 0 ), *p;
int i, len = run->strText->nLen;
int i;
BOOL found_ink = FALSE;
for (i = 0, p = str; i < len; i++, p++)
for (i = 0, p = str; i < run->len; i++, p++)
{
if (ME_IsWSpace( *p ))
{
......@@ -397,9 +399,9 @@ static BOOL run_is_splittable( const ME_Run *run )
static BOOL run_is_entirely_ws( const ME_Run *run )
{
WCHAR *str = get_text( run, 0 ), *p;
int i, len = run->strText->nLen;
int i;
for (i = 0, p = str; i < len; i++, p++)
for (i = 0, p = str; i < run->len; i++, p++)
if (!ME_IsWSpace( *p )) return FALSE;
return TRUE;
......@@ -439,7 +441,7 @@ void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
else
run->nFlags &= ~MERF_STARTWHITE;
if (ME_IsWSpace( *get_text( run, run->strText->nLen - 1 ) ))
if (ME_IsWSpace( *get_text( run, run->len - 1 ) ))
run->nFlags |= MERF_ENDWHITE;
else
run->nFlags &= ~MERF_ENDWHITE;
......@@ -461,7 +463,7 @@ int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run)
int fit = 0;
HGDIOBJ hOldFont;
SIZE sz;
if (!run->strText->nLen || cx <= 0)
if (!run->len || cx <= 0)
return 0;
if (run->nFlags & MERF_TAB ||
......@@ -483,14 +485,14 @@ int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run)
if (c->editor->cPasswordMask)
{
ME_String *strMasked = ME_MakeStringR(c->editor->cPasswordMask, run->strText->nLen);
GetTextExtentExPointW(c->hDC, strMasked->szData, run->strText->nLen,
ME_String *strMasked = ME_MakeStringR(c->editor->cPasswordMask, run->len);
GetTextExtentExPointW(c->hDC, strMasked->szData, run->len,
cx, &fit, NULL, &sz);
ME_DestroyString(strMasked);
}
else
{
GetTextExtentExPointW(c->hDC, get_text( run, 0 ), run->strText->nLen,
GetTextExtentExPointW(c->hDC, get_text( run, 0 ), run->len,
cx, &fit, NULL, &sz);
}
......@@ -514,11 +516,11 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
{
ME_String *mask_text = NULL;
WCHAR *str;
int fit = 0, len;
int fit = 0;
ME_Context c;
HGDIOBJ hOldFont;
SIZE sz, sz2, sz3;
if (!run->strText->nLen || cx <= 0)
if (!run->len || cx <= 0)
return 0;
if (run->nFlags & (MERF_TAB | MERF_ENDCELL))
......@@ -538,19 +540,18 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
return 1;
}
len = run->strText->nLen;
if (editor->cPasswordMask)
{
mask_text = ME_MakeStringR( editor->cPasswordMask, len );
mask_text = ME_MakeStringR( editor->cPasswordMask, run->len );
str = mask_text->szData;
}
else
str = get_text( run, 0 );
hOldFont = ME_SelectStyleFont(&c, run->style);
GetTextExtentExPointW(c.hDC, str, len,
GetTextExtentExPointW(c.hDC, str, run->len,
cx, &fit, NULL, &sz);
if (fit != len)
if (fit != run->len)
{
GetTextExtentPoint32W(c.hDC, str, fit, &sz2);
GetTextExtentPoint32W(c.hDC, str, fit + 1, &sz3);
......@@ -595,7 +596,6 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
ME_Context c;
ME_String *mask_text = NULL;
WCHAR *str;
int len;
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
if (pRun->nFlags & MERF_GRAPHICS)
......@@ -608,10 +608,9 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
nOffset = 0;
}
len = pRun->strText->nLen;
if (editor->cPasswordMask)
{
mask_text = ME_MakeStringR(editor->cPasswordMask, len);
mask_text = ME_MakeStringR(editor->cPasswordMask, pRun->len);
str = mask_text->szData;
}
else
......@@ -633,7 +632,7 @@ static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run
int startx, int *pAscent, int *pDescent)
{
SIZE size;
int nMaxLen = run->strText->nLen;
int nMaxLen = run->len;
if (nLen>nMaxLen)
nLen = nMaxLen;
......@@ -726,7 +725,7 @@ void ME_CalcRunExtent(ME_Context *c, const ME_Paragraph *para, int startx, ME_Ru
run->nWidth = 0;
else
{
int nEnd = run->strText->nLen;
int nEnd = run->len;
SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, startx,
&run->nAscent, &run->nDescent);
run->nWidth = size.cx;
......@@ -806,7 +805,7 @@ void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, C
/* ME_DumpStyle(new_style); */
add_undo_set_char_fmt( editor, para->member.para.nCharOfs + run->member.run.nCharOfs,
run->member.run.strText->nLen, &run->member.run.style->fmt );
run->member.run.len, &run->member.run.style->fmt );
ME_ReleaseStyle(run->member.run.style);
run->member.run.style = new_style;
run = ME_FindItemFwd(run, diRunOrParagraph);
......
......@@ -305,7 +305,7 @@ void ME_ProtectPartialTableDeletion(ME_TextEditor *editor, ME_Cursor *c, int *nC
- end_para->member.para.nCharOfs;
if (remaining)
{
assert(remaining < c2.pRun->member.run.strText->nLen);
assert(remaining < c2.pRun->member.run.len);
end_para = end_para->member.para.next_para;
}
}
......@@ -353,7 +353,7 @@ void ME_ProtectPartialTableDeletion(ME_TextEditor *editor, ME_Cursor *c, int *nC
{
ME_Run *end_run = &ME_FindItemBack(next_para, diRun)->member.run;
int nCharsNew = (next_para->member.para.nCharOfs - nOfs
- end_run->strText->nLen);
- end_run->len);
nCharsNew = max(nCharsNew, 0);
assert(nCharsNew <= *nChars);
*nChars = nCharsNew;
......
......@@ -187,7 +187,7 @@ BOOL add_undo_split_para( ME_TextEditor *editor, const ME_Paragraph *para, const
struct undo_item *undo = add_undo( editor, undo_split_para );
if (!undo) return FALSE;
undo->u.split_para.pos = para->nCharOfs - run->strText->nLen;
undo->u.split_para.pos = para->nCharOfs - run->len;
undo->u.split_para.eol_str = ME_StrDup( run->strText );
undo->u.split_para.fmt = *para->pFmt;
undo->u.split_para.border = para->border;
......
......@@ -111,7 +111,7 @@ static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd)
/* Exclude space characters from run width.
* Other whitespace or delimiters are not treated this way. */
SIZE sz;
int len = p->member.run.strText->nLen;
int len = p->member.run.len;
WCHAR *text = get_text( &p->member.run, len - 1 );
assert (len);
......@@ -120,7 +120,7 @@ static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd)
len--;
if (len)
{
if (len == p->member.run.strText->nLen)
if (len == p->member.run.len)
{
width += p->member.run.nWidth;
} else {
......@@ -233,7 +233,7 @@ static ME_DisplayItem *ME_MaximizeSplit(ME_WrapContext *wc, ME_DisplayItem *p, i
if (piter->member.run.nFlags & MERF_ENDWHITE)
{
i = ME_ReverseFindNonWhitespaceV(piter->member.run.strText,
piter->member.run.strText->nLen);
piter->member.run.len);
pp = ME_SplitRun(wc, piter, i);
wc->pt = pp->member.run.pt;
return pp;
......@@ -256,7 +256,7 @@ static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem
ME_Run *run = &p->member.run;
idesp = i = ME_CharFromPoint(wc->context, loc, run);
len = run->strText->nLen;
len = run->len;
assert(len>0);
assert(i<len);
if (i) {
......@@ -283,7 +283,7 @@ static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem
piter = wc->pLastSplittableRun;
run = &piter->member.run;
len = run->strText->nLen;
len = run->len;
/* don't split words */
i = ME_ReverseFindWhitespaceV(run->strText, len);
if (i == len)
......@@ -340,7 +340,7 @@ static ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p)
run->pt.x = wc->pt.x;
run->pt.y = wc->pt.y;
ME_WrapSizeRun(wc, p);
len = run->strText->nLen;
len = run->len;
if (wc->bOverflown) /* just skipping final whitespaces */
{
......
......@@ -870,7 +870,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
return FALSE;
}
/* Skip as many characters as required by current line break */
nChars = max(0, nChars - cursor.pRun->member.run.strText->nLen);
nChars = max(0, nChars - cursor.pRun->member.run.len);
} else if (cursor.pRun->member.run.nFlags & MERF_ENDROW) {
if (!ME_StreamOutPrint(pStream, "\\line \r\n"))
return FALSE;
......@@ -884,7 +884,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
if (!ME_StreamOutRTFCharProps(pStream, &cursor.pRun->member.run.style->fmt))
return FALSE;
nEnd = (cursor.pRun == endCur.pRun) ? endCur.nOffset : cursor.pRun->member.run.strText->nLen;
nEnd = (cursor.pRun == endCur.pRun) ? endCur.nOffset : cursor.pRun->member.run.len;
if (!ME_StreamOutRTFText(pStream, get_text( &cursor.pRun->member.run, cursor.nOffset ),
nEnd - cursor.nOffset))
return FALSE;
......@@ -919,7 +919,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream,
/* TODO: Handle SF_TEXTIZED */
while (success && nChars && cursor.pRun) {
nLen = min(nChars, cursor.pRun->member.run.strText->nLen - cursor.nOffset);
nLen = min(nChars, cursor.pRun->member.run.len - cursor.nOffset);
if (!editor->bEmulateVersion10 && cursor.pRun->member.run.nFlags & MERF_ENDPARA)
{
......
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