'#Reference {A3B5C45B-F842-44fc-A5E5-50CED69BA86E}#2.0#0#C:\Program Files\Mindjet\MindManager 6\Mm5WebExport.dll#Mm5webexport 2.0 Type Library
'#Uses "GlobalParameterNames.mmbas"
'#Uses "GlobalUtilities.mmbas"
'#Uses "ParameterNames.mmbas"
'#Uses "TOCHandler.cls"

Option Explicit

Sub Main

    Dim addin As Mm5WebExportAddIn
    Dim webex As WebExport

    Set addin = WebExportHelper.WebExportAddIn
    Set webex = addin.ActiveWebExport

    Dim oneDoc As Document
    Dim oneTopic As Topic
    Dim oneTOCHandler As TOCHandler

    On Error GoTo ReportError

    webex.Trace("Entering BeginExport", 2)

    Set oneDoc = webex.Document
    Set oneTopic = oneDoc.CentralTopic

    'Build table of contents number array for topics
    Set oneTOCHandler = New TOCHandler
    ' Build TOC array
    oneTOCHandler.BuildOutlineNumberList(oneTopic)
    ' TOC array built and persisted as parameter, we don't need the TOC handler anymore
    Set oneTOCHandler = Nothing
 
    ' Parameter initialization (needed to prevent errors when the map has no sub topics)
    webex.SetParameter("CustomParameter.MapName", VerifyTopicText(webex,oneDoc.CentralTopic))
    webex.SetParameter("CustomParameter.CentralTopicText", "")
    webex.SetParameter("CustomParameter.NumberOfImageMaps", 1)
    webex.SetParameter("CustomParameter.ImageCounter", 0)
    ' Initialize outline level generator parameters
    webex.SetParameter("CustomParameter.TOCOutlineNumber", "0")
    webex.SetParameter("CustomParameter.TOCLastLevel", 0)
    webex.SetParameter("CustomParameter.TOCMainTopicCounter", 0)

    webex.AssurePathExists(webex.FullExportFilename(webex.GetParameter(TdFolderMapMarkers)))
    webex.VariantSets(weVariantSetTopics).RemoveAll()
    webex.VariantSets(weVariantSetIcons).RemoveAll()
    
    webex.Trace("Exiting BeginExport", 2)
    
    Exit Sub
   
ReportError:
    ProcessError(webex)
    Exit Sub
   
End Sub
