xref: /AOO41X/main/svtools/inc/svtools/imap.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _IMAP_HXX
29*cdf0e10cSrcweir #define _IMAP_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "svtools/svtdllapi.h"
32*cdf0e10cSrcweir #include <tools/string.hxx>
33*cdf0e10cSrcweir #include <tools/stream.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir class Point;
36*cdf0e10cSrcweir class Rectangle;
37*cdf0e10cSrcweir class Size;
38*cdf0e10cSrcweir class Fraction;
39*cdf0e10cSrcweir class IMapObject;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir /******************************************************************************
42*cdf0e10cSrcweir |*
43*cdf0e10cSrcweir |*
44*cdf0e10cSrcweir |*
45*cdf0e10cSrcweir \******************************************************************************/
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir class SVT_DLLPUBLIC ImageMap
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir 	List				maList;
50*cdf0e10cSrcweir 	String				aName;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir protected:
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 	// Binaer laden/speichern
55*cdf0e10cSrcweir     void                ImpWriteImageMap( SvStream& rOStm, const String& ) const ;
56*cdf0e10cSrcweir     void                ImpReadImageMap( SvStream& rIStm, sal_uInt16 nCount, const String& );
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 	// Im-/Export
59*cdf0e10cSrcweir     void                ImpWriteCERN( SvStream& rOStm, const String& rBaseURL ) const;
60*cdf0e10cSrcweir     void                ImpWriteNCSA( SvStream& rOStm, const String& rBaseURL ) const;
61*cdf0e10cSrcweir     sal_uLong               ImpReadCERN( SvStream& rOStm, const String& rBaseURL );
62*cdf0e10cSrcweir     sal_uLong               ImpReadNCSA( SvStream& rOStm, const String& rBaseURL );
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir     void                ImpReadCERNLine( const ByteString& rLine, const String& rBaseURL );
65*cdf0e10cSrcweir 	Point				ImpReadCERNCoords( const char** ppStr );
66*cdf0e10cSrcweir 	long				ImpReadCERNRadius( const char** ppStr );
67*cdf0e10cSrcweir     String              ImpReadCERNURL( const char** ppStr, const String& rBaseURL );
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     void                ImpReadNCSALine( const ByteString& rLine, const String& rBaseURL );
70*cdf0e10cSrcweir     String              ImpReadNCSAURL( const char** ppStr, const String& rBaseURL );
71*cdf0e10cSrcweir 	Point				ImpReadNCSACoords( const char** ppStr );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	sal_uLong				ImpDetectFormat( SvStream& rIStm );
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir public:
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	TYPEINFO();
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 						ImageMap() {};
80*cdf0e10cSrcweir 						ImageMap( const String& rName );
81*cdf0e10cSrcweir 						ImageMap( const ImageMap& rImageMap );
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 						// Der Dtor gibt den intern belegten
84*cdf0e10cSrcweir 						// Speicher wieder frei;
85*cdf0e10cSrcweir 						//  alle IMapObjekte werden im Dtor zerstoert;
86*cdf0e10cSrcweir 	virtual				~ImageMap();
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	// Zuweisungsoperator
89*cdf0e10cSrcweir 	ImageMap&			operator=( const ImageMap& rImageMap );
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	// Vergleichsoperator (es wird alles auf Gleichheit geprueft)
92*cdf0e10cSrcweir 	sal_Bool				operator==( const ImageMap& rImageMap );
93*cdf0e10cSrcweir 	sal_Bool				operator!=( const ImageMap& rImageMap );
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	// In die Map wird ein neues IMap-Obkekt ans Ende eingefuegt
96*cdf0e10cSrcweir 	void				InsertIMapObject( const IMapObject& rIMapObject );
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	// Zugriff auf einzelne IMapObjekte; die Objekte
99*cdf0e10cSrcweir 	// duerfen von aussen _nicht_ zerstoert werden
100*cdf0e10cSrcweir 	IMapObject*			GetFirstIMapObject() { return (IMapObject*) maList.First(); }
101*cdf0e10cSrcweir 	IMapObject*			GetNextIMapObject() { return (IMapObject*) maList.Next(); }
102*cdf0e10cSrcweir 	IMapObject*			GetLastIMapObject() { return (IMapObject*) maList.Last(); }
103*cdf0e10cSrcweir 	IMapObject*			GetPrevIMapObject() { return (IMapObject*) maList.Prev(); }
104*cdf0e10cSrcweir 	IMapObject*			GetIMapObject( sal_uInt16 nPos ) const { return (IMapObject*) maList.GetObject( nPos ); }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	// Gibt das Objekt zurueck, das zuerst getroffen wurde oder NULL;
107*cdf0e10cSrcweir 	// Groessen- und Positionsangaben sind in 1/100mm;
108*cdf0e10cSrcweir 	// rTotalSize ist die Originalgroesse des Bildes;
109*cdf0e10cSrcweir 	// rDisplaySize die aktuelle Darstellungsgroesse;
110*cdf0e10cSrcweir 	// rRelPoint bezieht sich auf die Darstellungsgroesse
111*cdf0e10cSrcweir 	// und die linke oebere Ecke des Bildes
112*cdf0e10cSrcweir 	IMapObject*			GetHitIMapObject( const Size& rOriginalSize,
113*cdf0e10cSrcweir 										  const Size& rDisplaySize,
114*cdf0e10cSrcweir 										  const Point& rRelHitPoint,
115*cdf0e10cSrcweir 										  sal_uLong nFlags = 0 );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	// Gibt die Gesamtanzahl der IMap-Objekte zurueck
118*cdf0e10cSrcweir 	sal_uInt16				GetIMapObjectCount() const { return (sal_uInt16) maList.Count(); }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	// Loescht alle internen Objekte
121*cdf0e10cSrcweir 	void				ClearImageMap();
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	// liefert die aktuelle Versionsnummer
124*cdf0e10cSrcweir 	sal_uInt16				GetVersion() const;
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	// liefert / setzt den Namen der ImageMap
127*cdf0e10cSrcweir 	const String&		GetName() const { return aName; }
128*cdf0e10cSrcweir 	void				SetName( const String& rName ) { aName = rName; }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	// gibt das BoundRect aller IMap-Objekte in 1/100mm zurueck
131*cdf0e10cSrcweir 	Rectangle			GetBoundRect() const;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	// skaliert alle Objekte der ImageMap entpr. dem uebergebenen Faktor
134*cdf0e10cSrcweir 	void				Scale( const Fraction& rFractX, const Fraction& rFracY );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	// Im-/Export
137*cdf0e10cSrcweir     void                Write ( SvStream& rOStm, const String& rBaseURL ) const;
138*cdf0e10cSrcweir     void                Read( SvStream& rIStm, const String& rBaseURL );
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     void                Write( SvStream& rOStm, sal_uLong nFormat, const String& rBaseURL ) const;
141*cdf0e10cSrcweir     sal_uLong               Read( SvStream& rIStm, sal_uLong nFormat, const String& rBaseURL );
142*cdf0e10cSrcweir };
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir /******************************************************************************
145*cdf0e10cSrcweir |*
146*cdf0e10cSrcweir |*
147*cdf0e10cSrcweir |*
148*cdf0e10cSrcweir \******************************************************************************/
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir class IMapCompat
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	SvStream*		pRWStm;
155*cdf0e10cSrcweir 	sal_uLong			nCompatPos;
156*cdf0e10cSrcweir 	sal_uLong			nTotalSize;
157*cdf0e10cSrcweir 	sal_uInt16			nStmMode;
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 					IMapCompat() {}
160*cdf0e10cSrcweir 					IMapCompat( const IMapCompat& ) {}
161*cdf0e10cSrcweir 	IMapCompat&		operator=( const IMapCompat& ) { return *this; }
162*cdf0e10cSrcweir 	sal_Bool			operator==( const IMapCompat& ) { return sal_False; }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir public:
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 					IMapCompat( SvStream& rStm, const sal_uInt16 nStreamMode );
167*cdf0e10cSrcweir 					~IMapCompat();
168*cdf0e10cSrcweir };
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir //#endif // __PRIVATE
171*cdf0e10cSrcweir #endif // _IMAP_HXX
172