'-------------------------------------------------------------------------------- 'ReportGen.ebs ' ' Generates a data dictionary using Microsoft® Word OLE automation objects. ' ' Script Requires: ' Installed version of Microsoft® Word 7.0 ' ' Required Files: ' ReportGenLog.dot ' ReportGenComp.dot ' ' Created by Rational Software Corporation ' (C) Copyright Rational Software Corporation 1996 All Rights Reserved '-------------------------------------------------------------------------------- ' Modified by J.Pivitt to re-include changes to output in ' alphabetical order. (Based on reportgen.ebs for 4.0.) 19 Aug 97. ' Modified by David Hanslip to output classes in alphabetical order. 9 Mar 97. ' Modified by David Hanslip to use internal data structures for tracking ' selected classes rather than added properties thereby allowing document ' generation with write protected controlled units. 24 April 97. ' 12/02/99 Modified by Ahmed OUNAISSA (aounaiss@rational.com) ' ** Fix deleting word TABLE in "TABLE OF CONTENTS" ' ** Fix indentation pb. in Package structure. ' ** Fix the multiple selection problem. ' >> Flag : AO 12/02/99. ' End Modifs AO 12/02/99. ' ' 12/06/99 Modified by Greg Buhtz, GSB ' ** Merge with reportgen_2000.ebs ' ** Fix error exception handling ' ** Fix to ignore WordApp.FormatStyle error ' End Modifs GSB 12/06/99. ' ' 04/25/00 Modified by Ahmed OUNAISSA (aounaiss@rational.com) ' ** Add Type COM in Report Format. ' ** Parameter Modifiers for COM interfaces. ' >> Flag : AO 04/25/00. ' End Modifs AO 04/25/00. ' ' 02/03/2000 Modified by Oktay Amiry ' ** Modified SetGenerateFlags. Accessing theApplicableClassArray array directly to set GenerateFlag ' ** Added a routine GetAllOfClasses to return all classes, including netsted classes ' ** Fix to print documentation for nested classes. Modified SelectLogicalClassesForGeneration ' ** Fix to handle NestedClasses everywhere. Added a routine GetAllOfClasses to ' return all classes, including netsted classes and changed reference to Classes ' property to point instead to return value of GetAllOfClasses ' ** Fix to handle printing of selected classes where the selected classes are ' Nested classes. Change was made in PrintClassesForCategory routine. ' ' 21/06/2000 Modified by Guido Duerinckx, Alcatel Bell Space, guido.duerinckx@alcatel.be ' ** Added GenerateAssociation and GenerateClassAssociations in order to ' output information on associations between classes, if requested. ' ** Added output info on persistance classes. ' ** Fixed a problem in GetAllOfClasses (get only those classes belonging to aCategory). ' ** Fixed a problem in PrintClassesForCategory (avoid output nested classes twice). ' ** Slight modif & optim in PrintCategory. ' ** Modified ReportOptionsType (added new field IncludeNestedClasses) ' ** Modified SetGenerateFlags (recursively set flag for nested classes, if requested). ' ** Modified Dialog (added options for associations and nested classes). '-------------------------------------------------------------------------------- ' ---------------------------------------------------------------------- ' File: RoseWordUtil.ebs ' ' This file contains a set of Rose Script Utilities that enable diagrams ' and text to be formatted and inserted into Word documents. ' ' It uses the WordBasic interface into Word in an attempt to be ' compatible with versions of Word earlier than Word 8.0 (Office 97) ' ' PUBLIC UTILITIES ' ' Description: ' ' 1) WordUtilInit ' Initialises the word utilities. This must be called before any ' diagrams are inserted into the word document. ' ' 2) Para ' ' Inserts a paragraph spacing into the document ' ' 3) WordInsertScenarioDiagram ' ' Inserts a scenario diagram into the document ' ' 4) WordInsertClassDiagram ' ' Inserts a class or use case diagram into the document ' ' 5) WordInsertHeading1 ' ' Inserts a String as a Heading Level 1 ' ' 6) WordInsertDiagramTitle(aString As String, WordApp As Object) ' ' Inserts a String as a Heading Level 4 for use as diagram titles ' ' ' N.B. There is a known problem with this script. If you try to use it ' when You have previously extracted diagrams and have not closed down ' the associated Word Session, then it will not be able to delete the ' metafiles created in that Word Session. ' ' PRIVATE UTILITIES ' ' GetTempFileName ' ' ' Created 9/2/98 by IMS; last modified 9/2/98 IMS '------------------------------------------------------------------------ Const PRODUCTLONGNAME = 100 Const PRODUCTREV = 101 Const PRODUCTCOPYRIGHT = 102 Const PRODUCTDEFAULTWORDDOCFILENAME = 103 Const REPGEN_NOTLOC_NEW = 107 Const REPGEN_NOTLOC_WITHEVENTS = 108 Const REPGEN_NOTLOC_ISCONST = 109 ' Added the RoseVersion constant to ensure backwards compatability ' 4.0 - Rose 4.0 ' 4.1 - Includes functionality added after 4.0 #Const RoseVersion = 4.5 Type ClassAndFlag theClassID As String GenerateFlag As Boolean End Type Const DefaultTool$ = "ReportGen" Type ReportOptionsType Title As String ReportType As Integer ReportFormat As Integer IncludeOperations As Boolean IncludeAttributes As Boolean IncludeAssociations As Boolean GeneratePublicOnly As Boolean IncludeNestedClasses As Boolean 'added by Guido GenerateSelectedOnly As Boolean IncludeDocumentation As Boolean 'CurrentClass As Integer TotalClasses As Integer TotalCategories As Integer TotalSubsystems As Integer TotalModules As Integer ' XXX TotalUseCases As Integer IncludeClassDiagrams As Boolean IncludeUseCaseDiagrams As Boolean IncludeScenDiagrams As Boolean ' XXX End Type Type StatusBarInfo CurrentStep As Integer TotalSteps As Integer TotalSubSteps As Integer CurrentSubStep As Integer End Type private StatusBar As StatusBarInfo ' ReportType values Const RT_LogicalModel = 0 Const RT_PhysicalModel = 1 ' XXX Const RT_AnalysisModel = 2 ' XXX ' ReportFormatOption values Const RFO_Standard = 0 Const RFO_Basic = 1 Const RFO_CPlusPlus = 2 private ReportOptions As ReportOptionsType Const LogicalTemplateFileName$ = "ReportGenLog.dot" Const PhysicalTemplateFileName$ = "ReportGenComp.dot" ' Const UseCaseTemplateFileName$ = "ReportGenUseCase.dot" XXX Const UseCaseTemplateFileName$ = "ReportGenLog.dot" 'Const DefaultFileName$ = "Untitled.doc" private DefaultFileName as String Public theNumberOfApplicableClasses As Integer Public theApplicableClassArray() As ClassAndFlag Public RWU_DiagramCount As Integer '______________________________________________________________________________ Sub WordUtilInit() Let RWU_DiagramCount = 1 End Sub '______________________________________________________________________________ Sub Para(WordApp As Object) WordApp.InsertPara WordApp.InsertPara WordApp.InsertPara End Sub '______________________________________________________________________________ Function GetTmpFileName() Dim tmpFileName As String Dim tmpPathName As String 'On Error GoTo exitRoutine 'Get the Path to the Temp directory tmpPathName = Environ("TEMP") If tmpPathName = "" Then tmpPathName = CurDir End If 'Find a unique File Name Do tmpFileName = tmpPathName + "\rosed" & RWU_DiagramCount & ".wmf" 'Try to delete previously generated files. Will succeed if generated in another Word session 'This code was taken from elsewhere and I am not sure if it works. If Not Dir(tmpFileName)="" Then Kill(tmpFileName) End If Loop Until (Dir(tmpFileName)="") RWU_DiagramCount = RWU_DiagramCount + 1 GetTmpFileName = tmpFileName 'exitRoutine: ' Resume Next End Function '______________________________________________________________________________ Sub WordInsertScenarioDiagram(aDiagram As ScenarioDiagram, WordApp As Object) Dim tmpFileName As String Let tmpFileName = GetTmpFileName 'Let Rose render on file and insert file in Word aDiagram.RenderEnhanced tmpFileName WordApp.InsertPicture tmpFileName, false, false Para WordApp End Sub '______________________________________________________________________________ Sub WordInsertClassDiagram(aDiagram As ClassDiagram, WordApp As Object) Dim tmpFileName As String Let tmpFileName = GetTmpFileName 'Let Rose render on file and insert file in Word aDiagram.RenderEnhanced tmpFileName WordApp.InsertPicture tmpFileName, false, false Para WordApp End Sub '______________________________________________________________________________ Sub WordInsertHeading1(aString As String, WordApp As Object) WordApp.FormatStyle "Heading 1" WordApp.Insert aString WordApp.InsertPara WordApp.InsertPara WordApp.FormatStyle "Normal" End Sub '______________________________________________________________________________ Sub WordInsertDiagramTitle(aString As String, WordApp As Object) WordApp.FormatStyle "Heading 4" WordApp.Insert aString WordApp.InsertPara WordApp.InsertPara WordApp.FormatStyle "Normal" End Sub '______________________________________________________________________________ Function EnclosingDirPath(FileName As String) ' Extracts the enclosing directory path from a file name Dim Pos1, Pos2, Pos3 On Error GoTo EnclosingDirPath_excpetion Pos3 = 255 Pos2 = 1 Pos1 = 1 Do Pos3 = InStr(Pos2 + 1, FileName, "\") If Pos3 <> 0 Then Pos1 = Pos2 Pos2 = Pos3 Else Exit Do End If Loop EnclosingDirPath = Left(FileName, Pos2 - 1) Exit Function EnclosingDirPath_excpetion: Resume EnclosingDirPath_end EnclosingDirPath_end: 'Exit with the full path EnclosingDirPath = FileName End Function ' Oktay -- Get a listing of all classes, including nested classes ' Guido -- belonging to aCategory Function GetAllOfClasses(aCategory As Category) As ClassCollection Dim theCatClassCollection As New ClassCollection Dim theCatClass As Class, theCatInnerClass As Class Dim I As Integer, J As Integer For I = 1 To aCategory.Classes.Count Set theCatClass = aCategory.Classes.GetAt(I) theCatClassCollection.Add theCatClass For J = 1 To theCatClass.GetAllNestedClasses.Count Set theCatInnerClass = theCatClass.GetAllNestedClasses.GetAt(J) theCatClassCollection.Add theCatInnerClass Next J Next I Set GetAllOfClasses = theCatClassCollection End Function Public LicensedRoseApplication As Application Function GetLicensedRoseApplication() As Application Set GetLicensedRoseApplication = RoseApp.GetLicensedApplication("{A567222E-CBBE-11D0-BC0B-00A024C67143}") End Function Private resIFace As Object Public Function GetResourceString(resourceID As Long) As String If (resIFace Is Nothing) then Set resIFace = CreateObject("rvsreportgenres.rvsrepgeninterface") End If GetResourceString = resIFace.GetString(resourceID) End Function ' Version switches Function Version() As String Version = getResourceString(PRODUCTLONGNAME) & getResourceString(PRODUCTREV) & ". " & getResourceString(PRODUCTCOPYRIGHT) End Function Function propertyValue(theItem As RoseItem, propertyName As String) As Variant Dim value as string on error resume next value = theItem.GetProperty( propertyName) If Left(value, 1) = "(" And Right(value, 1) = ")" Then value = Mid(value, 2, Len(value) - 2) End If propertyValue = CVar(value) End Function Function GetProperty (theItem As RoseItem, theName As String) As String Dim Props As PropertyCollection Dim theProp As Property Set Props = theItem.GetProperties () PropID = Props.FindFirst (theName$) If PropID <> 0 Then Set theProp = Props.GetAt (PropID) GetProperty = theProp.Value End If End Function Public Sub hasPropertyStereotype(n As String, result As Boolean, OpKind As Integer, OpName As String) Dim lName1 As String Dim lName2 As String Const rvb_mt_Unknown = 0 Const rvb_mt_PropLet = 7 Const rvb_mt_PropSet = 8 Const rvb_mt_PropGet = 9 lName1 = Trim(n) lName2 = LCase(lName1) If Not ((lName2 Like "<> *") Or (lName2 Like "?et *")) Then result = False OpKind = rvb_mt_Unknown OpName = n Exit Sub ElseIf (Left(lName2, 1) = "<") Then result = True OpName = Mid(lName1, 9) '"<>" notation used If (lName2 Like "<> *") Then OpKind = rvb_mt_PropLet ElseIf (lName2 Like "<> *") Then OpKind = rvb_mt_PropGet ElseIf (lName2 Like "<> *") Then OpKind = rvb_mt_PropSet Else 'error result = False OpKind = rvb_mt_Unknown OpName = n End If Else '"get" notation used result = True OpName = Mid(lName1, 5) '"<>" notation used If (lName2 Like "let *") Then OpKind = rvb_mt_PropLet ElseIf (lName2 Like "get *") Then OpKind = rvb_mt_PropGet ElseIf (lName2 Like "set *") Then OpKind = rvb_mt_PropSet Else 'error result = False OpKind = rvb_mt_Unknown OpName = n End If End If End Sub '------------------------------------------------------------------------------------------------------- ' If the document being created is too big, then Word dies with an error saying ' "Formatting too complex, please do a full save." but saving doesn't help. Word97 ' dies earlier than Word version 7. An example of the problem was provided to the ' Word group at Microsoft and they acknowledge the bug and may fix it it the future. ' ' Thanks to the help of Evan Sullivan for VB5 QA group we have the following workaround: ' Word keeps some formatting information for the whole document attached to the last ' paragraph mark in the document, so at verious points in the report generation, we ' delete that final paragraph mark and insert a clean one. ' Sub ReplaceFinalParagraphKludge (WordApp As Object) WordApp.linedown WordApp.charright 1, 1 ' go right one character and select WordApp.insertpara ' overright the selected para marker with a new one WordApp.lineup End Sub '------------------------------------------------------------------------------------------------------- Sub OpenCancelDialog (MessageName As String, TotalSteps As Integer) ' jim 'Msg.Open MessageName, 0, TRUE, TRUE Msg.Open MessageName, 0, TRUE, TRUE, 0, 0 StatusBar.CurrentStep = 0 StatusBar.TotalSteps = TotalSteps StatusBar.TotalSubSteps = 0 StatusBar.CurrentSubStep = 0 End Sub Sub SetCancelDialogMessage (MessageName As String) 'Sleep 1 Msg.Text = MessageName End Sub Sub SubStepCancelDialog Dim MinorStep As Double Dim MinorRange As Double Dim ComputedValue As Integer ' This will yield and allow the cancel button to be pressed. Sleep 1 StatusBar.CurrentSubStep = StatusBar.CurrentSubStep + 1 If StatusBar.TotalSubSteps > 0 Then MinorRange = 100.0 / StatusBar.TotalSteps MinorStep = StatusBar.CurrentSubStep * MinorRange / StatusBar.TotalSubSteps ComputedValue = (StatusBar.CurrentStep-1) * 100.0 / StatusBar.TotalSteps + MinorStep If ComputedValue <= 100 Then Msg.Thermometer = ComputedValue Else Msg.Thermometer = 100 End If End If End Sub Sub StepCancelDialog (MessageName As String, TotalSubSteps As Integer) ' This will yield and allow the cancel button to be pressed. Sleep 1 Msg.Text = MessageName StatusBar.CurrentStep = StatusBar.CurrentStep + 1 If TotalSubSteps > 0 Then ' If there are substeps, count this as one sub step and increment StatusBar.TotalSubSteps = TotalSubSteps + 1 StatusBar.CurrentSubStep = 0 SubStepCancelDialog ElseIf StatusBar.TotalSteps > 0 Then If StatusBar.CurrentStep <= StatusBar.TotalSteps Then Msg.Thermometer = StatusBar.CurrentStep * 100.0 / StatusBar.TotalSteps Else Msg.Thermometer = 100 End If StatusBar.TotalSubSteps = 0 StatusBar.CurrentSubStep = 0 End If End Sub Sub FinishStepCancelDialog Msg.Thermometer = 100 End Sub Sub EndCancelDialog Msg.Close End Sub '------------------------------------------------------------------------------------------------------- Function GetWordStyleNameName (HeadingNumber As Integer) As String GetWordStyleNameName = "Heading " & CStr(HeadingNumber) End Function Function GenerateParameter (aParameter As Parameter) As String ' AO 04/25/00 Add COM in report format. strComAttr =aParameter.GetPropertyValue("COM","attributes") ' If this is N/A strComAttr will be empty. ' End ' AO 04/25/00. Select Case ReportOptions.ReportFormat Case RFO_Standard ' AO 04/25/00 Add COM in report format. ' Code$ = Code$ + aParameter.Name + " : " + aParameter.Type Code$ = Code$ + strComAttr + " " + aParameter.Name + " : " + aParameter.Type ' End ' AO 04/25/00. If Len (aParameter.InitValue) > 0 Then Code$ = Code$ + " = " + aParameter.InitValue End If Case RFO_Basic If Len (aParameter.InitValue) > 0 And InStr (1, aParameter.Name, "Optional", 1) = 0 Then ' Don't put in Optional if it is already there Code$ = Code$ & "Optional " & aParameter.Name & " As " & aParameter.Type & " = " + aParameter.InitValue Else Code$ = Code$ & aParameter.Name & " As " & aParameter.Type End If Case RFO_CPlusPlus ' AO 04/25/00 Add COM in report format. ' Code$ = Code$ + aParameter.Name + " : " + aParameter.Type Code$ = Code$ + strComAttr + " " + aParameter.Name + " : " + aParameter.Type ' End ' AO 04/25/00. If Len (aParameter.InitValue) > 0 Then Code$ = Code$ + " = " + aParameter.InitValue End If Case RFO_COM Code$ = Code$ + aParameter.GetPropertyValue("COM","Attributes") ' End ' AO 04/25/00. End Select 'If aParameter.Const = TRUE Then 'Print "const "; 'End If GenerateParameter = Code$ End Function Sub GenerateOperation (WordApp As Object, anOperation As Operation, theHeading As String) SubStepCancelDialog dim theDeclaration as String dim lineFeed as boolean lineFeed = TRUE 'If anOperation.Virtual Then ' WordApp.Insert "virtual " 'End If Params$ = "" For OperID = 1 To anOperation.Parameters.Count - 1 Params$ = Params$ + GenerateParameter (anOperation.Parameters.GetAt (OperID)) Params$ = Params$ + ", " Next OperID If anOperation.Parameters.Count > 0 Then Params$ = Params$ + GenerateParameter (anOperation.Parameters.GetAt (anOperation.Parameters.Count)) End If Select Case ReportOptions.ReportFormat Case RFO_Standard ' OpName (Param1 : type) : Return WordApp.FormatStyle theHeading$ WordApp.Insert anOperation.Name & " (" & Params$ & ") : " & anOperation.ReturnType Case RFO_Basic Dim oldTool As String Dim opName_withoutStereotype As String Dim propertyStereotypeFlag As Boolean Dim OpKind As Integer Const rvb_mt_PropLet = 7 Const rvb_mt_PropSet = 8 Const rvb_mt_PropGet = 9 Const vbpCommon = "205" Const vbpProperty = "207" Const vbpDll = "208" Const vbpEvent = "218" Const vbpPropertyGet = "206" Const vbpPropertySet = "209" Const vbpPropertyLet = "210" Const vbpOperationKind = "OperationKind" Const vbpPropertyKind = "PropertyKind" Const vbpLibraryName = "LibraryName" Const vbpAliasName = "AliasName" oldTool = LicensedRoseApplication.CurrentModel.DefaultTool LicensedRoseApplication.CurrentModel.DefaultTool = "Visual Basic" Select Case anOperation.ExportControl Case rsPublicAccess theDeclaration = "Public " Case Else theDeclaration = "Private " End Select '============================================================================== ' CODE PATCH ' author: jim conallen, jim@conallen.com ' ' I am presuming that the following call is made to determine if the operation ' is a property get/set/let, and that is has three output parameters; ' propertyStereotypeFlag - a boolean indicating that this is a property op ' OpKind - the specific type of property (get/set or let) ' opName_withoutStereotype - the parsed name ' ' in the newer REI, property gets and sets are indicated by stereotypes ' not only via property sets. So we can mimic this call via the stereotypes Dim theStereotype As String theStereotype = anOperation.stereotype Select Case lcase(theStereotype) Case "let" OpKind = rvb_mt_PropLet Case "set" OpKind = rvb_mt_PropSet Case "get" OpKind = rvb_mt_PropGet Case "event" Exit Sub Case "declare" OpKind = vbpDll Case Else OpKind = vbpCommon End Select opName_withoutStereotype = anOperation.Name Select Case OpKind Case rvb_mt_PropGet theDeclaration = theDeclaration & "Property Get " & opName_withoutStereotype & " (" & Params$ & ") As " If (anOperation.ReturnType = "" ) Then theDeclaration = theDeclaration & "" Else theDeclaration = theDeclaration & anOperation.ReturnType End If Case rvb_mt_PropLet theDeclaration = theDeclaration & "Property Let " & opName_withoutStereotype & " (" & Params$ & ")" Case rvb_mt_PropSet theDeclaration = theDeclaration & "Property Set " & opName_withoutStereotype & " (" & Params$ & ")" Case vbpCommon If (anOperation.ReturnType = "") Then theDeclaration = theDeclaration & "Sub " & anOperation.Name & " (" & Params$ & ")" Else theDeclaration = theDeclaration & "Function " & anOperation.Name & " (" & Params$ & ") As " & anOperation.ReturnType End If Case vbpDll theDeclaration = "Declare Function " & anOperation.Name & " Lib """ & propertyValue(anOperation.GetRoseItem, vbpLibraryName) & """ Alias """ & propertyValue(anOperation.GetRoseItem, vbpAliasName) & """ (" & Params$ & ")" End Select LicensedRoseApplication.CurrentModel.DefaultTool = oldTool if (lineFeed = true) then WordApp.FormatStyle theHeading$ WordApp.Insert theDeclaration end if Case RFO_CPlusPlus ReturnType$ = anOperation.ReturnType If ReturnType$ = "" Then ReturnType$ = "void" WordApp.FormatStyle theHeading$ WordApp.Insert ReturnType$ & " " & anOperation.Name & " (" & Params$ & ")" End Select If (lineFeed = true) Then WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then Doc$ = Trim (anOperation.Documentation) If Len (Doc$) > 0 Then WordApp.FormatStyle "Operation Documentation" 'WordApp.Italic 1 ' Make the text italic WordApp.Insert Doc$ 'WordApp.Italic 0 ' Make the text non-italic WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle theHeading$ End If If anOperation.Parameters.Count > 0 Then WordApp.FormatStyle "Operation Documentation" For i = 1 To anOperation.Parameters.Count WordApp.Italic 1 WordApp.Insert anOperation.Parameters.GetAt(i).Name WordApp.InsertPara WordApp.Italic 0 WordApp.Insert anOperation.Parameters.GetAt(i).Documentation WordApp.InsertPara Next i WordApp.FormatStyle theHeading$ End If End If 'IncludeDocumentation End If End Sub Function GenerateVBEvent (WordApp As Object, anOperation As Operation, theHeading As String) As Boolean Dim opName_withoutStereotype As String Dim propertyStereotypeFlag As Boolean Dim OpKind As Integer Const vbpEvent = "218" If (LCase(anOperation.Stereotype) = "event") Then Dim theDeclaration as String Params$ = "" For OperID = 1 To anOperation.Parameters.Count - 1 Params$ = Params$ + GenerateParameter (anOperation.Parameters.GetAt (OperID)) Params$ = Params$ + ", " Next OperID If anOperation.Parameters.Count > 0 Then Params$ = Params$ + GenerateParameter (anOperation.Parameters.GetAt (anOperation.Parameters.Count)) End If WordApp.FormatStyle theHeading$ theDeclaration = "Public Event " & anOperation.Name & " (" & Params$ & ")" WordApp.Insert theDeclaration WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then Doc$ = Trim (anOperation.Documentation) If Len (Doc$) > 0 Then 'WordApp.FormatStyle "Normal" WordApp.FormatStyle "Operation Documentation" WordApp.Insert Doc$ WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle theHeading$ End If End If GenerateVBEvent = TRUE Else GenerateVBEvent = FALSE End If End Function Sub GenerateAttribute (WordApp As Object, anAttribute As Attribute, theHeading As String) SubStepCancelDialog dim lineFeed as boolean lineFeed = true Select Case ReportOptions.ReportFormat Case RFO_Standard theAttribute$ = anAttribute.Name & " : " & anAttribute.Type If Len (anAttribute.InitValue) > 0 Then theAttribute$ = theAttribute$ & " = " & anAttribute.InitValue End If Case RFO_Basic Dim oldTool As String dim anAttributeType as String oldTool = LicensedRoseApplication.CurrentModel.DefaultTool LicensedRoseApplication.CurrentModel.DefaultTool = "Visual Basic" Select Case anAttribute.ExportControl Case rsPublicAccess theAttribute$ = theAttribute$ & "Public " Case Else theAttribute$ = theAttribute$ & "Private " End Select If (Trim(anAttribute.Type) = "") Then anAttributeType = "" Else anAttributeType = anAttribute.Type End If If CBool(LCase(anAttribute.GetRoseItem.Stereotype) = "const") Then lineFeed = false ElseIf CBool(propertyValue(anAttribute.GetRoseItem, getResourceString(REPGEN_NOTLOC_NEW))) Then theAttribute$ = theAttribute$ & anAttribute.Name & " As New " & anAttributeType ElseIf CBool(propertyValue(anAttribute.GetRoseItem, getResourceString(REPGEN_NOTLOC_WITHEVENTS))) Then theAttribute$ = theAttribute$ & "WithEvents " & anAttribute.Name & " As " & anAttributeType Else theAttribute$ = theAttribute$ & anAttribute.Name & " As " & anAttributeType If Len (anAttribute.InitValue) > 0 Then theAttribute$ = theAttribute$ & " ' = " & anAttribute.InitValue End If End If LicensedRoseApplication.CurrentModel.DefaultTool = oldTool Case RFO_CPlusPlus theAttribute$ = anAttribute.Type & " " & anAttribute.Name If Len (anAttribute.InitValue) > 0 Then theAttribute$ = theAttribute$ & " = " & anAttribute.InitValue End If End Select if (lineFeed = true) then WordApp.FormatStyle theHeading$ WordApp.Insert theAttribute$ WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then Doc$ = Trim (anAttribute.Documentation) If Len (Doc$) > 0 Then WordApp.FormatStyle "Attribute Documentation" 'WordApp.Italic 1 ' Make the text italic WordApp.Insert Doc$ 'WordApp.Italic 0 ' Make the text non-italic WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle theHeading$ End If End If end if End Sub Function GenerateVBConstant (WordApp As Object, anAttribute As Attribute, theHeading As String) As Boolean dim theDeclaration as String Dim oldTool As String oldTool = LicensedRoseApplication.CurrentModel.DefaultTool LicensedRoseApplication.CurrentModel.DefaultTool = "Visual Basic" Select Case anAttribute.ExportControl Case rsPublicAccess theDeclaration = theDeclaration & "Public " Case Else theDeclaration = theDeclaration & "Private " End Select If (LCase(anAttribute.GetRoseItem.Stereotype) = "const") Then theDeclaration = theDeclaration & "Const " & anAttribute.Name & " As " & anAttribute.Type & " = " If Len (anAttribute.InitValue) > 0 Then theDeclaration = theDeclaration & anAttribute.InitValue Else theDeclaration = theDeclaration & "" End If WordApp.FormatStyle theHeading$ WordApp.Insert theDeclaration WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then Doc$ = Trim (anAttribute.Documentation) If Len (Doc$) > 0 Then WordApp.FormatStyle "Attribute Documentation" 'WordApp.Italic 1 ' Make the text italic WordApp.Insert Doc$ 'WordApp.Italic 0 ' Make the text non-italic WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle theHeading$ End If End If GenerateVBConstant = TRUE Else GenerateVBConstant = FALSE End If LicensedRoseApplication.CurrentModel.DefaultTool = oldTool End Function 'added by Guido Sub GenerateAssociation (WordApp As Object, aClass As Class, anAssociation As Association, theHeading As String) Dim theRole As Role Dim otherRole As Role Dim includeAssociation As Boolean includeAssociation = TRUE set theRole = anAssociation.GetCorrespondingRole(aClass) set otherRole = anAssociation.GetOtherRole(aClass) If Not otherRole.Name = "" Then targetRoleInfo$ = otherRole.Name & " [" & otherRole.Cardinality & "] : " Else targetRoleInfo$ = "(Unnamed Target Role) [" & otherRole.Cardinality & "] : " End If If Not anAssociation.Name = "" Then anAssociationName$ = anAssociation.Name Else anAssociationName$ = "Unnamed Association" End If If Not theRole.Name = "" Then roleInfo$ = " (" & theRole.Name & " Role) to " Else roleInfo$ = " (Unnamed Supplier Role) to " End If targetClassName$ = otherRole.GetClassName() If targetClassName$ = "" Then targetClassName$ = "Unnamed Class" End If SubStepCancelDialog WordApp.FormatStyle theHeading$ Select Case ReportOptions.ReportFormat Case RFO_Standard theAssociation$ = targetRoleInfo & anAssociationName$ _ & roleInfo$ & targetClassName$ Case RFO_Basic theAssociation$ = targetRoleInfo & anAssociationName$ _ & roleInfo$ & targetClassName$ Case RFO_CPlusPlus If NOT otherRole.Navigable Then includeAssociation = FALSE 'WordApp.Insert "// Doc. // " End If theAssociation$ = targetRoleInfo & anAssociationName$ _ & roleInfo$ & targetClassName$ End Select If includeAssociation THEN WordApp.Insert theAssociation$ WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then Doc$ = Trim (anAssociation.Documentation) If Len (Doc$) > 0 Then WordApp.FormatStyle "Attribute Documentation" 'WordApp.Italic 1 ' Make the text italic WordApp.Insert Doc$ 'WordApp.Italic 0 ' Make the text non-italic WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle theHeading$ End If End If End If End Sub Sub GenerateClassOperations (WordApp As Object, aClass As Class, HeadingNumber As Integer) Dim PublicOperations As New OperationCollection Dim ProtectedOperations As New OperationCollection Dim PrivateOperations As New OperationCollection Dim Operation As Operation Dim HasAnEvent As Boolean ' Sort the operations into three lists: public, protected, and private For OperID = 1 To aClass.Operations.Count Set Operation = aClass.Operations.GetAt (OperID) Select Case Operation.ExportControl Case rsPublicAccess PublicOperations.Add Operation Case rsProtectedAccess ProtectedOperations.Add Operation Case Else PrivateOperations.Add Operation End Select Next OperID ' Generate the public operations If PublicOperations.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Public Operations:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp For OperID = 1 To PublicOperations.Count GenerateOperation WordApp, PublicOperations.GetAt (OperID), GetWordStyleNameName (HeadingNumber + 1) Next OperID WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If If (ReportOptions.ReportFormat = RFO_Basic And (PublicOperations.Count + ProtectedOperations.Count + PrivateOperations.Count > 0)) Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Events:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp HasAnEvent = FALSE For OperID = 1 To PublicOperations.Count If GenerateVBEvent (WordApp, PublicOperations.GetAt (OperID), GetWordStyleNameName (HeadingNumber + 1)) Then HasAnEvent = TRUE End If Next OperID For OperID = 1 To ProtectedOperations.Count If GenerateVBEvent (WordApp, ProtectedOperations.GetAt (OperID), GetWordStyleNameName (HeadingNumber + 1)) Then HasAnEvent = TRUE End If Next OperID For OperID = 1 To PrivateOperations.Count If GenerateVBEvent (WordApp, PrivateOperations.GetAt (OperID), GetWordStyleNameName (HeadingNumber + 1)) Then HasAnEvent = TRUE End If Next OperID If Not HasAnEvent Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) WordApp.Insert "No events." End If WordApp.InsertPara WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If If Not ReportOptions.GeneratePublicOnly Then ' Generate the protected operations If ProtectedOperations.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Protected Operations:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp For OperID = 1 To ProtectedOperations.Count GenerateOperation WordApp, ProtectedOperations.GetAt (OperID), GetWordStyleNameName (HeadingNumber + 1) Next OperID WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If ' Generate the private operations If PrivateOperations.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Private Operations:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp For OperID = 1 To PrivateOperations.Count GenerateOperation WordApp, PrivateOperations.GetAt (OperID), GetWordStyleNameName (HeadingNumber + 1) Next OperID WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If End Sub Sub GenerateClassAttributes (WordApp As Object, aClass As Class, HeadingNumber As Integer) Dim PublicAttributes As New AttributeCollection Dim ProtectedAttributes As New AttributeCollection Dim PrivateAttributes As New AttributeCollection Dim Attribute As Attribute Dim HasAConstant As Boolean ' Sort the attributes into three lists: public, protected, and private For AttribID = 1 To aClass.Attributes.Count Set Attribute = aClass.Attributes.GetAt (AttribID) Select Case Attribute.ExportControl Case rsPublicAccess PublicAttributes.Add Attribute Case rsProtectedAccess ProtectedAttributes.Add Attribute Case Else PrivateAttributes.Add Attribute End Select Next AttribID ' Generate the public attributes If PublicAttributes.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Public Attributes:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) For AttribID = 1 To PublicAttributes.Count GenerateAttribute WordApp, PublicAttributes.GetAt (AttribID), GetWordStyleNameName (HeadingNumber + 1) Next AttribID WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If If (ReportOptions.ReportFormat = RFO_Basic And PublicAttributes.Count > 0) Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Public Constants:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) HasAConstant = FALSE For AttribID = 1 To PublicAttributes.Count If GenerateVBConstant (WordApp, PublicAttributes.GetAt (AttribID), GetWordStyleNameName (HeadingNumber + 1)) Then HasAConstant = TRUE End If Next AttribID If Not HasAConstant Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) WordApp.Insert "No Public Constants." End If WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If If Not ReportOptions.GeneratePublicOnly Then ' Generate the protected attributes If ProtectedAttributes.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Protected Attributes:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) For AttribID = 1 To ProtectedAttributes.Count GenerateAttribute WordApp, ProtectedAttributes.GetAt (AttribID), GetWordStyleNameName (HeadingNumber + 1) Next AttribID WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If ' Generate the private attributes If PrivateAttributes.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Private Attributes:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) For AttribID = 1 To PrivateAttributes.Count GenerateAttribute WordApp, PrivateAttributes.GetAt (AttribID), GetWordStyleNameName (HeadingNumber + 1) Next AttribID WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If If (ReportOptions.ReportFormat = RFO_Basic And (PrivateAttributes.Count + ProtectedAttributes.Count > 0)) then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Private Constants:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) HasAConstant = FALSE For AttribID = 1 To ProtectedAttributes.Count If GenerateVBConstant (WordApp, ProtectedAttributes.GetAt (AttribID), GetWordStyleNameName (HeadingNumber + 1)) Then HasAConstant = TRUE End If Next AttribID For AttribID = 1 To PrivateAttributes.Count If GenerateVBConstant (WordApp, PrivateAttributes.GetAt (AttribID), GetWordStyleNameName (HeadingNumber + 1)) Then HasAConstant = TRUE End If Next AttribID If Not HasAConstant Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) WordApp.Insert "No Private Constants." End If WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If End Sub 'added by Guido Sub GenerateClassAssociations (WordApp As Object, aClass As Class, HeadingNumber As Integer) Dim Associations As AssociationCollection Dim theAssociation As Association Dim otherRole As Role Dim navigableAssociations As Integer Dim generateReportOnAssociations As Boolean generateReportOnAssociations = FALSE Set Associations = aClass.GetAssociations () 'count navigable associations, 'i.e. those for which a data member must be generated in the class navigableAssociations = 0 If Associations.Count > 0 Then For AssocID = 1 To Associations.Count set theAssociation = Associations.GetAt (AssocID) set otherRole = theAssociation.GetOtherRole(aClass) If otherRole.Navigable Then navigableAssociations = navigableAssociations + 1 End If Next AssocID End If Select Case ReportOptions.ReportFormat Case RFO_Standard generateReportOnAssociations = TRUE Case RFO_Basic generateReportOnAssociations = TRUE Case RFO_CPlusPlus If navigableAssociations > 0 Then generateReportOnAssociations = TRUE End If End Select 'WordApp.InsertPara 'ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeAssociations AND generateReportOnAssociations Then ' Generate the associations If Associations.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert "Associations:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) For AssocID = 1 To Associations.Count GenerateAssociation WordApp, aClass, Associations.GetAt (AssocID), GetWordStyleNameName (HeadingNumber + 1) Next AssocID WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If End Sub Sub GenerateLogicalClass (WordApp As Object, aClass As Class, HeadingNumber As Integer) 'GSB Fix to ignore WordApp.FormatStyle error On Error Resume Next WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) If Not aClass.Name = "" Then WordApp.Insert aClass.Name Else WordApp.Insert "Unnamed Class" End If WordApp.InsertPara ReplaceFinalParagraphKludge WordApp GenerateTheClassBody WordApp, aClass, HeadingNumber End Sub Sub GeneratePhysicalClass (WordApp As Object, aClass As Class, HeadingNumber As Integer) WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert aClass.Name & " (" & aClass.ParentCategory.Name & ")" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp GenerateTheClassBody WordApp, aClass, HeadingNumber End Sub Sub GenerateTheClassBody (WordApp As Object, aClass As Class, HeadingNumber As Integer) Dim SubSteps As Integer 'ReportOptions.CurrentClass = ReportOptions.CurrentClass + 1 SubSteps = 0 If ReportOptions.IncludeAttributes Then SubSteps = SubSteps + aClass.Attributes.Count End If 'added by Guido If ReportOptions.IncludeAssociations Then Dim Associations As AssociationCollection Set Associations = aClass.GetAssociations () SubSteps = SubSteps + Associations.Count End If If ReportOptions.IncludeOperations Then SubSteps = SubSteps + aClass.Operations.Count End If StepCancelDialog "Generating Class " & aClass.Name, SubSteps If ReportOptions.IncludeDocumentation Then If aClass.Documentation <> "" Then WordApp.FormatStyle "Class Documentation" WordApp.Insert Trim (aClass.Documentation) WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If 'added by Guido If aClass.Persistence Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) WordApp.Insert "Persistent Class" 'WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If Dim Superclasses As ClassCollection Dim theSuperclass As Class Set Superclasses = aClass.GetSuperclasses () If Superclasses.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) ClassList$ = "" For ClsID = 1 To Superclasses.Count Set theSuperclass = Superclasses.GetAt (ClsID) If ClassList$ <> "" Then ClassList$ = ClassList$ & ", " ClassList$ = ClassList$ & theSuperclass.Name Next ClsID WordApp.Insert "Derived from " & ClassList$ WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If If ReportOptions.IncludeAttributes Then SetCancelDialogMessage "Generating Class " & aClass.Name & " Attributes" GenerateClassAttributes WordApp, aClass, HeadingNumber + 1 End If 'added by Guido If ReportOptions.IncludeAssociations Then SetCancelDialogMessage "Generating Class " & aClass.Name & " Associations" GenerateClassAssociations WordApp, aClass, HeadingNumber + 1 End If If ReportOptions.IncludeOperations Then SetCancelDialogMessage "Generating Class " & aClass.Name & " Operations" GenerateClassOperations WordApp, aClass, HeadingNumber + 1 End If End Sub ' XXX Sub SearchForUseCaseDiagramsInPackage(WordApp As Object, aCategory As Category, HeadingNumber As Integer) Dim classDiagrams As ClassDiagramCollection Dim aClassDiagram As ClassDiagram Set classDiagrams = aCategory.ClassDiagrams For clsID = 1 To classDiagrams.Count Set aClassDiagram=classDiagrams.GetAt(clsID) If aClassDiagram.IsUseCaseDiagram Then InsertClassDiagram WordApp, aClassDiagram, HeadingNumber End If Next clsID End Sub Sub SearchForSeqAndCollabViewsInPackage(WordApp As Object, aCategory As Category, HeadingNumber As Integer) Dim aScenarioDiagram As ScenarioDiagram Dim ScenarioDiagrams As ScenarioDiagramCollection Set ScenarioDiagrams = aCategory.ScenarioDiagrams For scenID = 1 To ScenarioDiagrams.Count Set aScenarioDiagram = ScenarioDiagrams.GetAt(scenID) InsertSequenceOrCollaborationView WordApp, aScenarioDiagram, HeadingNumber Next scenID End Sub Sub InsertSequenceOrCollaborationView(WordApp As Object, aScenarioDiagram As ScenarioDiagram, HeadingNumber As Integer) WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) WordApp.Insert "Interaction Diagram - " & aScenarioDiagram.name WordApp.InsertPara WordApp.FormatStyle "Normal" WordApp.InsertPara WordInsertScenarioDiagram aScenarioDiagram, WordApp End Sub Sub SearchForClassDiagramsInPackage(WordApp As Object, aCategory As Category, HeadingNumber As Integer) Dim classDiagrams As ClassDiagramCollection Dim aClassDiagram As ClassDiagram Set classDiagrams = aCategory.ClassDiagrams For clsID = 1 To classDiagrams.Count Set aClassDiagram=classDiagrams.GetAt(clsID) If Not (aClassDiagram.IsUseCaseDiagram) Then InsertClassDiagram WordApp, aClassDiagram, HeadingNumber End If Next clsID End Sub Sub InsertClassDiagram(WordApp As Object, aClassDiagram As ClassDiagram, HeadingNumber As Integer) WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) If aClassDiagram.IsUseCaseDiagram Then WordApp.Insert " Use Case Diagram - " WordApp.Insert aClassDiagram.name Else WordApp.Insert "Class Diagram - " WordApp.Insert aClassDiagram.name End If WordApp.InsertPara WordApp.FormatStyle "Normal" WordApp.InsertPara WordInsertClassDiagram aClassDiagram, WordApp End Sub Function UseCaseApplies (theUseCase As UseCase) As Boolean If ReportOptions.GenerateSelectedOnly Then theUseCaseID = theUseCase.GetUniqueID() Dim UseCaseFound As Boolean i% = 1 On Error GoTo SkipUseCase While Not UseCaseFound If theUseCaseID = theApplicableUseCaseArray(i%).theUseCaseID Then UseCaseFound = True Else i% = i% + 1 End If Wend If theApplicableUseCaseArray(i%).GenerateFlag = TRUE Then UseCaseApplies = TRUE Else UseCaseApplies = FALSE End If Else UseCaseApplies = TRUE End If exit function SkipUseCase: Err = -1 ClassApplies = FALSE End Function ' XXX Function ClassApplies (theClass As Class) As Boolean Dim i As Integer If ReportOptions.GenerateSelectedOnly Then theClassID = theClass.GetUniqueID() Dim ClassFound As Boolean If ArrayDims (theApplicableClassArray) Then For i = LBound (theApplicableClassArray) To UBound (theApplicableClassArray) If theClassID = theApplicableClassArray(i).theClassID Then ClassApplies = theApplicableClassArray(i).GenerateFlag Exit Function End If Next i End If Else ClassApplies = TRUE End If End Function Function CategoryApplies (aCategory As Category) As Boolean 'Oktay - New - Fix problem where if user selects a Nested Class we are not ' printing it. Instead of using aCategory.Classes we should search all ' classes. Dim theCatClassCollection As ClassCollection Set theCatClassCollection = GetAllOfClasses(aCategory) ' End Oktay If ReportOptions.GenerateSelectedOnly Then Dim theClass As Class 'Oktay 'For ClsID = 1 To aCategory.Classes.Count For ClsID = 1 To theCatClassCollection.Count 'Set theClass = aCategory.Classes.GetAt (ClsID) Set theClass = theCatClassCollection.GetAt (ClsID) 'End Oktay If ClassApplies (theClass) Then CategoryApplies = TRUE Exit Function End If Next ClsID CategoryApplies = FALSE Else CategoryApplies = TRUE End If Set theCatClassCollection = Nothing End Function Function ModuleApplies (aModule As Module) As Boolean If ReportOptions.GenerateSelectedOnly Then Dim AssignedClasses As ClassCollection Dim theClass As Class Set AssignedClasses = aModule.GetAssignedClasses () For ClsID = 1 To AssignedClasses.Count Set theClass = AssignedClasses.GetAt (ClsID) If ClassApplies (theClass) Then ModuleApplies = TRUE Exit Function End If Next ClsID ModuleApplies = FALSE Else ModuleApplies = TRUE End If End Function Function SubsystemApplies (aSubsystem As Subsystem) As Boolean If ReportOptions.GenerateSelectedOnly Then Dim theModule As Module For ModID = 1 To aSubsystem.Modules.Count Set theModule = aSubsystem.Modules.GetAt (ModID) If ModuleApplies (theModule) Then SubsystemApplies = TRUE Exit Function End If Next ModID SubsystemApplies = FALSE Else SubsystemApplies = TRUE End If End Function ' BSR added for defect 146056 Sub PrintNestedClasses (WordApp As Object, theClass As class,HeadingNumber As Integer) Dim NestedClasses As ClassCollection Set NestedClasses = theClass.GetAllNestedClasses If NestedClasses.Count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 2) WordApp.Insert "Nested Classes" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp For NstdClsID = 1 To NestedClasses.Count If ClassApplies (NestedClasses.getat(NstdClsID)) Then GenerateLogicalClass WordApp, NestedClasses.getat(NstdClsID), HeadingNumber + 1 nestedClassesPrinted = true End If ReplaceFinalParagraphKludge WordApp Next NstdClsID If (nestedClassesPrinted = true) Then WordApp.InsertPara ReplaceFinalParagraphKludge WordApp nestedClassesPrinted = false End If End If End Sub ' BSR added for defect 146056 Sub sortalpha( aCategory As Category, myAlpha() As String) ' Oktay -- Instead of checking aCategory.classes check all classes, including ' nested classes Dim theCatClassCollection As ClassCollection Set theCatClassCollection = GetAllOfClasses(aCategory) 'For ike = 1 To aCategory.classes.count For ike = 1 To theCatClassCollection.count myAlpha(ike) = theCatClassCollection.GetAt(ike).Name Next ike arraysort myAlpha Set theCatClassCollection = Nothing End Sub ' BSR added for defect 146056 Sub PrintClassesForCategory (WordApp As Object, aCategory As Category,HeadingNumber As Integer, myAlpha() As String) Dim lastNoNameClassIndex As Integer 'Oktay - New - Fix problem where if user selects a Nested Class we are not ' printing it. Instead of using aCategory.Classes we should search all ' classes. Dim theCatClassCollection As ClassCollection Set theCatClassCollection = GetAllOfClasses(aCategory) ' End Oktay 'If aCategory.Classes.Count > 0 Then If (theCatClassCollection.Count > 0) Then Dim theClass As Class Dim NestedClasses As ClassCollection WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) ' Oktay -- Reference theCatClassCollection 'For ClsID = 1 To aCategory.Classes.Count For ClsID = 1 To theCatClassCollection.Count If (myAlpha(ClsID) = "") Then 'class with no name If (lastNoNameClassIndex = 0) Then ' Oktay -- Reference theCatClassCollection 'ike = aCategory.classes.findfirst("") ike = theCatClassCollection.FindFirst("") ' End Oktay lastNoNameClassIndex = ike Else ' Oktay -- Reference theCatClassCollection 'ike = aCategory.classes.findnext(lastNoNameClassIndex,"") ike = theCatClassCollection.FindNext(lastNoNameClassIndex,"") ' End Oktay lastNoNameClassIndex = ike End If Else ' Oktay -- Reference theCatClassCollection 'ike = aCategory.classes.FindFirst(myAlpha(ClsID)) ' End Oktay ike = theCatClassCollection.FindFirst(myAlpha(ClsID)) End If ' Oktay -- Reference theCatClassCollection 'Set theClass = aCategory.Classes.GetAt(ike) ' End Oktay Set theClass = theCatClassCollection.GetAt(ike) If ClassApplies (theClass) Then GenerateLogicalClass WordApp, theClass, HeadingNumber + 1 ' commented out by Guido, nested classes already printed out by Oktay's modif 'PrintNestedClasses WordApp, theClass, HeadingNumber End If Next ClsID WordApp.InsertPara ReplaceFinalParagraphKludge WordApp Else WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If Set theCatClassCollection = Nothing End Sub ' XXX Sub InsertUseCaseDocumentation (WordApp As Object, aUseCase As UseCase, HeadingNumber As Integer) If aUseCase.Documentation <> "" Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) WordApp.Insert "Documentation:" WordApp.InsertPara WordApp.FormatStyle "Normal" WordApp.Insert Trim (aUseCase.Documentation) WordApp.InsertPara WordApp.InsertPara End If End Sub Sub SearchForRelationshipsForUseCase(WordApp As Object, aUseCase As UseCase, HeadingNumber As Integer) Dim anAssociation As Association Dim associations As AssociationCollection Dim role1 As role Dim role2 As role Set associations = aUseCase.GetAssociations If associations.count > 0 Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) WordApp.Insert "List of Associations " WordApp.InsertPara WordApp.FormatStyle "Normal" For assID = 1 To associations.Count Set anAssociation = associations.GetAt(assID) Set role1 = anAssociation.role1 Set role2 = anAssociation.role2 WordApp.Insert role2.GetClassName If anAssociation.stereotype = "Extends" Then WordApp.Insert " Extends " Else If anAssociation.stereotype = "Uses" Then WordApp.Insert " Uses " Else WordApp.Insert " Communicates with " End If End If WordApp.Insert role1.GetClassName WordApp.InsertPara Next assID WordApp.InsertPara End If End Sub Sub SearchForSeqAndCollabViewsInUseCase(WordApp As Object, aUseCase As UseCase, HeadingNumber As Integer) Dim aScenarioDiagram As ScenarioDiagram Dim ScenarioDiagrams As ScenarioDiagramCollection Set ScenarioDiagrams = aUseCase.ScenarioDiagrams For scenID = 1 To ScenarioDiagrams.Count Set aScenarioDiagram = ScenarioDiagrams.GetAt(scenID) InsertSequenceOrCollaborationView WordApp, aScenarioDiagram, HeadingNumber Next scenID End Sub Sub SearchForUseCaseDiagramsInUseCase(WordApp As Object, aUseCase As UseCase, HeadingNumber As Integer) 'Use Case Diagrams are a type of Class diagram in Rose Dim classDiagrams As ClassDiagramCollection Dim aClassDiagram As ClassDiagram Set classDiagrams = aUseCase.ClassDiagrams For clsID = 1 To classDiagrams.Count Set aClassDiagram=classDiagrams.GetAt(clsID) If aClassDiagram.IsUseCaseDiagram Then InsertClassDiagram WordApp, aClassDiagram, HeadingNumber End If Next clsID End Sub Sub SearchForClassDiagramsInUseCase(WordApp As Object, aUseCase As UseCase, HeadingNumber As Integer) Dim classDiagrams As ClassDiagramCollection Dim aClassDiagram As ClassDiagram Set classDiagrams = aUseCase.ClassDiagrams For clsID = 1 To classDiagrams.Count Set aClassDiagram=classDiagrams.GetAt(clsID) If Not (aClassDiagram.IsUseCaseDiagram) Then InsertClassDiagram WordApp, aClassDiagram, HeadingNumber End If Next clsID End Sub Sub GenerateUseCase (WordApp As Object, aUseCase As UseCase, HeadingNumber As Integer) Dim fontUsed As String Dim SubSteps As Integer SubSteps = 0 StepCancelDialog "Generating Use Case" & aUseCase.Name, SubSteps WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) If Not aUseCase.Name = "" Then WordApp.Insert "Use Case - " WordApp.Insert aUseCase.Name Else WordApp.Insert "Unnamed " End If WordApp.InsertPara WordApp.FormatStyle "Normal" ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then InsertUseCaseDocumentation WordApp, aUseCase, HeadingNumber End If If ReportOptions.IncludeAssociations Then SearchForRelationshipsForUseCase WordApp, aUseCase, HeadingNumber End If If ReportOptions.IncludeScenDiagrams Then SearchForSeqAndCollabViewsInUseCase WordApp, aUseCase, HeadingNumber End If If ReportOptions.IncludeUseCaseDiagrams Then SearchForUseCaseDiagramsInUseCase WordApp, aUseCase, HeadingNumber End If If ReportOptions.IncludeClassDiagrams Then SearchForClassDiagramsInUseCase WordApp, aUseCase, HeadingNumber End If End Sub Sub PrintCategoryUseCases(WordApp As Object, aCategory As Category, HeadingNumber As Integer) If CategoryApplies (aCategory) Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert aCategory.Name WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then If aCategory.Documentation <> "" Then WordApp.FormatStyle "Category Documentation" WordApp.Insert Trim (aCategory.Documentation) WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If If ReportOptions.IncludeUseCaseDiagrams Then SearchForUseCaseDiagramsInPackage WordApp, aCategory, (HeadingNumber + 1) End If If ReportOptions.IncludeClassDiagrams Then SearchForClassDiagramsInPackage WordApp, aCategory, (HeadingNumber + 1) End If If ReportOptions.IncludeScenDiagrams Then SearchForSeqAndCollabViewsInPackage WordApp, aCategory, (HeadingNumber + 1) End If If aCategory.UseCases.Count > 0 Then Dim theUseCase As UseCase ' set up an array of the names of those classes tagged for generation ' and sort the array. Dim numberOfApplicableUseCases As Integer Dim UseCaseNames$() numberOfApplicableUseCases = 0 For ucID = 1 To aCategory.UseCases.Count Set theUseCase = aCategory.UseCases.GetAt(ucID) If UseCaseApplies (theUseCase) Then ReDim Preserve UseCaseNames$(numberOfApplicableUseCases + 1) UseCaseNames$(numberOfApplicableUseCases) = theUseCase.Name numberOfApplicableUseCases = numberOfApplicableUseCases + 1 End If Next ucID ' Sort the array to be in alphabetical order ArraySort UseCaseNames$() 'For each Use Case name in UseCaseNames$, find the first match in 'the collection and pass that Use Case to GenerateUseCase. For i% = 1 To numberOfApplicableUseCases ucID = aCategory.UseCases.FindFirst (UseCaseNames$(i%)) 'Got the Use Case id now get the Use Case Set theUseCase = aCategory.UseCases.GetAt (ucID) If theUseCase Is Nothing Then 'ie nothing matched MsgBox "Matching Use Case not found", ebInformation Else GenerateUseCase WordApp, theUseCase, (HeadingNumber + 1) End If Next i% ReplaceFinalParagraphKludge WordApp End If End If ' Category Applies End Sub ' PrintCategoryUseCases ' XXX Sub PrintCategoryClasses (WordApp As Object, aCategory As Category, HeadingNumber As Integer) ' Oktay -- Instead of checking aCategory.classes check all classes, including ' nested classes ' Slight modifs, by Guido Dim theCatClassCollection As ClassCollection 'Commented out, do later on, by Guido 'Set theCatClassCollection = GetAllOfClasses(aCategory) ' End Oktay Dim alpha() As String If CategoryApplies (aCategory) Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert aCategory.Name WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then If aCategory.Documentation <> "" Then WordApp.FormatStyle "Category Documentation" WordApp.Insert Trim (aCategory.Documentation) WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If 'Dim alpha() As String 'Oktay -- Reference all classes instead of upper level classes 'ReDim alpha(aCategory.classes.count) 'done here, by Guido Set theCatClassCollection = GetAllOfClasses(aCategory) ReDim alpha(theCatClassCollection.Count) sortalpha aCategory, alpha ' XXX If ReportOptions.IncludeUseCaseDiagrams Then SearchForUseCaseDiagramsInPackage WordApp, aCategory, (HeadingNumber + 1) End If If ReportOptions.IncludeClassDiagrams Then SearchForClassDiagramsInPackage WordApp, aCategory, (HeadingNumber + 1) End If If ReportOptions.IncludeScenDiagrams Then SearchForSeqAndCollabViewsInPackage WordApp, aCategory, (HeadingNumber + 1) End If ' XXX PrintClassesForCategory WordApp, aCategory, HeadingNumber, alpha End If Set theCatClassCollection = Nothing End Sub ' PrintCategoryClasses Sub PrintCategory (WordApp As Object, aCategory As Category, HeadingNumber As Integer) Dim beta() As String ' XXX Select Case ReportOptions.ReportType Case RT_LogicalModel Call PrintCategoryClasses(WordApp, aCategory, HeadingNumber) ' XXXV Case RT_PhysicalModel Case RT_AnalysisModel Call PrintCategoryUseCases(WordApp, aCategory, HeadingNumber) End Select ' XXX 'procede recursively... ReDim beta(aCategory.categories.count) For ike = 1 To aCategory.categories.count beta(ike) = aCategory.categories.getat(ike).name Next ike arraysort beta For CatID = 1 To aCategory.Categories.Count ike = aCategory.Categories.FindFirst(beta(CatID)) Call PrintCategory (WordApp, aCategory.Categories.GetAt (ike), HeadingNumber) Next CatID End Sub Sub PrintModule (WordApp As Object, aModule As Module, HeadingNumber As Integer) If ModuleApplies (aModule) Then Dim AssignedClasses As ClassCollection WordApp.FormatStyle GetWordStyleNameName (HeadingNumber) WordApp.Insert aModule.Name WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then If aModule.Documentation <> "" Then WordApp.FormatStyle "Module Documentation" WordApp.Insert Trim (aModule.Documentation) WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If Dim theClass As Class Set AssignedClasses = aModule.GetAssignedClasses () For ClsID = 1 To AssignedClasses.Count Set theClass = AssignedClasses.GetAt (ClsID) If ClassApplies (theClass) Then WordApp.FormatStyle GetWordStyleNameName (HeadingNumber + 1) GeneratePhysicalClass WordApp, theClass, HeadingNumber + 1 WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If Next ClsID End If End Sub Sub PrintSubsystem (WordApp As Object, aSubsystem As Subsystem, HeadingNumber As Integer) If SubsystemApplies (aSubsystem) Then WordApp.FormatStyle "Heading 2" WordApp.Insert aSubsystem.Name WordApp.InsertPara ReplaceFinalParagraphKludge WordApp If ReportOptions.IncludeDocumentation Then If aSubsystem.Documentation <> "" Then WordApp.FormatStyle "Subsystem Documentation" WordApp.Insert Trim (aSubsystem.Documentation) WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If If aSubsystem.Modules.Count > 0 Then Dim theModule As Module WordApp.FormatStyle "Heading 3" For ModID = 1 To aSubsystem.Modules.Count Set theModule = aSubsystem.Modules.GetAt (ModID) If ModuleApplies (theModule) Then PrintModule WordApp, theModule, HeadingNumber + 1 End If Next ModID Else WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End If End If For SubID = 1 To aSubsystem.Subsystems.Count Call PrintSubsystem (WordApp, aSubsystem.Subsystems.GetAt (SubID), HeadingNumber) Next SubID End Sub Sub PrintCategoryStructure (WordApp As Object, aCat As Category) WordApp.Insert aCat.Name WordApp.InsertPara ' AO 12/02/99: Fix Indentation in Cat structure ReplaceFinalParagraphKludge WordApp WordApp.Indent For CatID = 1 To aCat.Categories.Count PrintCategoryStructure WordApp, aCat.Categories.GetAt (CatID) Next CatID WordApp.UnIndent End Sub Sub PrintSubsystemStructure (WordApp As Object, aSubs As Subsystem) WordApp.Insert aSubs.Name WordApp.InsertPara ' AO 12/02/99: Fix Indentation in Cat structure ReplaceFinalParagraphKludge WordApp WordApp.Indent For SubID = 1 To aSubs.Subsystems.Count PrintSubsystemStructure WordApp, aSubs.Subsystems.GetAt (SubID) Next SubID WordApp.UnIndent End Sub Function CountSelectedClasses () As Integer Dim AllClasses As ClassCollection Dim ClassCount As Integer Dim NestedClasses As ClassCollection Set AllClasses = LicensedRoseApplication.CurrentModel.GetAllClasses () ClassCount = 0 For ClsID = 1 To AllClasses.Count If ClassApplies (AllClasses.GetAt (ClsID)) Then ClassCount = ClassCount + 1 Set NestedClasses = AllClasses.getAt (ClsID).GetAllNestedClasses For NestedClsCnt = 1 To NestedClasses.Count If ClassApplies (NestedClasses.GetAt (NestedClsCnt)) Then ClassCount = ClassCount + 1 Next NestedClsCnt Next ClsID CountSelectedClasses = ClassCount End Function Function CountSelectedCategories () As Integer Dim AllCategories As CategoryCollection Dim CatCount As Integer Set AllCategories = LicensedRoseApplication.CurrentModel.GetAllCategories () CatCount = 0 For CatID = 1 To AllCategories.Count If CategoryApplies (AllCategories.GetAt (CatID)) Then CatCount = CatCount + 1 Next CatID CountSelectedCategories = CatCount End Function Function CountSelectedModules () As Integer Dim AllModules As ModuleCollection Dim ModCount As Integer Set AllModules = LicensedRoseApplication.CurrentModel.GetAllModules () ModCount = 0 For ModID = 1 To AllModules.Count If ModuleApplies (AllModules.GetAt (ModID)) Then ModCount = ModCount + 1 Next ModID CountSelectedModules = ModCount End Function Function CountSelectedSubsystems () As Integer Dim AllSubsystems As SubsystemCollection Dim SubCount As Integer Set AllSubsystems = LicensedRoseApplication.CurrentModel.GetAllSubsystems () SubCount = 0 For SubID = 1 To AllSubsystems.Count If SubsystemApplies (AllSubsystems.GetAt (SubID)) Then SubCount = SubCount + 1 Next SubID CountSelectedSubsystems = SubCount End Function Sub SetGenerateFlags(theClassCollection As ClassCollection) 'commented out unused variables ClassFound and AllClasses, by Guido 'Dim ClassFound As Boolean 'Dim AllClasses As ClassCollection ' Oktay Dim I As Integer, J As Integer ' End Oktay 'Set AllClasses = LicensedRoseApplication.CurrentModel.GetAllClasses() 'Oktay -- Instead of accessing collection access the array directly 'For ClsID = 1 To theClassCollection.Count ' ClassFound = False ' i% = 1 ' While Not ClassFound ' If theClassCollection.GetAt(ClsID).GetUniqueID() = _ ' theApplicableClassArray(i%).theClassID Then ' theApplicableClassArray(i%).GenerateFlag = True ' ClassFound = True ' Else ' i% = i% + 1 ' End If ' Wend 'Next ClsID ' End Oktay Old 'Oktay -- Since theApplicableClassArray already contains the necessary information ' access the array directly to set the generation flag. For i = LBound(theApplicableClassArray) To UBound(theApplicableClassArray) For j = 1 To theClassCollection.Count If theClassCollection.GetAt(j).GetUniqueID() = _ theApplicableClassArray(i%).theClassID Then theApplicableClassArray(i%).GenerateFlag = True ' MsgBox theClassCollection.GetAt(j).Name & " has been selected." ' recursively set flag for nested classes, by Guido If ReportOptions.IncludeNestedClasses Then Dim theNestedClassesCollection As ClassCollection Set theNestedClassesCollection = theClassCollection.GetAt(j).GetNestedClasses SetGenerateFlags(theNestedClassesCollection) Set theNestedClassesCollection = Nothing End If End If Next j Next i 'End Oktay End Sub ' #BEGIN#AO# 12/02/99 Add recurse selection for a category. Sub RecurseSelectCategoryClasses(ByRef theCategory As Category) Dim nCatCount As Integer If ReportOptions.GenerateSelectedOnly Then SetGenerateFlags(theCategory.Classes) ' First flag the classes at that level. 'Then go deep. For nCatCount = 1 To theCategory.getAllCategories.Count RecurseSelectCategoryClasses(theCategory.getAllCategories.getAt(nCatCount)) Next nCatCount End If End Sub ' Of RecurseSelectCategoryClasses. ' #END#AO#12/02/99. Sub SelectLogicalClassesForGeneration () Dim theSelectedCategories As CategoryCollection Dim theSelectedClasses As ClassCollection Dim AllClasses As ClassCollection Dim theClass As Class Dim NestedClasses As ClassCollection Dim NstdOffSet As Integer NstdOffSet = 0 'Oktay -- New NestedClassCount = 0 'End Oktay Set theSelectedCategories = LicensedRoseApplication.CurrentModel.GetSelectedCategories () Set theSelectedClasses = LicensedRoseApplication.CurrentModel.GetSelectedClasses () ' Add all the classes to theApplicableClassArray and turn off the generate flags Set AllClasses = LicensedRoseApplication.CurrentModel.GetAllClasses() Redim theApplicableClassArray ( AllClasses.Count ) For ClsID = 1 To AllClasses.Count ' Oktay -- Old -- Offset is not specified correctly 'theApplicableClassArray(ClsID).theClassID = AllClasses.GetAt(ClsID).GetUniqueID() 'theApplicableClassArray(ClsID).GenerateFlag = False ' End Oktay -- Old 'Oktay -- New -- Fix the Nested Class Error ' Added NstdOffSet to ClsID because if not it overwrites the nested class info theApplicableClassArray(ClsID + NstdOffSet).theClassID = AllClasses.GetAt(ClsID).GetUniqueID() theApplicableClassArray(ClsID + NstdOffSet).GenerateFlag = False ' Oktay End Set NestedClasses = AllClasses.getat(ClsID).GetAllNestedClasses 'Oktay NestedClassCount = NestedClassCount + NestedClasses.Count 'End Oktay If NestedClasses.Count > 0 Then ReDim Preserve theApplicableClassArray (AllClasses.Count + NstdOffSet + NestedClasses.Count) For NstdClsID = 1 To NestedClasses.Count theApplicableClassArray(ClsID+NstdOffSet+NstdClsID).theClassID = NestedClasses.GetAt(NstdClsID).GetUniqueID() theApplicableClassArray(ClsID+NstdOffSet+NstdClsID).GenerateFlag = False Next NstdClsID NstdOffSet = NstdOffSet + NestedClasses.Count End If Next ClsID If ReportOptions.GenerateSelectedOnly Then ' Turn on the generate flag for the selected classes SetGenerateFlags(theSelectedClasses) ' Turn on the generate flag for classes in selected categories For CatID = 1 to theSelectedCategories.Count ' #BEGIN#AO 12/02/99 Add recurse selection for a category. ' SetGenerateFlags(theSelectedCategories.GetAt(CatID).Classes) RecurseSelectCategoryClasses(theSelectedCategories.GetAt(CatID)) ' #END#AO 12/02/99. Next CatID End If End Sub Sub SelectClassesForGeneration () Dim theSelectedSubsystems As SubsystemCollection Dim theSelectedModules As ModuleCollection Dim AssignedClasses As ClassCollection Dim theClass As Class Set theSelectedSubsystems = LicensedRoseApplication.CurrentModel.GetSelectedSubsystems () Set theSelectedModules = LicensedRoseApplication.CurrentModel.GetSelectedModules () SelectLogicalClassesForGeneration If ReportOptions.GenerateSelectedOnly Then ' theApplicableClassArray already contains all the classes in the model ' Turn on the generate flag for classes assigned to selected modules For ModID = 1 To theSelectedModules.Count SetGenerateFlags(theSelectedModules.GetAt(ModID).GetAssignedClasses ()) Next ModID ' Now, turn on the generate flag for classes linked to modules in ' selected subsystems Dim theSubsystem As Subsystem For SubID = 1 To theSelectedSubsystems.Count Set theSubsystem = theSelectedSubsystems.GetAt (SubID) For ModID = 1 To theSubsystem.Modules.Count SetGenerateFlags(theSubsystem.Modules.GetAt(ModID).GetAssignedClasses ()) Next ModID Next SubID End If ReportOptions.TotalClasses = CountSelectedClasses () ReportOptions.TotalCategories = CountSelectedCategories () ReportOptions.TotalSubsystems = CountSelectedSubsystems () ReportOptions.TotalModules = CountSelectedModules () ' XXX ReportOptions.TotalUseCases = CountSelectedUseCases ' XXX End Sub Sub SelectedLogicalModelReport (WordApp As Object, HeadingNumber As Integer) WordApp.Insert "Selected Logical View Report" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp PrintCategory WordApp, LicensedRoseApplication.CurrentModel.RootCategory, HeadingNumber End Sub Sub LogicalModelReport (WordApp As Object, HeadingNumber As Integer) WordApp.Insert "Logical View Report" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp PrintCategory WordApp, LicensedRoseApplication.CurrentModel.RootCategory, HeadingNumber End Sub Sub SelectedPhysicalModelReport (WordApp As Object, HeadingNumber As Integer) WordApp.Insert "Selected Component View Report" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp PrintSubsystem WordApp, LicensedRoseApplication.CurrentModel.RootSubsystem, HeadingNumber End Sub Sub PhysicalModelReport (WordApp As Object, HeadingNumber As Integer) WordApp.Insert "Component View Report" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp PrintSubsystem WordApp, LicensedRoseApplication.CurrentModel.RootSubsystem, HeadingNumber End Sub Sub DataDictionaryReport(WordApp As Object) WordApp.InsertPageBreak WordApp.FormatStyle "Heading 1" Select Case ReportOptions.ReportType Case RT_LogicalModel If ReportOptions.GenerateSelectedOnly Then Call SelectedLogicalModelReport (WordApp, 2) Else Call LogicalModelReport (WordApp, 2) End If Case RT_PhysicalModel If ReportOptions.GenerateSelectedOnly Then Call SelectedPhysicalModelReport (WordApp, 2) Else Call PhysicalModelReport (WordApp, 2) End If ' XXX Case RT_AnalysisModel If ReportOptions.GenerateSelectedOnly Then Call SelectedUseCaseModelReport (WordApp, 2) Else Call UseCaseModelReport (WordApp, 2) End If ' XXX End Select WordApp.InsertPageBreak WordApp.FormatStyle "Heading 1" WordApp.Insert "Totals:" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.NormalStyle Select Case ReportOptions.ReportType Case RT_LogicalModel WordApp.Insert Str$(ReportOptions.TotalCategories) & " Logical Packages" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.Insert Str$(ReportOptions.TotalClasses) & " Classes" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp Case RT_PhysicalModel WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.Insert Str$(ReportOptions.TotalModules) & " Components" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.Insert Str$(ReportOptions.TotalClasses) & " Classes" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp End Select WordApp.FormatStyle "Heading 1" Select Case ReportOptions.ReportType Case RT_LogicalModel SetCancelDialogMessage "Setting up Logical Package Structure" WordApp.Insert "Logical Package Structure" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp WordApp.NormalStyle PrintCategoryStructure WordApp, LicensedRoseApplication.CurrentModel.RootCategory Case RT_PhysicalModel SetCancelDialogMessage "Setting up Component Package Structure" WordApp.Insert "Component Package Structure" WordApp.InsertPara ReplaceFinalParagraphKludge WordApp PrintSubsystemStructure WordApp, LicensedRoseApplication.CurrentModel.RootSubsystem End Select End Sub Sub CoverPage (WordApp As Object) WordApp.FormatStyle "Title" WordApp.Insert ReportOptions.Title WordApp.InsertPara ' AO 12/02/99: Fix TABLE deleting ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle "SubTitle" WordApp.Bold If ReportOptions.GenerateSelectedOnly Then WordApp.Insert "Selected " End If Select Case ReportOptions.ReportType Case RT_LogicalModel WordApp.Insert "Logical View Report" Case RT_PhysicalModel WordApp.Insert "Component View Report" End Select WordApp.InsertPara ' AO 12/02/99: Fix TABLE deleting ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle "SubTitle" Select Case ReportOptions.ReportFormat Case RFO_Standard WordApp.Insert "Unified Modeling Language Syntax" Case RFO_Basic 'WordApp.Insert "Basic Syntax" WordApp.Insert "Visual Basic Syntax" Case RFO_CPlusPlus WordApp.Insert "C++ Syntax" End Select If ReportOptions.GeneratePublicOnly Then Prefix$ = "Public " End If WordApp.InsertPara ' AO 12/02/99: Fix TABLE deleting ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle "SubTitle" If ReportOptions.IncludeAttributes Or ReportOptions.IncludeOperations Then WordApp.Insert "Includes " & Prefix$ If ReportOptions.IncludeAttributes And ReportOptions.IncludeOperations Then WordApp.Insert "Attributes And Operations" ElseIf ReportOptions.IncludeAttributes And Not ReportOptions.IncludeOperations Then WordApp.Insert "Attributes" Else WordApp.Insert "Operations" End If Else WordApp.Insert "Attributes And Operations Excluded" End If 'added by Guido If ReportOptions.IncludeAssociations Then WordApp.InsertPara WordApp.FormatStyle "SubTitle" WordApp.Insert "Includes Associations" End If If ReportOptions.IncludeDocumentation Then WordApp.InsertPara ' AO 12/02/99: Fix TABLE deleting ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle "SubTitle" WordApp.Insert "Includes Documentation" End If WordApp.InsertPara ' AO 12/02/99: Fix TABLE deleting ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle "SubTitle" WordApp.Insert "Generated " & Format$ (Now (), "mmmm d, yyyy") WordApp.InsertPara ' AO 12/02/99: Fix TABLE deleting ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle "SubTitle" WordApp.Insert Format$ (Time$ (), "ttttt") #if RoseVersion > 4.0 Then WordApp.InsertPara ' AO 12/02/99: Fix TABLE deleting ReplaceFinalParagraphKludge WordApp WordApp.FormatStyle "SubTitle" WordApp.Insert LicensedRoseApplication.CurrentModel.GetFileName () #end if 'ReportOptions.IncludeDocumentation = MyDialog.IncludeDocumentation End Sub Function ReportDialogLoop(controlname$, action%, suppvalue%) As Integer '---------------------------------------------- 'If user presses a button do appropriate action '---------------------------------------------- Select Case action% Case 1 'Check for VB properties. Const vbpStopOnError = "StopOnError" on error resume next Dim aPropValue as variant Dim oldTool As String oldTool = LicensedRoseApplication.CurrentModel.DefaultTool LicensedRoseApplication.CurrentModel.DefaultTool = "Visual Basic" aPropValue = propertyValue (LicensedRoseApplication.CurrentModel.GetRoseItem, vbpStopOnError) if ((err <> 0) or (aPropValue = "")) then 'DlgEnable "BASICSyntax" , False err.clear end if LicensedRoseApplication.CurrentModel.DefaultTool = oldTool Case 2 If controlname$ = "Browse" Then FileName$ = SaveFilename$ ("Create a Word document", "Word Documents:*.DOC") If FileName$ <> "" Then DlgText "FileName", FileName$ End If ReportDialogLoop = 1 'End ElseIf controlname$ = "IncludeAttributes" Or controlname$ = "IncludeOperations" Then bEnable = (DlgValue ("IncludeAttributes") And DlgValue ("IncludeOperations")) DlgEnable "GeneratePublicOnly", bEnable End If End Select End Function Function MakeFileName (Path As String, FileName As String) As String ' Check to see if the last character is a separator If Instr ("\/", Right$(Path, 1)) Then MakeFileName$ = Path & FileName Else MakeFileName$ = Path & "\" & FileName End If End Function Function ChangeFileExtension (FullFileName As String, NewExtension As String) As String FilePath$ = FileParse$ (FullFileName, 2) FileRoot$ = FileParse$ (FullFileName, 4) ChangeFileExtension$ = MakeFileName$ (FilePath$, FileRoot$ & "." & NewExtension$) End Function ' XXX Function CountSelectedUseCases () As Integer Dim AllUseCases As UseCaseCollection Dim UseCaseCount As Integer Set AllUseCases = RoseApp.CurrentModel.GetAllUseCases () UseCaseCount = 0 For ucID = 1 To AllUseCases.Count If UseCaseApplies (AllUseCases.GetAt (ucID)) Then UseCaseCount = UseCaseCount + 1 Next ucID CountSelectedUseCases = UseCaseCount End Function Sub SelectUseCasesForGeneration () Dim AssignedUseCases As UseCaseCollection Dim theUseCase As UseCase SelectAllUseCasesForGeneration ReportOptions.TotalUseCases = CountSelectedUseCases () ReportOptions.TotalCategories = CountSelectedCategories () End Sub Sub SelectedUseCaseModelReport (WordApp As Object, HeadingNumber As Integer) WordApp.Insert "Selected Use Case View Report" WordApp.InsertPara PrintCategory WordApp, RoseApp.CurrentModel.RootUseCaseCategory, HeadingNumber End Sub Sub UseCaseModelReport (WordApp As Object, HeadingNumber As Integer) WordApp.Insert "Use Case View Report" WordApp.InsertPara PrintCategory WordApp, RoseApp.CurrentModel.RootUseCaseCategory, HeadingNumber End Sub Sub UseCaseReport(WordApp As Object) WordApp.InsertPageBreak WordApp.FormatStyle "Heading 1" If ReportOptions.GenerateSelectedOnly Then Call SelectedUseCaseModelReport (WordApp, 2) Else Call UseCaseModelReport (WordApp, 2) End If WordApp.InsertPageBreak WordApp.FormatStyle "Heading 1" WordApp.Insert "Totals:" WordApp.InsertPara WordApp.NormalStyle WordApp.Insert Str$(ReportOptions.TotalCategories) & " Packages" WordApp.InsertPara WordApp.Insert Str$(ReportOptions.TotalUseCases) & " Use Cases" WordApp.InsertPara FinishStepCancelDialog WordApp.FormatStyle "Heading 1" SetCancelDialogMessage "Setting up Package Structure" WordApp.Insert "Use Case Package Structure" Print "Use Case Package Structure" Print Space$(RoseApp.CurrentModel.GetAllCategories.Count);"|" WordApp.InsertPara WordApp.NormalStyle PrintCategoryStructure WordApp, RoseApp.CurrentModel.RootUseCaseCategory End Sub ' XXX Begin Dialog ReportDialog ,,266,280,"Generate Documentation",.ReportDialogLoop 'Begin Dialog ReportDialog ,,266,220,"Generate Report",.ReportDialogLoop 'PushButton 220,14,44,14,"Browse",.Browse PushButton 220,15,44,14,"Browse",.Browse HelpButton 220,43,44,14, "help\roseu.hlp", 67599 PushButton 184,180,76,14,"&Generate",.Generate PushButton 184,164,76,14,"Generate &Selected",.GenerateSelected CancelButton 184,196,76,14 TextBox 12,16,204,12,.FileName Text 8,4,112,8,"&Report File Name:",.Text1 Text 8,32,148,8,"Report &Title",.Text2 TextBox 12,44,204,12,.Title GroupBox 4,60,212,36,"Report Type",.ReportTypeGroup OptionGroup .ReportType OptionButton 8,72,88,8,"&Logical View Report",.LogicalModelReport OptionButton 8,84,192,8,"&Component View Report",.PhysicalModelReport OptionButton 108,72,88,8,"&Use Case View Report",.UseCaseModelReport GroupBox 4,100,212,48,"Attributes And Operations Syntax",.ReportFormatGroup 'GroupBox 4,100,212,48,"Properties And Methods Syntax",.ReportFormatGroup OptionGroup .ReportFormat OptionButton 8,112,160,8,"Use &Unified Modeling Language Syntax",.UMLSyntax 'OptionButton 8,130,160,8,"Use &BASIC Syntax",.BASICSyntax OptionButton 8,124,160,8,"Use &Visual Basic Syntax",.BASICSyntax OptionButton 8,136,160,8,"Use C&++ Syntax",.CPPSyntax 'GroupBox 4,156,172,60,"Report Options",.ReportOptions GroupBox 4,150,172,122,"Report Options",.ReportOptions CheckBox 8,162,92,8,"Include &Operations",.IncludeOperations 'CheckBox 8,162,92,8,"Include &Methods",.IncludeOperations CheckBox 8,174,96,8,"Include &Attributes",.IncludeAttributes 'CheckBox 8,174,96,8,"Include &Properties",.IncludeAttributes CheckBox 8,186,96,8,"Include &Associations",.IncludeAssociations 'added by Guido CheckBox 8,198,136,8,"&Public Operations And Attributes Only",.GeneratePublicOnly 'CheckBox 8,186,136,8,"&Only Public Methods And Properties",.GeneratePublicOnly 'CheckBox 8,204,132,8,"Include Documentation",.IncludeDocumentation CheckBox 8,210,132,8,"Include &Documentation",.IncludeDocumentation CheckBox 8,222,132,8,"Include &Nested Classes",.IncludeNestedClasses 'added by Guido CheckBox 8,234,88,8,"Include C&lass Diagrams",.IncludeClassDiagrams CheckBox 8,244,100,8,"Include Use Case &Diagrams",.IncludeUseCaseDiagrams CheckBox 8,254,104,8,"Include &Interaction Diagrams",.IncludeScenDiagrams End Dialog Sub Main Dim MyDialog As ReportDialog Set LicensedRoseApplication = GetLicensedRoseApplication() LicensedRoseApplication.CurrentModel.DefaultTool = DefaultTool$ CurrentDirectory$ = CurDir$ NewDirectory$ = EnclosingDirPath( LicensedRoseApplication.ApplicationPath ) If NewDirectory$ <> "" Then If Mid$(NewDirectory$, 2, 1) = ":" Then ChDrive NewDirectory$ End If ChDir NewDirectory$ Else MsgBox "Error: Installation directory not found." Exit Sub End If DefaultFileName = getResourceString(PRODUCTDEFAULTWORDDOCFILENAME) #if RoseVersion > 4.0 Then ModelName$ = LicensedRoseApplication.CurrentModel.GetFileName () If ModelName$ = "" Then MyDialog.FileName$ = MakeFileName$ (NewDirectory$, DefaultFileName) MyDialog.Title$ = FileParse$ (DefaultFileName, 4) Else MyDialog.FileName$ = ChangeFileExtension$ (ModelName$, "doc") MyDialog.Title$ = FileParse$ (ModelName$, 4) End If #else MyDialog.FileName$ = MakeFileName$ (NewDirectory$, DefaultFileName) MyDialog.Title$ = getResourceString(PRODUCTLONGNAME) & " Report" #end if MyDialog.IncludeOperations = TRUE MyDialog.IncludeAttributes = TRUE 'added by Guido MyDialog.IncludeAssociations = TRUE MyDialog.IncludeDocumentation = TRUE MyDialog.IncludeNestedClasses = TRUE ' XXX MyDialog.IncludeClassDiagrams = TRUE MyDialog.IncludeScenDiagrams = TRUE ' XXX Result = Dialog (MyDialog) If Result = 0 Then ' Cancel Selected Exit Sub End If If Result = 3 Then ' Generate Selected ReportOptions.GenerateSelectedOnly = TRUE End If If Result = 2 Then ' Generate ReportOptions.GenerateSelectedOnly = FALSE End If ReportOptions.Title = MyDialog.Title ReportOptions.ReportType = MyDialog.ReportType ReportOptions.ReportFormat = MyDialog.ReportFormat ReportOptions.IncludeOperations = MyDialog.IncludeOperations ReportOptions.IncludeAttributes = MyDialog.IncludeAttributes ReportOptions.IncludeAssociations = MyDialog.IncludeAssociations 'added by Guido ReportOptions.GeneratePublicOnly = MyDialog.GeneratePublicOnly ReportOptions.IncludeDocumentation = MyDialog.IncludeDocumentation ReportOptions.IncludeNestedClasses = MyDialog.IncludeNestedClasses 'added by Guido ' XXX ReportOptions.IncludeUseCaseDiagrams = MyDialog.IncludeUseCaseDiagrams ReportOptions.IncludeScenDiagrams = MyDialog.IncludeScenDiagrams ReportOptions.IncludeClassDiagrams = MyDialog.IncludeClassDiagrams ' XXX FileName$ = MyDialog.FileName$ If Len (FileName$) = 0 Then End Select Case ReportOptions.ReportType Case RT_LogicalModel TemplatePathName$ = NewDirectory$ & "\" & LogicalTemplateFileName$ Case RT_PhysicalModel TemplatePathName$ = NewDirectory$ & "\" & PhysicalTemplateFileName$ ' XXX Case RT_AnalysisModel TemplatePathName$ = NewDirectory$ & "\" & UseCaseTemplateFileName$ ' XXX End Select If Not FileExists (TemplatePathName$) Then MsgBox "Error: Missing file [" & TemplatePathName$ & "]." Exit Sub End If SelectClassesForGeneration ' The following three objects are OLE Automation objects. Dim WordApplication As Object Dim WordApp As Object ' Add four additional steps for initialization and post processing OpenCancelDialog "Opening Microsoft Word", ReportOptions.TotalClasses + 4 StepCancelDialog "Opening Microsoft Word", 0 'GSB Fix exception error handling ' If an error occurs then go to the TryWord95Create label ' On Error GoTo TryWord95Create XXX revalid ' Create an instance of Word using Word 97 technique Set WordApplication = CreateObject ("Word.Application") Set WordApp = WordApplication.WordBasic GoTo HaveWordApp TryWord95Create: 'GSB Fix exception error handling ' If an error occurs then go to the CancelPressed label ' On Error GoTo CancelPressed XXX revalid ' Create an instance of Word using Word 95 technique Set WordApp = CreateObject ("Word.Basic") HaveWordApp: ' If an error occurs then go to the CancelPressed label ' On Error GoTo CancelPressed XXX revalid StepCancelDialog "Loading Document Template", 1 WordApp.FileNew TemplatePathName$ SubStepCancelDialog WordApp.FileSaveAs FileName$ StepCancelDialog "Setting up document", 5 WordApp.ViewPage SubStepCancelDialog WordApp.AppMinimize SubStepCancelDialog WordApp.StartOfDocument SubStepCancelDialog CoverPage WordApp SubStepCancelDialog WordApp.EndOfDocument ' Part of the kludge to fix the "formatting too complex" Word problem ' but it didn't help. 'WordApp.insertpara 'WordApp.insertpara 'WordApp.lineup 'WordApp.lineup 'WordApp.lineup SubStepCancelDialog DataDictionaryReport (WordApp) StepCancelDialog "Updating Fields", 4 WordApp.EditSelectAll SubStepCancelDialog WordApp.UpdateFields SubStepCancelDialog WordApp.StartOfDocument SubStepCancelDialog WordApp.FileSaveAs FileName$ SubStepCancelDialog EndCancelDialog WordApp.AppMaximize WordApp.AppShow 'WordApp.FileExit 'MsgBox "Finished. Click OK to close word." Set resIFace = Nothing Exit Sub CancelPressed: If WordApp Is Not Nothing Then WordApp.AppShow End If ' If the error is not user interupt... If Err.Number <> 0 Then Select Case Err.Number Case 18 ' User interrupt Case 432 ' File name or class name not found during OLE Automation operation MsgBox "Could not create Microsoft Word. Word 7.0 must be installed on this system to generate this report." Case Else MsgBox Err.Number & ": " & Err.Description End Select Else MsgBox "Error generating report." End If 'WordApp.FileExit Set resIFace = Nothing Exit Sub Trap1: MsgBox Err.Description Set resIFace = Nothing Exit Sub End Sub