[Libreoffice-commits] .: 3 commits - cui/source editeng/inc editeng/source sc/inc sc/source sw/inc sw/source

Michael Stahl mst at kemper.freedesktop.org
Thu May 3 02:21:31 PDT 2012


 cui/source/tabpages/border.cxx    |    2 
 editeng/inc/editeng/boxitem.hxx   |    9 
 editeng/source/items/frmitems.cxx |   63 ++++
 sc/inc/autoform.hxx               |   83 +++++-
 sc/source/core/tool/autoform.cxx  |  333 +++++++++-----------------
 sw/inc/doc.hxx                    |   10 
 sw/inc/fmtornt.hxx                |    3 
 sw/inc/tblafmt.hxx                |   89 +++++--
 sw/source/core/doc/tblafmt.cxx    |  479 +++++++++++++++++++++++---------------
 sw/source/core/docnode/ndtbl.cxx  |    9 
 sw/source/core/inc/UndoTable.hxx  |    1 
 sw/source/core/layout/atrfrm.cxx  |   27 ++
 sw/source/core/undo/untbl.cxx     |    6 
 sw/source/ui/table/tabledlg.cxx   |    4 
 14 files changed, 681 insertions(+), 437 deletions(-)

New commits:
commit 3aa74a27230e9c1d38425e59aa790e05c4a8afd5
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu May 3 00:36:35 2012 +0200

    remove obsolete READ_OLDVERS table autoformat code

diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx
index a103f18..32f28dd 100644
--- a/sc/inc/autoform.hxx
+++ b/sc/inc/autoform.hxx
@@ -255,10 +255,6 @@ public:
 
     sal_Bool                        Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
     sal_Bool                        Save( SvStream& rStream, sal_uInt16 fileVersion );
-
-#ifdef READ_OLDVERS
-    sal_Bool                        LoadOld( SvStream& rStream, const ScAfVersions& rVersions );
-#endif
 };
 
 
@@ -320,10 +316,6 @@ public:
 
     bool                        Load( SvStream& rStream, const ScAfVersions& rVersions );
     bool                        Save( SvStream& rStream, sal_uInt16 fileVersion );
-
-#ifdef READ_OLDVERS
-    sal_Bool                        LoadOld( SvStream& rStream, const ScAfVersions& rVersions );
-#endif
 };
 
 class SC_DLLPUBLIC ScAutoFormat
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index f1c0a35..f8fa79b 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -26,11 +26,6 @@
  *
  ************************************************************************/
 
-
-
-
-#define READ_OLDVERS
-
 #include "autoform.hxx"
 
 #include <sfx2/app.hxx>
@@ -94,12 +89,6 @@ const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_31005;
 const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_31005;
 
 
-#ifdef READ_OLDVERS
-const sal_uInt16 AUTOFORMAT_OLD_ID_OLD  = 4201;
-const sal_uInt16 AUTOFORMAT_OLD_DATA_ID = 4202;
-const sal_uInt16 AUTOFORMAT_OLD_ID_NEW  = 4203;
-#endif
-
 namespace
 {
     /// Read an AutoFormatSwBlob from stream.
@@ -401,40 +390,6 @@ sal_Bool ScAutoFormatDataField::Load( SvStream& rStream, const ScAfVersions& rVe
     return (rStream.GetError() == 0);
 }
 
-#ifdef READ_OLDVERS
-sal_Bool ScAutoFormatDataField::LoadOld( SvStream& rStream, const ScAfVersions& rVersions )
-{
-    SfxPoolItem* pNew;
-    SvxOrientationItem aOrientation( SVX_ORIENTATION_STANDARD, 0 );
-
-    aNumFormat.Load(rStream, rStream.GetStreamCharSet());
-
-    READ( aFont,        SvxFontItem,        rVersions.nFontVersion)
-    READ( aHeight,      SvxFontHeightItem,  rVersions.nFontHeightVersion)
-    READ( aWeight,      SvxWeightItem,      rVersions.nWeightVersion)
-    READ( aPosture,     SvxPostureItem,     rVersions.nPostureVersion)
-    READ( aUnderline,   SvxUnderlineItem,   rVersions.nUnderlineVersion)
-    READ( aCrossedOut,  SvxCrossedOutItem,  rVersions.nCrossedOutVersion)
-    READ( aContour,     SvxContourItem,     rVersions.nContourVersion)
-    READ( aShadowed,    SvxShadowedItem,    rVersions.nShadowedVersion)
-    READ( aColor,       SvxColorItem,       rVersions.nColorVersion)
-    READ( aHorJustify,  SvxHorJustifyItem,  rVersions.nHorJustifyVersion)
-    READ( aVerJustify,  SvxVerJustifyItem,  rVersions.nVerJustifyVersion)
-    READ( aOrientation, SvxOrientationItem, rVersions.nOrientationVersion)
-    pNew = aLinebreak.Create( rStream, rVersions.nBoolVersion );
-    SetLinebreak( *(SfxBoolItem*)pNew );
-    delete pNew;
-    READ( aMargin,      SvxMarginItem,      rVersions.nMarginVersion)
-    READ( aBox,         SvxBoxItem,         rVersions.nBoxVersion)
-    READ( aBackground,  SvxBrushItem,       rVersions.nBrushVersion)
-
-    aStacked.SetValue( aOrientation.IsStacked() );
-    aRotateAngle.SetValue( aOrientation.GetRotation( aRotateAngle.GetValue() ) );
-
-    return (rStream.GetError() == 0);
-}
-#endif
-
 sal_Bool ScAutoFormatDataField::Save( SvStream& rStream, sal_uInt16 fileVersion )
 {
     SvxOrientationItem aOrientation( aRotateAngle.GetValue(), aStacked.GetValue(), 0 );
@@ -849,34 +804,6 @@ bool ScAutoFormatData::Load( SvStream& rStream, const ScAfVersions& rVersions )
     return bRet;
 }
 
-#ifdef READ_OLDVERS
-sal_Bool ScAutoFormatData::LoadOld( SvStream& rStream, const ScAfVersions& rVersions )
-{
-    sal_Bool    bRet = true;
-    sal_uInt16  nVal = 0;
-    rStream >> nVal;
-    bRet = (rStream.GetError() == 0);
-    if (bRet && (nVal == AUTOFORMAT_OLD_DATA_ID))
-    {
-        aName = rStream.ReadUniOrByteString( rStream.GetStreamCharSet() );
-        sal_Bool b;
-        rStream >> b; bIncludeFont = b;
-        rStream >> b; bIncludeJustify = b;
-        rStream >> b; bIncludeFrame = b;
-        rStream >> b; bIncludeBackground = b;
-        rStream >> b; bIncludeValueFormat = b;
-        rStream >> b; bIncludeWidthHeight = b;
-
-        bRet = 0 == rStream.GetError();
-        for (sal_uInt16 i=0; bRet && i < 16; i++)
-            bRet = GetField( i ).LoadOld( rStream, rVersions );
-    }
-    else
-        bRet = false;
-    return bRet;
-}
-#endif
-
 bool ScAutoFormatData::Save(SvStream& rStream, sal_uInt16 fileVersion)
 {
     sal_uInt16 nVal = AUTOFORMAT_DATA_ID;
@@ -1151,47 +1078,8 @@ bool ScAutoFormat::Load()
                     insert(pData);
                 }
             }
-#ifdef READ_OLDVERS
             else
-            {
-                if( AUTOFORMAT_OLD_ID_NEW == nVal )
-                {
-                    // alte Version der Versions laden
-                    rStream >> m_aVersions.nFontVersion;
-                    rStream >> m_aVersions.nFontHeightVersion;
-                    rStream >> m_aVersions.nWeightVersion;
-                    rStream >> m_aVersions.nPostureVersion;
-                    rStream >> m_aVersions.nUnderlineVersion;
-                    rStream >> m_aVersions.nCrossedOutVersion;
-                    rStream >> m_aVersions.nContourVersion;
-                    rStream >> m_aVersions.nShadowedVersion;
-                    rStream >> m_aVersions.nColorVersion;
-                    rStream >> m_aVersions.nHorJustifyVersion;
-                    rStream >> m_aVersions.nVerJustifyVersion;
-                    rStream >> m_aVersions.nOrientationVersion;
-                    rStream >> m_aVersions.nBoolVersion;
-                    rStream >> m_aVersions.nMarginVersion;
-                    rStream >> m_aVersions.nBoxVersion;
-                    rStream >> m_aVersions.nBrushVersion;
-                }
-                if( AUTOFORMAT_OLD_ID_OLD == nVal ||
-                    AUTOFORMAT_OLD_ID_NEW == nVal )
-                {
-                    ScAutoFormatData* pData;
-                    sal_uInt16 nAnz = 0;
-                    rStream >> nAnz;
-                    bRet = 0 == rStream.GetError();
-                    for( sal_uInt16 i=0; bRet && (i < nAnz); ++i )
-                    {
-                        pData = new ScAutoFormatData();
-                        bRet = pData->LoadOld( rStream, m_aVersions );
-                        insert(pData);
-                    }
-                }
-                else
-                    bRet = false;
-            }
-#endif
+                bRet = false;
         }
     }
     mbSaveLater = false;
diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index ecce699..5ea37b5 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -190,11 +190,6 @@ public:
     sal_Bool Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer );
     sal_Bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
     sal_Bool SaveVersionNo( SvStream& rStream, sal_uInt16 fileVersion ) const;
-
-#ifdef READ_OLDVERS
-    // load old version.
-    sal_Bool LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] );
-#endif
 };
 
 /*
@@ -308,11 +303,6 @@ public:
 
     sal_Bool Load( SvStream& rStream, const SwAfVersions& );
     sal_Bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
-
-#ifdef READ_OLDVERS
-    // Load old versions.
-    sal_Bool LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] );
-#endif
 };
 
 typedef SwTableAutoFmt* SwTableAutoFmtPtr ;
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index d887195..db8d7cb 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -43,8 +43,6 @@
 #include <swtable.hxx>
 #include <swtblfmt.hxx>
 #include <com/sun/star/text/VertOrientation.hpp>
-
-#define READ_OLDVERS        // read the old version for a start
 #include <swtypes.hxx>
 #include <doc.hxx>
 #include <poolfmt.hxx>
@@ -95,14 +93,6 @@ const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_31005;
 const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_31005;
 const sal_uInt16 AUTOFORMAT_FILE_VERSION= SOFFICE_FILEFORMAT_50;
 
-
-#ifdef READ_OLDVERS
-const sal_uInt16 AUTOFORMAT_OLD_ID      = 8201;
-const sal_uInt16 AUTOFORMAT_OLD_ID1     = 8301;
-const sal_uInt16 AUTOFORMAT_OLD_DATA_ID = 8202;
-#endif
-
-
 SwBoxAutoFmt* SwTableAutoFmt::pDfltBoxAutoFmt = 0;
 
 #define sAutoTblFmtName "autotbl.fmt"
@@ -516,38 +506,6 @@ sal_Bool SwBoxAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, s
     return 0 == rStream.GetError();
 }
 
-#ifdef READ_OLDVERS
-
-sal_Bool SwBoxAutoFmt::LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] )
-{
-    SfxPoolItem* pNew;
-    READ( aFont,        SvxFontItem         , 0)
-
-    if( rStream.GetStreamCharSet() == aFont.GetCharSet() )
-        aFont.SetCharSet(::osl_getThreadTextEncoding());
-
-    READ( aHeight,      SvxFontHeightItem   , 1)
-    READ( aWeight,      SvxWeightItem       , 2)
-    READ( aPosture,     SvxPostureItem      , 3)
-    READ( aUnderline,   SvxUnderlineItem    , 4)
-    READ( aCrossedOut,  SvxCrossedOutItem   , 5)
-    READ( aContour,     SvxContourItem      , 6)
-    READ( aShadowed,    SvxShadowedItem     , 7)
-    READ( aColor,       SvxColorItem        , 8)
-
-    pNew = aAdjust.Create(rStream, aLoadVer[ 9 ] );
-    SetAdjust( *(SvxAdjustItem*)pNew );
-    delete pNew;
-
-    READ( aBox,         SvxBoxItem          , 10)
-    READ( aBackground,  SvxBrushItem        , 11)
-
-    return 0 == rStream.GetError();
-}
-
-#endif
-
-
 sal_Bool SwBoxAutoFmt::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
 {
     SvxOrientationItem aOrientation( aRotateAngle.GetValue(), aStacked.GetValue(), 0 );
@@ -1027,43 +985,6 @@ sal_Bool SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions
     return bRet;
 }
 
-#ifdef READ_OLDVERS
-
-sal_Bool SwTableAutoFmt::LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] )
-{
-    sal_Bool    bRet = sal_True;
-    sal_uInt16  nVal = 0;
-    rStream >> nVal;
-    bRet = 0 == rStream.GetError();
-
-    if( bRet && ( AUTOFORMAT_OLD_DATA_ID == nVal ))
-    {
-        sal_Bool b;
-        aName = rStream.ReadUniOrByteString( rStream.GetStreamCharSet() );
-        rStream >> b; bInclFont = b;
-        rStream >> b; bInclJustify = b;
-        rStream >> b; bInclFrame = b;
-        rStream >> b; bInclBackground = b;
-        bRet = (rStream.GetError() == 0);
-
-        for( int i = 0; i < 16; i++)
-        {
-            SwBoxAutoFmt* pFmt = new SwBoxAutoFmt;
-            bRet = pFmt->LoadOld( rStream, aLoadVer );
-            if( bRet )
-                aBoxAutoFmt[ i ] = pFmt;
-            else
-            {
-                delete pFmt;
-                break;
-            }
-        }
-    }
-    return bRet;
-}
-#endif
-
-
 sal_Bool SwTableAutoFmt::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
 {
     sal_uInt16 nVal = AUTOFORMAT_DATA_ID;
@@ -1252,37 +1173,10 @@ sal_Bool SwTableAutoFmtTbl::Load( SvStream& rStream )
                     }
                 }
             }
-#ifdef READ_OLDVERS
-            else if( AUTOFORMAT_OLD_ID == nVal || AUTOFORMAT_OLD_ID1 == nVal )
+            else
             {
-                SwTableAutoFmt* pNew;
-                sal_uInt16 nAnz = 0;
-                rStream >> nAnz;
-
-                sal_uInt16 aArr[ 12 ];
-                memset( aArr, 0, 12 * sizeof( sal_uInt16 ) );
-                if( AUTOFORMAT_OLD_ID1 == nVal )
-                    for( sal_uInt16 n = 0; n < 12; ++n )
-                        rStream >> aArr[ n ];
-
-                bRet = 0 == rStream.GetError();
-
-                for( sal_uInt16 i = 0; i < nAnz; ++i )
-                {
-                    pNew = new SwTableAutoFmt( aEmptyStr );
-                    bRet = pNew->LoadOld( rStream, aArr );
-                    if( bRet )
-                    {
-                        Insert( pNew, Count() );
-                    }
-                    else
-                    {
-                        delete pNew;
-                        break;
-                    }
-                }
+                bRet = false;
             }
-#endif
         }
     }
     return bRet;
commit 7e8c0bd73ee59ff3041e55268c77203373962e51
Author: Muhammad Haggag <mhaggag at gmail.com>
Date:   Sun Apr 22 21:20:25 2012 +0200

    fdo#31005 Table Autoformats do not save/apply all properties
    
    This change expands the number of properties supported by autoformats,
    mainly for Writer.  Some improvements affect Calc as well (e.g. border
    styles are now preserved for Calc).
    
    Common: boxitem.hxx, frmitems.cxx
    * Added a new version for SvxBoxItem serialization that includes border styles.
    * Updated SvxBoxItem and SvxBorderLine serialization logic accordingly.
    
    Writer: fmtornt.hxx, attrfrm.cxx
    * Added serialization/deserialization logic for SwFmtVertOrient.
    
    Writer: tblafmt.hxx, tblafmt.cxx, ndtbl.cxx
    * Updated file version for autotbl.fmt to be SOFFICE_FILEFORMAT_50.
    * Autoformats now record the text orientation and vertical alignment
      of table cells.
    * Autoformats now record the following table-level properties:
        - Break
        - Keep with next paragraph
        - Repeat heading
        - Allow table split across pages
        - Allow rows to break across pages
        - Merge adjacent line styles
        - Table shadow
    
    Calc: autoform.hxx, autoform.cxx
    * Added support for reading/writing writer-specific data as binary blobs.
    * Updated file version for autotbl.fmt to be SOFFICE_FILEFORMAT_50.

diff --git a/editeng/inc/editeng/boxitem.hxx b/editeng/inc/editeng/boxitem.hxx
index 4659770..1d9062f 100644
--- a/editeng/inc/editeng/boxitem.hxx
+++ b/editeng/inc/editeng/boxitem.hxx
@@ -48,7 +48,16 @@ namespace rtl { class OUString; }
 #define BOX_LINE_LEFT   ((sal_uInt16)2)
 #define BOX_LINE_RIGHT  ((sal_uInt16)3)
 
+/**
+This version causes SvxBoxItem to store the 4 cell spacing distances separately
+when serializing to stream.
+*/
 #define BOX_4DISTS_VERSION ((sal_uInt16)1)
+/**
+This version causes SvxBoxItem to store the styles for its border lines when
+serializing to stream.
+*/
+#define BOX_BORDER_STYLE_VERSION ((sal_uInt16)2)
 
 class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem
 {
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index d4b876b..f98058e 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -124,6 +124,54 @@ inline void SetValueProp( XubString& rStr, const short nValue,
 
 // -----------------------------------------------------------------------
 
+/*
+SvxBorderLine is not an SfxPoolItem, and has no Store/Create serialization/deserialization methods.
+Since border line information needs to be serialized by the table autoformat code, these file-local
+methods are defined to encapsulate the necessary serialization logic.
+*/
+namespace
+{
+    /// Item version for saved border lines. The old version saves the line without style information.
+    const int BORDER_LINE_OLD_VERSION = 0;
+    /// Item version for saved border lies. The new version includes line style.
+    const int BORDER_LINE_WITH_STYLE_VERSION = 1;
+
+    /// Store a border line to a stream.
+    SvStream& StoreBorderLine(SvStream &stream, const SvxBorderLine &l, sal_uInt16 version)
+    {
+        stream << l.GetColor()
+               << l.GetOutWidth()
+               << l.GetInWidth()
+               << l.GetDistance();
+
+        if (version >= BORDER_LINE_WITH_STYLE_VERSION)
+               stream << static_cast<sal_uInt16>(l.GetStyle());
+
+        return stream;
+    }
+
+    /// Creates a border line from a stream.
+    SvxBorderLine CreateBorderLine(SvStream &stream, sal_uInt16 version)
+    {
+        sal_uInt16 nOutline, nInline, nDistance, nStyle = NO_STYLE;
+        Color aColor;
+        stream >> aColor >> nOutline >> nInline >> nDistance;
+
+        if (version >= BORDER_LINE_WITH_STYLE_VERSION)
+            stream >> nStyle;
+
+        SvxBorderLine border(&aColor);
+        border.GuessLinesWidths(static_cast<SvxBorderStyle>(nStyle), nOutline, nInline, nDistance);
+        return border;
+    }
+
+    /// Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
+    sal_uInt16 BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion)
+    {
+        return (boxVersion >= BOX_BORDER_STYLE_VERSION)? BORDER_LINE_WITH_STYLE_VERSION : BORDER_LINE_OLD_VERSION;
+    }
+}
+
 TYPEINIT1_FACTORY(SvxPaperBinItem, SfxByteItem, new SvxPaperBinItem(0));
 TYPEINIT1_FACTORY(SvxSizeItem, SfxPoolItem, new SvxSizeItem(0));
 TYPEINIT1_FACTORY(SvxLRSpaceItem, SfxPoolItem, new SvxLRSpaceItem(0));
@@ -2205,11 +2253,8 @@ SvStream& SvxBoxItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
         const SvxBorderLine* l = pLine[ i ];
         if( l )
         {
-            rStrm << (sal_Int8) i
-                  << l->GetColor()
-                  << (sal_uInt16) l->GetOutWidth()
-                  << (sal_uInt16) l->GetInWidth()
-                  << (sal_uInt16) l->GetDistance();
+            rStrm << static_cast<sal_Int8>(i);
+            StoreBorderLine(rStrm, *l, BorderLineVersionFromBoxVersion(nItemVersion));
         }
     }
     sal_Int8 cLine = 4;
@@ -2243,7 +2288,7 @@ sal_uInt16 SvxBoxItem::GetVersion( sal_uInt16 nFFVer ) const
             SOFFICE_FILEFORMAT_50==nFFVer,
             "SvxBoxItem: Gibt es ein neues Fileformat?" );
     return SOFFICE_FILEFORMAT_31==nFFVer ||
-           SOFFICE_FILEFORMAT_40==nFFVer ? 0 : BOX_4DISTS_VERSION;
+           SOFFICE_FILEFORMAT_40==nFFVer ? 0 : BOX_BORDER_STYLE_VERSION;
 }
 
 // -----------------------------------------------------------------------
@@ -2286,12 +2331,8 @@ SfxPoolItem* SvxBoxItem::Create( SvStream& rStrm, sal_uInt16 nIVersion ) const
 
         if( cLine > 3 )
             break;
-        sal_uInt16 nOutline, nInline, _nDistance;
-        Color aColor;
-        rStrm >> aColor >> nOutline >> nInline >> _nDistance;
-        SvxBorderLine aBorder( &aColor );
-        aBorder.GuessLinesWidths( NO_STYLE, nOutline, nInline, _nDistance );
 
+        SvxBorderLine aBorder = CreateBorderLine(rStrm, BorderLineVersionFromBoxVersion(nIVersion));
         pAttr->SetLine( &aBorder, aLineMap[cLine] );
     }
 
diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx
index b6d07ee..a103f18 100644
--- a/sc/inc/autoform.hxx
+++ b/sc/inc/autoform.hxx
@@ -70,8 +70,72 @@
 
 #include <boost/ptr_container/ptr_map.hpp>
 
-struct ScAfVersions;
+/**
+A binary blob of writer-specific data. This data typically consists of types that are
+unavailable to Calc (e.g. SwFmtVertOrient), or that Calc doesn't care about.
+
+ at remarks Note that in autoformat versions prior to AUTOFORMAT_DATA_ID_31005, Calc
+logic handled and stored several writer-specific items (such as ScAutoFormatDataField::aAdjust).
+That logic was preserved. From _31005 onward, writer-specific data should be handled by
+blobs to avoid needlessly complicating the Calc logic.
+*/
+struct AutoFormatSwBlob : ::boost::noncopyable
+{
+    sal_uInt8 *pData;
+    sal_Size size;
+
+    AutoFormatSwBlob() : pData(0), size(0)
+    {
+    }
+
+    ~AutoFormatSwBlob()
+    {
+        Reset();
+    }
+
+    void Reset()
+    {
+        delete[] pData;
+        pData = 0;
+        size = 0;
+    }
+};
 
+/// Struct with version numbers of the Items
+struct ScAfVersions
+{
+public:
+    sal_uInt16 nFontVersion;
+    sal_uInt16 nFontHeightVersion;
+    sal_uInt16 nWeightVersion;
+    sal_uInt16 nPostureVersion;
+    sal_uInt16 nUnderlineVersion;
+    sal_uInt16 nOverlineVersion;
+    sal_uInt16 nCrossedOutVersion;
+    sal_uInt16 nContourVersion;
+    sal_uInt16 nShadowedVersion;
+    sal_uInt16 nColorVersion;
+    sal_uInt16 nBoxVersion;
+    sal_uInt16 nLineVersion;
+    sal_uInt16 nBrushVersion;
+
+    sal_uInt16 nAdjustVersion;
+    AutoFormatSwBlob swVersions;
+
+    sal_uInt16 nHorJustifyVersion;
+    sal_uInt16 nVerJustifyVersion;
+    sal_uInt16 nOrientationVersion;
+    sal_uInt16 nMarginVersion;
+    sal_uInt16 nBoolVersion;
+    sal_uInt16 nInt32Version;
+    sal_uInt16 nRotateModeVersion;
+
+    sal_uInt16 nNumFmtVersion;
+
+    ScAfVersions();
+    void Load( SvStream& rStream, sal_uInt16 nVer );
+    void Write(SvStream& rStream, sal_uInt16 fileVersion);
+};
 
 /// Contains all items for one cell of a table autoformat.
 class ScAutoFormatDataField
@@ -105,6 +169,7 @@ private:
 
     // Writer specific
     SvxAdjustItem               aAdjust;
+    AutoFormatSwBlob            m_swFields;
 
     // Calc specific
     SvxHorJustifyItem           aHorJustify;
@@ -189,7 +254,7 @@ public:
     void    SetRotateMode( const SvxRotateModeItem& rRotateMode )   { aRotateMode.SetValue( rRotateMode.GetValue() ); }
 
     sal_Bool                        Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
-    sal_Bool                        Save( SvStream& rStream );
+    sal_Bool                        Save( SvStream& rStream, sal_uInt16 fileVersion );
 
 #ifdef READ_OLDVERS
     sal_Bool                        LoadOld( SvStream& rStream, const ScAfVersions& rVersions );
@@ -212,6 +277,9 @@ private:
     bool                        bIncludeValueFormat : 1;
     bool                        bIncludeWidthHeight : 1;
 
+    // Writer-specific data
+    AutoFormatSwBlob m_swFields;
+
     ScAutoFormatDataField**     ppDataField;
 
     SC_DLLPRIVATE ScAutoFormatDataField&       GetField( sal_uInt16 nIndex );
@@ -251,7 +319,7 @@ public:
     void                        GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat );
 
     bool                        Load( SvStream& rStream, const ScAfVersions& rVersions );
-    bool                        Save( SvStream& rStream );
+    bool                        Save( SvStream& rStream, sal_uInt16 fileVersion );
 
 #ifdef READ_OLDVERS
     sal_Bool                        LoadOld( SvStream& rStream, const ScAfVersions& rVersions );
@@ -263,6 +331,7 @@ class SC_DLLPUBLIC ScAutoFormat
     typedef boost::ptr_map<rtl::OUString, ScAutoFormatData> MapType;
     MapType maData;
     bool mbSaveLater;
+    ScAfVersions m_aVersions;
 
 public:
     typedef MapType::const_iterator const_iterator;
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index 5151105..f1c0a35 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -85,9 +85,13 @@ const sal_uInt16 AUTOFORMAT_DATA_ID_680DR25 = 10022;
 const sal_uInt16 AUTOFORMAT_ID_300OVRLN      = 10031;
 const sal_uInt16 AUTOFORMAT_DATA_ID_300OVRLN = 10032;
 
-// aktuelle Version
-const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_300OVRLN;
-const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_300OVRLN;
+// --- Bug fix to fdo#31005: Table Autoformats does not save/apply all properties (Writer and Calc)
+const sal_uInt16 AUTOFORMAT_ID_31005      = 10041;
+const sal_uInt16 AUTOFORMAT_DATA_ID_31005 = 10042;
+
+// current version
+const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_31005;
+const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_31005;
 
 
 #ifdef READ_OLDVERS
@@ -96,42 +100,41 @@ const sal_uInt16 AUTOFORMAT_OLD_DATA_ID = 4202;
 const sal_uInt16 AUTOFORMAT_OLD_ID_NEW  = 4203;
 #endif
 
+namespace
+{
+    /// Read an AutoFormatSwBlob from stream.
+    SvStream& operator>>(SvStream &stream, AutoFormatSwBlob &blob)
+    {
+        blob.Reset();
 
-//  Struct mit Versionsnummern der Items
+        sal_uInt64 endOfBlob = 0;
+        stream >> endOfBlob;
 
-struct ScAfVersions
-{
-public:
-    sal_uInt16 nFontVersion;
-    sal_uInt16 nFontHeightVersion;
-    sal_uInt16 nWeightVersion;
-    sal_uInt16 nPostureVersion;
-    sal_uInt16 nUnderlineVersion;
-    sal_uInt16 nOverlineVersion;
-    sal_uInt16 nCrossedOutVersion;
-    sal_uInt16 nContourVersion;
-    sal_uInt16 nShadowedVersion;
-    sal_uInt16 nColorVersion;
-    sal_uInt16 nBoxVersion;
-    sal_uInt16 nLineVersion;
-    sal_uInt16 nBrushVersion;
-
-    sal_uInt16 nAdjustVersion;
-
-    sal_uInt16 nHorJustifyVersion;
-    sal_uInt16 nVerJustifyVersion;
-    sal_uInt16 nOrientationVersion;
-    sal_uInt16 nMarginVersion;
-    sal_uInt16 nBoolVersion;
-    sal_uInt16 nInt32Version;
-    sal_uInt16 nRotateModeVersion;
-
-    sal_uInt16 nNumFmtVersion;
-
-    ScAfVersions();
-    void Load( SvStream& rStream, sal_uInt16 nVer );
-    static void Write(SvStream& rStream);
-};
+        const sal_uInt64 currentPosition = stream.Tell();
+        const sal_uInt64 blobSize = endOfBlob - currentPosition;
+        // A zero-size indicates an empty blob. This happens when Calc creates a new autoformat,
+        // since it (naturally) doesn't have any writer-specific data to write.
+        if (blobSize)
+        {
+            blob.pData = new sal_uInt8[blobSize];
+            blob.size = static_cast<sal_Size>(blobSize);
+            stream.Read(blob.pData, blob.size);
+        }
+
+        return stream;
+    }
+
+    /// Write an AutoFormatSwBlob to stream.
+    SvStream& operator<<(SvStream &stream, AutoFormatSwBlob &blob)
+    {
+        const sal_uInt64 endOfBlob = stream.Tell() + sizeof(sal_uInt64) + blob.size;
+        stream << endOfBlob;
+        if (blob.size)
+            stream.Write(blob.pData, blob.size);
+
+        return stream;
+    }
+}
 
 ScAfVersions::ScAfVersions() :
     nFontVersion(0),
@@ -177,6 +180,8 @@ void ScAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
         rStream >> nLineVersion;
     rStream >> nBrushVersion;
     rStream >> nAdjustVersion;
+    if (nVer >= AUTOFORMAT_ID_31005)
+        rStream >> swVersions;
     rStream >> nHorJustifyVersion;
     rStream >> nVerJustifyVersion;
     rStream >> nOrientationVersion;
@@ -190,31 +195,33 @@ void ScAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
     rStream >> nNumFmtVersion;
 }
 
-void ScAfVersions::Write(SvStream& rStream)
+void ScAfVersions::Write(SvStream& rStream, sal_uInt16 fileVersion)
 {
-    rStream << SvxFontItem(ATTR_FONT).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxFontHeightItem(240, 100, ATTR_FONT_HEIGHT).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxWeightItem(WEIGHT_NORMAL, ATTR_FONT_WEIGHT).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxPostureItem(ITALIC_NONE, ATTR_FONT_POSTURE).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxUnderlineItem(UNDERLINE_NONE, ATTR_FONT_UNDERLINE).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxOverlineItem(UNDERLINE_NONE, ATTR_FONT_OVERLINE).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxCrossedOutItem(STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxContourItem(false, ATTR_FONT_CONTOUR).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxShadowedItem(false, ATTR_FONT_SHADOWED).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxColorItem(ATTR_FONT_COLOR).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxBoxItem(ATTR_BORDER).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxLineItem(SID_FRAME_LINESTYLE).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxBrushItem(ATTR_BACKGROUND).GetVersion(SOFFICE_FILEFORMAT_40);
-
-    rStream << SvxAdjustItem(SVX_ADJUST_LEFT, 0).GetVersion(SOFFICE_FILEFORMAT_40);
-
-    rStream << SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxVerJustifyItem(SVX_VER_JUSTIFY_STANDARD, ATTR_VER_JUSTIFY).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxMarginItem(ATTR_MARGIN).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SfxBoolItem(ATTR_LINEBREAK).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SfxInt32Item(ATTR_ROTATE_VALUE).GetVersion(SOFFICE_FILEFORMAT_40);
-    rStream << SvxRotateModeItem(SVX_ROTATE_MODE_STANDARD,0).GetVersion(SOFFICE_FILEFORMAT_40);
+    rStream << SvxFontItem(ATTR_FONT).GetVersion(fileVersion);
+    rStream << SvxFontHeightItem(240, 100, ATTR_FONT_HEIGHT).GetVersion(fileVersion);
+    rStream << SvxWeightItem(WEIGHT_NORMAL, ATTR_FONT_WEIGHT).GetVersion(fileVersion);
+    rStream << SvxPostureItem(ITALIC_NONE, ATTR_FONT_POSTURE).GetVersion(fileVersion);
+    rStream << SvxUnderlineItem(UNDERLINE_NONE, ATTR_FONT_UNDERLINE).GetVersion(fileVersion);
+    rStream << SvxOverlineItem(UNDERLINE_NONE, ATTR_FONT_OVERLINE).GetVersion(fileVersion);
+    rStream << SvxCrossedOutItem(STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT).GetVersion(fileVersion);
+    rStream << SvxContourItem(false, ATTR_FONT_CONTOUR).GetVersion(fileVersion);
+    rStream << SvxShadowedItem(false, ATTR_FONT_SHADOWED).GetVersion(fileVersion);
+    rStream << SvxColorItem(ATTR_FONT_COLOR).GetVersion(fileVersion);
+    rStream << SvxBoxItem(ATTR_BORDER).GetVersion(fileVersion);
+    rStream << SvxLineItem(SID_FRAME_LINESTYLE).GetVersion(fileVersion);
+    rStream << SvxBrushItem(ATTR_BACKGROUND).GetVersion(fileVersion);
+
+    rStream << SvxAdjustItem(SVX_ADJUST_LEFT, 0).GetVersion(fileVersion);
+    if (fileVersion >= SOFFICE_FILEFORMAT_50)
+        rStream << swVersions;
+
+    rStream << SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY).GetVersion(fileVersion);
+    rStream << SvxVerJustifyItem(SVX_VER_JUSTIFY_STANDARD, ATTR_VER_JUSTIFY).GetVersion(fileVersion);
+    rStream << SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0).GetVersion(fileVersion);
+    rStream << SvxMarginItem(ATTR_MARGIN).GetVersion(fileVersion);
+    rStream << SfxBoolItem(ATTR_LINEBREAK).GetVersion(fileVersion);
+    rStream << SfxInt32Item(ATTR_ROTATE_VALUE).GetVersion(fileVersion);
+    rStream << SvxRotateModeItem(SVX_ROTATE_MODE_STANDARD,0).GetVersion(fileVersion);
 
     rStream << (sal_uInt16)0;       // Num-Format
 }
