Files
libreoffice/svx/source/dialog/graphctl.cxx

795 lines
23 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patch contributed by Christian Lippka impress212: #i113063# patch: dubios self assign in svx/source/dialog/framelink.cxx http://svn.apache.org/viewvc?view=revision&revision=1167619 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i117712#: fix several resource errors introduced by IAccessible2 implementation http://svn.apache.org/viewvc?view=revision&revision=1172343 cws mba34issues01: #i117719#: use correct resource ID http://svn.apache.org/viewvc?view=revision&revision=1172351 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Armin Le-Grand #118804# corrected GraphicExporter behaviour on shortcut when pixel graphic is requested http://svn.apache.org/viewvc?view=revision&revision=1240195 fix for #118525#: Using primitives for chart sub-geometry visualisation http://svn.apache.org/viewvc?view=revision&revision=1226879 #118485# - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 #118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 13f79535-47bb-0310-9956-ffa450edef68 Patch contributed by Regina Henschel linecap: Reintegrating finished LineCap feature http://svn.apache.org/viewvc?view=revision&revision=1232507 Patch contributed by Wang Lei (leiw) #i118760# split the first table cell vertically, then undo&redo, the Presentation app will crash http://svn.apache.org/viewvc?view=revision&revision=1301361 cleanup globlmn hacks, undo dependent fixmes.
2012-11-21 22:06:52 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include <svl/itempool.hxx>
#include <vcl/dialog.hxx>
2000-09-18 16:07:07 +00:00
#include <vcl/wrkwin.hxx>
#include <unotools/syslocale.hxx>
#include <rtl/math.hxx>
#include <unotools/localedatawrapper.hxx>
#include <comphelper/processfactory.hxx>
#include <vcl/svapp.hxx>
#include <osl/mutex.hxx>
#include <svx/graphctl.hxx>
#include "GraphCtlAccessibleContext.hxx"
#include "svx/xoutbmp.hxx"
#include <svx/svxids.hrc>
#include <svx/svdpage.hxx>
2000-09-18 16:07:07 +00:00
// #i72889#
#include "svx/sdrpaintwindow.hxx"
void GraphCtrlUserCall::Changed( const SdrObject& rObj, SdrUserCallType eType, const Rectangle& /*rOldBoundRect*/ )
2000-09-18 16:07:07 +00:00
{
switch( eType )
{
case( SDRUSERCALL_MOVEONLY ):
case( SDRUSERCALL_RESIZE ):
rWin.SdrObjChanged( rObj );
break;
case( SDRUSERCALL_INSERTED ):
rWin.SdrObjCreated( rObj );
break;
default:
break;
}
}
GraphCtrl::GraphCtrl( Window* pParent, const ResId& rResId ) :
Control ( pParent, rResId ),
aMap100 ( MAP_100TH_MM ),
nWinStyle ( 0 ),
2000-09-18 16:07:07 +00:00
eObjKind ( OBJ_NONE ),
nPolyEdit ( 0 ),
bEditMode ( sal_False ),
bSdrMode ( sal_False ),
bAnim ( sal_False ),
mpAccContext ( NULL ),
pModel ( NULL ),
pView ( NULL )
2000-09-18 16:07:07 +00:00
{
pUserCall = new GraphCtrlUserCall( *this );
aUpdateTimer.SetTimeout( 500 );
aUpdateTimer.SetTimeoutHdl( LINK( this, GraphCtrl, UpdateHdl ) );
aUpdateTimer.Start();
EnableRTL( sal_False );
2000-09-18 16:07:07 +00:00
}
GraphCtrl::GraphCtrl( Window* pParent, WinBits nStyle ) :
Control ( pParent, nStyle ),
aMap100 ( MAP_100TH_MM ),
nWinStyle ( 0 ),
eObjKind ( OBJ_NONE ),
nPolyEdit ( 0 ),
bEditMode ( sal_False ),
bSdrMode ( sal_False ),
bAnim ( sal_False ),
mpAccContext ( NULL ),
pModel ( NULL ),
pView ( NULL )
{
pUserCall = new GraphCtrlUserCall( *this );
aUpdateTimer.SetTimeout( 500 );
aUpdateTimer.SetTimeoutHdl( LINK( this, GraphCtrl, UpdateHdl ) );
aUpdateTimer.Start();
EnableRTL( sal_False );
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeGraphCtrl(Window *pParent, VclBuilder::stringmap &rMap)
{
WinBits nWinStyle = 0;
OString sBorder = VclBuilder::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
return new GraphCtrl(pParent, nWinStyle);
}
2000-09-18 16:07:07 +00:00
GraphCtrl::~GraphCtrl()
{
if( mpAccContext )
{
mpAccContext->disposing();
mpAccContext->release();
}
2000-09-18 16:07:07 +00:00
delete pView;
delete pModel;
delete pUserCall;
}
void GraphCtrl::SetWinStyle( WinBits nWinBits )
{
nWinStyle = nWinBits;
bAnim = ( nWinStyle & WB_ANIMATION ) == WB_ANIMATION;
bSdrMode = ( nWinStyle & WB_SDRMODE ) == WB_SDRMODE;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
SetMapMode( aMap100 );
delete pView;
pView = NULL;
delete pModel;
pModel = NULL;
if ( bSdrMode )
InitSdrModel();
}
void GraphCtrl::InitSdrModel()
{
SolarMutexGuard aGuard;
2000-09-18 16:07:07 +00:00
SdrPage* pPage;
// destroy old junk
2000-09-18 16:07:07 +00:00
delete pView;
delete pModel;
// Creating a Model
2000-09-18 16:07:07 +00:00
pModel = new SdrModel;
pModel->GetItemPool().FreezeIdRanges();
pModel->SetScaleUnit( aMap100.GetMapUnit() );
pModel->SetScaleFraction( Fraction( 1, 1 ) );
pModel->SetDefaultFontHeight( 500 );
pPage = new SdrPage( *pModel );
pPage->SetSize( aGraphSize );
pPage->SetBorder( 0, 0, 0, 0 );
pModel->InsertPage( pPage );
pModel->SetChanged( sal_False );
2000-09-18 16:07:07 +00:00
// Creating a View
2000-09-18 16:07:07 +00:00
pView = new GraphCtrlView( pModel, this );
pView->SetWorkArea( Rectangle( Point(), aGraphSize ) );
pView->EnableExtendedMouseEventDispatcher( sal_True );
pView->ShowSdrPage(pView->GetModel()->GetPage(0));
pView->SetFrameDragSingles( sal_True );
2000-09-18 16:07:07 +00:00
pView->SetMarkedPointsSmooth( SDRPATHSMOOTH_SYMMETRIC );
pView->SetEditMode( sal_True );
// #i72889# set neeeded flags
pView->SetPagePaintingAllowed(false);
pView->SetBufferedOutputAllowed(true);
pView->SetBufferedOverlayAllowed(true);
// Tell the accessibility object about the changes.
if (mpAccContext != NULL)
mpAccContext->setModelAndView (pModel, pView);
2000-09-18 16:07:07 +00:00
}
void GraphCtrl::SetGraphic( const Graphic& rGraphic, sal_Bool bNewModel )
2000-09-18 16:07:07 +00:00
{
// If possible we dither bitmaps for the display
2000-09-18 16:07:07 +00:00
if ( !bAnim && ( rGraphic.GetType() == GRAPHIC_BITMAP ) )
{
if ( rGraphic.IsTransparent() )
{
Bitmap aBmp( rGraphic.GetBitmap() );
DitherBitmap( aBmp );
aGraphic = Graphic( BitmapEx( aBmp, rGraphic.GetBitmapEx().GetMask() ) );
}
else
{
Bitmap aBmp( rGraphic.GetBitmap() );
DitherBitmap( aBmp );
aGraphic = aBmp;
}
}
else
aGraphic = rGraphic;
if ( aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
aGraphSize = Application::GetDefaultDevice()->PixelToLogic( aGraphic.GetPrefSize(), aMap100 );
else
aGraphSize = OutputDevice::LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 );
if ( bSdrMode && bNewModel )
InitSdrModel();
if ( aGraphSizeLink.IsSet() )
aGraphSizeLink.Call( this );
Resize();
Invalidate();
}
void GraphCtrl::Resize()
{
Control::Resize();
if ( aGraphSize.Width() && aGraphSize.Height() )
{
MapMode aDisplayMap( aMap100 );
Point aNewPos;
Size aNewSize;
const Size aWinSize = PixelToLogic( GetOutputSizePixel(), aDisplayMap );
const long nWidth = aWinSize.Width();
const long nHeight = aWinSize.Height();
double fGrfWH = (double) aGraphSize.Width() / aGraphSize.Height();
double fWinWH = (double) nWidth / nHeight;
// Adapt Bitmap to Thumb size
2000-09-18 16:07:07 +00:00
if ( fGrfWH < fWinWH)
{
aNewSize.Width() = (long) ( (double) nHeight * fGrfWH );
aNewSize.Height()= nHeight;
}
else
{
aNewSize.Width() = nWidth;
aNewSize.Height()= (long) ( (double) nWidth / fGrfWH );
}
aNewPos.X() = ( nWidth - aNewSize.Width() ) >> 1;
aNewPos.Y() = ( nHeight - aNewSize.Height() ) >> 1;
// Implementing MapMode for Engine
2000-09-18 16:07:07 +00:00
aDisplayMap.SetScaleX( Fraction( aNewSize.Width(), aGraphSize.Width() ) );
aDisplayMap.SetScaleY( Fraction( aNewSize.Height(), aGraphSize.Height() ) );
aDisplayMap.SetOrigin( LogicToLogic( aNewPos, aMap100, aDisplayMap ) );
SetMapMode( aDisplayMap );
}
Invalidate();
}
void GraphCtrl::Paint( const Rectangle& rRect )
{
// #i72889# used splitted repaint to be able to paint an own background
// even to the buffered view
const bool bGraphicValid(GRAPHIC_NONE != aGraphic.GetType());
2000-09-18 16:07:07 +00:00
if(bSdrMode)
{
SdrPaintWindow* pPaintWindow = pView->BeginCompleteRedraw(this);
if(bGraphicValid)
{
OutputDevice& rTarget = pPaintWindow->GetTargetOutputDevice();
rTarget.SetBackground(GetBackground());
rTarget.Erase();
aGraphic.Draw(&rTarget, Point(), aGraphSize);
}
const Region aRepaintRegion(rRect);
pView->DoCompleteRedraw(*pPaintWindow, aRepaintRegion);
CWS-TOOLING: integrate CWS aw061 2009-01-13 19:18:08 +0100 aw r266250 : #i96669# changed initialisation order in Embedded3DPrimitive2D::Embedded3DPrimitive2D due to TinderBox 2009-01-13 19:15:37 +0100 aw r266249 : #i96669# changed initialisation order in Embedded3DPrimitive2D::Embedded3DPrimitive2D due to TinderBox 2009-01-12 11:53:37 +0100 aw r266141 : #i97874# corrected include for TinderBox build 2009-01-08 17:48:23 +0100 aw r266029 : #i97874# extended SdrTextObj::ImpConvertAddText to copy needed attributes from original object 2009-01-08 14:59:08 +0100 aw r266015 : #i96350# added fallback to solid fill in shadow TabPage when no fill is defined to get a reasonable shadow preview 2009-01-08 12:40:49 +0100 aw r265995 : #i94832# remuved not needed E3DModifySceneSnapRectUpdater usages 2009-01-08 01:53:46 +0100 thb r265982 : #i94860# Blacklisting another ATI card/driver that causes blank screens 2009-01-08 01:46:38 +0100 thb r265981 : #i97853# Changed all gradient texture methods to use basegfx gradienttools. consolidated quite some code 2009-01-08 01:45:09 +0100 thb r265980 : #i97853# Added lerp methods, slight changes to have everything necessary contained in the ODFGradientInfo struct 2009-01-08 00:01:54 +0100 thb r265979 : #i97853# First part of the move - duplicated the stuff to basegfx 2009-01-06 16:23:09 +0100 aw r265930 : #i97197# Changed SwDrawVirtObj to work well with changed aOutRect and bBoundRectValid functionality 2009-01-06 12:41:24 +0100 aw r265909 : #i97784# corrected regression with connectors 2009-01-05 17:30:31 +0100 aw r265881 : #i97772# added missing usage of reduce factor for BitmapPrimitive creation 2009-01-05 12:24:01 +0100 aw r265863 : #i97321# added direct handling of HatchTexturePrimitive3D to not use it's decomposition for HitTest 2008-12-23 13:57:27 +0100 aw r265782 : #i96669# changed SW's FlyFrame paint fallback with primitives to use createLocalDecomposition since get2Decomposition does not have to stay virtual on the long run 2008-12-23 13:47:59 +0100 aw r265781 : #i96669# optimized impCreateTextPortionPrimitive to only create TextDecoratedPortionPrimitive2D when needed 2008-12-23 13:44:45 +0100 aw r265780 : #i96669# added B2DRange buffering to some primitive implementations where it is most necessary 2008-12-19 15:45:45 +0100 aw r265729 : #i96669# prepared TextPrimitives to work without DXarray, too. Had to rework impSplitSingleWords which gets active when a text portion has some word-wise decorations. Tested before committing 2008-12-19 15:44:16 +0100 aw r265728 : #i96669# corrected error in createPolygonFromUnitEllipseSegment which popped up when investigating 2008-12-18 17:45:58 +0100 aw r265708 : #i97149# added ActionChanged() call when visualisation object is modified 2008-12-18 15:34:42 +0100 aw r265695 : #i96598# corrected SdrPageObj's usage of aOutRect 2008-12-17 16:59:37 +0100 aw r265647 : #i96537# exchanged the marker for point number in string with correct one 2008-12-16 17:50:33 +0100 aw r265566 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer 2008-12-16 17:50:17 +0100 aw r265565 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer 2008-12-16 17:50:00 +0100 aw r265564 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer 2008-12-16 17:49:48 +0100 aw r265563 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer 2008-12-16 17:49:35 +0100 aw r265562 : #i93170# added a bool to EndDrawLayer() and corresponding mechanisms to allow to end without drawing FormLayer
2009-01-20 09:49:16 +00:00
pView->EndCompleteRedraw(*pPaintWindow, true);
}
else
{
// #i73381# in non-SdrMode, paint to local directly
if(bGraphicValid)
{
aGraphic.Draw(this, Point(), aGraphSize);
}
}
2000-09-18 16:07:07 +00:00
}
void GraphCtrl::SdrObjChanged( const SdrObject& )
2000-09-18 16:07:07 +00:00
{
}
void GraphCtrl::SdrObjCreated( const SdrObject& )
2000-09-18 16:07:07 +00:00
{
}
void GraphCtrl::MarkListHasChanged()
{
if ( aMarkObjLink.IsSet() )
aMarkObjLink.Call( this );
}
void GraphCtrl::KeyInput( const KeyEvent& rKEvt )
{
KeyCode aCode( rKEvt.GetKeyCode() );
bool bProc = false;
2000-09-18 16:07:07 +00:00
Dialog* pDialog = GetParentDialog();
2000-09-18 16:07:07 +00:00
switch ( aCode.GetCode() )
{
case KEY_DELETE:
case KEY_BACKSPACE:
{
if ( bSdrMode )
{
pView->DeleteMarked();
bProc = true;
if (!pView->AreObjectsMarked() && pDialog)
pDialog->GrabFocusToFirstControl();
}
}
break;
2000-09-18 16:07:07 +00:00
case KEY_ESCAPE:
{
if ( bSdrMode )
{
bool bGrabFocusToFirstControl = true;
2000-09-18 16:07:07 +00:00
if ( pView->IsAction() )
{
pView->BrkAction();
bGrabFocusToFirstControl = false;
2000-09-18 16:07:07 +00:00
}
else if ( pView->AreObjectsMarked() )
{
const SdrHdlList& rHdlList = pView->GetHdlList();
SdrHdl* pHdl = rHdlList.GetFocusHdl();
if(pHdl)
{
((SdrHdlList&)rHdlList).ResetFocusHdl();
bGrabFocusToFirstControl = false;
}
}
if (bGrabFocusToFirstControl && pDialog)
pDialog->GrabFocusToFirstControl();
bProc = true;
2000-09-18 16:07:07 +00:00
}
}
break;
case KEY_F11:
case KEY_TAB:
2000-09-18 16:07:07 +00:00
{
if( bSdrMode )
2000-09-18 16:07:07 +00:00
{
if( !aCode.IsMod1() && !aCode.IsMod2() )
{
bool bForward = !aCode.IsShift();
// select next object
if ( ! pView->MarkNextObj( bForward ))
{
// At first or last object. Cycle to the other end
// of the list.
pView->UnmarkAllObj();
pView->MarkNextObj (bForward);
}
bProc = true;
}
else if(aCode.IsMod1())
{
// select next handle
const SdrHdlList& rHdlList = pView->GetHdlList();
sal_Bool bForward(!aCode.IsShift());
((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
bProc = true;
}
2000-09-18 16:07:07 +00:00
}
}
break;
case KEY_END:
{
if ( aCode.IsMod1() )
{
// mark last object
pView->UnmarkAllObj();
pView->MarkNextObj(sal_False);
bProc = true;
}
}
break;
case KEY_HOME:
2000-09-18 16:07:07 +00:00
{
if ( aCode.IsMod1() )
2000-09-18 16:07:07 +00:00
{
pView->UnmarkAllObj();
pView->MarkNextObj(sal_True);
bProc = true;
}
}
break;
case KEY_UP:
case KEY_DOWN:
case KEY_LEFT:
case KEY_RIGHT:
{
long nX = 0;
long nY = 0;
if (aCode.GetCode() == KEY_UP)
{
// Scroll up
nX = 0;
nY =-1;
}
else if (aCode.GetCode() == KEY_DOWN)
{
// Scroll down
nX = 0;
nY = 1;
}
else if (aCode.GetCode() == KEY_LEFT)
{
// Scroll left
nX =-1;
nY = 0;
}
else if (aCode.GetCode() == KEY_RIGHT)
{
// Scroll right
nX = 1;
nY = 0;
}
if (pView->AreObjectsMarked() && !aCode.IsMod1() )
{
if(aCode.IsMod2())
2000-09-18 16:07:07 +00:00
{
// move in 1 pixel distance
Size aLogicSizeOnePixel = PixelToLogic(Size(1,1));
nX *= aLogicSizeOnePixel.Width();
nY *= aLogicSizeOnePixel.Height();
}
else
{
// old, fixed move distance
nX *= 100;
nY *= 100;
2000-09-18 16:07:07 +00:00
}
// II
const SdrHdlList& rHdlList = pView->GetHdlList();
SdrHdl* pHdl = rHdlList.GetFocusHdl();
if(0L == pHdl)
{
// restrict movement to WorkArea
const Rectangle& rWorkArea = pView->GetWorkArea();
if(!rWorkArea.IsEmpty())
{
Rectangle aMarkRect(pView->GetMarkedObjRect());
aMarkRect.Move(nX, nY);
if(!aMarkRect.IsInside(rWorkArea))
{
if(aMarkRect.Left() < rWorkArea.Left())
{
nX += rWorkArea.Left() - aMarkRect.Left();
}
if(aMarkRect.Right() > rWorkArea.Right())
{
nX -= aMarkRect.Right() - rWorkArea.Right();
}
if(aMarkRect.Top() < rWorkArea.Top())
{
nY += rWorkArea.Top() - aMarkRect.Top();
}
if(aMarkRect.Bottom() > rWorkArea.Bottom())
{
nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
}
}
}
// no handle selected
if(0 != nX || 0 != nY)
{
pView->MoveAllMarked(Size(nX, nY));
}
}
else
{
// move handle with index nHandleIndex
if(pHdl && (nX || nY))
{
// now move the Handle (nX, nY)
Point aStartPoint(pHdl->GetPos());
Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
const SdrDragStat& rDragStat = pView->GetDragStat();
// start dragging
pView->BegDragObj(aStartPoint, 0, pHdl, 0);
if(pView->IsDragObj())
{
2010-10-05 07:57:54 -05:00
bool bWasNoSnap = rDragStat.IsNoSnap();
sal_Bool bWasSnapEnabled = pView->IsSnapEnabled();
// switch snapping off
if(!bWasNoSnap)
((SdrDragStat&)rDragStat).SetNoSnap(sal_True);
if(bWasSnapEnabled)
pView->SetSnapEnabled(sal_False);
pView->MovAction(aEndPoint);
pView->EndDragObj();
// restore snap
if(!bWasNoSnap)
((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
if(bWasSnapEnabled)
pView->SetSnapEnabled(bWasSnapEnabled);
}
}
}
bProc = true;
2000-09-18 16:07:07 +00:00
}
}
break;
2002-04-12 10:54:45 +00:00
case KEY_SPACE:
{
const SdrHdlList& rHdlList = pView->GetHdlList();
SdrHdl* pHdl = rHdlList.GetFocusHdl();
if(pHdl)
{
if(pHdl->GetKind() == HDL_POLY)
{
// rescue ID of point with focus
sal_uInt32 nPol(pHdl->GetPolyNum());
sal_uInt32 nPnt(pHdl->GetPointNum());
2002-04-12 10:54:45 +00:00
if(pView->IsPointMarked(*pHdl))
{
if(rKEvt.GetKeyCode().IsShift())
{
pView->UnmarkPoint(*pHdl);
}
}
else
{
if(!rKEvt.GetKeyCode().IsShift())
{
pView->UnmarkAllPoints();
}
pView->MarkPoint(*pHdl);
}
if(0L == rHdlList.GetFocusHdl())
{
// restore point with focus
SdrHdl* pNewOne = 0L;
for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
{
SdrHdl* pAct = rHdlList.GetHdl(a);
if(pAct
&& pAct->GetKind() == HDL_POLY
&& pAct->GetPolyNum() == nPol
&& pAct->GetPointNum() == nPnt)
{
pNewOne = pAct;
}
}
if(pNewOne)
{
((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
}
}
bProc = true;
2002-04-12 10:54:45 +00:00
}
}
}
break;
2000-09-18 16:07:07 +00:00
default:
break;
}
if ( !bProc )
Control::KeyInput( rKEvt );
else
ReleaseMouse();
}
void GraphCtrl::MouseButtonDown( const MouseEvent& rMEvt )
{
if ( bSdrMode && ( rMEvt.GetClicks() < 2 ) )
{
const Point aLogPt( PixelToLogic( rMEvt.GetPosPixel() ) );
if ( !Rectangle( Point(), aGraphSize ).IsInside( aLogPt ) && !pView->IsEditMode() )
Control::MouseButtonDown( rMEvt );
else
{
// Get Focus for key inputs
2000-09-18 16:07:07 +00:00
GrabFocus();
if ( nPolyEdit )
{
SdrViewEvent aVEvt;
SdrHitKind eHit = pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
if ( nPolyEdit == SID_BEZIER_INSERT && eHit == SDRHIT_MARKEDOBJECT )
pView->BegInsObjPoint( aLogPt, rMEvt.IsMod1());
2000-09-18 16:07:07 +00:00
else
pView->MouseButtonDown( rMEvt, this );
}
else
pView->MouseButtonDown( rMEvt, this );
}
SdrObject* pCreateObj = pView->GetCreateObj();
// We want to realize the insert
2000-09-18 16:07:07 +00:00
if ( pCreateObj && !pCreateObj->GetUserCall() )
pCreateObj->SetUserCall( pUserCall );
SetPointer( pView->GetPreferredPointer( aLogPt, this ) );
2000-09-18 16:07:07 +00:00
}
else
Control::MouseButtonDown( rMEvt );
}
void GraphCtrl::MouseMove(const MouseEvent& rMEvt)
{
const Point aLogPos( PixelToLogic( rMEvt.GetPosPixel() ) );
if ( bSdrMode )
{
pView->MouseMove( rMEvt, this );
if( ( SID_BEZIER_INSERT == nPolyEdit ) &&
!pView->PickHandle( aLogPos ) &&
2000-09-18 16:07:07 +00:00
!pView->IsInsObjPoint() )
{
SetPointer( POINTER_CROSS );
}
else
SetPointer( pView->GetPreferredPointer( aLogPos, this ) );
2000-09-18 16:07:07 +00:00
}
else
Control::MouseButtonUp( rMEvt );
if ( aMousePosLink.IsSet() )
{
if ( Rectangle( Point(), aGraphSize ).IsInside( aLogPos ) )
aMousePos = aLogPos;
else
aMousePos = Point();
aMousePosLink.Call( this );
}
}
void GraphCtrl::MouseButtonUp(const MouseEvent& rMEvt)
{
if ( bSdrMode )
{
if ( pView->IsInsObjPoint() )
pView->EndInsObjPoint( SDRCREATE_FORCEEND );
else
pView->MouseButtonUp( rMEvt, this );
ReleaseMouse();
SetPointer( pView->GetPreferredPointer( PixelToLogic( rMEvt.GetPosPixel() ), this ) );
2000-09-18 16:07:07 +00:00
}
else
Control::MouseButtonUp( rMEvt );
}
SdrObject* GraphCtrl::GetSelectedSdrObject() const
{
SdrObject* pSdrObj = NULL;
if ( bSdrMode )
{
const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
2000-09-18 16:07:07 +00:00
if ( rMarkList.GetMarkCount() == 1 )
pSdrObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
2000-09-18 16:07:07 +00:00
}
return pSdrObj;
}
void GraphCtrl::SetEditMode( const sal_Bool _bEditMode )
2000-09-18 16:07:07 +00:00
{
if ( bSdrMode )
{
bEditMode = _bEditMode;
pView->SetEditMode( bEditMode );
eObjKind = OBJ_NONE;
pView->SetCurrentObj( sal::static_int_cast< sal_uInt16 >( eObjKind ) );
2000-09-18 16:07:07 +00:00
}
else
bEditMode = sal_False;
2000-09-18 16:07:07 +00:00
}
void GraphCtrl::SetPolyEditMode( const sal_uInt16 _nPolyEdit )
2000-09-18 16:07:07 +00:00
{
if ( bSdrMode && ( _nPolyEdit != nPolyEdit ) )
{
nPolyEdit = _nPolyEdit;
pView->SetFrameDragSingles( nPolyEdit == 0 );
}
else
nPolyEdit = 0;
}
void GraphCtrl::SetObjKind( const SdrObjKind _eObjKind )
{
if ( bSdrMode )
{
bEditMode = sal_False;
pView->SetEditMode( bEditMode );
eObjKind = _eObjKind;
pView->SetCurrentObj( sal::static_int_cast< sal_uInt16 >( eObjKind ) );
2000-09-18 16:07:07 +00:00
}
else
eObjKind = OBJ_NONE;
}
IMPL_LINK( GraphCtrl, UpdateHdl, Timer*, pTimer )
{
if ( aUpdateLink.IsSet() )
aUpdateLink.Call( this );
pTimer->Start();
return 0L;
}
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GraphCtrl::CreateAccessible()
{
if( mpAccContext == NULL )
{
Window* pParent = GetParent();
DBG_ASSERT( pParent, "-GraphCtrl::CreateAccessible(): No Parent!" );
if( pParent )
{
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccParent( pParent->GetAccessible() );
// Disable accessibility if no model/view data available
if( pView &&
pModel &&
xAccParent.is() )
{
mpAccContext = new SvxGraphCtrlAccessibleContext( xAccParent, *this );
mpAccContext->acquire();
}
}
}
return mpAccContext;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */