diff options
36 files changed, 660 insertions, 333 deletions
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index ffc1e95ca796..1b0d8fb4889c 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -52,17 +52,6 @@ namespace chart namespace wrapper { -namespace -{ - -rtl::OUString lcl_getCIDForDiagram( const Reference< frame::XModel >& xChartModel ) -{ - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - return ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xChartModel ); -} - -} //anonymous namespace - Chart2ModelContact::Chart2ModelContact( const Reference< uno::XComponentContext > & xContext ) : m_xContext( xContext ), diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index edf8ad2b6209..d6487d425657 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -239,14 +239,14 @@ void lcl_AddPropertiesToVector( Property( C2U( "DisableComplexChartTypes" ), PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, ::getBooleanCppuType(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ) ); + //#i112666# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT ) ); rOutProperties.push_back( Property( C2U( "DisableDataTableDialog" ), PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG, ::getBooleanCppuType(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ) ); + //#i112666# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT ) ); } const uno::Sequence< Property > & lcl_GetPropertySequence() diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index eb3c76dd2c40..c0be0ddcbf0d 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -749,20 +749,19 @@ void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); if( xProp.is() ) { - if( aPosition.X < 0 || aPosition.Y < 0 || aPosition.X > 1 || aPosition.Y > 1 ) - { - DBG_ERROR("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); - uno::Any aEmpty; - xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); - return; - } - awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); chart2::RelativePosition aRelativePosition; aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); + if( aRelativePosition.Primary < 0 || aRelativePosition.Secondary < 0 || aRelativePosition.Primary > 1 || aRelativePosition.Secondary > 1 ) + { + DBG_ERROR("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); + return; + } xProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); xProp->setPropertyValue( C2U( "PosSizeExcludeAxes" ), uno::makeAny(false) ); } diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index f104045727bb..f32a882aa1e9 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -41,6 +41,7 @@ #include "CommonFunctors.hxx" #include "ControllerLockGuard.hxx" #include "ChartTypeHelper.hxx" +#include "ThreeDHelper.hxx" #include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/chart2/AxisType.hpp> @@ -525,6 +526,9 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( try { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); + ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); + sal_Int32 nSeriesInChartType = 0; const sal_Int32 nTotalSeries = countSeries(); if( xChartType.is()) @@ -540,7 +544,7 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( xChartType, nTotalSeries, // new series' index nSeriesInChartType, - m_xChartDocument->getFirstDiagram(), + xDiagram, m_xTemplate, bCreateDataCachedSequences )); @@ -561,6 +565,8 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( aSeries.insert( aIt, xNewSeries ); xSeriesCnt->setDataSeries( ContainerToSequence( aSeries )); } + + ThreeDHelper::setScheme( xDiagram, e3DScheme ); } catch( uno::Exception & ex ) { @@ -694,14 +700,19 @@ bool DialogModel::setData( m_xTemplate->getDataInterpreter()); if( xInterpreter.is()) { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); + ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); + ::std::vector< Reference< XDataSeries > > aSeriesToReUse( - DiagramHelper::getDataSeriesFromDiagram( m_xChartDocument->getFirstDiagram())); + DiagramHelper::getDataSeriesFromDiagram( xDiagram )); applyInterpretedData( xInterpreter->interpretDataSource( xDataSource, rArguments, ContainerToSequence( aSeriesToReUse )), aSeriesToReUse, true /* bSetStyles */); + + ThreeDHelper::setScheme( xDiagram, e3DScheme ); } } catch( uno::Exception & ex ) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index f7ae5e63f165..304a9d1df0f7 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1276,6 +1276,7 @@ public: SC_DLLPUBLIC USHORT GetColWidth( SCCOL nCol, SCTAB nTab ) const; SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const; + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const; SC_DLLPUBLIC ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const; SCROW GetRowForHeight( SCTAB nTab, ULONG nHeight ) const; ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 78e5875b6879..5f42a2f37247 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -628,12 +628,12 @@ public: // nPPT fuer Test auf Veraenderung void SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual ); - USHORT GetColWidth( SCCOL nCol ); - SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ); - ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ); - ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ); - ULONG GetColOffset( SCCOL nCol ); - ULONG GetRowOffset( SCROW nRow ); + USHORT GetColWidth( SCCOL nCol ) const; + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ) const; + ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const; + ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const; + ULONG GetColOffset( SCCOL nCol ) const; + ULONG GetRowOffset( SCROW nRow ) const; /** * Get the last row such that the height of row 0 to the end row is as @@ -643,7 +643,7 @@ public: * * @return SCROW last row of the range within specified height. */ - SCROW GetRowForHeight(ULONG nHeight); + SCROW GetRowForHeight(ULONG nHeight) const; USHORT GetOriginalWidth( SCCOL nCol ) const; USHORT GetOriginalHeight( SCROW nRow ) const; @@ -711,33 +711,33 @@ public: ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData() const; - bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); - bool RowHidden(SCROW nRow, SCROW& rLastRow); - bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow); - bool ColHidden(SCCOL nCol, SCCOL& rLastCol); - bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); + bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const; + bool RowHidden(SCROW nRow, SCROW& rLastRow) const; + bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const; + bool ColHidden(SCCOL nCol, SCCOL& rLastCol) const; + bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL) const; void SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden); void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden); void CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); void CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow); void CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset); - SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow); - SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow); - SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow); - sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow); + SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const; + sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) const; - SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol); + SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const; - bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); - bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); - bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow); + bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const; + bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL) const; + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const; void CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); void CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow); void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered); void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered); - SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow); - SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow); - SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow); + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const; void SyncColRowFlags(); diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 95482b1c624b..540fb577a79b 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -136,10 +136,16 @@ ScBroadcastAreaSlot::ScBroadcastAreaSlot( ScDocument* pDocument, ScBroadcastAreaSlot::~ScBroadcastAreaSlot() { for ( ScBroadcastAreas::iterator aIter( aBroadcastAreaTbl.begin()); - aIter != aBroadcastAreaTbl.end(); ++aIter) + aIter != aBroadcastAreaTbl.end(); /* none */) { - if (!(*aIter)->DecRef()) - delete *aIter; + // Prevent hash from accessing dangling pointer in case area is + // deleted. + ScBroadcastArea* pArea = *aIter; + // Erase all so no hash will be accessed upon destruction of the + // hash_set. + aBroadcastAreaTbl.erase( aIter++); + if (!pArea->DecRef()) + delete pArea; } } diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 1861988d78aa..4928ade0f13d 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -1546,6 +1546,54 @@ void ScDocument::ResetEmbedded() aEmbedRange = ScRange(); } + +/** Similar to ScViewData::AddPixelsWhile(), but add height twips and only + while result is less than nStopTwips. + @return TRUE if advanced at least one row. + */ +bool lcl_AddTwipsWhile( long & rTwips, long nStopTwips, SCROW & rPosY, SCROW nEndRow, const ScTable * pTable ) +{ + SCROW nRow = rPosY; + bool bAdded = false; + bool bStop = false; + while (rTwips < nStopTwips && nRow <= nEndRow && !bStop) + { + SCROW nHeightEndRow; + USHORT nHeight = pTable->GetRowHeight( nRow, NULL, &nHeightEndRow); + if (nHeightEndRow > nEndRow) + nHeightEndRow = nEndRow; + if (!nHeight) + nRow = nHeightEndRow + 1; + else + { + SCROW nRows = nHeightEndRow - nRow + 1; + sal_Int64 nAdd = static_cast<sal_Int64>(nHeight) * nRows; + if (nAdd + rTwips >= nStopTwips) + { + sal_Int64 nDiff = nAdd + rTwips - nStopTwips; + nRows -= static_cast<SCROW>(nDiff / nHeight); + nAdd = nHeight * nRows; + // We're looking for a value that satisfies loop condition. + if (nAdd + rTwips >= nStopTwips) + { + --nRows; + nAdd -= nHeight; + } + bStop = true; + } + rTwips += static_cast<long>(nAdd); + nRow += nRows; + } + } + if (nRow > rPosY) + { + --nRow; + bAdded = true; + } + rPosY = nRow; + return bAdded; +} + ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) { ScTable* pTable = pTab[nTab]; @@ -1602,43 +1650,16 @@ ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) nTwips = (long) (aPosRect.Top() / HMM_PER_TWIPS); SCROW nY1 = 0; - bEnd = FALSE; - for (SCROW i = nY1; i <= MAXROW && !bEnd; ++i) - { - if (pTable->RowHidden(i)) - continue; - - nY1 = i; - nAdd = static_cast<long>(pTable->GetRowHeight(i)); - if (nSize+nAdd <= nTwips+1 && nY1<MAXROW) - { - nSize += nAdd; - ++nY1; - } - else - bEnd = TRUE; - } - if (!bEnd) - nY1 = MAXROW; // all hidden down to the bottom + // Was if(nSize+nAdd<=nTwips+1) inside loop => if(nSize+nAdd<nTwips+2) + if (lcl_AddTwipsWhile( nSize, nTwips+2, nY1, MAXROW, pTable) && nY1 < MAXROW) + ++nY1; // original loop ended on last matched +1 unless that was MAXROW nTwips = (long) (aPosRect.Bottom() / HMM_PER_TWIPS); SCROW nY2 = nY1; - bEnd = FALSE; - for (SCROW i = nY2; i <= MAXROW && !bEnd; ++i) - { - nY2 = i; - nAdd = static_cast<long>(pTable->GetRowHeight(i)); - if (nSize+nAdd < nTwips && nY2<MAXROW) - { - nSize += nAdd; - ++nY2; - } - else - bEnd = TRUE; - } - if (!bEnd) - nY2 = MAXROW; // all hidden down to the bottom + // Was if(nSize+nAdd<nTwips) inside loop => if(nSize+nAdd<nTwips) + if (lcl_AddTwipsWhile( nSize, nTwips, nY2, MAXROW, pTable) && nY2 < MAXROW) + ++nY2; // original loop ended on last matched +1 unless that was MAXROW return ScRange( nX1,nY1,nTab, nX2,nY2,nTab ); } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index bef4cbf87396..a4f8833f6caa 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3061,6 +3061,19 @@ void ScDocument::CalcAfterLoad() bCalcingAfterLoad = FALSE; SetDetectiveDirty(FALSE); // noch keine wirklichen Aenderungen + + // #i112436# If formula cells are already dirty, they don't broadcast further changes. + // So the source ranges of charts must be interpreted even if they are not visible, + // similar to ScMyShapeResizer::CreateChartListener for loading own files (i104899). + if (pChartListenerCollection) + { + sal_uInt16 nChartCount = pChartListenerCollection->GetCount(); + for ( sal_uInt16 nIndex = 0; nIndex < nChartCount; nIndex++ ) + { + ScChartListener* pChartListener = static_cast<ScChartListener*>(pChartListenerCollection->At(nIndex)); + InterpretDirtyCells(*pChartListener->GetRangeList()); + } + } } @@ -3161,7 +3174,16 @@ USHORT ScDocument::GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero ) co { if ( ValidTab(nTab) && pTab[nTab] ) return pTab[nTab]->GetRowHeight( nRow, NULL, NULL, bHiddenAsZero ); - DBG_ERROR("Falsche Tabellennummer"); + DBG_ERROR("Wrong sheet number"); + return 0; +} + + +USHORT ScDocument::GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero ) const +{ + if ( ValidTab(nTab) && pTab[nTab] ) + return pTab[nTab]->GetRowHeight( nRow, pStartRow, pEndRow, bHiddenAsZero ); + DBG_ERROR("Wrong sheet number"); return 0; } @@ -3684,24 +3706,35 @@ SCCOL ScDocument::GetNextDifferentChangedCol( SCTAB nTab, SCCOL nStart) const SCROW ScDocument::GetNextDifferentChangedRow( SCTAB nTab, SCROW nStart, bool bCareManualSize) const { - if ( ValidTab(nTab) && pTab[nTab] && pTab[nTab]->GetRowFlagsArray() && pTab[nTab]->mpRowHeights ) - { - BYTE nStartFlags = pTab[nTab]->GetRowFlags(nStart); - USHORT nStartHeight = pTab[nTab]->GetOriginalHeight(nStart); - for (SCROW nRow = nStart + 1; nRow <= MAXROW; nRow++) + const ScBitMaskCompressedArray< SCROW, BYTE> * pRowFlagsArray; + if ( ValidTab(nTab) && pTab[nTab] && ((pRowFlagsArray = pTab[nTab]->GetRowFlagsArray()) != NULL) && + pTab[nTab]->mpRowHeights && pTab[nTab]->mpHiddenRows ) + { + size_t nIndex; // ignored + SCROW nFlagsEndRow; + SCROW nHiddenEndRow; + SCROW nHeightEndRow; + BYTE nFlags; + bool bHidden; + USHORT nHeight; + BYTE nStartFlags = nFlags = pRowFlagsArray->GetValue( nStart, nIndex, nFlagsEndRow); + bool bStartHidden = bHidden = pTab[nTab]->RowHidden( nStart, NULL, &nHiddenEndRow); + USHORT nStartHeight = nHeight = pTab[nTab]->GetRowHeight( nStart, NULL, &nHeightEndRow, false); + SCROW nRow; + while ((nRow = std::min( nHiddenEndRow, std::min( nFlagsEndRow, nHeightEndRow)) + 1) <= MAXROW) { - size_t nIndex; // ignored - SCROW nFlagsEndRow; - SCROW nHeightEndRow; - BYTE nFlags = pTab[nTab]->GetRowFlagsArray()->GetValue( nRow, nIndex, nFlagsEndRow ); - USHORT nHeight = pTab[nTab]->GetRowHeight(nRow, NULL, &nHeightEndRow); - if (((nStartFlags & CR_MANUALBREAK) != (nFlags & CR_MANUALBREAK)) || - ((nStartFlags & CR_MANUALSIZE) != (nFlags & CR_MANUALSIZE)) || - (bCareManualSize && (nStartFlags & CR_MANUALSIZE) && (nStartHeight != nHeight)) || - (!bCareManualSize && ((nStartHeight != nHeight)))) + if (nFlagsEndRow < nRow) + nFlags = pRowFlagsArray->GetValue( nRow, nIndex, nFlagsEndRow); + if (nHiddenEndRow < nRow) + bHidden = pTab[nTab]->RowHidden( nRow, NULL, &nHiddenEndRow); + if (nHeightEndRow < nRow) + nHeight = pTab[nTab]->GetRowHeight( nRow, NULL, &nHeightEndRow, false); + if ( ((nStartFlags & CR_MANUALBREAK) != (nFlags & CR_MANUALBREAK)) || + ((nStartFlags & CR_MANUALSIZE) != (nFlags & CR_MANUALSIZE)) || + (bStartHidden != bHidden) || + (bCareManualSize && (nStartFlags & CR_MANUALSIZE) && (nStartHeight != nHeight)) || + (!bCareManualSize && ((nStartHeight != nHeight)))) return nRow; - - nRow = std::min( nFlagsEndRow, nHeightEndRow ); } return MAXROW+1; } diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 7ca41d47f79d..e994339f4a9a 100755..100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -67,6 +67,7 @@ #include <com/sun/star/sheet/DataPilotTablePositionType.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp> @@ -2293,6 +2294,9 @@ uno::Sequence<rtl::OUString> ScDPObject::GetRegisteredSources() return aSeq; } +// use getContext from addincol.cxx +uno::Reference<uno::XComponentContext> getContext(uno::Reference<lang::XMultiServiceFactory> xMSF); + // static uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPServiceDesc& rDesc ) { @@ -2317,12 +2321,26 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS if ( xIntFac.is() ) { uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY ); - uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY ); - if ( xFac.is() && xInfo.is() && xInfo->getImplementationName() == aImplName ) + if ( xInfo.is() && xInfo->getImplementationName() == aImplName ) { try { - uno::Reference<uno::XInterface> xInterface = xFac->createInstance(); + // #i113160# try XSingleComponentFactory in addition to (old) XSingleServiceFactory, + // passing the context to the component (see ScUnoAddInCollection::Initialize) + + uno::Reference<uno::XInterface> xInterface; + uno::Reference<uno::XComponentContext> xCtx = getContext(xManager); + uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY ); + if (xCtx.is() && xCFac.is()) + xInterface = xCFac->createInstanceWithContext(xCtx); + + if (!xInterface.is()) + { + uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY ); + if ( xFac.is() ) + xInterface = xFac->createInstance(); + } + uno::Reference<lang::XInitialization> xInit( xInterface, uno::UNO_QUERY ); if (xInit.is()) { diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 8418cb3c3a25..99da4979a1b6 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -219,6 +219,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX nArrY=0; SCROW nYExtra = nY2+1; + USHORT nDocHeight = ScGlobal::nStdRowHeight; + SCROW nDocHeightEndRow = -1; for (nSignedY=((SCsROW)nY1)-1; nSignedY<=(SCsROW)nYExtra; nSignedY++) { if (nSignedY >= 0) @@ -226,11 +228,13 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX else nY = MAXROW+1; // ungueltig - USHORT nDocHeight; - if (ValidRow(nY)) - nDocHeight = GetRowHeight( nY, nTab ); - else - nDocHeight = ScGlobal::nStdRowHeight; + if (nY > nDocHeightEndRow) + { + if (ValidRow(nY)) + nDocHeight = GetRowHeight( nY, nTab, NULL, &nDocHeightEndRow ); + else + nDocHeight = ScGlobal::nStdRowHeight; + } if ( nArrY==0 || nDocHeight || nY > MAXROW ) { @@ -384,11 +388,15 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX nArrY = 1; SCSIZE nUIndex; + bool bHiddenRow = true; + SCROW nHiddenEndRow = -1; (void) pThisCol->Search( nY1, nUIndex ); while ( nUIndex < pThisCol->nCount && (nThisRow=pThisCol->pItems[nUIndex].nRow) <= nY2 ) { - if ( !RowHidden( nThisRow,nTab ) ) + if (nThisRow > nHiddenEndRow) + bHiddenRow = RowHidden( nThisRow, nTab, nHiddenEndRow); + if ( !bHiddenRow ) { while ( pRowInfo[nArrY].nRowNo < nThisRow ) ++nArrY; diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx index baf3f4cf3f95..4401ac19d199 100644 --- a/sc/source/core/data/markdata.cxx +++ b/sc/source/core/data/markdata.cxx @@ -429,18 +429,28 @@ SCCOLROW ScMarkData::GetMarkColumnRanges( SCCOLROW* pRanges ) if (!bMultiMarked) return 0; - DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); + DBG_ASSERT(pMultiSel, "bMultiMarked, but pMultiSel == 0"); + + const SCCOLROW nMultiStart = aMultiRange.aStart.Col(); + const SCCOLROW nMultiEnd = aMultiRange.aEnd.Col(); + if (nMultiStart == 0 && nMultiEnd == MAXCOL) + { + // One or more entire rows. + pRanges[0] = 0; + pRanges[1] = MAXCOL; + return 1; + } SCCOLROW nRangeCnt = 0; - SCCOLROW nStart = 0; - while (nStart<=MAXCOL) + SCCOLROW nStart = nMultiStart; + while (nStart <= nMultiEnd) { - while (nStart<MAXCOL && !pMultiSel[nStart].HasMarks()) + while (nStart < nMultiEnd && !pMultiSel[nStart].HasMarks()) ++nStart; if (pMultiSel[nStart].HasMarks()) { SCCOLROW nEnd = nStart; - while (nEnd<MAXCOL && pMultiSel[nEnd].HasMarks()) + while (nEnd < nMultiEnd && pMultiSel[nEnd].HasMarks()) ++nEnd; if (!pMultiSel[nEnd].HasMarks()) --nEnd; @@ -450,7 +460,7 @@ SCCOLROW ScMarkData::GetMarkColumnRanges( SCCOLROW* pRanges ) nStart = nEnd+1; } else - nStart = MAXCOL+1; + nStart = nMultiEnd+1; } return nRangeCnt; @@ -464,37 +474,51 @@ SCCOLROW ScMarkData::GetMarkRowRanges( SCCOLROW* pRanges ) if (!bMultiMarked) return 0; - DBG_ASSERT(pMultiSel, "bMultiMarked, aber pMultiSel == 0"); + DBG_ASSERT(pMultiSel, "bMultiMarked, but pMultiSel == 0"); - // Welche Zeilen sind markiert? + // Which rows are marked? - BOOL* bRowMarked = new BOOL[MAXROW+1]; + // Optimized to not loop over MAXCOL*MAXROW as worst case, i.e. Ctrl+A + + const SCCOLROW nMultiStart = aMultiRange.aStart.Row(); + const SCCOLROW nMultiEnd = aMultiRange.aEnd.Row(); + + BOOL* bRowMarked = new BOOL[MAXROWCOUNT]; + memset( bRowMarked, 0, sizeof(BOOL) * MAXROWCOUNT); SCROW nRow; SCCOL nCol; - for (nRow=0; nRow<=MAXROW; nRow++) - bRowMarked[nRow] = FALSE; - SCROW nTop, nBottom; - for (nCol=0; nCol<=MAXCOL; nCol++) + SCROW nTop = -1, nBottom = -1; + for (nCol = aMultiRange.aStart.Col(); nCol <= aMultiRange.aEnd.Col(); ++nCol) { ScMarkArrayIter aMarkIter( &pMultiSel[nCol] ); while (aMarkIter.Next( nTop, nBottom )) for (nRow=nTop; nRow<=nBottom; nRow++) bRowMarked[nRow] = TRUE; + if (nTop == nMultiStart && nBottom == nMultiEnd) + break; // for, all relevant rows marked + } + + if (nTop == nMultiStart && nBottom == nMultiEnd) + { + pRanges[0] = nTop; + pRanges[1] = nBottom; + delete[] bRowMarked; + return 1; } - // zu Bereichen zusammenfassen + // Combine to ranges of rows. SCCOLROW nRangeCnt = 0; - SCCOLROW nStart = 0; - while (nStart<=MAXROW) + SCCOLROW nStart = nMultiStart; + while (nStart <= nMultiEnd) { - while (nStart<MAXROW && !bRowMarked[nStart]) + while (nStart < nMultiEnd && !bRowMarked[nStart]) ++nStart; if (bRowMarked[nStart]) { SCCOLROW nEnd = nStart; - while (nEnd<MAXROW && bRowMarked[nEnd]) + while (nEnd < nMultiEnd && bRowMarked[nEnd]) ++nEnd; if (!bRowMarked[nEnd]) --nEnd; @@ -504,7 +528,7 @@ SCCOLROW ScMarkData::GetMarkRowRanges( SCCOLROW* pRanges ) nStart = nEnd+1; } else - nStart = MAXROW+1; + nStart = nMultiEnd+1; } delete[] bRowMarked; diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 9bd5b031fde5..b8bd9037c900 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2241,7 +2241,7 @@ void ScTable::SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual ) } -USHORT ScTable::GetColWidth( SCCOL nCol ) +USHORT ScTable::GetColWidth( SCCOL nCol ) const { DBG_ASSERT(VALIDCOL(nCol),"Falsche Spaltennummer"); @@ -2315,34 +2315,50 @@ USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) } -USHORT ScTable::GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero ) +USHORT ScTable::GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero ) const { - DBG_ASSERT(VALIDROW(nRow),"Falsche Zeilennummer"); + DBG_ASSERT(VALIDROW(nRow),"Invalid row number"); if (VALIDROW(nRow) && mpRowHeights) { - if (bHiddenAsZero && RowHidden(nRow)) + if (bHiddenAsZero && RowHidden( nRow, pStartRow, pEndRow)) return 0; else { ScFlatUInt16RowSegments::RangeData aData; if (!mpRowHeights->getRangeData(nRow, aData)) + { + if (pStartRow) + *pStartRow = nRow; + if (pEndRow) + *pEndRow = nRow; // TODO: What should we return in case the search fails? return 0; + } + // If bHiddenAsZero, pStartRow and pEndRow were initialized to + // boundaries of a non-hidden segment. Assume that the previous and + // next segment are hidden then and limit the current height + // segment. if (pStartRow) - *pStartRow = aData.mnRow1; + *pStartRow = (bHiddenAsZero ? std::max( *pStartRow, aData.mnRow1) : aData.mnRow1); if (pEndRow) - *pEndRow = aData.mnRow2; + *pEndRow = (bHiddenAsZero ? std::min( *pEndRow, aData.mnRow2) : aData.mnRow2); return aData.mnValue; } } else + { + if (pStartRow) + *pStartRow = nRow; + if (pEndRow) + *pEndRow = nRow; return (USHORT) ScGlobal::nStdRowHeight; + } } -ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) +ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const { DBG_ASSERT(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer"); @@ -2368,7 +2384,7 @@ ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) } -ULONG ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) +ULONG ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const { DBG_ASSERT(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer"); @@ -3036,7 +3052,7 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, bool bUpdateNoteCaptionPos } -ULONG ScTable::GetRowOffset( SCROW nRow ) +ULONG ScTable::GetRowOffset( SCROW nRow ) const { ULONG n = 0; if ( mpHiddenRows && mpRowHeights ) @@ -3059,7 +3075,7 @@ ULONG ScTable::GetRowOffset( SCROW nRow ) return n; } -SCROW ScTable::GetRowForHeight(ULONG nHeight) +SCROW ScTable::GetRowForHeight(ULONG nHeight) const { sal_uInt32 nSum = 0; @@ -3086,7 +3102,7 @@ SCROW ScTable::GetRowForHeight(ULONG nHeight) } -ULONG ScTable::GetColOffset( SCCOL nCol ) +ULONG ScTable::GetColOffset( SCCOL nCol ) const { ULONG n = 0; if ( pColWidth ) diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx index 2635b5821e4f..e7ee96367785 100644 --- a/sc/source/core/data/table5.cxx +++ b/sc/source/core/data/table5.cxx @@ -355,7 +355,7 @@ bool ScTable::HasRowPageBreak(SCROW nRow) const if (!ValidRow(nRow)) return false; - return maRowPageBreaks.count(nRow) > 0; + return maRowPageBreaks.find(nRow) != maRowPageBreaks.end(); } bool ScTable::HasColPageBreak(SCCOL nCol) const @@ -363,7 +363,7 @@ bool ScTable::HasColPageBreak(SCCOL nCol) const if (!ValidCol(nCol)) return false; - return maColPageBreaks.count(nCol) > 0; + return maColPageBreaks.find(nCol) != maColPageBreaks.end(); } bool ScTable::HasRowManualBreak(SCROW nRow) const @@ -371,7 +371,7 @@ bool ScTable::HasRowManualBreak(SCROW nRow) const if (!ValidRow(nRow)) return false; - return maRowManualBreaks.count(nRow) > 0; + return maRowManualBreaks.find(nRow) != maRowManualBreaks.end(); } bool ScTable::HasColManualBreak(SCCOL nCol) const @@ -379,7 +379,7 @@ bool ScTable::HasColManualBreak(SCCOL nCol) const if (!ValidCol(nCol)) return false; - return (maColManualBreaks.count(nCol) > 0); + return maColManualBreaks.find(nCol) != maColManualBreaks.end(); } SCROW ScTable::GetNextManualBreak(SCROW nRow) const @@ -483,15 +483,27 @@ Sequence<TablePageBreakData> ScTable::GetRowBreakData() const return aSeq; } -bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) +bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) const { if (!ValidRow(nRow)) + { + if (pFirstRow) + *pFirstRow = nRow; + if (pLastRow) + *pLastRow = nRow; return true; + } ScFlatBoolRowSegments::RangeData aData; if (!mpHiddenRows->getRangeData(nRow, aData)) + { // search failed. + if (pFirstRow) + *pFirstRow = nRow; + if (pLastRow) + *pLastRow = nRow; return true; + } if (pFirstRow) *pFirstRow = aData.mnRow1; @@ -502,7 +514,7 @@ bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) } -bool ScTable::RowHidden(SCROW nRow, SCROW& rLastRow) +bool ScTable::RowHidden(SCROW nRow, SCROW& rLastRow) const { rLastRow = nRow; if (!ValidRow(nRow)) @@ -517,7 +529,7 @@ bool ScTable::RowHidden(SCROW nRow, SCROW& rLastRow) return aData.mbValue; } -bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow) +bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nStartRow; while (nRow <= nEndRow) @@ -532,7 +544,7 @@ bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow) return false; } -bool ScTable::ColHidden(SCCOL nCol, SCCOL& rLastCol) +bool ScTable::ColHidden(SCCOL nCol, SCCOL& rLastCol) const { rLastCol = nCol; if (!ValidCol(nCol)) @@ -546,7 +558,7 @@ bool ScTable::ColHidden(SCCOL nCol, SCCOL& rLastCol) return aData.mbValue; } -bool ScTable::ColHidden(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) +bool ScTable::ColHidden(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) const { if (!ValidCol(nCol)) return true; @@ -627,7 +639,7 @@ void ScTable::CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, } } -SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nStartRow; ScFlatBoolRowSegments::RangeData aData; @@ -650,7 +662,7 @@ SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) return ::std::numeric_limits<SCROW>::max(); } -SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nEndRow; ScFlatBoolRowSegments::RangeData aData; @@ -673,7 +685,7 @@ SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow) return ::std::numeric_limits<SCROW>::max(); } -SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const { SCROW nCount = 0; SCROW nRow = nStartRow; @@ -694,7 +706,7 @@ SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW nEndRow) return nCount; } -sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) +sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) const { sal_uInt32 nHeight = 0; SCROW nRow = nStartRow; @@ -717,7 +729,7 @@ sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) return nHeight; } -SCCOLROW ScTable::LastHiddenColRow(SCCOLROW nPos, bool bCol) +SCCOLROW ScTable::LastHiddenColRow(SCCOLROW nPos, bool bCol) const { if (bCol) { @@ -741,7 +753,7 @@ SCCOLROW ScTable::LastHiddenColRow(SCCOLROW nPos, bool bCol) return ::std::numeric_limits<SCCOLROW>::max(); } -bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) +bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) const { if (!ValidRow(nRow)) return false; @@ -759,7 +771,7 @@ bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow) return aData.mbValue; } -bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) +bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) const { if (!ValidCol(nCol)) return false; @@ -777,7 +789,7 @@ bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol) return aData.mbValue; } -bool ScTable::HasFilteredRows(SCROW nStartRow, SCROW nEndRow) +bool ScTable::HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nStartRow; while (nRow <= nEndRow) @@ -837,7 +849,7 @@ void ScTable::SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered) mpFilteredCols->setFalse(nStartCol, nEndCol); } -SCROW ScTable::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nStartRow; ScFlatBoolRowSegments::RangeData aData; @@ -860,7 +872,7 @@ SCROW ScTable::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) return ::std::numeric_limits<SCROW>::max(); } -SCROW ScTable::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const { SCROW nRow = nEndRow; ScFlatBoolRowSegments::RangeData aData; @@ -883,7 +895,7 @@ SCROW ScTable::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) return ::std::numeric_limits<SCROW>::max(); } -SCROW ScTable::CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) +SCROW ScTable::CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const { SCROW nCount = 0; SCROW nRow = nStartRow; diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index c28d295275ae..828c9ae64c7d 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -121,24 +121,6 @@ enum ScanState ssStop }; -// ODFF names that are not written in the current mapping but to be recognized. -// New names will be written in a future relase, then exchange (!) with the -// names in formula/source/core/resource/core_resource.src to be able to still -// read the old names as well. -struct FunctionName -{ - const sal_Char* pName; - OpCode eOp; -}; -static const FunctionName aOdffAliases[] = { - // Renamed old names: - // XXX none yet. - // Renamed new names: - { "BINOM.DIST.RANGE", ocB }, // B -> BINOM.DIST.RANGE - { "LEGACY.TDIST", ocTDist } // TDIST -> LEGACY.TDIST -}; -static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]); - static const sal_Char* pInternal[ 1 ] = { "TTT" }; using namespace ::com::sun::star::i18n; @@ -2524,6 +2506,25 @@ BOOL ScCompiler::IsOpCode( const String& rName, bool bInArray ) } else if (mxSymbols->isODFF()) { + // ODFF names that are not written in the current mapping but to be + // recognized. New names will be written in a future relase, then + // exchange (!) with the names in + // formula/source/core/resource/core_resource.src to be able to still + // read the old names as well. + struct FunctionName + { + const sal_Char* pName; + OpCode eOp; + }; + static const FunctionName aOdffAliases[] = { + // Renamed old names: + // XXX none yet. + // Renamed new names: + { "BINOM.DIST.RANGE", ocB }, // B -> BINOM.DIST.RANGE + { "LEGACY.TDIST", ocTDist }, // TDIST -> LEGACY.TDIST + { "ORG.OPENOFFICE.EASTERSUNDAY", ocEasterSunday } // EASTERSUNDAY -> ORG.OPENOFFICE.EASTERSUNDAY + }; + static const size_t nOdffAliases = sizeof(aOdffAliases) / sizeof(aOdffAliases[0]); for (size_t i=0; i<nOdffAliases; ++i) { if (rName.EqualsIgnoreCaseAscii( aOdffAliases[i].pName)) diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 30aa0b8aa13e..35c63f52a92b 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -7097,22 +7097,75 @@ void ScInterpreter::ScText() if ( MustHaveParamCount( GetByte(), 2 ) ) { String sFormatString = GetString(); - double fVal = GetDouble(); String aStr; - Color* pColor = NULL; - LanguageType eCellLang; - const ScPatternAttr* pPattern = pDok->GetPattern( - aPos.Col(), aPos.Row(), aPos.Tab() ); - if ( pPattern ) - eCellLang = ((const SvxLanguageItem&) - pPattern->GetItem( ATTR_LANGUAGE_FORMAT )).GetValue(); - else - eCellLang = ScGlobal::eLnge; - if ( !pFormatter->GetPreviewStringGuess( sFormatString, fVal, aStr, - &pColor, eCellLang ) ) - PushIllegalArgument(); + bool bString = false; + double fVal = 0.0; + switch (GetStackType()) + { + case svError: + PopError(); + break; + case svDouble: + fVal = PopDouble(); + break; + case svString: + aStr = PopString(); + bString = true; + break; + default: + { + FormulaTokenRef xTok( PopToken()); + if (!nGlobalError) + { + PushTempToken( xTok); + // Temporarily override the ConvertStringToValue() + // error for GetCellValue() / GetCellValueOrZero() + USHORT nSErr = mnStringNoValueError; + mnStringNoValueError = errNotNumericString; + fVal = GetDouble(); + mnStringNoValueError = nSErr; + if (nGlobalError == errNotNumericString) + { + // Not numeric. + nGlobalError = 0; + PushTempToken( xTok); + aStr = GetString(); + bString = true; + } + } + } + } + if (nGlobalError) + PushError( nGlobalError); else - PushString(aStr); + { + String aResult; + Color* pColor = NULL; + LanguageType eCellLang; + const ScPatternAttr* pPattern = pDok->GetPattern( + aPos.Col(), aPos.Row(), aPos.Tab() ); + if ( pPattern ) + eCellLang = ((const SvxLanguageItem&) + pPattern->GetItem( ATTR_LANGUAGE_FORMAT )).GetValue(); + else + eCellLang = ScGlobal::eLnge; + if (bString) + { + if (!pFormatter->GetPreviewString( sFormatString, aStr, + aResult, &pColor, eCellLang)) + PushIllegalArgument(); + else + PushString( aResult); + } + else + { + if (!pFormatter->GetPreviewStringGuess( sFormatString, fVal, + aResult, &pColor, eCellLang)) + PushIllegalArgument(); + else + PushString( aResult); + } + } } } diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index dc87bba4c050..8d09cae60941 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -98,7 +98,6 @@ #include "convuno.hxx" #include "postit.hxx" #include "globstr.hrc" -#include "chartlis.hxx" #include "fprogressbar.hxx" #include "xltracer.hxx" @@ -4056,9 +4055,8 @@ void XclImpObjectManager::ConvertObjects() for( XclImpSheetDrawingMap::iterator aIt = maSheetDrawings.begin(), aEnd = maSheetDrawings.end(); aIt != aEnd; ++aIt ) aIt->second->ConvertObjects( aDffConv ); - ScChartListenerCollection* pChartListeners = GetDoc().GetChartListenerCollection(); - if( pChartListeners && (pChartListeners->GetCount() > 0) ) - pChartListeners->SetDirty(); + // #i112436# don't call ScChartListenerCollection::SetDirty here, + // instead use InterpretDirtyCells in ScDocument::CalcAfterLoad. } String XclImpObjectManager::GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx index f8bafa32f205..66f3ea613a3a 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx @@ -1234,10 +1234,31 @@ void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nFie const sal_Int32 nStringIndex) { DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); - DBG_ASSERT(aTables[nTable].size() >= static_cast<sal_uInt32>(nField), "wrong field"); - if (aTables[nTable].size() == static_cast<sal_uInt32>(nField)) + DBG_ASSERT(aTables[nTable].size() >= static_cast<size_t>(nField), "wrong field"); + if (aTables[nTable].size() == static_cast<size_t>(nField)) aTables[nTable].push_back(nStringIndex); - aTables[nTable][nField] = nStringIndex; + else + aTables[nTable][nField] = nStringIndex; +} + +void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, + const sal_Int32 nStringIndex, const sal_Int32 nEndField) +{ + DBG_ASSERT( nStartField <= nEndField, "bad field range"); + DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table"); + DBG_ASSERT(aTables[nTable].size() >= static_cast<size_t>(nStartField), "wrong field"); + ScMysalInt32Vec& rTable = aTables[nTable]; + size_t nSize = rTable.size(); + if (nSize == static_cast<size_t>(nStartField)) + rTable.insert( rTable.end(), static_cast<size_t>(nEndField - nStartField + 1), nStringIndex); + else + { + size_t nField = static_cast<size_t>(nStartField); + for ( ; nField < nSize && nField <= static_cast<size_t>(nEndField); ++nField) + rTable[nField] = nStringIndex; + if (nField <= static_cast<size_t>(nEndField)) + rTable.insert( rTable.end(), static_cast<size_t>(nEndField - nField + 1), nStringIndex); + } } rtl::OUString* ScRowStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField) diff --git a/sc/source/filter/xml/XMLStylesExportHelper.hxx b/sc/source/filter/xml/XMLStylesExportHelper.hxx index 34672aeef96e..79b19b7ce9ab 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.hxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.hxx @@ -286,6 +286,7 @@ public: virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields); sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField); void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex); + void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, const sal_Int32 nStringIndex, const sal_Int32 nEndField); virtual rtl::OUString* GetStyleName(const sal_Int32 nTable, const sal_Int32 nField); }; diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 0563f6430063..b34abb29443c 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2576,14 +2576,13 @@ void ScXMLExport::_ExportAutoStyles() } sal_Int32 nOld(nRow); nRow = pDoc->GetNextDifferentChangedRow(sal::static_int_cast<SCTAB>(nTable), static_cast<SCROW>(nRow), false); - for (sal_Int32 i = nOld + 1; i < nRow; ++i) - pRowStyles->AddFieldStyleName(nTable, i, nIndex); + if (nRow > nOld + 1) + pRowStyles->AddFieldStyleName(nTable, nOld + 1, nIndex, nRow - 1); } if (aCellAddress.EndRow > nRows) { sal_Int32 nIndex(pRowStyles->GetStyleNameIndex(nTable, nRows)); - for (sal_Int32 i = nRows + 1; i <= aCellAddress.EndRow; ++i) - pRowStyles->AddFieldStyleName(nTable, i, nIndex); + pRowStyles->AddFieldStyleName(nTable, nRows + 1, nIndex, aCellAddress.EndRow); } } } diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx index 4127f5246428..d061ea24b194 100644 --- a/sc/source/filter/xml/xmlstyle.cxx +++ b/sc/source/filter/xml/xmlstyle.cxx @@ -81,9 +81,11 @@ const XMLPropertyMapEntry aXMLScCellStylesProperties[] = MAP( "ConditionalFormatXML", XML_NAMESPACE_STYLE, XML_MAP, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_IMPORT_MAP ), MAP( "ConditionalFormatXML", XML_NAMESPACE_STYLE, XML_MAP, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_MAP ), MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER, CTF_SC_DIAGONALBLTR ), - MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTH ), + MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTH ), // #i102690# for old files + MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTHS, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTHS ), MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER, CTF_SC_DIAGONALTLBR ), - MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTH ), + MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTH ), // #i102690# for old files + MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTHS, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTHS ), MAP( "HoriJustify", XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_TYPE_PROP_PARAGRAPH|XML_SC_TYPE_HORIJUSTIFY|MID_FLAG_MERGE_PROPERTY, 0 ), MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_TEXT_ALIGN_SOURCE, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_HORIJUSTIFYSOURCE|MID_FLAG_MERGE_PROPERTY, 0 ), MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_REPEAT_CONTENT, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_HORIJUSTIFYREPEAT|MID_FLAG_MERGE_PROPERTY, 0 ), @@ -490,6 +492,18 @@ void ScXMLCellExportPropertyMapper::ContextFilter( pParaMarginBottomRel->maValue.clear(); } + // #i102690# old diagonal line attribute names without "s" are only read, not written + if (pDiagonalTLBRWidthState) + { + pDiagonalTLBRWidthState->mnIndex = -1; + pDiagonalTLBRWidthState->maValue.clear(); + } + if (pDiagonalBLTRWidthState) + { + pDiagonalBLTRWidthState->mnIndex = -1; + pDiagonalBLTRWidthState->maValue.clear(); + } + SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet); } diff --git a/sc/source/filter/xml/xmlstyle.hxx b/sc/source/filter/xml/xmlstyle.hxx index 07e7138afc71..f8abf5e6443d 100644 --- a/sc/source/filter/xml/xmlstyle.hxx +++ b/sc/source/filter/xml/xmlstyle.hxx @@ -90,6 +90,8 @@ extern const XMLPropertyMapEntry aXMLScTableStylesImportProperties[]; #define CTF_SC_DIAGONALTLBRWIDTH (XML_SC_CTF_START + 26) #define CTF_SC_DIAGONALBLTR (XML_SC_CTF_START + 27) #define CTF_SC_DIAGONALBLTRWIDTH (XML_SC_CTF_START + 28) +#define CTF_SC_DIAGONALTLBRWIDTHS (XML_SC_CTF_START + 29) +#define CTF_SC_DIAGONALBLTRWIDTHS (XML_SC_CTF_START + 30) #define CTF_SC_ROWHEIGHT (XML_SC_CTF_START + 50) #define CTF_SC_ROWOPTIMALHEIGHT (XML_SC_CTF_START + 51) diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 9a04e284bf45..3866bba63239 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -105,6 +105,7 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& XMLPropertyState* pAllBorderWidthProperty = NULL; XMLPropertyState* pBorderWidths[4] = { NULL, NULL, NULL, NULL }; XMLPropertyState* pDiagBorders[2] = { 0 }; + XMLPropertyState* pOldDiagBorderWidths[2] = { 0 }; // old attribute names without "s" XMLPropertyState* pDiagBorderWidths[2] = { 0 }; ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end()); @@ -134,8 +135,10 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& case CTF_SC_BOTTOMBORDERWIDTH : pBorderWidths[XML_LINE_BOTTOM] = &*property; break; case CTF_SC_DIAGONALTLBR : pDiagBorders[XML_LINE_TLBR] = &*property; break; case CTF_SC_DIAGONALBLTR : pDiagBorders[XML_LINE_BLTR] = &*property; break; - case CTF_SC_DIAGONALTLBRWIDTH : pDiagBorderWidths[XML_LINE_TLBR] = &*property; break; - case CTF_SC_DIAGONALBLTRWIDTH : pDiagBorderWidths[XML_LINE_BLTR] = &*property; break; + case CTF_SC_DIAGONALTLBRWIDTH : pOldDiagBorderWidths[XML_LINE_TLBR] = &*property; break; + case CTF_SC_DIAGONALTLBRWIDTHS : pDiagBorderWidths[XML_LINE_TLBR] = &*property; break; + case CTF_SC_DIAGONALBLTRWIDTH : pOldDiagBorderWidths[XML_LINE_BLTR] = &*property; break; + case CTF_SC_DIAGONALBLTRWIDTHS : pDiagBorderWidths[XML_LINE_BLTR] = &*property; break; } } } @@ -179,17 +182,23 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& } for( i = 0; i < 2; ++i ) { - if( pDiagBorders[i] && pDiagBorderWidths[i] ) + if( pDiagBorders[i] && ( pDiagBorderWidths[i] || pOldDiagBorderWidths[i] ) ) { table::BorderLine aBorderLine; pDiagBorders[i]->maValue >>= aBorderLine; table::BorderLine aBorderLineWidth; - pDiagBorderWidths[i]->maValue >>= aBorderLineWidth; + if (pDiagBorderWidths[i]) + pDiagBorderWidths[i]->maValue >>= aBorderLineWidth; // prefer new attribute + else + pOldDiagBorderWidths[i]->maValue >>= aBorderLineWidth; aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; aBorderLine.LineDistance = aBorderLineWidth.LineDistance; pDiagBorders[i]->maValue <<= aBorderLine; - pDiagBorderWidths[i]->mnIndex = -1; + if (pDiagBorderWidths[i]) + pDiagBorderWidths[i]->mnIndex = -1; + if (pOldDiagBorderWidths[i]) + pOldDiagBorderWidths[i]->mnIndex = -1; // reset mnIndex for old and new attribute if both are present } } diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index 6e7cfed9d95c..2f23166966b6 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -33,12 +33,16 @@ #include "dpcontrol.hxx" #include "dpcontrol.hrc" -#include "vcl/outdev.hxx" -#include "vcl/settings.hxx" -#include "vcl/wintypes.hxx" -#include "vcl/decoview.hxx" +#include <vcl/outdev.hxx> +#include <vcl/settings.hxx> +#include <vcl/wintypes.hxx> +#include <vcl/decoview.hxx> #include "strload.hxx" #include "global.hxx" +#include "scitems.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "patattr.hxx" #include "AccessibleFilterMenu.hxx" #include "AccessibleFilterTopWindow.hxx" @@ -55,7 +59,8 @@ using ::std::vector; using ::std::hash_map; using ::std::auto_ptr; -ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX, const Fraction* pZoomY) : +ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX, const Fraction* pZoomY, ScDocument* pDoc) : + mpDoc(pDoc), mpOutDev(pOutDev), mpStyle(pStyle), mbBaseButton(true), @@ -135,17 +140,28 @@ void ScDPFieldButton::draw() Point(maPos.X()+maSize.Width()-1, maPos.Y()+maSize.Height()-1)); // Field name. - Font aTextFont( mpStyle->GetLabelFont() ); - double fFontHeight = 12.0; - fFontHeight *= static_cast<double>(maZoomY.GetNumerator()) / static_cast<double>(maZoomY.GetDenominator()); - aTextFont.SetHeight(static_cast<long>(fFontHeight)); + // Get the font and size the same way as in scenario selection (lcl_DrawOneFrame in gridwin4.cxx) + Font aTextFont( mpStyle->GetAppFont() ); + if ( mpDoc ) + { + // use ScPatternAttr::GetFont only for font size + Font aAttrFont; + static_cast<const ScPatternAttr&>(mpDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)). + GetFont( aAttrFont, SC_AUTOCOL_BLACK, mpOutDev, &maZoomY ); + aTextFont.SetSize( aAttrFont.GetSize() ); + } mpOutDev->SetFont(aTextFont); + mpOutDev->SetTextColor(mpStyle->GetButtonTextColor()); Point aTextPos = maPos; - long nTHeight = static_cast<long>(fFontHeight); + long nTHeight = mpOutDev->GetTextHeight(); aTextPos.setX(maPos.getX() + nMargin); aTextPos.setY(maPos.getY() + (maSize.Height()-nTHeight)/2); + + mpOutDev->Push(PUSH_CLIPREGION); + mpOutDev->IntersectClipRegion(aRect); mpOutDev->DrawText(aTextPos, maText); + mpOutDev->Pop(); } if (mbPopupButton) diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index bfbeba2d1302..a5159d8a8043 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -486,11 +486,16 @@ void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN ) { SdrView * pView = pViewData->GetScDrawView(); - EditView & rEditView = pView->GetTextEditOutlinerView()->GetEditView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); String aStatusVal; LanguageType nLang = LANGUAGE_NONE; - bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + bool bIsLookUpWord = false; + if ( pOutView ) + { + EditView& rEditView = pOutView->GetEditView(); + bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + } rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); // disable thesaurus main menu and context menu entry if there is nothing to look up diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx index 15f0c9174cc8..45badf0c88fd 100644 --- a/sc/source/ui/inc/dpcontrol.hxx +++ b/sc/source/ui/inc/dpcontrol.hxx @@ -64,7 +64,8 @@ class ScAccessibleFilterMenu; class ScDPFieldButton { public: - ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX = NULL, const Fraction* pZoomY = NULL); + ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX = NULL, const Fraction* pZoomY = NULL, + ScDocument* pDoc = NULL); ~ScDPFieldButton(); void setText(const ::rtl::OUString& rText); @@ -86,6 +87,7 @@ private: ::rtl::OUString maText; Fraction maZoomX; Fraction maZoomY; + ScDocument* mpDoc; OutputDevice* mpOutDev; const StyleSettings* mpStyle; bool mbBaseButton; diff --git a/sc/source/ui/inc/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc index becd05165a4e..00b1658849d6 100644 --- a/sc/source/ui/inc/miscdlgs.hrc +++ b/sc/source/ui/inc/miscdlgs.hrc @@ -185,5 +185,4 @@ // Tab Bg Color #define TAB_BG_COLOR_CT_BORDER 1 #define TAB_BG_COLOR_SET_BGDCOLOR 2 -#define TAB_BG_COLOR_GB_BGDCOLOR 3 diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx index 241fc806022d..338609ae0e4d 100644 --- a/sc/source/ui/inc/tabbgcolordlg.hxx +++ b/sc/source/ui/inc/tabbgcolordlg.hxx @@ -32,7 +32,6 @@ #define SC_TABBGCOLORDLG_HXX #include <vcl/dialog.hxx> -#include <vcl/fixed.hxx> #include <vcl/imagebtn.hxx> #include <svtools/valueset.hxx> @@ -63,7 +62,6 @@ private: Control aBorderWin; ScTabBgColorValueSet aTabBgColorSet; - FixedLine aTabBgColorBox; OKButton aBtnOk; CancelButton aBtnCancel; HelpButton aBtnHelp; diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 106d196a8175..fb9c674a4488 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -482,6 +482,24 @@ public: BOOL IsSelCtrlMouseClick() { return bSelCtrlMouseClick; } static inline long ToPixel( USHORT nTwips, double nFactor ); + + /** while (rScrY <= nEndPixels && rPosY <= nEndRow) add pixels of row + heights converted with nPPTY to rScrY, optimized for row height + segments. Upon return rPosY is the last row evaluated <= nEndRow, rScrY + may be > nEndPixels! + */ + static void AddPixelsWhile( long & rScrY, long nEndPixels, + SCROW & rPosY, SCROW nEndRow, double nPPTY, + const ScDocument * pDoc, SCTAB nTabNo ); + + /** while (rScrY <= nEndPixels && rPosY >= nStartRow) add pixels of row + heights converted with nPPTY to rScrY, optimized for row height + segments. Upon return rPosY is the last row evaluated >= nStartRow, + rScrY may be > nEndPixels! + */ + static void AddPixelsWhileBackward( long & rScrY, long nEndPixels, + SCROW & rPosY, SCROW nStartRow, double nPPTY, + const ScDocument * pDoc, SCTAB nTabNo ); }; diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx index fdc4c9fd34bf..463c06d76712 100644 --- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -39,14 +39,15 @@ #include "scresid.hxx" #include "miscdlgs.hrc" -#include "tools/debug.hxx" -#include "tools/color.hxx" -#include "sfx2/objsh.hxx" -#include "svx/xtable.hxx" -#include "svx/drawitem.hxx" -#include "unotools/pathoptions.hxx" -#include "tools/resid.hxx" -#include "editeng/editrids.hrc" +#include <tools/debug.hxx> +#include <tools/color.hxx> +#include <sfx2/objsh.hxx> +#include <svx/xtable.hxx> +#include <svx/drawitem.hxx> +#include <unotools/pathoptions.hxx> +#include <tools/resid.hxx> +#include <editeng/editrids.hrc> +#include <editeng/eerdll.hxx> #include <boost/scoped_ptr.hpp> @@ -62,7 +63,6 @@ ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent, ModalDialog ( pParent, ScResId( RID_SCDLG_TAB_BG_COLOR ) ), aBorderWin ( this, ScResId( TAB_BG_COLOR_CT_BORDER ) ), aTabBgColorSet ( &aBorderWin, ScResId( TAB_BG_COLOR_SET_BGDCOLOR ), this ), - aTabBgColorBox ( this, ScResId( TAB_BG_COLOR_GB_BGDCOLOR ) ), aBtnOk ( this, ScResId( BTN_OK ) ), aBtnCancel ( this, ScResId( BTN_CANCEL ) ), aBtnHelp ( this, ScResId( BTN_HELP ) ), @@ -75,7 +75,6 @@ ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent, this->SetText( rTitle ); this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE); - aTabBgColorBox.SetText(rTitle); FillColorValueSets_Impl(); aTabBgColorSet.SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) ); aBtnOk.SetClickHdl( HDL(TabBgColorOKHdl_Impl) ); @@ -120,7 +119,7 @@ void ScTabBgColorDlg::FillColorValueSets_Impl() long nCount = pColorTable->Count(); XColorEntry* pEntry = NULL; Color aColWhite( COL_WHITE ); - String aStrWhite( ScResId( RID_SVXITEMS_COLOR_WHITE ) ); + String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) ); WinBits nBits = ( aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS); aTabBgColorSet.SetText( aTabBgColorNoColorText ); aTabBgColorSet.SetStyle( nBits ); diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index c284045c5b11..3fb2c74a9954 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -592,7 +592,7 @@ ScUndoDeleteMulti::ScUndoDeleteMulti( ScDocShell* pNewDocShell, __EXPORT ScUndoDeleteMulti::~ScUndoDeleteMulti() { - delete pRanges; + delete [] pRanges; } String __EXPORT ScUndoDeleteMulti::GetComment() const diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index f8b5c25c4a70..a64814d952ef 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -144,7 +144,7 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& Size aScrSize(nSizeX-1, nSizeY-1); // Check if the mouse cursor is clicking on the popup arrow box. - mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY())); + mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc)); mpFilterButton->setBoundingBox(aScrPos, aScrSize); Point aPopupPos; Size aPopupSize; diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index d8024e439173..ba73fbf00269 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -401,17 +401,13 @@ void __EXPORT ScGridWindow::Paint( const Rectangle& rRect ) nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX2, nTab ), nPPTX ); } - long nScrY = ScViewData::ToPixel( pDoc->GetRowHeight( nY1, nTab ), nPPTY ); - while ( nScrY <= aPixRect.Top() && nY1 < MAXROW ) - { - ++nY1; - nScrY += ScViewData::ToPixel( pDoc->GetRowHeight( nY1, nTab ), nPPTY ); - } + long nScrY = 0; + ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, MAXROW, nPPTY, pDoc, nTab); SCROW nY2 = nY1; - while ( nScrY <= aPixRect.Bottom() && nY2 < MAXROW ) + if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW) { ++nY2; - nScrY += ScViewData::ToPixel( pDoc->GetRowHeight( nY2, nTab ), nPPTY ); + ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab); } Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS ); // nicht weiterzeichnen @@ -750,6 +746,15 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( !bLogicText ) aOutputData.DrawStrings(FALSE); // in pixel MapMode + // edit cells and printer-metrics text must be before the buttons + // (DataPilot buttons contain labels in UI font) + + pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich)); + if ( bLogicText ) + aOutputData.DrawStrings(TRUE); // in logic MapMode if bTextWysiwyg is set + aOutputData.DrawEdit(TRUE); + pContentDev->SetMapMode(MAP_PIXEL); + // Autofilter- und Pivot-Buttons DrawButtons( nX1, nY1, nX2, nY2, aTabInfo, pContentDev ); // Pixel @@ -759,14 +764,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( rOpts.GetOption( VOPT_NOTES ) ) aOutputData.DrawNoteMarks(); - // Edit-Zellen - - pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich)); - if ( bLogicText ) - aOutputData.DrawStrings(TRUE); // in logic MapMode if bTextWysiwyg is set - aOutputData.DrawEdit(TRUE); - - pContentDev->SetMapMode(MAP_PIXEL); if ( !bGridFirst && ( bGrid || bPage ) ) { aOutputData.DrawGrid( bGrid, bPage ); @@ -1208,14 +1205,14 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2 { aComboButton.SetOutputDevice( pContentDev ); - ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY()); + ScDocument* pDoc = pViewData->GetDocument(); + ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc); SCCOL nCol; SCROW nRow; SCSIZE nArrY; SCSIZE nQuery; SCTAB nTab = pViewData->GetTabNo(); - ScDocument* pDoc = pViewData->GetDocument(); ScDBData* pDBData = NULL; ScQueryParam* pQueryParam = NULL; diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 961572fc0185..7b27ddf3f8cc 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -489,6 +489,8 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) // Horizontale Linien // + bool bHiddenRow = true; + SCROW nHiddenEndRow = -1; nPosY = nScrY; for (nArrY=1; nArrY+1<nArrCount; nArrY++) { @@ -503,9 +505,17 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage ) { for (SCROW i = nYplus1; i <= MAXROW; ++i) { + if (i > nHiddenEndRow) + bHiddenRow = pDoc->RowHidden(i, nTab, nHiddenEndRow); + /* TODO: optimize the row break thing for large hidden + * segments where HasRowBreak() has to be called + * nevertheless for each row, as a row break is drawn also + * for hidden rows, above them. This needed to be done only + * once per hidden segment, maybe giving manual breaks + * priority. Something like GetNextRowBreak() and + * GetNextManualRowBreak(). */ nBreak = pDoc->HasRowBreak(i, nTab); - bool bHidden = pDoc->RowHidden(i, nTab); - if (nBreak || !bHidden) + if (!bHiddenRow || nBreak) break; } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index b0b040f9b5e0..6d40d304fb13 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -171,12 +171,11 @@ public: private: void SetHashText(); - long GetMaxDigitWidth(); + long GetMaxDigitWidth(); // in logic units long GetSignWidth(); long GetDotWidth(); long GetExpWidth(); void TextChanged(); - long ConvertWidthLogicToPixel( long nWidth ) const; }; //================================================================== @@ -518,6 +517,10 @@ void ScDrawStringsVars::SetHashText() void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) { + // #i113045# do the single-character width calculations in logic units + if (bPixelToLogic) + nWidth = pOutput->pRefDevice->PixelToLogic(Size(nWidth,0)).Width(); + if (!pCell) return; @@ -565,6 +568,12 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) else if (c == sal_Unicode('E')) ++nExpCount; } + + // #i112250# A small value might be formatted as "0" when only counting the digits, + // but fit into the column when considering the smaller width of the decimal separator. + if (aString.EqualsAscii("0") && fVal != 0.0) + nDecimalCount = 1; + if (nDecimalCount) nWidth += (nMaxDigit - GetDotWidth()) * nDecimalCount; if (nSignCount) @@ -582,10 +591,6 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) } long nActualTextWidth = pOutput->pFmtDevice->GetTextWidth(aString); - - if (bPixelToLogic) - nActualTextWidth = ConvertWidthLogicToPixel(nActualTextWidth); - if (nActualTextWidth > nWidth) { // Even after the decimal adjustment the text doesn't fit. Give up. @@ -594,6 +599,7 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) } TextChanged(); + pLastCell = NULL; // #i113022# equal cell and format in another column may give different string } void ScDrawStringsVars::SetAutoText( const String& rAutoText ) @@ -638,9 +644,6 @@ long ScDrawStringsVars::GetMaxDigitWidth() long n = pOutput->pFmtDevice->GetTextWidth(String(cDigit)); nMaxDigitWidth = ::std::max(nMaxDigitWidth, n); } - - if (bPixelToLogic) - nMaxDigitWidth = ConvertWidthLogicToPixel(nMaxDigitWidth); return nMaxDigitWidth; } @@ -650,8 +653,6 @@ long ScDrawStringsVars::GetSignWidth() return nSignWidth; nSignWidth = pOutput->pFmtDevice->GetTextWidth(String('-')); - if (bPixelToLogic) - nSignWidth = ConvertWidthLogicToPixel(nSignWidth); return nSignWidth; } @@ -662,8 +663,6 @@ long ScDrawStringsVars::GetDotWidth() const ::rtl::OUString& sep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator; nDotWidth = pOutput->pFmtDevice->GetTextWidth(sep); - if (bPixelToLogic) - nDotWidth = ConvertWidthLogicToPixel(nDotWidth); return nDotWidth; } @@ -673,8 +672,6 @@ long ScDrawStringsVars::GetExpWidth() return nExpWidth; nExpWidth = pOutput->pFmtDevice->GetTextWidth(String('E')); - if (bPixelToLogic) - nExpWidth = ConvertWidthLogicToPixel(nExpWidth); return nExpWidth; } @@ -704,13 +701,6 @@ void ScDrawStringsVars::TextChanged() aTextSize = pRefDevice->LogicToPixel( aTextSize ); } -long ScDrawStringsVars::ConvertWidthLogicToPixel( long nWidth ) const -{ - Size aSize(nWidth, pOutput->pFmtDevice->GetTextHeight()); - aSize = pOutput->pRefDevice->LogicToPixel(aSize); - return aSize.Width(); -} - BOOL ScDrawStringsVars::HasEditCharacters() const { static const sal_Unicode pChars[] = diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index c034836d4d4a..7b35328f68bb 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1696,50 +1696,32 @@ SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, USHO if (pView) ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY); - SCROW nY; - USHORT nScrPosY = 0; - if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = (USHORT) aScrSize.Height(); - if (nDir==1) - nY = nPosY; // vorwaerts - else - nY = nPosY-1; // rueckwaerts - - BOOL bOut = FALSE; - for ( ; nScrPosY<=nScrSizeY && !bOut; nY+=nDir ) - { - SCsROW nRowNo = nY; - if ( nRowNo < 0 || nRowNo > MAXROW ) - bOut = TRUE; - else - { - USHORT nTSize = pDoc->GetRowHeight( nRowNo, nTabNo ); - if (nTSize) - { - long nSizeYPix = ToPixel( nTSize, nPPTY ); - nScrPosY = sal::static_int_cast<USHORT>( nScrPosY + (USHORT) nSizeYPix ); - } - else if ( nDir == 1 && nRowNo < MAXROW ) - { - // skip multiple hidden rows (forward only for now) - SCROW nNext = pDoc->FirstVisibleRow(nRowNo + 1, MAXROW, nTabNo); - if ( nNext > MAXROW ) - { - // same behavior as without the optimization: set bOut with nY=MAXROW+1 - nY = MAXROW+1; - bOut = TRUE; - } - else - nY = nNext - 1; // +=nDir advances to next visible row - } - } - } + SCROW nY; if (nDir==1) + { + // forward + nY = nPosY; + long nScrPosY = 0; + AddPixelsWhile( nScrPosY, nScrSizeY, nY, MAXROW, nPPTY, pDoc, nTabNo); + // Original loop ended on last evaluated +1 or if that was MAXROW even + // on MAXROW+2. + nY += (nY == MAXROW ? 2 : 1); nY -= nPosY; + } else + { + // backward + nY = nPosY-1; + long nScrPosY = 0; + AddPixelsWhileBackward( nScrPosY, nScrSizeY, nY, 0, nPPTY, pDoc, nTabNo); + // Original loop ended on last evaluated -1 or if that was 0 even on + // -2. + nY -= (nY == 0 ? 2 : 1); nY = (nPosY-1)-nY; + } if (nY>0) --nY; return nY; @@ -1855,16 +1837,10 @@ BOOL ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich, } if (nClickY > 0) - { - while ( rPosY<=MAXROW && nClickY >= nScrY ) - { - nScrY += ToPixel( pDoc->GetRowHeight( rPosY, nTabNo ), nPPTY ); - ++rPosY; - } - --rPosY; - } + AddPixelsWhile( nScrY, nClickY, rPosY, MAXROW, nPPTY, pDoc, nTabNo ); else { + /* TODO: could need some "SubPixelsWhileBackward" method */ while ( rPosY>0 && nClickY < nScrY ) { --rPosY; @@ -1984,20 +1960,24 @@ void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY ) SCROW nOldPosY = pThisTab->nPosY[eWhich]; long nTPosY = pThisTab->nTPosY[eWhich]; long nPixPosY = pThisTab->nPixPosY[eWhich]; - SCROW i; + SCROW i, nHeightEndRow; if ( nNewPosY > nOldPosY ) for ( i=nOldPosY; i<nNewPosY; i++ ) { - long nThis = pDoc->GetRowHeight( i,nTabNo ); - nTPosY -= nThis; - nPixPosY -= ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY); + long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow ); + SCROW nRows = std::min( nNewPosY, nHeightEndRow + 1) - i; + i = nHeightEndRow; + nTPosY -= nThis * nRows; + nPixPosY -= ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY) * nRows; } else for ( i=nNewPosY; i<nOldPosY; i++ ) { - long nThis = pDoc->GetRowHeight( i,nTabNo ); - nTPosY += nThis; - nPixPosY += ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY); + long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow ); + SCROW nRows = std::min( nOldPosY, nHeightEndRow + 1) - i; + i = nHeightEndRow; + nTPosY += nThis * nRows; + nPixPosY += ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY) * nRows; } pThisTab->nPosY[eWhich] = nNewPosY; @@ -3118,5 +3098,82 @@ ScAddress ScViewData::GetCurPos() const } +// static +void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY, + SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo ) +{ + SCROW nRow = rPosY; + while (rScrY <= nEndPixels && nRow <= nEndRow) + { + SCROW nHeightEndRow; + USHORT nHeight = pDoc->GetRowHeight( nRow, nTabNo, NULL, &nHeightEndRow); + if (nHeightEndRow > nEndRow) + nHeightEndRow = nEndRow; + if (!nHeight) + nRow = nHeightEndRow + 1; + else + { + SCROW nRows = nHeightEndRow - nRow + 1; + sal_Int64 nPixel = ToPixel( nHeight, nPPTY); + sal_Int64 nAdd = nPixel * nRows; + if (nAdd + rScrY > nEndPixels) + { + sal_Int64 nDiff = rScrY + nAdd - nEndPixels; + nRows -= static_cast<SCROW>(nDiff / nPixel); + nAdd = nPixel * nRows; + // We're looking for a value that satisfies loop condition. + if (nAdd + rScrY <= nEndPixels) + { + ++nRows; + nAdd += nPixel; + } + } + rScrY += static_cast<long>(nAdd); + nRow += nRows; + } + } + if (nRow > rPosY) + --nRow; + rPosY = nRow; +} +// static +void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels, + SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc, + SCTAB nTabNo ) +{ + SCROW nRow = rPosY; + while (rScrY <= nEndPixels && nRow >= nStartRow) + { + SCROW nHeightStartRow; + USHORT nHeight = pDoc->GetRowHeight( nRow, nTabNo, &nHeightStartRow, NULL); + if (nHeightStartRow < nStartRow) + nHeightStartRow = nStartRow; + if (!nHeight) + nRow = nHeightStartRow - 1; + else + { + SCROW nRows = nRow - nHeightStartRow + 1; + sal_Int64 nPixel = ToPixel( nHeight, nPPTY); + sal_Int64 nAdd = nPixel * nRows; + if (nAdd + rScrY > nEndPixels) + { + sal_Int64 nDiff = nAdd + rScrY - nEndPixels; + nRows -= static_cast<SCROW>(nDiff / nPixel); + nAdd = nPixel * nRows; + // We're looking for a value that satisfies loop condition. + if (nAdd + rScrY <= nEndPixels) + { + ++nRows; + nAdd += nPixel; + } + } + rScrY += static_cast<long>(nAdd); + nRow -= nRows; + } + } + if (nRow < rPosY) + ++nRow; + rPosY = nRow; +} |