[Libreoffice-commits] .: 20 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Jun 6 10:55:59 PDT 2011


 sc/inc/datauno.hxx                 |    2 
 sc/source/core/data/clipparam.cxx  |    2 
 sc/source/filter/xml/xmldrani.cxx  |   11 +
 sc/source/ui/docshell/autostyl.cxx |   66 +++++++---
 sc/source/ui/unoobj/datauno.cxx    |    5 
 sc/source/ui/view/output.cxx       |   11 +
 sc/source/ui/view/tabcont.cxx      |    2 
 sc/source/ui/view/tabview2.cxx     |  229 +++++++++++++++++++++++++++++++++++++
 8 files changed, 299 insertions(+), 29 deletions(-)

New commits:
commit c6aacca8bf75dfa8c0657c64272a0c031e879ecd
Merge: 97452fd... 3de51ad...
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Jun 6 13:55:04 2011 -0400

    Merge remote branch 'origin/master'

commit 97452fdfff1a486af9e02eb5804679f729a98034
Merge: a0a74cb... 1a19e46...
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Jun 6 13:44:40 2011 -0400

    Merge remote branch 'origin/libreoffice-3-4'
    
    Conflicts:
    	sc/source/core/tool/dbcolect.cxx
    	sc/source/filter/excel/xiname.cxx
    	sc/source/filter/xml/xmldrani.cxx
    	sc/source/ui/view/tabview2.cxx

diff --cc sc/source/filter/xml/xmldrani.cxx
index 5baf226,d0fb4aa..bd75821
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@@ -453,23 -453,6 +453,24 @@@ ScDBData* ScXMLDatabaseRangeContext::Co
      return pData.release();
  }
  
 +namespace {
 +
- void setAutoFilterFlags(ScDocument& rDoc, const ScDBData& rData)
++bool setAutoFilterFlags(ScDocument& rDoc, const ScDBData& rData)
 +{
 +    if (!rData.HasAutoFilter())
-         return;
++        return false;
 +
 +    // Set autofilter flags so that the buttons get displayed.
 +    ScRange aRange;
 +    rData.GetArea(aRange);
 +    rDoc.ApplyFlagsTab(
 +        aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(),
 +        aRange.aStart.Tab(), SC_MF_AUTO);
++    return false;
 +}
 +
 +}
 +
  void ScXMLDatabaseRangeContext::EndElement()
  {
      ScDocument* pDoc = GetScImport().GetDocument();
@@@ -498,8 -487,18 +499,10 @@@
  
          if (pData.get())
          {
-             setAutoFilterFlags(*pDoc, *pData);
-             pDoc->GetDBCollection()->getAnonDBs().insert(pData.release());
 -            if (pData->HasAutoFilter())
 -            {
 -                // Set autofilter flags so that the buttons get displayed.
 -                ScRange aRange;
 -                pData->GetArea(aRange);
 -                pDoc->ApplyFlagsTab(
 -                    aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(),
 -                    aRange.aStart.Tab(), SC_MF_AUTO);
++            if (setAutoFilterFlags(*pDoc, *pData))
+                 pDoc->SetAnonymousDBData(aRange.aStart.Tab(), pData.release());
 -            }
+             else
 -                pDoc->GetDBCollection()->insertAnonRange(pData.release());
++                pDoc->GetDBCollection()->getAnonDBs().insert(pData.release());
          }
          return;
      }
commit 1a19e46f2ae558370a3986af38bc76391abadf14
Author: Andras Timar <atimar at suse.com>
Date:   Mon Jun 6 14:27:31 2011 +0200

    fix a dialog layout problem - fdo#37985
    
    Signed-off-by: Tor Lillqvist <tlillqvist at novell.com>

diff --git a/sc/source/ui/dbgui/dapitype.src b/sc/source/ui/dbgui/dapitype.src
index 283106c..b9c636b 100644
--- a/sc/source/ui/dbgui/dapitype.src
+++ b/sc/source/ui/dbgui/dapitype.src
@@ -74,13 +74,13 @@ ModalDialog RID_SCDLG_DAPITYPE
     RadioButton BTN_NAMED_RANGE
     {
         Pos = MAP_APPFONT ( 12 , 32 ) ;
-        Size = MAP_APPFONT ( 70 , 10 ) ;
+        Size = MAP_APPFONT ( 80 , 10 ) ;
         TabStop = TRUE ;
         Text [ en-US ] = "~Named range";
     };
     ListBox LB_NAMED_RANGE
     {
-        Pos = MAP_APPFONT ( 90 , 31 ) ;
+        Pos = MAP_APPFONT ( 100 , 31 ) ;
         Size = MAP_APPFONT ( 70 , 10 ) ;
         TabStop = TRUE ;
         DropDown = TRUE ;
commit 10e0290bb5dec02584c287f5a147d613c653cb04
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri May 27 23:22:28 2011 +0000

    fdo#34214: Fixed selection by arrow keys around merged cells.
    
    Signed-off-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index f9429ec..e0a808d 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -684,6 +684,152 @@ void moveCursorByProtRule(
     }
 }
 
+bool checkBoundary(SCCOL& rCol, SCROW& rRow)
+{
+    bool bGood = true;
+    if (rCol < 0)
+    {
+        rCol = 0;
+        bGood = false;
+    }
+    else if (rCol > MAXCOL)
+    {
+        rCol = MAXCOL;
+        bGood = false;
+    }
+
+    if (rRow < 0)
+    {
+        rRow = 0;
+        bGood = false;
+    }
+    else if (rRow > MAXROW)
+    {
+        rRow = MAXROW;
+        bGood = false;
+    }
+    return bGood;
+}
+
+void moveCursorByMergedCell(
+    SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab,
+    ScDocument* pDoc, const ScViewData& rViewData)
+{
+    SCCOL nOrigX = rViewData.GetCurX();
+    SCROW nOrigY = rViewData.GetCurY();
+
+    ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
+    bool bSelectLocked = true;
+    bool bSelectUnlocked = true;
+    if (pTabProtection && pTabProtection->isProtected())
+    {
+        bSelectLocked   = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+        bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+    }
+
+    const ScMergeAttr* pMergeAttr = static_cast<const ScMergeAttr*>(
+        pDoc->GetAttr(nOrigX, nOrigY, nTab, ATTR_MERGE));
+
+    bool bOriginMerged = false;
+    SCsCOL nColSpan = 1;
+    SCsROW nRowSpan = 1;
+    if (pMergeAttr && pMergeAttr->IsMerged())
+    {
+        nColSpan = pMergeAttr->GetColMerge();
+        nRowSpan = pMergeAttr->GetRowMerge();
+        bOriginMerged = true;
+    }
+
+    if (nMovX > 0)
+    {
+        SCCOL nOld = rCol;
+        if (bOriginMerged)
+        {
+            // Original cell is merged.  Push the block end outside the merged region.
+            if (nOrigX < MAXCOL && nOrigX < rCol && rCol <= nOrigX + nColSpan - 1)
+                rCol = nOrigX + nColSpan;
+        }
+        else
+        {
+            pDoc->SkipOverlapped(rCol, rRow, nTab);
+        }
+
+        if (nOld < rCol)
+        {
+            // The block end has moved.  Check the protection setting and move back if needed.
+            checkBoundary(rCol, rRow);
+            if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                --rCol;
+        }
+    }
+    if (nMovX < 0)
+    {
+        SCCOL nOld = rCol;
+        if (bOriginMerged)
+        {
+            if (nOrigX > 0 && nOrigX <= rCol && rCol < nOrigX + nColSpan - 1)
+                // Block end is still within the merged region.  Push it outside.
+                rCol = nOrigX - 1;
+        }
+        else
+        {
+            pDoc->SkipOverlapped(rCol, rRow, nTab);
+        }
+
+        if (nOld > rCol)
+        {
+            // The block end has moved.  Check the protection setting and move back if needed.
+            checkBoundary(rCol, rRow);
+            if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                ++rCol;
+        }
+    }
+    if (nMovY > 0)
+    {
+        SCROW nOld = rRow;
+        if (bOriginMerged)
+        {
+            // Original cell is merged.  Push the block end outside the merged region.
+            if (nOrigY < MAXROW && nOrigY < rRow && rRow <= nOrigY + nRowSpan - 1)
+                rRow = nOrigY + nRowSpan;
+        }
+        else
+        {
+            pDoc->SkipOverlapped(rCol, rRow, nTab);
+        }
+
+        if (nOld < rRow)
+        {
+            // The block end has moved.  Check the protection setting and move back if needed.
+            checkBoundary(rCol, rRow);
+            if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                --rRow;
+        }
+    }
+    if (nMovY < 0)
+    {
+        SCROW nOld = rRow;
+        if (bOriginMerged)
+        {
+            if (nOrigY > 0 && nOrigY <= rRow && rRow < nOrigY + nRowSpan - 1)
+                // Block end is still within the merged region.  Push it outside.
+                rRow = nOrigY - 1;
+        }
+        else
+        {
+            pDoc->SkipOverlapped(rCol, rRow, nTab);
+        }
+
+        if (nOld > rRow)
+        {
+            // The block end has moved.  Check the protection setting and move back if needed.
+            checkBoundary(rCol, rRow);
+            if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
+                ++rRow;
+        }
+    }
+}
+
 }
 
 void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
