First working release.

Other files (not .docx) support is not guaranteed
This commit is contained in:
BarsTiger
2023-02-06 21:40:47 +02:00
parent 2a189cc689
commit 13b48be802
21 changed files with 1378 additions and 143 deletions

View File

View File

@@ -0,0 +1,49 @@
import time
from gui.gui import Ui_MainWindow
from modules.document.document_properties import DocumentProps
from modules.helpers import xml
import datetime
from ezzthread import threaded
@threaded
def update_button(ui: Ui_MainWindow):
ui.save_button.setText('Success')
time.sleep(3)
ui.save_button.setText('Save')
def write_document(ui: Ui_MainWindow, document_props: DocumentProps):
if not document_props.parsed_:
return
xml.set_value(document_props.app_xml, '//Application', ui.application_name_box.text())
xml.set_value(document_props.app_xml, '//Paragraphs', ui.paragraphs_box.value())
xml.set_value(document_props.app_xml, '//Lines', ui.lines_box.value())
xml.set_value(document_props.app_xml, '//Characters', ui.symbols_box.value())
xml.set_value(document_props.app_xml, '//Words', ui.words_box.value())
xml.set_value(document_props.app_xml, '//Pages', ui.pages_box.value())
xml.set_value(document_props.app_xml, '//TotalTime', ui.custom_edit_time_box.value())
xml.set_value(document_props.app_xml, '//Template', ui.template_box.text())
xml.set_value(
document_props.core_xml, 'dcterms:modified',
datetime.datetime.combine(ui.dateandtime_edited_box.date().toPython(),
ui.dateandtime_edited_box.time().toPython()
).strftime('%Y-%m-%dT%H:%M:%SZ')
)
xml.set_value(
document_props.core_xml, 'dcterms:created',
datetime.datetime.combine(ui.dateandtime_created_box.date().toPython(),
ui.dateandtime_created_box.time().toPython()
).strftime('%Y-%m-%dT%H:%M:%SZ')
)
xml.set_value(document_props.core_xml, 'cp:revision', ui.revision_box.text())
xml.set_value(document_props.core_xml, 'cp:lastModifiedBy', ui.last_modified_by_box.text())
xml.set_value(document_props.core_xml, 'dc:creator', ui.creator_box.text())
document_props.core_xml.write(document_props.extracted_document.core)
document_props.app_xml.write(document_props.extracted_document.app)
document_props.extracted_document.pack(ui.save_to_box.text())
update_button(ui)

View File

@@ -0,0 +1,35 @@
from PySide6 import QtCore
from gui.gui import Ui_MainWindow
from modules.document.document_properties import DocumentProps
def fill_gui(ui: Ui_MainWindow, document_props: DocumentProps):
if not document_props.parsed_:
return
ui.remove_objects.append(document_props.extracted_document)
ui.save_to_box.setText(ui.path_to_original_box.text())
ui.creator_box.setText(document_props.creator)
ui.last_modified_by_box.setText(document_props.last_modified_by)
ui.dateandtime_created_box.setDateTime(
QtCore.QDateTime(QtCore.QDate(document_props.created.date()), QtCore.QTime(document_props.created.time()))
)
ui.dateandtime_edited_box.setDateTime(
QtCore.QDateTime(QtCore.QDate(document_props.modified.date()), QtCore.QTime(document_props.modified.time()))
)
ui.revision_box.setText(document_props.revision)
ui.template_box.setText(document_props.template)
ui.pages_box.setValue(document_props.pages)
ui.words_box.setValue(document_props.words)
ui.symbols_box.setValue(document_props.characters)
ui.lines_box.setValue(document_props.lines)
ui.paragraphs_box.setValue(document_props.paragraphs)
ui.application_name_box.setText(document_props.application)
ui.custom_edit_time_box.setValue(document_props.total_time)
ui.document = document_props
ui.save_button.setEnabled(True)