LCOV - code coverage report
Current view: top level - sd/source/ui/view - drviews4.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 413 0.2 %
Date: 2014-11-03 Functions: 2 16 12.5 %
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 (QueryBox(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           0 : bool DrawViewShell::KeyInput (const KeyEvent& rKEvt, ::sd::Window* pWin)
     124             : {
     125           0 :     bool bRet = false;
     126             : 
     127           0 :     if ( !IsInputLocked() || ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) )
     128             :     {
     129           0 :         if(KEY_RETURN == rKEvt.GetKeyCode().GetCode()
     130           0 :             && rKEvt.GetKeyCode().IsMod1()
     131           0 :             && 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 = (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           0 :             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           0 :             if(KEY_TAB == rKEvt.GetKeyCode().GetCode())
     198             :             {
     199           0 :                FreshNavigatrTree();
     200             :             }
     201             :         }
     202             :     }
     203             : 
     204           0 :     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 = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
     252           0 :         if( pNavWin )
     253           0 :             pNavWin->FreshEntry();
     254             :     }
     255           0 : }
     256             : 
     257           0 : void DrawViewShell::FreshNavigatrTree()
     258             : {
     259           0 :     sal_uInt16 nId = SID_NAVIGATOR;
     260           0 :     SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
     261           0 :     if( pWindow )
     262             :     {
     263           0 :         SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
     264           0 :         if( pNavWin )
     265           0 :             pNavWin->FreshTree( GetDoc() );
     266             :     }
     267           0 : }
     268             : 
     269           0 : 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           0 :     SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
     279           0 :     bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
     280             : 
     281           0 :     if ( bIsOleActive && PopupMenu::IsInExecute() )
     282           0 :         return;
     283             : 
     284           0 :     if ( !IsInputLocked() )
     285             :     {
     286           0 :         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           0 :         FreshNavigatrTree();
     291           0 :         if ( mbPipette )
     292           0 :             ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->PipetteClicked();
     293             :     }
     294             : }
     295             : 
     296           0 : void DrawViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
     297             : {
     298           0 :     if ( !IsInputLocked() )
     299             :     {
     300           0 :         if ( mpDrawView->IsAction() )
     301             :         {
     302           0 :             Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
     303             : 
     304           0 :             if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
     305             :             {
     306           0 :                 bool bInsideOtherWindow = false;
     307             : 
     308           0 :                 if (mpContentWindow.get() != NULL)
     309             :                 {
     310             :                     aOutputArea = Rectangle(Point(0,0),
     311           0 :                         mpContentWindow->GetOutputSizePixel());
     312             : 
     313           0 :                     Point aPos = mpContentWindow->GetPointerPosPixel();
     314           0 :                     if ( aOutputArea.IsInside(aPos) )
     315           0 :                         bInsideOtherWindow = true;
     316             :                 }
     317             : 
     318           0 :                 if (! GetActiveWindow()->HasFocus ())
     319             :                 {
     320           0 :                     GetActiveWindow()->ReleaseMouse ();
     321           0 :                     mpDrawView->BrkAction ();
     322           0 :                     return;
     323             :                 }
     324           0 :                 else if ( bInsideOtherWindow )
     325             :                 {
     326           0 :                     GetActiveWindow()->ReleaseMouse();
     327           0 :                     pWin->CaptureMouse ();
     328             :                 }
     329             :             }
     330           0 :             else if ( pWin != GetActiveWindow() )
     331           0 :                  pWin->CaptureMouse();
     332             :         }
     333             : 
     334             :         // Since the next MouseMove may execute a IsSolidDraggingNow() in
     335             :         // SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor
     336             :         // is needed it is necessary to set it here.
     337           0 :         if (GetDoc())
     338             :         {
     339           0 :             svtools::ColorConfig aColorConfig;
     340           0 :             Color aFillColor;
     341             : 
     342           0 :             aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor );
     343             : 
     344           0 :             mpDrawView->SetApplicationBackgroundColor(aFillColor);
     345             :         }
     346             : 
     347           0 :         ViewShell::MouseMove(rMEvt, pWin);
     348             : 
     349           0 :         if( !mbMousePosFreezed )
     350           0 :             maMousePos = rMEvt.GetPosPixel();
     351             : 
     352           0 :         Rectangle aRect;
     353             : 
     354           0 :         if ( mbIsRulerDrag )
     355             :         {
     356           0 :             Point aLogPos = GetActiveWindow()->PixelToLogic(maMousePos);
     357           0 :             mpDrawView->MovAction(aLogPos);
     358             :         }
     359             : 
     360           0 :         if ( mpDrawView->IsAction() )
     361             :         {
     362           0 :             mpDrawView->TakeActionRect(aRect);
     363           0 :             aRect = GetActiveWindow()->LogicToPixel(aRect);
     364             :         }
     365             :         else
     366             :         {
     367           0 :             aRect = Rectangle(maMousePos, maMousePos);
     368             :         }
     369             : 
     370           0 :         ShowMousePosInfo(aRect, pWin);
     371             : 
     372           0 :         if ( mbPipette && GetViewFrame()->HasChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() ) )
     373             :         {
     374           0 :             const long      nStartX = maMousePos.X() - PIPETTE_RANGE;
     375           0 :             const long      nEndX = maMousePos.X() + PIPETTE_RANGE;
     376           0 :             const long      nStartY = maMousePos.Y() - PIPETTE_RANGE;
     377           0 :             const long      nEndY = maMousePos.Y() + PIPETTE_RANGE;
     378           0 :             long            nRed = 0;
     379           0 :             long            nGreen = 0;
     380           0 :             long            nBlue = 0;
     381           0 :             const double    fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 );
     382             : 
     383           0 :             for ( long nY = nStartY; nY <= nEndY; nY++ )
     384             :             {
     385           0 :                 for( long nX = nStartX; nX <= nEndX; nX++ )
     386             :                 {
     387           0 :                     const Color aCol( pWin->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) );
     388             : 
     389           0 :                     nRed += aCol.GetRed();
     390           0 :                     nGreen += aCol.GetGreen();
     391           0 :                     nBlue += aCol.GetBlue();
     392             :                 }
     393             :             }
     394             : 
     395           0 :             ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
     396           0 :                 SetColor( Color( (sal_uInt8) ( nRed / fDiv + .5 ),
     397           0 :                                  (sal_uInt8) ( nGreen / fDiv + .5 ),
     398           0 :                                  (sal_uInt8) ( nBlue / fDiv + .5 ) ) );
     399             :         }
     400             :     }
     401             : }
     402             : 
     403           0 : void DrawViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
     404             : {
     405           0 :     if ( !IsInputLocked() )
     406             :     {
     407           0 :         bool bIsSetPageOrg = mpDrawView->IsSetPageOrg();
     408             : 
     409           0 :         if (mbIsRulerDrag)
     410             :         {
     411           0 :             Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
     412             : 
     413           0 :             if (aOutputArea.IsInside(rMEvt.GetPosPixel()))
     414             :             {
     415           0 :                 mpDrawView->EndAction();
     416             : 
     417           0 :                 if (bIsSetPageOrg)
     418           0 :                     GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
     419             :             }
     420           0 :             else if (rMEvt.IsLeft() && bIsSetPageOrg)
     421             :             {
     422           0 :                 mpDrawView->BrkAction();
     423           0 :                 SdPage* pPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
     424           0 :                 Point aOrg(pPage->GetLftBorder(), pPage->GetUppBorder());
     425           0 :                 mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg);
     426           0 :                 GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
     427             :             }
     428             :             else
     429             :             {
     430           0 :                 mpDrawView->BrkAction();
     431             :             }
     432             : 
     433           0 :             GetActiveWindow()->ReleaseMouse();
     434           0 :             mbIsRulerDrag = false;
     435             :         }
     436             :         else
     437           0 :             ViewShell::MouseButtonUp(rMEvt, pWin);
     438             :         //If object is marked , the corresponding entry is set true ,
     439             :         //else the corresponding entry is set false .
     440           0 :         FreshNavigatrTree();
     441             :     }
     442           0 : }
     443             : 
     444           0 : void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
     445             : {
     446             :     // The command event is send to the window after a possible context
     447             :     // menu from an inplace client is closed. Now we have the chance to
     448             :     // deactivate the inplace client without any problem regarding parent
     449             :     // windows and code on the stack.
     450           0 :     SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
     451           0 :     bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
     452           0 :     if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
     453             :     {
     454             :         // Deactivate OLE object
     455           0 :         mpDrawView->UnmarkAll();
     456           0 :         SelectionHasChanged();
     457           0 :         return;
     458             :     }
     459             : 
     460           0 :     if ( !IsInputLocked() )
     461             :     {
     462           0 :         if( GetView() &&GetView()->getSmartTags().Command(rCEvt) )
     463           0 :             return;
     464             : 
     465           0 :         const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
     466             : 
     467           0 :         if( rCEvt.GetCommand() == COMMAND_PASTESELECTION && !bNativeShow )
     468             :         {
     469           0 :             TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) );
     470             : 
     471           0 :             if( aDataHelper.GetTransferable().is() )
     472             :             {
     473           0 :                 Point       aPos;
     474           0 :                 sal_Int8    nDnDAction = DND_ACTION_COPY;
     475             : 
     476           0 :                 if( GetActiveWindow() )
     477           0 :                     aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
     478             : 
     479           0 :                 if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, false ) )
     480             :                 {
     481           0 :                     INetBookmark    aINetBookmark( aEmptyStr, aEmptyStr );
     482             : 
     483           0 :                     if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
     484           0 :                           aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
     485           0 :                         ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
     486           0 :                           aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
     487           0 :                         ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
     488           0 :                           aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
     489             :                     {
     490           0 :                         InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
     491           0 :                     }
     492             :                 }
     493           0 :             }
     494             :         }
     495           0 :         else if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bNativeShow &&
     496           0 :                  pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
     497             :         {
     498           0 :             sal_uInt16 nSdResId = 0;          // ResourceID for popup menu
     499           0 :             bool bGraphicShell = this->ISA(GraphicViewShell);
     500             : 
     501             :             // is there a snap object under the cursor?
     502             :             SdrPageView* pPV;
     503           0 :             Point   aMPos = pWin->PixelToLogic( maMousePos );
     504           0 :             sal_uInt16  nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic(
     505           0 :                 Size(FuPoor::HITPIX, 0 ) ).Width();
     506             :             sal_uInt16  nHelpLine;
     507             :             // for glue points
     508           0 :             SdrObject*  pObj = NULL;
     509           0 :             sal_uInt16      nPickId = 0;
     510             :             // for field command
     511           0 :             OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
     512           0 :             const SvxFieldItem* pFldItem = NULL;
     513           0 :             if( pOLV )
     514           0 :                 pFldItem = pOLV->GetFieldAtSelection();
     515             : 
     516             :             // helper line
     517           0 :             if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
     518             :             {
     519           0 :                 nSdResId = RID_DRAW_SNAPOBJECT_POPUP;
     520           0 :                 ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel());
     521           0 :                 return;
     522             :             }
     523             :             // is glue point under cursor marked?
     524           0 :             else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
     525           0 :                      mpDrawView->IsGluePointMarked( pObj, nPickId ) )
     526             :             {
     527           0 :                 nSdResId = RID_DRAW_GLUEPOINT_POPUP;
     528             :             }
     529             :             // field command?
     530           0 :             else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
     531           0 :                                  pFldItem->GetField()->ISA( SvxExtTimeField ) ||
     532           0 :                                  pFldItem->GetField()->ISA( SvxExtFileField ) ||
     533           0 :                                  pFldItem->GetField()->ISA( SvxAuthorField ) ) )
     534             :             {
     535           0 :                 LanguageType eLanguage( LANGUAGE_SYSTEM );
     536             : 
     537             :                 // Format popup with outliner language, if possible
     538           0 :                 if( pOLV->GetOutliner() )
     539             :                 {
     540           0 :                     ESelection aSelection( pOLV->GetSelection() );
     541           0 :                     eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
     542             :                 }
     543             : 
     544             :                 //fdo#44998 if the outliner has captured the mouse events release the lock
     545             :                 //so the SdFieldPopup can get them
     546           0 :                 pOLV->ReleaseMouse();
     547           0 :                 SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage );
     548             : 
     549           0 :                 if ( rCEvt.IsMouseEvent() )
     550           0 :                     aMPos = rCEvt.GetMousePosPixel();
     551             :                 else
     552           0 :                     aMPos = Point( 20, 20 );
     553           0 :                 aFieldPopup.Execute( pWin, aMPos );
     554             : 
     555           0 :                 boost::scoped_ptr<SvxFieldData> pField(aFieldPopup.GetField());
     556           0 :                 if( pField )
     557             :                 {
     558           0 :                     SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
     559             :                     // select field, so that it will be deleted on insert
     560           0 :                     ESelection aSel = pOLV->GetSelection();
     561           0 :                     bool bSel = true;
     562           0 :                     if( aSel.nStartPos == aSel.nEndPos )
     563             :                     {
     564           0 :                         bSel = false;
     565           0 :                         aSel.nEndPos++;
     566             :                     }
     567           0 :                     pOLV->SetSelection( aSel );
     568             : 
     569           0 :                     pOLV->InsertField( aFieldItem );
     570             : 
     571             :                     // reset selection back to original state
     572           0 :                     if( !bSel )
     573           0 :                         aSel.nEndPos--;
     574           0 :                     pOLV->SetSelection( aSel );
     575           0 :                 }
     576             :             }
     577             :             else
     578             :             {
     579             :                 // is something selected?
     580           0 :                 if (mpDrawView->AreObjectsMarked() &&
     581           0 :                     mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
     582             :                 {
     583           0 :                     pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
     584           0 :                     if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) )
     585             :                     {
     586           0 :                         nSdResId = RID_BEZIER_POPUP;
     587             :                     }
     588             :                     else
     589             :                     {
     590           0 :                         if( mpDrawView->GetTextEditObject() )
     591             :                         {
     592           0 :                             OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
     593           0 :                             Point aPos(rCEvt.GetMousePosPixel());
     594             : 
     595           0 :                             if ( pOutlinerView )
     596             :                             {
     597           0 :                                 if( (  rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
     598           0 :                                     ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
     599             :                                 {
     600             :                                     // Popup for Online-Spelling now handled by DrawDocShell
     601           0 :                                     Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
     602             : 
     603           0 :                                     if( !rCEvt.IsMouseEvent() )
     604             :                                     {
     605           0 :                                         aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
     606             :                                     }
     607             :                                     // While showing the spell context menu
     608             :                                     // we lock the input so that another
     609             :                                     // context menu can not be opened during
     610             :                                     // that time (crash #i43235#).  In order
     611             :                                     // to not lock the UI completely we
     612             :                                     // first release the mouse.
     613           0 :                                     GetActiveWindow()->ReleaseMouse();
     614           0 :                                     LockInput();
     615           0 :                                     pOutlinerView->ExecuteSpellPopup(aPos, &aLink);
     616           0 :                                     UnlockInput();
     617             :                                 }
     618             :                                 else
     619             :                                 {
     620           0 :                                     if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
     621             :                                     {
     622           0 :                                         nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP;
     623             :                                     }
     624             :                                     else
     625             :                                     {
     626           0 :                                         nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP;
     627             :                                     }
     628             :                                 }
     629             :                             }
     630             :                         }
     631             :                         else
     632             :                         {
     633           0 :                             sal_uInt32 nInv = pObj->GetObjInventor();
     634           0 :                             sal_uInt16 nId = pObj->GetObjIdentifier();
     635             : 
     636           0 :                             if (nInv == SdrInventor)
     637             :                             {
     638           0 :                                 switch ( nId )
     639             :                                 {
     640             :                                     case OBJ_OUTLINETEXT:
     641             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_OUTLINETEXTOBJ_POPUP :
     642           0 :                                                                     RID_DRAW_OUTLINETEXTOBJ_POPUP;
     643           0 :                                         break;
     644             : 
     645             :                                     case OBJ_CAPTION:
     646             :                                     case OBJ_TITLETEXT:
     647             :                                     case OBJ_TEXT:
     648             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP :
     649           0 :                                                                     RID_DRAW_TEXTOBJ_POPUP;
     650           0 :                                         break;
     651             : 
     652             :                                     case OBJ_PATHLINE:
     653             :                                     case OBJ_PLIN:
     654             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP :
     655           0 :                                                                     RID_DRAW_POLYLINEOBJ_POPUP;
     656           0 :                                         break;
     657             : 
     658             :                                     case OBJ_FREELINE:
     659             :                                     case OBJ_EDGE:      // Connector
     660             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP :
     661           0 :                                                                     RID_DRAW_EDGEOBJ_POPUP;
     662           0 :                                         break;
     663             : 
     664             :                                     case OBJ_LINE:
     665             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP :
     666           0 :                                                                     RID_DRAW_LINEOBJ_POPUP;
     667           0 :                                         break;
     668             : 
     669             :                                     case OBJ_MEASURE:
     670             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP :
     671           0 :                                                                     RID_DRAW_MEASUREOBJ_POPUP;
     672           0 :                                         break;
     673             : 
     674             :                                     case OBJ_RECT:
     675             :                                     case OBJ_CIRC:
     676             :                                     case OBJ_FREEFILL:
     677             :                                     case OBJ_PATHFILL:
     678             :                                     case OBJ_POLY:
     679             :                                     case OBJ_SECT:
     680             :                                     case OBJ_CARC:
     681             :                                     case OBJ_CCUT:
     682             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP :
     683           0 :                                                                     RID_DRAW_GEOMOBJ_POPUP;
     684           0 :                                         break;
     685             : 
     686             :                                     case OBJ_CUSTOMSHAPE:
     687             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP :
     688           0 :                                                                     RID_DRAW_CUSTOMSHAPE_POPUP;
     689           0 :                                         break;
     690             : 
     691             :                                     case OBJ_GRUP:
     692             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP :
     693           0 :                                                                     RID_DRAW_GROUPOBJ_POPUP;
     694           0 :                                         break;
     695             : 
     696             :                                     case OBJ_GRAF:
     697             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP :
     698           0 :                                                                     RID_DRAW_GRAPHIC_POPUP;
     699           0 :                                         break;
     700             : 
     701             :                                     case OBJ_OLE2:
     702             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP :
     703           0 :                                                                     RID_DRAW_OLE2_POPUP;
     704           0 :                                         break;
     705             :                                     case OBJ_MEDIA:
     706             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP :
     707           0 :                                                                     RID_DRAW_MEDIA_POPUP;
     708           0 :                                         break;
     709             :                                     case OBJ_TABLE:
     710             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP :
     711           0 :                                                                     RID_DRAW_TABLE_POPUP;
     712           0 :                                         break;
     713             :                                 }
     714             :                             }
     715           0 :                             else if( nInv == E3dInventor )
     716             :                             {
     717           0 :                                 if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID )
     718             :                                 {
     719           0 :                                     if( !mpDrawView->IsGroupEntered() )
     720             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP :
     721           0 :                                                                 RID_DRAW_3DSCENE_POPUP;
     722             :                                     else
     723             :                                         nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP :
     724           0 :                                                                 RID_DRAW_3DSCENE2_POPUP;
     725             :                                 }
     726             :                                 else
     727             :                                     nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP :
     728           0 :                                                                 RID_DRAW_3DOBJ_POPUP;
     729             :                             }
     730           0 :                             else if( nInv == FmFormInventor )
     731             :                             {
     732           0 :                                 nSdResId = RID_FORM_CONTROL_POPUP;
     733             :                             }
     734             :                         }
     735             :                     }
     736             :                 }
     737             : 
     738             :                 // multiple selection
     739           0 :                 else if (mpDrawView->AreObjectsMarked() &&
     740           0 :                     mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
     741             :                 {
     742             :                     nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP :
     743           0 :                                                 RID_DRAW_MULTISELECTION_POPUP;
     744             :                 }
     745             : 
     746             :                 // nothing selected
     747             :                 else
     748             :                 {
     749             :                     nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP :
     750           0 :                                                 RID_DRAW_NOSEL_POPUP;
     751             :                 }
     752             :             }
     753             :             // show Popup-Menu
     754           0 :             if (nSdResId)
     755             :             {
     756           0 :                 GetActiveWindow()->ReleaseMouse();
     757             : 
     758           0 :                 if(rCEvt.IsMouseEvent())
     759           0 :                     GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId));
     760             :                 else
     761             :                 {
     762             :                     //don't open contextmenu at mouse position if not opened via mouse
     763             : 
     764             :                     //middle of the window if nothing is marked
     765           0 :                     Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
     766           0 :                             ,GetActiveWindow()->GetSizePixel().Height()/2);
     767             : 
     768             :                     //middle of the bounding rect if something is marked
     769           0 :                     if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
     770             :                     {
     771           0 :                         Rectangle aMarkRect;
     772           0 :                         mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect);
     773           0 :                         aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
     774             : 
     775             :                         //move the point into the visible window area
     776           0 :                         if( aMenuPos.X() < 0 )
     777           0 :                             aMenuPos.X() = 0;
     778           0 :                         if( aMenuPos.Y() < 0 )
     779           0 :                             aMenuPos.Y() = 0;
     780           0 :                         if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
     781           0 :                             aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width();
     782           0 :                         if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
     783           0 :                             aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height();
     784             :                     }
     785             : 
     786             :                     //open context menu at that point
     787           0 :                     GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos);
     788             :                 }
     789           0 :                 mbMousePosFreezed = false;
     790             :             }
     791             :         }
     792             :         else
     793             :         {
     794           0 :             ViewShell::Command(rCEvt, pWin);
     795             :         }
     796             :     }
     797             : }
     798             : 
     799           0 : void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect,
     800             :     ::sd::Window* pWin)
     801             : {
     802           0 :     if (mbHasRulers && pWin )
     803             :     {
     804             :         RulerLine   pHLines[2];
     805             :         RulerLine   pVLines[2];
     806           0 :         long        nHOffs = 0L;
     807           0 :         long        nVOffs = 0L;
     808             :         sal_uInt16      nCnt;
     809             : 
     810           0 :         if (mpHorizontalRuler.get() != NULL)
     811           0 :             mpHorizontalRuler->SetLines();
     812             : 
     813           0 :         if (mpVerticalRuler.get() != NULL)
     814           0 :             mpVerticalRuler->SetLines();
     815             : 
     816           0 :         if (mpHorizontalRuler.get() != NULL)
     817             :         {
     818           0 :             nHOffs = mpHorizontalRuler->GetNullOffset() +
     819           0 :                      mpHorizontalRuler->GetPageOffset();
     820             :         }
     821             : 
     822           0 :         if (mpVerticalRuler.get() != NULL)
     823             :         {
     824           0 :             nVOffs = mpVerticalRuler->GetNullOffset() +
     825           0 :                      mpVerticalRuler->GetPageOffset();
     826             :         }
     827             : 
     828           0 :         nCnt = 1;
     829           0 :         pHLines[0].nPos = rRect.Left() - nHOffs;
     830           0 :         pVLines[0].nPos = rRect.Top()  - nVOffs;
     831           0 :         pHLines[0].nStyle = 0;
     832           0 :         pVLines[0].nStyle = 0;
     833             : 
     834           0 :         if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
     835             :         {
     836           0 :             pHLines[1].nPos = rRect.Right()  - nHOffs;
     837           0 :             pVLines[1].nPos = rRect.Bottom() - nVOffs;
     838           0 :             pHLines[1].nStyle = 0;
     839           0 :             pVLines[1].nStyle = 0;
     840           0 :             nCnt++;
     841             :         }
     842             : 
     843           0 :         if (mpHorizontalRuler.get() != NULL)
     844           0 :             mpHorizontalRuler->SetLines(nCnt, pHLines);
     845           0 :         if (mpVerticalRuler.get() != NULL)
     846           0 :             mpVerticalRuler->SetLines(nCnt, pVLines);
     847             :     }
     848             : 
     849             :     // display with coordinates in StatusBar
     850             :     OSL_ASSERT (GetViewShell()!=NULL);
     851           0 :     if ( !GetViewShell()->GetUIActiveClient() )
     852             :     {
     853           0 :         SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT,
     854             :                                    SID_ATTR_POSITION, SID_ATTR_POSITION,
     855             :                                    SID_ATTR_SIZE, SID_ATTR_SIZE,
     856           0 :                                    0L);
     857             : 
     858           0 :         GetStatusBarState(aSet);
     859             : 
     860           0 :         aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
     861             : 
     862           0 :         SfxBindings& rBindings = GetViewFrame()->GetBindings();
     863           0 :         rBindings.SetState(aSet);
     864           0 :         rBindings.Invalidate(SID_CONTEXT);
     865           0 :         rBindings.Invalidate(SID_ATTR_POSITION);
     866           0 :         rBindings.Invalidate(SID_ATTR_SIZE);
     867             :     }
     868           0 : }
     869             : 
     870           0 : void DrawViewShell::LockInput()
     871             : {
     872           0 :     mnLockCount++;
     873           0 : }
     874             : 
     875           0 : void DrawViewShell::UnlockInput()
     876             : {
     877             :     DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
     878           0 :     if ( mnLockCount )
     879           0 :         mnLockCount--;
     880           0 : }
     881             : 
     882           0 : void DrawViewShell::ShowSnapLineContextMenu (
     883             :     SdrPageView& rPageView,
     884             :     const sal_uInt16 nSnapLineIndex,
     885             :     const Point& rMouseLocation)
     886             : {
     887           0 :     const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
     888           0 :     ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ());
     889             : 
     890           0 :     if (rHelpLine.GetKind() == SDRHELPLINE_POINT)
     891             :     {
     892           0 :         pMenu->InsertItem(
     893             :             SID_SET_SNAPITEM,
     894           0 :             SD_RESSTR(STR_POPUP_EDIT_SNAPPOINT));
     895           0 :         pMenu->InsertSeparator();
     896           0 :         pMenu->InsertItem(
     897             :             SID_DELETE_SNAPITEM,
     898           0 :             SD_RESSTR(STR_POPUP_DELETE_SNAPPOINT));
     899             :     }
     900             :     else
     901             :     {
     902           0 :         pMenu->InsertItem(
     903             :             SID_SET_SNAPITEM,
     904           0 :             SD_RESSTR(STR_POPUP_EDIT_SNAPLINE));
     905           0 :         pMenu->InsertSeparator();
     906           0 :         pMenu->InsertItem(
     907             :             SID_DELETE_SNAPITEM,
     908           0 :             SD_RESSTR(STR_POPUP_DELETE_SNAPLINE));
     909             :     }
     910             : 
     911           0 :     pMenu->RemoveDisabledEntries(false, false);
     912             : 
     913             :     const sal_uInt16 nResult = pMenu->Execute(
     914           0 :         GetActiveWindow(),
     915             :         Rectangle(rMouseLocation, Size(10,10)),
     916           0 :         POPUPMENU_EXECUTE_DOWN);
     917           0 :     switch (nResult)
     918             :     {
     919             :         case SID_SET_SNAPITEM:
     920             :         {
     921           0 :             SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
     922           0 :             const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL};
     923             :             GetViewFrame()->GetDispatcher()->Execute(
     924             :                 SID_SET_SNAPITEM,
     925             :                 SfxCallMode::SLOT,
     926           0 :                 aArguments);
     927             :         }
     928           0 :         break;
     929             : 
     930             :         case SID_DELETE_SNAPITEM:
     931             :         {
     932           0 :             rPageView.DeleteHelpLine(nSnapLineIndex);
     933             :         }
     934           0 :         break;
     935             : 
     936             :         default:
     937           0 :             break;
     938           0 :     }
     939           0 : }
     940             : 
     941         114 : } // end of namespace sd
     942             : 
     943             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10