| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/include/pdfwindow/PDFWindow.h" | |
| 8 #include "fpdfsdk/include/pdfwindow/PWL_Icon.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_Icon.h" |
| 9 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 8 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
| 10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
| 11 | 10 |
| 12 /* ------------------------------- CPWL_Image ---------------------------------- | |
| 13 */ | |
| 14 | |
| 15 CPWL_Image::CPWL_Image() : m_pPDFStream(NULL) {} | 11 CPWL_Image::CPWL_Image() : m_pPDFStream(NULL) {} |
| 16 | 12 |
| 17 CPWL_Image::~CPWL_Image() {} | 13 CPWL_Image::~CPWL_Image() {} |
| 18 | 14 |
| 19 CFX_ByteString CPWL_Image::GetImageAppStream() { | 15 CFX_ByteString CPWL_Image::GetImageAppStream() { |
| 20 CFX_ByteTextBuf sAppStream; | 16 CFX_ByteTextBuf sAppStream; |
| 21 | 17 |
| 22 CFX_ByteString sAlias = GetImageAlias(); | 18 CFX_ByteString sAlias = GetImageAlias(); |
| 23 CPDF_Rect rcPlate = GetClientRect(); | 19 CPDF_Rect rcPlate = GetClientRect(); |
| 24 CFX_Matrix mt; | 20 CFX_Matrix mt; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (m_pPDFStream) { | 72 if (m_pPDFStream) { |
| 77 if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) { | 73 if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) { |
| 78 return pDict->GetMatrix("Matrix"); | 74 return pDict->GetMatrix("Matrix"); |
| 79 } | 75 } |
| 80 } | 76 } |
| 81 | 77 |
| 82 return CFX_Matrix(); | 78 return CFX_Matrix(); |
| 83 } | 79 } |
| 84 | 80 |
| 85 CFX_ByteString CPWL_Image::GetImageAlias() { | 81 CFX_ByteString CPWL_Image::GetImageAlias() { |
| 86 if (m_sImageAlias.IsEmpty()) { | 82 if (!m_sImageAlias.IsEmpty()) |
| 87 if (m_pPDFStream) { | 83 return m_sImageAlias; |
| 88 if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) { | 84 |
| 89 return pDict->GetString("Name"); | 85 if (m_pPDFStream) { |
| 90 } | 86 if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) { |
| 87 return pDict->GetString("Name"); |
| 91 } | 88 } |
| 92 } else | 89 } |
| 93 return m_sImageAlias; | |
| 94 | 90 |
| 95 return CFX_ByteString(); | 91 return CFX_ByteString(); |
| 96 } | 92 } |
| 97 | 93 |
| 98 void CPWL_Image::SetImageAlias(const FX_CHAR* sImageAlias) { | 94 void CPWL_Image::SetImageAlias(const FX_CHAR* sImageAlias) { |
| 99 m_sImageAlias = sImageAlias; | 95 m_sImageAlias = sImageAlias; |
| 100 } | 96 } |
| 101 | 97 |
| 102 void CPWL_Image::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) { | 98 void CPWL_Image::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) { |
| 103 fHScale = 1.0f; | 99 fHScale = 1.0f; |
| 104 fVScale = 1.0f; | 100 fVScale = 1.0f; |
| 105 } | 101 } |
| 106 | 102 |
| 107 void CPWL_Image::GetImageOffset(FX_FLOAT& x, FX_FLOAT& y) { | 103 void CPWL_Image::GetImageOffset(FX_FLOAT& x, FX_FLOAT& y) { |
| 108 x = 0.0f; | 104 x = 0.0f; |
| 109 y = 0.0f; | 105 y = 0.0f; |
| 110 } | 106 } |
| 111 | 107 |
| 112 /* ------------------------------- CPWL_Icon ---------------------------------- | |
| 113 */ | |
| 114 | |
| 115 CPWL_Icon::CPWL_Icon() : m_pIconFit(NULL) {} | 108 CPWL_Icon::CPWL_Icon() : m_pIconFit(NULL) {} |
| 116 | 109 |
| 117 CPWL_Icon::~CPWL_Icon() {} | 110 CPWL_Icon::~CPWL_Icon() {} |
| 118 | 111 |
| 119 int32_t CPWL_Icon::GetScaleMethod() { | 112 int32_t CPWL_Icon::GetScaleMethod() { |
| 120 if (m_pIconFit) | 113 if (m_pIconFit) |
| 121 return m_pIconFit->GetScaleMethod(); | 114 return m_pIconFit->GetScaleMethod(); |
| 122 | 115 |
| 123 return 0; | 116 return 0; |
| 124 } | 117 } |
| 125 | 118 |
| 126 FX_BOOL CPWL_Icon::IsProportionalScale() { | 119 FX_BOOL CPWL_Icon::IsProportionalScale() { |
| 127 if (m_pIconFit) | 120 if (m_pIconFit) |
| 128 return m_pIconFit->IsProportionalScale(); | 121 return m_pIconFit->IsProportionalScale(); |
| 129 | 122 |
| 130 return FALSE; | 123 return FALSE; |
| 131 } | 124 } |
| 132 | 125 |
| 133 void CPWL_Icon::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { | 126 void CPWL_Icon::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { |
| 134 if (m_pIconFit) { | 127 if (m_pIconFit) { |
| 135 // m_pIconFit->GetIconPosition(fLeft,fBottom); | |
| 136 fLeft = 0.0f; | 128 fLeft = 0.0f; |
| 137 fBottom = 0.0f; | 129 fBottom = 0.0f; |
| 138 CPDF_Array* pA = | 130 CPDF_Array* pA = |
| 139 m_pIconFit->m_pDict ? m_pIconFit->m_pDict->GetArray("A") : NULL; | 131 m_pIconFit->m_pDict ? m_pIconFit->m_pDict->GetArray("A") : NULL; |
| 140 if (pA) { | 132 if (pA) { |
| 141 FX_DWORD dwCount = pA->GetCount(); | 133 FX_DWORD dwCount = pA->GetCount(); |
| 142 if (dwCount > 0) | 134 if (dwCount > 0) |
| 143 fLeft = pA->GetNumber(0); | 135 fLeft = pA->GetNumber(0); |
| 144 if (dwCount > 1) | 136 if (dwCount > 1) |
| 145 fBottom = pA->GetNumber(1); | 137 fBottom = pA->GetNumber(1); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 FX_FLOAT fImageFactHeight = fImageHeight * fVScale; | 213 FX_FLOAT fImageFactHeight = fImageHeight * fVScale; |
| 222 | 214 |
| 223 FX_FLOAT fPlateWidth, fPlateHeight; | 215 FX_FLOAT fPlateWidth, fPlateHeight; |
| 224 CPDF_Rect rcPlate = GetClientRect(); | 216 CPDF_Rect rcPlate = GetClientRect(); |
| 225 fPlateWidth = rcPlate.right - rcPlate.left; | 217 fPlateWidth = rcPlate.right - rcPlate.left; |
| 226 fPlateHeight = rcPlate.top - rcPlate.bottom; | 218 fPlateHeight = rcPlate.top - rcPlate.bottom; |
| 227 | 219 |
| 228 x = (fPlateWidth - fImageFactWidth) * fLeft; | 220 x = (fPlateWidth - fImageFactWidth) * fLeft; |
| 229 y = (fPlateHeight - fImageFactHeight) * fBottom; | 221 y = (fPlateHeight - fImageFactHeight) * fBottom; |
| 230 } | 222 } |
| OLD | NEW |