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