summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/column.hxx13
-rw-r--r--sc/inc/dbdocutl.hxx12
-rw-r--r--sc/inc/dociter.hxx39
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sc/inc/table.hxx4
-rw-r--r--sc/source/core/data/column.cxx14
-rw-r--r--sc/source/core/data/column2.cxx50
-rw-r--r--sc/source/core/data/column3.cxx2
-rw-r--r--sc/source/core/data/dbdocutl.cxx18
-rw-r--r--sc/source/core/data/dociter.cxx98
-rw-r--r--sc/source/core/data/document.cxx10
-rw-r--r--sc/source/core/data/makefile.mk2
-rw-r--r--sc/source/core/data/table1.cxx4
-rw-r--r--sc/source/ui/docshell/dbdocimp.cxx3
-rw-r--r--sc/source/ui/docshell/docsh.cxx46
-rw-r--r--sc/source/ui/docshell/docsh8.cxx30
-rw-r--r--sc/source/ui/docshell/impex.cxx4
-rw-r--r--sc/source/ui/inc/docsh.hxx4
18 files changed, 308 insertions, 50 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index f22654710189..f4f1c83c8d9c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -67,6 +67,7 @@ struct ScLineFlags;
struct ScMergePatternState;
class ScFlatBoolRowSegments;
struct ScSetStringParam;
+struct ScColWidthParam;
#define COLUMN_DELTA 4
@@ -121,8 +122,16 @@ friend class ScHorizontalCellIterator;
friend class ScHorizontalAttrIterator;
public:
-static BOOL bDoubleAlloc; // fuer Import: Groesse beim Allozieren verdoppeln
+ static bool bDoubleAlloc; // fuer Import: Groesse beim Allozieren verdoppeln
+ class DoubleAllocSwitch
+ {
+ public:
+ DoubleAllocSwitch(bool bNewVal = true);
+ ~DoubleAllocSwitch();
+ private:
+ bool mbOldVal;
+ };
public:
ScColumn();
~ScColumn();
@@ -357,7 +366,7 @@ public:
const Fraction& rZoomX, const Fraction& rZoomY,
BOOL bFormula, USHORT nOldWidth,
const ScMarkData* pMarkData,
- BOOL bSimpleTextImport );
+ const ScColWidthParam* pParam );
void GetOptimalHeight( SCROW nStartRow, SCROW nEndRow, USHORT* pHeight,
OutputDevice* pDev,
double nPPTX, double nPPTY,
diff --git a/sc/inc/dbdocutl.hxx b/sc/inc/dbdocutl.hxx
index 3071b542f4b6..384375152954 100644
--- a/sc/inc/dbdocutl.hxx
+++ b/sc/inc/dbdocutl.hxx
@@ -42,10 +42,20 @@ namespace com { namespace sun { namespace star { namespace sdbc {
class ScDatabaseDocUtil
{
public:
+ /**
+ * Detailed information on single string value.
+ */
+ struct StrData
+ {
+ bool mbSimpleText;
+ sal_uInt32 mnStrLength;
+
+ StrData();
+ };
static void PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
const ::com::sun::star::uno::Reference<
::com::sun::star::sdbc::XRow>& xRow, long nRowPos,
- long nType, BOOL bCurrency, BOOL* pSimpleFlag = NULL );
+ long nType, BOOL bCurrency, StrData* pStrData = NULL );
};
#endif
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index c36899a41208..928c5ab1f390 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -37,6 +37,8 @@
#include <memory>
#include <set>
+#include <vector>
+#include <boost/shared_ptr.hpp>
class ScDocument;
class ScBaseCell;
@@ -44,6 +46,7 @@ class ScPatternAttr;
class ScAttrArray;
class ScAttrIterator;
class ScRange;
+class ScFlatBoolRowSegments;
class ScDocumentIterator // alle nichtleeren Zellen durchgehen
{
@@ -526,6 +529,42 @@ private:
::std::set<SCROW>::const_iterator maEnd;
};
+// ============================================================================
+
+class ScDocRowHeightUpdater
+{
+public:
+ struct TabRanges
+ {
+ SCTAB mnTab;
+ ::boost::shared_ptr<ScFlatBoolRowSegments> mpRanges;
+
+ TabRanges();
+ TabRanges(SCTAB nTab);
+ };
+
+ /**
+ * Passing a NULL pointer to pTabRangesArray forces the heights of all
+ * rows in all tables to be updated.
+ */
+ explicit ScDocRowHeightUpdater(
+ ScDocument& rDoc, OutputDevice* pOutDev, double fPPTX, double fPPTY,
+ const ::std::vector<TabRanges>* pTabRangesArray = NULL);
+
+ void update();
+
+private:
+ void updateAll();
+
+private:
+ ScDocument& mrDoc;
+ OutputDevice* mpOutDev;
+ double mfPPTX;
+ double mfPPTY;
+ const ::std::vector<TabRanges>* mpTabRangesArray;
+};
+
+
#endif
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 0b66a0c18b9f..bc81d6eaf365 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -147,6 +147,8 @@ struct ScClipParam;
struct ScClipRangeNameData;
class ScRowBreakIterator;
struct ScSetStringParam;
+class ScDocRowHeightUpdater;
+struct ScColWidthParam;
namespace com { namespace sun { namespace star {
namespace lang {
@@ -250,6 +252,7 @@ friend class ScHorizontalAttrIterator;
friend class ScDocAttrIterator;
friend class ScAttrRectIterator;
friend class ScDocShell;
+friend class ScDocRowHeightUpdater;
private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;
@@ -1301,7 +1304,7 @@ public:
const Fraction& rZoomX, const Fraction& rZoomY,
BOOL bFormula,
const ScMarkData* pMarkData = NULL,
- BOOL bSimpleTextImport = FALSE );
+ const ScColWidthParam* pParam = NULL );
SC_DLLPUBLIC BOOL SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, USHORT nExtra,
OutputDevice* pDev,
double nPPTX, double nPPTY,
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 757d07a903da..db6b3ab11682 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -86,6 +86,8 @@ class ScFlatUInt16RowSegments;
class ScFlatBoolRowSegments;
class ScFlatBoolColSegments;
struct ScSetStringParam;
+struct ScColWidthParam;
+struct ScColWidthParam;
class ScTable
{
@@ -595,7 +597,7 @@ public:
double nPPTX, double nPPTY,
const Fraction& rZoomX, const Fraction& rZoomY,
BOOL bFormula, const ScMarkData* pMarkData,
- BOOL bSimpleTextImport );
+ const ScColWidthParam* pParam );
BOOL SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, USHORT nExtra,
OutputDevice* pDev,
double nPPTX, double nPPTY,
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 0383409532a2..13b366be5a35 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -67,8 +67,20 @@ inline BOOL IsAmbiguousScriptNonZero( BYTE nScript )
nScript != 0 );
}
-// -----------------------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+ScColumn::DoubleAllocSwitch::DoubleAllocSwitch(bool bNewVal) :
+ mbOldVal(ScColumn::bDoubleAlloc)
+{
+ ScColumn::bDoubleAlloc = bNewVal;
+}
+
+ScColumn::DoubleAllocSwitch::~DoubleAllocSwitch()
+{
+ ScColumn::bDoubleAlloc = mbOldVal;
+}
+
+// ----------------------------------------------------------------------------
ScColumn::ScColumn() :
nCol( 0 ),
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 5085cb1b99b1..b6770e475719 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -67,6 +67,7 @@
#include "dbcolect.hxx"
#include "fillinfo.hxx"
#include "segmenttree.hxx"
+#include "docparam.hxx"
#include <math.h>
@@ -548,10 +549,10 @@ long ScColumn::GetSimpleTextNeededSize( SCSIZE nIndex, OutputDevice* pDev,
}
USHORT ScColumn::GetOptimalColWidth( OutputDevice* pDev, double nPPTX, double nPPTY,
- const Fraction& rZoomX, const Fraction& rZoomY,
- BOOL bFormula, USHORT nOldWidth,
- const ScMarkData* pMarkData,
- BOOL bSimpleTextImport )
+ const Fraction& rZoomX, const Fraction& rZoomY,
+ BOOL bFormula, USHORT nOldWidth,
+ const ScMarkData* pMarkData,
+ const ScColWidthParam* pParam )
{
if (nCount == 0)
return nOldWidth;
@@ -561,7 +562,7 @@ USHORT ScColumn::GetOptimalColWidth( OutputDevice* pDev, double nPPTX, double nP
SCSIZE nIndex;
ScMarkedDataIter aDataIter(this, pMarkData, TRUE);
- if ( bSimpleTextImport )
+ if ( pParam && pParam->mbSimpleText )
{ // alles eins bis auf NumberFormate
const ScPatternAttr* pPattern = GetPattern( 0 );
Font aFont;
@@ -572,19 +573,44 @@ USHORT ScColumn::GetOptimalColWidth( OutputDevice* pDev, double nPPTX, double nP
long nMargin = (long) ( pMargin->GetLeftMargin() * nPPTX ) +
(long) ( pMargin->GetRightMargin() * nPPTX );
- while (aDataIter.Next( nIndex ))
+ // Try to find the row that has the longest string, and measure the width of that string.
+ SvNumberFormatter* pFormatter = pDocument->GetFormatTable();
+ ULONG nFormat = pPattern->GetNumberFormat( pFormatter );
+ String aLongStr;
+ Color* pColor;
+ if (pParam->mnMaxTextRow >= 0)
{
- USHORT nThis = (USHORT) (GetSimpleTextNeededSize( nIndex, pDev,
- TRUE ) + nMargin);
- if (nThis)
+ ScBaseCell* pCell = GetCell(pParam->mnMaxTextRow);
+ ScCellFormat::GetString(
+ pCell, nFormat, aLongStr, &pColor, *pFormatter, TRUE, FALSE, ftCheck );
+ }
+ else
+ {
+ xub_StrLen nLongLen = 0;
+ while (aDataIter.Next(nIndex))
{
- if (nThis>nWidth || !bFound)
+ if (nIndex >= nCount)
+ // Out-of-bound reached. No need to keep going.
+ break;
+
+ ScBaseCell* pCell = pItems[nIndex].pCell;
+ String aValStr;
+ ScCellFormat::GetString(
+ pCell, nFormat, aValStr, &pColor, *pFormatter, TRUE, FALSE, ftCheck );
+
+ if (aValStr.Len() > nLongLen)
{
- nWidth = nThis;
- bFound = TRUE;
+ nLongLen = aValStr.Len();
+ aLongStr = aValStr;
}
}
}
+
+ if (aLongStr.Len())
+ {
+ nWidth = pDev->GetTextWidth(aLongStr) + static_cast<USHORT>(nMargin);
+ bFound = true;
+ }
}
else
{
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index bf437cf62ccd..642d5bdcf3f0 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -65,7 +65,7 @@ extern const ScFormulaCell* pLastFormulaTreeTop; // in cellform.cxx
using namespace formula;
// STATIC DATA -----------------------------------------------------------
-BOOL ScColumn::bDoubleAlloc = FALSE; // fuer Import: Groesse beim Allozieren verdoppeln
+bool ScColumn::bDoubleAlloc = FALSE; // fuer Import: Groesse beim Allozieren verdoppeln
void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell )
diff --git a/sc/source/core/data/dbdocutl.cxx b/sc/source/core/data/dbdocutl.cxx
index 39675704fb70..7a56f90bbffa 100644
--- a/sc/source/core/data/dbdocutl.cxx
+++ b/sc/source/core/data/dbdocutl.cxx
@@ -46,12 +46,19 @@ using namespace ::com::sun::star;
#define D_TIMEFACTOR 86400.0
-// -----------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+
+ScDatabaseDocUtil::StrData::StrData() :
+ mbSimpleText(true), mnStrLength(0)
+{
+}
+
+// ----------------------------------------------------------------------------
// static
void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab,
const uno::Reference<sdbc::XRow>& xRow, long nRowPos,
- long nType, BOOL bCurrency, BOOL* pSimpleFlag )
+ long nType, BOOL bCurrency, StrData* pStrData )
{
String aString;
double nVal = 0.0;
@@ -185,8 +192,11 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB
if (aString.Len())
{
pCell = ScBaseCell::CreateTextCell( aString, pDoc );
- if ( pSimpleFlag && pCell->GetCellType() == CELLTYPE_EDIT )
- *pSimpleFlag = FALSE;
+ if (pStrData)
+ {
+ pStrData->mbSimpleText = pCell->GetCellType() != CELLTYPE_EDIT;
+ pStrData->mnStrLength = aString.Len();
+ }
}
else
pCell = NULL;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 61e79c7da64e..280cd340e59f 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -43,6 +43,10 @@
#include "patattr.hxx"
#include "docoptio.hxx"
#include "cellform.hxx"
+#include "segmenttree.hxx"
+#include "progress.hxx"
+#include "globstr.hrc"
+#include "tools/fract.hxx"
#include <vector>
@@ -2024,6 +2028,100 @@ const ScPatternAttr* ScDocAttrIterator::GetNext( SCCOL& rCol, SCROW& rRow1, SCRO
return NULL; // is nix mehr
}
+// ============================================================================
+
+ScDocRowHeightUpdater::TabRanges::TabRanges() :
+ mnTab(0), mpRanges(new ScFlatBoolRowSegments)
+{
+}
+
+ScDocRowHeightUpdater::TabRanges::TabRanges(SCTAB nTab) :
+ mnTab(nTab), mpRanges(new ScFlatBoolRowSegments)
+{
+}
+
+ScDocRowHeightUpdater::ScDocRowHeightUpdater(ScDocument& rDoc, OutputDevice* pOutDev, double fPPTX, double fPPTY, const vector<TabRanges>* pTabRangesArray) :
+ mrDoc(rDoc), mpOutDev(pOutDev), mfPPTX(fPPTX), mfPPTY(fPPTY), mpTabRangesArray(pTabRangesArray)
+{
+}
+
+void ScDocRowHeightUpdater::update()
+{
+ if (!mpTabRangesArray || mpTabRangesArray->empty())
+ {
+ // No ranges defined. Update all rows in all tables.
+ updateAll();
+ return;
+ }
+
+ sal_uInt32 nCellCount = 0;
+ vector<TabRanges>::const_iterator itr = mpTabRangesArray->begin(), itrEnd = mpTabRangesArray->end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScFlatBoolRowSegments::RangeData aData;
+ ScFlatBoolRowSegments::RangeIterator aRangeItr(*itr->mpRanges);
+ for (bool bFound = aRangeItr.getFirst(aData); bFound; bFound = aRangeItr.getNext(aData))
+ {
+ if (!aData.mbValue)
+ continue;
+
+ nCellCount += aData.mnRow2 - aData.mnRow1 + 1;
+ }
+ }
+
+ ScProgress aProgress(mrDoc.GetDocumentShell(), ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), nCellCount);
+
+ Fraction aZoom(1, 1);
+ itr = mpTabRangesArray->begin();
+ sal_uInt32 nProgressStart = 0;
+ for (; itr != itrEnd; ++itr)
+ {
+ SCTAB nTab = itr->mnTab;
+ if (!ValidTab(nTab) || !mrDoc.pTab[nTab])
+ continue;
+
+ ScFlatBoolRowSegments::RangeData aData;
+ ScFlatBoolRowSegments::RangeIterator aRangeItr(*itr->mpRanges);
+ for (bool bFound = aRangeItr.getFirst(aData); bFound; bFound = aRangeItr.getNext(aData))
+ {
+ if (!aData.mbValue)
+ continue;
+
+ mrDoc.pTab[nTab]->SetOptimalHeight(
+ aData.mnRow1, aData.mnRow2, 0, mpOutDev, mfPPTX, mfPPTY, aZoom, aZoom, false, &aProgress, nProgressStart);
+
+ nProgressStart += aData.mnRow2 - aData.mnRow1 + 1;
+ }
+ }
+}
+
+void ScDocRowHeightUpdater::updateAll()
+{
+ sal_uInt32 nCellCount = 0;
+ for (SCTAB nTab = 0; nTab <= MAXTAB; ++nTab)
+ {
+ if (!ValidTab(nTab) || !mrDoc.pTab[nTab])
+ continue;
+
+ nCellCount += mrDoc.pTab[nTab]->GetWeightedCount();
+ }
+
+ ScProgress aProgress(mrDoc.GetDocumentShell(), ScGlobal::GetRscString(STR_PROGRESS_HEIGHTING), nCellCount);
+
+ Fraction aZoom(1, 1);
+ ULONG nProgressStart = 0;
+ for (SCTAB nTab = 0; nTab <= MAXTAB; ++nTab)
+ {
+ if (!ValidTab(nTab) || !mrDoc.pTab[nTab])
+ continue;
+
+ mrDoc.pTab[nTab]->SetOptimalHeight(
+ 0, MAXROW, 0, mpOutDev, mfPPTX, mfPPTY, aZoom, aZoom, false, &aProgress, nProgressStart);
+
+ nProgressStart += mrDoc.pTab[nTab]->GetWeightedCount();
+ }
+}
+
//-------------------------------------------------------------------------------
ScAttrRectIterator::ScAttrRectIterator(ScDocument* pDocument, SCTAB nTable,
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index d3630ac451da..28611e9e3b91 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3281,14 +3281,14 @@ ULONG ScDocument::GetRowOffset( SCROW nRow, SCTAB nTab ) const
USHORT ScDocument::GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev,
- double nPPTX, double nPPTY,
- const Fraction& rZoomX, const Fraction& rZoomY,
- BOOL bFormula, const ScMarkData* pMarkData,
- BOOL bSimpleTextImport )
+ double nPPTX, double nPPTY,
+ const Fraction& rZoomX, const Fraction& rZoomY,
+ BOOL bFormula, const ScMarkData* pMarkData,
+ const ScColWidthParam* pParam )
{
if ( ValidTab(nTab) && pTab[nTab] )
return pTab[nTab]->GetOptimalColWidth( nCol, pDev, nPPTX, nPPTY,
- rZoomX, rZoomY, bFormula, pMarkData, bSimpleTextImport );
+ rZoomX, rZoomY, bFormula, pMarkData, pParam );
DBG_ERROR("Falsche Tabellennummer");
return 0;
}
diff --git a/sc/source/core/data/makefile.mk b/sc/source/core/data/makefile.mk
index 95ce6bcec179..9041e1c3696d 100644
--- a/sc/source/core/data/makefile.mk
+++ b/sc/source/core/data/makefile.mk
@@ -70,6 +70,7 @@ SLOFILES = \
$(SLO)$/documen8.obj \
$(SLO)$/documen9.obj \
$(SLO)$/document.obj \
+ $(SLO)$/docparam.obj \
$(SLO)$/dpcachetable.obj \
$(SLO)$/dpdimsave.obj \
$(SLO)$/dpglobal.obj \
@@ -122,6 +123,7 @@ EXCEPTIONSFILES= \
$(SLO)$/clipparam.obj \
$(SLO)$/column.obj \
$(SLO)$/column3.obj \
+ $(SLO)$/dociter.obj \
$(SLO)$/documen2.obj \
$(SLO)$/document.obj \
$(SLO)$/dpdimsave.obj \
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 949fff851893..bf5f0de31f5c 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -256,10 +256,10 @@ USHORT ScTable::GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev,
double nPPTX, double nPPTY,
const Fraction& rZoomX, const Fraction& rZoomY,
BOOL bFormula, const ScMarkData* pMarkData,
- BOOL bSimpleTextImport )
+ const ScColWidthParam* pParam )
{
return aCol[nCol].GetOptimalColWidth( pDev, nPPTX, nPPTY, rZoomX, rZoomY,
- bFormula, STD_COL_WIDTH - STD_EXTRA_WIDTH, pMarkData, bSimpleTextImport );
+ bFormula, STD_COL_WIDTH - STD_EXTRA_WIDTH, pMarkData, pParam );
}
long ScTable::GetNeededSize( SCCOL nCol, SCROW nRow,
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx
index da5cd4dc9fc6..dee7438bc07f 100644
--- a/sc/source/ui/docshell/dbdocimp.cxx
+++ b/sc/source/ui/docshell/dbdocimp.cxx
@@ -268,7 +268,7 @@ BOOL ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
// ImportDoc - also used for Redo
ScDocument* pImportDoc = new ScDocument( SCDOCMODE_UNDO );
pImportDoc->InitUndo( pDoc, nTab, nTab );
- ScColumn::bDoubleAlloc = TRUE;
+ ScColumn::DoubleAllocSwitch aAllocSwitch(true);
//
// get data from database into import document
@@ -460,7 +460,6 @@ BOOL ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
DBG_ERROR("Unexpected exception in database");
}
- ScColumn::bDoubleAlloc = FALSE;
pImportDoc->DoColResize( nTab, rParam.nCol1,nEndCol, 0 );
//
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 5f9cd2426259..cf2caa219c08 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -121,18 +121,26 @@
#include "optsolver.hxx"
#include "sheetdata.hxx"
#include "tabprotection.hxx"
+#include "docparam.hxx"
#include "docsh.hxx"
#include "docshimp.hxx"
+#include "sizedev.hxx"
#include <rtl/logfile.hxx>
#include <comphelper/processfactory.hxx>
#include "uiitems.hxx"
#include "cellsuno.hxx"
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
using namespace com::sun::star;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
+using ::boost::shared_ptr;
+using ::std::vector;
// STATIC DATA -----------------------------------------------------------
@@ -1022,12 +1030,13 @@ BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
// ob nach dem Import optimale Spaltenbreiten gesetzt werden sollen
BOOL bSetColWidths = FALSE;
BOOL bSetSimpleTextColWidths = FALSE;
- BOOL bSimpleColWidth[MAXCOLCOUNT];
- memset( bSimpleColWidth, 1, (MAXCOLCOUNT) * sizeof(BOOL) );
+ ScColWidthParam aColWidthParam[MAXCOLCOUNT];
ScRange aColWidthRange;
// ob nach dem Import optimale Zeilenhoehen gesetzt werden sollen
BOOL bSetRowHeights = FALSE;
+ vector<ScDocRowHeightUpdater::TabRanges> aRecalcRowRangesArray;
+
aConvFilterName.Erase(); //@ #BugId 54198
// Alle Filter brauchen die komplette Datei am Stueck (nicht asynchron),
@@ -1226,8 +1235,10 @@ BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_850 );
}
+ ScDocRowHeightUpdater::TabRanges aRecalcRanges(0);
ULONG eError = DBaseImport( rMedium.GetPhysicalName(),
- ScGlobal::GetCharsetValue(sItStr), bSimpleColWidth );
+ ScGlobal::GetCharsetValue(sItStr), aColWidthParam, *aRecalcRanges.mpRanges );
+ aRecalcRowRangesArray.push_back(aRecalcRanges);
if (eError != eERR_OK)
{
@@ -1241,12 +1252,6 @@ BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
aColWidthRange.aStart.SetRow( 1 ); // Spaltenheader nicht
bSetColWidths = TRUE;
bSetSimpleTextColWidths = TRUE;
- // Memo-Felder fuehren zu einem bSimpleColWidth[nCol]==FALSE
- for ( SCCOL nCol=0; nCol <= MAXCOL && !bSetRowHeights; nCol++ )
- {
- if ( !bSimpleColWidth[nCol] )
- bSetRowHeights = TRUE;
- }
}
else if (aFltName.EqualsAscii(pFilterDif))
{
@@ -1460,9 +1465,12 @@ BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
{
for ( SCCOL nCol=0; nCol <= nEndCol; nCol++ )
{
+ if (!bSetSimpleTextColWidths)
+ aColWidthParam[nCol].mbSimpleText = false;
+
USHORT nWidth = aDocument.GetOptimalColWidth(
nCol, nTab, &aVirtDev, nPPTX, nPPTY, aZoom, aZoom, FALSE, &aMark,
- (bSetSimpleTextColWidths && bSimpleColWidth[nCol]) );
+ &aColWidthParam[nCol] );
aDocument.SetColWidth( nCol, nTab,
nWidth + (USHORT)ScGlobal::nLastColWidthExtra );
}
@@ -1474,11 +1482,25 @@ BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
// nPPTX, nPPTY, aZoom, aZoom, FALSE );
// }
}
- if ( bSetRowHeights )
- UpdateAllRowHeights(); // with vdev or printer, depending on configuration
+
+ if (bSetRowHeights)
+ {
+ // Update all rows in all tables.
+ ScSizeDeviceProvider aProv(this);
+ ScDocRowHeightUpdater aUpdater(aDocument, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), NULL);
+ aUpdater.update();
+ }
+ else if (!aRecalcRowRangesArray.empty())
+ {
+ // Update only specified row ranges for better performance.
+ ScSizeDeviceProvider aProv(this);
+ ScDocRowHeightUpdater aUpdater(aDocument, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), &aRecalcRowRangesArray);
+ aUpdater.update();
+ }
}
FinishedLoading( SFX_LOADED_MAINDOCUMENT | SFX_LOADED_IMAGES );
+
// #73762# invalidate eventually temporary table areas
if ( bRet )
aDocument.InvalidateTableArea();
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 2b6c6af4beca..8ef15badde9c 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -83,6 +83,8 @@
#include "patattr.hxx"
#include "scitems.hxx"
#include "docpool.hxx"
+#include "segmenttree.hxx"
+#include "docparam.hxx"
#include <vector>
@@ -99,6 +101,7 @@ using ::std::vector;
#define SC_DBPROP_ACTIVECONNECTION "ActiveConnection"
#define SC_DBPROP_COMMAND "Command"
#define SC_DBPROP_COMMANDTYPE "CommandType"
+#define SC_DBPROP_PROPCHANGE_NOTIFY "PropertyChangeNotificationEnabled"
#define SC_DBPROP_NAME "Name"
#define SC_DBPROP_TYPE "Type"
@@ -302,8 +305,10 @@ static void lcl_setScalesToColumns(ScDocument& rDoc, const vector<long>& rScales
}
ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet,
- BOOL bSimpleColWidth[MAXCOLCOUNT] )
+ ScColWidthParam aColWidthParam[MAXCOLCOUNT], ScFlatBoolRowSegments& rRowHeightsRecalc )
{
+ ScColumn::DoubleAllocSwitch aAllocSwitch(true);
+
ULONG nErr = eERR_OK;
long i;
@@ -349,6 +354,10 @@ ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet,
xRowProp->setPropertyValue(
rtl::OUString::createFromAscii(SC_DBPROP_COMMAND), aAny );
+ aAny <<= sal_False;
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_PROPCHANGE_NOTIFY), aAny );
+
xRowSet->execute();
long nColCount = 0;
@@ -426,16 +435,33 @@ ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet,
BOOL bEnd = FALSE;
while ( !bEnd && xRowSet->next() )
{
+ bool bSimpleRow = true;
if ( nRow <= MAXROW )
{
SCCOL nCol = 0;
for (i=0; i<nColCount; i++)
{
+ ScDatabaseDocUtil::StrData aStrData;
ScDatabaseDocUtil::PutData( &aDocument, nCol, nRow, 0,
xRow, i+1, pTypeArr[i], FALSE,
- &bSimpleColWidth[nCol] );
+ &aStrData );
+
+ if (aStrData.mnStrLength > aColWidthParam[nCol].mnMaxTextLen)
+ {
+ aColWidthParam[nCol].mnMaxTextLen = aStrData.mnStrLength;
+ aColWidthParam[nCol].mnMaxTextRow = nRow;
+ }
+
+ if (!aStrData.mbSimpleText)
+ {
+ bSimpleRow = false;
+ aColWidthParam[nCol].mbSimpleText = false;
+ }
+
++nCol;
}
+ if (!bSimpleRow)
+ rRowHeightsRecalc.setTrue(nRow, nRow);
++nRow;
}
else // past the end of the spreadsheet
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 981cfa7afc5e..9d57734dd2fb 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1191,8 +1191,7 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
if ( rStrm.GetStreamCharSet() == RTL_TEXTENCODING_UNICODE )
rStrm.StartReadingUnicodeText();
- BOOL bOld = ScColumn::bDoubleAlloc;
- ScColumn::bDoubleAlloc = TRUE;
+ ScColumn::DoubleAllocSwitch aAllocSwitch(true);
SCCOL nStartCol = aRange.aStart.Col();
SCCOL nEndCol = aRange.aEnd.Col();
@@ -1393,7 +1392,6 @@ BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
bDetermineRange = !bDetermineRange; // toggle
} while (!bDetermineRange);
- ScColumn::bDoubleAlloc = bOld;
pDoc->DoColResize( nTab, nStartCol, nEndCol, 0 );
delete pEnglishTransliteration;
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 19147cfaf61f..bae92e1c0cad 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -68,6 +68,8 @@ class ScImportOptions;
class ScDocShellModificator;
class ScOptSolverSave;
class ScSheetSaveData;
+class ScFlatBoolRowSegments;
+struct ScColWidthParam;
namespace sfx2 { class FileDialogHelper; }
struct DocShell_Impl;
@@ -148,7 +150,7 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener
SC_DLLPRIVATE SCTAB GetSaveTab();
SC_DLLPRIVATE ULONG DBaseImport( const String& rFullFileName, CharSet eCharSet,
- BOOL bSimpleColWidth[MAXCOLCOUNT] );
+ ScColWidthParam aColWidthParam[MAXCOLCOUNT], ScFlatBoolRowSegments& rRowHeightsRecalc );
SC_DLLPRIVATE ULONG DBaseExport( const String& rFullFileName, CharSet eCharSet,
BOOL& bHasMemo );