00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SEN_FRAGMENT_BASE_H
00023 #define SEN_FRAGMENT_BASE_H
00024
00025
00026 #include <s32mem.h>
00027
00028 #include <Xml/ContentHandler.h>
00029 #include <RSenDocument.h>
00030 #include <SenParser.h>
00031 #include <XmlEngElement.h>
00032
00033 using namespace Xml;
00034
00035
00036
00037
00038 const TInt KSenStateNotSet = -1;
00039 const TInt KSenStateIgnore = 0;
00040 const TInt KSenStateSave = 1;
00041 const TInt KSenStateResume = 2;
00042 const TInt KSenStateDelegate = 3;
00043
00044
00045 class RWriteStream;
00046
00047 class CSenNamespaceData;
00048
00049
00050
00066 class CSenFragmentBase : public CBase, public MContentHandler
00067 {
00068 friend class CSenParserImpl;
00069
00070 public:
00071
00078 IMPORT_C static CSenFragmentBase* NewL(const TXmlEngElement& aElement);
00079
00085 IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aLocalName);
00086
00093 IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00094 const TDesC8& aLocalName);
00095
00103 IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00104 const TDesC8& aLocalName,
00105 const TDesC8& aPrefix);
00106
00115 IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00116 const TDesC8& aLocalName,
00117 const TDesC8& aPrefix,
00118 const RAttributeArray& apAttrs);
00119
00130 IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00131 const TDesC8& aLocalName,
00132 const TDesC8& aPrefix,
00133 const RAttributeArray& apAttrs,
00134 TXmlEngElement& aParent);
00135
00148 IMPORT_C static CSenFragmentBase* NewL(const TDesC8& aNsUri,
00149 const TDesC8& aLocalName,
00150 const TDesC8& aPrefix,
00151 const RAttributeArray& apAttrs,
00152 TXmlEngElement& aParent,
00153 RSenDocument& aOwnerDocument);
00154
00164 IMPORT_C static CSenFragmentBase* NewL(TXmlEngElement& aRootElement,
00165 RSenDocument& aOwnerDocument);
00166
00170 IMPORT_C virtual ~CSenFragmentBase();
00171
00172
00173
00174
00175
00182 IMPORT_C virtual void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode);
00183
00190 IMPORT_C virtual void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
00191
00198 IMPORT_C virtual void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
00199
00206 IMPORT_C virtual void OnEndDocumentL(TInt aErrorCode);
00207
00214 IMPORT_C virtual void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
00215
00222 IMPORT_C virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
00223
00230 IMPORT_C virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
00231
00238 IMPORT_C virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt ErrorCode);
00239
00246 IMPORT_C virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
00247
00254 IMPORT_C virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
00255
00262 IMPORT_C virtual void OnError(TInt aErrorCode);
00263
00270 IMPORT_C virtual TAny* GetExtendedInterface(const TInt32 aUid);
00271
00272
00273
00279 IMPORT_C virtual TPtrC8 ContentL();
00280
00288 IMPORT_C virtual TXmlEngNamespace Namespace(const TDesC8& aPrefix);
00289
00296
00297
00302 IMPORT_C virtual void ResetContentL();
00303
00308 IMPORT_C virtual TPtrC8 LocalName() const;
00309
00315 IMPORT_C virtual TPtrC8 NsUri() const;
00316
00322 IMPORT_C virtual TPtrC8 NsPrefix() const;
00323
00331 IMPORT_C virtual TXmlEngElement AsElementL();
00332
00340 IMPORT_C virtual RSenDocument& AsDocumentL();
00341
00351 IMPORT_C virtual TXmlEngElement ExtractElement();
00352
00361 IMPORT_C virtual void OnDelegateParsingL(CSenFragmentBase& aDelegate);
00362
00374 IMPORT_C virtual void OnDelegateParsingL(const RTagInfo& aElement,
00375 const RAttributeArray& aAttributes,
00376 TInt aErrorCode);
00377
00383 IMPORT_C virtual void SetOwner(CSenFragmentBase& aFragment);
00384
00395 IMPORT_C virtual void OnResumeParsingFromL(const RTagInfo& aElement, TInt aErrorCode);
00396
00406
00407
00416 IMPORT_C void OnWriteStartElementL(const RTagInfo& aElement,
00417 const RAttributeArray& aAttributes);
00418
00426 IMPORT_C void OnWriteEndElementL(const RTagInfo& aElement);
00427
00433 IMPORT_C virtual HBufC* AsXmlUnicodeL();
00434
00440 IMPORT_C virtual HBufC8* AsXmlL();
00441
00448 IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWs);
00449
00460 IMPORT_C virtual TBool ConsistsOfL(CSenFragmentBase& aCandidate);
00461
00462
00463 IMPORT_C void SetContentHandler(CSenFragmentBase& aContentHandler);
00464
00469 IMPORT_C void SetDocument(RSenDocument& aDocument);
00470
00471 protected:
00472
00476 IMPORT_C CSenFragmentBase();
00477
00488 IMPORT_C void BaseConstructL(const TXmlEngElement& aSrc);
00489
00495 IMPORT_C void BaseConstructL(const TDesC8& aLocalName);
00496
00503 IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00504 const TDesC8& aLocalName);
00505
00513 IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00514 const TDesC8& aLocalName,
00515 const TDesC8& aPrefix);
00524 IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00525 const TDesC8& aLocalName,
00526 const TDesC8& aPrefix,
00527 const RAttributeArray& aAttrs);
00528
00538 IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00539 const TDesC8& aLocalName,
00540 const TDesC8& aPrefix,
00541 const RAttributeArray& aAttrs,
00542 TXmlEngElement& aParent);
00543
00555 IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
00556 const TDesC8& aLocalName,
00557 const TDesC8& aPrefix,
00558 const RAttributeArray& aAttrs,
00559 TXmlEngElement& aParent,
00560 RSenDocument& aOwnerDocument);
00561
00570 IMPORT_C void BaseConstructL(TXmlEngElement& aRootElement,
00571 RSenDocument& aOwnerDocument);
00572
00573
00574
00580 IMPORT_C virtual void AddAttributesL(const RAttributeArray& apAttrs);
00581
00587 IMPORT_C virtual void AddAttributesToElementL(TXmlEngElement element,
00588 const RAttributeArray& apAttrs);
00589
00597 void RenameL(const TDesC8& aLocalName, const TDesC8& aPrefix, const TDesC8& aNamespace);
00598
00605 void RenameL(const TDesC8& aLocalName, const TDesC8& aNamespace);
00606
00612 void RenameLocalNameL(const TDesC8& aLocalName);
00613
00619 void RenameNamespaceL(const TDesC8& aNamespace);
00620
00626 void RenamePrefixL(const TDesC8& aPrefix);
00627
00634 void RenameNamespaceL(const TDesC8& aPrefix, const TDesC8& aNamespace);
00635
00648 IMPORT_C TXmlEngElement SetContentOfL(const TDesC8& aLocalName,
00649 const TDesC8& aContent);
00657 IMPORT_C TPtrC8 ContentOf(const TDesC8& aLocalName);
00658
00659 IMPORT_C virtual TBool ConsistsOfL(TXmlEngElement& aElement, TXmlEngElement& aCandidate);
00660
00665 IMPORT_C virtual void AddNamespacesL();
00666
00673 IMPORT_C virtual void SetContentL(const TDesC8& aContent);
00674
00680 IMPORT_C virtual void AddContentL(const TDesC8& aContent);
00681
00689 IMPORT_C void StartSavingContent();
00690
00691
00692 private:
00693
00700 IMPORT_C virtual void SetParser(CSenParser& aParser);
00701
00702 protected:
00703
00704
00705
00706
00707
00708
00709 TInt iState;
00710
00711
00712 TXmlEngElement iElement;
00713
00714
00715 RSenDocument iDocument;
00716
00717
00718 CSenParser* ipParser;
00719
00720
00721 CSenFragmentBase* ipOwner;
00722 CSenFragmentBase* ipDelegate;
00723
00724 RPointerArray<CSenNamespaceData>* ipNamespaceArray;
00725
00726 CBufFlat* ipContentBuf;
00727 RBufWriteStream* ipContentWriteStream;
00728 };
00729
00730 class CSenNamespaceData : public CBase
00731 {
00732 public:
00733 virtual ~CSenNamespaceData();
00734
00735 public:
00736 HBufC8* ipLocalName;
00737 HBufC8* ipNamespaceUri;
00738 HBufC8* ipPrefix;
00739 };
00740
00741 #endif //SEN_FRAGMENT_BASE_H
00742
00743
00744
00745
00746