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
e0403efc
Commit
e0403efc
authored
Apr 21, 2015
by
Nikolay Sivov
Committed by
Alexandre Julliard
Apr 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Added a helper to get source text pointer.
parent
6e4ad78f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
32 deletions
+55
-32
analyzer.c
dlls/dwrite/analyzer.c
+55
-32
No files found.
dlls/dwrite/analyzer.c
View file @
e0403efc
...
...
@@ -676,19 +676,66 @@ static ULONG WINAPI dwritetextanalyzer_Release(IDWriteTextAnalyzer2 *iface)
return
1
;
}
/* This helper tries to get 'length' chars from a source, allocating a buffer only if source failed to provide enough
data after a first request. */
static
HRESULT
get_text_source_ptr
(
IDWriteTextAnalysisSource
*
source
,
UINT32
position
,
UINT32
length
,
const
WCHAR
**
text
,
WCHAR
**
buff
)
{
HRESULT
hr
;
UINT32
len
;
*
buff
=
NULL
;
*
text
=
NULL
;
len
=
0
;
hr
=
IDWriteTextAnalysisSource_GetTextAtPosition
(
source
,
position
,
text
,
&
len
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
len
<
length
)
{
UINT32
read
;
*
buff
=
heap_alloc
(
length
*
sizeof
(
WCHAR
));
if
(
!*
buff
)
return
E_OUTOFMEMORY
;
memcpy
(
*
buff
,
*
text
,
len
*
sizeof
(
WCHAR
));
read
=
len
;
while
(
read
<
length
&&
*
text
)
{
*
text
=
NULL
;
len
=
0
;
hr
=
IDWriteTextAnalysisSource_GetTextAtPosition
(
source
,
read
,
text
,
&
len
);
if
(
FAILED
(
hr
))
{
heap_free
(
*
buff
);
return
hr
;
}
memcpy
(
*
buff
+
read
,
*
text
,
min
(
len
,
length
-
read
)
*
sizeof
(
WCHAR
));
read
+=
len
;
}
*
text
=
*
buff
;
}
return
hr
;
}
static
HRESULT
WINAPI
dwritetextanalyzer_AnalyzeScript
(
IDWriteTextAnalyzer2
*
iface
,
IDWriteTextAnalysisSource
*
source
,
UINT32
position
,
UINT32
length
,
IDWriteTextAnalysisSink
*
sink
)
{
WCHAR
*
buff
=
NULL
;
const
WCHAR
*
text
;
HRESULT
hr
;
UINT32
len
;
TRACE
(
"(%p %u %u %p)
\n
"
,
source
,
position
,
length
,
sink
);
hr
=
IDWriteTextAnalysisSource_GetTextAtPosition
(
source
,
position
,
&
text
,
&
len
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
length
==
0
)
return
S_OK
;
hr
=
get_text_source_ptr
(
source
,
position
,
length
,
&
text
,
&
buff
);
if
(
FAILED
(
hr
))
return
hr
;
return
analyze_script
(
text
,
len
,
sink
);
hr
=
analyze_script
(
text
,
length
,
sink
);
heap_free
(
buff
);
return
hr
;
}
static
HRESULT
WINAPI
dwritetextanalyzer_AnalyzeBidi
(
IDWriteTextAnalyzer2
*
iface
,
...
...
@@ -698,7 +745,7 @@ static HRESULT WINAPI dwritetextanalyzer_AnalyzeBidi(IDWriteTextAnalyzer2 *iface
UINT8
baselevel
,
level
,
explicit_level
;
WCHAR
*
buff
=
NULL
;
const
WCHAR
*
text
;
UINT32
len
,
pos
,
i
;
UINT32
pos
,
i
;
HRESULT
hr
;
TRACE
(
"(%p %u %u %p)
\n
"
,
source
,
position
,
length
,
sink
);
...
...
@@ -706,33 +753,9 @@ static HRESULT WINAPI dwritetextanalyzer_AnalyzeBidi(IDWriteTextAnalyzer2 *iface
if
(
length
==
0
)
return
S_OK
;
/* get some, check for length */
text
=
NULL
;
len
=
0
;
hr
=
IDWriteTextAnalysisSource_GetTextAtPosition
(
source
,
position
,
&
text
,
&
len
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
len
<
length
)
{
UINT32
read
;
buff
=
heap_alloc
(
length
*
sizeof
(
WCHAR
));
if
(
!
buff
)
return
E_OUTOFMEMORY
;
memcpy
(
buff
,
text
,
len
*
sizeof
(
WCHAR
));
read
=
len
;
while
(
read
<
length
&&
text
)
{
text
=
NULL
;
len
=
0
;
hr
=
IDWriteTextAnalysisSource_GetTextAtPosition
(
source
,
read
,
&
text
,
&
len
);
if
(
FAILED
(
hr
))
goto
done
;
memcpy
(
&
buff
[
read
],
text
,
min
(
len
,
length
-
read
)
*
sizeof
(
WCHAR
));
read
+=
len
;
}
text
=
buff
;
}
hr
=
get_text_source_ptr
(
source
,
position
,
length
,
&
text
,
&
buff
);
if
(
FAILED
(
hr
))
return
hr
;
levels
=
heap_alloc
(
length
*
sizeof
(
*
levels
));
explicit
=
heap_alloc
(
length
*
sizeof
(
*
explicit
));
...
...
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