[Libreoffice-commits] .: Branch 'libreoffice-4-0' - 2 commits - writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 4 07:49:12 PST 2013


 writerfilter/source/dmapper/CellMarginHandler.cxx      |    6 ++++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx      |   17 ++++++++++++--
 writerfilter/source/dmapper/TablePropertiesHandler.cxx |   20 +++++++++++++++++
 3 files changed, 40 insertions(+), 3 deletions(-)

New commits:
commit 1505a56f5a0d0ed0e3a8571ff89a15aaed180a32
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jan 4 12:56:40 2013 +0100

    n#793262 DOCX: import w:tcMar inside w:tc
    
    These were ignored previously, and in case they contained some margins,
    the resulting table was potentially smaller than necessary.
    (cherry picked from commit 60ec497e0e91354a616978be531d15d3efa3f559)

diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx
index 6ee219e..6119831 100644
--- a/writerfilter/source/dmapper/CellMarginHandler.cxx
+++ b/writerfilter/source/dmapper/CellMarginHandler.cxx
@@ -75,6 +75,7 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
         switch( rSprm.getId() )
         {
             case NS_ooxml::LN_CT_TblCellMar_top:
+            case NS_ooxml::LN_CT_TcMar_top:
                 m_nTopMargin = m_nValue;
                 m_bTopMarginValid = true;
             break;
@@ -91,10 +92,12 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
                 }
             break;
             case NS_ooxml::LN_CT_TblCellMar_left:
+            case NS_ooxml::LN_CT_TcMar_left:
                 m_nLeftMargin = m_nValue;
                 m_bLeftMarginValid = true;
             break;
             case NS_ooxml::LN_CT_TblCellMar_bottom:
+            case NS_ooxml::LN_CT_TcMar_bottom:
                 m_nBottomMargin = m_nValue;
                 m_bBottomMarginValid = true;
             break;
@@ -111,11 +114,12 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
                 }
             break;
             case NS_ooxml::LN_CT_TblCellMar_right:
+            case NS_ooxml::LN_CT_TcMar_right:
                 m_nRightMargin = m_nValue;
                 m_bRightMarginValid = true;
             break;
             default:
-                OSL_FAIL( "unknown attribute");
+                OSL_FAIL( "unknown sprm");
         }
     }
     m_nValue = 0;
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 17e1a84..b1d560c 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -170,6 +170,26 @@ namespace dmapper {
                 }
             }
             break;
+            case NS_ooxml::LN_CT_TcPrBase_tcMar:
+                {
+                    writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+                    if (pProperties.get())
+                    {
+                        CellMarginHandlerPtr pCellMarginHandler(new CellMarginHandler);
+                        pProperties->resolve(*pCellMarginHandler);
+                        TablePropertyMapPtr pCellProperties(new TablePropertyMap);
+                        if (pCellMarginHandler->m_bTopMarginValid)
+                            pCellProperties->Insert(PROP_TOP_BORDER_DISTANCE, false, uno::makeAny(pCellMarginHandler->m_nTopMargin));
+                        if (pCellMarginHandler->m_bLeftMarginValid)
+                            pCellProperties->Insert(PROP_LEFT_BORDER_DISTANCE, false, uno::makeAny(pCellMarginHandler->m_nLeftMargin));
+                        if (pCellMarginHandler->m_bBottomMarginValid)
+                            pCellProperties->Insert(PROP_BOTTOM_BORDER_DISTANCE, false, uno::makeAny(pCellMarginHandler->m_nBottomMargin));
+                        if (pCellMarginHandler->m_bRightMarginValid)
+                            pCellProperties->Insert(PROP_RIGHT_BORDER_DISTANCE, false, uno::makeAny(pCellMarginHandler->m_nRightMargin));
+                        cellProps(pCellProperties);
+                    }
+                }
+            break;
             case NS_ooxml::LN_CT_TblPrBase_shd:
             {
                 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
commit a23fc47fccb907dc7a3197982ea541834f5d8fd7
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Thu Jan 3 16:40:29 2013 +0100

    n#793262 fix DOCX import of last empty header/footer para char props
    
    At the end of the header/footer import, the last empty paragraph was
    removed. In case the last but one paragraph was empty, but had character
    properties (e.g. a custom font size), the removal changed these, and
    used the character properties of the last paragraph instead.
    
    Simply dispose the last paragraph, this way character properties are
    always kept.
    (cherry picked from commit e8b661dd0aed9b35104e910acbb814748a2c3af0)

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9381f73..ef16af5 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -279,8 +279,21 @@ void DomainMapper_Impl::RemoveLastParagraph( )
         }
         else
             xCursor.set(m_aTextAppendStack.top().xCursor, uno::UNO_QUERY);
-        xCursor->goLeft( 1, true );
-        xCursor->setString(OUString());
+        uno::Reference<container::XEnumerationAccess> xEnumerationAccess(xCursor, uno::UNO_QUERY);
+        // Keep the character properties of the last but one paragraph, even if
+        // it's empty. This works for headers/footers, and maybe in other cases
+        // as well, but surely not in textboxes.
+        if (m_bInHeaderFooterImport && xEnumerationAccess.is())
+        {
+            uno::Reference<container::XEnumeration> xEnumeration = xEnumerationAccess->createEnumeration();
+            uno::Reference<lang::XComponent> xParagraph(xEnumeration->nextElement(), uno::UNO_QUERY);
+            xParagraph->dispose();
+        }
+        else
+        {
+            xCursor->goLeft( 1, true );
+            xCursor->setString(OUString());
+        }
     }
     catch( const uno::Exception& )
     {


More information about the Libreoffice-commits mailing list