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

Yousuf Philips philipz85 at hotmail.com
Sat Sep 12 12:57:20 PDT 2015


 helpauthoring/Addons.xcu                |   61 +++++++++++----
 helpauthoring/HelpAuthoring/Helpers.xba |   19 ++++
 helpauthoring/HelpAuthoring/_Main.xba   |  128 ++++++++++++++++++++++++++++++--
 3 files changed, 189 insertions(+), 19 deletions(-)

New commits:
commit 512ac2ae57bd4f10d5af446c01461974bd6b7aca
Author: Yousuf Philips <philipz85 at hotmail.com>
Date:   Sat Sep 12 22:59:41 2015 +0400

    View help file source, unhide paragraph ids and reorganize menu
    
    Change-Id: I1994e2481a87a627667a4a06c4b8a61782174c63
    Reviewed-on: https://gerrit.libreoffice.org/18518
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/helpauthoring/Addons.xcu b/helpauthoring/Addons.xcu
index 6974509..e4268ac 100644
--- a/helpauthoring/Addons.xcu
+++ b/helpauthoring/Addons.xcu
@@ -166,7 +166,16 @@
                         </prop>
                         <prop oor:name="Title" oor:type="xs:string">
                             <value/>
-                            <value xml:lang="en-US">Open <Embed> or <Link> Help File </value>
+                            <value xml:lang="en-US">Open <Embed> or <Link> File </value>
+                        </prop>
+                    </node>
+                    <node oor:name="m14" oor:op="replace">
+                        <prop oor:name="URL" oor:type="xs:string">
+                            <value>vnd.sun.star.script:HelpAuthoring._Main.OpenLinkSource?language=Basic&location=application</value>
+                        </prop>
+                        <prop oor:name="Title" oor:type="xs:string">
+                            <value/>
+                            <value xml:lang="en-US">View <Embed> or <Link> File Source</value>
                         </prop>
                     </node>
 
@@ -218,7 +227,7 @@
                         </prop>
                         <prop oor:name="Title" oor:type="xs:string">
                             <value/>
-                            <value xml:lang="en-US">Insert Variable (<variable>) </value>
+                            <value xml:lang="en-US">Insert Variable (<variable>/<var>) </value>
                         </prop>
                     </node>
 
@@ -243,7 +252,7 @@
                         </prop>
                         <prop oor:name="Title" oor:type="xs:string">
                             <value/>
-                            <value xml:lang="en-US">Insert Extended Tip (<avis>/<ahis>) </value>
+                            <value xml:lang="en-US">Insert Extended Tip (<ahelp>/<avis>/<ahid>) </value>
                         </prop>
                     </node>
                     <node oor:name="m33" oor:op="replace">
@@ -360,22 +369,21 @@
                         </node>
                     </node>
 
-                    <!-- Functions that are least used -->
-                    <node oor:name="m80" oor:op="replace">
+                    <node oor:name="m70" oor:op="replace">
                         <prop oor:name="URL" oor:type="xs:string">
                             <value>private:separator</value>
                         </prop>
                     </node>
-                    <node oor:name="m81" oor:op="replace">
+                    <node oor:name="m71" oor:op="replace">
                         <prop oor:name="URL" oor:type="xs:string">
-                            <value>vnd.sun.star.script:HelpAuthoring.Meta.Main?language=Basic&location=application</value>
+                            <value>vnd.sun.star.script:HelpAuthoring.OtherElements.ToggleParaL10NStatus?language=Basic&location=application</value>
                         </prop>
                         <prop oor:name="Title" oor:type="xs:string">
                             <value/>
-                            <value xml:lang="en-US">Edit Meta Data </value>
+                            <value xml:lang="en-US">Toggle Paragraph L10N Status (localize="...") </value>
                         </prop>
                     </node>
-                    <node oor:name="m82" oor:op="replace">
+                    <node oor:name="m72" oor:op="replace">
                         <prop oor:name="URL" oor:type="xs:string">
                             <value>vnd.sun.star.script:HelpAuthoring.Helpers.InsertNewParaData?language=Basic&location=application</value>
                         </prop>
@@ -384,16 +392,32 @@
                             <value xml:lang="en-US">Assign Paragraph ID </value>
                         </prop>
                     </node>
-                    <node oor:name="m83" oor:op="replace">
+                    <node oor:name="m73" oor:op="replace">
                         <prop oor:name="URL" oor:type="xs:string">
-                            <value>vnd.sun.star.script:HelpAuthoring.OtherElements.ToggleParaL10NStatus?language=Basic&location=application</value>
+                            <value>vnd.sun.star.script:HelpAuthoring._Main.UnhideParaIDs?language=Basic&location=application</value>
                         </prop>
                         <prop oor:name="Title" oor:type="xs:string">
                             <value/>
-                            <value xml:lang="en-US">Toggle L10N (localize="...") </value>
+                            <value xml:lang="en-US">Unhide Paragraph IDs </value>
                         </prop>
                     </node>
-                    <node oor:name="m84" oor:op="replace">
+
+                    <!-- Functions that are least used -->
+                    <node oor:name="m80" oor:op="replace">
+                        <prop oor:name="URL" oor:type="xs:string">
+                            <value>private:separator</value>
+                        </prop>
+                    </node>
+                    <node oor:name="m81" oor:op="replace">
+                        <prop oor:name="URL" oor:type="xs:string">
+                            <value>vnd.sun.star.script:HelpAuthoring.Meta.Main?language=Basic&location=application</value>
+                        </prop>
+                        <prop oor:name="Title" oor:type="xs:string">
+                            <value/>
+                            <value xml:lang="en-US">Edit Meta Data </value>
+                        </prop>
+                    </node>
+                    <node oor:name="m82" oor:op="replace">
                         <prop oor:name="URL" oor:type="xs:string">
                             <value>vnd.sun.star.script:HelpAuthoring.Validate.Validate?language=Basic&location=application</value>
                         </prop>
@@ -402,7 +426,7 @@
                             <value xml:lang="en-US">Validate Help File </value>
                         </prop>
                     </node>
-                    <node oor:name="m86" oor:op="replace">
+                    <node oor:name="m83" oor:op="replace">
                         <prop oor:name="URL" oor:type="xs:string">
                             <value>vnd.sun.star.script:HelpAuthoring._Main.ReloadXHP?language=Basic&location=application</value>
                         </prop>
@@ -411,6 +435,15 @@
                             <value xml:lang="en-US">Reload File</value>
                         </prop>
                     </node>
+                    <node oor:name="m84" oor:op="replace">
+                        <prop oor:name="URL" oor:type="xs:string">
+                            <value>vnd.sun.star.script:HelpAuthoring._Main.OpenXHPText?language=Basic&location=application</value>
+                        </prop>
+                        <prop oor:name="Title" oor:type="xs:string">
+                            <value/>
+                            <value xml:lang="en-US">View File Source</value>
+                        </prop>
+                    </node>
 
                     <!-- Functions that maybe opened by the user only once -->
                     <node oor:name="m90" oor:op="replace">
diff --git a/helpauthoring/HelpAuthoring/Helpers.xba b/helpauthoring/HelpAuthoring/Helpers.xba
index fdd56bf..25d533e 100644
--- a/helpauthoring/HelpAuthoring/Helpers.xba
+++ b/helpauthoring/HelpAuthoring/Helpers.xba
@@ -1085,4 +1085,23 @@ Function GetUserFieldNumber(fn as String)
     Next a
     GetUserFieldNumber = fnum
 End Function
+
+'==========================================
+'determine Operating System
+'==========================================
+Function getOS()as String     
+  Select Case getGUIType
+  Case 1: 
+    getOS="WIN"
+  Case 3: 
+    getOS="MAC"
+  Case 4: 
+    If fileExists( "/usr/bin/xdg-open" ) Then
+		getOS="UNIX"
+	Else
+		getOS="OSX"
+	End If
+  End Select
+End Function
+
 </script:module>
diff --git a/helpauthoring/HelpAuthoring/_Main.xba b/helpauthoring/HelpAuthoring/_Main.xba
index 4e1c0b3..be5f59c 100644
--- a/helpauthoring/HelpAuthoring/_Main.xba
+++ b/helpauthoring/HelpAuthoring/_Main.xba
@@ -99,7 +99,10 @@ Sub SetMetaDataOnSave(Path as String)
 		If desc = "" Then
 			desc = "Help description"
 		End If
+		InsertTag("AVIS_","<AVIS hid=""."">")
+		SetCharStyle("Default Style")
 		InsertText( desc )
+		InsertTag("_AVIS","</AVIS>")
 		InsertNewParaData()
 		CR()
 
@@ -107,6 +110,7 @@ Sub SetMetaDataOnSave(Path as String)
 		SetCharStyle("Default Style")
 		startTyping = "Start Typing Here..."
 		InsertText( startTyping )
+		InsertNewParaData()
 
 		goKey( ".uno:GoToStartOfLine" )
 		goLeft(1)
@@ -130,7 +134,7 @@ Sub SetMetaDataOnSave(Path as String)
 		end if
 
 		goKey( ".uno:GoToEndOfDoc" ) ' will stop at end of section instead of end of doc
-		goRight( 1 )
+		goRight( 2 )
 		goRight( len(startTyping), 1 )
 	end if
 
@@ -275,6 +279,27 @@ Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
     oFileDialog.Dispose()
 End Sub
 
+Sub OpenXHPText( optional doc_url as string )
+    If not IsHelpFile Then
+        msgbox( strErr_NoHelpFile )
+        Exit Sub
+    End If
+
+	if ismissing(doc_url) or doc_url = 0 then
+		document = StarDesktop.CurrentComponent
+		doc_url = convertfromurl( document.URL )
+	end if
+
+	Dim oSvc as Object
+	oSvc = createUnoService("com.sun.star.system.SystemShellExecute")
+
+	Select Case getOS()
+		Case "WIN" : oSvc.execute( "explorer", doc_url, 0)
+		Case "OSX" : oSvc.execute( "open", doc_url, 0) ' this hasnt been tested yet
+		Case "UNIX" : oSvc.execute( "xdg-open", doc_url, 0)
+	End Select
+End Sub
+
 Sub OpenLink
     If not IsHelpFile Then
         msgbox( strErr_NoHelpFile )
@@ -283,7 +308,7 @@ Sub OpenLink
 
 	oVC = ThisComponent.CurrentController.getViewCursor
 	If oVC.isCollapsed Then
-	 	Print "Please select a <embed> or <link> tag."
+	 	msgbox "Please select a <embed> or <link> tag."
 	 Else
 	 	link_start = instr(oVC.String,"<LINK")
 	 	embed_start = instr(oVC.String,"<EMBED")
@@ -296,6 +321,7 @@ Sub OpenLink
  			href_end = instr( href_start + 6, oVC.String, """" )
 			href = mid( oVC.String, href_start + 6, href_end - href_start - 6 )
 			section_start = instr( href, "#" )
+			section = ""
 			If section_start Then
 				section = mid( href, section_start + 1, len(href) - section_start )
 				href = mid( href, 1, section_start - 1 )
@@ -303,16 +329,57 @@ Sub OpenLink
 
 			sPath = ReadConfig("HelpPrefix") + href
 			if StarDesktop.CurrentComponent.URL = sPath then
-				print "Cant open currently open help file"
+				msgbox "Cant open currently open help file"
 			else
 				Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
 				FileProperties(0).Name = "FilterName"
 		        FileProperties(0).Value ="XHP_Help"
 		        oDoc = StarDesktop.loadComponentFromURL(sPath, "_blank", 0, FileProperties())
-		        ' would be good to add code here to jump to the link's section/variable reference location in the file
+		        if section <> "" then
+		        	FindLink( oDoc, section )
+		        end if
 		     end if
 	 	Else
-	 		Print "Please select a <embed> or <link> tag."
+	 		msgbox "Please select a <embed> or <link> tag."
+	 	End If 
+	EndIf
+End Sub
+
+Sub OpenLinkSource
+    If not IsHelpFile Then
+        msgbox( strErr_NoHelpFile )
+        Exit Sub
+    End If
+
+	oVC = ThisComponent.CurrentController.getViewCursor
+	If oVC.isCollapsed Then
+	 	msgbox "Please select a <embed> or <link> tag."
+	 Else
+	 	link_start = instr(oVC.String,"<LINK")
+	 	embed_start = instr(oVC.String,"<EMBED")
+	 	If link_start Or embed_start Then
+	 		If link_start Then
+	 			href_start = instr( link_start, oVC.String, "href=""" )
+	 		Else
+	 			href_start = instr( embed_start, oVC.String, "href=""" )
+	 		End If 
+ 			href_end = instr( href_start + 6, oVC.String, """" )
+			href = mid( oVC.String, href_start + 6, href_end - href_start - 6 )
+			section_start = instr( href, "#" )
+			section = ""
+			If section_start Then
+				section = mid( href, section_start + 1, len(href) - section_start )
+				href = mid( href, 1, section_start - 1 )
+			End If
+
+			sPath = ReadConfig("HelpPrefix") + href
+			if StarDesktop.CurrentComponent.URL = sPath then
+				msgbox "Cant open currently open help file"
+			else
+				OpenXHPText( sPath )
+		    end if
+	 	Else
+	 		msgbox "Please select a <embed> or <link> tag."
 	 	End If 
 	EndIf
 End Sub
@@ -332,4 +399,55 @@ Sub ReloadXHP
 	document.close(-1)
 	oDoc = StarDesktop.loadComponentFromURL(path, path, 0, FileProperties())
 End Sub
+
+Sub UnhideParaIDs
+    oDoc = StarDesktop.CurrentComponent
+    Enum = oDoc.Text.createEnumeration
+
+    Do While Enum.hasMoreElements
+        TE = Enum.nextElement
+
+        If TE.supportsService("com.sun.star.text.Paragraph") Then
+		    If Left(TE.ParaStyleName,4) = "hlp_" AND Not(Left(TE.ParaStyleName,8) = "hlp_aux_") Then
+		        sText = TE.GetString
+		
+		        If sText <> "" Then
+		            TP = TE.createEnumeration
+		            Ct = 0
+		            posID = 0
+		
+		            While TP.hasmoreElements
+		                Ct = Ct+1
+		                TPE = TP.nextElement
+		                If TPE.TextPortionType="TextField" Then
+		                    If TPE.TextField.TextFieldMaster.Name="ID" Then
+		                        TPE.TextField.IsVisible = TRUE
+		                    End If
+		                End If
+		                If TPE.String = "" Then
+		                    Ct = Ct-1
+		                End If
+		            Wend
+		        End If
+		    End If
+        End If
+    Loop
+End Sub
+
+Sub FindLink( oDoc, section )
+    oDoc = StarDesktop.CurrentComponent
+    Enum = oDoc.Text.createEnumeration
+
+    Do While Enum.hasMoreElements
+        TE = Enum.nextElement
+
+		If TE.supportsService("com.sun.star.text.Paragraph") Then
+			if instr( lcase(TE.GetString), "id=""" + section + """" ) then
+		        oCur = TE.getText.createTextCursorByRange(TE)
+	    	    thiscomponent.getcurrentcontroller.select(oCur)
+	    	    exit sub
+	    	end if
+	    end if
+   Loop
+End Sub
 </script:module>


More information about the Libreoffice-commits mailing list