Ask Your Question
2

API: Object to access the Page Pane of a Draw or Impress document?

asked 2018-02-14 14:50:56 +0100

Lupp gravatar image

updated 2018-02-15 12:02:37 +0100

Drawings in 'Draw' or 'Impress' are inserted in pages (aka slides).
The UI supplies a 'Page Pane' (titled "Pages") which allows to pick any selection of pages.
I would like to get access to that selection of pages in macros. How can I get the respective object?

(Editing:)
See also this post of mine in the forum.openoffice.org/en. The thread there gives the background of my question here.

edit retag flag offensive close merge delete

Comments

The pane is the SlideSorter. Maybe XSlideSorterBase.DocumentSlides, although I'm not sure how to access this object.

Jim K gravatar imageJim K ( 2018-02-15 15:42:42 +0100 )edit

@Jim K: Thanks. I did not find a way and therefore abandoned the search. See also my comment to the answer by @librebel.
I did not yet publish the code I wrote motivated by the question starting the above linked thread. It is mainly made to loop through the shapes of a Draw / Impress document, and to resolve groups and/or a selection for the purpose. If somebody is interested, I will post it, of course. (There is also a sorting function for arrays.)

Lupp gravatar imageLupp ( 2018-02-15 22:23:24 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2018-02-15 16:58:27 +0100

librebel gravatar image

Hello @Lupp,

Unfortunately this is not so straightforward as accessing SideBar elements from the Right Sidebar, which can be obtained by CurrentController.getSideBar().

The Pages Pane ( a.k.a. “Slide Sorter” ) is by default located in the Left Sidebar.

But even though it can be dragged over to the Right Sidebar, it is not included in the Decks collection from getSideBar().

( The Decks that are accessible via getSideBar() are apparently limited to: PropertyDeck, ShapesDeck, StyleListDeck, GalleryDeck, NavigatorDeck. )

To access the Slide Sorter from a specific anchor such as the Left Sidebar, the Right Sidebar, or a floating window, i tried using the BasicViewFactory service.

It succeeds in getting the Slide Sorter pane, and it does even have a method getSelection() that returns an array of Objects.

But to my chagrin, this array still contains only 1 selected Slide object, even when multiple Slides are selected by the user in the Slide Sorter pane.

Please see if you can verify this behaviour.

Code fragment:

REM NB. ThisComponent must be a Draw or Impress document.
Dim oController As Object : oController = ThisComponent.getCurrentController()

Dim oBasicViewFactory As Object
oBasicViewFactory = createUNOservice( "com.sun.star.drawing.framework.BasicViewFactory" )
oBasicViewFactory.initialize( Array( oController ) )

Dim vResourceId    As Variant: vResourceId  = com.sun.star.drawing.framework.ResourceId
Dim strResourceURL As String : strResourceURL = "private:resource/view/SlideSorter"
Dim strAnchorURL   As String : strAnchorURL = "private:resource/pane/LeftDrawPane" REM LeftDrawPane; LeftImpressPane.
Dim oResourceID    As Object : oResourceID  = vResourceId.createWithAnchorURL( strResourceURL, strAnchorURL )
Dim oSlideSorter   As Object : oSlideSorter = oBasicViewFactory.createResource( oResourceID )

If Not IsNull( oSlideSorter ) Then
    Dim aSelection() : aSelection = oSlideSorter.getSelection()     REM Ouch: Array contains only 1 item, 
    Dim i As Integer : i = uBound( aSelection )                     REM even when multiple items are selected ...
    Dim oSelectedSlide As Object : oSelectedSlide = aSelection(0)   REM The "only selected" item.
End If

With Regards, lib

edit flag offensive delete link more

Comments

Thanks @librebel . Yes. I found the behaviour you described. Firstly I never had heard of that way to create objects. I hoped to be able to use "createUnoService to get a service. In fact I still cannot understand for what reosen there is not (accessible) a dedicated controller for the Page Pane.
I think I will abandon this special kick concerning the code I wrote for walking recursively through DrawingDocuments or selections made there.

Lupp gravatar imageLupp ( 2018-02-15 22:14:42 +0100 )edit

Thanks for the confirmation @Lupp,

i agree that the API could be improved here ... perhaps a parameter to getSideBar(), specifying which SideBar to get ( Left or Right ) ?

librebel gravatar imagelibrebel ( 2018-02-15 22:21:13 +0100 )edit

about the ResourceID object ... it could also be created by createUNOservice() and then initialized by .initialize( URLarray ), but this way is shorter :)

librebel gravatar imagelibrebel ( 2018-02-15 22:26:40 +0100 )edit

Btw @Lupp, i believe that the above does answer your question correctly, in sofar that it does provide an object to access the Page Pane of a Draw or Impress document.

So ... please mark the answer as correct by clicking on the checkmark icon on the left :)

librebel gravatar imagelibrebel ( 2018-02-17 18:26:11 +0100 )edit

Ok. I expressed myself not very precisely. Assuming there was only one such pane and it would give access to the selection of pages, I worded the question as I did. In fact I should have asked for access to the selection of pages. The newly created 'SlideSorter' doesn't heplp with my original intentions.

Lupp gravatar imageLupp ( 2018-02-17 20:00:42 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-02-14 14:50:56 +0100

Seen: 53 times

Last updated: Feb 15