Re: EXTERNAL: Re: DisposedException

2014-03-07 Thread Andre Fischer
.getByName(Oper Data);

XSpreadsheet sheet3 = 
_UnoRuntime_.queryInterface(_XspreadsheetDocument_.*class*, sheetObj3);


//sheetObj = sheets.getByName(Oper Data);

// com.sun.star.lang.DisposedException occurs 
here.//


  //sheet = _UnoRuntime_.queryInterface(_XSpreadsheet_.class, sheetObj);

XCellRange cells3 = _UnoRuntime_.queryInterface(_XCellRange_.*class*, 
sheet3);


XCellRange range3 = cells3.getCellRangeByName(A2:E11);

XCellRangeData data3 = 
_UnoRuntime_.queryInterface(_XCellRangeData_.*class*, range3);


Object[][] data_obj3 = data3.getDataArray();

//Populate data_obj here. This part omitted for clarity an need to 
manually type.


data3.setDataArray(data_obj3);

//Populate worksheet

XNameAcess sheetNA4 = 
_UnoRuntime_.queryInterface(_XspreadsheetDocument_.*class*, sheets);


Object sheetObj4 = sheetNA4.getByName(Param Data);

XSpreadsheet sheet4 = 
_UnoRuntime_.queryInterface(_XspreadsheetDocument_.*class*, sheetObj4);


//sheetObj = sheets.getByName(Param Data);

//sheet = _UnoRuntime_.queryInterface(_XSpreadsheet_.*class*, sheetObj);

XCellRange cells4 = _UnoRuntime_.queryInterface(_XCellRange_.*class*, 
sheet4);


XCellRange range4 = cells.getCellRangeByName(A2:AW2);

XCellRangeData data4 = 
_UnoRuntime_.queryInterface(_XCellRangeData_.*class*, range4);


Object[][] data_obj4 = data4.getDataArray();

//Populate data_obj here. This part omitted for clarity an need to 
manually type.


data4.setDataArray(data_obj4);

//Populate worksheet

XNameAcess sheetNA5 = 
_UnoRuntime_.queryInterface(_XspreadsheetDocument_.*class*, sheets);


Object sheetObj5 = sheetNA5.getByName(Point Data);

XSpreadsheet sheet5 = 
_UnoRuntime_.queryInterface(_XspreadsheetDocument_.*class*, sheetObj5);


//sheetObj = sheets.getByName(Point Data);

//sheet = _UnoRuntime_.queryInterface(_XSpreadsheet_.*class*, sheetObj);

XCellRange cells5 = _UnoRuntime_.queryInterface(_XCellRange_.*class*, 
sheet5);


XCellRange range5 = cells5.getCellRangeByName(A2:AJ151);

XCellRangeData data5 = 
_UnoRuntime_.queryInterface(_XCellRangeData_.*class*, range5);


Object[][] data_obj5 = data5.getDataArray();

//Populate data_obj here. This part omitted for clarity an need to 
manually type.


data5.setDataArray(data_obj5);

} *catch*(_com.sun.star_.uno.Exception ex) {

System.err.println(ex.getMessage());

} *finally*{

System.exit(1);

}

_}_

   }

*public**void*closeDocument(_XComponent_ document) {

_XModel_ model = _UnoRuntime_.queryInterface(_XModel_.*class*, document);

*if*(model != *null*) {

_XCloseable_ closeable = 
_UnoRuntime_.queryInterface(_XCloseable_.*class*, model);


*if*(closeable != *null*) {

*try*{

closeable.close(*false*);

} *catch*(_CloseVetoException_ ex) {

System./out/.println(ex.getMessage());

}

}

} *else*{

_XComponent_ disposeable = 
_UnoRuntime_.queryInterface(_XCompnent_.*class*, model);


disposeable.dispose();

}

   }

*public**void*ExportDocumentAs(_XComponent_ doc, String save_file, 
_DocumentHandler_.DocumentSaveFormat format, *boolean*overwrite, 
String page_range) {


*if*((save_file == *null*) || (save_file.trim().length()) == 0) {

*return*;

}

*if*(!overwrite) {

_File_ sfile = *new*_File_(save_file);

*if*(sfile.exists()) {

*throw**new*Exception(File exists);

}

}

_DocumentHandler_ = *new*_DocumentHandler_();

String file_url = _handler_.convertFIlePAthToUrl(save_file);

_XStoreable_ store = _UnoRuntime_.queryInterface(_XStoreable_.*class*, 
doc);


_PropertyValue_ filter_data= *new*_PropertyValue_[1];

_loadProps_[0] = *new*_PropertyValue_();

_loadProps_[0].Name = PageRange;

_loadProps_[0].Value = page_range;

_PropertyValue_ loadProps= *new*_PropertyValue_[2];

loadProps[0] = *new*_PropertyValue_();

loadProps[0].Name = FilterName;

loadProps[0].Value = format.getFormatCode;

loadProps[1] = *new*_PropertyValue_();

loadProps[1].Name = FilterData;

loadProps[1].Value = filter_data;

store.storeToUrl(file_url, loadProps);

}

}

*From:*Andre Fischer [mailto:awf@gmail.com]
*Sent:* Thursday, March 06, 2014 1:24 AM
*To:* Steele, Raymond; Andre Fischer; api@openoffice.apache.org
*Subject:* Re: EXTERNAL: Re: DisposedException

On 28.02.2014 20:35, Steele, Raymond wrote:

I am still having issues. I've typed (there may be typos) out most
of the code. The following code will fail during runtime on the
line bolded below. Can anyone identify why? Any help would be great!!!


Sorry for the late reply, I am still not scanning api@ every day and 
my thunderbird did not update the count of new mails automatically.


I don't see any obvious error in your Java code.  I also looked into 
the C++ implementation of ScTableSheetObj and did not find anything 
obvious either.  The only thing that I can do is to debug the C++ side 
of the problem, but only if you can send me a running version of your 
extension, stripped down to the minimum to reproduce this bug.


The only alternative to that (if you can not provide the extension

RE: EXTERNAL: Re: DisposedException

2014-03-06 Thread Steele, Raymond
 = 
UnoRuntime.queryInterface(XCompnent.class, model);
 disposeable.dispose();
  }
   }

   public void ExportDocumentAs(XComponent doc, String save_file, 
DocumentHandler.DocumentSaveFormat format, boolean overwrite, String 
page_range) {
  if((save_file == null) || (save_file.trim().length()) == 0) {
 return;
  }

  if(!overwrite) {
 File sfile = new File(save_file);
 if(sfile.exists()) {
   throw new Exception(File exists);
 }
  }

  DocumentHandler = new DocumentHandler();

  String file_url = handler.convertFIlePAthToUrl(save_file);
  XStoreable store = UnoRuntime.queryInterface(XStoreable.class, 
doc);

  PropertyValue filter_data= new PropertyValue[1];
  loadProps[0] = new PropertyValue();
  loadProps[0].Name = PageRange;
  loadProps[0].Value = page_range;

  PropertyValue loadProps= new PropertyValue[2];
  loadProps[0] = new PropertyValue();
  loadProps[0].Name = FilterName;
  loadProps[0].Value = format.getFormatCode;
  loadProps[1] = new PropertyValue();
  loadProps[1].Name = FilterData;
  loadProps[1].Value = filter_data;

  store.storeToUrl(file_url, loadProps);


   }
}


From: Andre Fischer [mailto:awf@gmail.com]
Sent: Thursday, March 06, 2014 1:24 AM
To: Steele, Raymond; Andre Fischer; api@openoffice.apache.org
Subject: Re: EXTERNAL: Re: DisposedException

On 28.02.2014 20:35, Steele, Raymond wrote:
I am still having issues. I've typed (there may be typos) out most of the code. 
The following code will fail during runtime on the line bolded below. Can 
anyone identify why? Any help would be great!!!

Sorry for the late reply, I am still not scanning api@ every day and my 
thunderbird did not update the count of new mails automatically.

I don't see any obvious error in your Java code.  I also looked into the C++ 
implementation of ScTableSheetObj and did not find anything obvious either.  
The only thing that I can do is to debug the C++ side of the problem, but only 
if you can send me a running version of your extension, stripped down to the 
minimum to reproduce this bug.

The only alternative to that (if you can not provide the extension) then we 
have to rely on collecting more data:

- add an XEventListener to sheets and possibly to doc right after the
 XSpreadsheets sheets = doc.getSheets();
line and see if the disposing() method of the listener is called.

- when the DisposedException is thrown, then look at its Source member (should 
be sheetObj).  I don't expect any surprises there but the check doesn't take 
long.

I am sorry that I can not be of more help.

-Andre



Basically, I am just trying to populate an .ods file's worksheets with data.


   public class Load {
  String master_track_dir = System.getenv(PLN_MASTER_TRK);
  String restore_track = master_track_dir + 
/RAYMOND/restore_track.xml;
  String master_track = master_track_dir + /RAYMOND/track.xml;

   public Load() {

   }

   public static main(String[] args) {
  try {
 Load block = new Load();
 XComponentContext context = Bootstarp.bootstrap();
 if(context == null) {
   System.err.println(ERROR: Could not bootstrap 
default Office);
   System.exit(1);
 }

 XMultiComponentFactory component_factory = 
context.getServiceManager();
 try {
   Object desktop = 
component_factory.createInstanceWithContext(com.sun.star.frame.Desktop, 
context);
   XComponentLoader xComponentLoader = 
UnoRuntime.queryInterface(XComponentLoader.class, desktop);

   PropertyValue loadProps= new PropertyValue[1];
   loadProps[0] = new PropertyValue();
   loadProps[0].Name = Hidden;
   loadProps[0].Value = Boolean.FALSE;

   String odsFile = System.getenv(PLN_DAT_GCFILES) + 
/Track.ods;
   new File(odsFile).delete();
   DocumentHandler otsHandler = new DocumentHandler();
   String otsFile = /tmp/Track.ots;
   String otsUrl = 
otsHandler.convertFilePathToURL(otsFile);
   String odsUrl = 
otsHandler.convertFilePathToURL(odsFile);

   //Load .ots file, opens Untitled 1.ods
   XComponent otsComponent = 
XComponentLoader.loadComponent.loadComponentFromURL(otsUrl, _blank, 0, 
loadProps);
   //export Untitled 1

RE: EXTERNAL: Re: DisposedException

2014-02-28 Thread Steele, Raymond
   sheetObj = sheets.getByName(Oper Data);
   // 
com.sun.star.lang.DisposedException occurs here.//
 sheet = UnoRuntime.queryInterface(XSpreadsheet.class, 
sheetObj);
   cells = UnoRuntime.queryInterface(XCellRange.class, 
sheet);
   range = cells.getCellRangeByName(A2:E11);
   data = 
UnoRuntime.queryInterface(XCellRangeData.class, range);
   data_obj = data.getDataArray();
   //Populate data_obj here. This part omitted for 
clarity an need to manually type.
   data.setDataArray(data_obj);

//Populate worksheet
   sheetObj = sheets.getByName(Param Data);
   sheet = 
UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj);
   cells = UnoRuntime.queryInterface(XCellRange.class, 
sheet);
   range = cells.getCellRangeByName(A2:AW2);
   data = 
UnoRuntime.queryInterface(XCellRangeData.class, range);
   data_obj = data.getDataArray();
   //Populate data_obj here. This part omitted for 
clarity an need to manually type.
   data.setDataArray(data_obj);

//Populate worksheet
   sheetObj = sheets.getByName(Point Data);
   sheet = 
UnoRuntime.queryInterface(XSpreadsheet.class, sheetObj);
   cells = UnoRuntime.queryInterface(XCellRange.class, 
sheet);
   range = cells.getCellRangeByName(A2:AJ151);
   data = 
UnoRuntime.queryInterface(XCellRangeData.class, range);
   data_obj = data.getDataArray();
   //Populate data_obj here. This part omitted for 
clarity an need to manually type.
   data.setDataArray(data_obj);

 } catch(com.sun.star.uno.Exception ex) {
   System.err.println(ex.getMessage());
 } finally {
   System.exit(1);
 }


  }
   }

   public void closeDocument(XComponent document) {
  XModel model = UnoRuntime.queryInterface(XModel.class, document);
  if(model != null) {
 XCloseable closeable = 
UnoRuntime.queryInterface(XCloseable.class, model);
 if(closeable != null) {
   try {
  closeable.close(false);
   } catch (CloseVetoException ex) {
  System.out.println(ex.getMessage());
   }
 }
  } else {
 XComponent disposeable = 
UnoRuntime.queryInterface(XCompnent.class, model);
 disposeable.dispose();
  }
   }

   public void ExportDocumentAs(XComponent doc, String save_file, 
DocumentHandler.DocumentSaveFormat format, boolean overwrite, String 
page_range) {
  if((save_file == null) || (save_file.trim().length()) == 0) {
 return;
  }

  if(!overwrite) {
 File sfile = new File(save_file);
 if(sfile.exists()) {
   throw new Exception(File exists);
 }
  }

  DocumentHandler = new DocumentHandler();

  String file_url = handler.convertFIlePAthToUrl(save_file);
  XStoreable store = UnoRuntime.queryInterface(XStoreable.class, 
doc);

  PropertyValue filter_data= new PropertyValue[1];
  loadProps[0] = new PropertyValue();
  loadProps[0].Name = PageRange;
  loadProps[0].Value = page_range;

  PropertyValue loadProps= new PropertyValue[2];
  loadProps[0] = new PropertyValue();
  loadProps[0].Name = FilterName;
  loadProps[0].Value = format.getFormatCode;
  loadProps[1] = new PropertyValue();
  loadProps[1].Name = FilterData;
  loadProps[1].Value = filter_data;

  store.storeToUrl(file_url, loadProps);


   }
}

From: Andre Fischer [mailto:awf@gmail.com]
Sent: Wednesday, February 26, 2014 3:15 AM
To: Steele, Raymond; Andre Fischer; api@openoffice.apache.org
Subject: Re: EXTERNAL: Re: DisposedException

On 26.02.2014 00:25, Steele, Raymond wrote:

Thanks,



I am not explicitly calling the dispose method .

I would expect that dispose is called by a closing frame or something like that.



Here is an overview of what I am doing.



1.   opening a XSpreadsheetDocument (called temp_doc)  by calling after 
creating an object using  XMultiComponentFactory

Re: EXTERNAL: Re: DisposedException

2014-02-26 Thread Andre Fischer

On 26.02.2014 00:25, Steele, Raymond wrote:


Thanks,

I am not explicitly calling the dispose method .



I would expect that dispose is called by a closing frame or something 
like that.



Here is an overview of what I am doing.

1.opening a XSpreadsheetDocument (called temp_doc)  by calling after 
creating an object using 
XMultiComponentFactory::createInstanceWithContext.


a.The document is a .ots file which opens as Untitled 1.

2.XComponent  temp_comp = UnoRuntime.queryInterface(XComponent.class, 
temp_doc);


3.XStoreable store = UnoRuntime.queryInterface(XStoreable.class, 
temp_comp);


a. exporting Unititled 1,  to an ODF Spreadsheet, StarOffice XML 
(Calc) format by setting the PropertyValue FilterName property.  Once 
the properties are set, I use XStoreable::stopToURL to save Untitled 
1 to RawData.ods


4.Then I close the document:

