OpenOffice and Eclipse

From Apache OpenOffice Wiki
Jump to: navigation, search

With current versions of Eclipse (4.3) it is possible to create C/C++ projects for OpenOffice modules and use code assist, refactoring, lookup of definitions and declarations and all the other nice things that a modern IDE provides.

There are two different approaches to import the OpenOffice source code into Eclipse:

  • The whole repository at once.
You will need a not-yet-released nightly build of CDT to prevent major memory leaks and still have to increase memory limits for Eclipse.
  • Module by module.
This approach works with vanilla Eclipse. You only import individual modules (say sw/ and sfx/ into your workspace).
This approach is described below.

OpenOffice in Eclipse: Some Highlights

Here are some highlights of developing OpenOffice with Eclipse illustrated with the sfx2 module and its sfx2/source/sidebar/AsynchronousCall file.

  • Syntax coloring and code formatting
Both are very customizable (in the 'Preferences' dialog: C/C++->Editor->Syntax Coloring respectively C/C++->Code Style->Formatter)

AfterStart.png

  • Switch between .hxx and implementing .cxx
  • Follow header inclusion
  • Extended tooltips that can display declaration/definition of classes, methods, variables, constants.

Find out how the constant is defined without leaving the editor

  • Visualization of whether code enclosed by #ifdef/#endif is active or not

Ifdef.png

  • Tooltips can be focused => you can explore a class definition without switching your editor to another file.

'Simple' macro expansion on hover Press F2 to see more details

  • Find out from where a function or method is called
  • Explore the type hierarchy of a class
  • Code assist while typing.
  • Integration of bugzilla (via Mylyn), don't line how the bugzilla data is presented? Just open an inplace browser to have the same experience as you have now.
  • Static code analysis (CODAN)

Module by Module

The following describes how to set up Eclipse for the module by module approach.

Install Eclipse

Install a current version of Eclipse (http://www.eclipse.org/downloads/).

  • Version 4.3 (Kepler) is known to work. Older 4.* versions may also work.
  • A version with focus on C/C++ (titled "Eclipse IDE for C/C++ Developers) works best but other versions with the CDT addon installed should work also.

Prepare a workspace

Start Eclipse and select or create an empty workspace. The empty workspace is not a hard requirement but with one Eclipse project per OpenOffice module you may loose track otherwise. You can freely choose the location of the workspace, just don't use the OpenOffice source code directory.


Add module to workspace

  • Open the import wizard via menu File->New->Other.
  • In the dialog choose the C/C++ -> Makefile Project with Existing Code wizard.
  • In the 'Import Existing Code' wizard
    • use the 'Browse...' button to set the 'Existing Code Location' to the top-level directory of a module. This will also set the 'Project Name'.
    • Select the correct tool chain for your platform.
Tool chains for the individual platforms:
Windows : Microsoft Visual C++
    • Close the import wizard via the Finish button to start the module import.

Setup project properties

A few changes to the project properties are necessary for the indexer to find all include files and use the correct compiler definitions.

  • Compile OpenOffice. That is necessary to create some header files and copy (deliver) them into solver/.
  • Open the properties dialog via the menu Project->Properties.
  • Activate the C/C++ General->Paths and Symbols page.
  • Add include paths
    • For the paths
      • main/solver/VERSION/PLATFORM/inc
      • main/solver/VERSION/PLATFORM/inc/offuh
      • main/solver/VERSION/PLATFORM/inc/stl
      • <visual-studio-9.0>/VC/include
    • do
      • Go to the 'Includes' tab page (initially selected)
      • In the 'Languages' list (left center) activate 'GNU C++', (for some reason this name does not change even when you use the MSVC tool chain).
      • Click 'Add...' and in the new dialog 'File system...' and browse to the include path.
    • Click 'OK' two times to get back to the properties dialog.
  • Add some macro definitions
    • For the macros
      • Windows: WNT, WIN32
    • do
      • Go to the 'Symbols' tab page.
      • Click 'Add...' and add macro definitions
    • Click OK to close the dialog.
  • Rebuild the index via 'Project->C/C++ Index->Rebuild'. This time the indexer should runs longer because it has to index no only the files in the module but also all include files in solver/

Using Mylyn for integrating Bugzilla

Eclipse has a very powerful plugin for integrating bug trackers into the IDE. Bugzilla is supported out of the box. Support for eg. Jira exists also. Setup for OpenOffice Bugzilla:

  • Open the 'Task List' via 'Window->Show View->Task List'. Note that this is not the same view as 'Tasks'.
  • If you do this for the first time you will see a 'Connect' link at the bottom of the new view. Click it.
  • Otherwise open the 'Task Repositories' view via 'Window->Show View->Other...'
    • In the 'Show View' dialog select 'Mylyn->Task Repositories'
    • Click on the 'Add Task Repository...' button in the tool bar of the view.

In the 'Add Task Repository...' dialog:

  • Choose 'Bugzilla (supports 3.6 and later)'
  • Click 'Next >'
  • Enter 'https://issues.apache.org/ooo/ ' into the 'Server' field.
  • Enter 'OpenOffice Bugzilla' or some other descriptive string into the 'Label' field.
  • Fill out 'User ID' and 'Password' fields
  • (Optional) Check the 'Save Password'
  • Click 'Finish' and answer any popups as you like.

Search for tasks in Bugzilla in the 'Task List' view:

  • Insert the task id in the search field. Click the now visible link 'Search repository for key or summary...'.
  • In the 'Search' dialog:
    • Make sure that 'Repository' is set to 'OpenOffice Bugzilla'
    • The 'Task Key/ID' field should show the task id you entered earlier.
    • Click on 'Search'
  • A new editor opens in the editor area with the details about the found bug.
  • If you don't like this view, click on the 'Open with Web Browser' button in the toolbar of the editor.
  • There seems to be a bug that prevents submitting changes. I get a 'Submit failed:...' error message.
  • In the 'Task List' view there is now a new tree view with root node 'Uncategorized'.
    • Expand it to see your bug
    • A double click on the bug entry opens the Bugzilla editor with that bug.

There exists the concept of 'Context' which defines a set of files for each bug. This is activated by clicking on the 'Activate...' link in the 'Task List' view.

Personal tools