summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-08-12 10:34:03 -0400
committerKohei Yoshida <kohei.yoshida@suse.com>2011-08-16 21:22:42 -0400
commitd2e538a63507aa3310a854d5c1414565efa3a361 (patch)
tree5ad9bc6fcc2db39fcc5604d396bddf63d962ab05
parent4fae740db79d4e7cc97440e2bab8d1ef612d9b51 (diff)
Slightly changed the API.
-rw-r--r--forms/source/misc/InterfaceContainer.cxx8
-rw-r--r--offapi/com/sun/star/document/XCodeNameQuery.idl6
-rw-r--r--sc/source/ui/unoobj/servuno.cxx78
-rw-r--r--sw/source/core/unocore/unocoll.cxx3
4 files changed, 19 insertions, 76 deletions
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index 1301c08c255d..e908d75472c1 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -149,12 +149,8 @@ void OInterfaceContainer::impl_addVbEvents_nolck_nothrow( const sal_Int32 i_nIn
break;
rtl::OUString sCodeName;
- {
- Reference<XInterface> xThis = static_cast<XContainer*>(this);
- sal_Int32 nPageIndex = xNameQuery->getPageIndexForObject(xThis);
- if (nPageIndex >= 0)
- sCodeName = xNameQuery->getCodeNameByIndex(nPageIndex);
- }
+ Reference<XInterface> xThis = static_cast<XContainer*>(this);
+ sCodeName = xNameQuery->getCodeNameForObject(xThis, 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 4cddafee9da8..47908f0549d1 100644
--- a/offapi/com/sun/star/document/XCodeNameQuery.idl
+++ b/offapi/com/sun/star/document/XCodeNameQuery.idl
@@ -38,11 +38,7 @@ module com { module sun { module star { module document {
interface XCodeNameQuery
{
//-------------------------------------------------------------------------
- string getCodeNameForObject( [in] com::sun::star::uno::XInterface aObj );
-
- string getCodeNameByIndex( [in] long nIndex );
-
- long getPageIndexForObject( [in] com::sun::star::uno::XInterface aObj );
+ string getCodeNameForObject( [in] com::sun::star::uno::XInterface aContainer, [in] com::sun::star::uno::XInterface aObj );
};
//=============================================================================
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index f53fd9de43ab..9be7c614fb71 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -192,70 +192,16 @@ public:
class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
{
-ScDocShell* mpDocShell;
+ ScDocShell& mrDocShell;
public:
- ScVbaCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
+ ScVbaCodeNameProvider( ScDocShell& rDocShell ) : mrDocShell(rDocShell) {}
// XCodeNameQuery
- rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
+ rtl::OUString SAL_CALL getCodeNameForObject(
+ const uno::Reference<uno::XInterface>& xContainer, const uno::Reference<uno::XInterface>& /*xIf*/ )
+ throw( uno::RuntimeException )
{
SolarMutexGuard aGuard;
- rtl::OUString sCodeName;
- if ( mpDocShell )
- {
- OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
- // need to find the page ( and index ) for this control
- uno::Reference< drawing::XDrawPagesSupplier > xSupplier( mpDocShell->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;
- mpDocShell->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 getCodeNameByIndex( sal_Int32 nIndex ) throw (uno::RuntimeException)
- {
- if (!mpDocShell)
- return rtl::OUString();
-
- String aName;
- if (!mpDocShell->GetDocument()->GetCodeName(static_cast<SCTAB>(nIndex), aName))
- return rtl::OUString();
- return aName;
- }
-
- sal_Int32 SAL_CALL getPageIndexForObject( const uno::Reference<uno::XInterface>& xIf ) throw(uno::RuntimeException)
- {
- if (!mpDocShell)
- return -1;
-
- uno::Reference<drawing::XDrawPagesSupplier> xSupplier(mpDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPagesSupplier> xSupplier(mrDocShell.GetModel(), uno::UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIndex(xSupplier->getDrawPages(), uno::UNO_QUERY_THROW);
for (sal_Int32 i = 0, n = xIndex->getCount(); i < n; ++i)
@@ -266,12 +212,16 @@ public:
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);
- if (xFormControls == xIf)
- return i;
+ if (xFormControls == xContainer)
+ {
+ String aName;
+ if (mrDocShell.GetDocument()->GetCodeName(static_cast<SCTAB>(i), aName))
+ return aName;
+ }
}
catch( uno::Exception& ) {}
}
- return -1;
+ return rtl::OUString();
}
};
@@ -608,7 +558,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
if ( pDocShell && ooo::vba::isAlienExcelDoc( *pDocShell ) && isInVBAMode( *pDocShell ) )
{
OSL_TRACE("**** creating VBA Object provider");
- xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
+ xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider(*pDocShell)));
}
break;
case SC_SERVICE_VBAGLOBALS:
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index ab4950b6a129..735dc6bff3cf 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -106,7 +106,8 @@ class SwVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNam
public:
SwVbaCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
// XCodeNameQuery
- rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
+ rtl::OUString SAL_CALL getCodeNameForObject(
+ const uno::Reference< uno::XInterface >& /*xContainer*/, const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
{
// Initialise the code name
if ( msThisDocumentCodeName.getLength() == 0 )