Kaydet (Commit) 3cbb6e73 authored tarafından Szymon Kłos's avatar Szymon Kłos

SmartArt: export text rotation in the PPTX

Change-Id: I74bfc172fe7434d14de468ecfd3412636e53780c
Reviewed-on: https://gerrit.libreoffice.org/43202Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSzymon Kłos <szymon.klos@collabora.com>
üst 2ea531c0
......@@ -151,6 +151,21 @@ struct IndexRange {
/** retrieve the content of CT_IndexRange */
IndexRange GetIndexRange( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttributes );
/**
* nRotation is a 100th of a degree and the return value is
* in a 60,000th of a degree
*
* Also rotation is in opposite directions so multiply with -1
*/
inline OString calcRotationValue(sal_Int32 nRotation)
{
if (nRotation > 18000) // 180 degree
{
nRotation -= 36000;
}
nRotation *= -600;
return OString::number(nRotation);
}
const sal_Int32 EMU_PER_HMM = 360; /// 360 EMUs per 1/100 mm.
const sal_Int32 EMU_PER_PT = 12700;
......
......@@ -893,26 +893,6 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x
pFS->endElement( FSNS( XML_c, XML_legend ) );
}
namespace {
/**
* nRotation is a 100th of a degree and the return value is
* in a 60,000th of a degree
*
* Also rotation is in opposite directions so multiply with -1
*/
OString calcRotationValue(sal_Int32 nRotation)
{
if (nRotation > 18000) // 180 degree
{
nRotation -= 36000;
}
nRotation *= -600;
return OString::number(nRotation);
}
}
void ChartExport::exportTitle( const Reference< XShape >& xShape )
{
OUString sText;
......@@ -945,7 +925,7 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape )
pFS->singleElement( FSNS( XML_a, XML_bodyPr ),
XML_vert, sWritingMode,
XML_rot, calcRotationValue(nRotation).getStr(),
XML_rot, oox::drawingml::calcRotationValue(nRotation).getStr(),
FSEND );
// TODO: lstStyle
pFS->singleElement( FSNS( XML_a, XML_lstStyle ),
......
......@@ -2224,6 +2224,8 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
if( !xXText.is() )
return;
sal_Int32 nTextRotateAngle = 0;
#define DEFLRINS 254
#define DEFTBINS 127
sal_Int32 nLeft, nRight, nTop, nBottom;
......@@ -2263,7 +2265,6 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
{
for ( sal_Int32 i = 0, nElems = aProps.getLength(); i < nElems; ++i )
{
sal_Int32 nTextRotateAngle = 0;
if ( aProps[ i ].Name == "TextPreRotateAngle" && ( aProps[ i ].Value >>= nTextRotateAngle ) )
{
if ( nTextRotateAngle == -90 )
......@@ -2320,6 +2321,7 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
XML_anchor, sVerticalAlignment,
XML_anchorCtr, bHorizontalCenter ? "1" : nullptr,
XML_vert, sWritingMode,
XML_rot, (nTextRotateAngle != 0) ? oox::drawingml::calcRotationValue( nTextRotateAngle * 100 ).getStr() : nullptr,
FSEND );
if( !presetWarp.isEmpty())
{
......
......@@ -119,6 +119,7 @@ public:
void testTdf112647();
void testGroupRotation();
void testTdf104788();
void testSmartartRotation2();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
......@@ -163,6 +164,7 @@ public:
CPPUNIT_TEST(testTdf112647);
CPPUNIT_TEST(testGroupRotation);
CPPUNIT_TEST(testTdf104788);
CPPUNIT_TEST(testSmartartRotation2);
CPPUNIT_TEST_SUITE_END();
......@@ -1238,6 +1240,17 @@ void SdOOXMLExportTest2::testTdf104788()
xDocShRef->DoClose();
}
void SdOOXMLExportTest2::testSmartartRotation2()
{
::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rotation2.pptx"), PPTX);
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
xDocShRef->DoClose();
xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:bodyPr", "rot", "10800000");
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment