diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index e8526a0e4d70..9431577b5a4b 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1867,14 +1867,14 @@ uno::Reference ScTabViewShell::GetRangeWithSheet(css:: uno::Reference xController(xModel->getCurrentController()); // spreadsheet's extension of com.sun.star.frame.Controller service - uno::Reference SpreadsheetDocument(xController, uno::UNO_QUERY); - uno::Reference ActiveSheet = SpreadsheetDocument->getActiveSheet(); + ScTabViewObj* pSpreadsheetDocument = dynamic_cast(xController.get()); + assert(pSpreadsheetDocument); + uno::Reference ActiveSheet = pSpreadsheetDocument->getActiveSheet(); if (!bHasUnoArguments) { // get the selection supplier, extract selection in XSheetCellRange - uno::Reference xSelectionSupplier(SpreadsheetDocument, uno::UNO_QUERY); - uno::Any Selection = xSelectionSupplier->getSelection(); + uno::Any Selection = pSpreadsheetDocument->getSelection(); uno::Reference SelectedCellRange; Selection >>= SelectedCellRange;