office-gobmx/wizards/source/gimmicks/AutoText.xba
Oliver Bolte 20cea29aa2 CWS-TOOLING: integrate CWS fwk99
2009-01-20 17:39:31 +0100 pb  r266605 : fix: #i98280# new 'More templates'-URL
2009-01-15 20:17:58 +0100 mst  r266391 : #i95702# convert wizards to DocumentProperties (partially based on patch by cmc)
2009-01-12 07:35:44 +0100 pb  r266131 : fix: #i96851# HID_PASTE_DLG and HID_LINKDLG_TABLB added
2009-01-09 10:40:48 +0100 pb  r266061 : fix: #i97386# Execute_Impl() while sub-dialog is open this could be deleted; #i68415# patch from cmc
2009-01-09 10:35:24 +0100 pb  r266059 : fix: #i97386# struct Deleted added
2009-01-09 10:05:17 +0100 pb  r266057 : fix: #i97365# ModalDialog RID_SVXPAGE_IMPROVEMENT removed
2009-01-09 10:02:39 +0100 pb  r266056 : fix: #i97841# new: set InfoURL and HandleHyperLink()
2009-01-09 09:59:13 +0100 pb  r266053 : fix: #i97391# MinWidth re-calculated; #i97365# SvxImprovementDialog2 removed
2009-01-09 09:55:00 +0100 pb  r266051 : fix: #i97841# new: HandleHyperLink(); #i97365# SvxImprovementDialog2 removed
2009-01-06 14:24:24 +0100 cd  r265921 : #i96831# Fix build problem with gcc 4.3.2 using the return value of link correctly.
2009-01-06 12:18:41 +0100 cd  r265907 : #i96831# Fix build problem with gcc 4.3.2
2009-01-06 12:02:59 +0100 mst  r265905 : fix #i97775#
- xmloff/source/core/nmspmap.cxx:
  + SvXMLNamespaceMap::GetQNameByKey does not handle default namespace
    correctly
2009-02-12 14:03:59 +00:00

97 lines
4 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="AutoText" script:language="StarBasic">&apos; BASIC
Option Explicit
Dim oDocument as Object
Dim sDocumentTitle as String
Sub Main()
Dim oTable as Object
Dim oRows as Object
Dim oDocuText as Object
Dim oAutoTextCursor as Object
Dim oAutoTextContainer as Object
Dim oAutogroup as Object
Dim oAutoText as Object
Dim oCharStyles as Object
Dim oContentStyle as Object
Dim oHeaderStyle as Object
Dim oGroupTitleStyle as Object
Dim n, m, iAutoCount as Integer
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
sDocumentTitle = &quot;Installed AutoTexts&quot;
&apos; Open a new empty document
oDocument = CreateNewDocument(&quot;swriter&quot;)
If Not IsNull(oDocument) Then
oDocument.DocumentProperties.Title = sDocumentTitle
oDocuText = oDocument.Text
&apos; Create The Character-templates
oCharStyles = oDocument.StyleFamilies.GetByName(&quot;CharacterStyles&quot;)
&apos; The Characterstyle for the Header that describes the Title of Autotextgroups
oGroupTitleStyle = oDocument.createInstance(&quot;com.sun.star.style.CharacterStyle&quot;)
oCharStyles.InsertbyName(&quot;AutoTextGroupTitle&quot;, oGroupTitleStyle)
oGroupTitleStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD
oGroupTitleStyle.CharHeight = 14
&apos; The Characterstyle for the Header that describes the Title of Autotextgroups
oHeaderStyle = oDocument.createInstance(&quot;com.sun.star.style.CharacterStyle&quot;)
oCharStyles.InsertbyName(&quot;AutoTextHeading&quot;, oHeaderStyle)
oHeaderStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD
&apos; &quot;Ordinary&quot; Table Content
oContentStyle = oDocument.createInstance(&quot;com.sun.star.style.CharacterStyle&quot;)
oCharStyles.InsertbyName(&quot;TableContent&quot;, oContentStyle)
oAutoTextContainer = CreateUnoService(&quot;com.sun.star.text.AutoTextContainer&quot;)
oAutoTextCursor = oDocuText.CreateTextCursor()
oAutoTextCursor.CharStyleName = &quot;AutoTextGroupTitle&quot;
&apos; Link the Title with the following table
oAutoTextCursor.ParaKeepTogether = True
For n = 0 To oAutoTextContainer.Count - 1
oAutoGroup = oAutoTextContainer.GetByIndex(n)
oAutoTextCursor.SetString(oAutoGroup.Title)
oAutoTextCursor.CollapseToEnd()
oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oTable = oDocument.CreateInstance(&quot;com.sun.star.text.TextTable&quot;)
&apos; Divide the table if necessary
oTable.Split = True
&apos; oTable.KeepTogether = False
oTable.RepeatHeadLine = True
oAutoTextCursor.Text.InsertTextContent(oAutoTextCursor,oTable,False)
InsertStringToCell(&quot;AutoText Name&quot;,oTable.GetCellbyPosition(0,0), &quot;AutoTextHeading&quot;)
InsertStringToCell(&quot;AutoText Shortcut&quot;,oTable.GetCellbyPosition(1,0), &quot;AutoTextHeading&quot;)
&apos; Insert one row at the bottom of the table
oRows = oTable.Rows
iAutoCount = oAutoGroup.Count
For m = 0 To iAutoCount-1
&apos; Insert the name and the title of all Autotexts
oAutoText = oAutoGroup.GetByIndex(m)
InsertStringToCell(oAutoGroup.Titles(m), oTable.GetCellbyPosition(0, m + 1), &quot;TableContent&quot;)
InsertStringToCell(oAutoGroup.ElementNames(m), oTable.GetCellbyPosition(1, m + 1), &quot;TableContent&quot;)
If m &lt; iAutoCount-1 Then
oRows.InsertbyIndex(m + 2,1)
End If
Next m
oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oAutoTextCursor.CollapseToEnd()
Next n
End If
End Sub
Sub InsertStringToCell(sCellString as String, oCell as Object, sCellStyle as String)
Dim oCellCursor as Object
oCellCursor = oCell.CreateTextCursor()
oCellCursor.CharStyleName = sCellStyle
oCell.Text.insertString(oCellCursor,sCellString,False)
oDocument.CurrentController.Select(oCellCursor)
End Sub</script:module>