Kaydet (Commit) 39b2de75 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Code page should be the same for the same drawing page.

This removes O(n^2) from the process of querying the code pages for
form elements.
üst bc01bc63
......@@ -148,7 +148,15 @@ void OInterfaceContainer::impl_addVbEvents_nolck_nothrow( const sal_Int32 i_nIn
if ( xElementAsForm.is() )
break;
::rtl::OUString sCodeName( xNameQuery->getCodeNameForObject( xElement ) );
rtl::OUString sCodeName;
{
Reference<XInterface> xThis = static_cast<XContainer*>(this);
sal_Int32 nPageIndex = xNameQuery->getPageIndexForObject(xThis);
if (nPageIndex >= 0)
sCodeName = xNameQuery->getCodeNameByIndex(nPageIndex);
else
sCodeName = xNameQuery->getCodeNameForObject(xElement);
}
Reference< XPropertySet > xProps( xElement, UNO_QUERY_THROW );
::rtl::OUString sServiceName;
......
......@@ -39,6 +39,10 @@ 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 );
};
//=============================================================================
......
......@@ -239,6 +239,40 @@ public:
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<container::XIndexAccess> xIndex(xSupplier->getDrawPages(), uno::UNO_QUERY_THROW);
for (sal_Int32 i = 0, n = xIndex->getCount(); i < n; ++i)
{
try
{
uno::Reference<form::XFormsSupplier> xFormSupplier(xIndex->getByIndex(i), 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);
if (xFormControls == xIf)
return i;
}
catch( uno::Exception& ) {}
}
return -1;
}
};
//------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment