<div>And again with the patches.</div><div><br></div><div class="gmail_quote">2011/4/15 Markus Mohrhard <span dir="ltr">&lt;<a href="mailto:markus.mohrhard@googlemail.com">markus.mohrhard@googlemail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>Hi Noel,<br></div><div><br></div><div>here is the patch without the conversion from XSpreadsheet to XWorksheet.</div><div><br></div><div>I found some nice Code in ScVbaWorkbook::getActiveSheet() where nearly the same thing was done. But the following attempt didn&#39;t work, and created always an error message in getDocUnoModule()</div>

<div><br></div><div>    uno::Reference&lt;frame::XModel&gt; xNewModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW );<br>    ScDocShell* pShell = excel::getDocShell( xNewModel );<br>    if( !pShell )<br>        throw uno::RuntimeException();<br>

    ScDocument* pDoc = pShell-&gt;GetDocument();<br>    String aCodeName;<br>    pDoc-&gt;GetCodeName((SCTAB)0 ,aCodeName);<br>return uno::Reference&lt; excel::XWorksheet &gt;( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW );<br>

</div><div><br></div><div>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&#39;t work.</div><div><br></div><div>Perhabs you know why my idea won&#39;t work. Nearly the same code works fine with ScVbaWorkbook::getActiveSheet()</div>

<div><br></div><div>Patch is under LGPLv3+/MPL.</div><div><br></div><div>Regards,</div><div>Markus</div><div><br></div><div>P.S. Even some really strange ways of using the setUpDocumentModules(const uno::Reference&lt; sheet::XSpreadsheetDocument &gt;) 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&#39;t work I will try again on the conversion</div>
<div><div class="h5">
<div><br></div><div><br></div><br><br><br><div class="gmail_quote">2011/4/14 Noel Power <span dir="ltr">&lt;<a href="mailto:nopower@novell.com" target="_blank">nopower@novell.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi Markus<div><div><br>
On 14/04/11 00:49, Markus Mohrhard wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
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.<br>
<br>
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?<br>



</blockquote></div></div>
aha very good!! I didn&#39;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.<br>



The parent should be a Workbook object, problem here is that when you create a new document, just creating a workbook object isn&#39;t enough as those parents are by a weakreference and the workbook object you would create would only be temporary.<br>



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&#39;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.<br>



<br>
thanks for you continued efforts<br><font color="#888888">
Noel<br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>