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

Radek Doulík rodo at kemper.freedesktop.org
Wed Mar 30 08:38:01 PDT 2011


 oox/inc/oox/drawingml/textfield.hxx              |    2 +-
 oox/inc/oox/drawingml/textrun.hxx                |    2 +-
 oox/inc/oox/drawingml/textspacing.hxx            |    7 +------
 oox/source/drawingml/textfield.cxx               |    7 ++++++-
 oox/source/drawingml/textparagraph.cxx           |   10 +++++++---
 oox/source/drawingml/textparagraphproperties.cxx |    4 ++--
 oox/source/drawingml/textrun.cxx                 |    7 ++++++-
 7 files changed, 24 insertions(+), 15 deletions(-)

New commits:
commit 68ca223c828be170aa3b0f46c5cfac87f2934090
Author: Radek Doulik <rodo at novell.com>
Date:   Wed Mar 30 17:32:44 2011 +0200

    fix import of percentual top and bottom paragraph margins

diff --git a/oox/inc/oox/drawingml/textfield.hxx b/oox/inc/oox/drawingml/textfield.hxx
index 2203545..504b53d 100644
--- a/oox/inc/oox/drawingml/textfield.hxx
+++ b/oox/inc/oox/drawingml/textfield.hxx
@@ -50,7 +50,7 @@ public:
     inline void setType( const ::rtl::OUString& sType ) { msType = sType; }
     inline void setUuid( const ::rtl::OUString & sUuid ) { msUuid = sUuid; }
 
-    virtual void    insertAt(
+    virtual sal_Int32    insertAt(
                         const ::oox::core::XmlFilterBase& rFilterBase,
                         const ::com::sun::star::uno::Reference < ::com::sun::star::text::XText > & xText,
                         const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor > &xAt,
diff --git a/oox/inc/oox/drawingml/textrun.hxx b/oox/inc/oox/drawingml/textrun.hxx
index 537ae84..1bcbec9 100644
--- a/oox/inc/oox/drawingml/textrun.hxx
+++ b/oox/inc/oox/drawingml/textrun.hxx
@@ -50,7 +50,7 @@ public:
 
     inline void                 setLineBreak() { mbIsLineBreak = true; }
 
-    virtual void                insertAt(
+    virtual sal_Int32               insertAt(
                                     const ::oox::core::XmlFilterBase& rFilterBase,
                                     const ::com::sun::star::uno::Reference < ::com::sun::star::text::XText >& xText,
                                     const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor >& xAt,
diff --git a/oox/inc/oox/drawingml/textspacing.hxx b/oox/inc/oox/drawingml/textspacing.hxx
index 907e7ea..5a69c0e 100644
--- a/oox/inc/oox/drawingml/textspacing.hxx
+++ b/oox/inc/oox/drawingml/textspacing.hxx
@@ -62,12 +62,7 @@ namespace oox { namespace drawingml {
         sal_Int32 toMargin( float fFontSize ) const
             {
                 if ( nUnit == PERCENT )
-                {
-                    double fMargin = ( fFontSize * 2540 + 36 ) / 72;
-                    fMargin *= nValue;
-                    fMargin /= 100000;
-                    return static_cast< sal_Int32 >( fMargin );
-                }
+                    return (sal_Int32) ((((fFontSize*nValue)/1000)*254 + 360)/720);
                 else
                     return nValue;
             }
diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx
index 3527f23..f088136 100644
--- a/oox/source/drawingml/textfield.cxx
+++ b/oox/source/drawingml/textfield.cxx
@@ -139,12 +139,13 @@ void lclCreateTextFields( std::list< Reference< XTextField > > & aFields,
 
 } // namespace
 
-void TextField::insertAt(
+sal_Int32 TextField::insertAt(
         const ::oox::core::XmlFilterBase& rFilterBase,
         const Reference < XText > & xText,
         const Reference < XTextCursor > &xAt,
         const TextCharacterProperties& rTextCharacterStyle ) const
 {
+    sal_Int32 nCharHeight = 0;
     try
     {
         PropertyMap aioBulletList;
@@ -157,6 +158,8 @@ void TextField::insertAt(
         TextCharacterProperties aTextCharacterProps( rTextCharacterStyle );
         aTextCharacterProps.assignUsed( maTextParagraphProperties.getTextCharacterProperties() );
         aTextCharacterProps.assignUsed( getTextCharacterProperties() );
+        if ( aTextCharacterProps.moHeight.has() )
+            nCharHeight = aTextCharacterProps.moHeight.get();
         aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
 
         std::list< Reference< XTextField > > fields;
@@ -191,6 +194,8 @@ void TextField::insertAt(
     {
         OSL_TRACE("OOX:  TextField::insertAt() exception");
     }
+
+    return nCharHeight;
 }
 
 } }
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
index 2205d7b..ca2dcee 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -80,19 +80,23 @@ void TextParagraph::insertAt(
             xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False );
             xAt->gotoEnd( sal_True );
         }
+
+        sal_Int32 nCharHeight = 0;
         if ( maRuns.begin() == maRuns.end() )
         {
             PropertySet aPropSet( xStart );
 
             TextCharacterProperties aTextCharacterProps( aTextCharacterStyle );
             aTextCharacterProps.assignUsed( maEndProperties );
+            if ( aTextCharacterProps.moHeight.has() )
+                nCharHeight = aTextCharacterProps.moHeight.get();
             aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
         }
         else
         {
             for( TextRunVector::const_iterator aIt = maRuns.begin(), aEnd = maRuns.end(); aIt != aEnd; ++aIt )
             {
-                (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle );
+                nCharHeight = std::max< sal_Int32 >( nCharHeight, (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ) );
                 nParagraphSize += (*aIt)->getText().getLength();
             }
         }
@@ -100,11 +104,11 @@ void TextParagraph::insertAt(
 
         PropertyMap aioBulletList;
         Reference< XPropertySet > xProps( xStart, UNO_QUERY);
-        float fCharacterSize = 18;
+        float fCharacterSize = nCharHeight > 0 ? GetFontHeight( nCharHeight ) :  18;
         if ( pTextParagraphStyle.get() )
         {
             pTextParagraphStyle->pushToPropSet( &rFilterBase, xProps, aioBulletList, NULL, sal_False, fCharacterSize );
-            fCharacterSize = pTextParagraphStyle->getCharHeightPoints( 18 );
+            fCharacterSize = pTextParagraphStyle->getCharHeightPoints( fCharacterSize );
         }
         maProperties.pushToPropSet( &rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize );
 
diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
index 5d50f6a..99eeebb 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -405,9 +405,9 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p
     maBulletList.pushToPropMap( pFilterBase, rioBulletMap );
 
     if ( maParaTopMargin.bHasValue )
-        aPropSet.setProperty( PROP_ParaTopMargin, maParaTopMargin.toMargin( getCharHeightPoints( 18.0 ) ) );
+        aPropSet.setProperty( PROP_ParaTopMargin, maParaTopMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 18.0 ) ) );
     if ( maParaBottomMargin.bHasValue )
-        aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( getCharHeightPoints( 18.0 ) ) );
+        aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 18.0 ) ) );
     if ( nNumberingType == NumberingType::BITMAP )
     {
         fCharacterSize = getCharHeightPoints( fCharacterSize );
diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx
index 9d14e46..ad973ca 100644
--- a/oox/source/drawingml/textrun.cxx
+++ b/oox/source/drawingml/textrun.cxx
@@ -55,18 +55,21 @@ TextRun::~TextRun()
 {
 }
 
-void TextRun::insertAt(
+sal_Int32 TextRun::insertAt(
         const ::oox::core::XmlFilterBase& rFilterBase,
         const Reference < XText > & xText,
         const Reference < XTextCursor > &xAt,
         const TextCharacterProperties& rTextCharacterStyle ) const
 {
+    sal_Int32 nCharHeight = 0;
     try {
         Reference< XTextRange > xStart( xAt, UNO_QUERY );
         PropertySet aPropSet( xStart );
 
         TextCharacterProperties aTextCharacterProps( rTextCharacterStyle );
         aTextCharacterProps.assignUsed( maTextCharacterProperties );
+        if ( aTextCharacterProps.moHeight.has() )
+            nCharHeight = aTextCharacterProps.moHeight.get();
         aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
 
         if( maTextCharacterProperties.maHyperlinkPropertyMap.empty() )
@@ -163,6 +166,8 @@ void TextRun::insertAt(
     {
         OSL_TRACE("OOX:  TextRun::insertAt() exception");
     }
+
+    return nCharHeight;
 }
 
 


More information about the Libreoffice-commits mailing list