1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/fxge/win32/cpsoutput.h"
8
9 #include <algorithm>
10
11 #include "core/fxcrt/fx_system.h"
12
CPSOutput(HDC hDC)13 CPSOutput::CPSOutput(HDC hDC) {
14 m_hDC = hDC;
15 }
16
~CPSOutput()17 CPSOutput::~CPSOutput() {}
18
Release()19 void CPSOutput::Release() {
20 delete this;
21 }
22
OutputPS(const FX_CHAR * str,int len)23 void CPSOutput::OutputPS(const FX_CHAR* str, int len) {
24 if (len < 0)
25 len = static_cast<int>(FXSYS_strlen(str));
26
27 int sent_len = 0;
28 while (len > 0) {
29 FX_CHAR buffer[1026];
30 int send_len = std::min(len, 1024);
31 *(reinterpret_cast<uint16_t*>(buffer)) = send_len;
32 FXSYS_memcpy(buffer + 2, str + sent_len, send_len);
33
34 // TODO(thestig/rbpotter): Do PASSTHROUGH for non-Chromium usage.
35 // ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, buffer, 0, nullptr);
36 ::GdiComment(m_hDC, send_len + 2, reinterpret_cast<const BYTE*>(buffer));
37 sent_len += send_len;
38 len -= send_len;
39 }
40 }
41