[Libreoffice-commits] core.git: 5 commits - sd/source sfx2/source sw/source

Caolán McNamara caolanm at redhat.com
Mon Mar 24 13:46:20 PDT 2014


 sd/source/ui/slidesorter/controller/SlsSlotManager.cxx |    1 
 sd/source/ui/view/drviewsh.cxx                         |  127 +++++++----------
 sfx2/source/appl/macroloader.cxx                       |   10 -
 sfx2/source/appl/module.cxx                            |    4 
 sw/source/core/text/inftxt.cxx                         |    5 
 5 files changed, 61 insertions(+), 86 deletions(-)

New commits:
commit 2d43fed5870d89a96e3caee7563798bd09a22d6b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 24 20:44:55 2014 +0000

    coverity#704301 Logically dead code
    
    Change-Id: I865979464a2abe51136b577fdb10ec0ae9faf11e

diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx
index 0590b0a..1eefa3f 100644
--- a/sfx2/source/appl/module.cxx
+++ b/sfx2/source/appl/module.cxx
@@ -375,9 +375,7 @@ FieldUnit SfxModule::GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com
     // find the module
     SfxModule const * pModule = GetActiveModule( pViewFrame );
     ENSURE_OR_RETURN( pModule != NULL, "SfxModule::GetModuleFieldUnit: no SfxModule for the given frame!", FUNIT_100TH_MM );
-	if ( pModule )
-		return pModule->GetFieldUnit();
-	return FUNIT_INCH;
+    return pModule->GetFieldUnit();
 }
 
 FieldUnit SfxModule::GetCurrentFieldUnit()
commit c7e314e94b8c41bd05064483ba8e33c6b7fdb9c0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 24 20:42:25 2014 +0000

    coverity#704300 Logically dead code
    
    since af22075998a021d23ec1b266433f239d3200c35d "undoapi: attempt to fix broken
    Undo contexts after executing a script" in 2010
    
    Change-Id: I95f5ebf8960dc82d4a6da1ef186ba524e3cddfd1

diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx
index eb632af..81afe1f 100644
--- a/sfx2/source/appl/macroloader.cxx
+++ b/sfx2/source/appl/macroloader.cxx
@@ -251,16 +251,6 @@ ErrCode SfxMacroLoader::loadMacro( const OUString& rURL, com::sun::star::uno::An
                     // check forbids execution
                     return ERRCODE_IO_ACCESSDENIED;
             }
-            else if ( pDoc && pDoc->GetMedium() )
-            {
-                pDoc->AdjustMacroMode( OUString() );
-                SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
-                SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pMacroExecModeItem, SfxUInt16Item, SID_MACROEXECMODE, false);
-                if ( pUpdateDocItem && pMacroExecModeItem
-                  && pUpdateDocItem->GetValue() == document::UpdateDocMode::NO_UPDATE
-                  && pMacroExecModeItem->GetValue() == document::MacroExecMode::NEVER_EXECUTE )
-                    return ERRCODE_IO_ACCESSDENIED;
-            }
 
             // find BASIC method
             OUString aQualifiedMethod( INetURLObject::decode(aMacro.copy( nHashPos+1 ), INET_HEX_ESCAPE, INetURLObject::DECODE_WITH_CHARSET) );
commit e9cc56517ffbe784e4bca8611b48bbebcc79bcce
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 24 20:35:28 2014 +0000

    coverity#704298 Logically dead code
    
    Change-Id: Ic2f52bb5ec072f11c99f20455e4536bc298b47c7

diff --git a/sd/source/ui/view/drviewsh.cxx b/sd/source/ui/view/drviewsh.cxx
index 7608c00..8164a28 100644
--- a/sd/source/ui/view/drviewsh.cxx
+++ b/sd/source/ui/view/drviewsh.cxx
@@ -67,14 +67,7 @@ void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin)
     // smaller than the visible area, the user-defined zoom was
     // changed. This was decided to be a bug for 6.x, thus I developed a
     // version which instead handles X/Y bigger/smaller and visibility
-    // questions separately. The new behaviour is triggered with the
-    // bZoomAllowed parameter which for old behaviour should be set to
-    // sal_True. I looked at all uses of MakeVisible() in the application
-    // and found no valid reason for really changing the zoom factor, thus I
-    // decided to NOT expand (incompatible) this virtual method to get one
-    // more parameter. If this is wanted in later versions, feel free to add
-    // that bool to the parameter list.
-    sal_Bool bZoomAllowed(sal_False);
+    // questions separately
     Size aLogicSize(rRect.GetSize());
 
     // visible area
@@ -82,87 +75,79 @@ void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin)
     Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel)));
     Size aVisAreaSize(aVisArea.GetSize());
 
-    if(!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) )
+    if (!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) )
     {
         // object is not entirely in visible area
         sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width());
         sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height());
 
-        if(bZoomAllowed && (nFreeSpaceX < 0 || nFreeSpaceY < 0))
+        // allow a mode for move-only visibility without zooming.
+        const sal_Int32 nPercentBorder(30);
+        const Rectangle aInnerRectangle(
+            aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200),
+            aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200),
+            aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200),
+            aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200)
+            );
+        Point aNewPos(aVisArea.TopLeft());
+
+        if(nFreeSpaceX < 0)
         {
-            // object does not fit into visible area -> zoom to object size
-            SetZoomRect(rRect);
-        }
-        else
-        {
-            // allow a mode for move-only visibility without zooming.
-            const sal_Int32 nPercentBorder(30);
-            const Rectangle aInnerRectangle(
-                aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200),
-                aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200),
-                aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200),
-                aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200)
-                );
-            Point aNewPos(aVisArea.TopLeft());
-
-            if(nFreeSpaceX < 0)
+            if(aInnerRectangle.Left() > rRect.Right())
             {
-                if(aInnerRectangle.Left() > rRect.Right())
-                {
-                    // object moves out to the left
-                    aNewPos.X() -= aVisAreaSize.Width() / 2;
-                }
-
-                if(aInnerRectangle.Right() < rRect.Left())
-                {
-                    // object moves out to the right
-                    aNewPos.X() += aVisAreaSize.Width() / 2;
-                }
+                // object moves out to the left
+                aNewPos.X() -= aVisAreaSize.Width() / 2;
             }
-            else
+
+            if(aInnerRectangle.Right() < rRect.Left())
             {
-                if(nFreeSpaceX > rRect.GetWidth())
-                    nFreeSpaceX = rRect.GetWidth();
+                // object moves out to the right
+                aNewPos.X() += aVisAreaSize.Width() / 2;
+            }
+        }
+        else
+        {
+            if(nFreeSpaceX > rRect.GetWidth())
+                nFreeSpaceX = rRect.GetWidth();
 
-                while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width())
-                    aNewPos.X() += nFreeSpaceX;
+            while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width())
+                aNewPos.X() += nFreeSpaceX;
 
-                while(rRect.Left() < aNewPos.X())
-                    aNewPos.X() -= nFreeSpaceX;
-            }
+            while(rRect.Left() < aNewPos.X())
+                aNewPos.X() -= nFreeSpaceX;
+        }
 
-            if(nFreeSpaceY < 0)
+        if(nFreeSpaceY < 0)
+        {
+            if(aInnerRectangle.Top() > rRect.Bottom())
             {
-                if(aInnerRectangle.Top() > rRect.Bottom())
-                {
-                    // object moves out to the top
-                    aNewPos.Y() -= aVisAreaSize.Height() / 2;
-                }
-
-                if(aInnerRectangle.Bottom() < rRect.Top())
-                {
-                    // object moves out to the right
-                    aNewPos.Y() += aVisAreaSize.Height() / 2;
-                }
+                // object moves out to the top
+                aNewPos.Y() -= aVisAreaSize.Height() / 2;
             }
-            else
+
+            if(aInnerRectangle.Bottom() < rRect.Top())
             {
-                if(nFreeSpaceY > rRect.GetHeight())
-                    nFreeSpaceY = rRect.GetHeight();
+                // object moves out to the right
+                aNewPos.Y() += aVisAreaSize.Height() / 2;
+            }
+        }
+        else
+        {
+            if(nFreeSpaceY > rRect.GetHeight())
+                nFreeSpaceY = rRect.GetHeight();
 
-                while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height())
-                    aNewPos.Y() += nFreeSpaceY;
+            while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height())
+                aNewPos.Y() += nFreeSpaceY;
 
-                while(rRect.Top() < aNewPos.Y())
-                    aNewPos.Y() -= nFreeSpaceY;
-            }
+            while(rRect.Top() < aNewPos.Y())
+                aNewPos.Y() -= nFreeSpaceY;
+        }
 
-            // did position change? Does it need to be set?
-            if(aNewPos != aVisArea.TopLeft())
-            {
-                aVisArea.SetPos(aNewPos);
-                SetZoomRect(aVisArea);
-            }
+        // did position change? Does it need to be set?
+        if(aNewPos != aVisArea.TopLeft())
+        {
+            aVisArea.SetPos(aNewPos);
+            SetZoomRect(aVisArea);
         }
     }
 }
commit 68269a8e4def273d5114dcb1dcefada566887091
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 24 20:31:18 2014 +0000

    coverity#704294 Logically dead code
    
    Change-Id: I347b8cfaf6d608e59dec25bb80a96ba862b3fcae

diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
index 2fe886e..68b85dd 100644
--- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
@@ -1306,7 +1306,6 @@ SlideExclusionState GetSlideExclusionState (model::PageEnumeration& rPageSet)
                     eState = MIXED;
                 break;
 
-            case MIXED:
             default:
                 // No need to change anything.
                 break;
commit 7e5e61dc529cf359309d3cdb944760905e5262c5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 24 16:15:28 2014 +0000

    Resolves: fdo#73466 overflow on addition to COMPLETE_STRING
    
    sw/source/core/text/itrcrsr.cxx:1632
    
    SwTxtSizeInfo aSizeInf( GetInfo(), &rText, nCurrStart )
    
    where nCurrStart is non 0 and the hidden 4th argument to SwTxtSizeInfo is
    COMPLETE_STRING
    
    in the past it was STRING_LEN unsigned 16bit 0xFFFF and so in GetMinLen in
    sw/source/core/text/inftxt.cxx adding x to it resulted in x-1 which at least is
    in bounds if selected by the std::min
    
    Change-Id: I78f176804b79fb3c991677adb016579eabcfd56f

diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index fcc2794..ea96e08 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -182,8 +182,11 @@ void ChkOutDev( const SwTxtSizeInfo &rInf )
 
 inline sal_Int32 GetMinLen( const SwTxtSizeInfo &rInf )
 {
+    const sal_Int32 nTxtLen = rInf.GetTxt().getLength();
+    if (rInf.GetLen() == COMPLETE_STRING)
+        return nTxtLen;
     const sal_Int32 nInfLen = rInf.GetIdx() + rInf.GetLen();
-    return std::min( rInf.GetTxt().getLength(), nInfLen );
+    return std::min(nTxtLen, nInfLen);
 }
 
 SwTxtSizeInfo::SwTxtSizeInfo( const SwTxtSizeInfo &rNew )


More information about the Libreoffice-commits mailing list