sc/source/filter/xml/XMLCalculationSettingsContext.cxx |    9 -
 sc/source/filter/xml/XMLTableShapeImportHelper.cxx     |    2 
 sc/source/filter/xml/xmlbodyi.cxx                      |    6 -
 sc/source/filter/xml/xmlcelli.cxx                      |    6 -
 sc/source/filter/xml/xmlcoli.cxx                       |    2 
 sc/source/filter/xml/xmlimprt.cxx                      |   85 +++++++----------
 sc/source/filter/xml/xmlimprt.hxx                      |    3 
 sc/source/filter/xml/xmlrowi.cxx                       |    2 
 sc/source/filter/xml/xmlstyli.cxx                      |   70 ++++++--------
 sc/source/filter/xml/xmlsubti.cxx                      |    2 
 sc/source/filter/xml/xmltabi.cxx                       |    2 
 11 files changed, 87 insertions(+), 102 deletions(-)

New commits:
commit da0ca6a060e7df6fec65af502484ae0fda0d3033
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu Nov 23 21:10:23 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Nov 24 12:47:40 2023 +0100

    use more concrete UNO in sc
    
    Change-Id: Id486b94464bfa49ed471bcb825acee7bddeacb8c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159873
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx 
b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
index d5e214b7c20d..645da6c59773 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
@@ -25,7 +25,7 @@
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/xmlnamespace.hxx>
 #include <sax/tools/converter.hxx>
-
+#include <docuno.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 
@@ -110,11 +110,8 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 
ScXMLCalculationSetting
 
 void SAL_CALL ScXMLCalculationSettingsContext::endFastElement( sal_Int32 
/*nElement*/ )
 {
-    if (!GetScImport().GetModel().is())
-        return;
-
-    uno::Reference <beans::XPropertySet> xPropertySet 
(GetScImport().GetModel(), uno::UNO_QUERY);
-    if (!xPropertySet.is())
+    ScModelObj* xPropertySet(GetScImport().GetScModel());
+    if (!xPropertySet)
         return;
 
     xPropertySet->setPropertyValue( SC_UNO_CALCASSHOWN, uno::Any(bCalcAsShown) 
);
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx 
b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index 8a6c4b4c3ca6..003b84a0e488 100644
--- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
@@ -221,7 +221,7 @@ void XMLTableShapeImportHelper::finishShape(
     if (!bNote)
     {
         // any shape other than a note prevents copying the sheet
-        ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(mrImporter.GetModel())->GetSheetSaveData();
+        ScSheetSaveData* pSheetData = 
static_cast<ScXMLImport&>(mrImporter).GetScModel()->GetSheetSaveData();
         pSheetData->BlockSheet( rTables.GetCurrentSheet() );
     }
 
diff --git a/sc/source/filter/xml/xmlbodyi.cxx 
b/sc/source/filter/xml/xmlbodyi.cxx
index 64c807dfe11e..0b75b50466eb 100644
--- a/sc/source/filter/xml/xmlbodyi.cxx
+++ b/sc/source/filter/xml/xmlbodyi.cxx
@@ -121,7 +121,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
         ScXMLBodyContext::createFastChildContext( sal_Int32 nElement,
         const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
 {
-    ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetScImport().GetModel())->GetSheetSaveData();
+    ScSheetSaveData* pSheetData = 
GetScImport().GetScModel()->GetSheetSaveData();
     if ( pSheetData && pSheetData->HasStartPos() )
     {
         // stream part to copy ends before the next child element
@@ -195,7 +195,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
 
 void SAL_CALL ScXMLBodyContext::characters(const OUString &)
 {
-    ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetScImport().GetModel())->GetSheetSaveData();
+    ScSheetSaveData* pSheetData = 
GetScImport().GetScModel()->GetSheetSaveData();
     if ( pSheetData && pSheetData->HasStartPos() )
     {
         // stream part to copy ends before any content (whitespace) within the 
spreadsheet element
@@ -207,7 +207,7 @@ void SAL_CALL ScXMLBodyContext::characters(const OUString &)
 
 void SAL_CALL ScXMLBodyContext::endFastElement(sal_Int32 nElement)
 {
-    ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetScImport().GetModel())->GetSheetSaveData();
+    ScSheetSaveData* pSheetData = 
GetScImport().GetScModel()->GetSheetSaveData();
     if ( pSheetData && pSheetData->HasStartPos() )
     {
         // stream part to copy ends before the closing tag of spreadsheet 
element
diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index e0968d3ad3dc..6c739dc42304 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -375,7 +375,7 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, 
sal_Int32 nEnd, cons
     rFmt.maSelection.nEndPos = nEnd;
 
     // Store the used text styles for export.
-    ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(rXMLImport.GetModel())->GetSheetSaveData();
+    ScSheetSaveData* pSheetData = rXMLImport.GetScModel()->GetSheetSaveData();
     ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
     pSheetData->AddTextStyle(rStyleName, aCellPos, rFmt.maSelection);
 
@@ -812,7 +812,7 @@ void ScXMLTableRowCellContext::SetContentValidation( const 
ScRange& rScRange )
     // is the below still needed?
     // For now, any sheet with validity is blocked from stream-copying.
     // Later, the validation names could be stored along with the style names.
-    ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetImport().GetModel())->GetSheetSaveData();
+    ScSheetSaveData* pSheetData = 
GetScImport().GetScModel()->GetSheetSaveData();
     pSheetData->BlockSheet( GetScImport().GetTables().GetCurrentSheet() );
 }
 
@@ -935,7 +935,7 @@ void ScXMLTableRowCellContext::SetAnnotation(const 
ScAddress& rPos)
     }
 
     // store the style names for stream copying
-    ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(rXMLImport.GetModel())->GetSheetSaveData();
+    ScSheetSaveData* pSheetData = rXMLImport.GetScModel()->GetSheetSaveData();
     pSheetData->HandleNoteStyles( mxAnnotationData->maStyleName, 
mxAnnotationData->maTextStyle, rPos );
 
     for (const auto& rContentStyle : mxAnnotationData->maContentStyles)
diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx
index 4e52dfa413ad..f835bddb7c5e 100644
--- a/sc/source/filter/xml/xmlcoli.cxx
+++ b/sc/source/filter/xml/xmlcoli.cxx
@@ -112,7 +112,7 @@ void SAL_CALL ScXMLTableColContext::endFastElement( 
sal_Int32 /*nElement*/ )
 
                             if ( nSheet != pStyle->GetLastSheet() )
                             {
-                                ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(rXMLImport.GetModel())->GetSheetSaveData();
+                                ScSheetSaveData* pSheetData = 
rXMLImport.GetScModel()->GetSheetSaveData();
                                 pSheetData->AddColumnStyle( sStyleName, 
ScAddress( static_cast<SCCOL>(nCurrentColumn), 0, nSheet ) );
                                 pStyle->SetLastSheet(nSheet);
                             }
diff --git a/sc/source/filter/xml/xmlimprt.cxx 
b/sc/source/filter/xml/xmlimprt.cxx
index b9c775fff470..60fa7ba71741 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -337,11 +337,8 @@ SvXMLImportContext *ScXMLImport::CreateFastContext( 
sal_Int32 nElement,
 
     case XML_ELEMENT( OFFICE, XML_DOCUMENT ):
     {
-        uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
-            GetModel(), uno::UNO_QUERY_THROW);
         // flat OpenDocument file format
-        pContext = new ScXMLFlatDocContext_Impl( *this,
-            xDPS->getDocumentProperties());
+        pContext = new ScXMLFlatDocContext_Impl( *this, 
GetScModel()->getDocumentProperties());
         break;
     }
 
@@ -454,10 +451,8 @@ SvXMLImportContext *ScXMLImport::CreateMetaContext(
 
     if (getImportFlags() & SvXMLImportFlags::META)
     {
-        uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
-            GetModel(), uno::UNO_QUERY_THROW);
         uno::Reference<document::XDocumentProperties> const xDocProps(
-            (IsStylesOnlyMode()) ? nullptr : xDPS->getDocumentProperties());
+            (IsStylesOnlyMode()) ? nullptr : 
GetScModel()->getDocumentProperties());
         pContext = new SvXMLMetaDocumentContext(*this, xDocProps);
     }
 
@@ -723,7 +718,7 @@ void ScXMLImport::SetViewSettings(const 
uno::Sequence<beans::PropertyValue>& aVi
     if (!(nHeight && nWidth && GetModel().is()))
         return;
 
-    ScModelObj* pDocObj(comphelper::getFromUnoTunnel<ScModelObj>( GetModel() 
));
+    ScModelObj* pDocObj( GetScModel() );
     if (!pDocObj)
         return;
 
@@ -739,10 +734,7 @@ void ScXMLImport::SetViewSettings(const 
uno::Sequence<beans::PropertyValue>& aVi
 
 void ScXMLImport::SetConfigurationSettings(const 
uno::Sequence<beans::PropertyValue>& aConfigProps)
 {
-    if (!GetModel().is())
-        return;
-
-    uno::Reference <lang::XMultiServiceFactory> 
xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
+    rtl::Reference<ScModelObj> xMultiServiceFactory(GetScModel());
     if (!xMultiServiceFactory.is())
         return;
 
@@ -1001,7 +993,7 @@ void ScXMLImport::SetStyleToRanges()
                 sal_uInt64 nKey = 0;
                 if ((aAny >>= nKey) && nKey)
                 {
-                    ScFormatSaveData* pFormatSaveData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetFormatSaveData();
+                    ScFormatSaveData* pFormatSaveData = 
GetScModel()->GetFormatSaveData();
                     pFormatSaveData->maIDToName.insert(std::pair<sal_uInt64, 
OUString>(nKey, sPrevStyleName));
                 }
 
@@ -1013,7 +1005,7 @@ void ScXMLImport::SetStyleToRanges()
                     const table::CellRangeAddress& rRange = aAddresses[0];
                     if ( rRange.Sheet != pStyle->GetLastSheet() )
                     {
-                        ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetSheetSaveData();
+                        ScSheetSaveData* pSheetData = 
GetScModel()->GetSheetSaveData();
                         pSheetData->AddCellStyle( sPrevStyleName,
                             ScAddress( static_cast<SCCOL>(rRange.StartColumn), 
static_cast<SCROW>(rRange.StartRow), static_cast<SCTAB>(rRange.Sheet) ) );
                         pStyle->SetLastSheet(rRange.Sheet);
@@ -1033,10 +1025,9 @@ void ScXMLImport::SetStyleToRanges()
     }
     if (GetModel().is())
     {
-        uno::Reference <lang::XMultiServiceFactory> 
xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
-        if (xMultiServiceFactory.is())
-            mxSheetCellRanges = &dynamic_cast<ScCellRangesObj&>(
-                
*xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"));
+        rtl::Reference<ScModelObj> xMultiServiceFactory(GetScModel());
+        mxSheetCellRanges = &dynamic_cast<ScCellRangesObj&>(
+            
*xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"));
     }
     OSL_ENSURE(mxSheetCellRanges.is(), "didn't get SheetCellRanges");
 }
@@ -1077,11 +1068,9 @@ void ScXMLImport::SetStyleToRanges(const ScRangeList& 
rRanges, const OUString* p
 
     if (!mxSheetCellRanges.is() && GetModel().is())
     {
-        uno::Reference <lang::XMultiServiceFactory> 
xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
-        if (xMultiServiceFactory.is())
-            mxSheetCellRanges = 
&dynamic_cast<ScCellRangesObj&>(*xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"));
+        rtl::Reference<ScModelObj> xMultiServiceFactory(GetScModel());
+        mxSheetCellRanges = 
&dynamic_cast<ScCellRangesObj&>(*xMultiServiceFactory->createInstance("com.sun.star.sheet.SheetCellRanges"));
         OSL_ENSURE(mxSheetCellRanges.is(), "didn't get SheetCellRanges");
-
     }
     mxSheetCellRanges->SetNewRanges(rRanges);
 }
@@ -1144,7 +1133,7 @@ void SAL_CALL ScXMLImport::startDocument()
     SvXMLImport::startDocument();
     if (pDoc && !pDoc->IsImportingXML())
     {
-        
comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->BeforeXMLLoading();
+        GetScModel()->BeforeXMLLoading();
         bSelfImportingXMLSet = true;
     }
 
@@ -1159,7 +1148,7 @@ void SAL_CALL ScXMLImport::startDocument()
         if (GetModel().is())
         {
             // store initial namespaces, to find the ones that were added from 
the file later
-            ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetSheetSaveData();
+            ScSheetSaveData* pSheetData = GetScModel()->GetSheetSaveData();
             const SvXMLNamespaceMap& rNamespaces = GetNamespaceMap();
             pSheetData->StoreInitialNamespaces(rNamespaces);
         }
@@ -1217,7 +1206,7 @@ void ScXMLImport::SetLabelRanges()
     if (maMyLabelRanges.empty())
         return;
 
-    uno::Reference <beans::XPropertySet> xPropertySet (GetModel(), 
uno::UNO_QUERY);
+    rtl::Reference<ScModelObj> xPropertySet (GetScModel());
     if (!xPropertySet.is())
         return;
 
@@ -1367,29 +1356,26 @@ void SAL_CALL ScXMLImport::endDocument()
         {
             mpDocImport->finalize();
 
-            uno::Reference<document::XViewDataSupplier> 
xViewDataSupplier(GetModel(), uno::UNO_QUERY);
-            if (xViewDataSupplier.is())
+            rtl::Reference<ScModelObj> xViewDataSupplier(GetScModel());
+            uno::Reference<container::XIndexAccess> 
xIndexAccess(xViewDataSupplier->getViewData());
+            if (xIndexAccess.is() && xIndexAccess->getCount() > 0)
             {
-                uno::Reference<container::XIndexAccess> 
xIndexAccess(xViewDataSupplier->getViewData());
-                if (xIndexAccess.is() && xIndexAccess->getCount() > 0)
+                uno::Sequence< beans::PropertyValue > aSeq;
+                if (xIndexAccess->getByIndex(0) >>= aSeq)
                 {
-                    uno::Sequence< beans::PropertyValue > aSeq;
-                    if (xIndexAccess->getByIndex(0) >>= aSeq)
+                    for (const auto& rProp : std::as_const(aSeq))
                     {
-                        for (const auto& rProp : std::as_const(aSeq))
+                        OUString sName(rProp.Name);
+                        if (sName == SC_ACTIVETABLE)
                         {
-                            OUString sName(rProp.Name);
-                            if (sName == SC_ACTIVETABLE)
+                            OUString sTabName;
+                            if(rProp.Value >>= sTabName)
                             {
-                                OUString sTabName;
-                                if(rProp.Value >>= sTabName)
+                                SCTAB nTab(0);
+                                if (pDoc->GetTable(sTabName, nTab))
                                 {
-                                    SCTAB nTab(0);
-                                    if (pDoc->GetTable(sTabName, nTab))
-                                    {
-                                        pDoc->SetVisibleTab(nTab);
-                                        break;
-                                    }
+                                    pDoc->SetVisibleTab(nTab);
+                                    break;
                                 }
                             }
                         }
@@ -1422,7 +1408,7 @@ void SAL_CALL ScXMLImport::endDocument()
         {
             // set "valid stream" flags after loading (before 
UpdateRowHeights, so changed formula results
             // in UpdateRowHeights can already clear the flags again)
-            ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->GetSheetSaveData();
+            ScSheetSaveData* pSheetData = GetScModel()->GetSheetSaveData();
 
             SCTAB nTabCount = pDoc->GetTableCount();
             for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
@@ -1482,11 +1468,9 @@ void SAL_CALL ScXMLImport::endDocument()
 
         aTables.FixupOLEs();
     }
-    if (GetModel().is())
+    if (GetScModel())
     {
-        uno::Reference<document::XActionLockable> xActionLockable(GetModel(), 
uno::UNO_QUERY);
-        if (xActionLockable.is())
-            xActionLockable->removeActionLock();
+        GetScModel()->removeActionLock();
     }
     SvXMLImport::endDocument();
 
@@ -1496,7 +1480,7 @@ void SAL_CALL ScXMLImport::endDocument()
     }
 
     if(pDoc && bSelfImportingXMLSet)
-        
comphelper::getFromUnoTunnel<ScModelObj>(GetModel())->AfterXMLLoading();
+        GetScModel()->AfterXMLLoading();
 }
 
 // XEventListener
@@ -1679,6 +1663,11 @@ ScMyImpDetectiveOpArray* 
ScXMLImport::GetDetectiveOpArray()
     return pDetectiveOpArray.get();
 }
 
+ScModelObj* ScXMLImport::GetScModel() const
+{
+    return static_cast<ScModelObj*>(GetModel().get());
+}
+
 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportFODS(SvStream &rStream)
 {
     ScDLL::Init();
diff --git a/sc/source/filter/xml/xmlimprt.hxx 
b/sc/source/filter/xml/xmlimprt.hxx
index 7dddb7d6f5c9..843e86536088 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -50,6 +50,7 @@ class ScEditEngineDefaulter;
 class ScDocumentImport;
 class ScMyImpDetectiveOpArray;
 class SdrPage;
+class ScModelObj;
 
 namespace sc {
 struct ImportPostProcessData;
@@ -206,6 +207,8 @@ public:
     ScDocument*          GetDocument()           { return pDoc; }
     const ScDocument*    GetDocument() const     { return pDoc; }
 
+    ScModelObj* GetScModel() const;
+
     ScMyTables& GetTables() { return aTables; }
 
     std::vector<ScDocRowHeightUpdater::TabRanges>& GetRecalcRowRanges() { 
return maRecalcRowRanges; }
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index d510d5557eed..82f58d1f3c40 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -183,7 +183,7 @@ void SAL_CALL 
ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/)
 
                 if ( nSheet != pStyle->GetLastSheet() )
                 {
-                    ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(rXMLImport.GetModel())->GetSheetSaveData();
+                    ScSheetSaveData* pSheetData = 
rXMLImport.GetScModel()->GetSheetSaveData();
                     pSheetData->AddRowStyle( sStyleName, ScAddress( 0, 
static_cast<SCROW>(nFirstRow), nSheet ) );
                     pStyle->SetLastSheet(nSheet);
                 }
diff --git a/sc/source/filter/xml/xmlstyli.cxx 
b/sc/source/filter/xml/xmlstyli.cxx
index a607b013e9c7..7b5d8611a954 100644
--- a/sc/source/filter/xml/xmlstyli.cxx
+++ b/sc/source/filter/xml/xmlstyli.cxx
@@ -546,9 +546,9 @@ void XMLTableStyleContext::FillPropertySet(
 
 void XMLTableStyleContext::SetDefaults()
 {
-    if ((GetFamily() == XmlStyleFamily::TABLE_CELL) && 
GetImport().GetModel().is())
+    if ((GetFamily() == XmlStyleFamily::TABLE_CELL) && 
GetScImport().GetScModel())
     {
-        uno::Reference <lang::XMultiServiceFactory> 
xMultiServiceFactory(GetImport().GetModel(), uno::UNO_QUERY);
+        rtl::Reference<ScModelObj> 
xMultiServiceFactory(GetScImport().GetScModel());
         if (xMultiServiceFactory.is())
         {
             uno::Reference <beans::XPropertySet> 
xProperties(xMultiServiceFactory->createInstance("com.sun.star.sheet.Defaults"),
 uno::UNO_QUERY);
@@ -799,41 +799,37 @@ uno::Reference < XNameContainer >
         }
         if( !xStyles.is() && !sName.isEmpty() && GetScImport().GetModel().is() 
)
         {
-            uno::Reference< XStyleFamiliesSupplier > xFamiliesSupp(
-                                            GetScImport().GetModel(), 
UNO_QUERY );
-            if (xFamiliesSupp.is())
-            {
-                uno::Reference< XNameAccess > 
xFamilies(xFamiliesSupp->getStyleFamilies());
+            ScModelObj* xFamiliesSupp( GetScImport().GetScModel() );
+            uno::Reference< XNameAccess > 
xFamilies(xFamiliesSupp->getStyleFamilies());
 
-                try
-                {
-                    xStyles.set(xFamilies->getByName( sName ), uno::UNO_QUERY);
-                }
-                catch ( uno::Exception& )
-                {
-                    // #i97680# Named table/column/row styles aren't 
supported, getByName will throw an exception.
-                    // For better interoperability, these styles should then 
be handled as automatic styles.
-                    // For now, NULL is returned (and the style is ignored).
-                }
-                switch( nFamily )
-                {
-                case XmlStyleFamily::TABLE_TABLE:
-                    const_cast<XMLTableStylesContext 
*>(this)->xTableStyles.set(xStyles);
-                    break;
-                case XmlStyleFamily::TABLE_CELL:
-                    const_cast<XMLTableStylesContext 
*>(this)->xCellStyles.set(xStyles);
-                    break;
-                case XmlStyleFamily::TABLE_COLUMN:
-                    const_cast<XMLTableStylesContext 
*>(this)->xColumnStyles.set(xStyles);
-                    break;
-                case XmlStyleFamily::TABLE_ROW:
-                    const_cast<XMLTableStylesContext 
*>(this)->xRowStyles.set(xStyles);
-                    break;
-                case XmlStyleFamily::SD_GRAPHICS_ID:
-                    const_cast<XMLTableStylesContext 
*>(this)->xGraphicStyles.set(xStyles);
-                    break;
-                default: break;
-                }
+            try
+            {
+                xStyles.set(xFamilies->getByName( sName ), uno::UNO_QUERY);
+            }
+            catch ( uno::Exception& )
+            {
+                // #i97680# Named table/column/row styles aren't supported, 
getByName will throw an exception.
+                // For better interoperability, these styles should then be 
handled as automatic styles.
+                // For now, NULL is returned (and the style is ignored).
+            }
+            switch( nFamily )
+            {
+            case XmlStyleFamily::TABLE_TABLE:
+                const_cast<XMLTableStylesContext 
*>(this)->xTableStyles.set(xStyles);
+                break;
+            case XmlStyleFamily::TABLE_CELL:
+                const_cast<XMLTableStylesContext 
*>(this)->xCellStyles.set(xStyles);
+                break;
+            case XmlStyleFamily::TABLE_COLUMN:
+                const_cast<XMLTableStylesContext 
*>(this)->xColumnStyles.set(xStyles);
+                break;
+            case XmlStyleFamily::TABLE_ROW:
+                const_cast<XMLTableStylesContext 
*>(this)->xRowStyles.set(xStyles);
+                break;
+            case XmlStyleFamily::SD_GRAPHICS_ID:
+                const_cast<XMLTableStylesContext 
*>(this)->xGraphicStyles.set(xStyles);
+                break;
+            default: break;
             }
         }
     }
@@ -1038,7 +1034,7 @@ void ScCellTextStyleContext::FillPropertySet( const 
uno::Reference<beans::XPrope
         {
             ESelection aSel = pCellImp->GetSelection();
 
-            ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(GetImport().GetModel())->GetSheetSaveData();
+            ScSheetSaveData* pSheetData = 
GetScImport().GetScModel()->GetSheetSaveData();
             pSheetData->AddTextStyle( GetName(), aPos, aSel );
 
             nLastSheet = aPos.Tab();
diff --git a/sc/source/filter/xml/xmlsubti.cxx 
b/sc/source/filter/xml/xmlsubti.cxx
index a20b74a328a2..7e5083f2a3c9 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -153,7 +153,7 @@ void ScMyTables::SetTableStyle(const OUString& sStyleName)
         {
             pStyle->FillPropertySet(xProperties);
 
-            ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(rImport.GetModel())->GetSheetSaveData();
+            ScSheetSaveData* pSheetData = 
rImport.GetScModel()->GetSheetSaveData();
             pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, 
maCurrentCellPos.Tab() ) );
         }
     }
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index 173e651874a8..af4ba33d3c6f 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -399,7 +399,7 @@ void SAL_CALL ScXMLTableContext::endFastElement(sal_Int32 
/*nElement*/)
     // store stream positions
     if (!pExternalRefInfo && nStartOffset >= 0 /* && nEndOffset >= 0 */)
     {
-        ScSheetSaveData* pSheetData = 
comphelper::getFromUnoTunnel<ScModelObj>(rImport.GetModel())->GetSheetSaveData();
+        ScSheetSaveData* pSheetData = rImport.GetScModel()->GetSheetSaveData();
         SCTAB nTab = rTables.GetCurrentSheet();
         // pSheetData->AddStreamPos( nTab, nStartOffset, nEndOffset );
         pSheetData->StartStreamPos( nTab, nStartOffset );

Reply via email to