xref: /AOO41X/main/svtools/inc/svtools/imap.hxx (revision 01aa44aa134af97080e2cf8e8bf3a0a4cd1cffe0)
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 _IMAP_HXX
25 #define _IMAP_HXX
26 
27 #include "svtools/svtdllapi.h"
28 #include <tools/string.hxx>
29 #include <tools/stream.hxx>
30 
31 class Point;
32 class Rectangle;
33 class Size;
34 class Fraction;
35 class IMapObject;
36 
37 /******************************************************************************
38 |*
39 |*
40 |*
41 \******************************************************************************/
42 
43 class SVT_DLLPUBLIC ImageMap
44 {
45     List                maList;
46     String              aName;
47 
48 protected:
49 
50     // Binaer laden/speichern
51     void                ImpWriteImageMap( SvStream& rOStm, const String& ) const ;
52     void                ImpReadImageMap( SvStream& rIStm, sal_uInt16 nCount, const String& );
53 
54     // Im-/Export
55     void                ImpWriteCERN( SvStream& rOStm, const String& rBaseURL ) const;
56     void                ImpWriteNCSA( SvStream& rOStm, const String& rBaseURL ) const;
57     sal_uLong               ImpReadCERN( SvStream& rOStm, const String& rBaseURL );
58     sal_uLong               ImpReadNCSA( SvStream& rOStm, const String& rBaseURL );
59 
60     void                ImpReadCERNLine( const ByteString& rLine, const String& rBaseURL );
61     Point               ImpReadCERNCoords( const char** ppStr );
62     long                ImpReadCERNRadius( const char** ppStr );
63     String              ImpReadCERNURL( const char** ppStr, const String& rBaseURL );
64 
65     void                ImpReadNCSALine( const ByteString& rLine, const String& rBaseURL );
66     String              ImpReadNCSAURL( const char** ppStr, const String& rBaseURL );
67     Point               ImpReadNCSACoords( const char** ppStr );
68 
69     sal_uLong               ImpDetectFormat( SvStream& rIStm );
70 
71 public:
72 
73     TYPEINFO();
74 
ImageMap()75                         ImageMap() {};
76                         ImageMap( const String& rName );
77                         ImageMap( const ImageMap& rImageMap );
78 
79                         // Der Dtor gibt den intern belegten
80                         // Speicher wieder frei;
81                         //  alle IMapObjekte werden im Dtor zerstoert;
82     virtual             ~ImageMap();
83 
84     // Zuweisungsoperator
85     ImageMap&           operator=( const ImageMap& rImageMap );
86 
87     // Vergleichsoperator (es wird alles auf Gleichheit geprueft)
88     sal_Bool                operator==( const ImageMap& rImageMap );
89     sal_Bool                operator!=( const ImageMap& rImageMap );
90 
91     // In die Map wird ein neues IMap-Obkekt ans Ende eingefuegt
92     void                InsertIMapObject( const IMapObject& rIMapObject );
93 
94     // Zugriff auf einzelne IMapObjekte; die Objekte
95     // duerfen von aussen _nicht_ zerstoert werden
GetFirstIMapObject()96     IMapObject*         GetFirstIMapObject() { return (IMapObject*) maList.First(); }
GetNextIMapObject()97     IMapObject*         GetNextIMapObject() { return (IMapObject*) maList.Next(); }
GetLastIMapObject()98     IMapObject*         GetLastIMapObject() { return (IMapObject*) maList.Last(); }
GetPrevIMapObject()99     IMapObject*         GetPrevIMapObject() { return (IMapObject*) maList.Prev(); }
GetIMapObject(sal_uInt16 nPos) const100     IMapObject*         GetIMapObject( sal_uInt16 nPos ) const { return (IMapObject*) maList.GetObject( nPos ); }
101 
102     // Gibt das Objekt zurueck, das zuerst getroffen wurde oder NULL;
103     // Groessen- und Positionsangaben sind in 1/100mm;
104     // rTotalSize ist die Originalgroesse des Bildes;
105     // rDisplaySize die aktuelle Darstellungsgroesse;
106     // rRelPoint bezieht sich auf die Darstellungsgroesse
107     // und die linke oebere Ecke des Bildes
108     IMapObject*         GetHitIMapObject( const Size& rOriginalSize,
109                                           const Size& rDisplaySize,
110                                           const Point& rRelHitPoint,
111                                           sal_uLong nFlags = 0 );
112 
113     // Gibt die Gesamtanzahl der IMap-Objekte zurueck
GetIMapObjectCount() const114     sal_uInt16              GetIMapObjectCount() const { return (sal_uInt16) maList.Count(); }
115 
116     // Loescht alle internen Objekte
117     void                ClearImageMap();
118 
119     // liefert die aktuelle Versionsnummer
120     sal_uInt16              GetVersion() const;
121 
122     // liefert / setzt den Namen der ImageMap
GetName() const123     const String&       GetName() const { return aName; }
SetName(const String & rName)124     void                SetName( const String& rName ) { aName = rName; }
125 
126     // gibt das BoundRect aller IMap-Objekte in 1/100mm zurueck
127     Rectangle           GetBoundRect() const;
128 
129     // skaliert alle Objekte der ImageMap entpr. dem uebergebenen Faktor
130     void                Scale( const Fraction& rFractX, const Fraction& rFracY );
131 
132     // Im-/Export
133     void                Write ( SvStream& rOStm, const String& rBaseURL ) const;
134     void                Read( SvStream& rIStm, const String& rBaseURL );
135 
136     void                Write( SvStream& rOStm, sal_uLong nFormat, const String& rBaseURL ) const;
137     sal_uLong               Read( SvStream& rIStm, sal_uLong nFormat, const String& rBaseURL );
138 };
139 
140 /******************************************************************************
141 |*
142 |*
143 |*
144 \******************************************************************************/
145 
146 //#if 0 // _SOLAR__PRIVATE
147 
148 class IMapCompat
149 {
150     SvStream*       pRWStm;
151     sal_uLong           nCompatPos;
152     sal_uLong           nTotalSize;
153     sal_uInt16          nStmMode;
154 
IMapCompat()155                     IMapCompat() {}
IMapCompat(const IMapCompat &)156                     IMapCompat( const IMapCompat& ) {}
operator =(const IMapCompat &)157     IMapCompat&     operator=( const IMapCompat& ) { return *this; }
operator ==(const IMapCompat &)158     sal_Bool            operator==( const IMapCompat& ) { return sal_False; }
159 
160 public:
161 
162                     IMapCompat( SvStream& rStm, const sal_uInt16 nStreamMode );
163                     ~IMapCompat();
164 };
165 
166 //#endif // __PRIVATE
167 #endif // _IMAP_HXX
168