Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On Fri, 2012-04-06 at 16:00 -0700, avamk wrote:
I am actually quite new to Base, and didn't realise I could use the File
Picker control. When I try to change its reaction to the Mouse Pressed
event, it asked me for a macro.

Do I need to write a macro to get the relative path of my desired image??? I
actually have no macro coding skills to do that...

And how do I tie the selected file's relative path to the field I desire?

Sorry I am so new to this, but I would really appreciate any guidance you
can give me...

Well, I feel stupid - you already asked on ask.libreoffice didn't you..
http://ask.libreoffice.org/question/1715/make-a-form-that-allows-drag-and-drop-of-images-in
... the other day.

OK- well, I haven't added the part to generate the relative path, but
for the basics of syncing the control with a data column I did put
together a little database.

It's only a few lines of basic, but if you only have a starting
knowledge of the basic scripting in the package it likely makes sense to
let you have this first.

To use the odb (embedded HSQL) database you will need to do two things
interactively first.

1 - you must enable macro execution. I really suggest going for the
highest setting, which requires you to designate what directories files
with macros will be allowed to execute from - I more highly suggest you
do not use your default download or document directory.. for myself I
create a sub-directory under my Documents directory for such.
Anyway - to do this open the Otpions dialog (File>Options), select
Security and then Macro Security. The information on the dialog should
be reasonably clear to follow.

2 - you must load the 'Tools' basic library before it can used. When
macros are embedded in and ODB, as they are in this example file this
must be done outside of the file. (don't ask me why, I think its a bug)

Now - there is a nice way to handle that. The example odb file has the
document level event 'Open Oocument' set to call the Main procedure in
the LibreOffice standard basic library. Every install of LibreOffice has
this User specific standard library - by default, empty save a stubbed
out Main procedure.

So - what you need to do is:
Start Libreoffice
Select Tools>Macros>Organize Dialogs
On the dialog select the 'Modules' tab.
You will see in the list of libraries the category:
My Macros
Under this - Standard
If you double click this, a single module - Module 1
Select that and click the Edit button.

Now you have the Basic IDE open.
There is a Main Procedure, with no actual basic commands.

Add this line between the opening
"Sub Main" and "End Sub" Lines
    BasicLibraries.LoadLibrary("Tools")

Save the library and close the IDE you are done with this.

Now - if you have authorized Macro execution at some level you can load
the example file 'linkme.odb', you will find a single table and form.

The form uses a hidden text control and two macros and two events to
transfer the URL selected from the file picker (File Selector) control
into two data columns in the table. One of the macros also uses the link
data column in the table to display the referenced image in an Image
Control on the form. 

For kicks I've preloaded 3 records in the table - the first two will
display a graphic from the internet and the third will display no image,
as it has a file path (URL) to an image on my local disk.

So - you can find the example file here for the moment - 
https://wiki.documentfoundation.org/File:Linkme.odb

After I finish up the PATH massaging will move that over to the ask LibO
site.

Also - I need to do a few things here this Saturday morning, but I'll
get back to it later this afernoon - if you check out the macros you
will likely say HUH - but I'll also explain the constructs when I get
back to this. 

//drew
    


--
View this message in context: 
http://nabble.documentfoundation.org/Make-a-form-that-allows-user-to-drag-and-drop-in-an-image-tp3890657p3891586.html
Sent from the Users mailing list archive at Nabble.com.




-- 
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.