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