i was testing the last version 1.1.7, and , as the previous versions, was not implemented the numeration of elements. It show it as a simple paragraph.
i change the version of the 'Sub TraverseText', in the Traverse Macro, to permit this option. I show 3 options, because no all devices support lists or blockquotes. The last version, is the most simple, and I think it works for all devices, but fails to nest lists. Still, it's better than nothing.
Sub TraverseText
'From:
http://www.pitonyak.org/AndrewMacro.odt, Listing 7.52: Enumerate paragraph level text content.
Dim oParEnum As object 'Enumerator used to enumerate the paragraphs
Dim oPar As object 'The enumerated paragraph
Dim oContentEnum 'Enum content, such As graphics objects
Dim oContent 'The numerated content
Dim oCurs As object
Dim sParEx As string 'The exported paragraph
Dim n, nPara As integer 'Paragraph counter
Dim MaxLength, CountLength as Long
MaxLength = val(myPrefs.getPropertyValue("SplitFilesEvery"))*1 000 ' Max Length of an xhtml file, used to split files
CountLength = 0
WritingMode = oDoc.StyleFamilies.getByName("PageStyles").getByNa me("Standard").WritingMode
sStartPageCode = "<?xml version=""1.0"" encoding=""utf-8""?>" & chr(13)
sStartPageCode = sStartPageCode & "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN""" & chr(13)
sStartPageCode = sStartPageCode & " ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">" & chr(13)
AddPageBreakBeforeH1
If WritingMode = 2 Then
sStartPageCode = sStartPageCode & "<html xmlns=""http://www.w3.org/1999/xhtml"" xmlns:xml=""http://www.w3.org/XML/1998/namespace"" xml:lang=""ja"">" & Chr(13)
Else
sStartPageCode = sStartPageCode & "<html xmlns=""http://www.w3.org/1999/xhtml"">" & Chr(13)
End If
' sStartPageCode = sStartPageCode & "<html xmlns=""http://www.w3.org/1999/xhtml"">" & chr(13)
sStartPageCode = sStartPageCode & "<head>" & chr(13)
sStartPageCode = sStartPageCode & "<link rel=""stylesheet"" href=""../styles/style001.css"" type=""text/css"" />" & chr(13)
sStartPageCode = sStartPageCode & "<title></title>" & chr(13)
sStartPageCode = sStartPageCode & "</head>" & chr(13)
sStartPageCode = sStartPageCode & "<body>" & chr(13)
sEndPageCode = "</body>" & chr(13)
sEndPageCode = sEndPageCode & "</html>" & chr(13)
iImageCount = 0
oText = oDoc.Text
iSplitNumber = 1 'GLOBAL VARIABLE
bBreak = 0 '0=no break 1= break before 2= break after
bFirstpage = True
Dim oOutputAccess As Object
Dim oOutputStream As Object
Dim vOutputData As Variant
oOutputAccess = CreateUnoService("com.sun.star.ucb.SimpleFileAcces s")
oOutputStream = CreateUnoService("com.sun.star.io.TextOutputStream ")
vOutputData = oOutputAccess.openFileWrite(MyEpub & "/OEBPS/text/content" & Format(iSplitNumber,"0000") & ".xhtml")
oOutputStream.setOutputStream(vOutputData)
oOutputStream.setEncoding("UTF-8")
oOutputStream.writeString( sStartPageCode & Chr(13) )
'---- Show the progress bar
nPara = oDoc.ParagraphCount
oBar.start(progParaMSG, nPara)
n = 0
'---- Get "Standard" style CharHeight (I'll use it to compare "large font" height)
oCurs = oText.CreateTextCursor()
oCurs.GoToEnd(FALSE)
oText.insertControlCharacter(oCurs,com.sun.star.te xt.ControlCharacter.PARAGRAPH_BREAK,FALSE)
oCurs.ParaStyleName = "Standard"
fStandardCharHeight = oCurs.CharHeight
'---- Enumerate the paragraphs.
'---- Tables are enumerated along with paragraphs
'---------------------------------------------------
'codigo propio 2
dim nivelLista as integer
nivelLista=-1
dim sfin as string
sfin = ""
'fin codigopropio 2
'---------------------------------------------------
oParEnum = oDoc.getText().createEnumeration()
Do While oParEnum.hasMoreElements()
oPar = oParEnum.nextElement()
If oPar.supportsService("com.sun.star.text.Paragraph" ) Then '---- This manages the paragraphs
n = n + 1
oBar.setValue(n + 1 / nPara)
oContentEnum = oPar.createContentEnumeration("com.sun.star.text.T extContent")
Do While oContentEnum.hasMoreElements()
oContent = oContentEnum.nextElement()
If oContent.supportsService("com.sun.star.text.TextGr aphicObject") Then
'---- Print "Found a graphic object anchored to a Paragraph"
End If
Loop
'---- Call Paragraph analysis
sParEx = fnExportParagraph(oPar)
'--------------------------bisoft@hotmail.com--------------------------------------------------------------------
' 'codigo propio1 Mete el texto con bloquotes, y eso significa que va achatando la longitud de las lineas. No funciona con energy system 1060
' dim sinicio as string, sfin as string
' dim i as integer
' i=0
' sinicio=""
' sfin = ""
' if oPar.NumberingIsNumber = true then
' if oPar.ListLabelString = "" then
' while i<= oPar.NumberingLevel
' sinicio = sinicio & "<blockquote>"
' sfin = "</blockquote>" & sfin
' i=i+1
' wend
' sParEx = sinicio & "<p>" & "- " & right(sParEx, len(sParEx) - 3) & sfin
' else
' while i<= oPar.NumberingLevel
' sinicio = sinicio & "<blockquote>"
' sfin = "</blockquote>" & sfin
' i=i+1
' wend
' sParEx = sinicio & "<p>" & oPar.ListLabelString & right(sParEx, len(sParEx) - 3) & sfin
' end if
' end if
' ' fin codigo propio1
' codigo propio 2 Usa las listas de html. Funciona ok. Las numeraciones siempre serán numéricas. Se anidan bien. No funcionan en el energy system 1060
' if oPar.NumberingIsNumber = true then
' if oPar.NumberingLevel <> nivelLista then
' if oPar.NumberingLevel < nivelLista then 'retrocedemos un nivel nunha lista previa
' sParEx = left(sfin,len(sfin) - 5) & "<li>" & mid(sParEx, 4, len(sParEx) - 7) & "</li>"
' sfin=right(sfin,len(sfin) - 5)
' else
' if oPar.ListLabelString = "" then 'no ordenada
' sParEx = "<ul> <li>" + mid(sParEx, 4, len(sParEx) - 7) + "</li>"
' sfin = "</ul>" & sfin
' else 'ordenada
' sParEx = "<ol> <li>" + mid(sParEx, 4, len(sParEx) - 7) + "</li>"
' sfin = "</ol>" & sfin
' end if
' end if
' nivelLista = oPar.NumberingLevel
' else
' sParEx = "<li>" & mid(sParEx, 4, len(sParEx) - 7) & "</li>"
' end if
'
' else
' sParEx = sfin + sParEx
' sfin=""
' nivelLista=-1
' end if
' fin codigo propio 2
'codigo propio 3. Simplemente añade el label string para las ordenadas, y un "- " para las otras. Todos quedan a la misma altura, sin anidamientos. Es el único que funciona en energy system.
if oPar.NumberingIsNumber = true then
if oPar.ListLabelString = "" then
sParEx = "<p>" & "- " & right(sParEx, len(sParEx) - 3)
else
sParEx = "<p>" & oPar.ListLabelString & right(sParEx, len(sParEx) - 3)
end if
end if
' fin codigo propio 3
'-------------------------------bisoft@hotmail.com----------------------------------------------------
CountLength = CountLength + Len (sParEx)
If CountLength > MaxLength Then
If bBreak = 0 then bBreak = 1
CountLength = 0
End If
Select Case bBreak
Case 0
oOutputStream.writeString( sParEx & Chr(13) )
Case 1 '---- split file before
oOutputStream.writeString( sEndPageCode & Chr(13) )
oOutputStream.flush()
oOutputStream.closeOutput()
iSplitNumber = iSplitNumber +1
vOutputData = oOutputAccess.openFileWrite(MyEpub & "/OEBPS/text/content" & Format(iSplitNumber,"0000") & ".xhtml")
oOutputStream.setOutputStream(vOutputData)
oOutputStream.setEncoding("UTF-8")
oOutputStream.writeString( sStartPageCode & Chr(13) )
oOutputStream.writeString( sParEx & Chr(13) )
Case 2 '---- split file after
oOutputStream.writeString( sParEx & Chr(13) )
oOutputStream.writeString( sEndPageCode & Chr(13) )
oOutputStream.flush()
oOutputStream.closeOutput()
iSplitNumber = iSplitNumber +1
vOutputData = oOutputAccess.openFileWrite(MyEpub & "/OEBPS/text/content" & Format(iSplitNumber,"0000") & ".xhtml")
oOutputStream.setOutputStream(vOutputData)
oOutputStream.setEncoding("UTF-8")
oOutputStream.writeString( sStartPageCode & Chr(13) )
End Select
'---- Export Paragraph text
End If
If oPar.supportsService("com.sun.star.text.TextTable" ) Then '---- This manages the tables.
oOutputStream.writeString( fnExportTable(oPar) & Chr(13) )
End If
Loop
oOutputStream.writeString( sEndPageCode & Chr(13) )
oOutputStream.flush()
oOutputStream.closeOutput()
End Sub