LibreOffice Module vcl (master) 1
imap.cxx
Go to the documentation of this file.
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
21#include <tools/urlobj.hxx>
22#include <tools/fract.hxx>
24#include <utility>
25#include <vcl/outdev.hxx>
26#include <vcl/svapp.hxx>
27#include <vcl/mapmod.hxx>
28#include <o3tl/numeric.hxx>
29#include <svl/urihelper.hxx>
30#include <vcl/imap.hxx>
31#include <vcl/imapobj.hxx>
32#include <vcl/imapcirc.hxx>
33#include <vcl/imaprect.hxx>
34#include <vcl/imappoly.hxx>
35
36#include <string.h>
37#include <math.h>
38#include <memory>
39#include <sal/log.hxx>
40
41
42#define SCALEPOINT(aPT,aFracX,aFracY) (aPT).setX(tools::Long((aPT).X()*aFracX)); \
43 (aPT).setY(tools::Long((aPT).Y()*aFracY));
44
45
46/******************************************************************************/
47
48
50 : bActive( false )
51 , nReadVersion( 0 )
52{
53}
54
55IMapObject::IMapObject( OUString _aURL, OUString _aAltText, OUString _aDesc,
56 OUString _aTarget, OUString _aName, bool bURLActive )
57: aURL(std::move( _aURL ))
58, aAltText(std::move( _aAltText ))
59, aDesc(std::move( _aDesc ))
60, aTarget(std::move( _aTarget ))
61, aName(std::move( _aName ))
62, bActive( bURLActive )
63, nReadVersion( 0 )
64{
65}
66
67
68void IMapObject::Write( SvStream& rOStm ) const
69{
70 const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
71
72 rOStm.WriteUInt16( static_cast<sal_uInt16>(GetType()) );
74 rOStm.WriteUInt16( eEncoding );
75
76 const OString aRelURL = OUStringToOString(
80 rOStm.WriteBool( bActive );
82
83 IMapCompat aCompat( rOStm, StreamMode::WRITE );
84
85 WriteIMapObject( rOStm );
86 aEventList.Write( rOStm ); // V4
88}
89
90
91/******************************************************************************
92|*
93|* Binary import
94|*
95\******************************************************************************/
96
98{
99 rtl_TextEncoding nTextEncoding;
100
101 // read on type and version
102 rIStm.SeekRel( 2 );
103 rIStm.ReadUInt16( nReadVersion );
104 rIStm.ReadUInt16( nTextEncoding );
105 aURL = read_uInt16_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding);
107 rIStm.ReadCharAsBool( bActive );
109
110 // make URL absolute
112 IMapCompat aCompat( rIStm, StreamMode::READ );
113
114 ReadIMapObject( rIStm );
115
116 // from version 4 onwards we read an eventlist
117 if ( nReadVersion >= 0x0004 )
118 {
119 aEventList.Read(rIStm);
121 // from version 5 onwards an objectname could be available
122 if ( nReadVersion >= 0x0005 )
123 aName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding);
124 }
125}
126
127bool IMapObject::IsEqual( const IMapObject& rEqObj ) const
128{
129 return ( ( aURL == rEqObj.aURL ) &&
130 ( aAltText == rEqObj.aAltText ) &&
131 ( aDesc == rEqObj.aDesc ) &&
132 ( aTarget == rEqObj.aTarget ) &&
133 ( aName == rEqObj.aName ) &&
134 ( bActive == rEqObj.bActive ) );
135}
136
138 const OUString& rURL,
139 const OUString& rAltText,
140 const OUString& rDesc,
141 const OUString& rTarget,
142 const OUString& rName,
143 bool bURLActive,
144 bool bPixelCoords ) :
145 IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive )
146{
147 ImpConstruct( rRect, bPixelCoords );
148}
149
151{
152 if ( bPixel )
153 aRect = Application::GetDefaultDevice()->PixelToLogic( rRect, MapMode( MapUnit::Map100thMM ) );
154 else
155 aRect = rRect;
156}
157
158
159/******************************************************************************
160|*
161|* Binary export
162|*
163\******************************************************************************/
164
166{
167 tools::GenericTypeSerializer aSerializer(rOStm);
168 aSerializer.writeRectangle(aRect);
169}
170
171
172/******************************************************************************
173|*
174|* Binary import
175|*
176\******************************************************************************/
177
179{
180 tools::GenericTypeSerializer aSerializer(rIStm);
181 aSerializer.readRectangle(aRect);
182}
183
184
185/******************************************************************************
186|*
187|* return type
188|*
189\******************************************************************************/
190
192{
194}
195
196
197/******************************************************************************
198|*
199|* Hit test
200|*
201\******************************************************************************/
202
203bool IMapRectangleObject::IsHit( const Point& rPoint ) const
204{
205 return aRect.Contains( rPoint );
206}
207
209{
210 tools::Rectangle aNewRect;
211
212 if ( bPixelCoords )
213 aNewRect = Application::GetDefaultDevice()->LogicToPixel( aRect, MapMode( MapUnit::Map100thMM ) );
214 else
215 aNewRect = aRect;
216
217 return aNewRect;
218}
219
220void IMapRectangleObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
221{
222 Point aTL( aRect.TopLeft() );
223 Point aBR( aRect.BottomRight() );
224
225 if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
226 {
227 SCALEPOINT( aTL, rFracX, rFracY );
228 SCALEPOINT( aBR, rFracX, rFracY );
229 }
230
231 aRect = tools::Rectangle( aTL, aBR );
232}
233
235{
236 return ( IMapObject::IsEqual( rEqObj ) && ( aRect == rEqObj.aRect ) );
237}
238
239IMapCircleObject::IMapCircleObject( const Point& rCenter, sal_Int32 nCircleRadius,
240 const OUString& rURL,
241 const OUString& rAltText,
242 const OUString& rDesc,
243 const OUString& rTarget,
244 const OUString& rName,
245 bool bURLActive,
246 bool bPixelCoords ) :
247 IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive )
248{
249 ImpConstruct( rCenter, nCircleRadius, bPixelCoords );
250}
251
252void IMapCircleObject::ImpConstruct( const Point& rCenter, sal_Int32 nRad, bool bPixel )
253{
254 if ( bPixel )
255 {
256 MapMode aMap100( MapUnit::Map100thMM );
257
258 aCenter = Application::GetDefaultDevice()->PixelToLogic( rCenter, aMap100 );
259 nRadius = Application::GetDefaultDevice()->PixelToLogic( Size( nRad, 0 ), aMap100 ).Width();
260 }
261 else
262 {
263 aCenter = rCenter;
264 nRadius = nRad;
265 }
266}
267
268
269/******************************************************************************
270|*
271|* Binary export
272|*
273\******************************************************************************/
274
276{
277 sal_uInt32 nTmp = nRadius;
278 tools::GenericTypeSerializer aSerializer(rOStm);
279 aSerializer.writePoint(aCenter);
280 rOStm.WriteUInt32( nTmp );
281}
282
283
284/******************************************************************************
285|*
286|* Binary import
287|*
288\******************************************************************************/
289
291{
292 sal_uInt32 nTmp;
293
294 tools::GenericTypeSerializer aSerializer(rIStm);
295 aSerializer.readPoint(aCenter);
296 rIStm.ReadUInt32( nTmp );
297
298 nRadius = nTmp;
299}
300
301
302/******************************************************************************
303|*
304|* return type
305|*
306\******************************************************************************/
307
309{
311}
312
313
314/******************************************************************************
315|*
316|* Hit-Test
317|*
318\******************************************************************************/
319
320bool IMapCircleObject::IsHit( const Point& rPoint ) const
321{
322 const Point aPoint( aCenter - rPoint );
323
324 return static_cast<sal_Int32>( std::hypot( aPoint.X(), aPoint.Y() ) ) <= nRadius;
325}
326
327Point IMapCircleObject::GetCenter( bool bPixelCoords ) const
328{
329 Point aNewPoint;
330
331 if ( bPixelCoords )
332 aNewPoint = Application::GetDefaultDevice()->LogicToPixel( aCenter, MapMode( MapUnit::Map100thMM ) );
333 else
334 aNewPoint = aCenter;
335
336 return aNewPoint;
337}
338
339sal_Int32 IMapCircleObject::GetRadius( bool bPixelCoords ) const
340{
341 sal_Int32 nNewRadius;
342
343 if ( bPixelCoords )
344 nNewRadius = Application::GetDefaultDevice()->LogicToPixel( Size( nRadius, 0 ), MapMode( MapUnit::Map100thMM ) ).Width();
345 else
346 nNewRadius = nRadius;
347
348 return nNewRadius;
349}
350
351void IMapCircleObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
352{
353 Fraction aAverage( rFracX );
354
355 aAverage += rFracY;
356 aAverage *= Fraction( 1, 2 );
357
358 if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
359 {
360 SCALEPOINT( aCenter, rFracX, rFracY );
361 }
362
363 if (!aAverage.GetDenominator())
364 throw o3tl::divide_by_zero();
365
366 nRadius = double(nRadius * aAverage);
367}
368
370{
371 return ( IMapObject::IsEqual( rEqObj ) &&
372 ( aCenter == rEqObj.aCenter ) &&
373 ( nRadius == rEqObj.nRadius ) );
374}
375
377 const OUString& rURL,
378 const OUString& rAltText,
379 const OUString& rDesc,
380 const OUString& rTarget,
381 const OUString& rName,
382 bool bURLActive,
383 bool bPixelCoords ) :
384 IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive ),
385 bEllipse ( false )
386{
387 ImpConstruct( rPoly, bPixelCoords );
388}
389
390void IMapPolygonObject::ImpConstruct( const tools::Polygon& rPoly, bool bPixel )
391{
392 if ( bPixel )
393 aPoly = Application::GetDefaultDevice()->PixelToLogic( rPoly, MapMode( MapUnit::Map100thMM ) );
394 else
395 aPoly = rPoly;
396}
397
398
399/******************************************************************************
400|*
401|* Binary export
402|*
403\******************************************************************************/
404
406{
407 tools::GenericTypeSerializer aSerializer(rOStm);
408 WritePolygon( rOStm, aPoly );
409 // Version 2
410 rOStm.WriteBool( bEllipse );
411 aSerializer.writeRectangle(aEllipse);
412}
413
414
415/******************************************************************************
416|*
417|* Binary import
418|*
419\******************************************************************************/
420
422{
423 ReadPolygon( rIStm, aPoly );
424
425 // Version >= 2 has additional ellipses information
426 if ( nReadVersion >= 2 )
427 {
428 rIStm.ReadCharAsBool( bEllipse );
429 tools::GenericTypeSerializer aSerializer(rIStm);
430 aSerializer.readRectangle(aEllipse);
431 }
432}
433
434
435/******************************************************************************
436|*
437|* return type
438|*
439\******************************************************************************/
440
442{
444}
445
446
447/******************************************************************************
448|*
449|* hit test
450|*
451\******************************************************************************/
452
453bool IMapPolygonObject::IsHit( const Point& rPoint ) const
454{
455 return aPoly.Contains( rPoint );
456}
457
459{
460 tools::Polygon aNewPoly;
461
462 if ( bPixelCoords )
463 aNewPoly = Application::GetDefaultDevice()->LogicToPixel( aPoly, MapMode( MapUnit::Map100thMM ) );
464 else
465 aNewPoly = aPoly;
466
467 return aNewPoly;
468}
469
471{
472 if ( aPoly.GetSize() )
473 {
474 bEllipse = true;
475 aEllipse = rEllipse;
476 }
477}
478
479void IMapPolygonObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
480{
481 sal_uInt16 nCount = aPoly.GetSize();
482
483 for ( sal_uInt16 i = 0; i < nCount; i++ )
484 {
485 Point aScaledPt( aPoly[ i ] );
486
487 if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
488 {
489 SCALEPOINT( aScaledPt, rFracX, rFracY );
490 }
491
492 aPoly[ i ] = aScaledPt;
493 }
494
495 if ( !bEllipse )
496 return;
497
498 Point aTL( aEllipse.TopLeft() );
499 Point aBR( aEllipse.BottomRight() );
500
501 if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
502 {
503 SCALEPOINT( aTL, rFracX, rFracY );
504 SCALEPOINT( aBR, rFracX, rFracY );
505 }
506
507 aEllipse = tools::Rectangle( aTL, aBR );
508}
509
511{
512 bool bRet = false;
513
514 if ( IMapObject::IsEqual( rEqObj ) )
515 {
516 const tools::Polygon& rEqPoly = rEqObj.aPoly;
517 const sal_uInt16 nCount = aPoly.GetSize();
518 const sal_uInt16 nEqCount = rEqPoly.GetSize();
519
520 if ( nCount == nEqCount )
521 {
522 bool bDifferent = false;
523
524 for ( sal_uInt16 i = 0; i < nCount; i++ )
525 {
526 if ( aPoly[ i ] != rEqPoly[ i ] )
527 {
528 bDifferent = true;
529 break;
530 }
531 }
532
533 if ( !bDifferent )
534 bRet = true;
535 }
536 }
537
538 return bRet;
539}
540
541/******************************************************************************
542|*
543|* Ctor
544|*
545\******************************************************************************/
546
547ImageMap::ImageMap( OUString _aName )
548: aName(std::move( _aName ))
549{
550}
551
552
553/******************************************************************************
554|*
555|* Copy-Ctor
556|*
557\******************************************************************************/
558
559ImageMap::ImageMap( const ImageMap& rImageMap )
560{
561
562 size_t nCount = rImageMap.GetIMapObjectCount();
563
564 for ( size_t i = 0; i < nCount; i++ )
565 {
566 IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
567
568 switch( pCopyObj->GetType() )
569 {
571 maList.emplace_back( new IMapRectangleObject( *static_cast<IMapRectangleObject*>( pCopyObj ) ) );
572 break;
573
575 maList.emplace_back( new IMapCircleObject( *static_cast<IMapCircleObject*>( pCopyObj ) ) );
576 break;
577
579 maList.emplace_back( new IMapPolygonObject( *static_cast<IMapPolygonObject*>( pCopyObj ) ) );
580 break;
581
582 default:
583 break;
584 }
585 }
586
587 aName = rImageMap.aName;
588}
589
590
591/******************************************************************************
592|*
593|* Dtor
594|*
595\******************************************************************************/
596
598{
599}
600
601
602/******************************************************************************
603|*
604|* release internal memory
605|*
606\******************************************************************************/
607
609{
610 maList.clear();
611
612 aName.clear();
613}
614
615
616/******************************************************************************
617|*
618|* assignment operator
619|*
620\******************************************************************************/
621
623{
624 if (this != &rImageMap)
625 {
626 size_t nCount = rImageMap.GetIMapObjectCount();
627
629
630 for ( size_t i = 0; i < nCount; i++ )
631 {
632 IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
633
634 switch( pCopyObj->GetType() )
635 {
637 maList.emplace_back( new IMapRectangleObject( *static_cast<IMapRectangleObject*>(pCopyObj) ) );
638 break;
639
641 maList.emplace_back( new IMapCircleObject( *static_cast<IMapCircleObject*>(pCopyObj) ) );
642 break;
643
645 maList.emplace_back( new IMapPolygonObject( *static_cast<IMapPolygonObject*>(pCopyObj) ) );
646 break;
647
648 default:
649 break;
650 }
651 }
652
653 aName = rImageMap.aName;
654 }
655 return *this;
656}
657
658
659/******************************************************************************
660|*
661|* compare operator I
662|*
663\******************************************************************************/
664
665bool ImageMap::operator==( const ImageMap& rImageMap )
666{
667 const size_t nCount = maList.size();
668 const size_t nEqCount = rImageMap.GetIMapObjectCount();
669 bool bRet = false;
670
671 if ( nCount == nEqCount )
672 {
673 bool bDifferent = ( aName != rImageMap.aName );
674
675 for ( size_t i = 0; ( i < nCount ) && !bDifferent; i++ )
676 {
677 IMapObject* pObj = maList[ i ].get();
678 IMapObject* pEqObj = rImageMap.GetIMapObject( i );
679
680 if ( pObj->GetType() == pEqObj->GetType() )
681 {
682 switch( pObj->GetType() )
683 {
685 {
686 if ( ! static_cast<IMapRectangleObject*>(pObj)->IsEqual( *static_cast<IMapRectangleObject*>(pEqObj) ) )
687 bDifferent = true;
688 }
689 break;
690
692 {
693 if ( ! static_cast<IMapCircleObject*>(pObj)->IsEqual( *static_cast<IMapCircleObject*>(pEqObj) ) )
694 bDifferent = true;
695 }
696 break;
697
699 {
700 if ( ! static_cast<IMapPolygonObject*>(pObj)->IsEqual( *static_cast<IMapPolygonObject*>(pEqObj) ) )
701 bDifferent = true;
702 }
703 break;
704
705 default:
706 break;
707 }
708 }
709 else
710 bDifferent = true;
711 }
712
713 if ( !bDifferent )
714 bRet = true;
715 }
716
717 return bRet;
718}
719
720
721/******************************************************************************
722|*
723|* compare operator II
724|*
725\******************************************************************************/
726
727bool ImageMap::operator!=( const ImageMap& rImageMap )
728{
729 return !( *this == rImageMap );
730}
731
732
733/******************************************************************************
734|*
735|* insert new object
736|*
737\******************************************************************************/
738
739void ImageMap::InsertIMapObject( const IMapObject& rIMapObject )
740{
741 switch( rIMapObject.GetType() )
742 {
744 maList.emplace_back( new IMapRectangleObject( static_cast<const IMapRectangleObject&>( rIMapObject ) ) );
745 break;
746
748 maList.emplace_back( new IMapCircleObject( static_cast<const IMapCircleObject&>( rIMapObject ) ) );
749 break;
750
752 maList.emplace_back( new IMapPolygonObject( static_cast<const IMapPolygonObject&>( rIMapObject ) ) );
753 break;
754
755 default:
756 break;
757 }
758}
759
760void ImageMap::InsertIMapObject( std::unique_ptr<IMapObject> pNewObject )
761{
762 maList.emplace_back( std::move(pNewObject) );
763}
764
765/******************************************************************************
766|*
767|* hit test
768|*
769\******************************************************************************/
770
772 const Size& rDisplaySize,
773 const Point& rRelHitPoint,
774 sal_uLong nFlags ) const
775{
776 Point aRelPoint( rTotalSize.Width() * rRelHitPoint.X() / rDisplaySize.Width(),
777 rTotalSize.Height() * rRelHitPoint.Y() / rDisplaySize.Height() );
778
779 // transform point to check before checking if flags to mirror etc. are set,
780 if ( nFlags )
781 {
782 if ( nFlags & IMAP_MIRROR_HORZ )
783 aRelPoint.setX( rTotalSize.Width() - aRelPoint.X() );
784
785 if ( nFlags & IMAP_MIRROR_VERT )
786 aRelPoint.setY( rTotalSize.Height() - aRelPoint.Y() );
787 }
788
789 // walk over all objects and execute HitTest
790 IMapObject* pObj = nullptr;
791 for(const auto& i : maList) {
792 if ( i->IsHit( aRelPoint ) ) {
793 pObj = i.get();
794 break;
795 }
796 }
797
798 return( pObj ? ( pObj->IsActive() ? pObj : nullptr ) : nullptr );
799}
800
801void ImageMap::Scale( const Fraction& rFracX, const Fraction& rFracY )
802{
803 size_t nCount = maList.size();
804
805 for ( size_t i = 0; i < nCount; i++ )
806 {
807 IMapObject* pObj = maList[ i ].get();
808
809 switch( pObj->GetType() )
810 {
812 static_cast<IMapRectangleObject*>( pObj )->Scale( rFracX, rFracY );
813 break;
814
816 static_cast<IMapCircleObject*>( pObj )->Scale( rFracX, rFracY );
817 break;
818
820 static_cast<IMapPolygonObject*>( pObj )->Scale( rFracX, rFracY );
821 break;
822
823 default:
824 break;
825 }
826 }
827}
828
829
830/******************************************************************************
831|*
832|* sequentially write objects
833|*
834\******************************************************************************/
835
837{
838 size_t nCount = maList.size();
839
840 for ( size_t i = 0; i < nCount; i++ )
841 {
842 auto& pObj = maList[ i ];
843 pObj->Write( rOStm );
844 }
845}
846
847
848/******************************************************************************
849|*
850|* sequentially read objects
851|*
852\******************************************************************************/
853
854void ImageMap::ImpReadImageMap( SvStream& rIStm, size_t nCount )
855{
856 const size_t nMinRecordSize = 12; //circle, three 32bit numbers
857 const size_t nMaxRecords = rIStm.remainingSize() / nMinRecordSize;
858
859 if (nCount > nMaxRecords)
860 {
861 SAL_WARN("svtools.misc", "Parsing error: " << nMaxRecords << " max possible entries, but " <<
862 nCount << " claimed, truncating");
863 nCount = nMaxRecords;
864 }
865
866 // read new objects
867 for (size_t i = 0; i < nCount; ++i)
868 {
869 sal_uInt16 nType;
870
871 rIStm.ReadUInt16( nType );
872 rIStm.SeekRel( -2 );
873
874 switch( static_cast<IMapObjectType>(nType) )
875 {
877 {
879 pObj->Read( rIStm );
880 maList.emplace_back( pObj );
881 }
882 break;
883
885 {
887 pObj->Read( rIStm );
888 maList.emplace_back( pObj );
889 }
890 break;
891
893 {
895 pObj->Read( rIStm );
896 maList.emplace_back( pObj );
897 }
898 break;
899
900 default:
901 break;
902 }
903 }
904}
905
906
907/******************************************************************************
908|*
909|* store binary
910|*
911\******************************************************************************/
912
913void ImageMap::Write( SvStream& rOStm ) const
914{
915 IMapCompat* pCompat;
916 OUString aImageName( GetName() );
917 SvStreamEndian nOldFormat = rOStm.GetEndian();
918 sal_uInt16 nCount = static_cast<sal_uInt16>(GetIMapObjectCount());
919 const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding(); //vomit!
920
921 rOStm.SetEndian( SvStreamEndian::LITTLE );
922
923 // write MagicCode
924 rOStm.WriteOString( IMAPMAGIC );
926 write_uInt16_lenPrefixed_uInt8s_FromOUString(rOStm, aImageName, eEncoding);
928 rOStm.WriteUInt16( nCount );
929 write_uInt16_lenPrefixed_uInt8s_FromOUString(rOStm, aImageName, eEncoding);
930
931 pCompat = new IMapCompat( rOStm, StreamMode::WRITE );
932
933 // here one can insert in newer versions
934
935 delete pCompat;
936
937 ImpWriteImageMap( rOStm );
938
939 rOStm.SetEndian( nOldFormat );
940}
941
942
943/******************************************************************************
944|*
945|* load binary
946|*
947\******************************************************************************/
948
950{
951 char cMagic[6];
952 SvStreamEndian nOldFormat = rIStm.GetEndian();
953
954 rIStm.SetEndian( SvStreamEndian::LITTLE );
955 rIStm.ReadBytes(cMagic, sizeof(cMagic));
956
957 if ( !memcmp( cMagic, IMAPMAGIC, sizeof( cMagic ) ) )
958 {
959 IMapCompat* pCompat;
960 sal_uInt16 nCount;
961
962 // delete old content
964
965 // read on version
966 rIStm.SeekRel( 2 );
967
968 aName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rIStm, osl_getThreadTextEncoding());
970 rIStm.ReadUInt16( nCount );
972
973 pCompat = new IMapCompat( rIStm, StreamMode::READ );
974
975 // here one can read in newer versions
976
977 delete pCompat;
978 ImpReadImageMap( rIStm, nCount );
979
980 }
981 else
983
984 rIStm.SetEndian( nOldFormat );
985}
986
987
988/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1043
sal_Int32 GetDenominator() const
bool IsEqual(const IMapCircleObject &rEqObj) const
Definition: imap.cxx:369
sal_Int32 nRadius
Definition: imapcirc.hxx:31
virtual IMapObjectType GetType() const override
Definition: imap.cxx:308
sal_Int32 GetRadius(bool bPixelCoords=true) const
Definition: imap.cxx:339
virtual bool IsHit(const Point &rPoint) const override
Definition: imap.cxx:320
virtual void ReadIMapObject(SvStream &rIStm) override
Definition: imap.cxx:290
virtual void WriteIMapObject(SvStream &rOStm) const override
Definition: imap.cxx:275
void Scale(const Fraction &rFractX, const Fraction &rFracY)
Definition: imap.cxx:351
void ImpConstruct(const Point &rCenter, sal_Int32 nRad, bool bPixel)
Definition: imap.cxx:252
Point GetCenter(bool bPixelCoords=true) const
Definition: imap.cxx:327
virtual void WriteIMapObject(SvStream &rOStm) const =0
bool IsEqual(const IMapObject &rEqObj) const
Definition: imap.cxx:127
virtual IMapObjectType GetType() const =0
void Read(SvStream &rIStm)
Definition: imap.cxx:97
bool IsActive() const
Definition: imapobj.hxx:117
virtual void ReadIMapObject(SvStream &rIStm)=0
OUString aURL
Definition: imapobj.hxx:59
OUString aAltText
Definition: imapobj.hxx:60
void Write(SvStream &rOStm) const
Definition: imap.cxx:68
SvxMacroTableDtor aEventList
Definition: imapobj.hxx:64
bool bActive
Definition: imapobj.hxx:65
OUString aTarget
Definition: imapobj.hxx:62
sal_uInt16 nReadVersion
Definition: imapobj.hxx:68
OUString aName
Definition: imapobj.hxx:63
IMapObject()
Definition: imap.cxx:49
OUString aDesc
Definition: imapobj.hxx:61
bool IsEqual(const IMapPolygonObject &rEqObj)
Definition: imap.cxx:510
tools::Rectangle aEllipse
Definition: imappoly.hxx:32
VCL_DLLPRIVATE void ImpConstruct(const tools::Polygon &rPoly, bool bPixel)
Definition: imap.cxx:390
void Scale(const Fraction &rFractX, const Fraction &rFracY)
Definition: imap.cxx:479
tools::Polygon GetPolygon(bool bPixelCoords=true) const
Definition: imap.cxx:458
virtual void ReadIMapObject(SvStream &rIStm) override
Definition: imap.cxx:421
void SetExtraEllipse(const tools::Rectangle &rEllipse)
Definition: imap.cxx:470
virtual void WriteIMapObject(SvStream &rOStm) const override
Definition: imap.cxx:405
tools::Polygon aPoly
Definition: imappoly.hxx:31
virtual bool IsHit(const Point &rPoint) const override
Definition: imap.cxx:453
virtual IMapObjectType GetType() const override
Definition: imap.cxx:441
tools::Rectangle GetRectangle(bool bPixelCoords=true) const
Definition: imap.cxx:208
virtual bool IsHit(const Point &rPoint) const override
Definition: imap.cxx:203
tools::Rectangle aRect
Definition: imaprect.hxx:30
VCL_DLLPRIVATE void ImpConstruct(const tools::Rectangle &rRect, bool bPixel)
Definition: imap.cxx:150
virtual void ReadIMapObject(SvStream &rIStm) override
Definition: imap.cxx:178
bool IsEqual(const IMapRectangleObject &rEqObj) const
Definition: imap.cxx:234
virtual void WriteIMapObject(SvStream &rOStm) const override
Definition: imap.cxx:165
virtual IMapObjectType GetType() const override
Definition: imap.cxx:191
void Scale(const Fraction &rFractX, const Fraction &rFracY)
Definition: imap.cxx:220
void Scale(const Fraction &rFractX, const Fraction &rFracY)
Definition: imap.cxx:801
OUString aName
Definition: imap.hxx:40
void Write(SvStream &rOStm) const
Definition: imap.cxx:913
const OUString & GetName() const
Definition: imap.hxx:106
ImageMap()
Definition: imap.hxx:65
void ImpWriteImageMap(SvStream &rOStm) const
Definition: imap.cxx:836
std::vector< std::unique_ptr< IMapObject > > maList
Definition: imap.hxx:39
void InsertIMapObject(const IMapObject &rIMapObject)
Definition: imap.cxx:739
void Read(SvStream &rIStm)
Definition: imap.cxx:949
IMapObject * GetIMapObject(size_t nPos) const
Definition: imap.hxx:84
IMapObject * GetHitIMapObject(const Size &rOriginalSize, const Size &rDisplaySize, const Point &rRelHitPoint, sal_uLong nFlags=0) const
Definition: imap.cxx:771
bool operator==(const ImageMap &rImageMap)
Definition: imap.cxx:665
~ImageMap()
Definition: imap.cxx:597
ImageMap & operator=(const ImageMap &rImageMap)
Definition: imap.cxx:622
size_t GetIMapObjectCount() const
Definition: imap.hxx:101
bool operator!=(const ImageMap &rImageMap)
Definition: imap.cxx:727
void ImpReadImageMap(SvStream &rIStm, size_t nCount)
Definition: imap.cxx:854
void ClearImageMap()
Definition: imap.cxx:608
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1110
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:879
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
SvStream & ReadCharAsBool(bool &rBool)
void SetEndian(SvStreamEndian SvStreamEndian)
SvStream & WriteBool(bool b)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteOString(std::string_view rStr)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
SvStreamEndian GetEndian() const
void SetError(ErrCode nErrorCode)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 SeekRel(sal_Int64 nPos)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
void Read(SvStream &)
SvStream & Write(SvStream &) const
void readPoint(Point &rPoint)
void writePoint(const Point &rPoint)
void readRectangle(Rectangle &rRectangle)
void writeRectangle(const Rectangle &rRectangle)
bool Contains(const Point &rPt) const
sal_uInt16 GetSize() const
bool Contains(const Point &rPOINT) const
constexpr Point TopLeft() const
constexpr Point BottomRight() const
int nCount
URL aURL
float u
#define SVSTREAM_GENERALERROR
FilterGroup & rTarget
#define SCALEPOINT(aPT, aFracX, aFracY)
Definition: imap.cxx:42
IMapObjectType
Definition: imapobj.hxx:30
#define IMAP_MIRROR_VERT
Definition: imapobj.hxx:42
#define IMAP_MIRROR_HORZ
Definition: imapobj.hxx:41
#define IMAPMAGIC
Definition: imapobj.hxx:39
#define IMAGE_MAP_VERSION
Definition: imapobj.hxx:37
#define IMAP_OBJ_VERSION
Definition: imapobj.hxx:36
OUString aName
#define SAL_WARN(area, stream)
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
int i
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
SvStream & ReadPolygon(SvStream &rIStream, tools::Polygon &rPoly)
SvStream & WritePolygon(SvStream &rOStream, const tools::Polygon &rPoly)
QPRO_FUNC_TYPE nType
sal_uIntPtr sal_uLong
OString read_uInt16_lenPrefixed_uInt8s_ToOString(SvStream &rStrm)
OUString read_uInt16_lenPrefixed_uInt8s_ToOUString(SvStream &rStrm, rtl_TextEncoding eEnc)
SvStreamEndian
TOOLS_DLLPUBLIC std::size_t write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream &rStrm, std::string_view rStr)
std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream &rStrm, std::u16string_view rStr, rtl_TextEncoding eEnc)