summaryrefslogtreecommitdiffstats
path: root/sc/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx4
-rw-r--r--sc/source/ui/app/inputwin.cxx19
-rw-r--r--sc/source/ui/app/transobj.cxx31
-rw-r--r--sc/source/ui/condformat/condformatdlgentry.cxx68
-rw-r--r--sc/source/ui/dialogs/searchresults.cxx20
-rw-r--r--sc/source/ui/docshell/docfunc.cxx6
-rw-r--r--sc/source/ui/inc/output.hxx1
-rw-r--r--sc/source/ui/miscdlgs/inscodlg.cxx4
-rw-r--r--sc/source/ui/miscdlgs/mvtabdlg.cxx16
-rw-r--r--sc/source/ui/namedlg/namedefdlg.cxx8
-rw-r--r--sc/source/ui/namedlg/namedlg.cxx4
-rw-r--r--sc/source/ui/navipi/content.cxx2
-rw-r--r--sc/source/ui/undo/undodat.cxx129
-rw-r--r--sc/source/ui/undo/undotab.cxx26
-rw-r--r--sc/source/ui/view/formatsh.cxx2
-rw-r--r--sc/source/ui/view/output.cxx1
-rw-r--r--sc/source/ui/view/output3.cxx8
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx2
18 files changed, 233 insertions, 118 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index 7aaa7237cc..020386a69a 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -310,7 +310,11 @@ void SAL_CALL ScAccessibleSpreadsheet::disposing()
mpViewShell->RemoveAccessibilityObject(*this);
mpViewShell = nullptr;
}
+
mpAccCell.clear();
+ m_mapSelectionSend.clear();
+ m_mapFormulaSelectionSend.clear();
+ m_pAccFormulaCell.clear();
ScAccessibleTableBase::disposing();
}
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7f0cf742b0..2b2dcb7ebd 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -799,9 +799,11 @@ void ScInputWindow::MouseButtonDown( const MouseEvent& rMEvt )
// I'd prefer to leave at least a single column header and a
// row but I don't know how to get that value in pixels.
// Use TOOLBOX_WINDOW_HEIGHT for the moment
- ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
- mnMaxY = GetOutputSizePixel().Height() + (pViewSh->GetGridHeight(SC_SPLIT_TOP)
- + pViewSh->GetGridHeight(SC_SPLIT_BOTTOM)) - TOOLBOX_WINDOW_HEIGHT;
+ if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
+ {
+ mnMaxY = GetOutputSizePixel().Height() + (pViewSh->GetGridHeight(SC_SPLIT_TOP)
+ + pViewSh->GetGridHeight(SC_SPLIT_BOTTOM)) - TOOLBOX_WINDOW_HEIGHT;
+ }
}
}
@@ -2663,11 +2665,12 @@ void ScPosWnd::DoEnter()
if (bOpenManageNamesDialog)
{
const sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
- ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
- assert(pViewSh);
- SfxViewFrame& rViewFrm = pViewSh->GetViewFrame();
- SfxChildWindow* pWnd = rViewFrm.GetChildWindow( nId );
- SC_MOD()->SetRefDialog( nId, pWnd == nullptr );
+ if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
+ {
+ SfxViewFrame& rViewFrm = pViewSh->GetViewFrame();
+ SfxChildWindow* pWnd = rViewFrm.GetChildWindow( nId );
+ SC_MOD()->SetRefDialog( nId, pWnd == nullptr );
+ }
}
}
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 5f0599c888..e5ed3b1afe 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -405,11 +405,38 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt
aReducedBlock.aEnd.Col(), aReducedBlock.aEnd.Row(),
aReducedBlock.aStart.Tab() );
ScopedVclPtrInstance< VirtualDevice > pVirtDev;
- pVirtDev->SetOutputSizePixel(pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM)));
+
+ // tdf#160855 fix crash due to Skia's internal maximum pixel limit
+ // Somewhere in the tens of thousands of selected fill cells,
+ // the size of the VirtualDevice exceeds 1 GB of pixels. But
+ // Skia, at least on macOS, will fail to create a surface.
+ // Even if there is ample free memory, Skia/Raster will fail.
+ // The second problem is that even if you disable Skia, the
+ // crash is just delayed when a BitmapEx is created from the
+ // VirtualDevice and malloc() fails.
+ // Since this data flavor really triggers one or more system
+ // memory limits, lower the resolution of the bitmap by keeping
+ // the VirtualDevice pixel size within an arbitrary number of
+ // pixels.
+ // Note: the artibrary "maximum number of pixels" limit that
+ // that Skia can handle may need to be raised or lowered for
+ // platforms other than macOS.
+ static constexpr tools::Long nCopyToImageMaxPixels = 8192 * 8192;
+ Fraction aScale(1.0);
+ Size aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM));
+ tools::Long nPixels(aPixelSize.Width() * aPixelSize.Height());
+ if (nPixels < 0 || nPixels > nCopyToImageMaxPixels)
+ {
+ aScale = Fraction(nCopyToImageMaxPixels, nPixels);
+ aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM, Point(), aScale, aScale));
+ nPixels = aPixelSize.Width() * aPixelSize.Height();
+ }
+
+ pVirtDev->SetOutputSizePixel(aPixelSize);
PaintToDev( pVirtDev, *m_pDoc, 1.0, aReducedBlock );
- pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel ) );
+ pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel, Point(), aScale, aScale ) );
BitmapEx aBmp = pVirtDev->GetBitmapEx( Point(), pVirtDev->GetOutputSize() );
bOK = SetBitmapEx( aBmp, rFlavor );
}
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index ade0cede7c..171c9ecd13 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -440,43 +440,45 @@ void StyleSelect(weld::Window* pDialogParent, weld::ComboBox& rLbStyle, const Sc
// unlock the dispatcher so SID_STYLE_NEW can be executed
// (SetDispatcherLock would affect all Calc documents)
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
- SfxDispatcher* pDisp = pViewShell->GetDispatcher();
- bool bLocked = pDisp->IsLocked();
- if (bLocked)
- pDisp->Lock(false);
-
- // Execute the "new style" slot, complete with undo and all necessary updates.
- // The return value (SfxUInt16Item) is ignored, look for new styles instead.
- pDisp->ExecuteList(SID_STYLE_NEW,
- SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
- { &aFamilyItem, &aRefItem }, { &aDialogParent });
-
- if (bLocked)
- pDisp->Lock(true);
-
- // Find the new style and add it into the style list boxes
- SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SfxStyleFamily::Para );
- bool bFound = false;
- for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle && !bFound; pStyle = aStyleIter.Next() )
+ if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell())
{
- const OUString& aName = pStyle->GetName();
- if (rLbStyle.find_text(aName) == -1) // all lists contain the same entries
+ SfxDispatcher* pDisp = pViewShell->GetDispatcher();
+ bool bLocked = pDisp->IsLocked();
+ if (bLocked)
+ pDisp->Lock(false);
+
+ // Execute the "new style" slot, complete with undo and all necessary updates.
+ // The return value (SfxUInt16Item) is ignored, look for new styles instead.
+ pDisp->ExecuteList(SID_STYLE_NEW,
+ SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
+ { &aFamilyItem, &aRefItem }, { &aDialogParent });
+
+ if (bLocked)
+ pDisp->Lock(true);
+
+ // Find the new style and add it into the style list boxes
+ SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SfxStyleFamily::Para );
+ bool bFound = false;
+ for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle && !bFound; pStyle = aStyleIter.Next() )
{
- for( sal_Int32 i = 1, n = rLbStyle.get_count(); i <= n && !bFound; ++i)
+ const OUString& aName = pStyle->GetName();
+ if (rLbStyle.find_text(aName) == -1) // all lists contain the same entries
{
- OUString aStyleName = ScGlobal::getCharClass().uppercase(rLbStyle.get_text(i));
- if( i == n )
+ for( sal_Int32 i = 1, n = rLbStyle.get_count(); i <= n && !bFound; ++i)
{
- rLbStyle.append_text(aName);
- rLbStyle.set_active_text(aName);
- bFound = true;
- }
- else if( aStyleName > ScGlobal::getCharClass().uppercase(aName) )
- {
- rLbStyle.insert_text(i, aName);
- rLbStyle.set_active_text(aName);
- bFound = true;
+ OUString aStyleName = ScGlobal::getCharClass().uppercase(rLbStyle.get_text(i));
+ if( i == n )
+ {
+ rLbStyle.append_text(aName);
+ rLbStyle.set_active_text(aName);
+ bFound = true;
+ }
+ else if( aStyleName > ScGlobal::getCharClass().uppercase(aName) )
+ {
+ rLbStyle.insert_text(i, aName);
+ rLbStyle.set_active_text(aName);
+ bFound = true;
+ }
}
}
}
diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx
index 4ea08c1d49..31444dbb3f 100644
--- a/sc/source/ui/dialogs/searchresults.cxx
+++ b/sc/source/ui/dialogs/searchresults.cxx
@@ -249,18 +249,22 @@ IMPL_LINK_NOARG( SearchResultsDlg, ListSelectHdl, weld::TreeView&, void )
return;
// Jump to the cell.
- ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
- pScViewShell->SetTabNo(nTab);
- pScViewShell->SetCursor(aPos.Col(), aPos.Row());
- pScViewShell->AlignToCursor(aPos.Col(), aPos.Row(), SC_FOLLOW_JUMP);
+ if (ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell())
+ {
+ pScViewShell->SetTabNo(nTab);
+ pScViewShell->SetCursor(aPos.Col(), aPos.Row());
+ pScViewShell->AlignToCursor(aPos.Col(), aPos.Row(), SC_FOLLOW_JUMP);
+ }
}
IMPL_STATIC_LINK( SearchResultsDlg, OnShowToggled, weld::Toggleable&, rButton, void )
{
- ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
- ScViewOptions aViewOpt( pScViewShell->GetViewData().GetOptions() );
- aViewOpt.SetOption( VOPT_SUMMARY, rButton.get_active() );
- pScViewShell->GetViewData().SetOptions( aViewOpt );
+ if (ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell())
+ {
+ ScViewOptions aViewOpt( pScViewShell->GetViewData().GetOptions() );
+ aViewOpt.SetOption( VOPT_SUMMARY, rButton.get_active() );
+ pScViewShell->GetViewData().SetOptions( aViewOpt );
+ }
}
SearchResultsDlgWrapper::SearchResultsDlgWrapper(
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 4c333b0502..d67e6efa66 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5500,11 +5500,11 @@ void ScDocFunc::ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd
if ( DeleteContents( aMark, InsertDeleteFlags::CONTENTS, true, false/*bApi*/ ) )
{
- // GRAM_API for API compatibility.
- if (!EnterMatrix( aNewRange, &aMark, nullptr, aFormula, false/*bApi*/, false, OUString(), formula::FormulaGrammar::GRAM_API ))
+ // Formula string was obtained in document grammar.
+ if (!EnterMatrix( aNewRange, &aMark, nullptr, aFormula, false/*bApi*/, false, OUString(), rDoc.GetGrammar() ))
{
// try to restore the previous state
- EnterMatrix( rOldRange, &aMark, nullptr, aFormula, false/*bApi*/, false, OUString(), formula::FormulaGrammar::GRAM_API );
+ EnterMatrix( rOldRange, &aMark, nullptr, aFormula, false/*bApi*/, false, OUString(), rDoc.GetGrammar() );
}
}
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index e4763767b7..18d4aa1f2b 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -175,6 +175,7 @@ private:
void adjustForHyperlinkInPDF(Point aURLStart, const OutputDevice* pDev);
};
+ VclPtr<OutputDevice> mpOriginalTargetDevice; // 'unpatched' TargetDevice
VclPtr<OutputDevice> mpDev; // Device
VclPtr<OutputDevice> mpRefDevice; // printer if used for preview
VclPtr<OutputDevice> pFmtDevice; // reference for text formatting
diff --git a/sc/source/ui/miscdlgs/inscodlg.cxx b/sc/source/ui/miscdlgs/inscodlg.cxx
index 84292dcd91..378b10f37f 100644
--- a/sc/source/ui/miscdlgs/inscodlg.cxx
+++ b/sc/source/ui/miscdlgs/inscodlg.cxx
@@ -231,7 +231,9 @@ void ScInsertContentsDlg::SetInsContentsCmdBits(const InsertDeleteFlags eFlags)
mxBtnInsNumbers->set_active((InsertDeleteFlags::VALUE & eFlags) == InsertDeleteFlags::VALUE);
mxBtnInsDateTime->set_active((InsertDeleteFlags::DATETIME & eFlags) == InsertDeleteFlags::DATETIME);
mxBtnInsStrings->set_active((InsertDeleteFlags::STRING & eFlags) == InsertDeleteFlags::STRING);
- mxBtnInsNotes->set_active((InsertDeleteFlags::NOTE & eFlags) == InsertDeleteFlags::NOTE);
+ // tdf#160765 - additionally check either NOTE or ADDNOTES
+ mxBtnInsNotes->set_active(((InsertDeleteFlags::NOTE | InsertDeleteFlags::ADDNOTES) & eFlags)
+ != InsertDeleteFlags::NONE);
mxBtnInsFormulas->set_active((InsertDeleteFlags::FORMULA & eFlags) == InsertDeleteFlags::FORMULA);
mxBtnInsAttrs->set_active((InsertDeleteFlags::ATTRIB & eFlags) == InsertDeleteFlags::ATTRIB);
mxBtnInsObjects->set_active((InsertDeleteFlags::OBJECTS & eFlags) == InsertDeleteFlags::OBJECTS);
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index afacdc48b4..fe2b9d2111 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -191,9 +191,9 @@ void ScMoveTableDlg::Init()
m_xEdTabName->connect_changed(LINK(this, ScMoveTableDlg, CheckNameHdl));
// tdf#96854 - remember last used option for copy/move sheet
- const bool bIsCopyActive
- = ScTabViewShell::GetActiveViewShell()->GetViewData().GetOptions().GetOption(
- VOPT_COPY_SHEET);
+ bool bIsCopyActive = false;
+ if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
+ bIsCopyActive = pViewSh->GetViewData().GetOptions().GetOption(VOPT_COPY_SHEET);
m_xBtnMove->set_active(!bIsCopyActive);
m_xBtnCopy->set_active(bIsCopyActive);
m_xEdTabName->set_sensitive(false);
@@ -251,10 +251,12 @@ void ScMoveTableDlg::SetOkBtnLabel()
// tdf#139464 Write "Copy" or "Move" on OK button
m_xBtnOk->set_label(bIsCopyActive ? m_xBtnCopy->get_label() : m_xBtnMove->get_label());
// tdf#96854 - remember last used option for copy/move sheet
- ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
- ScViewOptions aViewOpt(pScViewShell->GetViewData().GetOptions());
- aViewOpt.SetOption(VOPT_COPY_SHEET, bIsCopyActive);
- pScViewShell->GetViewData().SetOptions(aViewOpt);
+ if (ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell())
+ {
+ ScViewOptions aViewOpt(pScViewShell->GetViewData().GetOptions());
+ aViewOpt.SetOption(VOPT_COPY_SHEET, bIsCopyActive);
+ pScViewShell->GetViewData().SetOptions(aViewOpt);
+ }
}
// Handler:
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 3304f4d39b..81139b7766 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -94,8 +94,8 @@ void ScNameDefDlg::CancelPushed()
response(RET_CANCEL);
else
{
- ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
- pViewSh->SwitchBetweenRefDialogs(this);
+ if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
+ pViewSh->SwitchBetweenRefDialogs(this);
}
}
@@ -254,8 +254,8 @@ void ScNameDefDlg::AddPushed()
{
maName = aName;
maScope = aScope;
- ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
- pViewSh->SwitchBetweenRefDialogs(this);
+ if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
+ pViewSh->SwitchBetweenRefDialogs(this);
}
}
else
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index a6a182cd82..2501672378 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -306,8 +306,8 @@ void ScNameDlg::ShowOptions(const ScRangeNameLine& rLine)
void ScNameDlg::AddPushed()
{
mbCloseWithoutUndo = true;
- ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
- pViewSh->SwitchBetweenRefDialogs(this);
+ if (ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell())
+ pViewSh->SwitchBetweenRefDialogs(this);
}
void ScNameDlg::SetEntry(const OUString& rName, const OUString& rScope)
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 89d7764255..374ee93438 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -1435,7 +1435,7 @@ void ScContentTree::SelectEntryByName(const ScContentId nRoot, std::u16string_vi
{
weld::TreeIter* pParent = m_aRootNodes[nRoot].get();
- if (pParent || !m_xTreeView->iter_has_child(*pParent))
+ if (!pParent || !m_xTreeView->iter_has_child(*pParent))
return;
std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator(pParent));
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 498060839a..f34ebba87d 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -77,10 +77,13 @@ OUString ScUndoDoOutline::GetComment() const
void ScUndoDoOutline::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
// sheet has to be switched over (#46952#)!
@@ -114,9 +117,11 @@ void ScUndoDoOutline::Undo()
void ScUndoDoOutline::Redo()
{
- BeginRedo();
-
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
+ BeginRedo();
// sheet has to be switched over (#46952#)!
@@ -168,10 +173,13 @@ OUString ScUndoMakeOutline::GetComment() const
void ScUndoMakeOutline::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
SCTAB nTab = aBlockStart.Tab();
ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
@@ -196,10 +204,13 @@ void ScUndoMakeOutline::Undo()
void ScUndoMakeOutline::Redo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginRedo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
@@ -253,10 +264,13 @@ OUString ScUndoOutlineLevel::GetComment() const
void ScUndoOutlineLevel::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
// Original Outline table
@@ -288,9 +302,11 @@ void ScUndoOutlineLevel::Undo()
void ScUndoOutlineLevel::Redo()
{
- BeginRedo();
-
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
+ BeginRedo();
// sheet has to be switched on or off before this (#46952#) !!!
@@ -337,10 +353,13 @@ OUString ScUndoOutlineBlock::GetComment() const
void ScUndoOutlineBlock::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
SCTAB nTab = aBlockStart.Tab();
// Original Outline table
@@ -387,9 +406,11 @@ void ScUndoOutlineBlock::Undo()
void ScUndoOutlineBlock::Redo()
{
- BeginRedo();
-
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
+ BeginRedo();
ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
if (bShow)
@@ -437,10 +458,13 @@ OUString ScUndoRemoveAllOutlines::GetComment() const
void ScUndoRemoveAllOutlines::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
SCTAB nTab = aBlockStart.Tab();
// Original Outline table
@@ -477,9 +501,11 @@ void ScUndoRemoveAllOutlines::Undo()
void ScUndoRemoveAllOutlines::Redo()
{
- BeginRedo();
-
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
+ BeginRedo();
// sheet has to be switched over (#46952#)!
@@ -523,10 +549,13 @@ OUString ScUndoAutoOutline::GetComment() const
void ScUndoAutoOutline::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
SCTAB nTab = aBlockStart.Tab();
// Original outline table
@@ -561,19 +590,18 @@ void ScUndoAutoOutline::Undo()
void ScUndoAutoOutline::Redo()
{
- BeginRedo();
-
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
+ BeginRedo();
SCTAB nTab = aBlockStart.Tab();
- if (pViewShell)
- {
- // sheet has to be switched on or off before this (#46952#) !!!
+ // sheet has to be switched on or off before this (#46952#) !!!
- SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
- if ( nVisTab != nTab )
- pViewShell->SetTabNo( nTab );
- }
+ SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
ScRange aRange( aBlockStart.Col(), aBlockStart.Row(), nTab,
aBlockEnd.Col(), aBlockEnd.Row(), nTab );
@@ -584,8 +612,7 @@ void ScUndoAutoOutline::Redo()
// If it was called with a multi selection,
// then this is now the enclosing range...
- if (pViewShell)
- pViewShell->MarkRange( aRange );
+ pViewShell->MarkRange( aRange );
EndRedo();
}
@@ -624,10 +651,13 @@ OUString ScUndoSubTotals::GetComment() const
void ScUndoSubTotals::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
if (nNewEndRow > aParam.nRow2)
{
@@ -691,9 +721,11 @@ void ScUndoSubTotals::Undo()
void ScUndoSubTotals::Redo()
{
- BeginRedo();
-
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
+ BeginRedo();
SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
if ( nVisTab != nTab )
@@ -755,6 +787,9 @@ OUString ScUndoQuery::GetComment() const
void ScUndoQuery::Undo()
{
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
if (ScTabViewShell::isAnyEditViewInRange(pViewShell, /*bColumns*/ false, aQueryParam.nRow1, aQueryParam.nRow2))
return;
@@ -870,9 +905,11 @@ void ScUndoQuery::Undo()
void ScUndoQuery::Redo()
{
- BeginRedo();
-
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
+ BeginRedo();
SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
if ( nVisTab != nTab )
@@ -1065,10 +1102,13 @@ OUString ScUndoImportData::GetComment() const
void ScUndoImportData::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab,
nEndCol,nEndRow,nTab );
@@ -1150,10 +1190,13 @@ void ScUndoImportData::Undo()
void ScUndoImportData::Redo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginRedo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab,
nEndCol,nEndRow,nTab );
@@ -1274,10 +1317,13 @@ OUString ScUndoRepeatDB::GetComment() const
void ScUndoRepeatDB::Undo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
SCTAB nTab = aBlockStart.Tab();
if (bQuerySize)
@@ -1375,9 +1421,12 @@ void ScUndoRepeatDB::Undo()
void ScUndoRepeatDB::Redo()
{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
BeginRedo();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
SCTAB nTab = aBlockStart.Tab();
SCTAB nVisTab = pViewShell->GetViewData().GetTabNo();
@@ -1493,12 +1542,6 @@ void ScUndoDataPilot::Undo()
pDocShell->PostPaint(aOldRange, PaintPartFlags::Grid, SC_PF_LINES);
pDocShell->PostDataChanged();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
- if (pViewShell)
- {
- //! set current sheet
- }
-
if (xNewDPObject)
{
// notify API objects
@@ -1887,7 +1930,7 @@ void ScUndoDataForm::DoChange( const bool bUndo )
aDrawRange.aEnd.SetCol(rDoc.MaxCol());
aDrawRange.aEnd.SetRow(rDoc.MaxRow());
nPaint |= PaintPartFlags::Top | PaintPartFlags::Left;
-/*A*/ if (pViewShell)
+ if (pViewShell)
pViewShell->AdjustBlockHeight(false);
}
else
@@ -1902,7 +1945,7 @@ void ScUndoDataForm::DoChange( const bool bUndo )
nPaint |= PaintPartFlags::Left;
aDrawRange.aEnd.SetRow(rDoc.MaxRow());
}
-/*A*/ if (pViewShell && pViewShell->AdjustBlockHeight(false))
+ if (pViewShell && pViewShell->AdjustBlockHeight(false))
{
aDrawRange.aStart.SetCol(0);
aDrawRange.aStart.SetRow(0);
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 4237aab463..0eacb70d1c 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -105,6 +105,9 @@ void ScUndoInsertTab::SetChangeTrack()
void ScUndoInsertTab::Undo()
{
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
pViewShell->SetTabNo(nTab);
pDocShell->SetInUndo( true ); //! BeginUndo
@@ -126,6 +129,8 @@ void ScUndoInsertTab::Undo()
void ScUndoInsertTab::Redo()
{
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
RedoSdrUndoAction( pDrawUndo.get() ); // Draw Redo first
@@ -202,6 +207,9 @@ void ScUndoInsertTables::SetChangeTrack()
void ScUndoInsertTables::Undo()
{
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
pViewShell->SetTabNo(nTab);
pDocShell->SetInUndo( true ); //! BeginUndo
@@ -225,6 +233,8 @@ void ScUndoInsertTables::Undo()
void ScUndoInsertTables::Redo()
{
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
RedoSdrUndoAction( pDrawUndo.get() ); // Draw Redo first
@@ -493,9 +503,11 @@ OUString ScUndoMoveTab::GetComment() const
void ScUndoMoveTab::DoChange( bool bUndo ) const
{
- ScDocument& rDoc = pDocShell->GetDocument();
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+ ScDocument& rDoc = pDocShell->GetDocument();
if (bUndo) // UnDo
{
size_t i = mpNewTabs->size();
@@ -645,8 +657,11 @@ void ScUndoCopyTab::Undo()
void ScUndoCopyTab::Redo()
{
- ScDocument& rDoc = pDocShell->GetDocument();
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
+ ScDocument& rDoc = pDocShell->GetDocument();
SCTAB nDestTab = 0;
for (size_t i = 0, n = mpNewTabs->size(); i < n; ++i)
@@ -883,6 +898,9 @@ OUString ScUndoImportTab::GetComment() const
void ScUndoImportTab::DoChange() const
{
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+
ScDocument& rDoc = pDocShell->GetDocument();
SCTAB nTabCount = rDoc.GetTableCount();
if (pViewShell)
@@ -1105,9 +1123,11 @@ ScUndoShowHideTab::~ScUndoShowHideTab()
void ScUndoShowHideTab::DoChange( bool bShowP ) const
{
- ScDocument& rDoc = pDocShell->GetDocument();
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (!pViewShell)
+ return;
+ ScDocument& rDoc = pDocShell->GetDocument();
for(const SCTAB& nTab : undoTabs)
{
rDoc.SetVisible( nTab, bShowP );
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 93a456e46b..8381209e7c 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -1736,7 +1736,7 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
// SvNumFormatType::DEFINED bit.
const SvNumFormatType nType = (eItemState >= SfxItemState::DEFAULT ? pFormatter->GetType( nNumberFormat) :
GetCurrentNumberFormatType());
- NfIndexTableOffset nOffset = pFormatter->GetIndexTableOffset(nNumberFormat);
+ NfIndexTableOffset nOffset = SvNumberFormatter::GetIndexTableOffset(nNumberFormat);
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 9d0fe14305..6f01dc052f 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -144,6 +144,7 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
double nPixelPerTwipsX, double nPixelPerTwipsY,
const Fraction* pZoomX, const Fraction* pZoomY ) :
+ mpOriginalTargetDevice( pNewDev ),
mpDev( pNewDev ),
mpRefDevice( pNewDev ), // default is output device
pFmtDevice( pNewDev ), // default is output device
diff --git a/sc/source/ui/view/output3.cxx b/sc/source/ui/view/output3.cxx
index bc6efec654..760a62a12d 100644
--- a/sc/source/ui/view/output3.cxx
+++ b/sc/source/ui/view/output3.cxx
@@ -206,7 +206,13 @@ void ScOutputData::DrawSelectiveObjects(SdrLayerID nLayer)
if(pPageView)
{
- if (nullptr != pPageView->FindPageWindow(*mpDev))
+ // tdf#160589 need to check for registered PaintWindow using the
+ // 'original' TragetDevice, mpDev might have been changed by a
+ // call to ::SetContentDevice. That again might patch in a
+ // pre-render device fetched from SdrPaintWindow::GetTargetOutputDevice
+ // and thus the test if target is aregistered PageWindow would fail
+ assert(nullptr != mpOriginalTargetDevice && "mpOriginalTargetDevice *must* be set when constructing ScOutputData (!)");
+ if (nullptr != pPageView->FindPageWindow(*mpOriginalTargetDevice))
{
// Target OutputDevice is registered for this view
// (as it should be), we can just render
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 345a33534d..2daa55be00 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1075,7 +1075,7 @@ void ScTabViewShell::SetDrawTextUndo( SfxUndoManager* pNewUndoMgr )
ScTabViewShell* ScTabViewShell::GetActiveViewShell()
{
- return dynamic_cast< ScTabViewShell *>( Current() );
+ return dynamic_cast< ScTabViewShell *>( SfxViewShell::Current() );
}
SfxPrinter* ScTabViewShell::GetPrinter( bool bCreate )