diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-08-13 01:20:31 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-08-16 21:22:44 -0400 |
commit | c8f40655eac948bb8b7c9387e7333160c0088f4f (patch) | |
tree | 0940fa43c94c794d9f9f6e7fa7dbaffcc132e524 /sc | |
parent | 80b1e662777100a7dfd80176a2b528880a838167 (diff) |
Keep the container and object separate methods.
ScVbaControl doesn't have any container instance to pass to the
old method.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/unoobj/servuno.cxx | 43 |
1 files changed, 41 insertions, 2 deletions
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; |