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

Sub Main

    Dim addin As Mm5WebExportAddIn
    Dim webex As WebExport
    Dim aPage As Mm5WebExportLib.Page
    Dim oneTOCHandler As TOCHandler

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

    Dim theMapGraphic As GraphicExport
    Dim oneTopic As Topic
    Dim nextTopic As Topic
    Dim i As Long

    Dim template As String
    Dim topicString As String
    Dim bodyString As String

    On Error GoTo ReportError
    
    webex.Trace("Entering BoxPartMap.mmbas",2)

    Set oneTOCHandler = New TOCHandler
    Set oneTopic = webex.ActiveTopic
    ' If user hasn't disabled the export of subtopic links in the user interface
    If (webex.GetParameter("Strings.Show.SubLinks") = "links") Then  ' text style links

        For i = 1 To oneTopic.SubTopics(False).Count
            
            Dim link as HyperlinkData

            Set nextTopic = oneTopic.SubTopics(False).Item(i)

            template = webex.ReadFile("BoxPartMapSubTp.htm")

            ' Get parameters for HTML template processing
            link = TopicHyperlink(webex, nextTopic)
            webex.SetParameter("CustomParameter.SubTopicItemURL", link.Url)
            webex.SetParameter("CustomParameter.SubTopicItemText", _
                                 oneTOCHandler.GetOutlineNumberForTopic(nextTopic, _
                                                                        webex.GetParameter("Strings.Show.NumberToLevel")) _
                               + VerifyTopicText(webex, nextTopic))
            webex.SetParameter("CustomParameter.SubTopicItemTarget", TargetAttribute(link))

            ' Read our template
            topicString = template

            ' Process all commands and parameters
            ProcessString webex, topicString

            ' Our merged string to write back
            bodyString = bodyString + topicString

        Next i

        ' Write out the result
        webex.PushString(bodyString)

      Else

        ' User has chosen to not include the sub topics section
        webex.PushString("")

    End If

    webex.Trace("Exiting BoxPartMapSubTp.htm",2)

    Exit Sub
 
ReportError:
    ProcessError(webex)
    Exit Sub
 
End Sub
