def createMimeDataFromSelection(self): result = QMimeData() cursor = self.textCursor() selection = cursor.selectedText() selection = selection.replace('\u2029', '\n') selection = selection.replace('\u2028', '\n') result.setText(selection) # create an xml representation of the selected document structure traversal = TextDocumentSelectionTraversal() frame = traversal.traverse(self.textCursor(), self.document()) print('\n-----------------------------------------------') printer = StructurePrinter(frame, self.outPut) printer.traverse() print('-----------------------------------------------') return sp = AppXmlPrinter(frame, None) sp.traverse() blafasel = '''<?xml version="1.0" encoding="utf-8"?> <article version="5.0" xml:lang="en" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title></title></article>''' result.setData("application/xml", blafasel) return result
def activateStructureView(self): self.textView.clear() doc = self.editorWidget.editView.document() traversal = TextDocumentTraversal() tree = traversal.traverse(doc) sp = StructurePrinter(tree, self.textView.insertPlainText) sp.traverse()