[Libreoffice-commits] .: oox/inc oox/source

Muthu Subramanian sumuthu at kemper.freedesktop.org
Tue Feb 14 05:59:41 PST 2012


 oox/inc/oox/drawingml/textbodyproperties.hxx       |    9 +++-
 oox/source/drawingml/shape.cxx                     |    6 ++-
 oox/source/drawingml/textbodyproperties.cxx        |   32 ++++++++++++++++-
 oox/source/drawingml/textbodypropertiescontext.cxx |   38 ++++-----------------
 4 files changed, 48 insertions(+), 37 deletions(-)

New commits:
commit 8167b8f3d9ca506a30bd8454d934d713033cb8b4
Author: Muthu Subramanian <sumuthu at suse.com>
Date:   Tue Feb 14 19:49:31 2012 +0530

    n744510: Improved 'vert' text imports.

diff --git a/oox/inc/oox/drawingml/textbodyproperties.hxx b/oox/inc/oox/drawingml/textbodyproperties.hxx
index a1b914a..e155d30 100644
--- a/oox/inc/oox/drawingml/textbodyproperties.hxx
+++ b/oox/inc/oox/drawingml/textbodyproperties.hxx
@@ -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();
 };
 
 // ============================================================================
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 54d9527..a6e86c3 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -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() )
diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx
index 43acd8c..b79883a 100644
--- a/oox/source/drawingml/textbodyproperties.cxx
+++ b/oox/source/drawingml/textbodyproperties.cxx
@@ -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
diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx
index f281c56..a654fb6 100644
--- a/oox/source/drawingml/textbodypropertiescontext.cxx
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -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;
-        }
-        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;
+            case XML_t :    mrTextBodyProp.meVA = drawing::TextVerticalAdjust_TOP; break;
         }
-        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;
     }
 }
 


More information about the Libreoffice-commits mailing list