sexta-feira, 28 de maio de 2010

connecting to openoffice.org base from a form via macro [GkSpk]

connecting to openoffice.org base from a form via macro [GkSpk]

Base is the database package that comes with openoffice.org 2.x. It seems quite OK as a desktop database package. But, I’ve found that resources for macro editing in basic for base are quite scarce. This is quite a problem since the editor it comes with doesn’t have intellisense/autocomplete. The uno documentation is way too big to be of any real use as a reference document. So I thought I’ll just write a beginners tutorial for connecting to the base database that is currently open from a form using openoffice.org basic macro.
The syntax itself is quite similar to VBA, so it should appear familiar to excel and access macro coders.

Example Scenario

In the example below, we will simply get a reference to our database, execute a simple select query, and retrieve the results.

For this example, we need a database table called MY_TABLE which will need an integer column and a varchar column in that order. We also need a form with a button to invoke the method we will write.

The macro code

We will create a macro to handle the button click from the form above. It will contain a function which requires an event object as its parameter as shown below:

Sub DoSomething(evt as Object)
// code goes here
End Sub

To run our queries we need a reference to our current database. This can be obtained from the form object, which can be obtained through the event parameter passed to our function.

Dim frm As object
frm = evt.Source.Model.Parent

This form object will also come in handy, if you have text boxes etc. you wish to populate with your sql results.

Now that we have a function which gets our form object, we can get on with a few examples.

Making a sql query:

First we create an object to store the results.

dim rows
rows = createUnoService("com.sun.star.sdb.RowSet")

We then get the connection for the database:

rows.ActiveConnection = frm.ActiveConnection

and, set the command type, create a sql statement, and execute it:

rows.CommandType = com.sun.star.sdb.CommandType.COMMAND
rows.Command = "select * from MY_TABLE"
rows.execute()

This puts all the rows from MY_TABLE into our rows object, and we can go through them using the following:

dim col1, col2

while rows.next()
col1 = rows.getInt(1)
col2 = rows.getString(2)
wend

The while loop goes through the records, which you can use to get your data.

This has been a basic intro into running custom queries from a form. Hopefully this will help you get started with your macros.

Posted in Programming

Assigning Macros to OpenOffice Events: How to Assign an OpenOffice.org Basic Macro to an Event

Assigning Macros to OpenOffice Events: How to Assign an OpenOffice.org Basic Macro to an Event


Adding an OpenOffice.org macro is a very useful way of extending the functionality of a Calc spreadsheet or a Writer document. For example, a user may wish to time stamp a spreadsheet every time that it's opened - a task that can easily be achieved by adding a macro which the user manually runs whenever they open the spreadsheet. Of course, there are some drawbacks to this:

  • the user must remember to run the macro
  • the user must know how to run the macro
  • the user must want to run the macro.

A much better solution for everyone is to get OpenOffice to do all of the hard work itself - and for that macros can be assigned to events.

OpenOffice.org's Built-in Events

OpenOffice has a number of built-in events that can be used to trigger any macro; these events are:

  • activate document
  • close application
  • close document
  • create document
  • deactivate document
  • document has been save as
  • document has been saved
  • document is closing
  • 'Modified' status was changed
  • open document
  • print document
  • save document
  • save document as
  • start application

So if, for example, the user wants the macro to run whenever they open the document then the trigger event should be 'open document'.

Having decided which is to be the trigger event then next step is to create a macro for that event.

Number format no mysql - Fórum do Clube do Hardware

Number format no mysql - Fórum do Clube do Hardware
Pode usar assim:

REPLACE( REPLACE( REPLACE( FORMAT( value, 2), '.', '|'), ',', '.'), '|', ',')

Alguem sabe uma forma mais direta?
Vitor.anacleto está offline Responder com Quote

terça-feira, 25 de maio de 2010

HOWTO: Install FreeNX - Ubuntu Forums

What is FreeNX

FreeNX is a system that allows you to access your desktop from another machine over the Internet. You can use this to login graphically to your desktop from a remote location. One example of its use would be to have a FreeNX server set up on your home computer, and graphically logging in to the home computer from your work computer, using a FreeNX client.

It's Open Source, secure (SSH based), fast and versatile!

Note: Running FreeNX as server on Ubuntu with the free "NX Client for Windows" from NoMachine on a Windows workstation is working fine.

Terminology

The Server is the computer you want to connect to. This is the computer where the FreeNX server will need to be installed. The name of the Ubuntu package providing the server is "freenx". For the example used here, the home computer is the server.

The Client is the computer from which you want to be able to access the Server. The name of the Ubuntu package providing the client is "nxclient". For the example used here, the work computer is the client.

