drawingML export/import: text frames with vertical alignment
Change-Id: I469da0a8234dd2979facfed3d66907aad1a138ab
This commit is contained in:
@@ -126,6 +126,12 @@ sal_Int16 GetCaseMap( sal_Int32 nToken );
|
|||||||
/** converts a paragraph align to a ParaAdjust */
|
/** converts a paragraph align to a ParaAdjust */
|
||||||
sal_Int16 GetParaAdjust( sal_Int32 nAlign );
|
sal_Int16 GetParaAdjust( sal_Int32 nAlign );
|
||||||
|
|
||||||
|
// Convert vertical adjust tokens to a TextVerticalAdjust item
|
||||||
|
::com::sun::star::drawing::TextVerticalAdjust GetTextVerticalAdjust( sal_Int32 nToken );
|
||||||
|
|
||||||
|
// Convert a TextVerticalAdjust item to string value appearing in ooxml
|
||||||
|
SAL_DLLPUBLIC const char* GetTextVerticalAdjust( ::com::sun::star::drawing::TextVerticalAdjust eAdjust );
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// CT_IndexRange
|
// CT_IndexRange
|
||||||
|
@@ -187,6 +187,45 @@ sal_Int16 GetParaAdjust( sal_Int32 nAlign )
|
|||||||
return nEnum;
|
return nEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextVerticalAdjust GetTextVerticalAdjust( sal_Int32 nToken )
|
||||||
|
{
|
||||||
|
TextVerticalAdjust aVertAdjust;
|
||||||
|
switch( nToken )
|
||||||
|
{
|
||||||
|
case XML_b:
|
||||||
|
aVertAdjust = TextVerticalAdjust_BOTTOM;
|
||||||
|
break;
|
||||||
|
case XML_dist:
|
||||||
|
case XML_just:
|
||||||
|
case XML_ctr:
|
||||||
|
aVertAdjust = TextVerticalAdjust_CENTER;
|
||||||
|
break;
|
||||||
|
case XML_t:
|
||||||
|
default:
|
||||||
|
aVertAdjust = TextVerticalAdjust_TOP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return aVertAdjust;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* GetTextVerticalAdjust( TextVerticalAdjust eAdjust )
|
||||||
|
{
|
||||||
|
const char* sVerticalAdjust = 0;
|
||||||
|
switch( eAdjust )
|
||||||
|
{
|
||||||
|
case TextVerticalAdjust_BOTTOM:
|
||||||
|
sVerticalAdjust = "b";
|
||||||
|
break;
|
||||||
|
case TextVerticalAdjust_CENTER:
|
||||||
|
sVerticalAdjust = "ctr";
|
||||||
|
break;
|
||||||
|
case TextVerticalAdjust_TOP:
|
||||||
|
default:
|
||||||
|
sVerticalAdjust = "t";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return sVerticalAdjust;
|
||||||
|
}
|
||||||
|
|
||||||
TabAlign GetTabAlign( sal_Int32 aToken )
|
TabAlign GetTabAlign( sal_Int32 aToken )
|
||||||
{
|
{
|
||||||
|
@@ -96,16 +96,9 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper& rPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ST_TextAnchoringType
|
// ST_TextAnchoringType
|
||||||
if( rAttribs.hasAttribute( XML_anchor ) ) {
|
if( rAttribs.hasAttribute( XML_anchor ) )
|
||||||
switch( rAttribs.getToken( XML_anchor, XML_t ) )
|
{
|
||||||
{
|
mrTextBodyProp.meVA = GetTextVerticalAdjust( rAttribs.getToken( XML_anchor, XML_t ) );
|
||||||
case XML_b : mrTextBodyProp.meVA = drawing::TextVerticalAdjust_BOTTOM; break;
|
|
||||||
case XML_dist :
|
|
||||||
case XML_just :
|
|
||||||
case XML_ctr : mrTextBodyProp.meVA = drawing::TextVerticalAdjust_CENTER; break;
|
|
||||||
default:
|
|
||||||
case XML_t : mrTextBodyProp.meVA = drawing::TextVerticalAdjust_TOP; break;
|
|
||||||
}
|
|
||||||
mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= mrTextBodyProp.meVA;
|
mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= mrTextBodyProp.meVA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1541,17 +1541,8 @@ void DrawingML::WriteText( Reference< XInterface > rXIface, bool bBodyPr, bool b
|
|||||||
TextVerticalAdjust eVerticalAlignment( TextVerticalAdjust_TOP );
|
TextVerticalAdjust eVerticalAlignment( TextVerticalAdjust_TOP );
|
||||||
const char* sVerticalAlignment = NULL;
|
const char* sVerticalAlignment = NULL;
|
||||||
GET( eVerticalAlignment, TextVerticalAdjust );
|
GET( eVerticalAlignment, TextVerticalAdjust );
|
||||||
switch( eVerticalAlignment ) {
|
if( eVerticalAlignment != TextVerticalAdjust_TOP )
|
||||||
case TextVerticalAdjust_BOTTOM:
|
sVerticalAlignment = GetTextVerticalAdjust(eVerticalAlignment);
|
||||||
sVerticalAlignment = "b";
|
|
||||||
break;
|
|
||||||
case TextVerticalAdjust_CENTER:
|
|
||||||
sVerticalAlignment = "ctr";
|
|
||||||
break;
|
|
||||||
case TextVerticalAdjust_TOP:
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* sWritingMode = NULL;
|
const char* sWritingMode = NULL;
|
||||||
sal_Bool bVertical = sal_False;
|
sal_Bool bVertical = sal_False;
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include <oox/drawingml/shapepropertiescontext.hxx>
|
#include <oox/drawingml/shapepropertiescontext.hxx>
|
||||||
#include <oox/drawingml/shapestylecontext.hxx>
|
#include <oox/drawingml/shapestylecontext.hxx>
|
||||||
#include <com/sun/star/beans/XPropertyState.hpp>
|
#include <com/sun/star/beans/XPropertyState.hpp>
|
||||||
|
#include <oox/drawingml/drawingmltypes.hxx>
|
||||||
|
|
||||||
using namespace com::sun::star;
|
using namespace com::sun::star;
|
||||||
|
|
||||||
@@ -86,6 +87,13 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
|
|||||||
for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i)
|
for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i)
|
||||||
if (oInsets[i])
|
if (oInsets[i])
|
||||||
xPropertySet->setPropertyValue(aProps[i], uno::makeAny(*oInsets[i]));
|
xPropertySet->setPropertyValue(aProps[i], uno::makeAny(*oInsets[i]));
|
||||||
|
|
||||||
|
// Handle text vertical adjustment inside a text frame
|
||||||
|
if( rAttribs.hasAttribute( XML_anchor ) )
|
||||||
|
{
|
||||||
|
drawing::TextVerticalAdjust eAdjust = drawingml::GetTextVerticalAdjust( rAttribs.getToken( XML_anchor, XML_t ) );
|
||||||
|
xPropertySet->setPropertyValue("TextVerticalAdjust", uno::makeAny(eAdjust));
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
BIN
sw/qa/extras/ooxmlexport/data/dml-textframe-vertadjust.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/dml-textframe-vertadjust.docx
Normal file
Binary file not shown.
@@ -49,6 +49,7 @@
|
|||||||
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
|
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
|
||||||
#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
|
#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
|
||||||
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
|
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
|
||||||
|
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
|
||||||
|
|
||||||
#include <libxml/xpathInternals.h>
|
#include <libxml/xpathInternals.h>
|
||||||
#include <libxml/parserInternals.h>
|
#include <libxml/parserInternals.h>
|
||||||
@@ -2868,6 +2869,21 @@ DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx")
|
|||||||
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").match("6138"));
|
CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").match("6138"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECLARE_OOXMLEXPORT_TEST(testDMLTextFrameVertAdjust, "dml-textframe-vertadjust.docx")
|
||||||
|
{
|
||||||
|
// DOCX textboxes with text are imported as text frames but in Writer text frames did not have
|
||||||
|
// TextVerticalAdjust attribute so far.
|
||||||
|
|
||||||
|
// 1st frame's context is adjusted to the top
|
||||||
|
uno::Reference<beans::XPropertySet> xFrame(getTextFrameByName("Rectangle 1"), uno::UNO_QUERY);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
|
||||||
|
// 2nd frame's context is adjusted to the center
|
||||||
|
xFrame.set(getTextFrameByName("Rectangle 2"), uno::UNO_QUERY);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_CENTER, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
|
||||||
|
// 3rd frame's context is adjusted to the bottom
|
||||||
|
xFrame.set(getTextFrameByName("Rectangle 3"), uno::UNO_QUERY);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@@ -881,6 +881,12 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId)
|
|||||||
FSEND);
|
FSEND);
|
||||||
m_pImpl->m_bDMLTextFrameSyntax = true;
|
m_pImpl->m_bDMLTextFrameSyntax = true;
|
||||||
m_pImpl->m_pBodyPrAttrList = pFS->createAttrList();
|
m_pImpl->m_pBodyPrAttrList = pFS->createAttrList();
|
||||||
|
{
|
||||||
|
drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
|
||||||
|
if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("TextVerticalAdjust") )
|
||||||
|
xPropertySet->getPropertyValue("TextVerticalAdjust") >>= eAdjust;
|
||||||
|
m_pImpl->m_pBodyPrAttrList->add(XML_anchor, oox::drawingml::GetTextVerticalAdjust(eAdjust));
|
||||||
|
}
|
||||||
m_pImpl->m_rExport.OutputFormat(pParentFrame->GetFrmFmt(), false, false, true);
|
m_pImpl->m_rExport.OutputFormat(pParentFrame->GetFrmFmt(), false, false, true);
|
||||||
m_pImpl->m_bDMLTextFrameSyntax = false;
|
m_pImpl->m_bDMLTextFrameSyntax = false;
|
||||||
writeDMLEffectLst(rFrmFmt);
|
writeDMLEffectLst(rFrmFmt);
|
||||||
|
Reference in New Issue
Block a user