[Libreoffice-commits] .: 5 commits - offapi/UnoApi_offapi.mk offapi/com sw/inc sw/source unotools/source

Michael Stahl mst at kemper.freedesktop.org
Mon Nov 28 13:51:57 PST 2011


 offapi/UnoApi_offapi.mk                          |    1 
 offapi/com/sun/star/awt/MaxChildrenException.idl |   27 -------
 offapi/com/sun/star/drawing/modules.idl          |    7 --
 sw/inc/fmtanchr.hxx                              |    7 +-
 sw/source/core/crsr/pam.cxx                      |   78 ++++++++++++++++++++---
 sw/source/core/layout/atrfrm.cxx                 |   57 +++++++---------
 unotools/source/ucbhelper/ucbhelper.cxx          |    2 
 7 files changed, 100 insertions(+), 79 deletions(-)

New commits:
commit 274da1e4d2b7756e80ff73dcf0007627db90a14b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Nov 28 22:17:15 2011 +0100

    utl::UCBContentHelper::EqualURLs: inverted return

diff --git a/unotools/source/ucbhelper/ucbhelper.cxx b/unotools/source/ucbhelper/ucbhelper.cxx
index 137d170..935620f 100644
--- a/unotools/source/ucbhelper/ucbhelper.cxx
+++ b/unotools/source/ucbhelper/ucbhelper.cxx
@@ -493,7 +493,7 @@ bool utl::UCBContentHelper::EqualURLs(
                 RTL_CONSTASCII_USTRINGPARAM("no ucbhelper::ContentBroker")),
             css::uno::Reference<css::uno::XInterface>());
     }
