Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / lotattr.hxx
blob475d46547e4a7f7265f8999409d61fed70bba74a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <vector>
23 #include <memory>
25 #include <address.hxx>
27 class ScDocumentPool;
28 class ScPatternAttr;
29 class SvxColorItem;
30 class Color;
31 struct LotusContext;
33 namespace editeng { class SvxBorderLine; }
35 struct LotAttrWK3
37 sal_uInt8 nFont;
38 sal_uInt8 nLineStyle;
39 sal_uInt8 nFontCol;
40 sal_uInt8 nBack;
42 bool HasStyles () const
44 return ( nFont || nLineStyle || nFontCol || ( nBack & 0x7F ) );
45 // !! without center bit!!
48 bool IsCentered () const
50 return ( nBack & 0x80 );
54 class LotAttrCache
56 public:
58 LotAttrCache(LotusContext& rContext);
60 ~LotAttrCache();
62 const ScPatternAttr& GetPattAttr( const LotAttrWK3& );
64 private:
66 friend class LotAttrTable;
68 struct ENTRY
70 std::unique_ptr<ScPatternAttr> pPattAttr;
71 sal_uInt32 nHash0;
73 ENTRY(std::unique_ptr<ScPatternAttr> p);
75 ~ENTRY();
78 static void MakeHash( const LotAttrWK3& rAttr, sal_uInt32& rOut )
80 reinterpret_cast<sal_uInt8*>(&rOut)[ 0 ] = rAttr.nFont & 0x7F;
81 reinterpret_cast<sal_uInt8*>(&rOut)[ 1 ] = rAttr.nLineStyle;
82 reinterpret_cast<sal_uInt8*>(&rOut)[ 2 ] = rAttr.nFontCol;
83 reinterpret_cast<sal_uInt8*>(&rOut)[ 3 ] = rAttr.nBack;
86 static void LotusToScBorderLine( sal_uInt8 nLine, ::editeng::SvxBorderLine& );
88 const SvxColorItem& GetColorItem( const sal_uInt8 nLotIndex ) const;
90 const Color& GetColor( const sal_uInt8 nLotIndex ) const;
92 ScDocumentPool* pDocPool;
93 std::unique_ptr<SvxColorItem> ppColorItems[6]; // 0 and 7 are missing!
94 std::unique_ptr<SvxColorItem> pWhite;
95 std::unique_ptr<Color[]> pColTab;
96 std::vector< std::unique_ptr<ENTRY> > aEntries;
98 LotusContext& mrContext;
101 class LotAttrCol
103 public:
104 void SetAttr (const ScDocument* pDoc, const SCROW nRow, const ScPatternAttr&);
106 void Apply(LotusContext& rContext, const SCCOL nCol, const SCTAB nTab);
107 private:
109 struct ENTRY
111 const ScPatternAttr* pPattAttr;
112 SCROW nFirstRow;
113 SCROW nLastRow;
116 std::vector< std::unique_ptr<ENTRY> > aEntries;
119 class LotAttrTable
121 public:
122 LotAttrTable(LotusContext& rContext);
124 void SetAttr(const LotusContext& rContext, const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& );
126 void Apply(LotusContext& rContext, const SCTAB nTabNum);
128 private:
130 LotAttrCol pCols[ MAXCOLCOUNT ];
131 LotAttrCache aAttrCache;
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */