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>
50 #include "patattr.hxx"
51 #include "docpool.hxx"
52 #include "document.hxx"
53 #include "collect.hxx"
54 #include "rangenam.hxx"
56 #include "stlsheet.hxx"
57 #include "stlpool.hxx"
60 #include "formulacell.hxx"
62 #include "docoptio.hxx"
63 #include "viewopti.hxx"
65 #include "globstr.hrc"
67 #include "tabprotection.hxx"
69 #include "fprogressbar.hxx"
72 using namespace com::sun::star
;
74 #define DEFCHARSET RTL_TEXTENCODING_MS_1252
76 #define SC10TOSTRING(p) OUString((p), strlen(p), DEFCHARSET)
78 const SCCOL SC10MAXCOL
= 255; // #i85906# don't try to load more columns than there are in the file
80 /** Those strings are used with SC10TOSTRING() and strcmp() and such, hence
81 need to be 0-terminated. */
82 static void lcl_ReadFixedString( SvStream
& rStream
, void* pData
, size_t nLen
)
84 sal_Char
* pBuf
= static_cast<sal_Char
*>(pData
);
89 rStream
.Read( pBuf
, nLen
);
94 static void lcl_ReadFileHeader(SvStream
& rStream
, Sc10FileHeader
& rFileHeader
)
96 lcl_ReadFixedString( rStream
, &rFileHeader
.CopyRight
, sizeof(rFileHeader
.CopyRight
));
97 rStream
.ReadUInt16( rFileHeader
.Version
);
98 rStream
.Read(&rFileHeader
.Reserved
, sizeof(rFileHeader
.Reserved
));
101 static void lcl_ReadTabProtect(SvStream
& rStream
, Sc10TableProtect
& rProtect
)
103 lcl_ReadFixedString( rStream
, &rProtect
.PassWord
, sizeof(rProtect
.PassWord
));
104 rStream
.ReadUInt16( rProtect
.Flags
);
105 rStream
.ReadUChar( rProtect
.Protect
);
108 static void lcl_ReadSheetProtect(SvStream
& rStream
, Sc10SheetProtect
& rProtect
)
110 lcl_ReadFixedString( rStream
, &rProtect
.PassWord
, sizeof(rProtect
.PassWord
));
111 rStream
.ReadUInt16( rProtect
.Flags
);
112 rStream
.ReadUChar( rProtect
.Protect
);
115 static void lcl_ReadRGB(SvStream
& rStream
, Sc10Color
& rColor
)
117 rStream
.ReadUChar( rColor
.Dummy
);
118 rStream
.ReadUChar( rColor
.Blue
);
119 rStream
.ReadUChar( rColor
.Green
);
120 rStream
.ReadUChar( rColor
.Red
);
123 static void lcl_ReadPalette(SvStream
& rStream
, Sc10Color
* pPalette
)
125 for (sal_uInt16 i
= 0; i
< 16; i
++)
126 lcl_ReadRGB(rStream
, pPalette
[i
]);
129 static void lcl_ReadValueFormat(SvStream
& rStream
, Sc10ValueFormat
& rFormat
)
131 rStream
.ReadUChar( rFormat
.Format
);
132 rStream
.ReadUChar( rFormat
.Info
);
135 static void lcl_ReadLogFont(SvStream
& rStream
, Sc10LogFont
& rFont
)
137 rStream
.ReadInt16( rFont
.lfHeight
);
138 rStream
.ReadInt16( rFont
.lfWidth
);
139 rStream
.ReadInt16( rFont
.lfEscapement
);
140 rStream
.ReadInt16( rFont
.lfOrientation
);
141 rStream
.ReadInt16( rFont
.lfWeight
);
142 rStream
.ReadUChar( rFont
.lfItalic
);
143 rStream
.ReadUChar( rFont
.lfUnderline
);
144 rStream
.ReadUChar( rFont
.lfStrikeOut
);
145 rStream
.ReadUChar( rFont
.lfCharSet
);
146 rStream
.ReadUChar( rFont
.lfOutPrecision
);
147 rStream
.ReadUChar( rFont
.lfClipPrecision
);
148 rStream
.ReadUChar( rFont
.lfQuality
);
149 rStream
.ReadUChar( rFont
.lfPitchAndFamily
);
150 lcl_ReadFixedString( rStream
, &rFont
.lfFaceName
, sizeof(rFont
.lfFaceName
));
153 static void lcl_ReadBlockRect(SvStream
& rStream
, Sc10BlockRect
& rBlock
)
155 rStream
.ReadInt16( rBlock
.x1
);
156 rStream
.ReadInt16( rBlock
.y1
);
157 rStream
.ReadInt16( rBlock
.x2
);
158 rStream
.ReadInt16( rBlock
.y2
);
161 static void lcl_ReadHeadFootLine(SvStream
& rStream
, Sc10HeadFootLine
& rLine
)
163 lcl_ReadFixedString( rStream
, &rLine
.Title
, sizeof(rLine
.Title
));
164 lcl_ReadLogFont(rStream
, rLine
.LogFont
);
165 rStream
.ReadUChar( rLine
.HorJustify
);
166 rStream
.ReadUChar( rLine
.VerJustify
);
167 rStream
.ReadUInt16( rLine
.Raster
);
168 rStream
.ReadUInt16( rLine
.Frame
);
169 lcl_ReadRGB(rStream
, rLine
.TextColor
);
170 lcl_ReadRGB(rStream
, rLine
.BackColor
);
171 lcl_ReadRGB(rStream
, rLine
.RasterColor
);
172 rStream
.ReadUInt16( rLine
.FrameColor
);
173 rStream
.ReadUInt16( rLine
.Reserved
);
176 static void lcl_ReadPageFormat(SvStream
& rStream
, Sc10PageFormat
& rFormat
)
178 lcl_ReadHeadFootLine(rStream
, rFormat
.HeadLine
);
179 lcl_ReadHeadFootLine(rStream
, rFormat
.FootLine
);
180 rStream
.ReadInt16( rFormat
.Orientation
);
181 rStream
.ReadInt16( rFormat
.Width
);
182 rStream
.ReadInt16( rFormat
.Height
);
183 rStream
.ReadInt16( rFormat
.NonPrintableX
);
184 rStream
.ReadInt16( rFormat
.NonPrintableY
);
185 rStream
.ReadInt16( rFormat
.Left
);
186 rStream
.ReadInt16( rFormat
.Top
);
187 rStream
.ReadInt16( rFormat
.Right
);
188 rStream
.ReadInt16( rFormat
.Bottom
);
189 rStream
.ReadInt16( rFormat
.Head
);
190 rStream
.ReadInt16( rFormat
.Foot
);
191 rStream
.ReadUChar( rFormat
.HorCenter
);
192 rStream
.ReadUChar( rFormat
.VerCenter
);
193 rStream
.ReadUChar( rFormat
.PrintGrid
);
194 rStream
.ReadUChar( rFormat
.PrintColRow
);
195 rStream
.ReadUChar( rFormat
.PrintNote
);
196 rStream
.ReadUChar( rFormat
.TopBottomDir
);
197 lcl_ReadFixedString( rStream
, &rFormat
.PrintAreaName
, sizeof(rFormat
.PrintAreaName
));
198 lcl_ReadBlockRect(rStream
, rFormat
.PrintArea
);
199 rStream
.Read(&rFormat
.PrnZoom
, sizeof(rFormat
.PrnZoom
));
200 rStream
.ReadInt16( rFormat
.FirstPageNo
);
201 rStream
.ReadInt16( rFormat
.RowRepeatStart
);
202 rStream
.ReadInt16( rFormat
.RowRepeatEnd
);
203 rStream
.ReadInt16( rFormat
.ColRepeatStart
);
204 rStream
.ReadInt16( rFormat
.ColRepeatEnd
);
205 rStream
.Read(&rFormat
.Reserved
, sizeof(rFormat
.Reserved
));
208 static void lcl_ReadGraphHeader(SvStream
& rStream
, Sc10GraphHeader
& rHeader
)
210 rStream
.ReadUChar( rHeader
.Typ
);
211 rStream
.ReadInt16( rHeader
.CarretX
);
212 rStream
.ReadInt16( rHeader
.CarretY
);
213 rStream
.ReadInt16( rHeader
.CarretZ
);
214 rStream
.ReadInt32( rHeader
.x
);
215 rStream
.ReadInt32( rHeader
.y
);
216 rStream
.ReadInt32( rHeader
.w
);
217 rStream
.ReadInt32( rHeader
.h
);
218 rStream
.ReadUChar( rHeader
.IsRelPos
);
219 rStream
.ReadUChar( rHeader
.DoPrint
);
220 rStream
.ReadUInt16( rHeader
.FrameType
);
221 rStream
.ReadUChar( rHeader
.IsTransparent
);
222 lcl_ReadRGB(rStream
, rHeader
.FrameColor
);
223 lcl_ReadRGB(rStream
, rHeader
.BackColor
);
224 rStream
.Read(&rHeader
.Reserved
, sizeof(rHeader
.Reserved
));
227 static void lcl_ReadImageHeaer(SvStream
& rStream
, Sc10ImageHeader
& rHeader
)
229 lcl_ReadFixedString( rStream
, &rHeader
.FileName
, sizeof(rHeader
.FileName
));
230 rStream
.ReadInt16( rHeader
.Typ
);
231 rStream
.ReadUChar( rHeader
.Linked
);
232 rStream
.ReadInt16( rHeader
.x1
);
233 rStream
.ReadInt16( rHeader
.y1
);
234 rStream
.ReadInt16( rHeader
.x2
);
235 rStream
.ReadInt16( rHeader
.y2
);
236 rStream
.ReadUInt32( rHeader
.Size
);
239 static void lcl_ReadChartHeader(SvStream
& rStream
, Sc10ChartHeader
& rHeader
)
241 rStream
.ReadInt16( rHeader
.MM
);
242 rStream
.ReadInt16( rHeader
.xExt
);
243 rStream
.ReadInt16( rHeader
.yExt
);
244 rStream
.ReadUInt32( rHeader
.Size
);
247 static void lcl_ReadChartSheetData(SvStream
& rStream
, Sc10ChartSheetData
& rSheetData
)
249 rStream
.ReadUChar( rSheetData
.HasTitle
);
250 rStream
.ReadInt16( rSheetData
.TitleX
);
251 rStream
.ReadInt16( rSheetData
.TitleY
);
252 rStream
.ReadUChar( rSheetData
.HasSubTitle
);
253 rStream
.ReadInt16( rSheetData
.SubTitleX
);
254 rStream
.ReadInt16( rSheetData
.SubTitleY
);
255 rStream
.ReadUChar( rSheetData
.HasLeftTitle
);
256 rStream
.ReadInt16( rSheetData
.LeftTitleX
);
257 rStream
.ReadInt16( rSheetData
.LeftTitleY
);
258 rStream
.ReadUChar( rSheetData
.HasLegend
);
259 rStream
.ReadInt16( rSheetData
.LegendX1
);
260 rStream
.ReadInt16( rSheetData
.LegendY1
);
261 rStream
.ReadInt16( rSheetData
.LegendX2
);
262 rStream
.ReadInt16( rSheetData
.LegendY2
);
263 rStream
.ReadUChar( rSheetData
.HasLabel
);
264 rStream
.ReadInt16( rSheetData
.LabelX1
);
265 rStream
.ReadInt16( rSheetData
.LabelY1
);
266 rStream
.ReadInt16( rSheetData
.LabelX2
);
267 rStream
.ReadInt16( rSheetData
.LabelY2
);
268 rStream
.ReadInt16( rSheetData
.DataX1
);
269 rStream
.ReadInt16( rSheetData
.DataY1
);
270 rStream
.ReadInt16( rSheetData
.DataX2
);
271 rStream
.ReadInt16( rSheetData
.DataY2
);
272 rStream
.Read(&rSheetData
.Reserved
, sizeof(rSheetData
.Reserved
));
275 static void lcl_ReadChartTypeData(SvStream
& rStream
, Sc10ChartTypeData
& rTypeData
)
277 rStream
.ReadInt16( rTypeData
.NumSets
);
278 rStream
.ReadInt16( rTypeData
.NumPoints
);
279 rStream
.ReadInt16( rTypeData
.DrawMode
);
280 rStream
.ReadInt16( rTypeData
.GraphType
);
281 rStream
.ReadInt16( rTypeData
.GraphStyle
);
282 lcl_ReadFixedString( rStream
, &rTypeData
.GraphTitle
, sizeof(rTypeData
.GraphTitle
));
283 lcl_ReadFixedString( rStream
, &rTypeData
.BottomTitle
, sizeof(rTypeData
.BottomTitle
));
285 for (i
= 0; i
< 256; i
++)
286 rStream
.ReadInt16( rTypeData
.SymbolData
[i
] );
287 for (i
= 0; i
< 256; i
++)
288 rStream
.ReadInt16( rTypeData
.ColorData
[i
] );
289 for (i
= 0; i
< 256; i
++)
290 rStream
.ReadInt16( rTypeData
.ThickLines
[i
] );
291 for (i
= 0; i
< 256; i
++)
292 rStream
.ReadInt16( rTypeData
.PatternData
[i
] );
293 for (i
= 0; i
< 256; i
++)
294 rStream
.ReadInt16( rTypeData
.LinePatternData
[i
] );
295 for (i
= 0; i
< 11; i
++)
296 rStream
.ReadInt16( rTypeData
.NumGraphStyles
[i
] );
297 rStream
.ReadInt16( rTypeData
.ShowLegend
);
298 for (i
= 0; i
< 256; i
++)
299 lcl_ReadFixedString( rStream
, &rTypeData
.LegendText
[i
], sizeof(Sc10ChartText
));
300 rStream
.ReadInt16( rTypeData
.ExplodePie
);
301 rStream
.ReadInt16( rTypeData
.FontUse
);
302 for (i
= 0; i
< 5; i
++)
303 rStream
.ReadInt16( rTypeData
.FontFamily
[i
] );
304 for (i
= 0; i
< 5; i
++)
305 rStream
.ReadInt16( rTypeData
.FontStyle
[i
] );
306 for (i
= 0; i
< 5; i
++)
307 rStream
.ReadInt16( rTypeData
.FontSize
[i
] );
308 rStream
.ReadInt16( rTypeData
.GridStyle
);
309 rStream
.ReadInt16( rTypeData
.Labels
);
310 rStream
.ReadInt16( rTypeData
.LabelEvery
);
311 for (i
= 0; i
< 50; i
++)
312 lcl_ReadFixedString( rStream
, &rTypeData
.LabelText
[i
], sizeof(Sc10ChartText
));
313 lcl_ReadFixedString( rStream
, &rTypeData
.LeftTitle
, sizeof(rTypeData
.LeftTitle
));
314 rStream
.Read(&rTypeData
.Reserved
, sizeof(rTypeData
.Reserved
));
317 static double lcl_PascalToDouble(sal_Char
* tp6
)
319 sal_uInt8
* pnUnsigned
= reinterpret_cast< sal_uInt8
* >( tp6
);
321 sal_uInt8 be
= pnUnsigned
[ 0 ];
322 // lower 16 bits of mantissa
323 sal_uInt16 v1
= static_cast< sal_uInt16
>( pnUnsigned
[ 2 ] * 256 + pnUnsigned
[ 1 ] );
324 // next 16 bits of mantissa
325 sal_uInt16 v2
= static_cast< sal_uInt16
>( pnUnsigned
[ 4 ] * 256 + pnUnsigned
[ 3 ] );
326 // upper 7 bits of mantissa
327 sal_uInt8 v3
= static_cast< sal_uInt8
>( pnUnsigned
[ 5 ] & 0x7F );
329 bool s
= (pnUnsigned
[ 5 ] & 0x80) != 0;
333 return (((((128 + v3
) * 65536.0) + v2
) * 65536.0 + v1
) *
334 ldexp ((s
? -1.0 : 1.0), be
- (129+39)));
337 static void lcl_ChangeColor( sal_uInt16 nIndex
, Color
& rColor
)
343 case 1: aCol
= COL_RED
; break;
344 case 2: aCol
= COL_GREEN
; break;
345 case 3: aCol
= COL_BROWN
; break;
346 case 4: aCol
= COL_BLUE
; break;
347 case 5: aCol
= COL_MAGENTA
; break;
348 case 6: aCol
= COL_CYAN
; break;
349 case 7: aCol
= COL_GRAY
; break;
350 case 8: aCol
= COL_LIGHTGRAY
; break;
351 case 9: aCol
= COL_LIGHTRED
; break;
352 case 10: aCol
= COL_LIGHTGREEN
; break;
353 case 11: aCol
= COL_YELLOW
; break;
354 case 12: aCol
= COL_LIGHTBLUE
; break;
355 case 13: aCol
= COL_LIGHTMAGENTA
; break;
356 case 14: aCol
= COL_LIGHTCYAN
; break;
357 case 15: aCol
= COL_WHITE
; break;
358 default: aCol
= COL_BLACK
;
361 rColor
.SetColor( aCol
);
364 static OUString
lcl_MakeOldPageStyleFormatName( sal_uInt16 i
)
366 OUString aName
= ScGlobal::GetRscString( STR_PAGESTYLE
) + " " + OUString::number( i
+ 1 );
370 template < typename T
> sal_uLong
insert_new( ScCollection
* pCollection
, SvStream
& rStream
)
372 std::unique_ptr
<T
> pData(new (::std::nothrow
) T( rStream
));
373 sal_uLong nError
= rStream
.GetError();
377 pCollection
->Insert( pData
.release() );
380 nError
= errOutOfMemory
;
386 Sc10FontData::Sc10FontData(SvStream
& rStream
)
391 rStream
.ReadInt16( Height
);
392 rStream
.ReadUChar( CharSet
);
393 rStream
.ReadUChar( PitchAndFamily
);
395 rStream
.ReadUInt16( nLen
);
396 if (nLen
< sizeof(FaceName
))
397 rStream
.Read(FaceName
, nLen
);
399 rStream
.SetError(ERRCODE_IO_WRONGFORMAT
);
402 Sc10FontCollection::Sc10FontCollection(SvStream
& rStream
)
407 rStream
.ReadUInt16( ID
);
411 rStream
.ReadUInt16( nAnz
);
412 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
414 nError
= insert_new
<Sc10FontData
>( this, rStream
);
419 OSL_FAIL( "FontID" );
420 nError
= errUnknownID
;
426 Sc10NameData::Sc10NameData(SvStream
& rStream
)
429 rStream
.ReadUChar( nLen
);
430 rStream
.Read(Name
, sizeof(Name
) - 1);
431 if (nLen
>= sizeof(Name
))
432 nLen
= sizeof(Name
) - 1;
435 rStream
.ReadUChar( nLen
);
436 rStream
.Read(Reference
, sizeof(Reference
) - 1);
437 if (nLen
>= sizeof(Reference
))
438 nLen
= sizeof(Reference
) - 1;
440 rStream
.Read(Reserved
, sizeof(Reserved
));
443 Sc10NameCollection::Sc10NameCollection(SvStream
& rStream
) :
448 rStream
.ReadUInt16( ID
);
452 rStream
.ReadUInt16( nAnz
);
453 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
455 nError
= insert_new
<Sc10NameData
>( this, rStream
);
460 OSL_FAIL( "NameID" );
461 nError
= errUnknownID
;
466 Sc10PatternData::Sc10PatternData(SvStream
& rStream
)
476 memset(Name
, 0, sizeof(Name
));
477 memset(Reserved
, 0, sizeof(Reserved
));
478 lcl_ReadFixedString( rStream
, Name
, sizeof(Name
));
479 lcl_ReadValueFormat(rStream
, ValueFormat
);
480 lcl_ReadLogFont(rStream
, LogFont
);
482 rStream
.ReadUInt16( Attr
);
483 rStream
.ReadUInt16( Justify
);
484 rStream
.ReadUInt16( Frame
);
485 rStream
.ReadUInt16( Raster
);
486 rStream
.ReadUInt16( nColor
);
487 rStream
.ReadUInt16( FrameColor
);
488 rStream
.ReadUInt16( Flags
);
489 rStream
.ReadUInt16( FormatFlags
);
490 rStream
.Read(Reserved
, sizeof(Reserved
));
493 Sc10PatternCollection::Sc10PatternCollection(SvStream
& rStream
)
498 rStream
.ReadUInt16( ID
);
502 rStream
.ReadUInt16( nAnz
);
503 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
505 nError
= insert_new
<Sc10PatternData
>( this, rStream
);
510 OSL_FAIL( "PatternID" );
511 nError
= errUnknownID
;
517 Sc10DataBaseData::Sc10DataBaseData(SvStream
& rStream
)
519 lcl_ReadFixedString( rStream
, &DataBaseRec
.Name
, sizeof(DataBaseRec
.Name
));
520 rStream
.ReadInt16( DataBaseRec
.Tab
);
521 lcl_ReadBlockRect(rStream
, DataBaseRec
.Block
);
522 rStream
.ReadUChar( DataBaseRec
.RowHeader
);
523 rStream
.ReadInt16( DataBaseRec
.SortField0
);
524 rStream
.ReadUChar( DataBaseRec
.SortUpOrder0
);
525 rStream
.ReadInt16( DataBaseRec
.SortField1
);
526 rStream
.ReadUChar( DataBaseRec
.SortUpOrder1
);
527 rStream
.ReadInt16( DataBaseRec
.SortField2
);
528 rStream
.ReadUChar( DataBaseRec
.SortUpOrder2
);
529 rStream
.ReadUChar( DataBaseRec
.IncludeFormat
);
531 rStream
.ReadInt16( DataBaseRec
.QueryField0
);
532 rStream
.ReadInt16( DataBaseRec
.QueryOp0
);
533 rStream
.ReadUChar( DataBaseRec
.QueryByString0
);
534 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString0
, sizeof(DataBaseRec
.QueryString0
));
535 DataBaseRec
.QueryValue0
= ScfTools::ReadLongDouble(rStream
);
537 rStream
.ReadInt16( DataBaseRec
.QueryConnect1
);
538 rStream
.ReadInt16( DataBaseRec
.QueryField1
);
539 rStream
.ReadInt16( DataBaseRec
.QueryOp1
);
540 rStream
.ReadUChar( DataBaseRec
.QueryByString1
);
541 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString1
, sizeof(DataBaseRec
.QueryString1
));
542 DataBaseRec
.QueryValue1
= ScfTools::ReadLongDouble(rStream
);
544 rStream
.ReadInt16( DataBaseRec
.QueryConnect2
);
545 rStream
.ReadInt16( DataBaseRec
.QueryField2
);
546 rStream
.ReadInt16( DataBaseRec
.QueryOp2
);
547 rStream
.ReadUChar( DataBaseRec
.QueryByString2
);
548 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString2
, sizeof(DataBaseRec
.QueryString2
));
549 DataBaseRec
.QueryValue2
= ScfTools::ReadLongDouble(rStream
);
552 Sc10DataBaseCollection::Sc10DataBaseCollection(SvStream
& rStream
)
557 rStream
.ReadUInt16( ID
);
558 if (ID
== DataBaseID
)
560 lcl_ReadFixedString( rStream
, ActName
, sizeof(ActName
));
562 rStream
.ReadUInt16( nAnz
);
563 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
565 nError
= insert_new
<Sc10DataBaseData
>( this, rStream
);
570 OSL_FAIL( "DataBaseID" );
571 nError
= errUnknownID
;
575 bool Sc10LogFont::operator==( const Sc10LogFont
& rData
) const
577 return !strcmp( lfFaceName
, rData
.lfFaceName
)
578 && lfHeight
== rData
.lfHeight
579 && lfWidth
== rData
.lfWidth
580 && lfEscapement
== rData
.lfEscapement
581 && lfOrientation
== rData
.lfOrientation
582 && lfWeight
== rData
.lfWeight
583 && lfItalic
== rData
.lfItalic
584 && lfUnderline
== rData
.lfUnderline
585 && lfStrikeOut
== rData
.lfStrikeOut
586 && lfCharSet
== rData
.lfCharSet
587 && lfOutPrecision
== rData
.lfOutPrecision
588 && lfClipPrecision
== rData
.lfClipPrecision
589 && lfQuality
== rData
.lfQuality
590 && lfPitchAndFamily
== rData
.lfPitchAndFamily
;
593 bool Sc10Color::operator==( const Sc10Color
& rColor
) const
595 return ((Red
== rColor
.Red
) && (Green
== rColor
.Green
) && (Blue
== rColor
.Blue
));
598 bool Sc10HeadFootLine::operator==( const Sc10HeadFootLine
& rData
) const
600 return !strcmp(Title
, rData
.Title
)
601 && LogFont
== rData
.LogFont
602 && HorJustify
== rData
.HorJustify
603 && VerJustify
== rData
.VerJustify
604 && Raster
== rData
.Raster
605 && Frame
== rData
.Frame
606 && TextColor
== rData
.TextColor
607 && BackColor
== rData
.BackColor
608 && RasterColor
== rData
.RasterColor
609 && FrameColor
== rData
.FrameColor
610 && Reserved
== rData
.Reserved
;
613 bool Sc10PageFormat::operator==( const Sc10PageFormat
& rData
) const
615 return !strcmp(PrintAreaName
, rData
.PrintAreaName
)
616 && HeadLine
== rData
.HeadLine
617 && FootLine
== rData
.FootLine
618 && Orientation
== rData
.Orientation
619 && Width
== rData
.Width
620 && Height
== rData
.Height
621 && NonPrintableX
== rData
.NonPrintableX
622 && NonPrintableY
== rData
.NonPrintableY
623 && Left
== rData
.Left
625 && Right
== rData
.Right
626 && Bottom
== rData
.Bottom
627 && Head
== rData
.Head
628 && Foot
== rData
.Foot
629 && HorCenter
== rData
.HorCenter
630 && VerCenter
== rData
.VerCenter
631 && PrintGrid
== rData
.PrintGrid
632 && PrintColRow
== rData
.PrintColRow
633 && PrintNote
== rData
.PrintNote
634 && TopBottomDir
== rData
.TopBottomDir
635 && FirstPageNo
== rData
.FirstPageNo
636 && RowRepeatStart
== rData
.RowRepeatStart
637 && RowRepeatEnd
== rData
.RowRepeatEnd
638 && ColRepeatStart
== rData
.ColRepeatStart
639 && ColRepeatEnd
== rData
.ColRepeatEnd
640 && !memcmp( PrnZoom
, rData
.PrnZoom
, sizeof(PrnZoom
) )
641 && !memcmp( &PrintArea
, &rData
.PrintArea
, sizeof(PrintArea
) );
644 sal_uInt16
Sc10PageCollection::InsertFormat( const Sc10PageFormat
& rData
)
646 for (sal_uInt16 i
=0; i
<nCount
; i
++)
647 if (At(i
)->aPageFormat
== rData
)
650 Insert( new Sc10PageData(rData
) );
655 static inline sal_uInt8
GetMixedCol( const sal_uInt8 nB
, const sal_uInt8 nF
, const sal_uInt16 nFak
)
657 sal_Int32 nT
= nB
- nF
;
658 nT
*= ( sal_Int32
) nFak
;
661 return ( sal_uInt8
) nT
;
663 static inline Color
GetMixedColor( const Color
& rFore
, const Color
& rBack
, sal_uInt16 nFact
)
665 return Color( GetMixedCol( rBack
.GetRed(), rFore
.GetRed(), nFact
),
666 GetMixedCol( rBack
.GetGreen(), rFore
.GetGreen(), nFact
),
667 GetMixedCol( rBack
.GetBlue(), rFore
.GetBlue(), nFact
) );
670 void Sc10PageCollection::PutToDoc( ScDocument
* pDoc
)
672 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
673 EditEngine
aEditEngine( pDoc
->GetEnginePool() );
674 EditTextObject
* pEmptyObject
= aEditEngine
.CreateTextObject();
676 for (sal_uInt16 i
=0; i
<nCount
; i
++)
678 Sc10PageFormat
* pPage
= &At(i
)->aPageFormat
;
680 pPage
->Width
= (short) ( pPage
->Width
+ 0.5 );
681 pPage
->Height
= (short) ( pPage
->Height
+ 0.5 );
682 pPage
->Top
= (short) ( pPage
->Top
+ 0.5 );
683 pPage
->Bottom
= (short) ( pPage
->Bottom
+ 0.5 );
684 pPage
->Left
= (short) ( pPage
->Left
+ 0.5 );
685 pPage
->Right
= (short) ( pPage
->Right
+ 0.5 );
686 pPage
->Head
= (short) ( pPage
->Head
+ 0.5 );
687 pPage
->Foot
= (short) ( pPage
->Foot
+ 0.5 );
689 OUString aName
= lcl_MakeOldPageStyleFormatName( i
);
691 ScStyleSheet
* pSheet
= static_cast<ScStyleSheet
*>( &pStylePool
->Make( aName
,
692 SfxStyleFamily::Page
,
693 SFXSTYLEBIT_USERDEF
| SCSTYLEBIT_STANDARD
) );
694 // #i68483# set page style name at sheet...
695 pDoc
->SetPageStyle( static_cast< SCTAB
>( i
), aName
);
697 SfxItemSet
* pSet
= &pSheet
->GetItemSet();
699 for (sal_uInt16 nHeadFoot
=0; nHeadFoot
<2; nHeadFoot
++)
701 Sc10HeadFootLine
* pHeadFootLine
= nHeadFoot
? &pPage
->FootLine
: &pPage
->HeadLine
;
703 SfxItemSet
aEditAttribs(aEditEngine
.GetEmptyItemSet());
704 FontFamily eFam
= FAMILY_DONTKNOW
;
705 switch (pPage
->HeadLine
.LogFont
.lfPitchAndFamily
& 0xF0)
707 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
708 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
709 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
710 case ffModern
: eFam
= FAMILY_MODERN
; break;
711 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
712 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
713 default: eFam
= FAMILY_DONTKNOW
; break;
715 aEditAttribs
.Put( SvxFontItem(
717 SC10TOSTRING( pHeadFootLine
->LogFont
.lfFaceName
), EMPTY_OUSTRING
,
718 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, EE_CHAR_FONTINFO
),
720 aEditAttribs
.Put( SvxFontHeightItem( std::abs( pHeadFootLine
->LogFont
.lfHeight
), 100, EE_CHAR_FONTHEIGHT
),
723 Sc10Color nColor
= pHeadFootLine
->TextColor
;
724 Color
TextColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
725 aEditAttribs
.Put(SvxColorItem(TextColor
, EE_CHAR_COLOR
), EE_CHAR_COLOR
);
727 if (pHeadFootLine
->LogFont
.lfWeight
!= fwNormal
)
728 aEditAttribs
.Put(SvxWeightItem(WEIGHT_BOLD
, EE_CHAR_WEIGHT
), EE_CHAR_WEIGHT
);
729 if (pHeadFootLine
->LogFont
.lfItalic
!= 0)
730 aEditAttribs
.Put(SvxPostureItem(ITALIC_NORMAL
, EE_CHAR_ITALIC
), EE_CHAR_ITALIC
);
731 if (pHeadFootLine
->LogFont
.lfUnderline
!= 0)
732 aEditAttribs
.Put(SvxUnderlineItem(LINESTYLE_SINGLE
, EE_CHAR_UNDERLINE
), EE_CHAR_UNDERLINE
);
733 if (pHeadFootLine
->LogFont
.lfStrikeOut
!= 0)
734 aEditAttribs
.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE
, EE_CHAR_STRIKEOUT
), EE_CHAR_STRIKEOUT
);
735 OUString
aText( pHeadFootLine
->Title
, strlen(pHeadFootLine
->Title
), DEFCHARSET
);
736 aEditEngine
.SetText( aText
);
737 aEditEngine
.QuickSetAttribs( aEditAttribs
, ESelection( 0, 0, 0, aText
.getLength() ) );
739 EditTextObject
* pObject
= aEditEngine
.CreateTextObject();
740 ScPageHFItem
aHeaderItem(nHeadFoot
? ATTR_PAGE_FOOTERRIGHT
: ATTR_PAGE_HEADERRIGHT
);
741 switch (pHeadFootLine
->HorJustify
)
744 aHeaderItem
.SetLeftArea(*pEmptyObject
);
745 aHeaderItem
.SetCenterArea(*pObject
);
746 aHeaderItem
.SetRightArea(*pEmptyObject
);
749 aHeaderItem
.SetLeftArea(*pEmptyObject
);
750 aHeaderItem
.SetCenterArea(*pEmptyObject
);
751 aHeaderItem
.SetRightArea(*pObject
);
754 aHeaderItem
.SetLeftArea(*pObject
);
755 aHeaderItem
.SetCenterArea(*pEmptyObject
);
756 aHeaderItem
.SetRightArea(*pEmptyObject
);
760 pSet
->Put( aHeaderItem
);
762 SfxItemSet
aSetItemItemSet( *pDoc
->GetPool(),
763 ATTR_BACKGROUND
, ATTR_BACKGROUND
,
764 ATTR_BORDER
, ATTR_SHADOW
,
765 ATTR_PAGE_SIZE
, ATTR_PAGE_SIZE
,
766 ATTR_LRSPACE
, ATTR_ULSPACE
,
767 ATTR_PAGE_ON
, ATTR_PAGE_SHARED
,
769 nColor
= pHeadFootLine
->BackColor
;
770 Color
aBColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
771 nColor
= pHeadFootLine
->RasterColor
;
772 Color
aRColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
775 bool bSwapCol
= false;
776 switch (pHeadFootLine
->Raster
)
778 case raNone
: nFact
= 0xffff; bSwapCol
= true; break;
779 case raGray12
: nFact
= (0xffff / 100) * 12; break;
780 case raGray25
: nFact
= (0xffff / 100) * 25; break;
781 case raGray50
: nFact
= (0xffff / 100) * 50; break;
782 case raGray75
: nFact
= (0xffff / 100) * 75; break;
783 default: nFact
= 0xffff;
786 aSetItemItemSet
.Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
788 aSetItemItemSet
.Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
790 if (pHeadFootLine
->Frame
!= 0)
792 sal_uInt16 nLeft
= 0;
794 sal_uInt16 nRight
= 0;
795 sal_uInt16 nBottom
= 0;
796 sal_uInt16 fLeft
= (pHeadFootLine
->Frame
& 0x000F);
797 sal_uInt16 fTop
= (pHeadFootLine
->Frame
& 0x00F0) / 0x0010;
798 sal_uInt16 fRight
= (pHeadFootLine
->Frame
& 0x0F00) / 0x0100;
799 sal_uInt16 fBottom
= (pHeadFootLine
->Frame
& 0xF000) / 0x1000;
814 else if (fBottom
> 0)
816 Color
ColorLeft(COL_BLACK
);
817 Color
ColorTop(COL_BLACK
);
818 Color
ColorRight(COL_BLACK
);
819 Color
ColorBottom(COL_BLACK
);
820 sal_uInt16 cLeft
= (pHeadFootLine
->FrameColor
& 0x000F);
821 sal_uInt16 cTop
= (pHeadFootLine
->FrameColor
& 0x00F0) >> 4;
822 sal_uInt16 cRight
= (pHeadFootLine
->FrameColor
& 0x0F00) >> 8;
823 sal_uInt16 cBottom
= (pHeadFootLine
->FrameColor
& 0xF000) >> 12;
824 lcl_ChangeColor(cLeft
, ColorLeft
);
825 lcl_ChangeColor(cTop
, ColorTop
);
826 lcl_ChangeColor(cRight
, ColorRight
);
827 lcl_ChangeColor(cBottom
, ColorBottom
);
828 ::editeng::SvxBorderLine aLine
;
829 SvxBoxItem
aBox( ATTR_BORDER
);
830 aLine
.SetWidth(nLeft
);
831 aLine
.SetColor(ColorLeft
);
832 aBox
.SetLine(&aLine
, SvxBoxItemLine::LEFT
);
833 aLine
.SetWidth(nTop
);
834 aLine
.SetColor(ColorTop
);
835 aBox
.SetLine(&aLine
, SvxBoxItemLine::TOP
);
836 aLine
.SetWidth(nRight
);
837 aLine
.SetColor(ColorRight
);
838 aBox
.SetLine(&aLine
, SvxBoxItemLine::RIGHT
);
839 aLine
.SetWidth(nBottom
);
840 aLine
.SetColor(ColorBottom
);
841 aBox
.SetLine(&aLine
, SvxBoxItemLine::BOTTOM
);
843 aSetItemItemSet
.Put(aBox
);
846 pSet
->Put( SvxULSpaceItem( 0, 0, ATTR_ULSPACE
) );
849 aSetItemItemSet
.Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( 0, pPage
->Top
- pPage
->Head
) ) );
851 aSetItemItemSet
.Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( 0, pPage
->Bottom
- pPage
->Foot
) ) );
853 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_ON
, true ));
854 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_DYNAMIC
, false ));
855 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_SHARED
, true ));
857 pSet
->Put( SvxSetItem( nHeadFoot
? ATTR_PAGE_FOOTERSET
: ATTR_PAGE_HEADERSET
,
861 SvxPageItem
aPageItem(ATTR_PAGE
);
862 aPageItem
.SetPageUsage( SVX_PAGE_ALL
);
863 aPageItem
.SetLandscape( pPage
->Orientation
!= 1 );
864 aPageItem
.SetNumType( SVX_ARABIC
);
865 pSet
->Put(aPageItem
);
867 pSet
->Put(SvxLRSpaceItem( pPage
->Left
, pPage
->Right
, 0,0, ATTR_LRSPACE
));
868 pSet
->Put(SvxULSpaceItem( pPage
->Top
, pPage
->Bottom
, ATTR_ULSPACE
));
870 pSet
->Put(SfxBoolItem( ATTR_PAGE_HORCENTER
, pPage
->HorCenter
));
871 pSet
->Put(SfxBoolItem( ATTR_PAGE_VERCENTER
, pPage
->VerCenter
));
876 ScRange
* pRepeatRow
= nullptr;
877 ScRange
* pRepeatCol
= nullptr;
879 if ( pPage
->ColRepeatStart
>= 0 )
880 pRepeatCol
= new ScRange( static_cast<SCCOL
> (pPage
->ColRepeatStart
), 0, 0 );
881 if ( pPage
->RowRepeatStart
>= 0 )
882 pRepeatRow
= new ScRange( 0, static_cast<SCROW
> (pPage
->RowRepeatStart
), 0 );
884 if ( pRepeatRow
|| pRepeatCol
)
887 // set for all tables
889 for ( SCTAB nTab
= 0, nTabCount
= pDoc
->GetTableCount(); nTab
< nTabCount
; ++nTab
)
891 pDoc
->SetRepeatColRange( nTab
, pRepeatCol
);
892 pDoc
->SetRepeatRowRange( nTab
, pRepeatRow
);
902 pSet
->Put( SfxBoolItem( ATTR_PAGE_NOTES
, pPage
->PrintNote
) );
903 pSet
->Put( SfxBoolItem( ATTR_PAGE_GRID
, pPage
->PrintGrid
) );
904 pSet
->Put( SfxBoolItem( ATTR_PAGE_HEADERS
, pPage
->PrintColRow
) );
905 pSet
->Put( SfxBoolItem( ATTR_PAGE_TOPDOWN
, pPage
->TopBottomDir
) );
906 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_CHARTS
, VOBJ_MODE_SHOW
) );
907 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_OBJECTS
, VOBJ_MODE_SHOW
) );
908 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_DRAWINGS
, VOBJ_MODE_SHOW
) );
909 pSet
->Put( SfxUInt16Item( ATTR_PAGE_SCALE
,
910 (sal_uInt16
)( lcl_PascalToDouble( pPage
->PrnZoom
) * 100 ) ) );
911 pSet
->Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO
, 1 ) );
913 pSet
->Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( pPage
->Width
, pPage
->Height
) ) );
919 ScDataObject
* Sc10PageData::Clone() const
921 return new Sc10PageData(aPageFormat
);
926 Sc10Import::Sc10Import(SvStream
& rStr
, ScDocument
* pDocument
) :
929 pFontCollection (nullptr),
930 pNameCollection (nullptr),
931 pPatternCollection (nullptr),
932 pDataBaseCollection (nullptr),
939 Sc10Import::~Sc10Import()
941 pDoc
->CalcAfterLoad();
942 pDoc
->UpdateAllCharts();
944 delete pFontCollection
;
945 delete pNameCollection
;
946 delete pPatternCollection
;
947 delete pDataBaseCollection
;
949 OSL_ENSURE( pPrgrsBar
== nullptr,
950 "*Sc10Import::Sc10Import(): Progressbar lebt noch!?" );
953 sal_uLong
Sc10Import::Import()
955 pPrgrsBar
= new ScfStreamProgressBar( rStream
, pDoc
->GetDocumentShell() );
957 ScDocOptions aOpt
= pDoc
->GetDocOptions();
958 aOpt
.SetDate( 1, 1, 1900 );
959 aOpt
.SetYear2000( 18 + 1901 ); // 4-digit since SO51 src513e
960 pDoc
->SetDocOptions( aOpt
);
961 pDoc
->GetFormatTable()->ChangeNullDate( 1, 1, 1900 );
963 LoadFileHeader(); pPrgrsBar
->Progress();
964 if (!nError
) { LoadFileInfo(); pPrgrsBar
->Progress(); }
965 if (!nError
) { LoadEditStateInfo(); pPrgrsBar
->Progress(); }
966 if (!nError
) { LoadProtect(); pPrgrsBar
->Progress(); }
967 if (!nError
) { LoadViewColRowBar(); pPrgrsBar
->Progress(); }
968 if (!nError
) { LoadScrZoom(); pPrgrsBar
->Progress(); }
969 if (!nError
) { LoadPalette(); pPrgrsBar
->Progress(); }
970 if (!nError
) { LoadFontCollection(); pPrgrsBar
->Progress(); }
971 if (!nError
) { LoadNameCollection(); pPrgrsBar
->Progress(); }
972 if (!nError
) { LoadPatternCollection(); pPrgrsBar
->Progress(); }
973 if (!nError
) { LoadDataBaseCollection(); pPrgrsBar
->Progress(); }
974 if (!nError
) { LoadTables(); pPrgrsBar
->Progress(); }
975 if (!nError
) { LoadObjects(); pPrgrsBar
->Progress(); }
976 if (!nError
) { ImportNameCollection(); pPrgrsBar
->Progress(); }
977 pDoc
->SetViewOptions( aSc30ViewOpt
);
979 #if OSL_DEBUG_LEVEL > 0
982 OSL_FAIL( OString::number(nError
).getStr());
987 #if OSL_DEBUG_LEVEL > 0
994 void Sc10Import::LoadFileHeader()
996 Sc10FileHeader FileHeader
;
997 lcl_ReadFileHeader(rStream
, FileHeader
);
999 nError
= rStream
.GetError();
1002 sal_Char Sc10CopyRight
[32];
1003 strcpy(Sc10CopyRight
, "Blaise-Tabelle");
1004 Sc10CopyRight
[14] = 10;
1005 Sc10CopyRight
[15] = 13;
1006 Sc10CopyRight
[16] = 0;
1007 if ((strcmp(FileHeader
.CopyRight
, Sc10CopyRight
) != 0)
1008 || (FileHeader
.Version
< 101)
1009 || (FileHeader
.Version
> 102))
1010 nError
= errUnknownFormat
;
1014 void Sc10Import::LoadFileInfo()
1016 Sc10FileInfo FileInfo
;
1017 rStream
.Read(&FileInfo
, sizeof(FileInfo
));
1019 nError
= rStream
.GetError();
1020 // TODO: ? copy info
1023 void Sc10Import::LoadEditStateInfo()
1025 Sc10EditStateInfo EditStateInfo
;
1027 #if !defined(NDEBUG)
1028 sal_uInt64
const nOldPos(rStream
.Tell());
1031 rStream
.ReadUInt16(EditStateInfo
.CarretX
);
1032 rStream
.ReadUInt16(EditStateInfo
.CarretY
);
1033 rStream
.ReadUInt16(EditStateInfo
.CarretZ
);
1034 rStream
.ReadUInt16(EditStateInfo
.DeltaX
);
1035 rStream
.ReadUInt16(EditStateInfo
.DeltaY
);
1036 rStream
.ReadUInt16(EditStateInfo
.DeltaZ
);
1037 rStream
.ReadUChar(EditStateInfo
.DataBaseMode
);
1038 rStream
.Read(EditStateInfo
.Reserved
, sizeof(EditStateInfo
.Reserved
));
1040 assert(rStream
.GetError() || rStream
.Tell() == nOldPos
+ sizeof(Sc10EditStateInfo
));
1042 nError
= rStream
.GetError();
1043 nShowTab
= static_cast<SCTAB
>(EditStateInfo
.DeltaZ
);
1044 // TODO: ? copy cursor position and offset of the table (shall we do that??)
1048 void Sc10Import::LoadProtect()
1050 lcl_ReadSheetProtect(rStream
, SheetProtect
);
1051 nError
= rStream
.GetError();
1053 ScDocProtection aProtection
;
1054 aProtection
.setProtected(static_cast<bool>(SheetProtect
.Protect
));
1055 aProtection
.setPassword(SC10TOSTRING(SheetProtect
.PassWord
));
1056 pDoc
->SetDocProtection(&aProtection
);
1059 void Sc10Import::LoadViewColRowBar()
1061 bool bViewColRowBar
;
1062 rStream
.ReadCharAsBool( bViewColRowBar
);
1063 nError
= rStream
.GetError();
1064 aSc30ViewOpt
.SetOption( VOPT_HEADER
, bViewColRowBar
);
1067 void Sc10Import::LoadScrZoom()
1069 // TODO: unfortunately Zoom is a 6-byte TP real number (don't know how to translate that)
1071 rStream
.Read(cZoom
, sizeof(cZoom
));
1072 nError
= rStream
.GetError();
1075 void Sc10Import::LoadPalette()
1077 lcl_ReadPalette(rStream
, TextPalette
);
1078 lcl_ReadPalette(rStream
, BackPalette
);
1079 lcl_ReadPalette(rStream
, RasterPalette
);
1080 lcl_ReadPalette(rStream
, FramePalette
);
1082 nError
= rStream
.GetError();
1085 void Sc10Import::LoadFontCollection()
1087 pFontCollection
= new Sc10FontCollection(rStream
);
1089 nError
= pFontCollection
->GetError();
1092 void Sc10Import::LoadNameCollection()
1094 pNameCollection
= new Sc10NameCollection(rStream
);
1096 nError
= pNameCollection
->GetError();
1099 void Sc10Import::ImportNameCollection()
1101 ScRangeName
* pRN
= pDoc
->GetRangeName();
1103 for (sal_uInt16 i
= 0; i
< pNameCollection
->GetCount(); i
++)
1105 Sc10NameData
* pName
= pNameCollection
->At( i
);
1108 pDoc
, SC10TOSTRING(pName
->Name
), SC10TOSTRING(pName
->Reference
)));
1112 void Sc10Import::LoadPatternCollection()
1114 pPatternCollection
= new Sc10PatternCollection( rStream
);
1116 nError
= pPatternCollection
->GetError();
1117 if (nError
== errOutOfMemory
)
1119 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
1120 for( sal_uInt16 i
= 0 ; i
< pPatternCollection
->GetCount() ; i
++ )
1122 Sc10PatternData
* pPattern
= pPatternCollection
->At( i
);
1123 OUString
aName( pPattern
->Name
, strlen(pPattern
->Name
), DEFCHARSET
);
1124 SfxStyleSheetBase
* pStyle
= pStylePool
->Find( aName
, SfxStyleFamily::Para
);
1125 if( pStyle
== nullptr )
1126 pStylePool
->Make( aName
, SfxStyleFamily::Para
);
1129 pPattern
->Name
[ 27 ] = 0;
1130 strcat( pPattern
->Name
, "_Old" );
1131 aName
= SC10TOSTRING( pPattern
->Name
);
1132 pStylePool
->Make( aName
, SfxStyleFamily::Para
);
1134 pStyle
= pStylePool
->Find( aName
, SfxStyleFamily::Para
);
1135 if( pStyle
!= nullptr )
1137 SfxItemSet
&rItemSet
= pStyle
->GetItemSet();
1139 if( ( pPattern
->FormatFlags
& pfFont
) == pfFont
)
1141 FontFamily eFam
= FAMILY_DONTKNOW
;
1142 switch( pPattern
->LogFont
.lfPitchAndFamily
& 0xF0 )
1144 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
1145 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
1146 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
1147 case ffModern
: eFam
= FAMILY_MODERN
; break;
1148 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
1149 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
1150 default: eFam
= FAMILY_DONTKNOW
; break;
1152 rItemSet
.Put( SvxFontItem( eFam
, SC10TOSTRING( pPattern
->LogFont
.lfFaceName
), EMPTY_OUSTRING
,
1153 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
) );
1154 rItemSet
.Put( SvxFontHeightItem( std::abs( pPattern
->LogFont
.lfHeight
), 100, ATTR_FONT_HEIGHT
) );
1155 Color
TextColor( COL_BLACK
);
1156 lcl_ChangeColor( ( pPattern
->nColor
& 0x000F ), TextColor
);
1157 rItemSet
.Put( SvxColorItem( TextColor
, ATTR_FONT_COLOR
) );
1159 if( pPattern
->LogFont
.lfWeight
!= fwNormal
)
1160 rItemSet
.Put( SvxWeightItem( WEIGHT_BOLD
, ATTR_FONT_WEIGHT
) );
1161 if( pPattern
->LogFont
.lfItalic
!= 0 )
1162 rItemSet
.Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
1163 if( pPattern
->LogFont
.lfUnderline
!= 0 )
1164 rItemSet
.Put( SvxUnderlineItem( LINESTYLE_SINGLE
, ATTR_FONT_UNDERLINE
) );
1165 if( pPattern
->LogFont
.lfStrikeOut
!= 0 )
1166 rItemSet
.Put( SvxCrossedOutItem( STRIKEOUT_SINGLE
, ATTR_FONT_CROSSEDOUT
) );
1169 if( ( pPattern
->FormatFlags
& pfJustify
) == pfJustify
)
1171 sal_uInt16 HorJustify
= ( pPattern
->Justify
& 0x000F );
1172 sal_uInt16 VerJustify
= ( pPattern
->Justify
& 0x00F0 ) >> 4;
1173 sal_uInt16 OJustify
= ( pPattern
->Justify
& 0x0F00 ) >> 8;
1174 sal_uInt16 EJustify
= ( pPattern
->Justify
& 0xF000 ) >> 12;
1175 if( HorJustify
!= 0 )
1176 switch( HorJustify
)
1179 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT
, ATTR_HOR_JUSTIFY
) );
1182 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
) );
1185 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT
, ATTR_HOR_JUSTIFY
) );
1188 if( VerJustify
!= 0 )
1189 switch( VerJustify
)
1192 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_TOP
, ATTR_VER_JUSTIFY
) );
1195 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER
, ATTR_VER_JUSTIFY
) );
1198 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_BOTTOM
, ATTR_VER_JUSTIFY
) );
1202 if( ( OJustify
& ojWordBreak
) == ojWordBreak
)
1203 rItemSet
.Put( SfxBoolItem( ATTR_LINEBREAK
, true ) );
1204 if( ( OJustify
& ojBottomTop
) == ojBottomTop
)
1205 rItemSet
.Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 9000 ) );
1206 else if( ( OJustify
& ojTopBottom
) == ojTopBottom
)
1207 rItemSet
.Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 27000 ) );
1209 sal_Int16 Margin
= std::max( ( sal_uInt16
) 20, ( sal_uInt16
) ( EJustify
* 20 ) );
1210 if( ( ( OJustify
& ojBottomTop
) == ojBottomTop
) )
1211 rItemSet
.Put( SvxMarginItem( 20, Margin
, 20, Margin
, ATTR_MARGIN
) );
1213 rItemSet
.Put( SvxMarginItem( Margin
, 20, Margin
, 20, ATTR_MARGIN
) );
1217 if( ( pPattern
->FormatFlags
& pfFrame
) == pfFrame
)
1219 if( pPattern
->Frame
!= 0 )
1221 sal_uInt16 nLeft
= 0;
1222 sal_uInt16 nTop
= 0;
1223 sal_uInt16 nRight
= 0;
1224 sal_uInt16 nBottom
= 0;
1225 sal_uInt16 fLeft
= ( pPattern
->Frame
& 0x000F );
1226 sal_uInt16 fTop
= ( pPattern
->Frame
& 0x00F0 ) / 0x0010;
1227 sal_uInt16 fRight
= ( pPattern
->Frame
& 0x0F00 ) / 0x0100;
1228 sal_uInt16 fBottom
= ( pPattern
->Frame
& 0xF000 ) / 0x1000;
1232 else if( fLeft
> 0 )
1242 else if( fRight
> 0 )
1247 else if( fBottom
> 0 )
1250 Color
ColorLeft( COL_BLACK
);
1251 Color
ColorTop( COL_BLACK
);
1252 Color
ColorRight( COL_BLACK
);
1253 Color
ColorBottom( COL_BLACK
);
1255 sal_uInt16 cLeft
= ( pPattern
->FrameColor
& 0x000F );
1256 sal_uInt16 cTop
= ( pPattern
->FrameColor
& 0x00F0 ) >> 4;
1257 sal_uInt16 cRight
= ( pPattern
->FrameColor
& 0x0F00 ) >> 8;
1258 sal_uInt16 cBottom
= ( pPattern
->FrameColor
& 0xF000 ) >> 12;
1260 lcl_ChangeColor( cLeft
, ColorLeft
);
1261 lcl_ChangeColor( cTop
, ColorTop
);
1262 lcl_ChangeColor( cRight
, ColorRight
);
1263 lcl_ChangeColor( cBottom
, ColorBottom
);
1265 ::editeng::SvxBorderLine aLine
;
1266 SvxBoxItem
aBox( ATTR_BORDER
);
1268 aLine
.SetWidth( nLeft
);
1269 aLine
.SetColor( ColorLeft
);
1270 aBox
.SetLine( &aLine
, SvxBoxItemLine::LEFT
);
1271 aLine
.SetWidth( nTop
);
1272 aLine
.SetColor( ColorTop
);
1273 aBox
.SetLine( &aLine
, SvxBoxItemLine::TOP
);
1274 aLine
.SetWidth( nRight
);
1275 aLine
.SetColor( ColorRight
);
1276 aBox
.SetLine( &aLine
, SvxBoxItemLine::RIGHT
);
1277 aLine
.SetWidth( nBottom
);
1278 aLine
.SetColor( ColorBottom
);
1279 aBox
.SetLine( &aLine
, SvxBoxItemLine::BOTTOM
);
1280 rItemSet
.Put( aBox
);
1284 if( ( pPattern
->FormatFlags
& pfRaster
) == pfRaster
)
1286 if( pPattern
->Raster
!= 0 )
1288 sal_uInt16 nBColor
= ( pPattern
->nColor
& 0x00F0 ) >> 4;
1289 sal_uInt16 nRColor
= ( pPattern
->nColor
& 0x0F00 ) >> 8;
1290 Color
aBColor( COL_BLACK
);
1292 lcl_ChangeColor( nBColor
, aBColor
);
1295 aBColor
.SetColor( COL_WHITE
);
1296 else if( nBColor
== 15 )
1297 aBColor
.SetColor( COL_BLACK
);
1299 Color
aRColor( COL_BLACK
);
1300 lcl_ChangeColor( nRColor
, aRColor
);
1302 bool bSwapCol
= false;
1303 bool bSetItem
= true;
1304 switch (pPattern
->Raster
)
1306 case raNone
: nFact
= 0xffff; bSwapCol
= true; bSetItem
= (nBColor
> 0); break;
1307 case raGray12
: nFact
= (0xffff / 100) * 12; break;
1308 case raGray25
: nFact
= (0xffff / 100) * 25; break;
1309 case raGray50
: nFact
= (0xffff / 100) * 50; break;
1310 case raGray75
: nFact
= (0xffff / 100) * 75; break;
1311 default: nFact
= 0xffff; bSetItem
= (nRColor
< 15);
1316 rItemSet
.Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
1318 rItemSet
.Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
1323 if( ( pPattern
->ValueFormat
.Format
!= 0 ) &&
1324 ( ( pPattern
->FormatFlags
& pfValue
) == pfValue
) )
1327 ChangeFormat( pPattern
->ValueFormat
.Format
, pPattern
->ValueFormat
.Info
, nKey
);
1328 rItemSet
.Put( SfxUInt32Item( ATTR_VALUE_FORMAT
, ( sal_uInt32
) nKey
) );
1331 // cell attributes (protected, hidden...)
1332 if( ( pPattern
->Flags
!= 0 ) &&
1333 ( ( pPattern
->FormatFlags
& pfProtection
) == pfProtection
) )
1335 bool bProtect
= ( ( pPattern
->Flags
& paProtect
) == paProtect
);
1336 bool bHFormula
= ( ( pPattern
->Flags
& paHideFormula
) == paHideFormula
);
1337 bool bHCell
= ( ( pPattern
->Flags
& paHideAll
) == paHideAll
);
1338 bool bHPrint
= ( ( pPattern
->Flags
& paHidePrint
) == paHidePrint
);
1339 rItemSet
.Put( ScProtectionAttr( bProtect
, bHFormula
, bHCell
, bHPrint
) );
1342 } // for (i = 0; i < GetCount()
1345 void Sc10Import::LoadDataBaseCollection()
1347 pDataBaseCollection
= new Sc10DataBaseCollection(rStream
);
1349 nError
= pDataBaseCollection
->GetError();
1350 if (nError
== errOutOfMemory
)
1352 for( sal_uInt16 i
= 0 ; i
< pDataBaseCollection
->GetCount() ; i
++ )
1354 Sc10DataBaseData
* pOldData
= pDataBaseCollection
->At(i
);
1355 ScDBData
* pNewData
= new ScDBData( SC10TOSTRING( pOldData
->DataBaseRec
.Name
),
1356 ( SCTAB
) pOldData
->DataBaseRec
.Tab
,
1357 ( SCCOL
) pOldData
->DataBaseRec
.Block
.x1
,
1358 ( SCROW
) pOldData
->DataBaseRec
.Block
.y1
,
1359 ( SCCOL
) pOldData
->DataBaseRec
.Block
.x2
,
1360 ( SCROW
) pOldData
->DataBaseRec
.Block
.y2
,
1362 (bool) pOldData
->DataBaseRec
.RowHeader
);
1363 bool ins
= pDoc
->GetDBCollection()->getNamedDBs().insert(pNewData
);
1364 assert(ins
); (void)ins
;
1365 //TODO: or can this fail (and need delete pNewData)?
1371 sal_uInt16
ReadAndSanitizeDataCount(SvStream
&rStream
)
1373 sal_uInt16
nDataCount(0);
1374 rStream
.ReadUInt16(nDataCount
);
1375 const size_t nMinRecordSize
= sizeof(sal_uInt16
)*2;
1376 const size_t nMaxRecords
= rStream
.remainingSize() / nMinRecordSize
;
1377 if (nDataCount
> nMaxRecords
)
1379 SAL_WARN("sc", "Parsing error: " << nMaxRecords
<<
1380 " max possible entries, but " << nDataCount
<< " claimed, truncating");
1381 nDataCount
= nMaxRecords
;
1387 void Sc10Import::LoadTables()
1389 Sc10PageCollection aPageCollection
;
1391 sal_Int16 nTabCount
;
1392 rStream
.ReadInt16( nTabCount
);
1393 for (sal_Int16 Tab
= 0; (Tab
< nTabCount
) && (nError
== 0); Tab
++)
1395 Sc10PageFormat PageFormat
;
1396 sal_Int16 DataBaseIndex
;
1397 Sc10TableProtect TabProtect
;
1399 sal_Char TabName
[128];
1403 sal_uInt16 DataCount
;
1404 sal_uInt16 DataStart
;
1406 sal_uInt16 DataValue
;
1410 lcl_ReadPageFormat(rStream
, PageFormat
);
1412 sal_uInt16 nAt
= aPageCollection
.InsertFormat(PageFormat
);
1413 OUString aPageName
= lcl_MakeOldPageStyleFormatName( nAt
);
1415 pPrgrsBar
->Progress();
1417 rStream
.ReadInt16( DataBaseIndex
);
1419 lcl_ReadTabProtect(rStream
, TabProtect
);
1421 ScTableProtection aProtection
;
1422 aProtection
.setProtected(static_cast<bool>(TabProtect
.Protect
));
1423 aProtection
.setPassword(SC10TOSTRING(TabProtect
.PassWord
));
1424 pDoc
->SetTabProtection(static_cast<SCTAB
>(Tab
), &aProtection
);
1426 rStream
.ReadInt16( TabNo
);
1429 rStream
.ReadUChar( nLen
);
1430 rStream
.Read(TabName
, sizeof(TabName
) - 1);
1431 if (nLen
>= sizeof(TabName
))
1432 nLen
= sizeof(TabName
) - 1;
1435 rStream
.ReadUInt16( Display
);
1437 if ( Tab
== (sal_Int16
)nShowTab
)
1439 ScVObjMode eObjMode
= VOBJ_MODE_SHOW
;
1441 aSc30ViewOpt
.SetOption( VOPT_FORMULAS
, IS_SET(dfFormula
,Display
) );
1442 aSc30ViewOpt
.SetOption( VOPT_NULLVALS
, IS_SET(dfZerro
,Display
) );
1443 aSc30ViewOpt
.SetOption( VOPT_SYNTAX
, IS_SET(dfSyntax
,Display
) );
1444 aSc30ViewOpt
.SetOption( VOPT_NOTES
, IS_SET(dfNoteMark
,Display
) );
1445 aSc30ViewOpt
.SetOption( VOPT_VSCROLL
);
1446 aSc30ViewOpt
.SetOption( VOPT_HSCROLL
);
1447 aSc30ViewOpt
.SetOption( VOPT_TABCONTROLS
);
1448 aSc30ViewOpt
.SetOption( VOPT_OUTLINER
);
1449 aSc30ViewOpt
.SetOption( VOPT_GRID
, IS_SET(dfGrid
,Display
) );
1451 // VOPT_HEADER is set in LoadViewColRowBar()
1453 if ( IS_SET(dfObjectAll
,Display
) ) // show objects
1454 eObjMode
= VOBJ_MODE_SHOW
;
1455 else if ( IS_SET(dfObjectFrame
,Display
) ) // object as placeholder
1456 eObjMode
= VOBJ_MODE_SHOW
;
1457 else if ( IS_SET(dfObjectNone
,Display
) ) // don't show objects
1458 eObjMode
= VOBJ_MODE_HIDE
;
1460 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_OLE
, eObjMode
);
1461 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_CHART
, eObjMode
);
1462 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_DRAW
, eObjMode
);
1465 rStream
.ReadUChar( Visible
);
1467 nError
= rStream
.GetError();
1468 if (nError
!= 0) return;
1471 pDoc
->RenameTab(static_cast<SCTAB
> (TabNo
), SC10TOSTRING( TabName
), false);
1473 pDoc
->InsertTab(SC_TAB_APPEND
, SC10TOSTRING( TabName
) );
1475 pDoc
->SetPageStyle( static_cast<SCTAB
>(Tab
), aPageName
);
1477 if (Visible
== 0) pDoc
->SetVisible(static_cast<SCTAB
> (TabNo
), false);
1480 rStream
.ReadUInt16( ID
);
1481 if (ID
!= ColWidthID
)
1483 OSL_FAIL( "ColWidthID" );
1484 nError
= errUnknownID
;
1487 DataCount
= ReadAndSanitizeDataCount(rStream
);
1489 for (i
=0; i
< DataCount
; i
++)
1491 rStream
.ReadUInt16( DataEnd
);
1492 DataEnd
= SanitizeCol(DataEnd
);
1493 rStream
.ReadUInt16( DataValue
);
1494 for (SCCOL j
= static_cast<SCCOL
>(DataStart
); j
<= static_cast<SCCOL
>(DataEnd
); j
++)
1495 pDoc
->SetColWidth(j
, static_cast<SCTAB
> (TabNo
), DataValue
);
1496 DataStart
= DataEnd
+ 1;
1498 pPrgrsBar
->Progress();
1501 rStream
.ReadUInt16( ID
);
1502 if (ID
!= ColAttrID
)
1504 OSL_FAIL( "ColAttrID" );
1505 nError
= errUnknownID
;
1509 DataCount
= ReadAndSanitizeDataCount(rStream
);
1511 for (i
=0; i
< DataCount
; i
++)
1513 rStream
.ReadUInt16( DataEnd
);
1514 rStream
.ReadUInt16( DataValue
);
1517 bool bPageBreak
= ((DataValue
& crfSoftBreak
) == crfSoftBreak
);
1518 bool bManualBreak
= ((DataValue
& crfHardBreak
) == crfHardBreak
);
1519 bool bHidden
= ((DataValue
& crfHidden
) == crfHidden
);
1520 for (SCCOL k
= SanitizeCol(static_cast<SCCOL
>(DataStart
)); k
<= SanitizeCol(static_cast<SCCOL
>(DataEnd
)); k
++)
1522 pDoc
->SetColHidden(k
, k
, static_cast<SCTAB
>(TabNo
), bHidden
);
1523 pDoc
->SetColBreak(k
, static_cast<SCTAB
> (TabNo
), bPageBreak
, bManualBreak
);
1526 DataStart
= DataEnd
+ 1;
1528 pPrgrsBar
->Progress();
1531 rStream
.ReadUInt16( ID
);
1532 if (ID
!= RowHeightID
)
1534 OSL_FAIL( "RowHeightID" );
1535 nError
= errUnknownID
;
1539 DataCount
= ReadAndSanitizeDataCount(rStream
);
1541 for (i
=0; i
< DataCount
; i
++)
1543 rStream
.ReadUInt16( DataEnd
);
1544 rStream
.ReadUInt16( DataValue
);
1545 pDoc
->SetRowHeightRange(static_cast<SCROW
> (DataStart
), static_cast<SCROW
> (DataEnd
), static_cast<SCTAB
> (TabNo
), DataValue
);
1546 DataStart
= DataEnd
+ 1;
1548 pPrgrsBar
->Progress();
1551 rStream
.ReadUInt16( ID
);
1552 if (ID
!= RowAttrID
)
1554 OSL_FAIL( "RowAttrID" );
1555 nError
= errUnknownID
;
1559 DataCount
= ReadAndSanitizeDataCount(rStream
);
1561 for (i
=0; i
< DataCount
; i
++)
1563 rStream
.ReadUInt16( DataEnd
);
1564 rStream
.ReadUInt16( DataValue
);
1567 bool bPageBreak
= ((DataValue
& crfSoftBreak
) == crfSoftBreak
);
1568 bool bManualBreak
= ((DataValue
& crfHardBreak
) == crfHardBreak
);
1569 bool bHidden
= ((DataValue
& crfHidden
) == crfHidden
);
1570 for (SCROW l
= SanitizeRow(static_cast<SCROW
>(DataStart
)); l
<= SanitizeRow(static_cast<SCROW
>(DataEnd
)); ++l
)
1572 pDoc
->SetRowHidden(l
, l
, static_cast<SCTAB
> (TabNo
), bHidden
);
1573 pDoc
->SetRowBreak(l
, static_cast<SCTAB
> (TabNo
), bPageBreak
, bManualBreak
);
1576 DataStart
= DataEnd
+ 1;
1578 pPrgrsBar
->Progress();
1581 rStream
.ReadUInt16( ID
);
1584 OSL_FAIL( "TableID" );
1585 nError
= errUnknownID
;
1588 for (SCCOL Col
= 0; (Col
<= SC10MAXCOL
) && (nError
== 0); Col
++)
1590 rStream
.ReadUInt16( Count
);
1591 nError
= rStream
.GetError();
1592 if ((Count
!= 0) && (nError
== 0))
1593 LoadCol(Col
, static_cast<SCTAB
> (TabNo
));
1595 OSL_ENSURE( nError
== 0, "Stream" );
1597 pPrgrsBar
->Progress();
1599 aPageCollection
.PutToDoc( pDoc
);
1602 void Sc10Import::LoadCol(SCCOL Col
, SCTAB Tab
)
1604 LoadColAttr(Col
, Tab
);
1606 sal_uInt16 CellCount
;
1609 rStream
.ReadUInt16( CellCount
);
1610 SCROW nScCount
= static_cast< SCROW
>( CellCount
);
1611 if (nScCount
> MAXROW
) nError
= errUnknownFormat
;
1612 for (sal_uInt16 i
= 0; (i
< CellCount
) && (nError
== 0); i
++)
1614 rStream
.ReadUChar( CellType
);
1615 rStream
.ReadUInt16( Row
);
1616 nError
= rStream
.GetError();
1623 const SfxPoolItem
* pValueFormat
= pDoc
->GetAttr(Col
, static_cast<SCROW
> (Row
), Tab
, ATTR_VALUE_FORMAT
);
1624 sal_uLong nFormat
= static_cast<const SfxUInt32Item
*>(pValueFormat
)->GetValue();
1625 double Value
= ScfTools::ReadLongDouble(rStream
);
1626 //rStream.Read(&Value, sizeof(Value));
1628 // TODO: adjustment is needed if we change the Basis Date
1629 // StarCalc 1.0: 01.01.1900
1630 // if ((nFormat >= 30) && (nFormat <= 35))
1632 if ((nFormat
>= 40) && (nFormat
<= 45))
1634 pDoc
->SetValue(Col
, static_cast<SCROW
> (Row
), Tab
, Value
);
1641 rStream
.ReadUChar( Len
);
1642 rStream
.Read(s
, Len
);
1645 pDoc
->SetString( Col
, static_cast<SCROW
> (Row
), Tab
, SC10TOSTRING( s
) );
1650 /*double Value =*/ ScfTools::ReadLongDouble(rStream
);
1653 rStream
.ReadUChar( Len
);
1654 rStream
.Read(&s
[1], Len
);
1657 ScFormulaCell
* pCell
= new ScFormulaCell( pDoc
, ScAddress( Col
, static_cast<SCROW
> (Row
), Tab
) );
1658 pCell
->SetHybridFormula( SC10TOSTRING( s
),formula::FormulaGrammar::GRAM_NATIVE
);
1659 pDoc
->EnsureTable(Tab
);
1660 pDoc
->SetFormulaCell(ScAddress(Col
,Row
,Tab
), pCell
);
1666 nError
= errUnknownFormat
;
1669 sal_uInt16
nNoteLen(0);
1670 rStream
.ReadUInt16(nNoteLen
);
1671 size_t nAvailable
= rStream
.remainingSize();
1672 if (nNoteLen
> nAvailable
)
1673 nNoteLen
= nAvailable
;
1676 std::unique_ptr
<sal_Char
[]> xNote(new sal_Char
[nNoteLen
+1]);
1677 nNoteLen
= rStream
.Read(xNote
.get(), nNoteLen
);
1678 xNote
[nNoteLen
] = 0;
1679 OUString
aNoteText( SC10TOSTRING(xNote
.get()));
1681 ScAddress
aPos( Col
, static_cast<SCROW
>(Row
), Tab
);
1682 ScNoteUtil::CreateNoteFromString( *pDoc
, aPos
, aNoteText
, false, false );
1685 pPrgrsBar
->Progress();
1689 void Sc10Import::LoadColAttr(SCCOL Col
, SCTAB Tab
)
1693 Sc10ColAttr aJustify
;
1695 Sc10ColAttr aRaster
;
1698 Sc10ColAttr aFrameColor
;
1700 Sc10ColAttr aPattern
;
1702 if (nError
== 0) LoadAttr(aFont
);
1703 if (nError
== 0) LoadAttr(aAttr
);
1704 if (nError
== 0) LoadAttr(aJustify
);
1705 if (nError
== 0) LoadAttr(aFrame
);
1706 if (nError
== 0) LoadAttr(aRaster
);
1707 if (nError
== 0) LoadAttr(aValue
);
1708 if (nError
== 0) LoadAttr(aColor
);
1709 if (nError
== 0) LoadAttr(aFrameColor
);
1710 if (nError
== 0) LoadAttr(aFlag
);
1711 if (nError
== 0) LoadAttr(aPattern
);
1720 Sc10ColData
*pColData
;
1722 // Font (Name, Size)
1724 nLimit
= aFont
.Count
;
1725 pColData
= aFont
.pData
;
1726 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1728 SCROW nEnd
= static_cast<SCROW
>(pColData
->Row
);
1729 if ((nStart
<= nEnd
) && (pColData
->Value
))
1731 FontFamily eFam
= FAMILY_DONTKNOW
;
1732 Sc10FontData
* pFont
= pFontCollection
->At(pColData
->Value
);
1735 switch (pFont
->PitchAndFamily
& 0xF0)
1737 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
1738 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
1739 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
1740 case ffModern
: eFam
= FAMILY_MODERN
; break;
1741 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
1742 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
1743 default: eFam
= FAMILY_DONTKNOW
; break;
1745 ScPatternAttr
aScPattern(pDoc
->GetPool());
1746 aScPattern
.GetItemSet().Put(SvxFontItem(eFam
, SC10TOSTRING( pFont
->FaceName
), EMPTY_OUSTRING
,
1747 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
));
1748 aScPattern
.GetItemSet().Put(SvxFontHeightItem(std::abs(pFont
->Height
), 100, ATTR_FONT_HEIGHT
));
1749 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1757 nLimit
= aColor
.Count
;
1758 pColData
= aColor
.pData
;
1759 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1761 SCROW nEnd
= static_cast<SCROW
>(pColData
->Row
);
1762 if ((nStart
<= nEnd
) && (pColData
->Value
))
1764 Color
TextColor(COL_BLACK
);
1765 lcl_ChangeColor((pColData
->Value
& 0x000F), TextColor
);
1766 ScPatternAttr
aScPattern(pDoc
->GetPool());
1767 aScPattern
.GetItemSet().Put(SvxColorItem(TextColor
, ATTR_FONT_COLOR
));
1768 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1773 // Font attributes (Bold, Italic...)
1775 nLimit
= aAttr
.Count
;
1776 pColData
= aAttr
.pData
;
1777 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1779 SCROW nEnd
= static_cast<SCROW
>(pColData
->Row
);
1780 nValue1
= pColData
->Value
;
1781 if ((nStart
<= nEnd
) && (nValue1
))
1783 ScPatternAttr
aScPattern(pDoc
->GetPool());
1784 if ((nValue1
& atBold
) == atBold
)
1785 aScPattern
.GetItemSet().Put(SvxWeightItem(WEIGHT_BOLD
, ATTR_FONT_WEIGHT
));
1786 if ((nValue1
& atItalic
) == atItalic
)
1787 aScPattern
.GetItemSet().Put(SvxPostureItem(ITALIC_NORMAL
, ATTR_FONT_POSTURE
));
1788 if ((nValue1
& atUnderline
) == atUnderline
)
1789 aScPattern
.GetItemSet().Put(SvxUnderlineItem(LINESTYLE_SINGLE
, ATTR_FONT_UNDERLINE
));
1790 if ((nValue1
& atStrikeOut
) == atStrikeOut
)
1791 aScPattern
.GetItemSet().Put(SvxCrossedOutItem(STRIKEOUT_SINGLE
, ATTR_FONT_CROSSEDOUT
));
1792 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1799 nLimit
= aJustify
.Count
;
1800 pColData
= aJustify
.pData
;
1801 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1803 SCROW nEnd
= static_cast<SCROW
>(pColData
->Row
);
1804 nValue1
= pColData
->Value
;
1805 if ((nStart
<= nEnd
) && (nValue1
))
1807 ScPatternAttr
aScPattern(pDoc
->GetPool());
1808 sal_uInt16 HorJustify
= (nValue1
& 0x000F);
1809 sal_uInt16 VerJustify
= (nValue1
& 0x00F0) >> 4;
1810 sal_uInt16 OJustify
= (nValue1
& 0x0F00) >> 8;
1811 sal_uInt16 EJustify
= (nValue1
& 0xF000) >> 12;
1816 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_LEFT
, ATTR_HOR_JUSTIFY
));
1819 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
));
1822 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT
, ATTR_HOR_JUSTIFY
));
1829 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_TOP
, ATTR_VER_JUSTIFY
));
1832 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_CENTER
, ATTR_VER_JUSTIFY
));
1835 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_BOTTOM
, ATTR_VER_JUSTIFY
));
1839 if (OJustify
& ojWordBreak
)
1840 aScPattern
.GetItemSet().Put(SfxBoolItem(ATTR_LINEBREAK
, true));
1841 if (OJustify
& ojBottomTop
)
1842 aScPattern
.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE
,9000));
1843 else if (OJustify
& ojTopBottom
)
1844 aScPattern
.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE
,27000));
1846 sal_Int16 Margin
= std::max((sal_uInt16
)20, (sal_uInt16
)(EJustify
* 20));
1847 if (OJustify
& ojBottomTop
)
1848 aScPattern
.GetItemSet().Put(SvxMarginItem(20, Margin
, 20, Margin
, ATTR_MARGIN
));
1850 aScPattern
.GetItemSet().Put(SvxMarginItem(Margin
, 20, Margin
, 20, ATTR_MARGIN
));
1851 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1857 sal_uInt16 nColorIndex
= 0;
1858 sal_uInt16 nFrameIndex
= 0;
1861 const sal_uInt32 nHelpMeStart
= 100;
1862 sal_uInt32 nHelpMe
= nHelpMeStart
;
1863 sal_uInt16 nColorIndexOld
= nColorIndex
;
1864 sal_uInt16 nFrameIndexOld
= nColorIndex
;
1867 while( !bEnd
&& nHelpMe
)
1870 pColData
= &aFrame
.pData
[ nFrameIndex
];
1872 sal_uInt16 nValue
= pColData
->Value
;
1873 sal_uInt16 nLeft
= 0;
1874 sal_uInt16 nTop
= 0;
1875 sal_uInt16 nRight
= 0;
1876 sal_uInt16 nBottom
= 0;
1877 sal_uInt16 fLeft
= ( nValue
& 0x000F );
1878 sal_uInt16 fTop
= ( nValue
& 0x00F0 ) >> 4;
1879 sal_uInt16 fRight
= ( nValue
& 0x0F00 ) >> 8;
1880 sal_uInt16 fBottom
= ( nValue
& 0xF000 ) >> 12;
1884 else if( fLeft
> 0 )
1894 else if( fRight
> 0 )
1899 else if( fBottom
> 0 )
1902 Color
ColorLeft( COL_BLACK
);
1903 Color
ColorTop( COL_BLACK
);
1904 Color
ColorRight( COL_BLACK
);
1905 Color
ColorBottom( COL_BLACK
);
1906 sal_uInt16 nFrmColVal
= aFrameColor
.pData
[ nColorIndex
].Value
;
1907 SCROW nFrmColRow
= static_cast<SCROW
>(aFrameColor
.pData
[ nColorIndex
].Row
);
1908 sal_uInt16 cLeft
= ( nFrmColVal
& 0x000F );
1909 sal_uInt16 cTop
= ( nFrmColVal
& 0x00F0 ) >> 4;
1910 sal_uInt16 cRight
= ( nFrmColVal
& 0x0F00 ) >> 8;
1911 sal_uInt16 cBottom
= ( nFrmColVal
& 0xF000 ) >> 12;
1913 lcl_ChangeColor( cLeft
, ColorLeft
);
1914 lcl_ChangeColor( cTop
, ColorTop
);
1915 lcl_ChangeColor( cRight
, ColorRight
);
1916 lcl_ChangeColor( cBottom
, ColorBottom
);
1918 if( static_cast<SCROW
>(pColData
->Row
) < nFrmColRow
)
1920 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1921 if( nFrameIndex
< ( aFrame
.Count
- 1 ) )
1924 else if( static_cast<SCROW
>(pColData
->Row
) > nFrmColRow
)
1926 nEnd
= static_cast<SCROW
>(aFrameColor
.pData
[ nColorIndex
].Row
);
1927 if( nColorIndex
< ( aFrameColor
.Count
- 1 ) )
1933 if( nFrameIndex
< (aFrame
.Count
- 1 ) )
1935 if( nColorIndex
< ( aFrameColor
.Count
- 1 ) )
1938 if( ( nStart
<= nEnd
) && ( nValue
!= 0 ) )
1940 ScPatternAttr
aScPattern(pDoc
->GetPool());
1941 ::editeng::SvxBorderLine aLine
;
1942 SvxBoxItem
aBox( ATTR_BORDER
);
1944 aLine
.SetWidth( nLeft
);
1945 aLine
.SetColor( ColorLeft
);
1946 aBox
.SetLine( &aLine
, SvxBoxItemLine::LEFT
);
1948 aLine
.SetWidth( nTop
);
1949 aLine
.SetColor( ColorTop
);
1950 aBox
.SetLine( &aLine
, SvxBoxItemLine::TOP
);
1952 aLine
.SetWidth( nRight
);
1953 aLine
.SetColor( ColorRight
);
1954 aBox
.SetLine( &aLine
, SvxBoxItemLine::RIGHT
);
1956 aLine
.SetWidth( nBottom
);
1957 aLine
.SetColor( ColorBottom
);
1958 aBox
.SetLine( &aLine
, SvxBoxItemLine::BOTTOM
);
1960 aScPattern
.GetItemSet().Put( aBox
);
1961 pDoc
->ApplyPatternAreaTab( Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1965 bEnd
= ( nFrameIndex
== ( aFrame
.Count
- 1 ) ) && ( nColorIndex
== ( aFrameColor
.Count
- 1 ) );
1967 if( nColorIndexOld
!= nColorIndex
|| nFrameIndexOld
!= nFrameIndex
)
1969 nColorIndexOld
= nColorIndex
;
1970 nFrameIndexOld
= nFrameIndex
;
1971 nHelpMe
= nHelpMeStart
;
1979 // TODO: Code up to here works more or less ... from here I've had enough ! (GT)
1981 // Background (Color, Raster)
1982 sal_uInt16 nRasterIndex
= 0;
1988 nHelpMe
= nHelpMeStart
;
1989 sal_uInt16 nRasterIndexOld
= nRasterIndex
;
1991 while( !bEnd
&& nHelpMe
)
1994 sal_uInt16 nBColor
= ( aColor
.pData
[ nColorIndex
].Value
& 0x00F0 ) >> 4;
1995 sal_uInt16 nRColor
= ( aColor
.pData
[ nColorIndex
].Value
& 0x0F00 ) >> 8;
1996 Color
aBColor( COL_BLACK
);
1998 lcl_ChangeColor( nBColor
, aBColor
);
2001 aBColor
.SetColor( COL_WHITE
);
2002 else if( nBColor
== 15 )
2003 aBColor
.SetColor( COL_BLACK
);
2005 Color
aRColor( COL_BLACK
);
2007 lcl_ChangeColor( nRColor
, aRColor
);
2009 ScPatternAttr
aScPattern( pDoc
->GetPool() );
2012 bool bSwapCol
= false;
2013 bool bSetItem
= true;
2014 switch ( aRaster
.pData
[ nRasterIndex
].Value
)
2016 case raNone
: nFact
= 0xffff; bSwapCol
= true; bSetItem
= (nBColor
> 0); break;
2017 case raGray12
: nFact
= (0xffff / 100) * 12; break;
2018 case raGray25
: nFact
= (0xffff / 100) * 25; break;
2019 case raGray50
: nFact
= (0xffff / 100) * 50; break;
2020 case raGray75
: nFact
= (0xffff / 100) * 75; break;
2021 default: nFact
= 0xffff; bSetItem
= (nRColor
< 15);
2026 aScPattern
.GetItemSet().Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
2028 aScPattern
.GetItemSet().Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
2030 if( aRaster
.pData
[ nRasterIndex
].Row
< aColor
.pData
[ nColorIndex
].Row
)
2032 nEnd
= static_cast<SCROW
>(aRaster
.pData
[ nRasterIndex
].Row
);
2033 if( nRasterIndex
< ( aRaster
.Count
- 1 ) )
2036 else if( aRaster
.pData
[ nRasterIndex
].Row
> aColor
.pData
[ nColorIndex
].Row
)
2038 nEnd
= static_cast<SCROW
>(aColor
.pData
[ nColorIndex
].Row
);
2039 if( nColorIndex
< ( aColor
.Count
- 1 ) )
2044 nEnd
= static_cast<SCROW
>(aColor
.pData
[ nColorIndex
].Row
);
2045 if( nRasterIndex
< ( aRaster
.Count
- 1 ) )
2047 if( nColorIndex
< ( aColor
.Count
- 1 ) )
2050 if( nStart
<= nEnd
)
2051 pDoc
->ApplyPatternAreaTab( Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2055 bEnd
= ( nRasterIndex
== ( aRaster
.Count
- 1 ) ) && ( nColorIndex
== ( aColor
.Count
- 1 ) );
2057 if( nColorIndexOld
!= nColorIndex
|| nRasterIndexOld
!= nRasterIndex
)
2059 nColorIndexOld
= nColorIndex
;
2060 nRasterIndexOld
= nRasterIndex
;
2061 nHelpMe
= nHelpMeStart
;
2071 nLimit
= aValue
.Count
;
2072 pColData
= aValue
.pData
;
2073 for (i
=0; i
<nLimit
; i
++, pColData
++)
2075 SCROW nEnd
= static_cast<SCROW
>(pColData
->Row
);
2076 nValue1
= pColData
->Value
;
2077 if ((nStart
<= nEnd
) && (nValue1
))
2080 sal_uInt16 nFormat
= (nValue1
& 0x00FF);
2081 sal_uInt16 nInfo
= (nValue1
& 0xFF00) >> 8;
2082 ChangeFormat(nFormat
, nInfo
, nKey
);
2083 ScPatternAttr
aScPattern(pDoc
->GetPool());
2084 aScPattern
.GetItemSet().Put(SfxUInt32Item(ATTR_VALUE_FORMAT
, (sal_uInt32
)nKey
));
2085 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2090 // Cell attributes (protected, hidden...)
2092 for (i
=0; i
<aFlag
.Count
; i
++)
2094 SCROW nEnd
= static_cast<SCROW
>(aFlag
.pData
[i
].Row
);
2095 if ((nStart
<= nEnd
) && (aFlag
.pData
[i
].Value
!= 0))
2097 bool bProtect
= ((aFlag
.pData
[i
].Value
& paProtect
) == paProtect
);
2098 bool bHFormula
= ((aFlag
.pData
[i
].Value
& paHideFormula
) == paHideFormula
);
2099 bool bHCell
= ((aFlag
.pData
[i
].Value
& paHideAll
) == paHideAll
);
2100 bool bHPrint
= ((aFlag
.pData
[i
].Value
& paHidePrint
) == paHidePrint
);
2101 ScPatternAttr
aScPattern(pDoc
->GetPool());
2102 aScPattern
.GetItemSet().Put(ScProtectionAttr(bProtect
, bHFormula
, bHCell
, bHPrint
));
2103 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2110 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
2111 for (i
=0; i
<aPattern
.Count
; i
++)
2113 SCROW nEnd
= static_cast<SCROW
>(aPattern
.pData
[i
].Row
);
2114 if ((nStart
<= nEnd
) && (aPattern
.pData
[i
].Value
!= 0))
2116 sal_uInt16 nPatternIndex
= (aPattern
.pData
[i
].Value
& 0x00FF) - 1;
2117 Sc10PatternData
* pPattern
= pPatternCollection
->At(nPatternIndex
);
2118 if (pPattern
!= nullptr)
2120 ScStyleSheet
* pStyle
= static_cast<ScStyleSheet
*>( pStylePool
->Find(
2121 SC10TOSTRING( pPattern
->Name
), SfxStyleFamily::Para
) );
2123 if (pStyle
!= nullptr)
2124 pDoc
->ApplyStyleAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, *pStyle
);
2131 void Sc10Import::LoadAttr(Sc10ColAttr
& rAttr
)
2133 // rAttr is not reused, otherwise we'd have to delete [] rAttr.pData;
2134 rStream
.ReadUInt16(rAttr
.Count
);
2136 const size_t nMaxEntries
= rStream
.remainingSize() / (sizeof(sal_uInt16
) * 2);
2137 if (rAttr
.Count
> nMaxEntries
)
2138 rAttr
.Count
= nMaxEntries
;
2143 rAttr
.pData
= new (::std::nothrow
) Sc10ColData
[rAttr
.Count
];
2144 if (rAttr
.pData
== nullptr)
2146 nError
= errOutOfMemory
;
2151 for (sal_uInt16 i
= 0; i
< rAttr
.Count
; ++i
)
2153 rStream
.ReadUInt16( rAttr
.pData
[i
].Row
);
2154 rStream
.ReadUInt16( rAttr
.pData
[i
].Value
);
2157 nError
= rStream
.GetError();
2160 void Sc10Import::ChangeFormat(sal_uInt16 nFormat
, sal_uInt16 nInfo
, sal_uLong
& nKey
)
2162 // TODO: formats are mapped only for StarCalc 3.0 internal formats
2163 // more correctly, at times new formats need to be created (Stephan: please check!)
2193 // TODO: no equivalent
2216 case df_NDMY_Short
:
2268 case vfStandardRed
:
2278 case vfThousendRed
:
2290 case vfExponentRed
:
2302 void Sc10Import::LoadObjects()
2305 rStream
.ReadUInt16( ID
);
2306 if (rStream
.IsEof())
2311 rStream
.ReadUInt16( nAnz
);
2312 sal_Char Reserved
[32];
2313 rStream
.Read(Reserved
, sizeof(Reserved
));
2314 nError
= rStream
.GetError();
2315 if ((nAnz
> 0) && (nError
== 0))
2317 sal_uInt8 ObjectType
;
2318 Sc10GraphHeader GraphHeader
;
2319 bool IsOleObject
= false; // TODO: this is only a band-aid
2320 for (sal_uInt16 i
= 0; (i
< nAnz
) && (nError
== 0) && !rStream
.IsEof() && !IsOleObject
; i
++)
2322 rStream
.ReadUChar( ObjectType
);
2323 lcl_ReadGraphHeader(rStream
, GraphHeader
);
2325 double nPPTX
= ScGlobal::nScreenPPTX
;
2326 double nPPTY
= ScGlobal::nScreenPPTY
;
2329 SCCOL nMaxCol
= SanitizeCol(GraphHeader
.CarretX
);
2330 for (SCCOL nX
= 0; nX
< nMaxCol
; ++nX
)
2331 nStartX
+= pDoc
->GetColWidth(nX
, static_cast<SCTAB
>(GraphHeader
.CarretZ
));
2332 nStartX
= (long) ( nStartX
* HMM_PER_TWIPS
);
2333 nStartX
+= (long) ( GraphHeader
.x
/ nPPTX
* HMM_PER_TWIPS
);
2334 long nSizeX
= (long) ( GraphHeader
.w
/ nPPTX
* HMM_PER_TWIPS
);
2335 long nStartY
= pDoc
->GetRowHeight( 0,
2336 SanitizeRow(static_cast<SCsROW
>(GraphHeader
.CarretY
) - 1),
2337 SanitizeTab(static_cast<SCTAB
>(GraphHeader
.CarretZ
)));
2338 nStartY
= (long) ( nStartY
* HMM_PER_TWIPS
);
2339 nStartY
+= (long) ( GraphHeader
.y
/ nPPTY
* HMM_PER_TWIPS
);
2340 long nSizeY
= (long) ( GraphHeader
.h
/ nPPTY
* HMM_PER_TWIPS
);
2345 // TODO: here we need to do something like OleLoadFromStream
2350 Sc10ImageHeader ImageHeader
;
2351 lcl_ReadImageHeaer(rStream
, ImageHeader
);
2353 // Attention: here come the data (Bitmap oder Metafile)
2354 // Typ = 1 Device-dependend Bitmap DIB
2356 rStream
.SeekRel(ImageHeader
.Size
);
2358 if( ImageHeader
.Typ
!= 1 && ImageHeader
.Typ
!= 2 )
2359 nError
= errUnknownFormat
;
2364 Sc10ChartHeader ChartHeader
;
2365 Sc10ChartSheetData ChartSheetData
;
2366 Sc10ChartTypeData
* pTypeData
= new (::std::nothrow
) Sc10ChartTypeData
;
2368 nError
= errOutOfMemory
;
2371 lcl_ReadChartHeader(rStream
, ChartHeader
);
2373 // TODO: use old Metafile ??
2374 rStream
.SeekRel(ChartHeader
.Size
);
2376 lcl_ReadChartSheetData(rStream
, ChartSheetData
);
2378 lcl_ReadChartTypeData(rStream
, *pTypeData
);
2380 Rectangle
aRect( Point(nStartX
,nStartY
), Size(nSizeX
,nSizeY
) );
2381 Sc10InsertObject::InsertChart( pDoc
, static_cast<SCTAB
>(GraphHeader
.CarretZ
), aRect
,
2382 static_cast<SCTAB
>(GraphHeader
.CarretZ
),
2383 ChartSheetData
.DataX1
, ChartSheetData
.DataY1
,
2384 ChartSheetData
.DataX2
, ChartSheetData
.DataY2
);
2391 nError
= errUnknownFormat
;
2394 nError
= rStream
.GetError();
2400 OSL_FAIL( "ObjectID" );
2401 nError
= errUnknownID
;
2405 FltError
ScFormatFilterPluginImpl::ScImportStarCalc10( SvStream
& rStream
, ScDocument
* pDocument
)
2407 rStream
.Seek( 0UL );
2408 Sc10Import
aImport( rStream
, pDocument
);
2409 return ( FltError
) aImport
.Import();
2412 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */