summaryrefslogtreecommitdiff
path: root/sc/source/ui/unoobj/servuno.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-08-12 00:08:26 -0400
committerKohei Yoshida <kohei.yoshida@suse.com>2011-08-16 21:22:41 -0400
commit39b2de7545780d8897c9f28cbedfefd672cd53d7 (patch)
tree14a4dd58f4e9c8fc0b8f01560032bfaa79b023bc /sc/source/ui/unoobj/servuno.cxx
parentbc01bc636d104b435ea5ad1dcc7cab85d6dc4b9a (diff)
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.
Diffstat (limited to 'sc/source/ui/unoobj/servuno.cxx')
-rw-r--r--sc/source/ui/unoobj/servuno.cxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index e83c19437215..f53fd9de43ab 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -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;
+ }
};
//------------------------------------------------------------------------