Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index



 Hello,

 could somebody please review and pick for 3-5 the following changes from 
master? They all have nice descriptive commit messages and testcases in 
sw/qa/extras :) .

- http://cgit.freedesktop.org/libreoffice/core/commit/?id=04d600d4be7c
- http://cgit.freedesktop.org/libreoffice/core/commit/?id=5935a6db6483
- http://cgit.freedesktop.org/libreoffice/core/commit/?id=d4798414f270
- http://cgit.freedesktop.org/libreoffice/core/commit/?id=5845298e615a

- http://cgit.freedesktop.org/libreoffice/core/commit/?id=0a9161263b8e (does 
not backport without conflicts, use the attached patch)

- the attached 0001-fix-UNO-ZOrder.patch, which is commits 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=e05e77f4b737 and 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=9365a3255875 merged

 Thanks.

-- 
 Lubos Lunak
 l.lunak@suse.cz
From 9b909c372cd1e214a723aaae42bc3a0597ca5f86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <l.lunak@suse.cz>
Date: Tue, 17 Apr 2012 13:53:17 +0200
Subject: [PATCH] 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
---
 writerfilter/inc/dmapper/DomainMapper.hxx      |    4 ++
 writerfilter/source/dmapper/DomainMapper.cxx   |    8 +++++
 writerfilter/source/dmapper/GraphicHelpers.cxx |   41 ++++++++++++++++++++++++
 writerfilter/source/dmapper/GraphicHelpers.hxx |   10 ++++++
 writerfilter/source/dmapper/GraphicImport.cxx  |   12 ++++++-
 writerfilter/source/dmapper/PropertyIds.cxx    |    1 +
 writerfilter/source/dmapper/PropertyIds.hxx    |    1 +
 7 files changed, 76 insertions(+), 1 deletions(-)

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
-- 
1.7.7

From 5d16c73ae6f8c7a97c4ffab23ee39738fbf93fe0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <l.lunak@suse.cz>
Date: Wed, 30 May 2012 18:23:51 +0200
Subject: [PATCH] fix UNO ZOrder

this is from commits e05e77f4b7373b686f02cc51c7003e72efb07053
and 9365a3255875eb75923903c8b3d47066aa679c3b

Change-Id: Idad4d6e818e322f30389a9279666166256842185
---
 sw/source/core/unocore/unoframe.cxx |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

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();
-- 
1.7.7


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.