Difference between revisions of "Porting example"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Step 3 Prepare and provide implementation code)
(Step 3 Prepare and provide implementation code)
Line 32: Line 32:
 
In the java version a helper class ( which doesn't exist in the c++ oovbaapi ) is used to convert from the <tt>CellRangeAddress</tt> obtained from the <tt>XDatabaseRange</tt> implementation object to a <tt>XRange</tt> implementation object. It's not necessary to do this in the c++ oovbaapi as we can create a <tt>ScVbaRange</tt> object from a <tt>table::XCellRange</tt> object, looking at the source code <tt>unoobj/datauno.cxx</tt> ( the <tt>XDatabaseRange</tt> implementation ) its clear that we can get a hold of a <tt>table::XCellRange</tt> object pretty easily by querying for the <tt>sheet::XCellRangeReferrer</tt> interface.
 
In the java version a helper class ( which doesn't exist in the c++ oovbaapi ) is used to convert from the <tt>CellRangeAddress</tt> obtained from the <tt>XDatabaseRange</tt> implementation object to a <tt>XRange</tt> implementation object. It's not necessary to do this in the c++ oovbaapi as we can create a <tt>ScVbaRange</tt> object from a <tt>table::XCellRange</tt> object, looking at the source code <tt>unoobj/datauno.cxx</tt> ( the <tt>XDatabaseRange</tt> implementation ) its clear that we can get a hold of a <tt>table::XCellRange</tt> object pretty easily by querying for the <tt>sheet::XCellRangeReferrer</tt> interface.
  
Next to port is to create the filters collection. Collections are implemented quite differenty ( some details available from [porting notes#Collection|Collection]
+
Next to port is to create the filters collection. Collections are implemented quite differenty ( some details available from [[porting notes#Collection|Collection]]
  
 
semi-ported ( and completely untested ) examples are  
 
semi-ported ( and completely untested ) examples are  

Revision as of 21:46, 25 February 2007

Step 1 Choose an object to port

I randomly picked the Filter object e.g. XFilter in the helperapi ( of course you also want to make sure this object isn't already implemented in oovbaapi ). Browse the helperapi code to find where XFilter is implemented. It's implemented by FilterImpl.java and it expects to be initialised by an XAutoFilter implementation object AutoFilterImpl

so already an implementation not only for XFilter need to be provided but also and implementation for XAutoFilter as well.

looking at XAutoFilter.idl you see that there is a Filters() attribute/method that returns a Collection of Filters, so additionally an implementation of the XFilters object is needed. The XAutoFilter implementation is the key object that the others are accessed/provided from. Searching through the source code you find this is an attribute of the SheetImpl object

so, to summarize, after initially choosing one object to have a crack at porting, you actually need to provide implementations for the following interfaces

  • XFilter
  • XAutoFilter
  • XFilters

and also you need to add a new attribute to return an XAutoFilter implementation

Step 2 Port the idl files

It's worth taking a look at the idl section in the porting notes and examples of the ported idl files

also modifications to existing files

Step 3 Prepare and provide implementation code

It's probably an idea just start with a stub implementation and then build on that. That's precisely what I will show here, once the stub implementation is in place you can get deeper into the implementation.

I decided to try and port the AutoFilter implementation object first, the

XAutofilter has two methods, Filters and Range. In the java version a helper class ( which doesn't exist in the c++ oovbaapi ) is used to convert from the CellRangeAddress obtained from the XDatabaseRange implementation object to a XRange implementation object. It's not necessary to do this in the c++ oovbaapi as we can create a ScVbaRange object from a table::XCellRange object, looking at the source code unoobj/datauno.cxx ( the XDatabaseRange implementation ) its clear that we can get a hold of a table::XCellRange object pretty easily by querying for the sheet::XCellRangeReferrer interface.

Next to port is to create the filters collection. Collections are implemented quite differenty ( some details available from Collection

semi-ported ( and completely untested ) examples are

Personal tools