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

Generated by: LCOV version 1.10