diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:44:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:44:47 +0000 |
commit | 91fe6b97952aa6f7cef58327fd085a17db38ad95 (patch) | |
tree | 7a4412295bfb80e15a4936fe67d4bd7b96458ce8 /sc/source/core | |
parent | Releasing progress-linux version 4:24.2.1-4~progress7.99u1. (diff) | |
download | libreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.tar.xz libreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.zip |
Merging upstream version 4:24.2.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/source/core')
-rw-r--r-- | sc/source/core/data/SolverSettings.cxx | 220 | ||||
-rw-r--r-- | sc/source/core/data/clipcontext.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 17 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 14 | ||||
-rw-r--r-- | sc/source/core/data/drwlayer.cxx | 142 | ||||
-rw-r--r-- | sc/source/core/data/fillinfo.cxx | 4 |
7 files changed, 337 insertions, 70 deletions
diff --git a/sc/source/core/data/SolverSettings.cxx b/sc/source/core/data/SolverSettings.cxx index 60eb747f55..64badb8c27 100644 --- a/sc/source/core/data/SolverSettings.cxx +++ b/sc/source/core/data/SolverSettings.cxx @@ -11,6 +11,7 @@ #include <global.hxx> #include <table.hxx> #include <docsh.hxx> +#include <rtl/math.hxx> #include <solverutil.hxx> #include <unotools/charclass.hxx> #include <SolverSettings.hxx> @@ -73,6 +74,28 @@ void SolverSettings::Initialize() ReadParamValue(SP_LIMIT_BBDEPTH, m_sLimitBBDepth); ReadParamValue(SP_TIMEOUT, m_sTimeout); ReadParamValue(SP_ALGORITHM, m_sAlgorithm); + // Engine options common for DEPS and SCO + ReadParamValue(SP_SWARM_SIZE, m_sSwarmSize); + ReadParamValue(SP_LEARNING_CYCLES, m_sLearningCycles); + ReadParamValue(SP_GUESS_VARIABLE_RANGE, m_sGuessVariableRange); + ReadDoubleParamValue(SP_VARIABLE_RANGE_THRESHOLD, m_sVariableRangeThreshold); + ReadParamValue(SP_ACR_COMPARATOR, m_sUseACRComparator); + ReadParamValue(SP_RND_STARTING_POINT, m_sUseRandomStartingPoint); + ReadParamValue(SP_STRONGER_PRNG, m_sUseStrongerPRNG); + ReadParamValue(SP_STAGNATION_LIMIT, m_sStagnationLimit); + ReadDoubleParamValue(SP_STAGNATION_TOLERANCE, m_sTolerance); + ReadParamValue(SP_ENHANCED_STATUS, m_sEnhancedSolverStatus); + // DEPS Options + ReadDoubleParamValue(SP_AGENT_SWITCH_RATE, m_sAgentSwitchRate); + ReadDoubleParamValue(SP_SCALING_MIN, m_sScalingFactorMin); + ReadDoubleParamValue(SP_SCALING_MAX, m_sScalingFactorMax); + ReadDoubleParamValue(SP_CROSSOVER_PROB, m_sCrossoverProbability); + ReadDoubleParamValue(SP_COGNITIVE_CONST, m_sCognitiveConstant); + ReadDoubleParamValue(SP_SOCIAL_CONST, m_sSocialConstant); + ReadDoubleParamValue(SP_CONSTRICTION_COEFF, m_sConstrictionCoeff); + ReadDoubleParamValue(SP_MUTATION_PROB, m_sMutationProbability); + // SCO Options + ReadParamValue(SP_LIBRARY_SIZE, m_sLibrarySize); } // Returns the current value of the parameter in the object as a string @@ -119,6 +142,63 @@ OUString SolverSettings::GetParameter(SolverParameter eParam) case SP_ALGORITHM: return m_sAlgorithm; break; + case SP_SWARM_SIZE: + return m_sSwarmSize; + break; + case SP_LEARNING_CYCLES: + return m_sLearningCycles; + break; + case SP_GUESS_VARIABLE_RANGE: + return m_sGuessVariableRange; + break; + case SP_VARIABLE_RANGE_THRESHOLD: + return m_sVariableRangeThreshold; + break; + case SP_ACR_COMPARATOR: + return m_sUseACRComparator; + break; + case SP_RND_STARTING_POINT: + return m_sUseRandomStartingPoint; + break; + case SP_STRONGER_PRNG: + return m_sUseStrongerPRNG; + break; + case SP_STAGNATION_LIMIT: + return m_sStagnationLimit; + break; + case SP_STAGNATION_TOLERANCE: + return m_sTolerance; + break; + case SP_ENHANCED_STATUS: + return m_sEnhancedSolverStatus; + break; + case SP_AGENT_SWITCH_RATE: + return m_sAgentSwitchRate; + break; + case SP_SCALING_MIN: + return m_sScalingFactorMin; + break; + case SP_SCALING_MAX: + return m_sScalingFactorMax; + break; + case SP_CROSSOVER_PROB: + return m_sCrossoverProbability; + break; + case SP_COGNITIVE_CONST: + return m_sCognitiveConstant; + break; + case SP_SOCIAL_CONST: + return m_sSocialConstant; + break; + case SP_CONSTRICTION_COEFF: + return m_sConstrictionCoeff; + break; + case SP_MUTATION_PROB: + return m_sMutationProbability; + break; + case SP_LIBRARY_SIZE: + return m_sLibrarySize; + break; default: return ""; } @@ -188,6 +268,75 @@ void SolverSettings::SetParameter(SolverParameter eParam, OUString sValue) m_sAlgorithm = sValue; } break; + case SP_SWARM_SIZE: + m_sSwarmSize = sValue; + break; + case SP_LEARNING_CYCLES: + m_sLearningCycles = sValue; + break; + case SP_GUESS_VARIABLE_RANGE: + m_sGuessVariableRange = sValue; + break; + case SP_VARIABLE_RANGE_THRESHOLD: + m_sVariableRangeThreshold = sValue; + break; + case SP_ACR_COMPARATOR: + { + if (sValue == "0" || sValue == "1") + m_sUseACRComparator = sValue; + } + break; + case SP_RND_STARTING_POINT: + { + if (sValue == "0" || sValue == "1") + m_sUseRandomStartingPoint = sValue; + } + break; + case SP_STRONGER_PRNG: + { + if (sValue == "0" || sValue == "1") + m_sUseStrongerPRNG = sValue; + } + break; + case SP_STAGNATION_LIMIT: + m_sStagnationLimit = sValue; + break; + case SP_STAGNATION_TOLERANCE: + m_sTolerance = sValue; + break; + case SP_ENHANCED_STATUS: + { + if (sValue == "0" || sValue == "1") + m_sEnhancedSolverStatus = sValue; + } + break; + case SP_AGENT_SWITCH_RATE: + m_sAgentSwitchRate = sValue; + break; + case SP_SCALING_MIN: + m_sScalingFactorMin = sValue; + break; + case SP_SCALING_MAX: + m_sScalingFactorMax = sValue; + break; + case SP_CROSSOVER_PROB: + m_sCrossoverProbability = sValue; + break; + case SP_COGNITIVE_CONST: + m_sCognitiveConstant = sValue; + break; + case SP_SOCIAL_CONST: + m_sSocialConstant = sValue; + break; + case SP_CONSTRICTION_COEFF: + m_sConstrictionCoeff = sValue; + break; + case SP_MUTATION_PROB: + m_sMutationProbability = sValue; + break; + case SP_LIBRARY_SIZE: + m_sLibrarySize = sValue; + break; default: break; } @@ -321,12 +470,35 @@ void SolverSettings::SaveSolverSettings() sal_Int32 nConstrCount = m_aConstraints.size(); WriteParamValue(SP_CONSTR_COUNT, OUString::number(nConstrCount)); + // Solver engine options WriteParamValue(SP_INTEGER, m_sInteger); WriteParamValue(SP_NON_NEGATIVE, m_sNonNegative); WriteParamValue(SP_EPSILON_LEVEL, m_sEpsilonLevel); WriteParamValue(SP_LIMIT_BBDEPTH, m_sLimitBBDepth); WriteParamValue(SP_TIMEOUT, m_sTimeout); WriteParamValue(SP_ALGORITHM, m_sAlgorithm); + // Engine options common for DEPS and SCO + WriteParamValue(SP_SWARM_SIZE, m_sSwarmSize); + WriteParamValue(SP_LEARNING_CYCLES, m_sLearningCycles); + WriteParamValue(SP_GUESS_VARIABLE_RANGE, m_sGuessVariableRange); + WriteDoubleParamValue(SP_VARIABLE_RANGE_THRESHOLD, m_sVariableRangeThreshold); + WriteParamValue(SP_ACR_COMPARATOR, m_sUseACRComparator); + WriteParamValue(SP_RND_STARTING_POINT, m_sUseRandomStartingPoint); + WriteParamValue(SP_STRONGER_PRNG, m_sUseStrongerPRNG); + WriteParamValue(SP_STAGNATION_LIMIT, m_sStagnationLimit); + WriteDoubleParamValue(SP_STAGNATION_TOLERANCE, m_sTolerance); + WriteParamValue(SP_ENHANCED_STATUS, m_sEnhancedSolverStatus); + // DEPS Options + WriteDoubleParamValue(SP_AGENT_SWITCH_RATE, m_sAgentSwitchRate); + WriteDoubleParamValue(SP_SCALING_MIN, m_sScalingFactorMin); + WriteDoubleParamValue(SP_SCALING_MAX, m_sScalingFactorMax); + WriteDoubleParamValue(SP_CROSSOVER_PROB, m_sCrossoverProbability); + WriteDoubleParamValue(SP_COGNITIVE_CONST, m_sCognitiveConstant); + WriteDoubleParamValue(SP_SOCIAL_CONST, m_sSocialConstant); + WriteDoubleParamValue(SP_CONSTRICTION_COEFF, m_sConstrictionCoeff); + WriteDoubleParamValue(SP_MUTATION_PROB, m_sMutationProbability); + // SCO Options + WriteParamValue(SP_LIBRARY_SIZE, m_sLibrarySize); if (m_pDocShell) m_pDocShell->SetDocumentModified(); @@ -354,6 +526,26 @@ bool SolverSettings::ReadParamValue(SolverParameter eParam, OUString& rValue, bo return false; } +// Reads a parameter value of type 'double' from the named range and into rValue +bool SolverSettings::ReadDoubleParamValue(SolverParameter eParam, OUString& rValue) +{ + const auto iter = m_mNamedRanges.find(eParam); + assert(iter != m_mNamedRanges.end()); + OUString sRange = iter->second; + ScRangeData* pRangeData + = m_pRangeName->findByUpperName(ScGlobal::getCharClass().uppercase(sRange)); + if (pRangeData) + { + OUString sLocalizedValue = pRangeData->GetSymbol(); + double fValue = rtl::math::stringToDouble(sLocalizedValue, + ScGlobal::getLocaleData().getNumDecimalSep()[0], + ScGlobal::getLocaleData().getNumThousandSep()[0]); + rValue = OUString::number(fValue); + return true; + } + return false; +} + /* Writes a parameter value to the file as a named range. * Argument bQuoted indicates whether the value should be enclosed with quotes or not (used * for string expressions that must be enclosed with quotes) @@ -375,6 +567,22 @@ void SolverSettings::WriteParamValue(SolverParameter eParam, OUString sValue, bo m_pRangeName->insert(pNewEntry); } +// Writes a parameter value of type 'double' to the file as a named range +// The argument 'sValue' uses dot as decimal separator and needs to be localized before +// being written to the file +void SolverSettings::WriteDoubleParamValue(SolverParameter eParam, std::u16string_view sValue) +{ + const auto iter = m_mNamedRanges.find(eParam); + assert(iter != m_mNamedRanges.end()); + OUString sRange = iter->second; + double fValue = rtl::math::stringToDouble(sValue, '.', ','); + OUString sLocalizedValue = rtl::math::doubleToUString( + fValue, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, + ScGlobal::getLocaleData().getNumDecimalSep()[0], true); + ScRangeData* pNewEntry = new ScRangeData(m_rDoc, sRange, sLocalizedValue); + m_pRangeName->insert(pNewEntry); +} + void SolverSettings::GetEngineOptions(css::uno::Sequence<css::beans::PropertyValue>& aOptions) { sal_Int32 nOptionsSize = aOptions.getLength(); @@ -398,6 +606,12 @@ void SolverSettings::GetEngineOptions(css::uno::Sequence<css::beans::PropertyVal pParamValues[i] = css::beans::PropertyValue(sLOParamName, -1, nValue, css::beans::PropertyState_DIRECT_VALUE); } + if (sParamType == "double") + { + css::uno::Any fValue(sParamValue.toDouble()); + pParamValues[i] = css::beans::PropertyValue(sLOParamName, -1, fValue, + css::beans::PropertyState_DIRECT_VALUE); + } if (sParamType == "bool") { // The parameter NonNegative is a special case for MS compatibility @@ -438,6 +652,12 @@ void SolverSettings::SetEngineOptions(css::uno::Sequence<css::beans::PropertyVal aProp.Value >>= nValue; SetParameter(eParamId, OUString::number(nValue)); } + if (sParamType == "double") + { + double fValue = 0; + aProp.Value >>= fValue; + SetParameter(eParamId, OUString::number(fValue)); + } if (sParamType == "bool") { bool bValue = false; diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx index ce6974d423..be145f9954 100644 --- a/sc/source/core/data/clipcontext.cxx +++ b/sc/source/core/data/clipcontext.cxx @@ -403,8 +403,8 @@ bool CopyFromClipContext::isDateCell( const ScColumn& rCol, SCROW nRow ) const } CopyToClipContext::CopyToClipContext( - ScDocument& rDoc, bool bKeepScenarioFlags) : - ClipContextBase(rDoc), mbKeepScenarioFlags(bKeepScenarioFlags) {} + ScDocument& rDoc, bool bKeepScenarioFlags, bool bCopyChartRanges) : + ClipContextBase(rDoc), mbKeepScenarioFlags(bKeepScenarioFlags), mbCopyChartRanges(bCopyChartRanges) {} CopyToClipContext::~CopyToClipContext() {} diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 5bae9b7b9d..ceadfc2f3e 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -880,14 +880,16 @@ public: void ScColumn::CopyToClip( sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const { - pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray, - rCxt.isKeepScenarioFlags() ? (ScMF::All & ~ScMF::Scenario) : ScMF::All ); + if (!rCxt.isCopyChartRanges()) // No need to copy attributes for chart ranges + pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray, + rCxt.isKeepScenarioFlags() ? (ScMF::All & ~ScMF::Scenario) : ScMF::All ); { CopyToClipHandler aFunc(GetDoc(), *this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol)); sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2); } + if (!rCxt.isCopyChartRanges()) // No need to copy attributes for chart ranges { CopyTextAttrToClipHandler aFunc(rColumn.maCellTextAttrs); sc::ParseBlock(maCellTextAttrs.begin(), maCellTextAttrs, aFunc, nRow1, nRow2); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 7902722638..f0f4cc8326 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2582,10 +2582,21 @@ class FilterEntriesHandler if (bIsEmptyCell) { - if (!mrFilterEntries.mbHasEmpties) + if (mbFilteredRow) { - mrFilterEntries.push_back(ScTypedStrData(OUString(), 0.0, 0.0, ScTypedStrData::Standard, false, mbFilteredRow)); - mrFilterEntries.mbHasEmpties = true; + if (!mrFilterEntries.mbHasHiddenEmpties) + { + mrFilterEntries.push_back(ScTypedStrData(OUString(), 0.0, 0.0, ScTypedStrData::Standard, false, true)); + mrFilterEntries.mbHasHiddenEmpties = true; + } + } + else + { + if (!mrFilterEntries.mbHasUnHiddenEmpties) + { + mrFilterEntries.push_back(ScTypedStrData(OUString(), 0.0, 0.0, ScTypedStrData::Standard, false, false)); + mrFilterEntries.mbHasUnHiddenEmpties = true; + } } return; } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 15bb28fe61..2bca3a798f 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2218,6 +2218,7 @@ void ScDocument::CopyToClip(const ScClipParam& rClipParam, sc::CopyToClipContext aCxt(*pClipDoc, bKeepScenarioFlags); CopyRangeNamesToClip(pClipDoc, aClipRange, pMarks); + // 1. Copy selected cells for (SCTAB i = 0; i < nEndTab; ++i) { if (!maTabs[i] || i >= pClipDoc->GetTableCount() || !pClipDoc->maTabs[i]) @@ -2227,12 +2228,17 @@ void ScDocument::CopyToClip(const ScClipParam& rClipParam, continue; maTabs[i]->CopyToClip(aCxt, rClipParam.maRanges, pClipDoc->maTabs[i].get()); + } - if (mpDrawLayer && bIncludeObjects) + // 2. Copy drawing objects in the selection. Do in after the first "copy cells" pass, because + // the embedded objects (charts) coud reference cells from tabs not (yet) copied; doing it now + // allows to know what is already copied, to not owerwrite attributes of already copied data. + if (mpDrawLayer && bIncludeObjects) + { + for (SCTAB i = 0; i < nEndTab; ++i) { - // also copy drawing objects - tools::Rectangle aObjRect = GetMMRect( - aClipRange.aStart.Col(), aClipRange.aStart.Row(), aClipRange.aEnd.Col(), aClipRange.aEnd.Row(), i); + tools::Rectangle aObjRect = GetMMRect(aClipRange.aStart.Col(), aClipRange.aStart.Row(), + aClipRange.aEnd.Col(), aClipRange.aEnd.Row(), i); mpDrawLayer->CopyToClip(pClipDoc, i, aObjRect); } } diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 3f98fc770a..d5f2cc09b9 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -88,6 +88,7 @@ #include <docpool.hxx> #include <detfunc.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <clipcontext.hxx> #include <clipparam.hxx> #include <memory> @@ -1786,76 +1787,104 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec ScRange aClipRange = lcl_getClipRangeFromClipDoc(pClipDoc, nTab); SdrObjListIter aIter( pSrcPage, SdrIterMode::Flat ); - SdrObject* pOldObject = aIter.Next(); - while (pOldObject) + while (SdrObject* pOldObject = aIter.Next()) { + // do not copy internal objects (detective) and note captions + if (pOldObject->GetLayer() == SC_LAYER_INTERN) + continue; + + const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pOldObject); + if (IsNoteCaption(pObjData)) + continue; + // Catch objects where the object itself is inside the rectangle to be copied. bool bObjectInArea = rRange.Contains(pOldObject->GetCurrentBoundRect()); // Catch objects whose anchor is inside the rectangle to be copied. - const ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pOldObject); - if (pObjData) - bObjectInArea = bObjectInArea || aClipRange.Contains(pObjData->maStart); + if (!bObjectInArea && pObjData) + bObjectInArea = aClipRange.Contains(pObjData->maStart); + if (!bObjectInArea) + continue; + + if (!pDestModel) + { + pDestModel = pClipDoc->GetDrawLayer(); // does the document already have a drawing layer? + if (!pDestModel) + { + // allocate drawing layer in clipboard document only if there are objects to copy - // do not copy internal objects (detective) and note captions - if (bObjectInArea && pOldObject->GetLayer() != SC_LAYER_INTERN - && !IsNoteCaption(pOldObject)) + pClipDoc->InitDrawLayer(); //TODO: create contiguous pages + pDestModel = pClipDoc->GetDrawLayer(); + } + if (pDestModel) + pDestPage = pDestModel->GetPage(static_cast<sal_uInt16>(nTab)); + } + + OSL_ENSURE(pDestPage, "no page"); + if (pDestPage) { - if ( !pDestModel ) + // Clone to target SdrModel + rtl::Reference<SdrObject> pNewObject(pOldObject->CloneSdrObject(*pDestModel)); + uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) ); + if(!xOldChart.is())//#i110034# do not move charts as they lose all their data references otherwise { - pDestModel = pClipDoc->GetDrawLayer(); // does the document already have a drawing layer? - if ( !pDestModel ) + if (pObjData) { - // allocate drawing layer in clipboard document only if there are objects to copy - - pClipDoc->InitDrawLayer(); //TODO: create contiguous pages - pDestModel = pClipDoc->GetDrawLayer(); + // The object is anchored to cell. The position is determined by the start + // address. Copying into the clipboard does not change the anchor. + // ToDo: Adapt Offset relative to anchor cell size for cell anchored. + // ToDo: Adapt Offset and size for cell-anchored with resize objects. + // ToDo: Exclude object from resize if disallowed at object. + } + else + { + // The object is anchored to page. We make its position so, that the + // cell behind the object will have the same address in clipboard document as + // in source document. So we will be able to reconstruct the original cell + // address from position when pasting the object. + tools::Rectangle aObjRect = pOldObject->GetSnapRect(); + ScRange aPseudoAnchor = pDoc->GetRange(nTab, aObjRect, true /*bHiddenAsZero*/); + tools::Rectangle aSourceCellRect + = GetCellRect(*pDoc, aPseudoAnchor.aStart, false /*bMergedCell*/); + tools::Rectangle aDestCellRect + = GetCellRect(*pClipDoc, aPseudoAnchor.aStart, false); + Point aMove = aDestCellRect.TopLeft() - aSourceCellRect.TopLeft(); + pNewObject->NbcMove(Size(aMove.getX(), aMove.getY())); } - if (pDestModel) - pDestPage = pDestModel->GetPage( static_cast<sal_uInt16>(nTab) ); } - OSL_ENSURE( pDestPage, "no page" ); - if (pDestPage) + pDestPage->InsertObject(pNewObject.get()); + + // Store the chart's source data to the clipboad document, even when it's out of the + // copied range. It will be ignored when pasted to the same document; when pasted to + // another document, ScDocument::mpClipParam will provide the actually copied ranges, + // and the data copied here will be used to break connection and switch to own data + // in ScDrawLayer::CopyFromClip. + if (xOldChart && !xOldChart->hasInternalDataProvider()) { - // Clone to target SdrModel - rtl::Reference<SdrObject> pNewObject(pOldObject->CloneSdrObject(*pDestModel)); - uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) ); - if(!xOldChart.is())//#i110034# do not move charts as they lose all their data references otherwise + sc::CopyToClipContext aCxt(*pClipDoc, false, true); + OUString aChartName = static_cast<SdrOle2Obj*>(pOldObject)->GetPersistName(); + std::vector<ScRangeList> aRangesVector; + pDoc->GetChartRanges(aChartName, aRangesVector, *pDoc); + for (const ScRangeList& ranges : aRangesVector) { - if (pObjData) - { - // The object is anchored to cell. The position is determined by the start - // address. Copying into the clipboard does not change the anchor. - // ToDo: Adapt Offset relative to anchor cell size for cell anchored. - // ToDo: Adapt Offset and size for cell-anchored with resize objects. - // ToDo: Exclude object from resize if disallowed at object. - } - else + for (const ScRange& r : ranges) { - // The object is anchored to page. We make its position so, that the - // cell behind the object will have the same address in clipboard document as - // in source document. So we will be able to reconstruct the original cell - // address from position when pasting the object. - tools::Rectangle aObjRect = pOldObject->GetSnapRect(); - ScRange aPseudoAnchor - = pDoc->GetRange(nTab, aObjRect, true /*bHiddenAsZero*/); - tools::Rectangle aSourceCellRect - = GetCellRect(*pDoc, aPseudoAnchor.aStart, false /*bMergedCell*/); - tools::Rectangle aDestCellRect - = GetCellRect(*pClipDoc, aPseudoAnchor.aStart, false); - Point aMove = aDestCellRect.TopLeft() - aSourceCellRect.TopLeft(); - pNewObject->NbcMove(Size(aMove.getX(), aMove.getY())); + for (SCTAB i = r.aStart.Tab(); i <= r.aEnd.Tab(); ++i) + { + ScTable* pTab = pDoc->FetchTable(i); + ScTable* pClipTab = pClipDoc->FetchTable(i); + if (!pTab || !pClipTab) + continue; + pTab->CopyToClip(aCxt, r.aStart.Col(), r.aStart.Row(), r.aEnd.Col(), + r.aEnd.Row(), pClipTab); + } } } - - pDestPage->InsertObject( pNewObject.get() ); - - // no undo needed in clipboard document - // charts are not updated } - } - pOldObject = aIter.Next(); + // no undo needed in clipboard document + // charts are not updated + } } } @@ -1990,7 +2019,7 @@ void ScDrawLayer::CopyFromClip(ScDrawLayer* pClipModel, SCTAB nSourceTab, } else // Object is anchored to page. { - aSrcObjStart = pClipDoc->GetRange(nClipTab, pOldObject->GetCurrentBoundRect()).aStart; + aSrcObjStart = pClipDoc->GetRange(nSourceTab, pOldObject->GetCurrentBoundRect()).aStart; } if (!rSourceRange.Contains(aSrcObjStart)) { @@ -2895,16 +2924,15 @@ ScDrawObjData* ScDrawLayer::GetObjDataTab( SdrObject* pObj, SCTAB nTab ) return pData; } -bool ScDrawLayer::IsNoteCaption( SdrObject* pObj ) +bool ScDrawLayer::IsNoteCaption(const ScDrawObjData* pData) { - ScDrawObjData* pData = pObj ? GetObjData( pObj ) : nullptr; return pData && pData->meType == ScDrawObjData::CellNote; } ScDrawObjData* ScDrawLayer::GetNoteCaptionData( SdrObject* pObj, SCTAB nTab ) { - ScDrawObjData* pData = pObj ? GetObjDataTab( pObj, nTab ) : nullptr; - return (pData && pData->meType == ScDrawObjData::CellNote) ? pData : nullptr; + ScDrawObjData* pData = GetObjDataTab(pObj, nTab); + return IsNoteCaption(pData) ? pData : nullptr; } ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, bool bCreate ) diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 4a573e1c21..659a539799 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -296,7 +296,7 @@ bool handleConditionalFormat(ScConditionalFormatList& rCondFormList, const ScCon ScCondFormatData aData = pCondForm->GetData( pInfo->maCell, rAddr); - if (!aData.aStyleName.isEmpty()) + if (!bAnyCondition && !aData.aStyleName.isEmpty()) { SfxStyleSheetBase* pStyleSheet = pStlPool->Find( aData.aStyleName, SfxStyleFamily::Para ); @@ -337,7 +337,7 @@ bool handleConditionalFormat(ScConditionalFormatList& rCondFormList, const ScCon pTableInfo->addIconSetInfo(std::move(aData.pIconSet)); } - if (pInfo->mxColorScale && pInfo->pIconSet && pInfo->pDataBar) + if (bAnyCondition && pInfo->mxColorScale && pInfo->pIconSet && pInfo->pDataBar) break; } |