Page 1 of 1

Data pilot ImportDescriptor availlable since OOo 3.3

Posted: Tue Nov 30, 2010 1:13 am
by Villeroy
Since v3.3 we can access imported pilots via API. Before that version the API was completely blinded towards imported pilots.
The fixed issue with Basic code to create a pilot: http://www.openoffice.org/issues/show_bug.cgi?id=42199
A quick and dirty macro printing info about a pilot's import descriptor:

Code: Select all

Sub PrintPilotImportInfo()
oInitialTarget =ThisComponent
  Dim oSpreadsheet As Object
  Dim oDataPilotTables As Object
  Dim oObj_1 As Object
  Dim oPropertyValue As Object
  oSpreadsheet = oInitialTarget.Sheets.getByName("Pivot")
  oDataPilotTables = oSpreadsheet.DataPilotTables
  oObj_1 = oDataPilotTables.getByIndex(0)
  
  oPropertyValue = oObj_1.getPropertyValue("ImportDescriptor")
  '0 DatabaseName ="PVC"
  '1 SourceType =com.sun.star.sheet.DataImportMode.TABLE
  '2 SourceObject ="List"
  '3 IsNative =False
Dim sImport$
  select case oPropertyValue(1).Value
  	case is=com.sun.star.sheet.DataImportMode.NONE
  		sImport="Not Imported"
  	case is=com.sun.star.sheet.DataImportMode.SQL
	  If oPropertyValue(3).Value then
	  	sImport= "Source:"& oPropertyValue(0).Value &", "& "Native SQL:"
	  else
	  	sImport= "Source:"& oPropertyValue(0).Value &", "& "Parsed SQL:"
	  endif
  	case is=com.sun.star.sheet.DataImportMode.TABLE
  		sImport= "Source:"& oPropertyValue(0).Value &", "& "Table:"
  	case is=com.sun.star.sheet.DataImportMode.QUERY
	  If oPropertyValue(3).Value then
  		sImport= "Source:"& oPropertyValue(0).Value &", "& "Native Query:"
  	else
		sImport= "Source:"& oPropertyValue(0).Value &", "& "Parsed Query:"
	endif
  end select
Print sImport & oPropertyValue(2).Value 
End Sub

Re: Data pilot ImportDescriptor availlable since OOo 3.3

Posted: Wed Dec 08, 2010 1:08 am
by mbrouillet
For those who haven't yet upgraded to Ooo 3.3, here is a dirty solution, assuming you've got a linux-like command-line (or a cygwin or something similar):

Code: Select all

zipgrep -oi '<table:database-source[^>]*>' yourfile.ods content.xml