LCOV - code coverage report
Current view: top level - sd/source/ui/docshell - sdclient.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 81 0.0 %
Date: 2014-04-14 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           0 : Client::Client(SdrOle2Obj* pObj, ViewShell* pViewShell, ::Window* pWindow) :
      43             :     SfxInPlaceClient(pViewShell->GetViewShell(), pWindow, pObj->GetAspect() ),
      44             :     mpViewShell(pViewShell),
      45             :     pSdrOle2Obj(pObj),
      46             :     pSdrGrafObj(NULL),
      47           0 :     pOutlinerParaObj (NULL)
      48             : {
      49           0 :     SetObject( pObj->GetObjRef() );
      50             :     DBG_ASSERT( GetObject().is(), "No object connected!" );
      51           0 : }
      52             : 
      53           0 : Client::~Client()
      54             : {
      55           0 : }
      56             : 
      57             : 
      58             : /**
      59             :  * If IP active, then we get this request to increase the visible section of the
      60             :  * object.
      61             :  */
      62           0 : void Client::RequestNewObjectArea( Rectangle& aObjRect )
      63             : {
      64           0 :     ::sd::View* pView = mpViewShell->GetView();
      65             : 
      66           0 :     sal_Bool bSizeProtect = sal_False;
      67           0 :     sal_Bool bPosProtect = sal_False;
      68             : 
      69           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
      70           0 :     if (rMarkList.GetMarkCount() == 1)
      71             :     {
      72           0 :         SdrMark* pMark = rMarkList.GetMark(0);
      73           0 :         SdrObject* pObj = pMark->GetMarkedSdrObj();
      74             : 
      75             :         // no need to check for changes, this method is called only if the area really changed
      76           0 :         bSizeProtect = pObj->IsResizeProtect();
      77           0 :         bPosProtect = pObj->IsMoveProtect();
      78             :     }
      79             : 
      80           0 :     Rectangle aOldRect = GetObjArea();
      81           0 :     if ( bPosProtect )
      82           0 :         aObjRect.SetPos( aOldRect.TopLeft() );
      83             : 
      84           0 :     if ( bSizeProtect )
      85           0 :         aObjRect.SetSize( aOldRect.GetSize() );
      86             : 
      87           0 :     Rectangle aWorkArea( pView->GetWorkArea() );
      88           0 :     if ( !aWorkArea.IsInside(aObjRect) && !bPosProtect && aObjRect != aOldRect )
      89             :     {
      90             :         // correct position
      91           0 :         Point aPos = aObjRect.TopLeft();
      92           0 :         Size  aSize = aObjRect.GetSize();
      93           0 :         Point aWorkAreaTL = aWorkArea.TopLeft();
      94           0 :         Point aWorkAreaBR = aWorkArea.BottomRight();
      95             : 
      96           0 :         aPos.X() = std::max(aPos.X(), aWorkAreaTL.X());
      97           0 :         aPos.X() = std::min(aPos.X(), aWorkAreaBR.X()-aSize.Width());
      98           0 :         aPos.Y() = std::max(aPos.Y(), aWorkAreaTL.Y());
      99           0 :         aPos.Y() = std::min(aPos.Y(), aWorkAreaBR.Y()-aSize.Height());
     100             : 
     101           0 :         aObjRect.SetPos(aPos);
     102             :     }
     103           0 : }
     104             : 
     105           0 : void Client::ObjectAreaChanged()
     106             : {
     107           0 :     ::sd::View* pView = mpViewShell->GetView();
     108           0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     109           0 :     if (rMarkList.GetMarkCount() == 1)
     110             :     {
     111           0 :         SdrMark* pMark = rMarkList.GetMark(0);
     112           0 :                 SdrOle2Obj* pObj = dynamic_cast< SdrOle2Obj* >(pMark->GetMarkedSdrObj());
     113             : 
     114           0 :         if(pObj)
     115             :         {
     116             :             // no need to check for changes, this method is called only if the area really changed
     117           0 :             Rectangle aNewRectangle(GetScaledObjArea());
     118             : 
     119             :             // #i118524# if sheared/rotated, center to non-rotated LogicRect
     120           0 :             pObj->setSuppressSetVisAreaSize(true);
     121             : 
     122           0 :             if(pObj->GetGeoStat().nDrehWink || pObj->GetGeoStat().nShearWink)
     123             :             {
     124           0 :                 pObj->SetLogicRect( aNewRectangle );
     125             : 
     126           0 :                 const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
     127           0 :                 const Point aDelta(aNewRectangle.Center() - rBoundRect.Center());
     128             : 
     129           0 :                 aNewRectangle.Move(aDelta.X(), aDelta.Y());
     130             :             }
     131             : 
     132           0 :             pObj->SetLogicRect( aNewRectangle );
     133           0 :             pObj->setSuppressSetVisAreaSize(false);
     134             :         }
     135             :     }
     136           0 : }
     137             : 
     138           0 : void Client::ViewChanged()
     139             : {
     140           0 :     if ( GetAspect() == embed::Aspects::MSOLE_ICON )
     141             :     {
     142             :         // the iconified object seems not to need such a scaling handling
     143             :         // since the replacement image and the size a completely controlled by the container
     144             :         // TODO/LATER: when the icon exchange is implemented the scaling handling might be required again here
     145             : 
     146           0 :         pSdrOle2Obj->ActionChanged(); // draw needs it to remove lines in slide preview
     147           0 :         return;
     148             :     }
     149             : 
     150             :     //TODO/LATER: should we try to avoid the recalculation of the visareasize
     151             :     //if we know that it didn't change?
     152           0 :     if (mpViewShell->GetActiveWindow())
     153             :     {
     154           0 :         ::sd::View* pView = mpViewShell->GetView();
     155           0 :         if (pView)
     156             :         {
     157           0 :             Rectangle aLogicRect( pSdrOle2Obj->GetLogicRect() );
     158           0 :             Size aLogicSize( aLogicRect.GetWidth(), aLogicRect.GetHeight() );
     159             : 
     160           0 :             if( pSdrOle2Obj->IsChart() )
     161             :             {
     162             :                 //charts never should be stretched see #i84323# for example
     163           0 :                 pSdrOle2Obj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aLogicSize ) );
     164           0 :                 pSdrOle2Obj->BroadcastObjectChange();
     165           0 :                 return;
     166             :             }
     167             : 
     168             :             // TODO/LEAN: maybe we can do this without requesting the VisualArea?
     169             :             // working with the visual area might need running state, so the object may switch itself to this state
     170           0 :             MapMode             aMap100( MAP_100TH_MM );
     171           0 :             Rectangle           aVisArea;
     172           0 :             Size aSize = pSdrOle2Obj->GetOrigObjSize( &aMap100 );
     173             : 
     174           0 :             aVisArea.SetSize( aSize );
     175           0 :             Size                aScaledSize( static_cast< long >( GetScaleWidth() * Fraction( aVisArea.GetWidth() ) ),
     176           0 :                                                 static_cast< long >( GetScaleHeight() * Fraction( aVisArea.GetHeight() ) ) );
     177             : 
     178             :             // react to the change if the difference is bigger than one pixel
     179             :             Size aPixelDiff =
     180             :                 Application::GetDefaultDevice()->LogicToPixel(
     181           0 :                     Size( aLogicRect.GetWidth() - aScaledSize.Width(),
     182           0 :                           aLogicRect.GetHeight() - aScaledSize.Height() ),
     183           0 :                     aMap100 );
     184           0 :             if( aPixelDiff.Width() || aPixelDiff.Height() )
     185             :             {
     186           0 :                 pSdrOle2Obj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
     187           0 :                 pSdrOle2Obj->BroadcastObjectChange();
     188             :             }
     189             :             else
     190           0 :                 pSdrOle2Obj->ActionChanged();
     191             :         }
     192             :     }
     193             : }
     194             : 
     195             : 
     196             : /**
     197             :  * Scroll object into visible area.
     198             :  */
     199           0 : void Client::MakeVisible()
     200             : {
     201           0 :     if (mpViewShell->ISA(DrawViewShell))
     202             :     {
     203             :         static_cast<DrawViewShell*>(mpViewShell)->MakeVisible(
     204           0 :             pSdrOle2Obj->GetLogicRect(),
     205           0 :             *mpViewShell->GetActiveWindow());
     206             :     }
     207           0 : }
     208             : 
     209             : } // end of namespace sd
     210             : 
     211             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10