Use o3tl::convert in Math
[LibreOffice.git] / reportdesign / source / ui / report / dlgedfunc.cxx
blobe258f659e05bd9a8d5212fe2661b6142c78ee86c
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/seleng.hxx>
21 #include <vcl/ptrstyle.hxx>
22 #include <com/sun/star/embed/EmbedStates.hpp>
23 #include <com/sun/star/embed/XEmbeddedObject.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <svx/svdview.hxx>
27 #include <svx/svdpagv.hxx>
28 #include <svx/svdetc.hxx>
29 #include <svx/svddrgmt.hxx>
30 #include <svx/svdoashp.hxx>
31 #include <svx/svxids.hrc>
32 #include <svx/svditer.hxx>
34 #include <toolkit/helper/vclunohelper.hxx>
36 #include <dlgedfunc.hxx>
37 #include <ReportSection.hxx>
38 #include <DesignView.hxx>
39 #include <ReportController.hxx>
40 #include <SectionView.hxx>
41 #include <ViewsWindow.hxx>
42 #include <ReportWindow.hxx>
43 #include <RptObject.hxx>
44 #include <ScrollHelper.hxx>
45 #include <UITools.hxx>
47 #include <strings.hxx>
48 #include <UndoEnv.hxx>
49 #include <RptModel.hxx>
50 #include <comphelper/propertysequence.hxx>
51 #include <tools/diagnose_ex.h>
53 #define DEFAUL_MOVE_SIZE 100
54 namespace rptui
56 using namespace ::com::sun::star;
59 IMPL_LINK_NOARG( DlgEdFunc, ScrollTimeout, Timer *, void )
61 ForceScroll( m_pParent->PixelToLogic( m_pParent->GetPointerPosPixel() ) );
65 void DlgEdFunc::ForceScroll( const Point& rPos )
67 aScrollTimer.Stop();
69 OReportWindow* pReportWindow = m_pParent->getSectionWindow()->getViewsWindow()->getView();
70 OScrollWindowHelper* pScrollWindow = pReportWindow->getScrollWindow();
72 Size aOut = pReportWindow->GetOutputSizePixel();
73 Fraction aStartWidth(tools::Long(REPORT_STARTMARKER_WIDTH));
74 aStartWidth *= m_pParent->GetMapMode().GetScaleX();
76 aOut.AdjustWidth( -static_cast<tools::Long>(aStartWidth) );
77 aOut.setHeight( m_pParent->GetOutputSizePixel().Height() );
79 Point aPos = pScrollWindow->getThumbPos();
80 aPos.setX( aPos.X() * 0.5 );
81 aPos.setY( aPos.Y() * 0.5 );
82 tools::Rectangle aOutRect( aPos, aOut );
83 aOutRect = m_pParent->PixelToLogic( aOutRect );
84 tools::Rectangle aWorkArea(Point(), pScrollWindow->getTotalSize());
85 aWorkArea.AdjustRight( -static_cast<tools::Long>(aStartWidth) );
86 aWorkArea = pScrollWindow->PixelToLogic( aWorkArea );
87 if( !aOutRect.Contains( rPos ) && aWorkArea.Contains( rPos ) )
89 ScrollBar& rHScroll = pScrollWindow->GetHScroll();
90 ScrollBar& rVScroll = pScrollWindow->GetVScroll();
91 ScrollType eH = ScrollType::LineDown,eV = ScrollType::LineDown;
92 if( rPos.X() < aOutRect.Left() )
93 eH = ScrollType::LineUp;
94 else if( rPos.X() <= aOutRect.Right() )
95 eH = ScrollType::DontKnow;
97 if( rPos.Y() < aOutRect.Top() )
98 eV = ScrollType::LineUp;
99 else if( rPos.Y() <= aOutRect.Bottom() )
100 eV = ScrollType::DontKnow;
102 rHScroll.DoScrollAction(eH);
103 rVScroll.DoScrollAction(eV);
106 aScrollTimer.Start();
109 DlgEdFunc::DlgEdFunc( OReportSection* _pParent )
110 : m_pParent(_pParent)
111 , m_rView(_pParent->getSectionView())
112 , aScrollTimer("reportdesign DlgEdFunc aScrollTimer")
113 , m_pOverlappingObj(nullptr)
114 , m_nOverlappedControlColor(0)
115 , m_nOldColor(0)
116 , m_bSelectionMode(false)
117 , m_bUiActive(false)
118 , m_bShowPropertyBrowser(false)
120 aScrollTimer.SetInvokeHandler( LINK( this, DlgEdFunc, ScrollTimeout ) );
121 m_rView.SetActualWin( m_pParent->GetOutDev() );
122 aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
125 void DlgEdFunc::setOverlappedControlColor(Color _nColor)
127 m_nOverlappedControlColor = _nColor;
130 static Color lcl_setColorOfObject(const uno::Reference< uno::XInterface >& _xObj, Color _nColorTRGB)
132 Color nBackColor;
135 uno::Reference<report::XReportComponent> xComponent(_xObj, uno::UNO_QUERY_THROW);
136 uno::Reference< beans::XPropertySet > xProp(xComponent, uno::UNO_QUERY_THROW);
137 uno::Any aAny = xProp->getPropertyValue(PROPERTY_CONTROLBACKGROUND);
138 if (aAny.hasValue())
140 aAny >>= nBackColor;
141 // try to set background color at the ReportComponent
142 uno::Any aBlackColorAny = uno::makeAny(_nColorTRGB);
143 xProp->setPropertyValue(PROPERTY_CONTROLBACKGROUND, aBlackColorAny);
146 catch(uno::Exception&)
149 return nBackColor;
152 DlgEdFunc::~DlgEdFunc()
154 unColorizeOverlappedObj();
155 aScrollTimer.Stop();
159 bool DlgEdFunc::MouseButtonDown( const MouseEvent& rMEvt )
161 m_aMDPos = m_pParent->PixelToLogic( rMEvt.GetPosPixel() );
162 m_pParent->GrabFocus();
163 bool bHandled = false;
164 if ( rMEvt.IsLeft() )
166 if ( rMEvt.GetClicks() > 1 )
168 // show property browser
169 uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({
170 { "ShowProperties", uno::Any(true) }
171 }));
172 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_SHOW_PROPERTYBROWSER,aArgs);
173 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
174 // TODO character in shapes
175 // SdrViewEvent aVEvt;
176 // m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
177 // if ( aVEvt.mpRootObj && aVEvt.pRootObj->ISA(SdrTextObj) )
178 // SetInEditMode(static_cast<SdrTextObj *>(aVEvt.mpRootObj),rMEvt, sal_False);
179 bHandled = true;
181 else
183 SdrHdl* pHdl = m_rView.PickHandle(m_aMDPos);
185 // if selected object was hit, drag object
186 if ( pHdl!=nullptr || m_rView.IsMarkedHit(m_aMDPos) )
188 bHandled = true;
189 m_pParent->CaptureMouse();
190 m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, pHdl,&m_rView);
194 else if ( rMEvt.IsRight() && !rMEvt.IsLeft() && rMEvt.GetClicks() == 1 ) // mark object when context menu was selected
196 SdrPageView* pPV = m_rView.GetSdrPageView();
197 SdrViewEvent aVEvt;
198 if ( m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt) != SdrHitKind::MarkedObject && !rMEvt.IsShift() )
199 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
200 if ( aVEvt.mpRootObj )
201 m_rView.MarkObj(aVEvt.mpRootObj, pPV);
202 else
203 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
205 bHandled = true;
207 else if( !rMEvt.IsLeft() )
208 bHandled = true;
209 if ( !bHandled )
210 m_pParent->CaptureMouse();
211 return bHandled;
215 bool DlgEdFunc::MouseButtonUp( const MouseEvent& /*rMEvt*/ )
217 m_pParent->getSectionWindow()->getViewsWindow()->stopScrollTimer();
218 return false;
221 void DlgEdFunc::checkTwoClicks(const MouseEvent& rMEvt)
223 deactivateOle();
225 const sal_uInt16 nClicks = rMEvt.GetClicks();
226 if ( !(nClicks == 2 && rMEvt.IsLeft()) )
227 return;
229 if ( m_rView.AreObjectsMarked() )
231 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
232 if (rMarkList.GetMarkCount() == 1)
234 const SdrMark* pMark = rMarkList.GetMark(0);
235 SdrObject* pObj = pMark->GetMarkedSdrObj();
236 activateOle(pObj);
241 void DlgEdFunc::stopScrollTimer()
243 unColorizeOverlappedObj();
244 aScrollTimer.Stop();
245 if ( m_pParent->IsMouseCaptured() )
246 m_pParent->ReleaseMouse();
250 bool DlgEdFunc::MouseMove( const MouseEvent& /*rMEvt*/ )
252 return false;
255 bool DlgEdFunc::handleKeyEvent(const KeyEvent& _rEvent)
257 bool bReturn = false;
259 if ( !m_bUiActive )
261 const vcl::KeyCode& rCode = _rEvent.GetKeyCode();
262 sal_uInt16 nCode = rCode.GetCode();
264 switch ( nCode )
266 case KEY_ESCAPE:
268 if ( m_pParent->getSectionWindow()->getViewsWindow()->IsAction() )
270 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
271 bReturn = true;
273 else if ( m_rView.IsTextEdit() )
275 m_rView.SdrEndTextEdit();
276 bReturn = true;
278 else if ( m_rView.AreObjectsMarked() )
280 const SdrHdlList& rHdlList = m_rView.GetHdlList();
281 SdrHdl* pHdl = rHdlList.GetFocusHdl();
282 if ( pHdl )
283 const_cast<SdrHdlList&>(rHdlList).ResetFocusHdl();
284 else
285 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
287 deactivateOle(true);
288 bReturn = false;
290 else
292 deactivateOle(true);
295 break;
296 case KEY_TAB:
298 if ( !rCode.IsMod1() && !rCode.IsMod2() )
300 // mark next object
301 if ( !m_rView.MarkNextObj( !rCode.IsShift() ) )
303 // if no next object, mark first/last
304 m_rView.UnmarkAllObj();
305 m_rView.MarkNextObj( !rCode.IsShift() );
308 if ( m_rView.AreObjectsMarked() )
309 m_rView.MakeVisible( m_rView.GetAllMarkedRect(), *m_pParent);
311 bReturn = true;
313 else if ( rCode.IsMod1() && rCode.IsMod2())
315 // selected handle
316 const SdrHdlList& rHdlList = m_rView.GetHdlList();
317 const_cast<SdrHdlList&>(rHdlList).TravelFocusHdl( !rCode.IsShift() );
319 // guarantee visibility of focused handle
320 SdrHdl* pHdl = rHdlList.GetFocusHdl();
321 if ( pHdl )
323 Point aHdlPosition( pHdl->GetPos() );
324 tools::Rectangle aVisRect( aHdlPosition - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) );
325 m_rView.MakeVisible( aVisRect, *m_pParent);
328 bReturn = true;
331 break;
332 case KEY_UP:
333 case KEY_DOWN:
334 case KEY_LEFT:
335 case KEY_RIGHT:
337 m_pParent->getSectionWindow()->getViewsWindow()->handleKey(rCode);
338 bReturn = true;
340 break;
341 case KEY_RETURN:
342 if ( !rCode.IsMod1() )
344 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
345 if ( rMarkList.GetMarkCount() == 1 )
347 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
348 activateOle(pObj);
351 break;
352 case KEY_DELETE:
353 if ( !rCode.IsMod1() && !rCode.IsMod2() )
355 bReturn = true;
356 break;
358 [[fallthrough]];
359 default:
361 bReturn = m_rView.KeyInput(_rEvent, m_pParent);
363 break;
367 if ( bReturn && m_pParent->IsMouseCaptured() )
368 m_pParent->ReleaseMouse();
370 return bReturn;
373 void DlgEdFunc::activateOle(SdrObject* _pObj)
375 if ( !_pObj )
376 return;
378 const sal_uInt16 nSdrObjKind = _pObj->GetObjIdentifier();
380 // OLE: activate
382 if (nSdrObjKind != OBJ_OLE2)
383 return;
385 SdrOle2Obj* pOleObj = dynamic_cast<SdrOle2Obj*>(_pObj);
386 if (!(pOleObj && pOleObj->GetObjRef().is()))
387 return;
389 if (m_rView.IsTextEdit())
391 m_rView.SdrEndTextEdit();
394 pOleObj->AddOwnLightClient();
395 pOleObj->SetWindow(VCLUnoHelper::GetInterface(m_pParent));
398 pOleObj->GetObjRef()->changeState( embed::EmbedStates::UI_ACTIVE );
399 m_bUiActive = true;
400 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
401 m_bShowPropertyBrowser = rController.isCommandChecked(SID_SHOW_PROPERTYBROWSER);
402 if ( m_bShowPropertyBrowser )
403 rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >());
405 catch( uno::Exception& )
407 DBG_UNHANDLED_EXCEPTION("reportdesign");
411 void DlgEdFunc::deactivateOle(bool _bSelect)
413 OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
414 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
415 const size_t nCount = rObjCache.size();
416 for(size_t i = 0 ; i < nCount;++i)
418 SdrOle2Obj* pObj = rObjCache[i];
419 if ( m_pParent->getPage() == pObj->getSdrPageFromSdrObject() )
421 uno::Reference< embed::XEmbeddedObject > xObj = pObj->GetObjRef();
422 if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::UI_ACTIVE )
424 xObj->changeState( embed::EmbedStates::RUNNING );
425 m_bUiActive = false;
426 if ( m_bShowPropertyBrowser )
428 rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >());
431 if ( _bSelect )
433 SdrPageView* pPV = m_rView.GetSdrPageView();
434 m_rView.MarkObj(pObj, pPV);
441 void DlgEdFunc::colorizeOverlappedObject(SdrObject* _pOverlappedObj)
443 OObjectBase* pObj = dynamic_cast<OObjectBase*>(_pOverlappedObj);
444 if ( !pObj )
445 return;
447 const uno::Reference<report::XReportComponent>& xComponent = pObj->getReportComponent();
448 if (xComponent.is() && xComponent != m_xOverlappingObj)
450 OReportModel& rRptModel(static_cast< OReportModel& >(_pOverlappedObj->getSdrModelFromSdrObject()));
451 OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv());
453 // uncolorize an old object, if there is one
454 unColorizeOverlappedObj();
456 m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor);
457 m_xOverlappingObj = xComponent;
458 m_pOverlappingObj = _pOverlappedObj;
462 void DlgEdFunc::unColorizeOverlappedObj()
464 // uncolorize an old object, if there is one
465 if (m_xOverlappingObj.is())
467 OReportModel& rRptModel(static_cast< OReportModel& >(m_pOverlappingObj->getSdrModelFromSdrObject()));
468 OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv());
470 lcl_setColorOfObject(m_xOverlappingObj, m_nOldColor);
471 m_xOverlappingObj = nullptr;
472 m_pOverlappingObj = nullptr;
476 bool DlgEdFunc::isOverlapping(const MouseEvent& rMEvt)
478 SdrViewEvent aVEvt;
479 bool bOverlapping = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONUP, aVEvt) != SdrHitKind::NONE;
480 if (bOverlapping && aVEvt.mpObj)
482 colorizeOverlappedObject(aVEvt.mpObj);
484 else
486 unColorizeOverlappedObj();
489 return bOverlapping;
492 void DlgEdFunc::checkMovementAllowed(const MouseEvent& rMEvt)
494 if ( m_pParent->getSectionWindow()->getViewsWindow()->IsDragObj() )
496 if ( isRectangleHit(rMEvt) )
498 // there is another component under use, break action
499 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
501 // object was dragged
502 Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
503 if (m_bSelectionMode)
505 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
507 else
509 bool bControlKeyPressed = rMEvt.IsMod1();
510 // Don't allow points smaller 0
511 if (bControlKeyPressed && (aPnt.Y() < 0))
513 aPnt.setY( 0 );
515 if (m_rView.IsDragResize())
517 // we resize the object don't resize to above sections
518 if ( aPnt.Y() < 0 )
520 aPnt.setY( 0 );
523 m_pParent->getSectionWindow()->getViewsWindow()->EndDragObj( bControlKeyPressed, &m_rView, aPnt );
525 m_pParent->getSectionWindow()->getViewsWindow()->ForceMarkedToAnotherPage();
526 m_pParent->Invalidate(InvalidateFlags::Children);
528 else
529 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
532 bool DlgEdFunc::isOnlyCustomShapeMarked() const
534 bool bReturn = true;
535 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
536 for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
538 SdrMark* pMark = rMarkList.GetMark(i);
539 SdrObject* pObj = pMark->GetMarkedSdrObj();
540 if (pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE)
542 // we found an object in the marked objects, which is not a custom shape.
543 bReturn = false;
544 break;
547 return bReturn;
550 bool DlgEdFunc::isRectangleHit(const MouseEvent& rMEvt)
552 if (isOnlyCustomShapeMarked())
554 return false;
557 SdrViewEvent aVEvt;
558 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::MOVE, aVEvt);
559 bool bIsSetPoint = (eHit == SdrHitKind::UnmarkedObject);
560 if ( !bIsSetPoint )
562 // no drag rect, we have to check every single select rect
563 const SdrDragStat& rDragStat = m_rView.GetDragStat();
564 if (rDragStat.GetDragMethod() != nullptr)
566 SdrObjListIter aIter(m_pParent->getPage(),SdrIterMode::DeepNoGroups);
567 // loop through all marked objects and check if there new rect overlapps an old one.
568 for (;;)
570 SdrObject* pObjIter = aIter.Next();
571 if( !pObjIter || bIsSetPoint)
572 break;
573 if ( m_rView.IsObjMarked(pObjIter)
574 && (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr) )
576 tools::Rectangle aNewRect = pObjIter->GetLastBoundRect();
577 tools::Long nDx = rDragStat.IsHorFixed() ? 0 : rDragStat.GetDX();
578 tools::Long nDy = rDragStat.IsVerFixed() ? 0 : rDragStat.GetDY();
579 if ( (nDx + aNewRect.Left()) < 0 )
580 nDx = -aNewRect.Left();
581 if ( (nDy + aNewRect.Top()) < 0 )
582 nDy = -aNewRect.Top();
584 if ( rDragStat.GetDragMethod()->getMoveOnly() )
585 aNewRect.Move(nDx,nDy);
586 else
587 ::ResizeRect(aNewRect,rDragStat.GetRef1(),rDragStat.GetXFact(),rDragStat.GetYFact());
590 SdrObject* pObjOverlapped = isOver(aNewRect,*m_pParent->getPage(),m_rView,false,pObjIter, ISOVER_IGNORE_CUSTOMSHAPES);
591 bIsSetPoint = pObjOverlapped != nullptr;
592 if (pObjOverlapped && !m_bSelectionMode)
594 colorizeOverlappedObject(pObjOverlapped);
600 else if (aVEvt.mpObj && (aVEvt.mpObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE) && !m_bSelectionMode)
602 colorizeOverlappedObject(aVEvt.mpObj);
604 else
605 bIsSetPoint = false;
606 return bIsSetPoint;
609 bool DlgEdFunc::setMovementPointer(const MouseEvent& rMEvt)
611 bool bIsSetPoint = isRectangleHit(rMEvt);
612 if ( bIsSetPoint )
613 m_pParent->SetPointer( PointerStyle::NotAllowed );
614 else
616 bool bCtrlKey = rMEvt.IsMod1();
617 if (bCtrlKey)
619 m_pParent->SetPointer( PointerStyle::MoveDataLink );
620 bIsSetPoint = true;
623 return bIsSetPoint;
627 DlgEdFuncInsert::DlgEdFuncInsert( OReportSection* _pParent ) :
628 DlgEdFunc( _pParent )
630 m_rView.SetCreateMode();
634 DlgEdFuncInsert::~DlgEdFuncInsert()
636 m_rView.SetEditMode();
640 bool DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt )
642 if ( DlgEdFunc::MouseButtonDown(rMEvt) )
643 return true;
645 SdrViewEvent aVEvt;
646 sal_Int16 nId = m_rView.GetCurrentObjIdentifier();
648 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
650 if (eHit == SdrHitKind::UnmarkedObject && nId != OBJ_CUSTOMSHAPE)
652 // there is an object under the mouse cursor, but not a customshape
653 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
654 return false;
657 // if no action, create object
658 if (!m_pParent->getSectionWindow()->getViewsWindow()->IsAction())
660 deactivateOle(true);
661 if ( m_pParent->getSectionWindow()->getViewsWindow()->HasSelection() )
662 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(&m_rView);
663 m_rView.BegCreateObj(m_aMDPos);
664 m_pParent->getSectionWindow()->getViewsWindow()->createDefault();
667 return true;
671 bool DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt )
673 if ( DlgEdFunc::MouseButtonUp( rMEvt ) )
674 return true;
676 const Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
677 const sal_uInt16 nHitLog = sal_uInt16 ( m_pParent->PixelToLogic(Size(3,0)).Width() );
679 bool bReturn = true;
680 // object creation active?
681 if ( m_rView.IsCreateObj() )
683 if ( isOver(m_rView.GetCreateObj(),*m_pParent->getPage(),m_rView) )
685 m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
686 // BrkAction disables the create mode
687 m_rView.SetCreateMode();
688 return true;
691 m_rView.EndCreateObj(SdrCreateCmd::ForceEnd);
693 if ( !m_rView.AreObjectsMarked() )
695 m_rView.MarkObj(aPos, nHitLog);
698 bReturn = m_rView.AreObjectsMarked();
699 if ( bReturn )
701 OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
702 const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
703 for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
705 SdrMark* pMark = rMarkList.GetMark(i);
706 OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj());
707 if ( pObj && !pObj->IsEmpty() )
709 pObj->initializeChart(rController.getModel());
714 else
715 checkMovementAllowed(rMEvt);
717 if ( !m_rView.AreObjectsMarked() &&
718 std::abs(m_aMDPos.X() - aPos.X()) < nHitLog &&
719 std::abs(m_aMDPos.Y() - aPos.Y()) < nHitLog &&
720 !rMEvt.IsShift() && !rMEvt.IsMod2() )
722 SdrPageView* pPV = m_rView.GetSdrPageView();
723 SdrViewEvent aVEvt;
724 m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
725 m_rView.MarkObj(aVEvt.mpRootObj, pPV);
727 checkTwoClicks(rMEvt);
728 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
729 return bReturn;
733 bool DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt )
735 if ( DlgEdFunc::MouseMove(rMEvt ) )
736 return true;
737 Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
739 if ( m_rView.IsCreateObj() )
741 m_rView.SetOrtho(SdrObjCustomShape::doConstructOrthogonal(m_rView.getReportSection()->getSectionWindow()->getViewsWindow()->getShapeType()) ? !rMEvt.IsShift() : rMEvt.IsShift());
742 m_rView.SetAngleSnapEnabled(rMEvt.IsShift());
745 bool bIsSetPoint = false;
746 if ( m_rView.IsAction() )
748 if ( m_rView.IsDragResize() )
750 // we resize the object don't resize to above sections
751 if ( aPos.Y() < 0 )
753 aPos.setY( 0 );
756 bIsSetPoint = setMovementPointer(rMEvt);
757 ForceScroll(aPos);
758 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPos,&m_rView, false);
761 if ( !bIsSetPoint )
762 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPos, m_pParent->GetOutDev()) );
764 return true;
768 DlgEdFuncSelect::DlgEdFuncSelect( OReportSection* _pParent ) :
769 DlgEdFunc( _pParent )
774 DlgEdFuncSelect::~DlgEdFuncSelect()
779 bool DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
781 m_bSelectionMode = false;
782 if ( DlgEdFunc::MouseButtonDown(rMEvt) )
783 return true;
785 SdrViewEvent aVEvt;
786 const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
787 if( eHit == SdrHitKind::UnmarkedObject )
789 // if not multi selection, unmark all
790 if ( !rMEvt.IsShift() )
791 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
793 if ( m_rView.MarkObj(m_aMDPos) && rMEvt.IsLeft() )
795 // drag object
796 m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, m_rView.PickHandle(m_aMDPos), &m_rView);
798 else
800 // select object
801 m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj(m_aMDPos,&m_rView);
804 else
806 if( !rMEvt.IsShift() )
807 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(nullptr);
809 if ( rMEvt.GetClicks() == 1 )
811 m_bSelectionMode = true;
812 m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos ,&m_rView);
814 else
816 m_rView.SdrBeginTextEdit( aVEvt.mpRootObj,m_rView.GetSdrPageView(),m_pParent );
820 return true;
824 bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt )
826 if ( DlgEdFunc::MouseButtonUp( rMEvt ) )
827 return true;
829 // get view from parent
830 const Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
832 if ( rMEvt.IsLeft() ) // left mousebutton pressed
833 checkMovementAllowed(rMEvt);
835 m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
836 checkTwoClicks(rMEvt);
838 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPnt, m_pParent->GetOutDev() ) );
840 if ( !m_bUiActive )
841 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
842 m_bSelectionMode = false;
843 return true;
847 bool DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
849 if ( DlgEdFunc::MouseMove(rMEvt ) )
850 return true;
852 Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
853 bool bIsSetPoint = false;
855 if ( m_rView.IsAction() ) // Drag Mode
857 bIsSetPoint = setMovementPointer(rMEvt);
858 ForceScroll(aPnt);
859 if (m_rView.GetDragMethod()==nullptr)
861 // create a selection
862 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, false);
864 else
866 if ( m_rView.IsDragResize() )
868 // we resize the object don't resize to above sections
869 if ( aPnt.Y() < 0 )
871 aPnt.setY( 0 );
874 // drag or resize an object
875 bool bControlKey = rMEvt.IsMod1();
876 m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, bControlKey);
880 if ( !bIsSetPoint )
882 m_pParent->SetPointer( m_rView.GetPreferredPointer( aPnt, m_pParent->GetOutDev() ) );
884 // restore color
885 unColorizeOverlappedObj();
888 return true;
894 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */