summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Toth <szabolcs450@gmail.com>2019-09-11 13:49:56 +0200
committerLászló Németh <nemeth@numbertext.org>2019-10-04 07:36:27 +0200
commit89c0b79911c469518c8872a4ec06b3d2c61c357c (patch)
tree287cb2f16d60e03c18f32ffece59804ab4d28924
parent1ab80992b8b9445e4cfad7f5b772bbef5a4b3c7b (diff)
tdf#123341 XLSX: fix vertical alignment in comments
Import and export of VML element TextVAlign weren't supported by Calc, losing vertical aligment of the comments assigned to the spreadsheet cells. Change-Id: Ice70d3c65021902991ae869b6c60e30e4cdef8c3 Reviewed-on: https://gerrit.libreoffice.org/78816 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rwxr-xr-xsc/qa/unit/data/ods/CommentTextVAlign.odsbin0 -> 7796 bytes
-rwxr-xr-xsc/qa/unit/subsequent_export-test.cxx18
-rwxr-xr-x[-rw-r--r--]sc/source/filter/oox/commentsbuffer.cxx7
-rwxr-xr-x[-rw-r--r--]sc/source/filter/xcl97/xcl97rec.cxx21
4 files changed, 46 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/CommentTextVAlign.ods b/sc/qa/unit/data/ods/CommentTextVAlign.ods
new file mode 100755
index 000000000000..a1cac792cbac
--- /dev/null
+++ b/sc/qa/unit/data/ods/CommentTextVAlign.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 30cb91116875..eaadde60f558 100755
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -222,6 +222,7 @@ public:
void testTdf79972XLSX();
void testTdf126024XLSX();
void testTdf126177XLSX();
+ void testCommentTextVAlignment();
void testXltxExport();
@@ -349,6 +350,7 @@ public:
CPPUNIT_TEST(testTdf79972XLSX);
CPPUNIT_TEST(testTdf126024XLSX);
CPPUNIT_TEST(testTdf126177XLSX);
+ CPPUNIT_TEST(testCommentTextVAlignment);
CPPUNIT_TEST(testXltxExport);
@@ -4486,6 +4488,22 @@ void ScExportTest::testTdf126177XLSX()
assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External");
}
+void ScExportTest::testCommentTextVAlignment()
+{
+ // Testing comment text alignments.
+ ScDocShellRef xShell = loadDoc("CommentTextVAlign.", 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:TextVAlign", "Center");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/oox/commentsbuffer.cxx b/sc/source/filter/oox/commentsbuffer.cxx
index aab70b07ae73..00045842c9fd 100644..100755
--- a/sc/source/filter/oox/commentsbuffer.cxx
+++ b/sc/source/filter/oox/commentsbuffer.cxx
@@ -64,10 +64,13 @@ static sal_Int32 lcl_ToVertAlign( sal_Int32 nAlign )
switch( nAlign )
{
case XML_top:
+ case XML_Top:
return SDRTEXTVERTADJUST_TOP;
case XML_center:
+ case XML_Center:
return SDRTEXTVERTADJUST_CENTER;
case XML_bottom:
+ case XML_Bottom:
return SDRTEXTVERTADJUST_BOTTOM;
default:
return SDRTEXTVERTADJUST_BLOCK;
@@ -164,6 +167,10 @@ void Comment::finalizeImport()
pNoteShape->convertFormatting( xAnnoShape );
// visibility
bVisible = pNoteShape->getTypeModel().mbVisible;
+
+ // Setting comment text alignment
+ const ::oox::vml::ClientData* xClientData = pNoteShape->getClientData();
+ aCommentPr.setProperty(PROP_TextVerticalAdjust, lcl_ToVertAlign(xClientData->mnTextVAlign));
}
xAnno->setIsVisible( bVisible );
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index e2b8593c88f0..f750fdb9ad6c 100644..100755
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -624,6 +624,22 @@ sal_Int32 VmlCommentExporter::StartShape()
return nId;
}
+static const char* lcl_GetVertAlignFromItemSetChar( const SfxItemSet& rItemSet )
+{
+ switch( rItemSet.Get( SDRATTR_TEXT_VERTADJUST ).GetValue() )
+ {
+ case SDRTEXTVERTADJUST_CENTER:
+ return "Center";
+ case SDRTEXTVERTADJUST_BOTTOM:
+ return "Bottom";
+ case SDRTEXTVERTADJUST_BLOCK:
+ return "Justify";
+ case SDRTEXTVERTADJUST_TOP:
+ default:
+ return "Top";
+ }
+}
+
void VmlCommentExporter::EndShape( sal_Int32 nShapeElement )
{
char pAnchor[100];
@@ -632,11 +648,15 @@ void VmlCommentExporter::EndShape( sal_Int32 nShapeElement )
maFrom.Left(), maFrom.Top(), maFrom.Right(), maFrom.Bottom(),
maTo.Left(), maTo.Top(), maTo.Right(), maTo.Bottom() );
+ // Getting comment text alignments
+ const char* pVertAlign = lcl_GetVertAlignFromItemSetChar(mpCaption->GetMergedItemSet());
+
pVmlDrawing->startElement(FSNS(XML_x, XML_ClientData), XML_ObjectType, "Note");
pVmlDrawing->singleElement(FSNS(XML_x, XML_MoveWithCells));
pVmlDrawing->singleElement(FSNS(XML_x, XML_SizeWithCells));
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_TextVAlign ), pVertAlign );
XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Row ), maScPos.Row() );
XclXmlUtils::WriteElement( pVmlDrawing, FSNS(XML_x, XML_Column), sal_Int32(maScPos.Col()));
if(mbVisible)
@@ -731,6 +751,7 @@ static sal_uInt8 lcl_GetVerAlignFromItemSet( const SfxItemSet& rItemSet )
case SDRTEXTVERTADJUST_CENTER: nVerAlign = EXC_OBJ_VER_CENTER; break;
case SDRTEXTVERTADJUST_BOTTOM: nVerAlign = EXC_OBJ_VER_BOTTOM; break;
case SDRTEXTVERTADJUST_BLOCK: nVerAlign = EXC_OBJ_VER_JUSTIFY; break;
+ default:;
}
return nVerAlign;
}