Skip to content

Commit

Permalink
Modeless diagram editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmierzeje committed Nov 2, 2021
1 parent 7d8c00b commit fcb44a2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 34 deletions.
58 changes: 41 additions & 17 deletions src/vba/PlantUMLEdit.frm
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} PlantUMLEdit
TypeInfoVer = 93
End
Attribute VB_Name = "PlantUMLEdit"
Attribute VB_Base = "0{4D81A2E8-D919-48B6-85F7-481A6429260D}{D82CBFC3-4044-4614-8FF9-25C1420FC4F8}"
Attribute VB_Base = "0{EED7A077-936A-4B57-9167-37564FA5DBA3}{D765CBC1-2154-4616-AAEA-79547FFA068F}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = False

Public Hidden As Boolean

Public Hidden As Boolean
Private Focus As Boolean
Private Target As Shape
Private WithEvents oFormResize As UserFormResizer
Attribute oFormResize.VB_VarHelpID = -1
Expand All @@ -35,12 +36,13 @@ On Error GoTo Failed
And ActiveWindow.Selection.ShapeRange.Count = 1 _
And ActiveWindow.Selection.ShapeRange(1).Tags("diagram_type") > "" Then

UserForm_Initialize
If Left <> 0 Then
StartUpPosition = 0
End If
Show
Target.Select

ShowWindow Focus
Focus = False

Exit Sub
End If
Failed:
Expand Down Expand Up @@ -74,6 +76,7 @@ Private Sub Code_Change()
UpdateDiagram
End Sub


Private Sub JarLocationTextBox_Enter()
BrowseForJarButton.SetFocus
BrowseForJarButton_Click
Expand All @@ -86,8 +89,15 @@ End Sub

Private Sub UserForm_Activate()
Hidden = False

On Error Resume Next
Set Target = ActiveWindow.Selection.ShapeRange(1)
TypeCombo.Text = Target.Tags("diagram_type")
Code.Text = Target.Tags("plantuml")
Code.SelStart = 0
End Sub


Private Sub UserForm_Initialize()
Initializing = True

Expand All @@ -100,29 +110,20 @@ Private Sub UserForm_Initialize()

JarLocationTextBox.Text = GetSetting("PlantUML_Plugin", "Settings", "JarPath")

If oFormResize Is Nothing Then
Set oFormResize = New UserFormResizer
Set oFormResize.ResizableForm = Me
End If
Set oFormResize = New UserFormResizer
Set oFormResize.ResizableForm = Me

If Dir(JarLocationTextBox.Text) = "" Then
BrowseForJarButton_Click
End If

On Error GoTo Failed
Set Target = ActiveWindow.Selection.ShapeRange(1)
TypeCombo.Text = Target.Tags("diagram_type")
Code.Text = Target.Tags("plantuml")
Code.SelStart = 0
Code.SetFocus
Failed:
Initializing = False
End Sub

Private Sub oFormResize_Resizing(ByVal X As Single, ByVal Y As Single)
With Code
.width = .width + X
.height = .height + Y
.Height = .Height + Y
End With

AlignBottom JarLocationLabel, Y
Expand Down Expand Up @@ -155,3 +156,26 @@ Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
CancelButton_Click
End If
End Sub

Private Sub ShowWindow(Optional Focus As Boolean = True)
UserForm_Activate

Show
TypeCombo.SetFocus
Code.SetFocus

If Not Focus Then
Target.Select
End If
End Sub

Public Sub Edit(Optional shp As Shape)

If shp Is Nothing Then
ShowWindow
Else
Focus = True
Hidden = False
shp.Select
End If
End Sub
Binary file modified src/vba/PlantUMLEdit.frx
Binary file not shown.
13 changes: 5 additions & 8 deletions src/vba/PlantUml.bas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Attribute VB_Name = "PlantUml"
Private controller As New UIController

Property Get Editor()
Property Get Editor() As PlantUMLEdit
Static obj As PlantUMLEdit
If obj Is Nothing Then
Set obj = New PlantUMLEdit
Expand Down Expand Up @@ -63,7 +63,6 @@ End Function


Public Sub InsertDiagram()
On Error GoTo Failed
Dim sld As Slide
Dim shp As Shape
Set sld = Application.ActiveWindow.View.Slide
Expand All @@ -73,17 +72,15 @@ Public Sub InsertDiagram()
shp.Line.Visible = msoFalse
shp.Tags.Add "plantuml", ""
shp.Tags.Add "diagram_type", "uml"
Editor.Hidden = False
shp.Select
Failed:


Editor.Edit shp
End Sub

Public Sub EditDiagram()
If ActiveWindow.Selection.ShapeRange.Count = 0 Then
If ActiveWindow.Selection.ShapeRange.Count <> 1 Then
Exit Sub
End If
Editor.Show
Editor.Edit
End Sub

Function GetScale(orig As String, current As Single) As Single
Expand Down
18 changes: 9 additions & 9 deletions src/vba/Project.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
CodePage=1250
SysKind=1
Version=1668524404.4
ID="{F2CCB579-F747-461A-8FD7-A9FA76DDCE4D}"
Version=1668895371.2
ID="{45A99429-F8AE-4E2C-9F9C-9C5D9B4B6ECD}"
Package={AC9F2F90-E877-11CE-9F68-00AA00574A4F}
Name="VBAProject"
HelpContextID="0"
VersionCompatible32="393222000"
CMG="C1C3850389038903890389"
DPB="4F4D0B1F1723A424A424A4"
GC="DDDF99ADA93AAA3AAAC5"
CMG="4F4D73078F1B191F191F191F191F"
DPB="DDDFE195E122E222E222"
GC="6B69572BE42CE42C1B"

[Host Extender Info]
&H00000001={3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000
Expand All @@ -17,15 +17,15 @@ GC="DDDF99ADA93AAA3AAAC5"
[Constants]

[Reference stdole]
LibId=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\Windows\SysWOW64\stdole2.tlb#OLE Automation
LibId=*\G{00020430-0000-0000-C000-000000000046}#2.0#0##

[Reference Office]
LibId=*\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16\MSO.DLL#Microsoft Office 16.0 Object Library
LibId=*\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0##

[Reference MSForms]
LibIdTwiddled=*\G{00000000-0000-0000-0000-000000000000}#0.0#0##
LibIdExtended=*\G{1E29F92C-6504-41B6-A70A-746D674E48B6}#2.0#0##
LibIdExtended=*\G{1E29F92C-6504-41B6-A70A-746D674E48B6}#2.0#0#
NameRecordExtended=MSForms
OriginalLibId=*\G{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0#C:\WINDOWS\SysWOW64\FM20.DLL#Microsoft Forms 2.0 Object Library
OriginalLibId=*\G{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0##
OriginalTypeLib={0d452ee1-e08f-101a-852e-02608c4d0bb4}
Cookie=1
3 changes: 3 additions & 0 deletions src/vba/UserFormResizer.cls
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Private Sub AddResizeControls()
.SpecialEffect = fmSpecialEffectFlat
.MousePointer = fmMousePointerSizeNWSE
.ZOrder 0
.TabStop = False
.width = 15
.height = 15
End With
Expand All @@ -97,13 +98,15 @@ Private Sub AddResizeControls()
.SpecialEffect = fmSpecialEffectFlat
.MousePointer = fmMousePointerSizeWE
.ZOrder 0
.TabStop = False
.width = 2
.Top = 0
End With
Set frResizerBottom = oResizableForm.Controls.Add("Forms.Frame.1")
With frResizerBottom
.SpecialEffect = fmSpecialEffectFlat
.MousePointer = fmMousePointerSizeNS
.TabStop = False
.ZOrder 0
.height = 2
.Left = 0
Expand Down

0 comments on commit fcb44a2

Please sign in to comment.