[Libreoffice-commits] core.git: 3 commits - basic/source vcl/source xmloff/inc xmloff/source

Caolán McNamara caolanm at redhat.com
Fri Oct 2 03:39:22 PDT 2015


 basic/source/classes/sbunoobj.cxx          |   87 ++++++++++++++---------------
 basic/source/inc/sbunoobj.hxx              |    2 
 basic/source/runtime/runtime.cxx           |    2 
 vcl/source/gdi/sallayout.cxx               |    6 +-
 xmloff/inc/DomExport.hxx                   |    1 
 xmloff/source/core/DomExport.cxx           |    6 ++
 xmloff/source/forms/elementimport.hxx      |   15 +++++
 xmloff/source/forms/elementimport_impl.hxx |   67 ++++++++++++++++++++++
 8 files changed, 137 insertions(+), 49 deletions(-)

New commits:
commit ae850353151cd6a79f7b4a012d0a411013c841a4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Oct 2 11:25:29 2015 +0100

    Resolves: tdf#92993 access violation on particular .docx on glyph layout
    
    Change-Id: I69dfd6747e37ddb1727dd41b99d1b70eaed83425

diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 0154aaa..eefcd57 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1650,8 +1650,9 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
         maFallbackRuns[n].ResetPos();
     // get the next codepoint index that needs fallback
     int nActiveCharPos = nCharPos[0];
+    int nActiveCharIndex = nActiveCharPos - mnMinCharPos;
     // get the end index of the active run
-    int nLastRunEndChar = (vRtl[nActiveCharPos - mnMinCharPos])?
+    int nLastRunEndChar = (nActiveCharIndex >= 0 && vRtl[nActiveCharIndex]) ?
         rArgs.mnEndCharPos : rArgs.mnMinCharPos - 1;
     int nRunVisibleEndChar = nCharPos[0];
     // merge the fallback levels
@@ -1800,7 +1801,8 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
             if( !bLTR )
                 nOldRunAdv = -nOldRunAdv;
 #endif
-            if (vRtl[nActiveCharPos - mnMinCharPos])
+            nActiveCharIndex = nActiveCharPos - mnMinCharPos;
+            if (nActiveCharIndex >= 0 && vRtl[nActiveCharIndex])
             {
               if (nRunVisibleEndChar > mnMinCharPos && nRunVisibleEndChar <= mnEndCharPos)
                   nRunAdvance -= aMultiArgs.mpDXArray[nRunVisibleEndChar - 1 - mnMinCharPos];
commit e9ae1b64af9b38669476bbcb38a033000149b60f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Oct 2 09:27:37 2015 +0100

    checkUnoObjectType etc always deref their ptr arg, convert to ref
    
    Change-Id: Iabdb057fb2dc05cfb8c98864dc5109360b50633a

diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 216210f..2918736 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -1607,33 +1607,29 @@ OUString Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Referenc
     return aRetStr.makeStringAndClear();
 }
 
-OUString getDbgObjectNameImpl( SbUnoObject* pUnoObj )
+OUString getDbgObjectNameImpl(SbUnoObject& rUnoObj)
 {
-    OUString aName;
-    if( pUnoObj )
+    OUString aName = rUnoObj.GetClassName();
+    if( aName.isEmpty() )
     {
-        aName = pUnoObj->GetClassName();
-        if( aName.isEmpty() )
+        Any aToInspectObj = rUnoObj.getUnoAny();
+        TypeClass eType = aToInspectObj.getValueType().getTypeClass();
+        Reference< XInterface > xObj;
+        if( eType == TypeClass_INTERFACE )
+            xObj = *static_cast<Reference< XInterface > const *>(aToInspectObj.getValue());
+        if( xObj.is() )
         {
-            Any aToInspectObj = pUnoObj->getUnoAny();
-            TypeClass eType = aToInspectObj.getValueType().getTypeClass();
-            Reference< XInterface > xObj;
-            if( eType == TypeClass_INTERFACE )
-                xObj = *static_cast<Reference< XInterface > const *>(aToInspectObj.getValue());
-            if( xObj.is() )
-            {
-                Reference< XServiceInfo > xServiceInfo( xObj, UNO_QUERY );
-                if( xServiceInfo.is() )
-                    aName = xServiceInfo->getImplementationName();
-            }
+            Reference< XServiceInfo > xServiceInfo( xObj, UNO_QUERY );
+            if( xServiceInfo.is() )
+                aName = xServiceInfo->getImplementationName();
         }
     }
     return aName;
 }
 
-OUString getDbgObjectName( SbUnoObject* pUnoObj )
+OUString getDbgObjectName(SbUnoObject& rUnoObj)
 {
-    OUString aName = getDbgObjectNameImpl( pUnoObj );
+    OUString aName = getDbgObjectNameImpl(rUnoObj);
     if( aName.isEmpty() )
         aName += "Unknown";
 
@@ -1650,22 +1646,23 @@ OUString getDbgObjectName( SbUnoObject* pUnoObj )
 
 OUString getBasicObjectTypeName( SbxObject* pObj )
 {
-    OUString aName;
-    if( pObj )
+    if (pObj)
     {
-        SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( pObj );
-        SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>( pObj );
-        if( pUnoObj )
-            aName = getDbgObjectNameImpl( pUnoObj );
-        else if ( pUnoStructObj )
-            aName = pUnoStructObj->GetClassName();
+        if (SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>(pObj))
+        {
+            return getDbgObjectNameImpl(*pUnoObj);
+        }
+        else if (SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>(pObj))
+        {
+            return pUnoStructObj->GetClassName();
+        }
     }
-    return aName;
+    return OUString();
 }
 
-bool checkUnoObjectType( SbUnoObject* pUnoObj, const OUString& rClass )
+bool checkUnoObjectType(SbUnoObject& rUnoObj, const OUString& rClass)
 {
-    Any aToInspectObj = pUnoObj->getUnoAny();
+    Any aToInspectObj = rUnoObj.getUnoAny();
     TypeClass eType = aToInspectObj.getValueType().getTypeClass();
     if( eType != TypeClass_INTERFACE )
     {
@@ -1759,9 +1756,9 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, const OUString& rClass )
 }
 
 // Debugging help method to readout the imlemented interfaces of an object
-OUString Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj )
+OUString Impl_GetSupportedInterfaces(SbUnoObject& rUnoObj)
 {
-    Any aToInspectObj = pUnoObj->getUnoAny();
+    Any aToInspectObj = rUnoObj.getUnoAny();
 
     // allow only TypeClass interface
     TypeClass eType = aToInspectObj.getValueType().getTypeClass();
@@ -1779,7 +1776,7 @@ OUString Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj )
         Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY );
 
         aRet.append( "Supported interfaces by object " );
-        aRet.append( getDbgObjectName( pUnoObj ) );
+        aRet.append(getDbgObjectName(rUnoObj));
         aRet.append( "\n" );
         if( xTypeProvider.is() )
         {
@@ -1858,17 +1855,17 @@ OUString Dbg_SbxDataType2String( SbxDataType eType )
 }
 
 // Debugging help method to display the properties of a SbUnoObjects
-OUString Impl_DumpProperties( SbUnoObject* pUnoObj )
+OUString Impl_DumpProperties(SbUnoObject& rUnoObj)
 {
     OUStringBuffer aRet;
     aRet.append("Properties of object ");
-    aRet.append( getDbgObjectName( pUnoObj ) );
+    aRet.append(getDbgObjectName(rUnoObj));
 
     // analyse the Uno-Infos to recognise the arrays
-    Reference< XIntrospectionAccess > xAccess = pUnoObj->getIntrospectionAccess();
+    Reference< XIntrospectionAccess > xAccess = rUnoObj.getIntrospectionAccess();
     if( !xAccess.is() )
     {
-        Reference< XInvocation > xInvok = pUnoObj->getInvocation();
+        Reference< XInvocation > xInvok = rUnoObj.getInvocation();
         if( xInvok.is() )
             xAccess = xInvok->getIntrospection();
     }
@@ -1882,7 +1879,7 @@ OUString Impl_DumpProperties( SbUnoObject* pUnoObj )
     sal_uInt32 nUnoPropCount = props.getLength();
     const Property* pUnoProps = props.getConstArray();
 
-    SbxArray* pProps = pUnoObj->GetProperties();
+    SbxArray* pProps = rUnoObj.GetProperties();
     sal_uInt16 nPropCount = pProps->Count();
     sal_uInt16 nPropsPerLine = 1 + nPropCount / 30;
     for( sal_uInt16 i = 0; i < nPropCount; i++ )
@@ -1935,17 +1932,17 @@ OUString Impl_DumpProperties( SbUnoObject* pUnoObj )
 }
 
 // Debugging help method to display the methods of an SbUnoObjects
-OUString Impl_DumpMethods( SbUnoObject* pUnoObj )
+OUString Impl_DumpMethods(SbUnoObject& rUnoObj)
 {
     OUStringBuffer aRet;
     aRet.append("Methods of object ");
-    aRet.append( getDbgObjectName( pUnoObj ) );
+    aRet.append(getDbgObjectName(rUnoObj));
 
     // XIntrospectionAccess, so that the types of the parameter could be outputted
-    Reference< XIntrospectionAccess > xAccess = pUnoObj->getIntrospectionAccess();
+    Reference< XIntrospectionAccess > xAccess = rUnoObj.getIntrospectionAccess();
     if( !xAccess.is() )
     {
-        Reference< XInvocation > xInvok = pUnoObj->getInvocation();
+        Reference< XInvocation > xInvok = rUnoObj.getInvocation();
         if( xInvok.is() )
             xAccess = xInvok->getIntrospection();
     }
@@ -1958,7 +1955,7 @@ OUString Impl_DumpMethods( SbUnoObject* pUnoObj )
         ( MethodConcept::ALL - MethodConcept::DANGEROUS );
     const Reference< XIdlMethod >* pUnoMethods = methods.getConstArray();
 
-    SbxArray* pMethods = pUnoObj->GetMethods();
+    SbxArray* pMethods = rUnoObj.GetMethods();
     sal_uInt16 nMethodCount = pMethods->Count();
     if( !nMethodCount )
     {
@@ -2046,7 +2043,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                     // Id == -1: Display implemented interfaces according the ClassProvider
                     if( nId == -1 )     // Property ID_DBG_SUPPORTEDINTERFACES"
                     {
-                        OUString aRetStr = Impl_GetSupportedInterfaces( this );
+                        OUString aRetStr = Impl_GetSupportedInterfaces(*this);
                         pVar->PutString( aRetStr );
                     }
                     // Id == -2: output properties
@@ -2054,7 +2051,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                     {
                         // now all properties must be created
                         implCreateAll();
-                        OUString aRetStr = Impl_DumpProperties( this );
+                        OUString aRetStr = Impl_DumpProperties(*this);
                         pVar->PutString( aRetStr );
                     }
                     // Id == -3: output the methods
@@ -2062,7 +2059,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                     {
                         // now all properties must be created
                         implCreateAll();
-                        OUString aRetStr = Impl_DumpMethods( this );
+                        OUString aRetStr = Impl_DumpMethods(*this);
                         pVar->PutString( aRetStr );
                     }
                     return;
diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx
index 41a7852..bead0c9 100644
--- a/basic/source/inc/sbunoobj.hxx
+++ b/basic/source/inc/sbunoobj.hxx
@@ -410,7 +410,7 @@ css::uno::Reference< css::uno::XInterface > createComListener( const css::uno::A
                                                                                          const OUString& aPrefix,
                                                                                          SbxObjectRef xScopeObj );
 
-bool checkUnoObjectType( SbUnoObject* refVal, const OUString& aClass );
+bool checkUnoObjectType(SbUnoObject& refVal, const OUString& aClass);
 
 SbUnoObject* createOLEObject_Impl( const OUString& aType );
 
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 288d858..0441666 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -3255,7 +3255,7 @@ bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal,
                 if ( ( bVBAEnabled || CodeCompleteOptions::IsExtendedTypeDeclaration() ) && pObj->IsA( TYPE(SbUnoObject) ) )
                 {
                     SbUnoObject& rUnoObj = dynamic_cast<SbUnoObject&>(*pObj);
-                    bOk = checkUnoObjectType(&rUnoObj, aClass);
+                    bOk = checkUnoObjectType(rUnoObj, aClass);
                 }
                 else
                     bOk = false;
commit 446be18a3e6636f40f6ae2f6f8749e068f48aad3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Oct 2 11:38:11 2015 +0100

    make CppunitTest_sw_ww8export work again
    
    revert xmloff portion of
    
    commit 35e68754ec3cff30c5cdb665688a9b13f29dd439
    Author: Noel Grandin <noel at peralex.com>
    Date:   Thu Oct 1 15:10:56 2015 +0200
    
        loplugin:unusedmethods
    
        Change-Id: I3d6f1300f4fae2af9e580d1d3b2c2c80fa9e9268
        Reviewed-on: https://gerrit.libreoffice.org/19075
        Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
        Tested-by: Noel Grandin <noelgrandin at gmail.com>
    
    Change-Id: I24aa3f113a77d93c789b063b3c099bf2038e1dad

diff --git a/xmloff/inc/DomExport.hxx b/xmloff/inc/DomExport.hxx
index c8c9a5d..6f88dc3 100644
--- a/xmloff/inc/DomExport.hxx
+++ b/xmloff/inc/DomExport.hxx
@@ -30,6 +30,7 @@ namespace com { namespace sun { namespace star {
 } } }
 
 void exportDom( SvXMLExport&, const com::sun::star::uno::Reference<com::sun::star::xml::dom::XDocument>& );
+void exportDom( SvXMLExport&, const com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode>& );
 
 #endif
 
diff --git a/xmloff/source/core/DomExport.cxx b/xmloff/source/core/DomExport.cxx
index 4502718..ec55a17 100644
--- a/xmloff/source/core/DomExport.cxx
+++ b/xmloff/source/core/DomExport.cxx
@@ -257,4 +257,10 @@ void exportDom( SvXMLExport& rExport, const Reference<XDocument>& xDocument )
     visit( aDomExport, xDocument );
 }
 
+void exportDom( SvXMLExport& rExport, const Reference<XNode>& xNode )
+{
+    DomExport aDomExport( rExport );
+    visit( aDomExport, xNode );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/forms/elementimport.hxx b/xmloff/source/forms/elementimport.hxx
index 0affa22..c74ba87 100644
--- a/xmloff/source/forms/elementimport.hxx
+++ b/xmloff/source/forms/elementimport.hxx
@@ -572,7 +572,17 @@ namespace xmloff
         {
         }
 
+        // SvXMLImportContext overridables
+        virtual SvXMLImportContext* CreateChildContext(
+            sal_uInt16 _nPrefix, const OUString& _rLocalName,
+            const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList);
+        virtual void EndElement();
+
     protected:
+        // OElementImport overridables
+        virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+                        createElement();
+
         // create the child context for the given control type
         virtual SvXMLImportContext* implCreateControlWrapper(
             sal_uInt16 _nPrefix, const OUString& _rLocalName) = 0;
@@ -595,6 +605,11 @@ namespace xmloff
         OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
                 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxParentContainer,
                 OControlElement::ElementType _eType);
+
+    protected:
+        // OElementImport overridables
+        virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+                        createElement();
     };
 
     //= OColumnWrapperImport
diff --git a/xmloff/source/forms/elementimport_impl.hxx b/xmloff/source/forms/elementimport_impl.hxx
index 1678367..a9cfc99 100644
--- a/xmloff/source/forms/elementimport_impl.hxx
+++ b/xmloff/source/forms/elementimport_impl.hxx
@@ -28,6 +28,58 @@
 // no namespace. Same as above: this file is included from elementimport.hxx only,
 // and this is done inside the namespace
 
+//= OContainerImport
+template <class BASE>
+inline SvXMLImportContext* OContainerImport< BASE >::CreateChildContext(
+    sal_uInt16 _nPrefix, const OUString& _rLocalName,
+    const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttrList)
+{
+    // maybe it's a sub control
+    if (_rLocalName == m_sWrapperElementName)
+    {
+        if (m_xMeAsContainer.is())
+            return implCreateControlWrapper(_nPrefix, _rLocalName);
+        else
+        {
+            OSL_FAIL("OContainerImport::CreateChildContext: don't have an element!");
+            return NULL;
+        }
+    }
+
+    return BASE::CreateChildContext(_nPrefix, _rLocalName, _rxAttrList);
+}
+
+template <class BASE>
+inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+    OContainerImport< BASE >::createElement()
+{
+    // let the base class create the object
+    ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn = BASE::createElement();
+    if (!xReturn.is())
+        return xReturn;
+
+    // ensure that the object is a XNameContainer (we strongly need this for inserting child elements)
+    m_xMeAsContainer = ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >(xReturn, ::com::sun::star::uno::UNO_QUERY);
+    if (!m_xMeAsContainer.is())
+    {
+        OSL_FAIL("OContainerImport::createElement: invalid element (no XNameContainer) created!");
+        xReturn.clear();
+    }
+
+    return xReturn;
+}
+
+template <class BASE>
+inline void OContainerImport< BASE >::EndElement()
+{
+    BASE::EndElement();
+
+    // now that we have all children, attach the events
+    ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xIndexContainer(m_xMeAsContainer, ::com::sun::star::uno::UNO_QUERY);
+    if (xIndexContainer.is())
+        ODefaultEventAttacherManager::setEvents(xIndexContainer);
+}
+
 //= OColumnImport
 template <class BASE>
 OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventAttacherManager& _rEventManager, sal_uInt16 _nPrefix, const OUString& _rName,
@@ -39,4 +91,19 @@ OColumnImport< BASE >::OColumnImport(OFormLayerXMLImport_Impl& _rImport, IEventA
     OSL_ENSURE(m_xColumnFactory.is(), "OColumnImport::OColumnImport: invalid parent container (no factory)!");
 }
 
+// OElementImport overridables
+template <class BASE>
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > OColumnImport< BASE >::createElement()
+{
+    ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xReturn;
+    // no call to the base class' method. We have to use the grid column factory
+    if (m_xColumnFactory.is())
+    {
+        // create the column
+        xReturn = m_xColumnFactory->createColumn(this->m_sServiceName);
+        OSL_ENSURE(xReturn.is(), "OColumnImport::createElement: the factory returned an invalid object!");
+    }
+    return xReturn;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list