diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 21 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 20 | ||||
-rw-r--r-- | sc/source/core/data/dpoutput.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/stlpool.cxx | 20 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 12 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/interpr2.cxx | 75 | ||||
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/html/htmlexp.cxx | 23 | ||||
-rw-r--r-- | sc/source/filter/inc/rtfexp.hxx | 8 | ||||
-rw-r--r-- | sc/source/filter/rtf/rtfexp.cxx | 135 | ||||
-rw-r--r-- | sc/source/ui/docshell/autostyl.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/docshell/documentlinkmgr.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/spellcheckcontext.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 2 |
19 files changed, 293 insertions, 80 deletions
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 52496653ab1b..8b1a8987acbb 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -379,6 +379,9 @@ ScColorScaleFormat::ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleForma { maColorScales.emplace_back(new ScColorScaleEntry(pDoc, *rxEntry)); } + + auto aCache = rFormat.GetCache(); + SetCache(aCache); } ScColorFormat* ScColorScaleFormat::Clone(ScDocument* pDoc) const @@ -440,6 +443,18 @@ const ScRangeList& ScColorFormat::GetRange() const return mpParent->GetRange(); } +std::vector<double> ScColorFormat::GetCache() const +{ + std::vector<double> empty; + return mpCache ? mpCache->maValues : empty; +} + +void ScColorFormat::SetCache(const std::vector<double>& aValues) +{ + mpCache.reset(new ScColorFormatCache); + mpCache->maValues = aValues; +} + std::vector<double>& ScColorFormat::getValues() const { if(!mpCache) @@ -512,6 +527,12 @@ void ScColorFormat::endRendering() mpCache.reset(); } +void ScColorFormat::updateValues() +{ + getMinValue(); + getMaxValue(); +} + namespace { sal_uInt8 GetColorValue( double nVal, double nVal1, sal_uInt8 nColVal1, double nVal2, sal_uInt8 nColVal2 ) diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 35a6ff99c699..72446f306562 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -73,6 +73,10 @@ void ScFormatEntry::endRendering() { } +void ScFormatEntry::updateValues() +{ +} + static bool lcl_HasRelRef( ScDocument* pDoc, const ScTokenArray* pFormula, sal_uInt16 nRecursion = 0 ) { if (pFormula) @@ -2040,6 +2044,14 @@ void ScConditionalFormat::endRendering() } } +void ScConditionalFormat::updateValues() +{ + for(auto& rxEntry : maEntries) + { + rxEntry->updateValues(); + } +} + void ScConditionalFormat::CalcAll() { for(const auto& rxEntry : maEntries) @@ -2287,6 +2299,14 @@ void ScConditionalFormatList::endRendering() } } +void ScConditionalFormatList::updateValues() +{ + for (auto const& it : m_ConditionalFormats) + { + it->updateValues(); + } +} + void ScConditionalFormatList::clear() { m_ConditionalFormats.clear(); diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index fe54b7c1086c..7c0e6f01ebaf 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -599,7 +599,11 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS case sheet::DataPilotFieldOrientation_ROW: { uno::Sequence<sheet::MemberResult> aResult = xLevRes->getResults(); - if (!lcl_MemberEmpty(aResult)) + // We want only to remove the DATA column if it is empty + // and not any other empty columns (to still show the + // header columns) + bool bSkip = lcl_MemberEmpty(aResult) && bIsDataLayout; + if (!bSkip) { ScDPOutLevelData tmp(nDim, nHierarchy, nLev, nDimPos, nNumFmt, aResult, aName, aCaption, bHasHiddenMember, bIsDataLayout, false); diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 8295b8033182..b40f0ceaa5f9 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -36,6 +36,7 @@ #include <svl/zformat.hxx> #include <vcl/keycodes.hxx> #include <vcl/virdev.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <unotools/charclass.hxx> @@ -772,7 +773,7 @@ void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgno OUString aUrlName( rURL ); SfxViewFrame* pFrame = nullptr; - const SfxObjectShell* pObjShell = nullptr; + SfxObjectShell* pObjShell = nullptr; OUString aReferName; if ( pScActiveViewShell ) { @@ -806,6 +807,9 @@ void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgno aUrlName = aNewUrlName; } + if (!SfxObjectShell::AllowedLinkProtocolFromDocument(aUrlName, pObjShell, pFrame ? pFrame->GetFrameWeld() : nullptr)) + return; + SfxStringItem aUrl( SID_FILE_NAME, aUrlName ); SfxStringItem aTarget( SID_TARGETNAME, rTarget ); if ( nScClickMouseModifier & KEY_SHIFT ) // control-click -> into new window diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx index 3939978633f3..ce8617a66150 100644 --- a/sc/source/core/data/stlpool.cxx +++ b/sc/source/core/data/stlpool.cxx @@ -411,14 +411,30 @@ ScStyleSheet* ScStyleSheetPool::FindCaseIns( const OUString& rName, SfxStyleFami CaseInsensitiveNamePredicate aPredicate(rName, eFam); std::vector<sal_Int32> aFoundPositions = GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate); + ScStyleSheet* first = nullptr; // first case insensitive match found for (const auto& rPos : aFoundPositions) { SfxStyleSheetBase *pFound = GetStyleSheetByPositionInIndex(rPos); // we do not know what kind of sheets we have. if (pFound->isScStyleSheet()) - return static_cast<ScStyleSheet*>(pFound); + { + if (pFound->GetName() == rName) // exact case sensitive match + return static_cast<ScStyleSheet*>(pFound); + if (!first) + first = static_cast<ScStyleSheet*>(pFound); + } } - return nullptr; + return first; +} + +ScStyleSheet* ScStyleSheetPool::FindAutoStyle(const OUString& rName) +{ + ScStyleSheet* pStyleSheet = FindCaseIns(rName, SfxStyleFamily::Para); + if (!pStyleSheet) + if (auto pFound = Find(ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para)) + if (pFound->isScStyleSheet()) // we do not know what kind of sheets we have + pStyleSheet = static_cast<ScStyleSheet*>(pFound); + return pStyleSheet; } void ScStyleSheetPool::setAllParaStandard() diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index c2de8dead98c..1f5d1fb34f4b 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -522,7 +522,10 @@ void ScTable::CopyToClip( for (SCCOL i = nCol1; i <= nCol2; i++) pTable->aCol[i].RemoveProtected(nRow1, nRow2); + mpCondFormatList->startRendering(); + mpCondFormatList->updateValues(); pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->rDocument, *mpCondFormatList)); + mpCondFormatList->endRendering(); } void ScTable::CopyToClip( diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index c7b93798bc58..c80ec572f1b5 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -231,6 +231,7 @@ private: inline bool MustHaveParamCount( short nAct, short nMust ); inline bool MustHaveParamCount( short nAct, short nMust, short nMax ); inline bool MustHaveParamCountMin( short nAct, short nMin ); + inline bool MustHaveParamCountMinWithStackCheck( short nAct, short nMin ); void PushParameterExpected(); void PushIllegalParameter(); void PushIllegalArgument(); @@ -1085,6 +1086,17 @@ inline bool ScInterpreter::MustHaveParamCountMin( short nAct, short nMin ) return false; } +inline bool ScInterpreter::MustHaveParamCountMinWithStackCheck( short nAct, short nMin ) +{ + assert(sp >= nAct); + if (sp < nAct) + { + PushParameterExpected(); + return false; + } + return MustHaveParamCountMin( nAct, nMin); +} + inline bool ScInterpreter::CheckStringPositionArgument( double & fVal ) { if (!std::isfinite( fVal)) diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index cc710efc353e..a957b916f64a 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -7515,7 +7515,7 @@ void ScInterpreter::ScVLookup() void ScInterpreter::ScSubTotal() { sal_uInt8 nParamCount = GetByte(); - if ( !MustHaveParamCountMin( nParamCount, 2 ) ) + if ( !MustHaveParamCountMinWithStackCheck( nParamCount, 2 ) ) return; // We must fish the 1st parameter deep from the stack! And push it on top. @@ -7562,7 +7562,7 @@ void ScInterpreter::ScSubTotal() void ScInterpreter::ScAggregate() { sal_uInt8 nParamCount = GetByte(); - if ( !MustHaveParamCountMin( nParamCount, 3 ) ) + if ( !MustHaveParamCountMinWithStackCheck( nParamCount, 3 ) ) return; const FormulaError nErr = nGlobalError; diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 632b04643a28..71c784c6b358 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -40,6 +40,7 @@ #include <dpobject.hxx> #include <tokenarray.hxx> #include <globalnames.hxx> +#include <stlpool.hxx> #include <stlsheet.hxx> #include <dpcache.hxx> @@ -2595,48 +2596,62 @@ void ScInterpreter::ScCurrent() void ScInterpreter::ScStyle() { sal_uInt8 nParamCount = GetByte(); - if (nParamCount >= 1 && nParamCount <= 3) - { - OUString aStyle2; // Template after timer - if (nParamCount >= 3) - aStyle2 = GetString().getString(); - tools::Long nTimeOut = 0; // timeout - if (nParamCount >= 2) - nTimeOut = static_cast<tools::Long>(GetDouble()*1000.0); - OUString aStyle1 = GetString().getString(); // Template for immediate + if (!MustHaveParamCount(nParamCount, 1, 3)) + return; - if (nTimeOut < 0) - nTimeOut = 0; + OUString aStyle2; // Style after timer + if (nParamCount >= 3) + aStyle2 = GetString().getString(); + tools::Long nTimeOut = 0; // timeout + if (nParamCount >= 2) + nTimeOut = static_cast<tools::Long>(GetDouble()*1000.0); + OUString aStyle1 = GetString().getString(); // Style for immediate - // Execute request to apply template - if ( !mrDoc.IsClipOrUndo() ) + if (nTimeOut < 0) + nTimeOut = 0; + + // Execute request to apply style + if ( !mrDoc.IsClipOrUndo() ) + { + SfxObjectShell* pShell = mrDoc.GetDocumentShell(); + if (pShell) { - SfxObjectShell* pShell = mrDoc.GetDocumentShell(); - if (pShell) + // Normalize style names right here, making sure that character case is correct, + // and that we only apply anything when there's something to apply + auto pPool = mrDoc.GetStyleSheetPool(); + if (!aStyle1.isEmpty()) { - // notify object shell directly! - bool bNotify = true; - if (aStyle2.isEmpty()) - { - const ScStyleSheet* pStyle = mrDoc.GetStyle(aPos.Col(), aPos.Row(), aPos.Tab()); - - if (pStyle && pStyle->GetName() == aStyle1) - bNotify = false; - } + if (auto pNewStyle = pPool->FindAutoStyle(aStyle1)) + aStyle1 = pNewStyle->GetName(); + else + aStyle1.clear(); + } + if (!aStyle2.isEmpty()) + { + if (auto pNewStyle = pPool->FindAutoStyle(aStyle2)) + aStyle2 = pNewStyle->GetName(); + else + aStyle2.clear(); + } + // notify object shell directly! + if (!aStyle1.isEmpty() || !aStyle2.isEmpty()) + { + const ScStyleSheet* pStyle = mrDoc.GetStyle(aPos.Col(), aPos.Row(), aPos.Tab()); + const bool bNotify = !pStyle + || (!aStyle1.isEmpty() && pStyle->GetName() != aStyle1) + || (!aStyle2.isEmpty() && pStyle->GetName() != aStyle2); if (bNotify) { ScRange aRange(aPos); - ScAutoStyleHint aHint( aRange, aStyle1, nTimeOut, aStyle2 ); - pShell->Broadcast( aHint ); + ScAutoStyleHint aHint(aRange, aStyle1, nTimeOut, aStyle2); + pShell->Broadcast(aHint); } } } - - PushDouble(0.0); } - else - PushIllegalParameter(); + + PushDouble(0.0); } static ScDdeLink* lcl_GetDdeLink( const sfx2::LinkManager* pLinkMgr, diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 9f5812a787a1..43c35cc7ac1a 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -3466,7 +3466,7 @@ void ScInterpreter::ScPercentile( bool bInclusive ) GetNumberSequenceArray( 1, aArray, false ); if ( aArray.empty() || nGlobalError != FormulaError::NONE ) { - SetError( FormulaError::NoValue ); + PushNoValue(); return; } if ( bInclusive ) @@ -3489,7 +3489,7 @@ void ScInterpreter::ScQuartile( bool bInclusive ) GetNumberSequenceArray( 1, aArray, false ); if ( aArray.empty() || nGlobalError != FormulaError::NONE ) { - SetError( FormulaError::NoValue ); + PushNoValue(); return; } if ( bInclusive ) diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 288d01d2eacc..1b165ff5c962 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -4019,7 +4019,15 @@ StackVar ScInterpreter::Interpret() else if (sp >= pCur->GetParamCount()) nStackBase = sp - pCur->GetParamCount(); else - nStackBase = sp; // underflow?!? + { + SAL_WARN("sc.core", "Stack anomaly at " << aPos.Format( + ScRefFlags::VALID | ScRefFlags::FORCE_DOC | ScRefFlags::TAB_3D, &mrDoc) + << " eOp: " << static_cast<int>(eOp) + << " params: " << static_cast<int>(pCur->GetParamCount()) + << " nStackBase: " << nStackBase << " sp: " << sp); + nStackBase = sp; + assert(!"underflow"); + } } switch( eOp ) diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx index 270312f594ce..d21fcf4d0035 100644 --- a/sc/source/filter/html/htmlexp.cxx +++ b/sc/source/filter/html/htmlexp.cxx @@ -64,6 +64,8 @@ #include <editutil.hxx> #include <ftools.hxx> #include <cellvalue.hxx> +#include <conditio.hxx> +#include <colorscale.hxx> #include <mtvelements.hxx> #include <editeng/flditem.hxx> @@ -881,10 +883,27 @@ void ScHTMLExport::WriteTables() void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow, SCTAB nTab ) { + std::optional<Color> aColorScale; ScAddress aPos( nCol, nRow, nTab ); ScRefCellValue aCell(*pDoc, aPos, rBlockPos); const ScPatternAttr* pAttr = pDoc->GetPattern( nCol, nRow, nTab ); const SfxItemSet* pCondItemSet = pDoc->GetCondResult( nCol, nRow, nTab, &aCell ); + if (!pCondItemSet) + { + ScConditionalFormatList* pCondList = pDoc->GetCondFormList(nTab); + const ScCondFormatItem& rCondItem = pAttr->GetItem(ATTR_CONDITIONAL); + const ScCondFormatIndexes& rCondIndex = rCondItem.GetCondFormatData(); + if (rCondIndex.size() > 0) + { + ScConditionalFormat* pCondFmt = pCondList->GetFormat(rCondIndex[0]); + if (pCondFmt) + { + const ScColorScaleFormat* pEntry = dynamic_cast<const ScColorScaleFormat*>(pCondFmt->GetEntry(0)); + if (pEntry) + aColorScale = pEntry->GetColor(aPos); + } + } + } const ScMergeFlagAttr& rMergeFlagAttr = pAttr->GetItem( ATTR_MERGE_FLAG, pCondItemSet ); if ( rMergeFlagAttr.IsOverlapped() ) @@ -1023,7 +1042,9 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SC ATTR_BACKGROUND, pCondItemSet ); Color aBgColor; - if ( rBrushItem.GetColor().GetAlpha() == 0 ) + if ( aColorScale ) + aBgColor = *aColorScale; + else if ( rBrushItem.GetColor().GetAlpha() == 0 ) aBgColor = aHTMLStyle.aBackgroundColor; // No unwanted background color else aBgColor = rBrushItem.GetColor(); diff --git a/sc/source/filter/inc/rtfexp.hxx b/sc/source/filter/inc/rtfexp.hxx index 0d5e69f79d8e..9d0b204540c7 100644 --- a/sc/source/filter/inc/rtfexp.hxx +++ b/sc/source/filter/inc/rtfexp.hxx @@ -19,17 +19,23 @@ #pragma once +#include <map> #include <memory> #include "expbase.hxx" #include <tools/solar.h> class ScRTFExport : public ScExportBase { - std::unique_ptr<sal_uLong[]> pCellX; // cumulative range in a table + std::unique_ptr<sal_uLong[]> m_pCellX; // cumulative range in a table + std::map<OUString, sal_Int32> m_pFontTable; + SvMemoryStream m_aFontStrm; + SvMemoryStream m_aDocStrm; + int AddFont( const SvxFontItem& rFontItem ); void WriteTab( SCTAB nTab ); void WriteRow( SCTAB nTab, SCROW nRow ); void WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ); + void WriteFontTable(const SvxFontItem& rFontItem, int nIndex); public: diff --git a/sc/source/filter/rtf/rtfexp.cxx b/sc/source/filter/rtf/rtfexp.cxx index 340e3cdab7c7..e53a488d06b5 100644 --- a/sc/source/filter/rtf/rtfexp.cxx +++ b/sc/source/filter/rtf/rtfexp.cxx @@ -19,9 +19,13 @@ #include <scitems.hxx> +#include <rtl/tencinfo.h> +#include <osl/thread.h> + #include <editeng/wghtitem.hxx> #include <editeng/postitem.hxx> #include <editeng/udlnitem.hxx> +#include <editeng/fontitem.hxx> #include <editeng/justifyitem.hxx> #include <svtools/rtfout.hxx> #include <svtools/rtfkeywd.hxx> @@ -46,7 +50,7 @@ void ScFormatFilterPluginImpl::ScExportRTF( SvStream& rStrm, ScDocument* pDoc, ScRTFExport::ScRTFExport( SvStream& rStrmP, ScDocument* pDocP, const ScRange& rRangeP ) : ScExportBase( rStrmP, pDocP, rRangeP ), - pCellX( new sal_uLong[ pDoc->MaxCol()+2 ] ) + m_pCellX( new sal_uLong[ pDoc->MaxCol()+2 ] ) { } @@ -59,28 +63,35 @@ void ScRTFExport::Write() rStrm.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_RTF ); rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ANSI ).WriteCharPtr( SAL_NEWLINE_STRING ); + m_aFontStrm.WriteChar( '{' ).WriteOString( OOO_STRING_SVTOOLS_RTF_FONTTBL ); + // Data for ( SCTAB nTab = aRange.aStart.Tab(); nTab <= aRange.aEnd.Tab(); nTab++ ) { if ( nTab > aRange.aStart.Tab() ) - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PAR ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PAR ); WriteTab( nTab ); } - rStrm.WriteChar( '}' ).WriteCharPtr( SAL_NEWLINE_STRING ); + m_aFontStrm.WriteChar( '}' ); + m_aFontStrm.Seek(0); + rStrm.WriteStream(m_aFontStrm); + m_aDocStrm.Seek(0); + rStrm.WriteStream(m_aDocStrm); + rStrm.WriteChar( '}' ).WriteOString( SAL_NEWLINE_STRING ); } void ScRTFExport::WriteTab( SCTAB nTab ) { - rStrm.WriteChar( '{' ).WriteCharPtr( SAL_NEWLINE_STRING ); + m_aDocStrm.WriteChar( '{' ).WriteOString( SAL_NEWLINE_STRING ); if ( pDoc->HasTable( nTab ) ) { - memset( &pCellX[0], 0, (pDoc->MaxCol()+2) * sizeof(sal_uLong) ); + memset( &m_pCellX[0], 0, (pDoc->MaxCol()+2) * sizeof(sal_uLong) ); SCCOL nCol; SCCOL nEndCol = aRange.aEnd.Col(); for ( nCol = aRange.aStart.Col(); nCol <= nEndCol; nCol++ ) { - pCellX[nCol+1] = pCellX[nCol] + pDoc->GetColWidth( nCol, nTab ); + m_pCellX[nCol+1] = m_pCellX[nCol] + pDoc->GetColWidth( nCol, nTab ); } SCROW nEndRow = aRange.aEnd.Row(); @@ -89,13 +100,13 @@ void ScRTFExport::WriteTab( SCTAB nTab ) WriteRow( nTab, nRow ); } } - rStrm.WriteChar( '}' ).WriteCharPtr( SAL_NEWLINE_STRING ); + m_aDocStrm.WriteChar( '}' ).WriteOString( SAL_NEWLINE_STRING ); } void ScRTFExport::WriteRow( SCTAB nTab, SCROW nRow ) { - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TROWD ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TRGAPH ).WriteCharPtr( "30" ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TRLEFT ).WriteCharPtr( "-30" ); - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TRRH ).WriteOString( OString::number(pDoc->GetRowHeight(nRow, nTab)) ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_TROWD ).WriteOString( OOO_STRING_SVTOOLS_RTF_TRGAPH ).WriteOString( "30" ).WriteOString( OOO_STRING_SVTOOLS_RTF_TRLEFT ).WriteOString( "-30" ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_TRRH ).WriteOString( OString::number(pDoc->GetRowHeight(nRow, nTab)) ); SCCOL nCol; SCCOL nEndCol = aRange.aEnd.Col(); for ( nCol = aRange.aStart.Col(); nCol <= nEndCol; nCol++ ) @@ -107,12 +118,12 @@ void ScRTFExport::WriteRow( SCTAB nTab, SCROW nRow ) const char* pChar; if ( rMergeAttr.GetColMerge() != 0 ) - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_CLMGF ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CLMGF ); else { const ScMergeFlagAttr& rMergeFlagAttr = pAttr->GetItem( ATTR_MERGE_FLAG ); if ( rMergeFlagAttr.IsHorOverlapped() ) - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_CLMRG ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CLMRG ); } switch( rVerJustifyItem.GetValue() ) @@ -124,25 +135,87 @@ void ScRTFExport::WriteRow( SCTAB nTab, SCROW nRow ) default: pChar = nullptr; break; } if ( pChar ) - rStrm.WriteCharPtr( pChar ); + m_aDocStrm.WriteOString( pChar ); - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_CELLX ).WriteOString( OString::number(pCellX[nCol+1]) ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELLX ).WriteOString( OString::number(m_pCellX[nCol+1]) ); if ( (nCol & 0x0F) == 0x0F ) - rStrm.WriteCharPtr( SAL_NEWLINE_STRING ); // Do not let lines get too long + m_aDocStrm.WriteOString( SAL_NEWLINE_STRING ); // Do not let lines get too long } - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PARD ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PLAIN ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_INTBL ).WriteCharPtr( SAL_NEWLINE_STRING ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PARD ).WriteOString( OOO_STRING_SVTOOLS_RTF_PLAIN ).WriteOString( OOO_STRING_SVTOOLS_RTF_INTBL ).WriteOString( SAL_NEWLINE_STRING ); - sal_uLong nStrmPos = rStrm.Tell(); + sal_uLong nStrmPos = m_aDocStrm.Tell(); for ( nCol = aRange.aStart.Col(); nCol <= nEndCol; nCol++ ) { WriteCell( nTab, nRow, nCol ); - if ( rStrm.Tell() - nStrmPos > 255 ) + if ( m_aDocStrm.Tell() - nStrmPos > 255 ) { // Do not let lines get too long - rStrm.WriteCharPtr( SAL_NEWLINE_STRING ); - nStrmPos = rStrm.Tell(); + m_aDocStrm.WriteOString( SAL_NEWLINE_STRING ); + nStrmPos = m_aDocStrm.Tell(); } } - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ROW ).WriteCharPtr( SAL_NEWLINE_STRING ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_ROW ).WriteOString( SAL_NEWLINE_STRING ); +} + +void ScRTFExport::WriteFontTable(const SvxFontItem& rFontItem, int nIndex) +{ + m_aFontStrm.WriteChar( '{' ); + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_F ); + m_aFontStrm.WriteOString( OString::number(nIndex) ); + + FontFamily eFamily = rFontItem.GetFamily(); + if (eFamily == FAMILY_DONTKNOW) + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_FNIL ); + else if (eFamily == FAMILY_DECORATIVE) + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_FDECOR ); + else if (eFamily == FAMILY_MODERN) + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_FMODERN ); + else if (eFamily == FAMILY_ROMAN) + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_FROMAN ); + else if (eFamily == FAMILY_SCRIPT) + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_FSCRIPT ); + else if (eFamily == FAMILY_SWISS) + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_FSWISS ); + + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_FPRQ ); + + sal_uInt16 nVal = 0; + FontPitch ePitch = rFontItem.GetPitch(); + if ( ePitch == PITCH_FIXED ) + nVal = 1; + else if ( ePitch == PITCH_VARIABLE ) + nVal = 2; + m_aFontStrm.WriteOString( OString::number(nVal) ); + + rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252; + rtl_TextEncoding eChrSet = rFontItem.GetCharSet(); + if (IsStarSymbol(rFontItem.GetFamilyName())) + eChrSet = RTL_TEXTENCODING_UTF8; + else if( RTL_TEXTENCODING_DONTKNOW == eChrSet ) + eChrSet = osl_getThreadTextEncoding(); + + m_aFontStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_FCHARSET ); + m_aFontStrm.WriteOString( OString::number(rtl_getBestWindowsCharsetFromTextEncoding( eChrSet )) ); + + m_aFontStrm.WriteChar( ' ' ); + RTFOutFuncs::Out_String( m_aFontStrm, rFontItem.GetFamilyName(), eDestEnc ); + m_aFontStrm.WriteOString( ";}" ); +} + +int ScRTFExport::AddFont(const SvxFontItem& rFontItem) +{ + auto nRet = m_pFontTable.size(); + auto itFont(m_pFontTable.find(rFontItem.GetFamilyName())); + if (itFont == m_pFontTable.end()) + { + m_pFontTable[rFontItem.GetFamilyName()] = nRet; + WriteFontTable(rFontItem, nRet); + } + else + { + nRet = itFont->second; + } + + return nRet; } void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) @@ -152,7 +225,7 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) const ScMergeFlagAttr& rMergeFlagAttr = pAttr->GetItem( ATTR_MERGE_FLAG ); if ( rMergeFlagAttr.IsHorOverlapped() ) { - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_CELL ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELL ); return ; } @@ -185,11 +258,15 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) bool bResetAttr(false); + const SvxFontItem& rFontItem = pAttr->GetItem( ATTR_FONT ); const SvxHorJustifyItem& rHorJustifyItem = pAttr->GetItem( ATTR_HOR_JUSTIFY ); const SvxWeightItem& rWeightItem = pAttr->GetItem( ATTR_FONT_WEIGHT ); const SvxPostureItem& rPostureItem = pAttr->GetItem( ATTR_FONT_POSTURE ); const SvxUnderlineItem& rUnderlineItem = pAttr->GetItem( ATTR_FONT_UNDERLINE ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_F ) + .WriteOString( OString::number(AddFont(rFontItem)) ); + const char* pChar; switch( rHorJustifyItem.GetValue() ) @@ -204,30 +281,30 @@ void ScRTFExport::WriteCell( SCTAB nTab, SCROW nRow, SCCOL nCol ) case SvxCellHorJustify::Repeat: default: pChar = OOO_STRING_SVTOOLS_RTF_QL; break; } - rStrm.WriteCharPtr( pChar ); + m_aDocStrm.WriteOString( pChar ); if ( rWeightItem.GetWeight() >= WEIGHT_BOLD ) { // bold bResetAttr = true; - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_B ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_B ); } if ( rPostureItem.GetPosture() != ITALIC_NONE ) { // italic bResetAttr = true; - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_I ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_I ); } if ( rUnderlineItem.GetLineStyle() != LINESTYLE_NONE ) { // underline bResetAttr = true; - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_UL ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_UL ); } - rStrm.WriteChar( ' ' ); - RTFOutFuncs::Out_String( rStrm, aContent ); - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_CELL ); + m_aDocStrm.WriteChar( ' ' ); + RTFOutFuncs::Out_String( m_aDocStrm, aContent ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_CELL ); if ( bResetAttr ) - rStrm.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PLAIN ); + m_aDocStrm.WriteOString( OOO_STRING_SVTOOLS_RTF_PLAIN ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/autostyl.cxx b/sc/source/ui/docshell/autostyl.cxx index 24c9bade1c50..5b6eaa30c296 100644 --- a/sc/source/ui/docshell/autostyl.cxx +++ b/sc/source/ui/docshell/autostyl.cxx @@ -83,7 +83,8 @@ void ScAutoStyleList::AddInitial( const ScRange& rRange, const OUString& rStyle1 IMPL_LINK_NOARG(ScAutoStyleList, InitHdl, Timer *, void) { - for (const auto& rInitial : aInitials) + std::vector<ScAutoStyleInitData> aLocalInitials(std::move(aInitials)); + for (const auto& rInitial : aLocalInitials) { // apply first style immediately pDocSh->DoAutoStyle(rInitial.aRange, rInitial.aStyle1); @@ -92,8 +93,6 @@ IMPL_LINK_NOARG(ScAutoStyleList, InitHdl, Timer *, void) if (rInitial.nTimeout) AddEntry(rInitial.nTimeout, rInitial.aRange, rInitial.aStyle2 ); } - - aInitials.clear(); } void ScAutoStyleList::AddEntry( sal_uLong nTimeout, const ScRange& rRange, const OUString& rStyle ) diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 432776b6a7ee..4010218b7b7b 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1540,11 +1540,7 @@ void ScDocShell::DoHardRecalc() void ScDocShell::DoAutoStyle( const ScRange& rRange, const OUString& rStyle ) { ScStyleSheetPool* pStylePool = m_aDocument.GetStyleSheetPool(); - ScStyleSheet* pStyleSheet = - pStylePool->FindCaseIns( rStyle, SfxStyleFamily::Para ); - if (!pStyleSheet) - pStyleSheet = static_cast<ScStyleSheet*>( - pStylePool->Find( ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para )); + ScStyleSheet* pStyleSheet = pStylePool->FindAutoStyle(rStyle); if (!pStyleSheet) return; diff --git a/sc/source/ui/docshell/documentlinkmgr.cxx b/sc/source/ui/docshell/documentlinkmgr.cxx index 3652df5cca0a..79a86d08b438 100644 --- a/sc/source/ui/docshell/documentlinkmgr.cxx +++ b/sc/source/ui/docshell/documentlinkmgr.cxx @@ -144,7 +144,7 @@ bool DocumentLinkManager::hasDdeOrOleOrWebServiceLinks(bool bDde, bool bOle, boo sfx2::SvBaseLink* pBase = rLink.get(); if (bDde && dynamic_cast<ScDdeLink*>(pBase)) return true; - if (bOle && dynamic_cast<SdrEmbedObjectLink*>(pBase)) + if (bOle && (dynamic_cast<SdrEmbedObjectLink*>(pBase) || dynamic_cast<SdrIFrameLink*>(pBase))) return true; if (bWebService && dynamic_cast<ScWebServiceLink*>(pBase)) return true; @@ -175,6 +175,13 @@ bool DocumentLinkManager::updateDdeOrOleOrWebServiceLinks(weld::Window* pWin) continue; } + SdrIFrameLink* pIFrameLink = dynamic_cast<SdrIFrameLink*>(pBase); + if (pIFrameLink) + { + pIFrameLink->Update(); + continue; + } + ScWebServiceLink* pWebserviceLink = dynamic_cast<ScWebServiceLink*>(pBase); if (pWebserviceLink) { diff --git a/sc/source/ui/view/spellcheckcontext.cxx b/sc/source/ui/view/spellcheckcontext.cxx index 224af6859f59..a1358dcd647a 100644 --- a/sc/source/ui/view/spellcheckcontext.cxx +++ b/sc/source/ui/view/spellcheckcontext.cxx @@ -327,12 +327,14 @@ void SpellCheckContext::ensureResults(SCCOL nCol, SCROW nRow) } // Cache miss, the cell needs spell-check.. - mpEngine->SetDefaultItem(SvxLanguageItem(eCellLang, EE_CHAR_LANGUAGE)); if (eType == CELLTYPE_STRING) mpEngine->SetText(aCell.mpString->getString()); else mpEngine->SetText(*aCell.mpEditText); + // it has to happen after we set text + mpEngine->SetDefaultItem(SvxLanguageItem(eCellLang, EE_CHAR_LANGUAGE)); + mpStatus->mbModified = false; mpEngine->CompleteOnlineSpelling(); std::unique_ptr<MisspellType> pRanges; diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index b4e8744cfe0d..49f14af06c7a 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -597,6 +597,8 @@ void ScViewFunc::PasteFromSystem() PasteFromSystem(SotClipboardFormatId::RICHTEXT); else if (aDataHelper.HasFormat(SotClipboardFormatId::HTML)) PasteFromSystem(SotClipboardFormatId::HTML); + else if (aDataHelper.HasFormat(SotClipboardFormatId::BITMAP)) + PasteFromSystem(SotClipboardFormatId::BITMAP); else if (aDataHelper.HasFormat(SotClipboardFormatId::HTML_SIMPLE)) PasteFromSystem(SotClipboardFormatId::HTML_SIMPLE); else if (aDataHelper.HasFormat(SotClipboardFormatId::SYLK)) |