How to alphabetize slides?
Posted: Fri Apr 20, 2018 9:47 pm
Hello, is it possible to alphabetize slides, I use them for a lyric monitor. THX!
User community support forum for Apache OpenOffice, LibreOffice and all the OpenOffice.org derivatives
https://forum.openoffice.org/en/forum/
What you want to do really? Please give us some more details.is it possible to alphabetize slides, I use them for a lyric monitor.
Maybe you can operate with some macros, but - I think - it is not an Impress related task.Hi Zizi,
thank you for responding, yes, I would like to sort each individual slide. Each slide contains lyrics to one song and the title is at the top of the page. Is there a way to alphabetize each single slide?
I can see only one object on each sheet. There is not separated Title object and Text object on the slides. And the those different structures in the Titles...:I would like to sort each individual slide. Each slide contains lyrics to one song and the title is at the top of the page. Is there a way to alphabetize each single slide?
Code: Select all
REM ***** BASIC *****
Option explicit
Sub List_Titles
Dim oDoc As Object
Dim oSlides As object
Dim oSlide as object
Dim oShape as Object
Dim oShapeStyle
Dim iSlideCount as Integer
Dim iSlideNumber as integer
Dim iShapeCount
Dim iShapeNumber
Dim sTitleList as string
'loadxray
oDoc = ThisComponent
'xray oDoc
oSlides = oDoc.getDrawPages
iSlideCount = oSlides.count
for iSlideNumber = 0 to iSlideCount-1
oSlide = oSlides.getbyindex(iSlideNumber)
'xray oSlide
For iShapeNumber = 0 to iShapeCount-1
oShape = oSlide.getByIndex(iShapeNumber)
'Xray oShape
oShapeStyle = oShape.Style
'print oShapeStyle.name
If oShapeStyle.name = "title" then
sTitleList = sTitleList + oShape.String + Chr(13)
'print oShape.String
end if
next iShapeNumber
next iSlideNumber
MsgBox(sTitleList, 0, "List of the Titles:")
End Sub
Code: Select all
REM ***** BASIC *****
Option explicit
Sub Create_Sorted_SlideShow
Dim oDoc as object
Dim oDrawPages as object
Dim oCustPresentations as object
Dim oMyCustPres as object
Dim oPresentation as object
Dim oNewPresentation as object
Dim oActualSlide as object
Dim iSlideCount as integer
Dim iCount as integer
Dim i as integer
'loadxray
oDoc = ThisComponent
oDrawPages = oDoc.getDrawPages
iSlideCount = oDrawPages.Count
Dim vTitleList(iSlideCount-1) as String
Dim vSortedTitleIndex(iSlideCount-1) as Integer
For i = 0 to iSlideCount-1
vSortedTitleIndex(i) = i
next i
vTitleList = Get_Slide_Titles(oDoc)
SortStringArray(vTitleList, vSortedTitleIndex)
oCustPresentations = oDoc.getCustomPresentations()
If oCustPresentations.hasByname("SortedSlides") Then
oMyCustPres = oCustPresentations.getByName("SortedSlides")
iCount = oMyCustPres.Count
If iCount > 0 then
For i = 0 to iCount-1
oMyCustPres.removeByIndex(0)
next i
End if
Else
oNewPresentation = oCustPresentations.createInstance() '"com.sun.star.presentation.CustomPresentation")
oCustPresentations.insertByName("SortedSlides", oNewPresentation)
oMyCustPres = oCustPresentations.getByName("SortedSlides")
end if
iCount = oMyCustPres.Count
If iCount > 0 then
For i = 0 to iCount -1
oMyCustPres.removeByIndex(0)
next i
end if
For i = 0 to iSlideCount-1
oActualSlide = oDrawPages.getByIndex(vSortedTitleIndex(i))
oMyCustPres.insertByIndex(i, oActualSlide)
next i
oPresentation = oDoc.Presentation
oPresentation.CustomShow = "SortedSlides"
oPresentation.Start()
end sub
'________________________________________________________________
Function Get_Slide_Titles(Optional oPassedDoc as object) as Variant
Dim oDoc As Object
Dim oSlides As object
Dim oSlide as object
Dim oShape as Object
Dim oShapeStyle
Dim iSlideCount as Integer
Dim iSlideNumber as integer
Dim iShapeCount
Dim iShapeNumber
If isMissing(oPassedDoc) then
oDoc = ThisComponent
else
oDoc = oPassedDoc
end if
oSlides = oDoc.getDrawPages
iSlideCount = oSlides.count
Dim TheResultArray(iSlideCount-1) as String
for iSlideNumber = 0 to iSlideCount-1
oSlide = oSlides.getbyindex(iSlideNumber)
for iShapeNumber = 0 to iShapeCount-1
oShape = oSlide.getByIndex(iShapeNumber)
oShapeStyle = oShape.Style
If oShapeStyle.name = "title" then
TheResultArray(iSlideNumber) = oShape.String
end if
next iShapeNumber
next iSlideNumber
Get_Slide_Titles = TheResultArray
End function
'________________________________________________________________
sub SortStringArray(myArray as variant, myIntArray as variant)
dim h as integer
dim i as integer
dim j as integer
dim t as string
dim iUb as integer
dim iLb as integer
iLb = lBound(myArray)
iUb = uBound(myArray)
for i = iUb to iLb step -1
for j = 0 to i - 1 step 1
if strComp(myArray(i), myArray(j), 0) < 1 then
t = myArray(i)
h = myIntArray(i)
myArray(i) = myArray(j)
myIntArray(i) = myIntArray(j)
myArray(j) = t
myIntArray(j) = h
end if
next j
next i
end sub
'________________________________________________________________