epoc32/include/mw/sendomfragmentbase.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
     1.1 --- a/epoc32/include/mw/sendomfragmentbase.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/mw/sendomfragmentbase.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,478 @@
     1.4 -sendomfragmentbase.h
     1.5 +/*
     1.6 +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:        Class implements XML DOM fragment using libxml2 classes
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +
    1.27 +
    1.28 +
    1.29 +
    1.30 +#ifndef SEN_DOM_FRAGMENT_BASE_H
    1.31 +#define SEN_DOM_FRAGMENT_BASE_H
    1.32 +
    1.33 +//  INCLUDES
    1.34 +#include <SenFragmentBase.h>
    1.35 +
    1.36 +// FORWARD DECLARATIONS
    1.37 +class RFileLogger;
    1.38 +
    1.39 +// CLASS DECLARATION
    1.40 +
    1.41 +/**
    1.42 +* Class implements DOM fragment functionality
    1.43 +* The implementation further extends CSenBaseFragment
    1.44 +* functionality. In DOM fragment, all child elements
    1.45 +* are parsed into separate element objects. This makes
    1.46 +* it possible to reference any child which offer methods
    1.47 +* declared in XML element interface. Any such element
    1.48 +* can also be easily extracted (detached) from this
    1.49 +* root DOM fragment.
    1.50 +* @lib SenFragment.dll
    1.51 +* @since Series60 4.0
    1.52 +*/
    1.53 +class CSenDomFragmentBase : public CSenFragmentBase
    1.54 +    {
    1.55 +    public:  // Constructors and destructor
    1.56 +        
    1.57 +        /**
    1.58 +        * Basic contructor. Should be used only for parsing new fragments etc. 
    1.59 +        * Constructing DomFragments for other use should be done with at least 
    1.60 +        * localname parameter.
    1.61 +        * @since Series60 4.0
    1.62 +        */
    1.63 +        IMPORT_C static CSenDomFragmentBase* NewL();
    1.64 +
    1.65 +        /**
    1.66 +        * Basic constructor.
    1.67 +        * @since Series60 4.0
    1.68 +        * @param aElement Element to copy construction data from.
    1.69 +        */
    1.70 +        IMPORT_C static CSenDomFragmentBase* NewL(
    1.71 +            const TXmlEngElement& aElement);
    1.72 +
    1.73 +        /**
    1.74 +        * Basic constructor.
    1.75 +        * @since Series60 4.0
    1.76 +        * @param aLocalName is the XML localname of this fragment
    1.77 +        */
    1.78 +        IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aLocalName);
    1.79 +
    1.80 +        /**
    1.81 +        * Basic constructor.
    1.82 +        * @since Series60 4.0
    1.83 +        * @param aNsUri     is the XML namespace user of this fragment
    1.84 +        * @param aLocalName is the XML localname of this fragment
    1.85 +        */
    1.86 +        IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
    1.87 +                                              const TDesC8& aLocalName);
    1.88 +
    1.89 +        /**
    1.90 +        * Basic constructor.
    1.91 +        * @since Series60 4.0
    1.92 +        * @param aNsUri     is the XML namespace user of this fragment
    1.93 +        * @param aLocalName is the XML localname of this fragment
    1.94 +        * @param aPrefix    is the XML prefix of this fragment
    1.95 +        */
    1.96 +        IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
    1.97 +                                              const TDesC8& aLocalName,
    1.98 +                                              const TDesC8& aPrefix);
    1.99 +
   1.100 +        /**
   1.101 +        * Basic constructor.
   1.102 +        * @since Series60 4.0
   1.103 +        * @param aNsUri     is the XML namespace of this fragment
   1.104 +        * @param aLocalName is the XML localname of this fragment
   1.105 +        * @param aPrefix    is the prefix of this fragment
   1.106 +        * @param aAttrs     are the XML attributes of this fragment
   1.107 +        */
   1.108 +        IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
   1.109 +                                              const TDesC8& aLocalName,
   1.110 +                                              const TDesC8& aPrefix,
   1.111 +                                              const RAttributeArray& aAttrs);
   1.112 +
   1.113 +        /**
   1.114 +        * Basic constructor.
   1.115 +        * @since Series60 4.0
   1.116 +        * @param aNsUri     is the XML namespace of this fragment
   1.117 +        * @param aLocalName is the XML localname of this fragment
   1.118 +        * @param aPrefix    is the prefix of this fragment
   1.119 +        * @param aAttrs     are the XML attributes of this fragment
   1.120 +        * @param aParent    is the parent XML element of this fragment
   1.121 +        */
   1.122 +        IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
   1.123 +                                              const TDesC8& aLocalName,
   1.124 +                                              const TDesC8& aPrefix,
   1.125 +                                              const RAttributeArray& aAttrs,
   1.126 +                                              TXmlEngElement& aParent);
   1.127 +
   1.128 +        /**
   1.129 +        * Basic constructor.
   1.130 +        * @since Series60 4.0
   1.131 +        * @param aNsUri         is the XML namespace of this fragment
   1.132 +        * @param aLocalName     is the XML localname of this fragment
   1.133 +        * @param aPrefix        is the prefix of this fragment
   1.134 +        * @param aAttrs         are the XML attributes of this fragment
   1.135 +        * @param aParent        is the parent XML element of this fragment
   1.136 +        * @param aOwnerDocument is the document which will be the owner of
   1.137 +        *                       the elements of this fragment
   1.138 +        */
   1.139 +        IMPORT_C static CSenDomFragmentBase* NewL(const TDesC8& aNsUri,
   1.140 +                                              const TDesC8& aLocalName,
   1.141 +                                              const TDesC8& aPrefix,
   1.142 +                                              const RAttributeArray& aAttrs,
   1.143 +                                              TXmlEngElement& aParent,
   1.144 +                                              RSenDocument& aOwnerDocument);
   1.145 +        /**
   1.146 +        * Destructor.
   1.147 +        */
   1.148 +        IMPORT_C virtual ~CSenDomFragmentBase();
   1.149 +
   1.150 +        // New functions
   1.151 +    
   1.152 +        /**
   1.153 +        * Initiates the parsing chain where new delegate will be created with
   1.154 +        * given parameters and parsing will be delegated to it. Should not be
   1.155 +        * called externally.
   1.156 +        * @since Series60 4.0
   1.157 +        * @param aElement     The RTagInfo class holding information that describes
   1.158 +        *                     the element.
   1.159 +        * @param aAttributes  The attributes of the new element
   1.160 +        * @param aErrorCode   Error code
   1.161 +        */
   1.162 +        IMPORT_C virtual void ExpandL(const RTagInfo& aElement,
   1.163 +                                      const RAttributeArray& aAttributes,
   1.164 +                                      TInt aErrorCode);
   1.165 +                                      
   1.166 +        // Functions from base classes
   1.167 +
   1.168 +        // From CSenBaseFragment
   1.169 +        
   1.170 +        /**
   1.171 +        * Resumes the parsing. Usually called by the delegate fragment which was
   1.172 +        *                      parsing itself after DelegateParsingL().
   1.173 +        * @since Series60 4.0
   1.174 +        * @param aElement     The RTagInfo class holding information that describes
   1.175 +        *                     the element.
   1.176 +        * @param aErrorCode   Error code
   1.177 +        */
   1.178 +        IMPORT_C virtual void OnResumeParsingFromL(const RTagInfo& aElement,
   1.179 +                                           TInt aErrorCode);
   1.180 +
   1.181 +        /**
   1.182 +        * Sets the attributes for the fragment.
   1.183 +        * @since Series60 4.0
   1.184 +        * @param aAttributes    The array of attributes.
   1.185 +        */
   1.186 +        IMPORT_C virtual void AddAttributesL(const RAttributeArray& aAttrs);
   1.187 +        
   1.188 +        /**
   1.189 +         * Gets the fragment data as an UTF-8 form XML.
   1.190 +         * @since Series60 4.0
   1.191 +         * @return  fragment as XML. Caller takes ownership.
   1.192 +         */ 
   1.193 +        IMPORT_C virtual HBufC8* AsXmlL();
   1.194 +        
   1.195 +        /**
   1.196 +         * Callback function implementing the XML content handler interface.
   1.197 +         * Inheriting classes can override these.
   1.198 +         * @since Series60 4.0
   1.199 +         * @see MContentHandler
   1.200 +         */
   1.201 +    	IMPORT_C virtual void OnStartElementL(const RTagInfo& aElement,
   1.202 +    	                                      const RAttributeArray& aAttributes,
   1.203 +    	                                      TInt aErrorCode);
   1.204 +
   1.205 +        /**
   1.206 +         * Callback function implementing the XML content handler interface.
   1.207 +         * Inheriting classes can override these.
   1.208 +         * @since Series60 4.0
   1.209 +         * @see MContentHandler
   1.210 +         */
   1.211 +        IMPORT_C virtual void OnContentL(const TDesC8& aBytes,
   1.212 +                                         TInt aErrorCode);
   1.213 +        
   1.214 +        /**
   1.215 +         * Overriding content writing from CSenBaseFragment to do nothing in
   1.216 +         * DOM fragment (because the tree is expanded).
   1.217 +         * @since Series60 4.0
   1.218 +         * @param aElement      The RTagInfo class holding information that
   1.219 +         *                      describes the element.
   1.220 +         * @param aAttributes   The attributes of the new element
   1.221 +         */
   1.222 +        IMPORT_C void OnWriteStartElementL(const RTagInfo& aElement, 
   1.223 +                                           const RAttributeArray& aAttributes);
   1.224 +
   1.225 +        /**
   1.226 +         * Overriding content writing from CSenBaseFragment to do nothing in
   1.227 +         * DOM fragment (because the tree is expanded).
   1.228 +         * @since Series60 4.0
   1.229 +         * @param aElement      The RTagInfo class holding information that
   1.230 +         *                      describes the element.
   1.231 +         */
   1.232 +        IMPORT_C void OnWriteEndElementL(const RTagInfo& aElement);        
   1.233 +        /**
   1.234 +         * Callback function implementing the XML content handler interface.
   1.235 +         * Inheriting classes can override these.
   1.236 +         * @since Series60 4.0
   1.237 +         * @see MContentHandler
   1.238 +         */
   1.239 +        IMPORT_C virtual void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
   1.240 +
   1.241 +        /**
   1.242 +         * Callback function implementing the XML content handler interface.
   1.243 +         * Inheriting classes can override these.
   1.244 +         * @since Series60 4.0
   1.245 +         * @see MContentHandler
   1.246 +         */
   1.247 +    	IMPORT_C virtual void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
   1.248 +
   1.249 +        /**
   1.250 +         * Callback function implementing the XML content handler interface.
   1.251 +         * Inheriting classes can override these.
   1.252 +         * @since Series60 4.0
   1.253 +         * @see MContentHandler
   1.254 +         */
   1.255 +    	IMPORT_C virtual void OnEndDocumentL(TInt aErrorCode);
   1.256 +
   1.257 +        /**
   1.258 +         * Callback function implementing the XML content handler interface.
   1.259 +         * Inheriting classes can override these.
   1.260 +         * @since Series60 4.0
   1.261 +         * @see MContentHandler
   1.262 +         */
   1.263 +    	IMPORT_C virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
   1.264 +
   1.265 +        /**
   1.266 +         * Callback function implementing the XML content handler interface.
   1.267 +         * Inheriting classes can override these.
   1.268 +         * @since Series60 4.0
   1.269 +         * @see MContentHandler
   1.270 +         */
   1.271 +    	IMPORT_C virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
   1.272 +
   1.273 +        /**
   1.274 +         * Callback function implementing the XML content handler interface.
   1.275 +         * Inheriting classes can override these.
   1.276 +         * @since Series60 4.0
   1.277 +         * @see MContentHandler
   1.278 +         */
   1.279 +    	IMPORT_C virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt ErrorCode);
   1.280 +
   1.281 +        /**
   1.282 +         * Callback function implementing the XML content handler interface.
   1.283 +         * Inheriting classes can override these.
   1.284 +         * @since Series60 4.0
   1.285 +         * @see MContentHandler
   1.286 +         */
   1.287 +    	IMPORT_C virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
   1.288 +
   1.289 +        /**
   1.290 +         * Callback function implementing the XML content handler interface.
   1.291 +         * Inheriting classes can override these.
   1.292 +         * @since Series60 4.0
   1.293 +         * @see MContentHandler
   1.294 +         */
   1.295 +    	IMPORT_C virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
   1.296 +
   1.297 +        /**
   1.298 +         * Callback function implementing the XML content handler interface.
   1.299 +         * Inheriting classes can override these.
   1.300 +         * @since Series60 4.0
   1.301 +         * @see MContentHandler
   1.302 +         */
   1.303 +    	IMPORT_C virtual void OnError(TInt aErrorCode);
   1.304 +
   1.305 +        /**
   1.306 +         * Callback function implementing the XML content handler interface.
   1.307 +         * Inheriting classes can override these.
   1.308 +         * @since Series60 4.0
   1.309 +         * @see MContentHandler
   1.310 +         */
   1.311 +    	IMPORT_C virtual TAny* GetExtendedInterface(const TInt32 aUid);
   1.312 +
   1.313 +        // From CSenBaseFragment
   1.314 +        IMPORT_C virtual TPtrC8 ContentL();
   1.315 +        
   1.316 +        IMPORT_C virtual TXmlEngNamespace Namespace(const TDesC8& aPrefix);
   1.317 +        
   1.318 +//        IMPORT_C virtual void DetachL();
   1.319 +        
   1.320 +        IMPORT_C virtual void ResetContentL();
   1.321 +
   1.322 +        IMPORT_C virtual TPtrC8 LocalName() const;
   1.323 +        
   1.324 +        IMPORT_C virtual TPtrC8 NsUri() const;
   1.325 +
   1.326 +        IMPORT_C virtual TPtrC8 NsPrefix() const;    
   1.327 +
   1.328 +        IMPORT_C virtual TXmlEngElement AsElementL();
   1.329 +
   1.330 +        IMPORT_C virtual RSenDocument& AsDocumentL();
   1.331 +
   1.332 +        IMPORT_C virtual TXmlEngElement ExtractElement();
   1.333 +        
   1.334 +        IMPORT_C virtual void OnDelegateParsingL(CSenFragmentBase& aDelegate);
   1.335 +
   1.336 +        IMPORT_C virtual void OnDelegateParsingL(const RTagInfo& aElement, 
   1.337 +                                                 const RAttributeArray& aAttributes, 
   1.338 +                                                 TInt aErrorCode);
   1.339 +        
   1.340 +        IMPORT_C virtual void SetOwner(CSenFragmentBase& aFragment);
   1.341 +
   1.342 +        IMPORT_C virtual HBufC* AsXmlUnicodeL();
   1.343 +
   1.344 +        IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWs);
   1.345 +
   1.346 +        IMPORT_C virtual TBool ConsistsOfL(CSenFragmentBase& aCandidate);
   1.347 +        
   1.348 +        IMPORT_C void SetContentHandler(CSenFragmentBase& aContentHandler);
   1.349 +        
   1.350 +    protected: // From CSenBaseFragment
   1.351 +    
   1.352 +        void RenameL(const TDesC8& aLocalName, const TDesC8& aPrefix, const TDesC8& aNamespace);
   1.353 +
   1.354 +        void RenameL(const TDesC8& aLocalName, const TDesC8& aNamespace);
   1.355 +
   1.356 +        void RenameLocalNameL(const TDesC8& aLocalName);
   1.357 +
   1.358 +        void RenameNamespaceL(const TDesC8& aNamespace);
   1.359 +
   1.360 +        void RenamePrefixL(const TDesC8& aPrefix);
   1.361 +
   1.362 +        void RenameNamespaceL(const TDesC8& aPrefix, const TDesC8& aNamespace);
   1.363 +         
   1.364 +        IMPORT_C TXmlEngElement SetContentOfL(const TDesC8& aLocalName,
   1.365 +                                        const TDesC8& aContent);
   1.366 +
   1.367 +        IMPORT_C TPtrC8 ContentOf(const TDesC8& aLocalName);        
   1.368 +
   1.369 +        IMPORT_C virtual TBool ConsistsOfL(TXmlEngElement& aElement, TXmlEngElement& aCandidate);
   1.370 +
   1.371 +        IMPORT_C virtual void AddNamespacesL();
   1.372 +
   1.373 +    protected:  
   1.374 +        
   1.375 +        /**
   1.376 +        * C++ default constructor.
   1.377 +        */
   1.378 +        IMPORT_C CSenDomFragmentBase();
   1.379 +
   1.380 +        /**
   1.381 +        * "ConstructL" method for calling the base classes ones.
   1.382 +        * @since Series60 4.0
   1.383 +        */
   1.384 +        IMPORT_C void BaseConstructL();
   1.385 +
   1.386 +        /**
   1.387 +        * "ConstructL" method for calling the base classes ones.
   1.388 +        * @since Series60 4.0
   1.389 +        * @param aElement is the XML element of this fragment.
   1.390 +        */
   1.391 +        IMPORT_C void BaseConstructL(const TXmlEngElement& aElement);
   1.392 +
   1.393 +        /**
   1.394 +        * "ConstructL" method for calling the base classes ones.
   1.395 +        * @since Series60 4.0
   1.396 +        * @param aLocalName The local name of the element
   1.397 +        */
   1.398 +        IMPORT_C void BaseConstructL(const TDesC8& aLocalName);
   1.399 +
   1.400 +        /**
   1.401 +        * "ConstructL" method for calling the base classes ones.
   1.402 +        * @since Series60 4.0
   1.403 +        * @param aNsUri     The namespace URI of the element
   1.404 +        * @param aLocalName The local name of the element
   1.405 +        */
   1.406 +        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   1.407 +                                     const TDesC8& aLocalName);
   1.408 +
   1.409 +        /**
   1.410 +        * "ConstructL" method for calling the base classes ones.
   1.411 +        * @since Series60 4.0
   1.412 +        * @param aNsUri     The namespace URI of the element
   1.413 +        * @param aLocalName The local name of the element
   1.414 +        * @param aPrefix    The prefix of the element
   1.415 +        */
   1.416 +        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   1.417 +                                     const TDesC8& aLocalName,
   1.418 +                                     const TDesC8& aPrefix);
   1.419 +
   1.420 +        /**
   1.421 +        * "ConstructL" method for calling the base classes ones.
   1.422 +        * @since Series60 4.0
   1.423 +        * @param aNsUri     The namespace URI of the element
   1.424 +        * @param aLocalName The local name of the element
   1.425 +        * @param aPrefix    The prefix of the element
   1.426 +        * @param aAttrs     The attributes of the element
   1.427 +        */
   1.428 +        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   1.429 +                                     const TDesC8& aLocalName,
   1.430 +                                     const TDesC8& aPrefix,
   1.431 +                                     const RAttributeArray& aAttrs);
   1.432 +
   1.433 +        /**
   1.434 +        * "ConstructL" method for calling the base classes ones.
   1.435 +        * @since Series60 4.0
   1.436 +        * @param aNsUri     The namespace URI of the element
   1.437 +        * @param aLocalName The local name of the element
   1.438 +        * @param aPrefix    The prefix of the element
   1.439 +        * @param aAttrs     The attributes of the element
   1.440 +        * @param aParent    The parent of the element
   1.441 +        */
   1.442 +        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   1.443 +                                     const TDesC8& aLocalName,
   1.444 +                                     const TDesC8& aPrefix,
   1.445 +                                     const RAttributeArray& aAttrs,
   1.446 +                                     TXmlEngElement& aParent);
   1.447 +                                     
   1.448 +        /**
   1.449 +        * "ConstructL" method for calling the base classes ones.
   1.450 +        * @since Series60 4.0
   1.451 +        * @param aNsUri         The namespace URI of the element
   1.452 +        * @param aLocalName     The local name of the element
   1.453 +        * @param aPrefix        The prefix of the element
   1.454 +        * @param aAttrs         The attributes of the element
   1.455 +        * @param aParent        The parent of the element
   1.456 +        * @param aOwnerDocument The document which will be the owner of
   1.457 +        *                       the elements of this fragment
   1.458 +        */
   1.459 +        IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
   1.460 +                                     const TDesC8& aLocalName,
   1.461 +                                     const TDesC8& aPrefix,
   1.462 +                                     const RAttributeArray& aAttrs,
   1.463 +                                     TXmlEngElement& aParent,
   1.464 +                                     RSenDocument& aOwnerDocument);
   1.465 +
   1.466 +        /**
   1.467 +         *  Callback functions which implement the XML content handler interface.
   1.468 +         *  Inheriting classes can override these.
   1.469 +         */
   1.470 +         
   1.471 +        // From CSenBaseFragment 
   1.472 +                                       
   1.473 +    protected: // Data
   1.474 +        CSenDomFragmentBase* ipDomDelegate;
   1.475 +    };
   1.476 +
   1.477 +#endif //SEN_DOM_FRAGMENT_BASE_H
   1.478 +
   1.479 +// End of File
   1.480 +
   1.481 +
   1.482 +