LCOV - code coverage report
Current view: top level - sd/source/ui/docshell - sdclient.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 71 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 122 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "Client.hxx"
      31                 :            : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      32                 :            : #include <svx/svdoole2.hxx>
      33                 :            : #include <svx/svdograf.hxx>
      34                 :            : #include <svx/svdpagv.hxx>
      35                 :            : 
      36                 :            : #include <toolkit/helper/vclunohelper.hxx>
      37                 :            : 
      38                 :            : #include "strings.hrc"
      39                 :            : #include "ViewShell.hxx"
      40                 :            : #include "DrawViewShell.hxx"
      41                 :            : #include "View.hxx"
      42                 :            : #include "Window.hxx"
      43                 :            : #include "sdresid.hxx"
      44                 :            : #include <vcl/svapp.hxx>
      45                 :            : 
      46                 :            : using namespace com::sun::star;
      47                 :            : 
      48                 :            : namespace sd {
      49                 :            : 
      50                 :            : /*************************************************************************
      51                 :            : |*
      52                 :            : |* Ctor
      53                 :            : |*
      54                 :            : \************************************************************************/
      55                 :            : 
      56                 :          0 : Client::Client(SdrOle2Obj* pObj, ViewShell* pViewShell, ::Window* pWindow) :
      57                 :            :     SfxInPlaceClient(pViewShell->GetViewShell(), pWindow, pObj->GetAspect() ),
      58                 :            :     mpViewShell(pViewShell),
      59                 :            :     pSdrOle2Obj(pObj),
      60                 :            :     pSdrGrafObj(NULL),
      61                 :          0 :     pOutlinerParaObj (NULL)
      62                 :            : {
      63 [ #  # ][ #  # ]:          0 :     SetObject( pObj->GetObjRef() );
      64                 :            :     DBG_ASSERT( GetObject().is(), "No object connected!" );
      65                 :          0 : }
      66                 :            : 
      67                 :            : /*************************************************************************
      68                 :            : |*
      69                 :            : |* Dtor
      70                 :            : |*
      71                 :            : \************************************************************************/
      72                 :            : 
      73                 :          0 : Client::~Client()
      74                 :            : {
      75         [ #  # ]:          0 : }
      76                 :            : 
      77                 :            : 
      78                 :            : /*************************************************************************
      79                 :            : |*
      80                 :            : |* Wenn IP-aktiv, dann kommt diese Anforderung um Vergroesserung des
      81                 :            : |* sichtbaren Ausschnitts des Objektes
      82                 :            : |*
      83                 :            : \************************************************************************/
      84                 :            : 
      85                 :          0 : void Client::RequestNewObjectArea( Rectangle& aObjRect )
      86                 :            : {
      87                 :          0 :     ::sd::View* pView = mpViewShell->GetView();
      88                 :            : 
      89                 :          0 :     sal_Bool bSizeProtect = sal_False;
      90                 :          0 :     sal_Bool bPosProtect = sal_False;
      91                 :            : 
      92                 :          0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
      93         [ #  # ]:          0 :     if (rMarkList.GetMarkCount() == 1)
      94                 :            :     {
      95         [ #  # ]:          0 :         SdrMark* pMark = rMarkList.GetMark(0);
      96         [ #  # ]:          0 :         SdrObject* pObj = pMark->GetMarkedSdrObj();
      97                 :            : 
      98                 :            :         // no need to check for changes, this method is called only if the area really changed
      99         [ #  # ]:          0 :         bSizeProtect = pObj->IsResizeProtect();
     100         [ #  # ]:          0 :         bPosProtect = pObj->IsMoveProtect();
     101                 :            :     }
     102                 :            : 
     103         [ #  # ]:          0 :     Rectangle aOldRect = GetObjArea();
     104         [ #  # ]:          0 :     if ( bPosProtect )
     105                 :          0 :         aObjRect.SetPos( aOldRect.TopLeft() );
     106                 :            : 
     107         [ #  # ]:          0 :     if ( bSizeProtect )
     108 [ #  # ][ #  # ]:          0 :         aObjRect.SetSize( aOldRect.GetSize() );
     109                 :            : 
     110                 :          0 :     Rectangle aWorkArea( pView->GetWorkArea() );
     111 [ #  # ][ #  # ]:          0 :     if ( !aWorkArea.IsInside(aObjRect) && !bPosProtect && aObjRect != aOldRect )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     112                 :            :     {
     113                 :            :         // correct position
     114                 :          0 :         Point aPos = aObjRect.TopLeft();
     115         [ #  # ]:          0 :         Size  aSize = aObjRect.GetSize();
     116                 :          0 :         Point aWorkAreaTL = aWorkArea.TopLeft();
     117         [ #  # ]:          0 :         Point aWorkAreaBR = aWorkArea.BottomRight();
     118                 :            : 
     119                 :          0 :         aPos.X() = Max(aPos.X(), aWorkAreaTL.X());
     120                 :          0 :         aPos.X() = Min(aPos.X(), aWorkAreaBR.X()-aSize.Width());
     121                 :          0 :         aPos.Y() = Max(aPos.Y(), aWorkAreaTL.Y());
     122                 :          0 :         aPos.Y() = Min(aPos.Y(), aWorkAreaBR.Y()-aSize.Height());
     123                 :            : 
     124                 :          0 :         aObjRect.SetPos(aPos);
     125                 :            :     }
     126                 :          0 : }
     127                 :            : 
     128                 :          0 : void Client::ObjectAreaChanged()
     129                 :            : {
     130                 :          0 :     ::sd::View* pView = mpViewShell->GetView();
     131                 :          0 :     const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
     132         [ #  # ]:          0 :     if (rMarkList.GetMarkCount() == 1)
     133                 :            :     {
     134                 :          0 :         SdrMark* pMark = rMarkList.GetMark(0);
     135                 :          0 :         SdrObject* pObj = pMark->GetMarkedSdrObj();
     136                 :            : 
     137                 :            :         // no need to check for changes, this method is called only if the area really changed
     138         [ #  # ]:          0 :         pObj->SetLogicRect( GetScaledObjArea() );
     139                 :            :     }
     140                 :          0 : }
     141                 :            : 
     142                 :          0 : void Client::ViewChanged()
     143                 :            : {
     144         [ #  # ]:          0 :     if ( GetAspect() == embed::Aspects::MSOLE_ICON )
     145                 :            :     {
     146                 :            :         // the iconified object seems not to need such a scaling handling
     147                 :            :         // since the replacement image and the size a completely controlled by the container
     148                 :            :         // TODO/LATER: when the icon exchange is implemented the scaling handling might be required again here
     149                 :            : 
     150                 :          0 :         pSdrOle2Obj->ActionChanged(); // draw needs it to remove lines in slide preview
     151                 :          0 :         return;
     152                 :            :     }
     153                 :            : 
     154                 :            :     //TODO/LATER: should we try to avoid the recalculation of the visareasize
     155                 :            :     //if we know that it didn't change?
     156         [ #  # ]:          0 :     if (mpViewShell->GetActiveWindow())
     157                 :            :     {
     158                 :          0 :         ::sd::View* pView = mpViewShell->GetView();
     159         [ #  # ]:          0 :         if (pView)
     160                 :            :         {
     161         [ #  # ]:          0 :             Rectangle aLogicRect( pSdrOle2Obj->GetLogicRect() );
     162 [ #  # ][ #  # ]:          0 :             Size aLogicSize( aLogicRect.GetWidth(), aLogicRect.GetHeight() );
     163                 :            : 
     164 [ #  # ][ #  # ]:          0 :             if( pSdrOle2Obj->IsChart() )
     165                 :            :             {
     166                 :            :                 //charts never should be stretched see #i84323# for example
     167 [ #  # ][ #  # ]:          0 :                 pSdrOle2Obj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aLogicSize ) );
     168         [ #  # ]:          0 :                 pSdrOle2Obj->BroadcastObjectChange();
     169                 :            :                 return;
     170                 :            :             }
     171                 :            : 
     172                 :            :             // TODO/LEAN: maybe we can do this without requesting the VisualArea?
     173                 :            :             // working with the visual area might need running state, so the object may switch itself to this state
     174         [ #  # ]:          0 :             MapMode             aMap100( MAP_100TH_MM );
     175         [ #  # ]:          0 :             Rectangle           aVisArea;
     176         [ #  # ]:          0 :             Size aSize = pSdrOle2Obj->GetOrigObjSize( &aMap100 );
     177                 :            : 
     178         [ #  # ]:          0 :             aVisArea.SetSize( aSize );
     179         [ #  # ]:          0 :             Size                aScaledSize( static_cast< long >( GetScaleWidth() * Fraction( aVisArea.GetWidth() ) ),
     180 [ #  # ][ #  # ]:          0 :                                                 static_cast< long >( GetScaleHeight() * Fraction( aVisArea.GetHeight() ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     181                 :            : 
     182                 :            :             // react to the change if the difference is bigger than one pixel
     183                 :            :             Size aPixelDiff =
     184                 :            :                 Application::GetDefaultDevice()->LogicToPixel(
     185         [ #  # ]:          0 :                     Size( aLogicRect.GetWidth() - aScaledSize.Width(),
     186         [ #  # ]:          0 :                           aLogicRect.GetHeight() - aScaledSize.Height() ),
     187 [ #  # ][ #  # ]:          0 :                     aMap100 );
     188 [ #  # ][ #  # ]:          0 :             if( aPixelDiff.Width() || aPixelDiff.Height() )
                 [ #  # ]
     189                 :            :             {
     190 [ #  # ][ #  # ]:          0 :                 pSdrOle2Obj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
     191         [ #  # ]:          0 :                 pSdrOle2Obj->BroadcastObjectChange();
     192                 :            :             }
     193                 :            :             else
     194 [ #  # ][ #  # ]:          0 :                 pSdrOle2Obj->ActionChanged();
     195                 :            :         }
     196                 :            :     }
     197                 :            : }
     198                 :            : 
     199                 :            : 
     200                 :            : /*************************************************************************
     201                 :            : |*
     202                 :            : |* Objekt in den sichtbaren Breich scrollen
     203                 :            : |*
     204                 :            : \************************************************************************/
     205                 :            : 
     206                 :          0 : void Client::MakeVisible()
     207                 :            : {
     208         [ #  # ]:          0 :     if (mpViewShell->ISA(DrawViewShell))
     209                 :            :     {
     210                 :            :         static_cast<DrawViewShell*>(mpViewShell)->MakeVisible(
     211                 :          0 :             pSdrOle2Obj->GetLogicRect(),
     212                 :          0 :             *mpViewShell->GetActiveWindow());
     213                 :            :     }
     214                 :          0 : }
     215                 :            : 
     216                 :            : } // end of namespace sd
     217                 :            : 
     218                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10