1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scflt.cxx,v $
10 * $Revision: 1.25.124.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include "scitems.hxx"
39 #include <svx/eeitem.hxx>
41 #include <svx/algitem.hxx>
42 #include <svx/boxitem.hxx>
43 #include <svx/brshitem.hxx>
44 #include <svx/colritem.hxx>
45 #include <svx/crsditem.hxx>
46 #include <svx/editdata.hxx>
47 #include <svx/editeng.hxx>
48 #include <svx/editobj.hxx>
49 #include <svx/fhgtitem.hxx>
50 #include <svx/fontitem.hxx>
51 #include <svx/lrspitem.hxx>
52 #include <svx/pageitem.hxx>
53 #include <svx/postitem.hxx>
54 #include <svx/sizeitem.hxx>
55 #include <svx/udlnitem.hxx>
56 #include <svx/ulspitem.hxx>
57 #include <svx/wghtitem.hxx>
58 #include <svtools/zforlist.hxx>
59 #include <svtools/PasswordHelper.hxx>
67 #include "patattr.hxx"
68 #include "docpool.hxx"
69 #include "document.hxx"
70 #include "collect.hxx"
71 #include "rangenam.hxx"
72 #include "dbcolect.hxx"
73 #include "stlsheet.hxx"
74 #include "stlpool.hxx"
79 #include "docoptio.hxx"
80 #include "viewopti.hxx"
82 #include "globstr.hrc"
84 #include "tabprotection.hxx"
86 #include "fprogressbar.hxx"
88 using namespace com::sun::star
;
90 #define DEFCHARSET RTL_TEXTENCODING_MS_1252
92 #define SC10TOSTRING(p) String(p,DEFCHARSET)
94 const SCCOL SC10MAXCOL
= 255; // #i85906# don't try to load more columns than there are in the file
97 void lcl_ReadFileHeader(SvStream
& rStream
, Sc10FileHeader
& rFileHeader
)
99 rStream
.Read(&rFileHeader
.CopyRight
, sizeof(rFileHeader
.CopyRight
));
100 rStream
>> rFileHeader
.Version
;
101 rStream
.Read(&rFileHeader
.Reserved
, sizeof(rFileHeader
.Reserved
));
105 void lcl_ReadTabProtect(SvStream
& rStream
, Sc10TableProtect
& rProtect
)
107 rStream
.Read(&rProtect
.PassWord
, sizeof(rProtect
.PassWord
));
108 rStream
>> rProtect
.Flags
;
109 rStream
>> rProtect
.Protect
;
113 void lcl_ReadSheetProtect(SvStream
& rStream
, Sc10SheetProtect
& rProtect
)
115 rStream
.Read(&rProtect
.PassWord
, sizeof(rProtect
.PassWord
));
116 rStream
>> rProtect
.Flags
;
117 rStream
>> rProtect
.Protect
;
121 void lcl_ReadRGB(SvStream
& rStream
, Sc10Color
& rColor
)
123 rStream
>> rColor
.Dummy
;
124 rStream
>> rColor
.Blue
;
125 rStream
>> rColor
.Green
;
126 rStream
>> rColor
.Red
;
130 void lcl_ReadPalette(SvStream
& rStream
, Sc10Color
* pPalette
)
132 for (USHORT i
= 0; i
< 16; i
++)
133 lcl_ReadRGB(rStream
, pPalette
[i
]);
137 void lcl_ReadValueFormat(SvStream
& rStream
, Sc10ValueFormat
& rFormat
)
139 rStream
>> rFormat
.Format
;
140 rStream
>> rFormat
.Info
;
144 void lcl_ReadLogFont(SvStream
& rStream
, Sc10LogFont
& rFont
)
146 rStream
>> rFont
.lfHeight
;
147 rStream
>> rFont
.lfWidth
;
148 rStream
>> rFont
.lfEscapement
;
149 rStream
>> rFont
.lfOrientation
;
150 rStream
>> rFont
.lfWeight
;
151 rStream
>> rFont
.lfItalic
;
152 rStream
>> rFont
.lfUnderline
;
153 rStream
>> rFont
.lfStrikeOut
;
154 rStream
>> rFont
.lfCharSet
;
155 rStream
>> rFont
.lfOutPrecision
;
156 rStream
>> rFont
.lfClipPrecision
;
157 rStream
>> rFont
.lfQuality
;
158 rStream
>> rFont
.lfPitchAndFamily
;
159 rStream
.Read(&rFont
.lfFaceName
, sizeof(rFont
.lfFaceName
));
163 void lcl_ReadBlockRect(SvStream
& rStream
, Sc10BlockRect
& rBlock
)
165 rStream
>> rBlock
.x1
;
166 rStream
>> rBlock
.y1
;
167 rStream
>> rBlock
.x2
;
168 rStream
>> rBlock
.y2
;
172 void lcl_ReadHeadFootLine(SvStream
& rStream
, Sc10HeadFootLine
& rLine
)
174 rStream
.Read(&rLine
.Title
, sizeof(rLine
.Title
));
175 lcl_ReadLogFont(rStream
, rLine
.LogFont
);
176 rStream
>> rLine
.HorJustify
;
177 rStream
>> rLine
.VerJustify
;
178 rStream
>> rLine
.Raster
;
179 rStream
>> rLine
.Frame
;
180 lcl_ReadRGB(rStream
, rLine
.TextColor
);
181 lcl_ReadRGB(rStream
, rLine
.BackColor
);
182 lcl_ReadRGB(rStream
, rLine
.RasterColor
);
183 rStream
>> rLine
.FrameColor
;
184 rStream
>> rLine
.Reserved
;
188 void lcl_ReadPageFormat(SvStream
& rStream
, Sc10PageFormat
& rFormat
)
190 lcl_ReadHeadFootLine(rStream
, rFormat
.HeadLine
);
191 lcl_ReadHeadFootLine(rStream
, rFormat
.FootLine
);
192 rStream
>> rFormat
.Orientation
;
193 rStream
>> rFormat
.Width
;
194 rStream
>> rFormat
.Height
;
195 rStream
>> rFormat
.NonPrintableX
;
196 rStream
>> rFormat
.NonPrintableY
;
197 rStream
>> rFormat
.Left
;
198 rStream
>> rFormat
.Top
;
199 rStream
>> rFormat
.Right
;
200 rStream
>> rFormat
.Bottom
;
201 rStream
>> rFormat
.Head
;
202 rStream
>> rFormat
.Foot
;
203 rStream
>> rFormat
.HorCenter
;
204 rStream
>> rFormat
.VerCenter
;
205 rStream
>> rFormat
.PrintGrid
;
206 rStream
>> rFormat
.PrintColRow
;
207 rStream
>> rFormat
.PrintNote
;
208 rStream
>> rFormat
.TopBottomDir
;
209 rStream
.Read(&rFormat
.PrintAreaName
, sizeof(rFormat
.PrintAreaName
));
210 lcl_ReadBlockRect(rStream
, rFormat
.PrintArea
);
211 rStream
.Read(&rFormat
.PrnZoom
, sizeof(rFormat
.PrnZoom
));
212 rStream
>> rFormat
.FirstPageNo
;
213 rStream
>> rFormat
.RowRepeatStart
;
214 rStream
>> rFormat
.RowRepeatEnd
;
215 rStream
>> rFormat
.ColRepeatStart
;
216 rStream
>> rFormat
.ColRepeatEnd
;
217 rStream
.Read(&rFormat
.Reserved
, sizeof(rFormat
.Reserved
));
221 void lcl_ReadGraphHeader(SvStream
& rStream
, Sc10GraphHeader
& rHeader
)
223 rStream
>> rHeader
.Typ
;
224 rStream
>> rHeader
.CarretX
;
225 rStream
>> rHeader
.CarretY
;
226 rStream
>> rHeader
.CarretZ
;
227 rStream
>> rHeader
.x
;
228 rStream
>> rHeader
.y
;
229 rStream
>> rHeader
.w
;
230 rStream
>> rHeader
.h
;
231 rStream
>> rHeader
.IsRelPos
;
232 rStream
>> rHeader
.DoPrint
;
233 rStream
>> rHeader
.FrameType
;
234 rStream
>> rHeader
.IsTransparent
;
235 lcl_ReadRGB(rStream
, rHeader
.FrameColor
);
236 lcl_ReadRGB(rStream
, rHeader
.BackColor
);
237 rStream
.Read(&rHeader
.Reserved
, sizeof(rHeader
.Reserved
));
241 void lcl_ReadImageHeaer(SvStream
& rStream
, Sc10ImageHeader
& rHeader
)
243 rStream
.Read(&rHeader
.FileName
, sizeof(rHeader
.FileName
));
244 rStream
>> rHeader
.Typ
;
245 rStream
>> rHeader
.Linked
;
246 rStream
>> rHeader
.x1
;
247 rStream
>> rHeader
.y1
;
248 rStream
>> rHeader
.x2
;
249 rStream
>> rHeader
.y2
;
250 rStream
>> rHeader
.Size
;
254 void lcl_ReadChartHeader(SvStream
& rStream
, Sc10ChartHeader
& rHeader
)
256 rStream
>> rHeader
.MM
;
257 rStream
>> rHeader
.xExt
;
258 rStream
>> rHeader
.yExt
;
259 rStream
>> rHeader
.Size
;
263 void lcl_ReadChartSheetData(SvStream
& rStream
, Sc10ChartSheetData
& rSheetData
)
265 rStream
>> rSheetData
.HasTitle
;
266 rStream
>> rSheetData
.TitleX
;
267 rStream
>> rSheetData
.TitleY
;
268 rStream
>> rSheetData
.HasSubTitle
;
269 rStream
>> rSheetData
.SubTitleX
;
270 rStream
>> rSheetData
.SubTitleY
;
271 rStream
>> rSheetData
.HasLeftTitle
;
272 rStream
>> rSheetData
.LeftTitleX
;
273 rStream
>> rSheetData
.LeftTitleY
;
274 rStream
>> rSheetData
.HasLegend
;
275 rStream
>> rSheetData
.LegendX1
;
276 rStream
>> rSheetData
.LegendY1
;
277 rStream
>> rSheetData
.LegendX2
;
278 rStream
>> rSheetData
.LegendY2
;
279 rStream
>> rSheetData
.HasLabel
;
280 rStream
>> rSheetData
.LabelX1
;
281 rStream
>> rSheetData
.LabelY1
;
282 rStream
>> rSheetData
.LabelX2
;
283 rStream
>> rSheetData
.LabelY2
;
284 rStream
>> rSheetData
.DataX1
;
285 rStream
>> rSheetData
.DataY1
;
286 rStream
>> rSheetData
.DataX2
;
287 rStream
>> rSheetData
.DataY2
;
288 rStream
.Read(&rSheetData
.Reserved
, sizeof(rSheetData
.Reserved
));
292 void lcl_ReadChartTypeData(SvStream
& rStream
, Sc10ChartTypeData
& rTypeData
)
294 rStream
>> rTypeData
.NumSets
;
295 rStream
>> rTypeData
.NumPoints
;
296 rStream
>> rTypeData
.DrawMode
;
297 rStream
>> rTypeData
.GraphType
;
298 rStream
>> rTypeData
.GraphStyle
;
299 rStream
.Read(&rTypeData
.GraphTitle
, sizeof(rTypeData
.GraphTitle
));
300 rStream
.Read(&rTypeData
.BottomTitle
, sizeof(rTypeData
.BottomTitle
));
302 for (i
= 0; i
< 256; i
++)
303 rStream
>> rTypeData
.SymbolData
[i
];
304 for (i
= 0; i
< 256; i
++)
305 rStream
>> rTypeData
.ColorData
[i
];
306 for (i
= 0; i
< 256; i
++)
307 rStream
>> rTypeData
.ThickLines
[i
];
308 for (i
= 0; i
< 256; i
++)
309 rStream
>> rTypeData
.PatternData
[i
];
310 for (i
= 0; i
< 256; i
++)
311 rStream
>> rTypeData
.LinePatternData
[i
];
312 for (i
= 0; i
< 11; i
++)
313 rStream
>> rTypeData
.NumGraphStyles
[i
];
314 rStream
>> rTypeData
.ShowLegend
;
315 for (i
= 0; i
< 256; i
++)
316 rStream
.Read(&rTypeData
.LegendText
[i
], sizeof(Sc10ChartText
));
317 rStream
>> rTypeData
.ExplodePie
;
318 rStream
>> rTypeData
.FontUse
;
319 for (i
= 0; i
< 5; i
++)
320 rStream
>> rTypeData
.FontFamily
[i
];
321 for (i
= 0; i
< 5; i
++)
322 rStream
>> rTypeData
.FontStyle
[i
];
323 for (i
= 0; i
< 5; i
++)
324 rStream
>> rTypeData
.FontSize
[i
];
325 rStream
>> rTypeData
.GridStyle
;
326 rStream
>> rTypeData
.Labels
;
327 rStream
>> rTypeData
.LabelEvery
;
328 for (i
= 0; i
< 50; i
++)
329 rStream
.Read(&rTypeData
.LabelText
[i
], sizeof(Sc10ChartText
));
330 rStream
.Read(&rTypeData
.LeftTitle
, sizeof(rTypeData
.LeftTitle
));
331 rStream
.Read(&rTypeData
.Reserved
, sizeof(rTypeData
.Reserved
));
332 //rStream.Read(&rTypeData, sizeof(rTypeData));
335 double lcl_PascalToDouble(sal_Char
* tp6
)
337 // #i68483# bah! this was broken forever...
340 // sal_uInt8 be ; /* biased exponent */
341 // sal_uInt16 v1 ; /* lower 16 bits of mantissa */
342 // sal_uInt16 v2 ; /* next 16 bits of mantissa */
343 // sal_uInt8 v3:7; /* upper 7 bits of mantissa */
344 // sal_uInt8 s :1; /* sign bit */
347 // memcpy (&real, tp6, 6);
350 // return (((((128 +real.v3) * 65536.0) + real.v2) * 65536.0 + real.v1) *
351 // ldexp ((real.s? -1.0: 1.0), real.be - (129+39)));
353 sal_uInt8
* pnUnsigned
= reinterpret_cast< sal_uInt8
* >( tp6
);
355 sal_uInt8 be
= pnUnsigned
[ 0 ];
356 // lower 16 bits of mantissa
357 sal_uInt16 v1
= static_cast< sal_uInt16
>( pnUnsigned
[ 2 ] * 256 + pnUnsigned
[ 1 ] );
358 // next 16 bits of mantissa
359 sal_uInt16 v2
= static_cast< sal_uInt16
>( pnUnsigned
[ 4 ] * 256 + pnUnsigned
[ 3 ] );
360 // upper 7 bits of mantissa
361 sal_uInt8 v3
= static_cast< sal_uInt8
>( pnUnsigned
[ 5 ] & 0x7F );
363 bool s
= (pnUnsigned
[ 5 ] & 0x80) != 0;
367 return (((((128 + v3
) * 65536.0) + v2
) * 65536.0 + v1
) *
368 ldexp ((s
? -1.0 : 1.0), be
- (129+39)));
372 void lcl_ChangeColor( USHORT nIndex
, Color
& rColor
)
378 case 1: aCol
= COL_RED
; break;
379 case 2: aCol
= COL_GREEN
; break;
380 case 3: aCol
= COL_BROWN
; break;
381 case 4: aCol
= COL_BLUE
; break;
382 case 5: aCol
= COL_MAGENTA
; break;
383 case 6: aCol
= COL_CYAN
; break;
384 case 7: aCol
= COL_GRAY
; break;
385 case 8: aCol
= COL_LIGHTGRAY
; break;
386 case 9: aCol
= COL_LIGHTRED
; break;
387 case 10: aCol
= COL_LIGHTGREEN
; break;
388 case 11: aCol
= COL_YELLOW
; break;
389 case 12: aCol
= COL_LIGHTBLUE
; break;
390 case 13: aCol
= COL_LIGHTMAGENTA
; break;
391 case 14: aCol
= COL_LIGHTCYAN
; break;
392 case 15: aCol
= COL_WHITE
; break;
393 default: aCol
= COL_BLACK
;
396 rColor
.SetColor( aCol
);
399 String
lcl_MakeOldPageStyleFormatName( USHORT i
)
401 String aName
= ScGlobal::GetRscString( STR_PAGESTYLE
);
402 aName
.AppendAscii( " " );
403 aName
+= String::CreateFromInt32( i
+ 1 );
408 //--------------------------------------------
410 //--------------------------------------------
413 Sc10FontData::Sc10FontData(SvStream
& rStream
)
417 rStream
>> PitchAndFamily
;
420 rStream
.Read(FaceName
, nLen
);
424 Sc10FontCollection::Sc10FontCollection(SvStream
& rStream
) :
434 for (USHORT i
=0; (i
< nAnz
) && (nError
== 0); i
++)
436 Insert(new Sc10FontData(rStream
));
437 nError
= rStream
.GetError();
442 DBG_ERROR( "FontID" );
443 nError
= errUnknownID
;
448 //--------------------------------------------
450 //--------------------------------------------
453 Sc10NameData::Sc10NameData(SvStream
& rStream
)
457 rStream
.Read(Name
, sizeof(Name
) - 1);
461 rStream
.Read(Reference
, sizeof(Reference
) - 1);
463 rStream
.Read(Reserved
, sizeof(Reserved
));
467 Sc10NameCollection::Sc10NameCollection(SvStream
& rStream
) :
477 for (USHORT i
=0; (i
< nAnz
) && (nError
== 0); i
++)
479 Insert(new Sc10NameData(rStream
));
480 nError
= rStream
.GetError();
485 DBG_ERROR( "NameID" );
486 nError
= errUnknownID
;
490 //--------------------------------------------
492 //--------------------------------------------
495 Sc10PatternData::Sc10PatternData(SvStream
& rStream
)
497 rStream
.Read(Name
, sizeof(Name
));
498 //rStream.Read(&ValueFormat, sizeof(ValueFormat));
499 //rStream.Read(&LogFont, sizeof(LogFont));
500 lcl_ReadValueFormat(rStream
, ValueFormat
);
501 lcl_ReadLogFont(rStream
, LogFont
);
508 rStream
>> FrameColor
;
510 rStream
>> FormatFlags
;
511 rStream
.Read(Reserved
, sizeof(Reserved
));
515 Sc10PatternCollection::Sc10PatternCollection(SvStream
& rStream
) :
525 for (USHORT i
=0; (i
< nAnz
) && (nError
== 0); i
++)
527 Insert(new Sc10PatternData(rStream
));
528 nError
= rStream
.GetError();
533 DBG_ERROR( "PatternID" );
534 nError
= errUnknownID
;
539 //--------------------------------------------
541 //--------------------------------------------
544 Sc10DataBaseData::Sc10DataBaseData(SvStream
& rStream
)
546 //rStream.Read(&DataBaseRec, sizeof(DataBaseRec));
547 rStream
.Read(&DataBaseRec
.Name
, sizeof(DataBaseRec
.Name
));
548 rStream
>> DataBaseRec
.Tab
;
549 lcl_ReadBlockRect(rStream
, DataBaseRec
.Block
);
550 rStream
>> DataBaseRec
.RowHeader
;
551 rStream
>> DataBaseRec
.SortField0
;
552 rStream
>> DataBaseRec
.SortUpOrder0
;
553 rStream
>> DataBaseRec
.SortField1
;
554 rStream
>> DataBaseRec
.SortUpOrder1
;
555 rStream
>> DataBaseRec
.SortField2
;
556 rStream
>> DataBaseRec
.SortUpOrder2
;
557 rStream
>> DataBaseRec
.IncludeFormat
;
559 rStream
>> DataBaseRec
.QueryField0
;
560 rStream
>> DataBaseRec
.QueryOp0
;
561 rStream
>> DataBaseRec
.QueryByString0
;
562 rStream
.Read(&DataBaseRec
.QueryString0
, sizeof(DataBaseRec
.QueryString0
));
563 DataBaseRec
.QueryValue0
= ScfTools::ReadLongDouble(rStream
);
565 rStream
>> DataBaseRec
.QueryConnect1
;
566 rStream
>> DataBaseRec
.QueryField1
;
567 rStream
>> DataBaseRec
.QueryOp1
;
568 rStream
>> DataBaseRec
.QueryByString1
;
569 rStream
.Read(&DataBaseRec
.QueryString1
, sizeof(DataBaseRec
.QueryString1
));
570 DataBaseRec
.QueryValue1
= ScfTools::ReadLongDouble(rStream
);
572 rStream
>> DataBaseRec
.QueryConnect2
;
573 rStream
>> DataBaseRec
.QueryField2
;
574 rStream
>> DataBaseRec
.QueryOp2
;
575 rStream
>> DataBaseRec
.QueryByString2
;
576 rStream
.Read(&DataBaseRec
.QueryString2
, sizeof(DataBaseRec
.QueryString2
));
577 DataBaseRec
.QueryValue2
= ScfTools::ReadLongDouble(rStream
);
581 Sc10DataBaseCollection::Sc10DataBaseCollection(SvStream
& rStream
) :
587 if (ID
== DataBaseID
)
589 rStream
.Read(ActName
, sizeof(ActName
));
592 for (USHORT i
=0; (i
< nAnz
) && (nError
== 0); i
++)
594 Insert(new Sc10DataBaseData(rStream
));
595 nError
= rStream
.GetError();
600 DBG_ERROR( "DataBaseID" );
601 nError
= errUnknownID
;
606 int Sc10LogFont::operator==( const Sc10LogFont
& rData
) const
608 return !strcmp( lfFaceName
, rData
.lfFaceName
)
609 && lfHeight
== rData
.lfHeight
610 && lfWidth
== rData
.lfWidth
611 && lfEscapement
== rData
.lfEscapement
612 && lfOrientation
== rData
.lfOrientation
613 && lfWeight
== rData
.lfWeight
614 && lfItalic
== rData
.lfItalic
615 && lfUnderline
== rData
.lfUnderline
616 && lfStrikeOut
== rData
.lfStrikeOut
617 && lfCharSet
== rData
.lfCharSet
618 && lfOutPrecision
== rData
.lfOutPrecision
619 && lfClipPrecision
== rData
.lfClipPrecision
620 && lfQuality
== rData
.lfQuality
621 && lfPitchAndFamily
== rData
.lfPitchAndFamily
;
625 int Sc10Color::operator==( const Sc10Color
& rColor
) const
627 return ((Red
== rColor
.Red
) && (Green
== rColor
.Green
) && (Blue
== rColor
.Blue
));
631 int Sc10HeadFootLine::operator==( const Sc10HeadFootLine
& rData
) const
633 return !strcmp(Title
, rData
.Title
)
634 && LogFont
== rData
.LogFont
635 && HorJustify
== rData
.HorJustify
636 && VerJustify
== rData
.VerJustify
637 && Raster
== rData
.Raster
638 && Frame
== rData
.Frame
639 && TextColor
== rData
.TextColor
640 && BackColor
== rData
.BackColor
641 && RasterColor
== rData
.RasterColor
642 && FrameColor
== rData
.FrameColor
643 && Reserved
== rData
.Reserved
;
647 int Sc10PageFormat::operator==( const Sc10PageFormat
& rData
) const
649 return !strcmp(PrintAreaName
, rData
.PrintAreaName
)
650 && HeadLine
== rData
.HeadLine
651 && FootLine
== rData
.FootLine
652 && Orientation
== rData
.Orientation
653 && Width
== rData
.Width
654 && Height
== rData
.Height
655 && NonPrintableX
== rData
.NonPrintableX
656 && NonPrintableY
== rData
.NonPrintableY
657 && Left
== rData
.Left
659 && Right
== rData
.Right
660 && Bottom
== rData
.Bottom
661 && Head
== rData
.Head
662 && Foot
== rData
.Foot
663 && HorCenter
== rData
.HorCenter
664 && VerCenter
== rData
.VerCenter
665 && PrintGrid
== rData
.PrintGrid
666 && PrintColRow
== rData
.PrintColRow
667 && PrintNote
== rData
.PrintNote
668 && TopBottomDir
== rData
.TopBottomDir
669 && FirstPageNo
== rData
.FirstPageNo
670 && RowRepeatStart
== rData
.RowRepeatStart
671 && RowRepeatEnd
== rData
.RowRepeatEnd
672 && ColRepeatStart
== rData
.ColRepeatStart
673 && ColRepeatEnd
== rData
.ColRepeatEnd
674 && !memcmp( PrnZoom
, rData
.PrnZoom
, sizeof(PrnZoom
) )
675 && !memcmp( &PrintArea
, &rData
.PrintArea
, sizeof(PrintArea
) );
679 USHORT
Sc10PageCollection::InsertFormat( const Sc10PageFormat
& rData
)
681 for (USHORT i
=0; i
<nCount
; i
++)
682 if (At(i
)->aPageFormat
== rData
)
685 Insert( new Sc10PageData(rData
) );
691 static inline UINT8
GetMixedCol( const UINT8 nB
, const UINT8 nF
, const UINT16 nFak
)
694 nT
*= ( INT32
) nFak
;
699 static inline Color
GetMixedColor( const Color
& rFore
, const Color
& rBack
, UINT16 nFact
)
701 return Color( GetMixedCol( rBack
.GetRed(), rFore
.GetRed(), nFact
),
702 GetMixedCol( rBack
.GetGreen(), rFore
.GetGreen(), nFact
),
703 GetMixedCol( rBack
.GetBlue(), rFore
.GetBlue(), nFact
) );
707 void Sc10PageCollection::PutToDoc( ScDocument
* pDoc
)
709 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
710 EditEngine
aEditEngine( pDoc
->GetEnginePool() );
711 EditTextObject
* pEmptyObject
= aEditEngine
.CreateTextObject();
713 for (USHORT i
=0; i
<nCount
; i
++)
715 Sc10PageFormat
* pPage
= &At(i
)->aPageFormat
;
717 pPage
->Width
= (short) ( pPage
->Width
* ( 72.0 / 72.27 ) + 0.5 );
718 pPage
->Height
= (short) ( pPage
->Height
* ( 72.0 / 72.27 ) + 0.5 );
719 pPage
->Top
= (short) ( pPage
->Top
* ( 72.0 / 72.27 ) + 0.5 );
720 pPage
->Bottom
= (short) ( pPage
->Bottom
* ( 72.0 / 72.27 ) + 0.5 );
721 pPage
->Left
= (short) ( pPage
->Left
* ( 72.0 / 72.27 ) + 0.5 );
722 pPage
->Right
= (short) ( pPage
->Right
* ( 72.0 / 72.27 ) + 0.5 );
723 pPage
->Head
= (short) ( pPage
->Head
* ( 72.0 / 72.27 ) + 0.5 );
724 pPage
->Foot
= (short) ( pPage
->Foot
* ( 72.0 / 72.27 ) + 0.5 );
726 String aName
= lcl_MakeOldPageStyleFormatName( i
);
728 ScStyleSheet
* pSheet
= (ScStyleSheet
*) &pStylePool
->Make( aName
,
729 SFX_STYLE_FAMILY_PAGE
,
730 SFXSTYLEBIT_USERDEF
| SCSTYLEBIT_STANDARD
);
731 // #i68483# set page style name at sheet...
732 pDoc
->SetPageStyle( static_cast< SCTAB
>( i
), aName
);
734 SfxItemSet
* pSet
= &pSheet
->GetItemSet();
736 for (USHORT nHeadFoot
=0; nHeadFoot
<2; nHeadFoot
++)
738 Sc10HeadFootLine
* pHeadFootLine
= nHeadFoot
? &pPage
->FootLine
: &pPage
->HeadLine
;
740 SfxItemSet
aEditAttribs(aEditEngine
.GetEmptyItemSet());
741 FontFamily eFam
= FAMILY_DONTKNOW
;
742 switch (pPage
->HeadLine
.LogFont
.lfPitchAndFamily
& 0xF0)
744 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
745 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
746 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
747 case ffModern
: eFam
= FAMILY_MODERN
; break;
748 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
749 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
750 default: eFam
= FAMILY_DONTKNOW
; break;
752 aEditAttribs
.Put( SvxFontItem(
754 SC10TOSTRING( pHeadFootLine
->LogFont
.lfFaceName
), EMPTY_STRING
,
755 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, EE_CHAR_FONTINFO
),
757 aEditAttribs
.Put( SvxFontHeightItem( Abs( pHeadFootLine
->LogFont
.lfHeight
), 100, EE_CHAR_FONTHEIGHT
),
760 Sc10Color nColor
= pHeadFootLine
->TextColor
;
761 Color
TextColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
762 aEditAttribs
.Put(SvxColorItem(TextColor
, EE_CHAR_COLOR
), EE_CHAR_COLOR
);
764 if (pHeadFootLine
->LogFont
.lfWeight
!= fwNormal
)
765 aEditAttribs
.Put(SvxWeightItem(WEIGHT_BOLD
, EE_CHAR_WEIGHT
), EE_CHAR_WEIGHT
);
766 if (pHeadFootLine
->LogFont
.lfItalic
!= 0)
767 aEditAttribs
.Put(SvxPostureItem(ITALIC_NORMAL
, EE_CHAR_ITALIC
), EE_CHAR_ITALIC
);
768 if (pHeadFootLine
->LogFont
.lfUnderline
!= 0)
769 aEditAttribs
.Put(SvxUnderlineItem(UNDERLINE_SINGLE
, EE_CHAR_UNDERLINE
), EE_CHAR_UNDERLINE
);
770 if (pHeadFootLine
->LogFont
.lfStrikeOut
!= 0)
771 aEditAttribs
.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE
, EE_CHAR_STRIKEOUT
), EE_CHAR_STRIKEOUT
);
772 String
aText( pHeadFootLine
->Title
, DEFCHARSET
);
773 aEditEngine
.SetText( aText
);
774 aEditEngine
.QuickSetAttribs( aEditAttribs
, ESelection( 0, 0, 0, aText
.Len() ) );
776 EditTextObject
* pObject
= aEditEngine
.CreateTextObject();
777 ScPageHFItem
aHeaderItem(nHeadFoot
? ATTR_PAGE_FOOTERRIGHT
: ATTR_PAGE_HEADERRIGHT
);
778 switch (pHeadFootLine
->HorJustify
)
781 aHeaderItem
.SetLeftArea(*pEmptyObject
);
782 aHeaderItem
.SetCenterArea(*pObject
);
783 aHeaderItem
.SetRightArea(*pEmptyObject
);
786 aHeaderItem
.SetLeftArea(*pEmptyObject
);
787 aHeaderItem
.SetCenterArea(*pEmptyObject
);
788 aHeaderItem
.SetRightArea(*pObject
);
791 aHeaderItem
.SetLeftArea(*pObject
);
792 aHeaderItem
.SetCenterArea(*pEmptyObject
);
793 aHeaderItem
.SetRightArea(*pEmptyObject
);
797 pSet
->Put( aHeaderItem
);
799 SfxItemSet
aSetItemItemSet( *pDoc
->GetPool(),
800 ATTR_BACKGROUND
, ATTR_BACKGROUND
,
801 ATTR_BORDER
, ATTR_SHADOW
,
802 ATTR_PAGE_SIZE
, ATTR_PAGE_SIZE
,
803 ATTR_LRSPACE
, ATTR_ULSPACE
,
804 ATTR_PAGE_ON
, ATTR_PAGE_SHARED
,
806 nColor
= pHeadFootLine
->BackColor
;
807 Color
aBColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
808 nColor
= pHeadFootLine
->RasterColor
;
809 Color
aRColor( nColor
.Red
, nColor
.Green
, nColor
.Blue
);
812 BOOL bSwapCol
= FALSE
;
813 switch (pHeadFootLine
->Raster
)
815 case raNone
: nFact
= 0xffff; bSwapCol
= TRUE
; break;
816 case raGray12
: nFact
= (0xffff / 100) * 12; break;
817 case raGray25
: nFact
= (0xffff / 100) * 25; break;
818 case raGray50
: nFact
= (0xffff / 100) * 50; break;
819 case raGray75
: nFact
= (0xffff / 100) * 75; break;
820 default: nFact
= 0xffff;
823 aSetItemItemSet
.Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
825 aSetItemItemSet
.Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
827 if (pHeadFootLine
->Frame
!= 0)
833 USHORT fLeft
= (pHeadFootLine
->Frame
& 0x000F);
834 USHORT fTop
= (pHeadFootLine
->Frame
& 0x00F0) / 0x0010;
835 USHORT fRight
= (pHeadFootLine
->Frame
& 0x0F00) / 0x0100;
836 USHORT fBottom
= (pHeadFootLine
->Frame
& 0xF000) / 0x1000;
851 else if (fBottom
> 0)
853 Color
ColorLeft(COL_BLACK
);
854 Color
ColorTop(COL_BLACK
);
855 Color
ColorRight(COL_BLACK
);
856 Color
ColorBottom(COL_BLACK
);
857 USHORT cLeft
= (pHeadFootLine
->FrameColor
& 0x000F);
858 USHORT cTop
= (pHeadFootLine
->FrameColor
& 0x00F0) >> 4;
859 USHORT cRight
= (pHeadFootLine
->FrameColor
& 0x0F00) >> 8;
860 USHORT cBottom
= (pHeadFootLine
->FrameColor
& 0xF000) >> 12;
861 lcl_ChangeColor(cLeft
, ColorLeft
);
862 lcl_ChangeColor(cTop
, ColorTop
);
863 lcl_ChangeColor(cRight
, ColorRight
);
864 lcl_ChangeColor(cBottom
, ColorBottom
);
866 SvxBoxItem
aBox( ATTR_BORDER
);
867 aLine
.SetOutWidth(nLeft
);
868 aLine
.SetColor(ColorLeft
);
869 aBox
.SetLine(&aLine
, BOX_LINE_LEFT
);
870 aLine
.SetOutWidth(nTop
);
871 aLine
.SetColor(ColorTop
);
872 aBox
.SetLine(&aLine
, BOX_LINE_TOP
);
873 aLine
.SetOutWidth(nRight
);
874 aLine
.SetColor(ColorRight
);
875 aBox
.SetLine(&aLine
, BOX_LINE_RIGHT
);
876 aLine
.SetOutWidth(nBottom
);
877 aLine
.SetColor(ColorBottom
);
878 aBox
.SetLine(&aLine
, BOX_LINE_BOTTOM
);
880 aSetItemItemSet
.Put(aBox
);
883 pSet
->Put( SvxULSpaceItem( 0, 0, ATTR_ULSPACE
) );
886 aSetItemItemSet
.Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( 0, pPage
->Top
- pPage
->Head
) ) );
888 aSetItemItemSet
.Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( 0, pPage
->Bottom
- pPage
->Foot
) ) );
890 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_ON
, TRUE
));
891 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_DYNAMIC
, FALSE
));
892 aSetItemItemSet
.Put(SfxBoolItem( ATTR_PAGE_SHARED
, TRUE
));
894 pSet
->Put( SvxSetItem( nHeadFoot
? ATTR_PAGE_FOOTERSET
: ATTR_PAGE_HEADERSET
,
898 SvxPageItem
aPageItem(ATTR_PAGE
);
899 aPageItem
.SetPageUsage( SVX_PAGE_ALL
);
900 aPageItem
.SetLandscape( pPage
->Orientation
!= 1 );
901 aPageItem
.SetNumType( SVX_ARABIC
);
902 pSet
->Put(aPageItem
);
904 pSet
->Put(SvxLRSpaceItem( pPage
->Left
, pPage
->Right
, 0,0, ATTR_LRSPACE
));
905 pSet
->Put(SvxULSpaceItem( pPage
->Top
, pPage
->Bottom
, ATTR_ULSPACE
));
907 pSet
->Put(SfxBoolItem( ATTR_PAGE_HORCENTER
, pPage
->HorCenter
));
908 pSet
->Put(SfxBoolItem( ATTR_PAGE_VERCENTER
, pPage
->VerCenter
));
914 ScRange
* pRepeatRow
= NULL
;
915 ScRange
* pRepeatCol
= NULL
;
917 if ( pPage
->ColRepeatStart
>= 0 )
918 pRepeatCol
= new ScRange( static_cast<SCCOL
> (pPage
->ColRepeatStart
), 0, 0 );
919 if ( pPage
->RowRepeatStart
>= 0 )
920 pRepeatRow
= new ScRange( 0, static_cast<SCROW
> (pPage
->RowRepeatStart
), 0 );
923 if ( pRepeatRow
|| pRepeatCol
)
926 // an allen Tabellen setzen
928 for ( SCTAB nTab
= 0, nTabCount
= pDoc
->GetTableCount(); nTab
< nTabCount
; ++nTab
)
930 pDoc
->SetRepeatColRange( nTab
, pRepeatCol
);
931 pDoc
->SetRepeatRowRange( nTab
, pRepeatRow
);
942 pSet
->Put( SfxBoolItem( ATTR_PAGE_NOTES
, pPage
->PrintNote
) );
943 pSet
->Put( SfxBoolItem( ATTR_PAGE_GRID
, pPage
->PrintGrid
) );
944 pSet
->Put( SfxBoolItem( ATTR_PAGE_HEADERS
, pPage
->PrintColRow
) );
945 pSet
->Put( SfxBoolItem( ATTR_PAGE_TOPDOWN
, pPage
->TopBottomDir
) );
946 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_CHARTS
, VOBJ_MODE_SHOW
) );
947 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_OBJECTS
, VOBJ_MODE_SHOW
) );
948 pSet
->Put( ScViewObjectModeItem( ATTR_PAGE_DRAWINGS
, VOBJ_MODE_SHOW
) );
949 pSet
->Put( SfxUInt16Item( ATTR_PAGE_SCALE
,
950 (UINT16
)( lcl_PascalToDouble( pPage
->PrnZoom
) * 100 ) ) );
951 pSet
->Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO
, 1 ) );
953 pSet
->Put( SvxSizeItem( ATTR_PAGE_SIZE
, Size( pPage
->Width
, pPage
->Height
) ) );
960 ScDataObject
* Sc10PageData::Clone() const
962 return new Sc10PageData(aPageFormat
);
966 //--------------------------------------------
968 //--------------------------------------------
971 Sc10Import::Sc10Import(SvStream
& rStr
, ScDocument
* pDocument
) :
974 pFontCollection (NULL
),
975 pNameCollection (NULL
),
976 pPatternCollection (NULL
),
977 pDataBaseCollection (NULL
),
985 Sc10Import::~Sc10Import()
987 pDoc
->CalcAfterLoad();
988 pDoc
->UpdateAllCharts();
990 delete pFontCollection
;
991 delete pNameCollection
;
992 delete pPatternCollection
;
993 delete pDataBaseCollection
;
995 DBG_ASSERT( pPrgrsBar
== NULL
,
996 "*Sc10Import::Sc10Import(): Progressbar lebt noch!?" );
1000 ULONG
Sc10Import::Import()
1002 pPrgrsBar
= new ScfStreamProgressBar( rStream
, pDoc
->GetDocumentShell() );
1004 ScDocOptions aOpt
= pDoc
->GetDocOptions();
1005 aOpt
.SetDate( 1, 1, 1900 );
1006 aOpt
.SetYear2000( 18 + 1901 ); // ab SO51 src513e vierstellig
1007 pDoc
->SetDocOptions( aOpt
);
1008 pDoc
->GetFormatTable()->ChangeNullDate( 1, 1, 1900 );
1010 LoadFileHeader(); pPrgrsBar
->Progress();
1011 if (!nError
) { LoadFileInfo(); pPrgrsBar
->Progress(); }
1012 if (!nError
) { LoadEditStateInfo(); pPrgrsBar
->Progress(); }
1013 if (!nError
) { LoadProtect(); pPrgrsBar
->Progress(); }
1014 if (!nError
) { LoadViewColRowBar(); pPrgrsBar
->Progress(); }
1015 if (!nError
) { LoadScrZoom(); pPrgrsBar
->Progress(); }
1016 if (!nError
) { LoadPalette(); pPrgrsBar
->Progress(); }
1017 if (!nError
) { LoadFontCollection(); pPrgrsBar
->Progress(); }
1018 if (!nError
) { LoadNameCollection(); pPrgrsBar
->Progress(); }
1019 if (!nError
) { LoadPatternCollection(); pPrgrsBar
->Progress(); }
1020 if (!nError
) { LoadDataBaseCollection(); pPrgrsBar
->Progress(); }
1021 if (!nError
) { LoadTables(); pPrgrsBar
->Progress(); }
1022 if (!nError
) { LoadObjects(); pPrgrsBar
->Progress(); }
1023 if (!nError
) { ImportNameCollection(); pPrgrsBar
->Progress(); }
1024 pDoc
->SetViewOptions( aSc30ViewOpt
);
1029 DBG_ERROR( ByteString::CreateFromInt32( nError
).GetBuffer() );
1042 void Sc10Import::LoadFileHeader()
1044 Sc10FileHeader FileHeader
;
1045 //rStream.Read(&FileHeader, sizeof(FileHeader));
1046 lcl_ReadFileHeader(rStream
, FileHeader
);
1048 nError
= rStream
.GetError();
1051 sal_Char Sc10CopyRight
[32];
1052 strcpy(Sc10CopyRight
, "Blaise-Tabelle"); // #100211# - checked
1053 Sc10CopyRight
[14] = 10;
1054 Sc10CopyRight
[15] = 13;
1055 Sc10CopyRight
[16] = 0;
1056 if ((strcmp(FileHeader
.CopyRight
, Sc10CopyRight
) != 0)
1057 || (FileHeader
.Version
< 101)
1058 || (FileHeader
.Version
> 102))
1059 nError
= errUnknownFormat
;
1064 void Sc10Import::LoadFileInfo()
1066 Sc10FileInfo FileInfo
;
1067 rStream
.Read(&FileInfo
, sizeof(FileInfo
));
1069 nError
= rStream
.GetError();
1070 // Achtung Info Uebertragen
1075 void Sc10Import::LoadEditStateInfo()
1077 Sc10EditStateInfo EditStateInfo
;
1078 rStream
.Read(&EditStateInfo
, sizeof(EditStateInfo
));
1080 nError
= rStream
.GetError();
1081 nShowTab
= static_cast<SCTAB
>(EditStateInfo
.DeltaZ
);
1082 // Achtung Cursorposition und Offset der Tabelle Uebertragen (soll man das machen??)
1086 void Sc10Import::LoadProtect()
1088 //rStream.Read(&SheetProtect, sizeof(SheetProtect));
1089 lcl_ReadSheetProtect(rStream
, SheetProtect
);
1090 nError
= rStream
.GetError();
1092 ScDocProtection aProtection
;
1093 aProtection
.setProtected(static_cast<bool>(SheetProtect
.Protect
));
1094 aProtection
.setPassword(SC10TOSTRING(SheetProtect
.PassWord
));
1095 pDoc
->SetDocProtection(&aProtection
);
1099 void Sc10Import::LoadViewColRowBar()
1102 rStream
>> ViewColRowBar
;
1103 nError
= rStream
.GetError();
1104 aSc30ViewOpt
.SetOption( VOPT_HEADER
, (BOOL
)ViewColRowBar
);
1108 void Sc10Import::LoadScrZoom()
1110 // Achtung Zoom ist leider eine 6Byte TP real Zahl (keine Ahnung wie die Umzusetzen ist)
1112 rStream
.Read(cZoom
, sizeof(cZoom
));
1113 nError
= rStream
.GetError();
1117 void Sc10Import::LoadPalette()
1119 //rStream.Read(TextPalette, sizeof(TextPalette));
1120 //rStream.Read(BackPalette, sizeof(BackPalette));
1121 //rStream.Read(RasterPalette, sizeof(RasterPalette));
1122 //rStream.Read(FramePalette, sizeof(FramePalette));
1123 lcl_ReadPalette(rStream
, TextPalette
);
1124 lcl_ReadPalette(rStream
, BackPalette
);
1125 lcl_ReadPalette(rStream
, RasterPalette
);
1126 lcl_ReadPalette(rStream
, FramePalette
);
1128 nError
= rStream
.GetError();
1132 void Sc10Import::LoadFontCollection()
1134 pFontCollection
= new Sc10FontCollection(rStream
);
1138 void Sc10Import::LoadNameCollection()
1140 pNameCollection
= new Sc10NameCollection(rStream
);
1144 void Sc10Import::ImportNameCollection()
1146 ScRangeName
* pRN
= pDoc
->GetRangeName();
1148 for (USHORT i
= 0; i
< pNameCollection
->GetCount(); i
++)
1150 Sc10NameData
* pName
= pNameCollection
->At( i
);
1151 pRN
->Insert( new ScRangeData( pDoc
,
1152 SC10TOSTRING( pName
->Name
),
1153 SC10TOSTRING( pName
->Reference
) ) );
1158 void Sc10Import::LoadPatternCollection()
1160 pPatternCollection
= new Sc10PatternCollection( rStream
);
1161 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
1162 for( USHORT i
= 0 ; i
< pPatternCollection
->GetCount() ; i
++ )
1164 Sc10PatternData
* pPattern
= pPatternCollection
->At( i
);
1165 String
aName( pPattern
->Name
, DEFCHARSET
);
1166 SfxStyleSheetBase
* pStyle
= pStylePool
->Find( aName
, SFX_STYLE_FAMILY_PARA
);
1167 if( pStyle
== NULL
)
1168 pStylePool
->Make( aName
, SFX_STYLE_FAMILY_PARA
);
1171 pPattern
->Name
[ 27 ] = 0;
1172 strcat( pPattern
->Name
, "_Old" ); // #100211# - checked
1173 aName
= SC10TOSTRING( pPattern
->Name
);
1174 pStylePool
->Make( aName
, SFX_STYLE_FAMILY_PARA
);
1176 pStyle
= pStylePool
->Find( aName
, SFX_STYLE_FAMILY_PARA
);
1177 if( pStyle
!= NULL
)
1179 SfxItemSet
&rItemSet
= pStyle
->GetItemSet();
1181 if( ( pPattern
->FormatFlags
& pfFont
) == pfFont
)
1183 FontFamily eFam
= FAMILY_DONTKNOW
;
1184 switch( pPattern
->LogFont
.lfPitchAndFamily
& 0xF0 )
1186 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
1187 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
1188 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
1189 case ffModern
: eFam
= FAMILY_MODERN
; break;
1190 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
1191 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
1192 default: eFam
= FAMILY_DONTKNOW
; break;
1194 rItemSet
.Put( SvxFontItem( eFam
, SC10TOSTRING( pPattern
->LogFont
.lfFaceName
), EMPTY_STRING
,
1195 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
) );
1196 rItemSet
.Put( SvxFontHeightItem( Abs( pPattern
->LogFont
.lfHeight
), 100, ATTR_FONT_HEIGHT
) );
1197 Color
TextColor( COL_BLACK
);
1198 lcl_ChangeColor( ( pPattern
->nColor
& 0x000F ), TextColor
);
1199 rItemSet
.Put( SvxColorItem( TextColor
, ATTR_FONT_COLOR
) );
1201 if( pPattern
->LogFont
.lfWeight
!= fwNormal
)
1202 rItemSet
.Put( SvxWeightItem( WEIGHT_BOLD
, ATTR_FONT_WEIGHT
) );
1203 if( pPattern
->LogFont
.lfItalic
!= 0 )
1204 rItemSet
.Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
1205 if( pPattern
->LogFont
.lfUnderline
!= 0 )
1206 rItemSet
.Put( SvxUnderlineItem( UNDERLINE_SINGLE
, ATTR_FONT_UNDERLINE
) );
1207 if( pPattern
->LogFont
.lfStrikeOut
!= 0 )
1208 rItemSet
.Put( SvxCrossedOutItem( STRIKEOUT_SINGLE
, ATTR_FONT_CROSSEDOUT
) );
1211 if( ( pPattern
->FormatFlags
& pfJustify
) == pfJustify
)
1213 USHORT HorJustify
= ( pPattern
->Justify
& 0x000F );
1214 USHORT VerJustify
= ( pPattern
->Justify
& 0x00F0 ) >> 4;
1215 USHORT OJustify
= ( pPattern
->Justify
& 0x0F00 ) >> 8;
1216 USHORT EJustify
= ( pPattern
->Justify
& 0xF000 ) >> 12;
1217 if( HorJustify
!= 0 )
1218 switch( HorJustify
)
1221 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT
, ATTR_HOR_JUSTIFY
) );
1224 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
) );
1227 rItemSet
.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT
, ATTR_HOR_JUSTIFY
) );
1230 if( VerJustify
!= 0 )
1231 switch( VerJustify
)
1234 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_TOP
, ATTR_VER_JUSTIFY
) );
1237 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER
, ATTR_VER_JUSTIFY
) );
1240 rItemSet
.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_BOTTOM
, ATTR_VER_JUSTIFY
) );
1244 if( ( OJustify
& ojWordBreak
) == ojWordBreak
)
1245 rItemSet
.Put( SfxBoolItem( TRUE
) );
1246 if( ( OJustify
& ojBottomTop
) == ojBottomTop
)
1247 rItemSet
.Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 9000 ) );
1248 else if( ( OJustify
& ojTopBottom
) == ojTopBottom
)
1249 rItemSet
.Put( SfxInt32Item( ATTR_ROTATE_VALUE
, 27000 ) );
1251 INT16 Margin
= Max( ( USHORT
) 20, ( USHORT
) ( EJustify
* 20 ) );
1252 // if( ( ( OJustify & ojBottomTop ) == ojBottomTop ) ||
1253 // ( ( OJustify & ojBottomTop ) == ojBottomTop ) )
1255 if( ( ( OJustify
& ojBottomTop
) == ojBottomTop
) )
1256 rItemSet
.Put( SvxMarginItem( 20, Margin
, 20, Margin
, ATTR_MARGIN
) );
1258 rItemSet
.Put( SvxMarginItem( Margin
, 20, Margin
, 20, ATTR_MARGIN
) );
1262 if( ( pPattern
->FormatFlags
& pfFrame
) == pfFrame
)
1264 if( pPattern
->Frame
!= 0 )
1270 USHORT fLeft
= ( pPattern
->Frame
& 0x000F );
1271 USHORT fTop
= ( pPattern
->Frame
& 0x00F0 ) / 0x0010;
1272 USHORT fRight
= ( pPattern
->Frame
& 0x0F00 ) / 0x0100;
1273 USHORT fBottom
= ( pPattern
->Frame
& 0xF000 ) / 0x1000;
1277 else if( fLeft
> 0 )
1287 else if( fRight
> 0 )
1292 else if( fBottom
> 0 )
1295 Color
ColorLeft( COL_BLACK
);
1296 Color
ColorTop( COL_BLACK
);
1297 Color
ColorRight( COL_BLACK
);
1298 Color
ColorBottom( COL_BLACK
);
1300 USHORT cLeft
= ( pPattern
->FrameColor
& 0x000F );
1301 USHORT cTop
= ( pPattern
->FrameColor
& 0x00F0 ) >> 4;
1302 USHORT cRight
= ( pPattern
->FrameColor
& 0x0F00 ) >> 8;
1303 USHORT cBottom
= ( pPattern
->FrameColor
& 0xF000 ) >> 12;
1305 lcl_ChangeColor( cLeft
, ColorLeft
);
1306 lcl_ChangeColor( cTop
, ColorTop
);
1307 lcl_ChangeColor( cRight
, ColorRight
);
1308 lcl_ChangeColor( cBottom
, ColorBottom
);
1310 SvxBorderLine aLine
;
1311 SvxBoxItem
aBox( ATTR_BORDER
);
1313 aLine
.SetOutWidth( nLeft
);
1314 aLine
.SetColor( ColorLeft
);
1315 aBox
.SetLine( &aLine
, BOX_LINE_LEFT
);
1316 aLine
.SetOutWidth( nTop
);
1317 aLine
.SetColor( ColorTop
);
1318 aBox
.SetLine( &aLine
, BOX_LINE_TOP
);
1319 aLine
.SetOutWidth( nRight
);
1320 aLine
.SetColor( ColorRight
);
1321 aBox
.SetLine( &aLine
, BOX_LINE_RIGHT
);
1322 aLine
.SetOutWidth( nBottom
);
1323 aLine
.SetColor( ColorBottom
);
1324 aBox
.SetLine( &aLine
, BOX_LINE_BOTTOM
);
1325 rItemSet
.Put( aBox
);
1329 if( ( pPattern
->FormatFlags
& pfRaster
) == pfRaster
)
1331 if( pPattern
->Raster
!= 0 )
1333 USHORT nBColor
= ( pPattern
->nColor
& 0x00F0 ) >> 4;
1334 USHORT nRColor
= ( pPattern
->nColor
& 0x0F00 ) >> 8;
1335 Color
aBColor( COL_BLACK
);
1337 lcl_ChangeColor( nBColor
, aBColor
);
1340 aBColor
.SetColor( COL_WHITE
);
1341 else if( nBColor
== 15 )
1342 aBColor
.SetColor( COL_BLACK
);
1344 Color
aRColor( COL_BLACK
);
1345 lcl_ChangeColor( nRColor
, aRColor
);
1347 BOOL bSwapCol
= FALSE
;
1348 BOOL bSetItem
= TRUE
;
1349 switch (pPattern
->Raster
)
1351 case raNone
: nFact
= 0xffff; bSwapCol
= TRUE
; bSetItem
= (nBColor
> 0); break;
1352 case raGray12
: nFact
= (0xffff / 100) * 12; break;
1353 case raGray25
: nFact
= (0xffff / 100) * 25; break;
1354 case raGray50
: nFact
= (0xffff / 100) * 50; break;
1355 case raGray75
: nFact
= (0xffff / 100) * 75; break;
1356 default: nFact
= 0xffff; bSetItem
= (nRColor
< 15);
1361 rItemSet
.Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
1363 rItemSet
.Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
1368 if( ( pPattern
->ValueFormat
.Format
!= 0 ) &&
1369 ( ( pPattern
->FormatFlags
& pfValue
) == pfValue
) )
1372 ChangeFormat( pPattern
->ValueFormat
.Format
, pPattern
->ValueFormat
.Info
, nKey
);
1373 rItemSet
.Put( SfxUInt32Item( ATTR_VALUE_FORMAT
, ( UINT32
) nKey
) );
1376 // Zellattribute (Schutz, Versteckt...)
1377 if( ( pPattern
->Flags
!= 0 ) &&
1378 ( ( pPattern
->FormatFlags
& pfProtection
) == pfProtection
) )
1380 BOOL bProtect
= ( ( pPattern
->Flags
& paProtect
) == paProtect
);
1381 BOOL bHFormula
= ( ( pPattern
->Flags
& paHideFormula
) == paHideFormula
);
1382 BOOL bHCell
= ( ( pPattern
->Flags
& paHideAll
) == paHideAll
);
1383 BOOL bHPrint
= ( ( pPattern
->Flags
& paHidePrint
) == paHidePrint
);
1384 rItemSet
.Put( ScProtectionAttr( bProtect
, bHFormula
, bHCell
, bHPrint
) );
1387 } // for (i = 0; i < GetCount()
1391 void Sc10Import::LoadDataBaseCollection()
1393 pDataBaseCollection
= new Sc10DataBaseCollection(rStream
);
1394 for( USHORT i
= 0 ; i
< pDataBaseCollection
->GetCount() ; i
++ )
1396 Sc10DataBaseData
* pOldData
= pDataBaseCollection
->At(i
);
1397 ScDBData
* pNewData
= new ScDBData( SC10TOSTRING( pOldData
->DataBaseRec
.Name
),
1398 ( SCTAB
) pOldData
->DataBaseRec
.Tab
,
1399 ( SCCOL
) pOldData
->DataBaseRec
.Block
.x1
,
1400 ( SCROW
) pOldData
->DataBaseRec
.Block
.y1
,
1401 ( SCCOL
) pOldData
->DataBaseRec
.Block
.x2
,
1402 ( SCROW
) pOldData
->DataBaseRec
.Block
.y2
,
1404 ( BOOL
) pOldData
->DataBaseRec
.RowHeader
);
1405 pDoc
->GetDBCollection()->Insert( pNewData
);
1410 void Sc10Import::LoadTables()
1412 Sc10PageCollection aPageCollection
;
1415 rStream
>> nTabCount
;
1416 for (INT16 Tab
= 0; (Tab
< nTabCount
) && (nError
== 0); Tab
++)
1418 Sc10PageFormat PageFormat
;
1419 INT16 DataBaseIndex
;
1420 Sc10TableProtect TabProtect
;
1422 sal_Char TabName
[128];
1432 String aStr
; // Universal-Konvertierungs-String
1435 //rStream.Read(&PageFormat, sizeof(PageFormat));
1436 lcl_ReadPageFormat(rStream
, PageFormat
);
1438 USHORT nAt
= aPageCollection
.InsertFormat(PageFormat
);
1439 String aPageName
= lcl_MakeOldPageStyleFormatName( nAt
);
1441 pPrgrsBar
->Progress();
1443 rStream
>> DataBaseIndex
;
1445 //rStream.Read(&TabProtect, sizeof(TabProtect));
1446 lcl_ReadTabProtect(rStream
, TabProtect
);
1448 ScTableProtection aProtection
;
1449 aProtection
.setProtected(static_cast<bool>(TabProtect
.Protect
));
1450 aProtection
.setPassword(SC10TOSTRING(TabProtect
.PassWord
));
1451 pDoc
->SetTabProtection(static_cast<SCTAB
>(Tab
), &aProtection
);
1457 rStream
.Read(TabName
, sizeof(TabName
) - 1);
1460 //----------------------------------------------------------
1463 if ( Tab
== (INT16
)nShowTab
)
1465 ScVObjMode eObjMode
= VOBJ_MODE_SHOW
;
1467 aSc30ViewOpt
.SetOption( VOPT_FORMULAS
, IS_SET(dfFormula
,Display
) );
1468 aSc30ViewOpt
.SetOption( VOPT_NULLVALS
, IS_SET(dfZerro
,Display
) );
1469 aSc30ViewOpt
.SetOption( VOPT_SYNTAX
, IS_SET(dfSyntax
,Display
) );
1470 aSc30ViewOpt
.SetOption( VOPT_NOTES
, IS_SET(dfNoteMark
,Display
) );
1471 aSc30ViewOpt
.SetOption( VOPT_VSCROLL
, TRUE
);
1472 aSc30ViewOpt
.SetOption( VOPT_HSCROLL
, TRUE
);
1473 aSc30ViewOpt
.SetOption( VOPT_TABCONTROLS
, TRUE
);
1474 aSc30ViewOpt
.SetOption( VOPT_OUTLINER
, TRUE
);
1475 aSc30ViewOpt
.SetOption( VOPT_GRID
, IS_SET(dfGrid
,Display
) );
1477 // VOPT_HEADER wird in LoadViewColRowBar() gesetzt
1479 if ( IS_SET(dfObjectAll
,Display
) ) // Objekte anzeigen
1480 eObjMode
= VOBJ_MODE_SHOW
;
1481 else if ( IS_SET(dfObjectFrame
,Display
) ) // Objekte als Platzhalter
1482 eObjMode
= VOBJ_MODE_SHOW
;
1483 else if ( IS_SET(dfObjectNone
,Display
) ) // Objekte nicht anzeigen
1484 eObjMode
= VOBJ_MODE_HIDE
;
1486 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_OLE
, eObjMode
);
1487 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_CHART
, eObjMode
);
1488 aSc30ViewOpt
.SetObjMode( VOBJ_TYPE_DRAW
, eObjMode
);
1491 /* wofuer wird das benoetigt? Da in SC 1.0 die Anzeigeflags pro Tabelle gelten und nicht pro View
1492 Dieses Flag in die ViewOptions eintragen bei Gelegenheit, Sollte der Stephan Olk machen
1493 USHORT nDisplayMask = 0xFFFF;
1494 USHORT nDisplayValue = 0;
1496 nDisplayValue = Display;
1499 USHORT nDiff = Display ^ nDisplayValue;
1500 nDisplayMask &= ~nDiff;
1503 //--------------------------------------------------------------------
1506 nError
= rStream
.GetError();
1507 if (nError
!= 0) return;
1510 pDoc
->RenameTab(static_cast<SCTAB
> (TabNo
), SC10TOSTRING( TabName
), FALSE
);
1512 pDoc
->InsertTab(SC_TAB_APPEND
, SC10TOSTRING( TabName
) );
1514 pDoc
->SetPageStyle( static_cast<SCTAB
>(Tab
), aPageName
);
1516 if (Visible
== 0) pDoc
->SetVisible(static_cast<SCTAB
> (TabNo
), FALSE
);
1520 if (ID
!= ColWidthID
)
1522 DBG_ERROR( "ColWidthID" );
1523 nError
= errUnknownID
;
1526 rStream
>> DataCount
;
1528 for (i
=0; i
< DataCount
; i
++)
1531 rStream
>> DataValue
;
1532 for (SCCOL j
= static_cast<SCCOL
>(DataStart
); j
<= static_cast<SCCOL
>(DataEnd
); j
++) pDoc
->SetColWidth(j
, static_cast<SCTAB
> (TabNo
), DataValue
);
1533 DataStart
= DataEnd
+ 1;
1535 pPrgrsBar
->Progress();
1539 if (ID
!= ColAttrID
)
1541 DBG_ERROR( "ColAttrID" );
1542 nError
= errUnknownID
;
1546 rStream
>> DataCount
;
1548 for (i
=0; i
< DataCount
; i
++)
1551 rStream
>> DataValue
;
1554 bool bPageBreak
= ((DataValue
& crfSoftBreak
) == crfSoftBreak
);
1555 bool bManualBreak
= ((DataValue
& crfHardBreak
) == crfHardBreak
);
1556 bool bHidden
= ((DataValue
& crfHidden
) == crfHidden
);
1557 for (SCCOL k
= static_cast<SCCOL
>(DataStart
); k
<= static_cast<SCCOL
>(DataEnd
); k
++)
1559 pDoc
->SetColHidden(k
, k
, static_cast<SCTAB
>(TabNo
), bHidden
);
1560 pDoc
->SetColBreak(k
, static_cast<SCTAB
> (TabNo
), bPageBreak
, bManualBreak
);
1563 DataStart
= DataEnd
+ 1;
1565 pPrgrsBar
->Progress();
1569 if (ID
!= RowHeightID
)
1571 DBG_ERROR( "RowHeightID" );
1572 nError
= errUnknownID
;
1576 rStream
>> DataCount
;
1578 for (i
=0; i
< DataCount
; i
++)
1581 rStream
>> DataValue
;
1582 pDoc
->SetRowHeightRange(static_cast<SCROW
> (DataStart
), static_cast<SCROW
> (DataEnd
), static_cast<SCTAB
> (TabNo
), DataValue
);
1583 DataStart
= DataEnd
+ 1;
1585 pPrgrsBar
->Progress();
1589 if (ID
!= RowAttrID
)
1591 DBG_ERROR( "RowAttrID" );
1592 nError
= errUnknownID
;
1596 rStream
>> DataCount
;
1598 for (i
=0; i
< DataCount
; i
++)
1601 rStream
>> DataValue
;
1604 bool bPageBreak
= ((DataValue
& crfSoftBreak
) == crfSoftBreak
);
1605 bool bManualBreak
= ((DataValue
& crfHardBreak
) == crfHardBreak
);
1606 bool bHidden
= ((DataValue
& crfHidden
) == crfHidden
);
1607 for (SCROW l
= static_cast<SCROW
>(DataStart
); l
<= static_cast<SCROW
>(DataEnd
); l
++)
1609 pDoc
->SetRowHidden(l
, l
, static_cast<SCTAB
> (TabNo
), bHidden
);
1610 pDoc
->SetRowBreak(l
, static_cast<SCTAB
> (TabNo
), bPageBreak
, bManualBreak
);
1613 DataStart
= DataEnd
+ 1;
1615 pPrgrsBar
->Progress();
1621 DBG_ERROR( "TableID" );
1622 nError
= errUnknownID
;
1625 for (SCCOL Col
= 0; (Col
<= SC10MAXCOL
) && (nError
== 0); Col
++)
1628 nError
= rStream
.GetError();
1629 if ((Count
!= 0) && (nError
== 0))
1630 LoadCol(Col
, static_cast<SCTAB
> (TabNo
));
1632 DBG_ASSERT( nError
== 0, "Stream" );
1634 pPrgrsBar
->Progress();
1636 aPageCollection
.PutToDoc( pDoc
);
1640 void Sc10Import::LoadCol(SCCOL Col
, SCTAB Tab
)
1642 LoadColAttr(Col
, Tab
);
1647 rStream
>> CellCount
;
1648 SCROW nScCount
= static_cast< SCROW
>( CellCount
);
1649 if (nScCount
> MAXROW
) nError
= errUnknownFormat
;
1650 for (USHORT i
= 0; (i
< CellCount
) && (nError
== 0); i
++)
1652 rStream
>> CellType
;
1654 nError
= rStream
.GetError();
1661 const SfxPoolItem
* pValueFormat
= pDoc
->GetAttr(Col
, static_cast<SCROW
> (Row
), Tab
, ATTR_VALUE_FORMAT
);
1662 ULONG nFormat
= ((SfxUInt32Item
*)pValueFormat
)->GetValue();
1663 double Value
= ScfTools::ReadLongDouble(rStream
);
1664 //rStream.Read(&Value, sizeof(Value));
1666 // Achtung hier ist eine Anpassung Notwendig wenn Ihr das Basisdatum aendert
1667 // In StarCalc 1.0 entspricht 0 dem 01.01.1900
1668 // if ((nFormat >= 30) && (nFormat <= 35))
1670 if ((nFormat
>= 40) && (nFormat
<= 45))
1672 pDoc
->SetValue(Col
, static_cast<SCROW
> (Row
), Tab
, Value
);
1680 rStream
.Read(s
, Len
);
1683 pDoc
->SetString( Col
, static_cast<SCROW
> (Row
), Tab
, SC10TOSTRING( s
) );
1688 /*double Value =*/ ScfTools::ReadLongDouble(rStream
);
1691 //rStream.Read(&Value, sizeof(Value));
1693 rStream
.Read(&s
[1], Len
);
1696 ScFormulaCell
* pCell
= new ScFormulaCell( pDoc
, ScAddress( Col
, static_cast<SCROW
> (Row
), Tab
) );
1697 pCell
->SetHybridFormula( SC10TOSTRING( s
),formula::FormulaGrammar::GRAM_NATIVE
);
1698 pDoc
->PutCell( Col
, static_cast<SCROW
> (Row
), Tab
, pCell
, (BOOL
)TRUE
);
1704 nError
= errUnknownFormat
;
1711 sal_Char
* pNote
= new sal_Char
[NoteLen
+1];
1712 rStream
.Read(pNote
, NoteLen
);
1714 String
aNoteText( SC10TOSTRING(pNote
));
1716 ScAddress
aPos( Col
, static_cast<SCROW
>(Row
), Tab
);
1717 ScNoteUtil::CreateNoteFromString( *pDoc
, aPos
, aNoteText
, false, false );
1720 pPrgrsBar
->Progress();
1725 void Sc10Import::LoadColAttr(SCCOL Col
, SCTAB Tab
)
1729 Sc10ColAttr aJustify
;
1731 Sc10ColAttr aRaster
;
1734 Sc10ColAttr aFrameColor
;
1736 Sc10ColAttr aPattern
;
1738 if (nError
== 0) LoadAttr(aFont
);
1739 if (nError
== 0) LoadAttr(aAttr
);
1740 if (nError
== 0) LoadAttr(aJustify
);
1741 if (nError
== 0) LoadAttr(aFrame
);
1742 if (nError
== 0) LoadAttr(aRaster
);
1743 if (nError
== 0) LoadAttr(aValue
);
1744 if (nError
== 0) LoadAttr(aColor
);
1745 if (nError
== 0) LoadAttr(aFrameColor
);
1746 if (nError
== 0) LoadAttr(aFlag
);
1747 if (nError
== 0) LoadAttr(aPattern
);
1756 Sc10ColData
*pColData
;
1758 // Font (Name, Groesse)
1761 nLimit
= aFont
.Count
;
1762 pColData
= aFont
.pData
;
1763 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1765 //nEnd = aFont.pData[i].Row;
1766 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1767 //if ((nStart <= nEnd) && (aFont.pData[i].Value != 0))
1768 if ((nStart
<= nEnd
) && (pColData
->Value
))
1770 FontFamily eFam
= FAMILY_DONTKNOW
;
1771 //Sc10FontData* pFont = pFontCollection->At(aFont.pData[i].Value);
1772 Sc10FontData
* pFont
= pFontCollection
->At(pColData
->Value
);
1773 switch (pFont
->PitchAndFamily
& 0xF0)
1775 case ffDontCare
: eFam
= FAMILY_DONTKNOW
; break;
1776 case ffRoman
: eFam
= FAMILY_ROMAN
; break;
1777 case ffSwiss
: eFam
= FAMILY_SWISS
; break;
1778 case ffModern
: eFam
= FAMILY_MODERN
; break;
1779 case ffScript
: eFam
= FAMILY_SCRIPT
; break;
1780 case ffDecorative
: eFam
= FAMILY_DECORATIVE
; break;
1781 default: eFam
= FAMILY_DONTKNOW
; break;
1783 ScPatternAttr
aScPattern(pDoc
->GetPool());
1784 aScPattern
.GetItemSet().Put(SvxFontItem(eFam
, SC10TOSTRING( pFont
->FaceName
), EMPTY_STRING
,
1785 PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
));
1786 aScPattern
.GetItemSet().Put(SvxFontHeightItem(Abs(pFont
->Height
), 100, ATTR_FONT_HEIGHT
));
1787 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1795 nLimit
= aColor
.Count
;
1796 pColData
= aColor
.pData
;
1797 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1799 //nEnd = aColor.pData[i].Row;
1800 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1801 //if ((nStart <= nEnd) && (aColor.pData[i].Value != 0))
1802 if ((nStart
<= nEnd
) && (pColData
->Value
))
1804 Color
TextColor(COL_BLACK
);
1805 lcl_ChangeColor((pColData
->Value
& 0x000F), TextColor
);
1806 ScPatternAttr
aScPattern(pDoc
->GetPool());
1807 aScPattern
.GetItemSet().Put(SvxColorItem(TextColor
, ATTR_FONT_COLOR
));
1808 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1813 // Fontattribute (Fett, Kursiv...)
1816 nLimit
= aAttr
.Count
;
1817 pColData
= aAttr
.pData
;
1818 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1820 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1821 nValue1
= pColData
->Value
;
1822 if ((nStart
<= nEnd
) && (nValue1
))
1824 ScPatternAttr
aScPattern(pDoc
->GetPool());
1825 if ((nValue1
& atBold
) == atBold
)
1826 aScPattern
.GetItemSet().Put(SvxWeightItem(WEIGHT_BOLD
, ATTR_FONT_WEIGHT
));
1827 if ((nValue1
& atItalic
) == atItalic
)
1828 aScPattern
.GetItemSet().Put(SvxPostureItem(ITALIC_NORMAL
, ATTR_FONT_POSTURE
));
1829 if ((nValue1
& atUnderline
) == atUnderline
)
1830 aScPattern
.GetItemSet().Put(SvxUnderlineItem(UNDERLINE_SINGLE
, ATTR_FONT_UNDERLINE
));
1831 if ((nValue1
& atStrikeOut
) == atStrikeOut
)
1832 aScPattern
.GetItemSet().Put(SvxCrossedOutItem(STRIKEOUT_SINGLE
, ATTR_FONT_CROSSEDOUT
));
1833 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1841 nLimit
= aJustify
.Count
;
1842 pColData
= aJustify
.pData
;
1843 for( i
= 0 ; i
< nLimit
; i
++, pColData
++ )
1845 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1846 nValue1
= pColData
->Value
;
1847 if ((nStart
<= nEnd
) && (nValue1
))
1849 ScPatternAttr
aScPattern(pDoc
->GetPool());
1850 USHORT HorJustify
= (nValue1
& 0x000F);
1851 USHORT VerJustify
= (nValue1
& 0x00F0) >> 4;
1852 USHORT OJustify
= (nValue1
& 0x0F00) >> 8;
1853 USHORT EJustify
= (nValue1
& 0xF000) >> 12;
1858 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_LEFT
, ATTR_HOR_JUSTIFY
));
1861 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_CENTER
, ATTR_HOR_JUSTIFY
));
1864 aScPattern
.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT
, ATTR_HOR_JUSTIFY
));
1871 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_TOP
, ATTR_VER_JUSTIFY
));
1874 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_CENTER
, ATTR_VER_JUSTIFY
));
1877 aScPattern
.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_BOTTOM
, ATTR_VER_JUSTIFY
));
1881 if (OJustify
& ojWordBreak
)
1882 aScPattern
.GetItemSet().Put(SfxBoolItem(TRUE
));
1883 if (OJustify
& ojBottomTop
)
1884 aScPattern
.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE
,9000));
1885 else if (OJustify
& ojTopBottom
)
1886 aScPattern
.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE
,27000));
1888 INT16 Margin
= Max((USHORT
)20, (USHORT
)(EJustify
* 20));
1889 if (((OJustify
& ojBottomTop
) == ojBottomTop
) || ((OJustify
& ojBottomTop
) == ojBottomTop
))
1890 aScPattern
.GetItemSet().Put(SvxMarginItem(20, Margin
, 20, Margin
, ATTR_MARGIN
));
1892 aScPattern
.GetItemSet().Put(SvxMarginItem(Margin
, 20, Margin
, 20, ATTR_MARGIN
));
1893 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
1899 USHORT nColorIndex
= 0;
1900 USHORT nFrameIndex
= 0;
1903 const UINT32 nHelpMeStart
= 100;
1904 UINT32 nHelpMe
= nHelpMeStart
;
1905 USHORT nColorIndexOld
= nColorIndex
;
1906 USHORT nFrameIndexOld
= nColorIndex
;
1910 while( !bEnd
&& nHelpMe
)
1912 pColData
= &aFrame
.pData
[ nFrameIndex
];
1914 USHORT nValue
= pColData
->Value
;
1919 USHORT fLeft
= ( nValue
& 0x000F );
1920 USHORT fTop
= ( nValue
& 0x00F0 ) >> 4;
1921 USHORT fRight
= ( nValue
& 0x0F00 ) >> 8;
1922 USHORT fBottom
= ( nValue
& 0xF000 ) >> 12;
1926 else if( fLeft
> 0 )
1936 else if( fRight
> 0 )
1941 else if( fBottom
> 0 )
1944 Color
ColorLeft( COL_BLACK
);
1945 Color
ColorTop( COL_BLACK
);
1946 Color
ColorRight( COL_BLACK
);
1947 Color
ColorBottom( COL_BLACK
);
1948 USHORT nFrmColVal
= aFrameColor
.pData
[ nColorIndex
].Value
;
1949 SCROW nFrmColRow
= static_cast<SCROW
>(aFrameColor
.pData
[ nColorIndex
].Row
);
1950 USHORT cLeft
= ( nFrmColVal
& 0x000F );
1951 USHORT cTop
= ( nFrmColVal
& 0x00F0 ) >> 4;
1952 USHORT cRight
= ( nFrmColVal
& 0x0F00 ) >> 8;
1953 USHORT cBottom
= ( nFrmColVal
& 0xF000 ) >> 12;
1955 lcl_ChangeColor( cLeft
, ColorLeft
);
1956 lcl_ChangeColor( cTop
, ColorTop
);
1957 lcl_ChangeColor( cRight
, ColorRight
);
1958 lcl_ChangeColor( cBottom
, ColorBottom
);
1960 if( static_cast<SCROW
>(pColData
->Row
) < nFrmColRow
)
1962 nEnd
= static_cast<SCROW
>(pColData
->Row
);
1963 if( nFrameIndex
< ( aFrame
.Count
- 1 ) )
1966 else if( static_cast<SCROW
>(pColData
->Row
) > nFrmColRow
)
1968 nEnd
= static_cast<SCROW
>(aFrameColor
.pData
[ nColorIndex
].Row
);
1969 if( nColorIndex
< ( aFrameColor
.Count
- 1 ) )
1975 if( nFrameIndex
< (aFrame
.Count
- 1 ) )
1977 if( nColorIndex
< ( aFrameColor
.Count
- 1 ) )
1980 if( ( nStart
<= nEnd
) && ( nValue
!= 0 ) )
1982 ScPatternAttr
aScPattern(pDoc
->GetPool());
1983 SvxBorderLine aLine
;
1984 SvxBoxItem
aBox( ATTR_BORDER
);
1986 aLine
.SetOutWidth( nLeft
);
1987 aLine
.SetColor( ColorLeft
);
1988 aBox
.SetLine( &aLine
, BOX_LINE_LEFT
);
1990 aLine
.SetOutWidth( nTop
);
1991 aLine
.SetColor( ColorTop
);
1992 aBox
.SetLine( &aLine
, BOX_LINE_TOP
);
1994 aLine
.SetOutWidth( nRight
);
1995 aLine
.SetColor( ColorRight
);
1996 aBox
.SetLine( &aLine
, BOX_LINE_RIGHT
);
1998 aLine
.SetOutWidth( nBottom
);
1999 aLine
.SetColor( ColorBottom
);
2000 aBox
.SetLine( &aLine
, BOX_LINE_BOTTOM
);
2002 aScPattern
.GetItemSet().Put( aBox
);
2003 pDoc
->ApplyPatternAreaTab( Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2007 bEnd
= ( nFrameIndex
== ( aFrame
.Count
- 1 ) ) && ( nColorIndex
== ( aFrameColor
.Count
- 1 ) );
2009 if( nColorIndexOld
!= nColorIndex
|| nFrameIndexOld
!= nFrameIndex
)
2011 nColorIndexOld
= nColorIndex
;
2012 nFrameIndexOld
= nFrameIndex
;
2013 nHelpMe
= nHelpMeStart
;
2021 // ACHTUNG: Code bis hier ueberarbeitet ... jetzt hab' ich keinen Bock mehr! (GT)
2023 // Hintergrund (Farbe, Raster)
2024 USHORT nRasterIndex
= 0;
2031 nHelpMe
= nHelpMeStart
;
2032 USHORT nRasterIndexOld
= nRasterIndex
;
2034 while( !bEnd
&& nHelpMe
)
2036 USHORT nBColor
= ( aColor
.pData
[ nColorIndex
].Value
& 0x00F0 ) >> 4;
2037 USHORT nRColor
= ( aColor
.pData
[ nColorIndex
].Value
& 0x0F00 ) >> 8;
2038 Color
aBColor( COL_BLACK
);
2040 lcl_ChangeColor( nBColor
, aBColor
);
2043 aBColor
.SetColor( COL_WHITE
);
2044 else if( nBColor
== 15 )
2045 aBColor
.SetColor( COL_BLACK
);
2047 Color
aRColor( COL_BLACK
);
2049 lcl_ChangeColor( nRColor
, aRColor
);
2051 ScPatternAttr
aScPattern( pDoc
->GetPool() );
2054 BOOL bSwapCol
= FALSE
;
2055 BOOL bSetItem
= TRUE
;
2056 switch ( aRaster
.pData
[ nRasterIndex
].Value
)
2058 case raNone
: nFact
= 0xffff; bSwapCol
= TRUE
; bSetItem
= (nBColor
> 0); break;
2059 case raGray12
: nFact
= (0xffff / 100) * 12; break;
2060 case raGray25
: nFact
= (0xffff / 100) * 25; break;
2061 case raGray50
: nFact
= (0xffff / 100) * 50; break;
2062 case raGray75
: nFact
= (0xffff / 100) * 75; break;
2063 default: nFact
= 0xffff; bSetItem
= (nRColor
< 15);
2068 aScPattern
.GetItemSet().Put( SvxBrushItem( GetMixedColor( aBColor
, aRColor
, nFact
), ATTR_BACKGROUND
) );
2070 aScPattern
.GetItemSet().Put( SvxBrushItem( GetMixedColor( aRColor
, aBColor
, nFact
), ATTR_BACKGROUND
) );
2072 if( aRaster
.pData
[ nRasterIndex
].Row
< aColor
.pData
[ nColorIndex
].Row
)
2074 nEnd
= static_cast<SCROW
>(aRaster
.pData
[ nRasterIndex
].Row
);
2075 if( nRasterIndex
< ( aRaster
.Count
- 1 ) )
2078 else if( aRaster
.pData
[ nRasterIndex
].Row
> aColor
.pData
[ nColorIndex
].Row
)
2080 nEnd
= static_cast<SCROW
>(aColor
.pData
[ nColorIndex
].Row
);
2081 if( nColorIndex
< ( aColor
.Count
- 1 ) )
2086 nEnd
= static_cast<SCROW
>(aColor
.pData
[ nColorIndex
].Row
);
2087 if( nRasterIndex
< ( aRaster
.Count
- 1 ) )
2089 if( nColorIndex
< ( aColor
.Count
- 1 ) )
2092 if( nStart
<= nEnd
)
2093 pDoc
->ApplyPatternAreaTab( Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2097 bEnd
= ( nRasterIndex
== ( aRaster
.Count
- 1 ) ) && ( nColorIndex
== ( aColor
.Count
- 1 ) );
2099 if( nColorIndexOld
!= nColorIndex
|| nRasterIndexOld
!= nRasterIndex
)
2101 nColorIndexOld
= nColorIndex
;
2102 nRasterIndexOld
= nRasterIndex
;
2103 nHelpMe
= nHelpMeStart
;
2114 nLimit
= aValue
.Count
;
2115 pColData
= aValue
.pData
;
2116 for (i
=0; i
<nLimit
; i
++, pColData
++)
2118 nEnd
= static_cast<SCROW
>(pColData
->Row
);
2119 nValue1
= pColData
->Value
;
2120 if ((nStart
<= nEnd
) && (nValue1
))
2123 USHORT nFormat
= (nValue1
& 0x00FF);
2124 USHORT nInfo
= (nValue1
& 0xFF00) >> 8;
2125 ChangeFormat(nFormat
, nInfo
, nKey
);
2126 ScPatternAttr
aScPattern(pDoc
->GetPool());
2127 aScPattern
.GetItemSet().Put(SfxUInt32Item(ATTR_VALUE_FORMAT
, (UINT32
)nKey
));
2128 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2133 // Zellattribute (Schutz, Versteckt...)
2136 for (i
=0; i
<aFlag
.Count
; i
++)
2138 nEnd
= static_cast<SCROW
>(aFlag
.pData
[i
].Row
);
2139 if ((nStart
<= nEnd
) && (aFlag
.pData
[i
].Value
!= 0))
2141 BOOL bProtect
= ((aFlag
.pData
[i
].Value
& paProtect
) == paProtect
);
2142 BOOL bHFormula
= ((aFlag
.pData
[i
].Value
& paHideFormula
) == paHideFormula
);
2143 BOOL bHCell
= ((aFlag
.pData
[i
].Value
& paHideAll
) == paHideAll
);
2144 BOOL bHPrint
= ((aFlag
.pData
[i
].Value
& paHidePrint
) == paHidePrint
);
2145 ScPatternAttr
aScPattern(pDoc
->GetPool());
2146 aScPattern
.GetItemSet().Put(ScProtectionAttr(bProtect
, bHFormula
, bHCell
, bHPrint
));
2147 pDoc
->ApplyPatternAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, aScPattern
);
2155 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
2156 for (i
=0; i
<aPattern
.Count
; i
++)
2158 nEnd
= static_cast<SCROW
>(aPattern
.pData
[i
].Row
);
2159 if ((nStart
<= nEnd
) && (aPattern
.pData
[i
].Value
!= 0))
2161 USHORT nPatternIndex
= (aPattern
.pData
[i
].Value
& 0x00FF) - 1;
2162 Sc10PatternData
* pPattern
= pPatternCollection
->At(nPatternIndex
);
2163 if (pPattern
!= NULL
)
2165 ScStyleSheet
* pStyle
= (ScStyleSheet
*) pStylePool
->Find(
2166 SC10TOSTRING( pPattern
->Name
), SFX_STYLE_FAMILY_PARA
);
2169 pDoc
->ApplyStyleAreaTab(Col
, nStart
, Col
, nEnd
, Tab
, *pStyle
);
2176 delete[] aFont
.pData
;
2177 delete[] aAttr
.pData
;
2178 delete[] aJustify
.pData
;
2179 delete[] aFrame
.pData
;
2180 delete[] aRaster
.pData
;
2181 delete[] aValue
.pData
;
2182 delete[] aColor
.pData
;
2183 delete[] aFrameColor
.pData
;
2184 delete[] aFlag
.pData
;
2185 delete[] aPattern
.pData
;
2189 void Sc10Import::LoadAttr(Sc10ColAttr
& rAttr
)
2191 rStream
>> rAttr
.Count
;
2192 rAttr
.pData
= new Sc10ColData
[rAttr
.Count
];
2193 if (rAttr
.pData
!= NULL
)
2195 for (USHORT i
= 0; i
< rAttr
.Count
; i
++)
2197 rStream
>> rAttr
.pData
[i
].Row
;
2198 rStream
>> rAttr
.pData
[i
].Value
;
2200 //rStream.Read(rAttr.pData, rAttr.Count * sizeof(Sc10ColData));
2201 nError
= rStream
.GetError();
2204 nError
= errOutOfMemory
;
2208 void Sc10Import::ChangeFormat(USHORT nFormat
, USHORT nInfo
, ULONG
& nKey
)
2210 // Achtung: Die Formate werden nur auf die StarCalc 3.0 internen Formate gemappt
2211 // Korrekterweise muessten zum Teil neue Formate erzeugt werden (sollte Stephan sich ansehen)
2241 // Achtung kein Aequivalent
2264 case df_NDMY_Short
:
2316 case vfStandardRed
:
2326 case vfThousendRed
:
2338 case vfExponentRed
:
2351 void Sc10Import::LoadObjects()
2355 if (rStream
.IsEof()) return;
2358 #ifdef SC10_SHOW_OBJECTS
2359 // Achtung nur zu Debugzwecken
2360 //-----------------------------------
2361 pDoc
->InsertTab(SC_TAB_APPEND
, "GraphObjects");
2365 pDoc
->GetTable("GraphObjects", nTab
);
2366 pDoc
->SetString(nCol
++, nRow
, nTab
, "ObjectTyp");
2367 pDoc
->SetString(nCol
++, nRow
, nTab
, "Col");
2368 pDoc
->SetString(nCol
++, nRow
, nTab
, "Row");
2369 pDoc
->SetString(nCol
++, nRow
, nTab
, "Tab");
2370 pDoc
->SetString(nCol
++, nRow
, nTab
, "X");
2371 pDoc
->SetString(nCol
++, nRow
, nTab
, "Y");
2372 pDoc
->SetString(nCol
++, nRow
, nTab
, "W");
2373 pDoc
->SetString(nCol
++, nRow
, nTab
, "H");
2374 //-----------------------------------
2379 sal_Char Reserved
[32];
2380 rStream
.Read(Reserved
, sizeof(Reserved
));
2381 nError
= rStream
.GetError();
2382 if ((nAnz
> 0) && (nError
== 0))
2385 Sc10GraphHeader GraphHeader
;
2386 BOOL IsOleObject
= FALSE
; // Achtung dies ist nur ein Notnagel
2387 for (USHORT i
= 0; (i
< nAnz
) && (nError
== 0) && !rStream
.IsEof() && !IsOleObject
; i
++)
2389 rStream
>> ObjectType
;
2390 //rStream.Read(&GraphHeader, sizeof(GraphHeader));
2391 lcl_ReadGraphHeader(rStream
, GraphHeader
);
2393 double nPPTX
= ScGlobal::nScreenPPTX
;
2394 double nPPTY
= ScGlobal::nScreenPPTY
;
2397 for (SCsCOL nX
=0; nX
<GraphHeader
.CarretX
; nX
++)
2398 nStartX
+= pDoc
->GetColWidth(nX
, static_cast<SCTAB
>(GraphHeader
.CarretZ
));
2399 nStartX
= (long) ( nStartX
* HMM_PER_TWIPS
);
2400 nStartX
+= (long) ( GraphHeader
.x
/ nPPTX
* HMM_PER_TWIPS
);
2401 long nSizeX
= (long) ( GraphHeader
.w
/ nPPTX
* HMM_PER_TWIPS
);
2402 long nStartY
= pDoc
->FastGetRowHeight( 0,
2403 static_cast<SCsROW
>(GraphHeader
.CarretY
) - 1,
2404 static_cast<SCTAB
>(GraphHeader
.CarretZ
));
2405 nStartY
= (long) ( nStartY
* HMM_PER_TWIPS
);
2406 nStartY
+= (long) ( GraphHeader
.y
/ nPPTY
* HMM_PER_TWIPS
);
2407 long nSizeY
= (long) ( GraphHeader
.h
/ nPPTY
* HMM_PER_TWIPS
);
2409 #ifdef SC10_SHOW_OBJECTS
2410 // Achtung nur zu Debugzwecken
2411 //-----------------------------------
2417 pDoc
->SetString(nCol
++, nRow
, nTab
, "Ole-Object");
2420 pDoc
->SetString(nCol
++, nRow
, nTab
, "Image-Object");
2423 pDoc
->SetString(nCol
++, nRow
, nTab
, "Chart-Object");
2426 pDoc
->SetString(nCol
++, nRow
, nTab
, "ERROR");
2429 pDoc
->SetValue(nCol
++, nRow
, nTab
, GraphHeader
.CarretX
);
2430 pDoc
->SetValue(nCol
++, nRow
, nTab
, GraphHeader
.CarretY
);
2431 pDoc
->SetValue(nCol
++, nRow
, nTab
, GraphHeader
.CarretZ
);
2432 pDoc
->SetValue(nCol
++, nRow
, nTab
, GraphHeader
.x
);
2433 pDoc
->SetValue(nCol
++, nRow
, nTab
, GraphHeader
.y
);
2434 pDoc
->SetValue(nCol
++, nRow
, nTab
, GraphHeader
.w
);
2435 pDoc
->SetValue(nCol
++, nRow
, nTab
, GraphHeader
.h
);
2436 //-----------------------------------
2442 // Achtung hier muss sowas wie OleLoadFromStream passieren
2447 Sc10ImageHeader ImageHeader
;
2448 //rStream.Read(&ImageHeader, sizeof(ImageHeader));
2449 lcl_ReadImageHeaer(rStream
, ImageHeader
);
2451 // Achtung nun kommen die Daten (Bitmap oder Metafile)
2452 // Typ = 1 Device Dependend Bitmap DIB
2454 rStream
.SeekRel(ImageHeader
.Size
);
2456 if( ImageHeader
.Typ
!= 1 && ImageHeader
.Typ
!= 2 )
2457 nError
= errUnknownFormat
;
2462 Sc10ChartHeader ChartHeader
;
2463 Sc10ChartSheetData ChartSheetData
;
2464 Sc10ChartTypeData
* pTypeData
= new Sc10ChartTypeData
;
2465 //rStream.Read(&ChartHeader, sizeof(ChartHeader));
2466 lcl_ReadChartHeader(rStream
, ChartHeader
);
2468 //! altes Metafile verwenden ??
2469 rStream
.SeekRel(ChartHeader
.Size
);
2471 //rStream.Read(&ChartSheetData, sizeof(ChartSheetData));
2472 lcl_ReadChartSheetData(rStream
, ChartSheetData
);
2474 //rStream.Read(pTypeData, sizeof(Sc10ChartTypeData));
2475 lcl_ReadChartTypeData(rStream
, *pTypeData
);
2477 Rectangle
aRect( Point(nStartX
,nStartY
), Size(nSizeX
,nSizeY
) );
2478 Sc10InsertObject::InsertChart( pDoc
, static_cast<SCTAB
>(GraphHeader
.CarretZ
), aRect
,
2479 static_cast<SCTAB
>(GraphHeader
.CarretZ
),
2480 ChartSheetData
.DataX1
, ChartSheetData
.DataY1
,
2481 ChartSheetData
.DataX2
, ChartSheetData
.DataY2
);
2487 nError
= errUnknownFormat
;
2490 nError
= rStream
.GetError();
2496 DBG_ERROR( "ObjectID" );
2497 nError
= errUnknownID
;
2504 //-----------------------------------------------------------------------------------------------
2506 FltError
ScFormatFilterPluginImpl::ScImportStarCalc10( SvStream
& rStream
, ScDocument
* pDocument
)
2508 rStream
.Seek( 0UL );
2509 Sc10Import
aImport( rStream
, pDocument
);
2510 return ( FltError
) aImport
.Import();