LCOV - code coverage report
Current view: top level - sd/source/ui/view - drviews4.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 73 419 17.4 %
Date: 2015-06-13 12:38:46 Functions: 8 16 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             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      21             : 
      22             : #include "DrawViewShell.hxx"
      23             : #include <vcl/msgbox.hxx>
      24             : #include <svl/urlbmk.hxx>
      25             : #include <svx/svdpagv.hxx>
      26             : #include <svx/svdundo.hxx>
      27             : #include <svx/fmglob.hxx>
      28             : #include <editeng/eeitem.hxx>
      29             : #include <editeng/flditem.hxx>
      30             : #include <svx/svxids.hrc>
      31             : #include <svx/ruler.hxx>
      32             : #include <svx/globl3d.hxx>
      33             : #include <editeng/outliner.hxx>
      34             : #include <sfx2/ipclient.hxx>
      35             : #include <sfx2/request.hxx>
      36             : #include <sfx2/dispatch.hxx>
      37             : #include <svx/svdopath.hxx>
      38             : #include <sfx2/viewfrm.hxx>
      39             : #include <editeng/editview.hxx>
      40             : #include <vcl/cursor.hxx>
      41             : 
      42             : #include "app.hrc"
      43             : #include "glob.hrc"
      44             : #include "strings.hrc"
      45             : #include "res_bmp.hrc"
      46             : #include "DrawDocShell.hxx"
      47             : #include "drawdoc.hxx"
      48             : #include "Window.hxx"
      49             : #include "fupoor.hxx"
      50             : #include "fusnapln.hxx"
      51             : #include "sdmod.hxx"
      52             : #include "Ruler.hxx"
      53             : #include "sdresid.hxx"
      54             : #include "GraphicViewShell.hxx"
      55             : #include "sdpage.hxx"
      56             : #include "slideshow.hxx"
      57             : #include "anminfo.hxx"
      58             : #include "sdpopup.hxx"
      59             : #include "drawview.hxx"
      60             : #include <svx/bmpmask.hxx>
      61             : #include "LayerTabBar.hxx"
      62             : 
      63             : #include <svx/svditer.hxx>
      64             : 
      65             : #include <navigatr.hxx>
      66             : #include <boost/scoped_ptr.hpp>
      67             : 
      68             : namespace sd {
      69             : 
      70             : #define PIPETTE_RANGE 0
      71             : 
      72             : using namespace ::com::sun::star::uno;
      73             : using namespace ::com::sun::star::drawing;
      74             : 
      75           0 : void DrawViewShell::DeleteActualPage()
      76             : {
      77           0 :     sal_uInt16          nPage = maTabControl->GetCurPageId() - 1;
      78             : 
      79           0 :     mpDrawView->SdrEndTextEdit();
      80             : 
      81             :     try
      82             :     {
      83           0 :         Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW );
      84           0 :         Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
      85           0 :         Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
      86           0 :         xPages->remove( xPage );
      87             :     }
      88           0 :     catch( Exception& )
      89             :     {
      90             :         OSL_FAIL("SelectionManager::DeleteSelectedMasterPages(), exception caught!");
      91             :     }
      92           0 : }
      93             : 
      94           0 : void DrawViewShell::DeleteActualLayer()
      95             : {
      96           0 :     if(!GetLayerTabControl()) // #i87182#
      97             :     {
      98             :         OSL_ENSURE(false, "No LayerTabBar (!)");
      99           0 :         return;
     100             :     }
     101             : 
     102           0 :     SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin();
     103           0 :     const OUString& rName = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId());
     104           0 :     OUString aString(SD_RESSTR(STR_ASK_DELETE_LAYER));
     105             : 
     106             :     // replace placeholder
     107           0 :     aString = aString.replaceFirst("$", rName);
     108             : 
     109           0 :     if (ScopedVclPtr<QueryBox>::Create(GetActiveWindow(), WB_YES_NO, aString)->Execute() == RET_YES)
     110             :     {
     111           0 :         const SdrLayer* pLayer = rAdmin.GetLayer(rName, false);
     112           0 :         mpDrawView->DeleteLayer( pLayer->GetName() );
     113             : 
     114             :         /* in order to redraw TabBar and Window; should be initiated later on by
     115             :            a hint from Joe (as by a change if the layer order). */
     116             :         // ( View::Notify() --> ViewShell::ResetActualLayer() )
     117             : 
     118           0 :         mbIsLayerModeActive = false;    // so that ChangeEditMode() does something
     119           0 :         ChangeEditMode(GetEditMode(), true);
     120           0 :     }
     121             : }
     122             : 
     123           1 : bool DrawViewShell::KeyInput (const KeyEvent& rKEvt, ::sd::Window* pWin)
     124             : {
     125           1 :     bool bRet = false;
     126             : 
     127           1 :     if ( !IsInputLocked() || ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) )
     128             :     {
     129           2 :         if(KEY_RETURN == rKEvt.GetKeyCode().GetCode()
     130           0 :             && rKEvt.GetKeyCode().IsMod1()
     131           1 :             && GetView()->IsTextEdit())
     132             :         {
     133             :             // this should be used for cursor travelling.
     134           0 :             SdPage* pActualPage = GetActualPage();
     135           0 :             const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList();
     136           0 :             SdrTextObj* pCandidate = 0L;
     137             : 
     138           0 :             if(pActualPage && 1 == rMarkList.GetMarkCount())
     139             :             {
     140           0 :                 SdrMark* pMark = rMarkList.GetMark(0);
     141             : 
     142             :                 // remember which object was the text in edit mode
     143           0 :                 SdrObject* pOldObj = pMark->GetMarkedSdrObj();
     144             : 
     145             :                 // end text edit now
     146           0 :                 GetView()->SdrEndTextEdit();
     147             : 
     148             :                 // look for a new candidate, a successor of pOldObj
     149           0 :                 SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
     150           0 :                 bool bDidVisitOldObject(false);
     151             : 
     152           0 :                 while(aIter.IsMore() && !pCandidate)
     153             :                 {
     154           0 :                     SdrObject* pObj = aIter.Next();
     155             : 
     156           0 :                     if(pObj && pObj->ISA(SdrTextObj))
     157             :                     {
     158           0 :                         sal_uInt32 nInv(pObj->GetObjInventor());
     159           0 :                         sal_uInt16 nKnd(pObj->GetObjIdentifier());
     160             : 
     161           0 :                         if(SdrInventor == nInv &&
     162           0 :                             (OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd)
     163           0 :                             && bDidVisitOldObject)
     164             :                         {
     165           0 :                             pCandidate = static_cast<SdrTextObj*>(pObj);
     166             :                         }
     167             : 
     168           0 :                         if(pObj == pOldObj)
     169             :                         {
     170           0 :                             bDidVisitOldObject = true;
     171             :                         }
     172             :                     }
     173           0 :                 }
     174             :             }
     175             : 
     176           0 :             if(pCandidate)
     177             :             {
     178             :                 // set the new candidate to text edit mode
     179           0 :                 GetView()->UnMarkAll();
     180           0 :                 GetView()->MarkObj(pCandidate, GetView()->GetSdrPageView());
     181             : 
     182             :                 GetViewFrame()->GetDispatcher()->Execute(
     183           0 :                     SID_ATTR_CHAR, SfxCallMode::ASYNCHRON);
     184             :             }
     185             :             else
     186             :             {
     187             :                 // insert a new page with the same page layout
     188             :                 GetViewFrame()->GetDispatcher()->Execute(
     189           0 :                     SID_INSERTPAGE_QUICK, SfxCallMode::ASYNCHRON);
     190             :             }
     191             :         }
     192             :         else
     193             :         {
     194           1 :             bRet = ViewShell::KeyInput(rKEvt, pWin);
     195             :             //If object is marked , the corresponding entry is set true , else
     196             :             //the corresponding entry is set false .
     197           1 :             if(KEY_TAB == rKEvt.GetKeyCode().GetCode())
     198             :             {
     199           0 :                FreshNavigatrTree();
     200             :             }
     201             :         }
     202             :     }
     203             : 
     204           1 :     return bRet;
     205             : }
     206             : 
     207             : /**
     208             :  * Start with Drag from ruler (helper lines, origin)
     209             :  */
     210           0 : void DrawViewShell::StartRulerDrag (
     211             :     const Ruler& rRuler,
     212             :     const MouseEvent& rMEvt)
     213             : {
     214           0 :     GetActiveWindow()->CaptureMouse();
     215             : 
     216           0 :     Point aWPos = GetActiveWindow()->PixelToLogic(GetActiveWindow()->GetPointerPosPixel());
     217             : 
     218           0 :     if ( rRuler.GetExtraRect().IsInside(rMEvt.GetPosPixel()) )
     219             :     {
     220           0 :         mpDrawView->BegSetPageOrg(aWPos);
     221           0 :         mbIsRulerDrag = true;
     222             :     }
     223             :     else
     224             :     {
     225             :         // #i34536# if no guide-lines are visible yet, that show them
     226           0 :         if( ! mpDrawView->IsHlplVisible())
     227           0 :             mpDrawView->SetHlplVisible( true );
     228             : 
     229             :         SdrHelpLineKind eKind;
     230             : 
     231           0 :         if ( rMEvt.IsMod1() )
     232           0 :             eKind = SDRHELPLINE_POINT;
     233           0 :         else if ( rRuler.IsHorizontal() )
     234           0 :             eKind = SDRHELPLINE_HORIZONTAL;
     235             :         else
     236           0 :             eKind = SDRHELPLINE_VERTICAL;
     237             : 
     238           0 :         mpDrawView->BegDragHelpLine(aWPos, eKind);
     239           0 :         mbIsRulerDrag = true;
     240             :     }
     241           0 : }
     242             : 
     243             : //If object is marked , the corresponding entry is set true ,
     244             : //else the corresponding entry is set false .
     245           0 : void DrawViewShell::FreshNavigatrEntry()
     246             : {
     247           0 :     sal_uInt16 nId = SID_NAVIGATOR;
     248           0 :     SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
     249           0 :     if( pWindow )
     250             :     {
     251           0 :         SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
     252           0 :         if( pNavWin )
     253           0 :             pNavWin->FreshEntry();
     254             :     }
     255           0 : }
     256             : 
     257           4 : void DrawViewShell::FreshNavigatrTree()
     258             : {
     259           4 :     sal_uInt16 nId = SID_NAVIGATOR;
     260           4 :     SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
     261           4 :     if( pWindow )
     262             :     {
     263           0 :         SdNavigatorWin* pNavWin = static_cast<SdNavigatorWin*>( pWindow->GetContextWindow( SD_MOD() ) );
     264           0 :         if( pNavWin )
     265           0 :             pNavWin->FreshTree( GetDoc() );
     266             :     }
     267           4 : }
     268             : 
     269           2 : void DrawViewShell::MouseButtonDown(const MouseEvent& rMEvt,
     270             :     ::sd::Window* pWin)
     271             : {
     272             :     // We have to check if a context menu is shown and we have an UI
     273             :     // active inplace client. In that case we have to ignore the mouse
     274             :     // button down event. Otherwise we would crash (context menu has been
     275             :     // opened by inplace client and we would deactivate the inplace client,
     276             :     // the contex menu is closed by VCL asynchronously which in the end
     277             :     // would work on deleted objects or the context menu has no parent anymore)
     278           2 :     SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
     279           2 :     bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
     280             : 
     281           2 :     if ( bIsOleActive && PopupMenu::IsInExecute() )
     282           2 :         return;
     283             : 
     284           2 :     if ( !IsInputLocked() )
     285             :     {
     286           2 :         ViewShell::MouseButtonDown(rMEvt, pWin);
     287             : 
     288             :         //If object is marked , the corresponding entry is set true ,
     289             :         //else the corresponding entry is set false .
     290           2 :         FreshNavigatrTree();
     291           2 :         if (mbPipette)
     292             :         {
     293           0 :             SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId());
     294           0 :             SvxBmpMask* pBmpMask = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : NULL;
     295           0 :             if (pBmpMask)
     296           0 :                 pBmpMask->PipetteClicked();
     297             :         }
     298             :     }
     299             : }
     300             : 
     301           2 : void DrawViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
     302             : {
     303           2 :     if ( !IsInputLocked() )
     304             :     {
     305           2 :         if ( mpDrawView->IsAction() )
     306             :         {
     307           2 :             Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
     308             : 
     309           2 :             if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
     310             :             {
     311           2 :                 bool bInsideOtherWindow = false;
     312             : 
     313           2 :                 if (mpContentWindow.get() != NULL)
     314             :                 {
     315             :                     aOutputArea = Rectangle(Point(0,0),
     316           2 :                         mpContentWindow->GetOutputSizePixel());
     317             : 
     318           2 :                     Point aPos = mpContentWindow->GetPointerPosPixel();
     319           2 :                     if ( aOutputArea.IsInside(aPos) )
     320           0 :                         bInsideOtherWindow = true;
     321             :                 }
     322             : 
     323           2 :                 if (! GetActiveWindow()->HasFocus ())
     324             :                 {
     325           0 :                     GetActiveWindow()->ReleaseMouse ();
     326           0 :                     mpDrawView->BrkAction ();
     327           2 :                     return;
     328             :                 }
     329           2 :                 else if ( bInsideOtherWindow )
     330             :                 {
     331           0 :                     GetActiveWindow()->ReleaseMouse();
     332           0 :                     pWin->CaptureMouse ();
     333             :                 }
     334             :             }
     335           0 :             else if ( pWin != GetActiveWindow() )
     336           0 :                  pWin->CaptureMouse();
     337             :         }
     338             : 
     339             :         // Since the next MouseMove may execute a IsSolidDraggingNow() in
     340             :         // SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor
     341             :         // is needed it is necessary to set it here.
     342           2 :         if (GetDoc())
     343             :         {
     344           2 :             svtools::ColorConfig aColorConfig;
     345           2 :             Color aFillColor;
     346             : 
     347           2 :             aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor );
     348             : 
     349           2 :             mpDrawView->SetApplicationBackgroundColor(aFillColor);
     350             :         }
     351             : 
     352           2 :         ViewShell::MouseMove(rMEvt, pWin);
     353             : 
     354           2 :         if( !mbMousePosFreezed )
     355           2 :             maMousePos = rMEvt.GetPosPixel();
     356             : 
     357           2 :         Rectangle aRect;
     358             : 
     359           2 :         if ( mbIsRulerDrag )
     360             :         {
     361           0 :             Point aLogPos = GetActiveWindow()->PixelToLogic(maMousePos);
     362           0 :             mpDrawView->MovAction(aLogPos);
     363             :         }
     364             : 
     365           2 :         if ( mpDrawView->IsAction() )
     366             :         {
     367           2 :             mpDrawView->TakeActionRect(aRect);
     368           2 :             aRect = GetActiveWindow()->LogicToPixel(aRect);
     369             :         }
     370             :         else
     371             :         {
     372           0 :             aRect = Rectangle(maMousePos, maMousePos);
     373             :         }
     374             : 
     375           2 :         ShowMousePosInfo(aRect, pWin);
     376             : 
     377           2 :         SvxBmpMask* pBmpMask = NULL;
     378           2 :         if (mbPipette && GetViewFrame()->HasChildWindow(SvxBmpMaskChildWindow::GetChildWindowId()))
     379             :         {
     380           0 :             SfxChildWindow* pWnd = GetViewFrame()->GetChildWindow(SvxBmpMaskChildWindow::GetChildWindowId());
     381           0 :             pBmpMask = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : NULL;
     382             :         }
     383             : 
     384           2 :         if (pBmpMask)
     385             :         {
     386           0 :             const long      nStartX = maMousePos.X() - PIPETTE_RANGE;
     387           0 :             const long      nEndX = maMousePos.X() + PIPETTE_RANGE;
     388           0 :             const long      nStartY = maMousePos.Y() - PIPETTE_RANGE;
     389           0 :             const long      nEndY = maMousePos.Y() + PIPETTE_RANGE;
     390           0 :             long            nRed = 0;
     391           0 :             long            nGreen = 0;
     392           0 :             long            nBlue = 0;
     393           0 :             const double    fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 );
     394             : 
     395           0 :             for ( long nY = nStartY; nY <= nEndY; nY++ )
     396             :             {
     397           0 :                 for( long nX = nStartX; nX <= nEndX; nX++ )
     398             :                 {
     399           0 :                     const Color aCol( pWin->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) );
     400             : 
     401           0 :                     nRed += aCol.GetRed();
     402           0 :                     nGreen += aCol.GetGreen();
     403           0 :                     nBlue += aCol.GetBlue();
     404             :                 }
     405             :             }
     406             : 
     407           0 :             pBmpMask->SetColor( Color( (sal_uInt8) ( nRed / fDiv + .5 ),
     408           0 :                                  (sal_uInt8) ( nGreen / fDiv + .5 ),
     409           0 :                                  (sal_uInt8) ( nBlue / fDiv + .5 ) ) );
     410             :         }
     411             :     }
     412             : }
     413             : 
     414           2 : void DrawViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
     415             : {
     416           2 :     if ( !IsInputLocked() )
     417             :     {
     418           2 :         bool bIsSetPageOrg = mpDrawView->IsSetPageOrg();
     419             : 
     420           2 :         if (mbIsRulerDrag)
     421             :         {
     422           0 :             Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
     423             : 
     424           0 :             if (aOutputArea.IsInside(rMEvt.GetPosPixel()))
     425             :             {
     426           0 :                 mpDrawView->EndAction();
     427             : 
     428           0 :                 if (bIsSetPageOrg)
     429           0 :                     GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
     430             :             }
     431           0 :             else if (rMEvt.IsLeft() && bIsSetPageOrg)
     432             :             {
     433           0 :                 mpDrawView->BrkAction();
     434           0 :                 SdPage* pPage = static_cast<SdPage*>( mpDrawView->GetSdrPageView()->GetPage() );
     435           0 :                 Point aOrg(pPage->GetLftBorder(), pPage->GetUppBorder());
     436           0 :                 mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg);
     437           0 :                 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
     438             :             }
     439             :             else
     440             :             {
     441           0 :                 mpDrawView->BrkAction();
     442             :             }
     443             : 
     444           0 :             GetActiveWindow()->ReleaseMouse();
     445           0 :             mbIsRulerDrag = false;
     446             :         }
     447             :         else
     448           2 :             ViewShell::MouseButtonUp(rMEvt, pWin);
     449             :         //If object is marked , the corresponding entry is set true ,
     450             :         //else the corresponding entry is set false .
     451           2 :         FreshNavigatrTree();
     452             :     }
     453           2 : }
     454             : 
     455           0 : void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
     456             : {
     457             :     // The command event is send to the window after a possible context
     458             :     // menu from an inplace client is closed. Now we have the chance to
     459             :     // deactivate the inplace client without any problem regarding parent
     460             :     // windows and code on the stack.
     461           0 :     SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
     462           0 :     bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
     463           0 :     if ( bIsOleActive && ( rCEvt.GetCommand() == CommandEventId::ContextMenu ))
     464             :     {
     465             :         // Deactivate OLE object
     466           0 :         mpDrawView->UnmarkAll();
     467           0 :         SelectionHasChanged();
     468           0 :         return;
     469             :     }
     470             : 
     471           0 :     if ( !IsInputLocked() )
     472             :     {
     473           0 :         if( GetView() &&GetView()->getSmartTags().Command(rCEvt) )
     474           0 :             return;
     475             : 
     476           0 :         const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
     477             : 
     478           0 :         if( rCEvt.GetCommand() == CommandEventId::PasteSelection && !bNativeShow )
     479             :         {
     480           0 :             TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) );
     481             : 
     482           0 :             if( aDataHelper.GetTransferable().is() )
     483             :             {
     484           0 :                 Point       aPos;
     485           0 :                 sal_Int8    nDnDAction = DND_ACTION_COPY;
     486             : 
     487           0 :                 if( GetActiveWindow() )
     488           0 :                     aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
     489             : 
     490           0 :                 if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, false ) )
     491             :                 {
     492           0 :                     INetBookmark    aINetBookmark( aEmptyStr, aEmptyStr );
     493             : 
     494           0 :                     if( ( aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) &&
     495           0 :                           aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
     496           0 :                         ( aDataHelper.HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) &&
     497           0 :                           aDataHelper.GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
     498           0 :                         ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) &&
     499           0 :                           aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
     500             :                     {
     501           0 :                         InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
     502           0 :                     }
     503             :                 }
     504           0 :             }
     505             :         }
     506           0 :         else if( rCEvt.GetCommand() == CommandEventId::ContextMenu && !bNativeShow &&
     507           0 :                  pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
     508             :         {
     509           0 :             sal_uInt16 nSdResId = 0;          // ResourceID for popup menu
     510           0 :             bool bGraphicShell = this->ISA(GraphicViewShell);
     511             : 
     512             :             // is there a snap object under the cursor?
     513             :             SdrPageView* pPV;
     514           0 :             Point   aMPos = pWin->PixelToLogic( maMousePos );
     515           0 :             sal_uInt16  nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic(
     516           0 :                 Size(FuPoor::HITPIX, 0 ) ).Width();
     517             :             sal_uInt16  nHelpLine;
     518             :             // for glue points
     519           0 :             SdrObject*  pObj = NULL;
     520           0 :             sal_uInt16      nPickId = 0;
     521             :             // for field command
     522           0 :             OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
     523           0 :             const SvxFieldItem* pFldItem = NULL;
     524           0 :             if( pOLV )
     525           0 :                 pFldItem = pOLV->GetFieldAtSelection();
     526             : 
     527             :             // helper line
     528           0 :             if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
     529             :             {
     530           0 :                 nSdResId = RID_DRAW_SNAPOBJECT_POPUP;
     531           0 :                 ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel());
     532           0 :                 return;
     533             :             }
     534             :             // is glue point under cursor marked?
     535           0 :             else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
     536           0 :                      mpDrawView->IsGluePointMarked( pObj, nPickId ) )
     537             :             {
     538           0 :                 nSdResId = RID_DRAW_GLUEPOINT_POPUP;
     539             :             }
     540             :             // field command?
     541           0 :             else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
     542           0 :                                  pFldItem->GetField()->ISA( SvxExtTimeField ) ||
     543           0 :                                  pFldItem->GetField()->ISA( SvxExtFileField ) ||
     544           0 :                                  pFldItem->GetField()->ISA( SvxAuthorField ) ) )
     545             :             {
     546           0 :                 LanguageType eLanguage( LANGUAGE_SYSTEM );
     547             : 
     548             :                 // Format popup with outliner language, if possible
     549           0 :                 if( pOLV->GetOutliner() )
     550             :                 {
     551           0 :                     ESelection aSelection( pOLV->GetSelection() );
     552           0 :                     eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
     553             :                 }
     554             : 
     555             :                 //fdo#44998 if the outliner has captured the mouse events release the lock
     556             :                 //so the SdFieldPopup can get them
     557           0 :                 pOLV->ReleaseMouse();
     558           0 :                 SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage );
     559             : 
     560           0 :                 if ( rCEvt.IsMouseEvent() )
     561           0 :                     aMPos = rCEvt.GetMousePosPixel();
     562             :                 else
     563           0 :                     aMPos = Point( 20, 20 );
     564           0 :                 aFieldPopup.Execute( pWin, aMPos );
     565             : 
     566           0 :                 boost::scoped_ptr<SvxFieldData> pField(aFieldPopup.GetField());
     567           0 :                 if( pField )
     568             :                 {
     569           0 :                     SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
     570             :                     // select field, so that it will be deleted on insert
     571           0 :                     ESelection aSel = pOLV->GetSelection();
     572           0 :                     bool bSel = true;
     573           0 :                     if( aSel.nStartPos == aSel.nEndPos )
     574             :                     {
     575           0 :                         bSel = false;
     576           0 :                         aSel.nEndPos++;
     577             :                     }
     578           0 :                     pOLV->SetSelection( aSel );
     579             : 
     580           0 :                     pOLV->InsertField( aFieldItem );
     581             : 
     582             :                     // reset selection back to original state
     583           0 :                     if( !bSel )
     584           0 :                         aSel.nEndPos--;
     585           0 :                     pOLV->SetSelection( aSel );
     586           0 :                 }
     587             :             }
     588             :             else
     589             :             {
     590             :                 // is something selected?
     591           0 :                 if (mpDrawView->AreObjectsMarked() &&
     592           0 :                     mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
     593             :                 {
     594           0 :                     pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
     595           0 :                     if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) )
     596             :                     {
     597           0 :                         nSdResId = RID_BEZIER_POPUP;
     598             :                     }
     599             :                     else
     600             :                     {
     601           0 :                         if( mpDrawView->GetTextEditObject() )
     602             :                         {
     603           0 :                             OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
     604           0 :                             Point aPos(rCEvt.GetMousePosPixel());
     605             : 
     606           0 :                             if ( pOutlinerView )
     607             :                             {
     608           0 :                                 if( (  rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
     609           0 :                                     ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
     610             :                                 {
     611             :                                     // Popup for Online-Spelling now handled by DrawDocShell
     612           0 :                                     Link<> aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
     613             : 
     614           0 :                                     if( !rCEvt.IsMouseEvent() )
     615             :                                     {
     616           0 :                                         aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
     617             :                                     }
     618             :                                     // While showing the spell context menu
     619             :                                     // we lock the input so that another
     620             :                                     // context menu can not be opened during
     621             :                                     // that time (crash #i43235#).  In order
     622             :                                     // to not lock the UI completely we
     623             :                                     // first release the mouse.
     624           0 :                                     GetActiveWindow()->ReleaseMouse();
     625           0 :                                     LockInput();
     626           0 :                                     pOutlinerView->ExecuteSpellPopup(aPos, &aLink);
     627           0 :                                     UnlockInput();
     628             :                                 }
     629             :                                 else
     630             :                                 {
     631           0 :                                     if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
     632             :                                     {
     633           0 :                                         nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP;
     634             :                                     }
     635             :                                     else
     636             :                                     {
     637           0 :                                         nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP;
     638             :                                     }
     639             :                                 }
     640             :                             }
     641             :                         }
     642             :                         else
     643             :                         {
     644           0 :                             sal_uInt32 nInv = pObj->GetObjInventor();
     645           0 :                             sal_uInt16 nId = pObj->GetObjIdentifier();
     646             : 
     647           0 :                             if (nInv == SdrInventor)
     648             :                             {
     649           0 :                                 switch ( nId )
     650             :                                 {
     651             :                                     case OBJ_OUTLINETEXT:
     652             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_OUTLINETEXTOBJ_POPUP :
     653           0 :                                                                     RID_DRAW_OUTLINETEXTOBJ_POPUP;
     654           0 :                                         break;
     655             : 
     656             :                                     case OBJ_CAPTION:
     657             :                                     case OBJ_TITLETEXT:
     658             :                                     case OBJ_TEXT:
     659             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP :
     660           0 :                                                                     RID_DRAW_TEXTOBJ_POPUP;
     661           0 :                                         break;
     662             : 
     663             :                                     case OBJ_PATHLINE:
     664             :                                     case OBJ_PLIN:
     665             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP :
     666           0 :                                                                     RID_DRAW_POLYLINEOBJ_POPUP;
     667           0 :                                         break;
     668             : 
     669             :                                     case OBJ_FREELINE:
     670             :                                     case OBJ_EDGE:      // Connector
     671             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP :
     672           0 :                                                                     RID_DRAW_EDGEOBJ_POPUP;
     673           0 :                                         break;
     674             : 
     675             :                                     case OBJ_LINE:
     676             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP :
     677           0 :                                                                     RID_DRAW_LINEOBJ_POPUP;
     678           0 :                                         break;
     679             : 
     680             :                                     case OBJ_MEASURE:
     681             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP :
     682           0 :                                                                     RID_DRAW_MEASUREOBJ_POPUP;
     683           0 :                                         break;
     684             : 
     685             :                                     case OBJ_RECT:
     686             :                                     case OBJ_CIRC:
     687             :                                     case OBJ_FREEFILL:
     688             :                                     case OBJ_PATHFILL:
     689             :                                     case OBJ_POLY:
     690             :                                     case OBJ_SECT:
     691             :                                     case OBJ_CARC:
     692             :                                     case OBJ_CCUT:
     693             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP :
     694           0 :                                                                     RID_DRAW_GEOMOBJ_POPUP;
     695           0 :                                         break;
     696             : 
     697             :                                     case OBJ_CUSTOMSHAPE:
     698             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP :
     699           0 :                                                                     RID_DRAW_CUSTOMSHAPE_POPUP;
     700           0 :                                         break;
     701             : 
     702             :                                     case OBJ_GRUP:
     703             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP :
     704           0 :                                                                     RID_DRAW_GROUPOBJ_POPUP;
     705           0 :                                         break;
     706             : 
     707             :                                     case OBJ_GRAF:
     708             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP :
     709           0 :                                                                     RID_DRAW_GRAPHIC_POPUP;
     710           0 :                                         break;
     711             : 
     712             :                                     case OBJ_OLE2:
     713             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP :
     714           0 :                                                                     RID_DRAW_OLE2_POPUP;
     715           0 :                                         break;
     716             :                                     case OBJ_MEDIA:
     717             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP :
     718           0 :                                                                     RID_DRAW_MEDIA_POPUP;
     719           0 :                                         break;
     720             :                                     case OBJ_TABLE:
     721             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP :
     722           0 :                                                                     RID_DRAW_TABLE_POPUP;
     723           0 :                                         break;
     724             :                                 }
     725             :                             }
     726           0 :                             else if( nInv == E3dInventor )
     727             :                             {
     728           0 :                                 if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID )
     729             :                                 {
     730           0 :                                     if( !mpDrawView->IsGroupEntered() )
     731             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP :
     732           0 :                                                                 RID_DRAW_3DSCENE_POPUP;
     733             :                                     else
     734             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP :
     735           0 :                                                                 RID_DRAW_3DSCENE2_POPUP;
     736             :                                 }
     737             :                                 else
     738             :                                     nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP :
     739           0 :                                                                 RID_DRAW_3DOBJ_POPUP;
     740             :                             }
     741           0 :                             else if( nInv == FmFormInventor )
     742             :                             {
     743           0 :                                 nSdResId = RID_FORM_CONTROL_POPUP;
     744             :                             }
     745             :                         }
     746             :                     }
     747             :                 }
     748             : 
     749             :                 // multiple selection
     750           0 :                 else if (mpDrawView->AreObjectsMarked() &&
     751           0 :                     mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
     752             :                 {
     753             :                     nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP :
     754           0 :                                                 RID_DRAW_MULTISELECTION_POPUP;
     755             :                 }
     756             : 
     757             :                 // nothing selected
     758             :                 else
     759             :                 {
     760             :                     nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP :
     761           0 :                                                 RID_DRAW_NOSEL_POPUP;
     762             :                 }
     763             :             }
     764             :             // show Popup-Menu
     765           0 :             if (nSdResId)
     766             :             {
     767           0 :                 GetActiveWindow()->ReleaseMouse();
     768             : 
     769           0 :                 if(rCEvt.IsMouseEvent())
     770           0 :                     GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId));
     771             :                 else
     772             :                 {
     773             :                     //don't open contextmenu at mouse position if not opened via mouse
     774             : 
     775             :                     //middle of the window if nothing is marked
     776           0 :                     Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
     777           0 :                             ,GetActiveWindow()->GetSizePixel().Height()/2);
     778             : 
     779             :                     //middle of the bounding rect if something is marked
     780           0 :                     if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
     781             :                     {
     782           0 :                         Rectangle aMarkRect;
     783           0 :                         mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect);
     784           0 :                         aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
     785             : 
     786             :                         //move the point into the visible window area
     787           0 :                         if( aMenuPos.X() < 0 )
     788           0 :                             aMenuPos.X() = 0;
     789           0 :                         if( aMenuPos.Y() < 0 )
     790           0 :                             aMenuPos.Y() = 0;
     791           0 :                         if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
     792           0 :                             aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width();
     793           0 :                         if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
     794           0 :                             aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height();
     795             :                     }
     796             : 
     797             :                     //open context menu at that point
     798           0 :                     GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos);
     799             :                 }
     800           0 :                 mbMousePosFreezed = false;
     801             :             }
     802             :         }
     803             :         else
     804             :         {
     805           0 :             ViewShell::Command(rCEvt, pWin);
     806             :         }
     807             :     }
     808             : }
     809             : 
     810           2 : void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect,
     811             :     ::sd::Window* pWin)
     812             : {
     813           2 :     if (mbHasRulers && pWin )
     814             :     {
     815             :         RulerLine   pHLines[2];
     816             :         RulerLine   pVLines[2];
     817           0 :         long        nHOffs = 0L;
     818           0 :         long        nVOffs = 0L;
     819             :         sal_uInt16      nCnt;
     820             : 
     821           0 :         if (mpHorizontalRuler.get() != NULL)
     822           0 :             mpHorizontalRuler->SetLines();
     823             : 
     824           0 :         if (mpVerticalRuler.get() != NULL)
     825           0 :             mpVerticalRuler->SetLines();
     826             : 
     827           0 :         if (mpHorizontalRuler.get() != NULL)
     828             :         {
     829           0 :             nHOffs = mpHorizontalRuler->GetNullOffset() +
     830           0 :                      mpHorizontalRuler->GetPageOffset();
     831             :         }
     832             : 
     833           0 :         if (mpVerticalRuler.get() != NULL)
     834             :         {
     835           0 :             nVOffs = mpVerticalRuler->GetNullOffset() +
     836           0 :                      mpVerticalRuler->GetPageOffset();
     837             :         }
     838             : 
     839           0 :         nCnt = 1;
     840           0 :         pHLines[0].nPos = rRect.Left() - nHOffs;
     841           0 :         pVLines[0].nPos = rRect.Top()  - nVOffs;
     842           0 :         pHLines[0].nStyle = 0;
     843           0 :         pVLines[0].nStyle = 0;
     844             : 
     845           0 :         if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
     846             :         {
     847           0 :             pHLines[1].nPos = rRect.Right()  - nHOffs;
     848           0 :             pVLines[1].nPos = rRect.Bottom() - nVOffs;
     849           0 :             pHLines[1].nStyle = 0;
     850           0 :             pVLines[1].nStyle = 0;
     851           0 :             nCnt++;
     852             :         }
     853             : 
     854           0 :         if (mpHorizontalRuler.get() != NULL)
     855           0 :             mpHorizontalRuler->SetLines(nCnt, pHLines);
     856           0 :         if (mpVerticalRuler.get() != NULL)
     857           0 :             mpVerticalRuler->SetLines(nCnt, pVLines);
     858             :     }
     859             : 
     860             :     // display with coordinates in StatusBar
     861             :     OSL_ASSERT (GetViewShell()!=NULL);
     862           2 :     if ( !GetViewShell()->GetUIActiveClient() )
     863             :     {
     864           2 :         SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT,
     865             :                                    SID_ATTR_POSITION, SID_ATTR_POSITION,
     866             :                                    SID_ATTR_SIZE, SID_ATTR_SIZE,
     867           2 :                                    0L);
     868             : 
     869           2 :         GetStatusBarState(aSet);
     870             : 
     871           2 :         aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
     872             : 
     873           2 :         SfxBindings& rBindings = GetViewFrame()->GetBindings();
     874           2 :         rBindings.SetState(aSet);
     875           2 :         rBindings.Invalidate(SID_CONTEXT);
     876           2 :         rBindings.Invalidate(SID_ATTR_POSITION);
     877           2 :         rBindings.Invalidate(SID_ATTR_SIZE);
     878             :     }
     879           2 : }
     880             : 
     881           0 : void DrawViewShell::LockInput()
     882             : {
     883           0 :     mnLockCount++;
     884           0 : }
     885             : 
     886           0 : void DrawViewShell::UnlockInput()
     887             : {
     888             :     DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
     889           0 :     if ( mnLockCount )
     890           0 :         mnLockCount--;
     891           0 : }
     892             : 
     893           0 : void DrawViewShell::ShowSnapLineContextMenu (
     894             :     SdrPageView& rPageView,
     895             :     const sal_uInt16 nSnapLineIndex,
     896             :     const Point& rMouseLocation)
     897             : {
     898           0 :     const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
     899           0 :     ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ());
     900             : 
     901           0 :     if (rHelpLine.GetKind() == SDRHELPLINE_POINT)
     902             :     {
     903           0 :         pMenu->InsertItem(
     904             :             SID_SET_SNAPITEM,
     905           0 :             SD_RESSTR(STR_POPUP_EDIT_SNAPPOINT));
     906           0 :         pMenu->InsertSeparator();
     907           0 :         pMenu->InsertItem(
     908             :             SID_DELETE_SNAPITEM,
     909           0 :             SD_RESSTR(STR_POPUP_DELETE_SNAPPOINT));
     910             :     }
     911             :     else
     912             :     {
     913           0 :         pMenu->InsertItem(
     914             :             SID_SET_SNAPITEM,
     915           0 :             SD_RESSTR(STR_POPUP_EDIT_SNAPLINE));
     916           0 :         pMenu->InsertSeparator();
     917           0 :         pMenu->InsertItem(
     918             :             SID_DELETE_SNAPITEM,
     919           0 :             SD_RESSTR(STR_POPUP_DELETE_SNAPLINE));
     920             :     }
     921             : 
     922           0 :     pMenu->RemoveDisabledEntries(false, false);
     923             : 
     924             :     const sal_uInt16 nResult = pMenu->Execute(
     925           0 :         GetActiveWindow(),
     926             :         Rectangle(rMouseLocation, Size(10,10)),
     927           0 :         PopupMenuFlags::ExecuteDown);
     928           0 :     switch (nResult)
     929             :     {
     930             :         case SID_SET_SNAPITEM:
     931             :         {
     932           0 :             SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
     933           0 :             const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL};
     934             :             GetViewFrame()->GetDispatcher()->Execute(
     935             :                 SID_SET_SNAPITEM,
     936             :                 SfxCallMode::SLOT,
     937           0 :                 aArguments);
     938             :         }
     939           0 :         break;
     940             : 
     941             :         case SID_DELETE_SNAPITEM:
     942             :         {
     943           0 :             rPageView.DeleteHelpLine(nSnapLineIndex);
     944             :         }
     945           0 :         break;
     946             : 
     947             :         default:
     948           0 :             break;
     949           0 :     }
     950           0 : }
     951             : 
     952          66 : } // end of namespace sd
     953             : 
     954             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11