tdf#79298 - FORMATTING: Copy/paste: import strikethrough attribute
Change-Id: I0539e87f2a87f869e234ed7c944b9da6bd0e82bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177847 Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de> Tested-by: Jenkins
This commit is contained in:
parent
c4dee829f3
commit
813f34d672
7 changed files with 63 additions and 1 deletions
3
sc/qa/filter/html/data/tdf79298_strikeout_variants.html
Normal file
3
sc/qa/filter/html/data/tdf79298_strikeout_variants.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<p><s>s</s></p>
|
||||
<p><strike>strike</strike></p>
|
||||
<p><del>del</del></p>
|
|
@ -13,6 +13,8 @@
|
|||
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
|
||||
#include <com/sun/star/table/XCellRange.hpp>
|
||||
|
||||
#include <editeng/crossedoutitem.hxx>
|
||||
|
||||
#include <comphelper/propertyvalue.hxx>
|
||||
#include <svl/numformat.hxx>
|
||||
#include <svl/zformat.hxx>
|
||||
|
@ -205,6 +207,30 @@ CPPUNIT_TEST_FIXTURE(Test, testPasteSingleCell)
|
|||
CPPUNIT_ASSERT_EQUAL(static_cast<double>(3), pDoc->GetValue(/*col=*/2, /*row=*/0, /*tab=*/0));
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testTdf79298_strikeout_variants)
|
||||
{
|
||||
createScDoc();
|
||||
|
||||
// Paste different strikeout variants into the first cell
|
||||
ScDocument* pDoc = getScDoc();
|
||||
ScAddress aCellPos(/*nColP=*/0, /*nRowP=*/0, /*nTabP=*/0);
|
||||
ScImportExport aImporter(*pDoc, aCellPos);
|
||||
SvFileStream aFile(createFileURL(u"tdf79298_strikeout_variants.html"), StreamMode::READ);
|
||||
SvMemoryStream aMemory;
|
||||
aMemory.WriteStream(aFile);
|
||||
aMemory.Seek(0);
|
||||
CPPUNIT_ASSERT(aImporter.ImportStream(aMemory, OUString(), SotClipboardFormatId::HTML));
|
||||
|
||||
// Verify HTML strikeout tags (<del>, <s>, and <strike>)
|
||||
for (size_t nCol = 0; nCol < 3; ++nCol)
|
||||
{
|
||||
const ScPatternAttr* pAttr = pDoc->GetPattern(ScAddress(0, nCol, 0));
|
||||
CPPUNIT_ASSERT_MESSAGE("Failed to get cell attribute.", pAttr);
|
||||
const SvxCrossedOutItem& rCrossedOutItem = pAttr->GetItem(ATTR_FONT_CROSSEDOUT);
|
||||
CPPUNIT_ASSERT_EQUAL(FontStrikeout::STRIKEOUT_SINGLE, rCrossedOutItem.GetStrikeout());
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testCopyText)
|
||||
{
|
||||
// Given a document with 01 in A1:
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <scitems.hxx>
|
||||
|
||||
#include <editeng/colritem.hxx>
|
||||
#include <editeng/crossedoutitem.hxx>
|
||||
#include <editeng/brushitem.hxx>
|
||||
#include <editeng/editeng.hxx>
|
||||
#include <editeng/fhgtitem.hxx>
|
||||
|
@ -1794,6 +1795,14 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* pInfo )
|
|||
}
|
||||
}
|
||||
break;
|
||||
case HtmlTokenId::STRIKE_ON:
|
||||
case HtmlTokenId::STRIKETHROUGH_ON:
|
||||
case HtmlTokenId::DELETEDTEXT_ON:
|
||||
{
|
||||
if (IsAtBeginningOfText(pInfo))
|
||||
mxActEntry->aItemSet.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, ATTR_FONT_CROSSEDOUT));
|
||||
}
|
||||
break;
|
||||
case HtmlTokenId::UNDERLINE_ON :
|
||||
{
|
||||
if ( IsAtBeginningOfText( pInfo ) )
|
||||
|
|
|
@ -246,6 +246,8 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
|
|||
pAttrItemSet->Put( *pItem );
|
||||
if ( rESet.GetItemState( ATTR_FONT_UNDERLINE, false, &pItem) == SfxItemState::SET )
|
||||
pAttrItemSet->Put( *pItem );
|
||||
if ( rESet.GetItemState( ATTR_FONT_CROSSEDOUT, false, &pItem) == SfxItemState::SET )
|
||||
pAttrItemSet->Put( *pItem );
|
||||
// HTML LATIN/CJK/CTL script type dependent
|
||||
const SfxPoolItem* pFont;
|
||||
if ( rESet.GetItemState( ATTR_FONT, false, &pFont) != SfxItemState::SET )
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<p><s>s</s></p>
|
||||
<p><strike>strike</strike></p>
|
||||
<p><del>del</del></p>
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <com/sun/star/awt/FontSlant.hpp>
|
||||
#include <com/sun/star/awt/FontUnderline.hpp>
|
||||
#include <com/sun/star/awt/FontStrikeout.hpp>
|
||||
#include <com/sun/star/awt/FontWeight.hpp>
|
||||
#include <com/sun/star/graphic/XGraphic.hpp>
|
||||
#include <com/sun/star/graphic/GraphicType.hpp>
|
||||
|
@ -376,6 +377,24 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testImageSize)
|
|||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(aExpected.getHeight()), aSize.Height);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf79298StrikeoutVariants)
|
||||
{
|
||||
createSwWebDoc("tdf79298-strikeout-variants.html");
|
||||
|
||||
// Without the accompanying fix in place, this tests would have failed with:
|
||||
// - Expected: 1 (FontStrikeout::SINGLE)
|
||||
// - Actual : 0 (FontStrikeout::NONE)
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Strikeout for <del> missing", sal_Int16(awt::FontStrikeout::SINGLE),
|
||||
getProperty<sal_Int16>(getRun(getParagraph(1), 1), u"CharStrikeout"_ustr));
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Strikeout for <s> missing", sal_Int16(awt::FontStrikeout::SINGLE),
|
||||
getProperty<sal_Int16>(getRun(getParagraph(2), 1), u"CharStrikeout"_ustr));
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(
|
||||
"Strikeout for <strike> missing", sal_Int16(awt::FontStrikeout::SINGLE),
|
||||
getProperty<sal_Int16>(getRun(getParagraph(3), 1), u"CharStrikeout"_ustr));
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf142781)
|
||||
{
|
||||
// FIXME: the DPI check should be removed when either (1) the test is fixed to work with
|
||||
|
|
|
@ -1889,6 +1889,7 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
|
|||
|
||||
case HtmlTokenId::STRIKE_ON:
|
||||
case HtmlTokenId::STRIKETHROUGH_ON:
|
||||
case HtmlTokenId::DELETEDTEXT_ON:
|
||||
{
|
||||
NewStdAttr( HtmlTokenId::STRIKE_ON, &m_xAttrTab->pStrike,
|
||||
SvxCrossedOutItem(STRIKEOUT_SINGLE, RES_CHRATR_CROSSEDOUT) );
|
||||
|
@ -1974,7 +1975,6 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
|
|||
case HtmlTokenId::ACRONYM_ON:
|
||||
case HtmlTokenId::ABBREVIATION_ON:
|
||||
case HtmlTokenId::INSERTEDTEXT_ON:
|
||||
case HtmlTokenId::DELETEDTEXT_ON:
|
||||
|
||||
case HtmlTokenId::TELETYPE_ON:
|
||||
NewCharFormat( nToken );
|
||||
|
|
Loading…
Reference in a new issue