Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sc / editutil.hxx
blob94fc6fc94333580b1257e762f309ff43b5a44c75
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: editutil.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_EDITUTIL_HXX
32 #define SC_EDITUTIL_HXX
35 #ifndef _MyEDITENG_HXX //autogen
36 #include <bf_svx/editeng.hxx>
37 #endif
39 #ifndef _SVX_PAGEITEM_HXX //autogen
40 #include <bf_svx/pageitem.hxx>
41 #endif
43 #ifndef _DATE_HXX //autogen
44 #include <tools/date.hxx>
45 #endif
47 #ifndef _TIME_HXX //autogen
48 #include <tools/time.hxx>
49 #endif
51 #ifndef _GEN_HXX //autogen
52 #include <tools/gen.hxx>
53 #endif
55 #ifndef _FRACT_HXX //autogen
56 #include <tools/fract.hxx>
57 #endif
58 class OutputDevice;
59 namespace binfilter {
62 class ScDocument;
63 class ScPatternAttr;
65 class ScEditUtil
67 ScDocument* pDoc;
68 USHORT nCol;
69 USHORT nRow;
70 USHORT nTab;
71 Point aScrPos;
72 OutputDevice* pDev; // MapMode muss eingestellt sein
73 double nPPTX;
74 double nPPTY;
75 Fraction aZoomX;
76 Fraction aZoomY;
78 static const char __FAR_DATA pCalcDelimiters[];
80 public:
81 static String ModifyDelimiters( const String& rOld );
82 static String GetSpaceDelimitedString( const EditEngine& rEngine );
84 public:
85 ScEditUtil( ScDocument* pDocument, USHORT nX, USHORT nY, USHORT nZ,
86 const Point& rScrPosPixel,
87 OutputDevice* pDevice, double nScaleX, double nScaleY,
88 const Fraction& rX, const Fraction& rY ) :
89 pDoc(pDocument),nCol(nX),nRow(nY),nTab(nZ),
90 aScrPos(rScrPosPixel),pDev(pDevice),
91 nPPTX(nScaleX),nPPTY(nScaleY),aZoomX(rX),aZoomY(rY) {}
96 class ScEditAttrTester
98 EditEngine* pEngine;
99 SfxItemSet* pEditAttrs;
100 BOOL bNeedsObject;
101 BOOL bNeedsCellAttr;
103 public:
104 ScEditAttrTester( EditEngine* pEng );
105 ~ScEditAttrTester();
107 BOOL NeedsObject() const { return bNeedsObject; }
108 BOOL NeedsCellAttr() const { return bNeedsCellAttr; }
109 const SfxItemSet& GetAttribs() const { return *pEditAttrs; }
113 // construct pool before constructing EditEngine, destroy pool after EditEngine
114 class ScEnginePoolHelper
116 protected:
117 SfxItemPool* pEnginePool;
118 SfxItemSet* pDefaults;
119 BOOL bDeleteEnginePool;
120 BOOL bDeleteDefaults;
122 ScEnginePoolHelper( SfxItemPool* pEnginePool,
123 BOOL bDeleteEnginePool = FALSE );
124 ScEnginePoolHelper( const ScEnginePoolHelper& rOrg );
125 virtual ~ScEnginePoolHelper();
129 class ScEditEngineDefaulter : public ScEnginePoolHelper, public EditEngine
131 public:
132 /// bDeleteEnginePool: Engine becomes the owner of the pool
133 /// and deletes it on destruction
134 ScEditEngineDefaulter( SfxItemPool* pEnginePool,
135 BOOL bDeleteEnginePool = FALSE );
136 /// If rOrg.bDeleteEnginePool: pool gets cloned and will be
137 /// deleted on destruction. Defaults are not set.
138 ScEditEngineDefaulter( const ScEditEngineDefaulter& rOrg );
139 virtual ~ScEditEngineDefaulter();
141 /// Creates a copy of SfxItemSet if bRememberCopy set
142 void SetDefaults( const SfxItemSet& rDefaults, BOOL bRememberCopy = TRUE );
144 /// Becomes the owner of the SfxItemSet if bTakeOwnership set
145 void SetDefaults( SfxItemSet* pDefaults, BOOL bTakeOwnership = TRUE );
147 /// Set the item in the default ItemSet which is created
148 /// if it doesn't exist yet.
149 /// The default ItemSet is then applied to each paragraph.
151 /// Overwritten method to be able to apply defaults already set
152 void SetText( const EditTextObject& rTextObject );
153 /// Current defaults are not applied, new defaults are applied
154 void SetTextNewDefaults( const EditTextObject& rTextObject,
155 const SfxItemSet& rDefaults, BOOL bRememberCopy = TRUE );
156 /// Current defaults are not applied, new defaults are applied
157 void SetTextNewDefaults( const EditTextObject& rTextObject,
158 SfxItemSet* pDefaults, BOOL bTakeOwnership = TRUE );
160 /// Overwritten method to be able to apply defaults already set
161 void SetText( const String& rText );
162 /// Current defaults are not applied, new defaults are applied
163 void SetTextNewDefaults( const String& rText,
164 const SfxItemSet& rDefaults, BOOL bRememberCopy = TRUE );
165 /// Current defaults are not applied, new defaults are applied
166 void SetTextNewDefaults( const String& rText,
167 SfxItemSet* pDefaults, BOOL bTakeOwnership = TRUE );
169 /// Paragraph attributes that are not defaults are copied to
170 /// character attributes and all paragraph attributes reset
172 /// Re-apply existing defaults if set, same as in SetText,
173 /// but without EnableUndo/SetUpdateMode.
174 void RepeatDefaults();
178 // 1/100 mm
181 struct ScHeaderFieldData
183 String aTitle; // Titel oder Dateiname wenn kein Titel
184 String aLongDocName; // Pfad und Dateiname
185 String aShortDocName; // nur Dateiname
186 String aTabName;
187 Date aDate;
188 Time aTime;
189 long nPageNo;
190 long nTotalPages;
191 SvxNumType eNumType;
193 ScHeaderFieldData();
197 // fuer Feldbefehle in der Tabelle
198 class ScFieldEditEngine : public ScEditEngineDefaulter
200 private:
201 BOOL bExecuteURL;
203 public:
204 // pEnginePool = ScDocument.GetEnginePool()
205 // pTextObjectPool = ScDocument.GetEditPool()
206 ScFieldEditEngine( SfxItemPool* pEnginePool,
207 SfxItemPool* pTextObjectPool = NULL,
208 BOOL bDeleteEnginePool = FALSE );
210 void SetExecuteURL(BOOL bSet) { bExecuteURL = bSet; }
212 virtual String CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, USHORT nPos, Color*& rTxtColor, Color*& rFldColor );
216 // for headers/footers with fields
217 class ScHeaderEditEngine : public ScEditEngineDefaulter
219 private:
220 ScHeaderFieldData aData;
222 public:
223 ScHeaderEditEngine( SfxItemPool* pEnginePool, BOOL bDeleteEnginePool = FALSE );
224 virtual String CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, USHORT nPos, Color*& rTxtColor, Color*& rFldColor );
226 void SetTitle(const String& rNew) { aData.aTitle = rNew; }
227 void SetLongDocName(const String& rNew) { aData.aLongDocName = rNew; }
228 void SetShortDocName(const String& rNew) { aData.aShortDocName = rNew; }
229 void SetTabName(const String& rNew) { aData.aTabName = rNew; }
230 void SetDate(const Date& rNew) { aData.aDate = rNew; }
231 void SetTime(const Time& rNew) { aData.aTime = rNew; }
232 void SetPageNo(long nNew) { aData.nPageNo = nNew; }
233 void SetTotalPages(long nNew) { aData.nTotalPages = nNew; }
234 void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; }
235 void SetData(const ScHeaderFieldData& rNew) { aData = rNew; }
238 // SvxFieldData-Ableitungen sind nach Svx verschoben
241 } //namespace binfilter
242 #endif