You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by js...@apache.org on 2014/03/28 10:40:25 UTC
svn commit: r1582653 - in
/openoffice/branches/AOO410/main/sw/source/filter/ww8: ww8par6.cxx
ww8struc.hxx
Author: jsc
Date: Fri Mar 28 09:40:24 2014
New Revision: 1582653
URL: http://svn.apache.org/r1582653
Log:
#124468# add checks for the read numbers of column for a section
Patch By: orw
Modified:
openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx
openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8struc.hxx
Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx?rev=1582653&r1=1582652&r2=1582653&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8par6.cxx Fri Mar 28 09:40:24 2014
@@ -921,7 +921,14 @@ void wwSectionManager::CreateSep(const l
// sprmSFBiDi
aNewSection.maSep.fBiDi = eVer >= ww::eWW8 ? ReadBSprm(pSep, 0x3228, 0) : 0;
+ // Reading section property sprmSCcolumns - one less than the number of columns in the section.
+ // It must be less than MAX_NO_OF_SEP_COLUMNS according the WW8 specification.
aNewSection.maSep.ccolM1 = ReadSprm(pSep, pIds[3], 0 );
+ if ( aNewSection.maSep.ccolM1 >= MAX_NO_OF_SEP_COLUMNS )
+ {
+ // fallback to one column
+ aNewSection.maSep.ccolM1 = 0;
+ }
//sprmSDxaColumns - Default-Abstand 1.25 cm
aNewSection.maSep.dxaColumns = ReadUSprm( pSep, pIds[4], 708 );
@@ -931,39 +938,41 @@ void wwSectionManager::CreateSep(const l
if (eVer >= ww::eWW6)
{
- // sprmSFEvenlySpaced
- aNewSection.maSep.fEvenlySpaced =
- ReadBSprm(pSep, (eVer <= ww::eWW7 ? 138 : 0x3005), 1) ? true : false;
+ // sprmSFEvenlySpaced
+ aNewSection.maSep.fEvenlySpaced = ReadBSprm( pSep, ( eVer <= ww::eWW7 ? 138 : 0x3005 ), 1 ) ? true : false;
- if (aNewSection.maSep.ccolM1 > 0 && !aNewSection.maSep.fEvenlySpaced)
- {
- aNewSection.maSep.rgdxaColumnWidthSpacing[0] = 0;
- int nCols = aNewSection.maSep.ccolM1 + 1;
- int nIdx = 0;
- for (int i = 0; i < nCols; ++i)
- {
- //sprmSDxaColWidth
- const sal_uInt8* pSW = pSep->HasSprm( (eVer <= ww::eWW7 ? 136 : 0xF203), sal_uInt8( i ) );
+ if ( aNewSection.maSep.ccolM1 > 0 && !aNewSection.maSep.fEvenlySpaced )
+ {
+ int nColumnDataIdx = 0;
+ aNewSection.maSep.rgdxaColumnWidthSpacing[nColumnDataIdx] = 0;
- ASSERT( pSW, "+Sprm 136 (bzw. 0xF203) (ColWidth) fehlt" );
- sal_uInt16 nWidth = pSW ? SVBT16ToShort(pSW + 1) : 1440;
+ const sal_uInt16 nColumnWidthSprmId = ( eVer <= ww::eWW7 ? 136 : 0xF203 );
+ const sal_uInt16 nColumnSpacingSprmId = ( eVer <= ww::eWW7 ? 137 : 0xF204 );
+ const sal_uInt8 nColumnCount = static_cast< sal_uInt8 >(aNewSection.maSep.ccolM1 + 1);
+ for ( sal_uInt8 nColumn = 0; nColumn < nColumnCount; ++nColumn )
+ {
+ //sprmSDxaColWidth
+ const sal_uInt8* pSW = pSep->HasSprm( nColumnWidthSprmId, nColumn );
- aNewSection.maSep.rgdxaColumnWidthSpacing[++nIdx] = nWidth;
+ ASSERT( pSW != NULL, "+Sprm 136 (bzw. 0xF203) (ColWidth) fehlt" );
+ sal_uInt16 nWidth = pSW != NULL ? SVBT16ToShort( pSW + 1 ) : 1440;
- if (i < nCols-1)
- {
- //sprmSDxaColSpacing
- const sal_uInt8* pSD = pSep->HasSprm( (eVer <= ww::eWW7 ? 137 : 0xF204), sal_uInt8( i ) );
+ aNewSection.maSep.rgdxaColumnWidthSpacing[++nColumnDataIdx] = nWidth;
- ASSERT( pSD, "+Sprm 137 (bzw. 0xF204) (Colspacing) fehlt" );
- if( pSD )
- {
- nWidth = SVBT16ToShort(pSD + 1);
- aNewSection.maSep.rgdxaColumnWidthSpacing[++nIdx] = nWidth;
- }
- }
- }
- }
+ if ( nColumn < nColumnCount - 1 )
+ {
+ //sprmSDxaColSpacing
+ const sal_uInt8* pSD = pSep->HasSprm( nColumnSpacingSprmId, nColumn );
+
+ ASSERT( pSD, "+Sprm 137 (bzw. 0xF204) (Colspacing) fehlt" );
+ if ( pSD )
+ {
+ nWidth = SVBT16ToShort( pSD + 1 );
+ aNewSection.maSep.rgdxaColumnWidthSpacing[++nColumnDataIdx] = nWidth;
+ }
+ }
+ }
+ }
}
static const sal_uInt16 aVer2Ids1[] =
Modified: openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8struc.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8struc.hxx?rev=1582653&r1=1582652&r2=1582653&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8struc.hxx (original)
+++ openoffice/branches/AOO410/main/sw/source/filter/ww8/ww8struc.hxx Fri Mar 28 09:40:24 2014
@@ -967,6 +967,9 @@ struct WW8_WKB
# pragma pack()
#endif
+// Maximum number of columns according the WW8 specification
+static const sal_uInt8 MAX_NO_OF_SEP_COLUMNS = 44;
+
struct SEPr
{
SEPr();
@@ -1026,7 +1029,7 @@ struct SEPr
sal_uInt32 dzaGutter;
sal_uInt32 dyaHdrTop;
sal_uInt32 dyaHdrBottom;
- sal_Int16 ccolM1;
+ sal_Int16 ccolM1; // have to be less than MAX_NO_OF_SEP_COLUMNS according the WW8 specification
sal_Int8 fEvenlySpaced;
sal_Int8 reserved3;
sal_uInt8 fBiDi;
@@ -1034,7 +1037,13 @@ struct SEPr
sal_uInt8 fRTLGutter;
sal_uInt8 fRTLAlignment;
sal_Int32 dxaColumns;
- sal_Int32 rgdxaColumnWidthSpacing[89];
+
+ // Fixed array - two entries for each SEP column to store width of column and spacing to next column.
+ // At odd index values [1,3,5,...] the column widths are stored.
+ // At even index values [2,4,6,...] the spacings to the next columns are stored.
+ // Value at index 0 is initialized with 0 and used for easier interation on the array
+ sal_Int32 rgdxaColumnWidthSpacing[MAX_NO_OF_SEP_COLUMNS*2 + 1];
+
sal_Int32 dxaColumnWidth;
sal_uInt8 dmOrientFirst;
sal_uInt8 fLayout;