[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri May 16 07:47:47 PDT 2014


 sc/qa/unit/subsequent_export-test.cxx |  131 +++++++++++++++++++++++++++++-----
 sc/source/filter/xml/xmlexprt.cxx     |   39 +++++++++-
 2 files changed, 149 insertions(+), 21 deletions(-)

New commits:
commit fcf5b5c081ded93b12dd888236d0a860b7693ed1
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri May 16 10:45:40 2014 -0400

    fdo#75056: Overline attribute needs special treatment as well.
    
    Also fix the export of underline types as well.  It was always saved
    as a single line.
    
    Change-Id: I88cb0f3702a6afc14544ecbce8f200b5422fd78f

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 737a881..d61496e 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1171,6 +1171,10 @@ const SvxFieldData* toXMLPropertyStates(
                 if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
                     break;
 
+                sal_Int32 nIndexType = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-underline-type", 0);
+                if (nIndexType == -1 || nIndexType > nEntryCount)
+                    break;
+
                 sal_Int32 nIndexColor = xMapper->FindEntryIndex("CharUnderlineColor", XML_NAMESPACE_STYLE, "text-underline-color");
                 if (nIndexColor == -1 || nIndexColor > nEntryCount)
                     break;
@@ -1182,6 +1186,7 @@ const SvxFieldData* toXMLPropertyStates(
                 const SvxUnderlineItem* pUL = static_cast<const SvxUnderlineItem*>(p);
                 pUL->QueryValue(aAny, MID_TL_STYLE);
                 rPropStates.push_back(XMLPropertyState(nIndexStyle, aAny));
+                rPropStates.push_back(XMLPropertyState(nIndexType,  aAny));
                 rPropStates.push_back(XMLPropertyState(nIndexWidth, aAny));
 
                 pUL->QueryValue(aAny, MID_TL_COLOR);
@@ -1193,10 +1198,38 @@ const SvxFieldData* toXMLPropertyStates(
             break;
             case EE_CHAR_OVERLINE:
             {
-                if (!static_cast<const SvxOverlineItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                    continue;
+                // Same with overline.  Do just as we do with underline attributes.
+                sal_Int32 nIndexStyle = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-overline-style", 0);
+                if (nIndexStyle == -1 || nIndexStyle > nEntryCount)
+                    break;
 
-                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+                sal_Int32 nIndexWidth = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-overline-width", 0);
+                if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
+                    break;
+
+                sal_Int32 nIndexType = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-overline-type", 0);
+                if (nIndexType == -1 || nIndexType > nEntryCount)
+                    break;
+
+                sal_Int32 nIndexColor = xMapper->FindEntryIndex("CharOverlineColor", XML_NAMESPACE_STYLE, "text-overline-color");
+                if (nIndexColor == -1 || nIndexColor > nEntryCount)
+                    break;
+
+                sal_Int32 nIndexHasColor = xMapper->FindEntryIndex("CharOverlineHasColor", XML_NAMESPACE_STYLE, "text-overline-color");
+                if (nIndexHasColor == -1 || nIndexHasColor > nEntryCount)
+                    break;
+
+                const SvxOverlineItem* pOL = static_cast<const SvxOverlineItem*>(p);
+                pOL->QueryValue(aAny, MID_TL_STYLE);
+                rPropStates.push_back(XMLPropertyState(nIndexStyle, aAny));
+                rPropStates.push_back(XMLPropertyState(nIndexType,  aAny));
+                rPropStates.push_back(XMLPropertyState(nIndexWidth, aAny));
+
+                pOL->QueryValue(aAny, MID_TL_COLOR);
+                rPropStates.push_back(XMLPropertyState(nIndexColor, aAny));
+
+                pOL->QueryValue(aAny, MID_TL_HASCOLOR);
+                rPropStates.push_back(XMLPropertyState(nIndexHasColor, aAny));
             }
             break;
             case EE_CHAR_COLOR:
commit 5c0b8937f4f41ed1e4a01151bc96113f65c2770c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri May 16 10:45:09 2014 -0400

    fdo#75056: Write test for this.
    
    Change-Id: I716467ffe81a1f71f03e0dc7a17c33b2ed39d334

diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index ab25140..2e36357 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -45,6 +45,7 @@
 #include <editeng/crossedoutitem.hxx>
 #include <editeng/borderline.hxx>
 #include <editeng/fontitem.hxx>
+#include <editeng/udlnitem.hxx>
 #include <formula/grammar.hxx>
 
 #include <com/sun/star/table/BorderLineStyle.hpp>
@@ -437,6 +438,20 @@ void setAttribute( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, sa
             rEE.QuickSetAttribs(aItemSet, aSel);
         }
         break;
+        case EE_CHAR_OVERLINE:
+        {
+            SvxOverlineItem aItem(UNDERLINE_DOUBLE, nType);
+            aItemSet.Put(aItem);
+            rEE.QuickSetAttribs(aItemSet, aSel);
+        }
+        break;
+        case EE_CHAR_UNDERLINE:
+        {
+            SvxUnderlineItem aItem(UNDERLINE_DOUBLE, nType);
+            aItemSet.Put(aItem);
+            rEE.QuickSetAttribs(aItemSet, aSel);
+        }
+        break;
         default:
             ;
     }
@@ -539,6 +554,40 @@ void ScExportTest::testRichTextExportODS()
             return false;
         }
 
+        static bool isOverline(const editeng::Section& rAttr, FontUnderline eStyle)
+        {
+            if (rAttr.maAttributes.empty())
+                return false;
+
+            std::vector<const SfxPoolItem*>::const_iterator it = rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end();
+            for (; it != itEnd; ++it)
+            {
+                const SfxPoolItem* p = *it;
+                if (p->Which() != EE_CHAR_OVERLINE)
+                    continue;
+
+                return static_cast<const SvxOverlineItem*>(p)->GetLineStyle() == eStyle;
+            }
+            return false;
+        }
+
+        static bool isUnderline(const editeng::Section& rAttr, FontUnderline eStyle)
+        {
+            if (rAttr.maAttributes.empty())
+                return false;
+
+            std::vector<const SfxPoolItem*>::const_iterator it = rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end();
+            for (; it != itEnd; ++it)
+            {
+                const SfxPoolItem* p = *it;
+                if (p->Which() != EE_CHAR_UNDERLINE)
+                    continue;
+
+                return static_cast<const SvxUnderlineItem*>(p)->GetLineStyle() == eStyle;
+            }
+            return false;
+        }
+
         static bool isFont(const editeng::Section& rAttr, const OUString& rFontName)
         {
             if (rAttr.maAttributes.empty())
@@ -715,6 +764,41 @@ void ScExportTest::testRichTextExportODS()
             return true;
         }
 
+        bool checkB8(const EditTextObject* pText) const
+        {
+            if (!pText)
+                return false;
+
+            if (pText->GetParagraphCount() != 1)
+                return false;
+
+            if (pText->GetText(0) != "Over and Under")
+                return false;
+
+            std::vector<editeng::Section> aSecAttrs;
+            pText->GetAllSections(aSecAttrs);
+            if (aSecAttrs.size() != 3)
+                return false;
+
+            // First section shoul have overline applied.
+            const editeng::Section* pAttr = &aSecAttrs[0];
+            if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 0 || pAttr->mnEnd != 4)
+                return false;
+
+            if (pAttr->maAttributes.size() != 1 || !isOverline(*pAttr, UNDERLINE_DOUBLE))
+                return false;
+
+            // Last section should have underline applied.
+            pAttr = &aSecAttrs[2];
+            if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 9 || pAttr->mnEnd != 14)
+                return false;
+
+            if (pAttr->maAttributes.size() != 1 || !isUnderline(*pAttr, UNDERLINE_DOUBLE))
+                return false;
+
+            return true;
+        }
+
     } aCheckFunc;
 
     // Start with an empty document, put one edit text cell, and make sure it
