LCOV - code coverage report
Current view: top level - sc/source/filter/starcalc - scflt.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 1498 0.1 %
Date: 2014-04-11 Functions: 2 64 3.1 %
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 "scitems.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : 
      23             : #include <svx/algitem.hxx>
      24             : #include <editeng/boxitem.hxx>
      25             : #include <editeng/brushitem.hxx>
      26             : #include <editeng/colritem.hxx>
      27             : #include <editeng/crossedoutitem.hxx>
      28             : #include <editeng/editdata.hxx>
      29             : #include <editeng/editeng.hxx>
      30             : #include <editeng/editobj.hxx>
      31             : #include <editeng/fhgtitem.hxx>
      32             : #include <editeng/fontitem.hxx>
      33             : #include <editeng/lrspitem.hxx>
      34             : #include <svx/pageitem.hxx>
      35             : #include <editeng/postitem.hxx>
      36             : #include <editeng/sizeitem.hxx>
      37             : #include <editeng/udlnitem.hxx>
      38             : #include <editeng/ulspitem.hxx>
      39             : #include <editeng/wghtitem.hxx>
      40             : #include <editeng/justifyitem.hxx>
      41             : #include <svl/zforlist.hxx>
      42             : #include <svl/PasswordHelper.hxx>
      43             : #include <cassert>
      44             : #include <stdio.h>
      45             : #include <math.h>
      46             : #include <string.h>
      47             : 
      48             : #include "global.hxx"
      49             : #include "sc.hrc"
      50             : #include "attrib.hxx"
      51             : #include "patattr.hxx"
      52             : #include "docpool.hxx"
      53             : #include "document.hxx"
      54             : #include "collect.hxx"
      55             : #include "rangenam.hxx"
      56             : #include "dbdata.hxx"
      57             : #include "stlsheet.hxx"
      58             : #include "stlpool.hxx"
      59             : #include "filter.hxx"
      60             : #include "scflt.hxx"
      61             : #include "formulacell.hxx"
      62             : #include "scfobj.hxx"
      63             : #include "docoptio.hxx"
      64             : #include "viewopti.hxx"
      65             : #include "postit.hxx"
      66             : #include "globstr.hrc"
      67             : #include "ftools.hxx"
      68             : #include "tabprotection.hxx"
      69             : 
      70             : #include "fprogressbar.hxx"
      71             : #include <boost/scoped_array.hpp>
      72             : 
      73             : using namespace com::sun::star;
      74             : 
      75             : #define DEFCHARSET          RTL_TEXTENCODING_MS_1252
      76             : 
      77             : #define SC10TOSTRING(p)     OUString((p), strlen(p), DEFCHARSET)
      78             : 
      79             : const SCCOL SC10MAXCOL = 255;   // #i85906# don't try to load more columns than there are in the file
      80             : 
      81             : 
      82             : /** Those strings are used with SC10TOSTRING() and strcmp() and such, hence
      83             :     need to be 0-terminated. */
      84           0 : static void lcl_ReadFixedString( SvStream& rStream, void* pData, size_t nLen )
      85             : {
      86           0 :     sal_Char* pBuf = static_cast<sal_Char*>(pData);
      87           0 :     if (!nLen)
      88           0 :         pBuf[0] = 0;
      89             :     else
      90             :     {
      91           0 :         rStream.Read( pBuf, nLen);
      92           0 :         pBuf[nLen-1] = 0;
      93             :     }
      94           0 : }
      95             : 
      96             : 
      97           0 : static void lcl_ReadFileHeader(SvStream& rStream, Sc10FileHeader& rFileHeader)
      98             : {
      99           0 :     lcl_ReadFixedString( rStream, &rFileHeader.CopyRight, sizeof(rFileHeader.CopyRight));
     100           0 :     rStream.ReadUInt16( rFileHeader.Version );
     101           0 :     rStream.Read(&rFileHeader.Reserved, sizeof(rFileHeader.Reserved));
     102           0 : }
     103             : 
     104             : 
     105           0 : static void lcl_ReadTabProtect(SvStream& rStream, Sc10TableProtect& rProtect)
     106             : {
     107           0 :     lcl_ReadFixedString( rStream, &rProtect.PassWord, sizeof(rProtect.PassWord));
     108           0 :     rStream.ReadUInt16( rProtect.Flags );
     109           0 :     rStream.ReadUChar( rProtect.Protect );
     110           0 : }
     111             : 
     112             : 
     113           0 : static void lcl_ReadSheetProtect(SvStream& rStream, Sc10SheetProtect& rProtect)
     114             : {
     115           0 :     lcl_ReadFixedString( rStream, &rProtect.PassWord, sizeof(rProtect.PassWord));
     116           0 :     rStream.ReadUInt16( rProtect.Flags );
     117           0 :     rStream.ReadUChar( rProtect.Protect );
     118           0 : }
     119             : 
     120             : 
     121           0 : static void lcl_ReadRGB(SvStream& rStream, Sc10Color& rColor)
     122             : {
     123           0 :     rStream.ReadUChar( rColor.Dummy );
     124           0 :     rStream.ReadUChar( rColor.Blue );
     125           0 :     rStream.ReadUChar( rColor.Green );
     126           0 :     rStream.ReadUChar( rColor.Red );
     127           0 : }
     128             : 
     129             : 
     130           0 : static void lcl_ReadPalette(SvStream& rStream, Sc10Color* pPalette)
     131             : {
     132           0 :     for (sal_uInt16 i = 0; i < 16; i++)
     133           0 :         lcl_ReadRGB(rStream, pPalette[i]);
     134           0 : }
     135             : 
     136             : 
     137           0 : static void lcl_ReadValueFormat(SvStream& rStream, Sc10ValueFormat& rFormat)
     138             : {
     139           0 :     rStream.ReadUChar( rFormat.Format );
     140           0 :     rStream.ReadUChar( rFormat.Info );
     141           0 : }
     142             : 
     143             : 
     144           0 : static void lcl_ReadLogFont(SvStream& rStream, Sc10LogFont& rFont)
     145             : {
     146           0 :     rStream.ReadInt16( rFont.lfHeight );
     147           0 :     rStream.ReadInt16( rFont.lfWidth );
     148           0 :     rStream.ReadInt16( rFont.lfEscapement );
     149           0 :     rStream.ReadInt16( rFont.lfOrientation );
     150           0 :     rStream.ReadInt16( rFont.lfWeight );
     151           0 :     rStream.ReadUChar( rFont.lfItalic );
     152           0 :     rStream.ReadUChar( rFont.lfUnderline );
     153           0 :     rStream.ReadUChar( rFont.lfStrikeOut );
     154           0 :     rStream.ReadUChar( rFont.lfCharSet );
     155           0 :     rStream.ReadUChar( rFont.lfOutPrecision );
     156           0 :     rStream.ReadUChar( rFont.lfClipPrecision );
     157           0 :     rStream.ReadUChar( rFont.lfQuality );
     158           0 :     rStream.ReadUChar( rFont.lfPitchAndFamily );
     159           0 :     lcl_ReadFixedString( rStream, &rFont.lfFaceName, sizeof(rFont.lfFaceName));
     160           0 : }
     161             : 
     162             : 
     163           0 : static void lcl_ReadBlockRect(SvStream& rStream, Sc10BlockRect& rBlock)
     164             : {
     165           0 :     rStream.ReadInt16( rBlock.x1 );
     166           0 :     rStream.ReadInt16( rBlock.y1 );
     167           0 :     rStream.ReadInt16( rBlock.x2 );
     168           0 :     rStream.ReadInt16( rBlock.y2 );
     169           0 : }
     170             : 
     171             : 
     172           0 : static void lcl_ReadHeadFootLine(SvStream& rStream, Sc10HeadFootLine& rLine)
     173             : {
     174           0 :     lcl_ReadFixedString( rStream, &rLine.Title, sizeof(rLine.Title));
     175           0 :     lcl_ReadLogFont(rStream, rLine.LogFont);
     176           0 :     rStream.ReadUChar( rLine.HorJustify );
     177           0 :     rStream.ReadUChar( rLine.VerJustify );
     178           0 :     rStream.ReadUInt16( rLine.Raster );
     179           0 :     rStream.ReadUInt16( rLine.Frame );
     180           0 :     lcl_ReadRGB(rStream, rLine.TextColor);
     181           0 :     lcl_ReadRGB(rStream, rLine.BackColor);
     182           0 :     lcl_ReadRGB(rStream, rLine.RasterColor);
     183           0 :     rStream.ReadUInt16( rLine.FrameColor );
     184           0 :     rStream.ReadUInt16( rLine.Reserved );
     185           0 : }
     186             : 
     187             : 
     188           0 : static void lcl_ReadPageFormat(SvStream& rStream, Sc10PageFormat& rFormat)
     189             : {
     190           0 :     lcl_ReadHeadFootLine(rStream, rFormat.HeadLine);
     191           0 :     lcl_ReadHeadFootLine(rStream, rFormat.FootLine);
     192           0 :     rStream.ReadInt16( rFormat.Orientation );
     193           0 :     rStream.ReadInt16( rFormat.Width );
     194           0 :     rStream.ReadInt16( rFormat.Height );
     195           0 :     rStream.ReadInt16( rFormat.NonPrintableX );
     196           0 :     rStream.ReadInt16( rFormat.NonPrintableY );
     197           0 :     rStream.ReadInt16( rFormat.Left );
     198           0 :     rStream.ReadInt16( rFormat.Top );
     199           0 :     rStream.ReadInt16( rFormat.Right );
     200           0 :     rStream.ReadInt16( rFormat.Bottom );
     201           0 :     rStream.ReadInt16( rFormat.Head );
     202           0 :     rStream.ReadInt16( rFormat.Foot );
     203           0 :     rStream.ReadUChar( rFormat.HorCenter );
     204           0 :     rStream.ReadUChar( rFormat.VerCenter );
     205           0 :     rStream.ReadUChar( rFormat.PrintGrid );
     206           0 :     rStream.ReadUChar( rFormat.PrintColRow );
     207           0 :     rStream.ReadUChar( rFormat.PrintNote );
     208           0 :     rStream.ReadUChar( rFormat.TopBottomDir );
     209           0 :     lcl_ReadFixedString( rStream, &rFormat.PrintAreaName, sizeof(rFormat.PrintAreaName));
     210           0 :     lcl_ReadBlockRect(rStream, rFormat.PrintArea);
     211           0 :     rStream.Read(&rFormat.PrnZoom, sizeof(rFormat.PrnZoom));
     212           0 :     rStream.ReadInt16( rFormat.FirstPageNo );
     213           0 :     rStream.ReadInt16( rFormat.RowRepeatStart );
     214           0 :     rStream.ReadInt16( rFormat.RowRepeatEnd );
     215           0 :     rStream.ReadInt16( rFormat.ColRepeatStart );
     216           0 :     rStream.ReadInt16( rFormat.ColRepeatEnd );
     217           0 :     rStream.Read(&rFormat.Reserved, sizeof(rFormat.Reserved));
     218           0 : }
     219             : 
     220             : 
     221           0 : static void lcl_ReadGraphHeader(SvStream& rStream, Sc10GraphHeader& rHeader)
     222             : {
     223           0 :     rStream.ReadUChar( rHeader.Typ );
     224           0 :     rStream.ReadInt16( rHeader.CarretX );
     225           0 :     rStream.ReadInt16( rHeader.CarretY );
     226           0 :     rStream.ReadInt16( rHeader.CarretZ );
     227           0 :     rStream.ReadInt32( rHeader.x );
     228           0 :     rStream.ReadInt32( rHeader.y );
     229           0 :     rStream.ReadInt32( rHeader.w );
     230           0 :     rStream.ReadInt32( rHeader.h );
     231           0 :     rStream.ReadUChar( rHeader.IsRelPos );
     232           0 :     rStream.ReadUChar( rHeader.DoPrint );
     233           0 :     rStream.ReadUInt16( rHeader.FrameType );
     234           0 :     rStream.ReadUChar( rHeader.IsTransparent );
     235           0 :     lcl_ReadRGB(rStream, rHeader.FrameColor);
     236           0 :     lcl_ReadRGB(rStream, rHeader.BackColor);
     237           0 :     rStream.Read(&rHeader.Reserved, sizeof(rHeader.Reserved));
     238           0 : }
     239             : 
     240             : 
     241           0 : static void lcl_ReadImageHeaer(SvStream& rStream, Sc10ImageHeader& rHeader)
     242             : {
     243           0 :     lcl_ReadFixedString( rStream, &rHeader.FileName, sizeof(rHeader.FileName));
     244           0 :     rStream.ReadInt16( rHeader.Typ );
     245           0 :     rStream.ReadUChar( rHeader.Linked );
     246           0 :     rStream.ReadInt16( rHeader.x1 );
     247           0 :     rStream.ReadInt16( rHeader.y1 );
     248           0 :     rStream.ReadInt16( rHeader.x2 );
     249           0 :     rStream.ReadInt16( rHeader.y2 );
     250           0 :     rStream.ReadUInt32( rHeader.Size );
     251           0 : }
     252             : 
     253             : 
     254           0 : static void lcl_ReadChartHeader(SvStream& rStream, Sc10ChartHeader& rHeader)
     255             : {
     256           0 :     rStream.ReadInt16( rHeader.MM );
     257           0 :     rStream.ReadInt16( rHeader.xExt );
     258           0 :     rStream.ReadInt16( rHeader.yExt );
     259           0 :     rStream.ReadUInt32( rHeader.Size );
     260           0 : }
     261             : 
     262             : 
     263           0 : static void lcl_ReadChartSheetData(SvStream& rStream, Sc10ChartSheetData& rSheetData)
     264             : {
     265           0 :     rStream.ReadUChar( rSheetData.HasTitle );
     266           0 :     rStream.ReadInt16( rSheetData.TitleX );
     267           0 :     rStream.ReadInt16( rSheetData.TitleY );
     268           0 :     rStream.ReadUChar( rSheetData.HasSubTitle );
     269           0 :     rStream.ReadInt16( rSheetData.SubTitleX );
     270           0 :     rStream.ReadInt16( rSheetData.SubTitleY );
     271           0 :     rStream.ReadUChar( rSheetData.HasLeftTitle );
     272           0 :     rStream.ReadInt16( rSheetData.LeftTitleX );
     273           0 :     rStream.ReadInt16( rSheetData.LeftTitleY );
     274           0 :     rStream.ReadUChar( rSheetData.HasLegend );
     275           0 :     rStream.ReadInt16( rSheetData.LegendX1 );
     276           0 :     rStream.ReadInt16( rSheetData.LegendY1 );
     277           0 :     rStream.ReadInt16( rSheetData.LegendX2 );
     278           0 :     rStream.ReadInt16( rSheetData.LegendY2 );
     279           0 :     rStream.ReadUChar( rSheetData.HasLabel );
     280           0 :     rStream.ReadInt16( rSheetData.LabelX1 );
     281           0 :     rStream.ReadInt16( rSheetData.LabelY1 );
     282           0 :     rStream.ReadInt16( rSheetData.LabelX2 );
     283           0 :     rStream.ReadInt16( rSheetData.LabelY2 );
     284           0 :     rStream.ReadInt16( rSheetData.DataX1 );
     285           0 :     rStream.ReadInt16( rSheetData.DataY1 );
     286           0 :     rStream.ReadInt16( rSheetData.DataX2 );
     287           0 :     rStream.ReadInt16( rSheetData.DataY2 );
     288           0 :     rStream.Read(&rSheetData.Reserved, sizeof(rSheetData.Reserved));
     289           0 : }
     290             : 
     291             : 
     292           0 : static void lcl_ReadChartTypeData(SvStream& rStream, Sc10ChartTypeData& rTypeData)
     293             : {
     294           0 :     rStream.ReadInt16( rTypeData.NumSets );
     295           0 :     rStream.ReadInt16( rTypeData.NumPoints );
     296           0 :     rStream.ReadInt16( rTypeData.DrawMode );
     297           0 :     rStream.ReadInt16( rTypeData.GraphType );
     298           0 :     rStream.ReadInt16( rTypeData.GraphStyle );
     299           0 :     lcl_ReadFixedString( rStream, &rTypeData.GraphTitle, sizeof(rTypeData.GraphTitle));
     300           0 :     lcl_ReadFixedString( rStream, &rTypeData.BottomTitle, sizeof(rTypeData.BottomTitle));
     301             :     sal_uInt16 i;
     302           0 :     for (i = 0; i < 256; i++)
     303           0 :         rStream.ReadInt16( rTypeData.SymbolData[i] );
     304           0 :     for (i = 0; i < 256; i++)
     305           0 :         rStream.ReadInt16( rTypeData.ColorData[i] );
     306           0 :     for (i = 0; i < 256; i++)
     307           0 :         rStream.ReadInt16( rTypeData.ThickLines[i] );
     308           0 :     for (i = 0; i < 256; i++)
     309           0 :         rStream.ReadInt16( rTypeData.PatternData[i] );
     310           0 :     for (i = 0; i < 256; i++)
     311           0 :         rStream.ReadInt16( rTypeData.LinePatternData[i] );
     312           0 :     for (i = 0; i < 11; i++)
     313           0 :         rStream.ReadInt16( rTypeData.NumGraphStyles[i] );
     314           0 :     rStream.ReadInt16( rTypeData.ShowLegend );
     315           0 :     for (i = 0; i < 256; i++)
     316           0 :         lcl_ReadFixedString( rStream, &rTypeData.LegendText[i], sizeof(Sc10ChartText));
     317           0 :     rStream.ReadInt16( rTypeData.ExplodePie );
     318           0 :     rStream.ReadInt16( rTypeData.FontUse );
     319           0 :     for (i = 0; i < 5; i++)
     320           0 :         rStream.ReadInt16( rTypeData.FontFamily[i] );
     321           0 :     for (i = 0; i < 5; i++)
     322           0 :         rStream.ReadInt16( rTypeData.FontStyle[i] );
     323           0 :     for (i = 0; i < 5; i++)
     324           0 :         rStream.ReadInt16( rTypeData.FontSize[i] );
     325           0 :     rStream.ReadInt16( rTypeData.GridStyle );
     326           0 :     rStream.ReadInt16( rTypeData.Labels );
     327           0 :     rStream.ReadInt16( rTypeData.LabelEvery );
     328           0 :     for (i = 0; i < 50; i++)
     329           0 :         lcl_ReadFixedString( rStream, &rTypeData.LabelText[i], sizeof(Sc10ChartText));
     330           0 :     lcl_ReadFixedString( rStream, &rTypeData.LeftTitle, sizeof(rTypeData.LeftTitle));
     331           0 :     rStream.Read(&rTypeData.Reserved, sizeof(rTypeData.Reserved));
     332           0 : }
     333             : 
     334           0 : static double lcl_PascalToDouble(sal_Char* tp6)
     335             : {
     336           0 :     sal_uInt8* pnUnsigned = reinterpret_cast< sal_uInt8* >( tp6 );
     337             :     // biased exponent
     338           0 :     sal_uInt8 be = pnUnsigned[ 0 ];
     339             :     // lower 16 bits of mantissa
     340           0 :     sal_uInt16 v1 = static_cast< sal_uInt16 >( pnUnsigned[ 2 ] * 256 + pnUnsigned[ 1 ] );
     341             :     // next 16 bits of mantissa
     342           0 :     sal_uInt16 v2 = static_cast< sal_uInt16 >( pnUnsigned[ 4 ] * 256 + pnUnsigned[ 3 ] );
     343             :     // upper 7 bits of mantissa
     344           0 :     sal_uInt8 v3 = static_cast< sal_uInt8 >( pnUnsigned[ 5 ] & 0x7F );
     345             :     // sign bit
     346           0 :     bool s = (pnUnsigned[ 5 ] & 0x80) != 0;
     347             : 
     348           0 :     if (be == 0)
     349           0 :         return 0.0;
     350           0 :     return (((((128 + v3) * 65536.0) + v2) * 65536.0 + v1) *
     351           0 :         ldexp ((s ? -1.0 : 1.0), be - (129+39)));
     352             : }
     353             : 
     354             : 
     355           0 : static void lcl_ChangeColor( sal_uInt16 nIndex, Color& rColor )
     356             : {
     357             :     ColorData aCol;
     358             : 
     359           0 :     switch( nIndex )
     360             :         {
     361           0 :         case 1:     aCol = COL_RED;             break;
     362           0 :         case 2:     aCol = COL_GREEN;           break;
     363           0 :         case 3:     aCol = COL_BROWN;           break;
     364           0 :         case 4:     aCol = COL_BLUE;            break;
     365           0 :         case 5:     aCol = COL_MAGENTA;         break;
     366           0 :         case 6:     aCol = COL_CYAN;            break;
     367           0 :         case 7:     aCol = COL_GRAY;            break;
     368           0 :         case 8:     aCol = COL_LIGHTGRAY;       break;
     369           0 :         case 9:     aCol = COL_LIGHTRED;        break;
     370           0 :         case 10:    aCol = COL_LIGHTGREEN;      break;
     371           0 :         case 11:    aCol = COL_YELLOW;          break;
     372           0 :         case 12:    aCol = COL_LIGHTBLUE;       break;
     373           0 :         case 13:    aCol = COL_LIGHTMAGENTA;    break;
     374           0 :         case 14:    aCol = COL_LIGHTCYAN;       break;
     375           0 :         case 15:    aCol = COL_WHITE;           break;
     376           0 :         default:    aCol = COL_BLACK;
     377             :         }
     378             : 
     379           0 :     rColor.SetColor( aCol );
     380           0 : }
     381             : 
     382           0 : static OUString lcl_MakeOldPageStyleFormatName( sal_uInt16 i )
     383             : {
     384           0 :     OUString  aName = ScGlobal::GetRscString( STR_PAGESTYLE ) + " " + OUString::number( i + 1 );
     385           0 :     return aName;
     386             : }
     387             : 
     388             : 
     389           0 : template < typename T > sal_uLong insert_new( ScCollection* pCollection, SvStream& rStream )
     390             : {
     391           0 :     T* pData = new (::std::nothrow) T( rStream);
     392           0 :     sal_uLong nError = rStream.GetError();
     393           0 :     if (pData)
     394             :     {
     395           0 :         if (nError)
     396           0 :             delete pData;
     397             :         else
     398           0 :             pCollection->Insert( pData);
     399             :     }
     400             :     else
     401           0 :         nError = errOutOfMemory;
     402           0 :     return nError;
     403             : }
     404             : 
     405             : 
     406             : // Font
     407             : 
     408             : 
     409           0 : Sc10FontData::Sc10FontData(SvStream& rStream)
     410             : {
     411           0 :     rStream.ReadInt16( Height );
     412           0 :     rStream.ReadUChar( CharSet );
     413           0 :     rStream.ReadUChar( PitchAndFamily );
     414             :     sal_uInt16 nLen;
     415           0 :     rStream.ReadUInt16( nLen );
     416           0 :     if (nLen < sizeof(FaceName))
     417           0 :         rStream.Read(FaceName, nLen);
     418             :     else
     419           0 :         rStream.SetError(ERRCODE_IO_WRONGFORMAT);
     420           0 : }
     421             : 
     422             : 
     423           0 : Sc10FontCollection::Sc10FontCollection(SvStream& rStream) :
     424             :     ScCollection (4, 4),
     425           0 :     nError     (0)
     426             : {
     427             :   sal_uInt16 ID;
     428           0 :   rStream.ReadUInt16( ID );
     429           0 :   if (ID == FontID)
     430             :   {
     431             :     sal_uInt16 nAnz;
     432           0 :     rStream.ReadUInt16( nAnz );
     433           0 :     for (sal_uInt16 i=0; (i < nAnz) && (nError == 0); i++)
     434             :     {
     435           0 :         nError = insert_new<Sc10FontData>( this, rStream);
     436             :     }
     437             :   }
     438             :   else
     439             :   {
     440             :     OSL_FAIL( "FontID" );
     441           0 :     nError = errUnknownID;
     442             :   }
     443           0 : }
     444             : 
     445             : 
     446             : // Benannte-Bereiche
     447             : 
     448             : 
     449           0 : Sc10NameData::Sc10NameData(SvStream& rStream)
     450             : {
     451             :     sal_uInt8 nLen;
     452           0 :     rStream.ReadUChar( nLen );
     453           0 :     rStream.Read(Name, sizeof(Name) - 1);
     454           0 :     if (nLen >= sizeof(Name))
     455           0 :         nLen = sizeof(Name) - 1;
     456           0 :     Name[nLen] = 0;
     457             : 
     458           0 :     rStream.ReadUChar( nLen );
     459           0 :     rStream.Read(Reference, sizeof(Reference) - 1);
     460           0 :     if (nLen >= sizeof(Reference))
     461           0 :         nLen = sizeof(Reference) - 1;
     462           0 :     Reference[nLen] = 0;
     463           0 :     rStream.Read(Reserved, sizeof(Reserved));
     464           0 : }
     465             : 
     466             : 
     467           0 : Sc10NameCollection::Sc10NameCollection(SvStream& rStream) :
     468             :     ScCollection (4, 4),
     469           0 :     nError     (0)
     470             : {
     471             :   sal_uInt16 ID;
     472           0 :   rStream.ReadUInt16( ID );
     473           0 :   if (ID == NameID)
     474             :   {
     475             :     sal_uInt16 nAnz;
     476           0 :     rStream.ReadUInt16( nAnz );
     477           0 :     for (sal_uInt16 i=0; (i < nAnz) && (nError == 0); i++)
     478             :     {
     479           0 :         nError = insert_new<Sc10NameData>( this, rStream);
     480             :     }
     481             :   }
     482             :   else
     483             :   {
     484             :     OSL_FAIL( "NameID" );
     485           0 :     nError = errUnknownID;
     486             :   }
     487           0 : }
     488             : 
     489             : 
     490             : // Vorlagen
     491             : 
     492             : 
     493           0 : Sc10PatternData::Sc10PatternData(SvStream& rStream)
     494             : {
     495           0 :   lcl_ReadFixedString( rStream, Name, sizeof(Name));
     496           0 :   lcl_ReadValueFormat(rStream, ValueFormat);
     497           0 :   lcl_ReadLogFont(rStream, LogFont);
     498             : 
     499           0 :   rStream.ReadUInt16( Attr );
     500           0 :   rStream.ReadUInt16( Justify );
     501           0 :   rStream.ReadUInt16( Frame );
     502           0 :   rStream.ReadUInt16( Raster );
     503           0 :   rStream.ReadUInt16( nColor );
     504           0 :   rStream.ReadUInt16( FrameColor );
     505           0 :   rStream.ReadUInt16( Flags );
     506           0 :   rStream.ReadUInt16( FormatFlags );
     507           0 :   rStream.Read(Reserved, sizeof(Reserved));
     508           0 : }
     509             : 
     510             : 
     511           0 : Sc10PatternCollection::Sc10PatternCollection(SvStream& rStream) :
     512             :   ScCollection (4, 4),
     513           0 :   nError     (0)
     514             : {
     515             :   sal_uInt16 ID;
     516           0 :   rStream.ReadUInt16( ID );
     517           0 :   if (ID == PatternID)
     518             :   {
     519             :     sal_uInt16 nAnz;
     520           0 :     rStream.ReadUInt16( nAnz );
     521           0 :     for (sal_uInt16 i=0; (i < nAnz) && (nError == 0); i++)
     522             :     {
     523           0 :         nError = insert_new<Sc10PatternData>( this, rStream);
     524             :     }
     525             :   }
     526             :   else
     527             :   {
     528             :     OSL_FAIL( "PatternID" );
     529           0 :     nError = errUnknownID;
     530             :   }
     531           0 : }
     532             : 
     533             : 
     534             : // Datenbank
     535             : 
     536             : 
     537           0 : Sc10DataBaseData::Sc10DataBaseData(SvStream& rStream)
     538             : {
     539           0 :     lcl_ReadFixedString( rStream, &DataBaseRec.Name, sizeof(DataBaseRec.Name));
     540           0 :     rStream.ReadInt16( DataBaseRec.Tab );
     541           0 :     lcl_ReadBlockRect(rStream, DataBaseRec.Block);
     542           0 :     rStream.ReadUChar( DataBaseRec.RowHeader );
     543           0 :     rStream.ReadInt16( DataBaseRec.SortField0 );
     544           0 :     rStream.ReadUChar( DataBaseRec.SortUpOrder0 );
     545           0 :     rStream.ReadInt16( DataBaseRec.SortField1 );
     546           0 :     rStream.ReadUChar( DataBaseRec.SortUpOrder1 );
     547           0 :     rStream.ReadInt16( DataBaseRec.SortField2 );
     548           0 :     rStream.ReadUChar( DataBaseRec.SortUpOrder2 );
     549           0 :     rStream.ReadUChar( DataBaseRec.IncludeFormat );
     550             : 
     551           0 :     rStream.ReadInt16( DataBaseRec.QueryField0 );
     552           0 :     rStream.ReadInt16( DataBaseRec.QueryOp0 );
     553           0 :     rStream.ReadUChar( DataBaseRec.QueryByString0 );
     554           0 :     lcl_ReadFixedString( rStream, &DataBaseRec.QueryString0, sizeof(DataBaseRec.QueryString0));
     555           0 :     DataBaseRec.QueryValue0 = ScfTools::ReadLongDouble(rStream);
     556             : 
     557           0 :     rStream.ReadInt16( DataBaseRec.QueryConnect1 );
     558           0 :     rStream.ReadInt16( DataBaseRec.QueryField1 );
     559           0 :     rStream.ReadInt16( DataBaseRec.QueryOp1 );
     560           0 :     rStream.ReadUChar( DataBaseRec.QueryByString1 );
     561           0 :     lcl_ReadFixedString( rStream, &DataBaseRec.QueryString1, sizeof(DataBaseRec.QueryString1));
     562           0 :     DataBaseRec.QueryValue1 = ScfTools::ReadLongDouble(rStream);
     563             : 
     564           0 :     rStream.ReadInt16( DataBaseRec.QueryConnect2 );
     565           0 :     rStream.ReadInt16( DataBaseRec.QueryField2 );
     566           0 :     rStream.ReadInt16( DataBaseRec.QueryOp2 );
     567           0 :     rStream.ReadUChar( DataBaseRec.QueryByString2 );
     568           0 :     lcl_ReadFixedString( rStream, &DataBaseRec.QueryString2, sizeof(DataBaseRec.QueryString2));
     569           0 :     DataBaseRec.QueryValue2 = ScfTools::ReadLongDouble(rStream);
     570           0 : }
     571             : 
     572             : 
     573           0 : Sc10DataBaseCollection::Sc10DataBaseCollection(SvStream& rStream) :
     574             :   ScCollection (4, 4),
     575           0 :   nError     (0)
     576             : {
     577             :   sal_uInt16 ID;
     578           0 :   rStream.ReadUInt16( ID );
     579           0 :   if (ID == DataBaseID)
     580             :   {
     581           0 :     lcl_ReadFixedString( rStream, ActName, sizeof(ActName));
     582             :     sal_uInt16 nAnz;
     583           0 :     rStream.ReadUInt16( nAnz );
     584           0 :     for (sal_uInt16 i=0; (i < nAnz) && (nError == 0); i++)
     585             :     {
     586           0 :         nError = insert_new<Sc10DataBaseData>( this, rStream);
     587             :     }
     588             :   }
     589             :   else
     590             :   {
     591             :     OSL_FAIL( "DataBaseID" );
     592           0 :     nError = errUnknownID;
     593             :   }
     594           0 : }
     595             : 
     596             : 
     597           0 : bool Sc10LogFont::operator==( const Sc10LogFont& rData ) const
     598             : {
     599           0 :     return !strcmp( lfFaceName, rData.lfFaceName )
     600           0 :         && lfHeight == rData.lfHeight
     601           0 :         && lfWidth == rData.lfWidth
     602           0 :         && lfEscapement == rData.lfEscapement
     603           0 :         && lfOrientation == rData.lfOrientation
     604           0 :         && lfWeight == rData.lfWeight
     605           0 :         && lfItalic == rData.lfItalic
     606           0 :         && lfUnderline == rData.lfUnderline
     607           0 :         && lfStrikeOut == rData.lfStrikeOut
     608           0 :         && lfCharSet == rData.lfCharSet
     609           0 :         && lfOutPrecision == rData.lfOutPrecision
     610           0 :         && lfClipPrecision == rData.lfClipPrecision
     611           0 :         && lfQuality == rData.lfQuality
     612           0 :         && lfPitchAndFamily == rData.lfPitchAndFamily;
     613             : }
     614             : 
     615             : 
     616           0 : bool Sc10Color::operator==( const Sc10Color& rColor ) const
     617             : {
     618           0 :     return ((Red == rColor.Red) && (Green == rColor.Green) && (Blue == rColor.Blue));
     619             : }
     620             : 
     621             : 
     622           0 : bool Sc10HeadFootLine::operator==( const Sc10HeadFootLine& rData ) const
     623             : {
     624           0 :     return !strcmp(Title, rData.Title)
     625           0 :         && LogFont == rData.LogFont
     626           0 :         && HorJustify == rData.HorJustify
     627           0 :         && VerJustify == rData.VerJustify
     628           0 :         && Raster == rData.Raster
     629           0 :         && Frame == rData.Frame
     630           0 :         && TextColor == rData.TextColor
     631           0 :         && BackColor == rData.BackColor
     632           0 :         && RasterColor == rData.RasterColor
     633           0 :         && FrameColor == rData.FrameColor
     634           0 :         && Reserved == rData.Reserved;
     635             : }
     636             : 
     637             : 
     638           0 : bool Sc10PageFormat::operator==( const Sc10PageFormat& rData ) const
     639             : {
     640           0 :     return !strcmp(PrintAreaName, rData.PrintAreaName)
     641           0 :         && HeadLine == rData.HeadLine
     642           0 :         && FootLine == rData.FootLine
     643           0 :         && Orientation == rData.Orientation
     644           0 :         && Width == rData.Width
     645           0 :         && Height == rData.Height
     646           0 :         && NonPrintableX == rData.NonPrintableX
     647           0 :         && NonPrintableY == rData.NonPrintableY
     648           0 :         && Left == rData.Left
     649           0 :         && Top == rData.Top
     650           0 :         && Right == rData.Right
     651           0 :         && Bottom == rData.Bottom
     652           0 :         && Head == rData.Head
     653           0 :         && Foot == rData.Foot
     654           0 :         && HorCenter == rData.HorCenter
     655           0 :         && VerCenter == rData.VerCenter
     656           0 :         && PrintGrid == rData.PrintGrid
     657           0 :         && PrintColRow == rData.PrintColRow
     658           0 :         && PrintNote == rData.PrintNote
     659           0 :         && TopBottomDir == rData.TopBottomDir
     660           0 :         && FirstPageNo == rData.FirstPageNo
     661           0 :         && RowRepeatStart == rData.RowRepeatStart
     662           0 :         && RowRepeatEnd == rData.RowRepeatEnd
     663           0 :         && ColRepeatStart == rData.ColRepeatStart
     664           0 :         && ColRepeatEnd == rData.ColRepeatEnd
     665           0 :         && !memcmp( PrnZoom, rData.PrnZoom, sizeof(PrnZoom) )
     666           0 :         && !memcmp( &PrintArea, &rData.PrintArea, sizeof(PrintArea) );
     667             : }
     668             : 
     669             : 
     670           0 : sal_uInt16 Sc10PageCollection::InsertFormat( const Sc10PageFormat& rData )
     671             : {
     672           0 :     for (sal_uInt16 i=0; i<nCount; i++)
     673           0 :         if (At(i)->aPageFormat == rData)
     674           0 :             return i;
     675             : 
     676           0 :     Insert( new Sc10PageData(rData) );
     677             : 
     678           0 :     return nCount-1;
     679             : }
     680             : 
     681             : 
     682           0 : static inline sal_uInt8 GetMixedCol( const sal_uInt8 nB, const sal_uInt8 nF, const sal_uInt16 nFak )
     683             : {
     684           0 :     sal_Int32       nT = nB - nF;
     685           0 :                 nT *= ( sal_Int32 ) nFak;
     686           0 :                 nT /= 0xFFFF;
     687           0 :                 nT += nF;
     688           0 :     return ( sal_uInt8 ) nT;
     689             : }
     690           0 : static inline Color GetMixedColor( const Color& rFore, const Color& rBack, sal_uInt16 nFact )
     691             : {
     692           0 :     return Color(   GetMixedCol( rBack.GetRed(), rFore.GetRed(), nFact ),
     693           0 :                     GetMixedCol( rBack.GetGreen(), rFore.GetGreen(), nFact ),
     694           0 :                     GetMixedCol( rBack.GetBlue(), rFore.GetBlue(), nFact ) );
     695             : }
     696             : 
     697             : 
     698           0 : void Sc10PageCollection::PutToDoc( ScDocument* pDoc )
     699             : {
     700           0 :     ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
     701           0 :     EditEngine aEditEngine( pDoc->GetEnginePool() );
     702           0 :     EditTextObject* pEmptyObject = aEditEngine.CreateTextObject();
     703             : 
     704           0 :     for (sal_uInt16 i=0; i<nCount; i++)
     705             :     {
     706           0 :         Sc10PageFormat* pPage = &At(i)->aPageFormat;
     707             : 
     708           0 :         pPage->Width = (short) ( pPage->Width * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
     709           0 :         pPage->Height = (short) ( pPage->Height * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
     710           0 :         pPage->Top = (short) ( pPage->Top * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
     711           0 :         pPage->Bottom = (short) ( pPage->Bottom * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
     712           0 :         pPage->Left = (short) ( pPage->Left * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
     713           0 :         pPage->Right = (short) ( pPage->Right * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
     714           0 :         pPage->Head = (short) ( pPage->Head * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
     715           0 :         pPage->Foot = (short) ( pPage->Foot * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
     716             : 
     717           0 :         OUString aName = lcl_MakeOldPageStyleFormatName( i );
     718             : 
     719             :         ScStyleSheet* pSheet = (ScStyleSheet*) &pStylePool->Make( aName,
     720             :                                     SFX_STYLE_FAMILY_PAGE,
     721           0 :                                     SFXSTYLEBIT_USERDEF | SCSTYLEBIT_STANDARD );
     722             :         // #i68483# set page style name at sheet...
     723           0 :         pDoc->SetPageStyle( static_cast< SCTAB >( i ), aName );
     724             : 
     725           0 :         SfxItemSet* pSet = &pSheet->GetItemSet();
     726             : 
     727           0 :         for (sal_uInt16 nHeadFoot=0; nHeadFoot<2; nHeadFoot++)
     728             :         {
     729           0 :             Sc10HeadFootLine* pHeadFootLine = nHeadFoot ? &pPage->FootLine : &pPage->HeadLine;
     730             : 
     731           0 :             SfxItemSet aEditAttribs(aEditEngine.GetEmptyItemSet());
     732           0 :             FontFamily eFam = FAMILY_DONTKNOW;
     733           0 :             switch (pPage->HeadLine.LogFont.lfPitchAndFamily & 0xF0)
     734             :             {
     735           0 :                 case ffDontCare:    eFam = FAMILY_DONTKNOW;     break;
     736           0 :                 case ffRoman:       eFam = FAMILY_ROMAN;        break;
     737           0 :                 case ffSwiss:       eFam = FAMILY_SWISS;        break;
     738           0 :                 case ffModern:      eFam = FAMILY_MODERN;       break;
     739           0 :                 case ffScript:      eFam = FAMILY_SCRIPT;       break;
     740           0 :                 case ffDecorative:  eFam = FAMILY_DECORATIVE;   break;
     741           0 :                 default:    eFam = FAMILY_DONTKNOW;     break;
     742             :             }
     743             :             aEditAttribs.Put(   SvxFontItem(
     744             :                                     eFam,
     745           0 :                                     SC10TOSTRING( pHeadFootLine->LogFont.lfFaceName ), EMPTY_OUSTRING,
     746             :                                     PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO ),
     747           0 :                                 EE_CHAR_FONTINFO );
     748           0 :             aEditAttribs.Put(   SvxFontHeightItem( std::abs( pHeadFootLine->LogFont.lfHeight ), 100, EE_CHAR_FONTHEIGHT ),
     749           0 :                                 EE_CHAR_FONTHEIGHT);
     750             : 
     751           0 :             Sc10Color nColor = pHeadFootLine->TextColor;
     752           0 :             Color TextColor( nColor.Red, nColor.Green, nColor.Blue );
     753           0 :             aEditAttribs.Put(SvxColorItem(TextColor, EE_CHAR_COLOR), EE_CHAR_COLOR);
     754             :             // FontAttr
     755           0 :             if (pHeadFootLine->LogFont.lfWeight != fwNormal)
     756           0 :                 aEditAttribs.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT), EE_CHAR_WEIGHT);
     757           0 :             if (pHeadFootLine->LogFont.lfItalic != 0)
     758           0 :                 aEditAttribs.Put(SvxPostureItem(ITALIC_NORMAL, EE_CHAR_ITALIC), EE_CHAR_ITALIC);
     759           0 :             if (pHeadFootLine->LogFont.lfUnderline != 0)
     760           0 :                 aEditAttribs.Put(SvxUnderlineItem(UNDERLINE_SINGLE, EE_CHAR_UNDERLINE), EE_CHAR_UNDERLINE);
     761           0 :             if (pHeadFootLine->LogFont.lfStrikeOut != 0)
     762           0 :                 aEditAttribs.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT), EE_CHAR_STRIKEOUT);
     763           0 :             OUString aText( pHeadFootLine->Title, strlen(pHeadFootLine->Title), DEFCHARSET );
     764           0 :             aEditEngine.SetText( aText );
     765           0 :             aEditEngine.QuickSetAttribs( aEditAttribs, ESelection( 0, 0, 0, aText.getLength() ) );
     766             : 
     767           0 :             EditTextObject* pObject = aEditEngine.CreateTextObject();
     768           0 :             ScPageHFItem aHeaderItem(nHeadFoot ? ATTR_PAGE_FOOTERRIGHT : ATTR_PAGE_HEADERRIGHT);
     769           0 :             switch (pHeadFootLine->HorJustify)
     770             :             {
     771             :                 case hjCenter:
     772           0 :                     aHeaderItem.SetLeftArea(*pEmptyObject);
     773           0 :                     aHeaderItem.SetCenterArea(*pObject);
     774           0 :                     aHeaderItem.SetRightArea(*pEmptyObject);
     775           0 :                     break;
     776             :                 case hjRight:
     777           0 :                     aHeaderItem.SetLeftArea(*pEmptyObject);
     778           0 :                     aHeaderItem.SetCenterArea(*pEmptyObject);
     779           0 :                     aHeaderItem.SetRightArea(*pObject);
     780           0 :                     break;
     781             :                 default:
     782           0 :                     aHeaderItem.SetLeftArea(*pObject);
     783           0 :                     aHeaderItem.SetCenterArea(*pEmptyObject);
     784           0 :                     aHeaderItem.SetRightArea(*pEmptyObject);
     785           0 :                     break;
     786             :             }
     787           0 :             delete pObject;
     788           0 :             pSet->Put( aHeaderItem );
     789             : 
     790           0 :             SfxItemSet aSetItemItemSet( *pDoc->GetPool(),
     791             :                                   ATTR_BACKGROUND, ATTR_BACKGROUND,
     792             :                                   ATTR_BORDER, ATTR_SHADOW,
     793             :                                   ATTR_PAGE_SIZE, ATTR_PAGE_SIZE,
     794             :                                   ATTR_LRSPACE, ATTR_ULSPACE,
     795             :                                   ATTR_PAGE_ON, ATTR_PAGE_SHARED,
     796           0 :                                   0 );
     797           0 :             nColor = pHeadFootLine->BackColor;
     798           0 :             Color aBColor( nColor.Red, nColor.Green, nColor.Blue );
     799           0 :             nColor = pHeadFootLine->RasterColor;
     800           0 :             Color aRColor( nColor.Red, nColor.Green, nColor.Blue );
     801             : 
     802             :             sal_uInt16 nFact;
     803           0 :             sal_Bool        bSwapCol = false;
     804           0 :             switch (pHeadFootLine->Raster)
     805             :             {
     806           0 :                case raNone:     nFact = 0xffff; bSwapCol = sal_True; break;
     807           0 :                case raGray12:   nFact = (0xffff / 100) * 12;    break;
     808           0 :                case raGray25:   nFact = (0xffff / 100) * 25;    break;
     809           0 :                case raGray50:   nFact = (0xffff / 100) * 50;    break;
     810           0 :                case raGray75:   nFact = (0xffff / 100) * 75;    break;
     811           0 :                default: nFact = 0xffff;
     812             :             }
     813           0 :             if( bSwapCol )
     814           0 :                 aSetItemItemSet.Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
     815             :             else
     816           0 :                 aSetItemItemSet.Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
     817             : 
     818           0 :             if (pHeadFootLine->Frame != 0)
     819             :             {
     820           0 :               sal_uInt16 nLeft = 0;
     821           0 :               sal_uInt16 nTop = 0;
     822           0 :               sal_uInt16 nRight = 0;
     823           0 :               sal_uInt16 nBottom = 0;
     824           0 :               sal_uInt16 fLeft   = (pHeadFootLine->Frame & 0x000F);
     825           0 :               sal_uInt16 fTop    = (pHeadFootLine->Frame & 0x00F0) / 0x0010;
     826           0 :               sal_uInt16 fRight  = (pHeadFootLine->Frame & 0x0F00) / 0x0100;
     827           0 :               sal_uInt16 fBottom = (pHeadFootLine->Frame & 0xF000) / 0x1000;
     828           0 :               if (fLeft > 1)
     829           0 :                 nLeft = 50;
     830           0 :               else if (fLeft > 0)
     831           0 :                 nLeft = 20;
     832           0 :               if (fTop > 1)
     833           0 :                 nTop = 50;
     834           0 :               else if (fTop > 0)
     835           0 :                 nTop = 20;
     836           0 :               if (fRight > 1)
     837           0 :                 nRight = 50;
     838           0 :               else if (fRight > 0)
     839           0 :                 nRight = 20;
     840           0 :               if (fBottom > 1)
     841           0 :                 nBottom = 50;
     842           0 :               else if (fBottom > 0)
     843           0 :                 nBottom = 20;
     844           0 :               Color  ColorLeft(COL_BLACK);
     845           0 :               Color  ColorTop(COL_BLACK);
     846           0 :               Color  ColorRight(COL_BLACK);
     847           0 :               Color  ColorBottom(COL_BLACK);
     848           0 :               sal_uInt16 cLeft   = (pHeadFootLine->FrameColor & 0x000F);
     849           0 :               sal_uInt16 cTop    = (pHeadFootLine->FrameColor & 0x00F0) >> 4;
     850           0 :               sal_uInt16 cRight  = (pHeadFootLine->FrameColor & 0x0F00) >> 8;
     851           0 :               sal_uInt16 cBottom = (pHeadFootLine->FrameColor & 0xF000) >> 12;
     852           0 :               lcl_ChangeColor(cLeft, ColorLeft);
     853           0 :               lcl_ChangeColor(cTop, ColorTop);
     854           0 :               lcl_ChangeColor(cRight, ColorRight);
     855           0 :               lcl_ChangeColor(cBottom, ColorBottom);
     856           0 :               ::editeng::SvxBorderLine aLine;
     857           0 :               SvxBoxItem aBox( ATTR_BORDER );
     858           0 :               aLine.SetWidth(nLeft);
     859           0 :               aLine.SetColor(ColorLeft);
     860           0 :               aBox.SetLine(&aLine, BOX_LINE_LEFT);
     861           0 :               aLine.SetWidth(nTop);
     862           0 :               aLine.SetColor(ColorTop);
     863           0 :               aBox.SetLine(&aLine, BOX_LINE_TOP);
     864           0 :               aLine.SetWidth(nRight);
     865           0 :               aLine.SetColor(ColorRight);
     866           0 :               aBox.SetLine(&aLine, BOX_LINE_RIGHT);
     867           0 :               aLine.SetWidth(nBottom);
     868           0 :               aLine.SetColor(ColorBottom);
     869           0 :               aBox.SetLine(&aLine, BOX_LINE_BOTTOM);
     870             : 
     871           0 :               aSetItemItemSet.Put(aBox);
     872             :             }
     873             : 
     874           0 :             pSet->Put( SvxULSpaceItem( 0, 0, ATTR_ULSPACE ) );
     875             : 
     876           0 :             if (nHeadFoot==0)
     877           0 :                 aSetItemItemSet.Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( 0, pPage->Top - pPage->Head ) ) );
     878             :             else
     879           0 :                 aSetItemItemSet.Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( 0, pPage->Bottom - pPage->Foot ) ) );
     880             : 
     881           0 :             aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_ON, true ));
     882           0 :             aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_DYNAMIC, false ));
     883           0 :             aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_SHARED, true ));
     884             : 
     885             :             pSet->Put( SvxSetItem( nHeadFoot ? ATTR_PAGE_FOOTERSET : ATTR_PAGE_HEADERSET,
     886           0 :                                     aSetItemItemSet ) );
     887           0 :         }
     888             : 
     889           0 :         SvxPageItem aPageItem(ATTR_PAGE);
     890           0 :         aPageItem.SetPageUsage( SVX_PAGE_ALL );
     891           0 :         aPageItem.SetLandscape( pPage->Orientation != 1 );
     892           0 :         aPageItem.SetNumType( SVX_ARABIC );
     893           0 :         pSet->Put(aPageItem);
     894             : 
     895           0 :         pSet->Put(SvxLRSpaceItem( pPage->Left, pPage->Right, 0,0, ATTR_LRSPACE ));
     896           0 :         pSet->Put(SvxULSpaceItem( pPage->Top, pPage->Bottom, ATTR_ULSPACE ));
     897             : 
     898           0 :         pSet->Put(SfxBoolItem( ATTR_PAGE_HORCENTER, pPage->HorCenter ));
     899           0 :         pSet->Put(SfxBoolItem( ATTR_PAGE_VERCENTER, pPage->VerCenter ));
     900             : 
     901             : 
     902             :         // Area-Parameter:
     903             : 
     904             :         {
     905           0 :             ScRange* pRepeatRow = NULL;
     906           0 :             ScRange* pRepeatCol = NULL;
     907             : 
     908           0 :             if ( pPage->ColRepeatStart >= 0 )
     909           0 :                 pRepeatCol = new ScRange( static_cast<SCCOL> (pPage->ColRepeatStart), 0, 0 );
     910           0 :             if ( pPage->RowRepeatStart >= 0 )
     911           0 :                 pRepeatRow = new ScRange( 0, static_cast<SCROW> (pPage->RowRepeatStart), 0 );
     912             : 
     913             : 
     914           0 :             if ( pRepeatRow || pRepeatCol )
     915             :             {
     916             : 
     917             :                 // an allen Tabellen setzen
     918             : 
     919           0 :                 for ( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
     920             :                 {
     921           0 :                     pDoc->SetRepeatColRange( nTab, pRepeatCol );
     922           0 :                     pDoc->SetRepeatRowRange( nTab, pRepeatRow );
     923             :                 }
     924             :             }
     925             : 
     926           0 :             delete pRepeatRow;
     927           0 :             delete pRepeatCol;
     928             :         }
     929             : 
     930             : 
     931             :         // Table-Parameter:
     932             : 
     933           0 :         pSet->Put( SfxBoolItem( ATTR_PAGE_NOTES,   pPage->PrintNote ) );
     934           0 :         pSet->Put( SfxBoolItem( ATTR_PAGE_GRID,    pPage->PrintGrid ) );
     935           0 :         pSet->Put( SfxBoolItem( ATTR_PAGE_HEADERS, pPage->PrintColRow ) );
     936           0 :         pSet->Put( SfxBoolItem( ATTR_PAGE_TOPDOWN, pPage->TopBottomDir ) );
     937           0 :         pSet->Put( ScViewObjectModeItem( ATTR_PAGE_CHARTS,   VOBJ_MODE_SHOW ) );
     938           0 :         pSet->Put( ScViewObjectModeItem( ATTR_PAGE_OBJECTS,  VOBJ_MODE_SHOW ) );
     939           0 :         pSet->Put( ScViewObjectModeItem( ATTR_PAGE_DRAWINGS, VOBJ_MODE_SHOW ) );
     940             :         pSet->Put( SfxUInt16Item( ATTR_PAGE_SCALE,
     941           0 :                                   (sal_uInt16)( lcl_PascalToDouble( pPage->PrnZoom ) * 100 ) ) );
     942           0 :         pSet->Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 1 ) );
     943             : 
     944           0 :         pSet->Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( pPage->Width, pPage->Height ) ) );
     945           0 :     }
     946             : 
     947           0 :     delete pEmptyObject;
     948           0 : }
     949             : 
     950             : 
     951           0 : ScDataObject* Sc10PageData::Clone() const
     952             : {
     953           0 :     return new Sc10PageData(aPageFormat);
     954             : }
     955             : 
     956             : // Import
     957             : 
     958           0 : Sc10Import::Sc10Import(SvStream& rStr, ScDocument* pDocument ) :
     959             :     rStream             (rStr),
     960             :     pDoc                (pDocument),
     961             :     pFontCollection     (NULL),
     962             :     pNameCollection     (NULL),
     963             :     pPatternCollection  (NULL),
     964             :     pDataBaseCollection (NULL),
     965             :     nError              (0),
     966           0 :     nShowTab            (0)
     967             : {
     968           0 :     pPrgrsBar = NULL;
     969           0 : }
     970             : 
     971             : 
     972           0 : Sc10Import::~Sc10Import()
     973             : {
     974           0 :     pDoc->CalcAfterLoad();
     975           0 :     pDoc->UpdateAllCharts();
     976             : 
     977           0 :     delete pFontCollection;
     978           0 :     delete pNameCollection;
     979           0 :     delete pPatternCollection;
     980           0 :     delete pDataBaseCollection;
     981             : 
     982             :     OSL_ENSURE( pPrgrsBar == NULL,
     983             :         "*Sc10Import::Sc10Import(): Progressbar lebt noch!?" );
     984           0 : }
     985             : 
     986             : 
     987           0 : sal_uLong Sc10Import::Import()
     988             : {
     989           0 :     pPrgrsBar = new ScfStreamProgressBar( rStream, pDoc->GetDocumentShell() );
     990             : 
     991           0 :     ScDocOptions aOpt = pDoc->GetDocOptions();
     992           0 :     aOpt.SetDate( 1, 1, 1900 );
     993           0 :     aOpt.SetYear2000( 18 + 1901 );      // ab SO51 src513e vierstellig
     994           0 :     pDoc->SetDocOptions( aOpt );
     995           0 :     pDoc->GetFormatTable()->ChangeNullDate( 1, 1, 1900 );
     996             : 
     997           0 :     LoadFileHeader();                           pPrgrsBar->Progress();
     998           0 :     if (!nError) { LoadFileInfo();              pPrgrsBar->Progress(); }
     999           0 :     if (!nError) { LoadEditStateInfo();         pPrgrsBar->Progress(); }
    1000           0 :     if (!nError) { LoadProtect();               pPrgrsBar->Progress(); }
    1001           0 :     if (!nError) { LoadViewColRowBar();         pPrgrsBar->Progress(); }
    1002           0 :     if (!nError) { LoadScrZoom();               pPrgrsBar->Progress(); }
    1003           0 :     if (!nError) { LoadPalette();               pPrgrsBar->Progress(); }
    1004           0 :     if (!nError) { LoadFontCollection();        pPrgrsBar->Progress(); }
    1005           0 :     if (!nError) { LoadNameCollection();        pPrgrsBar->Progress(); }
    1006           0 :     if (!nError) { LoadPatternCollection();     pPrgrsBar->Progress(); }
    1007           0 :     if (!nError) { LoadDataBaseCollection();    pPrgrsBar->Progress(); }
    1008           0 :     if (!nError) { LoadTables();                pPrgrsBar->Progress(); }
    1009           0 :     if (!nError) { LoadObjects();               pPrgrsBar->Progress(); }
    1010           0 :     if (!nError) { ImportNameCollection();      pPrgrsBar->Progress(); }
    1011           0 :     pDoc->SetViewOptions( aSc30ViewOpt );
    1012             : 
    1013             : #if OSL_DEBUG_LEVEL > 0
    1014             :     if (nError)
    1015             :     {
    1016             :         OSL_FAIL( OString::number(nError).getStr());
    1017             :     }
    1018             : #endif
    1019             : 
    1020           0 :     delete pPrgrsBar;
    1021             : #if OSL_DEBUG_LEVEL > 0
    1022             :     pPrgrsBar = NULL;
    1023             : #endif
    1024             : 
    1025           0 :     return nError;
    1026             : }
    1027             : 
    1028             : 
    1029           0 : void Sc10Import::LoadFileHeader()
    1030             : {
    1031             :     Sc10FileHeader FileHeader;
    1032           0 :     lcl_ReadFileHeader(rStream, FileHeader);
    1033             : 
    1034           0 :     nError = rStream.GetError();
    1035           0 :     if ( nError == 0 )
    1036             :     {
    1037             :         sal_Char Sc10CopyRight[32];
    1038           0 :         strcpy(Sc10CopyRight, "Blaise-Tabelle");
    1039           0 :         Sc10CopyRight[14] = 10;
    1040           0 :         Sc10CopyRight[15] = 13;
    1041           0 :         Sc10CopyRight[16] = 0;
    1042           0 :         if ((strcmp(FileHeader.CopyRight, Sc10CopyRight) != 0)
    1043           0 :             || (FileHeader.Version < 101)
    1044           0 :             || (FileHeader.Version > 102))
    1045           0 :             nError = errUnknownFormat;
    1046             :     }
    1047           0 : }
    1048             : 
    1049             : 
    1050           0 : void Sc10Import::LoadFileInfo()
    1051             : {
    1052             :     Sc10FileInfo FileInfo;
    1053           0 :     rStream.Read(&FileInfo, sizeof(FileInfo));
    1054             : 
    1055           0 :     nError = rStream.GetError();
    1056             :     // Achtung Info Uebertragen
    1057           0 : }
    1058             : 
    1059           0 : void Sc10Import::LoadEditStateInfo()
    1060             : {
    1061             :     Sc10EditStateInfo EditStateInfo;
    1062           0 :     rStream.Read(&EditStateInfo, sizeof(EditStateInfo));
    1063             : 
    1064           0 :     nError = rStream.GetError();
    1065           0 :     nShowTab = static_cast<SCTAB>(EditStateInfo.DeltaZ);
    1066             :     // Achtung Cursorposition und Offset der Tabelle Uebertragen (soll man das machen??)
    1067           0 : }
    1068             : 
    1069             : 
    1070           0 : void Sc10Import::LoadProtect()
    1071             : {
    1072           0 :     lcl_ReadSheetProtect(rStream, SheetProtect);
    1073           0 :     nError = rStream.GetError();
    1074             : 
    1075           0 :     ScDocProtection aProtection;
    1076           0 :     aProtection.setProtected(static_cast<bool>(SheetProtect.Protect));
    1077           0 :     aProtection.setPassword(SC10TOSTRING(SheetProtect.PassWord));
    1078           0 :     pDoc->SetDocProtection(&aProtection);
    1079           0 : }
    1080             : 
    1081             : 
    1082           0 : void Sc10Import::LoadViewColRowBar()
    1083             : {
    1084             :     sal_uInt8 ViewColRowBar;
    1085           0 :     rStream.ReadUChar( ViewColRowBar );
    1086           0 :     nError = rStream.GetError();
    1087           0 :     aSc30ViewOpt.SetOption( VOPT_HEADER, (sal_Bool)ViewColRowBar );
    1088           0 : }
    1089             : 
    1090             : 
    1091           0 : void Sc10Import::LoadScrZoom()
    1092             : {
    1093             :     // Achtung Zoom ist leider eine 6Byte TP real Zahl (keine Ahnung wie die Umzusetzen ist)
    1094             :     sal_Char cZoom[6];
    1095           0 :     rStream.Read(cZoom, sizeof(cZoom));
    1096           0 :     nError = rStream.GetError();
    1097           0 : }
    1098             : 
    1099             : 
    1100           0 : void Sc10Import::LoadPalette()
    1101             : {
    1102           0 :     lcl_ReadPalette(rStream, TextPalette);
    1103           0 :     lcl_ReadPalette(rStream, BackPalette);
    1104           0 :     lcl_ReadPalette(rStream, RasterPalette);
    1105           0 :     lcl_ReadPalette(rStream, FramePalette);
    1106             : 
    1107           0 :     nError = rStream.GetError();
    1108           0 : }
    1109             : 
    1110             : 
    1111           0 : void Sc10Import::LoadFontCollection()
    1112             : {
    1113           0 :     pFontCollection = new Sc10FontCollection(rStream);
    1114           0 :     if (!nError)
    1115           0 :         nError = pFontCollection->GetError();
    1116           0 : }
    1117             : 
    1118             : 
    1119           0 : void Sc10Import::LoadNameCollection()
    1120             : {
    1121           0 :     pNameCollection = new Sc10NameCollection(rStream);
    1122           0 :     if (!nError)
    1123           0 :         nError = pNameCollection->GetError();
    1124           0 : }
    1125             : 
    1126             : 
    1127           0 : void Sc10Import::ImportNameCollection()
    1128             : {
    1129           0 :     ScRangeName*        pRN = pDoc->GetRangeName();
    1130             : 
    1131           0 :     for (sal_uInt16 i = 0; i < pNameCollection->GetCount(); i++)
    1132             :     {
    1133           0 :         Sc10NameData*   pName = pNameCollection->At( i );
    1134             :         pRN->insert(
    1135             :             new ScRangeData(
    1136           0 :                 pDoc, SC10TOSTRING(pName->Name), SC10TOSTRING(pName->Reference)));
    1137             :     }
    1138           0 : }
    1139             : 
    1140             : 
    1141           0 : void Sc10Import::LoadPatternCollection()
    1142             : {
    1143           0 :     pPatternCollection = new Sc10PatternCollection( rStream );
    1144           0 :     if (!nError)
    1145           0 :         nError = pPatternCollection->GetError();
    1146           0 :     if (nError == errOutOfMemory)
    1147           0 :         return;     // hopeless
    1148           0 :     ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
    1149           0 :     for( sal_uInt16 i = 0 ; i < pPatternCollection->GetCount() ; i++ )
    1150             :     {
    1151           0 :         Sc10PatternData* pPattern = pPatternCollection->At( i );
    1152           0 :         OUString aName( pPattern->Name, strlen(pPattern->Name), DEFCHARSET );
    1153           0 :         SfxStyleSheetBase* pStyle = pStylePool->Find( aName, SFX_STYLE_FAMILY_PARA );
    1154           0 :         if( pStyle == NULL )
    1155           0 :             pStylePool->Make( aName, SFX_STYLE_FAMILY_PARA );
    1156             :         else
    1157             :         {
    1158           0 :             pPattern->Name[ 27 ] = 0;
    1159           0 :             strcat( pPattern->Name, "_Old" );
    1160           0 :             aName = SC10TOSTRING( pPattern->Name );
    1161           0 :             pStylePool->Make( aName, SFX_STYLE_FAMILY_PARA );
    1162             :         }
    1163           0 :         pStyle = pStylePool->Find( aName, SFX_STYLE_FAMILY_PARA );
    1164           0 :         if( pStyle != NULL )
    1165             :         {
    1166           0 :             SfxItemSet &rItemSet = pStyle->GetItemSet();
    1167             :             // Font
    1168           0 :             if( ( pPattern->FormatFlags & pfFont ) == pfFont )
    1169             :             {
    1170           0 :                 FontFamily eFam = FAMILY_DONTKNOW;
    1171           0 :                 switch( pPattern->LogFont.lfPitchAndFamily & 0xF0 )
    1172             :                 {
    1173           0 :                     case ffDontCare   : eFam = FAMILY_DONTKNOW;     break;
    1174           0 :                     case ffRoman      : eFam = FAMILY_ROMAN;        break;
    1175           0 :                     case ffSwiss      : eFam = FAMILY_SWISS;        break;
    1176           0 :                     case ffModern     : eFam = FAMILY_MODERN;       break;
    1177           0 :                     case ffScript     : eFam = FAMILY_SCRIPT;       break;
    1178           0 :                     case ffDecorative : eFam = FAMILY_DECORATIVE;   break;
    1179           0 :                     default: eFam = FAMILY_DONTKNOW;        break;
    1180             :                 }
    1181           0 :                 rItemSet.Put( SvxFontItem( eFam, SC10TOSTRING( pPattern->LogFont.lfFaceName ), EMPTY_OUSTRING,
    1182           0 :                         PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ) );
    1183           0 :                 rItemSet.Put( SvxFontHeightItem( std::abs( pPattern->LogFont.lfHeight ), 100, ATTR_FONT_HEIGHT ) );
    1184           0 :                 Color TextColor( COL_BLACK );
    1185           0 :                 lcl_ChangeColor( ( pPattern->nColor & 0x000F ), TextColor );
    1186           0 :                 rItemSet.Put( SvxColorItem( TextColor, ATTR_FONT_COLOR ) );
    1187             :                 // FontAttr
    1188           0 :                 if( pPattern->LogFont.lfWeight != fwNormal )
    1189           0 :                     rItemSet.Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
    1190           0 :                 if( pPattern->LogFont.lfItalic != 0 )
    1191           0 :                     rItemSet.Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
    1192           0 :                 if( pPattern->LogFont.lfUnderline != 0 )
    1193           0 :                     rItemSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
    1194           0 :                 if( pPattern->LogFont.lfStrikeOut != 0 )
    1195           0 :                     rItemSet.Put( SvxCrossedOutItem( STRIKEOUT_SINGLE, ATTR_FONT_CROSSEDOUT ) );
    1196             :             }
    1197             :             // Ausrichtung
    1198           0 :             if( ( pPattern->FormatFlags & pfJustify ) == pfJustify )
    1199             :             {
    1200           0 :                 sal_uInt16 HorJustify = ( pPattern->Justify & 0x000F );
    1201           0 :                 sal_uInt16 VerJustify = ( pPattern->Justify & 0x00F0 ) >> 4;
    1202           0 :                 sal_uInt16 OJustify   = ( pPattern->Justify & 0x0F00 ) >> 8;
    1203           0 :                 sal_uInt16 EJustify   = ( pPattern->Justify & 0xF000 ) >> 12;
    1204           0 :                 if( HorJustify != 0 )
    1205           0 :                     switch( HorJustify )
    1206             :                     {
    1207             :                         case hjLeft:
    1208           0 :                             rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY ) );
    1209           0 :                             break;
    1210             :                         case hjCenter:
    1211           0 :                             rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
    1212           0 :                             break;
    1213             :                         case hjRight:
    1214           0 :                             rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY ) );
    1215           0 :                             break;
    1216             :                     }
    1217           0 :                 if( VerJustify != 0 )
    1218           0 :                     switch( VerJustify )
    1219             :                     {
    1220             :                         case vjTop:
    1221           0 :                             rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_TOP, ATTR_VER_JUSTIFY ) );
    1222           0 :                             break;
    1223             :                         case vjCenter:
    1224           0 :                             rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY ) );
    1225           0 :                             break;
    1226             :                         case vjBottom:
    1227           0 :                             rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_BOTTOM, ATTR_VER_JUSTIFY ) );
    1228           0 :                             break;
    1229             :                     }
    1230             : 
    1231           0 :                 if( ( OJustify & ojWordBreak ) == ojWordBreak )
    1232           0 :                     rItemSet.Put( SfxBoolItem( sal_True ) );
    1233           0 :                 if( ( OJustify & ojBottomTop ) == ojBottomTop )
    1234           0 :                     rItemSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
    1235           0 :                 else if( ( OJustify & ojTopBottom ) == ojTopBottom )
    1236           0 :                     rItemSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
    1237             : 
    1238           0 :                 sal_Int16 Margin = std::max( ( sal_uInt16 ) 20, ( sal_uInt16 ) ( EJustify * 20 ) );
    1239           0 :                 if( ( ( OJustify & ojBottomTop ) == ojBottomTop ) )
    1240           0 :                     rItemSet.Put( SvxMarginItem( 20, Margin, 20, Margin, ATTR_MARGIN ) );
    1241             :                 else
    1242           0 :                     rItemSet.Put( SvxMarginItem( Margin, 20, Margin, 20, ATTR_MARGIN ) );
    1243             :             }
    1244             : 
    1245             :             // Frame
    1246           0 :             if( ( pPattern->FormatFlags & pfFrame ) == pfFrame )
    1247             :             {
    1248           0 :                 if( pPattern->Frame != 0 )
    1249             :                 {
    1250           0 :                     sal_uInt16  nLeft   = 0;
    1251           0 :                     sal_uInt16  nTop    = 0;
    1252           0 :                     sal_uInt16  nRight  = 0;
    1253           0 :                     sal_uInt16  nBottom = 0;
    1254           0 :                     sal_uInt16  fLeft   = ( pPattern->Frame & 0x000F );
    1255           0 :                     sal_uInt16  fTop    = ( pPattern->Frame & 0x00F0 ) / 0x0010;
    1256           0 :                     sal_uInt16  fRight  = ( pPattern->Frame & 0x0F00 ) / 0x0100;
    1257           0 :                     sal_uInt16  fBottom = ( pPattern->Frame & 0xF000 ) / 0x1000;
    1258             : 
    1259           0 :                     if( fLeft > 1 )
    1260           0 :                         nLeft = 50;
    1261           0 :                     else if( fLeft > 0 )
    1262           0 :                         nLeft = 20;
    1263             : 
    1264           0 :                     if( fTop > 1 )
    1265           0 :                         nTop = 50;
    1266           0 :                     else if( fTop > 0 )
    1267           0 :                         nTop = 20;
    1268             : 
    1269           0 :                     if( fRight > 1 )
    1270           0 :                         nRight = 50;
    1271           0 :                     else if( fRight > 0 )
    1272           0 :                         nRight = 20;
    1273             : 
    1274           0 :                     if( fBottom > 1 )
    1275           0 :                         nBottom = 50;
    1276           0 :                     else if( fBottom > 0 )
    1277           0 :                         nBottom = 20;
    1278             : 
    1279           0 :                     Color   ColorLeft( COL_BLACK );
    1280           0 :                     Color   ColorTop( COL_BLACK );
    1281           0 :                     Color   ColorRight( COL_BLACK );
    1282           0 :                     Color   ColorBottom( COL_BLACK );
    1283             : 
    1284           0 :                     sal_uInt16  cLeft   = ( pPattern->FrameColor & 0x000F );
    1285           0 :                     sal_uInt16  cTop    = ( pPattern->FrameColor & 0x00F0 ) >> 4;
    1286           0 :                     sal_uInt16  cRight  = ( pPattern->FrameColor & 0x0F00 ) >> 8;
    1287           0 :                     sal_uInt16  cBottom = ( pPattern->FrameColor & 0xF000 ) >> 12;
    1288             : 
    1289           0 :                     lcl_ChangeColor( cLeft, ColorLeft );
    1290           0 :                     lcl_ChangeColor( cTop, ColorTop );
    1291           0 :                     lcl_ChangeColor( cRight, ColorRight );
    1292           0 :                     lcl_ChangeColor( cBottom, ColorBottom );
    1293             : 
    1294           0 :                     ::editeng::SvxBorderLine    aLine;
    1295           0 :                     SvxBoxItem      aBox( ATTR_BORDER );
    1296             : 
    1297           0 :                     aLine.SetWidth( nLeft );
    1298           0 :                     aLine.SetColor( ColorLeft );
    1299           0 :                     aBox.SetLine( &aLine, BOX_LINE_LEFT );
    1300           0 :                     aLine.SetWidth( nTop );
    1301           0 :                     aLine.SetColor( ColorTop );
    1302           0 :                     aBox.SetLine( &aLine, BOX_LINE_TOP );
    1303           0 :                     aLine.SetWidth( nRight );
    1304           0 :                     aLine.SetColor( ColorRight );
    1305           0 :                     aBox.SetLine( &aLine, BOX_LINE_RIGHT );
    1306           0 :                     aLine.SetWidth( nBottom );
    1307           0 :                     aLine.SetColor( ColorBottom );
    1308           0 :                     aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
    1309           0 :                     rItemSet.Put( aBox );
    1310             :                 }
    1311             :             }
    1312             :             // Raster
    1313           0 :             if( ( pPattern->FormatFlags & pfRaster ) == pfRaster )
    1314             :             {
    1315           0 :                 if( pPattern->Raster != 0 )
    1316             :                 {
    1317           0 :                     sal_uInt16 nBColor = ( pPattern->nColor & 0x00F0 ) >> 4;
    1318           0 :                     sal_uInt16 nRColor = ( pPattern->nColor & 0x0F00 ) >> 8;
    1319           0 :                     Color aBColor( COL_BLACK );
    1320             : 
    1321           0 :                     lcl_ChangeColor( nBColor, aBColor );
    1322             : 
    1323           0 :                     if( nBColor == 0 )
    1324           0 :                         aBColor.SetColor( COL_WHITE );
    1325           0 :                     else if( nBColor == 15 )
    1326           0 :                         aBColor.SetColor( COL_BLACK );
    1327             : 
    1328           0 :                     Color aRColor( COL_BLACK );
    1329           0 :                     lcl_ChangeColor( nRColor, aRColor );
    1330             :                     sal_uInt16 nFact;
    1331           0 :                     sal_Bool        bSwapCol = false;
    1332           0 :                     sal_Bool        bSetItem = sal_True;
    1333           0 :                     switch (pPattern->Raster)
    1334             :                     {
    1335           0 :                        case raNone:     nFact = 0xffff; bSwapCol = sal_True; bSetItem = (nBColor > 0); break;
    1336           0 :                        case raGray12:   nFact = (0xffff / 100) * 12;    break;
    1337           0 :                        case raGray25:   nFact = (0xffff / 100) * 25;    break;
    1338           0 :                        case raGray50:   nFact = (0xffff / 100) * 50;    break;
    1339           0 :                        case raGray75:   nFact = (0xffff / 100) * 75;    break;
    1340           0 :                        default: nFact = 0xffff; bSetItem = (nRColor < 15);
    1341             :                     }
    1342           0 :                     if ( bSetItem )
    1343             :                     {
    1344           0 :                         if( bSwapCol )
    1345           0 :                             rItemSet.Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
    1346             :                         else
    1347           0 :                             rItemSet.Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
    1348             :                     }
    1349             :                 }
    1350             :             }
    1351             :             // ZahlenFormate
    1352           0 :             if( ( pPattern->ValueFormat.Format != 0 ) &&
    1353           0 :                 ( ( pPattern->FormatFlags & pfValue ) == pfValue ) )
    1354             :             {
    1355           0 :                 sal_uLong nKey = 0;
    1356           0 :                 ChangeFormat( pPattern->ValueFormat.Format, pPattern->ValueFormat.Info, nKey );
    1357           0 :                 rItemSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, ( sal_uInt32 ) nKey ) );
    1358             :             }
    1359             : 
    1360             :             // Zellattribute (Schutz, Versteckt...)
    1361           0 :             if( ( pPattern->Flags != 0 ) &&
    1362           0 :                 ( ( pPattern->FormatFlags & pfProtection ) == pfProtection ) )
    1363             :             {
    1364           0 :                 sal_Bool bProtect  = ( ( pPattern->Flags & paProtect ) == paProtect );
    1365           0 :                 sal_Bool bHFormula = ( ( pPattern->Flags & paHideFormula ) == paHideFormula );
    1366           0 :                 sal_Bool bHCell    = ( ( pPattern->Flags & paHideAll ) == paHideAll );
    1367           0 :                 sal_Bool bHPrint   = ( ( pPattern->Flags & paHidePrint ) == paHidePrint );
    1368           0 :                 rItemSet.Put( ScProtectionAttr( bProtect, bHFormula, bHCell, bHPrint ) );
    1369             :             }
    1370             :         } // if Style != 0
    1371           0 :     } // for (i = 0; i < GetCount()
    1372             : }
    1373             : 
    1374             : 
    1375           0 : void Sc10Import::LoadDataBaseCollection()
    1376             : {
    1377           0 :     pDataBaseCollection = new Sc10DataBaseCollection(rStream);
    1378           0 :     if (!nError)
    1379           0 :         nError = pDataBaseCollection->GetError();
    1380           0 :     if (nError == errOutOfMemory)
    1381           0 :         return;     // hopeless
    1382           0 :     for( sal_uInt16 i = 0 ; i < pDataBaseCollection->GetCount() ; i++ )
    1383             :     {
    1384           0 :         Sc10DataBaseData* pOldData = pDataBaseCollection->At(i);
    1385           0 :         ScDBData* pNewData = new ScDBData( SC10TOSTRING( pOldData->DataBaseRec.Name ),
    1386             :                                     ( SCTAB ) pOldData->DataBaseRec.Tab,
    1387             :                                     ( SCCOL ) pOldData->DataBaseRec.Block.x1,
    1388             :                                     ( SCROW ) pOldData->DataBaseRec.Block.y1,
    1389             :                                     ( SCCOL ) pOldData->DataBaseRec.Block.x2,
    1390             :                                     ( SCROW ) pOldData->DataBaseRec.Block.y2,
    1391             :                                     true,
    1392           0 :                                     ( sal_Bool) pOldData->DataBaseRec.RowHeader );
    1393           0 :         bool ins = pDoc->GetDBCollection()->getNamedDBs().insert(pNewData);
    1394             :         assert(ins); (void)ins;
    1395             :             //TODO: or can this fail (and need delete pNewData)?
    1396             :     }
    1397             : }
    1398             : 
    1399             : 
    1400           0 : void Sc10Import::LoadTables()
    1401             : {
    1402           0 :     Sc10PageCollection aPageCollection;
    1403             : 
    1404             :     sal_Int16 nTabCount;
    1405           0 :     rStream.ReadInt16( nTabCount );
    1406           0 :     for (sal_Int16 Tab = 0; (Tab < nTabCount) && (nError == 0); Tab++)
    1407             :     {
    1408             :         Sc10PageFormat   PageFormat;
    1409             :         sal_Int16            DataBaseIndex;
    1410             :         Sc10TableProtect TabProtect;
    1411             :         sal_Int16            TabNo;
    1412             :         sal_Char             TabName[128];
    1413             :         sal_uInt16           Display;
    1414             :         sal_uInt8             Visible;
    1415             :         sal_uInt16           ID;
    1416             :         sal_uInt16           DataCount;
    1417             :         sal_uInt16           DataStart;
    1418             :         sal_uInt16           DataEnd;
    1419             :         sal_uInt16           DataValue;
    1420             :         sal_uInt16           Count;
    1421             :         sal_uInt16           i;
    1422             : 
    1423           0 :         lcl_ReadPageFormat(rStream, PageFormat);
    1424             : 
    1425           0 :         sal_uInt16 nAt = aPageCollection.InsertFormat(PageFormat);
    1426           0 :         OUString aPageName = lcl_MakeOldPageStyleFormatName( nAt );
    1427             : 
    1428           0 :         pPrgrsBar->Progress();
    1429             : 
    1430           0 :         rStream.ReadInt16( DataBaseIndex );
    1431             : 
    1432           0 :         lcl_ReadTabProtect(rStream, TabProtect);
    1433             : 
    1434           0 :         ScTableProtection aProtection;
    1435           0 :         aProtection.setProtected(static_cast<bool>(TabProtect.Protect));
    1436           0 :         aProtection.setPassword(SC10TOSTRING(TabProtect.PassWord));
    1437           0 :         pDoc->SetTabProtection(static_cast<SCTAB>(Tab), &aProtection);
    1438             : 
    1439           0 :         rStream.ReadInt16( TabNo );
    1440             : 
    1441             :         sal_uInt8 nLen;
    1442           0 :         rStream.ReadUChar( nLen );
    1443           0 :         rStream.Read(TabName, sizeof(TabName) - 1);
    1444           0 :         if (nLen >= sizeof(TabName))
    1445           0 :             nLen = sizeof(TabName) - 1;
    1446           0 :         TabName[nLen] = 0;
    1447             : 
    1448             : 
    1449           0 :         rStream.ReadUInt16( Display );
    1450             : 
    1451           0 :         if ( Tab == (sal_Int16)nShowTab )
    1452             :         {
    1453           0 :             ScVObjMode  eObjMode = VOBJ_MODE_SHOW;
    1454             : 
    1455           0 :             aSc30ViewOpt.SetOption( VOPT_FORMULAS,    IS_SET(dfFormula,Display) );
    1456           0 :             aSc30ViewOpt.SetOption( VOPT_NULLVALS,    IS_SET(dfZerro,Display) );
    1457           0 :             aSc30ViewOpt.SetOption( VOPT_SYNTAX,      IS_SET(dfSyntax,Display) );
    1458           0 :             aSc30ViewOpt.SetOption( VOPT_NOTES,       IS_SET(dfNoteMark,Display) );
    1459           0 :             aSc30ViewOpt.SetOption( VOPT_VSCROLL,     true );
    1460           0 :             aSc30ViewOpt.SetOption( VOPT_HSCROLL,     true );
    1461           0 :             aSc30ViewOpt.SetOption( VOPT_TABCONTROLS, true );
    1462           0 :             aSc30ViewOpt.SetOption( VOPT_OUTLINER,    true );
    1463           0 :             aSc30ViewOpt.SetOption( VOPT_GRID,        IS_SET(dfGrid,Display) );
    1464             : 
    1465             :             // VOPT_HEADER wird in LoadViewColRowBar() gesetzt
    1466             : 
    1467           0 :             if ( IS_SET(dfObjectAll,Display) )          // Objekte anzeigen
    1468           0 :                 eObjMode = VOBJ_MODE_SHOW;
    1469           0 :             else if ( IS_SET(dfObjectFrame,Display) )   // Objekte als Platzhalter
    1470           0 :                 eObjMode = VOBJ_MODE_SHOW;
    1471           0 :             else if ( IS_SET(dfObjectNone,Display) )    // Objekte nicht anzeigen
    1472           0 :                 eObjMode = VOBJ_MODE_HIDE;
    1473             : 
    1474           0 :             aSc30ViewOpt.SetObjMode( VOBJ_TYPE_OLE,   eObjMode );
    1475           0 :             aSc30ViewOpt.SetObjMode( VOBJ_TYPE_CHART, eObjMode );
    1476           0 :             aSc30ViewOpt.SetObjMode( VOBJ_TYPE_DRAW,  eObjMode );
    1477             :         }
    1478             : 
    1479             : 
    1480           0 :         rStream.ReadUChar( Visible );
    1481             : 
    1482           0 :         nError = rStream.GetError();
    1483           0 :         if (nError != 0) return;
    1484             : 
    1485           0 :         if (TabNo == 0)
    1486           0 :             pDoc->RenameTab(static_cast<SCTAB> (TabNo), SC10TOSTRING( TabName ), false);
    1487             :         else
    1488           0 :             pDoc->InsertTab(SC_TAB_APPEND, SC10TOSTRING( TabName ) );
    1489             : 
    1490           0 :         pDoc->SetPageStyle( static_cast<SCTAB>(Tab), aPageName );
    1491             : 
    1492           0 :         if (Visible == 0) pDoc->SetVisible(static_cast<SCTAB> (TabNo), false);
    1493             : 
    1494             :         // ColWidth
    1495           0 :         rStream.ReadUInt16( ID );
    1496           0 :         if (ID != ColWidthID)
    1497             :         {
    1498             :             OSL_FAIL( "ColWidthID" );
    1499           0 :             nError = errUnknownID;
    1500           0 :             return;
    1501             :         }
    1502           0 :         rStream.ReadUInt16( DataCount );
    1503           0 :         DataStart = 0;
    1504           0 :         for (i=0; i < DataCount; i++)
    1505             :         {
    1506           0 :             rStream.ReadUInt16( DataEnd );
    1507           0 :             rStream.ReadUInt16( DataValue );
    1508           0 :             for (SCCOL j = static_cast<SCCOL>(DataStart); j <= static_cast<SCCOL>(DataEnd); j++) pDoc->SetColWidth(j, static_cast<SCTAB> (TabNo), DataValue);
    1509           0 :             DataStart = DataEnd + 1;
    1510             :         }
    1511           0 :         pPrgrsBar->Progress();
    1512             : 
    1513             :         // ColAttr
    1514           0 :         rStream.ReadUInt16( ID );
    1515           0 :         if (ID != ColAttrID)
    1516             :         {
    1517             :             OSL_FAIL( "ColAttrID" );
    1518           0 :             nError = errUnknownID;
    1519           0 :             return;
    1520             :         }
    1521             : 
    1522           0 :         rStream.ReadUInt16( DataCount );
    1523           0 :         DataStart = 0;
    1524           0 :         for (i=0; i < DataCount; i++)
    1525             :         {
    1526           0 :             rStream.ReadUInt16( DataEnd );
    1527           0 :             rStream.ReadUInt16( DataValue );
    1528           0 :             if (DataValue != 0)
    1529             :             {
    1530           0 :                 bool bPageBreak   = ((DataValue & crfSoftBreak) == crfSoftBreak);
    1531           0 :                 bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
    1532           0 :                 bool bHidden = ((DataValue & crfHidden) == crfHidden);
    1533           0 :                 for (SCCOL k = static_cast<SCCOL>(DataStart); k <= static_cast<SCCOL>(DataEnd); k++)
    1534             :                 {
    1535           0 :                     pDoc->SetColHidden(k, k, static_cast<SCTAB>(TabNo), bHidden);
    1536           0 :                     pDoc->SetColBreak(k, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
    1537             :                 }
    1538             :             }
    1539           0 :             DataStart = DataEnd + 1;
    1540             :         }
    1541           0 :         pPrgrsBar->Progress();
    1542             : 
    1543             :         // RowHeight
    1544           0 :         rStream.ReadUInt16( ID );
    1545           0 :         if (ID != RowHeightID)
    1546             :         {
    1547             :             OSL_FAIL( "RowHeightID" );
    1548           0 :             nError = errUnknownID;
    1549           0 :             return;
    1550             :         }
    1551             : 
    1552           0 :         rStream.ReadUInt16( DataCount );
    1553           0 :         DataStart = 0;
    1554           0 :         for (i=0; i < DataCount; i++)
    1555             :         {
    1556           0 :             rStream.ReadUInt16( DataEnd );
    1557           0 :             rStream.ReadUInt16( DataValue );
    1558           0 :             pDoc->SetRowHeightRange(static_cast<SCROW> (DataStart), static_cast<SCROW> (DataEnd), static_cast<SCTAB> (TabNo), DataValue);
    1559           0 :             DataStart = DataEnd + 1;
    1560             :         }
    1561           0 :         pPrgrsBar->Progress();
    1562             : 
    1563             :         // RowAttr
    1564           0 :         rStream.ReadUInt16( ID );
    1565           0 :         if (ID != RowAttrID)
    1566             :         {
    1567             :             OSL_FAIL( "RowAttrID" );
    1568           0 :             nError = errUnknownID;
    1569           0 :             return;
    1570             :         }
    1571             : 
    1572           0 :         rStream.ReadUInt16( DataCount );
    1573           0 :         DataStart = 0;
    1574           0 :         for (i=0; i < DataCount; i++)
    1575             :         {
    1576           0 :             rStream.ReadUInt16( DataEnd );
    1577           0 :             rStream.ReadUInt16( DataValue );
    1578           0 :             if (DataValue != 0)
    1579             :             {
    1580           0 :                 bool bPageBreak   = ((DataValue & crfSoftBreak) == crfSoftBreak);
    1581           0 :                 bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
    1582           0 :                 bool bHidden      = ((DataValue & crfHidden) == crfHidden);
    1583           0 :                 for (SCROW l = static_cast<SCROW>(DataStart); l <= static_cast<SCROW>(DataEnd); l++)
    1584             :                 {
    1585           0 :                     pDoc->SetRowHidden(l, l, static_cast<SCTAB> (TabNo), bHidden);
    1586           0 :                     pDoc->SetRowBreak(l, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
    1587             :                 }
    1588             :             }
    1589           0 :             DataStart = DataEnd + 1;
    1590             :         }
    1591           0 :         pPrgrsBar->Progress();
    1592             : 
    1593             :         // DataTable
    1594           0 :         rStream.ReadUInt16( ID );
    1595           0 :         if (ID != TableID)
    1596             :         {
    1597             :             OSL_FAIL( "TableID" );
    1598           0 :             nError = errUnknownID;
    1599           0 :             return;
    1600             :         }
    1601           0 :         for (SCCOL Col = 0; (Col <= SC10MAXCOL) && (nError == 0); Col++)
    1602             :         {
    1603           0 :             rStream.ReadUInt16( Count );
    1604           0 :             nError = rStream.GetError();
    1605           0 :             if ((Count != 0) && (nError == 0))
    1606           0 :                 LoadCol(Col, static_cast<SCTAB> (TabNo));
    1607             :         }
    1608             :         OSL_ENSURE( nError == 0, "Stream" );
    1609           0 :     }
    1610           0 :     pPrgrsBar->Progress();
    1611             : 
    1612           0 :     aPageCollection.PutToDoc( pDoc );
    1613             : }
    1614             : 
    1615             : 
    1616           0 : void Sc10Import::LoadCol(SCCOL Col, SCTAB Tab)
    1617             : {
    1618           0 :     LoadColAttr(Col, Tab);
    1619             : 
    1620             :     sal_uInt16 CellCount;
    1621             :     sal_uInt8   CellType;
    1622             :     sal_uInt16 Row;
    1623           0 :     rStream.ReadUInt16( CellCount );
    1624           0 :     SCROW nScCount = static_cast< SCROW >( CellCount );
    1625           0 :     if (nScCount > MAXROW) nError = errUnknownFormat;
    1626           0 :     for (sal_uInt16 i = 0; (i < CellCount) && (nError == 0); i++)
    1627             :     {
    1628           0 :         rStream.ReadUChar( CellType );
    1629           0 :         rStream.ReadUInt16( Row );
    1630           0 :         nError = rStream.GetError();
    1631           0 :         if (nError == 0)
    1632             :         {
    1633           0 :             switch (CellType)
    1634             :             {
    1635             :                 case ctValue :
    1636             :                 {
    1637           0 :                     const SfxPoolItem* pValueFormat = pDoc->GetAttr(Col, static_cast<SCROW> (Row), Tab, ATTR_VALUE_FORMAT);
    1638           0 :                     sal_uLong nFormat = ((SfxUInt32Item*)pValueFormat)->GetValue();
    1639           0 :                     double Value = ScfTools::ReadLongDouble(rStream);
    1640             :                     //rStream.Read(&Value, sizeof(Value));
    1641             : 
    1642             :                     // Achtung hier ist eine Anpassung Notwendig wenn Ihr das Basisdatum aendert
    1643             :                     // In StarCalc 1.0 entspricht 0 dem 01.01.1900
    1644             :                     // if ((nFormat >= 30) && (nFormat <= 35))
    1645             :                     // Value += 0;
    1646           0 :                     if ((nFormat >= 40) && (nFormat <= 45))
    1647           0 :                         Value /= 86400.0;
    1648           0 :                     pDoc->SetValue(Col, static_cast<SCROW> (Row), Tab, Value);
    1649           0 :                     break;
    1650             :                 }
    1651             :                 case ctString :
    1652             :                 {
    1653             :                     sal_uInt8 Len;
    1654             :                     sal_Char s[256];
    1655           0 :                     rStream.ReadUChar( Len );
    1656           0 :                     rStream.Read(s, Len);
    1657           0 :                     s[Len] = 0;
    1658             : 
    1659           0 :                     pDoc->SetString( Col, static_cast<SCROW> (Row), Tab, SC10TOSTRING( s ) );
    1660           0 :                     break;
    1661             :                 }
    1662             :                 case ctFormula :
    1663             :                 {
    1664           0 :                     /*double Value =*/ ScfTools::ReadLongDouble(rStream);
    1665             :                     sal_uInt8 Len;
    1666             :                     sal_Char s[256+1];
    1667           0 :                     rStream.ReadUChar( Len );
    1668           0 :                     rStream.Read(&s[1], Len);
    1669           0 :                     s[0] = '=';
    1670           0 :                     s[Len + 1] = 0;
    1671           0 :                     ScFormulaCell* pCell = new ScFormulaCell( pDoc, ScAddress( Col, static_cast<SCROW> (Row), Tab ) );
    1672           0 :                     pCell->SetHybridFormula( SC10TOSTRING( s ),formula::FormulaGrammar::GRAM_NATIVE );
    1673           0 :                     pDoc->EnsureTable(Tab);
    1674           0 :                     pDoc->SetFormulaCell(ScAddress(Col,Row,Tab), pCell);
    1675           0 :                     break;
    1676             :                 }
    1677             :                 case ctNote :
    1678           0 :                     break;
    1679             :                 default :
    1680           0 :                     nError = errUnknownFormat;
    1681           0 :                     break;
    1682             :             }
    1683             :             sal_uInt16 NoteLen;
    1684           0 :             rStream.ReadUInt16( NoteLen );
    1685           0 :             if (NoteLen != 0)
    1686             :             {
    1687           0 :                 boost::scoped_array<sal_Char> pNote(new sal_Char[NoteLen+1]);
    1688           0 :                 rStream.Read(pNote.get(), NoteLen);
    1689           0 :                 pNote[NoteLen] = 0;
    1690           0 :                 OUString aNoteText( SC10TOSTRING(pNote.get()));
    1691           0 :                 pNote.reset();
    1692           0 :                 ScAddress aPos( Col, static_cast<SCROW>(Row), Tab );
    1693           0 :                 ScNoteUtil::CreateNoteFromString( *pDoc, aPos, aNoteText, false, false );
    1694             :             }
    1695             :         }
    1696           0 :         pPrgrsBar->Progress();
    1697             :     }
    1698           0 : }
    1699             : 
    1700             : 
    1701           0 : void Sc10Import::LoadColAttr(SCCOL Col, SCTAB Tab)
    1702             : {
    1703           0 :     Sc10ColAttr aFont;
    1704           0 :     Sc10ColAttr aAttr;
    1705           0 :     Sc10ColAttr aJustify;
    1706           0 :     Sc10ColAttr aFrame;
    1707           0 :     Sc10ColAttr aRaster;
    1708           0 :     Sc10ColAttr aValue;
    1709           0 :     Sc10ColAttr aColor;
    1710           0 :     Sc10ColAttr aFrameColor;
    1711           0 :     Sc10ColAttr aFlag;
    1712           0 :     Sc10ColAttr aPattern;
    1713             : 
    1714           0 :     if (nError == 0) LoadAttr(aFont);
    1715           0 :     if (nError == 0) LoadAttr(aAttr);
    1716           0 :     if (nError == 0) LoadAttr(aJustify);
    1717           0 :     if (nError == 0) LoadAttr(aFrame);
    1718           0 :     if (nError == 0) LoadAttr(aRaster);
    1719           0 :     if (nError == 0) LoadAttr(aValue);
    1720           0 :     if (nError == 0) LoadAttr(aColor);
    1721           0 :     if (nError == 0) LoadAttr(aFrameColor);
    1722           0 :     if (nError == 0) LoadAttr(aFlag);
    1723           0 :     if (nError == 0) LoadAttr(aPattern);
    1724             : 
    1725           0 :     if (nError == 0)
    1726             :     {
    1727             :         SCROW nStart;
    1728             :         SCROW nEnd;
    1729             :         sal_uInt16 i;
    1730             :         sal_uInt16 nLimit;
    1731             :         sal_uInt16 nValue1;
    1732             :         Sc10ColData *pColData;
    1733             : 
    1734             :         // Font (Name, Size)
    1735           0 :         nStart = 0;
    1736           0 :         nEnd = 0;
    1737           0 :         nLimit = aFont.Count;
    1738           0 :         pColData = aFont.pData;
    1739           0 :         for( i = 0 ; i < nLimit ; i++, pColData++ )
    1740             :         {
    1741           0 :             nEnd = static_cast<SCROW>(pColData->Row);
    1742           0 :             if ((nStart <= nEnd) && (pColData->Value))
    1743             :             {
    1744           0 :                 FontFamily eFam = FAMILY_DONTKNOW;
    1745           0 :                 Sc10FontData* pFont = pFontCollection->At(pColData->Value);
    1746           0 :                 if (pFont)
    1747             :                 {
    1748           0 :                     switch (pFont->PitchAndFamily & 0xF0)
    1749             :                     {
    1750           0 :                         case ffDontCare   : eFam = FAMILY_DONTKNOW;     break;
    1751           0 :                         case ffRoman      : eFam = FAMILY_ROMAN;        break;
    1752           0 :                         case ffSwiss      : eFam = FAMILY_SWISS;        break;
    1753           0 :                         case ffModern     : eFam = FAMILY_MODERN;       break;
    1754           0 :                         case ffScript     : eFam = FAMILY_SCRIPT;       break;
    1755           0 :                         case ffDecorative : eFam = FAMILY_DECORATIVE;   break;
    1756           0 :                         default: eFam = FAMILY_DONTKNOW;        break;
    1757             :                     }
    1758           0 :                     ScPatternAttr aScPattern(pDoc->GetPool());
    1759           0 :                     aScPattern.GetItemSet().Put(SvxFontItem(eFam, SC10TOSTRING( pFont->FaceName ), EMPTY_OUSTRING,
    1760           0 :                         PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ));
    1761           0 :                     aScPattern.GetItemSet().Put(SvxFontHeightItem(std::abs(pFont->Height), 100, ATTR_FONT_HEIGHT ));
    1762           0 :                     pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
    1763             :                 }
    1764             :             }
    1765           0 :             nStart = nEnd + 1;
    1766             :         }
    1767             : 
    1768             :     // Font color
    1769           0 :     nStart = 0;
    1770           0 :     nEnd = 0;
    1771           0 :     nLimit = aColor.Count;
    1772           0 :     pColData = aColor.pData;
    1773           0 :     for( i = 0 ; i < nLimit ; i++, pColData++ )
    1774             :     {
    1775           0 :         nEnd = static_cast<SCROW>(pColData->Row);
    1776           0 :         if ((nStart <= nEnd) && (pColData->Value))
    1777             :         {
    1778           0 :             Color TextColor(COL_BLACK);
    1779           0 :             lcl_ChangeColor((pColData->Value & 0x000F), TextColor);
    1780           0 :             ScPatternAttr aScPattern(pDoc->GetPool());
    1781           0 :             aScPattern.GetItemSet().Put(SvxColorItem(TextColor, ATTR_FONT_COLOR ));
    1782           0 :             pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
    1783             :         }
    1784           0 :         nStart = nEnd + 1;
    1785             :     }
    1786             : 
    1787             :     // Font attributes (Bold, Italic...)
    1788           0 :     nStart = 0;
    1789           0 :     nEnd = 0;
    1790           0 :     nLimit = aAttr.Count;
    1791           0 :     pColData = aAttr.pData;
    1792           0 :     for( i = 0 ; i < nLimit ; i++, pColData++ )
    1793             :     {
    1794           0 :         nEnd = static_cast<SCROW>(pColData->Row);
    1795           0 :         nValue1 = pColData->Value;
    1796           0 :         if ((nStart <= nEnd) && (nValue1))
    1797             :         {
    1798           0 :             ScPatternAttr aScPattern(pDoc->GetPool());
    1799           0 :             if ((nValue1 & atBold) == atBold)
    1800           0 :              aScPattern.GetItemSet().Put(SvxWeightItem(WEIGHT_BOLD, ATTR_FONT_WEIGHT));
    1801           0 :             if ((nValue1 & atItalic) == atItalic)
    1802           0 :              aScPattern.GetItemSet().Put(SvxPostureItem(ITALIC_NORMAL, ATTR_FONT_POSTURE));
    1803           0 :             if ((nValue1 & atUnderline) == atUnderline)
    1804           0 :              aScPattern.GetItemSet().Put(SvxUnderlineItem(UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE));
    1805           0 :             if ((nValue1 & atStrikeOut) == atStrikeOut)
    1806           0 :              aScPattern.GetItemSet().Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, ATTR_FONT_CROSSEDOUT));
    1807           0 :             pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
    1808             :         }
    1809           0 :         nStart = nEnd + 1;
    1810             :     }
    1811             : 
    1812             :     // Cell alignment
    1813           0 :     nStart = 0;
    1814           0 :     nEnd = 0;
    1815           0 :     nLimit = aJustify.Count;
    1816           0 :     pColData = aJustify.pData;
    1817           0 :     for( i = 0 ; i < nLimit ; i++, pColData++ )
    1818             :     {
    1819           0 :         nEnd = static_cast<SCROW>(pColData->Row);
    1820           0 :         nValue1 = pColData->Value;
    1821           0 :         if ((nStart <= nEnd) && (nValue1))
    1822             :         {
    1823           0 :             ScPatternAttr aScPattern(pDoc->GetPool());
    1824           0 :             sal_uInt16 HorJustify = (nValue1 & 0x000F);
    1825           0 :             sal_uInt16 VerJustify = (nValue1 & 0x00F0) >> 4;
    1826           0 :             sal_uInt16 OJustify   = (nValue1 & 0x0F00) >> 8;
    1827           0 :             sal_uInt16 EJustify   = (nValue1 & 0xF000) >> 12;
    1828             : 
    1829           0 :             switch (HorJustify)
    1830             :             {
    1831             :                 case hjLeft:
    1832           0 :                     aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY));
    1833           0 :                     break;
    1834             :                 case hjCenter:
    1835           0 :                     aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY));
    1836           0 :                     break;
    1837             :                 case hjRight:
    1838           0 :                     aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY));
    1839           0 :                     break;
    1840             :             }
    1841             : 
    1842           0 :             switch (VerJustify)
    1843             :             {
    1844             :                 case vjTop:
    1845           0 :                     aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_TOP, ATTR_VER_JUSTIFY));
    1846           0 :                     break;
    1847             :                 case vjCenter:
    1848           0 :                     aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY));
    1849           0 :                     break;
    1850             :                 case vjBottom:
    1851           0 :                     aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_BOTTOM, ATTR_VER_JUSTIFY));
    1852           0 :                     break;
    1853             :             }
    1854             : 
    1855           0 :             if (OJustify & ojWordBreak)
    1856           0 :                 aScPattern.GetItemSet().Put(SfxBoolItem(sal_True));
    1857           0 :             if (OJustify & ojBottomTop)
    1858           0 :                 aScPattern.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE,9000));
    1859           0 :             else if (OJustify & ojTopBottom)
    1860           0 :                 aScPattern.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE,27000));
    1861             : 
    1862           0 :             sal_Int16 Margin = std::max((sal_uInt16)20, (sal_uInt16)(EJustify * 20));
    1863           0 :             if (OJustify & ojBottomTop)
    1864           0 :                 aScPattern.GetItemSet().Put(SvxMarginItem(20, Margin, 20, Margin, ATTR_MARGIN));
    1865             :             else
    1866           0 :                 aScPattern.GetItemSet().Put(SvxMarginItem(Margin, 20, Margin, 20, ATTR_MARGIN));
    1867           0 :             pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
    1868             :         }
    1869           0 :         nStart = nEnd + 1;
    1870             :     }
    1871             :     // Border
    1872           0 :     sal_Bool            bEnd = false;
    1873           0 :     sal_uInt16          nColorIndex = 0;
    1874           0 :     sal_uInt16          nFrameIndex = 0;
    1875             : 
    1876             :     // Special Fix...
    1877           0 :     const sal_uInt32    nHelpMeStart = 100;
    1878           0 :     sal_uInt32          nHelpMe = nHelpMeStart;
    1879           0 :     sal_uInt16          nColorIndexOld = nColorIndex;
    1880           0 :     sal_uInt16          nFrameIndexOld = nColorIndex;
    1881             : 
    1882           0 :     nEnd = 0;
    1883           0 :     nStart = 0;
    1884           0 :     while( !bEnd && nHelpMe )
    1885             :     {
    1886           0 :         pColData = &aFrame.pData[ nFrameIndex ];
    1887             : 
    1888           0 :         sal_uInt16  nValue  = pColData->Value;
    1889           0 :         sal_uInt16  nLeft   = 0;
    1890           0 :         sal_uInt16  nTop    = 0;
    1891           0 :         sal_uInt16  nRight  = 0;
    1892           0 :         sal_uInt16  nBottom = 0;
    1893           0 :         sal_uInt16  fLeft   = ( nValue & 0x000F );
    1894           0 :         sal_uInt16  fTop    = ( nValue & 0x00F0 ) >> 4;
    1895           0 :         sal_uInt16  fRight  = ( nValue & 0x0F00 ) >> 8;
    1896           0 :         sal_uInt16  fBottom = ( nValue & 0xF000 ) >> 12;
    1897             : 
    1898           0 :         if( fLeft > 1 )
    1899           0 :             nLeft = 50;
    1900           0 :         else if( fLeft > 0 )
    1901           0 :             nLeft = 20;
    1902             : 
    1903           0 :         if( fTop > 1 )
    1904           0 :             nTop = 50;
    1905           0 :         else if( fTop > 0 )
    1906           0 :             nTop = 20;
    1907             : 
    1908           0 :         if( fRight > 1 )
    1909           0 :             nRight = 50;
    1910           0 :         else if( fRight > 0 )
    1911           0 :             nRight = 20;
    1912             : 
    1913           0 :         if( fBottom > 1 )
    1914           0 :             nBottom = 50;
    1915           0 :         else if( fBottom > 0 )
    1916           0 :             nBottom = 20;
    1917             : 
    1918           0 :         Color   ColorLeft( COL_BLACK );
    1919           0 :         Color   ColorTop( COL_BLACK );
    1920           0 :         Color   ColorRight( COL_BLACK );
    1921           0 :         Color   ColorBottom( COL_BLACK );
    1922           0 :         sal_uInt16  nFrmColVal  = aFrameColor.pData[ nColorIndex ].Value;
    1923           0 :         SCROW   nFrmColRow  = static_cast<SCROW>(aFrameColor.pData[ nColorIndex ].Row);
    1924           0 :         sal_uInt16  cLeft       = ( nFrmColVal & 0x000F );
    1925           0 :         sal_uInt16  cTop        = ( nFrmColVal & 0x00F0 ) >> 4;
    1926           0 :         sal_uInt16  cRight      = ( nFrmColVal & 0x0F00 ) >> 8;
    1927           0 :         sal_uInt16  cBottom     = ( nFrmColVal & 0xF000 ) >> 12;
    1928             : 
    1929           0 :         lcl_ChangeColor( cLeft, ColorLeft );
    1930           0 :         lcl_ChangeColor( cTop, ColorTop );
    1931           0 :         lcl_ChangeColor( cRight, ColorRight );
    1932           0 :         lcl_ChangeColor( cBottom, ColorBottom );
    1933             : 
    1934           0 :         if( static_cast<SCROW>(pColData->Row) < nFrmColRow )
    1935             :         {
    1936           0 :             nEnd = static_cast<SCROW>(pColData->Row);
    1937           0 :             if( nFrameIndex < ( aFrame.Count - 1 ) )
    1938           0 :                 nFrameIndex++;
    1939             :         }
    1940           0 :         else if( static_cast<SCROW>(pColData->Row) > nFrmColRow )
    1941             :         {
    1942           0 :             nEnd = static_cast<SCROW>(aFrameColor.pData[ nColorIndex ].Row);
    1943           0 :             if( nColorIndex < ( aFrameColor.Count - 1 ) )
    1944           0 :                 nColorIndex++;
    1945             :         }
    1946             :         else
    1947             :         {
    1948           0 :             nEnd = nFrmColRow;
    1949           0 :             if( nFrameIndex < (aFrame.Count - 1 ) )
    1950           0 :                 nFrameIndex++;
    1951           0 :             if( nColorIndex < ( aFrameColor.Count - 1 ) )
    1952           0 :                 nColorIndex++;
    1953             :         }
    1954           0 :         if( ( nStart <= nEnd ) && ( nValue != 0 ) )
    1955             :         {
    1956           0 :             ScPatternAttr   aScPattern(pDoc->GetPool());
    1957           0 :             ::editeng::SvxBorderLine    aLine;
    1958           0 :             SvxBoxItem      aBox( ATTR_BORDER );
    1959             : 
    1960           0 :             aLine.SetWidth( nLeft );
    1961           0 :             aLine.SetColor( ColorLeft );
    1962           0 :             aBox.SetLine( &aLine, BOX_LINE_LEFT );
    1963             : 
    1964           0 :             aLine.SetWidth( nTop );
    1965           0 :             aLine.SetColor( ColorTop );
    1966           0 :             aBox.SetLine( &aLine, BOX_LINE_TOP );
    1967             : 
    1968           0 :             aLine.SetWidth( nRight );
    1969           0 :             aLine.SetColor( ColorRight );
    1970           0 :             aBox.SetLine( &aLine, BOX_LINE_RIGHT );
    1971             : 
    1972           0 :             aLine.SetWidth( nBottom );
    1973           0 :             aLine.SetColor( ColorBottom );
    1974           0 :             aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
    1975             : 
    1976           0 :             aScPattern.GetItemSet().Put( aBox );
    1977           0 :             pDoc->ApplyPatternAreaTab( Col, nStart, Col, nEnd, Tab, aScPattern );
    1978             :         }
    1979           0 :         nStart = nEnd + 1;
    1980             : 
    1981           0 :         bEnd = ( nFrameIndex == ( aFrame.Count - 1 ) ) && ( nColorIndex == ( aFrameColor.Count - 1 ) );
    1982             : 
    1983           0 :         if( nColorIndexOld != nColorIndex || nFrameIndexOld != nFrameIndex )
    1984             :         {
    1985           0 :             nColorIndexOld = nColorIndex;
    1986           0 :             nFrameIndexOld = nFrameIndex;
    1987           0 :             nHelpMe = nHelpMeStart;
    1988             :         }
    1989             :         else
    1990           0 :             nHelpMe--;
    1991             : 
    1992           0 :         pColData++;
    1993             :     }
    1994             : 
    1995             :     // ATTENTION: Code up to here works more or less ... from here I've had enough ! (GT)
    1996             : 
    1997             :     // Background (Color, Raster)
    1998           0 :     sal_uInt16      nRasterIndex = 0;
    1999           0 :     bEnd        = false;
    2000           0 :     nColorIndex = 0;
    2001           0 :     nEnd        = 0;
    2002           0 :     nStart      = 0;
    2003             : 
    2004             :     // Special Fix...
    2005           0 :     nHelpMe     = nHelpMeStart;
    2006           0 :     sal_uInt16      nRasterIndexOld = nRasterIndex;
    2007             : 
    2008           0 :     while( !bEnd && nHelpMe )
    2009             :     {
    2010           0 :         sal_uInt16  nBColor = ( aColor.pData[ nColorIndex ].Value & 0x00F0 ) >> 4;
    2011           0 :         sal_uInt16  nRColor = ( aColor.pData[ nColorIndex ].Value & 0x0F00 ) >> 8;
    2012           0 :         Color   aBColor( COL_BLACK );
    2013             : 
    2014           0 :         lcl_ChangeColor( nBColor, aBColor );
    2015             : 
    2016           0 :         if( nBColor == 0 )
    2017           0 :             aBColor.SetColor( COL_WHITE );
    2018           0 :         else if( nBColor == 15 )
    2019           0 :             aBColor.SetColor( COL_BLACK );
    2020             : 
    2021           0 :         Color   aRColor( COL_BLACK );
    2022             : 
    2023           0 :         lcl_ChangeColor( nRColor, aRColor );
    2024             : 
    2025           0 :         ScPatternAttr aScPattern( pDoc->GetPool() );
    2026             : 
    2027             :         sal_uInt16 nFact;
    2028           0 :         sal_Bool        bSwapCol = false;
    2029           0 :         sal_Bool        bSetItem = sal_True;
    2030           0 :         switch ( aRaster.pData[ nRasterIndex ].Value )
    2031             :         {
    2032           0 :         case raNone:        nFact = 0xffff; bSwapCol = sal_True; bSetItem = (nBColor > 0); break;
    2033           0 :         case raGray12:  nFact = (0xffff / 100) * 12;    break;
    2034           0 :         case raGray25:  nFact = (0xffff / 100) * 25;    break;
    2035           0 :         case raGray50:  nFact = (0xffff / 100) * 50;    break;
    2036           0 :         case raGray75:  nFact = (0xffff / 100) * 75;    break;
    2037           0 :         default:    nFact = 0xffff; bSetItem = (nRColor < 15);
    2038             :         }
    2039           0 :         if ( bSetItem )
    2040             :         {
    2041           0 :             if( bSwapCol )
    2042           0 :                 aScPattern.GetItemSet().Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
    2043             :             else
    2044           0 :                 aScPattern.GetItemSet().Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
    2045             :         }
    2046           0 :         if( aRaster.pData[ nRasterIndex ].Row < aColor.pData[ nColorIndex ].Row )
    2047             :         {
    2048           0 :             nEnd = static_cast<SCROW>(aRaster.pData[ nRasterIndex ].Row);
    2049           0 :             if( nRasterIndex < ( aRaster.Count - 1 ) )
    2050           0 :                 nRasterIndex++;
    2051             :         }
    2052           0 :         else if( aRaster.pData[ nRasterIndex ].Row > aColor.pData[ nColorIndex ].Row )
    2053             :         {
    2054           0 :             nEnd = static_cast<SCROW>(aColor.pData[ nColorIndex ].Row);
    2055           0 :             if( nColorIndex < ( aColor.Count - 1 ) )
    2056           0 :                 nColorIndex++;
    2057             :         }
    2058             :         else
    2059             :         {
    2060           0 :             nEnd = static_cast<SCROW>(aColor.pData[ nColorIndex ].Row);
    2061           0 :             if( nRasterIndex < ( aRaster.Count - 1 ) )
    2062           0 :                 nRasterIndex++;
    2063           0 :             if( nColorIndex < ( aColor.Count - 1 ) )
    2064           0 :                 nColorIndex++;
    2065             :         }
    2066           0 :         if( nStart <= nEnd )
    2067           0 :             pDoc->ApplyPatternAreaTab( Col, nStart, Col, nEnd, Tab, aScPattern );
    2068             : 
    2069           0 :         nStart = nEnd + 1;
    2070             : 
    2071           0 :         bEnd = ( nRasterIndex == ( aRaster.Count - 1 ) ) && ( nColorIndex == ( aColor.Count - 1 ) );
    2072             : 
    2073           0 :         if( nColorIndexOld != nColorIndex || nRasterIndexOld != nRasterIndex )
    2074             :         {
    2075           0 :             nColorIndexOld = nColorIndex;
    2076           0 :             nRasterIndexOld = nRasterIndex;
    2077           0 :             nHelpMe = nHelpMeStart;
    2078             :         }
    2079             :         else
    2080           0 :             nHelpMe--;
    2081             : 
    2082           0 :         nHelpMe--;
    2083           0 :     }
    2084             : 
    2085             :     // Number format
    2086           0 :     nStart = 0;
    2087           0 :     nEnd = 0;
    2088           0 :     nLimit = aValue.Count;
    2089           0 :     pColData = aValue.pData;
    2090           0 :     for (i=0; i<nLimit; i++, pColData++)
    2091             :     {
    2092           0 :         nEnd = static_cast<SCROW>(pColData->Row);
    2093           0 :         nValue1 = pColData->Value;
    2094           0 :         if ((nStart <= nEnd) && (nValue1))
    2095             :         {
    2096           0 :             sal_uLong  nKey    = 0;
    2097           0 :             sal_uInt16 nFormat = (nValue1 & 0x00FF);
    2098           0 :             sal_uInt16 nInfo   = (nValue1 & 0xFF00) >> 8;
    2099           0 :             ChangeFormat(nFormat, nInfo, nKey);
    2100           0 :             ScPatternAttr aScPattern(pDoc->GetPool());
    2101           0 :             aScPattern.GetItemSet().Put(SfxUInt32Item(ATTR_VALUE_FORMAT, (sal_uInt32)nKey));
    2102           0 :             pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
    2103             :         }
    2104           0 :         nStart = nEnd + 1;
    2105             :     }
    2106             : 
    2107             :     // Cell attributes (Protected, hidden...)
    2108           0 :     nStart = 0;
    2109           0 :     nEnd = 0;
    2110           0 :     for (i=0; i<aFlag.Count; i++)
    2111             :     {
    2112           0 :         nEnd = static_cast<SCROW>(aFlag.pData[i].Row);
    2113           0 :         if ((nStart <= nEnd) && (aFlag.pData[i].Value != 0))
    2114             :         {
    2115           0 :             sal_Bool bProtect  = ((aFlag.pData[i].Value & paProtect) == paProtect);
    2116           0 :             sal_Bool bHFormula = ((aFlag.pData[i].Value & paHideFormula) == paHideFormula);
    2117           0 :             sal_Bool bHCell    = ((aFlag.pData[i].Value & paHideAll) == paHideAll);
    2118           0 :             sal_Bool bHPrint   = ((aFlag.pData[i].Value & paHidePrint) == paHidePrint);
    2119           0 :             ScPatternAttr aScPattern(pDoc->GetPool());
    2120           0 :             aScPattern.GetItemSet().Put(ScProtectionAttr(bProtect, bHFormula, bHCell, bHPrint));
    2121           0 :             pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
    2122             :         }
    2123           0 :         nStart = nEnd + 1;
    2124             :     }
    2125             : 
    2126             :     // Cell style
    2127           0 :     nStart = 0;
    2128           0 :     nEnd = 0;
    2129           0 :     ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
    2130           0 :     for (i=0; i<aPattern.Count; i++)
    2131             :     {
    2132           0 :         nEnd = static_cast<SCROW>(aPattern.pData[i].Row);
    2133           0 :         if ((nStart <= nEnd) && (aPattern.pData[i].Value != 0))
    2134             :         {
    2135           0 :             sal_uInt16 nPatternIndex = (aPattern.pData[i].Value & 0x00FF) - 1;
    2136           0 :             Sc10PatternData* pPattern = pPatternCollection->At(nPatternIndex);
    2137           0 :             if (pPattern != NULL)
    2138             :             {
    2139             :                 ScStyleSheet* pStyle = (ScStyleSheet*) pStylePool->Find(
    2140           0 :                                     SC10TOSTRING( pPattern->Name ), SFX_STYLE_FAMILY_PARA);
    2141             : 
    2142           0 :                 if (pStyle != NULL)
    2143           0 :                     pDoc->ApplyStyleAreaTab(Col, nStart, Col, nEnd, Tab, *pStyle);
    2144             :             }
    2145             :         }
    2146           0 :         nStart = nEnd + 1;
    2147             :     }
    2148           0 :   }
    2149           0 : }
    2150             : 
    2151             : 
    2152           0 : void Sc10Import::LoadAttr(Sc10ColAttr& rAttr)
    2153             : {
    2154             :     // rAttr is not reused, otherwise we'd have to delete [] rAttr.pData;
    2155           0 :     rStream.ReadUInt16( rAttr.Count );
    2156           0 :     if (rAttr.Count)
    2157             :     {
    2158           0 :         rAttr.pData = new (::std::nothrow) Sc10ColData[rAttr.Count];
    2159           0 :         if (rAttr.pData != NULL)
    2160             :         {
    2161           0 :             for (sal_uInt16 i = 0; i < rAttr.Count; i++)
    2162             :             {
    2163           0 :                 rStream.ReadUInt16( rAttr.pData[i].Row );
    2164           0 :                 rStream.ReadUInt16( rAttr.pData[i].Value );
    2165             :             }
    2166           0 :             nError = rStream.GetError();
    2167             :         }
    2168             :         else
    2169             :         {
    2170           0 :             nError = errOutOfMemory;
    2171           0 :             rAttr.Count = 0;
    2172             :         }
    2173             :     }
    2174           0 : }
    2175             : 
    2176             : 
    2177           0 : void Sc10Import::ChangeFormat(sal_uInt16 nFormat, sal_uInt16 nInfo, sal_uLong& nKey)
    2178             : {
    2179             :   // Achtung: Die Formate werden nur auf die StarCalc 3.0 internen Formate gemappt
    2180             :   //          Korrekterweise muessten zum Teil neue Formate erzeugt werden (sollte Stephan sich ansehen)
    2181           0 :   nKey = 0;
    2182           0 :   switch (nFormat)
    2183             :   {
    2184             :     case vfStandard :
    2185           0 :      if (nInfo > 0)
    2186           0 :        nKey = 2;
    2187           0 :      break;
    2188             :     case vfMoney :
    2189           0 :      if (nInfo > 0)
    2190           0 :        nKey = 21;
    2191             :      else
    2192           0 :        nKey = 20;
    2193           0 :      break;
    2194             :     case vfThousend :
    2195           0 :      if (nInfo > 0)
    2196           0 :        nKey = 4;
    2197             :      else
    2198           0 :        nKey = 5;
    2199           0 :      break;
    2200             :     case vfPercent :
    2201           0 :      if (nInfo > 0)
    2202           0 :        nKey = 11;
    2203             :      else
    2204           0 :        nKey = 10;
    2205           0 :      break;
    2206             :     case vfExponent :
    2207           0 :      nKey = 60;
    2208           0 :      break;
    2209             :     case vfZerro :
    2210             :      // Achtung kein Aequivalent
    2211           0 :      break;
    2212             :     case vfDate :
    2213           0 :       switch (nInfo)
    2214             :       {
    2215             :         case df_NDMY_Long :
    2216           0 :          nKey = 31;
    2217           0 :          break;
    2218             :         case df_DMY_Long :
    2219           0 :          nKey = 30;
    2220           0 :          break;
    2221             :         case df_MY_Long :
    2222           0 :          nKey = 32;
    2223           0 :          break;
    2224             :         case df_NDM_Long :
    2225           0 :          nKey = 31;
    2226           0 :          break;
    2227             :         case df_DM_Long :
    2228           0 :          nKey = 33;
    2229           0 :          break;
    2230             :         case df_M_Long :
    2231           0 :          nKey = 34;
    2232           0 :          break;
    2233             :         case df_NDMY_Short :
    2234           0 :          nKey = 31;
    2235           0 :          break;
    2236             :         case df_DMY_Short :
    2237           0 :          nKey = 30;
    2238           0 :          break;
    2239             :         case df_MY_Short :
    2240           0 :          nKey = 32;
    2241           0 :          break;
    2242             :         case df_NDM_Short :
    2243           0 :          nKey = 31;
    2244           0 :          break;
    2245             :         case df_DM_Short :
    2246           0 :          nKey = 33;
    2247           0 :          break;
    2248             :         case df_M_Short :
    2249           0 :          nKey = 34;
    2250           0 :          break;
    2251             :         case df_Q_Long :
    2252           0 :          nKey = 35;
    2253           0 :          break;
    2254             :         case df_Q_Short :
    2255           0 :          nKey = 35;
    2256           0 :          break;
    2257             :         default :
    2258           0 :          nKey = 30;
    2259           0 :          break;
    2260             :       }
    2261           0 :       break;
    2262             :     case vfTime :
    2263           0 :      switch (nInfo)
    2264             :      {
    2265             :        case tf_HMS_Long :
    2266           0 :         nKey = 41;
    2267           0 :         break;
    2268             :        case tf_HM_Long :
    2269           0 :         nKey = 40;
    2270           0 :         break;
    2271             :        case tf_HMS_Short :
    2272           0 :         nKey = 43;
    2273           0 :         break;
    2274             :        case tf_HM_Short :
    2275           0 :         nKey = 42;
    2276           0 :         break;
    2277             :        default :
    2278           0 :         nKey = 41;
    2279           0 :         break;
    2280             :      }
    2281           0 :      break;
    2282             :     case vfBoolean :
    2283           0 :      nKey = 99;
    2284           0 :      break;
    2285             :     case vfStandardRed :
    2286           0 :      if (nInfo > 0)
    2287           0 :        nKey = 2;
    2288           0 :      break;
    2289             :     case vfMoneyRed :
    2290           0 :      if (nInfo > 0)
    2291           0 :        nKey = 23;
    2292             :      else
    2293           0 :        nKey = 22;
    2294           0 :      break;
    2295             :     case vfThousendRed :
    2296           0 :      if (nInfo > 0)
    2297           0 :        nKey = 4;
    2298             :      else
    2299           0 :        nKey = 5;
    2300           0 :      break;
    2301             :     case vfPercentRed :
    2302           0 :      if (nInfo > 0)
    2303           0 :        nKey = 11;
    2304             :      else
    2305           0 :        nKey = 10;
    2306           0 :      break;
    2307             :     case vfExponentRed :
    2308           0 :      nKey = 60;
    2309           0 :      break;
    2310             :     case vfFormula :
    2311           0 :      break;
    2312             :     case vfString :
    2313           0 :      break;
    2314             :     default :
    2315           0 :      break;
    2316             :   }
    2317           0 : }
    2318             : 
    2319             : 
    2320           0 : void Sc10Import::LoadObjects()
    2321             : {
    2322             :   sal_uInt16 ID;
    2323           0 :   rStream.ReadUInt16( ID );
    2324           0 :   if (rStream.IsEof()) return;
    2325           0 :   if (ID == ObjectID)
    2326             :   {
    2327             :     sal_uInt16 nAnz;
    2328           0 :     rStream.ReadUInt16( nAnz );
    2329             :     sal_Char Reserved[32];
    2330           0 :     rStream.Read(Reserved, sizeof(Reserved));
    2331           0 :     nError = rStream.GetError();
    2332           0 :     if ((nAnz > 0) && (nError == 0))
    2333             :     {
    2334             :       sal_uInt8 ObjectType;
    2335             :       Sc10GraphHeader GraphHeader;
    2336           0 :       sal_Bool IsOleObject = false; // Achtung dies ist nur ein Notnagel
    2337           0 :       for (sal_uInt16 i = 0; (i < nAnz) && (nError == 0) && !rStream.IsEof() && !IsOleObject; i++)
    2338             :       {
    2339           0 :         rStream.ReadUChar( ObjectType );
    2340           0 :         lcl_ReadGraphHeader(rStream, GraphHeader);
    2341             : 
    2342           0 :         double nPPTX = ScGlobal::nScreenPPTX;
    2343           0 :         double nPPTY = ScGlobal::nScreenPPTY;
    2344             : 
    2345           0 :         long nStartX = 0;
    2346           0 :         for (SCsCOL nX=0; nX<GraphHeader.CarretX; nX++)
    2347           0 :             nStartX += pDoc->GetColWidth(nX, static_cast<SCTAB>(GraphHeader.CarretZ));
    2348           0 :         nStartX = (long) ( nStartX * HMM_PER_TWIPS );
    2349           0 :         nStartX += (long) ( GraphHeader.x / nPPTX * HMM_PER_TWIPS );
    2350           0 :         long nSizeX = (long) ( GraphHeader.w / nPPTX * HMM_PER_TWIPS );
    2351             :         long nStartY = pDoc->GetRowHeight( 0,
    2352             :                 static_cast<SCsROW>(GraphHeader.CarretY) - 1,
    2353           0 :                 static_cast<SCTAB>(GraphHeader.CarretZ));
    2354           0 :         nStartY = (long) ( nStartY * HMM_PER_TWIPS );
    2355           0 :         nStartY += (long) ( GraphHeader.y / nPPTY * HMM_PER_TWIPS );
    2356           0 :         long nSizeY = (long) ( GraphHeader.h / nPPTY * HMM_PER_TWIPS );
    2357             : 
    2358           0 :         switch (ObjectType)
    2359             :         {
    2360             :           case otOle :
    2361             :            // Achtung hier muss sowas wie OleLoadFromStream passieren
    2362           0 :            IsOleObject = sal_True;
    2363           0 :            break;
    2364             :           case otImage :
    2365             :           {
    2366             :            Sc10ImageHeader ImageHeader;
    2367           0 :            lcl_ReadImageHeaer(rStream, ImageHeader);
    2368             : 
    2369             :            // Achtung nun kommen die Daten (Bitmap oder Metafile)
    2370             :            // Typ = 1 Device Dependend Bitmap DIB
    2371             :            // Typ = 2 MetaFile
    2372           0 :            rStream.SeekRel(ImageHeader.Size);
    2373             : 
    2374           0 :             if( ImageHeader.Typ != 1 && ImageHeader.Typ != 2 )
    2375           0 :                 nError = errUnknownFormat;
    2376           0 :            break;
    2377             :           }
    2378             :           case otChart :
    2379             :           {
    2380             :             Sc10ChartHeader ChartHeader;
    2381             :             Sc10ChartSheetData ChartSheetData;
    2382           0 :             Sc10ChartTypeData* pTypeData = new (::std::nothrow) Sc10ChartTypeData;
    2383           0 :             if (!pTypeData)
    2384           0 :                 nError = errOutOfMemory;
    2385             :             else
    2386             :             {
    2387           0 :                 lcl_ReadChartHeader(rStream, ChartHeader);
    2388             : 
    2389             :                 //! altes Metafile verwenden ??
    2390           0 :                 rStream.SeekRel(ChartHeader.Size);
    2391             : 
    2392           0 :                 lcl_ReadChartSheetData(rStream, ChartSheetData);
    2393             : 
    2394           0 :                 lcl_ReadChartTypeData(rStream, *pTypeData);
    2395             : 
    2396           0 :                 Rectangle aRect( Point(nStartX,nStartY), Size(nSizeX,nSizeY) );
    2397             :                 Sc10InsertObject::InsertChart( pDoc, static_cast<SCTAB>(GraphHeader.CarretZ), aRect,
    2398             :                         static_cast<SCTAB>(GraphHeader.CarretZ),
    2399             :                         ChartSheetData.DataX1, ChartSheetData.DataY1,
    2400           0 :                         ChartSheetData.DataX2, ChartSheetData.DataY2 );
    2401             : 
    2402           0 :                 delete pTypeData;
    2403             :             }
    2404             :           }
    2405           0 :           break;
    2406             :           default :
    2407           0 :            nError = errUnknownFormat;
    2408           0 :            break;
    2409             :         }
    2410           0 :         nError = rStream.GetError();
    2411             :       }
    2412             :     }
    2413             :   }
    2414             :   else
    2415             :   {
    2416             :     OSL_FAIL( "ObjectID" );
    2417           0 :     nError = errUnknownID;
    2418             :   }
    2419             : }
    2420             : 
    2421           0 : FltError ScFormatFilterPluginImpl::ScImportStarCalc10( SvStream& rStream, ScDocument* pDocument )
    2422             : {
    2423           0 :     rStream.Seek( 0UL );
    2424           0 :     Sc10Import  aImport( rStream, pDocument );
    2425           0 :     return ( FltError ) aImport.Import();
    2426          18 : }
    2427             : 
    2428             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10