summaryrefslogtreecommitdiffstats
path: root/forms
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-10-13 10:17:11 +0100
committerNoel Power <noel.power@novell.com>2010-10-13 10:17:11 +0100
commit5a9064d007fb1268ef72073466c554f43f0b8439 (patch)
treebbc57d9f7210e36f48d2b32ea6cd3c62a38af529 /forms
parent#i112786# make ConfigManager a well-behaved singleton (diff)
parentinitial commit for vba blob ( not including container_control stuff ) (diff)
downloadcore-5a9064d007fb1268ef72073466c554f43f0b8439.tar.gz
core-5a9064d007fb1268ef72073466c554f43f0b8439.zip
Merge branch 'vba' fix conflics ( below ), trailing ws and leading tabs
Conflicts: forms/source/component/RadioButton.cxx forms/source/inc/property.hrc
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/FormComponent.cxx4
-rw-r--r--forms/source/component/GroupManager.cxx50
-rw-r--r--forms/source/component/GroupManager.hxx2
-rw-r--r--forms/source/component/ListBox.cxx4
-rw-r--r--forms/source/component/RadioButton.cxx105
-rw-r--r--forms/source/component/RadioButton.hxx2
-rw-r--r--forms/source/inc/frm_strings.hxx1
-rw-r--r--forms/source/inc/property.hrc3
-rw-r--r--forms/source/misc/InterfaceContainer.cxx9
9 files changed, 128 insertions, 52 deletions
diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx
index f9d3ffab9709..d568ef8a6419 100644
--- a/forms/source/component/FormComponent.cxx
+++ b/forms/source/component/FormComponent.cxx
@@ -2717,8 +2717,8 @@ void SAL_CALL OBoundControlModel::setValueBinding( const Reference< XValueBindin
OSL_PRECOND( m_bSupportsExternalBinding, "OBoundControlModel::setValueBinding: How did you reach this method?" );
// the interface for this method should not have been exposed if we do not
// support binding to external data
-
- if ( !impl_approveValueBinding_nolock( _rxBinding ) )
+ // allow reset
+ if ( _rxBinding.is() && !impl_approveValueBinding_nolock( _rxBinding ) )
{
throw IncompatibleTypesException(
FRM_RES_STRING( RID_STR_INCOMPATIBLE_TYPES ),
diff --git a/forms/source/component/GroupManager.cxx b/forms/source/component/GroupManager.cxx
index fde6aa1a23ca..858a7869c864 100644
--- a/forms/source/component/GroupManager.cxx
+++ b/forms/source/component/GroupManager.cxx
@@ -124,14 +124,13 @@ OGroupComp::OGroupComp(const Reference<XPropertySet>& rxSet, sal_Int32 nInsertPo
,m_xControlModel(rxSet,UNO_QUERY)
,m_nPos( nInsertPos )
,m_nTabIndex(0)
+ ,m_aName( OGroupManager::GetGroupName( rxSet ) )
{
if (m_xComponent.is())
{
if (hasProperty( PROPERTY_TABINDEX, m_xComponent ) )
// Indices kleiner 0 werden wie 0 behandelt
m_nTabIndex = Max(getINT16(m_xComponent->getPropertyValue( PROPERTY_TABINDEX )) , sal_Int16(0));
-
- m_xComponent->getPropertyValue( PROPERTY_NAME ) >>= m_aName;
}
}
@@ -318,7 +317,8 @@ void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const
aFind->second.RemoveComponent( _xSet );
// Wenn Anzahl der Gruppenelemente == 1 ist, Gruppe deaktivieren
- if ( aFind->second.Count() == 1 )
+ sal_Int32 nCount = aFind->second.Count();
+ if ( nCount == 1 || nCount == 0 )
{
OActiveGroups::iterator aActiveFind = ::std::find(
m_aActiveGroupMap.begin(),
@@ -329,7 +329,7 @@ void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const
{
// the group is active. Deactivate it if the remaining component
// is *no* radio button
- if ( !isRadioButton( aFind->second.GetObject( 0 ) ) )
+ if ( nCount == 0 || !isRadioButton( aFind->second.GetObject( 0 ) ) )
m_aActiveGroupMap.erase( aActiveFind );
}
}
@@ -338,6 +338,8 @@ void OGroupManager::removeFromGroupMap(const ::rtl::OUString& _sGroupName,const
// Bei Component als PropertyChangeListener abmelden
_xSet->removePropertyChangeListener( PROPERTY_NAME, this );
+ if (hasProperty(PROPERTY_GROUP_NAME, _xSet))
+ _xSet->removePropertyChangeListener( PROPERTY_GROUP_NAME, this );
if (hasProperty(PROPERTY_TABINDEX, _xSet))
_xSet->removePropertyChangeListener( PROPERTY_TABINDEX, this );
}
@@ -348,10 +350,23 @@ void SAL_CALL OGroupManager::propertyChange(const PropertyChangeEvent& evt) thro
// Component aus Gruppe entfernen
::rtl::OUString sGroupName;
- if (evt.PropertyName == PROPERTY_NAME)
+ if (hasProperty( PROPERTY_GROUP_NAME, xSet ))
+ xSet->getPropertyValue( PROPERTY_GROUP_NAME ) >>= sGroupName;
+ if (evt.PropertyName == PROPERTY_NAME) {
+ if (sGroupName.getLength() > 0)
+ return; // group hasn't changed; ignore this name change.
+ // no GroupName; use Name as GroupNme
+ evt.OldValue >>= sGroupName;
+ }
+ else if (evt.PropertyName == PROPERTY_GROUP_NAME) {
evt.OldValue >>= sGroupName;
+ if (sGroupName.getLength() == 0) {
+ // No prior GroupName; fallback to Nme
+ xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+ }
+ }
else
- xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+ sGroupName = GetGroupName( xSet );
removeFromGroupMap(sGroupName,xSet);
@@ -434,8 +449,7 @@ void OGroupManager::InsertElement( const Reference<XPropertySet>& xSet )
m_pCompGroup->InsertComponent( xSet );
// Component in Gruppe aufnehmen
- ::rtl::OUString sGroupName;
- xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+ ::rtl::OUString sGroupName( GetGroupName( xSet ) );
OGroupArr::iterator aFind = m_aGroupArr.find(sGroupName);
@@ -473,6 +487,8 @@ void OGroupManager::InsertElement( const Reference<XPropertySet>& xSet )
// Bei Component als PropertyChangeListener anmelden
xSet->addPropertyChangeListener( PROPERTY_NAME, this );
+ if (hasProperty(PROPERTY_GROUP_NAME, xSet))
+ xSet->addPropertyChangeListener( PROPERTY_GROUP_NAME, this );
// Tabindex muss nicht jeder unterstuetzen
if (hasProperty(PROPERTY_TABINDEX, xSet))
@@ -489,12 +505,26 @@ void OGroupManager::RemoveElement( const Reference<XPropertySet>& xSet )
return;
// Component aus Gruppe entfernen
- ::rtl::OUString sGroupName;
- xSet->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+ ::rtl::OUString sGroupName( GetGroupName( xSet ) );
removeFromGroupMap(sGroupName,xSet);
}
+::rtl::OUString OGroupManager::GetGroupName( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xComponent )
+{
+ if (!xComponent.is())
+ return ::rtl::OUString();
+ ::rtl::OUString sGroupName;
+ if (hasProperty( PROPERTY_GROUP_NAME, xComponent )) {
+ xComponent->getPropertyValue( PROPERTY_GROUP_NAME ) >>= sGroupName;
+ if (sGroupName.getLength() == 0)
+ xComponent->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+ }
+ else
+ xComponent->getPropertyValue( PROPERTY_NAME ) >>= sGroupName;
+ return sGroupName;
+}
+
//.........................................................................
} // namespace frm
//.........................................................................
diff --git a/forms/source/component/GroupManager.hxx b/forms/source/component/GroupManager.hxx
index fc9d8ce82c61..5c3f2966ef9c 100644
--- a/forms/source/component/GroupManager.hxx
+++ b/forms/source/component/GroupManager.hxx
@@ -217,6 +217,8 @@ public:
void getGroup(sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> >& _rGroup, ::rtl::OUString& Name);
void getGroupByName(const ::rtl::OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> >& _rGroup);
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> > getControlModels();
+
+ static ::rtl::OUString GetGroupName( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xComponent );
};
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index d2de4882dead..55624b44e1c7 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -1555,6 +1555,8 @@ namespace frm
void SAL_CALL OListBoxControl::itemStateChanged(const ItemEvent& _rEvent) throw(RuntimeException)
{
// forward this to our listeners
+ Reference< XChild > xChild( getModel(), UNO_QUERY );
+ if ( xChild.is() && xChild->getParent().is() )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_aItemListeners.getLength() )
@@ -1567,6 +1569,8 @@ namespace frm
m_pItemBroadcaster->addEvent( new ItemEventDescription( _rEvent ), this );
}
}
+ else
+ m_aItemListeners.notifyEach( &XItemListener::itemStateChanged, _rEvent );
// and do the handling for the ChangeListeners
::osl::ClearableMutexGuard aGuard(m_aMutex);
diff --git a/forms/source/component/RadioButton.cxx b/forms/source/component/RadioButton.cxx
index c9a36876dd94..9a7e5095600c 100644
--- a/forms/source/component/RadioButton.cxx
+++ b/forms/source/component/RadioButton.cxx
@@ -28,6 +28,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_forms.hxx"
#include "RadioButton.hxx"
+#include "GroupManager.hxx"
#include "property.hxx"
#include "property.hrc"
#include "services.hxx"
@@ -117,6 +118,7 @@ ORadioButtonModel::ORadioButtonModel(const Reference<XMultiServiceFactory>& _rxF
m_nClassId = FormComponentType::RADIOBUTTON;
m_aLabelServiceName = FRM_SUN_COMPONENT_GROUPBOX;
initValueProperty( PROPERTY_STATE, PROPERTY_ID_STATE );
+ startAggregatePropertyListening( PROPERTY_GROUP_NAME );
}
//------------------------------------------------------------------
@@ -164,7 +166,11 @@ StringSequence SAL_CALL ORadioButtonModel::getSupportedServiceNames() throw(Runt
void ORadioButtonModel::SetSiblingPropsTo(const ::rtl::OUString& rPropName, const Any& rValue)
{
// my name
- ::rtl::OUString sMyName(m_aName);
+ ::rtl::OUString sMyGroup;
+ if (hasProperty(PROPERTY_GROUP_NAME, this))
+ this->getPropertyValue(PROPERTY_GROUP_NAME) >>= sMyGroup;
+ if (sMyGroup.getLength() == 0)
+ sMyGroup = m_aName;
// meine Siblings durchiterieren
Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY);
@@ -172,8 +178,9 @@ void ORadioButtonModel::SetSiblingPropsTo(const ::rtl::OUString& rPropName, cons
{
Reference<XPropertySet> xMyProps;
query_interface(static_cast<XWeak*>(this), xMyProps);
- ::rtl::OUString sCurrentName;
- for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i)
+ ::rtl::OUString sCurrentGroup;
+ sal_Int32 nNumSiblings = xIndexAccess->getCount();
+ for (sal_Int32 i=0; i<nNumSiblings; ++i)
{
Reference<XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), UNO_QUERY);
if (!xSiblingProperties.is())
@@ -190,8 +197,8 @@ void ORadioButtonModel::SetSiblingPropsTo(const ::rtl::OUString& rPropName, cons
continue;
// das 'zur selben Gruppe gehoeren' wird am Namen festgemacht
- xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sCurrentName;
- if (sCurrentName == sMyName)
+ sCurrentGroup = OGroupManager::GetGroupName( xSiblingProperties );
+ if (sCurrentGroup == sMyGroup)
xSiblingProperties->setPropertyValue(rPropName, rValue);
}
}
@@ -218,40 +225,7 @@ void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, cons
// die andere Richtung : wenn sich mein Name aendert ...
if (nHandle == PROPERTY_ID_NAME)
{
- // ... muss ich testen, ob ich Siblings mit dem selben Namen habe, damit ich deren ControlSource uebernehmen kann
- Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY);
- if (xIndexAccess.is())
- {
- ::rtl::OUString sName;
- ::rtl::OUString sControlSource;
-
- Reference<XPropertySet> xMyProps;
- query_interface(static_cast<XWeak*>(this), xMyProps);
- for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i)
- {
- Reference<XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), UNO_QUERY);
- if (!xSiblingProperties.is())
- continue;
-
- if (xMyProps == xSiblingProperties)
- // nur wenn ich nicht mich selber gefunden habe
- continue;
-
- sal_Int16 nType = 0;
- xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType;
- if (nType != FormComponentType::RADIOBUTTON)
- // nur Radio-Buttons
- continue;
-
- xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sName;
- // Control, das zur gleichen Gruppe gehoert ?
- if (rValue == sName)
- {
- setPropertyValue(PROPERTY_CONTROLSOURCE, xSiblingProperties->getPropertyValue(PROPERTY_CONTROLSOURCE));
- break;
- }
- }
- }
+ setControlSource();
}
if (nHandle == PROPERTY_ID_DEFAULT_STATE)
@@ -269,6 +243,52 @@ void ORadioButtonModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, cons
}
}
+void ORadioButtonModel::setControlSource()
+{
+ Reference<XIndexAccess> xIndexAccess(getParent(), UNO_QUERY);
+ if (xIndexAccess.is())
+ {
+ ::rtl::OUString sName, sGroupName;
+
+ if (hasProperty(PROPERTY_GROUP_NAME, this))
+ this->getPropertyValue(PROPERTY_GROUP_NAME) >>= sGroupName;
+ this->getPropertyValue(PROPERTY_NAME) >>= sName;
+
+ Reference<XPropertySet> xMyProps;
+ query_interface(static_cast<XWeak*>(this), xMyProps);
+ for (sal_Int32 i=0; i<xIndexAccess->getCount(); ++i)
+ {
+ Reference<XPropertySet> xSiblingProperties(*(InterfaceRef*)xIndexAccess->getByIndex(i).getValue(), UNO_QUERY);
+ if (!xSiblingProperties.is())
+ continue;
+
+ if (xMyProps == xSiblingProperties)
+ // nur wenn ich nicht mich selber gefunden habe
+ continue;
+
+ sal_Int16 nType = 0;
+ xSiblingProperties->getPropertyValue(PROPERTY_CLASSID) >>= nType;
+ if (nType != FormComponentType::RADIOBUTTON)
+ // nur Radio-Buttons
+ continue;
+
+ ::rtl::OUString sSiblingName, sSiblingGroupName;
+ if (hasProperty(PROPERTY_GROUP_NAME, xSiblingProperties))
+ xSiblingProperties->getPropertyValue(PROPERTY_GROUP_NAME) >>= sSiblingGroupName;
+ xSiblingProperties->getPropertyValue(PROPERTY_NAME) >>= sSiblingName;
+
+ if ((sGroupName.getLength() == 0 && sSiblingGroupName.getLength() == 0 && // (no group name
+ sName == sSiblingName) || // names match) or
+ (sGroupName.getLength() != 0 && sSiblingGroupName.getLength() != 0 && // (have group name
+ sGroupName == sSiblingGroupName)) // they match)
+ {
+ setPropertyValue(PROPERTY_CONTROLSOURCE, xSiblingProperties->getPropertyValue(PROPERTY_CONTROLSOURCE));
+ break;
+ }
+ }
+ }
+}
+
//------------------------------------------------------------------------------
void ORadioButtonModel::describeFixedProperties( Sequence< Property >& _rProps ) const
{
@@ -358,6 +378,13 @@ void ORadioButtonModel::_propertyChanged(const PropertyChangeEvent& _rEvent) thr
SetSiblingPropsTo( PROPERTY_STATE, aZero );
}
}
+ else if ( _rEvent.PropertyName.equals( PROPERTY_GROUP_NAME ) )
+ {
+ setControlSource();
+ // Can't call OReferenceValueComponent::_propertyChanged(), as it
+ // doesn't know what to do with the GroupName property.
+ return;
+ }
OReferenceValueComponent::_propertyChanged( _rEvent );
}
diff --git a/forms/source/component/RadioButton.hxx b/forms/source/component/RadioButton.hxx
index 3f122fe7b27c..37d129d0befc 100644
--- a/forms/source/component/RadioButton.hxx
+++ b/forms/source/component/RadioButton.hxx
@@ -84,6 +84,8 @@ private:
our mutex is aquired exactly once
*/
void setNewAggregateState( const ::com::sun::star::uno::Any& _rValue );
+
+ void setControlSource();
};
//==================================================================
diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx
index 1e3b1b1bd312..e3e8897fa14b 100644
--- a/forms/source/inc/frm_strings.hxx
+++ b/forms/source/inc/frm_strings.hxx
@@ -97,6 +97,7 @@ namespace frm
FORMS_CONSTASCII_STRING( PROPERTY_TABINDEX, "TabIndex" );
FORMS_CONSTASCII_STRING( PROPERTY_TAG, "Tag" );
FORMS_CONSTASCII_STRING( PROPERTY_NAME, "Name" );
+ FORMS_CONSTASCII_STRING( PROPERTY_GROUP_NAME, "GroupName" );
FORMS_CONSTASCII_STRING( PROPERTY_CLASSID, "ClassId" );
FORMS_CONSTASCII_STRING( PROPERTY_FETCHSIZE, "FetchSize" );
FORMS_CONSTASCII_STRING( PROPERTY_VALUE, "Value" );
diff --git a/forms/source/inc/property.hrc b/forms/source/inc/property.hrc
index 0582ce36c6ee..37070490d65c 100644
--- a/forms/source/inc/property.hrc
+++ b/forms/source/inc/property.hrc
@@ -62,6 +62,9 @@ namespace frm
#define PROPERTY_ID_CONTEXT_WRITING_MODE (PROPERTY_ID_START + 21)
#define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 22)
#define PROPERTY_ID_GRAPHIC (PROPERTY_ID_START + 23)
+#define PROPERTY_ID_GROUP_NAME (PROPERTY_ID_START + 24)
+#define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 25)
+ // free
// free
// free
// free
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index e494406f87ef..713dc8fb8909 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -154,9 +154,16 @@ void OInterfaceContainer::impl_addVbEvents_nolck_nothrow( const sal_Int32 i_nIn
xProps->getPropertyValue( rtl::OUString::createFromAscii("DefaultControl" ) ) >>= sServiceName;
Reference< ooo::vba::XVBAToOOEventDescGen > xDescSupplier( m_xServiceFactory->createInstance( rtl::OUString::createFromAscii( "ooo.vba.VBAToOOEventDesc" ) ), UNO_QUERY_THROW );
- Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( m_xServiceFactory->createInstance( sServiceName ), sCodeName );
+ Reference< XInterface > xInterface = m_xServiceFactory->createInstance( sServiceName );
+ Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( xInterface, sCodeName );
// register the vba script events
m_xEventAttacher->registerScriptEvents( i_nIndex, vbaEvents );
+
+ Reference< XComponent > xComponent( xInterface, UNO_QUERY );
+ if ( xComponent.is() )
+ {
+ xComponent->dispose();
+ }
}
while ( false );
}