[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 7 commits - filter/inc filter/source oox/inc oox/source sw/source writerfilter/inc writerfilter/source

Caolán McNamara caolan at kemper.freedesktop.org
Thu May 31 07:16:41 PDT 2012


 filter/inc/filter/msfilter/msdffimp.hxx        |    2 
 filter/source/msfilter/msdffimp.cxx            |   20 ++++++++-
 oox/inc/oox/vml/vmlshapecontainer.hxx          |    6 --
 oox/source/shape/ShapeContextHandler.cxx       |    5 --
 oox/source/vml/vmlshapecontainer.cxx           |   11 +++--
 sw/source/core/unocore/unoframe.cxx            |    2 
 sw/source/filter/ww8/ww8graf2.cxx              |   30 +++++++++-----
 sw/source/filter/ww8/ww8par.cxx                |   18 +++++++-
 writerfilter/inc/dmapper/DomainMapper.hxx      |    4 +
 writerfilter/source/dmapper/DomainMapper.cxx   |    8 +++
 writerfilter/source/dmapper/GraphicHelpers.cxx |   53 +++++++++++++++++++++++--
 writerfilter/source/dmapper/GraphicHelpers.hxx |   10 ++++
 writerfilter/source/dmapper/GraphicImport.cxx  |   12 +++++
 writerfilter/source/dmapper/PropertyIds.cxx    |    1 
 writerfilter/source/dmapper/PropertyIds.hxx    |    1 
 writerfilter/source/dmapper/PropertyMap.cxx    |   18 ++++++++
 16 files changed, 171 insertions(+), 30 deletions(-)

New commits:
commit 3d6e83aa1161a2a7b2c6c334f458a019185ea670
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri May 4 20:17:44 2012 +0200

    .docx wrap values mean different things than in LO, map them (bnc#750838)
    
    Change-Id: Ic355ae9993702c37c958ea16d8d97e6ef4892dcd
    (cherry picked from commit 20a8768b1c6a6a1456cda9cd096a304e16473fbb)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index 819dc6f..e79e8b4 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -184,12 +184,16 @@ void WrapHandler::lcl_sprm( Sprm& )
 
 sal_Int32 WrapHandler::getWrapMode( )
 {
-    sal_Int32 nMode = com::sun::star::text::WrapTextMode_NONE;
+    // The wrap values do not map directly to our wrap mode,
+    // e.g. none in .docx actually means through in LO.
+    sal_Int32 nMode = com::sun::star::text::WrapTextMode_THROUGHT;
 
     switch ( m_nType )
     {
         case NS_ooxml::LN_Value_vml_wordprocessingDrawing_ST_WrapType_square:
+        // through and tight are somewhat complicated, approximate
         case NS_ooxml::LN_Value_vml_wordprocessingDrawing_ST_WrapType_tight:
+        case NS_ooxml::LN_Value_vml_wordprocessingDrawing_ST_WrapType_through:
             {
                 switch ( m_nSide )
                 {
@@ -204,13 +208,13 @@ sal_Int32 WrapHandler::getWrapMode( )
                 }
             }
             break;
-        case NS_ooxml::LN_Value_vml_wordprocessingDrawing_ST_WrapType_through:
-            nMode = com::sun::star::text::WrapTextMode_THROUGHT;
             break;
         case NS_ooxml::LN_Value_vml_wordprocessingDrawing_ST_WrapType_topAndBottom:
+            nMode = com::sun::star::text::WrapTextMode_NONE;
+            break;
         case NS_ooxml::LN_Value_vml_wordprocessingDrawing_ST_WrapType_none:
         default:
-            nMode = com::sun::star::text::WrapTextMode_NONE;
+            nMode = com::sun::star::text::WrapTextMode_THROUGHT;
     }
 
     return nMode;
commit daa593c4b9656221c95dcb6382fadd017cf9d451
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed May 30 18:23:51 2012 +0200

    fix UNO ZOrder
    
    this is from commits e05e77f4b7373b686f02cc51c7003e72efb07053
    and 9365a3255875eb75923903c8b3d47066aa679c3b
    
    Change-Id: Idad4d6e818e322f30389a9279666166256842185
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 21bc5fa..bf7f079 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1600,6 +1600,8 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
         else if(FN_UNO_Z_ORDER == pEntry->nWID)
         {
             const SdrObject* pObj = pFmt->FindRealSdrObject();
+            if( pObj == NULL )
+                pObj = pFmt->FindSdrObject();
             if( pObj )
             {
                 aAny <<= (sal_Int32)pObj->GetOrdNum();
commit ef0deb11f75c9b3cb031158555748652ffbd6f31
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Apr 17 13:53:17 2012 +0200

    implement relativeHeight (z-order) in .docx import (part of bnc#747461)
    
    Conflicts:
    
    	writerfilter/source/dmapper/DomainMapper.cxx
    	writerfilter/source/dmapper/PropertyIds.cxx
    	writerfilter/source/dmapper/PropertyIds.hxx
    
    Change-Id: I0893014fab1caf0cee9a597e55b931b51b175b6c
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index 4713763..95ddc6f 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -36,6 +36,7 @@
 
 #include <map>
 #include <vector>
+#include <boost/scoped_ptr.hpp>
 
 namespace com{ namespace sun {namespace star{
     namespace beans{
@@ -65,6 +66,7 @@ class PropertyMap;
 class DomainMapper_Impl;
 class ListsManager;
 class StyleSheetTable;
+class GraphicZOrderHelper;
 
 // different context types require different sprm handling (e.g. names)
 enum SprmType
@@ -113,6 +115,7 @@ public:
 
     ::rtl::OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties );
     boost::shared_ptr< StyleSheetTable > GetStyleSheetTable( );
+    GraphicZOrderHelper* graphicZOrderHelper();
 
 private:
     // Stream
@@ -150,6 +153,7 @@ private:
     sal_Unicode getFillCharFromValue(const sal_Int32 nIntValue);
     sal_Int32 mnBackgroundColor;
     bool mbIsHighlightSet;
+    boost::scoped_ptr< GraphicZOrderHelper > zOrderHelper;
 };
 
 } // namespace dmapper
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 4bbba6d..99dbbf6 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -95,6 +95,7 @@
 #endif
 
 #include <resourcemodel/TagLogger.hxx>
+#include <GraphicHelpers.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::rtl;
@@ -3774,6 +3775,13 @@ StyleSheetTablePtr DomainMapper::GetStyleSheetTable( )
     return m_pImpl->GetStyleSheetTable( );
 }
 
+GraphicZOrderHelper* DomainMapper::graphicZOrderHelper()
+{
+    if( zOrderHelper.get() == NULL )
+        zOrderHelper.reset( new GraphicZOrderHelper );
+    return zOrderHelper.get();
+}
+
 } //namespace dmapper
 } //namespace writerfilter
 
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index cdafb8e..819dc6f 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -216,6 +216,47 @@ sal_Int32 WrapHandler::getWrapMode( )
     return nMode;
 }
 
+
+void GraphicZOrderHelper::addItem( uno::Reference< beans::XPropertySet > props, sal_Int32 relativeHeight )
+{
+    items[ relativeHeight ] = props;
+}
+
+// The relativeHeight value in .docx is an arbitrary number, where only the relative ordering matters.
+// But in Writer, the z-order is index in 0..(numitems-1) range, so whenever a new item needs to be
+// added in the proper z-order, it is necessary to find the proper index.
+sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight )
+{
+    Items::const_iterator it = items.begin();
+    while( it != items.end())
+    {
+        // std::map is iterated sorted by key
+        if( it->first > relativeHeight )
+            break; // this is the first one higher, we belong right before it
+        else
+            ++it;
+    }
+    if( it == items.end()) // we're topmost
+    {
+        if( items.empty())
+            return 0;
+        sal_Int32 itemZOrder;
+        --it;
+        if( it->second->getPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier()
+            .GetName( PROP_Z_ORDER )) >>= itemZOrder )
+            return itemZOrder + 1; // after the topmost
+    }
+    else
+    {
+        sal_Int32 itemZOrder;
+        if( it->second->getPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier()
+            .GetName( PROP_Z_ORDER )) >>= itemZOrder )
+            return itemZOrder; // before the item
+    }
+    SAL_WARN( "writerfilter", "findZOrder() didn't find item z-order" );
+    return 0; // this should not(?) happen
+}
+
 } }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/GraphicHelpers.hxx b/writerfilter/source/dmapper/GraphicHelpers.hxx
index 80ddc93..f87b6f9 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.hxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.hxx
@@ -51,6 +51,16 @@ public:
 };
 typedef boost::shared_ptr<WrapHandler> WrapHandlerPtr;
 
+class WRITERFILTER_DLLPRIVATE GraphicZOrderHelper
+{
+public:
+    void addItem( uno::Reference< beans::XPropertySet > props, sal_Int32 relativeHeight );
+    sal_Int32 findZOrder( sal_Int32 relativeHeight );
+private:
+    typedef std::map< sal_Int32, uno::Reference< beans::XPropertySet > > Items;
+    Items items;
+};
+
 } }
 
 #endif
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 2bb6693..62fb1c6 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -209,6 +209,7 @@ public:
     sal_Int32 nBottomCrop;
 
     bool      bUseSimplePos;
+    sal_Int32 zOrder;
 
     sal_Int16 nHoriOrient;
     sal_Int16 nHoriRelation;
@@ -274,6 +275,7 @@ public:
         ,nRightCrop (0)
         ,nBottomCrop(0)
         ,bUseSimplePos(false)
+        ,zOrder(-1)
         ,nHoriOrient(   text::HoriOrientation::NONE )
         ,nHoriRelation( text::RelOrientation::FRAME )
         ,bPageToggle( false )
