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
e934f14b
Commit
e934f14b
authored
Jun 17, 2020
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jun 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prntvpt: Initialize ticket from printer defaults.
Signed-off-by:
Dmitry Timoshkov
<
dmitry@baikal.ru
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
642e82ed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
55 deletions
+88
-55
main.c
dlls/prntvpt/main.c
+3
-12
prntvpt_private.h
dlls/prntvpt/prntvpt_private.h
+29
-0
ticket.c
dlls/prntvpt/ticket.c
+56
-43
No files found.
dlls/prntvpt/main.c
View file @
e934f14b
...
...
@@ -29,13 +29,9 @@
#include "wine/heap.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
prntvpt
);
#include "prntvpt_private.h"
struct
prn_provider
{
DWORD
owner
;
HANDLE
hprn
;
};
WINE_DEFAULT_DEBUG_CHANNEL
(
prntvpt
);
BOOL
WINAPI
DllMain
(
HINSTANCE
hinst
,
DWORD
reason
,
LPVOID
reserved
)
{
...
...
@@ -64,18 +60,13 @@ HRESULT WINAPI PTQuerySchemaVersionSupport(PCWSTR printer, DWORD *version)
return
E_NOTIMPL
;
}
static
BOOL
is_valid_provider
(
struct
prn_provider
*
prov
)
{
return
prov
&&
prov
->
owner
==
GetCurrentThreadId
();
}
HRESULT
WINAPI
PTCloseProvider
(
HPTPROVIDER
provider
)
{
struct
prn_provider
*
prov
=
(
struct
prn_provider
*
)
provider
;
TRACE
(
"%p
\n
"
,
provider
);
if
(
!
is_valid_provider
(
prov
))
if
(
!
is_valid_provider
(
prov
ider
))
return
E_HANDLE
;
prov
->
owner
=
0
;
...
...
dlls/prntvpt/prntvpt_private.h
0 → 100644
View file @
e934f14b
/*
* Copyright 2019 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
struct
prn_provider
{
DWORD
owner
;
HANDLE
hprn
;
};
static
inline
BOOL
is_valid_provider
(
HPTPROVIDER
provider
)
{
struct
prn_provider
*
prov
=
(
struct
prn_provider
*
)
provider
;
return
prov
&&
prov
->
owner
==
GetCurrentThreadId
();
}
dlls/prntvpt/ticket.c
View file @
e934f14b
...
...
@@ -33,6 +33,8 @@
#include "wine/heap.h"
#include "wine/debug.h"
#include "prntvpt_private.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
prntvpt
);
struct
size
...
...
@@ -665,47 +667,6 @@ static void ticket_to_devmode(const struct ticket *ticket, DEVMODEW *dm)
dm
->
dmCollate
=
ticket
->
document
.
collate
;
}
static
void
initialize_ticket
(
struct
ticket
*
ticket
)
{
ticket
->
job
.
nup
=
0
;
ticket
->
job
.
copies
=
1
;
ticket
->
job
.
input_bin
=
DMBIN_AUTO
;
ticket
->
document
.
collate
=
DMCOLLATE_FALSE
;
ticket
->
page
.
media
.
paper
=
DMPAPER_A4
;
ticket
->
page
.
media
.
size
.
width
=
210000
;
ticket
->
page
.
media
.
size
.
height
=
297000
;
ticket
->
page
.
resolution
.
x
=
600
;
ticket
->
page
.
resolution
.
y
=
600
;
ticket
->
page
.
orientation
=
DMORIENT_PORTRAIT
;
ticket
->
page
.
scaling
=
100
;
ticket
->
page
.
color
=
DMCOLOR_MONOCHROME
;
}
HRESULT
WINAPI
PTConvertPrintTicketToDevMode
(
HPTPROVIDER
provider
,
IStream
*
stream
,
EDefaultDevmodeType
type
,
EPrintTicketScope
scope
,
ULONG
*
size
,
PDEVMODEW
*
dm
,
BSTR
*
error
)
{
HRESULT
hr
;
struct
ticket
ticket
;
TRACE
(
"%p,%p,%d,%d,%p,%p,%p
\n
"
,
provider
,
stream
,
type
,
scope
,
size
,
dm
,
error
);
if
(
!
provider
||
!
stream
||
!
size
||
!
dm
)
return
E_INVALIDARG
;
initialize_ticket
(
&
ticket
);
hr
=
parse_ticket
(
stream
,
scope
,
&
ticket
);
if
(
hr
!=
S_OK
)
return
hr
;
*
dm
=
heap_alloc
(
sizeof
(
**
dm
));
if
(
!
dm
)
return
E_OUTOFMEMORY
;
ticket_to_devmode
(
&
ticket
,
*
dm
);
*
size
=
sizeof
(
**
dm
);
return
S_OK
;
}
static
void
devmode_to_ticket
(
const
DEVMODEW
*
dm
,
struct
ticket
*
ticket
)
{
if
(
dm
->
dmFields
&
DM_ORIENTATION
)
...
...
@@ -738,6 +699,55 @@ static void devmode_to_ticket(const DEVMODEW *dm, struct ticket *ticket)
ticket
->
document
.
collate
=
dm
->
dmCollate
;
}
static
HRESULT
initialize_ticket
(
struct
prn_provider
*
prov
,
struct
ticket
*
ticket
)
{
PRINTER_INFO_2W
*
pi2
;
DWORD
size
;
HRESULT
hr
=
S_OK
;
GetPrinterW
(
prov
->
hprn
,
2
,
NULL
,
0
,
&
size
);
if
(
GetLastError
()
!=
ERROR_INSUFFICIENT_BUFFER
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
pi2
=
heap_alloc
(
size
);
if
(
!
pi2
)
return
E_OUTOFMEMORY
;
if
(
!
GetPrinterW
(
prov
->
hprn
,
2
,
(
LPBYTE
)
pi2
,
size
,
NULL
))
hr
=
HRESULT_FROM_WIN32
(
GetLastError
());
else
devmode_to_ticket
(
pi2
->
pDevMode
,
ticket
);
heap_free
(
pi2
);
return
hr
;
}
HRESULT
WINAPI
PTConvertPrintTicketToDevMode
(
HPTPROVIDER
provider
,
IStream
*
stream
,
EDefaultDevmodeType
type
,
EPrintTicketScope
scope
,
ULONG
*
size
,
PDEVMODEW
*
dm
,
BSTR
*
error
)
{
struct
prn_provider
*
prov
=
(
struct
prn_provider
*
)
provider
;
HRESULT
hr
;
struct
ticket
ticket
;
TRACE
(
"%p,%p,%d,%d,%p,%p,%p
\n
"
,
provider
,
stream
,
type
,
scope
,
size
,
dm
,
error
);
if
(
!
is_valid_provider
(
provider
)
||
!
stream
||
!
size
||
!
dm
)
return
E_INVALIDARG
;
hr
=
initialize_ticket
(
prov
,
&
ticket
);
if
(
hr
!=
S_OK
)
return
hr
;
hr
=
parse_ticket
(
stream
,
scope
,
&
ticket
);
if
(
hr
!=
S_OK
)
return
hr
;
*
dm
=
heap_alloc
(
sizeof
(
**
dm
));
if
(
!
dm
)
return
E_OUTOFMEMORY
;
ticket_to_devmode
(
&
ticket
,
*
dm
);
*
size
=
sizeof
(
**
dm
);
return
S_OK
;
}
static
HRESULT
add_attribute
(
IXMLDOMElement
*
element
,
const
WCHAR
*
attr
,
const
WCHAR
*
value
)
{
VARIANT
var
;
...
...
@@ -1197,11 +1207,13 @@ static void dump_devmode(const DEVMODEW *dm)
HRESULT
WINAPI
PTConvertDevModeToPrintTicket
(
HPTPROVIDER
provider
,
ULONG
size
,
PDEVMODEW
dm
,
EPrintTicketScope
scope
,
IStream
*
stream
)
{
struct
prn_provider
*
prov
=
(
struct
prn_provider
*
)
provider
;
struct
ticket
ticket
;
HRESULT
hr
;
TRACE
(
"%p,%u,%p,%d,%p
\n
"
,
provider
,
size
,
dm
,
scope
,
stream
);
if
(
!
provider
||
!
dm
||
!
stream
)
if
(
!
is_valid_provider
(
provider
)
||
!
dm
||
!
stream
)
return
E_INVALIDARG
;
dump_devmode
(
dm
);
...
...
@@ -1209,7 +1221,8 @@ HRESULT WINAPI PTConvertDevModeToPrintTicket(HPTPROVIDER provider, ULONG size, P
if
(
!
IsValidDevmodeW
(
dm
,
size
))
return
E_INVALIDARG
;
initialize_ticket
(
&
ticket
);
hr
=
initialize_ticket
(
prov
,
&
ticket
);
if
(
hr
!=
S_OK
)
return
hr
;
devmode_to_ticket
(
dm
,
&
ticket
);
return
write_ticket
(
stream
,
&
ticket
,
scope
);
...
...
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