/src/libreoffice/include/vcl/imap.hxx
Line | Count | Source |
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_VCL_IMAP_HXX |
21 | | #define INCLUDED_VCL_IMAP_HXX |
22 | | |
23 | | #include <vcl/imapobj.hxx> |
24 | | #include <vcl/dllapi.h> |
25 | | #include <rtl/ustring.hxx> |
26 | | #include <tools/long.hxx> |
27 | | #include <tools/solar.h> |
28 | | #include <memory> |
29 | | #include <vector> |
30 | | |
31 | | class Point; |
32 | | class Size; |
33 | | class SvStream; |
34 | | enum class IMapFormat; |
35 | | enum class StreamMode; |
36 | | |
37 | | class VCL_DLLPUBLIC ImageMap final |
38 | | { |
39 | | private: |
40 | | |
41 | | std::vector<std::unique_ptr<IMapObject>> maList; |
42 | | OUString aName; |
43 | | |
44 | | // binary saving/loading |
45 | | SAL_DLLPRIVATE void ImpWriteImageMap( SvStream& rOStm ) const ; |
46 | | SAL_DLLPRIVATE void ImpReadImageMap( SvStream& rIStm, size_t nCount ); |
47 | | |
48 | | // Import/Export |
49 | | SAL_DLLPRIVATE void ImpWriteCERN( SvStream& rOStm ) const; |
50 | | SAL_DLLPRIVATE void ImpWriteNCSA( SvStream& rOStm ) const; |
51 | | SAL_DLLPRIVATE void ImpReadCERN( SvStream& rOStm ); |
52 | | SAL_DLLPRIVATE void ImpReadNCSA( SvStream& rOStm ); |
53 | | |
54 | | SAL_DLLPRIVATE void ImpReadCERNLine( std::string_view rLine ); |
55 | | SAL_DLLPRIVATE static Point ImpReadCERNCoords( const char** ppStr ); |
56 | | SAL_DLLPRIVATE static tools::Long ImpReadCERNRadius( const char** ppStr ); |
57 | | SAL_DLLPRIVATE static OUString ImpReadCERNURL( const char** ppStr ); |
58 | | |
59 | | SAL_DLLPRIVATE void ImpReadNCSALine( std::string_view rLine ); |
60 | | SAL_DLLPRIVATE static OUString ImpReadNCSAURL( const char** ppStr ); |
61 | | SAL_DLLPRIVATE static Point ImpReadNCSACoords( const char** ppStr ); |
62 | | |
63 | | SAL_DLLPRIVATE static IMapFormat ImpDetectFormat( SvStream& rIStm ); |
64 | | |
65 | | public: |
66 | | |
67 | 2.00k | ImageMap() {}; |
68 | | ImageMap( OUString aName ); |
69 | | ImageMap( const ImageMap& rImageMap ); |
70 | | |
71 | | // all IMapObjects are destroyed in the destructor |
72 | | ~ImageMap(); |
73 | | |
74 | | ImageMap& operator=( const ImageMap& rImageMap ); |
75 | | |
76 | | // comparison (everything is checked for equality) |
77 | | bool operator==( const ImageMap& rImageMap ); |
78 | | bool operator!=( const ImageMap& rImageMap ); |
79 | | |
80 | | // a new IMap object is inserted at the end of the Map |
81 | | void InsertIMapObject( const IMapObject& rIMapObject ); |
82 | | void InsertIMapObject( std::unique_ptr<IMapObject> rIMapObject ); |
83 | | |
84 | | // access to the single ImapObjects; the objects may |
85 | | // not be destroyed from outside |
86 | | IMapObject* GetIMapObject( size_t nPos ) const |
87 | 4.44k | { |
88 | 4.44k | return ( nPos < maList.size() ) ? maList[ nPos ].get() : nullptr; |
89 | 4.44k | } |
90 | | |
91 | | // returns the object which was hit first or NULL; |
92 | | // size and position values are in 1/100mm; |
93 | | // rTotalSize is the original size of the image |
94 | | // rDisplaySize is the current size; |
95 | | // rRelPoint relates to the display size and the upper left |
96 | | // corner of the image |
97 | | IMapObject* GetHitIMapObject( const Size& rOriginalSize, |
98 | | const Size& rDisplaySize, |
99 | | const Point& rRelHitPoint, |
100 | | sal_uLong nFlags = 0 ) const; |
101 | | |
102 | | // returns the total amount of IMap objects |
103 | 10.2k | size_t GetIMapObjectCount() const { return maList.size(); } |
104 | | |
105 | | // deletes all internal objects |
106 | | void ClearImageMap(); |
107 | | |
108 | 5.62k | const OUString& GetName() const { return aName; } |
109 | 1.27k | void SetName( const OUString& rName ) { aName = rName; } |
110 | | |
111 | | // scales all objects of the ImageMap according to the given factor |
112 | | void Scale( double fFractX, double fFracY ); |
113 | | |
114 | | // Import/Export |
115 | | SAL_DLLPRIVATE void Write ( SvStream& rOStm ) const; |
116 | | void Read( SvStream& rIStm ); |
117 | | |
118 | | void Write( SvStream& rOStm, IMapFormat nFormat ) const; |
119 | | sal_uLong Read( SvStream& rIStm, IMapFormat nFormat ); |
120 | | }; |
121 | | |
122 | | class IMapCompat |
123 | | { |
124 | | SvStream* pRWStm; |
125 | | sal_uInt64 nCompatPos; |
126 | | sal_uInt64 nTotalSize; |
127 | | StreamMode nStmMode; |
128 | | |
129 | | IMapCompat( const IMapCompat& ) = delete; |
130 | 0 | IMapCompat& operator=( const IMapCompat& ) { return *this; } |
131 | | |
132 | | public: |
133 | | |
134 | | IMapCompat( SvStream& rStm, const StreamMode nStreamMode ); |
135 | | ~IMapCompat(); |
136 | | }; |
137 | | |
138 | | #endif // INCLUDED_VCL_IMAP_HXX |
139 | | |
140 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |