LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - dlgedfunc.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 448 0.0 %
Date: 2014-04-11 Functions: 0 35 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #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>
      26             : 
      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>
      38             : 
      39             : #include <toolkit/helper/vclunohelper.hxx>
      40             : 
      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             : 
      51             : #include "ReportRuler.hxx"
      52             : #include "UITools.hxx"
      53             : 
      54             : #include <uistrings.hrc>
      55             : #include "UndoEnv.hxx"
      56             : #include <RptModel.hxx>
      57             : #include <tools/diagnose_ex.h>
      58             : 
      59             : #define DEFAUL_MOVE_SIZE    100
      60             : namespace rptui
      61             : {
      62             : using namespace ::com::sun::star;
      63             : 
      64             : 
      65             : 
      66             : 
      67           0 : IMPL_LINK( DlgEdFunc, ScrollTimeout, Timer *,  )
      68             : {
      69           0 :     ForceScroll( m_pParent->PixelToLogic( m_pParent->GetPointerPosPixel() ) );
      70           0 :     return 0;
      71             : }
      72             : 
      73             : 
      74             : 
      75           0 : void DlgEdFunc::ForceScroll( const Point& rPos )
      76             : {
      77           0 :     aScrollTimer.Stop();
      78             : 
      79           0 :     OReportWindow* pReportWindow = m_pParent->getSectionWindow()->getViewsWindow()->getView();
      80           0 :     OScrollWindowHelper* pScrollWindow = pReportWindow->getScrollWindow();
      81             : 
      82           0 :     Size aOut = pReportWindow->GetOutputSizePixel();
      83           0 :     Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
      84           0 :     aStartWidth *= m_pParent->GetMapMode().GetScaleX();
      85             : 
      86           0 :     aOut.Width() -= (long)aStartWidth;
      87           0 :     aOut.Height() = m_pParent->GetOutputSizePixel().Height();
      88             : 
      89           0 :     Point aPos = pScrollWindow->getThumbPos();
      90           0 :     aPos.X() *= 0.5;
      91           0 :     aPos.Y() *= 0.5;
      92           0 :     Rectangle aOutRect( aPos, aOut );
      93           0 :     aOutRect = m_pParent->PixelToLogic( aOutRect );
      94           0 :     Point aGcc3WorkaroundTemporary;
      95           0 :     Rectangle aWorkArea(aGcc3WorkaroundTemporary,pScrollWindow->getTotalSize());
      96           0 :     aWorkArea.Right() -= (long)aStartWidth;
      97           0 :     aWorkArea = pScrollWindow->PixelToLogic( aWorkArea );
      98           0 :     if( !aOutRect.IsInside( rPos ) && aWorkArea.IsInside( rPos ) )
      99             :     {
     100           0 :         ScrollBar* pHScroll = pScrollWindow->GetHScroll();
     101           0 :         ScrollBar* pVScroll = pScrollWindow->GetVScroll();
     102           0 :         ScrollType eH = SCROLL_LINEDOWN,eV = SCROLL_LINEDOWN;
     103           0 :         if( rPos.X() < aOutRect.Left() )
     104           0 :             eH = SCROLL_LINEUP;
     105           0 :         else if( rPos.X() <= aOutRect.Right() )
     106           0 :             eH = SCROLL_DONTKNOW;
     107             : 
     108           0 :         if( rPos.Y() < aOutRect.Top() )
     109           0 :             eV = SCROLL_LINEUP;
     110           0 :         else if( rPos.Y() <= aOutRect.Bottom() )
     111           0 :             eV = SCROLL_DONTKNOW;
     112             : 
     113           0 :         pHScroll->DoScrollAction(eH);
     114           0 :         pVScroll->DoScrollAction(eV);
     115             :     }
     116             : 
     117           0 :     aScrollTimer.Start();
     118           0 : }
     119             : 
     120           0 : DlgEdFunc::DlgEdFunc( OReportSection* _pParent )
     121             :     : m_pParent(_pParent)
     122           0 :     , m_rView(_pParent->getSectionView())
     123             :     , m_xOverlappingObj(NULL)
     124             :     , m_pOverlappingObj(NULL)
     125             :     , m_nOverlappedControlColor(0)
     126             :     , m_nOldColor(0)
     127             :     , m_bSelectionMode(false)
     128             :     , m_bUiActive(false)
     129           0 :     , m_bShowPropertyBrowser(false)
     130             : {
     131           0 :     aScrollTimer.SetTimeoutHdl( LINK( this, DlgEdFunc, ScrollTimeout ) );
     132           0 :     m_rView.SetActualWin( m_pParent);
     133           0 :     aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
     134           0 : }
     135             : 
     136           0 : void DlgEdFunc::setOverlappedControlColor(sal_Int32 _nColor)
     137             : {
     138           0 :     m_nOverlappedControlColor = _nColor;
     139           0 : }
     140             : 
     141           0 : sal_Int32 lcl_setColorOfObject(uno::Reference< uno::XInterface > _xObj, long _nColorTRGB)
     142             : {
     143           0 :     sal_Int32 nBackColor = 0;
     144             :     try
     145             :     {
     146           0 :         uno::Reference<report::XReportComponent> xComponent(_xObj, uno::UNO_QUERY_THROW);
     147           0 :         uno::Reference< beans::XPropertySet > xProp(xComponent, uno::UNO_QUERY_THROW);
     148           0 :         uno::Any aAny = xProp->getPropertyValue(PROPERTY_CONTROLBACKGROUND);
     149           0 :         if (aAny.hasValue())
     150             :         {
     151           0 :             aAny >>= nBackColor;
     152             :             // try to set background color at the ReportComponent
     153           0 :             uno::Any aBlackColorAny = uno::makeAny(_nColorTRGB);
     154           0 :             xProp->setPropertyValue(PROPERTY_CONTROLBACKGROUND, aBlackColorAny);
     155           0 :         }
     156             :     }
     157           0 :     catch(uno::Exception&)
     158             :     {
     159             :     }
     160           0 :     return nBackColor;
     161             : }
     162             : 
     163           0 : DlgEdFunc::~DlgEdFunc()
     164             : {
     165           0 :     unColorizeOverlappedObj();
     166           0 :     aScrollTimer.Stop();
     167           0 : }
     168             : 
     169             : 
     170             : 
     171           0 : sal_Bool DlgEdFunc::MouseButtonDown( const MouseEvent& rMEvt )
     172             : {
     173           0 :     m_aMDPos = m_pParent->PixelToLogic( rMEvt.GetPosPixel() );
     174           0 :     m_pParent->GrabFocus();
     175           0 :     sal_Bool bHandled = sal_False;
     176           0 :     if ( rMEvt.IsLeft() )
     177             :     {
     178           0 :         if ( rMEvt.GetClicks() > 1 )
     179             :         {
     180             :             // show property browser
     181           0 :             if ( m_pParent->GetMode() != RPTUI_READONLY )
     182             :             {
     183           0 :                 uno::Sequence<beans::PropertyValue> aArgs(1);
     184           0 :                 aArgs[0].Name = "ShowProperties";
     185           0 :                 aArgs[0].Value <<= sal_True;
     186           0 :                 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_SHOW_PROPERTYBROWSER,aArgs);
     187           0 :                 m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
     188             :                 // TODO character in shapes
     189             :                 //    SdrViewEvent aVEvt;
     190             :                 // m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     191             :                 //    if ( aVEvt.pRootObj && aVEvt.pRootObj->ISA(SdrTextObj) )
     192             :                 //        SetInEditMode(static_cast<SdrTextObj *>(aVEvt.pRootObj),rMEvt, sal_False);
     193           0 :                 bHandled = sal_True;
     194             :             }
     195             :         }
     196             :         else
     197             :         {
     198           0 :             SdrHdl* pHdl = m_rView.PickHandle(m_aMDPos);
     199             : 
     200             :             // if selected object was hit, drag object
     201           0 :             if ( pHdl!=NULL || m_rView.IsMarkedHit(m_aMDPos) )
     202             :             {
     203           0 :                 bHandled = sal_True;
     204           0 :                 m_pParent->CaptureMouse();
     205           0 :                 m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, pHdl,&m_rView);
     206             :             }
     207             :         }
     208             :     }
     209           0 :     else if ( rMEvt.IsRight() && !rMEvt.IsLeft() && rMEvt.GetClicks() == 1 ) // mark object when context menu was selected
     210             :     {
     211           0 :         SdrPageView* pPV = m_rView.GetSdrPageView();
     212           0 :         SdrViewEvent aVEvt;
     213           0 :         if ( m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt) != SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() )
     214           0 :             m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
     215           0 :         if ( aVEvt.pRootObj )
     216           0 :             m_rView.MarkObj(aVEvt.pRootObj, pPV);
     217             :         else
     218           0 :             m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
     219             : 
     220           0 :         bHandled = sal_True;
     221             :     }
     222           0 :     else if( !rMEvt.IsLeft() )
     223           0 :         bHandled = sal_True;
     224           0 :     if ( !bHandled )
     225           0 :         m_pParent->CaptureMouse();
     226           0 :     return bHandled;
     227             : }
     228             : 
     229             : 
     230             : 
     231           0 : sal_Bool DlgEdFunc::MouseButtonUp( const MouseEvent& /*rMEvt*/ )
     232             : {
     233           0 :     sal_Bool bHandled = sal_False;
     234           0 :     m_pParent->getSectionWindow()->getViewsWindow()->stopScrollTimer();
     235           0 :     return bHandled;
     236             : }
     237             : 
     238           0 : void DlgEdFunc::checkTwoCklicks(const MouseEvent& rMEvt)
     239             : {
     240           0 :     deactivateOle();
     241             : 
     242           0 :     const sal_uInt16 nClicks = rMEvt.GetClicks();
     243           0 :     if ( nClicks == 2 && rMEvt.IsLeft() )
     244             :     {
     245           0 :         if ( m_rView.AreObjectsMarked() )
     246             :         {
     247           0 :             const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
     248           0 :             if (rMarkList.GetMarkCount() == 1)
     249             :             {
     250           0 :                 const SdrMark* pMark = rMarkList.GetMark(0);
     251           0 :                 SdrObject* pObj = pMark->GetMarkedSdrObj();
     252           0 :                 activateOle(pObj);
     253             :             }
     254             :         }
     255             :     }
     256           0 : }
     257             : 
     258           0 : void DlgEdFunc::stopScrollTimer()
     259             : {
     260           0 :     unColorizeOverlappedObj();
     261           0 :     aScrollTimer.Stop();
     262           0 :     if ( m_pParent->IsMouseCaptured() )
     263           0 :         m_pParent->ReleaseMouse();
     264           0 : }
     265             : 
     266             : 
     267           0 : sal_Bool DlgEdFunc::MouseMove( const MouseEvent& /*rMEvt*/ )
     268             : {
     269           0 :     return sal_False;
     270             : }
     271             : 
     272           0 : sal_Bool DlgEdFunc::handleKeyEvent(const KeyEvent& _rEvent)
     273             : {
     274           0 :     sal_Bool bReturn = sal_False;
     275             : 
     276           0 :     if ( !m_bUiActive )
     277             :     {
     278           0 :         const KeyCode& rCode = _rEvent.GetKeyCode();
     279           0 :         sal_uInt16 nCode = rCode.GetCode();
     280             : 
     281           0 :         switch ( nCode )
     282             :         {
     283             :             case KEY_ESCAPE:
     284             :             {
     285           0 :                 if ( m_pParent->getSectionWindow()->getViewsWindow()->IsAction() )
     286             :                 {
     287           0 :                     m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
     288           0 :                     bReturn = sal_True;
     289             :                 }
     290           0 :                 else if ( m_rView.IsTextEdit() )
     291             :                 {
     292           0 :                     m_rView.SdrEndTextEdit();
     293           0 :                     bReturn = sal_True;
     294             :                 }
     295           0 :                 else if ( m_rView.AreObjectsMarked() )
     296             :                 {
     297           0 :                     const SdrHdlList& rHdlList = m_rView.GetHdlList();
     298           0 :                     SdrHdl* pHdl = rHdlList.GetFocusHdl();
     299           0 :                     if ( pHdl )
     300           0 :                         ((SdrHdlList&)rHdlList).ResetFocusHdl();
     301             :                     else
     302           0 :                         m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
     303             : 
     304           0 :                     deactivateOle(true);
     305           0 :                     bReturn = sal_False;
     306             :                 }
     307             :                 else
     308             :                 {
     309           0 :                     deactivateOle(true);
     310             :                 }
     311             :             }
     312           0 :             break;
     313             :             case KEY_TAB:
     314             :             {
     315           0 :                 if ( !rCode.IsMod1() && !rCode.IsMod2() )
     316             :                 {
     317             :                     // mark next object
     318           0 :                     if ( !m_rView.MarkNextObj( !rCode.IsShift() ) )
     319             :                     {
     320             :                         // if no next object, mark first/last
     321           0 :                         m_rView.UnmarkAllObj();
     322           0 :                         m_rView.MarkNextObj( !rCode.IsShift() );
     323             :                     }
     324             : 
     325           0 :                     if ( m_rView.AreObjectsMarked() )
     326           0 :                         m_rView.MakeVisible( m_rView.GetAllMarkedRect(), *m_pParent);
     327             : 
     328           0 :                     bReturn = sal_True;
     329             :                 }
     330           0 :                 else if ( rCode.IsMod1() && rCode.IsMod2())
     331             :                 {
     332             :                     // selected handle
     333           0 :                     const SdrHdlList& rHdlList = m_rView.GetHdlList();
     334           0 :                     ((SdrHdlList&)rHdlList).TravelFocusHdl( !rCode.IsShift() );
     335             : 
     336             :                     // guarantee visibility of focused handle
     337           0 :                     SdrHdl* pHdl = rHdlList.GetFocusHdl();
     338           0 :                     if ( pHdl )
     339             :                     {
     340           0 :                         Point aHdlPosition( pHdl->GetPos() );
     341           0 :                         Rectangle aVisRect( aHdlPosition - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) );
     342           0 :                         m_rView.MakeVisible( aVisRect, *m_pParent);
     343             :                     }
     344             : 
     345           0 :                     bReturn = sal_True;
     346             :                 }
     347             :             }
     348           0 :             break;
     349             :             case KEY_UP:
     350             :             case KEY_DOWN:
     351             :             case KEY_LEFT:
     352             :             case KEY_RIGHT:
     353             :             {
     354           0 :                 m_pParent->getSectionWindow()->getViewsWindow()->handleKey(rCode);
     355           0 :                 bReturn = sal_True;
     356             :             }
     357           0 :             break;
     358             :             case KEY_RETURN:
     359           0 :                 if ( !rCode.IsMod1() )
     360             :                 {
     361           0 :                     const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
     362           0 :                     if ( rMarkList.GetMarkCount() == 1 )
     363             :                     {
     364           0 :                         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
     365           0 :                         activateOle(pObj);
     366             :                     }
     367             :                 }
     368           0 :                 break;
     369             :             case KEY_DELETE:
     370           0 :                 if ( !rCode.IsMod1() && !rCode.IsMod2() )
     371             :                 {
     372           0 :                     bReturn = sal_True;
     373           0 :                     break;
     374             :                 }
     375             :                 // run through
     376             :             default:
     377             :             {
     378           0 :                 bReturn = m_rView.KeyInput(_rEvent, m_pParent);
     379             :             }
     380           0 :             break;
     381             :         }
     382             :     }
     383             : 
     384           0 :     if ( bReturn && m_pParent->IsMouseCaptured() )
     385           0 :         m_pParent->ReleaseMouse();
     386             : 
     387           0 :     return bReturn;
     388             : }
     389             : 
     390           0 : void DlgEdFunc::activateOle(SdrObject* _pObj)
     391             : {
     392           0 :     if ( _pObj )
     393             :     {
     394           0 :         const sal_uInt16 nSdrObjKind = _pObj->GetObjIdentifier();
     395             : 
     396             :         //  OLE: activate
     397             : 
     398           0 :         if (nSdrObjKind == OBJ_OLE2)
     399             :         {
     400           0 :             bool bIsInplaceOle = false;
     401           0 :             if (!bIsInplaceOle)
     402             :             {
     403           0 :                 SdrOle2Obj* pOleObj = dynamic_cast<SdrOle2Obj*>(_pObj);
     404           0 :                 if (pOleObj && pOleObj->GetObjRef().is())
     405             :                 {
     406           0 :                     if (m_rView.IsTextEdit())
     407             :                     {
     408           0 :                         m_rView.SdrEndTextEdit();
     409             :                     }
     410             : 
     411           0 :                     pOleObj->AddOwnLightClient();
     412           0 :                     pOleObj->SetWindow(VCLUnoHelper::GetInterface(m_pParent));
     413             :                     try
     414             :                     {
     415           0 :                         pOleObj->GetObjRef()->changeState( embed::EmbedStates::UI_ACTIVE );
     416           0 :                         m_bUiActive = true;
     417           0 :                         OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
     418           0 :                         m_bShowPropertyBrowser = rController.isCommandChecked(SID_SHOW_PROPERTYBROWSER);
     419           0 :                         if ( m_bShowPropertyBrowser )
     420           0 :                             rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >());
     421             :                     }
     422           0 :                     catch( uno::Exception& )
     423             :                     {
     424             :                         DBG_UNHANDLED_EXCEPTION();
     425             :                     }
     426             :                 }
     427             :             }
     428             :         }
     429             :     }
     430           0 : }
     431             : 
     432           0 : void DlgEdFunc::deactivateOle(bool _bSelect)
     433             : {
     434           0 :     OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
     435           0 :     OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
     436           0 :     const sal_uLong nCount = rObjCache.size();
     437           0 :     for(sal_uLong i = 0 ; i< nCount;++i)
     438             :     {
     439           0 :         SdrOle2Obj* pObj = rObjCache[i];
     440           0 :         if ( m_pParent->getPage() == pObj->GetPage() )
     441             :         {
     442           0 :             uno::Reference< embed::XEmbeddedObject > xObj = pObj->GetObjRef();
     443           0 :             if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::UI_ACTIVE )
     444             :             {
     445           0 :                 xObj->changeState( embed::EmbedStates::RUNNING );
     446           0 :                 m_bUiActive = false;
     447           0 :                 if ( m_bShowPropertyBrowser )
     448             :                 {
     449           0 :                     rController.executeChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue >());
     450             :                 }
     451             : 
     452           0 :                 if ( _bSelect )
     453             :                 {
     454           0 :                     SdrPageView* pPV = m_rView.GetSdrPageView();
     455           0 :                     m_rView.MarkObj(pObj, pPV);
     456             :                 }
     457           0 :             }
     458             :         }
     459             :     }
     460           0 : }
     461             : 
     462           0 : void DlgEdFunc::colorizeOverlappedObject(SdrObject* _pOverlappedObj)
     463             : {
     464           0 :     OObjectBase* pObj = dynamic_cast<OObjectBase*>(_pOverlappedObj);
     465           0 :     if ( pObj )
     466             :     {
     467           0 :         uno::Reference<report::XReportComponent> xComponent = pObj->getReportComponent();
     468           0 :         if (xComponent.is() && xComponent != m_xOverlappingObj)
     469             :         {
     470           0 :             OReportModel* pRptModel = static_cast<OReportModel*>(_pOverlappedObj->GetModel());
     471           0 :             if ( pRptModel )
     472             :             {
     473           0 :                 OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     474             : 
     475             :                 // uncolorize an old object, if there is one
     476           0 :                 unColorizeOverlappedObj();
     477             : 
     478           0 :                 m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor);
     479           0 :                 m_xOverlappingObj = xComponent;
     480           0 :                 m_pOverlappingObj = _pOverlappedObj;
     481             :             }
     482           0 :         }
     483             :     }
     484           0 : }
     485             : 
     486           0 : void DlgEdFunc::unColorizeOverlappedObj()
     487             : {
     488             :     // uncolorize an old object, if there is one
     489           0 :     if (m_xOverlappingObj.is())
     490             :     {
     491           0 :         OReportModel* pRptModel = static_cast<OReportModel*>(m_pOverlappingObj->GetModel());
     492           0 :         if ( pRptModel )
     493             :         {
     494           0 :             OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv());
     495             : 
     496           0 :             lcl_setColorOfObject(m_xOverlappingObj, m_nOldColor);
     497           0 :             m_xOverlappingObj = NULL;
     498           0 :             m_pOverlappingObj = NULL;
     499             :         }
     500             :     }
     501           0 : }
     502             : 
     503           0 : bool DlgEdFunc::isOverlapping(const MouseEvent& rMEvt)
     504             : {
     505           0 :     SdrViewEvent aVEvt;
     506           0 :     bool bOverlapping = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONUP, aVEvt) != SDRHIT_NONE;
     507           0 :     if (bOverlapping && aVEvt.pObj)
     508             :     {
     509           0 :         colorizeOverlappedObject(aVEvt.pObj);
     510             :     }
     511             :     else
     512             :     {
     513           0 :         unColorizeOverlappedObj();
     514             :     }
     515             : 
     516           0 :     return bOverlapping;
     517             : }
     518             : 
     519           0 : void DlgEdFunc::checkMovementAllowed(const MouseEvent& rMEvt)
     520             : {
     521           0 :     if ( m_pParent->getSectionWindow()->getViewsWindow()->IsDragObj() )
     522             :     {
     523           0 :         if ( isRectangleHit(rMEvt) )
     524             :         {
     525             :             // there is an other component under use, break action
     526           0 :             m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
     527             :         }
     528             :         // object was dragged
     529           0 :         Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
     530           0 :         if (m_bSelectionMode)
     531             :         {
     532           0 :             m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
     533             :         }
     534             :         else
     535             :         {
     536           0 :             bool bControlKeyPressed = rMEvt.IsMod1();
     537             :             // Don't allow points smaller 0
     538           0 :             if (bControlKeyPressed && (aPnt.Y() < 0))
     539             :             {
     540           0 :                 aPnt.Y() = 0;
     541             :             }
     542           0 :             if (m_rView.IsDragResize())
     543             :             {
     544             :                 // we resize the object don't resize to above sections
     545           0 :                 if ( aPnt.Y() < 0 )
     546             :                 {
     547           0 :                     aPnt.Y() = 0;
     548             :                 }
     549             :             }
     550           0 :             m_pParent->getSectionWindow()->getViewsWindow()->EndDragObj( bControlKeyPressed, &m_rView, aPnt );
     551             :         }
     552           0 :         m_pParent->getSectionWindow()->getViewsWindow()->ForceMarkedToAnotherPage();
     553           0 :         m_pParent->Invalidate(INVALIDATE_CHILDREN);
     554             :     }
     555             :     else
     556           0 :         m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
     557           0 : }
     558             : 
     559           0 : bool DlgEdFunc::isOnlyCustomShapeMarked()
     560             : {
     561           0 :     bool bReturn = true;
     562           0 :     const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
     563           0 :     for (sal_uInt32 i =  0; i < rMarkList.GetMarkCount();++i )
     564             :     {
     565           0 :         SdrMark* pMark = rMarkList.GetMark(i);
     566           0 :         SdrObject* pObj = pMark->GetMarkedSdrObj();
     567           0 :         if (pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE)
     568             :         {
     569             :             // we found an object in the marked objects, which is not a custom shape.
     570           0 :             bReturn = false;
     571           0 :             break;
     572             :         }
     573             :     }
     574           0 :     return bReturn;
     575             : }
     576             : 
     577           0 : bool DlgEdFunc::isRectangleHit(const MouseEvent& rMEvt)
     578             : {
     579           0 :     if (isOnlyCustomShapeMarked())
     580             :     {
     581           0 :         return false;
     582             :     }
     583             : 
     584           0 :     SdrViewEvent aVEvt;
     585           0 :     const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEMOVE, aVEvt);
     586           0 :     bool bIsSetPoint = (eHit == SDRHIT_UNMARKEDOBJECT);
     587           0 :     if ( !bIsSetPoint )
     588             :     {
     589             :         // no drag rect, we have to check every single select rect
     590           0 :         const SdrDragStat& rDragStat = m_rView.GetDragStat();
     591           0 :         if (rDragStat.GetDragMethod() != NULL)
     592             :         {
     593           0 :             SdrObjListIter aIter(*m_pParent->getPage(),IM_DEEPNOGROUPS);
     594           0 :             SdrObject* pObjIter = NULL;
     595             :             // loop through all marked objects and check if there new rect overlapps an old one.
     596           0 :             while( (pObjIter = aIter.Next()) != NULL && !bIsSetPoint)
     597             :             {
     598           0 :                 if ( m_rView.IsObjMarked(pObjIter)
     599           0 :                      && (dynamic_cast<OUnoObject*>(pObjIter) != NULL || dynamic_cast<OOle2Obj*>(pObjIter) != NULL) )
     600             :                 {
     601           0 :                     Rectangle aNewRect = pObjIter->GetLastBoundRect();
     602           0 :                     long nDx = rDragStat.IsHorFixed() ? 0 : rDragStat.GetDX();
     603           0 :                     long nDy = rDragStat.IsVerFixed() ? 0 : rDragStat.GetDY();
     604           0 :                     if ( (nDx + aNewRect.Left()) < 0 )
     605           0 :                         nDx = -aNewRect.Left();
     606           0 :                     if ( (nDy + aNewRect.Top()) < 0 )
     607           0 :                         nDy = -aNewRect.Top();
     608             : 
     609           0 :                     if ( rDragStat.GetDragMethod()->getMoveOnly() )
     610           0 :                         aNewRect.Move(nDx,nDy);
     611             :                     else
     612           0 :                         ::ResizeRect(aNewRect,rDragStat.GetRef1(),rDragStat.GetXFact(),rDragStat.GetYFact());
     613             : 
     614             : 
     615           0 :                     SdrObject* pObjOverlapped = isOver(aNewRect,*m_pParent->getPage(),m_rView,false,pObjIter, ISOVER_IGNORE_CUSTOMSHAPES);
     616           0 :                     bIsSetPoint = pObjOverlapped ? true : false;
     617           0 :                     if (pObjOverlapped && !m_bSelectionMode)
     618             :                     {
     619           0 :                         colorizeOverlappedObject(pObjOverlapped);
     620             :                     }
     621             :                 }
     622           0 :             }
     623             :         }
     624             :     }
     625           0 :     else if ( aVEvt.pObj && (aVEvt.pObj->GetObjIdentifier() != OBJ_CUSTOMSHAPE) && !m_bSelectionMode)
     626             :     {
     627           0 :         colorizeOverlappedObject(aVEvt.pObj);
     628             :     }
     629             :     else
     630           0 :         bIsSetPoint = false;
     631           0 :     return bIsSetPoint;
     632             : }
     633             : 
     634           0 : bool DlgEdFunc::setMovementPointer(const MouseEvent& rMEvt)
     635             : {
     636           0 :     bool bIsSetPoint = isRectangleHit(rMEvt);
     637           0 :     if ( bIsSetPoint )
     638           0 :         m_pParent->SetPointer( Pointer(POINTER_NOTALLOWED));
     639             :     else
     640             :     {
     641           0 :         bool bCtrlKey = rMEvt.IsMod1();
     642             :         (void)bCtrlKey;
     643           0 :         if (bCtrlKey)
     644             :         {
     645           0 :             m_pParent->SetPointer( Pointer(POINTER_MOVEDATALINK ));
     646           0 :             bIsSetPoint = true;
     647             :         }
     648             :     }
     649           0 :     return bIsSetPoint;
     650             : }
     651             : 
     652             : 
     653           0 : DlgEdFuncInsert::DlgEdFuncInsert( OReportSection* _pParent ) :
     654           0 :     DlgEdFunc( _pParent )
     655             : {
     656           0 :     m_rView.SetCreateMode( true );
     657           0 : }
     658             : 
     659             : 
     660             : 
     661           0 : DlgEdFuncInsert::~DlgEdFuncInsert()
     662             : {
     663           0 :     m_rView.SetEditMode( true );
     664           0 : }
     665             : 
     666             : 
     667             : 
     668           0 : sal_Bool DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt )
     669             : {
     670           0 :     if ( DlgEdFunc::MouseButtonDown(rMEvt) )
     671           0 :         return sal_True;
     672             : 
     673           0 :     SdrViewEvent aVEvt;
     674           0 :     sal_Int16 nId = m_rView.GetCurrentObjIdentifier();
     675             : 
     676           0 :     const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     677             : 
     678           0 :     if (eHit == SDRHIT_UNMARKEDOBJECT &&
     679             :         nId != OBJ_CUSTOMSHAPE)
     680             :     {
     681             :         // there is an object under the mouse cursor, but not a customshape
     682           0 :         m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
     683           0 :         return sal_False;
     684             :     }
     685             : 
     686           0 :     if( eHit != SDRHIT_UNMARKEDOBJECT || nId == OBJ_CUSTOMSHAPE)
     687             :     {
     688             :         // if no action, create object
     689           0 :         if ( !m_pParent->getSectionWindow()->getViewsWindow()->IsAction() )
     690             :         {
     691           0 :             deactivateOle(true);
     692           0 :             if ( m_pParent->getSectionWindow()->getViewsWindow()->HasSelection() )
     693           0 :                 m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(&m_rView);
     694           0 :             m_rView.BegCreateObj(m_aMDPos);
     695           0 :             m_pParent->getSectionWindow()->getViewsWindow()->createDefault();
     696             :         }
     697             :     }
     698             :     else
     699             :     {
     700           0 :         if( !rMEvt.IsShift() )
     701             :         {
     702             :             // shift key pressed?
     703           0 :             m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
     704             :         }
     705           0 :         m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos,&m_rView );
     706             :     }
     707             : 
     708           0 :     return sal_True;
     709             : }
     710             : 
     711             : 
     712           0 : sal_Bool DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt )
     713             : {
     714           0 :     if ( DlgEdFunc::MouseButtonUp( rMEvt ) )
     715           0 :         return sal_True;
     716             : 
     717           0 :     const Point aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
     718           0 :     const sal_uInt16 nHitLog = sal_uInt16 ( m_pParent->PixelToLogic(Size(3,0)).Width() );
     719             : 
     720           0 :     sal_Bool bReturn = sal_True;
     721             :     // object creation active?
     722           0 :     if ( m_rView.IsCreateObj() )
     723             :     {
     724           0 :         if ( isOver(m_rView.GetCreateObj(),*m_pParent->getPage(),m_rView) )
     725             :         {
     726           0 :             m_pParent->getSectionWindow()->getViewsWindow()->BrkAction();
     727             :             // BrkAction disables the create mode
     728           0 :             m_rView.SetCreateMode( true );
     729           0 :             return sal_True;
     730             :         }
     731             : 
     732           0 :         m_rView.EndCreateObj(SDRCREATE_FORCEEND);
     733             : 
     734           0 :         if ( !m_rView.AreObjectsMarked() )
     735             :         {
     736           0 :             m_rView.MarkObj(aPos, nHitLog);
     737             :         }
     738             : 
     739           0 :         bReturn = m_rView.AreObjectsMarked();
     740           0 :         if ( bReturn )
     741             :         {
     742           0 :             OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
     743           0 :             const SdrMarkList& rMarkList = m_rView.GetMarkedObjectList();
     744           0 :             for (sal_uInt32 i =  0; i < rMarkList.GetMarkCount();++i )
     745             :             {
     746           0 :                 SdrMark* pMark = rMarkList.GetMark(i);
     747           0 :                 OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj());
     748           0 :                 if ( pObj && !pObj->IsEmpty() )
     749             :                 {
     750           0 :                     pObj->initializeChart(rController.getModel());
     751             :                 }
     752             :             }
     753             :         }
     754             :     }
     755             :     else
     756           0 :         checkMovementAllowed(rMEvt);
     757             : 
     758           0 :     if ( !m_rView.AreObjectsMarked() &&
     759           0 :          std::abs(m_aMDPos.X() - aPos.X()) < nHitLog &&
     760           0 :          std::abs(m_aMDPos.Y() - aPos.Y()) < nHitLog &&
     761           0 :          !rMEvt.IsShift() && !rMEvt.IsMod2() )
     762             :     {
     763           0 :         SdrPageView* pPV = m_rView.GetSdrPageView();
     764           0 :         SdrViewEvent aVEvt;
     765           0 :         m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     766           0 :         m_rView.MarkObj(aVEvt.pRootObj, pPV);
     767             :     }
     768           0 :     checkTwoCklicks(rMEvt);
     769           0 :     m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
     770           0 :     return bReturn;
     771             : }
     772             : 
     773             : 
     774             : 
     775           0 : sal_Bool DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt )
     776             : {
     777           0 :     if ( DlgEdFunc::MouseMove(rMEvt ) )
     778           0 :         return sal_True;
     779           0 :     Point   aPos( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
     780             : 
     781           0 :     if ( m_rView.IsCreateObj() )
     782             :     {
     783           0 :         m_rView.SetOrtho(SdrObjCustomShape::doConstructOrthogonal(m_rView.getReportSection()->getSectionWindow()->getViewsWindow()->getShapeType()) ? !rMEvt.IsShift() : rMEvt.IsShift());
     784           0 :         m_rView.SetAngleSnapEnabled(rMEvt.IsShift());
     785             :     }
     786             : 
     787           0 :     bool bIsSetPoint = false;
     788           0 :     if ( m_rView.IsAction() )
     789             :     {
     790           0 :         if ( m_rView.IsDragResize() )
     791             :         {
     792             :             // we resize the object don't resize to above sections
     793           0 :             if ( aPos.Y() < 0 )
     794             :             {
     795           0 :                 aPos.Y() = 0;
     796             :             }
     797             :         }
     798           0 :         bIsSetPoint = setMovementPointer(rMEvt);
     799           0 :         ForceScroll(aPos);
     800           0 :         m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPos,&m_rView, m_rView.GetDragMethod() == NULL, false);
     801             :     }
     802             : 
     803           0 :     if ( !bIsSetPoint )
     804           0 :         m_pParent->SetPointer( m_rView.GetPreferredPointer( aPos, m_pParent) );
     805             : 
     806           0 :     return sal_True;
     807             : }
     808             : 
     809             : 
     810             : 
     811           0 : DlgEdFuncSelect::DlgEdFuncSelect( OReportSection* _pParent ) :
     812           0 :     DlgEdFunc( _pParent )
     813             : {
     814           0 : }
     815             : 
     816             : 
     817             : 
     818           0 : DlgEdFuncSelect::~DlgEdFuncSelect()
     819             : {
     820           0 : }
     821             : 
     822             : 
     823             : 
     824           0 : sal_Bool DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
     825             : {
     826           0 :     m_bSelectionMode = false;
     827           0 :     if ( DlgEdFunc::MouseButtonDown(rMEvt) )
     828           0 :         return sal_True;
     829             : 
     830           0 :     SdrViewEvent aVEvt;
     831           0 :     const SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     832           0 :     if( eHit == SDRHIT_UNMARKEDOBJECT )
     833             :     {
     834             :         // if not multi selection, unmark all
     835           0 :         if ( !rMEvt.IsShift() )
     836           0 :             m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
     837             : 
     838           0 :         if ( m_rView.MarkObj(m_aMDPos) && rMEvt.IsLeft() )
     839             :         {
     840             :             // drag object
     841           0 :             m_pParent->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos, m_rView.PickHandle(m_aMDPos), &m_rView);
     842             :         }
     843             :         else
     844             :         {
     845             :             // select object
     846           0 :             m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj(m_aMDPos,&m_rView);
     847             :         }
     848             :     }
     849             :     else
     850             :     {
     851           0 :         if( !rMEvt.IsShift() )
     852           0 :             m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL);
     853             : 
     854           0 :         if ( rMEvt.GetClicks() == 1 )
     855             :         {
     856           0 :             m_bSelectionMode = true;
     857           0 :             m_pParent->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos ,&m_rView);
     858             :         }
     859             :         else
     860             :         {
     861           0 :             m_rView.SdrBeginTextEdit( aVEvt.pRootObj,m_rView.GetSdrPageView(),m_pParent, false );
     862             :         }
     863             :     }
     864             : 
     865           0 :     return sal_True;
     866             : }
     867             : 
     868             : 
     869             : 
     870           0 : sal_Bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt )
     871             : {
     872           0 :     if ( DlgEdFunc::MouseButtonUp( rMEvt ) )
     873           0 :         return sal_True;
     874             : 
     875             :     // get view from parent
     876           0 :     const Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
     877             : 
     878           0 :     if ( rMEvt.IsLeft() )                     // left mousebutton pressed
     879           0 :         checkMovementAllowed(rMEvt);
     880             : 
     881           0 :     m_pParent->getSectionWindow()->getViewsWindow()->EndAction();
     882           0 :     checkTwoCklicks(rMEvt);
     883             : 
     884           0 :     m_pParent->SetPointer( m_rView.GetPreferredPointer( aPnt, m_pParent) );
     885             : 
     886           0 :     if ( !m_bUiActive )
     887           0 :         m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView);
     888           0 :     m_bSelectionMode = false;
     889           0 :     return sal_True;
     890             : }
     891             : 
     892             : 
     893             : 
     894           0 : sal_Bool DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
     895             : {
     896           0 :     if ( DlgEdFunc::MouseMove(rMEvt ) )
     897           0 :         return sal_True;
     898             : 
     899           0 :     Point aPnt( m_pParent->PixelToLogic( rMEvt.GetPosPixel() ) );
     900           0 :     bool bIsSetPoint = false;
     901             : 
     902           0 :     if ( m_rView.IsAction() ) // Drag Mode
     903             :     {
     904           0 :         bIsSetPoint = setMovementPointer(rMEvt);
     905           0 :         ForceScroll(aPnt);
     906           0 :         if (m_rView.GetDragMethod()==NULL)
     907             :         {
     908             :             // create a selection
     909           0 :             m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, true, false);
     910             :         }
     911             :         else
     912             :         {
     913           0 :             if ( m_rView.IsDragResize() )
     914             :             {
     915             :                 // we resize the object don't resize to above sections
     916           0 :                 if ( aPnt.Y() < 0 )
     917             :                 {
     918           0 :                     aPnt.Y() = 0;
     919             :                 }
     920             :             }
     921             :             // drag or resize an object
     922           0 :             bool bControlKey = rMEvt.IsMod1();
     923           0 :             m_pParent->getSectionWindow()->getViewsWindow()->MovAction(aPnt, &m_rView, false, bControlKey);
     924             :         }
     925             :     }
     926             : 
     927           0 :     if ( !bIsSetPoint )
     928             :     {
     929           0 :         m_pParent->SetPointer( m_rView.GetPreferredPointer( aPnt, m_pParent) );
     930             : 
     931             :         // restore color
     932           0 :         unColorizeOverlappedObj();
     933             :     }
     934             : 
     935           0 :     return sal_True;
     936             : }
     937             : 
     938             : 
     939             : }
     940             : 
     941             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10