diff --git a/libs/text/CMakeLists.txt b/libs/text/CMakeLists.txt index 9c33b4c0159..ed96aef3bdc 100644 --- a/libs/text/CMakeLists.txt +++ b/libs/text/CMakeLists.txt @@ -1,298 +1,298 @@ include_directories(${KOTEXT_INCLUDES} ${FONTCONFIG_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIRS} ${KOMAIN_INCLUDES}) add_subdirectory( tests ) add_subdirectory( styles/tests ) ########### next target ############### set(kotext_LIB_SRCS KoDocumentRdfBase.cpp KoText.cpp KoTextBlockData.cpp KoTextBlockBorderData.cpp KoTextBlockPaintStrategyBase.cpp KoTextOdfSaveHelper.cpp KoTextPaste.cpp KoTextDocument.cpp KoTextEditor.cpp KoTextEditor_undo.cpp KoTextEditor_format.cpp KoList.cpp KoTextEditingRegistry.cpp KoTextEditingFactory.cpp KoTextEditingPlugin.cpp KoTextRangeManager.cpp KoInlineTextObjectManager.cpp KoInlineObjectFactoryBase.cpp KoInlineObjectRegistry.cpp InsertInlineObjectActionBase_p.cpp InsertVariableAction.cpp InsertNamedVariableAction.cpp InsertTextReferenceAction.cpp InsertTextLocator.cpp KoInlineObject.cpp KoTextRange.cpp KoVariable.cpp KoVariableManager.cpp KoNamedVariable.cpp KoSection.cpp KoSectionEnd.cpp KoSectionUtils.cpp KoSectionModel.cpp KoTextLocator.cpp KoTextReference.cpp KoAnchorInlineObject.cpp KoAnchorTextRange.cpp KoTextShapeSavingContext.cpp KoAnnotation.cpp KoAnnotationManager.cpp KoBookmark.cpp KoBookmarkManager.cpp KoInlineNote.cpp KoInlineCite.cpp KoTextSoftPageBreak.cpp FindDirection_p.cpp KoFindStrategy.cpp KoReplaceStrategy.cpp KoFind_p.cpp KoFind.cpp KoTextDebug.cpp KoTextPage.cpp KoPageProvider.cpp KoTableColumnAndRowStyleManager.cpp KoTextInlineRdf.cpp KoTextMeta.cpp KoTextTableTemplate.cpp OdfTextTrackStyles.cpp ToCBibGeneratorInfo.cpp KoTableOfContentsGeneratorInfo.cpp KoBibliographyInfo.cpp BibliographyGenerator.cpp styles/Styles_p.cpp styles/KoCharacterStyle.cpp styles/KoParagraphStyle.cpp styles/KoStyleManager.cpp styles/KoListStyle.cpp styles/KoListLevelProperties.cpp styles/KoTableStyle.cpp styles/KoTableColumnStyle.cpp styles/KoTableRowStyle.cpp styles/KoTableCellStyle.cpp styles/KoSectionStyle.cpp opendocument/KoTextSharedLoadingData.cpp opendocument/KoTextSharedSavingData.cpp opendocument/KoTextLoader.cpp opendocument/KoTextWriter_p.cpp opendocument/KoTextWriter.cpp changetracker/KoChangeTracker.cpp changetracker/KoChangeTrackerElement.cpp changetracker/KoFormatChangeInformation.cpp changetracker/KoDeletedRowColumnDataStore.cpp changetracker/KoDeletedRowData.cpp changetracker/KoDeletedColumnData.cpp changetracker/KoDeletedCellData.cpp commands/ChangeAnchorPropertiesCommand.cpp commands/ChangeListCommand.cpp commands/ChangeStylesCommand.cpp commands/ChangeStylesMacroCommand.cpp commands/DeleteAnchorsCommand.cpp commands/DeleteAnnotationsCommand.cpp commands/DeleteCommand.cpp commands/DeleteTableColumnCommand.cpp commands/DeleteTableRowCommand.cpp commands/InsertNoteCommand.cpp commands/InsertTableColumnCommand.cpp commands/InsertTableRowCommand.cpp commands/ResizeTableCommand.cpp commands/InsertInlineObjectCommand.cpp commands/ListItemNumberingCommand.cpp commands/TextPasteCommand.cpp commands/AddTextRangeCommand.cpp commands/AddAnnotationCommand.cpp commands/ParagraphFormattingCommand.cpp commands/RenameSectionCommand.cpp commands/NewSectionCommand.cpp commands/SplitSectionsCommand.cpp mct/MctAbstractGraph.cpp mct/MctAuthor.cpp mct/MctCell.cpp mct/MctChange.cpp mct/MctChangeEntities.cpp mct/MctChangeset.cpp mct/MctDoBase.cpp mct/MctEmbObjProperties.cpp mct/MctNode.cpp mct/MctPosition.cpp mct/MctPropertyBase.cpp mct/MctRedoClass.cpp mct/MctRedoGraph.cpp mct/MctRedoGraphXMLfilter.cpp mct/MctStaticData.cpp mct/MctTableProperties.cpp mct/MctUndoClass.cpp mct/MctUndoGraph.cpp mct/MctUndoGraphXMLfilter.cpp mct/ExtractFile.cpp KoTextDrag.cpp KoTextCommandBase.cpp TextDebug.cpp ) if( SHOULD_BUILD_FEATURE_RDF ) set(kotext_LIB_SRCS ${kotext_LIB_SRCS} KoTextRdfCore.cpp ) endif() -##add_library(kotext STATIC ${kotext_LIB_SRCS}) +#add_library(kotext STATIC ${kotext_LIB_SRCS}) add_library(kotext SHARED ${kotext_LIB_SRCS}) generate_export_header(kotext BASE_NAME kotext) target_link_libraries(kotext PUBLIC flake KF5::TextWidgets KF5::Archive PRIVATE koplugin KF5::WindowSystem # KoFind to activate the window with content found ) if( SHOULD_BUILD_FEATURE_RDF ) target_link_libraries(kotext PRIVATE ${SOPRANO_LIBRARIES}) endif() if( FONTCONFIG_FOUND ) target_link_libraries(kotext PRIVATE ${FONTCONFIG_LIBRARIES}) endif() if( FREETYPE_FOUND ) target_link_libraries(kotext PRIVATE ${FREETYPE_LIBRARIES}) endif() set_target_properties(kotext PROPERTIES VERSION ${GENERIC_CALLIGRA_LIB_VERSION} SOVERSION ${GENERIC_CALLIGRA_LIB_SOVERSION} COMPILE_FLAGS "-fPIC" ) install(TARGETS kotext ${INSTALL_TARGETS_DEFAULT_ARGS}) ########### install files ############### # TODO: with the new embedded JSON data for plugins there is no schema ATM to define extended properties # texteditingplugin.desktop inlinetextobject.desktop if (SHOULD_BUILD_DEVEL_HEADERS) install( FILES KoDocumentRdfBase.h KoInlineObject.h KoTextEditor.h KoTextEditingFactory.h KoTextEditingPlugin.h KoTextEditingRegistry.h KoInlineObjectRegistry.h KoInlineObjectFactoryBase.h KoBookmark.h KoBookmarkManager.h KoAnnotationManager.h KoInlineTextObjectManager.h KoAnchorInlineObject.h KoAnchorTextRange.h KoTextBlockBorderData.h KoTextBlockData.h KoTextDocument.h KoText.h KoTextRange.h KoTextRangeManager.h KoList.h KoTextLocator.h KoTextPage.h KoTextPaste.h KoVariable.h KoVariableManager.h KoTextRdfCore.h KoTextInlineRdf.h KoTextMeta.h KoTextSoftPageBreak.cpp KoSection.h KoSectionEnd.h KoSectionUtils.h KoSectionModel.h KoTextCommandBase.h KoTextTableTemplate.h DESTINATION ${INCLUDE_INSTALL_DIR}/calligra COMPONENT Devel ) install( FILES styles/KoCharacterStyle.h styles/KoListLevelProperties.h styles/KoListStyle.h styles/KoParagraphStyle.h styles/KoTableColumnStyle.h styles/KoTableRowStyle.h styles/KoTableCellStyle.h styles/KoSectionStyle.h styles/KoStyleManager.h styles/KoTableStyle.h DESTINATION ${INCLUDE_INSTALL_DIR}/calligra/styles COMPONENT Devel ) install( FILES changetracker/KoChangeTracker.h changetracker/KoChangeTrackerElement.h changetracker/KoDeletedRowColumnDataStore.h changetracker/KoDeletedRowData.cpp changetracker/KoDeletedColumnData.cpp changetracker/KoDeletedCellData.cpp DESTINATION ${INCLUDE_INSTALL_DIR}/calligra/changetracker COMPONENT Devel ) install( FILES mct/MctAbstractGraph.h mct/MctAuthor.h mct/MctCell.h mct/MctChange.h mct/MctChangeEntities.h mct/MctChangeset.h mct/MctChangeTypes.h mct/MctDoBase.h mct/MctEmbObjProperties.h mct/MctNode.h mct/MctPosition.h mct/MctPropertyBase.h mct/MctRedoClass.h mct/MctRedoGraph.h mct/MctRedoGraphXMLfilter.h mct/MctStaticData.h mct/MctTableProperties.h mct/MctUndoClass.h mct/MctUndoGraph.h mct/MctUndoGraphXMLfilter.h mct/ExtractFile.h DESTINATION ${INCLUDE_INSTALL_DIR}/calligra/mct COMPONENT Devel ) endif() diff --git a/libs/text/mct/MctAbstractGraph.h b/libs/text/mct/MctAbstractGraph.h index f2ad9d071fb..f5b7a145a43 100644 --- a/libs/text/mct/MctAbstractGraph.h +++ b/libs/text/mct/MctAbstractGraph.h @@ -1,477 +1,479 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTABSTRACTGRAPH_H #define MCTABSTRACTGRAPH_H #include #include #include #include #include "MctChangeTypes.h" #include "KoShape.h" #include "KoProperties.h" +#include "kotext_export.h" + class MctChange; class MctChangeset; class MctPosition; class MctEmbObjProperties; class MctTableProperties; class MctAuthor; class KoTextDocument; /** * Represents a DOM document in the memory * * The MctAbstractGraph contains all the changes of the actual document. * Each document must have two abstract graph (undo and redo). */ -class MctAbstractGraph +class KOTEXT_EXPORT MctAbstractGraph { public: /** * constructor * * @param redoOrUndo "UndoChanges" for undo.xml, "RedoChanges" for redo.xml * @param odt file handle or name. * @param koTextDoc */ MctAbstractGraph(const QString &redoOrUndo, const QString &odt, KoTextDocument *koTextDoc); virtual ~MctAbstractGraph(); QList *changeNodes() const; void setChangeNodes(QList *changeNodes); QMap *changesetNodes() const; void setChangesetNodes(QMap *setChangesetNodes); QVector * dates(QVector *excludeDates = NULL) const; void setDates(QVector *m_dates); QMap * idDates() const; void setIdDates(QMap *m_idDates); /// return whether the graph is redo or undo QString redoOrUndo() const; void setRedoOrUndo(const QString &string); /// return the filename of the odt file QString odtFile() const; void setOdtFile(const QString &name); /// return the filename of the graph output QString filename() const; void setFilename(const QString &name); /// return the value of the root xml tag /// @deprecated QString nodeTag() const; void setNodeTag(const QString &name); /// return the root of the graph QDomElement root() const; void setRoot(const QDomElement &m_root); QDomDocument * doc() const; void setDoc(QDomDocument *m_doc); KoTextDocument * koTextDoc(); /** * return the changeset node with given date. * * @param date the date corresponding to the wanted changeset * @return the changesetNode corresponding to the given date. */ MctChangeset * getChangeset(const QDateTime &date); /** * return the list of changesetNodes. * * If date is set, return with changesetnodes earlier than the given date. * @param date the date of the wanted change * @return the list of changesets ordered by the dates. */ QList * getChangesetList(const QDateTime &date = QDateTime()); /** * return the list of changesetNodes corresponding to the list of dates. * @param dates list of dates. * @return the list of changesets ordered by the dates. */ QList * getChangesetListByDates(QList *dates); /** * create embObjProps object from properties in the graph xml * * @param change the node representing the change * @return an object with the properties of the embedded object */ MctEmbObjProperties * createEmbObjProps(const QDomElement &change); MctEmbObjProperties * createEmbObjShapeProps(const QDomElement &change); void setShapeStyles(KoShape* shape, const QDomElement &change); KoShape * createShapeFromProps(const QDomElement &change); const KoProperties * getShapeProperties(const QString &type); /** * create tableProps object from properties in the graph xml * @param change the node representing the change * @return an object with the properties of the table */ MctTableProperties * createTableProps(const QDomElement &change); /** * fill the graph from input xml * * Opening a document, or starting an MCT session will call this with method. * The content of the related "undo.xml"/"redo.xml" files will be read in the memory. */ void fillUpGraph(); /** * correct the block positions of a change * * During export the paragraph numbers should be written in the xml, * but the blocknumber gives a false value if the document contains tables. * The correction is applied right before exporting to xml. * @param node actual change node in the xml * @param indexes * @param import */ void correctBlockPosition(QDomNode *node, QMap *indexes, bool import = true); /** * @brief wrapper function to apply correction for all nodes * @param document pointer to the Dom document * @param indexes the frame index, it is the base of the correction */ void correctBlockPositionForExport(QDomDocument *document, QMap *indexes); /// get the date of changeset by its Id QDateTime getDateFromId(ulong id); /** * @brief find a changesetnode corresponding to given revision. * * The revision number is actually the index of the revision in the data structure. * @param revNum the number of the revision * @return the changeset node, or NULL if revision does not exist. */ MctChangeset * findChangeset(ulong revNum); /** * sort the list of dates * * The sorting goes from the most older (first index) to the youngest one (last index). */ void sortDates(); /** * add new changeset * * This will add new changeset to the end of the graph * without correcting the position attribute. * @param changes list of changes * @param author author of the revision * @param date date of the revision * @param comment comment of the revision * @param parentId parent changeset id * @param merge True if the adding changeset is being merged from another graph, False otherwise. * @return Returns with the created changesetNode */ MctChangeset * addChangeset(QList *changes, MctAuthor* author, const QDateTime &date, const QString &comment, uint parentId = 0, bool merge = false); /** * compare dates * * @param d1 first date * @param d2 second date * @return @c -1 if d1 earlier, @c 0 if equal, @c 1 if d1 later than d2 */ int dateComapre(const QDateTime &d1, const QDateTime &d2) ; /** * find the parents of the changesetNode. * * @param changsetnode changeset * @param merge True if the adding changeset is being merged from another graph, False otherwise. */ void findParents(MctChangeset *changsetNode, bool merge = false); /** * corrects parent-child correspondance, when new changeset is merged into the graph * * @param changsetnode changeset node that was merged * @param merge True if the adding changeset is being merged from another graph, False otherwise. */ void correctParentsAndChildren(MctChangeset *changsetNode, bool merge=false); /** * detect overlapping changes * * This method decid whether change1 and change2 related to embedded objects are overlaping or not. * @param change1 ChangeNode * @param change2 ChangeNode * @return @c true if changes are related to the same embedded object, @c false otherwise. */ bool areChangesOverlapping2(MctChange* change1, MctChange* change2); /** * detect overlapping positions * * Recursively decides, whether pos1 and pos2 are overlappong or not. * @param pos1 position object * @param pos2 position object * @return @c true if positions are overlapping in paragraph, @c false otherwise. */ bool arePositionsOverlapping(MctPosition *pos1, MctPosition *pos2); /** * compare positions * * Recursively decides, whether pos1 is before pos2 or not. * @param pos1 position object * @param pos2 position object * @return @c 0 if pos1 and pos2 are not in the same textcontent, @c 1 if pos1 is before pos2, @c -1 otherwise. */ int comparePositions(MctPosition *pos1, MctPosition *pos2); /** * detect overlapping changes * * * This decides, whether change1 and change2 are overlaping or not. * @param change ChangeNode * @param pos_orig original position * @param movedpos_orig moved position of change * @return @c true if they are overlapping in paragraph, @c false otherwise. * @warning there is a similar function above FIXME please */ bool areChangesOverlapping(MctChange *change, MctPosition *pos_orig, MctPosition *movedpos_orig); /** * add changesetNode into the graph. * * The changesetNode is corrected due to the earlier changesetNodes and the later ChangesetNodes in the graph are corrected as well. * @param changesetnode the new changesetNode */ void addChangesetNodeWithCorr(MctChangeset *changesetNode); /** * find date keys of changesets with later date, than the given one * @param date date * @return list of later dates */ QVector * findLaterDates(const QDateTime &date); /** * find date keys of changesets with earlier or equal date, than the given one * @param date date * @return list of earlier or equal dates */ QVector * findEarlierDates(const QDateTime &date); /** * correct the position attributes of changes * * The correction is applied to all changes in the set, according to the given changeset. * @param changesetNode changeset */ void correctChangesetNodeList(MctChangeset *changesetNode); /** * correct the position attributes of changes * * This correct the position attributes of changes in all changesets of the graph with later/earlier/all date than the given changeset according to the given changeset. * @param changesetNode changesetNode * @param withdates string: 'earlier', 'later', 'all'. Used to select dates to correct. * @param foradd True if the changesetNode is intended to be added. */ void correctChangesetNodeListWithDate(MctChangeset*changesetNode, const QString &withdates = DATE_LATER, bool foradd = true); /** * correct the position attributes of changes * * This corrects the position attributes of changes in changeset according to previous/later/all changes in the graph. * @param changesetnode changesetNode * @param withdates string: 'earlier', 'later', 'all'. Used to select dates to correct. * @param foradd True if the changesetNode is intended to be added. * @return parent ID */ int correctChangesetNode(MctChangeset*changesetNode, const QString &withdates = DATE_LATER, bool foradd = true); /** * correct the position attributes of changes * * This corrects the position attributes of changes in changeset according to other changes * @param changesetNode changeset node to correct. * @param changesetnodes list of changeset nodes using to correct the position attributes. * @param foradd True if the changesetNode is intended to be added. * @return parent ID */ int correctChangesetNode2(MctChangeset *changesetNode, QList *changesetnodes, bool foradd = true); /** * correct the position attributes of changes * * This corrects the position attributes of change node according to previous changes. * @param changeNode change node to correct. * @param prevChangeNode changeNode in order to correct the change node. * @param foradd True if the changesetNode is intended to be added. * @return corrected change node. */ MctChange* correctChangeNode(MctChange* changeNode, MctChange* prevChangeNode, bool foradd=true); /** * correct the paragraph position attribute of change * * This corrects the paragraph attributes of position structure, when the order of two changes are exchanged. * @param pos position class to be corrected. * @param prevpos reference position class used in the exchange with the other position class pos. * @param prevchangetype change type of the reference position class. */ void correctParInPosition(MctPosition *pos, MctPosition *prevpos, MctChangeTypes prevchangetype); /** * correct position structure * * @param pos position class to correct. * @param prevpos position class used to correct the pos position class. * @param prevchangetype change type of the previous change. * @param pos_orig original position to correct. * @param foradd True if the changesetNode related to pos is intended to be added. * @return corrected position */ MctPosition * correctPosition(MctPosition *pos, MctPosition *prevpos, MctChangeTypes prevchangetype, MctPosition *pos_orig = NULL, bool foradd=true); /** * remove changeset from the graph * * This removes changeset from the graph without position correction of the other changesets * @param changesetnode changeset node to remove. * @param clearchanges whether clear the list of changes or not. */ void removeChangeset(MctChangeset *changesetnode, bool clearchanges=true); /** * pop changeset from the graph * * This removes changeset from the graph without position correction of the other changesets * @param date date of the wanted changesetNode. * @return the removed changesetNode. */ MctChangeset * popChangeset(const QDateTime &date); virtual void addChange(MctChange* change, MctChangeset* changeset) = 0 ; virtual void addChangeFromXML(const QDomNode &change, MctChangeset* changeset) = 0; /** * export the graph to xml * * @param document Dom document to export into undo/redo.xml */ void exportGraph(QDomDocument *document); /** * register undo.xml/redo.xml files in the manifest.xml * * @param filename name of the copied manifest file */ void regManifest(const QString &filename); /// return the current number of revisions ulong getCurrentRevision(); /** * export position information from XML to Position object * * @param change XML node. * @param moved True if moved position is wanted, False otherwise * @return exported position class. */ MctPosition * getPosFromXML(const QDomElement &change, bool moved=false); /** * get postion of a table related change * * @param change Dom element * @param changeNode change representation * @param moved if true, moved position is affected */ void addTableDataToPos(QDomElement &change, MctChange *changeNode, bool moved=false); /** * add position attribute to dom tree * * This recursively adds position attribute to the node of the graph * @param change change node in the ElementTree * @param pos position object * @param moved if true, moved position is affected. */ void addPos2change(QDomElement *change, MctPosition *pos, bool moved=false); /** * reverse a list * * @param list list to reverse */ template void reverseList(QList **list); /** * look for moved changes * * @param changes list of changes * @return changes which */ QList * findMovedChanges(QList * changes); /** * delete directory (used for remove temp dirs) * * @param dirName path to directory * @return result of the delete operation */ bool removeDir(const QString &dirName); static const QString DATE_EARLIER; static const QString DATE_LATER; static const QString DATE_ALL; protected: ulong _id; ///< static id number which is given to the next node QList *m_changeNodes; ///< list of changes QMap *m_changesetNodes; ///< map of revisions QVector *m_dates; ///< array of revision dates QMap *m_idDates; ///< map of QString m_redoOrUndo; QString m_odtFile; ///< odt file name QString m_fileName; ///< filename containing the XML graph QString m_nodeTag; ///< root node tag (string of xml tag) QDomElement m_root; ///< root Dom element QDomDocument *m_doc; ///< Dom document KoTextDocument *m_koTextDoc; ///< legacy document }; #endif // MCTABSTRACTGRAPH_H diff --git a/libs/text/mct/MctAuthor.h b/libs/text/mct/MctAuthor.h index 21855ebf1a3..7a3fc8483cf 100644 --- a/libs/text/mct/MctAuthor.h +++ b/libs/text/mct/MctAuthor.h @@ -1,56 +1,58 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTAUTHOR_H #define MCTAUTHOR_H #include "MctNode.h" +#include "kotext_export.h" + /** * Author class represents the author of a change */ -class MctAuthor : public MctNode +class KOTEXT_EXPORT MctAuthor : public MctNode { public: /// constructor MctAuthor(QString m_userName = "", QString m_forename = "", QString m_surname = ""); ~MctAuthor(); /// getter QString name() const; /// setter void setName(const QString &name); /// getter QString forename() const; /// setter void setForename(const QString &name); /// getter QString surname() const; /// setter void setSurname(const QString &name); private: QString m_userName; ///< username from input field or system QString m_forename; ///< forename QString m_surname; ///< surname }; #endif // MCTAUTHOR_H diff --git a/libs/text/mct/MctCell.h b/libs/text/mct/MctCell.h index ca15823c5f0..4eeb230a53e 100644 --- a/libs/text/mct/MctCell.h +++ b/libs/text/mct/MctCell.h @@ -1,94 +1,96 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTCELL_H #define MCTCELL_H #include "MctPropertyBase.h" +#include "kotext_export.h" + /** * Representation of a table cell */ -class MctCell : public MctPropertyBase +class KOTEXT_EXPORT MctCell : public MctPropertyBase { public: MctCell(const QString &m_cellName, const QString &m_tableName, int m_row = -1, int m_col = -1); MctCell(int m_row, int m_col, const QString &m_tableName = "noname"); MctCell(const MctCell &cell); MctCell(); ~MctCell(); /** * merge cell with another * * Merge two cell positions and create new cell object at the position * @param cell to merge * @return new cell with extended position */ MctCell * addCelPos(MctCell *cell); /** * convert the cell name string into interger positions * * @note example: "D2" -> col = 3*60^0 = 4, row = 2 * @todo remove this function */ void convertCellPos2CellName(); /** * generate string position identifier as cellname from current position * * @note Pl: col = 4, row = 2 -> "D"+"2" = "D2" * @todo remove this function if not used */ void convertCellName2CellPos(); /// getter QString cellName() const; /// setter void setCellName(QString cell); /// getter QString tableName() const; /// setter void setTableName(const QString &name); /// getter int row() const; /// setter void setRow(int r); /// getter int col() const; /// setter void setCol(int c); const static QString COLS; ///< cell indentifier string eg: A22 @note probably legacy code protected: QString m_cellName; ///< name of the cell QString m_tableName;///< name of the anchor table private: int m_col; ///< column number of the cell int m_row; ///< row number of the cell }; #endif // MCTCELL_H diff --git a/libs/text/mct/MctChange.h b/libs/text/mct/MctChange.h index 1197c9f9945..35a02731530 100644 --- a/libs/text/mct/MctChange.h +++ b/libs/text/mct/MctChange.h @@ -1,88 +1,90 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTCHANGE_H #define MCTCHANGE_H #include "MctNode.h" #include "MctChangeTypes.h" #include "KoXmlReader.h" +#include "kotext_export.h" + class MctPosition; /** * Practial node in the abstract change-tracking graph * * The MctChange represents an actual change in the document history. * The class connect the position, the change type, the id and the related Dom element. */ -class MctChange : public MctNode +class KOTEXT_EXPORT MctChange : public MctNode { public: /// constructor MctChange(MctPosition *m_position, MctChangeTypes m_changeType, MctNode *m_changeEntity, QDomElement m_change, MctPosition *movedpos = NULL); MctChange(MctPosition *m_position, MctChangeTypes m_changeType, MctNode *m_changeEntity, MctPosition *movedpos = NULL); ~MctChange(); /** * setter of the corresponding XML node * * @param change XML node representing the change event. * @note position and movedPosition will be set to nullptr */ void addElementTreeNode(const QDomElement &m_change); /// getter MctChangeTypes changeType() const; /// setter void setChangeType(MctChangeTypes m_changeType); /** * getter for change position * * A copy of the stored position pointer is returned, if member was set. * The function will return nullptr if the related DOM object is undefined, * otherwise the XML will be read and retunr with a new position object. */ MctPosition * position() const; /// setter for change position void setPosition(MctPosition *m_position); /// setter void setMovedPosition(MctPosition *m_position); /// getter MctPosition * movedPosition() const; /// getter MctNode * changeEntity(); /// setter void setChangeNode(const QDomElement &element); /// getter QDomElement changeNode(); private: MctPosition *m_position; ///< position of the change MctChangeTypes m_changeType; ///< type of the change MctNode *m_changeEntity; ///< change entity, change id QDomElement m_change; ///< change node in the XML MctPosition *m_movedPosition; ///< position of the change }; #endif // MCTCHANGE_H diff --git a/libs/text/mct/MctChangeEntities.h b/libs/text/mct/MctChangeEntities.h index 29629287b24..06128e9e057 100644 --- a/libs/text/mct/MctChangeEntities.h +++ b/libs/text/mct/MctChangeEntities.h @@ -1,404 +1,406 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTCHANGEENTITIES_H #define MCTCHANGEENTITIES_H #include "MctCell.h" #include "MctNode.h" #include #include #include +#include "kotext_export.h" + class MctPropertyBase; class MctEmbObjProperties; class MctTableProperties; class ChangeEvent; using ChangeEventList = QList; /** * Change entities are used for specify all possible change type. * They are added to MctChange as an MctNode pointer. */ enum ChangeAction { NOCHANGE, /// there is no change CHANGED, /// something changed ADDED, /// new value (which wasnt used before, in the old format) REMOVED /// deleted value (new format does not contains it) }; using PropertyMap = QMap>; /// Base class for Table related changes -class MctTable : public virtual MctNode , public MctCell +class KOTEXT_EXPORT MctTable : public virtual MctNode , public MctCell { public: MctTable(const QString &m_cellName = "", const QString &m_tableName = "", MctCell *cellInfo = NULL); ~MctTable(); }; /// Base class for Paragraph related changes -class MctParagraphBreak : public virtual MctNode +class KOTEXT_EXPORT MctParagraphBreak : public virtual MctNode { public: MctParagraphBreak(); ~MctParagraphBreak(); }; -class MctParagraphBreakInTable : public MctParagraphBreak , public MctTable +class KOTEXT_EXPORT MctParagraphBreakInTable : public MctParagraphBreak , public MctTable { public: MctParagraphBreakInTable(const QString &m_cellName = "", const QString &m_tableName = "", MctCell *cellInfo = NULL); ~MctParagraphBreakInTable(); }; -class MctDelParagraphBreak : public virtual MctNode +class KOTEXT_EXPORT MctDelParagraphBreak : public virtual MctNode { public: MctDelParagraphBreak(); ~MctDelParagraphBreak(); }; -class MctDelParagraphBreakInTable : public MctDelParagraphBreak , public MctTable +class KOTEXT_EXPORT MctDelParagraphBreakInTable : public MctDelParagraphBreak , public MctTable { public: MctDelParagraphBreakInTable(const QString &m_cellName = "", const QString &m_tableName = "", MctCell *cellInfo = NULL); ~MctDelParagraphBreakInTable(); }; /// Base class for String related changes -class MctStringChange : public virtual MctNode +class KOTEXT_EXPORT MctStringChange : public virtual MctNode { public: MctStringChange(const QString &string = ""); ~MctStringChange(); QString getString() const; void setString(const QString &string); private: QString m_string; }; -class MctStringChangeInTable : public MctStringChange , public MctTable +class KOTEXT_EXPORT MctStringChangeInTable : public MctStringChange , public MctTable { public: MctStringChangeInTable(const QString &string = "", const QString &cellName = "", const QString &tableName = "", MctCell *cellInfo = NULL); ~MctStringChangeInTable(); }; // FIXME: ::com::sun::star::beans::PropertyChangeEvent in the python legacy code is similar struct -class ChangeEvent +class KOTEXT_EXPORT ChangeEvent { public: ChangeEvent(const QTextFormat &o, const QTextFormat &n); /** * getter of old type id * * @return type of old text format */ int type(); /** * compare old and new text format * * The different proprties will be inserted into m_changedProperties map. * @param type format type selector @todo refactor to use enum class instead of int */ void calcDiff(int type); /// getter PropertyMap * changes(); /// getter QTextFormat oldFormat(); /// setter void setOldFormat(const QTextFormat &format); /// getter QTextFormat newFormat(); /// setter void setNewFormat(const QTextFormat &format); // static functions! /** * copy properties * * @param format1 output formatting props * @param format2 input formatting props */ static void ensureProperties(QTextFormat &format1, const QTextFormat &format2); /** * * @param current * @param base * @return * @todo understand this function */ static QTextFormat getNewValuesForFormat(const QTextFormat& current, const QTextFormat &base); /** * * @param current * @param base * @return * @todo understand this function */ static QTextFormat getOldValuesForFormat(const QTextFormat ¤t, const QTextFormat &base); /** * toString method for debugging * @param format text format */ static void printProperties(const QTextFormat &format); private: QTextFormat m_oldFormat; ///< old text format QTextFormat m_newFormat; ///< new text format PropertyMap * m_changedProperties; ///< map of changed properties }; /** * similar to \ref ChangeEvent * * @todo refactor this, merge with ChangeEvent for example */ -class MctStylePropertyChange : public virtual MctNode +class KOTEXT_EXPORT MctStylePropertyChange : public virtual MctNode { public: MctStylePropertyChange(ChangeEventList *changeList); ~MctStylePropertyChange(); QTextFormat *getOldFormat() const; void setOldFormat(QTextFormat *value); /// getter of paragraph related style changes ChangeEventList * paragraphPropChanges(); /// getter of text related style changes ChangeEventList * textPropChanges(); /// getter of list related style changes ChangeEventList * listPropChanges(); /// getter of other style changes ChangeEventList * otherPropChanges(); private: // bool hasNonUnoChangeEvent(); /** * sort the different change types into theire own container * @param propChanges style changes list */ void sortPropertyChanges(ChangeEventList *propChanges); ChangeEventList *m_textPropChanges; ///< QTextCharFormat : QTextFormat ! ChangeEventList *m_paragraphPropChanges; ///< QTextBlockFormat : QTextFormat ! ChangeEventList *m_listPropChanges; ///< QTextListFormat : QTextFormat ! ChangeEventList *m_otherPropChanges; ///< QTextFormat // list of complex uno services cant be constructed when graph is loaded from xml. (every item in the list contains dictionary with keys identical to ::com::sun::star::beans::PropertyChangeEvent) // QList< QMap > nonUnoPropertyChanges; }; -class MctAddedTextFrame : public virtual MctNode +class KOTEXT_EXPORT MctAddedTextFrame : public virtual MctNode { public: MctAddedTextFrame(); ~MctAddedTextFrame(); }; -class MctRemovedTextFrame : public virtual MctNode +class KOTEXT_EXPORT MctRemovedTextFrame : public virtual MctNode { public: MctRemovedTextFrame(); ~MctRemovedTextFrame(); }; /// Base of text object changes -class MctChangedTexObjectBase : public virtual MctNode +class KOTEXT_EXPORT MctChangedTexObjectBase : public virtual MctNode { public: MctChangedTexObjectBase(const QString &name, MctPropertyBase *objectProperties = NULL); virtual ~MctChangedTexObjectBase(); /// getter MctPropertyBase* objectProperties() const; /// setter void setObjectName(const QString &name); /// setter void setObjectProperties(MctPropertyBase* objectProperties); protected: MctPropertyBase *m_objectProperties; ///< property container }; -class MctAddedTextGraphicObject : public MctChangedTexObjectBase +class KOTEXT_EXPORT MctAddedTextGraphicObject : public MctChangedTexObjectBase { public: MctAddedTextGraphicObject(const QString &name, MctEmbObjProperties* embObjProps = NULL); ~MctAddedTextGraphicObject(); }; -class MctRemovedTextGraphicObject : public MctChangedTexObjectBase +class KOTEXT_EXPORT MctRemovedTextGraphicObject : public MctChangedTexObjectBase { public: MctRemovedTextGraphicObject(const QString &name, MctEmbObjProperties* embObjProps = NULL); ~MctRemovedTextGraphicObject(); }; -class MctAddedTextGraphicObjectInTable : public MctAddedTextGraphicObject , public MctTable +class KOTEXT_EXPORT MctAddedTextGraphicObjectInTable : public MctAddedTextGraphicObject , public MctTable { public: MctAddedTextGraphicObjectInTable(const QString &name, MctEmbObjProperties* embObjProps = NULL, const QString &m_cellName = "", const QString &m_tableName = "", MctCell *cellInfo = NULL); ~MctAddedTextGraphicObjectInTable(); }; -class MctRemovedTextGraphicObjectInTable : public MctRemovedTextGraphicObject , public MctTable +class KOTEXT_EXPORT MctRemovedTextGraphicObjectInTable : public MctRemovedTextGraphicObject , public MctTable { public: MctRemovedTextGraphicObjectInTable(const QString &name, MctEmbObjProperties* embObjProps = NULL, const QString &m_cellName = "", const QString &m_tableName = "", MctCell *cellInfo = NULL); ~MctRemovedTextGraphicObjectInTable(); }; -class MctAddedEmbeddedObject : public virtual MctNode +class KOTEXT_EXPORT MctAddedEmbeddedObject : public virtual MctNode { public: MctAddedEmbeddedObject(const QString &name); ~MctAddedEmbeddedObject(); }; -class MctRemovedEmbeddedObject : public virtual MctNode +class KOTEXT_EXPORT MctRemovedEmbeddedObject : public virtual MctNode { public: MctRemovedEmbeddedObject(); ~MctRemovedEmbeddedObject(); }; /// Table related changes -class MctAddedTextTable : public MctChangedTexObjectBase +class KOTEXT_EXPORT MctAddedTextTable : public MctChangedTexObjectBase { public: MctAddedTextTable(const QString &name, MctTableProperties* tableProps = NULL); MctAddedTextTable(int row, int col, const QTextTableFormat &format); ~MctAddedTextTable(); int rowCount(); // unused int colCount(); // unused QTextTableFormat getTableFormat(); void setRowCount(int row); void setColCount(int col); void setTableFormat(const QTextTableFormat &format); protected: int m_row; int m_col; QTextTableFormat m_tableFormat; }; -class MctRemovedTextTable : public MctChangedTexObjectBase +class KOTEXT_EXPORT MctRemovedTextTable : public MctChangedTexObjectBase { public: MctRemovedTextTable(const QString &name, MctTableProperties* tableProps = NULL); ~MctRemovedTextTable(); }; -class MctAddedTextTableInTable : public MctAddedTextTable , public MctTable +class KOTEXT_EXPORT MctAddedTextTableInTable : public MctAddedTextTable , public MctTable { public: MctAddedTextTableInTable(const QString &name, MctTableProperties* tableProps = NULL, const QString &cellName = "", const QString &tableName = "", MctCell *cellInfo = NULL); ~MctAddedTextTableInTable(); }; -class MctRemovedTextTableInTable : public MctRemovedTextTable , public MctTable +class KOTEXT_EXPORT MctRemovedTextTableInTable : public MctRemovedTextTable , public MctTable { public: MctRemovedTextTableInTable(const QString &name, MctTableProperties* tableProps = NULL, const QString &cellName = "", const QString &tableName = "", MctCell *cellInfo = NULL); ~MctRemovedTextTableInTable(); }; -class MctStylePropertyChangeInTable : public MctStylePropertyChange , public MctTable +class KOTEXT_EXPORT MctStylePropertyChangeInTable : public MctStylePropertyChange , public MctTable { public: MctStylePropertyChangeInTable(ChangeEventList *propChanges, const QString &cellName = "", const QString &tableName = "", MctCell *cellInfo = NULL); ~MctStylePropertyChangeInTable(); }; -class MctRowChangeInTable : public virtual MctNode +class KOTEXT_EXPORT MctRowChangeInTable : public virtual MctNode { public: MctRowChangeInTable(int startRow, int rowCount, const QString &tableName); ~MctRowChangeInTable(); int startRow() const; void setStartRow(int n); int rowCount() const; void setRowCount(int n); QString tableName() const; void setTableName(const QString &n); private: int m_startRow; int m_rowCount; QString m_tableName; }; -class MctColChangeInTable : public virtual MctNode +class KOTEXT_EXPORT MctColChangeInTable : public virtual MctNode { public: MctColChangeInTable(int startCol, int colCount, const QString &tableName); ~MctColChangeInTable(); int startCol() const; void setStartCol(int n); int colCount() const; void setColCount(int n); QString tableName() const; void setTableName(const QString &n); private: int m_startCol; int m_colCount; QString m_tableName; }; -class MctAddedRowInTable : public MctRowChangeInTable +class KOTEXT_EXPORT MctAddedRowInTable : public MctRowChangeInTable { public: MctAddedRowInTable(int m_startRow, int rowCount, const QString &m_tableName); ~MctAddedRowInTable(); }; -class MctRemovedRowInTable : public MctRowChangeInTable +class KOTEXT_EXPORT MctRemovedRowInTable : public MctRowChangeInTable { public: MctRemovedRowInTable(int m_startRow, int rowCount, const QString &m_tableName); ~MctRemovedRowInTable(); }; -class MctAddedColInTable : public MctColChangeInTable +class KOTEXT_EXPORT MctAddedColInTable : public MctColChangeInTable { public: MctAddedColInTable(int m_startCol, int colCount, const QString &tableName); ~MctAddedColInTable(); }; -class MctRemovedColInTable : public MctColChangeInTable +class KOTEXT_EXPORT MctRemovedColInTable : public MctColChangeInTable { public: MctRemovedColInTable(int m_startCol, int colCount, const QString &tableName); ~MctRemovedColInTable(); }; #endif // MCTCHANGEENTITIES_H diff --git a/libs/text/mct/MctDoBase.h b/libs/text/mct/MctDoBase.h index 72bf81ed67d..e2e4310f8d7 100644 --- a/libs/text/mct/MctDoBase.h +++ b/libs/text/mct/MctDoBase.h @@ -1,56 +1,58 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTDOBASE_H #define MCTDOBASE_H #include "MctChange.h" #include "MctStaticData.h" +#include "kotext_export.h" + class KoTextDocument; /** * Base class of Undo and Redo classes * * This class is responsible for the connection with Calligra via containing the KoDocument pointer. */ -class MctDoBase +class KOTEXT_EXPORT MctDoBase { public: /// constructor MctDoBase(); virtual ~MctDoBase(); /** * create textcursor from a change node and a position * * Wrapper function which calls static method to get cursor * at the given position, in the current document (m_doc). * @param change @todo remove this param * @param pos where to set the new cursor * @return new cursor */ QTextCursor *createcursor(MctChange *change, MctPosition *pos); protected: KoTextDocument *m_doc; ///< pointer access to the current document which is handled by Calligra }; #endif // MCTDOBASE_H diff --git a/libs/text/mct/MctEmbObjProperties.h b/libs/text/mct/MctEmbObjProperties.h index ff310f03a26..520bee048c8 100644 --- a/libs/text/mct/MctEmbObjProperties.h +++ b/libs/text/mct/MctEmbObjProperties.h @@ -1,184 +1,186 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTEMBOBJPROPERTIES_H #define MCTEMBOBJPROPERTIES_H #include "MctPropertyBase.h" #include "KoShape.h" #include "KoShapeStroke.h" #include "KoShapeShadow.h" +#include "kotext_export.h" + #include /** * Represent an embedded object with properties * * @note this class was also designed for UNO interface * @todo refactoring, re-thinking is suggested */ -class MctEmbObjProperties : public MctPropertyBase +class KOTEXT_EXPORT MctEmbObjProperties : public MctPropertyBase { public: MctEmbObjProperties(const QString &name); MctEmbObjProperties(const QString &name, KoShape *m_shape); MctEmbObjProperties(const QString &name, KoShape *m_shape, const QPointF &m_pos, const QSizeF &m_size); ~MctEmbObjProperties(); /** * export odt content for backup * * make a copy of a metadata stored in the Odt. * @param innerURL relative URL in the Odt. * @param OdtURL absolute URL of the Odt. * @return the URL of the backed up file */ QString backupFileFromOdt(const QString &m_innerURL, const QString &absOdtURL); /// restore embedded file from backup (if it exists) void restoreBackupFile(); /// cleans up backup files. void deleteBackupFile(); /** * update mediatype member * * update the value of this->mediaType member from the given manifest file * @param fileName manifest file (usually .../odtURL/manifest.xml) */ void mediaType(const QString &fileName); /** * register manifest file * * @param fileName manifest file */ void regManifest(const QString &fileName); /** * compare two embedded object property dictionary * * Gives a a dictionary about the not identical elements * @param otherEmbObjProperties dictionary that should contains all element of this object's props dictionary. * @return new dictionary which conatins the differences. */ PropertyDictionary * compareProperties(const MctEmbObjProperties& otherEmbObjProperties); /** * transform graphicURL to innerURL * * @param graphicURL should start with someting like this: "nd.sun.star.GraphicObject:"identifier * @return The innerURL that looks like this: "Picture/"identifier * @todo probably legacy code */ QString createInnerURL(const QString &graphicURL); /** * transforms innerURL into grapicURL * * @param innerURL example: "Picture/"identifier * @return example: "nd.sun.star.GraphicObject:"identifier * @todo probably legacy code */ QString createGraphicURL(const QString &m_innerURL); /// setter void setOdtUrl(const QString &odt); /// getter QString url() const; /// setter void setURL(const QString &value); /// getter QString odtURL() const; /// setter void setOdtURL(const QString &value); /// getter bool isBackedUp() const; /// setter void setIsBackedUp(bool value); /// getter bool wasInserted() const; /// setter void setWasInserted(bool value); /// getter bool doRestoreWhenDeleted() const; /// setter void setDoRestoreWhenDeleted(bool value); /// getter KoShape* shape(); /// getter QPointF pos() const; /// get center position (pos+dim_size/2) QPointF centerPos() const; /// add postion properties to property dictionary void setPositionInExport(); virtual void fillUpProperties(); /// insert stroke related properties void addStrokeStyleChanges(KoShapeStroke *newStroke); /// insert shadow related properties void addShadowStyleChanges(KoShapeShadow *newShadow); /// insert PrevSize properties void addSizeChanged(const QSizeF &prevPos); /// insert PrevRotation property void addRotationChanged(double rotation); /// insert PreviousPosition properties void setPrevPos(const QPointF &prevPos); /** * set graphical style proprties of the parameter from the property dictionary * * @param props2 @todo maybe remove and use this pointer instead? * @param m_shape grpahical object to style */ void textGraphicStyleChanges(MctEmbObjProperties* props2, KoShape* m_shape); /// utility to delete a folder @todo redundant function maybe bool removeDir(const QString & dirName); private: QString m_url; /// URL of the backup file QString m_odtURL; /// URL of the Odt file QString m_mediaType; /// media type of the embedded object in the manifest file bool m_isBackedUp; ///< true if the embedded object is backed up bool m_wasInserted; ///< true if the object was inserted bool m_doRestoreWhenDeleted; ///< backed up file is restored into the Odt when True KoShape *m_shape; ///< describe formatting of document element QPointF m_pos; ///< position (x, y) QSizeF m_size; ///< size (width, height) /** * utility method to swap the prefix of URL * * @param oldPrefix URL should start with this. * @param newPrefix URL should start with this. * @param name original identifier that should contain oldPrefix. * @return identifier starting with the newPrefix substring. */ QString convertURL(const QString &oldPrefix, const QString &newPrefix, const QString &name); }; #endif // MCTEMBOBJPROPERTIES_H diff --git a/libs/text/mct/MctNode.h b/libs/text/mct/MctNode.h index 228a3d38bc4..24761989708 100644 --- a/libs/text/mct/MctNode.h +++ b/libs/text/mct/MctNode.h @@ -1,49 +1,52 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTNODE_H #define MCTNODE_H #include + +#include "kotext_export.h" + /** * A basic node for the abstract graph */ -class MctNode +class KOTEXT_EXPORT MctNode { public: /// constructor MctNode(unsigned long id); MctNode(); virtual ~MctNode(); /// setter virtual void setId(unsigned long id); /// getter virtual unsigned long id() const; /// setter void setName(const QString &name); /// getter QString name(); protected: unsigned long m_id; ///< indetifier number QString m_name; ///< optional name or comment }; #endif // MCTNODE_H diff --git a/libs/text/mct/MctPosition.h b/libs/text/mct/MctPosition.h index 06e2080a018..f64397b36d8 100644 --- a/libs/text/mct/MctPosition.h +++ b/libs/text/mct/MctPosition.h @@ -1,101 +1,103 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTPOSITION_H #define MCTPOSITION_H #include #include #include #include +#include "kotext_export.h" + class MctCell; /** * Position of a change * * A change position in MCT usually consists of four component. * The starting and ending paragraphs are counted and so the character positions. * Sometimes ending information is not give for example when Paragraph change is in action. */ -class MctPosition +class KOTEXT_EXPORT MctPosition { public: /// constructor MctPosition(ulong startPar = 0, ulong starChar = 0, ulong endPar = 0, ulong endChar = 0, MctCell *startCellInf = NULL, MctCell *endCellInf = NULL); MctPosition(const MctPosition &position); ~MctPosition(); /// getter ulong startPar() const; /// setter void setStartPar(ulong value); /// getter ulong endPar() const; /// setter void setEndPar(ulong value); /// getter ulong startChar() const; /// setter void setStartChar(ulong value); /// getter ulong endChar() const; /// setter void setEndChar(ulong value); /// getter MctCell* startCellInfo() const; /// setter void setStartCellInfo(MctCell* info); /// getter MctCell* endCellInfoEnd() const; /// setter void setEndCellInfo(MctCell* info); /// getter MctPosition * anchoredPos() const; /// setter void setAnchored(MctPosition *parentPos); /** * correct table cell position calculation * * Calligra adds a hidden cursor position before tables, * this function correct the position regarding to the hidden point. * @param cursor which is point inside the table * @return absolute cursor position */ int tableCellPosition(QTextCursor *cursor) const; /// simple debug function QString toString() const; private: ulong m_startPar; ///< start number of the paragraph where the change starts. ulong m_startChar; ///< start number of the character in the paragraph where the change starts. ulong m_endPar; ///< end number of the paragraph where the change starts. ulong m_endChar; ///< end number of the character in the paragraph where the change starts. MctCell *m_startCellInf; ///< cell which contains starting cell name and table name MctCell *m_endCellInf; ///< cell which contains ending cell name and table name MctPosition *m_anchoredPos; ///< position of the object where this position is anchored }; #endif // MCTPOSITION_H diff --git a/libs/text/mct/MctRedoClass.h b/libs/text/mct/MctRedoClass.h index 20420b86932..00902398cd2 100644 --- a/libs/text/mct/MctRedoClass.h +++ b/libs/text/mct/MctRedoClass.h @@ -1,146 +1,148 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTREDOCLASS_H #define MCTREDOCLASS_H #include "MctChange.h" #include "MctChangeset.h" #include "MctDoBase.h" #include "MctChangeEntities.h" #include "KoShape.h" +#include "kotext_export.h" + #include /** * Do redo operation for all changes of a revision * * Redo class prepare and apply a change set before added to abstract graph as a new undo revision. * It behaves like a hub, gathers uncommited changes, decide the type of each change, * collect type depending information, APPLY the change and than add it to the abstract graph (undo). */ -class MctRedoClass : public MctDoBase +class KOTEXT_EXPORT MctRedoClass : public MctDoBase { public: /// constructor MctRedoClass(KoTextDocument *kotextdoc); ~MctRedoClass(); /** * add changeset to undo abstarct graph * * @param changesetNode * @param redoChangeList * @return */ MctChangeset * addChangesetToUndo(MctChangeset * changesetNode, QList * undoChangeList); /** * prepare changes into changeset object * * @param changesetNode * @param add2Graph */ void redoChangeset(MctChangeset * changesetNode, bool add2Graph = true); /** * call type related private function (redo the change) * * @param changeNode individual change which is tested * @return properly configured change object */ MctChange* redoChange(MctChange * changeNode); private: /// redo added string change and commit to undo MctChange * redoAddedString(MctChange * changeNode); /// redo removed string change and commit to undo MctChange * redoRemovedString(MctChange * changeNode); /// redo moved string change and commit to undo MctChange * redoMovedString(MctChange * changeNode); /// redo added string (in table) change and commit to undo MctChange * redoAddedStringInTable(MctChange * changeNode); /// redo removed string (in table) change and commit to undo MctChange * redoRemovedStringInTable(MctChange * changeNode); /// redo moved string change (in table) and commit to undo MctChange * redoMovedStringInTable(MctChange * changeNode); /// redo added paragraph break change and commit to undo MctChange * redoParagraphBreak(MctChange * changeNode); /// redo deleted paragraph break change and commit to undo MctChange * redoDelParagraphBreak(MctChange * changeNode); /// redo added paragraph break change (in table) and commit to undo MctChange * redoParagraphBreakInTable(MctChange * changeNode); /// redo deleted paragraph break change (in table) and commit to undo MctChange * redoDelParagraphBreakInTable(MctChange * changeNode); /// redo style change and commit to undo MctChange * redoStyleChange(MctChange * changeNode); /// wrapper for different style type changes void redoPropsChange(QTextCursor *cursor, ChangeEventList * propchanges); /// redo style change (in table) and commit to undo MctChange * redoStyleChangeInTable(MctChange * changeNode); /// redo added object change and commit to undo MctChange * redoAddedTextGraphicObjects(MctChange * changeNode, bool withprops = true); /// redo removed object change and commit to undo MctChange * redoRemovedTextGraphicObjects(MctChange * changeNode, bool withprops = true); /// redo added onbject change (in table) and commit to undo MctChange * redoAddedTextGraphicObjectsInTable(MctChange * changeNode, bool withprops = true); /// redo removed object change (in table) and commit to undo MctChange * redoRemovedTextGraphicObjectsInTable(MctChange * changeNode, bool withprops = true); /// redo added text table change and commit to undo MctChange * redoAddedTextTable(MctChange * changeNode, bool withprops = true); /// redo removed text table change and commit to undo MctChange * redoRemovedTextTable(MctChange * changeNode); /// redo added text table change (in table) and commit to undo MctChange * redoAddedTextTableInTable(MctChange * changeNode, bool withprops = true); /// redo removed text table change (in table) and commit to undo MctChange * redoRemovedTextTableInTable(MctChange * changeNode); /// redo added row change in table and commit to undo MctChange * redoAddedRowInTable(MctChange * changeNode); /// redo removed row change in table and commit to undo MctChange * redoRemovedRowInTable(MctChange * changeNode); /// redo added col change in table and commit to undo MctChange * redoAddedColInTable(MctChange * changeNode); /// redo added col change in table and commit to undo MctChange * redoRemovedColInTable(MctChange * changeNode); }; #endif // MCTREDOCLASS_H diff --git a/libs/text/mct/MctRedoGraph.h b/libs/text/mct/MctRedoGraph.h index af7e829a13a..90f30979508 100644 --- a/libs/text/mct/MctRedoGraph.h +++ b/libs/text/mct/MctRedoGraph.h @@ -1,227 +1,229 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTREDOGRAPH_H #define MCTREDOGRAPH_H #include "MctRedoGraphXMLfilter.h" +#include "kotext_export.h" + class ChangeEvent; using ChangeEventList = QList; /** * Export changes from abstract redo graph to XML */ -class MctRedoGraph : public MctRedoGraphXMLfilter +class KOTEXT_EXPORT MctRedoGraph : public MctRedoGraphXMLfilter { public: MctRedoGraph(const QString &odt, KoTextDocument *m_koTextDoc); virtual ~MctRedoGraph(); /** * convert and add changeset from undo graph into redo graph * * @param redochangeset node in the redo graph * @return created changeset node. */ MctChangeset* addchangesetFromUndo(MctChangeset* undochangeset); /** * add a single change to changeset and XML (wrapper function) * * @param change change to be added * @param changeset parent changeset */ void addChange(MctChange* changeNode, MctChangeset* changeset); /** * add addString to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void addString(QDomElement *xmlchange, MctChange* change); /** * add removeString to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void removeString(QDomElement *xmlchange, MctChange* change); /** * add moveString to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void moveString(QDomElement *xmlchange, MctChange* change); /** * add addParBreak to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void addParBreak(QDomElement *xmlchange, MctChange* change); /** * add delParBreak to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void delParBreak(QDomElement *xmlchange, MctChange* change); /** * add styleChange to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void styleChange(QDomElement *xmlchange, MctChange* change); /** * add styling change as subnode * * @param subnode node to insert change * @param propchanges style changes in a list * @param type style type flag @todo replace with enum */ void fillPropertySubNode(QDomElement *subnode, ChangeEventList *propchanges, int type); //UNO /** * add textFrame to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void textFrame(QDomElement *xmlchange, MctChange* change); /** * add textTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted * @param added */ void textTable(QDomElement *xmlchange, MctChange* change, bool added=true); /** * add textGraphicObject to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted * @param added */ void textGraphicObject(QDomElement *xmlchange, MctChange* change, bool added=true); /** * add embeddedObject to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void embeddedObject(QDomElement *xmlchange, MctChange* change); /** * add addStringInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void addStringInTable(QDomElement *xmlchange, MctChange* change); /** * add removeStringInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void removeStringInTable(QDomElement *xmlchange, MctChange* change); /** * add moveStringInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void moveStringInTable(QDomElement *xmlchange, MctChange* change); /** * add addParBreakInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void addParBreakInTable(QDomElement *xmlchange, MctChange* change); /** * add delParBreakInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void delParBreakInTable(QDomElement *xmlchange, MctChange* change); /** * add styleChangeInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void styleChangeInTable(QDomElement *xmlchange, MctChange* change); /** * add textGraphicObjectInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted * @param added if False other style data are also exported. */ void textGraphicObjectInTable(QDomElement *xmlchange, MctChange* change, bool added=true); /** * add textTableInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted * @param added if False other style data are also exported. */ void textTableInTable(QDomElement *xmlchange, MctChange* change, bool added=true); /** * add rowChangeInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void rowChangeInTable(QDomElement *xmlchange, MctChange* change); /** * add colChangeInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void colChangeInTable(QDomElement *xmlchange, MctChange* change); }; #endif // MCTREDOGRAPH_H diff --git a/libs/text/mct/MctStaticData.h b/libs/text/mct/MctStaticData.h index b0d06c69af8..9c7a1eec926 100644 --- a/libs/text/mct/MctStaticData.h +++ b/libs/text/mct/MctStaticData.h @@ -1,438 +1,440 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTSTATICDATA_H #define MCTSTATICDATA_H #include #include #include #include #include #include #include +#include "kotext_export.h" + class MctChange; class MctPosition; class MctEmbObjProperties; class MctUndoGraph; class MctRedoGraph; class KZip; class KArchiveDirectory; class KoTextDocument; class KoDocument; // TODO class FIXME_EmbElement; class FIXME_URL; class FIXME_TextInterface; class FIXME_Doc; class FIXME_PropertyDictionary; enum MctChangeTypes : unsigned int; using XMLns = QString; /** * Contains all static const global variable and function */ -class MctStaticData +class KOTEXT_EXPORT MctStaticData { public: /// String constants static const QString EXPORTED_BY_SYSTEM; static const ulong UNDEFINED; static const QString UNDOTAG; static const QString REDOTAG; static const QString UNDOCHANGES; static const QString REDOCHANGES; // names of the files containing undo/redo operations static const QString UNDOFILE; static const QString REDOFILE; //static variables to parse position data from XML static const QString POSSEPARATOR; static const QString POSSTART; static const QString POSEND; static const QString MPOSSTART; static const QString MPOSEND; static const QString TABLE; static const QString CELL; static const QString MOVEDTABLE; static const QString MOVEDCELL; static const QString DATESEP; static const QString TIMESEP; static const QString DATETIMESEP; static const QString GRAPHICOBJ; static const QString GRAPHICOBJ_PATH; static const QChar REDOCHAR; /// XML namespaces static const XMLns XMLNS; static const XMLns NS_DC; static const XMLns NS_C; static const XMLns NS_OFFICE; /// XML string constants (tags, attribute values, etc) static const QString VERSION; static const QString STARTINGSTRING; static const QString AUTHOR; static const QString COMMENT; static const QString DATE; static const QString TYPE; static const QString ID; static const QString NAME; static const QString ROW; static const QString COL; static const QString URL; static const QString POSX; static const QString POSY; static const QString PREVPOSX; static const QString PREVPOSY; static const QString HEIGHT; static const QString WIDTH; static const QString ROTATION; static const QString PARENT; static const QString ADDED; // undo uses "del" here (!) static const QString REMOVED; // undo uses "add" here (!) static const QString MOVED; static const QString STRING; static const QString PARAGRAPH; static const QString STYLE; static const QString TEXTFRAME; static const QString TEXTGRAPHICOBJECT; static const QString EMBEDDEDOBJECT; static const QString ROWCHANGE; static const QString COLCHANGE; //static const QString TABLE; static const QString FORMATTAG; static const QString PROPERTIESTAG; static const QString TEXTTAG; static const QString PARAGRAPHTAG; static const QString LIST; static const QString UNDEFINEDTAG; static int currentRevision; /// property string and values static const QSet TEXTGRAPHICOBJECTS_INTPROPS; static const QSet TEXTGRAPHICOBJECTS_STRUCTPROPS; static const QSet TEXTGRAPHICOBJECTS_FLOATPROPS; static const QSet TEXTGRAPHICOBJECTS_STRINGPROPS; static const QSet TEXTGRAPHICOBJECTS_BOOLEANPROPS; static const QSet TEXTTABLE_STRUCTPROPS; static const QSet TEXTTABLE_ENUMPROPS; static const QSet TEXT_PROPS_BOOLEAN; static const QSet TEXT_PROPS_INT; static const QSet TEXT_PROPS_DOUBLE; static const QSet TEXT_PROPS_STRING; static const QMap TEXT_PROPS_AS_STRING; static const QMap initTEXT_PROPS_AS_STRING(); static const QMap TEXT_KO_CHAR_PROPS_AS_STRING; static const QMap initTEXT_KO_CHAR_PROPS_AS_STRING(); static const QMap TEXT_KO_PAR_PROPS_AS_STRING; static const QMap initTEXT_KO_PAR_PROPS_AS_STRING(); static const QMap TEXT_KO_LIST_PROPS_AS_STRING; static const QMap initTEXT_KO_LIST_PROPS_AS_STRING(); /** * convert text property to integer * * @param propertyname name of the property (eg. from XML) * @return corresponding interger identifier */ static int getTextPropAsInt(QString propertyname); /** * convert property type and id key into property name * * @param key property identifier * @param type property type id (text, list, etc) @todo enum class * @return property name as string */ static QString getTextPropetyString(int key, int type); static const QMap CHANGE_AS_STRING; ///< \ref ChangeEntities classes as string static const QMap initCHANGE_AS_STRING(); /** * Text formatting property types * * @todo should make to enum class and use it correctly @ref MctChangeEntities */ enum PropertyType{ CharacterProperty, ParagraphProperty, ListProperty, UnknownProperty }; static MctStaticData* instance() { static QMutex mutex; if (!m_Instance) { mutex.lock(); if (!m_Instance) m_Instance = new MctStaticData(); mutex.unlock(); } return m_Instance; } static void drop() { static QMutex mutex; mutex.lock(); if(m_Instance) { delete m_Instance; m_Instance = 0; } mutex.unlock(); } template void reverseList(QList **list); template void reverseList2(QList *list); // functions.py /** * create the temporary file path of the MCT tracket document * * @param url original URL of the document * @return the temporary file path */ QString tempMctFile(QString url); /** * zips embedded files into the Odt when graph is exported * * @param delemet dictionary of embedded objects stored in staticvars */ void includeEmbeddedFiles(QMap delemet); /** * backsup embedded files from the Odt when graph is exported * @param delemet dictionary of embedded objects stored in staticvars */ void backupEmbeddedFiles(QMap delemet); /** * deletes embedded files corresponding to container delement * @param delemet dictionary of embedded objects stored in staticvars */ void deleteEmbeddedFiles(QMap delemet); /// export undo and redo graphs void exportGraphs(); // function2.py /** * get data from position tag and arrange it into a list * @param postag position tag * @return the list of data extracted from position tag */ QList getDataFromPosTag(const QString &postag); /** * create position class from string extracted from the XML node * @param change XML node. * @param moved true if moved position is wanted, False otherwise * @return created position class */ MctPosition * getPosFromElementreeNode(const QDomElement &change, bool moved=false); /** * create position class from string extracted from the XML node. --- new * * The index start from 1 in the xml, we need to fix that. * @param change the XML node. * @param moved true if moved position is wanted, False otherwise * @return created position class. */ MctPosition * getPosFromElementreeNodeNew(const QDomElement &change, bool moved=false); /** * create position class from string extracted from the XML node. --- Obsolete * * @param change The XML node. * @param moved True if moved position is wanted, False otherwise * @return Returns with the created position class. * * @todo if obsolete why not removed? */ MctPosition * getPosFromElementreeNodeOld(const QDomElement &change, bool moved=false); /** * recursively add position attribute to the node of the graph. * * The index start from 0 in Calligra, and start from 1 in the xml. * @param change change node in the XML * @param pos position * @param moved if true, moved position is affected. * @param clearfirst if true, position attributes in the XML node are cleared */ void addPos2change(QDomElement *change, MctPosition *pos, bool moved=false, bool clearfirst=true); /** * decide, whether the chage node represents table change or not * * @param changeNode * @return Returns with True if the changenode is related to table change, False otherwise */ bool isTableChange(const MctChange *changeNode); FIXME_TextInterface * getTextInterface(FIXME_TextInterface *parent, MctPosition *position); QTextCursor * CreateCursorFromRecursivePos(KoTextDocument *doc, MctPosition *position); QTextCursor * CreateCursorFromPos( FIXME_TextInterface *xtext_interface, MctPosition *position); // function3.py /** * gather indexes of newline characters in the parameter string * * @param string * @return list of indexes * @todo unused method */ QList *findNewLines(QString string); /** * creates change node for redo operation * * @param changeNode The undo changeNode. * @param doc * @return */ MctChange * createRedoChangeNode(KoTextDocument *doc, MctChange *changeNode); /// @todo unused void insertTextGraphicObjects(MctChange *changeNode, FIXME_Doc * doc/*,staticvars */,bool withprops=true, FIXME_TextInterface *xtext_interface=NULL); /// @todo unused void instertTextTable(MctChange *changeNode/*,staticvars */, bool withprops=true, FIXME_TextInterface *xtext_interface=NULL); /// @todo unused FIXME_PropertyDictionary * getNoneDefaultProps(MctEmbObjProperties *props); // own functions /** * recursive copy of the given directory * * @param dir directory to copy * @param path destination * @param destinationZip output which contains the copied content */ static void recursiveDirectoryCopy(const KArchiveDirectory *dir, const QString &path, KZip *destinationZip); /** * check whether the property type is supported or not * * @param key property type id @todo use enum class instead */ static void textPropMapTester(int key); /** * check wether the given odt file has undo/redo.xml in the package * @param odt file to check * @return true if the odt has mct support, false otherwise * @todo unused function */ static bool hasMctSupport(QString odt); /// getter MctUndoGraph* getUndoGraph(); /// setter void setUndoGraph(MctUndoGraph* graph); /// getter MctRedoGraph* getRedoGraph(); /// setter void setRedoGraph(MctRedoGraph* graph); /// getter QString getFileURL(); /// setter void setFileURL(const QString &url); /// getter QList* getChanges(); /// setter void setChanges(QList *change); /// clear the list of changes void clearChanges(); /// getter KoDocument* getKoDocument(); /// setter void setKoDocument(KoDocument* doc); /** * create a map to the frames of the document * * The created map contains from which block how much position correction is needed * @param koTextDoc document in action * @return map of frame indexes */ QMap * getFrameIndexes(const KoTextDocument *koTextDoc); /// getter bool getMctState() const; /// setter void setMctState(bool state); /// getter @todo unused QString getAddedShapeType(); void setAddedShapeType(const QString &shapeType); /** * extends XML attribute with namespace prefix * * @param attribute xml attribute * @param ns namespace prefix * @return "ns:attribute" */ static QString attributeNS(const QString &attribute, const XMLns &ns); private: /// constructor MctStaticData(); MctStaticData(const MctStaticData&); MctStaticData& operator=(const MctStaticData&); static MctStaticData* m_Instance; KoDocument *kodoc; ///< kde document handler class QList * changes; ///< list of changes MctUndoGraph * undograph; ///< undo graph MctRedoGraph * redograph; ///< redo graph QString fileURL; ///< path to document in action bool mctState; ///< MCT status indicator QString addedShapeType; ///< ? }; #endif // MCTSTATICDATA_H diff --git a/libs/text/mct/MctTableProperties.h b/libs/text/mct/MctTableProperties.h index c430485a787..2a178b4a3cd 100644 --- a/libs/text/mct/MctTableProperties.h +++ b/libs/text/mct/MctTableProperties.h @@ -1,50 +1,52 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTTABLEPROPERTIES_H #define MCTTABLEPROPERTIES_H #include "MctPropertyBase.h" +#include "kotext_export.h" + /** * Text table properties */ -class MctTableProperties : public MctPropertyBase +class KOTEXT_EXPORT MctTableProperties : public MctPropertyBase { public: /// constructor MctTableProperties(const QString &name, int rows = -1, int cols = -1); ~MctTableProperties(); /// getter int rows() const; /// setter void setRows(int value); /// getter int cols() const; /// setter void setCols(int value); private: int m_rows; ///< row count int m_cols; ///< col count }; #endif // MCTTABLEPROPERTIES_H diff --git a/libs/text/mct/MctUndoClass.h b/libs/text/mct/MctUndoClass.h index aa7ac17d5fe..389a8cbed1b 100644 --- a/libs/text/mct/MctUndoClass.h +++ b/libs/text/mct/MctUndoClass.h @@ -1,145 +1,147 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTUNDOCLASS_H #define MCTUNDOCLASS_H #include "MctChange.h" #include "MctChangeset.h" #include "MctDoBase.h" #include "MctRedoGraph.h" +#include "kotext_export.h" + #include /** * Do undo operation for all changes of a revision * * Undo class prepare and apply a change set before added to abstract graph as a new redo revision. * It behaves like a hub, gathers uncommited changes, decide the type of each change, * collect type depending information, APPLY the change and than add it to the abstract graph (redo). */ -class MctUndoClass : MctDoBase +class KOTEXT_EXPORT MctUndoClass : MctDoBase { public: /// constructor MctUndoClass(KoTextDocument *kotextdoc); ~MctUndoClass(); /** * add changeset to redo abstarct graph * * @param changesetNode * @param redoChangeList * @return */ MctChangeset * addChangesetToRedo(MctChangeset * changesetNode, QList * redoChangeList); /** * prepare changes into changeset object * * @param changesetNode * @param add2Graph */ void undoChangeset(MctChangeset * changesetNode, bool add2Graph = true); /** * call type related private function (undo the change) * * @param changeNode individual change which is tested * @return properly configured change object */ MctChange* undoChange(MctChange * changeNode); private: /// undo added string change and commit to redo MctChange * undoAddedString(MctChange * changeNode); /// undo removed string change and commit to redo MctChange * undoRemovedString(MctChange * changeNode); /// undo moved string change and commit to redo MctChange * undoMovedString(MctChange * changeNode); /// undo added string (in table) change and commit to redo MctChange * undoAddedStringInTable(MctChange * changeNode); /// undo removed string (in table) change and commit to redo MctChange * undoRemovedStringInTable(MctChange * changeNode); /// undo moved string change (in table) and commit to redo MctChange * undoMovedStringInTable(MctChange * changeNode); /// undo added paragraph break change and commit to redo MctChange * undoParagraphBreak(MctChange * changeNode); /// undo deleted paragraph break change and commit to redo MctChange * undoDelParagraphBreak(MctChange * changeNode); /// undo added paragraph break change (in table) and commit to redo MctChange * undoParagraphBreakInTable(MctChange * changeNode); /// undo deleted paragraph break change (in table) and commit to redo MctChange * undoDelParagraphBreakInTable(MctChange * changeNode); /// undo style change and commit to redo MctChange * undoStyleChange(MctChange * changeNode); /// wrapper for different style type changes void undoPropsChange(QTextCursor *cursor, ChangeEventList * changeNode); /// undo style change (in table) and commit to redo MctChange * undoStyleChangeInTable(MctChange * changeNode); /// undo added object change and commit to redo MctChange * undoAddedTextGraphicObjects(MctChange * changeNode, bool withprops = true); /// undo removed object change and commit to redo MctChange * undoRemovedTextGraphicObjects(MctChange * changeNode, bool withprops = true); /// undo added onbject change (in table) and commit to redo MctChange * undoAddedTextGraphicObjectsInTable(MctChange * changeNode, bool withprops = true); /// undo removed object change (in table) and commit to redo MctChange * undoRemovedTextGraphicObjectsInTable(MctChange * changeNode, bool withprops = true); /// undo added text table change and commit to redo MctChange * undoAddedTextTable(MctChange * changeNode, bool withprops = true); /// undo removed text table change and commit to redo MctChange * undoRemovedTextTable(MctChange * changeNode); /// undo added text table change (in table) and commit to redo MctChange * undoAddedTextTableInTable(MctChange * changeNode, bool withprops = true); /// undo removed text table change (in table) and commit to redo MctChange * undoRemovedTextTableInTable(MctChange * changeNode); /// undo added row change in table and commit to redo MctChange * undoAddedRowInTable(MctChange * changeNode); /// undo removed row change in table and commit to redo MctChange * undoRemovedRowInTable(MctChange * changeNode); /// undo added col change in table and commit to redo MctChange * undoAddedColInTable(MctChange * changeNode); /// undo added col change in table and commit to redo MctChange * undoRemovedColInTable(MctChange * changeNode); }; #endif // MCTUNDOCLASS_H diff --git a/libs/text/mct/MctUndoGraph.h b/libs/text/mct/MctUndoGraph.h index 1f4c5e72a4c..383f9840ea9 100644 --- a/libs/text/mct/MctUndoGraph.h +++ b/libs/text/mct/MctUndoGraph.h @@ -1,228 +1,230 @@ /* This file is part of the KDE project * Copyright (C) 2015-2016 MultiRacio Ltd. (S.Schliszka, F.Novak, P.Rakyta) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef MCTUNDOGRAPH_H #define MCTUNDOGRAPH_H #include "MctUndoGraphXMLfilter.h" +#include "kotext_export.h" + class ChangeEvent; using ChangeEventList = QList; /** * Export changes from abstract undo graph to XML */ -class MctUndoGraph : public MctUndoGraphXMLfilter +class KOTEXT_EXPORT MctUndoGraph : public MctUndoGraphXMLfilter { public: MctUndoGraph(const QString &odt, KoTextDocument *m_koTextDoc); virtual ~MctUndoGraph(); /** * convert and add changeset from redo graph into undo graph * * @param redochangeset node in the redo graph * @return created changeset node. */ MctChangeset* addchangesetFromRedo(MctChangeset* redochangeset); /** * add a single change to changeset and XML (wrapper function) * * @param change change to be added * @param changeset parent changeset */ void addChange(MctChange* change, MctChangeset* changeset); /** * add addString to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void addString(QDomElement *xmlchange, MctChange* change); /** * add removeString to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void removeString(QDomElement *xmlchange, MctChange* change); /** * add moveString to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void moveString(QDomElement *xmlchange, MctChange* change); /** * add addParBreak to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void addParBreak(QDomElement *xmlchange, MctChange* change); /** * add delParBreak to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void delParBreak(QDomElement *xmlchange, MctChange* change); /** * add styleChange to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void styleChange(QDomElement *xmlchange, MctChange* change); /** * add styling change as subnode * * @param subnode node to insert change * @param propchanges style changes in a list * @param type style type flag @todo replace with enum */ void fillPropertySubNode(QDomElement *subnode, ChangeEventList *propchanges, int type); //UNO /** * add textFrame to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void textFrame(QDomElement *xmlchange, MctChange* change); /** * add textTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted * @param added */ void textTable(QDomElement *xmlchange, MctChange* change, bool added=true); /** * add textGraphicObject to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted * @param added */ void textGraphicObject(QDomElement *xmlchange, MctChange* change, bool added=true); /** * add embeddedObject to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void embeddedObject(QDomElement *xmlchange, MctChange* change); /** * add addStringInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void addStringInTable(QDomElement *xmlchange, MctChange* change); /** * add removeStringInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void removeStringInTable(QDomElement *xmlchange, MctChange* change); /** * add moveStringInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void moveStringInTable(QDomElement *xmlchange, MctChange* change); /** * add addParBreakInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void addParBreakInTable(QDomElement *xmlchange, MctChange* change); /** * add delParBreakInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void delParBreakInTable(QDomElement *xmlchange, MctChange* change); /** * add styleChangeInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void styleChangeInTable(QDomElement *xmlchange, MctChange* change); /** * add textGraphicObjectInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted * @param added if False other style data are also exported. */ void textGraphicObjectInTable(QDomElement *xmlchange, MctChange* change, bool added=true); /** * add textTableInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted * @param added if False other style data are also exported. */ void textTableInTable(QDomElement *xmlchange, MctChange* change, bool added=true); /** * add rowChangeInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void rowChangeInTable(QDomElement *xmlchange, MctChange* change); /** * add colChangeInTable to changeset and XML * * @param xmlchange node to insert change * @param change change to inserted */ void colChangeInTable(QDomElement *xmlchange, MctChange* change); }; #endif // MCTUNDOGRAPH_H diff --git a/words/part/CMakeLists.txt b/words/part/CMakeLists.txt index de982dfb42a..fe91303837e 100644 --- a/words/part/CMakeLists.txt +++ b/words/part/CMakeLists.txt @@ -1,191 +1,192 @@ project(wordspart) #TODO port to textlayout-rework add_subdirectory( tests ) -include_directories( ${KORDF_INCLUDES} ${KOTEXT_INCLUDES} ${TEXTLAYOUT_INCLUDES}) +include_directories(${KORDF_INCLUDES} ${KOTEXT_INCLUDES} ${TEXTLAYOUT_INCLUDES}) +include_directories(${KOMAIN_INCLUDES} {CMAKE_SOURCE_DIR}/libs/text/mct) ########### WordsPrivate library ############### set(wordsprivate_LIB_SRCS KWFactory.cpp WordsDebug.cpp Words.cpp KWApplicationConfig.cpp KWCanvasBase.cpp KWCanvas.cpp KWCanvasItem.cpp KWDocument.cpp KWGui.cpp KWView.cpp KWPart.cpp KWPage.cpp KWPageCacheManager.cpp KWPageManager.cpp KWPageStyle.cpp KWViewMode.cpp KWViewModeNormal.cpp KWViewModePreview.cpp KWStatusBar.cpp KWOdfLoader.cpp KWOdfWriter.cpp KWOdfSharedLoadingData.cpp KWRootAreaProviderBase.cpp KWRootAreaProviderTextBox.cpp KWRootAreaProvider.cpp mct/MctWidget.cpp mct/MctMain.cpp mct/MctManagerBase.cpp mct/MctRevisionManager.cpp mct/mctmergemanagerdialog.cpp pagetool/KWPageTool.cpp pagetool/KWPageToolFactory.cpp pagetool/SimpleSetupWidget.cpp pagetool/SimpleHeaderFooterWidget.cpp frames/KWFrameLayout.cpp frames/KWFrame.cpp frames/KWFrameSet.cpp frames/KWTextFrameSet.cpp frames/KWCopyShape.cpp widgets/KoFindToolbar.cpp dialogs/KWFrameConnectSelector.cpp dialogs/KWRunAroundProperties.cpp dialogs/KWAnchoringProperties.cpp dialogs/KWFrameDialog.cpp dialogs/KWShapeConfigFactory.cpp dialogs/KWDocumentColumns.cpp dialogs/KWStartupWidget.cpp dialogs/KWPageSettingsDialog.cpp dialogs/KWPrintingDialog.cpp dialogs/KWCreateBookmarkDialog.cpp dialogs/KWSelectBookmarkDialog.cpp dialogs/KWConfigureDialog.cpp dockers/KWStatisticsDocker.cpp dockers/KWStatisticsWidget.cpp dockers/StatisticsPreferencesPopup.cpp dockers/KWNavigationDocker.cpp dockers/KWNavigationDockerFactory.cpp dockers/KWNavigationWidget.cpp commands/KWPageStylePropertiesCommand.cpp commands/KWNewPageStyleCommand.cpp commands/KWChangePageStyleCommand.cpp commands/KWShapeCreateCommand.cpp ) set(wordsprivate_LIB_SRCS ${wordsprivate_LIB_SRCS} dockers/KWDebugDocker.cpp dockers/KWDebugDockerFactory.cpp dockers/KWDebugWidget.cpp ) if( SHOULD_BUILD_FEATURE_RDF ) set(wordsprivate_LIB_SRCS ${wordsprivate_LIB_SRCS} dockers/KWRdfDocker.cpp dockers/KWRdfDockerFactory.cpp dockers/KWRdfDockerTree.cpp ) endif() ki18n_wrap_ui(wordsprivate_LIB_SRCS dialogs/KWFrameConnectSelector.ui dialogs/KWRunAroundProperties.ui dialogs/KWAnchoringProperties.ui dialogs/KWDocumentColumns.ui dialogs/KWStartupWidget.ui dialogs/KWCreateBookmark.ui dialogs/KWSelectBookmark.ui dialogs/KWInsertImage.ui mct/MctWidget.ui mct/MctRevisionManager.ui mct/mctmergemanagerdialog.ui dockers/StatisticsPreferencesPopup.ui pagetool/SimpleSetupWidget.ui pagetool/SimpleHeaderFooterWidget.ui ) if( SHOULD_BUILD_FEATURE_RDF ) ki18n_wrap_ui(wordsprivate_LIB_SRCS dockers/KWRdfDocker.ui ) endif() add_library(wordsprivate SHARED ${wordsprivate_LIB_SRCS}) generate_export_header(wordsprivate BASE_NAME words EXPORT_FILE_NAME words_generated_export.h ) target_link_libraries(wordsprivate PUBLIC komain PRIVATE kotextlayout KF5::IconThemes ) if( SHOULD_BUILD_FEATURE_RDF ) target_link_libraries(wordsprivate PRIVATE kordf ) endif() set_target_properties(wordsprivate PROPERTIES VERSION ${GENERIC_CALLIGRA_LIB_VERSION} SOVERSION ${GENERIC_CALLIGRA_LIB_SOVERSION} ) install(TARGETS wordsprivate ${INSTALL_TARGETS_DEFAULT_ARGS}) ########### WordsPart Library ############### set(wordspart_PART_SRCS KWFactoryInit.cpp ) add_library(calligrawordspart MODULE ${wordspart_PART_SRCS}) calligra_part_desktop_to_json(calligrawordspart wordspart.desktop) target_link_libraries(calligrawordspart wordsprivate ) install(TARGETS calligrawordspart DESTINATION ${PLUGIN_INSTALL_DIR}/calligra/parts) ########### install files ############### install( FILES calligrawords.rc calligrawords_readonly.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/calligrawords) install( FILES calligrawordsrc DESTINATION ${CONFIG_INSTALL_DIR} ) if (SHOULD_BUILD_DEVEL_HEADERS) install( FILES words_export.h KWPage.h KWPageManager.h KWPageStyle.h Words.h KWCanvasBase.h KWCanvas.h KWCanvasItem.h KWDocument.h KWApplicationConfig.h KWViewMode.h KWView.h KWViewModeNormal.h DESTINATION ${INCLUDE_INSTALL_DIR}/calligrawords/part COMPONENT Devel) install( FILES frames/KWFrame.h frames/KWFrameLayout.h frames/KWFrameSet.h frames/KWTextFrameSet.h DESTINATION ${INCLUDE_INSTALL_DIR}/calligrawords/part/frames COMPONENT Devel) endif()