Kaydet (Commit) 8167b8f3 authored tarafından Muthu Subramanian's avatar Muthu Subramanian

n744510: Improved 'vert' text imports.

üst cc459ea8
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#ifndef OOX_DRAWINGML_TEXTBODYPROPERTIES_HXX #ifndef OOX_DRAWINGML_TEXTBODYPROPERTIES_HXX
#define OOX_DRAWINGML_TEXTBODYPROPERTIES_HXX #define OOX_DRAWINGML_TEXTBODYPROPERTIES_HXX
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include "oox/helper/helper.hxx" #include "oox/helper/helper.hxx"
#include "oox/helper/propertymap.hxx" #include "oox/helper/propertymap.hxx"
...@@ -39,13 +40,15 @@ namespace drawingml { ...@@ -39,13 +40,15 @@ namespace drawingml {
struct TextBodyProperties struct TextBodyProperties
{ {
PropertyMap maPropertyMap; PropertyMap maPropertyMap;
OptValue< sal_Int32 > moRotation; OptValue< sal_Int32 > moRotation;
OptValue< sal_Int32 > moVert; OptValue< sal_Int32 > moVert;
::com::sun::star::drawing::TextVerticalAdjust meVA;
explicit TextBodyProperties(); explicit TextBodyProperties();
void pushToPropMap( PropertyMap& rPropMap ) const; void pushToPropMap( PropertyMap& rPropMap ) const;
void pushVertSimulation();
}; };
// ============================================================================ // ============================================================================
......
...@@ -528,15 +528,17 @@ Reference< XShape > Shape::createAndInsert( ...@@ -528,15 +528,17 @@ Reference< XShape > Shape::createAndInsert(
mpCustomShapePropertiesPtr->setMirroredX( sal_True ); mpCustomShapePropertiesPtr->setMirroredX( sal_True );
if ( mbFlipV ) if ( mbFlipV )
mpCustomShapePropertiesPtr->setMirroredY( sal_True ); 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 ); mpCustomShapePropertiesPtr->setTextRotateAngle( -nTextRotateAngle / 60000 );
} }
OSL_TRACE("==cscode== shape name: '%s'", rtl::OUStringToOString(msName, RTL_TEXTENCODING_UTF8 ).getStr()); OSL_TRACE("==cscode== shape name: '%s'", rtl::OUStringToOString(msName, RTL_TEXTENCODING_UTF8 ).getStr());
mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape ); mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape );
} }
else if( getTextBody() )
getTextBody()->getTextProperties().pushVertSimulation();
// in some cases, we don't have any text body. // in some cases, we don't have any text body.
if( getTextBody() ) if( getTextBody() )
......
...@@ -26,16 +26,22 @@ ...@@ -26,16 +26,22 @@
* *
************************************************************************/ ************************************************************************/
#include "oox/drawingml/textbodyproperties.hxx"
#include <com/sun/star/text/WritingMode.hpp> #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" #include "oox/token/tokens.hxx"
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::text;
namespace oox { namespace oox {
namespace drawingml { namespace drawingml {
// ============================================================================ // ============================================================================
TextBodyProperties::TextBodyProperties() TextBodyProperties::TextBodyProperties():
meVA( TextVerticalAdjust_TOP )
{ {
} }
...@@ -44,6 +50,28 @@ void TextBodyProperties::pushToPropMap( PropertyMap& rPropMap ) const ...@@ -44,6 +50,28 @@ void TextBodyProperties::pushToPropMap( PropertyMap& rPropMap ) const
rPropMap.insert( maPropertyMap.begin(), maPropertyMap.end() ); 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 } // namespace drawingml
......
...@@ -28,12 +28,10 @@ ...@@ -28,12 +28,10 @@
#include "oox/drawingml/textbodypropertiescontext.hxx" #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/text/WritingMode.hpp>
#include <com/sun/star/drawing/TextFitToSizeType.hpp> #include <com/sun/star/drawing/TextFitToSizeType.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include "oox/drawingml/textbodyproperties.hxx" #include "oox/drawingml/textbodyproperties.hxx"
#include "oox/drawingml/drawingmltypes.hxx" #include "oox/drawingml/drawingmltypes.hxx"
#include "oox/helper/attributelist.hxx" #include "oox/helper/attributelist.hxx"
...@@ -118,45 +116,25 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent, ...@@ -118,45 +116,25 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent,
mrTextBodyProp.moVert = aAttribs.getToken( XML_vert ); mrTextBodyProp.moVert = aAttribs.getToken( XML_vert );
bool bRtl = aAttribs.getBool( XML_rtl, false ); bool bRtl = aAttribs.getBool( XML_rtl, false );
sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz ); sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz );
if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) { 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.moRotation = 5400000*(tVert==XML_vert270?3:1);
mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ] else
<<= 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
mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ] mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ]
<<= ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB ); <<= ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB );
} }
// ST_TextAnchoringType // ST_TextAnchoringType
if( xAttributes->hasAttribute( XML_anchor ) ) { if( xAttributes->hasAttribute( XML_anchor ) ) {
drawing::TextVerticalAdjust eVA( drawing::TextVerticalAdjust_TOP );
switch( xAttributes->getOptionalValueToken( XML_anchor, XML_t ) ) 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_dist :
case XML_just : case XML_just :
case XML_ctr : eVA = drawing::TextVerticalAdjust_CENTER; break; case XML_ctr : mrTextBodyProp.meVA = drawing::TextVerticalAdjust_CENTER; break;
default: 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 ] <<= mrTextBodyProp.meVA;
mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= eVA;
else if( eVA == drawing::TextVerticalAdjust_CENTER && xAttributes->hasAttribute( XML_vert ) )
mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<= TextHorizontalAdjust_CENTER;
} }
} }
......
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