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 #pragma once
21 
22 #include <vector>
23 #include <memory>
24 
25 #include <address.hxx>
26 
27 class ScDocumentPool;
28 class ScPatternAttr;
29 class SvxColorItem;
30 class Color;
31 struct LotusContext;
32 
33 namespace editeng { class SvxBorderLine; }
34 
35 struct LotAttrWK3
36 {
41 
42  bool HasStyles () const
43  {
44  return ( nFont || nLineStyle || nFontCol || ( nBack & 0x7F ) );
45  // !! without center bit!!
46  }
47 
48  bool IsCentered () const
49  {
50  return ( nBack & 0x80 );
51  }
52 };
53 
55 {
56 public:
57 
58  LotAttrCache(LotusContext& rContext);
59 
60  ~LotAttrCache();
61 
62  const ScPatternAttr& GetPattAttr( const LotAttrWK3& );
63 
64 private:
65 
66  friend class LotAttrTable;
67 
68  struct ENTRY
69  {
70  std::unique_ptr<ScPatternAttr> pPattAttr;
71  sal_uInt32 nHash0;
72 
73  ENTRY(std::unique_ptr<ScPatternAttr> p);
74 
75  ~ENTRY();
76  };
77 
78  static void MakeHash( const LotAttrWK3& rAttr, sal_uInt32& rOut )
79  {
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;
84  }
85 
86  static void LotusToScBorderLine( sal_uInt8 nLine, ::editeng::SvxBorderLine& );
87 
88  const SvxColorItem& GetColorItem( const sal_uInt8 nLotIndex ) const;
89 
90  const Color& GetColor( const sal_uInt8 nLotIndex ) const;
91 
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;
97 
99 };
100 
102 {
103 public:
104  void SetAttr (const ScDocument* pDoc, const SCROW nRow, const ScPatternAttr&);
105 
106  void Apply(LotusContext& rContext, const SCCOL nCol, const SCTAB nTab);
107 private:
108 
109  struct ENTRY
110  {
114  };
115 
116  std::vector< std::unique_ptr<ENTRY> > aEntries;
117 };
118 
120 {
121 public:
122  LotAttrTable(LotusContext& rContext);
123 
124  void SetAttr(LotusContext& rContext, const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& );
125 
126  void Apply(LotusContext& rContext, const SCTAB nTabNum);
127 
128 private:
129 
132 };
133 
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 nHash0
Definition: lotattr.hxx:71
sal_uInt8 nFont
Definition: lotattr.hxx:37
static void LotusToScBorderLine(sal_uInt8 nLine,::editeng::SvxBorderLine &)
Definition: lotattr.cxx:147
LotusContext & mrContext
Definition: lotattr.hxx:98
std::unique_ptr< ScPatternAttr > pPattAttr
Definition: lotattr.hxx:70
const SvxColorItem & GetColorItem(const sal_uInt8 nLotIndex) const
Definition: lotattr.cxx:165
void Apply(LotusContext &rContext, const SCCOL nCol, const SCTAB nTab)
Definition: lotattr.cxx:214
LotAttrCache aAttrCache
Definition: lotattr.hxx:131
std::unique_ptr< Color[]> pColTab
Definition: lotattr.hxx:95
LotAttrCache(LotusContext &rContext)
Definition: lotattr.cxx:49
ENTRY(std::unique_ptr< ScPatternAttr > p)
Definition: lotattr.cxx:39
const SCCOL MAXCOLCOUNT
Definition: address.hxx:63
ScDocumentPool * pDocPool
Definition: lotattr.hxx:92
void Apply(LotusContext &rContext, const SCTAB nTabNum)
Definition: lotattr.cxx:243
const ScPatternAttr * pPattAttr
Definition: lotattr.hxx:111
LotAttrTable(LotusContext &rContext)
Definition: lotattr.cxx:225
bool HasStyles() const
Definition: lotattr.hxx:42
sal_uInt8 nLineStyle
Definition: lotattr.hxx:38
sal_Int16 SCCOL
Definition: types.hxx:21
std::vector< std::unique_ptr< ENTRY > > aEntries
Definition: lotattr.hxx:116
std::vector< std::unique_ptr< ENTRY > > aEntries
Definition: lotattr.hxx:96
const Color & GetColor(const sal_uInt8 nLotIndex) const
Definition: lotattr.cxx:173
bool IsCentered() const
Definition: lotattr.hxx:48
sal_Int32 SCROW
Definition: types.hxx:17
static void MakeHash(const LotAttrWK3 &rAttr, sal_uInt32 &rOut)
Definition: lotattr.hxx:78
unsigned char sal_uInt8
void SetAttr(const ScDocument *pDoc, const SCROW nRow, const ScPatternAttr &)
Definition: lotattr.cxx:182
std::unique_ptr< SvxColorItem > pWhite
Definition: lotattr.hxx:94
sal_uInt8 nFontCol
Definition: lotattr.hxx:39
LotAttrCol pCols[MAXCOLCOUNT]
Definition: lotattr.hxx:130
void SetAttr(LotusContext &rContext, const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3 &)
Definition: lotattr.cxx:230
std::unique_ptr< SvxColorItem > ppColorItems[6]
Definition: lotattr.hxx:93
sal_uInt8 nBack
Definition: lotattr.hxx:40
const ScPatternAttr & GetPattAttr(const LotAttrWK3 &)
Definition: lotattr.cxx:78
sal_Int16 SCTAB
Definition: types.hxx:22