tdf#148806 doc vba: AutoOpen runs before Document_Open

The same is true for AutoClose and AutoNew.
I tested in Word 2003, and DOCX with Word 2010.

Change-Id: I7243573be0fee529494f1ab6031d89ec57805695
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141093
Tested-by: Justin Luth <jluth@mail.com>
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/sw/source/ui/vba/vbaeventshelper.cxx b/sw/source/ui/vba/vbaeventshelper.cxx
index 6e9e510..ccdb105 100644
--- a/sw/source/ui/vba/vbaeventshelper.cxx
+++ b/sw/source/ui/vba/vbaeventshelper.cxx
@@ -48,14 +48,14 @@ bool SwVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue,
{
    switch( rInfo.mnEventId )
    {
        case DOCUMENT_NEW:
            rEventQueue.emplace_back(AUTO_NEW );
        case AUTO_NEW:
            rEventQueue.emplace_back(DOCUMENT_NEW);
        break;
        case DOCUMENT_OPEN:
            rEventQueue.emplace_back(AUTO_OPEN );
        case AUTO_OPEN:
            rEventQueue.emplace_back(DOCUMENT_OPEN);
        break;
        case DOCUMENT_CLOSE:
            rEventQueue.emplace_back(AUTO_CLOSE );
        case AUTO_CLOSE:
            rEventQueue.emplace_back(DOCUMENT_CLOSE);
        break;
    }
    return true;
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 8813828..d9e1486 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -221,10 +221,10 @@ static void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVB
    switch( pSfxEventHint->GetEventId() )
    {
        case SfxEventHintId::CreateDoc:
            xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs );
            xVbaEvents->processVbaEvent(AUTO_NEW, aArgs);
        break;
        case SfxEventHintId::OpenDoc:
            xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs );
            xVbaEvents->processVbaEvent(AUTO_OPEN, aArgs);
        break;
        default: break;
    }
@@ -385,7 +385,7 @@ bool SwDocShell::PrepareClose( bool bUI )
        {
            using namespace com::sun::star::script::vba::VBAEventId;
            uno::Sequence< uno::Any > aNoArgs;
            xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aNoArgs );
            xVbaEvents->processVbaEvent(AUTO_CLOSE, aNoArgs);
        }
    }
    return bRet;