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: svdetc.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 ************************************************************************/
34 #ifndef _STRING_HXX //autogen
35 #include <tools/string.hxx>
38 #ifndef _CONTNR_HXX //autogen
39 #include <tools/contnr.hxx>
42 #ifndef _OUTDEV_HXX //autogen
43 #include <vcl/outdev.hxx>
46 #ifndef _SHL_HXX //autogen
47 #include <tools/shl.hxx>
50 namespace com
{ namespace sun
{ namespace star
{ namespace lang
{
54 class LocaleDataWrapper
;
62 ////////////////////////////////////////////////////////////////////////////////////////////////////
64 // ExchangeFormat-Id der DrawingEngine holen. Daten koennen dann per
65 // static BOOL CopyData(pData,nLen,nFormat);
66 // bereitgestellt werden, wobei pData/nLen einen SvMemoryStream beschreiben in
67 // dem ein SdrModel gestreamt wird an dem fuer die Zeitdauer des Streamens das
68 // Flag SdrModel::SetStreamingSdrModel(TRUE) gesetzt wird.
69 // ULONG SdrGetExchangeFormat(); -- JP 18.01.99 - dafuer gibt es ein define
74 //STRIP008 namespace com { namespace sun { namespace star { namespace lang {
75 //STRIP008 struct Locale;
78 // Globale Defaulteinstellungen fuer die DrawingEngine.
79 // Diese Einstellungen sollte man direkt beim Applikationsstart
80 // vornehmen, noch bevor andere Methoden der Engine gerufen werden.
81 class SdrEngineDefaults
83 friend class SdrAttrObj
;
85 FontFamily eFontFamily
;
89 Fraction aMapFraction
;
92 static SdrEngineDefaults
& GetDefaults();
96 // Default Fontname ist "Times New Roman"
97 static void SetFontName(const String
& rFontName
) { GetDefaults().aFontName
=rFontName
; }
98 static String
GetFontName() { return GetDefaults().aFontName
; }
99 // Default FontFamily ist FAMILY_ROMAN
100 static void SetFontFamily(FontFamily eFam
) { GetDefaults().eFontFamily
=eFam
; }
101 static FontFamily
GetFontFamily() { return GetDefaults().eFontFamily
; }
102 // Default FontColor ist COL_BLACK
103 static void SetFontColor(const Color
& rColor
) { GetDefaults().aFontColor
=rColor
; }
104 static Color
GetFontColor() { return GetDefaults().aFontColor
; }
105 // Default FontHeight ist 847. Die Fonthoehe wird in logischen Einheiten
106 // (MapUnit/MapFraction (siehe unten)) angegeben. Die Defaulteinstellung
107 // 847/100mm entspricht also ca. 24 Point. Verwendet man stattdessen
108 // beispielsweise Twips (SetMapUnit(MAP_TWIP)) (20 Twip = 1 Point) muss
109 // man als Fonthoehe 480 angeben um 24 Point als default zu erhalten.
110 static void SetFontHeight(ULONG nHeight
) { GetDefaults().nFontHeight
=nHeight
; }
111 static ULONG
GetFontHeight() { return GetDefaults().nFontHeight
; }
112 // Der MapMode wird fuer den globalen Outliner benoetigt.
113 // Gleichzeitig bekommt auch jedes neu instanziierte SdrModel
114 // diesen MapMode default zugewiesen.
115 // Default MapUnit ist MAP_100TH_MM
116 static void SetMapUnit(MapUnit eMap
) { GetDefaults().eMapUnit
=eMap
; }
117 static MapUnit
GetMapUnit() { return GetDefaults().eMapUnit
; }
118 // Default MapFraction ist 1/1.
119 static void SetMapFraction(const Fraction
& rMap
) { GetDefaults().aMapFraction
=rMap
; }
120 static Fraction
GetMapFraction() { return GetDefaults().aMapFraction
; }
121 // Der Aufruf der folgenden Methode veranlasst die Engine
122 // ihre sprachabhaengigen Resourcen neu zu initiallisieren.
123 // Bereits bestehende Undotexte, etc. bleiben jedoch in der
124 // sprache erhalten, in der sie erzeugt wurden.
126 // Einen Outliner mit den engineglobalen
127 // Defaulteinstellungen auf dem Heap erzeugen.
128 // Ist pMod<>NULL, dann wird der MapMode des uebergebenen
129 // Models verwendet. Die resultierende Default-Fonthoehe bleibt
130 // jedoch dieselbe (die logische Fonthoehe wird umgerechnet).
131 friend SdrOutliner
* SdrMakeOutliner( USHORT nOutlinerMode
, SdrModel
* pMod
);
134 // Einen Outliner mit den engineglobalen
135 // Defaulteinstellungen auf dem Heap erzeugen.
136 // Ist pMod<>NULL, dann wird der MapMode des uebergebenen
137 // Models verwendet. Die resultierende Default-Fonthoehe bleibt
138 // jedoch dieselbe (die logische Fonthoehe wird umgerechnet).
139 SdrOutliner
* SdrMakeOutliner( USHORT nOutlinerMode
, SdrModel
* pMod
);
141 // Liefert eine Ersatzdarstellung fuer einen XFillStyle
142 // Bei XFILL_NONE gibt's FALSE und rCol bleibt unveraendert.
143 FASTBOOL
GetDraftFillColor(const SfxItemSet
& rSet
, Color
& rCol
);
145 // Ein Container fuer USHORTs (im Prinzip ein dynamisches Array)
149 UShortCont(USHORT nBlock
, USHORT nInit
, USHORT nResize
): aArr(nBlock
,nInit
,nResize
) {}
150 void Clear() { aArr
.Clear(); }
151 void Insert(USHORT nElem
, ULONG nPos
=CONTAINER_APPEND
) { aArr
.Insert((void*)ULONG(nElem
),nPos
); }
152 void Remove(ULONG nPos
) { aArr
.Remove(nPos
); }
153 void Replace(USHORT nElem
, ULONG nPos
) { aArr
.Replace((void*)ULONG(nElem
),nPos
); }
154 USHORT
GetObject(ULONG nPos
) const { return USHORT(ULONG(aArr
.GetObject(nPos
))); }
155 ULONG
GetPos(USHORT nElem
) const { return aArr
.GetPos((void*)(ULONG
)nElem
); }
156 ULONG
GetCount() const { return aArr
.Count(); }
160 class ContainerSorter
{
165 void ImpSubSort(long nL
, long nR
) const;
168 ContainerSorter(Container
& rNewCont
): rCont(rNewCont
) {}
169 void DoSort(ULONG a
=0, ULONG b
=0xFFFFFFFF) const;
170 #ifdef This_Is_Just_For_A_Comment
171 Compare() muss returnieren
:
172 -1 falls
*pElem1
<*pElem2
173 0 falls
*pElem1
=*pElem2
174 +1 falls
*pElem1
>*pElem2
176 virtual int Compare(const void* pElem1
, const void* pElem2
) const = 0;
177 private: // damit keiner vergessen wird
178 // virtual FASTBOOL Is1stLessThan2nd(const void* pElem1, const void* pElem2) const=NULL;
181 ////////////////////////////////////////////////////////////////////////////////////////////////////
184 #define SDRHDC_SAVEPEN 1 /* Save Linecolor */
185 #define SDRHDC_SAVEBRUSH 2 /* Save Fillcolorn */
186 #define SDRHDC_SAVEFONT 4 /* Save Font */
187 #define SDRHDC_SAVEPENANDBRUSH 3 /* Save Line- and FillColor */
188 #define SDRHDC_SAVEPENANDBRUSHANDFONT 7 /* Save Font, Line- and fillcolor */
189 #define SDRHDC_SAVECLIPPING 8 /* Save Clipping */
190 #define SDRHDC_SAVEALL 15 /* Save Clipping, Font, fill- and linecolor */
196 ImpColorMerk
* pFarbMerk
;
197 ImpClipMerk
* pClipMerk
;
198 Color
* pLineColorMerk
;
201 ImpSdrHdcMerk(const OutputDevice
& rOut
, USHORT nNewMode
=SDRHDC_SAVEALL
, FASTBOOL bAutoMerk
=TRUE
);
203 void Save(const OutputDevice
& rOut
);
204 void Restore(OutputDevice
& rOut
, USHORT nMask
=SDRHDC_SAVEALL
) const;
208 ////////////////////////////////////////////////////////////////////////////////////////////////////
210 // Ein ItemSet auf Outliner- bzw. EditEngine-Items durchsuchen
211 // Liefert TRUE, wenn der Set solchen Items enthaelt.
213 // zurueck erhaelt man einen neuen WhichTable den
214 // man dann irgendwann mit delete platthauen muss.
216 ////////////////////////////////////////////////////////////////////////////////////////////////////
218 ////////////////////////////////////////////////////////////////////////////////////////////////////
221 // Hilfsklasse zur kommunikation zwischen dem Dialog
222 // zum aufbrechen von Metafiles (sd/source/ui/dlg/brkdlg.cxx),
223 // SdrEditView::DoImportMarkedMtf() und
224 // ImpSdrGDIMetaFileImport::DoImport()
230 unsigned FindEntry(const Link
& rLink
) const;
232 SdrLinkList(): aList(1024,4,4) {}
233 ~SdrLinkList() { Clear(); }
235 unsigned GetLinkCount() const { return (unsigned)aList
.Count(); }
236 Link
& GetLink(unsigned nNum
) { return *((Link
*)(aList
.GetObject(nNum
))); }
237 const Link
& GetLink(unsigned nNum
) const { return *((Link
*)(aList
.GetObject(nNum
))); }
238 void InsertLink(const Link
& rLink
, unsigned nPos
=0xFFFF);
239 void RemoveLink(const Link
& rLink
);
240 FASTBOOL
HasLink(const Link
& rLink
) const { return FindEntry(rLink
)!=0xFFFF; }
243 // Fuer die Factory in SvdObj.CXX
244 SdrLinkList
& ImpGetUserMakeObjHdl();
245 SdrLinkList
& ImpGetUserMakeObjUserDataHdl();
249 class OLEObjCache
: public Container
254 BOOL
UnloadObj( SdrOle2Obj
* pObj
);
255 DECL_LINK( UnloadCheckHdl
, AutoTimer
* );
261 void InsertObj(SdrOle2Obj
* pObj
);
262 void RemoveObj(SdrOle2Obj
* pObj
);
268 SdrLinkList aUserMakeObjHdl
;
269 SdrLinkList aUserMakeObjUserDataHdl
;
270 SdrOutliner
* pOutliner
;
271 SdrEngineDefaults
* pDefaults
;
274 ULONG nExchangeFormat
;
275 OLEObjCache aOLEObjCache
;
276 const SvtSysLocale
* pSysLocale
; // follows always locale settings
277 const CharClass
* pCharClass
; // follows always SysLocale
278 const LocaleDataWrapper
* pLocaleData
; // follows always SysLocale
284 OLEObjCache
& GetOLEObjCache() { return aOLEObjCache
; }
287 inline SdrGlobalData
& GetSdrGlobalData()
289 void** ppAppData
=GetAppData(BF_SHL_SVD
);
290 if (*ppAppData
==NULL
) {
291 *ppAppData
=new SdrGlobalData
;
293 return *((SdrGlobalData
*)*ppAppData
);
296 /////////////////////////////////////////////////////////////////////
298 }//end of namespace binfilter