@@ -829,7 +831,7 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
             m_pImpl->bUseSimplePos = nIntValue > 0;
         break;
         case NS_ooxml::LN_CT_Anchor_relativeHeight: // 90988;
-            //z-order
+            m_pImpl->zOrder = nIntValue;
         break;
         case NS_ooxml::LN_CT_Anchor_behindDoc: // 90989; - in background
             if( nIntValue > 0 )
@@ -1448,6 +1450,14 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_BACK_COLOR ),
                     uno::makeAny( m_pImpl->nFillColor ));
 
+                if( m_pImpl->zOrder >= 0 )
+                {
+                    GraphicZOrderHelper* zOrderHelper = m_pImpl->rDomainMapper.graphicZOrderHelper();
+                    xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_Z_ORDER ),
+                        uno::makeAny( zOrderHelper->findZOrder( m_pImpl->zOrder )));
+                    zOrderHelper->addItem( xGraphicObjectProperties, m_pImpl->zOrder );
+                }
+
                 //there seems to be no way to detect the original size via _real_ API
                 uno::Reference< beans::XPropertySet > xGraphicProperties( xGraphic, uno::UNO_QUERY_THROW );
                 awt::Size aGraphicSize, aGraphicSizePixel;
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index c8f8a55..b37632c 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -319,6 +319,7 @@ const rtl::OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
             case PROP_HEADING_STYLE_NAME:    sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName")); break;
             case PROP_FRM_DIRECTION:        sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FRMDirection")); break;
             case PROP_EMBEDDED_OBJECT           :    sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EmbeddedObject")); break;
+            case PROP_Z_ORDER: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZOrder")); break;
         }
         ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
                 m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index b109cd6..fbbae64 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -292,6 +292,7 @@ enum PropertyIds
         ,PROP_WRITING_MODE
 /*253*/ ,PROP_FRM_DIRECTION
         ,PROP_EMBEDDED_OBJECT
