2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-27 16:10:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2012-11-27 16:10:40 +00:00
|
|
|
* 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/.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2012-11-27 16:10:40 +00:00
|
|
|
* This file incorporates work covered by the following license notice:
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2012-11-27 16:10:40 +00:00
|
|
|
* 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 16:07:07 +00:00
|
|
|
|
2004-01-20 09:54:37 +00:00
|
|
|
#include "Client.hxx"
|
2005-04-18 10:15:21 +00:00
|
|
|
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/svdoole2.hxx>
|
|
|
|
#include <svx/svdograf.hxx>
|
|
|
|
#include <svx/svdpagv.hxx>
|
|
|
|
|
2004-10-04 17:31:06 +00:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "strings.hrc"
|
2004-01-20 09:54:37 +00:00
|
|
|
#include "ViewShell.hxx"
|
|
|
|
#include "DrawViewShell.hxx"
|
|
|
|
#include "View.hxx"
|
|
|
|
#include "Window.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "sdresid.hxx"
|
2006-11-14 13:26:56 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 17:31:06 +00:00
|
|
|
using namespace com::sun::star;
|
|
|
|
|
2004-01-20 09:54:37 +00:00
|
|
|
namespace sd {
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
Client::Client(SdrOle2Obj* pObj, ViewShell* pViewShell, vcl::Window* pWindow) :
|
2004-10-04 17:31:06 +00:00
|
|
|
SfxInPlaceClient(pViewShell->GetViewShell(), pWindow, pObj->GetAspect() ),
|
2006-12-12 16:13:24 +00:00
|
|
|
mpViewShell(pViewShell),
|
2000-09-18 16:07:07 +00:00
|
|
|
pSdrOle2Obj(pObj),
|
2015-11-10 10:23:02 +01:00
|
|
|
pSdrGrafObj(nullptr)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:31:06 +00:00
|
|
|
SetObject( pObj->GetObjRef() );
|
|
|
|
DBG_ASSERT( GetObject().is(), "No object connected!" );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-01-20 09:54:37 +00:00
|
|
|
Client::~Client()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-03-10 16:46:07 +01:00
|
|
|
/**
|
|
|
|
* If IP active, then we get this request to increase the visible section of the
|
|
|
|
* object.
|
|
|
|
*/
|
2004-10-04 17:31:06 +00:00
|
|
|
void Client::RequestNewObjectArea( Rectangle& aObjRect )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-12-12 16:13:24 +00:00
|
|
|
::sd::View* pView = mpViewShell->GetView();
|
2007-04-19 08:11:07 +00:00
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bSizeProtect = false;
|
|
|
|
bool bPosProtect = false;
|
2007-04-19 08:11:07 +00:00
|
|
|
|
|
|
|
const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
|
|
|
|
if (rMarkList.GetMarkCount() == 1)
|
|
|
|
{
|
|
|
|
SdrMark* pMark = rMarkList.GetMark(0);
|
|
|
|
SdrObject* pObj = pMark->GetMarkedSdrObj();
|
|
|
|
|
|
|
|
// no need to check for changes, this method is called only if the area really changed
|
|
|
|
bSizeProtect = pObj->IsResizeProtect();
|
|
|
|
bPosProtect = pObj->IsMoveProtect();
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle aOldRect = GetObjArea();
|
|
|
|
if ( bPosProtect )
|
|
|
|
aObjRect.SetPos( aOldRect.TopLeft() );
|
|
|
|
|
|
|
|
if ( bSizeProtect )
|
|
|
|
aObjRect.SetSize( aOldRect.GetSize() );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Rectangle aWorkArea( pView->GetWorkArea() );
|
2007-04-19 08:11:07 +00:00
|
|
|
if ( !aWorkArea.IsInside(aObjRect) && !bPosProtect && aObjRect != aOldRect )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:31:06 +00:00
|
|
|
// correct position
|
2000-09-18 16:07:07 +00:00
|
|
|
Point aPos = aObjRect.TopLeft();
|
|
|
|
Size aSize = aObjRect.GetSize();
|
|
|
|
Point aWorkAreaTL = aWorkArea.TopLeft();
|
|
|
|
Point aWorkAreaBR = aWorkArea.BottomRight();
|
|
|
|
|
2013-04-11 00:21:40 -03:00
|
|
|
aPos.X() = std::max(aPos.X(), aWorkAreaTL.X());
|
|
|
|
aPos.X() = std::min(aPos.X(), aWorkAreaBR.X()-aSize.Width());
|
|
|
|
aPos.Y() = std::max(aPos.Y(), aWorkAreaTL.Y());
|
|
|
|
aPos.Y() = std::min(aPos.Y(), aWorkAreaBR.Y()-aSize.Height());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
aObjRect.SetPos(aPos);
|
|
|
|
}
|
2004-10-04 17:31:06 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 17:31:06 +00:00
|
|
|
void Client::ObjectAreaChanged()
|
|
|
|
{
|
2006-12-12 16:13:24 +00:00
|
|
|
::sd::View* pView = mpViewShell->GetView();
|
2004-07-12 14:00:56 +00:00
|
|
|
const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
|
2000-09-18 16:07:07 +00:00
|
|
|
if (rMarkList.GetMarkCount() == 1)
|
|
|
|
{
|
|
|
|
SdrMark* pMark = rMarkList.GetMark(0);
|
2016-02-09 09:21:53 +11:00
|
|
|
SdrOle2Obj* pObj = dynamic_cast< SdrOle2Obj* >(pMark->GetMarkedSdrObj());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-11-27 16:10:40 +00:00
|
|
|
if(pObj)
|
|
|
|
{
|
|
|
|
// no need to check for changes, this method is called only if the area really changed
|
|
|
|
Rectangle aNewRectangle(GetScaledObjArea());
|
|
|
|
|
|
|
|
// #i118524# if sheared/rotated, center to non-rotated LogicRect
|
|
|
|
pObj->setSuppressSetVisAreaSize(true);
|
|
|
|
|
2014-10-21 08:56:06 +02:00
|
|
|
if(pObj->GetGeoStat().nRotationAngle || pObj->GetGeoStat().nShearAngle)
|
2012-11-27 16:10:40 +00:00
|
|
|
{
|
|
|
|
pObj->SetLogicRect( aNewRectangle );
|
|
|
|
|
|
|
|
const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
|
|
|
|
const Point aDelta(aNewRectangle.Center() - rBoundRect.Center());
|
|
|
|
|
|
|
|
aNewRectangle.Move(aDelta.X(), aDelta.Y());
|
|
|
|
}
|
|
|
|
|
|
|
|
pObj->SetLogicRect( aNewRectangle );
|
|
|
|
pObj->setSuppressSetVisAreaSize(false);
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-04 17:31:06 +00:00
|
|
|
void Client::ViewChanged()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-10-13 10:02:13 +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
|
|
|
|
|
|
|
|
pSdrOle2Obj->ActionChanged(); // draw needs it to remove lines in slide preview
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-10-04 17:31:06 +00:00
|
|
|
//TODO/LATER: should we try to avoid the recalculation of the visareasize
|
|
|
|
//if we know that it didn't change?
|
2006-12-12 16:13:24 +00:00
|
|
|
if (mpViewShell->GetActiveWindow())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-12-12 16:13:24 +00:00
|
|
|
::sd::View* pView = mpViewShell->GetView();
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pView)
|
|
|
|
{
|
2008-01-14 12:44:18 +00:00
|
|
|
Rectangle aLogicRect( pSdrOle2Obj->GetLogicRect() );
|
|
|
|
Size aLogicSize( aLogicRect.GetWidth(), aLogicRect.GetHeight() );
|
|
|
|
|
|
|
|
if( pSdrOle2Obj->IsChart() )
|
|
|
|
{
|
|
|
|
//charts never should be stretched see #i84323# for example
|
|
|
|
pSdrOle2Obj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aLogicSize ) );
|
|
|
|
pSdrOle2Obj->BroadcastObjectChange();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-11-26 15:17:37 +00:00
|
|
|
// TODO/LEAN: maybe we can do this without requesting the VisualArea?
|
2005-01-31 08:04:52 +00:00
|
|
|
// working with the visual area might need running state, so the object may switch itself to this state
|
2016-09-20 16:41:39 +02:00
|
|
|
MapMode aMap100( MapUnit::Map100thMM );
|
2004-10-04 17:31:06 +00:00
|
|
|
Rectangle aVisArea;
|
2006-10-13 10:02:13 +00:00
|
|
|
Size aSize = pSdrOle2Obj->GetOrigObjSize( &aMap100 );
|
|
|
|
|
|
|
|
aVisArea.SetSize( aSize );
|
2014-10-23 17:41:47 +02:00
|
|
|
Size aScaledSize( static_cast< long >( GetScaleWidth() * Fraction( aVisArea.GetWidth() ) ),
|
|
|
|
static_cast< long >( GetScaleHeight() * Fraction( aVisArea.GetHeight() ) ) );
|
2006-03-24 11:50:51 +00:00
|
|
|
|
|
|
|
// react to the change if the difference is bigger than one pixel
|
|
|
|
Size aPixelDiff =
|
|
|
|
Application::GetDefaultDevice()->LogicToPixel(
|
|
|
|
Size( aLogicRect.GetWidth() - aScaledSize.Width(),
|
|
|
|
aLogicRect.GetHeight() - aScaledSize.Height() ),
|
|
|
|
aMap100 );
|
|
|
|
if( aPixelDiff.Width() || aPixelDiff.Height() )
|
2001-12-05 14:24:58 +00:00
|
|
|
{
|
2004-10-04 17:31:06 +00:00
|
|
|
pSdrOle2Obj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
|
|
|
|
pSdrOle2Obj->BroadcastObjectChange();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-10-04 17:31:06 +00:00
|
|
|
else
|
|
|
|
pSdrOle2Obj->ActionChanged();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-20 09:54:37 +00:00
|
|
|
} // end of namespace sd
|
2004-10-04 17:31:06 +00:00
|
|
|
|
2010-10-12 15:51:52 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|