Branch libreoffice-5-0-4
[LibreOffice.git] / include / svtools / imapobj.hxx
blob5fcd543e63831d53fc4b74fd767faccfa45bdf77
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVTOOLS_IMAPOBJ_HXX
21 #define INCLUDED_SVTOOLS_IMAPOBJ_HXX
23 #include <svtools/svtdllapi.h>
24 #include <svl/macitem.hxx>
25 #include <rtl/strbuf.hxx>
27 class Point;
28 class Rectangle;
29 class SvStream;
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)
37 #define IMAGE_MAP_VERSION ((sal_uInt16)0x0001)
39 #define IMAPMAGIC "SDIMAP"
41 #define IMAP_MIRROR_HORZ 0x00000001L
42 #define IMAP_MIRROR_VERT 0x00000002L
44 #define IMAP_FORMAT_BIN 0x00000001L
45 #define IMAP_FORMAT_CERN 0x00000002L
46 #define IMAP_FORMAT_NCSA 0x00000004L
47 #define IMAP_FORMAT_DETECT 0xffffffffL
49 #define IMAP_ERR_OK 0x00000000L
50 #define IMAP_ERR_FORMAT 0x00000001L
52 class SVT_DLLPUBLIC IMapObject
54 friend class ImageMap;
56 OUString aURL;
57 OUString aAltText;
58 OUString aDesc;
59 OUString aTarget;
60 OUString aName;
61 SvxMacroTableDtor aEventList;
62 bool bActive;
64 protected:
65 sal_uInt16 nReadVersion;
67 // binary import/export
68 virtual void WriteIMapObject( SvStream& rOStm ) const = 0;
69 virtual void ReadIMapObject( SvStream& rIStm ) = 0;
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;
77 public:
79 static rtl_TextEncoding nActualTextEncoding;
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 virtual ~IMapObject() {};
90 static sal_uInt16 GetVersion() { return IMAP_OBJ_VERSION; }
92 virtual sal_uInt16 GetType() const = 0;
93 virtual bool IsHit( const Point& rPoint ) const = 0;
95 void Write ( SvStream& rOStm, const OUString& rBaseURL ) const;
96 void Read( SvStream& rIStm, const OUString& rBaseURL );
98 virtual Rectangle GetBoundRect() const = 0;
100 const OUString& GetURL() const { return aURL; }
101 void SetURL( const OUString& rURL ) { aURL = rURL; }
103 const OUString& GetAltText() const { return aAltText; }
104 void SetAltText( const OUString& rAltText) { aAltText = rAltText; }
106 const OUString& GetDesc() const { return aDesc; }
107 void SetDesc( const OUString& rDesc ) { aDesc = rDesc; }
109 const OUString& GetTarget() const { return aTarget; }
110 void SetTarget( const OUString& rTarget ) { aTarget = rTarget; }
112 const OUString& GetName() const { return aName; }
113 void SetName( const OUString& rName ) { aName = rName; }
115 bool IsActive() const { return bActive; }
116 void SetActive( bool bSetActive = true ) { bActive = bSetActive; }
118 bool IsEqual( const IMapObject& rEqObj );
120 // IMap-Events
121 inline const SvxMacroTableDtor& GetMacroTable() const { return aEventList;}
122 inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aEventList = rTbl; }
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 );
130 inline bool IMapObject::HasEvent( sal_uInt16 nEvent ) const
132 return aEventList.IsKeyValid( nEvent );
134 inline const SvxMacro& IMapObject::GetEvent( sal_uInt16 nEvent ) const
136 return *(aEventList.Get( nEvent ));
138 inline bool IMapObject::DelEvent( sal_uInt16 nEvent )
140 return aEventList.Erase( nEvent );
143 #endif
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */