Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions core/fpdfdoc/cpdf_appearancegenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class CPDF_AppearanceGenerator {
public:
// kPushButton: the button's background and border, and its caption (/MK
// /CA) centred in the /DA font and colour. One that shows its icon alone
// (/MK /TP 1) draws the normal icon (/MK /I) inside the border, fitted as
// /MK /IF says, and no caption. One that shows both (/MK /TP 2 to 6)
// draws both, each in its part of the button.
// (/MK /TP 1) draws the normal icon (/MK /I) twice the border's width in,
// fitted as /MK /IF says, and no caption. One that shows both (/MK /TP 2
// to 6) draws both, sharing the button as Acrobat does.
enum FormType { kTextField, kComboBox, kListBox, kPushButton };

static void GenerateFormAP(CPDF_Document* doc,
Expand All @@ -66,9 +66,10 @@ class CPDF_AppearanceGenerator {
static void GenerateCheckboxFormAP(CPDF_Document* doc,
CPDF_Dictionary* annot_dict);

// A radio button's Off and on appearances: a circle with a dot by default;
// any other symbol /MK /CA names sits in a box, as PDFium's form filler
// draws it. The symbol takes the /DA colour (black by default).
// A radio button's Off and on appearances: by default a circle in the
// middle of the box, as wide as the box is high, with a dot, as Acrobat
// draws it; any other symbol /MK /CA names sits in a box, as PDFium's form
// filler draws it. The symbol takes the /DA colour (black by default).
static void GenerateRadioButtonFormAP(CPDF_Document* doc,
CPDF_Dictionary* annot_dict);

Expand Down
37 changes: 19 additions & 18 deletions core/fpdfdoc/cpdf_appearancegenerator_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ std::vector<float> BorderDash(const fpdfdoc::AnnotBorder& border) {
return DashValues(border.dash_array.Get());
}

// The dash operator for |values|; empty when there are none.
ByteString DashOperator(const std::vector<float>& values) {
if (values.empty()) {
return ByteString();
}
fxcrt::ostringstream dash_stream;
dash_stream << "[";
for (float value : values) {
WriteFloat(dash_stream, value) << " ";
}
dash_stream << "] 0 d\n";
return ByteString(dash_stream);
}

// /RD as its four numbers, in rectangle order (left, bottom, right, top), as
// Acrobat writes it and PDFium reads it.
CFX_FloatRect GetRectDifferences(const CPDF_Dictionary* annot_dict) {
Expand Down Expand Up @@ -411,9 +397,23 @@ ByteString GenerateColorAP(const CFX_Color& color, PaintOperation operation) {
NOTREACHED();
}

ByteString DashOperator(const std::vector<float>& values) {
if (values.empty()) {
return ByteString();
}
fxcrt::ostringstream dash_stream;
dash_stream << "[";
for (float value : values) {
WriteFloat(dash_stream, value) << " ";
}
dash_stream << "] 0 d\n";
return ByteString(dash_stream);
}

ByteString GenerateBorderAP(const CFX_FloatRect& rect,
const BorderStyleInfo& border_style_info,
const CFX_Color& border_color) {
const CFX_Color& border_color,
const CFX_Color& beveled_shade) {
const float width = border_style_info.width;
if (width <= 0) {
return ByteString();
Expand Down Expand Up @@ -472,10 +472,11 @@ ByteString GenerateBorderAP(const CFX_FloatRect& rect,
WritePoint(app_stream, {left + width, top - width}) << " l\n";
WritePoint(app_stream, {left + width, bottom + width}) << " l f\n";

const float right_bottom_gray_value =
border_style_info.style == BorderStyle::kBeveled ? 0.5f : 0.75f;
app_stream << GenerateColorAP(
CFX_Color::MakeGray(right_bottom_gray_value), PaintOperation::kFill);
border_style_info.style == BorderStyle::kBeveled
? beveled_shade
: CFX_Color::MakeGray(0.75f),
PaintOperation::kFill);
WritePoint(app_stream, {right - half_width, top - half_width}) << " m\n";
WritePoint(app_stream, {right - half_width, bottom + half_width})
<< " l\n";
Expand Down
Loading