1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "scitems.hxx"
21 #include <editeng/eeitem.hxx>
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>
51 #include "patattr.hxx"
52 #include "docpool.hxx"
53 #include "document.hxx"
54 #include "collect.hxx"
55 #include "rangenam.hxx"
57 #include "stlsheet.hxx"
58 #include "stlpool.hxx"
61 #include "formulacell.hxx"
63 #include "docoptio.hxx"
64 #include "viewopti.hxx"
66 #include "globstr.hrc"
68 #include "tabprotection.hxx"
70 #include "fprogressbar.hxx"
71 #include <boost/scoped_array.hpp>
73 using namespace com::sun::star
;
75 #define DEFCHARSET RTL_TEXTENCODING_MS_1252
77 #define SC10TOSTRING(p) OUString((p), strlen(p), DEFCHARSET)
79 const SCCOL SC10MAXCOL
= 255; // #i85906# don't try to load more columns than there are in the file
81 /** Those strings are used with SC10TOSTRING() and strcmp() and such, hence
82 need to be 0-terminated. */
83 static void lcl_ReadFixedString( SvStream
& rStream
, void* pData
, size_t nLen
)
85 sal_Char
* pBuf
= static_cast<sal_Char
*>(pData
);
90 rStream
.Read( pBuf
, nLen
);
95 static void lcl_ReadFileHeader(SvStream
& rStream
, Sc10FileHeader
& rFileHeader
)
97 lcl_ReadFixedString( rStream
, &rFileHeader
.CopyRight
, sizeof(rFileHeader
.CopyRight
));
98 rStream
.ReadUInt16( rFileHeader
.Version
);
99 rStream
.Read(&rFileHeader
.Reserved
, sizeof(rFileHeader
.Reserved
));
102 static void lcl_ReadTabProtect(SvStream
& rStream
, Sc10TableProtect
& rProtect
)
104 lcl_ReadFixedString( rStream
, &rProtect
.PassWord
, sizeof(rProtect
.PassWord
));
105 rStream
.ReadUInt16( rProtect
.Flags
);
106 rStream
.ReadUChar( rProtect
.Protect
);
109 static void lcl_ReadSheetProtect(SvStream
& rStream
, Sc10SheetProtect
& rProtect
)
111 lcl_ReadFixedString( rStream
, &rProtect
.PassWord
, sizeof(rProtect
.PassWord
));
112 rStream
.ReadUInt16( rProtect
.Flags
);
113 rStream
.ReadUChar( rProtect
.Protect
);
116 static void lcl_ReadRGB(SvStream
& rStream
, Sc10Color
& rColor
)
118 rStream
.ReadUChar( rColor
.Dummy
);
119 rStream
.ReadUChar( rColor
.Blue
);
120 rStream
.ReadUChar( rColor
.Green
);
121 rStream
.ReadUChar( rColor
.Red
);
124 static void lcl_ReadPalette(SvStream
& rStream
, Sc10Color
* pPalette
)
126 for (sal_uInt16 i
= 0; i
< 16; i
++)
127 lcl_ReadRGB(rStream
, pPalette
[i
]);
130 static void lcl_ReadValueFormat(SvStream
& rStream
, Sc10ValueFormat
& rFormat
)
132 rStream
.ReadUChar( rFormat
.Format
);
133 rStream
.ReadUChar( rFormat
.Info
);
136 static void lcl_ReadLogFont(SvStream
& rStream
, Sc10LogFont
& rFont
)
138 rStream
.ReadInt16( rFont
.lfHeight
);
139 rStream
.ReadInt16( rFont
.lfWidth
);
140 rStream
.ReadInt16( rFont
.lfEscapement
);
141 rStream
.ReadInt16( rFont
.lfOrientation
);
142 rStream
.ReadInt16( rFont
.lfWeight
);
143 rStream
.ReadUChar( rFont
.lfItalic
);
144 rStream
.ReadUChar( rFont
.lfUnderline
);
145 rStream
.ReadUChar( rFont
.lfStrikeOut
);
146 rStream
.ReadUChar( rFont
.lfCharSet
);
147 rStream
.ReadUChar( rFont
.lfOutPrecision
);
148 rStream
.ReadUChar( rFont
.lfClipPrecision
);
149 rStream
.ReadUChar( rFont
.lfQuality
);
150 rStream
.ReadUChar( rFont
.lfPitchAndFamily
);
151 lcl_ReadFixedString( rStream
, &rFont
.lfFaceName
, sizeof(rFont
.lfFaceName
));
154 static void lcl_ReadBlockRect(SvStream
& rStream
, Sc10BlockRect
& rBlock
)
156 rStream
.ReadInt16( rBlock
.x1
);
157 rStream
.ReadInt16( rBlock
.y1
);
158 rStream
.ReadInt16( rBlock
.x2
);
159 rStream
.ReadInt16( rBlock
.y2
);
162 static void lcl_ReadHeadFootLine(SvStream
& rStream
, Sc10HeadFootLine
& rLine
)
164 lcl_ReadFixedString( rStream
, &rLine
.Title
, sizeof(rLine
.Title
));
165 lcl_ReadLogFont(rStream
, rLine
.LogFont
);
166 rStream
.ReadUChar( rLine
.HorJustify
);
167 rStream
.ReadUChar( rLine
.VerJustify
);
168 rStream
.ReadUInt16( rLine
.Raster
);
169 rStream
.ReadUInt16( rLine
.Frame
);
170 lcl_ReadRGB(rStream
, rLine
.TextColor
);
171 lcl_ReadRGB(rStream
, rLine
.BackColor
);
172 lcl_ReadRGB(rStream
, rLine
.RasterColor
);
173 rStream
.ReadUInt16( rLine
.FrameColor
);
174 rStream
.ReadUInt16( rLine
.Reserved
);
177 static void lcl_ReadPageFormat(SvStream
& rStream
, Sc10PageFormat
& rFormat
)
179 lcl_ReadHeadFootLine(rStream
, rFormat
.HeadLine
);
180 lcl_ReadHeadFootLine(rStream
, rFormat
.FootLine
);
181 rStream
.ReadInt16( rFormat
.Orientation
);
182 rStream
.ReadInt16( rFormat
.Width
);
183 rStream
.ReadInt16( rFormat
.Height
);
184 rStream
.ReadInt16( rFormat
.NonPrintableX
);
185 rStream
.ReadInt16( rFormat
.NonPrintableY
);
186 rStream
.ReadInt16( rFormat
.Left
);
187 rStream
.ReadInt16( rFormat
.Top
);
188 rStream
.ReadInt16( rFormat
.Right
);
189 rStream
.ReadInt16( rFormat
.Bottom
);
190 rStream
.ReadInt16( rFormat
.Head
);
191 rStream
.ReadInt16( rFormat
.Foot
);
192 rStream
.ReadUChar( rFormat
.HorCenter
);
193 rStream
.ReadUChar( rFormat
.VerCenter
);
194 rStream
.ReadUChar( rFormat
.PrintGrid
);
195 rStream
.ReadUChar( rFormat
.PrintColRow
);
196 rStream
.ReadUChar( rFormat
.PrintNote
);
197 rStream
.ReadUChar( rFormat
.TopBottomDir
);
198 lcl_ReadFixedString( rStream
, &rFormat
.PrintAreaName
, sizeof(rFormat
.PrintAreaName
));
199 lcl_ReadBlockRect(rStream
, rFormat
.PrintArea
);
200 rStream
.Read(&rFormat
.PrnZoom
, sizeof(rFormat
.PrnZoom
));
201 rStream
.ReadInt16( rFormat
.FirstPageNo
);
202 rStream
.ReadInt16( rFormat
.RowRepeatStart
);
203 rStream
.ReadInt16( rFormat
.RowRepeatEnd
);
204 rStream
.ReadInt16( rFormat
.ColRepeatStart
);
205 rStream
.ReadInt16( rFormat
.ColRepeatEnd
);
206 rStream
.Read(&rFormat
.Reserved
, sizeof(rFormat
.Reserved
));
209 static void lcl_ReadGraphHeader(SvStream
& rStream
, Sc10GraphHeader
& rHeader
)
211 rStream
.ReadUChar( rHeader
.Typ
);
212 rStream
.ReadInt16( rHeader
.CarretX
);
213 rStream
.ReadInt16( rHeader
.CarretY
);
214 rStream
.ReadInt16( rHeader
.CarretZ
);
215 rStream
.ReadInt32( rHeader
.x
);
216 rStream
.ReadInt32( rHeader
.y
);
217 rStream
.ReadInt32( rHeader
.w
);
218 rStream
.ReadInt32( rHeader
.h
);
219 rStream
.ReadUChar( rHeader
.IsRelPos
);
220 rStream
.ReadUChar( rHeader
.DoPrint
);
221 rStream
.ReadUInt16( rHeader
.FrameType
);
222 rStream
.ReadUChar( rHeader
.IsTransparent
);
223 lcl_ReadRGB(rStream
, rHeader
.FrameColor
);
224 lcl_ReadRGB(rStream
, rHeader
.BackColor
);
225 rStream
.Read(&rHeader
.Reserved
, sizeof(rHeader
.Reserved
));
228 static void lcl_ReadImageHeaer(SvStream
& rStream
, Sc10ImageHeader
& rHeader
)
230 lcl_ReadFixedString( rStream
, &rHeader
.FileName
, sizeof(rHeader
.FileName
));
231 rStream
.ReadInt16( rHeader
.Typ
);
232 rStream
.ReadUChar( rHeader
.Linked
);
233 rStream
.ReadInt16( rHeader
.x1
);
234 rStream
.ReadInt16( rHeader
.y1
);
235 rStream
.ReadInt16( rHeader
.x2
);
236 rStream
.ReadInt16( rHeader
.y2
);
237 rStream
.ReadUInt32( rHeader
.Size
);
240 static void lcl_ReadChartHeader(SvStream
& rStream
, Sc10ChartHeader
& rHeader
)
242 rStream
.ReadInt16( rHeader
.MM
);
243 rStream
.ReadInt16( rHeader
.xExt
);
244 rStream
.ReadInt16( rHeader
.yExt
);
245 rStream
.ReadUInt32( rHeader
.Size
);
248 static void lcl_ReadChartSheetData(SvStream
& rStream
, Sc10ChartSheetData
& rSheetData
)
250 rStream
.ReadUChar( rSheetData
.HasTitle
);
251 rStream
.ReadInt16( rSheetData
.TitleX
);
252 rStream
.ReadInt16( rSheetData
.TitleY
);
253 rStream
.ReadUChar( rSheetData
.HasSubTitle
);
254 rStream
.ReadInt16( rSheetData
.SubTitleX
);
255 rStream
.ReadInt16( rSheetData
.SubTitleY
);
256 rStream
.ReadUChar( rSheetData
.HasLeftTitle
);
257 rStream
.ReadInt16( rSheetData
.LeftTitleX
);
258 rStream
.ReadInt16( rSheetData
.LeftTitleY
);
259 rStream
.ReadUChar( rSheetData
.HasLegend
);
260 rStream
.ReadInt16( rSheetData
.LegendX1
);
261 rStream
.ReadInt16( rSheetData
.LegendY1
);
262 rStream
.ReadInt16( rSheetData
.LegendX2
);
263 rStream
.ReadInt16( rSheetData
.LegendY2
);
264 rStream
.ReadUChar( rSheetData
.HasLabel
);
265 rStream
.ReadInt16( rSheetData
.LabelX1
);
266 rStream
.ReadInt16( rSheetData
.LabelY1
);
267 rStream
.ReadInt16( rSheetData
.LabelX2
);
268 rStream
.ReadInt16( rSheetData
.LabelY2
);
269 rStream
.ReadInt16( rSheetData
.DataX1
);
270 rStream
.ReadInt16( rSheetData
.DataY1
);
271 rStream
.ReadInt16( rSheetData
.DataX2
);
272 rStream
.ReadInt16( rSheetData
.DataY2
);
273 rStream
.Read(&rSheetData
.Reserved
, sizeof(rSheetData
.Reserved
));
276 static void lcl_ReadChartTypeData(SvStream
& rStream
, Sc10ChartTypeData
& rTypeData
)
278 rStream
.ReadInt16( rTypeData
.NumSets
);
279 rStream
.ReadInt16( rTypeData
.NumPoints
);
280 rStream
.ReadInt16( rTypeData
.DrawMode
);
281 rStream
.ReadInt16( rTypeData
.GraphType
);
282 rStream
.ReadInt16( rTypeData
.GraphStyle
);
283 lcl_ReadFixedString( rStream
, &rTypeData
.GraphTitle
, sizeof(rTypeData
.GraphTitle
));
284 lcl_ReadFixedString( rStream
, &rTypeData
.BottomTitle
, sizeof(rTypeData
.BottomTitle
));
286 for (i
= 0; i
< 256; i
++)
287 rStream
.ReadInt16( rTypeData
.SymbolData
[i
] );
288 for (i
= 0; i
< 256; i
++)
289 rStream
.ReadInt16( rTypeData
.ColorData
[i
] );
290 for (i
= 0; i
< 256; i
++)
291 rStream
.ReadInt16( rTypeData
.ThickLines
[i
] );
292 for (i
= 0; i
< 256; i
++)
293 rStream
.ReadInt16( rTypeData
.PatternData
[i
] );
294 for (i
= 0; i
< 256; i
++)
295 rStream
.ReadInt16( rTypeData
.LinePatternData
[i
] );
296 for (i
= 0; i
< 11; i
++)
297 rStream
.ReadInt16( rTypeData
.NumGraphStyles
[i
] );
298 rStream
.ReadInt16( rTypeData
.ShowLegend
);
299 for (i
= 0; i
< 256; i
++)
300 lcl_ReadFixedString( rStream
, &rTypeData
.LegendText
[i
], sizeof(Sc10ChartText
));
301 rStream
.ReadInt16( rTypeData
.ExplodePie
);
302 rStream
.ReadInt16( rTypeData
.FontUse
);
303 for (i
= 0; i
< 5; i
++)
304 rStream
.ReadInt16( rTypeData
.FontFamily
[i
] );
305 for (i
= 0; i
< 5; i
++)
306 rStream
.ReadInt16( rTypeData
.FontStyle
[i
] );
307 for (i
= 0; i
< 5; i
++)
308 rStream
.ReadInt16( rTypeData
.FontSize
[i
] );
309 rStream
.ReadInt16( rTypeData
.GridStyle
);
310 rStream
.ReadInt16( rTypeData
.Labels
);
311 rStream
.ReadInt16( rTypeData
.LabelEvery
);
312 for (i
= 0; i
< 50; i
++)
313 lcl_ReadFixedString( rStream
, &rTypeData
.LabelText
[i
], sizeof(Sc10ChartText
));
314 lcl_ReadFixedString( rStream
, &rTypeData
.LeftTitle
, sizeof(rTypeData
.LeftTitle
));
315 rStream
.Read(&rTypeData
.Reserved
, sizeof(rTypeData
.Reserved
));
318 static double lcl_PascalToDouble(sal_Char
* tp6
)
320 sal_uInt8
* pnUnsigned
= reinterpret_cast< sal_uInt8
* >( tp6
);
322 sal_uInt8 be
= pnUnsigned
[ 0 ];
323 // lower 16 bits of mantissa
324 sal_uInt16 v1
= static_cast< sal_uInt16
>( pnUnsigned
[ 2 ] * 256 + pnUnsigned
[ 1 ] );
325 // next 16 bits of mantissa
326 sal_uInt16 v2
= static_cast< sal_uInt16
>( pnUnsigned
[ 4 ] * 256 + pnUnsigned
[ 3 ] );
327 // upper 7 bits of mantissa
328 sal_uInt8 v3
= static_cast< sal_uInt8
>( pnUnsigned
[ 5 ] & 0x7F );
330 bool s
= (pnUnsigned
[ 5 ] & 0x80) != 0;
334 return (((((128 + v3
) * 65536.0) + v2
) * 65536.0 + v1
) *
335 ldexp ((s
? -1.0 : 1.0), be
- (129+39)));
338 static void lcl_ChangeColor( sal_uInt16 nIndex
, Color
& rColor
)
344 case 1: aCol
= COL_RED
; break;
345 case 2: aCol
= COL_GREEN
; break;
346 case 3: aCol
= COL_BROWN
; break;
347 case 4: aCol
= COL_BLUE
; break;
348 case 5: aCol
= COL_MAGENTA
; break;
349 case 6: aCol
= COL_CYAN
; break;
350 case 7: aCol
= COL_GRAY
; break;
351 case 8: aCol
= COL_LIGHTGRAY
; break;
352 case 9: aCol
= COL_LIGHTRED
; break;
353 case 10: aCol
= COL_LIGHTGREEN
; break;
354 case 11: aCol
= COL_YELLOW
; break;
355 case 12: aCol
= COL_LIGHTBLUE
; break;
356 case 13: aCol
= COL_LIGHTMAGENTA
; break;
357 case 14: aCol
= COL_LIGHTCYAN
; break;
358 case 15: aCol
= COL_WHITE
; break;
359 default: aCol
= COL_BLACK
;
362 rColor
.SetColor( aCol
);
365 static OUString
lcl_MakeOldPageStyleFormatName( sal_uInt16 i
)
367 OUString aName
= ScGlobal::GetRscString( STR_PAGESTYLE
) + " " + OUString::number( i
+ 1 );
371 template < typename T
> sal_uLong
insert_new( ScCollection
* pCollection
, SvStream
& rStream
)
373 T
* pData
= new (::std::nothrow
) T( rStream
);
374 sal_uLong nError
= rStream
.GetError();
380 pCollection
->Insert( pData
);
383 nError
= errOutOfMemory
;
389 Sc10FontData::Sc10FontData(SvStream
& rStream
)
394 rStream
.ReadInt16( Height
);
395 rStream
.ReadUChar( CharSet
);
396 rStream
.ReadUChar( PitchAndFamily
);
398 rStream
.ReadUInt16( nLen
);
399 if (nLen
< sizeof(FaceName
))
400 rStream
.Read(FaceName
, nLen
);
402 rStream
.SetError(ERRCODE_IO_WRONGFORMAT
);
405 Sc10FontCollection::Sc10FontCollection(SvStream
& rStream
)
410 rStream
.ReadUInt16( ID
);
414 rStream
.ReadUInt16( nAnz
);
415 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
417 nError
= insert_new
<Sc10FontData
>( this, rStream
);
422 OSL_FAIL( "FontID" );
423 nError
= errUnknownID
;
429 Sc10NameData::Sc10NameData(SvStream
& rStream
)
432 rStream
.ReadUChar( nLen
);
433 rStream
.Read(Name
, sizeof(Name
) - 1);
434 if (nLen
>= sizeof(Name
))
435 nLen
= sizeof(Name
) - 1;
438 rStream
.ReadUChar( nLen
);
439 rStream
.Read(Reference
, sizeof(Reference
) - 1);
440 if (nLen
>= sizeof(Reference
))
441 nLen
= sizeof(Reference
) - 1;
443 rStream
.Read(Reserved
, sizeof(Reserved
));
446 Sc10NameCollection::Sc10NameCollection(SvStream
& rStream
) :
451 rStream
.ReadUInt16( ID
);
455 rStream
.ReadUInt16( nAnz
);
456 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
458 nError
= insert_new
<Sc10NameData
>( this, rStream
);
463 OSL_FAIL( "NameID" );
464 nError
= errUnknownID
;
469 Sc10PatternData::Sc10PatternData(SvStream
& rStream
)
479 memset(Name
, 0, sizeof(Name
));
480 memset(Reserved
, 0, sizeof(Reserved
));
481 lcl_ReadFixedString( rStream
, Name
, sizeof(Name
));
482 lcl_ReadValueFormat(rStream
, ValueFormat
);
483 lcl_ReadLogFont(rStream
, LogFont
);
485 rStream
.ReadUInt16( Attr
);
486 rStream
.ReadUInt16( Justify
);
487 rStream
.ReadUInt16( Frame
);
488 rStream
.ReadUInt16( Raster
);
489 rStream
.ReadUInt16( nColor
);
490 rStream
.ReadUInt16( FrameColor
);
491 rStream
.ReadUInt16( Flags
);
492 rStream
.ReadUInt16( FormatFlags
);
493 rStream
.Read(Reserved
, sizeof(Reserved
));
496 Sc10PatternCollection::Sc10PatternCollection(SvStream
& rStream
) :
501 rStream
.ReadUInt16( ID
);
505 rStream
.ReadUInt16( nAnz
);
506 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
508 nError
= insert_new
<Sc10PatternData
>( this, rStream
);
513 OSL_FAIL( "PatternID" );
514 nError
= errUnknownID
;
520 Sc10DataBaseData::Sc10DataBaseData(SvStream
& rStream
)
522 lcl_ReadFixedString( rStream
, &DataBaseRec
.Name
, sizeof(DataBaseRec
.Name
));
523 rStream
.ReadInt16( DataBaseRec
.Tab
);
524 lcl_ReadBlockRect(rStream
, DataBaseRec
.Block
);
525 rStream
.ReadUChar( DataBaseRec
.RowHeader
);
526 rStream
.ReadInt16( DataBaseRec
.SortField0
);
527 rStream
.ReadUChar( DataBaseRec
.SortUpOrder0
);
528 rStream
.ReadInt16( DataBaseRec
.SortField1
);
529 rStream
.ReadUChar( DataBaseRec
.SortUpOrder1
);
530 rStream
.ReadInt16( DataBaseRec
.SortField2
);
531 rStream
.ReadUChar( DataBaseRec
.SortUpOrder2
);
532 rStream
.ReadUChar( DataBaseRec
.IncludeFormat
);
534 rStream
.ReadInt16( DataBaseRec
.QueryField0
);
535 rStream
.ReadInt16( DataBaseRec
.QueryOp0
);
536 rStream
.ReadUChar( DataBaseRec
.QueryByString0
);
537 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString0
, sizeof(DataBaseRec
.QueryString0
));
538 DataBaseRec
.QueryValue0
= ScfTools::ReadLongDouble(rStream
);
540 rStream
.ReadInt16( DataBaseRec
.QueryConnect1
);
541 rStream
.ReadInt16( DataBaseRec
.QueryField1
);
542 rStream
.ReadInt16( DataBaseRec
.QueryOp1
);
543 rStream
.ReadUChar( DataBaseRec
.QueryByString1
);
544 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString1
, sizeof(DataBaseRec
.QueryString1
));
545 DataBaseRec
.QueryValue1
= ScfTools::ReadLongDouble(rStream
);
547 rStream
.ReadInt16( DataBaseRec
.QueryConnect2
);
548 rStream
.ReadInt16( DataBaseRec
.QueryField2
);
549 rStream
.ReadInt16( DataBaseRec
.QueryOp2
);
550 rStream
.ReadUChar( DataBaseRec
.QueryByString2
);
551 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString2
, sizeof(DataBaseRec
.QueryString2
));
552 DataBaseRec
.QueryValue2
= ScfTools::ReadLongDouble(rStream
);
555 Sc10DataBaseCollection::Sc10DataBaseCollection(SvStream
& rStream
) :
560 rStream
.ReadUInt16( ID
);
561 if (ID
== DataBaseID
)
563 lcl_ReadFixedString( rStream
, ActName
, sizeof(ActName
));
565 rStream
.ReadUInt16( nAnz
);
566 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
568 nError
= insert_new
<Sc10DataBaseData
>( this, rStream
);
573 OSL_FAIL( "DataBaseID" );
574 nError
= errUnknownID
;
578 bool Sc10LogFont::operator==( const Sc10LogFont
& rData
) const
580 return !strcmp( lfFaceName
, rData
.lfFaceName
)
581 && lfHeight
== rData
.lfHeight
582 && lfWidth
== rData
.lfWidth
583 && lfEscapement
== rData
.lfEscapement
584 && lfOrientation
== rData
.lfOrientation
585 && lfWeight
== rData
.lfWeight
586 && lfItalic
== rData
.lfItalic
587 && lfUnderline
== rData
.lfUnderline
588 && lfStrikeOut
== rData
.lfStrikeOut
589 && lfCharSet
== rData
.lfCharSet
590 && lfOutPrecision
== rData
.lfOutPrecision
591 && lfClipPrecision
== rData
.lfClipPrecision
592 && lfQuality
== rData
.lfQuality
593 && lfPitchAndFamily
== rData
.lfPitchAndFamily
;
596 bool Sc10Color::operator==( const Sc10Color
& rColor
) const
598 return ((Red
== rColor
.Red
) && (Green
== rColor
.Green
) && (Blue
== rColor
.Blue
));
601 bool Sc10HeadFootLine::operator==( const Sc10HeadFootLine
& rData
) const
603 return !strcmp(Title
, rData
.Title
)
604 && LogFont
== rData
.LogFont
605 && HorJustify
== rData
.HorJustify
606 && VerJustify
== rData
.VerJustify
607 && Raster
== rData
.Raster
608 && Frame
== rData
.Frame
609 && TextColor
== rData
.TextColor
610 && BackColor
== rData
.BackColor
611 && RasterColor
== rData
.RasterColor
612 && FrameColor
== rData
.FrameColor
613 && Reserved
== rData
.Reserved
;
616 bool Sc10PageFormat::operator==( const Sc10PageFormat
& rData
) const
618 return !strcmp(PrintAreaName
, rData
.PrintAreaName
)
619 && HeadLine
== rData
.HeadLine
620 && FootLine
== rData
.FootLine
621 && Orientation
== rData
.Orientation
622 && Width
== rData
.Width
623 && Height
== rData
.Height
624 && NonPrintableX
== rData
.NonPrintableX
625 && NonPrintableY
== rData
.NonPrintableY
626 && Left
== rData
.Left
628 && Right
== rData
.Right
629 && Bottom
== rData
.Bottom
630 && Head
== rData
.Head
631 && Foot
== rData
.Foot
632 && HorCenter
== rData
.HorCenter
633 && VerCenter
== rData
.VerCenter
634 && PrintGrid
== rData
.PrintGrid
635 && PrintColRow
== rData
.PrintColRow
636 && PrintNote
== rData
.PrintNote
637 && TopBottomDir
== rData
.TopBottomDir
638 && FirstPageNo
== rData
.FirstPageNo
639 && RowRepeatStart
== rData
.RowRepeatStart
640 && RowRepeatEnd
== rData
.RowRepeatEnd
641 && ColRepeatStart
== rData
.ColRepeatStart
642 && ColRepeatEnd
== rData
.ColRepeatEnd
643 && !memcmp( PrnZoom
, rData
.PrnZoom
, sizeof(PrnZoom
) )
644 && !memcmp( &PrintArea
, &rData
.PrintArea
, sizeof(PrintArea
) );
647 sal_uInt16
Sc10PageCollection::InsertFormat( const Sc10PageFormat
& rData
)
649 for (sal_uInt16 i
=0; i
<nCount
; i
++)
650 if (At(i
)->aPageFormat
== rData
)
653 Insert( new Sc10PageData(rData
) );
658 static inline sal_uInt8
GetMixedCol( const sal_uInt8 nB
, const sal_uInt8 nF
, const sal_uInt16 nFak
)
660 sal_Int32 nT
= nB
- nF
;
661 nT
*= ( sal_Int32
) nFak
;
664 return ( sal_uInt8
) nT
;
666 static inline Color
GetMixedColor( const Color
& rFore
, const Color
& rBack
, sal_uInt16 nFact
)
668 return Color( GetMixedCol( rBack
.GetRed(), rFore
.GetRed(), nFact
),
669 GetMixedCol( rBack
.GetGreen(), rFore
.GetGreen(), nFact
),
670 GetMixedCol( rBack
.GetBlue(), rFore
.GetBlue(), nFact
) );
673 void Sc10PageCollection::PutToDoc( ScDocument
* pDoc
)
675 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
676 EditEngine
aEditEngine( pDoc
->GetEnginePool() );
677 EditTextObject
* pEmptyObject
= aEditEngine
.CreateTextObject();
679 for (sal_uInt16 i
=0; i
<nCount
; i
++)
681 Sc10PageFormat
* pPage
= &At(i
)->aPageFormat
;
683 pPage
->Width
= (short) ( pPage
->Width
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
684 pPage
->Height
= (short) ( pPage
->Height
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
685 pPage
->Top
= (short) ( pPage
->Top
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
686 pPage
->Bottom
= (short) ( pPage
->Bottom
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
687 pPage
->Left
= (short) ( pPage
->Left
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
688 pPage
->Right
= (short) ( pPage
->Right
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
689 pPage
->Head
= (short) ( pPage
->Head
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
690 pPage
->Foot
= (short) ( pPage
->Foot
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
692 OUString aName
= lcl_MakeOldPageStyleFormatName( i
);
694 ScStyleSheet
* pSheet
= static_cast<ScStyleSheet
*>( &pStylePool
->Make( aName
,
695 SFX_STYLE_FAMILY_PAGE
,
696 SFXSTYLEBIT_USERDEF
| SCSTYLEBIT_STANDARD
) );
697 // #i68483# set page style name at sheet...
698 pDoc
->SetPageStyle( static_cast< SCTAB
>( i
), aName
);
700 SfxItemSet
* pSet
= &pSheet
->GetItemSet();
702 for (sal_uInt16 nHeadFoot
=0; nHeadFoot
<2; nHeadFoot
++)
704 Sc10HeadFootLine
* pHeadFootLine
= nHeadFoot
? &pPage
->FootLine
: &pPage
->HeadLine
;
706 SfxItemSet
aEditAttribs(aEditEngine
.GetEmptyItemSet());
707 FontFamily eFam
= FAMILY_DONTKNOW
;
708 switch (pPage
->HeadLine
.LogFont
.lfPitchAndFamily
& 0xF0)
710 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
711 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
712 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
713 case ffModern
: eFam
= FAMILY_MODERN
; break;
714 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
715 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
716 default: eFam
= FAMILY_DONTKNOW
; break;
718 aEditAttribs
.Put( SvxFontItem(
720 SC10TOSTRING( pHeadFootLine
->LogFont
.lfFaceName
), EMPTY_OUSTRING
,
721 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, EE_CHAR_FONTINFO
),
723 aEditAttribs
.Put( SvxFontHeightItem( std::abs( pHeadFootLine
->LogFont
.lfHeight
), 100, EE_CHAR_FONTHEIGHT
),
726 Sc10Color nColor
= pHeadFootLine
->TextColor
;
727 Color
TextColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
728 aEditAttribs
.Put(SvxColorItem(TextColor
, EE_CHAR_COLOR
), EE_CHAR_COLOR
);
730 if (pHeadFootLine
->LogFont
.lfWeight
!= fwNormal
)
731 aEditAttribs
.Put(SvxWeightItem(WEIGHT_BOLD
, EE_CHAR_WEIGHT
), EE_CHAR_WEIGHT
);
732 if (pHeadFootLine
->LogFont
.lfItalic
!= 0)
733 aEditAttribs
.Put(SvxPostureItem(ITALIC_NORMAL
, EE_CHAR_ITALIC
), EE_CHAR_ITALIC
);
734 if (pHeadFootLine
->LogFont
.lfUnderline
!= 0)
735 aEditAttribs
.Put(SvxUnderlineItem(UNDERLINE_SINGLE
, EE_CHAR_UNDERLINE
), EE_CHAR_UNDERLINE
);
736 if (pHeadFootLine
->LogFont
.lfStrikeOut
!= 0)
737 aEditAttribs
.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE
, EE_CHAR_STRIKEOUT
), EE_CHAR_STRIKEOUT
);
738 OUString
aText( pHeadFootLine
->Title
, strlen(pHeadFootLine
->Title
), DEFCHARSET
);
739 aEditEngine
.SetText( aText
);
740 aEditEngine
.QuickSetAttribs( aEditAttribs
, ESelection( 0, 0, 0, aText
.getLength() ) );
742 EditTextObject
* pObject
= aEditEngine
.CreateTextObject();
743 ScPageHFItem
aHeaderItem(nHeadFoot
? ATTR_PAGE_FOOTERRIGHT
: ATTR_PAGE_HEADERRIGHT
);
744 switch (pHeadFootLine
->HorJustify
)
747 aHeaderItem
.SetLeftArea(*pEmptyObject
);
748 aHeaderItem
.SetCenterArea(*pObject
);
749 aHeaderItem
.SetRightArea(*pEmptyObject
);
752 aHeaderItem
.SetLeftArea(*pEmptyObject
);
753 aHeaderItem
.SetCenterArea(*pEmptyObject
);
754 aHeaderItem
.SetRightArea(*pObject
);
757 aHeaderItem
.SetLeftArea(*pObject
);
758 aHeaderItem
.SetCenterArea(*pEmptyObject
);
759 aHeaderItem
.SetRightArea(*pEmptyObject
);
763 pSet
->Put( aHeaderItem
);
765 SfxItemSet
aSetItemItemSet( *pDoc
->GetPool(),
766 ATTR_BACKGROUND
, ATTR_BACKGROUND
,
767 ATTR_BORDER
, ATTR_SHADOW
,
768 ATTR_PAGE_SIZE
, ATTR_PAGE_SIZE
,
769 ATTR_LRSPACE
, ATTR_ULSPACE
,
770 ATTR_PAGE_ON
, ATTR_PAGE_SHARED
,
772 nColor
= pHeadFootLine
->BackColor
;
773 Color
aBColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
774 nColor
= pHeadFootLine
->RasterColor
;
775 Color
aRColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
778 bool bSwapCol
= false;
779 switch (pHeadFootLine
->Raster
)
781 case raNone
: nFact
= 0xffff; bSwapCol
= true; break;
782 case raGray12
: nFact
= (0xffff / 100) * 12; break;
783 case raGray25
: nFact
= (0xffff / 100) * 25; break;
784 case raGray50
: nFact
= (0xffff / 100) * 50; break;
785 case raGray75
: nFact
= (0xffff / 100) * 75; break;
786 default: nFact
= 0xffff;
789 aSetItemItemSet
.Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
791 aSetItemItemSet
.Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
793 if (pHeadFootLine
->Frame
!= 0)
795 sal_uInt16 nLeft
= 0;
797 sal_uInt16 nRight
= 0;
798 sal_uInt16 nBottom
= 0;
799 sal_uInt16 fLeft
= (pHeadFootLine
->Frame
& 0x000F);
800 sal_uInt16 fTop
= (pHeadFootLine
->Frame
& 0x00F0) / 0x0010;
801 sal_uInt16 fRight
= (pHeadFootLine
->Frame
& 0x0F00) / 0x0100;
802 sal_uInt16 fBottom
= (pHeadFootLine
->Frame
& 0xF000) / 0x1000;
817 else if (fBottom
> 0)
819 Color
ColorLeft(COL_BLACK
);
820 Color
ColorTop(COL_BLACK
);
821 Color
ColorRight(COL_BLACK
);
822 Color
ColorBottom(COL_BLACK
);
823 sal_uInt16 cLeft
= (pHeadFootLine
->FrameColor
& 0x000F);
824 sal_uInt16 cTop
= (pHeadFootLine
->FrameColor
& 0x00F0) >> 4;
825 sal_uInt16 cRight
= (pHeadFootLine
->FrameColor
& 0x0F00) >> 8;
826 sal_uInt16 cBottom
= (pHeadFootLine
->FrameColor
& 0xF000) >> 12;
827 lcl_ChangeColor(cLeft
, ColorLeft
);
828 lcl_ChangeColor(cTop
, ColorTop
);
829 lcl_ChangeColor(cRight
, ColorRight
);
830 lcl_ChangeColor(cBottom
, ColorBottom
);
831 ::editeng::SvxBorderLine aLine
;
832 SvxBoxItem
aBox( ATTR_BORDER
);
833 aLine
.SetWidth(nLeft
);
834 aLine
.SetColor(ColorLeft
);
835 aBox
.SetLine(&aLine
, SvxBoxItemLine::LEFT
);
836 aLine
.SetWidth(nTop
);
837 aLine
.SetColor(ColorTop
);
838 aBox
.SetLine(&aLine
, SvxBoxItemLine::TOP
);
839 aLine
.SetWidth(nRight
);
840 aLine
.SetColor(ColorRight
);
841 aBox
.SetLine(&aLine
, SvxBoxItemLine::RIGHT
);
842 aLine
.SetWidth(nBottom
);
843 aLine
.SetColor(ColorBottom
);
844 aBox
.SetLine(&aLine
, SvxBoxItemLine::BOTTOM
);
846 aSetItemItemSet
.Put(aBox
);
849 pSet
->Put( SvxULSpaceItem( 0, 0, ATTR_ULSPACE
) );
852 aSetItemItemSet
.Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( 0, pPage
->Top
- pPage
->Head
) ) );
854 aSetItemItemSet
.Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( 0, pPage
->Bottom
- pPage
->Foot
) ) );
856 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_ON
, true ));
857 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_DYNAMIC
, false ));
858 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_SHARED
, true ));
860 pSet
->Put( SvxSetItem( nHeadFoot
? ATTR_PAGE_FOOTERSET
: ATTR_PAGE_HEADERSET
,
864 SvxPageItem
aPageItem(ATTR_PAGE
);
865 aPageItem
.SetPageUsage( SVX_PAGE_ALL
);
866 aPageItem
.SetLandscape( pPage
->Orientation
!= 1 );
867 aPageItem
.SetNumType( SVX_ARABIC
);
868 pSet
->Put(aPageItem
);
870 pSet
->Put(SvxLRSpaceItem( pPage
->Left
, pPage
->Right
, 0,0, ATTR_LRSPACE
));
871 pSet
->Put(SvxULSpaceItem( pPage
->Top
, pPage
->Bottom
, ATTR_ULSPACE
));
873 pSet
->Put(SfxBoolItem( ATTR_PAGE_HORCENTER
, pPage
->HorCenter
));
874 pSet
->Put(SfxBoolItem( ATTR_PAGE_VERCENTER
, pPage
->VerCenter
));
879 ScRange
* pRepeatRow
= NULL
;
880 ScRange
* pRepeatCol
= NULL
;
882 if ( pPage
->ColRepeatStart
>= 0 )
883 pRepeatCol
= new ScRange( static_cast<SCCOL
> (pPage
->ColRepeatStart
), 0, 0 );
884 if ( pPage
->RowRepeatStart
>= 0 )
885 pRepeatRow
= new ScRange( 0, static_cast<SCROW
> (pPage
->RowRepeatStart
), 0 );
887 if ( pRepeatRow
|| pRepeatCol
)
890 // set for all tables
892 for ( SCTAB nTab
= 0, nTabCount
= pDoc
->GetTableCount(); nTab
< nTabCount
; ++nTab
)
894 pDoc
->SetRepeatColRange( nTab
, pRepeatCol
);
895 pDoc
->SetRepeatRowRange( nTab
, pRepeatRow
);
905 pSet
->Put( SfxBoolItem( ATTR_PAGE_NOTES
, pPage
->PrintNote
) );
906 pSet
->Put( SfxBoolItem( ATTR_PAGE_GRID
, pPage
->PrintGrid
) );
907 pSet
->Put( SfxBoolItem( ATTR_PAGE_HEADERS
, pPage
->PrintColRow
) );
908 pSet
->Put( SfxBoolItem( ATTR_PAGE_TOPDOWN
, pPage
->TopBottomDir
) );
909 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_CHARTS
, VOBJ_MODE_SHOW
) );
910 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_OBJECTS
, VOBJ_MODE_SHOW
) );
911 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_DRAWINGS
, VOBJ_MODE_SHOW
) );
912 pSet
->Put( SfxUInt16Item( ATTR_PAGE_SCALE
,
913 (sal_uInt16
)( lcl_PascalToDouble( pPage
->PrnZoom
) * 100 ) ) );
914 pSet
->Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO
, 1 ) );
916 pSet
->Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( pPage
->Width
, pPage
->Height
) ) );
922 ScDataObject
* Sc10PageData::Clone() const
924 return new Sc10PageData(aPageFormat
);
929 Sc10Import::Sc10Import(SvStream
& rStr
, ScDocument
* pDocument
) :
932 pFontCollection (NULL
),
933 pNameCollection (NULL
),
934 pPatternCollection (NULL
),
935 pDataBaseCollection (NULL
),
942 Sc10Import::~Sc10Import()
944 pDoc
->CalcAfterLoad();
945 pDoc
->UpdateAllCharts();
947 delete pFontCollection
;
948 delete pNameCollection
;
949 delete pPatternCollection
;
950 delete pDataBaseCollection
;
952 OSL_ENSURE( pPrgrsBar
== NULL
,
953 "*Sc10Import::Sc10Import(): Progressbar lebt noch!?" );
956 sal_uLong
Sc10Import::Import()
958 pPrgrsBar
= new ScfStreamProgressBar( rStream
, pDoc
->GetDocumentShell() );
960 ScDocOptions aOpt
= pDoc
->GetDocOptions();
961 aOpt
.SetDate( 1, 1, 1900 );
962 aOpt
.SetYear2000( 18 + 1901 ); // 4-digit since SO51 src513e
963 pDoc
->SetDocOptions( aOpt
);
964 pDoc
->GetFormatTable()->ChangeNullDate( 1, 1, 1900 );
966 LoadFileHeader(); pPrgrsBar
->Progress();
967 if (!nError
) { LoadFileInfo(); pPrgrsBar
->Progress(); }
968 if (!nError
) { LoadEditStateInfo(); pPrgrsBar
->Progress(); }
969 if (!nError
) { LoadProtect(); pPrgrsBar
->Progress(); }
970 if (!nError
) { LoadViewColRowBar(); pPrgrsBar
->Progress(); }
971 if (!nError
) { LoadScrZoom(); pPrgrsBar
->Progress(); }
972 if (!nError
) { LoadPalette(); pPrgrsBar
->Progress(); }
973 if (!nError
) { LoadFontCollection(); pPrgrsBar
->Progress(); }
974 if (!nError
) { LoadNameCollection(); pPrgrsBar
->Progress(); }
975 if (!nError
) { LoadPatternCollection(); pPrgrsBar
->Progress(); }
976 if (!nError
) { LoadDataBaseCollection(); pPrgrsBar
->Progress(); }
977 if (!nError
) { LoadTables(); pPrgrsBar
->Progress(); }
978 if (!nError
) { LoadObjects(); pPrgrsBar
->Progress(); }
979 if (!nError
) { ImportNameCollection(); pPrgrsBar
->Progress(); }
980 pDoc
->SetViewOptions( aSc30ViewOpt
);
982 #if OSL_DEBUG_LEVEL > 0
985 OSL_FAIL( OString::number(nError
).getStr());
990 #if OSL_DEBUG_LEVEL > 0
997 void Sc10Import::LoadFileHeader()
999 Sc10FileHeader FileHeader
;
1000 lcl_ReadFileHeader(rStream
, FileHeader
);
1002 nError
= rStream
.GetError();
1005 sal_Char Sc10CopyRight
[32];
1006 strcpy(Sc10CopyRight
, "Blaise-Tabelle");
1007 Sc10CopyRight
[14] = 10;
1008 Sc10CopyRight
[15] = 13;
1009 Sc10CopyRight
[16] = 0;
1010 if ((strcmp(FileHeader
.CopyRight
, Sc10CopyRight
) != 0)
1011 || (FileHeader
.Version
< 101)
1012 || (FileHeader
.Version
> 102))
1013 nError
= errUnknownFormat
;
1017 void Sc10Import::LoadFileInfo()
1019 Sc10FileInfo FileInfo
;
1020 rStream
.Read(&FileInfo
, sizeof(FileInfo
));
1022 nError
= rStream
.GetError();
1023 // TODO: ? copy info
1026 void Sc10Import::LoadEditStateInfo()
1028 Sc10EditStateInfo EditStateInfo
;
1029 rStream
.Read(&EditStateInfo
, sizeof(EditStateInfo
));
1031 nError
= rStream
.GetError();
1032 nShowTab
= static_cast<SCTAB
>(EditStateInfo
.DeltaZ
);
1033 // TODO: ? copy cursor position and offset of the table (shall we do that??)
1037 void Sc10Import::LoadProtect()
1039 lcl_ReadSheetProtect(rStream
, SheetProtect
);
1040 nError
= rStream
.GetError();
1042 ScDocProtection aProtection
;
1043 aProtection
.setProtected(static_cast<bool>(SheetProtect
.Protect
));
1044 aProtection
.setPassword(SC10TOSTRING(SheetProtect
.PassWord
));
1045 pDoc
->SetDocProtection(&aProtection
);
1048 void Sc10Import::LoadViewColRowBar()
1050 bool bViewColRowBar
;
1051 rStream
.ReadCharAsBool( bViewColRowBar
);
1052 nError
= rStream
.GetError();
1053 aSc30ViewOpt
.SetOption( VOPT_HEADER
, bViewColRowBar
);
1056 void Sc10Import::LoadScrZoom()
1058 // TODO: unfortunately Zoom is a 6-byte TP real number (don't know how to translate that)
1060 rStream
.Read(cZoom
, sizeof(cZoom
));
1061 nError
= rStream
.GetError();
1064 void Sc10Import::LoadPalette()
1066 lcl_ReadPalette(rStream
, TextPalette
);
1067 lcl_ReadPalette(rStream
, BackPalette
);
1068 lcl_ReadPalette(rStream
, RasterPalette
);
1069 lcl_ReadPalette(rStream
, FramePalette
);
1071 nError
= rStream
.GetError();
1074 void Sc10Import::LoadFontCollection()
1076 pFontCollection
= new Sc10FontCollection(rStream
);
1078 nError
= pFontCollection
->GetError();
1081 void Sc10Import::LoadNameCollection()
1083 pNameCollection
= new Sc10NameCollection(rStream
);
1085 nError
= pNameCollection
->GetError();
1088 void Sc10Import::ImportNameCollection()
1090 ScRangeName
* pRN
= pDoc
->GetRangeName();
1092 for (sal_uInt16 i
= 0; i
< pNameCollection
->GetCount(); i
++)
1094 Sc10NameData
* pName
= pNameCollection
->At( i
);
1097 pDoc
, SC10TOSTRING(pName
->Name
), SC10TOSTRING(pName
->Reference
)));
1101 void Sc10Import::LoadPatternCollection()
1103 pPatternCollection
= new Sc10PatternCollection( rStream
);
1105 nError
= pPatternCollection
->GetError();
1106 if (nError
== errOutOfMemory
)
1108 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
1109 for( sal_uInt16 i
= 0 ; i
< pPatternCollection
->GetCount() ; i
++ )
1111 Sc10PatternData
* pPattern
= pPatternCollection
->At( i
);
1112 OUString
aName( pPattern
->Name
, strlen(pPattern
->Name
), DEFCHARSET
);
1113 SfxStyleSheetBase
* pStyle
= pStylePool
->Find( aName
, SFX_STYLE_FAMILY_PARA
);
1114 if( pStyle
== NULL
)
1115 pStylePool
->Make( aName
, SFX_STYLE_FAMILY_PARA
);
1118 pPattern
->Name
[ 27 ] = 0;
1119 strcat( pPattern
->Name
, "_Old" );
1120 aName
= SC10TOSTRING( pPattern
->Name
);
1121 pStylePool
->Make( aName
, SFX_STYLE_FAMILY_PARA
);
1123 pStyle
= pStylePool
->Find( aName
, SFX_STYLE_FAMILY_PARA
);
1124 if( pStyle
!= NULL
)
1126 SfxItemSet
&rItemSet
= pStyle
->GetItemSet();
1128 if( ( pPattern
->FormatFlags
& pfFont
) == pfFont
)
1130 FontFamily eFam
= FAMILY_DONTKNOW
;
1131 switch( pPattern
->LogFont
.lfPitchAndFamily
& 0xF0 )
1133 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
1134 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
1135 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
1136 case ffModern
: eFam
= FAMILY_MODERN
; break;
1137 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
1138 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
1139 default: eFam
= FAMILY_DONTKNOW
; break;
1141 rItemSet
.Put( SvxFontItem( eFam
, SC10TOSTRING( pPattern
->LogFont
.lfFaceName
), EMPTY_OUSTRING
,
1142 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
) );
1143 rItemSet
.Put( SvxFontHeightItem( std::abs( pPattern
->LogFont
.lfHeight
), 100, ATTR_FONT_HEIGHT
) );
1144 Color
TextColor( COL_BLACK
);
1145 lcl_ChangeColor( ( pPattern
->nColor
& 0x000F ), TextColor
);
1146 rItemSet
.Put( SvxColorItem( TextColor
, ATTR_FONT_COLOR
) );
1148 if( pPattern
->LogFont
.lfWeight
!= fwNormal
)
1149 rItemSet
.Put( SvxWeightItem( WEIGHT_BOLD
, ATTR_FONT_WEIGHT
) );
1150 if( pPattern
->LogFont
.lfItalic
!= 0 )
1151 rItemSet
.Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
1152 if( pPattern
->LogFont
.lfUnderline
!= 0 )
1153 rItemSet
.Put( SvxUnderlineItem( UNDERLINE_SINGLE
, ATTR_FONT_UNDERLINE
) );
1154 if( pPattern
->LogFont
.lfStrikeOut
!= 0 )
1155 rItemSet
.Put( SvxCrossedOutItem( STRIKEOUT_SINGLE
, ATTR_FONT_CROSSEDOUT
) );
1158 if( ( pPattern
->FormatFlags
& pfJustify
) == pfJustify
)
1160 sal_uInt16 HorJustify
= ( pPattern
->Justify
& 0x000F );
1161 sal_uInt16 VerJustify
= ( pPattern
->Justify
& 0x00F0 ) >> 4;
1162 sal_uInt16 OJustify
= ( pPattern
->Justify
& 0x0F00 ) >> 8;
1163 sal_uInt16 EJustify
= ( pPattern
->Justify
& 0xF000 ) >> 12;
1164 if( HorJustify
!= 0 )
1165 switch( HorJustify
)
1168 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT
, ATTR_HOR_JUSTIFY
) );
1171 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
) );
1174 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT
, ATTR_HOR_JUSTIFY
) );
1177 if( VerJustify
!= 0 )
1178 switch( VerJustify
)
1181 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_TOP
, ATTR_VER_JUSTIFY
) );
1184 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER
, ATTR_VER_JUSTIFY
) );
1187 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_BOTTOM
, ATTR_VER_JUSTIFY
) );
1191 if( ( OJustify
& ojWordBreak
) == ojWordBreak
)
1192 rItemSet
.Put( SfxBoolItem( ATTR_LINEBREAK
, true ) );
1193 if( ( OJustify
& ojBottomTop
) == ojBottomTop
)
1194 rItemSet
.Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 9000 ) );
1195 else if( ( OJustify
& ojTopBottom
) == ojTopBottom
)
1196 rItemSet
.Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 27000 ) );
1198 sal_Int16 Margin
= std::max( ( sal_uInt16
) 20, ( sal_uInt16
) ( EJustify
* 20 ) );
1199 if( ( ( OJustify
& ojBottomTop
) == ojBottomTop
) )
1200 rItemSet
.Put( SvxMarginItem( 20, Margin
, 20, Margin
, ATTR_MARGIN
) );
1202 rItemSet
.Put( SvxMarginItem( Margin
, 20, Margin
, 20, ATTR_MARGIN
) );
1206 if( ( pPattern
->FormatFlags
& pfFrame
) == pfFrame
)
1208 if( pPattern
->Frame
!= 0 )
1210 sal_uInt16 nLeft
= 0;
1211 sal_uInt16 nTop
= 0;
1212 sal_uInt16 nRight
= 0;
1213 sal_uInt16 nBottom
= 0;
1214 sal_uInt16 fLeft
= ( pPattern
->Frame
& 0x000F );
1215 sal_uInt16 fTop
= ( pPattern
->Frame
& 0x00F0 ) / 0x0010;
1216 sal_uInt16 fRight
= ( pPattern
->Frame
& 0x0F00 ) / 0x0100;
1217 sal_uInt16 fBottom
= ( pPattern
->Frame
& 0xF000 ) / 0x1000;
1221 else if( fLeft
> 0 )
1231 else if( fRight
> 0 )
1236 else if( fBottom
> 0 )
1239 Color
ColorLeft( COL_BLACK
);
1240 Color
ColorTop( COL_BLACK
);
1241 Color
ColorRight( COL_BLACK
);
1242 Color
ColorBottom( COL_BLACK
);
1244 sal_uInt16 cLeft
= ( pPattern
->FrameColor
& 0x000F );
1245 sal_uInt16 cTop
= ( pPattern
->FrameColor
& 0x00F0 ) >> 4;
1246 sal_uInt16 cRight
= ( pPattern
->FrameColor
& 0x0F00 ) >> 8;
1247 sal_uInt16 cBottom
= ( pPattern
->FrameColor
& 0xF000 ) >> 12;
1249 lcl_ChangeColor( cLeft
, ColorLeft
);
1250 lcl_ChangeColor( cTop
, ColorTop
);
1251 lcl_ChangeColor( cRight
, ColorRight
);
1252 lcl_ChangeColor( cBottom
, ColorBottom
);
1254 ::editeng::SvxBorderLine aLine
;
1255 SvxBoxItem
aBox( ATTR_BORDER
);
1257 aLine
.SetWidth( nLeft
);
1258 aLine
.SetColor( ColorLeft
);
1259 aBox
.SetLine( &aLine
, SvxBoxItemLine::LEFT
);
1260 aLine
.SetWidth( nTop
);
1261 aLine
.SetColor( ColorTop
);
1262 aBox
.SetLine( &aLine
, SvxBoxItemLine::TOP
);
1263 aLine
.SetWidth( nRight
);
1264 aLine
.SetColor( ColorRight
);
1265 aBox
.SetLine( &aLine
, SvxBoxItemLine::RIGHT
);
1266 aLine
.SetWidth( nBottom
);
1267 aLine
.SetColor( ColorBottom
);
1268 aBox
.SetLine( &aLine
, SvxBoxItemLine::BOTTOM
);
1269 rItemSet
.Put( aBox
);
1273 if( ( pPattern
->FormatFlags
& pfRaster
) == pfRaster
)
1275 if( pPattern
->Raster
!= 0 )
1277 sal_uInt16 nBColor
= ( pPattern
->nColor
& 0x00F0 ) >> 4;
1278 sal_uInt16 nRColor
= ( pPattern
->nColor
& 0x0F00 ) >> 8;
1279 Color
aBColor( COL_BLACK
);
1281 lcl_ChangeColor( nBColor
, aBColor
);
1284 aBColor
.SetColor( COL_WHITE
);
1285 else if( nBColor
== 15 )
1286 aBColor
.SetColor( COL_BLACK
);
1288 Color
aRColor( COL_BLACK
);
1289 lcl_ChangeColor( nRColor
, aRColor
);
1291 bool bSwapCol
= false;
1292 bool bSetItem
= true;
1293 switch (pPattern
->Raster
)
1295 case raNone
: nFact
= 0xffff; bSwapCol
= true; bSetItem
= (nBColor
> 0); break;
1296 case raGray12
: nFact
= (0xffff / 100) * 12; break;
1297 case raGray25
: nFact
= (0xffff / 100) * 25; break;
1298 case raGray50
: nFact
= (0xffff / 100) * 50; break;
1299 case raGray75
: nFact
= (0xffff / 100) * 75; break;
1300 default: nFact
= 0xffff; bSetItem
= (nRColor
< 15);
1305 rItemSet
.Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
1307 rItemSet
.Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
1312 if( ( pPattern
->ValueFormat
.Format
!= 0 ) &&
1313 ( ( pPattern
->FormatFlags
& pfValue
) == pfValue
) )
1316 ChangeFormat( pPattern
->ValueFormat
.Format
, pPattern
->ValueFormat
.Info
, nKey
);
1317 rItemSet
.Put( SfxUInt32Item( ATTR_VALUE_FORMAT
, ( sal_uInt32
) nKey
) );
1320 // cell attributes (protected, hidden...)
1321 if( ( pPattern
->Flags
!= 0 ) &&
1322 ( ( pPattern
->FormatFlags
& pfProtection
) == pfProtection
) )
1324 bool bProtect
= ( ( pPattern
->Flags
& paProtect
) == paProtect
);
1325 bool bHFormula
= ( ( pPattern
->Flags
& paHideFormula
) == paHideFormula
);
1326 bool bHCell
= ( ( pPattern
->Flags
& paHideAll
) == paHideAll
);
1327 bool bHPrint
= ( ( pPattern
->Flags
& paHidePrint
) == paHidePrint
);
1328 rItemSet
.Put( ScProtectionAttr( bProtect
, bHFormula
, bHCell
, bHPrint
) );
1331 } // for (i = 0; i < GetCount()
1334 void Sc10Import::LoadDataBaseCollection()
1336 pDataBaseCollection
= new Sc10DataBaseCollection(rStream
);
1338 nError
= pDataBaseCollection
->GetError();
1339 if (nError
== errOutOfMemory
)
1341 for( sal_uInt16 i
= 0 ; i
< pDataBaseCollection
->GetCount() ; i
++ )
1343 Sc10DataBaseData
* pOldData
= pDataBaseCollection
->At(i
);
1344 ScDBData
* pNewData
= new ScDBData( SC10TOSTRING( pOldData
->DataBaseRec
.Name
),
1345 ( SCTAB
) pOldData
->DataBaseRec
.Tab
,
1346 ( SCCOL
) pOldData
->DataBaseRec
.Block
.x1
,
1347 ( SCROW
) pOldData
->DataBaseRec
.Block
.y1
,
1348 ( SCCOL
) pOldData
->DataBaseRec
.Block
.x2
,
1349 ( SCROW
) pOldData
->DataBaseRec
.Block
.y2
,
1351 (bool) pOldData
->DataBaseRec
.RowHeader
);
1352 bool ins
= pDoc
->GetDBCollection()->getNamedDBs().insert(pNewData
);
1353 assert(ins
); (void)ins
;
1354 //TODO: or can this fail (and need delete pNewData)?
1360 sal_uInt16
ReadAndSanitizeDataCount(SvStream
&rStream
)
1362 sal_uInt16
nDataCount(0);
1363 rStream
.ReadUInt16(nDataCount
);
1364 const size_t nMinRecordSize
= sizeof(sal_uInt16
)*2;
1365 const size_t nMaxRecords
= rStream
.remainingSize() / nMinRecordSize
;
1366 if (nDataCount
> nMaxRecords
)
1368 SAL_WARN("sc", "Parsing error: " << nMaxRecords
<<
1369 " max possible entries, but " << nDataCount
<< " claimed, truncating");
1370 nDataCount
= nMaxRecords
;
1376 void Sc10Import::LoadTables()
1378 Sc10PageCollection aPageCollection
;
1380 sal_Int16 nTabCount
;
1381 rStream
.ReadInt16( nTabCount
);
1382 for (sal_Int16 Tab
= 0; (Tab
< nTabCount
) && (nError
== 0); Tab
++)
1384 Sc10PageFormat PageFormat
;
1385 sal_Int16 DataBaseIndex
;
1386 Sc10TableProtect TabProtect
;
1388 sal_Char TabName
[128];
1392 sal_uInt16 DataCount
;
1393 sal_uInt16 DataStart
;
1395 sal_uInt16 DataValue
;
1399 lcl_ReadPageFormat(rStream
, PageFormat
);
1401 sal_uInt16 nAt
= aPageCollection
.InsertFormat(PageFormat
);
1402 OUString aPageName
= lcl_MakeOldPageStyleFormatName( nAt
);
1404 pPrgrsBar
->Progress();
1406 rStream
.ReadInt16( DataBaseIndex
);
1408 lcl_ReadTabProtect(rStream
, TabProtect
);
1410 ScTableProtection aProtection
;
1411 aProtection
.setProtected(static_cast<bool>(TabProtect
.Protect
));
1412 aProtection
.setPassword(SC10TOSTRING(TabProtect
.PassWord
));
1413 pDoc
->SetTabProtection(static_cast<SCTAB
>(Tab
), &aProtection
);
1415 rStream
.ReadInt16( TabNo
);
1418 rStream
.ReadUChar( nLen
);
1419 rStream
.Read(TabName
, sizeof(TabName
) - 1);
1420 if (nLen
>= sizeof(TabName
))
1421 nLen
= sizeof(TabName
) - 1;
1424 rStream
.ReadUInt16( Display
);
1426 if ( Tab
== (sal_Int16
)nShowTab
)
1428 ScVObjMode eObjMode
= VOBJ_MODE_SHOW
;
1430 aSc30ViewOpt
.SetOption( VOPT_FORMULAS
, IS_SET(dfFormula
,Display
) );
1431 aSc30ViewOpt
.SetOption( VOPT_NULLVALS
, IS_SET(dfZerro
,Display
) );
1432 aSc30ViewOpt
.SetOption( VOPT_SYNTAX
, IS_SET(dfSyntax
,Display
) );
1433 aSc30ViewOpt
.SetOption( VOPT_NOTES
, IS_SET(dfNoteMark
,Display
) );
1434 aSc30ViewOpt
.SetOption( VOPT_VSCROLL
, true );
1435 aSc30ViewOpt
.SetOption( VOPT_HSCROLL
, true );
1436 aSc30ViewOpt
.SetOption( VOPT_TABCONTROLS
, true );
1437 aSc30ViewOpt
.SetOption( VOPT_OUTLINER
, true );
1438 aSc30ViewOpt
.SetOption( VOPT_GRID
, IS_SET(dfGrid
,Display
) );
1440 // VOPT_HEADER is set in LoadViewColRowBar()
1442 if ( IS_SET(dfObjectAll
,Display
) ) // show objects
1443 eObjMode
= VOBJ_MODE_SHOW
;
1444 else if ( IS_SET(dfObjectFrame
,Display
) ) // object as placeholder
1445 eObjMode
= VOBJ_MODE_SHOW
;
1446 else if ( IS_SET(dfObjectNone
,Display
) ) // don't show objects
1447 eObjMode
= VOBJ_MODE_HIDE
;
1449 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_OLE
, eObjMode
);
1450 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_CHART
, eObjMode
);
1451 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_DRAW
, eObjMode
);
1454 rStream
.ReadUChar( Visible
);
1456 nError
= rStream
.GetError();
1457 if (nError
!= 0) return;
1460 pDoc
->RenameTab(static_cast<SCTAB
> (TabNo
), SC10TOSTRING( TabName
), false);
1462 pDoc
->InsertTab(SC_TAB_APPEND
, SC10TOSTRING( TabName
) );
1464 pDoc
->SetPageStyle( static_cast<SCTAB
>(Tab
), aPageName
);
1466 if (Visible
== 0) pDoc
->SetVisible(static_cast<SCTAB
> (TabNo
), false);
1469 rStream
.ReadUInt16( ID
);
1470 if (ID
!= ColWidthID
)
1472 OSL_FAIL( "ColWidthID" );
1473 nError
= errUnknownID
;
1476 DataCount
= ReadAndSanitizeDataCount(rStream
);
1478 for (i
=0; i
< DataCount
; i
++)
1480 rStream
.ReadUInt16( DataEnd
);
1481 DataEnd
= SanitizeCol(DataEnd
);
1482 rStream
.ReadUInt16( DataValue
);
1483 for (SCCOL j
= static_cast<SCCOL
>(DataStart
); j
<= static_cast<SCCOL
>(DataEnd
); j
++)
1484 pDoc
->SetColWidth(j
, static_cast<SCTAB
> (TabNo
), DataValue
);
1485 DataStart
= DataEnd
+ 1;
1487 pPrgrsBar
->Progress();
1490 rStream
.ReadUInt16( ID
);
1491 if (ID
!= ColAttrID
)
1493 OSL_FAIL( "ColAttrID" );
1494 nError
= errUnknownID
;
1498 DataCount
= ReadAndSanitizeDataCount(rStream
);
1500 for (i
=0; i
< DataCount
; i
++)
1502 rStream
.ReadUInt16( DataEnd
);
1503 rStream
.ReadUInt16( DataValue
);
1506 bool bPageBreak
= ((DataValue
& crfSoftBreak
) == crfSoftBreak
);
1507 bool bManualBreak
= ((DataValue
& crfHardBreak
) == crfHardBreak
);
1508 bool bHidden
= ((DataValue
& crfHidden
) == crfHidden
);
1509 for (SCCOL k
= SanitizeCol(static_cast<SCCOL
>(DataStart
)); k
<= SanitizeCol(static_cast<SCCOL
>(DataEnd
)); k
++)
1511 pDoc
->SetColHidden(k
, k
, static_cast<SCTAB
>(TabNo
), bHidden
);
1512 pDoc
->SetColBreak(k
, static_cast<SCTAB
> (TabNo
), bPageBreak
, bManualBreak
);
1515 DataStart
= DataEnd
+ 1;
1517 pPrgrsBar
->Progress();
1520 rStream
.ReadUInt16( ID
);
1521 if (ID
!= RowHeightID
)
1523 OSL_FAIL( "RowHeightID" );
1524 nError
= errUnknownID
;
1528 DataCount
= ReadAndSanitizeDataCount(rStream
);
1530 for (i
=0; i
< DataCount
; i
++)
1532 rStream
.ReadUInt16( DataEnd
);
1533 rStream
.ReadUInt16( DataValue
);
1534 pDoc
->SetRowHeightRange(static_cast<SCROW
> (DataStart
), static_cast<SCROW
> (DataEnd
), static_cast<SCTAB
> (TabNo
), DataValue
);
1535 DataStart
= DataEnd
+ 1;
1537 pPrgrsBar
->Progress();
1540 rStream
.ReadUInt16( ID
);
1541 if (ID
!= RowAttrID
)
1543 OSL_FAIL( "RowAttrID" );
1544 nError
= errUnknownID
;
1548 DataCount
= ReadAndSanitizeDataCount(rStream
);
1550 for (i
=0; i
< DataCount
; i
++)
1552 rStream
.ReadUInt16( DataEnd
);
1553 rStream
.ReadUInt16( DataValue
);
1556 bool bPageBreak
= ((DataValue
& crfSoftBreak
) == crfSoftBreak
);
1557 bool bManualBreak
= ((DataValue
& crfHardBreak
) == crfHardBreak
);
1558 bool bHidden
= ((DataValue
& crfHidden
) == crfHidden
);
1559 for (SCROW l
= SanitizeRow(static_cast<SCROW
>(DataStart
)); l
<= SanitizeRow(static_cast<SCROW
>(DataEnd
)); ++l
)
1561 pDoc
->SetRowHidden(l
, l
, static_cast<SCTAB
> (TabNo
), bHidden
);
1562 pDoc
->SetRowBreak(l
, static_cast<SCTAB
> (TabNo
), bPageBreak
, bManualBreak
);
1565 DataStart
= DataEnd
+ 1;
1567 pPrgrsBar
->Progress();
1570 rStream
.ReadUInt16( ID
);
1573 OSL_FAIL( "TableID" );
1574 nError
= errUnknownID
;
1577 for (SCCOL Col
= 0; (Col
<= SC10MAXCOL
) && (nError
== 0); Col
++)
1579 rStream
.ReadUInt16( Count
);
1580 nError
= rStream
.GetError();
1581 if ((Count
!= 0) && (nError
== 0))
1582 LoadCol(Col
, static_cast<SCTAB
> (TabNo
));
1584 OSL_ENSURE( nError
== 0, "Stream" );
1586 pPrgrsBar
->Progress();
1588 aPageCollection
.PutToDoc( pDoc
);
1591 void Sc10Import::LoadCol(SCCOL Col
, SCTAB Tab
)
1593 LoadColAttr(Col
, Tab
);
1595 sal_uInt16 CellCount
;
1598 rStream
.ReadUInt16( CellCount
);
1599 SCROW nScCount
= static_cast< SCROW
>( CellCount
);
1600 if (nScCount
> MAXROW
) nError
= errUnknownFormat
;
1601 for (sal_uInt16 i
= 0; (i
< CellCount
) && (nError
== 0); i
++)
1603 rStream
.ReadUChar( CellType
);
1604 rStream
.ReadUInt16( Row
);
1605 nError
= rStream
.GetError();
1612 const SfxPoolItem
* pValueFormat
= pDoc
->GetAttr(Col
, static_cast<SCROW
> (Row
), Tab
, ATTR_VALUE_FORMAT
);
1613 sal_uLong nFormat
= static_cast<const SfxUInt32Item
*>(pValueFormat
)->GetValue();
1614 double Value
= ScfTools::ReadLongDouble(rStream
);
1615 //rStream.Read(&Value, sizeof(Value));
1617 // TODO: adjustment is needed if we change the Basis Date
1618 // StarCalc 1.0: 01.01.1900
1619 // if ((nFormat >= 30) && (nFormat <= 35))
1621 if ((nFormat
>= 40) && (nFormat
<= 45))
1623 pDoc
->SetValue(Col
, static_cast<SCROW
> (Row
), Tab
, Value
);
1630 rStream
.ReadUChar( Len
);
1631 rStream
.Read(s
, Len
);
1634 pDoc
->SetString( Col
, static_cast<SCROW
> (Row
), Tab
, SC10TOSTRING( s
) );
1639 /*double Value =*/ ScfTools::ReadLongDouble(rStream
);
1642 rStream
.ReadUChar( Len
);
1643 rStream
.Read(&s
[1], Len
);
1646 ScFormulaCell
* pCell
= new ScFormulaCell( pDoc
, ScAddress( Col
, static_cast<SCROW
> (Row
), Tab
) );
1647 pCell
->SetHybridFormula( SC10TOSTRING( s
),formula::FormulaGrammar::GRAM_NATIVE
);
1648 pDoc
->EnsureTable(Tab
);
1649 pDoc
->SetFormulaCell(ScAddress(Col
,Row
,Tab
), pCell
);
1655 nError
= errUnknownFormat
;
1658 sal_uInt16
nNoteLen(0);
1659 rStream
.ReadUInt16(nNoteLen
);
1660 size_t nAvailable
= rStream
.remainingSize();
1661 if (nNoteLen
> nAvailable
)
1662 nNoteLen
= nAvailable
;
1665 boost::scoped_array
<sal_Char
> xNote(new sal_Char
[nNoteLen
+1]);
1666 nNoteLen
= rStream
.Read(xNote
.get(), nNoteLen
);
1667 xNote
[nNoteLen
] = 0;
1668 OUString
aNoteText( SC10TOSTRING(xNote
.get()));
1670 ScAddress
aPos( Col
, static_cast<SCROW
>(Row
), Tab
);
1671 ScNoteUtil::CreateNoteFromString( *pDoc
, aPos
, aNoteText
, false, false );
1674 pPrgrsBar
->Progress();
1678 void Sc10Import::LoadColAttr(SCCOL Col
, SCTAB Tab
)
1682 Sc10ColAttr aJustify
;
1684 Sc10ColAttr aRaster
;
1687 Sc10ColAttr aFrameColor
;
1689 Sc10ColAttr aPattern
;
1691 if (nError
== 0) LoadAttr(aFont
);
1692 if (nError
== 0) LoadAttr(aAttr
);
1693 if (nError
== 0) LoadAttr(aJustify
);
1694 if (nError
== 0) LoadAttr(aFrame
);
1695 if (nError
== 0) LoadAttr(aRaster
);
1696 if (nError
== 0) LoadAttr(aValue
);
1697 if (nError
== 0) LoadAttr(aColor
);
1698 if (nError
== 0) LoadAttr(aFrameColor
);
1699 if (nError
== 0) LoadAttr(aFlag
);
1700 if (nError
== 0) LoadAttr(aPattern
);
1709 Sc10ColData
*pColData
;
1711 // Font (Name, Size)
1714 nLimit
= aFont
.Count
;
1715 pColData
= aFont
.pData
;
1716 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1718 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1719 if ((nStart
<= nEnd
) && (pColData
->Value
))
1721 FontFamily eFam
= FAMILY_DONTKNOW
;
1722 Sc10FontData
* pFont
= pFontCollection
->At(pColData
->Value
);
1725 switch (pFont
->PitchAndFamily
& 0xF0)
1727 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
1728 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
1729 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
1730 case ffModern
: eFam
= FAMILY_MODERN
; break;
1731 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
1732 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
1733 default: eFam
= FAMILY_DONTKNOW
; break;
1735 ScPatternAttr
aScPattern(pDoc
->GetPool());
1736 aScPattern
.GetItemSet().Put(SvxFontItem(eFam
, SC10TOSTRING( pFont
->FaceName
), EMPTY_OUSTRING
,
1737 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
));
1738 aScPattern
.GetItemSet().Put(SvxFontHeightItem(std::abs(pFont
->Height
), 100, ATTR_FONT_HEIGHT
));
1739 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1748 nLimit
= aColor
.Count
;
1749 pColData
= aColor
.pData
;
1750 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1752 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1753 if ((nStart
<= nEnd
) && (pColData
->Value
))
1755 Color
TextColor(COL_BLACK
);
1756 lcl_ChangeColor((pColData
->Value
& 0x000F), TextColor
);
1757 ScPatternAttr
aScPattern(pDoc
->GetPool());
1758 aScPattern
.GetItemSet().Put(SvxColorItem(TextColor
, ATTR_FONT_COLOR
));
1759 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1764 // Font attributes (Bold, Italic...)
1767 nLimit
= aAttr
.Count
;
1768 pColData
= aAttr
.pData
;
1769 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1771 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1772 nValue1
= pColData
->Value
;
1773 if ((nStart
<= nEnd
) && (nValue1
))
1775 ScPatternAttr
aScPattern(pDoc
->GetPool());
1776 if ((nValue1
& atBold
) == atBold
)
1777 aScPattern
.GetItemSet().Put(SvxWeightItem(WEIGHT_BOLD
, ATTR_FONT_WEIGHT
));
1778 if ((nValue1
& atItalic
) == atItalic
)
1779 aScPattern
.GetItemSet().Put(SvxPostureItem(ITALIC_NORMAL
, ATTR_FONT_POSTURE
));
1780 if ((nValue1
& atUnderline
) == atUnderline
)
1781 aScPattern
.GetItemSet().Put(SvxUnderlineItem(UNDERLINE_SINGLE
, ATTR_FONT_UNDERLINE
));
1782 if ((nValue1
& atStrikeOut
) == atStrikeOut
)
1783 aScPattern
.GetItemSet().Put(SvxCrossedOutItem(STRIKEOUT_SINGLE
, ATTR_FONT_CROSSEDOUT
));
1784 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1792 nLimit
= aJustify
.Count
;
1793 pColData
= aJustify
.pData
;
1794 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1796 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1797 nValue1
= pColData
->Value
;
1798 if ((nStart
<= nEnd
) && (nValue1
))
1800 ScPatternAttr
aScPattern(pDoc
->GetPool());
1801 sal_uInt16 HorJustify
= (nValue1
& 0x000F);
1802 sal_uInt16 VerJustify
= (nValue1
& 0x00F0) >> 4;
1803 sal_uInt16 OJustify
= (nValue1
& 0x0F00) >> 8;
1804 sal_uInt16 EJustify
= (nValue1
& 0xF000) >> 12;
1809 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_LEFT
, ATTR_HOR_JUSTIFY
));
1812 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
));
1815 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT
, ATTR_HOR_JUSTIFY
));
1822 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_TOP
, ATTR_VER_JUSTIFY
));
1825 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_CENTER
, ATTR_VER_JUSTIFY
));
1828 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_BOTTOM
, ATTR_VER_JUSTIFY
));
1832 if (OJustify
& ojWordBreak
)
1833 aScPattern
.GetItemSet().Put(SfxBoolItem(ATTR_LINEBREAK
, true));
1834 if (OJustify
& ojBottomTop
)
1835 aScPattern
.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE
,9000));
1836 else if (OJustify
& ojTopBottom
)
1837 aScPattern
.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE
,27000));
1839 sal_Int16 Margin
= std::max((sal_uInt16
)20, (sal_uInt16
)(EJustify
* 20));
1840 if (OJustify
& ojBottomTop
)
1841 aScPattern
.GetItemSet().Put(SvxMarginItem(20, Margin
, 20, Margin
, ATTR_MARGIN
));
1843 aScPattern
.GetItemSet().Put(SvxMarginItem(Margin
, 20, Margin
, 20, ATTR_MARGIN
));
1844 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1850 sal_uInt16 nColorIndex
= 0;
1851 sal_uInt16 nFrameIndex
= 0;
1854 const sal_uInt32 nHelpMeStart
= 100;
1855 sal_uInt32 nHelpMe
= nHelpMeStart
;
1856 sal_uInt16 nColorIndexOld
= nColorIndex
;
1857 sal_uInt16 nFrameIndexOld
= nColorIndex
;
1861 while( !bEnd
&& nHelpMe
)
1863 pColData
= &aFrame
.pData
[ nFrameIndex
];
1865 sal_uInt16 nValue
= pColData
->Value
;
1866 sal_uInt16 nLeft
= 0;
1867 sal_uInt16 nTop
= 0;
1868 sal_uInt16 nRight
= 0;
1869 sal_uInt16 nBottom
= 0;
1870 sal_uInt16 fLeft
= ( nValue
& 0x000F );
1871 sal_uInt16 fTop
= ( nValue
& 0x00F0 ) >> 4;
1872 sal_uInt16 fRight
= ( nValue
& 0x0F00 ) >> 8;
1873 sal_uInt16 fBottom
= ( nValue
& 0xF000 ) >> 12;
1877 else if( fLeft
> 0 )
1887 else if( fRight
> 0 )
1892 else if( fBottom
> 0 )
1895 Color
ColorLeft( COL_BLACK
);
1896 Color
ColorTop( COL_BLACK
);
1897 Color
ColorRight( COL_BLACK
);
1898 Color
ColorBottom( COL_BLACK
);
1899 sal_uInt16 nFrmColVal
= aFrameColor
.pData
[ nColorIndex
].Value
;
1900 SCROW nFrmColRow
= static_cast<SCROW
>(aFrameColor
.pData
[ nColorIndex
].Row
);
1901 sal_uInt16 cLeft
= ( nFrmColVal
& 0x000F );
1902 sal_uInt16 cTop
= ( nFrmColVal
& 0x00F0 ) >> 4;
1903 sal_uInt16 cRight
= ( nFrmColVal
& 0x0F00 ) >> 8;
1904 sal_uInt16 cBottom
= ( nFrmColVal
& 0xF000 ) >> 12;
1906 lcl_ChangeColor( cLeft
, ColorLeft
);
1907 lcl_ChangeColor( cTop
, ColorTop
);
1908 lcl_ChangeColor( cRight
, ColorRight
);
1909 lcl_ChangeColor( cBottom
, ColorBottom
);
1911 if( static_cast<SCROW
>(pColData
->Row
) < nFrmColRow
)
1913 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1914 if( nFrameIndex
< ( aFrame
.Count
- 1 ) )
1917 else if( static_cast<SCROW
>(pColData
->Row
) > nFrmColRow
)
1919 nEnd
= static_cast<SCROW
>(aFrameColor
.pData
[ nColorIndex
].Row
);
1920 if( nColorIndex
< ( aFrameColor
.Count
- 1 ) )
1926 if( nFrameIndex
< (aFrame
.Count
- 1 ) )
1928 if( nColorIndex
< ( aFrameColor
.Count
- 1 ) )
1931 if( ( nStart
<= nEnd
) && ( nValue
!= 0 ) )
1933 ScPatternAttr
aScPattern(pDoc
->GetPool());
1934 ::editeng::SvxBorderLine aLine
;
1935 SvxBoxItem
aBox( ATTR_BORDER
);
1937 aLine
.SetWidth( nLeft
);
1938 aLine
.SetColor( ColorLeft
);
1939 aBox
.SetLine( &aLine
, SvxBoxItemLine::LEFT
);
1941 aLine
.SetWidth( nTop
);
1942 aLine
.SetColor( ColorTop
);
1943 aBox
.SetLine( &aLine
, SvxBoxItemLine::TOP
);
1945 aLine
.SetWidth( nRight
);
1946 aLine
.SetColor( ColorRight
);
1947 aBox
.SetLine( &aLine
, SvxBoxItemLine::RIGHT
);
1949 aLine
.SetWidth( nBottom
);
1950 aLine
.SetColor( ColorBottom
);
1951 aBox
.SetLine( &aLine
, SvxBoxItemLine::BOTTOM
);
1953 aScPattern
.GetItemSet().Put( aBox
);
1954 pDoc
->ApplyPatternAreaTab( Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1958 bEnd
= ( nFrameIndex
== ( aFrame
.Count
- 1 ) ) && ( nColorIndex
== ( aFrameColor
.Count
- 1 ) );
1960 if( nColorIndexOld
!= nColorIndex
|| nFrameIndexOld
!= nFrameIndex
)
1962 nColorIndexOld
= nColorIndex
;
1963 nFrameIndexOld
= nFrameIndex
;
1964 nHelpMe
= nHelpMeStart
;
1972 // TODO: Code up to here works more or less ... from here I've had enough ! (GT)
1974 // Background (Color, Raster)
1975 sal_uInt16 nRasterIndex
= 0;
1982 nHelpMe
= nHelpMeStart
;
1983 sal_uInt16 nRasterIndexOld
= nRasterIndex
;
1985 while( !bEnd
&& nHelpMe
)
1987 sal_uInt16 nBColor
= ( aColor
.pData
[ nColorIndex
].Value
& 0x00F0 ) >> 4;
1988 sal_uInt16 nRColor
= ( aColor
.pData
[ nColorIndex
].Value
& 0x0F00 ) >> 8;
1989 Color
aBColor( COL_BLACK
);
1991 lcl_ChangeColor( nBColor
, aBColor
);
1994 aBColor
.SetColor( COL_WHITE
);
1995 else if( nBColor
== 15 )
1996 aBColor
.SetColor( COL_BLACK
);
1998 Color
aRColor( COL_BLACK
);
2000 lcl_ChangeColor( nRColor
, aRColor
);
2002 ScPatternAttr
aScPattern( pDoc
->GetPool() );
2005 bool bSwapCol
= false;
2006 bool bSetItem
= true;
2007 switch ( aRaster
.pData
[ nRasterIndex
].Value
)
2009 case raNone
: nFact
= 0xffff; bSwapCol
= true; bSetItem
= (nBColor
> 0); break;
2010 case raGray12
: nFact
= (0xffff / 100) * 12; break;
2011 case raGray25
: nFact
= (0xffff / 100) * 25; break;
2012 case raGray50
: nFact
= (0xffff / 100) * 50; break;
2013 case raGray75
: nFact
= (0xffff / 100) * 75; break;
2014 default: nFact
= 0xffff; bSetItem
= (nRColor
< 15);
2019 aScPattern
.GetItemSet().Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
2021 aScPattern
.GetItemSet().Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
2023 if( aRaster
.pData
[ nRasterIndex
].Row
< aColor
.pData
[ nColorIndex
].Row
)
2025 nEnd
= static_cast<SCROW
>(aRaster
.pData
[ nRasterIndex
].Row
);
2026 if( nRasterIndex
< ( aRaster
.Count
- 1 ) )
2029 else if( aRaster
.pData
[ nRasterIndex
].Row
> aColor
.pData
[ nColorIndex
].Row
)
2031 nEnd
= static_cast<SCROW
>(aColor
.pData
[ nColorIndex
].Row
);
2032 if( nColorIndex
< ( aColor
.Count
- 1 ) )
2037 nEnd
= static_cast<SCROW
>(aColor
.pData
[ nColorIndex
].Row
);
2038 if( nRasterIndex
< ( aRaster
.Count
- 1 ) )
2040 if( nColorIndex
< ( aColor
.Count
- 1 ) )
2043 if( nStart
<= nEnd
)
2044 pDoc
->ApplyPatternAreaTab( Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2048 bEnd
= ( nRasterIndex
== ( aRaster
.Count
- 1 ) ) && ( nColorIndex
== ( aColor
.Count
- 1 ) );
2050 if( nColorIndexOld
!= nColorIndex
|| nRasterIndexOld
!= nRasterIndex
)
2052 nColorIndexOld
= nColorIndex
;
2053 nRasterIndexOld
= nRasterIndex
;
2054 nHelpMe
= nHelpMeStart
;
2065 nLimit
= aValue
.Count
;
2066 pColData
= aValue
.pData
;
2067 for (i
=0; i
<nLimit
; i
++, pColData
++)
2069 nEnd
= static_cast<SCROW
>(pColData
->Row
);
2070 nValue1
= pColData
->Value
;
2071 if ((nStart
<= nEnd
) && (nValue1
))
2074 sal_uInt16 nFormat
= (nValue1
& 0x00FF);
2075 sal_uInt16 nInfo
= (nValue1
& 0xFF00) >> 8;
2076 ChangeFormat(nFormat
, nInfo
, nKey
);
2077 ScPatternAttr
aScPattern(pDoc
->GetPool());
2078 aScPattern
.GetItemSet().Put(SfxUInt32Item(ATTR_VALUE_FORMAT
, (sal_uInt32
)nKey
));
2079 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2084 // Cell attributes (protected, hidden...)
2087 for (i
=0; i
<aFlag
.Count
; i
++)
2089 nEnd
= static_cast<SCROW
>(aFlag
.pData
[i
].Row
);
2090 if ((nStart
<= nEnd
) && (aFlag
.pData
[i
].Value
!= 0))
2092 bool bProtect
= ((aFlag
.pData
[i
].Value
& paProtect
) == paProtect
);
2093 bool bHFormula
= ((aFlag
.pData
[i
].Value
& paHideFormula
) == paHideFormula
);
2094 bool bHCell
= ((aFlag
.pData
[i
].Value
& paHideAll
) == paHideAll
);
2095 bool bHPrint
= ((aFlag
.pData
[i
].Value
& paHidePrint
) == paHidePrint
);
2096 ScPatternAttr
aScPattern(pDoc
->GetPool());
2097 aScPattern
.GetItemSet().Put(ScProtectionAttr(bProtect
, bHFormula
, bHCell
, bHPrint
));
2098 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2106 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
2107 for (i
=0; i
<aPattern
.Count
; i
++)
2109 nEnd
= static_cast<SCROW
>(aPattern
.pData
[i
].Row
);
2110 if ((nStart
<= nEnd
) && (aPattern
.pData
[i
].Value
!= 0))
2112 sal_uInt16 nPatternIndex
= (aPattern
.pData
[i
].Value
& 0x00FF) - 1;
2113 Sc10PatternData
* pPattern
= pPatternCollection
->At(nPatternIndex
);
2114 if (pPattern
!= NULL
)
2116 ScStyleSheet
* pStyle
= static_cast<ScStyleSheet
*>( pStylePool
->Find(
2117 SC10TOSTRING( pPattern
->Name
), SFX_STYLE_FAMILY_PARA
) );
2120 pDoc
->ApplyStyleAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, *pStyle
);
2128 void Sc10Import::LoadAttr(Sc10ColAttr
& rAttr
)
2130 // rAttr is not reused, otherwise we'd have to delete [] rAttr.pData;
2131 rStream
.ReadUInt16(rAttr
.Count
);
2133 const size_t nMaxEntries
= rStream
.remainingSize() / (sizeof(sal_uInt16
) * 2);
2134 if (rAttr
.Count
> nMaxEntries
)
2135 rAttr
.Count
= nMaxEntries
;
2140 rAttr
.pData
= new (::std::nothrow
) Sc10ColData
[rAttr
.Count
];
2141 if (rAttr
.pData
== NULL
)
2143 nError
= errOutOfMemory
;
2148 for (sal_uInt16 i
= 0; i
< rAttr
.Count
; ++i
)
2150 rStream
.ReadUInt16( rAttr
.pData
[i
].Row
);
2151 rStream
.ReadUInt16( rAttr
.pData
[i
].Value
);
2154 nError
= rStream
.GetError();
2157 void Sc10Import::ChangeFormat(sal_uInt16 nFormat
, sal_uInt16 nInfo
, sal_uLong
& nKey
)
2159 // TODO: formats are mapped only for StarCalc 3.0 internal formats
2160 // more correctly, at times new formats need to be created (Stephan: please check!)
2190 // TODO: no equivalent
2213 case df_NDMY_Short
:
2265 case vfStandardRed
:
2275 case vfThousendRed
:
2287 case vfExponentRed
:
2299 void Sc10Import::LoadObjects()
2302 rStream
.ReadUInt16( ID
);
2303 if (rStream
.IsEof()) return;
2307 rStream
.ReadUInt16( nAnz
);
2308 sal_Char Reserved
[32];
2309 rStream
.Read(Reserved
, sizeof(Reserved
));
2310 nError
= rStream
.GetError();
2311 if ((nAnz
> 0) && (nError
== 0))
2313 sal_uInt8 ObjectType
;
2314 Sc10GraphHeader GraphHeader
;
2315 bool IsOleObject
= false; // TODO: this is only a bandaid
2316 for (sal_uInt16 i
= 0; (i
< nAnz
) && (nError
== 0) && !rStream
.IsEof() && !IsOleObject
; i
++)
2318 rStream
.ReadUChar( ObjectType
);
2319 lcl_ReadGraphHeader(rStream
, GraphHeader
);
2321 double nPPTX
= ScGlobal::nScreenPPTX
;
2322 double nPPTY
= ScGlobal::nScreenPPTY
;
2325 SCCOL nMaxCol
= SanitizeCol(GraphHeader
.CarretX
);
2326 for (SCCOL nX
= 0; nX
< nMaxCol
; ++nX
)
2327 nStartX
+= pDoc
->GetColWidth(nX
, static_cast<SCTAB
>(GraphHeader
.CarretZ
));
2328 nStartX
= (long) ( nStartX
* HMM_PER_TWIPS
);
2329 nStartX
+= (long) ( GraphHeader
.x
/ nPPTX
* HMM_PER_TWIPS
);
2330 long nSizeX
= (long) ( GraphHeader
.w
/ nPPTX
* HMM_PER_TWIPS
);
2331 long nStartY
= pDoc
->GetRowHeight( 0,
2332 SanitizeRow(static_cast<SCsROW
>(GraphHeader
.CarretY
) - 1),
2333 SanitizeTab(static_cast<SCTAB
>(GraphHeader
.CarretZ
)));
2334 nStartY
= (long) ( nStartY
* HMM_PER_TWIPS
);
2335 nStartY
+= (long) ( GraphHeader
.y
/ nPPTY
* HMM_PER_TWIPS
);
2336 long nSizeY
= (long) ( GraphHeader
.h
/ nPPTY
* HMM_PER_TWIPS
);
2341 // TODO: here we need to do something like OleLoadFromStream
2346 Sc10ImageHeader ImageHeader
;
2347 lcl_ReadImageHeaer(rStream
, ImageHeader
);
2349 // Attention: here come the data (Bitmap oder Metafile)
2350 // Typ = 1 Device-dependend Bitmap DIB
2352 rStream
.SeekRel(ImageHeader
.Size
);
2354 if( ImageHeader
.Typ
!= 1 && ImageHeader
.Typ
!= 2 )
2355 nError
= errUnknownFormat
;
2360 Sc10ChartHeader ChartHeader
;
2361 Sc10ChartSheetData ChartSheetData
;
2362 Sc10ChartTypeData
* pTypeData
= new (::std::nothrow
) Sc10ChartTypeData
;
2364 nError
= errOutOfMemory
;
2367 lcl_ReadChartHeader(rStream
, ChartHeader
);
2369 // TODO: use old Metafile ??
2370 rStream
.SeekRel(ChartHeader
.Size
);
2372 lcl_ReadChartSheetData(rStream
, ChartSheetData
);
2374 lcl_ReadChartTypeData(rStream
, *pTypeData
);
2376 Rectangle
aRect( Point(nStartX
,nStartY
), Size(nSizeX
,nSizeY
) );
2377 Sc10InsertObject::InsertChart( pDoc
, static_cast<SCTAB
>(GraphHeader
.CarretZ
), aRect
,
2378 static_cast<SCTAB
>(GraphHeader
.CarretZ
),
2379 ChartSheetData
.DataX1
, ChartSheetData
.DataY1
,
2380 ChartSheetData
.DataX2
, ChartSheetData
.DataY2
);
2387 nError
= errUnknownFormat
;
2390 nError
= rStream
.GetError();
2396 OSL_FAIL( "ObjectID" );
2397 nError
= errUnknownID
;
2401 FltError
ScFormatFilterPluginImpl::ScImportStarCalc10( SvStream
& rStream
, ScDocument
* pDocument
)
2403 rStream
.Seek( 0UL );
2404 Sc10Import
aImport( rStream
, pDocument
);
2405 return ( FltError
) aImport
.Import();
2408 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */