summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_iconfit.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-08-02 15:43:46 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-02 15:43:46 -0700
commit27053d81ca80a2f9433abf3e9c393d2914c91ad8 (patch)
treeecf94b4610dfd09d42a83b1ab86ec22223957390 /core/fpdfdoc/cpdf_iconfit.cpp
parente21501d9427539828b5d547b9d20a752d06914aa (diff)
downloadpdfium-27053d81ca80a2f9433abf3e9c393d2914c91ad8.tar.xz
Splitting fpdfdoc/doc_* part III.
This CL cleans up the remaining doc_* files, splitting into .h and .pp files as needed. Review-Url: https://codereview.chromium.org/2190983002
Diffstat (limited to 'core/fpdfdoc/cpdf_iconfit.cpp')
-rw-r--r--core/fpdfdoc/cpdf_iconfit.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp
new file mode 100644
index 0000000000..3b3a09a54b
--- /dev/null
+++ b/core/fpdfdoc/cpdf_iconfit.cpp
@@ -0,0 +1,48 @@
+// 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/fpdfdoc/include/cpdf_iconfit.h"
+
+#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
+#include "core/fxcrt/include/fx_string.h"
+
+CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() {
+ if (!m_pDict)
+ return Always;
+
+ CFX_ByteString csSW = m_pDict->GetStringBy("SW", "A");
+ if (csSW == "B")
+ return Bigger;
+ if (csSW == "S")
+ return Smaller;
+ if (csSW == "N")
+ return Never;
+ return Always;
+}
+
+FX_BOOL CPDF_IconFit::IsProportionalScale() {
+ return m_pDict ? m_pDict->GetStringBy("S", "P") != "A" : TRUE;
+}
+
+void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
+ fLeft = fBottom = 0.5;
+ if (!m_pDict)
+ return;
+
+ CPDF_Array* pA = m_pDict->GetArrayBy("A");
+ if (pA) {
+ uint32_t dwCount = pA->GetCount();
+ if (dwCount > 0)
+ fLeft = pA->GetNumberAt(0);
+ if (dwCount > 1)
+ fBottom = pA->GetNumberAt(1);
+ }
+}
+
+bool CPDF_IconFit::GetFittingBounds() {
+ return m_pDict ? m_pDict->GetBooleanBy("FB") : false;
+}