'#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
    Dim aPage As Mm5WebExportLib.Page

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

    Dim count As Long
    Dim i As Long
    Dim template As String
    Dim topicString As String
    Dim bodyString As String
    Dim aRelativeMapMarkerPath As String

    Dim oneIconsCollection As Icons
    Dim oneIcon As Icon
    Dim oneTopic As Topic

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

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

    Set oneTopic = webex.ActiveTopic

    Set oneIconsCollection = oneTopic.Icons(True)

    If oneIconsCollection.Count > 0 Then 

        ' Iterate over icons
        For Each oneIcon In oneIconsCollection

            ' don't export the controlstrip icons
            Select Case oneIcon.Type

                Case mmIconTypeAutomaticHyperlink, mmIconTypeAutomaticNotes
                    ' do nothing

                Case Else

                    ' Save the graphic to the export directory
                    aRelativeMapMarkerPath = RelativeMapMarkerPath(webex, oneIcon.Name)
                    oneIcon.Save(webex.FullExportFilename(aRelativeMapMarkerPath), mmGraphicTypeGif)

                    ' Get parameters for HTML template processing
                    webex.SetParameter("CustomParameter.CodeName", oneIcon.Name)
                    webex.SetParameter("CustomParameter.CodeFileName", webex.PathToUrl(aRelativeMapMarkerPath))
                    webex.SetParameter("CustomParameter.CodeLabel", IconLabel(oneIcon, webex.Document))

                    ' Read our template
                    topicString = template

                    ' Process all commands and parameters
                    ProcessString webex, topicString

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

            End Select

        Next

    Else
        ' No icons to export
    End If

    ' Write out the result
    webex.PushString(bodyString)
 
    webex.Trace("Exiting PageIcons.mmbas",2)

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

