Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3124)

Unified Diff: core/fpdfdoc/cpdf_iconfit.cpp

Issue 2190983002: Splitting fpdfdoc/doc_* part III. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@fpdf_doc_IV
Patch Set: Rebase to master Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/fpdfdoc/cpdf_iconfit.cpp
diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3b3a09a54baca2c472fc3cd383150cba5d482ace
--- /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;
+}

Powered by Google App Engine
This is Rietveld 408576698