summaryrefslogtreecommitdiff
path: root/basctl/source/dlged
diff options
context:
space:
mode:
authorThomas Benisch <tbe@openoffice.org>2002-04-24 13:52:16 +0000
committerThomas Benisch <tbe@openoffice.org>2002-04-24 13:52:16 +0000
commit70e3bad60eebcfe704b21399c9c1cb129dc9d3b6 (patch)
tree464a35a20d72520c0be906f33fdfc39d978261ed /basctl/source/dlged
parenta281906bd6e2c321718791e15a8c831ccb5d5cdf (diff)
#98585# ACC: Unable to create a new Basic Dialog with the keyboard
Diffstat (limited to 'basctl/source/dlged')
-rw-r--r--basctl/source/dlged/dlgedfunc.cxx242
-rw-r--r--basctl/source/dlged/dlgedobj.cxx148
-rw-r--r--basctl/source/dlged/dlgedview.cxx23
3 files changed, 319 insertions, 94 deletions
diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx
index 37ab1ffe918c..0745b44fe672 100644
--- a/basctl/source/dlged/dlgedfunc.cxx
+++ b/basctl/source/dlged/dlgedfunc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlgedfunc.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: tbe $ $Date: 2001-11-12 22:38:41 $
+ * last change: $Author: tbe $ $Date: 2002-04-24 14:52:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,10 +75,6 @@
#include "dlged.hxx"
#endif
-#ifndef _BASCTL_DLGEDOBJ_HXX
-#include "dlgedobj.hxx"
-#endif
-
#ifndef _SV_SELENG_HXX //autogen
#include <vcl/seleng.hxx>
#endif
@@ -185,15 +181,230 @@ BOOL DlgEdFunc::MouseMove( const MouseEvent& rMEvt )
BOOL DlgEdFunc::KeyInput( const KeyEvent& rKEvt )
{
- if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE )
+ BOOL bReturn = FALSE;
+
+ SdrView* pView = pParent->GetView();
+ Window* pWindow = pParent->GetWindow();
+
+ KeyCode aCode = rKEvt.GetKeyCode();
+ USHORT nCode = aCode.GetCode();
+
+ switch ( nCode )
{
- if( pParent->GetView() )
+ case KEY_ESCAPE:
{
- pParent->GetView()->BrkAction();
- return TRUE;
+ if ( pView->IsAction() )
+ {
+ pView->BrkAction();
+ bReturn = TRUE;
+ }
+ else if ( pView->HasMarkedObj() )
+ {
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+ if ( pHdl )
+ ((SdrHdlList&)rHdlList).ResetFocusHdl();
+ else
+ pView->UnmarkAll();
+
+ bReturn = TRUE;
+ }
+ }
+ break;
+ case KEY_TAB:
+ {
+ if ( !aCode.IsMod1() && !aCode.IsMod2() )
+ {
+ // mark next object
+ if ( !pView->MarkNextObj( !aCode.IsShift() ) )
+ {
+ // if no next object, mark first/last
+ pView->UnmarkAllObj();
+ pView->MarkNextObj( !aCode.IsShift() );
+ }
+
+ if ( pView->HasMarkedObj() )
+ pView->MakeVisible( pView->GetAllMarkedRect(), *pWindow );
+
+ bReturn = TRUE;
+ }
+ else if ( aCode.IsMod1() )
+ {
+ // selected handle
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ ((SdrHdlList&)rHdlList).TravelFocusHdl( !aCode.IsShift() );
+
+ // guarantee visibility of focused handle
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+ if ( pHdl )
+ {
+ Point aHdlPosition( pHdl->GetPos() );
+ Rectangle aVisRect( aHdlPosition - Point( 100, 100 ), Size( 200, 200 ) );
+ pView->MakeVisible( aVisRect, *pWindow );
+ }
+
+ bReturn = TRUE;
+ }
}
+ break;
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ {
+ long nX = 0;
+ long nY = 0;
+
+ if ( nCode == KEY_UP )
+ {
+ // scroll up
+ nX = 0;
+ nY = -1;
+ }
+ else if ( nCode == KEY_DOWN )
+ {
+ // scroll down
+ nX = 0;
+ nY = 1;
+ }
+ else if ( nCode == KEY_LEFT )
+ {
+ // scroll left
+ nX = -1;
+ nY = 0;
+ }
+ else if ( nCode == KEY_RIGHT )
+ {
+ // scroll right
+ nX = 1;
+ nY = 0;
+ }
+
+ if ( pView->HasMarkedObj() && !aCode.IsMod1() )
+ {
+ if ( aCode.IsMod2() )
+ {
+ // move in 1 pixel distance
+ Size aPixelSize = pWindow ? pWindow->PixelToLogic( Size( 1, 1 ) ) : Size( 100, 100 );
+ nX *= aPixelSize.Width();
+ nY *= aPixelSize.Height();
+ }
+ else
+ {
+ // move in 1 mm distance
+ nX *= 100;
+ nY *= 100;
+ }
+
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if ( pHdl == 0 )
+ {
+ // no handle selected
+ if ( pView->IsMoveAllowed() )
+ {
+ // restrict movement to work area
+ const Rectangle& rWorkArea = pView->GetWorkArea();
+
+ if ( !rWorkArea.IsEmpty() )
+ {
+ Rectangle aMarkRect( pView->GetMarkedObjRect() );
+ aMarkRect.Move( nX, nY );
+
+ if ( !rWorkArea.IsInside( aMarkRect ) )
+ {
+ if ( aMarkRect.Left() < rWorkArea.Left() )
+ nX += rWorkArea.Left() - aMarkRect.Left();
+
+ if ( aMarkRect.Right() > rWorkArea.Right() )
+ nX -= aMarkRect.Right() - rWorkArea.Right();
+
+ if ( aMarkRect.Top() < rWorkArea.Top() )
+ nY += rWorkArea.Top() - aMarkRect.Top();
+
+ if ( aMarkRect.Bottom() > rWorkArea.Bottom() )
+ nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
+ }
+ }
+
+ if ( nX != 0 || nY != 0 )
+ {
+ pView->MoveAllMarked( Size( nX, nY ) );
+ pView->MakeVisible( pView->GetAllMarkedRect(), *pWindow );
+ }
+ }
+ }
+ else
+ {
+ // move the handle
+ if ( pHdl && ( nX || nY ) )
+ {
+ Point aStartPoint( pHdl->GetPos() );
+ Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) );
+ const SdrDragStat& rDragStat = pView->GetDragStat();
+
+ // start dragging
+ pView->BegDragObj( aStartPoint, 0, pHdl, 0 );
+
+ if ( pView->IsDragObj() )
+ {
+ FASTBOOL bWasNoSnap = rDragStat.IsNoSnap();
+ BOOL bWasSnapEnabled = pView->IsSnapEnabled();
+
+ // switch snapping off
+ if ( !bWasNoSnap )
+ ((SdrDragStat&)rDragStat).SetNoSnap( TRUE );
+ if ( bWasSnapEnabled )
+ pView->SetSnapEnabled( FALSE );
+
+ pView->MovAction( aEndPoint );
+ pView->EndDragObj();
+
+ // restore snap
+ if ( !bWasNoSnap )
+ ((SdrDragStat&)rDragStat).SetNoSnap( bWasNoSnap );
+ if ( bWasSnapEnabled )
+ pView->SetSnapEnabled( bWasSnapEnabled );
+ }
+
+ // make moved handle visible
+ Rectangle aVisRect( aEndPoint - Point( 100, 100 ), Size( 200, 200 ) );
+ pView->MakeVisible( aVisRect, *pWindow );
+ }
+ }
+ }
+ else
+ {
+ // scroll page
+ ScrollBar* pScrollBar = ( nX != 0 ) ? pParent->GetHScroll() : pParent->GetVScroll();
+ if ( pScrollBar )
+ {
+ long nRangeMin = pScrollBar->GetRangeMin();
+ long nRangeMax = pScrollBar->GetRangeMax();
+ long nThumbPos = pScrollBar->GetThumbPos() + ( ( nX != 0 ) ? nX : nY ) * pScrollBar->GetLineSize();
+ if ( nThumbPos < nRangeMin )
+ nThumbPos = nRangeMin;
+ if ( nThumbPos > nRangeMax )
+ nThumbPos = nRangeMax;
+ pScrollBar->SetThumbPos( nThumbPos );
+ pParent->DoScroll( pScrollBar );
+ }
+ }
+
+ bReturn = TRUE;
+ }
+ break;
+ default:
+ {
+ }
+ break;
}
- return FALSE;
+
+ if ( bReturn )
+ pWindow->ReleaseMouse();
+
+ return bReturn;
}
//----------------------------------------------------------------------------
@@ -280,14 +491,6 @@ BOOL DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt )
{
SdrMark* pMark = rMarkList.GetMark(0);
SdrObject* pObj = pMark->GetObj();
-
- DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
- if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
- {
- sal_Int32 nCurStep = pDlgEdObj->GetDlgEdForm()->GetStep();
- pDlgEdObj->SetStep( nCurStep );
- pDlgEdObj->UpdateStep();
- }
}
if ( !pView->HasMarkedObj() )
@@ -498,4 +701,3 @@ BOOL DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
}
//----------------------------------------------------------------------------
-
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index 99e7be9434f4..8d246babd5ea 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlgedobj.cxx,v $
*
- * $Revision: 1.27 $
+ * $Revision: 1.28 $
*
- * last change: $Author: tbe $ $Date: 2001-09-25 11:06:10 $
+ * last change: $Author: tbe $ $Date: 2002-04-24 14:51:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -407,20 +407,6 @@ sal_Int32 DlgEdObj::GetStep() const
//----------------------------------------------------------------------------
-void DlgEdObj::SetStep( sal_Int32 nStep )
-{
- // set step property
- uno::Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), uno::UNO_QUERY );
- if (xPSet.is())
- {
- uno::Any aStep;
- aStep <<= nStep;
- xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Step" ) ), aStep );
- }
-}
-
-//----------------------------------------------------------------------------
-
void DlgEdObj::UpdateStep()
{
sal_Int32 nCurStep = GetDlgEdForm()->GetStep();
@@ -464,7 +450,7 @@ void SAL_CALL DlgEdObj::TabIndexChange( const ::com::sun::star::beans::Property
Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
const ::rtl::OUString* pNames = aNames.getConstArray();
sal_Int32 nCtrls = aNames.getLength();
- ::std::vector< ::rtl::OUString > aNameList(nCtrls);
+ ::std::vector< ::rtl::OUString > aNameList( nCtrls );
// fill helper list
for ( sal_Int16 i = 0; i < nCtrls; i++ )
@@ -477,14 +463,10 @@ void SAL_CALL DlgEdObj::TabIndexChange( const ::com::sun::star::beans::Property
evt.OldValue >>= nOldTabIndex;
sal_Int16 nNewTabIndex;
evt.NewValue >>= nNewTabIndex;
- if (nNewTabIndex < 0)
- {
+ if ( nNewTabIndex < 0 )
nNewTabIndex = 0;
- }
- else if (nNewTabIndex > nCtrls - 1)
- {
+ else if ( nNewTabIndex > nCtrls - 1 )
nNewTabIndex = nCtrls - 1;
- }
// reorder helper list
::rtl::OUString aCtrlName = aNameList[nOldTabIndex];
@@ -502,7 +484,7 @@ void SAL_CALL DlgEdObj::TabIndexChange( const ::com::sun::star::beans::Property
// set new tabindex
Reference< ::com::sun::star::beans::XPropertySet > xPSet;
aCtrl >>= xPSet;
- if (xPSet.is())
+ if ( xPSet.is() )
{
Any aTabIndex;
aTabIndex <<= (sal_Int16) i;
@@ -513,6 +495,9 @@ void SAL_CALL DlgEdObj::TabIndexChange( const ::com::sun::star::beans::Property
xCont->removeByName( aName );
xCont->insertByName( aName , aCtrl );
}
+
+ // reorder objects in drawing page
+ GetModel()->GetPage(0)->SetObjectOrdNum( nOldTabIndex + 1, nNewTabIndex + 1 );
}
// start listening with all childs
@@ -857,68 +842,91 @@ FASTBOOL DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
{
sal_Bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
+ SetDefaults();
+
+ return bResult;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetDefaults()
+{
// stop listening
- EndListening(sal_False);
+ EndListening( sal_False );
// set parent form
pDlgEdForm = ((DlgEdPage*)GetPage())->GetDlgEdForm();
// add child to parent form
- pDlgEdForm->AddChild(this);
+ pDlgEdForm->AddChild( this );
+
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ // get unique name
+ ::rtl::OUString aOUniqueName( GetUniqueName() );
+
+ // set name property
+ Any aUniqueName;
+ aUniqueName <<= aOUniqueName;
+ xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), aUniqueName );
+
+ // set labels
+ ::rtl::OUString aServiceName = GetServiceName();
+ if (aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ||
+ aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ||
+ aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ||
+ aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ||
+ aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) )
+ {
+ xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Label" ) ), aUniqueName );
+ }
- // get unique name
- ::rtl::OUString aOUniqueName( GetUniqueName() );
+ // set number formats supplier for formatted field
+ if ( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) )
+ {
+ Reference< util::XNumberFormatsSupplier > xSupplier = GetDlgEdForm()->GetDlgEditor()->GetNumberFormatsSupplier();
+ if ( xSupplier.is() )
+ {
+ Any aSupplier;
+ aSupplier <<= xSupplier;
+ xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FormatsSupplier" ) ), aSupplier );
+ }
+ }
- // set name property
- uno::Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), uno::UNO_QUERY );
- uno::Any aUniqueName;
- aUniqueName <<= aOUniqueName;
- xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), aUniqueName );
+ // set geometry properties
+ SetPropsFromRect();
- // set labels
- ::rtl::OUString aServiceName = GetServiceName();
- if (aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlButtonModel") ) ||
- aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) ||
- aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlCheckBoxModel") ) ||
- aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ||
- aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlFixedTextModel") ) )
- {
- xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Label" ) ), aUniqueName );
- }
+ Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
+ if ( xCont.is() )
+ {
+ // set tabindex
+ Sequence< OUString > aNames = xCont->getElementNames();
+ uno::Any aTabIndex;
+ aTabIndex <<= (sal_Int16) aNames.getLength();
+ xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) ), aTabIndex );
+
+ // set step
+ Reference< beans::XPropertySet > xPSetForm( xCont, UNO_QUERY );
+ if ( xPSetForm.is() )
+ {
+ Any aStep = xPSetForm->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Step" ) ) );
+ xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Step" ) ), aStep );
+ }
- // set number formats supplier for formatted field
- if ( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.awt.UnoControlFormattedFieldModel") ) )
- {
- uno::Reference< util::XNumberFormatsSupplier > xSupplier = GetDlgEdForm()->GetDlgEditor()->GetNumberFormatsSupplier();
- uno::Any aSupplier;
- aSupplier <<= xSupplier;
- xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FormatsSupplier" ) ), aSupplier );
+ // insert control model in dialog model
+ Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
+ Any aAny;
+ aAny <<= xCtrl;
+ xCont->insertByName( aOUniqueName , aAny );
+ }
}
- // set geometry properties
- SetPropsFromRect();
-
- // set tabindex
- uno::Reference< container::XNameAccess > xNameAcc( (GetDlgEdForm()->GetUnoControlModel()) , uno::UNO_QUERY );
- Sequence< OUString > aNames = xNameAcc->getElementNames();
- uno::Any aTabIndex;
- aTabIndex <<= (sal_Int16) aNames.getLength();
- xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) ), aTabIndex );
-
- // insert control model in dialog model
- uno::Reference< container::XNameContainer > xC( xNameAcc , uno::UNO_QUERY );
- uno::Reference< awt::XControlModel > xCtrl( xPSet , uno::UNO_QUERY );
- uno::Any aAny;
- aAny <<= xCtrl;
- xC->insertByName( aOUniqueName , aAny );
-
// dialog model changed
- GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(TRUE);
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged( TRUE );
// start listening
StartListening();
-
- return bResult;
}
//----------------------------------------------------------------------------
diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx
index f1ab40a90386..028b6dcf8648 100644
--- a/basctl/source/dlged/dlgedview.cxx
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlgedview.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: tbe $ $Date: 2001-11-14 11:12:04 $
+ * last change: $Author: tbe $ $Date: 2002-04-24 14:50:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,6 +64,10 @@
#include "dlgedview.hxx"
#endif
+#ifndef _BASCTL_DLGED_HXX
+#include "dlged.hxx"
+#endif
+
#ifndef _SVXIDS_HRC
#include <svx/svxids.hrc>
#endif
@@ -97,8 +101,9 @@ void DlgEdView::MarkListHasChanged()
//----------------------------------------------------------------------------
-DlgEdView::DlgEdView(SdrModel* pModel1, OutputDevice* pOut) :
- SdrView( pModel1, pOut )
+DlgEdView::DlgEdView( SdrModel* pModel, OutputDevice* pOut, DlgEditor* pEditor )
+ :SdrView( pModel, pOut )
+ ,pDlgEditor( pEditor )
{
}
@@ -110,3 +115,13 @@ DlgEdView::~DlgEdView()
//----------------------------------------------------------------------------
+void DlgEdView::MakeVisible( const Rectangle& rRect, Window& rWin )
+{
+ SdrPaintView::MakeVisible( rRect, rWin );
+
+ if ( pDlgEditor )
+ pDlgEditor->UpdateScrollBars();
+}
+
+//----------------------------------------------------------------------------
+