xref: /aoo41x/main/sc/source/filter/inc/lotattr.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_LOTATTR_HXX
25 #define SC_LOTATTR_HXX
26 
27 #include <tools/solar.h>
28 #include <tools/list.hxx>
29 #include "patattr.hxx"
30 #include "scitems.hxx"
31 #include "address.hxx"
32 
33 // ----- forwards --------------------------------------------------------
34 class ScDocument;
35 class ScDocumentPool;
36 class SvxBorderLine;
37 class SvxColorItem;
38 class Color;
39 
40 class LotAttrTable;
41 
42 
43 struct LotAttrWK3
44 {
45 	sal_uInt8					nFont;
46 	sal_uInt8					nLineStyle;
47 	sal_uInt8					nFontCol;
48 	sal_uInt8					nBack;
49 
50 	inline sal_Bool				HasStyles( void );
51 	inline sal_Bool				IsCentered( void );
52 };
53 
54 
HasStyles(void)55 inline sal_Bool LotAttrWK3::HasStyles( void )
56 {
57 	return ( nFont || nLineStyle || nFontCol || ( nBack & 0x7F ) );
58 					// !! ohne Center-Bit!!
59 }
60 
61 
IsCentered(void)62 inline sal_Bool LotAttrWK3::IsCentered( void )
63 {
64 	return ( nBack & 0x80 );
65 }
66 
67 
68 class LotAttrCache : private List
69 {
70 private:
71 	friend class LotAttrTable;
72 
73 	struct ENTRY
74 	{
75 		ScPatternAttr*	pPattAttr;
76 		sal_uInt32			nHash0;
77 
ENTRYLotAttrCache::ENTRY78 		inline			ENTRY( const ScPatternAttr& r )			{ pPattAttr = new ScPatternAttr( r ); }
79 
ENTRYLotAttrCache::ENTRY80 		inline			ENTRY( ScPatternAttr* p )				{ pPattAttr = p; }
81 
~ENTRYLotAttrCache::ENTRY82 		inline			~ENTRY()								{ delete pPattAttr; }
83 
operator ==LotAttrCache::ENTRY84 		inline sal_Bool		operator ==( const ENTRY& r ) const		{ return nHash0 == r.nHash0; }
85 
operator ==LotAttrCache::ENTRY86 		inline sal_Bool		operator ==( const sal_uInt32& r ) const	{ return nHash0 == r; }
87 	};
88 
89 	ScDocumentPool*		pDocPool;
90 	SvxColorItem*		ppColorItems[ 6 ];		// 0 und 7 fehlen!
91 	SvxColorItem*		pBlack;
92 	SvxColorItem*		pWhite;
93 	Color*				pColTab;
94 
MakeHash(const LotAttrWK3 & rAttr,sal_uInt32 & rOut)95 	inline static void	MakeHash( const LotAttrWK3& rAttr, sal_uInt32& rOut )
96 						{
97 							( ( sal_uInt8* ) &rOut )[ 0 ] = rAttr.nFont & 0x7F;
98 							( ( sal_uInt8* ) &rOut )[ 1 ] = rAttr.nLineStyle;
99 							( ( sal_uInt8* ) &rOut )[ 2 ] = rAttr.nFontCol;
100 							( ( sal_uInt8* ) &rOut )[ 3 ] = rAttr.nBack;
101 						}
102 	static void			LotusToScBorderLine( sal_uInt8 nLine, SvxBorderLine& );
103 	const SvxColorItem&	GetColorItem( const sal_uInt8 nLotIndex ) const;
104 	const Color&		GetColor( const sal_uInt8 nLotIndex ) const;
105 public:
106 						LotAttrCache( void );
107 						~LotAttrCache();
108 
109 	const ScPatternAttr&	GetPattAttr( const LotAttrWK3& );
110 };
111 
112 
113 class LotAttrCol : private List
114 {
115 private:
116 	struct ENTRY
117 	{
118 		const ScPatternAttr*	pPattAttr;
119 		SCROW					nFirstRow;
120 		SCROW					nLastRow;
121 	};
122 
123 public:
124 								~LotAttrCol( void );
125 	void						SetAttr( const SCROW nRow, const ScPatternAttr& );
126 	void						Apply( const SCCOL nCol, const SCTAB nTab, const sal_Bool bClear = sal_True );
127 	void						Clear( void );
128 };
129 
130 
131 class LotAttrTable
132 {
133 private:
134 	LotAttrCol			pCols[ MAXCOLCOUNT ];
135 	LotAttrCache		aAttrCache;
136 public:
137 						LotAttrTable( void );
138 						~LotAttrTable();
139 
140 	void				SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& );
141 	void				Apply( const SCTAB nTabNum );
142 };
143 
144 
145 
146 
147 
148 #endif
149 
150