1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_IMAP_HXX
21 #define INCLUDED_SVTOOLS_IMAP_HXX
23 #include <svtools/imapobj.hxx>
24 #include <svtools/svtdllapi.h>
25 #include <tools/stream.hxx>
34 typedef ::std::vector
< IMapObject
* > IMapObjectList_impl
;
36 class SVT_DLLPUBLIC ImageMap
40 IMapObjectList_impl maList
;
45 // binary saving/loading
46 void ImpWriteImageMap( SvStream
& rOStm
, const OUString
& ) const ;
47 void ImpReadImageMap( SvStream
& rIStm
, size_t nCount
, const OUString
& );
50 void ImpWriteCERN( SvStream
& rOStm
, const OUString
& rBaseURL
) const;
51 void ImpWriteNCSA( SvStream
& rOStm
, const OUString
& rBaseURL
) const;
52 sal_uLong
ImpReadCERN( SvStream
& rOStm
, const OUString
& rBaseURL
);
53 sal_uLong
ImpReadNCSA( SvStream
& rOStm
, const OUString
& rBaseURL
);
55 void ImpReadCERNLine( const OString
& rLine
, const OUString
& rBaseURL
);
56 static Point
ImpReadCERNCoords( const char** ppStr
);
57 static long ImpReadCERNRadius( const char** ppStr
);
58 static OUString
ImpReadCERNURL( const char** ppStr
, const OUString
& rBaseURL
);
60 void ImpReadNCSALine( const OString
& rLine
, const OUString
& rBaseURL
);
61 static OUString
ImpReadNCSAURL( const char** ppStr
, const OUString
& rBaseURL
);
62 static Point
ImpReadNCSACoords( const char** ppStr
);
64 static sal_uLong
ImpDetectFormat( SvStream
& rIStm
);
71 ImageMap( const OUString
& rName
);
72 ImageMap( const ImageMap
& rImageMap
);
74 // all IMapObjects are destroyed in the destructor
77 ImageMap
& operator=( const ImageMap
& rImageMap
);
79 // comparison (everything is checked for equality)
80 bool operator==( const ImageMap
& rImageMap
);
81 bool operator!=( const ImageMap
& rImageMap
);
83 // a new IMap object is inserted at the end of the Map
84 void InsertIMapObject( const IMapObject
& rIMapObject
);
86 // access to the single ImapObjects; the objects may
87 // not be destroyed from outside
88 IMapObject
* GetIMapObject( size_t nPos
) const
90 return ( nPos
< maList
.size() ) ? maList
[ nPos
] : NULL
;
93 // returns the object which was hit first or NULL;
94 // size and position values are in 1/100mm;
95 // rTotalSize is the original size of the image
96 // rDisplaySize is the current size;
97 // rRelPoint relates to the display size and the upper left
98 // corener of the image
99 IMapObject
* GetHitIMapObject( const Size
& rOriginalSize
,
100 const Size
& rDisplaySize
,
101 const Point
& rRelHitPoint
,
102 sal_uLong nFlags
= 0 );
104 // returns the total amount of IMap objects
105 size_t GetIMapObjectCount() const { return maList
.size(); }
107 // deletes all internal objects
108 void ClearImageMap();
110 // returns the current version number
111 static sal_uInt16
GetVersion() { return IMAGE_MAP_VERSION
; }
113 const OUString
& GetName() const { return aName
; }
114 void SetName( const OUString
& rName
) { aName
= rName
; }
116 // scales all objects of the ImageMap according to the given factor
117 void Scale( const Fraction
& rFractX
, const Fraction
& rFracY
);
120 void Write ( SvStream
& rOStm
, const OUString
& rBaseURL
) const;
121 void Read( SvStream
& rIStm
, const OUString
& rBaseURL
);
123 void Write( SvStream
& rOStm
, sal_uLong nFormat
, const OUString
& rBaseURL
) const;
124 sal_uLong
Read( SvStream
& rIStm
, sal_uLong nFormat
, const OUString
& rBaseURL
);
130 sal_uLong nCompatPos
;
131 sal_uLong nTotalSize
;
135 IMapCompat( const IMapCompat
& ) {}
136 IMapCompat
& operator=( const IMapCompat
& ) { return *this; }
137 bool operator==( const IMapCompat
& ) { return false; }
141 IMapCompat( SvStream
& rStm
, const StreamMode nStreamMode
);
145 #endif // INCLUDED_SVTOOLS_IMAP_HXX
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */