[Libreoffice-commits] core.git: 3 commits - include/xmloff xmloff/source

Thorsten Behrens tbehrens at suse.com
Wed May 15 02:15:13 PDT 2013


 include/xmloff/unointerfacetouniqueidentifiermapper.hxx     |   23 --
 include/xmloff/xmlmultiimagehelper.hxx                      |    6 
 xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx |  108 +++---------
 xmloff/source/core/xmlmultiimagehelper.cxx                  |    8 
 xmloff/source/draw/ximpshap.cxx                             |   11 -
 xmloff/source/draw/ximpshap.hxx                             |    2 
 xmloff/source/text/XMLTextFrameContext.cxx                  |    2 
 xmloff/source/text/XMLTextFrameContext.hxx                  |    2 
 8 files changed, 55 insertions(+), 107 deletions(-)

New commits:
commit 450cd772aa734cfcb989c8cedd3c0a454db74a34
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Wed May 15 11:05:45 2013 +0200

    Fix fdo#64512 Handle xml:id correctly on multi-image draw:frames
    
    Fixes a regression from the pick-best-image from draw:frame in ODF,
    where before sometimes the XShape got deleted that the
    UnoInterfaceToUniqueIdentifierMapper::registerReference stored.
    
    For that, added a
    UnoInterfaceToUniqueIdentifierMapper::registerReferenceAlways
    function, which overwrites potentially existing earlier entries
    with the same identifier string.
    
    This fix was originally much more messy, but then dtardon committed
    30b248dfe5bfb8a0649e36f22c943b3feb2f1385 which also fixes this here
    bug. Now only sneaking in slightly less involved interface map
    handling and a safeguard in ximpshap.cxx.
    
    Change-Id: I87501e43518a5fc2fee166c45a4e2f01718f5228

diff --git a/include/xmloff/unointerfacetouniqueidentifiermapper.hxx b/include/xmloff/unointerfacetouniqueidentifiermapper.hxx
index 6f154bf..6ec3700 100644
--- a/include/xmloff/unointerfacetouniqueidentifiermapper.hxx
+++ b/include/xmloff/unointerfacetouniqueidentifiermapper.hxx
@@ -24,7 +24,6 @@
 #include "xmloff/dllapi.h"
 #include "sal/types.h"
 
-#include <deque>
 #include <map>
 #include <rtl/ustring.hxx>
 #include <com/sun/star/uno/XInterface.hpp>
@@ -32,12 +31,10 @@
 namespace comphelper
 {
 
-typedef ::std::map< OUString, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > IdMap_t;
+typedef ::std::map< OUString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > IdMap_t;
 
 class XMLOFF_DLLPUBLIC UnoInterfaceToUniqueIdentifierMapper
 {
-    typedef std::deque< rtl::OUString > Reserved_t;
-
 public:
     UnoInterfaceToUniqueIdentifierMapper();
     ~UnoInterfaceToUniqueIdentifierMapper();
@@ -54,16 +51,12 @@ public:
     */
     bool registerReference( const OUString& rIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface );
 
-    /** reserves an identifier for later registration.
-
-        @returns
-            false, if the identifier already exists
-      */
-    bool reserveIdentifier( const rtl::OUString& rIdentifier );
+    /** always registers the given uno object with the given identifier.
 
-    /** registers the given uno object with reserved identifier.
-      */
-    bool registerReservedReference( const rtl::OUString& rIdentifier, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rInterface );
+        In contrast to registerReference(), this here overwrites any
+        earlier registration of the same identifier
+    */
+    void registerReferenceAlways( const rtl::OUString& rIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface );
 
     /** @returns
             the identifier for the given uno object. If this uno object is not already
@@ -80,12 +73,10 @@ public:
 private:
     bool findReference( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface, IdMap_t::const_iterator& rIter ) const;
     bool findIdentifier( const OUString& rIdentifier, IdMap_t::const_iterator& rIter ) const;
-    bool findReserved( const OUString& rIdentifier ) const;
-    bool findReserved( const OUString& rIdentifier, Reserved_t::const_iterator& rIter ) const;
+    void insertReference( const OUString& rIdentifier, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rInterface );
 
     IdMap_t	maEntries;
     sal_Int32 mnNextId;
-    Reserved_t maReserved;
 };
 
 }
diff --git a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
index 568943a..317ad07 100644
--- a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
+++ b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
@@ -17,8 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <algorithm>
-
 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
 
 using namespace ::com::sun::star;
@@ -72,42 +70,25 @@ bool UnoInterfaceToUniqueIdentifierMapper::registerReference( const OUString& rI
     {
         return rIdentifier != (*aIter).first;
     }
-    else if( findIdentifier( rIdentifier, aIter ) || findReserved( rIdentifier ) )
+    else if( findIdentifier( rIdentifier, aIter ) )
     {
         return false;
     }
     else
     {
-        maEntries.insert( IdMap_t::value_type( rIdentifier, xRef ) );
-
-        // see if this is a reference like something we would generate in the future
-        const sal_Unicode *p = rIdentifier.getStr();
-        sal_Int32 nLength = rIdentifier.getLength();
-
-        // see if the identifier is 'id' followed by a pure integer value
-        if( nLength < 2 || p[0] != 'i' || p[1] != 'd' )
-            return true;
-
-        nLength -= 2;
-        p += 2;
-
-        while(nLength--)
-        {
-            if( (*p < '0') || (*p > '9') )
-                return true; // a custom id, that will never conflict with genereated id's
+        insertReference( rIdentifier, xRef );
+    }
 
-            p++;
-        }
+    return true;
+}
 
-        // the identifier is a pure integer value
-        // so we make sure we will never generate
-        // an integer value like this one
-        sal_Int32 nId = rIdentifier.copy(2).toInt32();
-        if( mnNextId <= nId )
-            mnNextId = nId + 1;
+void UnoInterfaceToUniqueIdentifierMapper::registerReferenceAlways( const OUString& rIdentifier, const Reference< XInterface >& rInterface )
+{
+    // Be certain that the references we store in our table are to the
+    // leading / primary XInterface - cf. findReference
+    uno::Reference< uno::XInterface > xRef( rInterface, uno::UNO_QUERY );
 
-        return true;
-    }
+    insertReference( rIdentifier, xRef );
 }
 
 const OUString& UnoInterfaceToUniqueIdentifierMapper::getIdentifier( const Reference< XInterface >& rInterface ) const
@@ -166,42 +147,35 @@ bool UnoInterfaceToUniqueIdentifierMapper::findIdentifier( const OUString& rIden
     return rIter != maEntries.end();
 }
 
-bool UnoInterfaceToUniqueIdentifierMapper::reserveIdentifier( const rtl::OUString& rIdentifier )
+void UnoInterfaceToUniqueIdentifierMapper::insertReference( const OUString& rIdentifier, const Reference< XInterface >& rInterface )
 {
-    if ( findReserved( rIdentifier ) )
-        return false;
+    maEntries[rIdentifier] = rInterface;
 
-    maReserved.push_back( rIdentifier );
-    return true;
-}
+    // see if this is a reference like something we would generate in the future
+    const sal_Unicode *p = rIdentifier.getStr();
+    sal_Int32 nLength = rIdentifier.getLength();
 
-bool UnoInterfaceToUniqueIdentifierMapper::registerReservedReference(
-        const rtl::OUString& rIdentifier,
-        const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rInterface )
-{
-    Reserved_t::const_iterator aIt;
-    if ( !findReserved( rIdentifier, aIt ) )
-        return false;
+    // see if the identifier is 'id' followed by a pure integer value
+    if( nLength < 2 || p[0] != 'i' || p[1] != 'd' )
+        return;
 
-    Reserved_t::iterator aRemoveIt( maReserved.begin() + ( aIt - maReserved.begin() ) );
-    maReserved.erase( aRemoveIt );
-    registerReference( rIdentifier, rInterface );
+    nLength -= 2;
+    p += 2;
 
-    return true;
-}
+    while(nLength--)
+    {
+        if( (*p < '0') || (*p > '9') )
+            return; // a custom id, that will never conflict with genereated id's
 
-bool UnoInterfaceToUniqueIdentifierMapper::findReserved( const OUString& rIdentifier ) const
-{
-    Reserved_t::const_iterator aDummy;
-    return findReserved( rIdentifier, aDummy );
-}
+        p++;
+    }
 
-bool UnoInterfaceToUniqueIdentifierMapper::findReserved(
-        const OUString& rIdentifier,
-        Reserved_t::const_iterator& rIter ) const
-{
-    rIter = std::find( maReserved.begin(), maReserved.end(), rIdentifier );
-    return rIter != maReserved.end();
+    // the identifier is a pure integer value
+    // so we make sure we will never generate
+    // an integer value like this one
+    sal_Int32 nId = rIdentifier.copy(2).toInt32();
+    if( mnNextId <= nId )
+        mnNextId = nId + 1;
 }
 
 }
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 75dae5d..eb7171b 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3455,9 +3455,6 @@ SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPref
 
         if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext))
         {
-            if ( !maShapeId.isEmpty() )
-                GetImport().getInterfaceToIdentifierMapper().reserveIdentifier( maShapeId );
-
             addContent(*mxImplContext);
         }
     }
@@ -3534,11 +3531,13 @@ void SdXMLFrameShapeContext::EndElement()
     // solve if multiple image child contexts were imported
     const SvXMLImportContext* const pSelectedContext(solveMultipleImages());
     const SdXMLGraphicObjectShapeContext* pShapeContext( dynamic_cast<const SdXMLGraphicObjectShapeContext*>( pSelectedContext ) );
-    if ( pShapeContext )
+    if ( pShapeContext && !maShapeId.isEmpty() )
     {
+        // fdo#64512 and fdo#60075 - make sure *this* shape is
+        // registered for given ID
         assert( mxImplContext.Is() );
         const uno::Reference< uno::XInterface > xShape( pShapeContext->getShape() );
-        GetImport().getInterfaceToIdentifierMapper().registerReservedReference( maShapeId, xShape );
+        GetImport().getInterfaceToIdentifierMapper().registerReferenceAlways( maShapeId, xShape );
     }
 
     if( !mxImplContext.Is() )
commit 5134816d205fc9733a35bb6fd8a6a1a04ec8bc9e
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Wed May 15 02:58:22 2013 +0200

    Remove redundant doxygen doc strings.
    
    This is already (identically) documented in the header file.
    
    Change-Id: I4a10cb0c1d1b1eee80fd828ab95829fb8128433f

diff --git a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
index bbbc874..568943a 100644
--- a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
+++ b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
@@ -41,9 +41,6 @@ UnoInterfaceToUniqueIdentifierMapper::~UnoInterfaceToUniqueIdentifierMapper()
     );
 }
 
-/** returns a unique identifier for the given uno object. IF a uno object is
-    registered more than once, the returned identifier is always the same.
-*/
 const OUString& UnoInterfaceToUniqueIdentifierMapper::registerReference( const Reference< XInterface >& rInterface )
 {
     // Be certain that the references we store in our table are to the
@@ -63,11 +60,6 @@ const OUString& UnoInterfaceToUniqueIdentifierMapper::registerReference( const R
     }
 }
 
-/** registers the given uno object with the given identifier.
-
-    @returns
-        false, if the given identifier already exists and is not associated with the given interface
-*/
 bool UnoInterfaceToUniqueIdentifierMapper::registerReference( const OUString& rIdentifier, const Reference< XInterface >& rInterface )
 {
     IdMap_t::const_iterator aIter;
@@ -118,10 +110,6 @@ bool UnoInterfaceToUniqueIdentifierMapper::registerReference( const OUString& rI
     }
 }
 
-/** @returns
-        the identifier for the given uno object. If this uno object is not already
-        registered, an empty string is returned
-*/
 const OUString& UnoInterfaceToUniqueIdentifierMapper::getIdentifier( const Reference< XInterface >& rInterface ) const
 {
     IdMap_t::const_iterator aIter;
@@ -136,10 +124,6 @@ const OUString& UnoInterfaceToUniqueIdentifierMapper::getIdentifier( const Refer
     }
 }
 
-/** @returns
-    the uno object that is registered with the given identifier. If no uno object
-    is registered with the given identifier, an empty reference is returned.
-*/
 const Reference< XInterface >& UnoInterfaceToUniqueIdentifierMapper::getReference( const OUString& rIdentifier ) const
 {
     IdMap_t::const_iterator aIter;
commit c6747ee3a9f02cfbb1a89572180d7bb7ee5be9eb
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Wed May 15 09:31:38 2013 +0200

    Use upper camel case for class names in xmloff.
    
    Align multiimagehelper with module standard.
    
    Change-Id: I70a4dbc66a0d127b9bf04d1e8db694d3526b21d7

diff --git a/include/xmloff/xmlmultiimagehelper.hxx b/include/xmloff/xmlmultiimagehelper.hxx
index bbe9ce1..7a7e2ab 100644
--- a/include/xmloff/xmlmultiimagehelper.hxx
+++ b/include/xmloff/xmlmultiimagehelper.hxx
@@ -25,7 +25,7 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
-class multiImageImportHelper
+class MultiImageImportHelper
 {
 private:
     std::vector< SvXMLImportContextRef* >       maImplContextVector;
@@ -37,8 +37,8 @@ protected:
     virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) const = 0;
 
 public:
-    multiImageImportHelper();
-    virtual ~multiImageImportHelper();
+    MultiImageImportHelper();
+    virtual ~MultiImageImportHelper();
 
     /// solve multiple imported images. The most valuable one is choosen,
     /// see imlementation for evtl. changing weights and/or adding filetypes.
diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx
index 3d2dc77..5159720 100644
--- a/xmloff/source/core/xmlmultiimagehelper.cxx
+++ b/xmloff/source/core/xmlmultiimagehelper.cxx
@@ -74,13 +74,13 @@ namespace
 
 //////////////////////////////////////////////////////////////////////////////
 
-multiImageImportHelper::multiImageImportHelper()
+MultiImageImportHelper::MultiImageImportHelper()
 :   maImplContextVector(),
     mbSupportsMultipleContents(false)
 {
 }
 
-multiImageImportHelper::~multiImageImportHelper()
+MultiImageImportHelper::~MultiImageImportHelper()
 {
     while(!maImplContextVector.empty())
     {
@@ -89,7 +89,7 @@ multiImageImportHelper::~multiImageImportHelper()
     }
 }
 
-const SvXMLImportContext* multiImageImportHelper::solveMultipleImages()
+const SvXMLImportContext* MultiImageImportHelper::solveMultipleImages()
 {
     const SvXMLImportContext* pContext(0);
     if(maImplContextVector.size() > 1)
@@ -137,7 +137,7 @@ const SvXMLImportContext* multiImageImportHelper::solveMultipleImages()
     return pContext;
 }
 
-void multiImageImportHelper::addContent(const SvXMLImportContext& rSvXMLImportContext)
+void MultiImageImportHelper::addContent(const SvXMLImportContext& rSvXMLImportContext)
 {
     if(dynamic_cast< const SvXMLImportContext* >(&rSvXMLImportContext))
     {
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 81c91a1..75dae5d 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3347,7 +3347,7 @@ SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport& rImport, sal_uInt16
         com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
         sal_Bool bTemporaryShape)
 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
-    multiImageImportHelper(),
+    MultiImageImportHelper(),
     mbSupportsReplacement( sal_False ),
     mxImplContext(),
     mxReplImplContext()
diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx
index 949c70b..4d64a63 100644
--- a/xmloff/source/draw/ximpshap.hxx
+++ b/xmloff/source/draw/ximpshap.hxx
@@ -570,7 +570,7 @@ public:
 //////////////////////////////////////////////////////////////////////////////
 // draw:-frame
 
-class SdXMLFrameShapeContext : public SdXMLShapeContext, public multiImageImportHelper
+class SdXMLFrameShapeContext : public SdXMLShapeContext, public MultiImageImportHelper
 {
 private:
     sal_Bool mbSupportsReplacement;
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index 826b9e8..4c268e6 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -1333,7 +1333,7 @@ XMLTextFrameContext::XMLTextFrameContext(
         const Reference< XAttributeList > & xAttrList,
         TextContentAnchorType eATyp )
 :   SvXMLImportContext( rImport, nPrfx, rLName )
-,   multiImageImportHelper()
+,   MultiImageImportHelper()
 ,   m_xAttrList( new SvXMLAttributeList( xAttrList ) )
 ,   m_pHyperlink( 0 )
     // Implement Title/Description Elements UI (#i73249#)
diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx
index 818b306..4c01671 100644
--- a/xmloff/source/text/XMLTextFrameContext.hxx
+++ b/xmloff/source/text/XMLTextFrameContext.hxx
@@ -30,7 +30,7 @@ namespace com { namespace sun { namespace star {
 
 class XMLTextFrameContextHyperlink_Impl;
 
-class XMLTextFrameContext : public SvXMLImportContext, public multiImageImportHelper
+class XMLTextFrameContext : public SvXMLImportContext, public MultiImageImportHelper
 {
     ::com::sun::star::uno::Reference<
         ::com::sun::star::xml::sax::XAttributeList > m_xAttrList;


More information about the Libreoffice-commits mailing list