textrendering/texthandling/stext/TXTFMSTM.CPP
changeset 44 601ab138ba0b
parent 0 1fb32624e06b
child 55 336bee5c2d35
equal deleted inserted replaced
37:6be019398652 44:601ab138ba0b
    22 #include <s32mem.h>
    22 #include <s32mem.h>
    23 #include "TXTFRMAT.H"
    23 #include "TXTFRMAT.H"
    24 #include <txtfmstm.h>
    24 #include <txtfmstm.h>
    25 
    25 
    26 #include "TXTSTD.H"
    26 #include "TXTSTD.H"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "TXTFMSTMTraces.h"
       
    30 #endif
       
    31 
    27 
    32 
    28 const TInt KMaxFormatStreamLength=0x400;  // 1024 bytes
    33 const TInt KMaxFormatStreamLength=0x400;  // 1024 bytes
    29 
    34 
    30 // Standard attributes
    35 // Standard attributes
    31 const TUint KFontProportional=0x01;
    36 const TUint KFontProportional=0x01;
   288 
   293 
   289 
   294 
   290 void RFormatStream::CopyL(const RFormatStream& aSource)
   295 void RFormatStream::CopyL(const RFormatStream& aSource)
   291 	{
   296 	{
   292 	TInt size = aSource.iEnd - aSource.iBase;
   297 	TInt size = aSource.iEnd - aSource.iBase;
       
   298 	if (size < 0)
       
   299 	    {
       
   300 	    OstTrace0( TRACE_DUMP, RFORMATSTREAM_COPYL, "EDebug" );
       
   301 	    }
   293 	__ASSERT_DEBUG(size >= 0,Panic(EDebug));
   302 	__ASSERT_DEBUG(size >= 0,Panic(EDebug));
   294 	if (size == 0)
   303 	if (size == 0)
   295 		Reset();
   304 		Reset();
   296 	else
   305 	else
   297 		{
   306 		{
   355 // Return a pointer to the stored bytecode and put its length in bytes in aLength.
   364 // Return a pointer to the stored bytecode and put its length in bytes in aLength.
   356 const TUint8* RFormatStream::Ptr(TInt& aLength) const
   365 const TUint8* RFormatStream::Ptr(TInt& aLength) const
   357 	{
   366 	{
   358 	__TEST_INVARIANT;
   367 	__TEST_INVARIANT;
   359 	aLength=iEnd-iBase;
   368 	aLength=iEnd-iBase;
       
   369 	if (!((iBase==NULL && aLength==0) || (iBase!=NULL && aLength>0)))
       
   370 	    {
       
   371 	    OstTrace0( TRACE_DUMP, RFORMATSTREAM_PTR, "ECorruptFormatLayer" );
       
   372 	    }
   360 	__ASSERT_DEBUG((iBase==NULL && aLength==0) || (iBase!=NULL && aLength>0),Panic(ECorruptFormatLayer));
   373 	__ASSERT_DEBUG((iBase==NULL && aLength==0) || (iBase!=NULL && aLength>0),Panic(ECorruptFormatLayer));
   361 	return iBase;
   374 	return iBase;
   362 	}
   375 	}
   363 
   376 
   364 
   377 
  1592 			else
  1605 			else
  1593 				requiredTabCount++;
  1606 				requiredTabCount++;
  1594 			}
  1607 			}
  1595 		}
  1608 		}
  1596 // ASSERT: The tabList offsets are as we would expect in a normal (correct) completion.	
  1609 // ASSERT: The tabList offsets are as we would expect in a normal (correct) completion.	
       
  1610 	if (offsetInDesired!=aDesiredTabCount)
       
  1611 	    {
       
  1612 	    OstTrace0( TRACE_FATAL, RFORMATSTREAM_MERGETABLISTS, "EStoreTabError" );
       
  1613 	    }
  1597 	__ASSERT_ALWAYS(offsetInDesired==aDesiredTabCount,Panic(EStoreTabError));
  1614 	__ASSERT_ALWAYS(offsetInDesired==aDesiredTabCount,Panic(EStoreTabError));
       
  1615 	if (offsetInCurrent!=aCurrentTabCount)
       
  1616 	    {
       
  1617 	    OstTrace0( TRACE_FATAL, DUP1_RFORMATSTREAM_MERGETABLISTS, "EStoreTabError" );
       
  1618 	    }
  1598 	__ASSERT_ALWAYS(offsetInCurrent==aCurrentTabCount,Panic(EStoreTabError));
  1619 	__ASSERT_ALWAYS(offsetInCurrent==aCurrentTabCount,Panic(EStoreTabError));
  1599 	return requiredTabCount;
  1620 	return requiredTabCount;
  1600 	}
  1621 	}
  1601 
  1622 
  1602 
  1623 
  1772 	// Read typeface name size
  1793 	// Read typeface name size
  1773 	TInt length=*aPtr++;
  1794 	TInt length=*aPtr++;
  1774 	//
  1795 	//
  1775 	// Read typeface name
  1796 	// Read typeface name
  1776 	TInt typefaceLength=length-KTypefaceFlags;
  1797 	TInt typefaceLength=length-KTypefaceFlags;
       
  1798 	
       
  1799 	if ((typefaceLength%2)!=0)
       
  1800 	    {
       
  1801 	    OstTrace0( TRACE_DUMP, RFORMATSTREAM_READVALUE, "ECorruptFormatLayer" );
       
  1802 	    }
  1777 	__ASSERT_DEBUG((typefaceLength%2)==0,Panic(ECorruptFormatLayer)); // must be an even number
  1803 	__ASSERT_DEBUG((typefaceLength%2)==0,Panic(ECorruptFormatLayer)); // must be an even number
  1778 
  1804 
  1779 	TPtr name=aTypeface.iName.Des();
  1805 	TPtr name=aTypeface.iName.Des();
  1780 	Mem::Copy(CONST_CAST(TText*,name.Ptr()),aPtr,typefaceLength);
  1806 	Mem::Copy(CONST_CAST(TText*,name.Ptr()),aPtr,typefaceLength);
  1781 	typefaceLength>>=1;
  1807 	typefaceLength>>=1;
  1828 // aPtr is incremented by the appropriate amount following a read.
  1854 // aPtr is incremented by the appropriate amount following a read.
  1829 //
  1855 //
  1830 	{
  1856 	{
  1831 	TInt length=TheAttributeLength[aType];
  1857 	TInt length=TheAttributeLength[aType];
  1832 
  1858 
       
  1859 	if (length<0)
       
  1860 	    {
       
  1861 	    OstTrace0( TRACE_DUMP, RFORMATSTREAM_LENGTH, "EAttributeLengthLookupNegative" );
       
  1862 	    }
  1833 	__ASSERT_DEBUG(length>=0,Panic(EAttributeLengthLookupNegative));
  1863 	__ASSERT_DEBUG(length>=0,Panic(EAttributeLengthLookupNegative));
  1834 	if (length>0)
  1864 	if (length>0)
  1835 		return length;
  1865 		return length;
  1836 	else
  1866 	else
  1837 		return *aPtr++;
  1867 		return *aPtr++;