[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

2018-02-21 Thread Eike Rathke
 sc/inc/document.hxx  |5 -
 sc/source/core/data/documen2.cxx |7 +--
 sc/source/core/tool/interpr7.cxx |   28 +++-
 sc/source/ui/unoobj/funcuno.cxx  |2 +-
 4 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit 4a412bdf0387cc2cb59d656d0738a63a286ec497
Author: Eike Rathke 
Date:   Mon Feb 19 23:43:51 2018 +0100

Resolves: tdf#115710 let css::sheet::FunctionAccess execute WEBSERVICE

... independent of a LinkManager that is not present in the
interim FunctionAccess document. FunctionAccess is executed by
extensions, Add-Ons and macros that the user gave permission
already.

Change-Id: I9349a59ee24089c3657de7786b49e5e81946f175
(cherry picked from commit 121fda77b0cc16d54607a1f5f7b26c0f1050284f)
Reviewed-on: https://gerrit.libreoffice.org/50020
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index fedd52423c53..f0fc4563fe1d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -235,7 +235,8 @@ enum ScDocumentMode
 {
 SCDOCMODE_DOCUMENT,
 SCDOCMODE_CLIP,
-SCDOCMODE_UNDO
+SCDOCMODE_UNDO,
+SCDOCMODE_FUNCTIONACCESS
 };
 
 enum CommentCaptionState
@@ -430,6 +431,7 @@ private:
 boolbCalculatingFormulaTree;
 boolbIsClip;
 boolbIsUndo;
+boolbIsFunctionAccess;
 boolbIsVisible; // set from view ctor
 
 boolbIsEmbedded;// display/adjust 
Embedded area?
@@ -1372,6 +1374,7 @@ public:
 bool   IsClipboard() const { return 
bIsClip; }
 bool   IsUndoEnabled() const   { return 
mbUndoEnabled; }
 SC_DLLPUBLIC void  EnableUndo( bool bVal );
+boolIsFunctionAccess() const{ return 
bIsFunctionAccess; }
 
 bool IsAdjustHeightEnabled() const   { 
return mbAdjustHeightEnabled; }
 void EnableAdjustHeight( bool bVal ) { 
mbAdjustHeightEnabled = bVal; }
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 90afbfdca234..a55f48008bfe 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -181,12 +181,13 @@ ScDocument::ScDocument( ScDocumentMode eMode, 
SfxObjectShell* pDocShell ) :
 eHardRecalcState(HARDRECALCSTATE_OFF),
 nVisibleTab( 0 ),
 eLinkMode(LM_UNKNOWN),
-bAutoCalc( eMode == SCDOCMODE_DOCUMENT ),
+bAutoCalc( eMode == SCDOCMODE_DOCUMENT || eMode == 
SCDOCMODE_FUNCTIONACCESS ),
 bAutoCalcShellDisabled( false ),
 bForcedFormulaPending( false ),
 bCalculatingFormulaTree( false ),
 bIsClip( eMode == SCDOCMODE_CLIP ),
 bIsUndo( eMode == SCDOCMODE_UNDO ),
+bIsFunctionAccess( eMode == SCDOCMODE_FUNCTIONACCESS ),
 bIsVisible( false ),
 bIsEmbedded( false ),
 bInsertingFromOtherDoc( false ),
@@ -225,7 +226,9 @@ ScDocument::ScDocument( ScDocumentMode eMode, 
SfxObjectShell* pDocShell ) :
 
 eSrcSet = osl_getThreadTextEncoding();
 
-if ( eMode == SCDOCMODE_DOCUMENT )
+/* TODO: for SCDOCMODE_FUNCTIONACCESS it might not even be necessary to
+ * have all of these available. */
+if ( eMode == SCDOCMODE_DOCUMENT || eMode == SCDOCMODE_FUNCTIONACCESS )
 {
 xPoolHelper = new ScPoolHelper( this );
 
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index 9af943e05bca..710bfa9483a0 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -256,6 +256,21 @@ static ScWebServiceLink* lcl_GetWebServiceLink(const 
sfx2::LinkManager* pLinkMgr
 return nullptr;
 }
 
+static bool lcl_FunctionAccessLoadWebServiceLink( OUString& rResult, 
ScDocument* pDoc, const OUString& rURI )
+{
+// For FunctionAccess service always force a changed data update.
+ScWebServiceLink aLink( pDoc, rURI);
+if (aLink.DataChanged( OUString(), css::uno::Any()) != 
sfx2::SvBaseLink::UpdateResult::SUCCESS)
+return false;
+
+if (!aLink.HasResult())
+return false;
+
+rResult = aLink.GetResult();
+
+return true;
+}
+
 void ScInterpreter::ScWebservice()
 {
 sal_uInt8 nParamCount = GetByte();
@@ -279,7 +294,18 @@ void ScInterpreter::ScWebservice()
 
 if (!mpLinkManager)
 {
-PushError(FormulaError::NoValue);
+if (!pDok->IsFunctionAccess() || 
pDok->HasLinkFormulaNeedingCheck())
+{
+PushError( FormulaError::NoValue);
+}
+else
+{
+OUString aResult;
+if (lcl_FunctionAccessLoadWebServiceLink( 

[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

2018-02-17 Thread Eike Rathke
 sc/inc/dbdata.hxx|1 +
 sc/source/ui/docshell/docsh5.cxx |   21 ++---
 2 files changed, 19 insertions(+), 3 deletions(-)

New commits:
commit 54fac33e16550c1dd95c89362130229ba2b54270
Author: Eike Rathke 
Date:   Thu Feb 15 12:50:40 2018 +0100

Resolves: tdf#115046 don't restore a sheet-local DBData from temporary

And don't clear AutoFilter button flags in the new temporary range.

Change-Id: I273de1e04632ac99c267523b2843665d257fd361
(cherry picked from commit 74d30155c5067271fb98bacbcb895c215e61678d)
Reviewed-on: https://gerrit.libreoffice.org/49810
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 9412f23b7c65..ca1a19f10263 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -122,6 +122,7 @@ public:
 
 const OUString& GetName() const { return aName; }
 const OUString& GetUpperName() const { return aUpper; }
+SCTAB   GetTab() const  { return nTable; }
 voidGetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, 
SCROW& rRow2) const;
 SC_DLLPUBLIC void GetArea(ScRange& rRange) const;
 voidSetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2);
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index d247d39ab25d..4599c2da6065 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -222,8 +222,10 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, 
ScGetDBMode eMode, ScGe
 // other ranges, use the document global temporary anonymous range
 // instead. But, if AutoFilter is to be toggled then do use the
 // sheet-local DB range.
+bool bSheetLocal = true;
 if (eMode != SC_DB_AUTOFILTER && pNoNameData->HasAutoFilter())
 {
+bSheetLocal = false;
 pNoNameData = aDocument.GetAnonymousDBData();
 if (!pNoNameData)
 {
@@ -231,14 +233,24 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, 
ScGetDBMode eMode, ScGe
 nTab, nStartCol, nStartRow, nEndCol, nEndRow, 
true, bHasHeader);
 aDocument.SetAnonymousDBData( pNoNameData);
 }
+// ScDocShell::CancelAutoDBRange() would restore the
+// sheet-local anonymous DBData from pOldAutoDBRange, unset so
+// that won't happen with data of a previous sheet-local
+// DBData.
+delete pOldAutoDBRange;
+pOldAutoDBRange = nullptr;
 }
-
-if ( !pOldAutoDBRange )
+else if (!pOldAutoDBRange)
 {
 // store the old unnamed database range with its settings for 
undo
 // (store at the first change, get the state before all 
changes)
 pOldAutoDBRange = new ScDBData( *pNoNameData );
 }
+else if (pOldAutoDBRange->GetTab() != pNoNameData->GetTab())
+{
+// Different sheet-local unnamed DB range than the previous 
one.
+*pOldAutoDBRange = *pNoNameData;
+}
 
 SCCOL nOldX1;   // take old range 
away cleanly
 SCROW nOldY1;   //! (UNDO ???)
@@ -255,7 +267,10 @@ ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, 
ScGetDBMode eMode, ScGe
 nStartCol <= nOldY2 && nOldY1 <= nEndCol)
 bHasHeader = true;
 
-DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2 );
+// Remove AutoFilter button flags only for sheet-local DB range,
+// not if a temporary is used.
+if (bSheetLocal)
+DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2 );
 
 pNoNameData->SetSortParam( ScSortParam() ); // reset 
parameter
 pNoNameData->SetQueryParam( ScQueryParam() );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

2018-02-14 Thread Eike Rathke
 sc/inc/stringutil.hxx  |7 +++
 sc/source/core/data/column3.cxx|   10 +++---
 sc/source/core/tool/stringutil.cxx |3 ++-
 sc/source/filter/rtf/eeimpars.cxx  |1 +
 4 files changed, 17 insertions(+), 4 deletions(-)

New commits:
commit 1a1fc4ad83539b63d4dace3ddd3e24a54bf44791
Author: Eike Rathke 
Date:   Tue Feb 13 17:10:21 2018 +0100

ScSetStringParam::mbCheckLinkFormula for HTML and RTF import

 This is a combination of 3 commits.

Introduce ScSetStringParam::mbCheckLinkFormula

(cherry picked from commit 5a93c51e3b7f455ff5d4cfc9e8b6e510fc126b75)

Handle ScSetStringParam::mbCheckLinkFormula in ScColumn::ParseString()

(cherry picked from commit 271d9ebfe0c4fc57ea6f01a9c048021e5429dd15)

 Conflicts:
sc/source/core/data/column3.cxx

ScSetStringParam::mbCheckLinkFormula for HTML and RTF import

(cherry picked from commit 98c0bd7ffd008015623b2c5eb8630649394d76f6)

d6b0705140baacdb872560f7031efaf0c03f0e00
7cf7cf12142322cbffd5160e9a8dce55efd36be5

Change-Id: I2028fc53f9778606778cd8629611752acd3f1a1c
Reviewed-on: https://gerrit.libreoffice.org/49709
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
index c208332b48f6..219a80cd452a 100644
--- a/sc/inc/stringutil.hxx
+++ b/sc/inc/stringutil.hxx
@@ -88,6 +88,13 @@ struct SAL_WARN_UNUSED SC_DLLPUBLIC ScSetStringParam
 
 sc::StartListeningType meStartListening;
 
+/** When true and the string results in a compiled formula, check the
+formula tokens for presence of functions that could trigger access to
+external resources. This is to be set to true in import filter code,
+but not for user input.
+ */
+bool mbCheckLinkFormula;
+
 ScSetStringParam();
 
 /**
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 28445f7c469a..8e36534e8461 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1721,11 +1721,15 @@ bool ScColumn::ParseString(
 rCell.set(rPool.intern(rString));
 }
 else // = Formula
-rCell.set(
-new ScFormulaCell(
+{
+ScFormulaCell* pFormulaCell = new ScFormulaCell(
 pDocument, ScAddress(nCol, nRow, nTabP), rString,
 
formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_DEFAULT, 
eConv),
-ScMatrixMode::NONE));
+ScMatrixMode::NONE);
+if (aParam.mbCheckLinkFormula)
+pDocument->CheckLinkFormulaNeedingCheck( 
*pFormulaCell->GetCode());
+rCell.set( pFormulaCell);
+}
 }
 else if ( cFirstChar == '\'') // 'Text
 {
diff --git a/sc/source/core/tool/stringutil.cxx 
b/sc/source/core/tool/stringutil.cxx
index afcbe7412474..f52646c980af 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -30,7 +30,8 @@ ScSetStringParam::ScSetStringParam() :
 mbDetectNumberFormat(true),
 meSetTextNumFormat(Never),
 mbHandleApostrophe(true),
-meStartListening(sc::SingleCellListening)
+meStartListening(sc::SingleCellListening),
+mbCheckLinkFormula(false)
 {
 }
 
diff --git a/sc/source/filter/rtf/eeimpars.cxx 
b/sc/source/filter/rtf/eeimpars.cxx
index 0e6eab3bc56c..e0202ce7e6fe 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -330,6 +330,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, 
double nOutputFactor, SvNu
 aParam.mbDetectNumberFormat = true;
 aParam.meSetTextNumFormat = 
ScSetStringParam::SpecialNumberOnly;
 aParam.mbHandleApostrophe = false;
+aParam.mbCheckLinkFormula = true;
 
 if (!aValStr.isEmpty())
 mpDoc->SetValue( nCol, nRow, nTab, fVal );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

2018-01-27 Thread Eike Rathke
 sc/inc/document.hxx|2 ++
 sc/source/core/data/documen8.cxx   |   10 ++
 sc/source/core/data/formulacell.cxx|3 +--
 sc/source/filter/excel/excform.cxx |1 +
 sc/source/filter/excel/excform8.cxx|1 +
 sc/source/filter/excel/impop.cxx   |1 +
 sc/source/filter/oox/formulabuffer.cxx |4 
 7 files changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 2bef4debcf7650f3b3922134dff0332d4a95da3f
Author: Eike Rathke 
Date:   Wed Jan 17 22:22:55 2018 +0100

CheckLinkFormulaNeedingCheck() for .xls and .xlsx formula cells

 This is a combination of 3 commits.

Move implementation to CheckLinkFormulaNeedingCheck() for further reuse

(cherry picked from commit 55e484c7bcd3ef218e08d3fd93f97bf98fd8cb7f)

CheckLinkFormulaNeedingCheck() for .xlsx cell formulas

(cherry picked from commit f96dbc3dd9c33202f75e29ef49d962386595995d)

CheckLinkFormulaNeedingCheck() for .xls cell formulas

(cherry picked from commit 6bc48275558c3f76c4da25eb8af3c48583ac5599)

a6dd195f7eb4d43483e87eeca59f651e7bf2dcb8
2587fbc4fec39b6f2c8e71815a2953dee308

Change-Id: I541d2b6e12a88371c064b901b00e71206ee0c18e
Reviewed-on: https://gerrit.libreoffice.org/48143
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 30c15bcea696..fedd52423c53 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1941,6 +1941,8 @@ public:
 
 boolHasLinkFormulaNeedingCheck() const  { return 
bLinkFormulaNeedingCheck; }
 voidSetLinkFormulaNeedingCheck(bool bSet)   { 
bLinkFormulaNeedingCheck = bSet; }
+/** Check token array and set link check if ocDde/ocWebservice is 
contained. */
+SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode 
);
 
 voidSetRangeOverflowType(sal_uInt32 nType)  { 
nRangeOverflowType = nType; }
 boolHasRangeOverflow() const{ return 
nRangeOverflowType != 0; }
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 79eee1794b0e..9cf09ddb4c70 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -86,6 +86,7 @@
 #include "stringutil.hxx"
 #include 
 #include 
+#include 
 
 #include 
 
@@ -1151,6 +1152,15 @@ void ScDocument::UpdateRefAreaLinks( UpdateRefMode 
eUpdateRefMode,
 }
 }
 
+void ScDocument::CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode )
+{
+if (HasLinkFormulaNeedingCheck())
+return;
+
+if (rCode.HasOpCodeRPN(ocDde) || rCode.HasOpCodeRPN(ocWebservice))
+SetLinkFormulaNeedingCheck(true);
+}
+
 // TimerDelays etc.
 void ScDocument::KeyInput()
 {
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 444a66b33196..809a04de325d 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1370,8 +1370,7 @@ void ScFormulaCell::CompileXML( 
sc::CompileFormulaContext& rCxt, ScProgress& rPr
 
 //  After loading, it must be known if ocDde/ocWebservice is in any formula
 //  (for external links warning, CompileXML is called at the end of 
loading XML file)
-if (!pDocument->HasLinkFormulaNeedingCheck() && 
(pCode->HasOpCodeRPN(ocDde) || pCode->HasOpCodeRPN(ocWebservice)))
-pDocument->SetLinkFormulaNeedingCheck(true);
+pDocument->CheckLinkFormulaNeedingCheck(*pCode);
 
 //volatile cells must be added here for import
 if( pCode->IsRecalcModeAlways() || pCode->IsRecalcModeForced() ||
diff --git a/sc/source/filter/excel/excform.cxx 
b/sc/source/filter/excel/excform.cxx
index 8ed97f50c82e..312f8ce153c5 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -157,6 +157,7 @@ void ImportExcel::Formula(
 {
 pCell = new ScFormulaCell((), aScPos, *pResult);
 pCell->GetCode()->WrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8);
+rDoc.getDoc().CheckLinkFormulaNeedingCheck( *pCell->GetCode());
 rDoc.getDoc().EnsureTable(aScPos.Tab());
 rDoc.setFormulaCell(aScPos, pCell);
 SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, pCell);
diff --git a/sc/source/filter/excel/excform8.cxx 
b/sc/source/filter/excel/excform8.cxx
index 089b6da9bcdb..b72d0c03bf2c 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -730,6 +730,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& 
rpTokArray, XclImpStream& aIn,
 << nMerk0 << ocClose;
 aPool >> aStack;
 pExtName->CreateDdeData( GetDoc(), aApplic, 
aTopic );
+GetDoc().SetLinkFormulaNeedingCheck(true);
  

[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

2017-11-22 Thread Eike Rathke
 sc/inc/stringutil.hxx   |8 +++-
 sc/source/core/data/column3.cxx |   12 ++--
 sc/source/ui/undo/undocell.cxx  |4 +++-
 3 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit ad07d83af2a2b7df29223891bc028a4e7aedfe72
Author: Eike Rathke 
Date:   Tue Nov 21 15:33:58 2017 +0100

Resolves: tdf#103234 undo replacing text with formula

 This is a combination of 3 commits.

tdf#103234 undo replacing text with formula

if this isn't what we want, then presumably ScSetStringParam shouldn't
exist here at all

Reviewed-on: https://gerrit.libreoffice.org/45008
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 
(cherry picked from commit 466c3564058aae4946cdd21eab9dfef529554d90)

Invert logic of ScSetStringParam::* enum value checks, tdf#103234 follow-up

In preparation for adding a new enum value to keep existing
formatting in any case.

(cherry picked from commit f2f0a7c5a9d8185fedef5c737d1b7479b9fc0c1e)

Keep number format on string cell content Undo, tdf#103234 follow-up

(cherry picked from commit ba9833a1d63747eaa5124271a1ac51cb926bce7a)

c15a900adba0281d1267d95f821e1e898f80f566
18c281211e6eeb4816da13972c360df85d577491

Change-Id: I17318c38948bc19b7148276935830f83356c7ed2
Reviewed-on: https://gerrit.libreoffice.org/45026
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
index 3f9b0dbccaa2..c208332b48f6 100644
--- a/sc/inc/stringutil.hxx
+++ b/sc/inc/stringutil.hxx
@@ -31,7 +31,7 @@ class SvNumberFormatter;
  * Store parameters used in the ScDocument::SetString() method.  Various
  * options for string-setting operation are specified herein.
  */
-struct SC_DLLPUBLIC ScSetStringParam
+struct SAL_WARN_UNUSED SC_DLLPUBLIC ScSetStringParam
 {
 enum TextFormatPolicy
 {
@@ -47,6 +47,12 @@ struct SC_DLLPUBLIC ScSetStringParam
 SpecialNumberOnly,
 
 /**
+ * Keep an existing number format, do not set Text number format and do
+ * not set another number format.
+ */
+Keep,
+
+/**
  * Never set Text number format.
  */
 Never
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 7942ad881bc0..28445f7c469a 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1795,7 +1795,8 @@ bool ScColumn::ParseString(
 }
 }
 }
-else if (aParam.meSetTextNumFormat != ScSetStringParam::Always)
+else if (aParam.meSetTextNumFormat == ScSetStringParam::Never ||
+ aParam.meSetTextNumFormat == 
ScSetStringParam::SpecialNumberOnly)
 {
 // Only check if the string is a regular number.
 const LocaleDataWrapper* pLocale = 
aParam.mpNumFormatter->GetLocaleData();
@@ -1821,7 +1822,14 @@ bool ScColumn::ParseString(
 
 if (rCell.meType == CELLTYPE_NONE)
 {
-if (aParam.meSetTextNumFormat != ScSetStringParam::Never && 
aParam.mpNumFormatter->IsNumberFormat(rString, nIndex, nVal))
+// If we reach here with ScSetStringParam::SpecialNumberOnly it
+// means a simple number was not detected above, so test for
+// special numbers. In any case ScSetStringParam::Always does not
+// mean always, but only always for content that could be any
+// numeric.
+if ((aParam.meSetTextNumFormat == ScSetStringParam::Always ||
+ aParam.meSetTextNumFormat == 
ScSetStringParam::SpecialNumberOnly) &&
+aParam.mpNumFormatter->IsNumberFormat(rString, nIndex, 
nVal))
 {
 // Set the cell format type to Text.
 applyTextNumFormat(*this, nRow, aParam.mpNumFormatter);
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index a087a20d79c1..c85e2d8aece1 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -459,7 +459,9 @@ void ScUndoSetCell::SetValue( const ScCellValue& rVal )
 {
 ScSetStringParam aParam;
 aParam.setTextInput();
-rDoc.SetString(maPos, rVal.mpString->getString());
+// Undo only cell content, without setting any number format.
+aParam.meSetTextNumFormat = ScSetStringParam::Keep;
+rDoc.SetString(maPos, rVal.mpString->getString(), );
 }
 break;
 case CELLTYPE_EDIT:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

2017-07-13 Thread Markus Mohrhard
 sc/inc/colorscale.hxx  |   18 -
 sc/source/core/data/colorscale.cxx |   65 ++---
 sc/source/filter/xml/xmlcondformat.cxx |   13 +-
 sc/source/filter/xml/xmlcondformat.hxx |1 
 4 files changed, 88 insertions(+), 9 deletions(-)

New commits:
commit 6ed7a3085216caf29f9066154fccc6ee2f1b953d
Author: Markus Mohrhard 
Date:   Thu Mar 16 22:43:43 2017 +0100

repaint whole range for range based cond formats, tdf#105696

The range based cond formats need to be repainted across the whole
range. This ensures that a change in condition which affects all cells
causes a repaint.

Change-Id: Ie6dd10088a1c11c1bafd1faa9c429a35a6469ff2
Reviewed-on: https://gerrit.libreoffice.org/35302
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 
(cherry picked from commit 49922897d68835ae4e5c850b3c55107157fe7548)
Reviewed-on: https://gerrit.libreoffice.org/39713
Reviewed-by: Eike Rathke 

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 840b6824963d..ab94b22a34d3 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -49,6 +49,7 @@ private:
 std::unique_ptr mpCell;
 std::unique_ptr mpListener;
 ScColorScaleEntryType meType;
+ScConditionalFormat* mpFormat;
 
 public:
 ScColorScaleEntry(double nVal, const Color& rCol);
@@ -74,6 +75,8 @@ public:
 
 ScColorScaleEntryType GetType() const { return meType;}
 void SetType( ScColorScaleEntryType eType );
+
+void SetRepaintCallback(ScConditionalFormat* pParent);
 };
 
 namespace databar
@@ -97,7 +100,10 @@ struct SC_DLLPUBLIC ScDataBarFormatData
 meAxisPosition(databar::AUTOMATIC),
 mnMinLength(0),
 mnMaxLength(100),
-mbOnlyBar(false){}
+mbOnlyBar(false),
+mpUpperLimit(new ScColorScaleEntry()),
+mpLowerLimit(new ScColorScaleEntry())
+{}
 
 ScDataBarFormatData(const ScDataBarFormatData& r):
 maPositiveColor(r.maPositiveColor),
@@ -114,8 +120,12 @@ struct SC_DLLPUBLIC ScDataBarFormatData
 
 if(r.mpLowerLimit)
 mpLowerLimit.reset( new ScColorScaleEntry(*r.mpLowerLimit));
+else
+mpLowerLimit.reset(new ScColorScaleEntry());
 if(r.mpUpperLimit)
 mpUpperLimit.reset( new ScColorScaleEntry(*r.mpUpperLimit));
+else
+mpUpperLimit.reset(new ScColorScaleEntry());
 }
 
 /**
@@ -255,6 +265,8 @@ public:
 virtual ~ScColorScaleFormat() override;
 virtual ScColorFormat* Clone(ScDocument* pDoc) const override;
 
+virtual void SetParent(ScConditionalFormat* pParent) override;
+
 Color* GetColor(const ScAddress& rAddr) const;
 void AddEntry(ScColorScaleEntry* pEntry);
 
@@ -288,6 +300,8 @@ public:
 ScDataBarFormat(ScDocument* pDoc, const ScDataBarFormat& rFormat);
 virtual ScColorFormat* Clone(ScDocument* pDoc) const override;
 
+virtual void SetParent(ScConditionalFormat* pParent) override;
+
 ScDataBarInfo* GetDataBarInfo(const ScAddress& rAddr) const;
 
 void SetDataBarData( ScDataBarFormatData* pData );
@@ -348,6 +362,8 @@ public:
 
 virtual ScColorFormat* Clone(ScDocument* pDoc) const override;
 
+virtual void SetParent(ScConditionalFormat* pParent) override;
+
 ScIconSetInfo* GetIconSetInfo(const ScAddress& rAddr) const;
 
 void SetIconSetData( ScIconSetFormatData* pData );
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index cfa93309ec63..a3b1290a2652 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -156,21 +156,24 @@ bool ScFormulaListener::NeedsRepaint() const
 
 ScColorScaleEntry::ScColorScaleEntry():
 mnVal(0),
-meType(COLORSCALE_VALUE)
+meType(COLORSCALE_VALUE),
+mpFormat(nullptr)
 {
 }
 
 ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol):
 mnVal(nVal),
 maColor(rCol),
-meType(COLORSCALE_VALUE)
+meType(COLORSCALE_VALUE),
+mpFormat(nullptr)
 {
 }
 
 ScColorScaleEntry::ScColorScaleEntry(const ScColorScaleEntry& rEntry):
 mnVal(rEntry.mnVal),
 maColor(rEntry.maColor),
-meType(rEntry.meType)
+meType(rEntry.meType),
+mpFormat(rEntry.mpFormat)
 {
 if(rEntry.mpCell)
 {
@@ -184,13 +187,16 @@ ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, 
const ScColorScaleEntry&
 mnVal(rEntry.mnVal),
 maColor(rEntry.maColor),
 mpCell(),
-meType(rEntry.meType)
+meType(rEntry.meType),
+mpFormat(rEntry.mpFormat)
 {
 if(rEntry.mpCell)
 {
 mpCell.reset(new ScFormulaCell(*rEntry.mpCell, 
*rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, 
ScCloneFlags::NoMakeAbsExternal));
 mpCell->StartListeningTo( pDoc );
 mpListener.reset(new ScFormulaListener(mpCell.get()));
+if (mpFormat)
+

[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

2017-06-15 Thread Eike Rathke
 sc/inc/externalrefmgr.hxx|2 +-
 sc/source/ui/docshell/externalrefmgr.cxx |   13 +++--
 2 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 3d6797cde0663f3a558568a26ad19c7b5c98efa7
Author: Eike Rathke 
Date:   Wed Jun 14 23:30:57 2017 +0200

Resolves: tdf#104875 defer filter detection to first load/update of external

 This is a combination of 2 commits.

This could never have been meant

Since commit 67b374980f340faa2695001984aaf98886a32fad
executing ScDocumentLoader::GetFilterName() twice if there was no stored
filter, and still executing it if there was one, even if the comment says we
shouldn't.

(cherry picked from commit 1bc793f8ab8f9b4ce435bd3585f9579df4a11819)

Resolves: tdf#104875 defer filter detection to first load/update of external

Attempting to access all linked external documents right on load time was
specifically nasty for non-local URIs (unmounted smb, http, ...)

(cherry picked from commit 416752b9e4bc4605c479d3eff7797be9f0ef2a38)

f4a7414dfe36875b505c73b8c963b650eeffe204

Change-Id: Iaf4b88e63b3987fb661df0e9b095f06b29076894
Reviewed-on: https://gerrit.libreoffice.org/38819
Reviewed-by: Eike Rathke 
Tested-by: Jenkins 

diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 27002763d88e..5a63a0030797 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -772,7 +772,7 @@ private:
  */
 ScDocument& cacheNewDocShell( sal_uInt16 nFileId, SrcShell& rSrcShell );
 
-void maybeLinkExternalFile(sal_uInt16 nFileId);
+void maybeLinkExternalFile( sal_uInt16 nFileId, bool bDeferFilterDetection 
= false );
 
 /**
  * Try to create a "real" file name from the relative path.  The original
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx 
b/sc/source/ui/docshell/externalrefmgr.cxx
index c8680615b789..a83a4799c879 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2479,7 +2479,6 @@ SfxObjectShellRef 
ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
 rFilter = pFileData->maFilterName;  // don't overwrite stored 
filter with guessed filter
 else
 ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false);
-ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false);
 std::shared_ptr pFilter = 
ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName(rFilter);
 
 if (pFileData->maRelativeName.isEmpty())
@@ -2594,7 +2593,7 @@ bool ScExternalRefManager::isFileLoadable(const OUString& 
rFile) const
 return true;// for http and others, Exists doesn't work, but the 
URL can still be opened
 }
 
-void ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
+void ScExternalRefManager::maybeLinkExternalFile( sal_uInt16 nFileId, bool 
bDeferFilterDetection )
 {
 if (maLinkedDocs.count(nFileId))
 // file already linked, or the link has been broken.
@@ -2614,7 +2613,9 @@ void 
ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
 }
 // If a filter was already set (for example, loading the cached table),
 // don't call GetFilterName which has to access the source file.
-if (aFilter.isEmpty())
+// If filter detection is deferred, the next successfull loadSrcDocument()
+// will update SrcFileData filter name.
+if (aFilter.isEmpty() && !bDeferFilterDetection)
 ScDocumentLoader::GetFilterName(*pFileName, aFilter, aOptions, true, 
false);
 sfx2::LinkManager* pLinkMgr = mpDoc->GetLinkManager();
 if (!pLinkMgr)
@@ -2624,8 +2625,8 @@ void 
ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
 }
 ScExternalRefLink* pLink = new ScExternalRefLink(mpDoc, nFileId, aFilter);
 OSL_ENSURE(pFileName, "ScExternalRefManager::maybeLinkExternalFile: file 
name pointer is NULL");
-OUString aTmp = aFilter;
-pLinkMgr->InsertFileLink(*pLink, OBJECT_CLIENT_FILE, *pFileName, );
+pLinkMgr->InsertFileLink(*pLink, OBJECT_CLIENT_FILE, *pFileName,
+(aFilter.isEmpty() && bDeferFilterDetection ? nullptr : ));
 
 pLink->SetDoReferesh(false);
 pLink->Update();
@@ -2643,7 +2644,7 @@ void ScExternalRefManager::addFilesToLinkManager()
 "sc.ui", "ScExternalRefManager::addFilesToLinkManager: files 
overflow");
 const sal_uInt16 nSize = static_cast( std::min( 
maSrcFiles.size(), SAL_MAX_UINT16));
 for (sal_uInt16 nFileId = 0; nFileId < nSize; ++nFileId)
-maybeLinkExternalFile( nFileId);
+maybeLinkExternalFile( nFileId, true);
 }
 
 void ScExternalRefManager::SrcFileData::maybeCreateRealFileName(const 
OUString& rOwnDocName)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sc/inc sc/source

2017-06-04 Thread Eike Rathke
 sc/inc/markarr.hxx|1 
 sc/inc/markmulti.hxx  |   12 -
 sc/source/core/data/markarr.cxx   |8 +++
 sc/source/core/data/markdata.cxx  |   85 
 sc/source/core/data/markmulti.cxx |   88 ++
 sc/source/core/data/table2.cxx|   11 +++-
 6 files changed, 165 insertions(+), 40 deletions(-)

New commits:
commit 3a52f3bf5ecf0a2b8d4f4b87e19911ad8e7eaefa
Author: Eike Rathke 
Date:   Sun Jun 4 00:04:10 2017 +0200

Perf-sc: tdf#100709 avoid segment tree with ScMultiSelIter where possible

* create ScFlatBoolRowSegments in ScMultiSelIter only if necessary
* create ScMultiSelIter only for affected columns in
  ScTable::MergeSelectionPattern() using ScMarkData::GetMarkedColSpans()
* obtaining a full ScRangeList in ScMarkData::GetMarkedColSpans() was
  completely unnecessary, use existing selection containers instead and also
  if possible avoid creating a segment tree that needs to be converted to
  vector, directly use a vector instead

Improvement:
* under ScDocShell::Load()
  previous: Ir:  26 454 571 612
   now: Ir:  18 811 368 362

* thereof under ScTable::MergeSelectionPattern()
  previous: Ir:   4 104 164 533
   now: Ir: 664 738 808

Change-Id: I95895a3a000c1a0b7895fb0696b0889c6d6b4d49
(cherry picked from commit bb9b6cb4e6cfc5fbb4733abb8e9f5758987c197a)
Reviewed-on: https://gerrit.libreoffice.org/38376
Reviewed-by: Eike Rathke 
Tested-by: Jenkins 

diff --git a/sc/inc/markarr.hxx b/sc/inc/markarr.hxx
index 33a7b9031128..548d023db4d4 100644
--- a/sc/inc/markarr.hxx
+++ b/sc/inc/markarr.hxx
@@ -71,6 +71,7 @@ public:
 ~ScMarkArrayIter();
 
 boolNext( SCROW& rTop, SCROW& rBottom );
+voidreset( const ScMarkArray* pNewArray );
 };
 
 #endif
diff --git a/sc/inc/markmulti.hxx b/sc/inc/markmulti.hxx
index 4999df5c5708..6ada78c243e6 100644
--- a/sc/inc/markmulti.hxx
+++ b/sc/inc/markmulti.hxx
@@ -63,20 +63,28 @@ public:
 void Clear();
 void MarkAllCols( SCROW nStartRow, SCROW nEndRow );
 bool HasAnyMarks() const;
+
+// For faster access from within ScMarkData, instead of creating
+// ScMultiSelIter with ScFlatBoolRowSegments bottleneck.
+const ScMarkArray& GetRowSelArray() const;
+const ScMarkArray* GetMultiSelArray( SCCOL nCol ) const;
 };
 
 class ScMultiSelIter
 {
 
 private:
-ScFlatBoolRowSegments aRowSegs;
+std::unique_ptr  pRowSegs;
+ScMarkArrayIter aMarkArrayIter;
 SCROW nNextSegmentStart;
 public:
 ScMultiSelIter( const ScMultiSel& rMultiSel, SCCOL nCol );
 ~ScMultiSelIter();
 
 bool Next( SCROW& rTop, SCROW& rBottom );
-const ScFlatBoolRowSegments& GetRowSegments() const { return aRowSegs; }
+/** Only to be used by ScMultiSel::IsAllMarked() or otherwise sure that a
+segment tree is actually used. */
+bool GetRangeData( SCROW nRow, ScFlatBoolRowSegments::RangeData& rRowRange 
) const;
 };
 
 #endif
diff --git a/sc/source/core/data/markarr.cxx b/sc/source/core/data/markarr.cxx
index b95cf07c9e6d..52b7597fe1cd 100644
--- a/sc/source/core/data/markarr.cxx
+++ b/sc/source/core/data/markarr.cxx
@@ -372,8 +372,16 @@ ScMarkArrayIter::~ScMarkArrayIter()
 {
 }
 
+void ScMarkArrayIter::reset( const ScMarkArray* pNewArray )
+{
+pArray = pNewArray;
+nPos = 0;
+}
+
 bool ScMarkArrayIter::Next( SCROW& rTop, SCROW& rBottom )
 {
+if (!pArray)
+return false;
 if ( nPos >= pArray->nCount )
 return false;
 while (!pArray->pData[nPos].bMarked)
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index e2e89e829d09..67c309169c53 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -468,19 +468,86 @@ std::vector 
ScMarkData::GetMarkedRowSpans() const
 
 std::vector ScMarkData::GetMarkedColSpans() const
 {
-typedef mdds::flat_segment_tree SpansType;
 
-ScRangeList aRanges = GetMarkedRanges();
-SpansType aSpans(0, MAXCOL+1, false);
-SpansType::const_iterator itPos = aSpans.begin();
-
-for (size_t i = 0, n = aRanges.size(); i < n; ++i)
+if (bMultiMarked)
 {
-const ScRange& r = *aRanges[i];
-itPos = aSpans.insert(itPos, r.aStart.Col(), r.aEnd.Col()+1, 
true).first;
+SCCOL nStartCol = aMultiRange.aStart.Col();
+SCCOL nEndCol = aMultiRange.aEnd.Col();
+if (bMarked)
+{
+// Use segment tree to merge marked with multi marked.
+typedef mdds::flat_segment_tree SpansType;
+SpansType aSpans(0, MAXCOL+1, false);
+SpansType::const_iterator itPos = aSpans.begin();
+do
+{
+if (aMultiSel.GetRowSelArray().HasMarks())
+{
+