a.XModel model = UnoRuntime.queryInterface(XModel.class, document);

b.If model not null then, XCloseable closeable = 
UnoRuntime.queryInterface(XCloseable.class, model);


i.closeable.close(); (This is always the case that happens)

c.If model null then,  XComponent disposable = 
UnoRuntime.queryInterface(Xcomponent.class,  model);


i.disposable.dispose(); (My code never gets into this condition)

5.I then immediately open the file I exported in step three above by 
creating a new XSpreadsheetDocument (called doc), using the same 
methods defined in step one above,  but when I do a


a.document = UnoRuntime.queryInterface(XpreadsheetDocument.class, 
xCalcComponent);


I receive: com.sun.star.lang.DisposedExcpetion

at 
com.sun.star.lib.uno.environments.remote.JobQueue.removeJob(JobQueue.java: 
210)




Is it possible that xCalcComponent still belongs to temp_doc?  That 
would explain why it is disposed.
Otherwise, xCalcComponent should not be disposed directly after 
loading.  Even if the loading failed, it should not be created in the 
first place and be NULL (well, an empty Reference, that contains NULL).  
I would ask for any exceptions during the second loading, but 
unfortunately OpenOffice throws a lot of exceptions that don't notify 
any errors but are used for normal communication (don't ask)


-Andre

Hopefully, this provides some context. Basically, I am opening an .ots 
file, saving(exporting) it as an .ods file and closing it. Then  I 
open the .ods file so that I can populate the cells with data, but 
right after loadComponentFromURL, I try to query the XComponent 
returned from loadComponentFromURL to get the XSpreadsheetDocument. 
 That is when I get the DisposedException.


-Original Message-
From: Andre Fischer [mailto:awf@gmail.com]
Sent: Tuesday, February 25, 2014 1:26 AM
To: Steele, Raymond; api@openoffice.apache.org
Cc: awf@gmail.com
Subject: Re: EXTERNAL: Re: DisposedException

On 24.02.2014 20:56, Steele, Raymond wrote:

 Thanks for responding. How can I determine what called dispose()?

If you want to know who calls dispose() then you have to place a 
breakpoint in the dispose() method of xCalcComponent.


If you want to know when dispose() is called then register a 
com::sun::star::lang::XEventListener at the xCalcComponent object. 
When it is disposed, it will call disposing(...) at the listener.


I am just not sure if it calls disposing() when the object is already 
disposed when the listener is registered.  Probably not.


   This is working in version AOO 3.3. Has something changed?

Without knowing the context this can easily be a timing problem in a 
multi-threaded environment: in AOO 3.3 some operation took longer 
resulting in the dispose() call made a few milliseconds later (or 
anything to this effect.)


-Andre



 -Original Message-

 From: Andre Fischer [mailto:awf@gmail.com]

 Sent: Monday, February 24, 2014 3:54 AM

 To: api@openoffice.apache.org mailto:api@openoffice.apache.org

 Subject: EXTERNAL: Re: DisposedException



 On 21.02.2014 19:20, Steele, Raymond wrote:

 While running my application using AOO 4.0.1 on Solaris 11,  a 
star.lang.DisposedException is thrown  inconsistently (sometimes it 
works) when I use UnoRuntime.queryInterface.




 The line of code causing the issue:



 XSpreadsheetDocument  document =

 UnoRuntime.queryInterface(XSpreadsheetDocument.class,

 xCalcCompinent);

 The DisposedException means that the throwing object has been marked 
by its owner for destruction in the near future.  Any access after 
that results in the DisposedException being thrown.




 That means, that the line above is executed after xCalcCompinent has 
received a dispose() call.




 -Andre



 This works perfectly when I use AOO 3.3, but not since upgrading to 
4.0.1.




 Any help would be appreciated.



 Thanks,

 Raymond







 -

 To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org 
mailto:api-unsubscr...@openoffice.apache.org


 For additional commands, e-mail: api-h...@openoffice.apache.org 
mailto:api