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 SC_SCPATATR_HXX
21 : #define SC_SCPATATR_HXX
22 :
23 : #include <svl/poolitem.hxx>
24 : #include <svl/itemset.hxx>
25 : #include <unotools/fontcvt.hxx>
26 : #include <editeng/svxenum.hxx>
27 : #include "scdllapi.h"
28 :
29 : class Font;
30 : class OutputDevice;
31 : class Fraction;
32 : class ScStyleSheet;
33 : class SvNumberFormatter;
34 : class ScDocument;
35 :
36 :
37 : // how to treat COL_AUTO in GetFont:
38 :
39 : enum ScAutoFontColorMode
40 : {
41 : SC_AUTOCOL_RAW, // COL_AUTO is returned
42 : SC_AUTOCOL_BLACK, // always use black
43 : SC_AUTOCOL_PRINT, // black or white, depending on background
44 : SC_AUTOCOL_DISPLAY, // from style settings, or black/white if needed
45 : SC_AUTOCOL_IGNOREFONT, // like DISPLAY, but ignore stored font color (assume COL_AUTO)
46 : SC_AUTOCOL_IGNOREBACK, // like DISPLAY, but ignore stored background color (use configured color)
47 : SC_AUTOCOL_IGNOREALL // like DISPLAY, but ignore stored font and background colors
48 : };
49 :
50 :
51 : class SC_DLLPUBLIC ScPatternAttr: public SfxSetItem
52 : {
53 : String* pName;
54 : ScStyleSheet* pStyle;
55 : public:
56 : static ScDocument* pDoc;
57 : ScPatternAttr(SfxItemSet* pItemSet, const String& rStyleName);
58 : ScPatternAttr(SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet = NULL);
59 : ScPatternAttr(SfxItemPool* pItemPool);
60 : ScPatternAttr(const ScPatternAttr& rPatternAttr);
61 :
62 : ~ScPatternAttr();
63 :
64 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
65 : virtual SfxPoolItem* Create(SvStream& rStream, sal_uInt16 nVersion) const;
66 : virtual SvStream& Store(SvStream& rStream, sal_uInt16 nItemVersion) const;
67 :
68 : virtual int operator==(const SfxPoolItem& rCmp) const;
69 :
70 2533338 : const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const
71 2533338 : { return GetItemSet().Get(nWhichP); }
72 :
73 : static const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet );
74 : const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const;
75 :
76 : // pWhich are no ranges, but single IDs, 0-terminated
77 : bool HasItemsSet( const sal_uInt16* pWhich ) const;
78 : void ClearItems( const sal_uInt16* pWhich );
79 :
80 : void DeleteUnchanged( const ScPatternAttr* pOldAttrs );
81 :
82 : static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet = 0 );
83 : SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = 0 ) const;
84 :
85 : /** Static helper function to fill a font object from the passed item set. */
86 : static void GetFont( Font& rFont, const SfxItemSet& rItemSet,
87 : ScAutoFontColorMode eAutoMode,
88 : OutputDevice* pOutDev = NULL,
89 : const Fraction* pScale = NULL,
90 : const SfxItemSet* pCondSet = NULL,
91 : sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL,
92 : const Color* pTextConfigColor = NULL );
93 : /** Fills a font object from the own item set. */
94 : void GetFont( Font& rFont, ScAutoFontColorMode eAutoMode,
95 : OutputDevice* pOutDev = NULL,
96 : const Fraction* pScale = NULL,
97 : const SfxItemSet* pCondSet = NULL,
98 : sal_uInt8 nScript = 0, const Color* pBackConfigColor = NULL,
99 : const Color* pTextConfigColor = NULL ) const;
100 :
101 : /** Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet. */
102 : static void FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = NULL );
103 : /** Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSet. */
104 : void FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet = NULL ) const;
105 :
106 : /** Converts all edit engine items contained in rEditSet to Calc items and puts them into rDestSet. */
107 : static void GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet );
108 : /** Converts all edit engine items contained in pEditSet to Calc items and puts them into the own item set. */
109 : void GetFromEditItemSet( const SfxItemSet* pEditSet );
110 :
111 : void FillEditParaItems( SfxItemSet* pSet ) const;
112 :
113 : ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const;
114 :
115 : void SetStyleSheet(ScStyleSheet* pNewStyle, bool bClearDirectFormat = true);
116 2408570 : const ScStyleSheet* GetStyleSheet() const { return pStyle; }
117 : const String* GetStyleName() const;
118 : void UpdateStyleSheet();
119 : void StyleToName();
120 :
121 : bool IsVisible() const;
122 : bool IsVisibleEqual( const ScPatternAttr& rOther ) const;
123 :
124 : /** If font is an old symbol font StarBats/StarMath
125 : with text encoding RTL_TEXTENC_SYMBOL */
126 : bool IsSymbolFont() const;
127 :
128 : sal_uLong GetNumberFormat( SvNumberFormatter* ) const;
129 : sal_uLong GetNumberFormat( SvNumberFormatter* pFormatter,
130 : const SfxItemSet* pCondSet ) const;
131 :
132 : long GetRotateVal( const SfxItemSet* pCondSet ) const;
133 : sal_uInt8 GetRotateDir( const SfxItemSet* pCondSet ) const;
134 : };
135 :
136 :
137 : class ScFontToSubsFontConverter_AutoPtr
138 : {
139 : FontToSubsFontConverter h;
140 :
141 : void release()
142 : {
143 : if ( h )
144 : DestroyFontToSubsFontConverter( h );
145 : }
146 :
147 : // prevent usage
148 : ScFontToSubsFontConverter_AutoPtr( const ScFontToSubsFontConverter_AutoPtr& );
149 : ScFontToSubsFontConverter_AutoPtr& operator=( const ScFontToSubsFontConverter_AutoPtr& );
150 :
151 : public:
152 : ScFontToSubsFontConverter_AutoPtr()
153 : : h(0)
154 : {}
155 : ~ScFontToSubsFontConverter_AutoPtr()
156 : {
157 : release();
158 : }
159 :
160 : ScFontToSubsFontConverter_AutoPtr& operator=( FontToSubsFontConverter hN )
161 : {
162 : release();
163 : h = hN;
164 : return *this;
165 : }
166 :
167 : operator FontToSubsFontConverter() const
168 : { return h; }
169 : };
170 :
171 :
172 : #endif
173 :
174 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|