summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2023-11-23 20:58:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-11-24 12:47:32 +0100
commit6f0f7fa17aebe888cb8264bd48d741f469ba56b9 (patch)
treeb578782dc9927c72b9de97cb936c6dcfbf7efaad
parentca0609368edf80c4e56abf36fefc2bfabfd82deb (diff)
loplugin:fieldcast in ScXMLImport
Change-Id: I0820427504d0cb9e14b54bb92a2e383bf0137121 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159872 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--compilerplugins/clang/fieldcast.results3
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx19
-rw-r--r--sc/source/filter/xml/xmlimprt.hxx3
3 files changed, 11 insertions, 14 deletions
diff --git a/compilerplugins/clang/fieldcast.results b/compilerplugins/clang/fieldcast.results
index b3a206434484..6fa27d645135 100644
--- a/compilerplugins/clang/fieldcast.results
+++ b/compilerplugins/clang/fieldcast.results
@@ -298,9 +298,6 @@ sc/source/filter/excel/xeformula.cxx:60
sc/source/filter/inc/eeimport.hxx:43
ScEEImport mpParser std::unique_ptr<ScEEParser>
ScHTMLParser
-sc/source/filter/xml/xmlimprt.hxx:156
- ScXMLImport xSheetCellRanges css::uno::Reference<css::sheet::XSheetCellRangeContainer>
- ScCellRangesObj
sc/source/ui/inc/AccessibleContextBase.hxx:232
ScAccessibleContextBase mxParent css::uno::Reference<css::accessibility::XAccessible>
ScAccessibleSpreadsheet
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index db113a47b4b1..b9c775fff470 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -982,7 +982,7 @@ void ScXMLImport::SetStyleToRanges()
if (!sPrevStyleName.isEmpty())
{
- uno::Reference <beans::XPropertySet> xProperties (xSheetCellRanges, uno::UNO_QUERY);
+ uno::Reference <beans::XPropertySet> xProperties (mxSheetCellRanges);
if (xProperties.is())
{
XMLTableStylesContext *pStyles(static_cast<XMLTableStylesContext *>(GetAutoStyles()));
@@ -1006,7 +1006,7 @@ void ScXMLImport::SetStyleToRanges()
}
// store first cell of first range for each style, once per sheet
- uno::Sequence<table::CellRangeAddress> aAddresses(xSheetCellRanges->getRangeAddresses());
+ uno::Sequence<table::CellRangeAddress> aAddresses(mxSheetCellRanges->getRangeAddresses());
pStyle->ApplyCondFormat(aAddresses);
if ( aAddresses.hasElements() )
{
@@ -1035,11 +1035,10 @@ void ScXMLImport::SetStyleToRanges()
{
uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
if (xMultiServiceFactory.is())
- xSheetCellRanges.set(uno::Reference <sheet::XSheetCellRangeContainer>(
- xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"),
- uno::UNO_QUERY));
+ mxSheetCellRanges = &dynamic_cast<ScCellRangesObj&>(
+ *xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"));
}
- OSL_ENSURE(xSheetCellRanges.is(), "didn't get SheetCellRanges");
+ OSL_ENSURE(mxSheetCellRanges.is(), "didn't get SheetCellRanges");
}
void ScXMLImport::SetStyleToRanges(const ScRangeList& rRanges, const OUString* pStyleName,
@@ -1076,15 +1075,15 @@ void ScXMLImport::SetStyleToRanges(const ScRangeList& rRanges, const OUString* p
sPrevCurrency.clear();
}
- if (!xSheetCellRanges.is() && GetModel().is())
+ if (!mxSheetCellRanges.is() && GetModel().is())
{
uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
if (xMultiServiceFactory.is())
- xSheetCellRanges.set(uno::Reference <sheet::XSheetCellRangeContainer>(xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY));
- OSL_ENSURE(xSheetCellRanges.is(), "didn't get SheetCellRanges");
+ mxSheetCellRanges = &dynamic_cast<ScCellRangesObj&>(*xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"));
+ OSL_ENSURE(mxSheetCellRanges.is(), "didn't get SheetCellRanges");
}
- static_cast<ScCellRangesObj*>(xSheetCellRanges.get())->SetNewRanges(rRanges);
+ mxSheetCellRanges->SetNewRanges(rRanges);
}
bool ScXMLImport::SetNullDateOnUnitConverter()
diff --git a/sc/source/filter/xml/xmlimprt.hxx b/sc/source/filter/xml/xmlimprt.hxx
index 88feb0ddb671..7dddb7d6f5c9 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -110,6 +110,7 @@ struct ScMyImportValidation
typedef std::vector<ScMyImportValidation> ScMyImportValidations;
class ScMyStylesImportHelper;
class ScXMLEditAttributeMap;
+class ScCellRangesObj;
class ScXMLImport: public SvXMLImport
{
@@ -153,7 +154,7 @@ class ScXMLImport: public SvXMLImport
css::uno::Reference <css::util::XNumberFormats> xNumberFormats;
css::uno::Reference <css::util::XNumberFormatTypes> xNumberFormatTypes;
- css::uno::Reference <css::sheet::XSheetCellRangeContainer> xSheetCellRanges;
+ rtl::Reference<ScCellRangesObj> mxSheetCellRanges; // css::sheet::XSheetCellRangeContainer
OUString sPrevStyleName;
OUString sPrevCurrency;