2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 10:10:34 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 10:10:34 +00:00
|
|
|
* $RCSfile: swcli.cxx,v $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2007-09-27 11:36:02 +00:00
|
|
|
* $Revision: 1.13 $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2007-09-27 11:36:02 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2007-09-27 12:36:02 $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 10:10:34 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 10:10:34 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 10:10:34 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 10:10:34 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 10:10:34 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 22:23:17 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2005-03-15 10:26:34 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_NOVISUALAREASIZEEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-03-01 11:34:58 +00:00
|
|
|
#ifndef _WRTSH_HXX
|
|
|
|
#include <wrtsh.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SWTYPES_HXX
|
|
|
|
#include <swtypes.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _VIEW_HXX
|
|
|
|
#include <view.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _EDTWIN_HXX
|
|
|
|
#include <edtwin.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SWCLI_HXX
|
|
|
|
#include <swcli.hxx>
|
|
|
|
#endif
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
using namespace com::sun::star;
|
|
|
|
|
|
|
|
SwOleClient::SwOleClient( SwView *pView, SwEditWin *pWin, const svt::EmbeddedObjectRef& xObj ) :
|
|
|
|
SfxInPlaceClient( pView, pWin, xObj.GetViewAspect() ), bInDoVerb( FALSE ),
|
2001-03-01 11:34:58 +00:00
|
|
|
bOldCheckForOLEInCaption( pView->GetWrtShell().IsCheckForOLEInCaption() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-10-04 18:32:09 +00:00
|
|
|
SetObject( xObj.GetObject() );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
void SwOleClient::RequestNewObjectArea( Rectangle& aLogRect )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
//Der Server moechte die Clientgrosse verandern.
|
|
|
|
//Wir stecken die Wunschgroesse in die Core. Die Attribute des Rahmens
|
|
|
|
//werden auf den Wunschwert eingestellt. Dieser Wert wird also auch an
|
|
|
|
//den InPlaceClient weitergegeben.
|
|
|
|
//Die Core aktzeptiert bzw. formatiert die eingestellten Werte nicht
|
|
|
|
//zwangslaeufig. Wenn der Ole-Frm formatiert wurde wird das CalcAndSetScale()
|
|
|
|
//der WrtShell gerufen. Dort wird ggf. die Scalierung des SwOleClient
|
|
|
|
//eingestellt.
|
|
|
|
|
|
|
|
SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
|
|
|
|
|
2007-04-19 08:14:59 +00:00
|
|
|
rSh.StartAllAction();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2007-04-19 08:14:59 +00:00
|
|
|
// the aLogRect will get the preliminary size now
|
|
|
|
aLogRect.SetSize( rSh.RequestObjectResize( SwRect( aLogRect ), GetObject() ) );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2007-04-19 08:14:59 +00:00
|
|
|
// the EndAllAction() call will trigger CalcAndSetScale() call,
|
|
|
|
// so the embedded object must get the correct size before
|
2004-10-04 18:32:09 +00:00
|
|
|
if ( aLogRect.GetSize() != GetScaledObjArea().GetSize() )
|
|
|
|
{
|
|
|
|
// size has changed, so first change visual area of the object before we resize its view
|
|
|
|
// without this the object always would be scaled - now it has the choice
|
2004-11-26 15:29:33 +00:00
|
|
|
|
2005-01-31 08:11:16 +00:00
|
|
|
// TODO/LEAN: getMapUnit can switch object to running state
|
2004-10-04 18:32:09 +00:00
|
|
|
MapMode aObjectMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( GetObject()->getMapUnit( GetAspect() ) ) );
|
|
|
|
MapMode aClientMap( GetEditWin()->GetMapMode().GetMapUnit() );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
Size aNewObjSize( Fraction( aLogRect.GetWidth() ) / GetScaleWidth(),
|
|
|
|
Fraction( aLogRect.GetHeight() ) / GetScaleHeight() );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
// convert to logical coordinates of the embedded object
|
|
|
|
Size aNewSize = GetEditWin()->LogicToLogic( aNewObjSize, &aClientMap, &aObjectMap );
|
|
|
|
GetObject()->setVisualAreaSize( GetAspect(), awt::Size( aNewSize.Width(), aNewSize.Height() ) );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
rSh.EndAllAction();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
SwRect aFrm( rSh.GetAnyCurRect( RECT_FLY_EMBEDDED, 0, GetObject() )),
|
|
|
|
aPrt( rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, GetObject() ));
|
|
|
|
aLogRect.SetPos( aPrt.Pos() + aFrm.Pos() );
|
|
|
|
aLogRect.SetSize( aPrt.SSize() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwOleClient::ObjectAreaChanged()
|
|
|
|
{
|
|
|
|
SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
|
|
|
|
SwRect aFrm( rSh.GetAnyCurRect( RECT_FLY_EMBEDDED, 0, GetObject() )),
|
|
|
|
aPrt( rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, GetObject() ));
|
2000-09-18 16:15:01 +00:00
|
|
|
if ( !aFrm.IsOver( rSh.VisArea() ) )
|
|
|
|
rSh.MakeVisible( aFrm );
|
|
|
|
}
|
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
void SwOleClient::ViewChanged()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-10-04 18:32:09 +00:00
|
|
|
if ( bInDoVerb )
|
2000-09-18 16:15:01 +00:00
|
|
|
return;
|
|
|
|
|
2006-10-13 10:13:04 +00:00
|
|
|
if ( GetAspect() == embed::Aspects::MSOLE_ICON )
|
|
|
|
{
|
|
|
|
// the iconified object seems not to need such a scaling handling
|
|
|
|
// since the replacement image and the size a completely controlled by the container
|
|
|
|
// TODO/LATER: when the icon exchange is implemented the scaling handling might be required again here
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
|
|
|
|
|
|
|
|
//Einstellen der Groesse des Objektes in der Core. Die Scalierung muss
|
|
|
|
//beruecksichtigt werden. Rueckwirkung auf das Objekt werden von
|
|
|
|
//CalcAndSetScale() der WrtShell beruecksichtig, wenn die Groesse/Pos des
|
|
|
|
//Rahmens in der Core sich veraendert.
|
2004-11-26 15:29:33 +00:00
|
|
|
|
2005-01-31 08:11:16 +00:00
|
|
|
// TODO/LEAN: getMapUnit can switch object to running state
|
2005-03-15 10:26:34 +00:00
|
|
|
awt::Size aSz;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aSz = GetObject()->getVisualAreaSize( GetAspect() );
|
|
|
|
}
|
|
|
|
catch( embed::NoVisualAreaSizeException& )
|
|
|
|
{
|
|
|
|
// Nothing will be done
|
|
|
|
}
|
2006-10-13 10:13:04 +00:00
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
// this is an error
|
|
|
|
OSL_ENSURE( sal_False, "Something goes wrong on requesting object size!\n" );
|
|
|
|
}
|
2005-03-15 10:26:34 +00:00
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
Size aVisSize( aSz.Width, aSz.Height );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
// Bug 24833: solange keine vernuenftige Size vom Object kommt,
|
|
|
|
// kann nichts skaliert werden
|
|
|
|
if( !aVisSize.Width() || !aVisSize.Height() )
|
|
|
|
return;
|
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
// first convert to TWIPS before scaling, because scaling factors are calculated for
|
|
|
|
// the TWIPS mapping and so they will produce the best results if applied to TWIPS based
|
|
|
|
// coordinates
|
2000-09-18 16:15:01 +00:00
|
|
|
const MapMode aMyMap ( MAP_TWIP );
|
2004-10-04 18:32:09 +00:00
|
|
|
const MapMode aObjMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( GetObject()->getMapUnit( GetAspect() ) ) );
|
2000-09-18 16:15:01 +00:00
|
|
|
aVisSize = OutputDevice::LogicToLogic( aVisSize, aObjMap, aMyMap );
|
|
|
|
|
2004-10-04 18:32:09 +00:00
|
|
|
aVisSize.Width() = Fraction( aVisSize.Width() ) * GetScaleWidth();
|
|
|
|
aVisSize.Height()= Fraction( aVisSize.Height() ) * GetScaleHeight();
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
SwRect aRect( Point( LONG_MIN, LONG_MIN ), aVisSize );
|
|
|
|
rSh.LockView( TRUE ); //Scrollen im EndAction verhindern
|
|
|
|
rSh.StartAllAction();
|
2004-10-04 18:32:09 +00:00
|
|
|
rSh.RequestObjectResize( aRect, GetObject() );
|
2000-09-18 16:15:01 +00:00
|
|
|
rSh.EndAllAction();
|
|
|
|
rSh.LockView( FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwOleClient::MakeVisible()
|
|
|
|
{
|
|
|
|
const SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
|
2004-10-04 18:32:09 +00:00
|
|
|
rSh.MakeObjVisible( GetObject() );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|