'#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 theMapGraphic As GraphicExport
    Dim aColor As Object
    Dim oneTopic As Topic
    Dim oneDoc As Document

    Dim count As Long
    Dim k As Long
    Dim template As String
    Dim topicString As String
    Dim bodyString As String
    Dim ImagemapFilename As String
    Dim FullImagemapFilename As String
    Dim BaseImagemapFilename As String
    Dim CentralTopicExportBaseFilename As String

    Set oneTopic = webex.Document.CentralTopic 'webex.ActiveTopic
    Set aColor = New Color
    Set oneDoc = oneTopic.Document
    Set aPage = webex.ActivePage

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

    If webex.GetParameter("Strings.Show.AboutBox") Then ' display About map and info

        ' Get base file name for central topic to use to export about preview image
        CentralTopicExportBaseFilename = webex.Pages.FindPage(webex.ActiveTopic.Document.CentralTopic).BaseFilename

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

        Set aColor = oneTopic.TextColor

        ' Create preview image for the about box
        Set theMapGraphic = oneDoc.GraphicExport
        theMapGraphic.Reset
        theMapGraphic.AddCustomizedTopic(oneDoc.CentralTopic,3)
        FullImagemapFilename = webex.FullExportFilename(CentralTopicExportBaseFilename + ".jpg")
        BaseImagemapFilename = CentralTopicExportBaseFilename + ".jpg"
        If webex.ShouldWriteFile(FullImagemapFilename) Then
            theMapGraphic.ExportSized (FullImagemapFilename, mmGraphicTypeJpeg, 300, 250, True, True)
        End If

        ' Read our template
        topicString = template

        If oneDoc.Properties.Comments <> "" Then
            webex.SetParameter("CustomParameter.Comments", VerifyText(webex,oneDoc.Properties.Comments))
        Else
            webex.SetParameter("CustomParameter.Comments", "-")
        End If
        
        If oneDoc.Properties.AuthorName <> "" Then
            webex.SetParameter("CustomParameter.Author", VerifyText(webex,oneDoc.Properties.AuthorName))
        Else
            webex.SetParameter("CustomParameter.Author", "-")
        End If
        
        If oneDoc.Properties.Subject <> "" Then
            webex.SetParameter("CustomParameter.Subject", VerifyText(webex,oneDoc.Properties.Subject))
        Else
            webex.SetParameter("CustomParameter.Subject", "-")
        End If
        
        If oneDoc.Properties.CompanyName <> "" Then
            webex.SetParameter("CustomParameter.CompanyName", VerifyText(webex,oneDoc.Properties.CompanyName))
        Else
            webex.SetParameter("CustomParameter.CompanyName", "-")
        End If
        
        webex.SetParameter("CustomParameter.PreviewImage", BaseImagemapFilename)
        webex.SetParameter("CustomParameter.Title", VerifyTopicText(webex, oneDoc.CentralTopic))
        webex.SetParameter("CustomParameter.Version", oneDoc.Properties.Version)
        'webex.SetParameter("CustomParameter.Email", webex.GetParameter("Strings.User.AuthorEmail")) 'not needed, read direct

        ' Process all commands and parameters
        ProcessString webex, topicString

        ' Our merged string to write back
        bodyString = topicString
        
    End If

    ' Push the string
    webex.PushString(bodyString)

    webex.Trace("Exiting ToolsCntAbout.mmbas",2)

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