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

List:       kde-commits
Subject:    [Calligra] df41a9b: Improve support for a few text fields:
From:       Shaheed <srhaque () theiet ! org>
Date:       2011-01-13 19:29:19
Message-ID: 20110113192919.9F1F7A6090 () git ! kde ! org
[Download RAW message or body]

commit df41a9b62b741c6c228672fa2b9eda9782b8fe8a
branch master
Author: Shaheed <srhaque@theiet.org>
Date:   Thu Jan 13 19:04:28 2011 +0000

    Improve support for a few text fields:
    
    1. LAST_REVISED_BY, SUBJECT, TITLE are proper inline variables.
    2. AUTHOR is tidied up a little.

diff --git a/filters/words/msword-odf/texthandler.cpp \
b/filters/words/msword-odf/texthandler.cpp index b6c5872..225ee57 100644
--- a/filters/words/msword-odf/texthandler.cpp
+++ b/filters/words/msword-odf/texthandler.cpp
@@ -969,12 +969,16 @@ void KWordTextHandler::fieldStart(const wvWare::FLD* fld, \
wvWare::SharedPtr<cons  
     //check to see if we can process this field type or not
     switch (m_fieldType) {
+    case AUTHOR:
+        break;
     case EQ:
         kDebug(30513) << "processing field... EQ (Combined Characters)";
         break;
     case HYPERLINK:
         kDebug(30513) << "processing field... HYPERLINK";
         break;
+    case LAST_REVISED_BY:
+        break;
     case MACROBUTTON:
         kDebug(30513) << "processing field... MACROBUTTON";
         break;
@@ -989,23 +993,24 @@ void KWordTextHandler::fieldStart(const wvWare::FLD* fld, \
wvWare::SharedPtr<cons  kWarning(30513) << "Warning: unsupported field (REF)";
         m_fieldType = UNSUPPORTED;
         break;
+    case SUBJECT:
+    case TITLE:
+        break;
     case TOC:
         kDebug(30513) << "processing field... TOC";
         m_tocNumber++;
         break;
-    case AUTHOR:
     case EDITTIME:
     case FILENAME:
     case MERGEFIELD:
     case SHAPE:
-    case TITLE:
         kWarning(30513) << "Warning: field instructions not supported, storing field \
result!";  break;
     case SYMBOL:
         kWarning(30513) << "Warning: processing only a subset of field \
instructions!";  break;
     default:
-        kWarning(30513) << "Warning: unrecognized field type, ignoring!";
+        kWarning(30513) << "Warning: unrecognized field type" << m_fieldType << ", \
ignoring!";  m_fieldType = UNSUPPORTED;
         break;
     }
@@ -1254,6 +1259,18 @@ void KWordTextHandler::fieldSeparator(const wvWare::FLD* \
/*fld*/, wvWare::Shared  }
 } //end fieldSeparator()
 
+/**
+ * Fields which are supported by inline variables can be dealt with by emitting
+ * the necessary markup here. For example:
+ * 
+ *	case LAST_REVISED_BY:
+ *	    writer.startElement("text:creator");
+ *	    writer.endElement();
+ *	    break;
+ *
+ * However, fields which do not enjoy such support are dealt with by emitting
+ * the "result" text generated by Word as vanilla text in @ref runOftext.
+ */
 void KWordTextHandler::fieldEnd(const wvWare::FLD* /*fld*/, wvWare::SharedPtr<const \
wvWare::Word97::CHP> chp)  {
 //    Q_UNUSED(chp);
@@ -1300,6 +1317,10 @@ void KWordTextHandler::fieldEnd(const wvWare::FLD* /*fld*/, \
                wvWare::SharedPtr<co
         //else a frame or drawing shape acting as a hyperlink already processed
         break;
     }
+    case LAST_REVISED_BY:
+        writer.startElement("text:creator");
+        writer.endElement();
+        break;
     case MACROBUTTON:
     {
         //TODO: nested fields support required
@@ -1342,6 +1363,10 @@ void KWordTextHandler::fieldEnd(const wvWare::FLD* /*fld*/, \
wvWare::SharedPtr<co  }
         break;
     }
+    case SUBJECT:
+        writer.startElement("text:subject");
+        writer.endElement();
+        break;
     case SYMBOL:
     {
         //TODO: nested fields support required
@@ -1380,6 +1405,10 @@ void KWordTextHandler::fieldEnd(const wvWare::FLD* /*fld*/, \
                wvWare::SharedPtr<co
         m_paragraph->addRunOfText(tmp, chp, QString(""), m_parser->styleSheet());
         break;
     }
+    case TITLE:
+        writer.startElement("text:title");
+        writer.endElement();
+        break;
     case TOC:
     {
         //NOTE: Nested fields had been processed and wrote into content.xml by
@@ -1436,7 +1465,12 @@ void KWordTextHandler::fieldEnd(const wvWare::FLD* /*fld*/, \
wvWare::SharedPtr<co  }
 } //end fieldEnd()
 
-//this handles a basic section of text
+/**
+ * This handles a basic section of text.
+ * 
+ * Fields which are not supported by inline variables in @ref fieldEnd are also \
dealt with by  + * emitting the "result" text generated by Word as vanilla text here.
+ */
 void KWordTextHandler::runOfText(const wvWare::UString& text, \
wvWare::SharedPtr<const wvWare::Word97::CHP> chp)  {
     bool common_flag = false;
@@ -1485,10 +1519,9 @@ void KWordTextHandler::runOfText(const wvWare::UString& text, \
wvWare::SharedPtr<  case FILENAME:
             case MERGEFIELD:
             case SHAPE:
-            case TITLE:
             case TOC:
                 //Ignoring any nested fields around the result!
-                kDebug(30513) << "Processing field result as common text string.";
+                kDebug(30513) << "Processing field result as vanilla text string.";
                 common_flag = true;
                 break;
             default:
diff --git a/filters/words/msword-odf/texthandler.h \
b/filters/words/msword-odf/texthandler.h index 269946d..b2580b6 100644
--- a/filters/words/msword-odf/texthandler.h
+++ b/filters/words/msword-odf/texthandler.h
@@ -293,7 +293,9 @@ private:
         REF = 0x03,
         TOC = 0x0d,
         TITLE = 0x0f,
+        SUBJECT = 0x10,
         AUTHOR = 0x11,
+        LAST_REVISED_BY = 0x14,
         EDITTIME = 0x19,
         NUMPAGES = 0x1a,
         FILENAME = 0x1d,
diff --git a/plugins/variables/InfoVariable.cpp b/plugins/variables/InfoVariable.cpp
index 7d7a02c..9f3f2eb 100644
--- a/plugins/variables/InfoVariable.cpp
+++ b/plugins/variables/InfoVariable.cpp
@@ -33,6 +33,7 @@ static const struct {
     const char * tag;
     const char * saveTag;
 } propertyData[] = {
+    { KoInlineObject::AuthorName, "creator", "text:creator" },
     { KoInlineObject::DocumentURL, "file-name", "text:file-name" },
     { KoInlineObject::Title, "title", "text:title" },
     { KoInlineObject::Subject, "subject", "text:subject" },


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

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