/src/mozilla-central/toolkit/components/printingui/ipc/PrintDataUtils.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* vim: set sw=4 ts=8 et tw=80 : */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "PrintDataUtils.h" |
8 | | #include "nsIPrintSettings.h" |
9 | | #include "nsIServiceManager.h" |
10 | | #include "nsIWebBrowserPrint.h" |
11 | | #include "nsString.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace embedding { |
15 | | |
16 | | /** |
17 | | * MockWebBrowserPrint is a mostly useless implementation of nsIWebBrowserPrint, |
18 | | * but wraps a PrintData so that it's able to return information to print |
19 | | * settings dialogs that need an nsIWebBrowserPrint to interrogate. |
20 | | */ |
21 | | |
22 | | NS_IMPL_ISUPPORTS(MockWebBrowserPrint, nsIWebBrowserPrint); |
23 | | |
24 | | MockWebBrowserPrint::MockWebBrowserPrint(const PrintData &aData) |
25 | | : mData(aData) |
26 | 0 | { |
27 | 0 | } |
28 | | |
29 | | MockWebBrowserPrint::~MockWebBrowserPrint() |
30 | 0 | { |
31 | 0 | } |
32 | | |
33 | | NS_IMETHODIMP |
34 | | MockWebBrowserPrint::GetGlobalPrintSettings(nsIPrintSettings **aGlobalPrintSettings) |
35 | 0 | { |
36 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
37 | 0 | } |
38 | | |
39 | | NS_IMETHODIMP |
40 | | MockWebBrowserPrint::GetCurrentPrintSettings(nsIPrintSettings **aCurrentPrintSettings) |
41 | 0 | { |
42 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
43 | 0 | } |
44 | | |
45 | | NS_IMETHODIMP |
46 | | MockWebBrowserPrint::GetDoingPrint(bool *aDoingPrint) |
47 | 0 | { |
48 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
49 | 0 | } |
50 | | |
51 | | NS_IMETHODIMP |
52 | | MockWebBrowserPrint::GetDoingPrintPreview(bool *aDoingPrintPreview) |
53 | 0 | { |
54 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
55 | 0 | } |
56 | | |
57 | | NS_IMETHODIMP |
58 | | MockWebBrowserPrint::GetIsFramesetDocument(bool *aIsFramesetDocument) |
59 | 0 | { |
60 | 0 | *aIsFramesetDocument = mData.isFramesetDocument(); |
61 | 0 | return NS_OK; |
62 | 0 | } |
63 | | |
64 | | NS_IMETHODIMP |
65 | | MockWebBrowserPrint::GetIsFramesetFrameSelected(bool *aIsFramesetFrameSelected) |
66 | 0 | { |
67 | 0 | *aIsFramesetFrameSelected = mData.isFramesetFrameSelected(); |
68 | 0 | return NS_OK; |
69 | 0 | } |
70 | | |
71 | | NS_IMETHODIMP |
72 | | MockWebBrowserPrint::GetIsIFrameSelected(bool *aIsIFrameSelected) |
73 | 0 | { |
74 | 0 | *aIsIFrameSelected = mData.isIFrameSelected(); |
75 | 0 | return NS_OK; |
76 | 0 | } |
77 | | |
78 | | NS_IMETHODIMP |
79 | | MockWebBrowserPrint::GetIsRangeSelection(bool *aIsRangeSelection) |
80 | 0 | { |
81 | 0 | *aIsRangeSelection = mData.isRangeSelection(); |
82 | 0 | return NS_OK; |
83 | 0 | } |
84 | | |
85 | | NS_IMETHODIMP |
86 | | MockWebBrowserPrint::GetPrintPreviewNumPages(int32_t *aPrintPreviewNumPages) |
87 | 0 | { |
88 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
89 | 0 | } |
90 | | |
91 | | NS_IMETHODIMP |
92 | | MockWebBrowserPrint::Print(nsIPrintSettings* aThePrintSettings, |
93 | | nsIWebProgressListener* aWPListener) |
94 | 0 | { |
95 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
96 | 0 | } |
97 | | |
98 | | NS_IMETHODIMP |
99 | | MockWebBrowserPrint::PrintPreview(nsIPrintSettings* aThePrintSettings, |
100 | | mozIDOMWindowProxy* aChildDOMWin, |
101 | | nsIWebProgressListener* aWPListener) |
102 | 0 | { |
103 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
104 | 0 | } |
105 | | |
106 | | NS_IMETHODIMP |
107 | | MockWebBrowserPrint::PrintPreviewNavigate(int16_t aNavType, |
108 | | int32_t aPageNum) |
109 | 0 | { |
110 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
111 | 0 | } |
112 | | |
113 | | NS_IMETHODIMP |
114 | | MockWebBrowserPrint::Cancel() |
115 | 0 | { |
116 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
117 | 0 | } |
118 | | |
119 | | NS_IMETHODIMP |
120 | | MockWebBrowserPrint::EnumerateDocumentNames(uint32_t* aCount, |
121 | | char16_t*** aResult) |
122 | 0 | { |
123 | 0 | *aCount = 0; |
124 | 0 | *aResult = nullptr; |
125 | 0 |
|
126 | 0 | if (mData.printJobName().IsEmpty()) { |
127 | 0 | return NS_OK; |
128 | 0 | } |
129 | 0 | |
130 | 0 | // The only consumer that cares about this is the OS X printing |
131 | 0 | // dialog, and even then, it only cares about the first document |
132 | 0 | // name. That's why we only send a single document name through |
133 | 0 | // PrintData. |
134 | 0 | char16_t** array = (char16_t**) moz_xmalloc(sizeof(char16_t*)); |
135 | 0 | array[0] = ToNewUnicode(mData.printJobName()); |
136 | 0 |
|
137 | 0 | *aCount = 1; |
138 | 0 | *aResult = array; |
139 | 0 | return NS_OK; |
140 | 0 | } |
141 | | |
142 | | NS_IMETHODIMP |
143 | | MockWebBrowserPrint::ExitPrintPreview() |
144 | 0 | { |
145 | 0 | return NS_ERROR_NOT_IMPLEMENTED; |
146 | 0 | } |
147 | | |
148 | | } // namespace embedding |
149 | | } // namespace mozilla |
150 | | |