Commit 30c66a5d authored by Boudewijn Rempt's avatar Boudewijn Rempt

Move the textlayout and kotext libaries to the text shape plugin

The textshape is the last user of these libraries.
parent ab36b445
......@@ -633,22 +633,8 @@ set(VECTORIMAGE_INCLUDES
${CMAKE_SOURCE_DIR}/libs/vectorimage/libsvm
${CMAKE_SOURCE_DIR}/libs/vectorimage/libwmf)
# KoText depends on koplugin, odf
set(KOTEXT_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kotext
${CMAKE_BINARY_DIR}/libs/kotext
${CMAKE_SOURCE_DIR}/libs/kotext/changetracker
${CMAKE_SOURCE_DIR}/libs/kotext/styles
${CMAKE_SOURCE_DIR}/libs/kotext/opendocument
${FLAKE_INCLUDES}
${KOODF_INCLUDES})
# TextLayout depends on kotext
set(TEXTLAYOUT_INCLUDES ${KOTEXT_INCLUDES}
${CMAKE_SOURCE_DIR}/libs/textlayout
${CMAKE_BINARY_DIR}/libs/textlayout)
# Widgets depends on kritatext and flake
set(KOWIDGETS_INCLUDES ${KOTEXT_INCLUDES}
set(KOWIDGETS_INCLUDES ${FLAKE_INCLUDES}
${CMAKE_SOURCE_DIR}/libs/widgetutils
${CMAKE_BINARY_DIR}/libs/widgetutils
${CMAKE_SOURCE_DIR}/libs/widgets
......
include_directories(${KOTEXT_INCLUDES})
include_directories(${FLAKE_INCLUDES})
include_directories(${CMAKE_BINARY_DIR}/krita/libpsd) #For kispsd_include.h
add_subdirectory( tests )
......
include_directories( ${KRITA_INCLUDES} ${KOTEXT_INCLUDES} )
include_directories( ${KRITA_INCLUDES} ${FLAKE_INCLUDES} )
set(kritahistorydocker_SOURCES
History.h
......
......@@ -51,7 +51,6 @@
#include "KisViewManager.h"
#include "kis_node.h"
#include <KoTextDocumentLayout.h>
#include <KoDocumentResourceManager.h>
#include <KoDataCenterBase.h>
#include <commands/kis_image_layer_add_command.h>
......
......@@ -129,7 +129,7 @@ void KisZoomManager::setup(KActionCollection * actionCollection)
m_horizontalRuler->setShowMousePosition(true);
m_horizontalRuler->createGuideToolConnection(m_view->canvasBase());
new KoRulerController(m_horizontalRuler, m_canvasController->canvas()->resourceManager());
// new KoRulerController(m_horizontalRuler, m_canvasController->canvas()->resourceManager());
m_verticalRuler = new KoRuler(m_view, Qt::Vertical, m_zoomHandler);
m_verticalRuler->setShowMousePosition(true);
m_verticalRuler->createGuideToolConnection(m_view->canvasBase());
......
......@@ -15,8 +15,6 @@ if (SHOULD_BUILD_LIB_CALLIGRA)
add_subdirectory( widgets )
add_subdirectory( store )
add_subdirectory( odf )
add_subdirectory( textlayout )
add_subdirectory( kotext )
add_subdirectory( flake )
add_subdirectory( basicflakes )
add_subdirectory( pigment )
......
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
include_directories(
${KOTEXT_INCLUDES}
${QT_INCLUDES})
add_definitions(-DSPECS_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/specs/")
########### next target ###############
set(TestStyles_test_SRCS TestStyles.cpp)
kde4_add_unit_test(TestStyles TESTNAME libs-kotext-styles-TestStyles ${TestStyles_test_SRCS})
target_link_libraries(TestStyles kritatext Qt5::Test)
########### next target ###############
set(TestListStyly_test_SRCS TestListStyle.cpp)
kde4_add_unit_test(TestListStyle TESTNAME libs-kotext-styles-TestListStyle ${TestListStyly_test_SRCS})
target_link_libraries(TestListStyle kritatext Qt5::Test)
########### next target ###############
set(TestSectionStyle_test_SRCS TestSectionStyle.cpp)
kde4_add_unit_test(TestSectionStyle TESTNAME libs-kotext-styles-TestSectionStyle ${TestSectionStyle_test_SRCS})
target_link_libraries(TestSectionStyle kritatext Qt5::Test)
########### next target ###############
set(TestTableCellStyle_test_SRCS TestTableCellStyle.cpp)
kde4_add_unit_test(TestTableCellStyle TESTNAME libs-kotext-styles-TestTableCellStyle ${TestTableCellStyle_test_SRCS})
target_link_libraries(TestTableCellStyle kritatext Qt5::Test)
########### next target ###############
set(TestStyleManager_test_SRCS TestStyleManager.cpp)
kde4_add_unit_test(TestStyleManager TESTNAME libs-kotext-styles-TestStyleManager ${TestStyleManager_test_SRCS})
target_link_libraries(TestStyleManager kritatext Qt5::Test)
########### next target ###############
#set(TestOpenDocumentStyle_test_SRCS TestOpenDocumentStyle.cpp)
#kde4_add_unit_test(TestOpenDocumentStyle TESTNAME libs-kotext-styles-TestOpenDocumentStyle ${TestOpenDocumentStyle_test_SRCS})
#target_link_libraries(TestOpenDocumentStyle kritatext Qt5::Test ${QT_XML_LIBRARY})
/* This file is part of the KDE project
* Copyright (C) 2007-2010 Thomas Zander <zander@kde.org>
*
* 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.
*/
#include "TestListStyle.h"
#include "styles/KoParagraphStyle.h"
#include "styles/KoListStyle.h"
#include "styles/KoListLevelProperties.h"
#include "KoTextBlockBorderData.h"
#include "KoTextDocument.h"
#include "styles/KoStyleManager.h"
#include <QTextDocument>
#include <QTextCursor>
#include <QTextBlock>
#include <QTextList>
#include <QTest>
void TestListStyle::testListStyle()
{
KoListStyle ls;
KoListLevelProperties llp = ls.levelProperties(2);
QCOMPARE(llp.level(), 2);
llp.setStyle(KoListStyle::AlphaLowerItem);
KoListLevelProperties llp2 = ls.levelProperties(2);
QVERIFY(llp2.style() != llp.style());
ls.setLevelProperties(llp);
QCOMPARE(llp.level(), 2);
QCOMPARE(llp.style(), KoListStyle::AlphaLowerItem);
llp = ls.levelProperties(2);
QCOMPARE(llp.level(), 2);
QCOMPARE(llp.style(), KoListStyle::AlphaLowerItem);
QTextDocument doc;
KoTextDocument kodoc(&doc);
kodoc.setStyleManager(new KoStyleManager(0));
QTextCursor cursor(&doc);
cursor.insertText("foo\nbar\nBaz\n");
QTextBlock block = doc.begin();
ls.applyStyle(block, 2);
QVERIFY(block.textList());
QTextList *textList = block.textList();
QTextListFormat format = textList->format();
QCOMPARE(format.intProperty(QTextListFormat::ListStyle), (int)(KoListStyle::AlphaLowerItem));
block = block.next();
QVERIFY(block.isValid());
ls.applyStyle(block, 2);
QVERIFY(block.textList());
QCOMPARE(block.textList(), textList);
ls.applyStyle(block, 10); // should set the properties of the only one that is set, level 1
QVERIFY(block.textList());
textList = block.textList();
format = textList->format();
QCOMPARE(format.intProperty(QTextListFormat::ListStyle), (int)(KoListStyle::AlphaLowerItem));
// getting a properties without setting it doesn't change the list.
KoListLevelProperties l4 = ls.levelProperties(4);
QCOMPARE(l4.level(), 4);
QCOMPARE(l4.displayLevel(), 1); // default
l4.setDisplayLevel(3);
QCOMPARE(l4.displayLevel(), 3);
QCOMPARE(ls.hasLevelProperties(4), false);
KoListLevelProperties anotherL4 = ls.levelProperties(4);
QCOMPARE(anotherL4.level(), 4);
QCOMPARE(anotherL4.displayLevel(), 1); // default
QCOMPARE(ls.hasLevelProperties(4), false);
QCOMPARE(ls.hasLevelProperties(5), false);
// new levels are a copy of the existing level.
KoListLevelProperties l5 = ls.levelProperties(5);
QCOMPARE(l5.displayLevel(), 1);
QCOMPARE(l5.style(), KoListStyle::AlphaLowerItem);
QCOMPARE(l5.indent(), 0.);
}
QTEST_MAIN(TestListStyle)
/* This file is part of the KDE project
* Copyright (C) 2007-2010 Thomas Zander <zander@kde.org>
*
* 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 TESTLISTSTYLE_H
#define TESTLISTSTYLE_H
#include <QObject>
class TestListStyle : public QObject
{
Q_OBJECT
public:
TestListStyle() {}
private Q_SLOTS:
void testListStyle();
};
#endif
This diff is collapsed.
/*
Copyright (C) 2011 Pierre Ducroquet <pinaraf@pinaraf.info>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TESTOPENDOCUMENTSTYLE_H
#define TESTOPENDOCUMENTSTYLE_H
#include <QObject>
#include <QMultiHash>
#include <QStringList>
#include <QDomElement>
#include <QList>
#include <KoGenStyle.h>
class Attribute : public QObject
{
Q_OBJECT
public:
Attribute(const QDomElement &element);
QString name();
QStringList listValues();
bool compare (const QString &initialValue, const QString &outputValue);
bool hasReference (const QString &reference);
QMap<QString, QString> requiredExtraAttributes() const;
private:
QStringList listValuesFromNode(const QDomElement &element);
QStringList m_references;
QString m_name;
QStringList m_values;
QList<QStringList> m_equivalences;
QMap<QString, QString> m_requiredExtraAttributes;
};
Q_DECLARE_METATYPE(Attribute*);
class TestOpenDocumentStyle : public QObject
{
Q_OBJECT
public:
TestOpenDocumentStyle();
private:
QByteArray generateStyleNodeWithAttribute(const QString &styleFamily, const QString &attributeName, const QString &attributeValue, const Attribute &attribute);
QByteArray generateStyleProperties(const KoGenStyle &genStyle, const QString &styleFamily);
QList<Attribute*> listAttributesFromRNGName(const QString &name);
QMultiHash<QString, QDomElement> m_rngRules;
template<class T>
bool basicTestFunction(KoGenStyle::Type family, const QString &familyName, Attribute *attribute, const QString &value);
private Q_SLOTS:
void initTestCase();
void testTableColumnStyle();
void testTableColumnStyle_data();
void testTableStyle();
void testTableStyle_data();
void testTableRowStyle();
void testTableRowStyle_data();
void testTableCellStyle();
void testTableCellStyle_data();
void testParagraphStyle();
void testParagraphStyle_data();
void testCharacterStyle();
void testCharacterStyle_data();
};
#endif // TESTOPENDOCUMENTSTYLE_H
/* This file is part of the Calligra project
* Copyright (C) 2010 KO GmbH <cbo@kogmbh.com>
*
* 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.
*/
#include "TestSectionStyle.h"
#include "styles/KoSectionStyle.h"
#include <QTextFrameFormat>
#include <QTest>
void TestSectionStyle::testSectionStyle()
{
// Test basic functionality of the section style (roundtripping to format and back).
KoSectionStyle *style1 = new KoSectionStyle();
QVERIFY(style1);
style1->setLeftMargin(1.0);
style1->setRightMargin(2.0);
QTextFrameFormat format;
style1->applyStyle(format);
KoSectionStyle *style2 = new KoSectionStyle(format);
QVERIFY(style2);
QCOMPARE(style2->leftMargin(), 1.0);
QCOMPARE(style2->rightMargin(), 2.0);
}
QTEST_MAIN(TestSectionStyle)
/* This file is part of the Calligra project
* Copyright (C) 2010 KO GmbH <cbo@kogmbh.com>
*
* 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 TESTSECTIONSTYLE_H
#define TESTSECTIONSTYLE_H
#include <QObject>
class TestSectionStyle : public QObject
{
Q_OBJECT
public:
TestSectionStyle() {}
private Q_SLOTS:
void testSectionStyle();
};
#endif // TESTSECTIONSTYLE_H
This diff is collapsed.
/* This file is part of the KDE project
* Copyright (C) 2013 Elvis Stansvik <elvstone@gmail.com>
*
* 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 TESTSTYLEMANAGER_H
#define TESTSTYLEMANAGER_H
#include <QObject>
class KoStyleManager;
class KoTextDocument;
class QTextDocument;
class TestStyleManager : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void testAddRemoveCharacterStyle();
void testAddRemoveParagraphStyle();
void testAddRemoveListStyle();
void testAddRemoveTableStyle();
void testAddRemoveTableColumnStyle();
void testAddRemoveTableRowStyle();
void testAddRemoveTableCellStyle();
void testAddRemoveSectionStyle();
void testAddAppliedCharacterStyle();
void testApplyAddedCharacterStyle();
void testAddAppliedParagraphStyle();
void testApplyAddedParagraphStyle();
void cleanup();
private:
KoStyleManager *m_styleManager;
KoTextDocument *m_koDoc;
QTextDocument *m_doc;
};
#endif // TESTSTYLEMANAGER_H
This diff is collapsed.
/* This file is part of the Calligra project
* Copyright (C) 2006 Thomas Zander <zander@kde.org>
* Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in>
*
* 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 TESTSTYLES_H
#define TESTSTYLES_H
#include <QObject>
class TestStyles : public QObject
{
Q_OBJECT
private Q_SLOTS: // tests
void testStyleInheritance();
void testChangeParent();
void testTabsStorage();
void testApplyParagraphStyle();
void testApplyParagraphStyleWithParent();
void testCopyParagraphStyle();
void testUnapplyStyle();
};
#endif
#include "TestTableCellStyle.h"
#include "styles/KoTableStyle.h"
#include "styles/KoTableCellStyle.h"
#include <QTextTableCellFormat>
#include <QRectF>
#include <QTest>
void TestTableCellStyle::testPen()
{
// Test basic functionality of the table cell style (roundtripping to format).
QTextTableCellFormat format1;
KoBorder border;
KoBorder::BorderData data;
data.outerPen = QPen(Qt::red, 5.0);
data.innerPen = QPen(Qt::red, 7.0);
border.setBorderData(KoBorder::TopBorder, data);
data.outerPen = QPen(Qt::red, 8.0);
data.innerPen = QPen(Qt::red, 10.0);
border.setBorderData(KoBorder::LeftBorder, data);
data.outerPen = QPen(Qt::red, 11.0);
data.innerPen = QPen(Qt::red, 13.0);
border.setBorderData(KoBorder::BottomBorder, data);
data.outerPen = QPen(Qt::red, 14.0);
data.innerPen = QPen(Qt::red, 16.0);
border.setBorderData(KoBorder::RightBorder, data);
format1.setProperty(KoTableCellStyle::Borders, QVariant::fromValue<KoBorder>(border));
KoTableCellStyle *style = new KoTableCellStyle(format1);
QVERIFY(style);
QTextTableCellFormat format2;
style->applyStyle(format2);
KoBorder border2 = format2.property(KoTableCellStyle::Borders).value<KoBorder>();
QCOMPARE(border2.borderData(KoBorder::TopBorder).outerPen, QPen(Qt::red, 5.0));
QCOMPARE(border2.borderData(KoBorder::TopBorder).innerPen, QPen(Qt::red, 7.0));
QCOMPARE(border2.borderData(KoBorder::LeftBorder).outerPen, QPen(Qt::red, 8.0));