Commit 80579d63 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

opcservices: Implement writing stub compressed package.

parent 951741e6
MODULE = opcservices.dll
IMPORTS = uuid ole32 advapi32 urlmon
IMPORTS = uuid ole32 advapi32 urlmon xmllite
EXTRALIBS = $(Z_LIBS)
C_SRCS = \
compress.c \
factory.c \
package.c \
uri.c
......
......@@ -26,6 +26,7 @@
#include "ole2.h"
#include "rpcproxy.h"
#include "msopc.h"
#include "xmllite.h"
#include "wine/debug.h"
......@@ -350,9 +351,9 @@ static HRESULT WINAPI opc_factory_ReadPackageFromStream(IOpcFactory *iface, IStr
static HRESULT WINAPI opc_factory_WritePackageToStream(IOpcFactory *iface, IOpcPackage *package, OPC_WRITE_FLAGS flags,
IStream *stream)
{
FIXME("iface %p, package %p, flags %#x, stream %p stub!\n", iface, package, flags, stream);
TRACE("iface %p, package %p, flags %#x, stream %p.\n", iface, package, flags, stream);
return E_NOTIMPL;
return opc_package_write(package, flags, stream);
}
static HRESULT WINAPI opc_factory_CreateDigitalSignatureManager(IOpcFactory *iface, IOpcPackage *package,
......
......@@ -48,3 +48,11 @@ static inline BOOL opc_array_reserve(void **elements, size_t *capacity, size_t c
extern HRESULT opc_package_create(IOpcFactory *factory, IOpcPackage **package) DECLSPEC_HIDDEN;
extern HRESULT opc_part_uri_create(const WCHAR *uri, IOpcPartUri **part_uri) DECLSPEC_HIDDEN;
extern HRESULT opc_uri_create(const WCHAR *uri, IOpcUri **opc_uri) DECLSPEC_HIDDEN;
extern HRESULT opc_package_write(IOpcPackage *package, OPC_WRITE_FLAGS flags, IStream *stream) DECLSPEC_HIDDEN;
struct zip_archive;
extern HRESULT compress_create_archive(IStream *output, struct zip_archive **archive) DECLSPEC_HIDDEN;
extern HRESULT compress_add_file(struct zip_archive *archive, const WCHAR *path, IStream *content,
OPC_COMPRESSION_OPTIONS options) DECLSPEC_HIDDEN;
extern void compress_finalize_archive(struct zip_archive *archive) DECLSPEC_HIDDEN;
......@@ -22,6 +22,7 @@
#include "windef.h"
#include "winbase.h"
#include "ntsecapi.h"
#include "xmllite.h"
#include "wine/debug.h"
#include "wine/unicode.h"
......@@ -786,3 +787,57 @@ HRESULT opc_package_create(IOpcFactory *factory, IOpcPackage **out)
TRACE("Created package %p.\n", *out);
return S_OK;
}
static HRESULT opc_package_write_contenttypes(struct zip_archive *archive, IXmlWriter *writer)
{
static const WCHAR contenttypesW[] = {'[','C','o','n','t','e','n','t','_','T','y','p','e','s',']','.','x','m','l',0};
static const WCHAR typesW[] = {'T','y','p','e','s',0};
IStream *content;
HRESULT hr;
if (FAILED(hr = CreateStreamOnHGlobal(NULL, TRUE, &content)))
return hr;
IXmlWriter_SetOutput(writer, (IUnknown *)content);
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit);
if (SUCCEEDED(hr))
hr = IXmlWriter_WriteStartElement(writer, NULL, typesW, NULL);
if (SUCCEEDED(hr))
hr = IXmlWriter_WriteEndDocument(writer);
if (SUCCEEDED(hr))
hr = IXmlWriter_Flush(writer);
if (SUCCEEDED(hr))
hr = compress_add_file(archive, contenttypesW, content, OPC_COMPRESSION_NORMAL);
IStream_Release(content);
return hr;
}
HRESULT opc_package_write(IOpcPackage *input, OPC_WRITE_FLAGS flags, IStream *stream)
{
struct zip_archive *archive;
IXmlWriter *writer;
HRESULT hr;
if (flags != OPC_WRITE_FORCE_ZIP32)
FIXME("Unsupported write flags %#x.\n", flags);
if (FAILED(hr = CreateXmlWriter(&IID_IXmlWriter, (void **)&writer, NULL)))
return hr;
if (FAILED(hr = compress_create_archive(stream, &archive)))
{
IXmlWriter_Release(writer);
return hr;
}
/* [Content_Types].xml */
hr = opc_package_write_contenttypes(archive, writer);
compress_finalize_archive(archive);
IXmlWriter_Release(writer);
return hr;
}
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