-    return broker->getContentProviderInterface()->compareContentIds(
+    return 0 == broker->getContentProviderInterface()->compareContentIds(
         (broker->getContentIdentifierFactoryInterface()->
          createContentIdentifier(canonic(url1))),
         (broker->getContentIdentifierFactoryInterface()->
commit 5469d397c6d31b7dc57574f13976155f78df582f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Nov 28 21:51:53 2011 +0100

    offapi: remove outdated doucmentation of removed stuff

diff --git a/offapi/com/sun/star/drawing/modules.idl b/offapi/com/sun/star/drawing/modules.idl
index 53d34c0..e0231a3 100644
--- a/offapi/com/sun/star/drawing/modules.idl
+++ b/offapi/com/sun/star/drawing/modules.idl
@@ -32,13 +32,6 @@ module com { module sun { module star { module drawing {
 
 /** The drawing framework is responsible for managing the resources used by
     the UI of the drawing applications.
-    <p>The framework is implemented by a set of sub controllers that are
-    responsible for its different resources: <type
-    scope="com::sun::star::drawing::framework">XModuleController</type>,
-    <type scope="com::sun::star::drawing::framework">XPaneController</type>,
-    <type scope="com::sun::star::drawing::framework">XViewController</type>,
-    <type scope="com::sun::star::drawing::framework">XToolbarController</type>,
-    <type scope="com::sun::star::drawing::framework">XCommandController</type>.
     The set of active resources is represented by the <type
     scope="com::sun::star::drawing::framework">XConfiguration</type>.</p>
     <p>The <type
commit ad88d5116ba7326e6bf71f6081398c2114db9c99
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Nov 28 21:51:18 2011 +0100

    offapi: remove obsolete MaxChildrenException.idl

diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index f63ddd3..66e5944 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -1675,7 +1675,6 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,offapi,offapi/com/sun/star/awt,\
 	KeyModifier \
 	KeyStroke \
 	LineEndFormat \
-	MaxChildrenException \
 	MenuEvent \
 	MenuItemStyle \
 	MenuItemType \
diff --git a/offapi/com/sun/star/awt/MaxChildrenException.idl b/offapi/com/sun/star/awt/MaxChildrenException.idl
deleted file mode 100644
index 54bedbf..0000000
--- a/offapi/com/sun/star/awt/MaxChildrenException.idl
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __com_sun_star_awt_MaxChildrenException_idl__
-#define __com_sun_star_awt_MaxChildrenException_idl__
-
-#include <com/sun/star/uno/Exception.idl>
-
-//=============================================================================
-
-module com {  module sun {  module star {  module awt {
-
-//=============================================================================
-
-/** This exception is thrown when adding a child to a container that is full.
-
-    @see     XLayoutContainer
-    @see     com::sun::star::awt::XLayoutContainer::addChild
-
-    @since OOo 3.0
- */
-exception MaxChildrenException: com::sun::star::uno::Exception
-{
-};
-
-//=============================================================================
-
-}; }; }; };
-
-#endif
commit 59e298823019093ee788104c2e95cb0c7b145d05
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Nov 28 17:27:38 2011 +0100

    SwPosition: handle un-registered SwIndex:
    
    For frames anchored at paragraph, SwFmtAnchor::SetAnchor() creates
    an anchor SwPosition that points at the SwTxtNode but with a SwIndex
    that is not registered at the SwTxtNode.
    SwXFrame::getAnchor() then creates a bookmark from that, which asserts
    in the SwIndex comparison operators.
    
    Work around this by adding ugly special handling for the case of 2
    positions having their SwNodeIndex point to the same node but one of
    them not having its SwIndex at the node.
    
    It seems it is best to do this in SwPosition operators, as the SwIndex
    operators lack the context to know if this inconsistency is allowed,
    and it is unknown whether the bookmarks sort code is the only path that
    triggers this assert.

diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index b22bad8..8e59406 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -108,7 +108,21 @@ sal_Bool SwPosition::operator<(const SwPosition &rPos) const
     if( nNode < rPos.nNode )
         return sal_True;
     if( nNode == rPos.nNode )
-        return ( nContent < rPos.nContent );
+    {
+        // note that positions with text node but no SwIndex registered are
+        // created for text frames anchored at para (see SwXFrame::getAnchor())
+        SwIndexReg const*const pThisReg(nContent.GetIdxReg());
+        SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
+        if (pThisReg && pOtherReg)
+        {
+            return (nContent < rPos.nContent);
+        }
+        else // by convention position with no index is smaller
+        {
+            return (pThisReg) ? sal_False :
+                     ((pOtherReg) ? sal_True : (this < &rPos));
+        }
+    }
     return sal_False;
 }
 
@@ -118,7 +132,21 @@ sal_Bool SwPosition::operator>(const SwPosition &rPos) const
     if(nNode > rPos.nNode )
         return sal_True;
     if( nNode == rPos.nNode )
-        return ( nContent > rPos.nContent );
+    {
+        // note that positions with text node but no SwIndex registered are
+        // created for text frames anchored at para (see SwXFrame::getAnchor())
+        SwIndexReg const*const pThisReg(nContent.GetIdxReg());
+        SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
+        if (pThisReg && pOtherReg)
+        {
+            return (nContent > rPos.nContent);
+        }
+        else // by convention position with no index is smaller
+        {
+            return (pThisReg) ? sal_True:
+                     ((pOtherReg) ? sal_False: (this > &rPos));
+        }
+    }
     return sal_False;
 }
 
@@ -128,7 +156,21 @@ sal_Bool SwPosition::operator<=(const SwPosition &rPos) const
     if(nNode < rPos.nNode )
         return sal_True;
     if( nNode == rPos.nNode )
-        return ( nContent <= rPos.nContent );
+    {
+        // note that positions with text node but no SwIndex registered are
+        // created for text frames anchored at para (see SwXFrame::getAnchor())
+        SwIndexReg const*const pThisReg(nContent.GetIdxReg());
+        SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
+        if (pThisReg && pOtherReg)
+        {
+            return (nContent <= rPos.nContent);
+        }
+        else // by convention position with no index is smaller
+        {
+            return (pThisReg) ? sal_False :
+                     ((pOtherReg) ? sal_True : (this <= &rPos));
+        }
+    }
     return sal_False;
 }
 
@@ -138,24 +180,40 @@ sal_Bool SwPosition::operator>=(const SwPosition &rPos) const
     if(nNode > rPos.nNode )
         return sal_True;
     if( nNode == rPos.nNode )
-        return ( nContent >= rPos.nContent );
+    {
+        // note that positions with text node but no SwIndex registered are
+        // created for text frames anchored at para (see SwXFrame::getAnchor())
+        SwIndexReg const*const pThisReg(nContent.GetIdxReg());
+        SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
+        if (pThisReg && pOtherReg)
+        {
+            return (nContent >= rPos.nContent);
+        }
+        else // by convention position with no index is smaller
+        {
+            return (pThisReg) ? sal_True:
+                     ((pOtherReg) ? sal_False: (this >= &rPos));
+        }
+    }
     return sal_False;
 }
 
 
 sal_Bool SwPosition::operator==(const SwPosition &rPos) const
 {
-    return
-        ( ( nNode == rPos.nNode ) && ( nContent == rPos.nContent ) ?
-            sal_True: sal_False);
+    return (nNode == rPos.nNode)
+        // GetIndexReg may be null for FLY_AT_PARA frame anchor position
+        && (nContent.GetIdxReg() == rPos.nContent.GetIdxReg())
+        && (nContent == rPos.nContent);
 }
 
 
 sal_Bool SwPosition::operator!=(const SwPosition &rPos) const
 {
-    if( nNode != rPos.nNode )
-        return sal_True;
-    return ( nContent != rPos.nContent );
+    return (nNode != rPos.nNode)
+        // GetIndexReg may be null for FLY_AT_PARA frame anchor position
+        || (nContent.GetIdxReg() != rPos.nContent.GetIdxReg())
+        || (nContent != rPos.nContent);
 }
 
 SwDoc * SwPosition::GetDoc() const
commit b1c56d12fe5cf0071c22c6ff80049b5fbe48920a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Nov 28 17:13:35 2011 +0100

    SwFmtAchor: bit of style cleanup

diff --git a/sw/inc/fmtanchr.hxx b/sw/inc/fmtanchr.hxx
index 6595991..fbceba4 100644
--- a/sw/inc/fmtanchr.hxx
+++ b/sw/inc/fmtanchr.hxx
@@ -34,6 +34,9 @@
 #include <format.hxx>
 #include <svl/poolitem.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
+
 struct SwPosition;
 class IntlWrapper;
 #define IVER_FMTANCHOR_LONGIDX ((sal_uInt16)1)
@@ -41,7 +44,7 @@ class IntlWrapper;
 // FlyAnchors
 class SW_DLLPUBLIC SwFmtAnchor: public SfxPoolItem
 {
-    SwPosition *pCntntAnchor;   // 0 for page-bound frames.
+    ::boost::scoped_ptr<SwPosition> m_pCntntAnchor; // 0 for page-bound frames.
                                 // Index for paragraph-bound frames.
                                 // Position for character-bound frames.
     RndStdIds  nAnchorId;
@@ -72,7 +75,7 @@ public:
 
     RndStdIds GetAnchorId() const { return nAnchorId; }
     sal_uInt16 GetPageNum() const { return nPageNum; }
-    const SwPosition *GetCntntAnchor() const { return pCntntAnchor; }
+    const SwPosition *GetCntntAnchor() const { return m_pCntntAnchor.get(); }
     // #i28701#
     sal_uInt32 GetOrder() const;
 
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index a1e2f45..70fb124 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -1476,7 +1476,6 @@ bool SwFmtHoriOrient::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
 
 SwFmtAnchor::SwFmtAnchor( RndStdIds nRnd, sal_uInt16 nPage )
     : SfxPoolItem( RES_ANCHOR ),
-    pCntntAnchor( 0 ),
     nAnchorId( nRnd ),
     nPageNum( nPage ),
     // OD 2004-05-05 #i28701# - get always new increased order number
@@ -1484,30 +1483,28 @@ SwFmtAnchor::SwFmtAnchor( RndStdIds nRnd, sal_uInt16 nPage )
 {}
 
 SwFmtAnchor::SwFmtAnchor( const SwFmtAnchor &rCpy )
-    : SfxPoolItem( RES_ANCHOR ),
-    nAnchorId( rCpy.GetAnchorId() ),
-    nPageNum( rCpy.GetPageNum() ),
+    : SfxPoolItem( RES_ANCHOR )
+    , m_pCntntAnchor( (rCpy.GetCntntAnchor())
+            ?  new SwPosition( *rCpy.GetCntntAnchor() ) : 0 )
+    , nAnchorId( rCpy.GetAnchorId() )
+    , nPageNum( rCpy.GetPageNum() )
     // OD 2004-05-05 #i28701# - get always new increased order number
-    mnOrder( ++mnOrderCounter )
+    , mnOrder( ++mnOrderCounter )
 {
-    pCntntAnchor = rCpy.GetCntntAnchor() ?
-                        new SwPosition( *rCpy.GetCntntAnchor() ) : 0;
 }
 
- SwFmtAnchor::~SwFmtAnchor()
+SwFmtAnchor::~SwFmtAnchor()
 {
-    delete pCntntAnchor;
 }
 
 void SwFmtAnchor::SetAnchor( const SwPosition *pPos )
 {
-    delete pCntntAnchor;
-    pCntntAnchor = pPos ? new SwPosition( *pPos ) : 0;
-        //AM Absatz gebundene Flys sollten nie in den Absatz hineinzeigen.
-    if (pCntntAnchor &&
+    m_pCntntAnchor .reset( (pPos) ? new SwPosition( *pPos ) : 0 );
+    // Flys anchored AT paragraph should not point into the paragraph content
+    if (m_pCntntAnchor &&
         ((FLY_AT_PARA == nAnchorId) || (FLY_AT_FLY == nAnchorId)))
     {
-        pCntntAnchor->nContent.Assign( 0, 0 );
+        m_pCntntAnchor->nContent.Assign( 0, 0 );
     }
 }
 
@@ -1518,24 +1515,24 @@ SwFmtAnchor& SwFmtAnchor::operator=(const SwFmtAnchor& rAnchor)
     // OD 2004-05-05 #i28701# - get always new increased order number
     mnOrder = ++mnOrderCounter;
 
-    delete pCntntAnchor;
-    pCntntAnchor = rAnchor.pCntntAnchor ?
-                                    new SwPosition(*(rAnchor.pCntntAnchor)) : 0;
+    m_pCntntAnchor.reset( (rAnchor.GetCntntAnchor())
+        ? new SwPosition(*(rAnchor.GetCntntAnchor()))
+        : 0 );
     return *this;
 }
 
 int  SwFmtAnchor::operator==( const SfxPoolItem& rAttr ) const
 {
     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
+    SwFmtAnchor const& rFmtAnchor(static_cast<SwFmtAnchor const&>(rAttr));
     // OD 2004-05-05 #i28701# - Note: <mnOrder> hasn't to be considered.
-    return ( nAnchorId == ((SwFmtAnchor&)rAttr).GetAnchorId() &&
-             nPageNum == ((SwFmtAnchor&)rAttr).GetPageNum()   &&
-                    //Anker vergleichen. Entweder zeigen beide auf das gleiche
-                    //Attribut bzw. sind 0 oder die SwPosition* sind beide
-                    //gueltig und die SwPositions sind gleich.
-             (pCntntAnchor == ((SwFmtAnchor&)rAttr).GetCntntAnchor() ||
-              (pCntntAnchor && ((SwFmtAnchor&)rAttr).GetCntntAnchor() &&
-               *pCntntAnchor == *((SwFmtAnchor&)rAttr).GetCntntAnchor())));
+    return ( nAnchorId == rFmtAnchor.GetAnchorId() &&
+             nPageNum == rFmtAnchor.GetPageNum()   &&
+                // compare anchor: either both do not point into a textnode or
+                // both do (valid m_pCntntAnchor) and the positions are equal
+             ((m_pCntntAnchor.get() == rFmtAnchor.m_pCntntAnchor.get()) ||
+              (m_pCntntAnchor && rFmtAnchor.GetCntntAnchor() &&
+               (*m_pCntntAnchor == *rFmtAnchor.GetCntntAnchor()))));
 }
 
 SfxPoolItem*  SwFmtAnchor::Clone( SfxItemPool* ) const
@@ -1587,9 +1584,9 @@ bool SwFmtAnchor::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
         break;
         case MID_ANCHOR_ANCHORFRAME:
         {
-            if(pCntntAnchor && FLY_AT_FLY == nAnchorId)
+            if (m_pCntntAnchor && FLY_AT_FLY == nAnchorId)
             {
-                SwFrmFmt* pFmt = pCntntAnchor->nNode.GetNode().GetFlyFmt();
+                SwFrmFmt* pFmt = m_pCntntAnchor->nNode.GetNode().GetFlyFmt();
                 if(pFmt)
                 {
                     uno::Reference<container::XNamed> xNamed = SwXFrames::GetObject( *pFmt, FLYCNTTYPE_FRM );
@@ -1628,8 +1625,7 @@ bool SwFmtAnchor::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
                         // If the anchor type is page and a valid page number
                         // has been set, the content position isn't required
                         // any longer.
-                        delete pCntntAnchor;
-                        pCntntAnchor = 0;
+                        m_pCntntAnchor.reset();
                     }
                     break;
                 case  text::TextContentAnchorType_AT_FRAME:
@@ -1659,8 +1655,7 @@ bool SwFmtAnchor::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
                     // confuse the layout (frmtool.cxx). However, if the
                     // anchor type is not page, any content position will
                     // be kept.
-                    delete pCntntAnchor;
-                    pCntntAnchor = 0;
+                    m_pCntntAnchor.reset();
                 }
             }
             else


More information about the Libreoffice-commits mailing list