xref: /aoo4110/main/svx/inc/svx/svdetc.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVDETC_HXX
25 #define _SVDETC_HXX
26 
27 #include <tools/string.hxx>
28 #include <tools/contnr.hxx>
29 
30 #ifndef _OUTDEV_HXX //autogen
31 #include <vcl/outdev.hxx>
32 #endif
33 #include <tools/shl.hxx>
34 #include <editeng/outliner.hxx>
35 #include "svx/svxdllapi.h"
36 
37 ////////////////////////////////////////////////////////////////////////////////////////////////////
38 
39 // ExchangeFormat-Id der DrawingEngine holen. Daten koennen dann per
40 //   static sal_Bool CopyData(pData,nLen,nFormat);
41 // bereitgestellt werden, wobei pData/nLen einen SvMemoryStream beschreiben in
42 // dem ein SdrModel gestreamt wird an dem fuer die Zeitdauer des Streamens das
43 // Flag SdrModel::SetStreamingSdrModel(sal_True) gesetzt wird.
44 // sal_uIntPtr SdrGetExchangeFormat(); -- JP 18.01.99 - dafuer gibt es ein define
45 
46 class SdrOutliner;
47 class SdrModel;
48 class SvtSysLocale;
49 class CharClass;
50 class LocaleDataWrapper;
51 
52 namespace com { namespace sun { namespace star { namespace lang {
53 	struct Locale;
54 }}}}
55 
56 // Einen Outliner mit den engineglobalen
57 // Defaulteinstellungen auf dem Heap erzeugen.
58 // Ist pMod<>NULL, dann wird der MapMode des uebergebenen
59 // Models verwendet. Die resultierende Default-Fonthoehe bleibt
60 // jedoch dieselbe (die logische Fonthoehe wird umgerechnet).
61 SVX_DLLPUBLIC SdrOutliner* SdrMakeOutliner( sal_uInt16 nOutlinerMode, SdrModel* pMod );
62 
63 // Globale Defaulteinstellungen fuer die DrawingEngine.
64 // Diese Einstellungen sollte man direkt beim Applikationsstart
65 // vornehmen, noch bevor andere Methoden der Engine gerufen werden.
66 class SVX_DLLPUBLIC SdrEngineDefaults
67 {
68 friend class SdrAttrObj;
69 	String     aFontName;
70 	FontFamily eFontFamily;
71 	Color      aFontColor;
72 	sal_uIntPtr      nFontHeight;
73 	MapUnit    eMapUnit;
74 	Fraction   aMapFraction;
75 
76 private:
77 	static SdrEngineDefaults& GetDefaults();
78 
79 public:
80 	SdrEngineDefaults();
81 	// Default Fontname ist "Times New Roman"
SetFontName(const String & rFontName)82 	static void       SetFontName(const String& rFontName) { GetDefaults().aFontName=rFontName; }
GetFontName()83 	static String     GetFontName()                        { return GetDefaults().aFontName; }
84 	// Default FontFamily ist FAMILY_ROMAN
SetFontFamily(FontFamily eFam)85 	static void       SetFontFamily(FontFamily eFam)       { GetDefaults().eFontFamily=eFam; }
GetFontFamily()86 	static FontFamily GetFontFamily()                      { return GetDefaults().eFontFamily; }
87 	// Default FontColor ist COL_BLACK
SetFontColor(const Color & rColor)88 	static void       SetFontColor(const Color& rColor)    { GetDefaults().aFontColor=rColor; }
GetFontColor()89 	static Color      GetFontColor()                       { return GetDefaults().aFontColor; }
90 	// Default FontHeight ist 847. Die Fonthoehe wird in logischen Einheiten
91 	// (MapUnit/MapFraction (siehe unten)) angegeben. Die Defaulteinstellung
92 	// 847/100mm entspricht also ca. 24 Point. Verwendet man stattdessen
93 	// beispielsweise Twips (SetMapUnit(MAP_TWIP)) (20 Twip = 1 Point) muss
94 	// man als Fonthoehe 480 angeben um 24 Point als default zu erhalten.
SetFontHeight(sal_uIntPtr nHeight)95 	static void       SetFontHeight(sal_uIntPtr nHeight)         { GetDefaults().nFontHeight=nHeight; }
GetFontHeight()96 	static sal_uIntPtr      GetFontHeight()                      { return GetDefaults().nFontHeight; }
97 	// Der MapMode wird fuer den globalen Outliner benoetigt.
98 	// Gleichzeitig bekommt auch jedes neu instanziierte SdrModel
99 	// diesen MapMode default zugewiesen.
100 	// Default MapUnit ist MAP_100TH_MM
SetMapUnit(MapUnit eMap)101 	static void       SetMapUnit(MapUnit eMap)             { GetDefaults().eMapUnit=eMap; }
GetMapUnit()102 	static MapUnit    GetMapUnit()                         { return GetDefaults().eMapUnit; }
103 	// Default MapFraction ist 1/1.
SetMapFraction(const Fraction & rMap)104 	static void       SetMapFraction(const Fraction& rMap) { GetDefaults().aMapFraction=rMap; }
GetMapFraction()105 	static Fraction   GetMapFraction()                     { return GetDefaults().aMapFraction; }
106 	// Der Aufruf der folgenden Methode veranlasst die Engine
107 	// ihre sprachabhaengigen Resourcen neu zu initiallisieren.
108 	// Bereits bestehende Undotexte, etc. bleiben jedoch in der
109 	// sprache erhalten, in der sie erzeugt wurden.
110 	static void       LanguageHasChanged();
111 
112 
113 	// Einen Outliner mit den engineglobalen
114 	// Defaulteinstellungen auf dem Heap erzeugen.
115 	// Ist pMod<>NULL, dann wird der MapMode des uebergebenen
116 	// Models verwendet. Die resultierende Default-Fonthoehe bleibt
117 	// jedoch dieselbe (die logische Fonthoehe wird umgerechnet).
118 	friend SVX_DLLPUBLIC SdrOutliner* SdrMakeOutliner( sal_uInt16 nOutlinerMode, SdrModel* pMod );
119 };
120 
121 class SfxItemSet;
122 // Liefert eine Ersatzdarstellung fuer einen XFillStyle
123 // Bei XFILL_NONE gibt's sal_False und rCol bleibt unveraendert.
124 SVX_DLLPUBLIC FASTBOOL GetDraftFillColor(const SfxItemSet& rSet, Color& rCol);
125 
126 // Ein Container fuer USHORTs (im Prinzip ein dynamisches Array)
127 class UShortCont {
128 	Container aArr;
129 public:
UShortCont(sal_uInt16 nBlock,sal_uInt16 nInit,sal_uInt16 nResize)130 	UShortCont(sal_uInt16 nBlock, sal_uInt16 nInit, sal_uInt16 nResize): aArr(nBlock,nInit,nResize) {}
Clear()131 	void   Clear()                                           { aArr.Clear(); }
Insert(sal_uInt16 nElem,sal_uIntPtr nPos=CONTAINER_APPEND)132 	void   Insert(sal_uInt16 nElem, sal_uIntPtr nPos=CONTAINER_APPEND) { aArr.Insert((void*)sal_uIntPtr(nElem),nPos); }
Remove(sal_uIntPtr nPos)133 	void   Remove(sal_uIntPtr nPos)                                { aArr.Remove(nPos); }
Replace(sal_uInt16 nElem,sal_uIntPtr nPos)134 	void   Replace(sal_uInt16 nElem, sal_uIntPtr nPos)                 { aArr.Replace((void*)sal_uIntPtr(nElem),nPos); }
GetObject(sal_uIntPtr nPos) const135 	sal_uInt16 GetObject(sal_uIntPtr nPos)                       const { return sal_uInt16(sal_uIntPtr(aArr.GetObject(nPos))); }
GetPos(sal_uInt16 nElem) const136 	sal_uIntPtr  GetPos(sal_uInt16 nElem)                        const { return aArr.GetPos((void*)(sal_uIntPtr)nElem); }
GetCount() const137 	sal_uIntPtr  GetCount()                                  const { return aArr.Count(); }
138 	void   Sort();
139 };
140 
141 class ContainerSorter {
142 protected:
143 	Container& rCont;
144 private:
145 //#if 0 // _SOLAR__PRIVATE
146 	void ImpSubSort(long nL, long nR) const;
147 //#endif // __PRIVATE
148 public:
ContainerSorter(Container & rNewCont)149 	ContainerSorter(Container& rNewCont): rCont(rNewCont) {}
150 	void DoSort(sal_uIntPtr a=0, sal_uIntPtr b=0xFFFFFFFF) const;
151 #ifdef This_Is_Just_For_A_Comment
152 	Compare() muss returnieren:
153 	  -1 falls *pElem1<*pElem2
154 	   0 falls *pElem1=*pElem2
155 	  +1 falls *pElem1>*pElem2
156 #endif
157 	virtual int Compare(const void* pElem1, const void* pElem2) const=0;
158 private: // damit keiner vergessen wird
159 virtual
160 		void
161 				 Is1stLessThan2nd(const void* pElem1, const void* pElem2) const;
162 //  virtual FASTBOOL Is1stLessThan2nd(const void* pElem1, const void* pElem2) const=NULL;
163 };
164 
165 ////////////////////////////////////////////////////////////////////////////////////////////////////
166 
167 //#if 0 // _SOLAR__PRIVATE
168 #define SDRHDC_SAVEPEN                1 /* Save Linecolor                     */
169 #define SDRHDC_SAVEBRUSH              2 /* Save Fillcolorn                    */
170 #define SDRHDC_SAVEFONT               4 /* Save Font                          */
171 #define SDRHDC_SAVEPENANDBRUSH        3 /* Save Line- and FillColor           */
172 #define SDRHDC_SAVEPENANDBRUSHANDFONT 7 /* Save Font, Line- and fillcolor     */
173 #define SDRHDC_SAVECLIPPING           8 /* Save Clipping                      */
174 #define SDRHDC_SAVEALL               15 /* Save Clipping, Font, fill- and linecolor */
175 
176 class ImpClipMerk;
177 class ImpColorMerk;
178 class ImpSdrHdcMerk
179 {
180 	ImpColorMerk* pFarbMerk;
181 	ImpClipMerk*  pClipMerk;
182 	Color*		  pLineColorMerk;
183 	sal_uInt16        nMode;
184 public:
185 	ImpSdrHdcMerk(const OutputDevice& rOut, sal_uInt16 nNewMode=SDRHDC_SAVEALL, FASTBOOL bAutoMerk=sal_True);
186 	~ImpSdrHdcMerk();
187 	void Save(const OutputDevice& rOut);
IsSaved() const188 	FASTBOOL IsSaved() const                 { return pFarbMerk!=NULL || pClipMerk!=NULL || pLineColorMerk!=NULL; }
189 	void Restore(OutputDevice& rOut, sal_uInt16 nMask=SDRHDC_SAVEALL) const;
190 };
191 //#endif // __PRIVATE
192 
193 ////////////////////////////////////////////////////////////////////////////////////////////////////
194 
195 // Ein ItemSet auf Outliner- bzw. EditEngine-Items durchsuchen
196 // Liefert sal_True, wenn der Set solchen Items enthaelt.
197 sal_Bool SearchOutlinerItems(const SfxItemSet& rSet, sal_Bool bInklDefaults, sal_Bool* pbOnlyEE=NULL);
198 
199 // zurueck erhaelt man einen neuen WhichTable den
200 // man dann irgendwann mit delete platthauen muss.
201 sal_uInt16* RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd);
202 
203 ////////////////////////////////////////////////////////////////////////////////////////////////////
204 
205 ////////////////////////////////////////////////////////////////////////////////////////////////////
206 
207 class Link;
208 
209 // Hilfsklasse zur kommunikation zwischen dem Dialog
210 // zum aufbrechen von Metafiles (sd/source/ui/dlg/brkdlg.cxx),
211 // SdrEditView::DoImportMarkedMtf() und
212 // ImpSdrGDIMetaFileImport::DoImport()
213 class SVX_DLLPUBLIC SvdProgressInfo
214 {
215 private:
216 	sal_uIntPtr nSumActionCount;	// Summe aller Actions
217 	sal_uIntPtr nSumCurAction;	// Summe aller bearbeiteten Actions
218 
219 	sal_uIntPtr nActionCount;		// Anzahl der Actions im akt. Obj.
220 	sal_uIntPtr nCurAction;		// Anzahl bearbeiteter Act. im akt. Obj.
221 
222 	sal_uIntPtr nInsertCount;		// Anzahl einzufuegender Act. im akt. Obj.
223 	sal_uIntPtr nCurInsert;		// Anzahl bereits eingefuegter Actions
224 
225 	sal_uIntPtr nObjCount;		// Anzahl der selektierten Objekte
226 	sal_uIntPtr nCurObj;			// Aktuelles Objekt
227 
228 	Link *pLink;
229 
230 public:
231 	SvdProgressInfo( Link *_pLink );
232 
233 	void Init( sal_uIntPtr _nSumActionCount, sal_uIntPtr _nObjCount );
234 
235 	sal_Bool SetNextObject();
236 
237 	void SetActionCount( sal_uIntPtr _nActionCount );
238 	void SetInsertCount( sal_uIntPtr _nInsertCount );
239 
240 	sal_Bool ReportActions( sal_uIntPtr nAnzActions );
241 	sal_Bool ReportInserts( sal_uIntPtr nAnzInserts );
242 
GetSumActionCount() const243 	sal_uIntPtr GetSumActionCount() const { return nSumActionCount; };
GetSumCurAction() const244 	sal_uIntPtr GetSumCurAction() const { return nSumCurAction; };
GetObjCount() const245 	sal_uIntPtr GetObjCount() const { return nObjCount; };
GetCurObj() const246 	sal_uIntPtr GetCurObj() const { return nCurObj; };
247 
GetActionCount() const248 	sal_uIntPtr GetActionCount() const { return nActionCount; };
GetCurAction() const249 	sal_uIntPtr GetCurAction() const { return nCurAction; };
250 
GetInsertCount() const251 	sal_uIntPtr GetInsertCount() const { return nInsertCount; };
GetCurInsert() const252 	sal_uIntPtr GetCurInsert() const { return nCurInsert; };
253 
254 	void ReportError();
255 	sal_Bool ReportRescales( sal_uIntPtr nAnzRescales );
256 };
257 
258 
259 
260 class SdrLinkList
261 {
262 	Container aList;
263 protected:
264 	unsigned FindEntry(const Link& rLink) const;
265 public:
SdrLinkList()266 	SdrLinkList(): aList(1024,4,4)        {}
~SdrLinkList()267 	~SdrLinkList()                        { Clear(); }
268 	SVX_DLLPUBLIC void Clear();
GetLinkCount() const269 	unsigned GetLinkCount() const            { return (unsigned)aList.Count(); }
GetLink(unsigned nNum)270 	Link& GetLink(unsigned nNum)             { return *((Link*)(aList.GetObject(nNum))); }
GetLink(unsigned nNum) const271 	const Link& GetLink(unsigned nNum) const { return *((Link*)(aList.GetObject(nNum))); }
272 	void InsertLink(const Link& rLink, unsigned nPos=0xFFFF);
273 	void RemoveLink(const Link& rLink);
HasLink(const Link & rLink) const274 	FASTBOOL HasLink(const Link& rLink) const { return FindEntry(rLink)!=0xFFFF; }
275 };
276 
277 // Fuer die Factory in SvdObj.CXX
278 SdrLinkList& ImpGetUserMakeObjHdl();
279 SdrLinkList& ImpGetUserMakeObjUserDataHdl();
280 
281 class SdrOle2Obj;
282 class AutoTimer;
283 
284 class OLEObjCache : public Container
285 {
286 	sal_uIntPtr				nSize;
287 	AutoTimer*          pTimer;
288 
289     void UnloadOnDemand();
290 	sal_Bool UnloadObj( SdrOle2Obj* pObj );
291 	DECL_LINK( UnloadCheckHdl, AutoTimer* );
292 
293 public:
294 	OLEObjCache();
295 	SVX_DLLPUBLIC ~OLEObjCache();
296 
297 	void SetSize(sal_uIntPtr nNewSize);
298 	void InsertObj(SdrOle2Obj* pObj);
299 	void RemoveObj(SdrOle2Obj* pObj);
300 };
301 
302 
303 class SVX_DLLPUBLIC SdrGlobalData
304 {
305     const SvtSysLocale*         pSysLocale;     // follows always locale settings
306     const CharClass*            pCharClass;     // follows always SysLocale
307     const LocaleDataWrapper*    pLocaleData;    // follows always SysLocale
308 public:
309 	SdrLinkList     	aUserMakeObjHdl;
310 	SdrLinkList     	aUserMakeObjUserDataHdl;
311 	SdrOutliner*       	pOutliner;
312 	SdrEngineDefaults* 	pDefaults;
313 	ResMgr*            	pResMgr;
314 	sal_uIntPtr              	nExchangeFormat;
315 	OLEObjCache			aOLEObjCache;
316 
317 
318     const SvtSysLocale*         GetSysLocale();     // follows always locale settings
319     const CharClass*            GetCharClass();     // follows always SysLocale
320     const LocaleDataWrapper*    GetLocaleData();    // follows always SysLocale
321 public:
322 	SdrGlobalData();
323 	~SdrGlobalData();
324 
GetOLEObjCache()325 	OLEObjCache& 		GetOLEObjCache() { return aOLEObjCache; }
326 };
327 
GetSdrGlobalData()328 inline SdrGlobalData& GetSdrGlobalData()
329 {
330 	void** ppAppData=GetAppData(SHL_SVD);
331 	if (*ppAppData==NULL) {
332 		*ppAppData=new SdrGlobalData;
333 	}
334 	return *((SdrGlobalData*)*ppAppData);
335 }
336 
337 namespace sdr
338 {
339 
340 SVX_DLLPUBLIC String GetResourceString(sal_uInt16 nResID);
341 
342 }
343 
344 /////////////////////////////////////////////////////////////////////
345 // #i101872# isolated GetTextEditBackgroundColor for tooling
346 class SdrObjEditView;
347 
348 SVX_DLLPUBLIC Color GetTextEditBackgroundColor(const SdrObjEditView& rView);
349 
350 /////////////////////////////////////////////////////////////////////
351 
352 #endif //_SVDETC_HXX
353