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
d2723461
Commit
d2723461
authored
May 27, 2015
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 27, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
riched20: Implement SetText for regular range.
parent
aa37c179
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
157 additions
and
3 deletions
+157
-3
richole.c
dlls/riched20/richole.c
+70
-3
richole.c
dlls/riched20/tests/richole.c
+87
-0
No files found.
dlls/riched20/richole.c
View file @
d2723461
...
@@ -201,6 +201,10 @@ typedef union {
...
@@ -201,6 +201,10 @@ typedef union {
BSTR
str
;
BSTR
str
;
}
textfont_prop_val
;
}
textfont_prop_val
;
enum
range_update_op
{
RANGE_UPDATE_DELETE
};
typedef
struct
IRichEditOleImpl
{
typedef
struct
IRichEditOleImpl
{
IUnknown
IUnknown_inner
;
IUnknown
IUnknown_inner
;
IRichEditOle
IRichEditOle_iface
;
IRichEditOle
IRichEditOle_iface
;
...
@@ -304,6 +308,35 @@ static inline ITextParaImpl *impl_from_ITextPara(ITextPara *iface)
...
@@ -304,6 +308,35 @@ static inline ITextParaImpl *impl_from_ITextPara(ITextPara *iface)
static
HRESULT
create_textfont
(
ITextRange
*
,
const
ITextFontImpl
*
,
ITextFont
**
);
static
HRESULT
create_textfont
(
ITextRange
*
,
const
ITextFontImpl
*
,
ITextFont
**
);
static
HRESULT
create_textpara
(
ITextRange
*
,
ITextPara
**
);
static
HRESULT
create_textpara
(
ITextRange
*
,
ITextPara
**
);
static
void
textranges_update_ranges
(
IRichEditOleImpl
*
reole
,
LONG
start
,
LONG
end
,
enum
range_update_op
op
)
{
ITextRangeImpl
*
range
;
LIST_FOR_EACH_ENTRY
(
range
,
&
reole
->
rangelist
,
ITextRangeImpl
,
entry
)
{
switch
(
op
)
{
case
RANGE_UPDATE_DELETE
:
/* range fully covered by deleted range - collapse to insertion point */
if
(
range
->
start
>=
start
&&
range
->
end
<=
end
)
range
->
start
=
range
->
end
=
start
;
/* deleted range cuts from the right */
else
if
(
range
->
start
<
start
&&
range
->
end
<=
end
)
range
->
end
=
start
;
/* deleted range cuts from the left */
else
if
(
range
->
start
>=
start
&&
range
->
end
>
end
)
{
range
->
start
=
start
;
range
->
end
-=
end
-
start
;
}
/* deleted range cuts within */
else
range
->
end
-=
end
-
start
;
break
;
default:
FIXME
(
"unknown update op, %d
\n
"
,
op
);
}
}
}
static
inline
BOOL
is_equal_textfont_prop_value
(
enum
textfont_prop_id
propid
,
textfont_prop_val
*
left
,
static
inline
BOOL
is_equal_textfont_prop_value
(
enum
textfont_prop_id
propid
,
textfont_prop_val
*
left
,
textfont_prop_val
*
right
)
textfont_prop_val
*
right
)
{
{
...
@@ -1376,14 +1409,48 @@ static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr)
...
@@ -1376,14 +1409,48 @@ static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr)
return
E_NOTIMPL
;
return
E_NOTIMPL
;
}
}
static
HRESULT
WINAPI
ITextRange_fnSetText
(
ITextRange
*
me
,
BSTR
b
str
)
static
HRESULT
WINAPI
ITextRange_fnSetText
(
ITextRange
*
me
,
BSTR
str
)
{
{
ITextRangeImpl
*
This
=
impl_from_ITextRange
(
me
);
ITextRangeImpl
*
This
=
impl_from_ITextRange
(
me
);
ME_TextEditor
*
editor
;
ME_Cursor
cursor
;
ME_Style
*
style
;
int
len
;
TRACE
(
"(%p)->(%s)
\n
"
,
This
,
debugstr_w
(
str
));
if
(
!
This
->
reOle
)
if
(
!
This
->
reOle
)
return
CO_E_RELEASED
;
return
CO_E_RELEASED
;
FIXME
(
"not implemented %p
\n
"
,
This
);
editor
=
This
->
reOle
->
editor
;
return
E_NOTIMPL
;
/* delete only where's something to delete */
if
(
This
->
start
!=
This
->
end
)
{
ME_CursorFromCharOfs
(
editor
,
This
->
start
,
&
cursor
);
ME_InternalDeleteText
(
editor
,
&
cursor
,
This
->
end
-
This
->
start
,
FALSE
);
}
if
(
!
str
||
!*
str
)
{
/* will update this range as well */
textranges_update_ranges
(
This
->
reOle
,
This
->
start
,
This
->
end
,
RANGE_UPDATE_DELETE
);
return
S_OK
;
}
/* it's safer not to rely on stored BSTR length */
len
=
strlenW
(
str
);
cursor
=
editor
->
pCursors
[
0
];
ME_CursorFromCharOfs
(
editor
,
This
->
start
,
&
editor
->
pCursors
[
0
]);
style
=
ME_GetInsertStyle
(
editor
,
0
);
ME_InsertTextFromCursor
(
editor
,
0
,
str
,
len
,
style
);
ME_ReleaseStyle
(
style
);
editor
->
pCursors
[
0
]
=
cursor
;
if
(
len
<
This
->
end
-
This
->
start
)
textranges_update_ranges
(
This
->
reOle
,
This
->
start
+
len
,
This
->
end
,
RANGE_UPDATE_DELETE
);
else
This
->
end
=
len
-
This
->
start
;
return
S_OK
;
}
}
static
HRESULT
range_GetChar
(
ME_TextEditor
*
editor
,
ME_Cursor
*
cursor
,
LONG
*
pch
)
static
HRESULT
range_GetChar
(
ME_TextEditor
*
editor
,
ME_Cursor
*
cursor
,
LONG
*
pch
)
...
...
dlls/riched20/tests/richole.c
View file @
d2723461
...
@@ -2401,6 +2401,92 @@ todo_wine
...
@@ -2401,6 +2401,92 @@ todo_wine
release_interfaces
(
&
hwnd
,
&
reOle
,
&
doc
,
NULL
);
release_interfaces
(
&
hwnd
,
&
reOle
,
&
doc
,
NULL
);
}
}
static
void
test_SetText
(
void
)
{
static
const
CHAR
test_text1
[]
=
"TestSomeText"
;
static
const
WCHAR
textW
[]
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
0
};
IRichEditOle
*
reOle
=
NULL
;
ITextDocument
*
doc
=
NULL
;
ITextRange
*
range
,
*
range2
;
LONG
value
;
HRESULT
hr
;
HWND
hwnd
;
BSTR
str
;
create_interfaces
(
&
hwnd
,
&
reOle
,
&
doc
,
NULL
);
SendMessageA
(
hwnd
,
WM_SETTEXT
,
0
,
(
LPARAM
)
test_text1
);
hr
=
ITextDocument_Range
(
doc
,
0
,
4
,
&
range
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
ITextDocument_Range
(
doc
,
0
,
4
,
&
range2
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
value
=
1
;
hr
=
ITextRange_GetStart
(
range2
,
&
value
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
value
==
0
,
"got %d
\n
"
,
value
);
value
=
0
;
hr
=
ITextRange_GetEnd
(
range2
,
&
value
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
value
==
4
,
"got %d
\n
"
,
value
);
hr
=
ITextRange_SetText
(
range
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
value
=
1
;
hr
=
ITextRange_GetEnd
(
range2
,
&
value
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
value
==
0
,
"got %d
\n
"
,
value
);
str
=
SysAllocString
(
textW
);
hr
=
ITextRange_SetText
(
range
,
str
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
value
=
1
;
hr
=
ITextRange_GetStart
(
range
,
&
value
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
value
==
0
,
"got %d
\n
"
,
value
);
value
=
0
;
hr
=
ITextRange_GetEnd
(
range
,
&
value
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
value
==
9
,
"got %d
\n
"
,
value
);
value
=
1
;
hr
=
ITextRange_GetStart
(
range2
,
&
value
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
value
==
0
,
"got %d
\n
"
,
value
);
value
=
0
;
hr
=
ITextRange_GetEnd
(
range2
,
&
value
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
value
==
0
,
"got %d
\n
"
,
value
);
str
=
SysAllocStringLen
(
NULL
,
0
);
hr
=
ITextRange_SetText
(
range
,
str
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
value
=
1
;
hr
=
ITextRange_GetEnd
(
range
,
&
value
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
value
==
0
,
"got %d
\n
"
,
value
);
SysFreeString
(
str
);
ITextRange_Release
(
range2
);
release_interfaces
(
&
hwnd
,
&
reOle
,
&
doc
,
NULL
);
hr
=
ITextRange_SetText
(
range
,
NULL
);
ok
(
hr
==
CO_E_RELEASED
,
"got 0x%08x
\n
"
,
hr
);
str
=
SysAllocStringLen
(
NULL
,
0
);
hr
=
ITextRange_SetText
(
range
,
str
);
ok
(
hr
==
CO_E_RELEASED
,
"got 0x%08x
\n
"
,
hr
);
SysFreeString
(
str
);
ITextRange_Release
(
range
);
}
START_TEST
(
richole
)
START_TEST
(
richole
)
{
{
/* Must explicitly LoadLibrary(). The test has no references to functions in
/* Must explicitly LoadLibrary(). The test has no references to functions in
...
@@ -2427,4 +2513,5 @@ START_TEST(richole)
...
@@ -2427,4 +2513,5 @@ START_TEST(richole)
test_dispatch
();
test_dispatch
();
test_ITextFont
();
test_ITextFont
();
test_Delete
();
test_Delete
();
test_SetText
();
}
}
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