OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FDE_XML_FDE_XML_IMP_H_ | 7 #ifndef XFA_FDE_XML_FDE_XML_IMP_H_ |
8 #define XFA_FDE_XML_FDE_XML_IMP_H_ | 8 #define XFA_FDE_XML_FDE_XML_IMP_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_system.h" | 10 #include "core/fxcrt/include/fx_system.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 int32_t& iBlockIndex, | 284 int32_t& iBlockIndex, |
285 int32_t& iInnerIndex) const; | 285 int32_t& iInnerIndex) const; |
286 void ClearBuffer(); | 286 void ClearBuffer(); |
287 CFX_PtrArray m_BlockArray; | 287 CFX_PtrArray m_BlockArray; |
288 int32_t m_iDataLength; | 288 int32_t m_iDataLength; |
289 int32_t m_iBufferSize; | 289 int32_t m_iBufferSize; |
290 int32_t m_iAllocStep; | 290 int32_t m_iAllocStep; |
291 int32_t m_iStartPosition; | 291 int32_t m_iStartPosition; |
292 }; | 292 }; |
293 | 293 |
294 #define FDE_XMLSYNTAXMODE_Text 0 | |
295 #define FDE_XMLSYNTAXMODE_Node 1 | |
296 #define FDE_XMLSYNTAXMODE_Target 2 | |
297 #define FDE_XMLSYNTAXMODE_Tag 3 | |
298 #define FDE_XMLSYNTAXMODE_AttriName 4 | |
299 #define FDE_XMLSYNTAXMODE_AttriEqualSign 5 | |
300 #define FDE_XMLSYNTAXMODE_AttriQuotation 6 | |
301 #define FDE_XMLSYNTAXMODE_AttriValue 7 | |
302 #define FDE_XMLSYNTAXMODE_Entity 8 | |
303 #define FDE_XMLSYNTAXMODE_EntityDecimal 9 | |
304 #define FDE_XMLSYNTAXMODE_EntityHex 10 | |
305 #define FDE_XMLSYNTAXMODE_CloseInstruction 11 | |
306 #define FDE_XMLSYNTAXMODE_BreakElement 12 | |
307 #define FDE_XMLSYNTAXMODE_CloseElement 13 | |
308 #define FDE_XMLSYNTAXMODE_SkipDeclNode 14 | |
309 #define FDE_XMLSYNTAXMODE_DeclCharData 15 | |
310 #define FDE_XMLSYNTAXMODE_SkipComment 16 | |
311 #define FDE_XMLSYNTAXMODE_SkipCommentOrDecl 17 | |
312 #define FDE_XMLSYNTAXMODE_SkipCData 18 | |
313 #define FDE_XMLSYNTAXMODE_TargetData 19 | |
314 | |
315 class CFDE_XMLSyntaxParser : public CFX_Target { | 294 class CFDE_XMLSyntaxParser : public CFX_Target { |
316 public: | 295 public: |
317 CFDE_XMLSyntaxParser(); | 296 CFDE_XMLSyntaxParser(); |
318 ~CFDE_XMLSyntaxParser(); | 297 ~CFDE_XMLSyntaxParser(); |
319 void Release() { delete this; } | 298 void Release() { delete this; } |
320 void Init(IFX_Stream* pStream, | 299 void Init(IFX_Stream* pStream, |
321 int32_t iXMLPlaneSize, | 300 int32_t iXMLPlaneSize, |
322 int32_t iTextDataSize = 256); | 301 int32_t iTextDataSize = 256); |
323 uint32_t DoSyntaxParse(); | 302 FDE_XmlSyntaxResult DoSyntaxParse(); |
324 int32_t GetStatus() const; | 303 int32_t GetStatus() const; |
325 int32_t GetCurrentPos() const { | 304 int32_t GetCurrentPos() const { |
326 return m_iParsedChars + (m_pStart - m_pBuffer); | 305 return m_iParsedChars + (m_pStart - m_pBuffer); |
327 } | 306 } |
328 FX_FILESIZE GetCurrentBinaryPos() const; | 307 FX_FILESIZE GetCurrentBinaryPos() const; |
329 int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } | 308 int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } |
330 int32_t GetLastNodeNumber() const { return m_iLastNodeNum; } | 309 int32_t GetLastNodeNumber() const { return m_iLastNodeNum; } |
331 | 310 |
332 void GetTargetName(CFX_WideString& wsTarget) const { | 311 void GetTargetName(CFX_WideString& wsTarget) const { |
333 m_BlockBuffer.GetTextData(wsTarget, 0, m_iTextDataLength); | 312 m_BlockBuffer.GetTextData(wsTarget, 0, m_iTextDataLength); |
334 } | 313 } |
335 void GetTagName(CFX_WideString& wsTag) const { | 314 void GetTagName(CFX_WideString& wsTag) const { |
336 m_BlockBuffer.GetTextData(wsTag, 0, m_iTextDataLength); | 315 m_BlockBuffer.GetTextData(wsTag, 0, m_iTextDataLength); |
337 } | 316 } |
338 void GetAttributeName(CFX_WideString& wsAttriName) const { | 317 void GetAttributeName(CFX_WideString& wsAttriName) const { |
339 m_BlockBuffer.GetTextData(wsAttriName, 0, m_iTextDataLength); | 318 m_BlockBuffer.GetTextData(wsAttriName, 0, m_iTextDataLength); |
340 } | 319 } |
341 void GetAttributeValue(CFX_WideString& wsAttriValue) const { | 320 void GetAttributeValue(CFX_WideString& wsAttriValue) const { |
342 m_BlockBuffer.GetTextData(wsAttriValue, 0, m_iTextDataLength); | 321 m_BlockBuffer.GetTextData(wsAttriValue, 0, m_iTextDataLength); |
343 } | 322 } |
344 void GetTextData(CFX_WideString& wsText) const { | 323 void GetTextData(CFX_WideString& wsText) const { |
345 m_BlockBuffer.GetTextData(wsText, 0, m_iTextDataLength); | 324 m_BlockBuffer.GetTextData(wsText, 0, m_iTextDataLength); |
346 } | 325 } |
347 void GetTargetData(CFX_WideString& wsData) const { | 326 void GetTargetData(CFX_WideString& wsData) const { |
348 m_BlockBuffer.GetTextData(wsData, 0, m_iTextDataLength); | 327 m_BlockBuffer.GetTextData(wsData, 0, m_iTextDataLength); |
349 } | 328 } |
350 | 329 |
351 protected: | 330 protected: |
| 331 enum class FDE_XmlSyntaxState { |
| 332 Text, |
| 333 Node, |
| 334 Target, |
| 335 Tag, |
| 336 AttriName, |
| 337 AttriEqualSign, |
| 338 AttriQuotation, |
| 339 AttriValue, |
| 340 Entity, |
| 341 EntityDecimal, |
| 342 EntityHex, |
| 343 CloseInstruction, |
| 344 BreakElement, |
| 345 CloseElement, |
| 346 SkipDeclNode, |
| 347 DeclCharData, |
| 348 SkipComment, |
| 349 SkipCommentOrDecl, |
| 350 SkipCData, |
| 351 TargetData |
| 352 }; |
| 353 |
352 IFX_Stream* m_pStream; | 354 IFX_Stream* m_pStream; |
353 int32_t m_iXMLPlaneSize; | 355 int32_t m_iXMLPlaneSize; |
354 int32_t m_iCurrentPos; | 356 int32_t m_iCurrentPos; |
355 int32_t m_iCurrentNodeNum; | 357 int32_t m_iCurrentNodeNum; |
356 int32_t m_iLastNodeNum; | 358 int32_t m_iLastNodeNum; |
357 int32_t m_iParsedChars; | 359 int32_t m_iParsedChars; |
358 int32_t m_iParsedBytes; | 360 int32_t m_iParsedBytes; |
359 FX_WCHAR* m_pBuffer; | 361 FX_WCHAR* m_pBuffer; |
360 int32_t m_iBufferChars; | 362 int32_t m_iBufferChars; |
361 FX_BOOL m_bEOS; | 363 FX_BOOL m_bEOS; |
362 FX_WCHAR* m_pStart; | 364 FX_WCHAR* m_pStart; |
363 FX_WCHAR* m_pEnd; | 365 FX_WCHAR* m_pEnd; |
364 FDE_XMLNODE m_CurNode; | 366 FDE_XMLNODE m_CurNode; |
365 CFDE_XMLNodeStack m_XMLNodeStack; | 367 CFDE_XMLNodeStack m_XMLNodeStack; |
366 CFDE_BlockBuffer m_BlockBuffer; | 368 CFDE_BlockBuffer m_BlockBuffer; |
367 int32_t m_iAllocStep; | 369 int32_t m_iAllocStep; |
368 int32_t& m_iDataLength; | 370 int32_t& m_iDataLength; |
369 FX_WCHAR* m_pCurrentBlock; | 371 FX_WCHAR* m_pCurrentBlock; |
370 int32_t m_iIndexInBlock; | 372 int32_t m_iIndexInBlock; |
371 int32_t m_iTextDataLength; | 373 int32_t m_iTextDataLength; |
372 uint32_t m_dwStatus; | 374 FDE_XmlSyntaxResult m_syntaxParserResult; |
373 uint32_t m_dwMode; | 375 FDE_XmlSyntaxState m_syntaxParserState; |
374 FX_WCHAR m_wQuotationMark; | 376 FX_WCHAR m_wQuotationMark; |
375 int32_t m_iEntityStart; | 377 int32_t m_iEntityStart; |
376 CFX_DWordStack m_SkipStack; | 378 CFX_DWordStack m_SkipStack; |
377 FX_WCHAR m_SkipChar; | 379 FX_WCHAR m_SkipChar; |
378 inline void ParseTextChar(FX_WCHAR ch); | 380 inline void ParseTextChar(FX_WCHAR ch); |
379 }; | 381 }; |
380 | 382 |
381 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ | 383 #endif // XFA_FDE_XML_FDE_XML_IMP_H_ |
OLD | NEW |