2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-15 17:28:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2006-09-17 14:11:06 +00:00
|
|
|
|
2000-09-18 15:59:02 +00:00
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/mapmod.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
#include "svl/urihelper.hxx"
|
2007-06-27 20:50:55 +00:00
|
|
|
#include <svtools/imap.hxx>
|
|
|
|
#include <svtools/imapobj.hxx>
|
|
|
|
#include <svtools/imapcirc.hxx>
|
|
|
|
#include <svtools/imaprect.hxx>
|
|
|
|
#include <svtools/imappoly.hxx>
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2008-08-19 23:44:04 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2006-06-19 20:20:28 +00:00
|
|
|
DBG_NAME( ImageMap )
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define SCALEPOINT(aPT,aFracX,aFracY) (aPT).X()=((aPT).X()*(aFracX).GetNumerator())/(aFracX).GetDenominator(); \
|
|
|
|
(aPT).Y()=((aPT).Y()*(aFracY).GetNumerator())/(aFracY).GetDenominator();
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 IMapObject::nActualTextEncoding = (sal_uInt16) RTL_TEXTENCODING_DONTKNOW;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
2009-10-30 17:36:02 +01:00
|
|
|
IMapObject::IMapObject()
|
|
|
|
: bActive( false )
|
|
|
|
, nReadVersion( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-15 09:10:28 +02:00
|
|
|
IMapObject::IMapObject( const OUString& rURL, const OUString& rAltText, const OUString& rDesc,
|
|
|
|
const OUString& rTarget, const OUString& rName, sal_Bool bURLActive )
|
2007-06-26 12:33:34 +00:00
|
|
|
: aURL( rURL )
|
|
|
|
, aAltText( rAltText )
|
|
|
|
, aDesc( rDesc )
|
|
|
|
, aTarget( rTarget )
|
|
|
|
, aName( rName )
|
|
|
|
, bActive( bURLActive )
|
2009-10-30 17:36:02 +01:00
|
|
|
, nReadVersion( 0 )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* release internal memory
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 IMapObject::GetVersion() const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return IMAP_OBJ_VERSION;
|
|
|
|
}
|
|
|
|
|
2013-08-15 09:10:28 +02:00
|
|
|
void IMapObject::Write( SvStream& rOStm, const OUString& rBaseURL ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
IMapCompat* pCompat;
|
2011-08-21 23:49:54 +01:00
|
|
|
const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2005-01-11 12:11:43 +00:00
|
|
|
rOStm << GetType();
|
|
|
|
rOStm << GetVersion();
|
2010-11-05 10:31:15 +08:00
|
|
|
rOStm << ( (sal_uInt16) eEncoding );
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
const OString aRelURL = OUStringToOString(
|
2011-11-07 22:24:39 +00:00
|
|
|
URIHelper::simpleNormalizedMakeRelative(rBaseURL, aURL), eEncoding);
|
2011-12-21 13:33:58 +00:00
|
|
|
write_lenPrefixed_uInt8s_FromOString<sal_uInt16>(rOStm, aRelURL);
|
|
|
|
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, aAltText, eEncoding);
|
2005-01-11 12:11:43 +00:00
|
|
|
rOStm << bActive;
|
2011-12-21 13:33:58 +00:00
|
|
|
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, aTarget, eEncoding);
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
pCompat = new IMapCompat( rOStm, STREAM_WRITE );
|
|
|
|
|
2005-01-11 12:11:43 +00:00
|
|
|
WriteIMapObject( rOStm );
|
2011-12-21 10:44:56 +00:00
|
|
|
aEventList.Write( rOStm ); // V4
|
2011-12-21 13:33:58 +00:00
|
|
|
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, aName, eEncoding); // V5
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
delete pCompat;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* Binary import
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2013-08-15 09:10:28 +02:00
|
|
|
void IMapObject::Read( SvStream& rIStm, const OUString& rBaseURL )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
IMapCompat* pCompat;
|
|
|
|
rtl_TextEncoding nTextEncoding;
|
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// read on type and version
|
2000-09-18 15:59:02 +00:00
|
|
|
rIStm.SeekRel( 2 );
|
2005-01-11 12:11:43 +00:00
|
|
|
rIStm >> nReadVersion;
|
2000-09-18 15:59:02 +00:00
|
|
|
rIStm >> nTextEncoding;
|
2011-12-21 13:33:58 +00:00
|
|
|
aURL = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, nTextEncoding);
|
|
|
|
aAltText = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, nTextEncoding);
|
2005-01-11 12:11:43 +00:00
|
|
|
rIStm >> bActive;
|
2011-12-21 13:33:58 +00:00
|
|
|
aTarget = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, nTextEncoding);
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// make URL absolute
|
2005-01-11 12:11:43 +00:00
|
|
|
aURL = URIHelper::SmartRel2Abs( INetURLObject(rBaseURL), aURL, URIHelper::GetMaybeFileHdl(), true, false, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS );
|
2000-09-18 15:59:02 +00:00
|
|
|
pCompat = new IMapCompat( rIStm, STREAM_READ );
|
|
|
|
|
2005-01-11 12:11:43 +00:00
|
|
|
ReadIMapObject( rIStm );
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// from version 4 onwards we read a eventlist
|
2005-01-11 12:11:43 +00:00
|
|
|
if ( nReadVersion >= 0x0004 )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
2005-01-11 12:11:43 +00:00
|
|
|
aEventList.Read(rIStm);
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// from version 5 onwards an objectname could be available
|
2005-01-11 12:11:43 +00:00
|
|
|
if ( nReadVersion >= 0x0005 )
|
2011-12-21 13:33:58 +00:00
|
|
|
aName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, nTextEncoding);
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete pCompat;
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool IMapObject::IsEqual( const IMapObject& rEqObj )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return ( ( aURL == rEqObj.aURL ) &&
|
2007-06-26 12:33:34 +00:00
|
|
|
( aAltText == rEqObj.aAltText ) &&
|
|
|
|
( aDesc == rEqObj.aDesc ) &&
|
2000-09-18 15:59:02 +00:00
|
|
|
( aTarget == rEqObj.aTarget ) &&
|
|
|
|
( aName == rEqObj.aName ) &&
|
|
|
|
( bActive == rEqObj.bActive ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
IMapRectangleObject::IMapRectangleObject( const Rectangle& rRect,
|
2013-08-15 09:10:28 +02:00
|
|
|
const OUString& rURL,
|
|
|
|
const OUString& rAltText,
|
|
|
|
const OUString& rDesc,
|
|
|
|
const OUString& rTarget,
|
|
|
|
const OUString& rName,
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bURLActive,
|
|
|
|
sal_Bool bPixelCoords ) :
|
2007-06-26 12:33:34 +00:00
|
|
|
IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
ImpConstruct( rRect, bPixelCoords );
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
void IMapRectangleObject::ImpConstruct( const Rectangle& rRect, sal_Bool bPixel )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
if ( bPixel )
|
|
|
|
aRect = Application::GetDefaultDevice()->PixelToLogic( rRect, MapMode( MAP_100TH_MM ) );
|
|
|
|
else
|
|
|
|
aRect = rRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* Binary export
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
void IMapRectangleObject::WriteIMapObject( SvStream& rOStm ) const
|
|
|
|
{
|
|
|
|
rOStm << aRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* Binary import
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
void IMapRectangleObject::ReadIMapObject( SvStream& rIStm )
|
|
|
|
{
|
|
|
|
rIStm >> aRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* return type
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 IMapRectangleObject::GetType() const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return IMAP_OBJ_RECTANGLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* Hit test
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool IMapRectangleObject::IsHit( const Point& rPoint ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return aRect.IsInside( rPoint );
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
Rectangle IMapRectangleObject::GetRectangle( sal_Bool bPixelCoords ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
Rectangle aNewRect;
|
|
|
|
|
|
|
|
if ( bPixelCoords )
|
|
|
|
aNewRect = Application::GetDefaultDevice()->LogicToPixel( aRect, MapMode( MAP_100TH_MM ) );
|
|
|
|
else
|
|
|
|
aNewRect = aRect;
|
|
|
|
|
|
|
|
return aNewRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IMapRectangleObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
|
|
|
|
{
|
|
|
|
Point aTL( aRect.TopLeft() );
|
|
|
|
Point aBR( aRect.BottomRight() );
|
|
|
|
|
|
|
|
if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
|
|
|
|
{
|
|
|
|
SCALEPOINT( aTL, rFracX, rFracY );
|
|
|
|
SCALEPOINT( aBR, rFracX, rFracY );
|
|
|
|
}
|
|
|
|
|
|
|
|
aRect = Rectangle( aTL, aBR );
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool IMapRectangleObject::IsEqual( const IMapRectangleObject& rEqObj )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return ( IMapObject::IsEqual( rEqObj ) && ( aRect == rEqObj.aRect ) );
|
|
|
|
}
|
|
|
|
|
2011-01-12 15:56:50 +01:00
|
|
|
IMapCircleObject::IMapCircleObject( const Point& rCenter, sal_uLong nCircleRadius,
|
2013-08-15 09:10:28 +02:00
|
|
|
const OUString& rURL,
|
|
|
|
const OUString& rAltText,
|
|
|
|
const OUString& rDesc,
|
|
|
|
const OUString& rTarget,
|
|
|
|
const OUString& rName,
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bURLActive,
|
|
|
|
sal_Bool bPixelCoords ) :
|
2007-06-26 12:33:34 +00:00
|
|
|
IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
ImpConstruct( rCenter, nCircleRadius, bPixelCoords );
|
|
|
|
}
|
|
|
|
|
2011-01-12 15:56:50 +01:00
|
|
|
void IMapCircleObject::ImpConstruct( const Point& rCenter, sal_uLong nRad, sal_Bool bPixel )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
if ( bPixel )
|
|
|
|
{
|
|
|
|
MapMode aMap100( MAP_100TH_MM );
|
|
|
|
|
|
|
|
aCenter = Application::GetDefaultDevice()->PixelToLogic( rCenter, aMap100 );
|
|
|
|
nRadius = Application::GetDefaultDevice()->PixelToLogic( Size( nRad, 0 ), aMap100 ).Width();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aCenter = rCenter;
|
|
|
|
nRadius = nRad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* Binary export
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
void IMapCircleObject::WriteIMapObject( SvStream& rOStm ) const
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt32 nTmp = nRadius;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
rOStm << aCenter;
|
|
|
|
rOStm << nTmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* Binary import
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
void IMapCircleObject::ReadIMapObject( SvStream& rIStm )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt32 nTmp;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
rIStm >> aCenter;
|
|
|
|
rIStm >> nTmp;
|
|
|
|
|
|
|
|
nRadius = nTmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* return type
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 IMapCircleObject::GetType() const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return IMAP_OBJ_CIRCLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
|
|
|
|* Hit-Test
|
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool IMapCircleObject::IsHit( const Point& rPoint ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
const Point aPoint( aCenter - rPoint );
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bRet = sal_False;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2011-06-20 21:39:11 +01:00
|
|
|
if ( (sal_Int32) sqrt( (double) aPoint.X() * aPoint.X() +
|
2000-09-18 15:59:02 +00:00
|
|
|
aPoint.Y() * aPoint.Y() ) <= nRadius )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
bRet = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
Point IMapCircleObject::GetCenter( sal_Bool bPixelCoords ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
Point aNewPoint;
|
|
|
|
|
|
|
|
if ( bPixelCoords )
|
|
|
|
aNewPoint = Application::GetDefaultDevice()->LogicToPixel( aCenter, MapMode( MAP_100TH_MM ) );
|
|
|
|
else
|
|
|
|
aNewPoint = aCenter;
|
|
|
|
|
|
|
|
return aNewPoint;
|
|
|
|
}
|
|
|
|
|
2011-01-12 15:56:50 +01:00
|
|
|
sal_uLong IMapCircleObject::GetRadius( sal_Bool bPixelCoords ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
2011-01-12 15:56:50 +01:00
|
|
|
sal_uLong nNewRadius;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
if ( bPixelCoords )
|
|
|
|
nNewRadius = Application::GetDefaultDevice()->LogicToPixel( Size( nRadius, 0 ), MapMode( MAP_100TH_MM ) ).Width();
|
|
|
|
else
|
|
|
|
nNewRadius = nRadius;
|
|
|
|
|
|
|
|
return nNewRadius;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle IMapCircleObject::GetBoundRect() const
|
|
|
|
{
|
|
|
|
long nWidth = nRadius << 1;
|
|
|
|
|
|
|
|
return Rectangle( Point( aCenter.X() - nRadius, aCenter.Y() - nRadius ),
|
|
|
|
Size( nWidth, nWidth ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void IMapCircleObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
|
|
|
|
{
|
|
|
|
Fraction aAverage( rFracX );
|
|
|
|
|
|
|
|
aAverage += rFracY;
|
|
|
|
aAverage *= Fraction( 1, 2 );
|
|
|
|
|
|
|
|
if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
|
|
|
|
{
|
|
|
|
SCALEPOINT( aCenter, rFracX, rFracY );
|
|
|
|
}
|
|
|
|
|
|
|
|
nRadius = ( nRadius * aAverage.GetNumerator() ) / aAverage.GetDenominator();
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool IMapCircleObject::IsEqual( const IMapCircleObject& rEqObj )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return ( IMapObject::IsEqual( rEqObj ) &&
|
|
|
|
( aCenter == rEqObj.aCenter ) &&
|
|
|
|
( nRadius == rEqObj.nRadius ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
IMapPolygonObject::IMapPolygonObject( const Polygon& rPoly,
|
2013-08-15 09:10:28 +02:00
|
|
|
const OUString& rURL,
|
|
|
|
const OUString& rAltText,
|
|
|
|
const OUString& rDesc,
|
|
|
|
const OUString& rTarget,
|
|
|
|
const OUString& rName,
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bURLActive,
|
|
|
|
sal_Bool bPixelCoords ) :
|
2007-06-26 12:33:34 +00:00
|
|
|
IMapObject ( rURL, rAltText, rDesc, rTarget, rName, bURLActive ),
|
2010-11-05 10:31:15 +08:00
|
|
|
bEllipse ( sal_False )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
ImpConstruct( rPoly, bPixelCoords );
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
void IMapPolygonObject::ImpConstruct( const Polygon& rPoly, sal_Bool bPixel )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
if ( bPixel )
|
|
|
|
aPoly = Application::GetDefaultDevice()->PixelToLogic( rPoly, MapMode( MAP_100TH_MM ) );
|
|
|
|
else
|
|
|
|
aPoly = rPoly;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* Binary export
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
void IMapPolygonObject::WriteIMapObject( SvStream& rOStm ) const
|
|
|
|
{
|
|
|
|
rOStm << aPoly;
|
|
|
|
rOStm << bEllipse; // >= Version 2
|
|
|
|
rOStm << aEllipse; // >= Version 2
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* Binary import
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
void IMapPolygonObject::ReadIMapObject( SvStream& rIStm )
|
|
|
|
{
|
|
|
|
rIStm >> aPoly;
|
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// Version >= 2 has additional ellipses information
|
2000-09-18 15:59:02 +00:00
|
|
|
if ( nReadVersion >= 2 )
|
|
|
|
{
|
|
|
|
rIStm >> bEllipse;
|
|
|
|
rIStm >> aEllipse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* return type
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 IMapPolygonObject::GetType() const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return IMAP_OBJ_POLYGON;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* hit test
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool IMapPolygonObject::IsHit( const Point& rPoint ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return aPoly.IsInside( rPoint );
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
Polygon IMapPolygonObject::GetPolygon( sal_Bool bPixelCoords ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
Polygon aNewPoly;
|
|
|
|
|
|
|
|
if ( bPixelCoords )
|
|
|
|
aNewPoly = Application::GetDefaultDevice()->LogicToPixel( aPoly, MapMode( MAP_100TH_MM ) );
|
|
|
|
else
|
|
|
|
aNewPoly = aPoly;
|
|
|
|
|
|
|
|
return aNewPoly;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IMapPolygonObject::SetExtraEllipse( const Rectangle& rEllipse )
|
|
|
|
{
|
|
|
|
if ( aPoly.GetSize() )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
bEllipse = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
aEllipse = rEllipse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IMapPolygonObject::Scale( const Fraction& rFracX, const Fraction& rFracY )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 nCount = aPoly.GetSize();
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
for ( sal_uInt16 i = 0; i < nCount; i++ )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
Point aScaledPt( aPoly[ i ] );
|
|
|
|
|
|
|
|
if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
|
|
|
|
{
|
|
|
|
SCALEPOINT( aScaledPt, rFracX, rFracY );
|
|
|
|
}
|
|
|
|
|
|
|
|
aPoly[ i ] = aScaledPt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bEllipse )
|
|
|
|
{
|
|
|
|
Point aTL( aEllipse.TopLeft() );
|
|
|
|
Point aBR( aEllipse.BottomRight() );
|
|
|
|
|
|
|
|
if ( rFracX.GetDenominator() && rFracY.GetDenominator() )
|
|
|
|
{
|
|
|
|
SCALEPOINT( aTL, rFracX, rFracY );
|
|
|
|
SCALEPOINT( aBR, rFracX, rFracY );
|
|
|
|
}
|
|
|
|
|
|
|
|
aEllipse = Rectangle( aTL, aBR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool IMapPolygonObject::IsEqual( const IMapPolygonObject& rEqObj )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bRet = sal_False;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
if ( IMapObject::IsEqual( rEqObj ) )
|
|
|
|
{
|
|
|
|
const Polygon& rEqPoly = rEqObj.aPoly;
|
2010-11-05 10:31:15 +08:00
|
|
|
const sal_uInt16 nCount = aPoly.GetSize();
|
|
|
|
const sal_uInt16 nEqCount = rEqPoly.GetSize();
|
|
|
|
sal_Bool bDifferent = sal_False;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
if ( nCount == nEqCount )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
for ( sal_uInt16 i = 0; i < nCount; i++ )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
if ( aPoly[ i ] != rEqPoly[ i ] )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
bDifferent = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bDifferent )
|
2010-11-05 10:31:15 +08:00
|
|
|
bRet = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
|
|
|
|* Ctor
|
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2013-08-15 09:10:28 +02:00
|
|
|
ImageMap::ImageMap( const OUString& rName )
|
2011-07-12 20:06:36 -07:00
|
|
|
: aName( rName )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
|
|
|
|* Copy-Ctor
|
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
ImageMap::ImageMap( const ImageMap& rImageMap )
|
|
|
|
{
|
|
|
|
DBG_CTOR( ImageMap, NULL );
|
|
|
|
|
2011-07-12 20:06:36 -07:00
|
|
|
size_t nCount = rImageMap.GetIMapObjectCount();
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2011-07-12 20:06:36 -07:00
|
|
|
for ( size_t i = 0; i < nCount; i++ )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
|
|
|
|
|
|
|
|
switch( pCopyObj->GetType() )
|
|
|
|
{
|
|
|
|
case( IMAP_OBJ_RECTANGLE ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapRectangleObject( *(IMapRectangleObject*) pCopyObj ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_CIRCLE ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapCircleObject( *(IMapCircleObject*) pCopyObj ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_POLYGON ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapPolygonObject( *(IMapPolygonObject*) pCopyObj ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aName = rImageMap.aName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
|
|
|
|* Dtor
|
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
ImageMap::~ImageMap()
|
|
|
|
{
|
|
|
|
DBG_DTOR( ImageMap, NULL );
|
|
|
|
|
|
|
|
ClearImageMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* release internal memory
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
void ImageMap::ClearImageMap()
|
|
|
|
{
|
2011-07-12 20:06:36 -07:00
|
|
|
for( size_t i = 0, n = maList.size(); i < n; ++i )
|
|
|
|
delete maList[ i ];
|
|
|
|
maList.clear();
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2013-08-20 16:09:10 +02:00
|
|
|
aName = "";
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* assignment operator
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
ImageMap& ImageMap::operator=( const ImageMap& rImageMap )
|
|
|
|
{
|
2011-07-12 20:06:36 -07:00
|
|
|
size_t nCount = rImageMap.GetIMapObjectCount();
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
ClearImageMap();
|
|
|
|
|
2011-07-12 20:06:36 -07:00
|
|
|
for ( size_t i = 0; i < nCount; i++ )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
|
|
|
|
|
|
|
|
switch( pCopyObj->GetType() )
|
|
|
|
{
|
|
|
|
case( IMAP_OBJ_RECTANGLE ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapRectangleObject( *(IMapRectangleObject*) pCopyObj ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_CIRCLE ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapCircleObject( *(IMapCircleObject*) pCopyObj ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_POLYGON ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapPolygonObject( *(IMapPolygonObject*) pCopyObj ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aName = rImageMap.aName;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* compare operator I
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool ImageMap::operator==( const ImageMap& rImageMap )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
2011-07-12 20:06:36 -07:00
|
|
|
const size_t nCount = maList.size();
|
|
|
|
const size_t nEqCount = rImageMap.GetIMapObjectCount();
|
|
|
|
sal_Bool bRet = sal_False;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
if ( nCount == nEqCount )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bDifferent = ( aName != rImageMap.aName );
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2011-07-12 20:06:36 -07:00
|
|
|
for ( size_t i = 0; ( i < nCount ) && !bDifferent; i++ )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
2011-07-12 20:06:36 -07:00
|
|
|
IMapObject* pObj = maList[ i ];
|
2000-09-18 15:59:02 +00:00
|
|
|
IMapObject* pEqObj = rImageMap.GetIMapObject( i );
|
|
|
|
|
|
|
|
if ( pObj->GetType() == pEqObj->GetType() )
|
|
|
|
{
|
|
|
|
switch( pObj->GetType() )
|
|
|
|
{
|
|
|
|
case( IMAP_OBJ_RECTANGLE ):
|
|
|
|
{
|
|
|
|
if ( !( (IMapRectangleObject*) pObj )->IsEqual( *(IMapRectangleObject*) pEqObj ) )
|
2010-11-05 10:31:15 +08:00
|
|
|
bDifferent = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_CIRCLE ):
|
|
|
|
{
|
|
|
|
if ( !( (IMapCircleObject*) pObj )->IsEqual( *(IMapCircleObject*) pEqObj ) )
|
2010-11-05 10:31:15 +08:00
|
|
|
bDifferent = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_POLYGON ):
|
|
|
|
{
|
|
|
|
if ( !( (IMapPolygonObject*) pObj )->IsEqual( *(IMapPolygonObject*) pEqObj ) )
|
2010-11-05 10:31:15 +08:00
|
|
|
bDifferent = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-11-05 10:31:15 +08:00
|
|
|
bDifferent = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bDifferent )
|
2010-11-05 10:31:15 +08:00
|
|
|
bRet = sal_True;
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* compare operator II
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool ImageMap::operator!=( const ImageMap& rImageMap )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return !( *this == rImageMap );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* release internal memory
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 ImageMap::GetVersion() const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
return IMAGE_MAP_VERSION;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* insert new object
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
void ImageMap::InsertIMapObject( const IMapObject& rIMapObject )
|
|
|
|
{
|
|
|
|
switch( rIMapObject.GetType() )
|
|
|
|
{
|
|
|
|
case( IMAP_OBJ_RECTANGLE ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapRectangleObject( (IMapRectangleObject&) rIMapObject ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_CIRCLE ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapCircleObject( (IMapCircleObject&) rIMapObject ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_POLYGON ):
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( new IMapPolygonObject( (IMapPolygonObject&) rIMapObject ) );
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* hit test
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
IMapObject* ImageMap::GetHitIMapObject( const Size& rTotalSize,
|
|
|
|
const Size& rDisplaySize,
|
|
|
|
const Point& rRelHitPoint,
|
2011-01-12 15:56:50 +01:00
|
|
|
sal_uLong nFlags )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
Point aRelPoint( rTotalSize.Width() * rRelHitPoint.X() / rDisplaySize.Width(),
|
|
|
|
rTotalSize.Height() * rRelHitPoint.Y() / rDisplaySize.Height() );
|
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// transform point to check before checking if flags to mirror etc. are set,
|
2000-09-18 15:59:02 +00:00
|
|
|
if ( nFlags )
|
|
|
|
{
|
|
|
|
if ( nFlags & IMAP_MIRROR_HORZ )
|
|
|
|
aRelPoint.X() = rTotalSize.Width() - aRelPoint.X();
|
|
|
|
|
|
|
|
if ( nFlags & IMAP_MIRROR_VERT )
|
|
|
|
aRelPoint.Y() = rTotalSize.Height() - aRelPoint.Y();
|
|
|
|
}
|
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// walk over all objects and execute HitTest
|
2011-07-12 20:06:36 -07:00
|
|
|
IMapObject* pObj = NULL;
|
|
|
|
for( size_t i = 0, n = maList.size(); i < n; ++i ) {
|
|
|
|
if ( maList[ i ]->IsHit( aRelPoint ) ) {
|
|
|
|
pObj = maList[ i ];
|
2000-09-18 15:59:02 +00:00
|
|
|
break;
|
2011-07-12 20:06:36 -07:00
|
|
|
}
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return( pObj ? ( pObj->IsActive() ? pObj : NULL ) : NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImageMap::Scale( const Fraction& rFracX, const Fraction& rFracY )
|
|
|
|
{
|
2011-07-12 20:06:36 -07:00
|
|
|
size_t nCount = maList.size();
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2011-07-12 20:06:36 -07:00
|
|
|
for ( size_t i = 0; i < nCount; i++ )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
2011-07-12 20:06:36 -07:00
|
|
|
IMapObject* pObj = maList[ i ];
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
switch( pObj->GetType() )
|
|
|
|
{
|
|
|
|
case( IMAP_OBJ_RECTANGLE ):
|
|
|
|
( (IMapRectangleObject*) pObj )->Scale( rFracX, rFracY );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_CIRCLE ):
|
|
|
|
( (IMapCircleObject*) pObj )->Scale( rFracX, rFracY );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case( IMAP_OBJ_POLYGON ):
|
|
|
|
( (IMapPolygonObject*) pObj )->Scale( rFracX, rFracY );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* sequentially write objects
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2013-08-15 09:10:28 +02:00
|
|
|
void ImageMap::ImpWriteImageMap( SvStream& rOStm, const OUString& rBaseURL ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
IMapObject* pObj;
|
2011-07-12 20:06:36 -07:00
|
|
|
size_t nCount = maList.size();
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2011-07-12 20:06:36 -07:00
|
|
|
for ( size_t i = 0; i < nCount; i++ )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
2011-07-12 20:06:36 -07:00
|
|
|
pObj = maList[ i ];
|
2005-01-11 12:11:43 +00:00
|
|
|
pObj->Write( rOStm, rBaseURL );
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* sequentially read objects
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2013-08-15 09:10:28 +02:00
|
|
|
void ImageMap::ImpReadImageMap( SvStream& rIStm, size_t nCount, const OUString& rBaseURL )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
// neue Objekte einlesen
|
2011-07-12 20:06:36 -07:00
|
|
|
for ( size_t i = 0; i < nCount; i++ )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 nType;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
rIStm >> nType;
|
|
|
|
rIStm.SeekRel( -2 );
|
|
|
|
|
|
|
|
switch( nType )
|
|
|
|
{
|
|
|
|
case ( IMAP_OBJ_RECTANGLE ):
|
|
|
|
{
|
|
|
|
IMapRectangleObject* pObj = new IMapRectangleObject;
|
2005-01-11 12:11:43 +00:00
|
|
|
pObj->Read( rIStm, rBaseURL );
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( pObj );
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ( IMAP_OBJ_CIRCLE ):
|
|
|
|
{
|
|
|
|
IMapCircleObject* pObj = new IMapCircleObject;
|
2005-01-11 12:11:43 +00:00
|
|
|
pObj->Read( rIStm, rBaseURL );
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( pObj );
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ( IMAP_OBJ_POLYGON ):
|
|
|
|
{
|
|
|
|
IMapPolygonObject* pObj = new IMapPolygonObject;
|
2005-01-11 12:11:43 +00:00
|
|
|
pObj->Read( rIStm, rBaseURL );
|
2011-07-12 20:06:36 -07:00
|
|
|
maList.push_back( pObj );
|
2000-09-18 15:59:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* store binary
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2013-08-15 09:10:28 +02:00
|
|
|
void ImageMap::Write( SvStream& rOStm, const OUString& rBaseURL ) const
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
IMapCompat* pCompat;
|
2013-08-20 16:09:10 +02:00
|
|
|
OUString aImageName( GetName() );
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 nOldFormat = rOStm.GetNumberFormatInt();
|
|
|
|
sal_uInt16 nCount = (sal_uInt16) GetIMapObjectCount();
|
2011-12-21 10:44:56 +00:00
|
|
|
const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding(); //vomit!
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
|
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// write MagicCode
|
2000-09-18 15:59:02 +00:00
|
|
|
rOStm << IMAPMAGIC;
|
2005-01-11 12:11:43 +00:00
|
|
|
rOStm << GetVersion();
|
2011-12-21 13:33:58 +00:00
|
|
|
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, aImageName, eEncoding);
|
2013-04-07 12:06:47 +02:00
|
|
|
write_lenPrefixed_uInt8s_FromOString<sal_uInt16>(rOStm, OString()); //dummy
|
2000-09-18 15:59:02 +00:00
|
|
|
rOStm << nCount;
|
2011-12-21 13:33:58 +00:00
|
|
|
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, aImageName, eEncoding);
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
pCompat = new IMapCompat( rOStm, STREAM_WRITE );
|
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// here one can insert in newer versions
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
delete pCompat;
|
|
|
|
|
2005-01-11 12:11:43 +00:00
|
|
|
ImpWriteImageMap( rOStm, rBaseURL );
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
rOStm.SetNumberFormatInt( nOldFormat );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|*
|
2014-01-07 21:47:08 +01:00
|
|
|
|* load binary
|
2000-09-18 15:59:02 +00:00
|
|
|
|*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2013-08-15 09:10:28 +02:00
|
|
|
void ImageMap::Read( SvStream& rIStm, const OUString& rBaseURL )
|
2000-09-18 15:59:02 +00:00
|
|
|
{
|
|
|
|
char cMagic[6];
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 nOldFormat = rIStm.GetNumberFormatInt();
|
|
|
|
sal_uInt16 nCount;
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
|
|
|
|
rIStm.Read( cMagic, sizeof( cMagic ) );
|
|
|
|
|
|
|
|
if ( !memcmp( cMagic, IMAPMAGIC, sizeof( cMagic ) ) )
|
|
|
|
{
|
|
|
|
IMapCompat* pCompat;
|
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// delete old content
|
2005-01-11 12:11:43 +00:00
|
|
|
ClearImageMap();
|
2000-09-18 15:59:02 +00:00
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// read on version
|
2000-09-18 15:59:02 +00:00
|
|
|
rIStm.SeekRel( 2 );
|
|
|
|
|
2011-12-21 13:33:58 +00:00
|
|
|
aName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, osl_getThreadTextEncoding());
|
|
|
|
read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIStm); // Dummy
|
2000-09-18 15:59:02 +00:00
|
|
|
rIStm >> nCount;
|
2011-12-21 13:33:58 +00:00
|
|
|
read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIStm); // Dummy
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
pCompat = new IMapCompat( rIStm, STREAM_READ );
|
|
|
|
|
2014-01-07 21:47:08 +01:00
|
|
|
// here one can read in newer versions
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
delete pCompat;
|
2005-01-11 12:11:43 +00:00
|
|
|
ImpReadImageMap( rIStm, nCount, rBaseURL );
|
2000-09-18 15:59:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rIStm.SetError( SVSTREAM_GENERALERROR );
|
|
|
|
|
|
|
|
rIStm.SetNumberFormatInt( nOldFormat );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-16 23:44:29 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|