LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/view - drviewsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 53 1.9 %
Date: 2013-07-09 Functions: 2 4 50.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 "DrawViewShell.hxx"
      22             : #include <svl/aeitem.hxx>
      23             : #include <svl/itemset.hxx>
      24             : #include <sfx2/request.hxx>
      25             : #include <svx/svxids.hrc>
      26             : 
      27             : 
      28             : #include <svx/fmshell.hxx>
      29             : #include <sfx2/dispatch.hxx>
      30             : 
      31             : #include "app.hrc"
      32             : #include "strings.hrc"
      33             : #include "sdpage.hxx"
      34             : #ifndef SD_FRAME_VIEW
      35             : #include "FrameView.hxx"
      36             : #endif
      37             : #include "sdresid.hxx"
      38             : #include "drawdoc.hxx"
      39             : #include "DrawDocShell.hxx"
      40             : #include "Window.hxx"
      41             : #include "GraphicViewShell.hxx"
      42             : #include "drawview.hxx"
      43             : 
      44             : #include "slideshow.hxx"
      45             : 
      46             : namespace sd {
      47             : 
      48           0 : sal_Bool DrawViewShell::GotoBookmark(const String& rBookmark)
      49             : {
      50           0 :     sal_Bool bRet = sal_False;
      51           0 :     ::sd::DrawDocShell* pDocSh = GetDocSh();
      52           0 :     if( pDocSh )
      53             :     {
      54           0 :         if( !pDocSh->GetViewShell() ) //#i26016# this case occurs if the jump-target-document was opened already with file open dialog before triggering the jump via hyperlink
      55           0 :             pDocSh->Connect(this);
      56           0 :         bRet = (pDocSh->GotoBookmark(rBookmark));
      57             :     }
      58           0 :     return bRet;
      59             : }
      60             : 
      61             : /**
      62             :  * Make area visible (scroll part of picture)
      63             : |*
      64             : \************************************************************************/
      65             : 
      66           0 : void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin)
      67             : {
      68             :     // In older versions, if in X or Y the size of the object was
      69             :     // smaller than the visible area, the user-defined zoom was
      70             :     // changed. This was decided to be a bug for 6.x, thus I developed a
      71             :     // version which instead handles X/Y bigger/smaller and visibility
      72             :     // questions separately. The new behaviour is triggered with the
      73             :     // bZoomAllowed parameter which for old behaviour should be set to
      74             :     // sal_True. I looked at all uses of MakeVisible() in the application
      75             :     // and found no valid reason for really changing the zoom factor, thus I
      76             :     // decided to NOT expand (incompatible) this virtual method to get one
      77             :     // more parameter. If this is wanted in later versions, feel free to add
      78             :     // that bool to the parameter list.
      79           0 :     sal_Bool bZoomAllowed(sal_False);
      80           0 :     Size aLogicSize(rRect.GetSize());
      81             : 
      82             :     // visible area
      83           0 :     Size aVisSizePixel(rWin.GetOutputSizePixel());
      84           0 :     Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel)));
      85           0 :     Size aVisAreaSize(aVisArea.GetSize());
      86             : 
      87           0 :     if(!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) )
      88             :     {
      89             :         // object is not entirely in visible area
      90           0 :         sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width());
      91           0 :         sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height());
      92             : 
      93           0 :         if(bZoomAllowed && (nFreeSpaceX < 0 || nFreeSpaceY < 0))
      94             :         {
      95             :             // object does not fit into visible area -> zoom to object size
      96           0 :             SetZoomRect(rRect);
      97             :         }
      98             :         else
      99             :         {
     100             :             // allow a mode for move-only visibility without zooming.
     101           0 :             const sal_Int32 nPercentBorder(30);
     102             :             const Rectangle aInnerRectangle(
     103           0 :                 aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200),
     104           0 :                 aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200),
     105           0 :                 aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200),
     106           0 :                 aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200)
     107           0 :                 );
     108           0 :             Point aNewPos(aVisArea.TopLeft());
     109             : 
     110           0 :             if(nFreeSpaceX < 0)
     111             :             {
     112           0 :                 if(aInnerRectangle.Left() > rRect.Right())
     113             :                 {
     114             :                     // object moves out to the left
     115           0 :                     aNewPos.X() -= aVisAreaSize.Width() / 2;
     116             :                 }
     117             : 
     118           0 :                 if(aInnerRectangle.Right() < rRect.Left())
     119             :                 {
     120             :                     // object moves out to the right
     121           0 :                     aNewPos.X() += aVisAreaSize.Width() / 2;
     122             :                 }
     123             :             }
     124             :             else
     125             :             {
     126           0 :                 if(nFreeSpaceX > rRect.GetWidth())
     127           0 :                     nFreeSpaceX = rRect.GetWidth();
     128             : 
     129           0 :                 while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width())
     130           0 :                     aNewPos.X() += nFreeSpaceX;
     131             : 
     132           0 :                 while(rRect.Left() < aNewPos.X())
     133           0 :                     aNewPos.X() -= nFreeSpaceX;
     134             :             }
     135             : 
     136           0 :             if(nFreeSpaceY < 0)
     137             :             {
     138           0 :                 if(aInnerRectangle.Top() > rRect.Bottom())
     139             :                 {
     140             :                     // object moves out to the top
     141           0 :                     aNewPos.Y() -= aVisAreaSize.Height() / 2;
     142             :                 }
     143             : 
     144           0 :                 if(aInnerRectangle.Bottom() < rRect.Top())
     145             :                 {
     146             :                     // object moves out to the right
     147           0 :                     aNewPos.Y() += aVisAreaSize.Height() / 2;
     148             :                 }
     149             :             }
     150             :             else
     151             :             {
     152           0 :                 if(nFreeSpaceY > rRect.GetHeight())
     153           0 :                     nFreeSpaceY = rRect.GetHeight();
     154             : 
     155           0 :                 while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height())
     156           0 :                     aNewPos.Y() += nFreeSpaceY;
     157             : 
     158           0 :                 while(rRect.Top() < aNewPos.Y())
     159           0 :                     aNewPos.Y() -= nFreeSpaceY;
     160             :             }
     161             : 
     162             :             // did position change? Does it need to be set?
     163           0 :             if(aNewPos != aVisArea.TopLeft())
     164             :             {
     165           0 :                 aVisArea.SetPos(aNewPos);
     166           0 :                 SetZoomRect(aVisArea);
     167             :             }
     168             :         }
     169             :     }
     170           0 : }
     171             : 
     172          33 : }
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10