| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #include "xfa/src/foxitlib.h" | |
| 8 #include "xfa/src/fxfa/src/app/xfa_ffConfigAcc.h" | |
| 9 #include "xfa/src/fxfa/src/common/xfa_object.h" | |
| 10 | |
| 11 CXFA_FFConfigAcc::CXFA_FFConfigAcc(CXFA_Node* pNode) | |
| 12 : m_pNode(pNode), m_pPsMapNode(NULL) {} | |
| 13 CXFA_FFConfigAcc::~CXFA_FFConfigAcc() {} | |
| 14 int32_t CXFA_FFConfigAcc::CountChildren() { | |
| 15 GetPsMapNode(); | |
| 16 if (m_pPsMapNode == NULL) { | |
| 17 return 0; | |
| 18 } | |
| 19 int32_t iCount = 0; | |
| 20 CXFA_Node* pNode = m_pPsMapNode->GetNodeItem(XFA_NODEITEM_FirstChild); | |
| 21 for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | |
| 22 iCount++; | |
| 23 } | |
| 24 return iCount; | |
| 25 } | |
| 26 FX_BOOL CXFA_FFConfigAcc::GetFontInfo(int32_t index, | |
| 27 CFX_WideString& wsFontFamily, | |
| 28 CFX_WideString& wsPsName, | |
| 29 FX_BOOL bBold, | |
| 30 FX_BOOL bItalic) { | |
| 31 if (index < 0 || index >= CountChildren()) { | |
| 32 return FALSE; | |
| 33 } | |
| 34 CXFA_Node* pFontNode = m_pPsMapNode->GetChild(index, XFA_ELEMENT_Font); | |
| 35 if (pFontNode == NULL) { | |
| 36 return FALSE; | |
| 37 } | |
| 38 wsFontFamily.Empty(); | |
| 39 wsPsName.Empty(); | |
| 40 bBold = FALSE; | |
| 41 bItalic = FALSE; | |
| 42 pFontNode->GetAttribute(XFA_ATTRIBUTE_Typeface, wsFontFamily); | |
| 43 pFontNode->GetAttribute(XFA_ATTRIBUTE_PsName, wsPsName); | |
| 44 CFX_WideString wsValue; | |
| 45 pFontNode->GetAttribute(XFA_ATTRIBUTE_Weight, wsValue); | |
| 46 wsValue.MakeLower(); | |
| 47 if (wsValue == FX_WSTRC(L"bold")) { | |
| 48 bBold = TRUE; | |
| 49 } | |
| 50 pFontNode->GetAttribute(XFA_ATTRIBUTE_Posture, wsValue); | |
| 51 wsValue.MakeLower(); | |
| 52 if (wsValue == FX_WSTRC(L"italic")) { | |
| 53 bItalic = TRUE; | |
| 54 } | |
| 55 return wsFontFamily.GetLength() > 0; | |
| 56 } | |
| 57 void CXFA_FFConfigAcc::GetPsMapNode() { | |
| 58 if (m_pNode == NULL) { | |
| 59 return; | |
| 60 } | |
| 61 m_pPsMapNode = m_pNode->GetChild(0, XFA_ELEMENT_PsMap); | |
| 62 } | |
| OLD | NEW |