bump product version to 6.3.0.0.beta1
[LibreOffice.git] / reportdesign / source / ui / report / dlgedfunc.cxx
blob19aa6430884538f68ff1cabb9241736b962a56b3
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 <vcl/ptrstyle.hxx>
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 <strings.hxx>
53 #include <UndoEnv.hxx>
54 #include <RptModel.hxx>
55 #include <comphelper/propertysequence.hxx>
56 #include <tools/diagnose_ex.h>
58 #define DEFAUL_MOVE_SIZE 100
59 namespace rptui
61 using namespace ::com::sun::star;
64 IMPL_LINK_NOARG( DlgEdFunc, ScrollTimeout, Timer *, void )
66 ForceScroll( m_pParent->PixelToLogic( m_pParent->GetPointerPosPixel() ) );
70 void DlgEdFunc::ForceScroll( const Point& rPos )
72 aScrollTimer.Stop();
74 OReportWindow* pReportWindow = m_pParent->getSectionWindow()->getViewsWindow()->getView();
75 OScrollWindowHelper* pScrollWindow = pReportWindow->getScrollWindow();
77 Size aOut = pReportWindow->GetOutputSizePixel();
78 Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
79 aStartWidth *= m_pParent->GetMapMode().GetScaleX();
81 aOut.AdjustWidth( -static_cast<long>(aStartWidth) );
82 aOut.setHeight( m_pParent->GetOutputSizePixel().Height() );
84 Point aPos = pScrollWindow->getThumbPos();
85 aPos.setX( aPos.X() * 0.5 );
86 aPos.setY( aPos.Y() * 0.5 );
87 tools::Rectangle aOutRect( aPos, aOut );
88 aOutRect = m_pParent->PixelToLogic( aOutRect );
89 tools::Rectangle aWorkArea(Point(), pScrollWindow->getTotalSize());
90 aWorkArea.AdjustRight( -static_cast<long>(aStartWidth) );
91 aWorkArea = pScrollWindow->PixelToLogic( aWorkArea );
92 if( !aOutRect.IsInside( rPos ) && aWorkArea.IsInside( rPos ) )
94 ScrollBar& rHScroll = pScrollWindow->GetHScroll();
95 ScrollBar& rVScroll = pScrollWindow->GetVScroll();
96 ScrollType eH = ScrollType::LineDown,eV = ScrollType::LineDown;
97 if( rPos.X() < aOutRect.Left() )
98 eH = ScrollType::LineUp;
99 else if( rPos.X() <= aOutRect.Right() )
100 eH = ScrollType::DontKnow;
102 if( rPos.Y() < aOutRect.Top() )
103 eV = ScrollType::LineUp;
104 else if( rPos.Y() <= aOutRect.Bottom() )
105 eV = ScrollType::DontKnow;
107 rHScroll.DoScrollAction(eH);
108 rVScroll.DoScrollAction(eV);
111 aScrollTimer.Start();
114 DlgEdFunc::DlgEdFunc( OReportSection* _pParent )
115 : m_pParent(_pParent)
116 , m_rView(_pParent->getSectionView())
117 , m_pOverlappingObj(nullptr)
118 , m_nOverlappedControlColor(0)
119 , m_nOldColor(0)
120 , m_bSelectionMode(false)
121 , m_bUiActive(false)
122 , m_bShowPropertyBrowser(false)
124 aScrollTimer.SetInvokeHandler( LINK( this, DlgEdFunc, ScrollTimeout ) );
125 m_rView.SetActualWin( m_pParent);
126 aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
129 void DlgEdFunc::setOverlappedControlColor(Color _nColor)
131 m_nOverlappedControlColor = _nColor;
134 static Color lcl_setColorOfObject(const uno::Reference< uno::XInterface >& _xObj, Color _nColorTRGB)
136 Color nBackColor;
139 uno::Reference<report::XReportComponent> xComponent(_xObj, uno::UNO_QUERY_THROW);
140 uno::Reference< beans::XPropertySet > xProp(xComponent, uno::UNO_QUERY_THROW);
141 uno::Any aAny = xProp->getPropertyValue(PROPERTY_CONTROLBACKGROUND);
142 if (aAny.hasValue())
144 aAny >>= nBackColor;
145 // try to set background color at the ReportComponent
146 uno::Any aBlackColorAny = uno::makeAny(_nColorTRGB);
147 xProp->setPropertyValue(PROPERTY_CONTROLBACKGROUND, aBlackColorAny);
150 catch(uno::Exception&)
153 return nBackColor;
156 DlgEdFunc::~DlgEdFunc()
158 unColorizeOverlappedObj();
159 aScrollTimer.Stop();
163 bool DlgEdFunc::MouseButtonDown( const MouseEvent& rMEvt )
165 m_aMDPos = m_pParent->PixelToLogic( rMEvt.GetPosPixel() );
166 m_pParent->GrabFocus();
167 bool bHandled = false;
168 if ( rMEvt.IsLeft() )
170 if ( rMEvt.GetClicks() > 1 )
172 // show property browser
173 uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({
174 { "ShowProperties", uno::Any(true) }
175 }));
176 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_SHOW_PROPERTYBROWSER,aArgs);
177 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
178 // TODO character in shapes
179 // SdrViewEvent aVEvt;
180 // m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
181 // if ( aVEvt.pRootObj && aVEvt.pRootObj->ISA(SdrTextObj) )
182 // SetInEditMode(static_cast<SdrTextObj *>(aVEvt.pRootObj),rMEvt, sal_False);
183 bHandled = true;
185 else
187 SdrHdl* pHdl = m_rView.PickHandle(m_aMDPos);
189 // if selected object was hit, drag object
190 if ( pHdl!=nullptr || m_rView.IsMarkedHit(m_aMDPos) )
192 bHandled = true;
193 m_pParent->CaptureMouse();
194 m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, pHdl,&m_rView);
198 else if ( rMEvt.IsRight() && !rMEvt.IsLeft() && rMEvt.GetClicks() == 1 ) // mark object when context menu was selected
200 SdrPageView* pPV = m_rView.GetSdrPageView();
201 SdrViewEvent aVEvt;
202 if ( m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt) != SdrHitKind::MarkedObject && !rMEvt.IsShift() )
203 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
204 if ( aVEvt.pRootObj )
205 m_rView.MarkObj(aVEvt.pRootObj, pPV);
206 else
207 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
209 bHandled = true;
211 else if( !rMEvt.IsLeft() )
212 bHandled = true;
213 if ( !bHandled )
214 m_pParent->CaptureMouse();
215 return bHandled;
219 bool DlgEdFunc::MouseButtonUp( const MouseEvent& /*rMEvt*/ )
221 m_pParent->getSectionWindow()->getViewsWindow()->stopScrollTimer();
222 return false;
225 void DlgEdFunc::checkTwoCklicks(const MouseEvent& rMEvt)
227 deactivateOle();
229 const sal_uInt16 nClicks = rMEvt.GetClicks();
230 if ( nClicks == 2 && rMEvt.IsLeft() )
232 if ( m_rView.AreObjectsMarked() )
234 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
235 if (rMarkList.GetMarkCount() == 1)
237 const SdrMark* pMark = rMarkList.GetMark(0);
238 SdrObject* pObj = pMark->GetMarkedSdrObj();
239 activateOle(pObj);
245 void DlgEdFunc::stopScrollTimer()
247 unColorizeOverlappedObj();
248 aScrollTimer.Stop();
249 if ( m_pParent->IsMouseCaptured() )
250 m_pParent->ReleaseMouse();
254 bool DlgEdFunc::MouseMove( const MouseEvent& /*rMEvt*/ )
256 return false;
259 bool DlgEdFunc::handleKeyEvent(const KeyEvent& _rEvent)
261 bool bReturn = false;
263 if ( !m_bUiActive )
265 const vcl::KeyCode& rCode = _rEvent.GetKeyCode();
266 sal_uInt16 nCode = rCode.GetCode();
268 switch ( nCode )
270 case KEY_ESCAPE:
272 if ( m_pParent->getSectionWindow()->getViewsWindow()->IsAction() )
274 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
275 bReturn = true;
277 else if ( m_rView.IsTextEdit() )
279 m_rView.SdrEndTextEdit();
280 bReturn = true;
282 else if ( m_rView.AreObjectsMarked() )
284 const SdrHdlList& rHdlList = m_rView.GetHdlList();
285 SdrHdl* pHdl = rHdlList.GetFocusHdl();
286 if ( pHdl )
287 const_cast<SdrHdlList&>(rHdlList).ResetFocusHdl();
288 else
289 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
291 deactivateOle(true);
292 bReturn = false;
294 else
296 deactivateOle(true);
299 break;
300 case KEY_TAB:
302 if ( !rCode.IsMod1() && !rCode.IsMod2() )
304 // mark next object
305 if ( !m_rView.MarkNextObj( !rCode.IsShift() ) )
307 // if no next object, mark first/last
308 m_rView.UnmarkAllObj();
309 m_rView.MarkNextObj( !rCode.IsShift() );
312 if ( m_rView.AreObjectsMarked() )
313 m_rView.MakeVisible( m_rView.GetAllMarkedRect(), *m_pParent);
315 bReturn = true;
317 else if ( rCode.IsMod1() && rCode.IsMod2())
319 // selected handle
320 const SdrHdlList& rHdlList = m_rView.GetHdlList();
321 const_cast<SdrHdlList&>(rHdlList).TravelFocusHdl( !rCode.IsShift() );
323 // guarantee visibility of focused handle
324 SdrHdl* pHdl = rHdlList.GetFocusHdl();
325 if ( pHdl )
327 Point aHdlPosition( pHdl->GetPos() );
328 tools::Rectangle aVisRect( aHdlPosition - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) );
329 m_rView.MakeVisible( aVisRect, *m_pParent);
332 bReturn = true;
335 break;
336 case KEY_UP:
337 case KEY_DOWN:
338 case KEY_LEFT:
339 case KEY_RIGHT:
341 m_pParent->getSectionWindow()->getViewsWindow()->handleKey(rCode);
342 bReturn = true;
344 break;
345 case KEY_RETURN:
346 if ( !rCode.IsMod1() )
348 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
349 if ( rMarkList.GetMarkCount() == 1 )
351 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
352 activateOle(pObj);
355 break;
356 case KEY_DELETE:
357 if ( !rCode.IsMod1() && !rCode.IsMod2() )
359 bReturn = true;
360 break;
362 [[fallthrough]];
363 default:
365 bReturn = m_rView.KeyInput(_rEvent, m_pParent);
367 break;
371 if ( bReturn && m_pParent->IsMouseCaptured() )
372 m_pParent->ReleaseMouse();
374 return bReturn;
377 void DlgEdFunc::activateOle(SdrObject* _pObj)
379 if ( _pObj )
381 const sal_uInt16 nSdrObjKind = _pObj->GetObjIdentifier();
383 // OLE: activate
385 if (nSdrObjKind == OBJ_OLE2)
387 SdrOle2Obj* pOleObj = dynamic_cast<SdrOle2Obj*>(_pObj);
388 if (pOleObj && pOleObj->GetObjRef().is())
390 if (m_rView.IsTextEdit())
392 m_rView.SdrEndTextEdit();
395 pOleObj->AddOwnLightClient();
396 pOleObj->SetWindow(VCLUnoHelper::GetInterface(m_pParent));
399 pOleObj->GetObjRef()->changeState( embed::EmbedStates::UI_ACTIVE );
400 m_bUiActive = true;
401 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
402 m_bShowPropertyBrowser = rController.isCommandChecked(SID_SHOW_PROPERTYBROWSER);
403 if ( m_bShowPropertyBrowser )
404 rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >());
406 catch( uno::Exception& )
408 DBG_UNHANDLED_EXCEPTION("reportdesign");
415 void DlgEdFunc::deactivateOle(bool _bSelect)
417 OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
418 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
419 const sal_uLong nCount = rObjCache.size();
420 for(sal_uLong i = 0 ; i< nCount;++i)
422 SdrOle2Obj* pObj = rObjCache[i];
423 if ( m_pParent->getPage() == pObj->getSdrPageFromSdrObject() )
425 uno::Reference< embed::XEmbeddedObject > xObj = pObj->GetObjRef();
426 if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::UI_ACTIVE )
428 xObj->changeState( embed::EmbedStates::RUNNING );
429 m_bUiActive = false;
430 if ( m_bShowPropertyBrowser )
432 rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >());
435 if ( _bSelect )
437 SdrPageView* pPV = m_rView.GetSdrPageView();
438 m_rView.MarkObj(pObj, pPV);
445 void DlgEdFunc::colorizeOverlappedObject(SdrObject* _pOverlappedObj)
447 OObjectBase* pObj = dynamic_cast<OObjectBase*>(_pOverlappedObj);
448 if ( pObj )
450 const uno::Reference<report::XReportComponent>& xComponent = pObj->getReportComponent();
451 if (xComponent.is() && xComponent != m_xOverlappingObj)
453 OReportModel& rRptModel(static_cast< OReportModel& >(_pOverlappedObj->getSdrModelFromSdrObject()));
454 OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv());
456 // uncolorize an old object, if there is one
457 unColorizeOverlappedObj();
459 m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor);
460 m_xOverlappingObj = xComponent;
461 m_pOverlappingObj = _pOverlappedObj;
466 void DlgEdFunc::unColorizeOverlappedObj()
468 // uncolorize an old object, if there is one
469 if (m_xOverlappingObj.is())
471 OReportModel& rRptModel(static_cast< OReportModel& >(m_pOverlappingObj->getSdrModelFromSdrObject()));
472 OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv());
474 lcl_setColorOfObject(m_xOverlappingObj, m_nOldColor);
475 m_xOverlappingObj = nullptr;
476 m_pOverlappingObj = nullptr;
480 bool DlgEdFunc::isOverlapping(const MouseEvent& rMEvt)
482 SdrViewEvent aVEvt;
483 bool bOverlapping = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONUP, aVEvt) != SdrHitKind::NONE;
484 if (bOverlapping && aVEvt.pObj)
486 colorizeOverlappedObject(aVEvt.pObj);
488 else
490 unColorizeOverlappedObj();
493 return bOverlapping;
496 void DlgEdFunc::checkMovementAllowed(const MouseEvent& rMEvt)
498 if ( m_pParent->getSectionWindow()->getViewsWindow()->IsDragObj() )
500 if ( isRectangleHit(rMEvt) )
502 // there is another component under use, break action
503 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
505 // object was dragged
506 Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
507 if (m_bSelectionMode)
509 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
511 else
513 bool bControlKeyPressed = rMEvt.IsMod1();
514 // Don't allow points smaller 0
515 if (bControlKeyPressed && (aPnt.Y() < 0))
517 aPnt.setY( 0 );
519 if (m_rView.IsDragResize())
521 // we resize the object don't resize to above sections
522 if ( aPnt.Y() < 0 )
524 aPnt.setY( 0 );
527 m_pParent->getSectionWindow()->getViewsWindow()->EndDragObj( bControlKeyPressed, &m_rView, aPnt );
529 m_pParent->getSectionWindow()->getViewsWindow()->ForceMarkedToAnotherPage();
530 m_pParent->Invalidate(InvalidateFlags::Children);
532 else
533 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
536 bool DlgEdFunc::isOnlyCustomShapeMarked()
538 bool bReturn = true;
539 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
540 for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
542 SdrMark* pMark = rMarkList.GetMark(i);
543 SdrObject* pObj = pMark->GetMarkedSdrObj();
544 if (pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE)
546 // we found an object in the marked objects, which is not a custom shape.
547 bReturn = false;
548 break;
551 return bReturn;
554 bool DlgEdFunc::isRectangleHit(const MouseEvent& rMEvt)
556 if (isOnlyCustomShapeMarked())
558 return false;
561 SdrViewEvent aVEvt;
562 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::MOVE, aVEvt);
563 bool bIsSetPoint = (eHit == SdrHitKind::UnmarkedObject);
564 if ( !bIsSetPoint )
566 // no drag rect, we have to check every single select rect
567 const SdrDragStat& rDragStat = m_rView.GetDragStat();
568 if (rDragStat.GetDragMethod() != nullptr)
570 SdrObjListIter aIter(m_pParent->getPage(),SdrIterMode::DeepNoGroups);
571 SdrObject* pObjIter = nullptr;
572 // loop through all marked objects and check if there new rect overlapps an old one.
573 while( (pObjIter = aIter.Next()) != nullptr && !bIsSetPoint)
575 if ( m_rView.IsObjMarked(pObjIter)
576 && (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr) )
578 tools::Rectangle aNewRect = pObjIter->GetLastBoundRect();
579 long nDx = rDragStat.IsHorFixed() ? 0 : rDragStat.GetDX();
580 long nDy = rDragStat.IsVerFixed() ? 0 : rDragStat.GetDY();
581 if ( (nDx + aNewRect.Left()) < 0 )
582 nDx = -aNewRect.Left();
583 if ( (nDy + aNewRect.Top()) < 0 )
584 nDy = -aNewRect.Top();
586 if ( rDragStat.GetDragMethod()->getMoveOnly() )
587 aNewRect.Move(nDx,nDy);
588 else
589 ::ResizeRect(aNewRect,rDragStat.GetRef1(),rDragStat.GetXFact(),rDragStat.GetYFact());
592 SdrObject* pObjOverlapped = isOver(aNewRect,*m_pParent->getPage(),m_rView,false,pObjIter, ISOVER_IGNORE_CUSTOMSHAPES);
593 bIsSetPoint = pObjOverlapped != nullptr;
594 if (pObjOverlapped && !m_bSelectionMode)
596 colorizeOverlappedObject(pObjOverlapped);
602 else if ( aVEvt.pObj && (aVEvt.pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE) && !m_bSelectionMode)
604 colorizeOverlappedObject(aVEvt.pObj);
606 else
607 bIsSetPoint = false;
608 return bIsSetPoint;
611 bool DlgEdFunc::setMovementPointer(const MouseEvent& rMEvt)
613 bool bIsSetPoint = isRectangleHit(rMEvt);
614 if ( bIsSetPoint )
615 m_pParent->SetPointer( PointerStyle::NotAllowed );
616 else
618 bool bCtrlKey = rMEvt.IsMod1();
619 if (bCtrlKey)
621 m_pParent->SetPointer( PointerStyle::MoveDataLink );
622 bIsSetPoint = true;
625 return bIsSetPoint;
629 DlgEdFuncInsert::DlgEdFuncInsert( OReportSection* _pParent ) :
630 DlgEdFunc( _pParent )
632 m_rView.SetCreateMode();
636 DlgEdFuncInsert::~DlgEdFuncInsert()
638 m_rView.SetEditMode();
642 bool DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt )
644 if ( DlgEdFunc::MouseButtonDown(rMEvt) )
645 return true;
647 SdrViewEvent aVEvt;
648 sal_Int16 nId = m_rView.GetCurrentObjIdentifier();
650 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
652 if (eHit == SdrHitKind::UnmarkedObject && nId != OBJ_CUSTOMSHAPE)
654 // there is an object under the mouse cursor, but not a customshape
655 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
656 return false;
659 // if no action, create object
660 if (!m_pParent->getSectionWindow()->getViewsWindow()->IsAction())
662 deactivateOle(true);
663 if ( m_pParent->getSectionWindow()->getViewsWindow()->HasSelection() )
664 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(&m_rView);
665 m_rView.BegCreateObj(m_aMDPos);
666 m_pParent->getSectionWindow()->getViewsWindow()->createDefault();
669 return true;
673 bool DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt )
675 if ( DlgEdFunc::MouseButtonUp( rMEvt ) )
676 return true;
678 const Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
679 const sal_uInt16 nHitLog = sal_uInt16 ( m_pParent->PixelToLogic(Size(3,0)).Width() );
681 bool bReturn = true;
682 // object creation active?
683 if ( m_rView.IsCreateObj() )
685 if ( isOver(m_rView.GetCreateObj(),*m_pParent->getPage(),m_rView) )
687 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
688 // BrkAction disables the create mode
689 m_rView.SetCreateMode();
690 return true;
693 m_rView.EndCreateObj(SdrCreateCmd::ForceEnd);
695 if ( !m_rView.AreObjectsMarked() )
697 m_rView.MarkObj(aPos, nHitLog);
700 bReturn = m_rView.AreObjectsMarked();
701 if ( bReturn )
703 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
704 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
705 for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
707 SdrMark* pMark = rMarkList.GetMark(i);
708 OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj());
709 if ( pObj && !pObj->IsEmpty() )
711 pObj->initializeChart(rController.getModel());
716 else
717 checkMovementAllowed(rMEvt);
719 if ( !m_rView.AreObjectsMarked() &&
720 std::abs(m_aMDPos.X() - aPos.X()) < nHitLog &&
721 std::abs(m_aMDPos.Y() - aPos.Y()) < nHitLog &&
722 !rMEvt.IsShift() && !rMEvt.IsMod2() )
724 SdrPageView* pPV = m_rView.GetSdrPageView();
725 SdrViewEvent aVEvt;
726 m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
727 m_rView.MarkObj(aVEvt.pRootObj, pPV);
729 checkTwoCklicks(rMEvt);
730 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
731 return bReturn;
735 bool DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt )
737 if ( DlgEdFunc::MouseMove(rMEvt ) )
738 return true;
739 Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
741 if ( m_rView.IsCreateObj() )
743 m_rView.SetOrtho(SdrObjCustomShape::doConstructOrthogonal(m_rView.getReportSection()->getSectionWindow()->getViewsWindow()->getShapeType()) ? !rMEvt.IsShift() : rMEvt.IsShift());
744 m_rView.SetAngleSnapEnabled(rMEvt.IsShift());
747 bool bIsSetPoint = false;
748 if ( m_rView.IsAction() )
750 if ( m_rView.IsDragResize() )
752 // we resize the object don't resize to above sections
753 if ( aPos.Y() < 0 )
755 aPos.setY( 0 );
758 bIsSetPoint = setMovementPointer(rMEvt);
759 ForceScroll(aPos);
760 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPos,&m_rView, false);
763 if ( !bIsSetPoint )
764 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPos, m_pParent) );
766 return true;
770 DlgEdFuncSelect::DlgEdFuncSelect( OReportSection* _pParent ) :
771 DlgEdFunc( _pParent )
776 DlgEdFuncSelect::~DlgEdFuncSelect()
781 bool DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
783 m_bSelectionMode = false;
784 if ( DlgEdFunc::MouseButtonDown(rMEvt) )
785 return true;
787 SdrViewEvent aVEvt;
788 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
789 if( eHit == SdrHitKind::UnmarkedObject )
791 // if not multi selection, unmark all
792 if ( !rMEvt.IsShift() )
793 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
795 if ( m_rView.MarkObj(m_aMDPos) && rMEvt.IsLeft() )
797 // drag object
798 m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, m_rView.PickHandle(m_aMDPos), &m_rView);
800 else
802 // select object
803 m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj(m_aMDPos,&m_rView);
806 else
808 if( !rMEvt.IsShift() )
809 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
811 if ( rMEvt.GetClicks() == 1 )
813 m_bSelectionMode = true;
814 m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos ,&m_rView);
816 else
818 m_rView.SdrBeginTextEdit( aVEvt.pRootObj,m_rView.GetSdrPageView(),m_pParent );
822 return true;
826 bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt )
828 if ( DlgEdFunc::MouseButtonUp( rMEvt ) )
829 return true;
831 // get view from parent
832 const Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
834 if ( rMEvt.IsLeft() ) // left mousebutton pressed
835 checkMovementAllowed(rMEvt);
837 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
838 checkTwoCklicks(rMEvt);
840 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPnt, m_pParent) );
842 if ( !m_bUiActive )
843 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
844 m_bSelectionMode = false;
845 return true;
849 bool DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
851 if ( DlgEdFunc::MouseMove(rMEvt ) )
852 return true;
854 Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
855 bool bIsSetPoint = false;
857 if ( m_rView.IsAction() ) // Drag Mode
859 bIsSetPoint = setMovementPointer(rMEvt);
860 ForceScroll(aPnt);
861 if (m_rView.GetDragMethod()==nullptr)
863 // create a selection
864 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, false);
866 else
868 if ( m_rView.IsDragResize() )
870 // we resize the object don't resize to above sections
871 if ( aPnt.Y() < 0 )
873 aPnt.setY( 0 );
876 // drag or resize an object
877 bool bControlKey = rMEvt.IsMod1();
878 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, bControlKey);
882 if ( !bIsSetPoint )
884 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPnt, m_pParent) );
886 // restore color
887 unColorizeOverlappedObj();
890 return true;
896 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */