[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/coffice] coffice: Improve sheets integration
From:       Sebastian Sauer <sebastian.sauer () kdab ! com>
Date:       2013-06-30 19:46:56
Message-ID: E1UtNaK-00011h-6W () scm ! kde ! org
[Download RAW message or body]

Git commit 68ed089ca58705084f2db403534e972fc03a90f6 by Sebastian Sauer.
Committed on 30/06/2013 at 15:43.
Pushed by sebsauer into branch 'coffice'.

Improve sheets integration

M  +1    -1    coffice/calligrasheets/calligrasheets.pro
M  +9    -2    coffice/coffice.pro
M  +65   -17   coffice/coffice/AppManager.cpp
M  +6    -1    coffice/coffice/FileSystemModel.cpp
M  +5    -7    coffice/coffice/coffice.pro
M  +10   -2    coffice/common.pri

http://commits.kde.org/calligra/68ed089ca58705084f2db403534e972fc03a90f6

diff --git a/coffice/calligrasheets/calligrasheets.pro \
b/coffice/calligrasheets/calligrasheets.pro index 30d7e37..1581dc9 100644
--- a/coffice/calligrasheets/calligrasheets.pro
+++ b/coffice/calligrasheets/calligrasheets.pro
@@ -13,7 +13,6 @@ DEFINES += QT_NO_SQL
 
 #DEFINES += EIGEN_USE_LAPACKE
 DEFINES += EIGEN2_SUPPORT
-#$${TOP_SOURCE_DIR}/Eigen \
 
 INCLUDEPATH = \
     $${THEIRDPARTY_DIR} \
@@ -30,6 +29,7 @@ INCLUDEPATH = \
     $$CALLIGRASHEETS_DIR/chart \
     $$CALLIGRASHEETS_DIR/interfaces \
     $$CALLIGRASHEETS_DIR/commands \
+    $$CALLIGRASHEETS_DIR/.. \
     $$INCLUDEPATH
 
 LIBS += -lcalligralibs
diff --git a/coffice/coffice.pro b/coffice/coffice.pro
index 01e9464..8de6460 100644
--- a/coffice/coffice.pro
+++ b/coffice/coffice.pro
@@ -1,11 +1,18 @@
 TEMPLATE = subdirs
 
+#FIXME
 CONFIG += ordered
 
+BUILD_WORDS = 1
+BUILD_SHEETS = 1
+
 QMAKE_CACHE = "$${OUT_PWD}/.qmake.cache"
 TOP_SOURCE_DIR = $${IN_PWD}
 TOP_BUILD_DIR = $${OUT_PWD}
+
 system('echo \"\" > $${QMAKE_CACHE}')
+system('echo BUILD_WORDS=$${BUILD_WORDS} >> $${QMAKE_CACHE}')
+system('echo BUILD_SHEETS=$${BUILD_SHEETS} >> $${QMAKE_CACHE}')
 system('echo TOP_SOURCE_DIR=$${TOP_SOURCE_DIR} >> $${QMAKE_CACHE}')
 system('echo TOP_BUILD_DIR=$${TOP_BUILD_DIR} >> $${QMAKE_CACHE}')
 
@@ -14,8 +21,8 @@ include(common.pri)
 SUBDIRS += calligralibs
 SUBDIRS += calligrafilters
 SUBDIRS += calligraplugins
-SUBDIRS += calligrawords
-#SUBDIRS += calligrasheets
+contains(BUILD_WORDS,1):SUBDIRS += calligrawords
+contains(BUILD_SHEETS,1):SUBDIRS += calligrasheets
 SUBDIRS += coffice
 
 android:OTHER_FILES += \
diff --git a/coffice/coffice/AppManager.cpp b/coffice/coffice/AppManager.cpp
index 3ff08e2..349d0b0 100644
--- a/coffice/coffice/AppManager.cpp
+++ b/coffice/coffice/AppManager.cpp
@@ -23,6 +23,7 @@
 #include <kpluginfactory.h>
 #include <kmimetype.h>
 
+#ifndef NO_CALLIGRA_WORDS
 #include <KWPart.h>
 #include <KWView.h>
 #include <KWDocument.h>
@@ -30,6 +31,12 @@
 #include <KWCanvasItem.h>
 #include <KWPage.h>
 #include <KWPageManager.h>
+#endif
+
+#ifndef NO_CALLIGRA_SHEETS
+//#include <part/Part.h>
+//#include <part/Doc.h>
+#endif
 
 /**************************************************************************
  * PartFactory
@@ -48,24 +55,61 @@ public:
         qDeleteAll(m_filterPlugins);
     }
 
-    KWPart* createPart()
+    KoPart* createPart(const QString &file)
     {
-        //TODO reuse the KWPart-factory plugin rather then create manually
-
-        KWPart *part = new KWPart(this);
-        KWDocument *document = new KWDocument(part);
-        document->setCheckAutoSaveFile(false);
-        document->setAutoErrorHandlingEnabled(false);
-        document->resourceManager()->setResource(KoText::StyleManager, \
                QVariant::fromValue<KoStyleManager*>(new KoStyleManager(0)));
-        part->setDocument(document);
+        //TODO reuse the KoPart-factory plugin rather then create manually
+
+        KoPart *part = 0;
+        //KWPart *part = 0;
+
+        KMimeType::Ptr mime = KMimeType::findByUrl(KUrl(file));
+        Q_ASSERT(mime);
+
+#ifndef NO_CALLIGRA_WORDS
+        /*
+        if (mime->name().startsWith("application/vnd.oasis.opendocument.text") ||
+            mime->name().startsWith("application/vnd.openxmlformats-officedocument.wordprocessingml.document") \
|| +            mime->name().startsWith("application/vnd.openxmlformats-officedocument.wordprocessingml.template") \
|| +            mime->name().startsWith("application/vnd.ms-word.document.macroEnabled.12") \
|| +            mime->name().startsWith("application/vnd.ms-word.template.macroEnabled.12") \
|| +            mime->name().startsWith("application/msword") )
+        {
+        */
+            // Calligra Words
+            KWPart *kwpart = new KWPart(this);
+            part = kwpart;
+            KWDocument *document = new KWDocument(kwpart);
+            document->setCheckAutoSaveFile(false);
+            document->setAutoErrorHandlingEnabled(false);
+            document->resourceManager()->setResource(KoText::StyleManager, \
QVariant::fromValue<KoStyleManager*>(new KoStyleManager(0))); +            \
kwpart->setDocument(document); +        /*
+        }
+         */
+#endif
+        /*
+#ifndef NO_CALLIGRA_SHEETS
+        if (mime->name().startsWith("application/vnd.oasis.opendocument.spreadsheet")) \
{ +            // Calligra Sheets
+            Calligra *shpart = new Calligra::Sheets::Part(this);
+            part = shpart;
+            Calligra::Sheets::Doc *document = new Calligra::Sheets::Doc(shpart);
+            document->setCheckAutoSaveFile(false);
+            document->setAutoErrorHandlingEnabled(false);
+            document->resourceManager()->setResource(KoText::StyleManager, \
QVariant::fromValue<KoStyleManager*>(new KoStyleManager(0))); +            \
shpart->setDocument(document); +        }
+#endif
+        */
+        if (!part)
+            qWarning() << Q_FUNC_INFO << "Unsupported mime type=" << mime->name() << \
"for file=" << file;  return part;
     }
 
     QPair<QString, KoFilter*> filterForFile(const QString &file)
     {
         KMimeType::Ptr mime = KMimeType::findByUrl(KUrl(file));
-        if (!mime || mime->name().isEmpty())
-            return QPair<QString, KoFilter*>(); // unknown/unsupported file format
+        Q_ASSERT(mime);
         if (mime->name().startsWith("application/vnd.oasis.opendocument."))
             return QPair<QString, KoFilter*>(); // ODF, native buildin file format
         Q_FOREACH(KoFilter *f, m_filterPlugins) {
@@ -165,16 +209,18 @@ public:
         delete m_doc->d->m_kopart;
         m_doc->d->m_kopart = 0;
 
-        KoPart *kopart = s_partFactory()->createPart();
+        KoPart *kopart = s_partFactory()->createPart(m_file);
         if (!kopart) {
             qWarning() << Q_FUNC_INFO << "Failed to create KoPart";
-            QMetaObject::invokeMethod(m_doc->d, "slotOpenFileFailed", \
Qt::QueuedConnection, Q_ARG(QString, QObject::tr("Unsupported Mimetype"))); +         \
QMetaObject::invokeMethod(m_doc->d, "slotOpenFileFailed", Qt::QueuedConnection, \
Q_ARG(QString, QObject::tr("Unsupported file type %1").arg(m_file)));  return;
         }
 
         m_doc->d->m_progressProxy->setValue(0);
         kopart->document()->setProgressProxy(m_doc->d->m_progressProxy);
 
+//TODO
+//QObject::connect(kopart->document(), SIGNAL(updateView()), m_doc->d, \
                SLOT(slotPageSetupChanged()), Qt::DirectConnection);
         QObject::connect(kopart->document(), SIGNAL(pageSetupChanged()), m_doc->d, \
                SLOT(slotPageSetupChanged()), Qt::DirectConnection);
         QObject::connect(kopart->document(), SIGNAL(layoutFinished()), m_doc->d, \
SLOT(slotLayoutFinished()), Qt::DirectConnection);  m_doc->d->m_kopart = kopart;
@@ -191,7 +237,7 @@ public:
                 if (outputTempFile)
                     outputTempFile->remove();
                 if (error.isEmpty())
-                    error = QObject::tr("Cannot import file");
+                    error = QObject::tr("Cannot import file %1").arg(m_file);
                 qWarning() << Q_FUNC_INFO << inputFile << error;
                 QMetaObject::invokeMethod(m_doc->d, "slotOpenFileFailed", \
Qt::QueuedConnection, Q_ARG(QString, error));  return;
@@ -209,7 +255,7 @@ public:
             m_doc->d->m_kopart = 0;
             QString error = kopart->document()->errorMessage();
             if (error.isEmpty())
-                error = QObject::tr("Cannot load file");
+                error = QObject::tr("Cannot load file %1").arg(m_file);
             qWarning() << Q_FUNC_INFO << inputFile << error;
             QMetaObject::invokeMethod(m_doc->d, "slotOpenFileFailed", \
Qt::QueuedConnection, Q_ARG(QString, error));  return;
@@ -286,7 +332,7 @@ public:
     virtual void run()
     {
         qDebug() << Q_FUNC_INFO << "Starting updating page" << m_page->pageNumber() \
                << "document=" << m_doc->file();
-
+#ifndef NO_CALLIGRA_WORDS
         m_page->setUpdating(false);
 
         KoPart *kopart = m_doc->d->m_kopart;
@@ -299,7 +345,8 @@ public:
         KWPage kwpage = kwPageManager->page(m_page->pageNumber());
         Q_ASSERT_X(kwpage.isValid(), __FUNCTION__, qPrintable(QString("No such page \
number %1 (valid are 1-%2) in document \
%3").arg(m_page->pageNumber()).arg(kwPageManager->pageCount()).arg(kopart->url().toString())));
  
-        KWCanvasItem *canvasItem = \
static_cast<KWCanvasItem*>(kwdoc->documentPart()->canvasItem()); +        \
Q_ASSERT(kwdoc->documentPart()); +        KWCanvasItem *canvasItem = \
dynamic_cast<KWCanvasItem*>(kwdoc->documentPart()->canvasItem());  \
Q_ASSERT(canvasItem);  
         KoShapeManager *shapeManager = canvasItem->shapeManager();
@@ -320,6 +367,7 @@ public:
 
         qDebug() << Q_FUNC_INFO << "Finished updating page" << m_page.data();
         QMetaObject::invokeMethod(m_doc->d, "slotThumbnailFinished", \
Qt::QueuedConnection, Q_ARG(int, m_page->pageNumber()), Q_ARG(QImage, thumbnail)); \
+#endif  }
 };
 
diff --git a/coffice/coffice/FileSystemModel.cpp \
b/coffice/coffice/FileSystemModel.cpp index 8d119d4..dd1f295 100644
--- a/coffice/coffice/FileSystemModel.cpp
+++ b/coffice/coffice/FileSystemModel.cpp
@@ -41,10 +41,15 @@ FileSystemModel::FileSystemModel(QObject *parent)
     //setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot);
 
     setNameFilters(QStringList()
-       << "*.odt" // OpenDocument ODF
+#ifndef NO_CALLIGRA_WORDS
+       << "*.odt" // OpenDocument Text ODT
        << "*.doc" << "*.dot" // Microsoft Word binary
        << "*.docx" << "*.dotx" // Microsoft Word OOXML
        << "*.docm" << "*.dotm" // Microsoft Word macroEnabled
+#endif
+#ifndef NO_CALLIGRA_SHEETS
+       << "*.ods" // OpenDocument Spreadsheet ODS
+#endif
     );
     setNameFilterDisables(false);
 
diff --git a/coffice/coffice/coffice.pro b/coffice/coffice/coffice.pro
index d07dc15..80a1615 100644
--- a/coffice/coffice/coffice.pro
+++ b/coffice/coffice/coffice.pro
@@ -1,7 +1,5 @@
-#!android {
-#    TEMPLATE = app
-#    TARGET = coffice
-#}
+#!android:TEMPLATE = app
+TARGET = coffice
 
 include($${TOP_SOURCE_DIR}/common.pri)
 
@@ -16,12 +14,12 @@ CALLIGRAWORDS_DIR = $${TOP_SOURCE_DIR}/../words
 CALLIGRASHEETS_DIR = $${TOP_SOURCE_DIR}/../sheets
 
 INCLUDEPATH += $${CALLIGRAWORDS_DIR} $${CALLIGRAWORDS_DIR}/part
-#INCLUDEPATH += $${CALLIGRASHEETS_DIR} $${CALLIGRASHEETS_DIR}/part
+INCLUDEPATH += $${CALLIGRASHEETS_DIR} $${CALLIGRASHEETS_DIR}/part
 
 LIBS += -lcalligralibs
 #LIBS += -lcalligraplugins
-LIBS += -lcalligrawords
-#LIBS += -lcalligrasheets
+contains(BUILD_WORDS,1):LIBS += -lcalligrawords
+contains(BUILD_SHEETS,1):LIBS += -lcalligrasheets
 
 unix:!macx {
     # needed for XInitThreads hack
diff --git a/coffice/common.pri b/coffice/common.pri
index b3e846d..b7c817c 100644
--- a/coffice/common.pri
+++ b/coffice/common.pri
@@ -6,6 +6,9 @@ DEFINES += QT_FATAL_ASSERT
 DEFINES += QT_NO_DBUS
 #DEFINES += QT_NO_PRINTER
 
+!contains(BUILD_WORDS,1):DEFINES += NO_CALLIGRA_WORDS
+!contains(BUILD_SHEETS,1):DEFINES += NO_CALLIGRA_SHEETS
+
 # Be less verbose
 *-g++*|*-clang*|*-llvm* {
     QMAKE_CXXFLAGS += -Wno-unused-variable -Wno-unused-but-set-variable \
-Wno-unused-parameter -Wno-unused-function @@ -70,6 +73,7 @@ INCLUDEPATH = \
     $$CALLIGRALIBS_WIDGETSUTILS_DIR \
     $$CALLIGRALIBS_WIDGETS_DIR \
     $${TOP_BUILD_DIR} \
+    $${TOP_BUILD_DIR}/$${TARGET} \
     $${TOP_SOURCE_DIR} \
     $$INCLUDEPATH
 
@@ -104,8 +108,9 @@ defineTest( mocWrapper ) {
         in=$${LITERAL_HASH}include <moc_$${fname}.cpp>
 
         #out=$${OUT_PWD}/$${fname}.moc
-        out=$${TOP_BUILD_DIR}/$${fname}.moc
 
+        outdir=$${TOP_BUILD_DIR}/$${TARGET}
+        out=$${outdir}/$${fname}.moc
         exists( $${fdir}/$${fname}.cpp ) {
             system(echo \"Creating moc-wrapper $$out\")
 
@@ -114,6 +119,7 @@ defineTest( mocWrapper ) {
             #system(moc -E \"$$hdr\" | grep \"class\")
             #system(cat \"$$hdr\" | grep \"Q_OBJECT\")
 
+            !exists($$outdir):system($$QMAKE_MKDIR \"$$outdir\")
             system(echo \"$$in\" > \"$$out\")
         }
     }
@@ -121,8 +127,10 @@ defineTest( mocWrapper ) {
         base=$$basename(hdr)
         fname=$$section(base, ".", 0, 0)
         in=$${LITERAL_HASH}include <moc_$${fname}.cpp>
-        out=$${TOP_BUILD_DIR}/$${fname}.moc
+        outdir=$${TOP_BUILD_DIR}/$${TARGET}
+        out=$${outdir}/$${fname}.moc
         system(echo \"Creating moc-wrapper $$out\")
+        !exists($$outdir):system($$QMAKE_MKDIR \"$$outdir\")
         system(echo \"$$in\" > \"$$out\")
     }
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic