Author: hanya
Date: Sat May 17 10:16:40 2014
New Revision: 1595439

URL: http://svn.apache.org/r1595439
Log:
#i113481# query script invocation from the current frame when the controller is 
not yet attached

Modified:
    openoffice/trunk/main/scripting/source/protocolhandler/scripthandler.cxx

Modified: 
openoffice/trunk/main/scripting/source/protocolhandler/scripthandler.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/scripting/source/protocolhandler/scripthandler.cxx?rev=1595439&r1=1595438&r2=1595439&view=diff
==============================================================================
--- openoffice/trunk/main/scripting/source/protocolhandler/scripthandler.cxx 
(original)
+++ openoffice/trunk/main/scripting/source/protocolhandler/scripthandler.cxx 
Sat May 17 10:16:40 2014
@@ -170,7 +170,28 @@ void SAL_CALL ScriptProtocolHandler::dis
 
                 OSL_ENSURE( xDocumentScripts.is(), 
"ScriptProtocolHandler::dispatchWithNotification: can't do the security check!" 
);
                 if ( !xDocumentScripts.is() || 
!xDocumentScripts->getAllowMacroExecution() )
+                {
+                    if ( xListener.is() )
+                    {
+                        ::com::sun::star::frame::DispatchResultEvent aEvent(
+                                static_cast< ::cppu::OWeakObject* >( this ), 
+                                
::com::sun::star::frame::DispatchResultState::FAILURE, 
+                                invokeResult );
+                        try
+                        {
+                            xListener->dispatchFinished( aEvent ) ;
+                        }
+                        catch(RuntimeException & e)
+                        {
+                            OSL_TRACE( 
+                                
"ScriptProtocolHandler::dispatchWithNotification: caught RuntimeException"
+                                "while dispatchFinished with failture of the 
execution %s",
+                                ::rtl::OUStringToOString( e.Message,
+                                RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+                        }
+                    }
                     return;
+                }
             }
 
             // Creates a ScriptProvider ( if one is not created already ) 
@@ -345,6 +366,25 @@ ScriptProtocolHandler::getScriptInvocati
             if ( !m_xScriptInvocation.set( xController->getModel(), UNO_QUERY 
) )
                 m_xScriptInvocation.set( xController, UNO_QUERY );
         }
+        else
+        {
+            Reference< XFrame > xFrame( m_xFrame.get(), UNO_QUERY );
+            if ( xFrame.is() )
+            {
+                SfxFrame* pFrame = NULL;
+                for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = 
SfxFrame::GetNext( *pFrame ) )
+                {
+                    if ( pFrame->GetFrameInterface() == xFrame )
+                        break;
+                }
+                SfxObjectShell* pDocShell = pFrame ? 
pFrame->GetCurrentDocument() : SfxObjectShell::Current();
+                if ( pDocShell )
+                {
+                    Reference< XModel > xModel( pDocShell->GetModel() );
+                    m_xScriptInvocation.set( xModel, UNO_QUERY );
+                }
+            }
+        }
     }
     return m_xScriptInvocation.is();
 }


Reply via email to