1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: editutil.hxx,v $
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>
39 #ifndef _SVX_PAGEITEM_HXX //autogen
40 #include <bf_svx/pageitem.hxx>
43 #ifndef _DATE_HXX //autogen
44 #include <tools/date.hxx>
47 #ifndef _TIME_HXX //autogen
48 #include <tools/time.hxx>
51 #ifndef _GEN_HXX //autogen
52 #include <tools/gen.hxx>
55 #ifndef _FRACT_HXX //autogen
56 #include <tools/fract.hxx>
72 OutputDevice
* pDev
; // MapMode muss eingestellt sein
78 static const char __FAR_DATA pCalcDelimiters
[];
81 static String
ModifyDelimiters( const String
& rOld
);
82 static String
GetSpaceDelimitedString( const EditEngine
& rEngine
);
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
99 SfxItemSet
* pEditAttrs
;
104 ScEditAttrTester( EditEngine
* pEng
);
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
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
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();
181 struct ScHeaderFieldData
183 String aTitle
; // Titel oder Dateiname wenn kein Titel
184 String aLongDocName
; // Pfad und Dateiname
185 String aShortDocName
; // nur Dateiname
197 // fuer Feldbefehle in der Tabelle
198 class ScFieldEditEngine
: public ScEditEngineDefaulter
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
220 ScHeaderFieldData aData
;
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