@@ -718,6 +864,7 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
         }
 
         moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, pDoc);
+        checkBoundary(nNewX, nNewY);
 
         if (nMovX)
         {
@@ -728,6 +875,8 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
                     ++nTempX;
                 else
                     --nTempX;
+                if (!checkBoundary(nTempX, nNewY))
+                    break;
             }
             if (isCellQualified(pDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked))
                 nNewX = nTempX;
@@ -742,6 +891,8 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
                     ++nTempY;
                 else
                     --nTempY;
+                if (!checkBoundary(nNewX, nTempY))
+                    break;
             }
             if (isCellQualified(pDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked))
                 nNewY = nTempY;
@@ -756,23 +907,19 @@ void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
         // normal selection mode
 
         SCTAB nTab = aViewData.GetTabNo();
+        SCCOL nOrigX = aViewData.GetCurX();
+        SCROW nOrigY = aViewData.GetCurY();
+
+        // Note that the origin position *never* moves during selection.
 
         if (!IsBlockMode())
-            InitBlockMode(aViewData.GetCurX(), aViewData.GetCurY(), nTab, true);
+            InitBlockMode(nOrigX, nOrigY, nTab, true);
 
         moveCursorByProtRule(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc);
+        checkBoundary(nBlockEndX, nBlockEndY);
+        moveCursorByMergedCell(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc, aViewData);
+        checkBoundary(nBlockEndX, nBlockEndY);
 
-        if (nBlockEndX < 0)
-            nBlockEndX = 0;
-        else if (nBlockEndX > MAXCOL)
-            nBlockEndX = MAXCOL;
-
-        if (nBlockEndY < 0)
-            nBlockEndY = 0;
-        else if (nBlockEndY > MAXROW)
-            nBlockEndY = MAXROW;
-
-        pDoc->SkipOverlapped(nBlockEndX, nBlockEndY, nTab);
         MarkCursor(nBlockEndX, nBlockEndY, nTab, false, false, true);
 
         // Check if the entire row(s) or column(s) are selected.
commit dbabcc82389f4a443334e03dd92331840b7597c8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue May 31 05:35:42 2011 +0200

    fix for fdo#37772: Insert sheets in a protected spreadsheet document

diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index c080b64..c46bf6a 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -183,6 +183,8 @@ void ScTabControl::MouseButtonUp( const MouseEvent& rMEvt )
     {
         // Insert a new sheet at the right end, with default name.
         ScDocument* pDoc = pViewData->GetDocument();
+        if (!pDoc->IsDocEditable())
+            return;
         String aName;
         pDoc->CreateValidTabName(aName);
         SCTAB nTabCount = pDoc->GetTableCount();
commit de2ca4df263d210773931952601ce29c6b232159
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu May 26 15:45:05 2011 -0400

    fdo#37356: Fix broken transposition during paste of cell range.
    
    Refactoring of ScRangeList accidentally skipped the first element during
    for loop.
    
    Signed-off-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/data/clipparam.cxx b/sc/source/core/data/clipparam.cxx
index 7804bcc..bdef09c 100644
--- a/sc/source/core/data/clipparam.cxx
+++ b/sc/source/core/data/clipparam.cxx
@@ -175,7 +175,7 @@ void ScClipParam::transpose()
         SCCOL nColOrigin = p->aStart.Col();
         SCROW nRowOrigin = p->aStart.Row();
 
-        for ( size_t i = 1, n = maRanges.size(); i < n; ++i )
+        for ( size_t i = 0, n = maRanges.size(); i < n; ++i )
         {
             p = maRanges[ i ];
             SCCOL nColDelta = p->aStart.Col() - nColOrigin;
commit 10feb42cc16b9a715e1d631941875f9aab17ae37
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu May 26 00:05:32 2011 -0400

    fdo#37458: Prevent crash on named range deletion.
    
    Simple NULL pointer checks will prevent crashes....

diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 85f02e2..472c451 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -469,8 +469,11 @@ void ScDPObject::CreateObjects()
         {
             DBG_ASSERT( !pServDesc, "DPSource could not be created" );
             ScDPTableData* pData = GetTableData();
-            ScDPSource* pSource = new ScDPSource( pData );
-            xSource = pSource;
+            if (pData)
+            {
+                ScDPSource* pSource = new ScDPSource( pData );
+                xSource = pSource;
+            }
         }
 
         if (pSaveData)
@@ -1848,6 +1851,9 @@ sal_Bool ScDPObject::FillOldParam(ScPivotParam& rParam) const
 {
     ((ScDPObject*)this)->CreateObjects();		// xSource is needed for field numbers
 
+    if (!xSource.is())
+        return false;
+
     rParam.nCol = aOutRange.aStart.Col();
     rParam.nRow = aOutRange.aStart.Row();
     rParam.nTab = aOutRange.aStart.Tab();
@@ -1941,6 +1947,8 @@ sal_Bool ScDPObject::FillLabelData(ScPivotParam& rParam)
     rParam.maLabelArray.clear();
 
     ((ScDPObject*)this)->CreateObjects();
+    if (!xSource.is())
+        return false;
 
     uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
     uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( xDimsName );
commit 17ec3ef031415fa4ec1a80b9d2415c84e209034d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed May 25 03:32:09 2011 +0200

    fix for fdo#37548: InsertNames->InsertAll doesn't insert anything
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index a0e5355..b752383 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4721,7 +4721,7 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
     for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
     {
         const ScRangeData& r = *itr;
-        if (r.HasType(RT_DATABASE && !r.HasType(RT_SHARED)))
+        if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED))
             ++nValidCount;
     }
 
commit 226c30f2a6cdb5be63b62f0d65577bf6550f3fa8
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue May 24 15:49:55 2011 -0400

    fdo#37520: Don't cache the array size but query it dynamically.
    
    The size of the array may change during the loop, so we need to always
    query it dynamically via size() instead of caching it at the beginning
    of the loop.
    
    Signed-off-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 0a92d63..572472e 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -260,7 +260,9 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList )
     }
     bool bJoinedInput = false;
 
-    for ( size_t i = 0, nRanges = maRanges.size(); i < nRanges && pOver; ++i )
+    // We need to query the size of the container dynamically since its size
+    // may change during the loop.
+    for ( size_t i = 0; i < maRanges.size() && pOver; ++i )
     {
         ScRange* p = maRanges[i];
         if ( p == pOver )
commit 465a643dfcd49d79f434c4959ead7b8bda39d88c
Author: Katarina Machalkova <kmachalkova at suse.cz>
Date:   Tue May 24 17:23:35 2011 +0200

    fdo#35345: Query the sheet for the presence of anonymous DB ranges
    
    ... and for autofilters || query params in those. This avoids
    overwriting the hidden cells in drag-fill operation
    
    Signed-off-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx
index 635ab5a..39b6575 100644
--- a/sc/source/core/tool/dbcolect.cxx
+++ b/sc/source/core/tool/dbcolect.cxx
@@ -827,7 +827,8 @@ ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCO
 
 ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const
 {
-    ScDBData* pDataEmpty = NULL;
+    ScDBData* pAnonData = pDoc->GetAnonymousDBData(nTab);
+
     if (pItems)
     {
         for (sal_uInt16 i = 0; i < nCount; i++)
@@ -843,7 +844,13 @@ ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const
         }
     }
 
-    return pDataEmpty;
+    if (pAnonData)
+    {
+        if ( pAnonData->HasAutoFilter() || pAnonData->HasQueryParam())
+            return pAnonData;
+    }
+
+    return NULL;
 }
 
 sal_Bool ScDBCollection::SearchName( const String& rName, sal_uInt16& rIndex ) const
commit 345a5ab62a91822086392c9b2e196a2cc66e9bcc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun May 22 23:35:50 2011 +0200

    fix for fdo#37429 crash when copy/paste table from writer to calc
    
    Signed-off-by: Tor Lillqvist <tlillqvist at novell.com>

diff --git a/sc/source/filter/rtf/rtfparse.cxx b/sc/source/filter/rtf/rtfparse.cxx
index 44d0498..1243138 100644
--- a/sc/source/filter/rtf/rtfparse.cxx
+++ b/sc/source/filter/rtf/rtfparse.cxx
@@ -299,7 +299,7 @@ void ScRTFParser::ProcToken( ImportInfo* pInfo )
     {
         case RTF_TROWD:			// denotes table row defauls, before RTF_CELLX
         {
-            if ( (pD = &(pDefaultList->back())) != 0 )
+            if ( !pDefaultList->empty() && (pD = &(pDefaultList->back())) != 0 )
                 nLastWidth = pD->nTwips;
             nColCnt = 0;
             pDefaultList->clear();
commit 0934b98ccbd075f22a0cb6d2e85d475ff110aa14
Author: Andras Timar <atimar at suse.com>
Date:   Fri May 20 22:21:40 2011 +0200

    fdo#37418, fix a layout problem in Export text (CSV) dialog
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/sc/source/ui/dbgui/imoptdlg.src b/sc/source/ui/dbgui/imoptdlg.src
index 8f68395..f095705 100644
--- a/sc/source/ui/dbgui/imoptdlg.src
+++ b/sc/source/ui/dbgui/imoptdlg.src
@@ -111,7 +111,7 @@ ModalDialog RID_SCDLG_IMPORTOPT
     CheckBox CB_QUOTEALL
     {
         HelpID = "sc:CheckBox:RID_SCDLG_IMPORTOPT:CB_QUOTEALL";
-        Pos = MAP_APPFONT( 20, 64 );
+        Pos = MAP_APPFONT( 12, 79 );
         Size = MAP_APPFONT( 164, 10 );
         Hide = TRUE;
         Text [ en-US ] = "~Quote all text cells";
commit dd3f3f575584a4fd71375b156a1f16ef7afb0e47
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri May 20 06:11:07 2011 +0200

    update sheet local db data when sheets are inserted/deleted
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 551ecbf..2927aa0 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1402,7 +1402,12 @@ void ScTable::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY )
 
 void ScTable::UpdateInsertTab(SCTAB nTable)
 {
-    if (nTab >= nTable) nTab++;
+    if (nTab >= nTable)
+    {
+        nTab++;
+        if (pDBDataNoName)
+            pDBDataNoName->UpdateMoveTab(nTab - 1 ,nTab);
+    }
     for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].UpdateInsertTab(nTable);
 
     if (IsStreamValid())
@@ -1411,7 +1416,12 @@ void ScTable::UpdateInsertTab(SCTAB nTable)
 
 void ScTable::UpdateDeleteTab( SCTAB nTable, sal_Bool bIsMove, ScTable* pRefUndo )
 {
-    if (nTab > nTable) nTab--;
+    if (nTab > nTable)
+    {
+        nTab--;
+        if (pDBDataNoName)
+            pDBDataNoName->UpdateMoveTab(nTab + 1,nTab);
+    }
 
     SCCOL i;
     if (pRefUndo)
commit e1043677355a7ce54de4e177285720560b8c5653
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri May 20 05:42:28 2011 +0200

    fix for fdo#37323: Correct autofilter import from ODS.
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index 7e91218..d0fb4aa 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -466,21 +466,17 @@ void ScXMLDatabaseRangeContext::EndElement()
 
         if (pData.get())
         {
-            // Infer sheet index from the name.
-            OUString aStrNum = sDatabaseRangeName.copy(aName.getLength());
-            SCTAB nTab = static_cast<SCTAB>(aStrNum.toInt32());
-
+            ScRange aRange;
+            pData->GetArea(aRange);
             if (pData->HasAutoFilter())
             {
                 // Set autofilter flags so that the buttons get displayed.
-                ScRange aRange;
-                pData->GetArea(aRange);
                 pDoc->ApplyFlagsTab(
                     aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(),
                     aRange.aStart.Tab(), SC_MF_AUTO);
             }
 
-            pDoc->SetAnonymousDBData(nTab, pData.release());
+            pDoc->SetAnonymousDBData(aRange.aStart.Tab(), pData.release());
         }
         return;
     }
@@ -499,9 +495,10 @@ void ScXMLDatabaseRangeContext::EndElement()
                 pDoc->ApplyFlagsTab(
                     aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aStart.Row(),
                     aRange.aStart.Tab(), SC_MF_AUTO);
+                pDoc->SetAnonymousDBData(aRange.aStart.Tab(), pData.release());
             }
-
-            pDoc->GetDBCollection()->insertAnonRange(pData.release());
+            else
+                pDoc->GetDBCollection()->insertAnonRange(pData.release());
         }
         return;
     }
commit b79294b824506dd78a7e0e4bbf6250343a618a26
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu May 12 16:21:15 2011 -0400

    Let's not change the signature of UNO call & prefer static_cast.

diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index 7d43e4f..423ab5f 100644
--- a/sc/inc/datauno.hxx
+++ b/sc/inc/datauno.hxx
@@ -683,7 +683,7 @@ public:
     virtual void SAL_CALL setByTable( const ::com::sun::star::table::CellRangeAddress& aRange )
                                 throw(::com::sun::star::uno::RuntimeException,
                                       ::com::sun::star::lang::IndexOutOfBoundsException );
-    virtual com::sun::star::uno::Any SAL_CALL getByTable( const sal_Int32 nTab )
+    virtual com::sun::star::uno::Any SAL_CALL getByTable( sal_Int32 nTab )
                                 throw(::com::sun::star::uno::RuntimeException,
                                 ::com::sun::star::lang::IndexOutOfBoundsException,
                                 ::com::sun::star::container::NoSuchElementException );
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 860db1b..f192242 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -2419,7 +2419,7 @@ void ScUnnamedDatabaseRangesObj::setByTable( const table::CellRangeAddress& aRan
         throw uno::RuntimeException();		// no other exceptions specified
 }
 
-uno::Any ScUnnamedDatabaseRangesObj::getByTable( const sal_Int32 nTab )
+uno::Any ScUnnamedDatabaseRangesObj::getByTable( sal_Int32 nTab )
                                 throw(uno::RuntimeException,
                                     lang::IndexOutOfBoundsException,
                                     container::NoSuchElementException)
@@ -2429,7 +2429,8 @@ uno::Any ScUnnamedDatabaseRangesObj::getByTable( const sal_Int32 nTab )
     {
         if ( pDocShell->GetDocument()->GetTableCount() <= nTab )
             throw lang::IndexOutOfBoundsException();
-        uno::Reference<sheet::XDatabaseRange> xRange( new ScDatabaseRangeObj(pDocShell, (SCTAB) nTab) );
+        uno::Reference<sheet::XDatabaseRange> xRange(
+            new ScDatabaseRangeObj(pDocShell, static_cast<SCTAB>(nTab)));
         if (xRange.is())
             return uno::makeAny(xRange);
         else
commit b7a805c683a1143f63fa2bac88a8ae2ae95f6875
Author: Regina Henschel <rb.henschel at t-online.de>
Date:   Thu May 19 15:55:13 2011 -0400

    fdo#37326: Sign number must be either 1 or -1, never 0.
    
    This fixes incorrect result with LINEST cell function.
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index bc1348c..7f005e2 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1978,14 +1978,10 @@ double lcl_TGetColumnSumProduct(ScMatrixRef pMatA, SCSIZE nRa,
     return fResult;
 }
 
+// no mathematical signum, but used to switch between adding and subtracting
 double lcl_GetSign(double fValue)
 {
-    if (fValue < 0.0)
-        return -1.0;
-    else if (fValue > 0.0)
-        return 1.0;
-    else
-        return 0.0;
+    return (fValue >= 0.0 ? 1.0 : -1.0 );
 }
 
 /* Calculates a QR decomposition with Householder reflection.
commit b1ad6ec86661730b5dcd787bc7a0b5337a3c6eb7
Author: Katarina Machalkova <kmachalkova at suse.cz>
Date:   Thu May 19 16:21:52 2011 +0200

    Fix for fdo#37322 (binary import crash)
    
    Avoid retrieving defined name items on positions >= maNameList.size()
    (boost::ptr_vector doesn't like it)
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>
    Signed-off-by: Noel Power <noel.power at novell.com>

diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx
index 15bf618..90be4dc 100644
--- a/sc/source/filter/excel/xiname.cxx
+++ b/sc/source/filter/excel/xiname.cxx
@@ -271,7 +271,7 @@ const XclImpName* XclImpNameManager::FindName( const String& rXclName, SCTAB nSc
 const XclImpName* XclImpNameManager::GetName( sal_uInt16 nXclNameIdx ) const
 {
     DBG_ASSERT( nXclNameIdx > 0, "XclImpNameManager::GetName - index must be >0" );
-    return &(maNameList.at( nXclNameIdx - 1 ));
+    return ( nXclNameIdx >= maNameList.size() ) ? NULL : &(maNameList.at( nXclNameIdx - 1 ));
 }
 
 // ============================================================================
commit 70af08e849a93d56915b7abe14537facf1022a6a
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed May 18 12:04:28 2011 +0200

    fdo#36688: Fixed undisplayed calc page and header / footer borders
    
    When displaying the page, header and footer borders, calc uses a fake
    ScDocument with no drawing page. Create a new SdrPage if none can be
    fetched from the ScDocument to create the primitive processor.
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index f37a2c8..22b5d24 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -52,6 +52,7 @@
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <svx/sdr/contact/objectcontacttools.hxx>
 #include <svx/unoapi.hxx>
+#include <svx/svdpage.hxx>
 
 #include "output.hxx"
 #include "document.hxx"
@@ -1634,17 +1635,19 @@ void ScOutputData::DrawRotatedFrame( const Color* pForceColor )
 
 drawinglayer::processor2d::BaseProcessor2D* ScOutputData::CreateProcessor2D( )
 {
+    SdrModel aModel;
+    SdrPage aSdrPage( aModel );
+
     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
-    if (!pDrawLayer)
-        return NULL;
+    if ( pDrawLayer )
+        aSdrPage = *pDrawLayer->GetPage( static_cast< sal_uInt16 >( nTab ) );
 
     basegfx::B2DRange aViewRange;
-    SdrPage *pDrawPage = pDrawLayer->GetPage( static_cast< sal_uInt16 >( nTab ) );
     const drawinglayer::geometry::ViewInformation2D aNewViewInfos(
             basegfx::B2DHomMatrix(  ),
             pDev->GetViewTransformation(),
             aViewRange,
-            GetXDrawPageForSdrPage( pDrawPage ),
+            GetXDrawPageForSdrPage( &aSdrPage ),
             0.0,
             uno::Sequence< beans::PropertyValue >() );
 
commit d74b904a233a22c0ee81fd11f65d6d4b9319357a
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue May 17 23:17:10 2011 -0430

    Fix index out of bounds in ScTableConditionalFormat.
    
    Signed-off-by: Kohei Yoshida <kyoshida at novell.com>

diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx
index e88369e..5c37c53 100644
--- a/sc/source/ui/unoobj/fmtuno.cxx
+++ b/sc/source/ui/unoobj/fmtuno.cxx
@@ -286,7 +286,7 @@ void ScTableConditionalFormat::AddEntry_Impl(const ScCondFormatEntryItem& aEntry
 
 ScTableConditionalEntry* ScTableConditionalFormat::GetObjectByIndex_Impl(sal_uInt16 nIndex) const
 {
-    return aEntries[nIndex];
+    return nIndex < aEntries.size() ? aEntries[nIndex] : NULL;
 }
 
 void SAL_CALL ScTableConditionalFormat::addNew(
commit 7a249586c0fd056f7fc6919cdc3d1d51034f2425
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue May 17 11:33:17 2011 -0400

    fdo#37226: Use real function objects with standard algorithms.
    
    This fixes a crasher, and also some incorrect usage of standard
    algorithms, where boolean values were passed which end up doing
    things that the original author probably never intended.

diff --git a/sc/source/ui/docshell/autostyl.cxx b/sc/source/ui/docshell/autostyl.cxx
index d05676e..10773c4 100644
--- a/sc/source/ui/docshell/autostyl.cxx
+++ b/sc/source/ui/docshell/autostyl.cxx
@@ -64,6 +64,34 @@ inline sal_uLong TimeNow()			// Sekunden
     return (sal_uLong) time(0);
 }
 
+namespace {
+
+class FindByRange : public ::std::unary_function<ScAutoStyleData, bool>
+{
+    ScRange maRange;
+public:
+    FindByRange(const ScRange& r) : maRange(r) {}
+    bool operator() (const ScAutoStyleData& rData) const { return rData.aRange == maRange; }
+};
+
+class FindByTimeout : public ::std::unary_function<ScAutoStyleData, bool>
+{
+    sal_uLong mnTimeout;
+public:
+    FindByTimeout(sal_uLong n) : mnTimeout(n) {}
+    bool operator() (const ScAutoStyleData& rData) const { return rData.nTimeout >= mnTimeout; }
+};
+
+struct FindNonZeroTimeout : public ::std::unary_function<ScAutoStyleData, bool>
+{
+    bool operator() (const ScAutoStyleData& rData) const
+    {
+        return rData.nTimeout != 0;
+    }
+};
+
+}
+
 ScAutoStyleList::ScAutoStyleList(ScDocShell* pShell) :
     pDocSh( pShell )
 {
@@ -108,8 +136,12 @@ void ScAutoStyleList::AddEntry( sal_uLong nTimeout, const ScRange& rRange, const
     aTimer.Stop();
     sal_uLong nNow = TimeNow();
 
-    aEntries.erase(std::remove_if(aEntries.begin(),aEntries.end(),
-                                  boost::bind(&ScAutoStyleData::aRange,_1) == rRange));
+    // Remove the first item with the same range.
+    ::boost::ptr_vector<ScAutoStyleData>::iterator itr =
+        ::std::find_if(aEntries.begin(), aEntries.end(), FindByRange(rRange));
+
+    if (itr != aEntries.end())
+        aEntries.erase(itr);
 
     //	Timeouts von allen Eintraegen anpassen
 
@@ -120,8 +152,8 @@ void ScAutoStyleList::AddEntry( sal_uLong nTimeout, const ScRange& rRange, const
     }
 
     //	Einfuege-Position suchen
-    boost::ptr_vector<ScAutoStyleData>::iterator iter = std::find_if(aEntries.begin(),aEntries.end(),
-                                                                     boost::bind(&ScAutoStyleData::nTimeout,_1) >= nTimeout);
+    boost::ptr_vector<ScAutoStyleData>::iterator iter =
+        ::std::find_if(aEntries.begin(), aEntries.end(), FindByTimeout(nTimeout));
 
     aEntries.insert(iter,new ScAutoStyleData(nTimeout,rRange,rStyle));
 
@@ -145,19 +177,19 @@ void ScAutoStyleList::AdjustEntries( sal_uLong nDiff )	// Millisekunden
 
 void ScAutoStyleList::ExecuteEntries()
 {
-    boost::ptr_vector<ScAutoStyleData>::iterator iter;
-    for (iter = aEntries.begin(); iter != aEntries.end();)
+    // Execute and remove all items with timeout == 0 from the begin position
+    // until the first item with non-zero timeout value.
+    ::boost::ptr_vector<ScAutoStyleData>::iterator itr = aEntries.begin(), itrEnd = aEntries.end();
+    for (; itr != itrEnd; ++itr)
     {
-        if (!iter->nTimeout)
-        {
-            pDocSh->DoAutoStyle(iter->aRange,iter->aStyle);
-            iter = aEntries.erase(iter);
-        }
-        else
-        {
-            ++iter;
-        }
+        if (itr->nTimeout)
+            break;
+
+        pDocSh->DoAutoStyle(itr->aRange, itr->aStyle);
     }
+    // At this point itr should be on the first item with non-zero timeout, or
+    // the end position in case all items have timeout == 0.
+    aEntries.erase(aEntries.begin(), itr);
 }
 
 void ScAutoStyleList::ExecuteAllNow()
@@ -174,8 +206,8 @@ void ScAutoStyleList::ExecuteAllNow()
 void ScAutoStyleList::StartTimer( sal_uLong nNow )		// Sekunden
 {
     // ersten Eintrag mit Timeout != 0 suchen
-    boost::ptr_vector<ScAutoStyleData>::iterator iter = std::find_if(aEntries.begin(),aEntries.end(),
-                                                                     boost::bind(&ScAutoStyleData::nTimeout,_1) != static_cast<unsigned>(0));
+    boost::ptr_vector<ScAutoStyleData>::iterator iter =
+        ::std::find_if(aEntries.begin(),aEntries.end(), FindNonZeroTimeout());
 
     if (iter != aEntries.end())
     {


More information about the Libreoffice-commits mailing list