'---------------------------------------------------
' mm2xtm Is free software; you can redistribute it And/Or
' modify it under the terms of the GNU General Public License
' As published by the Free Software Foundation.
'
' This software Is distributed In the hope that it will be useful,
' but WITHOUT Any WARRANTY; without even the implied warranty of
' MERCHANTABILITY Or FITNESS For A PARTICULAR PURPOSE.
'
' You should have received a copy of the GNU General Public License
' along With this software. If Not, Write To the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-
' 1307, USA.
'
' See the GPL In the COPYING.GPL file For more details.
'
' Author: Michel Kern (mkern@club-internet.fr)
' Description: export MindManager to XML Topic Maps
' Version: 1 july 2003
'---------------------------------------------------
Dim nbBranch As Integer
Sub Main
Dim MindDoc As Document
Dim aBranch As Branch
Dim FileName As String
Dim NewName As String
Dim fileId As Integer
fileId = FreeFile
'Determine if there is a document open in MindManager
If Documents.Count > 0 Then
'Assign the active document to our "MindDoc-object variable"
Set MindDoc = ActiveDocument
Else
MsgBox("Unable to proceed, no document is open.", vbCritical)
End ' End script execution since no document is open
End If
FileName = ActiveDocument.FullName
NewName = Replace$(FileName, "mmp", "xml",Len(FileName) - 4,1)
FileName = GetFilePath$(NewName,,"Export As",3)
If Len(FileName) < 1 Then
FileName = "C:\temp\testfile.xml"
End If
Set aBranch = ActiveDocument.MapTitle() ' Then select the map-title
nbBranch = 0
Open FileName For Output As #fileId
Print #fileId, "
Print #fileId, ""
Print #fileId, ""
Call ConvertBranchToTopic(aBranch, fileId)
Set aBranch = ActiveDocument.MapTitle()
Call ConvertAssociations(aBranch, fileId)
Print #fileId, ""
Close #fileId
End Sub
' A MindManager Branch is converted to XTM tag
Function ConvertBranchToTopic(ByVal aBranch As Branch, fileId As Integer)
Dim nextBranch As Branch
Dim topicId As String
topicId = Str$(aBranch.ObjectID) + "_" + LCase(aBranch.Text)
topicId = Replace$(topicId, " ", "_")
topicId = Replace$(topicId, "&", "AND")
' association tag (Relation to Parent Branch)
'---------------------------------------------------------------------------
If (nbBranch <> 0) Then
Dim topicRef As String
topicRef = "#" + Str$(aBranch.ParentBranch.ObjectID) + "_" + LCase(aBranch.ParentBranch.Text)
topicRef = Replace$(topicRef, " ", "_")
topicRef = Replace$(topicRef, "&", "AND")
Print #fileId, ""
'Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, ""
End If
'---------------------------------------------------------------------------
Print #fileId, Space$(Indent); ""
' baseName tag (Branch.Text)
'---------------------------------------------------------------------------
Dim baseNameString As String
baseNameString = aBranch.Text
Print #fileId, " "
Print #fileId, " "; baseNameString; ""
If Not aBranch.IsTitle() Then
If Len(aBranch.Bookmark) > 0 Then
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " ";aBranch.Bookmark;""
Print #fileId, " "
Print #fileId, " "
End If
End If
Print #fileId, " "
'---------------------------------------------------------------------------
' occurence Tag for Notes (Branch.Notes)
'---------------------------------------------------------------------------
If Len(aBranch.TextNotes.Text) > 0 Then
Dim resourceDataId As String
resourceDataId = "notes" + topicId
Print #fileId, " "
Print #fileId, " "
Print #fileId, aBranch.TextNotes.TextRTF
Print #fileId, " "
Print #fileId, " "
End If
'---------------------------------------------------------------------------
' occurence Tag for Hyperlink (Branch.Hyperlink)
'---------------------------------------------------------------------------
If Not aBranch.IsTitle() Then
If Len(aBranch.Hyperlink) > 0 Then
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
End If
End If
'---------------------------------------------------------------------------
Print #fileId, Space$(Indent); ""
nbBranch = nbBranch + 1
For i = 1 To aBranch.Count
Set nextBranch = aBranch.Item(i)
nextBranch.Select
Call ConvertBranchToTopic(nextBranch, fileId) '<-- Recursivity
Next i
End Function
Sub ConvertAssociations(ByVal aBranch As Branch, fileId As Integer)
Dim nextBranch As Branch
Dim associationId As String
Dim relations As Relationships
Dim relation As Relationship
Dim fromRef As String
Dim toRef As String
For i = 1 To aBranch.Count
Set nextBranch = aBranch.Item(i)
Set relations = nextBranch.Relationships
If (relations.Count > 0) Then
For j = 1 To relations.Count
Set relation = relations.Item(j)
If (relation.Branch1.ObjectID = nextBranch.ObjectID) Then
associationId = Str$(nextBranch.ObjectID) + "_" + LCase(nextBranch.Text)
associationId = Replace$(associationId, " ", "_") + Replace$(Str$(j), " ", "_")
fromRef = Str$(relation.Branch1.ObjectID) + "_" + LCase(relation.Branch1.Text)
fromRef = Replace$(fromRef, " ", "_")
toRef = Str$(relation.Branch2.ObjectID) + "_" + LCase(relation.Branch2.Text)
toRef = Replace$(toRef, " ", "_")
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
Print #fileId, " "
End If
Next j
End If
Call ConvertAssociations(nextBranch, fileId) '<-- Recursivity
Next i
End Sub