Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SVTOOLS_IMAPOBJ_HXX
21 : #define INCLUDED_SVTOOLS_IMAPOBJ_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 : #include <svl/macitem.hxx>
25 : #include <rtl/strbuf.hxx>
26 :
27 : class Point;
28 : class Rectangle;
29 : class SvStream;
30 :
31 : #define IMAP_OBJ_NONE ((sal_uInt16)0x0000)
32 : #define IMAP_OBJ_RECTANGLE ((sal_uInt16)0x0001)
33 : #define IMAP_OBJ_CIRCLE ((sal_uInt16)0x0002)
34 : #define IMAP_OBJ_POLYGON ((sal_uInt16)0x0003)
35 : #define IMAP_OBJ_VERSION ((sal_uInt16)0x0005)
36 :
37 : #define IMAGE_MAP_VERSION ((sal_uInt16)0x0001)
38 :
39 : #define IMAPMAGIC "SDIMAP"
40 :
41 : #define IMAP_MIRROR_HORZ 0x00000001L
42 : #define IMAP_MIRROR_VERT 0x00000002L
43 :
44 : #define IMAP_FORMAT_BIN 0x00000001L
45 : #define IMAP_FORMAT_CERN 0x00000002L
46 : #define IMAP_FORMAT_NCSA 0x00000004L
47 : #define IMAP_FORMAT_DETECT 0xffffffffL
48 :
49 : #define IMAP_ERR_OK 0x00000000L
50 : #define IMAP_ERR_FORMAT 0x00000001L
51 :
52 10 : class SVT_DLLPUBLIC IMapObject
53 : {
54 : friend class ImageMap;
55 :
56 : OUString aURL;
57 : OUString aAltText;
58 : OUString aDesc;
59 : OUString aTarget;
60 : OUString aName;
61 : SvxMacroTableDtor aEventList;
62 : bool bActive;
63 :
64 : protected:
65 : sal_uInt16 nReadVersion;
66 :
67 : // binary import/export
68 : virtual void WriteIMapObject( SvStream& rOStm ) const = 0;
69 : virtual void ReadIMapObject( SvStream& rIStm ) = 0;
70 :
71 : // helper methods
72 : static void AppendCERNCoords(OStringBuffer& rBuf, const Point& rPoint100);
73 : void AppendCERNURL(OStringBuffer& rBuf, const OUString& rBaseURL) const;
74 : static void AppendNCSACoords(OStringBuffer& rBuf, const Point& rPoint100);
75 : void AppendNCSAURL(OStringBuffer&rBuf, const OUString& rBaseURL) const;
76 :
77 : public:
78 :
79 : static rtl_TextEncoding nActualTextEncoding;
80 :
81 : IMapObject();
82 : IMapObject( const OUString& rURL,
83 : const OUString& rAltText,
84 : const OUString& rDesc,
85 : const OUString& rTarget,
86 : const OUString& rName,
87 : bool bActive );
88 11 : virtual ~IMapObject() {};
89 :
90 0 : static sal_uInt16 GetVersion() { return IMAP_OBJ_VERSION; }
91 :
92 : virtual sal_uInt16 GetType() const = 0;
93 : virtual bool IsHit( const Point& rPoint ) const = 0;
94 :
95 : void Write ( SvStream& rOStm, const OUString& rBaseURL ) const;
96 : void Read( SvStream& rIStm, const OUString& rBaseURL );
97 :
98 : virtual Rectangle GetBoundRect() const = 0;
99 :
100 2 : const OUString& GetURL() const { return aURL; }
101 0 : void SetURL( const OUString& rURL ) { aURL = rURL; }
102 :
103 1 : const OUString& GetAltText() const { return aAltText; }
104 0 : void SetAltText( const OUString& rAltText) { aAltText = rAltText; }
105 :
106 0 : const OUString& GetDesc() const { return aDesc; }
107 0 : void SetDesc( const OUString& rDesc ) { aDesc = rDesc; }
108 :
109 1 : const OUString& GetTarget() const { return aTarget; }
110 0 : void SetTarget( const OUString& rTarget ) { aTarget = rTarget; }
111 :
112 1 : const OUString& GetName() const { return aName; }
113 0 : void SetName( const OUString& rName ) { aName = rName; }
114 :
115 2 : bool IsActive() const { return bActive; }
116 0 : void SetActive( bool bSetActive = true ) { bActive = bSetActive; }
117 :
118 : bool IsEqual( const IMapObject& rEqObj );
119 :
120 : // IMap-Events
121 1 : inline const SvxMacroTableDtor& GetMacroTable() const { return aEventList;}
122 1 : inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aEventList = rTbl; }
123 :
124 : inline const SvxMacro& GetEvent( sal_uInt16 nEvent ) const;
125 : inline bool HasEvent( sal_uInt16 nEvent ) const;
126 : void SetEvent( sal_uInt16 nEvent, const SvxMacro& );
127 : inline bool DelEvent( sal_uInt16 nEvent );
128 : };
129 :
130 : inline bool IMapObject::HasEvent( sal_uInt16 nEvent ) const
131 : {
132 : return aEventList.IsKeyValid( nEvent );
133 : }
134 : inline const SvxMacro& IMapObject::GetEvent( sal_uInt16 nEvent ) const
135 : {
136 : return *(aEventList.Get( nEvent ));
137 : }
138 : inline bool IMapObject::DelEvent( sal_uInt16 nEvent )
139 : {
140 : return aEventList.Erase( nEvent );
141 : }
142 :
143 : #endif
144 :
145 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|