textrendering/texthandling/stext/Txtparse.cpp
changeset 40 91ef7621b7fc
parent 0 1fb32624e06b
child 55 336bee5c2d35
equal deleted inserted replaced
21:f2f7b3284356 40:91ef7621b7fc
    17 
    17 
    18 
    18 
    19 #include "TXTRICH.H"
    19 #include "TXTRICH.H"
    20 #include "TXTSTD.H"
    20 #include "TXTSTD.H"
    21 #include "ParseLst.h"
    21 #include "ParseLst.h"
       
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "TxtparseTraces.h"
       
    25 #endif
       
    26 
    22 
    27 
    23 
    28 
    24 // Install and activate a particular parser, app provides instance
    29 // Install and activate a particular parser, app provides instance
    25 EXPORT_C void CRichText::ActivateParserL(MParser* aParser)
    30 EXPORT_C void CRichText::ActivateParserL(MParser* aParser)
    26 	{
    31 	{
    36 
    41 
    37 // Deactivate and deinstall a particular parser, identified by ptr to instance
    42 // Deactivate and deinstall a particular parser, identified by ptr to instance
    38 EXPORT_C void CRichText::DeactivateParser(MParser* aParser)
    43 EXPORT_C void CRichText::DeactivateParser(MParser* aParser)
    39 	{
    44 	{
    40 	CParserList* activeParserList = (CParserList*)Dll::Tls();
    45 	CParserList* activeParserList = (CParserList*)Dll::Tls();
       
    46 	if (!activeParserList)
       
    47 	    {
       
    48 	    OstTrace0( TRACE_DUMP, CRICHTEXT_DEACTIVATEPARSER, "EParserListNotInitialized" );
       
    49 	    }
    41 	__ASSERT_DEBUG(activeParserList, Panic(EParserListNotInitialized));
    50 	__ASSERT_DEBUG(activeParserList, Panic(EParserListNotInitialized));
    42 	activeParserList->DeactivateParser(aParser);
    51 	activeParserList->DeactivateParser(aParser);
    43 	if ((activeParserList->iRefCount == 0) && (activeParserList->iNumberInList == 0))
    52 	if ((activeParserList->iRefCount == 0) && (activeParserList->iNumberInList == 0))
    44 		{
    53 		{
    45 		Dll::FreeTls();
    54 		Dll::FreeTls();
    78 
    87 
    79 
    88 
    80 // Create ParserLst instance and retain ownership of it but pass address to EText TLS
    89 // Create ParserLst instance and retain ownership of it but pass address to EText TLS
    81 void CRichText::CreateParserETextTLSL()
    90 void CRichText::CreateParserETextTLSL()
    82 	{
    91 	{
       
    92 	if (Dll::Tls() != NULL)
       
    93 	    {
       
    94 	    OstTrace0( TRACE_DUMP, CRICHTEXT_CREATEPARSERETEXTTLSL, "EParserListAlreadyExists" );
       
    95 	    }
    83 	__ASSERT_DEBUG(Dll::Tls() == NULL, Panic(EParserListAlreadyExists));
    96 	__ASSERT_DEBUG(Dll::Tls() == NULL, Panic(EParserListAlreadyExists));
    84 	CParserList* activeParserList = new (ELeave) CParserList;
    97 	CParserList* activeParserList = new (ELeave) CParserList;
    85 	CleanupStack::PushL(activeParserList);
    98 	CleanupStack::PushL(activeParserList);
    86 	TInt err = Dll::SetTls(activeParserList);
    99 	TInt err = Dll::SetTls(activeParserList);
    87 	User::LeaveIfError(err);
   100 	User::LeaveIfError(err);
   105 	}
   118 	}
   106 
   119 
   107 	
   120 	
   108 EXPORT_C TBool CRichText::ParseText(TInt& aStartOfTags, TInt& aLength, TBool aForceScanAllText)
   121 EXPORT_C TBool CRichText::ParseText(TInt& aStartOfTags, TInt& aLength, TBool aForceScanAllText)
   109 	{
   122 	{
       
   123 	if (!iIndex.IsPtr())
       
   124 	    {
       
   125 	    OstTrace0( TRACE_DUMP, CRICHTEXT_PARSETEXT, "EParserListTextIndexNotInitialized" );
       
   126 	    }
   110 	__ASSERT_ALWAYS(iIndex.IsPtr(),Panic(EParserListTextIndexNotInitialized));
   127 	__ASSERT_ALWAYS(iIndex.IsPtr(),Panic(EParserListTextIndexNotInitialized));
   111 	TBool foundSomething = EFalse;
   128 	TBool foundSomething = EFalse;
   112 	if (iParserData->iActiveParserList && iParserData->iEditObserver)
   129 	if (iParserData->iActiveParserList && iParserData->iEditObserver)
   113 		{
   130 		{
   114 		if (aForceScanAllText)
   131 		if (aForceScanAllText)
   131 	TCharFormatX format;
   148 	TCharFormatX format;
   132 	TCharFormatXMask varies;
   149 	TCharFormatXMask varies;
   133 	TBool success = EFalse;
   150 	TBool success = EFalse;
   134 	TBuf<1> buf;
   151 	TBuf<1> buf;
   135 
   152 
       
   153 	if (!iParserData->iActiveParserList)
       
   154 	    {
       
   155 	    OstTrace0( TRACE_DUMP, CRICHTEXT_DOCURSOROVERTAG, "EParserListNotInitialized" );
       
   156 	    }
   136 	__ASSERT_DEBUG(iParserData->iActiveParserList, Panic(EParserListNotInitialized));
   157 	__ASSERT_DEBUG(iParserData->iActiveParserList, Panic(EParserListNotInitialized));
       
   158 	if (!iParserData->iEditObserver)
       
   159 	    {
       
   160 	    OstTrace0( TRACE_DUMP, DUP1_CRICHTEXT_DOCURSOROVERTAG, "EParserListNotActive" );
       
   161 	    }
   137 	__ASSERT_DEBUG(iParserData->iEditObserver, Panic(EParserListNotActive));
   162 	__ASSERT_DEBUG(iParserData->iEditObserver, Panic(EParserListNotActive));
   138 	GetExtendedCharFormat(format, varies, aPos, 1);
   163 	GetExtendedCharFormat(format, varies, aPos, 1);
   139 	Extract(buf, aPos, 1);
   164 	Extract(buf, aPos, 1);
   140 	if ((format.iParserTag) && (buf[0] != 0x2029))
   165 	if ((format.iParserTag) && (buf[0] != 0x2029))
   141 		{
   166 		{