[Libreoffice-commits] core.git: sw/source

Stephan Bergmann sbergman at redhat.com
Tue Jan 28 08:14:47 PST 2014


 sw/source/filter/ww8/wrtww8.cxx   |    2 -
 sw/source/filter/ww8/ww8graf2.cxx |    8 +++----
 sw/source/filter/ww8/ww8scan.cxx  |    8 +++----
 sw/source/filter/ww8/ww8struc.hxx |   39 +++++++++++++++++++++++++-------------
 4 files changed, 35 insertions(+), 22 deletions(-)

New commits:
commit 424717f44c3c63569d1d321611ff5a3d3b7a7ff5
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 28 17:09:39 2014 +0100

    MSVC apparently does not pack bitfields of different type
    
    ...so c963d7e642c24f40c19fb9dc227db5da96728c12 "bool improvements" changed the
    size of some structs in sw/source/filter/ww8/ww8struc.hxx that are used for raw
    IO and thus have fixed layout requirements.  Reverted that part of the commit
    and instead use explicit conversion between bool and sal_uInt16 where necessary.
    
    Also added static asserts for those structs that were easily identifiable as
    being used for raw IO.  (Also reverted the bools in some other structs that were
    not (easily) identified as being used for raw IO even if that might thus not be
    necessary, but better safe than sorry.)
    
    Change-Id: I60e17a2821d67961f50691625999f2aa72c5ebce

diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 43b5fbe..de5c281 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -633,7 +633,7 @@ void WW8Export::ExportDopTypography(WW8DopTypography &rTypo)
 
     const IDocumentSettingAccess* pIDocumentSettingAccess = GetWriter().getIDocumentSettingAccess();
 
-    rTypo.fKerningPunct = pIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION);
+    rTypo.fKerningPunct = sal_uInt16(pIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION));
     rTypo.iJustification = pDoc->getCharacterCompressionType();
 }
 
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index d9f9b97..15118e3 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -756,14 +756,14 @@ void WW8FSPAShadowToReal( WW8_FSPA_SHADOW * pFSPAS, WW8_FSPA * pFSPA )
 
     sal_uInt16 nBits        = SVBT16ToShort( pFSPAS->aBits1 );
 
-    pFSPA->bHdr         = 0 !=  ( nBits & 0x0001 );
+    pFSPA->bHdr         = sal_uInt16(0 !=  ( nBits & 0x0001 ));
     pFSPA->nbx          =       ( nBits & 0x0006 ) >> 1;
     pFSPA->nby          =       ( nBits & 0x0018 ) >> 3;
     pFSPA->nwr          =       ( nBits & 0x01E0 ) >> 5;
     pFSPA->nwrk         =       ( nBits & 0x1E00 ) >> 9;
-    pFSPA->bRcaSimple   = 0 !=  ( nBits & 0x2000 );
-    pFSPA->bBelowText   = 0 !=  ( nBits & 0x4000 );
-    pFSPA->bAnchorLock  = 0 !=  ( nBits & 0x8000 );
+    pFSPA->bRcaSimple   = sal_uInt16(0 !=  ( nBits & 0x2000 ));
+    pFSPA->bBelowText   = sal_uInt16(0 !=  ( nBits & 0x4000 ));
+    pFSPA->bAnchorLock  = sal_uInt16(0 !=  ( nBits & 0x8000 ));
     pFSPA->nTxbx = SVBT32ToUInt32( pFSPAS->nTxbx );
 }
 
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 0a49f04..922aa0d 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -6008,10 +6008,10 @@ WW8_STD* WW8Style::Read1STDFixed( short& rSkip, short* pcbStd )
             a16Bit = 0;
             rSt >> a16Bit;
             pStd->sti          =        a16Bit & 0x0fff  ;
-            pStd->fScratch     = 0 != ( a16Bit & 0x1000 );
-            pStd->fInvalHeight = 0 != ( a16Bit & 0x2000 );
-            pStd->fHasUpe      = 0 != ( a16Bit & 0x4000 );
-            pStd->fMassCopy    = 0 != ( a16Bit & 0x8000 );
+            pStd->fScratch     = sal_uInt16(0 != ( a16Bit & 0x1000 ));
+            pStd->fInvalHeight = sal_uInt16(0 != ( a16Bit & 0x2000 ));
+            pStd->fHasUpe      = sal_uInt16(0 != ( a16Bit & 0x4000 ));
+            pStd->fMassCopy    = sal_uInt16(0 != ( a16Bit & 0x8000 ));
 
             if( 4 > nRead ) break;
             a16Bit = 0;
diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx
index 9935da4..0970e23 100644
--- a/sw/source/filter/ww8/ww8struc.hxx
+++ b/sw/source/filter/ww8/ww8struc.hxx
@@ -20,9 +20,11 @@
 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WW8STRUC_HXX
 #define INCLUDED_SW_SOURCE_FILTER_WW8_WW8STRUC_HXX
 
+#include <sal/config.h>
+
+#include <boost/static_assert.hpp>
 #include <osl/endian.h>
 #include "rtl/ustring.hxx"
-#include <sal/config.h>
 
 #include <editeng/borderline.hxx>
 #include <filter/msfilter/util.hxx>
@@ -164,11 +166,11 @@ struct WW8_STD
 {
     // Base part of STD:
     sal_uInt16  sti : 12;          // invariant style identifier
-    bool        fScratch : 1;      // spare field for any temporary use,
+    sal_uInt16  fScratch : 1;      // spare field for any temporary use,
                                                          // always reset back to zero!
-    bool        fInvalHeight : 1;  // PHEs of all text with this style are wrong
-    bool        fHasUpe : 1;       // UPEs have been generated
-    bool        fMassCopy : 1;     // std has been mass-copied; if unused at
+    sal_uInt16  fInvalHeight : 1;  // PHEs of all text with this style are wrong
+    sal_uInt16  fHasUpe : 1;       // UPEs have been generated
+    sal_uInt16  fMassCopy : 1;     // std has been mass-copied; if unused at
                                                          // save time, style should be deleted
     sal_uInt16  sgc : 4;           // style type code
     sal_uInt16  istdBase : 12;     // base style
@@ -177,8 +179,8 @@ struct WW8_STD
     sal_uInt16  bchUpe;            // offset to end of upx's, start of upe's
     //-------- jetzt neu:
     // ab Ver8 gibts zwei Felder mehr:
-  bool          fAutoRedef : 1;    /* auto redefine style when appropriate */
-  bool          fHidden : 1;       /* hidden from UI? */
+  sal_uInt16    fAutoRedef : 1;    /* auto redefine style when appropriate */
+  sal_uInt16    fHidden : 1;       /* hidden from UI? */
   sal_uInt16    : 14;              /* unused bits */
 
     // Variable length part of STD:
@@ -189,6 +191,8 @@ struct WW8_STD
     // char grupe[];
 };
 
+BOOST_STATIC_ASSERT(sizeof (WW8_STD) == 10);
+
 /** Basis zum Einlesen UND zum Arbeiten (wird jeweils unter schiedlich beerbt)
 */
 struct WW8_FFN_BASE     // Font Descriptor
@@ -207,6 +211,8 @@ struct WW8_FFN_BASE     // Font Descriptor
     sal_uInt8    ibszAlt;        //  0x5     index into ffn.szFfn to the name of the alternate font
 };
 
+BOOST_STATIC_ASSERT(sizeof (WW8_FFN_BASE) == 6);
+
 /** Hiermit arbeiten wir im Parser (und Dumper)
 */
 struct WW8_FFN : public WW8_FFN_BASE
@@ -283,7 +289,7 @@ public:
     //Maps what I think is the language this is to affect to the OOo language
     sal_uInt16 GetConvertedLang() const;
 
-    bool       fKerningPunct  : 1;  // true if we're kerning punctuation
+    sal_uInt16 fKerningPunct  : 1;  // true if we're kerning punctuation
     sal_uInt16 iJustification : 2;  // Kinsoku method of justification:
                                 //  0 = always expand
                                 //  1 = compress punctuation
@@ -292,7 +298,7 @@ public:
                                 //  0 = Level 1
                                 //  1 = Level 2
                                 //  2 = Custom
-    bool       f2on1          : 1;  // 2-page-on-1 feature is turned on.
+    sal_uInt16 f2on1          : 1;  // 2-page-on-1 feature is turned on.
     sal_uInt16 reserved1      : 4;  // in 97 its marked as reserved BUT
     sal_uInt16 reserved2      : 6;  // reserved ?
     //we find that the following applies,
@@ -346,6 +352,8 @@ struct WW8_DOGRID
                                                     // margins and ignore xaGrid and yaGrid.
 };
 
+BOOST_STATIC_ASSERT(sizeof (WW8_DOGRID) == 10);
+
 struct WW8_PIC
 {
     sal_Int32 lcb;          // 0x0 number of bytes in the PIC structure plus size of following picture data which may be a Window's metafile, a bitmap, or the filename of a TIFF file.
@@ -416,6 +424,8 @@ struct WW8_PIC_SHADOW
 //  SVBT8 rgb[];            // 0x3a variable array of bytes containing Window's metafile, bitmap or TIFF file filename.
 };
 
+BOOST_STATIC_ASSERT(sizeof (WW8_PIC_SHADOW) == 0x2E);
+    // "0x2E": cf. SwWW8ImplReader::PicRead pDataStream->Read call
 
 struct WW8_TBD
 {
@@ -801,7 +811,7 @@ public:
     sal_Int32 nYaTop;        //top of rectangle enclosing shape relative to the origin of the shape
     sal_Int32 nXaRight;  //right of rectangle enclosing shape relative to the origin of the shape
     sal_Int32 nYaBottom;//bottom of the rectangle enclosing shape relative to the origin of the shape
-    bool      bHdr:1;
+    sal_uInt16 bHdr:1;
     //0001 1 in the undo doc when shape is from the header doc, 0 otherwise (undefined when not in the undo doc)
     sal_uInt16 nbx:2;
     //0006 x position of shape relative to anchor CP
@@ -829,13 +839,13 @@ public:
     //1 wrap only on left
     //2 wrap only on right
     //3 wrap only on largest side
-    bool       bRcaSimple:1;
+    sal_uInt16 bRcaSimple:1;
     //2000 when set, temporarily overrides bx, by, forcing the xaLeft, xaRight, yaTop, and yaBottom fields to all be page relative.
-    bool       bBelowText:1;
+    sal_uInt16 bBelowText:1;
     //4000
     //1 shape is below text
     //0 shape is above text
-    bool       bAnchorLock:1;
+    sal_uInt16 bAnchorLock:1;
     //8000  1 anchor is locked
     //      0 anchor is not locked
     sal_Int32 nTxbx; //count of textboxes in shape (undo doc only)
@@ -855,6 +865,9 @@ struct WW8_FSPA_SHADOW  // alle Member an gleicher Position und Groesse,
     SVBT32 nTxbx;
 };
 
+BOOST_STATIC_ASSERT(sizeof (WW8_FSPA_SHADOW) == 26);
+    // "26": cf. WW8ScannerBase ctor case 8 creation of pMainFdoa and pHdFtFdoa
+
 struct WW8_TXBXS
 {
     SVBT32 cTxbx_iNextReuse;


More information about the Libreoffice-commits mailing list