Difference between revisions of "Dialog Dump"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Use it)
(Choosing the Dialogs)
Line 48: Line 48:
 
will dump the dialog named "HelloWorld", located in the "Demos" module in the document "c:\documents\dialog designs.odt".
 
will dump the dialog named "HelloWorld", located in the "Demos" module in the document "c:\documents\dialog designs.odt".
  
{{Template:Info|Currently, you must have opened the document in question in OpenOffice.org, before you can dump the contained dialogs. See [[#Future_Tasks|Future Tasks]] for more information.}}
+
{{Template:Important|Currently, you must have opened the document in question in OpenOffice.org, before you can dump the contained dialogs. See [[#Future_Tasks|Future Tasks]] for more information.}}
  
 
=== Output ===
 
=== Output ===

Revision as of 08:52, 1 September 2006

Introduction

Every OpenOffice.org who ever needed to create a VCL dialog knows that this can be a ... laborious procedure: You need to

  • define your dialog, with a text editor, in a resource file (.src), including manual maintainance of control sizes and positions
  • define the IDs for your dialog's elements in a separate .hrc file
  • create a class definition for your dialog in yet another .hxx file
  • create an initial class implementation in a .cxx file

All of this is laborious, cumbersome, and not really fun to do.

dialogdump is a Java tool which relieves you from some of those tasks, by dumping UNO dialogs to source code. This way, you can create your dialogs in the OpenOffice.org Dialog Editor (Tools / Macros / Organize Dialogs ...), and let dialogdump create all 4 files with initial content - ready to be compiled.

Get it

dialogdump is currently not available for direct download. You can check it out from CVS, it's in the module awttools of the gsl project:

 cvs checkout gsl/awttools

(If you're unfamilar with how to check out source code from CVS, refer to the documentation)

After you have the source, create a NetBeans project:

  • choose File / New Project ... from the menu
  • choose General / Java Project with Existing Sources in the "New Project" dialog
  • on the second page of the dialog, give your project a name and location
  • on the third page of the dialog, add the awttools/java directory, in the location where you just checked out the module, to the "Source Package Folders" list.
  • Finally, in the project properties, add the ridl.jar, unoil.jar, jurt.jar, juh.jar, jut.jar, java_uno.jar files, to be found in your OpenOffice.org installation in the program/classes folder, to the Compile-time Libraries list.

Use it

General

Start OpenOffice.org, by allowing it to accept incoming connections from localhost, on port 8100:

 soffice --accept=socket,host=localhost,port=8100;urp

Then, simply run dialogdump from the command line, or from within the NetBeans IDE, if you have set up a project as described in the previous chapter.

Just pass the names of the dialogs you want to dump as arguments when calling dialogdump:

 dialogdump [switches] <dialog_name_1> [<dialog_name_2> [<dialog_name_3> ... ]]

(in NetBeans, this is the "Run" section in the project properties)

Choosing the Dialogs

A dialog name is composed of the module, plus the actual name. So, for instance

 dialogdump Standard.MyDialog

will dump the dialog named "MyDialog" in the application-wide module "Standard"

If you want to dump dialogs which are not application-wide, but part of a document, use the --document switch:

 dialogdump --document "c:\documents\dialog designs.odt" Demos.HelloWorld

will dump the dialog named "HelloWorld", located in the "Demos" module in the document "c:\documents\dialog designs.odt".

Important.png Currently, you must have opened the document in question in OpenOffice.org, before you can dump the contained dialogs. See Future Tasks for more information.

Output

By default, all output happens on the console. You can override this with the --file switch:

 dialogdump --file c:\source\hello Demos.HelloWorld Demos.SimpleInput

will create the following files:

  • c:\source\hello.hrc - contains the resource identifier definitions
  • c:\source\hello.src - contains the resource definitions
  • c:\source\hello.hxx - contains the class declarations
  • c:\source\hello.cxx - contains the class implementations

All those files will be ready to compile - place them in a directory of your choice, and add them to the respective makefile. Note, however, that you certainly want to tweak the files:

  • The identifiers for the global dialogs are placed in the .hrc file, but this is not their proper place. You should move them to the central .hrc file for your complete source module, where you collect all global resouce identifiers for the module.
  • The dialog classes are constructed as follows

[c++] HelloWorldDialog::HelloWorldDialog( Window* _pParent )

 :ModalDialog( _pParent, ResId( DLG_HELLO_WORLD )
 ...

Note that there is a ResId in the call to the ModalDialog constructor. You will want to replace this with the resource-id-class for your module.

In general, look for // TODO: in the generated files - this will tell you placed you need to tweak.

Future Tasks

Personal tools