Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SC_SOURCE_FILTER_INC_LOTATTR_HXX
21 : #define INCLUDED_SC_SOURCE_FILTER_INC_LOTATTR_HXX
22 :
23 : #include <boost/ptr_container/ptr_vector.hpp>
24 :
25 : #include "address.hxx"
26 : #include "scitems.hxx"
27 :
28 : class ScDocumentPool;
29 : class ScPatternAttr;
30 : class SvxColorItem;
31 : class Color;
32 : class LotAttrTable;
33 : struct LOTUS_ROOT;
34 :
35 : namespace editeng { class SvxBorderLine; }
36 :
37 : struct LotAttrWK3
38 : {
39 : sal_uInt8 nFont;
40 : sal_uInt8 nLineStyle;
41 : sal_uInt8 nFontCol;
42 : sal_uInt8 nBack;
43 :
44 0 : inline bool HasStyles () const
45 : {
46 0 : return ( nFont || nLineStyle || nFontCol || ( nBack & 0x7F ) );
47 : // !! ohne Center-Bit!!
48 : }
49 :
50 0 : inline bool IsCentered () const
51 : {
52 0 : return ( nBack & 0x80 );
53 : }
54 : };
55 :
56 : class LotAttrCache
57 : {
58 : public:
59 :
60 : LotAttrCache(LOTUS_ROOT* pLotRoot);
61 :
62 : ~LotAttrCache();
63 :
64 : const ScPatternAttr& GetPattAttr( const LotAttrWK3& );
65 :
66 : private:
67 :
68 : friend class LotAttrTable;
69 :
70 : struct ENTRY
71 : {
72 : ScPatternAttr* pPattAttr;
73 : sal_uInt32 nHash0;
74 :
75 : ENTRY (ScPatternAttr* p);
76 :
77 : ~ENTRY ();
78 :
79 : inline bool operator == (const ENTRY &r) const { return nHash0 == r.nHash0; }
80 :
81 : inline bool operator == (const sal_uInt32 &r) const { return nHash0 == r; }
82 : };
83 :
84 0 : inline static void MakeHash( const LotAttrWK3& rAttr, sal_uInt32& rOut )
85 : {
86 0 : reinterpret_cast<sal_uInt8*>(&rOut)[ 0 ] = rAttr.nFont & 0x7F;
87 0 : reinterpret_cast<sal_uInt8*>(&rOut)[ 1 ] = rAttr.nLineStyle;
88 0 : reinterpret_cast<sal_uInt8*>(&rOut)[ 2 ] = rAttr.nFontCol;
89 0 : reinterpret_cast<sal_uInt8*>(&rOut)[ 3 ] = rAttr.nBack;
90 0 : }
91 :
92 : static void LotusToScBorderLine( sal_uInt8 nLine, ::editeng::SvxBorderLine& );
93 :
94 : const SvxColorItem& GetColorItem( const sal_uInt8 nLotIndex ) const;
95 :
96 : const Color& GetColor( const sal_uInt8 nLotIndex ) const;
97 :
98 : ScDocumentPool* pDocPool;
99 : SvxColorItem* ppColorItems[6]; // 0 und 7 fehlen!
100 : SvxColorItem* pBlack;
101 : SvxColorItem* pWhite;
102 : Color* pColTab;
103 : boost::ptr_vector<ENTRY> aEntries;
104 :
105 : LOTUS_ROOT* mpLotusRoot;
106 : };
107 :
108 8192 : class LotAttrCol
109 : {
110 : public:
111 : void SetAttr (const SCROW nRow, const ScPatternAttr&);
112 :
113 : void Apply(LOTUS_ROOT* pLotRoot, const SCCOL nCol, const SCTAB nTab);
114 : private:
115 :
116 : struct ENTRY
117 : {
118 : const ScPatternAttr* pPattAttr;
119 : SCROW nFirstRow;
120 : SCROW nLastRow;
121 : };
122 :
123 : boost::ptr_vector<ENTRY> aEntries;
124 : };
125 :
126 4 : class LotAttrTable
127 : {
128 : public:
129 : LotAttrTable(LOTUS_ROOT* pLotRoot);
130 :
131 : void SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& );
132 :
133 : void Apply(LOTUS_ROOT* pLotRoot, const SCTAB nTabNum);
134 :
135 : private:
136 :
137 : LotAttrCol pCols[ MAXCOLCOUNT ];
138 : LotAttrCache aAttrCache;
139 : };
140 :
141 : #endif
142 :
143 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|