summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-03-07 13:12:01 +0200
committerTor Lillqvist <tml@collabora.com>2018-05-31 21:40:46 +0300
commit96ba08dc515649f78019a1b4b3ad320280f979c6 (patch)
tree985c465eb7ed0f874151bb6804e46110938e1042 /vbahelper
parent9b28b780fb179b42d1473452c71f132d17d1247e (diff)
Add Caption property to ooo::vba::XApplicationBase
Implementation is just a dummy, though. At first I thought that it would work to get the XModel of the "current" document (as returned by getCurrentDocument()), and then get the XFrame of that, and then use the XFrame's getName() and setName(). But, it seems that getCurrentDocument() and what it calls is tightly coupled to StarBasic, and it doesn't do anything sane in the case of Automation clients. Change-Id: I74ded5114ecce06e72862f69d0c06d963e55fd75 Reviewed-on: https://gerrit.libreoffice.org/55064 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com> (cherry picked from commit 857a33404626f8df04882478d026969691624cbb)
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/source/vbahelper/vbaapplicationbase.cxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index b09de686dd31..9f27a0c7d839 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -152,6 +152,7 @@ struct VbaApplicationBase_Impl final
{
VbaTimerHashMap m_aTimerHash;
bool mbVisible;
+ OUString msCaption;
VbaApplicationBase_Impl() : mbVisible( true ) {}
@@ -263,6 +264,39 @@ void SAL_CALL VbaApplicationBase::setVisible( sal_Bool bVisible )
m_pImpl->mbVisible = bVisible; // dummy implementation
}
+OUString SAL_CALL VbaApplicationBase::getCaption()
+{
+ SbMethod* pMeth = StarBASIC::GetActiveMethod();
+ if (!pMeth)
+ {
+ // When called from Automation clients, we don't even try, as there doesn't seem to be any
+ // good way to get at the actual "caption" (title) of the application's window (any of them,
+ // if there are several). We just keep a copy of a fake caption in the VbaApplicationBase_Impl.
+ return m_pImpl->msCaption;
+ }
+
+ // No idea if this code, which uses APIs that apparently are related to StarBasic (check
+ // getCurrentDoc() in vbahelper.cxx), actually works any better.
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+ return xFrame->getName();
+}
+
+void SAL_CALL VbaApplicationBase::setCaption( const OUString& sCaption )
+{
+ // See comments in getCaption().
+
+ SbMethod* pMeth = StarBASIC::GetActiveMethod();
+ if (!pMeth)
+ {
+ m_pImpl->msCaption = sCaption;
+ return;
+ }
+
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+ xFrame->setName( sCaption );
+}
void SAL_CALL
VbaApplicationBase::OnKey( const OUString& Key, const uno::Any& Procedure )