[Libreoffice-commits] core.git: sc/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 8 08:42:53 UTC 2020


 sc/source/filter/oox/autofilterbuffer.cxx     |  250 ++++++-------
 sc/source/filter/oox/connectionsbuffer.cxx    |   48 +-
 sc/source/filter/oox/defnamesbuffer.cxx       |   81 ++--
 sc/source/filter/oox/drawingfragment.cxx      |   33 -
 sc/source/filter/oox/excelvbaproject.cxx      |    5 
 sc/source/filter/oox/externallinkfragment.cxx |   35 +
 sc/source/filter/oox/formulabase.cxx          |   33 -
 sc/source/filter/oox/pagesettings.cxx         |   40 +-
 sc/source/filter/oox/pivotcachebuffer.cxx     |   28 -
 sc/source/filter/oox/pivotcachefragment.cxx   |   30 -
 sc/source/filter/oox/pivottablebuffer.cxx     |  481 +++++++++++++-------------
 sc/source/filter/oox/querytablebuffer.cxx     |   84 ++--
 sc/source/filter/oox/richstring.cxx           |   70 +--
 sc/source/filter/oox/scenariobuffer.cxx       |    5 
 sc/source/filter/oox/sheetdatabuffer.cxx      |  139 +++----
 sc/source/filter/oox/sheetdatacontext.cxx     |  184 ++++-----
 sc/source/filter/oox/stylesbuffer.cxx         |  276 +++++++-------
 sc/source/filter/oox/tablebuffer.cxx          |   31 -
 sc/source/filter/oox/unitconverter.cxx        |   47 +-
 sc/source/filter/oox/viewsettings.cxx         |   94 ++---
 sc/source/filter/oox/workbookhelper.cxx       |  129 +++---
 sc/source/filter/oox/worksheetbuffer.cxx      |   42 +-
 sc/source/filter/oox/worksheethelper.cxx      |  114 +++---
 23 files changed, 1153 insertions(+), 1126 deletions(-)

New commits:
commit 358bdc5eb38a6a7c310027f4a10694230b848b7f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 7 16:34:54 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Aug 8 10:42:13 2020 +0200

    loplugin:flatten in sc/filter/oox
    
    Change-Id: Idd536dbeaee1f1db3317d96b90e56691976a89ee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100338
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx
index 8e77d935d9a2..6cb33c4d2658 100644
--- a/sc/source/filter/oox/autofilterbuffer.cxx
+++ b/sc/source/filter/oox/autofilterbuffer.cxx
@@ -556,86 +556,86 @@ FilterColumn& AutoFilter::createFilterColumn()
 
 void AutoFilter::finalizeImport( const Reference<XSheetFilterDescriptor3>& rxFilterDesc )
 {
-    if( rxFilterDesc.is() )
+    if( !rxFilterDesc.is() )
+        return;
+
+    // set some common properties for the auto filter range
+    PropertySet aDescProps( rxFilterDesc );
+    aDescProps.setProperty( PROP_IsCaseSensitive, false );
+    aDescProps.setProperty( PROP_SkipDuplicates, false );
+    aDescProps.setProperty( PROP_Orientation, TableOrientation_ROWS );
+    aDescProps.setProperty( PROP_ContainsHeader, true );
+    aDescProps.setProperty( PROP_CopyOutputData, false );
+
+    // maximum number of UNO API filter fields
+    sal_Int32 nMaxCount = 0;
+    aDescProps.getProperty( nMaxCount, PROP_MaxFieldCount );
+    OSL_ENSURE( nMaxCount > 0, "AutoFilter::finalizeImport - invalid maximum filter field count" );
+
+    // resulting list of all UNO API filter fields
+    ::std::vector<TableFilterField3> aFilterFields;
+
+    // track if columns require to enable or disable regular expressions
+    OptValue< bool > obNeedsRegExp;
+
+    /*  Track whether the filter fields of the first filter column are
+        connected with 'or'. In this case, other filter fields cannot be
+        inserted without altering the result of the entire filter, due to
+        Calc's precedence for the 'and' connection operator. Example:
+        Excel's filter conditions 'A1 and (B1 or B2) and C1' where B1 and
+        B2 belong to filter column B, will be evaluated by Calc as
+        '(A1 and B1) or (B2 and C1)'. */
+    bool bHasOrConnection = false;
+
+    // process all filter column objects, exit when 'or' connection exists
+    for( const auto& rxFilterColumn : maFilterColumns )
     {
-        // set some common properties for the auto filter range
-        PropertySet aDescProps( rxFilterDesc );
-        aDescProps.setProperty( PROP_IsCaseSensitive, false );
-        aDescProps.setProperty( PROP_SkipDuplicates, false );
-        aDescProps.setProperty( PROP_Orientation, TableOrientation_ROWS );
-        aDescProps.setProperty( PROP_ContainsHeader, true );
-        aDescProps.setProperty( PROP_CopyOutputData, false );
-
-        // maximum number of UNO API filter fields
-        sal_Int32 nMaxCount = 0;
-        aDescProps.getProperty( nMaxCount, PROP_MaxFieldCount );
-        OSL_ENSURE( nMaxCount > 0, "AutoFilter::finalizeImport - invalid maximum filter field count" );
-
-        // resulting list of all UNO API filter fields
-        ::std::vector<TableFilterField3> aFilterFields;
-
-        // track if columns require to enable or disable regular expressions
-        OptValue< bool > obNeedsRegExp;
-
-        /*  Track whether the filter fields of the first filter column are
-            connected with 'or'. In this case, other filter fields cannot be
-            inserted without altering the result of the entire filter, due to
-            Calc's precedence for the 'and' connection operator. Example:
-            Excel's filter conditions 'A1 and (B1 or B2) and C1' where B1 and
-            B2 belong to filter column B, will be evaluated by Calc as
-            '(A1 and B1) or (B2 and C1)'. */
-        bool bHasOrConnection = false;
-
-        // process all filter column objects, exit when 'or' connection exists
-        for( const auto& rxFilterColumn : maFilterColumns )
+        // the filter settings object creates a list of filter fields
+        ApiFilterSettings aSettings = rxFilterColumn->finalizeImport( nMaxCount );
+        ApiFilterSettings::FilterFieldVector& rColumnFields = aSettings.maFilterFields;
+
+        // new total number of filter fields
+        sal_Int32 nNewCount = static_cast< sal_Int32 >( aFilterFields.size() + rColumnFields.size() );
+
+        /*  Check whether mode for regular expressions is compatible with
+            the global mode in obNeedsRegExp. If either one is still in
+            don't-care state, all is fine. If both are set, they must be
+            equal. */
+        bool bRegExpCompatible = !obNeedsRegExp || !aSettings.mobNeedsRegExp || (obNeedsRegExp.get() == aSettings.mobNeedsRegExp.get());
+
+        // check whether fields are connected by 'or' (see comments above).
+        if( rColumnFields.size() >= 2 )
+            bHasOrConnection = std::any_of(rColumnFields.begin() + 1, rColumnFields.end(),
+                [](const css::sheet::TableFilterField3& rColumnField) { return rColumnField.Connection == FilterConnection_OR; });
+
+        /*  Skip the column filter, if no filter fields have been created,
+            if the number of new filter fields would exceed the total limit
+            of filter fields, or if the mode for regular expressions of the
+            filter column does not fit. */
+        if( !rColumnFields.empty() && (nNewCount <= nMaxCount) && bRegExpCompatible )
         {
-            // the filter settings object creates a list of filter fields
-            ApiFilterSettings aSettings = rxFilterColumn->finalizeImport( nMaxCount );
-            ApiFilterSettings::FilterFieldVector& rColumnFields = aSettings.maFilterFields;
-
-            // new total number of filter fields
-            sal_Int32 nNewCount = static_cast< sal_Int32 >( aFilterFields.size() + rColumnFields.size() );
-
-            /*  Check whether mode for regular expressions is compatible with
-                the global mode in obNeedsRegExp. If either one is still in
-                don't-care state, all is fine. If both are set, they must be
-                equal. */
-            bool bRegExpCompatible = !obNeedsRegExp || !aSettings.mobNeedsRegExp || (obNeedsRegExp.get() == aSettings.mobNeedsRegExp.get());
-
-            // check whether fields are connected by 'or' (see comments above).
-            if( rColumnFields.size() >= 2 )
-                bHasOrConnection = std::any_of(rColumnFields.begin() + 1, rColumnFields.end(),
-                    [](const css::sheet::TableFilterField3& rColumnField) { return rColumnField.Connection == FilterConnection_OR; });
-
-            /*  Skip the column filter, if no filter fields have been created,
-                if the number of new filter fields would exceed the total limit
-                of filter fields, or if the mode for regular expressions of the
-                filter column does not fit. */
-            if( !rColumnFields.empty() && (nNewCount <= nMaxCount) && bRegExpCompatible )
-            {
-                /*  Add 'and' connection to the first filter field to connect
-                    it to the existing filter fields of other columns. */
-                rColumnFields[ 0 ].Connection = FilterConnection_AND;
-
-                // insert the new filter fields
-                aFilterFields.insert( aFilterFields.end(), rColumnFields.begin(), rColumnFields.end() );
+            /*  Add 'and' connection to the first filter field to connect
+                it to the existing filter fields of other columns. */
+            rColumnFields[ 0 ].Connection = FilterConnection_AND;
 
-                // update the regular expressions mode
-                obNeedsRegExp.assignIfUsed( aSettings.mobNeedsRegExp );
-            }
+            // insert the new filter fields
+            aFilterFields.insert( aFilterFields.end(), rColumnFields.begin(), rColumnFields.end() );
 
-            if( bHasOrConnection )
-                break;
+            // update the regular expressions mode
+            obNeedsRegExp.assignIfUsed( aSettings.mobNeedsRegExp );
         }
 
-        // insert all filter fields to the filter descriptor
-        if( !aFilterFields.empty() )
-            rxFilterDesc->setFilterFields3( ContainerHelper::vectorToSequence( aFilterFields ) );
-
-        // regular expressions
-        bool bUseRegExp = obNeedsRegExp.get( false );
-        aDescProps.setProperty( PROP_UseRegularExpressions, bUseRegExp );
+        if( bHasOrConnection )
+            break;
     }
+
+    // insert all filter fields to the filter descriptor
+    if( !aFilterFields.empty() )
+        rxFilterDesc->setFilterFields3( ContainerHelper::vectorToSequence( aFilterFields ) );
+
+    // regular expressions
+    bool bUseRegExp = obNeedsRegExp.get( false );
+    aDescProps.setProperty( PROP_UseRegularExpressions, bUseRegExp );
 }
 
 AutoFilterBuffer::AutoFilterBuffer( const WorkbookHelper& rHelper ) :
@@ -653,59 +653,61 @@ AutoFilter& AutoFilterBuffer::createAutoFilter()
 void AutoFilterBuffer::finalizeImport( sal_Int16 nSheet )
 {
     // rely on existence of the defined name '_FilterDatabase' containing the range address of the filtered area
-    if( const DefinedName* pFilterDBName = getDefinedNames().getByBuiltinId( BIFF_DEFNAME_FILTERDATABASE, nSheet ).get() )
+    const DefinedName* pFilterDBName = getDefinedNames().getByBuiltinId( BIFF_DEFNAME_FILTERDATABASE, nSheet ).get();
+    if(!pFilterDBName)
+        return;
+
+    ScRange aFilterRange;
+    if( !(pFilterDBName->getAbsoluteRange( aFilterRange ) && (aFilterRange.aStart.Tab() == nSheet)) )
+        return;
+
+    // use the same name for the database range as used for the defined name '_FilterDatabase'
+    Reference< XDatabaseRange > xDatabaseRange = createUnnamedDatabaseRangeObject( aFilterRange );
+    // first, try to create an auto filter
+    bool bHasAutoFilter = finalizeImport( xDatabaseRange );
+    // no success: try to create an advanced filter
+    if( !(!bHasAutoFilter && xDatabaseRange.is()) )
+        return;
+
+    // the built-in defined name 'Criteria' must exist
+    const DefinedName* pCriteriaName = getDefinedNames().getByBuiltinId( BIFF_DEFNAME_CRITERIA, nSheet ).get();
+    if( !pCriteriaName )
+        return;
+
+    ScRange aCriteriaRange;
+    if( !pCriteriaName->getAbsoluteRange( aCriteriaRange ) )
+        return;
+
+    // set some common properties for the filter descriptor
+    PropertySet aDescProps( xDatabaseRange->getFilterDescriptor() );
+    aDescProps.setProperty( PROP_IsCaseSensitive, false );
+    aDescProps.setProperty( PROP_SkipDuplicates, false );
+    aDescProps.setProperty( PROP_Orientation, TableOrientation_ROWS );
+    aDescProps.setProperty( PROP_ContainsHeader, true );
+    // criteria range may contain wildcards, but these are incompatible with REs
+    aDescProps.setProperty( PROP_UseRegularExpressions, false );
+
+    // position of output data (if built-in defined name 'Extract' exists)
+    DefinedNameRef xExtractName = getDefinedNames().getByBuiltinId( BIFF_DEFNAME_EXTRACT, nSheet );
+    ScRange aOutputRange;
+    bool bHasOutputRange = xExtractName && xExtractName->getAbsoluteRange( aOutputRange );
+    aDescProps.setProperty( PROP_CopyOutputData, bHasOutputRange );
+    if( bHasOutputRange )
     {
-        ScRange aFilterRange;
-        if( pFilterDBName->getAbsoluteRange( aFilterRange ) && (aFilterRange.aStart.Tab() == nSheet) )
-        {
-            // use the same name for the database range as used for the defined name '_FilterDatabase'
-            Reference< XDatabaseRange > xDatabaseRange = createUnnamedDatabaseRangeObject( aFilterRange );
-            // first, try to create an auto filter
-            bool bHasAutoFilter = finalizeImport( xDatabaseRange );
-            // no success: try to create an advanced filter
-            if( !bHasAutoFilter && xDatabaseRange.is() )
-            {
-                // the built-in defined name 'Criteria' must exist
-                if( const DefinedName* pCriteriaName = getDefinedNames().getByBuiltinId( BIFF_DEFNAME_CRITERIA, nSheet ).get() )
-                {
-                    ScRange aCriteriaRange;
-                    if( pCriteriaName->getAbsoluteRange( aCriteriaRange ) )
-                    {
-                        // set some common properties for the filter descriptor
-                        PropertySet aDescProps( xDatabaseRange->getFilterDescriptor() );
-                        aDescProps.setProperty( PROP_IsCaseSensitive, false );
-                        aDescProps.setProperty( PROP_SkipDuplicates, false );
-                        aDescProps.setProperty( PROP_Orientation, TableOrientation_ROWS );
-                        aDescProps.setProperty( PROP_ContainsHeader, true );
-                        // criteria range may contain wildcards, but these are incompatible with REs
-                        aDescProps.setProperty( PROP_UseRegularExpressions, false );
-
-                        // position of output data (if built-in defined name 'Extract' exists)
-                        DefinedNameRef xExtractName = getDefinedNames().getByBuiltinId( BIFF_DEFNAME_EXTRACT, nSheet );
-                        ScRange aOutputRange;
-                        bool bHasOutputRange = xExtractName && xExtractName->getAbsoluteRange( aOutputRange );
-                        aDescProps.setProperty( PROP_CopyOutputData, bHasOutputRange );
-                        if( bHasOutputRange )
-                        {
-                            aDescProps.setProperty( PROP_SaveOutputPosition, true );
-                            aDescProps.setProperty( PROP_OutputPosition, CellAddress( aOutputRange.aStart.Tab(), aOutputRange.aStart.Col(), aOutputRange.aStart.Row() ) );
-                        }
-
-                        /*  Properties of the database range (must be set after
-                            modifying properties of the filter descriptor,
-                            otherwise the 'FilterCriteriaSource' property gets
-                            deleted). */
-                        PropertySet aRangeProps( xDatabaseRange );
-                        aRangeProps.setProperty( PROP_AutoFilter, false );
-                        aRangeProps.setProperty( PROP_FilterCriteriaSource,
-                                                 CellRangeAddress( aCriteriaRange.aStart.Tab(),
-                                                                   aCriteriaRange.aStart.Col(), aCriteriaRange.aStart.Row(),
-                                                                   aCriteriaRange.aEnd.Col(), aCriteriaRange.aEnd.Row() ));
-                    }
-                }
-            }
-        }
+        aDescProps.setProperty( PROP_SaveOutputPosition, true );
+        aDescProps.setProperty( PROP_OutputPosition, CellAddress( aOutputRange.aStart.Tab(), aOutputRange.aStart.Col(), aOutputRange.aStart.Row() ) );
     }
+
+    /*  Properties of the database range (must be set after
+        modifying properties of the filter descriptor,
+        otherwise the 'FilterCriteriaSource' property gets
+        deleted). */
+    PropertySet aRangeProps( xDatabaseRange );
+    aRangeProps.setProperty( PROP_AutoFilter, false );
+    aRangeProps.setProperty( PROP_FilterCriteriaSource,
+                             CellRangeAddress( aCriteriaRange.aStart.Tab(),
+                                               aCriteriaRange.aStart.Col(), aCriteriaRange.aStart.Row(),
+                                               aCriteriaRange.aEnd.Col(), aCriteriaRange.aEnd.Row() ));
 }
 
 bool AutoFilterBuffer::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRange )
diff --git a/sc/source/filter/oox/connectionsbuffer.cxx b/sc/source/filter/oox/connectionsbuffer.cxx
index 165772fefc3a..c8a2b700a863 100644
--- a/sc/source/filter/oox/connectionsbuffer.cxx
+++ b/sc/source/filter/oox/connectionsbuffer.cxx
@@ -163,20 +163,20 @@ void Connection::importTables()
 
 void Connection::importTable( const AttributeList& rAttribs, sal_Int32 nElement )
 {
-    if( maModel.mxWebPr )
+    if( !maModel.mxWebPr )
+        return;
+
+    Any aTableAny;
+    switch( nElement )
     {
-        Any aTableAny;
-        switch( nElement )
-        {
-            case XLS_TOKEN( m ):                                                            break;
-            case XLS_TOKEN( s ):    aTableAny <<= rAttribs.getXString( XML_v, OUString() ); break;
-            case XLS_TOKEN( x ):    aTableAny <<= rAttribs.getInteger( XML_v, -1 );         break;
-            default:
-                OSL_ENSURE( false, "Connection::importTable - unexpected element" );
-                return;
-        }
-        maModel.mxWebPr->maTables.push_back( aTableAny );
+        case XLS_TOKEN( m ):                                                            break;
+        case XLS_TOKEN( s ):    aTableAny <<= rAttribs.getXString( XML_v, OUString() ); break;
+        case XLS_TOKEN( x ):    aTableAny <<= rAttribs.getInteger( XML_v, -1 );         break;
+        default:
+            OSL_ENSURE( false, "Connection::importTable - unexpected element" );
+            return;
     }
+    maModel.mxWebPr->maTables.push_back( aTableAny );
 }
 
 void Connection::importConnection( SequenceInputStream& rStrm )
@@ -259,20 +259,20 @@ void Connection::importWebPrTables( SequenceInputStream& /*rStrm*/ )
 
 void Connection::importWebPrTable( SequenceInputStream& rStrm, sal_Int32 nRecId )
 {
-    if( maModel.mxWebPr )
+    if( !maModel.mxWebPr )
+        return;
+
+    Any aTableAny;
+    switch( nRecId )
     {
-        Any aTableAny;
-        switch( nRecId )
-        {
-            case BIFF12_ID_PCITEM_MISSING:                                                  break;
-            case BIFF12_ID_PCITEM_STRING:   aTableAny <<= BiffHelper::readString( rStrm );  break;
-            case BIFF12_ID_PCITEM_INDEX:    aTableAny <<= rStrm.readInt32();                break;
-            default:
-                OSL_ENSURE( false, "Connection::importWebPrTable - unexpected record" );
-                return;
-        }
-        maModel.mxWebPr->maTables.push_back( aTableAny );
+        case BIFF12_ID_PCITEM_MISSING:                                                  break;
+        case BIFF12_ID_PCITEM_STRING:   aTableAny <<= BiffHelper::readString( rStrm );  break;
+        case BIFF12_ID_PCITEM_INDEX:    aTableAny <<= rStrm.readInt32();                break;
+        default:
+            OSL_ENSURE( false, "Connection::importWebPrTable - unexpected record" );
+            return;
     }
+    maModel.mxWebPr->maTables.push_back( aTableAny );
 }
 
 ConnectionsBuffer::ConnectionsBuffer( const WorkbookHelper& rHelper ) :
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx
index 2bf5d5c4c0ac..ed2b041dcd0f 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -272,52 +272,55 @@ void DefinedName::convertFormula( const css::uno::Sequence<css::sheet::ExternalL
     Sequence< FormulaToken > aFTokenSeq;
     ScTokenConversion::ConvertToTokenSequence( getScDocument(), aFTokenSeq, *pTokenArray );
     // set built-in names (print ranges, repeated titles, filter ranges)
-    if( !isGlobalName() ) switch( mcBuiltinId )
+    if( isGlobalName() )
+        return;
+
+    switch( mcBuiltinId )
     {
-        case BIFF_DEFNAME_PRINTAREA:
-        {
-            Reference< XPrintAreas > xPrintAreas( getSheetFromDoc( mnCalcSheet ), UNO_QUERY );
-            ScRangeList aPrintRanges;
-            getFormulaParser().extractCellRangeList( aPrintRanges, aFTokenSeq, mnCalcSheet );
-            if( xPrintAreas.is() && !aPrintRanges.empty() )
-                xPrintAreas->setPrintAreas( AddressConverter::toApiSequence(aPrintRanges) );
-        }
-        break;
-        case BIFF_DEFNAME_PRINTTITLES:
+    case BIFF_DEFNAME_PRINTAREA:
+    {
+        Reference< XPrintAreas > xPrintAreas( getSheetFromDoc( mnCalcSheet ), UNO_QUERY );
+        ScRangeList aPrintRanges;
+        getFormulaParser().extractCellRangeList( aPrintRanges, aFTokenSeq, mnCalcSheet );
+        if( xPrintAreas.is() && !aPrintRanges.empty() )
+            xPrintAreas->setPrintAreas( AddressConverter::toApiSequence(aPrintRanges) );
+    }
+    break;
+    case BIFF_DEFNAME_PRINTTITLES:
+    {
+        Reference< XPrintAreas > xPrintAreas( getSheetFromDoc( mnCalcSheet ), UNO_QUERY );
+        ScRangeList aTitleRanges;
+        getFormulaParser().extractCellRangeList( aTitleRanges, aFTokenSeq, mnCalcSheet );
+        if( xPrintAreas.is() && !aTitleRanges.empty() )
         {
-            Reference< XPrintAreas > xPrintAreas( getSheetFromDoc( mnCalcSheet ), UNO_QUERY );
-            ScRangeList aTitleRanges;
-            getFormulaParser().extractCellRangeList( aTitleRanges, aFTokenSeq, mnCalcSheet );
-            if( xPrintAreas.is() && !aTitleRanges.empty() )
+            bool bHasRowTitles = false;
+            bool bHasColTitles = false;
+            const ScAddress& rMaxPos = getAddressConverter().getMaxAddress();
+            for (size_t i = 0, nSize = aTitleRanges.size(); i < nSize; ++i)
             {
-                bool bHasRowTitles = false;
-                bool bHasColTitles = false;
-                const ScAddress& rMaxPos = getAddressConverter().getMaxAddress();
-                for (size_t i = 0, nSize = aTitleRanges.size(); i < nSize; ++i)
+                const ScRange& rRange = aTitleRanges[i];
+                bool bFullRow = (rRange.aStart.Col() == 0) && ( rRange.aEnd.Col() >= rMaxPos.Col() );
+                bool bFullCol = (rRange.aStart.Row() == 0) && ( rRange.aEnd.Row() >= rMaxPos.Row() );
+                if( !bHasRowTitles && bFullRow && !bFullCol )
                 {
-                    const ScRange& rRange = aTitleRanges[i];
-                    bool bFullRow = (rRange.aStart.Col() == 0) && ( rRange.aEnd.Col() >= rMaxPos.Col() );
-                    bool bFullCol = (rRange.aStart.Row() == 0) && ( rRange.aEnd.Row() >= rMaxPos.Row() );
-                    if( !bHasRowTitles && bFullRow && !bFullCol )
-                    {
-                        xPrintAreas->setTitleRows( CellRangeAddress(rRange.aStart.Tab(),
-                                                                    rRange.aStart.Col(), rRange.aStart.Row(),
-                                                                    rRange.aEnd.Col(), rRange.aEnd.Row()) );
-                        xPrintAreas->setPrintTitleRows( true );
-                        bHasRowTitles = true;
-                    }
-                    else if( !bHasColTitles && bFullCol && !bFullRow )
-                    {
-                        xPrintAreas->setTitleColumns( CellRangeAddress(rRange.aStart.Tab(),
-                                                                       rRange.aStart.Col(), rRange.aStart.Row(),
-                                                                       rRange.aEnd.Col(), rRange.aEnd.Row()) );
-                        xPrintAreas->setPrintTitleColumns( true );
-                        bHasColTitles = true;
-                    }
+                    xPrintAreas->setTitleRows( CellRangeAddress(rRange.aStart.Tab(),
+                                                                rRange.aStart.Col(), rRange.aStart.Row(),
+                                                                rRange.aEnd.Col(), rRange.aEnd.Row()) );
+                    xPrintAreas->setPrintTitleRows( true );
+                    bHasRowTitles = true;
+                }
+                else if( !bHasColTitles && bFullCol && !bFullRow )
+                {
+                    xPrintAreas->setTitleColumns( CellRangeAddress(rRange.aStart.Tab(),
+                                                                   rRange.aStart.Col(), rRange.aStart.Row(),
+                                                                   rRange.aEnd.Col(), rRange.aEnd.Row()) );
+                    xPrintAreas->setPrintTitleColumns( true );
+                    bHasColTitles = true;
                 }
             }
         }
-        break;
+    }
+    break;
     }
 }
 
diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx
index 396170be35e3..83b3a7446f5e 100644
--- a/sc/source/filter/oox/drawingfragment.cxx
+++ b/sc/source/filter/oox/drawingfragment.cxx
@@ -671,25 +671,26 @@ void VmlDrawing::notifyXShapeInserted( const Reference< XShape >& rxShape,
         extendShapeBoundingBox( rShapeRect );
 
     // convert settings from VML client data
-    if( const ::oox::vml::ClientData* pClientData = rShape.getClientData() )
+    const ::oox::vml::ClientData* pClientData = rShape.getClientData();
+    if(!pClientData)
+        return;
+
+    // specific settings for embedded form controls
+    try
     {
-        // specific settings for embedded form controls
-        try
-        {
-            Reference< XControlShape > xCtrlShape( rxShape, UNO_QUERY_THROW );
-            Reference< XControlModel > xCtrlModel( xCtrlShape->getControl(), UNO_SET_THROW );
-            PropertySet aPropSet( xCtrlModel );
+        Reference< XControlShape > xCtrlShape( rxShape, UNO_QUERY_THROW );
+        Reference< XControlModel > xCtrlModel( xCtrlShape->getControl(), UNO_SET_THROW );
+        PropertySet aPropSet( xCtrlModel );
 
-            // printable
-            aPropSet.setProperty( PROP_Printable, pClientData->mbPrintObject );
+        // printable
+        aPropSet.setProperty( PROP_Printable, pClientData->mbPrintObject );
 
-            // control source links
-            if( !pClientData->maFmlaLink.isEmpty() || !pClientData->maFmlaRange.isEmpty() )
-                maControlConv.bindToSources( xCtrlModel, pClientData->maFmlaLink, pClientData->maFmlaRange, getSheetIndex() );
-        }
-        catch( Exception& )
-        {
-        }
+        // control source links
+        if( !pClientData->maFmlaLink.isEmpty() || !pClientData->maFmlaRange.isEmpty() )
+            maControlConv.bindToSources( xCtrlModel, pClientData->maFmlaLink, pClientData->maFmlaRange, getSheetIndex() );
+    }
+    catch( Exception& )
+    {
     }
 }
 
diff --git a/sc/source/filter/oox/excelvbaproject.cxx b/sc/source/filter/oox/excelvbaproject.cxx
index 8a9a3074a167..c3e48ba474c1 100644
--- a/sc/source/filter/oox/excelvbaproject.cxx
+++ b/sc/source/filter/oox/excelvbaproject.cxx
@@ -63,7 +63,10 @@ void ExcelVbaProject::prepareImport()
 {
     /*  Check if the sheets have imported codenames. Generate new unused
         codenames if not. */
-    if( mxDocument.is() ) try
+    if( !mxDocument.is() )
+        return;
+
+    try
     {
         // collect existing codenames (do not use them when creating new codenames)
         ::std::set< OUString > aUsedCodeNames;
diff --git a/sc/source/filter/oox/externallinkfragment.cxx b/sc/source/filter/oox/externallinkfragment.cxx
index eddc0c607cbd..07fbece61698 100644
--- a/sc/source/filter/oox/externallinkfragment.cxx
+++ b/sc/source/filter/oox/externallinkfragment.cxx
@@ -63,23 +63,23 @@ ContextHandlerRef ExternalSheetDataContext::onCreateContext( sal_Int32 nElement,
 
 void ExternalSheetDataContext::onCharacters( const OUString& rChars )
 {
-    if( isCurrentElement( XLS_TOKEN( v ) ) )
+    if( !isCurrentElement( XLS_TOKEN( v ) ) )
+        return;
+
+    switch( mnCurrType )
     {
-        switch( mnCurrType )
-        {
-            case XML_b:
-            case XML_n:
-                setCellValue( Any( rChars.toDouble() ) );
-            break;
-            case XML_e:
-                setCellValue( Any( BiffHelper::calcDoubleFromError( getUnitConverter().calcBiffErrorCode( rChars ) ) ) );
-            break;
-            case XML_str:
-                setCellValue( Any( rChars ) );
-            break;
-        }
-        mnCurrType = XML_TOKEN_INVALID;
+        case XML_b:
+        case XML_n:
+            setCellValue( Any( rChars.toDouble() ) );
+        break;
+        case XML_e:
+            setCellValue( Any( BiffHelper::calcDoubleFromError( getUnitConverter().calcBiffErrorCode( rChars ) ) ) );
+        break;
+        case XML_str:
+            setCellValue( Any( rChars ) );
+        break;
     }
+    mnCurrType = XML_TOKEN_INVALID;
 }
 
 ContextHandlerRef ExternalSheetDataContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
@@ -246,7 +246,10 @@ void ExternalLinkFragment::onCharacters( const OUString& rChars )
 
 void ExternalLinkFragment::onEndElement()
 {
-    if( isCurrentElement( XLS_TOKEN( value ) ) && mxExtName ) switch( mnResultType )
+    if( !(isCurrentElement( XLS_TOKEN( value ) ) && mxExtName) )
+        return;
+
+    switch( mnResultType )
     {
         case XML_b:
             mxExtName->appendResultValue( maResultValue.toDouble() );
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index 9eb33e8e3308..afd418acaf85 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -1149,7 +1149,10 @@ private:
 OpCodeProviderImpl::OpCodeProviderImpl( const FunctionInfoVector& rFuncInfos,
         const Reference< XMultiServiceFactory >& rxModelFactory )
 {
-    if( rxModelFactory.is() ) try
+    if( !rxModelFactory.is() )
+        return;
+
+    try
     {
         Reference< XFormulaOpCodeMapper > xMapper( rxModelFactory->createInstance(
             "com.sun.star.sheet.FormulaOpCodeMapper" ), UNO_QUERY_THROW );
@@ -1684,24 +1687,24 @@ void FormulaProcessorBase::convertStringToStringList(
         ApiTokenSequence& orTokens, sal_Unicode cStringSep, bool bTrimLeadingSpaces ) const
 {
     OUString aString;
-    if( extractString( aString, orTokens ) && !aString.isEmpty() )
+    if( !(extractString( aString, orTokens ) && !aString.isEmpty()) )
+        return;
+
+    ::std::vector< ApiToken > aNewTokens;
+    for( sal_Int32 nPos{ 0 }; nPos>=0; )
     {
-        ::std::vector< ApiToken > aNewTokens;
-        for( sal_Int32 nPos{ 0 }; nPos>=0; )
+        OUString aEntry = aString.getToken( 0, cStringSep, nPos );
+        if( bTrimLeadingSpaces )
         {
-            OUString aEntry = aString.getToken( 0, cStringSep, nPos );
-            if( bTrimLeadingSpaces )
-            {
-                sal_Int32 nStart = 0;
-                while( (nStart < aEntry.getLength()) && (aEntry[ nStart ] == ' ') ) ++nStart;
-                aEntry = aEntry.copy( nStart );
-            }
-            if( !aNewTokens.empty() )
-                aNewTokens.emplace_back( OPCODE_SEP, Any() );
-            aNewTokens.emplace_back( OPCODE_PUSH, Any( aEntry ) );
+            sal_Int32 nStart = 0;
+            while( (nStart < aEntry.getLength()) && (aEntry[ nStart ] == ' ') ) ++nStart;
+            aEntry = aEntry.copy( nStart );
         }
-        orTokens = ContainerHelper::vectorToSequence( aNewTokens );
+        if( !aNewTokens.empty() )
+            aNewTokens.emplace_back( OPCODE_SEP, Any() );
+        aNewTokens.emplace_back( OPCODE_PUSH, Any( aEntry ) );
     }
+    orTokens = ContainerHelper::vectorToSequence( aNewTokens );
 }
 
 } // namespace oox
diff --git a/sc/source/filter/oox/pagesettings.cxx b/sc/source/filter/oox/pagesettings.cxx
index b1854659f4ac..8965d78974b7 100644
--- a/sc/source/filter/oox/pagesettings.cxx
+++ b/sc/source/filter/oox/pagesettings.cxx
@@ -1012,26 +1012,26 @@ void PageSettingsConverter::convertHeaderFooterData(
     orHFData.mbShareOddEven = !bUseEvenContent;
     orHFData.mbDynamicHeight = true;
 
-    if( orHFData.mbHasContent )
-    {
-        // use maximum height of odd/even header/footer
-        orHFData.mnHeight = ::std::max( nOddHeight, nEvenHeight );
-        /*  Calc contains distance between bottom of header and top of page
-            body in "HeaderBodyDistance" property, and distance between bottom
-            of page body and top of footer in "FooterBodyDistance" property */
-        orHFData.mnBodyDist = getUnitConverter().scaleToMm100( fPageMargin - fContentMargin, Unit::Inch ) - orHFData.mnHeight;
-        /*  #i23296# Distance less than 0 means, header or footer overlays page
-            body. As this is not possible in Calc, set fixed header or footer
-            height (crop header/footer) to get correct top position of page body. */
-        orHFData.mbDynamicHeight = orHFData.mnBodyDist >= 0;
-        /*  "HeaderHeight" property is in fact distance from top of header to
-            top of page body (including "HeaderBodyDistance").
-            "FooterHeight" property is in fact distance from bottom of page
-            body to bottom of footer (including "FooterBodyDistance"). */
-        orHFData.mnHeight += orHFData.mnBodyDist;
-        // negative body distance not allowed
-        orHFData.mnBodyDist = ::std::max< sal_Int32 >( orHFData.mnBodyDist, 0 );
-    }
+    if( !orHFData.mbHasContent )
+        return;
+
+    // use maximum height of odd/even header/footer
+    orHFData.mnHeight = ::std::max( nOddHeight, nEvenHeight );
+    /*  Calc contains distance between bottom of header and top of page
+        body in "HeaderBodyDistance" property, and distance between bottom
+        of page body and top of footer in "FooterBodyDistance" property */
+    orHFData.mnBodyDist = getUnitConverter().scaleToMm100( fPageMargin - fContentMargin, Unit::Inch ) - orHFData.mnHeight;
+    /*  #i23296# Distance less than 0 means, header or footer overlays page
+        body. As this is not possible in Calc, set fixed header or footer
+        height (crop header/footer) to get correct top position of page body. */
+    orHFData.mbDynamicHeight = orHFData.mnBodyDist >= 0;
+    /*  "HeaderHeight" property is in fact distance from top of header to
+        top of page body (including "HeaderBodyDistance").
+        "FooterHeight" property is in fact distance from bottom of page
+        body to bottom of footer (including "FooterBodyDistance"). */
+    orHFData.mnHeight += orHFData.mnBodyDist;
+    // negative body distance not allowed
+    orHFData.mnBodyDist = ::std::max< sal_Int32 >( orHFData.mnBodyDist, 0 );
 }
 
 sal_Int32 PageSettingsConverter::writeHeaderFooter(
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx
index e80605b9c130..cd72bb418b83 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -816,21 +816,21 @@ void PivotCacheField::importPCRecordItem( SequenceInputStream& rStrm, const Work
 void PivotCacheField::writeItemToSourceDataCell( const WorksheetHelper& rSheetHelper,
         sal_Int32 nCol, sal_Int32 nRow, const PivotCacheItem& rItem )
 {
-    if( rItem.getType() != XML_m )
+    if( rItem.getType() == XML_m )
+        return;
+
+    CellModel aModel;
+    aModel.maCellAddr = ScAddress( SCCOL( nCol ), SCROW( nRow ), rSheetHelper.getSheetIndex() );
+    SheetDataBuffer& rSheetData = rSheetHelper.getSheetData();
+    switch( rItem.getType() )
     {
-        CellModel aModel;
-        aModel.maCellAddr = ScAddress( SCCOL( nCol ), SCROW( nRow ), rSheetHelper.getSheetIndex() );
-        SheetDataBuffer& rSheetData = rSheetHelper.getSheetData();
-        switch( rItem.getType() )
-        {
-            case XML_s: rSheetData.setStringCell( aModel, rItem.getValue().get< OUString >() );                             break;
-            case XML_n: rSheetData.setValueCell( aModel, rItem.getValue().get< double >() );                                break;
-            case XML_i: rSheetData.setValueCell( aModel, rItem.getValue().get< sal_Int16 >() );                             break;
-            case XML_d: rSheetData.setDateTimeCell( aModel, rItem.getValue().get< css::util::DateTime >() );                           break;
-            case XML_b: rSheetData.setBooleanCell( aModel, rItem.getValue().get< bool >() );                                break;
-            case XML_e: rSheetData.setErrorCell( aModel, static_cast< sal_uInt8 >( rItem.getValue().get< sal_Int32 >() ) ); break;
-            default:    OSL_FAIL( "PivotCacheField::writeItemToSourceDataCell - unexpected item data type" );
-        }
+        case XML_s: rSheetData.setStringCell( aModel, rItem.getValue().get< OUString >() );                             break;
+        case XML_n: rSheetData.setValueCell( aModel, rItem.getValue().get< double >() );                                break;
+        case XML_i: rSheetData.setValueCell( aModel, rItem.getValue().get< sal_Int16 >() );                             break;
+        case XML_d: rSheetData.setDateTimeCell( aModel, rItem.getValue().get< css::util::DateTime >() );                           break;
+        case XML_b: rSheetData.setBooleanCell( aModel, rItem.getValue().get< bool >() );                                break;
+        case XML_e: rSheetData.setErrorCell( aModel, static_cast< sal_uInt8 >( rItem.getValue().get< sal_Int32 >() ) ); break;
+        default:    OSL_FAIL( "PivotCacheField::writeItemToSourceDataCell - unexpected item data type" );
     }
 }
 
diff --git a/sc/source/filter/oox/pivotcachefragment.cxx b/sc/source/filter/oox/pivotcachefragment.cxx
index 1b7e2d36b090..a8db4426be33 100644
--- a/sc/source/filter/oox/pivotcachefragment.cxx
+++ b/sc/source/filter/oox/pivotcachefragment.cxx
@@ -300,23 +300,23 @@ void PivotCacheRecordsFragment::importPCRecord( SequenceInputStream& rStrm )
 
 void PivotCacheRecordsFragment::importPCRecordItem( sal_Int32 nRecId, SequenceInputStream& rStrm )
 {
-    if( mbInRecord )
+    if( !mbInRecord )
+        return;
+
+    PivotCacheItem aItem;
+    switch( nRecId )
     {
-        PivotCacheItem aItem;
-        switch( nRecId )
-        {
-            case BIFF12_ID_PCITEM_MISSING:                              break;
-            case BIFF12_ID_PCITEM_STRING:   aItem.readString( rStrm );  break;
-            case BIFF12_ID_PCITEM_DOUBLE:   aItem.readDouble( rStrm );  break;
-            case BIFF12_ID_PCITEM_DATE:     aItem.readDate( rStrm );    break;
-            case BIFF12_ID_PCITEM_BOOL:     aItem.readBool( rStrm );    break;
-            case BIFF12_ID_PCITEM_ERROR:    aItem.readError( rStrm );   break;
-            case BIFF12_ID_PCITEM_INDEX:    aItem.readIndex( rStrm );   break;
-            default:    OSL_FAIL( "OoxPivotCacheRecordsFragment::importPCRecordItem - unexpected record" );
-        }
-        mrPivotCache.writeSourceDataCell( *this, mnColIdx, mnRowIdx, aItem );
-        ++mnColIdx;
+        case BIFF12_ID_PCITEM_MISSING:                              break;
+        case BIFF12_ID_PCITEM_STRING:   aItem.readString( rStrm );  break;
+        case BIFF12_ID_PCITEM_DOUBLE:   aItem.readDouble( rStrm );  break;
+        case BIFF12_ID_PCITEM_DATE:     aItem.readDate( rStrm );    break;
+        case BIFF12_ID_PCITEM_BOOL:     aItem.readBool( rStrm );    break;
+        case BIFF12_ID_PCITEM_ERROR:    aItem.readError( rStrm );   break;
+        case BIFF12_ID_PCITEM_INDEX:    aItem.readIndex( rStrm );   break;
+        default:    OSL_FAIL( "OoxPivotCacheRecordsFragment::importPCRecordItem - unexpected record" );
     }
+    mrPivotCache.writeSourceDataCell( *this, mnColIdx, mnRowIdx, aItem );
+    ++mnColIdx;
 }
 
 
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx b/sc/source/filter/oox/pivottablebuffer.cxx
index 8bfa5f206ed3..23889b790774 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -382,7 +382,10 @@ void PivotTableField::finalizeImport( const Reference< XDataPilotDescriptor >& r
         returns -1 for all fields not based on source data. */
     Reference< XDataPilotField > xDPField;
     sal_Int32 nDatabaseIdx = mrPivotTable.getCacheDatabaseIndex( mnFieldIndex );
-    if( (nDatabaseIdx >= 0) && rxDPDesc.is() ) try
+    if( !((nDatabaseIdx >= 0) && rxDPDesc.is()) )
+        return;
+
+    try
     {
         // try to get the source field and its name from passed DataPilot descriptor
         Reference< XIndexAccess > xDPFieldsIA( rxDPDesc->getDataPilotFields(), UNO_SET_THROW );
@@ -443,29 +446,30 @@ void PivotTableField::finalizeDateGroupingImport( const Reference< XDataPilotFie
 
 void PivotTableField::finalizeParentGroupingImport( const Reference< XDataPilotField >& rxBaseDPField,  const PivotCacheField& rBaseCacheField, PivotCacheGroupItemVector& orItemNames )
 {
-    if( maDPFieldName.isEmpty() )    // prevent endless loops if file format is broken
+    if( !maDPFieldName.isEmpty() )    // prevent endless loops if file format is broken
+        return;
+
+    PivotCacheField* pCacheField = mrPivotTable.getCacheField( mnFieldIndex );
+    if( !pCacheField )
+        return;
+
+    // data field can have user defined groupname captions, apply them
+    // if they do
+    IdCaptionPairList captionList;
+    for( const auto& rItem : maItems )
     {
-        if( PivotCacheField* pCacheField = mrPivotTable.getCacheField( mnFieldIndex ) )
-        {
-            // data field can have user defined groupname captions, apply them
-            // if they do
-            IdCaptionPairList captionList;
-            for( const auto& rItem : maItems )
-            {
-                if ( rItem.mnType == XML_data  && rItem.msCaption.getLength() )
-                    captionList.emplace_back( rItem.mnCacheItem, rItem.msCaption );
-            }
-            if ( !captionList.empty() )
-                pCacheField->applyItemCaptions( captionList );
-
-            maDPFieldName = pCacheField->createParentGroupField( rxBaseDPField, rBaseCacheField, orItemNames );
-            pCacheField->setFinalGroupName(maDPFieldName);
-            // on success, try to create nested group fields
-            Reference< XDataPilotField > xDPField = mrPivotTable.getDataPilotField( maDPFieldName );
-            if( xDPField.is() )
-                mrPivotTable.finalizeParentGroupingImport( xDPField, *pCacheField, orItemNames );
-        }
+        if ( rItem.mnType == XML_data  && rItem.msCaption.getLength() )
+            captionList.emplace_back( rItem.mnCacheItem, rItem.msCaption );
     }
+    if ( !captionList.empty() )
+        pCacheField->applyItemCaptions( captionList );
+
+    maDPFieldName = pCacheField->createParentGroupField( rxBaseDPField, rBaseCacheField, orItemNames );
+    pCacheField->setFinalGroupName(maDPFieldName);
+    // on success, try to create nested group fields
+    Reference< XDataPilotField > xDPField = mrPivotTable.getDataPilotField( maDPFieldName );
+    if( xDPField.is() )
+        mrPivotTable.finalizeParentGroupingImport( xDPField, *pCacheField, orItemNames );
 }
 
 void PivotTableField::finalizeImportBasedOnCache( const Reference< XDataPilotDescriptor >& rxDPDesc)
@@ -516,50 +520,50 @@ void PivotTableField::convertPageField( const PTPageFieldModel& rPageField )
     // convert all settings common for row/column/page fields
     Reference< XDataPilotField > xDPField = convertRowColPageField( XML_axisPage );
 
-    if( xDPField.is() )
-    {
-        PropertySet aPropSet( xDPField );
+    if( !xDPField.is() )
+        return;
+
+    PropertySet aPropSet( xDPField );
 
-        // find cache item used as 'selected page'
-        sal_Int32 nCacheItem = -1;
-        if( maModel.mbMultiPageItems )
+    // find cache item used as 'selected page'
+    sal_Int32 nCacheItem = -1;
+    if( maModel.mbMultiPageItems )
+    {
+        // multiple items may be selected
+        OSL_ENSURE( rPageField.mnItem == BIFF12_PTPAGEFIELD_MULTIITEMS, "PivotTableField::convertPageField - unexpected cache item index" );
+        // try to find a single visible item
+        bool bHasMultiItems = false;
+        for( const auto& rItem : maItems )
         {
-            // multiple items may be selected
-            OSL_ENSURE( rPageField.mnItem == BIFF12_PTPAGEFIELD_MULTIITEMS, "PivotTableField::convertPageField - unexpected cache item index" );
-            // try to find a single visible item
-            bool bHasMultiItems = false;
-            for( const auto& rItem : maItems )
+            if( (rItem.mnType == XML_data) && !rItem.mbHidden )
             {
-                if( (rItem.mnType == XML_data) && !rItem.mbHidden )
-                {
-                    bHasMultiItems = nCacheItem >= 0;
-                    nCacheItem = bHasMultiItems ? -1 : rItem.mnCacheItem;
-                }
-
-                if( bHasMultiItems )
-                    break;
+                bHasMultiItems = nCacheItem >= 0;
+                nCacheItem = bHasMultiItems ? -1 : rItem.mnCacheItem;
             }
+
+            if( bHasMultiItems )
+                break;
         }
-        else
-        {
-            // single item may be selected
-            if( (0 <= rPageField.mnItem) && (rPageField.mnItem < static_cast< sal_Int32 >( maItems.size() )) )
-                nCacheItem = maItems[ rPageField.mnItem ].mnCacheItem;
-        }
+    }
+    else
+    {
+        // single item may be selected
+        if( (0 <= rPageField.mnItem) && (rPageField.mnItem < static_cast< sal_Int32 >( maItems.size() )) )
+            nCacheItem = maItems[ rPageField.mnItem ].mnCacheItem;
+    }
 
-        if( nCacheItem >= 0 )
+    if( nCacheItem < 0 )
+        return;
+
+    if( const PivotCacheField* pCacheField = mrPivotTable.getCacheField( mnFieldIndex ) )
+    {
+        if( const PivotCacheItem* pSharedItem = pCacheField->getCacheItem( nCacheItem ) )
         {
-            if( const PivotCacheField* pCacheField = mrPivotTable.getCacheField( mnFieldIndex ) )
-            {
-                if( const PivotCacheItem* pSharedItem = pCacheField->getCacheItem( nCacheItem ) )
-                {
-                    ScDPObject* pDPObj = mrPivotTable.getDPObject();
-                    ScDPSaveData* pSaveData = pDPObj->GetSaveData();
-                    ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(pCacheField->getName());
-                    OUString aSelectedPage = pSharedItem->getFormattedName(*pDim, pDPObj, DateTime(getWorkbookSettings().getNullDate()));
-                    aPropSet.setProperty( PROP_SelectedPage, aSelectedPage );
-                }
-            }
+            ScDPObject* pDPObj = mrPivotTable.getDPObject();
+            ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+            ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(pCacheField->getName());
+            OUString aSelectedPage = pSharedItem->getFormattedName(*pDim, pDPObj, DateTime(getWorkbookSettings().getNullDate()));
+            aPropSet.setProperty( PROP_SelectedPage, aSelectedPage );
         }
     }
 }
@@ -569,75 +573,76 @@ void PivotTableField::convertDataField( const PTDataFieldModel& rDataField )
     OSL_ENSURE( rDataField.mnField == mnFieldIndex, "PivotTableField::convertDataField - wrong field index" );
     OSL_ENSURE( maModel.mbDataField, "PivotTableField::convertDataField - not a data field" );
     Reference< XDataPilotField > xDPField = mrPivotTable.getDataPilotField( maDPFieldName );
-    if( xDPField.is() )
+    if( !xDPField.is() )
+        return;
+
+    PropertySet aPropSet( xDPField );
+
+    // field orientation
+    aPropSet.setProperty( PROP_Orientation, DataPilotFieldOrientation_DATA );
+
+    if (!rDataField.maName.isEmpty())
+        aPropSet.setProperty(PROP_Name, rDataField.maName);
+
+    /*  Field aggregation function. Documentation is a little bit confused
+        about which names to use for the count functions. The name 'count'
+        means 'count all', and 'countNum' means 'count numbers'. On the
+        other hand, for subtotals, 'countA' means 'count all', and 'count'
+        means 'count numbers' (see above). */
+    GeneralFunction eAggFunc = GeneralFunction_SUM;
+    switch( rDataField.mnSubtotal )
     {
-        PropertySet aPropSet( xDPField );
+        case XML_sum:       eAggFunc = GeneralFunction_SUM;         break;
+        case XML_count:     eAggFunc = GeneralFunction_COUNT;       break;
+        case XML_average:   eAggFunc = GeneralFunction_AVERAGE;     break;
+        case XML_max:       eAggFunc = GeneralFunction_MAX;         break;
+        case XML_min:       eAggFunc = GeneralFunction_MIN;         break;
+        case XML_product:   eAggFunc = GeneralFunction_PRODUCT;     break;
+        case XML_countNums: eAggFunc = GeneralFunction_COUNTNUMS;   break;
+        case XML_stdDev:    eAggFunc = GeneralFunction_STDEV;       break;
+        case XML_stdDevp:   eAggFunc = GeneralFunction_STDEVP;      break;
+        case XML_var:       eAggFunc = GeneralFunction_VAR;         break;
+        case XML_varp:      eAggFunc = GeneralFunction_VARP;        break;
+        default:            OSL_FAIL( "PivotTableField::convertDataField - unknown aggregation function" );
+    }
+    aPropSet.setProperty( PROP_Function, eAggFunc );
 
-        // field orientation
-        aPropSet.setProperty( PROP_Orientation, DataPilotFieldOrientation_DATA );
-
-        if (!rDataField.maName.isEmpty())
-            aPropSet.setProperty(PROP_Name, rDataField.maName);
-
-        /*  Field aggregation function. Documentation is a little bit confused
-            about which names to use for the count functions. The name 'count'
-            means 'count all', and 'countNum' means 'count numbers'. On the
-            other hand, for subtotals, 'countA' means 'count all', and 'count'
-            means 'count numbers' (see above). */
-        GeneralFunction eAggFunc = GeneralFunction_SUM;
-        switch( rDataField.mnSubtotal )
-        {
-            case XML_sum:       eAggFunc = GeneralFunction_SUM;         break;
-            case XML_count:     eAggFunc = GeneralFunction_COUNT;       break;
-            case XML_average:   eAggFunc = GeneralFunction_AVERAGE;     break;
-            case XML_max:       eAggFunc = GeneralFunction_MAX;         break;
-            case XML_min:       eAggFunc = GeneralFunction_MIN;         break;
-            case XML_product:   eAggFunc = GeneralFunction_PRODUCT;     break;
-            case XML_countNums: eAggFunc = GeneralFunction_COUNTNUMS;   break;
-            case XML_stdDev:    eAggFunc = GeneralFunction_STDEV;       break;
-            case XML_stdDevp:   eAggFunc = GeneralFunction_STDEVP;      break;
-            case XML_var:       eAggFunc = GeneralFunction_VAR;         break;
-            case XML_varp:      eAggFunc = GeneralFunction_VARP;        break;
-            default:            OSL_FAIL( "PivotTableField::convertDataField - unknown aggregation function" );
-        }
-        aPropSet.setProperty( PROP_Function, eAggFunc );
+    // field reference ('show data as')
+    DataPilotFieldReference aReference;
+    aReference.ReferenceType = DataPilotFieldReferenceType::NONE;
+    switch( rDataField.mnShowDataAs )
+    {
+        case XML_difference:        aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_DIFFERENCE;            break;
+        case XML_percent:           aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE;            break;
+        case XML_percentDiff:       aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE; break;
+        case XML_runTotal:          aReference.ReferenceType = DataPilotFieldReferenceType::RUNNING_TOTAL;              break;
+        case XML_percentOfRow:      aReference.ReferenceType = DataPilotFieldReferenceType::ROW_PERCENTAGE;             break;
+        case XML_percentOfCol:      aReference.ReferenceType = DataPilotFieldReferenceType::COLUMN_PERCENTAGE;          break;
+        case XML_percentOfTotal:    aReference.ReferenceType = DataPilotFieldReferenceType::TOTAL_PERCENTAGE;           break;
+        case XML_index:             aReference.ReferenceType = DataPilotFieldReferenceType::INDEX;                      break;
+    }
+    if( aReference.ReferenceType == DataPilotFieldReferenceType::NONE )
+        return;
 
-        // field reference ('show data as')
-        DataPilotFieldReference aReference;
-        aReference.ReferenceType = DataPilotFieldReferenceType::NONE;
-        switch( rDataField.mnShowDataAs )
-        {
-            case XML_difference:        aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_DIFFERENCE;            break;
-            case XML_percent:           aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE;            break;
-            case XML_percentDiff:       aReference.ReferenceType = DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE; break;
-            case XML_runTotal:          aReference.ReferenceType = DataPilotFieldReferenceType::RUNNING_TOTAL;              break;
-            case XML_percentOfRow:      aReference.ReferenceType = DataPilotFieldReferenceType::ROW_PERCENTAGE;             break;
-            case XML_percentOfCol:      aReference.ReferenceType = DataPilotFieldReferenceType::COLUMN_PERCENTAGE;          break;
-            case XML_percentOfTotal:    aReference.ReferenceType = DataPilotFieldReferenceType::TOTAL_PERCENTAGE;           break;
-            case XML_index:             aReference.ReferenceType = DataPilotFieldReferenceType::INDEX;                      break;
-        }
-        if( aReference.ReferenceType != DataPilotFieldReferenceType::NONE )
-        {
-            if( const PivotCacheField* pCacheField = mrPivotTable.getCacheField( rDataField.mnBaseField ) )
-            {
-                aReference.ReferenceField = pCacheField->getName();
-                switch( rDataField.mnBaseItem )
-                {
-                    case OOX_PT_PREVIOUS_ITEM:
-                        aReference.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
-                    break;
-                    case OOX_PT_NEXT_ITEM:
-                        aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
-                    break;
-                    default:
-                        aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
-                        if( const PivotCacheItem* pCacheItem = pCacheField->getCacheItem( rDataField.mnBaseItem ) )
-                            aReference.ReferenceItemName = pCacheItem->getName();
-                }
-                aPropSet.setProperty( PROP_Reference, aReference );
-            }
-        }
+    const PivotCacheField* pCacheField = mrPivotTable.getCacheField( rDataField.mnBaseField );
+    if( !pCacheField )
+        return;
+
+    aReference.ReferenceField = pCacheField->getName();
+    switch( rDataField.mnBaseItem )
+    {
+        case OOX_PT_PREVIOUS_ITEM:
+            aReference.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
+        break;
+        case OOX_PT_NEXT_ITEM:
+            aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
+        break;
+        default:
+            aReference.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
+            if( const PivotCacheItem* pCacheItem = pCacheField->getCacheItem( rDataField.mnBaseItem ) )
+                aReference.ReferenceItemName = pCacheItem->getName();
     }
+    aPropSet.setProperty( PROP_Reference, aReference );
 }
 
 // private --------------------------------------------------------------------
@@ -880,19 +885,19 @@ void PivotTableFilter::importTop10Filter( SequenceInputStream& rStrm )
 void PivotTableFilter::finalizeImport()
 {
     // only simple top10 filter supported
-    if( maModel.mnType == XML_count )
+    if( maModel.mnType != XML_count )
+        return;
+
+    PropertySet aPropSet( mrPivotTable.getDataPilotField( maModel.mnField ) );
+    if( aPropSet.is() )
     {
-        PropertySet aPropSet( mrPivotTable.getDataPilotField( maModel.mnField ) );
-        if( aPropSet.is() )
-        {
-            DataPilotFieldAutoShowInfo aAutoShowInfo;
-            aAutoShowInfo.IsEnabled = true;
-            aAutoShowInfo.ShowItemsMode = maModel.mbTopFilter ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
-            aAutoShowInfo.ItemCount = getLimitedValue< sal_Int32, double >( maModel.mfValue, 0, SAL_MAX_INT32 );
-            if( const PivotCacheField* pCacheField = mrPivotTable.getCacheFieldOfDataField( maModel.mnMeasureField ) )
-                aAutoShowInfo.DataField = pCacheField->getName();
-            aPropSet.setProperty( PROP_AutoShowInfo, aAutoShowInfo );
-        }
+        DataPilotFieldAutoShowInfo aAutoShowInfo;
+        aAutoShowInfo.IsEnabled = true;
+        aAutoShowInfo.ShowItemsMode = maModel.mbTopFilter ? DataPilotFieldShowItemsMode::FROM_TOP : DataPilotFieldShowItemsMode::FROM_BOTTOM;
+        aAutoShowInfo.ItemCount = getLimitedValue< sal_Int32, double >( maModel.mfValue, 0, SAL_MAX_INT32 );
+        if( const PivotCacheField* pCacheField = mrPivotTable.getCacheFieldOfDataField( maModel.mnMeasureField ) )
+            aAutoShowInfo.DataField = pCacheField->getName();
+        aPropSet.setProperty( PROP_AutoShowInfo, aAutoShowInfo );
     }
 }
 
@@ -1199,116 +1204,116 @@ PivotTableFilter& PivotTable::createTableFilter()
 
 void PivotTable::finalizeImport()
 {
-    if( getAddressConverter().validateCellRange( maLocationModel.maRange, true, true ) )
+    if( !getAddressConverter().validateCellRange( maLocationModel.maRange, true, true ) )
+        return;
+
+    mpPivotCache = getPivotCaches().importPivotCacheFragment( maDefModel.mnCacheId );
+    if( !(mpPivotCache && mpPivotCache->isValidDataSource() && !maDefModel.maName.isEmpty()) )
+        return;
+
+    // clear destination area of the original pivot table
+    try
+    {
+        Reference< XSheetOperation > xSheetOp( getCellRangeFromDoc( maLocationModel.maRange ), UNO_QUERY_THROW );
+        using namespace ::com::sun::star::sheet::CellFlags;
+        xSheetOp->clearContents( VALUE | DATETIME | STRING | FORMULA | HARDATTR | STYLES | EDITATTR | FORMATTED );
+    }
+    catch( Exception& )
     {
-        mpPivotCache = getPivotCaches().importPivotCacheFragment( maDefModel.mnCacheId );
-        if( mpPivotCache && mpPivotCache->isValidDataSource() && !maDefModel.maName.isEmpty() )
+    }
+
+    try
+    {
+        // create a new data pilot descriptor based on the source data
+        Reference< XDataPilotTablesSupplier > xDPTablesSupp( getSheetFromDoc( maLocationModel.maRange.aStart.Tab() ), UNO_QUERY_THROW );
+        Reference< XDataPilotTables > xDPTables( xDPTablesSupp->getDataPilotTables(), UNO_SET_THROW );
+        mxDPDescriptor.set( xDPTables->createDataPilotDescriptor(), UNO_SET_THROW );
+        ScRange aRange = mpPivotCache->getSourceRange();
+        CellRangeAddress aCellRangeAddress( aRange.aStart.Tab(),
+                                            aRange.aStart.Col(), aRange.aStart.Row(),
+                                            aRange.aEnd.Col(), aRange.aEnd.Row() );
+        mxDPDescriptor->setSourceRange( aCellRangeAddress );
+        mxDPDescriptor->setTag( maDefModel.maTag );
+
+        // TODO: This is a hack. Eventually we need to convert the whole thing to the internal API.
+        auto pImpl = comphelper::getUnoTunnelImplementation<ScDataPilotDescriptorBase>(mxDPDescriptor);
+        if (!pImpl)
+            return;
+
+        mpDPObject = pImpl->GetDPObject();
+        if (!mpDPObject)
+            return;
+
+        // global data pilot properties
+        PropertySet aDescProp( mxDPDescriptor );
+        aDescProp.setProperty( PROP_ColumnGrand, maDefModel.mbColGrandTotals );
+        aDescProp.setProperty( PROP_RowGrand, maDefModel.mbRowGrandTotals );
+        aDescProp.setProperty( PROP_ShowFilterButton, false );
+        aDescProp.setProperty( PROP_DrillDownOnDoubleClick, maDefModel.mbEnableDrill );
+
+        // finalize all fields, this finds field names and creates grouping fields
+        finalizeFieldsImport();
+
+        // all row fields
+        for( const auto& rRowField : maRowFields )
+            if( PivotTableField* pField = getTableField( rRowField ) )
+                pField->convertRowField();
+
+        // all column fields
+        for( const auto& rColField : maColFields )
+            if( PivotTableField* pField = getTableField( rColField ) )
+                pField->convertColField();
+
+        // all page fields
+        for( const auto& rPageField : maPageFields )
+            if( PivotTableField* pField = getTableField( rPageField.mnField ) )
+                pField->convertPageField( rPageField );
+
+        // all hidden fields
+        ::std::set< sal_Int32 > aVisFields;
+        aVisFields.insert( maRowFields.begin(), maRowFields.end() );
+        aVisFields.insert( maColFields.begin(), maColFields.end() );
+        for( const auto& rPageField : maPageFields )
+            aVisFields.insert( rPageField.mnField );
+        sal_Int32 nIndex = 0;
+        for( auto& rxField : maFields )
         {
-            // clear destination area of the original pivot table
-            try
-            {
-                Reference< XSheetOperation > xSheetOp( getCellRangeFromDoc( maLocationModel.maRange ), UNO_QUERY_THROW );
-                using namespace ::com::sun::star::sheet::CellFlags;
-                xSheetOp->clearContents( VALUE | DATETIME | STRING | FORMULA | HARDATTR | STYLES | EDITATTR | FORMATTED );
-            }
-            catch( Exception& )
-            {
-            }
+            if( aVisFields.count( nIndex ) == 0 )
+                rxField->convertHiddenField();
+            ++nIndex;
+        }
 
-            try
+        // all data fields
+        for( auto& rDataField : maDataFields )
+        {
+            if( const PivotCacheField* pCacheField = getCacheField( rDataField.mnField  ) )
             {
-                // create a new data pilot descriptor based on the source data
-                Reference< XDataPilotTablesSupplier > xDPTablesSupp( getSheetFromDoc( maLocationModel.maRange.aStart.Tab() ), UNO_QUERY_THROW );
-                Reference< XDataPilotTables > xDPTables( xDPTablesSupp->getDataPilotTables(), UNO_SET_THROW );
-                mxDPDescriptor.set( xDPTables->createDataPilotDescriptor(), UNO_SET_THROW );
-                ScRange aRange = mpPivotCache->getSourceRange();
-                CellRangeAddress aCellRangeAddress( aRange.aStart.Tab(),
-                                                    aRange.aStart.Col(), aRange.aStart.Row(),
-                                                    aRange.aEnd.Col(), aRange.aEnd.Row() );
-                mxDPDescriptor->setSourceRange( aCellRangeAddress );
-                mxDPDescriptor->setTag( maDefModel.maTag );
-
-                // TODO: This is a hack. Eventually we need to convert the whole thing to the internal API.
-                auto pImpl = comphelper::getUnoTunnelImplementation<ScDataPilotDescriptorBase>(mxDPDescriptor);
-                if (!pImpl)
-                    return;
-
-                mpDPObject = pImpl->GetDPObject();
-                if (!mpDPObject)
-                    return;
-
-                // global data pilot properties
-                PropertySet aDescProp( mxDPDescriptor );
-                aDescProp.setProperty( PROP_ColumnGrand, maDefModel.mbColGrandTotals );
-                aDescProp.setProperty( PROP_RowGrand, maDefModel.mbRowGrandTotals );
-                aDescProp.setProperty( PROP_ShowFilterButton, false );
-                aDescProp.setProperty( PROP_DrillDownOnDoubleClick, maDefModel.mbEnableDrill );
-
-                // finalize all fields, this finds field names and creates grouping fields
-                finalizeFieldsImport();
-
-                // all row fields
-                for( const auto& rRowField : maRowFields )
-                    if( PivotTableField* pField = getTableField( rRowField ) )
-                        pField->convertRowField();
-
-                // all column fields
-                for( const auto& rColField : maColFields )
-                    if( PivotTableField* pField = getTableField( rColField ) )
-                        pField->convertColField();
-
-                // all page fields
-                for( const auto& rPageField : maPageFields )
-                    if( PivotTableField* pField = getTableField( rPageField.mnField ) )
-                        pField->convertPageField( rPageField );
-
-                // all hidden fields
-                ::std::set< sal_Int32 > aVisFields;
-                aVisFields.insert( maRowFields.begin(), maRowFields.end() );
-                aVisFields.insert( maColFields.begin(), maColFields.end() );
-                for( const auto& rPageField : maPageFields )
-                    aVisFields.insert( rPageField.mnField );
-                sal_Int32 nIndex = 0;
-                for( auto& rxField : maFields )
-                {
-                    if( aVisFields.count( nIndex ) == 0 )
-                        rxField->convertHiddenField();
-                    ++nIndex;
-                }
-
-                // all data fields
-                for( auto& rDataField : maDataFields )
-                {
-                    if( const PivotCacheField* pCacheField = getCacheField( rDataField.mnField  ) )
-                    {
-                        if ( pCacheField-> getGroupBaseField() != -1 )
-                            rDataField.mnField = pCacheField-> getGroupBaseField();
-                    }
-                    if( PivotTableField* pField = getTableField( rDataField.mnField ) )
-                        pField->convertDataField( rDataField );
-                }
+                if ( pCacheField-> getGroupBaseField() != -1 )
+                    rDataField.mnField = pCacheField-> getGroupBaseField();
+            }
+            if( PivotTableField* pField = getTableField( rDataField.mnField ) )
+                pField->convertDataField( rDataField );
+        }
 
-                // filters
-                maFilters.forEachMem( &PivotTableFilter::finalizeImport );
+        // filters
+        maFilters.forEachMem( &PivotTableFilter::finalizeImport );
 
-                // calculate base position of table
-                CellAddress aPos( maLocationModel.maRange.aStart.Tab(), maLocationModel.maRange.aStart.Col(), maLocationModel.maRange.aStart.Row() );
-                /*  If page fields exist, include them into the destination
-                    area (they are excluded in Excel). Add an extra blank row. */
-                if( !maPageFields.empty() )
-                    aPos.Row = ::std::max< sal_Int32 >( static_cast< sal_Int32 >( aPos.Row - maPageFields.size() - 1 ), 0 );
+        // calculate base position of table
+        CellAddress aPos( maLocationModel.maRange.aStart.Tab(), maLocationModel.maRange.aStart.Col(), maLocationModel.maRange.aStart.Row() );
+        /*  If page fields exist, include them into the destination
+            area (they are excluded in Excel). Add an extra blank row. */
+        if( !maPageFields.empty() )
+            aPos.Row = ::std::max< sal_Int32 >( static_cast< sal_Int32 >( aPos.Row - maPageFields.size() - 1 ), 0 );
 
-                // save interop grab bag
-                mpDPObject->PutInteropGrabBag(std::move(maInteropGrabBag));
+        // save interop grab bag
+        mpDPObject->PutInteropGrabBag(std::move(maInteropGrabBag));
 
-                // insert the DataPilot table into the sheet
-                xDPTables->insertNewByName( maDefModel.maName, aPos, mxDPDescriptor );
-            }
-            catch( Exception& )
-            {
-                OSL_FAIL( "PivotTable::finalizeImport - exception while creating the DataPilot table" );
-            }
-        }
+        // insert the DataPilot table into the sheet
+        xDPTables->insertNewByName( maDefModel.maName, aPos, mxDPDescriptor );
+    }
+    catch( Exception& )
+    {
+        OSL_FAIL( "PivotTable::finalizeImport - exception while creating the DataPilot table" );
     }
 }
 
diff --git a/sc/source/filter/oox/querytablebuffer.cxx b/sc/source/filter/oox/querytablebuffer.cxx
index 268d7a929629..fc1110406dd8 100644
--- a/sc/source/filter/oox/querytablebuffer.cxx
+++ b/sc/source/filter/oox/querytablebuffer.cxx
@@ -214,52 +214,52 @@ void QueryTable::finalizeImport()
 {
     ConnectionRef xConnection = getConnections().getConnection( maModel.mnConnId );
     OSL_ENSURE( xConnection, "QueryTable::finalizeImport - missing connection object" );
-    if( xConnection && (xConnection->getConnectionType() == BIFF12_CONNECTION_HTML) )
+    if( !(xConnection && (xConnection->getConnectionType() == BIFF12_CONNECTION_HTML)) )
+        return;
+
+    // check that valid web query properties exist
+    const WebPrModel* pWebPr = xConnection->getModel().mxWebPr.get();
+    if( !(pWebPr && !pWebPr->mbXml) )
+        return;
+
+    OUString aFileUrl = getBaseFilter().getAbsoluteUrl( pWebPr->maUrl );
+    if( aFileUrl.isEmpty() )
+        return;
+
+    // resolve destination cell range (stored as defined name containing the range)
+    OUString aDefName = maModel.maDefName.replace( ' ', '_' ).replace( '-', '_' );
+    DefinedNameRef xDefName = getDefinedNames().getByModelName( aDefName, getSheetIndex() );
+    OSL_ENSURE( xDefName, "QueryTable::finalizeImport - missing defined name" );
+    if( !xDefName )
+        return;
+
+    ScRange aDestRange;
+    bool bIsRange = xDefName->getAbsoluteRange( aDestRange ) && (aDestRange.aStart.Tab() == getSheetIndex());
+    OSL_ENSURE( bIsRange, "QueryTable::finalizeImport - defined name does not contain valid cell range" );
+    if( !(bIsRange && getAddressConverter().checkCellRange( aDestRange, false, true )) )
+        return;
+
+    // find tables mode: entire document, all tables, or specific tables
+    OUString aTables = pWebPr->mbHtmlTables ? lclBuildWebQueryTables( pWebPr->maTables ) : "HTML_all";
+    if( !aTables.isEmpty() ) try
     {
-        // check that valid web query properties exist
-        const WebPrModel* pWebPr = xConnection->getModel().mxWebPr.get();
-        if( pWebPr && !pWebPr->mbXml )
+        PropertySet aDocProps( getDocument() );
+        Reference< XAreaLinks > xAreaLinks( aDocProps.getAnyProperty( PROP_AreaLinks ), UNO_QUERY_THROW );
+        CellAddress aDestPos( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row() );
+        OUString aFilterName = "calc_HTML_WebQuery";
+        OUString aFilterOptions;
+        xAreaLinks->insertAtPosition( aDestPos, aFileUrl, aTables, aFilterName, aFilterOptions );
+        // set refresh interval (convert minutes to seconds)
+        sal_Int32 nRefreshPeriod = xConnection->getModel().mnInterval * 60;
+        if( nRefreshPeriod > 0 )
         {
-            OUString aFileUrl = getBaseFilter().getAbsoluteUrl( pWebPr->maUrl );
-            if( !aFileUrl.isEmpty() )
-            {
-                // resolve destination cell range (stored as defined name containing the range)
-                OUString aDefName = maModel.maDefName.replace( ' ', '_' ).replace( '-', '_' );
-                DefinedNameRef xDefName = getDefinedNames().getByModelName( aDefName, getSheetIndex() );
-                OSL_ENSURE( xDefName, "QueryTable::finalizeImport - missing defined name" );
-                if( xDefName )
-                {
-                    ScRange aDestRange;
-                    bool bIsRange = xDefName->getAbsoluteRange( aDestRange ) && (aDestRange.aStart.Tab() == getSheetIndex());
-                    OSL_ENSURE( bIsRange, "QueryTable::finalizeImport - defined name does not contain valid cell range" );
-                    if( bIsRange && getAddressConverter().checkCellRange( aDestRange, false, true ) )
-                    {
-                        // find tables mode: entire document, all tables, or specific tables
-                        OUString aTables = pWebPr->mbHtmlTables ? lclBuildWebQueryTables( pWebPr->maTables ) : "HTML_all";
-                        if( !aTables.isEmpty() ) try
-                        {
-                            PropertySet aDocProps( getDocument() );
-                            Reference< XAreaLinks > xAreaLinks( aDocProps.getAnyProperty( PROP_AreaLinks ), UNO_QUERY_THROW );
-                            CellAddress aDestPos( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row() );
-                            OUString aFilterName = "calc_HTML_WebQuery";
-                            OUString aFilterOptions;
-                            xAreaLinks->insertAtPosition( aDestPos, aFileUrl, aTables, aFilterName, aFilterOptions );
-                            // set refresh interval (convert minutes to seconds)
-                            sal_Int32 nRefreshPeriod = xConnection->getModel().mnInterval * 60;
-                            if( nRefreshPeriod > 0 )
-                            {
-                                PropertySet aPropSet( lclFindAreaLink( xAreaLinks, aDestRange.aStart, aFileUrl, aTables, aFilterName, aFilterOptions ) );
-                                aPropSet.setProperty( PROP_RefreshPeriod, nRefreshPeriod );
-                            }
-                        }
-                        catch( Exception& )
-                        {
-                        }
-                    }
-                }
-            }
+            PropertySet aPropSet( lclFindAreaLink( xAreaLinks, aDestRange.aStart, aFileUrl, aTables, aFilterName, aFilterOptions ) );
+            aPropSet.setProperty( PROP_RefreshPeriod, nRefreshPeriod );
         }
     }
+    catch( Exception& )
+    {
+    }
 }
 
 QueryTableBuffer::QueryTableBuffer( const WorksheetHelper& rHelper ) :
diff --git a/sc/source/filter/oox/richstring.cxx b/sc/source/filter/oox/richstring.cxx
index c2ea6afe3120..a9d058f75ba5 100644
--- a/sc/source/filter/oox/richstring.cxx
+++ b/sc/source/filter/oox/richstring.cxx
@@ -432,25 +432,25 @@ RichStringPhoneticRef RichString::createPhonetic()
 void RichString::createTextPortions( const OUString& rText, FontPortionModelList& rPortions )
 {
     maTextPortions.clear();
-    if( !rText.isEmpty() )
+    if( rText.isEmpty() )
+        return;
+
+    sal_Int32 nStrLen = rText.getLength();
+    // add leading and trailing string position to ease the following loop
+    if( rPortions.empty() || (rPortions.front().mnPos > 0) )
+        rPortions.insert( rPortions.begin(), FontPortionModel( 0 ) );
+    if( rPortions.back().mnPos < nStrLen )
+        rPortions.push_back( FontPortionModel( nStrLen ) );
+
+    // create all string portions according to the font id vector
+    for( ::std::vector< FontPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
     {
-        sal_Int32 nStrLen = rText.getLength();
-        // add leading and trailing string position to ease the following loop
-        if( rPortions.empty() || (rPortions.front().mnPos > 0) )
-            rPortions.insert( rPortions.begin(), FontPortionModel( 0 ) );
-        if( rPortions.back().mnPos < nStrLen )
-            rPortions.push_back( FontPortionModel( nStrLen ) );
-
-        // create all string portions according to the font id vector
-        for( ::std::vector< FontPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
+        sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
+        if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
         {
-            sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
-            if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
-            {
-                RichStringPortionRef xPortion = createPortion();
-                xPortion->setText( rText.copy( aIt->mnPos, nPortionLen ) );
-                xPortion->setFontId( aIt->mnFontId );
-            }
+            RichStringPortionRef xPortion = createPortion();
+            xPortion->setText( rText.copy( aIt->mnPos, nPortionLen ) );
+            xPortion->setFontId( aIt->mnFontId );
         }
     }
 }
@@ -458,26 +458,26 @@ void RichString::createTextPortions( const OUString& rText, FontPortionModelList
 void RichString::createPhoneticPortions( const OUString& rText, PhoneticPortionModelList& rPortions, sal_Int32 nBaseLen )
 {
     maPhonPortions.clear();
-    if( !rText.isEmpty())
+    if( rText.isEmpty())
+        return;
+
+    sal_Int32 nStrLen = rText.getLength();
+    // no portions - assign phonetic text to entire base text
+    if( rPortions.empty() )
+        rPortions.push_back( PhoneticPortionModel( 0, 0, nBaseLen ) );
+    // add trailing string position to ease the following loop
+    if( rPortions.back().mnPos < nStrLen )
+        rPortions.push_back( PhoneticPortionModel( nStrLen, nBaseLen, 0 ) );
+
+    // create all phonetic portions according to the portions vector
+    for( ::std::vector< PhoneticPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
     {
-        sal_Int32 nStrLen = rText.getLength();
-        // no portions - assign phonetic text to entire base text
-        if( rPortions.empty() )
-            rPortions.push_back( PhoneticPortionModel( 0, 0, nBaseLen ) );
-        // add trailing string position to ease the following loop
-        if( rPortions.back().mnPos < nStrLen )
-            rPortions.push_back( PhoneticPortionModel( nStrLen, nBaseLen, 0 ) );
-
-        // create all phonetic portions according to the portions vector
-        for( ::std::vector< PhoneticPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
+        sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
+        if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
         {
-            sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
-            if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
-            {
-                RichStringPhoneticRef xPhonetic = createPhonetic();
-                xPhonetic->setText( rText.copy( aIt->mnPos, nPortionLen ) );
-                xPhonetic->setBaseRange( aIt->mnBasePos, aIt->mnBasePos + aIt->mnBaseLen );
-            }
+            RichStringPhoneticRef xPhonetic = createPhonetic();
+            xPhonetic->setText( rText.copy( aIt->mnPos, nPortionLen ) );
+            xPhonetic->setBaseRange( aIt->mnBasePos, aIt->mnBasePos + aIt->mnBaseLen );
         }
     }
 }
diff --git a/sc/source/filter/oox/scenariobuffer.cxx b/sc/source/filter/oox/scenariobuffer.cxx
index e52423ce6e01..7c45c822da27 100644
--- a/sc/source/filter/oox/scenariobuffer.cxx
+++ b/sc/source/filter/oox/scenariobuffer.cxx
@@ -109,7 +109,10 @@ void Scenario::finalizeImport()
         if( !rCell.mbDeleted && rAddrConv.checkCellAddress( rCell.maPos, true ) )
             aRanges.push_back( ScRange(rCell.maPos, rCell.maPos) );
 
-    if( !aRanges.empty() && !maModel.maName.isEmpty() ) try
+    if( aRanges.empty() || maModel.maName.isEmpty() )
+        return;
+
+    try
     {
         /*  Find an unused name for the scenario (Calc stores scenario data in
             hidden sheets named after the scenario following the base sheet). */
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index fd4b760c41be..de1d2c76f3c9 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -325,25 +325,25 @@ typedef std::pair<sal_Int32, sal_Int32> FormatKeyPair;
 static void addIfNotInMyMap( const StylesBuffer& rStyles, std::map< FormatKeyPair, ScRangeList >& rMap, sal_Int32 nXfId, sal_Int32 nFormatId, const ScRangeList& rRangeList )
 {
     Xf* pXf1 = rStyles.getCellXf( nXfId ).get();
-    if ( pXf1 )
+    if ( !pXf1 )
+        return;
+
+    auto it = std::find_if(rMap.begin(), rMap.end(),
+        [&nFormatId, &rStyles, &pXf1](const std::pair<FormatKeyPair, ScRangeList>& rEntry) {
+            if (rEntry.first.second != nFormatId)
+                return false;
+            Xf* pXf2 = rStyles.getCellXf( rEntry.first.first ).get();
+            return *pXf1 == *pXf2;
+        });
+    if (it != rMap.end()) // already exists
     {
-        auto it = std::find_if(rMap.begin(), rMap.end(),
-            [&nFormatId, &rStyles, &pXf1](const std::pair<FormatKeyPair, ScRangeList>& rEntry) {
-                if (rEntry.first.second != nFormatId)
-                    return false;
-                Xf* pXf2 = rStyles.getCellXf( rEntry.first.first ).get();
-                return *pXf1 == *pXf2;
-            });
-        if (it != rMap.end()) // already exists
-        {
-            // add ranges from the rangelist to the existing rangelist for the
-            // matching style ( should we check if they overlap ? )
-            for (size_t i = 0, nSize = rRangeList.size(); i < nSize; ++i)
-                it->second.push_back(rRangeList[i]);
-            return;
-        }
-        rMap[ FormatKeyPair( nXfId, nFormatId ) ] = rRangeList;
+        // add ranges from the rangelist to the existing rangelist for the
+        // matching style ( should we check if they overlap ? )
+        for (size_t i = 0, nSize = rRangeList.size(); i < nSize; ++i)
+            it->second.push_back(rRangeList[i]);
+        return;
     }
+    rMap[ FormatKeyPair( nXfId, nFormatId ) ] = rRangeList;
 }
 
 void SheetDataBuffer::addColXfStyle( sal_Int32 nXfId, sal_Int32 nFormatId, const ScRange& rAddress, bool bProcessRowRange )
@@ -657,66 +657,67 @@ void SheetDataBuffer::finalizeTableOperation( const ScRange& rRange, const DataT
 
 void SheetDataBuffer::setCellFormat( const CellModel& rModel )
 {
-    if( rModel.mnXfId >= 0 )
+    if( rModel.mnXfId < 0 )
+        return;
+
+    ScRangeList& rRangeList = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, -1 ) ];
+    ScRange* pLastRange = rRangeList.empty() ? nullptr : &rRangeList.back();
+    /* The xlsx sheet data contains row wise information.
+     * It is sufficient to check if the row range size is one
+     */
+    if (!rRangeList.empty() &&
+        *pLastRange == rModel.maCellAddr)
+        ; // do nothing - this probably bad data
+    else if (!rRangeList.empty() &&
+        pLastRange->aStart.Tab() == rModel.maCellAddr.Tab() &&
+        pLastRange->aStart.Row() == pLastRange->aEnd.Row() &&
+        pLastRange->aStart.Row() == rModel.maCellAddr.Row() &&
+        pLastRange->aEnd.Col() + 1 == rModel.maCellAddr.Col())
     {
-        ScRangeList& rRangeList = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, -1 ) ];
-        ScRange* pLastRange = rRangeList.empty() ? nullptr : &rRangeList.back();
-        /* The xlsx sheet data contains row wise information.
-         * It is sufficient to check if the row range size is one
-         */
-        if (!rRangeList.empty() &&
-            *pLastRange == rModel.maCellAddr)
-            ; // do nothing - this probably bad data
-        else if (!rRangeList.empty() &&
-            pLastRange->aStart.Tab() == rModel.maCellAddr.Tab() &&
-            pLastRange->aStart.Row() == pLastRange->aEnd.Row() &&
-            pLastRange->aStart.Row() == rModel.maCellAddr.Row() &&
-            pLastRange->aEnd.Col() + 1 == rModel.maCellAddr.Col())
-        {
-            pLastRange->aEnd.IncCol();       // Expand Column
-        }
-        else
-        {
-            rRangeList.push_back(ScRange(rModel.maCellAddr));
-            pLastRange = &rRangeList.back();
-        }
+        pLastRange->aEnd.IncCol();       // Expand Column
+    }
+    else
+    {
+        rRangeList.push_back(ScRange(rModel.maCellAddr));
+        pLastRange = &rRangeList.back();
+    }
 
-        if (rRangeList.size() > 1)
+    if (rRangeList.size() > 1)
+    {
+        for (size_t i = rRangeList.size() - 1; i != 0; --i)
         {
-            for (size_t i = rRangeList.size() - 1; i != 0; --i)
-            {
-                ScRange& rMergeRange = rRangeList[i - 1];
-                if (pLastRange->aStart.Tab() != rMergeRange.aStart.Tab())
-                    break;
+            ScRange& rMergeRange = rRangeList[i - 1];
+            if (pLastRange->aStart.Tab() != rMergeRange.aStart.Tab())
+                break;
 
-                /* Try to merge this with the previous range */
-                if (pLastRange->aStart.Row() == (rMergeRange.aEnd.Row() + 1) &&
-                    pLastRange->aStart.Col() == rMergeRange.aStart.Col() &&
-                    pLastRange->aEnd.Col() == rMergeRange.aEnd.Col())
-                {
-                    rMergeRange.aEnd.SetRow(pLastRange->aEnd.Row());
-                    rRangeList.Remove(rRangeList.size() - 1);
-                    break;
-                }
-                else if (pLastRange->aStart.Row() > (rMergeRange.aEnd.Row() + 1))
-                    break; // Un-necessary to check with any other rows
-            }
-        }
-        // update merged ranges for 'center across selection' and 'fill'
-        if( const Xf* pXf = getStyles().getCellXf( rModel.mnXfId ).get() )
-        {
-            sal_Int32 nHorAlign = pXf->getAlignment().getModel().mnHorAlign;
-            if( (nHorAlign == XML_centerContinuous) || (nHorAlign == XML_fill) )
+            /* Try to merge this with the previous range */
+            if (pLastRange->aStart.Row() == (rMergeRange.aEnd.Row() + 1) &&
+                pLastRange->aStart.Col() == rMergeRange.aStart.Col() &&
+                pLastRange->aEnd.Col() == rMergeRange.aEnd.Col())
             {
-                /*  start new merged range, if cell is not empty (#108781#),
-                    or try to expand last range with empty cell */
-                if( rModel.mnCellType != XML_TOKEN_INVALID )
-                    maCenterFillRanges.emplace_back( rModel.maCellAddr, nHorAlign );
-                else if( !maCenterFillRanges.empty() )
-                    maCenterFillRanges.rbegin()->tryExpand( rModel.maCellAddr, nHorAlign );
+                rMergeRange.aEnd.SetRow(pLastRange->aEnd.Row());
+                rRangeList.Remove(rRangeList.size() - 1);
+                break;
             }
+            else if (pLastRange->aStart.Row() > (rMergeRange.aEnd.Row() + 1))
+                break; // Un-necessary to check with any other rows
         }
     }
+    // update merged ranges for 'center across selection' and 'fill'
+    const Xf* pXf = getStyles().getCellXf( rModel.mnXfId ).get();
+    if( !pXf )
+        return;
+
+    sal_Int32 nHorAlign = pXf->getAlignment().getModel().mnHorAlign;
+    if( (nHorAlign == XML_centerContinuous) || (nHorAlign == XML_fill) )
+    {
+        /*  start new merged range, if cell is not empty (#108781#),
+            or try to expand last range with empty cell */
+        if( rModel.mnCellType != XML_TOKEN_INVALID )
+            maCenterFillRanges.emplace_back( rModel.maCellAddr, nHorAlign );
+        else if( !maCenterFillRanges.empty() )
+            maCenterFillRanges.rbegin()->tryExpand( rModel.maCellAddr, nHorAlign );
+    }
 }
 
 static void lcl_SetBorderLine( ScDocument& rDoc, const ScRange& rRange, SCTAB nScTab, SvxBoxItemLine nLine )
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index 242192f67350..c2b47a130bf4 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -122,92 +122,92 @@ void SheetDataContext::onCharacters( const OUString& rChars )
 
 void SheetDataContext::onEndElement()
 {
-    if( getCurrentElement() == XLS_TOKEN( c ) )
-    {
-        // try to create a formula cell
-        if( mbHasFormula ) switch( maFmlaData.mnFormulaType )
-        {
-            // will buffer formulas but need to
-            // a) need to set format first
-            // :/
-            case XML_normal:
-                setCellFormula( maCellData.maCellAddr, maFormulaStr );
-                mrSheetData.setCellFormat( maCellData );
+    if( getCurrentElement() != XLS_TOKEN( c ) )
+        return;
 
-                // If a number cell has some preloaded value, stick it into the buffer
-                // but do this only for real cell formulas (not array, shared etc.)
-                if (!maCellValue.isEmpty())
-                    setCellFormulaValue(maCellData.maCellAddr, maCellValue, maCellData.mnCellType);
-                break;
-
-            case XML_shared:
-                if( maFmlaData.mnSharedId >= 0 )
-                {
-                    if( mbValidRange && maFmlaData.isValidSharedRef( maCellData.maCellAddr ) )
-                        createSharedFormulaMapEntry(maCellData.maCellAddr, maFmlaData.mnSharedId, maFormulaStr);
-
-                    setCellFormula(maCellData.maCellAddr, maFmlaData.mnSharedId, maCellValue, maCellData.mnCellType);
-                    mrSheetData.setCellFormat( maCellData );
-                }
-                else
-                    // no success, set plain cell value and formatting below
-                    mbHasFormula = false;
-            break;
-            case XML_array:
-                if( mbValidRange && maFmlaData.isValidArrayRef( maCellData.maCellAddr ) )
-                {
-                    setCellArrayFormula( maFmlaData.maFormulaRef, maCellData.maCellAddr, maFormulaStr );
-                }
-                // set cell formatting, but do not set result as cell value
-                mrSheetData.setBlankCell( maCellData );
-            break;
-            case XML_dataTable:
-                if( mbValidRange )
-                    mrSheetData.createTableOperation( maFmlaData.maFormulaRef, maTableData );
-                // set cell formatting, but do not set result as cell value
-                mrSheetData.setBlankCell( maCellData );
+    // try to create a formula cell
+    if( mbHasFormula ) switch( maFmlaData.mnFormulaType )
+    {
+        // will buffer formulas but need to
+        // a) need to set format first
+        // :/
+        case XML_normal:
+            setCellFormula( maCellData.maCellAddr, maFormulaStr );
+            mrSheetData.setCellFormat( maCellData );
+
+            // If a number cell has some preloaded value, stick it into the buffer
+            // but do this only for real cell formulas (not array, shared etc.)
+            if (!maCellValue.isEmpty())
+                setCellFormulaValue(maCellData.maCellAddr, maCellValue, maCellData.mnCellType);
             break;
-            default:
-                OSL_ENSURE( maFmlaData.mnFormulaType == XML_TOKEN_INVALID, "SheetDataContext::onEndElement - unknown formula type" );
-                mbHasFormula = false;
-        }
 
-        if( !mbHasFormula )
-        {
-            // no formula created: try to set the cell value
-            if( !maCellValue.isEmpty() ) switch( maCellData.mnCellType )
+        case XML_shared:
+            if( maFmlaData.mnSharedId >= 0 )
             {
-                case XML_n:
-                    mrSheetData.setValueCell( maCellData, maCellValue.toDouble() );
-                break;
-                case XML_b:
-                    mrSheetData.setBooleanCell( maCellData, maCellValue.toDouble() != 0.0 );
-                break;
-                case XML_e:
-                    mrSheetData.setErrorCell( maCellData, maCellValue );
-                break;
-                case XML_str:
-                    mrSheetData.setStringCell( maCellData, maCellValue );
-                break;
-                case XML_s:
-                    mrSheetData.setStringCell( maCellData, maCellValue.toInt32() );
-                break;
-                case XML_d:
-                    mrSheetData.setDateCell( maCellData, maCellValue );
-                break;
-            }
-            else if( (maCellData.mnCellType == XML_inlineStr) && mxInlineStr )
-            {
-                mxInlineStr->finalizeImport();
-                mrSheetData.setStringCell( maCellData, mxInlineStr );
+                if( mbValidRange && maFmlaData.isValidSharedRef( maCellData.maCellAddr ) )
+                    createSharedFormulaMapEntry(maCellData.maCellAddr, maFmlaData.mnSharedId, maFormulaStr);
+
+                setCellFormula(maCellData.maCellAddr, maFmlaData.mnSharedId, maCellValue, maCellData.mnCellType);
+                mrSheetData.setCellFormat( maCellData );
             }
             else
+                // no success, set plain cell value and formatting below
+                mbHasFormula = false;
+        break;
+        case XML_array:
+            if( mbValidRange && maFmlaData.isValidArrayRef( maCellData.maCellAddr ) )
             {
-                // empty cell, update cell type
-                maCellData.mnCellType = XML_TOKEN_INVALID;
-                mrSheetData.setBlankCell( maCellData );
+                setCellArrayFormula( maFmlaData.maFormulaRef, maCellData.maCellAddr, maFormulaStr );
             }
-        }
+            // set cell formatting, but do not set result as cell value
+            mrSheetData.setBlankCell( maCellData );
+        break;
+        case XML_dataTable:
+            if( mbValidRange )
+                mrSheetData.createTableOperation( maFmlaData.maFormulaRef, maTableData );
+            // set cell formatting, but do not set result as cell value
+            mrSheetData.setBlankCell( maCellData );
+        break;
+        default:
+            OSL_ENSURE( maFmlaData.mnFormulaType == XML_TOKEN_INVALID, "SheetDataContext::onEndElement - unknown formula type" );
+            mbHasFormula = false;
+    }
+
+    if( mbHasFormula )
+        return;
+
+    // no formula created: try to set the cell value
+    if( !maCellValue.isEmpty() ) switch( maCellData.mnCellType )
+    {
+        case XML_n:
+            mrSheetData.setValueCell( maCellData, maCellValue.toDouble() );
+        break;
+        case XML_b:
+            mrSheetData.setBooleanCell( maCellData, maCellValue.toDouble() != 0.0 );
+        break;
+        case XML_e:
+            mrSheetData.setErrorCell( maCellData, maCellValue );
+        break;
+        case XML_str:
+            mrSheetData.setStringCell( maCellData, maCellValue );
+        break;
+        case XML_s:
+            mrSheetData.setStringCell( maCellData, maCellValue.toInt32() );
+        break;
+        case XML_d:
+            mrSheetData.setDateCell( maCellData, maCellValue );
+        break;
+    }
+    else if( (maCellData.mnCellType == XML_inlineStr) && mxInlineStr )
+    {
+        mxInlineStr->finalizeImport();
+        mrSheetData.setStringCell( maCellData, mxInlineStr );
+    }
+    else
+    {
+        // empty cell, update cell type
+        maCellData.mnCellType = XML_TOKEN_INVALID;
+        mrSheetData.setBlankCell( maCellData );
     }
 }
 
@@ -546,20 +546,20 @@ void SheetDataContext::importArray( SequenceInputStream& rStrm )
 
 void SheetDataContext::importDataTable( SequenceInputStream& rStrm )
 {
-    if( readFormulaRef( rStrm ) )
-    {
-        BinAddress aRef1, aRef2;
-        sal_uInt8 nFlags;
-        rStrm >> aRef1 >> aRef2;
-        nFlags = rStrm.readuChar();
-        maTableData.maRef1        = FormulaProcessorBase::generateAddress2dString( aRef1, false );
-        maTableData.maRef2        = FormulaProcessorBase::generateAddress2dString( aRef2, false );
-        maTableData.mbRowTable    = getFlag( nFlags, BIFF12_DATATABLE_ROW );
-        maTableData.mb2dTable     = getFlag( nFlags, BIFF12_DATATABLE_2D );
-        maTableData.mbRef1Deleted = getFlag( nFlags, BIFF12_DATATABLE_REF1DEL );
-        maTableData.mbRef2Deleted = getFlag( nFlags, BIFF12_DATATABLE_REF2DEL );
-        mrSheetData.createTableOperation( maFmlaData.maFormulaRef, maTableData );
-    }
+    if( !readFormulaRef( rStrm ) )
+        return;
+
+    BinAddress aRef1, aRef2;
+    sal_uInt8 nFlags;
+    rStrm >> aRef1 >> aRef2;
+    nFlags = rStrm.readuChar();
+    maTableData.maRef1        = FormulaProcessorBase::generateAddress2dString( aRef1, false );
+    maTableData.maRef2        = FormulaProcessorBase::generateAddress2dString( aRef2, false );
+    maTableData.mbRowTable    = getFlag( nFlags, BIFF12_DATATABLE_ROW );
+    maTableData.mb2dTable     = getFlag( nFlags, BIFF12_DATATABLE_2D );
+    maTableData.mbRef1Deleted = getFlag( nFlags, BIFF12_DATATABLE_REF1DEL );
+    maTableData.mbRef2Deleted = getFlag( nFlags, BIFF12_DATATABLE_REF2DEL );
+    mrSheetData.createTableOperation( maFmlaData.maFormulaRef, maTableData );
 }
 
 void SheetDataContext::importSharedFmla( SequenceInputStream& rStrm )
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 3ec09651ac11..89bc91dc17e4 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -782,51 +782,51 @@ void Font::finalizeImport()
     }
 
     // supported script types
-    if( maUsedFlags.mbNameUsed )
-    {
-        PropertySet aDocProps( getDocument() );
-        Reference< XDevice > xDevice( aDocProps.getAnyProperty( PROP_ReferenceDevice ), UNO_QUERY );
-        if( xDevice.is() )
-        {
-            Reference< XFont2 > xFont( xDevice->getFont( maApiData.maDesc ), UNO_QUERY );
-            if( xFont.is() )
-            {
-                // #91658# CJK fonts
-                bool bHasAsian =
-                    xFont->hasGlyphs( OUString( u'\x3041' ) ) ||    // 3040-309F: Hiragana
-                    xFont->hasGlyphs( OUString( u'\x30A1' ) ) ||    // 30A0-30FF: Katakana
-                    xFont->hasGlyphs( OUString( u'\x3111' ) ) ||    // 3100-312F: Bopomofo
-                    xFont->hasGlyphs( OUString( u'\x3131' ) ) ||    // 3130-318F: Hangul Compatibility Jamo
-                    xFont->hasGlyphs( OUString( u'\x3301' ) ) ||    // 3300-33FF: CJK Compatibility
-                    xFont->hasGlyphs( OUString( u'\x3401' ) ) ||    // 3400-4DBF: CJK Unified Ideographs Extension A
-                    xFont->hasGlyphs( OUString( u'\x4E01' ) ) ||    // 4E00-9FFF: CJK Unified Ideographs
-                    xFont->hasGlyphs( OUString( u'\x7E01' ) ) ||    // 4E00-9FFF: CJK Unified Ideographs
-                    xFont->hasGlyphs( OUString( u'\xA001' ) ) ||    // A001-A48F: Yi Syllables
-                    xFont->hasGlyphs( OUString( u'\xAC01' ) ) ||    // AC00-D7AF: Hangul Syllables
-                    xFont->hasGlyphs( OUString( u'\xCC01' ) ) ||    // AC00-D7AF: Hangul Syllables
-                    xFont->hasGlyphs( OUString( u'\xF901' ) ) ||    // F900-FAFF: CJK Compatibility Ideographs
-                    xFont->hasGlyphs( OUString( u'\xFF71' ) );      // FF00-FFEF: Halfwidth/Fullwidth Forms
-                // #113783# CTL fonts
-                bool bHasCmplx =
-                    xFont->hasGlyphs( OUString( u'\x05D1' ) ) ||    // 0590-05FF: Hebrew
-                    xFont->hasGlyphs( OUString( u'\x0631' ) ) ||    // 0600-06FF: Arabic
-                    xFont->hasGlyphs( OUString( u'\x0721' ) ) ||    // 0700-074F: Syriac
-                    xFont->hasGlyphs( OUString( u'\x0911' ) ) ||    // 0900-0DFF: Indic scripts
-                    xFont->hasGlyphs( OUString( u'\x0E01' ) ) ||    // 0E00-0E7F: Thai
-                    xFont->hasGlyphs( OUString( u'\xFB21' ) ) ||    // FB1D-FB4F: Hebrew Presentation Forms
-                    xFont->hasGlyphs( OUString( u'\xFB51' ) ) ||    // FB50-FDFF: Arabic Presentation Forms-A
-                    xFont->hasGlyphs( OUString( u'\xFE71' ) );      // FE70-FEFF: Arabic Presentation Forms-B
-                // Western fonts
-                bool bHasLatin =
-                    (!bHasAsian && !bHasCmplx) ||
-                    xFont->hasGlyphs( OUString( 'A' ) );
-
-                lclSetFontName( maApiData.maLatinFont, maApiData.maDesc, bHasLatin );
-                lclSetFontName( maApiData.maAsianFont, maApiData.maDesc, bHasAsian );
-                lclSetFontName( maApiData.maCmplxFont, maApiData.maDesc, bHasCmplx );
-            }
-        }
-    }
+    if( !maUsedFlags.mbNameUsed )
+        return;
+
+    PropertySet aDocProps( getDocument() );
+    Reference< XDevice > xDevice( aDocProps.getAnyProperty( PROP_ReferenceDevice ), UNO_QUERY );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list