n744510: Improved 'vert' text imports.

This commit is contained in:
Muthu Subramanian
2012-02-14 19:49:31 +05:30
parent cc459ea8c1
commit 8167b8f3d9
4 changed files with 48 additions and 37 deletions

View File

@@ -29,6 +29,7 @@
#ifndef OOX_DRAWINGML_TEXTBODYPROPERTIES_HXX
#define OOX_DRAWINGML_TEXTBODYPROPERTIES_HXX
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include "oox/helper/helper.hxx"
#include "oox/helper/propertymap.hxx"
@@ -39,13 +40,15 @@ namespace drawingml {
struct TextBodyProperties
{
PropertyMap maPropertyMap;
OptValue< sal_Int32 > moRotation;
OptValue< sal_Int32 > moVert;
PropertyMap maPropertyMap;
OptValue< sal_Int32 > moRotation;
OptValue< sal_Int32 > moVert;
::com::sun::star::drawing::TextVerticalAdjust meVA;
explicit TextBodyProperties();
void pushToPropMap( PropertyMap& rPropMap ) const;
void pushVertSimulation();
};
// ============================================================================

View File

@@ -528,15 +528,17 @@ Reference< XShape > Shape::createAndInsert(
mpCustomShapePropertiesPtr->setMirroredX( sal_True );
if ( mbFlipV )
mpCustomShapePropertiesPtr->setMirroredY( sal_True );
if( mpTextBody.get() )
if( getTextBody() )
{
sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( mpTextBody->getTextProperties().moRotation.get( 0 ) );
sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) );
mpCustomShapePropertiesPtr->setTextRotateAngle( -nTextRotateAngle / 60000 );
}
OSL_TRACE("==cscode== shape name: '%s'", rtl::OUStringToOString(msName, RTL_TEXTENCODING_UTF8 ).getStr());
mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape );
}
else if( getTextBody() )
getTextBody()->getTextProperties().pushVertSimulation();
// in some cases, we don't have any text body.
if( getTextBody() )

View File

@@ -26,16 +26,22 @@
*
************************************************************************/
#include "oox/drawingml/textbodyproperties.hxx"
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include "oox/drawingml/drawingmltypes.hxx"
#include "oox/drawingml/textbodyproperties.hxx"
#include "oox/token/tokens.hxx"
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::text;
namespace oox {
namespace drawingml {
// ============================================================================
TextBodyProperties::TextBodyProperties()
TextBodyProperties::TextBodyProperties():
meVA( TextVerticalAdjust_TOP )
{
}
@@ -44,6 +50,28 @@ void TextBodyProperties::pushToPropMap( PropertyMap& rPropMap ) const
rPropMap.insert( maPropertyMap.begin(), maPropertyMap.end() );
}
/* For Legacy purposes: TODO: Check if it is required at all! */
void TextBodyProperties::pushVertSimulation()
{
sal_Int32 tVert = moVert.get( XML_horz );
if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) {
// #160799# fake different vertical text modes by top-bottom writing mode
maPropertyMap[ PROP_TextWritingMode ] <<= WritingMode_TB_RL;
// workaround for TB_LR as using WritingMode2 doesn't work
if( meVA != TextVerticalAdjust_CENTER )
maPropertyMap[ PROP_TextHorizontalAdjust ] <<=
(tVert == XML_vert270) ? TextHorizontalAdjust_RIGHT : TextHorizontalAdjust_LEFT;
if( tVert == XML_vert270 )
maPropertyMap[ PROP_TextVerticalAdjust ] <<= TextVerticalAdjust_BOTTOM;
if( ( tVert == XML_vert && meVA == TextVerticalAdjust_TOP ) ||
( tVert == XML_vert270 && meVA == TextVerticalAdjust_BOTTOM ) )
maPropertyMap[ PROP_TextHorizontalAdjust ] <<= TextHorizontalAdjust_RIGHT;
else if( meVA == TextVerticalAdjust_CENTER )
maPropertyMap[ PROP_TextHorizontalAdjust ] <<= TextHorizontalAdjust_CENTER;
}
}
// ============================================================================
} // namespace drawingml

View File

@@ -28,12 +28,10 @@
#include "oox/drawingml/textbodypropertiescontext.hxx"
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include <com/sun/star/text/ControlCharacter.hpp>
//#include <com/sun/star/text/ControlCharacter.hpp>
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/drawing/TextFitToSizeType.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include "oox/drawingml/textbodyproperties.hxx"
#include "oox/drawingml/drawingmltypes.hxx"
#include "oox/helper/attributelist.hxx"
@@ -118,45 +116,25 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent,
mrTextBodyProp.moVert = aAttribs.getToken( XML_vert );
bool bRtl = aAttribs.getBool( XML_rtl, false );
sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz );
if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) {
// #160799# fake different vertical text modes by top-bottom writing mode
mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ]
<<= WritingMode_TB_RL;
// workaround for TB_LR as using WritingMode2 doesn't work
if( !bAnchorCenter )
mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<=
(tVert == XML_vert270) ? TextHorizontalAdjust_RIGHT : TextHorizontalAdjust_LEFT;
// Default for vert270
if( tVert == XML_vert270 )
mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= drawing::TextVerticalAdjust_BOTTOM;
} else
if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert )
mrTextBodyProp.moRotation = 5400000*(tVert==XML_vert270?3:1);
else
mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ]
<<= ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB );
}
// ST_TextAnchoringType
if( xAttributes->hasAttribute( XML_anchor ) ) {
drawing::TextVerticalAdjust eVA( drawing::TextVerticalAdjust_TOP );
switch( xAttributes->getOptionalValueToken( XML_anchor, XML_t ) )
{
case XML_b : eVA = drawing::TextVerticalAdjust_BOTTOM; break;
case XML_b : mrTextBodyProp.meVA = drawing::TextVerticalAdjust_BOTTOM; break;
case XML_dist :
case XML_just :
case XML_ctr : eVA = drawing::TextVerticalAdjust_CENTER; break;
case XML_ctr : mrTextBodyProp.meVA = drawing::TextVerticalAdjust_CENTER; break;
default:
case XML_t : eVA = drawing::TextVerticalAdjust_TOP; break;
case XML_t : mrTextBodyProp.meVA = drawing::TextVerticalAdjust_TOP; break;
}
if( xAttributes->hasAttribute( XML_vert ) &&
( ( mrTextBodyProp.moVert.get( XML_horz ) == XML_vert && eVA == drawing::TextVerticalAdjust_TOP ) ||
( mrTextBodyProp.moVert.get( XML_horz ) == XML_vert270 && eVA == drawing::TextVerticalAdjust_BOTTOM ) ) )
{
mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<=
TextHorizontalAdjust_RIGHT;
}
else if( mrTextBodyProp.moVert.get( XML_horz ) == XML_horz )
mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= eVA;
else if( eVA == drawing::TextVerticalAdjust_CENTER && xAttributes->hasAttribute( XML_vert ) )
mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<= TextHorizontalAdjust_CENTER;
mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= mrTextBodyProp.meVA;
}
}