LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/docshell - sdclient.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 80 0.0 %
Date: 2012-12-27 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "Client.hxx"
      22             : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      23             : #include <svx/svdoole2.hxx>
      24             : #include <svx/svdograf.hxx>
      25             : #include <svx/svdpagv.hxx>
      26             : 
      27             : #include <toolkit/helper/vclunohelper.hxx>
      28             : 
      29             : #include "strings.hrc"
      30             : #include "ViewShell.hxx"
      31             : #include "DrawViewShell.hxx"
      32             : #include "View.hxx"
      33             : #include "Window.hxx"
      34             : #include "sdresid.hxx"
      35             : #include <vcl/svapp.hxx>
      36             : 
      37             : using namespace com::sun::star;
      38             : 
      39             : namespace sd {
      40             : 
      41             : /*************************************************************************
      42             : |*
      43             : |* Ctor
      44             : |*
      45             : \************************************************************************/
      46             : 
      47           0 : Client::Client(SdrOle2Obj* pObj, ViewShell* pViewShell, ::Window* pWindow) :
      48             :     SfxInPlaceClient(pViewShell->GetViewShell(), pWindow, pObj->GetAspect() ),
      49             :     mpViewShell(pViewShell),
      50             :     pSdrOle2Obj(pObj),
      51             :     pSdrGrafObj(NULL),
      52           0 :     pOutlinerParaObj (NULL)
      53             : {
      54           0 :     SetObject( pObj->GetObjRef() );
      55             :     DBG_ASSERT( GetObject().is(), "No object connected!" );
      56           0 : }
      57             : 
      58             : /*************************************************************************
      59             : |*
      60             : |* Dtor
      61             : |*
      62             : \************************************************************************/
      63             : 
      64           0 : Client::~Client()
      65             : {
      66           0 : }
      67             : 
      68             : 
      69             : /*************************************************************************
      70             : |*
      71             : |* Wenn IP-aktiv, dann kommt diese Anforderung um Vergroesserung des
      72             : |* sichtbaren Ausschnitts des Objektes
      73             : |*
      74             : \************************************************************************/
      75             : 
      76           0 : void Client::RequestNewObjectArea( Rectangle& aObjRect )
      77             : {
      78           0 :     ::sd::View* pView = mpViewShell->GetView();
      79             : 
      80           0 :     sal_Bool bSizeProtect = sal_False;
      81           0 :     sal_Bool bPosProtect = sal_False;
      82             : 
      83           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
      84           0 :     if (rMarkList.GetMarkCount() == 1)
      85             :     {
      86           0 :         SdrMark* pMark = rMarkList.GetMark(0);
      87           0 :         SdrObject* pObj = pMark->GetMarkedSdrObj();
      88             : 
      89             :         // no need to check for changes, this method is called only if the area really changed
      90           0 :         bSizeProtect = pObj->IsResizeProtect();
      91           0 :         bPosProtect = pObj->IsMoveProtect();
      92             :     }
      93             : 
      94           0 :     Rectangle aOldRect = GetObjArea();
      95           0 :     if ( bPosProtect )
      96           0 :         aObjRect.SetPos( aOldRect.TopLeft() );
      97             : 
      98           0 :     if ( bSizeProtect )
      99           0 :         aObjRect.SetSize( aOldRect.GetSize() );
     100             : 
     101           0 :     Rectangle aWorkArea( pView->GetWorkArea() );
     102           0 :     if ( !aWorkArea.IsInside(aObjRect) && !bPosProtect && aObjRect != aOldRect )
     103             :     {
     104             :         // correct position
     105           0 :         Point aPos = aObjRect.TopLeft();
     106           0 :         Size  aSize = aObjRect.GetSize();
     107           0 :         Point aWorkAreaTL = aWorkArea.TopLeft();
     108           0 :         Point aWorkAreaBR = aWorkArea.BottomRight();
     109             : 
     110           0 :         aPos.X() = Max(aPos.X(), aWorkAreaTL.X());
     111           0 :         aPos.X() = Min(aPos.X(), aWorkAreaBR.X()-aSize.Width());
     112           0 :         aPos.Y() = Max(aPos.Y(), aWorkAreaTL.Y());
     113           0 :         aPos.Y() = Min(aPos.Y(), aWorkAreaBR.Y()-aSize.Height());
     114             : 
     115           0 :         aObjRect.SetPos(aPos);
     116             :     }
     117           0 : }
     118             : 
     119           0 : void Client::ObjectAreaChanged()
     120             : {
     121           0 :     ::sd::View* pView = mpViewShell->GetView();
     122           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     123           0 :     if (rMarkList.GetMarkCount() == 1)
     124             :     {
     125           0 :         SdrMark* pMark = rMarkList.GetMark(0);
     126           0 :                 SdrOle2Obj* pObj = dynamic_cast< SdrOle2Obj* >(pMark->GetMarkedSdrObj());
     127             : 
     128           0 :         if(pObj)
     129             :         {
     130             :             // no need to check for changes, this method is called only if the area really changed
     131           0 :             Rectangle aNewRectangle(GetScaledObjArea());
     132             : 
     133             :             // #i118524# if sheared/rotated, center to non-rotated LogicRect
     134           0 :             pObj->setSuppressSetVisAreaSize(true);
     135             : 
     136           0 :             if(pObj->GetGeoStat().nDrehWink || pObj->GetGeoStat().nShearWink)
     137             :             {
     138           0 :                 pObj->SetLogicRect( aNewRectangle );
     139             : 
     140           0 :                 const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
     141           0 :                 const Point aDelta(aNewRectangle.Center() - rBoundRect.Center());
     142             : 
     143           0 :                 aNewRectangle.Move(aDelta.X(), aDelta.Y());
     144             :             }
     145             : 
     146           0 :             pObj->SetLogicRect( aNewRectangle );
     147           0 :             pObj->setSuppressSetVisAreaSize(false);
     148             :         }
     149             :     }
     150           0 : }
     151             : 
     152           0 : void Client::ViewChanged()
     153             : {
     154           0 :     if ( GetAspect() == embed::Aspects::MSOLE_ICON )
     155             :     {
     156             :         // the iconified object seems not to need such a scaling handling
     157             :         // since the replacement image and the size a completely controlled by the container
     158             :         // TODO/LATER: when the icon exchange is implemented the scaling handling might be required again here
     159             : 
     160           0 :         pSdrOle2Obj->ActionChanged(); // draw needs it to remove lines in slide preview
     161           0 :         return;
     162             :     }
     163             : 
     164             :     //TODO/LATER: should we try to avoid the recalculation of the visareasize
     165             :     //if we know that it didn't change?
     166           0 :     if (mpViewShell->GetActiveWindow())
     167             :     {
     168           0 :         ::sd::View* pView = mpViewShell->GetView();
     169           0 :         if (pView)
     170             :         {
     171           0 :             Rectangle aLogicRect( pSdrOle2Obj->GetLogicRect() );
     172           0 :             Size aLogicSize( aLogicRect.GetWidth(), aLogicRect.GetHeight() );
     173             : 
     174           0 :             if( pSdrOle2Obj->IsChart() )
     175             :             {
     176             :                 //charts never should be stretched see #i84323# for example
     177           0 :                 pSdrOle2Obj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aLogicSize ) );
     178           0 :                 pSdrOle2Obj->BroadcastObjectChange();
     179             :                 return;
     180             :             }
     181             : 
     182             :             // TODO/LEAN: maybe we can do this without requesting the VisualArea?
     183             :             // working with the visual area might need running state, so the object may switch itself to this state
     184           0 :             MapMode             aMap100( MAP_100TH_MM );
     185           0 :             Rectangle           aVisArea;
     186           0 :             Size aSize = pSdrOle2Obj->GetOrigObjSize( &aMap100 );
     187             : 
     188           0 :             aVisArea.SetSize( aSize );
     189           0 :             Size                aScaledSize( static_cast< long >( GetScaleWidth() * Fraction( aVisArea.GetWidth() ) ),
     190           0 :                                                 static_cast< long >( GetScaleHeight() * Fraction( aVisArea.GetHeight() ) ) );
     191             : 
     192             :             // react to the change if the difference is bigger than one pixel
     193             :             Size aPixelDiff =
     194             :                 Application::GetDefaultDevice()->LogicToPixel(
     195           0 :                     Size( aLogicRect.GetWidth() - aScaledSize.Width(),
     196           0 :                           aLogicRect.GetHeight() - aScaledSize.Height() ),
     197           0 :                     aMap100 );
     198           0 :             if( aPixelDiff.Width() || aPixelDiff.Height() )
     199             :             {
     200           0 :                 pSdrOle2Obj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
     201           0 :                 pSdrOle2Obj->BroadcastObjectChange();
     202             :             }
     203             :             else
     204           0 :                 pSdrOle2Obj->ActionChanged();
     205             :         }
     206             :     }
     207             : }
     208             : 
     209             : 
     210             : /*************************************************************************
     211             : |*
     212             : |* Objekt in den sichtbaren Breich scrollen
     213             : |*
     214             : \************************************************************************/
     215             : 
     216           0 : void Client::MakeVisible()
     217             : {
     218           0 :     if (mpViewShell->ISA(DrawViewShell))
     219             :     {
     220             :         static_cast<DrawViewShell*>(mpViewShell)->MakeVisible(
     221           0 :             pSdrOle2Obj->GetLogicRect(),
     222           0 :             *mpViewShell->GetActiveWindow());
     223             :     }
     224           0 : }
     225             : 
     226             : } // end of namespace sd
     227             : 
     228             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10