blob: 2a3153377126a59c51d2553551a3a3ebb213237a (
plain)
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
|
// Copyright 2014 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 "xfa/src/foxitlib.h"
#include "xfa/src/fxfa/src/app/xfa_ffConfigAcc.h"
#include "xfa/src/fxfa/src/common/xfa_object.h"
CXFA_FFConfigAcc::CXFA_FFConfigAcc(CXFA_Node* pNode)
: m_pNode(pNode), m_pPsMapNode(NULL) {}
CXFA_FFConfigAcc::~CXFA_FFConfigAcc() {}
int32_t CXFA_FFConfigAcc::CountChildren() {
GetPsMapNode();
if (m_pPsMapNode == NULL) {
return 0;
}
int32_t iCount = 0;
CXFA_Node* pNode = m_pPsMapNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
iCount++;
}
return iCount;
}
FX_BOOL CXFA_FFConfigAcc::GetFontInfo(int32_t index,
CFX_WideString& wsFontFamily,
CFX_WideString& wsPsName,
FX_BOOL bBold,
FX_BOOL bItalic) {
if (index < 0 || index >= CountChildren()) {
return FALSE;
}
CXFA_Node* pFontNode = m_pPsMapNode->GetChild(index, XFA_ELEMENT_Font);
if (pFontNode == NULL) {
return FALSE;
}
wsFontFamily.Empty();
wsPsName.Empty();
bBold = FALSE;
bItalic = FALSE;
pFontNode->GetAttribute(XFA_ATTRIBUTE_Typeface, wsFontFamily);
pFontNode->GetAttribute(XFA_ATTRIBUTE_PsName, wsPsName);
CFX_WideString wsValue;
pFontNode->GetAttribute(XFA_ATTRIBUTE_Weight, wsValue);
wsValue.MakeLower();
if (wsValue == FX_WSTRC(L"bold")) {
bBold = TRUE;
}
pFontNode->GetAttribute(XFA_ATTRIBUTE_Posture, wsValue);
wsValue.MakeLower();
if (wsValue == FX_WSTRC(L"italic")) {
bItalic = TRUE;
}
return wsFontFamily.GetLength() > 0;
}
void CXFA_FFConfigAcc::GetPsMapNode() {
if (m_pNode == NULL) {
return;
}
m_pPsMapNode = m_pNode->GetChild(0, XFA_ELEMENT_PsMap);
}
|