blob: e2374eb95594dfda9a257547bfa2ac42686f7008 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
/*++
Copyright (c) 2005 Microsoft Corporation
All rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
File Name:
nuppchndlr.cpp
Abstract:
NUp PrintCapabilities handling implementation. The NUp PC handler
is used to set NUp settings in a PrintCapabilities.
--*/
#include "precomp.h"
#include "debug.h"
#include "xdexcept.h"
#include "nupchndlr.h"
#include "ptquerybld.h"
using XDPrintSchema::NUp::NUpData;
using XDPrintSchema::NUp::ENUpFeature;
using XDPrintSchema::NUp::ENUpFeatureMin;
using XDPrintSchema::NUp::DocumentNUp;
using XDPrintSchema::NUp::JobNUpAllDocumentsContiguously;
using XDPrintSchema::NUp::ENUpFeatureMax;
using XDPrintSchema::NUp::NUP_FEATURES;
using XDPrintSchema::NUp::NUP_PROP;
using XDPrintSchema::NUp::PresentationDirection::ENUpDirectionOption;
using XDPrintSchema::NUp::PresentationDirection::ENUpDirectionOptionMin;
using XDPrintSchema::NUp::PresentationDirection::ENUpDirectionOptionMax;
using XDPrintSchema::NUp::PresentationDirection::NUP_DIRECTION_FEATURE;
using XDPrintSchema::NUp::PresentationDirection::NUP_DIRECTION_OPTIONS;
/*++
Routine Name:
CNUpPCHandler::CNUpPCHandler
Routine Description:
CNUpPCHandler class constructor
Arguments:
pPrintCapabilities - Pointer to the DOM document representation of the PrintCapabilities
Return Value:
None
--*/
CNUpPCHandler::CNUpPCHandler(
_In_ IXMLDOMDocument2* pPrintCapabilities
) :
CPCHandler(pPrintCapabilities)
{
}
/*++
Routine Name:
CNUpPCHandler::~CNUpPCHandler
Routine Description:
CNUpPCHandler class destructor
Arguments:
None
Return Value:
None
--*/
CNUpPCHandler::~CNUpPCHandler()
{
}
/*++
Routine Name:
CNUpPCHandler::SetCapabilities
Routine Description:
This routine sets NUp capabilities in the PrintCapabilities passed to the
class constructor.
Arguments:
None
Return Value:
HRESULT
S_OK - On success
E_* - On error
--*/
HRESULT
CNUpPCHandler::SetCapabilities(
VOID
)
{
HRESULT hr = S_OK;
try
{
for (ENUpFeature nupFeatures = ENUpFeatureMin;
nupFeatures < ENUpFeatureMax && SUCCEEDED(hr);
nupFeatures = static_cast<ENUpFeature>(nupFeatures + 1))
{
//
// Find the existing NUp feature node
//
CPTQueryBuilder propertyQuery(m_bstrFrameworkPrefix);
CComPtr<IXMLDOMNode> pFeatureNode(NULL);
CComBSTR bstrFeatureQuery;
if (SUCCEEDED(hr = propertyQuery.AddFeature(m_bstrKeywordsPrefix, CComBSTR(NUP_FEATURES[nupFeatures]))) &&
SUCCEEDED(hr = propertyQuery.GetQuery(&bstrFeatureQuery)) &&
SUCCEEDED(hr = GetNode(bstrFeatureQuery, &pFeatureNode)) &&
hr != S_FALSE)
{
CComPtr<IXMLDOMElement> pPresentationFeature(NULL);
//
// Create the presentation feature options
//
if (SUCCEEDED(hr = CreateFeature(CComBSTR(NUP_DIRECTION_FEATURE),
NULL,
&pPresentationFeature)))
{
PTDOMElementVector optionList;
for (ENUpDirectionOption presentationOption = ENUpDirectionOptionMin;
presentationOption < ENUpDirectionOptionMax && SUCCEEDED(hr);
presentationOption = static_cast<ENUpDirectionOption>(presentationOption + 1))
{
//
// Create the presentation options property element
//
CComPtr<IXMLDOMElement> pOptionProperty(NULL);
if (SUCCEEDED(hr = CreateOption(CComBSTR(NUP_DIRECTION_OPTIONS[presentationOption]), NULL, &pOptionProperty)))
{
optionList.push_back(pOptionProperty);
}
}
//
// Add the options into the presentation feature
//
PTDOMElementVector::iterator iterOptionList = optionList.begin();
for (;iterOptionList != optionList.end() && SUCCEEDED(hr); iterOptionList++)
{
hr = pPresentationFeature->appendChild(*iterOptionList, NULL);
}
//
// Add the presentation feature into the existing NUp feature
//
if (SUCCEEDED(hr))
{
hr = pFeatureNode->appendChild(pPresentationFeature, NULL);
}
}
}
}
}
catch (exception& DBG_ONLY(e))
{
ERR(e.what());
hr = E_FAIL;
}
ERR_ON_HR(hr);
return hr;
}
|