Page 1 of 1

Access document "Referer" property

Posted: Mon Dec 26, 2016 2:10 pm
by Durre
Hello,

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

Sub OpenAddTransDoc_

Globalscope.BasicLibraries.LoadLibrary( "MRILib" )

Dim DocProperties(2) As New com.sun.star.beans.PropertyValue
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)
MRI.InspectObj(ThisDoc)

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

Sub OpenDoc_

Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
MRI.InspectObj(ThisComponent)

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?

Re: Access document "Referer" property

Posted: Tue Mar 28, 2017 7:44 am
by Zizi64
I know it is a very old topic... but is was unanswered one...


Access document "Referer" property

Code: Select all


...

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...