dumpAsXml

Miklos Vajna vmiklos at collabora.co.uk
Fri Oct 27 16:26:35 UTC 2017


Hi,

On Thu, Oct 26, 2017 at 02:24:33AM +0000, Yemelyanenko Fyodor <fyodor_e at hotmail.com> wrote:
> During work on bug https://bugs.documentfoundation.org/show_bug.cgi?id=108124 I found dumpAsXml methods in different classes (i.e. SwNode, SwNodes, SwDoc, SwPaM, SwPosition, etc.)
> I've created separate function which creates XML writer, calls dumpAsXml from some class and outputs result to debugger output. This is useful, as I can call such function from debugger (using .call in WinDbg) and immediately get class contents as xml (i.e SwNodes as xml). This function accepts only one parameter - pointer to class. Such pointer can be found in locals window in debugger. So dumping any class to debug output become easy and quick task, without rewriting and recompiling code.
> 
> The code itself is at the end of this message (this is draft code, written quickly).
> 
> I can make this code better (add cross-platform'ness as it depends on OutputDebugStringA and I'm not sure that it exists in any other OS than Windows), and submit as patch to master. Also I can add several lines here on how to use my function to get xml dump during debugging https://wiki.documentfoundation.org/Development/How_to_debug#Debugging_options
> 
> If all this makes sense and can be useful not only for me?

There are 2 dumpers in sw, a document and a layout dumper. To dump the
layout from a debugger, you need a reference to the SwRootFrame of the
document, then you can call pRoot->dumpAsXml() already, it'll write its
output in a file called layout.xml in the current directory.

The same is true for the doc xml dump, just it's SwDoc::dumpAsXml() and
the output is nodes.xml.

If some of that is not up to your expectations, feel free to submit a
gerrit patch to improve the output, the current contents is quite
ad-hoc, based on what was necessary for debugging past bugs and
features. :-)

(sw/qa/extras/README documents how the UI can invoke these functions in
debug mode via (Shift-)F12.)

Regards,

Miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20171027/b1bb2be9/attachment.sig>


More information about the LibreOffice mailing list