@@ -353,6 +360,9 @@ sal_Bool ScAutoFormatDataField::Load( SvStream& rStream, const ScAfVersions& rVe
     SetAdjust( *(SvxAdjustItem*)pNew );
     delete pNew;
 
+    if (nVer >= AUTOFORMAT_DATA_ID_31005)
+        rStream >> m_swFields;
+
     READ( aHorJustify,   SvxHorJustifyItem,  rVersions.nHorJustifyVersion)
     READ( aVerJustify,   SvxVerJustifyItem,  rVersions.nVerJustifyVersion)
     READ( aOrientation,  SvxOrientationItem, rVersions.nOrientationVersion)
@@ -425,49 +435,51 @@ sal_Bool ScAutoFormatDataField::LoadOld( SvStream& rStream, const ScAfVersions&
 }
 #endif
 
-sal_Bool ScAutoFormatDataField::Save( SvStream& rStream )
+sal_Bool ScAutoFormatDataField::Save( SvStream& rStream, sal_uInt16 fileVersion )
 {
     SvxOrientationItem aOrientation( aRotateAngle.GetValue(), aStacked.GetValue(), 0 );
 
-    aFont.Store         ( rStream, aFont.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aHeight.Store       ( rStream, aHeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aWeight.Store       ( rStream, aWeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aPosture.Store      ( rStream, aPosture.GetVersion( SOFFICE_FILEFORMAT_40 ) );
+    aFont.Store         ( rStream, aFont.GetVersion( fileVersion ) );
+    aHeight.Store       ( rStream, aHeight.GetVersion( fileVersion ) );
+    aWeight.Store       ( rStream, aWeight.GetVersion( fileVersion ) );
+    aPosture.Store      ( rStream, aPosture.GetVersion( fileVersion ) );
     // --- from 641 on: CJK and CTL font settings
-    aCJKFont.Store      ( rStream, aCJKFont.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aCJKHeight.Store    ( rStream, aCJKHeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aCJKWeight.Store    ( rStream, aCJKWeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aCJKPosture.Store   ( rStream, aCJKPosture.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aCTLFont.Store      ( rStream, aCTLFont.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aCTLHeight.Store    ( rStream, aCTLHeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aCTLWeight.Store    ( rStream, aCTLWeight.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aCTLPosture.Store   ( rStream, aCTLPosture.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-
-    aUnderline.Store    ( rStream, aUnderline.GetVersion( SOFFICE_FILEFORMAT_40 ) );
+    aCJKFont.Store      ( rStream, aCJKFont.GetVersion( fileVersion ) );
+    aCJKHeight.Store    ( rStream, aCJKHeight.GetVersion( fileVersion ) );
+    aCJKWeight.Store    ( rStream, aCJKWeight.GetVersion( fileVersion ) );
+    aCJKPosture.Store   ( rStream, aCJKPosture.GetVersion( fileVersion ) );
+    aCTLFont.Store      ( rStream, aCTLFont.GetVersion( fileVersion ) );
+    aCTLHeight.Store    ( rStream, aCTLHeight.GetVersion( fileVersion ) );
+    aCTLWeight.Store    ( rStream, aCTLWeight.GetVersion( fileVersion ) );
+    aCTLPosture.Store   ( rStream, aCTLPosture.GetVersion( fileVersion ) );
+
+    aUnderline.Store    ( rStream, aUnderline.GetVersion( fileVersion ) );
     // --- from DEV300/overline2 on: overline support
-    aOverline.Store     ( rStream, aOverline.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aCrossedOut.Store   ( rStream, aCrossedOut.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aContour.Store      ( rStream, aContour.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aShadowed.Store     ( rStream, aShadowed.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aColor.Store        ( rStream, aColor.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aBox.Store          ( rStream, aBox.GetVersion( SOFFICE_FILEFORMAT_40 ) );
+    aOverline.Store     ( rStream, aOverline.GetVersion( fileVersion ) );
+    aCrossedOut.Store   ( rStream, aCrossedOut.GetVersion( fileVersion ) );
+    aContour.Store      ( rStream, aContour.GetVersion( fileVersion ) );
+    aShadowed.Store     ( rStream, aShadowed.GetVersion( fileVersion ) );
+    aColor.Store        ( rStream, aColor.GetVersion( fileVersion ) );
+    aBox.Store          ( rStream, aBox.GetVersion( fileVersion ) );
 
     // --- from 680/dr14 on: diagonal frame lines
-    aTLBR.Store         ( rStream, aTLBR.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aBLTR.Store         ( rStream, aBLTR.GetVersion( SOFFICE_FILEFORMAT_40 ) );
+    aTLBR.Store         ( rStream, aTLBR.GetVersion( fileVersion ) );
+    aBLTR.Store         ( rStream, aBLTR.GetVersion( fileVersion ) );
 
-    aBackground.Store   ( rStream, aBackground.GetVersion( SOFFICE_FILEFORMAT_40 ) );
+    aBackground.Store   ( rStream, aBackground.GetVersion( fileVersion ) );
 
-    aAdjust.Store       ( rStream, aAdjust.GetVersion( SOFFICE_FILEFORMAT_40 ) );
+    aAdjust.Store       ( rStream, aAdjust.GetVersion( fileVersion ) );
+    if (fileVersion >= SOFFICE_FILEFORMAT_50)
+        rStream << m_swFields;
 
-    aHorJustify.Store   ( rStream, aHorJustify.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aVerJustify.Store   ( rStream, aVerJustify.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aOrientation.Store  ( rStream, aOrientation.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aMargin.Store       ( rStream, aMargin.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aLinebreak.Store    ( rStream, aLinebreak.GetVersion( SOFFICE_FILEFORMAT_40 ) );
+    aHorJustify.Store   ( rStream, aHorJustify.GetVersion( fileVersion ) );
+    aVerJustify.Store   ( rStream, aVerJustify.GetVersion( fileVersion ) );
+    aOrientation.Store  ( rStream, aOrientation.GetVersion( fileVersion ) );
+    aMargin.Store       ( rStream, aMargin.GetVersion( fileVersion ) );
+    aLinebreak.Store    ( rStream, aLinebreak.GetVersion( fileVersion ) );
     // Rotation ab SO5
-    aRotateAngle.Store  ( rStream, aRotateAngle.GetVersion( SOFFICE_FILEFORMAT_40 ) );
-    aRotateMode.Store   ( rStream, aRotateMode.GetVersion( SOFFICE_FILEFORMAT_40 ) );
+    aRotateAngle.Store  ( rStream, aRotateAngle.GetVersion( fileVersion ) );
+    aRotateMode.Store   ( rStream, aRotateMode.GetVersion( fileVersion ) );
 
     // --- from 680/dr25 on: store strings as UTF-8
     aNumFormat.Save( rStream, RTL_TEXTENCODING_UTF8 );
@@ -825,6 +837,9 @@ bool ScAutoFormatData::Load( SvStream& rStream, const ScAfVersions& rVersions )
         rStream >> b; bIncludeValueFormat = b;
         rStream >> b; bIncludeWidthHeight = b;
 
+        if (nVer >= AUTOFORMAT_DATA_ID_31005)
+            rStream >> m_swFields;
+
         bRet = 0 == rStream.GetError();
         for( sal_uInt16 i = 0; bRet && i < 16; ++i )
             bRet = GetField( i ).Load( rStream, rVersions, nVer );
@@ -862,7 +877,7 @@ sal_Bool ScAutoFormatData::LoadOld( SvStream& rStream, const ScAfVersions& rVers
 }
 #endif
 
-bool ScAutoFormatData::Save(SvStream& rStream)
+bool ScAutoFormatData::Save(SvStream& rStream, sal_uInt16 fileVersion)
 {
     sal_uInt16 nVal = AUTOFORMAT_DATA_ID;
     sal_Bool b;
@@ -878,9 +893,12 @@ bool ScAutoFormatData::Save(SvStream& rStream)
     rStream << ( b = bIncludeValueFormat );
     rStream << ( b = bIncludeWidthHeight );
 
+    if (fileVersion >= SOFFICE_FILEFORMAT_50)
+        rStream << m_swFields;
+
     sal_Bool bRet = 0 == rStream.GetError();
     for (sal_uInt16 i = 0; bRet && (i < 16); i++)
-        bRet = GetField( i ).Save( rStream );
+        bRet = GetField( i ).Save( rStream, fileVersion );
 
     return bRet;
 }
@@ -1099,8 +1117,6 @@ bool ScAutoFormat::Load()
         rStream >> nVal;
         bRet = 0 == rStream.GetError();
 
-        ScAfVersions aVersions;
-
         if (bRet)
         {
             if( nVal == AUTOFORMAT_ID_358 ||
@@ -1122,7 +1138,7 @@ bool ScAutoFormat::Load()
             if( nVal == AUTOFORMAT_ID_358 || nVal == AUTOFORMAT_ID_X ||
                     (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
             {
-                aVersions.Load( rStream, nVal );        // Item-Versionen
+                m_aVersions.Load( rStream, nVal );        // Item-Versionen
 
                 ScAutoFormatData* pData;
                 sal_uInt16 nAnz = 0;
@@ -1131,7 +1147,7 @@ bool ScAutoFormat::Load()
                 for (sal_uInt16 i=0; bRet && (i < nAnz); i++)
                 {
                     pData = new ScAutoFormatData();
-                    bRet = pData->Load(rStream, aVersions);
+                    bRet = pData->Load(rStream, m_aVersions);
                     insert(pData);
                 }
             }
@@ -1141,22 +1157,22 @@ bool ScAutoFormat::Load()
                 if( AUTOFORMAT_OLD_ID_NEW == nVal )
                 {
                     // alte Version der Versions laden
-                    rStream >> aVersions.nFontVersion;
-                    rStream >> aVersions.nFontHeightVersion;
-                    rStream >> aVersions.nWeightVersion;
-                    rStream >> aVersions.nPostureVersion;
-                    rStream >> aVersions.nUnderlineVersion;
-                    rStream >> aVersions.nCrossedOutVersion;
-                    rStream >> aVersions.nContourVersion;
-                    rStream >> aVersions.nShadowedVersion;
-                    rStream >> aVersions.nColorVersion;
-                    rStream >> aVersions.nHorJustifyVersion;
-                    rStream >> aVersions.nVerJustifyVersion;
-                    rStream >> aVersions.nOrientationVersion;
-                    rStream >> aVersions.nBoolVersion;
-                    rStream >> aVersions.nMarginVersion;
-                    rStream >> aVersions.nBoxVersion;
-                    rStream >> aVersions.nBrushVersion;
+                    rStream >> m_aVersions.nFontVersion;
+                    rStream >> m_aVersions.nFontHeightVersion;
+                    rStream >> m_aVersions.nWeightVersion;
+                    rStream >> m_aVersions.nPostureVersion;
+                    rStream >> m_aVersions.nUnderlineVersion;
+                    rStream >> m_aVersions.nCrossedOutVersion;
+                    rStream >> m_aVersions.nContourVersion;
+                    rStream >> m_aVersions.nShadowedVersion;
+                    rStream >> m_aVersions.nColorVersion;
+                    rStream >> m_aVersions.nHorJustifyVersion;
+                    rStream >> m_aVersions.nVerJustifyVersion;
+                    rStream >> m_aVersions.nOrientationVersion;
+                    rStream >> m_aVersions.nBoolVersion;
+                    rStream >> m_aVersions.nMarginVersion;
+                    rStream >> m_aVersions.nBoxVersion;
+                    rStream >> m_aVersions.nBrushVersion;
                 }
                 if( AUTOFORMAT_OLD_ID_OLD == nVal ||
                     AUTOFORMAT_OLD_ID_NEW == nVal )
@@ -1168,7 +1184,7 @@ bool ScAutoFormat::Load()
                     for( sal_uInt16 i=0; bRet && (i < nAnz); ++i )
                     {
                         pData = new ScAutoFormatData();
-                        bRet = pData->LoadOld( rStream, aVersions );
+                        bRet = pData->LoadOld( rStream, m_aVersions );
                         insert(pData);
                     }
                 }
@@ -1197,8 +1213,9 @@ bool ScAutoFormat::Save()
     bRet = (pStream && pStream->GetError() == 0);
     if (bRet)
     {
+        const sal_uInt16 fileVersion = SOFFICE_FILEFORMAT_50;
         SvStream& rStream = *pStream;
-        rStream.SetVersion( SOFFICE_FILEFORMAT_40 );
+        rStream.SetVersion( fileVersion );
 
         // Achtung hier muss ein allgemeiner Header gespeichert werden
         sal_uInt16 nVal = AUTOFORMAT_ID;
@@ -1206,7 +1223,7 @@ bool ScAutoFormat::Save()
                 << (sal_uInt8)2         // Anzahl von Zeichen des Headers incl. diesem
                 << (sal_uInt8)::GetSOStoreTextEncoding(
                     osl_getThreadTextEncoding() );
-        ScAfVersions::Write(rStream);           // Item-Versionen
+        m_aVersions.Write(rStream, fileVersion);
 
         bRet = (rStream.GetError() == 0);
         //-----------------------------------------------------------
@@ -1214,7 +1231,7 @@ bool ScAutoFormat::Save()
         bRet = (rStream.GetError() == 0);
         MapType::iterator it = maData.begin(), itEnd = maData.end();
         for (++it; bRet && it != itEnd; ++it) // Skip the first item.
-            bRet = it->second->Save(rStream);
+            bRet = it->second->Save(rStream, fileVersion);
 
         rStream.Flush();
 
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index b71b98f..7f4a1cc 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1900,6 +1900,16 @@ public:
                           const editeng::SvxBorderLine* pBorderLine );
     void GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet ) const;
     void SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew );
+    /**
+    Retrieves a box attribute from the given cursor.
+
+    @return Whether the property is set over the current box selection.
+
+    @remarks A property is 'set' if it's set to the same value over all boxes in the current selection.
+    The property value is retrieved from the first box in the current selection. It is then compared to
+    the values of the same property over any other boxes in the selection; if any value is different from
+    that of the first box, the property is unset (and sal_False is returned).
+    */
     sal_Bool GetBoxAttr( const SwCursor& rCursor, SfxPoolItem &rToFill ) const;
     void SetBoxAlign( const SwCursor& rCursor, sal_uInt16 nAlign );
     sal_uInt16 GetBoxAlign( const SwCursor& rCursor ) const;
diff --git a/sw/inc/fmtornt.hxx b/sw/inc/fmtornt.hxx
index ac19641..a4055da 100644
--- a/sw/inc/fmtornt.hxx
+++ b/sw/inc/fmtornt.hxx
@@ -64,6 +64,9 @@ public:
     virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
     virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
 
+    SvStream& Store(SvStream &rStream, sal_uInt16 itemVersion) const;
+    SfxPoolItem* Create(SvStream &rStream, sal_uInt16 itemVersion) const;
+
     sal_Int16 GetVertOrient() const { return eOrient; }
     sal_Int16 GetRelationOrient() const { return eRelation; }
     void   SetVertOrient( sal_Int16 eNew ) { eOrient = eNew; }
diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index 6ab318a..ecce699 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -53,9 +53,17 @@
 #include <editeng/brshitem.hxx>
 #include <editeng/adjitem.hxx>
 #include <editeng/justifyitem.hxx>
+#include <editeng/brkitem.hxx>
+#include <editeng/keepitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/shaditem.hxx>
 #include <svx/rotmodit.hxx>
 #include <svl/intitem.hxx>
 #include <editeng/bolnitem.hxx>
+#include <fmtpdsc.hxx>
+#include <fmtlsplt.hxx>
+#include <fmtrowsplt.hxx>
+#include <fmtornt.hxx>
 #include "swdllapi.h"
 
 struct SwAfVersions;
@@ -94,6 +102,8 @@ class SwBoxAutoFmt
 
     // Writer specific
     SvxAdjustItem       aAdjust;
+    SvxFrameDirectionItem m_aTextOrientation;
+    SwFmtVertOrient m_aVerticalAlignment;
 
     // Calc specific
     SvxHorJustifyItem   aHorJustify;
@@ -136,6 +146,8 @@ public:
     const SvxShadowedItem   &GetShadowed() const    { return aShadowed; }
     const SvxColorItem      &GetColor() const       { return aColor; }
     const SvxAdjustItem     &GetAdjust() const      { return aAdjust; }
+    const SvxFrameDirectionItem& GetTextOrientation() const { return m_aTextOrientation; }
+    const SwFmtVertOrient& GetVerticalAlignment() const { return m_aVerticalAlignment; }
     const SvxBoxItem        &GetBox() const         { return aBox; }
     const SvxLineItem       &GetTLBR() const        { return aTLBR; }
     const SvxLineItem       &GetBLTR() const        { return aBLTR; }
@@ -168,14 +180,16 @@ public:
             aAdjust.SetOneWord( rNew.GetOneWord() );
             aAdjust.SetLastBlock( rNew.GetLastBlock() );
         }
+    void SetTextOrientation(const SvxFrameDirectionItem& rNew) { m_aTextOrientation = rNew; }
+    void SetVerticalAlignment(const SwFmtVertOrient& rNew) { m_aVerticalAlignment = rNew; }
     void SetBox( const SvxBoxItem& rNew )               { aBox = rNew; }
     void SetBackground( const SvxBrushItem& rNew )      { aBackground = rNew; }
     void SetValueFormat( const String& rFmt, LanguageType eLng, LanguageType eSys )
         { sNumFmtString = rFmt; eNumFmtLanguage = eLng; eSysLanguage = eSys; }
 
     sal_Bool Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer );
-    sal_Bool Save( SvStream& rStream ) const;
-    sal_Bool SaveVerionNo( SvStream& rStream ) const;
+    sal_Bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
+    sal_Bool SaveVersionNo( SvStream& rStream, sal_uInt16 fileVersion ) const;
 
 #ifdef READ_OLDVERS
     // load old version.
@@ -183,6 +197,50 @@ public:
 #endif
 };
 
+/*
+ at remarks
+A table has a number of lines. These lines seem to correspond with rows, except in the case of
+rows spanning more than one line. Each line contains a number of boxes/cells.
+
+AutoFormat properties are retrieved and stored in a grid of 16 table boxes. A sampling approach
+is used to read the data. 4 lines are picked, and 4 boxes are picked from each.
+
+The line picking and box picking algorithms are similar. We start at the first line/box, and pick
+lines/boxes one by one for a maximum of 3. The 4th line/box is the last line/box in the current
+table/line. If we hit the end of lines/boxes, the last line/box encountered is picked several times.
+
+For example, in a 2x3 table, the 4 lines will be [0, 1, 1, 1]. In each line, the boxes will be
+[0, 1, 2, 2]. In a 6x5 table, the 4 lines will be [0, 1, 2, 4] and the boxes per line will be
+[0, 1, 2, 5].
+
+As you can see, property extraction/application is lossless for tables that are 4x4 or smaller
+(and in fact has a bit of redundnacy). For larger tables, we lose any individual cell formatting
+for the range [(3,rows - 1) -> (3, cols - 1)]. That formatting is replaced by formatting from
+the saved cells:
+
+            0            1            2           3           4           5
+        +-----------------------------------------------------------------------+
+     0  |   Saved   |  Saved    |  Saved    |           |           |  Saved    |
+        +-----------------------------------------------------------------------+
+     1  |   Saved   |  Saved    |  Saved    |           |           |  Saved    |
+        +-----------------------------------------------------------------------+
+     2  |   Saved   |  Saved    |  Saved    |           |           |  Saved    |
+        +-----------------------------------------------------------------------+
+     3  |           |           |           |           |           |           |
+        +-----------------------------------------------------------------------+
+     4  |           |           |           |           |           |           |
+        +-----------------------------------------------------------------------+
+     5  |   Saved   |  Saved    |  Saved    |           |           |  Saved    |
+        +-----------+-----------+-----------+-----------+-----------+-----------+
+
+The properties saved are divided into three categories:
+    1. Character properties: Font, font size, weight, etc.
+    2. Box properties: Box, cell background
+    3. Table properties: Properties that are set in the Table->Table Properties dialog.
+
+Character and box properties are stored per cell (and are lossy for tables larger than 4x4). Table
+properties are stored per-table, and are lossless.
+*/
 class SW_DLLPUBLIC SwTableAutoFmt
 {
     friend void _FinitCore();       // To destroy dflt. pointer.
@@ -203,6 +261,16 @@ class SW_DLLPUBLIC SwTableAutoFmt
 
     SwBoxAutoFmt* aBoxAutoFmt[ 16 ];
 
+    // Writer-specific options
+    SvxFmtBreakItem m_aBreak;
+    SwFmtPageDesc m_aPageDesc;
+    SvxFmtKeepItem m_aKeepWithNextPara;
+    sal_uInt16 m_aRepeatHeading;
+    sal_Bool m_bLayoutSplit;
+    sal_Bool m_bRowSplit;
+    sal_Bool m_bCollapsingBorders;
+    SvxShadowItem m_aShadow;
+
 public:
     SwTableAutoFmt( const String& rName );
     SwTableAutoFmt( const SwTableAutoFmt& rNew );
@@ -217,11 +285,14 @@ public:
     const String& GetName() const { return aName; }
 
     enum UpdateFlags { UPDATE_CHAR = 1, UPDATE_BOX = 2, UPDATE_ALL = 3 };
-    SwBoxAutoFmt& UpdateFromSet( sal_uInt8 nPos, const SfxItemSet& rSet,
+    void UpdateFromSet( sal_uInt8 nPos, const SfxItemSet& rSet,
                                 UpdateFlags eFlags, SvNumberFormatter* );
     void UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet, UpdateFlags eFlags,
                         SvNumberFormatter* ) const ;
 
+    void RestoreTableProperties(SwTable &table) const;
+    void StoreTableProperties(const SwTable &table);
+
     sal_Bool IsFont() const         { return bInclFont; }
     sal_Bool IsJustify() const      { return bInclJustify; }
     sal_Bool IsFrame() const        { return bInclFrame; }
@@ -236,7 +307,7 @@ public:
     void SetWidthHeight( const sal_Bool bNew )  { bInclWidthHeight = bNew; }
 
     sal_Bool Load( SvStream& rStream, const SwAfVersions& );
-    sal_Bool Save( SvStream& rStream ) const;
+    sal_Bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
 
 #ifdef READ_OLDVERS
     // Load old versions.
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index 266db7f..d887195 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -40,6 +40,9 @@
 #include <sfx2/app.hxx>
 #include <svx/dialmgr.hxx>
 #include <svx/dialogs.hrc>
+#include <swtable.hxx>
+#include <swtblfmt.hxx>
+#include <com/sun/star/text/VertOrientation.hpp>
 
 #define READ_OLDVERS        // read the old version for a start
 #include <swtypes.hxx>
@@ -48,6 +51,9 @@
 #include <tblafmt.hxx>
 #include <cellatr.hxx>
 #include <SwStyleNameMapper.hxx>
+#include <hintids.hxx>
+#include <fmtornt.hxx>
+#include <editsh.hxx>
 
 using ::editeng::SvxBorderLine;
 
@@ -80,9 +86,14 @@ const sal_uInt16 AUTOFORMAT_DATA_ID_680DR25 = 10022;
 const sal_uInt16 AUTOFORMAT_ID_300OVRLN      = 10031;
 const sal_uInt16 AUTOFORMAT_DATA_ID_300OVRLN = 10032;
 
+// --- Bug fix to fdo#31005: Table Autoformats does not save/apply all properties (Writer and Calc)
+const sal_uInt16 AUTOFORMAT_ID_31005      = 10041;
+const sal_uInt16 AUTOFORMAT_DATA_ID_31005 = 10042;
+
 // current version
-const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_300OVRLN;
-const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_300OVRLN;
+const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_31005;
+const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_31005;
+const sal_uInt16 AUTOFORMAT_FILE_VERSION= SOFFICE_FILEFORMAT_50;
 
 
 #ifdef READ_OLDVERS
@@ -99,6 +110,73 @@ SwBoxAutoFmt* SwTableAutoFmt::pDfltBoxAutoFmt = 0;
 // SwTable AutoFormat Table
 SV_IMPL_PTRARR( _SwTableAutoFmtTbl, SwTableAutoFmt* )
 
+namespace
+{
+    /// Begins a writer-specific data block. Call before serializing any writer-specific properties.
+    sal_uInt64 BeginSwBlock(SvStream& rStream)
+    {
+        // We need to write down the offset of the end of the writer-specific data, so that
+        // calc can skip it. We'll only have that value after writing the data, so we
+        // write a placeholder value first, write the data, then jump back and write the
+        // real offset.
+
+        // Note that we explicitly use sal_uInt64 instead of sal_Size (which can be 32
+        // or 64 depending on platform) to ensure 64-bit portability on this front. I don't
+        // actually know if autotbl.fmt as a whole is portable, since that requires all serialization
+        // logic to be written with portability in mind.
+        sal_uInt64 whereToWriteEndOfSwBlock = rStream.Tell();
+
+        sal_uInt64 endOfSwBlock = 0;
+        rStream << endOfSwBlock;
+
+        return whereToWriteEndOfSwBlock;
+    }
+
+    /// Ends a writer-specific data block. Call after serializing writer-specific properties.
+    /// Closes a corresponding BeginSwBlock call.
+    void EndSwBlock(SvStream& rStream, sal_uInt64 whereToWriteEndOfSwBlock)
+    {
+        sal_uInt64 endOfSwBlock = rStream.Tell();
+        rStream.Seek(whereToWriteEndOfSwBlock);
+        rStream << endOfSwBlock;
+        rStream.Seek(endOfSwBlock);
+    }
+
+    /**
+    Helper class for writer-specific blocks. Begins a writer-specific block on construction,
+    and closes it on destruction.
+
+    See also: BeginSwBlock and EndSwBlock.
+    */
+    class WriterSpecificAutoFormatBlock : ::boost::noncopyable
+    {
+    public:
+        WriterSpecificAutoFormatBlock(SvStream &rStream) : _rStream(rStream)
+        {
+            _whereToWriteEndOfBlock = BeginSwBlock(rStream);
+        }
+
+        ~WriterSpecificAutoFormatBlock()
+        {
+            EndSwBlock(_rStream, _whereToWriteEndOfBlock);
+        }
+
+    private:
+        SvStream &_rStream;
+        sal_uInt64 _whereToWriteEndOfBlock;
+    };
+
+    /// Checks whether a writer-specific block exists (i.e. size is not zero)
+    sal_Bool WriterSpecificBlockExists(SvStream &stream)
+    {
+        sal_uInt64 endOfSwBlock = 0;
+        stream >> endOfSwBlock;
+
+        // end-of-block pointing to itself indicates a zero-size block.
+        return endOfSwBlock != stream.Tell();
+    }
+}
+
 
 // Struct with version numbers of the Items
 
@@ -120,6 +198,8 @@ public:
     sal_uInt16 nBrushVersion;
 
     sal_uInt16 nAdjustVersion;
+    sal_uInt16 m_nTextOrientationVersion;
+    sal_uInt16 m_nVerticalAlignmentVersion;
 
     sal_uInt16 nHorJustifyVersion;
     sal_uInt16 nVerJustifyVersion;
@@ -150,6 +230,8 @@ SwAfVersions::SwAfVersions() :
     nLineVersion(0),
     nBrushVersion(0),
     nAdjustVersion(0),
+    m_nTextOrientationVersion(0),
+    m_nVerticalAlignmentVersion(0),
     nHorJustifyVersion(0),
     nVerJustifyVersion(0),
     nOrientationVersion(0),
@@ -179,6 +261,12 @@ void SwAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
         rStream >> nLineVersion;
     rStream >> nBrushVersion;
     rStream >> nAdjustVersion;
+    if (nVer >= AUTOFORMAT_ID_31005 && WriterSpecificBlockExists(rStream))
+    {
+        rStream >> m_nTextOrientationVersion;
+        rStream >> m_nVerticalAlignmentVersion;
+    }
+
     rStream >> nHorJustifyVersion;
     rStream >> nVerJustifyVersion;
     rStream >> nOrientationVersion;
@@ -221,6 +309,8 @@ SwBoxAutoFmt::SwBoxAutoFmt()
     aBLTR( 0 ),
     aBackground( RES_BACKGROUND ),
     aAdjust( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ),
+    m_aTextOrientation(FRMDIR_ENVIRONMENT, RES_FRAMEDIR),
+    m_aVerticalAlignment(0, com::sun::star::text::VertOrientation::NONE, com::sun::star::text::RelOrientation::FRAME),
     aHorJustify( SVX_HOR_JUSTIFY_STANDARD, 0),
     aVerJustify( SVX_VER_JUSTIFY_STANDARD, 0),
     aStacked( 0 ),
@@ -262,6 +352,8 @@ SwBoxAutoFmt::SwBoxAutoFmt( const SwBoxAutoFmt& rNew )
     aBLTR( rNew.aBLTR ),
     aBackground( rNew.aBackground ),
     aAdjust( rNew.aAdjust ),
+    m_aTextOrientation(rNew.m_aTextOrientation),
+    m_aVerticalAlignment(rNew.m_aVerticalAlignment),
     aHorJustify( rNew.aHorJustify ),
     aVerJustify( rNew.aVerJustify ),
     aStacked( rNew.aStacked ),
@@ -301,6 +393,8 @@ SwBoxAutoFmt& SwBoxAutoFmt::operator=( const SwBoxAutoFmt& rNew )
     aShadowed = rNew.aShadowed;
     aColor = rNew.aColor;
     SetAdjust( rNew.aAdjust );
+    m_aTextOrientation = rNew.m_aTextOrientation;
+    m_aVerticalAlignment = rNew.m_aVerticalAlignment;
     aBox = rNew.aBox;
     aTLBR = rNew.aTLBR;
     aBLTR = rNew.aBLTR;
@@ -377,8 +471,15 @@ sal_Bool SwBoxAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, s
     SetAdjust( *(SvxAdjustItem*)pNew );
     delete pNew;
 
+    if (nVer >= AUTOFORMAT_DATA_ID_31005 && WriterSpecificBlockExists(rStream))
+    {
+        READ(m_aTextOrientation, SvxFrameDirectionItem, rVersions.m_nTextOrientationVersion);
+        READ(m_aVerticalAlignment, SwFmtVertOrient, rVersions.m_nVerticalAlignmentVersion);
+    }
+
     READ( aHorJustify,  SvxHorJustifyItem , rVersions.nHorJustifyVersion)
     READ( aVerJustify,  SvxVerJustifyItem   , rVersions.nVerJustifyVersion)
+
     READ( aOrientation, SvxOrientationItem  , rVersions.nOrientationVersion)
     READ( aMargin, SvxMarginItem       , rVersions.nMarginVersion)
 
@@ -447,43 +548,50 @@ sal_Bool SwBoxAutoFmt::LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] )
 #endif
 
 
-sal_Bool SwBoxAutoFmt::Save( SvStream& rStream ) const
+sal_Bool SwBoxAutoFmt::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
 {
     SvxOrientationItem aOrientation( aRotateAngle.GetValue(), aStacked.GetValue(), 0 );
 
-    aFont.Store( rStream, aFont.GetVersion(SOFFICE_FILEFORMAT_40)  );
-    aHeight.Store( rStream, aHeight.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aWeight.Store( rStream, aWeight.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aPosture.Store( rStream, aPosture.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aCJKFont.Store( rStream, aCJKFont.GetVersion(SOFFICE_FILEFORMAT_40)  );
-    aCJKHeight.Store( rStream, aCJKHeight.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aCJKWeight.Store( rStream, aCJKWeight.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aCJKPosture.Store( rStream, aCJKPosture.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aCTLFont.Store( rStream, aCTLFont.GetVersion(SOFFICE_FILEFORMAT_40)  );
-    aCTLHeight.Store( rStream, aCTLHeight.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aCTLWeight.Store( rStream, aCTLWeight.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aCTLPosture.Store( rStream, aCTLPosture.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aUnderline.Store( rStream, aUnderline.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aOverline.Store( rStream, aOverline.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aCrossedOut.Store( rStream, aCrossedOut.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aContour.Store( rStream, aContour.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aShadowed.Store( rStream, aShadowed.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aColor.Store( rStream, aColor.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aBox.Store( rStream, aBox.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aTLBR.Store( rStream, aTLBR.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aBLTR.Store( rStream, aBLTR.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aBackground.Store( rStream, aBackground.GetVersion(SOFFICE_FILEFORMAT_40) );
-
-    aAdjust.Store( rStream, aAdjust.GetVersion(SOFFICE_FILEFORMAT_40) );
-
-    aHorJustify.Store( rStream, aHorJustify.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aVerJustify.Store( rStream, aVerJustify.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aOrientation.Store( rStream, aOrientation.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aMargin.Store( rStream, aMargin.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aLinebreak.Store( rStream, aLinebreak.GetVersion(SOFFICE_FILEFORMAT_40) );
+    aFont.Store( rStream, aFont.GetVersion(fileVersion)  );
+    aHeight.Store( rStream, aHeight.GetVersion(fileVersion) );
+    aWeight.Store( rStream, aWeight.GetVersion(fileVersion) );
+    aPosture.Store( rStream, aPosture.GetVersion(fileVersion) );
+    aCJKFont.Store( rStream, aCJKFont.GetVersion(fileVersion)  );
+    aCJKHeight.Store( rStream, aCJKHeight.GetVersion(fileVersion) );
+    aCJKWeight.Store( rStream, aCJKWeight.GetVersion(fileVersion) );
+    aCJKPosture.Store( rStream, aCJKPosture.GetVersion(fileVersion) );
+    aCTLFont.Store( rStream, aCTLFont.GetVersion(fileVersion)  );
+    aCTLHeight.Store( rStream, aCTLHeight.GetVersion(fileVersion) );
+    aCTLWeight.Store( rStream, aCTLWeight.GetVersion(fileVersion) );
+    aCTLPosture.Store( rStream, aCTLPosture.GetVersion(fileVersion) );
+    aUnderline.Store( rStream, aUnderline.GetVersion(fileVersion) );
+    aOverline.Store( rStream, aOverline.GetVersion(fileVersion) );
+    aCrossedOut.Store( rStream, aCrossedOut.GetVersion(fileVersion) );
+    aContour.Store( rStream, aContour.GetVersion(fileVersion) );
+    aShadowed.Store( rStream, aShadowed.GetVersion(fileVersion) );
+    aColor.Store( rStream, aColor.GetVersion(fileVersion) );
+    aBox.Store( rStream, aBox.GetVersion(fileVersion) );
+    aTLBR.Store( rStream, aTLBR.GetVersion(fileVersion) );
+    aBLTR.Store( rStream, aBLTR.GetVersion(fileVersion) );
+    aBackground.Store( rStream, aBackground.GetVersion(fileVersion) );
+
+    aAdjust.Store( rStream, aAdjust.GetVersion(fileVersion) );
+    if (fileVersion >= SOFFICE_FILEFORMAT_50)
+    {
+        WriterSpecificAutoFormatBlock block(rStream);
+
+        m_aTextOrientation.Store(rStream, m_aTextOrientation.GetVersion(fileVersion));
+        m_aVerticalAlignment.Store(rStream, m_aVerticalAlignment.GetVersion(fileVersion));
+    }
+
+    aHorJustify.Store( rStream, aHorJustify.GetVersion(fileVersion) );
+    aVerJustify.Store( rStream, aVerJustify.GetVersion(fileVersion) );
+    aOrientation.Store( rStream, aOrientation.GetVersion(fileVersion) );
+    aMargin.Store( rStream, aMargin.GetVersion(fileVersion) );
+    aLinebreak.Store( rStream, aLinebreak.GetVersion(fileVersion) );
     // Calc Rotation from SO5
-    aRotateAngle.Store( rStream, aRotateAngle.GetVersion(SOFFICE_FILEFORMAT_40) );
-    aRotateMode.Store( rStream, aRotateMode.GetVersion(SOFFICE_FILEFORMAT_40) );
+    aRotateAngle.Store( rStream, aRotateAngle.GetVersion(fileVersion) );
+    aRotateMode.Store( rStream, aRotateMode.GetVersion(fileVersion) );
 
     // --- from 680/dr25 on: store strings as UTF-8
     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStream, sNumFmtString,
@@ -494,31 +602,39 @@ sal_Bool SwBoxAutoFmt::Save( SvStream& rStream ) const
 }
 
 
-sal_Bool SwBoxAutoFmt::SaveVerionNo( SvStream& rStream ) const
+sal_Bool SwBoxAutoFmt::SaveVersionNo( SvStream& rStream, sal_uInt16 fileVersion ) const
 {
-    rStream << aFont.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aHeight.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aWeight.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aPosture.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aUnderline.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aOverline.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aCrossedOut.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aContour.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aShadowed.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aColor.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aBox.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aTLBR.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aBackground.GetVersion( SOFFICE_FILEFORMAT_40 );
-
-    rStream << aAdjust.GetVersion( SOFFICE_FILEFORMAT_40 );
-
-    rStream << aHorJustify.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aVerJustify.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0).GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aMargin.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aLinebreak.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aRotateAngle.GetVersion( SOFFICE_FILEFORMAT_40 );
-    rStream << aRotateMode.GetVersion( SOFFICE_FILEFORMAT_40 );
+    rStream << aFont.GetVersion( fileVersion );
+    rStream << aHeight.GetVersion( fileVersion );
+    rStream << aWeight.GetVersion( fileVersion );
+    rStream << aPosture.GetVersion( fileVersion );
+    rStream << aUnderline.GetVersion( fileVersion );
+    rStream << aOverline.GetVersion( fileVersion );
+    rStream << aCrossedOut.GetVersion( fileVersion );
+    rStream << aContour.GetVersion( fileVersion );
+    rStream << aShadowed.GetVersion( fileVersion );
+    rStream << aColor.GetVersion( fileVersion );
+    rStream << aBox.GetVersion( fileVersion );
+    rStream << aTLBR.GetVersion( fileVersion );
+    rStream << aBackground.GetVersion( fileVersion );
+
+    rStream << aAdjust.GetVersion( fileVersion );
+
+    if (fileVersion >= SOFFICE_FILEFORMAT_50)
+    {
+        WriterSpecificAutoFormatBlock block(rStream);
+
+        rStream << m_aTextOrientation.GetVersion(fileVersion);
+        rStream << m_aVerticalAlignment.GetVersion(fileVersion);
+    }
+
+    rStream << aHorJustify.GetVersion( fileVersion );
+    rStream << aVerJustify.GetVersion( fileVersion );
+    rStream << SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0).GetVersion( fileVersion );
+    rStream << aMargin.GetVersion( fileVersion );
+    rStream << aLinebreak.GetVersion( fileVersion );
+    rStream << aRotateAngle.GetVersion( fileVersion );
+    rStream << aRotateMode.GetVersion( fileVersion );
 
     rStream << (sal_uInt16)0;       // NumberFormat
 
@@ -528,7 +644,15 @@ sal_Bool SwBoxAutoFmt::SaveVerionNo( SvStream& rStream ) const
 
 
 SwTableAutoFmt::SwTableAutoFmt( const String& rName )
-    : aName( rName ), nStrResId( USHRT_MAX )
+    : aName( rName )
+    , nStrResId( USHRT_MAX )
+    , m_aBreak( SVX_BREAK_NONE, RES_BREAK )
+    , m_aKeepWithNextPara( sal_False, RES_KEEP )
+    , m_aRepeatHeading( 0 )
+    , m_bLayoutSplit( sal_True )
+    , m_bRowSplit( sal_True )
+    , m_bCollapsingBorders(sal_True)
+    , m_aShadow( RES_SHADOW )
 {
     bInclFont = sal_True;
     bInclJustify = sal_True;
@@ -542,6 +666,9 @@ SwTableAutoFmt::SwTableAutoFmt( const String& rName )
 
 
 SwTableAutoFmt::SwTableAutoFmt( const SwTableAutoFmt& rNew )
+    : m_aBreak( rNew.m_aBreak )
+    , m_aKeepWithNextPara( sal_False, RES_KEEP )
+    , m_aShadow( RES_SHADOW )
 {
     for( sal_uInt8 n = 0; n < 16; ++n )
         aBoxAutoFmt[ n ] = 0;
@@ -571,6 +698,15 @@ SwTableAutoFmt& SwTableAutoFmt::operator=( const SwTableAutoFmt& rNew )
     bInclValueFormat = rNew.bInclValueFormat;
     bInclWidthHeight = rNew.bInclWidthHeight;
 
+    m_aBreak = rNew.m_aBreak;
+    m_aPageDesc = rNew.m_aPageDesc;
+    m_aKeepWithNextPara = rNew.m_aKeepWithNextPara;
+    m_aRepeatHeading = rNew.m_aRepeatHeading;
+    m_bLayoutSplit = rNew.m_bLayoutSplit;
+    m_bRowSplit = rNew.m_bRowSplit;
+    m_bCollapsingBorders = rNew.m_bCollapsingBorders;
+    m_aShadow = rNew.m_aShadow;
+
     return *this;
 }
 
@@ -614,10 +750,10 @@ const SwBoxAutoFmt& SwTableAutoFmt::GetBoxFmt( sal_uInt8 nPos ) const
 
 
 
-SwBoxAutoFmt& SwTableAutoFmt::UpdateFromSet( sal_uInt8 nPos,
-                                            const SfxItemSet& rSet,
-                                            UpdateFlags eFlags,
-                                            SvNumberFormatter* pNFmtr )
+void SwTableAutoFmt::UpdateFromSet( sal_uInt8 nPos,
+                                    const SfxItemSet& rSet,
+                                    UpdateFlags eFlags,
+                                    SvNumberFormatter* pNFmtr)
 {
     OSL_ENSURE( nPos < 16, "wrong area" );
 
@@ -657,6 +793,8 @@ SwBoxAutoFmt& SwTableAutoFmt::UpdateFromSet( sal_uInt8 nPos,
 //        pFmt->SetTLBR( (SvxLineItem&)rSet.Get( RES_... ) );
 //        pFmt->SetBLTR( (SvxLineItem&)rSet.Get( RES_... ) );
         pFmt->SetBackground( (SvxBrushItem&)rSet.Get( RES_BACKGROUND ) );
+        pFmt->SetTextOrientation(static_cast<const SvxFrameDirectionItem&>(rSet.Get(RES_FRAMEDIR)));
+        pFmt->SetVerticalAlignment(static_cast<const SwFmtVertOrient&>(rSet.Get(RES_VERT_ORIENT)));
 
         const SwTblBoxNumFormat* pNumFmtItem;
         const SvNumberformat* pNumFormat = 0;
@@ -673,14 +811,13 @@ SwBoxAutoFmt& SwTableAutoFmt::UpdateFromSet( sal_uInt8 nPos,
                                   static_cast<LanguageType>(::GetAppLanguage() ));
         }
     }
-    // we cannot handle the rest, that's specific to StarCalc
 
-    return *pFmt;
+    // we cannot handle the rest, that's specific to StarCalc
 }
 
 
-void SwTableAutoFmt::UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet,
-                UpdateFlags eFlags, SvNumberFormatter* pNFmtr ) const
+void SwTableAutoFmt::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet,
+                                 UpdateFlags eFlags, SvNumberFormatter* pNFmtr) const
 {
     const SwBoxAutoFmt& rChg = GetBoxFmt( nPos );
 
@@ -745,6 +882,9 @@ void SwTableAutoFmt::UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet,
         if( IsBackground() )
             rSet.Put( rChg.GetBackground() );
 
+        rSet.Put(rChg.GetTextOrientation());
+        rSet.Put(rChg.GetVerticalAlignment());
+
         if( IsValueFormat() && pNFmtr )
         {
             String sFmt; LanguageType eLng, eSys;
@@ -766,6 +906,62 @@ void SwTableAutoFmt::UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet,
     // we cannot handle the rest, that's specific to StarCalc
 }
 
+void SwTableAutoFmt::RestoreTableProperties(SwTable &table) const
+{
+    SwTableFmt *pFormat = table.GetTableFmt();
+    if (!pFormat)
+        return;
+
+    SwDoc *pDoc = pFormat->GetDoc();
+    if (!pDoc)
+        return;
+
+    SfxItemSet rSet(pDoc->GetAttrPool(), aTableSetRange);
+
+    rSet.Put(m_aBreak);
+    rSet.Put(m_aPageDesc);
+    rSet.Put(SwFmtLayoutSplit(m_bLayoutSplit));
+    rSet.Put(SfxBoolItem(RES_COLLAPSING_BORDERS, m_bCollapsingBorders));
+    rSet.Put(m_aKeepWithNextPara);
+    rSet.Put(m_aShadow);
+
+    pFormat->SetFmtAttr(rSet);
+
+    SwEditShell *pShell = pDoc->GetEditShell();
+    pDoc->SetRowSplit(*pShell->getShellCrsr(false), SwFmtRowSplit(m_bRowSplit));
+
+    table.SetRowsToRepeat(m_aRepeatHeading);
+}
+
+void SwTableAutoFmt::StoreTableProperties(const SwTable &table)
+{
+    SwTableFmt *pFormat = table.GetTableFmt();
+    if (!pFormat)
+        return;
+
+    SwDoc *pDoc = pFormat->GetDoc();
+    if (!pDoc)
+        return;
+
+    SwEditShell *pShell = pDoc->GetEditShell();
+    SwFmtRowSplit *pRowSplit = 0;
+    pDoc->GetRowSplit(*pShell->getShellCrsr(false), pRowSplit);
+    m_bRowSplit = pRowSplit ? pRowSplit->GetValue() : sal_False;
+    delete pRowSplit;
+    pRowSplit = 0;
+
+    const SfxItemSet &rSet = pFormat->GetAttrSet();
+
+    m_aBreak = static_cast<const SvxFmtBreakItem&>(rSet.Get(RES_BREAK));
+    m_aPageDesc = static_cast<const SwFmtPageDesc&>(rSet.Get(RES_PAGEDESC));
+    const SwFmtLayoutSplit &layoutSplit = static_cast<const SwFmtLayoutSplit&>(rSet.Get(RES_LAYOUT_SPLIT));
+    m_bLayoutSplit = layoutSplit.GetValue();
+    m_bCollapsingBorders = static_cast<const SfxBoolItem&>(rSet.Get(RES_COLLAPSING_BORDERS)).GetValue();
+
+    m_aKeepWithNextPara = static_cast<const SvxFmtKeepItem&>(rSet.Get(RES_KEEP));
+    m_aRepeatHeading = table.GetRowsToRepeat();
+    m_aShadow = static_cast<const SvxShadowItem&>(rSet.Get(RES_SHADOW));
+}
 
 sal_Bool SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions )
 {
@@ -800,9 +996,22 @@ sal_Bool SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions
         rStream >> b; bInclValueFormat = b;
         rStream >> b; bInclWidthHeight = b;
 
+        if (nVal >= AUTOFORMAT_DATA_ID_31005 && WriterSpecificBlockExists(rStream))
+        {
+            SfxPoolItem* pNew = 0;
+
+            READ(m_aBreak, SvxFmtBreakItem, AUTOFORMAT_FILE_VERSION);
+            READ(m_aPageDesc, SwFmtPageDesc, AUTOFORMAT_FILE_VERSION);
+            READ(m_aKeepWithNextPara, SvxFmtKeepItem, AUTOFORMAT_FILE_VERSION);
+
+            rStream >> m_aRepeatHeading >> m_bLayoutSplit >> m_bRowSplit >> m_bCollapsingBorders;
+
+            READ(m_aShadow, SvxShadowItem, AUTOFORMAT_FILE_VERSION);
+        }
+
         bRet = 0 == rStream.GetError();
 
-        for( sal_uInt8 i = 0; i < 16; ++i )
+        for( sal_uInt8 i = 0; bRet && i < 16; ++i )
         {
             SwBoxAutoFmt* pFmt = new SwBoxAutoFmt;
             bRet = pFmt->Load( rStream, rVersions, nVal );
@@ -855,7 +1064,7 @@ sal_Bool SwTableAutoFmt::LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] )
 #endif
 
 
-sal_Bool SwTableAutoFmt::Save( SvStream& rStream ) const
+sal_Bool SwTableAutoFmt::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
 {
     sal_uInt16 nVal = AUTOFORMAT_DATA_ID;
     sal_Bool b;
@@ -871,6 +1080,16 @@ sal_Bool SwTableAutoFmt::Save( SvStream& rStream ) const
     rStream << ( b = bInclValueFormat );
     rStream << ( b = bInclWidthHeight );
 
+    {
+        WriterSpecificAutoFormatBlock block(rStream);
+
+        m_aBreak.Store(rStream, m_aBreak.GetVersion(fileVersion));
+        m_aPageDesc.Store(rStream, m_aPageDesc.GetVersion(fileVersion));
+        m_aKeepWithNextPara.Store(rStream, m_aKeepWithNextPara.GetVersion(fileVersion));
+        rStream << m_aRepeatHeading << m_bLayoutSplit << m_bRowSplit << m_bCollapsingBorders;
+        m_aShadow.Store(rStream, m_aShadow.GetVersion(fileVersion));
+    }
+
     sal_Bool bRet = 0 == rStream.GetError();
 
     for( int i = 0; bRet && i < 16; ++i )
@@ -883,7 +1102,7 @@ sal_Bool SwTableAutoFmt::Save( SvStream& rStream ) const
                 pDfltBoxAutoFmt = new SwBoxAutoFmt;
             pFmt = pDfltBoxAutoFmt;
         }
-        bRet = pFmt->Save( rStream );
+        bRet = pFmt->Save( rStream, fileVersion );
     }
     return bRet;
 }
@@ -987,15 +1206,17 @@ sal_Bool SwTableAutoFmtTbl::Load( SvStream& rStream )
         {
             SwAfVersions aVersions;
 
+            // Default version is 5.0, unless we detect an old format ID.
+            sal_uInt16 nFileVers = SOFFICE_FILEFORMAT_50;
+            if(nVal < AUTOFORMAT_ID_31005)
+                nFileVers = SOFFICE_FILEFORMAT_40;
+
             if( nVal == AUTOFORMAT_ID_358 ||
                     (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
             {
-                sal_uInt16 nFileVers = SOFFICE_FILEFORMAT_40;
                 sal_uInt8 nChrSet, nCnt;
                 long nPos = rStream.Tell();
                 rStream >> nCnt >> nChrSet;
-//              if( 4 <= nCnt )
-//                  rStream >> nFileVers;
                 if( rStream.Tell() != sal_uLong(nPos + nCnt) )
                 {
                     OSL_ENSURE( !this, "The Header contains more or newer Data" );
@@ -1073,7 +1294,7 @@ sal_Bool SwTableAutoFmtTbl::Save( SvStream& rStream ) const
     sal_Bool bRet = 0 == rStream.GetError();
     if (bRet)
     {
-        rStream.SetVersion( SOFFICE_FILEFORMAT_40 );
+        rStream.SetVersion(AUTOFORMAT_FILE_VERSION);
 
         // Attention: We need to save a general Header here
         sal_uInt16 nVal = AUTOFORMAT_ID;
@@ -1084,7 +1305,7 @@ sal_Bool SwTableAutoFmtTbl::Save( SvStream& rStream ) const
         bRet = 0 == rStream.GetError();
 
         // Write this version number for all attributes
-        (*this)[ 0 ]->GetBoxFmt( 0 ).SaveVerionNo( rStream );
+        (*this)[ 0 ]->GetBoxFmt( 0 ).SaveVersionNo( rStream, AUTOFORMAT_FILE_VERSION );
 
         rStream << (sal_uInt16)(Count() - 1);
         bRet = 0 == rStream.GetError();
@@ -1092,7 +1313,7 @@ sal_Bool SwTableAutoFmtTbl::Save( SvStream& rStream ) const
         for( sal_uInt16 i = 1; bRet && i < Count(); ++i )
         {
             SwTableAutoFmt* pFmt = (*this)[ i ];
-            bRet = pFmt->Save( rStream );
+            bRet = pFmt->Save( rStream, AUTOFORMAT_FILE_VERSION );
         }
     }
     rStream.Flush();
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 3c373bf..a338ded 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3724,7 +3724,8 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt&
     if( aFndBox.GetLines().empty() )
         return sal_False;
 
-    pTblNd->GetTable().SetHTMLTableLayout( 0 );
+    SwTable &table = pTblNd->GetTable();
+    table.SetHTMLTableLayout( 0 );
 
     _FndBox* pFndBox = &aFndBox;
     while( 1 == pFndBox->GetLines().size() &&
@@ -3747,6 +3748,8 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt&
         GetIDocumentUndoRedo().DoUndo(false);
     }
 
+    rNew.RestoreTableProperties(table);
+
     _SetAFmtTabPara aPara( rNew );
     _FndLines& rFLns = pFndBox->GetLines();
     _FndLine* pLine;
@@ -3808,6 +3811,10 @@ sal_Bool SwDoc::GetTableAutoFmt( const SwSelBoxes& rBoxes, SwTableAutoFmt& rGet
     if( aFndBox.GetLines().empty() )
         return sal_False;
 
+    // Store table properties
+    SwTable &table = pTblNd->GetTable();
+    rGet.StoreTableProperties(table);
+
     _FndBox* pFndBox = &aFndBox;
     while( 1 == pFndBox->GetLines().size() &&
             1 == pFndBox->GetLines().front().GetBoxes().size() )
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 6e29527..51c1a82 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -637,6 +637,17 @@ SwFmtPageDesc::SwFmtPageDesc( const SwPageDesc *pDesc )
 {
 }
 
+SwFmtPageDesc &SwFmtPageDesc::operator=(const SwFmtPageDesc &rCpy)
+{
+    if (rCpy.GetPageDesc())
+        RegisterToPageDesc(*const_cast<SwPageDesc*>(rCpy.GetPageDesc()));
+    nNumOffset = rCpy.nNumOffset;
+    nDescNameIdx = rCpy.nDescNameIdx;
+    pDefinedIn = 0;
+
+    return *this;
+}
+
  SwFmtPageDesc::~SwFmtPageDesc() {}
 
 bool SwFmtPageDesc::KnowsPageDesc() const
@@ -1228,6 +1239,22 @@ bool SwFmtSurround::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     return bRet;
 }
 
+SvStream& SwFmtVertOrient::Store(SvStream &rStream, sal_uInt16 /*version*/) const
+{
+    rStream << nYPos << eOrient << eRelation;
+    return rStream;
+}
+
+SfxPoolItem* SwFmtVertOrient::Create(SvStream &rStream, sal_uInt16 /*itemVersion*/) const
+{
+    SwTwips yPos;
+    sal_Int16 orient;
+    sal_Int16 relation;
+    rStream >> yPos >> orient >> relation;
+
+    return new SwFmtVertOrient(yPos, orient, relation);
+}
+
 //  class SwFmtVertOrient
 //  Partially implemented inline in hxx
 
commit 002127460ad4b18fd66723e93c3d308ffc7207b1
Author: Muhammad Haggag <mhaggag at gmail.com>
Date:   Wed May 2 22:32:48 2012 +0200

    fdo#31005 Writer: Undo support for "Repeat Heading" in autoformat application

diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 67bbeb9..d6bf7a0 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -600,7 +600,7 @@ sal_Bool SvxBorderTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
     const SfxPoolItem* pOld = 0;
 
     //------------------
-    // outter border:
+    // outer border:
     //------------------
     typedef ::std::pair<svx::FrameBorderType,sal_uInt16> TBorderPair;
     TBorderPair eTypes1[] = {
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 3f14ca4..83edaa3 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -162,6 +162,7 @@ class SwUndoTblAutoFmt : public SwUndo
     _SaveTable* pSaveTbl;
     ::std::vector< ::boost::shared_ptr<SwUndoTblNumFmt> > m_Undos;
     sal_Bool bSaveCntntAttr;
+    sal_uInt16 m_nRepeatHeading;
 
     void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
 
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 0f295a1..33afb36 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1473,6 +1473,7 @@ SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd,
     : SwUndo( UNDO_TABLE_AUTOFMT ),
     nSttNode( rTblNd.GetIndex() ),
     bSaveCntntAttr( sal_False )
+    , m_nRepeatHeading(rTblNd.GetTable().GetRowsToRepeat())
 {
     pSaveTbl = new _SaveTable( rTblNd.GetTable() );
 
@@ -1504,7 +1505,8 @@ SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext)
     SwTableNode* pTblNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode();
     OSL_ENSURE( pTblNd, "kein TabellenNode" );
 
-    _SaveTable* pOrig = new _SaveTable( pTblNd->GetTable() );
+    SwTable& table = pTblNd->GetTable();
+    _SaveTable* pOrig = new _SaveTable( table );
         // dann auch noch ueber die ContentNodes der EndBoxen und
         // und alle Absatz-Attribute zusammen sammeln
     if( bSaveCntntAttr )
@@ -1516,6 +1518,8 @@ SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext)
         {
             m_Undos.at(n-1)->UndoImpl(rContext);
         }
+
+        table.SetRowsToRepeat(m_nRepeatHeading);
     }
 
     pSaveTbl->RestoreAttr( pTblNd->GetTable(), !bUndo );
diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx
index 23fb5bc..9053b15 100644
--- a/sw/source/ui/table/tabledlg.cxx
+++ b/sw/source/ui/table/tabledlg.cxx
@@ -1409,7 +1409,7 @@ sal_Bool  SwTextFlowPage::FillItemSet( SfxItemSet& rSet )
 {
     sal_Bool bModified = sal_False;
 
-    //Ueberschrift wiederholen
+    // Repeat Heading
     if(aHeadLineCB.IsChecked() != aHeadLineCB.GetSavedValue() ||
         String::CreateFromInt32( static_cast< sal_Int32 >(aRepeatHeaderNF.GetValue()) ) != aRepeatHeaderNF.GetSavedValue() )
     {
@@ -1432,7 +1432,7 @@ sal_Bool  SwTextFlowPage::FillItemSet( SfxItemSet& rSet )
 
     sal_Bool bState = aPageCollCB.IsChecked();
 
-    //Wenn Seitenvorlage, dann kein Break
+    // If we have a page style, then there's no break
     sal_Bool bPageItemPut = sal_False;
     if ( bState != aPageCollCB.GetSavedValue() ||
          ( bState &&


More information about the Libreoffice-commits mailing list