LibreOffice Module sc (master)  1
lotattr.hxx
Go to the documentation of this file.
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 <vector>
24 #include <memory>
25 
26 #include <address.hxx>
27 
28 class ScDocumentPool;
29 class ScPatternAttr;
30 class SvxColorItem;
31 class Color;
32 struct LotusContext;
33 
34 namespace editeng { class SvxBorderLine; }
35 
36 struct LotAttrWK3
37 {
42 
43  bool HasStyles () const
44  {
45  return ( nFont || nLineStyle || nFontCol || ( nBack & 0x7F ) );
46  // !! without center bit!!
47  }
48 
49  bool IsCentered () const
50  {
51  return ( nBack & 0x80 );
52  }
53 };
54 
56 {
57 public:
58 
59  LotAttrCache(LotusContext& rContext);
60 
61  ~LotAttrCache();
62 
63  const ScPatternAttr& GetPattAttr( const LotAttrWK3& );
64 
65 private:
66 
67  friend class LotAttrTable;
68 
69  struct ENTRY
70  {
71  std::unique_ptr<ScPatternAttr> pPattAttr;
72  sal_uInt32 nHash0;
73 
74  ENTRY(std::unique_ptr<ScPatternAttr> p);
75 
76  ~ENTRY();
77  };
78 
79  static void MakeHash( const LotAttrWK3& rAttr, sal_uInt32& rOut )
80  {
81  reinterpret_cast<sal_uInt8*>(&rOut)[ 0 ] = rAttr.nFont & 0x7F;
82  reinterpret_cast<sal_uInt8*>(&rOut)[ 1 ] = rAttr.nLineStyle;
83  reinterpret_cast<sal_uInt8*>(&rOut)[ 2 ] = rAttr.nFontCol;
84  reinterpret_cast<sal_uInt8*>(&rOut)[ 3 ] = rAttr.nBack;
85  }
86 
87  static void LotusToScBorderLine( sal_uInt8 nLine, ::editeng::SvxBorderLine& );
88 
89  const SvxColorItem& GetColorItem( const sal_uInt8 nLotIndex ) const;
90 
91  const Color& GetColor( const sal_uInt8 nLotIndex ) const;
92 
94  std::unique_ptr<SvxColorItem> ppColorItems[6]; // 0 and 7 are missing!
95  std::unique_ptr<SvxColorItem> pWhite;
96  std::unique_ptr<Color[]> pColTab;
97  std::vector< std::unique_ptr<ENTRY> > aEntries;
98 
100 };
101 
103 {
104 public:
105  void SetAttr (const ScDocument* pDoc, const SCROW nRow, const ScPatternAttr&);
106 
107  void Apply(LotusContext& rContext, const SCCOL nCol, const SCTAB nTab);
108 private:
109 
110  struct ENTRY
111  {
115  };
116 
117  std::vector< std::unique_ptr<ENTRY> > aEntries;
118 };
119 
121 {
122 public:
123  LotAttrTable(LotusContext& rContext);
124 
125  void SetAttr(LotusContext& rContext, const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& );
126 
127  void Apply(LotusContext& rContext, const SCTAB nTabNum);
128 
129 private:
130 
133 };
134 
135 #endif
136 
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 nHash0
Definition: lotattr.hxx:72
sal_uInt8 nFont
Definition: lotattr.hxx:38
static void LotusToScBorderLine(sal_uInt8 nLine,::editeng::SvxBorderLine &)
Definition: lotattr.cxx:148
LotusContext & mrContext
Definition: lotattr.hxx:99
std::unique_ptr< ScPatternAttr > pPattAttr
Definition: lotattr.hxx:71
const SvxColorItem & GetColorItem(const sal_uInt8 nLotIndex) const
Definition: lotattr.cxx:166
void Apply(LotusContext &rContext, const SCCOL nCol, const SCTAB nTab)
Definition: lotattr.cxx:215
LotAttrCache aAttrCache
Definition: lotattr.hxx:132
std::unique_ptr< Color[]> pColTab
Definition: lotattr.hxx:96
LotAttrCache(LotusContext &rContext)
Definition: lotattr.cxx:50
ENTRY(std::unique_ptr< ScPatternAttr > p)
Definition: lotattr.cxx:40
const SCCOL MAXCOLCOUNT
Definition: address.hxx:64
ScDocumentPool * pDocPool
Definition: lotattr.hxx:93
void Apply(LotusContext &rContext, const SCTAB nTabNum)
Definition: lotattr.cxx:244
const ScPatternAttr * pPattAttr
Definition: lotattr.hxx:112
LotAttrTable(LotusContext &rContext)
Definition: lotattr.cxx:226
bool HasStyles() const
Definition: lotattr.hxx:43
sal_uInt8 nLineStyle
Definition: lotattr.hxx:39
sal_Int16 SCCOL
Definition: types.hxx:22
std::vector< std::unique_ptr< ENTRY > > aEntries
Definition: lotattr.hxx:117
std::vector< std::unique_ptr< ENTRY > > aEntries
Definition: lotattr.hxx:97
const Color & GetColor(const sal_uInt8 nLotIndex) const
Definition: lotattr.cxx:174
bool IsCentered() const
Definition: lotattr.hxx:49
sal_Int32 SCROW
Definition: types.hxx:18
static void MakeHash(const LotAttrWK3 &rAttr, sal_uInt32 &rOut)
Definition: lotattr.hxx:79
unsigned char sal_uInt8
void SetAttr(const ScDocument *pDoc, const SCROW nRow, const ScPatternAttr &)
Definition: lotattr.cxx:183
std::unique_ptr< SvxColorItem > pWhite
Definition: lotattr.hxx:95
sal_uInt8 nFontCol
Definition: lotattr.hxx:40
LotAttrCol pCols[MAXCOLCOUNT]
Definition: lotattr.hxx:131
void SetAttr(LotusContext &rContext, const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3 &)
Definition: lotattr.cxx:231
std::unique_ptr< SvxColorItem > ppColorItems[6]
Definition: lotattr.hxx:94
sal_uInt8 nBack
Definition: lotattr.hxx:41
const ScPatternAttr & GetPattAttr(const LotAttrWK3 &)
Definition: lotattr.cxx:79
sal_Int16 SCTAB
Definition: types.hxx:23