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