tdf#48140 replace ApiCellRangeList in xlsx import (2)

Change-Id: I3e609c54f7b21c300944362d27248d92ab69b886
Reviewed-on: https://gerrit.libreoffice.org/33092
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Tested-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
diff --git a/sc/source/filter/inc/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx
index 9884294..7c04971 100644
--- a/sc/source/filter/inc/addressconverter.hxx
+++ b/sc/source/filter/inc/addressconverter.hxx
@@ -554,6 +554,11 @@ public:
                            const BinRangeList& rBinRanges,
                            sal_Int16 nSheet,
                            bool bTrackOverflow );
    void                convertToCellRangeList(
                            ScRangeList& orRanges,
                            const BinRangeList& rBinRanges,
                            sal_Int16 nSheet,
                            bool bTrackOverflow );

private:
    void                initializeMaxPos(
diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx
index 3ff9ad3..a0c7aec 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -184,7 +184,7 @@ typedef std::shared_ptr< CondFormatRule > CondFormatRuleRef;
/** Model for a conditional formatting object. */
struct CondFormatModel
{
    ApiCellRangeList    maRanges;           /// Cell ranges for this conditional format.
    ScRangeList         maRanges;           /// Cell ranges for this conditional format.
    bool                mbPivot;            /// Conditional formatting belongs to pivot table.

    explicit            CondFormatModel();
@@ -210,7 +210,7 @@ public:
    void                finalizeImport();

    /** Returns the cell ranges this conditional formatting belongs to. */
    inline const ApiCellRangeList& getRanges() const { return maModel.maRanges; }
    inline const ScRangeList& getRanges() const { return maModel.maRanges; }

    void                setReadyForFinalize() { mbReadyForFinalize = true; }
private:
diff --git a/sc/source/filter/inc/viewsettings.hxx b/sc/source/filter/inc/viewsettings.hxx
index 1ba44d1..2537fa8 100644
--- a/sc/source/filter/inc/viewsettings.hxx
+++ b/sc/source/filter/inc/viewsettings.hxx
@@ -31,7 +31,7 @@ namespace xls {
struct PaneSelectionModel
{
    ScAddress maActiveCell;  /// Position of active cell (cursor).
    ApiCellRangeList    maSelection;                    /// Selected cell ranges.
    ScRangeList         maSelection;                    /// Selected cell ranges.
    sal_Int32           mnActiveCellId;                 /// Index of active cell in selection list.

    explicit            PaneSelectionModel();
diff --git a/sc/source/filter/oox/addressconverter.cxx b/sc/source/filter/oox/addressconverter.cxx
index ecb4a6b..0a2bd3e 100644
--- a/sc/source/filter/oox/addressconverter.cxx
+++ b/sc/source/filter/oox/addressconverter.cxx
@@ -532,6 +532,15 @@ void AddressConverter::convertToCellRangeList( ApiCellRangeList& orRanges,
            orRanges.push_back( aRange );
}

void AddressConverter::convertToCellRangeList( ScRangeList& orRanges,
        const BinRangeList& rBinRanges, sal_Int16 nSheet, bool bTrackOverflow )
{
    ScRange aRange;
    for( ::std::vector< BinRange >::const_iterator aIt = rBinRanges.begin(), aEnd = rBinRanges.end(); aIt != aEnd; ++aIt )
        if( convertToCellRange( aRange, *aIt, nSheet, true, bTrackOverflow ) )
            orRanges.Append( aRange );
}

// private --------------------------------------------------------------------

void AddressConverter::ControlCharacters::set(
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 2779e68..ede0d46 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -20,7 +20,6 @@
#include "condformatbuffer.hxx"

#include <com/sun/star/sheet/ConditionOperator2.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <rtl/ustrbuf.hxx>
#include <osl/diagnose.h>
#include <svl/intitem.hxx>
@@ -39,7 +38,6 @@
#include "colorscale.hxx"
#include "conditio.hxx"
#include "document.hxx"
#include "convuno.hxx"
#include "docfunc.hxx"
#include "tokenarray.hxx"
#include "tokenuno.hxx"
@@ -49,7 +47,6 @@ namespace xls {

using namespace ::com::sun::star::sheet;
using namespace ::com::sun::star::style;
using namespace ::com::sun::star::table;
using namespace ::com::sun::star::uno;

namespace {
@@ -473,7 +470,7 @@ void CondFormatRule::importCfRule( const AttributeList& rAttribs )

void CondFormatRule::appendFormula( const OUString& rFormula )
{
    ScAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
    ScAddress aBaseAddr = mrCondFormat.getRanges().GetTopLeftCorner();
    ApiTokenSequence aTokens = getFormulaParser().importFormula( aBaseAddr, rFormula );
    maModel.maFormulas.push_back( aTokens );
}
@@ -504,7 +501,7 @@ void CondFormatRule::importCfRule( SequenceInputStream& rStrm )
    SAL_WARN_IF( !( (nFmla1Size > 0) == (rStrm.getRemaining() >= 8) ), "sc.filter", "CondFormatRule::importCfRule - formula size mismatch" );
    if( rStrm.getRemaining() >= 8 )
    {
        ScAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
        ScAddress aBaseAddr = mrCondFormat.getRanges().GetTopLeftCorner();
        ApiTokenSequence aTokens = getFormulaParser().importFormula( aBaseAddr, FORMULATYPE_CONDFORMAT, rStrm );
        maModel.maFormulas.push_back( aTokens );

@@ -832,7 +829,7 @@ void CondFormatRule::finalizeImport()
            {
                case 'B':       // current base address
                    if( aAddress.isEmpty() )
                        aAddress = FormulaProcessorBase::generateAddress2dString( mrCondFormat.getRanges().getBaseAddress(), false );
                        aAddress = FormulaProcessorBase::generateAddress2dString( mrCondFormat.getRanges().GetTopLeftCorner(), false );
                    aReplaceFormula = aReplaceFormula.replaceAt( nStrPos, 2, aAddress );
                break;
                default:
@@ -846,7 +843,7 @@ void CondFormatRule::finalizeImport()
        eOperator = SC_COND_DIRECT;
    }

    ScAddress aPos = mrCondFormat.getRanges().getBaseAddress();
    ScAddress aPos = mrCondFormat.getRanges().GetTopLeftCorner();

    if( eOperator == SC_COND_ERROR || eOperator == SC_COND_NOERROR )
    {
@@ -1060,18 +1057,11 @@ void CondFormat::finalizeImport()
        return;
    ScDocument& rDoc = getScDocument();
    maRules.forEachMem( &CondFormatRule::finalizeImport );
    SCTAB nTab = maModel.maRanges.getBaseAddress().Tab();
    SCTAB nTab = maModel.maRanges.GetTopLeftCorner().Tab();
    sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, nTab);

    ScRangeList aList;
    for( ::std::vector< CellRangeAddress >::const_iterator itr = maModel.maRanges.begin(); itr != maModel.maRanges.end(); ++itr)
    {
        ScRange aRange;
        ScUnoConversion::FillScRange(aRange, *itr);
        aList.Append(aRange);
    }
    rDoc.AddCondFormatData( aList, nTab, nIndex );
    mpFormat->SetRange(aList);
    rDoc.AddCondFormatData( maModel.maRanges, nTab, nIndex );
    mpFormat->SetRange(maModel.maRanges);
}

CondFormatRuleRef CondFormat::createRule()
diff --git a/sc/source/filter/oox/viewsettings.cxx b/sc/source/filter/oox/viewsettings.cxx
index 26d99f5..4048674 100644
--- a/sc/source/filter/oox/viewsettings.cxx
+++ b/sc/source/filter/oox/viewsettings.cxx
@@ -224,7 +224,7 @@ void SheetViewSettings::importSelection( const AttributeList& rAttribs )
        rSelData.maActiveCell = getAddressConverter().createValidCellAddress( rAttribs.getString( XML_activeCell, OUString() ), getSheetIndex(), false );
        rSelData.mnActiveCellId = rAttribs.getInteger( XML_activeCellId, 0 );
        // selection
        rSelData.maSelection.clear();
        rSelData.maSelection.RemoveAll();
        getAddressConverter().convertToCellRangeList( rSelData.maSelection, rAttribs.getString( XML_sqref, OUString() ), getSheetIndex(), false );
    }
}
@@ -305,7 +305,7 @@ void SheetViewSettings::importSelection( SequenceInputStream& rStrm )
        // selection
        BinRangeList aSelection;
        rStrm >> aSelection;
        rPaneSel.maSelection.clear();
        rPaneSel.maSelection.RemoveAll();
        getAddressConverter().convertToCellRangeList( rPaneSel.maSelection, aSelection, getSheetIndex(), false );
    }
}