svgtopt/SVG/SVGImpl/src/SVGTitleElementImpl.cpp
changeset 0 d46562c3d99d
equal deleted inserted replaced
-1:000000000000 0:d46562c3d99d
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  SVG Implementation source file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #if !defined(__E32BASE_H__)
       
    20 #include <e32base.h>
       
    21 #endif
       
    22 #include "SVGTitleElementImpl.h"
       
    23 #include "SVGElementImpl.h"
       
    24 #include "SVGDocumentImpl.h"
       
    25 #include "SVGSchemaData.h"
       
    26 
       
    27 #include "GfxAffineTransform.h"
       
    28 
       
    29 
       
    30 // ==========================================================================
       
    31 // Need method description
       
    32 // ==========================================================================
       
    33 CSvgTitleElementImpl* CSvgTitleElementImpl::NewL( const TUint8 aElemID,
       
    34                                                   CSvgDocumentImpl* aDoc )
       
    35     {
       
    36     CSvgTitleElementImpl*   self    = new ( ELeave )
       
    37                                       CSvgTitleElementImpl( aDoc );
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL( aElemID );
       
    40     CleanupStack::Pop();
       
    41 
       
    42     return self;
       
    43     }
       
    44 
       
    45 // ==========================================================================
       
    46 // Need method description
       
    47 // ==========================================================================
       
    48 CSvgTitleElementImpl* CSvgTitleElementImpl::NewLC( const TUint8 aElemID,
       
    49                                                    CSvgDocumentImpl* aDoc )
       
    50     {
       
    51     CSvgTitleElementImpl*   self    = new ( ELeave )
       
    52                                       CSvgTitleElementImpl( aDoc );
       
    53     CleanupStack::PushL( self );
       
    54     self->ConstructL( aElemID );
       
    55 
       
    56     return self;
       
    57     }
       
    58 
       
    59 // ==========================================================================
       
    60 // Need method description
       
    61 // ==========================================================================
       
    62 CSvgTitleElementImpl::~CSvgTitleElementImpl()
       
    63     {
       
    64     	if ( iText )
       
    65         {
       
    66         delete iText;
       
    67         iText = NULL;
       
    68         }
       
    69     }
       
    70 
       
    71 // *******************************************************
       
    72 // From MXmlElement
       
    73 
       
    74 // ==========================================================================
       
    75 // Need method description
       
    76 // ==========================================================================
       
    77 TInt CSvgTitleElementImpl::GetAttributeDes( const TInt aNameId, TPtrC16& aValue )
       
    78     {
       
    79     switch ( aNameId )
       
    80         {
       
    81         case KAtrCdata:
       
    82         aValue.Set( iText->Ptr() );
       
    83         break;
       
    84         default:
       
    85         return CSvgElementImpl::GetAttributeDes( aNameId, aValue );
       
    86         }
       
    87     return KErrNone;
       
    88     }
       
    89     
       
    90 // ==========================================================================
       
    91 // Need method description
       
    92 // ==========================================================================
       
    93 TInt CSvgTitleElementImpl::SetAttributeDesL( const TInt aNameId,
       
    94                                             const TDesC& aValue )
       
    95     {
       
    96     switch ( aNameId )
       
    97         {
       
    98         case KAtrCdata:
       
    99         SetTextL( aValue );
       
   100         break;
       
   101 
       
   102         default:
       
   103         return CSvgElementImpl::SetAttributeDesL( aNameId, aValue );
       
   104         }
       
   105 
       
   106     return KErrNone;
       
   107     }
       
   108     
       
   109 // ==========================================================================
       
   110 // Need method description
       
   111 // ==========================================================================
       
   112 TInt CSvgTitleElementImpl::SetAttributeL( const TDesC& aName,
       
   113                                           const TDesC& aValue )
       
   114     {
       
   115 
       
   116     if ( this->SetLangSpaceAttributeL( aName, aValue ) )
       
   117         {
       
   118         return KErrNone;
       
   119         }
       
   120 
       
   121     /*    if(this->SetClassName(aName, aValue))
       
   122         {
       
   123             return KErrNone;
       
   124         }
       
   125     */
       
   126   
       
   127 
       
   128     if ( this->SetTestAttributeL( aName, aValue ) )
       
   129         {
       
   130         return KErrNone;
       
   131         }
       
   132 
       
   133     if ( SetIdandXmlbaseL( aName, aValue ) )
       
   134         {
       
   135         return KErrNone;
       
   136         }
       
   137 
       
   138     return KErrNone;
       
   139     }
       
   140 
       
   141 // ==========================================================================
       
   142 // xml:space is an inheritable attribute which can have one of two values:
       
   143 //
       
   144 // default (the initial/default value for xml:space) - When xml:space="default":
       
   145 //      - Remove all newline characters.
       
   146 //      - Convert all tab characters into space characters.
       
   147 //      - Strip off all leading and trailing space characters.
       
   148 //      - All contiguous space characters will be consolidated.
       
   149 //
       
   150 // preserve - When xml:space="preserve" :
       
   151 //      - Convert all newline and tab characters into space characters.
       
   152 // ==========================================================================
       
   153 void CSvgTitleElementImpl::SetTextL( const TDesC& aText )
       
   154     {
       
   155     _LIT( KPreserve, "preserve" );
       
   156 
       
   157     if ( iText )
       
   158         {
       
   159         delete iText;
       
   160         iText = NULL;
       
   161         }
       
   162 
       
   163     iText = aText.AllocL();
       
   164     TPtr textDes = iText->Des();
       
   165 
       
   166     // default
       
   167     if ( XMLSpace() != KPreserve )
       
   168         {
       
   169         for (TInt i = textDes.Length() - 1; i >= 0; i--)
       
   170         {
       
   171         	if (textDes[i] == '\n' || textDes[i] == '\r')
       
   172         	{
       
   173         	textDes.Delete(i,1);
       
   174         	} 
       
   175         }
       
   176         textDes.TrimRight();
       
   177         textDes.TrimLeft();
       
   178         }
       
   179     // preserve
       
   180     else
       
   181         {
       
   182         TInt textDesLength = textDes.Length();
       
   183         for ( TInt i = 0; i < textDesLength; i++ )
       
   184             {
       
   185             // ms-dos carriage return contains two characters: 13, 10
       
   186             if ( i + 1 < textDes.Length() && (TInt)textDes[i] == 13 && (TInt)textDes[i+1] == 10 )
       
   187                 {
       
   188                 textDes[i] = ' ';
       
   189                 textDes.Delete( i+1, 1 );
       
   190                 }
       
   191             else if ( TChar(textDes[i]).IsSpace() )
       
   192                 {
       
   193                 textDes[i] = ' ';
       
   194                 }
       
   195             }
       
   196         }
       
   197     }
       
   198     
       
   199 // *******************************************************
       
   200 // From CSvgElementImpl
       
   201 
       
   202 // perform a deep clone of this object
       
   203 // ==========================================================================
       
   204 // Need method description
       
   205 // ==========================================================================
       
   206 MXmlElement* CSvgTitleElementImpl::CloneL(MXmlElement* aParentElement)
       
   207     {
       
   208     CSvgTitleElementImpl* newElement = CSvgTitleElementImpl::NewL(  this->ElemID(), ((CSvgDocumentImpl*)iOwnerDocument) );
       
   209 
       
   210 		CleanupStack::PushL(newElement);
       
   211 		newElement->iParentNode = aParentElement;
       
   212     // copy everything over
       
   213     this->CopyL(newElement);
       
   214 		CleanupStack::Pop();
       
   215     return newElement;
       
   216     	
       
   217     }
       
   218 
       
   219 // ==========================================================================
       
   220 // perform a deep copy of this object
       
   221 // ==========================================================================
       
   222 void CSvgTitleElementImpl::CopyL( CSvgTitleElementImpl* aDestElement )
       
   223     {
       
   224     	if(aDestElement)
       
   225     	{
       
   226 
       
   227     	// copy stuff from superclass
       
   228     	this->CSvgElementImpl::CopyL(aDestElement);
       
   229 
       
   230 			if(this->iText)
       
   231 			{
       
   232      		delete aDestElement->iText;
       
   233 		 		aDestElement->iText= NULL;
       
   234 		 		aDestElement->iText= (this->iText)->AllocL();
       
   235 			}
       
   236 
       
   237     	// copy the reference to idoc (CSvgDocumentImpl)
       
   238     	aDestElement->iOwnerDocument = this->iOwnerDocument;
       
   239     	}
       
   240     }
       
   241     
       
   242 // ==========================================================================
       
   243 // Need method description
       
   244 // ==========================================================================
       
   245 TBool CSvgTitleElementImpl::DrawL( CGfx2dGc* /* aGc */,
       
   246                                    CSvgElementImpl* /* aElement */ )
       
   247     {
       
   248     return EFalse;
       
   249     }
       
   250 
       
   251 
       
   252 // *******************************************************
       
   253 // Private
       
   254 
       
   255 // ==========================================================================
       
   256 // Need method description
       
   257 // ==========================================================================
       
   258 void CSvgTitleElementImpl::ConstructL( const TUint8 aElemID )
       
   259     {
       
   260     CSvgElementImpl::InitializeL( aElemID );
       
   261     
       
   262     iText = HBufC::NewL( 2 );
       
   263     }
       
   264 
       
   265 // ==========================================================================
       
   266 // Need method description
       
   267 // ==========================================================================
       
   268 CSvgTitleElementImpl::CSvgTitleElementImpl( CSvgDocumentImpl* aDoc )
       
   269     {
       
   270     	SetOwnerDocument( aDoc );
       
   271     }
       
   272 
       
   273 // ==========================================================================
       
   274 // Need method description
       
   275 // ==========================================================================
       
   276 void CSvgTitleElementImpl::Print( TBool aIsEncodeOn )
       
   277 	{
       
   278 		if (!aIsEncodeOn)
       
   279 		{
       
   280 			#ifdef _DEBUG
       
   281 			RDebug::Printf("<title>");
       
   282 			#endif
       
   283 		}
       
   284 	}
       
   285