blob: de46a33b32483104d623763a73ac04b13bff3e59 (
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
63
64
65
|
// 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 "../../../foxitlib.h"
#include "../common/xfa_common.h"
#include "xfa_ffConfigAcc.h"
CXFA_FFConfigAcc::CXFA_FFConfigAcc(CXFA_Node *pNode)
: m_pNode(pNode)
, m_pPsMapNode(NULL)
{
}
CXFA_FFConfigAcc::~CXFA_FFConfigAcc()
{
}
FX_INT32 CXFA_FFConfigAcc::CountChildren()
{
GetPsMapNode();
if (m_pPsMapNode == NULL) {
return 0;
}
FX_INT32 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(FX_INT32 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);
}
|