Access document "Referer" property

Creating a macro - Writing a Script - Using the API

Access document "Referer" property

Postby Durre » Mon Dec 26, 2016 2:10 pm


I have the below 'dummy' sub assigned to a button on a switchboard document for my database. When clicked, it opens a document called "AddTransaction.odt", which contains some forms.

Code: Select all   Expand viewCollapse view
Sub OpenAddTransDoc_

Globalscope.BasicLibraries.LoadLibrary( "MRILib" )

Dim DocProperties(2) As New
DocProperties(0).Name = "ReadOnly"
DocProperties(0).Value = True
DocProperties(1).Name = "Referer"
DocProperties(1).Value = ThisComponent.URL
DocProperties(2).Name = "MacroExecutionMode"
DocProperties(2).Value = 4

Dim DocURL As String
DocURL = ConvertToURL("F:\Mattias Durnez\Documents HDD\Business\Finances_database\frontend\forms\AddTransaction.odt")

ThisDoc = StarDesktop.loadComponentFromURL(DocURL,"_default",0,DocProperties)

End Sub

The "AddTransaction.odt" document itself runs a macro called OpenDoc_ assigned to the "Open Document" event. Right now this macro does nothing but use MRI to inspect the document properties itself:

Code: Select all   Expand viewCollapse view
Sub OpenDoc_

Globalscope.BasicLibraries.LoadLibrary( "MRILib" )

End Sub

What I would like to do in the OpenDoc_ macro is to access the "Referer" property that I set when loading the "AddTransaction.odt" document. This way I can discriminate between the "AddTransaction.odt" document being opened from the switchoard or somewhere else.

I've used MRI to inspect the document's properties and can find the MacroExecutionMode and ReadOnly property through getArgs(). But nowhere can I seem to find the "Referer" property, even after manually stepping through all properties/methods in MRI. Usually I find my answer on this forum as a guest if such a thing happens, but this time my search came up empty. Would anyone be able to point me in the right direction? If not, are there other/better ways to find out if a document is being opened from a certain source?
LibreOffice | Windows 10
Posts: 4
Joined: Mon Dec 26, 2016 1:47 pm

Re: Access document "Referer" property

Postby Zizi64 » Tue Mar 28, 2017 7:44 am

I know it is a very old topic... but is was unanswered one...

Access document "Referer" property

Code: Select all   Expand viewCollapse view


oDocumentProperties = ThisComponent.getDocumentProperties()
oUserDefinedProperties = oDocumentProperties.getUserDefinedProperties()
oPropertyValues = oUserDefinedProperties.getPropertyValues()

   For i = 0 to uBound(oPropertyValues) step 1
      If oPropertyValues(i).Name = "Referer" then ...


It works in my Libreoffice 4.4.7 . but maybe the API of the AOO and LO are different...
Tibor Kovacs, Hungary; LibreOffice4.4.7 - Portable versions: LO3.3.0-LO5.3.2 and AOO4.1.3; on Win7x64Prof.
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Posts: 5011
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests