notepad/notepad1/LibSrc/NpdApi.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Implementation of Notepad Library APIs.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknPopup.h>
       
    21 #include <aknlists.h>
       
    22 #include <NpdLib.rsg>
       
    23 #include <bautils.h>
       
    24 #include <txtetext.h>
       
    25 #include <data_caging_path_literals.hrh>
       
    26 #include <StringLoader.h>
       
    27 
       
    28 #include "NpdApi.h"
       
    29 #include "NpdModel_platsec.h"
       
    30 #include "NpdListDialog.h"
       
    31 #include "NpdEditorDialog.h"
       
    32 #include "NpdExternalTextEditorDialog.h"
       
    33 #include "NpdViewerDialog.h"
       
    34 #include "NpdPopupList.h"
       
    35 
       
    36 // CONSTANTS
       
    37 _LIT(KNpdResourceDrive, "z:");
       
    38 _LIT(KNpdLibResourceFilename, "npdlib.rsc");
       
    39 
       
    40 //static const TInt KFetchMemoPromptMaxlength = 40;
       
    41 //static const TInt KEmptyMessageMaxlength = 80; 
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CNotepadApi::NewL
       
    47 // two-phased constructor
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CNotepadApi* CNotepadApi::NewL()
       
    51     {
       
    52     CNotepadApi* self = NewLC();
       
    53     CleanupStack::Pop(); // self
       
    54     return self;
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CNotepadApi::NewLC
       
    59 // two-phased constructor
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CNotepadApi* CNotepadApi::NewLC()
       
    63     {
       
    64     CNotepadApi* self = new(ELeave) CNotepadApi;
       
    65     CleanupStack::PushL(self);
       
    66     TFileName fileName(KNpdResourceDrive);
       
    67     fileName.Append(KDC_RESOURCE_FILES_DIR);
       
    68     fileName.Append(KNpdLibResourceFilename);
       
    69 
       
    70     self->iResourceLoader.OpenL(fileName);
       
    71     return self; // self is kept on CleanupStack
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CNotepadApi::~CNotepadApi
       
    76 // Destructor.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CNotepadApi::~CNotepadApi()
       
    80     {
       
    81     delete iModel;
       
    82     iResourceLoader.Close();
       
    83     delete iDialog;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CNotepadApi::FetchMemoL
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 EXPORT_C HBufC* CNotepadApi::FetchMemoL(const TDesC* aTitle)
       
    91     {
       
    92     CNotepadApi* api = CNotepadApi::NewLC(); // with resource adding
       
    93     HBufC* fetchedMemo = api->DoPopupListL(
       
    94         aTitle, 
       
    95         R_NOTEPAD_FETCH_MEMO_MODEL,
       
    96         R_NOTEPAD_FETCH_MEMO_PRMPT);
       
    97     CleanupStack::PopAndDestroy(); // api (release the resource)
       
    98     return fetchedMemo;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CNotepadApi::FetchTemplateL
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 EXPORT_C HBufC* CNotepadApi::FetchTemplateL(const TDesC* aTitle)
       
   106     {
       
   107     CNotepadApi* api = CNotepadApi::NewLC(); // with resource adding
       
   108     HBufC* fetchedTemplate = api->DoPopupListL(
       
   109         aTitle, 
       
   110         R_NOTEPAD_FETCH_TEMPLATE_MODEL,
       
   111         R_NOTEPAD_FETCH_TEMPLATE_PRMPT,
       
   112         R_NOTEPAD_MCE_EMPTY_LIST );
       
   113     CleanupStack::PopAndDestroy(); // api (release the resource)
       
   114     return fetchedTemplate;
       
   115     }   
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CNotepadApi::ExecTemplatesL
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C TInt CNotepadApi::ExecTemplatesL()
       
   122     {
       
   123     CNotepadApi* api = CNotepadApi::NewLC();
       
   124     api->CreateListDialogL(R_NOTEPAD_TEMPLATE_LIST_DIALOG);
       
   125     CNotepadListDialog* dialog = 
       
   126         STATIC_CAST(CNotepadListDialog*, api->iDialog);
       
   127     TInt returnValueOfDialogExecuteLD(dialog->ExecuteLD()); // wait dialog
       
   128     CleanupStack::PopAndDestroy(); // api
       
   129     return returnValueOfDialogExecuteLD;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CNotepadApi::ExecFileViewerL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C TInt CNotepadApi::ExecFileViewerL(
       
   137     const TDesC& aFileName, 
       
   138     const TDesC* aTitle,
       
   139     const TBool aDoWait,
       
   140     TBool aGuessEncoding,
       
   141     TUint aEncoding)
       
   142     {
       
   143     CNotepadApi* api = CNotepadApi::NewLC();
       
   144    	RFs fileSession;
       
   145    	User::LeaveIfError(fileSession.Connect());
       
   146    	CleanupClosePushL(fileSession);
       
   147     RFile file;
       
   148     User::LeaveIfError(file.Open(fileSession, aFileName, EFileRead));
       
   149     CleanupClosePushL(file);
       
   150     api->CreateViewerDialogL(
       
   151         file, aTitle, aDoWait, aGuessEncoding, aEncoding);
       
   152     TInt returnValueOfDialogExecuteLD(
       
   153         STATIC_CAST(CNotepadViewerDialog*, api->iDialog)->ExecuteLD() );
       
   154     CleanupStack::PopAndDestroy(3); // api, file, fileSession
       
   155     return returnValueOfDialogExecuteLD;
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CNotepadApi::ExecFileViewerL file handle
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 EXPORT_C TInt CNotepadApi::ExecFileViewerL(
       
   163     RFile& aFile, 
       
   164     const TDesC* aTitle,
       
   165     const TBool aDoWait,
       
   166     TBool aGuessEncoding,
       
   167     TUint aEncoding)
       
   168     {
       
   169     CNotepadApi* api = CNotepadApi::NewLC();
       
   170     api->CreateViewerDialogL(
       
   171         aFile, aTitle, aDoWait, aGuessEncoding, aEncoding);
       
   172     TInt returnValueOfDialogExecuteLD(
       
   173         STATIC_CAST(CNotepadViewerDialog*, api->iDialog)->ExecuteLD() );
       
   174     CleanupStack::PopAndDestroy(); // api
       
   175     return returnValueOfDialogExecuteLD;
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CNotepadApi::AddContentL
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 EXPORT_C void CNotepadApi::AddContentL(const TDesC& aText)
       
   183     {
       
   184     CNotepadApi::NewLC(); // loading our resource
       
   185     CNotepadCoreModel* model = new(ELeave) CNotepadCoreModel();
       
   186     CleanupStack::PushL(model);
       
   187     model->ConstructL( R_NOTEPAD_DATAFILE_NAME );
       
   188     TInt key(KNotepadPseudoKeyIdForNewNote);
       
   189     model->InsertL(aText, key);
       
   190     CleanupStack::PopAndDestroy(2); // model, api (release the resource)
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CNotepadApi::ExistsMemoL
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 EXPORT_C TBool CNotepadApi::ExistsMemoL(const TInt aKey)
       
   198     {
       
   199     CNotepadApi* api = CNotepadApi::NewLC();
       
   200     TBool isFound( api->ProbeMemoL(aKey) );
       
   201     CleanupStack::PopAndDestroy(); // api
       
   202     return isFound;
       
   203     }
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CNotepadApi::NumberOfTemplates
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C TInt CNotepadApi::NumberOfTemplates()
       
   210     {
       
   211     TInt numberOfTemplates(0);
       
   212     TRAPD(err, 
       
   213         CNotepadApi::NewLC(); // loading our resource
       
   214         CNotepadCoreModel* model = new(ELeave) CNotepadCoreModel();
       
   215         CleanupStack::PushL(model);
       
   216         model->ConstructL( R_NOTEPAD_TEMPLATE_DATAFILE_NAME );
       
   217         numberOfTemplates = model->CountL();
       
   218         CleanupStack::PopAndDestroy(2); // model, api (release the resource)
       
   219         );
       
   220     return (err < 0) ? err : numberOfTemplates;
       
   221     }
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CNotepadApi::SaveFileAsMemoL
       
   225 // -----------------------------------------------------------------------------
       
   226 //
       
   227 EXPORT_C void CNotepadApi::SaveFileAsMemoL(const TDesC& aFileName)
       
   228     {
       
   229     CPlainText* text = CPlainText::NewL(CEditableText::EFlatStorage);
       
   230     CleanupStack::PushL(text);
       
   231     NotepadUtil::LoadFileL(*CCoeEnv::Static(), aFileName, 
       
   232         ETrue, // aGuessEncoding
       
   233         0, // aEncoding
       
   234         *text );
       
   235     AddContentL(text->Read(0, text->DocumentLength()));
       
   236     CleanupStack::PopAndDestroy(); // text
       
   237     }
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // CNotepadApi::SaveFileAsMemoL file handle
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 EXPORT_C void CNotepadApi::SaveFileAsMemoL(RFile& aFile)
       
   244     {
       
   245     CPlainText* text = CPlainText::NewL(CEditableText::EFlatStorage);
       
   246     CleanupStack::PushL(text);
       
   247     NotepadUtil::LoadFileL(*CCoeEnv::Static(), aFile, 
       
   248         ETrue, // aGuessEncoding
       
   249         0, // aEncoding
       
   250         *text );
       
   251     AddContentL(text->Read(0, text->DocumentLength()));
       
   252     CleanupStack::PopAndDestroy(); // text
       
   253     }
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // CNotepadApi::SaveFileAsMemoL
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 EXPORT_C void CNotepadApi::SaveFileAsMemoL(const TDesC& aFileName, const TUint aEncoding)
       
   260     {
       
   261     CPlainText* text = CPlainText::NewL(CEditableText::EFlatStorage);
       
   262     CleanupStack::PushL(text);
       
   263     NotepadUtil::LoadFileL(*CCoeEnv::Static(), aFileName, 
       
   264         EFalse, // aGuessEncoding
       
   265         aEncoding, // aEncoding
       
   266         *text );
       
   267     AddContentL(text->Read(0, text->DocumentLength()));
       
   268     CleanupStack::PopAndDestroy(); // text
       
   269     }
       
   270 
       
   271 // -----------------------------------------------------------------------------
       
   272 // CNotepadApi::SaveFileAsMemoL file handle
       
   273 // -----------------------------------------------------------------------------
       
   274 //
       
   275 EXPORT_C void CNotepadApi::SaveFileAsMemoL(RFile& aFile, const TUint aEncoding)
       
   276     {
       
   277     CPlainText* text = CPlainText::NewL(CEditableText::EFlatStorage);
       
   278     CleanupStack::PushL(text);
       
   279     NotepadUtil::LoadFileL(*CCoeEnv::Static(), aFile, 
       
   280         EFalse, // aGuessEncoding
       
   281         aEncoding, // aEncoding
       
   282         *text );
       
   283     AddContentL(text->Read(0, text->DocumentLength()));
       
   284     CleanupStack::PopAndDestroy(); // text
       
   285     }
       
   286 
       
   287 // -----------------------------------------------------------------------------
       
   288 // CNotepadApi::Dialog
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 EXPORT_C CEikDialog* CNotepadApi::Dialog()
       
   292     {
       
   293     return iDialog;
       
   294     }
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CNotepadApi::Model
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 EXPORT_C CNotepadModel* CNotepadApi::Model()
       
   301     {
       
   302     return iModel;
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // CNotepadApi::CreateListDialogL
       
   307 // -----------------------------------------------------------------------------
       
   308 //
       
   309 EXPORT_C void CNotepadApi::CreateListDialogL(TInt aResId)
       
   310     {
       
   311     delete iDialog;
       
   312     iDialog = NULL;
       
   313     iDialog = CNotepadListDialog::NewL(aResId,
       
   314         REINTERPRET_CAST( CEikDialog**, &iDialog ) );
       
   315     }
       
   316 
       
   317 // -----------------------------------------------------------------------------
       
   318 // CNotepadApi::CreateViewerDialogL
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 EXPORT_C void CNotepadApi::CreateViewerDialogL(
       
   322     const TDesC& aFileName, 
       
   323     const TDesC* aTitle,
       
   324     const TBool aDoWait,
       
   325     TBool aGuessEncoding,
       
   326     TUint aEncoding)
       
   327     {
       
   328     CreateViewerDialogL(aDoWait);
       
   329     STATIC_CAST(CNotepadViewerDialog*, iDialog)->SetFileL(
       
   330         aFileName, aTitle, aGuessEncoding, aEncoding );
       
   331     }
       
   332 
       
   333 // -----------------------------------------------------------------------------
       
   334 // CNotepadApi::CreateViewerDialogL file handle
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 EXPORT_C void CNotepadApi::CreateViewerDialogL(
       
   338     RFile& aFile, 
       
   339     const TDesC* aTitle,
       
   340     const TBool aDoWait,
       
   341     TBool aGuessEncoding,
       
   342     TUint aEncoding)
       
   343     {
       
   344     CreateViewerDialogL(aDoWait);
       
   345     STATIC_CAST(CNotepadViewerDialog*, iDialog)->SetFileL(
       
   346         aFile, aTitle, aGuessEncoding, aEncoding );
       
   347     }
       
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 // CNotepadApi::CreateViewerDialogL
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 EXPORT_C void CNotepadApi::CreateViewerDialogL(const TBool aDoWait)
       
   354     {
       
   355     delete iDialog;
       
   356     iDialog = NULL;
       
   357     iDialog = CNotepadViewerDialog::NewL(
       
   358         ( aDoWait ? R_NOTEPAD_VIEWER_WAITING : R_NOTEPAD_VIEWER ),
       
   359         REINTERPRET_CAST( CEikDialog**, &iDialog ) );
       
   360     }
       
   361 
       
   362 
       
   363 // -----------------------------------------------------------------------------
       
   364 // CNotepadApi::CreateViewerDialogL
       
   365 // -----------------------------------------------------------------------------
       
   366 //
       
   367 EXPORT_C void CNotepadApi::CreateTextViewerDialogL(
       
   368     HBufC **aContentPointer,
       
   369     TInt& aReturnStatus,
       
   370     TBool aReadOnly,
       
   371     const TDesC& aText, 
       
   372     const TDesC& aTitle, 
       
   373     const TDesC& aDeleteConfirmationText
       
   374     )
       
   375     {
       
   376     delete iDialog;
       
   377     iDialog = NULL;
       
   378     iDialog = CNotepadViewerDialog::NewL(
       
   379         ( R_NOTEPAD_VIEWER_WAITING ),
       
   380         REINTERPRET_CAST( CEikDialog**, &iDialog ) );
       
   381 
       
   382     STATIC_CAST(CNotepadViewerDialog*, iDialog)->InitDescriptorViewerL(
       
   383         aContentPointer, aReturnStatus, aReadOnly, aText, aTitle, aDeleteConfirmationText );
       
   384     }
       
   385 
       
   386 // -----------------------------------------------------------------------------
       
   387 // CNotepadApi::CreateTextEditorDialogL
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 EXPORT_C void CNotepadApi::CreateTextEditorDialogL(
       
   391     HBufC **aContentPointer,
       
   392     TInt& aReturnStatus,
       
   393     const TDesC& aText, 
       
   394     const TDesC& aTitle, 
       
   395     const TDesC& aDeleteConfirmationText
       
   396     )
       
   397     {
       
   398     delete iDialog;
       
   399     iDialog = NULL;
       
   400     iDialog = CNotepadExternalTextDialog::NewL(
       
   401         aContentPointer, aReturnStatus, aText, aTitle, aDeleteConfirmationText, 
       
   402         REINTERPRET_CAST( CEikDialog**, &iDialog ) 
       
   403         );
       
   404     }
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // CNotepadApi::CreateModelL
       
   408 // -----------------------------------------------------------------------------
       
   409 //
       
   410 EXPORT_C void CNotepadApi::CreateModelL(TInt aResId)
       
   411     {
       
   412     delete iModel;
       
   413     iModel = NULL;
       
   414     iModel = CNotepadModel::NewL(iEnv->FsSession(), aResId);
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CNotepadApi::ProbeMemoL
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 EXPORT_C TBool CNotepadApi::ProbeMemoL(const TInt aKey)
       
   422     {
       
   423     if ( aKey < 0 )
       
   424         {
       
   425         return EFalse;
       
   426         }
       
   427     if ( !iModel )
       
   428         {
       
   429         iModel = CNotepadModel::NewL(
       
   430             iEnv->FsSession(), R_NOTEPAD_SAVE_MEMO );
       
   431         }
       
   432     return 0 == iModel->SeekKey(aKey);
       
   433     }
       
   434 
       
   435 // -----------------------------------------------------------------------------
       
   436 // CNotepadApi::CNotepadApi
       
   437 // private c++ Constructor
       
   438 // -----------------------------------------------------------------------------
       
   439 //
       
   440 CNotepadApi::CNotepadApi()
       
   441     : iEnv(CCoeEnv::Static()), iResourceLoader(*CCoeEnv::Static())
       
   442     {
       
   443     }
       
   444 
       
   445 // -----------------------------------------------------------------------------
       
   446 // CNotepadApi::DoPopupListL
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 HBufC* CNotepadApi::DoPopupListL(
       
   450     const TDesC* aTitle, 
       
   451     TInt aModelResId,
       
   452     TInt aPromptResId, 
       
   453     TInt aEmptyTextResId )
       
   454     {
       
   455     CreateModelL(aModelResId);
       
   456     
       
   457     TBool finished(ETrue);
       
   458     TBool isNotCancelled;
       
   459     TInt itemIndex(0);
       
   460 
       
   461     do
       
   462         {
       
   463         CAknSinglePopupMenuStyleListBox* listbox 
       
   464             = new(ELeave) CAknSinglePopupMenuStyleListBox;
       
   465         CleanupStack::PushL(listbox);
       
   466         CNotepadPopupList* popupList = CNotepadPopupList::NewL(
       
   467             listbox, 
       
   468             R_AVKON_SOFTKEYS_SELECT_CANCEL, 
       
   469             AknPopupLayouts::EMenuWindow,
       
   470             *iModel);
       
   471         CleanupStack::PushL(popupList);
       
   472         iModel->SetNotepadModelObserver(popupList);
       
   473 
       
   474         listbox->ConstructL(popupList, 0);
       
   475         (listbox->Model())->SetItemTextArray(iModel);
       
   476         (listbox->Model())->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   477         listbox->CreateScrollBarFrameL(ETrue);
       
   478 
       
   479         listbox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   480             CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   481         if ( aTitle )
       
   482             {
       
   483             popupList->SetTitleL(*aTitle);
       
   484             }
       
   485         else
       
   486             {
       
   487             HBufC* buf = StringLoader::LoadLC(aPromptResId);
       
   488             popupList->SetTitleL(*buf);
       
   489             CleanupStack::PopAndDestroy(buf);
       
   490             }
       
   491         if ( aEmptyTextResId > 0 )
       
   492             {
       
   493             HBufC* buf = StringLoader::LoadLC(aEmptyTextResId);
       
   494             listbox->View()->SetListEmptyTextL(*buf);
       
   495             CleanupStack::PopAndDestroy(buf);
       
   496             }
       
   497         
       
   498         isNotCancelled = popupList->EnhancedExecuteLD( finished );
       
   499         CleanupStack::Pop( popupList );
       
   500         itemIndex = listbox->CurrentItemIndex();
       
   501         CleanupStack::PopAndDestroy( listbox );
       
   502         }
       
   503     while(!finished);
       
   504     
       
   505     HBufC* fetchedContent = NULL;
       
   506     if ( isNotCancelled )
       
   507         {
       
   508         if (iModel->MdcaCount())
       
   509             {
       
   510             fetchedContent = 
       
   511                 iModel->ContentL( itemIndex );
       
   512             }
       
   513         }
       
   514 
       
   515     return fetchedContent;
       
   516     }
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 // CNotepadApi::ExecReadonlyTextViewerL
       
   520 // -----------------------------------------------------------------------------
       
   521 //
       
   522 EXPORT_C TInt CNotepadApi::ExecReadOnlyTextViewerL(
       
   523     const TDesC& aText, 
       
   524     const TDesC& aTitle, 
       
   525     const TDesC& aDeleteConfirmationText
       
   526     )
       
   527     {
       
   528 
       
   529     HBufC* tmp = NULL;
       
   530 
       
   531     CNotepadApi* api = CNotepadApi::NewLC();
       
   532     
       
   533     TInt returnValueOfDialogExecuteLD;
       
   534 
       
   535     api->CreateTextViewerDialogL( &tmp, returnValueOfDialogExecuteLD, ETrue, aText, aTitle, aDeleteConfirmationText);
       
   536 
       
   537     returnValueOfDialogExecuteLD = STATIC_CAST(CNotepadViewerDialog*, api->iDialog)->ExecuteLD();
       
   538 
       
   539     CleanupStack::PopAndDestroy(); // api
       
   540 
       
   541     delete tmp;
       
   542     return returnValueOfDialogExecuteLD;
       
   543     }
       
   544 
       
   545 // -----------------------------------------------------------------------------
       
   546 // CNotepadApi::ExecTextViewerL
       
   547 // -----------------------------------------------------------------------------
       
   548 //
       
   549 EXPORT_C HBufC* CNotepadApi::ExecTextViewerL(
       
   550     TInt& aReturnStatus, 
       
   551     const TDesC& aText, 
       
   552     const TDesC& aTitle, 
       
   553     const TDesC& aDeleteConfirmationText
       
   554     )
       
   555     {
       
   556 
       
   557     HBufC* tmp = NULL;
       
   558 
       
   559     CNotepadApi* api = CNotepadApi::NewLC();
       
   560 
       
   561     api->CreateTextViewerDialogL( &tmp, aReturnStatus,
       
   562         EFalse, aText, aTitle, aDeleteConfirmationText);
       
   563 
       
   564     STATIC_CAST(CNotepadViewerDialog*, api->iDialog)->ExecuteLD();
       
   565 
       
   566     CleanupStack::PopAndDestroy(); // api
       
   567 
       
   568     return tmp;
       
   569     }
       
   570 
       
   571 // -----------------------------------------------------------------------------
       
   572 // CNotepadApi::ExecTextEditorL
       
   573 // -----------------------------------------------------------------------------
       
   574 //
       
   575 EXPORT_C HBufC* CNotepadApi::ExecTextEditorL(
       
   576     TInt& aReturnStatus,  
       
   577     const TDesC& aText, 
       
   578     const TDesC& aTitle, 
       
   579     const TDesC& aDeleteConfirmationText
       
   580     )
       
   581     {
       
   582     HBufC* tmp = NULL;
       
   583 
       
   584     CNotepadApi* api = CNotepadApi::NewLC();
       
   585 
       
   586     aReturnStatus = KErrNone;
       
   587     api->CreateTextEditorDialogL( &tmp, aReturnStatus, aText, aTitle, aDeleteConfirmationText);
       
   588 
       
   589     STATIC_CAST(CNotepadExternalTextDialog*, api->iDialog)->ExecuteLD();
       
   590 
       
   591     CleanupStack::PopAndDestroy(); // api
       
   592 
       
   593     return tmp;
       
   594     }
       
   595 
       
   596 // -----------------------------------------------------------------------------
       
   597 // CNotepadApi::CNotepadApi_Reserved
       
   598 // -----------------------------------------------------------------------------
       
   599 //
       
   600 EXPORT_C void CNotepadApi::CNotepadApi_Reserved()
       
   601     {
       
   602     }
       
   603 
       
   604 // -----------------------------------------------------------------------------
       
   605 // CNotepadApi::CNotepadApi_Reserved_Static
       
   606 // -----------------------------------------------------------------------------
       
   607 //
       
   608 EXPORT_C void CNotepadApi::CNotepadApi_Reserved_Static()
       
   609     {
       
   610     }
       
   611 
       
   612 // End of File