csxhelp/HelpEngine/src/CSXHHtmlTOC2.cpp
changeset 0 1f04cf54edd8
equal deleted inserted replaced
-1:000000000000 0:1f04cf54edd8
       
     1 /*
       
     2 * Copyright (c) 2006 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:  CCSXHHtmlTOC2 class definition
       
    15 *
       
    16 */
       
    17 
       
    18 #include "CSXHHtmlTOC2.h"
       
    19 #include "CSXHHtmlTOC1.h"
       
    20 #include "CSXHViewIDs.h"
       
    21 #include "CSXHHTMLContentParser.h"
       
    22 #include "CSXHHelpDataBase.h"
       
    23 #include "csxhconstants.h"
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <zipfile.h>
       
    27 #include <bautils.h>
       
    28 #include <coehelp.h>
       
    29 
       
    30 // ---------------------------------------------------------
       
    31 // Items commented in header.
       
    32 // ---------------------------------------------------------
       
    33 CCSXHHtmlTOC2* CCSXHHtmlTOC2::NewL(CCSXHGenericTOC1* aParent,const TDesC& aName, 
       
    34                                    const TDesC& aHtmlHelpFile, TBool aKeyWordTopic )
       
    35     {
       
    36     CCSXHHtmlTOC2* self = CCSXHHtmlTOC2::NewLC(aParent, aName,aHtmlHelpFile,aKeyWordTopic);
       
    37     CleanupStack::Pop(self);
       
    38     return self;
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------
       
    42 // Items commented in header.
       
    43 // ---------------------------------------------------------
       
    44 CCSXHHtmlTOC2* CCSXHHtmlTOC2::NewLC(CCSXHGenericTOC1* aParent, const TDesC& aName, 
       
    45                                     const TDesC& aHtmlHelpFile, TBool aKeyWordTopic)
       
    46     {
       
    47     CCSXHHtmlTOC2* self = new(ELeave) CCSXHHtmlTOC2(aParent, aName,aHtmlHelpFile,aKeyWordTopic);
       
    48     CleanupStack::PushL(self);
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // Items commented in header.
       
    54 // ---------------------------------------------------------
       
    55 CCSXHHtmlTOC2::~CCSXHHtmlTOC2()
       
    56     {//No implementation required
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // Items commented in header.
       
    61 // ---------------------------------------------------------
       
    62 CCSXHHtmlTOC2::CCSXHHtmlTOC2(CCSXHGenericTOC1* aParent,const TDesC& aName, 
       
    63                             const TDesC& aHtmlHelpFile, TBool aKeyWordTopic) :
       
    64                             CCSXHGenericTOC2(aParent, aName),iHTMLFileName(aHtmlHelpFile),
       
    65                             iKeyWordTopic(aKeyWordTopic),iKywdParent(NULL)
       
    66     {//No implementation required
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------
       
    70 // Items commented in header.
       
    71 // ---------------------------------------------------------    
       
    72 TUid CCSXHHtmlTOC2::GetViewID() const
       
    73     {
       
    74     return KCSXHHtmlTopicViewID;
       
    75     }   
       
    76    
       
    77 // ---------------------------------------------------------
       
    78 // Items commented in header.
       
    79 // ---------------------------------------------------------    
       
    80 const TBuf<KMaxFileName>&  CCSXHHtmlTOC2::GetFileName() const
       
    81     {
       
    82     return iHTMLFileName;
       
    83     }
       
    84    
       
    85 // ---------------------------------------------------------
       
    86 // Items commented in header.
       
    87 // ---------------------------------------------------------    
       
    88 EXPORT_C TBool CCSXHHtmlTOC2::GetHelpContext(TCoeHelpContext& aContext) const
       
    89     {
       
    90     
       
    91     CCSXHHtmlTOC1* parent = STATIC_CAST(CCSXHHtmlTOC1*,iParent);
       
    92     aContext.iMajor = parent->GetAppUid();
       
    93     if( KErrNotFound != iHTMLFileName.Find(KHtmlFileExtn) )
       
    94         {
       
    95         aContext.iContext.Append(iHTMLFileName.Left(iHTMLFileName.Find(KHtmlFileExtn)));
       
    96         }
       
    97 #ifdef FF_HELP_TUTORIAL_MERGE
       
    98      else if( KErrNotFound != iHTMLFileName.Find(KTutorialFileExtn) )
       
    99         {
       
   100         aContext.iContext.Append(iHTMLFileName.Left(iHTMLFileName.Find(KTutorialFileExtn)));
       
   101         }
       
   102 #endif // FF_HELP_TUTORIAL_MERGE
       
   103     return ETrue;
       
   104     }
       
   105 // ---------------------------------------------------------
       
   106 // Items commented in header.
       
   107 // ---------------------------------------------------------
       
   108 EXPORT_C void CCSXHHtmlTOC2::GetHtmlUrlL(TBuf<KMaxFileName>& aFileUrl) const
       
   109     {
       
   110     aFileUrl = KFileUrlPrefix;
       
   111     
       
   112     aFileUrl.Append(iHTMLFilePath);
       
   113     aFileUrl.Append(iHTMLFileName);
       
   114     
       
   115     TInt pos = aFileUrl.Find(KFwdSlash) ;
       
   116     while (KErrNotFound != pos)
       
   117         {
       
   118         aFileUrl.Replace(pos,1,KBackSlash);
       
   119         pos = aFileUrl.Find(KFwdSlash) ;
       
   120         }
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // Items commented in header.
       
   125 // ---------------------------------------------------------    
       
   126 EXPORT_C TAny* CCSXHHtmlTOC2::GetTopicContentL()
       
   127     {
       
   128     return CCSXHHelpDataBase::GetInstance()->GetHtmlParser()->GetTopicContentL(this);
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------
       
   132 // Items commented in header.
       
   133 // ---------------------------------------------------------    
       
   134 EXPORT_C HBufC8* CCSXHHtmlTOC2::GetContentsFromUrlL(const TDesC&  fileUrl,CCoeEnv* aCoeEnv, 
       
   135 	RFeatureControl& aFeatureControl)
       
   136     {
       
   137     TBuf<KMaxFileName> htmlFile(fileUrl);
       
   138     htmlFile.Delete(0,KFileUrlPrefixLength);//Remove "file:///"
       
   139     //Replace "/" with "\\"
       
   140     TInt pos = htmlFile.Locate('/') ;
       
   141     while (KErrNotFound != pos)
       
   142         {
       
   143         htmlFile.Replace(pos,1,KFwdSlash);
       
   144         pos = htmlFile.Locate('/') ;
       
   145         }
       
   146     return CCSXHHTMLContentParser::GetContentsFromFileL(htmlFile,aCoeEnv,aFeatureControl);
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // Items commented in header.
       
   151 // ---------------------------------------------------------    
       
   152 EXPORT_C CCSXHKywdTOC1* CCSXHHtmlTOC2::GetKywdParent()
       
   153     {
       
   154     return iKywdParent;
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------
       
   158 // Items commented in header.
       
   159 // ---------------------------------------------------------    
       
   160 void CCSXHHtmlTOC2::SetKywdParent(CCSXHKywdTOC1* aKywdParent)
       
   161     {
       
   162     iKywdParent = aKywdParent;
       
   163     }
       
   164 
       
   165 // ---------------------------------------------------------
       
   166 // Items commented in header.
       
   167 // ---------------------------------------------------------    
       
   168 void CCSXHHtmlTOC2::SetHtmlFilePath(const TDesC&  aFilePath)
       
   169 	{
       
   170 	iHTMLFilePath = aFilePath;
       
   171 	}
       
   172 
       
   173 // ---------------------------------------------------------
       
   174 // Items commented in header.
       
   175 // ---------------------------------------------------------    	
       
   176 void CCSXHHtmlTOC2::GetHtmlFileName(TBuf<KMaxFileName>&  aFileName)	
       
   177 	{
       
   178 	aFileName.Copy(KEmptyString);
       
   179 	aFileName.Append(iHTMLFilePath);	
       
   180 	aFileName.Append(iHTMLFileName);	
       
   181 	}