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

Generated by: LCOV version 1.10