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_IMAP_HXX
21 : #define INCLUDED_SVTOOLS_IMAP_HXX
22 :
23 : #include <svtools/imapobj.hxx>
24 : #include <svtools/svtdllapi.h>
25 : #include <tools/stream.hxx>
26 : #include <vector>
27 :
28 : class Point;
29 : class Rectangle;
30 : class Size;
31 : class Fraction;
32 : class IMapObject;
33 :
34 : typedef ::std::vector< IMapObject* > IMapObjectList_impl;
35 :
36 : class SVT_DLLPUBLIC ImageMap
37 : {
38 : private:
39 :
40 : IMapObjectList_impl maList;
41 : OUString aName;
42 :
43 : protected:
44 :
45 : // binary saving/loading
46 : void ImpWriteImageMap( SvStream& rOStm, const OUString& ) const ;
47 : void ImpReadImageMap( SvStream& rIStm, size_t nCount, const OUString& );
48 :
49 : // Import/Export
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 );
54 :
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 );
59 :
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 );
63 :
64 : static sal_uLong ImpDetectFormat( SvStream& rIStm );
65 :
66 : public:
67 :
68 : TYPEINFO();
69 :
70 76 : ImageMap() {};
71 : ImageMap( const OUString& rName );
72 : ImageMap( const ImageMap& rImageMap );
73 :
74 : // all IMapObjects are destroyed in the destructor
75 : virtual ~ImageMap();
76 :
77 : ImageMap& operator=( const ImageMap& rImageMap );
78 :
79 : // comparison (everything is checked for equality)
80 : bool operator==( const ImageMap& rImageMap );
81 : bool operator!=( const ImageMap& rImageMap );
82 :
83 : // a new IMap object is inserted at the end of the Map
84 : void InsertIMapObject( const IMapObject& rIMapObject );
85 :
86 : // access to the single ImapObjects; the objects may
87 : // not be destroyed from outside
88 12 : IMapObject* GetIMapObject( size_t nPos ) const
89 : {
90 12 : return ( nPos < maList.size() ) ? maList[ nPos ] : NULL;
91 : }
92 :
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 );
103 :
104 : // returns the total amount of IMap objects
105 89 : size_t GetIMapObjectCount() const { return maList.size(); }
106 :
107 : // deletes all internal objects
108 : void ClearImageMap();
109 :
110 : // returns the current version number
111 0 : static sal_uInt16 GetVersion() { return IMAGE_MAP_VERSION; }
112 :
113 76 : const OUString& GetName() const { return aName; }
114 1 : void SetName( const OUString& rName ) { aName = rName; }
115 :
116 : // scales all objects of the ImageMap according to the given factor
117 : void Scale( const Fraction& rFractX, const Fraction& rFracY );
118 :
119 : // Import/Export
120 : void Write ( SvStream& rOStm, const OUString& rBaseURL ) const;
121 : void Read( SvStream& rIStm, const OUString& rBaseURL );
122 :
123 : void Write( SvStream& rOStm, sal_uLong nFormat, const OUString& rBaseURL ) const;
124 : sal_uLong Read( SvStream& rIStm, sal_uLong nFormat, const OUString& rBaseURL );
125 : };
126 :
127 : class IMapCompat
128 : {
129 : SvStream* pRWStm;
130 : sal_uLong nCompatPos;
131 : sal_uLong nTotalSize;
132 : StreamMode nStmMode;
133 :
134 : IMapCompat() {}
135 : IMapCompat( const IMapCompat& ) {}
136 : IMapCompat& operator=( const IMapCompat& ) { return *this; }
137 : bool operator==( const IMapCompat& ) { return false; }
138 :
139 : public:
140 :
141 : IMapCompat( SvStream& rStm, const StreamMode nStreamMode );
142 : ~IMapCompat();
143 : };
144 :
145 : #endif // INCLUDED_SVTOOLS_IMAP_HXX
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|