[Libreoffice-commits] core.git: 3 commits - sc/qa sc/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Fri Mar 27 11:59:12 PDT 2015
sc/qa/unit/data/xlsx/strike-through.xlsx |binary
sc/qa/unit/subsequent_filters-test.cxx | 34 ++++++++++++++++++++++
sc/source/filter/inc/stylesbuffer.hxx | 2 -
sc/source/filter/oox/richstring.cxx | 2 -
sc/source/filter/oox/stylesbuffer.cxx | 47 +++++++++++++++----------------
5 files changed, 59 insertions(+), 26 deletions(-)
New commits:
commit 5b7d51af074aa1c4616a6f411892974cc28d2e00
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri Mar 27 19:56:04 2015 +0100
add test for tdf#89170
Change-Id: Ia3458ae91ea20aa3f5090f9b85a5030ddde81c3c
diff --git a/sc/qa/unit/data/xlsx/strike-through.xlsx b/sc/qa/unit/data/xlsx/strike-through.xlsx
new file mode 100644
index 0000000..ca56768
Binary files /dev/null and b/sc/qa/unit/data/xlsx/strike-through.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 16a0e08..07b224f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -27,6 +27,7 @@
#include <svx/svdoole2.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/postitem.hxx>
+#include <editeng/crossedoutitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/editobj.hxx>
#include <editeng/borderline.hxx>
@@ -188,6 +189,7 @@ public:
void testCopyMergedNumberFormats();
void testVBAUserFunctionXLSM();
void testEmbeddedImageXLS();
+ void testEditEngStrikeThroughXLSX();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -275,6 +277,7 @@ public:
CPPUNIT_TEST(testVBAUserFunctionXLSM);
CPPUNIT_TEST(testEmbeddedImageXLS);
CPPUNIT_TEST(testErrorOnExternalReferences);
+ CPPUNIT_TEST(testEditEngStrikeThroughXLSX);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2867,6 +2870,37 @@ void ScFiltersTest::testErrorOnExternalReferences()
xDocSh->DoClose();
}
+void ScFiltersTest::testEditEngStrikeThroughXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("strike-through.", XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.Is());
+
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ const EditTextObject* pObj = rDoc.GetEditText(ScAddress(0, 0, 0));
+ CPPUNIT_ASSERT(pObj);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pObj->GetParagraphCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("this is strike through this not"), pObj->GetText(0));
+
+ std::vector<EECharAttrib> aAttribs;
+ pObj->GetCharAttribs(0, aAttribs);
+ for (std::vector<EECharAttrib>::const_iterator itr = aAttribs.begin(); itr != aAttribs.end(); ++itr)
+ {
+ if (itr->pAttr->Which() == EE_CHAR_STRIKEOUT)
+ {
+ const SvxCrossedOutItem& rItem = static_cast<const SvxCrossedOutItem&>(*itr->pAttr);
+ if (itr->nStart == 0)
+ {
+ CPPUNIT_ASSERT(rItem.GetStrikeout() != STRIKEOUT_NONE);
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL(STRIKEOUT_NONE, rItem.GetStrikeout());
+ }
+ }
+ }
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{
commit 8dd2888ac75c2c2ee9ca0ed0c6abda4dab7420cc
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri Mar 27 19:11:35 2015 +0100
we need to use the edit engine attibute id for rich text, tdf#89170
Change-Id: I8489b0341709d44bc62e5ddef49fe232998f3c80
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 46e328d..ab0c16a 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -994,7 +994,7 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, bool bEditEngineText, bool bSkip
// strike out style
if( maUsedFlags.mbStrikeoutUsed )
{
- ScfTools::PutItem( rItemSet, SvxCrossedOutItem( maModel.mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, bEditEngineText ? EE_CHAR_STRIKEOUT : ATTR_FONT_CROSSEDOUT ), ATTR_FONT_CROSSEDOUT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, SvxCrossedOutItem( maModel.mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, bEditEngineText ? EE_CHAR_STRIKEOUT : ATTR_FONT_CROSSEDOUT ), bEditEngineText ? EE_CHAR_STRIKEOUT : ATTR_FONT_CROSSEDOUT, bSkipPoolDefs );
}
// outline style
commit d63c5326b1d03a7a40cd14833853b7bdf324cdd2
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri Mar 27 19:09:35 2015 +0100
a boolean variable is enough
Change-Id: I0594de8cc79626720f2f72062c39a6f2590dd64f
diff --git a/sc/source/filter/inc/stylesbuffer.hxx b/sc/source/filter/inc/stylesbuffer.hxx
index ed78e48..a7c47e2 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -258,7 +258,7 @@ public:
needs an rich text cell for this attribute. */
bool needsRichTextFormat() const;
- void fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool bSkipPoolDefs = false ) const;
+ void fillToItemSet( SfxItemSet& rItemSet, bool bEditEngineText, bool bSkipPoolDefs = false ) const;
/** Writes all font attributes to the passed property map. */
void writeToPropertyMap(
PropertyMap& rPropMap,
diff --git a/sc/source/filter/oox/richstring.cxx b/sc/source/filter/oox/richstring.cxx
index 1b2961c..6023a71 100644
--- a/sc/source/filter/oox/richstring.cxx
+++ b/sc/source/filter/oox/richstring.cxx
@@ -121,7 +121,7 @@ void RichStringPortion::convert( ScEditEngineDefaulter& rEE, ESelection& rSelect
const Font* pFontToUse = mxFont.get() ? mxFont.get() : lclNeedsRichTextFormat( pFont ) ? pFont : NULL;
if ( pFontToUse )
- pFontToUse->fillToItemSet( aItemSet, FONT_PROPTYPE_TEXT );
+ pFontToUse->fillToItemSet( aItemSet, true );
// #TODO need to manually adjust nEndPos ( and nEndPara ) to cater for any paragraphs
sal_Int32 nLastParaLoc = -1;
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 170387f..46e328d 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -907,9 +907,8 @@ bool Font::needsRichTextFormat() const
return eScFamily;
}
-void Font::fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool bSkipPoolDefs ) const
+void Font::fillToItemSet( SfxItemSet& rItemSet, bool bEditEngineText, bool bSkipPoolDefs ) const
{
- bool bEdit = ( ePropType == FONT_PROPTYPE_TEXT );
namespace cssawt = ::com::sun::star::awt;
if ( maUsedFlags.mbNameUsed )
{
@@ -917,32 +916,32 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool
{
rtl_TextEncoding eFontEnc = maApiData.maLatinFont.mnTextEnc;
// taken from binary importer
- rtl_TextEncoding eTempTextEnc = (bEdit && (eFontEnc == getTextEncoding())) ?
+ rtl_TextEncoding eTempTextEnc = (bEditEngineText && (eFontEnc == getTextEncoding())) ?
ScfTools::GetSystemTextEncoding() : eFontEnc;
SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maLatinFont.mnFamily ), maApiData.maLatinFont.maName, OUString(),
PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT );
- ScfTools::PutItem( rItemSet, aFontItem, bEdit ? EE_CHAR_FONTINFO : ATTR_FONT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? EE_CHAR_FONTINFO : ATTR_FONT, bSkipPoolDefs );
}
if( !maApiData.maAsianFont.maName.isEmpty() )
{
rtl_TextEncoding eFontEnc = maApiData.maAsianFont.mnTextEnc;
// taken from binary importer
- rtl_TextEncoding eTempTextEnc = (bEdit && (eFontEnc == getTextEncoding())) ?
+ rtl_TextEncoding eTempTextEnc = (bEditEngineText && (eFontEnc == getTextEncoding())) ?
ScfTools::GetSystemTextEncoding() : eFontEnc;
SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maAsianFont.mnFamily ), maApiData.maAsianFont.maName, OUString(),
PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT );
- ScfTools::PutItem( rItemSet, aFontItem, bEdit ? EE_CHAR_FONTINFO_CJK : ATTR_CJK_FONT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? EE_CHAR_FONTINFO_CJK : ATTR_CJK_FONT, bSkipPoolDefs );
}
if( !maApiData.maCmplxFont.maName.isEmpty() )
{
rtl_TextEncoding eFontEnc = maApiData.maCmplxFont.mnTextEnc;
// taken from binary importer
- rtl_TextEncoding eTempTextEnc = (bEdit && (eFontEnc == getTextEncoding())) ?
+ rtl_TextEncoding eTempTextEnc = (bEditEngineText && (eFontEnc == getTextEncoding())) ?
ScfTools::GetSystemTextEncoding() : eFontEnc;
SvxFontItem aFontItem( lcl_getFontFamily( maApiData.maCmplxFont.mnFamily ), maApiData.maCmplxFont.maName, OUString(),
PITCH_DONTKNOW, eTempTextEnc, ATTR_FONT );
- ScfTools::PutItem( rItemSet, aFontItem, bEdit ? EE_CHAR_FONTINFO_CTL : ATTR_CTL_FONT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aFontItem, bEditEngineText ? EE_CHAR_FONTINFO_CTL : ATTR_CTL_FONT, bSkipPoolDefs );
}
}
// font height
@@ -950,34 +949,34 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool
{
sal_Int32 nHeight = maApiData.maDesc.Height;
// do we use EXC_FONTITEM_HF ( or is it just relevant for the binary filter )
- if( bEdit/* && (eType != EXC_FONTITEM_HF) */) // do not convert header/footer height
+ if( bEditEngineText/* && (eType != EXC_FONTITEM_HF) */) // do not convert header/footer height
nHeight = (nHeight * 127 + 36) / EXC_POINTS_PER_INCH; // 1 in == 72 pt
SvxFontHeightItem aHeightItem( nHeight, 100, ATTR_FONT_HEIGHT );
- ScfTools::PutItem( rItemSet, aHeightItem, bEdit ? EE_CHAR_FONTHEIGHT : ATTR_FONT_HEIGHT, bSkipPoolDefs );
- ScfTools::PutItem( rItemSet, aHeightItem, bEdit ? EE_CHAR_FONTHEIGHT_CJK : ATTR_CJK_FONT_HEIGHT, bSkipPoolDefs );
- ScfTools::PutItem( rItemSet, aHeightItem, bEdit ? EE_CHAR_FONTHEIGHT_CTL : ATTR_CTL_FONT_HEIGHT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? EE_CHAR_FONTHEIGHT : ATTR_FONT_HEIGHT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? EE_CHAR_FONTHEIGHT_CJK : ATTR_CJK_FONT_HEIGHT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aHeightItem, bEditEngineText ? EE_CHAR_FONTHEIGHT_CTL : ATTR_CTL_FONT_HEIGHT, bSkipPoolDefs );
}
// font weight
if( maUsedFlags.mbWeightUsed )
{
::FontWeight fWeight = VCLUnoHelper::ConvertFontWeight( maApiData.maDesc.Weight );
SvxWeightItem aWeightItem( fWeight, ATTR_FONT_WEIGHT );
- ScfTools::PutItem( rItemSet, aWeightItem, bEdit ? EE_CHAR_WEIGHT : ATTR_FONT_WEIGHT, bSkipPoolDefs );
- ScfTools::PutItem( rItemSet, aWeightItem, bEdit ? EE_CHAR_WEIGHT_CTL : ATTR_CTL_FONT_WEIGHT, bSkipPoolDefs );
- ScfTools::PutItem( rItemSet, aWeightItem, bEdit ? EE_CHAR_WEIGHT_CJK : ATTR_CJK_FONT_WEIGHT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? EE_CHAR_WEIGHT : ATTR_FONT_WEIGHT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? EE_CHAR_WEIGHT_CTL : ATTR_CTL_FONT_WEIGHT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aWeightItem, bEditEngineText ? EE_CHAR_WEIGHT_CJK : ATTR_CJK_FONT_WEIGHT, bSkipPoolDefs );
}
// font posture
if( maUsedFlags.mbPostureUsed )
{
SvxPostureItem aPostItem( ( maApiData.maDesc.Slant == cssawt::FontSlant_ITALIC ) ? ITALIC_NORMAL : ITALIC_NONE, ATTR_FONT_POSTURE);
- ScfTools::PutItem( rItemSet, aPostItem, bEdit ? EE_CHAR_ITALIC : ATTR_FONT_POSTURE, bSkipPoolDefs );
- ScfTools::PutItem( rItemSet, aPostItem, bEdit ? EE_CHAR_ITALIC_CJK : ATTR_CJK_FONT_POSTURE, bSkipPoolDefs );
- ScfTools::PutItem( rItemSet, aPostItem, bEdit ? EE_CHAR_ITALIC_CTL : ATTR_CTL_FONT_POSTURE, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? EE_CHAR_ITALIC : ATTR_FONT_POSTURE, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? EE_CHAR_ITALIC_CJK : ATTR_CJK_FONT_POSTURE, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aPostItem, bEditEngineText ? EE_CHAR_ITALIC_CTL : ATTR_CTL_FONT_POSTURE, bSkipPoolDefs );
}
// character color
if( maUsedFlags.mbColorUsed )
{
- ScfTools::PutItem( rItemSet,SvxColorItem( maApiData.mnColor, bEdit ? EE_CHAR_COLOR : ATTR_FONT_COLOR ) , bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet,SvxColorItem( maApiData.mnColor, bEditEngineText ? EE_CHAR_COLOR : ATTR_FONT_COLOR ) , bSkipPoolDefs );
}
// underline style
if( maUsedFlags.mbUnderlineUsed )
@@ -990,24 +989,24 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool
else
eScUnderl = UNDERLINE_NONE;
SvxUnderlineItem aUnderlItem( eScUnderl, ATTR_FONT_UNDERLINE );
- ScfTools::PutItem( rItemSet, aUnderlItem, bEdit ? EE_CHAR_UNDERLINE : ATTR_FONT_UNDERLINE, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, aUnderlItem, bEditEngineText ? EE_CHAR_UNDERLINE : ATTR_FONT_UNDERLINE, bSkipPoolDefs );
}
// strike out style
if( maUsedFlags.mbStrikeoutUsed )
{
- ScfTools::PutItem( rItemSet, SvxCrossedOutItem( maModel.mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, bEdit ? EE_CHAR_STRIKEOUT : ATTR_FONT_CROSSEDOUT ), ATTR_FONT_CROSSEDOUT, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, SvxCrossedOutItem( maModel.mbStrikeout ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, bEditEngineText ? EE_CHAR_STRIKEOUT : ATTR_FONT_CROSSEDOUT ), ATTR_FONT_CROSSEDOUT, bSkipPoolDefs );
}
// outline style
if( maUsedFlags.mbOutlineUsed )
{
- ScfTools::PutItem( rItemSet, SvxContourItem( maApiData.mbOutline, ATTR_FONT_CONTOUR ), bEdit ? EE_CHAR_OUTLINE : ATTR_FONT_CONTOUR, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, SvxContourItem( maApiData.mbOutline, ATTR_FONT_CONTOUR ), bEditEngineText ? EE_CHAR_OUTLINE : ATTR_FONT_CONTOUR, bSkipPoolDefs );
}
// shadow style
if( maUsedFlags.mbShadowUsed )
{
- ScfTools::PutItem( rItemSet, SvxShadowedItem( maApiData.mbShadow, ATTR_FONT_SHADOWED ), bEdit ? EE_CHAR_SHADOW : ATTR_FONT_SHADOWED, bSkipPoolDefs );
+ ScfTools::PutItem( rItemSet, SvxShadowedItem( maApiData.mbShadow, ATTR_FONT_SHADOWED ), bEditEngineText ? EE_CHAR_SHADOW : ATTR_FONT_SHADOWED, bSkipPoolDefs );
}
if( maUsedFlags.mbEscapementUsed )
{
@@ -1016,7 +1015,7 @@ void Font::fillToItemSet( SfxItemSet& rItemSet, FontPropertyType ePropType, bool
eScEscapem = SVX_ESCAPEMENT_SUPERSCRIPT;
else if ( maApiData.mnEscapement == API_ESCAPE_SUBSCRIPT )
eScEscapem = SVX_ESCAPEMENT_SUBSCRIPT;
- if( ePropType == FONT_PROPTYPE_TEXT && bEdit )
+ if( bEditEngineText )
{
// #TODO handle EscapementHeight
rItemSet.Put( SvxEscapementItem( eScEscapem, EE_CHAR_ESCAPEMENT ) );
More information about the Libreoffice-commits
mailing list