diff --git a/umbrello/CMakeLists.txt b/umbrello/CMakeLists.txt index 6c3f0105f..d699af4ff 100644 --- a/umbrello/CMakeLists.txt +++ b/umbrello/CMakeLists.txt @@ -1,680 +1,681 @@ add_subdirectory( headings ) add_subdirectory(docgenerators) if(ENABLE_OBJECT_DIAGRAM) set(ACTION_NEW_OBJECT_DIAGRAM "") endif() configure_file(umbrelloui.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/umbrelloui.rc @ONLY) if(BUILD_KF5) configure_file(ui.qrc.cmake ${CMAKE_CURRENT_BINARY_DIR}/ui.qrc @ONLY) endif() ########### set variables ############# # Some definitions for experimental code or debugging # TODO migrate debug settings to DEBUG_REGISTER macro #add_definitions(-DXMI_FLAT_PACKAGES) # umlobject #add_definitions(-DDEBUG_LVITEM_INSERTION_ORDER) # umllistviewitem #add_definitions(-DTRY_BUGFIX_120682) # model_utils #add_definitions(-DVERBOSE_DEBUGGING) # listpopupmenu, association, petaltree2uml, # umlobject, umldoc, classifierlistpage if(UNIX) add_definitions(-D_GLIBCXX_PERMIT_BACKWARD_HASH) endif() add_definitions(-DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}") add_definitions(-DDOCGENERATORS_DIR="${CMAKE_SOURCE_DIR}/umbrello/docgenerators") add_definitions(-DUMBRELLOUI_RC="${CMAKE_CURRENT_BINARY_DIR}/umbrelloui.rc") include_directories( ${LIBXML2_INCLUDE_DIR} ${LIBXSLT_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/ ${CMAKE_CURRENT_SOURCE_DIR}/clipboard/ ${CMAKE_CURRENT_SOURCE_DIR}/cmds ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/ada/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/as/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/cpp/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/csharp/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/d/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/idl/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/java/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/js/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/pascal/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/perl/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/php/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/python/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/ruby/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/sql/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/tcl/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/vala/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/xml/ ${CMAKE_CURRENT_SOURCE_DIR}/codegenwizard/ ${CMAKE_CURRENT_SOURCE_DIR}/codeimport/ ${CMAKE_CURRENT_SOURCE_DIR}/codeimport/csharp/ ${CMAKE_CURRENT_SOURCE_DIR}/codeimpwizard/ ${CMAKE_CURRENT_SOURCE_DIR}/debug/ ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/ ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/pages/ ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/widgets/ ${CMAKE_CURRENT_SOURCE_DIR}/docgenerators/ ${CMAKE_CURRENT_SOURCE_DIR}/finder/ ${CMAKE_CURRENT_SOURCE_DIR}/refactoring/ ${CMAKE_CURRENT_SOURCE_DIR}/uml1model/ ${CMAKE_CURRENT_SOURCE_DIR}/umlwidgets/ ${CMAKE_CURRENT_SOURCE_DIR}/menus ${CMAKE_SOURCE_DIR}/lib/cppparser/ ${CMAKE_SOURCE_DIR}/lib/interfaces/ ) set(libdebug_SRCS debug/debug_utils.cpp ) set(libcodegenerator_SRCS codegenerators/advancedcodegenerator.cpp codegenerators/classifiercodedocument.cpp codegenerators/codeaccessormethod.cpp codegenerators/codeblock.cpp codegenerators/codeblockwithcomments.cpp codegenerators/codeclassfield.cpp codegenerators/codeclassfielddeclarationblock.cpp codegenerators/codecomment.cpp codegenerators/codedocument.cpp codegenerators/codegenerationpolicy.cpp codegenerators/codegenerator.cpp codegenerators/codegenfactory.cpp codegenerators/codegenobjectwithtextblocks.cpp codegenerators/codegenpolicyext.cpp codegenerators/codegen_utils.cpp codegenerators/codemethodblock.cpp codegenerators/codeoperation.cpp codegenerators/codeparameter.cpp codegenerators/ada/adawriter.cpp codegenerators/as/aswriter.cpp codegenerators/cpp/cppcodeclassfield.cpp codegenerators/cpp/cppcodecomment.cpp codegenerators/cpp/cppcodedocumentation.cpp codegenerators/cpp/cppcodegenerationform.cpp codegenerators/cpp/cppcodegenerationpolicy.cpp codegenerators/cpp/cppcodegenerationpolicypage.cpp codegenerators/cpp/cppcodegenerator.cpp codegenerators/cpp/cppheaderclassdeclarationblock.cpp codegenerators/cpp/cppheadercodeaccessormethod.cpp codegenerators/cpp/cppheadercodeclassfielddeclarationblock.cpp codegenerators/cpp/cppheadercodedocument.cpp codegenerators/cpp/cppheadercodeoperation.cpp codegenerators/cpp/cppmakecodedocument.cpp codegenerators/cpp/cppsourcecodeaccessormethod.cpp codegenerators/cpp/cppsourcecodeclassfielddeclarationblock.cpp codegenerators/cpp/cppsourcecodedocument.cpp codegenerators/cpp/cppsourcecodeoperation.cpp codegenerators/cpp/cppwriter.cpp codegenerators/csharp/csharpwriter.cpp codegenerators/d/dclassdeclarationblock.cpp codegenerators/d/dclassifiercodedocument.cpp codegenerators/d/dcodeaccessormethod.cpp codegenerators/d/dcodeclassfield.cpp codegenerators/d/dcodeclassfielddeclarationblock.cpp codegenerators/d/dcodecomment.cpp codegenerators/d/dcodedocumentation.cpp codegenerators/d/dcodegenerationpolicy.cpp codegenerators/d/dcodegenerationpolicypage.cpp codegenerators/d/dcodegenerator.cpp codegenerators/d/dcodeoperation.cpp codegenerators/d/dwriter.cpp codegenerators/hierarchicalcodeblock.cpp codegenerators/idl/idlwriter.cpp codegenerators/java/javaantcodedocument.cpp codegenerators/java/javaclassdeclarationblock.cpp codegenerators/java/javaclassifiercodedocument.cpp codegenerators/java/javacodeaccessormethod.cpp codegenerators/java/javacodeclassfield.cpp codegenerators/java/javacodeclassfielddeclarationblock.cpp codegenerators/java/javacodecomment.cpp codegenerators/java/javacodedocumentation.cpp codegenerators/java/javacodegenerationpolicy.cpp codegenerators/java/javacodegenerationpolicypage.cpp codegenerators/java/javacodegenerator.cpp codegenerators/java/javacodeoperation.cpp codegenerators/java/javawriter.cpp codegenerators/js/jswriter.cpp codegenerators/ownedcodeblock.cpp codegenerators/ownedhierarchicalcodeblock.cpp codegenerators/pascal/pascalwriter.cpp codegenerators/perl/perlwriter.cpp codegenerators/php/php5writer.cpp codegenerators/php/phpwriter.cpp codegenerators/python/pythonwriter.cpp codegenerators/ruby/rubyclassdeclarationblock.cpp codegenerators/ruby/rubyclassifiercodedocument.cpp codegenerators/ruby/rubycodeaccessormethod.cpp codegenerators/ruby/rubycodeclassfield.cpp codegenerators/ruby/rubycodeclassfielddeclarationblock.cpp codegenerators/ruby/rubycodecomment.cpp codegenerators/ruby/rubycodedocumentation.cpp codegenerators/ruby/rubycodegenerationpolicy.cpp codegenerators/ruby/rubycodegenerationpolicypage.cpp codegenerators/ruby/rubycodegenerator.cpp codegenerators/ruby/rubycodeoperation.cpp codegenerators/ruby/rubywriter.cpp codegenerators/simplecodegenerator.cpp codegenerators/sql/mysqlwriter.cpp codegenerators/sql/postgresqlwriter.cpp codegenerators/sql/sqlwriter.cpp codegenerators/tcl/tclwriter.cpp codegenerators/textblock.cpp codegenerators/vala/valawriter.cpp codegenerators/xml/xmlcodecomment.cpp codegenerators/xml/xmlelementcodeblock.cpp codegenerators/xml/xmlschemawriter.cpp ) ki18n_wrap_ui( libcodegenerator_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/cpp/cppcodegenerationformbase.ui ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/d/dcodegenerationformbase.ui ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/java/javacodegenerationformbase.ui ${CMAKE_CURRENT_SOURCE_DIR}/codegenerators/ruby/rubycodegenerationformbase.ui ) set(libdocgenerator_SRCS docgenerators/docbook2xhtmlgeneratorjob.cpp docgenerators/docbookgenerator.cpp docgenerators/docbookgeneratorjob.cpp docgenerators/xhtmlgenerator.cpp ) set(libdialogs_SRCS dialogs/activitydialog.cpp dialogs/associationpropertiesdialog.cpp dialogs/classpropertiesdialog.cpp dialogs/classwizard.cpp dialogs/codeeditor.cpp dialogs/codetextedit.cpp dialogs/codetexthighlighter.cpp dialogs/codeviewerdialog.cpp dialogs/diagramselectiondialog.cpp dialogs/dialog_utils.cpp dialogs/dontaskagain.cpp dialogs/exportallviewsdialog.cpp dialogs/finddialog.cpp dialogs/messagewidgetpropertiesdialog.cpp dialogs/multipagedialogbase.cpp dialogs/notedialog.cpp dialogs/objectnodedialog.cpp dialogs/overwritedialog.cpp dialogs/parameterpropertiesdialog.cpp dialogs/selectoperationdialog.cpp dialogs/settingsdialog.cpp dialogs/singlepagedialogbase.cpp dialogs/statedialog.cpp dialogs/umlattributedialog.cpp dialogs/umlinstanceattributedialog.cpp dialogs/umlcheckconstraintdialog.cpp dialogs/umlentityattributedialog.cpp dialogs/umlenumliteraldialog.cpp dialogs/umlfiledialog.cpp dialogs/umlforeignkeyconstraintdialog.cpp dialogs/umloperationdialog.cpp dialogs/umlroledialog.cpp dialogs/umltemplatedialog.cpp dialogs/umluniqueconstraintdialog.cpp dialogs/umlviewdialog.cpp dialogs/pages/activitypage.cpp dialogs/pages/notepage.cpp dialogs/pages/associationgeneralpage.cpp dialogs/pages/associationrolepage.cpp dialogs/pages/autolayoutoptionpage.cpp dialogs/pages/classassociationspage.cpp dialogs/pages/classgeneralpage.cpp dialogs/pages/classifierlistpage.cpp dialogs/pages/classoptionspage.cpp dialogs/pages/codegenerationpolicypage.cpp dialogs/pages/codeimportoptionspage.cpp dialogs/pages/codevieweroptionspage.cpp dialogs/pages/constraintlistpage.cpp dialogs/pages/defaultcodegenpolicypage.cpp dialogs/pages/diagramprintpage.cpp dialogs/pages/diagrampropertiespage.cpp dialogs/pages/dialogpagebase.cpp dialogs/pages/generaloptionpage.cpp dialogs/pages/packagecontentspage.cpp dialogs/pages/selectoperationpage.cpp dialogs/pages/uioptionspage.cpp dialogs/pages/umlroleproperties.cpp dialogs/pages/umlwidgetstylepage.cpp dialogs/widgets/documentationwidget.cpp dialogs/widgets/imagetypewidget.cpp dialogs/widgets/resolutionwidget.cpp dialogs/widgets/umlartifacttypewidget.cpp dialogs/widgets/umldatatypewidget.cpp dialogs/widgets/defaultvaluewidget.cpp dialogs/widgets/umlobjectnamewidget.cpp dialogs/widgets/umlpackagewidget.cpp dialogs/widgets/umlstereotypewidget.cpp dialogs/widgets/visibilityenumwidget.cpp ) ki18n_wrap_ui( libdialogs_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/codeviewerdialogbase.ui ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/codevieweroptionsbase.ui ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/exportallviewsdialogbase.ui ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/finddialog.ui ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/pages/autolayoutoptionpage.ui ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/pages/codeimportoptionspage.ui ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/pages/diagrampropertiespage.ui ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/pages/umlrolepropertiesbase.ui ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/umlinstanceattributedialog.ui ) set(librefactoring_SRCS refactoring/refactoringassistant.cpp ) set(libcodegenwizard_SRCS codegenwizard/codegenerationwizard.cpp codegenwizard/codegenoptionspage.cpp codegenwizard/codegenselectpage.cpp codegenwizard/codegenstatuspage.cpp ) ki18n_wrap_ui( libcodegenwizard_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/codegenwizard/codegenoptionspage.ui ${CMAKE_CURRENT_SOURCE_DIR}/codegenwizard/codegenselectpage.ui ${CMAKE_CURRENT_SOURCE_DIR}/codegenwizard/codegenstatuspage.ui ) set(libcodeimpwizard_SRCS codeimpwizard/codeimportingwizard.cpp codeimpwizard/codeimpselectpage.cpp codeimpwizard/codeimpstatuspage.cpp codeimpwizard/codeimpthread.cpp ) ki18n_wrap_ui( libcodeimpwizard_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/codeimpwizard/codeimpselectpage.ui ${CMAKE_CURRENT_SOURCE_DIR}/codeimpwizard/codeimpstatuspage.ui ) set(libcodeimport_SRCS codeimport/adaimport.cpp codeimport/classimport.cpp codeimport/idlimport.cpp codeimport/import_utils.cpp codeimport/javaimport.cpp codeimport/nativeimportbase.cpp codeimport/pascalimport.cpp codeimport/pythonimport.cpp codeimport/sqlimport.cpp codeimport/csharp/csharpimport.cpp ) if(BUILD_PHP_IMPORT) list(APPEND libcodeimport_SRCS codeimport/phpimport.cpp ) endif() list(APPEND libcodeimport_SRCS codeimport/cppimport.cpp ) set(libkdevcppparser_SRCS ${CMAKE_SOURCE_DIR}/lib/cppparser/ast.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/ast_utils.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/cachemanager.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/driver.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/errors.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/lexer.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/lexercache.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/lookup.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/parser.cpp ${CMAKE_SOURCE_DIR}/lib/cppparser/tree_parser.cpp ${CMAKE_SOURCE_DIR}/lib/interfaces/hashedstring.cpp codeimport/kdevcppparser/cpptree2uml.cpp ) add_library(codeimport STATIC ${libcodeimport_SRCS} ${libkdevcppparser_SRCS}) if(NOT BUILD_KF5) if(BUILD_PHP_IMPORT) target_link_libraries(codeimport ${KDEVPLATFORM_INTERFACES_LIBRARIES} ${KDEVPLATFORM_LANGUAGE_LIBRARIES} ${KDEVPLATFORM_OUTPUTVIEW_LIBRARIES} ${KDEVPLATFORM_PROJECT_LIBRARIES} ${KDEVPLATFORM_SUBLIME_LIBRARIES} ${KDEVPLATFORM_SHELL_LIBRARIES} ${KDEVPLATFORM_UTIL_LIBRARIES} ${KDEVPLATFORM_VCS_LIBRARIES} ${KDEVPLATFORM_DEBUGGER_LIBRARIES} ${KDEVPLATFORM_DOCUMENTATION_LIBRARIES} ${KDEVPLATFORM_TESTS_LIBRARIES} ${KDEVPLATFORM_JSONTESTS_LIBRARIES} kdev4phpparser ) endif() else() target_link_libraries(codeimport KF5::KDELibs4Support ) if(BUILD_PHP_IMPORT) target_link_libraries(codeimport KDev::Interfaces KDev::Language KDev::Tests kdevphpparser ) endif() endif() set(libclipboard_SRCS clipboard/idchangelog.cpp clipboard/umlclipboard.cpp clipboard/umldragdata.cpp ) set(libcmds_SRCS cmds/cmdbaseobjectcommand.cpp cmds/cmdcreatediagram.cpp cmds/cmdhandlerename.cpp cmds/cmdremovediagram.cpp cmds/cmdsetstereotype.cpp cmds/cmdsetvisibility.cpp cmds/generic/cmdrenameumlinstancetype.cpp cmds/generic/cmdcreateumlobject.cpp cmds/generic/cmdremoveumlobject.cpp cmds/generic/cmdrenameumlobject.cpp cmds/widget/cmdbasewidgetcommand.cpp cmds/widget/cmdchangefont.cpp cmds/widget/cmdchangetextcolor.cpp cmds/widget/cmdchangelinecolor.cpp cmds/widget/cmdchangelinewidth.cpp cmds/widget/cmdchangefillcolor.cpp cmds/widget/cmdchangeusefillcolor.cpp cmds/widget/cmdchangemultiplicity.cpp cmds/widget/cmdchangevisualproperty.cpp cmds/widget/cmdcreatewidget.cpp cmds/widget/cmdmovewidget.cpp cmds/widget/cmdresizewidget.cpp cmds/widget/cmdremovewidget.cpp cmds/widget/cmdsetname.cpp cmds/widget/cmdsettxt.cpp ) set(libmenus_SRCS menus/listpopupmenu.cpp menus/umllistviewpopupmenu.cpp menus/umlscenepopupmenu.cpp menus/associationwidgetpopupmenu.cpp menus/widgetbasepopupmenu.cpp menus/dialogspopupmenu.cpp ) set(libumlwidgets_SRCS umlwidgets/activitywidget.cpp umlwidgets/actorwidget.cpp umlwidgets/artifactwidget.cpp umlwidgets/associationwidgetrole.cpp umlwidgets/associationline.cpp umlwidgets/associationwidget.cpp umlwidgets/boxwidget.cpp umlwidgets/categorywidget.cpp umlwidgets/childwidgetplacement.cpp umlwidgets/childwidgetplacementpin.cpp umlwidgets/childwidgetplacementport.cpp umlwidgets/classifierwidget.cpp umlwidgets/combinedfragmentwidget.cpp umlwidgets/componentwidget.cpp umlwidgets/datatypewidget.cpp umlwidgets/diagramproxywidget.cpp umlwidgets/entitywidget.cpp umlwidgets/enumwidget.cpp umlwidgets/floatingdashlinewidget.cpp umlwidgets/floatingtextwidget.cpp umlwidgets/forkjoinwidget.cpp umlwidgets/interfacewidget.cpp umlwidgets/layoutgrid.cpp umlwidgets/linkwidget.cpp umlwidgets/messagewidget.cpp umlwidgets/nodewidget.cpp umlwidgets/notewidget.cpp umlwidgets/objectnodewidget.cpp umlwidgets/objectwidget.cpp umlwidgets/packagewidget.cpp umlwidgets/pinportbase.cpp umlwidgets/pinwidget.cpp umlwidgets/portwidget.cpp umlwidgets/preconditionwidget.cpp umlwidgets/regionwidget.cpp umlwidgets/seqlinewidget.cpp umlwidgets/signalwidget.cpp umlwidgets/statewidget.cpp umlwidgets/toolbarstateonewidget.cpp umlwidgets/umlwidget.cpp umlwidgets/usecasewidget.cpp umlwidgets/widget_factory.cpp umlwidgets/widget_utils.cpp umlwidgets/widgetbase.cpp umlwidgets/widgetlist_utils.cpp umlwidgets/statusbartoolbutton.cpp ) set(libfinder_SRCS finder/findresults.cpp finder/umldocfinder.cpp finder/umlfinder.cpp finder/umllistviewfinder.cpp finder/umlscenefinder.cpp ) set(libuml_SRCS uml1model/actor.cpp uml1model/artifact.cpp uml1model/association.cpp uml1model/attribute.cpp uml1model/category.cpp uml1model/checkconstraint.cpp uml1model/classifier.cpp uml1model/classifierlistitem.cpp uml1model/component.cpp uml1model/datatype.cpp uml1model/entity.cpp uml1model/entityattribute.cpp uml1model/entityconstraint.cpp uml1model/enum.cpp uml1model/enumliteral.cpp uml1model/folder.cpp uml1model/foreignkeyconstraint.cpp uml1model/node.cpp uml1model/operation.cpp uml1model/package.cpp uml1model/port.cpp uml1model/stereotype.cpp uml1model/template.cpp uml1model/umlattributelist.cpp uml1model/umlcanvasobject.cpp uml1model/umlclassifierlistitemlist.cpp uml1model/umlentityattributelist.cpp uml1model/umlentityconstraintlist.cpp uml1model/umlobject.cpp uml1model/umlobjectlist.cpp uml1model/umlrole.cpp uml1model/usecase.cpp uml1model/uniqueconstraint.cpp uml1model/instance.cpp uml1model/instanceattribute.cpp ) set(umbrellobase_SRCS assocrules.cpp basictypes.cpp birdview.cpp codeviewerstate.cpp cmdlineexportallviewsevent.cpp diagramswindow.cpp diagram_utils.cpp + file_utils.cpp objectswindow.cpp docwindow.cpp dotgenerator.cpp icon_utils.cpp import_argo.cpp import_rose.cpp layoutgenerator.cpp model_utils.cpp object_factory.cpp optionstate.cpp petalnode.cpp petaltree2uml.cpp stereotypeswindow.cpp toolbarstatearrow.cpp toolbarstateassociation.cpp toolbarstate.cpp toolbarstatefactory.cpp toolbarstatemessages.cpp toolbarstateother.cpp toolbarstatepool.cpp umlappprivate.cpp uml.cpp umldoc.cpp umllistview.cpp umllistviewitem.cpp umlscene.cpp umlview.cpp umlviewimageexporterall.cpp umlviewimageexporter.cpp umlviewimageexportermodel.cpp uniqueid.cpp worktoolbar.cpp ) set(umbrellomodels_SRCS models/diagramsmodel.cpp models/objectsmodel.cpp models/stereotypesmodel.cpp ) kconfig_add_kcfg_files(umbrellobase_SRCS umbrellosettings.kcfgc) set(libumbrello_SRCS ${libdebug_SRCS} ${libdialogs_SRCS} ${libfinder_SRCS} ${librefactoring_SRCS} ${libcodegenwizard_SRCS} ${libcodeimpwizard_SRCS} ${libclassparser_SRCS} ${libclipboard_SRCS} ${libcodegenerator_SRCS} ${libdocgenerator_SRCS} ${libcmds_SRCS} ${libmenus_SRCS} ${libuml_SRCS} ${libumlwidgets_SRCS} ${umbrellobase_SRCS} ${umbrellomodels_SRCS} ) set(umbrello_SRCS main.cpp ) set(LIB_BUILD_MODE STATIC) if(NOT BUILD_KF5) if(CMAKE_MAJOR_VERSION LESS 3) qt4_add_resources(libumbrello_SRCS icons.qrc) else() list(APPEND libumbrello_SRCS icons.qrc) endif() kde4_add_library(libumbrello ${LIB_BUILD_MODE} ${libumbrello_SRCS}) set_target_properties(libumbrello PROPERTIES OUTPUT_NAME umbrello) target_link_libraries(libumbrello Qt4::QtCore Qt4::QtGui Qt4::QtXml Qt4::QtWebKit ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${KDE4_KTEXTEDITOR_LIBS} ${KDE4_KFILE_LIBS} codeimport ) kde4_add_app_icon(umbrello_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pics/global/hi*-apps-umbrello.png") kde4_add_executable(umbrello ${umbrello_SRCS}) target_link_libraries(umbrello ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${KDE4_KTEXTEDITOR_LIBS} ${KDE4_KFILE_LIBS} libumbrello) else() if(CMAKE_MAJOR_VERSION LESS 3) qt5_add_resources(libumbrello_SRCS icons.qrc ${CMAKE_CURRENT_BINARY_DIR}/ui.qrc) else() list(APPEND libumbrello_SRCS icons.qrc ${CMAKE_CURRENT_BINARY_DIR}/ui.qrc) endif() add_library(libumbrello ${LIB_BUILD_MODE} ${libumbrello_SRCS}) set_target_properties(libumbrello PROPERTIES OUTPUT_NAME umbrello) target_link_libraries(libumbrello Qt5::Widgets Qt5::Xml Qt5::PrintSupport Qt5::Svg Qt5::WebKitWidgets KF5::Archive KF5::Completion KF5::CoreAddons KF5::I18n KF5::IconThemes KF5::KIOCore KF5::KDELibs4Support KF5::TextEditor KF5::WidgetsAddons KF5::XmlGui KF5::Crash ${LIBXSLT_LIBRARIES} ${LIBXML2_LIBRARIES} codeimport ) ecm_add_app_icon(umbrello_SRCS ICONS ${CMAKE_CURRENT_SOURCE_DIR}/pics/global/16-apps-umbrello.png ${CMAKE_CURRENT_SOURCE_DIR}/pics/global/22-apps-umbrello.png ${CMAKE_CURRENT_SOURCE_DIR}/pics/global/32-apps-umbrello.png ${CMAKE_CURRENT_SOURCE_DIR}/pics/global/48-apps-umbrello.png ${CMAKE_CURRENT_SOURCE_DIR}/pics/global/64-apps-umbrello.png ${CMAKE_CURRENT_SOURCE_DIR}/pics/global/128-apps-umbrello.png ) add_executable(umbrello ${umbrello_SRCS}) target_link_libraries(umbrello libumbrello KF5::Crash KF5::WindowSystem KF5::KDELibs4Support ) set_target_properties(umbrello PROPERTIES OUTPUT_NAME umbrello5) endif() target_compile_definitions(libumbrello PRIVATE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII) if(LIB_BUILD_MODE EQUAL SHARED) install(TARGETS libumbrello ${INSTALL_TARGETS_DEFAULT_ARGS} ) endif() install(TARGETS umbrello ${INSTALL_TARGETS_DEFAULT_ARGS} ) ########### install files ############# if(NOT BUILD_KF5) install( PROGRAMS org.kde.umbrello.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/umbrelloui.rc DESTINATION ${UMBRELLO_DATA_INSTALL_DIR} ) else() file(READ org.kde.umbrello.desktop UMBRELLO_DESKTOP_OUT) string(REPLACE "Exec=umbrello" "Exec=umbrello5" UMBRELLO_DESKTOP_OUT "${UMBRELLO_DESKTOP_OUT}") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/org.kde.umbrello.desktop "${UMBRELLO_DESKTOP_OUT}") install( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.umbrello.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) install(FILES org.kde.umbrello.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) endif() install( DIRECTORY layouts DESTINATION ${UMBRELLO_DATA_INSTALL_DIR} PATTERN .svn EXCLUDE ) add_subdirectory( pics ) diff --git a/umbrello/docgenerators/docbook2xhtmlgeneratorjob.cpp b/umbrello/docgenerators/docbook2xhtmlgeneratorjob.cpp index f64a43517..93eb284c8 100644 --- a/umbrello/docgenerators/docbook2xhtmlgeneratorjob.cpp +++ b/umbrello/docgenerators/docbook2xhtmlgeneratorjob.cpp @@ -1,133 +1,112 @@ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * copyright (C) 2007-2014 * * Umbrello UML Modeller Authors * ***************************************************************************/ #include "docbook2xhtmlgeneratorjob.h" #include "debug_utils.h" +#include "file_utils.h" #include "uml.h" #include "umldoc.h" #include "xhtmlgenerator.h" #include #include #include #include #include #include #include #include #include #include // kde includes #include #if QT_VERSION < 0x050000 #include #include #include #endif // qt includes #if QT_VERSION >= 0x050000 #include #include #include #endif #include extern int xmlLoadExtDtdDefaultValue; /** * Constructor * @param docBookUrl The Url of the Docbook that is to be converted to XHtml * @param parent Parent object for QThread constructor */ #if QT_VERSION >= 0x050000 Docbook2XhtmlGeneratorJob::Docbook2XhtmlGeneratorJob(QUrl& docBookUrl, QObject* parent) :QThread(parent), m_docbookUrl(docBookUrl) #else Docbook2XhtmlGeneratorJob::Docbook2XhtmlGeneratorJob(KUrl& docBookUrl, QObject* parent) :QThread(parent), m_docbookUrl(docBookUrl) #endif { } void Docbook2XhtmlGeneratorJob::run() { UMLDoc* umlDoc = UMLApp::app()->document(); xsltStylesheetPtr cur = 0; xmlDocPtr doc, res; const char *params[16 + 1]; int nbparams = 0; params[nbparams] = 0; umlDoc->writeToStatusBar(i18n("Exporting to XHTML...")); QString xsltFileName = XhtmlGenerator::customXslFile(); - uDebug() << "XSLT file is'" << xsltFileName << "'"; - QFile xsltFile(xsltFileName); - xsltFile.open(QIODevice::ReadOnly); - QString xslt = QString::fromLatin1(xsltFile.readAll()); - uDebug() << "XSLT is'" << xslt << "'"; - xsltFile.close(); - - QString localXsl = XhtmlGenerator::localDocbookXslFile(); - uDebug() << "Local xsl is'" << localXsl << "'"; - if (!localXsl.isEmpty()) - { - localXsl = QLatin1String("href=\"file://") + localXsl + QLatin1String("\""); - xslt.replace(QRegExp(QLatin1String("href=\"http://[^\"]*\"")), localXsl); - } -#if QT_VERSION >= 0x050000 - QTemporaryFile tmpXsl; -#else - KTemporaryFile tmpXsl; -#endif - tmpXsl.setAutoRemove(false); - tmpXsl.open(); - QTextStream str (&tmpXsl); - str << xslt; - str.flush(); + // use public xml catalogs + xmlLoadCatalogs(File_Utils::xmlCatalogFilePath().toLocal8Bit().constData()); xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; - uDebug() << "Parsing stylesheet " << tmpXsl.fileName(); - cur = xsltParseStylesheetFile((const xmlChar *)tmpXsl.fileName().toLatin1().constData()); + uDebug() << "Parsing stylesheet " << xsltFileName; + cur = xsltParseStylesheetFile((const xmlChar *)xsltFileName.toLatin1().constData()); uDebug() << "Parsing file " << m_docbookUrl.path(); doc = xmlParseFile((const char*)(m_docbookUrl.path().toUtf8())); uDebug() << "Applying stylesheet "; res = xsltApplyStylesheet(cur, doc, params); #if QT_VERSION >= 0x050000 QTemporaryFile tmpXhtml; #else KTemporaryFile tmpXhtml; #endif tmpXhtml.setAutoRemove(false); tmpXhtml.open(); uDebug() << "Writing HTML result to temp file: " << tmpXhtml.fileName(); xsltSaveResultToFd(tmpXhtml.handle(), res, cur); xsltFreeStylesheet(cur); xmlFreeDoc(res); xmlFreeDoc(doc); xsltCleanupGlobals(); xmlCleanupParser(); emit xhtmlGenerated(tmpXhtml.fileName()); } diff --git a/umbrello/docgenerators/docbookgenerator.cpp b/umbrello/docgenerators/docbookgenerator.cpp index d71a96630..8b0e866b2 100644 --- a/umbrello/docgenerators/docbookgenerator.cpp +++ b/umbrello/docgenerators/docbookgenerator.cpp @@ -1,161 +1,181 @@ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * copyright (C) 2006 Gael de Chalendar (aka Kleag) kleag@free.fr * * copyright (C) 2006-2014 * * Umbrello UML Modeller Authors * ***************************************************************************/ #include "docbookgenerator.h" #include "debug_utils.h" #include "docbookgeneratorjob.h" #include "uml.h" #include "umldoc.h" #include "umlviewimageexportermodel.h" #if QT_VERSION >= 0x050000 #include #endif #include #include #if QT_VERSION < 0x050000 #include +#include #endif #include #include #include #include #include /** * Constructor. */ DocbookGenerator::DocbookGenerator() { umlDoc = UMLApp::app()->document(); m_pStatus = true; m_pThreadFinished = false; docbookGeneratorJob = 0; } /** * Destructor. */ DocbookGenerator::~DocbookGenerator() { } /** * Exports the current model to docbook in a directory named as the model * with the .xmi suffix removed. The docbook file will have the same name * with the .docbook suffix. Figures will be named as the corresponding * diagrams in the GUI * @todo change file naming to avoid paths with spaces or non-ASCII chars * @todo better handling of error conditions * @return true if saving is successful and false otherwise. */ bool DocbookGenerator::generateDocbookForProject() { #if QT_VERSION >= 0x050000 QUrl url = umlDoc->url(); #else KUrl url = umlDoc->url(); #endif QString fileName = url.fileName(); fileName.remove(QRegExp(QLatin1String(".xmi$"))); #if QT_VERSION >= 0x050000 url.setPath(url.path() + QLatin1Char('/') + fileName); #else url.setFileName(fileName); #endif uDebug() << "Exporting to directory: " << url; generateDocbookForProjectInto(url); return true; } /** * Exports the current model to docbook in the given directory * @param destDir the directory where the docbook file and the figures will * be written * @todo better handling of error conditions * @return true if saving is successful and false otherwise. */ #if QT_VERSION >= 0x050000 void DocbookGenerator::generateDocbookForProjectInto(const QUrl& destDir) #else void DocbookGenerator::generateDocbookForProjectInto(const KUrl& destDir) #endif { m_destDir = destDir; umlDoc->writeToStatusBar(i18n("Exporting all views...")); UMLViewList views = UMLApp::app()->document()->viewIterator(); QStringList errors = UMLViewImageExporterModel().exportViews(views, UMLViewImageExporterModel::mimeTypeToImageType(QLatin1String("image/png")), destDir, false); if (!errors.empty()) { KMessageBox::errorList(UMLApp::app(), i18n("Some errors happened when exporting the images:"), errors); return; } umlDoc->writeToStatusBar(i18n("Generating Docbook...")); docbookGeneratorJob = new DocbookGeneratorJob(this); connect(docbookGeneratorJob, SIGNAL(docbookGenerated(QString)), this, SLOT(slotDocbookGenerationFinished(QString))); connect(docbookGeneratorJob, SIGNAL(finished()), this, SLOT(threadFinished())); uDebug()<<"Threading"; docbookGeneratorJob->start(); } void DocbookGenerator::slotDocbookGenerationFinished(const QString& tmpFileName) { uDebug() << "Generation Finished" << tmpFileName; #if QT_VERSION >= 0x050000 QUrl url = umlDoc->url(); #else KUrl url = umlDoc->url(); #endif QString fileName = url.fileName(); fileName.replace(QRegExp(QLatin1String(".xmi$")), QLatin1String(".docbook")); #if QT_VERSION >= 0x050000 url.setPath(m_destDir.path() + QLatin1Char('/') + fileName); #else url.setPath(m_destDir.path()); url.addPath(fileName); #endif #if QT_VERSION >= 0x050000 KIO::Job* job = KIO::file_copy(QUrl::fromLocalFile(tmpFileName), url, -1, KIO::Overwrite | KIO::HideProgressInfo); KJobWidgets::setWindow(job, (QWidget*)UMLApp::app()); job->exec(); if (!job->error()) { #else KIO::Job* job = KIO::file_copy(KUrl::fromPath(tmpFileName), url, -1, KIO::Overwrite | KIO::HideProgressInfo); if (KIO::NetAccess::synchronousRun(job, (QWidget*)UMLApp::app())) { #endif umlDoc->writeToStatusBar(i18n("Docbook Generation Complete...")); m_pStatus = true; } else { umlDoc->writeToStatusBar(i18n("Docbook Generation Failed...")); m_pStatus = false; } while (m_pThreadFinished == false) { // wait for thread to finish qApp->processEvents(); } emit finished(m_pStatus); } void DocbookGenerator::threadFinished() { m_pThreadFinished = true; delete docbookGeneratorJob; docbookGeneratorJob = 0; } +/** + * return custom xsl file for generating docbook + * + * @return filename with path + */ +QString DocbookGenerator::customXslFile() +{ + QString xslBaseName = QLatin1String("xmi2docbook.xsl"); +#if QT_VERSION >= 0x050000 + QString xsltFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("umbrello5/") + xslBaseName)); +#else + QString xsltFile(KGlobal::dirs()->findResource("data", QLatin1String("umbrello/") + xslBaseName)); +#endif + if (xsltFile.isEmpty()) + xsltFile = QLatin1String(DOCGENERATORS_DIR) + QLatin1Char('/') + xslBaseName; + + uDebug() << "XSLT file is'" << xsltFile << "'"; + return xsltFile; +} diff --git a/umbrello/docgenerators/docbookgenerator.h b/umbrello/docgenerators/docbookgenerator.h index 07260f47d..1957fcca6 100644 --- a/umbrello/docgenerators/docbookgenerator.h +++ b/umbrello/docgenerators/docbookgenerator.h @@ -1,77 +1,78 @@ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * copyright (C) 2006 Gael de Chalendar (aka Kleag) kleag@free.fr * * copyright (C) 2006-2007 * * Umbrello UML Modeller Authors * ***************************************************************************/ #ifndef DOCBOOKGENERATOR_H #define DOCBOOKGENERATOR_H #include #if QT_VERSION < 0x050000 #include #endif #include #if QT_VERSION >= 0x050000 #include #endif class UMLDoc; class DocbookGeneratorJob; /** * class DocbookGenerator is a documentation generator for UML documents. * It uses libxslt to convert the XMI generated by UMLDoc::saveToXMI1 through * the XSLT file stored in resources. * * @todo Add configure checks for libxml2 and libxslt and use conditional * compilation of this library and its callers * @todo allow to specify the destination and ensure that it works with distant * ones */ class DocbookGenerator : public QObject { Q_OBJECT public: DocbookGenerator(); virtual ~DocbookGenerator(); bool generateDocbookForProject(); #if QT_VERSION >= 0x050000 void generateDocbookForProjectInto(const QUrl& destDir); #else void generateDocbookForProjectInto(const KUrl& destDir); #endif - signals: + static QString customXslFile(); +signals: void finished(bool status); private slots: void slotDocbookGenerationFinished(const QString&); void threadFinished(); private: DocbookGeneratorJob* docbookGeneratorJob; bool m_pStatus; bool m_pThreadFinished; #if QT_VERSION >= 0x050000 QUrl m_destDir; #else KUrl m_destDir; #endif UMLDoc* umlDoc; }; #endif // DOCBOOKGENERATOR_H diff --git a/umbrello/docgenerators/docbookgeneratorjob.cpp b/umbrello/docgenerators/docbookgeneratorjob.cpp index aa161bb85..a9df2f6d7 100644 --- a/umbrello/docgenerators/docbookgeneratorjob.cpp +++ b/umbrello/docgenerators/docbookgeneratorjob.cpp @@ -1,204 +1,207 @@ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * copyright (C) 2008-2014 * * Umbrello UML Modeller Authors * ***************************************************************************/ #include "docbookgeneratorjob.h" +#include "docbookgenerator.h" #include "debug_utils.h" +#include "file_utils.h" #include "uml.h" #include "umldoc.h" #include #include #include #include #include #include #include #include #include #include // kde includes #if QT_VERSION < 0x050000 #include #include #endif #include // qt includes #include #if QT_VERSION >= 0x050000 #include #include #endif extern int xmlLoadExtDtdDefaultValue; #define MAX_PATHS 64 xmlExternalEntityLoader defaultEntityLoader = NULL; static xmlChar *paths[MAX_PATHS + 1]; static int nbpaths = 0; static QHash replaceURLList; /* * Entity loading control and customization. * taken from kdelibs/kdoctools/xslt.cpp */ static xmlParserInputPtr xsltprocExternalEntityLoader(const char *_URL, const char *ID,xmlParserCtxtPtr ctxt) { xmlParserInputPtr ret; warningSAXFunc warning = NULL; // use local available dtd versions instead of fetching it everytime from the internet QString url = QLatin1String(_URL); QHash::const_iterator i; for(i = replaceURLList.constBegin(); i != replaceURLList.constEnd(); i++) { if (url.startsWith(i.key())) { url.replace(i.key(),i.value()); qDebug() << "converted" << _URL << "to" << url; } } char URL[1024]; strcpy(URL,url.toLatin1().constData()); const char *lastsegment = URL; const char *iter = URL; if (nbpaths > 0) { while (*iter != 0) { if (*iter == '/') lastsegment = iter + 1; iter++; } } if ((ctxt != NULL) && (ctxt->sax != NULL)) { warning = ctxt->sax->warning; ctxt->sax->warning = NULL; } if (defaultEntityLoader != NULL) { ret = defaultEntityLoader(URL, ID, ctxt); if (ret != NULL) { if (warning != NULL) ctxt->sax->warning = warning; qDebug() << "Loaded URL=\"" << URL << "\" ID=\"" << ID << "\""; return(ret); } } for (int i = 0;i < nbpaths;i++) { xmlChar *newURL; newURL = xmlStrdup((const xmlChar *) paths[i]); newURL = xmlStrcat(newURL, (const xmlChar *) "/"); newURL = xmlStrcat(newURL, (const xmlChar *) lastsegment); if (newURL != NULL) { ret = defaultEntityLoader((const char *)newURL, ID, ctxt); if (ret != NULL) { if (warning != NULL) ctxt->sax->warning = warning; qDebug() << "Loaded URL=\"" << newURL << "\" ID=\"" << ID << "\""; xmlFree(newURL); return(ret); } xmlFree(newURL); } } if (warning != NULL) { ctxt->sax->warning = warning; if (URL != NULL) warning(ctxt, "failed to load external entity \"%s\"\n", URL); else if (ID != NULL) warning(ctxt, "failed to load external entity \"%s\"\n", ID); } return(NULL); } DocbookGeneratorJob::DocbookGeneratorJob(QObject* parent): QThread(parent) { } void DocbookGeneratorJob::run() { UMLApp* app = UMLApp::app(); UMLDoc* umlDoc = app->document(); //write the XMI model in an in-memory char* string QString xmi; QTextStream xmiStream(&xmi, QIODevice::WriteOnly); #if QT_VERSION >= 0x050000 QTemporaryFile file; // we need this tmp file if we are writing to a remote file #else KTemporaryFile file; // we need this tmp file if we are writing to a remote file #endif file.setAutoRemove(false); // lets open the file for writing if (!file.open()) { uError() << "There was a problem saving file" << file.fileName(); return; } umlDoc->saveToXMI1(file); // save the xmi stuff to it xsltStylesheetPtr cur = 0; xmlDocPtr doc, res; const char *params[16 + 1]; int nbparams = 0; params[nbparams] = 0; - QString xslBaseName = QLatin1String("xmi2docbook.xsl"); -#if QT_VERSION >= 0x050000 - QString xsltFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("umbrello5/") + xslBaseName)); -#else - QString xsltFile(KGlobal::dirs()->findResource("data", QLatin1String("umbrello/") + xslBaseName)); -#endif - if (xsltFile.isEmpty()) - xsltFile = QLatin1String(DOCGENERATORS_DIR) + QLatin1Char('/') + xslBaseName; + // use public xml catalogs + xmlLoadCatalogs(File_Utils::xmlCatalogFilePath().toLocal8Bit().constData()); + + // replace external uri for docbook.xsl + QString docBookUrl = QLatin1String("http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"); + xmlChar *localDocBookURI = xmlCatalogResolveURI((const xmlChar *)docBookUrl.toLocal8Bit().constData()); + replaceURLList[docBookUrl] = QString(QLatin1String((const char *)localDocBookURI)); + + QString xsltFile = DocbookGenerator::customXslFile(); if (!defaultEntityLoader) { defaultEntityLoader = xmlGetExternalEntityLoader(); xmlSetExternalEntityLoader(xsltprocExternalEntityLoader); QFileInfo xsltFilePath(xsltFile); replaceURLList[QLatin1String("http://www.oasis-open.org/docbook/xml/simple/4.1.2.5/sdocbook.dtd")] = QString(QLatin1String("file:///%1/simple4125/sdocbook.dtd")).arg(xsltFilePath.absolutePath()); } xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; cur = xsltParseStylesheetFile((const xmlChar *)xsltFile.toLatin1().constData()); doc = xmlParseFile((const char*)(file.fileName().toUtf8())); res = xsltApplyStylesheet(cur, doc, params); #if QT_VERSION >= 0x050000 QTemporaryFile tmpDocBook; #else KTemporaryFile tmpDocBook; #endif tmpDocBook.setAutoRemove(false); tmpDocBook.open(); umlDoc->writeToStatusBar(i18n("Exporting to DocBook...")); xsltSaveResultToFd(tmpDocBook.handle(), res, cur); xsltFreeStylesheet(cur); xmlFreeDoc(res); xmlFreeDoc(doc); xsltCleanupGlobals(); xmlCleanupParser(); emit docbookGenerated(tmpDocBook.fileName()); } diff --git a/umbrello/docgenerators/xhtmlgenerator.cpp b/umbrello/docgenerators/xhtmlgenerator.cpp index 975475a0e..ddeed82e4 100644 --- a/umbrello/docgenerators/xhtmlgenerator.cpp +++ b/umbrello/docgenerators/xhtmlgenerator.cpp @@ -1,269 +1,252 @@ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * copyright (C) 2006 Gael de Chalendar (aka Kleag) kleag@free.fr * * copyright (C) 2006-2014 * * Umbrello UML Modeller Authors * ***************************************************************************/ #include "xhtmlgenerator.h" #include "debug_utils.h" #include "docbook2xhtmlgeneratorjob.h" #include "uml.h" #include "umldoc.h" #include "umlviewimageexportermodel.h" #include "docbookgenerator.h" #if QT_VERSION >= 0x050000 #include #endif #include #include #if QT_VERSION < 0x050000 #include #include #endif #include #include #include #include #if QT_VERSION >= 0x050000 #include #endif #include /** * Constructor. */ XhtmlGenerator::XhtmlGenerator() { m_umlDoc = UMLApp::app()->document(); m_pStatus = true; m_pThreadFinished = false; m_d2xg = 0; } /** * Destructor. */ XhtmlGenerator::~XhtmlGenerator() { } /** * Exports the current model to XHTML in a directory named as the model * with the .xmi suffix removed. The XHTML file will have the same name * with the .html suffix. Figures will be named as the corresponding * diagrams in the GUI * @todo change file naming to avoid paths with spaces or non-ASCII chars * @todo better handling of error conditions * @return true if saving is successful and false otherwise. */ bool XhtmlGenerator::generateXhtmlForProject() { #if QT_VERSION >= 0x050000 QUrl url = m_umlDoc->url(); #else KUrl url = m_umlDoc->url(); #endif QString fileName = url.fileName(); fileName.remove(QRegExp(QLatin1String(".xmi$"))); #if QT_VERSION >= 0x050000 url.setPath(fileName); #else url.setFileName(fileName); #endif uDebug() << "Exporting to directory: " << url; return generateXhtmlForProjectInto(url); } /** * Exports the current model to XHTML in the given directory * @param destDir the directory where the XHTML file and the figures will * be written * @todo better handling of error conditions * @return true if saving is successful and false otherwise. */ #if QT_VERSION >= 0x050000 bool XhtmlGenerator::generateXhtmlForProjectInto(const QUrl& destDir) #else bool XhtmlGenerator::generateXhtmlForProjectInto(const KUrl& destDir) #endif { uDebug() << "First convert to docbook"; m_destDir = destDir; // KUrl url(QString("file://")+m_tmpDir.name()); DocbookGenerator* docbookGenerator = new DocbookGenerator; docbookGenerator->generateDocbookForProjectInto(destDir); uDebug() << "Connecting..."; connect(docbookGenerator, SIGNAL(finished(bool)), this, SLOT(slotDocbookToXhtml(bool))); return true; } /** * This slot is triggerd when the first part, xmi to docbook, is finished * @param status status to continue with converting */ void XhtmlGenerator::slotDocbookToXhtml(bool status) { uDebug() << "Now convert docbook to html..."; if (!status) { uDebug() << "Error in converting to docbook"; m_pStatus = false; return; } else { #if QT_VERSION >= 0x050000 QUrl url = m_umlDoc->url(); #else KUrl url = m_umlDoc->url(); #endif QString fileName = url.fileName(); fileName.replace(QRegExp(QLatin1String(".xmi$")), QLatin1String(".docbook")); #if QT_VERSION >= 0x050000 url.setPath(m_destDir.path() + QLatin1Char('/') + fileName); #else url.setPath(m_destDir.path()); url.addPath(fileName); #endif m_umlDoc->writeToStatusBar(i18n("Generating XHTML...")); m_d2xg = new Docbook2XhtmlGeneratorJob(url, this); connect(m_d2xg, SIGNAL(xhtmlGenerated(QString)), this, SLOT(slotHtmlGenerated(QString))); connect(m_d2xg, SIGNAL(finished()), this, SLOT(threadFinished())); uDebug() << "Threading"; m_d2xg->start(); } } /** * Triggered when the copying of the HTML result file is finished. * Emits the signal finished(). * @param tmpFileName temporary file name */ void XhtmlGenerator::slotHtmlGenerated(const QString& tmpFileName) { uDebug() << "HTML Generated " << tmpFileName; #if QT_VERSION >= 0x050000 QUrl url = m_umlDoc->url(); #else KUrl url = m_umlDoc->url(); #endif QString fileName = url.fileName(); fileName.replace(QRegExp(QLatin1String(".xmi$")), QLatin1String(".html")); #if QT_VERSION >= 0x050000 url.setPath(m_destDir.path() + QLatin1Char('/') + fileName); #else url.setPath(m_destDir.path()); url.addPath(fileName); #endif #if QT_VERSION >= 0x050000 KIO::Job* htmlCopyJob = KIO::file_copy(QUrl::fromLocalFile(tmpFileName), url, -1, KIO::Overwrite | KIO::HideProgressInfo); KJobWidgets::setWindow(htmlCopyJob, (QWidget*)UMLApp::app()); htmlCopyJob->exec(); if (!htmlCopyJob->error()) { #else KIO::Job* htmlCopyJob = KIO::file_copy(KUrl::fromPath(tmpFileName), url, -1, KIO::Overwrite | KIO::HideProgressInfo); if (KIO::NetAccess::synchronousRun(htmlCopyJob, (QWidget*)UMLApp::app())) { #endif m_umlDoc->writeToStatusBar(i18n("XHTML Generation Complete...")); } else { m_pStatus = false; return; } m_umlDoc->writeToStatusBar(i18n("Copying CSS...")); QString cssBaseName = QLatin1String("xmi.css"); #if QT_VERSION >= 0x050000 QString cssFileName(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("umbrello5/") + cssBaseName)); #else QString cssFileName(KGlobal::dirs()->findResource("data", QLatin1String("umbrello/") + cssBaseName)); #endif if (cssFileName.isEmpty()) cssFileName = QLatin1String(DOCGENERATORS_DIR) + QLatin1Char('/') + cssBaseName; #if QT_VERSION >= 0x050000 QUrl cssUrl = m_destDir; cssUrl.setPath(cssUrl.path() + QLatin1Char('/') + cssBaseName); #else KUrl cssUrl = m_destDir; cssUrl.addPath(cssBaseName); #endif #if QT_VERSION >= 0x050000 KIO::Job* cssJob = KIO::file_copy(QUrl::fromLocalFile(cssFileName), cssUrl, -1, KIO::Overwrite | KIO::HideProgressInfo); KJobWidgets::setWindow(cssJob, (QWidget*)UMLApp::app()); cssJob->exec(); if (!cssJob->error()) { #else KIO::Job* cssJob = KIO::file_copy(cssFileName, cssUrl, -1, KIO::Overwrite | KIO::HideProgressInfo); if (KIO::NetAccess::synchronousRun(cssJob, (QWidget*)UMLApp::app())) { #endif m_umlDoc->writeToStatusBar(i18n("Finished Copying CSS...")); m_pStatus = true; } else { m_umlDoc->writeToStatusBar(i18n("Failed Copying CSS...")); m_pStatus = false; } while (m_pThreadFinished == false) { // wait for thread to finish qApp->processEvents(); } emit finished(m_pStatus); } /** * Invoked when a thread is finished */ void XhtmlGenerator::threadFinished() { m_pThreadFinished = true; delete m_d2xg; m_d2xg = 0; } -/** - * return local dookbool xsl file for generating html - * - * @return filename if present - */ -QString XhtmlGenerator::localDocbookXslFile() -{ - QString xslFileName = QLatin1String("xml/docbook/stylesheet/nwalsh/current/html/docbook.xsl"); -#if QT_VERSION >= 0x050000 - QString localXsl = QStandardPaths::locate(QStandardPaths::GenericDataLocation, xslFileName); -#else - QString localXsl = KGlobal::dirs()->findResource("data", QLatin1String("../../") + xslFileName); -#endif - QFileInfo fi(localXsl); - return fi.canonicalFilePath(); -} - /** * return custom xsl file for generating html * - * @return filename + * @return filename with path */ QString XhtmlGenerator::customXslFile() { - QString xslBaseName = QLatin1String("docbook2xhtml.xsl"); #if QT_VERSION >= 0x050000 QString xsltFileName(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("umbrello5/") + xslBaseName)); #else QString xsltFileName(KGlobal::dirs()->findResource("data", QLatin1String("umbrello/") + xslBaseName)); #endif if (xsltFileName.isEmpty()) xsltFileName = QLatin1String(DOCGENERATORS_DIR) + QLatin1Char('/') + xslBaseName; + uDebug() << "XSLT file is'" << xsltFileName << "'"; return xsltFileName; } diff --git a/umbrello/docgenerators/xhtmlgenerator.h b/umbrello/docgenerators/xhtmlgenerator.h index f98d6f4f2..925d62625 100644 --- a/umbrello/docgenerators/xhtmlgenerator.h +++ b/umbrello/docgenerators/xhtmlgenerator.h @@ -1,83 +1,82 @@ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * copyright (C) 2006 Gael de Chalendar (aka Kleag) kleag@free.fr * * copyright (C) 2006-2014 * * Umbrello UML Modeller Authors * ***************************************************************************/ #ifndef XHTMLGENERATOR_H #define XHTMLGENERATOR_H #include "basictypes.h" #if QT_VERSION < 0x050000 #include #endif #include #if QT_VERSION >= 0x050000 #include #endif class UMLDoc; class Docbook2XhtmlGeneratorJob; /** * class XhtmlGenerator is a documentation generator for UML documents. * It uses first @ref DocbookGenerator to convert the XMI generated by * UMLDoc::saveToXMI1 to docbook and next libxslt through * the XSLT file stored in resources to convert the docbook file to XHTML. * The latter uses the XSLT available on the Web at * http://docbook.sourceforge.net/release/xsl/snapshot/html/docbook.xsl * * @todo allow to specify the destination and ensure that it works with distant * ones */ class XhtmlGenerator : public QObject { Q_OBJECT public: XhtmlGenerator(); virtual ~XhtmlGenerator(); bool generateXhtmlForProject(); #if QT_VERSION >= 0x050000 bool generateXhtmlForProjectInto(const QUrl& destDir); #else bool generateXhtmlForProjectInto(const KUrl& destDir); #endif - static QString localDocbookXslFile(); static QString customXslFile(); signals: void finished(bool status); protected slots: void slotDocbookToXhtml(bool status); void slotHtmlGenerated(const QString& tmpFileName); void threadFinished(); private: Docbook2XhtmlGeneratorJob* m_d2xg; bool m_pStatus; bool m_pThreadFinished; #if QT_VERSION >= 0x050000 QUrl m_destDir; ///< Destination directory where the final documentation will be written. #else KUrl m_destDir; ///< Destination directory where the final documentation will be written. #endif UMLDoc* m_umlDoc; }; #endif // XHTMLGENERATOR_H diff --git a/umbrello/file_utils.cpp b/umbrello/file_utils.cpp new file mode 100644 index 000000000..14bd0801d --- /dev/null +++ b/umbrello/file_utils.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * copyright (C) 2020 * + * Umbrello UML Modeller Authors * + ***************************************************************************/ + +#include "file_utils.h" + +// app includes +#include "debug_utils.h" + +// qt includes +#include +#include + +namespace File_Utils { + +/** + * returns path to xml catalog + * @return string with file path + */ +QString xmlCatalogFilePath() +{ +#ifdef Q_OS_WIN + QString dataRoot = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/../"); +#else + QString dataRoot = QLatin1String("/etc/xml"); +#endif + QFileInfo fi(dataRoot + QLatin1String("/catalog")); + uDebug() << fi.canonicalFilePath(); + return fi.canonicalFilePath(); +} + +} // namespace File_Utils diff --git a/umbrello/file_utils.h b/umbrello/file_utils.h new file mode 100644 index 000000000..43ef21f49 --- /dev/null +++ b/umbrello/file_utils.h @@ -0,0 +1,20 @@ +/*************************************************************************** + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * copyright (C) 2020 * + * Umbrello UML Modeller Authors * + ***************************************************************************/ + +#ifndef FILE_UTILS_H +#define FILE_UTILS_H + +#include + +namespace File_Utils { + QString xmlCatalogFilePath(); +} + +#endif // FILE_UTILS_H