[Libreoffice-commits] dev-tools.git: helpauthoring/HelpAuthoring

Yousuf Philips philipz85 at hotmail.com
Thu Sep 10 01:23:12 PDT 2015


 helpauthoring/HelpAuthoring/Helpers.xba |   81 +++++++++++---------------------
 helpauthoring/HelpAuthoring/_Main.xba   |   62 ++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 52 deletions(-)

New commits:
commit faa1bf41bb02e21d22dc3082bd53b58aad243c5e
Author: Yousuf Philips <philipz85 at hotmail.com>
Date:   Thu Sep 10 03:59:50 2015 +0400

    Add wizard to creating new help file
    
    Change-Id: Id56b80da8311078787f17f16a1012580193b0ec0
    Reviewed-on: https://gerrit.libreoffice.org/18455
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/helpauthoring/HelpAuthoring/Helpers.xba b/helpauthoring/HelpAuthoring/Helpers.xba
index 628578d..fdd56bf 100644
--- a/helpauthoring/HelpAuthoring/Helpers.xba
+++ b/helpauthoring/HelpAuthoring/Helpers.xba
@@ -229,11 +229,11 @@ Sub InsertField(Field as String, Content as String)
 End Sub
 
 '=======================================================
-' GoUp
+' GoKey
 '-------------------------------------------------------
-' Simulates the CursorUp key
+' Executes any uno command but targetting to keyboard keystrokes
 '=======================================================
-Sub goUp(Count As Integer, Optional bSelect As Boolean)
+Sub goKey(Command as String, Optional Count As Integer, Optional bSelect As Boolean)
     dim document   as object
     dim dispatcher as object
 
@@ -250,7 +250,20 @@ Sub goUp(Count As Integer, Optional bSelect As Boolean)
         args(1).Value = bSelect
     End If
 
-    dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args())
+    dispatcher.executeDispatch(document, Command, "", 0, args())
+End Sub
+
+'=======================================================
+' GoUp
+'-------------------------------------------------------
+' Simulates the CursorUp key
+'=======================================================
+Sub goUp(Count As Integer, Optional bSelect As Boolean)
+    If IsMissing(bSelect) Then
+		goKey( ".uno:GoUp", Count )
+	Else
+		goKey( ".uno:GoUp", Count, bSelect )
+	End if
 End Sub
 
 '=======================================================
@@ -259,23 +272,11 @@ End Sub
 ' Simulates the CursorDown key
 '=======================================================
 Sub goDown(Count As Integer, Optional bSelect As Boolean)
-    dim document   as object
-    dim dispatcher as object
-
-    document   = ThisComponent.CurrentController.Frame
-    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
-
-    dim args(1) as new com.sun.star.beans.PropertyValue
-    args(0).Name = "Count"
-    args(0).Value = Count
-    args(1).Name = "Select"
     If IsMissing(bSelect) Then
-        args(1).Value = false
-    Else
-        args(1).Value = bSelect
-    End If
-
-    dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args())
+		goKey( ".uno:GoDown", Count )
+	Else
+		goKey( ".uno:GoDown", Count, bSelect )
+	End if
 End Sub
 
 
@@ -285,23 +286,11 @@ End Sub
 ' Simulates the CursorRight key
 '=======================================================
 Sub goRight(Count As Integer, Optional bSelect As Boolean)
-    dim document   as object
-    dim dispatcher as object
-
-    document   = ThisComponent.CurrentController.Frame
-    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
-
-    dim args(1) as new com.sun.star.beans.PropertyValue
-    args(0).Name = "Count"
-    args(0).Value = Count
-    args(1).Name = "Select"
     If IsMissing(bSelect) Then
-        args(1).Value = false
-    Else
-        args(1).Value = bSelect
-    End If
-
-    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args())
+		goKey( ".uno:GoRight", Count )
+	Else
+		goKey( ".uno:GoRight", Count, bSelect )
+	End if
 End Sub
 
 '=======================================================
@@ -310,23 +299,11 @@ End Sub
 ' Simulates the CursorLeft key
 '=======================================================
 Sub goLeft(Count As Integer, optional bSelect As boolean)
-    dim document   as object
-    dim dispatcher as object
-
-    document   = ThisComponent.CurrentController.Frame
-    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
-
-    dim args(1) as new com.sun.star.beans.PropertyValue
-    args(0).Name = "Count"
-    args(0).Value = Count
-    args(1).Name = "Select"
     If IsMissing(bSelect) Then
-        args(1).Value = false
-    Else
-        args(1).Value = bSelect
-    End If
-
-    dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args())
+		goKey( ".uno:GoLeft", Count )
+	Else
+		goKey( ".uno:GoLeft", Count, bSelect )
+	End if
 End Sub
 
 '=======================================================
diff --git a/helpauthoring/HelpAuthoring/_Main.xba b/helpauthoring/HelpAuthoring/_Main.xba
index 9746c02..ff3ab44 100644
--- a/helpauthoring/HelpAuthoring/_Main.xba
+++ b/helpauthoring/HelpAuthoring/_Main.xba
@@ -73,6 +73,68 @@ Sub SetMetaDataOnSave(Path as String)
 '    document.DocumentInfo.SetUserFieldName(2,"Comment")
     document.DocumentProperties.Subject = Path
 
+	If document.DocumentProperties.Title = "" Then
+		Ret = msgbox( "Automatically generate a basic help file?", 1+32, "Basic Help File" )
+		If Ret = 0 Then
+			Exit Sub
+		End if
+	
+		document.DocumentProperties.UserDefinedProperties.ID = Replace( AlphaNum(Path), "xhp", "xml" )
+		document.DocumentProperties.UserDefinedProperties.Indexer = "include"
+
+		title = inputbox("The help title is a few word description of the help file topic.","Enter Help Title")
+		If title = "" Then
+			title = "Help Title"
+		End If
+		document.DocumentProperties.Title = title
+
+		InsertText( title )
+        InsertTag("_LINK","</LINK>")
+		InsertNewParaData()
+		InsertTag("LINK_","<LINK href=""" + Right( Path, Len(Path) - 1 ) + """>")
+		CR()
+
+		SetParaStyle("hlp_paragraph")
+		SetCharStyle("Default Style")
+		desc = inputbox("The help description is a sentence of text to further describe the help title."+chr(10)+"example: This menu contains commands for editing the contents of the current document.","Enter Help Description")
+		If desc = "" Then
+			desc = "Help description"
+		End If
+		InsertText( desc )
+		InsertNewParaData()
+		CR()
+
+		SetParaStyle("hlp_paragraph")
+		SetCharStyle("Default Style")
+		startTyping = "Start Typing Here..."
+		InsertText( startTyping )
+
+		goKey( ".uno:GoToStartOfLine" )
+		goLeft(1)
+		
+		goKey( ".uno:StartOfParaSel", 1, 1 )
+		goUp( 1, 1 )
+
+		InsertSection( lcase( AlphaNum(title) ) )
+
+		sHID = inputbox("A help ID (hID) is a unique reference key to context-sensitive help when a user uses the F1 key or the Help button. There are two types: UNO commands and Symbolic names."+chr(10)+"examples: .uno:InsertCtrl, SID_FM_CONVERTTO_IMAGECONTROL","Enter Help ID (hID)",".uno:" )
+		if sHID <> "" and sHID <> ".uno:" then
+			goKey( ".uno:GoToPrevPara" )
+			goKey( ".uno:GoToPrevPara" )
+			CR_before()
+			goUp(1)
+			SetParaStyle("hlp_aux_bookmark")
+			SetCharStyle("hlp_aux_tag")
+			InsertTag("BOOKMARK","<BOOKMARK branch=""hid/" + sHID + """ id=""bm_id" + CreateID + """ localize=""false""/>")
+		else
+			goKey( ".uno:GoToPrevPara" )
+		end if
+
+		goKey( ".uno:GoToEndOfDoc" ) ' will stop at end of section instead of end of doc
+		goRight( 1 )
+		goRight( len(startTyping), 1 )
+	end if
+
 End Sub
 
 '=======================================================


More information about the Libreoffice-commits mailing list