sc: copy put font height in RTF export
When copying a range of cell the font height was not exported in the RTF format string copied to the clipboard. Change-Id: Ib26df4775df506584da43538653fd209329def47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203068 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204056 Tested-by: Jenkins
This commit is contained in:
committed by
Xisco Fauli
parent
a70e3dbfc6
commit
ad5dddb689
@@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_copypaste, \
|
||||
comphelper \
|
||||
cppu \
|
||||
cppuhelper \
|
||||
editeng \
|
||||
i18nlangtag \
|
||||
sal \
|
||||
sc \
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <attrib.hxx>
|
||||
#include <userlist.hxx>
|
||||
#include <undomanager.hxx>
|
||||
#include <editeng/fhgtitem.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::com::sun::star::uno;
|
||||
@@ -46,6 +47,7 @@ public:
|
||||
void tdf137625_autofillMergedUserlist();
|
||||
void tdf137624_autofillMergedMixed();
|
||||
void tdf122716_rtf_portion_encoding();
|
||||
void testRTFFontHeight();
|
||||
|
||||
CPPUNIT_TEST_SUITE(ScCopyPasteTest);
|
||||
CPPUNIT_TEST(testCopyPasteXLS);
|
||||
@@ -64,6 +66,7 @@ public:
|
||||
CPPUNIT_TEST(tdf137625_autofillMergedUserlist);
|
||||
CPPUNIT_TEST(tdf137624_autofillMergedMixed);
|
||||
CPPUNIT_TEST(tdf122716_rtf_portion_encoding);
|
||||
CPPUNIT_TEST(testRTFFontHeight);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
@@ -802,6 +805,33 @@ void ScCopyPasteTest::tdf122716_rtf_portion_encoding()
|
||||
CPPUNIT_ASSERT(rtf_string.indexOf("\\u352\\'3famp\\u363\\'3fnas") >= 0);
|
||||
}
|
||||
|
||||
void ScCopyPasteTest::testRTFFontHeight()
|
||||
{
|
||||
createScDoc();
|
||||
ScDocument* pDoc = getScDoc();
|
||||
ScTabViewShell* pViewShell = getViewShell();
|
||||
pDoc->SetString(ScAddress(0, 0, 0), u"Text"_ustr);
|
||||
sal_uInt32 nHeightPt = 8;
|
||||
pDoc->ApplyAttr(0, 0, 0, SvxFontHeightItem(nHeightPt * 20, 100, ATTR_FONT_HEIGHT));
|
||||
|
||||
// Select a range containing A1:
|
||||
ScRange aRange(0, 0, 0, 1, 0, 0);
|
||||
pViewShell->GetViewData().GetMarkData().SetMarkArea(aRange);
|
||||
|
||||
// Obtain a transferable, similar to what happens on copy to clipboard:
|
||||
ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
|
||||
auto xTransferable = pModelObj->getSelection();
|
||||
// Get the RTF data:
|
||||
auto aRTF
|
||||
= xTransferable->getTransferData({ u"text/rtf"_ustr, {}, cppu::UnoType<OUString>::get() });
|
||||
OUString sRTF;
|
||||
CPPUNIT_ASSERT(aRTF >>= sRTF);
|
||||
|
||||
// Check that the font height was exported (in Half-point units)
|
||||
OUString sText = "\\fs" + OUString::number(nHeightPt * 2);
|
||||
CPPUNIT_ASSERT(sRTF.indexOf(sText) >= 0);
|
||||
}
|
||||
|
||||
ScCopyPasteTest::ScCopyPasteTest()
|
||||
: ScModelTestBase(u"/sc/qa/unit/data/"_ustr)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <editeng/wghtitem.hxx>
|
||||
#include <editeng/postitem.hxx>
|
||||
#include <editeng/udlnitem.hxx>
|
||||
#include <editeng/fhgtitem.hxx>
|
||||
#include <editeng/fontitem.hxx>
|
||||
#include <editeng/justifyitem.hxx>
|
||||
#include <svtools/rtfout.hxx>
|
||||
@@ -260,6 +261,7 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol )
|
||||
bool bResetAttr(false);
|
||||
|
||||
const SvxFontItem& rFontItem = pAttr->GetItem( ATTR_FONT );
|
||||
const SvxFontHeightItem& rFontHeightItem = pAttr->GetItem(ATTR_FONT_HEIGHT);
|
||||
const SvxHorJustifyItem& rHorJustifyItem = pAttr->GetItem( ATTR_HOR_JUSTIFY );
|
||||
const SvxWeightItem& rWeightItem = pAttr->GetItem( ATTR_FONT_WEIGHT );
|
||||
const SvxPostureItem& rPostureItem = pAttr->GetItem( ATTR_FONT_POSTURE );
|
||||
@@ -268,6 +270,12 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol )
|
||||
m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_F )
|
||||
.WriteOString( OString::number(AddFont(rFontItem)) );
|
||||
|
||||
m_aDocStrm.WriteOString(OOO_STRING_SVTOOLS_RTF_FS);
|
||||
sal_Int32 nHeight = rFontHeightItem.GetHeight();
|
||||
// Twips => HalfPoints
|
||||
nHeight /= 10;
|
||||
m_aDocStrm.WriteNumberAsString(nHeight);
|
||||
|
||||
const char* pChar;
|
||||
|
||||
switch( rHorJustifyItem.GetValue() )
|
||||
|
||||
Reference in New Issue
Block a user