[Libreoffice-commits] core.git: 2 commits - sc/qa xmloff/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Feb 7 18:51:04 PST 2014
sc/qa/unit/subsequent_export-test.cxx | 127 ++++++++++++++++++++++++++++------
xmloff/source/style/cdouthdl.cxx | 2
2 files changed, 106 insertions(+), 23 deletions(-)
New commits:
commit 503b7191737eafa5621dc0aa552092793676c998
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Feb 7 21:47:19 2014 -0500
fdo#73281: Why!?
This restriction makes absolutely no sense. It was likely someone's
temporarily hack that was totally forgotten in the past 10 years...
Not to mention removing this fixes my bug.
Change-Id: I7394cccdc9fe486fda6cdd9b7eaf98fd291895a9
diff --git a/xmloff/source/style/cdouthdl.cxx b/xmloff/source/style/cdouthdl.cxx
index e2bf0e2..d559eb8 100644
--- a/xmloff/source/style/cdouthdl.cxx
+++ b/xmloff/source/style/cdouthdl.cxx
@@ -135,7 +135,7 @@ bool XMLCrossedOutTypePropHdl::exportXML( OUString& rStrExpValue, const uno::Any
sal_Int16 nValue = sal_Int16();
OUStringBuffer aOut;
- if( (rValue >>= nValue) && awt::FontStrikeout::DOUBLE==nValue )
+ if (rValue >>= nValue)
{
bRet = SvXMLUnitConverter::convertEnum(
aOut, (sal_uInt16)nValue, pXML_CrossedoutType_Enum );
commit 27251f37e564ed7b83891875d7d269ff21f18fd9
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Feb 7 21:46:33 2014 -0500
fdo#73281: Write an export test for strike-through text attribute.
Change-Id: Ib9cffac17a8f2e0bb016952ae5dd1b00bd4fc9f9
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 5e67df9..47278e0 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -41,6 +41,7 @@
#include "editeng/eeitem.hxx"
#include "editeng/editobj.hxx"
#include "editeng/section.hxx"
+#include <editeng/crossedoutitem.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -340,6 +341,45 @@ void ScExportTest::testMiscRowHeightExport()
miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) );
}
+namespace {
+
+void setAttribute( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt16 nType )
+{
+ ESelection aSel;
+ aSel.nStartPara = aSel.nEndPara = nPara;
+ aSel.nStartPos = nStart;
+ aSel.nEndPos = nEnd;
+
+ SfxItemSet aItemSet = rEE.GetEmptyItemSet();
+ switch (nType)
+ {
+ case EE_CHAR_WEIGHT:
+ {
+ SvxWeightItem aWeight(WEIGHT_BOLD, nType);
+ aItemSet.Put(aWeight);
+ rEE.QuickSetAttribs(aItemSet, aSel);
+ }
+ break;
+ case EE_CHAR_ITALIC:
+ {
+ SvxPostureItem aItalic(ITALIC_NORMAL, nType);
+ aItemSet.Put(aItalic);
+ rEE.QuickSetAttribs(aItemSet, aSel);
+ }
+ break;
+ case EE_CHAR_STRIKEOUT:
+ {
+ SvxCrossedOutItem aCrossOut(STRIKEOUT_SINGLE, nType);
+ aItemSet.Put(aCrossOut);
+ rEE.QuickSetAttribs(aItemSet, aSel);
+ }
+ break;
+ default:
+ ;
+ }
+}
+
+}
void ScExportTest::testNamedRangeBugfdo62729()
{
@@ -406,6 +446,23 @@ void ScExportTest::testRichTextExportODS()
return false;
}
+ static bool isStrikeOut(const editeng::Section& rAttr)
+ {
+ 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_STRIKEOUT)
+ continue;
+
+ return static_cast<const SvxCrossedOutItem*>(p)->GetStrikeout() == STRIKEOUT_SINGLE;
+ }
+ return false;
+ }
+
bool checkB2(const EditTextObject* pText) const
{
if (!pText)
@@ -498,6 +555,38 @@ void ScExportTest::testRichTextExportODS()
return true;
}
+ bool checkB6(const EditTextObject* pText) const
+ {
+ if (!pText)
+ return false;
+
+ if (pText->GetParagraphCount() != 1)
+ return false;
+
+ if (pText->GetText(0) != "Strike Me")
+ return false;
+
+ std::vector<editeng::Section> aSecAttrs;
+ pText->GetAllSections(aSecAttrs);
+ if (aSecAttrs.size() != 2)
+ return false;
+
+ // Check the first strike-out section.
+ const editeng::Section* pAttr = &aSecAttrs[0];
+ if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 0 || pAttr->mnEnd != 6)
+ return false;
+
+ if (pAttr->maAttributes.size() != 1 || !isStrikeOut(*pAttr))
+ return false;
+
+ // The last section should be unformatted.
+ pAttr = &aSecAttrs[1];
+ if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 6 || pAttr->mnEnd != 9)
+ return false;
+
+ return true;
+ }
+
} aCheckFunc;
// Start with an empty document, put one edit text cell, and make sure it
@@ -508,32 +597,15 @@ void ScExportTest::testRichTextExportODS()
CPPUNIT_ASSERT_MESSAGE("This document should at least have one sheet.", pDoc->GetTableCount() > 0);
// Insert an edit text cell.
- OUString aCellText("Bold and Italic");
ScFieldEditEngine& rEE = pDoc->GetEditEngine();
- rEE.SetText(aCellText);
+ rEE.SetText("Bold and Italic");
+ // Set the 'Bold' part bold.
+ setAttribute(rEE, 0, 0, 4, EE_CHAR_WEIGHT);
+ // Set the 'Italic' part italic.
+ setAttribute(rEE, 0, 9, 15, EE_CHAR_ITALIC);
ESelection aSel;
aSel.nStartPara = aSel.nEndPara = 0;
- {
- // Set the 'Bold' part bold.
- SfxItemSet aItemSet = rEE.GetEmptyItemSet();
- aSel.nStartPos = 0;
- aSel.nEndPos = 4;
- SvxWeightItem aWeight(WEIGHT_BOLD, EE_CHAR_WEIGHT);
- aItemSet.Put(aWeight);
- rEE.QuickSetAttribs(aItemSet, aSel);
- }
-
- {
- // Set the 'Italic' part italic.
- SfxItemSet aItemSet = rEE.GetEmptyItemSet();
- SvxPostureItem aItalic(ITALIC_NORMAL, EE_CHAR_ITALIC);
- aItemSet.Put(aItalic);
- aSel.nStartPos = 9;
- aSel.nEndPos = 15;
- rEE.QuickSetAttribs(aItemSet, aSel);
- }
-
// Set this edit text to cell B2.
pDoc->SetEditText(ScAddress(1,1,0), rEE.CreateTextObject());
const EditTextObject* pEditText = pDoc->GetEditText(ScAddress(1,1,0));
@@ -574,6 +646,15 @@ void ScExportTest::testRichTextExportODS()
pEditText = pDoc->GetEditText(ScAddress(4,1,0));
CPPUNIT_ASSERT_MESSAGE("Incorret B5 value.", aCheckFunc.checkB5(pEditText));
+ // Insert a text with strikethrough in B6.
+ rEE.Clear();
+ rEE.SetText("Strike Me");
+ // Set the 'Strike' part strikethrough.
+ setAttribute(rEE, 0, 0, 6, EE_CHAR_STRIKEOUT);
+ pDoc->SetEditText(ScAddress(5,1,0), rEE.CreateTextObject());
+ pEditText = pDoc->GetEditText(ScAddress(5,1,0));
+ CPPUNIT_ASSERT_MESSAGE("Incorret B6 value.", aCheckFunc.checkB6(pEditText));
+
// Reload the doc again, and check the content of B2, B4 and B6.
ScDocShellRef xNewDocSh3 = saveAndReload(xNewDocSh2, ODS);
pDoc = xNewDocSh3->GetDocument();
@@ -585,6 +666,8 @@ void ScExportTest::testRichTextExportODS()
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));
xNewDocSh3->DoClose();
}
More information about the Libreoffice-commits
mailing list