'#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"

Option Explicit

Sub Main

    Dim addin As Mm5WebExportAddIn
    Dim webex As WebExport

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

    Dim oneTopic As Topic
    Dim oneCallout As Topic
    Dim oneCalloutCollection As Topics

    Dim DoExportCalloutsSection As Boolean
    Dim MMCalloutType As Variant
    Dim template As String
    Dim topicString As String
    Dim bodyString As String

    On Error GoTo ReportError

    webex.Trace("Entering Page_CalloutNotes.htm",2)

    ' Read template file
    template = webex.ReadFile( "BoxCoNot.htm" )

    ' Assume no callouts will need to be exported
    DoExportCalloutsSection = False

    ' Store currently active topic
    Set oneTopic = webex.ActiveTopic

    If Not oneTopic.IsCentralTopic Then

        ' Don't do anything if the callout collection for the topic is empty
        Set oneCalloutCollection = oneTopic.CalloutTopics(False)

        For Each oneCallout In oneCalloutCollection
            MMCalloutType = webex.CalloutType(oneCallout)
            If Not webex.IsSuccessful Then
                Exit For
            End If
            If MMCalloutType <> weLinkCallout Then
                DoExportCalloutsSection = True
                Exit For
            End If
        Next

		If Not DoExportCalloutsSection And webex.IsSuccessful And oneTopic.HasBoundary Then
			If oneTopic.Boundary.HasSummaryTopic Then
	            MMCalloutType = webex.CalloutType(oneTopic.Boundary.SummaryTopic)
	            If MMCalloutType <> weLinkCallout Then
	                DoExportCalloutsSection = True
	            End If
	        End If
		End If

        If DoExportCalloutsSection Then

            topicString = template

            ' Process all commands and parameters
            ProcessString webex, topicString

            ' Store our processed review comments
            bodyString = bodyString + topicString

        Else

            ' No callouts to export
            bodyString = ""

        End If

    End If

    ' Write out the result
    webex.PushString(bodyString)

    webex.Trace("BoxCoNot.htm", 2)

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