csxhelp/src/CSXHHtmlTopicContainer.cpp
branchRCL_3
changeset 45 cbffe13eac63
equal deleted inserted replaced
44:12f60d9a73b3 45:cbffe13eac63
       
     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:  CCSXHHtmlTopicContainer class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CSXHHtmlTOC2.h"
       
    20 #include "CSXHHtmlTOC1.h"
       
    21 #include "CSXHDocument.h"
       
    22 #include "CSXHAppUi.h"
       
    23 #include "CSXHHtmlTopicView.h"
       
    24 #include "CSXHViewIDs.h"
       
    25 #include <cshelp.rsg>
       
    26 #include "CsHelp.hrh"
       
    27 #include "CSXHHtmlTopicContainer.h"
       
    28 #include "AppLauncherForCSXH.h"
       
    29 #include "csxhconstants.h"
       
    30 
       
    31 
       
    32 #include <brctlinterface.h>
       
    33 #include <browserlauncher.h>
       
    34 #include <brctldefs.h>
       
    35 
       
    36 #include <coemain.h>
       
    37 #include <AknUtils.h>
       
    38 #include <akntitle.h>
       
    39 #include <aknnotewrappers.h> 
       
    40 #include <AknGlobalNote.h>
       
    41 #include <apmrec.h>
       
    42 #include <apgcli.h>
       
    43 #include <zipfile.h> 
       
    44 #include <utf.h>
       
    45 #include <charconv.h>
       
    46 #include <bautils.h>
       
    47 
       
    48 _LIT(KContentType,"text/html");
       
    49 _LIT(KCsstextToRemovePathinfo,"<style>\n #APP_LAUNCH_LINK{display:none}\n</style>");
       
    50 
       
    51 
       
    52 CBlankContainer::CBlankContainer()
       
    53     {
       
    54     }
       
    55 
       
    56 CBlankContainer::~CBlankContainer()
       
    57     {
       
    58     }
       
    59     
       
    60 
       
    61 void CBlankContainer::Draw( const TRect& aRect ) const
       
    62     {
       
    63     CWindowGc& gc = SystemGc();
       
    64     TRect rect = Rect();
       
    65     gc.Clear(rect);    
       
    66     }
       
    67 
       
    68 
       
    69 // Standard construction sequence
       
    70 CCSXHHtmlTopicContainer* CCSXHHtmlTopicContainer::NewL(const TRect& aRect,CCSXHDocument 
       
    71 &aDocument,CCSXHHtmlTopicView *aView)
       
    72     {
       
    73     CCSXHHtmlTopicContainer* self = CCSXHHtmlTopicContainer::NewLC(aRect,aDocument,aView);
       
    74     CleanupStack::Pop(self);
       
    75     return self;
       
    76     }
       
    77 
       
    78 CCSXHHtmlTopicContainer* CCSXHHtmlTopicContainer::NewLC(const TRect& aRect,CCSXHDocument 
       
    79 &aDocument,CCSXHHtmlTopicView *aView)
       
    80     {
       
    81     CCSXHHtmlTopicContainer* self = new (ELeave) CCSXHHtmlTopicContainer(aDocument,aView);
       
    82     CleanupStack::PushL(self);
       
    83     self->ConstructL(aRect);
       
    84     return self;
       
    85     }
       
    86 
       
    87 CCSXHHtmlTopicContainer::CCSXHHtmlTopicContainer(CCSXHDocument &aDocument,CCSXHHtmlTopicView *aView)
       
    88         : iTopic(NULL),iDocument(aDocument),iView(aView)
       
    89         ,iAppLauncher(NULL), iLoadHtml(EFalse), iPrevPageCount(0), iBack(EFalse)
       
    90         ,iContentLoading(ENoContent)
       
    91 
       
    92     {
       
    93     // no implementation required
       
    94     }
       
    95 
       
    96 CCSXHHtmlTopicContainer::~CCSXHHtmlTopicContainer()
       
    97     {
       
    98     if(iBrCtrl)
       
    99         {
       
   100         iBrCtrl->SetFocus(EFalse);
       
   101         iBrCtrl->RemoveLoadEventObserver(this);
       
   102         delete iBrCtrl;
       
   103         iBrLibrary.Close();
       
   104         }
       
   105 
       
   106     delete iAppLauncher;
       
   107   
       
   108     delete iBlankContainer;
       
   109 
       
   110     }
       
   111 
       
   112 void CCSXHHtmlTopicContainer::ConstructL( const TRect& aRect )
       
   113     {
       
   114     // Create a window for this application view
       
   115     CreateWindowL();
       
   116 
       
   117     // Set the windows size
       
   118     SetRect(aRect);
       
   119     if( KErrNone != iBrLibrary.Load( _L( "BrowserEngine.dll" ) ) )
       
   120     	{
       
   121        	HBufC* ErrorMessage = CCSXHAppUi::GetCoeEnv()->AllocReadResourceLC(
       
   122     				R_CSHELP_RETRIEVE_NO_MEMORY_TEXT );      
       
   123     	CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   124     	note->ShowNoteL( EAknGlobalInformationNote, *ErrorMessage );
       
   125     	CleanupStack::PopAndDestroy( note ); 
       
   126     	CleanupStack::PopAndDestroy( ErrorMessage ); 
       
   127     	iDocument.SetDisplayTopic( iDocument.GetPrevTopic() );
       
   128 		CCSXHAppUi::GetInstance()->HandleCommandL( ECSXHOpenItem );
       
   129 		User::Leave( KErrNoMemory );
       
   130     	}     
       
   131 
       
   132 #ifdef __WINS__    
       
   133     TLibraryFunction result = iBrLibrary.Lookup( 10 ); 
       
   134 #else
       
   135     TLibraryFunction result = iBrLibrary.Lookup( 1 );   
       
   136 #endif    
       
   137 		
       
   138 	FuncPtr_CreateBrowserControlL fptr  = ( FuncPtr_CreateBrowserControlL )result;
       
   139     
       
   140     iBrCtrl = ( *fptr )(
       
   141                     this,aRect,
       
   142                     TBrCtlDefs::ECapabilityDisplayScrollBar|
       
   143                     TBrCtlDefs::ECapabilityClientResolveEmbeddedURL|
       
   144 #ifndef __SERIES60_30__                                 
       
   145                     TBrCtlDefs::ECapabilityCursorNavigation|
       
   146                     TBrCtlDefs::ECapabilityWebKitLite|
       
   147 #endif                                  
       
   148                     TBrCtlDefs::ECapabilityClientNotifyURL,
       
   149                     TBrCtlDefs::ECommandIdBase, this, this, NULL, this
       
   150                     );
       
   151     iBrCtrl->SetBrowserSettingL( TBrCtlDefs::ESettingsCSSFetchEnabled, 1 );    
       
   152     iBrCtrl->AddLoadEventObserverL( this );   
       
   153     
       
   154     
       
   155     SetSelectedFontSizeL( iView->GetCurrentFontSize() );
       
   156     iBrCtrl->MakeVisible( ETrue );
       
   157     
       
   158     iBlankContainer = new ( ELeave ) CBlankContainer();
       
   159     iBlankContainer->SetRect( Rect() );
       
   160     
       
   161     ShowBrowser();
       
   162     
       
   163     ActivateL();
       
   164     }
       
   165 
       
   166 void CCSXHHtmlTopicContainer::Draw(const TRect& /*aRect*/) const
       
   167     {
       
   168     CWindowGc& gc = SystemGc();
       
   169     TRect rect = Rect();
       
   170     gc.Clear(rect);    
       
   171     }
       
   172 void CCSXHHtmlTopicContainer::SetAndLoadInitialTopicL(CCSXHHtmlTOC2* aTopic)
       
   173 	{
       
   174 	iTopic = aTopic;
       
   175 	TRAPD(err,LoadHtmlL());
       
   176     if( KErrNone != err )
       
   177 	    {
       
   178 	    HBufC* ErrorMessage = CCSXHAppUi::GetCoeEnv()->AllocReadResourceLC(
       
   179     				R_CSHELP_RETRIEVE_NO_MEMORY_TEXT);      
       
   180     	CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   181     	note->ShowNoteL(EAknGlobalInformationNote, *ErrorMessage);
       
   182     	CleanupStack::PopAndDestroy(note); 
       
   183     	CleanupStack::PopAndDestroy(ErrorMessage); 
       
   184     	iDocument.SetDisplayTopic(iDocument.GetPrevTopic());
       
   185 		CCSXHAppUi::GetInstance()->HandleCommandL(ECSXHOpenItem);
       
   186 		User::Leave(KErrNoMemory);	    
       
   187 	    }
       
   188  
       
   189 	}
       
   190 
       
   191 void CCSXHHtmlTopicContainer::LoadHtmlL()
       
   192     {
       
   193     iBrCtrl->MakeVisible( EFalse ); 
       
   194     SetContentLoadState( EContentLoading );
       
   195     HBufC8 *htmlBuffer = STATIC_CAST(HBufC8*,iTopic->GetTopicContentL());
       
   196     if(htmlBuffer)
       
   197         {
       
   198         CleanupStack::PushL(htmlBuffer);
       
   199         TUid uid;
       
   200         uid.iUid = KCharacterSetIdentifierIso88591;
       
   201         _LIT8(KContentType,"text/html");
       
   202         TDataType dataType(KContentType());
       
   203         iTopic->GetHtmlUrlL(iUrlNoAnchors);
       
   204         iBack = EFalse;
       
   205         ClearHistoryL();
       
   206         iLoadHtml = ETrue;
       
   207         
       
   208         //RUNTIME
       
   209         //if it is context sensitive launch, Add CSS content to remove
       
   210         //Application launch link.
       
   211         if(iView->GetViewType() == CCSXHHtmlTopicView::EContextHtmlView)
       
   212 	        {
       
   213 	        HBufC8* ContextHtmlbuffer = HBufC8::NewLC(htmlBuffer->Size() + 100);
       
   214 	        TPtr8 bufferPtr = ContextHtmlbuffer->Des();
       
   215 	        bufferPtr.Copy(KCsstextToRemovePathinfo);
       
   216 	        bufferPtr.Append(htmlBuffer->Des());
       
   217 	        iBrCtrl->LoadDataL(iUrlNoAnchors,*ContextHtmlbuffer,dataType,uid);	
       
   218 	    	CleanupStack::PopAndDestroy(ContextHtmlbuffer);    	
       
   219 	        }
       
   220         else
       
   221 	        {
       
   222 	        iBrCtrl->LoadDataL(iUrlNoAnchors,*htmlBuffer,dataType,uid);	
       
   223 	        }
       
   224         CleanupStack::PopAndDestroy(htmlBuffer);
       
   225         }
       
   226     else
       
   227         {
       
   228         iTopic->GetHtmlUrlL(iUrlNoAnchors);
       
   229         iBrCtrl->LoadUrlL(iUrlNoAnchors);
       
   230         }
       
   231     CheckForMSK();  
       
   232     }
       
   233 
       
   234 TKeyResponse CCSXHHtmlTopicContainer::OfferKeyEventL(const TKeyEvent &  
       
   235 aKeyEvent,TEventCode  aType )
       
   236     {
       
   237     TKeyResponse result(EKeyWasNotConsumed);
       
   238     
       
   239     if ((aKeyEvent.iCode == EKeyEnter )&& (aType == EEventKey)
       
   240     	&& (IsHyperLinkFocused()))
       
   241         { 
       
   242         HandleCommandOpenHyperLinkL();
       
   243         CheckForMSK();
       
   244         return EKeyWasConsumed; 
       
   245         }
       
   246     
       
   247     if(iBrCtrl)
       
   248         {
       
   249         result = iBrCtrl->OfferKeyEventL(aKeyEvent, aType);        
       
   250 		CheckForMSK();
       
   251 		}       
       
   252     return result;  
       
   253     }
       
   254 
       
   255 TInt CCSXHHtmlTopicContainer::CountComponentControls() const
       
   256     {
       
   257     return 2; 
       
   258     }
       
   259 
       
   260 CCoeControl* CCSXHHtmlTopicContainer::ComponentControl(TInt aIndex) const
       
   261     {
       
   262     switch (aIndex)
       
   263         {
       
   264         case 0:
       
   265             return iBottomControl;
       
   266         case 1:
       
   267             return iTopControl;
       
   268         default:
       
   269             return NULL;
       
   270         }
       
   271     }
       
   272     
       
   273 void CCSXHHtmlTopicContainer::HandleResourceChange(TInt aType)
       
   274     {
       
   275     CCSXHAppUi::GetInstance()->PropagateResourceChange(aType); 
       
   276     }
       
   277 void CCSXHHtmlTopicContainer::HandleResourceChangeImpl(TInt aType)
       
   278     {
       
   279     if (aType == KEikDynamicLayoutVariantSwitch)
       
   280         {
       
   281         iBrCtrl->HandleResourceChange(aType);
       
   282         TRect mainRect; 
       
   283         TRect statusPaneRect;
       
   284         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainRect);
       
   285         SetRect(mainRect);
       
   286             if(iBrCtrl)
       
   287 #ifndef __SERIES60_30__             
       
   288                 iBrCtrl->SetRect(Rect());
       
   289 #else                       
       
   290                 iBrCtrl->SetRect(mainRect);
       
   291 #endif              
       
   292         DrawNow();
       
   293         }
       
   294     else
       
   295         {
       
   296         CCoeControl::HandleResourceChange(aType);   
       
   297         }
       
   298     }
       
   299 
       
   300 void CCSXHHtmlTopicContainer::SizeChanged()
       
   301     {
       
   302 #ifndef __SERIES60_30__ 
       
   303     if( iBrCtrl )
       
   304         {
       
   305         if ( iContentLoading != EContentLoading )
       
   306             {
       
   307             iBlankContainer->SetRect( Rect() );
       
   308             iBrCtrl->SetRect( Rect() );
       
   309             iBrCtrl->MakeVisible( ETrue );
       
   310             }
       
   311         else
       
   312             {
       
   313             //Update the title bar
       
   314             CEikStatusPane* sp = CCSXHAppUi::GetInstance()->StatusPane();
       
   315             CAknTitlePane* titlePane = NULL;
       
   316             TRAPD( err, titlePane = STATIC_CAST(CAknTitlePane*,
       
   317                     sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ) );
       
   318             if ( KErrNone == err )
       
   319                 {
       
   320                 //If can't set Null text to title, no other good way to do further, 
       
   321                 //so just ignore this leave
       
   322                 TRAP_IGNORE( titlePane->SetTextL( KNullDesC ) );
       
   323                 }
       
   324             iBlankContainer->SetRect( Rect() );
       
   325             iBrCtrl->SetRect( Rect() );            
       
   326             }
       
   327         }
       
   328 #endif  
       
   329     }
       
   330 
       
   331 void CCSXHHtmlTopicContainer::HandleCommandBackL()
       
   332     {
       
   333     iBrCtrl->HandleCommandL(TBrCtlDefs::ECommandIdBase + TBrCtlDefs::ECommandBack);
       
   334     }
       
   335  
       
   336 
       
   337 TBool CCSXHHtmlTopicContainer::IsPrevPageAvbl()
       
   338     {
       
   339     if (iPrevPageCount > 0)
       
   340       	{
       
   341       	return ETrue;
       
   342       	}
       
   343      else
       
   344       	{
       
   345       	return EFalse;
       
   346       	}
       
   347     } 
       
   348 
       
   349 
       
   350 
       
   351 void CCSXHHtmlTopicContainer::ClearHistoryL()
       
   352     {
       
   353     iBrCtrl->HandleCommandL(TBrCtlDefs::ECommandIdBase + TBrCtlDefs::ECommandClearHistory);
       
   354     iPrevPageCount = 0;
       
   355     }
       
   356  
       
   357 TBool CCSXHHtmlTopicContainer::ResolveEmbeddedLinkL(const TDesC& /*aEmbeddedUrl*/,
       
   358                                            const TDesC& /*aCurrentUrl*/,
       
   359                                            TBrCtlLoadContentType /*aLoadContentType*/, 
       
   360                                            MBrCtlLinkContent& /*aEmbeddedLinkContent*/)
       
   361     {
       
   362     return EFalse;
       
   363     }
       
   364 // --------------------------------------------------------------------------
       
   365 // Handling for
       
   366 // 1) Compressed HTML content
       
   367 // 2) Application Launch Links
       
   368 // 3) External Hyperlinks
       
   369 // --------------------------------------------------------------------------
       
   370 TBool CCSXHHtmlTopicContainer::ResolveLinkL(const TDesC& aUrl, const TDesC& aCurrentUrl,
       
   371                                    MBrCtlLinkContent& aBrCtlLinkContent)
       
   372     {
       
   373 #ifdef FF_HELP_TUTORIAL_MERGE
       
   374     if( KErrNotFound != aUrl.Find( KTutorialFileExtn ))
       
   375         {
       
   376         iView->LaunchTutorial();
       
   377         return ETrue;
       
   378         }
       
   379 #endif // FF_HELP_TUTORIAL_MERGE
       
   380     if(NULL == iAppLauncher)
       
   381 		{
       
   382 		iAppLauncher = AppLauncherForCSXH::NewL();	
       
   383 		}
       
   384         //Handling for application launch.
       
   385     if(iAppLauncher->LaunchAppL(aUrl,aCurrentUrl))
       
   386         return ETrue;//Link is resolved locally.
       
   387         
       
   388     if(CheckForExternalLinkL(aUrl))     
       
   389         return ETrue;//Link is resolved locally.
       
   390     
       
   391     //Remove the Anchor, if any     
       
   392     TInt DotPos = aUrl.LocateReverseF('.');
       
   393     TInt HashPos = aUrl.LocateReverseF('#');
       
   394     if(KErrNotFound != HashPos && HashPos > DotPos )
       
   395         {
       
   396         //Direct assignment does not work
       
   397         iUrlNoAnchors.Copy(KEmptyString);
       
   398         iUrlNoAnchors.Append(aUrl.Mid(0,HashPos));
       
   399         }
       
   400     else
       
   401         {
       
   402         //Direct assignment does not work
       
   403         iUrlNoAnchors.Copy(KEmptyString);
       
   404         iUrlNoAnchors.Append(aUrl);
       
   405         }   
       
   406     
       
   407     HBufC8 *htmlBuffer = CCSXHHtmlTOC2::GetContentsFromUrlL(iUrlNoAnchors,CCSXHAppUi::GetCoeEnv(),iFeatureControl);
       
   408     if(htmlBuffer)
       
   409         {
       
   410         TPtrC p(NULL,0);
       
   411         aBrCtlLinkContent.HandleResolveComplete(KContentType,p,htmlBuffer);
       
   412         delete htmlBuffer;
       
   413         iLoadHtml = EFalse;
       
   414         if (iBack)
       
   415         	{
       
   416         	iPrevPageCount--;
       
   417         	iBack = EFalse;
       
   418         	}
       
   419         else
       
   420         	{
       
   421             iPrevPageCount++;
       
   422         	}
       
   423 
       
   424         return ETrue;//Link is resolved locally.    
       
   425         }
       
   426         
       
   427     return  EFalse;
       
   428     }
       
   429 
       
   430 void CCSXHHtmlTopicContainer::CancelFetchL()
       
   431     {
       
   432     if (iBrCtrl)
       
   433         {
       
   434         iBrCtrl->HandleCommandL(
       
   435         	    		(TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ); 
       
   436         }
       
   437     }
       
   438 
       
   439 void CCSXHHtmlTopicContainer::CancelAll()
       
   440     {
       
   441 
       
   442     }
       
   443 
       
   444 
       
   445 void CCSXHHtmlTopicContainer::HandleResolveComplete(const TDesC& /*aContentType*/,
       
   446                                            const TDesC& /*aCharset*/,
       
   447                                            const HBufC8* /*aContentBuf*/)
       
   448     {
       
   449 
       
   450     }
       
   451 
       
   452 void CCSXHHtmlTopicContainer::HandleResolveError(TInt /*aError*/)
       
   453     {
       
   454     
       
   455     }
       
   456 void CCSXHHtmlTopicContainer::RefreshL(CCSXHHtmlTOC2 *aTopic)
       
   457     {
       
   458   	SetAndLoadInitialTopicL(aTopic);
       
   459     }
       
   460 
       
   461 // --------------------------------------------------------------------------
       
   462 // This callback function is used for the following
       
   463 // 1) When an HTML page is loaded, this callback function will be called. If 
       
   464 // this callback is invoked for hyperlink navigation, then the display topic
       
   465 // has to be updated. For example, the Application Topics option menu is
       
   466 // dependent on the dipslay topic.
       
   467 // 2) Updation of the softkey from Options-Close to Options-Back (& Vice-Versa)
       
   468 // in the context view as a result of hyperlink traveral
       
   469 // --------------------------------------------------------------------------
       
   470 void CCSXHHtmlTopicContainer::HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, 
       
   471                                     TUint /*aSize*/, TUint16 /*aTransactionId*/)
       
   472     {
       
   473     if(aLoadEvent == TBrCtlDefs::EEventLoadFinished)
       
   474         {
       
   475         ShowBrowser();
       
   476         SetContentLoadState( EContentLoadFinished );
       
   477         if ( IsVisible() )
       
   478              {
       
   479                HBufC* title = iBrCtrl->PageInfoLC(TBrCtlDefs::EPageInfoTitle);
       
   480                if(!title)
       
   481                    {
       
   482                    CleanupStack::PopAndDestroy(title);
       
   483                    return;
       
   484                    }
       
   485                
       
   486                //Update the title bar
       
   487                CEikStatusPane* sp = CCSXHAppUi::GetInstance()->StatusPane();
       
   488                CAknTitlePane* titlePane = STATIC_CAST(CAknTitlePane*, 
       
   489                sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
       
   490                titlePane->SetTextL(*title);
       
   491                CleanupStack::PopAndDestroy(title);
       
   492              }
       
   493         
       
   494         //For the context sensitive view, the softkey texts need to be changed.
       
   495         //add label iLoadHtml for ESNN-7N9CLN.If the html is opened by 
       
   496         //loadHtmlL, the iLoadHtml will be set to ETrue, which 
       
   497         //can guarantee the RSK keep as "CLOSE" when context is sensitive.
       
   498         if ((!iLoadHtml) && (iView->GetViewType() == CCSXHHtmlTopicView::EContextHtmlView))
       
   499         {  
       
   500             iView->SetViewTypeL(IsPrevHtmlPageAvblL() ? 
       
   501                     CCSXHHtmlTopicView::EHtmlView : CCSXHHtmlTopicView::EContextHtmlView);
       
   502         }
       
   503         
       
   504         //TSW Error:TKOI-74KE89: Help crashes when closing after viewing a link topic
       
   505         //When user presses back keys very quickly, TOC2 objects use to destroy and 
       
   506         //then browser call back function triggers which leads to crash. This check 
       
   507         //will avoid crash.
       
   508         TUid viewId = iDocument.GetDisplayTopic()->GetViewID();
       
   509 		if (viewId == KCSXHToc1ViewID || viewId == KCSXHKywdToc1ViewID
       
   510 			|| viewId == KCSXHToc2ViewID || viewId == KCSXHKywdToc2ViewID
       
   511 			|| viewId == KCSXHToc1AppHelpsViewID || viewId == KCSXHToc2AppHelpsViewID)
       
   512 			{
       
   513 			return;
       
   514 			}
       
   515 		
       
   516         //When user clicks on Application Topics, application topics 
       
   517         //corresponding to the topic being displayed has to be opened
       
   518         //Hence update the Display topic information if required.
       
   519         
       
   520         //Check if this event is triggered for the first load after construction
       
   521         TFileName url;
       
   522         iTopic->GetHtmlUrlL(url);
       
   523         if(url.Compare(iUrlNoAnchors) == 0)
       
   524         	{
       
   525         	iDocument.SetDisplayTopic(iTopic);
       
   526         	iNewTopic = NULL;
       
   527         	//Move the code from SetAndLoadInitialTopicL
       
   528         	//TSW Error:EJZG-7E2BUV
       
   529         	ClearHistoryL();
       
   530         	return;
       
   531         	}
       
   532             
       
   533         iNewTopic = iDocument.GetHtmlTopicForUrlL(iUrlNoAnchors);            
       
   534         CheckForMSK();
       
   535         }
       
   536     // Only when loadhtml is called, in that condition, last-displayed content may show;
       
   537     // then we should hide browser.
       
   538     else  if ( iContentLoading == EContentLoading )
       
   539         {
       
   540         HideBrowser();
       
   541         }
       
   542     }
       
   543     
       
   544 CCSXHHelpContentBase* CCSXHHtmlTopicContainer::GetCurrActiveObject()
       
   545     	{
       
   546     	return iNewTopic;
       
   547     	}    
       
   548 // --------------------------------------------------------------------------
       
   549 // Back Key Handling
       
   550 // --------------------------------------------------------------------------
       
   551 TBool CCSXHHtmlTopicContainer::HandleBackKeyL()
       
   552     {
       
   553     //When this view is initially created, the HTML content is loaded 
       
   554     //using the LoadDataL function and hence it will not be part of the
       
   555     //History stack but all other subsequest navigation by the user 
       
   556     //using the hyperlinks will be part of the History Stack
       
   557     if(IsPrevPageAvbl())
       
   558         {
       
   559         iBack = ETrue;
       
   560         TRAPD(res,HandleCommandBackL());
       
   561         if(res == KErrNone)
       
   562             return ETrue;
       
   563         else
       
   564             ClearHistoryL();
       
   565         }
       
   566     ClearHistoryL();
       
   567         
       
   568     return EFalse;  
       
   569     }
       
   570 TBool CCSXHHtmlTopicContainer::IsPrevHtmlPageAvblL()
       
   571     {
       
   572     if(IsPrevPageAvbl())
       
   573         return ETrue;
       
   574     
       
   575     return EFalse;  
       
   576     }
       
   577 
       
   578 void CCSXHHtmlTopicContainer::SetSelectedFontSizeL(TInt aValue)
       
   579     {
       
   580     iBrCtrl->SetBrowserSettingL(TBrCtlDefs::ESettingsFontSize,aValue);  
       
   581     }
       
   582     
       
   583 TInt CCSXHHtmlTopicContainer::GetCurrentValueL(TInt aSetting)
       
   584     {
       
   585         return iBrCtrl->BrowserSettingL(aSetting);  
       
   586     }   
       
   587 
       
   588 void CCSXHHtmlTopicContainer::UpdateSoftkeyL(TBrCtlKeySoftkey /*aKeySoftkey*/,
       
   589                                     const TDesC& /*aLabel*/,
       
   590                                     TUint32 /*aCommandId*/,
       
   591                                     TBrCtlSoftkeyChangeReason /*aBrCtlSoftkeyChangeReason*/)
       
   592     {
       
   593     }
       
   594 
       
   595 void CCSXHHtmlTopicContainer::UpdateBrowserVScrollBarL(TInt /*aDocumentHeight*/, 
       
   596                                               TInt /*aDisplayHeight*/,
       
   597                                               TInt /*aDisplayPosY*/ ) 
       
   598     {
       
   599     if(iBrCtrl)
       
   600         CheckForMSK();
       
   601 }
       
   602 void CCSXHHtmlTopicContainer::UpdateBrowserHScrollBarL(TInt /*aDocumentWidth*/, 
       
   603                                               TInt /*aDisplayWidth*/,
       
   604                                               TInt /*aDisplayPosX*/ )
       
   605     {
       
   606     if(iBrCtrl)
       
   607         CheckForMSK();
       
   608     }
       
   609 void CCSXHHtmlTopicContainer::NotifyLayoutChange( TBrCtlLayout /*aNewLayout*/ )
       
   610     {
       
   611     }
       
   612         
       
   613 void CCSXHHtmlTopicContainer::UpdateTitleL( const TDesC& /*aTitle*/ )
       
   614     {
       
   615     }
       
   616 
       
   617 void CCSXHHtmlTopicContainer::CheckForMSK()
       
   618     {
       
   619     if(IsHyperLinkFocused())
       
   620         {
       
   621         iView->SetMiddleSoftKey(ETrue); 
       
   622         }
       
   623     else
       
   624         {
       
   625         iView->SetMiddleSoftKey(EFalse);    
       
   626         }
       
   627     }
       
   628     
       
   629 TBool CCSXHHtmlTopicContainer::IsHyperLinkFocused() 
       
   630     {
       
   631     if(TBrCtlDefs::EElementAnchor == iBrCtrl->FocusedElementType())
       
   632         return ETrue;
       
   633     else
       
   634         return EFalse;
       
   635     }
       
   636     
       
   637 void CCSXHHtmlTopicContainer::HandleCommandOpenHyperLinkL()
       
   638     {
       
   639     iBrCtrl->HandleCommandL(TBrCtlDefs::ECommandIdBase + TBrCtlDefs::ECommandOpen);
       
   640     }
       
   641 
       
   642 TBool CCSXHHtmlTopicContainer::CheckForExternalLinkL(const TDesC& aUrl)
       
   643 	{
       
   644     TBool Result = EFalse;
       
   645         
       
   646     if( KErrNotFound != aUrl.Find(_L("http://")) |
       
   647         KErrNotFound != aUrl.Find(_L("https://")) |
       
   648         KErrNotFound != aUrl.Find(_L("ftp://")))
       
   649         {
       
   650         iAppLauncher->LaunchBrowserNGL(aUrl);           
       
   651         Result = ETrue;
       
   652         }
       
   653         
       
   654     return Result;
       
   655 	}
       
   656 
       
   657 void CCSXHHtmlTopicContainer::SetContentLoadState( TContentLoadState aLoadState )
       
   658     {
       
   659     if ( iContentLoading == aLoadState )
       
   660         {
       
   661         return;
       
   662         }
       
   663     else if ( NeedRefresh( aLoadState ) )
       
   664         {
       
   665         iContentLoading = aLoadState;
       
   666         SizeChanged();
       
   667         }
       
   668     else
       
   669         {
       
   670         iContentLoading = aLoadState;
       
   671         }
       
   672     }
       
   673 
       
   674 TBool CCSXHHtmlTopicContainer::NeedRefresh( const TContentLoadState aNewLoadState ) const
       
   675     {
       
   676     if ( 
       
   677             ( iContentLoading == EContentLoading && aNewLoadState != EContentLoading )
       
   678             ||( iContentLoading != EContentLoading && aNewLoadState == EContentLoading )
       
   679         )
       
   680         return ETrue;
       
   681     else
       
   682         return EFalse;
       
   683     }
       
   684 
       
   685 void CCSXHHtmlTopicContainer::HideBrowser()
       
   686     {
       
   687     SetTopAndBottomContainer( iBlankContainer, iBrCtrl );
       
   688     }
       
   689 
       
   690 void CCSXHHtmlTopicContainer::ShowBrowser()
       
   691     {
       
   692     SetTopAndBottomContainer( iBrCtrl, iBlankContainer );
       
   693     }
       
   694 
       
   695 void CCSXHHtmlTopicContainer::SetTopAndBottomContainer( CCoeControl* aTopControl, 
       
   696         CCoeControl* aBottomControl )
       
   697     {
       
   698     iTopControl = aTopControl;
       
   699     iBottomControl = aBottomControl;
       
   700     }
       
   701     
       
   702 //end of the file
       
   703