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

Generated by: LCOV version 1.11