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"
71 using namespace com::sun::star
;
73 #define DEFCHARSET RTL_TEXTENCODING_MS_1252
75 #define SC10TOSTRING(p) String((p),DEFCHARSET)
77 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
);
95 static void lcl_ReadFileHeader(SvStream
& rStream
, Sc10FileHeader
& rFileHeader
)
97 lcl_ReadFixedString( rStream
, &rFileHeader
.CopyRight
, sizeof(rFileHeader
.CopyRight
));
98 rStream
>> rFileHeader
.Version
;
99 rStream
.Read(&rFileHeader
.Reserved
, sizeof(rFileHeader
.Reserved
));
103 static void lcl_ReadTabProtect(SvStream
& rStream
, Sc10TableProtect
& rProtect
)
105 lcl_ReadFixedString( rStream
, &rProtect
.PassWord
, sizeof(rProtect
.PassWord
));
106 rStream
>> rProtect
.Flags
;
107 rStream
>> rProtect
.Protect
;
111 static void lcl_ReadSheetProtect(SvStream
& rStream
, Sc10SheetProtect
& rProtect
)
113 lcl_ReadFixedString( rStream
, &rProtect
.PassWord
, sizeof(rProtect
.PassWord
));
114 rStream
>> rProtect
.Flags
;
115 rStream
>> rProtect
.Protect
;
119 static void lcl_ReadRGB(SvStream
& rStream
, Sc10Color
& rColor
)
121 rStream
>> rColor
.Dummy
;
122 rStream
>> rColor
.Blue
;
123 rStream
>> rColor
.Green
;
124 rStream
>> rColor
.Red
;
128 static void lcl_ReadPalette(SvStream
& rStream
, Sc10Color
* pPalette
)
130 for (sal_uInt16 i
= 0; i
< 16; i
++)
131 lcl_ReadRGB(rStream
, pPalette
[i
]);
135 static void lcl_ReadValueFormat(SvStream
& rStream
, Sc10ValueFormat
& rFormat
)
137 rStream
>> rFormat
.Format
;
138 rStream
>> rFormat
.Info
;
142 static void lcl_ReadLogFont(SvStream
& rStream
, Sc10LogFont
& rFont
)
144 rStream
>> rFont
.lfHeight
;
145 rStream
>> rFont
.lfWidth
;
146 rStream
>> rFont
.lfEscapement
;
147 rStream
>> rFont
.lfOrientation
;
148 rStream
>> rFont
.lfWeight
;
149 rStream
>> rFont
.lfItalic
;
150 rStream
>> rFont
.lfUnderline
;
151 rStream
>> rFont
.lfStrikeOut
;
152 rStream
>> rFont
.lfCharSet
;
153 rStream
>> rFont
.lfOutPrecision
;
154 rStream
>> rFont
.lfClipPrecision
;
155 rStream
>> rFont
.lfQuality
;
156 rStream
>> rFont
.lfPitchAndFamily
;
157 lcl_ReadFixedString( rStream
, &rFont
.lfFaceName
, sizeof(rFont
.lfFaceName
));
161 static void lcl_ReadBlockRect(SvStream
& rStream
, Sc10BlockRect
& rBlock
)
163 rStream
>> rBlock
.x1
;
164 rStream
>> rBlock
.y1
;
165 rStream
>> rBlock
.x2
;
166 rStream
>> rBlock
.y2
;
170 static void lcl_ReadHeadFootLine(SvStream
& rStream
, Sc10HeadFootLine
& rLine
)
172 lcl_ReadFixedString( rStream
, &rLine
.Title
, sizeof(rLine
.Title
));
173 lcl_ReadLogFont(rStream
, rLine
.LogFont
);
174 rStream
>> rLine
.HorJustify
;
175 rStream
>> rLine
.VerJustify
;
176 rStream
>> rLine
.Raster
;
177 rStream
>> rLine
.Frame
;
178 lcl_ReadRGB(rStream
, rLine
.TextColor
);
179 lcl_ReadRGB(rStream
, rLine
.BackColor
);
180 lcl_ReadRGB(rStream
, rLine
.RasterColor
);
181 rStream
>> rLine
.FrameColor
;
182 rStream
>> rLine
.Reserved
;
186 static void lcl_ReadPageFormat(SvStream
& rStream
, Sc10PageFormat
& rFormat
)
188 lcl_ReadHeadFootLine(rStream
, rFormat
.HeadLine
);
189 lcl_ReadHeadFootLine(rStream
, rFormat
.FootLine
);
190 rStream
>> rFormat
.Orientation
;
191 rStream
>> rFormat
.Width
;
192 rStream
>> rFormat
.Height
;
193 rStream
>> rFormat
.NonPrintableX
;
194 rStream
>> rFormat
.NonPrintableY
;
195 rStream
>> rFormat
.Left
;
196 rStream
>> rFormat
.Top
;
197 rStream
>> rFormat
.Right
;
198 rStream
>> rFormat
.Bottom
;
199 rStream
>> rFormat
.Head
;
200 rStream
>> rFormat
.Foot
;
201 rStream
>> rFormat
.HorCenter
;
202 rStream
>> rFormat
.VerCenter
;
203 rStream
>> rFormat
.PrintGrid
;
204 rStream
>> rFormat
.PrintColRow
;
205 rStream
>> rFormat
.PrintNote
;
206 rStream
>> rFormat
.TopBottomDir
;
207 lcl_ReadFixedString( rStream
, &rFormat
.PrintAreaName
, sizeof(rFormat
.PrintAreaName
));
208 lcl_ReadBlockRect(rStream
, rFormat
.PrintArea
);
209 rStream
.Read(&rFormat
.PrnZoom
, sizeof(rFormat
.PrnZoom
));
210 rStream
>> rFormat
.FirstPageNo
;
211 rStream
>> rFormat
.RowRepeatStart
;
212 rStream
>> rFormat
.RowRepeatEnd
;
213 rStream
>> rFormat
.ColRepeatStart
;
214 rStream
>> rFormat
.ColRepeatEnd
;
215 rStream
.Read(&rFormat
.Reserved
, sizeof(rFormat
.Reserved
));
219 static void lcl_ReadGraphHeader(SvStream
& rStream
, Sc10GraphHeader
& rHeader
)
221 rStream
>> rHeader
.Typ
;
222 rStream
>> rHeader
.CarretX
;
223 rStream
>> rHeader
.CarretY
;
224 rStream
>> rHeader
.CarretZ
;
225 rStream
>> rHeader
.x
;
226 rStream
>> rHeader
.y
;
227 rStream
>> rHeader
.w
;
228 rStream
>> rHeader
.h
;
229 rStream
>> rHeader
.IsRelPos
;
230 rStream
>> rHeader
.DoPrint
;
231 rStream
>> rHeader
.FrameType
;
232 rStream
>> rHeader
.IsTransparent
;
233 lcl_ReadRGB(rStream
, rHeader
.FrameColor
);
234 lcl_ReadRGB(rStream
, rHeader
.BackColor
);
235 rStream
.Read(&rHeader
.Reserved
, sizeof(rHeader
.Reserved
));
239 static void lcl_ReadImageHeaer(SvStream
& rStream
, Sc10ImageHeader
& rHeader
)
241 lcl_ReadFixedString( rStream
, &rHeader
.FileName
, sizeof(rHeader
.FileName
));
242 rStream
>> rHeader
.Typ
;
243 rStream
>> rHeader
.Linked
;
244 rStream
>> rHeader
.x1
;
245 rStream
>> rHeader
.y1
;
246 rStream
>> rHeader
.x2
;
247 rStream
>> rHeader
.y2
;
248 rStream
>> rHeader
.Size
;
252 static void lcl_ReadChartHeader(SvStream
& rStream
, Sc10ChartHeader
& rHeader
)
254 rStream
>> rHeader
.MM
;
255 rStream
>> rHeader
.xExt
;
256 rStream
>> rHeader
.yExt
;
257 rStream
>> rHeader
.Size
;
261 static void lcl_ReadChartSheetData(SvStream
& rStream
, Sc10ChartSheetData
& rSheetData
)
263 rStream
>> rSheetData
.HasTitle
;
264 rStream
>> rSheetData
.TitleX
;
265 rStream
>> rSheetData
.TitleY
;
266 rStream
>> rSheetData
.HasSubTitle
;
267 rStream
>> rSheetData
.SubTitleX
;
268 rStream
>> rSheetData
.SubTitleY
;
269 rStream
>> rSheetData
.HasLeftTitle
;
270 rStream
>> rSheetData
.LeftTitleX
;
271 rStream
>> rSheetData
.LeftTitleY
;
272 rStream
>> rSheetData
.HasLegend
;
273 rStream
>> rSheetData
.LegendX1
;
274 rStream
>> rSheetData
.LegendY1
;
275 rStream
>> rSheetData
.LegendX2
;
276 rStream
>> rSheetData
.LegendY2
;
277 rStream
>> rSheetData
.HasLabel
;
278 rStream
>> rSheetData
.LabelX1
;
279 rStream
>> rSheetData
.LabelY1
;
280 rStream
>> rSheetData
.LabelX2
;
281 rStream
>> rSheetData
.LabelY2
;
282 rStream
>> rSheetData
.DataX1
;
283 rStream
>> rSheetData
.DataY1
;
284 rStream
>> rSheetData
.DataX2
;
285 rStream
>> rSheetData
.DataY2
;
286 rStream
.Read(&rSheetData
.Reserved
, sizeof(rSheetData
.Reserved
));
290 static void lcl_ReadChartTypeData(SvStream
& rStream
, Sc10ChartTypeData
& rTypeData
)
292 rStream
>> rTypeData
.NumSets
;
293 rStream
>> rTypeData
.NumPoints
;
294 rStream
>> rTypeData
.DrawMode
;
295 rStream
>> rTypeData
.GraphType
;
296 rStream
>> rTypeData
.GraphStyle
;
297 lcl_ReadFixedString( rStream
, &rTypeData
.GraphTitle
, sizeof(rTypeData
.GraphTitle
));
298 lcl_ReadFixedString( rStream
, &rTypeData
.BottomTitle
, sizeof(rTypeData
.BottomTitle
));
300 for (i
= 0; i
< 256; i
++)
301 rStream
>> rTypeData
.SymbolData
[i
];
302 for (i
= 0; i
< 256; i
++)
303 rStream
>> rTypeData
.ColorData
[i
];
304 for (i
= 0; i
< 256; i
++)
305 rStream
>> rTypeData
.ThickLines
[i
];
306 for (i
= 0; i
< 256; i
++)
307 rStream
>> rTypeData
.PatternData
[i
];
308 for (i
= 0; i
< 256; i
++)
309 rStream
>> rTypeData
.LinePatternData
[i
];
310 for (i
= 0; i
< 11; i
++)
311 rStream
>> rTypeData
.NumGraphStyles
[i
];
312 rStream
>> rTypeData
.ShowLegend
;
313 for (i
= 0; i
< 256; i
++)
314 lcl_ReadFixedString( rStream
, &rTypeData
.LegendText
[i
], sizeof(Sc10ChartText
));
315 rStream
>> rTypeData
.ExplodePie
;
316 rStream
>> rTypeData
.FontUse
;
317 for (i
= 0; i
< 5; i
++)
318 rStream
>> rTypeData
.FontFamily
[i
];
319 for (i
= 0; i
< 5; i
++)
320 rStream
>> rTypeData
.FontStyle
[i
];
321 for (i
= 0; i
< 5; i
++)
322 rStream
>> rTypeData
.FontSize
[i
];
323 rStream
>> rTypeData
.GridStyle
;
324 rStream
>> rTypeData
.Labels
;
325 rStream
>> rTypeData
.LabelEvery
;
326 for (i
= 0; i
< 50; i
++)
327 lcl_ReadFixedString( rStream
, &rTypeData
.LabelText
[i
], sizeof(Sc10ChartText
));
328 lcl_ReadFixedString( rStream
, &rTypeData
.LeftTitle
, sizeof(rTypeData
.LeftTitle
));
329 rStream
.Read(&rTypeData
.Reserved
, sizeof(rTypeData
.Reserved
));
332 static double lcl_PascalToDouble(sal_Char
* tp6
)
334 sal_uInt8
* pnUnsigned
= reinterpret_cast< sal_uInt8
* >( tp6
);
336 sal_uInt8 be
= pnUnsigned
[ 0 ];
337 // lower 16 bits of mantissa
338 sal_uInt16 v1
= static_cast< sal_uInt16
>( pnUnsigned
[ 2 ] * 256 + pnUnsigned
[ 1 ] );
339 // next 16 bits of mantissa
340 sal_uInt16 v2
= static_cast< sal_uInt16
>( pnUnsigned
[ 4 ] * 256 + pnUnsigned
[ 3 ] );
341 // upper 7 bits of mantissa
342 sal_uInt8 v3
= static_cast< sal_uInt8
>( pnUnsigned
[ 5 ] & 0x7F );
344 bool s
= (pnUnsigned
[ 5 ] & 0x80) != 0;
348 return (((((128 + v3
) * 65536.0) + v2
) * 65536.0 + v1
) *
349 ldexp ((s
? -1.0 : 1.0), be
- (129+39)));
353 static void lcl_ChangeColor( sal_uInt16 nIndex
, Color
& rColor
)
359 case 1: aCol
= COL_RED
; break;
360 case 2: aCol
= COL_GREEN
; break;
361 case 3: aCol
= COL_BROWN
; break;
362 case 4: aCol
= COL_BLUE
; break;
363 case 5: aCol
= COL_MAGENTA
; break;
364 case 6: aCol
= COL_CYAN
; break;
365 case 7: aCol
= COL_GRAY
; break;
366 case 8: aCol
= COL_LIGHTGRAY
; break;
367 case 9: aCol
= COL_LIGHTRED
; break;
368 case 10: aCol
= COL_LIGHTGREEN
; break;
369 case 11: aCol
= COL_YELLOW
; break;
370 case 12: aCol
= COL_LIGHTBLUE
; break;
371 case 13: aCol
= COL_LIGHTMAGENTA
; break;
372 case 14: aCol
= COL_LIGHTCYAN
; break;
373 case 15: aCol
= COL_WHITE
; break;
374 default: aCol
= COL_BLACK
;
377 rColor
.SetColor( aCol
);
380 static String
lcl_MakeOldPageStyleFormatName( sal_uInt16 i
)
382 OUString aName
= ScGlobal::GetRscString( STR_PAGESTYLE
) + " " + OUString::number( i
+ 1 );
387 template < typename T
> sal_uLong
insert_new( ScCollection
* pCollection
, SvStream
& rStream
)
389 T
* pData
= new (::std::nothrow
) T( rStream
);
390 sal_uLong nError
= rStream
.GetError();
396 pCollection
->Insert( pData
);
399 nError
= errOutOfMemory
;
403 //--------------------------------------------
405 //--------------------------------------------
407 Sc10FontData::Sc10FontData(SvStream
& rStream
)
411 rStream
>> PitchAndFamily
;
414 if (nLen
< sizeof(FaceName
))
415 rStream
.Read(FaceName
, nLen
);
417 rStream
.SetError(ERRCODE_IO_WRONGFORMAT
);
421 Sc10FontCollection::Sc10FontCollection(SvStream
& rStream
) :
431 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
433 nError
= insert_new
<Sc10FontData
>( this, rStream
);
438 OSL_FAIL( "FontID" );
439 nError
= errUnknownID
;
443 //--------------------------------------------
445 //--------------------------------------------
447 Sc10NameData::Sc10NameData(SvStream
& rStream
)
451 rStream
.Read(Name
, sizeof(Name
) - 1);
452 if (nLen
>= sizeof(Name
))
453 nLen
= sizeof(Name
) - 1;
457 rStream
.Read(Reference
, sizeof(Reference
) - 1);
458 if (nLen
>= sizeof(Reference
))
459 nLen
= sizeof(Reference
) - 1;
461 rStream
.Read(Reserved
, sizeof(Reserved
));
465 Sc10NameCollection::Sc10NameCollection(SvStream
& rStream
) :
475 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
477 nError
= insert_new
<Sc10NameData
>( this, rStream
);
482 OSL_FAIL( "NameID" );
483 nError
= errUnknownID
;
487 //--------------------------------------------
489 //--------------------------------------------
491 Sc10PatternData::Sc10PatternData(SvStream
& rStream
)
493 lcl_ReadFixedString( rStream
, Name
, sizeof(Name
));
494 lcl_ReadValueFormat(rStream
, ValueFormat
);
495 lcl_ReadLogFont(rStream
, LogFont
);
502 rStream
>> FrameColor
;
504 rStream
>> FormatFlags
;
505 rStream
.Read(Reserved
, sizeof(Reserved
));
509 Sc10PatternCollection::Sc10PatternCollection(SvStream
& rStream
) :
519 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
521 nError
= insert_new
<Sc10PatternData
>( this, rStream
);
526 OSL_FAIL( "PatternID" );
527 nError
= errUnknownID
;
531 //--------------------------------------------
533 //--------------------------------------------
535 Sc10DataBaseData::Sc10DataBaseData(SvStream
& rStream
)
537 lcl_ReadFixedString( rStream
, &DataBaseRec
.Name
, sizeof(DataBaseRec
.Name
));
538 rStream
>> DataBaseRec
.Tab
;
539 lcl_ReadBlockRect(rStream
, DataBaseRec
.Block
);
540 rStream
>> DataBaseRec
.RowHeader
;
541 rStream
>> DataBaseRec
.SortField0
;
542 rStream
>> DataBaseRec
.SortUpOrder0
;
543 rStream
>> DataBaseRec
.SortField1
;
544 rStream
>> DataBaseRec
.SortUpOrder1
;
545 rStream
>> DataBaseRec
.SortField2
;
546 rStream
>> DataBaseRec
.SortUpOrder2
;
547 rStream
>> DataBaseRec
.IncludeFormat
;
549 rStream
>> DataBaseRec
.QueryField0
;
550 rStream
>> DataBaseRec
.QueryOp0
;
551 rStream
>> DataBaseRec
.QueryByString0
;
552 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString0
, sizeof(DataBaseRec
.QueryString0
));
553 DataBaseRec
.QueryValue0
= ScfTools::ReadLongDouble(rStream
);
555 rStream
>> DataBaseRec
.QueryConnect1
;
556 rStream
>> DataBaseRec
.QueryField1
;
557 rStream
>> DataBaseRec
.QueryOp1
;
558 rStream
>> DataBaseRec
.QueryByString1
;
559 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString1
, sizeof(DataBaseRec
.QueryString1
));
560 DataBaseRec
.QueryValue1
= ScfTools::ReadLongDouble(rStream
);
562 rStream
>> DataBaseRec
.QueryConnect2
;
563 rStream
>> DataBaseRec
.QueryField2
;
564 rStream
>> DataBaseRec
.QueryOp2
;
565 rStream
>> DataBaseRec
.QueryByString2
;
566 lcl_ReadFixedString( rStream
, &DataBaseRec
.QueryString2
, sizeof(DataBaseRec
.QueryString2
));
567 DataBaseRec
.QueryValue2
= ScfTools::ReadLongDouble(rStream
);
571 Sc10DataBaseCollection::Sc10DataBaseCollection(SvStream
& rStream
) :
577 if (ID
== DataBaseID
)
579 lcl_ReadFixedString( rStream
, ActName
, sizeof(ActName
));
582 for (sal_uInt16 i
=0; (i
< nAnz
) && (nError
== 0); i
++)
584 nError
= insert_new
<Sc10DataBaseData
>( this, rStream
);
589 OSL_FAIL( "DataBaseID" );
590 nError
= errUnknownID
;
595 int Sc10LogFont::operator==( const Sc10LogFont
& rData
) const
597 return !strcmp( lfFaceName
, rData
.lfFaceName
)
598 && lfHeight
== rData
.lfHeight
599 && lfWidth
== rData
.lfWidth
600 && lfEscapement
== rData
.lfEscapement
601 && lfOrientation
== rData
.lfOrientation
602 && lfWeight
== rData
.lfWeight
603 && lfItalic
== rData
.lfItalic
604 && lfUnderline
== rData
.lfUnderline
605 && lfStrikeOut
== rData
.lfStrikeOut
606 && lfCharSet
== rData
.lfCharSet
607 && lfOutPrecision
== rData
.lfOutPrecision
608 && lfClipPrecision
== rData
.lfClipPrecision
609 && lfQuality
== rData
.lfQuality
610 && lfPitchAndFamily
== rData
.lfPitchAndFamily
;
614 int Sc10Color::operator==( const Sc10Color
& rColor
) const
616 return ((Red
== rColor
.Red
) && (Green
== rColor
.Green
) && (Blue
== rColor
.Blue
));
620 int Sc10HeadFootLine::operator==( const Sc10HeadFootLine
& rData
) const
622 return !strcmp(Title
, rData
.Title
)
623 && LogFont
== rData
.LogFont
624 && HorJustify
== rData
.HorJustify
625 && VerJustify
== rData
.VerJustify
626 && Raster
== rData
.Raster
627 && Frame
== rData
.Frame
628 && TextColor
== rData
.TextColor
629 && BackColor
== rData
.BackColor
630 && RasterColor
== rData
.RasterColor
631 && FrameColor
== rData
.FrameColor
632 && Reserved
== rData
.Reserved
;
636 int Sc10PageFormat::operator==( const Sc10PageFormat
& rData
) const
638 return !strcmp(PrintAreaName
, rData
.PrintAreaName
)
639 && HeadLine
== rData
.HeadLine
640 && FootLine
== rData
.FootLine
641 && Orientation
== rData
.Orientation
642 && Width
== rData
.Width
643 && Height
== rData
.Height
644 && NonPrintableX
== rData
.NonPrintableX
645 && NonPrintableY
== rData
.NonPrintableY
646 && Left
== rData
.Left
648 && Right
== rData
.Right
649 && Bottom
== rData
.Bottom
650 && Head
== rData
.Head
651 && Foot
== rData
.Foot
652 && HorCenter
== rData
.HorCenter
653 && VerCenter
== rData
.VerCenter
654 && PrintGrid
== rData
.PrintGrid
655 && PrintColRow
== rData
.PrintColRow
656 && PrintNote
== rData
.PrintNote
657 && TopBottomDir
== rData
.TopBottomDir
658 && FirstPageNo
== rData
.FirstPageNo
659 && RowRepeatStart
== rData
.RowRepeatStart
660 && RowRepeatEnd
== rData
.RowRepeatEnd
661 && ColRepeatStart
== rData
.ColRepeatStart
662 && ColRepeatEnd
== rData
.ColRepeatEnd
663 && !memcmp( PrnZoom
, rData
.PrnZoom
, sizeof(PrnZoom
) )
664 && !memcmp( &PrintArea
, &rData
.PrintArea
, sizeof(PrintArea
) );
668 sal_uInt16
Sc10PageCollection::InsertFormat( const Sc10PageFormat
& rData
)
670 for (sal_uInt16 i
=0; i
<nCount
; i
++)
671 if (At(i
)->aPageFormat
== rData
)
674 Insert( new Sc10PageData(rData
) );
680 static inline sal_uInt8
GetMixedCol( const sal_uInt8 nB
, const sal_uInt8 nF
, const sal_uInt16 nFak
)
682 sal_Int32 nT
= nB
- nF
;
683 nT
*= ( sal_Int32
) nFak
;
686 return ( sal_uInt8
) nT
;
688 static inline Color
GetMixedColor( const Color
& rFore
, const Color
& rBack
, sal_uInt16 nFact
)
690 return Color( GetMixedCol( rBack
.GetRed(), rFore
.GetRed(), nFact
),
691 GetMixedCol( rBack
.GetGreen(), rFore
.GetGreen(), nFact
),
692 GetMixedCol( rBack
.GetBlue(), rFore
.GetBlue(), nFact
) );
696 void Sc10PageCollection::PutToDoc( ScDocument
* pDoc
)
698 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
699 EditEngine
aEditEngine( pDoc
->GetEnginePool() );
700 EditTextObject
* pEmptyObject
= aEditEngine
.CreateTextObject();
702 for (sal_uInt16 i
=0; i
<nCount
; i
++)
704 Sc10PageFormat
* pPage
= &At(i
)->aPageFormat
;
706 pPage
->Width
= (short) ( pPage
->Width
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
707 pPage
->Height
= (short) ( pPage
->Height
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
708 pPage
->Top
= (short) ( pPage
->Top
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
709 pPage
->Bottom
= (short) ( pPage
->Bottom
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
710 pPage
->Left
= (short) ( pPage
->Left
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
711 pPage
->Right
= (short) ( pPage
->Right
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
712 pPage
->Head
= (short) ( pPage
->Head
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
713 pPage
->Foot
= (short) ( pPage
->Foot
* ( PS_POINTS_PER_INCH
/ POINTS_PER_INCH
) + 0.5 );
715 String aName
= lcl_MakeOldPageStyleFormatName( i
);
717 ScStyleSheet
* pSheet
= (ScStyleSheet
*) &pStylePool
->Make( aName
,
718 SFX_STYLE_FAMILY_PAGE
,
719 SFXSTYLEBIT_USERDEF
| SCSTYLEBIT_STANDARD
);
720 // #i68483# set page style name at sheet...
721 pDoc
->SetPageStyle( static_cast< SCTAB
>( i
), aName
);
723 SfxItemSet
* pSet
= &pSheet
->GetItemSet();
725 for (sal_uInt16 nHeadFoot
=0; nHeadFoot
<2; nHeadFoot
++)
727 Sc10HeadFootLine
* pHeadFootLine
= nHeadFoot
? &pPage
->FootLine
: &pPage
->HeadLine
;
729 SfxItemSet
aEditAttribs(aEditEngine
.GetEmptyItemSet());
730 FontFamily eFam
= FAMILY_DONTKNOW
;
731 switch (pPage
->HeadLine
.LogFont
.lfPitchAndFamily
& 0xF0)
733 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
734 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
735 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
736 case ffModern
: eFam
= FAMILY_MODERN
; break;
737 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
738 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
739 default: eFam
= FAMILY_DONTKNOW
; break;
741 aEditAttribs
.Put( SvxFontItem(
743 SC10TOSTRING( pHeadFootLine
->LogFont
.lfFaceName
), EMPTY_STRING
,
744 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, EE_CHAR_FONTINFO
),
746 aEditAttribs
.Put( SvxFontHeightItem( std::abs( pHeadFootLine
->LogFont
.lfHeight
), 100, EE_CHAR_FONTHEIGHT
),
749 Sc10Color nColor
= pHeadFootLine
->TextColor
;
750 Color
TextColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
751 aEditAttribs
.Put(SvxColorItem(TextColor
, EE_CHAR_COLOR
), EE_CHAR_COLOR
);
753 if (pHeadFootLine
->LogFont
.lfWeight
!= fwNormal
)
754 aEditAttribs
.Put(SvxWeightItem(WEIGHT_BOLD
, EE_CHAR_WEIGHT
), EE_CHAR_WEIGHT
);
755 if (pHeadFootLine
->LogFont
.lfItalic
!= 0)
756 aEditAttribs
.Put(SvxPostureItem(ITALIC_NORMAL
, EE_CHAR_ITALIC
), EE_CHAR_ITALIC
);
757 if (pHeadFootLine
->LogFont
.lfUnderline
!= 0)
758 aEditAttribs
.Put(SvxUnderlineItem(UNDERLINE_SINGLE
, EE_CHAR_UNDERLINE
), EE_CHAR_UNDERLINE
);
759 if (pHeadFootLine
->LogFont
.lfStrikeOut
!= 0)
760 aEditAttribs
.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE
, EE_CHAR_STRIKEOUT
), EE_CHAR_STRIKEOUT
);
761 String
aText( pHeadFootLine
->Title
, DEFCHARSET
);
762 aEditEngine
.SetText( aText
);
763 aEditEngine
.QuickSetAttribs( aEditAttribs
, ESelection( 0, 0, 0, aText
.Len() ) );
765 EditTextObject
* pObject
= aEditEngine
.CreateTextObject();
766 ScPageHFItem
aHeaderItem(nHeadFoot
? ATTR_PAGE_FOOTERRIGHT
: ATTR_PAGE_HEADERRIGHT
);
767 switch (pHeadFootLine
->HorJustify
)
770 aHeaderItem
.SetLeftArea(*pEmptyObject
);
771 aHeaderItem
.SetCenterArea(*pObject
);
772 aHeaderItem
.SetRightArea(*pEmptyObject
);
775 aHeaderItem
.SetLeftArea(*pEmptyObject
);
776 aHeaderItem
.SetCenterArea(*pEmptyObject
);
777 aHeaderItem
.SetRightArea(*pObject
);
780 aHeaderItem
.SetLeftArea(*pObject
);
781 aHeaderItem
.SetCenterArea(*pEmptyObject
);
782 aHeaderItem
.SetRightArea(*pEmptyObject
);
786 pSet
->Put( aHeaderItem
);
788 SfxItemSet
aSetItemItemSet( *pDoc
->GetPool(),
789 ATTR_BACKGROUND
, ATTR_BACKGROUND
,
790 ATTR_BORDER
, ATTR_SHADOW
,
791 ATTR_PAGE_SIZE
, ATTR_PAGE_SIZE
,
792 ATTR_LRSPACE
, ATTR_ULSPACE
,
793 ATTR_PAGE_ON
, ATTR_PAGE_SHARED
,
795 nColor
= pHeadFootLine
->BackColor
;
796 Color
aBColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
797 nColor
= pHeadFootLine
->RasterColor
;
798 Color
aRColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
801 sal_Bool bSwapCol
= false;
802 switch (pHeadFootLine
->Raster
)
804 case raNone
: nFact
= 0xffff; bSwapCol
= sal_True
; break;
805 case raGray12
: nFact
= (0xffff / 100) * 12; break;
806 case raGray25
: nFact
= (0xffff / 100) * 25; break;
807 case raGray50
: nFact
= (0xffff / 100) * 50; break;
808 case raGray75
: nFact
= (0xffff / 100) * 75; break;
809 default: nFact
= 0xffff;
812 aSetItemItemSet
.Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
814 aSetItemItemSet
.Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
816 if (pHeadFootLine
->Frame
!= 0)
818 sal_uInt16 nLeft
= 0;
820 sal_uInt16 nRight
= 0;
821 sal_uInt16 nBottom
= 0;
822 sal_uInt16 fLeft
= (pHeadFootLine
->Frame
& 0x000F);
823 sal_uInt16 fTop
= (pHeadFootLine
->Frame
& 0x00F0) / 0x0010;
824 sal_uInt16 fRight
= (pHeadFootLine
->Frame
& 0x0F00) / 0x0100;
825 sal_uInt16 fBottom
= (pHeadFootLine
->Frame
& 0xF000) / 0x1000;
840 else if (fBottom
> 0)
842 Color
ColorLeft(COL_BLACK
);
843 Color
ColorTop(COL_BLACK
);
844 Color
ColorRight(COL_BLACK
);
845 Color
ColorBottom(COL_BLACK
);
846 sal_uInt16 cLeft
= (pHeadFootLine
->FrameColor
& 0x000F);
847 sal_uInt16 cTop
= (pHeadFootLine
->FrameColor
& 0x00F0) >> 4;
848 sal_uInt16 cRight
= (pHeadFootLine
->FrameColor
& 0x0F00) >> 8;
849 sal_uInt16 cBottom
= (pHeadFootLine
->FrameColor
& 0xF000) >> 12;
850 lcl_ChangeColor(cLeft
, ColorLeft
);
851 lcl_ChangeColor(cTop
, ColorTop
);
852 lcl_ChangeColor(cRight
, ColorRight
);
853 lcl_ChangeColor(cBottom
, ColorBottom
);
854 ::editeng::SvxBorderLine aLine
;
855 SvxBoxItem
aBox( ATTR_BORDER
);
856 aLine
.SetWidth(nLeft
);
857 aLine
.SetColor(ColorLeft
);
858 aBox
.SetLine(&aLine
, BOX_LINE_LEFT
);
859 aLine
.SetWidth(nTop
);
860 aLine
.SetColor(ColorTop
);
861 aBox
.SetLine(&aLine
, BOX_LINE_TOP
);
862 aLine
.SetWidth(nRight
);
863 aLine
.SetColor(ColorRight
);
864 aBox
.SetLine(&aLine
, BOX_LINE_RIGHT
);
865 aLine
.SetWidth(nBottom
);
866 aLine
.SetColor(ColorBottom
);
867 aBox
.SetLine(&aLine
, BOX_LINE_BOTTOM
);
869 aSetItemItemSet
.Put(aBox
);
872 pSet
->Put( SvxULSpaceItem( 0, 0, ATTR_ULSPACE
) );
875 aSetItemItemSet
.Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( 0, pPage
->Top
- pPage
->Head
) ) );
877 aSetItemItemSet
.Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( 0, pPage
->Bottom
- pPage
->Foot
) ) );
879 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_ON
, sal_True
));
880 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_DYNAMIC
, false ));
881 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_SHARED
, sal_True
));
883 pSet
->Put( SvxSetItem( nHeadFoot
? ATTR_PAGE_FOOTERSET
: ATTR_PAGE_HEADERSET
,
887 SvxPageItem
aPageItem(ATTR_PAGE
);
888 aPageItem
.SetPageUsage( SVX_PAGE_ALL
);
889 aPageItem
.SetLandscape( pPage
->Orientation
!= 1 );
890 aPageItem
.SetNumType( SVX_ARABIC
);
891 pSet
->Put(aPageItem
);
893 pSet
->Put(SvxLRSpaceItem( pPage
->Left
, pPage
->Right
, 0,0, ATTR_LRSPACE
));
894 pSet
->Put(SvxULSpaceItem( pPage
->Top
, pPage
->Bottom
, ATTR_ULSPACE
));
896 pSet
->Put(SfxBoolItem( ATTR_PAGE_HORCENTER
, pPage
->HorCenter
));
897 pSet
->Put(SfxBoolItem( ATTR_PAGE_VERCENTER
, pPage
->VerCenter
));
903 ScRange
* pRepeatRow
= NULL
;
904 ScRange
* pRepeatCol
= NULL
;
906 if ( pPage
->ColRepeatStart
>= 0 )
907 pRepeatCol
= new ScRange( static_cast<SCCOL
> (pPage
->ColRepeatStart
), 0, 0 );
908 if ( pPage
->RowRepeatStart
>= 0 )
909 pRepeatRow
= new ScRange( 0, static_cast<SCROW
> (pPage
->RowRepeatStart
), 0 );
912 if ( pRepeatRow
|| pRepeatCol
)
915 // an allen Tabellen setzen
917 for ( SCTAB nTab
= 0, nTabCount
= pDoc
->GetTableCount(); nTab
< nTabCount
; ++nTab
)
919 pDoc
->SetRepeatColRange( nTab
, pRepeatCol
);
920 pDoc
->SetRepeatRowRange( nTab
, pRepeatRow
);
931 pSet
->Put( SfxBoolItem( ATTR_PAGE_NOTES
, pPage
->PrintNote
) );
932 pSet
->Put( SfxBoolItem( ATTR_PAGE_GRID
, pPage
->PrintGrid
) );
933 pSet
->Put( SfxBoolItem( ATTR_PAGE_HEADERS
, pPage
->PrintColRow
) );
934 pSet
->Put( SfxBoolItem( ATTR_PAGE_TOPDOWN
, pPage
->TopBottomDir
) );
935 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_CHARTS
, VOBJ_MODE_SHOW
) );
936 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_OBJECTS
, VOBJ_MODE_SHOW
) );
937 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_DRAWINGS
, VOBJ_MODE_SHOW
) );
938 pSet
->Put( SfxUInt16Item( ATTR_PAGE_SCALE
,
939 (sal_uInt16
)( lcl_PascalToDouble( pPage
->PrnZoom
) * 100 ) ) );
940 pSet
->Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO
, 1 ) );
942 pSet
->Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( pPage
->Width
, pPage
->Height
) ) );
949 ScDataObject
* Sc10PageData::Clone() const
951 return new Sc10PageData(aPageFormat
);
955 //--------------------------------------------
957 //--------------------------------------------
960 Sc10Import::Sc10Import(SvStream
& rStr
, ScDocument
* pDocument
) :
963 pFontCollection (NULL
),
964 pNameCollection (NULL
),
965 pPatternCollection (NULL
),
966 pDataBaseCollection (NULL
),
974 Sc10Import::~Sc10Import()
976 pDoc
->CalcAfterLoad();
977 pDoc
->UpdateAllCharts();
979 delete pFontCollection
;
980 delete pNameCollection
;
981 delete pPatternCollection
;
982 delete pDataBaseCollection
;
984 OSL_ENSURE( pPrgrsBar
== NULL
,
985 "*Sc10Import::Sc10Import(): Progressbar lebt noch!?" );
989 sal_uLong
Sc10Import::Import()
991 pPrgrsBar
= new ScfStreamProgressBar( rStream
, pDoc
->GetDocumentShell() );
993 ScDocOptions aOpt
= pDoc
->GetDocOptions();
994 aOpt
.SetDate( 1, 1, 1900 );
995 aOpt
.SetYear2000( 18 + 1901 ); // ab SO51 src513e vierstellig
996 pDoc
->SetDocOptions( aOpt
);
997 pDoc
->GetFormatTable()->ChangeNullDate( 1, 1, 1900 );
999 LoadFileHeader(); pPrgrsBar
->Progress();
1000 if (!nError
) { LoadFileInfo(); pPrgrsBar
->Progress(); }
1001 if (!nError
) { LoadEditStateInfo(); pPrgrsBar
->Progress(); }
1002 if (!nError
) { LoadProtect(); pPrgrsBar
->Progress(); }
1003 if (!nError
) { LoadViewColRowBar(); pPrgrsBar
->Progress(); }
1004 if (!nError
) { LoadScrZoom(); pPrgrsBar
->Progress(); }
1005 if (!nError
) { LoadPalette(); pPrgrsBar
->Progress(); }
1006 if (!nError
) { LoadFontCollection(); pPrgrsBar
->Progress(); }
1007 if (!nError
) { LoadNameCollection(); pPrgrsBar
->Progress(); }
1008 if (!nError
) { LoadPatternCollection(); pPrgrsBar
->Progress(); }
1009 if (!nError
) { LoadDataBaseCollection(); pPrgrsBar
->Progress(); }
1010 if (!nError
) { LoadTables(); pPrgrsBar
->Progress(); }
1011 if (!nError
) { LoadObjects(); pPrgrsBar
->Progress(); }
1012 if (!nError
) { ImportNameCollection(); pPrgrsBar
->Progress(); }
1013 pDoc
->SetViewOptions( aSc30ViewOpt
);
1015 #if OSL_DEBUG_LEVEL > 0
1018 OSL_FAIL( OString::number(nError
).getStr());
1023 #if OSL_DEBUG_LEVEL > 0
1031 void Sc10Import::LoadFileHeader()
1033 Sc10FileHeader FileHeader
;
1034 lcl_ReadFileHeader(rStream
, FileHeader
);
1036 nError
= rStream
.GetError();
1039 sal_Char Sc10CopyRight
[32];
1040 strcpy(Sc10CopyRight
, "Blaise-Tabelle");
1041 Sc10CopyRight
[14] = 10;
1042 Sc10CopyRight
[15] = 13;
1043 Sc10CopyRight
[16] = 0;
1044 if ((strcmp(FileHeader
.CopyRight
, Sc10CopyRight
) != 0)
1045 || (FileHeader
.Version
< 101)
1046 || (FileHeader
.Version
> 102))
1047 nError
= errUnknownFormat
;
1052 void Sc10Import::LoadFileInfo()
1054 Sc10FileInfo FileInfo
;
1055 rStream
.Read(&FileInfo
, sizeof(FileInfo
));
1057 nError
= rStream
.GetError();
1058 // Achtung Info Uebertragen
1063 void Sc10Import::LoadEditStateInfo()
1065 Sc10EditStateInfo EditStateInfo
;
1066 rStream
.Read(&EditStateInfo
, sizeof(EditStateInfo
));
1068 nError
= rStream
.GetError();
1069 nShowTab
= static_cast<SCTAB
>(EditStateInfo
.DeltaZ
);
1070 // Achtung Cursorposition und Offset der Tabelle Uebertragen (soll man das machen??)
1074 void Sc10Import::LoadProtect()
1076 lcl_ReadSheetProtect(rStream
, SheetProtect
);
1077 nError
= rStream
.GetError();
1079 ScDocProtection aProtection
;
1080 aProtection
.setProtected(static_cast<bool>(SheetProtect
.Protect
));
1081 aProtection
.setPassword(SC10TOSTRING(SheetProtect
.PassWord
));
1082 pDoc
->SetDocProtection(&aProtection
);
1086 void Sc10Import::LoadViewColRowBar()
1088 sal_uInt8 ViewColRowBar
;
1089 rStream
>> ViewColRowBar
;
1090 nError
= rStream
.GetError();
1091 aSc30ViewOpt
.SetOption( VOPT_HEADER
, (sal_Bool
)ViewColRowBar
);
1095 void Sc10Import::LoadScrZoom()
1097 // Achtung Zoom ist leider eine 6Byte TP real Zahl (keine Ahnung wie die Umzusetzen ist)
1099 rStream
.Read(cZoom
, sizeof(cZoom
));
1100 nError
= rStream
.GetError();
1104 void Sc10Import::LoadPalette()
1106 lcl_ReadPalette(rStream
, TextPalette
);
1107 lcl_ReadPalette(rStream
, BackPalette
);
1108 lcl_ReadPalette(rStream
, RasterPalette
);
1109 lcl_ReadPalette(rStream
, FramePalette
);
1111 nError
= rStream
.GetError();
1115 void Sc10Import::LoadFontCollection()
1117 pFontCollection
= new Sc10FontCollection(rStream
);
1119 nError
= pFontCollection
->GetError();
1123 void Sc10Import::LoadNameCollection()
1125 pNameCollection
= new Sc10NameCollection(rStream
);
1127 nError
= pNameCollection
->GetError();
1131 void Sc10Import::ImportNameCollection()
1133 ScRangeName
* pRN
= pDoc
->GetRangeName();
1135 for (sal_uInt16 i
= 0; i
< pNameCollection
->GetCount(); i
++)
1137 Sc10NameData
* pName
= pNameCollection
->At( i
);
1140 pDoc
, SC10TOSTRING(pName
->Name
), SC10TOSTRING(pName
->Reference
)));
1145 void Sc10Import::LoadPatternCollection()
1147 pPatternCollection
= new Sc10PatternCollection( rStream
);
1149 nError
= pPatternCollection
->GetError();
1150 if (nError
== errOutOfMemory
)
1152 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
1153 for( sal_uInt16 i
= 0 ; i
< pPatternCollection
->GetCount() ; i
++ )
1155 Sc10PatternData
* pPattern
= pPatternCollection
->At( i
);
1156 String
aName( pPattern
->Name
, DEFCHARSET
);
1157 SfxStyleSheetBase
* pStyle
= pStylePool
->Find( aName
, SFX_STYLE_FAMILY_PARA
);
1158 if( pStyle
== NULL
)
1159 pStylePool
->Make( aName
, SFX_STYLE_FAMILY_PARA
);
1162 pPattern
->Name
[ 27 ] = 0;
1163 strcat( pPattern
->Name
, "_Old" );
1164 aName
= SC10TOSTRING( pPattern
->Name
);
1165 pStylePool
->Make( aName
, SFX_STYLE_FAMILY_PARA
);
1167 pStyle
= pStylePool
->Find( aName
, SFX_STYLE_FAMILY_PARA
);
1168 if( pStyle
!= NULL
)
1170 SfxItemSet
&rItemSet
= pStyle
->GetItemSet();
1172 if( ( pPattern
->FormatFlags
& pfFont
) == pfFont
)
1174 FontFamily eFam
= FAMILY_DONTKNOW
;
1175 switch( pPattern
->LogFont
.lfPitchAndFamily
& 0xF0 )
1177 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
1178 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
1179 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
1180 case ffModern
: eFam
= FAMILY_MODERN
; break;
1181 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
1182 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
1183 default: eFam
= FAMILY_DONTKNOW
; break;
1185 rItemSet
.Put( SvxFontItem( eFam
, SC10TOSTRING( pPattern
->LogFont
.lfFaceName
), EMPTY_STRING
,
1186 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
) );
1187 rItemSet
.Put( SvxFontHeightItem( std::abs( pPattern
->LogFont
.lfHeight
), 100, ATTR_FONT_HEIGHT
) );
1188 Color
TextColor( COL_BLACK
);
1189 lcl_ChangeColor( ( pPattern
->nColor
& 0x000F ), TextColor
);
1190 rItemSet
.Put( SvxColorItem( TextColor
, ATTR_FONT_COLOR
) );
1192 if( pPattern
->LogFont
.lfWeight
!= fwNormal
)
1193 rItemSet
.Put( SvxWeightItem( WEIGHT_BOLD
, ATTR_FONT_WEIGHT
) );
1194 if( pPattern
->LogFont
.lfItalic
!= 0 )
1195 rItemSet
.Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
1196 if( pPattern
->LogFont
.lfUnderline
!= 0 )
1197 rItemSet
.Put( SvxUnderlineItem( UNDERLINE_SINGLE
, ATTR_FONT_UNDERLINE
) );
1198 if( pPattern
->LogFont
.lfStrikeOut
!= 0 )
1199 rItemSet
.Put( SvxCrossedOutItem( STRIKEOUT_SINGLE
, ATTR_FONT_CROSSEDOUT
) );
1202 if( ( pPattern
->FormatFlags
& pfJustify
) == pfJustify
)
1204 sal_uInt16 HorJustify
= ( pPattern
->Justify
& 0x000F );
1205 sal_uInt16 VerJustify
= ( pPattern
->Justify
& 0x00F0 ) >> 4;
1206 sal_uInt16 OJustify
= ( pPattern
->Justify
& 0x0F00 ) >> 8;
1207 sal_uInt16 EJustify
= ( pPattern
->Justify
& 0xF000 ) >> 12;
1208 if( HorJustify
!= 0 )
1209 switch( HorJustify
)
1212 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT
, ATTR_HOR_JUSTIFY
) );
1215 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
) );
1218 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT
, ATTR_HOR_JUSTIFY
) );
1221 if( VerJustify
!= 0 )
1222 switch( VerJustify
)
1225 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_TOP
, ATTR_VER_JUSTIFY
) );
1228 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER
, ATTR_VER_JUSTIFY
) );
1231 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_BOTTOM
, ATTR_VER_JUSTIFY
) );
1235 if( ( OJustify
& ojWordBreak
) == ojWordBreak
)
1236 rItemSet
.Put( SfxBoolItem( sal_True
) );
1237 if( ( OJustify
& ojBottomTop
) == ojBottomTop
)
1238 rItemSet
.Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 9000 ) );
1239 else if( ( OJustify
& ojTopBottom
) == ojTopBottom
)
1240 rItemSet
.Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 27000 ) );
1242 sal_Int16 Margin
= std::max( ( sal_uInt16
) 20, ( sal_uInt16
) ( EJustify
* 20 ) );
1243 if( ( ( OJustify
& ojBottomTop
) == ojBottomTop
) )
1244 rItemSet
.Put( SvxMarginItem( 20, Margin
, 20, Margin
, ATTR_MARGIN
) );
1246 rItemSet
.Put( SvxMarginItem( Margin
, 20, Margin
, 20, ATTR_MARGIN
) );
1250 if( ( pPattern
->FormatFlags
& pfFrame
) == pfFrame
)
1252 if( pPattern
->Frame
!= 0 )
1254 sal_uInt16 nLeft
= 0;
1255 sal_uInt16 nTop
= 0;
1256 sal_uInt16 nRight
= 0;
1257 sal_uInt16 nBottom
= 0;
1258 sal_uInt16 fLeft
= ( pPattern
->Frame
& 0x000F );
1259 sal_uInt16 fTop
= ( pPattern
->Frame
& 0x00F0 ) / 0x0010;
1260 sal_uInt16 fRight
= ( pPattern
->Frame
& 0x0F00 ) / 0x0100;
1261 sal_uInt16 fBottom
= ( pPattern
->Frame
& 0xF000 ) / 0x1000;
1265 else if( fLeft
> 0 )
1275 else if( fRight
> 0 )
1280 else if( fBottom
> 0 )
1283 Color
ColorLeft( COL_BLACK
);
1284 Color
ColorTop( COL_BLACK
);
1285 Color
ColorRight( COL_BLACK
);
1286 Color
ColorBottom( COL_BLACK
);
1288 sal_uInt16 cLeft
= ( pPattern
->FrameColor
& 0x000F );
1289 sal_uInt16 cTop
= ( pPattern
->FrameColor
& 0x00F0 ) >> 4;
1290 sal_uInt16 cRight
= ( pPattern
->FrameColor
& 0x0F00 ) >> 8;
1291 sal_uInt16 cBottom
= ( pPattern
->FrameColor
& 0xF000 ) >> 12;
1293 lcl_ChangeColor( cLeft
, ColorLeft
);
1294 lcl_ChangeColor( cTop
, ColorTop
);
1295 lcl_ChangeColor( cRight
, ColorRight
);
1296 lcl_ChangeColor( cBottom
, ColorBottom
);
1298 ::editeng::SvxBorderLine aLine
;
1299 SvxBoxItem
aBox( ATTR_BORDER
);
1301 aLine
.SetWidth( nLeft
);
1302 aLine
.SetColor( ColorLeft
);
1303 aBox
.SetLine( &aLine
, BOX_LINE_LEFT
);
1304 aLine
.SetWidth( nTop
);
1305 aLine
.SetColor( ColorTop
);
1306 aBox
.SetLine( &aLine
, BOX_LINE_TOP
);
1307 aLine
.SetWidth( nRight
);
1308 aLine
.SetColor( ColorRight
);
1309 aBox
.SetLine( &aLine
, BOX_LINE_RIGHT
);
1310 aLine
.SetWidth( nBottom
);
1311 aLine
.SetColor( ColorBottom
);
1312 aBox
.SetLine( &aLine
, BOX_LINE_BOTTOM
);
1313 rItemSet
.Put( aBox
);
1317 if( ( pPattern
->FormatFlags
& pfRaster
) == pfRaster
)
1319 if( pPattern
->Raster
!= 0 )
1321 sal_uInt16 nBColor
= ( pPattern
->nColor
& 0x00F0 ) >> 4;
1322 sal_uInt16 nRColor
= ( pPattern
->nColor
& 0x0F00 ) >> 8;
1323 Color
aBColor( COL_BLACK
);
1325 lcl_ChangeColor( nBColor
, aBColor
);
1328 aBColor
.SetColor( COL_WHITE
);
1329 else if( nBColor
== 15 )
1330 aBColor
.SetColor( COL_BLACK
);
1332 Color
aRColor( COL_BLACK
);
1333 lcl_ChangeColor( nRColor
, aRColor
);
1335 sal_Bool bSwapCol
= false;
1336 sal_Bool bSetItem
= sal_True
;
1337 switch (pPattern
->Raster
)
1339 case raNone
: nFact
= 0xffff; bSwapCol
= sal_True
; bSetItem
= (nBColor
> 0); break;
1340 case raGray12
: nFact
= (0xffff / 100) * 12; break;
1341 case raGray25
: nFact
= (0xffff / 100) * 25; break;
1342 case raGray50
: nFact
= (0xffff / 100) * 50; break;
1343 case raGray75
: nFact
= (0xffff / 100) * 75; break;
1344 default: nFact
= 0xffff; bSetItem
= (nRColor
< 15);
1349 rItemSet
.Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
1351 rItemSet
.Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
1356 if( ( pPattern
->ValueFormat
.Format
!= 0 ) &&
1357 ( ( pPattern
->FormatFlags
& pfValue
) == pfValue
) )
1360 ChangeFormat( pPattern
->ValueFormat
.Format
, pPattern
->ValueFormat
.Info
, nKey
);
1361 rItemSet
.Put( SfxUInt32Item( ATTR_VALUE_FORMAT
, ( sal_uInt32
) nKey
) );
1364 // Zellattribute (Schutz, Versteckt...)
1365 if( ( pPattern
->Flags
!= 0 ) &&
1366 ( ( pPattern
->FormatFlags
& pfProtection
) == pfProtection
) )
1368 sal_Bool bProtect
= ( ( pPattern
->Flags
& paProtect
) == paProtect
);
1369 sal_Bool bHFormula
= ( ( pPattern
->Flags
& paHideFormula
) == paHideFormula
);
1370 sal_Bool bHCell
= ( ( pPattern
->Flags
& paHideAll
) == paHideAll
);
1371 sal_Bool bHPrint
= ( ( pPattern
->Flags
& paHidePrint
) == paHidePrint
);
1372 rItemSet
.Put( ScProtectionAttr( bProtect
, bHFormula
, bHCell
, bHPrint
) );
1375 } // for (i = 0; i < GetCount()
1379 void Sc10Import::LoadDataBaseCollection()
1381 pDataBaseCollection
= new Sc10DataBaseCollection(rStream
);
1383 nError
= pDataBaseCollection
->GetError();
1384 if (nError
== errOutOfMemory
)
1386 for( sal_uInt16 i
= 0 ; i
< pDataBaseCollection
->GetCount() ; i
++ )
1388 Sc10DataBaseData
* pOldData
= pDataBaseCollection
->At(i
);
1389 ScDBData
* pNewData
= new ScDBData( SC10TOSTRING( pOldData
->DataBaseRec
.Name
),
1390 ( SCTAB
) pOldData
->DataBaseRec
.Tab
,
1391 ( SCCOL
) pOldData
->DataBaseRec
.Block
.x1
,
1392 ( SCROW
) pOldData
->DataBaseRec
.Block
.y1
,
1393 ( SCCOL
) pOldData
->DataBaseRec
.Block
.x2
,
1394 ( SCROW
) pOldData
->DataBaseRec
.Block
.y2
,
1396 ( sal_Bool
) pOldData
->DataBaseRec
.RowHeader
);
1397 pDoc
->GetDBCollection()->getNamedDBs().insert(pNewData
);
1402 void Sc10Import::LoadTables()
1404 Sc10PageCollection aPageCollection
;
1406 sal_Int16 nTabCount
;
1407 rStream
>> nTabCount
;
1408 for (sal_Int16 Tab
= 0; (Tab
< nTabCount
) && (nError
== 0); Tab
++)
1410 Sc10PageFormat PageFormat
;
1411 sal_Int16 DataBaseIndex
;
1412 Sc10TableProtect TabProtect
;
1414 sal_Char TabName
[128];
1418 sal_uInt16 DataCount
;
1419 sal_uInt16 DataStart
;
1421 sal_uInt16 DataValue
;
1425 lcl_ReadPageFormat(rStream
, PageFormat
);
1427 sal_uInt16 nAt
= aPageCollection
.InsertFormat(PageFormat
);
1428 String aPageName
= lcl_MakeOldPageStyleFormatName( nAt
);
1430 pPrgrsBar
->Progress();
1432 rStream
>> DataBaseIndex
;
1434 lcl_ReadTabProtect(rStream
, TabProtect
);
1436 ScTableProtection aProtection
;
1437 aProtection
.setProtected(static_cast<bool>(TabProtect
.Protect
));
1438 aProtection
.setPassword(SC10TOSTRING(TabProtect
.PassWord
));
1439 pDoc
->SetTabProtection(static_cast<SCTAB
>(Tab
), &aProtection
);
1445 rStream
.Read(TabName
, sizeof(TabName
) - 1);
1446 if (nLen
>= sizeof(TabName
))
1447 nLen
= sizeof(TabName
) - 1;
1450 //----------------------------------------------------------
1453 if ( Tab
== (sal_Int16
)nShowTab
)
1455 ScVObjMode eObjMode
= VOBJ_MODE_SHOW
;
1457 aSc30ViewOpt
.SetOption( VOPT_FORMULAS
, IS_SET(dfFormula
,Display
) );
1458 aSc30ViewOpt
.SetOption( VOPT_NULLVALS
, IS_SET(dfZerro
,Display
) );
1459 aSc30ViewOpt
.SetOption( VOPT_SYNTAX
, IS_SET(dfSyntax
,Display
) );
1460 aSc30ViewOpt
.SetOption( VOPT_NOTES
, IS_SET(dfNoteMark
,Display
) );
1461 aSc30ViewOpt
.SetOption( VOPT_VSCROLL
, sal_True
);
1462 aSc30ViewOpt
.SetOption( VOPT_HSCROLL
, sal_True
);
1463 aSc30ViewOpt
.SetOption( VOPT_TABCONTROLS
, sal_True
);
1464 aSc30ViewOpt
.SetOption( VOPT_OUTLINER
, sal_True
);
1465 aSc30ViewOpt
.SetOption( VOPT_GRID
, IS_SET(dfGrid
,Display
) );
1467 // VOPT_HEADER wird in LoadViewColRowBar() gesetzt
1469 if ( IS_SET(dfObjectAll
,Display
) ) // Objekte anzeigen
1470 eObjMode
= VOBJ_MODE_SHOW
;
1471 else if ( IS_SET(dfObjectFrame
,Display
) ) // Objekte als Platzhalter
1472 eObjMode
= VOBJ_MODE_SHOW
;
1473 else if ( IS_SET(dfObjectNone
,Display
) ) // Objekte nicht anzeigen
1474 eObjMode
= VOBJ_MODE_HIDE
;
1476 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_OLE
, eObjMode
);
1477 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_CHART
, eObjMode
);
1478 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_DRAW
, eObjMode
);
1481 //--------------------------------------------------------------------
1484 nError
= rStream
.GetError();
1485 if (nError
!= 0) return;
1488 pDoc
->RenameTab(static_cast<SCTAB
> (TabNo
), SC10TOSTRING( TabName
), false);
1490 pDoc
->InsertTab(SC_TAB_APPEND
, SC10TOSTRING( TabName
) );
1492 pDoc
->SetPageStyle( static_cast<SCTAB
>(Tab
), aPageName
);
1494 if (Visible
== 0) pDoc
->SetVisible(static_cast<SCTAB
> (TabNo
), false);
1498 if (ID
!= ColWidthID
)
1500 OSL_FAIL( "ColWidthID" );
1501 nError
= errUnknownID
;
1504 rStream
>> DataCount
;
1506 for (i
=0; i
< DataCount
; i
++)
1509 rStream
>> DataValue
;
1510 for (SCCOL j
= static_cast<SCCOL
>(DataStart
); j
<= static_cast<SCCOL
>(DataEnd
); j
++) pDoc
->SetColWidth(j
, static_cast<SCTAB
> (TabNo
), DataValue
);
1511 DataStart
= DataEnd
+ 1;
1513 pPrgrsBar
->Progress();
1517 if (ID
!= ColAttrID
)
1519 OSL_FAIL( "ColAttrID" );
1520 nError
= errUnknownID
;
1524 rStream
>> DataCount
;
1526 for (i
=0; i
< DataCount
; i
++)
1529 rStream
>> DataValue
;
1532 bool bPageBreak
= ((DataValue
& crfSoftBreak
) == crfSoftBreak
);
1533 bool bManualBreak
= ((DataValue
& crfHardBreak
) == crfHardBreak
);
1534 bool bHidden
= ((DataValue
& crfHidden
) == crfHidden
);
1535 for (SCCOL k
= static_cast<SCCOL
>(DataStart
); k
<= static_cast<SCCOL
>(DataEnd
); k
++)
1537 pDoc
->SetColHidden(k
, k
, static_cast<SCTAB
>(TabNo
), bHidden
);
1538 pDoc
->SetColBreak(k
, static_cast<SCTAB
> (TabNo
), bPageBreak
, bManualBreak
);
1541 DataStart
= DataEnd
+ 1;
1543 pPrgrsBar
->Progress();
1547 if (ID
!= RowHeightID
)
1549 OSL_FAIL( "RowHeightID" );
1550 nError
= errUnknownID
;
1554 rStream
>> DataCount
;
1556 for (i
=0; i
< DataCount
; i
++)
1559 rStream
>> DataValue
;
1560 pDoc
->SetRowHeightRange(static_cast<SCROW
> (DataStart
), static_cast<SCROW
> (DataEnd
), static_cast<SCTAB
> (TabNo
), DataValue
);
1561 DataStart
= DataEnd
+ 1;
1563 pPrgrsBar
->Progress();
1567 if (ID
!= RowAttrID
)
1569 OSL_FAIL( "RowAttrID" );
1570 nError
= errUnknownID
;
1574 rStream
>> DataCount
;
1576 for (i
=0; i
< DataCount
; i
++)
1579 rStream
>> DataValue
;
1582 bool bPageBreak
= ((DataValue
& crfSoftBreak
) == crfSoftBreak
);
1583 bool bManualBreak
= ((DataValue
& crfHardBreak
) == crfHardBreak
);
1584 bool bHidden
= ((DataValue
& crfHidden
) == crfHidden
);
1585 for (SCROW l
= static_cast<SCROW
>(DataStart
); l
<= static_cast<SCROW
>(DataEnd
); l
++)
1587 pDoc
->SetRowHidden(l
, l
, static_cast<SCTAB
> (TabNo
), bHidden
);
1588 pDoc
->SetRowBreak(l
, static_cast<SCTAB
> (TabNo
), bPageBreak
, bManualBreak
);
1591 DataStart
= DataEnd
+ 1;
1593 pPrgrsBar
->Progress();
1599 OSL_FAIL( "TableID" );
1600 nError
= errUnknownID
;
1603 for (SCCOL Col
= 0; (Col
<= SC10MAXCOL
) && (nError
== 0); Col
++)
1606 nError
= rStream
.GetError();
1607 if ((Count
!= 0) && (nError
== 0))
1608 LoadCol(Col
, static_cast<SCTAB
> (TabNo
));
1610 OSL_ENSURE( nError
== 0, "Stream" );
1612 pPrgrsBar
->Progress();
1614 aPageCollection
.PutToDoc( pDoc
);
1618 void Sc10Import::LoadCol(SCCOL Col
, SCTAB Tab
)
1620 LoadColAttr(Col
, Tab
);
1622 sal_uInt16 CellCount
;
1625 rStream
>> CellCount
;
1626 SCROW nScCount
= static_cast< SCROW
>( CellCount
);
1627 if (nScCount
> MAXROW
) nError
= errUnknownFormat
;
1628 for (sal_uInt16 i
= 0; (i
< CellCount
) && (nError
== 0); i
++)
1630 rStream
>> CellType
;
1632 nError
= rStream
.GetError();
1639 const SfxPoolItem
* pValueFormat
= pDoc
->GetAttr(Col
, static_cast<SCROW
> (Row
), Tab
, ATTR_VALUE_FORMAT
);
1640 sal_uLong nFormat
= ((SfxUInt32Item
*)pValueFormat
)->GetValue();
1641 double Value
= ScfTools::ReadLongDouble(rStream
);
1642 //rStream.Read(&Value, sizeof(Value));
1644 // Achtung hier ist eine Anpassung Notwendig wenn Ihr das Basisdatum aendert
1645 // In StarCalc 1.0 entspricht 0 dem 01.01.1900
1646 // if ((nFormat >= 30) && (nFormat <= 35))
1648 if ((nFormat
>= 40) && (nFormat
<= 45))
1650 pDoc
->SetValue(Col
, static_cast<SCROW
> (Row
), Tab
, Value
);
1658 rStream
.Read(s
, Len
);
1661 pDoc
->SetString( Col
, static_cast<SCROW
> (Row
), Tab
, SC10TOSTRING( s
) );
1666 /*double Value =*/ ScfTools::ReadLongDouble(rStream
);
1670 rStream
.Read(&s
[1], Len
);
1673 ScFormulaCell
* pCell
= new ScFormulaCell( pDoc
, ScAddress( Col
, static_cast<SCROW
> (Row
), Tab
) );
1674 pCell
->SetHybridFormula( SC10TOSTRING( s
),formula::FormulaGrammar::GRAM_NATIVE
);
1675 pDoc
->EnsureTable(Tab
);
1676 pDoc
->SetFormulaCell(ScAddress(Col
,Row
,Tab
), pCell
);
1682 nError
= errUnknownFormat
;
1689 sal_Char
* pNote
= new sal_Char
[NoteLen
+1];
1690 rStream
.Read(pNote
, NoteLen
);
1692 String
aNoteText( SC10TOSTRING(pNote
));
1694 ScAddress
aPos( Col
, static_cast<SCROW
>(Row
), Tab
);
1695 ScNoteUtil::CreateNoteFromString( *pDoc
, aPos
, aNoteText
, false, false );
1698 pPrgrsBar
->Progress();
1703 void Sc10Import::LoadColAttr(SCCOL Col
, SCTAB Tab
)
1707 Sc10ColAttr aJustify
;
1709 Sc10ColAttr aRaster
;
1712 Sc10ColAttr aFrameColor
;
1714 Sc10ColAttr aPattern
;
1716 if (nError
== 0) LoadAttr(aFont
);
1717 if (nError
== 0) LoadAttr(aAttr
);
1718 if (nError
== 0) LoadAttr(aJustify
);
1719 if (nError
== 0) LoadAttr(aFrame
);
1720 if (nError
== 0) LoadAttr(aRaster
);
1721 if (nError
== 0) LoadAttr(aValue
);
1722 if (nError
== 0) LoadAttr(aColor
);
1723 if (nError
== 0) LoadAttr(aFrameColor
);
1724 if (nError
== 0) LoadAttr(aFlag
);
1725 if (nError
== 0) LoadAttr(aPattern
);
1734 Sc10ColData
*pColData
;
1736 // Font (Name, Size)
1739 nLimit
= aFont
.Count
;
1740 pColData
= aFont
.pData
;
1741 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1743 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1744 if ((nStart
<= nEnd
) && (pColData
->Value
))
1746 FontFamily eFam
= FAMILY_DONTKNOW
;
1747 Sc10FontData
* pFont
= pFontCollection
->At(pColData
->Value
);
1750 switch (pFont
->PitchAndFamily
& 0xF0)
1752 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
1753 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
1754 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
1755 case ffModern
: eFam
= FAMILY_MODERN
; break;
1756 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
1757 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
1758 default: eFam
= FAMILY_DONTKNOW
; break;
1760 ScPatternAttr
aScPattern(pDoc
->GetPool());
1761 aScPattern
.GetItemSet().Put(SvxFontItem(eFam
, SC10TOSTRING( pFont
->FaceName
), EMPTY_STRING
,
1762 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
));
1763 aScPattern
.GetItemSet().Put(SvxFontHeightItem(std::abs(pFont
->Height
), 100, ATTR_FONT_HEIGHT
));
1764 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1773 nLimit
= aColor
.Count
;
1774 pColData
= aColor
.pData
;
1775 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1777 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1778 if ((nStart
<= nEnd
) && (pColData
->Value
))
1780 Color
TextColor(COL_BLACK
);
1781 lcl_ChangeColor((pColData
->Value
& 0x000F), TextColor
);
1782 ScPatternAttr
aScPattern(pDoc
->GetPool());
1783 aScPattern
.GetItemSet().Put(SvxColorItem(TextColor
, ATTR_FONT_COLOR
));
1784 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1789 // Font attributes (Bold, Italic...)
1792 nLimit
= aAttr
.Count
;
1793 pColData
= aAttr
.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 if ((nValue1
& atBold
) == atBold
)
1802 aScPattern
.GetItemSet().Put(SvxWeightItem(WEIGHT_BOLD
, ATTR_FONT_WEIGHT
));
1803 if ((nValue1
& atItalic
) == atItalic
)
1804 aScPattern
.GetItemSet().Put(SvxPostureItem(ITALIC_NORMAL
, ATTR_FONT_POSTURE
));
1805 if ((nValue1
& atUnderline
) == atUnderline
)
1806 aScPattern
.GetItemSet().Put(SvxUnderlineItem(UNDERLINE_SINGLE
, ATTR_FONT_UNDERLINE
));
1807 if ((nValue1
& atStrikeOut
) == atStrikeOut
)
1808 aScPattern
.GetItemSet().Put(SvxCrossedOutItem(STRIKEOUT_SINGLE
, ATTR_FONT_CROSSEDOUT
));
1809 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1817 nLimit
= aJustify
.Count
;
1818 pColData
= aJustify
.pData
;
1819 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1821 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1822 nValue1
= pColData
->Value
;
1823 if ((nStart
<= nEnd
) && (nValue1
))
1825 ScPatternAttr
aScPattern(pDoc
->GetPool());
1826 sal_uInt16 HorJustify
= (nValue1
& 0x000F);
1827 sal_uInt16 VerJustify
= (nValue1
& 0x00F0) >> 4;
1828 sal_uInt16 OJustify
= (nValue1
& 0x0F00) >> 8;
1829 sal_uInt16 EJustify
= (nValue1
& 0xF000) >> 12;
1834 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_LEFT
, ATTR_HOR_JUSTIFY
));
1837 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
));
1840 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT
, ATTR_HOR_JUSTIFY
));
1847 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_TOP
, ATTR_VER_JUSTIFY
));
1850 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_CENTER
, ATTR_VER_JUSTIFY
));
1853 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_BOTTOM
, ATTR_VER_JUSTIFY
));
1857 if (OJustify
& ojWordBreak
)
1858 aScPattern
.GetItemSet().Put(SfxBoolItem(sal_True
));
1859 if (OJustify
& ojBottomTop
)
1860 aScPattern
.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE
,9000));
1861 else if (OJustify
& ojTopBottom
)
1862 aScPattern
.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE
,27000));
1864 sal_Int16 Margin
= std::max((sal_uInt16
)20, (sal_uInt16
)(EJustify
* 20));
1865 if (OJustify
& ojBottomTop
)
1866 aScPattern
.GetItemSet().Put(SvxMarginItem(20, Margin
, 20, Margin
, ATTR_MARGIN
));
1868 aScPattern
.GetItemSet().Put(SvxMarginItem(Margin
, 20, Margin
, 20, ATTR_MARGIN
));
1869 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1874 sal_Bool bEnd
= false;
1875 sal_uInt16 nColorIndex
= 0;
1876 sal_uInt16 nFrameIndex
= 0;
1879 const sal_uInt32 nHelpMeStart
= 100;
1880 sal_uInt32 nHelpMe
= nHelpMeStart
;
1881 sal_uInt16 nColorIndexOld
= nColorIndex
;
1882 sal_uInt16 nFrameIndexOld
= nColorIndex
;
1886 while( !bEnd
&& nHelpMe
)
1888 pColData
= &aFrame
.pData
[ nFrameIndex
];
1890 sal_uInt16 nValue
= pColData
->Value
;
1891 sal_uInt16 nLeft
= 0;
1892 sal_uInt16 nTop
= 0;
1893 sal_uInt16 nRight
= 0;
1894 sal_uInt16 nBottom
= 0;
1895 sal_uInt16 fLeft
= ( nValue
& 0x000F );
1896 sal_uInt16 fTop
= ( nValue
& 0x00F0 ) >> 4;
1897 sal_uInt16 fRight
= ( nValue
& 0x0F00 ) >> 8;
1898 sal_uInt16 fBottom
= ( nValue
& 0xF000 ) >> 12;
1902 else if( fLeft
> 0 )
1912 else if( fRight
> 0 )
1917 else if( fBottom
> 0 )
1920 Color
ColorLeft( COL_BLACK
);
1921 Color
ColorTop( COL_BLACK
);
1922 Color
ColorRight( COL_BLACK
);
1923 Color
ColorBottom( COL_BLACK
);
1924 sal_uInt16 nFrmColVal
= aFrameColor
.pData
[ nColorIndex
].Value
;
1925 SCROW nFrmColRow
= static_cast<SCROW
>(aFrameColor
.pData
[ nColorIndex
].Row
);
1926 sal_uInt16 cLeft
= ( nFrmColVal
& 0x000F );
1927 sal_uInt16 cTop
= ( nFrmColVal
& 0x00F0 ) >> 4;
1928 sal_uInt16 cRight
= ( nFrmColVal
& 0x0F00 ) >> 8;
1929 sal_uInt16 cBottom
= ( nFrmColVal
& 0xF000 ) >> 12;
1931 lcl_ChangeColor( cLeft
, ColorLeft
);
1932 lcl_ChangeColor( cTop
, ColorTop
);
1933 lcl_ChangeColor( cRight
, ColorRight
);
1934 lcl_ChangeColor( cBottom
, ColorBottom
);
1936 if( static_cast<SCROW
>(pColData
->Row
) < nFrmColRow
)
1938 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1939 if( nFrameIndex
< ( aFrame
.Count
- 1 ) )
1942 else if( static_cast<SCROW
>(pColData
->Row
) > nFrmColRow
)
1944 nEnd
= static_cast<SCROW
>(aFrameColor
.pData
[ nColorIndex
].Row
);
1945 if( nColorIndex
< ( aFrameColor
.Count
- 1 ) )
1951 if( nFrameIndex
< (aFrame
.Count
- 1 ) )
1953 if( nColorIndex
< ( aFrameColor
.Count
- 1 ) )
1956 if( ( nStart
<= nEnd
) && ( nValue
!= 0 ) )
1958 ScPatternAttr
aScPattern(pDoc
->GetPool());
1959 ::editeng::SvxBorderLine aLine
;
1960 SvxBoxItem
aBox( ATTR_BORDER
);
1962 aLine
.SetWidth( nLeft
);
1963 aLine
.SetColor( ColorLeft
);
1964 aBox
.SetLine( &aLine
, BOX_LINE_LEFT
);
1966 aLine
.SetWidth( nTop
);
1967 aLine
.SetColor( ColorTop
);
1968 aBox
.SetLine( &aLine
, BOX_LINE_TOP
);
1970 aLine
.SetWidth( nRight
);
1971 aLine
.SetColor( ColorRight
);
1972 aBox
.SetLine( &aLine
, BOX_LINE_RIGHT
);
1974 aLine
.SetWidth( nBottom
);
1975 aLine
.SetColor( ColorBottom
);
1976 aBox
.SetLine( &aLine
, BOX_LINE_BOTTOM
);
1978 aScPattern
.GetItemSet().Put( aBox
);
1979 pDoc
->ApplyPatternAreaTab( Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1983 bEnd
= ( nFrameIndex
== ( aFrame
.Count
- 1 ) ) && ( nColorIndex
== ( aFrameColor
.Count
- 1 ) );
1985 if( nColorIndexOld
!= nColorIndex
|| nFrameIndexOld
!= nFrameIndex
)
1987 nColorIndexOld
= nColorIndex
;
1988 nFrameIndexOld
= nFrameIndex
;
1989 nHelpMe
= nHelpMeStart
;
1997 // ATTENTION: Code up to here works more or less ... from here I've had enough ! (GT)
1999 // Background (Color, Raster)
2000 sal_uInt16 nRasterIndex
= 0;
2007 nHelpMe
= nHelpMeStart
;
2008 sal_uInt16 nRasterIndexOld
= nRasterIndex
;
2010 while( !bEnd
&& nHelpMe
)
2012 sal_uInt16 nBColor
= ( aColor
.pData
[ nColorIndex
].Value
& 0x00F0 ) >> 4;
2013 sal_uInt16 nRColor
= ( aColor
.pData
[ nColorIndex
].Value
& 0x0F00 ) >> 8;
2014 Color
aBColor( COL_BLACK
);
2016 lcl_ChangeColor( nBColor
, aBColor
);
2019 aBColor
.SetColor( COL_WHITE
);
2020 else if( nBColor
== 15 )
2021 aBColor
.SetColor( COL_BLACK
);
2023 Color
aRColor( COL_BLACK
);
2025 lcl_ChangeColor( nRColor
, aRColor
);
2027 ScPatternAttr
aScPattern( pDoc
->GetPool() );
2030 sal_Bool bSwapCol
= false;
2031 sal_Bool bSetItem
= sal_True
;
2032 switch ( aRaster
.pData
[ nRasterIndex
].Value
)
2034 case raNone
: nFact
= 0xffff; bSwapCol
= sal_True
; bSetItem
= (nBColor
> 0); break;
2035 case raGray12
: nFact
= (0xffff / 100) * 12; break;
2036 case raGray25
: nFact
= (0xffff / 100) * 25; break;
2037 case raGray50
: nFact
= (0xffff / 100) * 50; break;
2038 case raGray75
: nFact
= (0xffff / 100) * 75; break;
2039 default: nFact
= 0xffff; bSetItem
= (nRColor
< 15);
2044 aScPattern
.GetItemSet().Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
2046 aScPattern
.GetItemSet().Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
2048 if( aRaster
.pData
[ nRasterIndex
].Row
< aColor
.pData
[ nColorIndex
].Row
)
2050 nEnd
= static_cast<SCROW
>(aRaster
.pData
[ nRasterIndex
].Row
);
2051 if( nRasterIndex
< ( aRaster
.Count
- 1 ) )
2054 else if( aRaster
.pData
[ nRasterIndex
].Row
> aColor
.pData
[ nColorIndex
].Row
)
2056 nEnd
= static_cast<SCROW
>(aColor
.pData
[ nColorIndex
].Row
);
2057 if( nColorIndex
< ( aColor
.Count
- 1 ) )
2062 nEnd
= static_cast<SCROW
>(aColor
.pData
[ nColorIndex
].Row
);
2063 if( nRasterIndex
< ( aRaster
.Count
- 1 ) )
2065 if( nColorIndex
< ( aColor
.Count
- 1 ) )
2068 if( nStart
<= nEnd
)
2069 pDoc
->ApplyPatternAreaTab( Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2073 bEnd
= ( nRasterIndex
== ( aRaster
.Count
- 1 ) ) && ( nColorIndex
== ( aColor
.Count
- 1 ) );
2075 if( nColorIndexOld
!= nColorIndex
|| nRasterIndexOld
!= nRasterIndex
)
2077 nColorIndexOld
= nColorIndex
;
2078 nRasterIndexOld
= nRasterIndex
;
2079 nHelpMe
= nHelpMeStart
;
2090 nLimit
= aValue
.Count
;
2091 pColData
= aValue
.pData
;
2092 for (i
=0; i
<nLimit
; i
++, pColData
++)
2094 nEnd
= static_cast<SCROW
>(pColData
->Row
);
2095 nValue1
= pColData
->Value
;
2096 if ((nStart
<= nEnd
) && (nValue1
))
2099 sal_uInt16 nFormat
= (nValue1
& 0x00FF);
2100 sal_uInt16 nInfo
= (nValue1
& 0xFF00) >> 8;
2101 ChangeFormat(nFormat
, nInfo
, nKey
);
2102 ScPatternAttr
aScPattern(pDoc
->GetPool());
2103 aScPattern
.GetItemSet().Put(SfxUInt32Item(ATTR_VALUE_FORMAT
, (sal_uInt32
)nKey
));
2104 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2109 // Cell attributes (Protected, hidden...)
2112 for (i
=0; i
<aFlag
.Count
; i
++)
2114 nEnd
= static_cast<SCROW
>(aFlag
.pData
[i
].Row
);
2115 if ((nStart
<= nEnd
) && (aFlag
.pData
[i
].Value
!= 0))
2117 sal_Bool bProtect
= ((aFlag
.pData
[i
].Value
& paProtect
) == paProtect
);
2118 sal_Bool bHFormula
= ((aFlag
.pData
[i
].Value
& paHideFormula
) == paHideFormula
);
2119 sal_Bool bHCell
= ((aFlag
.pData
[i
].Value
& paHideAll
) == paHideAll
);
2120 sal_Bool bHPrint
= ((aFlag
.pData
[i
].Value
& paHidePrint
) == paHidePrint
);
2121 ScPatternAttr
aScPattern(pDoc
->GetPool());
2122 aScPattern
.GetItemSet().Put(ScProtectionAttr(bProtect
, bHFormula
, bHCell
, bHPrint
));
2123 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2131 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
2132 for (i
=0; i
<aPattern
.Count
; i
++)
2134 nEnd
= static_cast<SCROW
>(aPattern
.pData
[i
].Row
);
2135 if ((nStart
<= nEnd
) && (aPattern
.pData
[i
].Value
!= 0))
2137 sal_uInt16 nPatternIndex
= (aPattern
.pData
[i
].Value
& 0x00FF) - 1;
2138 Sc10PatternData
* pPattern
= pPatternCollection
->At(nPatternIndex
);
2139 if (pPattern
!= NULL
)
2141 ScStyleSheet
* pStyle
= (ScStyleSheet
*) pStylePool
->Find(
2142 SC10TOSTRING( pPattern
->Name
), SFX_STYLE_FAMILY_PARA
);
2145 pDoc
->ApplyStyleAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, *pStyle
);
2154 void Sc10Import::LoadAttr(Sc10ColAttr
& rAttr
)
2156 // rAttr is not reused, otherwise we'd have to delete [] rAttr.pData;
2157 rStream
>> rAttr
.Count
;
2160 rAttr
.pData
= new (::std::nothrow
) Sc10ColData
[rAttr
.Count
];
2161 if (rAttr
.pData
!= NULL
)
2163 for (sal_uInt16 i
= 0; i
< rAttr
.Count
; i
++)
2165 rStream
>> rAttr
.pData
[i
].Row
;
2166 rStream
>> rAttr
.pData
[i
].Value
;
2168 nError
= rStream
.GetError();
2172 nError
= errOutOfMemory
;
2179 void Sc10Import::ChangeFormat(sal_uInt16 nFormat
, sal_uInt16 nInfo
, sal_uLong
& nKey
)
2181 // Achtung: Die Formate werden nur auf die StarCalc 3.0 internen Formate gemappt
2182 // Korrekterweise muessten zum Teil neue Formate erzeugt werden (sollte Stephan sich ansehen)
2212 // Achtung kein Aequivalent
2235 case df_NDMY_Short
:
2287 case vfStandardRed
:
2297 case vfThousendRed
:
2309 case vfExponentRed
:
2322 void Sc10Import::LoadObjects()
2326 if (rStream
.IsEof()) return;
2331 sal_Char Reserved
[32];
2332 rStream
.Read(Reserved
, sizeof(Reserved
));
2333 nError
= rStream
.GetError();
2334 if ((nAnz
> 0) && (nError
== 0))
2336 sal_uInt8 ObjectType
;
2337 Sc10GraphHeader GraphHeader
;
2338 sal_Bool IsOleObject
= false; // Achtung dies ist nur ein Notnagel
2339 for (sal_uInt16 i
= 0; (i
< nAnz
) && (nError
== 0) && !rStream
.IsEof() && !IsOleObject
; i
++)
2341 rStream
>> ObjectType
;
2342 lcl_ReadGraphHeader(rStream
, GraphHeader
);
2344 double nPPTX
= ScGlobal::nScreenPPTX
;
2345 double nPPTY
= ScGlobal::nScreenPPTY
;
2348 for (SCsCOL nX
=0; nX
<GraphHeader
.CarretX
; nX
++)
2349 nStartX
+= pDoc
->GetColWidth(nX
, static_cast<SCTAB
>(GraphHeader
.CarretZ
));
2350 nStartX
= (long) ( nStartX
* HMM_PER_TWIPS
);
2351 nStartX
+= (long) ( GraphHeader
.x
/ nPPTX
* HMM_PER_TWIPS
);
2352 long nSizeX
= (long) ( GraphHeader
.w
/ nPPTX
* HMM_PER_TWIPS
);
2353 long nStartY
= pDoc
->GetRowHeight( 0,
2354 static_cast<SCsROW
>(GraphHeader
.CarretY
) - 1,
2355 static_cast<SCTAB
>(GraphHeader
.CarretZ
));
2356 nStartY
= (long) ( nStartY
* HMM_PER_TWIPS
);
2357 nStartY
+= (long) ( GraphHeader
.y
/ nPPTY
* HMM_PER_TWIPS
);
2358 long nSizeY
= (long) ( GraphHeader
.h
/ nPPTY
* HMM_PER_TWIPS
);
2363 // Achtung hier muss sowas wie OleLoadFromStream passieren
2364 IsOleObject
= sal_True
;
2368 Sc10ImageHeader ImageHeader
;
2369 lcl_ReadImageHeaer(rStream
, ImageHeader
);
2371 // Achtung nun kommen die Daten (Bitmap oder Metafile)
2372 // Typ = 1 Device Dependend Bitmap DIB
2374 rStream
.SeekRel(ImageHeader
.Size
);
2376 if( ImageHeader
.Typ
!= 1 && ImageHeader
.Typ
!= 2 )
2377 nError
= errUnknownFormat
;
2382 Sc10ChartHeader ChartHeader
;
2383 Sc10ChartSheetData ChartSheetData
;
2384 Sc10ChartTypeData
* pTypeData
= new (::std::nothrow
) Sc10ChartTypeData
;
2386 nError
= errOutOfMemory
;
2389 lcl_ReadChartHeader(rStream
, ChartHeader
);
2391 //! altes Metafile verwenden ??
2392 rStream
.SeekRel(ChartHeader
.Size
);
2394 lcl_ReadChartSheetData(rStream
, ChartSheetData
);
2396 lcl_ReadChartTypeData(rStream
, *pTypeData
);
2398 Rectangle
aRect( Point(nStartX
,nStartY
), Size(nSizeX
,nSizeY
) );
2399 Sc10InsertObject::InsertChart( pDoc
, static_cast<SCTAB
>(GraphHeader
.CarretZ
), aRect
,
2400 static_cast<SCTAB
>(GraphHeader
.CarretZ
),
2401 ChartSheetData
.DataX1
, ChartSheetData
.DataY1
,
2402 ChartSheetData
.DataX2
, ChartSheetData
.DataY2
);
2409 nError
= errUnknownFormat
;
2412 nError
= rStream
.GetError();
2418 OSL_FAIL( "ObjectID" );
2419 nError
= errUnknownID
;
2423 //-----------------------------------------------------------------------------------------------
2425 FltError
ScFormatFilterPluginImpl::ScImportStarCalc10( SvStream
& rStream
, ScDocument
* pDocument
)
2427 rStream
.Seek( 0UL );
2428 Sc10Import
aImport( rStream
, pDocument
);
2429 return ( FltError
) aImport
.Import();
2434 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */