tdf#123339 XLSX: fix horizontal alignment in comments
Import and export of VML element TextHAlign weren't supported by Calc, losing horizontal aligment of the comments assigned to the spreadsheet cells. Change-Id: I41766d3004dd07ab34a2619e28532281366bf235 Reviewed-on: https://gerrit.libreoffice.org/79963 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
committed by
László Németh
parent
bef96f7a7b
commit
10c85f825f
BIN
sc/qa/unit/data/ods/CommentTextHAlign.ods
Normal file
BIN
sc/qa/unit/data/ods/CommentTextHAlign.ods
Normal file
Binary file not shown.
@@ -223,6 +223,7 @@ public:
|
|||||||
void testTdf126024XLSX();
|
void testTdf126024XLSX();
|
||||||
void testTdf126177XLSX();
|
void testTdf126177XLSX();
|
||||||
void testCommentTextVAlignment();
|
void testCommentTextVAlignment();
|
||||||
|
void testCommentTextHAlignment();
|
||||||
|
|
||||||
void testXltxExport();
|
void testXltxExport();
|
||||||
|
|
||||||
@@ -351,6 +352,7 @@ public:
|
|||||||
CPPUNIT_TEST(testTdf126024XLSX);
|
CPPUNIT_TEST(testTdf126024XLSX);
|
||||||
CPPUNIT_TEST(testTdf126177XLSX);
|
CPPUNIT_TEST(testTdf126177XLSX);
|
||||||
CPPUNIT_TEST(testCommentTextVAlignment);
|
CPPUNIT_TEST(testCommentTextVAlignment);
|
||||||
|
CPPUNIT_TEST(testCommentTextHAlignment);
|
||||||
|
|
||||||
CPPUNIT_TEST(testXltxExport);
|
CPPUNIT_TEST(testXltxExport);
|
||||||
|
|
||||||
@@ -4504,6 +4506,23 @@ void ScExportTest::testCommentTextVAlignment()
|
|||||||
assertXPathContent(pVmlDrawing, "/xml/v:shape/xx:ClientData/xx:TextVAlign", "Center");
|
assertXPathContent(pVmlDrawing, "/xml/v:shape/xx:ClientData/xx:TextVAlign", "Center");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScExportTest::testCommentTextHAlignment()
|
||||||
|
{
|
||||||
|
// Testing comment text alignments.
|
||||||
|
ScDocShellRef xShell = loadDoc("CommentTextHAlign.", FORMAT_ODS);
|
||||||
|
CPPUNIT_ASSERT(xShell.is());
|
||||||
|
|
||||||
|
std::shared_ptr<utl::TempFile> pXPathFile
|
||||||
|
= ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
|
||||||
|
|
||||||
|
const xmlDocPtr pVmlDrawing
|
||||||
|
= XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/vmlDrawing1.vml");
|
||||||
|
CPPUNIT_ASSERT(pVmlDrawing);
|
||||||
|
|
||||||
|
assertXPathContent(pVmlDrawing, "/xml/v:shape/xx:ClientData/xx:TextHAlign", "Center");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
|
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@@ -77,6 +77,21 @@ static sal_Int32 lcl_ToVertAlign( sal_Int32 nAlign )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static sal_Int16 lcl_ToParaAlign(sal_Int32 nAlign)
|
||||||
|
{
|
||||||
|
switch ( nAlign )
|
||||||
|
{
|
||||||
|
case XML_Left:
|
||||||
|
return sal_Int16(css::style::ParagraphAdjust_LEFT);
|
||||||
|
case XML_Right:
|
||||||
|
return sal_Int16(css::style::ParagraphAdjust_RIGHT);
|
||||||
|
case XML_Center:
|
||||||
|
return sal_Int16(css::style::ParagraphAdjust_CENTER);
|
||||||
|
default:
|
||||||
|
return sal_Int16(css::style::ParagraphAdjust_BLOCK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CommentModel::CommentModel()
|
CommentModel::CommentModel()
|
||||||
: mnAuthorId(-1)
|
: mnAuthorId(-1)
|
||||||
, mbAutoFill(false)
|
, mbAutoFill(false)
|
||||||
@@ -171,6 +186,7 @@ void Comment::finalizeImport()
|
|||||||
// Setting comment text alignment
|
// Setting comment text alignment
|
||||||
const ::oox::vml::ClientData* xClientData = pNoteShape->getClientData();
|
const ::oox::vml::ClientData* xClientData = pNoteShape->getClientData();
|
||||||
aCommentPr.setProperty(PROP_TextVerticalAdjust, lcl_ToVertAlign(xClientData->mnTextVAlign));
|
aCommentPr.setProperty(PROP_TextVerticalAdjust, lcl_ToVertAlign(xClientData->mnTextVAlign));
|
||||||
|
aCommentPr.setProperty(PROP_ParaAdjust, lcl_ToParaAlign(xClientData->mnTextHAlign));
|
||||||
}
|
}
|
||||||
xAnno->setIsVisible( bVisible );
|
xAnno->setIsVisible( bVisible );
|
||||||
|
|
||||||
|
@@ -624,6 +624,21 @@ sal_Int32 VmlCommentExporter::StartShape()
|
|||||||
return nId;
|
return nId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* lcl_GetHorizAlignFromItemSetChar(const SfxItemSet& rItemSet)
|
||||||
|
{
|
||||||
|
switch (rItemSet.Get(EE_PARA_JUST).GetAdjust())
|
||||||
|
{
|
||||||
|
case SvxAdjust::Center:
|
||||||
|
return "Center";
|
||||||
|
case SvxAdjust::Right:
|
||||||
|
return "Right";
|
||||||
|
case SvxAdjust::Block:
|
||||||
|
return "Justify";
|
||||||
|
default:
|
||||||
|
return "Left";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const char* lcl_GetVertAlignFromItemSetChar( const SfxItemSet& rItemSet )
|
static const char* lcl_GetVertAlignFromItemSetChar( const SfxItemSet& rItemSet )
|
||||||
{
|
{
|
||||||
switch( rItemSet.Get( SDRATTR_TEXT_VERTADJUST ).GetValue() )
|
switch( rItemSet.Get( SDRATTR_TEXT_VERTADJUST ).GetValue() )
|
||||||
@@ -650,6 +665,7 @@ void VmlCommentExporter::EndShape( sal_Int32 nShapeElement )
|
|||||||
|
|
||||||
// Getting comment text alignments
|
// Getting comment text alignments
|
||||||
const char* pVertAlign = lcl_GetVertAlignFromItemSetChar(mpCaption->GetMergedItemSet());
|
const char* pVertAlign = lcl_GetVertAlignFromItemSetChar(mpCaption->GetMergedItemSet());
|
||||||
|
const char* pHorizAlign = lcl_GetHorizAlignFromItemSetChar(mpCaption->GetMergedItemSet());
|
||||||
|
|
||||||
pVmlDrawing->startElement(FSNS(XML_x, XML_ClientData), XML_ObjectType, "Note");
|
pVmlDrawing->startElement(FSNS(XML_x, XML_ClientData), XML_ObjectType, "Note");
|
||||||
pVmlDrawing->singleElement(FSNS(XML_x, XML_MoveWithCells));
|
pVmlDrawing->singleElement(FSNS(XML_x, XML_MoveWithCells));
|
||||||
@@ -657,6 +673,7 @@ void VmlCommentExporter::EndShape( sal_Int32 nShapeElement )
|
|||||||
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Anchor ), pAnchor );
|
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Anchor ), pAnchor );
|
||||||
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_AutoFill ), "False" );
|
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_AutoFill ), "False" );
|
||||||
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_TextVAlign ), pVertAlign );
|
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_TextVAlign ), pVertAlign );
|
||||||
|
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_TextHAlign ), pHorizAlign );
|
||||||
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Row ), maScPos.Row() );
|
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Row ), maScPos.Row() );
|
||||||
XclXmlUtils::WriteElement( pVmlDrawing, FSNS(XML_x, XML_Column), sal_Int32(maScPos.Col()));
|
XclXmlUtils::WriteElement( pVmlDrawing, FSNS(XML_x, XML_Column), sal_Int32(maScPos.Col()));
|
||||||
if(mbVisible)
|
if(mbVisible)
|
||||||
|
Reference in New Issue
Block a user