LCOV - code coverage report
Current view: top level - sd/source/ui/view - viewoverlaymanager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 50 224 22.3 %
Date: 2012-08-25 Functions: 12 37 32.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 49 400 12.2 %

           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 2008 by Sun Microsystems, Inc.
       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 "sddll.hxx"
      31                 :            : 
      32                 :            : #include <com/sun/star/frame/XFrame.hpp>
      33                 :            : #include <sfx2/imagemgr.hxx>
      34                 :            : #include <sfx2/viewfrm.hxx>
      35                 :            : #include <sfx2/bindings.hxx>
      36                 :            : #include <sfx2/app.hxx>
      37                 :            : #include <sfx2/request.hxx>
      38                 :            : #include <sfx2/dispatch.hxx>
      39                 :            : 
      40                 :            : #include <tools/rcid.h>
      41                 :            : 
      42                 :            : #include <vcl/help.hxx>
      43                 :            : #include <vcl/lazydelete.hxx>
      44                 :            : 
      45                 :            : #include <svx/sdrpagewindow.hxx>
      46                 :            : #include <svx/sdrpaintwindow.hxx>
      47                 :            : #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
      48                 :            : #include <svx/sdr/overlay/overlaybitmapex.hxx>
      49                 :            : #include <svx/sdr/overlay/overlaymanager.hxx>
      50                 :            : #include <svx/svxids.hrc>
      51                 :            : 
      52                 :            : #include "view/viewoverlaymanager.hxx"
      53                 :            : 
      54                 :            : #include "res_bmp.hrc"
      55                 :            : #include "DrawDocShell.hxx"
      56                 :            : #include "DrawViewShell.hxx"
      57                 :            : #include "DrawController.hxx"
      58                 :            : #include "glob.hrc"
      59                 :            : #include "strings.hrc"
      60                 :            : #include "sdresid.hxx"
      61                 :            : #include "EventMultiplexer.hxx"
      62                 :            : #include "ViewShellManager.hxx"
      63                 :            : #include "helpids.h"
      64                 :            : #include "sdpage.hxx"
      65                 :            : #include "drawdoc.hxx"
      66                 :            : #include "smarttag.hxx"
      67                 :            : 
      68                 :            : using ::rtl::OUString;
      69                 :            : using namespace ::com::sun::star::uno;
      70                 :            : using namespace ::com::sun::star::frame;
      71                 :            : 
      72                 :            : namespace sd {
      73                 :            : 
      74                 :            : class ImageButtonHdl;
      75                 :            : 
      76                 :            : // --------------------------------------------------------------------
      77                 :            : 
      78                 :            : static sal_uInt16 gButtonSlots[] = { SID_INSERT_TABLE, SID_INSERT_DIAGRAM, SID_INSERT_GRAPHIC, SID_INSERT_AVMEDIA };
      79                 :            : static sal_uInt16 gButtonToolTips[] = { STR_INSERT_TABLE, STR_INSERT_CHART, STR_INSERT_PICTURE, STR_INSERT_MOVIE };
      80                 :            : 
      81                 :            : // --------------------------------------------------------------------
      82                 :            : 
      83                 :          0 : static BitmapEx loadImageResource( sal_uInt16 nId )
      84                 :            : {
      85         [ #  # ]:          0 :     SdResId aResId( nId );
      86                 :          0 :     aResId.SetRT( RSC_BITMAP );
      87                 :            : 
      88         [ #  # ]:          0 :     return BitmapEx( aResId );
      89                 :            : }
      90                 :            : 
      91                 :            : // --------------------------------------------------------------------
      92                 :            : 
      93                 :          0 : static BitmapEx* getButtonImage( int index, bool large )
      94                 :            : {
      95 [ #  # ][ #  # ]:          0 :     static vcl::DeleteOnDeinit< BitmapEx > gSmallButtonImages[BMP_PLACEHOLDER_SMALL_END - BMP_PLACEHOLDER_SMALL_START] = { 0, 0, 0, 0, 0, 0, 0, 0 };
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
           #  # ][ #  # ]
      96 [ #  # ][ #  # ]:          0 :     static vcl::DeleteOnDeinit< BitmapEx > gLargeButtonImages[BMP_PLACEHOLDER_LARGE_END - BMP_PLACEHOLDER_LARGE_START] = { 0, 0, 0, 0, 0, 0, 0, 0 };
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
           #  # ][ #  # ]
      97                 :            : 
      98         [ #  # ]:          0 :     if( !gSmallButtonImages[0].get() )
      99                 :            :     {
     100         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < (BMP_PLACEHOLDER_SMALL_END-BMP_PLACEHOLDER_SMALL_START); i++ )
     101                 :            :         {
     102         [ #  # ]:          0 :             gSmallButtonImages[i].set( new BitmapEx( loadImageResource( BMP_PLACEHOLDER_SMALL_START + i ) ) );
     103         [ #  # ]:          0 :             gLargeButtonImages[i].set( new BitmapEx( loadImageResource( BMP_PLACEHOLDER_LARGE_START + i ) ) );
     104                 :            :         }
     105                 :            :     }
     106                 :            : 
     107         [ #  # ]:          0 :     if( large )
     108                 :            :     {
     109                 :          0 :         return gLargeButtonImages[index].get();
     110                 :            :     }
     111                 :            :     else
     112                 :            :     {
     113                 :          0 :         return gSmallButtonImages[index].get();
     114                 :            :     }
     115                 :            : }
     116                 :            : 
     117                 :            : // --------------------------------------------------------------------
     118                 :            : 
     119                 :            : const sal_uInt32 SMART_TAG_HDL_NUM = SAL_MAX_UINT32;
     120                 :            : 
     121                 :            : class ChangePlaceholderTag : public SmartTag
     122                 :            : {
     123                 :            :     friend class ImageButtonHdl;
     124                 :            : public:
     125                 :            :     ChangePlaceholderTag( ViewOverlayManager& rManager, ::sd::View& rView, SdrObject& rPlaceholderObj );
     126                 :            :     virtual ~ChangePlaceholderTag();
     127                 :            : 
     128                 :            :     /** returns true if the SmartTag handled the event. */
     129                 :            :     virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& );
     130                 :            : 
     131                 :            :     /** returns true if the SmartTag consumes this event. */
     132                 :            :     virtual bool KeyInput( const KeyEvent& rKEvt );
     133                 :            : 
     134                 :            :     BitmapEx createOverlayImage( int nHighlight = -1 );
     135                 :            : 
     136                 :            : protected:
     137                 :            :     virtual void addCustomHandles( SdrHdlList& rHandlerList );
     138                 :            :     virtual void disposing();
     139                 :            :     virtual void select();
     140                 :            :     virtual void deselect();
     141                 :            : 
     142                 :            : private:
     143                 :            :     ViewOverlayManager& mrManager;
     144                 :            :     SdrObjectWeakRef    mxPlaceholderObj;
     145                 :            : };
     146                 :            : 
     147                 :            : class ImageButtonHdl : public SmartHdl
     148                 :            : {
     149                 :            : public:
     150                 :            :     ImageButtonHdl( const SmartTagReference& xTag, /* sal_uInt16 nSID, const Image& rImage, const Image& rImageMO, */ const Point& rPnt );
     151                 :            :     virtual ~ImageButtonHdl();
     152                 :            :     virtual void CreateB2dIAObject();
     153                 :            :     virtual sal_Bool IsFocusHdl() const;
     154                 :            :     virtual Pointer GetPointer() const;
     155                 :            :     virtual bool isMarkable() const;
     156                 :            : 
     157                 :            :     virtual void onMouseEnter(const MouseEvent& rMEvt);
     158                 :            :     virtual void onMouseLeave();
     159                 :            : 
     160                 :          0 :     int getHighlightId() const { return mnHighlightId; }
     161                 :            : 
     162                 :            :     void HideTip();
     163                 :            : 
     164                 :            : private:
     165                 :            :     rtl::Reference< ChangePlaceholderTag > mxTag;
     166                 :            : 
     167                 :            :     int mnHighlightId;
     168                 :            :     Size maImageSize;
     169                 :            :     sal_uLong mnTip;
     170                 :            : };
     171                 :            : 
     172                 :            : // --------------------------------------------------------------------
     173                 :            : 
     174                 :          0 : ImageButtonHdl::ImageButtonHdl( const SmartTagReference& xTag /*, sal_uInt16 nSID, const Image& rImage, const Image& rImageMO*/, const Point& rPnt )
     175                 :            : : SmartHdl( xTag, rPnt )
     176                 :          0 : , mxTag( dynamic_cast< ChangePlaceholderTag* >( xTag.get() ) )
     177                 :            : , mnHighlightId( -1 )
     178                 :            : , maImageSize( 42, 42 )
     179 [ #  # ][ #  # ]:          0 : , mnTip( 0 )
     180                 :            : {
     181                 :          0 : }
     182                 :            : 
     183                 :            : // --------------------------------------------------------------------
     184                 :            : 
     185         [ #  # ]:          0 : ImageButtonHdl::~ImageButtonHdl()
     186                 :            : {
     187         [ #  # ]:          0 :     HideTip();
     188         [ #  # ]:          0 : }
     189                 :            : 
     190                 :            : // --------------------------------------------------------------------
     191                 :            : 
     192                 :          0 : void ImageButtonHdl::HideTip()
     193                 :            : {
     194         [ #  # ]:          0 :     if( mnTip )
     195                 :            :     {
     196                 :          0 :         Help::HideTip( mnTip );
     197                 :          0 :         mnTip = 0;
     198                 :            :     }
     199                 :          0 : }
     200                 :            : 
     201                 :            : // --------------------------------------------------------------------
     202                 :            : 
     203                 :            : extern ::rtl::OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const OUString& aCmdURL );
     204                 :            : 
     205                 :          0 : void ImageButtonHdl::onMouseEnter(const MouseEvent& rMEvt)
     206                 :            : {
     207                 :            : 
     208 [ #  # ][ #  # ]:          0 :     if( pHdlList && pHdlList->GetView())
                 [ #  # ]
     209                 :            :     {
     210                 :          0 :         int nHighlightId = 0;
     211 [ #  # ][ #  # ]:          0 :         OutputDevice* pDev = pHdlList->GetView()->GetFirstOutputDevice();
     212         [ #  # ]:          0 :         if( pDev == 0 )
     213         [ #  # ]:          0 :             pDev = Application::GetDefaultDevice();
     214                 :            : 
     215                 :          0 :         Point aMDPos( rMEvt.GetPosPixel() );
     216         [ #  # ]:          0 :         aMDPos -= pDev->LogicToPixel( GetPos() );
     217                 :            : 
     218         [ #  # ]:          0 :         nHighlightId += aMDPos.X() > maImageSize.Width() ? 1 : 0;
     219         [ #  # ]:          0 :         nHighlightId += aMDPos.Y() > maImageSize.Height() ? 2 : 0;
     220                 :            : 
     221         [ #  # ]:          0 :         if( mnHighlightId != nHighlightId )
     222                 :            :         {
     223         [ #  # ]:          0 :             HideTip();
     224                 :            : 
     225                 :          0 :             mnHighlightId = nHighlightId;
     226                 :            : 
     227         [ #  # ]:          0 :             if( pHdlList )
     228                 :            :             {
     229         [ #  # ]:          0 :                 SdResId aResId( gButtonToolTips[mnHighlightId] );
     230                 :          0 :                 aResId.SetRT( RSC_STRING );
     231                 :            : 
     232         [ #  # ]:          0 :                 String aHelpText( aResId );
     233 [ #  # ][ #  # ]:          0 :                 Rectangle aScreenRect( pDev->LogicToPixel( GetPos() ), maImageSize );
     234 [ #  # ][ #  # ]:          0 :                 mnTip = Help::ShowTip( static_cast< ::Window* >( pHdlList->GetView()->GetFirstOutputDevice() ), aScreenRect, aHelpText, 0 ) ;
         [ #  # ][ #  # ]
     235                 :            :             }
     236         [ #  # ]:          0 :             Touch();
     237                 :            :         }
     238                 :            :     }
     239                 :          0 : }
     240                 :            : 
     241                 :            : // --------------------------------------------------------------------
     242                 :            : 
     243                 :          0 : void ImageButtonHdl::onMouseLeave()
     244                 :            : {
     245                 :          0 :     mnHighlightId = -1;
     246                 :          0 :     HideTip();
     247                 :          0 :     Touch();
     248                 :          0 : }
     249                 :            : 
     250                 :            : // --------------------------------------------------------------------
     251                 :            : 
     252                 :          0 : void ImageButtonHdl::CreateB2dIAObject()
     253                 :            : {
     254                 :            :     // first throw away old one
     255         [ #  # ]:          0 :     GetRidOfIAObject();
     256                 :            : 
     257                 :          0 :     const Point aTagPos( GetPos() );
     258                 :          0 :     basegfx::B2DPoint aPosition( aTagPos.X(), aTagPos.Y() );
     259                 :            : 
     260         [ #  # ]:          0 :     BitmapEx aBitmapEx( mxTag->createOverlayImage( mnHighlightId ) ); // maImageMO.GetBitmapEx() : maImage.GetBitmapEx() );
     261                 :          0 :     maImageSize = aBitmapEx.GetSizePixel();
     262                 :          0 :     maImageSize.Width() >>= 1;
     263                 :          0 :     maImageSize.Height() >>= 1;
     264                 :            : 
     265         [ #  # ]:          0 :     if(pHdlList)
     266                 :            :     {
     267         [ #  # ]:          0 :         SdrMarkView* pView = pHdlList->GetView();
     268                 :            : 
     269 [ #  # ][ #  # ]:          0 :         if(pView && !pView->areMarkHandlesHidden())
                 [ #  # ]
     270                 :            :         {
     271                 :          0 :             SdrPageView* pPageView = pView->GetSdrPageView();
     272                 :            : 
     273         [ #  # ]:          0 :             if(pPageView)
     274                 :            :             {
     275         [ #  # ]:          0 :                 for(sal_uInt32 b = 0; b < pPageView->PageWindowCount(); b++)
     276                 :            :                 {
     277         [ #  # ]:          0 :                     const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
     278                 :            : 
     279                 :          0 :                     SdrPaintWindow& rPaintWindow = rPageWindow.GetPaintWindow();
     280         [ #  # ]:          0 :                     rtl::Reference< ::sdr::overlay::OverlayManager > xManager = rPageWindow.GetOverlayManager();
     281 [ #  # ][ #  # ]:          0 :                     if(rPaintWindow.OutputToWindow() && xManager.is() )
                 [ #  # ]
     282                 :            :                     {
     283                 :          0 :                         ::sdr::overlay::OverlayObject* pOverlayObject = 0;
     284                 :            : 
     285 [ #  # ][ #  # ]:          0 :                         pOverlayObject = new ::sdr::overlay::OverlayBitmapEx( aPosition, aBitmapEx, 0, 0 );
     286         [ #  # ]:          0 :                         xManager->add(*pOverlayObject);
     287         [ #  # ]:          0 :                         maOverlayGroup.append(*pOverlayObject);
     288                 :            :                     }
     289         [ #  # ]:          0 :                 }
     290                 :            :             }
     291                 :            :         }
     292         [ #  # ]:          0 :     }
     293                 :          0 : }
     294                 :            : 
     295                 :            : // --------------------------------------------------------------------
     296                 :            : 
     297                 :          0 : sal_Bool ImageButtonHdl::IsFocusHdl() const
     298                 :            : {
     299                 :          0 :     return false;
     300                 :            : }
     301                 :            : 
     302                 :            : // --------------------------------------------------------------------
     303                 :            : 
     304                 :          0 : bool ImageButtonHdl::isMarkable() const
     305                 :            : {
     306                 :          0 :     return false;
     307                 :            : }
     308                 :            : 
     309                 :            : // --------------------------------------------------------------------
     310                 :            : 
     311                 :          0 : Pointer ImageButtonHdl::GetPointer() const
     312                 :            : {
     313                 :          0 :     return Pointer( POINTER_ARROW );
     314                 :            : }
     315                 :            : 
     316                 :            : // ====================================================================
     317                 :            : 
     318                 :          0 : ChangePlaceholderTag::ChangePlaceholderTag( ViewOverlayManager& rManager, ::sd::View& rView, SdrObject& rPlaceholderObj )
     319                 :            : : SmartTag( rView )
     320                 :            : , mrManager( rManager )
     321         [ #  # ]:          0 : , mxPlaceholderObj( &rPlaceholderObj )
     322                 :            : {
     323                 :          0 : }
     324                 :            : 
     325                 :            : // --------------------------------------------------------------------
     326                 :            : 
     327         [ #  # ]:          0 : ChangePlaceholderTag::~ChangePlaceholderTag()
     328                 :            : {
     329         [ #  # ]:          0 : }
     330                 :            : 
     331                 :            : // --------------------------------------------------------------------
     332                 :            : 
     333                 :            : /** returns true if the ChangePlaceholderTag handled the event. */
     334                 :          0 : bool ChangePlaceholderTag::MouseButtonDown( const MouseEvent& /*rMEvt*/, SmartHdl& rHdl )
     335                 :            : {
     336                 :          0 :     int nHighlightId = static_cast< ImageButtonHdl& >(rHdl).getHighlightId();
     337         [ #  # ]:          0 :     if( nHighlightId >= 0 )
     338                 :            :     {
     339                 :          0 :         sal_uInt16 nSID = gButtonSlots[nHighlightId];
     340                 :            : 
     341         [ #  # ]:          0 :         if( mxPlaceholderObj.get() )
     342                 :            :         {
     343                 :            :             // mark placeholder if it is not currently marked (or if also others are marked)
     344 [ #  # ][ #  # ]:          0 :             if( !mrView.IsObjMarked( mxPlaceholderObj.get() ) || (mrView.GetMarkedObjectList().GetMarkCount() != 1) )
                 [ #  # ]
     345                 :            :             {
     346                 :          0 :                 SdrPageView* pPV = mrView.GetSdrPageView();
     347                 :          0 :                 mrView.UnmarkAllObj(pPV );
     348                 :          0 :                 mrView.MarkObj(mxPlaceholderObj.get(), pPV, sal_False);
     349                 :            :             }
     350                 :            :         }
     351                 :            : 
     352                 :          0 :         mrView.GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSID, SFX_CALLMODE_ASYNCHRON);
     353                 :            :     }
     354                 :          0 :     return false;
     355                 :            : }
     356                 :            : 
     357                 :            : // --------------------------------------------------------------------
     358                 :            : 
     359                 :            : /** returns true if the SmartTag consumes this event. */
     360                 :          0 : bool ChangePlaceholderTag::KeyInput( const KeyEvent& rKEvt )
     361                 :            : {
     362                 :          0 :     sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
     363                 :          0 :     switch( nCode )
     364                 :            :     {
     365                 :            :     case KEY_DOWN:
     366                 :            :     case KEY_UP:
     367                 :            :     case KEY_LEFT:
     368                 :            :     case KEY_RIGHT:
     369                 :            :     case KEY_ESCAPE:
     370                 :            :     case KEY_TAB:
     371                 :            :     case KEY_RETURN:
     372                 :            :        case KEY_SPACE:
     373                 :            :     default:
     374                 :          0 :         return false;
     375                 :            :     }
     376                 :            : }
     377                 :            : 
     378                 :            : // --------------------------------------------------------------------
     379                 :            : 
     380                 :          0 : BitmapEx ChangePlaceholderTag::createOverlayImage( int nHighlight )
     381                 :            : {
     382                 :          0 :     BitmapEx aRet;
     383         [ #  # ]:          0 :     if( mxPlaceholderObj.is() )
     384                 :            :     {
     385                 :          0 :         SdrObject* pPlaceholder = mxPlaceholderObj.get();
     386         [ #  # ]:          0 :         SmartTagReference xThis( this );
     387         [ #  # ]:          0 :         const Rectangle& rSnapRect = pPlaceholder->GetSnapRect();
     388                 :          0 :         const Point aPoint;
     389                 :            : 
     390         [ #  # ]:          0 :         OutputDevice* pDev = mrView.GetFirstOutputDevice();
     391         [ #  # ]:          0 :         if( pDev == 0 )
     392         [ #  # ]:          0 :             pDev = Application::GetDefaultDevice();
     393                 :            : 
     394 [ #  # ][ #  # ]:          0 :         Size aShapeSizePix = pDev->LogicToPixel(rSnapRect.GetSize());
     395         [ #  # ]:          0 :         long nShapeSizePix = std::min(aShapeSizePix.Width(),aShapeSizePix.Height());
     396                 :            : 
     397                 :          0 :         bool bLarge = nShapeSizePix > 250;
     398                 :            : 
     399         [ #  # ]:          0 :         Size aSize( getButtonImage( 0, bLarge )->GetSizePixel() );
     400                 :            : 
     401         [ #  # ]:          0 :         aRet.SetSizePixel( Size( aSize.Width() << 1, aSize.Height() << 1 ) );
     402                 :            : 
     403         [ #  # ]:          0 :         const Rectangle aRectSrc( Point( 0, 0 ), aSize );
     404                 :            : 
     405 [ #  # ][ #  # ]:          0 :         aRet = *(getButtonImage((nHighlight == 0) ? 4 : 0, bLarge));
                 [ #  # ]
     406         [ #  # ]:          0 :         aRet.Expand( aSize.Width(), aSize.Height(), NULL, sal_True );
     407                 :            : 
     408 [ #  # ][ #  # ]:          0 :         aRet.CopyPixel( Rectangle( Point( aSize.Width(), 0              ), aSize ), aRectSrc, getButtonImage((nHighlight == 1) ? 5 : 1, bLarge) );
         [ #  # ][ #  # ]
     409 [ #  # ][ #  # ]:          0 :         aRet.CopyPixel( Rectangle( Point( 0,             aSize.Height() ), aSize ), aRectSrc, getButtonImage((nHighlight == 2) ? 6 : 2, bLarge) );
         [ #  # ][ #  # ]
     410 [ #  # ][ #  # ]:          0 :         aRet.CopyPixel( Rectangle( Point( aSize.Width(), aSize.Height() ), aSize ), aRectSrc, getButtonImage((nHighlight == 3) ? 7 : 3, bLarge) );
         [ #  # ][ #  # ]
                 [ #  # ]
     411                 :            :     }
     412                 :            : 
     413                 :          0 :     return aRet;
     414                 :            : }
     415                 :            : 
     416                 :          0 : void ChangePlaceholderTag::addCustomHandles( SdrHdlList& rHandlerList )
     417                 :            : {
     418         [ #  # ]:          0 :     if( mxPlaceholderObj.is() )
     419                 :            :     {
     420                 :          0 :         SdrObject* pPlaceholder = mxPlaceholderObj.get();
     421         [ #  # ]:          0 :         SmartTagReference xThis( this );
     422         [ #  # ]:          0 :         const Rectangle& rSnapRect = pPlaceholder->GetSnapRect();
     423                 :          0 :         const Point aPoint;
     424                 :            : 
     425         [ #  # ]:          0 :         OutputDevice* pDev = mrView.GetFirstOutputDevice();
     426         [ #  # ]:          0 :         if( pDev == 0 )
     427         [ #  # ]:          0 :             pDev = Application::GetDefaultDevice();
     428                 :            : 
     429 [ #  # ][ #  # ]:          0 :         Size aShapeSizePix = pDev->LogicToPixel(rSnapRect.GetSize());
     430         [ #  # ]:          0 :         long nShapeSizePix = std::min(aShapeSizePix.Width(),aShapeSizePix.Height());
     431         [ #  # ]:          0 :         if( 50 > nShapeSizePix )
     432                 :          0 :             return;
     433                 :            : 
     434                 :          0 :         bool bLarge = nShapeSizePix > 250;
     435                 :            : 
     436 [ #  # ][ #  # ]:          0 :         Size aButtonSize( pDev->PixelToLogic( getButtonImage(0, bLarge )->GetSizePixel()) );
     437                 :            : 
     438                 :          0 :         const int nColumns = 2;
     439                 :          0 :         const int nRows = 2;
     440                 :            : 
     441                 :          0 :         long all_width = nColumns * aButtonSize.Width();
     442                 :          0 :         long all_height = nRows * aButtonSize.Height();
     443                 :            : 
     444         [ #  # ]:          0 :         Point aPos( rSnapRect.Center() );
     445                 :          0 :         aPos.X() -= all_width >> 1;
     446                 :          0 :         aPos.Y() -= all_height >> 1;
     447                 :            : 
     448 [ #  # ][ #  # ]:          0 :         ImageButtonHdl* pHdl = new ImageButtonHdl( xThis, aPoint );
     449                 :          0 :         pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
     450                 :          0 :         pHdl->SetPageView( mrView.GetSdrPageView() );
     451                 :            : 
     452         [ #  # ]:          0 :         pHdl->SetPos( aPos );
     453                 :            : 
     454 [ #  # ][ #  # ]:          0 :         rHandlerList.AddHdl( pHdl );
                 [ #  # ]
     455                 :            :     }
     456                 :            : }
     457                 :            : 
     458                 :            : // --------------------------------------------------------------------
     459                 :            : 
     460                 :          0 : void ChangePlaceholderTag::disposing()
     461                 :            : {
     462                 :          0 :     SmartTag::disposing();
     463                 :          0 : }
     464                 :            : 
     465                 :            : // --------------------------------------------------------------------
     466                 :            : 
     467                 :          0 : void ChangePlaceholderTag::select()
     468                 :            : {
     469                 :          0 :     SmartTag::select();
     470                 :          0 : }
     471                 :            : 
     472                 :            : // --------------------------------------------------------------------
     473                 :            : 
     474                 :          0 : void ChangePlaceholderTag::deselect()
     475                 :            : {
     476                 :          0 :     SmartTag::deselect();
     477                 :          0 : }
     478                 :            : 
     479                 :            : // --------------------------------------------------------------------
     480                 :            : 
     481                 :        130 : ViewOverlayManager::ViewOverlayManager( ViewShellBase& rViewShellBase )
     482                 :            : : mrBase( rViewShellBase )
     483         [ +  - ]:        130 : , mnUpdateTagsEvent( 0 )
     484                 :            : {
     485         [ +  - ]:        130 :     Link aLink( LINK(this,ViewOverlayManager,EventMultiplexerListener) );
     486                 :            :     mrBase.GetEventMultiplexer()->AddEventListener(aLink, tools::EventMultiplexerEvent::EID_CURRENT_PAGE
     487                 :            :         | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
     488                 :            :         | tools::EventMultiplexerEvent::EID_VIEW_ADDED
     489                 :            :         | tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT
     490 [ +  - ][ +  - ]:        130 :         | tools::EventMultiplexerEvent::EID_END_TEXT_EDIT );
                 [ +  - ]
     491                 :            : 
     492 [ +  - ][ +  - ]:        130 :     StartListening( *mrBase.GetDocShell() );
     493                 :        130 : }
     494                 :            : 
     495                 :            : // --------------------------------------------------------------------
     496                 :            : 
     497                 :        130 : ViewOverlayManager::~ViewOverlayManager()
     498                 :            : {
     499         [ +  - ]:        130 :     Link aLink( LINK(this,ViewOverlayManager,EventMultiplexerListener) );
     500 [ +  - ][ +  - ]:        130 :     mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
                 [ +  - ]
     501                 :            : 
     502         [ +  + ]:        130 :     if( mnUpdateTagsEvent )
     503                 :            :     {
     504         [ +  - ]:         40 :         Application::RemoveUserEvent( mnUpdateTagsEvent );
     505                 :         40 :         mnUpdateTagsEvent = 0;
     506                 :            :     }
     507                 :            : 
     508         [ +  - ]:        130 :     DisposeTags();
     509         [ -  + ]:        260 : }
     510                 :            : 
     511                 :            : // --------------------------------------------------------------------
     512                 :            : 
     513                 :       7096 : void ViewOverlayManager::Notify(SfxBroadcaster&, const SfxHint& rHint)
     514                 :            : {
     515         [ -  + ]:       7096 :     const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
     516         [ +  + ]:       7096 :     if (pSimpleHint != NULL)
     517                 :            :     {
     518         [ +  + ]:       6162 :         if (pSimpleHint->GetId() == SFX_HINT_DOCCHANGED)
     519                 :            :         {
     520                 :       5484 :             UpdateTags();
     521                 :            :         }
     522                 :            :     }
     523                 :       7096 : }
     524                 :            : 
     525                 :        447 : void ViewOverlayManager::onZoomChanged()
     526                 :            : {
     527         [ -  + ]:        447 :     if( !maTagVector.empty() )
     528                 :            :     {
     529                 :          0 :         UpdateTags();
     530                 :            :     }
     531                 :        447 : }
     532                 :            : 
     533                 :       5929 : void ViewOverlayManager::UpdateTags()
     534                 :            : {
     535         [ +  + ]:       5929 :     if( !mnUpdateTagsEvent )
     536         [ +  - ]:        586 :         mnUpdateTagsEvent = Application::PostUserEvent( LINK( this, ViewOverlayManager, UpdateTagsHdl ) );
     537                 :       5929 : }
     538                 :            : 
     539                 :        546 : IMPL_LINK_NOARG(ViewOverlayManager, UpdateTagsHdl)
     540                 :            : {
     541                 :            :     OSL_TRACE("ViewOverlayManager::UpdateTagsHdl");
     542                 :            : 
     543                 :        546 :     mnUpdateTagsEvent  = 0;
     544                 :        546 :     bool bChanges = DisposeTags();
     545                 :        546 :     bChanges |= CreateTags();
     546                 :            : 
     547 [ #  # ][ -  + ]:        546 :     if( bChanges && mrBase.GetDrawView() )
                 [ -  + ]
     548                 :          0 :         static_cast< ::sd::View* >( mrBase.GetDrawView() )->updateHandles();
     549                 :        546 :     return 0;
     550                 :            : }
     551                 :            : 
     552                 :        546 : bool ViewOverlayManager::CreateTags()
     553                 :            : {
     554                 :        546 :     bool bChanges = false;
     555                 :            : 
     556         [ +  - ]:        546 :     ::boost::shared_ptr<ViewShell> aMainShell = mrBase.GetMainViewShell();
     557                 :            : 
     558 [ +  - ][ +  - ]:        546 :     SdPage* pPage = aMainShell.get() ? aMainShell->getCurrentPage() : NULL;
     559                 :            : 
     560 [ +  - ][ +  - ]:        546 :     if( pPage && !pPage->IsMasterPage() && (pPage->GetPageKind() == PK_STANDARD) )
         [ +  - ][ +  - ]
     561                 :            :     {
     562                 :        546 :         const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();
     563                 :            : 
     564 [ +  - ][ +  - ]:        656 :         for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter )
                 [ +  + ]
     565                 :            :         {
     566 [ +  - ][ +  - ]:        110 :             if( (*iter)->IsEmptyPresObj() && ((*iter)->GetObjIdentifier() == OBJ_OUTLINETEXT) && (mrBase.GetDrawView()->GetTextEditObject() != (*iter)) )
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ -  + ]
     567                 :            :             {
     568 [ #  # ][ #  # ]:          0 :                 rtl::Reference< SmartTag > xTag( new ChangePlaceholderTag( *this, *mrBase.GetMainViewShell()->GetView(), *(*iter) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     569         [ #  # ]:          0 :                 maTagVector.push_back(xTag);
     570         [ #  # ]:          0 :                 bChanges = true;
     571                 :            :             }
     572                 :            :         }
     573                 :            :     }
     574                 :            : 
     575         [ +  - ]:        546 :     return bChanges;
     576                 :            : }
     577                 :            : 
     578                 :            : // --------------------------------------------------------------------
     579                 :            : 
     580                 :        676 : bool ViewOverlayManager::DisposeTags()
     581                 :            : {
     582         [ -  + ]:        676 :     if( !maTagVector.empty() )
     583                 :            :     {
     584         [ #  # ]:          0 :         ViewTagVector vec;
     585                 :          0 :         vec.swap( maTagVector );
     586                 :            : 
     587                 :          0 :         ViewTagVector::iterator iter = vec.begin();
     588 [ #  # ][ #  # ]:          0 :         do
     589                 :            :         {
     590 [ #  # ][ #  # ]:          0 :             (*iter++)->Dispose();
     591                 :            :         }
     592                 :          0 :         while( iter != vec.end() );
     593                 :          0 :         return true;
     594                 :            :     }
     595                 :            : 
     596                 :        676 :     return false;
     597                 :            : }
     598                 :            : 
     599                 :            : // --------------------------------------------------------------------
     600                 :            : 
     601                 :       4683 : IMPL_LINK(ViewOverlayManager,EventMultiplexerListener,
     602                 :            :     tools::EventMultiplexerEvent*,pEvent)
     603                 :            : {
     604         [ +  + ]:       4683 :     switch (pEvent->meEventId)
     605                 :            :     {
     606                 :            :         case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
     607                 :            :         case tools::EventMultiplexerEvent::EID_VIEW_ADDED:
     608                 :            :         case tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT:
     609                 :            :         case tools::EventMultiplexerEvent::EID_END_TEXT_EDIT:
     610                 :            :         case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
     611                 :        445 :             UpdateTags();
     612                 :        445 :             break;
     613                 :            :     }
     614                 :       4683 :     return 0;
     615                 :            : }
     616                 :            : 
     617                 :            : }
     618                 :            : 
     619                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10