Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
9a2177ff
Commit
9a2177ff
authored
May 20, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Implement OmitXmlDeclaration property.
parent
e0e0af80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
4 deletions
+110
-4
writer.c
dlls/xmllite/tests/writer.c
+94
-0
writer.c
dlls/xmllite/writer.c
+16
-4
No files found.
dlls/xmllite/tests/writer.c
View file @
9a2177ff
...
...
@@ -312,6 +312,99 @@ static void test_flush(void)
ok
(
g_write_len
==
0
,
"got %d
\n
"
,
g_write_len
);
}
static
void
test_omitxmldeclaration
(
void
)
{
static
const
char
prologversion
[]
=
"<?xml version=
\"
1.0
\"
?>"
;
static
const
WCHAR
versionW
[]
=
{
'v'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
'='
,
'"'
,
'1'
,
'.'
,
'0'
,
'"'
,
0
};
static
const
WCHAR
xmlW
[]
=
{
'x'
,
'm'
,
'l'
,
0
};
IXmlWriter
*
writer
;
HGLOBAL
hglobal
;
IStream
*
stream
;
HRESULT
hr
;
char
*
ptr
;
hr
=
pCreateXmlWriter
(
&
IID_IXmlWriter
,
(
void
**
)
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
hr
=
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetOutput
(
writer
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetProperty
(
writer
,
XmlWriterProperty_OmitXmlDeclaration
,
TRUE
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Yes
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
GetHGlobalFromStream
(
stream
,
&
hglobal
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ptr
=
GlobalLock
(
hglobal
);
ok
(
!
ptr
,
"got %p
\n
"
,
ptr
);
GlobalUnlock
(
hglobal
);
/* one more time */
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Yes
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
IStream_Release
(
stream
);
/* now add PI manually, and try to start a document */
hr
=
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetOutput
(
writer
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteProcessingInstruction
(
writer
,
xmlW
,
versionW
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
GetHGlobalFromStream
(
stream
,
&
hglobal
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ptr
=
GlobalLock
(
hglobal
);
ok
(
!
strncmp
(
ptr
,
prologversion
,
strlen
(
prologversion
)),
"got %s
\n
"
,
ptr
);
GlobalUnlock
(
hglobal
);
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Yes
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ptr
=
GlobalLock
(
hglobal
);
ok
(
!
strncmp
(
ptr
,
prologversion
,
strlen
(
prologversion
)),
"got %s
\n
"
,
ptr
);
GlobalUnlock
(
hglobal
);
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Yes
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ptr
=
GlobalLock
(
hglobal
);
ok
(
!
strncmp
(
ptr
,
prologversion
,
strlen
(
prologversion
)),
"got %s
\n
"
,
ptr
);
GlobalUnlock
(
hglobal
);
/* another attempt to add 'xml' PI */
hr
=
IXmlWriter_WriteProcessingInstruction
(
writer
,
xmlW
,
versionW
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
}
START_TEST
(
writer
)
{
if
(
!
init_pointers
())
...
...
@@ -321,4 +414,5 @@ START_TEST(writer)
test_writeroutput
();
test_writestartdocument
();
test_flush
();
test_omitxmldeclaration
();
}
dlls/xmllite/writer.c
View file @
9a2177ff
...
...
@@ -392,13 +392,23 @@ static HRESULT WINAPI xmlwriter_GetProperty(IXmlWriter *iface, UINT property, LO
return
S_OK
;
}
static
HRESULT
WINAPI
xmlwriter_SetProperty
(
IXmlWriter
*
iface
,
UINT
nProperty
,
LONG_PTR
pV
alue
)
static
HRESULT
WINAPI
xmlwriter_SetProperty
(
IXmlWriter
*
iface
,
UINT
property
,
LONG_PTR
v
alue
)
{
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
FIXME
(
"%p %u %lu
\n
"
,
This
,
nProperty
,
pV
alue
);
TRACE
(
"(%p)->(%s %lu)
\n
"
,
This
,
debugstr_writer_prop
(
property
),
v
alue
);
return
E_NOTIMPL
;
switch
(
property
)
{
case
XmlWriterProperty_OmitXmlDeclaration
:
This
->
omitxmldecl
=
!!
value
;
break
;
default:
FIXME
(
"Unimplemented property (%u)
\n
"
,
property
);
return
E_NOTIMPL
;
}
return
S_OK
;
}
static
HRESULT
WINAPI
xmlwriter_WriteAttributes
(
IXmlWriter
*
iface
,
IXmlReader
*
pReader
,
...
...
@@ -625,6 +635,9 @@ static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandal
;
}
This
->
state
=
XmlWriterState_DocStarted
;
if
(
This
->
omitxmldecl
)
return
S_OK
;
/* version */
write_output_buffer
(
This
->
output
,
versionW
,
sizeof
(
versionW
)
/
sizeof
(
WCHAR
));
...
...
@@ -647,7 +660,6 @@ static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandal
write_output_buffer
(
This
->
output
,
noW
,
sizeof
(
noW
)
/
sizeof
(
WCHAR
));
}
This
->
state
=
XmlWriterState_DocStarted
;
return
S_OK
;
}
...
...
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