diff options
author | weili <weili@chromium.org> | 2016-06-18 06:25:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-18 06:25:37 -0700 |
commit | eec3a366adbfada36b98f1de651546ee09df8fc0 (patch) | |
tree | 794aa8c69392b60d8737a8a5b424732b98bdd4b4 /xfa/fde | |
parent | 4ce94e118d66064715de5baebeb4b2b580dcac66 (diff) | |
download | pdfium-eec3a366adbfada36b98f1de651546ee09df8fc0.tar.xz |
Make code compile with clang_use_chrome_plugin (final)
This change mainly contains files in xfa/ and fxjse/ directories
which were not covered by previous changes.
This is part of the efforts to make PDFium code compilable
by Clang chromium style plugins. After this change, PDFium can be
compiled with "clang_use_chrome_plugin=true" for GN build. Since
clang_use_chrome_plugin is true by default, we no longer need to
set this parameter explicitly.
The changes are mainly the following:
-- move inline constructor/destructor of complex class/struct out-of-line;
-- add constructor/destructor of complex class/struct if not
explicitly defined;
-- add explicit out-of-line copy constructor when needed;
-- move inline virtual functions out-of-line;
-- Properly mark virtual functions with 'override';
-- some minor cleanups;
BUG=pdfium:469
Review-Url: https://codereview.chromium.org/2072803002
Diffstat (limited to 'xfa/fde')
-rw-r--r-- | xfa/fde/cfde_txtedtengine.cpp | 25 | ||||
-rw-r--r-- | xfa/fde/css/fde_css.cpp | 27 | ||||
-rw-r--r-- | xfa/fde/css/fde_css.h | 24 | ||||
-rw-r--r-- | xfa/fde/css/fde_csscache.cpp | 6 | ||||
-rw-r--r-- | xfa/fde/css/fde_csscache.h | 6 | ||||
-rw-r--r-- | xfa/fde/css/fde_cssdatatable.cpp | 72 | ||||
-rw-r--r-- | xfa/fde/css/fde_cssdatatable.h | 76 | ||||
-rw-r--r-- | xfa/fde/css/fde_cssstyleselector.cpp | 250 | ||||
-rw-r--r-- | xfa/fde/css/fde_cssstyleselector.h | 276 | ||||
-rw-r--r-- | xfa/fde/css/fde_cssstylesheet.cpp | 89 | ||||
-rw-r--r-- | xfa/fde/css/fde_cssstylesheet.h | 61 | ||||
-rw-r--r-- | xfa/fde/css/fde_csssyntax.h | 3 | ||||
-rw-r--r-- | xfa/fde/fde_object.h | 2 | ||||
-rw-r--r-- | xfa/fde/ifde_txtedtengine.h | 24 | ||||
-rw-r--r-- | xfa/fde/tto/fde_textout.h | 6 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.cpp | 109 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.h | 44 |
17 files changed, 742 insertions, 358 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 11a6d5c3f7..8c950f5ab3 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -24,6 +24,31 @@ const uint32_t kUnicodeParagraphSeparator = 0x2029; } // namespace +FDE_TXTEDTPARAMS::FDE_TXTEDTPARAMS() + : fPlateWidth(0), + fPlateHeight(0), + nLineCount(0), + dwLayoutStyles(0), + dwAlignment(0), + dwMode(0), + pFont(nullptr), + fFontSize(10.0f), + dwFontColor(0xff000000), + fLineSpace(10.0f), + fTabWidth(36), + bTabEquidistant(FALSE), + wDefChar(0xFEFF), + wLineBreakChar('\n'), + nCharRotation(0), + nLineEnd(0), + nHorzScale(100), + fCharSpace(0), + pEventSink(nullptr) {} + +FDE_TXTEDT_TEXTCHANGE_INFO::FDE_TXTEDT_TEXTCHANGE_INFO() {} + +FDE_TXTEDT_TEXTCHANGE_INFO::~FDE_TXTEDT_TEXTCHANGE_INFO() {} + CFDE_TxtEdtEngine::CFDE_TxtEdtEngine() : m_pTextBreak(nullptr), m_nPageLineCount(20), diff --git a/xfa/fde/css/fde_css.cpp b/xfa/fde/css/fde_css.cpp new file mode 100644 index 0000000000..053b2774e6 --- /dev/null +++ b/xfa/fde/css/fde_css.cpp @@ -0,0 +1,27 @@ +// 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 "xfa/fde/css/fde_css.h" + +FDE_CSSVALUETYPE IFDE_CSSPrimitiveValue::GetType() const { + return FDE_CSSVALUETYPE_Primitive; +} + +FDE_CSSVALUETYPE IFDE_CSSValueList::GetType() const { + return FDE_CSSVALUETYPE_List; +} + +FDE_CSSRULETYPE IFDE_CSSStyleRule::GetType() const { + return FDE_CSSRULETYPE_Style; +} + +FDE_CSSRULETYPE IFDE_CSSMediaRule::GetType() const { + return FDE_CSSRULETYPE_Media; +} + +FDE_CSSRULETYPE IFDE_CSSFontFaceRule::GetType() const { + return FDE_CSSRULETYPE_FontFace; +} diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h index 551f8f8962..a0ede3d9f7 100644 --- a/xfa/fde/css/fde_css.h +++ b/xfa/fde/css/fde_css.h @@ -690,9 +690,9 @@ class IFDE_CSSValue { class IFDE_CSSPrimitiveValue : public IFDE_CSSValue { public: - virtual FDE_CSSVALUETYPE GetType() const { - return FDE_CSSVALUETYPE_Primitive; - } + // IFDE_CSSValue + FDE_CSSVALUETYPE GetType() const override; + virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const = 0; virtual FX_ARGB GetRGBColor() const = 0; virtual FX_FLOAT GetFloat() const = 0; @@ -705,7 +705,9 @@ class IFDE_CSSPrimitiveValue : public IFDE_CSSValue { class IFDE_CSSValueList : public IFDE_CSSValue { public: - virtual FDE_CSSVALUETYPE GetType() const { return FDE_CSSVALUETYPE_List; } + // IFDE_CSSValue + FDE_CSSVALUETYPE GetType() const override; + virtual int32_t CountValues() const = 0; virtual IFDE_CSSValue* GetValue(int32_t index) const = 0; }; @@ -715,11 +717,14 @@ class IFDE_CSSRule { virtual ~IFDE_CSSRule() {} virtual FDE_CSSRULETYPE GetType() const = 0; }; + typedef CFX_MassArrayTemplate<IFDE_CSSRule*> CFDE_CSSRuleArray; class IFDE_CSSStyleRule : public IFDE_CSSRule { public: - virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Style; } + // IFDE_CSSValue + FDE_CSSRULETYPE GetType() const override; + virtual int32_t CountSelectorLists() const = 0; virtual CFDE_CSSSelector* GetSelectorList(int32_t index) const = 0; virtual CFDE_CSSDeclaration* GetDeclaration() = 0; @@ -727,7 +732,9 @@ class IFDE_CSSStyleRule : public IFDE_CSSRule { class IFDE_CSSMediaRule : public IFDE_CSSRule { public: - virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Media; } + // IFDE_CSSValue + FDE_CSSRULETYPE GetType() const override; + virtual uint32_t GetMediaList() const = 0; virtual int32_t CountRules() const = 0; virtual IFDE_CSSRule* GetRule(int32_t index) = 0; @@ -735,7 +742,9 @@ class IFDE_CSSMediaRule : public IFDE_CSSRule { class IFDE_CSSFontFaceRule : public IFDE_CSSRule { public: - virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_FontFace; } + // IFDE_CSSValue + FDE_CSSRULETYPE GetType() const override; + virtual CFDE_CSSDeclaration* GetDeclaration() = 0; }; @@ -760,6 +769,7 @@ class IFDE_CSSStyleSheet : public IFX_Retainable { virtual int32_t CountRules() const = 0; virtual IFDE_CSSRule* GetRule(int32_t index) = 0; }; + typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray; struct FDE_CSSLENGTH { diff --git a/xfa/fde/css/fde_csscache.cpp b/xfa/fde/css/fde_csscache.cpp index 76a893d2d1..a355a43c61 100644 --- a/xfa/fde/css/fde_csscache.cpp +++ b/xfa/fde/css/fde_csscache.cpp @@ -56,6 +56,12 @@ FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it) dwClassHashs.Copy(it.dwClassHashs); } +FDE_CSSTagCache::~FDE_CSSTagCache() {} + +CFDE_CSSAccelerator::CFDE_CSSAccelerator() {} + +CFDE_CSSAccelerator::~CFDE_CSSAccelerator() {} + void CFDE_CSSAccelerator::OnEnterTag(CXFA_CSSTagProvider* pTag) { FDE_CSSTagCache* pTop = GetTopElement(); FDE_CSSTagCache item(pTop, pTag); diff --git a/xfa/fde/css/fde_csscache.h b/xfa/fde/css/fde_csscache.h index 28962e45eb..bab86ea880 100644 --- a/xfa/fde/css/fde_csscache.h +++ b/xfa/fde/css/fde_csscache.h @@ -15,7 +15,7 @@ class FDE_CSSCacheItem : public CFX_Target { public: explicit FDE_CSSCacheItem(IFDE_CSSStyleSheet* p); - ~FDE_CSSCacheItem(); + ~FDE_CSSCacheItem() override; IFDE_CSSStyleSheet* pStylesheet; uint32_t dwActivity; @@ -25,6 +25,7 @@ class FDE_CSSTagCache : public CFX_Target { public: FDE_CSSTagCache(FDE_CSSTagCache* parent, CXFA_CSSTagProvider* tag); FDE_CSSTagCache(const FDE_CSSTagCache& it); + ~FDE_CSSTagCache() override; FDE_CSSTagCache* GetParent() const { return pParent; } CXFA_CSSTagProvider* GetTag() const { return pTag; } @@ -52,6 +53,9 @@ typedef CFX_ObjectStackTemplate<FDE_CSSTagCache> CFDE_CSSTagStack; class CFDE_CSSAccelerator : public CFX_Target { public: + CFDE_CSSAccelerator(); + ~CFDE_CSSAccelerator() override; + void OnEnterTag(CXFA_CSSTagProvider* pTag); void OnLeaveTag(CXFA_CSSTagProvider* pTag); diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp index ac8c466932..c2767e7eb2 100644 --- a/xfa/fde/css/fde_cssdatatable.cpp +++ b/xfa/fde/css/fde_cssdatatable.cpp @@ -795,6 +795,14 @@ CFDE_CSSValueList::CFDE_CSSValueList(IFX_MemoryAllocator* pStaticStore, m_ppList = (IFDE_CSSValue**)pStaticStore->Alloc(iByteCount); FXSYS_memcpy(m_ppList, list.GetData(), iByteCount); } + +int32_t CFDE_CSSValueList::CountValues() const { + return m_iCount; +} + +IFDE_CSSValue* CFDE_CSSValueList::GetValue(int32_t index) const { + return m_ppList[index]; +} FX_BOOL CFDE_CSSValueListParser::NextValue(FDE_CSSPRIMITIVETYPE& eType, const FX_WCHAR*& pStart, int32_t& iLength) { @@ -896,3 +904,67 @@ int32_t CFDE_CSSValueListParser::SkipTo(FX_WCHAR wch, } return m_pCur - pStart; } + +CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue( + const CFDE_CSSPrimitiveValue& src) = default; + +CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FX_ARGB color) + : m_eType(FDE_CSSPRIMITIVETYPE_RGB), m_dwColor(color) {} + +CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPROPERTYVALUE eValue) + : m_eType(FDE_CSSPRIMITIVETYPE_Enum), m_eEnum(eValue) {} + +CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, + FX_FLOAT fValue) + : m_eType(eType), m_fNumber(fValue) {} + +CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, + const FX_WCHAR* pValue) + : m_eType(eType), m_pString(pValue) { + ASSERT(m_pString != nullptr); +} + +CFDE_CSSPrimitiveValue::CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction) + : m_eType(FDE_CSSPRIMITIVETYPE_Function), m_pFunction(pFunction) {} + +FDE_CSSPRIMITIVETYPE CFDE_CSSPrimitiveValue::GetPrimitiveType() const { + return m_eType; +} + +FX_ARGB CFDE_CSSPrimitiveValue::GetRGBColor() const { + ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_RGB); + return m_dwColor; +} + +FX_FLOAT CFDE_CSSPrimitiveValue::GetFloat() const { + ASSERT(m_eType >= FDE_CSSPRIMITIVETYPE_Number && + m_eType <= FDE_CSSPRIMITIVETYPE_PC); + return m_fNumber; +} + +const FX_WCHAR* CFDE_CSSPrimitiveValue::GetString(int32_t& iLength) const { + ASSERT(m_eType >= FDE_CSSPRIMITIVETYPE_String && + m_eType <= FDE_CSSPRIMITIVETYPE_URI); + iLength = FXSYS_wcslen(m_pString); + return m_pString; +} + +FDE_CSSPROPERTYVALUE CFDE_CSSPrimitiveValue::GetEnum() const { + ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Enum); + return m_eEnum; +} + +const FX_WCHAR* CFDE_CSSPrimitiveValue::GetFuncName() const { + ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function); + return m_pFunction->GetFuncName(); +} + +int32_t CFDE_CSSPrimitiveValue::CountArgs() const { + ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function); + return m_pFunction->CountArgs(); +} + +IFDE_CSSValue* CFDE_CSSPrimitiveValue::GetArgs(int32_t index) const { + ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function); + return m_pFunction->GetArgs(index); +} diff --git a/xfa/fde/css/fde_cssdatatable.h b/xfa/fde/css/fde_cssdatatable.h index d61ff09ae7..252efdce50 100644 --- a/xfa/fde/css/fde_cssdatatable.h +++ b/xfa/fde/css/fde_cssdatatable.h @@ -27,56 +27,26 @@ class CFDE_CSSFunction : public CFX_Target { IFDE_CSSValueList* m_pArgList; const FX_WCHAR* m_pszFuncName; }; + class CFDE_CSSPrimitiveValue : public IFDE_CSSPrimitiveValue, public CFX_Target { public: - CFDE_CSSPrimitiveValue(const CFDE_CSSPrimitiveValue& src) { *this = src; } - CFDE_CSSPrimitiveValue(FX_ARGB color) - : m_eType(FDE_CSSPRIMITIVETYPE_RGB), m_dwColor(color) {} - CFDE_CSSPrimitiveValue(FDE_CSSPROPERTYVALUE eValue) - : m_eType(FDE_CSSPRIMITIVETYPE_Enum), m_eEnum(eValue) {} - CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, FX_FLOAT fValue) - : m_eType(eType), m_fNumber(fValue) {} - CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, const FX_WCHAR* pValue) - : m_eType(eType), m_pString(pValue) { - ASSERT(m_pString); - } - CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction) - : m_eType(FDE_CSSPRIMITIVETYPE_Function), m_pFunction(pFunction) {} - - virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const { return m_eType; } - - virtual FX_ARGB GetRGBColor() const { - ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_RGB); - return m_dwColor; - } - virtual FX_FLOAT GetFloat() const { - ASSERT(m_eType >= FDE_CSSPRIMITIVETYPE_Number && - m_eType <= FDE_CSSPRIMITIVETYPE_PC); - return m_fNumber; - } - virtual const FX_WCHAR* GetString(int32_t& iLength) const { - ASSERT(m_eType >= FDE_CSSPRIMITIVETYPE_String && - m_eType <= FDE_CSSPRIMITIVETYPE_URI); - iLength = FXSYS_wcslen(m_pString); - return m_pString; - } - virtual FDE_CSSPROPERTYVALUE GetEnum() const { - ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Enum); - return m_eEnum; - } - virtual const FX_WCHAR* GetFuncName() const { - ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function); - return m_pFunction->GetFuncName(); - } - virtual int32_t CountArgs() const { - ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function); - return m_pFunction->CountArgs(); - } - virtual IFDE_CSSValue* GetArgs(int32_t index) const { - ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function); - return m_pFunction->GetArgs(index); - } + explicit CFDE_CSSPrimitiveValue(FX_ARGB color); + explicit CFDE_CSSPrimitiveValue(FDE_CSSPROPERTYVALUE eValue); + explicit CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction); + CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, FX_FLOAT fValue); + CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, const FX_WCHAR* pValue); + CFDE_CSSPrimitiveValue(const CFDE_CSSPrimitiveValue& src); + + // IFDE_CSSPrimitiveValue + FDE_CSSPRIMITIVETYPE GetPrimitiveType() const override; + FX_ARGB GetRGBColor() const override; + FX_FLOAT GetFloat() const override; + const FX_WCHAR* GetString(int32_t& iLength) const override; + FDE_CSSPROPERTYVALUE GetEnum() const override; + const FX_WCHAR* GetFuncName() const override; + int32_t CountArgs() const override; + IFDE_CSSValue* GetArgs(int32_t index) const override; FDE_CSSPRIMITIVETYPE m_eType; union { @@ -87,21 +57,24 @@ class CFDE_CSSPrimitiveValue : public IFDE_CSSPrimitiveValue, CFDE_CSSFunction* m_pFunction; }; }; + typedef CFX_ArrayTemplate<IFDE_CSSPrimitiveValue*> CFDE_CSSPrimitiveArray; typedef CFX_ArrayTemplate<IFDE_CSSValue*> CFDE_CSSValueArray; + class CFDE_CSSValueList : public IFDE_CSSValueList, public CFX_Target { public: CFDE_CSSValueList(IFX_MemoryAllocator* pStaticStore, const CFDE_CSSValueArray& list); - virtual int32_t CountValues() const { return m_iCount; } - virtual IFDE_CSSValue* GetValue(int32_t index) const { - return m_ppList[index]; - } + + // IFDE_CSSValueList + int32_t CountValues() const override; + IFDE_CSSValue* GetValue(int32_t index) const override; protected: IFDE_CSSValue** m_ppList; int32_t m_iCount; }; + class CFDE_CSSValueListParser : public CFX_Target { public: CFDE_CSSValueListParser(const FX_WCHAR* psz, int32_t iLen, FX_WCHAR separator) @@ -117,6 +90,7 @@ class CFDE_CSSValueListParser : public CFX_Target { int32_t SkipTo(FX_WCHAR wch, FX_BOOL bWSSeparator = FALSE, FX_BOOL bBrContinue = FALSE); + const FX_WCHAR* m_pCur; const FX_WCHAR* m_pEnd; }; diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp index 007657d154..6082136fe0 100644 --- a/xfa/fde/css/fde_cssstyleselector.cpp +++ b/xfa/fde/css/fde_cssstyleselector.cpp @@ -74,6 +74,12 @@ void CFDE_CSSCounterStyle::DoUpdateIndex(IFDE_CSSValueList* pList) { } } } + +CFDE_CSSCounterStyle::CFDE_CSSCounterStyle() + : m_pCounterInc(nullptr), m_pCounterReset(nullptr), m_bIndexDirty(FALSE) {} + +CFDE_CSSCounterStyle::~CFDE_CSSCounterStyle() {} + void CFDE_CSSCounterStyle::UpdateIndex() { if (!m_bIndexDirty) { return; @@ -98,6 +104,7 @@ FDE_CSSRuleData::FDE_CSSRuleData(CFDE_CSSSelector* pSel, } } } + void CFDE_CSSRuleCollection::Clear() { m_IDRules.RemoveAll(); m_TagRules.RemoveAll(); @@ -106,6 +113,17 @@ void CFDE_CSSRuleCollection::Clear() { m_pStaticStore = nullptr; m_iSelectors = 0; } + +CFDE_CSSRuleCollection::CFDE_CSSRuleCollection() + : m_pStaticStore(nullptr), + m_pUniversalRules(nullptr), + m_pPersudoRules(nullptr), + m_iSelectors(0) {} + +CFDE_CSSRuleCollection::~CFDE_CSSRuleCollection() { + Clear(); +} + void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, uint32_t dwMediaList, IFGAS_FontMgr* pFontMgr) { @@ -120,6 +138,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, } } } + void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, IFDE_CSSRule* pRule, uint32_t dwMediaList, @@ -179,6 +198,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet, break; } } + void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map, uint32_t dwKey, CFDE_CSSSelector* pSel, @@ -1783,3 +1803,233 @@ FDE_CSSFONTVARIANT CFDE_CSSStyleSelector::ToFontVariant( return eValue == FDE_CSSPROPERTYVALUE_SmallCaps ? FDE_CSSFONTVARIANT_SmallCaps : FDE_CSSFONTVARIANT_Normal; } + +CFDE_CSSComputedStyle::CFDE_CSSComputedStyle(IFX_MemoryAllocator* pAlloc) + : m_dwRefCount(1), m_pAllocator(pAlloc) {} + +CFDE_CSSComputedStyle::~CFDE_CSSComputedStyle() {} + +uint32_t CFDE_CSSComputedStyle::Retain() { + return ++m_dwRefCount; +} + +uint32_t CFDE_CSSComputedStyle::Release() { + uint32_t dwRefCount = --m_dwRefCount; + if (dwRefCount == 0) { + delete m_NonInheritedData.m_pCounterStyle; + FXTARGET_DeleteWith(CFDE_CSSComputedStyle, m_pAllocator, this); + } + return dwRefCount; +} + +void CFDE_CSSComputedStyle::Reset() { + m_InheritedData.Reset(); + m_NonInheritedData.Reset(); +} + +IFDE_CSSFontStyle* CFDE_CSSComputedStyle::GetFontStyles() { + return static_cast<IFDE_CSSFontStyle*>(this); +} + +IFDE_CSSBoundaryStyle* CFDE_CSSComputedStyle::GetBoundaryStyles() { + return static_cast<IFDE_CSSBoundaryStyle*>(this); +} + +IFDE_CSSPositionStyle* CFDE_CSSComputedStyle::GetPositionStyles() { + return static_cast<IFDE_CSSPositionStyle*>(this); +} + +IFDE_CSSParagraphStyle* CFDE_CSSComputedStyle::GetParagraphStyles() { + return static_cast<IFDE_CSSParagraphStyle*>(this); +} + +FX_BOOL CFDE_CSSComputedStyle::GetCustomStyle(const CFX_WideStringC& wsName, + CFX_WideString& wsValue) const { + for (int32_t i = m_CustomProperties.GetSize() - 2; i > -1; i -= 2) { + if (wsName == m_CustomProperties[i]) { + wsValue = m_CustomProperties[i + 1]; + return TRUE; + } + } + return FALSE; +} + +int32_t CFDE_CSSComputedStyle::CountFontFamilies() const { + return m_InheritedData.m_pFontFamily + ? m_InheritedData.m_pFontFamily->CountValues() + : 0; +} + +const FX_WCHAR* CFDE_CSSComputedStyle::GetFontFamily(int32_t index) const { + return (static_cast<IFDE_CSSPrimitiveValue*>( + m_InheritedData.m_pFontFamily->GetValue(index))) + ->GetString(index); +} + +uint16_t CFDE_CSSComputedStyle::GetFontWeight() const { + return m_InheritedData.m_wFontWeight; +} + +FDE_CSSFONTVARIANT CFDE_CSSComputedStyle::GetFontVariant() const { + return static_cast<FDE_CSSFONTVARIANT>(m_InheritedData.m_eFontVariant); +} + +FDE_CSSFONTSTYLE CFDE_CSSComputedStyle::GetFontStyle() const { + return static_cast<FDE_CSSFONTSTYLE>(m_InheritedData.m_eFontStyle); +} + +FX_FLOAT CFDE_CSSComputedStyle::GetFontSize() const { + return m_InheritedData.m_fFontSize; +} + +FX_ARGB CFDE_CSSComputedStyle::GetColor() const { + return m_InheritedData.m_dwFontColor; +} + +void CFDE_CSSComputedStyle::SetFontWeight(uint16_t wFontWeight) { + m_InheritedData.m_wFontWeight = wFontWeight; +} + +void CFDE_CSSComputedStyle::SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) { + m_InheritedData.m_eFontVariant = eFontVariant; +} + +void CFDE_CSSComputedStyle::SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) { + m_InheritedData.m_eFontStyle = eFontStyle; +} + +void CFDE_CSSComputedStyle::SetFontSize(FX_FLOAT fFontSize) { + m_InheritedData.m_fFontSize = fFontSize; +} + +void CFDE_CSSComputedStyle::SetColor(FX_ARGB dwFontColor) { + m_InheritedData.m_dwFontColor = dwFontColor; +} + +const FDE_CSSRECT* CFDE_CSSComputedStyle::GetBorderWidth() const { + return m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth) + : nullptr; +} + +const FDE_CSSRECT* CFDE_CSSComputedStyle::GetMarginWidth() const { + return m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth) + : nullptr; +} + +const FDE_CSSRECT* CFDE_CSSComputedStyle::GetPaddingWidth() const { + return m_NonInheritedData.m_bHasPadding ? &(m_NonInheritedData.m_PaddingWidth) + : nullptr; +} + +void CFDE_CSSComputedStyle::SetMarginWidth(const FDE_CSSRECT& rect) { + m_NonInheritedData.m_MarginWidth = rect; + m_NonInheritedData.m_bHasMargin = TRUE; +} + +void CFDE_CSSComputedStyle::SetPaddingWidth(const FDE_CSSRECT& rect) { + m_NonInheritedData.m_PaddingWidth = rect; + m_NonInheritedData.m_bHasPadding = TRUE; +} + +FDE_CSSDISPLAY CFDE_CSSComputedStyle::GetDisplay() const { + return static_cast<FDE_CSSDISPLAY>(m_NonInheritedData.m_eDisplay); +} + +FX_FLOAT CFDE_CSSComputedStyle::GetLineHeight() const { + return m_InheritedData.m_fLineHeight; +} + +const FDE_CSSLENGTH& CFDE_CSSComputedStyle::GetTextIndent() const { + return m_InheritedData.m_TextIndent; +} + +FDE_CSSTEXTALIGN CFDE_CSSComputedStyle::GetTextAlign() const { + return static_cast<FDE_CSSTEXTALIGN>(m_InheritedData.m_eTextAligh); +} + +FDE_CSSVERTICALALIGN CFDE_CSSComputedStyle::GetVerticalAlign() const { + return static_cast<FDE_CSSVERTICALALIGN>(m_NonInheritedData.m_eVerticalAlign); +} + +FX_FLOAT CFDE_CSSComputedStyle::GetNumberVerticalAlign() const { + return m_NonInheritedData.m_fVerticalAlign; +} + +uint32_t CFDE_CSSComputedStyle::GetTextDecoration() const { + return m_NonInheritedData.m_dwTextDecoration; +} + +const FDE_CSSLENGTH& CFDE_CSSComputedStyle::GetLetterSpacing() const { + return m_InheritedData.m_LetterSpacing; +} + +void CFDE_CSSComputedStyle::SetLineHeight(FX_FLOAT fLineHeight) { + m_InheritedData.m_fLineHeight = fLineHeight; +} + +void CFDE_CSSComputedStyle::SetTextIndent(const FDE_CSSLENGTH& textIndent) { + m_InheritedData.m_TextIndent = textIndent; +} + +void CFDE_CSSComputedStyle::SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) { + m_InheritedData.m_eTextAligh = eTextAlign; +} + +void CFDE_CSSComputedStyle::SetNumberVerticalAlign(FX_FLOAT fAlign) { + m_NonInheritedData.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number, + m_NonInheritedData.m_fVerticalAlign = fAlign; +} + +void CFDE_CSSComputedStyle::SetTextDecoration(uint32_t dwTextDecoration) { + m_NonInheritedData.m_dwTextDecoration = dwTextDecoration; +} + +void CFDE_CSSComputedStyle::SetLetterSpacing( + const FDE_CSSLENGTH& letterSpacing) { + m_InheritedData.m_LetterSpacing = letterSpacing; +} + +void CFDE_CSSComputedStyle::AddCustomStyle(const CFX_WideString& wsName, + const CFX_WideString& wsValue) { + m_CustomProperties.Add(wsName); + m_CustomProperties.Add(wsValue); +} + +CFDE_CSSInheritedData::CFDE_CSSInheritedData() { + Reset(); +} + +void CFDE_CSSInheritedData::Reset() { + FXSYS_memset(this, 0, sizeof(CFDE_CSSInheritedData)); + m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal); + m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal); + m_TextIndent.Set(FDE_CSSLENGTHUNIT_Point, 0); + m_fFontSize = 12.0f; + m_fLineHeight = 14.0f; + m_wFontWeight = 400; + m_dwFontColor = 0xFF000000; + m_iWidows = 2; + m_bTextEmphasisColorCurrent = TRUE; + m_iOrphans = 2; +} + +CFDE_CSSNonInheritedData::CFDE_CSSNonInheritedData() { + Reset(); +} + +void CFDE_CSSNonInheritedData::Reset() { + FXSYS_memset(this, 0, sizeof(CFDE_CSSNonInheritedData)); + m_PaddingWidth.Set(FDE_CSSLENGTHUNIT_Point, 0); + m_MarginWidth = m_PaddingWidth; + m_BorderWidth = m_PaddingWidth; + m_MinBoxSize.Set(FDE_CSSLENGTHUNIT_Point, 0); + m_MaxBoxSize.Set(FDE_CSSLENGTHUNIT_None); + m_eDisplay = FDE_CSSDISPLAY_Inline; + m_fVerticalAlign = 0.0f; + m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto); + m_ColumnGap.Set(FDE_CSSLENGTHUNIT_Normal); + m_bColumnRuleColorSame = TRUE; + m_ColumnWidth.Set(FDE_CSSLENGTHUNIT_Auto); + m_ColumnRuleWidth.Set(FDE_CSSLENGTHUNIT_Auto); + m_eTextCombine = FDE_CSSTEXTCOMBINE_None; +} diff --git a/xfa/fde/css/fde_cssstyleselector.h b/xfa/fde/css/fde_cssstyleselector.h index 3af75a7b9e..042e989242 100644 --- a/xfa/fde/css/fde_cssstyleselector.h +++ b/xfa/fde/css/fde_cssstyleselector.h @@ -34,12 +34,8 @@ class FDE_CSSRuleData : public CFX_Target { class CFDE_CSSRuleCollection : public CFX_Target { public: - CFDE_CSSRuleCollection() - : m_pStaticStore(nullptr), - m_pUniversalRules(nullptr), - m_pPersudoRules(nullptr), - m_iSelectors(0) {} - ~CFDE_CSSRuleCollection() { Clear(); } + CFDE_CSSRuleCollection(); + ~CFDE_CSSRuleCollection() override; void AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets, uint32_t dwMediaList, @@ -211,33 +207,29 @@ struct FDE_CSSCOUNTERDATA { class CFDE_CSSCounterStyle { public: - CFDE_CSSCounterStyle() : m_pCounterInc(nullptr), m_pCounterReset(nullptr) {} + CFDE_CSSCounterStyle(); + ~CFDE_CSSCounterStyle(); void SetCounterIncrementList(IFDE_CSSValueList* pList) { m_pCounterInc = pList; m_bIndexDirty = TRUE; } - void SetCounterResetList(IFDE_CSSValueList* pList) { m_pCounterReset = pList; m_bIndexDirty = TRUE; } - int32_t CountCounters() { UpdateIndex(); return m_arrCounterData.GetSize(); } - FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) { UpdateIndex(); return m_arrCounterData.ElementAt(index).GetCounterIncrement(iValue); } - FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) { UpdateIndex(); return m_arrCounterData.ElementAt(index).GetCounterReset(iValue); } - const FX_WCHAR* GetCounterIdentifier(int32_t index) { UpdateIndex(); return m_arrCounterData.ElementAt(index).m_pszIdent; @@ -256,19 +248,9 @@ class CFDE_CSSCounterStyle { class CFDE_CSSInheritedData { public: - void Reset() { - FXSYS_memset(this, 0, sizeof(CFDE_CSSInheritedData)); - m_LetterSpacing.Set(FDE_CSSLENGTHUNIT_Normal); - m_WordSpacing.Set(FDE_CSSLENGTHUNIT_Normal); - m_TextIndent.Set(FDE_CSSLENGTHUNIT_Point, 0); - m_fFontSize = 12.0f; - m_fLineHeight = 14.0f; - m_wFontWeight = 400; - m_dwFontColor = 0xFF000000; - m_iWidows = 2; - m_bTextEmphasisColorCurrent = TRUE; - m_iOrphans = 2; - } + CFDE_CSSInheritedData(); + + void Reset(); const FX_WCHAR* m_pszListStyleImage; FDE_CSSLENGTH m_LetterSpacing; @@ -306,21 +288,9 @@ class CFDE_CSSInheritedData { class CFDE_CSSNonInheritedData { public: - void Reset() { - FXSYS_memset(this, 0, sizeof(CFDE_CSSNonInheritedData)); - m_MarginWidth = m_BorderWidth = - m_PaddingWidth.Set(FDE_CSSLENGTHUNIT_Point, 0); - m_MinBoxSize.Set(FDE_CSSLENGTHUNIT_Point, 0); - m_MaxBoxSize.Set(FDE_CSSLENGTHUNIT_None); - m_eDisplay = FDE_CSSDISPLAY_Inline; - m_fVerticalAlign = 0.0f; - m_ColumnCount.Set(FDE_CSSLENGTHUNIT_Auto); - m_ColumnGap.Set(FDE_CSSLENGTHUNIT_Normal); - m_bColumnRuleColorSame = TRUE; - m_ColumnWidth.Set(FDE_CSSLENGTHUNIT_Auto); - m_ColumnRuleWidth.Set(FDE_CSSLENGTHUNIT_Auto); - m_eTextCombine = FDE_CSSTEXTCOMBINE_None; - } + CFDE_CSSNonInheritedData(); + + void Reset(); IFDE_CSSValueList* m_pContentList; CFDE_CSSCounterStyle* m_pCounterStyle; @@ -385,196 +355,62 @@ class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle, public IFDE_CSSParagraphStyle, public CFX_Target { public: - CFDE_CSSComputedStyle(IFX_MemoryAllocator* pAlloc) - : m_dwRefCount(1), m_pAllocator(pAlloc) {} - - ~CFDE_CSSComputedStyle() override {} - - // IFX_Retainable: - uint32_t Retain() override { return ++m_dwRefCount; } - uint32_t Release() override { - uint32_t dwRefCount = --m_dwRefCount; - if (dwRefCount == 0) { - delete m_NonInheritedData.m_pCounterStyle; - FXTARGET_DeleteWith(CFDE_CSSComputedStyle, m_pAllocator, this); - } - return dwRefCount; - } - - // IFDE_CSSComputedStyle: - void Reset() override { - m_InheritedData.Reset(); - m_NonInheritedData.Reset(); - } - - IFDE_CSSFontStyle* GetFontStyles() override { - return static_cast<IFDE_CSSFontStyle*>(this); - } - - IFDE_CSSBoundaryStyle* GetBoundaryStyles() override { - return static_cast<IFDE_CSSBoundaryStyle*>(this); - } - - IFDE_CSSPositionStyle* GetPositionStyles() override { - return static_cast<IFDE_CSSPositionStyle*>(this); - } - - IFDE_CSSParagraphStyle* GetParagraphStyles() override { - return static_cast<IFDE_CSSParagraphStyle*>(this); - } - + CFDE_CSSComputedStyle(IFX_MemoryAllocator* pAlloc); + ~CFDE_CSSComputedStyle() override; + + // IFX_Retainable + uint32_t Retain() override; + uint32_t Release() override; + + // IFDE_CSSComputedStyle + void Reset() override; + IFDE_CSSFontStyle* GetFontStyles() override; + IFDE_CSSBoundaryStyle* GetBoundaryStyles() override; + IFDE_CSSPositionStyle* GetPositionStyles() override; + IFDE_CSSParagraphStyle* GetParagraphStyles() override; FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName, - CFX_WideString& wsValue) const override { - for (int32_t i = m_CustomProperties.GetSize() - 2; i > -1; i -= 2) { - if (wsName == m_CustomProperties[i]) { - wsValue = m_CustomProperties[i + 1]; - return TRUE; - } - } - return FALSE; - } + CFX_WideString& wsValue) const override; // IFDE_CSSFontStyle: - int32_t CountFontFamilies() const override { - return m_InheritedData.m_pFontFamily - ? m_InheritedData.m_pFontFamily->CountValues() - : 0; - } - - const FX_WCHAR* GetFontFamily(int32_t index) const override { - return (static_cast<IFDE_CSSPrimitiveValue*>( - m_InheritedData.m_pFontFamily->GetValue(index))) - ->GetString(index); - } - - uint16_t GetFontWeight() const override { - return m_InheritedData.m_wFontWeight; - } - - FDE_CSSFONTVARIANT GetFontVariant() const override { - return static_cast<FDE_CSSFONTVARIANT>(m_InheritedData.m_eFontVariant); - } - - FDE_CSSFONTSTYLE GetFontStyle() const override { - return static_cast<FDE_CSSFONTSTYLE>(m_InheritedData.m_eFontStyle); - } - - FX_FLOAT GetFontSize() const override { return m_InheritedData.m_fFontSize; } - - FX_ARGB GetColor() const override { return m_InheritedData.m_dwFontColor; } - - void SetFontWeight(uint16_t wFontWeight) override { - m_InheritedData.m_wFontWeight = wFontWeight; - } - - void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) override { - m_InheritedData.m_eFontVariant = eFontVariant; - } - - void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) override { - m_InheritedData.m_eFontStyle = eFontStyle; - } - - void SetFontSize(FX_FLOAT fFontSize) override { - m_InheritedData.m_fFontSize = fFontSize; - } - - void SetColor(FX_ARGB dwFontColor) override { - m_InheritedData.m_dwFontColor = dwFontColor; - } + int32_t CountFontFamilies() const override; + const FX_WCHAR* GetFontFamily(int32_t index) const override; + uint16_t GetFontWeight() const override; + FDE_CSSFONTVARIANT GetFontVariant() const override; + FDE_CSSFONTSTYLE GetFontStyle() const override; + FX_FLOAT GetFontSize() const override; + FX_ARGB GetColor() const override; + void SetFontWeight(uint16_t wFontWeight) override; + void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) override; + void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) override; + void SetFontSize(FX_FLOAT fFontSize) override; + void SetColor(FX_ARGB dwFontColor) override; // IFDE_CSSBoundaryStyle: - const FDE_CSSRECT* GetBorderWidth() const override { - return m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth) - : nullptr; - } - - const FDE_CSSRECT* GetMarginWidth() const override { - return m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth) - : nullptr; - } - - const FDE_CSSRECT* GetPaddingWidth() const override { - return m_NonInheritedData.m_bHasPadding - ? &(m_NonInheritedData.m_PaddingWidth) - : nullptr; - } - - void SetMarginWidth(const FDE_CSSRECT& rect) override { - m_NonInheritedData.m_MarginWidth = rect; - m_NonInheritedData.m_bHasMargin = TRUE; - } - - void SetPaddingWidth(const FDE_CSSRECT& rect) override { - m_NonInheritedData.m_PaddingWidth = rect; - m_NonInheritedData.m_bHasPadding = TRUE; - } + const FDE_CSSRECT* GetBorderWidth() const override; + const FDE_CSSRECT* GetMarginWidth() const override; + const FDE_CSSRECT* GetPaddingWidth() const override; + void SetMarginWidth(const FDE_CSSRECT& rect) override; + void SetPaddingWidth(const FDE_CSSRECT& rect) override; // IFDE_CSSPositionStyle: - FDE_CSSDISPLAY GetDisplay() const override { - return static_cast<FDE_CSSDISPLAY>(m_NonInheritedData.m_eDisplay); - } + FDE_CSSDISPLAY GetDisplay() const override; // IFDE_CSSParagraphStyle: - FX_FLOAT GetLineHeight() const override { - return m_InheritedData.m_fLineHeight; - } - - const FDE_CSSLENGTH& GetTextIndent() const override { - return m_InheritedData.m_TextIndent; - } - - FDE_CSSTEXTALIGN GetTextAlign() const override { - return static_cast<FDE_CSSTEXTALIGN>(m_InheritedData.m_eTextAligh); - } - - FDE_CSSVERTICALALIGN GetVerticalAlign() const override { - return static_cast<FDE_CSSVERTICALALIGN>( - m_NonInheritedData.m_eVerticalAlign); - } - - FX_FLOAT GetNumberVerticalAlign() const override { - return m_NonInheritedData.m_fVerticalAlign; - } - - uint32_t GetTextDecoration() const override { - return m_NonInheritedData.m_dwTextDecoration; - } - - const FDE_CSSLENGTH& GetLetterSpacing() const override { - return m_InheritedData.m_LetterSpacing; - } - - void SetLineHeight(FX_FLOAT fLineHeight) override { - m_InheritedData.m_fLineHeight = fLineHeight; - } - - void SetTextIndent(const FDE_CSSLENGTH& textIndent) override { - m_InheritedData.m_TextIndent = textIndent; - } - - void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) override { - m_InheritedData.m_eTextAligh = eTextAlign; - } - - void SetNumberVerticalAlign(FX_FLOAT fAlign) override { - m_NonInheritedData.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number, - m_NonInheritedData.m_fVerticalAlign = fAlign; - } - - void SetTextDecoration(uint32_t dwTextDecoration) override { - m_NonInheritedData.m_dwTextDecoration = dwTextDecoration; - } - - void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) override { - m_InheritedData.m_LetterSpacing = letterSpacing; - } - + FX_FLOAT GetLineHeight() const override; + const FDE_CSSLENGTH& GetTextIndent() const override; + FDE_CSSTEXTALIGN GetTextAlign() const override; + FDE_CSSVERTICALALIGN GetVerticalAlign() const override; + FX_FLOAT GetNumberVerticalAlign() const override; + uint32_t GetTextDecoration() const override; + const FDE_CSSLENGTH& GetLetterSpacing() const override; + void SetLineHeight(FX_FLOAT fLineHeight) override; + void SetTextIndent(const FDE_CSSLENGTH& textIndent) override; + void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) override; + void SetNumberVerticalAlign(FX_FLOAT fAlign) override; + void SetTextDecoration(uint32_t dwTextDecoration) override; + void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) override; void AddCustomStyle(const CFX_WideString& wsName, - const CFX_WideString& wsValue) { - m_CustomProperties.Add(wsName); - m_CustomProperties.Add(wsValue); - } + const CFX_WideString& wsValue); uint32_t m_dwRefCount; IFX_MemoryAllocator* m_pAllocator; diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp index 6708ca2e72..f0b071223f 100644 --- a/xfa/fde/css/fde_cssstylesheet.cpp +++ b/xfa/fde/css/fde_cssstylesheet.cpp @@ -59,6 +59,7 @@ IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream( } return pStyleSheet; } + IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer( const CFX_WideString& szUrl, const FX_WCHAR* pBuffer, @@ -72,6 +73,7 @@ IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer( } return pStyleSheet; } + CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(uint32_t dwMediaList) : m_wCodePage(FX_CODEPAGE_UTF8), m_wRefCount(1), @@ -79,9 +81,11 @@ CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(uint32_t dwMediaList) m_pAllocator(nullptr) { ASSERT(m_dwMediaList > 0); } + CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() { Reset(); } + void CFDE_CSSStyleSheet::Reset() { for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); @@ -106,9 +110,11 @@ void CFDE_CSSStyleSheet::Reset() { delete m_pAllocator; m_pAllocator = nullptr; } + uint32_t CFDE_CSSStyleSheet::Retain() { return ++m_wRefCount; } + uint32_t CFDE_CSSStyleSheet::Release() { uint32_t dwRefCount = --m_wRefCount; if (dwRefCount == 0) { @@ -116,9 +122,24 @@ uint32_t CFDE_CSSStyleSheet::Release() { } return dwRefCount; } + +FX_BOOL CFDE_CSSStyleSheet::GetUrl(CFX_WideString& szUrl) { + szUrl = m_szUrl; + return szUrl.GetLength() > 0; +} + +uint32_t CFDE_CSSStyleSheet::GetMediaList() const { + return m_dwMediaList; +} + +uint16_t CFDE_CSSStyleSheet::GetCodePage() const { + return m_wCodePage; +} + int32_t CFDE_CSSStyleSheet::CountRules() const { return m_RuleArray.GetSize(); } + IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) { return m_RuleArray.GetAt(index); } @@ -178,6 +199,7 @@ FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax) { m_StringCache.clear(); return eStatus != FDE_CSSSYNTAXSTATUS_Error; } + FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule( CFDE_CSSSyntaxParser* pSyntax) { uint32_t dwMediaList = 0; @@ -216,6 +238,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule( } } } + FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule( CFDE_CSSSyntaxParser* pSyntax, CFDE_CSSRuleArray& ruleArray) { @@ -280,6 +303,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule( } } } + FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule( CFDE_CSSSyntaxParser* pSyntax, CFDE_CSSRuleArray& ruleArray) { @@ -318,6 +342,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule( } } } + FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule( CFDE_CSSSyntaxParser* pSyntax) { for (;;) { @@ -330,10 +355,12 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule( } } } + FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadPageRule( CFDE_CSSSyntaxParser* pSyntax) { return SkipRuleSet(pSyntax); } + FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet( CFDE_CSSSyntaxParser* pSyntax) { for (;;) { @@ -349,6 +376,21 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet( } } } + +CFDE_CSSStyleRule::CFDE_CSSStyleRule() : m_ppSelector(NULL), m_iSelectors(0) {} + +int32_t CFDE_CSSStyleRule::CountSelectorLists() const { + return m_iSelectors; +} + +CFDE_CSSSelector* CFDE_CSSStyleRule::GetSelectorList(int32_t index) const { + return m_ppSelector[index]; +} + +CFDE_CSSDeclaration* CFDE_CSSStyleRule::GetDeclaration() { + return &m_Declaration; +} + void CFDE_CSSStyleRule::SetSelector(IFX_MemoryAllocator* pStaticStore, const CFDE_CSSSelectorArray& list) { ASSERT(!m_ppSelector); @@ -359,6 +401,10 @@ void CFDE_CSSStyleRule::SetSelector(IFX_MemoryAllocator* pStaticStore, m_ppSelector[i] = list.GetAt(i); } } + +CFDE_CSSMediaRule::CFDE_CSSMediaRule(uint32_t dwMediaList) + : m_dwMediaList(dwMediaList) {} + CFDE_CSSMediaRule::~CFDE_CSSMediaRule() { for (int32_t i = m_RuleArray.GetSize() - 1; i >= 0; --i) { IFDE_CSSRule* pRule = m_RuleArray.GetAt(i); @@ -372,9 +418,23 @@ CFDE_CSSMediaRule::~CFDE_CSSMediaRule() { } } } -inline FX_BOOL FDE_IsCSSChar(FX_WCHAR wch) { + +uint32_t CFDE_CSSMediaRule::GetMediaList() const { + return m_dwMediaList; +} + +int32_t CFDE_CSSMediaRule::CountRules() const { + return m_RuleArray.GetSize(); +} + +IFDE_CSSRule* CFDE_CSSMediaRule::GetRule(int32_t index) { + return m_RuleArray.GetAt(index); +} + +FX_BOOL FDE_IsCSSChar(FX_WCHAR wch) { return (wch >= 'a' && wch <= 'z') || (wch >= 'A' && wch <= 'Z'); } + int32_t FDE_GetCSSPersudoLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) { ASSERT(*psz == ':'); const FX_WCHAR* pStart = psz; @@ -388,6 +448,7 @@ int32_t FDE_GetCSSPersudoLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) { } return psz - pStart; } + int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) { const FX_WCHAR* pStart = psz; while (psz < pEnd) { @@ -401,11 +462,33 @@ int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) { } return psz - pStart; } + +CFDE_CSSSelector::CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType, + const FX_WCHAR* psz, + int32_t iLen, + bool bIgnoreCase) + : m_eType(eType), + m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)), + m_pNext(nullptr) {} + +FDE_CSSSELECTORTYPE CFDE_CSSSelector::GetType() const { + return m_eType; +} + +uint32_t CFDE_CSSSelector::GetNameHash() const { + return m_dwHash; +} + +CFDE_CSSSelector* CFDE_CSSSelector::GetNextSelector() const { + return m_pNext; +} + CFDE_CSSSelector* CFDE_CSSSelector::FromString( IFX_MemoryAllocator* pStaticStore, const FX_WCHAR* psz, int32_t iLen) { ASSERT(pStaticStore && psz && iLen > 0); + const FX_WCHAR* pStart = psz; const FX_WCHAR* pEnd = psz + iLen; for (; psz < pEnd; ++psz) { @@ -496,3 +579,7 @@ CFDE_CSSSelector* CFDE_CSSSelector::FromString( pPersudoLast->SetNext(pFirst); return pPersudoFirst; } + +CFDE_CSSDeclaration* CFDE_CSSFontFaceRule::GetDeclaration() { + return &m_Declaration; +} diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h index 4c51579661..83eac993e7 100644 --- a/xfa/fde/css/fde_cssstylesheet.h +++ b/xfa/fde/css/fde_cssstylesheet.h @@ -19,42 +19,37 @@ class CFDE_CSSSelector : public CFX_Target { CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType, const FX_WCHAR* psz, int32_t iLen, - bool bIgnoreCase) - : m_eType(eType), - m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)), - m_pNext(nullptr) {} - virtual FDE_CSSSELECTORTYPE GetType() const { return m_eType; } + bool bIgnoreCase); - virtual uint32_t GetNameHash() const { return m_dwHash; } + virtual FDE_CSSSELECTORTYPE GetType() const; + virtual uint32_t GetNameHash() const; + virtual CFDE_CSSSelector* GetNextSelector() const; - virtual CFDE_CSSSelector* GetNextSelector() const { return m_pNext; } static CFDE_CSSSelector* FromString(IFX_MemoryAllocator* pStaticStore, const FX_WCHAR* psz, int32_t iLen); + void SetNext(CFDE_CSSSelector* pNext) { m_pNext = pNext; } protected: - static CFDE_CSSSelector* ParseSelector(IFX_MemoryAllocator* pStaticStore, - const FX_WCHAR* psz, - int32_t& iOff, - int32_t iLen, - FDE_CSSSELECTORTYPE eType); void SetType(FDE_CSSSELECTORTYPE eType) { m_eType = eType; } + FDE_CSSSELECTORTYPE m_eType; uint32_t m_dwHash; CFDE_CSSSelector* m_pNext; }; + typedef CFX_ArrayTemplate<CFDE_CSSSelector*> CFDE_CSSSelectorArray; class CFDE_CSSStyleRule : public IFDE_CSSStyleRule, public CFX_Target { public: - CFDE_CSSStyleRule() : m_ppSelector(nullptr), m_iSelectors(0) {} - int32_t CountSelectorLists() const override { return m_iSelectors; } - CFDE_CSSSelector* GetSelectorList(int32_t index) const override { - return m_ppSelector[index]; - } + CFDE_CSSStyleRule(); + + // IFDE_CSSStyleRule + int32_t CountSelectorLists() const override; + CFDE_CSSSelector* GetSelectorList(int32_t index) const override; + CFDE_CSSDeclaration* GetDeclaration() override; - CFDE_CSSDeclaration* GetDeclaration() override { return &m_Declaration; } CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } void SetSelector(IFX_MemoryAllocator* pStaticStore, const CFDE_CSSSelectorArray& list); @@ -64,37 +59,42 @@ class CFDE_CSSStyleRule : public IFDE_CSSStyleRule, public CFX_Target { CFDE_CSSSelector** m_ppSelector; int32_t m_iSelectors; }; + class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target { public: - CFDE_CSSMediaRule(uint32_t dwMediaList) : m_dwMediaList(dwMediaList) {} - ~CFDE_CSSMediaRule(); + explicit CFDE_CSSMediaRule(uint32_t dwMediaList); + ~CFDE_CSSMediaRule() override; - virtual uint32_t GetMediaList() const { return m_dwMediaList; } + // IFDE_CSSMediaRule + uint32_t GetMediaList() const override; + int32_t CountRules() const override; + IFDE_CSSRule* GetRule(int32_t index) override; - virtual int32_t CountRules() const { return m_RuleArray.GetSize(); } - virtual IFDE_CSSRule* GetRule(int32_t index) { - return m_RuleArray.GetAt(index); - } CFDE_CSSRuleArray& GetArray() { return m_RuleArray; } protected: uint32_t m_dwMediaList; CFDE_CSSRuleArray m_RuleArray; }; + class CFDE_CSSFontFaceRule : public IFDE_CSSFontFaceRule, public CFX_Target { public: - CFDE_CSSDeclaration* GetDeclaration() override { return &m_Declaration; } + // IFDE_CSSFontFaceRule + CFDE_CSSDeclaration* GetDeclaration() override; + CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; } protected: CFDE_CSSDeclaration m_Declaration; }; + #define FDE_CSSSWITCHDEFAULTS() \ case FDE_CSSSYNTAXSTATUS_EOS: \ return FDE_CSSSYNTAXSTATUS_EOS; \ case FDE_CSSSYNTAXSTATUS_Error: \ default: \ return FDE_CSSSYNTAXSTATUS_Error; + class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target { public: CFDE_CSSStyleSheet(uint32_t dwMediaList); @@ -105,12 +105,9 @@ class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target { uint32_t Release() override; // IFDE_CSSStyleSheet: - FX_BOOL GetUrl(CFX_WideString& szUrl) override { - szUrl = m_szUrl; - return szUrl.GetLength() > 0; - } - uint32_t GetMediaList() const override { return m_dwMediaList; } - uint16_t GetCodePage() const override { return m_wCodePage; } + FX_BOOL GetUrl(CFX_WideString& szUrl) override; + uint32_t GetMediaList() const override; + uint16_t GetCodePage() const override; int32_t CountRules() const override; IFDE_CSSRule* GetRule(int32_t index) override; diff --git a/xfa/fde/css/fde_csssyntax.h b/xfa/fde/css/fde_csssyntax.h index a4e9249055..294dfcb540 100644 --- a/xfa/fde/css/fde_csssyntax.h +++ b/xfa/fde/css/fde_csssyntax.h @@ -14,7 +14,8 @@ class CFDE_CSSTextBuf : public CFX_Target { public: CFDE_CSSTextBuf(); - ~CFDE_CSSTextBuf(); + ~CFDE_CSSTextBuf() override; + FX_BOOL AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen); FX_BOOL EstimateSize(int32_t iAllocSize); int32_t LoadFromStream(IFX_Stream* pTxtStream, diff --git a/xfa/fde/fde_object.h b/xfa/fde/fde_object.h index 7df5de2638..2af18ec3b7 100644 --- a/xfa/fde/fde_object.h +++ b/xfa/fde/fde_object.h @@ -26,7 +26,7 @@ class CFDE_Brush : public CFX_Target { class CFDE_Pen : public CFX_Target { public: CFDE_Pen() : m_Color(0) {} - ~CFDE_Pen() {} + ~CFDE_Pen() override {} FX_ARGB GetColor() const { return m_Color; } void SetColor(FX_ARGB color) { m_Color = color; } diff --git a/xfa/fde/ifde_txtedtengine.h b/xfa/fde/ifde_txtedtengine.h index 8ecf46e5c8..cf760035cf 100644 --- a/xfa/fde/ifde_txtedtengine.h +++ b/xfa/fde/ifde_txtedtengine.h @@ -82,26 +82,7 @@ enum FDE_TXTEDIT_LINEEND { }; struct FDE_TXTEDTPARAMS { - FDE_TXTEDTPARAMS() - : fPlateWidth(0), - fPlateHeight(0), - nLineCount(0), - dwLayoutStyles(0), - dwAlignment(0), - dwMode(0), - pFont(nullptr), - fFontSize(10.0f), - dwFontColor(0xff000000), - fLineSpace(10.0f), - fTabWidth(36), - bTabEquidistant(FALSE), - wDefChar(0xFEFF), - wLineBreakChar('\n'), - nCharRotation(0), - nLineEnd(0), - nHorzScale(100), - fCharSpace(0), - pEventSink(nullptr) {} + FDE_TXTEDTPARAMS(); FX_FLOAT fPlateWidth; FX_FLOAT fPlateHeight; @@ -131,6 +112,9 @@ enum FDE_TXTEDT_TEXTCHANGE_TYPE { }; struct FDE_TXTEDT_TEXTCHANGE_INFO { + FDE_TXTEDT_TEXTCHANGE_INFO(); + ~FDE_TXTEDT_TEXTCHANGE_INFO(); + int32_t nChangeType; CFX_WideString wsInsert; CFX_WideString wsDelete; diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h index 4959f2bc69..14ca5e19bb 100644 --- a/xfa/fde/tto/fde_textout.h +++ b/xfa/fde/tto/fde_textout.h @@ -10,10 +10,10 @@ #include <memory> #include "core/fxge/include/fx_dib.h" +#include "core/fxge/include/fx_ge.h" #include "xfa/fde/fde_object.h" #include "xfa/fgas/crt/fgas_utils.h" #include "xfa/fgas/font/fgas_font.h" -#include "xfa/fgas/layout/fgas_textbreak.h" #define FDE_TTOSTYLE_Underline 0x0001 #define FDE_TTOSTYLE_Strikeout 0x0002 @@ -42,6 +42,7 @@ class CFDE_RenderDevice; class CFX_TxtBreak; +struct FX_TXTRUN; struct FDE_TTOPIECE { int32_t iStartChar; @@ -55,7 +56,8 @@ class CFDE_TTOLine : public CFX_Target { public: CFDE_TTOLine(); CFDE_TTOLine(const CFDE_TTOLine& ttoLine); - ~CFDE_TTOLine(); + ~CFDE_TTOLine() override; + int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece); int32_t GetSize() const; FDE_TTOPIECE* GetPtrAt(int32_t index); diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp index b71d8b8f4f..da7e0a2fca 100644 --- a/xfa/fde/xml/fde_xml_imp.cpp +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -80,6 +80,14 @@ CFDE_XMLNode::CFDE_XMLNode() m_pPrior(nullptr), m_pNext(nullptr) {} +void CFDE_XMLNode::Release() { + delete this; +} + +FDE_XMLNODETYPE CFDE_XMLNode::GetType() const { + return FDE_XMLNODE_Unknown; +} + CFDE_XMLNode::~CFDE_XMLNode() { DeleteChildren(); } @@ -93,6 +101,7 @@ void CFDE_XMLNode::DeleteChildren() { } m_pChild = nullptr; } + int32_t CFDE_XMLNode::CountChildNodes() const { int32_t iCount = 0; CFDE_XMLNode* pChild = m_pChild; @@ -102,6 +111,7 @@ int32_t CFDE_XMLNode::CountChildNodes() const { } return iCount; } + CFDE_XMLNode* CFDE_XMLNode::GetChildNode(int32_t index) const { CFDE_XMLNode* pChild = m_pChild; while (pChild) { @@ -113,6 +123,7 @@ CFDE_XMLNode* CFDE_XMLNode::GetChildNode(int32_t index) const { } return nullptr; } + int32_t CFDE_XMLNode::GetChildNodeIndex(CFDE_XMLNode* pNode) const { int32_t index = 0; CFDE_XMLNode* pChild = m_pChild; @@ -125,6 +136,7 @@ int32_t CFDE_XMLNode::GetChildNodeIndex(CFDE_XMLNode* pNode) const { } return -1; } + CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath, int32_t iLength, FX_BOOL bQualifiedName) const { @@ -182,6 +194,7 @@ CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath, return pFind; return pFind->GetPath(pStart, iLength, bQualifiedName); } + int32_t CFDE_XMLNode::InsertChildNode(CFDE_XMLNode* pNode, int32_t index) { pNode->m_pParent = this; if (!m_pChild) { @@ -209,6 +222,7 @@ int32_t CFDE_XMLNode::InsertChildNode(CFDE_XMLNode* pNode, int32_t index) { pFind->m_pNext = pNode; return iCount; } + void CFDE_XMLNode::RemoveChildNode(CFDE_XMLNode* pNode) { ASSERT(m_pChild && pNode); if (m_pChild == pNode) { @@ -352,6 +366,7 @@ FX_BOOL CFDE_XMLNode::InsertNodeItem(CFDE_XMLNode::NodeItem eItem, return FALSE; } } + CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(CFDE_XMLNode::NodeItem eItem) { CFDE_XMLNode* pNode = nullptr; switch (eItem) { @@ -372,9 +387,11 @@ CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(CFDE_XMLNode::NodeItem eItem) { } return pNode; } + CFDE_XMLNode* CFDE_XMLNode::Clone(FX_BOOL bRecursive) { return nullptr; } + void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) { CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; switch (pNode->GetType()) { @@ -484,6 +501,7 @@ void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) { break; } } + void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) { if (!m_pChild) { return; @@ -504,6 +522,15 @@ CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget) : m_wsTarget(wsTarget) { ASSERT(m_wsTarget.GetLength() > 0); } + +void CFDE_XMLInstruction::Release() { + delete this; +} + +FDE_XMLNODETYPE CFDE_XMLInstruction::GetType() const { + return FDE_XMLNODE_Instruction; +} + CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) { CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget); if (!pClone) { @@ -516,9 +543,11 @@ CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) { } return pClone; } + int32_t CFDE_XMLInstruction::CountAttributes() const { return m_Attributes.GetSize() / 2; } + FX_BOOL CFDE_XMLInstruction::GetAttribute(int32_t index, CFX_WideString& wsAttriName, CFX_WideString& wsAttriValue) const { @@ -534,6 +563,7 @@ FX_BOOL CFDE_XMLInstruction::GetAttribute(int32_t index, } return FALSE; } + FX_BOOL CFDE_XMLInstruction::HasAttribute(const FX_WCHAR* pwsAttriName) const { int32_t iCount = m_Attributes.GetSize(); for (int32_t i = 0; i < iCount; i += 2) { @@ -543,6 +573,7 @@ FX_BOOL CFDE_XMLInstruction::HasAttribute(const FX_WCHAR* pwsAttriName) const { } return FALSE; } + void CFDE_XMLInstruction::GetString(const FX_WCHAR* pwsAttriName, CFX_WideString& wsAttriValue, const FX_WCHAR* pwsDefValue) const { @@ -555,6 +586,7 @@ void CFDE_XMLInstruction::GetString(const FX_WCHAR* pwsAttriName, } wsAttriValue = pwsDefValue; } + void CFDE_XMLInstruction::SetString(const CFX_WideString& wsAttriName, const CFX_WideString& wsAttriValue) { ASSERT(wsAttriName.GetLength() > 0); @@ -569,6 +601,7 @@ void CFDE_XMLInstruction::SetString(const CFX_WideString& wsAttriName, m_Attributes.Add(wsAttriName); m_Attributes.Add(wsAttriValue); } + int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName, int32_t iDefValue) const { int32_t iCount = m_Attributes.GetSize(); @@ -579,12 +612,14 @@ int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName, } return iDefValue; } + void CFDE_XMLInstruction::SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue) { CFX_WideString wsValue; wsValue.Format(L"%d", iAttriValue); SetString(pwsAttriName, wsValue); } + FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fDefValue) const { int32_t iCount = m_Attributes.GetSize(); @@ -595,12 +630,14 @@ FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName, } return fDefValue; } + void CFDE_XMLInstruction::SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue) { CFX_WideString wsValue; wsValue.Format(L"%f", fAttriValue); SetString(pwsAttriName, wsValue); } + void CFDE_XMLInstruction::RemoveAttribute(const FX_WCHAR* pwsAttriName) { int32_t iCount = m_Attributes.GetSize(); for (int32_t i = 0; i < iCount; i += 2) { @@ -611,9 +648,11 @@ void CFDE_XMLInstruction::RemoveAttribute(const FX_WCHAR* pwsAttriName) { } } } + int32_t CFDE_XMLInstruction::CountData() const { return m_TargetData.GetSize(); } + FX_BOOL CFDE_XMLInstruction::GetData(int32_t index, CFX_WideString& wsData) const { if (index < 0 || index >= m_TargetData.GetSize()) { @@ -622,20 +661,34 @@ FX_BOOL CFDE_XMLInstruction::GetData(int32_t index, wsData = m_TargetData[index]; return TRUE; } + void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) { m_TargetData.Add(wsData); } + void CFDE_XMLInstruction::RemoveData(int32_t index) { m_TargetData.RemoveAt(index); } +CFDE_XMLInstruction::~CFDE_XMLInstruction() {} + CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag) : CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() { ASSERT(m_wsTag.GetLength() > 0); } + CFDE_XMLElement::~CFDE_XMLElement() { m_Attributes.RemoveAll(); } + +void CFDE_XMLElement::Release() { + delete this; +} + +FDE_XMLNODETYPE CFDE_XMLElement::GetType() const { + return FDE_XMLNODE_Element; +} + CFDE_XMLNode* CFDE_XMLElement::Clone(FX_BOOL bRecursive) { CFDE_XMLElement* pClone = new CFDE_XMLElement(m_wsTag); if (!pClone) { @@ -661,9 +714,11 @@ CFDE_XMLNode* CFDE_XMLElement::Clone(FX_BOOL bRecursive) { } return pClone; } + void CFDE_XMLElement::GetTagName(CFX_WideString& wsTag) const { wsTag = m_wsTag; } + void CFDE_XMLElement::GetLocalTagName(CFX_WideString& wsTag) const { FX_STRSIZE iFind = m_wsTag.Find(L':', 0); if (iFind < 0) { @@ -672,6 +727,7 @@ void CFDE_XMLElement::GetLocalTagName(CFX_WideString& wsTag) const { wsTag = m_wsTag.Right(m_wsTag.GetLength() - iFind - 1); } } + void CFDE_XMLElement::GetNamespacePrefix(CFX_WideString& wsPrefix) const { FX_STRSIZE iFind = m_wsTag.Find(L':', 0); if (iFind < 0) { @@ -680,6 +736,7 @@ void CFDE_XMLElement::GetNamespacePrefix(CFX_WideString& wsPrefix) const { wsPrefix = m_wsTag.Left(iFind); } } + void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const { CFX_WideString wsAttri(L"xmlns"), wsPrefix; GetNamespacePrefix(wsPrefix); @@ -702,9 +759,11 @@ void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const { break; } } + int32_t CFDE_XMLElement::CountAttributes() const { return m_Attributes.GetSize() / 2; } + FX_BOOL CFDE_XMLElement::GetAttribute(int32_t index, CFX_WideString& wsAttriName, CFX_WideString& wsAttriValue) const { @@ -720,6 +779,7 @@ FX_BOOL CFDE_XMLElement::GetAttribute(int32_t index, } return FALSE; } + FX_BOOL CFDE_XMLElement::HasAttribute(const FX_WCHAR* pwsAttriName) const { int32_t iCount = m_Attributes.GetSize(); for (int32_t i = 0; i < iCount; i += 2) { @@ -729,6 +789,7 @@ FX_BOOL CFDE_XMLElement::HasAttribute(const FX_WCHAR* pwsAttriName) const { } return FALSE; } + void CFDE_XMLElement::GetString(const FX_WCHAR* pwsAttriName, CFX_WideString& wsAttriValue, const FX_WCHAR* pwsDefValue) const { @@ -741,6 +802,7 @@ void CFDE_XMLElement::GetString(const FX_WCHAR* pwsAttriName, } wsAttriValue = pwsDefValue; } + void CFDE_XMLElement::SetString(const CFX_WideString& wsAttriName, const CFX_WideString& wsAttriValue) { ASSERT(wsAttriName.GetLength() > 0); @@ -755,6 +817,7 @@ void CFDE_XMLElement::SetString(const CFX_WideString& wsAttriName, m_Attributes.Add(wsAttriName); m_Attributes.Add(wsAttriValue); } + int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName, int32_t iDefValue) const { int32_t iCount = m_Attributes.GetSize(); @@ -765,12 +828,14 @@ int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName, } return iDefValue; } + void CFDE_XMLElement::SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue) { CFX_WideString wsValue; wsValue.Format(L"%d", iAttriValue); SetString(pwsAttriName, wsValue); } + FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fDefValue) const { int32_t iCount = m_Attributes.GetSize(); @@ -781,12 +846,14 @@ FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, } return fDefValue; } + void CFDE_XMLElement::SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue) { CFX_WideString wsValue; wsValue.Format(L"%f", fAttriValue); SetString(pwsAttriName, wsValue); } + void CFDE_XMLElement::RemoveAttribute(const FX_WCHAR* pwsAttriName) { int32_t iCount = m_Attributes.GetSize(); for (int32_t i = 0; i < iCount; i += 2) { @@ -797,6 +864,7 @@ void CFDE_XMLElement::RemoveAttribute(const FX_WCHAR* pwsAttriName) { } } } + void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const { CFX_WideTextBuf buffer; CFDE_XMLNode* pChild = m_pChild; @@ -815,35 +883,61 @@ void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const { } wsText = buffer.AsStringC(); } + void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { if (wsText.GetLength() < 1) { return; } InsertChildNode(new CFDE_XMLText(wsText)); } + CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText) : CFDE_XMLNode(), m_wsText(wsText) {} + +void CFDE_XMLText::Release() { + delete this; +} + +FDE_XMLNODETYPE CFDE_XMLText::GetType() const { + return FDE_XMLNODE_Text; +} + CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) { CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText); return pClone; } +CFDE_XMLText::~CFDE_XMLText() {} + CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData) : CFDE_XMLDeclaration(), m_wsCharData(wsCData) {} + +void CFDE_XMLCharData::Release() { + delete this; +} + +FDE_XMLNODETYPE CFDE_XMLCharData::GetType() const { + return FDE_XMLNODE_CharData; +} + CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) { CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData); return pClone; } +CFDE_XMLCharData::~CFDE_XMLCharData() {} + CFDE_XMLDoc::CFDE_XMLDoc() : m_pRoot(nullptr), m_pSyntaxParser(nullptr), m_pXMLParser(nullptr) { Reset(TRUE); CFDE_XMLInstruction* pXML = new CFDE_XMLInstruction(L"xml"); m_pRoot->InsertChildNode(pXML); } + CFDE_XMLDoc::~CFDE_XMLDoc() { Reset(FALSE); } + void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { m_iStatus = 0; m_pStream = nullptr; @@ -860,6 +954,7 @@ void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { } ReleaseParser(); } + void CFDE_XMLDoc::ReleaseParser() { if (m_pXMLParser) { m_pXMLParser->Release(); @@ -879,14 +974,17 @@ FX_BOOL CFDE_XMLDoc::LoadXML(CFDE_XMLParser* pXMLParser) { m_pXMLParser = pXMLParser; return !!m_pXMLParser; } + int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { if (m_iStatus >= 100) return m_iStatus; return m_iStatus = m_pXMLParser->DoParser(pPause); } + void CFDE_XMLDoc::CloseXML() { ReleaseParser(); } + void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) { CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; switch (pNode->GetType()) { @@ -996,6 +1094,7 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) { break; } } + void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) { if (!pXMLStream || pXMLStream == m_pStream) { m_pStream->Seek(FX_STREAMSEEK_Begin, 0); @@ -1028,9 +1127,11 @@ CFDE_BlockBuffer::CFDE_BlockBuffer(int32_t iAllocStep) m_iBufferSize(0), m_iAllocStep(iAllocStep), m_iStartPosition(0) {} + CFDE_BlockBuffer::~CFDE_BlockBuffer() { ClearBuffer(); } + FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) { iIndexInBlock = 0; if (!m_BlockArray.GetSize()) { @@ -1046,6 +1147,7 @@ FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) { iIndexInBlock = iRealIndex % m_iAllocStep; return m_BlockArray[iRealIndex / m_iAllocStep]; } + FX_BOOL CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) { ClearBuffer(); int32_t iNumOfBlock = (iBufferSize - 1) / m_iAllocStep + 1; @@ -1055,6 +1157,7 @@ FX_BOOL CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) { m_iBufferSize = iNumOfBlock * m_iAllocStep; return TRUE; } + void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) { if (iIndex < 0) { return; @@ -1077,6 +1180,7 @@ void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) { m_iDataLength = iIndex + 1; } } + int32_t CFDE_BlockBuffer::DeleteTextChars(int32_t iCount, FX_BOOL bDirection) { if (iCount <= 0) { return m_iDataLength; @@ -1093,6 +1197,7 @@ int32_t CFDE_BlockBuffer::DeleteTextChars(int32_t iCount, FX_BOOL bDirection) { } return m_iDataLength; } + void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData, int32_t iStart, int32_t iLength) const { @@ -1135,6 +1240,7 @@ void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData, } wsTextData.ReleaseBuffer(iLength); } + void CFDE_BlockBuffer::TextDataIndex2BufIndex(const int32_t iIndex, int32_t& iBlockIndex, int32_t& iInnerIndex) const { @@ -1143,6 +1249,7 @@ void CFDE_BlockBuffer::TextDataIndex2BufIndex(const int32_t iIndex, iBlockIndex = iRealIndex / m_iAllocStep; iInnerIndex = iRealIndex % m_iAllocStep; } + void CFDE_BlockBuffer::ClearBuffer() { m_iBufferSize = 0; int32_t iSize = m_BlockArray.GetSize(); @@ -1179,6 +1286,7 @@ CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser() m_CurNode.iNodeNum = -1; m_CurNode.eNodeType = FDE_XMLNODE_Unknown; } + void CFDE_XMLSyntaxParser::Init(IFX_Stream* pStream, int32_t iXMLPlaneSize, int32_t iTextDataSize) { @@ -1720,6 +1828,7 @@ static int32_t FX_GetUTF8EncodeLength(const FX_WCHAR* pSrc, int32_t iSrcLen) { } return iDstNum; } + FX_FILESIZE CFDE_XMLSyntaxParser::GetCurrentBinaryPos() const { if (!m_pStream) return 0; diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h index b977d693d8..ba75f6b409 100644 --- a/xfa/fde/xml/fde_xml_imp.h +++ b/xfa/fde/xml/fde_xml_imp.h @@ -40,10 +40,10 @@ class CFDE_XMLNode : public CFX_Target { }; CFDE_XMLNode(); - virtual ~CFDE_XMLNode(); + ~CFDE_XMLNode() override; - virtual void Release() { delete this; } - virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; } + virtual void Release(); + virtual FDE_XMLNODETYPE GetType() const; virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); int32_t CountChildNodes() const; @@ -73,12 +73,12 @@ class CFDE_XMLNode : public CFX_Target { class CFDE_XMLInstruction : public CFDE_XMLNode { public: - CFDE_XMLInstruction(const CFX_WideString& wsTarget); - ~CFDE_XMLInstruction() override {} + explicit CFDE_XMLInstruction(const CFX_WideString& wsTarget); + ~CFDE_XMLInstruction() override; // CFDE_XMLNode - void Release() override { delete this; } - FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Instruction; } + void Release() override; + FDE_XMLNODETYPE GetType() const override; CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; void GetTargetName(CFX_WideString& wsTarget) const { wsTarget = m_wsTarget; } @@ -109,12 +109,12 @@ class CFDE_XMLInstruction : public CFDE_XMLNode { class CFDE_XMLElement : public CFDE_XMLNode { public: - CFDE_XMLElement(const CFX_WideString& wsTag); + explicit CFDE_XMLElement(const CFX_WideString& wsTag); ~CFDE_XMLElement() override; // CFDE_XMLNode - void Release() override { delete this; } - FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Element; } + void Release() override; + FDE_XMLNODETYPE GetType() const override; CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; void GetTagName(CFX_WideString& wsTag) const; @@ -151,12 +151,12 @@ class CFDE_XMLElement : public CFDE_XMLNode { class CFDE_XMLText : public CFDE_XMLNode { public: - CFDE_XMLText(const CFX_WideString& wsText); - ~CFDE_XMLText() override {} + explicit CFDE_XMLText(const CFX_WideString& wsText); + ~CFDE_XMLText() override; // CFDE_XMLNode - void Release() override { delete this; } - FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Text; } + void Release() override; + FDE_XMLNODETYPE GetType() const override; CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; void GetText(CFX_WideString& wsText) const { wsText = m_wsText; } @@ -167,17 +167,17 @@ class CFDE_XMLText : public CFDE_XMLNode { class CFDE_XMLDeclaration : public CFDE_XMLNode { public: - CFDE_XMLDeclaration() : CFDE_XMLNode() {} + CFDE_XMLDeclaration() {} ~CFDE_XMLDeclaration() override {} }; class CFDE_XMLCharData : public CFDE_XMLDeclaration { public: - CFDE_XMLCharData(const CFX_WideString& wsCData); - ~CFDE_XMLCharData() override {} + explicit CFDE_XMLCharData(const CFX_WideString& wsCData); + ~CFDE_XMLCharData() override; - void Release() override { delete this; } - FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_CharData; } + void Release() override; + FDE_XMLNODETYPE GetType() const override; CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; void GetCharData(CFX_WideString& wsCharData) const { @@ -222,8 +222,8 @@ class CFDE_XMLParser { class CFDE_BlockBuffer : public CFX_Target { public: - CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); - ~CFDE_BlockBuffer(); + explicit CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); + ~CFDE_BlockBuffer() override; FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024); FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } @@ -259,7 +259,7 @@ class CFDE_BlockBuffer : public CFX_Target { class CFDE_XMLSyntaxParser : public CFX_Target { public: CFDE_XMLSyntaxParser(); - ~CFDE_XMLSyntaxParser(); + ~CFDE_XMLSyntaxParser() override; void Release() { delete this; } void Init(IFX_Stream* pStream, |