+        ,PROP_Z_ORDER
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier
commit e224044d83cae5b6904188c368a714ff9554baba
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon May 28 17:21:10 2012 +0200

    fix horizontal rule width in .doc documents (bnc#757118)
    
    MSO uses undocumented properties that seem to map to o:hr and o:hrpct
    from .docx (including differences between .docx spec and implementation),
    so treat horizontal rule width the same way in .doc too. Also remove
    the guesswork for #i17200# that is not quite correct and no longer needed.
    
    Change-Id: Ibec543fa1679ca0b20e86ef6b4f77147b18dff7e
    (cherry picked from commit 5845298e615a599d5edc7c42275b52ae954250e8)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index 9dabeb0..412809f 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -315,6 +315,8 @@ struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
     sal_Bool        bVFlip :1;
     sal_Bool        bHFlip :1;
     sal_Bool        bAutoWidth      :1;
+    int             relativeHorizontalWidth; // in 0.1% or -1 for none
+    bool            isHorizontalRule;
 
     SvxMSDffImportRec();
     SvxMSDffImportRec(const SvxMSDffImportRec& rCopy);
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 9f67f28..3107635 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5349,6 +5349,18 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
                         *(pImpRec->pYRelTo) = nUDData;
                         break;
                     case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
+                    case 0x0393:
+                    // This seems to correspond to o:hrpct from .docx (even including
+                    // the difference that it's in 0.1% even though the .docx spec
+                    // says it's in 1%).
+                        pImpRec->relativeHorizontalWidth = nUDData;
+                        break;
+                    case 0x0394:
+                    // And this is really just a guess, but a mere presence of this
+                    // flag makes a horizontal rule be as wide as the page (unless
+                    // overriden by something), so it probably matches o:hr from .docx.
+                        pImpRec->isHorizontalRule = true;
+                        break;
                 }
                 if ( rSt.GetError() != 0 )
                     break;
@@ -7673,7 +7685,9 @@ SvxMSDffImportRec::SvxMSDffImportRec()
       aTextId( 0, 0 ),
       nNextShapeId( 0 ),
       nShapeId( 0 ),
-      eShapeType( mso_sptNil )
+      eShapeType( mso_sptNil ),
+      relativeHorizontalWidth( -1 ),
+      isHorizontalRule( false )
 {
       eLineStyle      = mso_lineSimple; // GPF-Bug #66227#
       eLineDashing    = mso_lineSolid;
@@ -7711,7 +7725,9 @@ SvxMSDffImportRec::SvxMSDffImportRec(const SvxMSDffImportRec& rCopy)
       aTextId( rCopy.aTextId ),
       nNextShapeId( rCopy.nNextShapeId ),
       nShapeId( rCopy.nShapeId ),
-      eShapeType( rCopy.eShapeType )
+      eShapeType( rCopy.eShapeType ),
+      relativeHorizontalWidth( rCopy.relativeHorizontalWidth ),
+      isHorizontalRule( rCopy.isHorizontalRule )
 {
     if (rCopy.pXRelTo)
     {
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 3bcbaf7..93ef5e7 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -528,15 +528,6 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
             // verlinkte Grafik im Escher-Objekt
             SdrObject* pObject = 0;
 
-            //#i17200#, a bit of guesswork I'm afraid
-            if (aPic.dxaGoal == 1000 && aPic.mx == 1)  //100% hack ?
-            {
-                aPic.mx = msword_cast<sal_uInt16>(
-                    maSectionManager.GetPageWidth() -
-                    maSectionManager.GetPageRight() -
-                    maSectionManager.GetPageLeft());
-            }
-
             WW8PicDesc aPD( aPic );
             String aGrName;
             if (!pMSDffManager)
@@ -577,6 +568,27 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
 
                 if( pRecord )
                 {
+
+                    // Horizontal rule may have its width given as % of page width
+                    // (-1 is used if not given, 0 means the object has fixed width).
+                    // Additionally, if it's a horizontal rule without width given,
+                    // assume 100.0% width.
+                    int relativeWidth = pRecord->relativeHorizontalWidth;
+                    if( relativeWidth == -1 )
+                        relativeWidth = pRecord->isHorizontalRule ? 1000 : 0;
+                    if( relativeWidth != 0 )
+                    {
+                        aPic.mx = msword_cast<sal_uInt16>(
+                            maSectionManager.GetPageWidth() -
+                            maSectionManager.GetPageRight() -
+                            maSectionManager.GetPageLeft()) * relativeWidth / 1000;
+                        aPD = WW8PicDesc( aPic );
+                        // This SetSnapRect() call adjusts the size of the object itself,
+                        // no idea why it's this call (or even what the call actually does),
+                        // but that's what ImportGraf() (called by ImportObj()) uses.
+                        pObject->SetSnapRect( Rectangle( 0, 0, aPD.nWidth, aPD.nHeight ));
+                    }
+
                     //A graphic of this type in this location is always
                     //inline, and uses the pic in the same mould as ww6
                     //graphics.
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 8d6d699..703ca04 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -491,6 +491,18 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
                         *(pImpRec->pYRelTo) = nUDData;
                         break;
                     case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
+                    case 0x0393:
+                    // This seems to correspond to o:hrpct from .docx (even including
+                    // the difference that it's in 0.1% even though the .docx spec
+                    // says it's in 1%).
+                        pImpRec->relativeHorizontalWidth = nUDData;
+                        break;
+                    case 0x0394:
+                    // And this is really just a guess, but a mere presence of this
+                    // flag makes a horizontal rule be as wide as the page (unless
+                    // overriden by something), so it probably matches o:hr from .docx.
+                        pImpRec->isHorizontalRule = true;
+                        break;
                 }
                 if ( rSt.GetError() != 0 )
                     break;
commit 5f9f711bbf2678479f3b6dfd497bc8dc1c6066ca
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu May 24 17:57:41 2012 +0200

    handle column break in .docx properly too
    
    related to d8cac25ed29dbeca16161f62173a7e341793b8b6
    
    Change-Id: I56b02a450e96acec0346d6a36c29ad8e0326b0c8
    (cherry picked from commit d4798414f2705ee987d79617ae2e76da2524e26d)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index adb8675..494e470 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -858,6 +858,24 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
         uno::Reference<beans::XPropertySet> xRangeProperties(lcl_GetRangeProperties(m_bIsFirstSection, rDM_Impl, m_xStartingRange));
         xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName));
     }
+    // If the section is of type "New column" (0x01), then simply insert a column break.
+    // But only if there actually are columns on the page, otherwise a column break
+    // seems to be handled like a page break by MSO.
+    else if(m_nBreakType == 1 && m_nColumnCount > 0 )
+    {
+        uno::Reference< beans::XPropertySet > xRangeProperties;
+        if( m_xStartingRange.is() )
+        {
+            xRangeProperties = uno::Reference< beans::XPropertySet >( m_xStartingRange, uno::UNO_QUERY_THROW );
+        }
+        else
+        {
+            //set the start value at the beginning of the document
+            xRangeProperties = uno::Reference< beans::XPropertySet >( rDM_Impl.GetTextDocument()->getText()->getStart(), uno::UNO_QUERY_THROW );
+        }
+        xRangeProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_BREAK_TYPE ),
+            uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE));
+    }
     else
     {
         //get the properties and create appropriate page styles
commit c15f23b561b9a540cd8024a4f4294a8b51596c28
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu May 24 15:27:57 2012 +0200

    column break without columns seems to be a page break (bnc#750255)
    
    That at least seems to be my conclusion after testing the doc
    and bnc#652364 in MSO2k7.
    
    Change-Id: Iec172dad32ba47c1f843df49a4eaff688c094373
    (cherry picked from commit 5935a6db64830ac5b932803cdcac5813aa033594)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 1070fdc..8d6d699 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3931,8 +3931,10 @@ void wwSectionManager::InsertSegments()
     mySegIter aStart = maSegments.begin();
     for (mySegIter aIter = aStart; aIter != aEnd; ++aIter)
     {
-        // If the section is of type "New column" (0x01), then simply insert a column break
-        if ( aIter->maSep.bkc == 1 )
+        // If the section is of type "New column" (0x01), then simply insert a column break.
+        // But only if there actually are columns on the page, otherwise a column break
+        // seems to be handled like a page break by MSO.
+        if ( aIter->maSep.bkc == 1 && aIter->maSep.ccolM1 > 0 )
         {
             SwPaM start( aIter->maStart );
             mrReader.rDoc.InsertPoolItem( start, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0);
commit a73a229f77471bcf50b00a8395ddcd7c85be69f6
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue May 22 17:21:13 2012 +0200

    rework getting shape for the .docx import filter
    
    This makes both sw/qa/extras/ooxmltok/data/n705956-{1|2}.docx testcases
    work at the same time. As far as I understand it, the .docx filter
    calls into oox and at the end if gets the shape, while the shape
    is removed from the ShapeContainer. In the case of recursion caused by
    <w:pict><v:shape><w:txbxContent><w:pict><v:shape>, clearing the whole
    list is wrong. Also, the OSL_ENSURE seems to suggest that there should
    not be more than one shape inserted by each read. So simply consider
    maShapes to be a stack when importing .docx .
    
    Change-Id: I7263aeaf74c8d31a05e64c56b880cbc6b00d7dd6
    (cherry picked from commit 04d600d4be7c50db4b3b505039eb8bc96856f593)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/oox/inc/oox/vml/vmlshapecontainer.hxx b/oox/inc/oox/vml/vmlshapecontainer.hxx
index 2880625..9b11c6c 100644
--- a/oox/inc/oox/vml/vmlshapecontainer.hxx
+++ b/oox/inc/oox/vml/vmlshapecontainer.hxx
@@ -92,16 +92,14 @@ public:
     template< typename Functor >
     const ShapeBase*    findShape( const Functor& rFunctor ) const;
 
-    /** Returns the first shape in the collection (Word only). */
-    const ShapeBase*    getFirstShape() const;
+    /** Returns and removes the last shape in the collection (Word only). */
+    const ShapeBase*    takeLastShape();
 
     /** Creates and inserts all UNO shapes into the passed container. */
     void                convertAndInsert(
                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
                             const ShapeParentAnchor* pParentAnchor = 0 ) const;
 
-    inline void                clearShapes( ) { maShapes.clear( ); }
-
 private:
     typedef RefVector< ShapeType >                  ShapeTypeVector;
     typedef RefVector< ShapeBase >                  ShapeVector;
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index de27734..3234238 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -244,11 +244,8 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException)
         if ( getContextHandler() == getDrawingShapeContext() )
         {
             mpDrawing->finalizeFragmentImport();
-            if( const ::oox::vml::ShapeBase* pShape = mpDrawing->getShapes().getFirstShape() )
-            {
+            if( const ::oox::vml::ShapeBase* pShape = mpDrawing->getShapes().takeLastShape() )
                 xResult = pShape->convertAndInsert( xShapes );
-                mpDrawing->getShapes( ).clearShapes( );
-            }
         }
         else if (mpShape.get() != NULL)
         {
diff --git a/oox/source/vml/vmlshapecontainer.cxx b/oox/source/vml/vmlshapecontainer.cxx
index e8a8d02..9502e4c 100644
--- a/oox/source/vml/vmlshapecontainer.cxx
+++ b/oox/source/vml/vmlshapecontainer.cxx
@@ -118,11 +118,14 @@ const ShapeBase* ShapeContainer::getShapeById( const OUString& rShapeId, bool bD
    return 0;
 }
 
-const ShapeBase* ShapeContainer::getFirstShape() const
+const ShapeBase* ShapeContainer::takeLastShape()
 {
-    OSL_ENSURE( mrDrawing.getType() == VMLDRAWING_WORD, "ShapeContainer::getFirstShape - illegal call, Word filter only" );
-    OSL_ENSURE( maShapes.size() == 1, "ShapeContainer::getFirstShape - single shape expected" );
-    return maShapes.get( 0 ).get();
+    assert( mrDrawing.getType() == VMLDRAWING_WORD );
+    if( maShapes.empty())
+        return NULL;
+    const ShapeBase* ret = maShapes.back().get();
+    maShapes.pop_back();
+    return ret;
 }
 
 void ShapeContainer::convertAndInsert( const Reference< XShapes >& rxShapes, const ShapeParentAnchor* pParentAnchor ) const


More information about the Libreoffice-commits mailing list