ooo-build r12009 - in trunk: . patches/src680



Author: kyoshida
Date: Tue Mar 25 22:42:14 2008
New Revision: 12009
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12009&view=rev

Log:
2008-03-25  Kohei Yoshida  <kyoshida novell com>

	* patches/src680/sc-formula-syntax.diff: modified the Excel R1C1 parser
	to make it more strict.  The parser now invalidates an address/range 
	string if the string has any trailing characters.


Modified:
   trunk/ChangeLog
   trunk/patches/src680/sc-formula-syntax.diff

Modified: trunk/patches/src680/sc-formula-syntax.diff
==============================================================================
--- trunk/patches/src680/sc-formula-syntax.diff	(original)
+++ trunk/patches/src680/sc-formula-syntax.diff	Tue Mar 25 22:42:14 2008
@@ -527,8 +527,93 @@
  			}
 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/source/core/tool/address.cxx sc/source/core/tool/address.cxx
 --- sc.clean/source/core/tool/address.cxx	2008-03-03 11:24:50.000000000 -0500
-+++ sc/source/core/tool/address.cxx	2008-03-25 13:07:48.000000000 -0400
-@@ -623,10 +623,24 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
++++ sc/source/core/tool/address.cxx	2008-03-25 18:28:59.000000000 -0400
+@@ -428,7 +428,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+                            const ScAddress::Details& rDetails,
+                            BOOL bOnlyAcceptSingle )
+ {
+-    const sal_Unicode* pTmp;
++    const sal_Unicode* pTmp = NULL;
+     String aExternDocName, aStartTabName, aEndTabName;
+     USHORT nFlags = SCA_VALID | SCA_VALID_TAB, nFlags2 = SCA_VALID_TAB2;
+ 
+@@ -453,11 +453,25 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+         {
+             if( p[0] != ':' || (p[1] != 'R' && p[1] != 'r' ) ||
+                 NULL == (pTmp = lcl_r1c1_get_row( p+1, rDetails, &r.aEnd, &nFlags2 )))
+-            {   // Fallback to just the initial R
++            {
++                // Only the initial row number is given, or the second row
++                // number is invalid. Fallback to just the initial R
+                 nFlags |= (nFlags << 4);
+                 r.aEnd.SetRow( r.aStart.Row() );
+-            } else
++            }
++            else
++            {
++                // Full row range successfully parsed.
+                 nFlags |= (nFlags2 << 4);
++                p = pTmp;
++            }
++
++            if (p && p[0] != 0)
++            {
++                // any trailing invalid character must invalidate the whole address.
++                nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB);
++                return nFlags;
++            }
+ 
+             nFlags |= 
+                 SCA_VALID_COL | SCA_VALID_COL2 |
+@@ -477,9 +491,29 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+             (*pTmp != 'C' && *pTmp != 'c') ||
+             NULL == (pTmp = lcl_r1c1_get_col( pTmp, rDetails, &r.aEnd, &nFlags2 )))
+         {
++            // single cell reference
++
++            if (p && p[0] != 0)
++            {
++                // any trailing invalid character must invalidate the whole address.
++                nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB);
++                return nFlags;
++            }
++
+             return bOnlyAcceptSingle ? lcl_XL_LinkSheetRef( r, pDoc,
+                 aExternDocName, aStartTabName, aEndTabName, nFlags ) : 0;
+         }
++        p = pTmp;
++
++        // double reference
++
++        if (p && p[0] != 0)
++        {
++            // any trailing invalid character must invalidate the whole range.
++            nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB | 
++                        SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2);
++            return nFlags;
++        }
+ 
+         nFlags |= (nFlags2 << 4);
+         return bOnlyAcceptSingle ? 0 : lcl_XL_LinkSheetRef( r, pDoc,
+@@ -497,7 +531,17 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+             r.aEnd.SetCol( r.aStart.Col() );
+         }
+         else
++        {
+             nFlags |= (nFlags2 << 4);
++            p = pTmp;
++        }
++
++        if (p && p[0] != 0)
++        {
++            // any trailing invalid character must invalidate the whole address.
++            nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB);
++            return nFlags;
++        }
+ 
+         nFlags |= 
+             SCA_VALID_ROW | SCA_VALID_ROW2 |
+@@ -623,10 +667,24 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
      // prepare as if it's a singleton, in case we want to fall back */
      r.aEnd.SetCol( r.aStart.Col() );
      r.aEnd.SetRow( r.aStart.Row() );    // don't overwrite sheet number as parsed in lcl_ScRange_Parse_XL_Header
@@ -555,7 +640,7 @@
          return nFlags;
      }
  
-@@ -640,6 +654,14 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
+@@ -640,6 +698,14 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
          return lcl_XL_LinkSheetRef( r, pDoc,
              aExternDocName, aStartTabName, aEndTabName, nFlags );
  
@@ -570,7 +655,7 @@
      nFlags |= (nFlags2 << 4);
      return lcl_XL_LinkSheetRef( r, pDoc,
          aExternDocName, aStartTabName, aEndTabName, nFlags );
-@@ -1334,9 +1356,12 @@ void ScAddress::Format( String& r, USHOR
+@@ -1334,9 +1400,12 @@ void ScAddress::Format( String& r, USHOR
  
              case CONV_XL_A1:
              case CONV_XL_R1C1:
@@ -586,7 +671,7 @@
                  r += aTabName;
                  r += '!';
                  break;
-@@ -1434,6 +1459,7 @@ lcl_ScRange_Format_XL_Header( String& r,
+@@ -1434,6 +1503,7 @@ lcl_ScRange_Format_XL_Header( String& r,
  void ScRange::Format( String& r, USHORT nFlags, ScDocument* pDoc,
                        const ScAddress::Details& rDetails ) const
  {
@@ -2129,7 +2214,7 @@
  	{
 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=sc.vpj sc.clean/source/ui/pagedlg/areasdlg.cxx sc/source/ui/pagedlg/areasdlg.cxx
 --- sc.clean/source/ui/pagedlg/areasdlg.cxx	2008-03-03 11:24:50.000000000 -0500
-+++ sc/source/ui/pagedlg/areasdlg.cxx	2008-03-25 13:09:04.000000000 -0400
++++ sc/source/ui/pagedlg/areasdlg.cxx	2008-03-25 18:31:27.000000000 -0400
 @@ -61,6 +61,7 @@
  #include "docsh.hxx"
  #include "globstr.hrc"
@@ -2138,7 +2223,7 @@
  
  // STATIC DATA ---------------------------------------------------------------
  
-@@ -85,10 +86,32 @@ const USHORT SC_AREASDLG_RR_OFFSET  = 2;
+@@ -85,10 +86,34 @@ const USHORT SC_AREASDLG_RR_OFFSET  = 2;
  
  // globale Funktionen (->am Ende der Datei):
  
@@ -2148,6 +2233,7 @@
 +bool    lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange );
 +void	lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr );
  
++#if 0
 +static void printAddressFlags(USHORT nFlag)
 +{
 +    if ((nFlag & SCA_COL_ABSOLUTE  ) == SCA_COL_ABSOLUTE  )  printf("SCA_COL_ABSOLUTE \n");
@@ -2171,10 +2257,11 @@
 +    if ((nFlag & SCA_ABS_3D        ) == SCA_ABS_3D        )  printf("SCA_ABS_3D       \n");
 +    if ((nFlag & SCR_ABS_3D        ) == SCR_ABS_3D        )  printf("SCR_ABS_3D       \n");
 +}
++#endif
  
  //============================================================================
  //	class ScPrintAreasDlg
-@@ -190,11 +213,11 @@ void ScPrintAreasDlg::SetReference( cons
+@@ -190,11 +215,11 @@ void ScPrintAreasDlg::SetReference( cons
  			RefInputStart( pRefInputEdit );
  
  		String	aStr;
@@ -2188,7 +2275,7 @@
  
  //			aEdPrintArea.ReplaceSelected( aStr );
  
-@@ -210,7 +233,7 @@ void ScPrintAreasDlg::SetReference( cons
+@@ -210,7 +235,7 @@ void ScPrintAreasDlg::SetReference( cons
  		else
  		{
  			BOOL bRow = ( &aEdRepeatRow == pRefInputEdit );
@@ -2197,7 +2284,7 @@
  			pRefInputEdit->SetRefString( aStr );
  		}
  	}
-@@ -225,8 +248,9 @@ void ScPrintAreasDlg::AddRefEntry()
+@@ -225,8 +250,9 @@ void ScPrintAreasDlg::AddRefEntry()
  {
  	if ( pRefInputEdit == &aEdPrintArea )
  	{
@@ -2208,7 +2295,7 @@
  		aEdPrintArea.SetText(aVal);
  
  		xub_StrLen nLen = aVal.Len();
-@@ -296,6 +320,8 @@ void ScPrintAreasDlg::Impl_Reset()
+@@ -296,6 +322,8 @@ void ScPrintAreasDlg::Impl_Reset()
  	//-------------------------
  	aStrRange.Erase();
      String aOne;
@@ -2217,7 +2304,7 @@
      USHORT nRangeCount = pDoc->GetPrintRangeCount( nCurTab );
      for (USHORT i=0; i<nRangeCount; i++)
      {
-@@ -303,9 +329,8 @@ void ScPrintAreasDlg::Impl_Reset()
+@@ -303,9 +331,8 @@ void ScPrintAreasDlg::Impl_Reset()
          if (pPrintRange)
          {
              if ( aStrRange.Len() )
@@ -2229,7 +2316,7 @@
              aStrRange += aOne;
          }
      }
-@@ -314,13 +339,13 @@ void ScPrintAreasDlg::Impl_Reset()
+@@ -314,13 +341,13 @@ void ScPrintAreasDlg::Impl_Reset()
  	//-------------------------------
  	// Wiederholungszeile
  	//-------------------------------
@@ -2245,7 +2332,7 @@
  	aEdRepeatCol.SetText( aStrRange );
  
  	Impl_ModifyHdl( &aEdPrintArea );
-@@ -345,9 +370,9 @@ BOOL ScPrintAreasDlg::Impl_GetItem( Edit
+@@ -345,9 +372,9 @@ BOOL ScPrintAreasDlg::Impl_GetItem( Edit
  	if ( (aRangeStr.Len() > 0) && &aEdPrintArea != pEd )
  	{
  		ScRange aRange;
@@ -2258,7 +2345,7 @@
  	}
  
  	rItem.SetValue( aRangeStr );
-@@ -368,25 +393,41 @@ BOOL ScPrintAreasDlg::Impl_CheckRefStrin
+@@ -368,25 +395,35 @@ BOOL ScPrintAreasDlg::Impl_CheckRefStrin
  	BOOL bPrintAreaOk = TRUE;
  	if ( aStrPrintArea.Len() )
  	{
@@ -2281,14 +2368,8 @@
 -			if (!(nResult & SCA_VALID))
 -				bPrintAreaOk = FALSE;
 +			String aOne = aStrPrintArea.GetToken(i, sep);
-+            bool bIsRange = (aOne.Search(rsep, 0) != STRING_NOTFOUND);
-+            if (bIsRange)
-+            {
-+                USHORT nResult = aRange.Parse( aOne, pDoc, eConv );
-+                if ((nResult & nValidRange) != nValidRange)
-+                    bPrintAreaOk = FALSE;
-+            }
-+            else
++            USHORT nResult = aRange.Parse( aOne, pDoc, eConv );
++            if ((nResult & nValidRange) != nValidRange)
 +            {
 +                USHORT nResult = aAddr.Parse( aOne, pDoc, eConv );
 +                if ((nResult & nValidAddr) != nValidAddr)
@@ -2309,7 +2390,7 @@
  
  	// Fehlermeldungen
  
-@@ -418,17 +459,18 @@ void ScPrintAreasDlg::Impl_FillLists()
+@@ -418,17 +455,18 @@ void ScPrintAreasDlg::Impl_FillLists()
  	ScRange	aRange;
  	String	aStrRange;
  	BOOL bSimple = TRUE;
@@ -2330,7 +2411,7 @@
  	}
  
      aLbPrintArea.SetEntryData( SC_AREASDLG_PR_SELECT, new String( aStrRange ) );
-@@ -457,11 +499,11 @@ void ScPrintAreasDlg::Impl_FillLists()
+@@ -457,11 +495,11 @@ void ScPrintAreasDlg::Impl_FillLists()
  				{
  					pData->GetName( aName );
  					pData->GetSymbol( aSymbol );
@@ -2344,7 +2425,7 @@
  							aLbPrintArea.SetEntryData(
  								aLbPrintArea.InsertEntry( aName ),
  								new String( aSymbol ) );
-@@ -469,7 +511,7 @@ void ScPrintAreasDlg::Impl_FillLists()
+@@ -469,7 +507,7 @@ void ScPrintAreasDlg::Impl_FillLists()
  
  						if ( pData->HasType( RT_ROWHEADER ) )
  						{
@@ -2353,7 +2434,7 @@
  							aLbRepeatRow.SetEntryData(
  								aLbRepeatRow.InsertEntry( aName ),
  								new String( aSymbol ) );
-@@ -477,7 +519,7 @@ void ScPrintAreasDlg::Impl_FillLists()
+@@ -477,7 +515,7 @@ void ScPrintAreasDlg::Impl_FillLists()
  
  						if ( pData->HasType( RT_COLHEADER ) )
  						{
@@ -2362,21 +2443,21 @@
  							aLbRepeatCol.SetEntryData(
  								aLbRepeatCol.InsertEntry( aName ),
  								new String( aSymbol ) );
-@@ -669,9 +711,11 @@ IMPL_LINK( ScPrintAreasDlg, Impl_ModifyH
+@@ -669,9 +707,11 @@ IMPL_LINK( ScPrintAreasDlg, Impl_ModifyH
  //============================================================================
  // globale Funktionen:
  
 -//----------------------------------------------------------------------------
 +// ----------------------------------------------------------------------------
++
++// TODO: It might make sense to move these functions to address.?xx. -kohei
  
 -BOOL lcl_CheckRepeatOne( const String& rStr, BOOL bIsRow, SCCOLROW& rVal )
-+// TODO: It might make sense to move these functions to address.?xx. -kohei
-+
 +bool lcl_CheckOne_OOO( const String& rStr, bool bIsRow, SCCOLROW& rVal )
  {
  	// Zulaessige Syntax fuer rStr:
  	// Row: [$]1-MAXTAB
-@@ -713,115 +757,160 @@ BOOL lcl_CheckRepeatOne( const String& r
+@@ -713,115 +753,160 @@ BOOL lcl_CheckRepeatOne( const String& r
  	return bStrOk;
  }
  
@@ -2581,7 +2662,7 @@
 +        bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
 +        if (!bRes)
 +            return false;
- 
++
 +        if (pRange)
 +        {
 +            if (bIsRow)
@@ -2613,7 +2694,7 @@
 +    const ScAddress::Convention eConv = pDoc->GetAddressConvention();
 +    const ScAddress& rStart = pRange->aStart;
 +    const ScAddress& rEnd   = pRange->aEnd;
-+
+ 
 +    const USHORT nFmt = bIsRow ? (SCA_VALID_ROW | SCA_ROW_ABSOLUTE) : (SCA_VALID_COL | SCA_COL_ABSOLUTE);
 +    String aTmpStr;
 +    rStart.Format(aTmpStr, nFmt, pDoc, eConv);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]