summaryrefslogtreecommitdiff
path: root/core/fxge/win32/cpsoutput.cpp
diff options
context:
space:
mode:
authorrbpotter <rbpotter@chromium.org>2017-01-06 08:10:18 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-06 08:10:19 -0800
commit8d94b6687f27e1238f352939434704f75b330c1d (patch)
treeeec42ae295885acce22ed547359ead388ba17737 /core/fxge/win32/cpsoutput.cpp
parent469f6da247ffe77d0ae6089e5d93db0b0c0bb37e (diff)
downloadpdfium-8d94b6687f27e1238f352939434704f75b330c1d.tar.xz
Revert postscript code removal.
Revert CL http://crrev.com/2608663003 in preparation for adding postscript generation to Pdfium. Note postscript generation code will not be called until additional patches land. These patches will also include modifications needed to make this code functional (currently missing a few compression functions). BUG= Review-Url: https://codereview.chromium.org/2615703002
Diffstat (limited to 'core/fxge/win32/cpsoutput.cpp')
-rw-r--r--core/fxge/win32/cpsoutput.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/fxge/win32/cpsoutput.cpp b/core/fxge/win32/cpsoutput.cpp
new file mode 100644
index 0000000000..76b37d7dac
--- /dev/null
+++ b/core/fxge/win32/cpsoutput.cpp
@@ -0,0 +1,40 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxge/win32/cpsoutput.h"
+
+#include <algorithm>
+
+#include "core/fxcrt/fx_system.h"
+
+CPSOutput::CPSOutput(HDC hDC) {
+ m_hDC = hDC;
+}
+
+CPSOutput::~CPSOutput() {}
+
+void CPSOutput::Release() {
+ delete this;
+}
+
+void CPSOutput::OutputPS(const FX_CHAR* str, int len) {
+ if (len < 0)
+ len = static_cast<int>(FXSYS_strlen(str));
+
+ int sent_len = 0;
+ while (len > 0) {
+ FX_CHAR buffer[1026];
+ int send_len = std::min(len, 1024);
+ *(reinterpret_cast<uint16_t*>(buffer)) = send_len;
+ FXSYS_memcpy(buffer + 2, str + sent_len, send_len);
+
+ // TODO(thestig/rbpotter): Do PASSTHROUGH for non-Chromium usage.
+ // ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, buffer, 0, nullptr);
+ ::GdiComment(m_hDC, send_len + 2, reinterpret_cast<const BYTE*>(buffer));
+ sent_len += send_len;
+ len -= send_len;
+ }
+}