Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: xfa/fde/xml/fde_xml_imp.cpp

Issue 1836353002: Remove IFDE_XML* classes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fde/xml/fde_xml_imp.h ('k') | xfa/fxfa/app/xfa_ffdoc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "xfa/fde/xml/fde_xml_imp.h" 7 #include "xfa/fde/xml/fde_xml_imp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ch = *pStart++; 136 ch = *pStart++;
137 if (ch == L'/') { 137 if (ch == L'/') {
138 break; 138 break;
139 } else { 139 } else {
140 csPath += ch; 140 csPath += ch;
141 } 141 }
142 } 142 }
143 iLength -= pStart - pPath; 143 iLength -= pStart - pPath;
144 CFDE_XMLNode* pFind = NULL; 144 CFDE_XMLNode* pFind = NULL;
145 if (csPath.GetLength() < 1) { 145 if (csPath.GetLength() < 1) {
146 pFind = GetNodeItem(IFDE_XMLNode::Root); 146 pFind = GetNodeItem(CFDE_XMLNode::Root);
147 } else if (csPath.Compare(L"..") == 0) { 147 } else if (csPath.Compare(L"..") == 0) {
148 pFind = m_pParent; 148 pFind = m_pParent;
149 } else if (csPath.Compare(L".") == 0) { 149 } else if (csPath.Compare(L".") == 0) {
150 pFind = (CFDE_XMLNode*)this; 150 pFind = (CFDE_XMLNode*)this;
151 } else { 151 } else {
152 CFX_WideString wsTag; 152 CFX_WideString wsTag;
153 CFDE_XMLNode* pNode = m_pChild; 153 CFDE_XMLNode* pNode = m_pChild;
154 while (pNode != NULL) { 154 while (pNode != NULL) {
155 if (pNode->GetType() == FDE_XMLNODE_Element) { 155 if (pNode->GetType() == FDE_XMLNODE_Element) {
156 if (bQualifiedName) { 156 if (bQualifiedName) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } else { 212 } else {
213 pNode->m_pPrior->m_pNext = pNode->m_pNext; 213 pNode->m_pPrior->m_pNext = pNode->m_pNext;
214 } 214 }
215 if (pNode->m_pNext != NULL) { 215 if (pNode->m_pNext != NULL) {
216 pNode->m_pNext->m_pPrior = pNode->m_pPrior; 216 pNode->m_pNext->m_pPrior = pNode->m_pPrior;
217 } 217 }
218 pNode->m_pParent = NULL; 218 pNode->m_pParent = NULL;
219 pNode->m_pNext = NULL; 219 pNode->m_pNext = NULL;
220 pNode->m_pPrior = NULL; 220 pNode->m_pPrior = NULL;
221 } 221 }
222 CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(IFDE_XMLNode::NodeItem eItem) const { 222 CFDE_XMLNode* CFDE_XMLNode::GetNodeItem(CFDE_XMLNode::NodeItem eItem) const {
223 switch (eItem) { 223 switch (eItem) {
224 case IFDE_XMLNode::Root: { 224 case CFDE_XMLNode::Root: {
225 CFDE_XMLNode* pParent = (CFDE_XMLNode*)this; 225 CFDE_XMLNode* pParent = (CFDE_XMLNode*)this;
226 while (pParent->m_pParent != NULL) { 226 while (pParent->m_pParent != NULL) {
227 pParent = pParent->m_pParent; 227 pParent = pParent->m_pParent;
228 } 228 }
229 return pParent; 229 return pParent;
230 } 230 }
231 case IFDE_XMLNode::Parent: 231 case CFDE_XMLNode::Parent:
232 return m_pParent; 232 return m_pParent;
233 case IFDE_XMLNode::FirstSibling: { 233 case CFDE_XMLNode::FirstSibling: {
234 CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; 234 CFDE_XMLNode* pItem = (CFDE_XMLNode*)this;
235 while (pItem->m_pPrior != NULL) { 235 while (pItem->m_pPrior != NULL) {
236 pItem = pItem->m_pPrior; 236 pItem = pItem->m_pPrior;
237 } 237 }
238 return pItem == (CFDE_XMLNode*)this ? NULL : pItem; 238 return pItem == (CFDE_XMLNode*)this ? NULL : pItem;
239 } 239 }
240 case IFDE_XMLNode::PriorSibling: 240 case CFDE_XMLNode::PriorSibling:
241 return m_pPrior; 241 return m_pPrior;
242 case IFDE_XMLNode::NextSibling: 242 case CFDE_XMLNode::NextSibling:
243 return m_pNext; 243 return m_pNext;
244 case IFDE_XMLNode::LastSibling: { 244 case CFDE_XMLNode::LastSibling: {
245 CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; 245 CFDE_XMLNode* pItem = (CFDE_XMLNode*)this;
246 while (pItem->m_pNext != NULL) { 246 while (pItem->m_pNext != NULL) {
247 pItem = pItem->m_pNext; 247 pItem = pItem->m_pNext;
248 } 248 }
249 return pItem == (CFDE_XMLNode*)this ? NULL : pItem; 249 return pItem == (CFDE_XMLNode*)this ? NULL : pItem;
250 } 250 }
251 case IFDE_XMLNode::FirstNeighbor: { 251 case CFDE_XMLNode::FirstNeighbor: {
252 CFDE_XMLNode* pParent = (CFDE_XMLNode*)this; 252 CFDE_XMLNode* pParent = (CFDE_XMLNode*)this;
253 while (pParent->m_pParent != NULL) { 253 while (pParent->m_pParent != NULL) {
254 pParent = pParent->m_pParent; 254 pParent = pParent->m_pParent;
255 } 255 }
256 return pParent == (CFDE_XMLNode*)this ? NULL : pParent; 256 return pParent == (CFDE_XMLNode*)this ? NULL : pParent;
257 } 257 }
258 case IFDE_XMLNode::PriorNeighbor: { 258 case CFDE_XMLNode::PriorNeighbor: {
259 if (m_pPrior == NULL) { 259 if (m_pPrior == NULL) {
260 return m_pParent; 260 return m_pParent;
261 } 261 }
262 CFDE_XMLNode* pItem = m_pPrior; 262 CFDE_XMLNode* pItem = m_pPrior;
263 while (CFDE_XMLNode* pTemp = pItem->m_pChild) { 263 while (CFDE_XMLNode* pTemp = pItem->m_pChild) {
264 pItem = pTemp; 264 pItem = pTemp;
265 while ((pTemp = pItem->m_pNext) != NULL) { 265 while ((pTemp = pItem->m_pNext) != NULL) {
266 pItem = pTemp; 266 pItem = pTemp;
267 } 267 }
268 } 268 }
269 return pItem; 269 return pItem;
270 } 270 }
271 case IFDE_XMLNode::NextNeighbor: { 271 case CFDE_XMLNode::NextNeighbor: {
272 if (m_pChild != NULL) { 272 if (m_pChild != NULL) {
273 return m_pChild; 273 return m_pChild;
274 } 274 }
275 if (m_pNext != NULL) { 275 if (m_pNext != NULL) {
276 return m_pNext; 276 return m_pNext;
277 } 277 }
278 CFDE_XMLNode* pItem = m_pParent; 278 CFDE_XMLNode* pItem = m_pParent;
279 while (pItem != NULL) { 279 while (pItem != NULL) {
280 if (pItem->m_pNext != NULL) { 280 if (pItem->m_pNext != NULL) {
281 return pItem->m_pNext; 281 return pItem->m_pNext;
282 } 282 }
283 pItem = pItem->m_pParent; 283 pItem = pItem->m_pParent;
284 } 284 }
285 return NULL; 285 return NULL;
286 } 286 }
287 case IFDE_XMLNode::LastNeighbor: { 287 case CFDE_XMLNode::LastNeighbor: {
288 CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; 288 CFDE_XMLNode* pItem = (CFDE_XMLNode*)this;
289 while (pItem->m_pParent != NULL) { 289 while (pItem->m_pParent != NULL) {
290 pItem = pItem->m_pParent; 290 pItem = pItem->m_pParent;
291 } 291 }
292 while (TRUE) { 292 while (TRUE) {
293 while (pItem->m_pNext != NULL) { 293 while (pItem->m_pNext != NULL) {
294 pItem = pItem->m_pNext; 294 pItem = pItem->m_pNext;
295 } 295 }
296 if (pItem->m_pChild == NULL) { 296 if (pItem->m_pChild == NULL) {
297 break; 297 break;
298 } 298 }
299 pItem = pItem->m_pChild; 299 pItem = pItem->m_pChild;
300 } 300 }
301 return pItem == (CFDE_XMLNode*)this ? NULL : pItem; 301 return pItem == (CFDE_XMLNode*)this ? NULL : pItem;
302 } 302 }
303 case IFDE_XMLNode::FirstChild: 303 case CFDE_XMLNode::FirstChild:
304 return m_pChild; 304 return m_pChild;
305 case IFDE_XMLNode::LastChild: { 305 case CFDE_XMLNode::LastChild: {
306 if (m_pChild == NULL) { 306 if (m_pChild == NULL) {
307 return NULL; 307 return NULL;
308 } 308 }
309 CFDE_XMLNode* pChild = m_pChild; 309 CFDE_XMLNode* pChild = m_pChild;
310 while (pChild->m_pNext != NULL) { 310 while (pChild->m_pNext != NULL) {
311 pChild = pChild->m_pNext; 311 pChild = pChild->m_pNext;
312 } 312 }
313 return pChild; 313 return pChild;
314 } 314 }
315 default: 315 default:
316 break; 316 break;
317 } 317 }
318 return NULL; 318 return NULL;
319 } 319 }
320 int32_t CFDE_XMLNode::GetNodeLevel() const { 320 int32_t CFDE_XMLNode::GetNodeLevel() const {
321 int32_t iLevel = 0; 321 int32_t iLevel = 0;
322 CFDE_XMLNode* pItem = (CFDE_XMLNode*)this; 322 CFDE_XMLNode* pItem = (CFDE_XMLNode*)this;
323 while ((pItem = pItem->m_pParent) != NULL) { 323 while ((pItem = pItem->m_pParent) != NULL) {
324 iLevel++; 324 iLevel++;
325 } 325 }
326 return iLevel; 326 return iLevel;
327 } 327 }
328 FX_BOOL CFDE_XMLNode::InsertNodeItem(IFDE_XMLNode::NodeItem eItem, 328 FX_BOOL CFDE_XMLNode::InsertNodeItem(CFDE_XMLNode::NodeItem eItem,
329 CFDE_XMLNode* pNode) { 329 CFDE_XMLNode* pNode) {
330 FXSYS_assert(pNode != NULL); 330 FXSYS_assert(pNode != NULL);
331 switch (eItem) { 331 switch (eItem) {
332 case IFDE_XMLNode::NextSibling: { 332 case CFDE_XMLNode::NextSibling: {
333 pNode->m_pParent = m_pParent; 333 pNode->m_pParent = m_pParent;
334 pNode->m_pNext = m_pNext; 334 pNode->m_pNext = m_pNext;
335 pNode->m_pPrior = this; 335 pNode->m_pPrior = this;
336 if (m_pNext) { 336 if (m_pNext) {
337 m_pNext->m_pPrior = pNode; 337 m_pNext->m_pPrior = pNode;
338 } 338 }
339 m_pNext = pNode; 339 m_pNext = pNode;
340 return TRUE; 340 return TRUE;
341 } 341 }
342 case IFDE_XMLNode::PriorSibling: { 342 case CFDE_XMLNode::PriorSibling: {
343 pNode->m_pParent = m_pParent; 343 pNode->m_pParent = m_pParent;
344 pNode->m_pNext = this; 344 pNode->m_pNext = this;
345 pNode->m_pPrior = m_pPrior; 345 pNode->m_pPrior = m_pPrior;
346 if (m_pPrior) { 346 if (m_pPrior) {
347 m_pPrior->m_pNext = pNode; 347 m_pPrior->m_pNext = pNode;
348 } else if (m_pParent) { 348 } else if (m_pParent) {
349 m_pParent->m_pChild = pNode; 349 m_pParent->m_pChild = pNode;
350 } 350 }
351 m_pPrior = pNode; 351 m_pPrior = pNode;
352 return TRUE; 352 return TRUE;
353 } 353 }
354 default: 354 default:
355 return FALSE; 355 return FALSE;
356 } 356 }
357 return FALSE; 357 return FALSE;
358 } 358 }
359 CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(IFDE_XMLNode::NodeItem eItem) { 359 CFDE_XMLNode* CFDE_XMLNode::RemoveNodeItem(CFDE_XMLNode::NodeItem eItem) {
360 CFDE_XMLNode* pNode = NULL; 360 CFDE_XMLNode* pNode = NULL;
361 switch (eItem) { 361 switch (eItem) {
362 case IFDE_XMLNode::NextSibling: 362 case CFDE_XMLNode::NextSibling:
363 if (m_pNext) { 363 if (m_pNext) {
364 pNode = m_pNext; 364 pNode = m_pNext;
365 m_pNext = pNode->m_pNext; 365 m_pNext = pNode->m_pNext;
366 if (m_pNext) { 366 if (m_pNext) {
367 m_pNext->m_pPrior = this; 367 m_pNext->m_pPrior = this;
368 } 368 }
369 pNode->m_pParent = NULL; 369 pNode->m_pParent = NULL;
370 pNode->m_pNext = NULL; 370 pNode->m_pNext = NULL;
371 pNode->m_pPrior = NULL; 371 pNode->m_pPrior = NULL;
372 } 372 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) { 493 void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) {
494 if (!m_pChild) { 494 if (!m_pChild) {
495 return; 495 return;
496 } 496 }
497 CFDE_XMLNode* pNext = m_pChild; 497 CFDE_XMLNode* pNext = m_pChild;
498 CFDE_XMLNode* pCloneNext = pNext->Clone(TRUE); 498 CFDE_XMLNode* pCloneNext = pNext->Clone(TRUE);
499 pClone->InsertChildNode(pCloneNext); 499 pClone->InsertChildNode(pCloneNext);
500 pNext = pNext->m_pNext; 500 pNext = pNext->m_pNext;
501 while (pNext) { 501 while (pNext) {
502 CFDE_XMLNode* pChild = pNext->Clone(TRUE); 502 CFDE_XMLNode* pChild = pNext->Clone(TRUE);
503 pCloneNext->InsertNodeItem(IFDE_XMLNode::NextSibling, pChild); 503 pCloneNext->InsertNodeItem(CFDE_XMLNode::NextSibling, pChild);
504 pCloneNext = pChild; 504 pCloneNext = pChild;
505 pNext = pNext->m_pNext; 505 pNext = pNext->m_pNext;
506 } 506 }
507 } 507 }
508 IFDE_XMLInstruction* IFDE_XMLInstruction::Create( 508
509 const CFX_WideString& wsTarget) {
510 return (IFDE_XMLInstruction*)new CFDE_XMLInstruction(wsTarget);
511 }
512 CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget) 509 CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget)
513 : m_wsTarget(wsTarget) { 510 : m_wsTarget(wsTarget) {
514 FXSYS_assert(m_wsTarget.GetLength() > 0); 511 FXSYS_assert(m_wsTarget.GetLength() > 0);
515 } 512 }
516 CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) { 513 CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) {
517 CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget); 514 CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget);
518 if (!pClone) { 515 if (!pClone) {
519 return pClone; 516 return pClone;
520 } 517 }
521 pClone->m_Attributes.Copy(m_Attributes); 518 pClone->m_Attributes.Copy(m_Attributes);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 627 }
631 wsData = m_TargetData[index]; 628 wsData = m_TargetData[index];
632 return TRUE; 629 return TRUE;
633 } 630 }
634 void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) { 631 void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) {
635 m_TargetData.Add(wsData); 632 m_TargetData.Add(wsData);
636 } 633 }
637 void CFDE_XMLInstruction::RemoveData(int32_t index) { 634 void CFDE_XMLInstruction::RemoveData(int32_t index) {
638 m_TargetData.RemoveAt(index); 635 m_TargetData.RemoveAt(index);
639 } 636 }
640 IFDE_XMLElement* IFDE_XMLElement::Create(const CFX_WideString& wsTag) { 637
641 return (IFDE_XMLElement*)new CFDE_XMLElement(wsTag);
642 }
643 CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag) 638 CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag)
644 : CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() { 639 : CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() {
645 FXSYS_assert(m_wsTag.GetLength() > 0); 640 FXSYS_assert(m_wsTag.GetLength() > 0);
646 } 641 }
647 CFDE_XMLElement::~CFDE_XMLElement() { 642 CFDE_XMLElement::~CFDE_XMLElement() {
648 m_Attributes.RemoveAll(); 643 m_Attributes.RemoveAll();
649 } 644 }
650 CFDE_XMLNode* CFDE_XMLElement::Clone(FX_BOOL bRecursive) { 645 CFDE_XMLNode* CFDE_XMLElement::Clone(FX_BOOL bRecursive) {
651 CFDE_XMLElement* pClone = new CFDE_XMLElement(m_wsTag); 646 CFDE_XMLElement* pClone = new CFDE_XMLElement(m_wsTag);
652 if (!pClone) { 647 if (!pClone) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 wsAttri += wsPrefix; 694 wsAttri += wsPrefix;
700 } 695 }
701 wsNamespace.Empty(); 696 wsNamespace.Empty();
702 CFDE_XMLNode* pNode = (CFDE_XMLNode*)this; 697 CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
703 while (pNode != NULL) { 698 while (pNode != NULL) {
704 if (pNode->GetType() != FDE_XMLNODE_Element) { 699 if (pNode->GetType() != FDE_XMLNODE_Element) {
705 break; 700 break;
706 } 701 }
707 CFDE_XMLElement* pElement = (CFDE_XMLElement*)pNode; 702 CFDE_XMLElement* pElement = (CFDE_XMLElement*)pNode;
708 if (!pElement->HasAttribute(wsAttri)) { 703 if (!pElement->HasAttribute(wsAttri)) {
709 pNode = pNode->GetNodeItem(IFDE_XMLNode::Parent); 704 pNode = pNode->GetNodeItem(CFDE_XMLNode::Parent);
710 continue; 705 continue;
711 } 706 }
712 pElement->GetString(wsAttri, wsNamespace); 707 pElement->GetString(wsAttri, wsNamespace);
713 break; 708 break;
714 } 709 }
715 } 710 }
716 int32_t CFDE_XMLElement::CountAttributes() const { 711 int32_t CFDE_XMLElement::CountAttributes() const {
717 return m_Attributes.GetSize() / 2; 712 return m_Attributes.GetSize() / 2;
718 } 713 }
719 FX_BOOL CFDE_XMLElement::GetAttribute(int32_t index, 714 FX_BOOL CFDE_XMLElement::GetAttribute(int32_t index,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 pChild = pChild->m_pNext; 820 pChild = pChild->m_pNext;
826 } 821 }
827 wsText = buffer.GetWideString(); 822 wsText = buffer.GetWideString();
828 } 823 }
829 void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { 824 void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) {
830 if (wsText.GetLength() < 1) { 825 if (wsText.GetLength() < 1) {
831 return; 826 return;
832 } 827 }
833 InsertChildNode(new CFDE_XMLText(wsText)); 828 InsertChildNode(new CFDE_XMLText(wsText));
834 } 829 }
835 IFDE_XMLText* IFDE_XMLText::Create(const CFX_WideString& wsText) {
836 return (IFDE_XMLText*)new CFDE_XMLText(wsText);
837 }
838 CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText) 830 CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText)
839 : CFDE_XMLNode(), m_wsText(wsText) {} 831 : CFDE_XMLNode(), m_wsText(wsText) {}
840 CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) { 832 CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) {
841 CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText); 833 CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText);
842 return pClone; 834 return pClone;
843 } 835 }
844 IFDE_XMLCharData* IFDE_XMLCharData::Create(const CFX_WideString& wsCData) { 836
845 return (IFDE_XMLCharData*)new CFDE_XMLCharData(wsCData);
846 }
847 CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData) 837 CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData)
848 : CFDE_XMLDeclaration(), m_wsCharData(wsCData) {} 838 : CFDE_XMLDeclaration(), m_wsCharData(wsCData) {}
849 CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) { 839 CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) {
850 CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData); 840 CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData);
851 return pClone; 841 return pClone;
852 } 842 }
853 IFDE_XMLDoc* IFDE_XMLDoc::Create() { 843
854 return (IFDE_XMLDoc*)new CFDE_XMLDoc;
855 }
856 CFDE_XMLDoc::CFDE_XMLDoc() 844 CFDE_XMLDoc::CFDE_XMLDoc()
857 : m_pRoot(NULL), m_pSyntaxParser(NULL), m_pXMLParser(NULL) { 845 : m_pRoot(NULL), m_pSyntaxParser(NULL), m_pXMLParser(NULL) {
858 Reset(TRUE); 846 Reset(TRUE);
859 CFDE_XMLInstruction* pXML = new CFDE_XMLInstruction(L"xml"); 847 CFDE_XMLInstruction* pXML = new CFDE_XMLInstruction(L"xml");
860 m_pRoot->InsertChildNode(pXML); 848 m_pRoot->InsertChildNode(pXML);
861 } 849 }
862 CFDE_XMLDoc::~CFDE_XMLDoc() { 850 CFDE_XMLDoc::~CFDE_XMLDoc() {
863 Reset(FALSE); 851 Reset(FALSE);
864 } 852 }
865 void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { 853 void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 iTextDataSize *= 128; 900 iTextDataSize *= 128;
913 if (iTextDataSize < 128) { 901 if (iTextDataSize < 128) {
914 iTextDataSize = 128; 902 iTextDataSize = 128;
915 } 903 }
916 m_pStream = pXMLStream; 904 m_pStream = pXMLStream;
917 uint16_t wCodePage = m_pStream->GetCodePage(); 905 uint16_t wCodePage = m_pStream->GetCodePage();
918 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && 906 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
919 wCodePage != FX_CODEPAGE_UTF8) { 907 wCodePage != FX_CODEPAGE_UTF8) {
920 m_pStream->SetCodePage(FX_CODEPAGE_UTF8); 908 m_pStream->SetCodePage(FX_CODEPAGE_UTF8);
921 } 909 }
922 m_pSyntaxParser = IFDE_XMLSyntaxParser::Create(); 910 m_pSyntaxParser = new CFDE_XMLSyntaxParser;
923 if (m_pSyntaxParser == NULL) { 911 if (m_pSyntaxParser == NULL) {
924 return FALSE; 912 return FALSE;
925 } 913 }
926 m_pSyntaxParser->Init(m_pStream, iXMLPlaneSize, iTextDataSize); 914 m_pSyntaxParser->Init(m_pStream, iXMLPlaneSize, iTextDataSize);
927 if (pHandler == NULL) { 915 if (pHandler == NULL) {
928 m_pXMLParser = new CFDE_XMLDOMParser(m_pRoot, m_pSyntaxParser); 916 m_pXMLParser = new CFDE_XMLDOMParser(m_pRoot, m_pSyntaxParser);
929 } else { 917 } else {
930 m_pXMLParser = new CFDE_XMLSAXParser(pHandler, m_pSyntaxParser); 918 m_pXMLParser = new CFDE_XMLSAXParser(pHandler, m_pSyntaxParser);
931 } 919 }
932 return TRUE; 920 return TRUE;
933 } 921 }
934 FX_BOOL CFDE_XMLDoc::LoadXML(IFDE_XMLParser* pXMLParser) { 922 FX_BOOL CFDE_XMLDoc::LoadXML(CFDE_XMLParser* pXMLParser) {
935 if (pXMLParser == NULL) { 923 if (pXMLParser == NULL) {
936 return FALSE; 924 return FALSE;
937 } 925 }
938 Reset(TRUE); 926 Reset(TRUE);
939 m_pXMLParser = pXMLParser; 927 m_pXMLParser = pXMLParser;
940 return m_pXMLParser != NULL; 928 return m_pXMLParser != NULL;
941 } 929 }
942 int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { 930 int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) {
943 if (m_iStatus >= 100) { 931 if (m_iStatus >= 100) {
944 return m_iStatus; 932 return m_iStatus;
945 } 933 }
946 FXSYS_assert(m_pXMLParser != NULL); 934 FXSYS_assert(m_pXMLParser != NULL);
947 return m_iStatus = m_pXMLParser->DoParser(pPause); 935 return m_iStatus = m_pXMLParser->DoParser(pPause);
948 } 936 }
949 void CFDE_XMLDoc::CloseXML() { 937 void CFDE_XMLDoc::CloseXML() {
950 ReleaseParser(); 938 ReleaseParser();
951 } 939 }
952 void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, IFDE_XMLNode* pINode) { 940 void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
953 CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; 941 CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode;
954 FXSYS_assert(pXMLStream != NULL && pNode != NULL); 942 FXSYS_assert(pXMLStream != NULL && pNode != NULL);
955 switch (pNode->GetType()) { 943 switch (pNode->GetType()) {
956 case FDE_XMLNODE_Instruction: { 944 case FDE_XMLNODE_Instruction: {
957 CFX_WideString ws; 945 CFX_WideString ws;
958 CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode; 946 CFDE_XMLInstruction* pInstruction = (CFDE_XMLInstruction*)pNode;
959 if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) { 947 if (pInstruction->m_wsTarget.CompareNoCase(L"xml") == 0) {
960 ws = L"<?xml version=\"1.0\" encoding=\""; 948 ws = L"<?xml version=\"1.0\" encoding=\"";
961 uint16_t wCodePage = pXMLStream->GetCodePage(); 949 uint16_t wCodePage = pXMLStream->GetCodePage();
962 if (wCodePage == FX_CODEPAGE_UTF16LE) { 950 if (wCodePage == FX_CODEPAGE_UTF16LE) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 pXMLStream->WriteString(ws, ws.GetLength()); 1011 pXMLStream->WriteString(ws, ws.GetLength());
1024 } 1012 }
1025 if (pNode->m_pChild == NULL) { 1013 if (pNode->m_pChild == NULL) {
1026 ws = L"\n/>"; 1014 ws = L"\n/>";
1027 pXMLStream->WriteString(ws, ws.GetLength()); 1015 pXMLStream->WriteString(ws, ws.GetLength());
1028 } else { 1016 } else {
1029 ws = L"\n>"; 1017 ws = L"\n>";
1030 pXMLStream->WriteString(ws, ws.GetLength()); 1018 pXMLStream->WriteString(ws, ws.GetLength());
1031 CFDE_XMLNode* pChild = pNode->m_pChild; 1019 CFDE_XMLNode* pChild = pNode->m_pChild;
1032 while (pChild != NULL) { 1020 while (pChild != NULL) {
1033 SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pChild); 1021 SaveXMLNode(pXMLStream, static_cast<CFDE_XMLNode*>(pChild));
1034 pChild = pChild->m_pNext; 1022 pChild = pChild->m_pNext;
1035 } 1023 }
1036 ws = L"</"; 1024 ws = L"</";
1037 ws += ((CFDE_XMLElement*)pNode)->m_wsTag; 1025 ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
1038 ws += L"\n>"; 1026 ws += L"\n>";
1039 pXMLStream->WriteString(ws, ws.GetLength()); 1027 pXMLStream->WriteString(ws, ws.GetLength());
1040 } 1028 }
1041 } break; 1029 } break;
1042 case FDE_XMLNODE_Text: { 1030 case FDE_XMLNODE_Text: {
1043 CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText; 1031 CFX_WideString ws = ((CFDE_XMLText*)pNode)->m_wsText;
(...skipping 27 matching lines...) Expand all
1071 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && 1059 if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
1072 wCodePage != FX_CODEPAGE_UTF8) { 1060 wCodePage != FX_CODEPAGE_UTF8) {
1073 wCodePage = FX_CODEPAGE_UTF8; 1061 wCodePage = FX_CODEPAGE_UTF8;
1074 pXMLStream->SetCodePage(wCodePage); 1062 pXMLStream->SetCodePage(wCodePage);
1075 } 1063 }
1076 if (bSaveBOM) { 1064 if (bSaveBOM) {
1077 pXMLStream->WriteString(L"\xFEFF", 1); 1065 pXMLStream->WriteString(L"\xFEFF", 1);
1078 } 1066 }
1079 CFDE_XMLNode* pNode = m_pRoot->m_pChild; 1067 CFDE_XMLNode* pNode = m_pRoot->m_pChild;
1080 while (pNode != NULL) { 1068 while (pNode != NULL) {
1081 SaveXMLNode(pXMLStream, (IFDE_XMLNode*)pNode); 1069 SaveXMLNode(pXMLStream, static_cast<CFDE_XMLNode*>(pNode));
1082 pNode = pNode->m_pNext; 1070 pNode = pNode->m_pNext;
1083 } 1071 }
1084 if (pXMLStream == m_pStream) { 1072 if (pXMLStream == m_pStream) {
1085 int32_t iPos = pXMLStream->GetPosition(); 1073 int32_t iPos = pXMLStream->GetPosition();
1086 pXMLStream->SetLength(iPos); 1074 pXMLStream->SetLength(iPos);
1087 } 1075 }
1088 } 1076 }
1089 CFDE_XMLDOMParser::CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, 1077 CFDE_XMLDOMParser::CFDE_XMLDOMParser(CFDE_XMLNode* pRoot,
1090 IFDE_XMLSyntaxParser* pParser) 1078 CFDE_XMLSyntaxParser* pParser)
1091 : m_pParser(pParser), 1079 : m_pParser(pParser),
1092 m_pParent(pRoot), 1080 m_pParent(pRoot),
1093 m_pChild(NULL), 1081 m_pChild(NULL),
1094 m_NodeStack(16), 1082 m_NodeStack(16),
1095 m_ws1(), 1083 m_ws1(),
1096 m_ws2() { 1084 m_ws2() {
1097 m_NodeStack.Push(m_pParent); 1085 m_NodeStack.Push(m_pParent);
1098 } 1086 }
1099 CFDE_XMLDOMParser::~CFDE_XMLDOMParser() { 1087 CFDE_XMLDOMParser::~CFDE_XMLDOMParser() {
1100 m_NodeStack.RemoveAll(); 1088 m_NodeStack.RemoveAll();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 dwRet == FDE_XMLSYNTAXSTATUS_EOS) { 1188 dwRet == FDE_XMLSYNTAXSTATUS_EOS) {
1201 break; 1189 break;
1202 } 1190 }
1203 if (pPause != NULL && iCount > 500 && pPause->NeedToPauseNow()) { 1191 if (pPause != NULL && iCount > 500 && pPause->NeedToPauseNow()) {
1204 break; 1192 break;
1205 } 1193 }
1206 } 1194 }
1207 return m_pParser->GetStatus(); 1195 return m_pParser->GetStatus();
1208 } 1196 }
1209 CFDE_XMLSAXParser::CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, 1197 CFDE_XMLSAXParser::CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler,
1210 IFDE_XMLSyntaxParser* pParser) 1198 CFDE_XMLSyntaxParser* pParser)
1211 : m_pHandler(pHandler), 1199 : m_pHandler(pHandler),
1212 m_pParser(pParser), 1200 m_pParser(pParser),
1213 m_TagStack(16), 1201 m_TagStack(16),
1214 m_pTagTop(NULL), 1202 m_pTagTop(NULL),
1215 m_ws1(), 1203 m_ws1(),
1216 m_ws2() {} 1204 m_ws2() {}
1217 CFDE_XMLSAXParser::~CFDE_XMLSAXParser() { 1205 CFDE_XMLSAXParser::~CFDE_XMLSAXParser() {
1218 m_TagStack.RemoveAll(); 1206 m_TagStack.RemoveAll();
1219 m_ws1.Empty(); 1207 m_ws1.Empty();
1220 m_ws2.Empty(); 1208 m_ws2.Empty();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 void CFDE_BlockBuffer::ClearBuffer() { 1429 void CFDE_BlockBuffer::ClearBuffer() {
1442 m_iBufferSize = 0; 1430 m_iBufferSize = 0;
1443 int32_t iSize = m_BlockArray.GetSize(); 1431 int32_t iSize = m_BlockArray.GetSize();
1444 for (int32_t i = 0; i < iSize; i++) { 1432 for (int32_t i = 0; i < iSize; i++) {
1445 FX_Free(m_BlockArray[i]); 1433 FX_Free(m_BlockArray[i]);
1446 m_BlockArray[i] = NULL; 1434 m_BlockArray[i] = NULL;
1447 } 1435 }
1448 m_BlockArray.RemoveAll(); 1436 m_BlockArray.RemoveAll();
1449 } 1437 }
1450 1438
1451 IFDE_XMLSyntaxParser* IFDE_XMLSyntaxParser::Create() {
1452 return new CFDE_XMLSyntaxParser;
1453 }
1454
1455 CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser() 1439 CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser()
1456 : m_pStream(nullptr), 1440 : m_pStream(nullptr),
1457 m_iXMLPlaneSize(-1), 1441 m_iXMLPlaneSize(-1),
1458 m_iCurrentPos(0), 1442 m_iCurrentPos(0),
1459 m_iCurrentNodeNum(-1), 1443 m_iCurrentNodeNum(-1),
1460 m_iLastNodeNum(-1), 1444 m_iLastNodeNum(-1),
1461 m_iParsedChars(0), 1445 m_iParsedChars(0),
1462 m_iParsedBytes(0), 1446 m_iParsedBytes(0),
1463 m_pBuffer(nullptr), 1447 m_pBuffer(nullptr),
1464 m_iBufferChars(0), 1448 m_iBufferChars(0),
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); 2074 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE);
2091 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); 2075 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
2092 m_iEntityStart = -1; 2076 m_iEntityStart = -1;
2093 } else { 2077 } else {
2094 if (m_iEntityStart < 0 && ch == L'&') { 2078 if (m_iEntityStart < 0 && ch == L'&') {
2095 m_iEntityStart = m_iDataLength - 1; 2079 m_iEntityStart = m_iDataLength - 1;
2096 } 2080 }
2097 } 2081 }
2098 m_pStart++; 2082 m_pStart++;
2099 } 2083 }
OLDNEW
« no previous file with comments | « xfa/fde/xml/fde_xml_imp.h ('k') | xfa/fxfa/app/xfa_ffdoc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698