1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
31 #include "viewopti.hxx"
32 #include "collect.hxx"
33 #include <tools/solar.h>
36 #define errUnknownFormat 1
37 #define errUnknownID 2
38 #define errOutOfMemory 3
40 // Identifiers im FileFormat
52 // Zeilen/Spalten Flags
53 #define crfSoftBreak 1
54 #define crfHardBreak 2
64 #define ffDontCare 0x00
69 #define ffDecorative 0x50
81 // Horizontale Ausrichtung
87 // Vertikale Ausrichtung
94 #define ojWordBreak 0x01
95 #define ojBottomTop 0x02
96 #define ojTopBottom 0x04
108 #define paHideFormula 2
110 #define paHidePrint 8
122 #define vfStandardRed 9
123 #define vfMoneyRed 10
124 #define vfThousendRed 11
125 #define vfPercentRed 12
126 #define vfExponentRed 13
132 #define df_NDMY_Long 0
133 #define df_DMY_Long 1
135 #define df_NDM_Long 3
138 #define df_NDMY_Short 6
139 #define df_DMY_Short 7
140 #define df_MY_Short 8
141 #define df_NDM_Short 9
142 #define df_DM_Short 10
143 #define df_M_Short 11
145 #define df_Q_Short 13
148 #define tf_HMS_Long 0
150 #define tf_HMS_Short 2
151 #define tf_HM_Short 3
153 // Attribute fuer FormatVorlage
156 #define pfJustify 0x04
158 #define pfRaster 0x10
159 #define pfProtection 0x20
161 // Displayflags fuer die Tabelle
162 #define dfFormula 0x0001 // Formeln
163 #define dfZerro 0x0002 // Nullwerte
164 #define dfGrid 0x0004 // Gitternetz
165 #define dfPageBreak 0x0008 // Seitenumbruch
166 #define dfColRowBar 0x0010 // Zeilen/Spalten Koepfe (Dummy)
167 #define dfSyntax 0x0020 // Syntax Highlighting
168 #define dfPrintPage 0x0040 // Druckbildansicht (Dummy)
169 #define dfObjectAll 0x0080 // Objekte anzeigen
170 #define dfObjectFrame 0x0100 // Objekte als Platzhalter
171 #define dfObjectNone 0x0200 // Objekte nicht anzeigen
172 #define dfNoteMark 0x0400 // Notizanzeiger
173 #define dfProtectMark 0x0800 // Schutzanzeiger
176 #define otNone 0 // s.u.
182 #define gtNone 0 // Kann nicht vorkommen
183 #define gtOle 1 // Ole 1.0 Objekt
184 #define gtImage 2 // Image (Bitmap oder Metafile)
185 #define gtChart 3 // Chart
199 struct Sc10ValueFormat
201 BYTE Format
; // Zahl, Waehrung, Prozent etc.
202 BYTE Info
; // Anzahl Nachkommastellen, Anzahl Stellen, bzw. Datums/Zeitformat
218 BYTE lfClipPrecision
;
220 BYTE lfPitchAndFamily
;
221 sal_Char lfFaceName
[32];
223 int operator==( const Sc10LogFont
& rData
) const;
233 int operator==( const Sc10Color
& rColor
) const;
246 struct Sc10DataBaseRec
262 sal_Char QueryString0
[64];
268 sal_Char QueryString1
[64];
274 sal_Char QueryString2
[64];
278 // Kopf/Fusszeilen-Beschreibung
279 struct Sc10HeadFootLine
289 Sc10Color RasterColor
;
290 USHORT FrameColor
; // Nibble Codierte Farben link oben rechts unten
293 int operator==( const Sc10HeadFootLine
& rData
) const;
297 struct Sc10PageFormat
299 Sc10HeadFootLine HeadLine
;
300 Sc10HeadFootLine FootLine
;
318 sal_Char PrintAreaName
[32];
319 Sc10BlockRect PrintArea
;
320 sal_Char PrnZoom
[6]; // Pascal 6 Byte Realzahl
322 INT16 RowRepeatStart
;
324 INT16 ColRepeatStart
;
326 sal_Char Reserved
[26];
328 int operator==( const Sc10PageFormat
& rData
) const;
332 struct Sc10TableProtect
334 sal_Char PassWord
[16];
340 struct Sc10SheetProtect
342 sal_Char PassWord
[16];
347 // Dateikopf StarCalc 1.0 Datei
348 struct Sc10FileHeader
350 sal_Char CopyRight
[30];
352 sal_Char Reserved
[32];
355 // Benutzer-Definierte Datei-Beschreibung
362 sal_Char InfoLabel0
[16];
363 sal_Char InfoLabel1
[16];
364 sal_Char InfoLabel2
[16];
365 sal_Char InfoLabel3
[16];
370 sal_Char CreateAuthor
[64];
371 sal_Char ChangeAuthor
[64];
372 sal_Char PrintAuthor
[64];
373 Sc10DateTime CreateDate
;
374 Sc10DateTime ChangeDate
;
375 Sc10DateTime PrintDate
;
376 sal_uInt32 PageCount
;
377 sal_uInt32 ChartCount
;
378 sal_uInt32 PictureCount
;
379 sal_uInt32 GraphCount
;
381 sal_uInt32 NoteCount
;
382 sal_uInt32 TextCellCount
;
383 sal_uInt32 ValueCellCount
;
384 sal_uInt32 FormulaCellCount
;
385 sal_uInt32 CellCount
;
386 sal_Char Reserved
[52];
389 // Letze Cursorposition
390 struct Sc10EditStateInfo
396 // Linke obere Ecke der Tabelle im Fenster
400 // Ueberfluessig in StarCalc 3.0
402 sal_Char Reserved
[51];
412 // ZellAttribut-Beschreibung
418 Sc10ColAttr() : pData(NULL
) {}
422 struct Sc10GraphHeader
424 BYTE Typ
; // Typ der Grafik (Ole-Objekt, Image (Bitmap oder MetaFile), Chart-Object)
425 INT16 CarretX
; // ZellPosition der Grafik
428 INT32 x
; // x,y Abstand zum Zellrand in Pixel (Pixel weil ich Grafiken in Fenstern ablege)
430 INT32 w
; // w,h Breite und Hoehe in Pixel
432 BYTE IsRelPos
; // Ist die Position relativ zur Zelle oder absolute in der Tabelle
433 BYTE DoPrint
; // Soll die Grafik ausgedruckt werden
434 USHORT FrameType
; // Art der Umrandung um die Grafik (Keine, Einfach, Doppelt, Einfach Dick, Doppelt Dick)
435 BYTE IsTransparent
; // Soll der Hintergrund gezeichnet werden
436 Sc10Color FrameColor
; // Umrandungsfarbe als RGB-Wert
437 Sc10Color BackColor
; // Hintergrundfarbe als RGB-Wert
438 sal_Char Reserved
[32]; // Na was wohl
442 struct Sc10ImageHeader
444 sal_Char FileName
[128]; // Dateiname des urspruenglich eingefuegten Bildes
445 INT16 Typ
; // Typ der Grafik (Bitmap oder Metafile)
446 BYTE Linked
; // Kann nicht vorkommen
447 INT16 x1
; // Urspruengliche Groesse der Grafik (nur fuer Metafiles)
451 sal_uInt32 Size
; // Groesse der Grafik in BYTES
455 struct Sc10ChartHeader
457 INT16 MM
; // Meatfile Struktur MapMode, Breite, Hoehe
460 sal_uInt32 Size
; // Groesse der Grafik in BYTES
464 struct Sc10ChartSheetData
466 BYTE HasTitle
; // Hat das Chart Daten aus der Tabell fuer einen Titel
467 INT16 TitleX
; // Zellposition des Titels
469 BYTE HasSubTitle
; // Hat das Chart Daten aus der Tabell fuer einen Untertitel
470 INT16 SubTitleX
; // Zellposition des Untertitels
472 BYTE HasLeftTitle
; // Hat das Chart Daten aus der Tabelle fuer einen Linken-Titel
473 INT16 LeftTitleX
; // Zellposition des Linken-Titels
475 BYTE HasLegend
; // Hat das Chart Daten aus der Tabelle fuer eine Legende
476 INT16 LegendX1
; // Zellen der Legende
480 BYTE HasLabel
; // Hat das Chart Daten aus der Tabelle fuer die Achsbeschriftung
481 INT16 LabelX1
; // Zellen der Achsbeschriftung
485 INT16 DataX1
; // Zellen der Daten
489 sal_Char Reserved
[64];
492 #define AGPie2D 1 // Pie Chart 2D
493 #define AGPie3D 2 // Pie Chart 3D
494 #define AGBar2D 3 // Bar Chart 2D
495 #define AGBar3D 4 // Bar Chart 3D
496 #define AGGantt 5 // Gantt Diagramm
497 #define AGLine 6 // Line Chart
498 #define AGLogLine 7 // Logarythmic-Coordinate Chart
499 #define AGArea 8 // Area Chart
500 #define AGHLC 11 // High-Low-Close Chart
501 #define AGPolar 10 // Polar-Coordinate Chart
503 typedef sal_Char Sc10ChartText
[30];
505 struct Sc10ChartTypeData
512 sal_Char GraphTitle
[80];
513 sal_Char BottomTitle
[80];
514 INT16 SymbolData
[256];
515 INT16 ColorData
[256];
516 INT16 ThickLines
[256];
517 INT16 PatternData
[256];
518 INT16 LinePatternData
[256];
519 INT16 NumGraphStyles
[11];
521 Sc10ChartText LegendText
[256];
530 Sc10ChartText LabelText
[50];
531 sal_Char LeftTitle
[80];
532 sal_Char Reserved
[4646];
537 class Sc10FontData
: public ScDataObject
543 sal_Char FaceName
[32];
545 Sc10FontData( const Sc10FontData
& rData
) :
546 ScDataObject( rData
),
547 Height( rData
.Height
),
548 CharSet( rData
.CharSet
),
549 PitchAndFamily( rData
.PitchAndFamily
)
551 strncpy( FaceName
, rData
.FaceName
, sizeof(FaceName
) );
552 FaceName
[sizeof(FaceName
)-1] = 0;
554 Sc10FontData( SvStream
& rStream
);
555 virtual ScDataObject
* Clone() const { return new Sc10FontData(*this); }
560 class Sc10FontCollection
: public ScCollection
565 Sc10FontCollection( SvStream
& rStream
);
566 ULONG
GetError() { return nError
; }
567 Sc10FontData
* At(USHORT nIndex
) { return (Sc10FontData
*)ScCollection::At(nIndex
); }
569 using ScCollection::At
;
574 class Sc10NameData
: public ScDataObject
578 sal_Char Reference
[64];
579 sal_Char Reserved
[12];
581 Sc10NameData(const Sc10NameData
& rData
) :
582 ScDataObject( rData
)
584 strncpy(Name
, rData
.Name
, sizeof(Name
));
585 Name
[sizeof(Name
)-1] = 0;
586 strncpy(Reference
, rData
.Reference
, sizeof(Reference
));
587 Reference
[sizeof(Reference
)-1] = 0;
588 memcpy(Reserved
, rData
.Reserved
, sizeof(Reserved
));
590 Sc10NameData(SvStream
& rStream
);
591 virtual ScDataObject
* Clone() const { return new Sc10NameData(*this); }
595 // Bereichs-Collection
596 class Sc10NameCollection
: public ScCollection
601 Sc10NameCollection(SvStream
& rStream
);
602 ULONG
GetError() { return nError
; }
603 Sc10NameData
* At(USHORT nIndex
) { return (Sc10NameData
*)ScCollection::At(nIndex
); }
605 using ScCollection::At
;
610 class Sc10PatternData
: public ScDataObject
614 Sc10ValueFormat ValueFormat
;
624 sal_Char Reserved
[8];
626 Sc10PatternData(const Sc10PatternData
& rData
) :
627 ScDataObject( rData
)
629 strncpy(Name
, rData
.Name
, sizeof(Name
));
630 Name
[sizeof(Name
)-1] = 0;
631 memcpy(&ValueFormat
, &rData
.ValueFormat
, sizeof(ValueFormat
));
632 memcpy(&LogFont
, &rData
.LogFont
, sizeof(LogFont
));
634 Justify
= rData
.Justify
;
636 Raster
= rData
.Raster
;
637 nColor
= rData
.nColor
;
638 FrameColor
= rData
.FrameColor
;
640 FormatFlags
= rData
.FormatFlags
;
641 memcpy(Reserved
, rData
.Reserved
, sizeof(Reserved
));
643 Sc10PatternData(SvStream
& rStream
);
644 virtual ScDataObject
* Clone() const { return new Sc10PatternData(*this); }
648 // Vorlage-Collection
649 class Sc10PatternCollection
: public ScCollection
654 Sc10PatternCollection(SvStream
& rStream
);
655 ULONG
GetError() { return nError
; }
656 Sc10PatternData
* At(USHORT nIndex
) { return (Sc10PatternData
*)ScCollection::At(nIndex
); }
658 using ScCollection::At
;
663 class Sc10DataBaseData
: public ScDataObject
666 Sc10DataBaseRec DataBaseRec
;
668 Sc10DataBaseData(const Sc10DataBaseData
& rData
) :
669 ScDataObject( rData
)
671 memcpy(&DataBaseRec
, &rData
.DataBaseRec
, sizeof(DataBaseRec
));
673 Sc10DataBaseData(SvStream
& rStream
);
674 virtual ScDataObject
* Clone() const { return new Sc10DataBaseData(*this); }
678 // DatenBank-Collection
679 class Sc10DataBaseCollection
: public ScCollection
683 sal_Char ActName
[32];
685 Sc10DataBaseCollection(SvStream
& rStream
);
686 ULONG
GetError() { return nError
; }
687 Sc10DataBaseData
* At(USHORT nIndex
) { return (Sc10DataBaseData
*)ScCollection::At(nIndex
); }
689 using ScCollection::At
;
693 class Sc10PageData
: public ScDataObject
696 Sc10PageFormat aPageFormat
;
697 Sc10PageData( const Sc10PageFormat
& rFormat
) : aPageFormat(rFormat
) {}
698 int operator==( const Sc10PageData
& rData
) const
699 { return aPageFormat
== rData
.aPageFormat
; }
700 virtual ScDataObject
* Clone() const;
703 // Seitenformat-Collection
704 class Sc10PageCollection
: public ScCollection
707 Sc10PageCollection() : ScCollection(1,1) {};
708 Sc10PageData
* At(USHORT nIndex
) { return (Sc10PageData
*)ScCollection::At(nIndex
); }
709 USHORT
InsertFormat( const Sc10PageFormat
& rData
);
710 void PutToDoc( ScDocument
* pDoc
);
712 using ScCollection::At
;
716 class ScfStreamProgressBar
;
723 Sc10Color TextPalette
[16];
724 Sc10Color BackPalette
[16];
725 Sc10Color RasterPalette
[16];
726 Sc10Color FramePalette
[16];
727 Sc10SheetProtect SheetProtect
;
728 Sc10FontCollection
* pFontCollection
;
729 Sc10NameCollection
* pNameCollection
;
730 Sc10PatternCollection
* pPatternCollection
;
731 Sc10DataBaseCollection
* pDataBaseCollection
;
735 ScViewOptions aSc30ViewOpt
;
736 ScfStreamProgressBar
* pPrgrsBar
;
739 Sc10Import( SvStream
& rStr
, ScDocument
* pDocument
);
743 void LoadFileHeader();
745 void LoadEditStateInfo();
747 void LoadViewColRowBar();
750 void LoadFontCollection();
751 void LoadNameCollection();
752 void ImportNameCollection();
753 void LoadPatternCollection();
754 void LoadDataBaseCollection();
756 void LoadCol(SCCOL Col
, SCTAB Tab
);
757 void LoadColAttr(SCCOL Col
, SCTAB Tab
);
758 void LoadAttr(Sc10ColAttr
& rAttr
);
759 void ChangeFormat(USHORT nFormat
, USHORT nInfo
, ULONG
& nKey
);