1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
//========================================================================
//
// ViewerPreferences.cc
//
// This file is licensed under the GPLv2 or later
//
// Copyright 2011 Pino Toscano <pino@kde.org>
// Copyright 2017, 2020, 2022 Albert Astals Cid <aacid@kde.org>
// Copyright 2019 Marek Kasik <mkasik@redhat.com>
//
//========================================================================
#include <config.h>
#include "ViewerPreferences.h"
#include "Object.h"
#include "Dict.h"
ViewerPreferences::ViewerPreferences(Dict *prefDict)
{
hideToolbar = prefDict->lookup("HideToolbar").getBoolWithDefaultValue(false);
hideMenubar = prefDict->lookup("HideMenubar").getBoolWithDefaultValue(false);
hideWindowUI = prefDict->lookup("HideWindowUI").getBoolWithDefaultValue(false);
fitWindow = prefDict->lookup("FitWindow").getBoolWithDefaultValue(false);
centerWindow = prefDict->lookup("CenterWindow").getBoolWithDefaultValue(false);
displayDocTitle = prefDict->lookup("DisplayDocTitle").getBoolWithDefaultValue(false);
Object obj = prefDict->lookup("NonFullScreenPageMode");
if (obj.isName()) {
const char *mode = obj.getName();
if (!strcmp(mode, "UseNone")) {
nonFullScreenPageMode = nfpmUseNone;
} else if (!strcmp(mode, "UseOutlines")) {
nonFullScreenPageMode = nfpmUseOutlines;
} else if (!strcmp(mode, "UseThumbs")) {
nonFullScreenPageMode = nfpmUseThumbs;
} else if (!strcmp(mode, "UseOC")) {
nonFullScreenPageMode = nfpmUseOC;
}
}
obj = prefDict->lookup("Direction");
if (obj.isName()) {
const char *dir = obj.getName();
if (!strcmp(dir, "L2R")) {
direction = directionL2R;
} else if (!strcmp(dir, "R2L")) {
direction = directionR2L;
}
}
obj = prefDict->lookup("PrintScaling");
if (obj.isName()) {
const char *ps = obj.getName();
if (!strcmp(ps, "None")) {
printScaling = printScalingNone;
} else if (!strcmp(ps, "AppDefault")) {
printScaling = printScalingAppDefault;
}
}
obj = prefDict->lookup("Duplex");
if (obj.isName()) {
const char *d = obj.getName();
if (!strcmp(d, "Simplex")) {
duplex = duplexSimplex;
} else if (!strcmp(d, "DuplexFlipShortEdge")) {
duplex = duplexDuplexFlipShortEdge;
} else if (!strcmp(d, "DuplexFlipLongEdge")) {
duplex = duplexDuplexFlipLongEdge;
}
}
pickTrayByPDFSize = prefDict->lookup("PickTrayByPDFSize").getBoolWithDefaultValue(false);
obj = prefDict->lookup("NumCopies");
if (obj.isInt()) {
numCopies = obj.getInt();
if (numCopies < 2) {
numCopies = 1;
}
}
obj = prefDict->lookup("PrintPageRange");
if (obj.isArray()) {
Array *range = obj.getArray();
int length = range->getLength();
int pageNumber1, pageNumber2;
if (length % 2 == 1) {
length--;
}
for (int i = 0; i < length; i += 2) {
Object obj2 = range->get(i);
Object obj3 = range->get(i + 1);
if (obj2.isInt() && (pageNumber1 = obj2.getInt()) >= 1 && obj3.isInt() && (pageNumber2 = obj3.getInt()) >= 1 && pageNumber1 < pageNumber2) {
printPageRange.emplace_back(pageNumber1, pageNumber2);
} else {
printPageRange.clear();
break;
}
}
}
}
ViewerPreferences::~ViewerPreferences() { }
|