xref: /trunk/main/svtools/inc/svtools/imapobj.hxx (revision 01aa44aa)
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 _GOODIES_IMAPOBJ_HXX
25 #define _GOODIES_IMAPOBJ_HXX
26 
27 #include "svtools/svtdllapi.h"
28 #include <tools/string.hxx>
29 #include <svl/macitem.hxx>
30 
31 class Point;
32 class Rectangle;
33 class SvStream;
34 
35 #define IMAP_OBJ_NONE		((sal_uInt16)0x0000)
36 #define IMAP_OBJ_RECTANGLE	((sal_uInt16)0x0001)
37 #define IMAP_OBJ_CIRCLE		((sal_uInt16)0x0002)
38 #define IMAP_OBJ_POLYGON	((sal_uInt16)0x0003)
39 #define IMAP_OBJ_VERSION	((sal_uInt16)0x0005)
40 
41 #define IMAGE_MAP_VERSION	((sal_uInt16)0x0001)
42 
43 #define	IMAPMAGIC			"SDIMAP"
44 
45 #define IMAP_MIRROR_HORZ	0x00000001L
46 #define IMAP_MIRROR_VERT	0x00000002L
47 
48 #define IMAP_FORMAT_BIN		0x00000001L
49 #define IMAP_FORMAT_CERN	0x00000002L
50 #define IMAP_FORMAT_NCSA	0x00000004L
51 #define IMAP_FORMAT_DETECT	0xffffffffL
52 
53 #define IMAP_ERR_OK			0x00000000L
54 #define IMAP_ERR_FORMAT		0x00000001L
55 
56 /******************************************************************************
57 |*
58 |*
59 |*
60 \******************************************************************************/
61 
62 class SVT_DLLPUBLIC IMapObject
63 {
64 	friend class		ImageMap;
65 
66 	String				aURL;
67 	String				aAltText;
68 	String				aDesc;
69 	String				aTarget;
70 	String				aName;
71 	SvxMacroTableDtor	aEventList;
72 	sal_Bool				bActive;
73 
74 protected:
75 
76 	sal_uInt16				nReadVersion;
77 
78 	// Binaer-Im-/Export
79 	virtual void		WriteIMapObject( SvStream& rOStm ) const = 0;
80 	virtual void		ReadIMapObject(  SvStream& rIStm ) = 0;
81 
82 	// Hilfsmethoden
83 	void				AppendCERNCoords( const Point& rPoint100, ByteString& rStr ) const;
84     void                AppendCERNURL( ByteString& rStr, const String& rBaseURL ) const;
85 	void				AppendNCSACoords( const Point& rPoint100, ByteString& rStr ) const;
86     void                AppendNCSAURL( ByteString& rStr, const String& rBaseURL ) const;
87 
88 public:
89 
90 	static rtl_TextEncoding	nActualTextEncoding;
91 
92                         IMapObject();
93 						IMapObject( const String& rURL,
94 									const String& rAltText,
95 									const String& rDesc,
96 									const String& rTarget,
97 									const String& rName,
98 									sal_Bool bActive );
~IMapObject()99 	virtual				~IMapObject() {};
100 
101 	virtual sal_uInt16		GetVersion() const;
102 	virtual sal_uInt16		GetType() const = 0;
103 	virtual sal_Bool		IsHit( const Point& rPoint ) const = 0;
104 
105     void                Write ( SvStream& rOStm, const String& rBaseURL ) const;
106     void                Read( SvStream& rIStm, const String& rBaseURL );
107 
108 	virtual Rectangle	GetBoundRect() const = 0;
109 
GetURL() const110 	const String&		GetURL() const { return aURL; }
SetURL(const String & rURL)111 	void				SetURL( const String& rURL ) { aURL = rURL; }
112 
GetAltText() const113 	const String&		GetAltText() const { return aAltText; }
SetAltText(const String & rAltText)114 	void				SetAltText( const String& rAltText) { aAltText = rAltText; }
115 
GetDesc() const116 	const String&		GetDesc() const { return aDesc; }
SetDesc(const String & rDesc)117 	void				SetDesc( const String& rDesc ) { aDesc = rDesc; }
118 
GetTarget() const119 	const String&		GetTarget() const { return aTarget; }
SetTarget(const String & rTarget)120 	void				SetTarget( const String& rTarget ) { aTarget = rTarget; }
121 
GetName() const122 	const String&		GetName() const { return aName; }
SetName(const String & rName)123 	void				SetName( const String& rName ) { aName = rName; }
124 
IsActive() const125 	sal_Bool				IsActive() const { return bActive; }
SetActive(sal_Bool bSetActive=sal_True)126 	void				SetActive( sal_Bool bSetActive = sal_True ) { bActive = bSetActive; }
127 
128 	static Point		GetPixelPoint( const Point& rLogPoint );
129 	static Point		GetLogPoint( const Point& rPixelPoint );
130 
131 	sal_Bool				IsEqual( const IMapObject& rEqObj );
132 
133 	// IMap-Events
GetMacroTable() const134 	inline const SvxMacroTableDtor& GetMacroTable() const { return aEventList;}
SetMacroTable(const SvxMacroTableDtor & rTbl)135 	inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aEventList = rTbl; }
136 
137 	inline const SvxMacro&	GetEvent( sal_uInt16 nEvent ) const;
138 	inline sal_Bool 			HasEvent( sal_uInt16 nEvent ) const;
139 		   void 			SetEvent( sal_uInt16 nEvent, const SvxMacro& );
140 	inline sal_Bool 			DelEvent( sal_uInt16 nEvent );
141 };
142 
HasEvent(sal_uInt16 nEvent) const143 inline sal_Bool IMapObject::HasEvent( sal_uInt16 nEvent ) const
144 {
145 	return aEventList.IsKeyValid( nEvent );
146 }
GetEvent(sal_uInt16 nEvent) const147 inline const SvxMacro& IMapObject::GetEvent( sal_uInt16 nEvent ) const
148 {
149 	return *(aEventList.Get( nEvent ));
150 }
DelEvent(sal_uInt16 nEvent)151 inline sal_Bool IMapObject::DelEvent( sal_uInt16 nEvent )
152 {
153 	SvxMacro *pMacro = aEventList.Remove( nEvent );
154 	delete pMacro;
155 	return ( pMacro != 0 );
156 }
157 
158 #endif
159 
160