summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorThomas Benisch <tbe@openoffice.org>2001-03-20 13:37:42 +0000
committerThomas Benisch <tbe@openoffice.org>2001-03-20 13:37:42 +0000
commit9b5e73c6814203f6867d07c826c005d313973ea3 (patch)
tree3eaee44b4613441c741a3a643ae2d478f0a00ae9 /basctl
parent157d59e155d698ad520ddfe0aa93b00cfd3d2e13 (diff)
added TabIndex
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/dlged/dlged.cxx13
-rw-r--r--basctl/source/dlged/dlgedobj.cxx269
-rw-r--r--basctl/source/inc/dlgedobj.hxx30
3 files changed, 271 insertions, 41 deletions
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index fb9501ddbcdf..08b2250d09c1 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlged.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tbe $ $Date: 2001-03-12 11:31:09 $
+ * last change: $Author: tbe $ $Date: 2001-03-20 14:37:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -447,6 +447,7 @@ void VCDlgEditor::SetDialog( uno::Reference< container::XNameContainer > xUnoCon
pDlgEdForm->SetUnoControlModel(xDlgMod);
pDlgEdForm->StartListening();
pDlgEdForm->SetDlgEditor( this );
+ pDlgEdForm->SortByTabIndex(); // for backward compatibility
pDlgEdForm->SetRectFromProps();
pSdrModel->GetPage(0)->InsertObject( pDlgEdForm );
pDlgEdForm->SendRepaintBroadcast(); //?
@@ -466,6 +467,7 @@ void VCDlgEditor::SetDialog( uno::Reference< container::XNameContainer > xUnoCon
aA >>= xCtrlModel;
DlgEdObj* pCtrlObj = new DlgEdObj();
pCtrlObj->SetDlgEdForm(pDlgEdForm);
+ pDlgEdForm->AddChild(pCtrlObj); // add child to parent form
pCtrlObj->SetUnoControlModel( xCtrlModel );
pCtrlObj->StartListening();
pCtrlObj->SetRectFromProps();
@@ -797,6 +799,7 @@ void VCDlgEditor::Delete()
xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= aName;
}
+ // remove control from dialog model
Reference< ::com::sun::star::container::XNameAccess > xNameAcc(pDlgEdObj->GetDlgEdForm()->GetUnoControlModel(), UNO_QUERY );
if ( xNameAcc.is() && xNameAcc->hasByName(aName) )
{
@@ -806,9 +809,15 @@ void VCDlgEditor::Delete()
xCont->removeByName( aName );
}
}
+
+ // remove child from parent form
+ pDlgEdForm->RemoveChild( pDlgEdObj );
}
}
+ // update tabindex
+ pDlgEdForm->SortByTabIndex();
+
pSdrView->BrkAction();
BOOL bDlgMarked = UnmarkDialog();
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index 52f08dc25f2f..36757696a45d 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlgedobj.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: tbe $ $Date: 2001-03-16 13:43:17 $
+ * last change: $Author: tbe $ $Date: 2001-03-20 14:37:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,6 +59,9 @@
*
************************************************************************/
+#include <vector>
+#include <algorithm>
+
#ifndef _BASCTL_DLGEDOBJ_HXX
#include "dlgedobj.hxx"
#endif
@@ -136,6 +139,18 @@ using namespace ::rtl;
//----------------------------------------------------------------------------
+// helper class for sorting by tabindex
+class TabSortHelper
+{
+public:
+ ::rtl::OUString name;
+ sal_Int16 tabindex;
+
+ bool operator<(const TabSortHelper& rComp) const { return tabindex < rComp.tabindex ? true : false; }
+};
+
+//----------------------------------------------------------------------------
+
TYPEINIT1(DlgEdObj, SdrUnoObj);
DBG_NAME(DlgEdObj);
@@ -519,33 +534,33 @@ void DlgEdObj::SetPropsFromRect()
//----------------------------------------------------------------------------
-void SAL_CALL DlgEdObj::SetNameFromProp( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
+void SAL_CALL DlgEdObj::NameChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
{
- if ( !ISA(DlgEdForm) )
- {
- // get old name
- ::rtl::OUString aOldName;
- evt.OldValue >>= aOldName;
+ // get old name
+ ::rtl::OUString aOldName;
+ evt.OldValue >>= aOldName;
- // get new name
- ::rtl::OUString aNewName;
- evt.NewValue >>= aNewName;
+ // get new name
+ ::rtl::OUString aNewName;
+ evt.NewValue >>= aNewName;
- // remove the control by the old name and insert the control by the new name in the container
- uno::Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
- if ( xNameAcc.is() && xNameAcc->hasByName(aOldName) )
+ // remove the control by the old name and insert the control by the new name in the container
+ uno::Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
+ if ( xNameAcc.is() && xNameAcc->hasByName(aOldName) )
+ {
+ uno::Reference< container::XNameContainer > xCont(xNameAcc, uno::UNO_QUERY );
+ if ( xCont.is() )
{
- uno::Reference< container::XNameContainer > xCont(xNameAcc, uno::UNO_QUERY );
- if ( xCont.is() )
- {
- uno::Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), uno::UNO_QUERY);
- uno::Any aAny;
- aAny <<= xCtrl;
- xCont->removeByName( aOldName );
- xCont->insertByName( aNewName , aAny );
- }
+ uno::Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), uno::UNO_QUERY);
+ uno::Any aAny;
+ aAny <<= xCtrl;
+ xCont->removeByName( aOldName );
+ xCont->insertByName( aNewName , aAny );
}
}
+
+ // sort the controls by tabindex
+ GetDlgEdForm()->SortByTabIndex();
}
//----------------------------------------------------------------------------
@@ -604,6 +619,84 @@ void DlgEdObj::UpdateStep()
//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::TabIndexChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ // stop listening with all childs
+ ::std::vector<DlgEdObj*> aChildList = GetDlgEdForm()->GetChilds();
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = aChildList.begin() ; aIter != aChildList.end() ; aIter++ )
+ {
+ (*aIter)->EndListening(sal_False);
+ }
+
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ // get sequence of control names
+ Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ ::std::vector<::rtl::OUString> aNameList(nCtrls);
+
+ // fill helper list
+ for ( sal_Int16 i = 0; i < nCtrls; i++ )
+ {
+ aNameList[i] = pNames[i];
+ }
+
+ // check tabindex
+ sal_Int16 nOldTabIndex;
+ evt.OldValue >>= nOldTabIndex;
+ sal_Int16 nNewTabIndex;
+ evt.NewValue >>= nNewTabIndex;
+ if (nNewTabIndex < 0)
+ {
+ nNewTabIndex = 0;
+ }
+ else if (nNewTabIndex > nCtrls - 1)
+ {
+ nNewTabIndex = nCtrls - 1;
+ }
+
+ // reorder helper list
+ ::rtl::OUString aCtrlName = aNameList[nOldTabIndex];
+ aNameList.erase( aNameList.begin() + nOldTabIndex );
+ aNameList.insert( aNameList.begin() + nNewTabIndex , aCtrlName );
+
+ // sort name container by tabindex
+ Reference< container::XNameContainer > xCont( xNameAcc, UNO_QUERY );
+ for ( i = 0; i < nCtrls; i++ )
+ {
+ // get control model
+ ::rtl::OUString aName = aNameList[i];
+ Any aCtrl = xNameAcc->getByName( aName );
+
+ // set new tabindex
+ Reference< ::com::sun::star::beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if (xPSet.is())
+ {
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) i;
+ xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) ), aTabIndex );
+ }
+
+ // sort name container
+ xCont->removeByName( aName );
+ xCont->insertByName( aName , aCtrl );
+ }
+ }
+
+ // start listening with all childs
+ for ( aIter = aChildList.begin() ; aIter != aChildList.end() ; aIter++ )
+ {
+ (*aIter)->StartListening();
+ }
+}
+
+//----------------------------------------------------------------------------
+
::rtl::OUString DlgEdObj::GetServiceName()
{
::rtl::OUString aServiceName;
@@ -824,9 +917,15 @@ FASTBOOL DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
{
sal_Bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
+ // stop listening
+ EndListening(sal_False);
+
// set parent form
pDlgEdForm = ((DlgEdPage*)GetPage())->GetDlgEd()->GetDlgEdForm();
+ // add child to parent form
+ pDlgEdForm->AddChild(this);
+
// get unique name
::rtl::OUString aOUniqueName( GetUniqueName() );
@@ -836,9 +935,6 @@ FASTBOOL DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
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") ) ||
@@ -850,13 +946,29 @@ FASTBOOL DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Label" ) ), aUniqueName );
}
+ // 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((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
- uno::Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), uno::UNO_QUERY);
+ 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);
+
+ // start listening
+ StartListening();
+
return bResult;
}
@@ -973,13 +1085,24 @@ void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::Propert
// change name of control in dialog model
else if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) )
{
- SetNameFromProp(evt);
+ if ( !ISA(DlgEdForm) )
+ {
+ NameChange(evt);
+ }
}
// update step
else if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Step")) )
{
UpdateStep();
}
+ // change tabindex
+ else if ( evt.PropertyName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TabIndex")) )
+ {
+ if ( !ISA(DlgEdForm) )
+ {
+ TabIndexChange(evt);
+ }
+ }
}
}
@@ -1076,6 +1199,20 @@ DlgEdForm::~DlgEdForm()
//----------------------------------------------------------------------------
+void DlgEdForm::AddChild( DlgEdObj* pDlgEdObj )
+{
+ pChilds.push_back( pDlgEdObj );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::RemoveChild( DlgEdObj* pDlgEdObj )
+{
+ pChilds.erase( ::std::find( pChilds.begin() , pChilds.end() , pDlgEdObj ) );
+}
+
+//----------------------------------------------------------------------------
+
void DlgEdForm::UpdateStep()
{
ULONG nObjCount;
@@ -1095,6 +1232,80 @@ void DlgEdForm::UpdateStep()
//----------------------------------------------------------------------------
+void DlgEdForm::SortByTabIndex()
+{
+ // stop listening with all childs
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; aIter++ )
+ {
+ (*aIter)->EndListening(sal_False);
+ }
+
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc( GetUnoControlModel() , UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ // get sequence of control names
+ Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ ::std::vector<TabSortHelper> aTabSortList(nCtrls);
+
+ for ( sal_Int16 i = 0; i < nCtrls; i++ )
+ {
+ // name
+ TabSortHelper aTabSortHelper;
+ aTabSortHelper.name = pNames[i];
+
+ // tabindex
+ Any aCtrl = xNameAcc->getByName( pNames[i] );
+ Reference< ::com::sun::star::beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if (xPSet.is())
+ {
+ xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) ) ) >>= aTabSortHelper.tabindex;
+ }
+
+ // insert element into helper list
+ aTabSortList[i] = aTabSortHelper;
+ }
+
+ // sort helper list by tabindex
+ ::std::sort( aTabSortList.begin() , aTabSortList.end() );
+
+ // sort name container by tabindex
+ Reference< container::XNameContainer > xCont( xNameAcc, UNO_QUERY );
+
+ for ( i = 0; i < nCtrls; i++ )
+ {
+ // get control model
+ ::rtl::OUString aName = aTabSortList[i].name;
+ Any aCtrl = xNameAcc->getByName( aName );
+
+ // set new tabindex
+ Reference< ::com::sun::star::beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if (xPSet.is())
+ {
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) i;
+ xPSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) ), aTabIndex );
+ }
+
+ // sort name container
+ xCont->removeByName( aName );
+ xCont->insertByName( aName , aCtrl );
+ }
+ }
+
+ // start listening with all childs
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; aIter++ )
+ {
+ (*aIter)->StartListening();
+ }
+}
+
+//----------------------------------------------------------------------------
+
SdrObject* DlgEdForm::CheckHit( const Point& rPnt, USHORT nTol,
const SetOfByte* pSet ) const
{
diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx
index 56b1f5ce2bce..72d7d2e6754b 100644
--- a/basctl/source/inc/dlgedobj.hxx
+++ b/basctl/source/inc/dlgedobj.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: dlgedobj.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tbe $ $Date: 2001-03-16 13:43:42 $
+ * last change: $Author: tbe $ $Date: 2001-03-20 14:34:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,6 +78,8 @@
#include <com/sun/star/container/XContainerListener.hpp>
#endif
+#include <vector>
+
class DlgEdForm;
//============================================================================
@@ -89,6 +91,7 @@ class DlgEdObj: public SdrUnoObj
friend class VCDlgEditor;
friend class VCDlgEditFactory;
friend class DlgEdPropListenerImpl;
+ friend class DlgEdForm;
private:
sal_Bool bIsListening;
@@ -114,12 +117,14 @@ public:
virtual void SetRectFromProps();
virtual void SetPropsFromRect();
- virtual void SAL_CALL SetNameFromProp( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL NameChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
virtual sal_Int32 GetStep() const;
virtual void SetStep( sal_Int32 nStep );
virtual void UpdateStep();
+ virtual void SAL_CALL TabIndexChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException);
+
::rtl::OUString GetServiceName();
::rtl::OUString GetDefaultName();
::rtl::OUString GetUniqueName();
@@ -143,6 +148,12 @@ protected:
DECL_LINK(OnCreate, void* );
+ // start listening
+ void StartListening();
+ // end listening
+ void EndListening(sal_Bool bRemoveListener = sal_True);
+ sal_Bool isListening() const { return bIsListening; }
+
public:
// PropertyChangeListener
virtual void SAL_CALL _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
@@ -151,13 +162,6 @@ public:
virtual void SAL_CALL _elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL _elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL _elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
-
-private:
- // start listening
- void StartListening();
- // end listening
- void EndListening(sal_Bool bRemoveListener = sal_True);
- sal_Bool isListening() const { return bIsListening; }
};
@@ -172,6 +176,7 @@ class DlgEdForm: public DlgEdObj
private:
VCDlgEditor* pDlgEditor;
+ ::std::vector<DlgEdObj*> pChilds;
public:
TYPEINFO();
@@ -187,7 +192,12 @@ public:
virtual void SetDlgEditor( VCDlgEditor* pEditor ) { pDlgEditor = pEditor; }
virtual VCDlgEditor* GetDlgEditor() const { return pDlgEditor; }
+ virtual void AddChild( DlgEdObj* pDlgEdObj );
+ virtual void RemoveChild( DlgEdObj* pDlgEdObj );
+ virtual ::std::vector<DlgEdObj*> GetChilds() const { return pChilds; }
+
virtual void UpdateStep();
+ virtual void SortByTabIndex();
virtual SdrObject* CheckHit(const Point& rPnt,USHORT nTol,const SetOfByte*) const;