1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlgedfunc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
31 #include <vcl/scrbar.hxx>
32 #include <vcl/svapp.hxx>
33 #include <vcl/seleng.hxx>
34 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
35 #include <com/sun/star/embed/EmbedStates.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <svx/svdview.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/outlobj.hxx>
41 #include <svx/unolingu.hxx>
42 #include <svx/svdetc.hxx>
43 #include <svx/editstat.hxx>
44 #include <svx/svdoutl.hxx>
45 #include <svx/svddrgmt.hxx>
46 #include <svx/svdoashp.hxx>
47 #include <svx/svxids.hrc>
48 #include <svx/svditer.hxx>
50 #include <toolkit/helper/vclunohelper.hxx>
52 #include "dlgedfunc.hxx"
53 #include "ReportSection.hxx"
54 #include "DesignView.hxx"
55 #include "ReportController.hxx"
56 #include "SectionView.hxx"
57 #include "ViewsWindow.hxx"
58 #include "ReportWindow.hxx"
59 #include "RptObject.hxx"
60 #include "ScrollHelper.hxx"
62 #include "ReportRuler.hxx"
63 #include "UITools.hxx"
65 #include <uistrings.hrc>
66 #include "UndoEnv.hxx"
67 #include <RptModel.hxx>
68 #include <tools/diagnose_ex.h>
70 #define DEFAUL_MOVE_SIZE 100
73 using namespace ::com::sun::star
;
74 //----------------------------------------------------------------------------
76 //----------------------------------------------------------------------------
78 IMPL_LINK( DlgEdFunc
, ScrollTimeout
, Timer
*, )
80 ForceScroll( m_pParent
->PixelToLogic( m_pParent
->GetPointerPosPixel() ) );
84 //----------------------------------------------------------------------------
86 void DlgEdFunc::ForceScroll( const Point
& rPos
)
90 OReportWindow
* pReportWindow
= m_pParent
->getSectionWindow()->getViewsWindow()->getView();
91 OScrollWindowHelper
* pScrollWindow
= pReportWindow
->getScrollWindow();
93 Size aOut
= pReportWindow
->GetOutputSizePixel();
94 Fraction
aStartWidth(long(REPORT_STARTMARKER_WIDTH
));
95 aStartWidth
*= m_pParent
->GetMapMode().GetScaleX();
97 aOut
.Width() -= (long)aStartWidth
;
99 Rectangle
aOutRect( pScrollWindow
->getThumbPos(), aOut
);
100 aOutRect
= m_pParent
->PixelToLogic( aOutRect
);
101 //Rectangle aWorkArea = m_pParent->getView()->GetWorkArea();
102 Point aGcc3WorkaroundTemporary
;
103 Rectangle
aWorkArea(aGcc3WorkaroundTemporary
,pScrollWindow
->getTotalSize());
104 aWorkArea
.Right() -= (long)aStartWidth
;
105 aWorkArea
= pScrollWindow
->PixelToLogic( aWorkArea
);
106 if( !aOutRect
.IsInside( rPos
) && aWorkArea
.IsInside( rPos
) )
108 ScrollBar
* pHScroll
= pScrollWindow
->GetHScroll();
109 ScrollBar
* pVScroll
= pScrollWindow
->GetVScroll();
110 ScrollType eH
= SCROLL_LINEDOWN
,eV
= SCROLL_LINEDOWN
;
111 if( rPos
.X() < aOutRect
.Left() )
113 else if( rPos
.X() <= aOutRect
.Right() )
114 eH
= SCROLL_DONTKNOW
;
116 if( rPos
.Y() < aOutRect
.Top() )
118 else if( rPos
.Y() <= aOutRect
.Bottom() )
119 eV
= SCROLL_DONTKNOW
;
121 pHScroll
->DoScrollAction(eH
);
122 pVScroll
->DoScrollAction(eV
);
125 aScrollTimer
.Start();
128 //----------------------------------------------------------------------------
130 DlgEdFunc::DlgEdFunc( OReportSection
* _pParent
)
131 :m_pParent(_pParent
),
132 m_rView(_pParent
->getSectionView()),
133 m_xOverlappingObj(NULL
),
134 m_pOverlappingObj(NULL
),
135 m_bSelectionMode(false),
137 m_bShowPropertyBrowser(false)
139 // m_pParent = _pParent;
140 aScrollTimer
.SetTimeoutHdl( LINK( this, DlgEdFunc
, ScrollTimeout
) );
141 m_rView
.SetActualWin( m_pParent
);
142 aScrollTimer
.SetTimeout( SELENG_AUTOREPEAT_INTERVAL
);
145 //----------------------------------------------------------------------------
146 void DlgEdFunc::setOverlappedControlColor(sal_Int32 _nColor
)
148 m_nOverlappedControlColor
= _nColor
;
150 // -----------------------------------------------------------------------------
151 sal_Int32
lcl_setColorOfObject(uno::Reference
< uno::XInterface
> _xObj
, long _nColorTRGB
)
153 sal_Int32 nBackColor
= 0;
156 uno::Reference
<report::XReportComponent
> xComponent(_xObj
, uno::UNO_QUERY_THROW
);
157 // NOT NEED if UNO_QUERY_THROW:
158 // if (xComponent.is())
160 uno::Reference
< beans::XPropertySet
> xProp(xComponent
, uno::UNO_QUERY_THROW
);
163 // ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlBackground"))
164 // is PROPERTY_CONTROLBACKGROUND
165 uno::Any aAny
= xProp
->getPropertyValue(PROPERTY_CONTROLBACKGROUND
);
169 // try to set background color at the ReportComponent
170 uno::Any aBlackColorAny
= uno::makeAny(_nColorTRGB
);
171 xProp
->setPropertyValue(PROPERTY_CONTROLBACKGROUND
, aBlackColorAny
);
173 // aCopies.push_back(xComponent->createClone());
175 catch(uno::Exception
&)
177 // bit my shiny metal as!
178 // OSL_ENSURE(0,"Can't copy report elements!");
182 // -----------------------------------------------------------------------------
183 DlgEdFunc::~DlgEdFunc()
185 unColorizeOverlappedObj();
189 //----------------------------------------------------------------------------
191 BOOL
DlgEdFunc::MouseButtonDown( const MouseEvent
& rMEvt
)
193 m_aMDPos
= m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() );
194 m_pParent
->GrabFocus();
195 BOOL bHandled
= FALSE
;
196 if ( rMEvt
.IsLeft() )
198 if ( rMEvt
.GetClicks() > 1 )
200 // show property browser
201 if ( m_pParent
->GetMode() != RPTUI_READONLY
)
203 uno::Sequence
<beans::PropertyValue
> aArgs(1);
204 aArgs
[0].Name
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowProperties"));
205 aArgs
[0].Value
<<= sal_True
;
206 m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_SHOW_PROPERTYBROWSER
,aArgs
);
207 m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView
);
208 // TODO character in shapes
209 // SdrViewEvent aVEvt;
210 // m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
211 // if ( aVEvt.pRootObj && aVEvt.pRootObj->ISA(SdrTextObj) )
212 // SetInEditMode(static_cast<SdrTextObj *>(aVEvt.pRootObj),rMEvt, FALSE);
218 SdrHdl
* pHdl
= m_rView
.PickHandle(m_aMDPos
);
219 //m_pParent->getSectionWindow()->getViewsWindow()->unmarkAllObjects(m_pView);
221 // if selected object was hit, drag object
222 if ( pHdl
!=NULL
|| m_rView
.IsMarkedHit(m_aMDPos
) )
225 m_pParent
->CaptureMouse();
226 m_pParent
->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos
, pHdl
,&m_rView
);
230 else if ( rMEvt
.IsRight() && !rMEvt
.IsLeft() && rMEvt
.GetClicks() == 1 ) // mark object when context menu was selected
232 SdrPageView
* pPV
= m_rView
.GetSdrPageView();
234 if ( m_rView
.PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
) != SDRHIT_MARKEDOBJECT
&& !rMEvt
.IsShift() )
235 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
236 if ( aVEvt
.pRootObj
)
237 m_rView
.MarkObj(aVEvt
.pRootObj
, pPV
);
239 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
243 else if( !rMEvt
.IsLeft() )
246 m_pParent
->CaptureMouse();
250 //----------------------------------------------------------------------------
252 BOOL
DlgEdFunc::MouseButtonUp( const MouseEvent
& /*rMEvt*/ )
254 BOOL bHandled
= FALSE
;
255 m_pParent
->getSectionWindow()->getViewsWindow()->stopScrollTimer();
258 // -----------------------------------------------------------------------------
259 void DlgEdFunc::checkTwoCklicks(const MouseEvent
& rMEvt
)
263 const USHORT nClicks
= rMEvt
.GetClicks();
264 if ( nClicks
== 2 && rMEvt
.IsLeft() )
266 if ( m_rView
.AreObjectsMarked() )
268 const SdrMarkList
& rMarkList
= m_rView
.GetMarkedObjectList();
269 if (rMarkList
.GetMarkCount() == 1)
271 const SdrMark
* pMark
= rMarkList
.GetMark(0);
272 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
274 } // if (rMarkList.GetMarkCount() == 1)
275 } // if ( pView->AreObjectsMarked() )
278 // -----------------------------------------------------------------------------
279 void DlgEdFunc::stopScrollTimer()
281 unColorizeOverlappedObj();
283 if ( m_pParent
->IsMouseCaptured() )
284 m_pParent
->ReleaseMouse();
286 //----------------------------------------------------------------------------
288 BOOL
DlgEdFunc::MouseMove( const MouseEvent
& /*rMEvt*/ )
292 //------------------------------------------------------------------------------
293 sal_Bool
DlgEdFunc::handleKeyEvent(const KeyEvent
& _rEvent
)
295 BOOL bReturn
= FALSE
;
299 const KeyCode
& rCode
= _rEvent
.GetKeyCode();
300 USHORT nCode
= rCode
.GetCode();
306 if ( m_pParent
->getSectionWindow()->getViewsWindow()->IsAction() )
308 m_pParent
->getSectionWindow()->getViewsWindow()->BrkAction();
311 else if ( m_rView
.IsTextEdit() )
313 m_rView
.SdrEndTextEdit();
316 else if ( m_rView
.AreObjectsMarked() )
318 const SdrHdlList
& rHdlList
= m_rView
.GetHdlList();
319 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
321 ((SdrHdlList
&)rHdlList
).ResetFocusHdl();
323 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
324 //m_rView.UnmarkAll();
337 if ( !rCode
.IsMod1() && !rCode
.IsMod2() )
340 if ( !m_rView
.MarkNextObj( !rCode
.IsShift() ) )
342 // if no next object, mark first/last
343 m_rView
.UnmarkAllObj();
344 m_rView
.MarkNextObj( !rCode
.IsShift() );
347 if ( m_rView
.AreObjectsMarked() )
348 m_rView
.MakeVisible( m_rView
.GetAllMarkedRect(), *m_pParent
);
352 else if ( rCode
.IsMod1() && rCode
.IsMod2())
355 const SdrHdlList
& rHdlList
= m_rView
.GetHdlList();
356 ((SdrHdlList
&)rHdlList
).TravelFocusHdl( !rCode
.IsShift() );
358 // guarantee visibility of focused handle
359 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
362 Point
aHdlPosition( pHdl
->GetPos() );
363 Rectangle
aVisRect( aHdlPosition
- Point( DEFAUL_MOVE_SIZE
, DEFAUL_MOVE_SIZE
), Size( 200, 200 ) );
364 m_rView
.MakeVisible( aVisRect
, *m_pParent
);
376 m_pParent
->getSectionWindow()->getViewsWindow()->handleKey(rCode
);
381 if ( !rCode
.IsMod1() )
383 const SdrMarkList
& rMarkList
= m_rView
.GetMarkedObjectList();
384 if ( rMarkList
.GetMarkCount() == 1 )
386 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
392 if ( !rCode
.IsMod1() && !rCode
.IsMod2() )
396 } // if ( !rCode.IsMod1() && !rCode.IsMod2() )
400 bReturn
= m_rView
.KeyInput(_rEvent
, m_pParent
);
406 if ( bReturn
&& m_pParent
->IsMouseCaptured() )
407 m_pParent
->ReleaseMouse();
411 // -----------------------------------------------------------------------------
412 void DlgEdFunc::activateOle(SdrObject
* _pObj
)
416 const UINT16 nSdrObjKind
= _pObj
->GetObjIdentifier();
420 if (nSdrObjKind
== OBJ_OLE2
)
422 bool bIsInplaceOle
= false;
425 SdrOle2Obj
* pOleObj
= dynamic_cast<SdrOle2Obj
*>(_pObj
);
426 if ( pOleObj
->GetObjRef().is() )
428 if (m_rView
.IsTextEdit())
430 m_rView
.SdrEndTextEdit();
433 pOleObj
->AddOwnLightClient();
434 pOleObj
->SetWindow(VCLUnoHelper::GetInterface(m_pParent
));
437 pOleObj
->GetObjRef()->changeState( embed::EmbedStates::UI_ACTIVE
);
439 OReportController
& rController
= m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
440 m_bShowPropertyBrowser
= rController
.isCommandChecked(SID_SHOW_PROPERTYBROWSER
);
441 if ( m_bShowPropertyBrowser
)
442 rController
.executeChecked(SID_SHOW_PROPERTYBROWSER
,uno::Sequence
< beans::PropertyValue
>());
444 catch( uno::Exception
& )
446 DBG_UNHANDLED_EXCEPTION();
450 } // if (nSdrObjKind == OBJ_OLE2)
453 // -----------------------------------------------------------------------------
454 void DlgEdFunc::deactivateOle(bool _bSelect
)
456 OLEObjCache
& rObjCache
= GetSdrGlobalData().GetOLEObjCache();
457 const ULONG nCount
= rObjCache
.Count();
458 for(ULONG i
= 0 ; i
< nCount
;++i
)
460 SdrOle2Obj
* pObj
= reinterpret_cast<SdrOle2Obj
*>(rObjCache
.GetObject(i
));
461 if ( m_pParent
->getPage() == pObj
->GetPage() )
463 uno::Reference
< embed::XEmbeddedObject
> xObj
= pObj
->GetObjRef();
464 if ( xObj
.is() && xObj
->getCurrentState() == embed::EmbedStates::UI_ACTIVE
)
466 xObj
->changeState( embed::EmbedStates::RUNNING
);
468 if ( m_bShowPropertyBrowser
)
470 OReportController
& rController
= m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
471 rController
.executeChecked(SID_SHOW_PROPERTYBROWSER
,uno::Sequence
< beans::PropertyValue
>());
476 SdrPageView
* pPV
= m_rView
.GetSdrPageView();
477 m_rView
.MarkObj(pObj
, pPV
);
479 } // if ( xObj.is() && xObj->getCurrentState() == embed::EmbedStates::UI_ACTIVE )
481 } // for(ULONG i = 0 ; i< nCount;++i)
483 // -----------------------------------------------------------------------------
484 void DlgEdFunc::colorizeOverlappedObject(SdrObject
* _pOverlappedObj
)
486 OObjectBase
* pObj
= dynamic_cast<OObjectBase
*>(_pOverlappedObj
);
489 uno::Reference
<report::XReportComponent
> xComponent
= pObj
->getReportComponent();
490 if (xComponent
.is() && xComponent
!= m_xOverlappingObj
)
492 OReportModel
* pRptModel
= static_cast<OReportModel
*>(_pOverlappedObj
->GetModel());
495 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
497 // uncolorize an old object, if there is one
498 unColorizeOverlappedObj();
500 m_nOldColor
= lcl_setColorOfObject(xComponent
, m_nOverlappedControlColor
);
501 m_xOverlappingObj
= xComponent
;
502 m_pOverlappingObj
= _pOverlappedObj
;
507 // -----------------------------------------------------------------------------
508 void DlgEdFunc::unColorizeOverlappedObj()
510 // uncolorize an old object, if there is one
511 if (m_xOverlappingObj
.is())
513 OReportModel
* pRptModel
= static_cast<OReportModel
*>(m_pOverlappingObj
->GetModel());
516 OXUndoEnvironment::OUndoEnvLock
aLock(pRptModel
->GetUndoEnv());
518 lcl_setColorOfObject(m_xOverlappingObj
, m_nOldColor
);
519 m_xOverlappingObj
= NULL
;
520 m_pOverlappingObj
= NULL
;
524 // -----------------------------------------------------------------------------
525 bool DlgEdFunc::isOverlapping(const MouseEvent
& rMEvt
)
527 bool bOverlapping
= false;
529 bOverlapping
= m_rView
.PickAnything(rMEvt
, SDRMOUSEBUTTONUP
, aVEvt
) != SDRHIT_NONE
;
530 if (bOverlapping
&& aVEvt
.pObj
)
532 colorizeOverlappedObject(aVEvt
.pObj
);
536 unColorizeOverlappedObj();
541 // -----------------------------------------------------------------------------
542 void DlgEdFunc::checkMovementAllowed(const MouseEvent
& rMEvt
)
544 if ( m_pParent
->getSectionWindow()->getViewsWindow()->IsDragObj() )
546 if ( isRectangleHit(rMEvt
) )
547 m_pParent
->getSectionWindow()->getViewsWindow()->BrkAction();
548 // object was dragged
549 Point
aPnt( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
550 if (m_bSelectionMode
)
552 m_pParent
->getSectionWindow()->getViewsWindow()->EndAction();
556 bool bControlKeyPressed
= rMEvt
.IsMod1();
557 // Don't allow points smaller 0
558 if (bControlKeyPressed
&& (aPnt
.Y() < 0))
562 m_pParent
->getSectionWindow()->getViewsWindow()->EndDragObj( bControlKeyPressed
, &m_rView
, aPnt
);
564 m_pParent
->getSectionWindow()->getViewsWindow()->ForceMarkedToAnotherPage();
565 m_pParent
->Invalidate(INVALIDATE_CHILDREN
);
568 m_pParent
->getSectionWindow()->getViewsWindow()->EndAction();
570 // -----------------------------------------------------------------------------
571 bool DlgEdFunc::isOnlyCustomShapeMarked()
574 const SdrMarkList
& rMarkList
= m_rView
.GetMarkedObjectList();
575 for (sal_uInt32 i
= 0; i
< rMarkList
.GetMarkCount();++i
)
577 SdrMark
* pMark
= rMarkList
.GetMark(i
);
578 // bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL;
579 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
580 if (pObj
->GetObjIdentifier() != OBJ_CUSTOMSHAPE
)
582 // we found an object in the marked objects, which is not a custom shape.
589 // -----------------------------------------------------------------------------
590 bool DlgEdFunc::isRectangleHit(const MouseEvent
& rMEvt
)
592 if (isOnlyCustomShapeMarked())
598 const SdrHitKind eHit
= m_rView
.PickAnything(rMEvt
, SDRMOUSEMOVE
, aVEvt
);
599 bool bIsSetPoint
= (eHit
== SDRHIT_UNMARKEDOBJECT
);
602 // no drag rect, we have to check every single select rect
603 //const Rectangle& rRect = m_rView.GetDragStat().GetActionRect();
604 const SdrDragStat
& rDragStat
= m_rView
.GetDragStat();
605 if (rDragStat
.GetDragMethod() != NULL
)
607 SdrObjListIter
aIter(*m_pParent
->getPage(),IM_DEEPNOGROUPS
);
608 SdrObject
* pObjIter
= NULL
;
609 // loop through all marked objects and check if there new rect overlapps an old one.
610 while( (pObjIter
= aIter
.Next()) != NULL
&& !bIsSetPoint
)
612 if ( m_rView
.IsObjMarked(pObjIter
)
613 && dynamic_cast<OUnoObject
*>(pObjIter
) != NULL
)
615 Rectangle aNewRect
= pObjIter
->GetLastBoundRect();
616 long nDx
= rDragStat
.IsHorFixed() ? 0 : rDragStat
.GetDX();
617 long nDy
= rDragStat
.IsVerFixed() ? 0 : rDragStat
.GetDY();
618 if ( (nDx
+ aNewRect
.Left()) < 0 )
619 nDx
= -aNewRect
.Left();
620 if ( (nDy
+ aNewRect
.Top()) < 0 )
621 nDy
= -aNewRect
.Top();
623 if ( rDragStat
.GetDragMethod()->getMoveOnly() )
624 aNewRect
.Move(nDx
,nDy
);
626 ::ResizeRect(aNewRect
,rDragStat
.GetRef1(),rDragStat
.GetXFact(),rDragStat
.GetYFact());
629 SdrObject
* pObjOverlapped
= isOver(aNewRect
,*m_pParent
->getPage(),m_rView
,false,pObjIter
);
630 bIsSetPoint
= pObjOverlapped
? true : false;
631 if (pObjOverlapped
&& !m_bSelectionMode
)
633 colorizeOverlappedObject(pObjOverlapped
);
639 else if ( aVEvt
.pObj
&& !m_bSelectionMode
)
641 colorizeOverlappedObject(aVEvt
.pObj
);
645 // -----------------------------------------------------------------------------
646 bool DlgEdFunc::setMovementPointer(const MouseEvent
& rMEvt
)
648 bool bIsSetPoint
= isRectangleHit(rMEvt
);
650 m_pParent
->SetPointer( Pointer(POINTER_NOTALLOWED
));
653 bool bCtrlKey
= rMEvt
.IsMod1();
657 m_pParent
->SetPointer( Pointer(POINTER_MOVEDATALINK
));
663 //----------------------------------------------------------------------------
665 DlgEdFuncInsert::DlgEdFuncInsert( OReportSection
* _pParent
) :
666 DlgEdFunc( _pParent
)
668 m_rView
.SetCreateMode( TRUE
);
671 //----------------------------------------------------------------------------
673 DlgEdFuncInsert::~DlgEdFuncInsert()
675 m_rView
.SetEditMode( TRUE
);
678 //----------------------------------------------------------------------------
680 BOOL
DlgEdFuncInsert::MouseButtonDown( const MouseEvent
& rMEvt
)
682 if ( DlgEdFunc::MouseButtonDown(rMEvt
) )
686 const SdrHitKind eHit
= m_rView
.PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
688 if( eHit
!= SDRHIT_UNMARKEDOBJECT
)
690 // if no action, create object
691 if ( !m_pParent
->getSectionWindow()->getViewsWindow()->IsAction() )
694 if ( m_pParent
->getSectionWindow()->getViewsWindow()->HasSelection() )
695 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(&m_rView
);
696 m_rView
.BegCreateObj(m_aMDPos
);
697 m_pParent
->getSectionWindow()->getViewsWindow()->createDefault();
702 if( !rMEvt
.IsShift() )
703 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
705 m_pParent
->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos
,&m_rView
);
711 //----------------------------------------------------------------------------
712 BOOL
DlgEdFuncInsert::MouseButtonUp( const MouseEvent
& rMEvt
)
714 if ( DlgEdFunc::MouseButtonUp( rMEvt
) )
717 const Point
aPos( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
718 const USHORT nHitLog
= USHORT ( m_pParent
->PixelToLogic(Size(3,0)).Width() );
721 // object creation active?
722 if ( m_rView
.IsCreateObj() )
724 if ( isOver(m_rView
.GetCreateObj(),*m_pParent
->getPage(),m_rView
) )
726 m_pParent
->getSectionWindow()->getViewsWindow()->BrkAction();
727 // BrkAction disables the create mode
728 m_rView
.SetCreateMode( TRUE
);
732 m_rView
.EndCreateObj(SDRCREATE_FORCEEND
);
734 if ( !m_rView
.AreObjectsMarked() )
736 m_rView
.MarkObj(aPos
, nHitLog
);
739 bReturn
= m_rView
.AreObjectsMarked();
742 OReportController
& rController
= m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
743 const SdrMarkList
& rMarkList
= m_rView
.GetMarkedObjectList();
744 for (sal_uInt32 i
= 0; i
< rMarkList
.GetMarkCount();++i
)
746 SdrMark
* pMark
= rMarkList
.GetMark(i
);
747 // bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL;
748 OOle2Obj
* pObj
= dynamic_cast<OOle2Obj
*>(pMark
->GetMarkedSdrObj());
749 if ( pObj
&& !pObj
->IsEmpty() )
751 pObj
->initializeChart(rController
.getModel());
757 checkMovementAllowed(rMEvt
);
759 if ( !m_rView
.AreObjectsMarked() &&
760 Abs(m_aMDPos
.X() - aPos
.X()) < nHitLog
&&
761 Abs(m_aMDPos
.Y() - aPos
.Y()) < nHitLog
&&
762 !rMEvt
.IsShift() && !rMEvt
.IsMod2() )
764 SdrPageView
* pPV
= m_rView
.GetSdrPageView();
766 m_rView
.PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
767 m_rView
.MarkObj(aVEvt
.pRootObj
, pPV
);
768 } // ift() && !rMEvt.IsMod2() )
769 checkTwoCklicks(rMEvt
);
770 m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView
);
774 //----------------------------------------------------------------------------
776 BOOL
DlgEdFuncInsert::MouseMove( const MouseEvent
& rMEvt
)
778 if ( DlgEdFunc::MouseMove(rMEvt
) )
780 const Point
aPos( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
782 if ( m_rView
.IsCreateObj() )
784 m_rView
.SetOrtho(SdrObjCustomShape::doConstructOrthogonal(m_rView
.getReportSection()->getSectionWindow()->getViewsWindow()->getShapeType()) ? !rMEvt
.IsShift() : rMEvt
.IsShift());
785 m_rView
.SetAngleSnapEnabled(rMEvt
.IsShift());
788 bool bIsSetPoint
= false;
789 if ( m_rView
.IsAction() )
791 bIsSetPoint
= setMovementPointer(rMEvt
);
793 m_pParent
->getSectionWindow()->getViewsWindow()->MovAction(aPos
,&m_rView
, m_rView
.GetDragMethod() == NULL
, false);
796 //if ( isOver(m_rView.GetCreateObj(),*m_pParent->getPage(),*m_pView) )
797 // m_pParent->SetPointer( Pointer(POINTER_NOTALLOWED));
800 m_pParent
->SetPointer( m_rView
.GetPreferedPointer( aPos
, m_pParent
) );
805 //----------------------------------------------------------------------------
807 DlgEdFuncSelect::DlgEdFuncSelect( OReportSection
* _pParent
) :
808 DlgEdFunc( _pParent
)
812 //----------------------------------------------------------------------------
814 DlgEdFuncSelect::~DlgEdFuncSelect()
818 //----------------------------------------------------------------------------
820 BOOL
DlgEdFuncSelect::MouseButtonDown( const MouseEvent
& rMEvt
)
822 m_bSelectionMode
= false;
823 if ( DlgEdFunc::MouseButtonDown(rMEvt
) )
827 const SdrHitKind eHit
= m_rView
.PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
828 if( eHit
== SDRHIT_UNMARKEDOBJECT
)
830 // if not multi selection, unmark all
831 if ( !rMEvt
.IsShift() )
832 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
834 if ( m_rView
.MarkObj(m_aMDPos
) && rMEvt
.IsLeft() )
837 m_pParent
->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos
, m_rView
.PickHandle(m_aMDPos
), &m_rView
);
842 m_pParent
->getSectionWindow()->getViewsWindow()->BegMarkObj(m_aMDPos
,&m_rView
);
847 if( !rMEvt
.IsShift() )
848 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
849 //m_rView.UnmarkAll();
851 if ( rMEvt
.GetClicks() == 1 )
853 m_bSelectionMode
= true;
854 m_pParent
->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos
,&m_rView
);
858 m_rView
.SdrBeginTextEdit( aVEvt
.pRootObj
,m_rView
.GetSdrPageView(),m_pParent
,sal_False
);
865 //----------------------------------------------------------------------------
867 BOOL
DlgEdFuncSelect::MouseButtonUp( const MouseEvent
& rMEvt
)
869 if ( DlgEdFunc::MouseButtonUp( rMEvt
) )
872 // get view from parent
873 const Point
aPnt( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
875 if ( rMEvt
.IsLeft() ) // left mousebutton pressed
876 checkMovementAllowed(rMEvt
);
878 m_pParent
->getSectionWindow()->getViewsWindow()->EndAction();
879 checkTwoCklicks(rMEvt
);
881 m_pParent
->SetPointer( m_rView
.GetPreferedPointer( aPnt
, m_pParent
) );
884 m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView
);
885 m_bSelectionMode
= false;
889 //----------------------------------------------------------------------------
891 BOOL
DlgEdFuncSelect::MouseMove( const MouseEvent
& rMEvt
)
893 if ( DlgEdFunc::MouseMove(rMEvt
) )
896 const Point
aPnt( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
897 bool bIsSetPoint
= false;
899 if ( m_rView
.IsAction() ) // Drag Mode
901 bIsSetPoint
= setMovementPointer(rMEvt
);
903 if (m_rView
.GetDragMethod()==NULL
)
905 m_pParent
->getSectionWindow()->getViewsWindow()->MovAction(aPnt
, &m_rView
, true, false);
909 bool bControlKey
= rMEvt
.IsMod1();
910 m_pParent
->getSectionWindow()->getViewsWindow()->MovAction(aPnt
, &m_rView
, false, bControlKey
);
916 m_pParent
->SetPointer( m_rView
.GetPreferedPointer( aPnt
, m_pParent
) );
919 unColorizeOverlappedObj();
924 // -----------------------------------------------------------------------------
925 //void DlgEdFuncSelect::SetInEditMode(SdrTextObj* _pTextObj,const MouseEvent& rMEvt, BOOL bQuickDrag)
928 // SdrPageView* pPV = m_rView.GetSdrPageView();
929 // if( _pTextObj && _pTextObj->GetPage() == pPV->GetPage() )
931 // m_rView.SetCurrentObj(OBJ_TEXT);
932 // m_rView.SetEditMode(SDREDITMODE_EDIT);
934 // BOOL bEmptyOutliner = FALSE;
936 // if (!_pTextObj->GetOutlinerParaObject() && m_rView.GetTextEditOutliner())
938 // ::SdrOutliner* pOutl = m_rView.GetTextEditOutliner();
939 // ULONG nParaAnz = pOutl->GetParagraphCount();
940 // Paragraph* p1stPara = pOutl->GetParagraph( 0 );
942 // if (nParaAnz==1 && p1stPara)
944 // // Bei nur einem Pararaph
945 // if (pOutl->GetText(p1stPara).Len() == 0)
947 // bEmptyOutliner = TRUE;
952 // if (_pTextObj != m_rView.GetTextEditObject() || bEmptyOutliner)
954 // UINT32 nInv = _pTextObj->GetObjInventor();
955 // UINT16 nSdrObjKind = _pTextObj->GetObjIdentifier();
957 // if (nInv == SdrInventor && _pTextObj->HasTextEdit() &&
958 // (nSdrObjKind == OBJ_TEXT ||
959 // nSdrObjKind == OBJ_TITLETEXT ||
960 // nSdrObjKind == OBJ_OUTLINETEXT ||
961 // (_pTextObj->ISA(SdrTextObj) && !_pTextObj->IsEmptyPresObj())))
963 // // Neuen Outliner machen (gehoert der SdrObjEditView)
964 // SdrModel* pModel = _pTextObj->GetModel();
965 // SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, pModel );
966 // pOutl->SetMinDepth(0);
967 // pOutl->SetStyleSheetPool((SfxStyleSheetPool*) pModel->GetStyleSheetPool());
968 // //pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
969 // ULONG nCntrl = pOutl->GetControlWord();
970 // nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
971 // nCntrl |= EE_CNTRL_URLSFXEXECUTE;
972 // nCntrl |= EE_CNTRL_MARKFIELDS;
973 // nCntrl |= EE_CNTRL_AUTOCORRECT;
975 // nCntrl &= ~EE_CNTRL_ULSPACESUMMATION;
976 // //if ( pModel->IsSummationOfParagraphs() )
977 // // nCntrl |= EE_CNTRL_ULSPACESUMMATION;
979 // //SetSpellOptions( nCntrl );
981 // pOutl->SetControlWord(nCntrl);
983 // uno::Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
984 // if ( xSpellChecker.is() )
985 // pOutl->SetSpeller( xSpellChecker );
987 // uno::Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
988 // if( xHyphenator.is() )
989 // pOutl->SetHyphenator( xHyphenator );
991 // pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
993 // // in einem Gliederungstext darf nicht auf die 0-te
994 // // Ebene ausgerueckt werden
995 // if (_pTextObj->GetObjInventor() == SdrInventor &&
996 // _pTextObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
998 // pOutl->SetMinDepth(1);
1001 // if (bEmptyOutliner)
1003 // m_rView.SdrEndTextEdit(sal_True);
1008 // OutlinerParaObject* pOPO = _pTextObj->GetOutlinerParaObject();
1009 // if( ( pOPO && pOPO->IsVertical() ) /*||
1010 // nSlotId == SID_ATTR_CHAR_VERTICAL ||
1011 // nSlotId == SID_TEXT_FITTOSIZE_VERTICAL */)
1012 // pOutl->SetVertical( TRUE );
1015 // if (m_rView.SdrBeginTextEdit(_pTextObj, pPV, pParent, sal_True, pOutl) && _pTextObj->GetObjInventor() == SdrInventor)
1017 // //bFirstObjCreated = TRUE;
1018 // //DeleteDefaultText();
1020 // OutlinerView* pOLV = m_rView.GetTextEditOutlinerView();
1022 // nSdrObjKind = _pTextObj->GetObjIdentifier();
1024 // SdrViewEvent aVEvt;
1025 // SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1027 // if (eHit == SDRHIT_TEXTEDIT)
1029 // // Text getroffen
1030 // if (nSdrObjKind == OBJ_TEXT ||
1031 // nSdrObjKind == OBJ_TITLETEXT ||
1032 // nSdrObjKind == OBJ_OUTLINETEXT ||
1033 // //nSlotId == SID_TEXTEDIT ||
1036 // pOLV->MouseButtonDown(rMEvt);
1037 // pOLV->MouseMove(rMEvt);
1038 // pOLV->MouseButtonUp(rMEvt);
1041 // if ( bQuickDrag && _pTextObj->GetOutlinerParaObject())
1043 // pOLV->MouseButtonDown(rMEvt);
1048 // // #98198# Move cursor to end of text
1049 // ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1050 // pOLV->SetSelection(aNewSelection);
1055 // //RestoreDefaultText();
1062 // _pTextObj = NULL;
1066 //----------------------------------------------------------------------------