Line data Source code
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 "nsXPIDLString.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 0 : NS_IMPL_ISUPPORTS(MockWebBrowserPrint, nsIWebBrowserPrint);
23 :
24 0 : MockWebBrowserPrint::MockWebBrowserPrint(const PrintData &aData)
25 0 : : mData(aData)
26 : {
27 0 : }
28 :
29 0 : MockWebBrowserPrint::~MockWebBrowserPrint()
30 : {
31 0 : }
32 :
33 : NS_IMETHODIMP
34 0 : MockWebBrowserPrint::GetGlobalPrintSettings(nsIPrintSettings **aGlobalPrintSettings)
35 : {
36 0 : return NS_ERROR_NOT_IMPLEMENTED;
37 : }
38 :
39 : NS_IMETHODIMP
40 0 : MockWebBrowserPrint::GetCurrentPrintSettings(nsIPrintSettings **aCurrentPrintSettings)
41 : {
42 0 : return NS_ERROR_NOT_IMPLEMENTED;
43 : }
44 :
45 : NS_IMETHODIMP
46 0 : MockWebBrowserPrint::GetCurrentChildDOMWindow(mozIDOMWindowProxy **aCurrentPrintSettings)
47 : {
48 0 : return NS_ERROR_NOT_IMPLEMENTED;
49 : }
50 :
51 : NS_IMETHODIMP
52 0 : MockWebBrowserPrint::GetDoingPrint(bool *aDoingPrint)
53 : {
54 0 : return NS_ERROR_NOT_IMPLEMENTED;
55 : }
56 :
57 : NS_IMETHODIMP
58 0 : MockWebBrowserPrint::GetDoingPrintPreview(bool *aDoingPrintPreview)
59 : {
60 0 : return NS_ERROR_NOT_IMPLEMENTED;
61 : }
62 :
63 : NS_IMETHODIMP
64 0 : MockWebBrowserPrint::GetIsFramesetDocument(bool *aIsFramesetDocument)
65 : {
66 0 : *aIsFramesetDocument = mData.isFramesetDocument();
67 0 : return NS_OK;
68 : }
69 :
70 : NS_IMETHODIMP
71 0 : MockWebBrowserPrint::GetIsFramesetFrameSelected(bool *aIsFramesetFrameSelected)
72 : {
73 0 : *aIsFramesetFrameSelected = mData.isFramesetFrameSelected();
74 0 : return NS_OK;
75 : }
76 :
77 : NS_IMETHODIMP
78 0 : MockWebBrowserPrint::GetIsIFrameSelected(bool *aIsIFrameSelected)
79 : {
80 0 : *aIsIFrameSelected = mData.isIFrameSelected();
81 0 : return NS_OK;
82 : }
83 :
84 : NS_IMETHODIMP
85 0 : MockWebBrowserPrint::GetIsRangeSelection(bool *aIsRangeSelection)
86 : {
87 0 : *aIsRangeSelection = mData.isRangeSelection();
88 0 : return NS_OK;
89 : }
90 :
91 : NS_IMETHODIMP
92 0 : MockWebBrowserPrint::GetPrintPreviewNumPages(int32_t *aPrintPreviewNumPages)
93 : {
94 0 : return NS_ERROR_NOT_IMPLEMENTED;
95 : }
96 :
97 : NS_IMETHODIMP
98 0 : MockWebBrowserPrint::Print(nsIPrintSettings* aThePrintSettings,
99 : nsIWebProgressListener* aWPListener)
100 : {
101 0 : return NS_ERROR_NOT_IMPLEMENTED;
102 : }
103 :
104 : NS_IMETHODIMP
105 0 : MockWebBrowserPrint::PrintPreview(nsIPrintSettings* aThePrintSettings,
106 : mozIDOMWindowProxy* aChildDOMWin,
107 : nsIWebProgressListener* aWPListener)
108 : {
109 0 : return NS_ERROR_NOT_IMPLEMENTED;
110 : }
111 :
112 : NS_IMETHODIMP
113 0 : MockWebBrowserPrint::PrintPreviewNavigate(int16_t aNavType,
114 : int32_t aPageNum)
115 : {
116 0 : return NS_ERROR_NOT_IMPLEMENTED;
117 : }
118 :
119 : NS_IMETHODIMP
120 0 : MockWebBrowserPrint::Cancel()
121 : {
122 0 : return NS_ERROR_NOT_IMPLEMENTED;
123 : }
124 :
125 : NS_IMETHODIMP
126 0 : MockWebBrowserPrint::EnumerateDocumentNames(uint32_t* aCount,
127 : char16_t*** aResult)
128 : {
129 0 : *aCount = 0;
130 0 : *aResult = nullptr;
131 :
132 0 : if (mData.printJobName().IsEmpty()) {
133 0 : return NS_OK;
134 : }
135 :
136 : // The only consumer that cares about this is the OS X printing
137 : // dialog, and even then, it only cares about the first document
138 : // name. That's why we only send a single document name through
139 : // PrintData.
140 0 : char16_t** array = (char16_t**) moz_xmalloc(sizeof(char16_t*));
141 0 : array[0] = ToNewUnicode(mData.printJobName());
142 :
143 0 : *aCount = 1;
144 0 : *aResult = array;
145 0 : return NS_OK;
146 : }
147 :
148 : NS_IMETHODIMP
149 0 : MockWebBrowserPrint::ExitPrintPreview()
150 : {
151 0 : return NS_ERROR_NOT_IMPLEMENTED;
152 : }
153 :
154 : } // namespace embedding
155 : } // namespace mozilla
156 :
|