LCOV - code coverage report
Current view: top level - sw/source/core/doc - tblafmt.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 610 0.2 %
Date: 2014-11-03 Functions: 2 42 4.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/resid.hxx>
      21             : #include <tools/stream.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include <sfx2/docfile.hxx>
      24             : #include <svl/urihelper.hxx>
      25             : #include <svl/zforlist.hxx>
      26             : #include <svl/zformat.hxx>
      27             : #include <unotools/pathoptions.hxx>
      28             : #include <sfx2/app.hxx>
      29             : #include <svx/dialmgr.hxx>
      30             : #include <svx/dialogs.hrc>
      31             : #include <swtable.hxx>
      32             : #include <swtblfmt.hxx>
      33             : #include <com/sun/star/text/VertOrientation.hpp>
      34             : #include <swtypes.hxx>
      35             : #include <doc.hxx>
      36             : #include <poolfmt.hxx>
      37             : #include <tblafmt.hxx>
      38             : #include <cellatr.hxx>
      39             : #include <SwStyleNameMapper.hxx>
      40             : #include <hintids.hxx>
      41             : #include <fmtornt.hxx>
      42             : #include <editsh.hxx>
      43             : 
      44             : /*
      45             :  * XXX: BIG RED NOTICE! Changes MUST be binary file format compatible and MUST
      46             :  * be synchronized with Calc's ScAutoFormat sc/source/core/tool/autoform.cxx
      47             :  */
      48             : 
      49             : using ::editeng::SvxBorderLine;
      50             : 
      51             : // until SO5PF
      52             : const sal_uInt16 AUTOFORMAT_ID_X        = 9501;
      53             : const sal_uInt16 AUTOFORMAT_ID_358      = 9601;
      54             : const sal_uInt16 AUTOFORMAT_DATA_ID_X   = 9502;
      55             : 
      56             : // from SO5
      57             : //! In follow-up versions these IDs' values need to increase
      58             : const sal_uInt16 AUTOFORMAT_ID_504      = 9801;
      59             : const sal_uInt16 AUTOFORMAT_DATA_ID_504 = 9802;
      60             : 
      61             : const sal_uInt16 AUTOFORMAT_DATA_ID_552 = 9902;
      62             : 
      63             : // --- from 641 on: CJK and CTL font settings
      64             : const sal_uInt16 AUTOFORMAT_DATA_ID_641 = 10002;
      65             : 
      66             : // --- from 680/dr14 on: diagonal frame lines
      67             : const sal_uInt16 AUTOFORMAT_ID_680DR14      = 10011;
      68             : const sal_uInt16 AUTOFORMAT_DATA_ID_680DR14 = 10012;
      69             : 
      70             : // --- from 680/dr25 on: store strings as UTF-8
      71             : const sal_uInt16 AUTOFORMAT_ID_680DR25      = 10021;
      72             : 
      73             : // --- from DEV300/overline2 on: overline
      74             : const sal_uInt16 AUTOFORMAT_ID_300OVRLN      = 10031;
      75             : const sal_uInt16 AUTOFORMAT_DATA_ID_300OVRLN = 10032;
      76             : 
      77             : // --- Bug fix to fdo#31005: Table Autoformats does not save/apply all properties (Writer and Calc)
      78             : const sal_uInt16 AUTOFORMAT_ID_31005      = 10041;
      79             : const sal_uInt16 AUTOFORMAT_DATA_ID_31005 = 10042;
      80             : 
      81             : // current version
      82             : const sal_uInt16 AUTOFORMAT_ID          = AUTOFORMAT_ID_31005;
      83             : const sal_uInt16 AUTOFORMAT_DATA_ID     = AUTOFORMAT_DATA_ID_31005;
      84             : const sal_uInt16 AUTOFORMAT_FILE_VERSION= SOFFICE_FILEFORMAT_50;
      85             : 
      86             : SwBoxAutoFmt* SwTableAutoFmt::pDfltBoxAutoFmt = 0;
      87             : 
      88             : #define AUTOTABLE_FORMAT_NAME "autotbl.fmt"
      89             : 
      90             : namespace
      91             : {
      92             :     /// Begins a writer-specific data block. Call before serializing any writer-specific properties.
      93           0 :     sal_uInt64 BeginSwBlock(SvStream& rStream)
      94             :     {
      95             :         // We need to write down the offset of the end of the writer-specific data, so that
      96             :         // calc can skip it. We'll only have that value after writing the data, so we
      97             :         // write a placeholder value first, write the data, then jump back and write the
      98             :         // real offset.
      99             : 
     100             :         // Note that we explicitly use sal_uInt64 instead of sal_Size (which can be 32
     101             :         // or 64 depending on platform) to ensure 64-bit portability on this front. I don't
     102             :         // actually know if autotbl.fmt as a whole is portable, since that requires all serialization
     103             :         // logic to be written with portability in mind.
     104           0 :         sal_uInt64 whereToWriteEndOfSwBlock = rStream.Tell();
     105             : 
     106           0 :         sal_uInt64 endOfSwBlock = 0;
     107           0 :         rStream.WriteUInt64( endOfSwBlock );
     108             : 
     109           0 :         return whereToWriteEndOfSwBlock;
     110             :     }
     111             : 
     112             :     /// Ends a writer-specific data block. Call after serializing writer-specific properties.
     113             :     /// Closes a corresponding BeginSwBlock call.
     114           0 :     void EndSwBlock(SvStream& rStream, sal_uInt64 whereToWriteEndOfSwBlock)
     115             :     {
     116           0 :         sal_uInt64 endOfSwBlock = rStream.Tell();
     117           0 :         rStream.Seek(whereToWriteEndOfSwBlock);
     118           0 :         rStream.WriteUInt64( endOfSwBlock );
     119           0 :         rStream.Seek(endOfSwBlock);
     120           0 :     }
     121             : 
     122             :     /**
     123             :     Helper class for writer-specific blocks. Begins a writer-specific block on construction,
     124             :     and closes it on destruction.
     125             : 
     126             :     See also: BeginSwBlock and EndSwBlock.
     127             :     */
     128             :     class WriterSpecificAutoFormatBlock : ::boost::noncopyable
     129             :     {
     130             :     public:
     131           0 :         WriterSpecificAutoFormatBlock(SvStream &rStream) : _rStream(rStream)
     132             :         {
     133           0 :             _whereToWriteEndOfBlock = BeginSwBlock(rStream);
     134           0 :         }
     135             : 
     136           0 :         ~WriterSpecificAutoFormatBlock()
     137             :         {
     138           0 :             EndSwBlock(_rStream, _whereToWriteEndOfBlock);
     139           0 :         }
     140             : 
     141             :     private:
     142             :         SvStream &_rStream;
     143             :         sal_uInt64 _whereToWriteEndOfBlock;
     144             :     };
     145             : 
     146             :     /// Checks whether a writer-specific block exists (i.e. size is not zero)
     147           0 :     bool WriterSpecificBlockExists(SvStream &stream)
     148             :     {
     149           0 :         sal_uInt64 endOfSwBlock = 0;
     150           0 :         stream.ReadUInt64( endOfSwBlock );
     151             : 
     152             :         // end-of-block pointing to itself indicates a zero-size block.
     153           0 :         return endOfSwBlock != stream.Tell();
     154             :     }
     155             : }
     156             : 
     157             : // Struct with version numbers of the Items
     158             : 
     159             : struct SwAfVersions
     160             : {
     161             : public:
     162             :     sal_uInt16 nFontVersion;
     163             :     sal_uInt16 nFontHeightVersion;
     164             :     sal_uInt16 nWeightVersion;
     165             :     sal_uInt16 nPostureVersion;
     166             :     sal_uInt16 nUnderlineVersion;
     167             :     sal_uInt16 nOverlineVersion;
     168             :     sal_uInt16 nCrossedOutVersion;
     169             :     sal_uInt16 nContourVersion;
     170             :     sal_uInt16 nShadowedVersion;
     171             :     sal_uInt16 nColorVersion;
     172             :     sal_uInt16 nBoxVersion;
     173             :     sal_uInt16 nLineVersion;
     174             :     sal_uInt16 nBrushVersion;
     175             : 
     176             :     sal_uInt16 nAdjustVersion;
     177             :     sal_uInt16 m_nTextOrientationVersion;
     178             :     sal_uInt16 m_nVerticalAlignmentVersion;
     179             : 
     180             :     sal_uInt16 nHorJustifyVersion;
     181             :     sal_uInt16 nVerJustifyVersion;
     182             :     sal_uInt16 nOrientationVersion;
     183             :     sal_uInt16 nMarginVersion;
     184             :     sal_uInt16 nBoolVersion;
     185             :     sal_uInt16 nInt32Version;
     186             :     sal_uInt16 nRotateModeVersion;
     187             : 
     188             :     sal_uInt16 nNumFmtVersion;
     189             : 
     190             :     SwAfVersions();
     191             :     void Load( SvStream& rStream, sal_uInt16 nVer );
     192             : };
     193             : 
     194           0 : SwAfVersions::SwAfVersions() :
     195             :     nFontVersion(0),
     196             :     nFontHeightVersion(0),
     197             :     nWeightVersion(0),
     198             :     nPostureVersion(0),
     199             :     nUnderlineVersion(0),
     200             :     nOverlineVersion(0),
     201             :     nCrossedOutVersion(0),
     202             :     nContourVersion(0),
     203             :     nShadowedVersion(0),
     204             :     nColorVersion(0),
     205             :     nBoxVersion(0),
     206             :     nLineVersion(0),
     207             :     nBrushVersion(0),
     208             :     nAdjustVersion(0),
     209             :     m_nTextOrientationVersion(0),
     210             :     m_nVerticalAlignmentVersion(0),
     211             :     nHorJustifyVersion(0),
     212             :     nVerJustifyVersion(0),
     213             :     nOrientationVersion(0),
     214             :     nMarginVersion(0),
     215             :     nBoolVersion(0),
     216             :     nInt32Version(0),
     217             :     nRotateModeVersion(0),
     218           0 :     nNumFmtVersion(0)
     219             : {
     220           0 : }
     221             : 
     222           0 : void SwAfVersions::Load( SvStream& rStream, sal_uInt16 nVer )
     223             : {
     224           0 :     rStream.ReadUInt16( nFontVersion );
     225           0 :     rStream.ReadUInt16( nFontHeightVersion );
     226           0 :     rStream.ReadUInt16( nWeightVersion );
     227           0 :     rStream.ReadUInt16( nPostureVersion );
     228           0 :     rStream.ReadUInt16( nUnderlineVersion );
     229           0 :     if ( nVer >= AUTOFORMAT_ID_300OVRLN )
     230           0 :         rStream.ReadUInt16( nOverlineVersion );
     231           0 :     rStream.ReadUInt16( nCrossedOutVersion );
     232           0 :     rStream.ReadUInt16( nContourVersion );
     233           0 :     rStream.ReadUInt16( nShadowedVersion );
     234           0 :     rStream.ReadUInt16( nColorVersion );
     235           0 :     rStream.ReadUInt16( nBoxVersion );
     236           0 :     if ( nVer >= AUTOFORMAT_ID_680DR14 )
     237           0 :         rStream.ReadUInt16( nLineVersion );
     238           0 :     rStream.ReadUInt16( nBrushVersion );
     239           0 :     rStream.ReadUInt16( nAdjustVersion );
     240           0 :     if (nVer >= AUTOFORMAT_ID_31005 && WriterSpecificBlockExists(rStream))
     241             :     {
     242           0 :         rStream.ReadUInt16( m_nTextOrientationVersion );
     243           0 :         rStream.ReadUInt16( m_nVerticalAlignmentVersion );
     244             :     }
     245             : 
     246           0 :     rStream.ReadUInt16( nHorJustifyVersion );
     247           0 :     rStream.ReadUInt16( nVerJustifyVersion );
     248           0 :     rStream.ReadUInt16( nOrientationVersion );
     249           0 :     rStream.ReadUInt16( nMarginVersion );
     250           0 :     rStream.ReadUInt16( nBoolVersion );
     251           0 :     if ( nVer >= AUTOFORMAT_ID_504 )
     252             :     {
     253           0 :         rStream.ReadUInt16( nInt32Version );
     254           0 :         rStream.ReadUInt16( nRotateModeVersion );
     255             :     }
     256           0 :     rStream.ReadUInt16( nNumFmtVersion );
     257           0 : }
     258             : 
     259           0 : SwBoxAutoFmt::SwBoxAutoFmt()
     260           0 :     : aFont( *(SvxFontItem*)GetDfltAttr( RES_CHRATR_FONT ) ),
     261             :     aHeight( 240, 100, RES_CHRATR_FONTSIZE ),
     262             :     aWeight( WEIGHT_NORMAL, RES_CHRATR_WEIGHT ),
     263             :     aPosture( ITALIC_NONE, RES_CHRATR_POSTURE ),
     264             : 
     265           0 :     aCJKFont( *(SvxFontItem*)GetDfltAttr( RES_CHRATR_CJK_FONT ) ),
     266             :     aCJKHeight( 240, 100, RES_CHRATR_CJK_FONTSIZE ),
     267             :     aCJKWeight( WEIGHT_NORMAL, RES_CHRATR_CJK_WEIGHT ),
     268             :     aCJKPosture( ITALIC_NONE, RES_CHRATR_CJK_POSTURE ),
     269             : 
     270           0 :     aCTLFont( *(SvxFontItem*)GetDfltAttr( RES_CHRATR_CTL_FONT ) ),
     271             :     aCTLHeight( 240, 100, RES_CHRATR_CTL_FONTSIZE ),
     272             :     aCTLWeight( WEIGHT_NORMAL, RES_CHRATR_CTL_WEIGHT ),
     273             :     aCTLPosture( ITALIC_NONE, RES_CHRATR_CTL_POSTURE ),
     274             : 
     275             :     aUnderline( UNDERLINE_NONE, RES_CHRATR_UNDERLINE ),
     276             :     aOverline( UNDERLINE_NONE, RES_CHRATR_OVERLINE ),
     277             :     aCrossedOut( STRIKEOUT_NONE, RES_CHRATR_CROSSEDOUT ),
     278             :     aContour( false, RES_CHRATR_CONTOUR ),
     279             :     aShadowed( false, RES_CHRATR_SHADOWED ),
     280             :     aColor( RES_CHRATR_COLOR ),
     281             :     aBox( RES_BOX ),
     282             :     aTLBR( 0 ),
     283             :     aBLTR( 0 ),
     284             :     aBackground( RES_BACKGROUND ),
     285             :     aAdjust( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ),
     286             :     m_aTextOrientation(FRMDIR_ENVIRONMENT, RES_FRAMEDIR),
     287             :     m_aVerticalAlignment(0, com::sun::star::text::VertOrientation::NONE, com::sun::star::text::RelOrientation::FRAME),
     288             :     aHorJustify( SVX_HOR_JUSTIFY_STANDARD, 0),
     289             :     aVerJustify( SVX_VER_JUSTIFY_STANDARD, 0),
     290             :     aStacked( 0 ),
     291             :     aMargin( 0 ),
     292             :     aLinebreak( 0 ),
     293             :     aRotateAngle( 0 ),
     294             : 
     295             : // FIXME - add attribute IDs for the diagonal line items
     296             : //    aTLBR( RES_... ),
     297             : //    aBLTR( RES_... ),
     298           0 :     aRotateMode( SVX_ROTATE_MODE_STANDARD, 0 )
     299             : {
     300           0 :     eSysLanguage = eNumFmtLanguage = ::GetAppLanguage();
     301           0 :     aBox.SetDistance( 55 );
     302           0 : }
     303             : 
     304           0 : SwBoxAutoFmt::SwBoxAutoFmt( const SwBoxAutoFmt& rNew )
     305             :     : aFont( rNew.aFont ),
     306             :     aHeight( rNew.aHeight ),
     307             :     aWeight( rNew.aWeight ),
     308             :     aPosture( rNew.aPosture ),
     309             :     aCJKFont( rNew.aCJKFont ),
     310             :     aCJKHeight( rNew.aCJKHeight ),
     311             :     aCJKWeight( rNew.aCJKWeight ),
     312             :     aCJKPosture( rNew.aCJKPosture ),
     313             :     aCTLFont( rNew.aCTLFont ),
     314             :     aCTLHeight( rNew.aCTLHeight ),
     315             :     aCTLWeight( rNew.aCTLWeight ),
     316             :     aCTLPosture( rNew.aCTLPosture ),
     317             :     aUnderline( rNew.aUnderline ),
     318             :     aOverline( rNew.aOverline ),
     319             :     aCrossedOut( rNew.aCrossedOut ),
     320             :     aContour( rNew.aContour ),
     321             :     aShadowed( rNew.aShadowed ),
     322             :     aColor( rNew.aColor ),
     323             :     aBox( rNew.aBox ),
     324             :     aTLBR( rNew.aTLBR ),
     325             :     aBLTR( rNew.aBLTR ),
     326             :     aBackground( rNew.aBackground ),
     327             :     aAdjust( rNew.aAdjust ),
     328             :     m_aTextOrientation(rNew.m_aTextOrientation),
     329             :     m_aVerticalAlignment(rNew.m_aVerticalAlignment),
     330             :     aHorJustify( rNew.aHorJustify ),
     331             :     aVerJustify( rNew.aVerJustify ),
     332             :     aStacked( rNew.aStacked ),
     333             :     aMargin( rNew.aMargin ),
     334             :     aLinebreak( rNew.aLinebreak ),
     335             :     aRotateAngle( rNew.aRotateAngle ),
     336             :     aRotateMode( rNew.aRotateMode ),
     337             :     sNumFmtString( rNew.sNumFmtString ),
     338             :     eSysLanguage( rNew.eSysLanguage ),
     339           0 :     eNumFmtLanguage( rNew.eNumFmtLanguage )
     340             : {
     341           0 : }
     342             : 
     343           0 : SwBoxAutoFmt::~SwBoxAutoFmt()
     344             : {
     345           0 : }
     346             : 
     347           0 : SwBoxAutoFmt& SwBoxAutoFmt::operator=( const SwBoxAutoFmt& rNew )
     348             : {
     349           0 :     aFont = rNew.aFont;
     350           0 :     aHeight = rNew.aHeight;
     351           0 :     aWeight = rNew.aWeight;
     352           0 :     aPosture = rNew.aPosture;
     353           0 :     aCJKFont = rNew.aCJKFont;
     354           0 :     aCJKHeight = rNew.aCJKHeight;
     355           0 :     aCJKWeight = rNew.aCJKWeight;
     356           0 :     aCJKPosture = rNew.aCJKPosture;
     357           0 :     aCTLFont = rNew.aCTLFont;
     358           0 :     aCTLHeight = rNew.aCTLHeight;
     359           0 :     aCTLWeight = rNew.aCTLWeight;
     360           0 :     aCTLPosture = rNew.aCTLPosture;
     361           0 :     aUnderline = rNew.aUnderline;
     362           0 :     aOverline = rNew.aOverline;
     363           0 :     aCrossedOut = rNew.aCrossedOut;
     364           0 :     aContour = rNew.aContour;
     365           0 :     aShadowed = rNew.aShadowed;
     366           0 :     aColor = rNew.aColor;
     367           0 :     SetAdjust( rNew.aAdjust );
     368           0 :     m_aTextOrientation = rNew.m_aTextOrientation;
     369           0 :     m_aVerticalAlignment = rNew.m_aVerticalAlignment;
     370           0 :     aBox = rNew.aBox;
     371           0 :     aTLBR = rNew.aTLBR;
     372           0 :     aBLTR = rNew.aBLTR;
     373           0 :     aBackground = rNew.aBackground;
     374             : 
     375           0 :     aHorJustify = rNew.aHorJustify;
     376           0 :     aVerJustify = rNew.aVerJustify;
     377           0 :     aStacked.SetValue( rNew.aStacked.GetValue() );
     378           0 :     aMargin = rNew.aMargin;
     379           0 :     aLinebreak.SetValue( rNew.aLinebreak.GetValue() );
     380           0 :     aRotateAngle.SetValue( rNew.aRotateAngle.GetValue() );
     381           0 :     aRotateMode.SetValue( rNew.aRotateMode.GetValue() );
     382             : 
     383           0 :     sNumFmtString = rNew.sNumFmtString;
     384           0 :     eSysLanguage = rNew.eSysLanguage;
     385           0 :     eNumFmtLanguage = rNew.eNumFmtLanguage;
     386             : 
     387           0 :     return *this;
     388             : }
     389             : 
     390             : #define READ( aItem, aItemType, nVers )\
     391             :     pNew = aItem.Create(rStream, nVers ); \
     392             :     aItem = *(aItemType*)pNew; \
     393             :     delete pNew;
     394             : 
     395           0 : bool SwBoxAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer )
     396             : {
     397             :     SfxPoolItem* pNew;
     398           0 :     SvxOrientationItem aOrientation( SVX_ORIENTATION_STANDARD, 0);
     399             : 
     400           0 :     READ( aFont,        SvxFontItem            , rVersions.nFontVersion)
     401             : 
     402           0 :     if( rStream.GetStreamCharSet() == aFont.GetCharSet() )
     403           0 :         aFont.SetCharSet(::osl_getThreadTextEncoding());
     404             : 
     405           0 :     READ( aHeight,      SvxFontHeightItem  , rVersions.nFontHeightVersion)
     406           0 :     READ( aWeight,      SvxWeightItem      , rVersions.nWeightVersion)
     407           0 :     READ( aPosture,     SvxPostureItem     , rVersions.nPostureVersion)
     408             :     // --- from 641 on: CJK and CTL font settings
     409           0 :     if( AUTOFORMAT_DATA_ID_641 <= nVer )
     410             :     {
     411           0 :         READ( aCJKFont,                        SvxFontItem         , rVersions.nFontVersion)
     412           0 :         READ( aCJKHeight,       SvxFontHeightItem   , rVersions.nFontHeightVersion)
     413           0 :         READ( aCJKWeight,     SvxWeightItem       , rVersions.nWeightVersion)
     414           0 :         READ( aCJKPosture,   SvxPostureItem      , rVersions.nPostureVersion)
     415           0 :         READ( aCTLFont,                        SvxFontItem         , rVersions.nFontVersion)
     416           0 :         READ( aCTLHeight,        SvxFontHeightItem   , rVersions.nFontHeightVersion)
     417           0 :         READ( aCTLWeight,       SvxWeightItem       , rVersions.nWeightVersion)
     418           0 :         READ( aCTLPosture,   SvxPostureItem      , rVersions.nPostureVersion)
     419             :     }
     420           0 :     READ( aUnderline,   SvxUnderlineItem   , rVersions.nUnderlineVersion)
     421           0 :     if( nVer >= AUTOFORMAT_DATA_ID_300OVRLN )
     422             :     {
     423           0 :         READ( aOverline,       SvxOverlineItem     , rVersions.nOverlineVersion)
     424             :     }
     425           0 :     READ( aCrossedOut,  SvxCrossedOutItem  , rVersions.nCrossedOutVersion)
     426           0 :     READ( aContour,     SvxContourItem     , rVersions.nContourVersion)
     427           0 :     READ( aShadowed,    SvxShadowedItem       , rVersions.nShadowedVersion)
     428           0 :     READ( aColor,       SvxColorItem       , rVersions.nColorVersion)
     429             : 
     430           0 :     READ( aBox,         SvxBoxItem         , rVersions.nBoxVersion)
     431             : 
     432             :     // --- from 680/dr14 on: diagonal frame lines
     433           0 :     if( nVer >= AUTOFORMAT_DATA_ID_680DR14 )
     434             :     {
     435           0 :         READ( aTLBR, SvxLineItem, rVersions.nLineVersion)
     436           0 :         READ( aBLTR, SvxLineItem, rVersions.nLineVersion)
     437             :     }
     438             : 
     439           0 :     READ( aBackground,  SvxBrushItem        , rVersions.nBrushVersion)
     440             : 
     441           0 :     pNew = aAdjust.Create(rStream, rVersions.nAdjustVersion );
     442           0 :     SetAdjust( *(SvxAdjustItem*)pNew );
     443           0 :     delete pNew;
     444             : 
     445           0 :     if (nVer >= AUTOFORMAT_DATA_ID_31005 && WriterSpecificBlockExists(rStream))
     446             :     {
     447           0 :         READ(m_aTextOrientation, SvxFrameDirectionItem, rVersions.m_nTextOrientationVersion);
     448           0 :         READ(m_aVerticalAlignment, SwFmtVertOrient, rVersions.m_nVerticalAlignmentVersion);
     449             :     }
     450             : 
     451           0 :     READ( aHorJustify,  SvxHorJustifyItem , rVersions.nHorJustifyVersion)
     452           0 :     READ( aVerJustify,  SvxVerJustifyItem   , rVersions.nVerJustifyVersion)
     453             : 
     454           0 :     READ( aOrientation, SvxOrientationItem  , rVersions.nOrientationVersion)
     455           0 :     READ( aMargin, SvxMarginItem       , rVersions.nMarginVersion)
     456             : 
     457           0 :     pNew = aLinebreak.Create(rStream, rVersions.nBoolVersion );
     458           0 :     aLinebreak.SetValue( ((SfxBoolItem*)pNew)->GetValue() );
     459           0 :     delete pNew;
     460             : 
     461           0 :     if ( nVer >= AUTOFORMAT_DATA_ID_504 )
     462             :     {
     463           0 :         pNew = aRotateAngle.Create( rStream, rVersions.nInt32Version );
     464           0 :         aRotateAngle.SetValue( ((SfxInt32Item*)pNew)->GetValue() );
     465           0 :         delete pNew;
     466           0 :         pNew = aRotateMode.Create( rStream, rVersions.nRotateModeVersion );
     467           0 :         aRotateMode.SetValue( ((SvxRotateModeItem*)pNew)->GetValue() );
     468           0 :         delete pNew;
     469             :     }
     470             : 
     471           0 :     if( 0 == rVersions.nNumFmtVersion )
     472             :     {
     473             :         sal_uInt16 eSys, eLge;
     474             :         // --- from 680/dr25 on: store strings as UTF-8
     475           0 :         rtl_TextEncoding eCharSet = (nVer >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
     476           0 :         sNumFmtString = rStream.ReadUniOrByteString( eCharSet );
     477           0 :         rStream.ReadUInt16( eSys ).ReadUInt16( eLge );
     478           0 :         eSysLanguage = (LanguageType) eSys;
     479           0 :         eNumFmtLanguage = (LanguageType) eLge;
     480           0 :         if ( eSysLanguage == LANGUAGE_SYSTEM )      // from old versions (Calc)
     481           0 :             eSysLanguage = ::GetAppLanguage();
     482             :     }
     483             : 
     484           0 :     aStacked.SetValue( aOrientation.IsStacked() );
     485           0 :     aRotateAngle.SetValue( aOrientation.GetRotation( aRotateAngle.GetValue() ) );
     486             : 
     487           0 :     return 0 == rStream.GetError();
     488             : }
     489             : 
     490           0 : bool SwBoxAutoFmt::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
     491             : {
     492           0 :     SvxOrientationItem aOrientation( aRotateAngle.GetValue(), aStacked.GetValue(), 0 );
     493             : 
     494           0 :     aFont.Store( rStream, aFont.GetVersion(fileVersion)  );
     495           0 :     aHeight.Store( rStream, aHeight.GetVersion(fileVersion) );
     496           0 :     aWeight.Store( rStream, aWeight.GetVersion(fileVersion) );
     497           0 :     aPosture.Store( rStream, aPosture.GetVersion(fileVersion) );
     498           0 :     aCJKFont.Store( rStream, aCJKFont.GetVersion(fileVersion)  );
     499           0 :     aCJKHeight.Store( rStream, aCJKHeight.GetVersion(fileVersion) );
     500           0 :     aCJKWeight.Store( rStream, aCJKWeight.GetVersion(fileVersion) );
     501           0 :     aCJKPosture.Store( rStream, aCJKPosture.GetVersion(fileVersion) );
     502           0 :     aCTLFont.Store( rStream, aCTLFont.GetVersion(fileVersion)  );
     503           0 :     aCTLHeight.Store( rStream, aCTLHeight.GetVersion(fileVersion) );
     504           0 :     aCTLWeight.Store( rStream, aCTLWeight.GetVersion(fileVersion) );
     505           0 :     aCTLPosture.Store( rStream, aCTLPosture.GetVersion(fileVersion) );
     506           0 :     aUnderline.Store( rStream, aUnderline.GetVersion(fileVersion) );
     507           0 :     aOverline.Store( rStream, aOverline.GetVersion(fileVersion) );
     508           0 :     aCrossedOut.Store( rStream, aCrossedOut.GetVersion(fileVersion) );
     509           0 :     aContour.Store( rStream, aContour.GetVersion(fileVersion) );
     510           0 :     aShadowed.Store( rStream, aShadowed.GetVersion(fileVersion) );
     511           0 :     aColor.Store( rStream, aColor.GetVersion(fileVersion) );
     512           0 :     aBox.Store( rStream, aBox.GetVersion(fileVersion) );
     513           0 :     aTLBR.Store( rStream, aTLBR.GetVersion(fileVersion) );
     514           0 :     aBLTR.Store( rStream, aBLTR.GetVersion(fileVersion) );
     515           0 :     aBackground.Store( rStream, aBackground.GetVersion(fileVersion) );
     516             : 
     517           0 :     aAdjust.Store( rStream, aAdjust.GetVersion(fileVersion) );
     518           0 :     if (fileVersion >= SOFFICE_FILEFORMAT_50)
     519             :     {
     520           0 :         WriterSpecificAutoFormatBlock block(rStream);
     521             : 
     522           0 :         m_aTextOrientation.Store(rStream, m_aTextOrientation.GetVersion(fileVersion));
     523           0 :         m_aVerticalAlignment.Store(rStream, m_aVerticalAlignment.GetVersion(fileVersion));
     524             :     }
     525             : 
     526           0 :     aHorJustify.Store( rStream, aHorJustify.GetVersion(fileVersion) );
     527           0 :     aVerJustify.Store( rStream, aVerJustify.GetVersion(fileVersion) );
     528           0 :     aOrientation.Store( rStream, aOrientation.GetVersion(fileVersion) );
     529           0 :     aMargin.Store( rStream, aMargin.GetVersion(fileVersion) );
     530           0 :     aLinebreak.Store( rStream, aLinebreak.GetVersion(fileVersion) );
     531             :     // Calc Rotation from SO5
     532           0 :     aRotateAngle.Store( rStream, aRotateAngle.GetVersion(fileVersion) );
     533           0 :     aRotateMode.Store( rStream, aRotateMode.GetVersion(fileVersion) );
     534             : 
     535             :     // --- from 680/dr25 on: store strings as UTF-8
     536             :     write_uInt16_lenPrefixed_uInt8s_FromOUString(rStream, sNumFmtString,
     537           0 :         RTL_TEXTENCODING_UTF8);
     538           0 :     rStream.WriteUInt16( eSysLanguage ).WriteUInt16( eNumFmtLanguage );
     539             : 
     540           0 :     return 0 == rStream.GetError();
     541             : }
     542             : 
     543           0 : bool SwBoxAutoFmt::SaveVersionNo( SvStream& rStream, sal_uInt16 fileVersion ) const
     544             : {
     545           0 :     rStream.WriteUInt16( aFont.GetVersion( fileVersion ) );
     546           0 :     rStream.WriteUInt16( aHeight.GetVersion( fileVersion ) );
     547           0 :     rStream.WriteUInt16( aWeight.GetVersion( fileVersion ) );
     548           0 :     rStream.WriteUInt16( aPosture.GetVersion( fileVersion ) );
     549           0 :     rStream.WriteUInt16( aUnderline.GetVersion( fileVersion ) );
     550           0 :     rStream.WriteUInt16( aOverline.GetVersion( fileVersion ) );
     551           0 :     rStream.WriteUInt16( aCrossedOut.GetVersion( fileVersion ) );
     552           0 :     rStream.WriteUInt16( aContour.GetVersion( fileVersion ) );
     553           0 :     rStream.WriteUInt16( aShadowed.GetVersion( fileVersion ) );
     554           0 :     rStream.WriteUInt16( aColor.GetVersion( fileVersion ) );
     555           0 :     rStream.WriteUInt16( aBox.GetVersion( fileVersion ) );
     556           0 :     rStream.WriteUInt16( aTLBR.GetVersion( fileVersion ) );
     557           0 :     rStream.WriteUInt16( aBackground.GetVersion( fileVersion ) );
     558             : 
     559           0 :     rStream.WriteUInt16( aAdjust.GetVersion( fileVersion ) );
     560             : 
     561           0 :     if (fileVersion >= SOFFICE_FILEFORMAT_50)
     562             :     {
     563           0 :         WriterSpecificAutoFormatBlock block(rStream);
     564             : 
     565           0 :         rStream.WriteUInt16( m_aTextOrientation.GetVersion(fileVersion) );
     566           0 :         rStream.WriteUInt16( m_aVerticalAlignment.GetVersion(fileVersion) );
     567             :     }
     568             : 
     569           0 :     rStream.WriteUInt16( aHorJustify.GetVersion( fileVersion ) );
     570           0 :     rStream.WriteUInt16( aVerJustify.GetVersion( fileVersion ) );
     571           0 :     rStream.WriteUInt16( SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0).GetVersion( fileVersion ) );
     572           0 :     rStream.WriteUInt16( aMargin.GetVersion( fileVersion ) );
     573           0 :     rStream.WriteUInt16( aLinebreak.GetVersion( fileVersion ) );
     574           0 :     rStream.WriteUInt16( aRotateAngle.GetVersion( fileVersion ) );
     575           0 :     rStream.WriteUInt16( aRotateMode.GetVersion( fileVersion ) );
     576             : 
     577           0 :     rStream.WriteUInt16( 0 );       // NumberFormat
     578             : 
     579           0 :     return 0 == rStream.GetError();
     580             : }
     581             : 
     582           0 : SwTableAutoFmt::SwTableAutoFmt( const OUString& rName )
     583             :     : m_aName( rName )
     584             :     , nStrResId( USHRT_MAX )
     585             :     , m_aBreak( SVX_BREAK_NONE, RES_BREAK )
     586             :     , m_aKeepWithNextPara( false, RES_KEEP )
     587             :     , m_aRepeatHeading( 0 )
     588             :     , m_bLayoutSplit( true )
     589             :     , m_bRowSplit( true )
     590             :     , m_bCollapsingBorders(true)
     591           0 :     , m_aShadow( RES_SHADOW )
     592             : {
     593           0 :     bInclFont = true;
     594           0 :     bInclJustify = true;
     595           0 :     bInclFrame = true;
     596           0 :     bInclBackground = true;
     597           0 :     bInclValueFormat = true;
     598           0 :     bInclWidthHeight = true;
     599             : 
     600           0 :     memset( aBoxAutoFmt, 0, sizeof( aBoxAutoFmt ) );
     601           0 : }
     602             : 
     603           0 : SwTableAutoFmt::SwTableAutoFmt( const SwTableAutoFmt& rNew )
     604             :     : m_aBreak( rNew.m_aBreak )
     605             :     , m_aKeepWithNextPara( false, RES_KEEP )
     606           0 :     , m_aShadow( RES_SHADOW )
     607             : {
     608           0 :     for( sal_uInt8 n = 0; n < 16; ++n )
     609           0 :         aBoxAutoFmt[ n ] = 0;
     610           0 :     *this = rNew;
     611           0 : }
     612             : 
     613           0 : SwTableAutoFmt& SwTableAutoFmt::operator=( const SwTableAutoFmt& rNew )
     614             : {
     615           0 :     if (&rNew == this)
     616           0 :         return *this;
     617             : 
     618           0 :     for( sal_uInt8 n = 0; n < 16; ++n )
     619             :     {
     620           0 :         if( aBoxAutoFmt[ n ] )
     621           0 :             delete aBoxAutoFmt[ n ];
     622             : 
     623           0 :         SwBoxAutoFmt* pFmt = rNew.aBoxAutoFmt[ n ];
     624           0 :         if( pFmt )      // if is set -> copy
     625           0 :             aBoxAutoFmt[ n ] = new SwBoxAutoFmt( *pFmt );
     626             :         else            // else default
     627           0 :             aBoxAutoFmt[ n ] = 0;
     628             :     }
     629             : 
     630           0 :     m_aName = rNew.m_aName;
     631           0 :     nStrResId = rNew.nStrResId;
     632           0 :     bInclFont = rNew.bInclFont;
     633           0 :     bInclJustify = rNew.bInclJustify;
     634           0 :     bInclFrame = rNew.bInclFrame;
     635           0 :     bInclBackground = rNew.bInclBackground;
     636           0 :     bInclValueFormat = rNew.bInclValueFormat;
     637           0 :     bInclWidthHeight = rNew.bInclWidthHeight;
     638             : 
     639           0 :     m_aBreak = rNew.m_aBreak;
     640           0 :     m_aPageDesc = rNew.m_aPageDesc;
     641           0 :     m_aKeepWithNextPara = rNew.m_aKeepWithNextPara;
     642           0 :     m_aRepeatHeading = rNew.m_aRepeatHeading;
     643           0 :     m_bLayoutSplit = rNew.m_bLayoutSplit;
     644           0 :     m_bRowSplit = rNew.m_bRowSplit;
     645           0 :     m_bCollapsingBorders = rNew.m_bCollapsingBorders;
     646           0 :     m_aShadow = rNew.m_aShadow;
     647             : 
     648           0 :     return *this;
     649             : }
     650             : 
     651           0 : SwTableAutoFmt::~SwTableAutoFmt()
     652             : {
     653           0 :     SwBoxAutoFmt** ppFmt = aBoxAutoFmt;
     654           0 :     for( sal_uInt8 n = 0; n < 16; ++n, ++ppFmt )
     655           0 :         if( *ppFmt )
     656           0 :             delete *ppFmt;
     657           0 : }
     658             : 
     659           0 : void SwTableAutoFmt::SetBoxFmt( const SwBoxAutoFmt& rNew, sal_uInt8 nPos )
     660             : {
     661             :     OSL_ENSURE( nPos < 16, "wrong area" );
     662             : 
     663           0 :     SwBoxAutoFmt* pFmt = aBoxAutoFmt[ nPos ];
     664           0 :     if( pFmt )      // if is set -> copy
     665           0 :         *aBoxAutoFmt[ nPos ] = rNew;
     666             :     else            // else set anew
     667           0 :         aBoxAutoFmt[ nPos ] = new SwBoxAutoFmt( rNew );
     668           0 : }
     669             : 
     670           0 : const SwBoxAutoFmt& SwTableAutoFmt::GetBoxFmt( sal_uInt8 nPos ) const
     671             : {
     672             :     OSL_ENSURE( nPos < 16, "wrong area" );
     673             : 
     674           0 :     SwBoxAutoFmt* pFmt = aBoxAutoFmt[ nPos ];
     675           0 :     if( pFmt )      // if is set -> copy
     676           0 :         return *pFmt;
     677             :     else            // else return the default
     678             :     {
     679             :         // If it doesn't exist yet:
     680           0 :         if( !pDfltBoxAutoFmt )
     681           0 :             pDfltBoxAutoFmt = new SwBoxAutoFmt;
     682           0 :         return *pDfltBoxAutoFmt;
     683             :     }
     684             : }
     685             : 
     686           0 : void SwTableAutoFmt::UpdateFromSet( sal_uInt8 nPos,
     687             :                                     const SfxItemSet& rSet,
     688             :                                     UpdateFlags eFlags,
     689             :                                     SvNumberFormatter* pNFmtr)
     690             : {
     691             :     OSL_ENSURE( nPos < 16, "wrong area" );
     692             : 
     693           0 :     SwBoxAutoFmt* pFmt = aBoxAutoFmt[ nPos ];
     694           0 :     if( !pFmt )     // if is set -> copy
     695             :     {
     696           0 :         pFmt = new SwBoxAutoFmt;
     697           0 :         aBoxAutoFmt[ nPos ] = pFmt;
     698             :     }
     699             : 
     700           0 :     if( UPDATE_CHAR & eFlags )
     701             :     {
     702           0 :         pFmt->SetFont( (SvxFontItem&)rSet.Get( RES_CHRATR_FONT ) );
     703           0 :         pFmt->SetHeight( (SvxFontHeightItem&)rSet.Get( RES_CHRATR_FONTSIZE ) );
     704           0 :         pFmt->SetWeight( (SvxWeightItem&)rSet.Get( RES_CHRATR_WEIGHT ) );
     705           0 :         pFmt->SetPosture( (SvxPostureItem&)rSet.Get( RES_CHRATR_POSTURE ) );
     706           0 :         pFmt->SetCJKFont( (SvxFontItem&)rSet.Get( RES_CHRATR_CJK_FONT ) );
     707           0 :         pFmt->SetCJKHeight( (SvxFontHeightItem&)rSet.Get( RES_CHRATR_CJK_FONTSIZE ) );
     708           0 :         pFmt->SetCJKWeight( (SvxWeightItem&)rSet.Get( RES_CHRATR_CJK_WEIGHT ) );
     709           0 :         pFmt->SetCJKPosture( (SvxPostureItem&)rSet.Get( RES_CHRATR_CJK_POSTURE ) );
     710           0 :         pFmt->SetCTLFont( (SvxFontItem&)rSet.Get( RES_CHRATR_CTL_FONT ) );
     711           0 :         pFmt->SetCTLHeight( (SvxFontHeightItem&)rSet.Get( RES_CHRATR_CTL_FONTSIZE ) );
     712           0 :         pFmt->SetCTLWeight( (SvxWeightItem&)rSet.Get( RES_CHRATR_CTL_WEIGHT ) );
     713           0 :         pFmt->SetCTLPosture( (SvxPostureItem&)rSet.Get( RES_CHRATR_CTL_POSTURE ) );
     714           0 :         pFmt->SetUnderline( (SvxUnderlineItem&)rSet.Get( RES_CHRATR_UNDERLINE ) );
     715           0 :         pFmt->SetOverline( (SvxOverlineItem&)rSet.Get( RES_CHRATR_OVERLINE ) );
     716           0 :         pFmt->SetCrossedOut( (SvxCrossedOutItem&)rSet.Get( RES_CHRATR_CROSSEDOUT ) );
     717           0 :         pFmt->SetContour( (SvxContourItem&)rSet.Get( RES_CHRATR_CONTOUR ) );
     718           0 :         pFmt->SetShadowed( (SvxShadowedItem&)rSet.Get( RES_CHRATR_SHADOWED ) );
     719           0 :         pFmt->SetColor( (SvxColorItem&)rSet.Get( RES_CHRATR_COLOR ) );
     720           0 :         pFmt->SetAdjust( (SvxAdjustItem&)rSet.Get( RES_PARATR_ADJUST ) );
     721             :     }
     722           0 :     if( UPDATE_BOX & eFlags )
     723             :     {
     724           0 :         pFmt->SetBox( (SvxBoxItem&)rSet.Get( RES_BOX ) );
     725             : // FIXME - add attribute IDs for the diagonal line items
     726             : //        pFmt->SetTLBR( (SvxLineItem&)rSet.Get( RES_... ) );
     727             : //        pFmt->SetBLTR( (SvxLineItem&)rSet.Get( RES_... ) );
     728           0 :         pFmt->SetBackground( (SvxBrushItem&)rSet.Get( RES_BACKGROUND ) );
     729           0 :         pFmt->SetTextOrientation(static_cast<const SvxFrameDirectionItem&>(rSet.Get(RES_FRAMEDIR)));
     730           0 :         pFmt->SetVerticalAlignment(static_cast<const SwFmtVertOrient&>(rSet.Get(RES_VERT_ORIENT)));
     731             : 
     732             :         const SwTblBoxNumFormat* pNumFmtItem;
     733           0 :         const SvNumberformat* pNumFormat = 0;
     734           0 :         if( SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMAT, true,
     735           0 :             (const SfxPoolItem**)&pNumFmtItem ) && pNFmtr &&
     736           0 :             0 != (pNumFormat = pNFmtr->GetEntry( pNumFmtItem->GetValue() )) )
     737           0 :             pFmt->SetValueFormat( ((SvNumberformat*)pNumFormat)->GetFormatstring(),
     738           0 :                                     pNumFormat->GetLanguage(),
     739           0 :                                     ::GetAppLanguage());
     740             :         else
     741             :         {
     742             :             // default
     743             :             pFmt->SetValueFormat( OUString(), LANGUAGE_SYSTEM,
     744           0 :                                   ::GetAppLanguage() );
     745             :         }
     746             :     }
     747             : 
     748             :     // we cannot handle the rest, that's specific to StarCalc
     749           0 : }
     750             : 
     751           0 : void SwTableAutoFmt::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet,
     752             :                                  UpdateFlags eFlags, SvNumberFormatter* pNFmtr) const
     753             : {
     754           0 :     const SwBoxAutoFmt& rChg = GetBoxFmt( nPos );
     755             : 
     756           0 :     if( UPDATE_CHAR & eFlags )
     757             :     {
     758           0 :         if( IsFont() )
     759             :         {
     760           0 :             rSet.Put( rChg.GetFont() );
     761           0 :             rSet.Put( rChg.GetHeight() );
     762           0 :             rSet.Put( rChg.GetWeight() );
     763           0 :             rSet.Put( rChg.GetPosture() );
     764             :             // do not insert empty CJK font
     765           0 :             const SvxFontItem& rCJKFont = rChg.GetCJKFont();
     766           0 :             if (!rCJKFont.GetStyleName().isEmpty())
     767             :             {
     768           0 :                 rSet.Put( rChg.GetCJKFont() );
     769           0 :                 rSet.Put( rChg.GetCJKHeight() );
     770           0 :                 rSet.Put( rChg.GetCJKWeight() );
     771           0 :                 rSet.Put( rChg.GetCJKPosture() );
     772             :             }
     773             :             else
     774             :             {
     775           0 :                 rSet.Put( rChg.GetHeight(), RES_CHRATR_CJK_FONTSIZE );
     776           0 :                 rSet.Put( rChg.GetWeight(), RES_CHRATR_CJK_WEIGHT );
     777           0 :                 rSet.Put( rChg.GetPosture(), RES_CHRATR_CJK_POSTURE );
     778             :             }
     779             :             // do not insert empty CTL font
     780           0 :             const SvxFontItem& rCTLFont = rChg.GetCTLFont();
     781           0 :             if (!rCTLFont.GetStyleName().isEmpty())
     782             :             {
     783           0 :                 rSet.Put( rChg.GetCTLFont() );
     784           0 :                 rSet.Put( rChg.GetCTLHeight() );
     785           0 :                 rSet.Put( rChg.GetCTLWeight() );
     786           0 :                 rSet.Put( rChg.GetCTLPosture() );
     787             :             }
     788             :             else
     789             :             {
     790           0 :                 rSet.Put( rChg.GetHeight(), RES_CHRATR_CTL_FONTSIZE );
     791           0 :                 rSet.Put( rChg.GetWeight(), RES_CHRATR_CTL_WEIGHT );
     792           0 :                 rSet.Put( rChg.GetPosture(), RES_CHRATR_CTL_POSTURE );
     793             :             }
     794           0 :             rSet.Put( rChg.GetUnderline() );
     795           0 :             rSet.Put( rChg.GetOverline() );
     796           0 :             rSet.Put( rChg.GetCrossedOut() );
     797           0 :             rSet.Put( rChg.GetContour() );
     798           0 :             rSet.Put( rChg.GetShadowed() );
     799           0 :             rSet.Put( rChg.GetColor() );
     800             :         }
     801           0 :         if( IsJustify() )
     802           0 :             rSet.Put( rChg.GetAdjust() );
     803             :     }
     804             : 
     805           0 :     if( UPDATE_BOX & eFlags )
     806             :     {
     807           0 :         if( IsFrame() )
     808             :         {
     809           0 :             rSet.Put( rChg.GetBox() );
     810             : // FIXME - uncomment the lines to put the diagonal line items
     811             : //            rSet.Put( rChg.GetTLBR() );
     812             : //            rSet.Put( rChg.GetBLTR() );
     813             :         }
     814           0 :         if( IsBackground() )
     815           0 :             rSet.Put( rChg.GetBackground() );
     816             : 
     817           0 :         rSet.Put(rChg.GetTextOrientation());
     818           0 :         rSet.Put(rChg.GetVerticalAlignment());
     819             : 
     820           0 :         if( IsValueFormat() && pNFmtr )
     821             :         {
     822           0 :             OUString sFmt;
     823             :             LanguageType eLng, eSys;
     824           0 :             rChg.GetValueFormat( sFmt, eLng, eSys );
     825           0 :             if( !sFmt.isEmpty() )
     826             :             {
     827             :                 short nType;
     828             :                 bool bNew;
     829             :                 sal_Int32 nCheckPos;
     830             :                 sal_uInt32 nKey = pNFmtr->GetIndexPuttingAndConverting( sFmt, eLng,
     831           0 :                                                                         eSys, nType, bNew, nCheckPos);
     832           0 :                 rSet.Put( SwTblBoxNumFormat( nKey ));
     833             :             }
     834             :             else
     835           0 :                 rSet.ClearItem( RES_BOXATR_FORMAT );
     836             :         }
     837             :     }
     838             : 
     839             :     // we cannot handle the rest, that's specific to StarCalc
     840           0 : }
     841             : 
     842           0 : void SwTableAutoFmt::RestoreTableProperties(SwTable &table) const
     843             : {
     844           0 :     SwTableFmt *pFormat = table.GetTableFmt();
     845           0 :     if (!pFormat)
     846           0 :         return;
     847             : 
     848           0 :     SwDoc *pDoc = pFormat->GetDoc();
     849           0 :     if (!pDoc)
     850           0 :         return;
     851             : 
     852           0 :     SfxItemSet rSet(pDoc->GetAttrPool(), aTableSetRange);
     853             : 
     854           0 :     rSet.Put(m_aBreak);
     855           0 :     rSet.Put(m_aPageDesc);
     856           0 :     rSet.Put(SwFmtLayoutSplit(m_bLayoutSplit));
     857           0 :     rSet.Put(SfxBoolItem(RES_COLLAPSING_BORDERS, m_bCollapsingBorders));
     858           0 :     rSet.Put(m_aKeepWithNextPara);
     859           0 :     rSet.Put(m_aShadow);
     860             : 
     861           0 :     pFormat->SetFmtAttr(rSet);
     862             : 
     863           0 :     SwEditShell *pShell = pDoc->GetEditShell();
     864           0 :     pDoc->SetRowSplit(*pShell->getShellCrsr(false), SwFmtRowSplit(m_bRowSplit));
     865             : 
     866           0 :     table.SetRowsToRepeat(m_aRepeatHeading);
     867             : }
     868             : 
     869           0 : void SwTableAutoFmt::StoreTableProperties(const SwTable &table)
     870             : {
     871           0 :     SwTableFmt *pFormat = table.GetTableFmt();
     872           0 :     if (!pFormat)
     873           0 :         return;
     874             : 
     875           0 :     SwDoc *pDoc = pFormat->GetDoc();
     876           0 :     if (!pDoc)
     877           0 :         return;
     878             : 
     879           0 :     SwEditShell *pShell = pDoc->GetEditShell();
     880           0 :     SwFmtRowSplit *pRowSplit = 0;
     881           0 :     pDoc->GetRowSplit(*pShell->getShellCrsr(false), pRowSplit);
     882           0 :     m_bRowSplit = pRowSplit ? pRowSplit->GetValue() : sal_False;
     883           0 :     delete pRowSplit;
     884           0 :     pRowSplit = 0;
     885             : 
     886           0 :     const SfxItemSet &rSet = pFormat->GetAttrSet();
     887             : 
     888           0 :     m_aBreak = static_cast<const SvxFmtBreakItem&>(rSet.Get(RES_BREAK));
     889           0 :     m_aPageDesc = static_cast<const SwFmtPageDesc&>(rSet.Get(RES_PAGEDESC));
     890           0 :     const SwFmtLayoutSplit &layoutSplit = static_cast<const SwFmtLayoutSplit&>(rSet.Get(RES_LAYOUT_SPLIT));
     891           0 :     m_bLayoutSplit = layoutSplit.GetValue();
     892           0 :     m_bCollapsingBorders = static_cast<const SfxBoolItem&>(rSet.Get(RES_COLLAPSING_BORDERS)).GetValue();
     893             : 
     894           0 :     m_aKeepWithNextPara = static_cast<const SvxFmtKeepItem&>(rSet.Get(RES_KEEP));
     895           0 :     m_aRepeatHeading = table.GetRowsToRepeat();
     896           0 :     m_aShadow = static_cast<const SvxShadowItem&>(rSet.Get(RES_SHADOW));
     897             : }
     898             : 
     899           0 : bool SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions )
     900             : {
     901           0 :     sal_uInt16  nVal = 0;
     902           0 :     rStream.ReadUInt16( nVal );
     903           0 :     bool bRet = 0 == rStream.GetError();
     904             : 
     905           0 :     if( bRet && (nVal == AUTOFORMAT_DATA_ID_X ||
     906           0 :             (AUTOFORMAT_DATA_ID_504 <= nVal && nVal <= AUTOFORMAT_DATA_ID)) )
     907             :     {
     908             :         bool b;
     909             :         // --- from 680/dr25 on: store strings as UTF-8
     910           0 :         rtl_TextEncoding eCharSet = (nVal >= AUTOFORMAT_ID_680DR25) ? RTL_TEXTENCODING_UTF8 : rStream.GetStreamCharSet();
     911           0 :         m_aName = rStream.ReadUniOrByteString( eCharSet );
     912           0 :         if( AUTOFORMAT_DATA_ID_552 <= nVal )
     913             :         {
     914           0 :             rStream.ReadUInt16( nStrResId );
     915           0 :             sal_uInt16 nId = RID_SVXSTR_TBLAFMT_BEGIN + nStrResId;
     916           0 :             if( RID_SVXSTR_TBLAFMT_BEGIN <= nId &&
     917             :                 nId < RID_SVXSTR_TBLAFMT_END )
     918             :             {
     919           0 :                 m_aName = SVX_RESSTR( nId );
     920             :             }
     921             :             else
     922           0 :                 nStrResId = USHRT_MAX;
     923             :         }
     924           0 :         rStream.ReadCharAsBool( b ); bInclFont = b;
     925           0 :         rStream.ReadCharAsBool( b ); bInclJustify = b;
     926           0 :         rStream.ReadCharAsBool( b ); bInclFrame = b;
     927           0 :         rStream.ReadCharAsBool( b ); bInclBackground = b;
     928           0 :         rStream.ReadCharAsBool( b ); bInclValueFormat = b;
     929           0 :         rStream.ReadCharAsBool( b ); bInclWidthHeight = b;
     930             : 
     931           0 :         if (nVal >= AUTOFORMAT_DATA_ID_31005 && WriterSpecificBlockExists(rStream))
     932             :         {
     933           0 :             SfxPoolItem* pNew = 0;
     934             : 
     935           0 :             READ(m_aBreak, SvxFmtBreakItem, AUTOFORMAT_FILE_VERSION);
     936           0 :             READ(m_aPageDesc, SwFmtPageDesc, AUTOFORMAT_FILE_VERSION);
     937           0 :             READ(m_aKeepWithNextPara, SvxFmtKeepItem, AUTOFORMAT_FILE_VERSION);
     938             : 
     939           0 :             rStream.ReadUInt16( m_aRepeatHeading ).ReadCharAsBool( m_bLayoutSplit ).ReadCharAsBool( m_bRowSplit ).ReadCharAsBool( m_bCollapsingBorders );
     940             : 
     941           0 :             READ(m_aShadow, SvxShadowItem, AUTOFORMAT_FILE_VERSION);
     942             :         }
     943             : 
     944           0 :         bRet = 0 == rStream.GetError();
     945             : 
     946           0 :         for( sal_uInt8 i = 0; bRet && i < 16; ++i )
     947             :         {
     948           0 :             SwBoxAutoFmt* pFmt = new SwBoxAutoFmt;
     949           0 :             bRet = pFmt->Load( rStream, rVersions, nVal );
     950           0 :             if( bRet )
     951           0 :                 aBoxAutoFmt[ i ] = pFmt;
     952             :             else
     953             :             {
     954           0 :                 delete pFmt;
     955           0 :                 break;
     956             :             }
     957             :         }
     958             :     }
     959           0 :     return bRet;
     960             : }
     961             : 
     962           0 : bool SwTableAutoFmt::Save( SvStream& rStream, sal_uInt16 fileVersion ) const
     963             : {
     964           0 :     sal_uInt16 nVal = AUTOFORMAT_DATA_ID;
     965             :     bool b;
     966           0 :     rStream.WriteUInt16( nVal );
     967             :     // --- from 680/dr25 on: store strings as UTF-8
     968             :     write_uInt16_lenPrefixed_uInt8s_FromOUString(rStream, m_aName,
     969           0 :         RTL_TEXTENCODING_UTF8 );
     970           0 :     rStream.WriteUInt16( nStrResId );
     971           0 :     rStream.WriteUChar( ( b = bInclFont ) );
     972           0 :     rStream.WriteUChar( ( b = bInclJustify ) );
     973           0 :     rStream.WriteUChar( ( b = bInclFrame ) );
     974           0 :     rStream.WriteUChar( ( b = bInclBackground ) );
     975           0 :     rStream.WriteUChar( ( b = bInclValueFormat ) );
     976           0 :     rStream.WriteUChar( ( b = bInclWidthHeight ) );
     977             : 
     978             :     {
     979           0 :         WriterSpecificAutoFormatBlock block(rStream);
     980             : 
     981           0 :         m_aBreak.Store(rStream, m_aBreak.GetVersion(fileVersion));
     982           0 :         m_aPageDesc.Store(rStream, m_aPageDesc.GetVersion(fileVersion));
     983           0 :         m_aKeepWithNextPara.Store(rStream, m_aKeepWithNextPara.GetVersion(fileVersion));
     984           0 :         rStream.WriteUInt16( m_aRepeatHeading ).WriteUChar( m_bLayoutSplit ).WriteUChar( m_bRowSplit ).WriteUChar( m_bCollapsingBorders );
     985           0 :         m_aShadow.Store(rStream, m_aShadow.GetVersion(fileVersion));
     986             :     }
     987             : 
     988           0 :     bool bRet = 0 == rStream.GetError();
     989             : 
     990           0 :     for( int i = 0; bRet && i < 16; ++i )
     991             :     {
     992           0 :         SwBoxAutoFmt* pFmt = aBoxAutoFmt[ i ];
     993           0 :         if( !pFmt )     // if not set -> write default
     994             :         {
     995             :             // If it doesn't exist yet:
     996           0 :             if( !pDfltBoxAutoFmt )
     997           0 :                 pDfltBoxAutoFmt = new SwBoxAutoFmt;
     998           0 :             pFmt = pDfltBoxAutoFmt;
     999             :         }
    1000           0 :         bRet = pFmt->Save( rStream, fileVersion );
    1001             :     }
    1002           0 :     return bRet;
    1003             : }
    1004             : 
    1005           0 : struct SwTableAutoFmtTbl::Impl
    1006             : {
    1007             :     boost::ptr_vector<SwTableAutoFmt> m_AutoFormats;
    1008             : };
    1009             : 
    1010           0 : size_t SwTableAutoFmtTbl::size() const
    1011             : {
    1012           0 :     return m_pImpl->m_AutoFormats.size();
    1013             : }
    1014             : 
    1015           0 : SwTableAutoFmt const& SwTableAutoFmtTbl::operator[](size_t const i) const
    1016             : {
    1017           0 :     return m_pImpl->m_AutoFormats[i];
    1018             : }
    1019           0 : SwTableAutoFmt      & SwTableAutoFmtTbl::operator[](size_t const i)
    1020             : {
    1021           0 :     return m_pImpl->m_AutoFormats[i];
    1022             : }
    1023             : 
    1024             : void
    1025           0 : SwTableAutoFmtTbl::InsertAutoFmt(size_t const i, SwTableAutoFmt *const pFmt)
    1026             : {
    1027           0 :     m_pImpl->m_AutoFormats.insert(m_pImpl->m_AutoFormats.begin() + i, pFmt);
    1028           0 : }
    1029             : 
    1030           0 : void SwTableAutoFmtTbl::EraseAutoFmt(size_t const i)
    1031             : {
    1032           0 :     m_pImpl->m_AutoFormats.erase(m_pImpl->m_AutoFormats.begin() + i);
    1033           0 : }
    1034             : 
    1035           0 : SwTableAutoFmt* SwTableAutoFmtTbl::ReleaseAutoFmt(size_t const i)
    1036             : {
    1037           0 :     return m_pImpl->m_AutoFormats.release(m_pImpl->m_AutoFormats.begin() + i).release();
    1038             : }
    1039             : 
    1040           0 : SwTableAutoFmtTbl::~SwTableAutoFmtTbl()
    1041             : {
    1042           0 : }
    1043             : 
    1044           0 : SwTableAutoFmtTbl::SwTableAutoFmtTbl()
    1045           0 :     : m_pImpl(new Impl)
    1046             : {
    1047           0 :     OUString sNm;
    1048             :     SwTableAutoFmt* pNew = new SwTableAutoFmt(
    1049           0 :                             SwStyleNameMapper::GetUIName( RES_POOLCOLL_STANDARD, sNm ) );
    1050             : 
    1051           0 :     SwBoxAutoFmt aNew;
    1052             : 
    1053             :     sal_uInt8 i;
    1054             : 
    1055           0 :     Color aColor( COL_BLUE );
    1056           0 :     SvxBrushItem aBrushItem( aColor, RES_BACKGROUND );
    1057           0 :     aNew.SetBackground( aBrushItem );
    1058           0 :     aNew.SetColor( SvxColorItem(Color( COL_WHITE ), RES_CHRATR_COLOR) );
    1059             : 
    1060           0 :     for( i = 0; i < 4; ++i )
    1061           0 :         pNew->SetBoxFmt( aNew, i );
    1062             : 
    1063             :     // 70% gray
    1064           0 :     aBrushItem.SetColor( RGB_COLORDATA( 0x4d, 0x4d, 0x4d ) );
    1065           0 :     aNew.SetBackground( aBrushItem );
    1066           0 :     for( i = 4; i <= 12; i += 4 )
    1067           0 :         pNew->SetBoxFmt( aNew, i );
    1068             : 
    1069             :     // 20% gray
    1070           0 :     aBrushItem.SetColor( RGB_COLORDATA( 0xcc, 0xcc, 0xcc ) );
    1071           0 :     aNew.SetBackground( aBrushItem );
    1072           0 :     aColor.SetColor( COL_BLACK );
    1073           0 :     aNew.SetColor( SvxColorItem( aColor, RES_CHRATR_COLOR) );
    1074           0 :     for( i = 7; i <= 15; i += 4 )
    1075           0 :         pNew->SetBoxFmt( aNew, i );
    1076           0 :     for( i = 13; i <= 14; ++i )
    1077           0 :         pNew->SetBoxFmt( aNew, i );
    1078             : 
    1079           0 :     aBrushItem.SetColor( Color( COL_WHITE ) );
    1080           0 :     aNew.SetBackground( aBrushItem );
    1081           0 :     for( i = 5; i <= 6; ++i )
    1082           0 :         pNew->SetBoxFmt( aNew, i );
    1083           0 :     for( i = 9; i <= 10; ++i )
    1084           0 :         pNew->SetBoxFmt( aNew, i );
    1085             : 
    1086           0 :     SvxBoxItem aBox( RES_BOX );
    1087           0 :     aBox.SetDistance( 55 );
    1088           0 :     SvxBorderLine aLn( &aColor, DEF_LINE_WIDTH_0 );
    1089           0 :     aBox.SetLine( &aLn, BOX_LINE_LEFT );
    1090           0 :     aBox.SetLine( &aLn, BOX_LINE_BOTTOM );
    1091             : 
    1092           0 :     for( i = 0; i <= 15; ++i )
    1093             :     {
    1094           0 :         aBox.SetLine( i <= 3 ? &aLn : 0, BOX_LINE_TOP );
    1095           0 :         aBox.SetLine( (3 == ( i & 3 )) ? &aLn : 0, BOX_LINE_RIGHT );
    1096           0 :         ((SwBoxAutoFmt&)pNew->GetBoxFmt( i )).SetBox( aBox );
    1097             :     }
    1098             : 
    1099           0 :     m_pImpl->m_AutoFormats.push_back(pNew);
    1100           0 : }
    1101             : 
    1102           0 : bool SwTableAutoFmtTbl::Load()
    1103             : {
    1104           0 :     bool bRet = false;
    1105           0 :     OUString sNm(AUTOTABLE_FORMAT_NAME);
    1106           0 :     SvtPathOptions aOpt;
    1107           0 :     if( aOpt.SearchFile( sNm, SvtPathOptions::PATH_USERCONFIG ))
    1108             :     {
    1109           0 :         SfxMedium aStream( sNm, STREAM_STD_READ );
    1110           0 :         bRet = Load( *aStream.GetInStream() );
    1111             :     }
    1112             :     else
    1113           0 :         bRet = false;
    1114           0 :     return bRet;
    1115             : }
    1116             : 
    1117           0 : bool SwTableAutoFmtTbl::Save() const
    1118             : {
    1119           0 :     SvtPathOptions aPathOpt;
    1120           0 :     const OUString sNm( aPathOpt.GetUserConfigPath() + "/" AUTOTABLE_FORMAT_NAME );
    1121           0 :     SfxMedium aStream(sNm, STREAM_STD_WRITE );
    1122           0 :     return Save( *aStream.GetOutStream() ) && aStream.Commit();
    1123             : }
    1124             : 
    1125           0 : bool SwTableAutoFmtTbl::Load( SvStream& rStream )
    1126             : {
    1127           0 :     bool bRet = 0 == rStream.GetError();
    1128           0 :     if (bRet)
    1129             :     {
    1130             :         // Attention: We need to read a general Header here
    1131           0 :         sal_uInt16 nVal = 0;
    1132           0 :         rStream.ReadUInt16( nVal );
    1133           0 :         bRet = 0 == rStream.GetError();
    1134             : 
    1135           0 :         if( bRet )
    1136             :         {
    1137           0 :             SwAfVersions aVersions;
    1138             : 
    1139             :             // Default version is 5.0, unless we detect an old format ID.
    1140           0 :             sal_uInt16 nFileVers = SOFFICE_FILEFORMAT_50;
    1141           0 :             if(nVal < AUTOFORMAT_ID_31005)
    1142           0 :                 nFileVers = SOFFICE_FILEFORMAT_40;
    1143             : 
    1144           0 :             if( nVal == AUTOFORMAT_ID_358 ||
    1145           0 :                     (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
    1146             :             {
    1147             :                 sal_uInt8 nChrSet, nCnt;
    1148           0 :                 long nPos = rStream.Tell();
    1149           0 :                 rStream.ReadUChar( nCnt ).ReadUChar( nChrSet );
    1150           0 :                 if( rStream.Tell() != sal_uLong(nPos + nCnt) )
    1151             :                 {
    1152             :                     OSL_ENSURE( false, "The Header contains more or newer Data" );
    1153           0 :                     rStream.Seek( nPos + nCnt );
    1154             :                 }
    1155           0 :                 rStream.SetStreamCharSet( (rtl_TextEncoding)nChrSet );
    1156           0 :                 rStream.SetVersion( nFileVers );
    1157             :             }
    1158             : 
    1159           0 :             if( nVal == AUTOFORMAT_ID_358 || nVal == AUTOFORMAT_ID_X ||
    1160           0 :                     (AUTOFORMAT_ID_504 <= nVal && nVal <= AUTOFORMAT_ID) )
    1161             :             {
    1162           0 :                 aVersions.Load( rStream, nVal );        // Item versions
    1163             : 
    1164             :                 SwTableAutoFmt* pNew;
    1165           0 :                 sal_uInt16 nAnz = 0;
    1166           0 :                 rStream.ReadUInt16( nAnz );
    1167             : 
    1168           0 :                 bRet = 0 == rStream.GetError();
    1169             : 
    1170           0 :                 for( sal_uInt16 i = 0; i < nAnz; ++i )
    1171             :                 {
    1172           0 :                     pNew = new SwTableAutoFmt( OUString() );
    1173           0 :                     bRet = pNew->Load( rStream, aVersions );
    1174           0 :                     if( bRet )
    1175             :                     {
    1176           0 :                         m_pImpl->m_AutoFormats.push_back(pNew);
    1177             :                     }
    1178             :                     else
    1179             :                     {
    1180           0 :                         delete pNew;
    1181           0 :                         break;
    1182             :                     }
    1183           0 :                 }
    1184             :             }
    1185             :             else
    1186             :             {
    1187           0 :                 bRet = false;
    1188             :             }
    1189             :         }
    1190             :     }
    1191           0 :     return bRet;
    1192             : }
    1193             : 
    1194           0 : bool SwTableAutoFmtTbl::Save( SvStream& rStream ) const
    1195             : {
    1196           0 :     bool bRet = 0 == rStream.GetError();
    1197           0 :     if (bRet)
    1198             :     {
    1199           0 :         rStream.SetVersion(AUTOFORMAT_FILE_VERSION);
    1200             : 
    1201             :         // Attention: We need to save a general Header here
    1202           0 :         sal_uInt16 nVal = AUTOFORMAT_ID;
    1203           0 :         rStream.WriteUInt16( nVal )
    1204           0 :                .WriteUChar( 2 ) // Character count of the Header including this value
    1205           0 :                .WriteUChar( GetStoreCharSet( ::osl_getThreadTextEncoding() ) );
    1206             : 
    1207           0 :         bRet = 0 == rStream.GetError();
    1208           0 :         if (!bRet)
    1209           0 :             return false;
    1210             : 
    1211             :         // Write this version number for all attributes
    1212           0 :         m_pImpl->m_AutoFormats[0].GetBoxFmt(0).SaveVersionNo(
    1213           0 :                 rStream, AUTOFORMAT_FILE_VERSION);
    1214             : 
    1215           0 :         rStream.WriteUInt16( m_pImpl->m_AutoFormats.size() - 1 );
    1216           0 :         bRet = 0 == rStream.GetError();
    1217             : 
    1218           0 :         for (sal_uInt16 i = 1; bRet && i < m_pImpl->m_AutoFormats.size(); ++i)
    1219             :         {
    1220           0 :             SwTableAutoFmt const& rFmt = m_pImpl->m_AutoFormats[i];
    1221           0 :             bRet = rFmt.Save(rStream, AUTOFORMAT_FILE_VERSION);
    1222             :         }
    1223             :     }
    1224           0 :     rStream.Flush();
    1225           0 :     return bRet;
    1226         270 : }
    1227             : 
    1228             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10