bump product version to 5.0.4.1
[LibreOffice.git] / reportdesign / source / ui / report / dlgedfunc.cxx
blob6b7791a306e0b7aaa616180f5bf5d4b532d5baa0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include <vcl/scrbar.hxx>
20 #include <vcl/svapp.hxx>
21 #include <vcl/seleng.hxx>
22 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
23 #include <com/sun/star/embed/EmbedStates.hpp>
24 #include <com/sun/star/embed/XEmbeddedObject.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <svx/svdview.hxx>
28 #include <svx/svdpagv.hxx>
29 #include <editeng/outlobj.hxx>
30 #include <editeng/unolingu.hxx>
31 #include <svx/svdetc.hxx>
32 #include <editeng/editstat.hxx>
33 #include <svx/svdoutl.hxx>
34 #include <svx/svddrgmt.hxx>
35 #include <svx/svdoashp.hxx>
36 #include <svx/svxids.hrc>
37 #include <svx/svditer.hxx>
39 #include <toolkit/helper/vclunohelper.hxx>
41 #include "dlgedfunc.hxx"
42 #include "ReportSection.hxx"
43 #include "DesignView.hxx"
44 #include "ReportController.hxx"
45 #include "SectionView.hxx"
46 #include "ViewsWindow.hxx"
47 #include "ReportWindow.hxx"
48 #include "RptObject.hxx"
49 #include "ScrollHelper.hxx"
50 #include "UITools.hxx"
52 #include <uistrings.hrc>
53 #include "UndoEnv.hxx"
54 #include <RptModel.hxx>
55 #include <tools/diagnose_ex.h>
57 #define DEFAUL_MOVE_SIZE 100
58 namespace rptui
60 using namespace ::com::sun::star;
65 IMPL_LINK_NOARG_TYPED( DlgEdFunc, ScrollTimeout, Timer *, void )
67 ForceScroll( m_pParent->PixelToLogic( m_pParent->GetPointerPosPixel() ) );
72 void DlgEdFunc::ForceScroll( const Point& rPos )
74 aScrollTimer.Stop();
76 OReportWindow* pReportWindow = m_pParent->getSectionWindow()->getViewsWindow()->getView();
77 OScrollWindowHelper* pScrollWindow = pReportWindow->getScrollWindow();
79 Size aOut = pReportWindow->GetOutputSizePixel();
80 Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
81 aStartWidth *= m_pParent->GetMapMode().GetScaleX();
83 aOut.Width() -= (long)aStartWidth;
84 aOut.Height() = m_pParent->GetOutputSizePixel().Height();
86 Point aPos = pScrollWindow->getThumbPos();
87 aPos.X() *= 0.5;
88 aPos.Y() *= 0.5;
89 Rectangle aOutRect( aPos, aOut );
90 aOutRect = m_pParent->PixelToLogic( aOutRect );
91 Rectangle aWorkArea(Point(), pScrollWindow->getTotalSize());
92 aWorkArea.Right() -= (long)aStartWidth;
93 aWorkArea = pScrollWindow->PixelToLogic( aWorkArea );
94 if( !aOutRect.IsInside( rPos ) && aWorkArea.IsInside( rPos ) )
96 ScrollBar& rHScroll = pScrollWindow->GetHScroll();
97 ScrollBar& rVScroll = pScrollWindow->GetVScroll();
98 ScrollType eH = SCROLL_LINEDOWN,eV = SCROLL_LINEDOWN;
99 if( rPos.X() < aOutRect.Left() )
100 eH = SCROLL_LINEUP;
101 else if( rPos.X() <= aOutRect.Right() )
102 eH = SCROLL_DONTKNOW;
104 if( rPos.Y() < aOutRect.Top() )
105 eV = SCROLL_LINEUP;
106 else if( rPos.Y() <= aOutRect.Bottom() )
107 eV = SCROLL_DONTKNOW;
109 rHScroll.DoScrollAction(eH);
110 rVScroll.DoScrollAction(eV);
113 aScrollTimer.Start();
116 DlgEdFunc::DlgEdFunc( OReportSection* _pParent )
117 : m_pParent(_pParent)
118 , m_rView(_pParent->getSectionView())
119 , m_xOverlappingObj(NULL)
120 , m_pOverlappingObj(NULL)
121 , m_nOverlappedControlColor(0)
122 , m_nOldColor(0)
123 , m_bSelectionMode(false)
124 , m_bUiActive(false)
125 , m_bShowPropertyBrowser(false)
127 aScrollTimer.SetTimeoutHdl( LINK( this, DlgEdFunc, ScrollTimeout ) );
128 m_rView.SetActualWin( m_pParent);
129 aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
132 void DlgEdFunc::setOverlappedControlColor(sal_Int32 _nColor)
134 m_nOverlappedControlColor = _nColor;
137 sal_Int32 lcl_setColorOfObject(uno::Reference< uno::XInterface > _xObj, long _nColorTRGB)
139 sal_Int32 nBackColor = 0;
142 uno::Reference<report::XReportComponent> xComponent(_xObj, uno::UNO_QUERY_THROW);
143 uno::Reference< beans::XPropertySet > xProp(xComponent, uno::UNO_QUERY_THROW);
144 uno::Any aAny = xProp->getPropertyValue(PROPERTY_CONTROLBACKGROUND);
145 if (aAny.hasValue())
147 aAny >>= nBackColor;
148 // try to set background color at the ReportComponent
149 uno::Any aBlackColorAny = uno::makeAny(_nColorTRGB);
150 xProp->setPropertyValue(PROPERTY_CONTROLBACKGROUND, aBlackColorAny);
153 catch(uno::Exception&)
156 return nBackColor;
159 DlgEdFunc::~DlgEdFunc()
161 unColorizeOverlappedObj();
162 aScrollTimer.Stop();
167 bool DlgEdFunc::MouseButtonDown( const MouseEvent& rMEvt )
169 m_aMDPos = m_pParent->PixelToLogic( rMEvt.GetPosPixel() );
170 m_pParent->GrabFocus();
171 bool bHandled = false;
172 if ( rMEvt.IsLeft() )
174 if ( rMEvt.GetClicks() > 1 )
176 // show property browser
177 if ( m_pParent->GetMode() != RPTUI_READONLY )
179 uno::Sequence<beans::PropertyValue> aArgs(1);
180 aArgs[0].Name = "ShowProperties";
181 aArgs[0].Value <<= sal_True;
182 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_SHOW_PROPERTYBROWSER,aArgs);
183 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
184 // TODO character in shapes
185 // SdrViewEvent aVEvt;
186 // m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
187 // if ( aVEvt.pRootObj && aVEvt.pRootObj->ISA(SdrTextObj) )
188 // SetInEditMode(static_cast<SdrTextObj *>(aVEvt.pRootObj),rMEvt, sal_False);
189 bHandled = true;
192 else
194 SdrHdl* pHdl = m_rView.PickHandle(m_aMDPos);
196 // if selected object was hit, drag object
197 if ( pHdl!=NULL || m_rView.IsMarkedHit(m_aMDPos) )
199 bHandled = true;
200 m_pParent->CaptureMouse();
201 m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, pHdl,&m_rView);
205 else if ( rMEvt.IsRight() && !rMEvt.IsLeft() && rMEvt.GetClicks() == 1 ) // mark object when context menu was selected
207 SdrPageView* pPV = m_rView.GetSdrPageView();
208 SdrViewEvent aVEvt;
209 if ( m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt) != SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() )
210 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
211 if ( aVEvt.pRootObj )
212 m_rView.MarkObj(aVEvt.pRootObj, pPV);
213 else
214 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
216 bHandled = true;
218 else if( !rMEvt.IsLeft() )
219 bHandled = true;
220 if ( !bHandled )
221 m_pParent->CaptureMouse();
222 return bHandled;
227 bool DlgEdFunc::MouseButtonUp( const MouseEvent& /*rMEvt*/ )
229 bool bHandled = false;
230 m_pParent->getSectionWindow()->getViewsWindow()->stopScrollTimer();
231 return bHandled;
234 void DlgEdFunc::checkTwoCklicks(const MouseEvent& rMEvt)
236 deactivateOle();
238 const sal_uInt16 nClicks = rMEvt.GetClicks();
239 if ( nClicks == 2 && rMEvt.IsLeft() )
241 if ( m_rView.AreObjectsMarked() )
243 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
244 if (rMarkList.GetMarkCount() == 1)
246 const SdrMark* pMark = rMarkList.GetMark(0);
247 SdrObject* pObj = pMark->GetMarkedSdrObj();
248 activateOle(pObj);
254 void DlgEdFunc::stopScrollTimer()
256 unColorizeOverlappedObj();
257 aScrollTimer.Stop();
258 if ( m_pParent->IsMouseCaptured() )
259 m_pParent->ReleaseMouse();
263 bool DlgEdFunc::MouseMove( const MouseEvent& /*rMEvt*/ )
265 return false;
268 bool DlgEdFunc::handleKeyEvent(const KeyEvent& _rEvent)
270 bool bReturn = false;
272 if ( !m_bUiActive )
274 const vcl::KeyCode& rCode = _rEvent.GetKeyCode();
275 sal_uInt16 nCode = rCode.GetCode();
277 switch ( nCode )
279 case KEY_ESCAPE:
281 if ( m_pParent->getSectionWindow()->getViewsWindow()->IsAction() )
283 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
284 bReturn = true;
286 else if ( m_rView.IsTextEdit() )
288 m_rView.SdrEndTextEdit();
289 bReturn = true;
291 else if ( m_rView.AreObjectsMarked() )
293 const SdrHdlList& rHdlList = m_rView.GetHdlList();
294 SdrHdl* pHdl = rHdlList.GetFocusHdl();
295 if ( pHdl )
296 ((SdrHdlList&)rHdlList).ResetFocusHdl();
297 else
298 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
300 deactivateOle(true);
301 bReturn = false;
303 else
305 deactivateOle(true);
308 break;
309 case KEY_TAB:
311 if ( !rCode.IsMod1() && !rCode.IsMod2() )
313 // mark next object
314 if ( !m_rView.MarkNextObj( !rCode.IsShift() ) )
316 // if no next object, mark first/last
317 m_rView.UnmarkAllObj();
318 m_rView.MarkNextObj( !rCode.IsShift() );
321 if ( m_rView.AreObjectsMarked() )
322 m_rView.MakeVisible( m_rView.GetAllMarkedRect(), *m_pParent);
324 bReturn = true;
326 else if ( rCode.IsMod1() && rCode.IsMod2())
328 // selected handle
329 const SdrHdlList& rHdlList = m_rView.GetHdlList();
330 ((SdrHdlList&)rHdlList).TravelFocusHdl( !rCode.IsShift() );
332 // guarantee visibility of focused handle
333 SdrHdl* pHdl = rHdlList.GetFocusHdl();
334 if ( pHdl )
336 Point aHdlPosition( pHdl->GetPos() );
337 Rectangle aVisRect( aHdlPosition - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) );
338 m_rView.MakeVisible( aVisRect, *m_pParent);
341 bReturn = true;
344 break;
345 case KEY_UP:
346 case KEY_DOWN:
347 case KEY_LEFT:
348 case KEY_RIGHT:
350 m_pParent->getSectionWindow()->getViewsWindow()->handleKey(rCode);
351 bReturn = true;
353 break;
354 case KEY_RETURN:
355 if ( !rCode.IsMod1() )
357 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
358 if ( rMarkList.GetMarkCount() == 1 )
360 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
361 activateOle(pObj);
364 break;
365 case KEY_DELETE:
366 if ( !rCode.IsMod1() && !rCode.IsMod2() )
368 bReturn = true;
369 break;
371 // run through
372 default:
374 bReturn = m_rView.KeyInput(_rEvent, m_pParent);
376 break;
380 if ( bReturn && m_pParent->IsMouseCaptured() )
381 m_pParent->ReleaseMouse();
383 return bReturn;
386 void DlgEdFunc::activateOle(SdrObject* _pObj)
388 if ( _pObj )
390 const sal_uInt16 nSdrObjKind = _pObj->GetObjIdentifier();
392 // OLE: activate
394 if (nSdrObjKind == OBJ_OLE2)
396 bool bIsInplaceOle = false;
397 if (!bIsInplaceOle)
399 SdrOle2Obj* pOleObj = dynamic_cast<SdrOle2Obj*>(_pObj);
400 if (pOleObj && pOleObj->GetObjRef().is())
402 if (m_rView.IsTextEdit())
404 m_rView.SdrEndTextEdit();
407 pOleObj->AddOwnLightClient();
408 pOleObj->SetWindow(VCLUnoHelper::GetInterface(m_pParent));
411 pOleObj->GetObjRef()->changeState( embed::EmbedStates::UI_ACTIVE );
412 m_bUiActive = true;
413 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
414 m_bShowPropertyBrowser = rController.isCommandChecked(SID_SHOW_PROPERTYBROWSER);
415 if ( m_bShowPropertyBrowser )
416 rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >());
418 catch( uno::Exception& )
420 DBG_UNHANDLED_EXCEPTION();
428 void DlgEdFunc::deactivateOle(bool _bSelect)
430 OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
431 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
432 const sal_uLong nCount = rObjCache.size();
433 for(sal_uLong i = 0 ; i< nCount;++i)
435 SdrOle2Obj* pObj = rObjCache[i];
436 if ( m_pParent->getPage() == pObj->GetPage() )
438 uno::Reference< embed::XEmbeddedObject > xObj = pObj->GetObjRef();
439 if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::UI_ACTIVE )
441 xObj->changeState( embed::EmbedStates::RUNNING );
442 m_bUiActive = false;
443 if ( m_bShowPropertyBrowser )
445 rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >());
448 if ( _bSelect )
450 SdrPageView* pPV = m_rView.GetSdrPageView();
451 m_rView.MarkObj(pObj, pPV);
458 void DlgEdFunc::colorizeOverlappedObject(SdrObject* _pOverlappedObj)
460 OObjectBase* pObj = dynamic_cast<OObjectBase*>(_pOverlappedObj);
461 if ( pObj )
463 uno::Reference<report::XReportComponent> xComponent = pObj->getReportComponent();
464 if (xComponent.is() && xComponent != m_xOverlappingObj)
466 OReportModel* pRptModel = static_cast<OReportModel*>(_pOverlappedObj->GetModel());
467 if ( pRptModel )
469 OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
471 // uncolorize an old object, if there is one
472 unColorizeOverlappedObj();
474 m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor);
475 m_xOverlappingObj = xComponent;
476 m_pOverlappingObj = _pOverlappedObj;
482 void DlgEdFunc::unColorizeOverlappedObj()
484 // uncolorize an old object, if there is one
485 if (m_xOverlappingObj.is())
487 OReportModel* pRptModel = static_cast<OReportModel*>(m_pOverlappingObj->GetModel());
488 if ( pRptModel )
490 OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
492 lcl_setColorOfObject(m_xOverlappingObj, m_nOldColor);
493 m_xOverlappingObj = NULL;
494 m_pOverlappingObj = NULL;
499 bool DlgEdFunc::isOverlapping(const MouseEvent& rMEvt)
501 SdrViewEvent aVEvt;
502 bool bOverlapping = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONUP, aVEvt) != SDRHIT_NONE;
503 if (bOverlapping && aVEvt.pObj)
505 colorizeOverlappedObject(aVEvt.pObj);
507 else
509 unColorizeOverlappedObj();
512 return bOverlapping;
515 void DlgEdFunc::checkMovementAllowed(const MouseEvent& rMEvt)
517 if ( m_pParent->getSectionWindow()->getViewsWindow()->IsDragObj() )
519 if ( isRectangleHit(rMEvt) )
521 // there is an other component under use, break action
522 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
524 // object was dragged
525 Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
526 if (m_bSelectionMode)
528 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
530 else
532 bool bControlKeyPressed = rMEvt.IsMod1();
533 // Don't allow points smaller 0
534 if (bControlKeyPressed && (aPnt.Y() < 0))
536 aPnt.Y() = 0;
538 if (m_rView.IsDragResize())
540 // we resize the object don't resize to above sections
541 if ( aPnt.Y() < 0 )
543 aPnt.Y() = 0;
546 m_pParent->getSectionWindow()->getViewsWindow()->EndDragObj( bControlKeyPressed, &m_rView, aPnt );
548 m_pParent->getSectionWindow()->getViewsWindow()->ForceMarkedToAnotherPage();
549 m_pParent->Invalidate(INVALIDATE_CHILDREN);
551 else
552 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
555 bool DlgEdFunc::isOnlyCustomShapeMarked()
557 bool bReturn = true;
558 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
559 for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
561 SdrMark* pMark = rMarkList.GetMark(i);
562 SdrObject* pObj = pMark->GetMarkedSdrObj();
563 if (pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE)
565 // we found an object in the marked objects, which is not a custom shape.
566 bReturn = false;
567 break;
570 return bReturn;
573 bool DlgEdFunc::isRectangleHit(const MouseEvent& rMEvt)
575 if (isOnlyCustomShapeMarked())
577 return false;
580 SdrViewEvent aVEvt;
581 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::MOVE, aVEvt);
582 bool bIsSetPoint = (eHit == SDRHIT_UNMARKEDOBJECT);
583 if ( !bIsSetPoint )
585 // no drag rect, we have to check every single select rect
586 const SdrDragStat& rDragStat = m_rView.GetDragStat();
587 if (rDragStat.GetDragMethod() != NULL)
589 SdrObjListIter aIter(*m_pParent->getPage(),IM_DEEPNOGROUPS);
590 SdrObject* pObjIter = NULL;
591 // loop through all marked objects and check if there new rect overlapps an old one.
592 while( (pObjIter = aIter.Next()) != NULL && !bIsSetPoint)
594 if ( m_rView.IsObjMarked(pObjIter)
595 && (dynamic_cast<OUnoObject*>(pObjIter) != NULL || dynamic_cast<OOle2Obj*>(pObjIter) != NULL) )
597 Rectangle aNewRect = pObjIter->GetLastBoundRect();
598 long nDx = rDragStat.IsHorFixed() ? 0 : rDragStat.GetDX();
599 long nDy = rDragStat.IsVerFixed() ? 0 : rDragStat.GetDY();
600 if ( (nDx + aNewRect.Left()) < 0 )
601 nDx = -aNewRect.Left();
602 if ( (nDy + aNewRect.Top()) < 0 )
603 nDy = -aNewRect.Top();
605 if ( rDragStat.GetDragMethod()->getMoveOnly() )
606 aNewRect.Move(nDx,nDy);
607 else
608 ::ResizeRect(aNewRect,rDragStat.GetRef1(),rDragStat.GetXFact(),rDragStat.GetYFact());
611 SdrObject* pObjOverlapped = isOver(aNewRect,*m_pParent->getPage(),m_rView,false,pObjIter, ISOVER_IGNORE_CUSTOMSHAPES);
612 bIsSetPoint = pObjOverlapped != nullptr;
613 if (pObjOverlapped && !m_bSelectionMode)
615 colorizeOverlappedObject(pObjOverlapped);
621 else if ( aVEvt.pObj && (aVEvt.pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE) && !m_bSelectionMode)
623 colorizeOverlappedObject(aVEvt.pObj);
625 else
626 bIsSetPoint = false;
627 return bIsSetPoint;
630 bool DlgEdFunc::setMovementPointer(const MouseEvent& rMEvt)
632 bool bIsSetPoint = isRectangleHit(rMEvt);
633 if ( bIsSetPoint )
634 m_pParent->SetPointer( Pointer(PointerStyle::NotAllowed));
635 else
637 bool bCtrlKey = rMEvt.IsMod1();
638 (void)bCtrlKey;
639 if (bCtrlKey)
641 m_pParent->SetPointer( Pointer(PointerStyle::MoveDataLink ));
642 bIsSetPoint = true;
645 return bIsSetPoint;
649 DlgEdFuncInsert::DlgEdFuncInsert( OReportSection* _pParent ) :
650 DlgEdFunc( _pParent )
652 m_rView.SetCreateMode( true );
657 DlgEdFuncInsert::~DlgEdFuncInsert()
659 m_rView.SetEditMode( true );
664 bool DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt )
666 if ( DlgEdFunc::MouseButtonDown(rMEvt) )
667 return true;
669 SdrViewEvent aVEvt;
670 sal_Int16 nId = m_rView.GetCurrentObjIdentifier();
672 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
674 if (eHit == SDRHIT_UNMARKEDOBJECT && nId != OBJ_CUSTOMSHAPE)
676 // there is an object under the mouse cursor, but not a customshape
677 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
678 return false;
681 // if no action, create object
682 if (!m_pParent->getSectionWindow()->getViewsWindow()->IsAction())
684 deactivateOle(true);
685 if ( m_pParent->getSectionWindow()->getViewsWindow()->HasSelection() )
686 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(&m_rView);
687 m_rView.BegCreateObj(m_aMDPos);
688 m_pParent->getSectionWindow()->getViewsWindow()->createDefault();
691 return true;
695 bool DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt )
697 if ( DlgEdFunc::MouseButtonUp( rMEvt ) )
698 return true;
700 const Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
701 const sal_uInt16 nHitLog = sal_uInt16 ( m_pParent->PixelToLogic(Size(3,0)).Width() );
703 bool bReturn = true;
704 // object creation active?
705 if ( m_rView.IsCreateObj() )
707 if ( isOver(m_rView.GetCreateObj(),*m_pParent->getPage(),m_rView) )
709 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
710 // BrkAction disables the create mode
711 m_rView.SetCreateMode( true );
712 return true;
715 m_rView.EndCreateObj(SDRCREATE_FORCEEND);
717 if ( !m_rView.AreObjectsMarked() )
719 m_rView.MarkObj(aPos, nHitLog);
722 bReturn = m_rView.AreObjectsMarked();
723 if ( bReturn )
725 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
726 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
727 for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
729 SdrMark* pMark = rMarkList.GetMark(i);
730 OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj());
731 if ( pObj && !pObj->IsEmpty() )
733 pObj->initializeChart(rController.getModel());
738 else
739 checkMovementAllowed(rMEvt);
741 if ( !m_rView.AreObjectsMarked() &&
742 std::abs(m_aMDPos.X() - aPos.X()) < nHitLog &&
743 std::abs(m_aMDPos.Y() - aPos.Y()) < nHitLog &&
744 !rMEvt.IsShift() && !rMEvt.IsMod2() )
746 SdrPageView* pPV = m_rView.GetSdrPageView();
747 SdrViewEvent aVEvt;
748 m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
749 m_rView.MarkObj(aVEvt.pRootObj, pPV);
751 checkTwoCklicks(rMEvt);
752 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
753 return bReturn;
758 bool DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt )
760 if ( DlgEdFunc::MouseMove(rMEvt ) )
761 return true;
762 Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
764 if ( m_rView.IsCreateObj() )
766 m_rView.SetOrtho(SdrObjCustomShape::doConstructOrthogonal(m_rView.getReportSection()->getSectionWindow()->getViewsWindow()->getShapeType()) ? !rMEvt.IsShift() : rMEvt.IsShift());
767 m_rView.SetAngleSnapEnabled(rMEvt.IsShift());
770 bool bIsSetPoint = false;
771 if ( m_rView.IsAction() )
773 if ( m_rView.IsDragResize() )
775 // we resize the object don't resize to above sections
776 if ( aPos.Y() < 0 )
778 aPos.Y() = 0;
781 bIsSetPoint = setMovementPointer(rMEvt);
782 ForceScroll(aPos);
783 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPos,&m_rView, m_rView.GetDragMethod() == NULL, false);
786 if ( !bIsSetPoint )
787 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPos, m_pParent) );
789 return true;
794 DlgEdFuncSelect::DlgEdFuncSelect( OReportSection* _pParent ) :
795 DlgEdFunc( _pParent )
801 DlgEdFuncSelect::~DlgEdFuncSelect()
807 bool DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
809 m_bSelectionMode = false;
810 if ( DlgEdFunc::MouseButtonDown(rMEvt) )
811 return true;
813 SdrViewEvent aVEvt;
814 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
815 if( eHit == SDRHIT_UNMARKEDOBJECT )
817 // if not multi selection, unmark all
818 if ( !rMEvt.IsShift() )
819 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
821 if ( m_rView.MarkObj(m_aMDPos) && rMEvt.IsLeft() )
823 // drag object
824 m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, m_rView.PickHandle(m_aMDPos), &m_rView);
826 else
828 // select object
829 m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj(m_aMDPos,&m_rView);
832 else
834 if( !rMEvt.IsShift() )
835 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
837 if ( rMEvt.GetClicks() == 1 )
839 m_bSelectionMode = true;
840 m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos ,&m_rView);
842 else
844 m_rView.SdrBeginTextEdit( aVEvt.pRootObj,m_rView.GetSdrPageView(),m_pParent, false );
848 return true;
853 bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt )
855 if ( DlgEdFunc::MouseButtonUp( rMEvt ) )
856 return true;
858 // get view from parent
859 const Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
861 if ( rMEvt.IsLeft() ) // left mousebutton pressed
862 checkMovementAllowed(rMEvt);
864 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
865 checkTwoCklicks(rMEvt);
867 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPnt, m_pParent) );
869 if ( !m_bUiActive )
870 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
871 m_bSelectionMode = false;
872 return true;
877 bool DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
879 if ( DlgEdFunc::MouseMove(rMEvt ) )
880 return true;
882 Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
883 bool bIsSetPoint = false;
885 if ( m_rView.IsAction() ) // Drag Mode
887 bIsSetPoint = setMovementPointer(rMEvt);
888 ForceScroll(aPnt);
889 if (m_rView.GetDragMethod()==NULL)
891 // create a selection
892 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, true, false);
894 else
896 if ( m_rView.IsDragResize() )
898 // we resize the object don't resize to above sections
899 if ( aPnt.Y() < 0 )
901 aPnt.Y() = 0;
904 // drag or resize an object
905 bool bControlKey = rMEvt.IsMod1();
906 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, false, bControlKey);
910 if ( !bIsSetPoint )
912 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPnt, m_pParent) );
914 // restore color
915 unColorizeOverlappedObj();
918 return true;
924 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */