summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--forms/source/misc/InterfaceContainer.cxx7
-rw-r--r--offapi/com/sun/star/document/XCodeNameQuery.idl4
-rw-r--r--sc/source/ui/unoobj/servuno.cxx43
-rw-r--r--sw/source/core/unocore/unocoll.cxx10
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx2
5 files changed, 58 insertions, 8 deletions
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index e908d75472c1..af244143f69e 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -148,9 +148,12 @@ void OInterfaceContainer::impl_addVbEvents_nolck_nothrow( const sal_Int32 i_nIn
if ( xElementAsForm.is() )
break;
- rtl::OUString sCodeName;
+ // Try getting the code name from the container first (faster),
+ // then from the element if that fails (slower).
Reference<XInterface> xThis = static_cast<XContainer*>(this);
- sCodeName = xNameQuery->getCodeNameForObject(xThis, xElement);
+ rtl::OUString sCodeName = xNameQuery->getCodeNameForContainer(xThis);
+ if (sCodeName.isEmpty())
+ sCodeName = xNameQuery->getCodeNameForObject(xElement);
Reference< XPropertySet > xProps( xElement, UNO_QUERY_THROW );
::rtl::OUString sServiceName;
diff --git a/offapi/com/sun/star/document/XCodeNameQuery.idl b/offapi/com/sun/star/document/XCodeNameQuery.idl
index 47908f0549d1..35e7b7f6ae9a 100644
--- a/offapi/com/sun/star/document/XCodeNameQuery.idl
+++ b/offapi/com/sun/star/document/XCodeNameQuery.idl
@@ -38,7 +38,9 @@ module com { module sun { module star { module document {
interface XCodeNameQuery
{
//-------------------------------------------------------------------------
- string getCodeNameForObject( [in] com::sun::star::uno::XInterface aContainer, [in] com::sun::star::uno::XInterface aObj );
+ string getCodeNameForObject( [in] com::sun::star::uno::XInterface aObj );
+
+ string getCodeNameForContainer( [in] com::sun::star::uno::XInterface aObj );
};
//=============================================================================
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 9be7c614fb71..ba27fc889450 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -196,8 +196,47 @@ class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNam
public:
ScVbaCodeNameProvider( ScDocShell& rDocShell ) : mrDocShell(rDocShell) {}
// XCodeNameQuery
- rtl::OUString SAL_CALL getCodeNameForObject(
- const uno::Reference<uno::XInterface>& xContainer, const uno::Reference<uno::XInterface>& /*xIf*/ )
+ rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
+ {
+ SolarMutexGuard aGuard;
+ rtl::OUString sCodeName;
+
+ // need to find the page ( and index ) for this control
+ uno::Reference< drawing::XDrawPagesSupplier > xSupplier( mrDocShell.GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
+ sal_Int32 nLen = xIndex->getCount();
+ bool bMatched = false;
+ uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
+ for ( sal_Int32 index = 0; index < nLen; ++index )
+ {
+ try
+ {
+ uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
+ // get the www-standard container
+ uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
+ sal_Int32 nCntrls = xFormControls->getCount();
+ for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
+ {
+ uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
+ bMatched = ( xControl == xIf );
+ if ( bMatched )
+ {
+ String sName;
+ mrDocShell.GetDocument()->GetCodeName( static_cast<SCTAB>( index ), sName );
+ sCodeName = sName;
+ }
+ }
+ }
+ catch( uno::Exception& ) {}
+ if ( bMatched )
+ break;
+ }
+ // Probably should throw here ( if !bMatched )
+ return sCodeName;
+ }
+
+ rtl::OUString SAL_CALL getCodeNameForContainer( const uno::Reference<uno::XInterface>& xContainer )
throw( uno::RuntimeException )
{
SolarMutexGuard aGuard;
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 735dc6bff3cf..a2e0dbc185c7 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -106,8 +106,14 @@ class SwVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNam
public:
SwVbaCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
// XCodeNameQuery
- rtl::OUString SAL_CALL getCodeNameForObject(
- const uno::Reference< uno::XInterface >& /*xContainer*/, const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
+
+ rtl::OUString SAL_CALL getCodeNameForContainer( const uno::Reference< uno::XInterface >& /*xIf*/ ) throw( uno::RuntimeException )
+ {
+ // not implemented...
+ return rtl::OUString();
+ }
+
+ rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
{
// Initialise the code name
if ( msThisDocumentCodeName.getLength() == 0 )
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index c7e2c6ed3641..8bebe6050d44 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -449,7 +449,7 @@ void ScVbaControl::fireEvent( script::ScriptEvent& evt )
uno::Reference< lang::XMultiServiceFactory > xDocFac( m_xModel, uno::UNO_QUERY_THROW );
uno::Reference< document::XCodeNameQuery > xNameQuery( xDocFac->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooo.vba.VBACodeNameProvider")) ), uno::UNO_QUERY_THROW );
uno::Reference< uno::XInterface > xIf( xControlShape->getControl(), uno::UNO_QUERY_THROW );
- evt.ScriptCode = xNameQuery->getCodeNameForObject( xIf, xIf ); // TODO : FIX THIS!!!
+ evt.ScriptCode = xNameQuery->getCodeNameForObject( xIf );
evt.Arguments[ 0 ] = uno::makeAny( aEvt );
xScriptListener->firing( evt );
}