Installation

Before installing FreeNX server make sure you have SSH set up and is working. You can find the SSH Howto here: https://help.ubuntu.com/community/SSHHowto

We will be installing the FreeNX server on the Server machine, i.e., the machine that you want to access remotely. In the stated example, this is your computer that is at home.

FreeNX is not included in Ubuntu, so we'll add it from the FreeNX Team PPA.

For the paranoid: there is an added security risk involved in using the default keys. If you keep the default keys then everybody will be able to connect to your SSH server as the NX user which is added to your system during the installation. This opens an additional (and unnecessary) opportunity to attack your computer. You could avoid it by using custom SSH keys, as explained later.

Installing the FreeNX server on Ubuntu Lucid (10.04)

Ubuntu Lucid now uses Neatx, the Open Source NX server from Google.

Installation is simple enough, and similar to the Ubuntu Karmic method.

  1. Open your terminal

    Applications->Accessories->Terminal

    and type in this command

    sudo add-apt-repository ppa:freenx-team
  2. Then Update Apt

    sudo apt-get update
  3. At this point, the repository is added and apt is updated, then install the neatx-server package (using Aptitude to install extra needed packages).

    sudo apt-get install neatx-server

Installing the FreeNX server on Ubuntu Karmic (9.10)

Karmic introduces the add-apt-repository command that simplifies most of the work of adding a third party repository.

  1. Open your terminal

    Applications->Accessories->Terminal

    and type in this command

    sudo add-apt-repository ppa:freenx-team
    • NOTE: If you do not have add-apt-repository installed add the following

        sudo apt-get install python-software-properties
  2. Then Update Apt

    sudo apt-get update
  3. At this point, the repository is added and apt is updated, then install the freenx package (using Aptitude to install extra needed packages).

    sudo aptitude install freenx
  4. Now use nxsetup to install necessary files and create the special user "nx"

    sudo /usr/lib/nx/nxsetup --install 

Installing the FreeNX server on older Ubuntu Versions

This Instructions are for older Ubuntu versions. FreeNX is not included in Ubuntu, so we'll add it from the FreeNX Team PPA.

Add this repository using the Third-Party Sources Tab in Software Sources. When it asks, Reload the information about available software. Now you can see and install the freenx package in Synaptic Package Manager.

You must edit the configuration files and install by hand:

  1. Open your apt sources list

    gksudo gedit /etc/apt/sources.list

    and append the two lines for the repository

    deb http://ppa.launchpad.net/freenx-team/ppa/ubuntu VERSION main
    deb-src http://ppa.launchpad.net/freenx-team/ppa/ubuntu VERSION main

    where VERSION can be: dapper, hardy, intrepid or jaunty. More information can be found at FreeNX Team PPA.

  2. Save and then close.

    To add the public key of FreeNX PPA run:

    sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2a8e3034d018a4ce
  3. Then Update Apt

    sudo apt-get update
  4. After you add the repository, then install the freenx package (using Aptitude to install extra needed packages).

    sudo aptitude install freenx
  5. Now use nxsetup to install necessary files and create the special user "nx"

    sudo /usr/lib/nx/nxsetup --install 

Installing the NX Client

The official NX client is not in the Ubuntu repositories.

You should be able to access your Ubuntu box from any Windows or Linux box using the free client from NoMachine's website. You can also embed your NX Server in a webpage by installing the Nomachine Web Companion and the Apache webserver.

Now you can execute the installed client using the following command:

/usr/NX/bin/nxclient &

Or by looking it up in the menu

This will start the NX client in a GUI, and step you through getting connected to the FreeNX server, and you will be on your way! [Note: If you are behind a firewall you may need to enable SSL encryption under the Advanced configuration tab - JeremySchroeder]

Installing QTNX (Opensource client)

sudo apt-get install qtnx

Miscellany

NX Server Free Edition

NX Server Free Edition provided by NoMachine is not related to FreeNX. NXSFE has a limit of 2 sessions per server. FreeNX doesn't have this limit.

FreeNX on PowerPC

There are no precompiled binaries of FreeNX on this platform (Launchpad PPA doesn't provide support), so FreeNX have to be compiled from source. Sources can be found at the FreeNX Team PPA.

These steps will build FreeNX from source (you need to add the deb-src repository):

  1. Create a directory to hold the FreeNX source, and cd into it.

    mkdir freenxSource; cd freenxSource
  2. Build the freenx packages and install related packages.

    sudo apt-get build-dep nx freenx
    apt-get -b source nx freenx
    This will download the source tarballs and build the freenx packages (*.deb) in the current directory.
  3. Install the FreeNX packages.

    sudo dpkg -i *.deb
  4. If dpkg complains about missing packages, let apt fix it

    sudo apt-get -f install
    sudo dpkg -i *.deb

How to start/stop FreeNX

The FreeNX server is not a service but uses ssh. The following command will stop the FreeNX program from accepting connections.

sudo /etc/init.d/freenx-server stop

(Replace stop by start for starting it again)

Configuring SSH port

By default, nxserver uses port 22 for communicating over SSH. On some machines or networks, port 22 may be blocked; some Internet providers block port 22, for instance. Port 22 is also a common target of people trying to crack into a network. To make the SSH server listen on port 8888, you can do the following:

Edit the file /etc/ssh/sshd_config

gksudo gedit /etc/ssh/sshd_config

Find

Port 22

and change it to

Port 8888

You then need to restart SSHD. Try

/etc/init.d/ssh restart

FreeNX should detect the SSHD port, but otherwise: Edit the file /etc/nxserver/node.conf

gksudo gedit /etc/nxserver/node.conf

Find

# The port number where local 'sshd' is listening.
#SSHD_PORT=22

and change it to:

# The port number where local 'sshd' is listening.
SSHD_PORT=8888

That is, change the port number to the one that sshd is listening to, and uncomment the line.

Using custom SSH keys

After installation, FreeNX will use a set of default ssh keys for authentication. This is a security risk, especially on any internet-facing machines, and the default keys should be replaced with your own custom keys.

To change the default keys to your own custom keys - on the machine hosting the freenx-server, run the command:

sudo dpkg-reconfigure freenx-server

This will launch a dialogue that will guide you through the generation of custom keys. On the first page hit 'OK' and on the second page select 'Create new custom keys'

a key file called client.id_dsa.key will be created in: /var/lib/nxserver/home/custom_keys/

Now, we need to transfer the key to the client machine so that it can be imported in the FreeNX client application. First copy the key to your home directory on the server machine:

sudo cp /var/lib/nxserver/home/custom_keys/client.id_dsa.key ~/

Next, copy client.id_dsa.key to your client machine. Ideally you should copy the file securely, for example by running the following command from the client computer:

scp user@freenx-server:~/client.id_dsa.key ~/

which will securely copy the client.id_dsa.key file from the freenx-server computer to your home directory on the client.

If your client is a Windows machine, just copy the key with your preferred method.

In the nx client software you can now import this key.

After you have tested that authentication is working using your custom keys you should then remove the client.id_dsa.key file from your home directories on both the server and client machines.

Troubleshooting

  • Problem: Everything is installed as described above, but I still get errors at installing nxsetup --install

  • Solution: Check that this line exists in /etc/ssh/sshd_config "AllowUsers nx" and this line also exists and is set to authorized_keys2 "AuthorizedKeysFile %h/.ssh/authorized_keys2", if commented, just uncomment them. after that run this command in a terminal sudo /etc/init.d/ssh restart .This issue is due custom SSH server configuration.

  • Problem: At the client, the !M logo window appears, but after a few seconds that window just closes, even without showing any error message.

  • Solution: In the server, access your home directory and run this command, sudo rm .Xauthority* followed by touch .Xauthority and finally chmod 600 .Xauthority . This issue is due custom VNC configuration.

  • Problem: What can I do if I get the error 'Could not yet establish the connection to the remote proxy' ?

  • Solution: This commonly happens when the Advanced tab configuration option "Disable encryption of all traffic" has been selected, but the appropriate firewall ports have not been opened. Open the necessary firewall ports, or uncheck the option to re-enable encryption over SSH. NoMachine knowledge base article

  • Problem: NX Client connects and displays the desktop but the screen does not refresh.

  • Solution: Set Disable Direct Draw for screen rendering in the client's advanced configuration tab.

References

You can also have a look at the article about installing the NX packages provided by NoMachine company

Desktop integration wanted

For those who want to have freenx supported in krfb, krdc, log into bugs.kde.org, and add a comment and vote for the following bugs (wishlist) :

  • 187310 : nxserver support in krfb

  • 149482 :nx support in krdc (client), it seems that work is already in progress, and there only a few problems left.

The same should be done on gnome side, for vino and vinagre.

NXLaunch is another solution and could possibly be integrated in other Remote Desktop clients.

HOWTO: Install FreeNX - Ubuntu Forums

HOWTO: Install FreeNX - Ubuntu Forums

HOWTO: Install FreeNX

HOWTO: Install FreeNX on (K)Ubuntu Breezy

This is my experience in installing the FreeNX server and the NoMachine NX Client on my Kubuntu Breezy.
I had some troubles in getting the whole thing work, so I write this little howto hoping that it may be useful for other (K)Ubuntu users


0. CONFIGURING THE RIGHT PACKAGE REPOSITORY


I used .deb packages from Seveas repository. In order to configure it for apt-get (or Synaptic) add the following line to /etc/apt/sources.list:

Code:
deb http://seveas.ubuntulinux.nl/ breezy-seveas all
In order to install the appropriate gpg key, execute the following commands (as described on the Seveas home page):

Code:
gpg --keyserver subkeys.pgp.net --recv-keys 1135D466
gpg --export --armor 1135D466 | sudo apt-key add -


1. INSTALLING THE SERVER


Having Seveas repository configured, it is easy to install the server part of FreeNX. Simply install the freenx package:

Code:
sudo apt-get install freenx
It will also install some dependencies, notably ssh, nxagent and nxlibs. Your (K)Ubuntu will ask you if you want to use the standard NoMachine key, among some other options. I recommend to use the standard NoMachine key for standard use (or for the initial debug of the NX protocol). We will see later how to setup a custom key for higher security.
Please note that the key is used for public key authentication on the user "nx", who is used by the NX protocol to establish an SSH tunnel for the secure protocol data transport. Session authentication is (by default setup) based on PAM, allowing server users to establish a remote NX session by mean of their own credentials (username and password, as defined on the server).

It is now necessary to check some settings of the ssh subsystem, by editing the /etc/ssh/sshd_config file:

1) sshd should listen on the standard 22 port. Please check that the sshd_config contains the line "Port 22" and that it is not commented out.
2) public key authentication is turned on. Check the sshd_config so it contains the line "PubkeyAuthentication yes"
3) modify the "AuthorizedKeysFile" line in "AuthorizedKeysFile %h/.ssh/authorized_keys2" (default is "%h/.ssh/authorized_keys")
4) By default, sshd should allow every system user to access the system. If your system is configured differently, please add (or modify) the "AllowUsers nx" line to allow the nx user to access. I think you can use the "user@host" syntax for this sshd parameter to limit hosts from which users can logon via NX.

If you have made any change to the sshd_config, restart the ssh daemon with
Code:
sudo /etc/init.d/ssh restart

2. INSTALLING THE CLIENT

On the client machine, from the Seveas repository, install the nxclient package.
In my KDE, I found the "NX Client for Linux" in the "Lost+found" submenu. Launching the client for the first time brings up a connection wizard that will allow you to setup a connection to a remote NX server (in this case, the one configured above). Insert the session name (just an identifier of the server/service/host you will connect to), the server IP address and pay attention to check the "Enable SSL encryption of all traffic" option. You may set other options in the connection wizard, for example the type of remote window manager to fire up when the nx user connects (KDE, GNOME, others) and the resolution of the virtual NX session.
Please note that the connection created by the wizard make use of the standard NoMachine key. We will see later how to change the connection key to a custom one.
At the end of the wizard, the NX client logon form fires up. You can insert the username, the password and choose one of the defined sessions.
The login button will attempt the NX connection to the server as defined in the selected session. If you press the "Configure..." button, you can change ALL the parameters of the selected session (the ones defined with the connection wizard and other...).



3. (Optional) DEFINING AND USING CUSTOM KEYS

If you chose "Custom keys" when prompted during the server package, the installation creates a random authentication key for the user "nx". If you chose the standard NoMachine key, you can reconfigure the freenx package to change this setting to "Custom keys" with the following command:

Code:
sudo dpkg-reconfigure freenx
The key is stored in the client.id_dsa.key file in the .ssh subdirectory of the nx home directory (default: /var/lib/nxserver/home/.ssh/client.id_dsa.key). You have to share this key with all the client hosts you want to authorize, by copying this file on the client machine and then importing it into the NX client. The destination path is not important, but you must know it to import the key file into the NX client.
To import the key, open the NX client, select the right session and click on the "Configure" button. From the "General" tab of the configuration window, click on the "Key" button and then on the "Import" button. Then select the client.id_dsa.key you copied from the server and click on the "Save" button, "OK" button (please confirm to save the new configuration)
From now on the NX connection to the server will use the new key. Clients with the default key (or other custom keys) cannot authenticate to the server anymore.

You can return to the standard NoMachine key by reconfiguring the freenx package on the server, and by modifying the key used by the client with the same procedure described above, but clicking on the "Default" button instead of the "Import" button we used before.

If you played with NX keys and your client doesn't authenticate anymore to the server, you can start from a clean state by reconfiguring the freenx package on the server and choosing the "Remove freenx keys" and reconfiguring again choosing the "NoMachine keys" or the "Custom keys" options.


Conclusions

I apologize for my english, far from being good. However I hope that this howto can help some user that (like me) has encountered troubles in configuring this powerful remote control protocol.

As a last note, if you has other troubles and you have set up a firewall, please check firewall settings keeping in mind that only the port 22 (ssh) have to be enabled in order to establish a connection to the server.

Bye

Macros in Database Documents - OpenOffice.org Wiki

Macros in Database Documents - OpenOffice.org Wiki
http://wiki.services.openoffice.org/wiki/Database
http://sheepdogguides.com/fdb/opof6oppeventsintro.htm
http://sheepdogguides.com/fdb/opof6button.htm
http://sheepdogguides.com/fdb/opof6button.htm#gotoDocument
http://sheepdogguides.com/fdb/fdb6exportcsv.htm
http://wiki.services.openoffice.org/wiki/Macros_in_Database_Documents
http://wiki.services.openoffice.org/wiki/Common_tasks
http://wiki.services.openoffice.org/wiki/Database#Examples
http://codesnippets.services.openoffice.org/Database/Database.CopyRecordToNew.snip
http://sheepdogguides.com/fdb/fdb7peopproj.htm
http://user.services.openoffice.org/en/forum/viewtopic.php?f=13&t=2665
http://www.gkspk.com/view/programming/connecting-to-openofficeorg-base-form-macro/
http://office-software.suite101.com/article.cfm/openoffice_automating_macros

segunda-feira, 10 de maio de 2010

Upgrade Alsa (1.0.23) on Ubuntu Lucid Lynx 10.04 | To a free world

Upgrade Alsa (1.0.23) on Ubuntu Lucid Lynx 10.04 | To a free world

Upgrade Alsa (1.0.23) on Ubuntu Lucid Lynx 10.04

May 2nd, 2010 by alpho2k | Print Upgrade Alsa (1.0.23) on Ubuntu Lucid Lynx 10.04
alsa Ubuntu Lucid Lynx 10.04 is coming by default with the version 1.0.21 of Alsa so I decided to upgrade to the last version wich is 1.0.23.

What is Alsa (Advanced Linux Sound Architecture) ?

According to Wikipedia, Alsa is a Linux kernel component intended to replace the original Open Sound System (OSS) for providing device drivers for sound cards. Some of the goals of the ALSA project at its inception were automatic configuration of sound-card hardware, and graceful handling of multiple sound devices in a system, goals which it has largely met.

Installation :

To do this, we must begin by determining our version of alsa as follows :

cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.21.

To avoid problems during the upgrade of Alsa-utils, we need to stop it with the following command :

sudo /etc/init.d/alsa-utils stop

We must then install the necessary tools to compile along with the kernel headers :

sudo apt-get -y install build-essential ncurses-dev gettext xmlto libasound2-dev
sudo apt-get -y install linux-headers-`uname -r` libncursesw5-dev

Then, we go in our personal folder and download alsa-driver, alsa-lib and alsa-utils :

cd ~
rm -rf ~/alsa* ~/.pulse*
wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.23.tar.bz2
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.23.tar.bz2
wget ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.0.23.tar.bz2

After that, we create a new folder for the compilation and installation of the 3 files. Then, we move the 3 tar files that we just downloaded in this folder :

sudo rm -rf /usr/src/alsa
sudo mkdir -p /usr/src/alsa
cd /usr/src/alsa
sudo cp ~/alsa* .

Unpack the 3 tar files :

sudo tar xjf alsa-driver*
sudo tar xjf alsa-lib*
sudo tar xjf alsa-utils*

We compile and install alsa-driver :

cd alsa-driver*
sudo ./configure
sudo make
sudo make install

We compile and install alsa-lib :

cd ../alsa-lib*
sudo ./configure
sudo make
sudo make install

We compile and install alsa-utils :

cd ../alsa-utils*
sudo ./configure
sudo make
sudo make install

Then, we remove the 3 tar files in our personal folder that are not anymore necessary :

rm -f ~/alsa-driver*
rm -f ~/alsa-lib*
rm -f ~/alsa-utils*

Then, just restart your computer and your alsa version should be 1.0.23!

You can verify that you have now indeed have this version of alsa :

cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.23.
Compiled on May 2 2010 for kernel 2.6.32-21-generic (SMP).

Just to be sure everything is well configured, execute this command :

sudo alsaconf

and reboot again!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Related Posts