Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e060272d
Commit
e060272d
authored
Sep 25, 2011
by
Dylan Smith
Committed by
Alexandre Julliard
Sep 26, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
richedit: Return number of bytes read for EM_STREAMIN with SF_TEXT.
parent
9c0085aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
17 deletions
+46
-17
editor.c
dlls/riched20/editor.c
+10
-7
editor.c
dlls/riched20/tests/editor.c
+36
-10
No files found.
dlls/riched20/editor.c
View file @
e060272d
...
@@ -285,9 +285,10 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
...
@@ -285,9 +285,10 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
{
{
WCHAR
wszText
[
STREAMIN_BUFFER_SIZE
+
1
];
WCHAR
wszText
[
STREAMIN_BUFFER_SIZE
+
1
];
WCHAR
*
pText
;
WCHAR
*
pText
;
LRESULT
total_bytes_read
=
0
;
TRACE
(
"%08x %p
\n
"
,
dwFormat
,
stream
);
TRACE
(
"%08x %p
\n
"
,
dwFormat
,
stream
);
do
{
do
{
LONG
nWideChars
=
0
;
LONG
nWideChars
=
0
;
...
@@ -298,8 +299,9 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
...
@@ -298,8 +299,9 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
break
;
break
;
if
(
!
stream
->
dwSize
)
if
(
!
stream
->
dwSize
)
break
;
break
;
total_bytes_read
+=
stream
->
dwSize
;
}
}
if
(
!
(
dwFormat
&
SF_UNICODE
))
if
(
!
(
dwFormat
&
SF_UNICODE
))
{
{
/* FIXME? this is doomed to fail on true MBCS like UTF-8, luckily they're unlikely to be used as CP_ACP */
/* FIXME? this is doomed to fail on true MBCS like UTF-8, luckily they're unlikely to be used as CP_ACP */
...
@@ -311,13 +313,13 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
...
@@ -311,13 +313,13 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
nWideChars
=
stream
->
dwSize
>>
1
;
nWideChars
=
stream
->
dwSize
>>
1
;
pText
=
(
WCHAR
*
)
stream
->
buffer
;
pText
=
(
WCHAR
*
)
stream
->
buffer
;
}
}
ME_InsertTextFromCursor
(
editor
,
0
,
pText
,
nWideChars
,
style
);
ME_InsertTextFromCursor
(
editor
,
0
,
pText
,
nWideChars
,
style
);
if
(
stream
->
dwSize
==
0
)
if
(
stream
->
dwSize
==
0
)
break
;
break
;
stream
->
dwSize
=
0
;
stream
->
dwSize
=
0
;
}
while
(
1
);
}
while
(
1
);
return
0
;
return
total_bytes_read
;
}
}
static
void
ME_ApplyBorderProperties
(
RTF_Info
*
info
,
static
void
ME_ApplyBorderProperties
(
RTF_Info
*
info
,
...
@@ -1390,6 +1392,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
...
@@ -1390,6 +1392,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
ME_InStream
inStream
;
ME_InStream
inStream
;
BOOL
invalidRTF
=
FALSE
;
BOOL
invalidRTF
=
FALSE
;
ME_Cursor
*
selStart
,
*
selEnd
;
ME_Cursor
*
selStart
,
*
selEnd
;
LRESULT
num_read
=
0
;
/* bytes read for SF_TEXT, non-control chars inserted for SF_RTF */
TRACE
(
"stream==%p editor==%p format==0x%X
\n
"
,
stream
,
editor
,
format
);
TRACE
(
"stream==%p editor==%p format==0x%X
\n
"
,
stream
,
editor
,
format
);
editor
->
nEventMask
=
0
;
editor
->
nEventMask
=
0
;
...
@@ -1564,7 +1567,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
...
@@ -1564,7 +1567,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
style
=
parser
.
style
;
style
=
parser
.
style
;
}
}
else
if
(
format
&
SF_TEXT
)
else
if
(
format
&
SF_TEXT
)
ME_StreamInText
(
editor
,
format
,
&
inStream
,
style
);
num_read
=
ME_StreamInText
(
editor
,
format
,
&
inStream
,
style
);
else
else
ERR
(
"EM_STREAMIN without SF_TEXT or SF_RTF
\n
"
);
ERR
(
"EM_STREAMIN without SF_TEXT or SF_RTF
\n
"
);
/* put the cursor at the top */
/* put the cursor at the top */
...
@@ -1594,7 +1597,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
...
@@ -1594,7 +1597,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
ME_SendSelChange
(
editor
);
ME_SendSelChange
(
editor
);
ME_SendRequestResize
(
editor
,
FALSE
);
ME_SendRequestResize
(
editor
,
FALSE
);
return
0
;
return
num_read
;
}
}
...
...
dlls/riched20/tests/editor.c
View file @
e060272d
...
@@ -5040,20 +5040,29 @@ static void test_EM_STREAMIN(void)
...
@@ -5040,20 +5040,29 @@ static void test_EM_STREAMIN(void)
const
char
*
streamText3
=
"RichEdit1"
;
const
char
*
streamText3
=
"RichEdit1"
;
struct
StringWithLength
cookieForStream4
;
const
char
*
streamText4
=
const
char
*
streamText4
=
"This text just needs to be long enough to cause run to be split onto "
"This text just needs to be long enough to cause run to be split onto "
"two separate lines and make sure the null terminating character is "
"two separate lines and make sure the null terminating character is "
"handled properly.
\0
"
;
"handled properly.
\0
"
;
int
length4
=
strlen
(
streamText4
)
+
1
;
int
length4
=
strlen
(
streamText4
)
+
1
;
cookieForStream4
.
buffer
=
(
char
*
)
streamText4
;
struct
StringWithLength
cookieForStream4
=
{
cookieForStream4
.
length
=
length4
;
length4
,
(
char
*
)
streamText4
,
};
const
WCHAR
streamText5
[]
=
{
'T'
,
'e'
,
's'
,
't'
,
'S'
,
'o'
,
'm'
,
'e'
,
'T'
,
'e'
,
'x'
,
't'
};
int
length5
=
sizeof
(
streamText5
)
/
sizeof
(
WCHAR
);
struct
StringWithLength
cookieForStream5
=
{
sizeof
(
streamText5
),
(
char
*
)
streamText5
,
};
/* Minimal test without \par at the end */
/* Minimal test without \par at the end */
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText0
;
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText0
;
es
.
dwError
=
0
;
es
.
dwError
=
0
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback
;
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
todo_wine
ok
(
result
==
12
,
"got %ld, expected %d
\n
"
,
result
,
12
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
12
,
ok
(
result
==
12
,
...
@@ -5067,7 +5076,8 @@ static void test_EM_STREAMIN(void)
...
@@ -5067,7 +5076,8 @@ static void test_EM_STREAMIN(void)
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText0a
;
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText0a
;
es
.
dwError
=
0
;
es
.
dwError
=
0
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback
;
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
todo_wine
ok
(
result
==
12
,
"got %ld, expected %d
\n
"
,
result
,
12
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
12
,
ok
(
result
==
12
,
...
@@ -5081,7 +5091,8 @@ static void test_EM_STREAMIN(void)
...
@@ -5081,7 +5091,8 @@ static void test_EM_STREAMIN(void)
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText0b
;
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText0b
;
es
.
dwError
=
0
;
es
.
dwError
=
0
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback
;
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
todo_wine
ok
(
result
==
13
,
"got %ld, expected %d
\n
"
,
result
,
13
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
14
,
ok
(
result
==
14
,
...
@@ -5094,7 +5105,8 @@ static void test_EM_STREAMIN(void)
...
@@ -5094,7 +5105,8 @@ static void test_EM_STREAMIN(void)
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText1
;
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText1
;
es
.
dwError
=
0
;
es
.
dwError
=
0
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback
;
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
todo_wine
ok
(
result
==
12
,
"got %ld, expected %d
\n
"
,
result
,
12
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
12
,
ok
(
result
==
12
,
...
@@ -5106,7 +5118,8 @@ static void test_EM_STREAMIN(void)
...
@@ -5106,7 +5118,8 @@ static void test_EM_STREAMIN(void)
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText2
;
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText2
;
es
.
dwError
=
0
;
es
.
dwError
=
0
;
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
ok
(
result
==
0
,
"got %ld, expected %d
\n
"
,
result
,
0
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
0
,
ok
(
result
==
0
,
...
@@ -5117,7 +5130,8 @@ static void test_EM_STREAMIN(void)
...
@@ -5117,7 +5130,8 @@ static void test_EM_STREAMIN(void)
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText3
;
es
.
dwCookie
=
(
DWORD_PTR
)
&
streamText3
;
es
.
dwError
=
0
;
es
.
dwError
=
0
;
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
ok
(
result
==
0
,
"got %ld, expected %d
\n
"
,
result
,
0
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
0
,
ok
(
result
==
0
,
...
@@ -5129,13 +5143,25 @@ static void test_EM_STREAMIN(void)
...
@@ -5129,13 +5143,25 @@ static void test_EM_STREAMIN(void)
es
.
dwCookie
=
(
DWORD_PTR
)
&
cookieForStream4
;
es
.
dwCookie
=
(
DWORD_PTR
)
&
cookieForStream4
;
es
.
dwError
=
0
;
es
.
dwError
=
0
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback2
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback2
;
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_TEXT
,
(
LPARAM
)
&
es
);
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_TEXT
,
(
LPARAM
)
&
es
);
ok
(
result
==
length4
,
"got %ld, expected %d
\n
"
,
result
,
length4
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
length4
,
ok
(
result
==
length4
,
"EM_STREAMIN: Test 4 returned %ld, expected %d
\n
"
,
result
,
length4
);
"EM_STREAMIN: Test 4 returned %ld, expected %d
\n
"
,
result
,
length4
);
ok
(
es
.
dwError
==
0
,
"EM_STREAMIN: Test 4 set error %d, expected %d
\n
"
,
es
.
dwError
,
0
);
ok
(
es
.
dwError
==
0
,
"EM_STREAMIN: Test 4 set error %d, expected %d
\n
"
,
es
.
dwError
,
0
);
es
.
dwCookie
=
(
DWORD_PTR
)
&
cookieForStream5
;
es
.
dwError
=
0
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback2
;
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_TEXT
|
SF_UNICODE
,
(
LPARAM
)
&
es
);
ok
(
result
==
sizeof
(
streamText5
),
"got %ld, expected %u
\n
"
,
result
,
(
UINT
)
sizeof
(
streamText5
));
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
length5
,
"EM_STREAMIN: Test 4 returned %ld, expected %d
\n
"
,
result
,
length5
);
ok
(
es
.
dwError
==
0
,
"EM_STREAMIN: Test 5 set error %d, expected %d
\n
"
,
es
.
dwError
,
0
);
DestroyWindow
(
hwndRichEdit
);
DestroyWindow
(
hwndRichEdit
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment