summaryrefslogtreecommitdiff
path: root/helpauthoring
diff options
context:
space:
mode:
authorYousuf Philips <philipz85@hotmail.com>2015-09-12 22:59:41 +0400
committerCaolán McNamara <caolanm@redhat.com>2015-09-12 19:57:02 +0000
commit512ac2ae57bd4f10d5af446c01461974bd6b7aca (patch)
treee95a6efc4ef568e972a8982c8d9bba3da03d02c0 /helpauthoring
parent01ef2e43cc66ad43b5fa06bc22eb9981b60de0fb (diff)
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@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'helpauthoring')
-rw-r--r--helpauthoring/Addons.xcu61
-rw-r--r--helpauthoring/HelpAuthoring/Helpers.xba19
-rw-r--r--helpauthoring/HelpAuthoring/_Main.xba128
3 files changed, 189 insertions, 19 deletions
diff --git a/helpauthoring/Addons.xcu b/helpauthoring/Addons.xcu
index 69745099..e4268ac1 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 &lt;Embed&gt; or &lt;Link&gt; Help File </value>
+ <value xml:lang="en-US">Open &lt;Embed&gt; or &lt;Link&gt; 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&amp;location=application</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">View &lt;Embed&gt; or &lt;Link&gt; 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 (&lt;variable&gt;) </value>
+ <value xml:lang="en-US">Insert Variable (&lt;variable&gt;/&lt;var&gt;) </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 (&lt;avis&gt;/&lt;ahis&gt;) </value>
+ <value xml:lang="en-US">Insert Extended Tip (&lt;ahelp&gt;/&lt;avis&gt;/&lt;ahid&gt;) </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&amp;location=application</value>
+ <value>vnd.sun.star.script:HelpAuthoring.OtherElements.ToggleParaL10NStatus?language=Basic&amp;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=&quot;...&quot;) </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&amp;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&amp;location=application</value>
+ <value>vnd.sun.star.script:HelpAuthoring._Main.UnhideParaIDs?language=Basic&amp;location=application</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
- <value xml:lang="en-US">Toggle L10N (localize=&quot;...&quot;) </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&amp;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&amp;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&amp;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&amp;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 fdd56bf8..25d533e1 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
+
+&apos;==========================================
+&apos;determine Operating System
+&apos;==========================================
+Function getOS()as String
+ Select Case getGUIType
+ Case 1:
+ getOS=&quot;WIN&quot;
+ Case 3:
+ getOS=&quot;MAC&quot;
+ Case 4:
+ If fileExists( &quot;/usr/bin/xdg-open&quot; ) Then
+ getOS=&quot;UNIX&quot;
+ Else
+ getOS=&quot;OSX&quot;
+ End If
+ End Select
+End Function
+
</script:module>
diff --git a/helpauthoring/HelpAuthoring/_Main.xba b/helpauthoring/HelpAuthoring/_Main.xba
index 4e1c0b31..be5f59c3 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(&quot;AVIS_&quot;,&quot;&lt;AVIS hid=&quot;&quot;.&quot;&quot;&gt;&quot;)
+ SetCharStyle(&quot;Default Style&quot;)
InsertText( desc )
+ InsertTag(&quot;_AVIS&quot;,&quot;&lt;/AVIS&gt;&quot;)
InsertNewParaData()
CR()
@@ -107,6 +110,7 @@ Sub SetMetaDataOnSave(Path as String)
SetCharStyle(&quot;Default Style&quot;)
startTyping = &quot;Start Typing Here...&quot;
InsertText( startTyping )
+ InsertNewParaData()
goKey( &quot;.uno:GoToStartOfLine&quot; )
goLeft(1)
@@ -130,7 +134,7 @@ Sub SetMetaDataOnSave(Path as String)
end if
goKey( &quot;.uno:GoToEndOfDoc&quot; ) &apos; 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(&quot;com.sun.star.system.SystemShellExecute&quot;)
+
+ Select Case getOS()
+ Case &quot;WIN&quot; : oSvc.execute( &quot;explorer&quot;, doc_url, 0)
+ Case &quot;OSX&quot; : oSvc.execute( &quot;open&quot;, doc_url, 0) &apos; this hasnt been tested yet
+ Case &quot;UNIX&quot; : oSvc.execute( &quot;xdg-open&quot;, 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 &quot;Please select a &lt;embed&gt; or &lt;link&gt; tag.&quot;
+ msgbox &quot;Please select a &lt;embed&gt; or &lt;link&gt; tag.&quot;
Else
link_start = instr(oVC.String,&quot;&lt;LINK&quot;)
embed_start = instr(oVC.String,&quot;&lt;EMBED&quot;)
@@ -296,6 +321,7 @@ Sub OpenLink
href_end = instr( href_start + 6, oVC.String, &quot;&quot;&quot;&quot; )
href = mid( oVC.String, href_start + 6, href_end - href_start - 6 )
section_start = instr( href, &quot;#&quot; )
+ section = &quot;&quot;
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(&quot;HelpPrefix&quot;) + href
if StarDesktop.CurrentComponent.URL = sPath then
- print &quot;Cant open currently open help file&quot;
+ msgbox &quot;Cant open currently open help file&quot;
else
Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = &quot;FilterName&quot;
FileProperties(0).Value =&quot;XHP_Help&quot;
oDoc = StarDesktop.loadComponentFromURL(sPath, &quot;_blank&quot;, 0, FileProperties())
- &apos; would be good to add code here to jump to the link&apos;s section/variable reference location in the file
+ if section &lt;&gt; &quot;&quot; then
+ FindLink( oDoc, section )
+ end if
end if
Else
- Print &quot;Please select a &lt;embed&gt; or &lt;link&gt; tag.&quot;
+ msgbox &quot;Please select a &lt;embed&gt; or &lt;link&gt; tag.&quot;
+ 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 &quot;Please select a &lt;embed&gt; or &lt;link&gt; tag.&quot;
+ Else
+ link_start = instr(oVC.String,&quot;&lt;LINK&quot;)
+ embed_start = instr(oVC.String,&quot;&lt;EMBED&quot;)
+ If link_start Or embed_start Then
+ If link_start Then
+ href_start = instr( link_start, oVC.String, &quot;href=&quot;&quot;&quot; )
+ Else
+ href_start = instr( embed_start, oVC.String, &quot;href=&quot;&quot;&quot; )
+ End If
+ href_end = instr( href_start + 6, oVC.String, &quot;&quot;&quot;&quot; )
+ href = mid( oVC.String, href_start + 6, href_end - href_start - 6 )
+ section_start = instr( href, &quot;#&quot; )
+ section = &quot;&quot;
+ 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(&quot;HelpPrefix&quot;) + href
+ if StarDesktop.CurrentComponent.URL = sPath then
+ msgbox &quot;Cant open currently open help file&quot;
+ else
+ OpenXHPText( sPath )
+ end if
+ Else
+ msgbox &quot;Please select a &lt;embed&gt; or &lt;link&gt; tag.&quot;
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(&quot;com.sun.star.text.Paragraph&quot;) Then
+ If Left(TE.ParaStyleName,4) = &quot;hlp_&quot; AND Not(Left(TE.ParaStyleName,8) = &quot;hlp_aux_&quot;) Then
+ sText = TE.GetString
+
+ If sText &lt;&gt; &quot;&quot; Then
+ TP = TE.createEnumeration
+ Ct = 0
+ posID = 0
+
+ While TP.hasmoreElements
+ Ct = Ct+1
+ TPE = TP.nextElement
+ If TPE.TextPortionType=&quot;TextField&quot; Then
+ If TPE.TextField.TextFieldMaster.Name=&quot;ID&quot; Then
+ TPE.TextField.IsVisible = TRUE
+ End If
+ End If
+ If TPE.String = &quot;&quot; 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(&quot;com.sun.star.text.Paragraph&quot;) Then
+ if instr( lcase(TE.GetString), &quot;id=&quot;&quot;&quot; + section + &quot;&quot;&quot;&quot; ) then
+ oCur = TE.getText.createTextCursorByRange(TE)
+ thiscomponent.getcurrentcontroller.select(oCur)
+ exit sub
+ end if
+ end if
+ Loop
+End Sub
</script:module>