Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / inc / patattr.hxx
blobcf09d54f5168c6898480b27b736897f5ec3b8659
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 #ifndef SC_SCPATATR_HXX
21 #define SC_SCPATATR_HXX
23 #include <svl/poolitem.hxx>
24 #include <svl/itemset.hxx>
25 #include <unotools/fontcvt.hxx>
26 #include <editeng/svxenum.hxx>
27 #include "scdllapi.h"
29 class Font;
30 class OutputDevice;
31 class Fraction;
32 class ScStyleSheet;
33 class SvNumberFormatter;
34 class ScDocument;
37 /// how to treat COL_AUTO in GetFont:
39 enum ScAutoFontColorMode
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
51 class SC_DLLPUBLIC ScPatternAttr: public SfxSetItem
53 OUString* pName;
54 ScStyleSheet* pStyle;
55 public:
56 static ScDocument* pDoc;
57 ScPatternAttr(SfxItemSet* pItemSet, const OUString& rStyleName);
58 ScPatternAttr(SfxItemSet* pItemSet, ScStyleSheet* pStyleSheet = NULL);
59 ScPatternAttr(SfxItemPool* pItemPool);
60 ScPatternAttr(const ScPatternAttr& rPatternAttr);
62 ~ScPatternAttr();
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;
68 virtual int operator==(const SfxPoolItem& rCmp) const;
70 const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const
71 { return GetItemSet().Get(nWhichP); }
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;
76 /// @param pWhich are no ranges, but single IDs, 0-terminated
77 bool HasItemsSet( const sal_uInt16* pWhich ) const;
78 void ClearItems( const sal_uInt16* pWhich );
80 void DeleteUnchanged( const ScPatternAttr* pOldAttrs );
82 static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet = 0 );
83 SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = 0 ) const;
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;
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;
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 );
111 void FillEditParaItems( SfxItemSet* pSet ) const;
113 ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const;
115 void SetStyleSheet(ScStyleSheet* pNewStyle, bool bClearDirectFormat = true);
116 const ScStyleSheet* GetStyleSheet() const { return pStyle; }
117 const OUString* GetStyleName() const;
118 void UpdateStyleSheet();
119 void StyleToName();
121 bool IsVisible() const;
122 bool IsVisibleEqual( const ScPatternAttr& rOther ) const;
124 /** If font is an old symbol font StarBats/StarMath
125 with text encoding RTL_TEXTENC_SYMBOL */
126 bool IsSymbolFont() const;
128 sal_uLong GetNumberFormat( SvNumberFormatter* ) const;
129 sal_uLong GetNumberFormat( SvNumberFormatter* pFormatter,
130 const SfxItemSet* pCondSet ) const;
132 long GetRotateVal( const SfxItemSet* pCondSet ) const;
133 sal_uInt8 GetRotateDir( const SfxItemSet* pCondSet ) const;
137 class ScFontToSubsFontConverter_AutoPtr
139 FontToSubsFontConverter h;
141 void release()
143 if ( h )
144 DestroyFontToSubsFontConverter( h );
147 /// prevent usage
148 ScFontToSubsFontConverter_AutoPtr( const ScFontToSubsFontConverter_AutoPtr& );
149 ScFontToSubsFontConverter_AutoPtr& operator=( const ScFontToSubsFontConverter_AutoPtr& );
151 public:
152 ScFontToSubsFontConverter_AutoPtr()
153 : h(0)
155 ~ScFontToSubsFontConverter_AutoPtr()
157 release();
160 ScFontToSubsFontConverter_AutoPtr& operator=( FontToSubsFontConverter hN )
162 release();
163 h = hN;
164 return *this;
167 operator FontToSubsFontConverter() const
168 { return h; }
172 #endif
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */