And again with the patches. 2011/4/15 Markus Mohrhard <markus.mohrh...@googlemail.com>
> Hi Noel, > > here is the patch without the conversion from XSpreadsheet to XWorksheet. > > I found some nice Code in ScVbaWorkbook::getActiveSheet() where nearly the > same thing was done. But the following attempt didn't work, and created > always an error message in getDocUnoModule() > > uno::Reference<frame::XModel> xNewModel( getCurrentExcelDoc( mxContext ), > uno::UNO_SET_THROW ); > ScDocShell* pShell = excel::getDocShell( xNewModel ); > if( !pShell ) > throw uno::RuntimeException(); > ScDocument* pDoc = pShell->GetDocument(); > String aCodeName; > pDoc->GetCodeName((SCTAB)0 ,aCodeName); > return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, > pShell ), uno::UNO_QUERY_THROW ); > > With a debugger you see that pShell points to the correct ScDocShell and > aCodeName points to the CodeName of the ScTable but it still won't work. > > Perhabs you know why my idea won't work. Nearly the same code works fine > with ScVbaWorkbook::getActiveSheet() > > Patch is under LGPLv3+/MPL. > > Regards, > Markus > > P.S. Even some really strange ways of using the setUpDocumentModules(const > uno::Reference< sheet::XSpreadsheetDocument >) of vbaworkbooks.cxx produces > an error. But this seems a good way to solve the problem. If you can give me > any hints why this won't work I will try again on the conversion > > > > > > 2011/4/14 Noel Power <nopo...@novell.com> > >> Hi Markus >> >> On 14/04/11 00:49, Markus Mohrhard wrote: >> >>> Hello, >>> >>> I have reworked most of the Code but have now the problem that I have an >>> instance of XSpreadsheet but need the corresponding XWorksheet object. >>> >>> I found one of these conversions at ScVbaWorksheet::getSheetAtOffset but >>> it needs to call getParent, which will not work in my case because it is for >>> the new method createSheetCopyInNewDoc. Do you know any way to resolve this >>> problem? >>> >> aha very good!! I didn't think of that, nice catch. Ok, here is what I >> propose, I think you have suffered enough with this so-called easy hack, >> just pass null as the parent and lets get the patch reviewed and in. Please >> do put a #TODO #FIXME in the code where the parent is (NOT) created. >> The parent should be a Workbook object, problem here is that when you >> create a new document, just creating a workbook object isn't enough as those >> parents are by a weakreference and the workbook object you would create >> would only be temporary. >> If the new document was created correctly ( e.g. in vba mode ) then we >> could use the getUnoDocModule() to access the correct Workbook instance and >> pass that instead. I think we need to tweak the existing code more to do >> that ( some stuff like this is already done in ScWorkbooks::Add ). if you >> are interested I'd give you some advice/hints on how that should be done and >> you could do that as a separate hack ( let me know if you are interested in >> doing that ) Otherwise just open a bug for that part and assign it to me and >> I will either fix it or create another easy hack from that. >> >> thanks for you continued efforts >> Noel >> > >
0001-add-method-Copy-to-ScVbaWorksheets.patch
Description: Binary data
0002-added-method-Copy-to-XWorksheets.patch
Description: Binary data
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice