diff options
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffapp.cpp | 59 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffdocview.cpp | 57 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffwidget.cpp | 49 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fwltheme.cpp | 69 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fwltheme.h | 39 | ||||
-rw-r--r-- | xfa/fxfa/include/xfa_ffapp.h | 34 | ||||
-rw-r--r-- | xfa/fxfa/include/xfa_ffdocview.h | 32 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_resolveprocessor.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_resolveprocessor.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_locale.cpp | 44 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_locale.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_localemgr.cpp | 15 |
12 files changed, 223 insertions, 193 deletions
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp index 22989b8b3e..18e2d76552 100644 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -37,6 +37,7 @@ FX_FILESIZE CXFA_FileRead::GetSize() { } return dwSize; } + FX_BOOL CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { @@ -72,47 +73,29 @@ void CXFA_FileRead::Release() { } CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider) - : m_pDocHandler(nullptr), - m_pFWLTheme(nullptr), - m_pProvider(pProvider), - m_pFontMgr(nullptr), -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - m_pFontSource(nullptr), -#endif - m_pAdapterWidgetMgr(nullptr), + : m_pProvider(pProvider), m_pWidgetMgrDelegate(nullptr), - m_pFDEFontMgr(nullptr) { - m_pFWLApp = IFWL_App::Create(this); - FWL_SetApp(m_pFWLApp); + m_pFWLApp(IFWL_App::Create(this)) { + FWL_SetApp(m_pFWLApp.get()); m_pFWLApp->Initialize(); CXFA_TimeZoneProvider::Create(); } CXFA_FFApp::~CXFA_FFApp() { - delete m_pDocHandler; if (m_pFWLApp) { m_pFWLApp->Finalize(); m_pFWLApp->Release(); - delete m_pFWLApp; } - delete m_pFWLTheme; - delete m_pAdapterWidgetMgr; CXFA_TimeZoneProvider::Destroy(); - delete m_pFontMgr; -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (m_pFontSource) - m_pFontSource->Release(); -#endif - if (m_pFDEFontMgr) - m_pFDEFontMgr->Release(); } CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { if (!m_pDocHandler) - m_pDocHandler = new CXFA_FFDocHandler; - return m_pDocHandler; + m_pDocHandler.reset(new CXFA_FFDocHandler); + return m_pDocHandler.get(); } + CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, IFX_FileRead* pStream, FX_BOOL bTakeOverFile) { @@ -133,12 +116,12 @@ CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, void CXFA_FFApp::SetDefaultFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr) { if (!m_pFontMgr) - m_pFontMgr = new CXFA_FontMgr(); + m_pFontMgr.reset(new CXFA_FontMgr()); m_pFontMgr->SetDefFontMgr(std::move(pFontMgr)); } -CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() { - return m_pFontMgr; +CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() const { + return m_pFontMgr.get(); } IFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() { @@ -146,28 +129,30 @@ IFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ m_pFDEFontMgr = IFGAS_FontMgr::Create(FX_GetDefFontEnumerator()); #else - m_pFontSource = new CFX_FontSourceEnum_File; - m_pFDEFontMgr = IFGAS_FontMgr::Create(m_pFontSource); + m_pFontSource.reset(new CFX_FontSourceEnum_File); + m_pFDEFontMgr = IFGAS_FontMgr::Create(m_pFontSource.get()); #endif } - return m_pFDEFontMgr; + return m_pFDEFontMgr.get(); } + CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() { - if (!m_pFWLTheme) { - m_pFWLTheme = new CXFA_FWLTheme(this); - } - return m_pFWLTheme; + if (!m_pFWLTheme) + m_pFWLTheme.reset(new CXFA_FWLTheme(this)); + return m_pFWLTheme.get(); } + CXFA_FWLAdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr( CFWL_WidgetMgrDelegate* pDelegate) { if (!m_pAdapterWidgetMgr) { - m_pAdapterWidgetMgr = new CXFA_FWLAdapterWidgetMgr; + m_pAdapterWidgetMgr.reset(new CXFA_FWLAdapterWidgetMgr); pDelegate->OnSetCapability(FWL_WGTMGR_DisableThread | FWL_WGTMGR_DisableForm); m_pWidgetMgrDelegate = pDelegate; } - return m_pAdapterWidgetMgr; + return m_pAdapterWidgetMgr.get(); } -IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() { + +IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() const { return m_pProvider->GetTimerMgr(); } diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index c0b42412ea..3609e55cba 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -56,7 +56,6 @@ CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) m_pListFocusWidget(nullptr), m_bInLayoutStatus(FALSE), m_pDoc(pDoc), - m_pWidgetHandler(nullptr), m_pXFADocLayout(nullptr), m_pFocusAcc(nullptr), m_pFocusWidget(nullptr), @@ -66,13 +65,14 @@ CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc) CXFA_FFDocView::~CXFA_FFDocView() { DestroyDocView(); - delete m_pWidgetHandler; } void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { RunBindItems(); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize, FALSE, TRUE, + nullptr); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange, FALSE, TRUE, + nullptr); } int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; @@ -91,7 +91,7 @@ int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { InitLayout(pRootItem); InitCalculate(pRootItem); InitValidate(pRootItem); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, TRUE); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, TRUE, TRUE, nullptr); m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; return iStatus; } @@ -124,13 +124,17 @@ void CXFA_FFDocView::StopLayout() { InitLayout(pPageSetNode); InitCalculate(pPageSetNode); InitValidate(pPageSetNode); - ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, TRUE); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady); + ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, TRUE, TRUE, + nullptr); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, FALSE, TRUE, + nullptr); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady, FALSE, TRUE, + nullptr); RunCalculateWidgets(); RunValidate(); if (RunLayout()) { - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, FALSE, TRUE, + nullptr); } m_CalculateAccs.RemoveAll(); if (m_pFocusAcc && !m_pFocusWidget) { @@ -177,7 +181,7 @@ void CXFA_FFDocView::UpdateDocView() { CXFA_Node* pNode = m_NewAddedNodes[i]; InitCalculate(pNode); InitValidate(pNode); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE, TRUE, nullptr); } m_NewAddedNodes.RemoveAll(); RunSubformIndexChange(); @@ -303,14 +307,15 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, } pNode = pRootItem->GetChild(0, XFA_Element::Subform); } - ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady); + ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady, + TRUE, nullptr); return XFA_EVENTERROR_Success; } CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() { if (!m_pWidgetHandler) { - m_pWidgetHandler = new CXFA_FFWidgetHandler(this); + m_pWidgetHandler.reset(new CXFA_FFWidgetHandler(this)); } - return m_pWidgetHandler; + return m_pWidgetHandler.get(); } CXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator( @@ -607,7 +612,8 @@ void CXFA_FFDocView::RunDocClose() { if (!pRootItem) { return; } - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, FALSE, TRUE, + nullptr); } void CXFA_FFDocView::DestroyDocView() { ClearInvalidateList(); @@ -685,14 +691,15 @@ void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { m_ValidateAccs.Add(pWidget); } FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, FALSE, TRUE, + nullptr); return TRUE; } FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { return FALSE; } - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, FALSE, TRUE, nullptr); m_ValidateAccs.RemoveAll(); return TRUE; } @@ -717,7 +724,8 @@ FX_BOOL CXFA_FFDocView::RunEventLayoutReady() { if (!pRootItem) { return FALSE; } - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, FALSE, TRUE, + nullptr); RunLayout(); return TRUE; } @@ -803,21 +811,24 @@ CXFA_Node* CXFA_FFDocView::GetRootSubform() { CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot) - : m_ContentIterator(pTravelRoot) { - m_pDocView = pDocView; - m_pCurWidgetAcc = nullptr; -} + : m_ContentIterator(pTravelRoot), + m_pDocView(pDocView), + m_pCurWidgetAcc(nullptr) {} + CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator() {} void CXFA_WidgetAccIterator::Reset() { m_pCurWidgetAcc = nullptr; m_ContentIterator.Reset(); } + CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToFirst() { return nullptr; } + CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToLast() { return nullptr; } + CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() { CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext() : m_ContentIterator.GetCurrent(); @@ -829,15 +840,19 @@ CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() { } return nullptr; } + CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToPrevious() { return nullptr; } + CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { return nullptr; } + FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { return FALSE; } + void CXFA_WidgetAccIterator::SkipTree() { m_ContentIterator.SkipChildrenAndMoveToNext(); m_pCurWidgetAcc = nullptr; diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index ed42aa4825..446fcd6303 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -564,11 +564,20 @@ class CXFA_ImageRenderer { FX_BOOL Continue(IFX_Pause* pPause); protected: + FX_BOOL StartDIBSource(); + void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, + int left, + int top, + FX_ARGB mask_argb, + int bitmap_alpha, + int blend_mode, + int Transparency); + CFX_RenderDevice* m_pDevice; int m_Status; CFX_Matrix m_ImageMatrix; CFX_DIBSource* m_pDIBSource; - CFX_DIBitmap* m_pCloneConvert; + std::unique_ptr<CFX_DIBitmap> m_pCloneConvert; int m_BitmapAlpha; FX_ARGB m_FillArgb; uint32_t m_Flags; @@ -577,31 +586,21 @@ class CXFA_ImageRenderer { int32_t m_BlendType; FX_BOOL m_Result; FX_BOOL m_bPrint; - FX_BOOL StartDIBSource(); - void CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, - int left, - int top, - FX_ARGB mask_argb, - int bitmap_alpha, - int blend_mode, - int Transparency); }; -CXFA_ImageRenderer::CXFA_ImageRenderer() { - m_pDevice = nullptr; - m_Status = 0; - m_pDIBSource = nullptr; - m_pCloneConvert = nullptr; - m_BitmapAlpha = 255; - m_FillArgb = 0; - m_Flags = 0; - m_DeviceHandle = nullptr; - m_BlendType = FXDIB_BLEND_NORMAL; - m_Result = TRUE; - m_bPrint = FALSE; -} + +CXFA_ImageRenderer::CXFA_ImageRenderer() + : m_pDevice(nullptr), + m_Status(0), + m_pDIBSource(nullptr), + m_BitmapAlpha(255), + m_FillArgb(0), + m_Flags(0), + m_DeviceHandle(nullptr), + m_BlendType(FXDIB_BLEND_NORMAL), + m_Result(TRUE), + m_bPrint(FALSE) {} CXFA_ImageRenderer::~CXFA_ImageRenderer() { - delete m_pCloneConvert; if (m_DeviceHandle) m_pDevice->CancelDIBits(m_DeviceHandle); } @@ -647,12 +646,12 @@ FX_BOOL CXFA_ImageRenderer::StartDIBSource() { if (m_pDIBSource->HasAlpha() && !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE) && !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { - m_pCloneConvert = m_pDIBSource->CloneConvert(FXDIB_Rgb); + m_pCloneConvert.reset(m_pDIBSource->CloneConvert(FXDIB_Rgb)); if (!m_pCloneConvert) { m_Result = FALSE; return FALSE; } - pDib = m_pCloneConvert; + pDib = m_pCloneConvert.get(); } FX_RECT clip_box = m_pDevice->GetClipBox(); clip_box.Intersect(image_rect); diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index 41d8fecb36..8e1b23c05d 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -43,38 +43,30 @@ CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) { : nullptr; } -CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) { - m_dwCapacity = 0; - m_fCapacity = 0; - m_pCalendarFont = nullptr; - m_Rect.Set(0, 0, 0, 0); - m_pCheckBoxTP = new CXFA_FWLCheckBoxTP; - m_pListBoxTP = new CFWL_ListBoxTP; - m_pPictureBoxTP = new CFWL_PictureBoxTP; - m_pSrollBarTP = new CFWL_ScrollBarTP; - m_pEditTP = new CXFA_FWLEditTP; - m_pComboBoxTP = new CFWL_ComboBoxTP; - m_pMonthCalendarTP = new CFWL_MonthCalendarTP; - m_pDateTimePickerTP = new CFWL_DateTimePickerTP; - m_pPushButtonTP = new CFWL_PushButtonTP; - m_pCaretTP = new CFWL_CaretTP; - m_pBarcodeTP = new CFWL_BarcodeTP; +CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) + : m_pCheckBoxTP(new CXFA_FWLCheckBoxTP), + m_pListBoxTP(new CFWL_ListBoxTP), + m_pPictureBoxTP(new CFWL_PictureBoxTP), + m_pSrollBarTP(new CFWL_ScrollBarTP), + m_pEditTP(new CXFA_FWLEditTP), + m_pComboBoxTP(new CFWL_ComboBoxTP), + m_pMonthCalendarTP(new CFWL_MonthCalendarTP), + m_pDateTimePickerTP(new CFWL_DateTimePickerTP), + m_pPushButtonTP(new CFWL_PushButtonTP), + m_pCaretTP(new CFWL_CaretTP), + m_pBarcodeTP(new CFWL_BarcodeTP), + m_fCapacity(0.0f), + m_dwCapacity(0), + m_pCalendarFont(nullptr), + m_pApp(pApp) { + m_Rect.Reset(); Initialize(); } + CXFA_FWLTheme::~CXFA_FWLTheme() { Finalize(); - delete m_pCheckBoxTP; - delete m_pListBoxTP; - delete m_pPictureBoxTP; - delete m_pSrollBarTP; - delete m_pEditTP; - delete m_pComboBoxTP; - delete m_pMonthCalendarTP; - delete m_pDateTimePickerTP; - delete m_pPushButtonTP; - delete m_pCaretTP; - delete m_pBarcodeTP; } + FWL_Error CXFA_FWLTheme::Initialize() { m_pTextOut.reset(new CFDE_TextOut); for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); @@ -96,6 +88,7 @@ FWL_Error CXFA_FWLTheme::Initialize() { FWLTHEME_Init(); return FWL_Error::Succeeded; } + FWL_Error CXFA_FWLTheme::Finalize() { m_pTextOut.reset(); if (m_pCalendarFont) { @@ -406,27 +399,27 @@ FX_BOOL CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) { switch (pWidget->GetClassID()) { case FWL_Type::CheckBox: - return m_pCheckBoxTP; + return m_pCheckBoxTP.get(); case FWL_Type::ListBox: - return m_pListBoxTP; + return m_pListBoxTP.get(); case FWL_Type::PictureBox: - return m_pPictureBoxTP; + return m_pPictureBoxTP.get(); case FWL_Type::ScrollBar: - return m_pSrollBarTP; + return m_pSrollBarTP.get(); case FWL_Type::Edit: - return m_pEditTP; + return m_pEditTP.get(); case FWL_Type::ComboBox: - return m_pComboBoxTP; + return m_pComboBoxTP.get(); case FWL_Type::MonthCalendar: - return m_pMonthCalendarTP; + return m_pMonthCalendarTP.get(); case FWL_Type::DateTimePicker: - return m_pDateTimePickerTP; + return m_pDateTimePickerTP.get(); case FWL_Type::PushButton: - return m_pPushButtonTP; + return m_pPushButtonTP.get(); case FWL_Type::Caret: - return m_pCaretTP; + return m_pCaretTP.get(); case FWL_Type::Barcode: - return m_pBarcodeTP; + return m_pBarcodeTP.get(); default: return nullptr; } diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h index 63a4247337..81f33b2944 100644 --- a/xfa/fxfa/app/xfa_fwltheme.h +++ b/xfa/fxfa/app/xfa_fwltheme.h @@ -29,13 +29,6 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider { CXFA_FWLTheme(CXFA_FFApp* pApp); ~CXFA_FWLTheme() override; - FWL_Error GetClassName(CFX_WideString& wsClass) const { - return FWL_Error::Succeeded; - } - uint32_t GetHashCode() const { return 0; } - FWL_Error Initialize(); - FWL_Error Finalize(); - // IFWL_ThemeProvider: bool IsValidWidget(IFWL_Widget* pWidget) override; uint32_t GetThemeID(IFWL_Widget* pWidget) override; @@ -56,30 +49,37 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider { FX_FLOAT fy) override; FX_BOOL CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) override; + FWL_Error GetClassName(CFX_WideString& wsClass) const { + return FWL_Error::Succeeded; + } + uint32_t GetHashCode() const { return 0; } + FWL_Error Initialize(); + FWL_Error Finalize(); FWL_Error GetPartRect(CFWL_ThemePart* pThemePart); protected: CFWL_WidgetTP* GetTheme(IFWL_Widget* pWidget); - CFWL_CheckBoxTP* m_pCheckBoxTP; - CFWL_ListBoxTP* m_pListBoxTP; - CFWL_PictureBoxTP* m_pPictureBoxTP; - CFWL_ScrollBarTP* m_pSrollBarTP; - CFWL_EditTP* m_pEditTP; - CFWL_ComboBoxTP* m_pComboBoxTP; - CFWL_MonthCalendarTP* m_pMonthCalendarTP; - CFWL_DateTimePickerTP* m_pDateTimePickerTP; - CFWL_PushButtonTP* m_pPushButtonTP; - CFWL_CaretTP* m_pCaretTP; - CFWL_BarcodeTP* m_pBarcodeTP; + std::unique_ptr<CFWL_CheckBoxTP> m_pCheckBoxTP; + std::unique_ptr<CFWL_ListBoxTP> m_pListBoxTP; + std::unique_ptr<CFWL_PictureBoxTP> m_pPictureBoxTP; + std::unique_ptr<CFWL_ScrollBarTP> m_pSrollBarTP; + std::unique_ptr<CFWL_EditTP> m_pEditTP; + std::unique_ptr<CFWL_ComboBoxTP> m_pComboBoxTP; + std::unique_ptr<CFWL_MonthCalendarTP> m_pMonthCalendarTP; + std::unique_ptr<CFWL_DateTimePickerTP> m_pDateTimePickerTP; + std::unique_ptr<CFWL_PushButtonTP> m_pPushButtonTP; + std::unique_ptr<CFWL_CaretTP> m_pCaretTP; + std::unique_ptr<CFWL_BarcodeTP> m_pBarcodeTP; std::unique_ptr<CFDE_TextOut> m_pTextOut; FX_FLOAT m_fCapacity; uint32_t m_dwCapacity; CFGAS_GEFont* m_pCalendarFont; CFX_WideString m_wsResource; - CXFA_FFApp* m_pApp; + CXFA_FFApp* const m_pApp; CFX_RectF m_Rect; CFX_SizeF m_SizeAboveBelow; }; + class CXFA_FWLCheckBoxTP : public CFWL_CheckBoxTP { public: CXFA_FWLCheckBoxTP(); @@ -94,6 +94,7 @@ class CXFA_FWLCheckBoxTP : public CFWL_CheckBoxTP { int32_t iState, CFX_Matrix* pMatrix); }; + class CXFA_FWLEditTP : public CFWL_EditTP { public: CXFA_FWLEditTP(); diff --git a/xfa/fxfa/include/xfa_ffapp.h b/xfa/fxfa/include/xfa_ffapp.h index 5780859a92..bc0d6dfb38 100644 --- a/xfa/fxfa/include/xfa_ffapp.h +++ b/xfa/fxfa/include/xfa_ffapp.h @@ -7,6 +7,8 @@ #ifndef XFA_FXFA_INCLUDE_XFA_FFAPP_H_ #define XFA_FXFA_INCLUDE_XFA_FFAPP_H_ +#include <memory> + #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" #include "xfa/fgas/font/fgas_font.h" @@ -40,36 +42,38 @@ class CXFA_FFApp { explicit CXFA_FFApp(IXFA_AppProvider* pProvider); ~CXFA_FFApp(); - CXFA_FFDocHandler* GetDocHandler(); CXFA_FFDoc* CreateDoc(IXFA_DocProvider* pProvider, IFX_FileRead* pStream, FX_BOOL bTakeOverFile); CXFA_FFDoc* CreateDoc(IXFA_DocProvider* pProvider, CPDF_Document* pPDFDoc); - IXFA_AppProvider* GetAppProvider() { return m_pProvider; } void SetDefaultFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr); + CXFA_FFDocHandler* GetDocHandler(); CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(CFWL_WidgetMgrDelegate* pDelegate); - IFWL_AdapterTimerMgr* GetTimerMgr(); - - CXFA_FontMgr* GetXFAFontMgr(); IFGAS_FontMgr* GetFDEFontMgr(); CXFA_FWLTheme* GetFWLTheme(); - CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() { + + IXFA_AppProvider* GetAppProvider() const { return m_pProvider; } + IFWL_AdapterTimerMgr* GetTimerMgr() const; + CXFA_FontMgr* GetXFAFontMgr() const; + CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() const { return m_pWidgetMgrDelegate; } protected: - CXFA_FFDocHandler* m_pDocHandler; - IFWL_App* m_pFWLApp; - CXFA_FWLTheme* m_pFWLTheme; - IXFA_AppProvider* m_pProvider; - CXFA_FontMgr* m_pFontMgr; + std::unique_ptr<CXFA_FFDocHandler> m_pDocHandler; + IXFA_AppProvider* const m_pProvider; + std::unique_ptr<CXFA_FontMgr> m_pFontMgr; #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - CFX_FontSourceEnum_File* m_pFontSource; + std::unique_ptr<CFX_FontSourceEnum_File> m_pFontSource; #endif - CXFA_FWLAdapterWidgetMgr* m_pAdapterWidgetMgr; - CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; - IFGAS_FontMgr* m_pFDEFontMgr; + std::unique_ptr<CXFA_FWLAdapterWidgetMgr> m_pAdapterWidgetMgr; + CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; // not owned. + std::unique_ptr<IFGAS_FontMgr> m_pFDEFontMgr; + // |m_pFWLApp| has to be released first, then |m_pFWLTheme| since the former + // may refers to theme manager and the latter refers to font manager. + std::unique_ptr<CXFA_FWLTheme> m_pFWLTheme; + std::unique_ptr<IFWL_App> m_pFWLApp; }; #endif // XFA_FXFA_INCLUDE_XFA_FFAPP_H_ diff --git a/xfa/fxfa/include/xfa_ffdocview.h b/xfa/fxfa/include/xfa_ffdocview.h index bc2373d155..8372981cfd 100644 --- a/xfa/fxfa/include/xfa_ffdocview.h +++ b/xfa/fxfa/include/xfa_ffdocview.h @@ -42,16 +42,16 @@ class CXFA_FFDocView { CXFA_FFDoc* GetDoc() { return m_pDoc; } int32_t StartLayout(int32_t iStartPage = 0); - int32_t DoLayout(IFX_Pause* pPause = nullptr); + int32_t DoLayout(IFX_Pause* pPause); void StopLayout(); int32_t GetLayoutStatus(); void UpdateDocView(); int32_t CountPageViews(); CXFA_FFPageView* GetPageView(int32_t nIndex); - void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc = nullptr); + void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc); int32_t ProcessWidgetEvent(CXFA_EventParam* pParam, - CXFA_WidgetAcc* pWidgetAcc = nullptr); + CXFA_WidgetAcc* pWidgetAcc); CXFA_FFWidgetHandler* GetWidgetHandler(); CXFA_WidgetAccIterator* CreateWidgetAccIterator( XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder); @@ -59,9 +59,9 @@ class CXFA_FFDocView { void KillFocus(); FX_BOOL SetFocus(CXFA_FFWidget* hWidget); CXFA_FFWidget* GetWidgetByName(const CFX_WideString& wsName, - CXFA_FFWidget* pRefWidget = nullptr); + CXFA_FFWidget* pRefWidget); CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideString& wsName, - CXFA_WidgetAcc* pRefWidgetAcc = nullptr); + CXFA_WidgetAcc* pRefWidgetAcc); CXFA_LayoutProcessor* GetXFALayout() const; void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent); void LockUpdate(); @@ -94,9 +94,9 @@ class CXFA_FFDocView { void DeleteLayoutItem(CXFA_FFWidget* pWidget); int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, - FX_BOOL bIsFormReady = FALSE, - FX_BOOL bRecursive = TRUE, - CXFA_Node* pExclude = nullptr); + FX_BOOL bIsFormReady, + FX_BOOL bRecursive, + CXFA_Node* pExclude); FX_BOOL m_bLayoutEvent; CFX_WideStringArray m_arrNullTestMsg; CXFA_FFWidget* m_pListFocusWidget; @@ -112,12 +112,12 @@ class CXFA_FFDocView { FX_BOOL ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc); CXFA_Node* GetRootSubform(); - CXFA_FFDoc* m_pDoc; - CXFA_FFWidgetHandler* m_pWidgetHandler; - CXFA_LayoutProcessor* m_pXFADocLayout; - CXFA_WidgetAcc* m_pFocusAcc; - CXFA_FFWidget* m_pFocusWidget; - CXFA_FFWidget* m_pOldFocusWidget; + CXFA_FFDoc* const m_pDoc; + std::unique_ptr<CXFA_FFWidgetHandler> m_pWidgetHandler; + CXFA_LayoutProcessor* m_pXFADocLayout; // not owned. + CXFA_WidgetAcc* m_pFocusAcc; // not owned. + CXFA_FFWidget* m_pFocusWidget; // not owned. + CXFA_FFWidget* m_pOldFocusWidget; // not owned. std::map<CXFA_FFPageView*, std::unique_ptr<CFX_RectF>> m_mapPageInvalidate; CFX_ArrayTemplate<CXFA_WidgetAcc*> m_ValidateAccs; CFX_ArrayTemplate<CXFA_WidgetAcc*> m_CalculateAccs; @@ -145,8 +145,8 @@ class CXFA_WidgetAccIterator { protected: CXFA_ContainerIterator m_ContentIterator; - CXFA_FFDocView* m_pDocView; - CXFA_WidgetAcc* m_pCurWidgetAcc; + CXFA_FFDocView* const m_pDocView; + CXFA_WidgetAcc* m_pCurWidgetAcc; // not owned. }; #endif // XFA_FXFA_INCLUDE_XFA_FFDOCVIEW_H_ diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp index 2a281f9c4b..60f3671418 100644 --- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp @@ -18,9 +18,7 @@ CXFA_ResolveProcessor::CXFA_ResolveProcessor() : m_iCurStart(0), m_pNodeHelper(new CXFA_NodeHelper) {} -CXFA_ResolveProcessor::~CXFA_ResolveProcessor() { - delete m_pNodeHelper; -} +CXFA_ResolveProcessor::~CXFA_ResolveProcessor() {} int32_t CXFA_ResolveProcessor::Resolve(CXFA_ResolveNodesData& rnd) { if (!rnd.m_CurNode) { diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.h b/xfa/fxfa/parser/cxfa_resolveprocessor.h index 4db0ea2270..630a54ea3c 100644 --- a/xfa/fxfa/parser/cxfa_resolveprocessor.h +++ b/xfa/fxfa/parser/cxfa_resolveprocessor.h @@ -7,6 +7,8 @@ #ifndef XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_ #define XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_ +#include <memory> + #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" @@ -46,7 +48,7 @@ class CXFA_ResolveProcessor { int32_t iCount); void SetCurStart(int32_t start) { m_iCurStart = start; } - CXFA_NodeHelper* GetNodeHelper() { return m_pNodeHelper; } + CXFA_NodeHelper* GetNodeHelper() const { return m_pNodeHelper.get(); } private: int32_t ResolveForAttributeRs(CXFA_Object* curNode, @@ -72,7 +74,7 @@ class CXFA_ResolveProcessor { void FilterCondition(CXFA_ResolveNodesData& rnd, CFX_WideString wsCondition); int32_t m_iCurStart; - CXFA_NodeHelper* m_pNodeHelper; + std::unique_ptr<CXFA_NodeHelper> m_pNodeHelper; }; #endif // XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_ diff --git a/xfa/fxfa/parser/xfa_locale.cpp b/xfa/fxfa/parser/xfa_locale.cpp index 67a9760646..723fdbc15c 100644 --- a/xfa/fxfa/parser/xfa_locale.cpp +++ b/xfa/fxfa/parser/xfa_locale.cpp @@ -6,6 +6,8 @@ #include "xfa/fxfa/parser/xfa_locale.h" +#include <utility> + #include "core/fxcrt/include/fx_xml.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/xfa_localemgr.h" @@ -17,19 +19,19 @@ static const FX_WCHAR g_FX_Currency[] = L"$z,zzz,zzz,zzz,zzz,zz9.99"; static const FX_WCHAR g_FX_Decimal[] = L"z,zzz,zzz,zzz,zzz,zz9.zzz"; static const FX_WCHAR g_FX_Integer[] = L"z,zzz,zzz,zzz,zzz,zzz"; -CXFA_XMLLocale::CXFA_XMLLocale(CXML_Element* pLocaleData) - : m_pLocaleData(pLocaleData) {} +CXFA_XMLLocale::CXFA_XMLLocale(std::unique_ptr<CXML_Element> pLocaleData) + : m_pLocaleData(std::move(pLocaleData)) {} -CXFA_XMLLocale::~CXFA_XMLLocale() { - delete m_pLocaleData; -} +CXFA_XMLLocale::~CXFA_XMLLocale() {} void CXFA_XMLLocale::Release() { delete this; } + CFX_WideString CXFA_XMLLocale::GetName() { return m_pLocaleData ? m_pLocaleData->GetAttrValue("name") : CFX_WideString(); } + void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, CFX_WideString& wsNumSymbol) const { CFX_ByteString bsSymbols; @@ -74,6 +76,7 @@ void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, CFX_ByteStringC(bsSymbols.c_str(), bsSymbols.GetLength() - 1), wsName.AsStringC(), wsNumSymbol); } + void CXFA_XMLLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { if (!m_pLocaleData) { return; @@ -86,26 +89,32 @@ void CXFA_XMLLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { } wsDtSymbol = pNumberSymbols->GetContent(0); } + void CXFA_XMLLocale::GetMonthName(int32_t nMonth, CFX_WideString& wsMonthName, FX_BOOL bAbbr) const { wsMonthName = GetCalendarSymbol("month", nMonth, bAbbr); } + void CXFA_XMLLocale::GetDayName(int32_t nWeek, CFX_WideString& wsDayName, FX_BOOL bAbbr) const { wsDayName = GetCalendarSymbol("day", nWeek, bAbbr); } + void CXFA_XMLLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, FX_BOOL bAM) const { wsMeridiemName = GetCalendarSymbol("meridiem", bAM ? 0 : 1, FALSE); } + void CXFA_XMLLocale::GetTimeZone(FX_TIMEZONE& tz) const { CXFA_TimeZoneProvider::Get()->GetTimeZone(tz); } + void CXFA_XMLLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { wsEraName = GetCalendarSymbol("era", bAD ? 1 : 0, FALSE); } + CFX_WideString CXFA_XMLLocale::GetCalendarSymbol(const CFX_ByteStringC& symbol, int index, FX_BOOL bAbbr) const { @@ -132,6 +141,7 @@ CFX_WideString CXFA_XMLLocale::GetCalendarSymbol(const CFX_ByteStringC& symbol, } return wsSymbolName; } + void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, CFX_WideString& wsPattern) const { CXML_Element* pElement = m_pLocaleData->GetElement("", "datePatterns"); @@ -156,6 +166,7 @@ void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, } GetPattern(pElement, "datePattern", wsName.AsStringC(), wsPattern); } + void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, CFX_WideString& wsPattern) const { CXML_Element* pElement = m_pLocaleData->GetElement("", "timePatterns"); @@ -180,6 +191,7 @@ void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, } GetPattern(pElement, "timePattern", wsName.AsStringC(), wsPattern); } + void CXFA_XMLLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, CFX_WideString& wsPattern) const { CXML_Element* pElement = m_pLocaleData->GetElement("", "numberPatterns"); @@ -201,6 +213,7 @@ void CXFA_XMLLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, break; } } + void CXFA_XMLLocale::GetPattern(CXML_Element* pElement, const CFX_ByteStringC& bsTag, const CFX_WideStringC& wsName, @@ -214,17 +227,20 @@ void CXFA_XMLLocale::GetPattern(CXML_Element* pElement, } } } -CXFA_NodeLocale::CXFA_NodeLocale(CXFA_Node* pLocale) { - m_pLocale = pLocale; -} + +CXFA_NodeLocale::CXFA_NodeLocale(CXFA_Node* pLocale) : m_pLocale(pLocale) {} + CXFA_NodeLocale::~CXFA_NodeLocale() {} + void CXFA_NodeLocale::Release() { delete this; } + CFX_WideString CXFA_NodeLocale::GetName() { return CFX_WideString(m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name) : nullptr); } + void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, CFX_WideString& wsNumSymbol) const { switch (eType) { @@ -254,33 +270,40 @@ void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType, break; } } + void CXFA_NodeLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const { CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols) : nullptr; wsDtSymbol = pSymbols ? pSymbols->GetContent() : CFX_WideString(); } + void CXFA_NodeLocale::GetMonthName(int32_t nMonth, CFX_WideString& wsMonthName, FX_BOOL bAbbr) const { wsMonthName = GetCalendarSymbol(XFA_Element::MonthNames, nMonth, bAbbr); } + void CXFA_NodeLocale::GetDayName(int32_t nWeek, CFX_WideString& wsDayName, FX_BOOL bAbbr) const { wsDayName = GetCalendarSymbol(XFA_Element::DayNames, nWeek, bAbbr); } + void CXFA_NodeLocale::GetMeridiemName(CFX_WideString& wsMeridiemName, FX_BOOL bAM) const { wsMeridiemName = GetCalendarSymbol(XFA_Element::MeridiemNames, bAM ? 0 : 1, FALSE); } + void CXFA_NodeLocale::GetTimeZone(FX_TIMEZONE& tz) const { CXFA_TimeZoneProvider::Get()->GetTimeZone(tz); } + void CXFA_NodeLocale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const { wsEraName = GetCalendarSymbol(XFA_Element::EraNames, bAD ? 1 : 0, FALSE); } + void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, CFX_WideString& wsPattern) const { switch (eType) { @@ -299,6 +322,7 @@ void CXFA_NodeLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType, break; } } + void CXFA_NodeLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, CFX_WideString& wsPattern) const { switch (eType) { @@ -317,6 +341,7 @@ void CXFA_NodeLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType, break; } } + void CXFA_NodeLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, CFX_WideString& wsPattern) const { switch (eType) { @@ -334,6 +359,7 @@ void CXFA_NodeLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType, break; } } + CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, const CFX_WideStringC& wsName) const { CXFA_Node* pChild = @@ -349,6 +375,7 @@ CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent, } return nullptr; } + CFX_WideString CXFA_NodeLocale::GetSymbol( XFA_Element eElement, const CFX_WideStringC& symbol_type) const { @@ -356,6 +383,7 @@ CFX_WideString CXFA_NodeLocale::GetSymbol( CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type); return pSymbol ? pSymbol->GetContent() : CFX_WideString(); } + CFX_WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement, int index, FX_BOOL bAbbr) const { diff --git a/xfa/fxfa/parser/xfa_locale.h b/xfa/fxfa/parser/xfa_locale.h index 0c72381cd5..0463a9f9e9 100644 --- a/xfa/fxfa/parser/xfa_locale.h +++ b/xfa/fxfa/parser/xfa_locale.h @@ -7,12 +7,14 @@ #ifndef XFA_FXFA_PARSER_XFA_LOCALE_H_ #define XFA_FXFA_PARSER_XFA_LOCALE_H_ +#include <memory> + #include "xfa/fgas/localization/fgas_locale.h" #include "xfa/fxfa/parser/xfa_object.h" class CXFA_XMLLocale : public IFX_Locale { public: - CXFA_XMLLocale(CXML_Element* pLocaleData); + explicit CXFA_XMLLocale(std::unique_ptr<CXML_Element> pLocaleData); // IFX_Locale void Release() override; @@ -51,7 +53,7 @@ class CXFA_XMLLocale : public IFX_Locale { FX_BOOL bAbbr) const; private: - CXML_Element* m_pLocaleData; + std::unique_ptr<CXML_Element> m_pLocaleData; }; class CXFA_NodeLocale : public IFX_Locale { @@ -94,7 +96,7 @@ class CXFA_NodeLocale : public IFX_Locale { int index, FX_BOOL bAbbr) const; - CXFA_Node* m_pLocale; + CXFA_Node* const m_pLocale; }; #endif // XFA_FXFA_PARSER_XFA_LOCALE_H_ diff --git a/xfa/fxfa/parser/xfa_localemgr.cpp b/xfa/fxfa/parser/xfa_localemgr.cpp index 2d100746c9..efc18af6e0 100644 --- a/xfa/fxfa/parser/xfa_localemgr.cpp +++ b/xfa/fxfa/parser/xfa_localemgr.cpp @@ -6,6 +6,9 @@ #include "xfa/fxfa/parser/xfa_localemgr.h" +#include <memory> +#include <utility> + #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_xml.h" #include "core/fxge/include/cfx_gemodule.h" @@ -1029,6 +1032,8 @@ const uint8_t g_ruRU_Locale[] = { 0x89, 0x26, 0xB5, 0x2C, 0xA3, 0xB6, 0x4E, 0x5C, 0xA6, 0x17, 0xA4, 0x7B, 0xB3, 0x85, 0xFA, 0x59, 0x2A, 0x7A, 0xFF, 0x3D, 0xC4, 0x3F, 0xDE, 0xCB, 0x8B, 0xC4}; + +// TODO(weili): Change this function to return std::unique_ptr type. static IFX_Locale* XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) { if (!pBuf || nBufLen <= 0) { return nullptr; @@ -1041,20 +1046,18 @@ static IFX_Locale* XFA_GetLocaleFromBuffer(const uint8_t* pBuf, int nBufLen) { if (!pCodecMgr) { return nullptr; } - CXML_Element* pLocale = nullptr; + std::unique_ptr<CXML_Element> pLocale; uint8_t* pOut = nullptr; uint32_t dwSize; pCodecMgr->GetFlateModule()->FlateOrLZWDecode(FALSE, pBuf, nBufLen, TRUE, 0, 0, 0, 0, 0, pOut, dwSize); if (pOut) { - pLocale = CXML_Element::Parse(pOut, dwSize); + pLocale.reset(CXML_Element::Parse(pOut, dwSize)); FX_Free(pOut); } - if (pLocale) { - return new CXFA_XMLLocale(pLocale); - } - return nullptr; + return pLocale ? new CXFA_XMLLocale(std::move(pLocale)) : nullptr; } + static uint16_t XFA_GetLanguage(CFX_WideString wsLanguage) { uint16_t dwLangueID = XFA_LANGID_en_US; if (wsLanguage.GetLength() < 2) { |