summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/data/attarray.cxx524
-rw-r--r--sc/source/core/data/bcaslot.cxx22
-rw-r--r--sc/source/core/data/column.cxx202
-rw-r--r--sc/source/core/data/column3.cxx112
-rw-r--r--sc/source/core/data/column4.cxx122
-rw-r--r--sc/source/core/data/compressedarray.cxx200
-rw-r--r--sc/source/core/data/conditio.cxx152
-rw-r--r--sc/source/core/data/dociter.cxx48
-rw-r--r--sc/source/core/data/documen2.cxx134
-rw-r--r--sc/source/core/data/documen3.cxx180
-rw-r--r--sc/source/core/data/documen5.cxx124
-rw-r--r--sc/source/core/data/documen7.cxx48
-rw-r--r--sc/source/core/data/documen8.cxx96
-rw-r--r--sc/source/core/data/documen9.cxx138
-rw-r--r--sc/source/core/data/document.cxx754
-rw-r--r--sc/source/core/data/documentimport.cxx28
-rw-r--r--sc/source/core/data/dpdimsave.cxx30
-rw-r--r--sc/source/core/data/dpobject.cxx186
-rw-r--r--sc/source/core/data/dpoutput.cxx262
-rw-r--r--sc/source/core/data/dpoutputgeometry.cxx30
-rw-r--r--sc/source/core/data/dpsave.cxx28
-rw-r--r--sc/source/core/data/dptabres.cxx514
-rw-r--r--sc/source/core/data/dptabsrc.cxx92
-rw-r--r--sc/source/core/data/drwlayer.cxx180
-rw-r--r--sc/source/core/data/formulacell.cxx212
-rw-r--r--sc/source/core/data/funcdesc.cxx86
-rw-r--r--sc/source/core/data/global.cxx30
-rw-r--r--sc/source/core/data/markarr.cxx168
-rw-r--r--sc/source/core/data/markdata.cxx64
-rw-r--r--sc/source/core/data/markmulti.cxx28
-rw-r--r--sc/source/core/data/patattr.cxx58
-rw-r--r--sc/source/core/data/postit.cxx176
-rw-r--r--sc/source/core/data/stlpool.cxx74
-rw-r--r--sc/source/core/data/subtotalparam.cxx30
-rw-r--r--sc/source/core/data/table1.cxx28
-rw-r--r--sc/source/core/data/table2.cxx296
-rw-r--r--sc/source/core/data/table4.cxx348
-rw-r--r--sc/source/core/data/table5.cxx64
-rw-r--r--sc/source/core/data/table7.cxx30
39 files changed, 2949 insertions, 2949 deletions
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index a4c57ca4f0b0..8174eeb84bbb 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -52,24 +52,24 @@ ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttr
nTab( nNewTab ),
pDocument( pDoc )
{
- if ( nCol != -1 && pDefaultColAttrArray && !pDefaultColAttrArray->mvData.empty())
+ if ( !(nCol != -1 && pDefaultColAttrArray && !pDefaultColAttrArray->mvData.empty()))
+ return;
+
+ ScAddress aAdrStart( nCol, 0, nTab );
+ ScAddress aAdrEnd( nCol, 0, nTab );
+ mvData.resize( pDefaultColAttrArray->mvData.size() );
+ for ( size_t nIdx = 0; nIdx < pDefaultColAttrArray->mvData.size(); ++nIdx )
{
- ScAddress aAdrStart( nCol, 0, nTab );
- ScAddress aAdrEnd( nCol, 0, nTab );
- mvData.resize( pDefaultColAttrArray->mvData.size() );
- for ( size_t nIdx = 0; nIdx < pDefaultColAttrArray->mvData.size(); ++nIdx )
+ mvData[nIdx].nEndRow = pDefaultColAttrArray->mvData[nIdx].nEndRow;
+ ScPatternAttr aNewPattern( *(pDefaultColAttrArray->mvData[nIdx].pPattern) );
+ mvData[nIdx].pPattern = &pDocument->GetPool()->Put( aNewPattern );
+ bool bNumFormatChanged = false;
+ if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
+ mvData[nIdx].pPattern->GetItemSet(), pDocument->GetDefPattern()->GetItemSet() ) )
{
- mvData[nIdx].nEndRow = pDefaultColAttrArray->mvData[nIdx].nEndRow;
- ScPatternAttr aNewPattern( *(pDefaultColAttrArray->mvData[nIdx].pPattern) );
- mvData[nIdx].pPattern = &pDocument->GetPool()->Put( aNewPattern );
- bool bNumFormatChanged = false;
- if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
- mvData[nIdx].pPattern->GetItemSet(), pDocument->GetDefPattern()->GetItemSet() ) )
- {
- aAdrStart.SetRow( nIdx ? mvData[nIdx-1].nEndRow+1 : 0 );
- aAdrEnd.SetRow( mvData[nIdx].nEndRow );
- pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
- }
+ aAdrStart.SetRow( nIdx ? mvData[nIdx-1].nEndRow+1 : 0 );
+ aAdrEnd.SetRow( mvData[nIdx].nEndRow );
+ pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
}
}
}
@@ -625,73 +625,73 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd
void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle )
{
- if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))
+ if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)))
+ return;
+
+ SetDefaultIfNotInit();
+ SCSIZE nPos;
+ SCROW nStart=0;
+ if (!Search( nStartRow, nPos ))
{
- SetDefaultIfNotInit();
- SCSIZE nPos;
- SCROW nStart=0;
- if (!Search( nStartRow, nPos ))
- {
- OSL_FAIL("Search Failure");
- return;
- }
+ OSL_FAIL("Search Failure");
+ return;
+ }
- ScAddress aAdrStart( nCol, 0, nTab );
- ScAddress aAdrEnd ( nCol, 0, nTab );
+ ScAddress aAdrStart( nCol, 0, nTab );
+ ScAddress aAdrEnd ( nCol, 0, nTab );
- do
- {
- const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
- std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*pOldPattern));
- pNewPattern->SetStyleSheet(const_cast<ScStyleSheet*>(&rStyle));
- SCROW nY1 = nStart;
- SCROW nY2 = mvData[nPos].nEndRow;
- nStart = mvData[nPos].nEndRow + 1;
+ do
+ {
+ const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
+ std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*pOldPattern));
+ pNewPattern->SetStyleSheet(const_cast<ScStyleSheet*>(&rStyle));
+ SCROW nY1 = nStart;
+ SCROW nY2 = mvData[nPos].nEndRow;
+ nStart = mvData[nPos].nEndRow + 1;
- if ( *pNewPattern == *pOldPattern )
- {
- // keep the original pattern (might be default)
- // pNewPattern is deleted below
- nPos++;
- }
- else if ( nY1 < nStartRow || nY2 > nEndRow )
- {
- if (nY1 < nStartRow) nY1=nStartRow;
- if (nY2 > nEndRow) nY2=nEndRow;
- SetPatternArea( nY1, nY2, std::move(pNewPattern), true );
- Search( nStart, nPos );
- }
- else
+ if ( *pNewPattern == *pOldPattern )
+ {
+ // keep the original pattern (might be default)
+ // pNewPattern is deleted below
+ nPos++;
+ }
+ else if ( nY1 < nStartRow || nY2 > nEndRow )
+ {
+ if (nY1 < nStartRow) nY1=nStartRow;
+ if (nY2 > nEndRow) nY2=nEndRow;
+ SetPatternArea( nY1, nY2, std::move(pNewPattern), true );
+ Search( nStart, nPos );
+ }
+ else
+ {
+ if ( nCol != -1 )
{
- if ( nCol != -1 )
+ // ensure attributing changes text width of cell; otherwise
+ // there aren't (yet) template format changes
+ const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
+ const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
+
+ bool bNumFormatChanged;
+ if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
+ rNewSet, rOldSet ) )
{
- // ensure attributing changes text width of cell; otherwise
- // there aren't (yet) template format changes
- const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
- const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
-
- bool bNumFormatChanged;
- if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
- rNewSet, rOldSet ) )
- {
- aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 );
- aAdrEnd .SetRow( mvData[nPos].nEndRow );
- pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
- }
+ aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 );
+ aAdrEnd .SetRow( mvData[nPos].nEndRow );
+ pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
}
-
- pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
- mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern);
- if (Concat(nPos))
- Search(nStart, nPos);
- else
- nPos++;
}
- }
- while ((nStart <= nEndRow) && (nPos < mvData.size()));
- pDocument->SetStreamValid(nTab, false);
+ pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
+ mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern);
+ if (Concat(nPos))
+ Search(nStart, nPos);
+ else
+ nPos++;
+ }
}
+ while ((nStart <= nEndRow) && (nPos < mvData.size()));
+
+ pDocument->SetStreamValid(nTab, false);
#if DEBUG_SC_TESTATTRARRAY
TestData();
@@ -723,121 +723,121 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
if ( bColorOnly && !pLine )
return;
- if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))
+ if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)))
+ return;
+
+ SCSIZE nPos;
+ SCROW nStart=0;
+ SetDefaultIfNotInit();
+ if (!Search( nStartRow, nPos ))
{
- SCSIZE nPos;
- SCROW nStart=0;
- SetDefaultIfNotInit();
- if (!Search( nStartRow, nPos ))
- {
- OSL_FAIL("Search failure");
- return;
- }
+ OSL_FAIL("Search failure");
+ return;
+ }
- do
- {
- const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
- const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
- const SfxPoolItem* pBoxItem = nullptr;
- SfxItemState eState = rOldSet.GetItemState( ATTR_BORDER, true, &pBoxItem );
- const SfxPoolItem* pTLBRItem = nullptr;
- SfxItemState eTLBRState = rOldSet.GetItemState( ATTR_BORDER_TLBR, true, &pTLBRItem );
- const SfxPoolItem* pBLTRItem = nullptr;
- SfxItemState eBLTRState = rOldSet.GetItemState( ATTR_BORDER_BLTR, true, &pBLTRItem );
+ do
+ {
+ const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
+ const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
+ const SfxPoolItem* pBoxItem = nullptr;
+ SfxItemState eState = rOldSet.GetItemState( ATTR_BORDER, true, &pBoxItem );
+ const SfxPoolItem* pTLBRItem = nullptr;
+ SfxItemState eTLBRState = rOldSet.GetItemState( ATTR_BORDER_TLBR, true, &pTLBRItem );
+ const SfxPoolItem* pBLTRItem = nullptr;
+ SfxItemState eBLTRState = rOldSet.GetItemState( ATTR_BORDER_BLTR, true, &pBLTRItem );
- if ( (SfxItemState::SET == eState) || (SfxItemState::SET == eTLBRState) || (SfxItemState::SET == eBLTRState) )
- {
- std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*pOldPattern));
- SfxItemSet& rNewSet = pNewPattern->GetItemSet();
- SCROW nY1 = nStart;
- SCROW nY2 = mvData[nPos].nEndRow;
+ if ( (SfxItemState::SET == eState) || (SfxItemState::SET == eTLBRState) || (SfxItemState::SET == eBLTRState) )
+ {
+ std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*pOldPattern));
+ SfxItemSet& rNewSet = pNewPattern->GetItemSet();
+ SCROW nY1 = nStart;
+ SCROW nY2 = mvData[nPos].nEndRow;
- std::unique_ptr<SvxBoxItem> pNewBoxItem( pBoxItem ? static_cast<SvxBoxItem*>(pBoxItem->Clone()) : nullptr);
- std::unique_ptr<SvxLineItem> pNewTLBRItem( pTLBRItem ? static_cast<SvxLineItem*>(pTLBRItem->Clone()) : nullptr);
- std::unique_ptr<SvxLineItem> pNewBLTRItem(pBLTRItem ? static_cast<SvxLineItem*>(pBLTRItem->Clone()) : nullptr);
+ std::unique_ptr<SvxBoxItem> pNewBoxItem( pBoxItem ? static_cast<SvxBoxItem*>(pBoxItem->Clone()) : nullptr);
+ std::unique_ptr<SvxLineItem> pNewTLBRItem( pTLBRItem ? static_cast<SvxLineItem*>(pTLBRItem->Clone()) : nullptr);
+ std::unique_ptr<SvxLineItem> pNewBLTRItem(pBLTRItem ? static_cast<SvxLineItem*>(pBLTRItem->Clone()) : nullptr);
- // fetch line and update attributes with parameters
+ // fetch line and update attributes with parameters
- if ( !pLine )
+ if ( !pLine )
+ {
+ if( pNewBoxItem )
{
+ if ( pNewBoxItem->GetTop() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::TOP );
+ if ( pNewBoxItem->GetBottom() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::BOTTOM );
+ if ( pNewBoxItem->GetLeft() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::LEFT );
+ if ( pNewBoxItem->GetRight() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::RIGHT );
+ }
+ if( pNewTLBRItem && pNewTLBRItem->GetLine() )
+ pNewTLBRItem->SetLine( nullptr );
+ if( pNewBLTRItem && pNewBLTRItem->GetLine() )
+ pNewBLTRItem->SetLine( nullptr );
+ }
+ else
+ {
+ if ( bColorOnly )
+ {
+ Color aColor( pLine->GetColor() );
if( pNewBoxItem )
{
- if ( pNewBoxItem->GetTop() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::TOP );
- if ( pNewBoxItem->GetBottom() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::BOTTOM );
- if ( pNewBoxItem->GetLeft() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::LEFT );
- if ( pNewBoxItem->GetRight() ) pNewBoxItem->SetLine( nullptr, SvxBoxItemLine::RIGHT );
+ SetLineColor( pNewBoxItem->GetTop(), aColor );
+ SetLineColor( pNewBoxItem->GetBottom(), aColor );
+ SetLineColor( pNewBoxItem->GetLeft(), aColor );
+ SetLineColor( pNewBoxItem->GetRight(), aColor );
}
- if( pNewTLBRItem && pNewTLBRItem->GetLine() )
- pNewTLBRItem->SetLine( nullptr );
- if( pNewBLTRItem && pNewBLTRItem->GetLine() )
- pNewBLTRItem->SetLine( nullptr );
+ if( pNewTLBRItem )
+ SetLineColor( pNewTLBRItem->GetLine(), aColor );
+ if( pNewBLTRItem )
+ SetLineColor( pNewBLTRItem->GetLine(), aColor );
}
else
{
- if ( bColorOnly )
- {
- Color aColor( pLine->GetColor() );
- if( pNewBoxItem )
- {
- SetLineColor( pNewBoxItem->GetTop(), aColor );
- SetLineColor( pNewBoxItem->GetBottom(), aColor );
- SetLineColor( pNewBoxItem->GetLeft(), aColor );
- SetLineColor( pNewBoxItem->GetRight(), aColor );
- }
- if( pNewTLBRItem )
- SetLineColor( pNewTLBRItem->GetLine(), aColor );
- if( pNewBLTRItem )
- SetLineColor( pNewBLTRItem->GetLine(), aColor );
- }
- else
+ if( pNewBoxItem )
{
- if( pNewBoxItem )
- {
- SetLine( pNewBoxItem->GetTop(), pLine );
- SetLine( pNewBoxItem->GetBottom(), pLine );
- SetLine( pNewBoxItem->GetLeft(), pLine );
- SetLine( pNewBoxItem->GetRight(), pLine );
- }
- if( pNewTLBRItem )
- SetLine( pNewTLBRItem->GetLine(), pLine );
- if( pNewBLTRItem )
- SetLine( pNewBLTRItem->GetLine(), pLine );
+ SetLine( pNewBoxItem->GetTop(), pLine );
+ SetLine( pNewBoxItem->GetBottom(), pLine );
+ SetLine( pNewBoxItem->GetLeft(), pLine );
+ SetLine( pNewBoxItem->GetRight(), pLine );
}
+ if( pNewTLBRItem )
+ SetLine( pNewTLBRItem->GetLine(), pLine );
+ if( pNewBLTRItem )
+ SetLine( pNewBLTRItem->GetLine(), pLine );
}
- if( pNewBoxItem ) rNewSet.Put( *pNewBoxItem );
- if( pNewTLBRItem ) rNewSet.Put( *pNewTLBRItem );
- if( pNewBLTRItem ) rNewSet.Put( *pNewBLTRItem );
-
- nStart = mvData[nPos].nEndRow + 1;
+ }
+ if( pNewBoxItem ) rNewSet.Put( *pNewBoxItem );
+ if( pNewTLBRItem ) rNewSet.Put( *pNewTLBRItem );
+ if( pNewBLTRItem ) rNewSet.Put( *pNewBLTRItem );
- if ( nY1 < nStartRow || nY2 > nEndRow )
- {
- if (nY1 < nStartRow) nY1=nStartRow;
- if (nY2 > nEndRow) nY2=nEndRow;
- SetPatternArea( nY1, nY2, std::move(pNewPattern), true );
- Search( nStart, nPos );
- }
- else
- {
- // remove from pool ?
- pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
- mvData[nPos].pPattern =
- &pDocument->GetPool()->Put(std::move(pNewPattern));
+ nStart = mvData[nPos].nEndRow + 1;
- if (Concat(nPos))
- Search(nStart, nPos);
- else
- nPos++;
- }
+ if ( nY1 < nStartRow || nY2 > nEndRow )
+ {
+ if (nY1 < nStartRow) nY1=nStartRow;
+ if (nY2 > nEndRow) nY2=nEndRow;
+ SetPatternArea( nY1, nY2, std::move(pNewPattern), true );
+ Search( nStart, nPos );
}
else
{
- nStart = mvData[nPos].nEndRow + 1;
- nPos++;
+ // remove from pool ?
+ pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
+ mvData[nPos].pPattern =
+ &pDocument->GetPool()->Put(std::move(pNewPattern));
+
+ if (Concat(nPos))
+ Search(nStart, nPos);
+ else
+ nPos++;
}
}
- while ((nStart <= nEndRow) && (nPos < mvData.size()));
+ else
+ {
+ nStart = mvData[nPos].nEndRow + 1;
+ nPos++;
+ }
}
+ while ((nStart <= nEndRow) && (nPos < mvData.size()));
}
void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray, bool* const pIsChanged )
@@ -846,77 +846,77 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac
TestData();
#endif
- if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))
+ if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)))
+ return;
+
+ SCSIZE nPos;
+ SCROW nStart=0;
+ SetDefaultIfNotInit();
+ if (!Search( nStartRow, nPos ))
{
- SCSIZE nPos;
- SCROW nStart=0;
- SetDefaultIfNotInit();
- if (!Search( nStartRow, nPos ))
- {
- OSL_FAIL("Search Failure");
- return;
- }
+ OSL_FAIL("Search Failure");
+ return;
+ }
- ScAddress aAdrStart( nCol, 0, nTab );
- ScAddress aAdrEnd ( nCol, 0, nTab );
+ ScAddress aAdrStart( nCol, 0, nTab );
+ ScAddress aAdrEnd ( nCol, 0, nTab );
- do
+ do
+ {
+ const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
+ const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pCache->ApplyTo( *pOldPattern ) );
+ if (pNewPattern != pOldPattern)
{
- const ScPatternAttr* pOldPattern = mvData[nPos].pPattern;
- const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pCache->ApplyTo( *pOldPattern ) );
- if (pNewPattern != pOldPattern)
- {
- SCROW nY1 = nStart;
- SCROW nY2 = mvData[nPos].nEndRow;
- nStart = mvData[nPos].nEndRow + 1;
+ SCROW nY1 = nStart;
+ SCROW nY2 = mvData[nPos].nEndRow;
+ nStart = mvData[nPos].nEndRow + 1;
- if(pIsChanged)
- *pIsChanged = true;
+ if(pIsChanged)
+ *pIsChanged = true;
- if ( nY1 < nStartRow || nY2 > nEndRow )
- {
- if (nY1 < nStartRow) nY1=nStartRow;
- if (nY2 > nEndRow) nY2=nEndRow;
- SetPatternArea( nY1, nY2, pNewPattern, false, pDataArray );
- Search( nStart, nPos );
- }
- else
+ if ( nY1 < nStartRow || nY2 > nEndRow )
+ {
+ if (nY1 < nStartRow) nY1=nStartRow;
+ if (nY2 > nEndRow) nY2=nEndRow;
+ SetPatternArea( nY1, nY2, pNewPattern, false, pDataArray );
+ Search( nStart, nPos );
+ }
+ else
+ {
+ if ( nCol != -1 )
{
- if ( nCol != -1 )
+ // ensure attributing changes text-width of cell
+
+ const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
+ const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
+
+ bool bNumFormatChanged;
+ if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
+ rNewSet, rOldSet ) )
{
- // ensure attributing changes text-width of cell
-
- const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
- const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
-
- bool bNumFormatChanged;
- if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
- rNewSet, rOldSet ) )
- {
- aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 );
- aAdrEnd .SetRow( mvData[nPos].nEndRow );
- pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
- }
+ aAdrStart.SetRow( nPos ? mvData[nPos-1].nEndRow+1 : 0 );
+ aAdrEnd .SetRow( mvData[nPos].nEndRow );
+ pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
}
-
- pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
- mvData[nPos].pPattern = pNewPattern;
- if (Concat(nPos))
- Search(nStart, nPos);
- else
- ++nPos;
}
- }
- else
- {
- nStart = mvData[nPos].nEndRow + 1;
- ++nPos;
+
+ pDocument->GetPool()->Remove(*mvData[nPos].pPattern);
+ mvData[nPos].pPattern = pNewPattern;
+ if (Concat(nPos))
+ Search(nStart, nPos);
+ else
+ ++nPos;
}
}
- while (nStart <= nEndRow);
-
- pDocument->SetStreamValid(nTab, false);
+ else
+ {
+ nStart = mvData[nPos].nEndRow + 1;
+ ++nPos;
+ }
}
+ while (nStart <= nEndRow);
+
+ pDocument->SetStreamValid(nTab, false);
#if DEBUG_SC_TESTATTRARRAY
TestData();
@@ -971,55 +971,55 @@ static void lcl_MergeDeep( SfxItemSet& rMergeSet, const SfxItemSet& rSource )
void ScAttrArray::MergePatternArea( SCROW nStartRow, SCROW nEndRow,
ScMergePatternState& rState, bool bDeep ) const
{
- if (pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow))
+ if (!(pDocument->ValidRow(nStartRow) && pDocument->ValidRow(nEndRow)))
+ return;
+
+ SCSIZE nPos = 0;
+ SCROW nStart=0;
+ if ( !mvData.empty() && !Search( nStartRow, nPos ) )
{
- SCSIZE nPos = 0;
- SCROW nStart=0;
- if ( !mvData.empty() && !Search( nStartRow, nPos ) )
- {
- OSL_FAIL("Search failure");
- return;
- }
+ OSL_FAIL("Search failure");
+ return;
+ }
- do
+ do
+ {
+ // similar patterns must not be repeated
+ const ScPatternAttr* pPattern = nullptr;
+ if ( !mvData.empty() )
+ pPattern = mvData[nPos].pPattern;
+ else
+ pPattern = pDocument->GetDefPattern();
+ if ( pPattern != rState.pOld1 && pPattern != rState.pOld2 )
{
- // similar patterns must not be repeated
- const ScPatternAttr* pPattern = nullptr;
- if ( !mvData.empty() )
- pPattern = mvData[nPos].pPattern;
- else
- pPattern = pDocument->GetDefPattern();
- if ( pPattern != rState.pOld1 && pPattern != rState.pOld2 )
+ const SfxItemSet& rThisSet = pPattern->GetItemSet();
+ if (rState.pItemSet)
{
- const SfxItemSet& rThisSet = pPattern->GetItemSet();
- if (rState.pItemSet)
- {
- rState.mbValidPatternId = false;
- if (bDeep)
- lcl_MergeDeep( *rState.pItemSet, rThisSet );
- else
- rState.pItemSet->MergeValues( rThisSet );
- }
+ rState.mbValidPatternId = false;
+ if (bDeep)
+ lcl_MergeDeep( *rState.pItemSet, rThisSet );
else
- {
- // first pattern - copied from parent
- rState.pItemSet = std::make_unique<SfxItemSet>( *rThisSet.GetPool(), rThisSet.GetRanges() );
- rState.pItemSet->Set( rThisSet, bDeep );
- rState.mnPatternId = pPattern->GetKey();
- }
-
- rState.pOld2 = rState.pOld1;
- rState.pOld1 = pPattern;
+ rState.pItemSet->MergeValues( rThisSet );
}
-
- if ( !mvData.empty() )
- nStart = mvData[nPos].nEndRow + 1;
else
- nStart = pDocument->MaxRow() + 1;
- ++nPos;
+ {
+ // first pattern - copied from parent
+ rState.pItemSet = std::make_unique<SfxItemSet>( *rThisSet.GetPool(), rThisSet.GetRanges() );
+ rState.pItemSet->Set( rThisSet, bDeep );
+ rState.mnPatternId = pPattern->GetKey();
+ }
+
+ rState.pOld2 = rState.pOld1;
+ rState.pOld1 = pPattern;
}
- while (nStart <= nEndRow);
+
+ if ( !mvData.empty() )
+ nStart = mvData[nPos].nEndRow + 1;
+ else
+ nStart = pDocument->MaxRow() + 1;
+ ++nPos;
}
+ while (nStart <= nEndRow);
}
// assemble border
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index c3a92bf7d187..fb80a7bdb17c 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -1059,18 +1059,18 @@ void ScBroadcastAreaSlotMachine::EnterBulkBroadcast()
void ScBroadcastAreaSlotMachine::LeaveBulkBroadcast( SfxHintId nHintId )
{
- if (nInBulkBroadcast > 0)
+ if (nInBulkBroadcast <= 0)
+ return;
+
+ if (--nInBulkBroadcast == 0)
{
- if (--nInBulkBroadcast == 0)
- {
- ScBroadcastAreasBulk().swap( aBulkBroadcastAreas);
- bool bBroadcasted = BulkBroadcastGroupAreas( nHintId );
- // Trigger the "final" tracking.
- if (pDoc->IsTrackFormulasPending())
- pDoc->FinalTrackFormulas( nHintId );
- else if (bBroadcasted)
- pDoc->TrackFormulas( nHintId );
- }
+ ScBroadcastAreasBulk().swap( aBulkBroadcastAreas);
+ bool bBroadcasted = BulkBroadcastGroupAreas( nHintId );
+ // Trigger the "final" tracking.
+ if (pDoc->IsTrackFormulasPending())
+ pDoc->FinalTrackFormulas( nHintId );
+ else if (bBroadcasted)
+ pDoc->TrackFormulas( nHintId );
}
}
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 61011da9aeae..34be6086f10e 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -464,22 +464,22 @@ void ScColumn::ClearSelectionItems( const sal_uInt16* pWhich,const ScMarkData& r
SCROW nTop;
SCROW nBottom;
- if (pAttrArray)
+ if (!pAttrArray)
+ return;
+
+ if (rMark.IsMultiMarked() )
{
- if (rMark.IsMultiMarked() )
+ ScMultiSelIter aMultiIter( rMark.GetMultiSelData(), nCol );
+ while (aMultiIter.Next( nTop, nBottom ))
+ pAttrArray->ClearItems(nTop, nBottom, pWhich);
+ }
+ else if (rMark.IsMarked())
+ {
+ ScRange aRange;
+ rMark.GetMarkArea(aRange);
+ if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col())
{
- ScMultiSelIter aMultiIter( rMark.GetMultiSelData(), nCol );
- while (aMultiIter.Next( nTop, nBottom ))
- pAttrArray->ClearItems(nTop, nBottom, pWhich);
- }
- else if (rMark.IsMarked())
- {
- ScRange aRange;
- rMark.GetMarkArea(aRange);
- if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col())
- {
- pAttrArray->ClearItems(aRange.aStart.Row(), aRange.aEnd.Row(), pWhich);
- }
+ pAttrArray->ClearItems(aRange.aStart.Row(), aRange.aEnd.Row(), pWhich);
}
}
}
@@ -1489,29 +1489,29 @@ class CopyByCloneHandler
}
}
- if (bCloneString)
- {
- svl::SharedString aStr = rSrcCell.GetString();
- if (aStr.isEmpty())
- // Don't create empty string cells.
- return;
+ if (!bCloneString)
+ return;
- if (rSrcCell.IsMultilineResult())
- {
- // Clone as an edit text object.
- EditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine();
- rEngine.SetText(aStr.getString());
- maDestPos.miCellPos =
- mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rEngine.CreateTextObject().release());
- }
- else
- {
- maDestPos.miCellPos =
- mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aStr);
- }
+ svl::SharedString aStr = rSrcCell.GetString();
+ if (aStr.isEmpty())
+ // Don't create empty string cells.
+ return;
- setDefaultAttrToDest(nRow);
+ if (rSrcCell.IsMultilineResult())
+ {
+ // Clone as an edit text object.
+ EditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine();
+ rEngine.SetText(aStr.getString());
+ maDestPos.miCellPos =
+ mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rEngine.CreateTextObject().release());
}
+ else
+ {
+ maDestPos.miCellPos =
+ mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aStr);
+ }
+
+ setDefaultAttrToDest(nRow);
}
public:
@@ -1531,28 +1531,28 @@ public:
~CopyByCloneHandler()
{
- if (mpDestPos)
- {
- // If broadcasters were setup in the same column,
- // maDestPos.miBroadcasterPos doesn't match
- // mrDestCol.maBroadcasters because it is never passed anywhere.
- // Assign a corresponding iterator before copying all over.
- // Otherwise this may result in wrongly copying a singular
- // iterator.
+ if (!mpDestPos)
+ return;
- {
- /* XXX Using a temporary ColumnBlockPosition just for
- * initializing from ScColumn::maBroadcasters.begin() is ugly,
- * on the other hand we don't want to expose
- * ScColumn::maBroadcasters to the outer world and have a
- * getter. */
- sc::ColumnBlockPosition aTempBlock;
- mrDestCol.InitBlockPosition(aTempBlock);
- maDestPos.miBroadcasterPos = aTempBlock.miBroadcasterPos;
- }
+ // If broadcasters were setup in the same column,
+ // maDestPos.miBroadcasterPos doesn't match
+ // mrDestCol.maBroadcasters because it is never passed anywhere.
+ // Assign a corresponding iterator before copying all over.
+ // Otherwise this may result in wrongly copying a singular
+ // iterator.
- *mpDestPos = maDestPos;
+ {
+ /* XXX Using a temporary ColumnBlockPosition just for
+ * initializing from ScColumn::maBroadcasters.begin() is ugly,
+ * on the other hand we don't want to expose
+ * ScColumn::maBroadcasters to the outer world and have a
+ * getter. */
+ sc::ColumnBlockPosition aTempBlock;
+ mrDestCol.InitBlockPosition(aTempBlock);
+ maDestPos.miBroadcasterPos = aTempBlock.miBroadcasterPos;
}
+
+ *mpDestPos = maDestPos;
}
void setStartListening( bool b )
@@ -1731,29 +1731,29 @@ void ScColumn::CopyToColumn(
pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray);
}
- if ((nFlags & InsertDeleteFlags::CONTENTS) != InsertDeleteFlags::NONE)
- {
- if (bAsLink)
- {
- CopyAsLinkHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags);
- aFunc.setStartListening(rCxt.isStartListening());
- sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
- }
- else
- {
- // Compare the ScDocumentPool* to determine if we are copying
- // within the same document. If not, re-intern shared strings.
- svl::SharedStringPool* pSharedStringPool =
- (GetDoc()->GetPool() != rColumn.GetDoc()->GetPool()) ?
- &rColumn.GetDoc()->GetSharedStringPool() : nullptr;
- CopyByCloneHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags,
- pSharedStringPool, bGlobalNamesToLocal);
- aFunc.setStartListening(rCxt.isStartListening());
- sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
- }
+ if ((nFlags & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE)
+ return;
- rColumn.CellStorageModified();
+ if (bAsLink)
+ {
+ CopyAsLinkHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags);
+ aFunc.setStartListening(rCxt.isStartListening());
+ sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
+ }
+ else
+ {
+ // Compare the ScDocumentPool* to determine if we are copying
+ // within the same document. If not, re-intern shared strings.
+ svl::SharedStringPool* pSharedStringPool =
+ (GetDoc()->GetPool() != rColumn.GetDoc()->GetPool()) ?
+ &rColumn.GetDoc()->GetSharedStringPool() : nullptr;
+ CopyByCloneHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags,
+ pSharedStringPool, bGlobalNamesToLocal);
+ aFunc.setStartListening(rCxt.isStartListening());
+ sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
}
+
+ rColumn.CellStorageModified();
}
void ScColumn::UndoToColumn(
@@ -2281,41 +2281,41 @@ class UpdateRefOnNonCopy
sc::RefUpdateResult aRes = pCode->AdjustReferenceOnMove(*mpCxt, aOldPos, aPos);
- if (aRes.mbReferenceModified || aRes.mbNameModified || bRecalcOnMove)
- {
- sc::AutoCalcSwitch aACSwitch(mpCxt->mrDoc, false);
+ if (!(aRes.mbReferenceModified || aRes.mbNameModified || bRecalcOnMove))
+ return;
- if (aRes.mbNameModified)
- recompileTokenArray(*pTop);
+ sc::AutoCalcSwitch aACSwitch(mpCxt->mrDoc, false);
- // Perform end-listening, start-listening, and dirtying on all
- // formula cells in the group.
+ if (aRes.mbNameModified)
+ recompileTokenArray(*pTop);
- // Make sure that the start and end listening contexts share the
- // same block position set, else an invalid iterator may ensue.
- auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(mpCxt->mrDoc);
+ // Perform end-listening, start-listening, and dirtying on all
+ // formula cells in the group.
- sc::StartListeningContext aStartCxt(mpCxt->mrDoc, pPosSet);
- sc::EndListeningContext aEndCxt(mpCxt->mrDoc, pPosSet, pOldCode.get());
+ // Make sure that the start and end listening contexts share the
+ // same block position set, else an invalid iterator may ensue.
+ auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(mpCxt->mrDoc);
- aEndCxt.setPositionDelta(
- ScAddress(-mpCxt->mnColDelta, -mpCxt->mnRowDelta, -mpCxt->mnTabDelta));
+ sc::StartListeningContext aStartCxt(mpCxt->mrDoc, pPosSet);
+ sc::EndListeningContext aEndCxt(mpCxt->mrDoc, pPosSet, pOldCode.get());
- for (; pp != ppEnd; ++pp)
- {
- ScFormulaCell* p = *pp;
- p->EndListeningTo(aEndCxt);
- p->StartListeningTo(aStartCxt);
- p->SetDirty();
- }
-
- mbUpdated = true;
+ aEndCxt.setPositionDelta(
+ ScAddress(-mpCxt->mnColDelta, -mpCxt->mnRowDelta, -mpCxt->mnTabDelta));
- // Move from clipboard is Cut&Paste, then do not copy the original
- // positions' formula cells to the Undo document.
- if (!mbClipboardSource || !bCellMoved)
- fillUndoDoc(aOldPos, rGroup.mnLength, *pOldCode);
+ for (; pp != ppEnd; ++pp)
+ {
+ ScFormulaCell* p = *pp;
+ p->EndListeningTo(aEndCxt);
+ p->StartListeningTo(aStartCxt);
+ p->SetDirty();
}
+
+ mbUpdated = true;
+
+ // Move from clipboard is Cut&Paste, then do not copy the original
+ // positions' formula cells to the Undo document.
+ if (!mbClipboardSource || !bCellMoved)
+ fillUndoDoc(aOldPos, rGroup.mnLength, *pOldCode);
}
void fillUndoDoc( const ScAddress& rOldPos, SCROW nLength, const ScTokenArray& rOldCode )
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 0f4f3d8e76ab..011caea06a13 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -343,21 +343,21 @@ void ScColumn::StartListeningUnshared( const std::vector<SCROW>& rNewSharedRows
{
assert(rNewSharedRows.empty() || rNewSharedRows.size() == 2 || rNewSharedRows.size() == 4);
ScDocument* pDoc = GetDoc();
- if (!rNewSharedRows.empty() && !pDoc->IsDelayedFormulaGrouping())
+ if (rNewSharedRows.empty() || pDoc->IsDelayedFormulaGrouping())
+ return;
+
+ auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*pDoc);
+ sc::StartListeningContext aStartCxt(*pDoc, pPosSet);
+ sc::EndListeningContext aEndCxt(*pDoc, pPosSet);
+ if (rNewSharedRows.size() >= 2)
{
- auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(*pDoc);
- sc::StartListeningContext aStartCxt(*pDoc, pPosSet);
- sc::EndListeningContext aEndCxt(*pDoc, pPosSet);
- if (rNewSharedRows.size() >= 2)
- {
- if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[0], rNewSharedRows[1]))
- StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[0], rNewSharedRows[1]);
- }
- if (rNewSharedRows.size() >= 4)
- {
- if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[2], rNewSharedRows[3]))
- StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[2], rNewSharedRows[3]);
- }
+ if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[0], rNewSharedRows[1]))
+ StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[0], rNewSharedRows[1]);
+ }
+ if (rNewSharedRows.size() >= 4)
+ {
+ if(!pDoc->CanDelayStartListeningFormulaCells( this, rNewSharedRows[2], rNewSharedRows[3]))
+ StartListeningFormulaCells(aStartCxt, aEndCxt, rNewSharedRows[2], rNewSharedRows[3]);
}
}
@@ -693,53 +693,53 @@ void ScColumn::AttachNewFormulaCells( const sc::CellStoreType::position_type& aP
JoinNewFormulaCell(aPosLast, *pCell2);
ScDocument* pDocument = GetDoc();
- if (!pDocument->IsClipOrUndo() && !pDocument->IsInsertingFromOtherDoc())
+ if (pDocument->IsClipOrUndo() || pDocument->IsInsertingFromOtherDoc())
+ return;
+
+ const bool bShared = pCell1->IsShared() || pCell2->IsShared();
+ if (bShared)
{
- const bool bShared = pCell1->IsShared() || pCell2->IsShared();
- if (bShared)
+ const SCROW nTopRow = (pCell1->IsShared() ? pCell1->GetSharedTopRow() : pCell1->aPos.Row());
+ const SCROW nBotRow = (pCell2->IsShared() ?
+ pCell2->GetSharedTopRow() + pCell2->GetSharedLength() - 1 : pCell2->aPos.Row());
+ if (rNewSharedRows.empty())
{
- const SCROW nTopRow = (pCell1->IsShared() ? pCell1->GetSharedTopRow() : pCell1->aPos.Row());
- const SCROW nBotRow = (pCell2->IsShared() ?
- pCell2->GetSharedTopRow() + pCell2->GetSharedLength() - 1 : pCell2->aPos.Row());
- if (rNewSharedRows.empty())
- {
- rNewSharedRows.push_back( nTopRow);
- rNewSharedRows.push_back( nBotRow);
- }
- else if (rNewSharedRows.size() == 2)
- {
- // Combine into one span.
- if (rNewSharedRows[0] > nTopRow)
- rNewSharedRows[0] = nTopRow;
- if (rNewSharedRows[1] < nBotRow)
- rNewSharedRows[1] = nBotRow;
- }
- else if (rNewSharedRows.size() == 4)
- {
- // Merge into one span.
- // The original two spans are ordered from top to bottom.
- std::vector<SCROW> aRows(2);
- aRows[0] = std::min( rNewSharedRows[0], nTopRow);
- aRows[1] = std::max( rNewSharedRows[3], nBotRow);
- rNewSharedRows.swap( aRows);
- }
- else
- {
- assert(!"rNewSharedRows?");
- }
+ rNewSharedRows.push_back( nTopRow);
+ rNewSharedRows.push_back( nBotRow);
}
- StartListeningUnshared( rNewSharedRows);
-
- sc::StartListeningContext aCxt(*pDocument);
- ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
- ScFormulaCell** ppEnd = pp + nLength;
- for (; pp != ppEnd; ++pp)
+ else if (rNewSharedRows.size() == 2)
{
- if (!bShared)
- (*pp)->StartListeningTo(aCxt);
- if (!pDocument->IsCalcingAfterLoad())
- (*pp)->SetDirty();
+ // Combine into one span.
+ if (rNewSharedRows[0] > nTopRow)
+ rNewSharedRows[0] = nTopRow;
+ if (rNewSharedRows[1] < nBotRow)
+ rNewSharedRows[1] = nBotRow;
}
+ else if (rNewSharedRows.size() == 4)
+ {
+ // Merge into one span.
+ // The original two spans are ordered from top to bottom.
+ std::vector<SCROW> aRows(2);
+ aRows[0] = std::min( rNewSharedRows[0], nTopRow);
+ aRows[1] = std::max( rNewSharedRows[3], nBotRow);
+ rNewSharedRows.swap( aRows);
+ }
+ else
+ {
+ assert(!"rNewSharedRows?");
+ }
+ }
+ StartListeningUnshared( rNewSharedRows);
+
+ sc::StartListeningContext aCxt(*pDocument);
+ ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
+ ScFormulaCell** ppEnd = pp + nLength;
+ for (; pp != ppEnd; ++pp)
+ {
+ if (!bShared)
+ (*pp)->StartListeningTo(aCxt);
+ if (!pDocument->IsCalcingAfterLoad())
+ (*pp)->SetDirty();
}
}
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 06f4684a5acd..d3a2d3db6a53 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -286,26 +286,26 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
}
const ScPostIt* pNote = rCxt.getSingleCellNote(nColOffset);
- if (pNote && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES)) != InsertDeleteFlags::NONE)
- {
- // Duplicate the cell note over the whole pasted range.
-
- ScDocument* pClipDoc = rCxt.getClipDoc();
- const ScAddress aSrcPos = pClipDoc->GetClipParam().getWholeRange().aStart;
- std::vector<ScPostIt*> aNotes;
- ScAddress aDestPos(nCol, nRow1, nTab);
- aNotes.reserve(nDestSize);
- for (size_t i = 0; i < nDestSize; ++i)
- {
- bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE;
- aNotes.push_back(pNote->Clone(aSrcPos, *pDocument, aDestPos, bCloneCaption).release());
- aDestPos.IncRow();
- }
+ if (!(pNote && (nFlags & (InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES)) != InsertDeleteFlags::NONE))
+ return;
- pBlockPos->miCellNotePos =
- maCellNotes.set(
- pBlockPos->miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
+ // Duplicate the cell note over the whole pasted range.
+
+ ScDocument* pClipDoc = rCxt.getClipDoc();
+ const ScAddress aSrcPos = pClipDoc->GetClipParam().getWholeRange().aStart;
+ std::vector<ScPostIt*> aNotes;
+ ScAddress aDestPos(nCol, nRow1, nTab);
+ aNotes.reserve(nDestSize);
+ for (size_t i = 0; i < nDestSize; ++i)
+ {
+ bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == InsertDeleteFlags::NONE;
+ aNotes.push_back(pNote->Clone(aSrcPos, *pDocument, aDestPos, bCloneCaption).release());
+ aDestPos.IncRow();
}
+
+ pBlockPos->miCellNotePos =
+ maCellNotes.set(
+ pBlockPos->miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
}
void ScColumn::SetValues( const SCROW nRow, const std::vector<double>& rVals )
@@ -834,37 +834,37 @@ public:
ScTokenArray* pCode = pTop->GetCode();
bool bRecompile = pCode->HasOpCodes(mrOps);
- if (bRecompile)
+ if (!bRecompile)
+ return;
+
+ // Get the formula string.
+ OUString aFormula = pTop->GetFormula(mrCompileFormulaCxt);
+ sal_Int32 n = aFormula.getLength();
+ if (pTop->GetMatrixFlag() != ScMatrixMode::NONE && n > 0)
{
- // Get the formula string.
- OUString aFormula = pTop->GetFormula(mrCompileFormulaCxt);
- sal_Int32 n = aFormula.getLength();
- if (pTop->GetMatrixFlag() != ScMatrixMode::NONE && n > 0)
- {
- if (aFormula[0] == '{' && aFormula[n-1] == '}')
- aFormula = aFormula.copy(1, n-2);
- }
+ if (aFormula[0] == '{' && aFormula[n-1] == '}')
+ aFormula = aFormula.copy(1, n-2);
+ }
- if (rEntry.mbShared)
- {
- ScFormulaCell** pp = rEntry.mpCells;
- ScFormulaCell** ppEnd = pp + rEntry.mnLength;
- for (; pp != ppEnd; ++pp)
- {
- ScFormulaCell* p = *pp;
- p->EndListeningTo(mrEndListenCxt);
- mpDoc->RemoveFromFormulaTree(p);
- }
- }
- else
+ if (rEntry.mbShared)
+ {
+ ScFormulaCell** pp = rEntry.mpCells;
+ ScFormulaCell** ppEnd = pp + rEntry.mnLength;
+ for (; pp != ppEnd; ++pp)
{
- rEntry.mpCell->EndListeningTo(mrEndListenCxt);
- mpDoc->RemoveFromFormulaTree(rEntry.mpCell);
+ ScFormulaCell* p = *pp;
+ p->EndListeningTo(mrEndListenCxt);
+ mpDoc->RemoveFromFormulaTree(p);
}
-
- pCode->Clear();
- pTop->SetHybridFormula(aFormula, mpDoc->GetGrammar());
}
+ else
+ {
+ rEntry.mpCell->EndListeningTo(mrEndListenCxt);
+ mpDoc->RemoveFromFormulaTree(rEntry.mpCell);
+ }
+
+ pCode->Clear();
+ pTop->SetHybridFormula(aFormula, mpDoc->GetGrammar());
}
};
@@ -1550,24 +1550,24 @@ void ScColumn::EndListeningIntersectedGroups(
aPos = maCells.position(it, nRow2);
it = aPos.first;
- if (it->type == sc::element_type_formula)
- {
- ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
- ScFormulaCellGroupRef xGroup = pFC->GetCellGroup();
- if (xGroup)
- {
- if (!pFC->IsSharedTop())
- // End listening.
- pFC->EndListeningTo(rCxt);
+ if (it->type != sc::element_type_formula)
+ return;
- if (pGroupPos)
- {
- // Record the position of the bottom cell of the group.
- ScAddress aPosLast = xGroup->mpTopCell->aPos;
- aPosLast.IncRow(xGroup->mnLength-1);
- pGroupPos->push_back(aPosLast);
- }
- }
+ ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
+ ScFormulaCellGroupRef xGroup = pFC->GetCellGroup();
+ if (!xGroup)
+ return;
+
+ if (!pFC->IsSharedTop())
+ // End listening.
+ pFC->EndListeningTo(rCxt);
+
+ if (pGroupPos)
+ {
+ // Record the position of the bottom cell of the group.
+ ScAddress aPosLast = xGroup->mpTopCell->aPos;
+ aPosLast.IncRow(xGroup->mnLength-1);
+ pGroupPos->push_back(aPosLast);
}
}
diff --git a/sc/source/core/data/compressedarray.cxx b/sc/source/core/data/compressedarray.cxx
index 914a6c52eb1f..6a3d41598ad7 100644
--- a/sc/source/core/data/compressedarray.cxx
+++ b/sc/source/core/data/compressedarray.cxx
@@ -69,124 +69,124 @@ size_t ScCompressedArray<A,D>::Search( A nAccess ) const
template< typename A, typename D >
void ScCompressedArray<A,D>::SetValue( A nStart, A nEnd, const D& rValue )
{
- if (0 <= nStart && nStart <= nMaxAccess && 0 <= nEnd && nEnd <= nMaxAccess
- && nStart <= nEnd)
+ if (!(0 <= nStart && nStart <= nMaxAccess && 0 <= nEnd && nEnd <= nMaxAccess
+ && nStart <= nEnd))
+ return;
+
+ if ((nStart == 0) && (nEnd == nMaxAccess))
+ Reset( rValue);
+ else
{
- if ((nStart == 0) && (nEnd == nMaxAccess))
- Reset( rValue);
- else
+ // Create a temporary copy in case we got a reference passed that
+ // points to a part of the array to be reallocated.
+ D aNewVal( rValue);
+ size_t nNeeded = nCount + 2;
+ if (nLimit < nNeeded)
{
- // Create a temporary copy in case we got a reference passed that
- // points to a part of the array to be reallocated.
- D aNewVal( rValue);
- size_t nNeeded = nCount + 2;
+ nLimit *= 1.5;
if (nLimit < nNeeded)
- {
- nLimit *= 1.5;
- if (nLimit < nNeeded)
- nLimit = nNeeded;
- std::unique_ptr<DataEntry[]> pNewData(new DataEntry[nLimit]);
- memcpy( pNewData.get(), pData.get(), nCount*sizeof(DataEntry));
- pData = std::move(pNewData);
- }
+ nLimit = nNeeded;
+ std::unique_ptr<DataEntry[]> pNewData(new DataEntry[nLimit]);
+ memcpy( pNewData.get(), pData.get(), nCount*sizeof(DataEntry));
+ pData = std::move(pNewData);
+ }
- size_t ni; // number of leading entries
- size_t nInsert; // insert position (nMaxAccess+1 := no insert)
- bool bCombined = false;
- bool bSplit = false;
- if (nStart > 0)
- {
- // skip leading
- ni = this->Search( nStart);
+ size_t ni; // number of leading entries
+ size_t nInsert; // insert position (nMaxAccess+1 := no insert)
+ bool bCombined = false;
+ bool bSplit = false;
+ if (nStart > 0)
+ {
+ // skip leading
+ ni = this->Search( nStart);
- nInsert = nMaxAccess+1;
- if (!(pData[ni].aValue == aNewVal))
- {
- if (ni == 0 || (pData[ni-1].nEnd < nStart - 1))
- { // may be a split or a simple insert or just a shrink,
- // row adjustment is done further down
- if (pData[ni].nEnd > nEnd)
- bSplit = true;
- ni++;
- nInsert = ni;
- }
- else if (ni > 0 && pData[ni-1].nEnd == nStart - 1)
- nInsert = ni;
- }
- if (ni > 0 && pData[ni-1].aValue == aNewVal)
- { // combine
- pData[ni-1].nEnd = nEnd;
- nInsert = nMaxAccess+1;
- bCombined = true;
+ nInsert = nMaxAccess+1;
+ if (!(pData[ni].aValue == aNewVal))
+ {
+ if (ni == 0 || (pData[ni-1].nEnd < nStart - 1))
+ { // may be a split or a simple insert or just a shrink,
+ // row adjustment is done further down
+ if (pData[ni].nEnd > nEnd)
+ bSplit = true;
+ ni++;
+ nInsert = ni;
}
+ else if (ni > 0 && pData[ni-1].nEnd == nStart - 1)
+ nInsert = ni;
}
- else
- {
- nInsert = 0;
- ni = 0;
+ if (ni > 0 && pData[ni-1].aValue == aNewVal)
+ { // combine
+ pData[ni-1].nEnd = nEnd;
+ nInsert = nMaxAccess+1;
+ bCombined = true;
}
+ }
+ else
+ {
+ nInsert = 0;
+ ni = 0;
+ }
- size_t nj = ni; // stop position of range to replace
- while (nj < nCount && pData[nj].nEnd <= nEnd)
- nj++;
- if (!bSplit)
- {
- if (nj < nCount && pData[nj].aValue == aNewVal)
- { // combine
- if (ni > 0)
- {
- if (pData[ni-1].aValue == aNewVal)
- { // adjacent entries
- pData[ni-1].nEnd = pData[nj].nEnd;
- nj++;
- }
- else if (ni == nInsert)
- pData[ni-1].nEnd = nStart - 1; // shrink
+ size_t nj = ni; // stop position of range to replace
+ while (nj < nCount && pData[nj].nEnd <= nEnd)
+ nj++;
+ if (!bSplit)
+ {
+ if (nj < nCount && pData[nj].aValue == aNewVal)
+ { // combine
+ if (ni > 0)
+ {
+ if (pData[ni-1].aValue == aNewVal)
+ { // adjacent entries
+ pData[ni-1].nEnd = pData[nj].nEnd;
+ nj++;
}
- nInsert = nMaxAccess+1;
- bCombined = true;
+ else if (ni == nInsert)
+ pData[ni-1].nEnd = nStart - 1; // shrink
}
- else if (ni > 0 && ni == nInsert)
- pData[ni-1].nEnd = nStart - 1; // shrink
+ nInsert = nMaxAccess+1;
+ bCombined = true;
+ }
+ else if (ni > 0 && ni == nInsert)
+ pData[ni-1].nEnd = nStart - 1; // shrink
+ }
+ if (ni < nj)
+ { // remove middle entries
+ if (!bCombined)
+ { // replace one entry
+ pData[ni].nEnd = nEnd;
+ pData[ni].aValue = aNewVal;
+ ni++;
+ nInsert = nMaxAccess+1;
}
if (ni < nj)
- { // remove middle entries
- if (!bCombined)
- { // replace one entry
- pData[ni].nEnd = nEnd;
- pData[ni].aValue = aNewVal;
- ni++;
- nInsert = nMaxAccess+1;
- }
- if (ni < nj)
- { // remove entries
- memmove( pData.get() + ni, pData.get() + nj,
- (nCount - nj) * sizeof(DataEntry));
- nCount -= nj - ni;
- }
+ { // remove entries
+ memmove( pData.get() + ni, pData.get() + nj,
+ (nCount - nj) * sizeof(DataEntry));
+ nCount -= nj - ni;
}
+ }
- if (nInsert < static_cast<size_t>(nMaxAccess+1))
- { // insert or append new entry
- if (nInsert <= nCount)
+ if (nInsert < static_cast<size_t>(nMaxAccess+1))
+ { // insert or append new entry
+ if (nInsert <= nCount)
+ {
+ if (!bSplit)
+ memmove( pData.get() + nInsert + 1, pData.get() + nInsert,
+ (nCount - nInsert) * sizeof(DataEntry));
+ else
{
- if (!bSplit)
- memmove( pData.get() + nInsert + 1, pData.get() + nInsert,
- (nCount - nInsert) * sizeof(DataEntry));
- else
- {
- memmove( pData.get() + nInsert + 2, pData.get() + nInsert,
- (nCount - nInsert) * sizeof(DataEntry));
- pData[nInsert+1] = pData[nInsert-1];
- nCount++;
- }
+ memmove( pData.get() + nInsert + 2, pData.get() + nInsert,
+ (nCount - nInsert) * sizeof(DataEntry));
+ pData[nInsert+1] = pData[nInsert-1];
+ nCount++;
}
- if (nInsert)
- pData[nInsert-1].nEnd = nStart - 1;
- pData[nInsert].nEnd = nEnd;
- pData[nInsert].aValue = aNewVal;
- nCount++;
}
+ if (nInsert)
+ pData[nInsert-1].nEnd = nStart - 1;
+ pData[nInsert].nEnd = nEnd;
+ pData[nInsert].aValue = aNewVal;
+ nCount++;
}
}
}
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index b18b68e1fc68..94a8dd4be086 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -311,24 +311,24 @@ void ScConditionEntry::SimplifyCompiledFormula( std::unique_ptr<ScTokenArray>& r
bool& rIsStr,
OUString& rStrVal )
{
- if ( rFormula->GetLen() == 1 )
+ if ( rFormula->GetLen() != 1 )
+ return;
+
+ // Single (constant number)?
+ FormulaToken* pToken = rFormula->FirstToken();
+ if ( pToken->GetOpCode() != ocPush )
+ return;
+
+ if ( pToken->GetType() == svDouble )
{
- // Single (constant number)?
- FormulaToken* pToken = rFormula->FirstToken();
- if ( pToken->GetOpCode() == ocPush )
- {
- if ( pToken->GetType() == svDouble )
- {
- rVal = pToken->GetDouble();
- rFormula.reset(); // Do not remember as formula
- }
- else if ( pToken->GetType() == svString )
- {
- rIsStr = true;
- rStrVal = pToken->GetString().getString();
- rFormula.reset(); // Do not remember as formula
- }
- }
+ rVal = pToken->GetDouble();
+ rFormula.reset(); // Do not remember as formula
+ }
+ else if ( pToken->GetType() == svString )
+ {
+ rIsStr = true;
+ rStrVal = pToken->GetString().getString();
+ rFormula.reset(); // Do not remember as formula
}
}
@@ -392,23 +392,23 @@ void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2,
*/
void ScConditionEntry::MakeCells( const ScAddress& rPos )
{
- if ( !mpDoc->IsClipOrUndo() ) // Never calculate in the Clipboard!
+ if ( mpDoc->IsClipOrUndo() ) // Never calculate in the Clipboard!
+ return;
+
+ if ( pFormula1 && !pFCell1 && !bRelRef1 )
{
- if ( pFormula1 && !pFCell1 && !bRelRef1 )
- {
- // pFCell1 will hold a flat-copied ScTokenArray sharing ref-counted
- // code tokens with pFormula1
- pFCell1.reset( new ScFormulaCell(mpDoc, rPos, *pFormula1) );
- pFCell1->StartListeningTo( mpDoc );
- }
+ // pFCell1 will hold a flat-copied ScTokenArray sharing ref-counted
+ // code tokens with pFormula1
+ pFCell1.reset( new ScFormulaCell(mpDoc, rPos, *pFormula1) );
+ pFCell1->StartListeningTo( mpDoc );
+ }
- if ( pFormula2 && !pFCell2 && !bRelRef2 )
- {
- // pFCell2 will hold a flat-copied ScTokenArray sharing ref-counted
- // code tokens with pFormula2
- pFCell2.reset( new ScFormulaCell(mpDoc, rPos, *pFormula2) );
- pFCell2->StartListeningTo( mpDoc );
- }
+ if ( pFormula2 && !pFCell2 && !bRelRef2 )
+ {
+ // pFCell2 will hold a flat-copied ScTokenArray sharing ref-counted
+ // code tokens with pFormula2
+ pFCell2.reset( new ScFormulaCell(mpDoc, rPos, *pFormula2) );
+ pFCell2->StartListeningTo( mpDoc );
}
}
@@ -755,58 +755,58 @@ static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rAr
void ScConditionEntry::FillCache() const
{
- if(!mpCache)
- {
- const ScRangeList& rRanges = pCondFormat->GetRange();
- mpCache.reset(new ScConditionEntryCache);
- size_t nListCount = rRanges.size();
- for( size_t i = 0; i < nListCount; i++ )
+ if(mpCache)
+ return;
+
+ const ScRangeList& rRanges = pCondFormat->GetRange();
+ mpCache.reset(new ScConditionEntryCache);
+ size_t nListCount = rRanges.size();
+ for( size_t i = 0; i < nListCount; i++ )
+ {
+ const ScRange & rRange = rRanges[i];
+ SCROW nRow = rRange.aEnd.Row();
+ SCCOL nCol = rRange.aEnd.Col();
+ SCCOL nColStart = rRange.aStart.Col();
+ SCROW nRowStart = rRange.aStart.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+
+ // temporary fix to workaround slow duplicate entry
+ // conditions, prevent to use a whole row
+ if(nRow == MAXROW)
{
- const ScRange & rRange = rRanges[i];
- SCROW nRow = rRange.aEnd.Row();
- SCCOL nCol = rRange.aEnd.Col();
- SCCOL nColStart = rRange.aStart.Col();
- SCROW nRowStart = rRange.aStart.Row();
- SCTAB nTab = rRange.aStart.Tab();
-
- // temporary fix to workaround slow duplicate entry
- // conditions, prevent to use a whole row
- if(nRow == MAXROW)
+ bool bShrunk = false;
+ mpDoc->ShrinkToUsedDataArea(bShrunk, nTab, nColStart, nRowStart,
+ nCol, nRow, false);
+ }
+
+ for( SCROW r = nRowStart; r <= nRow; r++ )
+ for( SCCOL c = nColStart; c <= nCol; c++ )
{
- bool bShrunk = false;
- mpDoc->ShrinkToUsedDataArea(bShrunk, nTab, nColStart, nRowStart,
- nCol, nRow, false);
- }
+ ScRefCellValue aCell(*mpDoc, ScAddress(c, r, nTab));
+ if (aCell.isEmpty())
+ continue;
- for( SCROW r = nRowStart; r <= nRow; r++ )
- for( SCCOL c = nColStart; c <= nCol; c++ )
+ double nVal = 0.0;
+ OUString aStr;
+ if (!lcl_GetCellContent(aCell, false, nVal, aStr, mpDoc))
{
- ScRefCellValue aCell(*mpDoc, ScAddress(c, r, nTab));
- if (aCell.isEmpty())
- continue;
+ std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult =
+ mpCache->maStrings.emplace(aStr, 1);
- double nVal = 0.0;
- OUString aStr;
- if (!lcl_GetCellContent(aCell, false, nVal, aStr, mpDoc))
- {
- std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult =
- mpCache->maStrings.emplace(aStr, 1);
-
- if(!aResult.second)
- aResult.first->second++;
- }
- else
- {
- std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult =
- mpCache->maValues.emplace(nVal, 1);
+ if(!aResult.second)
+ aResult.first->second++;
+ }
+ else
+ {
+ std::pair<ScConditionEntryCache::ValueCacheType::iterator, bool> aResult =
+ mpCache->maValues.emplace(nVal, 1);
- if(!aResult.second)
- aResult.first->second++;
+ if(!aResult.second)
+ aResult.first->second++;
- ++(mpCache->nValueItems);
- }
+ ++(mpCache->nValueItems);
}
- }
+ }
}
}
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index eb110991140a..0fbbdadd4e18 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -80,21 +80,21 @@ static void ScAttrArray_IterGetNumberFormat( sal_uInt32& nFormat, const ScAttrAr
SCROW& nAttrEndRow, const ScAttrArray* pNewArr, SCROW nRow,
const ScDocument* pDoc, const ScInterpreterContext* pContext = nullptr )
{
- if ( rpArr != pNewArr || nAttrEndRow < nRow )
- {
- SCROW nRowStart = 0;
- SCROW nRowEnd = pDoc->MaxRow();
- const ScPatternAttr* pPattern = pNewArr->GetPatternRange( nRowStart, nRowEnd, nRow );
- if( !pPattern )
- {
- pPattern = pDoc->GetDefPattern();
- nRowEnd = pDoc->MaxRow();
- }
+ if ( rpArr == pNewArr && nAttrEndRow >= nRow )
+ return;
- nFormat = pPattern->GetNumberFormat( pContext ? pContext->GetFormatTable() : pDoc->GetFormatTable() );
- rpArr = pNewArr;
- nAttrEndRow = nRowEnd;
+ SCROW nRowStart = 0;
+ SCROW nRowEnd = pDoc->MaxRow();
+ const ScPatternAttr* pPattern = pNewArr->GetPatternRange( nRowStart, nRowEnd, nRow );
+ if( !pPattern )
+ {
+ pPattern = pDoc->GetDefPattern();
+ nRowEnd = pDoc->MaxRow();
}
+
+ nFormat = pPattern->GetNumberFormat( pContext ? pContext->GetFormatTable() : pDoc->GetFormatTable() );
+ rpArr = pNewArr;
+ nAttrEndRow = nRowEnd;
}
ScValueIterator::ScValueIterator( ScDocument* pDocument, const ScRange& rRange,
@@ -1059,18 +1059,18 @@ ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, const ScInterpre
nCol = maParam.nCol1;
nRow = maParam.nRow1;
SCSIZE i;
- if (bMod) // Or else it's already inserted
+ if (!bMod) // Or else it's already inserted
+ return;
+
+ SCSIZE nCount = maParam.GetEntryCount();
+ for (i = 0; (i < nCount) && (maParam.GetEntry(i).bDoQuery); ++i)
{
- SCSIZE nCount = maParam.GetEntryCount();
- for (i = 0; (i < nCount) && (maParam.GetEntry(i).bDoQuery); ++i)
- {
- ScQueryEntry& rEntry = maParam.GetEntry(i);
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
- sal_uInt32 nIndex = 0;
- bool bNumber = mrContext.GetFormatTable()->IsNumberFormat(
- rItem.maString.getString(), nIndex, rItem.mfVal);
- rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
- }
+ ScQueryEntry& rEntry = maParam.GetEntry(i);
+ ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ sal_uInt32 nIndex = 0;
+ bool bNumber = mrContext.GetFormatTable()->IsNumberFormat(
+ rItem.maString.getString(), nIndex, rItem.mfVal);
+ rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
}
}
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index d80e15dd1c34..9b966c8d5cf5 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1273,85 +1273,85 @@ void ScDocument::GetCellChangeTrackNote( const ScAddress &aCellPos, OUString &aT
// Change-Tracking
ScChangeTrack* pTrack = GetChangeTrack();
ScChangeViewSettings* pSettings = GetChangeViewSettings();
- if ( pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges())
+ if ( !(pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges()))
+ return;
+
+ const ScChangeAction* pFound = nullptr;
+ const ScChangeAction* pFoundContent = nullptr;
+ const ScChangeAction* pFoundMove = nullptr;
+ const ScChangeAction* pAction = pTrack->GetFirst();
+ while (pAction)
{
- const ScChangeAction* pFound = nullptr;
- const ScChangeAction* pFoundContent = nullptr;
- const ScChangeAction* pFoundMove = nullptr;
- const ScChangeAction* pAction = pTrack->GetFirst();
- while (pAction)
+ if ( pAction->IsVisible() &&
+ ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
{
- if ( pAction->IsVisible() &&
- ScViewUtil::IsActionShown( *pAction, *pSettings, *this ) )
+ ScChangeActionType eType = pAction->GetType();
+ const ScBigRange& rBig = pAction->GetBigRange();
+ if ( rBig.aStart.Tab() == aCellPos.Tab())
{
- ScChangeActionType eType = pAction->GetType();
- const ScBigRange& rBig = pAction->GetBigRange();
- if ( rBig.aStart.Tab() == aCellPos.Tab())
+ ScRange aRange = rBig.MakeRange();
+ if ( eType == SC_CAT_DELETE_ROWS )
+ aRange.aEnd.SetRow( aRange.aStart.Row() );
+ else if ( eType == SC_CAT_DELETE_COLS )
+ aRange.aEnd.SetCol( aRange.aStart.Col() );
+ if ( aRange.In( aCellPos ) )
{
- ScRange aRange = rBig.MakeRange();
- if ( eType == SC_CAT_DELETE_ROWS )
- aRange.aEnd.SetRow( aRange.aStart.Row() );
- else if ( eType == SC_CAT_DELETE_COLS )
- aRange.aEnd.SetCol( aRange.aStart.Col() );
- if ( aRange.In( aCellPos ) )
+ pFound = pAction; // the last wins
+ switch ( eType )
{
- pFound = pAction; // the last wins
- switch ( eType )
- {
- case SC_CAT_CONTENT :
- pFoundContent = pAction;
- break;
- case SC_CAT_MOVE :
- pFoundMove = pAction;
+ case SC_CAT_CONTENT :
+ pFoundContent = pAction;
+ break;
+ case SC_CAT_MOVE :
+ pFoundMove = pAction;
+ break;
+ default:
break;
- default:
- break;
- }
}
}
- if ( eType == SC_CAT_MOVE )
- {
- ScRange aRange =
- static_cast<const ScChangeActionMove*>(pAction)->
- GetFromRange().MakeRange();
- if ( aRange.In( aCellPos ) )
- {
- pFound = pAction;
- }
- }
- }
- pAction = pAction->GetNext();
- }
- if ( pFound )
- {
- if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT )
- pFound = pFoundContent; // Content wins
- if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE &&
- pFoundMove->GetActionNumber() >
- pFound->GetActionNumber() )
- pFound = pFoundMove; // Move wins
- // for deleted columns: arrow on left side of row
- if ( pFound->GetType() == SC_CAT_DELETE_COLS )
- bLeftEdge = true;
- DateTime aDT = pFound->GetDateTime();
- aTrackText = pFound->GetUser();
- aTrackText += ", ";
- aTrackText += ScGlobal::getLocaleDataPtr()->getDate(aDT);
- aTrackText += " ";
- aTrackText += ScGlobal::getLocaleDataPtr()->getTime(aDT);
- aTrackText += ":\n";
- OUString aComStr = pFound->GetComment();
- if(!aComStr.isEmpty())
- {
- aTrackText += aComStr;
- aTrackText += "\n( ";
}
- pFound->GetDescription( aTrackText, this );
- if (!aComStr.isEmpty())
+ if ( eType == SC_CAT_MOVE )
{
- aTrackText += ")";
+ ScRange aRange =
+ static_cast<const ScChangeActionMove*>(pAction)->
+ GetFromRange().MakeRange();
+ if ( aRange.In( aCellPos ) )
+ {
+ pFound = pAction;
+ }
}
}
+ pAction = pAction->GetNext();
+ }
+ if ( !pFound )
+ return;
+
+ if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT )
+ pFound = pFoundContent; // Content wins
+ if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE &&
+ pFoundMove->GetActionNumber() >
+ pFound->GetActionNumber() )
+ pFound = pFoundMove; // Move wins
+ // for deleted columns: arrow on left side of row
+ if ( pFound->GetType() == SC_CAT_DELETE_COLS )
+ bLeftEdge = true;
+ DateTime aDT = pFound->GetDateTime();
+ aTrackText = pFound->GetUser();
+ aTrackText += ", ";
+ aTrackText += ScGlobal::getLocaleDataPtr()->getDate(aDT);
+ aTrackText += " ";
+ aTrackText += ScGlobal::getLocaleDataPtr()->getTime(aDT);
+ aTrackText += ":\n";
+ OUString aComStr = pFound->GetComment();
+ if(!aComStr.isEmpty())
+ {
+ aTrackText += aComStr;
+ aTrackText += "\n( ";
+ }
+ pFound->GetDescription( aTrackText, this );
+ if (!aComStr.isEmpty())
+ {
+ aTrackText += ")";
}
}
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 9c4ae4601948..ae51c8d22b5c 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -788,45 +788,45 @@ void ScDocument::CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc )
void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario )
{
- if (ValidTab(nSrcTab) && ValidTab(nDestTab) && nSrcTab < static_cast<SCTAB>(maTabs.size())
- && nDestTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nSrcTab] && maTabs[nDestTab])
+ if (!(ValidTab(nSrcTab) && ValidTab(nDestTab) && nSrcTab < static_cast<SCTAB>(maTabs.size())
+ && nDestTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nSrcTab] && maTabs[nDestTab]))
+ return;
+
+ // Set flags correctly for active scenarios
+ // and write current values back to recently active scenarios
+ ScRangeList aRanges = *maTabs[nSrcTab]->GetScenarioRanges();
+
+ // nDestTab is the target table
+ for ( SCTAB nTab = nDestTab+1;
+ nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && maTabs[nTab]->IsScenario();
+ nTab++ )
{
- // Set flags correctly for active scenarios
- // and write current values back to recently active scenarios
- ScRangeList aRanges = *maTabs[nSrcTab]->GetScenarioRanges();
-
- // nDestTab is the target table
- for ( SCTAB nTab = nDestTab+1;
- nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && maTabs[nTab]->IsScenario();
- nTab++ )
+ if ( maTabs[nTab]->IsActiveScenario() ) // Even if it's the same scenario
{
- if ( maTabs[nTab]->IsActiveScenario() ) // Even if it's the same scenario
+ bool bTouched = false;
+ for ( size_t nR=0, nRangeCount = aRanges.size(); nR < nRangeCount && !bTouched; nR++ )
{
- bool bTouched = false;
- for ( size_t nR=0, nRangeCount = aRanges.size(); nR < nRangeCount && !bTouched; nR++ )
- {
- const ScRange& rRange = aRanges[ nR ];
- if ( maTabs[nTab]->HasScenarioRange( rRange ) )
- bTouched = true;
- }
- if (bTouched)
- {
- maTabs[nTab]->SetActiveScenario(false);
- if ( maTabs[nTab]->GetScenarioFlags() & ScScenarioFlags::TwoWay )
- maTabs[nTab]->CopyScenarioFrom( maTabs[nDestTab].get() );
- }
+ const ScRange& rRange = aRanges[ nR ];
+ if ( maTabs[nTab]->HasScenarioRange( rRange ) )
+ bTouched = true;
+ }
+ if (bTouched)
+ {
+ maTabs[nTab]->SetActiveScenario(false);
+ if ( maTabs[nTab]->GetScenarioFlags() & ScScenarioFlags::TwoWay )
+ maTabs[nTab]->CopyScenarioFrom( maTabs[nDestTab].get() );
}
}
+ }
- maTabs[nSrcTab]->SetActiveScenario(true); // This is where it's from ...
- if (!bNewScenario) // Copy data from the selected scenario
- {
- sc::AutoCalcSwitch aACSwitch(*this, false);
- maTabs[nSrcTab]->CopyScenarioTo( maTabs[nDestTab].get() );
+ maTabs[nSrcTab]->SetActiveScenario(true); // This is where it's from ...
+ if (!bNewScenario) // Copy data from the selected scenario
+ {
+ sc::AutoCalcSwitch aACSwitch(*this, false);
+ maTabs[nSrcTab]->CopyScenarioTo( maTabs[nDestTab].get() );
- sc::SetFormulaDirtyContext aCxt;
- SetAllFormulasDirty(aCxt);
- }
+ sc::SetFormulaDirtyContext aCxt;
+ SetAllFormulasDirty(aCxt);
}
}
@@ -929,29 +929,29 @@ void ScDocument::RemoveUnoObject( SfxListener& rObject )
void ScDocument::BroadcastUno( const SfxHint &rHint )
{
- if (pUnoBroadcaster)
- {
- bInUnoBroadcast = true;
- pUnoBroadcaster->Broadcast( rHint );
- bInUnoBroadcast = false;
+ if (!pUnoBroadcaster)
+ return;
- // During Broadcast notification, Uno objects can add to pUnoListenerCalls.
- // The listener calls must be processed after completing the broadcast,
- // because they can add or remove objects from pUnoBroadcaster.
+ bInUnoBroadcast = true;
+ pUnoBroadcaster->Broadcast( rHint );
+ bInUnoBroadcast = false;
- if ( pUnoListenerCalls &&
- rHint.GetId() == SfxHintId::DataChanged &&
- !bInUnoListenerCall )
- {
- // Listener calls may lead to BroadcastUno calls again. The listener calls
- // are not nested, instead the calls are collected in the list, and the
- // outermost call executes them all.
-
- ScChartLockGuard aChartLockGuard(this);
- bInUnoListenerCall = true;
- pUnoListenerCalls->ExecuteAndClear();
- bInUnoListenerCall = false;
- }
+ // During Broadcast notification, Uno objects can add to pUnoListenerCalls.
+ // The listener calls must be processed after completing the broadcast,
+ // because they can add or remove objects from pUnoBroadcaster.
+
+ if ( pUnoListenerCalls &&
+ rHint.GetId() == SfxHintId::DataChanged &&
+ !bInUnoListenerCall )
+ {
+ // Listener calls may lead to BroadcastUno calls again. The listener calls
+ // are not nested, instead the calls are collected in the list, and the
+ // outermost call executes them all.
+
+ ScChartLockGuard aChartLockGuard(this);
+ bInUnoListenerCall = true;
+ pUnoListenerCalls->ExecuteAndClear();
+ bInUnoListenerCall = false;
}
}
@@ -1516,50 +1516,50 @@ void ScDocument::GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE&
void ScDocument::GetFilterEntries(
SCCOL nCol, SCROW nRow, SCTAB nTab, ScFilterEntries& rFilterEntries )
{
- if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && pDBCollection )
- {
- ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ScDBDataPortion::AREA); //!??
- if (pDBData)
- {
- pDBData->ExtendDataArea(this);
- SCTAB nAreaTab;
- SCCOL nStartCol;
- SCROW nStartRow;
- SCCOL nEndCol;
- SCROW nEndRow;
- pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ if ( !(ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && pDBCollection) )
+ return;
- if (pDBData->HasHeader())
- ++nStartRow;
+ ScDBData* pDBData = pDBCollection->GetDBAtCursor(nCol, nRow, nTab, ScDBDataPortion::AREA); //!??
+ if (!pDBData)
+ return;
- ScQueryParam aParam;
- pDBData->GetQueryParam( aParam );
+ pDBData->ExtendDataArea(this);
+ SCTAB nAreaTab;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
- // Return all filter entries, if a filter condition is connected with a boolean OR
- bool bFilter = true;
- SCSIZE nEntryCount = aParam.GetEntryCount();
- for ( SCSIZE i = 0; i < nEntryCount && aParam.GetEntry(i).bDoQuery; ++i )
- {
- ScQueryEntry& rEntry = aParam.GetEntry(i);
- if ( rEntry.eConnect != SC_AND )
- {
- bFilter = false;
- break;
- }
- }
+ if (pDBData->HasHeader())
+ ++nStartRow;
- if ( bFilter )
- {
- maTabs[nTab]->GetFilteredFilterEntries( nCol, nStartRow, nEndRow, aParam, rFilterEntries );
- }
- else
- {
- maTabs[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rFilterEntries );
- }
+ ScQueryParam aParam;
+ pDBData->GetQueryParam( aParam );
- sortAndRemoveDuplicates( rFilterEntries.maStrData, aParam.bCaseSens);
+ // Return all filter entries, if a filter condition is connected with a boolean OR
+ bool bFilter = true;
+ SCSIZE nEntryCount = aParam.GetEntryCount();
+ for ( SCSIZE i = 0; i < nEntryCount && aParam.GetEntry(i).bDoQuery; ++i )
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if ( rEntry.eConnect != SC_AND )
+ {
+ bFilter = false;
+ break;
}
}
+
+ if ( bFilter )
+ {
+ maTabs[nTab]->GetFilteredFilterEntries( nCol, nStartRow, nEndRow, aParam, rFilterEntries );
+ }
+ else
+ {
+ maTabs[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rFilterEntries );
+ }
+
+ sortAndRemoveDuplicates( rFilterEntries.maStrData, aParam.bCaseSens);
}
/**
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index 631f60c863fa..598643b7f473 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -53,23 +53,23 @@ static void lcl_GetChartParameters( const uno::Reference< chart2::XChartDocument
uno::Reference< chart2::data::XDataSource > xDataSource = xReceiver->getUsedData();
uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider();
- if ( xProvider.is() )
- {
- const uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xDataSource ) );
+ if ( !xProvider.is() )
+ return;
- for (const beans::PropertyValue& rProp : aArgs)
- {
- OUString aPropName(rProp.Name);
-
- if ( aPropName == "CellRangeRepresentation" )
- rProp.Value >>= rRanges;
- else if ( aPropName == "DataRowSource" )
- rDataRowSource = static_cast<chart::ChartDataRowSource>(ScUnoHelpFunctions::GetEnumFromAny( rProp.Value ));
- else if ( aPropName == "HasCategories" )
- rHasCategories = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
- else if ( aPropName == "FirstCellAsLabel" )
- rFirstCellAsLabel = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
- }
+ const uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xDataSource ) );
+
+ for (const beans::PropertyValue& rProp : aArgs)
+ {
+ OUString aPropName(rProp.Name);
+
+ if ( aPropName == "CellRangeRepresentation" )
+ rProp.Value >>= rRanges;
+ else if ( aPropName == "DataRowSource" )
+ rDataRowSource = static_cast<chart::ChartDataRowSource>(ScUnoHelpFunctions::GetEnumFromAny( rProp.Value ));
+ else if ( aPropName == "HasCategories" )
+ rHasCategories = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if ( aPropName == "FirstCellAsLabel" )
+ rFirstCellAsLabel = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
}
}
@@ -77,23 +77,23 @@ static void lcl_SetChartParameters( const uno::Reference< chart2::data::XDataRec
const OUString& rRanges, chart::ChartDataRowSource eDataRowSource,
bool bHasCategories, bool bFirstCellAsLabel )
{
- if ( xReceiver.is() )
- {
- uno::Sequence< beans::PropertyValue > aArgs( 4 );
- aArgs[0] = beans::PropertyValue(
- "CellRangeRepresentation", -1,
- uno::makeAny( rRanges ), beans::PropertyState_DIRECT_VALUE );
- aArgs[1] = beans::PropertyValue(
- "HasCategories", -1,
- uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
- aArgs[2] = beans::PropertyValue(
- "FirstCellAsLabel", -1,
- uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE );
- aArgs[3] = beans::PropertyValue(
- "DataRowSource", -1,
- uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE );
- xReceiver->setArguments( aArgs );
- }
+ if ( !xReceiver.is() )
+ return;
+
+ uno::Sequence< beans::PropertyValue > aArgs( 4 );
+ aArgs[0] = beans::PropertyValue(
+ "CellRangeRepresentation", -1,
+ uno::makeAny( rRanges ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[1] = beans::PropertyValue(
+ "HasCategories", -1,
+ uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[2] = beans::PropertyValue(
+ "FirstCellAsLabel", -1,
+ uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[3] = beans::PropertyValue(
+ "DataRowSource", -1,
+ uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE );
+ xReceiver->setArguments( aArgs );
}
bool ScDocument::HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName )
@@ -183,19 +183,19 @@ void ScDocument::GetChartRanges( const OUString& rChartName, ::std::vector< ScRa
void ScDocument::SetChartRanges( const OUString& rChartName, const ::std::vector< ScRangeList >& rRangesVector )
{
uno::Reference< chart2::XChartDocument > xChartDoc( GetChartByName( rChartName ) );
- if ( xChartDoc.is() )
+ if ( !xChartDoc.is() )
+ return;
+
+ sal_Int32 nCount = static_cast<sal_Int32>( rRangesVector.size() );
+ uno::Sequence< OUString > aRangeStrings(nCount);
+ for( sal_Int32 nN=0; nN<nCount; nN++ )
{
- sal_Int32 nCount = static_cast<sal_Int32>( rRangesVector.size() );
- uno::Sequence< OUString > aRangeStrings(nCount);
- for( sal_Int32 nN=0; nN<nCount; nN++ )
- {
- ScRangeList aScRangeList( rRangesVector[nN] );
- OUString sRangeStr;
- aScRangeList.Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
- aRangeStrings[nN]=sRangeStr;
- }
- ScChartHelper::SetChartRanges( xChartDoc, aRangeStrings );
+ ScRangeList aScRangeList( rRangesVector[nN] );
+ OUString sRangeStr;
+ aScRangeList.Format( sRangeStr, ScRefFlags::RANGE_ABS_3D, *this, GetAddressConvention() );
+ aRangeStrings[nN]=sRangeStr;
}
+ ScChartHelper::SetChartRanges( xChartDoc, aRangeStrings );
}
void ScDocument::GetOldChartParameters( const OUString& rName,
@@ -365,26 +365,26 @@ void ScDocument::RestoreChartListener( const OUString& rName )
// (called when a chart is saved, because then it might be swapped out and stop listening itself).
uno::Reference< embed::XEmbeddedObject > xObject = FindOleObjectByName( rName );
- if ( xObject.is() )
- {
- uno::Reference< util::XCloseable > xComponent = xObject->getComponent();
- uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY );
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xComponent, uno::UNO_QUERY );
- if ( xChartDoc.is() && xReceiver.is() && !xChartDoc->hasInternalDataProvider())
- {
- const uno::Sequence<OUString> aRepresentations( xReceiver->getUsedRangeRepresentations() );
- ScRangeListRef aRanges = new ScRangeList;
- for ( const auto& rRepresentation : aRepresentations )
- {
- ScRange aRange;
- ScAddress::Details aDetails(GetAddressConvention(), 0, 0);
- if ( aRange.ParseAny( rRepresentation, this, aDetails ) & ScRefFlags::VALID )
- aRanges->push_back( aRange );
- }
+ if ( !xObject.is() )
+ return;
- pChartListenerCollection->ChangeListening( rName, aRanges );
- }
+ uno::Reference< util::XCloseable > xComponent = xObject->getComponent();
+ uno::Reference< chart2::XChartDocument > xChartDoc( xComponent, uno::UNO_QUERY );
+ uno::Reference< chart2::data::XDataReceiver > xReceiver( xComponent, uno::UNO_QUERY );
+ if ( !(xChartDoc.is() && xReceiver.is() && !xChartDoc->hasInternalDataProvider()))
+ return;
+
+ const uno::Sequence<OUString> aRepresentations( xReceiver->getUsedRangeRepresentations() );
+ ScRangeListRef aRanges = new ScRangeList;
+ for ( const auto& rRepresentation : aRepresentations )
+ {
+ ScRange aRange;
+ ScAddress::Details aDetails(GetAddressConvention(), 0, 0);
+ if ( aRange.ParseAny( rRepresentation, this, aDetails ) & ScRefFlags::VALID )
+ aRanges->push_back( aRange );
}
+
+ pChartListenerCollection->ChangeListening( rName, aRanges );
}
void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode,
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 1cd90e5a74ae..a950e903f121 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -470,32 +470,32 @@ void ScDocument::RemoveFromFormulaTrack( ScFormulaCell* pCell )
ScFormulaCell* pPrev = pCell->GetPreviousTrack();
assert(pPrev != pCell); // pointing to itself?!?
// if the cell is first or somewhere in chain
- if ( pPrev || pFormulaTrack == pCell )
+ if ( !(pPrev || pFormulaTrack == pCell) )
+ return;
+
+ ScFormulaCell* pNext = pCell->GetNextTrack();
+ assert(pNext != pCell); // pointing to itself?!?
+ if ( pPrev )
{
- ScFormulaCell* pNext = pCell->GetNextTrack();
- assert(pNext != pCell); // pointing to itself?!?
- if ( pPrev )
- {
- assert(pFormulaTrack != pCell); // if this cell is also head something's wrong
- pPrev->SetNextTrack( pNext ); // predecessor exists, set successor
- }
- else
- {
- pFormulaTrack = pNext; // this cell was first cell
- }
- if ( pNext )
- {
- assert(pEOFormulaTrack != pCell); // if this cell is also tail something's wrong
- pNext->SetPreviousTrack( pPrev ); // successor exists, set predecessor
- }
- else
- {
- pEOFormulaTrack = pPrev; // this cell was last cell
- }
- pCell->SetPreviousTrack( nullptr );
- pCell->SetNextTrack( nullptr );
- --nFormulaTrackCount;
+ assert(pFormulaTrack != pCell); // if this cell is also head something's wrong
+ pPrev->SetNextTrack( pNext ); // predecessor exists, set successor
+ }
+ else
+ {
+ pFormulaTrack = pNext; // this cell was first cell
}
+ if ( pNext )
+ {
+ assert(pEOFormulaTrack != pCell); // if this cell is also tail something's wrong
+ pNext->SetPreviousTrack( pPrev ); // successor exists, set predecessor
+ }
+ else
+ {
+ pEOFormulaTrack = pPrev; // this cell was last cell
+ }
+ pCell->SetPreviousTrack( nullptr );
+ pCell->SetNextTrack( nullptr );
+ --nFormulaTrackCount;
}
bool ScDocument::IsInFormulaTrack( const ScFormulaCell* pCell ) const
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 312df8333f3b..9a6c090e413e 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -162,20 +162,20 @@ void ScDocument::SetPrintOptions()
if ( !mpPrinter ) GetPrinter(); // this sets mpPrinter
OSL_ENSURE( mpPrinter, "Error in printer creation :-/" );
- if ( mpPrinter )
- {
- SfxItemSet aOptSet( mpPrinter->GetOptions() );
+ if ( !mpPrinter )
+ return;
- SfxPrinterChangeFlags nFlags = SfxPrinterChangeFlags::NONE;
- if (officecfg::Office::Common::Print::Warning::PaperOrientation::get())
- nFlags |= SfxPrinterChangeFlags::CHG_ORIENTATION;
- if (officecfg::Office::Common::Print::Warning::PaperSize::get())
- nFlags |= SfxPrinterChangeFlags::CHG_SIZE;
- aOptSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlags) ) );
- aOptSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, officecfg::Office::Common::Print::Warning::NotFound::get() ) );
+ SfxItemSet aOptSet( mpPrinter->GetOptions() );
- mpPrinter->SetOptions( aOptSet );
- }
+ SfxPrinterChangeFlags nFlags = SfxPrinterChangeFlags::NONE;
+ if (officecfg::Office::Common::Print::Warning::PaperOrientation::get())
+ nFlags |= SfxPrinterChangeFlags::CHG_ORIENTATION;
+ if (officecfg::Office::Common::Print::Warning::PaperSize::get())
+ nFlags |= SfxPrinterChangeFlags::CHG_SIZE;
+ aOptSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlags) ) );
+ aOptSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, officecfg::Office::Common::Print::Warning::NotFound::get() ) );
+
+ mpPrinter->SetOptions( aOptSet );
}
VirtualDevice* ScDocument::GetVirtualDevice_100th_mm()
@@ -842,21 +842,21 @@ void ScDocument::UpdateExternalRefLinks(weld::Window* pWin)
pExternalRefMgr->enableDocTimer(true);
- if (bAny)
- {
- TrackFormulas();
- mpShell->Broadcast( SfxHint(SfxHintId::ScDataChanged) );
+ if (!bAny)
+ return;
- // #i101960# set document modified, as in TrackTimeHdl for DDE links
- if (!mpShell->IsModified())
+ TrackFormulas();
+ mpShell->Broadcast( SfxHint(SfxHintId::ScDataChanged) );
+
+ // #i101960# set document modified, as in TrackTimeHdl for DDE links
+ if (!mpShell->IsModified())
+ {
+ mpShell->SetModified();
+ SfxBindings* pBindings = GetViewBindings();
+ if (pBindings)
{
- mpShell->SetModified();
- SfxBindings* pBindings = GetViewBindings();
- if (pBindings)
- {
- pBindings->Invalidate( SID_SAVEDOC );
- pBindings->Invalidate( SID_DOC_MODIFIED );
- }
+ pBindings->Invalidate( SID_SAVEDOC );
+ pBindings->Invalidate( SID_DOC_MODIFIED );
}
}
}
@@ -1116,36 +1116,36 @@ void ScDocument::UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
}
}
- if ( bAnyUpdate )
- {
- // #i52120# Look for duplicates (after updating all positions).
- // If several links start at the same cell, the one with the lower index is removed
- // (file format specifies only one link definition for a cell).
+ if ( !bAnyUpdate )
+ return;
- sal_uInt16 nFirstIndex = 0;
- while ( nFirstIndex < nCount )
+ // #i52120# Look for duplicates (after updating all positions).
+ // If several links start at the same cell, the one with the lower index is removed
+ // (file format specifies only one link definition for a cell).
+
+ sal_uInt16 nFirstIndex = 0;
+ while ( nFirstIndex < nCount )
+ {
+ bool bFound = false;
+ ::sfx2::SvBaseLink* pFirst = rLinks[nFirstIndex].get();
+ if (ScAreaLink* pFirstLink = dynamic_cast<ScAreaLink*>(pFirst))
{
- bool bFound = false;
- ::sfx2::SvBaseLink* pFirst = rLinks[nFirstIndex].get();
- if (ScAreaLink* pFirstLink = dynamic_cast<ScAreaLink*>(pFirst))
+ ScAddress aFirstPos = pFirstLink->GetDestArea().aStart;
+ for ( sal_uInt16 nSecondIndex = nFirstIndex + 1; nSecondIndex < nCount && !bFound; ++nSecondIndex )
{
- ScAddress aFirstPos = pFirstLink->GetDestArea().aStart;
- for ( sal_uInt16 nSecondIndex = nFirstIndex + 1; nSecondIndex < nCount && !bFound; ++nSecondIndex )
+ ::sfx2::SvBaseLink* pSecond = rLinks[nSecondIndex].get();
+ ScAreaLink* pSecondLink = dynamic_cast<ScAreaLink*>(pSecond);
+ if (pSecondLink && pSecondLink->GetDestArea().aStart == aFirstPos)
{
- ::sfx2::SvBaseLink* pSecond = rLinks[nSecondIndex].get();
- ScAreaLink* pSecondLink = dynamic_cast<ScAreaLink*>(pSecond);
- if (pSecondLink && pSecondLink->GetDestArea().aStart == aFirstPos)
- {
- // remove the first link, exit the inner loop, don't increment nFirstIndex
- pMgr->Remove(pFirst);
- nCount = rLinks.size();
- bFound = true;
- }
+ // remove the first link, exit the inner loop, don't increment nFirstIndex
+ pMgr->Remove(pFirst);
+ nCount = rLinks.size();
+ bFound = true;
}
}
- if (!bFound)
- ++nFirstIndex;
}
+ if (!bFound)
+ ++nFirstIndex;
}
}
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index 8e6ac0aaea77..ee42ba27b14a 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -101,72 +101,72 @@ void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell )
mpShell = pDocShell;
}
- if (!mpDrawLayer)
+ if (mpDrawLayer)
+ return;
+
+ ScMutationGuard aGuard(this, ScMutationGuardFlags::CORE);
+ OUString aName;
+ if ( mpShell && !mpShell->IsLoading() ) // don't call GetTitle while loading
+ aName = mpShell->GetTitle();
+ mpDrawLayer.reset(new ScDrawLayer( this, aName ));
+
+ sfx2::LinkManager* pMgr = GetDocLinkManager().getLinkManager(bAutoCalc);
+ if (pMgr)
+ mpDrawLayer->SetLinkManager(pMgr);
+
+ // set DrawingLayer's SfxItemPool at Calc's SfxItemPool as
+ // secondary pool to support DrawingLayer FillStyle ranges (and similar)
+ // in SfxItemSets using the Calc SfxItemPool. This is e.g. needed when
+ // the PageStyle using SvxBrushItem is visualized and will be potentially
+ // used more intense in the future
+ if (mxPoolHelper.is() && !IsClipOrUndo()) //Using IsClipOrUndo as a proxy for SharePooledResources called
{
- ScMutationGuard aGuard(this, ScMutationGuardFlags::CORE);
- OUString aName;
- if ( mpShell && !mpShell->IsLoading() ) // don't call GetTitle while loading
- aName = mpShell->GetTitle();
- mpDrawLayer.reset(new ScDrawLayer( this, aName ));
-
- sfx2::LinkManager* pMgr = GetDocLinkManager().getLinkManager(bAutoCalc);
- if (pMgr)
- mpDrawLayer->SetLinkManager(pMgr);
-
- // set DrawingLayer's SfxItemPool at Calc's SfxItemPool as
- // secondary pool to support DrawingLayer FillStyle ranges (and similar)
- // in SfxItemSets using the Calc SfxItemPool. This is e.g. needed when
- // the PageStyle using SvxBrushItem is visualized and will be potentially
- // used more intense in the future
- if (mxPoolHelper.is() && !IsClipOrUndo()) //Using IsClipOrUndo as a proxy for SharePooledResources called
- {
- ScDocumentPool* pLocalPool = mxPoolHelper->GetDocPool();
+ ScDocumentPool* pLocalPool = mxPoolHelper->GetDocPool();
- if (pLocalPool)
- {
- OSL_ENSURE(!pLocalPool->GetSecondaryPool(), "OOps, already a secondary pool set where the DrawingLayer ItemPool is to be placed (!)");
- pLocalPool->SetSecondaryPool(&mpDrawLayer->GetItemPool());
- }
+ if (pLocalPool)
+ {
+ OSL_ENSURE(!pLocalPool->GetSecondaryPool(), "OOps, already a secondary pool set where the DrawingLayer ItemPool is to be placed (!)");
+ pLocalPool->SetSecondaryPool(&mpDrawLayer->GetItemPool());
}
+ }
- // Drawing pages are accessed by table number, so they must also be present
- // for preceding table numbers, even if the tables aren't allocated
- // (important for clipboard documents).
+ // Drawing pages are accessed by table number, so they must also be present
+ // for preceding table numbers, even if the tables aren't allocated
+ // (important for clipboard documents).
- SCTAB nDrawPages = 0;
- SCTAB nTab;
- for (nTab=0; nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
- if (maTabs[nTab])
- nDrawPages = nTab + 1; // needed number of pages
+ SCTAB nDrawPages = 0;
+ SCTAB nTab;
+ for (nTab=0; nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
+ if (maTabs[nTab])
+ nDrawPages = nTab + 1; // needed number of pages
- for (nTab=0; nTab<nDrawPages && nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
+ for (nTab=0; nTab<nDrawPages && nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
+ {
+ mpDrawLayer->ScAddPage( nTab ); // always add page, with or without the table
+ if (maTabs[nTab])
{
- mpDrawLayer->ScAddPage( nTab ); // always add page, with or without the table
- if (maTabs[nTab])
- {
- OUString aTabName = maTabs[nTab]->GetName();
- mpDrawLayer->ScRenamePage( nTab, aTabName );
+ OUString aTabName = maTabs[nTab]->GetName();
+ mpDrawLayer->ScRenamePage( nTab, aTabName );
- maTabs[nTab]->SetDrawPageSize(false,false); // set the right size immediately
- }
+ maTabs[nTab]->SetDrawPageSize(false,false); // set the right size immediately
}
+ }
- mpDrawLayer->SetDefaultTabulator( GetDocOptions().GetTabDistance() );
+ mpDrawLayer->SetDefaultTabulator( GetDocOptions().GetTabDistance() );
- UpdateDrawPrinter();
+ UpdateDrawPrinter();
- // set draw defaults directly
- SfxItemPool& rDrawPool = mpDrawLayer->GetItemPool();
- rDrawPool.SetPoolDefaultItem( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
+ // set draw defaults directly
+ SfxItemPool& rDrawPool = mpDrawLayer->GetItemPool();
+ rDrawPool.SetPoolDefaultItem( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
- UpdateDrawLanguages();
- if (bImportingXML)
- mpDrawLayer->EnableAdjust(false);
+ UpdateDrawLanguages();
+ if (bImportingXML)
+ mpDrawLayer->EnableAdjust(false);
- mpDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
- mpDrawLayer->SetCharCompressType( GetAsianCompression() );
- mpDrawLayer->SetKernAsianPunctuation( GetAsianKerning() );
- }
+ mpDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
+ mpDrawLayer->SetCharCompressType( GetAsianCompression() );
+ mpDrawLayer->SetKernAsianPunctuation( GetAsianKerning() );
}
void ScDocument::UpdateDrawLanguages()
@@ -550,27 +550,27 @@ void ScDocument::UpdateFontCharSet()
bool bUpdateOld = ( nSrcVer < SC_FONTCHARSET );
rtl_TextEncoding eSysSet = osl_getThreadTextEncoding();
- if ( eSrcSet != eSysSet || bUpdateOld )
+ if ( !(eSrcSet != eSysSet || bUpdateOld) )
+ return;
+
+ ScDocumentPool* pPool = mxPoolHelper->GetDocPool();
+ for (const SfxPoolItem* pItem : pPool->GetItemSurrogates(ATTR_FONT))
+ {
+ auto pFontItem = const_cast<SvxFontItem*>(dynamic_cast<const SvxFontItem*>(pItem));
+ if ( pFontItem && ( pFontItem->GetCharSet() == eSrcSet ||
+ ( bUpdateOld && pFontItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
+ pFontItem->SetCharSet(eSysSet);
+ }
+
+ if ( mpDrawLayer )
{
- ScDocumentPool* pPool = mxPoolHelper->GetDocPool();
- for (const SfxPoolItem* pItem : pPool->GetItemSurrogates(ATTR_FONT))
+ SfxItemPool& rDrawPool = mpDrawLayer->GetItemPool();
+ for (const SfxPoolItem* pItem : rDrawPool.GetItemSurrogates(EE_CHAR_FONTINFO))
{
- auto pFontItem = const_cast<SvxFontItem*>(dynamic_cast<const SvxFontItem*>(pItem));
+ SvxFontItem* pFontItem = const_cast<SvxFontItem*>(dynamic_cast<const SvxFontItem*>(pItem));
if ( pFontItem && ( pFontItem->GetCharSet() == eSrcSet ||
( bUpdateOld && pFontItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
- pFontItem->SetCharSet(eSysSet);
- }
-
- if ( mpDrawLayer )
- {
- SfxItemPool& rDrawPool = mpDrawLayer->GetItemPool();
- for (const SfxPoolItem* pItem : rDrawPool.GetItemSurrogates(EE_CHAR_FONTINFO))
- {
- SvxFontItem* pFontItem = const_cast<SvxFontItem*>(dynamic_cast<const SvxFontItem*>(pItem));
- if ( pFontItem && ( pFontItem->GetCharSet() == eSrcSet ||
- ( bUpdateOld && pFontItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
- pFontItem->SetCharSet( eSysSet );
- }
+ pFontItem->SetCharSet( eSysSet );
}
}
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 8f6eff2cc7d6..32154717bd29 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -166,25 +166,25 @@ typedef std::set<ScDefaultAttr, ScLessDefaultAttr> ScDefaultAttrSet;
void ScDocument::MakeTable( SCTAB nTab,bool _bNeedsNameCheck )
{
- if ( ValidTab(nTab) && ( nTab >= static_cast<SCTAB>(maTabs.size()) ||!maTabs[nTab]) )
+ if ( !(ValidTab(nTab) && ( nTab >= static_cast<SCTAB>(maTabs.size()) ||!maTabs[nTab])) )
+ return;
+
+ // Get Custom prefix
+ const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions();
+ OUString aString = rOpt.GetInitTabPrefix() + OUString::number(nTab+1);
+ if ( _bNeedsNameCheck )
+ CreateValidTabName( aString ); // no doubles
+ if (nTab < static_cast<SCTAB>(maTabs.size()))
{
- // Get Custom prefix
- const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions();
- OUString aString = rOpt.GetInitTabPrefix() + OUString::number(nTab+1);
- if ( _bNeedsNameCheck )
- CreateValidTabName( aString ); // no doubles
- if (nTab < static_cast<SCTAB>(maTabs.size()))
- {
- maTabs[nTab].reset( new ScTable(this, nTab, aString) );
- }
- else
- {
- while(nTab > static_cast<SCTAB>(maTabs.size()))
- maTabs.push_back(nullptr);
- maTabs.emplace_back( new ScTable(this, nTab, aString) );
- }
- maTabs[nTab]->SetLoadingMedium(bLoadingMedium);
+ maTabs[nTab].reset( new ScTable(this, nTab, aString) );
+ }
+ else
+ {
+ while(nTab > static_cast<SCTAB>(maTabs.size()))
+ maTabs.push_back(nullptr);
+ maTabs.emplace_back( new ScTable(this, nTab, aString) );
}
+ maTabs[nTab]->SetLoadingMedium(bLoadingMedium);
}
bool ScDocument::HasTable( SCTAB nTab ) const
@@ -948,45 +948,45 @@ void ScDocument::SetPendingRowHeights( SCTAB nTab, bool bSet )
void ScDocument::SetLayoutRTL( SCTAB nTab, bool bRTL )
{
- if ( ValidTab(nTab) && nTab < static_cast<SCTAB> (maTabs.size()) && maTabs[nTab] )
+ if ( !(ValidTab(nTab) && nTab < static_cast<SCTAB> (maTabs.size()) && maTabs[nTab]) )
+ return;
+
+ if ( bImportingXML )
{
- if ( bImportingXML )
- {
- // #i57869# only set the LoadingRTL flag, the real setting (including mirroring)
- // is applied in SetImportingXML(false). This is so the shapes can be loaded in
- // normal LTR mode.
+ // #i57869# only set the LoadingRTL flag, the real setting (including mirroring)
+ // is applied in SetImportingXML(false). This is so the shapes can be loaded in
+ // normal LTR mode.
- maTabs[nTab]->SetLoadingRTL( bRTL );
- return;
- }
+ maTabs[nTab]->SetLoadingRTL( bRTL );
+ return;
+ }
- maTabs[nTab]->SetLayoutRTL( bRTL ); // only sets the flag
- maTabs[nTab]->SetDrawPageSize();
+ maTabs[nTab]->SetLayoutRTL( bRTL ); // only sets the flag
+ maTabs[nTab]->SetDrawPageSize();
- // mirror existing objects:
+ // mirror existing objects:
- if (mpDrawLayer)
- {
- SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
- OSL_ENSURE(pPage,"Page ?");
- if (pPage)
- {
- SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
- SdrObject* pObject = aIter.Next();
- while (pObject)
- {
- // objects with ScDrawObjData are re-positioned in SetPageSize,
- // don't mirror again
- ScDrawObjData* pData = ScDrawLayer::GetObjData( pObject );
- if ( !pData )
- mpDrawLayer->MirrorRTL( pObject );
+ if (!mpDrawLayer)
+ return;
- pObject->SetContextWritingMode( bRTL ? WritingMode2::RL_TB : WritingMode2::LR_TB );
+ SdrPage* pPage = mpDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ OSL_ENSURE(pPage,"Page ?");
+ if (!pPage)
+ return;
- pObject = aIter.Next();
- }
- }
- }
+ SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ // objects with ScDrawObjData are re-positioned in SetPageSize,
+ // don't mirror again
+ ScDrawObjData* pData = ScDrawLayer::GetObjData( pObject );
+ if ( !pData )
+ mpDrawLayer->MirrorRTL( pObject );
+
+ pObject->SetContextWritingMode( bRTL ? WritingMode2::RL_TB : WritingMode2::LR_TB );
+
+ pObject = aIter.Next();
}
}
@@ -1155,19 +1155,19 @@ void ScDocument::LimitChartIfAll( ScRangeListRef& rRangeList )
static void lcl_GetFirstTabRange( SCTAB& rTabRangeStart, SCTAB& rTabRangeEnd, const ScMarkData* pTabMark, SCTAB aMaxTab )
{
// without ScMarkData, leave start/end unchanged
- if ( pTabMark )
- {
- for (SCTAB nTab=0; nTab< aMaxTab; ++nTab)
- if (pTabMark->GetTableSelect(nTab))
- {
- // find first range of consecutive selected sheets
- rTabRangeStart = pTabMark->GetFirstSelected();
- while ( nTab+1 < aMaxTab && pTabMark->GetTableSelect(nTab+1) )
- ++nTab;
- rTabRangeEnd = nTab;
- return;
- }
- }
+ if ( !pTabMark )
+ return;
+
+ for (SCTAB nTab=0; nTab< aMaxTab; ++nTab)
+ if (pTabMark->GetTableSelect(nTab))
+ {
+ // find first range of consecutive selected sheets
+ rTabRangeStart = pTabMark->GetFirstSelected();
+ while ( nTab+1 < aMaxTab && pTabMark->GetTableSelect(nTab+1) )
+ ++nTab;
+ rTabRangeEnd = nTab;
+ return;
+ }
}
static bool lcl_GetNextTabRange( SCTAB& rTabRangeStart, SCTAB& rTabRangeEnd, const ScMarkData* pTabMark, SCTAB aMaxTab )
@@ -1926,27 +1926,27 @@ void ScDocument::DeleteArea(
if ( rMark.GetTableSelect(i) || bIsUndo )
maTabs[i]->DeleteArea(nCol1, nRow1, nCol2, nRow2, nDelFlag, bBroadcast, pBroadcastSpans);
- if (bDelContent)
- {
- // Re-start listeners on those top bottom groups that have been split.
- SetNeedsListeningGroups(aGroupPos);
- StartNeededListeners();
+ if (!bDelContent)
+ return;
+
+ // Re-start listeners on those top bottom groups that have been split.
+ SetNeedsListeningGroups(aGroupPos);
+ StartNeededListeners();
+
+ // If formula groups were split their listeners were destroyed and may
+ // need to be notified now that they're restored, ScTable::DeleteArea()
+ // couldn't do that.
+ if (aGroupPos.empty())
+ return;
- // If formula groups were split their listeners were destroyed and may
- // need to be notified now that they're restored, ScTable::DeleteArea()
- // couldn't do that.
- if (!aGroupPos.empty())
+ ScRange aRange(nCol1, nRow1, 0, nCol2, nRow2, 0);
+ for (SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
+ {
+ if (rMark.GetTableSelect(i))
{
- ScRange aRange(nCol1, nRow1, 0, nCol2, nRow2, 0);
- for (SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
- {
- if (rMark.GetTableSelect(i))
- {
- aRange.aStart.SetTab(i);
- aRange.aEnd.SetTab(i);
- SetDirty( aRange, true);
- }
- }
+ aRange.aStart.SetTab(i);
+ aRange.aEnd.SetTab(i);
+ SetDirty( aRange, true);
}
}
}
@@ -2091,25 +2091,25 @@ void ScDocument::UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
PutInOrder( nCol1, nCol2 );
PutInOrder( nRow1, nRow2 );
PutInOrder( nTab1, nTab2 );
- if (ValidTab(nTab1) && ValidTab(nTab2))
- {
- sc::AutoCalcSwitch aACSwitch(rDestDoc, false); // avoid multiple calculations
+ if (!(ValidTab(nTab1) && ValidTab(nTab2)))
+ return;
- if (nTab1 > 0)
- CopyToDocument(0, 0, 0, MaxCol(), MaxRow(), nTab1-1, InsertDeleteFlags::FORMULA, false, rDestDoc);
+ sc::AutoCalcSwitch aACSwitch(rDestDoc, false); // avoid multiple calculations
- sc::CopyToDocContext aCxt(rDestDoc);
- assert( nTab2 < static_cast<SCTAB>(maTabs.size()) && nTab2 < static_cast<SCTAB>(rDestDoc.maTabs.size()));
- for (SCTAB i = nTab1; i <= nTab2; i++)
- {
- if (maTabs[i] && rDestDoc.maTabs[i])
- maTabs[i]->UndoToTable(aCxt, nCol1, nRow1, nCol2, nRow2, nFlags,
- bOnlyMarked, rDestDoc.maTabs[i].get());
- }
+ if (nTab1 > 0)
+ CopyToDocument(0, 0, 0, MaxCol(), MaxRow(), nTab1-1, InsertDeleteFlags::FORMULA, false, rDestDoc);
- if (nTab2 < MAXTAB)
- CopyToDocument(0, 0, nTab2+1, MaxCol(), MaxRow(), MAXTAB, InsertDeleteFlags::FORMULA, false, rDestDoc);
+ sc::CopyToDocContext aCxt(rDestDoc);
+ assert( nTab2 < static_cast<SCTAB>(maTabs.size()) && nTab2 < static_cast<SCTAB>(rDestDoc.maTabs.size()));
+ for (SCTAB i = nTab1; i <= nTab2; i++)
+ {
+ if (maTabs[i] && rDestDoc.maTabs[i])
+ maTabs[i]->UndoToTable(aCxt, nCol1, nRow1, nCol2, nRow2, nFlags,
+ bOnlyMarked, rDestDoc.maTabs[i].get());
}
+
+ if (nTab2 < MAXTAB)
+ CopyToDocument(0, 0, nTab2+1, MaxCol(), MaxRow(), MAXTAB, InsertDeleteFlags::FORMULA, false, rDestDoc);
}
void ScDocument::CopyToDocument(const ScRange& rRange,
@@ -2277,54 +2277,54 @@ void ScDocument::CopyTabToClip(SCCOL nCol1, SCROW nRow1,
SCCOL nCol2, SCROW nRow2,
SCTAB nTab, ScDocument* pClipDoc)
{
- if (!bIsClip)
+ if (bIsClip)
+ return;
+
+ if (!pClipDoc)
{
- if (!pClipDoc)
- {
- SAL_WARN("sc", "CopyTabToClip: no ClipDoc");
- pClipDoc = ScModule::GetClipDoc();
- }
+ SAL_WARN("sc", "CopyTabToClip: no ClipDoc");
+ pClipDoc = ScModule::GetClipDoc();
+ }
- if (mpShell->GetMedium())
- {
- pClipDoc->maFileURL = mpShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
- // for unsaved files use the title name and adjust during save of file
- if (pClipDoc->maFileURL.isEmpty())
- pClipDoc->maFileURL = mpShell->GetName();
- }
- else
- {
+ if (mpShell->GetMedium())
+ {
+ pClipDoc->maFileURL = mpShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
+ // for unsaved files use the title name and adjust during save of file
+ if (pClipDoc->maFileURL.isEmpty())
pClipDoc->maFileURL = mpShell->GetName();
- }
+ }
+ else
+ {
+ pClipDoc->maFileURL = mpShell->GetName();
+ }
- //init maTabNames
- for (const auto& rxTab : maTabs)
+ //init maTabNames
+ for (const auto& rxTab : maTabs)
+ {
+ if( rxTab )
{
- if( rxTab )
- {
- OUString aTabName = rxTab->GetName();
- pClipDoc->maTabNames.push_back(aTabName);
- }
- else
- pClipDoc->maTabNames.emplace_back();
+ OUString aTabName = rxTab->GetName();
+ pClipDoc->maTabNames.push_back(aTabName);
}
+ else
+ pClipDoc->maTabNames.emplace_back();
+ }
- PutInOrder( nCol1, nCol2 );
- PutInOrder( nRow1, nRow2 );
+ PutInOrder( nCol1, nCol2 );
+ PutInOrder( nRow1, nRow2 );
- ScClipParam& rClipParam = pClipDoc->GetClipParam();
- pClipDoc->aDocName = aDocName;
- rClipParam.maRanges.RemoveAll();
- rClipParam.maRanges.push_back(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0));
- pClipDoc->ResetClip( this, nTab );
+ ScClipParam& rClipParam = pClipDoc->GetClipParam();
+ pClipDoc->aDocName = aDocName;
+ rClipParam.maRanges.RemoveAll();
+ rClipParam.maRanges.push_back(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0));
+ pClipDoc->ResetClip( this, nTab );
- sc::CopyToClipContext aCxt(*pClipDoc, false);
- if (nTab < static_cast<SCTAB>(maTabs.size()) && nTab < static_cast<SCTAB>(pClipDoc->maTabs.size()))
- if (maTabs[nTab] && pClipDoc->maTabs[nTab])
- maTabs[nTab]->CopyToClip(aCxt, nCol1, nRow1, nCol2, nRow2, pClipDoc->maTabs[nTab].get());
+ sc::CopyToClipContext aCxt(*pClipDoc, false);
+ if (nTab < static_cast<SCTAB>(maTabs.size()) && nTab < static_cast<SCTAB>(pClipDoc->maTabs.size()))
+ if (maTabs[nTab] && pClipDoc->maTabs[nTab])
+ maTabs[nTab]->CopyToClip(aCxt, nCol1, nRow1, nCol2, nRow2, pClipDoc->maTabs[nTab].get());
- pClipDoc->GetClipParam().mbCutMode = false;
- }
+ pClipDoc->GetClipParam().mbCutMode = false;
}
void ScDocument::TransposeClip( ScDocument* pTransClip, InsertDeleteFlags nFlags, bool bAsLink )
@@ -2575,21 +2575,21 @@ void ScDocument::StartListeningFromClip( SCCOL nCol1, SCROW nRow1,
SCCOL nCol2, SCROW nRow2,
const ScMarkData& rMark, InsertDeleteFlags nInsFlag )
{
- if (nInsFlag & InsertDeleteFlags::CONTENTS)
- {
- auto pSet = std::make_shared<sc::ColumnBlockPositionSet>(*this);
+ if (!(nInsFlag & InsertDeleteFlags::CONTENTS))
+ return;
- sc::StartListeningContext aStartCxt(*this, pSet);
- sc::EndListeningContext aEndCxt(*this, pSet, nullptr);
+ auto pSet = std::make_shared<sc::ColumnBlockPositionSet>(*this);
- SCTAB nMax = static_cast<SCTAB>(maTabs.size());
- for (const auto& rTab : rMark)
- {
- if (rTab >= nMax)
- break;
- if (maTabs[rTab])
- maTabs[rTab]->StartListeningFormulaCells(aStartCxt, aEndCxt, nCol1, nRow1, nCol2, nRow2);
- }
+ sc::StartListeningContext aStartCxt(*this, pSet);
+ sc::EndListeningContext aEndCxt(*this, pSet, nullptr);
+
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ for (const auto& rTab : rMark)
+ {
+ if (rTab >= nMax)
+ break;
+ if (maTabs[rTab])
+ maTabs[rTab]->StartListeningFormulaCells(aStartCxt, aEndCxt, nCol1, nRow1, nCol2, nRow2);
}
}
@@ -2658,65 +2658,65 @@ void ScDocument::CopyBlockFromClip(
nClipTab = (nClipTab+1) % static_cast<SCTAB>(rClipTabs.size());
}
}
- if (rCxt.getInsertFlag() & InsertDeleteFlags::CONTENTS)
+ if (!(rCxt.getInsertFlag() & InsertDeleteFlags::CONTENTS))
+ return;
+
+ nClipTab = 0;
+ for (SCTAB i = rCxt.getTabStart(); i <= nTabEnd && i < static_cast<SCTAB>(maTabs.size()); i++)
{
- nClipTab = 0;
- for (SCTAB i = rCxt.getTabStart(); i <= nTabEnd && i < static_cast<SCTAB>(maTabs.size()); i++)
+ if (maTabs[i] && rMark.GetTableSelect(i) )
{
- if (maTabs[i] && rMark.GetTableSelect(i) )
+ while (!rClipTabs[nClipTab]) nClipTab = (nClipTab+1) % static_cast<SCTAB>(rClipTabs.size());
+ SCTAB nDz = i - nClipTab;
+
+ // ranges of consecutive selected tables (in clipboard and dest. doc)
+ // must be handled in one UpdateReference call
+ SCTAB nFollow = 0;
+ while ( i + nFollow < nTabEnd
+ && rMark.GetTableSelect( i + nFollow + 1 )
+ && nClipTab + nFollow < MAXTAB
+ && rClipTabs[(nClipTab + nFollow + 1) % static_cast<SCTAB>(rClipTabs.size())] )
+ ++nFollow;
+
+ sc::RefUpdateContext aRefCxt(*this);
+ aRefCxt.maRange = ScRange(nCol1, nRow1, i, nCol2, nRow2, i+nFollow);
+ aRefCxt.mnColDelta = nDx;
+ aRefCxt.mnRowDelta = nDy;
+ aRefCxt.mnTabDelta = nDz;
+ aRefCxt.setBlockPositionReference(rCxt.getBlockPositionSet()); // share mdds position caching
+ if (rCxt.getClipDoc()->GetClipParam().mbCutMode)
{
- while (!rClipTabs[nClipTab]) nClipTab = (nClipTab+1) % static_cast<SCTAB>(rClipTabs.size());
- SCTAB nDz = i - nClipTab;
-
- // ranges of consecutive selected tables (in clipboard and dest. doc)
- // must be handled in one UpdateReference call
- SCTAB nFollow = 0;
- while ( i + nFollow < nTabEnd
- && rMark.GetTableSelect( i + nFollow + 1 )
- && nClipTab + nFollow < MAXTAB
- && rClipTabs[(nClipTab + nFollow + 1) % static_cast<SCTAB>(rClipTabs.size())] )
- ++nFollow;
-
- sc::RefUpdateContext aRefCxt(*this);
- aRefCxt.maRange = ScRange(nCol1, nRow1, i, nCol2, nRow2, i+nFollow);
- aRefCxt.mnColDelta = nDx;
- aRefCxt.mnRowDelta = nDy;
- aRefCxt.mnTabDelta = nDz;
- aRefCxt.setBlockPositionReference(rCxt.getBlockPositionSet()); // share mdds position caching
- if (rCxt.getClipDoc()->GetClipParam().mbCutMode)
+ // Update references only if cut originates from the same
+ // document we are pasting into.
+ if (rCxt.getClipDoc()->GetPool() == GetPool())
{
- // Update references only if cut originates from the same
- // document we are pasting into.
- if (rCxt.getClipDoc()->GetPool() == GetPool())
- {
- bool bOldInserting = IsInsertingFromOtherDoc();
- SetInsertingFromOtherDoc( true);
- aRefCxt.meMode = URM_MOVE;
- UpdateReference(aRefCxt, rCxt.getUndoDoc(), false);
-
- // For URM_MOVE group listeners may have been removed,
- // re-establish them.
- if (!aRefCxt.maRegroupCols.empty())
- {
- /* TODO: holding the ColumnSet in a shared_ptr at
- * RefUpdateContext would eliminate the need of
- * copying it here. */
- auto pColSet = std::make_shared<sc::ColumnSet>( aRefCxt.maRegroupCols);
- StartNeededListeners( pColSet);
- }
+ bool bOldInserting = IsInsertingFromOtherDoc();
+ SetInsertingFromOtherDoc( true);
+ aRefCxt.meMode = URM_MOVE;
+ UpdateReference(aRefCxt, rCxt.getUndoDoc(), false);
- SetInsertingFromOtherDoc( bOldInserting);
+ // For URM_MOVE group listeners may have been removed,
+ // re-establish them.
+ if (!aRefCxt.maRegroupCols.empty())
+ {
+ /* TODO: holding the ColumnSet in a shared_ptr at
+ * RefUpdateContext would eliminate the need of
+ * copying it here. */
+ auto pColSet = std::make_shared<sc::ColumnSet>( aRefCxt.maRegroupCols);
+ StartNeededListeners( pColSet);
}
- }
- else
- {
- aRefCxt.meMode = URM_COPY;
- UpdateReference(aRefCxt, rCxt.getUndoDoc(), false);
- }
- nClipTab = (nClipTab+nFollow+1) % static_cast<SCTAB>(rClipTabs.size());
- i = sal::static_int_cast<SCTAB>( i + nFollow );
+ SetInsertingFromOtherDoc( bOldInserting);
+ }
}
+ else
+ {
+ aRefCxt.meMode = URM_COPY;
+ UpdateReference(aRefCxt, rCxt.getUndoDoc(), false);
+ }
+
+ nClipTab = (nClipTab+nFollow+1) % static_cast<SCTAB>(rClipTabs.size());
+ i = sal::static_int_cast<SCTAB>( i + nFollow );
}
}
}
@@ -3914,20 +3914,20 @@ void ScDocument::InterpretDirtyCells( const ScRangeList& rRanges )
void ScDocument::AddTableOpFormulaCell( ScFormulaCell* pCell )
{
- if (!m_TableOpList.empty())
+ if (m_TableOpList.empty())
+ return;
+
+ ScInterpreterTableOpParams *const p = m_TableOpList.back();
+ if ( p->bCollectNotifications )
{
- ScInterpreterTableOpParams *const p = m_TableOpList.back();
- if ( p->bCollectNotifications )
- {
- if ( p->bRefresh )
- { // refresh pointers only
- p->aNotifiedFormulaCells.push_back( pCell );
- }
- else
- { // init both, address and pointer
- p->aNotifiedFormulaCells.push_back( pCell );
- p->aNotifiedFormulaPos.push_back( pCell->aPos );
- }
+ if ( p->bRefresh )
+ { // refresh pointers only
+ p->aNotifiedFormulaCells.push_back( pCell );
+ }
+ else
+ { // init both, address and pointer
+ p->aNotifiedFormulaCells.push_back( pCell );
+ p->aNotifiedFormulaPos.push_back( pCell->aPos );
}
}
}
@@ -4660,43 +4660,43 @@ void ScDocument::GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& n
SCROW nStartRow;
SCROW nEndRow;
const ScPatternAttr* pAttr = aDocAttrItr.GetNext(nColumn, nStartRow, nEndRow);
- if (nEndRow < nLastRow)
+ if (nEndRow >= nLastRow)
+ return;
+
+ ScDefaultAttrSet aSet;
+ ScDefaultAttrSet::iterator aItr = aSet.end();
+ while (pAttr)
{
- ScDefaultAttrSet aSet;
- ScDefaultAttrSet::iterator aItr = aSet.end();
- while (pAttr)
+ ScDefaultAttr aAttr(pAttr);
+ aItr = aSet.find(aAttr);
+ if (aItr == aSet.end())
{
- ScDefaultAttr aAttr(pAttr);
- aItr = aSet.find(aAttr);
- if (aItr == aSet.end())
- {
- aAttr.nCount = static_cast<SCSIZE>(nEndRow - nStartRow + 1);
- aAttr.nFirst = nStartRow;
- aSet.insert(aAttr);
- }
- else
- {
- aAttr.nCount = aItr->nCount + static_cast<SCSIZE>(nEndRow - nStartRow + 1);
- aAttr.nFirst = aItr->nFirst;
- aSet.erase(aItr);
- aSet.insert(aAttr);
- }
- pAttr = aDocAttrItr.GetNext(nColumn, nStartRow, nEndRow);
+ aAttr.nCount = static_cast<SCSIZE>(nEndRow - nStartRow + 1);
+ aAttr.nFirst = nStartRow;
+ aSet.insert(aAttr);
}
- ScDefaultAttrSet::iterator aDefaultItr = aSet.begin();
- aItr = aDefaultItr;
- ++aItr;
- while (aItr != aSet.end())
+ else
{
- // for entries with equal count, use the one with the lowest start row,
- // don't use the random order of pointer comparisons
- if ( aItr->nCount > aDefaultItr->nCount ||
- ( aItr->nCount == aDefaultItr->nCount && aItr->nFirst < aDefaultItr->nFirst ) )
- aDefaultItr = aItr;
- ++aItr;
+ aAttr.nCount = aItr->nCount + static_cast<SCSIZE>(nEndRow - nStartRow + 1);
+ aAttr.nFirst = aItr->nFirst;
+ aSet.erase(aItr);
+ aSet.insert(aAttr);
}
- nDefault = aDefaultItr->nFirst;
+ pAttr = aDocAttrItr.GetNext(nColumn, nStartRow, nEndRow);
+ }
+ ScDefaultAttrSet::iterator aDefaultItr = aSet.begin();
+ aItr = aDefaultItr;
+ ++aItr;
+ while (aItr != aSet.end())
+ {
+ // for entries with equal count, use the one with the lowest start row,
+ // don't use the random order of pointer comparisons
+ if ( aItr->nCount > aDefaultItr->nCount ||
+ ( aItr->nCount == aDefaultItr->nCount && aItr->nFirst < aDefaultItr->nFirst ) )
+ aDefaultItr = aItr;
+ ++aItr;
}
+ nDefault = aDefaultItr->nFirst;
}
void ScDocument::StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab )
@@ -5622,25 +5622,25 @@ void ScDocument::ExtendTotalMerge( ScRange& rRange ) const
// Extend range to merged cells without including any new non-overlapped cells
ScRange aExt = rRange;
// ExtendMerge() is non-const, but called without refresh.
- if (const_cast<ScDocument*>(this)->ExtendMerge( aExt ))
- {
- if ( aExt.aEnd.Row() > rRange.aEnd.Row() )
- {
- ScRange aTest = aExt;
- aTest.aStart.SetRow( rRange.aEnd.Row() + 1 );
- if ( HasAttrib( aTest, HasAttrFlags::NotOverlapped ) )
- aExt.aEnd.SetRow(rRange.aEnd.Row());
- }
- if ( aExt.aEnd.Col() > rRange.aEnd.Col() )
- {
- ScRange aTest = aExt;
- aTest.aStart.SetCol( rRange.aEnd.Col() + 1 );
- if ( HasAttrib( aTest, HasAttrFlags::NotOverlapped ) )
- aExt.aEnd.SetCol(rRange.aEnd.Col());
- }
+ if (!const_cast<ScDocument*>(this)->ExtendMerge( aExt ))
+ return;
- rRange = aExt;
+ if ( aExt.aEnd.Row() > rRange.aEnd.Row() )
+ {
+ ScRange aTest = aExt;
+ aTest.aStart.SetRow( rRange.aEnd.Row() + 1 );
+ if ( HasAttrib( aTest, HasAttrFlags::NotOverlapped ) )
+ aExt.aEnd.SetRow(rRange.aEnd.Row());
+ }
+ if ( aExt.aEnd.Col() > rRange.aEnd.Col() )
+ {
+ ScRange aTest = aExt;
+ aTest.aStart.SetCol( rRange.aEnd.Col() + 1 );
+ if ( HasAttrib( aTest, HasAttrFlags::NotOverlapped ) )
+ aExt.aEnd.SetCol(rRange.aEnd.Col());
}
+
+ rRange = aExt;
}
void ScDocument::ExtendOverlapped( ScRange& rRange ) const
@@ -5776,85 +5776,85 @@ void ScDocument::ApplySelectionFrame( const ScMarkData& rMark,
}
}
}
- if (rLineOuter.IsRemoveAdjacentCellBorder())
- {
- SvxBoxItem aTmp0(rLineOuter);
- aTmp0.SetLine( nullptr, SvxBoxItemLine::TOP );
- aTmp0.SetLine( nullptr, SvxBoxItemLine::BOTTOM );
- aTmp0.SetLine( nullptr, SvxBoxItemLine::LEFT );
- aTmp0.SetLine( nullptr, SvxBoxItemLine::RIGHT );
- SvxBoxItem aLeft( aTmp0 );
- SvxBoxItem aRight( aTmp0 );
- SvxBoxItem aTop( aTmp0 );
- SvxBoxItem aBottom( aTmp0 );
-
- SvxBoxInfoItem aTmp1( *pLineInner );
- aTmp1.SetTable( false );
- aTmp1.SetLine( nullptr, SvxBoxInfoItemLine::HORI );
- aTmp1.SetLine( nullptr, SvxBoxInfoItemLine::VERT );
- aTmp1.SetValid( SvxBoxInfoItemValidFlags::ALL, false );
- aTmp1.SetValid( SvxBoxInfoItemValidFlags::DISTANCE );
- SvxBoxInfoItem aLeftInfo( aTmp1 );
- SvxBoxInfoItem aRightInfo( aTmp1 );
- SvxBoxInfoItem aTopInfo( aTmp1 );
- SvxBoxInfoItem aBottomInfo( aTmp1 );
-
- if (pLineInner->IsValid( SvxBoxInfoItemValidFlags::TOP ) && !rLineOuter.GetTop())
- aTopInfo.SetValid( SvxBoxInfoItemValidFlags::BOTTOM );
-
- if (pLineInner->IsValid( SvxBoxInfoItemValidFlags::BOTTOM ) && !rLineOuter.GetBottom())
- aBottomInfo.SetValid( SvxBoxInfoItemValidFlags::TOP );
-
- if (pLineInner->IsValid( SvxBoxInfoItemValidFlags::LEFT ) && !rLineOuter.GetLeft())
- aLeftInfo.SetValid( SvxBoxInfoItemValidFlags::RIGHT );
-
- if (pLineInner->IsValid( SvxBoxInfoItemValidFlags::RIGHT ) && !rLineOuter.GetRight())
- aRightInfo.SetValid( SvxBoxInfoItemValidFlags::LEFT );
-
- const ScRangeList& rRangeListTopEnvelope = rMark.GetTopEnvelope();
- const ScRangeList& rRangeListBottomEnvelope = rMark.GetBottomEnvelope();
- const ScRangeList& rRangeListLeftEnvelope = rMark.GetLeftEnvelope();
- const ScRangeList& rRangeListRightEnvelope = rMark.GetRightEnvelope();
+ if (!rLineOuter.IsRemoveAdjacentCellBorder())
+ return;
- for (const auto& rTab : rMark)
- {
- if (rTab >= nMax)
- break;
+ SvxBoxItem aTmp0(rLineOuter);
+ aTmp0.SetLine( nullptr, SvxBoxItemLine::TOP );
+ aTmp0.SetLine( nullptr, SvxBoxItemLine::BOTTOM );
+ aTmp0.SetLine( nullptr, SvxBoxItemLine::LEFT );
+ aTmp0.SetLine( nullptr, SvxBoxItemLine::RIGHT );
+ SvxBoxItem aLeft( aTmp0 );
+ SvxBoxItem aRight( aTmp0 );
+ SvxBoxItem aTop( aTmp0 );
+ SvxBoxItem aBottom( aTmp0 );
+
+ SvxBoxInfoItem aTmp1( *pLineInner );
+ aTmp1.SetTable( false );
+ aTmp1.SetLine( nullptr, SvxBoxInfoItemLine::HORI );
+ aTmp1.SetLine( nullptr, SvxBoxInfoItemLine::VERT );
+ aTmp1.SetValid( SvxBoxInfoItemValidFlags::ALL, false );
+ aTmp1.SetValid( SvxBoxInfoItemValidFlags::DISTANCE );
+ SvxBoxInfoItem aLeftInfo( aTmp1 );
+ SvxBoxInfoItem aRightInfo( aTmp1 );
+ SvxBoxInfoItem aTopInfo( aTmp1 );
+ SvxBoxInfoItem aBottomInfo( aTmp1 );
+
+ if (pLineInner->IsValid( SvxBoxInfoItemValidFlags::TOP ) && !rLineOuter.GetTop())
+ aTopInfo.SetValid( SvxBoxInfoItemValidFlags::BOTTOM );
+
+ if (pLineInner->IsValid( SvxBoxInfoItemValidFlags::BOTTOM ) && !rLineOuter.GetBottom())
+ aBottomInfo.SetValid( SvxBoxInfoItemValidFlags::TOP );
+
+ if (pLineInner->IsValid( SvxBoxInfoItemValidFlags::LEFT ) && !rLineOuter.GetLeft())
+ aLeftInfo.SetValid( SvxBoxInfoItemValidFlags::RIGHT );
+
+ if (pLineInner->IsValid( SvxBoxInfoItemValidFlags::RIGHT ) && !rLineOuter.GetRight())
+ aRightInfo.SetValid( SvxBoxInfoItemValidFlags::LEFT );
+
+ const ScRangeList& rRangeListTopEnvelope = rMark.GetTopEnvelope();
+ const ScRangeList& rRangeListBottomEnvelope = rMark.GetBottomEnvelope();
+ const ScRangeList& rRangeListLeftEnvelope = rMark.GetLeftEnvelope();
+ const ScRangeList& rRangeListRightEnvelope = rMark.GetRightEnvelope();
- if ( maTabs[rTab] )
+ for (const auto& rTab : rMark)
+ {
+ if (rTab >= nMax)
+ break;
+
+ if ( maTabs[rTab] )
+ {
+ size_t nEnvelopeRangeCount = rRangeListTopEnvelope.size();
+ for ( size_t j=0; j < nEnvelopeRangeCount; j++ )
{
- size_t nEnvelopeRangeCount = rRangeListTopEnvelope.size();
- for ( size_t j=0; j < nEnvelopeRangeCount; j++ )
- {
- const ScRange & rRange = rRangeListTopEnvelope[ j ];
- maTabs[rTab]->ApplyBlockFrame( aTop, &aTopInfo,
- rRange.aStart.Col(), rRange.aStart.Row(),
- rRange.aEnd.Col(), rRange.aEnd.Row() );
- }
- nEnvelopeRangeCount = rRangeListBottomEnvelope.size();
- for ( size_t j=0; j < nEnvelopeRangeCount; j++ )
- {
- const ScRange & rRange = rRangeListBottomEnvelope[ j ];
- maTabs[rTab]->ApplyBlockFrame( aBottom, &aBottomInfo,
- rRange.aStart.Col(), rRange.aStart.Row(),
- rRange.aEnd.Col(), rRange.aEnd.Row() );
- }
- nEnvelopeRangeCount = rRangeListLeftEnvelope.size();
- for ( size_t j=0; j < nEnvelopeRangeCount; j++ )
- {
- const ScRange & rRange = rRangeListLeftEnvelope[ j ];
- maTabs[rTab]->ApplyBlockFrame( aLeft, &aLeftInfo,
- rRange.aStart.Col(), rRange.aStart.Row(),
- rRange.aEnd.Col(), rRange.aEnd.Row() );
- }
- nEnvelopeRangeCount = rRangeListRightEnvelope.size();
- for ( size_t j=0; j < nEnvelopeRangeCount; j++ )
- {
- const ScRange & rRange = rRangeListRightEnvelope[ j ];
- maTabs[rTab]->ApplyBlockFrame( aRight, &aRightInfo,
- rRange.aStart.Col(), rRange.aStart.Row(),
- rRange.aEnd.Col(), rRange.aEnd.Row() );
- }
+ const ScRange & rRange = rRangeListTopEnvelope[ j ];
+ maTabs[rTab]->ApplyBlockFrame( aTop, &aTopInfo,
+ rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row() );
+ }
+ nEnvelopeRangeCount = rRangeListBottomEnvelope.size();
+ for ( size_t j=0; j < nEnvelopeRangeCount; j++ )
+ {
+ const ScRange & rRange = rRangeListBottomEnvelope[ j ];
+ maTabs[rTab]->ApplyBlockFrame( aBottom, &aBottomInfo,
+ rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row() );
+ }
+ nEnvelopeRangeCount = rRangeListLeftEnvelope.size();
+ for ( size_t j=0; j < nEnvelopeRangeCount; j++ )
+ {
+ const ScRange & rRange = rRangeListLeftEnvelope[ j ];
+ maTabs[rTab]->ApplyBlockFrame( aLeft, &aLeftInfo,
+ rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row() );
+ }
+ nEnvelopeRangeCount = rRangeListRightEnvelope.size();
+ for ( size_t j=0; j < nEnvelopeRangeCount; j++ )
+ {
+ const ScRange & rRange = rRangeListRightEnvelope[ j ];
+ maTabs[rTab]->ApplyBlockFrame( aRight, &aRightInfo,
+ rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row() );
}
}
}
@@ -5882,27 +5882,27 @@ void ScDocument::ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMark
if (pSet->GetItemState(i) == SfxItemState::SET)
bSet = true;
- if (bSet)
+ if (!bSet)
+ return;
+
+ // ApplySelectionCache needs multi mark
+ if ( rMark.IsMarked() && !rMark.IsMultiMarked() )
{
- // ApplySelectionCache needs multi mark
- if ( rMark.IsMarked() && !rMark.IsMultiMarked() )
- {
- ScRange aRange;
- rMark.GetMarkArea( aRange );
- ApplyPatternArea( aRange.aStart.Col(), aRange.aStart.Row(),
- aRange.aEnd.Col(), aRange.aEnd.Row(), rMark, rAttr, pDataArray, pIsChanged );
- }
- else
+ ScRange aRange;
+ rMark.GetMarkArea( aRange );
+ ApplyPatternArea( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), rMark, rAttr, pDataArray, pIsChanged );
+ }
+ else
+ {
+ SfxItemPoolCache aCache( mxPoolHelper->GetDocPool(), pSet );
+ SCTAB nMax = static_cast<SCTAB>(maTabs.size());
+ for (const auto& rTab : rMark)
{
- SfxItemPoolCache aCache( mxPoolHelper->GetDocPool(), pSet );
- SCTAB nMax = static_cast<SCTAB>(maTabs.size());
- for (const auto& rTab : rMark)
- {
- if (rTab >= nMax)
- break;
- if (maTabs[rTab])
- maTabs[rTab]->ApplySelectionCache( &aCache, rMark, pDataArray, pIsChanged );
- }
+ if (rTab >= nMax)
+ break;
+ if (maTabs[rTab])
+ maTabs[rTab]->ApplySelectionCache( &aCache, rMark, pDataArray, pIsChanged );
}
}
}
@@ -5962,30 +5962,30 @@ void ScDocument::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData&
maTabs[rTab]->DeleteSelection(nDelFlag, rMark, bBroadcast);
}
- if (bDelContent)
- {
- // Re-start listeners on those top bottom groups that have been split.
- SetNeedsListeningGroups(aGroupPos);
- StartNeededListeners();
+ if (!bDelContent)
+ return;
- // If formula groups were split their listeners were destroyed and may
- // need to be notified now that they're restored,
- // ScTable::DeleteSelection() couldn't do that.
- if (!aGroupPos.empty())
- {
- ScRangeList aRangeList;
- rMark.FillRangeListWithMarks( &aRangeList, false);
- for (size_t i = 0; i < aRangeList.size(); ++i)
- {
- SetDirty( aRangeList[i], true);
- }
- //Notify listeners on top and bottom of the group that has been split
- for (size_t i = 0; i < aGroupPos.size(); ++i) {
- ScFormulaCell *pFormulaCell = GetFormulaCell(aGroupPos[i]);
- if (pFormulaCell)
- pFormulaCell->SetDirty(true);
- }
- }
+ // Re-start listeners on those top bottom groups that have been split.
+ SetNeedsListeningGroups(aGroupPos);
+ StartNeededListeners();
+
+ // If formula groups were split their listeners were destroyed and may
+ // need to be notified now that they're restored,
+ // ScTable::DeleteSelection() couldn't do that.
+ if (aGroupPos.empty())
+ return;
+
+ ScRangeList aRangeList;
+ rMark.FillRangeListWithMarks( &aRangeList, false);
+ for (size_t i = 0; i < aRangeList.size(); ++i)
+ {
+ SetDirty( aRangeList[i], true);
+ }
+ //Notify listeners on top and bottom of the group that has been split
+ for (size_t i = 0; i < aGroupPos.size(); ++i) {
+ ScFormulaCell *pFormulaCell = GetFormulaCell(aGroupPos[i]);
+ if (pFormulaCell)
+ pFormulaCell->SetDirty(true);
}
}
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 41f84bd26a08..75571930fffb 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -702,23 +702,23 @@ public:
std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
mpImpl->miPos = mpImpl->maAttrs.set(mpImpl->miPos, node.position, aDefaults.begin(), aDefaults.end());
- if (node.type == sc::element_type_formula)
+ if (node.type != sc::element_type_formula)
+ return;
+
+ // Have all formula cells start listening to the document.
+ ScFormulaCell** pp = &sc::formula_block::at(*node.data, 0);
+ ScFormulaCell** ppEnd = pp + node.size;
+ for (; pp != ppEnd; ++pp)
{
- // Have all formula cells start listening to the document.
- ScFormulaCell** pp = &sc::formula_block::at(*node.data, 0);
- ScFormulaCell** ppEnd = pp + node.size;
- for (; pp != ppEnd; ++pp)
+ ScFormulaCell& rFC = **pp;
+ if (rFC.IsSharedTop())
{
- ScFormulaCell& rFC = **pp;
- if (rFC.IsSharedTop())
- {
- // Register formula cells as a group.
- sc::SharedFormulaUtil::startListeningAsGroup(mrDocImpl.maListenCxt, pp);
- pp += rFC.GetSharedLength() - 1; // Move to the last one in the group.
- }
- else
- rFC.StartListeningTo(mrDocImpl.maListenCxt);
+ // Register formula cells as a group.
+ sc::SharedFormulaUtil::startListeningAsGroup(mrDocImpl.maListenCxt, pp);
+ pp += rFC.GetSharedLength() - 1; // Move to the last one in the group.
}
+ else
+ rFC.StartListeningTo(mrDocImpl.maListenCxt);
}
}
diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx
index 3930a6e00554..8df2a547eaa6 100644
--- a/sc/source/core/data/dpdimsave.cxx
+++ b/sc/source/core/data/dpdimsave.cxx
@@ -340,25 +340,25 @@ void fillDateGroupDimension(
void ScDPSaveGroupDimension::AddToData( ScDPGroupTableData& rData ) const
{
long nSourceIndex = rData.GetDimensionIndex( aSourceDim );
- if ( nSourceIndex >= 0 )
- {
- ScDPGroupDimension aDim( nSourceIndex, aGroupDimName );
- if ( nDatePart )
- {
- // date grouping
+ if ( nSourceIndex < 0 )
+ return;
- aDim.SetDateDimension();
- }
- else
- {
- // normal (manual) grouping
+ ScDPGroupDimension aDim( nSourceIndex, aGroupDimName );
+ if ( nDatePart )
+ {
+ // date grouping
- for (const auto& rGroup : aGroups)
- rGroup.AddToData(aDim);
- }
+ aDim.SetDateDimension();
+ }
+ else
+ {
+ // normal (manual) grouping
- rData.AddGroupDimension( aDim );
+ for (const auto& rGroup : aGroups)
+ rGroup.AddToData(aDim);
}
+
+ rData.AddGroupDimension( aDim );
}
void ScDPSaveGroupDimension::AddToCache(ScDPCache& rCache) const
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 1821f825b59b..7c4bc44e967f 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -521,36 +521,36 @@ uno::Reference<sheet::XDimensionsSupplier> const & ScDPObject::GetSource()
void ScDPObject::CreateOutput()
{
CreateObjects();
- if (!pOutput)
- {
- bool bFilterButton = IsSheetData() && pSaveData && pSaveData->GetFilterButton();
- pOutput.reset( new ScDPOutput( pDoc, xSource, aOutRange.aStart, bFilterButton ) );
- pOutput->SetHeaderLayout ( mbHeaderLayout );
+ if (pOutput)
+ return;
- long nOldRows = nHeaderRows;
- nHeaderRows = pOutput->GetHeaderRows();
+ bool bFilterButton = IsSheetData() && pSaveData && pSaveData->GetFilterButton();
+ pOutput.reset( new ScDPOutput( pDoc, xSource, aOutRange.aStart, bFilterButton ) );
+ pOutput->SetHeaderLayout ( mbHeaderLayout );
- if ( bAllowMove && nHeaderRows != nOldRows )
- {
- long nDiff = nOldRows - nHeaderRows;
- if ( nOldRows == 0 )
- --nDiff;
- if ( nHeaderRows == 0 )
- ++nDiff;
+ long nOldRows = nHeaderRows;
+ nHeaderRows = pOutput->GetHeaderRows();
- long nNewRow = aOutRange.aStart.Row() + nDiff;
- if ( nNewRow < 0 )
- nNewRow = 0;
+ if ( !(bAllowMove && nHeaderRows != nOldRows) )
+ return;
- ScAddress aStart( aOutRange.aStart );
- aStart.SetRow(nNewRow);
- pOutput->SetPosition( aStart );
+ long nDiff = nOldRows - nHeaderRows;
+ if ( nOldRows == 0 )
+ --nDiff;
+ if ( nHeaderRows == 0 )
+ ++nDiff;
- //TODO: modify aOutRange?
+ long nNewRow = aOutRange.aStart.Row() + nDiff;
+ if ( nNewRow < 0 )
+ nNewRow = 0;
- bAllowMove = false; // use only once
- }
- }
+ ScAddress aStart( aOutRange.aStart );
+ aStart.SetRow(nNewRow);
+ pOutput->SetPosition( aStart );
+
+ //TODO: modify aOutRange?
+
+ bAllowMove = false; // use only once
}
namespace {
@@ -1065,44 +1065,44 @@ void ScDPObject::UpdateReference( UpdateRefMode eUpdateRefMode,
// sheet source data
- if ( pSheetDesc )
- {
- const OUString& rRangeName = pSheetDesc->GetRangeName();
- if (!rRangeName.isEmpty())
- // Source range is a named range. No need to update.
- return;
+ if ( !pSheetDesc )
+ return;
- const ScRange& rSrcRange = pSheetDesc->GetSourceRange();
- nCol1 = rSrcRange.aStart.Col();
- nRow1 = rSrcRange.aStart.Row();
- nTab1 = rSrcRange.aStart.Tab();
- nCol2 = rSrcRange.aEnd.Col();
- nRow2 = rSrcRange.aEnd.Row();
- nTab2 = rSrcRange.aEnd.Tab();
-
- eRes = ScRefUpdate::Update( pDoc, eUpdateRefMode,
- rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
- rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
- nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
- if ( eRes != UR_NOTHING )
- {
- SCCOL nDiffX = nCol1 - pSheetDesc->GetSourceRange().aStart.Col();
- SCROW nDiffY = nRow1 - pSheetDesc->GetSourceRange().aStart.Row();
-
- ScQueryParam aParam = pSheetDesc->GetQueryParam();
- aParam.nCol1 = sal::static_int_cast<SCCOL>( aParam.nCol1 + nDiffX );
- aParam.nCol2 = sal::static_int_cast<SCCOL>( aParam.nCol2 + nDiffX );
- aParam.nRow1 += nDiffY; //TODO: used?
- aParam.nRow2 += nDiffY; //TODO: used?
- SCSIZE nEC = aParam.GetEntryCount();
- for (SCSIZE i=0; i<nEC; i++)
- if (aParam.GetEntry(i).bDoQuery)
- aParam.GetEntry(i).nField += nDiffX;
-
- pSheetDesc->SetQueryParam(aParam);
- pSheetDesc->SetSourceRange(ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2));
- }
- }
+ const OUString& rRangeName = pSheetDesc->GetRangeName();
+ if (!rRangeName.isEmpty())
+ // Source range is a named range. No need to update.
+ return;
+
+ const ScRange& rSrcRange = pSheetDesc->GetSourceRange();
+ nCol1 = rSrcRange.aStart.Col();
+ nRow1 = rSrcRange.aStart.Row();
+ nTab1 = rSrcRange.aStart.Tab();
+ nCol2 = rSrcRange.aEnd.Col();
+ nRow2 = rSrcRange.aEnd.Row();
+ nTab2 = rSrcRange.aEnd.Tab();
+
+ eRes = ScRefUpdate::Update( pDoc, eUpdateRefMode,
+ rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
+ rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(), nDx, nDy, nDz,
+ nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+ if ( eRes == UR_NOTHING )
+ return;
+
+ SCCOL nDiffX = nCol1 - pSheetDesc->GetSourceRange().aStart.Col();
+ SCROW nDiffY = nRow1 - pSheetDesc->GetSourceRange().aStart.Row();
+
+ ScQueryParam aParam = pSheetDesc->GetQueryParam();
+ aParam.nCol1 = sal::static_int_cast<SCCOL>( aParam.nCol1 + nDiffX );
+ aParam.nCol2 = sal::static_int_cast<SCCOL>( aParam.nCol2 + nDiffX );
+ aParam.nRow1 += nDiffY; //TODO: used?
+ aParam.nRow2 += nDiffY; //TODO: used?
+ SCSIZE nEC = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nEC; i++)
+ if (aParam.GetEntry(i).bDoQuery)
+ aParam.GetEntry(i).nField += nDiffX;
+
+ pSheetDesc->SetQueryParam(aParam);
+ pSheetDesc->SetSourceRange(ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2));
}
bool ScDPObject::RefsEqual( const ScDPObject& r ) const
@@ -2306,25 +2306,25 @@ void ScDPObject::FillOldParam(ScPivotParam& rParam) const
rParam.maDataFields, xSource, sheet::DataPilotFieldOrientation_DATA, false);
uno::Reference<beans::XPropertySet> xProp( xSource, uno::UNO_QUERY );
- if (xProp.is())
+ if (!xProp.is())
+ return;
+
+ try
{
- try
- {
- rParam.bMakeTotalCol = ScUnoHelpFunctions::GetBoolProperty( xProp,
- SC_UNO_DP_COLGRAND, true );
- rParam.bMakeTotalRow = ScUnoHelpFunctions::GetBoolProperty( xProp,
- SC_UNO_DP_ROWGRAND, true );
-
- // following properties may be missing for external sources
- rParam.bIgnoreEmptyRows = ScUnoHelpFunctions::GetBoolProperty( xProp,
- SC_UNO_DP_IGNOREEMPTY );
- rParam.bDetectCategories = ScUnoHelpFunctions::GetBoolProperty( xProp,
- SC_UNO_DP_REPEATEMPTY );
- }
- catch(uno::Exception&)
- {
- // no error
- }
+ rParam.bMakeTotalCol = ScUnoHelpFunctions::GetBoolProperty( xProp,
+ SC_UNO_DP_COLGRAND, true );
+ rParam.bMakeTotalRow = ScUnoHelpFunctions::GetBoolProperty( xProp,
+ SC_UNO_DP_ROWGRAND, true );
+
+ // following properties may be missing for external sources
+ rParam.bIgnoreEmptyRows = ScUnoHelpFunctions::GetBoolProperty( xProp,
+ SC_UNO_DP_IGNOREEMPTY );
+ rParam.bDetectCategories = ScUnoHelpFunctions::GetBoolProperty( xProp,
+ SC_UNO_DP_REPEATEMPTY );
+ }
+ catch(uno::Exception&)
+ {
+ // no error
}
}
@@ -2417,20 +2417,20 @@ void ScDPObject::FillLabelDataForDimension(
rLabelData.mbDataLayout = bData;
rLabelData.mbIsValue = true; //TODO: check
- if (!bData)
- {
- rLabelData.mnOriginalDim = static_cast<long>(nOrigPos);
- rLabelData.maLayoutName = aLayoutName;
- rLabelData.maSubtotalName = aSubtotalName;
- if (nOrigPos >= 0)
- // This is a duplicated dimension. Use the original dimension index.
- nDim = nOrigPos;
- GetHierarchies(nDim, rLabelData.maHiers);
- GetMembers(nDim, GetUsedHierarchy(nDim), rLabelData.maMembers);
- lcl_FillLabelData(rLabelData, xDimProp);
- rLabelData.mnFlags = ScUnoHelpFunctions::GetLongProperty(
- xDimProp, SC_UNO_DP_FLAGS );
- }
+ if (bData)
+ return;
+
+ rLabelData.mnOriginalDim = static_cast<long>(nOrigPos);
+ rLabelData.maLayoutName = aLayoutName;
+ rLabelData.maSubtotalName = aSubtotalName;
+ if (nOrigPos >= 0)
+ // This is a duplicated dimension. Use the original dimension index.
+ nDim = nOrigPos;
+ GetHierarchies(nDim, rLabelData.maHiers);
+ GetMembers(nDim, GetUsedHierarchy(nDim), rLabelData.maMembers);
+ lcl_FillLabelData(rLabelData, xDimProp);
+ rLabelData.mnFlags = ScUnoHelpFunctions::GetLongProperty(
+ xDimProp, SC_UNO_DP_FLAGS );
}
void ScDPObject::FillLabelData(sal_Int32 nDim, ScDPLabelData& rLabels)
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 4bc67a0fcf8d..b44b2a194680 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -661,18 +661,18 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
// get "DataDescription" property (may be missing in external sources)
uno::Reference<beans::XPropertySet> xSrcProp( xSource, uno::UNO_QUERY );
- if ( xSrcProp.is() )
+ if ( !xSrcProp.is() )
+ return;
+
+ try
+ {
+ uno::Any aAny = xSrcProp->getPropertyValue( SC_UNO_DP_DATADESC );
+ OUString aUStr;
+ aAny >>= aUStr;
+ aDataDescription = aUStr;
+ }
+ catch(const uno::Exception&)
{
- try
- {
- uno::Any aAny = xSrcProp->getPropertyValue( SC_UNO_DP_DATADESC );
- OUString aUStr;
- aAny >>= aUStr;
- aDataDescription = aUStr;
- }
- catch(const uno::Exception&)
- {
- }
}
}
@@ -762,29 +762,29 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
}
}
- if ( nFlags & sheet::MemberResultFlags::SUBTOTAL )
+ if ( !(nFlags & sheet::MemberResultFlags::SUBTOTAL) )
+ return;
+
+ ScDPOutputImpl outputimp( pDoc, nTab,
+ nTabStartCol, nTabStartRow,
+ nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow );
+ //TODO: limit frames to horizontal or vertical?
+ if (bColHeader)
{
- ScDPOutputImpl outputimp( pDoc, nTab,
- nTabStartCol, nTabStartRow,
- nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow );
- //TODO: limit frames to horizontal or vertical?
- if (bColHeader)
- {
- outputimp.OutputBlockFrame( nCol,nMemberStartRow+static_cast<SCROW>(nLevel), nCol,nDataStartRow-1 );
+ outputimp.OutputBlockFrame( nCol,nMemberStartRow+static_cast<SCROW>(nLevel), nCol,nDataStartRow-1 );
- lcl_SetStyleById( pDoc,nTab, nCol,nMemberStartRow+static_cast<SCROW>(nLevel), nCol,nDataStartRow-1,
- STR_PIVOT_STYLENAME_TITLE );
- lcl_SetStyleById( pDoc,nTab, nCol,nDataStartRow, nCol,nTabEndRow,
- STR_PIVOT_STYLENAME_RESULT );
- }
- else
- {
- outputimp.OutputBlockFrame( nMemberStartCol+static_cast<SCCOL>(nLevel),nRow, nDataStartCol-1,nRow );
- lcl_SetStyleById( pDoc,nTab, nMemberStartCol+static_cast<SCCOL>(nLevel),nRow, nDataStartCol-1,nRow,
- STR_PIVOT_STYLENAME_TITLE );
- lcl_SetStyleById( pDoc,nTab, nDataStartCol,nRow, nTabEndCol,nRow,
- STR_PIVOT_STYLENAME_RESULT );
- }
+ lcl_SetStyleById( pDoc,nTab, nCol,nMemberStartRow+static_cast<SCROW>(nLevel), nCol,nDataStartRow-1,
+ STR_PIVOT_STYLENAME_TITLE );
+ lcl_SetStyleById( pDoc,nTab, nCol,nDataStartRow, nCol,nTabEndRow,
+ STR_PIVOT_STYLENAME_RESULT );
+ }
+ else
+ {
+ outputimp.OutputBlockFrame( nMemberStartCol+static_cast<SCCOL>(nLevel),nRow, nDataStartCol-1,nRow );
+ lcl_SetStyleById( pDoc,nTab, nMemberStartCol+static_cast<SCCOL>(nLevel),nRow, nDataStartCol-1,nRow,
+ STR_PIVOT_STYLENAME_TITLE );
+ lcl_SetStyleById( pDoc,nTab, nDataStartCol,nRow, nTabEndCol,nRow,
+ STR_PIVOT_STYLENAME_RESULT );
}
}
@@ -831,55 +831,55 @@ static void lcl_DoFilterButton( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB
void ScDPOutput::CalcSizes()
{
- if (!bSizesValid)
- {
- // get column size of data from first row
- //TODO: allow different sizes (and clear following areas) ???
+ if (bSizesValid)
+ return;
- nRowCount = aData.getLength();
- const uno::Sequence<sheet::DataResult>* pRowAry = aData.getConstArray();
- nColCount = nRowCount ? ( pRowAry[0].getLength() ) : 0;
+ // get column size of data from first row
+ //TODO: allow different sizes (and clear following areas) ???
- nHeaderSize = 1;
- if (GetHeaderLayout() && pColFields.empty())
- // Insert an extra header row only when there is no column field.
- nHeaderSize = 2;
+ nRowCount = aData.getLength();
+ const uno::Sequence<sheet::DataResult>* pRowAry = aData.getConstArray();
+ nColCount = nRowCount ? ( pRowAry[0].getLength() ) : 0;
- // calculate output positions and sizes
+ nHeaderSize = 1;
+ if (GetHeaderLayout() && pColFields.empty())
+ // Insert an extra header row only when there is no column field.
+ nHeaderSize = 2;
- long nPageSize = 0; // use page fields!
- if ( bDoFilter || !pPageFields.empty() )
- {
- nPageSize += pPageFields.size() + 1; // plus one empty row
- if ( bDoFilter )
- ++nPageSize; // filter button above the page fields
- }
+ // calculate output positions and sizes
- if ( aStartPos.Col() + static_cast<long>(pRowFields.size()) + nColCount - 1 > MAXCOL ||
- aStartPos.Row() + nPageSize + nHeaderSize + pColFields.size() + nRowCount > MAXROW )
- {
- bSizeOverflow = true;
- }
+ long nPageSize = 0; // use page fields!
+ if ( bDoFilter || !pPageFields.empty() )
+ {
+ nPageSize += pPageFields.size() + 1; // plus one empty row
+ if ( bDoFilter )
+ ++nPageSize; // filter button above the page fields
+ }
- nTabStartCol = aStartPos.Col();
- nTabStartRow = aStartPos.Row() + static_cast<SCROW>(nPageSize); // below page fields
- nMemberStartCol = nTabStartCol;
- nMemberStartRow = nTabStartRow + static_cast<SCROW>(nHeaderSize);
- nDataStartCol = nMemberStartCol + static_cast<SCCOL>(pRowFields.size());
- nDataStartRow = nMemberStartRow + static_cast<SCROW>(pColFields.size());
- if ( nColCount > 0 )
- nTabEndCol = nDataStartCol + static_cast<SCCOL>(nColCount) - 1;
- else
- nTabEndCol = nDataStartCol; // single column will remain empty
- // if page fields are involved, include the page selection cells
- if ( !pPageFields.empty() && nTabEndCol < nTabStartCol + 1 )
- nTabEndCol = nTabStartCol + 1;
- if ( nRowCount > 0 )
- nTabEndRow = nDataStartRow + static_cast<SCROW>(nRowCount) - 1;
- else
- nTabEndRow = nDataStartRow; // single row will remain empty
- bSizesValid = true;
+ if ( aStartPos.Col() + static_cast<long>(pRowFields.size()) + nColCount - 1 > MAXCOL ||
+ aStartPos.Row() + nPageSize + nHeaderSize + pColFields.size() + nRowCount > MAXROW )
+ {
+ bSizeOverflow = true;
}
+
+ nTabStartCol = aStartPos.Col();
+ nTabStartRow = aStartPos.Row() + static_cast<SCROW>(nPageSize); // below page fields
+ nMemberStartCol = nTabStartCol;
+ nMemberStartRow = nTabStartRow + static_cast<SCROW>(nHeaderSize);
+ nDataStartCol = nMemberStartCol + static_cast<SCCOL>(pRowFields.size());
+ nDataStartRow = nMemberStartRow + static_cast<SCROW>(pColFields.size());
+ if ( nColCount > 0 )
+ nTabEndCol = nDataStartCol + static_cast<SCCOL>(nColCount) - 1;
+ else
+ nTabEndCol = nDataStartCol; // single column will remain empty
+ // if page fields are involved, include the page selection cells
+ if ( !pPageFields.empty() && nTabEndCol < nTabStartCol + 1 )
+ nTabEndCol = nTabStartCol + 1;
+ if ( nRowCount > 0 )
+ nTabEndRow = nDataStartRow + static_cast<SCROW>(nRowCount) - 1;
+ else
+ nTabEndRow = nDataStartRow; // single row will remain empty
+ bSizesValid = true;
}
sal_Int32 ScDPOutput::GetPositionType(const ScAddress& rPos)
@@ -1219,63 +1219,63 @@ void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, s
if ( bRowGrand )
rGrandTotalRows = 1; // default if data layout not in rows
- if ( xSource.is() )
- {
- // find index and orientation of "data layout" dimension, count data dimensions
+ if ( !xSource.is() )
+ return;
- sal_Int32 nDataCount = 0;
+ // find index and orientation of "data layout" dimension, count data dimensions
- uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( xSource->getDimensions() );
- long nDimCount = xDims->getCount();
- for (long nDim=0; nDim<nDimCount; nDim++)
+ sal_Int32 nDataCount = 0;
+
+ uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( xSource->getDimensions() );
+ long nDimCount = xDims->getCount();
+ for (long nDim=0; nDim<nDimCount; nDim++)
+ {
+ uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
+ if ( xDimProp.is() )
{
- uno::Reference<uno::XInterface> xDim(xDims->getByIndex(nDim), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
- if ( xDimProp.is() )
+ sheet::DataPilotFieldOrientation eDimOrient =
+ ScUnoHelpFunctions::GetEnumProperty(
+ xDimProp, SC_UNO_DP_ORIENTATION,
+ sheet::DataPilotFieldOrientation_HIDDEN );
+ if ( ScUnoHelpFunctions::GetBoolProperty( xDimProp,
+ SC_UNO_DP_ISDATALAYOUT ) )
{
- sheet::DataPilotFieldOrientation eDimOrient =
- ScUnoHelpFunctions::GetEnumProperty(
- xDimProp, SC_UNO_DP_ORIENTATION,
- sheet::DataPilotFieldOrientation_HIDDEN );
- if ( ScUnoHelpFunctions::GetBoolProperty( xDimProp,
- SC_UNO_DP_ISDATALAYOUT ) )
- {
- rDataLayoutIndex = nDim;
- rDataOrient = eDimOrient;
- }
- if ( eDimOrient == sheet::DataPilotFieldOrientation_DATA )
+ rDataLayoutIndex = nDim;
+ rDataOrient = eDimOrient;
+ }
+ if ( eDimOrient == sheet::DataPilotFieldOrientation_DATA )
+ {
+ OUString aSourceName;
+ OUString aGivenName;
+ ScDPOutput::GetDataDimensionNames( aSourceName, aGivenName, xDim );
+ try
{
- OUString aSourceName;
- OUString aGivenName;
- ScDPOutput::GetDataDimensionNames( aSourceName, aGivenName, xDim );
- try
- {
- uno::Any aValue = xDimProp->getPropertyValue( SC_UNO_DP_LAYOUTNAME );
+ uno::Any aValue = xDimProp->getPropertyValue( SC_UNO_DP_LAYOUTNAME );
- if( aValue.hasValue() )
- {
- OUString strLayoutName;
-
- if( ( aValue >>= strLayoutName ) && !strLayoutName.isEmpty() )
- aGivenName = strLayoutName;
- }
- }
- catch(const uno::Exception&)
+ if( aValue.hasValue() )
{
- }
- rDataNames.push_back( aSourceName );
- rGivenNames.push_back( aGivenName );
+ OUString strLayoutName;
- ++nDataCount;
+ if( ( aValue >>= strLayoutName ) && !strLayoutName.isEmpty() )
+ aGivenName = strLayoutName;
+ }
+ }
+ catch(const uno::Exception&)
+ {
}
+ rDataNames.push_back( aSourceName );
+ rGivenNames.push_back( aGivenName );
+
+ ++nDataCount;
}
}
-
- if ( ( rDataOrient == sheet::DataPilotFieldOrientation_COLUMN ) && bColGrand )
- rGrandTotalCols = nDataCount;
- else if ( ( rDataOrient == sheet::DataPilotFieldOrientation_ROW ) && bRowGrand )
- rGrandTotalRows = nDataCount;
}
+
+ if ( ( rDataOrient == sheet::DataPilotFieldOrientation_COLUMN ) && bColGrand )
+ rGrandTotalCols = nDataCount;
+ else if ( ( rDataOrient == sheet::DataPilotFieldOrientation_ROW ) && bRowGrand )
+ rGrandTotalRows = nDataCount;
}
}
@@ -1517,20 +1517,20 @@ void ScDPOutput::GetDataDimensionNames(
{
uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
uno::Reference<container::XNamed> xDimName( xDim, uno::UNO_QUERY );
- if ( xDimProp.is() && xDimName.is() )
- {
- // Asterisks are added in ScDPSaveData::WriteToSource to create unique names.
- //TODO: preserve original name there?
- rSourceName = ScDPUtil::getSourceDimensionName(xDimName->getName());
+ if ( !(xDimProp.is() && xDimName.is()) )
+ return;
- // Generate "given name" the same way as in dptabres.
- //TODO: Should use a stored name when available
+ // Asterisks are added in ScDPSaveData::WriteToSource to create unique names.
+ //TODO: preserve original name there?
+ rSourceName = ScDPUtil::getSourceDimensionName(xDimName->getName());
- sal_Int16 eFunc = ScUnoHelpFunctions::GetShortProperty(
- xDimProp, SC_UNO_DP_FUNCTION2,
- sheet::GeneralFunction2::NONE );
- rGivenName = lcl_GetDataFieldName( rSourceName, eFunc );
- }
+ // Generate "given name" the same way as in dptabres.
+ //TODO: Should use a stored name when available
+
+ sal_Int16 eFunc = ScUnoHelpFunctions::GetShortProperty(
+ xDimProp, SC_UNO_DP_FUNCTION2,
+ sheet::GeneralFunction2::NONE );
+ rGivenName = lcl_GetDataFieldName( rSourceName, eFunc );
}
bool ScDPOutput::IsFilterButton( const ScAddress& rPos )
diff --git a/sc/source/core/data/dpoutputgeometry.cxx b/sc/source/core/data/dpoutputgeometry.cxx
index 6833ee908dc0..427bcf2326f3 100644
--- a/sc/source/core/data/dpoutputgeometry.cxx
+++ b/sc/source/core/data/dpoutputgeometry.cxx
@@ -184,22 +184,22 @@ void ScDPOutputGeometry::adjustFieldsForDataLayout(sal_uInt32& rColumnFields, sa
rRowFields = mnRowFields;
rColumnFields = mnColumnFields;
- if (mnDataFields < 2)
+ if (mnDataFields >= 2)
+ return;
+
+ // Data layout field can be either row or column field, never page field.
+ switch (meDataLayoutType)
{
- // Data layout field can be either row or column field, never page field.
- switch (meDataLayoutType)
- {
- case Column:
- if (rColumnFields > 0)
- rColumnFields -= 1;
- break;
- case Row:
- if (rRowFields > 0)
- rRowFields -= 1;
- break;
- default:
- ;
- }
+ case Column:
+ if (rColumnFields > 0)
+ rColumnFields -= 1;
+ break;
+ case Row:
+ if (rRowFields > 0)
+ rRowFields -= 1;
+ break;
+ default:
+ ;
}
}
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 0f0d687bd762..692186dacd5e 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -134,24 +134,24 @@ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMemb
{
uno::Reference<beans::XPropertySet> xMembProp( xMember, uno::UNO_QUERY );
OSL_ENSURE( xMembProp.is(), "no properties at member" );
- if ( xMembProp.is() )
- {
- // exceptions are caught at ScDPSaveData::WriteToSource
+ if ( !xMembProp.is() )
+ return;
- if ( nVisibleMode != SC_DPSAVEMODE_DONTKNOW )
- lcl_SetBoolProperty( xMembProp,
- SC_UNO_DP_ISVISIBLE, static_cast<bool>(nVisibleMode) );
+ // exceptions are caught at ScDPSaveData::WriteToSource
- if ( nShowDetailsMode != SC_DPSAVEMODE_DONTKNOW )
- lcl_SetBoolProperty( xMembProp,
- SC_UNO_DP_SHOWDETAILS, static_cast<bool>(nShowDetailsMode) );
+ if ( nVisibleMode != SC_DPSAVEMODE_DONTKNOW )
+ lcl_SetBoolProperty( xMembProp,
+ SC_UNO_DP_ISVISIBLE, static_cast<bool>(nVisibleMode) );
- if (mpLayoutName)
- ScUnoHelpFunctions::SetOptionalPropertyValue(xMembProp, SC_UNO_DP_LAYOUTNAME, *mpLayoutName);
+ if ( nShowDetailsMode != SC_DPSAVEMODE_DONTKNOW )
+ lcl_SetBoolProperty( xMembProp,
+ SC_UNO_DP_SHOWDETAILS, static_cast<bool>(nShowDetailsMode) );
- if ( nPosition >= 0 )
- ScUnoHelpFunctions::SetOptionalPropertyValue(xMembProp, SC_UNO_DP_POSITION, nPosition);
- }
+ if (mpLayoutName)
+ ScUnoHelpFunctions::SetOptionalPropertyValue(xMembProp, SC_UNO_DP_LAYOUTNAME, *mpLayoutName);
+
+ if ( nPosition >= 0 )
+ ScUnoHelpFunctions::SetOptionalPropertyValue(xMembProp, SC_UNO_DP_POSITION, nPosition);
}
#if DUMP_PIVOT_TABLE
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 05be6e615bf1..8519edb13122 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -1455,83 +1455,83 @@ void ScDPResultMember::FillMemberResults(
long nUserSubStart;
long nUserSubCount = GetSubTotalCount(&nUserSubStart);
- if ( nUserSubCount && pChildDimension && !bSubTotalInTitle )
- {
- long nMemberMeasure = nMeasure;
- long nSubSize = pResultData->GetCountForMeasure(nMeasure);
+ if ( !(nUserSubCount && pChildDimension && !bSubTotalInTitle) )
+ return;
- rPos -= nSubSize * (nUserSubCount - nUserSubStart); // GetSize includes space for SubTotal
- rPos -= nExtraSpace; // GetSize includes the empty line
+ long nMemberMeasure = nMeasure;
+ long nSubSize = pResultData->GetCountForMeasure(nMeasure);
- for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
+ rPos -= nSubSize * (nUserSubCount - nUserSubStart); // GetSize includes space for SubTotal
+ rPos -= nExtraSpace; // GetSize includes the empty line
+
+ for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
+ {
+ for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
{
- for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
- {
- if ( nMeasure == SC_DPMEASURE_ALL )
- nMemberMeasure = nSubCount;
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nMemberMeasure = nSubCount;
- ScSubTotalFunc eForce = SUBTOTAL_FUNC_NONE;
- if (bHasChild)
- eForce = lcl_GetForceFunc( pParentLevel, nUserPos );
+ ScSubTotalFunc eForce = SUBTOTAL_FUNC_NONE;
+ if (bHasChild)
+ eForce = lcl_GetForceFunc( pParentLevel, nUserPos );
- bool bTotalResult = false;
- OUString aSubStr = aCaption + " " + pResultData->GetMeasureString(nMemberMeasure, false, eForce, bTotalResult);
+ bool bTotalResult = false;
+ OUString aSubStr = aCaption + " " + pResultData->GetMeasureString(nMemberMeasure, false, eForce, bTotalResult);
- if (bTotalResult)
+ if (bTotalResult)
+ {
+ if (pMemberDesc)
{
- if (pMemberDesc)
- {
- // single data field layout.
- const std::optional<OUString> & pSubtotalName = pParentDim->GetSubtotalName();
- if (pSubtotalName)
- aSubStr = lcl_parseSubtotalName(*pSubtotalName, aCaption);
- pArray[rPos].Flags &= ~sheet::MemberResultFlags::GRANDTOTAL;
- }
- else
- {
- // root member - subtotal (grand total?) for multi-data field layout.
- const std::optional<OUString> & pGrandTotalName = pResultData->GetSource().GetGrandTotalName();
- if (pGrandTotalName)
- aSubStr = *pGrandTotalName;
- pArray[rPos].Flags |= sheet::MemberResultFlags::GRANDTOTAL;
- }
+ // single data field layout.
+ const std::optional<OUString> & pSubtotalName = pParentDim->GetSubtotalName();
+ if (pSubtotalName)
+ aSubStr = lcl_parseSubtotalName(*pSubtotalName, aCaption);
+ pArray[rPos].Flags &= ~sheet::MemberResultFlags::GRANDTOTAL;
+ }
+ else
+ {
+ // root member - subtotal (grand total?) for multi-data field layout.
+ const std::optional<OUString> & pGrandTotalName = pResultData->GetSource().GetGrandTotalName();
+ if (pGrandTotalName)
+ aSubStr = *pGrandTotalName;
+ pArray[rPos].Flags |= sheet::MemberResultFlags::GRANDTOTAL;
}
+ }
- rtl::math::setNan(&fValue); /* TODO: any numeric value to obtain? */
- pArray[rPos].Name = aName;
- pArray[rPos].Caption = aSubStr;
- pArray[rPos].Flags = ( pArray[rPos].Flags |
- ( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) &
- ~sheet::MemberResultFlags::CONTINUE;
- pArray[rPos].Value = fValue;
+ rtl::math::setNan(&fValue); /* TODO: any numeric value to obtain? */
+ pArray[rPos].Name = aName;
+ pArray[rPos].Caption = aSubStr;
+ pArray[rPos].Flags = ( pArray[rPos].Flags |
+ ( sheet::MemberResultFlags::HASMEMBER | sheet::MemberResultFlags::SUBTOTAL) ) &
+ ~sheet::MemberResultFlags::CONTINUE;
+ pArray[rPos].Value = fValue;
- if ( nMeasure == SC_DPMEASURE_ALL )
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ {
+ // data layout dimension is (direct/indirect) child of this.
+ // data layout dimension must have name for all entries.
+
+ uno::Sequence<sheet::MemberResult>* pLayoutSeq = pSequences;
+ if (!bRoot)
+ ++pLayoutSeq;
+ ScDPResultDimension* pLayoutDim = pChildDimension.get();
+ while ( pLayoutDim && !pLayoutDim->IsDataLayout() )
{
- // data layout dimension is (direct/indirect) child of this.
- // data layout dimension must have name for all entries.
-
- uno::Sequence<sheet::MemberResult>* pLayoutSeq = pSequences;
- if (!bRoot)
- ++pLayoutSeq;
- ScDPResultDimension* pLayoutDim = pChildDimension.get();
- while ( pLayoutDim && !pLayoutDim->IsDataLayout() )
- {
- pLayoutDim = pLayoutDim->GetFirstChildDimension();
- ++pLayoutSeq;
- }
- if ( pLayoutDim )
- {
- sheet::MemberResult* pLayoutArray = pLayoutSeq->getArray();
- pLayoutArray[rPos].Name = pResultData->GetMeasureDimensionName(nMemberMeasure);
- }
+ pLayoutDim = pLayoutDim->GetFirstChildDimension();
+ ++pLayoutSeq;
+ }
+ if ( pLayoutDim )
+ {
+ sheet::MemberResult* pLayoutArray = pLayoutSeq->getArray();
+ pLayoutArray[rPos].Name = pResultData->GetMeasureDimensionName(nMemberMeasure);
}
-
- rPos += 1;
}
- }
- rPos += nExtraSpace; // add again (subtracted above)
+ rPos += 1;
+ }
}
+
+ rPos += nExtraSpace; // add again (subtracted above)
}
void ScDPResultMember::FillDataResults(
@@ -1581,69 +1581,69 @@ void ScDPResultMember::FillDataResults(
long nUserSubStart;
long nUserSubCount = GetSubTotalCount(&nUserSubStart);
- if ( nUserSubCount || !bHasChild )
+ if ( !(nUserSubCount || !bHasChild) )
+ return;
+
+ // Calculate at least automatic if no subtotals are selected,
+ // show only own values if there's no child dimension (innermost).
+ if ( !nUserSubCount || !bHasChild )
{
- // Calculate at least automatic if no subtotals are selected,
- // show only own values if there's no child dimension (innermost).
- if ( !nUserSubCount || !bHasChild )
- {
- nUserSubCount = 1;
- nUserSubStart = 0;
- }
+ nUserSubCount = 1;
+ nUserSubStart = 0;
+ }
- long nMemberMeasure = nMeasure;
- long nSubSize = pResultData->GetCountForMeasure(nMeasure);
- if (bHasChild)
- {
- rFilterCxt.mnRow -= nSubSize * ( nUserSubCount - nUserSubStart ); // GetSize includes space for SubTotal
- rFilterCxt.mnRow -= nExtraSpace; // GetSize includes the empty line
- }
+ long nMemberMeasure = nMeasure;
+ long nSubSize = pResultData->GetCountForMeasure(nMeasure);
+ if (bHasChild)
+ {
+ rFilterCxt.mnRow -= nSubSize * ( nUserSubCount - nUserSubStart ); // GetSize includes space for SubTotal
+ rFilterCxt.mnRow -= nExtraSpace; // GetSize includes the empty line
+ }
- long nMoveSubTotal = 0;
- if ( bSubTotalInTitle )
- {
- nMoveSubTotal = rFilterCxt.mnRow - nStartRow; // force to first (title) row
- rFilterCxt.mnRow = nStartRow;
- }
+ long nMoveSubTotal = 0;
+ if ( bSubTotalInTitle )
+ {
+ nMoveSubTotal = rFilterCxt.mnRow - nStartRow; // force to first (title) row
+ rFilterCxt.mnRow = nStartRow;
+ }
- if ( pDataRoot )
+ if ( pDataRoot )
+ {
+ ScDPSubTotalState aSubState; // initial state
+
+ for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
{
- ScDPSubTotalState aSubState; // initial state
+ if ( bHasChild && nUserSubCount > 1 )
+ {
+ aSubState.nRowSubTotalFunc = nUserPos;
+ aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos );
+ }
- for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
+ for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
{
- if ( bHasChild && nUserSubCount > 1 )
- {
- aSubState.nRowSubTotalFunc = nUserPos;
- aSubState.eRowForce = lcl_GetForceFunc( /*pParentLevel*/GetParentLevel() , nUserPos );
- }
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nMemberMeasure = nSubCount;
+ else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL )
+ nMemberMeasure = SC_DPMEASURE_ALL;
- for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
+ OSL_ENSURE( rFilterCxt.mnRow < rSequence.getLength(), "bumm" );
+ rFilterCxt.mnCol = 0;
+ if (pRefMember->IsVisible())
{
- if ( nMeasure == SC_DPMEASURE_ALL )
- nMemberMeasure = nSubCount;
- else if ( pResultData->GetColStartMeasure() == SC_DPMEASURE_ALL )
- nMemberMeasure = SC_DPMEASURE_ALL;
-
- OSL_ENSURE( rFilterCxt.mnRow < rSequence.getLength(), "bumm" );
- rFilterCxt.mnCol = 0;
- if (pRefMember->IsVisible())
- {
- uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rFilterCxt.mnRow];
- pDataRoot->FillDataRow(pRefMember, rFilterCxt, rSubSeq, nMemberMeasure, bHasChild, aSubState);
- }
- rFilterCxt.mnRow += 1;
+ uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rFilterCxt.mnRow];
+ pDataRoot->FillDataRow(pRefMember, rFilterCxt, rSubSeq, nMemberMeasure, bHasChild, aSubState);
}
+ rFilterCxt.mnRow += 1;
}
}
- else
- rFilterCxt.mnRow += nSubSize * ( nUserSubCount - nUserSubStart ); // empty rows occur when ShowEmpty is true
-
- // add extra space again if subtracted from GetSize above,
- // add to own size if no children
- rFilterCxt.mnRow += nExtraSpace;
- rFilterCxt.mnRow += nMoveSubTotal;
}
+ else
+ rFilterCxt.mnRow += nSubSize * ( nUserSubCount - nUserSubStart ); // empty rows occur when ShowEmpty is true
+
+ // add extra space again if subtracted from GetSize above,
+ // add to own size if no children
+ rFilterCxt.mnRow += nExtraSpace;
+ rFilterCxt.mnRow += nMoveSubTotal;
}
void ScDPResultMember::UpdateDataResults( const ScDPResultMember* pRefMember, long nMeasure ) const
@@ -2093,77 +2093,77 @@ void ScDPDataMember::FillDataRow(
long nUserSubStart;
long nUserSubCount = pRefMember->GetSubTotalCount(&nUserSubStart);
- if ( nUserSubCount || !bHasChild )
+ if ( !(nUserSubCount || !bHasChild) )
+ return;
+
+ // Calculate at least automatic if no subtotals are selected,
+ // show only own values if there's no child dimension (innermost).
+ if ( !nUserSubCount || !bHasChild )
{
- // Calculate at least automatic if no subtotals are selected,
- // show only own values if there's no child dimension (innermost).
- if ( !nUserSubCount || !bHasChild )
- {
- nUserSubCount = 1;
- nUserSubStart = 0;
- }
+ nUserSubCount = 1;
+ nUserSubStart = 0;
+ }
- ScDPSubTotalState aLocalSubState(rSubState); // keep row state, modify column
+ ScDPSubTotalState aLocalSubState(rSubState); // keep row state, modify column
- long nMemberMeasure = nMeasure;
- long nSubSize = pResultData->GetCountForMeasure(nMeasure);
- if (bHasChild)
- {
- rFilterCxt.mnCol -= nSubSize * ( nUserSubCount - nUserSubStart ); // GetSize includes space for SubTotal
- rFilterCxt.mnCol -= nExtraSpace; // GetSize includes the empty line
- }
+ long nMemberMeasure = nMeasure;
+ long nSubSize = pResultData->GetCountForMeasure(nMeasure);
+ if (bHasChild)
+ {
+ rFilterCxt.mnCol -= nSubSize * ( nUserSubCount - nUserSubStart ); // GetSize includes space for SubTotal
+ rFilterCxt.mnCol -= nExtraSpace; // GetSize includes the empty line
+ }
+
+ long nMoveSubTotal = 0;
+ if ( bSubTotalInTitle )
+ {
+ nMoveSubTotal = rFilterCxt.mnCol - nStartCol; // force to first (title) column
+ rFilterCxt.mnCol = nStartCol;
+ }
- long nMoveSubTotal = 0;
- if ( bSubTotalInTitle )
+ for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
+ {
+ if ( pChildDimension && nUserSubCount > 1 )
{
- nMoveSubTotal = rFilterCxt.mnCol - nStartCol; // force to first (title) column
- rFilterCxt.mnCol = nStartCol;
+ const ScDPLevel* pForceLevel = pResultMember ? pResultMember->GetParentLevel() : nullptr;
+ aLocalSubState.nColSubTotalFunc = nUserPos;
+ aLocalSubState.eColForce = lcl_GetForceFunc( pForceLevel, nUserPos );
}
- for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
+ for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
{
- if ( pChildDimension && nUserSubCount > 1 )
- {
- const ScDPLevel* pForceLevel = pResultMember ? pResultMember->GetParentLevel() : nullptr;
- aLocalSubState.nColSubTotalFunc = nUserPos;
- aLocalSubState.eColForce = lcl_GetForceFunc( pForceLevel, nUserPos );
- }
-
- for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
- {
- if ( nMeasure == SC_DPMEASURE_ALL )
- nMemberMeasure = nSubCount;
+ if ( nMeasure == SC_DPMEASURE_ALL )
+ nMemberMeasure = nSubCount;
- OSL_ENSURE( rFilterCxt.mnCol < rSequence.getLength(), "bumm" );
- sheet::DataResult& rRes = rSequence.getArray()[rFilterCxt.mnCol];
+ OSL_ENSURE( rFilterCxt.mnCol < rSequence.getLength(), "bumm" );
+ sheet::DataResult& rRes = rSequence.getArray()[rFilterCxt.mnCol];
- if ( HasData( nMemberMeasure, aLocalSubState ) )
+ if ( HasData( nMemberMeasure, aLocalSubState ) )
+ {
+ if ( HasError( nMemberMeasure, aLocalSubState ) )
{
- if ( HasError( nMemberMeasure, aLocalSubState ) )
- {
- rRes.Value = 0;
- rRes.Flags |= sheet::DataResultFlags::ERROR;
- }
- else
- {
- rRes.Value = GetAggregate( nMemberMeasure, aLocalSubState );
- rRes.Flags |= sheet::DataResultFlags::HASDATA;
- }
+ rRes.Value = 0;
+ rRes.Flags |= sheet::DataResultFlags::ERROR;
}
+ else
+ {
+ rRes.Value = GetAggregate( nMemberMeasure, aLocalSubState );
+ rRes.Flags |= sheet::DataResultFlags::HASDATA;
+ }
+ }
- if ( bHasChild || bIsSubTotalRow )
- rRes.Flags |= sheet::DataResultFlags::SUBTOTAL;
+ if ( bHasChild || bIsSubTotalRow )
+ rRes.Flags |= sheet::DataResultFlags::SUBTOTAL;
- rFilterCxt.maFilterSet.add(rFilterCxt.maFilters, rRes.Value);
- rFilterCxt.mnCol += 1;
- }
+ rFilterCxt.maFilterSet.add(rFilterCxt.maFilters, rRes.Value);
+ rFilterCxt.mnCol += 1;
}
-
- // add extra space again if subtracted from GetSize above,
- // add to own size if no children
- rFilterCxt.mnCol += nExtraSpace;
- rFilterCxt.mnCol += nMoveSubTotal;
}
+
+ // add extra space again if subtracted from GetSize above,
+ // add to own size if no children
+ rFilterCxt.mnCol += nExtraSpace;
+ rFilterCxt.mnCol += nMoveSubTotal;
}
void ScDPDataMember::UpdateDataRow(
@@ -3152,48 +3152,48 @@ void ScDPResultDimension::DoAutoShow( ScDPResultMember* pRefMember )
pMember->DoAutoShow( pRefMember );
}
- if ( bAutoShow && nAutoCount > 0 && nAutoCount < nCount )
- {
- // establish temporary order, hide remaining members
+ if ( !(bAutoShow && nAutoCount > 0 && nAutoCount < nCount) )
+ return;
+
+ // establish temporary order, hide remaining members
- ScMemberSortOrder aAutoOrder;
- aAutoOrder.resize( nCount );
- long nPos;
- for (nPos=0; nPos<nCount; nPos++)
- aAutoOrder[nPos] = nPos;
+ ScMemberSortOrder aAutoOrder;
+ aAutoOrder.resize( nCount );
+ long nPos;
+ for (nPos=0; nPos<nCount; nPos++)
+ aAutoOrder[nPos] = nPos;
- ScDPRowMembersOrder aComp( *this, nAutoMeasure, !bAutoTopItems );
- ::std::sort( aAutoOrder.begin(), aAutoOrder.end(), aComp );
+ ScDPRowMembersOrder aComp( *this, nAutoMeasure, !bAutoTopItems );
+ ::std::sort( aAutoOrder.begin(), aAutoOrder.end(), aComp );
- // look for equal values to the last included one
+ // look for equal values to the last included one
- long nIncluded = nAutoCount;
- const ScDPResultMember* pMember1 = maMemberArray[aAutoOrder[nIncluded - 1]].get();
- const ScDPDataMember* pDataMember1 = pMember1->IsVisible() ? pMember1->GetDataRoot() : nullptr;
- bool bContinue = true;
- while ( bContinue )
+ long nIncluded = nAutoCount;
+ const ScDPResultMember* pMember1 = maMemberArray[aAutoOrder[nIncluded - 1]].get();
+ const ScDPDataMember* pDataMember1 = pMember1->IsVisible() ? pMember1->GetDataRoot() : nullptr;
+ bool bContinue = true;
+ while ( bContinue )
+ {
+ bContinue = false;
+ if ( nIncluded < nCount )
{
- bContinue = false;
- if ( nIncluded < nCount )
- {
- const ScDPResultMember* pMember2 = maMemberArray[aAutoOrder[nIncluded]].get();
- const ScDPDataMember* pDataMember2 = pMember2->IsVisible() ? pMember2->GetDataRoot() : nullptr;
+ const ScDPResultMember* pMember2 = maMemberArray[aAutoOrder[nIncluded]].get();
+ const ScDPDataMember* pDataMember2 = pMember2->IsVisible() ? pMember2->GetDataRoot() : nullptr;
- if ( lcl_IsEqual( pDataMember1, pDataMember2, nAutoMeasure ) )
- {
- ++nIncluded; // include more members if values are equal
- bContinue = true;
- }
+ if ( lcl_IsEqual( pDataMember1, pDataMember2, nAutoMeasure ) )
+ {
+ ++nIncluded; // include more members if values are equal
+ bContinue = true;
}
}
+ }
- // hide the remaining members
+ // hide the remaining members
- for (nPos = nIncluded; nPos < nCount; nPos++)
- {
- ScDPResultMember* pMember = maMemberArray[aAutoOrder[nPos]].get();
- pMember->SetAutoHidden();
- }
+ for (nPos = nIncluded; nPos < nCount; nPos++)
+ {
+ ScDPResultMember* pMember = maMemberArray[aAutoOrder[nPos]].get();
+ pMember->SetAutoHidden();
}
}
@@ -3722,50 +3722,50 @@ void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim )
}
}
- if ( pRefDim->IsAutoShow() && pRefDim->GetAutoCount() > 0 && pRefDim->GetAutoCount() < nCount )
- {
- // establish temporary order, hide remaining members
+ if ( !(pRefDim->IsAutoShow() && pRefDim->GetAutoCount() > 0 && pRefDim->GetAutoCount() < nCount) )
+ return;
+
+ // establish temporary order, hide remaining members
- ScMemberSortOrder aAutoOrder;
- aAutoOrder.resize( nCount );
- long nPos;
- for (nPos=0; nPos<nCount; nPos++)
- aAutoOrder[nPos] = nPos;
+ ScMemberSortOrder aAutoOrder;
+ aAutoOrder.resize( nCount );
+ long nPos;
+ for (nPos=0; nPos<nCount; nPos++)
+ aAutoOrder[nPos] = nPos;
- ScDPColMembersOrder aComp( *this, pRefDim->GetAutoMeasure(), !pRefDim->IsAutoTopItems() );
- ::std::sort( aAutoOrder.begin(), aAutoOrder.end(), aComp );
+ ScDPColMembersOrder aComp( *this, pRefDim->GetAutoMeasure(), !pRefDim->IsAutoTopItems() );
+ ::std::sort( aAutoOrder.begin(), aAutoOrder.end(), aComp );
- // look for equal values to the last included one
+ // look for equal values to the last included one
- long nIncluded = pRefDim->GetAutoCount();
- ScDPDataMember* pDataMember1 = maMembers[aAutoOrder[nIncluded - 1]].get();
- if ( !pDataMember1->IsVisible() )
- pDataMember1 = nullptr;
- bool bContinue = true;
- while ( bContinue )
+ long nIncluded = pRefDim->GetAutoCount();
+ ScDPDataMember* pDataMember1 = maMembers[aAutoOrder[nIncluded - 1]].get();
+ if ( !pDataMember1->IsVisible() )
+ pDataMember1 = nullptr;
+ bool bContinue = true;
+ while ( bContinue )
+ {
+ bContinue = false;
+ if ( nIncluded < nCount )
{
- bContinue = false;
- if ( nIncluded < nCount )
- {
- ScDPDataMember* pDataMember2 = maMembers[aAutoOrder[nIncluded]].get();
- if ( !pDataMember2->IsVisible() )
- pDataMember2 = nullptr;
+ ScDPDataMember* pDataMember2 = maMembers[aAutoOrder[nIncluded]].get();
+ if ( !pDataMember2->IsVisible() )
+ pDataMember2 = nullptr;
- if ( lcl_IsEqual( pDataMember1, pDataMember2, pRefDim->GetAutoMeasure() ) )
- {
- ++nIncluded; // include more members if values are equal
- bContinue = true;
- }
+ if ( lcl_IsEqual( pDataMember1, pDataMember2, pRefDim->GetAutoMeasure() ) )
+ {
+ ++nIncluded; // include more members if values are equal
+ bContinue = true;
}
}
+ }
- // hide the remaining members
+ // hide the remaining members
- for (nPos = nIncluded; nPos < nCount; nPos++)
- {
- ScDPResultMember* pMember = pRefDim->GetMember(aAutoOrder[nPos]);
- pMember->SetAutoHidden();
- }
+ for (nPos = nIncluded; nPos < nCount; nPos++)
+ {
+ ScDPResultMember* pMember = pRefDim->GetMember(aAutoOrder[nPos]);
+ pMember->SetAutoHidden();
}
}
@@ -3994,32 +3994,32 @@ void ScDPResultDimension::InitWithMembers(
ScDPLevel* pThisLevel = rParams.GetLevel( nPos );
SCROW nDataID = pItemData[nPos];
- if (pThisDim && pThisLevel)
- {
- long nDimSource = pThisDim->GetDimension(); //TODO: check GetSourceDim?
+ if (!(pThisDim && pThisLevel))
+ return;
- // create all members at the first call (preserve order)
- ResultMembers& rMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
- ScDPGroupCompare aCompare( pResultData, rInitState, nDimSource );
- // initialize only specific member (or all if "show empty" flag is set)
- ScDPResultMember* pResultMember = nullptr;
- if ( bInitialized )
- pResultMember = FindMember( nDataID );
- else
- bInitialized = true;
+ long nDimSource = pThisDim->GetDimension(); //TODO: check GetSourceDim?
- if ( pResultMember == nullptr )
- { //only insert found item
- const ScDPParentDimData* pMemberData = rMembers.FindMember( nDataID );
- if ( pMemberData && aCompare.IsIncluded( *( pMemberData->mpMemberDesc ) ) )
- pResultMember = InsertMember( pMemberData );
- }
- if ( pResultMember )
- {
- rInitState.AddMember( nDimSource, pResultMember->GetDataId() );
- pResultMember->LateInitFrom(rParams, pItemData, nPos+1, rInitState);
- rInitState.RemoveMember();
- }
+ // create all members at the first call (preserve order)
+ ResultMembers& rMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
+ ScDPGroupCompare aCompare( pResultData, rInitState, nDimSource );
+ // initialize only specific member (or all if "show empty" flag is set)
+ ScDPResultMember* pResultMember = nullptr;
+ if ( bInitialized )
+ pResultMember = FindMember( nDataID );
+ else
+ bInitialized = true;
+
+ if ( pResultMember == nullptr )
+ { //only insert found item
+ const ScDPParentDimData* pMemberData = rMembers.FindMember( nDataID );
+ if ( pMemberData && aCompare.IsIncluded( *( pMemberData->mpMemberDesc ) ) )
+ pResultMember = InsertMember( pMemberData );
+ }
+ if ( pResultMember )
+ {
+ rInitState.AddMember( nDimSource, pResultMember->GetDataId() );
+ pResultMember->LateInitFrom(rParams, pItemData, nPos+1, rInitState);
+ rInitState.RemoveMember();
}
}
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 0b9dd891e1d1..245c81dcd345 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -999,44 +999,44 @@ void ScDPSource::FillLevelList( sheet::DataPilotFieldOrientation nOrientation, s
void ScDPSource::FillMemberResults()
{
- if ( !pColResults && !pRowResults )
+ if ( pColResults || pRowResults )
+ return;
+
+ CreateRes_Impl();
+
+ if ( bResultOverflow ) // set in CreateRes_Impl
{
- CreateRes_Impl();
+ // no results available -> abort (leave empty)
+ // exception is thrown in ScDPSource::getResults
+ return;
+ }
- if ( bResultOverflow ) // set in CreateRes_Impl
- {
- // no results available -> abort (leave empty)
- // exception is thrown in ScDPSource::getResults
- return;
- }
+ FillLevelList( sheet::DataPilotFieldOrientation_COLUMN, aColLevelList );
+ long nColLevelCount = aColLevelList.size();
+ if (nColLevelCount)
+ {
+ long nColDimSize = pColResRoot->GetSize(pResData->GetColStartMeasure());
+ pColResults.reset(new uno::Sequence<sheet::MemberResult>[nColLevelCount]);
+ for (long i=0; i<nColLevelCount; i++)
+ pColResults[i].realloc(nColDimSize);
- FillLevelList( sheet::DataPilotFieldOrientation_COLUMN, aColLevelList );
- long nColLevelCount = aColLevelList.size();
- if (nColLevelCount)
- {
- long nColDimSize = pColResRoot->GetSize(pResData->GetColStartMeasure());
- pColResults.reset(new uno::Sequence<sheet::MemberResult>[nColLevelCount]);
- for (long i=0; i<nColLevelCount; i++)
- pColResults[i].realloc(nColDimSize);
-
- long nPos = 0;
- pColResRoot->FillMemberResults( pColResults.get(), nPos, pResData->GetColStartMeasure(),
- true, nullptr, nullptr );
- }
+ long nPos = 0;
+ pColResRoot->FillMemberResults( pColResults.get(), nPos, pResData->GetColStartMeasure(),
+ true, nullptr, nullptr );
+ }
- FillLevelList( sheet::DataPilotFieldOrientation_ROW, aRowLevelList );
- long nRowLevelCount = aRowLevelList.size();
- if (nRowLevelCount)
- {
- long nRowDimSize = pRowResRoot->GetSize(pResData->GetRowStartMeasure());
- pRowResults.reset( new uno::Sequence<sheet::MemberResult>[nRowLevelCount] );
- for (long i=0; i<nRowLevelCount; i++)
- pRowResults[i].realloc(nRowDimSize);
-
- long nPos = 0;
- pRowResRoot->FillMemberResults( pRowResults.get(), nPos, pResData->GetRowStartMeasure(),
- true, nullptr, nullptr );
- }
+ FillLevelList( sheet::DataPilotFieldOrientation_ROW, aRowLevelList );
+ long nRowLevelCount = aRowLevelList.size();
+ if (nRowLevelCount)
+ {
+ long nRowDimSize = pRowResRoot->GetSize(pResData->GetRowStartMeasure());
+ pRowResults.reset( new uno::Sequence<sheet::MemberResult>[nRowLevelCount] );
+ for (long i=0; i<nRowLevelCount; i++)
+ pRowResults[i].realloc(nRowDimSize);
+
+ long nPos = 0;
+ pRowResRoot->FillMemberResults( pRowResults.get(), nPos, pResData->GetRowStartMeasure(),
+ true, nullptr, nullptr );
}
}
@@ -1942,22 +1942,22 @@ void ScDPLevel::EvaluateSortOrder()
break;
}
- if ( aAutoShowInfo.IsEnabled )
- {
- // find index of measure (index among data dimensions)
+ if ( !aAutoShowInfo.IsEnabled )
+ return;
+
+ // find index of measure (index among data dimensions)
- long nMeasureCount = pSource->GetDataDimensionCount();
- for (long nMeasure=0; nMeasure<nMeasureCount; nMeasure++)
+ long nMeasureCount = pSource->GetDataDimensionCount();
+ for (long nMeasure=0; nMeasure<nMeasureCount; nMeasure++)
+ {
+ if (pSource->GetDataDimName(nMeasure) == aAutoShowInfo.DataField)
{
- if (pSource->GetDataDimName(nMeasure) == aAutoShowInfo.DataField)
- {
- nAutoMeasure = nMeasure;
- break;
- }
+ nAutoMeasure = nMeasure;
+ break;
}
-
- //TODO: error if not found?
}
+
+ //TODO: error if not found?
}
void ScDPLevel::SetEnableLayout(bool bSet)
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 48a0dacbac4a..4830dcc4f0fb 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -566,33 +566,33 @@ void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SC
void ScDrawLayer::SetPageSize( sal_uInt16 nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos )
{
SdrPage* pPage = GetPage(nPageNo);
- if (pPage)
+ if (!pPage)
+ return;
+
+ if ( rSize != pPage->GetSize() )
{
- if ( rSize != pPage->GetSize() )
- {
- pPage->SetSize( rSize );
- Broadcast( ScTabSizeChangedHint( static_cast<SCTAB>(nPageNo) ) ); // SetWorkArea() on the views
- }
+ pPage->SetSize( rSize );
+ Broadcast( ScTabSizeChangedHint( static_cast<SCTAB>(nPageNo) ) ); // SetWorkArea() on the views
+ }
- // Implement Detective lines (adjust to new heights / widths)
- // even if size is still the same
- // (individual rows/columns can have been changed))
+ // Implement Detective lines (adjust to new heights / widths)
+ // even if size is still the same
+ // (individual rows/columns can have been changed))
- bool bNegativePage = pDoc && pDoc->IsNegativePage( static_cast<SCTAB>(nPageNo) );
+ bool bNegativePage = pDoc && pDoc->IsNegativePage( static_cast<SCTAB>(nPageNo) );
- // Disable mass broadcasts from drawing objects' position changes.
- bool bWasLocked = isLocked();
- setLock(true);
- const size_t nCount = pPage->GetObjCount();
- for ( size_t i = 0; i < nCount; ++i )
- {
- SdrObject* pObj = pPage->GetObj( i );
- ScDrawObjData* pData = GetObjDataTab( pObj, static_cast<SCTAB>(nPageNo) );
- if( pData )
- RecalcPos( pObj, *pData, bNegativePage, bUpdateNoteCaptionPos );
- }
- setLock(bWasLocked);
+ // Disable mass broadcasts from drawing objects' position changes.
+ bool bWasLocked = isLocked();
+ setLock(true);
+ const size_t nCount = pPage->GetObjCount();
+ for ( size_t i = 0; i < nCount; ++i )
+ {
+ SdrObject* pObj = pPage->GetObj( i );
+ ScDrawObjData* pData = GetObjDataTab( pObj, static_cast<SCTAB>(nPageNo) );
+ if( pData )
+ RecalcPos( pObj, *pData, bNegativePage, bUpdateNoteCaptionPos );
}
+ setLock(bWasLocked);
}
namespace
@@ -1380,45 +1380,45 @@ void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
pPage->RecalcObjOrdNums();
const size_t nObjCount = pPage->GetObjCount();
- if (nObjCount)
- {
- size_t nDelCount = 0;
- tools::Rectangle aDelRect = pDoc->GetMMRect( nCol1, nRow1, nCol2, nRow2, nTab );
+ if (!nObjCount)
+ return;
- std::unique_ptr<SdrObject*[]> ppObj(new SdrObject*[nObjCount]);
+ size_t nDelCount = 0;
+ tools::Rectangle aDelRect = pDoc->GetMMRect( nCol1, nRow1, nCol2, nRow2, nTab );
- SdrObjListIter aIter( pPage, SdrIterMode::Flat );
- SdrObject* pObject = aIter.Next();
- while (pObject)
+ std::unique_ptr<SdrObject*[]> ppObj(new SdrObject*[nObjCount]);
+
+ SdrObjListIter aIter( pPage, SdrIterMode::Flat );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ // do not delete note caption, they are always handled by the cell note
+ // TODO: detective objects are still deleted, is this desired?
+ if (!IsNoteCaption( pObject ))
{
- // do not delete note caption, they are always handled by the cell note
- // TODO: detective objects are still deleted, is this desired?
- if (!IsNoteCaption( pObject ))
+ tools::Rectangle aObjRect = pObject->GetCurrentBoundRect();
+ if (aDelRect.IsInside(aObjRect))
{
- tools::Rectangle aObjRect = pObject->GetCurrentBoundRect();
- if (aDelRect.IsInside(aObjRect))
+ if (bAnchored)
{
- if (bAnchored)
- {
- ScAnchorType aAnchorType = ScDrawLayer::GetAnchorType(*pObject);
- if(aAnchorType == SCA_CELL || aAnchorType == SCA_CELL_RESIZE)
- ppObj[nDelCount++] = pObject;
- }
- else
+ ScAnchorType aAnchorType = ScDrawLayer::GetAnchorType(*pObject);
+ if(aAnchorType == SCA_CELL || aAnchorType == SCA_CELL_RESIZE)
ppObj[nDelCount++] = pObject;
}
+ else
+ ppObj[nDelCount++] = pObject;
}
-
- pObject = aIter.Next();
}
- if (bRecording)
- for (size_t i=1; i<=nDelCount; ++i)
- AddCalcUndo( std::make_unique<SdrUndoRemoveObj>( *ppObj[nDelCount-i] ) );
+ pObject = aIter.Next();
+ }
+ if (bRecording)
for (size_t i=1; i<=nDelCount; ++i)
- pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() );
- }
+ AddCalcUndo( std::make_unique<SdrUndoRemoveObj>( *ppObj[nDelCount-i] ) );
+
+ for (size_t i=1; i<=nDelCount; ++i)
+ pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() );
}
void ScDrawLayer::DeleteObjectsInSelection( const ScMarkData& rMark )
@@ -1503,61 +1503,61 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec
// copy everything in the specified range into the same page (sheet) in the clipboard doc
SdrPage* pSrcPage = GetPage(static_cast<sal_uInt16>(nTab));
- if (pSrcPage)
+ if (!pSrcPage)
+ return;
+
+ ScDrawLayer* pDestModel = nullptr;
+ SdrPage* pDestPage = nullptr;
+
+ SdrObjListIter aIter( pSrcPage, SdrIterMode::Flat );
+ SdrObject* pOldObject = aIter.Next();
+ while (pOldObject)
{
- ScDrawLayer* pDestModel = nullptr;
- SdrPage* pDestPage = nullptr;
+ tools::Rectangle aObjRect = pOldObject->GetCurrentBoundRect();
- SdrObjListIter aIter( pSrcPage, SdrIterMode::Flat );
- SdrObject* pOldObject = aIter.Next();
- while (pOldObject)
+ bool bObjectInArea = rRange.IsInside(aObjRect);
+ const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pOldObject);
+ if (pObjData)
{
- tools::Rectangle aObjRect = pOldObject->GetCurrentBoundRect();
-
- bool bObjectInArea = rRange.IsInside(aObjRect);
- const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pOldObject);
- if (pObjData)
- {
- ScRange aClipRange = lcl_getClipRangeFromClipDoc(pClipDoc, nTab);
- bObjectInArea = bObjectInArea || aClipRange.In(pObjData->maStart);
- }
+ ScRange aClipRange = lcl_getClipRangeFromClipDoc(pClipDoc, nTab);
+ bObjectInArea = bObjectInArea || aClipRange.In(pObjData->maStart);
+ }
- // do not copy internal objects (detective) and note captions
- if (bObjectInArea && pOldObject->GetLayer() != SC_LAYER_INTERN
- && !IsNoteCaption(pOldObject))
+ // do not copy internal objects (detective) and note captions
+ if (bObjectInArea && pOldObject->GetLayer() != SC_LAYER_INTERN
+ && !IsNoteCaption(pOldObject))
+ {
+ if ( !pDestModel )
{
+ pDestModel = pClipDoc->GetDrawLayer(); // does the document already have a drawing layer?
if ( !pDestModel )
{
- pDestModel = pClipDoc->GetDrawLayer(); // does the document already have a drawing layer?
- if ( !pDestModel )
- {
- // allocate drawing layer in clipboard document only if there are objects to copy
+ // allocate drawing layer in clipboard document only if there are objects to copy
- pClipDoc->InitDrawLayer(); //TODO: create contiguous pages
- pDestModel = pClipDoc->GetDrawLayer();
- }
- if (pDestModel)
- pDestPage = pDestModel->GetPage( static_cast<sal_uInt16>(nTab) );
+ pClipDoc->InitDrawLayer(); //TODO: create contiguous pages
+ pDestModel = pClipDoc->GetDrawLayer();
}
+ if (pDestModel)
+ pDestPage = pDestModel->GetPage( static_cast<sal_uInt16>(nTab) );
+ }
- OSL_ENSURE( pDestPage, "no page" );
- if (pDestPage)
- {
- // Clone to target SdrModel
- SdrObject* pNewObject(pOldObject->CloneSdrObject(*pDestModel));
+ OSL_ENSURE( pDestPage, "no page" );
+ if (pDestPage)
+ {
+ // Clone to target SdrModel
+ SdrObject* pNewObject(pOldObject->CloneSdrObject(*pDestModel));
- uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) );
- if(!xOldChart.is())//#i110034# do not move charts as they lose all their data references otherwise
- pNewObject->NbcMove(Size(0,0));
- pDestPage->InsertObject( pNewObject );
+ uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) );
+ if(!xOldChart.is())//#i110034# do not move charts as they lose all their data references otherwise
+ pNewObject->NbcMove(Size(0,0));
+ pDestPage->InsertObject( pNewObject );
- // no undo needed in clipboard document
- // charts are not updated
- }
+ // no undo needed in clipboard document
+ // charts are not updated
}
-
- pOldObject = aIter.Next();
}
+
+ pOldObject = aIter.Next();
}
}
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index e20a147ef528..144e2e482a15 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2343,46 +2343,46 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa
void ScFormulaCell::HandleStuffAfterParallelCalculation(ScInterpreter* pInterpreter)
{
- if( pCode->GetCodeLen() && pDocument )
- {
- if ( !pCode->IsRecalcModeAlways() )
- pDocument->RemoveFromFormulaTree( this );
+ if( !(pCode->GetCodeLen() && pDocument) )
+ return;
- std::unique_ptr<ScInterpreter> pScopedInterpreter;
- if (pInterpreter)
- pInterpreter->Init(this, aPos, *pCode);
- else
- {
- pScopedInterpreter.reset(new ScInterpreter( this, pDocument, pDocument->GetNonThreadedContext(), aPos, *pCode ));
- pInterpreter = pScopedInterpreter.get();
- }
+ if ( !pCode->IsRecalcModeAlways() )
+ pDocument->RemoveFromFormulaTree( this );
- switch (pInterpreter->GetVolatileType())
- {
- case ScInterpreter::VOLATILE_MACRO:
- // The formula contains a volatile macro.
- pCode->SetExclusiveRecalcModeAlways();
- pDocument->PutInFormulaTree(this);
- StartListeningTo(pDocument);
- break;
- case ScInterpreter::NOT_VOLATILE:
- if (pCode->IsRecalcModeAlways())
- {
- // The formula was previously volatile, but no more.
- EndListeningTo(pDocument);
- pCode->SetExclusiveRecalcModeNormal();
- }
- else
- {
- // non-volatile formula. End listening to the area in case
- // it's listening due to macro module change.
- pDocument->EndListeningArea(BCA_LISTEN_ALWAYS, false, this);
- }
- pDocument->RemoveFromFormulaTree(this);
- break;
- default:
- ;
- }
+ std::unique_ptr<ScInterpreter> pScopedInterpreter;
+ if (pInterpreter)
+ pInterpreter->Init(this, aPos, *pCode);
+ else
+ {
+ pScopedInterpreter.reset(new ScInterpreter( this, pDocument, pDocument->GetNonThreadedContext(), aPos, *pCode ));
+ pInterpreter = pScopedInterpreter.get();
+ }
+
+ switch (pInterpreter->GetVolatileType())
+ {
+ case ScInterpreter::VOLATILE_MACRO:
+ // The formula contains a volatile macro.
+ pCode->SetExclusiveRecalcModeAlways();
+ pDocument->PutInFormulaTree(this);
+ StartListeningTo(pDocument);
+ break;
+ case ScInterpreter::NOT_VOLATILE:
+ if (pCode->IsRecalcModeAlways())
+ {
+ // The formula was previously volatile, but no more.
+ EndListeningTo(pDocument);
+ pCode->SetExclusiveRecalcModeNormal();
+ }
+ else
+ {
+ // non-volatile formula. End listening to the area in case
+ // it's listening due to macro module change.
+ pDocument->EndListeningArea(BCA_LISTEN_ALWAYS, false, this);
+ }
+ pDocument->RemoveFromFormulaTree(this);
+ break;
+ default:
+ ;
}
}
@@ -2475,39 +2475,39 @@ void ScFormulaCell::Notify( const SfxHint& rHint )
return;
}
- if ( pDocument->GetHardRecalcState() == ScDocument::HardRecalcState::OFF )
+ if ( pDocument->GetHardRecalcState() != ScDocument::HardRecalcState::OFF )
+ return;
+
+ if (!(nHint == SfxHintId::ScDataChanged || nHint == SfxHintId::ScTableOpDirty || (bSubTotal && nHint == SfxHintId::ScHiddenRowsChanged)))
+ return;
+
+ bool bForceTrack = false;
+ if ( nHint == SfxHintId::ScTableOpDirty )
{
- if (nHint == SfxHintId::ScDataChanged || nHint == SfxHintId::ScTableOpDirty || (bSubTotal && nHint == SfxHintId::ScHiddenRowsChanged))
+ bForceTrack = !bTableOpDirty;
+ if ( !bTableOpDirty )
{
- bool bForceTrack = false;
- if ( nHint == SfxHintId::ScTableOpDirty )
- {
- bForceTrack = !bTableOpDirty;
- if ( !bTableOpDirty )
- {
- pDocument->AddTableOpFormulaCell( this );
- bTableOpDirty = true;
- }
- }
- else
- {
- bForceTrack = !bDirty;
- SetDirtyVar();
- }
- // Don't remove from FormulaTree to put in FormulaTrack to
- // put in FormulaTree again and again, only if necessary.
- // Any other means except ScRecalcMode::ALWAYS by which a cell could
- // be in FormulaTree if it would notify other cells through
- // FormulaTrack which weren't in FormulaTrack/FormulaTree before?!?
- // Yes. The new TableOpDirty made it necessary to have a
- // forced mode where formulas may still be in FormulaTree from
- // TableOpDirty but have to notify dependents for normal dirty.
- if ( (bForceTrack || !pDocument->IsInFormulaTree( this )
- || pCode->IsRecalcModeAlways())
- && !pDocument->IsInFormulaTrack( this ) )
- pDocument->AppendToFormulaTrack( this );
+ pDocument->AddTableOpFormulaCell( this );
+ bTableOpDirty = true;
}
}
+ else
+ {
+ bForceTrack = !bDirty;
+ SetDirtyVar();
+ }
+ // Don't remove from FormulaTree to put in FormulaTrack to
+ // put in FormulaTree again and again, only if necessary.
+ // Any other means except ScRecalcMode::ALWAYS by which a cell could
+ // be in FormulaTree if it would notify other cells through
+ // FormulaTrack which weren't in FormulaTrack/FormulaTree before?!?
+ // Yes. The new TableOpDirty made it necessary to have a
+ // forced mode where formulas may still be in FormulaTree from
+ // TableOpDirty but have to notify dependents for normal dirty.
+ if ( (bForceTrack || !pDocument->IsInFormulaTree( this )
+ || pCode->IsRecalcModeAlways())
+ && !pDocument->IsInFormulaTrack( this ) )
+ pDocument->AppendToFormulaTrack( this );
}
void ScFormulaCell::Query( SvtListener::QueryBase& rQuery ) const
@@ -2589,22 +2589,22 @@ void ScFormulaCell::ResetTableOpDirtyVar()
void ScFormulaCell::SetTableOpDirty()
{
- if ( !IsInChangeTrack() )
+ if ( IsInChangeTrack() )
+ return;
+
+ if ( pDocument->GetHardRecalcState() != ScDocument::HardRecalcState::OFF )
+ bTableOpDirty = true;
+ else
{
- if ( pDocument->GetHardRecalcState() != ScDocument::HardRecalcState::OFF )
- bTableOpDirty = true;
- else
+ if ( !bTableOpDirty || !pDocument->IsInFormulaTree( this ) )
{
- if ( !bTableOpDirty || !pDocument->IsInFormulaTree( this ) )
+ if ( !bTableOpDirty )
{
- if ( !bTableOpDirty )
- {
- pDocument->AddTableOpFormulaCell( this );
- bTableOpDirty = true;
- }
- pDocument->AppendToFormulaTrack( this );
- pDocument->TrackFormulas( SfxHintId::ScTableOpDirty );
+ pDocument->AddTableOpFormulaCell( this );
+ bTableOpDirty = true;
}
+ pDocument->AppendToFormulaTrack( this );
+ pDocument->TrackFormulas( SfxHintId::ScTableOpDirty );
}
}
}
@@ -5224,21 +5224,21 @@ void startListeningArea(
const ScSingleRefData& rRef2 = *rToken.GetSingleRef2();
ScAddress aCell1 = rRef1.toAbs(&rDoc, rPos);
ScAddress aCell2 = rRef2.toAbs(&rDoc, rPos);
- if (aCell1.IsValid() && aCell2.IsValid())
- {
- if (rToken.GetOpCode() == ocColRowNameAuto)
- { // automagically
- if ( rRef1.IsColRel() )
- { // ColName
- aCell2.SetRow(MAXROW);
- }
- else
- { // RowName
- aCell2.SetCol(MAXCOL);
- }
+ if (!(aCell1.IsValid() && aCell2.IsValid()))
+ return;
+
+ if (rToken.GetOpCode() == ocColRowNameAuto)
+ { // automagically
+ if ( rRef1.IsColRel() )
+ { // ColName
+ aCell2.SetRow(MAXROW);
+ }
+ else
+ { // RowName
+ aCell2.SetCol(MAXCOL);
}
- rDoc.StartListeningArea(ScRange(aCell1, aCell2), false, pCell);
}
+ rDoc.StartListeningArea(ScRange(aCell1, aCell2), false, pCell);
}
}
@@ -5336,22 +5336,22 @@ void endListeningArea(
const ScSingleRefData& rRef2 = *rToken.GetSingleRef2();
ScAddress aCell1 = rRef1.toAbs(&rDoc, rPos);
ScAddress aCell2 = rRef2.toAbs(&rDoc, rPos);
- if (aCell1.IsValid() && aCell2.IsValid())
- {
- if (rToken.GetOpCode() == ocColRowNameAuto)
- { // automagically
- if ( rRef1.IsColRel() )
- { // ColName
- aCell2.SetRow(MAXROW);
- }
- else
- { // RowName
- aCell2.SetCol(MAXCOL);
- }
- }
+ if (!(aCell1.IsValid() && aCell2.IsValid()))
+ return;
- rDoc.EndListeningArea(ScRange(aCell1, aCell2), false, pCell);
+ if (rToken.GetOpCode() == ocColRowNameAuto)
+ { // automagically
+ if ( rRef1.IsColRel() )
+ { // ColName
+ aCell2.SetRow(MAXROW);
+ }
+ else
+ { // RowName
+ aCell2.SetCol(MAXCOL);
+ }
}
+
+ rDoc.EndListeningArea(ScRange(aCell1, aCell2), false, pCell);
}
}
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index d84aa36ab138..154ef0db4cd5 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -329,24 +329,24 @@ void ScFuncDesc::initArgumentInfo() const
// get the full argument description
// (add-in has to be instantiated to get the type information)
- if ( bIncomplete && mxFuncName )
- {
- ScUnoAddInCollection& rAddIns = *ScGlobal::GetAddInCollection();
- OUString aIntName(rAddIns.FindFunction( *mxFuncName, true )); // pFuncName is upper-case
+ if ( !(bIncomplete && mxFuncName) )
+ return;
- if ( !aIntName.isEmpty() )
- {
- // GetFuncData with bComplete=true loads the component and updates
- // the global function list if needed.
+ ScUnoAddInCollection& rAddIns = *ScGlobal::GetAddInCollection();
+ OUString aIntName(rAddIns.FindFunction( *mxFuncName, true )); // pFuncName is upper-case
- rAddIns.GetFuncData( aIntName, true );
- }
+ if ( !aIntName.isEmpty() )
+ {
+ // GetFuncData with bComplete=true loads the component and updates
+ // the global function list if needed.
- if ( bIncomplete )
- {
- OSL_FAIL( "couldn't initialize add-in function" );
- const_cast<ScFuncDesc*>(this)->bIncomplete = false; // even if there was an error, don't try again
- }
+ rAddIns.GetFuncData( aIntName, true );
+ }
+
+ if ( bIncomplete )
+ {
+ OSL_FAIL( "couldn't initialize add-in function" );
+ const_cast<ScFuncDesc*>(this)->bIncomplete = false; // even if there was an error, don't try again
}
}
@@ -1235,37 +1235,37 @@ static void ScFuncRes(const ScFuncDescCore &rEntry, ScFuncDesc* pDesc, bool& rbS
pDesc->mxFuncName = ScCompiler::GetNativeSymbol(static_cast<OpCode>(nOpCode));
pDesc->mxFuncDesc = ScResId(rEntry.pResource[0]);
- if (nArgs)
+ if (!nArgs)
+ return;
+
+ pDesc->maDefArgNames.clear();
+ pDesc->maDefArgNames.resize(nArgs);
+ pDesc->maDefArgDescs.clear();
+ pDesc->maDefArgDescs.resize(nArgs);
+ for (sal_uInt16 i = 0; i < nArgs; ++i)
{
- pDesc->maDefArgNames.clear();
- pDesc->maDefArgNames.resize(nArgs);
- pDesc->maDefArgDescs.clear();
- pDesc->maDefArgDescs.resize(nArgs);
- for (sal_uInt16 i = 0; i < nArgs; ++i)
+ size_t nIndex = (i * 2) + 1;
+ if (nIndex < rEntry.nResourceLen)
+ pDesc->maDefArgNames[i] = ScResId(rEntry.pResource[nIndex]);
+ if (nIndex + 1 < rEntry.nResourceLen)
+ pDesc->maDefArgDescs[i] = ScResId(rEntry.pResource[nIndex + 1]);
+ // If empty and variable number of arguments and last parameter and
+ // parameter is optional and the previous is not optional, repeat
+ // previous parameter name and description.
+ if ((pDesc->maDefArgNames[i].isEmpty() || pDesc->maDefArgDescs[i].isEmpty()) &&
+ nVarArgsSet > 0 && i > nVarArgsSet && (i == nArgs-1 || i == nArgs-2) &&
+ pDesc->pDefArgFlags[i].bOptional)
{
- size_t nIndex = (i * 2) + 1;
- if (nIndex < rEntry.nResourceLen)
- pDesc->maDefArgNames[i] = ScResId(rEntry.pResource[nIndex]);
- if (nIndex + 1 < rEntry.nResourceLen)
- pDesc->maDefArgDescs[i] = ScResId(rEntry.pResource[nIndex + 1]);
- // If empty and variable number of arguments and last parameter and
- // parameter is optional and the previous is not optional, repeat
- // previous parameter name and description.
- if ((pDesc->maDefArgNames[i].isEmpty() || pDesc->maDefArgDescs[i].isEmpty()) &&
- nVarArgsSet > 0 && i > nVarArgsSet && (i == nArgs-1 || i == nArgs-2) &&
- pDesc->pDefArgFlags[i].bOptional)
+ sal_uInt16 nPrev = i - nVarArgsSet;
+ if (!pDesc->pDefArgFlags[nPrev].bOptional)
{
- sal_uInt16 nPrev = i - nVarArgsSet;
- if (!pDesc->pDefArgFlags[nPrev].bOptional)
- {
- if (pDesc->maDefArgNames[i].isEmpty())
- pDesc->maDefArgNames[i] = pDesc->maDefArgNames[nPrev];
- if (pDesc->maDefArgDescs[i].isEmpty())
- pDesc->maDefArgDescs[i] = pDesc->maDefArgDescs[nPrev];
- // This also means that variable arguments start one
- // parameter set earlier.
- pDesc->nVarArgsStart -= nVarArgsSet;
- }
+ if (pDesc->maDefArgNames[i].isEmpty())
+ pDesc->maDefArgNames[i] = pDesc->maDefArgNames[nPrev];
+ if (pDesc->maDefArgDescs[i].isEmpty())
+ pDesc->maDefArgDescs[i] = pDesc->maDefArgDescs[nPrev];
+ // This also means that variable arguments start one
+ // parameter set earlier.
+ pDesc->nVarArgsStart -= nVarArgsSet;
}
}
}
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 05583b96f327..f416d28673fe 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -964,21 +964,21 @@ void ScGlobal::AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatte
"ScGlobal::AddLanguage - language already added");
const SfxPoolItem* pHardItem;
- if ( rSet.GetItemState( ATTR_VALUE_FORMAT, false, &pHardItem ) == SfxItemState::SET )
- {
- const SvNumberformat* pHardFormat = rFormatter.GetEntry(
- static_cast<const SfxUInt32Item*>(pHardItem)->GetValue() );
-
- sal_uInt32 nParentFmt = 0; // Pool default
- const SfxItemSet* pParent = rSet.GetParent();
- if ( pParent )
- nParentFmt = pParent->Get( ATTR_VALUE_FORMAT ).GetValue();
- const SvNumberformat* pParFormat = rFormatter.GetEntry( nParentFmt );
-
- if ( pHardFormat && pParFormat &&
- (pHardFormat->GetLanguage() != pParFormat->GetLanguage()) )
- rSet.Put( SvxLanguageItem( pHardFormat->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
- }
+ if ( rSet.GetItemState( ATTR_VALUE_FORMAT, false, &pHardItem ) != SfxItemState::SET )
+ return;
+
+ const SvNumberformat* pHardFormat = rFormatter.GetEntry(
+ static_cast<const SfxUInt32Item*>(pHardItem)->GetValue() );
+
+ sal_uInt32 nParentFmt = 0; // Pool default
+ const SfxItemSet* pParent = rSet.GetParent();
+ if ( pParent )
+ nParentFmt = pParent->Get( ATTR_VALUE_FORMAT ).GetValue();
+ const SvNumberformat* pParFormat = rFormatter.GetEntry( nParentFmt );
+
+ if ( pHardFormat && pParFormat &&
+ (pHardFormat->GetLanguage() != pParFormat->GetLanguage()) )
+ rSet.Put( SvxLanguageItem( pHardFormat->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
}
utl::TransliterationWrapper* ScGlobal::GetpTransliteration()
diff --git a/sc/source/core/data/markarr.cxx b/sc/source/core/data/markarr.cxx
index 68fc09781a76..87dc032150b5 100644
--- a/sc/source/core/data/markarr.cxx
+++ b/sc/source/core/data/markarr.cxx
@@ -107,107 +107,107 @@ bool ScMarkArray::GetMark( SCROW nRow ) const
void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked )
{
- if (mrSheetLimits.ValidRow(nStartRow) && mrSheetLimits.ValidRow(nEndRow))
+ if (!(mrSheetLimits.ValidRow(nStartRow) && mrSheetLimits.ValidRow(nEndRow)))
+ return;
+
+ if ((nStartRow == 0) && (nEndRow == mrSheetLimits.mnMaxRow))
+ {
+ Reset(bMarked);
+ }
+ else
{
- if ((nStartRow == 0) && (nEndRow == mrSheetLimits.mnMaxRow))
+ SCSIZE ni; // number of entries in beginning
+ SCSIZE nInsert; // insert position (mnMaxRow+1 := no insert)
+ bool bCombined = false;
+ bool bSplit = false;
+ if ( nStartRow > 0 )
{
- Reset(bMarked);
+ // skip beginning
+ SCSIZE nIndex;
+ Search( nStartRow, nIndex );
+ ni = nIndex;
+
+ nInsert = mrSheetLimits.GetMaxRowCount();
+ if ( mvData[ni].bMarked != bMarked )
+ {
+ if ( ni == 0 || (mvData[ni-1].nRow < nStartRow - 1) )
+ { // may be a split or a simple insert or just a shrink,
+ // row adjustment is done further down
+ if ( mvData[ni].nRow > nEndRow )
+ bSplit = true;
+ ni++;
+ nInsert = ni;
+ }
+ else if ( ni > 0 && mvData[ni-1].nRow == nStartRow - 1 )
+ nInsert = ni;
+ }
+ if ( ni > 0 && mvData[ni-1].bMarked == bMarked )
+ { // combine
+ mvData[ni-1].nRow = nEndRow;
+ nInsert = mrSheetLimits.GetMaxRowCount();
+ bCombined = true;
+ }
}
else
{
- SCSIZE ni; // number of entries in beginning
- SCSIZE nInsert; // insert position (mnMaxRow+1 := no insert)
- bool bCombined = false;
- bool bSplit = false;
- if ( nStartRow > 0 )
- {
- // skip beginning
- SCSIZE nIndex;
- Search( nStartRow, nIndex );
- ni = nIndex;
+ nInsert = 0;
+ ni = 0;
+ }
- nInsert = mrSheetLimits.GetMaxRowCount();
- if ( mvData[ni].bMarked != bMarked )
+ SCSIZE nj = ni; // stop position of range to replace
+ while ( nj < mvData.size() && mvData[nj].nRow <= nEndRow )
+ nj++;
+ if ( !bSplit )
+ {
+ if ( nj < mvData.size() && mvData[nj].bMarked == bMarked )
+ { // combine
+ if ( ni > 0 )
{
- if ( ni == 0 || (mvData[ni-1].nRow < nStartRow - 1) )
- { // may be a split or a simple insert or just a shrink,
- // row adjustment is done further down
- if ( mvData[ni].nRow > nEndRow )
- bSplit = true;
- ni++;
- nInsert = ni;
+ if ( mvData[ni-1].bMarked == bMarked )
+ { // adjacent entries
+ mvData[ni-1].nRow = mvData[nj].nRow;
+ nj++;
}
- else if ( ni > 0 && mvData[ni-1].nRow == nStartRow - 1 )
- nInsert = ni;
+ else if ( ni == nInsert )
+ mvData[ni-1].nRow = nStartRow - 1; // shrink
}
- if ( ni > 0 && mvData[ni-1].bMarked == bMarked )
- { // combine
- mvData[ni-1].nRow = nEndRow;
- nInsert = mrSheetLimits.GetMaxRowCount();
- bCombined = true;
- }
- }
- else
- {
- nInsert = 0;
- ni = 0;
+ nInsert = mrSheetLimits.GetMaxRowCount();
+ bCombined = true;
}
-
- SCSIZE nj = ni; // stop position of range to replace
- while ( nj < mvData.size() && mvData[nj].nRow <= nEndRow )
- nj++;
- if ( !bSplit )
- {
- if ( nj < mvData.size() && mvData[nj].bMarked == bMarked )
- { // combine
- if ( ni > 0 )
- {
- if ( mvData[ni-1].bMarked == bMarked )
- { // adjacent entries
- mvData[ni-1].nRow = mvData[nj].nRow;
- nj++;
- }
- else if ( ni == nInsert )
- mvData[ni-1].nRow = nStartRow - 1; // shrink
- }
- nInsert = mrSheetLimits.GetMaxRowCount();
- bCombined = true;
- }
- else if ( ni > 0 && ni == nInsert )
- mvData[ni-1].nRow = nStartRow - 1; // shrink
+ else if ( ni > 0 && ni == nInsert )
+ mvData[ni-1].nRow = nStartRow - 1; // shrink
+ }
+ if ( ni < nj )
+ { // remove middle entries
+ if ( !bCombined )
+ { // replace one entry
+ mvData[ni].nRow = nEndRow;
+ mvData[ni].bMarked = bMarked;
+ ni++;
+ nInsert = mrSheetLimits.GetMaxRowCount();
}
if ( ni < nj )
- { // remove middle entries
- if ( !bCombined )
- { // replace one entry
- mvData[ni].nRow = nEndRow;
- mvData[ni].bMarked = bMarked;
- ni++;
- nInsert = mrSheetLimits.GetMaxRowCount();
- }
- if ( ni < nj )
- { // remove entries
- mvData.erase(mvData.begin() + ni, mvData.begin() + nj);
- }
+ { // remove entries
+ mvData.erase(mvData.begin() + ni, mvData.begin() + nj);
}
+ }
- if ( nInsert < sal::static_int_cast<SCSIZE>(mrSheetLimits.GetMaxRowCount()) )
- { // insert or append new entry
- if ( nInsert <= mvData.size() )
+ if ( nInsert < sal::static_int_cast<SCSIZE>(mrSheetLimits.GetMaxRowCount()) )
+ { // insert or append new entry
+ if ( nInsert <= mvData.size() )
+ {
+ if ( !bSplit )
+ mvData.insert(mvData.begin() + nInsert, { nEndRow, bMarked });
+ else
{
- if ( !bSplit )
- mvData.insert(mvData.begin() + nInsert, { nEndRow, bMarked });
- else
- {
- mvData.insert(mvData.begin() + nInsert, 2, { nEndRow, bMarked });
- mvData[nInsert+1] = mvData[nInsert-1];
- }
+ mvData.insert(mvData.begin() + nInsert, 2, { nEndRow, bMarked });
+ mvData[nInsert+1] = mvData[nInsert-1];
}
- else
- mvData.push_back(ScMarkEntry{ nEndRow, bMarked });
- if ( nInsert )
- mvData[nInsert-1].nRow = nStartRow - 1;
}
+ else
+ mvData.push_back(ScMarkEntry{ nEndRow, bMarked });
+ if ( nInsert )
+ mvData[nInsert-1].nRow = nStartRow - 1;
}
}
}
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index d2983b25688a..0740246bc220 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -242,43 +242,43 @@ void ScMarkData::MarkToSimple()
if ( bMultiMarked && bMarked )
MarkToMulti(); // may result in bMarked and bMultiMarked reset
- if ( bMultiMarked )
- {
- ScRange aNew = aMultiRange;
+ if ( !bMultiMarked )
+ return;
- bool bOk = false;
- SCCOL nStartCol = aNew.aStart.Col();
- SCCOL nEndCol = aNew.aEnd.Col();
+ ScRange aNew = aMultiRange;
- while ( nStartCol < nEndCol && !aMultiSel.HasMarks( nStartCol ) )
- ++nStartCol;
- while ( nStartCol < nEndCol && !aMultiSel.HasMarks( nEndCol ) )
- --nEndCol;
+ bool bOk = false;
+ SCCOL nStartCol = aNew.aStart.Col();
+ SCCOL nEndCol = aNew.aEnd.Col();
- // Rows are only taken from MarkArray
- SCROW nStartRow, nEndRow;
- if ( aMultiSel.HasOneMark( nStartCol, nStartRow, nEndRow ) )
- {
- bOk = true;
- SCROW nCmpStart, nCmpEnd;
- for (SCCOL nCol=nStartCol+1; nCol<=nEndCol && bOk; nCol++)
- if ( !aMultiSel.HasOneMark( nCol, nCmpStart, nCmpEnd )
- || nCmpStart != nStartRow || nCmpEnd != nEndRow )
- bOk = false;
- }
+ while ( nStartCol < nEndCol && !aMultiSel.HasMarks( nStartCol ) )
+ ++nStartCol;
+ while ( nStartCol < nEndCol && !aMultiSel.HasMarks( nEndCol ) )
+ --nEndCol;
- if (bOk)
- {
- aNew.aStart.SetCol(nStartCol);
- aNew.aStart.SetRow(nStartRow);
- aNew.aEnd.SetCol(nEndCol);
- aNew.aEnd.SetRow(nEndRow);
+ // Rows are only taken from MarkArray
+ SCROW nStartRow, nEndRow;
+ if ( aMultiSel.HasOneMark( nStartCol, nStartRow, nEndRow ) )
+ {
+ bOk = true;
+ SCROW nCmpStart, nCmpEnd;
+ for (SCCOL nCol=nStartCol+1; nCol<=nEndCol && bOk; nCol++)
+ if ( !aMultiSel.HasOneMark( nCol, nCmpStart, nCmpEnd )
+ || nCmpStart != nStartRow || nCmpEnd != nEndRow )
+ bOk = false;
+ }
- ResetMark();
- aMarkRange = aNew;
- bMarked = true;
- bMarkIsNeg = false;
- }
+ if (bOk)
+ {
+ aNew.aStart.SetCol(nStartCol);
+ aNew.aStart.SetRow(nStartRow);
+ aNew.aEnd.SetCol(nEndCol);
+ aNew.aEnd.SetRow(nEndRow);
+
+ ResetMark();
+ aMarkRange = aNew;
+ bMarked = true;
+ bMarkIsNeg = false;
}
}
diff --git a/sc/source/core/data/markmulti.cxx b/sc/source/core/data/markmulti.cxx
index f14999f542c7..95c52bc90e69 100644
--- a/sc/source/core/data/markmulti.cxx
+++ b/sc/source/core/data/markmulti.cxx
@@ -376,20 +376,20 @@ void ScMultiSel::ShiftCols(SCCOL nStartCol, long nColOffset)
}
aRowSel = aNewMultiSel.aRowSel;
- if (nColOffset > 0 && nStartCol > 0 && nStartCol < static_cast<SCCOL>(aNewMultiSel.aMultiSelContainer.size()))
- {
- // insert nColOffset new columns, and select their cells if they are selected
- // both in the old column at nStartPos and in the previous column
- auto& rPrevPos = aNewMultiSel.aMultiSelContainer[nStartCol - 1];
- auto& rStartPos = aNewMultiSel.aMultiSelContainer[nStartCol];
- auto& rNewCol = aMultiSelContainer[nStartCol];
- rNewCol = rStartPos;
- rNewCol.Intersect(rPrevPos);
- if (nStartCol + nColOffset >= static_cast<SCCOL>(aNewMultiSel.aMultiSelContainer.size()))
- aNewMultiSel.aMultiSelContainer.resize(nStartCol + nColOffset, ScMarkArray(mrSheetLimits));
- for (long i = 1; i < nColOffset; ++i)
- aMultiSelContainer[nStartCol + i] = rNewCol;
- }
+ if (!(nColOffset > 0 && nStartCol > 0 && nStartCol < static_cast<SCCOL>(aNewMultiSel.aMultiSelContainer.size())))
+ return;
+
+ // insert nColOffset new columns, and select their cells if they are selected
+ // both in the old column at nStartPos and in the previous column
+ auto& rPrevPos = aNewMultiSel.aMultiSelContainer[nStartCol - 1];
+ auto& rStartPos = aNewMultiSel.aMultiSelContainer[nStartCol];
+ auto& rNewCol = aMultiSelContainer[nStartCol];
+ rNewCol = rStartPos;
+ rNewCol.Intersect(rPrevPos);
+ if (nStartCol + nColOffset >= static_cast<SCCOL>(aNewMultiSel.aMultiSelContainer.size()))
+ aNewMultiSel.aMultiSelContainer.resize(nStartCol + nColOffset, ScMarkArray(mrSheetLimits));
+ for (long i = 1; i < nColOffset; ++i)
+ aMultiSelContainer[nStartCol + i] = rNewCol;
}
void ScMultiSel::ShiftRows(SCROW nStartRow, long nRowOffset)
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 005cfe23fc3e..eba3bcddd464 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -855,37 +855,37 @@ void ScPatternAttr::GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet&
if (rEditSet.GetItemState(EE_CHAR_LANGUAGE_CTL,true,&pItem) == SfxItemState::SET)
rDestSet.Put( SvxLanguageItem(static_cast<const SvxLanguageItem*>(pItem)->GetValue(), ATTR_CTL_FONT_LANGUAGE) );
- if (rEditSet.GetItemState(EE_PARA_JUST,true,&pItem) == SfxItemState::SET)
+ if (rEditSet.GetItemState(EE_PARA_JUST,true,&pItem) != SfxItemState::SET)
+ return;
+
+ SvxCellHorJustify eVal;
+ switch ( static_cast<const SvxAdjustItem*>(pItem)->GetAdjust() )
{
- SvxCellHorJustify eVal;
- switch ( static_cast<const SvxAdjustItem*>(pItem)->GetAdjust() )
- {
- case SvxAdjust::Left:
- // EditEngine Default is always set in the GetAttribs() ItemSet !
- // whether left or right, is decided in text / number
- eVal = SvxCellHorJustify::Standard;
- break;
- case SvxAdjust::Right:
- eVal = SvxCellHorJustify::Right;
- break;
- case SvxAdjust::Block:
- eVal = SvxCellHorJustify::Block;
- break;
- case SvxAdjust::Center:
- eVal = SvxCellHorJustify::Center;
- break;
- case SvxAdjust::BlockLine:
- eVal = SvxCellHorJustify::Block;
- break;
- case SvxAdjust::End:
- eVal = SvxCellHorJustify::Right;
- break;
- default:
- eVal = SvxCellHorJustify::Standard;
- }
- if ( eVal != SvxCellHorJustify::Standard )
- rDestSet.Put( SvxHorJustifyItem( eVal, ATTR_HOR_JUSTIFY) );
+ case SvxAdjust::Left:
+ // EditEngine Default is always set in the GetAttribs() ItemSet !
+ // whether left or right, is decided in text / number
+ eVal = SvxCellHorJustify::Standard;
+ break;
+ case SvxAdjust::Right:
+ eVal = SvxCellHorJustify::Right;
+ break;
+ case SvxAdjust::Block:
+ eVal = SvxCellHorJustify::Block;
+ break;
+ case SvxAdjust::Center:
+ eVal = SvxCellHorJustify::Center;
+ break;
+ case SvxAdjust::BlockLine:
+ eVal = SvxCellHorJustify::Block;
+ break;
+ case SvxAdjust::End:
+ eVal = SvxCellHorJustify::Right;
+ break;
+ default:
+ eVal = SvxCellHorJustify::Standard;
}
+ if ( eVal != SvxCellHorJustify::Standard )
+ rDestSet.Put( SvxHorJustifyItem( eVal, ATTR_HOR_JUSTIFY) );
}
void ScPatternAttr::GetFromEditItemSet( const SfxItemSet* pEditSet )
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index d0ac658f3e35..8d0d3e6d7be5 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -415,19 +415,19 @@ ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& r
{
SdrPage* pDrawPage = GetDrawPage();
OSL_ENSURE( pDrawPage, "ScNoteCaptionCreator::ScNoteCaptionCreator - no drawing page" );
- if( pDrawPage )
+ if( !pDrawPage )
+ return;
+
+ // create the caption drawing object
+ CreateCaption( rNoteData.mbShown, false );
+ rNoteData.mxCaption = GetCaption();
+ OSL_ENSURE( rNoteData.mxCaption, "ScNoteCaptionCreator::ScNoteCaptionCreator - missing caption object" );
+ if( rNoteData.mxCaption )
{
- // create the caption drawing object
- CreateCaption( rNoteData.mbShown, false );
- rNoteData.mxCaption = GetCaption();
- OSL_ENSURE( rNoteData.mxCaption, "ScNoteCaptionCreator::ScNoteCaptionCreator - missing caption object" );
- if( rNoteData.mxCaption )
- {
- // store note position in user data of caption object
- ScCaptionUtil::SetCaptionUserData( *rNoteData.mxCaption, rPos );
- // insert object into draw page
- pDrawPage->InsertObject( rNoteData.mxCaption.get() );
- }
+ // store note position in user data of caption object
+ ScCaptionUtil::SetCaptionUserData( *rNoteData.mxCaption, rPos );
+ // insert object into draw page
+ pDrawPage->InsertObject( rNoteData.mxCaption.get() );
}
}
@@ -697,41 +697,41 @@ bool ScCaptionPtr::decRef() const
void ScCaptionPtr::decRefAndDestroy()
{
- if (decRef())
- {
- assert(mpHead->mpFirst == this); // this must be one and only one
- assert(!mpNext); // this must be one and only one
- assert(mpCaption);
+ if (!decRef())
+ return;
+
+ assert(mpHead->mpFirst == this); // this must be one and only one
+ assert(!mpNext); // this must be one and only one
+ assert(mpCaption);
#if 0
- // Quick workaround for when there are still cases where the caption
- // pointer is dangling
+ // Quick workaround for when there are still cases where the caption
+ // pointer is dangling
+ mpCaption = nullptr;
+ mbNotOwner = false;
+#else
+ // Destroying Draw Undo and some other delete the SdrObject, don't
+ // attempt that twice.
+ if (mbNotOwner)
+ {
mpCaption = nullptr;
mbNotOwner = false;
-#else
- // Destroying Draw Undo and some other delete the SdrObject, don't
- // attempt that twice.
- if (mbNotOwner)
- {
- mpCaption = nullptr;
- mbNotOwner = false;
- }
- else
+ }
+ else
+ {
+ removeFromDrawPageAndFree( true ); // ignoring Undo
+ if (mpCaption)
{
- removeFromDrawPageAndFree( true ); // ignoring Undo
- if (mpCaption)
- {
- // There's no draw page associated so removeFromDrawPageAndFree()
- // didn't do anything, but still we want to delete the caption
- // object. release()/dissolve() also resets mpCaption.
- SdrObject* pObj = release();
- SdrObject::Free( pObj );
- }
+ // There's no draw page associated so removeFromDrawPageAndFree()
+ // didn't do anything, but still we want to delete the caption
+ // object. release()/dissolve() also resets mpCaption.
+ SdrObject* pObj = release();
+ SdrObject::Free( pObj );
}
-#endif
- delete mpHead;
- mpHead = nullptr;
}
+#endif
+ delete mpHead;
+ mpHead = nullptr;
}
void ScCaptionPtr::insertToDrawPage( SdrPage& rDrawPage )
@@ -753,28 +753,28 @@ void ScCaptionPtr::removeFromDrawPageAndFree( bool bIgnoreUndo )
assert(mpHead && mpCaption);
SdrPage* pDrawPage(mpCaption->getSdrPageFromSdrObject());
SAL_WARN_IF( !pDrawPage, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing page");
- if (pDrawPage)
+ if (!pDrawPage)
+ return;
+
+ pDrawPage->RecalcObjOrdNums();
+ bool bRecording = false;
+ if(!bIgnoreUndo)
{
- pDrawPage->RecalcObjOrdNums();
- bool bRecording = false;
- if(!bIgnoreUndo)
- {
- ScDrawLayer* pDrawLayer(dynamic_cast< ScDrawLayer* >(&mpCaption->getSdrModelFromSdrObject()));
- SAL_WARN_IF( !pDrawLayer, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing layer");
- // create drawing undo action (before removing the object to have valid draw page in undo action)
- bRecording = (pDrawLayer && pDrawLayer->IsRecording());
- if (bRecording)
- pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoDelObj>( *mpCaption ));
- }
- // remove the object from the drawing page, delete if undo is disabled
- removeFromDrawPage( *pDrawPage );
- // If called from outside mnRefs must be 1 to delete. If called from
- // decRefAndDestroy() mnRefs is already 0.
- if (!bRecording && getRefs() <= 1)
- {
- SdrObject* pObj = release();
- SdrObject::Free( pObj );
- }
+ ScDrawLayer* pDrawLayer(dynamic_cast< ScDrawLayer* >(&mpCaption->getSdrModelFromSdrObject()));
+ SAL_WARN_IF( !pDrawLayer, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing layer");
+ // create drawing undo action (before removing the object to have valid draw page in undo action)
+ bRecording = (pDrawLayer && pDrawLayer->IsRecording());
+ if (bRecording)
+ pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoDelObj>( *mpCaption ));
+ }
+ // remove the object from the drawing page, delete if undo is disabled
+ removeFromDrawPage( *pDrawPage );
+ // If called from outside mnRefs must be 1 to delete. If called from
+ // decRefAndDestroy() mnRefs is already 0.
+ if (!bRecording && getRefs() <= 1)
+ {
+ SdrObject* pObj = release();
+ SdrObject::Free( pObj );
}
}
@@ -1101,35 +1101,35 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCapti
// ScNoteCaptionCreator c'tor creates the caption and inserts it into the document and maNoteData
ScNoteCaptionCreator aCreator( mrDoc, rPos, maNoteData );
- if( maNoteData.mxCaption )
- {
- // clone settings of passed caption
- if( pCaption )
- {
- // copy edit text object (object must be inserted into page already)
- if( OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
- maNoteData.mxCaption->SetOutlinerParaObject( std::make_unique<OutlinerParaObject>( *pOPO ) );
- // copy formatting items (after text has been copied to apply font formatting)
- maNoteData.mxCaption->SetMergedItemSetAndBroadcast( pCaption->GetMergedItemSet() );
- // move textbox position relative to new cell, copy textbox size
- tools::Rectangle aCaptRect = pCaption->GetLogicRect();
- Point aDist = maNoteData.mxCaption->GetTailPos() - pCaption->GetTailPos();
- aCaptRect.Move( aDist.X(), aDist.Y() );
- maNoteData.mxCaption->SetLogicRect( aCaptRect );
- aCreator.FitCaptionToRect();
- }
- else
- {
- // set default formatting and default position
- ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, nullptr );
- aCreator.AutoPlaceCaption();
- }
+ if( !maNoteData.mxCaption )
+ return;
- // create undo action
- if( ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer() )
- if( pDrawLayer->IsRecording() )
- pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoNewObj>( *maNoteData.mxCaption ) );
+ // clone settings of passed caption
+ if( pCaption )
+ {
+ // copy edit text object (object must be inserted into page already)
+ if( OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
+ maNoteData.mxCaption->SetOutlinerParaObject( std::make_unique<OutlinerParaObject>( *pOPO ) );
+ // copy formatting items (after text has been copied to apply font formatting)
+ maNoteData.mxCaption->SetMergedItemSetAndBroadcast( pCaption->GetMergedItemSet() );
+ // move textbox position relative to new cell, copy textbox size
+ tools::Rectangle aCaptRect = pCaption->GetLogicRect();
+ Point aDist = maNoteData.mxCaption->GetTailPos() - pCaption->GetTailPos();
+ aCaptRect.Move( aDist.X(), aDist.Y() );
+ maNoteData.mxCaption->SetLogicRect( aCaptRect );
+ aCreator.FitCaptionToRect();
+ }
+ else
+ {
+ // set default formatting and default position
+ ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, nullptr );
+ aCreator.AutoPlaceCaption();
}
+
+ // create undo action
+ if( ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer() )
+ if( pDrawLayer->IsRecording() )
+ pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoNewObj>( *maNoteData.mxCaption ) );
}
void ScPostIt::RemoveCaption()
diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index 7d3da5eb3e0d..8395315883f8 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -129,49 +129,49 @@ void ScStyleSheetPool::CopyStyleFrom( ScStyleSheetPool* pSrcPool,
// this is the Dest-Pool
SfxStyleSheetBase* pStyleSheet = pSrcPool->Find( rName, eFamily );
- if (pStyleSheet)
+ if (!pStyleSheet)
+ return;
+
+ const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet();
+ SfxStyleSheetBase* pDestSheet = Find( rName, eFamily );
+ if (!pDestSheet)
+ pDestSheet = &Make( rName, eFamily );
+ SfxItemSet& rDestSet = pDestSheet->GetItemSet();
+ rDestSet.PutExtended( rSourceSet, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
+
+ const SfxPoolItem* pItem;
+ if ( eFamily == SfxStyleFamily::Page )
{
- const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet();
- SfxStyleSheetBase* pDestSheet = Find( rName, eFamily );
- if (!pDestSheet)
- pDestSheet = &Make( rName, eFamily );
- SfxItemSet& rDestSet = pDestSheet->GetItemSet();
- rDestSet.PutExtended( rSourceSet, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
-
- const SfxPoolItem* pItem;
- if ( eFamily == SfxStyleFamily::Page )
- {
- // Set-Items
+ // Set-Items
- if ( rSourceSet.GetItemState( ATTR_PAGE_HEADERSET, false, &pItem ) == SfxItemState::SET )
- {
- const SfxItemSet& rSrcSub = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
- SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
- aDestSub.PutExtended( rSrcSub, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
- rDestSet.Put( SvxSetItem( ATTR_PAGE_HEADERSET, aDestSub ) );
- }
- if ( rSourceSet.GetItemState( ATTR_PAGE_FOOTERSET, false, &pItem ) == SfxItemState::SET )
- {
- const SfxItemSet& rSrcSub = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
- SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
- aDestSub.PutExtended( rSrcSub, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
- rDestSet.Put( SvxSetItem( ATTR_PAGE_FOOTERSET, aDestSub ) );
- }
+ if ( rSourceSet.GetItemState( ATTR_PAGE_HEADERSET, false, &pItem ) == SfxItemState::SET )
+ {
+ const SfxItemSet& rSrcSub = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
+ SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
+ aDestSub.PutExtended( rSrcSub, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
+ rDestSet.Put( SvxSetItem( ATTR_PAGE_HEADERSET, aDestSub ) );
}
- else // cell styles
+ if ( rSourceSet.GetItemState( ATTR_PAGE_FOOTERSET, false, &pItem ) == SfxItemState::SET )
{
- // number format exchange list has to be handled here, too
+ const SfxItemSet& rSrcSub = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
+ SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
+ aDestSub.PutExtended( rSrcSub, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
+ rDestSet.Put( SvxSetItem( ATTR_PAGE_FOOTERSET, aDestSub ) );
+ }
+ }
+ else // cell styles
+ {
+ // number format exchange list has to be handled here, too
- if ( pDoc && pDoc->GetFormatExchangeList() &&
- rSourceSet.GetItemState( ATTR_VALUE_FORMAT, false, &pItem ) == SfxItemState::SET )
+ if ( pDoc && pDoc->GetFormatExchangeList() &&
+ rSourceSet.GetItemState( ATTR_VALUE_FORMAT, false, &pItem ) == SfxItemState::SET )
+ {
+ sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
+ SvNumberFormatterIndexTable::const_iterator it = pDoc->GetFormatExchangeList()->find(nOldFormat);
+ if (it != pDoc->GetFormatExchangeList()->end())
{
- sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
- SvNumberFormatterIndexTable::const_iterator it = pDoc->GetFormatExchangeList()->find(nOldFormat);
- if (it != pDoc->GetFormatExchangeList()->end())
- {
- sal_uInt32 nNewFormat = it->second;
- rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
- }
+ sal_uInt32 nNewFormat = it->second;
+ rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
}
}
}
diff --git a/sc/source/core/data/subtotalparam.cxx b/sc/source/core/data/subtotalparam.cxx
index 5b91e1580f21..fc9a565f0d8e 100644
--- a/sc/source/core/data/subtotalparam.cxx
+++ b/sc/source/core/data/subtotalparam.cxx
@@ -182,24 +182,24 @@ void ScSubTotalParam::SetSubTotals( sal_uInt16 nGroup,
OSL_ENSURE( (nCount > 0),
"ScSubTotalParam::SetSubTotals(): nCount <= 0!" );
- if ( ptrSubTotals && ptrFunctions && (nCount > 0) && (nGroup <= MAXSUBTOTAL) )
- {
- // 0 is interpreted as 1, otherwise decrementing the array index
- if (nGroup != 0)
- nGroup--;
+ if ( !(ptrSubTotals && ptrFunctions && (nCount > 0) && (nGroup <= MAXSUBTOTAL)) )
+ return;
- delete [] pSubTotals[nGroup];
- delete [] pFunctions[nGroup];
+ // 0 is interpreted as 1, otherwise decrementing the array index
+ if (nGroup != 0)
+ nGroup--;
- pSubTotals[nGroup] = new SCCOL [nCount];
- pFunctions[nGroup] = new ScSubTotalFunc [nCount];
- nSubTotals[nGroup] = static_cast<SCCOL>(nCount);
+ delete [] pSubTotals[nGroup];
+ delete [] pFunctions[nGroup];
- for ( sal_uInt16 i=0; i<nCount; i++ )
- {
- pSubTotals[nGroup][i] = ptrSubTotals[i];
- pFunctions[nGroup][i] = ptrFunctions[i];
- }
+ pSubTotals[nGroup] = new SCCOL [nCount];
+ pFunctions[nGroup] = new ScSubTotalFunc [nCount];
+ nSubTotals[nGroup] = static_cast<SCCOL>(nCount);
+
+ for ( sal_uInt16 i=0; i<nCount; i++ )
+ {
+ pSubTotals[nGroup][i] = ptrSubTotals[i];
+ pFunctions[nGroup][i] = ptrFunctions[i];
}
}
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 832af7d56a79..91b766f553c4 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1690,21 +1690,21 @@ void ScTable::UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nR
SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos )
{
- if ( nTab >= nTab1 && nTab <= nTab2 && nDz == 0 ) // only within the table
- {
- ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
- if ( eUpdateRefMode != URM_COPY && pDrawLayer )
- {
- if ( eUpdateRefMode == URM_MOVE )
- { // source range
- nCol1 = sal::static_int_cast<SCCOL>( nCol1 - nDx );
- nRow1 = sal::static_int_cast<SCROW>( nRow1 - nDy );
- nCol2 = sal::static_int_cast<SCCOL>( nCol2 - nDx );
- nRow2 = sal::static_int_cast<SCROW>( nRow2 - nDy );
- }
- pDrawLayer->MoveArea( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy,
- (eUpdateRefMode == URM_INSDEL), bUpdateNoteCaptionPos );
+ if ( !(nTab >= nTab1 && nTab <= nTab2 && nDz == 0) ) // only within the table
+ return;
+
+ ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
+ if ( eUpdateRefMode != URM_COPY && pDrawLayer )
+ {
+ if ( eUpdateRefMode == URM_MOVE )
+ { // source range
+ nCol1 = sal::static_int_cast<SCCOL>( nCol1 - nDx );
+ nRow1 = sal::static_int_cast<SCROW>( nRow1 - nDy );
+ nCol2 = sal::static_int_cast<SCCOL>( nCol2 - nDx );
+ nRow2 = sal::static_int_cast<SCROW>( nRow2 - nDy );
}
+ pDrawLayer->MoveArea( nTab, nCol1,nRow1, nCol2,nRow2, nDx,nDy,
+ (eUpdateRefMode == URM_INSDEL), bUpdateNoteCaptionPos );
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index ba596d54a8f1..6db4745722ac 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -720,56 +720,56 @@ void ScTable::CopyFromClip(
if (nRow2 > pDocument->MaxRow())
nRow2 = pDocument->MaxRow();
- if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
- {
- CreateColumnIfNotExists(nCol2);
- for ( SCCOL i = nCol1; i <= nCol2; i++)
- {
- pTable->CreateColumnIfNotExists(i - nDx);
- aCol[i].CopyFromClip(rCxt, nRow1, nRow2, nDy, pTable->aCol[i - nDx]); // notes are handles at column level
- }
+ if (!(ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2)))
+ return;
- if (rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB)
- {
- // make sure that there are no old references to the cond formats
- sal_uInt16 nWhichArray[2];
- nWhichArray[0] = ATTR_CONDITIONAL;
- nWhichArray[1] = 0;
- for ( SCCOL i = nCol1; i <= nCol2; ++i)
- aCol[i].ClearItems(nRow1, nRow2, nWhichArray);
- }
+ CreateColumnIfNotExists(nCol2);
+ for ( SCCOL i = nCol1; i <= nCol2; i++)
+ {
+ pTable->CreateColumnIfNotExists(i - nDx);
+ aCol[i].CopyFromClip(rCxt, nRow1, nRow2, nDy, pTable->aCol[i - nDx]); // notes are handles at column level
+ }
- if ((rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB) != InsertDeleteFlags::NONE)
- {
- if (nRow1==0 && nRow2==pDocument->MaxRow() && mpColWidth && pTable->mpColWidth)
- mpColWidth->CopyFrom(*pTable->mpColWidth, nCol1, nCol2, nCol1 - nDx);
+ if (rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB)
+ {
+ // make sure that there are no old references to the cond formats
+ sal_uInt16 nWhichArray[2];
+ nWhichArray[0] = ATTR_CONDITIONAL;
+ nWhichArray[1] = 0;
+ for ( SCCOL i = nCol1; i <= nCol2; ++i)
+ aCol[i].ClearItems(nRow1, nRow2, nWhichArray);
+ }
- if (nCol1==0 && nCol2==pDocument->MaxCol() && mpRowHeights && pTable->mpRowHeights &&
- pRowFlags && pTable->pRowFlags)
- {
- CopyRowHeight(*pTable, nRow1, nRow2, -nDy);
- // Must copy CRFlags::ManualSize bit too, otherwise pRowHeight doesn't make sense
- for (SCROW j=nRow1; j<=nRow2; j++)
- {
- if ( pTable->pRowFlags->GetValue(j-nDy) & CRFlags::ManualSize )
- pRowFlags->OrValue( j, CRFlags::ManualSize);
- else
- pRowFlags->AndValue( j, ~CRFlags::ManualSize);
- }
- }
+ if ((rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB) == InsertDeleteFlags::NONE)
+ return;
- // Do not set protected cell in a protected sheet
- if (IsProtected() && (rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB))
- {
- ScPatternAttr aPattern(pDocument->GetPool());
- aPattern.GetItemSet().Put( ScProtectionAttr( false ) );
- ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern );
- }
+ if (nRow1==0 && nRow2==pDocument->MaxRow() && mpColWidth && pTable->mpColWidth)
+ mpColWidth->CopyFrom(*pTable->mpColWidth, nCol1, nCol2, nCol1 - nDx);
- // create deep copies for conditional formatting
- CopyConditionalFormat( nCol1, nRow1, nCol2, nRow2, nDx, nDy, pTable);
+ if (nCol1==0 && nCol2==pDocument->MaxCol() && mpRowHeights && pTable->mpRowHeights &&
+ pRowFlags && pTable->pRowFlags)
+ {
+ CopyRowHeight(*pTable, nRow1, nRow2, -nDy);
+ // Must copy CRFlags::ManualSize bit too, otherwise pRowHeight doesn't make sense
+ for (SCROW j=nRow1; j<=nRow2; j++)
+ {
+ if ( pTable->pRowFlags->GetValue(j-nDy) & CRFlags::ManualSize )
+ pRowFlags->OrValue( j, CRFlags::ManualSize);
+ else
+ pRowFlags->AndValue( j, ~CRFlags::ManualSize);
}
}
+
+ // Do not set protected cell in a protected sheet
+ if (IsProtected() && (rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB))
+ {
+ ScPatternAttr aPattern(pDocument->GetPool());
+ aPattern.GetItemSet().Put( ScProtectionAttr( false ) );
+ ApplyPatternArea( nCol1, nRow1, nCol2, nRow2, aPattern );
+ }
+
+ // create deep copies for conditional formatting
+ CopyConditionalFormat( nCol1, nRow1, nCol2, nRow2, nDx, nDy, pTable);
}
void ScTable::MixData(
@@ -1016,71 +1016,71 @@ void ScTable::TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SC
}
}
- if (itBlk != itBlkEnd)
+ if (itBlk == itBlkEnd)
// Specified range found
+ return;
+
+ nRowPos = static_cast<size_t>(nRow2); // End row position.
+
+ // Keep processing until we hit the end row position.
+ sc::cellnote_block::const_iterator itData, itDataEnd;
+ for (; itBlk != itBlkEnd; ++itBlk, nBlockStart = nBlockEnd, nOffsetInBlock = 0)
{
- nRowPos = static_cast<size_t>(nRow2); // End row position.
+ nBlockEnd = nBlockStart + itBlk->size;
- // Keep processing until we hit the end row position.
- sc::cellnote_block::const_iterator itData, itDataEnd;
- for (; itBlk != itBlkEnd; ++itBlk, nBlockStart = nBlockEnd, nOffsetInBlock = 0)
+ if (itBlk->data)
{
- nBlockEnd = nBlockStart + itBlk->size;
+ itData = sc::cellnote_block::begin(*itBlk->data);
+ std::advance(itData, nOffsetInBlock);
- if (itBlk->data)
+ if (nBlockStart <= nRowPos && nRowPos < nBlockEnd)
{
- itData = sc::cellnote_block::begin(*itBlk->data);
- std::advance(itData, nOffsetInBlock);
-
- if (nBlockStart <= nRowPos && nRowPos < nBlockEnd)
- {
- // This block contains the end row. Only process partially.
- size_t nOffsetEnd = nRowPos - nBlockStart + 1;
- itDataEnd = sc::cellnote_block::begin(*itBlk->data);
- std::advance(itDataEnd, nOffsetEnd);
- size_t curRow = nBlockStart + nOffsetInBlock;
- for (; itData != itDataEnd; ++itData, ++curRow)
- {
- ScAddress aDestPos( static_cast<SCCOL>(curRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab );
- pTransClip->pDocument->ReleaseNote(aDestPos);
- ScPostIt* pNote = *itData;
- if (pNote)
- {
- std::unique_ptr<ScPostIt> pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true );
- pTransClip->pDocument->SetNote(aDestPos, std::move(pClonedNote));
- }
- }
- break; // we reached the last valid block
- }
- else
+ // This block contains the end row. Only process partially.
+ size_t nOffsetEnd = nRowPos - nBlockStart + 1;
+ itDataEnd = sc::cellnote_block::begin(*itBlk->data);
+ std::advance(itDataEnd, nOffsetEnd);
+ size_t curRow = nBlockStart + nOffsetInBlock;
+ for (; itData != itDataEnd; ++itData, ++curRow)
{
- itDataEnd = sc::cellnote_block::end(*itBlk->data);
- size_t curRow = nBlockStart + nOffsetInBlock;
- for (; itData != itDataEnd; ++itData, ++curRow)
+ ScAddress aDestPos( static_cast<SCCOL>(curRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab );
+ pTransClip->pDocument->ReleaseNote(aDestPos);
+ ScPostIt* pNote = *itData;
+ if (pNote)
{
- ScAddress aDestPos( static_cast<SCCOL>(curRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab );
- pTransClip->pDocument->ReleaseNote(aDestPos);
- ScPostIt* pNote = *itData;
- if (pNote)
- {
- std::unique_ptr<ScPostIt> pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true );
- pTransClip->pDocument->SetNote(aDestPos, std::move(pClonedNote));
- }
+ std::unique_ptr<ScPostIt> pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true );
+ pTransClip->pDocument->SetNote(aDestPos, std::move(pClonedNote));
}
}
+ break; // we reached the last valid block
}
else
{
- size_t curRow;
- for ( curRow = nBlockStart + nOffsetInBlock; curRow <= nBlockEnd && curRow <= nRowPos; ++curRow)
+ itDataEnd = sc::cellnote_block::end(*itBlk->data);
+ size_t curRow = nBlockStart + nOffsetInBlock;
+ for (; itData != itDataEnd; ++itData, ++curRow)
{
ScAddress aDestPos( static_cast<SCCOL>(curRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab );
pTransClip->pDocument->ReleaseNote(aDestPos);
+ ScPostIt* pNote = *itData;
+ if (pNote)
+ {
+ std::unique_ptr<ScPostIt> pClonedNote = pNote->Clone( ScAddress(nCol, curRow, nTab), *pTransClip->pDocument, aDestPos, true );
+ pTransClip->pDocument->SetNote(aDestPos, std::move(pClonedNote));
+ }
}
- if (curRow == nRowPos)
- break;
}
}
+ else
+ {
+ size_t curRow;
+ for ( curRow = nBlockStart + nOffsetInBlock; curRow <= nBlockEnd && curRow <= nRowPos; ++curRow)
+ {
+ ScAddress aDestPos( static_cast<SCCOL>(curRow-nRow1), static_cast<SCROW>(nCol-nCol1), pTransClip->nTab );
+ pTransClip->pDocument->ReleaseNote(aDestPos);
+ }
+ if (curRow == nRowPos)
+ break;
+ }
}
}
@@ -1325,51 +1325,51 @@ void ScTable::UndoToTable(
sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab )
{
- if (ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2))
- {
- bool bWidth = (nRow1==0 && nRow2==pDocument->MaxRow() && mpColWidth && pDestTab->mpColWidth);
- bool bHeight = (nCol1==0 && nCol2==pDocument->MaxCol() && mpRowHeights && pDestTab->mpRowHeights);
-
- if ((nFlags & InsertDeleteFlags::CONTENTS) && mpRangeName)
- {
- // Undo sheet-local named expressions created during copying
- // formulas. If mpRangeName is not set then the Undo wasn't even
- // set to an empty ScRangeName map so don't "undo" that.
- pDestTab->SetRangeName( std::unique_ptr<ScRangeName>( new ScRangeName( *GetRangeName())));
- if (!pDestTab->pDocument->IsClipOrUndo())
- {
- ScDocShell* pDocSh = static_cast<ScDocShell*>(pDestTab->pDocument->GetDocumentShell());
- if (pDocSh)
- pDocSh->SetAreasChangedNeedBroadcast();
- }
+ if (!(ValidColRow(nCol1, nRow1) && ValidColRow(nCol2, nRow2)))
+ return;
- }
+ bool bWidth = (nRow1==0 && nRow2==pDocument->MaxRow() && mpColWidth && pDestTab->mpColWidth);
+ bool bHeight = (nCol1==0 && nCol2==pDocument->MaxCol() && mpRowHeights && pDestTab->mpRowHeights);
- for ( SCCOL i = 0; i < aCol.size(); i++)
+ if ((nFlags & InsertDeleteFlags::CONTENTS) && mpRangeName)
+ {
+ // Undo sheet-local named expressions created during copying
+ // formulas. If mpRangeName is not set then the Undo wasn't even
+ // set to an empty ScRangeName map so don't "undo" that.
+ pDestTab->SetRangeName( std::unique_ptr<ScRangeName>( new ScRangeName( *GetRangeName())));
+ if (!pDestTab->pDocument->IsClipOrUndo())
{
- auto& rDestCol = pDestTab->CreateColumnIfNotExists(i);
- if ( i >= nCol1 && i <= nCol2 )
- aCol[i].UndoToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, rDestCol);
- else
- aCol[i].CopyToColumn(rCxt, 0, pDocument->MaxRow(), InsertDeleteFlags::FORMULA, false, rDestCol);
+ ScDocShell* pDocSh = static_cast<ScDocShell*>(pDestTab->pDocument->GetDocumentShell());
+ if (pDocSh)
+ pDocSh->SetAreasChangedNeedBroadcast();
}
- if (nFlags & InsertDeleteFlags::ATTRIB)
- pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(pDestTab->pDocument, *mpCondFormatList));
+ }
- if (bWidth||bHeight)
- {
- if (bWidth)
- {
- pDestTab->mpColWidth->CopyFrom(*mpColWidth, nCol1, nCol2);
- pDestTab->SetColManualBreaks( maColManualBreaks);
- }
- if (bHeight)
- {
- pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0);
- pDestTab->SetRowManualBreaks( maRowManualBreaks);
- }
- }
+ for ( SCCOL i = 0; i < aCol.size(); i++)
+ {
+ auto& rDestCol = pDestTab->CreateColumnIfNotExists(i);
+ if ( i >= nCol1 && i <= nCol2 )
+ aCol[i].UndoToColumn(rCxt, nRow1, nRow2, nFlags, bMarked, rDestCol);
+ else
+ aCol[i].CopyToColumn(rCxt, 0, pDocument->MaxRow(), InsertDeleteFlags::FORMULA, false, rDestCol);
+ }
+
+ if (nFlags & InsertDeleteFlags::ATTRIB)
+ pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(pDestTab->pDocument, *mpCondFormatList));
+
+ if (!(bWidth||bHeight))
+ return;
+
+ if (bWidth)
+ {
+ pDestTab->mpColWidth->CopyFrom(*mpColWidth, nCol1, nCol2);
+ pDestTab->SetColManualBreaks( maColManualBreaks);
+ }
+ if (bHeight)
+ {
+ pDestTab->CopyRowHeight(*this, nRow1, nRow2, 0);
+ pDestTab->SetRowManualBreaks( maRowManualBreaks);
}
}
@@ -2732,33 +2732,33 @@ void ScTable::ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet* rStyle )
void ScTable::ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle )
{
- if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
+ if (!(ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)))
+ return;
+
+ PutInOrder(nStartCol, nEndCol);
+ PutInOrder(nStartRow, nEndRow);
+ if ( nEndCol == pDocument->MaxCol() )
{
- PutInOrder(nStartCol, nEndCol);
- PutInOrder(nStartRow, nEndRow);
- if ( nEndCol == pDocument->MaxCol() )
+ if ( nStartCol < aCol.size() )
{
- if ( nStartCol < aCol.size() )
- {
- // If we would like set all columns to specific style, then change only default style for not existing columns
- nEndCol = aCol.size() - 1;
- for (SCCOL i = nStartCol; i <= nEndCol; i++)
- aCol[i].ApplyStyleArea(nStartRow, nEndRow, rStyle);
- aDefaultColAttrArray.ApplyStyleArea(nStartRow, nEndRow, rStyle );
- }
- else
- {
- CreateColumnIfNotExists( nStartCol - 1 );
- aDefaultColAttrArray.ApplyStyleArea(nStartRow, nEndRow, rStyle );
- }
+ // If we would like set all columns to specific style, then change only default style for not existing columns
+ nEndCol = aCol.size() - 1;
+ for (SCCOL i = nStartCol; i <= nEndCol; i++)
+ aCol[i].ApplyStyleArea(nStartRow, nEndRow, rStyle);
+ aDefaultColAttrArray.ApplyStyleArea(nStartRow, nEndRow, rStyle );
}
else
{
- CreateColumnIfNotExists( nEndCol );
- for (SCCOL i = nStartCol; i <= nEndCol; i++)
- aCol[i].ApplyStyleArea(nStartRow, nEndRow, rStyle);
+ CreateColumnIfNotExists( nStartCol - 1 );
+ aDefaultColAttrArray.ApplyStyleArea(nStartRow, nEndRow, rStyle );
}
}
+ else
+ {
+ CreateColumnIfNotExists( nEndCol );
+ for (SCCOL i = nStartCol; i <= nEndCol; i++)
+ aCol[i].ApplyStyleArea(nStartRow, nEndRow, rStyle);
+ }
}
void ScTable::ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark)
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index c8f533c65708..426b14132e0c 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -2061,137 +2061,137 @@ void ScTable::AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SC
void ScTable::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
sal_uInt16 nFormatNo )
{
- if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
+ if (!(ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)))
+ return;
+
+ ScAutoFormat& rFormat = *ScGlobal::GetOrCreateAutoFormat();
+ ScAutoFormatData* pData = rFormat.findByIndex(nFormatNo);
+ if (!pData)
+ return;
+
+ std::unique_ptr<ScPatternAttr> pPatternAttrs[16];
+ for (sal_uInt8 i = 0; i < 16; ++i)
{
- ScAutoFormat& rFormat = *ScGlobal::GetOrCreateAutoFormat();
- ScAutoFormatData* pData = rFormat.findByIndex(nFormatNo);
- if (pData)
- {
- std::unique_ptr<ScPatternAttr> pPatternAttrs[16];
- for (sal_uInt8 i = 0; i < 16; ++i)
- {
- pPatternAttrs[i].reset(new ScPatternAttr(pDocument->GetPool()));
- pData->FillToItemSet(i, pPatternAttrs[i]->GetItemSet(), *pDocument);
- }
+ pPatternAttrs[i].reset(new ScPatternAttr(pDocument->GetPool()));
+ pData->FillToItemSet(i, pPatternAttrs[i]->GetItemSet(), *pDocument);
+ }
- SCCOL nCol = nStartCol;
- SCROW nRow = nStartRow;
- sal_uInt16 nIndex = 0;
- // Left top corner
+ SCCOL nCol = nStartCol;
+ SCROW nRow = nStartRow;
+ sal_uInt16 nIndex = 0;
+ // Left top corner
+ AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
+ // Left column
+ if (pData->IsEqualData(4, 8))
+ AutoFormatArea(nStartCol, nStartRow + 1, nStartCol, nEndRow - 1, *pPatternAttrs[4], nFormatNo);
+ else
+ {
+ nIndex = 4;
+ for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
+ {
AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- // Left column
- if (pData->IsEqualData(4, 8))
- AutoFormatArea(nStartCol, nStartRow + 1, nStartCol, nEndRow - 1, *pPatternAttrs[4], nFormatNo);
+ if (nIndex == 4)
+ nIndex = 8;
else
- {
nIndex = 4;
- for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
- {
- AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- if (nIndex == 4)
- nIndex = 8;
- else
- nIndex = 4;
- }
- }
- // Left bottom corner
- nRow = nEndRow;
- nIndex = 12;
- AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- // Right top corner
- nCol = nEndCol;
- nRow = nStartRow;
- nIndex = 3;
+ }
+ }
+ // Left bottom corner
+ nRow = nEndRow;
+ nIndex = 12;
+ AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
+ // Right top corner
+ nCol = nEndCol;
+ nRow = nStartRow;
+ nIndex = 3;
+ AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
+ // Right column
+ if (pData->IsEqualData(7, 11))
+ AutoFormatArea(nEndCol, nStartRow + 1, nEndCol, nEndRow - 1, *pPatternAttrs[7], nFormatNo);
+ else
+ {
+ nIndex = 7;
+ for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
+ {
AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- // Right column
- if (pData->IsEqualData(7, 11))
- AutoFormatArea(nEndCol, nStartRow + 1, nEndCol, nEndRow - 1, *pPatternAttrs[7], nFormatNo);
+ if (nIndex == 7)
+ nIndex = 11;
else
- {
nIndex = 7;
- for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
- {
- AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- if (nIndex == 7)
- nIndex = 11;
- else
- nIndex = 7;
- }
- }
- // Right bottom corner
- nRow = nEndRow;
- nIndex = 15;
- AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- nRow = nStartRow;
+ }
+ }
+ // Right bottom corner
+ nRow = nEndRow;
+ nIndex = 15;
+ AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
+ nRow = nStartRow;
+ nIndex = 1;
+ for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
+ {
+ AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
+ if (nIndex == 1)
+ nIndex = 2;
+ else
nIndex = 1;
- for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
- {
- AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- if (nIndex == 1)
- nIndex = 2;
- else
- nIndex = 1;
- }
- // Bottom row
- nRow = nEndRow;
+ }
+ // Bottom row
+ nRow = nEndRow;
+ nIndex = 13;
+ for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
+ {
+ AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
+ if (nIndex == 13)
+ nIndex = 14;
+ else
nIndex = 13;
+ }
+ // Body
+ if ((pData->IsEqualData(5, 6)) && (pData->IsEqualData(9, 10)) && (pData->IsEqualData(5, 9)))
+ AutoFormatArea(nStartCol + 1, nStartRow + 1, nEndCol-1, nEndRow - 1, *pPatternAttrs[5], nFormatNo);
+ else
+ {
+ if ((pData->IsEqualData(5, 9)) && (pData->IsEqualData(6, 10)))
+ {
+ nIndex = 5;
for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
{
- AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- if (nIndex == 13)
- nIndex = 14;
+ AutoFormatArea(nCol, nStartRow + 1, nCol, nEndRow - 1, *pPatternAttrs[nIndex], nFormatNo);
+ if (nIndex == 5)
+ nIndex = 6;
else
- nIndex = 13;
+ nIndex = 5;
}
- // Body
- if ((pData->IsEqualData(5, 6)) && (pData->IsEqualData(9, 10)) && (pData->IsEqualData(5, 9)))
- AutoFormatArea(nStartCol + 1, nStartRow + 1, nEndCol-1, nEndRow - 1, *pPatternAttrs[5], nFormatNo);
- else
+ }
+ else
+ {
+ nIndex = 5;
+ for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
{
- if ((pData->IsEqualData(5, 9)) && (pData->IsEqualData(6, 10)))
+ for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
{
- nIndex = 5;
- for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
+ AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
+ if ((nIndex == 5) || (nIndex == 9))
{
- AutoFormatArea(nCol, nStartRow + 1, nCol, nEndRow - 1, *pPatternAttrs[nIndex], nFormatNo);
if (nIndex == 5)
- nIndex = 6;
+ nIndex = 9;
else
nIndex = 5;
}
- }
- else
- {
- nIndex = 5;
- for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
+ else
{
- for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
- {
- AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
- if ((nIndex == 5) || (nIndex == 9))
- {
- if (nIndex == 5)
- nIndex = 9;
- else
- nIndex = 5;
- }
- else
- {
- if (nIndex == 6)
- nIndex = 10;
- else
- nIndex = 6;
- }
- } // for nRow
- if ((nIndex == 5) || (nIndex == 9))
- nIndex = 6;
+ if (nIndex == 6)
+ nIndex = 10;
else
- nIndex = 5;
- } // for nCol
- } // if not equal Column
- } // if not all equal
- } // if AutoFormatData != NULL
- } // if ValidColRow
+ nIndex = 6;
+ }
+ } // for nRow
+ if ((nIndex == 5) || (nIndex == 9))
+ nIndex = 6;
+ else
+ nIndex = 5;
+ } // for nCol
+ } // if not equal Column
+ } // if not all equal
}
void ScTable::GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData)
@@ -2269,73 +2269,73 @@ void ScTable::GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_
void ScTable::GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData)
{
- if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
+ if (!(ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)))
+ return;
+
+ if ((nEndCol - nStartCol < 3) || (nEndRow - nStartRow < 3))
+ return;
+
+ // Left top corner
+ GetAutoFormatAttr(nStartCol, nStartRow, 0, rData);
+ GetAutoFormatFrame(nStartCol, nStartRow, LF_ALL, 0, rData);
+ // Left column
+ GetAutoFormatAttr(nStartCol, nStartRow + 1, 4, rData);
+ GetAutoFormatAttr(nStartCol, nStartRow + 2, 8, rData);
+ GetAutoFormatFrame(nStartCol, nStartRow + 1, LF_LEFT | LF_RIGHT | LF_BOTTOM, 4, rData);
+ if (nEndRow - nStartRow >= 4)
+ GetAutoFormatFrame(nStartCol, nStartRow + 2, LF_LEFT | LF_RIGHT | LF_BOTTOM, 8, rData);
+ else
+ rData.CopyItem( 8, 4, ATTR_BORDER );
+ // Left bottom corner
+ GetAutoFormatAttr(nStartCol, nEndRow, 12, rData);
+ GetAutoFormatFrame(nStartCol, nEndRow, LF_ALL, 12, rData);
+ // Right top corner
+ GetAutoFormatAttr(nEndCol, nStartRow, 3, rData);
+ GetAutoFormatFrame(nEndCol, nStartRow, LF_ALL, 3, rData);
+ // Right column
+ GetAutoFormatAttr(nEndCol, nStartRow + 1, 7, rData);
+ GetAutoFormatAttr(nEndCol, nStartRow + 2, 11, rData);
+ GetAutoFormatFrame(nEndCol, nStartRow + 1, LF_LEFT | LF_RIGHT | LF_BOTTOM, 7, rData);
+ if (nEndRow - nStartRow >= 4)
+ GetAutoFormatFrame(nEndCol, nStartRow + 2, LF_LEFT | LF_RIGHT | LF_BOTTOM, 11, rData);
+ else
+ rData.CopyItem( 11, 7, ATTR_BORDER );
+ // Right bottom corner
+ GetAutoFormatAttr(nEndCol, nEndRow, 15, rData);
+ GetAutoFormatFrame(nEndCol, nEndRow, LF_ALL, 15, rData);
+ // Top row
+ GetAutoFormatAttr(nStartCol + 1, nStartRow, 1, rData);
+ GetAutoFormatAttr(nStartCol + 2, nStartRow, 2, rData);
+ GetAutoFormatFrame(nStartCol + 1, nStartRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 1, rData);
+ if (nEndCol - nStartCol >= 4)
+ GetAutoFormatFrame(nStartCol + 2, nStartRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 2, rData);
+ else
+ rData.CopyItem( 2, 1, ATTR_BORDER );
+ // Bottom row
+ GetAutoFormatAttr(nStartCol + 1, nEndRow, 13, rData);
+ GetAutoFormatAttr(nStartCol + 2, nEndRow, 14, rData);
+ GetAutoFormatFrame(nStartCol + 1, nEndRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 13, rData);
+ if (nEndCol - nStartCol >= 4)
+ GetAutoFormatFrame(nStartCol + 2, nEndRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 14, rData);
+ else
+ rData.CopyItem( 14, 13, ATTR_BORDER );
+ // Body
+ GetAutoFormatAttr(nStartCol + 1, nStartRow + 1, 5, rData);
+ GetAutoFormatAttr(nStartCol + 2, nStartRow + 1, 6, rData);
+ GetAutoFormatAttr(nStartCol + 1, nStartRow + 2, 9, rData);
+ GetAutoFormatAttr(nStartCol + 2, nStartRow + 2, 10, rData);
+ GetAutoFormatFrame(nStartCol + 1, nStartRow + 1, LF_RIGHT | LF_BOTTOM, 5, rData);
+ if ((nEndCol - nStartCol >= 4) && (nEndRow - nStartRow >= 4))
{
- if ((nEndCol - nStartCol >= 3) && (nEndRow - nStartRow >= 3))
- {
- // Left top corner
- GetAutoFormatAttr(nStartCol, nStartRow, 0, rData);
- GetAutoFormatFrame(nStartCol, nStartRow, LF_ALL, 0, rData);
- // Left column
- GetAutoFormatAttr(nStartCol, nStartRow + 1, 4, rData);
- GetAutoFormatAttr(nStartCol, nStartRow + 2, 8, rData);
- GetAutoFormatFrame(nStartCol, nStartRow + 1, LF_LEFT | LF_RIGHT | LF_BOTTOM, 4, rData);
- if (nEndRow - nStartRow >= 4)
- GetAutoFormatFrame(nStartCol, nStartRow + 2, LF_LEFT | LF_RIGHT | LF_BOTTOM, 8, rData);
- else
- rData.CopyItem( 8, 4, ATTR_BORDER );
- // Left bottom corner
- GetAutoFormatAttr(nStartCol, nEndRow, 12, rData);
- GetAutoFormatFrame(nStartCol, nEndRow, LF_ALL, 12, rData);
- // Right top corner
- GetAutoFormatAttr(nEndCol, nStartRow, 3, rData);
- GetAutoFormatFrame(nEndCol, nStartRow, LF_ALL, 3, rData);
- // Right column
- GetAutoFormatAttr(nEndCol, nStartRow + 1, 7, rData);
- GetAutoFormatAttr(nEndCol, nStartRow + 2, 11, rData);
- GetAutoFormatFrame(nEndCol, nStartRow + 1, LF_LEFT | LF_RIGHT | LF_BOTTOM, 7, rData);
- if (nEndRow - nStartRow >= 4)
- GetAutoFormatFrame(nEndCol, nStartRow + 2, LF_LEFT | LF_RIGHT | LF_BOTTOM, 11, rData);
- else
- rData.CopyItem( 11, 7, ATTR_BORDER );
- // Right bottom corner
- GetAutoFormatAttr(nEndCol, nEndRow, 15, rData);
- GetAutoFormatFrame(nEndCol, nEndRow, LF_ALL, 15, rData);
- // Top row
- GetAutoFormatAttr(nStartCol + 1, nStartRow, 1, rData);
- GetAutoFormatAttr(nStartCol + 2, nStartRow, 2, rData);
- GetAutoFormatFrame(nStartCol + 1, nStartRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 1, rData);
- if (nEndCol - nStartCol >= 4)
- GetAutoFormatFrame(nStartCol + 2, nStartRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 2, rData);
- else
- rData.CopyItem( 2, 1, ATTR_BORDER );
- // Bottom row
- GetAutoFormatAttr(nStartCol + 1, nEndRow, 13, rData);
- GetAutoFormatAttr(nStartCol + 2, nEndRow, 14, rData);
- GetAutoFormatFrame(nStartCol + 1, nEndRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 13, rData);
- if (nEndCol - nStartCol >= 4)
- GetAutoFormatFrame(nStartCol + 2, nEndRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 14, rData);
- else
- rData.CopyItem( 14, 13, ATTR_BORDER );
- // Body
- GetAutoFormatAttr(nStartCol + 1, nStartRow + 1, 5, rData);
- GetAutoFormatAttr(nStartCol + 2, nStartRow + 1, 6, rData);
- GetAutoFormatAttr(nStartCol + 1, nStartRow + 2, 9, rData);
- GetAutoFormatAttr(nStartCol + 2, nStartRow + 2, 10, rData);
- GetAutoFormatFrame(nStartCol + 1, nStartRow + 1, LF_RIGHT | LF_BOTTOM, 5, rData);
- if ((nEndCol - nStartCol >= 4) && (nEndRow - nStartRow >= 4))
- {
- GetAutoFormatFrame(nStartCol + 2, nStartRow + 1, LF_RIGHT | LF_BOTTOM, 6, rData);
- GetAutoFormatFrame(nStartCol + 1, nStartRow + 2, LF_RIGHT | LF_BOTTOM, 9, rData);
- GetAutoFormatFrame(nStartCol + 2, nStartRow + 2, LF_RIGHT | LF_BOTTOM, 10, rData);
- }
- else
- {
- rData.CopyItem( 6, 5, ATTR_BORDER );
- rData.CopyItem( 9, 5, ATTR_BORDER );
- rData.CopyItem( 10, 5, ATTR_BORDER );
- }
- }
+ GetAutoFormatFrame(nStartCol + 2, nStartRow + 1, LF_RIGHT | LF_BOTTOM, 6, rData);
+ GetAutoFormatFrame(nStartCol + 1, nStartRow + 2, LF_RIGHT | LF_BOTTOM, 9, rData);
+ GetAutoFormatFrame(nStartCol + 2, nStartRow + 2, LF_RIGHT | LF_BOTTOM, 10, rData);
+ }
+ else
+ {
+ rData.CopyItem( 6, 5, ATTR_BORDER );
+ rData.CopyItem( 9, 5, ATTR_BORDER );
+ rData.CopyItem( 10, 5, ATTR_BORDER );
}
}
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 1370d77f56d3..0537e2f19882 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -1112,43 +1112,43 @@ void ScTable::EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAdd
void ScTable::SetPageStyle( const OUString& rName )
{
- if ( aPageStyle != rName )
- {
- OUString aStrNew = rName;
- SfxStyleSheetBasePool* pStylePool = pDocument->GetStyleSheetPool();
- SfxStyleSheetBase* pNewStyle = pStylePool->Find( aStrNew, SfxStyleFamily::Page );
+ if ( aPageStyle == rName )
+ return;
- if ( !pNewStyle )
- {
- aStrNew = ScResId(STR_STYLENAME_STANDARD_PAGE);
- pNewStyle = pStylePool->Find( aStrNew, SfxStyleFamily::Page );
- }
+ OUString aStrNew = rName;
+ SfxStyleSheetBasePool* pStylePool = pDocument->GetStyleSheetPool();
+ SfxStyleSheetBase* pNewStyle = pStylePool->Find( aStrNew, SfxStyleFamily::Page );
- if ( aPageStyle != aStrNew )
- {
- SfxStyleSheetBase* pOldStyle = pStylePool->Find( aPageStyle, SfxStyleFamily::Page );
- if ( pOldStyle && pNewStyle )
- {
- SfxItemSet& rOldSet = pOldStyle->GetItemSet();
- SfxItemSet& rNewSet = pNewStyle->GetItemSet();
- auto getScaleValue = [](const SfxItemSet& rSet, sal_uInt16 nId)
- { return static_cast<const SfxUInt16Item&>(rSet.Get(nId)).GetValue(); };
-
- const sal_uInt16 nOldScale = getScaleValue(rOldSet,ATTR_PAGE_SCALE);
- const sal_uInt16 nOldScaleToPages = getScaleValue(rOldSet,ATTR_PAGE_SCALETOPAGES);
- const sal_uInt16 nNewScale = getScaleValue(rNewSet,ATTR_PAGE_SCALE);
- const sal_uInt16 nNewScaleToPages = getScaleValue(rNewSet,ATTR_PAGE_SCALETOPAGES);
-
- if ( (nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages) )
- InvalidateTextWidth(nullptr, nullptr, false, false);
- }
+ if ( !pNewStyle )
+ {
+ aStrNew = ScResId(STR_STYLENAME_STANDARD_PAGE);
+ pNewStyle = pStylePool->Find( aStrNew, SfxStyleFamily::Page );
+ }
- if ( pNewStyle ) // also without the old one (for UpdateStdNames)
- aPageStyle = aStrNew;
+ if ( aPageStyle == aStrNew )
+ return;
- SetStreamValid(false);
- }
+ SfxStyleSheetBase* pOldStyle = pStylePool->Find( aPageStyle, SfxStyleFamily::Page );
+ if ( pOldStyle && pNewStyle )
+ {
+ SfxItemSet& rOldSet = pOldStyle->GetItemSet();
+ SfxItemSet& rNewSet = pNewStyle->GetItemSet();
+ auto getScaleValue = [](const SfxItemSet& rSet, sal_uInt16 nId)
+ { return static_cast<const SfxUInt16Item&>(rSet.Get(nId)).GetValue(); };
+
+ const sal_uInt16 nOldScale = getScaleValue(rOldSet,ATTR_PAGE_SCALE);
+ const sal_uInt16 nOldScaleToPages = getScaleValue(rOldSet,ATTR_PAGE_SCALETOPAGES);
+ const sal_uInt16 nNewScale = getScaleValue(rNewSet,ATTR_PAGE_SCALE);
+ const sal_uInt16 nNewScaleToPages = getScaleValue(rNewSet,ATTR_PAGE_SCALETOPAGES);
+
+ if ( (nOldScale != nNewScale) || (nOldScaleToPages != nNewScaleToPages) )
+ InvalidateTextWidth(nullptr, nullptr, false, false);
}
+
+ if ( pNewStyle ) // also without the old one (for UpdateStdNames)
+ aPageStyle = aStrNew;
+
+ SetStreamValid(false);
}
void ScTable::PageStyleModified( const OUString& rNewName )
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index d80277093c57..65230448c052 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -157,22 +157,22 @@ void ScTable::CopyOneCellFromClip(
// Copy graphics over too
bool bCopyGraphics
= (rCxt.getInsertFlag() & InsertDeleteFlags::OBJECTS) != InsertDeleteFlags::NONE;
- if (bCopyGraphics && rCxt.getClipDoc()->mpDrawLayer)
+ if (!(bCopyGraphics && rCxt.getClipDoc()->mpDrawLayer))
+ return;
+
+ ScDrawLayer* pDrawLayer = GetDoc().GetDrawLayer();
+ OSL_ENSURE(pDrawLayer, "No drawing layer");
+ if (pDrawLayer)
{
- ScDrawLayer* pDrawLayer = GetDoc().GetDrawLayer();
- OSL_ENSURE(pDrawLayer, "No drawing layer");
- if (pDrawLayer)
- {
- const ScAddress aSrcStartPos
- = rCxt.getClipDoc()->GetClipParam().getWholeRange().aStart;
- const ScAddress aSrcEndPos = rCxt.getClipDoc()->GetClipParam().getWholeRange().aEnd;
- tools::Rectangle aSourceRect = rCxt.getClipDoc()->GetMMRect(
- aSrcStartPos.Col(), aSrcStartPos.Row(), aSrcEndPos.Col(), aSrcEndPos.Row(),
- aSrcStartPos.Tab());
- tools::Rectangle aDestRect = GetDoc().GetMMRect(nCol1, nRow1, nCol2, nRow2, nTab);
- pDrawLayer->CopyFromClip(rCxt.getClipDoc()->mpDrawLayer.get(), aSrcStartPos.Tab(),
- aSourceRect, ScAddress(nCol1, nRow1, nTab), aDestRect);
- }
+ const ScAddress aSrcStartPos
+ = rCxt.getClipDoc()->GetClipParam().getWholeRange().aStart;
+ const ScAddress aSrcEndPos = rCxt.getClipDoc()->GetClipParam().getWholeRange().aEnd;
+ tools::Rectangle aSourceRect = rCxt.getClipDoc()->GetMMRect(
+ aSrcStartPos.Col(), aSrcStartPos.Row(), aSrcEndPos.Col(), aSrcEndPos.Row(),
+ aSrcStartPos.Tab());
+ tools::Rectangle aDestRect = GetDoc().GetMMRect(nCol1, nRow1, nCol2, nRow2, nTab);
+ pDrawLayer->CopyFromClip(rCxt.getClipDoc()->mpDrawLayer.get(), aSrcStartPos.Tab(),
+ aSourceRect, ScAddress(nCol1, nRow1, nTab), aDestRect);
}
}