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
) )
548 // there is an other component under use, break action
549 m_pParent
->getSectionWindow()->getViewsWindow()->BrkAction();
551 // object was dragged
552 Point
aPnt( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
553 if (m_bSelectionMode
)
555 m_pParent
->getSectionWindow()->getViewsWindow()->EndAction();
559 bool bControlKeyPressed
= rMEvt
.IsMod1();
560 // Don't allow points smaller 0
561 if (bControlKeyPressed
&& (aPnt
.Y() < 0))
565 if (m_rView
.IsDragResize())
567 // we resize the object don't resize to above sections
573 m_pParent
->getSectionWindow()->getViewsWindow()->EndDragObj( bControlKeyPressed
, &m_rView
, aPnt
);
575 m_pParent
->getSectionWindow()->getViewsWindow()->ForceMarkedToAnotherPage();
576 m_pParent
->Invalidate(INVALIDATE_CHILDREN
);
579 m_pParent
->getSectionWindow()->getViewsWindow()->EndAction();
581 // -----------------------------------------------------------------------------
582 bool DlgEdFunc::isOnlyCustomShapeMarked()
585 const SdrMarkList
& rMarkList
= m_rView
.GetMarkedObjectList();
586 for (sal_uInt32 i
= 0; i
< rMarkList
.GetMarkCount();++i
)
588 SdrMark
* pMark
= rMarkList
.GetMark(i
);
589 // bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL;
590 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
591 if (pObj
->GetObjIdentifier() != OBJ_CUSTOMSHAPE
)
593 // we found an object in the marked objects, which is not a custom shape.
600 // -----------------------------------------------------------------------------
601 bool DlgEdFunc::isRectangleHit(const MouseEvent
& rMEvt
)
603 if (isOnlyCustomShapeMarked())
609 const SdrHitKind eHit
= m_rView
.PickAnything(rMEvt
, SDRMOUSEMOVE
, aVEvt
);
610 bool bIsSetPoint
= (eHit
== SDRHIT_UNMARKEDOBJECT
);
613 // no drag rect, we have to check every single select rect
614 //const Rectangle& rRect = m_rView.GetDragStat().GetActionRect();
615 const SdrDragStat
& rDragStat
= m_rView
.GetDragStat();
616 if (rDragStat
.GetDragMethod() != NULL
)
618 SdrObjListIter
aIter(*m_pParent
->getPage(),IM_DEEPNOGROUPS
);
619 SdrObject
* pObjIter
= NULL
;
620 // loop through all marked objects and check if there new rect overlapps an old one.
621 while( (pObjIter
= aIter
.Next()) != NULL
&& !bIsSetPoint
)
623 if ( m_rView
.IsObjMarked(pObjIter
)
624 && dynamic_cast<OUnoObject
*>(pObjIter
) != NULL
)
626 Rectangle aNewRect
= pObjIter
->GetLastBoundRect();
627 long nDx
= rDragStat
.IsHorFixed() ? 0 : rDragStat
.GetDX();
628 long nDy
= rDragStat
.IsVerFixed() ? 0 : rDragStat
.GetDY();
629 if ( (nDx
+ aNewRect
.Left()) < 0 )
630 nDx
= -aNewRect
.Left();
631 if ( (nDy
+ aNewRect
.Top()) < 0 )
632 nDy
= -aNewRect
.Top();
634 if ( rDragStat
.GetDragMethod()->getMoveOnly() )
635 aNewRect
.Move(nDx
,nDy
);
637 ::ResizeRect(aNewRect
,rDragStat
.GetRef1(),rDragStat
.GetXFact(),rDragStat
.GetYFact());
640 SdrObject
* pObjOverlapped
= isOver(aNewRect
,*m_pParent
->getPage(),m_rView
,false,pObjIter
, ISOVER_IGNORE_CUSTOMSHAPES
);
641 bIsSetPoint
= pObjOverlapped
? true : false;
642 if (pObjOverlapped
&& !m_bSelectionMode
)
644 colorizeOverlappedObject(pObjOverlapped
);
650 else if ( aVEvt
.pObj
&& !m_bSelectionMode
)
652 colorizeOverlappedObject(aVEvt
.pObj
);
656 // -----------------------------------------------------------------------------
657 bool DlgEdFunc::setMovementPointer(const MouseEvent
& rMEvt
)
659 bool bIsSetPoint
= isRectangleHit(rMEvt
);
661 m_pParent
->SetPointer( Pointer(POINTER_NOTALLOWED
));
664 bool bCtrlKey
= rMEvt
.IsMod1();
668 m_pParent
->SetPointer( Pointer(POINTER_MOVEDATALINK
));
674 //----------------------------------------------------------------------------
676 DlgEdFuncInsert::DlgEdFuncInsert( OReportSection
* _pParent
) :
677 DlgEdFunc( _pParent
)
679 m_rView
.SetCreateMode( TRUE
);
682 //----------------------------------------------------------------------------
684 DlgEdFuncInsert::~DlgEdFuncInsert()
686 m_rView
.SetEditMode( TRUE
);
689 //----------------------------------------------------------------------------
691 BOOL
DlgEdFuncInsert::MouseButtonDown( const MouseEvent
& rMEvt
)
693 if ( DlgEdFunc::MouseButtonDown(rMEvt
) )
697 sal_Int16 nId
= m_rView
.GetCurrentObjIdentifier();
699 const SdrHitKind eHit
= m_rView
.PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
701 // eHit == SDRHIT_UNMARKEDOBJECT under the mouse cursor is a unmarked object
703 if (eHit
== SDRHIT_UNMARKEDOBJECT
&&
704 nId
!= OBJ_CUSTOMSHAPE
)
706 // there is an object under the mouse cursor, but not a customshape
707 // rtl::OUString suWasN = m_rView.getInsertObjString();
708 // rtl::OUString suWasN2 = m_pParent->getSectionWindow()->getViewsWindow()->GetInsertObjString();
710 m_pParent
->getSectionWindow()->getViewsWindow()->BrkAction();
714 if( eHit
!= SDRHIT_UNMARKEDOBJECT
|| nId
== OBJ_CUSTOMSHAPE
)
716 // if no action, create object
717 if ( !m_pParent
->getSectionWindow()->getViewsWindow()->IsAction() )
720 if ( m_pParent
->getSectionWindow()->getViewsWindow()->HasSelection() )
721 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(&m_rView
);
722 m_rView
.BegCreateObj(m_aMDPos
);
723 m_pParent
->getSectionWindow()->getViewsWindow()->createDefault();
728 if( !rMEvt
.IsShift() )
730 // shift key pressed?
731 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
733 m_pParent
->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos
,&m_rView
);
739 //----------------------------------------------------------------------------
740 BOOL
DlgEdFuncInsert::MouseButtonUp( const MouseEvent
& rMEvt
)
742 if ( DlgEdFunc::MouseButtonUp( rMEvt
) )
745 const Point
aPos( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
746 const USHORT nHitLog
= USHORT ( m_pParent
->PixelToLogic(Size(3,0)).Width() );
749 // object creation active?
750 if ( m_rView
.IsCreateObj() )
752 if ( isOver(m_rView
.GetCreateObj(),*m_pParent
->getPage(),m_rView
) )
754 m_pParent
->getSectionWindow()->getViewsWindow()->BrkAction();
755 // BrkAction disables the create mode
756 m_rView
.SetCreateMode( TRUE
);
760 m_rView
.EndCreateObj(SDRCREATE_FORCEEND
);
762 if ( !m_rView
.AreObjectsMarked() )
764 m_rView
.MarkObj(aPos
, nHitLog
);
767 bReturn
= m_rView
.AreObjectsMarked();
770 OReportController
& rController
= m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
771 const SdrMarkList
& rMarkList
= m_rView
.GetMarkedObjectList();
772 for (sal_uInt32 i
= 0; i
< rMarkList
.GetMarkCount();++i
)
774 SdrMark
* pMark
= rMarkList
.GetMark(i
);
775 // bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL;
776 OOle2Obj
* pObj
= dynamic_cast<OOle2Obj
*>(pMark
->GetMarkedSdrObj());
777 if ( pObj
&& !pObj
->IsEmpty() )
779 pObj
->initializeChart(rController
.getModel());
785 checkMovementAllowed(rMEvt
);
787 if ( !m_rView
.AreObjectsMarked() &&
788 Abs(m_aMDPos
.X() - aPos
.X()) < nHitLog
&&
789 Abs(m_aMDPos
.Y() - aPos
.Y()) < nHitLog
&&
790 !rMEvt
.IsShift() && !rMEvt
.IsMod2() )
792 SdrPageView
* pPV
= m_rView
.GetSdrPageView();
794 m_rView
.PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
795 m_rView
.MarkObj(aVEvt
.pRootObj
, pPV
);
796 } // ift() && !rMEvt.IsMod2() )
797 checkTwoCklicks(rMEvt
);
798 m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView
);
802 //----------------------------------------------------------------------------
804 BOOL
DlgEdFuncInsert::MouseMove( const MouseEvent
& rMEvt
)
806 if ( DlgEdFunc::MouseMove(rMEvt
) )
808 Point
aPos( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
810 if ( m_rView
.IsCreateObj() )
812 m_rView
.SetOrtho(SdrObjCustomShape::doConstructOrthogonal(m_rView
.getReportSection()->getSectionWindow()->getViewsWindow()->getShapeType()) ? !rMEvt
.IsShift() : rMEvt
.IsShift());
813 m_rView
.SetAngleSnapEnabled(rMEvt
.IsShift());
816 bool bIsSetPoint
= false;
817 if ( m_rView
.IsAction() )
819 if ( m_rView
.IsDragResize() )
821 // we resize the object don't resize to above sections
827 bIsSetPoint
= setMovementPointer(rMEvt
);
829 m_pParent
->getSectionWindow()->getViewsWindow()->MovAction(aPos
,&m_rView
, m_rView
.GetDragMethod() == NULL
, false);
832 //if ( isOver(m_rView.GetCreateObj(),*m_pParent->getPage(),*m_pView) )
833 // m_pParent->SetPointer( Pointer(POINTER_NOTALLOWED));
836 m_pParent
->SetPointer( m_rView
.GetPreferedPointer( aPos
, m_pParent
) );
841 //----------------------------------------------------------------------------
843 DlgEdFuncSelect::DlgEdFuncSelect( OReportSection
* _pParent
) :
844 DlgEdFunc( _pParent
)
848 //----------------------------------------------------------------------------
850 DlgEdFuncSelect::~DlgEdFuncSelect()
854 //----------------------------------------------------------------------------
856 BOOL
DlgEdFuncSelect::MouseButtonDown( const MouseEvent
& rMEvt
)
858 m_bSelectionMode
= false;
859 if ( DlgEdFunc::MouseButtonDown(rMEvt
) )
863 const SdrHitKind eHit
= m_rView
.PickAnything(rMEvt
, SDRMOUSEBUTTONDOWN
, aVEvt
);
864 if( eHit
== SDRHIT_UNMARKEDOBJECT
)
866 // if not multi selection, unmark all
867 if ( !rMEvt
.IsShift() )
868 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
870 if ( m_rView
.MarkObj(m_aMDPos
) && rMEvt
.IsLeft() )
873 m_pParent
->getSectionWindow()->getViewsWindow()->BegDragObj(m_aMDPos
, m_rView
.PickHandle(m_aMDPos
), &m_rView
);
878 m_pParent
->getSectionWindow()->getViewsWindow()->BegMarkObj(m_aMDPos
,&m_rView
);
883 if( !rMEvt
.IsShift() )
884 m_pParent
->getSectionWindow()->getViewsWindow()->unmarkAllObjects(NULL
);
885 //m_rView.UnmarkAll();
887 if ( rMEvt
.GetClicks() == 1 )
889 m_bSelectionMode
= true;
890 m_pParent
->getSectionWindow()->getViewsWindow()->BegMarkObj( m_aMDPos
,&m_rView
);
894 m_rView
.SdrBeginTextEdit( aVEvt
.pRootObj
,m_rView
.GetSdrPageView(),m_pParent
,sal_False
);
901 //----------------------------------------------------------------------------
903 BOOL
DlgEdFuncSelect::MouseButtonUp( const MouseEvent
& rMEvt
)
905 if ( DlgEdFunc::MouseButtonUp( rMEvt
) )
908 // get view from parent
909 const Point
aPnt( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
911 if ( rMEvt
.IsLeft() ) // left mousebutton pressed
912 checkMovementAllowed(rMEvt
);
914 m_pParent
->getSectionWindow()->getViewsWindow()->EndAction();
915 checkTwoCklicks(rMEvt
);
917 m_pParent
->SetPointer( m_rView
.GetPreferedPointer( aPnt
, m_pParent
) );
920 m_pParent
->getSectionWindow()->getViewsWindow()->getView()->getReportView()->UpdatePropertyBrowserDelayed(m_rView
);
921 m_bSelectionMode
= false;
925 //----------------------------------------------------------------------------
927 BOOL
DlgEdFuncSelect::MouseMove( const MouseEvent
& rMEvt
)
929 if ( DlgEdFunc::MouseMove(rMEvt
) )
932 Point
aPnt( m_pParent
->PixelToLogic( rMEvt
.GetPosPixel() ) );
933 bool bIsSetPoint
= false;
935 if ( m_rView
.IsAction() ) // Drag Mode
937 bIsSetPoint
= setMovementPointer(rMEvt
);
939 if (m_rView
.GetDragMethod()==NULL
)
941 // create a selection
942 m_pParent
->getSectionWindow()->getViewsWindow()->MovAction(aPnt
, &m_rView
, true, false);
946 if ( m_rView
.IsDragResize() )
948 // we resize the object don't resize to above sections
953 // grow section if it is under the current section
956 // const Size& aSectionSize = m_rView->GetSizePixel();
957 // if ( aPnt.Y() > aSectionSize.Height() )
959 // aPnt.Y() = aSectionSize.Height();
963 // drag or resize an object
964 bool bControlKey
= rMEvt
.IsMod1();
965 m_pParent
->getSectionWindow()->getViewsWindow()->MovAction(aPnt
, &m_rView
, false, bControlKey
);
971 m_pParent
->SetPointer( m_rView
.GetPreferedPointer( aPnt
, m_pParent
) );
974 unColorizeOverlappedObj();
979 // -----------------------------------------------------------------------------
980 //void DlgEdFuncSelect::SetInEditMode(SdrTextObj* _pTextObj,const MouseEvent& rMEvt, BOOL bQuickDrag)
983 // SdrPageView* pPV = m_rView.GetSdrPageView();
984 // if( _pTextObj && _pTextObj->GetPage() == pPV->GetPage() )
986 // m_rView.SetCurrentObj(OBJ_TEXT);
987 // m_rView.SetEditMode(SDREDITMODE_EDIT);
989 // BOOL bEmptyOutliner = FALSE;
991 // if (!_pTextObj->GetOutlinerParaObject() && m_rView.GetTextEditOutliner())
993 // ::SdrOutliner* pOutl = m_rView.GetTextEditOutliner();
994 // ULONG nParaAnz = pOutl->GetParagraphCount();
995 // Paragraph* p1stPara = pOutl->GetParagraph( 0 );
997 // if (nParaAnz==1 && p1stPara)
999 // // Bei nur einem Pararaph
1000 // if (pOutl->GetText(p1stPara).Len() == 0)
1002 // bEmptyOutliner = TRUE;
1007 // if (_pTextObj != m_rView.GetTextEditObject() || bEmptyOutliner)
1009 // UINT32 nInv = _pTextObj->GetObjInventor();
1010 // UINT16 nSdrObjKind = _pTextObj->GetObjIdentifier();
1012 // if (nInv == SdrInventor && _pTextObj->HasTextEdit() &&
1013 // (nSdrObjKind == OBJ_TEXT ||
1014 // nSdrObjKind == OBJ_TITLETEXT ||
1015 // nSdrObjKind == OBJ_OUTLINETEXT ||
1016 // (_pTextObj->ISA(SdrTextObj) && !_pTextObj->IsEmptyPresObj())))
1018 // // Neuen Outliner machen (gehoert der SdrObjEditView)
1019 // SdrModel* pModel = _pTextObj->GetModel();
1020 // SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, pModel );
1021 // pOutl->SetMinDepth(0);
1022 // pOutl->SetStyleSheetPool((SfxStyleSheetPool*) pModel->GetStyleSheetPool());
1023 // //pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
1024 // ULONG nCntrl = pOutl->GetControlWord();
1025 // nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
1026 // nCntrl |= EE_CNTRL_URLSFXEXECUTE;
1027 // nCntrl |= EE_CNTRL_MARKFIELDS;
1028 // nCntrl |= EE_CNTRL_AUTOCORRECT;
1030 // nCntrl &= ~EE_CNTRL_ULSPACESUMMATION;
1031 // //if ( pModel->IsSummationOfParagraphs() )
1032 // // nCntrl |= EE_CNTRL_ULSPACESUMMATION;
1034 // //SetSpellOptions( nCntrl );
1036 // pOutl->SetControlWord(nCntrl);
1038 // uno::Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
1039 // if ( xSpellChecker.is() )
1040 // pOutl->SetSpeller( xSpellChecker );
1042 // uno::Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
1043 // if( xHyphenator.is() )
1044 // pOutl->SetHyphenator( xHyphenator );
1046 // pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
1048 // // in einem Gliederungstext darf nicht auf die 0-te
1049 // // Ebene ausgerueckt werden
1050 // if (_pTextObj->GetObjInventor() == SdrInventor &&
1051 // _pTextObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
1053 // pOutl->SetMinDepth(1);
1056 // if (bEmptyOutliner)
1058 // m_rView.SdrEndTextEdit(sal_True);
1063 // OutlinerParaObject* pOPO = _pTextObj->GetOutlinerParaObject();
1064 // if( ( pOPO && pOPO->IsVertical() ) /*||
1065 // nSlotId == SID_ATTR_CHAR_VERTICAL ||
1066 // nSlotId == SID_TEXT_FITTOSIZE_VERTICAL */)
1067 // pOutl->SetVertical( TRUE );
1070 // if (m_rView.SdrBeginTextEdit(_pTextObj, pPV, pParent, sal_True, pOutl) && _pTextObj->GetObjInventor() == SdrInventor)
1072 // //bFirstObjCreated = TRUE;
1073 // //DeleteDefaultText();
1075 // OutlinerView* pOLV = m_rView.GetTextEditOutlinerView();
1077 // nSdrObjKind = _pTextObj->GetObjIdentifier();
1079 // SdrViewEvent aVEvt;
1080 // SdrHitKind eHit = m_rView.PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
1082 // if (eHit == SDRHIT_TEXTEDIT)
1084 // // Text getroffen
1085 // if (nSdrObjKind == OBJ_TEXT ||
1086 // nSdrObjKind == OBJ_TITLETEXT ||
1087 // nSdrObjKind == OBJ_OUTLINETEXT ||
1088 // //nSlotId == SID_TEXTEDIT ||
1091 // pOLV->MouseButtonDown(rMEvt);
1092 // pOLV->MouseMove(rMEvt);
1093 // pOLV->MouseButtonUp(rMEvt);
1096 // if ( bQuickDrag && _pTextObj->GetOutlinerParaObject())
1098 // pOLV->MouseButtonDown(rMEvt);
1103 // // #98198# Move cursor to end of text
1104 // ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
1105 // pOLV->SetSelection(aNewSelection);
1110 // //RestoreDefaultText();
1117 // _pTextObj = NULL;
1121 //----------------------------------------------------------------------------