diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/fm2js/xfa_expression.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_expression.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fmparse.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_program.cpp | 17 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_program.h | 8 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_graphics.cpp | 10 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_path.cpp | 15 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_path.h | 12 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_path_generator.cpp | 22 | ||||
-rw-r--r-- | xfa/fxgraphics/cfx_path_generator.h | 7 | ||||
-rw-r--r-- | xfa/fxgraphics/include/cfx_graphics.h | 4 |
11 files changed, 55 insertions, 51 deletions
diff --git a/xfa/fxfa/fm2js/xfa_expression.cpp b/xfa/fxfa/fm2js/xfa_expression.cpp index ad6acafd48..22e627d72d 100644 --- a/xfa/fxfa/fm2js/xfa_expression.cpp +++ b/xfa/fxfa/fm2js/xfa_expression.cpp @@ -32,16 +32,15 @@ CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( uint32_t line, FX_BOOL isGlobal, const CFX_WideStringC& wsName, - CFX_WideStringCArray* pArguments, + std::unique_ptr<CFX_WideStringCArray> pArguments, CFX_ArrayTemplate<CXFA_FMExpression*>* pExpressions) : CXFA_FMExpression(line, XFA_FM_EXPTYPE_FUNC), m_wsName(wsName), - m_pArguments(pArguments), + m_pArguments(std::move(pArguments)), m_pExpressions(pExpressions), m_isGlobal(isGlobal) {} CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() { - delete m_pArguments; if (m_pExpressions) { for (int i = 0; i < m_pExpressions->GetSize(); ++i) delete m_pExpressions->GetAt(i); diff --git a/xfa/fxfa/fm2js/xfa_expression.h b/xfa/fxfa/fm2js/xfa_expression.h index 8134988f4e..88cebdf036 100644 --- a/xfa/fxfa/fm2js/xfa_expression.h +++ b/xfa/fxfa/fm2js/xfa_expression.h @@ -44,7 +44,7 @@ class CXFA_FMFunctionDefinition : public CXFA_FMExpression { uint32_t line, FX_BOOL isGlobal, const CFX_WideStringC& wsName, - CFX_WideStringCArray* pArguments, + std::unique_ptr<CFX_WideStringCArray> pArguments, CFX_ArrayTemplate<CXFA_FMExpression*>* pExpressions); ~CXFA_FMFunctionDefinition() override; @@ -53,7 +53,7 @@ class CXFA_FMFunctionDefinition : public CXFA_FMExpression { private: CFX_WideStringC m_wsName; - CFX_WideStringCArray* m_pArguments; + std::unique_ptr<CFX_WideStringCArray> m_pArguments; CFX_ArrayTemplate<CXFA_FMExpression*>* m_pExpressions; FX_BOOL m_isGlobal; }; diff --git a/xfa/fxfa/fm2js/xfa_fmparse.cpp b/xfa/fxfa/fm2js/xfa_fmparse.cpp index 5c17bbc723..3223df64dc 100644 --- a/xfa/fxfa/fm2js/xfa_fmparse.cpp +++ b/xfa/fxfa/fm2js/xfa_fmparse.cpp @@ -129,7 +129,7 @@ CXFA_FMExpression* CXFA_FMParse::ParseFunction() { Check(TOKendfunc); } if (m_pErrorInfo->message.IsEmpty()) { - e.reset(new CXFA_FMFunctionDefinition(line, 0, ident, pArguments.release(), + e.reset(new CXFA_FMFunctionDefinition(line, 0, ident, std::move(pArguments), pExpressions.release())); } else { if (pArguments) diff --git a/xfa/fxfa/fm2js/xfa_program.cpp b/xfa/fxfa/fm2js/xfa_program.cpp index a5c429765f..5146a5e129 100644 --- a/xfa/fxfa/fm2js/xfa_program.cpp +++ b/xfa/fxfa/fm2js/xfa_program.cpp @@ -6,16 +6,14 @@ #include "xfa/fxfa/fm2js/xfa_program.h" -CXFA_FMProgram::CXFA_FMProgram() : m_globalFunction(0) {} -CXFA_FMProgram::~CXFA_FMProgram() { - if (m_globalFunction != 0) { - delete m_globalFunction; - m_globalFunction = 0; - } -} +CXFA_FMProgram::CXFA_FMProgram() {} + +CXFA_FMProgram::~CXFA_FMProgram() {} + int32_t CXFA_FMProgram::Init(const CFX_WideStringC& wsFormcalc) { return m_parse.Init(wsFormcalc, &m_pErrorInfo); } + int32_t CXFA_FMProgram::ParseProgram() { CFX_ArrayTemplate<CXFA_FMExpression*>* expressions = nullptr; m_parse.NextToken(); @@ -30,10 +28,11 @@ int32_t CXFA_FMProgram::ParseProgram() { delete expressions; return -1; } - m_globalFunction = - new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), 0, expressions); + m_globalFunction.reset( + new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), nullptr, expressions)); return 0; } + int32_t CXFA_FMProgram::TranslateProgram(CFX_WideTextBuf& wsJavaScript) { m_globalFunction->ToJavaScript(wsJavaScript); wsJavaScript.AppendChar(0); diff --git a/xfa/fxfa/fm2js/xfa_program.h b/xfa/fxfa/fm2js/xfa_program.h index 2f6de5e3a8..aa29bba87b 100644 --- a/xfa/fxfa/fm2js/xfa_program.h +++ b/xfa/fxfa/fm2js/xfa_program.h @@ -7,6 +7,8 @@ #ifndef XFA_FXFA_FM2JS_XFA_PROGRAM_H_ #define XFA_FXFA_FM2JS_XFA_PROGRAM_H_ +#include <memory> + #include "xfa/fxfa/fm2js/xfa_error.h" #include "xfa/fxfa/fm2js/xfa_fmparse.h" @@ -14,15 +16,17 @@ class CXFA_FMProgram { public: CXFA_FMProgram(); ~CXFA_FMProgram(); + int32_t Init(const CFX_WideStringC& wsFormcalc); int32_t ParseProgram(); int32_t TranslateProgram(CFX_WideTextBuf& wsJavaScript); - CXFA_FMErrorInfo& GetError() { return m_pErrorInfo; } + + const CXFA_FMErrorInfo& GetError() const { return m_pErrorInfo; } private: CXFA_FMErrorInfo m_pErrorInfo; CXFA_FMParse m_parse; - CXFA_FMFunctionDefinition* m_globalFunction; + std::unique_ptr<CXFA_FMFunctionDefinition> m_globalFunction; }; #endif // XFA_FXFA_FM2JS_XFA_PROGRAM_H_ diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index 90225d4e19..0e18d65e2d 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -567,9 +567,7 @@ const FX_HATCHDATA hatchBitmapData[FX_HATCHSTYLE_Total] = { } // namespace CFX_Graphics::CFX_Graphics() - : m_type(FX_CONTEXT_None), - m_renderDevice(nullptr), - m_aggGraphics(nullptr) {} + : m_type(FX_CONTEXT_None), m_renderDevice(nullptr) {} FWL_Error CFX_Graphics::Create(CFX_RenderDevice* renderDevice, FX_BOOL isAntialiasing) { @@ -596,13 +594,11 @@ FWL_Error CFX_Graphics::Create(int32_t width, m_type = FX_CONTEXT_Device; m_info.isAntialiasing = isAntialiasing; - m_aggGraphics = new CAGG_Graphics; + m_aggGraphics.reset(new CAGG_Graphics); return m_aggGraphics->Create(this, width, height, format); } -CFX_Graphics::~CFX_Graphics() { - delete m_aggGraphics; -} +CFX_Graphics::~CFX_Graphics() {} FWL_Error CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp index 892a339469..5adeded977 100644 --- a/xfa/fxgraphics/cfx_path.cpp +++ b/xfa/fxgraphics/cfx_path.cpp @@ -9,22 +9,17 @@ #include "core/fxge/include/cfx_pathdata.h" #include "xfa/fxgraphics/cfx_path_generator.h" -CFX_Path::CFX_Path() { - m_generator = nullptr; -} +CFX_Path::CFX_Path() {} FWL_Error CFX_Path::Create() { if (m_generator) return FWL_Error::PropertyInvalid; - m_generator = new CFX_PathGenerator; - m_generator->Create(); + m_generator.reset(new CFX_PathGenerator()); return FWL_Error::Succeeded; } -CFX_Path::~CFX_Path() { - delete m_generator; -} +CFX_Path::~CFX_Path() {} FWL_Error CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) { if (!m_generator) @@ -167,7 +162,7 @@ FWL_Error CFX_Path::Clear() { return FWL_Error::Succeeded; } -FX_BOOL CFX_Path::IsEmpty() { +FX_BOOL CFX_Path::IsEmpty() const { if (!m_generator) return FALSE; if (m_generator->GetPathData()->GetPointCount() == 0) @@ -175,7 +170,7 @@ FX_BOOL CFX_Path::IsEmpty() { return FALSE; } -CFX_PathData* CFX_Path::GetPathData() { +CFX_PathData* CFX_Path::GetPathData() const { if (!m_generator) return nullptr; return m_generator->GetPathData(); diff --git a/xfa/fxgraphics/cfx_path.h b/xfa/fxgraphics/cfx_path.h index f42586f0de..bfef04e591 100644 --- a/xfa/fxgraphics/cfx_path.h +++ b/xfa/fxgraphics/cfx_path.h @@ -7,16 +7,18 @@ #ifndef XFA_FXGRAPHICS_CFX_PATH_H_ #define XFA_FXGRAPHICS_CFX_PATH_H_ +#include <memory> + #include "core/fxcrt/include/fx_system.h" #include "xfa/fxgraphics/include/cfx_graphics.h" class CFX_PathData; class CFX_PathGenerator; -class CFX_Path { +class CFX_Path final { public: CFX_Path(); - virtual ~CFX_Path(); + ~CFX_Path(); FWL_Error Create(); FWL_Error MoveTo(FX_FLOAT x, FX_FLOAT y); @@ -68,11 +70,11 @@ class CFX_Path { FWL_Error AddSubpath(CFX_Path* path); FWL_Error Clear(); - FX_BOOL IsEmpty(); - CFX_PathData* GetPathData(); + FX_BOOL IsEmpty() const; + CFX_PathData* GetPathData() const; private: - CFX_PathGenerator* m_generator; + std::unique_ptr<CFX_PathGenerator> m_generator; }; #endif // XFA_FXGRAPHICS_CFX_PATH_H_ diff --git a/xfa/fxgraphics/cfx_path_generator.cpp b/xfa/fxgraphics/cfx_path_generator.cpp index f2dc182b55..aadaa85ad0 100644 --- a/xfa/fxgraphics/cfx_path_generator.cpp +++ b/xfa/fxgraphics/cfx_path_generator.cpp @@ -8,15 +8,9 @@ #include "core/fxge/include/cfx_pathdata.h" -CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(nullptr) {} +CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(new CFX_PathData) {} -void CFX_PathGenerator::Create() { - m_pPathData = new CFX_PathData; -} - -CFX_PathGenerator::~CFX_PathGenerator() { - delete m_pPathData; -} +CFX_PathGenerator::~CFX_PathGenerator() {} void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { if (pPathData && pPathData->GetPointCount() > 0) { @@ -25,6 +19,7 @@ void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) { AddPathData(pPoints, nCount); } } + void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { if (pPoints && nCount > 0) { int nOldCount = m_pPathData->GetPointCount(); @@ -34,14 +29,17 @@ void CFX_PathGenerator::AddPathData(FX_PATHPOINT* pPoints, int nCount) { sizeof(FX_PATHPOINT) * nCount); } } + void CFX_PathGenerator::MoveTo(FX_FLOAT x, FX_FLOAT y) { m_pPathData->AddPointCount(1); m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_MOVETO); } + void CFX_PathGenerator::LineTo(FX_FLOAT x, FX_FLOAT y) { m_pPathData->AddPointCount(1); m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, FXPT_LINETO); } + void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, FX_FLOAT ctrl_y1, FX_FLOAT ctrl_x2, @@ -54,6 +52,7 @@ void CFX_PathGenerator::BezierTo(FX_FLOAT ctrl_x1, m_pPathData->SetPoint(old_count + 1, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); m_pPathData->SetPoint(old_count + 2, to_x, to_y, FXPT_BEZIERTO); } + void CFX_PathGenerator::Close() { if (m_pPathData->GetPointCount() > 0) { int index = m_pPathData->GetPointCount() - 1; @@ -61,6 +60,7 @@ void CFX_PathGenerator::Close() { pPoints[index].m_Flag |= FXPT_CLOSEFIGURE; } } + void CFX_PathGenerator::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, @@ -70,6 +70,7 @@ void CFX_PathGenerator::AddLine(FX_FLOAT x1, m_pPathData->SetPoint(old_count, x1, y1, FXPT_MOVETO); m_pPathData->SetPoint(old_count + 1, x2, y2, FXPT_LINETO); } + void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, FX_FLOAT start_y, FX_FLOAT ctrl_x1, @@ -85,18 +86,21 @@ void CFX_PathGenerator::AddBezier(FX_FLOAT start_x, m_pPathData->SetPoint(old_count + 2, ctrl_x2, ctrl_y2, FXPT_BEZIERTO); m_pPathData->SetPoint(old_count + 3, end_x, end_y, FXPT_BEZIERTO); } + void CFX_PathGenerator::AddRectangle(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) { m_pPathData->AppendRect(x1, y1, x2, y2); } + void CFX_PathGenerator::AddEllipse(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, FX_FLOAT height) { AddArc(x, y, width, height, 0, FX_PI * 2); } + void CFX_PathGenerator::ArcTo(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, @@ -127,6 +131,7 @@ void CFX_PathGenerator::ArcTo(FX_FLOAT x, bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle)); m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); } + void CFX_PathGenerator::AddArc(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, @@ -178,6 +183,7 @@ void CFX_PathGenerator::AddArc(FX_FLOAT x, start_angle += local_sweep; } while (!done); } + void CFX_PathGenerator::AddPie(FX_FLOAT x, FX_FLOAT y, FX_FLOAT width, diff --git a/xfa/fxgraphics/cfx_path_generator.h b/xfa/fxgraphics/cfx_path_generator.h index 186178e516..0fed30f93f 100644 --- a/xfa/fxgraphics/cfx_path_generator.h +++ b/xfa/fxgraphics/cfx_path_generator.h @@ -7,6 +7,8 @@ #ifndef XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_ #define XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_ +#include <memory> + #include "core/fxge/include/cfx_pathdata.h" #include "core/fxge/include/fx_ge.h" @@ -15,8 +17,7 @@ class CFX_PathGenerator { CFX_PathGenerator(); ~CFX_PathGenerator(); - void Create(); - CFX_PathData* GetPathData() const { return m_pPathData; } + CFX_PathData* GetPathData() const { return m_pPathData.get(); } void AddPathData(CFX_PathData* path_data); void AddPathData(FX_PATHPOINT* points, int count); @@ -62,7 +63,7 @@ class CFX_PathGenerator { FX_FLOAT sweep_angle); protected: - CFX_PathData* m_pPathData; + std::unique_ptr<CFX_PathData> m_pPathData; }; #endif // XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_ diff --git a/xfa/fxgraphics/include/cfx_graphics.h b/xfa/fxgraphics/include/cfx_graphics.h index 916fba57c7..e581089aec 100644 --- a/xfa/fxgraphics/include/cfx_graphics.h +++ b/xfa/fxgraphics/include/cfx_graphics.h @@ -7,6 +7,8 @@ #ifndef XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ #define XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ +#include <memory> + #include "core/fxcrt/include/fx_system.h" #include "core/fxge/include/fx_dib.h" #include "core/fxge/include/fx_ge.h" @@ -230,7 +232,7 @@ class CFX_Graphics { CFX_RenderDevice* m_renderDevice; CFX_ArrayTemplate<TInfo*> m_infoStack; - CAGG_Graphics* m_aggGraphics; + std::unique_ptr<CAGG_Graphics> m_aggGraphics; friend class CAGG_Graphics; }; |