@@ -754,8 +838,8 @@ void ScExportTest::testRichTextExportODS()
     // Insert a multi-line content to B4.
     pEE->Clear();
     pEE->SetText("One\nTwo\nThree");
-    pDoc->SetEditText(ScAddress(3,1,0), pEE->CreateTextObject());
-    pEditText = pDoc->GetEditText(ScAddress(3,1,0));
+    pDoc->SetEditText(ScAddress(1,3,0), pEE->CreateTextObject());
+    pEditText = pDoc->GetEditText(ScAddress(1,3,0));
     CPPUNIT_ASSERT_MESSAGE("Incorret B4 value.", aCheckFunc.checkB4(pEditText));
 
     // Reload the doc again, and check the content of B2 and B4.
@@ -766,14 +850,14 @@ void ScExportTest::testRichTextExportODS()
 
     pEditText = pDoc->GetEditText(ScAddress(1,1,0));
     CPPUNIT_ASSERT_MESSAGE("B2 should be an edit text.", pEditText);
-    pEditText = pDoc->GetEditText(ScAddress(3,1,0));
+    pEditText = pDoc->GetEditText(ScAddress(1,3,0));
     CPPUNIT_ASSERT_MESSAGE("Incorret B4 value.", aCheckFunc.checkB4(pEditText));
 
     // Insert a multi-line content to B5, but this time, set some empty paragraphs.
     pEE->Clear();
     pEE->SetText("\nTwo\nThree\n\nFive\n");
-    pDoc->SetEditText(ScAddress(4,1,0), pEE->CreateTextObject());
-    pEditText = pDoc->GetEditText(ScAddress(4,1,0));
+    pDoc->SetEditText(ScAddress(1,4,0), pEE->CreateTextObject());
+    pEditText = pDoc->GetEditText(ScAddress(1,4,0));
     CPPUNIT_ASSERT_MESSAGE("Incorret B5 value.", aCheckFunc.checkB5(pEditText));
 
     // Insert a text with strikethrough in B6.
@@ -781,8 +865,8 @@ void ScExportTest::testRichTextExportODS()
     pEE->SetText("Strike Me");
     // Set the 'Strike' part strikethrough.
     setAttribute(*pEE, 0, 0, 6, EE_CHAR_STRIKEOUT);
-    pDoc->SetEditText(ScAddress(5,1,0), pEE->CreateTextObject());
-    pEditText = pDoc->GetEditText(ScAddress(5,1,0));
+    pDoc->SetEditText(ScAddress(1,5,0), pEE->CreateTextObject());
+    pEditText = pDoc->GetEditText(ScAddress(1,5,0));
     CPPUNIT_ASSERT_MESSAGE("Incorret B6 value.", aCheckFunc.checkB6(pEditText));
 
     // Insert a text with different font segments in B7.
@@ -790,25 +874,36 @@ void ScExportTest::testRichTextExportODS()
     pEE->SetText("Font1 and Font2");
     setFont(*pEE, 0, 0, 5, "Courier");
     setFont(*pEE, 0, 10, 15, "Luxi Mono");
-    pDoc->SetEditText(ScAddress(6,1,0), pEE->CreateTextObject());
-    pEditText = pDoc->GetEditText(ScAddress(6,1,0));
+    pDoc->SetEditText(ScAddress(1,6,0), pEE->CreateTextObject());
+    pEditText = pDoc->GetEditText(ScAddress(1,6,0));
     CPPUNIT_ASSERT_MESSAGE("Incorret B7 value.", aCheckFunc.checkB7(pEditText));
 
+    // Insert a text with overline and underline in B8.
+    pEE->Clear();
+    pEE->SetText("Over and Under");
+    setAttribute(*pEE, 0, 0, 4, EE_CHAR_OVERLINE);
+    setAttribute(*pEE, 0, 9, 14, EE_CHAR_UNDERLINE);
+    pDoc->SetEditText(ScAddress(1,7,0), pEE->CreateTextObject());
+    pEditText = pDoc->GetEditText(ScAddress(1,7,0));
+    CPPUNIT_ASSERT_MESSAGE("Incorret B8 value.", aCheckFunc.checkB8(pEditText));
+
     // Reload the doc again, and check the content of B2, B4, B6 and B7.
     ScDocShellRef xNewDocSh3 = saveAndReload(xNewDocSh2, ODS);
     pDoc = xNewDocSh3->GetDocument();
     xNewDocSh2->DoClose();
 
     pEditText = pDoc->GetEditText(ScAddress(1,1,0));
-    CPPUNIT_ASSERT_MESSAGE("Incorret B2 value.", aCheckFunc.checkB2(pEditText));
-    pEditText = pDoc->GetEditText(ScAddress(3,1,0));
-    CPPUNIT_ASSERT_MESSAGE("Incorret B4 value.", aCheckFunc.checkB4(pEditText));
-    pEditText = pDoc->GetEditText(ScAddress(4,1,0));
-    CPPUNIT_ASSERT_MESSAGE("Incorret B5 value.", aCheckFunc.checkB5(pEditText));
-    pEditText = pDoc->GetEditText(ScAddress(5,1,0));
-    CPPUNIT_ASSERT_MESSAGE("Incorret B6 value.", aCheckFunc.checkB6(pEditText));
-    pEditText = pDoc->GetEditText(ScAddress(6,1,0));
-    CPPUNIT_ASSERT_MESSAGE("Incorret B7 value.", aCheckFunc.checkB7(pEditText));
+    CPPUNIT_ASSERT_MESSAGE("Incorret B2 value after save and reload.", aCheckFunc.checkB2(pEditText));
+    pEditText = pDoc->GetEditText(ScAddress(1,3,0));
+    CPPUNIT_ASSERT_MESSAGE("Incorret B4 value after save and reload.", aCheckFunc.checkB4(pEditText));
+    pEditText = pDoc->GetEditText(ScAddress(1,4,0));
+    CPPUNIT_ASSERT_MESSAGE("Incorret B5 value after save and reload.", aCheckFunc.checkB5(pEditText));
+    pEditText = pDoc->GetEditText(ScAddress(1,5,0));
+    CPPUNIT_ASSERT_MESSAGE("Incorret B6 value after save and reload.", aCheckFunc.checkB6(pEditText));
+    pEditText = pDoc->GetEditText(ScAddress(1,6,0));
+    CPPUNIT_ASSERT_MESSAGE("Incorret B7 value after save and reload.", aCheckFunc.checkB7(pEditText));
+    pEditText = pDoc->GetEditText(ScAddress(1,7,0));
+    CPPUNIT_ASSERT_MESSAGE("Incorret B8 value after save and reload.", aCheckFunc.checkB8(pEditText));
 
     xNewDocSh3->DoClose();
 }


More information about the Libreoffice-commits mailing list