[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2023-10-29 Thread Paris Oplopoios (via logerrit)
 sc/qa/unit/subsequent_export_test.cxx |   31 +++
 sc/source/filter/excel/xecontent.cxx  |   17 -
 2 files changed, 47 insertions(+), 1 deletion(-)

New commits:
commit e123c772db8a12a37dfa14370b9db7c220f33ef1
Author: Paris Oplopoios 
AuthorDate: Thu Oct 26 14:28:06 2023 +0300
Commit: Paris Oplopoios 
CommitDate: Sun Oct 29 22:18:41 2023 +0100

sc: Test numeric conditional format text rule exports correctly

Change-Id: Ib57ea44912b4cb0be7cbdb127dd7ea6f08ec8392
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158498
Tested-by: Jenkins
Reviewed-by: Paris Oplopoios 

diff --git a/sc/qa/unit/subsequent_export_test.cxx 
b/sc/qa/unit/subsequent_export_test.cxx
index 5f5132c299c2..035709a036ac 100644
--- a/sc/qa/unit/subsequent_export_test.cxx
+++ b/sc/qa/unit/subsequent_export_test.cxx
@@ -2153,6 +2153,37 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, 
testSheetProtectionXLSB)
 
CPPUNIT_ASSERT(!pTabProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS));
 }
 
+CPPUNIT_TEST_FIXTURE(ScExportTest, testConditionalFormatNumberInTextRule)
+{
+createScDoc();
+
+ScDocument* pDocument = getScDoc();
+ScAddress aAddress(0, 0, 0);
+
+auto pFormat = std::make_unique(0, pDocument);
+ScRange aCondFormatRange(aAddress);
+ScRangeList aRangeList(aCondFormatRange);
+pFormat->SetRange(aRangeList);
+ScCondFormatEntry* pEntry
+= new ScCondFormatEntry(ScConditionMode::BeginsWith, "15", "", 
*pDocument, aAddress, "");
+pFormat->AddEntry(pEntry);
+pDocument->AddCondFormat(std::move(pFormat), 0);
+
+saveAndReload("Calc Office Open XML");
+pDocument = getScDoc();
+
+ScConditionalFormat* pCondFormat = pDocument->GetCondFormat(0, 0, 0);
+CPPUNIT_ASSERT(pCondFormat);
+CPPUNIT_ASSERT_EQUAL(size_t(1), pCondFormat->size());
+const ScFormatEntry* pCondFormatEntry = pCondFormat->GetEntry(0);
+CPPUNIT_ASSERT(pCondFormatEntry);
+CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Condition, 
pCondFormatEntry->GetType());
+const ScConditionEntry* pConditionEntry
+= static_cast(pCondFormatEntry);
+CPPUNIT_ASSERT_EQUAL(ScConditionMode::BeginsWith, 
pConditionEntry->GetOperation());
+CPPUNIT_ASSERT_EQUAL(OUString("\"15\""), 
pConditionEntry->GetExpression(aAddress, 0));
+}
+
 namespace
 {
 const char* toBorderName(SvxBorderLineStyle eStyle)
commit ac0a4b7c22b65325b3502cde3e05e106136c4f5b
Author: Paris Oplopoios 
AuthorDate: Thu Oct 26 12:35:23 2023 +0300
Commit: Paris Oplopoios 
CommitDate: Sun Oct 29 22:18:33 2023 +0100

sc: Export conditional formatting expression correctly for text rules

Text rules like BeginsWith would discard the expression if it was a
number when exporting, which is not what is supposed to happen - as
something like a conditional formatting rule BeginsWith "1" should be
valid.

Change-Id: I2d53754c462403f20b1991fa201184fcab3616a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158494
Tested-by: Jenkins
Reviewed-by: Paris Oplopoios 

diff --git a/sc/source/filter/excel/xecontent.cxx 
b/sc/source/filter/excel/xecontent.cxx
index 037e99c408a0..d8d21e360cd6 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1058,7 +1058,22 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
 // the token array for that
 std::unique_ptr 
pTokenArray(mrFormatEntry.CreateFlatCopiedTokenArray(0));
 if(pTokenArray->GetLen())
-aText = 
pTokenArray->FirstToken()->GetString().getString().toUtf8();
+{
+formula::StackVar eType = pTokenArray->FirstToken()->GetType();
+switch (eType)
+{
+case formula::svDouble:
+{
+aText = 
OString::number(pTokenArray->FirstToken()->GetDouble());
+break;
+}
+default:
+{
+aText = 
pTokenArray->FirstToken()->GetString().getString().toUtf8();
+break;
+}
+}
+}
 }
 
 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2023-08-08 Thread Henry Castro (via logerrit)
 sc/qa/unit/uicalc/uicalc.cxx   |   39 +++
 sc/source/ui/inc/tabvwsh.hxx   |1 +
 sc/source/ui/view/tabvwsha.cxx |8 
 3 files changed, 48 insertions(+)

New commits:
commit cdca06306e0d4ae2d9874bc7bbd0290d100d54cc
Author: Henry Castro 
AuthorDate: Tue Jul 18 15:21:02 2023 -0400
Commit: Tomaž Vajngerl 
CommitDate: Tue Aug 8 16:44:39 2023 +0200

tdf#155799: sc: qa: add unit test "testKeyboardMergeRef"

Signed-off-by: Henry Castro 
Change-Id: I4d80ad5d9e5fe2c131f9397ec59c6c16ef92c094
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154601
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 9a795f4a5bde..2d1378c92c30 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -2060,6 +2060,45 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf141440)
 CPPUNIT_ASSERT_EQUAL(OUString("Note in A1"), pDoc->GetNote(ScAddress(0, 0, 
0))->GetText());
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testKeyboardMergeRef)
+{
+createScDoc();
+ScDocShell* pDocSh = getScDocShell();
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
+ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
+CPPUNIT_ASSERT(pViewShell);
+
+goToCell("A1:A5");
+dispatchCommand(mxComponent, ".uno:ToggleMergeCells", {});
+goToCell("A6:A10");
+dispatchCommand(mxComponent, ".uno:ToggleMergeCells", {});
+
+goToCell("B1");
+typeString(u"=");
+
+goToCell("A1");
+
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN | KEY_SHIFT);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_DOWN | KEY_SHIFT);
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT(pViewShell->IsRefInputMode());
+{
+const OUString* pInput = pViewShell->GetEditString();
+CPPUNIT_ASSERT(pInput);
+CPPUNIT_ASSERT_EQUAL(OUString("=A1:A10"), *pInput);
+}
+
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_UP | KEY_SHIFT);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_UP | KEY_SHIFT);
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT(pViewShell->IsRefInputMode());
+{
+const OUString* pInput = pViewShell->GetEditString();
+CPPUNIT_ASSERT(pInput);
+CPPUNIT_ASSERT_EQUAL(OUString("=A1:A5"), *pInput);
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3273d44baaf0679a19527e953809b9d61d8e2201
Author: Henry Castro 
AuthorDate: Tue Jul 18 15:18:41 2023 -0400
Commit: Tomaž Vajngerl 
CommitDate: Tue Aug 8 16:44:31 2023 +0200

tdf#155799: sc: add getter function "GetEditString"

Useful for QA test queries.
..

Signed-off-by: Henry Castro 
Change-Id: Ibd3c902405f478032447b10286a788cd0769c855
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154600
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 06e9f31e19cb..3c80dbc1995d 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -236,6 +236,7 @@ public:
 
 const ScInputHandler* GetInputHandler() const { return 
mpInputHandler.get(); }
 ScInputHandler* GetInputHandler() { return mpInputHandler.get(); }
+const OUString* GetEditString() const;
 voidUpdateInputHandler( bool bForce = false, bool bStopEditing 
= true );
 voidUpdateInputHandlerCellAdjust( SvxCellHorJustify eJust );
 boolTabKeyInput(const KeyEvent& rKEvt);
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index c07a070e08ef..dd73c21a5076 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -631,6 +631,14 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& 
rReq, const OUString 
 });
 }
 
+const OUString* ScTabViewShell::GetEditString() const
+{
+if (mpInputHandler)
+return >GetEditString();
+
+return nullptr;
+}
+
 bool ScTabViewShell::IsRefInputMode() const
 {
 ScModule* pScMod = SC_MOD();


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source svx/inc svx/source

2023-04-18 Thread Maxim Monastirsky (via logerrit)
 sc/qa/unit/subsequent_export_test4.cxx|5 ++
 sc/source/core/data/drwlayer.cxx  |4 -
 sc/source/core/data/postit.cxx|   39 --
 svx/inc/sdr/primitive2d/sdrattributecreator.hxx   |3 -
 svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx |6 +-
 svx/source/sdr/primitive2d/sdrattributecreator.cxx|6 +-
 6 files changed, 34 insertions(+), 29 deletions(-)

New commits:
commit a9a2ace53625a8fb3feb1c050648a875a98cb7a8
Author: Maxim Monastirsky 
AuthorDate: Fri Apr 14 14:58:09 2023 +0300
Commit: Maxim Monastirsky 
CommitDate: Tue Apr 18 09:33:28 2023 +0200

sc drawstyles: Comment shadow should depends on shadow attribute

The shadow of comments differs from the shadow of normal callout
shapes, as it shows only for the text rectangle. However the way
it's implemented is weird: The shadow attribute is set to false,
which turns off the "normal" shadow, and then the special shadow
is drawn unconditionally. There is also a code that forces the
shadow attribute to false on import, to handle some old files
that used to have the shadow on.

The confusion begins when one shows the comment, and looks at
right click > Area... > Shadow, which (rightfully) shows the
shadow as off, but doesn't align with what is visible on the
document canvas. Moreover, the other shadow settings on this page
do affect the comment shadow, but in order to change them it is
needed to check the "Use shadow" checkbox first. But leaving that
checkbox as checked will result with a double shadow being drawn
for the text rectangle, and an unnecessary shadow drawn for the
arrow part. The problem becomes now more visible, as there is
a Note style listed in the sidebar.

One possible approach could be to draw the special shadow only
when the shadow attribute is on, and patch existing files on
import to "shadow on" instead of "shadow off". But this will
cause the "double shadow" problem when opened in older versions
(unless the comment is hidden, in which case we used to override
the shadow attribute).

But now there's an opportunity for a better solution: As we
assign the default comment style to imported comments, we can
just clear the shadow attribute DF, instead of forcing it to
some value. As a result, the "shadow on" attribute of the style
will be in effect in newer versions, while in older versions it
will fallback to the "shadow off" pool default.

Change-Id: I4b35bc1e8e2e12ed35a82b0c2e9aabcf28b46270
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150353
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 663767c7374f..eb3af3a2b2bf 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -1557,6 +1557,11 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testCommentStyles)
 auto pCaption = pNote->GetCaption();
 CPPUNIT_ASSERT(pCaption);
 
+// Check that we don't keep the shadow attribute as DF
+// (see ScNoteUtil::CreateNoteFromCaption)
+CPPUNIT_ASSERT_LESSEQUAL(SfxItemState::DEFAULT,
+ 
pCaption->GetMergedItemSet().GetItemState(SDRATTR_SHADOW, false));
+
 auto pStyleSheet = >GetStyleSheetPool()->Make("MyStyle1", 
SfxStyleFamily::Frame);
 auto& rSet = pStyleSheet->GetItemSet();
 rSet.Put(SvxFontHeightItem(1129, 100, EE_CHAR_FONTHEIGHT));
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 3940d09906ee..8191dfcede66 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -382,9 +382,7 @@ void ScDrawLayer::CreateDefaultStyles()
 pSet->Put(SdrCaptionEscDirItem(SdrCaptionEscDir::BestFit));
 
 // shadow
-/* SdrShadowItem has false, instead the shadow is set for the rectangle
-   only with SetSpecialTextBoxShadow() when the object is created. */
-pSet->Put(makeSdrShadowItem(false));
+pSet->Put(makeSdrShadowItem(true));
 pSet->Put(makeSdrShadowXDistItem(100));
 pSet->Put(makeSdrShadowYDistItem(100));
 
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index b4acfb35f205..66f034087678 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -112,8 +112,10 @@ void ScCaptionUtil::SetExtraItems( SdrCaptionObj& 
rCaption, const SfxItemSet& rE
 SfxItemSet aItemSet = rCaption.GetMergedItemSet();
 
 aItemSet.Put(rExtraItemSet);
-// reset shadow items
-aItemSet.Put( makeSdrShadowItem( false ) );
+// reset shadow visibility (see also ScNoteUtil::CreateNoteFromCaption)
+aItemSet.ClearItem(SDRATTR_SHADOW);
+// ... but not distance, as that will fallback to wrong values
+// if the comment is shown 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source sw/source

2023-03-16 Thread Paris Oplopoios (via logerrit)
 sc/qa/unit/uicalc/data/simpleTable.xlsx |binary
 sc/qa/unit/uicalc/uicalc.cxx|   15 +++
 sc/source/core/tool/dbdata.cxx  |7 ++-
 sw/source/core/docnode/ndtbl.cxx|1 +
 4 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 2135706397d36aa7ea24650b65859be0b6860a65
Author: Paris Oplopoios 
AuthorDate: Wed Mar 8 23:04:49 2023 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Mar 16 13:08:25 2023 +

tdf#154061 Make sure table column attributes size is correct

Resize maTableColumnAttributes to match the amount of columns, fixes
crash upon undoing a column insertion on a table

Change-Id: Iad4b8ac5c38d5d1065d6ef1267ce3f5d3b28afa8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148492
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/qa/unit/uicalc/data/simpleTable.xlsx 
b/sc/qa/unit/uicalc/data/simpleTable.xlsx
new file mode 100644
index ..fd4e394732ba
Binary files /dev/null and b/sc/qa/unit/uicalc/data/simpleTable.xlsx differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 421f96410e6f..4fb9416badd8 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -2221,6 +2221,21 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf142010)
 CPPUNIT_ASSERT_EQUAL(5.0, pDoc->GetValue(ScAddress(5, 71, 0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf154061)
+{
+createScDoc("simpleTable.xlsx");
+ScDocument* pDoc = getScDoc();
+CPPUNIT_ASSERT_EQUAL(OUString("Column2"), pDoc->GetString(ScAddress(1, 0, 
0)));
+
+goToCell("B1");
+
+// Without the fix in place, it would crash here due to an out of bounds 
array access
+dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {});
+CPPUNIT_ASSERT_EQUAL(OUString("Column2"), pDoc->GetString(ScAddress(2, 0, 
0)));
+dispatchCommand(mxComponent, ".uno:Undo", {});
+CPPUNIT_ASSERT_EQUAL(OUString("Column2"), pDoc->GetString(ScAddress(1, 0, 
0)));
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf132431)
 {
 createScDoc("tdf132431.ods");
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index dc10d6a0503e..293bb20a4976 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -116,6 +116,7 @@ ScDBData::ScDBData( const ScDBData& rData ) :
 bAutoFilter (rData.bAutoFilter),
 bModified   (rData.bModified),
 maTableColumnNames  (rData.maTableColumnNames),
+maTableColumnAttributes(rData.maTableColumnAttributes),
 mbTableColumnNamesDirty(rData.mbTableColumnNamesDirty),
 nFilteredRowCount   (rData.nFilteredRowCount)
 {
@@ -150,6 +151,7 @@ ScDBData::ScDBData( const OUString& rName, const ScDBData& 
rData ) :
 bAutoFilter (rData.bAutoFilter),
 bModified   (rData.bModified),
 maTableColumnNames  (rData.maTableColumnNames),
+maTableColumnAttributes(rData.maTableColumnAttributes),
 mbTableColumnNamesDirty (rData.mbTableColumnNamesDirty),
 nFilteredRowCount   (rData.nFilteredRowCount)
 {
@@ -199,6 +201,7 @@ ScDBData& ScDBData::operator= (const ScDBData& rData)
 else
 {
 maTableColumnNames  = rData.maTableColumnNames;
+maTableColumnAttributes = rData.maTableColumnAttributes;
 mbTableColumnNamesDirty = rData.mbTableColumnNamesDirty;
 }
 
@@ -577,6 +580,7 @@ void ScDBData::UpdateMoveTab(SCTAB nOldPos, SCTAB nNewPos)
 aRange.aEnd.Row());
 // Do not use SetTableColumnNames() because that resets 
mbTableColumnNamesDirty.
 maTableColumnNames = aNames;
+maTableColumnAttributes.resize(aNames.size());
 mbTableColumnNamesDirty = bTableColumnNamesDirty;
 }
 
@@ -620,6 +624,7 @@ bool ScDBData::UpdateReference(const ScDocument* pDoc, 
UpdateRefMode eUpdateRefM
 MoveTo( theTab1, theCol1, theRow1, theCol2, theRow2 );
 // Do not use SetTableColumnNames() because that resets 
mbTableColumnNamesDirty.
 maTableColumnNames = aNames;
+maTableColumnAttributes.resize(aNames.size());
 mbTableColumnNamesDirty = bTableColumnNamesDirty;
 }
 
@@ -721,7 +726,6 @@ void ScDBData::AdjustTableColumnAttributes( UpdateRefMode 
eUpdateRefMode, SCCOL
 n += nDx;
 aNewNames.resize(n);
 aNewAttributes.resize(n);
-maTableColumnAttributes.resize(n);
 // Copy head.
 for (size_t i = 0; i < nHead; ++i)
 {
@@ -876,6 +880,7 @@ void ScDBData::RefreshTableColumnNames( ScDocument* pDoc )
 }
 
 aNewNames.swap( maTableColumnNames);
+maTableColumnAttributes.resize(maTableColumnNames.size());
 mbTableColumnNamesDirty = false;
 }
 
commit 67d353ff50712a036d04b1c0ffab68f2a21b5008
Author: Caolán McNamara 
AuthorDate: Wed Mar 15 20:05:33 2023 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 16 13:08:20 2023 +

Related: 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2022-09-20 Thread Luboš Luňák (via logerrit)
 sc/qa/unit/data/functions/fods/Functions_Excel_2016.fods |2 -
 sc/source/core/opencl/op_logical.hxx |3 +
 sc/source/core/opencl/op_statistical.cxx |   24 ++-
 sc/source/core/opencl/opbase.cxx |4 +-
 sc/source/core/opencl/opbase.hxx |   12 ---
 5 files changed, 29 insertions(+), 16 deletions(-)

New commits:
commit 7dc92d60166a99e0539ce83ecf45bb40fd30d784
Author: Luboš Luňák 
AuthorDate: Tue Sep 20 09:57:38 2022 +0200
Commit: Luboš Luňák 
CommitDate: Tue Sep 20 17:53:32 2022 +0200

fix opencl AND() to treat empty cell in svSingleVectorRef as core does

Functions_Excel_2016.fods incorrectly used "=AND(Sheet2.C22;C33)"
instead of the correct "=AND(Sheet2.C22:C33)" (colon vs semicolon),
and C33 is an empty cell. The return however was true because empty
cells get special treatment because of Excel compatibility.

Change-Id: I6d0b28280059fd6fc945e77c7b5d714b5e4727a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140224
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/data/functions/fods/Functions_Excel_2016.fods 
b/sc/qa/unit/data/functions/fods/Functions_Excel_2016.fods
index f5c2aedd3abe..b4a6ea11500d 100644
--- a/sc/qa/unit/data/functions/fods/Functions_Excel_2016.fods
+++ b/sc/qa/unit/data/functions/fods/Functions_Excel_2016.fods
@@ -856,7 +856,7 @@
  
   1
  
- 
+ 
   WAAR
  
  
diff --git a/sc/source/core/opencl/op_logical.hxx 
b/sc/source/core/opencl/op_logical.hxx
index f4c6b7a952ef..a52d1db0cf86 100644
--- a/sc/source/core/opencl/op_logical.hxx
+++ b/sc/source/core/opencl/op_logical.hxx
@@ -32,6 +32,9 @@ public:
 virtual std::string BinFuncName() const override { return "And"; }
 virtual const char* openclOperator() const override { return "&&"; };
 virtual const char* defaultOpenclValue() const override { return "true"; }
+// AND() with a svSingleVectorRef pointing to an empty cell skips that 
cell.
+// See ScInterpreter::ScAnd().
+virtual const char* rangeEmptyCellValue() const override { return "1.0"; };
 };
 
 class OpOr: public OpLogicalBinaryOperator
diff --git a/sc/source/core/opencl/opbase.cxx b/sc/source/core/opencl/opbase.cxx
index 2cb51e47d080..fe98b4c09dd3 100644
--- a/sc/source/core/opencl/opbase.cxx
+++ b/sc/source/core/opencl/opbase.cxx
@@ -189,7 +189,7 @@ void SlidingFunctionBase::GenerateArg( const char* name, 
int arg, SubArguments&
 static_cast(token);
 ss << "if (gid0 >= " << svr->GetArrayLength() << " || isnan(";
 ss << vSubArguments[arg]->GenSlidingWindowDeclRef() << "))\n";
-ss << "" << name << " = 0.0;\n";
+ss << "" << name << " = " << rangeEmptyCellValue() << 
";\n";
 ss << "else\n";
 ss << "" << name << " = ";
 ss << vSubArguments[arg]->GenSlidingWindowDeclRef() << ";\n";
@@ -345,7 +345,7 @@ void SlidingFunctionBase::GenerateRangeArgElement( const 
char* name, int arg, co
 throw Unhandled( __FILE__, __LINE__ );
 const formula::DoubleVectorRefToken* pDVR =
 static_cast(token);
-ss << "double " << name << " = NAN;\n";
+ss << "double " << name << " = " << rangeEmptyCellValue() << ";\n";
 ss << "{\n";
 // GenSlidingWindowDeclRef() may refer to 'i' variable.
 ss << "int i = 0;\n";
diff --git a/sc/source/core/opencl/opbase.hxx b/sc/source/core/opencl/opbase.hxx
index ee55d72c45b6..aa2770cd20aa 100644
--- a/sc/source/core/opencl/opbase.hxx
+++ b/sc/source/core/opencl/opbase.hxx
@@ -261,12 +261,12 @@ public:
 const std::string&, SubArguments& ) = 0;
 protected:
 // generate code for "double  = ;" from vSubArguments, 
svDoubleVectorRef is not supported
-static void GenerateArg( const char* name, int arg, SubArguments& 
vSubArguments, outputstream& ss );
+void GenerateArg( const char* name, int arg, SubArguments& vSubArguments, 
outputstream& ss );
 // overload, variable will be named "arg"
-static void GenerateArg( int arg, SubArguments& vSubArguments, 
outputstream& ss );
+void GenerateArg( int arg, SubArguments& vSubArguments, outputstream& ss );
 // generate code for "double  = ;" from vSubArguments, if it 
exists,
 // otherwise set to 
-static void GenerateArgWithDefault( const char* name, int arg, double def, 
SubArguments& vSubArguments,
+void GenerateArgWithDefault( const char* name, int arg, double def, 
SubArguments& vSubArguments,
 outputstream& ss );
 void GenerateFunctionDeclaration( const std::string& sSymName,
 SubArguments& vSubArguments, outputstream& ss );
@@ -282,7 +282,7 @@ protected:
 // Overload.
 // Both arguments must be svDoubleRef of the same size.
 // If 'firstElementDiff' is set, the loop start will be offset by '+ 
firstElementDiff'.
-static 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source sw/source

2022-08-11 Thread Noel Grandin (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   26 ---
 sc/source/ui/view/tabvwshb.cxx   |   44 ++-
 sw/source/filter/ww8/ww8par.cxx  |2 -
 sw/source/filter/ww8/ww8par.hxx  |2 -
 sw/source/filter/ww8/ww8par5.cxx |   10 +++---
 5 files changed, 71 insertions(+), 13 deletions(-)

New commits:
commit c8ef47651a32c9cd00183d51fb31912990b89793
Author: Noel Grandin 
AuthorDate: Mon Aug 8 19:02:07 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Aug 11 10:32:36 2022 +0200

unique_ptr->optional in SwWW8ImplReader

Change-Id: I9d5961c974cf0ec378dd3560ad24d65e5d3aa197
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138104
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index a22469ba2994..548726482993 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5478,7 +5478,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const 
*pGloss)
 m_xLstManager.reset();
 }
 
-m_pPosAfterTOC.reset();
+m_oPosAfterTOC.reset();
 m_xRedlineStack.reset();
 mpCursor.reset();
 m_pPaM = nullptr;
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index fcd46da1cde4..f6c6e2fd9548 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1399,7 +1399,7 @@ private:
 // Indicate that current on loading a hyperlink, which is inside a TOC; 
Managed by Read_F_Hyperlink() and End_Field()
 bool m_bLoadingTOXHyperlink;
 // a document position recorded the after-position of TOC section, managed 
by Read_F_TOX() and End_Field()
-std::unique_ptr m_pPosAfterTOC;
+std::optional m_oPosAfterTOC;
 // used for some dropcap tweaking
 std::unique_ptr m_xPreviousNode;
 
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index d59f41d68174..508cae886c1f 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -569,10 +569,10 @@ sal_uInt16 SwWW8ImplReader::End_Field()
 m_bCareLastParaEndInToc = true;
 }
 
-if (m_pPosAfterTOC)
+if (m_oPosAfterTOC)
 {
-*m_pPaM = *m_pPosAfterTOC;
-m_pPosAfterTOC.reset();
+*m_pPaM = *m_oPosAfterTOC;
+m_oPosAfterTOC.reset();
 }
 }
 }
@@ -3479,7 +3479,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, 
OUString& rStr )
 
 //The TOC field representation contents should be inserted into TOC 
section, but not after TOC section.
 //So we need update the document position when loading TOC representation 
and after loading TOC;
-m_pPosAfterTOC.reset(new SwPaM(*m_pPaM, m_pPaM));
+m_oPosAfterTOC.emplace(*m_pPaM, m_pPaM);
 (*m_pPaM).Move(fnMoveBackward);
 SwPaM aRegion(*m_pPaM, m_pPaM);
 
@@ -3500,7 +3500,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, 
OUString& rStr )
 
 // inserting a toc inserts a section before this point, so adjust pos
 // for future page/section segment insertion
-m_aSectionManager.PrependedInlineNode( *m_pPosAfterTOC->GetPoint(), 
aRegion.GetNode() );
+m_aSectionManager.PrependedInlineNode( *m_oPosAfterTOC->GetPoint(), 
aRegion.GetNode() );
 }
 
 // Set end in stack
commit 30efbe72f6b3a025ef12695b23821a77e1b1a887
Author: Noel Grandin 
AuthorDate: Wed Aug 10 10:04:09 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Aug 11 10:32:22 2022 +0200

calc: fix undo action disabled in different views

when actions are independant.

Update existing unit test to test this too.

Change-Id: I0af804321c371e72fb1ce096ec4ec3566a3fcffc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138079
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Noel Grandin 
(cherry picked from commit db23578b694228c983b615c9be6aed8a6a2af84b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138029
Tested-by: Jenkins

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 559769c0c251..cfd80d53fa89 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1544,6 +1544,8 @@ void ScTiledRenderingTest::testDisableUndoRepair()
 int nView2 = SfxLokHelper::getView();
 SfxViewShell* pView2 = SfxViewShell::Current();
 CPPUNIT_ASSERT(pView1 != pView2);
+
+// both views have UNDO disabled
 {
 SfxItemSet aSet1(pView1->GetPool(), svl::Items);
 SfxItemSet aSet2(pView2->GetPool(), svl::Items);
@@ -1560,6 +1562,7 @@ void ScTiledRenderingTest::testDisableUndoRepair()
 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2022-05-27 Thread Luboš Luňák (via logerrit)
 sc/qa/unit/ucalc_formula.cxx   |   92 ++
 sc/source/core/tool/interpr1.cxx   |  130 ++---
 sc/source/core/tool/rangecache.cxx |5 -
 3 files changed, 175 insertions(+), 52 deletions(-)

New commits:
commit 7674399aac661eb503d7badc53b9a4d68bd9839d
Author: Luboš Luňák 
AuthorDate: Fri May 27 19:51:40 2022 +0200
Commit: Luboš Luňák 
CommitDate: Sat May 28 05:44:27 2022 +0200

try to range-reduce even COUNTIFS if not matching empty cells

It's possible to do reduce range of COUNTIFS to non-empty data too,
since empty cells cannot contribute to the result, as long as
the criteria do not require matching empty cells. Without this
queries like =COUNTIFS($A:$A,...) can spend most of their time
clearing and searching the vConditions vector that's big and
not useful for the trailing empty cells in that column.

Change-Id: I8d1e7977f172ac9b2cf84af3f982e945be3cb46c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135049
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 14d779d2e4f3..6bad4a40127c 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -308,6 +308,7 @@ public:
 void testFuncRowsHidden();
 void testFuncSUMIFS();
 void testFuncCOUNTIFEmpty();
+void testFuncCOUNTIFSRangeReduce();
 void testFuncRefListArraySUBTOTAL();
 void testFuncJumpMatrixArrayIF();
 void testFuncJumpMatrixArrayOFFSET();
@@ -427,6 +428,7 @@ public:
 CPPUNIT_TEST(testFuncRowsHidden);
 CPPUNIT_TEST(testFuncSUMIFS);
 CPPUNIT_TEST(testFuncCOUNTIFEmpty);
+CPPUNIT_TEST(testFuncCOUNTIFSRangeReduce);
 CPPUNIT_TEST(testFuncRefListArraySUBTOTAL);
 CPPUNIT_TEST(testFuncJumpMatrixArrayIF);
 CPPUNIT_TEST(testFuncJumpMatrixArrayOFFSET);
@@ -9356,6 +9358,56 @@ void TestFormula::testFuncCOUNTIFEmpty()
 m_pDoc->DeleteTab(0);
 }
 
+// Test that COUNTIFS counts properly empty cells if asked to.
+void TestFormula::testFuncCOUNTIFSRangeReduce()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+m_pDoc->InsertTab(0, "Test");
+
+// Data in A1:C9.
+std::vector> aData = {
+{ "" },
+{ "a",  "1", "1" },
+{ "b",  "2", "2" },
+{ "c",  "4", "3" },
+{ "d",  "8", "4" },
+{ "a", "16", "5" },
+{ "" },
+{ "b", "", "6" },
+{ "c", "64", "7" }
+};
+
+insertRangeData(m_pDoc, ScAddress(0,0,0), aData);
+
+constexpr SCROW maxRow = 20; // so that the unittest is not slow in 
dbgutil builds
+ScRange aSubRange( ScAddress( 0, 0, 0 ), ScAddress( 2, maxRow, 0 ));
+m_pDoc->GetDataAreaSubrange(aSubRange);
+// This is the range the data should be reduced to in 
ScInterpreter::IterateParametersIfs().
+CPPUNIT_ASSERT_EQUAL( SCROW(1), aSubRange.aStart.Row());
+CPPUNIT_ASSERT_EQUAL( SCROW(8), aSubRange.aEnd.Row());
+
+m_pDoc->SetFormula( ScAddress(10, 0, 0), "=COUNTIFS($A1:$A" + 
OUString::number(maxRow+1)
++ "; \"\"; $B1:$B" + OUString::number(maxRow+1)
++ "; \"\"; $C1:$C" + OUString::number(maxRow+1) +"; \"\")",
+formula::FormulaGrammar::GRAM_NATIVE_UI);
+// But it should find out that it can't range reduce and must count all 
the empty rows.
+CPPUNIT_ASSERT_EQUAL( double(maxRow + 1 - 7), 
m_pDoc->GetValue(ScAddress(10, 0, 0)));
+
+// Check also with criteria set as cell references, the middle one 
resulting in matching
+// empty cells (which should cause ScInterpreter::IterateParametersIfs() 
to undo
+// the range reduction). This should only match the A8-C8 row, but it also 
shouldn't crash.
+// Matching empty cells using a cell reference needs a formula to set the 
cell to
+// an empty string, plain empty cell wouldn't do, so use K2 for that.
+m_pDoc->SetFormula( ScAddress(10, 1, 0), "=\"\"", 
formula::FormulaGrammar::GRAM_NATIVE_UI );
+m_pDoc->SetFormula( ScAddress(10, 0, 0), "=COUNTIFS($A1:$A" + 
OUString::number(maxRow+1)
++ "; A8; $B1:$B" + OUString::number(maxRow+1)
++ "; K2; $C1:$C" + OUString::number(maxRow+1) + "; C8)",
+formula::FormulaGrammar::GRAM_NATIVE_UI);
+CPPUNIT_ASSERT_EQUAL( double(1), m_pDoc->GetValue(ScAddress(10, 0, 0)));
+
+m_pDoc->DeleteTab(0);
+}
+
 // Test SUBTOTAL with reference lists in array context.
 void TestFormula::testFuncRefListArraySUBTOTAL()
 {
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index c6bcb29b28bb..0b3592976a71 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5844,6 +5844,7 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 // matrix formula.
 vConditions.clear();
 
+// Range-reduce optimization
 SCCOL nStartColDiff = 0;
 SCCOL nEndColDiff = 0;
 SCROW nStartRowDiff = 0;
@@ -5851,43 +5852,39 @@ 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2022-05-16 Thread Mike Kaganski (via logerrit)
 sc/qa/uitest/chart/copyPaste.py  |3 
 sc/source/core/data/documen3.cxx |3 
 sc/source/core/data/documen5.cxx |3 
 sc/source/core/data/document.cxx |4 
 sc/source/ui/app/transobj.cxx|8 
 sc/source/ui/docshell/docsh.cxx  |  364 +++
 sc/source/ui/docshell/docsh2.cxx |   57 +++---
 sc/source/ui/docshell/docsh3.cxx |  114 ++--
 sc/source/ui/docshell/docsh4.cxx |  252 +--
 sc/source/ui/docshell/docsh5.cxx |  224 
 sc/source/ui/docshell/docsh6.cxx |   80 
 sc/source/ui/docshell/docsh8.cxx |   46 ++--
 sc/source/ui/inc/docsh.hxx   |8 
 sc/source/ui/inc/transobj.hxx|6 
 sc/source/ui/view/viewfun3.cxx   |8 
 15 files changed, 593 insertions(+), 587 deletions(-)

New commits:
commit 964e2eaae9d32df201574e6f083acc630fed2f1d
Author: Mike Kaganski 
AuthorDate: Mon May 16 09:03:03 2022 +0300
Commit: Mike Kaganski 
CommitDate: Tue May 17 06:15:48 2022 +0200

tdf#142635: use the same ScDocument for clipboard and GlobalDrawPersist

This way, the document used for chart copy has the proper sheets, and
the data ranges are created correctly.

This reverts commit 8d98dd8b3896c14af057e90e3a327172a9262e03
  Author Mike Kaganski 
  Date   Thu Jun 03 13:15:11 2021 +0200
tdf#142635: skip UITest for now

Change-Id: I0a3aa6028f49ded278f8665556007b1f722e21b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134251
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/qa/uitest/chart/copyPaste.py b/sc/qa/uitest/chart/copyPaste.py
index dfd38cbcc775..2df579db0bb5 100644
--- a/sc/qa/uitest/chart/copyPaste.py
+++ b/sc/qa/uitest/chart/copyPaste.py
@@ -7,8 +7,6 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
 
-import unittest
-import platform
 from uitest.framework import UITestCase
 from libreoffice.calc.document import get_cell_by_position
 from libreoffice.uno.propertyvalue import mkPropertyValues
@@ -16,7 +14,6 @@ from uitest.uihelper.common import get_url_for_data_file
 
 class CopyPaste(UITestCase):
 
-  @unittest.skipIf(platform.system() == "Windows", "Fails on Windows: 
tdf#142635")
   def test_copy_paste_chart_with_dot_in_sheet_name(self):
 with 
self.ui_test.load_file(get_url_for_data_file("chartWithDotInSheetName.ods")) as 
calc_doc:
 
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 37c0839fcf26..77afc2ff7d94 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1954,7 +1954,8 @@ void ScDocument::SetDocOptions( const ScDocOptions& rOpt )
 assert(pDocOptions && "No DocOptions! :-(");
 
 *pDocOptions = rOpt;
-mxPoolHelper->SetFormTableOpt(rOpt);
+if (mxPoolHelper)
+mxPoolHelper->SetFormTableOpt(rOpt);
 }
 
 const ScViewOptions& ScDocument::GetViewOptions() const
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index 1c695244bda4..c4f76433b41d 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -362,6 +362,9 @@ void ScDocument::UpdateChart( const OUString& rChartName )
 
 void ScDocument::RestoreChartListener( const OUString& rName )
 {
+if (!pChartListenerCollection)
+return;
+
 // Read the data ranges from the chart object, and start listening to 
those ranges again
 // (called when a chart is saved, because then it might be swapped out and 
stop listening itself).
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 8791c3afe1bd..8cf93a6abe5c 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6155,12 +6155,12 @@ ScPatternAttr* ScDocument::GetDefPattern() const
 
 ScDocumentPool* ScDocument::GetPool()
 {
-return mxPoolHelper->GetDocPool();
+return mxPoolHelper ? mxPoolHelper->GetDocPool() : nullptr;
 }
 
 ScStyleSheetPool* ScDocument::GetStyleSheetPool() const
 {
-return mxPoolHelper->GetStylePool();
+return mxPoolHelper ? mxPoolHelper->GetStylePool() : nullptr;
 }
 
 bool ScDocument::IsEmptyData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, 
SCROW nEndRow, SCTAB nTab) const
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index fcc5158e0001..d0be7e0aecc2 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -109,8 +109,8 @@ void ScTransferObj::PaintToDev( OutputDevice* pDev, 
ScDocument& rDoc, double nPr
 ScPrintFunc::DrawToDev( rDoc, pDev, nPrintFactor, aBound, , 
false/*bMetaFile*/ );
 }
 
-ScTransferObj::ScTransferObj( ScDocumentUniquePtr pClipDoc, const 
TransferableObjectDescriptor& rDesc ) :
-m_pDoc( std::move(pClipDoc ) ),
+ScTransferObj::ScTransferObj( const std::shared_ptr& pClipDoc, 
const TransferableObjectDescriptor& rDesc ) :
+m_pDoc( pClipDoc ),
 m_nNonFiltered(0),
 m_aObjDesc( rDesc ),
 m_nDragHandleX( 0 ),
@@ -813,14 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source svl/source sw/source

2022-05-16 Thread Luboš Luňák (via logerrit)
 sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods |   14 ---
 sc/source/core/data/dpobject.cxx |6 +++-
 sc/source/core/data/dpsave.cxx   |3 +-
 svl/source/items/stylepool.cxx   |2 -
 sw/source/filter/ww8/writerhelper.cxx|2 -
 sw/source/filter/ww8/wrtw8nds.cxx|2 -
 6 files changed, 20 insertions(+), 9 deletions(-)

New commits:
commit 86039563de87149a01ffb980b5ec99074b98fd5e
Author: Luboš Luňák 
AuthorDate: Sat May 14 16:52:09 2022 +0200
Commit: Luboš Luňák 
CommitDate: Mon May 16 09:05:00 2022 +0200

std::stable_sort() where libc++ debug mode breaks a unittest

Libc++ debug has a feature that randomizes equal elements during
sort, which normally wouldn't make a difference, but some tests
rely on specific order of tested data. The ones failing without
this include:
CppunitTest_sw_ooxmlexport testMsoPosition
CppunitTest_sw_xhtmlexport testTdf66305
CppunitTest_sw_ww8export testCommentExport

Change-Id: Id49846939a264150cc82091718ffe6b904d7130e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134337
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/svl/source/items/stylepool.cxx b/svl/source/items/stylepool.cxx
index b74d0cb94729..dc992a6ede72 100644
--- a/svl/source/items/stylepool.cxx
+++ b/svl/source/items/stylepool.cxx
@@ -261,7 +261,7 @@ namespace {
 // Sort the parents using their name, if they have one.
 if (!rParentNames.empty())
 {
-std::sort(maParents.begin(), maParents.end(),
+std::stable_sort(maParents.begin(), maParents.end(),
   [](const SfxItemSet* pA, const 
SfxItemSet* pB) {
   OUString aA;
   OUString aB;
diff --git a/sw/source/filter/ww8/writerhelper.cxx 
b/sw/source/filter/ww8/writerhelper.cxx
index 6c62af767ab0..9c3bae38f14d 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -838,7 +838,7 @@ namespace sw
 
 RedlineStack::~RedlineStack()
 {
-std::sort(maStack.begin(), maStack.end(), CompareRedlines());
+std::stable_sort(maStack.begin(), maStack.end(), 
CompareRedlines());
 std::for_each(maStack.begin(), maStack.end(), 
SetInDocAndDelete(mrDoc));
 }
 
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index 3ff1326c24a7..da9c73099dae 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -220,7 +220,7 @@ SwWW8AttrIter::SwWW8AttrIter(MSWordExportBase& rWr, const 
SwTextNode& rTextNd) :
  Get list of any graphics which may be anchored from this paragraph.
 */
 maFlyFrames = GetFramesInNode(rWr.m_aFrames, m_rNode);
-std::sort(maFlyFrames.begin(), maFlyFrames.end(), sortswflys());
+std::stable_sort(maFlyFrames.begin(), maFlyFrames.end(), sortswflys());
 
 /*
  #i18480#
commit ca8614fc44e66308b846d01b8c0ab6a63cc93eb9
Author: Luboš Luňák 
AuthorDate: Sun May 15 06:36:44 2022 +0200
Commit: Luboš Luňák 
CommitDate: Mon May 16 09:04:46 2022 +0200

fix GETPIVOTDATA() field name lookup

Field names are case-insensitive, so the lookup was failing if
the name wasn't typed in a way that matched exactly as
case-sensitive. The A29 field in getpivotdata.fods test was passing
only because the fields were typed in the same order as present
in the pivot table, and std::sort() was accidentally stable. But
reordering the fields in the formula makes it fail, and so does
using libc++ with debug mode (which randomizes equal fields
in std::sort()).

Change-Id: I88d078da435685c3557f24dc5f4a0bfc4d563aa6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134336
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods
index 7ea70d7b3acf..b392f066bc2b 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/getpivotdata.fods
@@ -7906,9 +7906,17 @@
  
 
 
- 
- 
- 
+ 
+  34
+ 
+ 
+  34
+ 
+ 
+  TRUE
+ 
+ 
  
  
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index efa77beb3377..b74fc5d7dfe5 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1341,11 +1341,13 @@ public:
 {
 size_t nRank1 = mrDimOrder.size();
 size_t nRank2 = mrDimOrder.size();
-ScDPSaveData::DimOrderType::const_iterator it1 = 
mrDimOrder.find(r1.FieldName);
+ScDPSaveData::DimOrderType::const_iterator it1 = mrDimOrder.find(
+   

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2022-05-15 Thread Luboš Luňák (via logerrit)
 sc/qa/unit/data/functions/statistical/fods/countif.fods  |   54 +++--
 sc/qa/unit/data/functions/statistical/fods/countifs.fods |   58 +--
 sc/source/core/data/queryiter.cxx|9 ++
 3 files changed, 106 insertions(+), 15 deletions(-)

New commits:
commit 8f61250bf9804ed54e7d960f1446a40b29d1a122
Author: Luboš Luňák 
AuthorDate: Fri May 13 17:01:32 2022 +0200
Commit: Luboš Luňák 
CommitDate: Sun May 15 10:50:15 2022 +0200

no ScSortedRangeCache-based query for number-as-string (tdf#149071)

The comparison depends on the cell encountered, which makes it hard
to prepare the sorted data.

Change-Id: I22f55003acde7eedadb8a4c8d61390dd30b6ac8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134287
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/data/functions/statistical/fods/countif.fods 
b/sc/qa/unit/data/functions/statistical/fods/countif.fods
index 3e77a2ed49c8..41ee8f439791 100644
--- a/sc/qa/unit/data/functions/statistical/fods/countif.fods
+++ b/sc/qa/unit/data/functions/statistical/fods/countif.fods
@@ -4048,16 +4048,54 @@
  
 
 
+ 
+  1
+ 
+ 
+  1
+ 
+ 
+  TRUE
+ 
+ 
+  =COUNTIF(I46:L46;)
+ 
+ 
+  numbers entered as string
+ 
+ 
+  3
+ 
  
- 
- 
- 
- 
- 
- 
- 
+ 
+  3
+ 
 
-
+
+ 
+  0
+ 
+ 
+  0
+ 
+ 
+  TRUE
+ 
+ 
+  =COUNTIF(I47:L47;)
+ 
+ 
+  numbers entered as string
+ 
+ 
+  2
+ 
+ 
+ 
+  1
+ 
+
+
  
  
  
diff --git a/sc/qa/unit/data/functions/statistical/fods/countifs.fods 
b/sc/qa/unit/data/functions/statistical/fods/countifs.fods
index 21f247f7139f..b236a8bebb83 100644
--- a/sc/qa/unit/data/functions/statistical/fods/countifs.fods
+++ b/sc/qa/unit/data/functions/statistical/fods/countifs.fods
@@ -3898,10 +3898,54 @@
  
   =COUNTIFS(AF2:AF7,   
AF6,AG2:AG7,  AG4)
  
- 
- 
- 
- 
+
+
+ 
+  1
+ 
+ 
+  1
+ 
+ 
+  TRUE
+ 
+ 
+  =COUNTIFS(I38:I39;F38)
+ 
+ 
+  numbers entered as string
+ 
+ 
+  3
+ 
+ 
+ 
+  3
+ 
+
+
+ 
+  0
+ 
+ 
+  0
+ 
+ 
+  TRUE
+ 
+ 
+  =COUNTIFS(I38:I39;F39)
+ 
+ 
+  numbers entered as string
+ 
+ 
+  2
+ 
+ 
+ 
+  1
+ 
 
 
  
@@ -4335,17 +4379,17 @@
   
   
  
- 
+ 
   
   
   
  
- 
+ 
   
   
   
  
- 
+ 
   
   
   
diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index f492d917b1eb..aeb310c706b5 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -1238,6 +1238,13 @@ static bool CanBeUsedForSorterCache(const ScDocument& 
rDoc, const ScQueryParam&
 && rParam.GetEntry(0).eOp != SC_GREATER && rParam.GetEntry(0).eOp != 
SC_GREATER_EQUAL
 && rParam.GetEntry(0).eOp != SC_EQUAL)
 return false;
+// tdf#149071 - numbers entered as string can be compared both as numbers
+// and as strings, depending on the cell content, and that makes it hard 
to pre-sort
+// the data; such queries are ScQueryEntry::ByValue but have maString set 
too
+// (see ScQueryParamBase::FillInExcelSyntax())
+if(rParam.GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByValue
+&& rParam.GetEntry(0).GetQueryItem().maString.isValid())
+return false;
 // For unittests allow inefficient caching, in order for the code to be 
checked.
 static bool inUnitTest = getenv("LO_TESTNAME") != nullptr;
 if(refData == nullptr || refData->Ref1.IsRowRel() || 
refData->Ref2.IsRowRel())
commit 3165328258c2d7031801d6074611f82b59bec8b5
Author: Luboš Luňák 
AuthorDate: Fri May 13 15:31:28 2022 +0200
Commit: Luboš Luňák 
CommitDate: Sun May 15 10:50:00 2022 +0200

ScSortedRangeCache-based query doesn't work with mbRangeLookup

Change-Id: I9ce8e3547fc261e92e1330df4c054c3efe532d61
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134286
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index ac8c791710e2..f492d917b1eb 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -1229,6 +1229,8 @@ static bool CanBeUsedForSorterCache(const ScDocument& 
rDoc, const ScQueryParam&
 return false;
 if(rParam.bHasHeader)
 return false;
+if(rParam.mbRangeLookup)
+return false;
 if(rParam.GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString
 && !ScQueryEvaluator::isMatchWholeCell(rDoc, rParam.GetEntry(0)))
 return false; // substring 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source sfx2/source

2021-03-08 Thread Szymon Kłos (via logerrit)
 sc/qa/uitest/calc_tests9/pivotTable.py |6 ++--
 sc/source/ui/attrdlg/scdlgfact.cxx |   14 --
 sc/source/ui/attrdlg/scdlgfact.hxx |   10 ---
 sc/source/ui/dbgui/PivotLayoutTreeList.cxx |   26 +++
 sc/source/ui/dbgui/PivotLayoutTreeListData.cxx |   34 ++---
 sc/source/ui/dbgui/pvfundlg.cxx|9 --
 sc/source/ui/inc/PivotLayoutTreeList.hxx   |1 
 sc/source/ui/inc/pvfundlg.hxx  |4 ++
 sfx2/source/appl/sfxhelp.cxx   |7 +
 9 files changed, 74 insertions(+), 37 deletions(-)

New commits:
commit 6b51f618e3ddfc7350a25a1f2bde689fed735f36
Author: Szymon Kłos 
AuthorDate: Mon Feb 8 19:01:00 2021 +0100
Commit: Szymon Kłos 
CommitDate: Mon Mar 8 11:51:02 2021 +0100

lok: send help even when document not ready

Change-Id: I44855ef00a6c54a774965b3c951a4476ed5c8b01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110593
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Henry Castro 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112159
Tested-by: Jenkins
Reviewed-by: Szymon Kłos 

diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 03afafcd4fa4..2e3e80680feb 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -719,6 +719,13 @@ static bool impl_showOnlineHelp( const OUString& rURL )

aHelpLink.toUtf8().getStr());
 return true;
 }
+else if (GetpApp())
+{
+
GetpApp()->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED,
+   
aHelpLink.toUtf8().getStr());
+return true;
+}
+
 return false;
 }
 
commit c883303400158573cfd3dc2bc0ad59fa8f64ce48
Author: Szymon Kłos 
AuthorDate: Tue Dec 15 15:31:49 2020 +0100
Commit: Szymon Kłos 
CommitDate: Mon Mar 8 11:50:51 2021 +0100

pivot table: make subdialogs of pivot table dialog async

Change-Id: I2c1b26ebe661a2f66bc7bf94e4f3ede2fc5e18b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107775
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112095
Tested-by: Jenkins

diff --git a/sc/qa/uitest/calc_tests9/pivotTable.py 
b/sc/qa/uitest/calc_tests9/pivotTable.py
index d85894bf9af6..2da282bb19d3 100644
--- a/sc/qa/uitest/calc_tests9/pivotTable.py
+++ b/sc/qa/uitest/calc_tests9/pivotTable.py
@@ -53,7 +53,7 @@ class pivotTable(UITestCase):
 self.assertEqual('true', 
get_state_as_dict(xEmptyLine)['Selected'])
 
 xOKBtn = dialog2.getChild("ok")
-self.ui_test.close_dialog_through_button(xOKBtn)
+xOKBtn.executeAction("CLICK", tuple())
 
 def handle_options_dialog_second_time(dialog2):
 xEmptyLine = dialog2.getChild("emptyline")
@@ -62,7 +62,7 @@ class pivotTable(UITestCase):
 self.assertEqual('false', 
get_state_as_dict(xEmptyLine)['Selected'])
 
 xCancelBtn = dialog2.getChild("cancel")
-self.ui_test.close_dialog_through_button(xCancelBtn)
+xCancelBtn.executeAction("CLICK", tuple())
 
 def handle_options_dialog_third_time(dialog2):
 xEmptyLine = dialog2.getChild("emptyline")
@@ -70,7 +70,7 @@ class pivotTable(UITestCase):
 self.assertEqual('true', 
get_state_as_dict(xEmptyLine)['Selected'])
 
 xOKBtn = dialog2.getChild("ok")
-self.ui_test.close_dialog_through_button(xOKBtn)
+xOKBtn.executeAction("CLICK", tuple())
 
 self.ui_test.execute_blocking_action(optionBtn.executeAction, 
args=('CLICK', ()),
 dialog_handler=handle_options_dialog_first_time)
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx 
b/sc/source/ui/attrdlg/scdlgfact.cxx
index b77f603540de..bc22a3fb443a 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -230,11 +230,21 @@ short AbstractScDPFunctionDlg_Impl::Execute()
 return m_xDlg->run();
 }
 
+bool 
AbstractScDPFunctionDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext 
)
+{
+return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 short AbstractScDPSubtotalDlg_Impl::Execute()
 {
 return m_xDlg->run();
 }
 
+bool 
AbstractScDPSubtotalDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext 
)
+{
+return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 short AbstractScDPNumGroupDlg_Impl::Execute()
 {
 return m_xDlg->run();
@@ -1123,7 +1133,7 @@ VclPtr 
ScAbstractDialogFactory_Impl::CreateScDPFunction

 const ScDPLabelData& rLabelData,
  

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source uitest/uitest

2020-11-17 Thread Attila Szűcs (via logerrit)
 sc/qa/unit/copy_paste_test.cxx|   52 
 sc/qa/unit/data/ods/tdf137624_autofillMergedMixed.ods |binary
 sc/source/core/data/table4.cxx|   75 --
 uitest/uitest/uihelper/common.py  |5 +
 4 files changed, 110 insertions(+), 22 deletions(-)

New commits:
commit 09eccdc87db5258ea779e2bcc12437f802624ee5
Author: Attila Szűcs 
AuthorDate: Fri Nov 13 09:42:00 2020 +0100
Commit: László Németh 
CommitDate: Tue Nov 17 13:02:19 2020 +0100

tdf#137624 sc: autofill mixed sequences in merged cells

Improve FillAnalyse, FillSeries to continue linear sequences
of mixed values in merged cells (mixed values are string + number,
like 'a1','a2' or '1a').

It discovers the linear sequence only if the string parts are
identical. It recognizes user lists only if all elements are in
the same user list.

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: I8810a0f1d637436222e3d0b9219da38ccb7c6346
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105784
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx
index 62ee0bcc53f0..87d8311bdc9b 100644
--- a/sc/qa/unit/copy_paste_test.cxx
+++ b/sc/qa/unit/copy_paste_test.cxx
@@ -51,6 +51,7 @@ public:
 void tdf137653_137654_autofillUserlist();
 void tdf113500_autofillMixed();
 void tdf137625_autofillMergedUserlist();
+void tdf137624_autofillMergedMixed();
 
 CPPUNIT_TEST_SUITE(ScCopyPasteTest);
 CPPUNIT_TEST(testCopyPasteXLS);
@@ -67,6 +68,7 @@ public:
 CPPUNIT_TEST(tdf137653_137654_autofillUserlist);
 CPPUNIT_TEST(tdf113500_autofillMixed);
 CPPUNIT_TEST(tdf137625_autofillMergedUserlist);
+CPPUNIT_TEST(tdf137624_autofillMergedMixed);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -930,7 +932,57 @@ void ScCopyPasteTest::tdf137625_autofillMergedUserlist()
 }
 }
 
+void ScCopyPasteTest::tdf137624_autofillMergedMixed()
+{
+ScDocShellRef xDocSh = 
loadDocAndSetupModelViewController("tdf137624_autofillMergedMixed.", 
FORMAT_ODS, true);
+ScDocument& rDoc = xDocSh->GetDocument();
+
+// Get the document controller
+ScTabViewShell* pView = xDocSh->GetBestViewShell(false);
+CPPUNIT_ASSERT(pView != nullptr);
 
+// add 1aa,2bb,3cc,4dd,5ee,6ff to userlist, to test that autofill won't 
confuse it with 1aa,3aa
+// delete every userlist to make sure there won't be any string that is in 
2 different userlist
+ScGlobal::GetUserList()->clear();
+addToUserList({ "1aa,2bb,3cc,4dd,5ee,6ff" });
+
+// fillauto mixed (string + number), these areas contain only merged cells
+pView->FillAuto(FILL_TO_RIGHT, 7, 5, 12, 7, 6);   //H6:M8
+pView->FillAuto(FILL_TO_LEFT, 7, 5, 12, 7, 6);//H6:M8
+pView->FillAuto(FILL_TO_BOTTOM, 1, 20, 3, 23, 4); //B21:D24
+pView->FillAuto(FILL_TO_TOP, 1, 20, 3, 23, 4);//B21:D24
+
+// compare the results of fill-right / -left with the reference stored in 
the test file
+// this compares the whole area blindly, for specific test cases, check 
the test file
+for (int nCol = 1; nCol <= 18; nCol++)
+{
+for (int nRow = 5; nRow <= 7; nRow++)
+{
+CellType nType1 = rDoc.GetCellType(ScAddress(nCol, nRow, 0));
+CellType nType2 = rDoc.GetCellType(ScAddress(nCol, nRow + 4, 0));
+OUString aStr1 = rDoc.GetString(nCol, nRow, 0);
+OUString aStr2 = rDoc.GetString(nCol, nRow + 4, 0);
+
+CPPUNIT_ASSERT_EQUAL(nType1, nType2);
+CPPUNIT_ASSERT_EQUAL(aStr1, aStr2);
+}
+}
+
+// compare the results of fill-up / -down
+for (int nCol = 1; nCol <= 3; nCol++)
+{
+for (int nRow = 16; nRow <= 27; nRow++)
+{
+CellType nType1 = rDoc.GetCellType(ScAddress(nCol, nRow, 0));
+CellType nType2 = rDoc.GetCellType(ScAddress(nCol + 4, nRow, 0));
+OUString aStr1 = rDoc.GetString(nCol, nRow, 0);
+OUString aStr2 = rDoc.GetString(nCol + 4, nRow, 0);
+
+CPPUNIT_ASSERT_EQUAL(nType1, nType2);
+CPPUNIT_ASSERT_EQUAL(aStr1, aStr2);
+}
+}
+}
 
 ScCopyPasteTest::ScCopyPasteTest()
   : ScBootstrapFixture( "sc/qa/unit/data" )
diff --git a/sc/qa/unit/data/ods/tdf137624_autofillMergedMixed.ods 
b/sc/qa/unit/data/ods/tdf137624_autofillMergedMixed.ods
new file mode 100644
index ..cc1b6a7c6ab8
Binary files /dev/null and 
b/sc/qa/unit/data/ods/tdf137624_autofillMergedMixed.ods differ
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 2e29cecff86b..a777aca898ae 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -420,25 +420,9 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 }
 else if (eCellType == CELLTYPE_STRING || eCellType == 
CELLTYPE_EDIT)

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2019-09-25 Thread Tamás Zolnai (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   40 ++-
 sc/source/ui/view/tabview.cxx|   38 -
 2 files changed, 52 insertions(+), 26 deletions(-)

New commits:
commit 72b3b651705b6f5a3d1f02572148c5697af9a8a9
Author: Tamás Zolnai 
AuthorDate: Sat Sep 21 16:13:14 2019 +0200
Commit: Tamás Zolnai 
CommitDate: Wed Sep 25 12:33:15 2019 +0200

sc lok: Test invalidation triggered by jumping horizontally on the sheet

Change-Id: Ia3d3b3f3020151939b8fb1cf48635303dc49892e
Reviewed-on: https://gerrit.libreoffice.org/79495
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 35e61c791db6..acd017773b54 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -103,6 +103,7 @@ public:
 void testSheetChangeInvalidation();
 void testInsertDeletePageInvalidation();
 void testGetRowColumnHeadersInvalidation();
+void testJumpHorizontallyInvalidation();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnSelections);
@@ -141,6 +142,7 @@ public:
 CPPUNIT_TEST(testSheetChangeInvalidation);
 CPPUNIT_TEST(testInsertDeletePageInvalidation);
 CPPUNIT_TEST(testGetRowColumnHeadersInvalidation);
+CPPUNIT_TEST(testJumpHorizontallyInvalidation);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1783,6 +1785,33 @@ void 
ScTiledRenderingTest::testGetRowColumnHeadersInvalidation()
 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(49725, 0, 75225, 19380), 
aView1.m_aInvalidations[0]);
 }
 
+void ScTiledRenderingTest::testJumpHorizontallyInvalidation()
+{
+comphelper::LibreOfficeKit::setActive();
+
+ScModelObj* pModelObj = createDoc("empty.ods");
+ScViewData* pViewData = ScDocShell::GetViewData();
+CPPUNIT_ASSERT(pViewData);
+
+int nView1 = SfxLokHelper::getView();
+ViewCallback aView1;
+CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
+
+SfxLokHelper::setView(nView1);
+aView1.m_bInvalidateTiles = false;
+aView1.m_aInvalidations.clear();
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN | 
KEY_MOD2);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | 
KEY_MOD2);
+Scheduler::ProcessEventsToIdle();
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN | 
KEY_MOD2);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | 
KEY_MOD2);
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
+CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidations.size());
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 10, 10), 
aView1.m_aInvalidations[0]);
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(26775, 0, 39525, 13005), 
aView1.m_aInvalidations[1]);
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
commit e740aaf876edd58c1f5c5e17af2495cad36cfc27
Author: Tamás Zolnai 
AuthorDate: Sat Sep 21 15:48:44 2019 +0200
Commit: Tamás Zolnai 
CommitDate: Wed Sep 25 12:32:53 2019 +0200

sc lok: Optimize invalidation triggered by getRowColumnHeaders() method

Don't call a full invalidation, rather use invalidation only on the new
area. Make sure that the invalidation is called first.

Change-Id: I89d1c6342ed8e95fe738a876a76ca6feda031962
Reviewed-on: https://gerrit.libreoffice.org/79494
Reviewed-by: Tamás Zolnai 
Tested-by: Tamás Zolnai 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index a22cca344966..35e61c791db6 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1761,9 +1761,8 @@ void 
ScTiledRenderingTest::testGetRowColumnHeadersInvalidation()
 pModelObj->getRowColumnHeaders(tools::Rectangle(0, 15, 19650, 5400));
 Scheduler::ProcessEventsToIdle();
 CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
-CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidations.size());
-CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 10, 10), 
aView1.m_aInvalidations[0]);
-CPPUNIT_ASSERT_EQUAL(tools::Rectangle(26775, 0, 49725, 13005), 
aView1.m_aInvalidations[1]);
+CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(26775, 0, 49725, 13005), 
aView1.m_aInvalidations[0]);
 
 // Extend area top-to-bottom
 aView1.m_bInvalidateTiles = false;
@@ -1771,9 +1770,8 @@ void 
ScTiledRenderingTest::testGetRowColumnHeadersInvalidation()
 pModelObj->getRowColumnHeaders(tools::Rectangle(0, 5400, 19650, 9800));
 Scheduler::ProcessEventsToIdle();
 CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
-CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidations.size());
-CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 10, 10), 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source solenv/bin xmloff/inc xmloff/source xmloff/util

2019-07-25 Thread Miklos Vajna (via logerrit)
 sc/qa/unit/copy_paste_test.cxx  |   59 
 sc/source/ui/inc/impex.hxx  |4 +-
 sc/source/ui/undo/undoblk.cxx   |6 ++--
 solenv/bin/native-code.py   |1 
 xmloff/inc/facreg.hxx   |7 
 xmloff/source/core/facreg.cxx   |5 ---
 xmloff/source/draw/sdxmlimp.cxx |   23 +--
 xmloff/util/xo.component|3 +-
 8 files changed, 77 insertions(+), 31 deletions(-)

New commits:
commit 3f471651049a318d7d8917855929e0535daf14b9
Author: Miklos Vajna 
AuthorDate: Wed Jul 24 21:26:11 2019 +0200
Commit: Miklos Vajna 
CommitDate: Thu Jul 25 09:21:20 2019 +0200

xmloff: create XMLImportStylesImportOasis instances with an uno constructor

See tdf#74608 for motivation.

Change-Id: I7e56486339d5fd436d4dba723bac8bb9bbed170b
Reviewed-on: https://gerrit.libreoffice.org/76275
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index f7858cdd49d4..fc5e2f725c21 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -273,6 +273,7 @@ core_constructor_list = [
 "com_sun_star_comp_Impress_XMLOasisMetaExporter_get_implementation",
 "com_sun_star_comp_Impress_XMLOasisMetaImporter_get_implementation",
 "com_sun_star_comp_Impress_XMLOasisContentImporter_get_implementation",
+"com_sun_star_comp_Impress_XMLOasisStylesImporter_get_implementation",
 "com_sun_star_comp_Impress_XMLOasisSettingsExporter_get_implementation",
 "com_sun_star_comp_Impress_XMLOasisSettingsImporter_get_implementation",
 "com_sun_star_comp_Draw_XMLOasisImporter_get_implementation",
diff --git a/xmloff/inc/facreg.hxx b/xmloff/inc/facreg.hxx
index 8541b7842b17..7cb149cac9f1 100644
--- a/xmloff/inc/facreg.hxx
+++ b/xmloff/inc/facreg.hxx
@@ -33,13 +33,6 @@ namespace com { namespace sun { namespace star {
 namespace uno { class XInterface; }
 } } }
 
-// impress oasis import
-OUString XMLImpressStylesImportOasis_getImplementationName() throw();
-css::uno::Sequence 
XMLImpressStylesImportOasis_getSupportedServiceNames() throw();
-/// @throws css::uno::Exception
-css::uno::Reference 
XMLImpressStylesImportOasis_createInstance(
-css::uno::Reference const & rSMgr);
-
 // impress OOo export
 OUString XMLImpressExportOOO_getImplementationName() throw();
 css::uno::Sequence XMLImpressExportOOO_getSupportedServiceNames() 
throw();
diff --git a/xmloff/source/core/facreg.cxx b/xmloff/source/core/facreg.cxx
index cba072106f97..0190e6b0d818 100644
--- a/xmloff/source/core/facreg.cxx
+++ b/xmloff/source/core/facreg.cxx
@@ -56,10 +56,7 @@ XMLOFF_DLLPUBLIC void * xo_component_getFactory( const 
sal_Char * pImplName, voi
 
 const sal_Int32 nImplNameLen = strlen( pImplName );
 
-// impress oasis import
-SINGLEFACTORY( XMLImpressStylesImportOasis )
-
-else SINGLEFACTORY( AnimationsImport )
+SINGLEFACTORY( AnimationsImport )
 
 // impress OOo export
 else SINGLEFACTORY( XMLImpressExportOOO )
diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx
index d161d68d657b..5b5b1ad63ee2 100644
--- a/xmloff/source/draw/sdxmlimp.cxx
+++ b/xmloff/source/draw/sdxmlimp.cxx
@@ -260,20 +260,6 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 
SdXMLFlatDocContext_Imp
 }
 }
 
-#define SERVICE(classname,servicename,implementationname,draw,flags)\
-uno::Sequence< OUString > classname##_getSupportedServiceNames() throw()\
-{\
-return uno::Sequence< OUString > { servicename };\
-}\
-OUString classname##_getImplementationName() throw()\
-{\
-return OUString( implementationname );\
-}\
-uno::Reference< uno::XInterface > classname##_createInstance(const 
uno::Reference< lang::XMultiServiceFactory > & rSMgr)\
-{\
-return static_cast(new SdXMLImport( 
comphelper::getComponentContext(rSMgr), implementationname, draw, flags )); \
-}
-
 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
 com_sun_star_comp_Impress_XMLOasisImporter_get_implementation(
 uno::XComponentContext* pCtx, uno::Sequence const& /*rSeq*/)
@@ -324,7 +310,14 @@ 
com_sun_star_comp_Draw_XMLOasisSettingsImporter_get_implementation(
 new SdXMLImport(pCtx, "XMLDrawSettingsImportOasis", true, 
SvXMLImportFlags::SETTINGS));
 }
 
-SERVICE( XMLImpressStylesImportOasis, 
"com.sun.star.comp.Impress.XMLOasisStylesImporter", 
"XMLImpressStylesImportOasis", false, 
SvXMLImportFlags::STYLES|SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::MASTERSTYLES
 )
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+com_sun_star_comp_Impress_XMLOasisStylesImporter_get_implementation(
+uno::XComponentContext* pCtx, uno::Sequence const& /*rSeq*/)
+{
+return cppu::acquire(new SdXMLImport(pCtx, "XMLImpressStylesImportOasis", 
false,
+ SvXMLImportFlags::STYLES | 
SvXMLImportFlags::AUTOSTYLES
+ | 
SvXMLImportFlags::MASTERSTYLES));
+}
 
 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2019-05-12 Thread Caolán McNamara (via logerrit)
 sc/qa/unit/screenshots/screenshots.cxx |3 +--
 sc/source/ui/inc/tabvwsh.hxx   |1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

New commits:
commit b49e1e709b3fc4b9831fd0961e9310ebf1050429
Author: Caolán McNamara 
AuthorDate: Sun May 12 19:24:35 2019 +0100
Commit: Caolán McNamara 
CommitDate: Sun May 12 22:20:12 2019 +0200

drop unneeded forward declare

Change-Id: Ib9a7d484cb93c0dbf6a13b540895e0e5d5c00d49
Reviewed-on: https://gerrit.libreoffice.org/72202
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index a738669dd7d1..7d51dbc5c7fa 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -38,7 +38,6 @@
 class SdrOle2Obj;
 class SfxBindings;
 class SfxChildWindow;
-class SfxModelessDialog;
 class SvxNumberInfoItem;
 struct SfxChildWinInfo;
 
commit e4228ba740f86f701b9d6f0472b65383f4cf44f0
Author: Caolán McNamara 
AuthorDate: Sun May 12 19:21:17 2019 +0100
Commit: Caolán McNamara 
CommitDate: Sun May 12 22:19:28 2019 +0200

drop intermediate vcl::Window

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

diff --git a/sc/qa/unit/screenshots/screenshots.cxx 
b/sc/qa/unit/screenshots/screenshots.cxx
index 402db2452590..96b2779860d2 100644
--- a/sc/qa/unit/screenshots/screenshots.cxx
+++ b/sc/qa/unit/screenshots/screenshots.cxx
@@ -192,8 +192,7 @@ VclPtr 
ScScreenshotTest::createDialogByID(sal_uInt32 nID)
 case 8: // "modules/scalc/ui/inputstringdialog.ui"
 {
 const OString aEmpty("");
-vcl::Window* pWindow = mpViewShell->GetDialogParent();
-pReturnDialog = mpFact->CreateScStringInputDlg(pWindow ? 
pWindow->GetFrameWeld() : nullptr,
+pReturnDialog = 
mpFact->CreateScStringInputDlg(mpViewShell->GetFrameWeld(),
 ScResId(SCSTR_APDTABLE), ScResId(SCSTR_NAME),
 aDefaultSheetName, aEmpty, aEmpty );
 break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2019-05-04 Thread Dennis Francis (via logerrit)
 sc/qa/unit/data/xlsx/conditional_fmt_checkpriority.xlsx |binary
 sc/qa/unit/data/xlsx/conditional_fmt_origin.xlsx|binary
 sc/qa/unit/subsequent_export-test.cxx   |   63 +++
 sc/source/filter/excel/xecontent.cxx|   19 ++-
 sc/source/filter/excel/xeextlst.cxx |2 
 sc/source/filter/inc/condformatbuffer.hxx   |   13 ++
 sc/source/filter/inc/extlstcontext.hxx  |2 
 sc/source/filter/inc/xecontent.hxx  |2 
 sc/source/filter/oox/condformatbuffer.cxx   |   87 +++-
 sc/source/filter/oox/extlstcontext.cxx  |   15 ++
 10 files changed, 188 insertions(+), 15 deletions(-)

New commits:
commit ca40d4ce9b8134fd8bfc90e9e8289b620163475b
Author: Dennis Francis 
AuthorDate: Thu Apr 25 08:37:58 2019 +0530
Commit: Andras Timar 
CommitDate: Sat May 4 10:22:21 2019 +0200

tdf#124953: Use rangelist's combined range top-left address...

as origin address in the conditional format formula on xlsx export.
Excel seems to get confused if anything else is supplied as the
origin in the formula.

For example, before this patch, for a condfmt range over the
range-list [A3:C5 E1:F2], the origin address used in the formula
(for text search type entries) is A3.


   
   NOT(ISERROR(SEARCH("ABC",A3)))
   


In this patch we use the top-left cell address(A1) of the combined range 
"A1:F5" as
the origin address.

   NOT(ISERROR(SEARCH("ABC",A1)))

Change-Id: If08a859bc361f925148ff463758d03ebbc41c0ac
Reviewed-on: https://gerrit.libreoffice.org/71312
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git a/sc/qa/unit/data/xlsx/conditional_fmt_origin.xlsx 
b/sc/qa/unit/data/xlsx/conditional_fmt_origin.xlsx
new file mode 100644
index ..aef60b6cb489
Binary files /dev/null and b/sc/qa/unit/data/xlsx/conditional_fmt_origin.xlsx 
differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index de8eb723b884..bc8545ca182e 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -105,6 +105,7 @@ public:
 void testConditionalFormatRangeListXLSX();
 void testConditionalFormatContainsTextXLSX();
 void testConditionalFormatPriorityCheckXLSX();
+void testConditionalFormatOriginXLSX();
 void testMiscRowHeightExport();
 void testNamedRangeBugfdo62729();
 void testBuiltinRangesXLSX();
@@ -243,6 +244,7 @@ public:
 CPPUNIT_TEST(testConditionalFormatRangeListXLSX);
 CPPUNIT_TEST(testConditionalFormatContainsTextXLSX);
 CPPUNIT_TEST(testConditionalFormatPriorityCheckXLSX);
+CPPUNIT_TEST(testConditionalFormatOriginXLSX);
 CPPUNIT_TEST(testMiscRowHeightExport);
 CPPUNIT_TEST(testNamedRangeBugfdo62729);
 CPPUNIT_TEST(testBuiltinRangesXLSX);
@@ -3976,6 +3978,19 @@ void 
ScExportTest::testConditionalFormatPriorityCheckXLSX()
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong priorities for A3", 
bHighPriorityExtensionA3, nA3ExtPriority < nA3NormalPriority);
 }
 
+void ScExportTest::testConditionalFormatOriginXLSX()
+{
+ScDocShellRef xDocSh = loadDoc("conditional_fmt_origin.", FORMAT_XLSX);
+CPPUNIT_ASSERT(xDocSh.is());
+
+xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, 
"xl/worksheets/sheet1.xml", FORMAT_XLSX);
+CPPUNIT_ASSERT(pDoc);
+
+// tdf#124953 : The range-list is B3:C6 F1:G2, origin address in the 
formula should be B1, not B3.
+OUString aFormula = getXPathContent(pDoc, 
"//x:conditionalFormatting/x:cfRule/x:formula");
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong origin address in formula", 
OUString("NOT(ISERROR(SEARCH(\"BAC\",B1)))"), aFormula);
+}
+
 void ScExportTest::testEscapeCharInNumberFormatXLSX()
 {
 ScDocShellRef xDocSh = loadDoc("tdf81939.", FORMAT_XLSX);
diff --git a/sc/source/filter/excel/xecontent.cxx 
b/sc/source/filter/excel/xecontent.cxx
index f71d48337baf..234c681c59c3 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -579,7 +579,7 @@ void XclExpLabelranges::Save( XclExpStream& rStrm )
 class XclExpCFImpl : protected XclExpRoot
 {
 public:
-explicitXclExpCFImpl( const XclExpRoot& rRoot, const 
ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority );
+explicitXclExpCFImpl( const XclExpRoot& rRoot, const 
ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin );
 
 /** Writes the body of the CF record. */
 voidWriteBody( XclExpStream& rStrm );
@@ -587,6 +587,7 @@ public:
 
 private:
 const ScCondFormatEntry& mrFormatEntry; /// Calc conditional format entry.
+ScAddress   maOrigin;   /// Top left cell of the combined 
range
 XclFontData maFontData; /// Font formatting attributes.
 XclExpCellBordermaBorder; 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2019-04-08 Thread Caolán McNamara (via logerrit)
 sc/qa/unit/data/xls/pass/ofz14101-1.xls |binary
 sc/qa/unit/data/xls/pass/ofz14120-1.xls |binary
 sc/source/core/data/document.cxx|2 +-
 sc/source/core/data/table7.cxx  |4 ++--
 4 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 3d57865fa367acf143232373f1096d067128bda6
Author: Caolán McNamara 
AuthorDate: Mon Apr 8 09:51:58 2019 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 8 12:11:24 2019 +0200

ofz#14101 another batch of oss-fuzz failures

since...

commit 7282014e362a1529a36c88eb308df8ed359c2cfa
Date:   Fri Feb 1 15:15:16 2019 +0100

tdf#50916 Makes numbers of columns dynamic

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

diff --git a/sc/qa/unit/data/xls/pass/ofz14101-1.xls 
b/sc/qa/unit/data/xls/pass/ofz14101-1.xls
new file mode 100644
index ..953f255fb19e
Binary files /dev/null and b/sc/qa/unit/data/xls/pass/ofz14101-1.xls differ
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index a3df4639e94b..f41e9e34c1d4 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6527,7 +6527,7 @@ void ScDocument::SetNote(const ScAddress& rPos, 
std::unique_ptr pNote)
 
 void ScDocument::SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, 
std::unique_ptr pNote)
 {
-return maTabs[nTab]->aCol[nCol].SetCellNote(nRow, std::move(pNote));
+return maTabs[nTab]->CreateColumnIfNotExists(nCol).SetCellNote(nRow, 
std::move(pNote));
 }
 
 bool ScDocument::HasNote(const ScAddress& rPos) const
commit 368448e7843bf4e58ed5637a731c67c76c3c11cb
Author: Caolán McNamara 
AuthorDate: Mon Apr 8 09:23:46 2019 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 8 12:11:10 2019 +0200

ofz#14120 another batch of oss-fuzz failures

since...

commit 7282014e362a1529a36c88eb308df8ed359c2cfa
Date:   Fri Feb 1 15:15:16 2019 +0100

tdf#50916 Makes numbers of columns dynamic

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

diff --git a/sc/qa/unit/data/xls/pass/ofz14120-1.xls 
b/sc/qa/unit/data/xls/pass/ofz14120-1.xls
new file mode 100644
index ..5d526b445c9d
Binary files /dev/null and b/sc/qa/unit/data/xls/pass/ofz14120-1.xls differ
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index e0ed0c96bce6..ae67c319651e 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -421,10 +421,10 @@ bool ScTable::IsEditActionAllowed(
 
 std::unique_ptr ScTable::GetColumnIterator( SCCOL nCol, 
SCROW nRow1, SCROW nRow2 ) const
 {
-if (!ValidCol(nCol) || nCol >= aCol.size())
+if (!ValidCol(nCol))
 return std::unique_ptr();
 
-return aCol[nCol].GetColumnIterator(nRow1, nRow2);
+return CreateColumnIfNotExists(nCol).GetColumnIterator(nRow1, nRow2);
 }
 
 bool ScTable::EnsureFormulaCellResults( const SCCOL nCol1, SCROW nRow1, const 
SCCOL nCol2, SCROW nRow2, bool bSkipRunning )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2018-07-14 Thread Libreoffice Gerrit user
 sc/qa/unit/data/ods/conditionalformat_containstext.ods |binary
 sc/qa/unit/subsequent_export-test.cxx  |   13 +
 sc/source/filter/excel/xecontent.cxx   |   10 ++
 3 files changed, 23 insertions(+)

New commits:
commit 7e8dbbb02f25278d5afc51ae4a397831f5b21239
Author: Markus Mohrhard 
AuthorDate: Sat Jul 14 15:29:41 2018 +0200
Commit: Markus Mohrhard 
CommitDate: Sun Jul 15 00:36:25 2018 +0200

add test for tdf#117816

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

diff --git a/sc/qa/unit/data/ods/conditionalformat_containstext.ods 
b/sc/qa/unit/data/ods/conditionalformat_containstext.ods
new file mode 100644
index ..fa3e21e29f5a
Binary files /dev/null and 
b/sc/qa/unit/data/ods/conditionalformat_containstext.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 09364c8de62e..f6e151390a5e 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -107,6 +107,7 @@ public:
 void testDataBarExportODS();
 void testDataBarExportXLSX();
 void testConditionalFormatRangeListXLSX();
+void testConditionalFormatContainsTextXLSX();
 void testMiscRowHeightExport();
 void testNamedRangeBugfdo62729();
 void testBuiltinRangesXLSX();
@@ -226,6 +227,7 @@ public:
 CPPUNIT_TEST(testDataBarExportODS);
 CPPUNIT_TEST(testDataBarExportXLSX);
 CPPUNIT_TEST(testConditionalFormatRangeListXLSX);
+CPPUNIT_TEST(testConditionalFormatContainsTextXLSX);
 CPPUNIT_TEST(testMiscRowHeightExport);
 CPPUNIT_TEST(testNamedRangeBugfdo62729);
 CPPUNIT_TEST(testBuiltinRangesXLSX);
@@ -3876,6 +3878,17 @@ void ScExportTest::testConditionalFormatRangeListXLSX()
 assertXPath(pDoc, "//x:conditionalFormatting", "sqref", "F4 F10");
 }
 
+void ScExportTest::testConditionalFormatContainsTextXLSX()
+{
+ScDocShellRef xDocSh = loadDoc("conditionalformat_containstext.", 
FORMAT_ODS);
+CPPUNIT_ASSERT(xDocSh.is());
+
+xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, 
"xl/worksheets/sheet1.xml", FORMAT_XLSX);
+CPPUNIT_ASSERT(pDoc);
+
+assertXPathContent(pDoc, "//x:conditionalFormatting/x:cfRule/x:formula", 
"NOT(ISERROR(SEARCH(\"test\",A1)))");
+}
+
 void ScExportTest::testEscapeCharInNumberFormatXLSX()
 {
 ScDocShellRef xDocSh = loadDoc("tdf81939.", FORMAT_XLSX);
commit e77596be879c25f5766b73a2f67cf0ddf7775ccc
Author: Markus Mohrhard 
AuthorDate: Sat Jul 14 15:16:46 2018 +0200
Commit: Markus Mohrhard 
CommitDate: Sun Jul 15 00:36:18 2018 +0200

tdf#117816, work around MS Excel bug with containsText cond format

Excel seems to require the formula that is equal to the containsText
condition.

According to cfRule (18.3.1.10) "Only rules with a type attribute
 value of expression support formula syntax." which contradicts the
MS EXCEL behavior.

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

diff --git a/sc/source/filter/excel/xecontent.cxx 
b/sc/source/filter/excel/xecontent.cxx
index deb8f8dd2454..6d025f022eeb 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -998,6 +998,16 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
 rWorksheet->endElement( XML_formula );
 }
 }
+else if (IsTextRule(eOperation))
+{
+OStringBuffer aBufferOld;
+OStringBuffer aBuffer = XclXmlUtils::ToOString(aBufferOld, 
mrFormatEntry.GetValidSrcPos());
+OString aTextTopCell = aBuffer.makeStringAndClear();
+OString aFormula = "NOT(ISERROR(SEARCH(\"" + aText + "\"," + 
aTextTopCell + ")))";
+rWorksheet->startElement( XML_formula, FSEND );
+rWorksheet->writeEscaped(aFormula.getStr());
+rWorksheet->endElement( XML_formula );
+}
 // OOXTODO: XML_extLst
 rWorksheet->endElement( XML_cfRule );
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source sw/source

2018-01-23 Thread Dennis Francis
 sc/qa/unit/parallelism.cxx   |   23 +++
 sc/source/core/tool/formulagroup.cxx |   16 +---
 sw/source/uibase/dochdl/swdtflvr.cxx |2 +-
 3 files changed, 37 insertions(+), 4 deletions(-)

New commits:
commit ff166845fa5ed178a97b54bb2deef4beb0cf3bdf
Author: Dennis Francis 
Date:   Tue Jan 23 19:53:19 2018 +0530

tdf#115093 : Do not reuse singleref tokens...

...in formula group computation if the formula contains
only a single reference besides any ocOpen/ocClose pairs
wrapping it as the sole content.

In such a case the "result" formula token
returned by ScInterpreter::GetResultToken() is the same
as the original singleref token, so for each row of the
formulagroup, we need to use a separate singleref token.

Also added a unit test in sc/qa/unit/parallelism.cxx

Change-Id: I6032efc5be9b51ca1e9daf9bdd19997a949d2f43
Reviewed-on: https://gerrit.libreoffice.org/48449
Reviewed-by: Michael Meeks 
Tested-by: Jenkins 

diff --git a/sc/qa/unit/parallelism.cxx b/sc/qa/unit/parallelism.cxx
index 428d65a20bec..896b7c1d8382 100644
--- a/sc/qa/unit/parallelism.cxx
+++ b/sc/qa/unit/parallelism.cxx
@@ -46,12 +46,14 @@ public:
 void testDivision();
 void testVLOOKUP();
 void testVLOOKUPSUM();
+void testSingleRef();
 
 CPPUNIT_TEST_SUITE(ScParallelismTest);
 CPPUNIT_TEST(testSUMIFS);
 CPPUNIT_TEST(testDivision);
 CPPUNIT_TEST(testVLOOKUP);
 CPPUNIT_TEST(testVLOOKUPSUM);
+CPPUNIT_TEST(testSingleRef);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -296,6 +298,27 @@ void ScParallelismTest::testVLOOKUPSUM()
 m_pDoc->DeleteTab(0);
 }
 
+void ScParallelismTest::testSingleRef()
+{
+m_pDoc->InsertTab(0, "1");
+
+const size_t nNumRows = 200;
+for (size_t i = 0; i < nNumRows; ++i)
+{
+m_pDoc->SetValue(0, i, 0, static_cast(i));
+m_pDoc->SetFormula(ScAddress(1, i, 0), "=A" + OUString::number(i+1), 
formula::FormulaGrammar::GRAM_NATIVE_UI);
+}
+
+m_xDocShell->DoHardRecalc();
+
+for (size_t i = 0; i < nNumRows; ++i)
+{
+OString aMsg = "At row " + OString::number(i);
+CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), i, 
static_cast(m_pDoc->GetValue(1, i, 0)));
+}
+m_pDoc->DeleteTab(0);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScParallelismTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index 57ad65d2b114..b494d25d1146 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -177,6 +177,7 @@ public:
 ScTokenArray aCode2;
 
 ScInterpreterContext aContext(mrDoc, mpFormatter);
+sal_uInt16 nNumNonOpenClose = mrCode.GetLen();
 
 for (SCROW i = mnIdx; i <= mnLastIdx; ++i, maBatchTopPos.IncRow())
 {
@@ -212,7 +213,7 @@ public:
 aCode2.AddString(rPool.intern(OUString(pStr)));
 else
 {
-if ( pTargetTok->GetType() == 
formula::svString )
+if ( ( pTargetTok->GetType() == 
formula::svString ) && ( nNumNonOpenClose > 1 ) )
 
pTargetTok->SetString(rPool.intern(OUString(pStr)));
 else
 {
@@ -226,7 +227,7 @@ public:
 // Value of NaN represents an empty cell.
 if ( !pTargetTok )
 aCode2.AddToken(ScEmptyCellToken(false, 
false));
-else if ( pTargetTok->GetType() != 
formula::svEmptyCell )
+else if ( ( pTargetTok->GetType() != 
formula::svEmptyCell ) || ( nNumNonOpenClose == 1 ) )
 {
 ScEmptyCellToken* pEmptyTok = new 
ScEmptyCellToken(false, false);
 aCode2.ReplaceToken(nTokIdx, pEmptyTok, 
formula::FormulaTokenArray::CODE_ONLY);
@@ -239,7 +240,7 @@ public:
 aCode2.AddDouble(fVal);
 else
 {
-if ( pTargetTok->GetType() == 
formula::svDouble )
+if ( ( pTargetTok->GetType() == 
formula::svDouble ) && ( nNumNonOpenClose > 1 ) )
 pTargetTok->GetDoubleAsReference() = fVal;
 else
 {
@@ -291,7 +292,16 @@ public:
 break;
 default:
 if ( !pTargetTok )
+{
+if ( p->GetType() == formula::svSep )
+{
+OpCode eOp = 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-08-16 Thread Markus Mohrhard
 sc/qa/unit/data/dataprovider/html/test1.html |   44 +++
 sc/qa/unit/dataproviders_test.cxx|   42 +
 sc/source/ui/dataprovider/datatransformation.cxx |   10 +
 sc/source/ui/dataprovider/htmldataprovider.cxx   |7 +++
 sc/source/ui/inc/datatransformation.hxx  |   12 ++
 5 files changed, 115 insertions(+)

New commits:
commit b607f62fde45a907f17545f4073e53d308b4cd1f
Author: Markus Mohrhard 
Date:   Tue Aug 15 18:19:08 2017 +0200

external data: add HTML data provider test

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

diff --git a/sc/qa/unit/data/dataprovider/html/test1.html 
b/sc/qa/unit/data/dataprovider/html/test1.html
new file mode 100644
index ..2d81f0503d21
--- /dev/null
+++ b/sc/qa/unit/data/dataprovider/html/test1.html
@@ -0,0 +1,44 @@
+
+
+
+
+Col1
+Col2
+Col3
+Col4
+
+
+
+
+1
+2
+Audi
+Berlin
+
+
+10
+2.1
+GM
+San Francisco
+
+
+-100
+2010-1-1
+Nissan
+Tokyo
+
+
+-0.1
+2
+Ferrari
+Rome
+
+
+1
+2
+Peugeot
+Paris
+
+
+
+
diff --git a/sc/qa/unit/dataproviders_test.cxx 
b/sc/qa/unit/dataproviders_test.cxx
index 5ab7dfe3f933..4b18db5ecd75 100644
--- a/sc/qa/unit/dataproviders_test.cxx
+++ b/sc/qa/unit/dataproviders_test.cxx
@@ -28,10 +28,12 @@ public:
 
 void testCSVImport();
 void testDataLargerThanDB();
+void testHTMLImport();
 
 CPPUNIT_TEST_SUITE(ScDataProvidersTest);
 CPPUNIT_TEST(testCSVImport);
 CPPUNIT_TEST(testDataLargerThanDB);
+CPPUNIT_TEST(testHTMLImport);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -95,6 +97,46 @@ void ScDataProvidersTest::testDataLargerThanDB()
 CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(2, 1, 0));
 }
 
+void ScDataProvidersTest::testHTMLImport()
+{
+ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10);
+bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData);
+CPPUNIT_ASSERT(bInserted);
+
+OUString aFileURL;
+createFileURL("test1.", "html", aFileURL);
+sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.html", 
m_pDoc);
+aDataSource.setID("//table");
+aDataSource.setDBData(pDBData);
+
+
+m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource);
+auto& rDataSources = m_pDoc->GetExternalDataMapper().getDataSources();
+CPPUNIT_ASSERT(!rDataSources.empty());
+
+rDataSources[0].refresh(m_pDoc, true);
+Scheduler::ProcessEventsToIdle();
+
+
+std::vector aCarManufacturers = {"Audi", "GM", "Nissan", 
"Ferrari", "Peugeot"};
+std::vector aCities = {"Berlin", "San Francisco", "Tokyo", 
"Rome", "Paris"};
+std::vector aFirstCol = {1, 10, -100, -0.1, 1};
+std::vector aSecondCol = {2, 2.1, 40179, 2, 2,}; // 40179 is equal 
to 2010-1-1
+
+CPPUNIT_ASSERT_EQUAL(OUString("Col1"), m_pDoc->GetString(0, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("Col2"), m_pDoc->GetString(1, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("Col3"), m_pDoc->GetString(2, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("Col4"), m_pDoc->GetString(3, 0, 0));
+
+for (SCROW nRow = 0; nRow <= 4; ++nRow)
+{
+ASSERT_DOUBLES_EQUAL(aFirstCol[nRow], m_pDoc->GetValue(0, nRow + 1, 
0));
+ASSERT_DOUBLES_EQUAL(aSecondCol[nRow], m_pDoc->GetValue(1, nRow + 1, 
0));
+CPPUNIT_ASSERT_EQUAL(aCarManufacturers[nRow], m_pDoc->GetString(2, 
nRow + 1, 0));
+CPPUNIT_ASSERT_EQUAL(aCities[nRow], m_pDoc->GetString(3, nRow + 1, 0));
+}
+}
+
 ScDataProvidersTest::ScDataProvidersTest() :
 ScBootstrapFixture( "/sc/qa/unit/data/dataprovider" ),
 m_pDoc(nullptr)
diff --git a/sc/source/ui/dataprovider/datatransformation.cxx 
b/sc/source/ui/dataprovider/datatransformation.cxx
index 2c2fe72bbcf4..b4251dc7201a 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -91,6 +91,16 @@ void MergeColumnTransformation::Transform(ScDocument& rDoc)
 rDoc.DeleteCol(0, 0, MAXROW, 0, mnCol2, 1);
 }
 
+SortTransformation::SortTransformation(const ScSortParam& rSortParam):
+maSortParam(rSortParam)
+{
+}
+
+void SortTransformation::Transform(ScDocument& rDoc)
+{
+rDoc.Sort(0, maSortParam, false, false, nullptr, nullptr);
+}
+
 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-06-09 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx |  141 -
 sc/source/core/tool/interpr1.cxx |  259 +++
 2 files changed, 342 insertions(+), 58 deletions(-)

New commits:
commit 076ed447f694239d5c67adee528ea6e471d909ff
Author: Eike Rathke 
Date:   Sat Jun 10 00:46:00 2017 +0200

Unit test for COUNTIFS, SUMIFS, AVERAGEIFS with array of references, 
tdf#58874

Change-Id: Ie833716fcde0b82dcaa2e5b66deb2952ee912b7f

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index dffcfff11dda..93c500a1dbfa 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -7936,15 +7936,140 @@ void Test::testFuncSUMIFS()
 // Matrix formula in E8:E10 with AVERAGEIFS
 m_pDoc->InsertMatrixFormula(4, 7, 4, 9, aMark, 
"=AVERAGEIFS(B1:B7;A1:A7;A9:A11)");
 
-// Result B1+B5, B2+B6, B3+B7 and counts and averages.
-std::vector aCheck = {
-{ "17", "2",  "8.5" },
-{ "34", "2", "17" },
-{ "68", "2", "34" }
-};
+{
+// Result B1+B5, B2+B6, B3+B7 and counts and averages.
+std::vector aCheck = {
+{ "17", "2",  "8.5" },
+{ "34", "2", "17" },
+{ "68", "2", "34" }
+};
+bool bGood = checkOutput(m_pDoc, ScRange(2,7,0, 4,9,0), aCheck,
+"SUMIFS, COUNTIFS and AVERAGEIFS in array context");
+CPPUNIT_ASSERT_MESSAGE("SUMIFS, COUNTIFS or AVERAGEIFS in array 
context failed", bGood);
+}
+
+// Matrix formula in G8:G10 with SUMIFS and reference list arrays.
+m_pDoc->InsertMatrixFormula(6, 7, 6, 9, aMark, 
"=SUMIFS(OFFSET(B1;ROW(1:3);0;2);OFFSET(B1;ROW(1:3);0;2);\">4\")");
+// Matrix formula in H8:H10 with COUNTIFS and reference list arrays.
+m_pDoc->InsertMatrixFormula(7, 7, 7, 9, aMark, 
"=COUNTIFS(OFFSET(B1;ROW(1:3);0;2);\">4\")");
+// Matrix formula in I8:I10 with AVERAGEIFS and reference list arrays.
+m_pDoc->InsertMatrixFormula(8, 7, 8, 9, aMark, 
"=AVERAGEIFS(OFFSET(B1;ROW(1:3);0;2);OFFSET(B1;ROW(1:3);0;2);\">4\")");
+
+{
+// Result sums, counts and averages.
+std::vector aCheck = {
+{  "0", "0", "#DIV/0!" },
+{  "8", "1",  "8" },
+{ "24", "2", "12" }
+};
+bool bGood = checkOutput(m_pDoc, ScRange(6,7,0, 8,9,0), aCheck,
+"SUMIFS, COUNTIFS and AVERAGEIFS with reference list arrays");
+CPPUNIT_ASSERT_MESSAGE("SUMIFS, COUNTIFS or AVERAGEIFS with reference 
list arrays failed", bGood);
+}
+
+// Matrix formula in K8:K10 with SUMIFS and reference list array condition
+// and "normal" data range.
+m_pDoc->InsertMatrixFormula(10, 7, 10, 9, aMark, 
"=SUMIFS(B1:B2;OFFSET(B1;ROW(1:3);0;2);\">4\")");
+// Matrix formula in L8:L10 with AVERAGEIFS and reference list array
+// condition and "normal" data range.
+m_pDoc->InsertMatrixFormula(11, 7, 11, 9, aMark, 
"=AVERAGEIFS(B1:B2;OFFSET(B1;ROW(1:3);0;2);\">4\")");
+
+{
+// Result sums and averages.
+std::vector aCheck = {
+{ "0", "#DIV/0!" },
+{ "2", "2" },
+{ "3", "1.5" }
+};
+bool bGood = checkOutput(m_pDoc, ScRange(10,7,0, 11,9,0), aCheck,
+"SUMIFS, COUNTIFS and AVERAGEIFS with reference list array and 
normal range");
+CPPUNIT_ASSERT_MESSAGE("SUMIFS, COUNTIFS or AVERAGEIFS with reference 
list array and normal range failed", bGood);
+}
+
+// Matrix formula in G18:G20 with SUMIFS and reference list arrays and a
+// "normal" criteria range.
+m_pDoc->InsertMatrixFormula(6, 17, 6, 19, aMark, 
"=SUMIFS(OFFSET(B1;ROW(1:3);0;2);OFFSET(B1;ROW(1:3);0;2);\">4\";B1:B2;\">1\")");
+// Matrix formula in H18:H20 with COUNTIFS and reference list arrays and a
+// "normal" criteria range.
+m_pDoc->InsertMatrixFormula(7, 17, 7, 19, aMark, 
"=COUNTIFS(OFFSET(B1;ROW(1:3);0;2);\">4\";B1:B2;\">1\")");
+// Matrix formula in I18:I20 with AVERAGEIFS and reference list arrays and
+// a "normal" criteria range.
+m_pDoc->InsertMatrixFormula(8, 17, 8, 19, aMark, 
"=AVERAGEIFS(OFFSET(B1;ROW(1:3);0;2);OFFSET(B1;ROW(1:3);0;2);\">4\";B1:B2;\">1\")");
+
+{
+// Result sums, counts and averages.
+std::vector aCheck = {
+{  "0", "0", "#DIV/0!" },
+{  "8", "1",  "8" },
+{ "16", "1", "16" }
+};
+bool bGood = checkOutput(m_pDoc, ScRange(6,17,0, 8,19,0), aCheck,
+"SUMIFS, COUNTIFS and AVERAGEIFS with reference list arrays 
and a normal criteria range");
+CPPUNIT_ASSERT_MESSAGE("SUMIFS, COUNTIFS or AVERAGEIFS with reference 
list arrays and a normal criteria range failed", bGood);
+}
+
+// Matrix formula in K18:K20 with SUMIFS and reference list array condition
+// and "normal" data range and a "normal" criteria range.
+m_pDoc->InsertMatrixFormula(10, 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-05-22 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx |9 +++
 sc/source/core/tool/interpr1.cxx |  114 +++
 2 files changed, 113 insertions(+), 10 deletions(-)

New commits:
commit a21f1c11aacde31fa190859828f257544afea818
Author: Eike Rathke 
Date:   Mon May 22 16:57:36 2017 +0200

Unit test for SUBTOTAL STDEV with array of references, tdf#58874

Change-Id: I27d8a0a3c03012a4575785feb32df11a76d6fcdb

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 69f3a47962c1..da0dc34cec2c 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -7955,6 +7955,15 @@ void Test::testFuncRefListArraySUBTOTAL()
 aPos.IncRow();
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MAX for A4:A5 failed", 16.0, 
m_pDoc->GetValue(aPos));
 
+// Matrix in F7:F9, individual STDEV of A2:A3, A3:A4 and A4:A5
+m_pDoc->InsertMatrixFormula(5, 6, 5, 8, aMark, 
"=SUBTOTAL(7;OFFSET(A1;ROW(1:3);0;2))");
+aPos.Set(5,6,0);
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("SUBTOTAL STDEV for A2:A3 failed", 
1.414214, m_pDoc->GetValue(aPos), 1e-6);
+aPos.IncRow();
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("SUBTOTAL STDEV for A3:A4 failed", 
2.828427, m_pDoc->GetValue(aPos), 1e-6);
+aPos.IncRow();
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("SUBTOTAL STDEV for A4:A5 failed", 
5.656854, m_pDoc->GetValue(aPos), 1e-6);
+
 m_pDoc->DeleteTab(0);
 }
 
commit fda09a666dd22aa6b2a9abfb25f7c97a3ab910fe
Author: Eike Rathke 
Date:   Mon May 22 16:56:50 2017 +0200

Handle STDEV, STDEVP, VAR and VARP with arrays of references, tdf#58874

Change-Id: Ifdd5336124df9a085902417590d081646d05a588

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 23f599e45a2d..f80f49557d82 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3785,10 +3785,19 @@ void ScInterpreter::ScMax( bool bTextAsZero )
 void ScInterpreter::GetStVarParams( bool bTextAsZero, double(*VarResult)( 
double fVal, size_t nValCount ) )
 {
 short nParamCount = GetByte();
+const SCSIZE nMatRows = GetRefListArrayMaxSize( nParamCount);
+
+struct ArrayRefListValue
+{
+std::vector mvValues;
+double mfSum;
+ArrayRefListValue() : mfSum(0.0) {}
+};
+std::vector vArrayValues;
+size_t nRefArrayPos = std::numeric_limits::max();
 
 std::vector values;
 double fSum= 0.0;
-double vSum= 0.0;
 double fVal = 0.0;
 ScAddress aAdr;
 ScRange aRange;
@@ -3826,9 +3835,60 @@ void ScInterpreter::GetStVarParams( bool bTextAsZero, 
double(*VarResult)( double
 }
 }
 break;
-case svDoubleRef :
 case svRefList :
 {
+const ScRefListToken* p = dynamic_cast(pStack[sp-1]);
+if (p && p->IsArrayResult())
+{
+nRefArrayPos = nRefInList;
+if (vArrayValues.empty())
+{
+// Create and init all elements with current value.
+assert(nMatRows > 0);
+vArrayValues.resize(nMatRows);
+for (auto & it : vArrayValues)
+{
+it.mvValues = values;
+it.mfSum = fSum;
+}
+}
+else
+{
+// Current value and values from vector are operands
+// for each vector position.
+for (auto & it : vArrayValues)
+{
+it.mvValues.insert( it.mvValues.end(), 
values.begin(), values.end());
+it.mfSum += fSum;
+}
+}
+ArrayRefListValue& rArrayValue = 
vArrayValues[nRefArrayPos];
+FormulaError nErr = FormulaError::NONE;
+PopDoubleRef( aRange, nParamCount, nRefInList);
+ScValueIterator aValIter( pDok, aRange, mnSubTotalFlags, 
bTextAsZero );
+if (aValIter.GetFirst(fVal, nErr))
+{
+do
+{
+rArrayValue.mvValues.push_back(fVal);
+rArrayValue.mfSum += fVal;
+}
+while ((nErr == FormulaError::NONE) && 
aValIter.GetNext(fVal, nErr));
+}
+if ( nErr != FormulaError::NONE )
+{
+rArrayValue.mfSum = CreateDoubleError( nErr);
+}
+// Reset.
+std::vector().swap(values);
+fSum = 0.0;
+nRefArrayPos = std::numeric_limits::max();
+

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-05-22 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx |   19 ++-
 sc/source/core/tool/interpr6.cxx |5 ++---
 2 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit 3e9f9bff4a3d8365f58545dae0c004a1254a56e3
Author: Eike Rathke 
Date:   Mon May 22 16:23:25 2017 +0200

Unit test for SUBTOTAL AVERAGE with array of references, tdf#58874

To test the count vector as well.

Change-Id: Idc6bcdc779ea0e6e8a6118934fd8e7856eba1518

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 92f93722c531..69f3a47962c1 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -7928,18 +7928,27 @@ void Test::testFuncRefListArraySUBTOTAL()
 aPos.IncRow();
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL SUM for A4:A5 failed", 24.0, 
m_pDoc->GetValue(aPos));
 
-// Matrix in C7:C9, individual MIN of A2:A3, A3:A4 and A4:A5
-m_pDoc->InsertMatrixFormula(2, 6, 2, 8, aMark, 
"=SUBTOTAL(5;OFFSET(A1;ROW(1:3);0;2))");
+// Matrix in C7:C9, individual AVERAGE of A2:A3, A3:A4 and A4:A5
+m_pDoc->InsertMatrixFormula(2, 6, 2, 8, aMark, 
"=SUBTOTAL(1;OFFSET(A1;ROW(1:3);0;2))");
 aPos.Set(2,6,0);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL AVERAGE for A2:A3 failed",  3.0, 
m_pDoc->GetValue(aPos));
+aPos.IncRow();
+CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL AVERAGE for A3:A4 failed",  6.0, 
m_pDoc->GetValue(aPos));
+aPos.IncRow();
+CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL AVERAGE for A4:A5 failed", 12.0, 
m_pDoc->GetValue(aPos));
+
+// Matrix in D7:D9, individual MIN of A2:A3, A3:A4 and A4:A5
+m_pDoc->InsertMatrixFormula(3, 6, 3, 8, aMark, 
"=SUBTOTAL(5;OFFSET(A1;ROW(1:3);0;2))");
+aPos.Set(3,6,0);
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MIN for A2:A3 failed",  2.0, 
m_pDoc->GetValue(aPos));
 aPos.IncRow();
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MIN for A3:A4 failed",  4.0, 
m_pDoc->GetValue(aPos));
 aPos.IncRow();
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MIN for A4:A5 failed",  8.0, 
m_pDoc->GetValue(aPos));
 
-// Matrix in D7:D9, individual MAX of A2:A3, A3:A4 and A4:A5
-m_pDoc->InsertMatrixFormula(3, 6, 3, 8, aMark, 
"=SUBTOTAL(4;OFFSET(A1;ROW(1:3);0;2))");
-aPos.Set(3,6,0);
+// Matrix in E7:E9, individual MAX of A2:A3, A3:A4 and A4:A5
+m_pDoc->InsertMatrixFormula(4, 6, 4, 8, aMark, 
"=SUBTOTAL(4;OFFSET(A1;ROW(1:3);0;2))");
+aPos.Set(4,6,0);
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MAX for A2:A3 failed",  4.0, 
m_pDoc->GetValue(aPos));
 aPos.IncRow();
 CPPUNIT_ASSERT_EQUAL_MESSAGE("SUBTOTAL MAX for A3:A4 failed",  8.0, 
m_pDoc->GetValue(aPos));
commit 44b56bab060b3268617ed930fb783a20e617d137
Author: Eike Rathke 
Date:   Mon May 22 16:20:59 2017 +0200

Get vector count right, tdf#58874

Change-Id: I1d4224c6a87af4ed9f879e144958f95418fabbf7

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 35004f2846bc..6e614098e4a7 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -997,14 +997,13 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, 
bool bTextAsZero )
 // Include value of last non-references-array type and calculate final 
result.
 for (SCSIZE i=0; i < nMatRows; ++i)
 {
-if (xResCount)
-nCount += xResCount->GetDouble(0,i);
+sal_uLong nVecCount = (xResCount ? nCount + 
xResCount->GetDouble(0,i) : nCount);
 double fVecRes = xResMat->GetDouble(0,i);
 if (eFunc == ifPRODUCT)
 fVecRes *= fRes;
 else
 fVecRes += fRes;
-fVecRes = lcl_IterResult( eFunc, fVecRes, fMem, nCount);
+fVecRes = lcl_IterResult( eFunc, fVecRes, fMem, nVecCount);
 xResMat->PutDouble( fVecRes, 0,i);
 }
 PushMatrix( xResMat);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-05-03 Thread Marco Cecchetti
 sc/qa/unit/tiledrendering/data/cursor-away.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   39 +
 sc/source/ui/view/gridwin4.cxx |6 ---
 3 files changed, 39 insertions(+), 6 deletions(-)

New commits:
commit 44eb05c254c3a45b3590fba7b4ea2194f45930b5
Author: Marco Cecchetti 
Date:   Wed May 3 18:15:11 2017 +0200

sc lok:fix up: scrolling issue: the document size is not updated in client

Change-Id: Ied16f52b0a3a3be074390d60120493c75076c84d

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 346f833050f2..fa565a4ab8c3 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1156,16 +1156,10 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 pDoc->GetTiledRenderingArea(nTab, nEndCol, nEndRow);
 
 if (nEndCol < nBottomRightTileCol)
-{
 nEndCol = nBottomRightTileCol;
-pViewData->SetMaxTiledCol(nEndCol);
-}
 
 if (nEndRow < nBottomRightTileRow)
-{
 nEndRow = nBottomRightTileRow;
-pViewData->SetMaxTiledRow(nEndRow);
-}
 
 nTopLeftTileCol = std::max(nTopLeftTileCol, 0);
 nTopLeftTileRow = std::max(nTopLeftTileRow, 0);
commit 02359793bbb8e2b762d3f9ce0f41905f8422d7d4
Author: Jan Holesovsky 
Date:   Tue May 2 16:32:28 2017 +0200

sc lok: Unit test that painting tiles after pgdown returns actual content.

Test based on the online.git test by Ashod Nakashian, thanks for the repro
steps there!

Change-Id: I225127e953b0dade0b1bd4e12c131dc984b7e3fc

diff --git a/sc/qa/unit/tiledrendering/data/cursor-away.ods 
b/sc/qa/unit/tiledrendering/data/cursor-away.ods
new file mode 100644
index ..c593fc7db033
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/cursor-away.ods 
differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 220a1a271e3b..29f8e5179a96 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -82,6 +82,7 @@ public:
 void testUndoLimiting();
 void testUndoRepairDispatch();
 void testInsertGraphicInvalidations();
+void testDocumentSizeWithTwoViews();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnSelections);
@@ -107,6 +108,7 @@ public:
 CPPUNIT_TEST(testUndoLimiting);
 CPPUNIT_TEST(testUndoRepairDispatch);
 CPPUNIT_TEST(testInsertGraphicInvalidations);
+CPPUNIT_TEST(testDocumentSizeWithTwoViews);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1314,6 +1316,43 @@ void 
ScTiledRenderingTest::testInsertGraphicInvalidations()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void ScTiledRenderingTest::testDocumentSizeWithTwoViews()
+{
+comphelper::LibreOfficeKit::setActive();
+
+// Open a document that has the cursor far away & paint a tile
+ScModelObj* pModelObj = createDoc("cursor-away.ods");
+
+// Set the visible area, and press page down
+pModelObj->setClientVisibleArea(Rectangle(750, 1861, 20583, 6997));
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN);
+Scheduler::ProcessEventsToIdle();
+
+int nCanvasWidth = 256;
+int nCanvasHeight = 256;
+std::vector aBuffer1(nCanvasWidth * nCanvasHeight * 4);
+ScopedVclPtrInstance pDevice1(nullptr, Size(1, 1), 
DeviceFormat::DEFAULT);
+pDevice1->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer1.data());
+pModelObj->paintTile(*pDevice1.get(), nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0, /*nTilePosY=*/291840, /*nTileWidth=*/3840, 
/*nTileHeight=*/3840);
+Scheduler::ProcessEventsToIdle();
+
+// Create a new view
+SfxLokHelper::createView();
+
+std::vector aBuffer2(nCanvasWidth * nCanvasHeight * 4);
+ScopedVclPtrInstance pDevice2(nullptr, Size(1, 1), 
DeviceFormat::DEFAULT);
+pDevice2->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, 
nCanvasHeight), Fraction(1.0), Point(), aBuffer2.data());
+pModelObj->paintTile(*pDevice2.get(), nCanvasWidth, nCanvasHeight, 
/*nTilePosX=*/0, /*nTilePosY=*/291840, /*nTileWidth=*/3840, 
/*nTileHeight=*/3840);
+Scheduler::ProcessEventsToIdle();
+
+// Check that the tiles actually have the same content
+for (size_t i = 0; i < aBuffer1.size(); ++i)
+CPPUNIT_ASSERT_EQUAL(aBuffer1[i], aBuffer2[i]);
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-03-16 Thread Markus Mohrhard
 sc/qa/unit/ucalc.hxx|2 ++
 sc/qa/unit/ucalc_condformat.cxx |   33 +
 sc/source/core/data/table7.cxx  |4 ++--
 3 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit 36d7e21c00d59eead018ad8ef339847a782b9734
Author: Markus Mohrhard 
Date:   Thu Mar 16 21:35:05 2017 +0100

add test for tdf#106242

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

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index c48a25f126af..fb2390c1f5da 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -468,6 +468,7 @@ public:
 void testCondCopyPaste();
 void testCondCopyPasteSingleCell(); //e.g. fdo#82503
 void testCondCopyPasteSingleCellToRange(); //e.g. fdo#82503
+void testCondCopyPasteSingleRowToRange(); //e.g. tdf#106242
 void testCondCopyPasteSheetBetweenDoc();
 void testCondCopyPasteSheet();
 void testIconSet();
@@ -745,6 +746,7 @@ public:
 CPPUNIT_TEST(testCondCopyPaste);
 CPPUNIT_TEST(testCondCopyPasteSingleCell);
 CPPUNIT_TEST(testCondCopyPasteSingleCellToRange);
+CPPUNIT_TEST(testCondCopyPasteSingleRowToRange);
 CPPUNIT_TEST(testCondCopyPasteSheetBetweenDoc);
 CPPUNIT_TEST(testCondCopyPasteSheet);
 CPPUNIT_TEST(testCondFormatEndsWithStr);
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index ee0d8abee066..0b0a8a2af97b 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -378,6 +378,39 @@ void Test::testCondCopyPasteSingleCellToRange()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testCondCopyPasteSingleRowToRange()
+{
+m_pDoc->InsertTab(0, "Test");
+
+ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+ScRange aCondFormatRange(0,0,0,0,0,0);
+ScRangeList aRangeList(aCondFormatRange);
+pFormat->SetRange(aRangeList);
+
+ScCondFormatEntry* pEntry = new 
ScCondFormatEntry(SC_COND_DIRECT,"=B2","",m_pDoc,ScAddress(0,0,0),ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+pFormat->AddEntry(pEntry);
+m_pDoc->AddCondFormat(pFormat, 0);
+
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+copyToClip(m_pDoc, ScRange(0,0,0,MAXCOL,0,0), );
+ScRange aTargetRange(0,4,0,MAXCOL,4,0);
+pasteOneCellFromClip(m_pDoc, aTargetRange, );
+
+std::set aCondFormatIndices;
+
+ScConditionalFormat* pNewFormat = m_pDoc->GetCondFormat(0, 4, 0);
+CPPUNIT_ASSERT(pNewFormat);
+CPPUNIT_ASSERT(pNewFormat->GetKey() != pFormat->GetKey());
+
+for (SCCOL nCol = 1; nCol <= MAXCOL; ++nCol)
+{
+ScConditionalFormat* pNewFormat2 = m_pDoc->GetCondFormat(nCol, 4, 0);
+CPPUNIT_ASSERT(!pNewFormat2);
+}
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testCondCopyPasteSheetBetweenDoc()
 {
 m_pDoc->InsertTab(0, "Test");
commit d4bdac90c3b12d1de74b99786f2e830ee2ae18dc
Author: Markus Mohrhard 
Date:   Thu Mar 16 21:46:57 2017 +0100

CopyOneCellFromClip also copies one row ranges, tdf#106242

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

diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index a84942912aa5..72595dae9b77 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -65,10 +65,10 @@ void ScTable::CopyOneCellFromClip(
 assert(nColOffset >= 0);
 aCol[nCol].CopyOneCellFromClip(rCxt, nRow1, nRow2, nColOffset);
 
-if (rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB)
+if ((rCxt.getInsertFlag() & InsertDeleteFlags::ATTRIB) && (nColOffset 
== 0))
 {
 for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
-CopyConditionalFormat(nCol, nRow, nCol, nRow, nCol - 
aSrcRange.aStart.Col(),
+CopyConditionalFormat(nCol, nRow, nCol + nSrcColSize - 1, 
nRow, nCol - aSrcRange.aStart.Col(),
 nRow - nSrcRow, pSrcTab);
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-03-16 Thread Markus Mohrhard
 sc/qa/unit/ucalc.hxx |4 +++
 sc/qa/unit/ucalc_condformat.cxx  |   40 +++
 sc/source/core/data/conditio.cxx |6 ++---
 3 files changed, 47 insertions(+), 3 deletions(-)

New commits:
commit ad9336f29650dc38be06d771f5c3dbc7f0078ff1
Author: Markus Mohrhard 
Date:   Thu Mar 16 20:07:04 2017 +0100

add tests for tdf#104026

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

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 076e5b0e404a..92f0d6dd04d5 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -485,6 +485,8 @@ public:
 void testCondFormatUpdateDeleteTab();
 void testCondFormatUpdateInsertTab();
 void testCondFormatUpdateReference();
+void testCondFormatUpdateReferenceDelRow();
+void testCondFormatUpdateReferenceInsRow();
 
 void testCondFormatEndsWithStr();
 void testCondFormatEndsWithVal();
@@ -745,6 +747,8 @@ public:
 CPPUNIT_TEST(testCondCopyPasteSheet);
 CPPUNIT_TEST(testCondFormatEndsWithStr);
 CPPUNIT_TEST(testCondFormatEndsWithVal);
+CPPUNIT_TEST(testCondFormatUpdateReferenceDelRow);
+CPPUNIT_TEST(testCondFormatUpdateReferenceInsRow);
 CPPUNIT_TEST(testIconSet);
 CPPUNIT_TEST(testDataBarLengthAutomaticAxis);
 CPPUNIT_TEST(testDataBarLengthMiddleAxis);
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 47230e100aac..ee0d8abee066 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -875,4 +875,44 @@ void Test::testCondFormatUpdateReference()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testCondFormatUpdateReferenceDelRow()
+{
+m_pDoc->InsertTab(0, "test");
+
+ScConditionEntry* pEntry = new ScConditionEntry(SC_COND_EQUAL, "B6", "", 
m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, 
formula::FormulaGrammar::GRAM_DEFAULT);
+
+ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+pFormat->SetRange(ScRange(0, 5, 0, 0, 5, 0));
+m_pDoc->AddCondFormat(pFormat, 0);
+
+pFormat->AddEntry(pEntry);
+
+m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 4, 1);
+
+OUString aStr = pEntry->GetExpression(ScAddress(0, 4, 0), 0);
+CPPUNIT_ASSERT_EQUAL(OUString("B5"), aStr);
+
+m_pDoc->DeleteTab(0);
+}
+
+void Test::testCondFormatUpdateReferenceInsRow()
+{
+m_pDoc->InsertTab(0, "test");
+
+ScConditionEntry* pEntry = new ScConditionEntry(SC_COND_EQUAL, "B6", "", 
m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, 
formula::FormulaGrammar::GRAM_DEFAULT);
+
+ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+pFormat->SetRange(ScRange(0, 5, 0, 0, 5, 0));
+m_pDoc->AddCondFormat(pFormat, 0);
+
+pFormat->AddEntry(pEntry);
+
+m_pDoc->InsertRow(0, 0, MAXCOL, 0, 4, 1);
+
+OUString aStr = pEntry->GetExpression(ScAddress(0, 6, 0), 0);
+CPPUNIT_ASSERT_EQUAL(OUString("B7"), aStr);
+
+m_pDoc->DeleteTab(0);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3f0f35c89f3f64fcb110483fd562a59f729dc344
Author: Markus Mohrhard 
Date:   Thu Mar 16 20:08:30 2017 +0100

the range should be updated after the references, tdf#104026

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

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 6657dcf37608..f4f0f116ba61 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1926,13 +1926,13 @@ void ScConditionalFormat::CompileXML()
 
 void ScConditionalFormat::UpdateReference( sc::RefUpdateContext& rCxt, bool 
bCopyAsMove )
 {
+for(CondFormatContainer::iterator itr = maEntries.begin(); itr != 
maEntries.end(); ++itr)
+(*itr)->UpdateReference(rCxt);
+
 if (rCxt.meMode == URM_COPY && bCopyAsMove)
 maRanges.UpdateReference(URM_MOVE, pDoc, rCxt.maRange, 
rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
 else
 maRanges.UpdateReference(rCxt.meMode, pDoc, rCxt.maRange, 
rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
-
-for(CondFormatContainer::iterator itr = maEntries.begin(); itr != 
maEntries.end(); ++itr)
-(*itr)->UpdateReference(rCxt);
 }
 
 void ScConditionalFormat::InsertRow(SCTAB nTab, SCCOL nColStart, SCCOL 
nColEnd, SCROW nRowPos, SCSIZE nSize)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-03-09 Thread Eike Rathke
 sc/qa/unit/ucalc.cxx   |   15 +++
 sc/source/core/data/postit.cxx |4 +++-
 2 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit da3d56b077ce81f6f399a68f53895590dbb1357f
Author: Eike Rathke 
Date:   Thu Mar 9 23:15:42 2017 +0100

finally turn this into a hard assert

Change-Id: Iba6abafeaa2542fc94b76a642ddb0eb5b70b572d

diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index c01b6d7..3addea4 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -959,7 +959,9 @@ void ScPostIt::UpdateCaptionPos( const ScAddress& rPos )
 
 void ScPostIt::CreateCaptionFromInitData( const ScAddress& rPos ) const
 {
-OSL_ENSURE( maNoteData.mxCaption || maNoteData.mxInitData.get(), 
"ScPostIt::CreateCaptionFromInitData - need caption object or initial caption 
data" );
+// Captions are not created in Undo documents and only rarely in Clipboard,
+// but otherwise we need caption or initial data.
+assert((maNoteData.mxCaption || maNoteData.mxInitData.get()) || 
mrDoc.IsUndo() || mrDoc.IsClipboard());
 if( maNoteData.mxInitData.get() )
 {
 /*  This function is called from ScPostIt::Clone() when copying cells
commit 96175e7ed24fc007f88c418f8d449b6bd07563ad
Author: Eike Rathke 
Date:   Thu Mar 9 22:38:57 2017 +0100

it's raining drawing layers

Change-Id: Ieee5cb5792535185ef09c3775072ed739fb0e4b0

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index dcb9a90..40a2801 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -776,6 +776,9 @@ void Test::testCopyToDocument()
 {
 CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, 
"src"));
 
+// We need a drawing layer in order to create caption objects.
+m_pDoc->InitDrawLayer(());
+
 m_pDoc->SetString(0, 0, 0, "Header");
 m_pDoc->SetString(0, 1, 0, "1");
 m_pDoc->SetString(0, 2, 0, "2");
@@ -1986,6 +1989,9 @@ void Test::testSheetCopy()
 CPPUNIT_ASSERT_EQUAL_MESSAGE("document should have one sheet to begin 
with.",
static_cast(1), m_pDoc->GetTableCount());
 
+// We need a drawing layer in order to create caption objects.
+m_pDoc->InitDrawLayer(());
+
 // Insert text in A1.
 m_pDoc->SetString(ScAddress(0,0,0), "copy me");
 
@@ -5247,6 +5253,9 @@ void Test::testNoteDeleteCol()
 ScDocument& rDoc = getDocShell().GetDocument();
 rDoc.InsertTab(0, "Sheet1");
 
+// We need a drawing layer in order to create caption objects.
+m_pDoc->InitDrawLayer(());
+
 ScAddress rAddr(1, 1, 0);
 ScPostIt* pNote = m_pDoc->GetOrCreateNote(rAddr);
 pNote->SetText(rAddr, "Hello");
@@ -5471,6 +5480,9 @@ void Test::testAreasWithNotes()
 ScDocument& rDoc = getDocShell().GetDocument();
 rDoc.InsertTab(0, "Sheet1");
 
+// We need a drawing layer in order to create caption objects.
+m_pDoc->InitDrawLayer(());
+
 ScAddress rAddr(1, 5, 0);
 ScPostIt* pNote = m_pDoc->GetOrCreateNote(rAddr);
 pNote->SetText(rAddr, "Hello");
@@ -6270,6 +6282,9 @@ void Test::testSetStringAndNote()
 {
 m_pDoc->InsertTab(0, "Test");
 
+// We need a drawing layer in order to create caption objects.
+m_pDoc->InitDrawLayer(());
+
 //note on A1
 ScAddress aAdrA1 (0, 0, 0);
 ScPostIt* pNote = m_pDoc->GetOrCreateNote(aAdrA1);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-02-13 Thread Justin Luth
 sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx |   14 +++
 sc/source/filter/excel/xetable.cxx|   26 ++
 sc/source/filter/inc/xetable.hxx  |2 +
 4 files changed, 33 insertions(+), 9 deletions(-)

New commits:
commit 1cde2eb9d128c9b1b658b1380074461429ab2214
Author: Justin Luth 
Date:   Fri Feb 10 12:44:47 2017 +0300

tdf#105840 EXCEL export: fixes for hidden defaultRow

second attempt at fixing hidden rows without creating
a million repeated rows. (related to tdf#98106)
This affects both .xls and .xlsx.  XLSX previously had
NO support for default-hidden(zeroHeight), but XLS already did.

Change-Id: I804e3f2ba21e595a1c2b2ebb355f0995868dd289
Reviewed-on: https://gerrit.libreoffice.org/34128
Tested-by: Jenkins 
Reviewed-by: Bartosz Kosiorek 

diff --git a/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx 
b/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx
new file mode 100644
index 000..e2c22cd
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf105840_allRowsHidden.xlsx 
differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 6413db8..fbb16cd 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -116,6 +116,7 @@ public:
 void testColumnWidthExportFromODStoXLSX();
 void testOutlineExportXLSX();
 void testHiddenEmptyRowsXLSX();
+void testAllRowsHiddenXLSX();
 void testLandscapeOrientationXLSX();
 
 void testInlineArrayXLS();
@@ -217,6 +218,7 @@ public:
 CPPUNIT_TEST(testColumnWidthExportFromODStoXLSX);
 CPPUNIT_TEST(testOutlineExportXLSX);
 CPPUNIT_TEST(testHiddenEmptyRowsXLSX);
+CPPUNIT_TEST(testAllRowsHiddenXLSX);
 CPPUNIT_TEST(testLandscapeOrientationXLSX);
 CPPUNIT_TEST(testInlineArrayXLS);
 CPPUNIT_TEST(testEmbeddedChartXLS);
@@ -891,6 +893,17 @@ void ScExportTest::testOutlineExportXLSX()
 assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 30);
 }
 
+void ScExportTest::testAllRowsHiddenXLSX()
+{
+ScDocShellRef xOrigDocSh = loadDoc("tdf105840_allRowsHidden.", 
FORMAT_XLSX);
+CPPUNIT_ASSERT(xOrigDocSh.is());
+
+std::shared_ptr pXPathFile = 
ScBootstrapFixture::exportTo(&(*xOrigDocSh), FORMAT_XLSX);
+xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/worksheets/sheet1.xml");
+CPPUNIT_ASSERT(pSheet);
+assertXPath(pSheet, "/x:worksheet/x:sheetFormatPr", "zeroHeight", "true" );
+assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row", 0);
+}
 
 void ScExportTest::testHiddenEmptyRowsXLSX()
 {
@@ -902,6 +915,7 @@ void ScExportTest::testHiddenEmptyRowsXLSX()
 xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/worksheets/sheet1.xml");
 CPPUNIT_ASSERT(pSheet);
 
+assertXPath(pSheet, "/x:worksheet/x:sheetFormatPr",  "zeroHeight", "false" 
);
 assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[1]", "hidden", "true");
 assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]", "hidden", "true");
 assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[3]", "hidden", "true");
diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index ee16f16..9ec23a1 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2047,7 +2047,7 @@ sal_uInt16 XclExpRow::GetFirstFreeXclCol() const
 
 bool XclExpRow::IsDefaultable() const
 {
-const sal_uInt16 nFlagsAlwaysMarkedAsDefault = EXC_ROW_DEFAULTFLAGS | 
EXC_ROW_UNSYNCED;
+const sal_uInt16 nFlagsAlwaysMarkedAsDefault = EXC_ROW_DEFAULTFLAGS | 
EXC_ROW_HIDDEN | EXC_ROW_UNSYNCED;
 return !::get_flag( mnFlags, static_cast< sal_uInt16 >( 
~nFlagsAlwaysMarkedAsDefault ) ) &&
IsEmpty();
 }
@@ -2056,6 +2056,7 @@ void XclExpRow::DisableIfDefault( const 
XclExpDefaultRowData& rDefRowData )
 {
 mbEnabled = !IsDefaultable() ||
 (mnHeight != rDefRowData.mnHeight) ||
+(IsHidden() != rDefRowData.IsHidden()) ||
 (IsUnsynced() != rDefRowData.IsUnsynced());
 }
 
@@ -2275,12 +2276,15 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& 
rDefRowData, const ScfUInt
 // return the default row format to caller
 rDefRowData = aMaxDefData;
 
-// now disable repeating extra (empty) rows that are equal to
-// default row height
+// now disable repeating extra (empty) rows that are equal to the default 
row
 for ( XclRepeatedRows::iterator it = aRepeated.begin(), it_end = 
aRepeated.end(); it != it_end; ++it)
 {
-if ( (*it)->GetXclRowRpt() > 1 && (*it)->GetHeight() == 
rDefRowData.mnHeight )
+if ( (*it)->GetXclRowRpt() > 1
+ && (*it)->GetHeight() == rDefRowData.mnHeight
+ && (*it)->IsHidden() == rDefRowData.IsHidden() )
+{
 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2017-02-09 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx  |3 ++-
 sc/source/core/tool/token.cxx |7 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 1e02bf3ceb747c8491b6489bef56dd4a896269b1
Author: Eike Rathke 
Date:   Thu Feb 9 18:54:50 2017 +0100

and more unit tests for tdf#103890

Change-Id: I342b11cb1442ff5ad4a51d8b8f2f7ed9f081bcaa

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index ceba828..cec64f1 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3349,7 +3349,8 @@ void Test::testTokenArrayRefUpdateMove()
 std::vector aTests = {
 "B1*C1",
 "SUM(B1:C1)",
-"$Sheet1.B1"
+"$Sheet1.B1",
+"SUM(Sheet1.B1:Sheet2.B1)"
 };
 
 // Since C3 is not referenced in any of the above formulas, moving C3 from
commit aeb465a458fc7ba02e3b1ca6b4193488defef511
Author: Eike Rathke 
Date:   Thu Feb 9 18:54:15 2017 +0100

yet more 3D flag to preserve cases, tdf#103890 follow-up

Change-Id: I8b8cdb01325d0cd54e436c1043c243eedfddbfb0

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 02f8a04..dcbde70 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -3167,7 +3167,12 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 }
 
 rRef.SetRange(aAbs, rNewPos);
-rRef.Ref1.SetFlag3D(aAbs.aStart.Tab() != rNewPos.Tab() 
|| !rRef.Ref1.IsTabRel());
+// Absolute sheet reference => set 3D flag.
+// More than one sheet referenced => has to have both 
3D flags.
+// If end part has 3D flag => start part must have it 
too.
+rRef.Ref2.SetFlag3D(aAbs.aStart.Tab() != 
aAbs.aEnd.Tab() || !rRef.Ref2.IsTabRel());
+rRef.Ref1.SetFlag3D(aAbs.aStart.Tab() != rNewPos.Tab() 
|| !rRef.Ref1.IsTabRel() ||
+rRef.Ref2.IsFlag3D());
 }
 break;
 case svExternalSingleRef:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-11-11 Thread Michael Meeks
 sc/qa/extras/sccellrangeobj.cxx  |   33 -
 sc/source/ui/unoobj/cellsuno.cxx |8 
 2 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 99316fc0c830ae6c827d9b7f56bf057ff7731ed5
Author: Michael Meeks 
Date:   Thu Nov 10 19:11:07 2016 +

tdf#103632 - sc: OOB sort fields unit test.

Change-Id: I6734d51c8f9c4ca5a01c3e54a71f83ba15db508d
Reviewed-on: https://gerrit.libreoffice.org/30761
Tested-by: Jenkins 
Reviewed-by: Michael Meeks 

diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx
index a81377e..12e2864 100644
--- a/sc/qa/extras/sccellrangeobj.cxx
+++ b/sc/qa/extras/sccellrangeobj.cxx
@@ -17,13 +17,15 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 using namespace css;
 using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 14
+#define NUMBER_OF_TESTS 15
 
 class ScCellRangeObj : public CalcUnoApiTest, public 
apitest::XCellRangesQuery, public apitest::CellProperties,
 public apitest::XSearchable, public 
apitest::XReplaceable, public apitest::XCellRangeData
@@ -35,6 +37,8 @@ public:
 virtual void tearDown() override;
 virtual uno::Reference< uno::XInterface > init() override;
 virtual uno::Reference< uno::XInterface > getXCellRangeData() override;
+void testSortOOB();
+
 
 CPPUNIT_TEST_SUITE(ScCellRangeObj);
 CPPUNIT_TEST(testQueryColumnDifference);
@@ -52,6 +56,7 @@ public:
 CPPUNIT_TEST(testCreateReplaceDescriptor);
 CPPUNIT_TEST(testGetDataArray);
 CPPUNIT_TEST(testSetDataArray);
+CPPUNIT_TEST(testSortOOB);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -109,6 +114,32 @@ uno::Reference< uno::XInterface > 
ScCellRangeObj::getXCellRangeData()
 return xReturn;
 }
 
+void ScCellRangeObj::testSortOOB()
+{
+uno::Reference xSortable(init(),UNO_QUERY_THROW);
+try {
+uno::Sequence aEmptyDescriptor;
+xSortable->sort(aEmptyDescriptor);
+} catch (const uno::Exception &) {
+CPPUNIT_FAIL("exception thrown during empty sort");
+}
+
+try {
+uno::Sequence aProps(1);
+uno::Sequence aSort(1);
+
+aSort[0].Field = 0xff;
+aSort[0].SortAscending = true;
+
+aProps[0].Name = "SortFields";
+aProps[0].Value = uno::makeAny(aSort);
+
+xSortable->sort(aProps);
+} catch (const uno::Exception &) {
+CPPUNIT_FAIL("exception thrown during OOB sort");
+}
+}
+
 void ScCellRangeObj::setUp()
 {
 nTest++;
commit b8fa4d1b2d135cabc9eb5162ca0c5af649f1cdaf
Author: Michael Meeks 
Date:   Fri Nov 4 21:14:34 2016 +

tdf#103632 - sc: tolerate OOB sort fields from UNO API.

Change-Id: Ie04b4281947a05572672838b3b4b5c6173d8fa0b
Reviewed-on: https://gerrit.libreoffice.org/30576
Tested-by: Jenkins 
Reviewed-by: Michael Meeks 

diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 49ac5e2..a1084a6 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5598,8 +5598,16 @@ void SAL_CALL ScCellRangeObj::sort( const 
uno::Sequence& a
 SCCOLROW nFieldStart = aParam.bByRow ?
 static_cast(aRange.aStart.Col()) :
 static_cast(aRange.aStart.Row());
+SCCOLROW nFieldEnd = aParam.bByRow ?
+static_cast(aRange.aEnd.Col()) :
+static_cast(aRange.aEnd.Row());
 for (i=0; i nFieldEnd)
+aParam.maKeyState[i].nField = nFieldEnd;
+}
 
 SCTAB nTab = aRange.aStart.Tab();
 aParam.nCol1 = aRange.aStart.Col();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source sd/source

2016-10-16 Thread Stephan Bergmann
 sc/qa/unit/subsequent_export-test.cxx|8 
 sc/source/ui/docshell/docsh4.cxx |4 ++--
 sd/source/ui/dlg/filedlg.cxx |4 ++--
 sd/source/ui/remotecontrol/BluetoothServer.cxx   |6 +++---
 sd/source/ui/remotecontrol/DiscoveryService.cxx  |6 --
 sd/source/ui/remotecontrol/WINNetworkService.cxx |2 +-
 sd/source/ui/remotecontrol/WINNetworkService.hxx |8 
 7 files changed, 24 insertions(+), 14 deletions(-)

New commits:
commit 4cfb22aaf50f93019ee888e84a2db2efd048b894
Author: Stephan Bergmann 
Date:   Fri Oct 14 16:53:50 2016 +0200

clang-cl loplugin: sc

Change-Id: I24d091174ab602ecf80c65ad75fd450e55cb01ac
Reviewed-on: https://gerrit.libreoffice.org/29856
Tested-by: Jenkins 
Reviewed-by: Stephan Bergmann 

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 693990d..9a47f47 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -141,7 +141,9 @@ public:
 void testCeilingFloorXLS();
 void testCeilingFloorODS();
 
+#if !defined _WIN32
 void testRelativePaths();
+#endif
 void testSheetProtection();
 
 void testPivotTableXLSX();
@@ -151,7 +153,9 @@ public:
 void testLinkedGraphicRT();
 void testImageWithSpecialID();
 
+#if !defined _WIN32
 void testSupBookVirtualPath();
+#endif
 void testSheetLocalRangeNameXLS();
 void testSheetTextBoxHyperlink();
 void testFontSize();
@@ -2622,6 +2626,7 @@ void ScExportTest::testCeilingFloorODS()
 testCeilingFloor(FORMAT_ODS);
 }
 
+#if !defined _WIN32
 void ScExportTest::testRelativePaths()
 {
 ScDocShellRef xDocSh = loadDoc("fdo79305.", FORMAT_ODS);
@@ -2634,6 +2639,7 @@ void ScExportTest::testRelativePaths()
 // make sure that the URL is relative
 CPPUNIT_ASSERT(aURL.startsWith(".."));
 }
+#endif
 
 namespace {
 
@@ -3025,6 +3031,7 @@ void ScExportTest::tearDown()
 test::BootstrapFixture::tearDown();
 }
 
+#if !defined _WIN32
 void ScExportTest::testSupBookVirtualPath()
 {
 ScDocShellRef xShell = loadDoc("external-ref.", FORMAT_XLS);
@@ -3041,6 +3048,7 @@ void ScExportTest::testSupBookVirtualPath()
 
 xDocSh->DoClose();
 }
+#endif
 
 void ScExportTest::testLinkedGraphicRT()
 {
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index e9a362c..977f03e 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -2195,10 +2195,10 @@ bool ScDocShell::DdeSetData( const OUString& rItem,
 if( aDdeTextFmt == "CSV" ||
 aDdeTextFmt == "FCSV" )
 aObj.SetSeparator( ',' );
-return aObj.ImportData( rMimeType, rValue );
+return ScImportExport::ImportData( rMimeType, rValue );
 }
 ScImportExport aObj( , rItem );
-return aObj.IsRef() && aObj.ImportData( rMimeType, rValue );
+return aObj.IsRef() && ScImportExport::ImportData( rMimeType, rValue );
 }
 #endif
 
commit 480e84d88d96d2d245b653613a9b83f3d7120ed8
Author: Stephan Bergmann 
Date:   Fri Oct 14 16:53:45 2016 +0200

clang-cl loplugin: sd

Change-Id: I26a1e20a3b811aea535994cda2e49a9c39df64b7
Reviewed-on: https://gerrit.libreoffice.org/29855
Tested-by: Jenkins 
Reviewed-by: Stephan Bergmann 

diff --git a/sd/source/ui/dlg/filedlg.cxx b/sd/source/ui/dlg/filedlg.cxx
index 0f0c87d..e5823d1 100644
--- a/sd/source/ui/dlg/filedlg.cxx
+++ b/sd/source/ui/dlg/filedlg.cxx
@@ -273,9 +273,9 @@ SdOpenSoundFileDialog::SdOpenSoundFileDialog() :
 mpImpl->AddFilter( aDescr, "*.svx");
 #else
 aDescr = SD_RESSTR(STR_WAV_FILE);
-mpImpl->AddFilter( aDescr, OUString("*.wav;*.mp3;*.ogg" ));
+mpImpl->AddFilter( aDescr, "*.wav;*.mp3;*.ogg" );
 aDescr = SD_RESSTR(STR_MIDI_FILE);
-mpImpl->AddFilter( aDescr, OUString("*.mid" ));
+mpImpl->AddFilter( aDescr, "*.mid" );
 #endif
 }
 
diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx 
b/sd/source/ui/remotecontrol/BluetoothServer.cxx
index f177d86..3002160 100644
--- a/sd/source/ui/remotecontrol/BluetoothServer.cxx
+++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx
@@ -1336,7 +1336,7 @@ void SAL_CALL BluetoothServer::run()
 aAddr.btAddr = 0;
 aAddr.serviceClassId = GUID_NULL;
 aAddr.port = BT_PORT_ANY; // Select any free socket.
-if ( bind( aSocket, (SOCKADDR*) , sizeof(aAddr) ) == SOCKET_ERROR )
+if ( bind( aSocket, reinterpret_cast(), sizeof(aAddr) ) 
== SOCKET_ERROR )
 {
 closesocket( aSocket );
 WSACleanup();
@@ -1372,7 +1372,7 @@ void SAL_CALL BluetoothServer::run()
 L"LibreOffice Impress Remote Control");
 aRecord.lpszComment = const_cast(
 L"Remote control of presentations over bluetooth.");
-aRecord.lpServiceClassId = (LPGUID) _UUID;
+aRecord.lpServiceClassId = 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-09-27 Thread Markus Mohrhard
 sc/qa/unit/subsequent_export-test.cxx |   24 
 sc/source/filter/xml/xmlexprt.cxx |6 ++
 2 files changed, 30 insertions(+)

New commits:
commit 7cf54c0c27e2f6d764164ea880b87163f45a
Author: Markus Mohrhard 
Date:   Tue Sep 27 18:36:52 2016 +0200

add test for tdf#101843

Change-Id: I90bd5e8042e3157286774c97d2ea3c109da2b658

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index ac1f035..0b78c56 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -174,6 +174,8 @@ public:
 void testEscapeCharInNumberFormatXLSX();
 void testNatNumInNumberFormatXLSX();
 
+void testHiddenRepeatedRowsODS();
+
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
 CPPUNIT_TEST(testPasswordExport);
@@ -255,6 +257,8 @@ public:
 CPPUNIT_TEST(testEscapeCharInNumberFormatXLSX);
 CPPUNIT_TEST(testNatNumInNumberFormatXLSX);
 
+CPPUNIT_TEST(testHiddenRepeatedRowsODS);
+
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3655,6 +3659,26 @@ void ScExportTest::testNatNumInNumberFormatXLSX()
 xDocSh->DoClose();
 }
 
+void ScExportTest::testHiddenRepeatedRowsODS()
+{
+ScDocShellRef xDocSh = loadDoc("empty.", FORMAT_ODS);
+CPPUNIT_ASSERT( xDocSh.Is() );
+
+{
+ScDocument& rDoc = xDocSh->GetDocument();
+rDoc.SetRowHidden(0, 20, 0, true);
+}
+
+xDocSh = saveAndReload( &(*xDocSh), FORMAT_ODS);  // Convert [NatNum5] to 
[DBNum2] in Chinese
+ScDocument& rDoc = xDocSh->GetDocument();
+SCROW nFirstRow = 0;
+SCROW nLastRow = 0;
+bool bHidden = rDoc.RowHidden(0, 0, , );
+CPPUNIT_ASSERT(bHidden);
+CPPUNIT_ASSERT_EQUAL((SCROW)0, nFirstRow);
+CPPUNIT_ASSERT_EQUAL((SCROW)20, nLastRow);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 7e7f6b0a056b51a425934f63745ae5c9fed2e51f
Author: Markus Mohrhard 
Date:   Tue Sep 27 18:17:11 2016 +0200

tdf#101843, ensure repeated rows set the hidden/filtered flag correctly

Change-Id: I759107eeb074698d5e4987c76005788aee33287d

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 8a0931c..4853373 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1439,9 +1439,15 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const 
sal_Int32 nStartRow, con
 if (pDoc)
 {
 if (nRow > nEndRowHidden)
+{
 bPrevHidden = rRowAttr.rowHidden(nTable, nRow, 
nEndRowHidden);
+bHidden = bPrevHidden;
+}
 if (nRow > nEndRowFiltered)
+{
 bPrevFiltered = rRowAttr.rowFiltered(nTable, nRow, 
nEndRowFiltered);
+bFiltered = bPrevFiltered;
+}
 }
 
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-09-26 Thread Markus Mohrhard
 sc/qa/unit/ucalc.cxx   |   13 +
 sc/qa/unit/ucalc.hxx   |1 +
 sc/qa/unit/ucalc_condformat.cxx|5 ++---
 sc/source/core/data/colorscale.cxx |4 
 4 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit f3531bebd1746e2f3cec2a18d92322ab482ee2ab
Author: Markus Mohrhard 
Date:   Tue Sep 27 00:11:32 2016 +0200

tdf#101104 this paranoid safety check actually causes a bug

Change-Id: Id31f98f5f84eabf603045e4d9f7ebd448689eed5

diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 2f816b0..25707bf 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -944,10 +944,6 @@ ScIconSetInfo* ScIconSetFormat::GetIconSetInfo(const 
ScAddress& rAddr) const
 double nMin = GetMinValue();
 double nMax = GetMaxValue();
 
-// this check is for safety
-if(nMin > nMax)
-return nullptr;
-
 sal_Int32 nIndex = 0;
 const_iterator itr = begin();
 ++itr;
commit c8a5f46b6121106d3efc0a4d45922bf910f6f94c
Author: Markus Mohrhard 
Date:   Mon Sep 26 22:28:20 2016 +0200

OOPS, we were actually testing the wrong method

Change-Id: I29adf81d3da56d7150e5182025d931ee62598e63

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 0db6a1c..f103f7d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -34,6 +34,7 @@
 #include "dbdata.hxx"
 #include "reftokenhelper.hxx"
 #include "userdat.hxx"
+#include "clipcontext.hxx"
 
 #include "docsh.hxx"
 #include "docfunc.hxx"
@@ -6135,6 +6136,18 @@ void Test::pasteFromClip(ScDocument* pDestDoc, const 
ScRange& rDestRange, ScDocu
 pDestDoc->CopyFromClip(rDestRange, aMark, InsertDeleteFlags::ALL, nullptr, 
pClipDoc);
 }
 
+void Test::pasteOneCellFromClip(ScDocument* pDestDoc, const ScRange& 
rDestRange, ScDocument* pClipDoc, InsertDeleteFlags eFlags)
+{
+ScMarkData aMark;
+aMark.SetMarkArea(rDestRange);
+sc::CopyFromClipContext aCxt(*pDestDoc, nullptr, pClipDoc, eFlags, false, 
false);
+aCxt.setDestRange(rDestRange.aStart.Col(), rDestRange.aStart.Row(),
+rDestRange.aEnd.Col(), rDestRange.aEnd.Row());
+aCxt.setTabRange(rDestRange.aStart.Tab(), rDestRange.aEnd.Tab());
+pDestDoc->CopyOneCellFromClip(aCxt, rDestRange.aStart.Col(), 
rDestRange.aStart.Row(),
+rDestRange.aEnd.Col(), rDestRange.aEnd.Row());
+}
+
 ScUndoPaste* Test::createUndoPaste(ScDocShell& rDocSh, const ScRange& rRange, 
ScDocument* pUndoDoc)
 {
 ScDocument& rDoc = rDocSh.GetDocument();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index b66110c..cbc9981 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -47,6 +47,7 @@ public:
 static void clearSheet(ScDocument* pDoc, SCTAB nTab);
 static void copyToClip(ScDocument* pSrcDoc, const ScRange& rRange, 
ScDocument* pClipDoc);
 static void pasteFromClip(ScDocument* pDestDoc, const ScRange& rDestRange, 
ScDocument* pClipDoc);
+static void pasteOneCellFromClip(ScDocument* pDestDoc, const ScRange& 
rDestRange, ScDocument* pClipDoc, InsertDeleteFlags eFlags = 
InsertDeleteFlags::ALL);
 static ScUndoPaste* createUndoPaste(ScDocShell& rDocSh, const ScRange& 
rRange, ScDocument* pUndoDoc);
 
 /**
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 93ce111..66f9a12 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -317,7 +317,7 @@ void Test::testCondCopyPasteSingleCell()
 copyToClip(m_pDoc, ScRange(0,0,0,0,0,0), );
 
 ScRange aTargetRange(4,4,0,4,4,0);
-pasteFromClip(m_pDoc, aTargetRange, );
+pasteOneCellFromClip(m_pDoc, aTargetRange, );
 
 ScConditionalFormat* pPastedFormat = m_pDoc->GetCondFormat(4,4,0);
 CPPUNIT_ASSERT(pPastedFormat);
@@ -349,9 +349,8 @@ void Test::testCondCopyPasteSingleCellToRange()
 
 ScDocument aClipDoc(SCDOCMODE_CLIP);
 copyToClip(m_pDoc, ScRange(0,0,0,0,0,0), );
-
 ScRange aTargetRange(4,4,0,5,8,0);
-pasteFromClip(m_pDoc, aTargetRange, );
+pasteOneCellFromClip(m_pDoc, aTargetRange, );
 
 std::set aCondFormatIndices;
 for(SCROW nRow = 4; nRow <= 8; ++nRow)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source solenv/gbuild solenv/sanitizers

2016-08-17 Thread Caolán McNamara
 sc/qa/unit/subsequent_export-test.cxx |   12 +---
 sc/source/core/tool/interpr1.cxx  |   12 ++--
 sc/source/core/tool/interpr2.cxx  |8 
 solenv/gbuild/CppunitTest.mk  |2 ++
 solenv/sanitizers/ubsan-suppressions  |1 +
 5 files changed, 14 insertions(+), 21 deletions(-)

New commits:
commit f2033c28f4ddb5984fc9b2374486f229f296d5f6
Author: Caolán McNamara 
Date:   Wed Aug 17 13:21:11 2016 +0100

enable password export tests under macosx

gerrit says they build with this cert folder
disable variable in place

Change-Id: Ibf711a01e6c055613c65dd94d85b523e7c8b5acd

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 60131bc..8cbb1fa 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -84,14 +84,10 @@ public:
 virtual void setUp() override;
 virtual void tearDown() override;
 
-#if !defined MACOSX && !defined DRAGONFLY
 ScDocShellRef saveAndReloadPassword( ScDocShell*, const OUString&, const 
OUString&, const OUString&, SfxFilterFlags );
-#endif
 
 void test();
-#if !defined MACOSX && !defined DRAGONFLY
 void testPasswordExport();
-#endif
 void testConditionalFormatExportODS();
 void testConditionalFormatExportXLSX();
 void testColorScaleExportODS();
@@ -178,9 +174,7 @@ public:
 
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
-#if !defined(MACOSX) && !defined(DRAGONFLY)
 CPPUNIT_TEST(testPasswordExport);
-#endif
 CPPUNIT_TEST(testConditionalFormatExportODS);
 CPPUNIT_TEST(testConditionalFormatExportXLSX);
 CPPUNIT_TEST(testColorScaleExportODS);
@@ -294,7 +288,6 @@ void ScExportTest::registerNamespaces(xmlXPathContextPtr& 
pXmlXPathCtx)
 }
 }
 
-#if !defined MACOSX && !defined DRAGONFLY
 ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const 
OUString ,
 const OUString , const OUString& rTypeName, SfxFilterFlags 
nFormatType)
 {
@@ -329,7 +322,6 @@ ScDocShellRef 
ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const OUSt
 OUString aPass("test");
 return load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, 
nFormatType, nFormat, SOFFICE_FILEFORMAT_CURRENT, );
 }
-#endif
 
 void ScExportTest::test()
 {
@@ -352,7 +344,6 @@ void ScExportTest::test()
 xDocSh->DoClose();
 }
 
-#if !defined MACOSX && !defined DRAGONFLY
 void ScExportTest::testPasswordExport()
 {
 ScDocShell* pShell = new ScDocShell(
@@ -363,7 +354,7 @@ void ScExportTest::testPasswordExport()
 
 ScDocument& rDoc = pShell->GetDocument();
 
-rDoc.SetValue(0,0,0, 1.0);
+rDoc.SetValue(0, 0, 0, 1.0);
 
 sal_Int32 nFormat = FORMAT_ODS;
 OUString aFilterName(getFileFormats()[nFormat].pFilterName, 
strlen(getFileFormats()[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ;
@@ -377,7 +368,6 @@ void ScExportTest::testPasswordExport()
 
 xDocSh->DoClose();
 }
-#endif
 
 void ScExportTest::testConditionalFormatExportODS()
 {
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index 5532192..f192b1e 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -21,6 +21,8 @@
 
 # Cap the number of threads unittests use.
 export MAX_CONCURRENCY=4
+# Disable searching for certificates by default
+export MOZILLA_CERTIFICATE_FOLDER=0
 
 gb_CppunitTest_UNITTESTFAILED ?= 
$(GBUILDDIR)/platform/unittest-failed-default.sh
 gb_CppunitTest_PYTHONDEPS ?= $(call gb_Library_get_target,pyuno_wrapper) $(if 
$(SYSTEM_PYTHON),,$(call gb_Package_get_target,python3))
commit 34d7a1d9bf0866b9dddb684e723d9f1e5e9a3697
Author: Caolán McNamara 
Date:   Wed Aug 17 15:10:59 2016 +0100

revert div by 0 ubsan hackarounds now

Change-Id: I6497a87d3071f91d5465033d2dc6ecafaa6461f4

Revert "use div() instead of /0 to content ubsan"

This reverts commit fa293f7d6792a2beab048461c8a067e9ca980bb8.

Revert "use div() instead of /0 to content ubsan"

This reverts commit e043cce9a48c1e4f4dd232a58de64f03d1d3919f.

Revert "use div() instead of /0 to content ubsan"

This reverts commit ebe04c075649c677b55941e3b4e57fbca150b5db.

Revert "use div() instead of /0 to content ubsan"

This reverts commit fb2c146752074b132d665e40343a08dcb2e6672e.

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index bec54db..52db341 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1697,7 +1697,7 @@ void ScInterpreter::ScTan()
 
 void ScInterpreter::ScCot()
 {
-PushDouble(div(1.0, ::rtl::math::tan(GetDouble(;
+PushDouble(1.0 / ::rtl::math::tan(GetDouble()));
 }
 
 void ScInterpreter::ScArcSin()
@@ -1737,7 +1737,7 @@ void ScInterpreter::ScTanHyp()
 
 void ScInterpreter::ScCotHyp()
 {
-PushDouble(div(1.0, tanh(GetDouble(;
+PushDouble(1.0 / tanh(GetDouble()));
 }
 
 void 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-08-03 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx |4 
 sc/source/core/tool/interpr4.cxx |   18 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 1b6caaeb7a323e91b6f6e2f3612a3bdc0a09fb45
Author: Eike Rathke 
Date:   Wed Aug 3 21:50:20 2016 +0200

disable unit test for tdf#100637 until fixed again

Change-Id: I5f5b442534585bdb69878d8790fb887dd65f0ccd

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index b2bfb37..f5f65bf 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3926,6 +3926,9 @@ void Test::testFuncIF()
 m_pDoc->SetValue(ScAddress(1,0,0), 3.0);
 CPPUNIT_ASSERT_EQUAL(OUString("not two"), 
m_pDoc->GetString(ScAddress(0,0,0)));
 
+/* FIXME: temporarily disabled because e54cd3fbf40300416ef337981bd356b88ad44a41
+ * reverted; reactivate when fixed again. */
+#if 0
 // Test nested IF in array/matrix.
 ScMarkData aMark;
 aMark.SelectOneTable(0);
@@ -3933,6 +3936,7 @@ void Test::testFuncIF()
 // Results must be 23 and 42.
 CPPUNIT_ASSERT_EQUAL(23.0, m_pDoc->GetValue(ScAddress(0,2,0)));
 CPPUNIT_ASSERT_EQUAL(42.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+#endif
 
 m_pDoc->DeleteTab(0);
 }
commit 3efcfc63eec7a75545e4f01fd15448744ad651fa
Author: Eike Rathke 
Date:   Wed Aug 3 21:41:38 2016 +0200

Revert "Resolves: tdf#100637 narrow down the JumpMatrix path finish 
condition"

This reverts commit e54cd3fbf40300416ef337981bd356b88ad44a41.

It breaks other nested array IF expressions.

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 8c4dd5c..9f64ea0 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4369,18 +4369,14 @@ StackVar ScInterpreter::Interpret()
 {
 if (nLevel == 1)
 aErrorFunctionStack.push( nErrorFunction);
-// Restrict nLevel==1 to not prematurely discard a path result.
-if (nLevel == 2 || (!aCode.HasStacked() || 
aCode.IsEndOfPath()))
+bGotResult = JumpMatrix( nLevel );
+if (aErrorFunctionStack.empty())
+assert(!"ScInterpreter::Interpret - aErrorFunctionStack 
empty in JumpMatrix context");
+else
 {
-bGotResult = JumpMatrix( nLevel );
-if (aErrorFunctionStack.empty())
-assert(!"ScInterpreter::Interpret - 
aErrorFunctionStack empty in JumpMatrix context");
-else
-{
-nErrorFunction = aErrorFunctionStack.top();
-if (bGotResult)
-aErrorFunctionStack.pop();
-}
+nErrorFunction = aErrorFunctionStack.top();
+if (bGotResult)
+aErrorFunctionStack.pop();
 }
 }
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-07-28 Thread Markus Mohrhard
 sc/qa/unit/subsequent_export-test.cxx  |5 +
 sc/source/filter/excel/xetable.cxx |   27 ---
 sc/source/filter/inc/xetable.hxx   |6 +-
 sc/source/filter/oox/worksheetfragment.cxx |5 +
 4 files changed, 39 insertions(+), 4 deletions(-)

New commits:
commit 4b3484b1fce510e53eb8ee587616b107ad477511
Author: Markus Mohrhard 
Date:   Thu Jul 28 16:57:10 2016 +0200

use n prefix for numeric variable

Change-Id: I70a7b10d46cdafc4dd59f8fc046587a6219a2218

diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index d1b731e..69ef932 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -1670,7 +1670,7 @@ XclExpColinfoBuffer::XclExpColinfoBuffer( const 
XclExpRoot& rRoot ) :
 XclExpRoot( rRoot ),
 maDefcolwidth( rRoot ),
 maOutlineBfr( rRoot ),
-maHighestOutlineLevel( 0 )
+mnHighestOutlineLevel( 0 )
 {
 }
 
@@ -1680,9 +1680,9 @@ void XclExpColinfoBuffer::Initialize( SCROW nLastScRow )
 for( sal_uInt16 nScCol = 0, nLastScCol = GetMaxPos().Col(); nScCol <= 
nLastScCol; ++nScCol )
 {
 maColInfos.AppendNewRecord( new XclExpColinfo( GetRoot(), nScCol, 
nLastScRow, maOutlineBfr ) );
-if( maOutlineBfr.GetLevel() > maHighestOutlineLevel )
+if( maOutlineBfr.GetLevel() > mnHighestOutlineLevel )
 {
-   maHighestOutlineLevel = maOutlineBfr.GetLevel();
+   mnHighestOutlineLevel = maOutlineBfr.GetLevel();
 }
 }
 }
@@ -2102,7 +2102,7 @@ XclExpRowBuffer::XclExpRowBuffer( const XclExpRoot& rRoot 
) :
 XclExpRoot( rRoot ),
 maOutlineBfr( rRoot ),
 maDimensions( rRoot ),
-maHighestOutlineLevel( 0 )
+mnHighestOutlineLevel( 0 )
 {
 }
 
@@ -2351,9 +2351,9 @@ XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 
nXclRow, bool bRowAlwaysE
  ( maOutlineBfr.GetLevel() != 0 ) ||
  ( rDoc.RowHidden(nFrom, nScTab) ) )
 {
-if( maOutlineBfr.GetLevel() > maHighestOutlineLevel )
+if( maOutlineBfr.GetLevel() > mnHighestOutlineLevel )
 {
-maHighestOutlineLevel = maOutlineBfr.GetLevel();
+mnHighestOutlineLevel = maOutlineBfr.GetLevel();
 }
 RowRef p(new XclExpRow(GetRoot(), nFrom, maOutlineBfr, 
bRowAlwaysEmpty));
 maRowMap.insert(RowMap::value_type(nFrom, p));
diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx
index 25ad278..c932be2 100644
--- a/sc/source/filter/inc/xetable.hxx
+++ b/sc/source/filter/inc/xetable.hxx
@@ -770,7 +770,7 @@ public:
 /** Writes all COLINFO records of this buffer. */
 virtual voidSave( XclExpStream& rStrm ) override;
 virtual voidSaveXml( XclExpXmlStream& rStrm ) override;
-sal_uInt8   GetHighestOutlineLevel() { return 
maHighestOutlineLevel; }
+sal_uInt8   GetHighestOutlineLevel() { return 
mnHighestOutlineLevel; }
 
 private:
 typedef XclExpRecordList< XclExpColinfo >   XclExpColinfoList;
@@ -779,7 +779,7 @@ private:
 XclExpColinfoList   maColInfos; /// List of COLINFO records.
 XclExpDefcolwidth   maDefcolwidth;  /// The DEFCOLWIDTH record.
 XclExpColOutlineBuffer maOutlineBfr;/// Buffer for column outline 
groups.
-sal_uInt8   maHighestOutlineLevel; /// Highest number of outline 
levels for columns in sheet.
+sal_uInt8   mnHighestOutlineLevel; /// Highest number of outline 
levels for columns in sheet.
 };
 
 class XclExpRow;
@@ -931,7 +931,7 @@ public:
 virtual voidSaveXml( XclExpXmlStream& rStrm ) override;
 
 XclExpDimensions&   GetDimensions() { return maDimensions; }
-sal_uInt8   GetHighestOutlineLevel() { return 
maHighestOutlineLevel; }
+sal_uInt8   GetHighestOutlineLevel() { return 
mnHighestOutlineLevel; }
 
 private:
 /** Returns access to the specified ROW record. Inserts preceding missing 
ROW records.
@@ -946,7 +946,7 @@ private:
 RowMap  maRowMap;
 XclExpRowOutlineBuffer maOutlineBfr;/// Buffer for row outline groups.
 XclExpDimensionsmaDimensions;   /// DIMENSIONS record for used 
area.
-sal_uInt8   maHighestOutlineLevel; /// Highest number of outline 
levels for rows in sheet.
+sal_uInt8   mnHighestOutlineLevel; /// Highest number of outline 
levels for rows in sheet.
 };
 
 // Cell Table
commit ad121df71ad463bed8caf147d27f020b548f0862
Author: Bartosz Kosiorek 
Date:   Tue Jul 26 18:14:30 2016 +0200

tdf#101135 FILESAVE .xlsx Save XML_outlineLevelRow, XML_outlineLevelCol keys

In .xlsx, the XML_outlineLevelRow and XML_outlineLevelCol keys
are required for Microsoft Office365 application
to properly displaying Outline values.

Change-Id: 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-04-15 Thread Markus Mohrhard
 sc/qa/unit/mark_test.cxx |   43 +++
 sc/source/core/data/markdata.cxx |   27 
 2 files changed, 61 insertions(+), 9 deletions(-)

New commits:
commit 4a2be39af5697356f2f4c0ae773f4b2530b2d9df
Author: Markus Mohrhard 
Date:   Fri Apr 15 13:08:49 2016 +0200

add test for tdf#72240

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

diff --git a/sc/qa/unit/mark_test.cxx b/sc/qa/unit/mark_test.cxx
index 41e0903..957d5fe 100644
--- a/sc/qa/unit/mark_test.cxx
+++ b/sc/qa/unit/mark_test.cxx
@@ -92,12 +92,21 @@ public:
 void testMultiMark_FourRanges();
 void testMultiMark_NegativeMarking();
 
+void testInsertTabBeforeSelected();
+void testInsertTabAfterSelected();
+void testDeleteTabBeforeSelected();
+void testDeleteTabAfterSelected();
+
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testSimpleMark_Simple);
 CPPUNIT_TEST(testSimpleMark_Column);
 CPPUNIT_TEST(testSimpleMark_Row);
 CPPUNIT_TEST(testMultiMark_FourRanges);
 CPPUNIT_TEST(testMultiMark_NegativeMarking);
+CPPUNIT_TEST(testInsertTabBeforeSelected);
+CPPUNIT_TEST(testInsertTabAfterSelected);
+CPPUNIT_TEST(testDeleteTabBeforeSelected);
+CPPUNIT_TEST(testDeleteTabAfterSelected);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -801,7 +810,41 @@ void Test::testMultiMark_NegativeMarking()
 testMultiMark( aData );
 }
 
+void Test::testInsertTabBeforeSelected()
+{
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+aMark.InsertTab(0);
+CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
+CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetFirstSelected());
+}
+
+void Test::testInsertTabAfterSelected()
+{
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+aMark.InsertTab(1);
+CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
+CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
+}
 
+void Test::testDeleteTabBeforeSelected()
+{
+ScMarkData aMark;
+aMark.SelectOneTable(1);
+aMark.DeleteTab(0);
+CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
+CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
+}
+
+void Test::testDeleteTabAfterSelected()
+{
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+aMark.DeleteTab(1);
+CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
+CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
+}
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
commit 67abc250e5f30844797996e09e66e61c2ef214db
Author: Markus Mohrhard 
Date:   Fri Apr 15 13:07:54 2016 +0200

fix InsertTab and DeleteTab in ScMarkData, tdf#72240

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

diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 154a693..53a5023 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -512,20 +512,29 @@ bool ScMarkData::HasAnyMultiMarks() const
 
 void ScMarkData::InsertTab( SCTAB nTab )
 {
-std::set tabMarked(maTabMarked.begin(), 
maTabMarked.upper_bound(nTab));
-std::set::iterator it = maTabMarked.upper_bound(nTab);
-for (; it != maTabMarked.end(); ++it)
-tabMarked.insert(*it + 1);
+std::set tabMarked;
+for (auto itr = maTabMarked.begin(), itrEnd = maTabMarked.end();
+itr != itrEnd; ++itr)
+{
+if (*itr < nTab)
+tabMarked.insert(*itr);
+else if (*itr >= nTab)
+tabMarked.insert(*itr + 1);
+}
 maTabMarked.swap(tabMarked);
 }
 
 void ScMarkData::DeleteTab( SCTAB nTab )
 {
-std::set tabMarked(maTabMarked.begin(), maTabMarked.find(nTab));
-tabMarked.erase( nTab );
-std::set::iterator it = maTabMarked.find(nTab);
-for (; it != maTabMarked.end(); ++it)
-tabMarked.insert(*it + 1);
+std::set tabMarked;
+for (auto itr = maTabMarked.begin(), itrEnd = maTabMarked.end();
+itr != itrEnd; ++itr)
+{
+if (*itr < nTab)
+tabMarked.insert(*itr);
+else if (*itr > nTab)
+tabMarked.insert(*itr - 1);
+}
 maTabMarked.swap(tabMarked);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-03-25 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx|   33 +
 sc/source/core/data/formulacell.cxx |5 +++--
 2 files changed, 36 insertions(+), 2 deletions(-)

New commits:
commit 19567deb49cdb4a49f251b1aacb305f68aee3c4a
Author: Eike Rathke 
Date:   Fri Mar 25 22:13:13 2016 +0100

unit test for copying sheet-local names before original position

Change-Id: I3a70539480b5b1d85b717fd6638359aa9ce5075a

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 8e8d092..6c1ac90 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3183,6 +3183,39 @@ void Test::testFormulaRefUpdateNameCopySheet()
 m_pDoc->DeleteTab(2);
 m_pDoc->DeleteTab(1);
 m_pDoc->DeleteTab(0);
+
+m_pDoc->InsertTab(0, "Test2");
+// Local name referencing sheet Test2.
+bInserted = m_pDoc->GetRangeName(0)->insert( new ScRangeData( m_pDoc, 
"localname", "$Test2.$A$1"));
+CPPUNIT_ASSERT(bInserted);
+m_pDoc->SetString(ScAddress(0,0,0), "=SHEET()");
+m_pDoc->SetString(ScAddress(1,0,0), "=localname");
+nVal = m_pDoc->GetValue(1,0,0);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Localname sheet number should be 1", 1.0, 
nVal);
+
+// Insert sheet before and shift sheet with local name.
+m_pDoc->InsertTab(0, "Test1");
+pName = m_pDoc->GetRangeName(1)->findByUpperName("LOCALNAME");
+CPPUNIT_ASSERT_MESSAGE("Org sheet-local name should exist", pName);
+nVal = m_pDoc->GetValue(1,0,1);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Localname sheet number should be 2", 2.0, 
nVal);
+
+// Copy sheet before, shifting following now two sheets.
+m_pDoc->CopyTab(1, 0);
+pName = m_pDoc->GetRangeName(0)->findByUpperName("LOCALNAME");
+CPPUNIT_ASSERT_MESSAGE("New sheet-local name should exist", pName);
+nVal = m_pDoc->GetValue(1,0,0);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("New sheet number should be 1", 1.0, nVal);
+pName = m_pDoc->GetRangeName(1)->findByUpperName("LOCALNAME");
+CPPUNIT_ASSERT_MESSAGE("Old sheet-local name should not exist", !pName);
+pName = m_pDoc->GetRangeName(2)->findByUpperName("LOCALNAME");
+CPPUNIT_ASSERT_MESSAGE("Org sheet-local name should exist", pName);
+nVal = m_pDoc->GetValue(1,0,2);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("New sheet number should be 3", 3.0, nVal);
+
+m_pDoc->DeleteTab(2);
+m_pDoc->DeleteTab(1);
+m_pDoc->DeleteTab(0);
 }
 
 void Test::testFormulaRefUpdateNameDelete()
commit 0189bfe9828c3f52cd72cf2f9da22d110e08c327
Author: Eike Rathke 
Date:   Fri Mar 25 21:36:00 2016 +0100

sheet-local names' references of original sheet are updated later

... in contrast to global names that are already updated before content
is copied. So don't modify the token's original sheet number before
adjusting the copied sheet-local names' references.

Change-Id: I3edfb53370a5e8811d7301af95238a865ff38f0c

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 1939f21..a8f8291 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -485,12 +485,13 @@ void adjustRangeName(formula::FormulaToken* pToken, 
ScDocument& rNewDoc, const S
 // Search the name of the RangeName.
 if (nOldSheet >= 0)
 {
+SCTAB nOldTab = nOldSheet;
 // XXX bGlobalNamesToLocal is also a synonym for copied sheet.
 if (bGlobalNamesToLocal && bSameDoc && rNewPos.Tab() <= rOldPos.Tab())
 // Sheet was already inserted before old position.
-++nOldSheet;
+++nOldTab;
 
-const ScRangeName* pRangeName = pOldDoc->GetRangeName(nOldSheet);
+const ScRangeName* pRangeName = pOldDoc->GetRangeName(nOldTab);
 pOldRangeData = pRangeName ? pRangeName->findByIndex(nOldIndex) : 
nullptr;
 if (!pOldRangeData)
 return; // might be an error in the formula array
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-03-19 Thread Pranav Kant
 sc/qa/unit/tiledrendering/data/select-row-cols.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   69 +
 sc/source/ui/unoobj/docuno.cxx |2 
 3 files changed, 70 insertions(+), 1 deletion(-)

New commits:
commit 91904157beb804e78570dedf3b57fc8407d399a8
Author: Pranav Kant 
Date:   Wed Mar 16 22:13:08 2016 +0530

sc tiled rendering: Unit test for extended .uno:SelectRow/Column

Change-Id: I0ab89598af28e12bebc271f7bce1e6166cb83b1d

diff --git a/sc/qa/unit/tiledrendering/data/select-row-cols.ods 
b/sc/qa/unit/tiledrendering/data/select-row-cols.ods
new file mode 100644
index 000..83cb8f1
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/select-row-cols.ods 
differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index ecfd605..539fe18 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -46,11 +46,13 @@ public:
 virtual void tearDown() SAL_OVERRIDE;
 
 #if !defined(WNT) && !defined(MACOSX)
+void testRowColumnSelections();
 void testSortAscendingDescending();
 #endif
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 #if !defined(WNT) && !defined(MACOSX)
+CPPUNIT_TEST(testRowColumnSelections);
 CPPUNIT_TEST(testSortAscendingDescending);
 #endif
 CPPUNIT_TEST_SUITE_END();
@@ -150,6 +152,73 @@ void ScTiledRenderingTest::callbackImpl(int /*nType*/, 
const char* /*pPayload*/)
 }
 #endif
 
+void ScTiledRenderingTest::testRowColumnSelections()
+{
+comphelper::LibreOfficeKit::setActive();
+ScModelObj* pModelObj = createDoc("select-row-cols.ods");
+//ScDocument* pDoc = pModelObj->GetDocument();
+
+uno::Sequence aArgs(2);
+
+// Select the 5th row with no modifier
+aArgs[0].Name = OUString::fromUtf8("Row");
+aArgs[0].Value <<= static_cast(5 - 1);
+aArgs[1].Name = OUString::fromUtf8("Modifier");
+aArgs[1].Value <<= static_cast(0);
+comphelper::dispatchCommand(".uno:SelectRow", aArgs);
+
+// Check if it is selected
+OString aUsedMimeType;
+OString aResult = pModelObj->getTextSelection("text/plain;charset=utf-8", 
aUsedMimeType);
+OString 
aExpected("1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\n");
+CPPUNIT_ASSERT_EQUAL(aExpected, aResult);
+
+// Select the 10th row with shift modifier
+aArgs[0].Name = OUString::fromUtf8("Row");
+aArgs[0].Value <<= static_cast(10 - 1);
+aArgs[1].Name = OUString::fromUtf8("Modifier");
+aArgs[1].Value <<= static_cast(KEY_SHIFT);
+comphelper::dispatchCommand(".uno:SelectRow", aArgs);
+
+// Check if all the rows from 5th to 10th get selected
+aResult = pModelObj->getTextSelection("text/plain;charset=utf-8", 
aUsedMimeType);
+aExpected = 
"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\n2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\n3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\n4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\n5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\n6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\n";
+CPPUNIT_ASSERT_EQUAL(aExpected, aResult);
+
+// Select the 10th row with ctrl modifier
+aArgs[0].Name = OUString::fromUtf8("Row");
+aArgs[0].Value <<= static_cast(13 - 1);
+aArgs[1].Name = OUString::fromUtf8("Modifier");
+aArgs[1].Value <<= static_cast(KEY_MOD1);
+comphelper::dispatchCommand(".uno:SelectRow", aArgs);
+
+// When we copy this, we don't get anything useful, but we must not crash
+// (used to happen)
+aResult = pModelObj->getTextSelection("text/plain;charset=utf-8", 
aUsedMimeType);
+CPPUNIT_ASSERT_EQUAL(OString(), aResult);
+
+// TODO check that we really selected what we wanted here
+
+// Select Column 5 with ctrl modifier
+aArgs[0].Name = OUString::fromUtf8("Col");
+aArgs[0].Value <<= static_cast(5 - 1);
+aArgs[1].Name = OUString::fromUtf8("Modifier");
+aArgs[1].Value <<= static_cast(KEY_MOD1);
+comphelper::dispatchCommand(".uno:SelectColumn", aArgs);
+
+// When we copy this, we don't get anything useful, but we must not crash
+// (used to happen)
+aResult = pModelObj->getTextSelection("text/plain;charset=utf-8", 
aUsedMimeType);
+CPPUNIT_ASSERT_EQUAL(OString(), aResult);
+
+// TODO check that we really selected what we wanted here
+
+// TODO: Add test for negative selection: .uno:SelectRow/Column on already
+// selected row/column should deselect it.
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 void ScTiledRenderingTest::testSortAscendingDescending()
 {
 comphelper::LibreOfficeKit::setActive();
commit 1592f030f8cab535b7ad0516abca0e309f84d4a3
Author: Jan Holesovsky 
Date:   Fri 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-01-27 Thread Markus Mohrhard
 sc/qa/unit/data/xlsx/preserve_space.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx|   16 
 sc/source/filter/excel/xestring.cxx  |2 +-
 3 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 4c61179b747e6309b9693cc1e2e79b2589aa807d
Author: Markus Mohrhard 
Date:   Wed Jan 27 16:27:06 2016 +0100

add test for tdf#96912

Change-Id: I6d3f7f86cffef8e91cf108c3aecdf5278e4b8658

diff --git a/sc/qa/unit/data/xlsx/preserve_space.xlsx 
b/sc/qa/unit/data/xlsx/preserve_space.xlsx
new file mode 100644
index 000..401a908
Binary files /dev/null and b/sc/qa/unit/data/xlsx/preserve_space.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 761a34a..e1f89b4 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -155,6 +155,7 @@ public:
 void testMoveCellAnchoredShapes();
 void testMatrixMultiplication();
 void testPreserveTextWhitespaceXLSX();
+void testPreserveTextWhitespace2XLSX();
 void testTextDirection();
 
 void testRefStringXLSX();
@@ -211,6 +212,7 @@ public:
 CPPUNIT_TEST(testLinkedGraphicRT);
 CPPUNIT_TEST(testImageWithSpecialID);
 CPPUNIT_TEST(testPreserveTextWhitespaceXLSX);
+CPPUNIT_TEST(testPreserveTextWhitespace2XLSX);
 CPPUNIT_TEST(testSheetLocalRangeNameXLS);
 CPPUNIT_TEST(testSheetTextBoxHyperlink);
 CPPUNIT_TEST(testFontSize);
@@ -2782,6 +2784,20 @@ void ScExportTest::testPreserveTextWhitespaceXLSX()
 xDocSh->DoClose();
 }
 
+void ScExportTest::testPreserveTextWhitespace2XLSX()
+{
+ScDocShellRef xShell = loadDoc("preserve_space.", FORMAT_XLSX);
+ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX);
+CPPUNIT_ASSERT(xDocSh.Is());
+
+xmlDocPtr pDoc = XPathHelper::parseExport(&(*xDocSh), m_xSFactory, 
"xl/sharedStrings.xml", FORMAT_XLSX);
+CPPUNIT_ASSERT(pDoc);
+assertXPath(pDoc, "/x:sst/x:si[1]/x:t", "space", "preserve");
+assertXPath(pDoc, "/x:sst/x:si[2]/x:r[1]/x:t", "space", "preserve");
+assertXPath(pDoc, "/x:sst/x:si[2]/x:r[2]/x:t", "space", "preserve");
+xDocSh->DoClose();
+}
+
 void ScExportTest::testHiddenShape()
 {
 ScDocShellRef xDocSh = loadDoc("hiddenShape.", FORMAT_XLSX);
commit 8aa853b2365430558693a32aa23825e199543cf9
Author: Markus Mohrhard 
Date:   Wed Jan 27 16:25:50 2016 +0100

we need the space="preserve" also for formatted strings, tdf#96912

Change-Id: I6e245de697c1c42acd916beb75d4d157b2962a9a

diff --git a/sc/source/filter/excel/xestring.cxx 
b/sc/source/filter/excel/xestring.cxx
index 58d1acef..d30b2f7 100644
--- a/sc/source/filter/excel/xestring.cxx
+++ b/sc/source/filter/excel/xestring.cxx
@@ -401,7 +401,7 @@ static sal_uInt16 lcl_WriteRun( XclExpXmlStream& rStrm, 
const ScfUInt16Vec& rBuf
 rWorksheet->endElement( XML_rPr );
 }
 rWorksheet->startElement( XML_t,
-FSEND );
+FSNS(XML_xml, XML_space), "preserve", FSEND );
 rWorksheet->writeEscaped( XclXmlUtils::ToOUString( rBuffer, nStart, 
nLength ) );
 rWorksheet->endElement( XML_t );
 rWorksheet->endElement( XML_r );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2016-01-03 Thread Markus Mohrhard
 sc/qa/unit/ucalc.hxx  |2 +-
 sc/source/core/tool/token.cxx |   13 +++--
 2 files changed, 4 insertions(+), 11 deletions(-)

New commits:
commit f4dc8a869ac49f19c20fc5fa606448e9103726bd
Author: Markus Mohrhard 
Date:   Sun Jan 3 16:29:50 2016 +0100

the idea behind the test can't work right now

The Test currently tries to test the OpenCL and the SW interpreter and
assumes that it will show different results. However if we succeed in
generating an OpenCL interpreter we will never generate a SW interpreter.

There are a number of problems with the approach taken in this test.

1.) Assuming that we are able to execute OpenCL is an invalid
assumption.

2.) Changing the configuration inside of a test needs to be exeption
save as we are otherwise left with a strange config for the remaining
test cases.

3.) Changing the configuration does not change the formula group
interpreter. This needs to be done explicitly.

Change-Id: I679985ee7551b21aaa52038e107324980e7e1bb6

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index fc90f81..b3e5bf3 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -474,7 +474,7 @@ public:
 CPPUNIT_TEST(testFormulaCreateStringFromTokens);
 CPPUNIT_TEST(testFormulaParseReference);
 CPPUNIT_TEST(testFetchVectorRefArray);
-CPPUNIT_TEST(testFormulaHashAndTag);
+// CPPUNIT_TEST(testFormulaHashAndTag);
 CPPUNIT_TEST(testFormulaTokenEquality);
 CPPUNIT_TEST(testFormulaRefData);
 CPPUNIT_TEST(testFormulaCompiler);
commit c4a90354df1009cd24a3ac4d1c72624759e7fe16
Author: Markus Mohrhard 
Date:   Sun Jan 3 16:18:46 2016 +0100

let us use the standard way to implement an if .. else if

Change-Id: Ie0b3efdbe23a163aab1e8d128217ee1f1c7fd287

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 05221e7..8e62a26 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1514,10 +1514,8 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
 default:
 meVectorState = FormulaVectorDisabled;
 }
-return;
 }
-
-if (eOp == ocPush)
+else if (eOp == ocPush)
 {
 // This is a stack variable.  See if this is a reference.
 
@@ -1557,28 +1555,23 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
 default:
 ;
 }
-return;
 }
-
-if (eOp >= SC_OPCODE_START_BIN_OP &&
+else if (eOp >= SC_OPCODE_START_BIN_OP &&
 eOp <= SC_OPCODE_STOP_UN_OP &&
 ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly &&
 ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == 
ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end())
 {
 meVectorState = FormulaVectorDisabled;
-return;
 }
-
 // only when openCL interpreter is not enabled - the assumption is that
 // the S/W interpreter blacklist is more strict
-if (eOp >= SC_OPCODE_START_BIN_OP &&
+else if (eOp >= SC_OPCODE_START_BIN_OP &&
 eOp <= SC_OPCODE_STOP_UN_OP &&
 ScCalcConfig::isSwInterpreterEnabled() &&
 
(dynamic_cast(sc::FormulaGroupInterpreter::getStatic())
 != nullptr) &&
 
ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == 
ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end())
 {
 meVectorState = FormulaVectorDisabled;
-return;
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-11-20 Thread Eike Rathke
 sc/qa/unit/ucalc.cxx|   25 +++
 sc/qa/unit/ucalc.hxx|2 +
 sc/source/core/data/formulacell.cxx |   47 ++--
 3 files changed, 67 insertions(+), 7 deletions(-)

New commits:
commit 01de2fc790b50c04f13907026f1a7782009fea61
Author: Eike Rathke 
Date:   Fri Nov 20 22:49:36 2015 +0100

unit test testMatrixConditionalBooleanResult

Change-Id: I6531a79b510da18b6799edd32d40cfce7dd2975a

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 66890c9..3fc85a6 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2033,6 +2033,31 @@ void Test::testMatrixComparisonWithErrors()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testMatrixConditionalBooleanResult()
+{
+m_pDoc->InsertTab(0, "foo");
+
+// Create matrix formulas in A1:B1,A2:B2,A3:B3,A4:B4 producing mixed
+// boolean and numeric results in an unformatted area.
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+m_pDoc->InsertMatrixFormula( 0,0, 1,0, aMark, "=IF({1,0};TRUE();42)");  // 
{TRUE,42}
+m_pDoc->InsertMatrixFormula( 0,1, 1,1, aMark, "=IF({0,1};TRUE();42)");  // 
{42,1} aim for {42,TRUE}
+m_pDoc->InsertMatrixFormula( 0,2, 1,2, aMark, "=IF({1,0};42;FALSE())"); // 
{42,0} aim for {42,FALSE}
+m_pDoc->InsertMatrixFormula( 0,3, 1,3, aMark, "=IF({0,1};42;FALSE())"); // 
{FALSE,42}
+
+CPPUNIT_ASSERT_EQUAL( OUString("TRUE"),  m_pDoc->GetString(0,0,0));
+CPPUNIT_ASSERT_EQUAL( OUString("42"),m_pDoc->GetString(1,0,0));
+CPPUNIT_ASSERT_EQUAL( OUString("42"),m_pDoc->GetString(0,1,0));
+//CPPUNIT_ASSERT_EQUAL( OUString("TRUE"),  m_pDoc->GetString(1,1,0));   // 
not yet
+CPPUNIT_ASSERT_EQUAL( OUString("42"),m_pDoc->GetString(0,2,0));
+//CPPUNIT_ASSERT_EQUAL( OUString("FALSE"), m_pDoc->GetString(1,2,0));   // 
not yet
+CPPUNIT_ASSERT_EQUAL( OUString("FALSE"), m_pDoc->GetString(0,3,0));
+CPPUNIT_ASSERT_EQUAL( OUString("42"),m_pDoc->GetString(1,3,0));
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testEnterMixedMatrix()
 {
 m_pDoc->InsertTab(0, "foo");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 9ea7f4b..fc90f81 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -236,6 +236,7 @@ public:
 void testCSV();
 void testMatrix();
 void testMatrixComparisonWithErrors();
+void testMatrixConditionalBooleanResult();
 void testEnterMixedMatrix();
 void testMatrixEditable();
 
@@ -559,6 +560,7 @@ public:
 CPPUNIT_TEST(testCSV);
 CPPUNIT_TEST(testMatrix);
 CPPUNIT_TEST(testMatrixComparisonWithErrors);
+CPPUNIT_TEST(testMatrixConditionalBooleanResult);
 CPPUNIT_TEST(testEnterMixedMatrix);
 CPPUNIT_TEST(testMatrixEditable);
 CPPUNIT_TEST(testPivotTable);
commit fd8c802533e962b8cd13f8aecc6a2a8aa487bba1
Author: Eike Rathke 
Date:   Fri Nov 20 22:10:38 2015 +0100

solve 6/8 cases of the dreaded conditional logical format in matrix results

So we now have
=IF({1,0},TRUE(),42)  => {TRUE,42}
=IF({0,1},TRUE(),42)  => {42,1}
=IF({1,0},42,FALSE()) => {42,0}
=IF({0,1},42,FALSE()) => {FALSE,42}

instead of before
=IF({1,0},TRUE(),42)  => {TRUE,TRUE}
=IF({0,1},TRUE(),42)  => {TRUE,TRUE}
=IF({1,0},42,FALSE()) => {TRUE,FALSE}
=IF({0,1},42,FALSE()) => {FALSE,TRUE}

Not perfect but better..

Change-Id: Ib4970f3c4c1bea87130730b956a0a6754879c6e6

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index d429c89..a405ebe 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1859,15 +1859,50 @@ void ScFormulaCell::InterpretTail( 
ScInterpretTailParameter eTailParam )
 bContentChanged = true;
 }
 
+ScFormulaResult aNewResult( p->GetResultToken().get());
+
 if( mbNeedsNumberFormat )
 {
+bool bSetFormat = true;
+const short nOldFormatType = nFormatType;
 nFormatType = p->GetRetFormatType();
 sal_Int32 nFormatIndex = p->GetRetFormatIndex();
 
-// don't set text format as hard format
-if(nFormatType == css::util::NumberFormat::TEXT)
-nFormatIndex = 0;
-else if((nFormatIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
+if (nFormatType == css::util::NumberFormat::TEXT)
+{
+// Don't set text format as hard format.
+bSetFormat = false;
+}
+else if (nFormatType == css::util::NumberFormat::LOGICAL && 
cMatrixFlag != MM_NONE)
+{
+// In a matrix range do not set an (inherited) logical format
+// as hard format if the value does not represent a strict TRUE
+// or FALSE value. But do set for a top left error value so
+// following matrix cells can inherit for non-error values.
+ 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-10-03 Thread Caolán McNamara
 sc/qa/unit/data/xls/pass/crash-3.xls |binary
 sc/source/filter/excel/impop.cxx |   15 +--
 2 files changed, 13 insertions(+), 2 deletions(-)

New commits:
commit c4d1a99ec667bdd661669afd72a708bd9a963db2
Author: Caolán McNamara 
Date:   Sat Oct 3 11:53:48 2015 +0100

fix crash on loading certain xls

Change-Id: I4f4563b07109df7e2288458cf8adda37582262cf

diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index 9b11b31..cc3c312 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -1026,17 +1026,21 @@ void ImportExcel::Array34()
 aIn.Ignore( (GetBiff() >= EXC_BIFF5) ? 6 : 2 );
 nFormLen = aIn.ReaduInt16();
 
+const ScTokenArray* pErgebnis = nullptr;
+
 if( ValidColRow( nLastCol, nLastRow ) )
 {
 // the read mark is now on the formula, length in nFormLen
-const ScTokenArray* pErgebnis;
 
 pFormConv->Reset( ScAddress( static_cast(nFirstCol),
 static_cast(nFirstRow), GetCurrScTab() ) );
 pFormConv->Convert( pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
 
-OSL_ENSURE( pErgebnis, "+ImportExcel::Array34(): ScTokenArray is 
NULL!" );
+SAL_WARN_IF(!pErgebnis, "sc", "+ImportExcel::Array34(): ScTokenArray 
is NULL!");
+}
 
+if (pErgebnis)
+{
 ScDocumentImport& rDoc = GetDocImport();
 ScRange aArrayRange(nFirstCol, nFirstRow, GetCurrScTab(), nLastCol, 
nLastRow, GetCurrScTab());
 rDoc.setMatrixCells(aArrayRange, *pErgebnis, 
formula::FormulaGrammar::GRAM_ENGLISH_XL_A1);
commit 4eb26f9cae2aacc8d672884283460e86e5c331ca
Author: Caolán McNamara 
Date:   Sat Oct 3 11:48:14 2015 +0100

xls: Defrowheight345 without pColRowBuff

Change-Id: I22be90d7c54b1118f81337bd9e1d97ba3a1fd86e

diff --git a/sc/qa/unit/data/xls/pass/crash-3.xls 
b/sc/qa/unit/data/xls/pass/crash-3.xls
new file mode 100644
index 000..99e485a
Binary files /dev/null and b/sc/qa/unit/data/xls/pass/crash-3.xls differ
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index e252185..9b11b31 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -1048,6 +1048,13 @@ void ImportExcel::Defrowheight345()
 sal_uInt16 nFlags, nDefHeight;
 nFlags = maStrm.ReaduInt16();
 nDefHeight = maStrm.ReaduInt16();
+
+if (!pColRowBuff)
+{
+SAL_WARN("sc", "*ImportExcel::Defrowheight345(): pColRowBuff is 
NULL!");
+return;
+}
+
 pColRowBuff->SetDefHeight( nDefHeight, nFlags );
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source xmloff/inc xmloff/source

2015-10-02 Thread Caolán McNamara
 sc/qa/unit/data/xls/pass/crash-1.xls |binary
 sc/source/filter/excel/impop.cxx |   24 +---
 xmloff/inc/DomExport.hxx |1 -
 xmloff/source/core/DomExport.cxx |6 --
 4 files changed, 13 insertions(+), 18 deletions(-)

New commits:
commit d2281e20d96c640998530f3fb577b87ee85426f1
Author: Caolán McNamara 
Date:   Fri Oct 2 10:41:25 2015 +0100

fix crash on loading certain xls

Change-Id: I2dd58060c1f3c9f12356c4ab18a0c838e7cdd718

diff --git a/sc/qa/unit/data/xls/pass/crash-1.xls 
b/sc/qa/unit/data/xls/pass/crash-1.xls
index 724bfc1..4b801ea3 100644
Binary files a/sc/qa/unit/data/xls/pass/crash-1.xls and 
b/sc/qa/unit/data/xls/pass/crash-1.xls differ
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index a08bd14..4339ae4 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -520,13 +520,11 @@ void ImportExcel::Columndefault()
 
 void ImportExcel::Array25()
 {
-sal_uInt16  nFirstRow, nLastRow, nFormLen;
-sal_uInt8   nFirstCol, nLastCol;
-
-nFirstRow = aIn.ReaduInt16();
-nLastRow = aIn.ReaduInt16();
-nFirstCol = aIn.ReaduInt8();
-nLastCol = aIn.ReaduInt8();
+sal_uInt16 nFormLen;
+sal_uInt16 nFirstRow = aIn.ReaduInt16();
+sal_uInt16 nLastRow = aIn.ReaduInt16();
+sal_uInt8 nFirstCol = aIn.ReaduInt8();
+sal_uInt8 nLastCol = aIn.ReaduInt8();
 
 if( GetBiff() == EXC_BIFF2 )
 {// BIFF2
@@ -539,17 +537,21 @@ void ImportExcel::Array25()
 nFormLen = aIn.ReaduInt16();
 }
 
-if( ValidColRow( nLastCol, nLastRow ) )
+const ScTokenArray* pErgebnis = nullptr;
+
+if (ValidColRow(nLastCol, nLastRow))
 {
 // the read mark is now on the formula, length in nFormLen
-const ScTokenArray* pErgebnis;
 
 pFormConv->Reset( ScAddress( static_cast(nFirstCol),
 static_cast(nFirstRow), GetCurrScTab() ) );
-pFormConv->Convert( pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
+pFormConv->Convert(pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
 
-OSL_ENSURE( pErgebnis, "*ImportExcel::Array25(): ScTokenArray is 
NULL!" );
+SAL_WARN_IF(!pErgebnis, "sc", "*ImportExcel::Array25(): ScTokenArray 
is NULL!");
+}
 
+if (pErgebnis)
+{
 ScDocumentImport& rDoc = GetDocImport();
 ScRange aArrayRange(nFirstCol, nFirstRow, GetCurrScTab(), nLastCol, 
nLastRow, GetCurrScTab());
 rDoc.setMatrixCells(aArrayRange, *pErgebnis, 
formula::FormulaGrammar::GRAM_ENGLISH_XL_A1);
commit 78cab9dc44009351ec1f19376b0594cb4a110814
Author: Caolán McNamara 
Date:   Fri Oct 2 11:42:24 2015 +0100

should be safe to remove this piece

Change-Id: Ic1c5be7794ff374c32a3c727d6233f69ea38c7aa

diff --git a/xmloff/inc/DomExport.hxx b/xmloff/inc/DomExport.hxx
index 6f88dc3..c8c9a5d 100644
--- a/xmloff/inc/DomExport.hxx
+++ b/xmloff/inc/DomExport.hxx
@@ -30,7 +30,6 @@ namespace com { namespace sun { namespace star {
 } } }
 
 void exportDom( SvXMLExport&, const 
com::sun::star::uno::Reference& );
-void exportDom( SvXMLExport&, const 
com::sun::star::uno::Reference& );
 
 #endif
 
diff --git a/xmloff/source/core/DomExport.cxx b/xmloff/source/core/DomExport.cxx
index ec55a17..4502718 100644
--- a/xmloff/source/core/DomExport.cxx
+++ b/xmloff/source/core/DomExport.cxx
@@ -257,10 +257,4 @@ void exportDom( SvXMLExport& rExport, const 
Reference& xDocument )
 visit( aDomExport, xDocument );
 }
 
-void exportDom( SvXMLExport& rExport, const Reference& xNode )
-{
-DomExport aDomExport( rExport );
-visit( aDomExport, xNode );
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-08-26 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx|   33 +
 sc/source/core/tool/address.cxx |   11 +--
 2 files changed, 42 insertions(+), 2 deletions(-)

New commits:
commit a7e273755095e4b97c05a63ab39aa09f8aa755a4
Author: Eike Rathke er...@redhat.com
Date:   Wed Aug 26 13:14:45 2015 +0200

unit test that parsing range fragments should fail

Change-Id: Iff5ef2a5b2315b19cf8f0e84a08c776c3c97e0ae

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 8a5d766..0e379f1 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -321,6 +321,39 @@ void Test::testFormulaParseReference()
 CPPUNIT_ASSERT_MESSAGE(This is not an external address., 
!aExtInfo.mbExternal);
 
 ScRange aRange;
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(:B, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(B:, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(:B2, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(B2:, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(:2, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(2:, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(:2B, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(2B:, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
 aRange.aStart.SetTab(0);
 nRes = aRange.Parse(B:B, m_pDoc, formula::FormulaGrammar::CONV_OOO);
 CPPUNIT_ASSERT_MESSAGE(Failed to parse., (nRes  SCA_VALID) != 0);
commit 56238d58a7da705e4e91604964e6564d819a9196
Author: Eike Rathke er...@redhat.com
Date:   Wed Aug 26 13:06:05 2015 +0200

do not parse range fragments as valid ranges

For example, B2: or :B2 were accepted as valid range, with the
missing part set to A1, which resulted in a A1:B2 range.

An omitted sheet specifier always results in a valid relative sheet,
hence that flag is set, so testing flags for non-null before the final
result is available isn't sufficient.

Additionally this revealed a flaw in handling of external references
when loading documents if the original file name differs from the
resulting real file name due to relative paths.

Actually now the displayed file name matches the real file name when
such a document was loaded, where before the original file name was
displayed.

Probably such references didn't even work before if the reference
spanned more than one sheet, which is a rather rare case for external
references.

Change-Id: I38035f2e4b3a11c0280457498cf62b02f882d2a1

diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 81e4047..8973f9d 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1198,7 +1198,14 @@ static sal_uInt16 lcl_ScAddress_Parse_OOo( const 
sal_Unicode* p, ScDocument* pDo
 // Need document name if inherited.
 if (bExtDocInherited)
 {
-const OUString* pFileName = pRefMgr-getExternalFileName( 
pExtInfo-mnFileId);
+// The FileId was created using the original file name, so
+// obtain that. Otherwise lcl_ScRange_External_TabSpan() would
+// retrieve a FileId for the real name and bail out if that
+// differed from pExtInfo-mnFileId, as is the case when
+// loading documents that refer external files relative to the
+// current own document but were saved from a different path
+// than loaded.
+const OUString* pFileName = pRefMgr-getExternalFileName( 
pExtInfo-mnFileId, true);
 if (pFileName)
 aDocName = *pFileName;
 else
@@ -1505,7 +1512,7 @@ static sal_uInt16 lcl_ScRange_Parse_OOo( ScRange rRange,
 nRes2 |= SCA_COL_ABSOLUTE;
 }
 }
-if (nRes1  nRes2)
+if ((nRes1  SCA_VALID)  (nRes2  SCA_VALID))
 {
 // PutInOrder / Justify
  

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-08-26 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx|   33 +
 sc/source/core/tool/address.cxx |2 +-
 2 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit 18a2a642c4a8848e2a2cb0df29c6463db8428ef9
Author: Eike Rathke er...@redhat.com
Date:   Wed Aug 26 13:14:45 2015 +0200

unit test that parsing range fragments should fail

Change-Id: Iff5ef2a5b2315b19cf8f0e84a08c776c3c97e0ae

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 8a5d766..0e379f1 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -321,6 +321,39 @@ void Test::testFormulaParseReference()
 CPPUNIT_ASSERT_MESSAGE(This is not an external address., 
!aExtInfo.mbExternal);
 
 ScRange aRange;
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(:B, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(B:, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(:B2, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(B2:, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(:2, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(2:, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(:2B, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
+aRange.aStart.SetTab(0);
+nRes = aRange.Parse(2B:, m_pDoc, formula::FormulaGrammar::CONV_OOO);
+CPPUNIT_ASSERT_MESSAGE(Should fail to parse., (nRes  SCA_VALID) == 0);
+
 aRange.aStart.SetTab(0);
 nRes = aRange.Parse(B:B, m_pDoc, formula::FormulaGrammar::CONV_OOO);
 CPPUNIT_ASSERT_MESSAGE(Failed to parse., (nRes  SCA_VALID) != 0);
commit ed6209f572bad38bdb066be668163fe8acf52056
Author: Eike Rathke er...@redhat.com
Date:   Wed Aug 26 13:06:05 2015 +0200

do not parse range fragments as valid ranges

For example, B2: or :B2 were accepted as valid range, with the
missing part set to A1, which resulted in a A1:B2 range.

An omitted sheet specifier always results in a valid relative sheet,
hence that flag is set, so testing flags for non-null before the final
result is available isn't sufficient.

Change-Id: I57d1b7cf71a298e7ac108b0e13aab88208f0f00c

diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 81e4047..da7a195 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1505,7 +1505,7 @@ static sal_uInt16 lcl_ScRange_Parse_OOo( ScRange rRange,
 nRes2 |= SCA_COL_ABSOLUTE;
 }
 }
-if (nRes1  nRes2)
+if ((nRes1  SCA_VALID)  (nRes2  SCA_VALID))
 {
 // PutInOrder / Justify
 sal_uInt16 nMask, nBits1, nBits2;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-08-10 Thread Łukasz Hryniuk
 sc/qa/unit/ucalc.hxx |2 ++
 sc/qa/unit/ucalc_formula.cxx |   30 ++
 sc/source/core/tool/interpr5.cxx |2 +-
 3 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit fc71e5b4637ece8822e83c844d191f461b2f0177
Author: Łukasz Hryniuk lukasz.hryn...@wp.pl
Date:   Sat Aug 8 20:50:04 2015 +0200

tdf#89387 related tests for ScSumXMY2()

Change-Id: Ia2ea65e05e0eec996f8ac485ee74b6daaa459178
Reviewed-on: https://gerrit.libreoffice.org/17598
Tested-by: Jenkins c...@libreoffice.org
Reviewed-by: Eike Rathke er...@redhat.com
Tested-by: Eike Rathke er...@redhat.com

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 759d65d..7c54dc0 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -160,6 +160,7 @@ public:
 void testFuncSUM();
 void testFuncPRODUCT();
 void testFuncSUMPRODUCT();
+void testFuncSUMXMY2();
 void testFuncMIN();
 void testFuncN();
 void testFuncCOUNTIF();
@@ -491,6 +492,7 @@ public:
 CPPUNIT_TEST(testFuncSUM);
 CPPUNIT_TEST(testFuncPRODUCT);
 CPPUNIT_TEST(testFuncSUMPRODUCT);
+CPPUNIT_TEST(testFuncSUMXMY2);
 CPPUNIT_TEST(testFuncMIN);
 CPPUNIT_TEST(testFuncN);
 CPPUNIT_TEST(testFuncCOUNTIF);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 38ac04a..720ff5e 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3369,6 +3369,36 @@ void Test::testFuncSUMPRODUCT()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFuncSUMXMY2()
+{
+m_pDoc-InsertTab(0, Test SumXMY2);
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
+
+ScAddress aPos(0,0,0);
+m_pDoc-SetString(aPos, =SUMXMY2(B1:B3;C1:C3));
+CPPUNIT_ASSERT_EQUAL(0.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(1,0,0),  1.0); // B1
+CPPUNIT_ASSERT_EQUAL(1.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(1,1,0),  2.0); // B2
+CPPUNIT_ASSERT_EQUAL(5.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(1,2,0),  3.0); // B3
+CPPUNIT_ASSERT_EQUAL(14.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(2,0,0), -1.0); // C1
+CPPUNIT_ASSERT_EQUAL(17.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(2,1,0),  3.0); // C2
+CPPUNIT_ASSERT_EQUAL(14.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(2,2,0),  1.0); // C3
+CPPUNIT_ASSERT_EQUAL(9.0,  m_pDoc-GetValue(aPos));
+
+double result = 0.0;
+m_pDoc-SetString(0, 4, 0, OUString(=SUMXMY2({2;3;4};{4;3;2})));
+m_pDoc-GetValue(0, 4, 0, result);
+CPPUNIT_ASSERT_MESSAGE(Calculation of SUMXMY2 with inline arrays failed, 
result == 8.0);
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFuncMIN()
 {
 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
commit d5bff1225a6739e8369bacd8392686bd26630d2f
Author: Łukasz Hryniuk lukasz.hryn...@wp.pl
Date:   Sat Aug 8 16:04:01 2015 +0200

tdf#89387 related, fix SumSquare bug in SumMXMY2

SumSquare returns IterateResult, which, because of rounding errors, store
first value in mfFirst and rest in mfRest. They should be added to get
the full sum of square of matrices difference.

Change-Id: I9bc435801d94206960b0b4fe4a9149ef1abeb3be
Reviewed-on: https://gerrit.libreoffice.org/17592
Reviewed-by: Eike Rathke er...@redhat.com
Tested-by: Eike Rathke er...@redhat.com

diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index c3c746d..907ce8d 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1791,7 +1791,7 @@ void ScInterpreter::ScSumXMY2()
 else
 {
 ScMatrix::IterateResult aRes = pResMat-SumSquare(false);
-double fSum = aRes.mfRest;
+double fSum = aRes.mfFirst + aRes.mfRest;
 PushDouble(fSum);
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-06-09 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx  |   29 +
 sc/source/core/tool/token.cxx |   19 ++-
 2 files changed, 39 insertions(+), 9 deletions(-)

New commits:
commit 782c116b5ac39aef27c3a00f7fc145c9f755e3a3
Author: Eike Rathke er...@redhat.com
Date:   Tue Jun 9 23:41:36 2015 +0200

more tests for the implemented cases, tdf#90001

Change-Id: Iec22ad67c9deaada827ba8eac47581e08f934353

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 9a0fb33..ed49635 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1616,6 +1616,35 @@ void Test::testFormulaRefUpdateSheetsDelete()
 m_pDoc-InsertTab(2, Sheet3);
 m_pDoc-InsertTab(3, Sheet4);
 
+m_pDoc-SetString(ScAddress(4,1,0), =SUM(Sheet2.A4:Sheet4.A4));
+m_pDoc-SetString(ScAddress(4,2,0), =SUM($Sheet2.A4:$Sheet4.A4));
+m_pDoc-DeleteTab(1);
+if (!checkFormula(*m_pDoc, ScAddress(4,1,0), SUM(Sheet3.A4:Sheet4.A4)))
+CPPUNIT_FAIL(Wrong Formula);
+if (!checkFormula(*m_pDoc, ScAddress(4,2,0), SUM($Sheet3.A4:$Sheet4.A4)))
+CPPUNIT_FAIL(Wrong Formula);
+m_pDoc-InsertTab(1, Sheet2);
+
+m_pDoc-SetString(ScAddress(5,1,3), =SUM(Sheet1.A5:Sheet3.A5));
+m_pDoc-SetString(ScAddress(5,2,3), =SUM($Sheet1.A5:$Sheet3.A5));
+m_pDoc-DeleteTab(2);
+if (!checkFormula(*m_pDoc, ScAddress(5,1,2), SUM(Sheet1.A5:Sheet2.A5)))
+CPPUNIT_FAIL(Wrong Formula);
+if (!checkFormula(*m_pDoc, ScAddress(5,2,2), SUM($Sheet1.A5:$Sheet2.A5)))
+CPPUNIT_FAIL(Wrong Formula);
+m_pDoc-InsertTab(2, Sheet3);
+
+m_pDoc-SetString(ScAddress(6,1,3), =SUM(Sheet1.A6:Sheet3.A6));
+m_pDoc-SetString(ScAddress(6,2,3), =SUM($Sheet1.A6:$Sheet3.A6));
+m_pDoc-DeleteTabs(0,3);
+if (!checkFormula(*m_pDoc, ScAddress(6,1,0), SUM(#REF!.A6:#REF!.A6)))
+CPPUNIT_FAIL(Wrong Formula);
+if (!checkFormula(*m_pDoc, ScAddress(6,2,0), SUM($#REF!.A6:$#REF!.A6)))
+CPPUNIT_FAIL(Wrong Formula);
+m_pDoc-InsertTab(0, Sheet1);
+m_pDoc-InsertTab(1, Sheet2);
+m_pDoc-InsertTab(2, Sheet3);
+
 m_pDoc-SetString(ScAddress(1,1,1), =SUM(Sheet1.A2:Sheet3.A2);
 m_pDoc-SetString(ScAddress(2,1,1), =SUM(Sheet1.A1:Sheet2.A1);
 m_pDoc-SetString(ScAddress(3,1,1), =SUM(Sheet2.A3:Sheet4.A3);
commit 20e4ccc6ba366cd70c9218e016ccff4025e3d816
Author: Eike Rathke er...@redhat.com
Date:   Tue Jun 9 23:29:38 2015 +0200

correct 3D reference update on sheet deletion, tdf#90001 follow-up

be1b3daeeb64a44e577510561d02147b87db72c2 missed a few cases
* a deleted reference start was shifted by two sheets instead of one if
  the formula was on a sheet before the deleted one
* a deleted reference end was not correct if the formula was on a sheet
  behind the deleted one and used relative sheet reference
* #REF! wasn't set when the entire referenced range was deleted

Change-Id: Ib9c7492a651a8429fa1c411c8e447593e366e09d

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 00c9395..4e20d93 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -3471,25 +3471,26 @@ bool adjustDoubleRefOnDeleteTab(ScComplexRefData rRef, 
SCTAB nDelPos, SCTAB nSh
 ScAddress aEndPos = rRef2.toAbs(rOldPos);
 bool bMoreThanOneTab = aStartPos.Tab() != aEndPos.Tab();
 bool bModified = false;
-if (bMoreThanOneTab  aStartPos.Tab() == nDelPos)
+if (bMoreThanOneTab  aStartPos.Tab() == nDelPos  nDelPos + nSheets = 
aEndPos.Tab())
 {
-if (rRef1.IsTabRel())
+if (rRef1.IsTabRel()  aStartPos.Tab()  rOldPos.Tab())
 {
-aStartPos.IncTab(nSheets);
-rRef1.SetAddress(aStartPos, rOldPos);
+rRef1.IncTab(nSheets);
+bModified = true;
 }
-bModified = true;
 }
 else
 {
 bModified = adjustSingleRefOnDeletedTab(rRef1, nDelPos, nSheets, 
rOldPos, rNewPos);
 }
 
-if (bMoreThanOneTab  aEndPos.Tab() == nDelPos)
+if (bMoreThanOneTab  aEndPos.Tab() == nDelPos  aStartPos.Tab() = 
nDelPos - nSheets)
 {
-aEndPos.IncTab(-nSheets);
-rRef2.SetAddress(aEndPos, rNewPos);
-bModified = true;
+if (!rRef2.IsTabRel() || rOldPos.Tab()  aEndPos.Tab())
+{
+rRef2.IncTab(-nSheets);
+bModified = true;
+}
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-05-19 Thread Markus Mohrhard
 sc/qa/unit/subsequent_filters-test.cxx   |2 ++
 sc/source/filter/oox/worksheethelper.cxx |   23 ++-
 2 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 16726a1b37df8bdcae02b3c7699df814977222bd
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Wed May 20 03:59:49 2015 +0200

better algorithm for OOXML column width import, tdf#91267

This patch contains a magic factor of 1.047 that is necessary as the set
value and retrieved value are not the same. When we ahve too much time
(propably never) we should explore why the value that we set for the
column width is not equal to the one that we see on the screen.

Change-Id: I317127ea5b8af2d5e8386758e66907a44fe58579

diff --git a/sc/source/filter/oox/worksheethelper.cxx 
b/sc/source/filter/oox/worksheethelper.cxx
index aaa45a9..3dfbf8a 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -78,6 +78,7 @@
 #include svl/stritem.hxx
 #include editeng/editobj.hxx
 #include editeng/flditem.hxx
+#include vcl/virdev.hxx
 
 namespace oox {
 namespace xls {
@@ -1166,11 +1167,31 @@ void WorksheetGlobals::convertColumns()
 convertOutlines( aColLevels, nMaxCol + 1, 0, false, false );
 }
 
+namespace {
+
+sal_Int32 getColumnWidth(UnitConverter rConverter, double nWidth)
+{
+double nCoeff = rConverter.getCoefficient(UNIT_DIGIT);
+VirtualDevice aDev;
+
+long nPixel = aDev.LogicToPixel(Point(nCoeff, 0), 
MapMode(MAP_100TH_MM)).getX();
+
+
+// the 1.047 has been experimentally chosen based on measurements witha  
screen ruler
+// TODO: fix the display of cells so that it no longer requires this hack
+// algorithm from OOXML spec part1: 18.3.1.13
+sal_Int32 nColWidthPixel= std::floor(((256*nWidth + 
std::floor(128.0/nPixel))/256.0)*nPixel) * 1.047;
+
+return aDev.PixelToLogic(Point(nColWidthPixel, 0), 
MapMode(MAP_100TH_MM)).getX();
+}
+
+}
+
 void WorksheetGlobals::convertColumns( OutlineLevelVec orColLevels,
 const ValueRange rColRange, const ColumnModel rModel )
 {
 // column width: convert 'number of characters' to column width in 1/100 mm
-sal_Int32 nWidth = getUnitConverter().scaleToMm100( rModel.mfWidth, 
UNIT_DIGIT );
+sal_Int32 nWidth = getColumnWidth(getUnitConverter(), rModel.mfWidth);
 // macro sheets have double width
 if( meSheetType == SHEETTYPE_MACROSHEET )
 nWidth *= 2;
commit 1d2d037b4defa775b164880b56732af2a837f254
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Tue May 19 05:49:28 2015 +0200

add missing DoClose at end of test

Change-Id: Ia06522ba4d3e6b4495e17d260d0bc3618b1a7cf2

diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index c0b12d3..a110cb56 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -3046,6 +3046,8 @@ void ScFiltersTest::testEditEngStrikeThroughXLSX()
 }
 }
 }
+
+xDocSh-DoClose();
 }
 
 void ScFiltersTest::testRefStringXLSX()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-03-28 Thread Markus Mohrhard
 sc/qa/unit/ucalc.hxx  |2 +
 sc/qa/unit/ucalc_formula.cxx  |   59 ++
 sc/source/core/tool/token.cxx |   40 +---
 3 files changed, 97 insertions(+), 4 deletions(-)

New commits:
commit 7937984a6a04446c0d3484832e6748ad925ddc80
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Sat Mar 28 15:35:13 2015 +0100

test for tdf#90001

Change-Id: If0cb056d5a5e82bec1f4b863e40ec05b405280ac

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index a60e478..1cec088 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -136,6 +136,7 @@ public:
 void testFormulaRefUpdate();
 void testFormulaRefUpdateRange();
 void testFormulaRefUpdateSheets();
+void testFormulaRefUpdateSheetsDelete();
 void testFormulaRefUpdateInsertRows();
 void testFormulaRefUpdateInsertColumns();
 void testFormulaRefUpdateMove();
@@ -456,6 +457,7 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdate);
 CPPUNIT_TEST(testFormulaRefUpdateRange);
 CPPUNIT_TEST(testFormulaRefUpdateSheets);
+CPPUNIT_TEST(testFormulaRefUpdateSheetsDelete);
 CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
 CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
 CPPUNIT_TEST(testFormulaRefUpdateMove);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index ca731a2..fe7d417 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1609,6 +1609,65 @@ void Test::testFormulaRefUpdateInsertRows()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFormulaRefUpdateSheetsDelete()
+{
+m_pDoc-InsertTab(0, Sheet1);
+m_pDoc-InsertTab(1, Sheet2);
+m_pDoc-InsertTab(2, Sheet3);
+m_pDoc-InsertTab(3, Sheet4);
+
+m_pDoc-SetString(ScAddress(1,1,1), =SUM(Sheet1.A2:Sheet3.A2);
+m_pDoc-SetString(ScAddress(2,1,1), =SUM(Sheet1.A1:Sheet2.A1);
+m_pDoc-SetString(ScAddress(3,1,1), =SUM(Sheet2.A3:Sheet4.A3);
+
+m_pDoc-SetString(ScAddress(1,2,1), =SUM($Sheet1.A2:$Sheet3.A2);
+m_pDoc-SetString(ScAddress(2,2,1), =SUM($Sheet1.A1:$Sheet2.A1);
+m_pDoc-SetString(ScAddress(3,2,1), =SUM($Sheet2.A3:$Sheet4.A3);
+
+m_pDoc-DeleteTab(2);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,1,1), SUM(Sheet1.A2:Sheet2.A2)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(2,1,1), SUM(Sheet1.A1:Sheet2.A1)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(3,1,1), SUM(Sheet2.A3:Sheet4.A3)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,2,1), SUM($Sheet1.A2:$Sheet2.A2)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(2,2,1), SUM($Sheet1.A1:$Sheet2.A1)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(3,2,1), SUM($Sheet2.A3:$Sheet4.A3)))
+CPPUNIT_FAIL(Wrong Formula);
+
+m_pDoc-DeleteTab(0);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,1,0), SUM(Sheet2.A2:Sheet2.A2)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(2,1,0), SUM(Sheet2.A1:Sheet2.A1)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(3,1,0), SUM(Sheet2.A3:Sheet4.A3)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,2,0), SUM($Sheet2.A2:$Sheet2.A2)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(2,2,0), SUM($Sheet2.A1:$Sheet2.A1)))
+CPPUNIT_FAIL(Wrong Formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(3,2,0), SUM($Sheet2.A3:$Sheet4.A3)))
+CPPUNIT_FAIL(Wrong Formula);
+
+m_pDoc-DeleteTab(0);
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFormulaRefUpdateInsertColumns()
 {
 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
commit be1b3daeeb64a44e577510561d02147b87db72c2
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Sat Mar 28 05:43:33 2015 +0100

3D refs with more than one sheet should not set sheets deleted, tdf#90001

Change-Id: I501ad421c283ec6a1f2629aa424f4d4c32228516

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6b582ec..ada4f91 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -3373,6 +3373,41 @@ bool adjustSingleRefOnInsertedTab( ScSingleRefData 
rRef, SCTAB nInsPos, SCTAB n
 return false;
 }
 
+bool adjustDoubleRefOnDeleteTab(ScComplexRefData rRef, SCTAB nDelPos, SCTAB 
nSheets, const ScAddress rOldPos, const ScAddress rNewPos)
+{
+ScSingleRefData rRef1 = rRef.Ref1;
+ScSingleRefData rRef2 = rRef.Ref2;
+ScAddress aStartPos = rRef1.toAbs(rOldPos);
+ScAddress aEndPos = rRef2.toAbs(rOldPos);
+bool bMoreThanOneTab = aStartPos.Tab() != aEndPos.Tab();
+bool bModified = false;
+if (bMoreThanOneTab  aStartPos.Tab() == nDelPos)
+{
+if (rRef1.IsTabRel())
+{
+aStartPos.IncTab(nSheets);
+

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2015-01-27 Thread Eike Rathke
 sc/qa/unit/ucalc_formula.cxx |   14 ++
 sc/source/core/tool/interpr5.cxx |2 +-
 sc/source/core/tool/scmatrix.cxx |4 ++--
 3 files changed, 17 insertions(+), 3 deletions(-)

New commits:
commit e5eb67781e352b5c13494f1ea1e39ea3a4dc0629
Author: Eike Rathke er...@redhat.com
Date:   Tue Jan 27 15:13:59 2015 +0100

add unit test for tdf#88786

Change-Id: I0cb533399a1e3ce83875f2966cb59354e92f05b5

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index ab23102..ca731a2 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -4867,6 +4867,20 @@ void Test::testMatrixOp()
 nVal = m_pDoc-GetValue(2, 1, 0);
 CPPUNIT_ASSERT_EQUAL(4.0, nVal);
 
+m_pDoc-SetString(4, 0, 0, =SUMPRODUCT({1;2;4}+8));
+m_pDoc-SetString(4, 1, 0, =SUMPRODUCT(8+{1;2;4}));
+m_pDoc-SetString(4, 2, 0, =SUMPRODUCT({1;2;4}-8));
+m_pDoc-SetString(4, 3, 0, =SUMPRODUCT(8-{1;2;4}));
+m_pDoc-SetString(4, 4, 0, =SUMPRODUCT({1;2;4}+{8;16;32}));
+m_pDoc-SetString(4, 5, 0, =SUMPRODUCT({8;16;32}+{1;2;4}));
+m_pDoc-SetString(4, 6, 0, =SUMPRODUCT({1;2;4}-{8;16;32}));
+m_pDoc-SetString(4, 7, 0, =SUMPRODUCT({8;16;32}-{1;2;4}));
+double fResult[8] = { 31.0, 31.0, -17.0, 17.0, 63.0, 63.0, -49.0, 49.0 };
+for (size_t i = 0; i  SAL_N_ELEMENTS(fResult); ++i)
+{
+CPPUNIT_ASSERT_EQUAL( fResult[i], m_pDoc-GetValue(4, i, 0));
+}
+
 m_pDoc-DeleteTab(0);
 }
 
commit b435ca9e6f826704314f8a437c352aa799767bd4
Author: Eike Rathke er...@redhat.com
Date:   Tue Jan 27 14:50:36 2015 +0100

Resolves: tdf#88786 correct matrix sub operation

Change-Id: Ib5ce2ffe17cc34e0b3f04ebc06ea392707b7b9e6

diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index fe87c04..b6d616e 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1297,7 +1297,7 @@ void ScInterpreter::CalculateAddSub(bool _bSub)
 }
 else
 {
-pMat-SubAddOp(true, fVal, aString, *pResMat);
+pMat-SubAddOp(false, -fVal, aString, *pResMat);
 }
 PushMatrix(pResMat);
 }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index bf2f163..4402002 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -2553,12 +2553,12 @@ public:
 
 double operator()(double nVal) const
 {
-return nVal - mnVal;
+return mnVal - nVal;
 }
 
 double operator()(bool bVal) const
 {
-return (double)bVal - mnVal;
+return mnVal - (double)bVal;
 }
 
 svl::SharedString operator()(const svl::SharedString) const
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-12-29 Thread Markus Mohrhard
 dev/null  |binary
 sc/qa/unit/data/xls/shared-formula/relative-refs1.xls |binary
 sc/qa/unit/data/xls/shared-formula/relative-refs2.xls |binary
 sc/qa/unit/subsequent_filters-test.cxx|   61 ++
 sc/source/filter/excel/excform8.cxx   |   11 ++-
 sc/source/filter/excel/impop.cxx  |   12 +--
 6 files changed, 64 insertions(+), 20 deletions(-)

New commits:
commit 11109ded381e0cc4f44f7837af995c8c82b3df09
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Tue Dec 30 01:17:29 2014 +0100

add test for fdo#84556

Change-Id: I9b3af4f66513fff437facd17c0758ee92ac5744d

diff --git a/sc/qa/unit/data/xls/shared-formula/relative-refs.xls 
b/sc/qa/unit/data/xls/shared-formula/relative-refs1.xls
similarity index 100%
rename from sc/qa/unit/data/xls/shared-formula/relative-refs.xls
rename to sc/qa/unit/data/xls/shared-formula/relative-refs1.xls
diff --git a/sc/qa/unit/data/xls/shared-formula/relative-refs2.xls 
b/sc/qa/unit/data/xls/shared-formula/relative-refs2.xls
new file mode 100644
index 000..56ff822
Binary files /dev/null and 
b/sc/qa/unit/data/xls/shared-formula/relative-refs2.xls differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 529486d..703f905 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -2583,23 +2583,58 @@ void ScFiltersTest::testSharedFormulaXLSB()
 
 void ScFiltersTest::testSharedFormulaXLS()
 {
-ScDocShellRef xDocSh = loadDoc(shared-formula/relative-refs., XLS);
-CPPUNIT_ASSERT(xDocSh.Is());
-ScDocument rDoc = xDocSh-GetDocument();
-rDoc.CalcAll();
+{
+// fdo#80091
+ScDocShellRef xDocSh = loadDoc(shared-formula/relative-refs1., XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument rDoc = xDocSh-GetDocument();
+rDoc.CalcAll();
 
-// A1:A30 should be all formulas, and they should belong to the same group.
-const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0,1,0));
-CPPUNIT_ASSERT(pFC);
-CPPUNIT_ASSERT_EQUAL(static_castSCROW(1), pFC-GetSharedTopRow());
-CPPUNIT_ASSERT_EQUAL(static_castSCROW(29), pFC-GetSharedLength());
+// A1:A30 should be all formulas, and they should belong to the same 
group.
+const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0,1,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(1), pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(29), pFC-GetSharedLength());
 
-for(SCROW nRow = 0; nRow  30; ++nRow)
-{
-ASSERT_DOUBLES_EQUAL(double(nRow+1), rDoc.GetValue(0, nRow, 0));
+for(SCROW nRow = 0; nRow  30; ++nRow)
+{
+ASSERT_DOUBLES_EQUAL(double(nRow+1), rDoc.GetValue(0, nRow, 0));
+}
+
+xDocSh-DoClose();
 }
 
-xDocSh-DoClose();
+{
+// fdo#84556 and some related tests
+ScDocShellRef xDocSh = loadDoc(shared-formula/relative-refs2., XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument rDoc = xDocSh-GetDocument();
+rDoc.CalcAll();
+
+{
+const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(2,1,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(1), 
pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(10), 
pFC-GetSharedLength());
+
+OUString aFormula;
+rDoc.GetFormula(2, 1, 0, aFormula);
+CPPUNIT_ASSERT_EQUAL(OUString(=SUM(B9:D9)), aFormula);
+}
+
+{
+const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(4,8,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(8), 
pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(10), 
pFC-GetSharedLength());
+
+OUString aFormula;
+rDoc.GetFormula(4, 8, 0, aFormula);
+CPPUNIT_ASSERT_EQUAL(OUString(=SUM(G9:EY9)), aFormula);
+}
+
+xDocSh-DoClose();
+}
 }
 
 void ScFiltersTest::testExternalRefCacheXLSX()
commit b010e6724fa5cd519daafd3abf57f0a3257025bb
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Tue Dec 30 01:16:53 2014 +0100

relative refs wrap around in xls, fdo#84556

Change-Id: If84d468d4bd55ed55ccd517d0b078d283a1a9c38

diff --git a/sc/source/filter/excel/excform8.cxx 
b/sc/source/filter/excel/excform8.cxx
index 042d79b..ff4bd6c 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -1464,7 +1464,16 @@ void ExcelToSc8::ExcRelToScRel8( sal_uInt16 nRow, 
sal_uInt16 nC, ScSingleRefData
 {
 // C O L
 if( bColRel )
-rSRD.SetRelCol(static_castSCCOL(static_castsal_Int8(nC)));
+{
+SCCOL nRelCol = static_castsal_Int8(nC);
+sal_Int16 nDiff = aEingPos.Col() + nRelCol;
+   

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-12-29 Thread Markus Mohrhard
 sc/qa/unit/data/xls/named-ranges-local.xls |binary
 sc/qa/unit/subsequent_filters-test.cxx |   23 +++
 sc/source/filter/excel/xeformula.cxx   |4 ++--
 3 files changed, 25 insertions(+), 2 deletions(-)

New commits:
commit 339521b5448ae3f63b790f144976e78c9941ed33
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Tue Dec 30 06:30:30 2014 +0100

add test for fdo#81195

Change-Id: If19f4067d53c2c614f6afcc0d6349db6ec2fd602

diff --git a/sc/qa/unit/data/xls/named-ranges-local.xls 
b/sc/qa/unit/data/xls/named-ranges-local.xls
new file mode 100644
index 000..7c39d20
Binary files /dev/null and b/sc/qa/unit/data/xls/named-ranges-local.xls differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 703f905..bafe992 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -88,6 +88,7 @@ public:
 //ods, xls, xlsx filter tests
 void testBasicCellContentODS();
 void testRangeNameXLS();
+void testRangeNameLocalXLS();
 void testRangeNameXLSX();
 void testHyperlinksXLSX();
 void testHardRecalcODS();
@@ -185,6 +186,7 @@ public:
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testBasicCellContentODS);
 CPPUNIT_TEST(testRangeNameXLS);
+CPPUNIT_TEST(testRangeNameLocalXLS);
 CPPUNIT_TEST(testRangeNameXLSX);
 CPPUNIT_TEST(testHyperlinksXLSX);
 CPPUNIT_TEST(testHardRecalcODS);
@@ -363,6 +365,27 @@ void ScFiltersTest::testRangeNameXLS()
 xDocSh-DoClose();
 }
 
+void ScFiltersTest::testRangeNameLocalXLS()
+{
+ScDocShellRef xDocSh = loadDoc(named-ranges-local., XLS);
+xDocSh-DoHardRecalc(true);
+
+ScDocument rDoc = xDocSh-GetDocument();
+ScRangeName* pRangeName = rDoc.GetRangeName(0);
+CPPUNIT_ASSERT(pRangeName);
+CPPUNIT_ASSERT_EQUAL(size_t(2), pRangeName-size());
+
+OUString aFormula;
+rDoc.GetFormula(3, 11, 0, aFormula);
+CPPUNIT_ASSERT_EQUAL(OUString(=SUM(local_name2)), aFormula);
+ASSERT_DOUBLES_EQUAL(14.0, rDoc.GetValue(3, 11, 0));
+
+rDoc.GetFormula(6, 4, 0, aFormula);
+CPPUNIT_ASSERT_EQUAL(OUString(=local_name1), aFormula);
+
+xDocSh-DoClose();
+}
+
 void ScFiltersTest::testRangeNameXLSX()
 {
 ScDocShellRef xDocSh = loadDoc(named-ranges-global., XLSX);
commit 4ebdadfda60f108556ea9cc4436dd440bf122ca4
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Tue Dec 30 06:16:45 2014 +0100

use the correct tab for sheet local names, fdo#81195

Change-Id: I7e8b7ed552a37c6d9c6ce7c75765267b343d508c

diff --git a/sc/source/filter/excel/xeformula.cxx 
b/sc/source/filter/excel/xeformula.cxx
index 214d979..145aaf3 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -2078,8 +2078,8 @@ void XclExpFmlaCompImpl::ProcessDefinedName( const 
XclExpScToken rTokData )
 {
 SCTAB nTab = SCTAB_GLOBAL;
 bool bGlobal = rTokData.mpScToken-IsGlobal();
-if (!bGlobal  mxData-mpScBasePos)
-nTab = mxData-mpScBasePos-Tab();
+if (!bGlobal)
+nTab = GetCurrScTab();
 
 XclExpNameManager rNameMgr = GetNameManager();
 sal_uInt16 nNameIdx = rNameMgr.InsertName(nTab, 
rTokData.mpScToken-GetIndex());
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-12-28 Thread Markus Mohrhard
 sc/qa/unit/data/xls/shared-formula/relative-refs.xls |binary
 sc/qa/unit/subsequent_filters-test.cxx   |   23 +++
 sc/source/filter/excel/excform8.cxx  |7 -
 3 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit 0c24686c3970bac7e9a4e214fccfdfffd742149e
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Mon Dec 29 06:23:53 2014 +0100

add test for fdo#80091

Change-Id: I8b62c0980275537adea7a4de44d4fe86995da92f

diff --git a/sc/qa/unit/data/xls/shared-formula/relative-refs.xls 
b/sc/qa/unit/data/xls/shared-formula/relative-refs.xls
new file mode 100644
index 000..88678b4
Binary files /dev/null and 
b/sc/qa/unit/data/xls/shared-formula/relative-refs.xls differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 2ba0050..529486d 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -174,6 +174,7 @@ public:
 void testSharedFormulaWrappedRefsXLS();
 void testSharedFormulaBIFF5();
 void testSharedFormulaXLSB();
+void testSharedFormulaXLS();
 void testExternalRefCacheXLSX();
 void testExternalRefCacheODS();
 void testHybridSharedStringODS();
@@ -257,6 +258,7 @@ public:
 CPPUNIT_TEST(testSharedFormulaWrappedRefsXLS);
 CPPUNIT_TEST(testSharedFormulaBIFF5);
 CPPUNIT_TEST(testSharedFormulaXLSB);
+CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testExternalRefCacheXLSX);
 CPPUNIT_TEST(testExternalRefCacheODS);
 CPPUNIT_TEST(testHybridSharedStringODS);
@@ -2579,6 +2581,27 @@ void ScFiltersTest::testSharedFormulaXLSB()
 xDocSh-DoClose();
 }
 
+void ScFiltersTest::testSharedFormulaXLS()
+{
+ScDocShellRef xDocSh = loadDoc(shared-formula/relative-refs., XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument rDoc = xDocSh-GetDocument();
+rDoc.CalcAll();
+
+// A1:A30 should be all formulas, and they should belong to the same group.
+const ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0,1,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(1), pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(29), pFC-GetSharedLength());
+
+for(SCROW nRow = 0; nRow  30; ++nRow)
+{
+ASSERT_DOUBLES_EQUAL(double(nRow+1), rDoc.GetValue(0, nRow, 0));
+}
+
+xDocSh-DoClose();
+}
+
 void ScFiltersTest::testExternalRefCacheXLSX()
 {
 ScDocShellRef xDocSh = loadDoc(external-refs., XLSX);
commit 16bfddca6187a426523bbe187db4506a34b5511c
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Mon Dec 29 06:01:27 2014 +0100

handle relative refs correctly in xls import, fdo#80091

Change-Id: Ia70f96e1d31e71c56f03c828be0a4e49fff4b198

diff --git a/sc/source/filter/excel/excform8.cxx 
b/sc/source/filter/excel/excform8.cxx
index f206804..042d79b 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -631,9 +631,12 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray* 
rpTokArray, XclImpStream aIn,
 ExcRelToScRel8( nRowFirst, nColFirst, aCRD.Ref1, bRNorSF );
 ExcRelToScRel8( nRowLast, nColLast, aCRD.Ref2, bRNorSF );
 
-if( IsComplColRange( nColFirst, nColLast ) )
+bool bColRel = aCRD.Ref1.IsColRel() || aCRD.Ref2.IsColRel();
+bool bRowRel = aCRD.Ref1.IsRowRel() || aCRD.Ref2.IsRowRel();
+
+if( !bColRel  IsComplColRange( nColFirst, nColLast ) )
 SetComplCol( aCRD );
-else if( IsComplRowRange( nRowFirst, nRowLast ) )
+else if( !bRowRel  IsComplRowRange( nRowFirst, nRowLast ) )
 SetComplRow( aCRD );
 
 aStack  aPool.Store( aCRD );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-12-11 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx  |2 +
 sc/qa/unit/ucalc_sharedformula.cxx|   36 ++
 sc/source/core/tool/sharedformula.cxx |7 --
 3 files changed, 43 insertions(+), 2 deletions(-)

New commits:
commit 170616e9f2d30c1302bbb5a7a4b588bc05cd5cc9
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Dec 11 20:54:12 2014 -0500

fdo#86572: Write test for this.

Change-Id: I00c3eaac473f0464e923e785cc50ad6769c78d41

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index b233274..0c39d6f 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -327,6 +327,7 @@ public:
 void testSharedFormulaMoveBlock();
 void testSharedFormulaUpdateOnNamedRangeChange();
 void testSharedFormulaUpdateOnDBChange();
+void testSharedFormulaAbsCellListener();
 void testFormulaPosition();
 
 void testMixData();
@@ -563,6 +564,7 @@ public:
 CPPUNIT_TEST(testSharedFormulaInsertColumn);
 CPPUNIT_TEST(testSharedFormulaUpdateOnNamedRangeChange);
 CPPUNIT_TEST(testSharedFormulaUpdateOnDBChange);
+CPPUNIT_TEST(testSharedFormulaAbsCellListener);
 CPPUNIT_TEST(testFormulaPosition);
 CPPUNIT_TEST(testMixData);
 CPPUNIT_TEST(testJumpToPrecedentsDependents);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index 677f4ff..aa1d778 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1656,4 +1656,40 @@ void Test::testSharedFormulaUpdateOnDBChange()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testSharedFormulaAbsCellListener()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+m_pDoc-InsertTab(0, Test);
+
+m_pDoc-SetValue(ScAddress(0,0,0), 1.0);
+
+const char* pData[][1] = {
+{ =$A$1 },
+{ =$A$1 },
+{ =$A$1 }
+};
+
+insertRangeData(m_pDoc, ScAddress(1,0,0), pData, SAL_N_ELEMENTS(pData));
+
+// A1 should have 3 listeners listening into it.
+const SvtBroadcaster* pBC = m_pDoc-GetBroadcaster(ScAddress(0,0,0));
+CPPUNIT_ASSERT(pBC);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(3), 
pBC-GetAllListeners().size());
+
+// Check the formula results.
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(1,0,0)));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(1,1,0)));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(1,2,0)));
+
+// Change the value of A1 and make sure B1:B3 follows.
+m_pDoc-SetValue(ScAddress(0,0,0), 2.5);
+
+CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc-GetValue(ScAddress(1,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc-GetValue(ScAddress(1,1,0)));
+CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc-GetValue(ScAddress(1,2,0)));
+
+m_pDoc-DeleteTab(0);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 52781a55441cb270ffecc2522d1e069141a21607
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Dec 11 20:52:53 2014 -0500

fdo#86572: Increment row position *only when* the row ref is relative.

This is just a simple oversight.

Change-Id: I024777c46641cce3410a20f40c48f47ad6a5dade

diff --git a/sc/source/core/tool/sharedformula.cxx 
b/sc/source/core/tool/sharedformula.cxx
index 67a40c2..b1cd80d 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -362,15 +362,18 @@ void SharedFormulaUtil::startListeningAsGroup( 
sc::StartListeningContext rCxt,
 {
 case formula::svSingleRef:
 {
-ScAddress aPos = t-GetSingleRef()-toAbs(rTopCell.aPos);
+const ScSingleRefData* pRef = t-GetSingleRef();
+ScAddress aPos = pRef-toAbs(rTopCell.aPos);
 ScFormulaCell** pp = ppSharedTop;
 ScFormulaCell** ppEnd = ppSharedTop + xGroup-mnLength;
-for (; pp != ppEnd; ++pp, aPos.IncRow())
+for (; pp != ppEnd; ++pp)
 {
 if (!aPos.IsValid())
 break;
 
 rDoc.StartListeningCell(rCxt, aPos, **pp);
+if (pRef-IsRowRel())
+aPos.IncRow();
 }
 }
 break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-12-07 Thread Markus Mohrhard
 sc/qa/unit/ucalc.hxx  |2 ++
 sc/qa/unit/ucalc_formula.cxx  |   20 
 sc/source/core/tool/token.cxx |3 +++
 3 files changed, 25 insertions(+)

New commits:
commit 664e64a1901d84137245c14ecfa9432123238bfa
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Mon Dec 8 08:21:46 2014 +0100

add test for fdo#85304

Change-Id: I35692a4a4ccfd1aa5938078bdf32a3eaff082453

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 9ab1199a..81d8788 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -149,6 +149,7 @@ public:
 void testFormulaRefUpdateNameExpandRef();
 void testFormulaRefUpdateNameDeleteRow();
 void testFormulaRefUpdateNameCopySheet();
+void testFormulaRefUpdateNameDelete();
 void testFormulaRefUpdateValidity();
 void testMultipleOperations();
 void testFuncCOLUMN();
@@ -454,6 +455,7 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateNameExpandRef);
 CPPUNIT_TEST(testFormulaRefUpdateNameDeleteRow);
 CPPUNIT_TEST(testFormulaRefUpdateNameCopySheet);
+CPPUNIT_TEST(testFormulaRefUpdateNameDelete);
 CPPUNIT_TEST(testFormulaRefUpdateValidity);
 CPPUNIT_TEST(testMultipleOperations);
 CPPUNIT_TEST(testFuncCOLUMN);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 44c78f32..5deed05 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2636,6 +2636,26 @@ void Test::testFormulaRefUpdateNameCopySheet()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFormulaRefUpdateNameDelete()
+{
+m_pDoc-InsertTab(0, Test);
+
+// Insert a new name 'MyRange' to reference B1
+bool bInserted = m_pDoc-InsertNewRangeName(MyRange, ScAddress(0,0,0), 
$Test.$B$1);
+CPPUNIT_ASSERT(bInserted);
+
+const ScRangeData* pName = 
m_pDoc-GetRangeName()-findByUpperName(MYRANGE);
+CPPUNIT_ASSERT(pName);
+
+m_pDoc-DeleteCol(1, 0, 3, 0, 0, 1);
+const ScTokenArray* pCode = pName-GetCode();
+sc::TokenStringContext aCxt(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH);
+OUString aExpr = pCode-CreateString(aCxt, ScAddress(0,0,0));
+CPPUNIT_ASSERT_EQUAL(OUString($Test.$B$1), aExpr);
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFormulaRefUpdateValidity()
 {
 struct {
commit 1de372de21f9b74c5ee736437a9875b6c90da386
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Mon Dec 8 08:05:34 2014 +0100

don't update range name if ref not in update range, fdo#85304

Change-Id: I1ccfacd98bd10f6ae1d4eaf7a705fe8863045697

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 74b30ad..f0ba930 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2955,6 +2955,9 @@ bool adjustSingleRefInName(
 return false;
 }
 
+if (!rCxt.maRange.In(rRef.toAbs(rPos)))
+return false;
+
 bool bChanged = false;
 
 if (rCxt.mnColDelta)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-11-25 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx|3 +++
 sc/qa/unit/ucalc_formula.cxx|   29 +
 sc/source/core/data/bcaslot.cxx |4 
 3 files changed, 36 insertions(+)

New commits:
commit d8266cfcd657485e1ea817376eb00c9fb2c8260f
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Nov 25 17:12:44 2014 -0500

fdo#86615: Track dependent formulas after bulk-broadcasting...

of group area listeners.

Change-Id: I3a8d2ceb57462c2c2c4cddb6e34966d2465e149b

diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 4290fbd..8a5913f 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -1204,6 +1204,7 @@ void ScBroadcastAreaSlotMachine::BulkBroadcastGroupAreas()
 
 sc::BulkDataHint aHint(*pDoc, NULL);
 
+bool bBroadcasted = false;
 BulkGroupAreasType::iterator it = maBulkGroupAreas.begin(), itEnd = 
maBulkGroupAreas.end();
 for (; it != itEnd; ++it)
 {
@@ -1213,9 +1214,12 @@ void 
ScBroadcastAreaSlotMachine::BulkBroadcastGroupAreas()
 assert(pSpans);
 aHint.setSpans(pSpans);
 pArea-GetBroadcaster().Broadcast(aHint);
+bBroadcasted = true;
 }
 
 maBulkGroupAreas.clear();
+if (bBroadcasted)
+pDoc-TrackFormulas();
 }
 
 size_t ScBroadcastAreaSlotMachine::RemoveBulkArea( const ScBroadcastArea* 
pArea )
commit 96a4189c568fbf7f63bec13f7a77a114aa7a3ede
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Nov 25 17:11:57 2014 -0500

fdo#86615: Write test for this.

Change-Id: I75412790e0afc1dbe3255254ff13fd41c5e9934b

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index e20b069..21568ed 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -204,6 +204,8 @@ public:
  */
 void testFormulaDepTracking2();
 
+void testFormulaDepTracking3();
+
 void testFormulaDepTrackingDeleteRow();
 
 void testFormulaDepTrackingDeleteCol();
@@ -491,6 +493,7 @@ public:
 CPPUNIT_TEST(testValueIterator);
 CPPUNIT_TEST(testFormulaDepTracking);
 CPPUNIT_TEST(testFormulaDepTracking2);
+CPPUNIT_TEST(testFormulaDepTracking3);
 CPPUNIT_TEST(testFormulaDepTrackingDeleteRow);
 CPPUNIT_TEST(testFormulaDepTrackingDeleteCol);
 CPPUNIT_TEST(testFormulaMatrixResultUpdate);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index b15342f..90e906b 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -4248,6 +4248,35 @@ void Test::testFormulaDepTracking2()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFormulaDepTracking3()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+m_pDoc-InsertTab(0, Formula);
+
+const char* pData[][4] = {
+{ 1, 2, =SUM(A1:B1), =SUM(C1:C3) },
+{ 3, 4, =SUM(A2:B2), 0 },
+{ 5, 6, =SUM(A3:B3), 0 },
+};
+
+insertRangeData(m_pDoc, ScAddress(0,0,0), pData, SAL_N_ELEMENTS(pData), 
true);
+
+// Check the initial formula results.
+CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc-GetValue(ScAddress(2,0,0)));
+CPPUNIT_ASSERT_EQUAL( 7.0, m_pDoc-GetValue(ScAddress(2,1,0)));
+CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc-GetValue(ScAddress(2,2,0)));
+CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc-GetValue(ScAddress(3,0,0)));
+
+// Change B3 and make sure the change gets propagated to D1.
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+rFunc.SetValueCell(ScAddress(1,2,0), 60.0, false);
+CPPUNIT_ASSERT_EQUAL(65.0, m_pDoc-GetValue(ScAddress(2,2,0)));
+CPPUNIT_ASSERT_EQUAL(75.0, m_pDoc-GetValue(ScAddress(3,0,0)));
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFormulaDepTrackingDeleteRow()
 {
 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-10-27 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx  |4 
 sc/qa/unit/ucalc_formula.cxx  |  226 ++
 sc/source/core/tool/token.cxx |   67 +++-
 3 files changed, 291 insertions(+), 6 deletions(-)

New commits:
commit 0dc61dab04507cb4b3698a1fa1ed696a123b9219
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Oct 27 07:33:38 2014 -0700

fdo#85282: Write test for this.

Change-Id: I2a0567c2872b503ceb3740127b6b58b1d1789690

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 9eaa709..0e58c18 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -133,6 +133,8 @@ public:
 void testFormulaRefUpdateMoveUndo();
 void testFormulaRefUpdateMoveToSheet();
 void testFormulaRefUpdateDeleteContent();
+void testFormulaRefUpdateDeleteAndShiftLeft();
+void testFormulaRefUpdateDeleteAndShiftUp();
 void testFormulaRefUpdateName();
 void testFormulaRefUpdateNameMove();
 void testFormulaRefUpdateNameExpandRef();
@@ -427,6 +429,8 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
 CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
 CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
+CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftLeft);
+CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftUp);
 CPPUNIT_TEST(testFormulaRefUpdateName);
 CPPUNIT_TEST(testFormulaRefUpdateNameMove);
 CPPUNIT_TEST(testFormulaRefUpdateNameExpandRef);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 5e0018a..f96c07b 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1944,6 +1944,232 @@ void Test::testFormulaRefUpdateDeleteContent()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFormulaRefUpdateDeleteAndShiftLeft()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+m_pDoc-InsertTab(0, Test);
+
+// Insert 1,2,3,4,5 in C1:G1.
+for (SCCOL i = 0; i = 4; ++i)
+m_pDoc-SetValue(ScAddress(i+2,0,0), i+1);
+
+// Insert formula in H1.
+ScAddress aPos(7,0,0);
+m_pDoc-SetString(aPos, =SUM(C1:G1));
+
+CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc-GetValue(aPos));
+
+// Delete columns D:E (middle of the reference).
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+bool bDeleted = rFunc.DeleteCells(ScRange(3,0,0,4,MAXROW,0), aMark, 
DEL_CELLSLEFT, true, true);
+CPPUNIT_ASSERT(bDeleted);
+
+aPos.IncCol(-2);
+CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc-GetValue(aPos));
+if (!checkFormula(*m_pDoc, aPos, SUM(C1:E1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Undo and check.
+SfxUndoManager* pUndo = m_pDoc-GetUndoManager();
+CPPUNIT_ASSERT(pUndo);
+
+pUndo-Undo();
+aPos.IncCol(2);
+CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc-GetValue(aPos));
+if (!checkFormula(*m_pDoc, aPos, SUM(C1:G1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Delete columns C:D (left end of the reference).
+bDeleted = rFunc.DeleteCells(ScRange(2,0,0,3,MAXROW,0), aMark, 
DEL_CELLSLEFT, true, true);
+CPPUNIT_ASSERT(bDeleted);
+
+aPos.IncCol(-2);
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc-GetValue(aPos));
+if (!checkFormula(*m_pDoc, aPos, SUM(C1:E1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Undo and check again.
+pUndo-Undo();
+aPos.IncCol(2);
+CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc-GetValue(aPos));
+if (!checkFormula(*m_pDoc, aPos, SUM(C1:G1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Delete columns B:E (overlaps on the left).
+bDeleted = rFunc.DeleteCells(ScRange(1,0,0,4,MAXROW,0), aMark, 
DEL_CELLSLEFT, true, true);
+CPPUNIT_ASSERT(bDeleted);
+
+aPos.IncCol(-4);
+CPPUNIT_ASSERT_EQUAL(9.0, m_pDoc-GetValue(aPos));
+if (!checkFormula(*m_pDoc, aPos, SUM(B1:C1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Undo and check again.
+pUndo-Undo();
+aPos.IncCol(4);
+CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc-GetValue(aPos));
+if (!checkFormula(*m_pDoc, aPos, SUM(C1:G1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Start over with a new scenario.
+clearSheet(m_pDoc, 0);
+
+// Insert 1,2,3,4,5,6 into C1:H1.
+for (SCCOL i = 0; i = 5; ++i)
+m_pDoc-SetValue(ScAddress(i+2,0,0), i+1);
+
+// Set formula in B1.
+aPos = ScAddress(1,0,0);
+m_pDoc-SetString(aPos, =SUM(C1:H1));
+CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc-GetValue(aPos));
+
+// Delete columns F:H (right end of the reference).
+bDeleted = rFunc.DeleteCells(ScRange(5,0,0,7,MAXROW,0), aMark, 
DEL_CELLSLEFT, true, true);
+CPPUNIT_ASSERT(bDeleted);
+
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(aPos));
+if (!checkFormula(*m_pDoc, aPos, SUM(C1:E1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Undo and check.
+pUndo-Undo();
+CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc-GetValue(aPos));
+if (!checkFormula(*m_pDoc, aPos, SUM(C1:H1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Delete columns G:I (overlaps on the 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-10-27 Thread Kohei Yoshida
 sc/qa/unit/ucalc_sort.cxx  |   34 +-
 sc/source/core/data/table3.cxx |   15 +++
 2 files changed, 48 insertions(+), 1 deletion(-)

New commits:
commit 0b3f0f0bad8752c2ff2a1933ced57874ee846805
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Oct 27 08:53:33 2014 -0700

fdo#85215: Write test for this.

Change-Id: I789da5d81e6211ed8f5fae1e293833bde5ce375b

diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index d0997c3..a1189dd 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -18,6 +18,7 @@
 #include scopetools.hxx
 #include globalnames.hxx
 #include dbdocfun.hxx
+#include docfunc.hxx
 #include scitems.hxx
 #include editutil.hxx
 
@@ -1430,7 +1431,38 @@ void Test::testSortRefUpdate6()
 { 9, 1, 7 },
 };
 
-bool bSuccess = checkOutput3(m_pDoc, aDataRange, aOutputCheck, 
Sorted without reference update);
+bool bSuccess = checkOutput3(m_pDoc, aDataRange, aOutputCheck, 
After redo);
+CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
+}
+
+// Change the value of C1 and make sure the formula broadcasting chain 
still works.
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+rFunc.SetValueCell(ScAddress(2,0,0), 11.0, false);
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][3] = {
+{ Order, Value, 11 },
+{ 1, 2, 13 },
+{ 8, 3, 16 },
+{ 9, 1, 17 },
+};
+
+bool bSuccess = checkOutput3(m_pDoc, aDataRange, aOutputCheck, 
Change the header value);
+CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
+}
+
+// Undo and check.
+pUndoMgr-Undo();
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][3] = {
+{ Order, Value, 1 },
+{ 1, 2, 3 },
+{ 8, 3, 6 },
+{ 9, 1, 7 },
+};
+
+bool bSuccess = checkOutput3(m_pDoc, aDataRange, aOutputCheck, 
After undo of header value change);
 CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
 }
 
commit 1eb82c78a223d9a0b2bb5c3f5c129c1ee8bdf303
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Oct 27 08:52:38 2014 -0700

fdo#85215: Ensure that formula broadcasting works after sort.

When the reference update on sort is turned off.

Change-Id: I547dd1525a638dd447fe331e22583af4a7947308

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 3e8250a..04bbbce 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -801,6 +801,15 @@ void ScTable::SortReorderByRow(
 ScSortInfoArray::RowsType* pRows = pArray-GetDataRows();
 assert(pRows); // In sort-by-row mode we must have data rows already 
populated.
 
+if (!pArray-IsUpdateRefs())
+{
+// When the update ref mode is disabled, we need to detach all formula
+// cells in the sorted range before reordering, and re-start them
+// afterward.
+sc::EndListeningContext aCxt(*pDocument);
+DetachFormulaCells(aCxt, nCol1, nRow1, nCol2, nRow2);
+}
+
 // Split formula groups at the sort range boundaries (if applicable).
 std::vectorSCROW aRowBounds;
 aRowBounds.reserve(2);
@@ -1081,6 +1090,12 @@ void ScTable::SortReorderByRow(
 // Re-group columns in the sorted range too.
 for (SCCOL i = nCol1; i = nCol2; ++i)
 aCol[i].RegroupFormulaCells();
+
+if (!pArray-IsUpdateRefs())
+{
+sc::StartListeningContext aCxt(*pDocument);
+AttachFormulaCells(aCxt, nCol1, nRow1, nCol2, nRow2);
+}
 }
 
 short ScTable::CompareCell(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-10-26 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx   |2 
 sc/qa/unit/ucalc_sort.cxx  |  108 +
 sc/source/core/data/table3.cxx |7 +-
 sc/source/ui/undo/undosort.cxx |3 -
 4 files changed, 116 insertions(+), 4 deletions(-)

New commits:
commit ae5ac4807cab26de2a149162576d2ef927cc8326
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Oct 26 14:43:47 2014 -0700

fdo#85215: Write test for this.

Change-Id: Ibe959201541ce6ad84540eba93ac9235dca91f40

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 472779c..9eaa709 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -364,6 +364,7 @@ public:
 void testSortRefUpdate3();
 void testSortRefUpdate4();
 void testSortRefUpdate5();
+void testSortRefUpdate6();
 void testSortOutOfPlaceResult();
 void testSortPartialFormulaGroup();
 
@@ -555,6 +556,7 @@ public:
 CPPUNIT_TEST(testSortRefUpdate3);
 CPPUNIT_TEST(testSortRefUpdate4);
 CPPUNIT_TEST(testSortRefUpdate5);
+CPPUNIT_TEST(testSortRefUpdate6);
 CPPUNIT_TEST(testSortOutOfPlaceResult);
 CPPUNIT_TEST(testSortPartialFormulaGroup);
 CPPUNIT_TEST(testShiftCells);
diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index ce6b9b3..d0997c3 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -1329,6 +1329,114 @@ void Test::testSortRefUpdate5()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testSortRefUpdate6()
+{
+SortRefNoUpdateSetter aUpdateSet;
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+m_pDoc-InsertTab(0, Sort);
+
+const char* aData[][3] = {
+{ Order, Value, 1 },
+{ 9, 1, =C1+B2 },
+{ 1, 2, =C2+B3 },
+{ 8, 3, =C3+B4 },
+};
+
+ScAddress aPos(0,0,0);
+ScRange aDataRange = insertRangeData(m_pDoc, aPos, aData, 
SAL_N_ELEMENTS(aData));
+CPPUNIT_ASSERT(aDataRange.aStart == aPos);
+
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][3] = {
+{ Order, Value, 1 },
+{ 9, 1, 2 },
+{ 1, 2, 4 },
+{ 8, 3, 7 },
+};
+
+bool bSuccess = checkOutput3(m_pDoc, aDataRange, aOutputCheck, 
Initial value);
+CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
+}
+
+ScDBDocFunc aFunc(getDocShell());
+
+// Sort A1:C4.
+m_pDoc-SetAnonymousDBData(
+0, new ScDBData(STR_DB_LOCAL_NONAME, 0, 0, 0, 2, 3));
+
+// Sort A1:A6 by column A (with a row header).
+ScSortParam aSortData;
+aSortData.nCol1 = 0;
+aSortData.nCol2 = 2;
+aSortData.nRow1 = 0;
+aSortData.nRow2 = 3;
+aSortData.bHasHeader = true;
+aSortData.maKeyState[0].bDoSort = true;
+aSortData.maKeyState[0].nField = 0;
+aSortData.maKeyState[0].bAscending = true;
+bool bSorted = aFunc.Sort(0, aSortData, true, true, true);
+CPPUNIT_ASSERT(bSorted);
+
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][3] = {
+{ Order, Value, 1 },
+{ 1, 2, 3 },
+{ 8, 3, 6 },
+{ 9, 1, 7 },
+};
+
+bool bSuccess = checkOutput3(m_pDoc, aDataRange, aOutputCheck, 
Sorted without reference update);
+CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
+}
+
+// Make sure that the formulas in C2:C4 are not adjusted.
+if (!checkFormula(*m_pDoc, ScAddress(2,1,0), C1+B2))
+CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(2,2,0), C2+B3))
+CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(2,3,0), C3+B4))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Undo and check.
+SfxUndoManager* pUndoMgr = m_pDoc-GetUndoManager();
+CPPUNIT_ASSERT(pUndoMgr);
+
+pUndoMgr-Undo();
+
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][3] = {
+{ Order, Value, 1 },
+{ 9, 1, 2 },
+{ 1, 2, 4 },
+{ 8, 3, 7 },
+};
+
+bool bSuccess = checkOutput3(m_pDoc, aDataRange, aOutputCheck, 
After undo);
+CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
+}
+
+// Redo and check.
+pUndoMgr-Redo();
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][3] = {
+{ Order, Value, 1 },
+{ 1, 2, 3 },
+{ 8, 3, 6 },
+{ 9, 1, 7 },
+};
+
+bool bSuccess = checkOutput3(m_pDoc, aDataRange, aOutputCheck, 
Sorted without reference update);
+CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
+}
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testSortOutOfPlaceResult()
 {
 m_pDoc-InsertTab(0, Sort);
commit 10fc138307afb4b39baddb0d56eb8e986e5d29ea
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Oct 26 14:43:14 2014 -0700

fdo#85215: 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-10-25 Thread Andras Timar
 sc/qa/unit/data/xls/external-ref.xls  |binary
 sc/qa/unit/subsequent_export-test.cxx |   22 ++
 sc/source/filter/excel/xehelper.cxx   |   10 ++
 sc/source/filter/inc/xllink.hxx   |2 +-
 4 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit 3f5251675ae56ea282fdeb09dbc53ce4aae6
Author: Andras Timar andras.ti...@collabora.com
Date:   Sat Oct 25 21:47:55 2014 +0200

bnc#893791 XLS export: external sheet references on Linux/OSX

The commit solves two problems.
1. Make sure we save absolute paths on Linux/OSX
2. Make sure we don't save invalid XLS (VirtualPath longer than 255 chars)
The first problem has always been there, so after a few load/save cycles
an XLS with reference to other XLS on a Unix-like file system became
invalid, and only LibreOffice could open it, Excel could not. These
broken XLS files can be repaired by saving after this patch, however,
the original reference will remain broken.

Change-Id: I8f575acb1d560d539c1da61a1afdaac3f0c13977

diff --git a/sc/qa/unit/data/xls/external-ref.xls 
b/sc/qa/unit/data/xls/external-ref.xls
new file mode 100644
index 000..21f3338
Binary files /dev/null and b/sc/qa/unit/data/xls/external-ref.xls differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 988ed34..ef3e8dc 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -125,6 +125,8 @@ public:
 void testPivotTableXLSX();
 void testPivotTableTwoDataFieldsXLSX();
 
+void testSupBookVirtualPath();
+
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
 #if !defined(MACOSX)  !defined(DRAGONFLY)
@@ -164,6 +166,9 @@ public:
 CPPUNIT_TEST(testPivotTableXLSX);
 CPPUNIT_TEST(testPivotTableTwoDataFieldsXLSX);
 CPPUNIT_TEST(testFunctionsExcel2010ODS);
+#if !defined(WNT)
+CPPUNIT_TEST(testSupBookVirtualPath);
+#endif
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -2272,6 +2277,23 @@ void ScExportTest::tearDown()
 test::BootstrapFixture::tearDown();
 }
 
+void ScExportTest::testSupBookVirtualPath()
+{
+ScDocShellRef xShell = loadDoc(external-ref., XLS);
+CPPUNIT_ASSERT(xShell.Is());
+
+ScDocShellRef xDocSh = saveAndReload(xShell, XLS);
+xShell-DoClose();
+CPPUNIT_ASSERT(xDocSh.Is());
+
+ScDocument rDoc = xDocSh-GetDocument();
+
+if (!checkFormula(rDoc, ScAddress(0,0,0), 
'file:///home/timar/Documents/external.xls'#$Sheet1.A1))
+CPPUNIT_FAIL(Wrong SupBook VirtualPath URL);
+
+xDocSh-DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/xehelper.cxx 
b/sc/source/filter/excel/xehelper.cxx
index 79da723..f58d192 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -908,6 +908,11 @@ OUString lclEncodeDosUrl(
 aBuf.append(EXC_URL_DOSDRIVE).append(cDrive);
 aOldUrl = aOldUrl.copy(3);
 }
+else
+{
+// URL probably points to a document on a Unix-like file system
+aBuf.append(EXC_URL_DRIVEROOT);
+}
 
 // directories
 sal_Int32 nPos = -1;
@@ -949,6 +954,11 @@ OUString lclEncodeDosUrl(
 if (pTableName)
 aBuf.append(*pTableName);
 
+// VirtualPath must be shorter than 255 chars ([MS-XLS].pdf 2.5.277)
+// It's better to truncate, than generate invalid file that Excel cannot 
open.
+if (aBuf.getLength()  255)
+aBuf.setLength(255);
+
 return aBuf.makeStringAndClear();
 }
 
commit 863bed8dd4414e995eb59e868edc4ac94a085b34
Author: Andras Timar andras.ti...@collabora.com
Date:   Sat Oct 25 17:25:08 2014 +0200

typo: uesd - used

Change-Id: I827f9a0889aca4a55586cdd2baa21846b1bc155b

diff --git a/sc/source/filter/inc/xllink.hxx b/sc/source/filter/inc/xllink.hxx
index 1eccffb..08cbb27 100644
--- a/sc/source/filter/inc/xllink.hxx
+++ b/sc/source/filter/inc/xllink.hxx
@@ -76,7 +76,7 @@ enum XclSupbookType
 EXC_SBTYPE_EXTERN,  /// SUPBOOK is used for external references.
 EXC_SBTYPE_ADDIN,   /// SUPBOOK contains add-in functions.
 EXC_SBTYPE_SPECIAL, /// SUPBOOK is used for DDE or OLE links.
-EXC_SBTYPE_EUROTOOL /// SUPBOOK is uesd for EUROCONVERT.
+EXC_SBTYPE_EUROTOOL /// SUPBOOK is used for EUROCONVERT.
 };
 
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-10-17 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx   |3 +
 sc/qa/unit/ucalc_formula.cxx   |  114 +
 sc/source/core/data/table2.cxx |7 --
 3 files changed, 119 insertions(+), 5 deletions(-)

New commits:
commit 7fef943114b9184e69c8c714bf158116b8d9caf7
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Oct 17 21:48:31 2014 -0400

fdo#80284: Avoid broadcasting during cell delete  shift.

Broadcasting it here and marking formula cells dirty prevents them
from being entered into the formula tree at the end.  They get marked
postponed dirty during reference update, and are supposed to be
set dirty at the end.

Change-Id: I65977300ee4ee26b6166d170acd2145abcbbf288

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 2aa91d0..fdbc463 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -383,11 +383,8 @@ void ScTable::DeleteCol(
 }
 }
 
-{   // scope for bulk broadcast
-ScBulkBroadcast aBulkBroadcast( pDocument-GetBASM());
-for (SCSIZE i = 0; i  nSize; i++)
-aCol[nStartCol + i].DeleteArea(nStartRow, nEndRow, IDF_ALL);
-}
+for (SCSIZE i = 0; i  nSize; i++)
+aCol[nStartCol + i].DeleteArea(nStartRow, nEndRow, IDF_ALL, false);
 
 if ((nStartRow == 0)  (nEndRow == MAXROW))
 {
commit f961771e31be34065d210574866c6811fc0288fd
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Oct 17 19:50:26 2014 -0400

fdo#80284: Write test for this first.

Change-Id: I2fe455fc627e4b358507b58f08a3198ac62edad0

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index d7f85f0..0053646 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -184,6 +184,8 @@ public:
 
 void testFormulaDepTrackingDeleteRow();
 
+void testFormulaDepTrackingDeleteCol();
+
 void testFormulaMatrixResultUpdate();
 
 /**
@@ -461,6 +463,7 @@ public:
 CPPUNIT_TEST(testFormulaDepTracking);
 CPPUNIT_TEST(testFormulaDepTracking2);
 CPPUNIT_TEST(testFormulaDepTrackingDeleteRow);
+CPPUNIT_TEST(testFormulaDepTrackingDeleteCol);
 CPPUNIT_TEST(testFormulaMatrixResultUpdate);
 CPPUNIT_TEST(testCellBroadcaster);
 CPPUNIT_TEST(testFuncParam);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 713abe3..84d34e0 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -4001,6 +4001,120 @@ void Test::testFormulaDepTrackingDeleteRow()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFormulaDepTrackingDeleteCol()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+m_pDoc-InsertTab(0, Formula);
+
+const char* aData[][3] = {
+{ 2, =A1, =B1 }, // not grouped
+{ 0, 0, 0 },   // empty row to separate the formula groups.
+{ 3, =A3, =B3 }, // grouped
+{ 4, =A4, =B4 }, // grouped
+};
+
+ScAddress aPos(0,0,0);
+ScRange aRange = insertRangeData(m_pDoc, aPos, aData, 
SAL_N_ELEMENTS(aData));
+CPPUNIT_ASSERT(aRange.aStart == aPos);
+
+// Check the initial values.
+for (SCCOL i = 0; i = 2; ++i)
+{
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc-GetValue(ScAddress(i,0,0)));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc-GetValue(ScAddress(i,2,0)));
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc-GetValue(ScAddress(i,3,0)));
+}
+
+// Make sure B3:B4 and C3:C4 are grouped.
+const ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(1,2,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(2), pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(2), pFC-GetSharedLength());
+
+pFC = m_pDoc-GetFormulaCell(ScAddress(2,2,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(2), pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(2), pFC-GetSharedLength());
+
+// Delete column A.  A1, B1, A3:A4 and B3:B4 should all show #REF!.
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+rFunc.DeleteCells(ScRange(0,0,0,0,MAXROW,0), aMark, DEL_CELLSLEFT, true, 
true);
+
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][2] = {
+{ #REF!, #REF! },
+{ 0,  0 },
+{ #REF!, #REF! },
+{ #REF!, #REF! },
+};
+
+ScRange aCheckRange(0,0,0,1,3,0);
+bool bSuccess = checkOutput2(m_pDoc, aCheckRange, aOutputCheck, 
Check after deleting column A);
+CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
+}
+
+// Undo and check the result.
+SfxUndoManager* pUndoMgr = m_pDoc-GetUndoManager();
+CPPUNIT_ASSERT(pUndoMgr);
+pUndoMgr-Undo();
+
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][3] = {
+{ 2, 2, 2 },
+{ 0,  0, 0 },
+{ 3, 3, 3 },
+   

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-10-16 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx |   21 ++
 sc/source/core/tool/interpr1.cxx |   55 +++
 2 files changed, 54 insertions(+), 22 deletions(-)

New commits:
commit 51b215902d8e1f415b5fef49fc50c7167f0c7787
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Oct 16 20:49:42 2014 -0400

fdo#73080: Fix the single cell reference cases as well.

Change-Id: Ib9a8ae04733c5bcb982ef4d337112eb8249d0ee0

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 44c3ea6..d5dcb8e 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4510,12 +4510,39 @@ void ScInterpreter::ScMatch()
 }
 }
 
+namespace {
+
+bool isCellContentEmpty( const ScRefCellValue rCell )
+{
+switch (rCell.meType)
+{
+case CELLTYPE_VALUE:
+case CELLTYPE_STRING:
+case CELLTYPE_EDIT:
+return false;
+case CELLTYPE_FORMULA:
+{
+sc::FormulaResultValue aRes = rCell.mpFormula-GetResult();
+if (aRes.meType != sc::FormulaResultValue::String)
+return false;
+if (!aRes.maString.isEmpty())
+return false;
+}
+break;
+default:
+;
+}
+
+return true;
+}
+
+}
+
 void ScInterpreter::ScCountEmptyCells()
 {
 if ( MustHaveParamCount( GetByte(), 1 ) )
 {
 sal_uLong nMaxCount = 0, nCount = 0;
-CellType eCellType;
 switch (GetStackType())
 {
 case svSingleRef :
@@ -4523,8 +4550,9 @@ void ScInterpreter::ScCountEmptyCells()
 nMaxCount = 1;
 ScAddress aAdr;
 PopSingleRef( aAdr );
-eCellType = pDok-GetCellType(aAdr);
-if (eCellType != CELLTYPE_NONE)
+ScRefCellValue aCell;
+aCell.assign(*pDok, aAdr);
+if (!isCellContentEmpty(aCell))
 nCount = 1;
 }
 break;
@@ -4546,25 +4574,8 @@ void ScInterpreter::ScCountEmptyCells()
 for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
 {
 const ScRefCellValue rCell = aIter.getRefCellValue();
-switch (rCell.meType)
-{
-case CELLTYPE_VALUE:
-case CELLTYPE_STRING:
-case CELLTYPE_EDIT:
-++nCount;
-break;
-case CELLTYPE_FORMULA:
-{
-sc::FormulaResultValue aRes = 
rCell.mpFormula-GetResult();
-if (aRes.meType != 
sc::FormulaResultValue::String)
-++nCount;
-else if (!aRes.maString.isEmpty())
-++nCount;
-}
-break;
-default:
-;
-}
+if (!isCellContentEmpty(rCell))
+++nCount;
 }
 }
 }
commit 9d8f1795836f58cb275eae19818eb25ee80901a0
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Oct 16 20:49:07 2014 -0400

fdo#73080: Write another test case for single cell reference cases.

Change-Id: I8dff6850c7088b483d1ad669867da6cef454d9a2

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 5c5d6b0..afa1261 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2538,6 +2538,27 @@ void Test::testFuncCOUNTBLANK()
 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc-GetValue(ScAddress(2,5,0)));
 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(3,5,0)));
 
+// Test single cell reference cases.
+
+clearSheet(m_pDoc, 0);
+
+const char* aData2[][2] = {
+{ 1, =COUNTBLANK(A1) },
+{ A, =COUNTBLANK(A2) },
+{   0, =COUNTBLANK(A3) },
+{ =\\, =COUNTBLANK(A4) },
+{ =A4  , =COUNTBLANK(A5) },
+};
+
+aRange = insertRangeData(m_pDoc, aPos, aData2, SAL_N_ELEMENTS(aData2));
+CPPUNIT_ASSERT(aRange.aStart == aPos);
+
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc-GetValue(ScAddress(1,0,0)));
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc-GetValue(ScAddress(1,1,0)));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(1,2,0)));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(1,3,0)));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(1,4,0)));
+
 m_pDoc-DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-10-15 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx |2 ++
 sc/qa/unit/ucalc_formula.cxx |   26 ++
 sc/source/core/tool/interpr1.cxx |   22 --
 3 files changed, 48 insertions(+), 2 deletions(-)

New commits:
commit 3e2bd1e4022e25b77bcc8eba5e02c1adc57008a1
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Wed Oct 15 20:07:33 2014 -0400

fdo#73080: Correctly count blank cells in COUNTBLANK.

Especially when formula cells are involved.

Change-Id: I40950e7108778821c17d08354f01bb157b1551e6

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 358dab0..44c3ea6 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4545,8 +4545,26 @@ void ScInterpreter::ScCountEmptyCells()
 ScCellIterator aIter( pDok, aRange, mnSubTotalFlags);
 for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
 {
-if (!aIter.hasEmptyData())
-++nCount;
+const ScRefCellValue rCell = aIter.getRefCellValue();
+switch (rCell.meType)
+{
+case CELLTYPE_VALUE:
+case CELLTYPE_STRING:
+case CELLTYPE_EDIT:
+++nCount;
+break;
+case CELLTYPE_FORMULA:
+{
+sc::FormulaResultValue aRes = 
rCell.mpFormula-GetResult();
+if (aRes.meType != 
sc::FormulaResultValue::String)
+++nCount;
+else if (!aRes.maString.isEmpty())
+++nCount;
+}
+break;
+default:
+;
+}
 }
 }
 }
commit 27a2e19ed2c3203c9d63873796d7c9ec2f58dd3d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Wed Oct 15 20:06:45 2014 -0400

fdo#73080: Write test for this first.

Change-Id: Ia2a32f4be3ef2c09ac68fe03ee9a7c9d31aef7ed

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 259d0a2..d7f85f0 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -140,6 +140,7 @@ public:
 void testMultipleOperations();
 void testFuncCOLUMN();
 void testFuncCOUNT();
+void testFuncCOUNTBLANK();
 void testFuncROW();
 void testFuncSUM();
 void testFuncPRODUCT();
@@ -429,6 +430,7 @@ public:
 CPPUNIT_TEST(testMultipleOperations);
 CPPUNIT_TEST(testFuncCOLUMN);
 CPPUNIT_TEST(testFuncCOUNT);
+CPPUNIT_TEST(testFuncCOUNTBLANK);
 CPPUNIT_TEST(testFuncROW);
 CPPUNIT_TEST(testFuncSUM);
 CPPUNIT_TEST(testFuncPRODUCT);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 45112d1..5c5d6b0 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2515,6 +2515,32 @@ void Test::testFuncCOUNT()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFuncCOUNTBLANK()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+m_pDoc-InsertTab(0, Formula);
+
+const char* aData[][4] = {
+{ 1, 0, =B1, =\\ },
+{ 2, 0, =B2, =\\ },
+{ A, 0, =B3, =\\ },
+{ B, 0, =B4, =D3 },
+{   0, 0, =B5, =D4 },
+{ =COUNTBLANK(A1:A5), =COUNTBLANK(B1:B5), =COUNTBLANK(C1:C5), 
=COUNTBLANK(D1:D5) }
+};
+
+ScAddress aPos(0,0,0);
+ScRange aRange = insertRangeData(m_pDoc, aPos, aData, 
SAL_N_ELEMENTS(aData));
+CPPUNIT_ASSERT(aRange.aStart == aPos);
+
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(0,5,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(1,5,0)));
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc-GetValue(ScAddress(2,5,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(3,5,0)));
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFuncROW()
 {
 m_pDoc-InsertTab(0, Formula);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-10-12 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx|   32 
 sc/source/core/data/column.cxx  |6 ++
 sc/source/core/data/formulacell.cxx |2 +-
 3 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 352958b7c6bbfeb8352570b28487cc1713f5a850
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Oct 12 10:19:49 2014 -0400

fdo#83901: Write a test for this.

Change-Id: If805ba07baa36cbf94ee22f77f98ef4057d8b306

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index d4344e2..45112d1 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2541,6 +2541,38 @@ void Test::testFuncROW()
 // The cell that references the moved cell should update its value as well.
 CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc-GetValue(ScAddress(0,1,0)));
 
+// Clear sheet and start over.
+clearSheet(m_pDoc, 0);
+
+m_pDoc-SetString(ScAddress(0,1,0), =ROW(A5));
+m_pDoc-SetString(ScAddress(1,1,0), =ROW(B5));
+m_pDoc-SetString(ScAddress(1,2,0), =ROW(B6));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(1,1,0)));
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(1,2,0)));
+
+// B2:B3 should be shared.
+const ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(1,1,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(1), pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(2), pFC-GetSharedLength());
+
+// Insert a new row at row 4.
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+rFunc.InsertCells(ScRange(0,3,0,MAXCOL,3,0), aMark, INS_INSROWS, false, 
true, false);
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), ROW(A6)))
+CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(1,1,0), ROW(B6)))
+CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(1,2,0), ROW(B7)))
+CPPUNIT_FAIL(Wrong formula!);
+
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(1,1,0)));
+CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc-GetValue(ScAddress(1,2,0)));
+
 m_pDoc-DeleteTab(0);
 }
 
commit 0b29a16d1dcffd75e49bd7ad3da867b0d0ebfa38
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Oct 12 10:18:09 2014 -0400

fdo#83901: ROW() and COLUMN() to be properly recalculated on cell move.

For cases where ROW or COLUMN references another cell that has shifted.

Change-Id: Ic4bef8672dab811ceff6886d9af0388306a66485

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d6152dd..521b942 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2044,6 +2044,12 @@ class UpdateRefOnNonCopy : 
std::unary_functionsc::FormulaGroupEntry, void
 if (pCode-IsRecalcModeOnRefMove())
 aRes.mbValueChanged = true;
 }
+else if (aRes.mbReferenceModified  pCode-IsRecalcModeOnRefMove())
+{
+// The cell itself hasn't shifted. But it may have ROW or COLUMN
+// referencing another cell that has.
+aRes.mbValueChanged = true;
+}
 
 if (aRes.mbNameModified)
 recompileTokenArray(*pTop);
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 8cd9598..33f64e9 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2788,7 +2788,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 
 if (bOnRefMove)
 // Cell may reference itself, e.g. ocColumn, ocRow without parameter
-bOnRefMove = (bValChanged || (aPos != aOldPos));
+bOnRefMove = (bValChanged || (aPos != aOldPos) || bRefModified);
 
 bool bNewListening = false;
 bool bInDeleteUndo = false;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-09-19 Thread Kohei Yoshida
 sc/qa/unit/ucalc_sort.cxx  |   18 ++
 sc/source/ui/docshell/dbdocfun.cxx |1 +
 2 files changed, 11 insertions(+), 8 deletions(-)

New commits:
commit 8af25862f1782ff1fb0f66415e3a2d624f61d737
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Sep 19 09:12:00 2014 -0400

fdo#84009: Adjust the test case to catch this.

Change-Id: I16bdc6760276b5bc0c78c3693d3f92c68ef67ed1

diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index 95a5e42..f81a394 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -1320,6 +1320,7 @@ void Test::testSortRefUpdate5()
 void Test::testSortOutOfPlaceResult()
 {
 m_pDoc-InsertTab(0, Sort);
+m_pDoc-InsertTab(1, Result);
 
 const char* pData[] = {
 Header,
@@ -1356,7 +1357,7 @@ void Test::testSortOutOfPlaceResult()
 aSortData.nRow2 = 5;
 aSortData.bHasHeader = true;
 aSortData.bInplace = false;
-aSortData.nDestTab = 0;
+aSortData.nDestTab = 1;
 aSortData.nDestCol = 2;
 aSortData.nDestRow = 1;
 aSortData.maKeyState[0].bDoSort = true;
@@ -1373,14 +1374,15 @@ void Test::testSortOutOfPlaceResult()
 CPPUNIT_ASSERT_EQUAL( 9.0, m_pDoc-GetValue(ScAddress(0,4,0)));
 CPPUNIT_ASSERT_EQUAL(-2.0, m_pDoc-GetValue(ScAddress(0,5,0)));
 
-// Sort result in C2:C7.
-CPPUNIT_ASSERT_EQUAL(OUString(Header), 
m_pDoc-GetString(ScAddress(2,1,0)));
-CPPUNIT_ASSERT_EQUAL(-2.0, m_pDoc-GetValue(ScAddress(2,2,0)));
-CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc-GetValue(ScAddress(2,3,0)));
-CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc-GetValue(ScAddress(2,4,0)));
-CPPUNIT_ASSERT_EQUAL( 9.0, m_pDoc-GetValue(ScAddress(2,5,0)));
-CPPUNIT_ASSERT_EQUAL(23.0, m_pDoc-GetValue(ScAddress(2,6,0)));
+// Sort result in C2:C7 on sheet Result.
+CPPUNIT_ASSERT_EQUAL(OUString(Header), 
m_pDoc-GetString(ScAddress(2,1,1)));
+CPPUNIT_ASSERT_EQUAL(-2.0, m_pDoc-GetValue(ScAddress(2,2,1)));
+CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc-GetValue(ScAddress(2,3,1)));
+CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc-GetValue(ScAddress(2,4,1)));
+CPPUNIT_ASSERT_EQUAL( 9.0, m_pDoc-GetValue(ScAddress(2,5,1)));
+CPPUNIT_ASSERT_EQUAL(23.0, m_pDoc-GetValue(ScAddress(2,6,1)));
 
+m_pDoc-DeleteTab(1);
 m_pDoc-DeleteTab(0);
 }
 
commit 5fd4679e7b92f344ea867e0dca1fc4c9363ae2cd
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Sep 19 09:11:09 2014 -0400

fdo#84009: Be sure to update the sheet index when moving the sort range.

Change-Id: Ic9ad51b33f6dfb6f90e76439c27eeff25ec4c7da

diff --git a/sc/source/ui/docshell/dbdocfun.cxx 
b/sc/source/ui/docshell/dbdocfun.cxx
index 7f30a02..fe843b5 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -499,6 +499,7 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam 
rSortParam,
 return false;
 
 aLocalParam.MoveToDest();
+nTab = aLocalParam.nDestTab;
 }
 
 ScEditableTester aTester( rDoc, nTab, aLocalParam.nCol1,aLocalParam.nRow1,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-08-18 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |   18 ++
 sc/source/filter/excel/excrecds.cxx   |5 +++--
 2 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 3104f95254530c76c3fc0c3b840254912c067ad8
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Aug 18 15:16:19 2014 -0400

Let's not export sheet tab color when it's not set.

COL_AUTO is the default value which is treated as color not being set.  The
old code would export it as a white color which is not correct.

Change-Id: Ib68fccfb228333f2059edc4cfffeed90880ebc60

diff --git a/sc/source/filter/excel/excrecds.cxx 
b/sc/source/filter/excel/excrecds.cxx
index 0ea43ff..d911c19 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -424,8 +424,9 @@ void XclExpXmlSheetPr::SaveXml( XclExpXmlStream rStrm )
 
 // OOXTODO: XML_outlinePr
 
-rWorksheet-singleElement(
-XML_tabColor, XML_rgb, XclXmlUtils::ToOString(maTabColor).getStr(), 
FSEND);
+if (maTabColor != Color(COL_AUTO))
+rWorksheet-singleElement(
+XML_tabColor, XML_rgb, 
XclXmlUtils::ToOString(maTabColor).getStr(), FSEND);
 
 rWorksheet-singleElement(XML_pageSetUpPr,
 // OOXTODO: XML_autoPageBreaks,
commit ead1db7d4907ff70d412701f08b9c74481cef0bc
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Aug 18 15:15:03 2014 -0400

Write test to ensure that we export sheet tab color settings correctly.

Previously, we would incorrectly export a sheet tab without any color set
as a tab with white color.

Change-Id: I97e59a0d8e2fba6db64149f53acfe4331a5ce2ba

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 466ca67..8d9a67a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -1757,6 +1757,24 @@ void ScExportTest::testSharedFormulaExportXLSX()
 {
 bool checkContent( ScDocument rDoc )
 {
+SCTAB nTabCount = rDoc.GetTableCount();
+if (nTabCount != 2)
+{
+cerr  Document should have exactly 2 sheets.
nTabCount   found.  endl;
+return false;
+}
+
+// Make sure the sheet tab colors are not set.
+for (SCROW i = 0; i = 1; ++i)
+{
+Color aTabBgColor = rDoc.GetTabBgColor(i);
+if (aTabBgColor != Color(COL_AUTO))
+{
+cerr  The tab color of Sheet   (i+1)   should not 
be explicitly set.  endl;
+return false;
+}
+}
+
 // B2:B7 should show 1,2,3,4,5,6.
 double fExpected = 1.0;
 for (SCROW i = 1; i = 6; ++i, ++fExpected)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-08-15 Thread Markus Mohrhard
 sc/qa/unit/ucalc.cxx   |   34 ++
 sc/qa/unit/ucalc.hxx   |2 ++
 sc/source/core/data/document10.cxx |5 +
 3 files changed, 41 insertions(+)

New commits:
commit 17f6f60c1c20782fb1cde69b949b97c2f3b0d830
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Sat Aug 16 03:13:38 2014 +0200

add test case for fdo#82503

Change-Id: I715f8b2c09bd6af2cf1f45029f0561d79817deed

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 20b7ba7..644f7fb 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6864,6 +6864,40 @@ void Test::testCondCopyPaste()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testCondCopyPasteSingleCell()
+{
+m_pDoc-InsertTab(0, Test);
+
+ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+ScRange aCondFormatRange(0,0,0,3,3,0);
+ScRangeList aRangeList(aCondFormatRange);
+pFormat-AddRange(aRangeList);
+
+ScCondFormatEntry* pEntry = new 
ScCondFormatEntry(SC_COND_DIRECT,=B2,,m_pDoc,ScAddress(0,0,0),ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+pFormat-AddEntry(pEntry);
+sal_uLong nIndex = m_pDoc-AddCondFormat(pFormat, 0);
+
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+copyToClip(m_pDoc, ScRange(0,0,0,0,0,0), aClipDoc);
+
+ScRange aTargetRange(4,4,0,4,4,0);
+pasteFromClip(m_pDoc, aTargetRange, aClipDoc);
+
+ScConditionalFormat* pPastedFormat = m_pDoc-GetCondFormat(4,4,0);
+CPPUNIT_ASSERT(pPastedFormat);
+
+CPPUNIT_ASSERT_EQUAL(ScRangeList(aTargetRange), pPastedFormat-GetRange());
+CPPUNIT_ASSERT( nIndex != pPastedFormat-GetKey());
+const SfxPoolItem* pItem = m_pDoc-GetAttr( 4, 4, 0, ATTR_CONDITIONAL );
+const ScCondFormatItem* pCondFormatItem = static_castconst 
ScCondFormatItem*(pItem);
+
+CPPUNIT_ASSERT(pCondFormatItem);
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
pCondFormatItem-GetCondFormatData().size());
+CPPUNIT_ASSERT( nIndex != pCondFormatItem-GetCondFormatData().at(0) );
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testIconSet()
 {
 m_pDoc-InsertTab(0, Test);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 80c46bf..5c03a70 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -374,6 +374,7 @@ public:
 void testCondFormatInsertCol();
 void testCondFormatInsertDeleteSheets();
 void testCondCopyPaste();
+void testCondCopyPasteSingleCell(); //e.g. fdo#82503
 void testIconSet();
 
 void testImportStream();
@@ -552,6 +553,7 @@ public:
 CPPUNIT_TEST(testCondFormatInsertCol);
 CPPUNIT_TEST(testCondFormatInsertDeleteSheets);
 CPPUNIT_TEST(testCondCopyPaste);
+CPPUNIT_TEST(testCondCopyPasteSingleCell);
 CPPUNIT_TEST(testIconSet);
 CPPUNIT_TEST(testImportStream);
 CPPUNIT_TEST(testDeleteContents);
commit 8c9014cc6e5a502f5719f17c111c29448d4d6f6b
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Sat Aug 16 03:07:07 2014 +0200

copy conditional formatting for single cells, fdo#82503

Change-Id: I22f239fbbbfa3ac562b860efb990dff10d0e0e24

diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index 49db92e..983e794 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -203,7 +203,12 @@ bool ScDocument::CopyOneCellFromClip(
 
 SCTAB nTabEnd = rCxt.getTabEnd();
 for (SCTAB i = rCxt.getTabStart(); i = nTabEnd  i  
static_castSCTAB(maTabs.size()); ++i)
+{
 maTabs[i]-CopyOneCellFromClip(rCxt, nCol1, nRow1, nCol2, nRow2);
+if (rCxt.getInsertFlag()  IDF_ATTRIB)
+maTabs[i]-CopyConditionalFormat(nCol1, nRow1, nCol2, nRow2, nCol1 
- aClipRange.aStart.Col(),
+nRow1 - aClipRange.aStart.Row(), pSrcTab);
+}
 
 return true;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-07-29 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx  |   42 ++
 sc/qa/unit/ucalc.hxx  |2 ++
 sc/source/core/tool/token.cxx |5 +
 3 files changed, 49 insertions(+)

New commits:
commit 5e55d5ffb70437e917e4092f4030d5a454fd20d6
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Jul 29 22:33:56 2014 -0400

fdo#81330: When moving to a different sheet, set 3D flag on.

Change-Id: I16c6e687259635c4d0ac0e5dab0140941b409bc8

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 99a26a8..569834a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2812,6 +2812,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 ScRange aOldRange = rCxt.maRange;
 aOldRange.Move(-rCxt.mnColDelta, -rCxt.mnRowDelta, -rCxt.mnTabDelta);
 
+bool b3DFlag = rOldPos.Tab() != rNewPos.Tab();
+
 FormulaToken** p = pCode;
 FormulaToken** pEnd = p + static_castsize_t(nLen);
 for (; p != pEnd; ++p)
@@ -2830,6 +2832,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 }
 
 rRef.SetAddress(aAbs, rNewPos);
+rRef.SetFlag3D(b3DFlag);
 }
 break;
 case svDoubleRef:
@@ -2844,6 +2847,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 }
 
 rRef.SetRange(aAbs, rNewPos);
+if (b3DFlag)
+rRef.Ref1.SetFlag3D(true);
 }
 break;
 case svIndex:
commit 6a816d1fdd63532c3a85ee9e7fe20040ee754f1a
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Jul 29 21:19:29 2014 -0400

fdo#81330: Write test for this.

Change-Id: Id781b13b180c0622bfb01cf2ca844fa452061b50

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bbed0c7..02950cf 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3942,6 +3942,48 @@ void Test::testCutPasteRefUndo()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testMoveRefBetweenSheets()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+m_pDoc-InsertTab(0, Test1);
+m_pDoc-InsertTab(1, Test2);
+
+m_pDoc-SetValue(ScAddress(0,0,0), 12.0);
+m_pDoc-SetValue(ScAddress(1,0,0), 10.0);
+m_pDoc-SetValue(ScAddress(2,0,0),  8.0);
+m_pDoc-SetString(ScAddress(0,1,0), =A1);
+m_pDoc-SetString(ScAddress(0,2,0), =SUM(A1:C1));
+
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc-GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc-GetValue(ScAddress(0,2,0)));
+
+// These formulas should not display the sheet name.
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), A1))
+CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(0,2,0), SUM(A1:C1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+// Move Test1.A2:A3 to Test2.A2:A3.
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+bool bMoved = rFunc.MoveBlock(ScRange(0,1,0,0,2,0), ScAddress(0,1,1), 
true, true, false, true);
+CPPUNIT_ASSERT(bMoved);
+
+CPPUNIT_ASSERT_MESSAGE(This cell should be empty after the move., 
m_pDoc-GetCellType(ScAddress(0,1,0)) == CELLTYPE_NONE);
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc-GetValue(ScAddress(0,1,1)));
+CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc-GetValue(ScAddress(0,2,1)));
+
+// The reference in the pasted formula should display sheet name after the 
move.
+if (!checkFormula(*m_pDoc, ScAddress(0,1,1), Test1.A1))
+CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(0,2,1), SUM(Test1.A1:C1)))
+CPPUNIT_FAIL(Wrong formula!);
+
+m_pDoc-DeleteTab(1);
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testUndoCut()
 {
 m_pDoc-InsertTab(0, Test);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index cf3d0d5..471cf82 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -280,6 +280,7 @@ public:
 void testCopyPasteSkipEmpty2();
 void testCopyPasteSkipEmptyConditionalFormatting();
 void testCutPasteRefUndo();
+void testMoveRefBetweenSheets();
 void testUndoCut();
 void testMoveBlock();
 void testCopyPasteRelativeFormula();
@@ -487,6 +488,7 @@ public:
 CPPUNIT_TEST(testCopyPasteSkipEmpty2);
 //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
 CPPUNIT_TEST(testCutPasteRefUndo);
+CPPUNIT_TEST(testMoveRefBetweenSheets);
 CPPUNIT_TEST(testUndoCut);
 CPPUNIT_TEST(testMoveBlock);
 CPPUNIT_TEST(testCopyPasteRelativeFormula);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-27 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx   |   43 +
 sc/qa/unit/ucalc.hxx   |2 +
 sc/source/core/data/column.cxx |2 -
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 054213e86b8f3b1084474b0447cc7ffaf82178c5
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 27 14:47:24 2014 -0400

fdo#78976: Correct way to determine the end position for matrix check.

Change-Id: Ifd6acd85a9bf33742cb62327a3b8a4320f35d0f3

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 485f5e8..7d6ebb1 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -154,7 +154,7 @@ sal_uInt16 ScColumn::GetBlockMatrixEdges( SCROW nRow1, 
SCROW nRow2, sal_uInt16 n
 }
 
 size_t nRowsToRead = nRow2 - nRow + 1;
-size_t nEnd = std::min(it-size, nRowsToRead);
+size_t nEnd = std::min(it-size, nOffset+nRowsToRead); // last row + 1
 sc::formula_block::const_iterator itCell = 
sc::formula_block::begin(*it-data);
 std::advance(itCell, nOffset);
 for (size_t i = nOffset; i  nEnd; ++itCell, ++i)
commit 175519643daa87ba3e65eb4b52df3c8a2f60ac64
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 27 14:47:05 2014 -0400

fdo#78976: Test for this.

Change-Id: I454e29c2cdf0857d329d84000d79973489cebb41

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index aa7ac1a..3396446 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -64,6 +64,8 @@
 #include globalnames.hxx
 #include inputopt.hxx
 
+#include editable.hxx
+
 #include formula/IFunctionDescription.hxx
 
 #include basegfx/polygon/b2dpolygon.hxx
@@ -2196,6 +2198,47 @@ void Test::testEnterMixedMatrix()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testMatrixEditable()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+m_pDoc-InsertTab(0, Test);
+
+// Values in A1:B1.
+m_pDoc-SetValue(ScAddress(0,0,0), 1.0);
+m_pDoc-SetValue(ScAddress(1,0,0), 2.0);
+
+// A2 is a normal formula.
+m_pDoc-SetString(ScAddress(0,1,0), =5);
+
+// A3:A4 is a matrix.
+ScRange aMatRange(0,2,0,0,3,0);
+ScMarkData aMark;
+aMark.SetMarkArea(aMatRange);
+m_pDoc-InsertMatrixFormula(0, 2, 0, 3, aMark, =TRANSPOSE(A1:B1), NULL);
+
+// Check their values.
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc-GetValue(ScAddress(0,3,0)));
+
+// Make sure A3:A4 is a matrix.
+ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(0,2,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_MESSAGE(A3 should be matrix origin., pFC-GetMatrixFlag() 
== MM_FORMULA);
+
+pFC = m_pDoc-GetFormulaCell(ScAddress(0,3,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_MESSAGE(A4 should be matrix reference., 
pFC-GetMatrixFlag() == MM_REFERENCE);
+
+// Check to make sure A3:A4 combined is editable.
+ScEditableTester aTester;
+aTester.TestSelection(m_pDoc, aMark);
+CPPUNIT_ASSERT(aTester.IsEditable());
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testCellCopy()
 {
 m_pDoc-InsertTab(0, TestTab);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 39862ee..73181ee 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -195,6 +195,7 @@ public:
 void testCSV();
 void testMatrix();
 void testEnterMixedMatrix();
+void testMatrixEditable();
 
 /**
  * Basic test for pivot tables.
@@ -442,6 +443,7 @@ public:
 CPPUNIT_TEST(testCSV);
 CPPUNIT_TEST(testMatrix);
 CPPUNIT_TEST(testEnterMixedMatrix);
+CPPUNIT_TEST(testMatrixEditable);
 CPPUNIT_TEST(testPivotTable);
 CPPUNIT_TEST(testPivotTableLabels);
 CPPUNIT_TEST(testPivotTableDateLabels);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-22 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   57 
 sc/qa/unit/ucalc.hxx|3 ++
 sc/source/core/data/column3.cxx |   22 ---
 3 files changed, 60 insertions(+), 22 deletions(-)

New commits:
commit cb167ac784f9b16944da4494b65e56b2a5b66bb7
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu May 22 20:56:04 2014 -0400

fdo#78903: Don't broadcast prematurely during cell deletion.

We need to wait until all the affected cells get marked dirty at the
end of the deletion process.

Change-Id: I49618fcc386ec2209f5f0267d50257ecb8dd21d1

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 3d447d1..2d54fd5 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -169,11 +169,6 @@ public:
 maRows.push_back(i + nTopRow);
 }
 
-void endFormulas()
-{
-mrDoc.EndListeningFormulaCells(maFormulaCells);
-}
-
 const std::vectorSCROW getNonEmptyRows() const
 {
 return maRows;
@@ -266,12 +261,6 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
 
 sc::AutoCalcSwitch aACSwitch(*pDocument, false);
 
-// Parse all non-empty cells in the range to pick up their row positions,
-// and end all formula cells.
-DeleteRowsHandler aDeleteRowsFunc(*pDocument);
-sc::ProcessFormula(itCell, maCells, nStartRow, nEndRow, aDeleteRowsFunc, 
aDeleteRowsFunc);
-aDeleteRowsFunc.endFormulas();
-
 // Remove the cells.
 maCells.erase(nStartRow, nEndRow);
 maCells.resize(MAXROWCOUNT);
@@ -285,22 +274,11 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
 
 sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
 
-// Single cell broadcasts on deleted cells.
-BroadcastCells(aDeleteRowsFunc.getNonEmptyRows(), SC_HINT_DATACHANGED);
-
 // Shift the text attribute array too (before the broadcast).
 maCellTextAttrs.erase(nStartRow, nEndRow);
 maCellTextAttrs.resize(MAXROWCOUNT);
 
 CellStorageModified();
-
-if (!bShiftCells)
-return;
-
-// Do area broadcast on the old non-empty cell ranges prior to the shift.
-sc::SingleColumnSpanSet::SpansType aSpans;
-aNonEmptySpans.getSpans(aSpans);
-std::for_each(aSpans.begin(), aSpans.end(), RangeBroadcaster(*pDocument, 
nTab, nCol));
 }
 
 sc::CellStoreType::iterator ScColumn::GetPositionToInsert( SCROW nRow )
commit fa2751ea5ce9066002a250f06bf5d056f6e0b71b
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu May 22 20:54:08 2014 -0400

fdo#78903: Write test for this.

Change-Id: If8ed8b74b58efd948772376a14172b52ff588f82

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8e65f68..38f7a3b 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1352,6 +1352,63 @@ void Test::testFormulaDepTracking2()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFormulaDepTrackingDeleteRow()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+m_pDoc-InsertTab(0, Test);
+
+// Values in A1:A3.
+m_pDoc-SetValue(ScAddress(0,0,0), 1.0);
+m_pDoc-SetValue(ScAddress(0,1,0), 3.0);
+m_pDoc-SetValue(ScAddress(0,2,0), 5.0);
+
+// SUM(A1:A3) in A5.
+m_pDoc-SetString(ScAddress(0,4,0), =SUM(A1:A3));
+
+// A6 to reference A5.
+m_pDoc-SetString(ScAddress(0,5,0), =A5*10);
+const ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(0,5,0));
+CPPUNIT_ASSERT(pFC);
+
+// A4 should have a broadcaster with A5 listening to it.
+SvtBroadcaster* pBC = m_pDoc-GetBroadcaster(ScAddress(0,4,0));
+fprintf(stdout, Test::testFormulaDepTrackingDeleteRow:   broadcaster at 
A5 = %p\n, pBC);
+CPPUNIT_ASSERT(pBC);
+SvtBroadcaster::ListenersType* pListeners = pBC-GetAllListeners();
+CPPUNIT_ASSERT_MESSAGE(A5 should have one listener., pListeners-size() 
== 1);
+SvtListener* pListener = pListeners-at(0);
+CPPUNIT_ASSERT_MESSAGE(A6 should be listening to A5., pListener == pFC);
+
+// Check initial values.
+CPPUNIT_ASSERT_EQUAL(9.0, m_pDoc-GetValue(ScAddress(0,4,0)));
+CPPUNIT_ASSERT_EQUAL(90.0, m_pDoc-GetValue(ScAddress(0,5,0)));
+
+fprintf(stdout, Test::testFormulaDepTrackingDeleteRow:   Deleting row 
2\n);
+// Delete row 2.
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+rFunc.DeleteCells(ScRange(0,1,0,MAXCOL,1,0), aMark, DEL_CELLSUP, true, 
true);
+fprintf(stdout, Test::testFormulaDepTrackingDeleteRow:   Done deleting 
row 2.\n);
+
+pBC = m_pDoc-GetBroadcaster(ScAddress(0,3,0));
+fprintf(stdout, Test::testFormulaDepTrackingDeleteRow:   broadcaster at 
A4 = %p\n, pBC);
+CPPUNIT_ASSERT_MESSAGE(Broadcaster at A5 should have shifted to A4., 
pBC);
+pListeners = pBC-GetAllListeners();
+CPPUNIT_ASSERT_MESSAGE(A3 should have one listener., pListeners-size() 
== 1);
+pFC = m_pDoc-GetFormulaCell(ScAddress(0,4,0));
+

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-16 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |  131 +-
 sc/source/filter/xml/xmlexprt.cxx |   39 +-
 2 files changed, 149 insertions(+), 21 deletions(-)

New commits:
commit fcf5b5c081ded93b12dd888236d0a860b7693ed1
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 16 10:45:40 2014 -0400

fdo#75056: Overline attribute needs special treatment as well.

Also fix the export of underline types as well.  It was always saved
as a single line.

Change-Id: I88cb0f3702a6afc14544ecbce8f200b5422fd78f

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 737a881..d61496e 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1171,6 +1171,10 @@ const SvxFieldData* toXMLPropertyStates(
 if (nIndexWidth == -1 || nIndexWidth  nEntryCount)
 break;
 
+sal_Int32 nIndexType = 
xMapper-GetEntryIndex(XML_NAMESPACE_STYLE, text-underline-type, 0);
+if (nIndexType == -1 || nIndexType  nEntryCount)
+break;
+
 sal_Int32 nIndexColor = 
xMapper-FindEntryIndex(CharUnderlineColor, XML_NAMESPACE_STYLE, 
text-underline-color);
 if (nIndexColor == -1 || nIndexColor  nEntryCount)
 break;
@@ -1182,6 +1186,7 @@ const SvxFieldData* toXMLPropertyStates(
 const SvxUnderlineItem* pUL = static_castconst 
SvxUnderlineItem*(p);
 pUL-QueryValue(aAny, MID_TL_STYLE);
 rPropStates.push_back(XMLPropertyState(nIndexStyle, aAny));
+rPropStates.push_back(XMLPropertyState(nIndexType,  aAny));
 rPropStates.push_back(XMLPropertyState(nIndexWidth, aAny));
 
 pUL-QueryValue(aAny, MID_TL_COLOR);
@@ -1193,10 +1198,38 @@ const SvxFieldData* toXMLPropertyStates(
 break;
 case EE_CHAR_OVERLINE:
 {
-if (!static_castconst SvxOverlineItem*(p)-QueryValue(aAny, 
pEntry-mnFlag))
-continue;
+// Same with overline.  Do just as we do with underline 
attributes.
+sal_Int32 nIndexStyle = 
xMapper-GetEntryIndex(XML_NAMESPACE_STYLE, text-overline-style, 0);
+if (nIndexStyle == -1 || nIndexStyle  nEntryCount)
+break;
 
-rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+sal_Int32 nIndexWidth = 
xMapper-GetEntryIndex(XML_NAMESPACE_STYLE, text-overline-width, 0);
+if (nIndexWidth == -1 || nIndexWidth  nEntryCount)
+break;
+
+sal_Int32 nIndexType = 
xMapper-GetEntryIndex(XML_NAMESPACE_STYLE, text-overline-type, 0);
+if (nIndexType == -1 || nIndexType  nEntryCount)
+break;
+
+sal_Int32 nIndexColor = 
xMapper-FindEntryIndex(CharOverlineColor, XML_NAMESPACE_STYLE, 
text-overline-color);
+if (nIndexColor == -1 || nIndexColor  nEntryCount)
+break;
+
+sal_Int32 nIndexHasColor = 
xMapper-FindEntryIndex(CharOverlineHasColor, XML_NAMESPACE_STYLE, 
text-overline-color);
+if (nIndexHasColor == -1 || nIndexHasColor  nEntryCount)
+break;
+
+const SvxOverlineItem* pOL = static_castconst 
SvxOverlineItem*(p);
+pOL-QueryValue(aAny, MID_TL_STYLE);
+rPropStates.push_back(XMLPropertyState(nIndexStyle, aAny));
+rPropStates.push_back(XMLPropertyState(nIndexType,  aAny));
+rPropStates.push_back(XMLPropertyState(nIndexWidth, aAny));
+
+pOL-QueryValue(aAny, MID_TL_COLOR);
+rPropStates.push_back(XMLPropertyState(nIndexColor, aAny));
+
+pOL-QueryValue(aAny, MID_TL_HASCOLOR);
+rPropStates.push_back(XMLPropertyState(nIndexHasColor, aAny));
 }
 break;
 case EE_CHAR_COLOR:
commit 5c0b8937f4f41ed1e4a01151bc96113f65c2770c
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 16 10:45:09 2014 -0400

fdo#75056: Write test for this.

Change-Id: I716467ffe81a1f71f03e0dc7a17c33b2ed39d334

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index ab25140..2e36357 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -45,6 +45,7 @@
 #include editeng/crossedoutitem.hxx
 #include editeng/borderline.hxx
 #include editeng/fontitem.hxx
+#include editeng/udlnitem.hxx
 #include formula/grammar.hxx
 
 #include com/sun/star/table/BorderLineStyle.hpp
@@ -437,6 +438,20 @@ void setAttribute( ScFieldEditEngine rEE, sal_Int32 
nPara, sal_Int32 nStart, sa
 rEE.QuickSetAttribs(aItemSet, aSel);
 }
 break;
+case EE_CHAR_OVERLINE:
+{
+SvxOverlineItem 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-16 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   25 +
 sc/qa/unit/ucalc.hxx|2 ++
 sc/source/core/data/column4.cxx |4 
 3 files changed, 31 insertions(+)

New commits:
commit bc7e0967be52f5eb7948fbb1c30edc7dd5acc18d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 16 23:06:33 2014 -0400

fdo#77735: Don't proceed when all cells in the range are empty.

That means there is nothing to delete, and proceeding would cause Calc
to freeze.

Change-Id: I2a8fb5736870ba459082873c8f864283d8b9c664

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index c5465c6..4acb374 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -59,6 +59,10 @@ void ScColumn::DeleteBeforeCopyFromClip( 
sc::CopyFromClipContext rCxt, const Sc
 sc::SingleColumnSpanSet::SpansType aSpans;
 aSpanSet.getSpans(aSpans);
 
+if (aSpans.empty())
+// All cells in the range in the clip are empty.  Nothing to delete.
+return;
+
 // Translate the clip column spans into the destination column, and repeat 
as needed.
 std::vectorsc::RowSpan aDestSpans;
 SCROW nDestOffset = aRange.mnRow1 - nClipRow1;
commit 30cc43a56d63ba9ffd588ebc589e3576483d7141
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 16 23:05:40 2014 -0400

fdo#77735: Write test for this.  This test will freeze with the bug present.

Change-Id: I7b7e67fe2ee59b57ce74f8303d30bebc84f6b0d0

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 14a323b..b086711 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3706,6 +3706,31 @@ void Test::testCopyPasteSkipEmpty()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testCopyPasteSkipEmpty2()
+{
+m_pDoc-InsertTab(0, Test);
+
+m_pDoc-SetString(ScAddress(0,0,0), A);
+m_pDoc-SetString(ScAddress(2,0,0), C);
+
+// Copy A1:C1 to clipboard.
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+aClipDoc.ResetClip(m_pDoc, static_castSCTAB(0));
+copyToClip(m_pDoc, ScRange(0,0,0,2,0,0), aClipDoc);
+
+// Paste to A3 with the skip empty option set.  This used to freeze. 
(fdo#77735)
+ScRange aDestRange(0,2,0,2,2,0);
+ScMarkData aMark;
+aMark.SetMarkArea(aDestRange);
+m_pDoc-CopyFromClip(aDestRange, aMark, IDF_ALL, NULL, aClipDoc, false, 
false, true, true);
+
+CPPUNIT_ASSERT_EQUAL(OUString(A), m_pDoc-GetString(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_MESSAGE(B3 should be empty., 
m_pDoc-GetCellType(ScAddress(1,2,0)) == CELLTYPE_NONE);
+CPPUNIT_ASSERT_EQUAL(OUString(C), m_pDoc-GetString(ScAddress(2,2,0)));
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testCopyPasteSkipEmptyConditionalFormatting()
 {
 m_pDoc-InsertTab(0, Test);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 35d57ce..66fbfd5 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -273,6 +273,7 @@ public:
 void testCopyPasteTranspose();
 void testCopyPasteMultiRange();
 void testCopyPasteSkipEmpty();
+void testCopyPasteSkipEmpty2();
 void testCopyPasteSkipEmptyConditionalFormatting();
 void testCutPasteRefUndo();
 void testUndoCut();
@@ -469,6 +470,7 @@ public:
 CPPUNIT_TEST(testCopyPasteTranspose);
 CPPUNIT_TEST(testCopyPasteMultiRange);
 CPPUNIT_TEST(testCopyPasteSkipEmpty);
+CPPUNIT_TEST(testCopyPasteSkipEmpty2);
 //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
 CPPUNIT_TEST(testCutPasteRefUndo);
 CPPUNIT_TEST(testUndoCut);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-15 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |  113 --
 sc/source/filter/xml/xmlexprt.cxx |   14 +++-
 2 files changed, 107 insertions(+), 20 deletions(-)

New commits:
commit 48eccfb812284f43ba24c3be3903537ce954944d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu May 15 20:32:05 2014 -0400

fdo#77537: Exporting font names in edit text needs special handling.

Change-Id: Ia9c29d37eaf962e0245920e50f534dd779af72dc

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index b1f831d..737a881 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1116,10 +1116,18 @@ const SvxFieldData* toXMLPropertyStates(
 case EE_CHAR_FONTINFO_CJK:
 case EE_CHAR_FONTINFO_CTL:
 {
-if (!static_castconst SvxFontItem*(p)-QueryValue(aAny, 
pEntry-mnFlag))
-continue;
+// Apparently font info needs special handling.
+const SvxFontItem* pItem = static_castconst SvxFontItem*(p);
 
-rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+sal_Int32 nIndexFontName = 
xMapper-GetEntryIndex(XML_NAMESPACE_STYLE, font-name, 0);
+
+if (nIndexFontName == -1 || nIndexFontName = nEntryCount)
+break;
+
+if (!pItem-QueryValue(aAny, MID_FONT_FAMILY_NAME))
+break;
+
+rPropStates.push_back(XMLPropertyState(nIndexFontName, aAny));
 }
 break;
 case EE_CHAR_WEIGHT:
commit 90f7bd61fb1c4665051f721bb7721277a79eb267
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu May 15 20:27:44 2014 -0400

fdo#77537: Write export test for this.

Change-Id: I2960713b1005c5f91fe78d12e33f1786978eac67

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index f984e69..ab25140 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -44,6 +44,7 @@
 #include editeng/section.hxx
 #include editeng/crossedoutitem.hxx
 #include editeng/borderline.hxx
+#include editeng/fontitem.hxx
 #include formula/grammar.hxx
 
 #include com/sun/star/table/BorderLineStyle.hpp
@@ -441,6 +442,19 @@ void setAttribute( ScFieldEditEngine rEE, sal_Int32 
nPara, sal_Int32 nStart, sa
 }
 }
 
+void setFont( ScFieldEditEngine rEE, sal_Int32 nPara, sal_Int32 nStart, 
sal_Int32 nEnd, const OUString rFontName )
+{
+ESelection aSel;
+aSel.nStartPara = aSel.nEndPara = nPara;
+aSel.nStartPos = nStart;
+aSel.nEndPos = nEnd;
+
+SfxItemSet aItemSet = rEE.GetEmptyItemSet();
+SvxFontItem aItem(FAMILY_MODERN, rFontName, , PITCH_VARIABLE, 
RTL_TEXTENCODING_UTF8, EE_CHAR_FONTINFO);
+aItemSet.Put(aItem);
+rEE.QuickSetAttribs(aItemSet, aSel);
+}
+
 }
 
 void ScExportTest::testNamedRangeBugfdo62729()
@@ -525,6 +539,23 @@ void ScExportTest::testRichTextExportODS()
 return false;
 }
 
+static bool isFont(const editeng::Section rAttr, const OUString 
rFontName)
+{
+if (rAttr.maAttributes.empty())
+return false;
+
+std::vectorconst SfxPoolItem*::const_iterator it = 
rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end();
+for (; it != itEnd; ++it)
+{
+const SfxPoolItem* p = *it;
+if (p-Which() != EE_CHAR_FONTINFO)
+continue;
+
+return static_castconst SvxFontItem*(p)-GetFamilyName() == 
rFontName;
+}
+return false;
+}
+
 bool checkB2(const EditTextObject* pText) const
 {
 if (!pText)
@@ -649,27 +680,62 @@ void ScExportTest::testRichTextExportODS()
 return true;
 }
 
+bool checkB7(const EditTextObject* pText) const
+{
+if (!pText)
+return false;
+
+if (pText-GetParagraphCount() != 1)
+return false;
+
+if (pText-GetText(0) != Font1 and Font2)
+return false;
+
+std::vectorediteng::Section aSecAttrs;
+pText-GetAllSections(aSecAttrs);
+if (aSecAttrs.size() != 3)
+return false;
+
+// First section should have Courier font applied.
+const editeng::Section* pAttr = aSecAttrs[0];
+if (pAttr-mnParagraph != 0 ||pAttr-mnStart != 0 || pAttr-mnEnd 
!= 5)
+return false;
+
+if (pAttr-maAttributes.size() != 1 || !isFont(*pAttr, Courier))
+return false;
+
+// Last section should have Luxi Mono applied.
+pAttr = aSecAttrs[2];
+if (pAttr-mnParagraph != 0 ||pAttr-mnStart != 10 || pAttr-mnEnd 
!= 15)
+return false;
+
+if (pAttr-maAttributes.size() != 1 || !isFont(*pAttr, Luxi 
Mono))
+  

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-13 Thread Kohei Yoshida
 sc/qa/unit/data/xls/shared-formula/biff5.xls |binary
 sc/qa/unit/subsequent_filters-test.cxx   |   18 ++
 sc/source/filter/excel/read.cxx  |2 +-
 3 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 286760359bae7e21a772dd104ab17a1df69a57b0
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 13 14:02:45 2014 -0400

fdo#78471: Don't forget to record the ID of the last record for BIFF5.

Shared formula import code depends on this.

Change-Id: Iecb009252c56673df33e0d681de825911154903a

diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index 05d2fca..5c6e6f2 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -90,7 +90,7 @@ FltError ImportExcel::Read( void )
 sal_Size nProgressBasePos = 0;
 sal_Size nProgressBaseSize = 0;
 
-while( eAkt != Z_Ende )
+for (; eAkt != Z_Ende; mnLastRecId = nOpcode)
 {
 if( eAkt == Z_Biff5E )
 {
commit 14e21865443a7318c715c2f9ff655d5b21f716ea
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 13 14:01:53 2014 -0400

fdo#78471: Write test for import of shared formulas from BIFF5.

Change-Id: I77fee109adf1c0decc6eb96cf2292f89fde1aceb

diff --git a/sc/qa/unit/data/xls/shared-formula/biff5.xls 
b/sc/qa/unit/data/xls/shared-formula/biff5.xls
new file mode 100644
index 000..ce72eb1
Binary files /dev/null and b/sc/qa/unit/data/xls/shared-formula/biff5.xls differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index ef0428d..2e5a8f6 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -170,6 +170,7 @@ public:
 
 void testSharedFormulaHorizontalXLS();
 void testSharedFormulaWrappedRefsXLS();
+void testSharedFormulaBIFF5();
 void testExternalRefCacheXLSX();
 void testExternalRefCacheODS();
 void testHybridSharedStringODS();
@@ -247,6 +248,7 @@ public:
 CPPUNIT_TEST(testColumnStyleXLSX);
 CPPUNIT_TEST(testSharedFormulaHorizontalXLS);
 CPPUNIT_TEST(testSharedFormulaWrappedRefsXLS);
+CPPUNIT_TEST(testSharedFormulaBIFF5);
 CPPUNIT_TEST(testExternalRefCacheXLSX);
 CPPUNIT_TEST(testExternalRefCacheODS);
 CPPUNIT_TEST(testHybridSharedStringODS);
@@ -2522,6 +2524,22 @@ void ScFiltersTest::testSharedFormulaWrappedRefsXLS()
 xDocSh-DoClose();
 }
 
+void ScFiltersTest::testSharedFormulaBIFF5()
+{
+ScDocShellRef xDocSh = loadDoc(shared-formula/biff5., XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh-GetDocument();
+pDoc-CalcAll();
+
+// E6:E376 should be all formulas, and they should belong to the same 
group.
+const ScFormulaCell* pFC = pDoc-GetFormulaCell(ScAddress(4,5,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(5), pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(371), pFC-GetSharedLength());
+
+xDocSh-DoClose();
+}
+
 void ScFiltersTest::testExternalRefCacheXLSX()
 {
 ScDocShellRef xDocSh = loadDoc(external-refs., XLSX);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-13 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |  106 +++
 sc/qa/unit/ucalc.hxx |2 
 sc/source/core/data/conditio.cxx |   37 +
 3 files changed, 145 insertions(+)

New commits:
commit 146f6e7e68ea56f79b72047b97bd9fba66db499d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 13 22:46:17 2014 -0400

fdo#76710: Adjust sheet position of conditional format entries.

When inserting or deleting sheets.

Change-Id: Ibf898350e22f092ec38b75ad98957832a5580e6a

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 49f2fea..80a2b53 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -2002,12 +2002,49 @@ void ScConditionalFormat::InsertCol(SCTAB nTab, SCROW 
nRowStart, SCROW nRowEnd,
 
 void ScConditionalFormat::UpdateInsertTab( sc::RefUpdateInsertTabContext rCxt 
)
 {
+for (size_t i = 0, n = maRanges.size(); i  n; ++i)
+{
+// We assume that the start and end sheet indices are equal.
+ScRange* pRange = maRanges[i];
+SCTAB nTab = pRange-aStart.Tab();
+
+if (nTab  rCxt.mnInsertPos)
+// Unaffected.
+continue;
+
+pRange-aStart.IncTab(rCxt.mnSheets);
+pRange-aEnd.IncTab(rCxt.mnSheets);
+}
+
 for (CondFormatContainer::iterator it = maEntries.begin(); it != 
maEntries.end(); ++it)
 it-UpdateInsertTab(rCxt);
 }
 
 void ScConditionalFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext rCxt 
)
 {
+for (size_t i = 0, n = maRanges.size(); i  n; ++i)
+{
+// We assume that the start and end sheet indices are equal.
+ScRange* pRange = maRanges[i];
+SCTAB nTab = pRange-aStart.Tab();
+
+if (nTab  rCxt.mnDeletePos)
+// Left of the deleted sheet(s).  Unaffected.
+continue;
+
+if (nTab = rCxt.mnDeletePos+rCxt.mnSheets-1)
+{
+// On the deleted sheet(s).
+pRange-aStart.SetTab(-1);
+pRange-aEnd.SetTab(-1);
+continue;
+}
+
+// Right of the deleted sheet(s).  Adjust the sheet indices.
+pRange-aStart.IncTab(-1*rCxt.mnSheets);
+pRange-aEnd.IncTab(-1*rCxt.mnSheets);
+}
+
 for (CondFormatContainer::iterator it = maEntries.begin(); it != 
maEntries.end(); ++it)
 it-UpdateDeleteTab(rCxt);
 }
commit dff4725f0dbb3bd7c32155e51ba49c05ee104d4f
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 13 22:42:44 2014 -0400

fdo#76710: Write test for this.

Change-Id: Ia0338d2839f0f319881948c208a74bee950da4af

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 2a2f706..14a323b 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5882,6 +5882,112 @@ void Test::testCondFormatInsertRow()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testCondFormatInsertDeleteSheets()
+{
+m_pDoc-InsertTab(0, Test);
+
+// Add a conditional format to B2:B4.
+ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+pFormat-AddRange(ScRange(1,1,0,1,3,0));
+
+sal_uLong nKey = m_pDoc-AddCondFormat(pFormat, 0);
+
+// Add condition in which if the value equals 2, set the Result style.
+ScCondFormatEntry* pEntry = new ScCondFormatEntry(
+SC_COND_EQUAL, =2,  , m_pDoc, ScAddress(0,0,0), 
ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+pFormat-AddEntry(pEntry);
+
+// Apply the format to the range.
+m_pDoc-AddCondFormatData(pFormat-GetRange(), 0, nKey);
+
+// Make sure this conditional format entry is really there.
+ScConditionalFormatList* pList = m_pDoc-GetCondFormList(0);
+CPPUNIT_ASSERT(pList);
+const ScConditionalFormat* pCheck = pList-GetFormat(nKey);
+CPPUNIT_ASSERT_MESSAGE(Wrong condntional format instance., pCheck == 
pFormat);
+
+// ... and its range is B2:B4.
+ScRangeList aCheckRange = pCheck-GetRange();
+CPPUNIT_ASSERT_MESSAGE(This should be a single range., 
aCheckRange.size() == 1);
+const ScRange* pRange = aCheckRange[0];
+CPPUNIT_ASSERT(pRange);
+CPPUNIT_ASSERT_MESSAGE(Format should be applied to B2:B4., *pRange == 
ScRange(1,1,0,1,3,0));
+
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+
+// Insert a new sheet at the left.
+bool bInserted = rFunc.InsertTable(0, Inserted, true, true);
+CPPUNIT_ASSERT(bInserted);
+
+pList = m_pDoc-GetCondFormList(1);
+CPPUNIT_ASSERT(pList);
+pCheck = pList-GetFormat(nKey);
+CPPUNIT_ASSERT(pCheck);
+
+// Make sure the range also got shifted.
+aCheckRange = pCheck-GetRange();
+CPPUNIT_ASSERT_MESSAGE(This should be a single range., 
aCheckRange.size() == 1);
+pRange = aCheckRange[0];
+CPPUNIT_ASSERT(pRange);
+CPPUNIT_ASSERT_MESSAGE(Format should be applied to B2:B4 on the 2nd sheet 
after the sheet insertion., *pRange == ScRange(1,1,1,1,3,1));
+
+// Delete the sheet to the left.
+bool bDeleted = rFunc.DeleteTable(0, 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |9 +
 sc/source/core/data/document.cxx |   20 ++--
 2 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit a45973a90625f4b9e0f603154194f357ff2418d4
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 9 11:44:51 2014 -0400

fdo#77806: Check the boundaries before accessing an array

Change-Id: I0878f734599f566cde83183947cd7613c0f8d5c6

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 181f294..414abd4 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6135,14 +6135,30 @@ bool ScDocument::HasNote(const ScAddress rPos) const
 {
 return HasNote(rPos.Col(), rPos.Row(), rPos.Tab());
 }
+
 bool ScDocument::HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const
 {
-const ScPostIt* pNote = maTabs[nTab]-aCol[nCol].GetCellNote(nRow);
+if (!ValidColRow(nCol, nRow))
+return false;
+
+const ScTable* pTab = FetchTable(nTab);
+if (!pTab)
+return false;
+
+const ScPostIt* pNote = pTab-aCol[nCol].GetCellNote(nRow);
 return pNote != NULL;
 }
+
 bool ScDocument::HasColNotes(SCCOL nCol, SCTAB nTab) const
 {
-return maTabs[nTab]-aCol[nCol].HasCellNotes();
+if (!ValidCol(nCol))
+return false;
+
+const ScTable* pTab = FetchTable(nTab);
+if (!pTab)
+return false;
+
+return pTab-aCol[nCol].HasCellNotes();
 }
 
 bool ScDocument::HasTabNotes(SCTAB nTab) const
commit cd87cd92b95861e5cacb111dc33a809a9db884e3
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 9 11:44:28 2014 -0400

fdo#77806: Write test for this.

Change-Id: Ic05b6fec2bfc89688cb1670a163f27caccc7f213

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index d764673..1ca19b8 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5176,6 +5176,15 @@ void Test::testNoteBasic()
 {
 m_pDoc-InsertTab(0, PostIts);
 
+CPPUNIT_ASSERT(!m_pDoc-HasNotes());
+
+// Check for note's presence in all tables before inserting any notes.
+for (SCTAB i = 0; i = MAXTAB; ++i)
+{
+bool bHasNotes = m_pDoc-HasTabNotes(i);
+CPPUNIT_ASSERT(!bHasNotes);
+}
+
 ScAddress aAddr(2, 2, 0); // cell C3
 ScPostIt *pNote = m_pDoc-GetOrCreateNote(aAddr);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   55 
 sc/qa/unit/ucalc.hxx|2 +
 sc/source/core/data/column3.cxx |4 +-
 3 files changed, 59 insertions(+), 2 deletions(-)

New commits:
commit f4673ccd5e26d38a28f297d64ed70ba719d21ef2
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 9 14:04:30 2014 -0400

fdo#77379: Don't return from the call. Notes are handled at the end.

Returning prematurely would end up skipping pasting of notes.

Change-Id: I79e0968023342a68fe729f31eb6cfc3cfacd5850

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index e3a81a5..8bb8223 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -873,7 +873,7 @@ public:
 case sc::element_type_string:
 {
 if (!bString)
-return;
+break;
 
 sc::string_block::const_iterator it = 
sc::string_block::begin(*node.data);
 std::advance(it, nOffset);
@@ -897,7 +897,7 @@ public:
 case sc::element_type_edittext:
 {
 if (!bString)
-return;
+break;
 
 sc::edittext_block::const_iterator it = 
sc::edittext_block::begin(*node.data);
 std::advance(it, nOffset);
commit 71cd1ca57faf423fb607fab64914719238bc1e4f
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 9 13:50:31 2014 -0400

fdo#77379: Write test for this.

Change-Id: Iccc0b499abae90f5b780aebab17ff6315b5690ec

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1ca19b8..4cf444f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5400,6 +5400,61 @@ void Test::testNoteLifeCycle()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testNoteCopyPaste()
+{
+m_pDoc-InsertTab(0, Test);
+
+// We need a drawing layer in order to create caption objects.
+m_pDoc-InitDrawLayer(getDocShell());
+
+// Insert in B2 a text and cell comment.
+ScAddress aPos(1,1,0);
+m_pDoc-SetString(aPos, Text);
+ScPostIt* pNote = m_pDoc-GetOrCreateNote(aPos);
+CPPUNIT_ASSERT(pNote);
+pNote-SetText(aPos, Note1);
+
+// Insert in B4 a number and cell comment.
+aPos.SetRow(3);
+m_pDoc-SetValue(aPos, 1.1);
+pNote = m_pDoc-GetOrCreateNote(aPos);
+CPPUNIT_ASSERT(pNote);
+pNote-SetText(aPos, Note2);
+
+// Copy B2:B4 to clipboard.
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+ScRange aCopyRange(1,1,0,1,3,0);
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+aClipDoc.ResetClip(m_pDoc, aMark);
+ScClipParam aClipParam(aCopyRange, false);
+m_pDoc-CopyToClip(aClipParam, aClipDoc, aMark, false, false, false, 
true, false);
+
+// Make sure the notes are in the clipboard.
+pNote = aClipDoc.GetNote(ScAddress(1,1,0));
+CPPUNIT_ASSERT(pNote);
+CPPUNIT_ASSERT_EQUAL(OUString(Note1), pNote-GetText());
+
+pNote = aClipDoc.GetNote(ScAddress(1,3,0));
+CPPUNIT_ASSERT(pNote);
+CPPUNIT_ASSERT_EQUAL(OUString(Note2), pNote-GetText());
+
+// Paste to B6:B8 but only cell notes.
+ScRange aDestRange(1,5,0,1,7,0);
+m_pDoc-CopyFromClip(aDestRange, aMark, IDF_NOTE, NULL, aClipDoc);
+
+// Make sure the notes are there.
+pNote = m_pDoc-GetNote(ScAddress(1,5,0));
+CPPUNIT_ASSERT(pNote);
+CPPUNIT_ASSERT_EQUAL(OUString(Note1), pNote-GetText());
+
+pNote = m_pDoc-GetNote(ScAddress(1,7,0));
+CPPUNIT_ASSERT(pNote);
+CPPUNIT_ASSERT_EQUAL(OUString(Note2), pNote-GetText());
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testAreasWithNotes()
 {
 ScDocument* pDoc = getDocShell().GetDocument();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index dbe84e7..76c74cc 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -341,6 +341,7 @@ public:
 void testNoteDeleteRow();
 void testNoteDeleteCol();
 void testNoteLifeCycle();
+void testNoteCopyPaste();
 void testAreasWithNotes();
 void testAnchoredRotatedShape();
 void testCellTextWidth();
@@ -499,6 +500,7 @@ public:
 CPPUNIT_TEST(testNoteDeleteRow);
 CPPUNIT_TEST(testNoteDeleteCol);
 CPPUNIT_TEST(testNoteLifeCycle);
+CPPUNIT_TEST(testNoteCopyPaste);
 CPPUNIT_TEST(testAreasWithNotes);
 CPPUNIT_TEST(testAnchoredRotatedShape);
 CPPUNIT_TEST(testCellTextWidth);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   44 +---
 sc/source/core/data/column3.cxx |   43 +++
 2 files changed, 63 insertions(+), 24 deletions(-)

New commits:
commit 83a88b942134314e86ac612d0ef70a8e4919e4af
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 9 22:19:15 2014 -0400

fdo#77056: Treat empty cells as if they have a value of 0.0.

Change-Id: Ibe64cf7177a5298c1878e0014c049dc9c82b1344

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 8bb8223..5db4625 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1158,6 +1158,23 @@ class MixDataHandler
 
 bool mbSkipEmpty;
 
+void doFunction( size_t nDestRow, double fVal1, double fVal2 )
+{
+bool bOk = lcl_DoFunction(fVal1, fVal2, mnFunction);
+
+if (bOk)
+miNewCellsPos = maNewCells.set(miNewCellsPos, 
nDestRow-mnRowOffset, fVal1);
+else
+{
+ScAddress aPos(mrDestColumn.GetCol(), nDestRow, 
mrDestColumn.GetTab());
+
+ScFormulaCell* pFC = new ScFormulaCell(mrDestColumn.GetDoc(), 
aPos);
+pFC-SetErrCode(errNoValue);
+
+miNewCellsPos = maNewCells.set(miNewCellsPos, 
nDestRow-mnRowOffset, pFC);
+}
+}
+
 public:
 MixDataHandler(
 sc::ColumnBlockPosition rBlockPos,
@@ -1180,22 +1197,15 @@ public:
 mrBlockPos.miCellPos = aPos.first;
 switch (aPos.first-type)
 {
+case sc::element_type_empty:
 case sc::element_type_numeric:
 {
-// Both src and dest are of numeric type.
-bool bOk = lcl_DoFunction(f, 
sc::numeric_block::at(*aPos.first-data, aPos.second), mnFunction);
-
-if (bOk)
-miNewCellsPos = maNewCells.set(miNewCellsPos, 
nRow-mnRowOffset, f);
-else
-{
-ScFormulaCell* pFC =
-new ScFormulaCell(
-mrDestColumn.GetDoc(), 
ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()));
+double fSrcVal = 0.0;
+if (aPos.first-type == sc::element_type_numeric)
+fSrcVal = sc::numeric_block::at(*aPos.first-data, 
aPos.second);
 
-pFC-SetErrCode(errNoValue);
-miNewCellsPos = maNewCells.set(miNewCellsPos, 
nRow-mnRowOffset, pFC);
-}
+// Both src and dest are of numeric type.
+doFunction(nRow, f, fSrcVal);
 }
 break;
 case sc::element_type_formula:
@@ -1229,7 +1239,6 @@ public:
 break;
 case sc::element_type_string:
 case sc::element_type_edittext:
-case sc::element_type_empty:
 {
 // Destination cell is not a number. Just take the source cell.
 miNewCellsPos = maNewCells.set(miNewCellsPos, 
nRow-mnRowOffset, f);
@@ -1346,9 +1355,9 @@ public:
 {
 case sc::element_type_numeric:
 {
-double fVal = sc::numeric_block::at(*aPos.first-data, 
aPos.second);
-miNewCellsPos = maNewCells.set(
-miNewCellsPos, nDestRow-mnRowOffset, fVal);
+double fVal1 = 0.0;
+double fVal2 = sc::numeric_block::at(*aPos.first-data, 
aPos.second);
+doFunction(nDestRow, fVal1, fVal2);
 }
 break;
 case sc::element_type_string:
commit b44f8185398ff6835a71fe237089746fca7f999d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri May 9 22:18:14 2014 -0400

fdo#77056: Modify existing test to cover the reported scenario.

Change-Id: I6d0fe13e6756d8b6c3e7ac9ffba828e3f9c2a7b5

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4cf444f..4a9fb2f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6089,19 +6089,49 @@ void Test::testMixData()
 {
 m_pDoc-InsertTab(0, Test);
 
-m_pDoc-SetValue(1,0,0,2);
-m_pDoc-SetValue(0,1,0,3);
+m_pDoc-SetValue(ScAddress(1,0,0), 2.0); // B1
+m_pDoc-SetValue(ScAddress(0,1,0), 3.0); // A2
+
+// Copy A1:B1 to the clip document.
 ScDocument aClipDoc(SCDOCMODE_CLIP);
-copyToClip(m_pDoc, ScRange(0,0,0,1,0,0), aClipDoc);
+copyToClip(m_pDoc, ScRange(0,0,0,1,0,0), aClipDoc); // A1:B1
 
+// Copy A2:B2 to the mix document (for arithemetic paste).
 ScDocument aMixDoc(SCDOCMODE_CLIP);
-copyToClip(m_pDoc, ScRange(0,1,0,1,1,0), aMixDoc);
+copyToClip(m_pDoc, ScRange(0,1,0,1,1,0), aMixDoc); // A2:B2
 
+// Paste A1:B1 to A2:B2 and perform addition.
 pasteFromClip(m_pDoc, ScRange(0,1,0,1,1,0), aClipDoc);
-m_pDoc-MixDocument(ScRange(0,1,0,1,1,0), 1, false, aMixDoc);
+

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-06 Thread Kohei Yoshida
 sc/qa/unit/helper/qahelper.cxx  |4 +++
 sc/qa/unit/ucalc.cxx|   48 
 sc/qa/unit/ucalc.hxx|2 +
 sc/source/core/data/formulacell.cxx |2 -
 4 files changed, 55 insertions(+), 1 deletion(-)

New commits:
commit 67563fd55b230eb68fef705ff645af7dab73af73
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 6 12:22:53 2014 -0400

fdo#77944: Put updated formula cells into undo document.

Change-Id: Ib9d6a73d485878bfe6c2a1875936025eb4d0a30a

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index d7cef22..a233fe5 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2871,7 +2871,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
  (bValChanged  bHasRelName ) || bOnRefMove)
 bNeedDirty = true;
 
-if (pUndoDoc  (bValChanged || bOnRefMove))
+if (pUndoDoc  (bValChanged || bRefModified || bOnRefMove))
 setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, 
cMatrixFlag);
 
 bValChanged = false;
commit 5971a8f1cee915e762784e970f0eb10f2baf0f71
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 6 12:22:13 2014 -0400

fdo#77944: Write test for this.

Change-Id: I0dae7533121d5501b35c289bd48ef8d139e37d3e

diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 776955f..e97329f 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -404,7 +404,11 @@ ScTokenArray* getTokens(ScDocument rDoc, const ScAddress 
rPos)
 {
 ScFormulaCell* pCell = rDoc.GetFormulaCell(rPos);
 if (!pCell)
+{
+OUString aStr = rPos.Format(SCA_VALID);
+cerr  aStr   is not a formula cell.  endl;
 return NULL;
+}
 
 return pCell-GetCode();
 }
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ace06b2..97e6521 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3772,6 +3772,54 @@ void Test::testCopyPasteSkipEmptyConditionalFormatting()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testCutPasteRefUndo()
+{
+// Testing scenario: A2 references B2, and B2 gets cut and pasted onto C2,
+// which updates A2's formula to reference C2. Then the paste action gets
+// undone, which should also undo A2's formula to reference back to B2.
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+m_pDoc-InsertTab(0, Test);
+
+// A2 references B2.
+m_pDoc-SetString(ScAddress(0,1,0), =B2);
+
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+
+// Set up clip document for cutting of B2.
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+aClipDoc.ResetClip(m_pDoc, aMark);
+ScClipParam aParam(ScAddress(1,1,0), true);
+aClipDoc.SetClipParam(aParam);
+aClipDoc.SetValue(ScAddress(1,1,0), 12.0);
+
+// Set up undo document for reference update.
+ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
+pUndoDoc-InitUndo(m_pDoc, 0, 0);
+
+// Do the pasting of 12 into C2.  This should update A2 to reference C2.
+m_pDoc-CopyFromClip(ScAddress(2,1,0), aMark, IDF_CONTENTS, pUndoDoc, 
aClipDoc, true, false);
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc-GetValue(0,1,0));
+
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), C2))
+CPPUNIT_FAIL(A2 should be referencing C2.);
+
+// At this point, the ref undo document should contain a formula cell at 
A2 that references B2.
+if (!checkFormula(*pUndoDoc, ScAddress(0,1,0), B2))
+CPPUNIT_FAIL(A2 in the undo document should be referencing B2.);
+
+ScUndoPaste aUndo(getDocShell(), ScRange(ScAddress(2,1,0)), aMark, 
pUndoDoc, NULL, IDF_CONTENTS, NULL, false, NULL);
+aUndo.Undo();
+
+// Now A2 should be referencing B2 once again.
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), B2))
+CPPUNIT_FAIL(A2 should be referencing B2 after undo.);
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testUndoCut()
 {
 m_pDoc-InsertTab(0, Test);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2a256a1..f812630 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -261,6 +261,7 @@ public:
 void testCopyPasteMultiRange();
 void testCopyPasteSkipEmpty();
 void testCopyPasteSkipEmptyConditionalFormatting();
+void testCutPasteRefUndo();
 void testUndoCut();
 void testMoveBlock();
 void testCopyPasteRelativeFormula();
@@ -449,6 +450,7 @@ public:
 CPPUNIT_TEST(testCopyPasteMultiRange);
 CPPUNIT_TEST(testCopyPasteSkipEmpty);
 //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
+CPPUNIT_TEST(testCutPasteRefUndo);
 CPPUNIT_TEST(testUndoCut);
 CPPUNIT_TEST(testMoveBlock);
 CPPUNIT_TEST(testCopyPasteRelativeFormula);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-05-06 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx  |9 +++
 sc/qa/unit/ucalc.hxx  |8 ++
 sc/qa/unit/ucalc_formula.cxx  |   52 +-
 sc/source/core/tool/token.cxx |2 -
 4 files changed, 54 insertions(+), 17 deletions(-)

New commits:
commit 7aa32a759fb7b440f870739f7bb680f405f338ce
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 6 15:24:50 2014 -0400

fdo#77647: Fix the column insertion use case.

Change-Id: I7c78f54c9386eced16113e69e625d23ed4acedd7

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index b1f8e02..636ff01 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2546,7 +2546,7 @@ bool expandRange( const sc::RefUpdateContext rCxt, 
ScRange rRefRange, const Sc
 // Selected range is only partially overlapping in vertical 
direction. Bail out.
 return false;
 
-if (!rCxt.mrDoc.IsExpandRefs()  rSelectedRange.aStart.Col() == 
rRefRange.aStart.Col())
+if (!rCxt.mrDoc.IsExpandRefs()  rSelectedRange.aStart.Col() = 
rRefRange.aStart.Col())
 // Selected range is at the left end and the edge expansion is 
turned off.  No expansion.
 return false;
 
commit 48631bde1ccdbd618e5892b7050822b61b843332
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue May 6 15:23:57 2014 -0400

fdo#77647: Test for reference adjustment on column insertion.

Change-Id: Ic95ff3892efbfc003ae9976b4fba4129de11bbef

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 97e6521..d764673 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -62,6 +62,7 @@
 #include patattr.hxx
 #include docpool.hxx
 #include globalnames.hxx
+#include inputopt.hxx
 
 #include formula/IFunctionDescription.hxx
 
@@ -6139,6 +6140,14 @@ ScUndoPaste* Test::createUndoPaste(ScDocShell rDocSh, 
const ScRange rRange, Sc
 rDocSh, rRange, aMarkData, pUndoDoc, NULL, IDF_ALL, pRefUndoData, 
false);
 }
 
+void Test::setExpandRefs(bool bExpand)
+{
+ScModule* pMod = SC_MOD();
+ScInputOptions aOpt = pMod-GetInputOptions();
+aOpt.SetExpandRefs(bExpand);
+pMod-SetInputOptions(aOpt);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f812630..dbe84e7 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -47,6 +47,12 @@ public:
 static void pasteFromClip(ScDocument* pDestDoc, const ScRange rDestRange, 
ScDocument* pClipDoc);
 static ScUndoPaste* createUndoPaste(ScDocShell rDocSh, const ScRange 
rRange, ScDocument* pUndoDoc);
 
+/**
+ * Enable or disable expand reference options which controls how
+ * references in formula are expanded when inserting rows or columns.
+ */
+static void setExpandRefs(bool bExpand);
+
 templatesize_t _Size
 static ScRange insertRangeData(ScDocument* pDoc, const ScAddress rPos, 
const char* aData[][_Size], size_t nRowCount)
 {
@@ -119,6 +125,7 @@ public:
 void testFormulaRefUpdateRange();
 void testFormulaRefUpdateSheets();
 void testFormulaRefUpdateInsertRows();
+void testFormulaRefUpdateInsertColumns();
 void testFormulaRefUpdateMove();
 void testFormulaRefUpdateMoveUndo();
 void testFormulaRefUpdateNamedExpression();
@@ -375,6 +382,7 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateRange);
 CPPUNIT_TEST(testFormulaRefUpdateSheets);
 CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
+CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
 CPPUNIT_TEST(testFormulaRefUpdateMove);
 CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
 CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index efe73a0..3f75db8 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -17,7 +17,6 @@
 #include scopetools.hxx
 #include formulacell.hxx
 #include formulagroup.hxx
-#include inputopt.hxx
 #include scmod.hxx
 #include docsh.hxx
 #include docfunc.hxx
@@ -1036,10 +1035,7 @@ void Test::testFormulaRefUpdateRange()
 
 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
 
-ScModule* pMod = SC_MOD();
-ScInputOptions aOpt = pMod-GetInputOptions();
-aOpt.SetExpandRefs(false);
-pMod-SetInputOptions(aOpt);
+setExpandRefs(false);
 
 // Set values to B2:C5.
 m_pDoc-SetValue(ScAddress(1,1,0), 1);
@@ -1166,7 +1162,7 @@ void Test::testFormulaRefUpdateRange()
 clearRange(m_pDoc, ScRange(0,0,0,20,20,0));
 
 // Disable expansion of range reference on insertion in adjacent areas.
-m_pDoc-SetExpandRefs(false);
+setExpandRefs(false);
 
 // Fill C2:D3 with values.
 m_pDoc-SetValue(ScAddress(2,1,0), 1);
@@ -1251,8 +1247,7 @@ void Test::testFormulaRefUpdateRange()
 clearRange(m_pDoc, ScRange(0,0,0,20,20,0));
 
 // Turn edge expansion on.
-aOpt.SetExpandRefs(true);
-

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-04-29 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx   |   22 ++
 sc/source/core/data/document10.cxx |4 
 2 files changed, 26 insertions(+)

New commits:
commit ea0ac020160207a08de3168142abc2a74f17afd6
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Apr 29 11:40:06 2014 -0400

fdo#74322: Let's not handle cut mode here.

Things are a bit more complex in cut mode than what this method can handle.

Change-Id: Idadee23beff08c2df89d47bb237e8a2d2fd69dab

diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index 2046b31..4112bb9 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -57,6 +57,10 @@ bool ScDocument::CopyOneCellFromClip(
 sc::CopyFromClipContext rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 )
 {
 ScDocument* pClipDoc = rCxt.getClipDoc();
+if (pClipDoc-GetClipParam().mbCutMode)
+// We don't handle cut and paste or moving of cells here.
+return false;
+
 ScRange aClipRange = pClipDoc-GetClipParam().getWholeRange();
 if (aClipRange.aStart != aClipRange.aEnd)
 // The source is not really a single cell. Bail out.
commit fd65b90934d0c521de1f3b04214e364fd540f080
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Apr 29 11:20:55 2014 -0400

fdo#74322: Additional test for the followup issue.

Change-Id: I971e7ea2535138eb4ac901c227c72a50578746a8

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 937c96e..ae65185 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1932,6 +1932,28 @@ void Test::testFormulaRefUpdateNamedExpressionMove()
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(0,9,0)));
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(0,10,0)));
 
+// Clear and start over.
+clearSheet(m_pDoc, 0);
+m_pDoc-GetRangeName()-clear();
+
+// Set value to B2.
+m_pDoc-SetValue(ScAddress(1,1,0), 2.0);
+
+// Define B2 as 'MyCell'.
+bInserted = m_pDoc-InsertNewRangeName(MyCell, ScAddress(0,0,0), 
$Test.$B$2);
+CPPUNIT_ASSERT(bInserted);
+
+// Set formula to B3 that references B2 via MyCell.
+m_pDoc-SetString(ScAddress(1,2,0), =MyCell*2);
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc-GetValue(ScAddress(1,2,0)));
+
+// Move B2 to D2.
+bMoved = rFunc.MoveBlock(ScRange(1,1,0,1,1,0), ScAddress(3,1,0), true, 
true, false, true);
+CPPUNIT_ASSERT(bMoved);
+
+// Value in B3 should remain unchanged.
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc-GetValue(ScAddress(1,2,0)));
+
 m_pDoc-DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-04-28 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx |2 ++
 sc/qa/unit/ucalc_formula.cxx |   33 +
 sc/source/core/tool/scmatrix.cxx |2 +-
 3 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 5fab47ddbe332a150fb2005e941a2c19bd38ce7f
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Apr 28 11:55:23 2014 -0400

fdo#75397: Return an empty string for empty element.

This is the behavior as of 3.6.  It had changed in 4.0 and onward by
accident, and caused the bug as reported in fdo#75397.

Change-Id: Id96fea354604b3c13cbbf2d9a73223b7725c7d66

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index b71da72..32da95a 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -579,7 +579,7 @@ svl::SharedString ScMatrixImpl::GetString( 
SvNumberFormatter rFormatter, SCSIZE
 {
 if (!maMatFlag.getbool(nR, nC))
 // not an empty path.
-break;
+return svl::SharedString::getEmptyString();
 
 // result of empty FALSE jump path
 sal_uLong nKey = rFormatter.GetStandardFormat( 
NUMBERFORMAT_LOGICAL,
commit 18fa4733f46c2dae40bad7cdea9d3f98e24495dd
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Apr 28 11:16:29 2014 -0400

fdo#75397: Write unit test for this.

Change-Id: Id261aebd427eb032463668c2654ce837139b4a05

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2939ac5..71b33a7 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -133,6 +133,7 @@ public:
 void testFuncN();
 void testFuncCOUNTIF();
 void testFuncNUMBERVALUE();
+void testFuncLEN();
 void testFuncLOOKUP();
 void testFuncVLOOKUP();
 void testFuncMATCH();
@@ -383,6 +384,7 @@ public:
 CPPUNIT_TEST(testFuncN);
 CPPUNIT_TEST(testFuncCOUNTIF);
 CPPUNIT_TEST(testFuncNUMBERVALUE);
+CPPUNIT_TEST(testFuncLEN);
 CPPUNIT_TEST(testFuncLOOKUP);
 CPPUNIT_TEST(testFuncVLOOKUP);
 CPPUNIT_TEST(testFuncMATCH);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 9776715..b2caf22 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2635,6 +2635,39 @@ void Test::testFuncNUMBERVALUE()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFuncLEN()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+m_pDoc-InsertTab(0, Formula);
+
+// Leave A1:A3 empty, and insert an array of LEN in B1:B3 that references
+// these empty cells.
+
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+m_pDoc-InsertMatrixFormula(1, 0, 1, 2, aMark, =LEN(A1:A3), NULL);
+
+ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(1,0,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_MESSAGE(This formulashould be a matrix origin.,
+   pFC-GetMatrixFlag() == MM_FORMULA);
+
+// This should be a 1x3 matrix.
+SCCOL nCols = -1;
+SCROW nRows = -1;
+pFC-GetMatColsRows(nCols, nRows);
+CPPUNIT_ASSERT_EQUAL(static_castSCCOL(1), nCols);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(3), nRows);
+
+// LEN value should be 0 for an empty cell.
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc-GetValue(ScAddress(1,0,0)));
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc-GetValue(ScAddress(1,1,0)));
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc-GetValue(ScAddress(1,2,0)));
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFuncLOOKUP()
 {
 FormulaGrammarSwitch aFGSwitch(m_pDoc, 
formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-04-24 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx |8 
 sc/source/core/tool/interpr6.cxx |1 +
 sc/source/core/tool/scmatrix.cxx |   14 ++
 3 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit 4158d8843d50d50e9830c8dc24af8722de77f4af
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Apr 24 12:26:01 2014 -0400

fdo#76663: Let's not skip the first element of a matrix in PRODUCT.

Change-Id: I00683ce64fea58a80cd7137384e8f30464c44e9f

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 97282d0..84d4599 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -387,6 +387,7 @@ void IterateMatrix(
 case ifPRODUCT:
 {
 ScMatrix::IterateResult aRes = pMat-Product(bTextAsZero);
+fRes = aRes.mfFirst;
 fRes *= aRes.mfRest;
 rCount += aRes.mnCount;
 }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index e926e4b..b71da72 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -950,7 +950,7 @@ namespace {
 
 struct SumOp
 {
-static const int InitVal = 0;
+static const double InitVal;
 
 void operator() (double rAccum, double fVal)
 {
@@ -958,9 +958,11 @@ struct SumOp
 }
 };
 
+const double SumOp::InitVal = 0.0;
+
 struct SumSquareOp
 {
-static const int InitVal = 0;
+static const double InitVal;
 
 void operator() (double rAccum, double fVal)
 {
@@ -968,9 +970,11 @@ struct SumSquareOp
 }
 };
 
+const double SumSquareOp::InitVal = 0.0;
+
 struct ProductOp
 {
-static const int InitVal = 1;
+static const double InitVal;
 
 void operator() (double rAccum, double fVal)
 {
@@ -978,6 +982,8 @@ struct ProductOp
 }
 };
 
+const double ProductOp::InitVal = 1.0;
+
 templatetypename _Op
 class WalkElementBlocks : 
std::unary_functionMatrixImplType::element_block_node_type, void
 {
@@ -987,7 +993,7 @@ class WalkElementBlocks : 
std::unary_functionMatrixImplType::element_block_node
 bool mbFirst:1;
 bool mbTextAsZero:1;
 public:
-WalkElementBlocks(bool bTextAsZero) : maRes(0.0, _Op::InitVal, 0), 
mbFirst(true), mbTextAsZero(bTextAsZero) {}
+WalkElementBlocks(bool bTextAsZero) : maRes(_Op::InitVal, _Op::InitVal, 
0), mbFirst(true), mbTextAsZero(bTextAsZero) {}
 
 const ScMatrix::IterateResult getResult() const { return maRes; }
 
commit d36442aa31a57b8c559f33564dde5366358564f1
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Apr 24 12:31:02 2014 -0400

fdo#76663: Better test to really test PRODUCT with array input.

The first element should be something other than 1 to make this a better
check.

Change-Id: I2dc108a2e755034f584fef781eb5668b629dc3fd

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 4544ac6..254962e 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2163,6 +2163,8 @@ void Test::testFuncSUM()
 
 void Test::testFuncPRODUCT()
 {
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
+
 OUString aTabName(foo);
 CPPUNIT_ASSERT_MESSAGE (failed to insert sheet,
 m_pDoc-InsertTab (0, aTabName));
@@ -2175,14 +2177,12 @@ void Test::testFuncPRODUCT()
 val = 3;
 m_pDoc-SetValue(0, 2, 0, val);
 m_pDoc-SetString(0, 3, 0, OUString(=PRODUCT(A1:A3)));
-m_pDoc-CalcAll();
 m_pDoc-GetValue(0, 3, 0, result);
 CPPUNIT_ASSERT_MESSAGE(Calculation of PRODUCT failed, result == 6.0);
 
-m_pDoc-SetString(0, 4, 0, OUString(=PRODUCT({1;2;3})));
-m_pDoc-CalcAll();
+m_pDoc-SetString(0, 4, 0, OUString(=PRODUCT({2;3;4})));
 m_pDoc-GetValue(0, 4, 0, result);
-CPPUNIT_ASSERT_MESSAGE(Calculation of PRODUCT with inline array failed, 
result == 6.0);
+CPPUNIT_ASSERT_MESSAGE(Calculation of PRODUCT with inline array failed, 
result == 24.0);
 
 m_pDoc-DeleteTab(0);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-04-24 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx   |   17 +++--
 sc/source/core/tool/queryparam.cxx |   14 --
 2 files changed, 23 insertions(+), 8 deletions(-)

New commits:
commit 50708577850544920c746ebc382d47275452a761
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Apr 24 19:42:30 2014 -0400

fdo#77039: Fill the match string even if the raw string is empty.

And in case of an empty string, call svl::SharedString::getEmptyString()
to get an empty shared string instance.

Change-Id: I0923e59f03468790270de8ef22323c0cedad002f

diff --git a/sc/source/core/tool/queryparam.cxx 
b/sc/source/core/tool/queryparam.cxx
index c9d7e29..487a577 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -173,14 +173,16 @@ void ScQueryParamBase::FillInExcelSyntax(
 svl::SharedStringPool rPool, const OUString rStr, SCSIZE nIndex)
 {
 const OUString aCellStr = rStr;
-if (!aCellStr.isEmpty())
-{
-if ( nIndex = maEntries.size() )
-Resize( nIndex+1 );
+if (nIndex = maEntries.size())
+Resize(nIndex+1);
 
-ScQueryEntry rEntry = GetEntry(nIndex);
-ScQueryEntry::Item rItem = rEntry.GetQueryItem();
+ScQueryEntry rEntry = GetEntry(nIndex);
+ScQueryEntry::Item rItem = rEntry.GetQueryItem();
 
+if (aCellStr.isEmpty())
+rItem.maString = svl::SharedString::getEmptyString();
+else
+{
 rEntry.bDoQuery = true;
 // Operatoren herausfiltern
 if (aCellStr[0] == '')
commit 380631d0e24d8bf90a5431b3e3c5fb36f21dbcf0
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Apr 24 19:15:38 2014 -0400

fdo#77039: Write test for this.

Change-Id: If34291ffb9705c413a451091ac70d7f2c7ea8f63

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 254962e..e3283db 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2294,6 +2294,8 @@ void Test::testFuncN()
 
 void Test::testFuncCOUNTIF()
 {
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
 // COUNTIF (test case adopted from OOo i#36381)
 
 OUString aTabName(foo);
@@ -2345,7 +2347,6 @@ void Test::testFuncCOUNTIF()
 SCROW nRow = 20 + i;
 m_pDoc-SetString(0, nRow, 0, 
OUString::createFromAscii(aChecks[i].pFormula));
 }
-m_pDoc-CalcAll();
 
 for (SCROW i = 0; i  nRows; ++i)
 {
@@ -2368,11 +2369,23 @@ void Test::testFuncCOUNTIF()
 
 m_pDoc-SetString(0, 0, 0, OUString(=\\));
 m_pDoc-SetString(0, 1, 0, OUString(=COUNTIF(A1;1)));
-m_pDoc-CalcAll();
 
 double result = m_pDoc-GetValue(0, 1, 0);
 CPPUNIT_ASSERT_MESSAGE(We shouldn't count empty string as valid number., 
result == 0.0);
 
+// Another test case adopted from fdo#77039.
+clearSheet(m_pDoc, 0);
+
+// Set formula cells with blank results in A1:A4.
+for (SCROW i = 0; i =3; ++i)
+m_pDoc-SetString(ScAddress(0,i,0), =\\);
+
+// Insert formula into A5 to count all cells with empty strings.
+m_pDoc-SetString(ScAddress(0,4,0), =COUNTIF(A1:A4;\\);
+
+// We should correctly count with empty string key.
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc-GetValue(ScAddress(0,4,0)));
+
 m_pDoc-DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-04-10 Thread Kohei Yoshida
 sc/qa/unit/ucalc_sharedformula.cxx |8 
 sc/source/core/data/column4.cxx|   19 +++
 2 files changed, 19 insertions(+), 8 deletions(-)

New commits:
commit 66c6a3bfc9cd89c562107d3d369b3d82bae94d68
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Apr 11 00:43:18 2014 -0400

fdo#77300: Don't re-compile formulas when the hybrid formula is not there.

Change-Id: I9b0f8d031fec08bb8d92333ff67074fdc739e034

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index c658124..7d87177 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -661,16 +661,19 @@ public:
 ScFormulaCell* pCell = rEntry.mpCell;
 OUString aFormula = pCell-GetHybridFormula();
 
-// Create token array from formula string.
-ScCompiler aComp(mrCompileFormulaCxt, pCell-aPos);
-ScTokenArray* pNewCode = aComp.CompileString(aFormula);
+if (!aFormula.isEmpty())
+{
+// Create token array from formula string.
+ScCompiler aComp(mrCompileFormulaCxt, pCell-aPos);
+ScTokenArray* pNewCode = aComp.CompileString(aFormula);
 
-// Generate RPN tokens.
-ScCompiler aComp2(mpDoc, pCell-aPos, *pNewCode);
-aComp2.CompileTokenArray();
+// Generate RPN tokens.
+ScCompiler aComp2(mpDoc, pCell-aPos, *pNewCode);
+aComp2.CompileTokenArray();
 
-pCell-SetCode(pNewCode);
-pCell-SetDirty();
+pCell-SetCode(pNewCode);
+pCell-SetDirty();
+}
 }
 }
 };
commit bdc8d5f9e712fce35098352b8c1d9028f4095d8c
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Apr 11 00:34:37 2014 -0400

fdo#77300: Add test for this.

Change-Id: Ib870d8f115b074a4ad80ee6910f92ba8d4b0c01e

diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index acb249a..603e26e 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1222,6 +1222,9 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 m_pDoc-SetString(ScAddress(1,1,0), =SUM(MyRange));
 m_pDoc-SetString(ScAddress(1,2,0), =SUM(MyRange));
 
+// Set single formula with no named range to B5.
+m_pDoc-SetString(ScAddress(1,4,0), =ROW());
+
 // B1:B3 should be grouped.
 ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(1,0,0));
 CPPUNIT_ASSERT(pFC);
@@ -1232,6 +1235,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(1,1,0)));
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(1,2,0)));
 
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(1,4,0)));
+
 // Set a single formula to C1.
 m_pDoc-SetString(ScAddress(2,0,0), =AVERAGE(MyRange));
 pFC = m_pDoc-GetFormulaCell(ScAddress(2,0,0));
@@ -1260,6 +1265,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_FAIL(Wrong formula!);
 if (!checkFormula(*m_pDoc, ScAddress(1,2,0), SUM(MyRange)))
 CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(1,4,0), ROW()))
+CPPUNIT_FAIL(Wrong formula!);
 if (!checkFormula(*m_pDoc, ScAddress(2,0,0), AVERAGE(MyRange)))
 CPPUNIT_FAIL(Wrong formula!);
 
@@ -1267,6 +1274,7 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc-GetValue(ScAddress(1,0,0)));
 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc-GetValue(ScAddress(1,1,0)));
 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc-GetValue(ScAddress(1,2,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(1,4,0)));
 CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc-GetValue(ScAddress(2,0,0)));
 
 m_pDoc-DeleteTab(0);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-04-10 Thread Kohei Yoshida
 sc/qa/unit/ucalc_sharedformula.cxx |   18 ++
 sc/source/core/data/column4.cxx|   35 +++
 2 files changed, 37 insertions(+), 16 deletions(-)

New commits:
commit 0e63ca4fde4e446f346e35849c756a30ca294aab
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Apr 11 00:55:10 2014 -0400

fdo#77300: Do the same for the shared formula case as well.

Change-Id: I560b0beabe81907e3f85d8845041a9df25d2200d

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 7d87177..ec938d8 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -637,23 +637,26 @@ public:
 ScFormulaCell* pTop = *rEntry.mpCells;
 OUString aFormula = pTop-GetHybridFormula();
 
-// Create a new token array from the hybrid formula string, and
-// set it to the group.
-ScCompiler aComp(mrCompileFormulaCxt, pTop-aPos);
-ScTokenArray* pNewCode = aComp.CompileString(aFormula);
-ScFormulaCellGroupRef xGroup = pTop-GetCellGroup();
-assert(xGroup);
-xGroup-setCode(pNewCode);
-xGroup-compileCode(*mpDoc, pTop-aPos, mpDoc-GetGrammar());
-
-// Propagate the new token array to all formula cells in the group.
-ScFormulaCell** pp = rEntry.mpCells;
-ScFormulaCell** ppEnd = pp + rEntry.mnLength;
-for (; pp != ppEnd; ++pp)
+if (!aFormula.isEmpty())
 {
-ScFormulaCell* p = *pp;
-p-SyncSharedCode();
-p-SetDirty();
+// Create a new token array from the hybrid formula string, and
+// set it to the group.
+ScCompiler aComp(mrCompileFormulaCxt, pTop-aPos);
+ScTokenArray* pNewCode = aComp.CompileString(aFormula);
+ScFormulaCellGroupRef xGroup = pTop-GetCellGroup();
+assert(xGroup);
+xGroup-setCode(pNewCode);
+xGroup-compileCode(*mpDoc, pTop-aPos, mpDoc-GetGrammar());
+
+// Propagate the new token array to all formula cells in the 
group.
+ScFormulaCell** pp = rEntry.mpCells;
+ScFormulaCell** ppEnd = pp + rEntry.mnLength;
+for (; pp != ppEnd; ++pp)
+{
+ScFormulaCell* p = *pp;
+p-SyncSharedCode();
+p-SetDirty();
+}
 }
 }
 else
commit ed9d606306cc66ec89e9a6696494b6cdefd9b208
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Apr 11 00:53:49 2014 -0400

fdo#77300: Add more test to cover the shared formula case.

Change-Id: I076cb7b8d5f9b51e7337a512bb86efbabee021a8

diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index 603e26e..d482216 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1225,17 +1225,29 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 // Set single formula with no named range to B5.
 m_pDoc-SetString(ScAddress(1,4,0), =ROW());
 
+// Set shared formula with no named range to B7:B8.
+m_pDoc-SetString(ScAddress(1,6,0), =ROW());
+m_pDoc-SetString(ScAddress(1,7,0), =ROW());
+
 // B1:B3 should be grouped.
 ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(1,0,0));
 CPPUNIT_ASSERT(pFC);
 CPPUNIT_ASSERT_EQUAL(static_castSCROW(0), pFC-GetSharedTopRow());
 CPPUNIT_ASSERT_EQUAL(static_castSCROW(3), pFC-GetSharedLength());
 
+// B7:B8 should be grouped.
+pFC = m_pDoc-GetFormulaCell(ScAddress(1,6,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(6), pFC-GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_castSCROW(2), pFC-GetSharedLength());
+
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(1,0,0)));
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(1,1,0)));
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(1,2,0)));
 
 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(1,4,0)));
+CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc-GetValue(ScAddress(1,6,0)));
+CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc-GetValue(ScAddress(1,7,0)));
 
 // Set a single formula to C1.
 m_pDoc-SetString(ScAddress(2,0,0), =AVERAGE(MyRange));
@@ -1267,6 +1279,10 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_FAIL(Wrong formula!);
 if (!checkFormula(*m_pDoc, ScAddress(1,4,0), ROW()))
 CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(1,6,0), ROW()))
+CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(1,7,0), ROW()))
+CPPUNIT_FAIL(Wrong formula!);
 if (!checkFormula(*m_pDoc, ScAddress(2,0,0), AVERAGE(MyRange)))
 CPPUNIT_FAIL(Wrong formula!);
 
@@ -1275,6 +1291,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-28 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |   48 ++
 sc/qa/unit/ucalc.hxx |2 
 sc/source/core/data/document.cxx |  101 ---
 3 files changed, 82 insertions(+), 69 deletions(-)

New commits:
commit 2ec45841b97a994ef9dca854e142598a063877fd
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Mar 28 20:50:29 2014 -0400

rhbz#1080196: Delete the destination first then paste.

Deleting in-between pasting was causing the block iterators to become
invalid when the deletion took place, which resulted in a segfault.

Also cleaned up the bits about handling filtered rows.  It was using the
old row flag which is empty these days (so it never would have worked).
Plus we do bail out earlier if the destination contains a filtered row.

Change-Id: I78d3ee8bce1647c1c8685f92a3df3c38cc014811

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index e9417bf..421d64e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2820,21 +2820,6 @@ void ScDocument::CopyFromClip( const ScRange 
rDestRange, const ScMarkData rMar
 pClipDoc-GetClipParam().mbCutMode = false;
 }
 
-static SCROW lcl_getLastNonFilteredRow(
-const ScBitMaskCompressedArraySCROW, sal_uInt8 rFlags, SCROW nBegRow, 
SCROW nEndRow,
-SCROW nRowCount)
-{
-SCROW nFilteredRow = rFlags.GetFirstForCondition(
-nBegRow, nEndRow, CR_FILTERED, CR_FILTERED);
-
-SCROW nRow = nFilteredRow - 1;
-if (nRow - nBegRow + 1  nRowCount)
-// make sure the row range stays within the data size.
-nRow = nBegRow + nRowCount - 1;
-
-return nRow;
-}
-
 void ScDocument::CopyMultiRangeFromClip(
 const ScAddress rDestPos, const ScMarkData rMark, sal_uInt16 nInsFlag, 
ScDocument* pClipDoc,
 bool bResetCut, bool bAsLink, bool /*bIncludeFiltered*/, bool 
bSkipAttrForEmpty)
@@ -2846,83 +2831,62 @@ void ScDocument::CopyMultiRangeFromClip(
 // There is nothing in the clip doc to copy.
 return;
 
-bool bOldAutoCalc = GetAutoCalc();
-SetAutoCalc( false );   // avoid multiple recalculations
+// Right now, we don't allow pasting into filtered rows, so we don't even 
handle it here.
 
+sc::AutoCalcSwitch aACSwitch(*this, false); // turn of auto calc 
temporarily.
 NumFmtMergeHandler aNumFmtMergeHdl(this, pClipDoc);
 
+ScRange aDestRange;
+rMark.GetMarkArea(aDestRange);
+
+bInsertingFromOtherDoc = true;  // kein Broadcast/Listener aufbauen bei 
Insert
+
 SCCOL nCol1 = rDestPos.Col();
 SCROW nRow1 = rDestPos.Row();
 ScClipParam rClipParam = pClipDoc-GetClipParam();
 
+if (!bSkipAttrForEmpty)
+{
+// Do the deletion first.
+sal_uInt16 nDelFlag = IDF_CONTENTS;
+SCCOL nColSize = rClipParam.getPasteColSize();
+SCROW nRowSize = rClipParam.getPasteRowSize();
+
+DeleteArea(nCol1, nRow1, nCol1+nColSize-1, nRow1+nRowSize-1, rMark, 
nDelFlag);
+}
+
 sc::CopyFromClipContext aCxt(*this, NULL, pClipDoc, nInsFlag, bAsLink, 
bSkipAttrForEmpty);
 std::pairSCTAB,SCTAB aTabRanges = getMarkedTableRange(maTabs, rMark);
 aCxt.setTabRange(aTabRanges.first, aTabRanges.second);
 
-ScRange aDestRange;
-rMark.GetMarkArea(aDestRange);
-SCROW nLastMarkedRow = aDestRange.aEnd.Row();
-
-bInsertingFromOtherDoc = true;  // kein Broadcast/Listener aufbauen bei 
Insert
-
-SCROW nBegRow = nRow1;
-sal_uInt16 nDelFlag = IDF_CONTENTS;
-const ScBitMaskCompressedArraySCROW, sal_uInt8 rFlags = 
GetRowFlagsArray(aCxt.getTabStart());
-
-for ( size_t i = 0, n = rClipParam.maRanges.size(); i  n; ++i )
+for (size_t i = 0, n = rClipParam.maRanges.size(); i  n; ++i)
 {
-ScRange* p = rClipParam.maRanges[ i ];
-// The begin row must not be filtered.
+ScRange* p = rClipParam.maRanges[i];
 
 SCROW nRowCount = p-aEnd.Row() - p-aStart.Row() + 1;
-
 SCsCOL nDx = static_castSCsCOL(nCol1 - p-aStart.Col());
-SCsROW nDy = static_castSCsROW(nBegRow - p-aStart.Row());
+SCsROW nDy = static_castSCsROW(nRow1 - p-aStart.Row());
 SCCOL nCol2 = nCol1 + p-aEnd.Col() - p-aStart.Col();
+SCROW nEndRow = nRow1 + nRowCount - 1;
 
-SCROW nEndRow = lcl_getLastNonFilteredRow(rFlags, nBegRow, 
nLastMarkedRow, nRowCount);
-
-if (!bSkipAttrForEmpty)
-DeleteArea(nCol1, nBegRow, nCol2, nEndRow, rMark, nDelFlag);
+CopyBlockFromClip(aCxt, nCol1, nRow1, nCol2, nEndRow, rMark, nDx, nDy);
 
-CopyBlockFromClip(aCxt, nCol1, nBegRow, nCol2, nEndRow, rMark, nDx, 
nDy);
-nRowCount -= nEndRow - nBegRow + 1;
-
-while (nRowCount  0)
+switch (rClipParam.meDirection)
 {
-// Get the first non-filtered row.
-SCROW nNonFilteredRow = rFlags.GetFirstForCondition(nEndRow+1, 
nLastMarkedRow, CR_FILTERED, 0);
-if (nNonFilteredRow  

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-25 Thread Eike Rathke
 sc/qa/unit/data/xls/enhanced-protection.xls |binary
 sc/qa/unit/filters-test.cxx |   20 
 sc/source/core/data/tabprotection.cxx   |   27 +++
 3 files changed, 47 insertions(+)

New commits:
commit e27cc864be4d18d5bf307c58ebf1c1aa4ef90078
Author: Eike Rathke er...@redhat.com
Date:   Tue Mar 25 20:41:52 2014 +0100

added unit test for .xls BIFF enhanced protection

Change-Id: I8f218f8f8ce12525b4c9995567d2864baa610c0b

diff --git a/sc/qa/unit/data/xls/enhanced-protection.xls 
b/sc/qa/unit/data/xls/enhanced-protection.xls
new file mode 100644
index 000..00cc6e6
Binary files /dev/null and b/sc/qa/unit/data/xls/enhanced-protection.xls differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 4de62d1..9d049f7 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -31,6 +31,7 @@
 #include drwlayer.hxx
 #include userdat.hxx
 #include formulacell.hxx
+#include tabprotection.hxx
 
 #include svx/svdpage.hxx
 
@@ -69,6 +70,7 @@ public:
 void testSharedFormulaXLS();
 void testSharedFormulaXLSX();
 void testLegacyCellAnchoredRotatedShape();
+void testEnhancedProtectionXLS();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testCVEs);
@@ -82,6 +84,7 @@ public:
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testSharedFormulaXLSX);
 CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape);
+CPPUNIT_TEST(testEnhancedProtectionXLS);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -491,6 +494,23 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
 }
 }
 
+void ScFiltersTest::testEnhancedProtectionXLS()
+{
+ScDocShellRef xDocSh = loadDoc(enhanced-protection., XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh-GetDocument();
+
+const ScTableProtection* pProt = pDoc-GetTabProtection(0);
+
+CPPUNIT_ASSERT( !pProt-isBlockEditable( ScRange( 0, 0, 0, 0, 0, 0)));  // 
locked
+CPPUNIT_ASSERT(  pProt-isBlockEditable( ScRange( 0, 1, 0, 0, 1, 0)));  // 
editable without password
+CPPUNIT_ASSERT(  pProt-isBlockEditable( ScRange( 0, 2, 0, 0, 2, 0)));  // 
editable without password
+CPPUNIT_ASSERT( !pProt-isBlockEditable( ScRange( 0, 3, 0, 0, 3, 0)));  // 
editable with password foo
+CPPUNIT_ASSERT(  pProt-isBlockEditable( ScRange( 0, 1, 0, 0, 2, 0)));  // 
union of two different editables
+CPPUNIT_ASSERT( !pProt-isBlockEditable( ScRange( 0, 0, 0, 0, 1, 0)));  // 
union of locked and editable
+CPPUNIT_ASSERT( !pProt-isBlockEditable( ScRange( 0, 2, 0, 0, 3, 0)));  // 
union of editable and password editable
+}
+
 ScFiltersTest::ScFiltersTest()
   : ScBootstrapFixture( /sc/qa/unit/data )
 {
commit 98c6b4149e46eec6aaee5b64f2fa40678589dd4b
Author: Eike Rathke er...@redhat.com
Date:   Tue Mar 25 20:39:10 2014 +0100

union of a to be edited range may be distributed over two different records

Change-Id: I1d0047e04394a79134beef35ba0cfe6a8ca1

diff --git a/sc/source/core/data/tabprotection.cxx 
b/sc/source/core/data/tabprotection.cxx
index 161cf65..a8aa278 100644
--- a/sc/source/core/data/tabprotection.cxx
+++ b/sc/source/core/data/tabprotection.cxx
@@ -434,6 +434,33 @@ bool ScTableProtectionImpl::isBlockEditable( const 
ScRange rRange ) const
 }
 }
 
+// Ranges may even be distributed over different protection records, for
+// example if they are assigned different names, and can have different
+// passwords. Combine the ones that can be edited.
+/* TODO: once we handle passwords, remember a successful unlock at
+ * ScEnhancedProtection so we can use that here. */
+ScRangeList aRangeList;
+for (::std::vectorScEnhancedProtection::const_iterator 
it(maEnhancedProtection.begin()),
+itEnd(maEnhancedProtection.end()); it != itEnd; ++it)
+{
+if ((*it).maSecurityDescriptor.empty()  (*it).maRangeList.Is())
+{
+// Ranges are editable if no password is assigned.
+if (!(*it).mnPasswordVerifier)
+{
+const ScRangeList rRanges = *(*it).maRangeList;
+size_t nRanges = rRanges.size();
+for (size_t i=0; i  nRanges; ++i)
+{
+aRangeList.Append( *rRanges[i]);
+}
+}
+}
+}
+ScRangeList aResultList( aRangeList.GetIntersectedRange( rRange));
+if (aResultList.size() == 1  *aResultList[0] == rRange)
+return true;
+
 return false;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-13 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|6 ++
 sc/qa/unit/ucalc.hxx|1 +
 sc/qa/unit/ucalc_formula.cxx|   18 +-
 sc/source/core/data/dociter.cxx |4 +++-
 4 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit c078d5fef98ba77751b7a9593691d88dfc1c9ba1
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Mar 13 10:22:25 2014 -0400

fdo#75642: Check the high position block correctly.

Change-Id: I25deabf69e78c6e0354e8a528ab88891a30f9aec

diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 481796c..3a1e7d9 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1538,7 +1538,9 @@ public:
 // Move to the last position of the previous block.
 decBlock(aHiPos);
 
-if (aHiPos.first == mrCells.begin())
+// Check the row postion of the end of the previous block, and 
make sure it's valid.
+SCROW nBlockEndRow = aHiPos.first-position + aHiPos.first-size - 
1;
+if (nBlockEndRow  nStartRow)
 {
 mbValid = false;
 return;
commit e5802954853a9ec64fb5fec917f8c3b2daba6526
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Mar 13 09:53:23 2014 -0400

fdo#75642: Add test case for this.

Change-Id: I220cc3aeac79325e7664461d3bd5219e9e1f04f7

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3c809a8..ed5e894 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5575,6 +5575,12 @@ void Test::clearRange(ScDocument* pDoc, const ScRange 
rRange)
 rRange.aEnd.Col(), rRange.aEnd.Row(), aMarkData, IDF_CONTENTS);
 }
 
+void Test::clearSheet(ScDocument* pDoc, SCTAB nTab)
+{
+ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
+clearRange(pDoc, aRange);
+}
+
 void Test::copyToClip(ScDocument* pSrcDoc, const ScRange rRange, ScDocument* 
pClipDoc)
 {
 ScClipParam aClipParam(rRange, false);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index d17c8f5..68f5bc4 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -42,6 +42,7 @@ public:
 static bool insertRangeNames(ScDocument* pDoc, const RangeNameDef* p, 
const RangeNameDef* pEnd);
 static void printRange(ScDocument* pDoc, const ScRange rRange, const 
char* pCaption);
 static void clearRange(ScDocument* pDoc, const ScRange rRange);
+static void clearSheet(ScDocument* pDoc, SCTAB nTab);
 static void copyToClip(ScDocument* pSrcDoc, const ScRange rRange, 
ScDocument* pClipDoc);
 static void pasteFromClip(ScDocument* pDestDoc, const ScRange rDestRange, 
ScDocument* pClipDoc);
 static ScUndoPaste* createUndoPaste(ScDocShell rDocSh, const ScRange 
rRange, ScDocument* pUndoDoc);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 3fcc896..8bf8435 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2458,7 +2458,7 @@ void Test::testFuncVLOOKUP()
 }
 
 // Clear the sheet and start over.
-clearRange(m_pDoc, ScRange(0,0,0,MAXCOL,MAXROW,0));
+clearSheet(m_pDoc, 0);
 
 // Lookup on sorted data intersparsed with empty cells.
 
@@ -2492,6 +2492,22 @@ void Test::testFuncVLOOKUP()
 CPPUNIT_ASSERT_EQUAL(OUString(Four), 
m_pDoc-GetString(ScAddress(4,3,0)));
 CPPUNIT_ASSERT_EQUAL(OUString(Four), 
m_pDoc-GetString(ScAddress(4,4,0)));
 
+// Start over again.
+clearSheet(m_pDoc, 0);
+
+// Set A,B,,G to A1:A7.
+m_pDoc-SetString(ScAddress(0,0,0), A);
+m_pDoc-SetString(ScAddress(0,1,0), B);
+m_pDoc-SetString(ScAddress(0,2,0), C);
+m_pDoc-SetString(ScAddress(0,3,0), D);
+m_pDoc-SetString(ScAddress(0,4,0), E);
+m_pDoc-SetString(ScAddress(0,5,0), F);
+m_pDoc-SetString(ScAddress(0,6,0), G);
+
+// Set the formula in C1.
+m_pDoc-SetString(ScAddress(2,0,0), =VLOOKUP(\C\;A1:A16;1));
+CPPUNIT_ASSERT_EQUAL(OUString(C), m_pDoc-GetString(ScAddress(2,0,0)));
+
 m_pDoc-DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-13 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   31 +++
 sc/source/core/data/column4.cxx |   35 +--
 2 files changed, 56 insertions(+), 10 deletions(-)

New commits:
commit 36bcab7859b7dfa1f1377bb5865c881742f178dd
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Mar 13 16:08:03 2014 -0400

fdo#76132: Don't create a formula group of length 1.

That's asking for trouble.

Change-Id: I6aaa4d1e2aed4f166ee216c3eb02d3b7794c9a8c

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index fa18818..2f21623 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -334,25 +334,40 @@ void ScColumn::CloneFormulaCell( const ScFormulaCell 
rSrc, const std::vectorsc
 {
 SCROW nRow1 = itSpan-mnRow1, nRow2 = itSpan-mnRow2;
 size_t nLen = nRow2 - nRow1 + 1;
+assert(nLen  0);
 aFormulas.clear();
 aFormulas.reserve(nLen);
 
 ScAddress aPos(nCol, nRow1, nTab);
-ScFormulaCellGroupRef xGroup(new ScFormulaCellGroup);
-xGroup-setCode(*rSrc.GetCode());
-xGroup-compileCode(*pDocument, aPos, pDocument-GetGrammar());
-for (size_t i = 0; i  nLen; ++i, aPos.IncRow())
+
+if (nLen == 1)
 {
-ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, xGroup);
-if (i == 0)
-{
-xGroup-mpTopCell = pCell;
-xGroup-mnLength = nLen;
-}
+// Single, ungrouped formula cell.
+ScFormulaCell* pCell =
+new ScFormulaCell(rSrc, *pDocument, aPos, 
pDocument-GetGrammar());
 pCell-StartListeningTo(aCxt);
 pCell-SetDirty();
 aFormulas.push_back(pCell);
 }
+else
+{
+// Create a group of formula cells.
+ScFormulaCellGroupRef xGroup(new ScFormulaCellGroup);
+xGroup-setCode(*rSrc.GetCode());
+xGroup-compileCode(*pDocument, aPos, pDocument-GetGrammar());
+for (size_t i = 0; i  nLen; ++i, aPos.IncRow())
+{
+ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, 
xGroup);
+if (i == 0)
+{
+xGroup-mpTopCell = pCell;
+xGroup-mnLength = nLen;
+}
+pCell-StartListeningTo(aCxt);
+pCell-SetDirty();
+aFormulas.push_back(pCell);
+}
+}
 
 itPos = maCells.set(itPos, nRow1, aFormulas.begin(), aFormulas.end());
 
commit ce524556df4bf06cde1229475b9de9822a89f62b
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Mar 13 14:43:06 2014 -0400

fdo#76132: Write test for this first.

The crash is a result of the pasted formula cell (single cell) being marked
shared, which should never happen.

Change-Id: I7b7fa536c520c76b56cce78457e11b6e2eaee76f

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ed5e894..c903f4f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3765,6 +3765,37 @@ void Test::testCopyPasteRelativeFormula()
 // B2 references A2, so the value should be 1.
 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(1,1,0)));
 
+// Clear content and start over.
+clearSheet(m_pDoc, 0);
+clearSheet(aClipDoc, 0);
+
+// Insert a single formula cell in A1.
+m_pDoc-SetString(ScAddress(0,0,0), =ROW());
+const ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(0,0,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT(!pFC-IsShared()); // single formula cell is never shared.
+
+// Copy A1 to clipboard.
+aClipParam = ScClipParam(ScAddress(0,0,0), false);
+m_pDoc-CopyToClip(aClipParam, aClipDoc, aMark);
+
+pFC = aClipDoc.GetFormulaCell(ScAddress(0,0,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT(!pFC-IsShared());
+
+// Paste to A3.
+aDestRange = ScRange(0,2,0,0,2,0);
+aMark.SetMarkArea(aDestRange);
+m_pDoc-CopyFromClip(aDestRange, aMark, nFlags, NULL, aClipDoc);
+
+pFC = m_pDoc-GetFormulaCell(ScAddress(0,2,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT(!pFC-IsShared());
+
+// Delete A3 and make sure it doesn't crash (see fdo#76132).
+clearRange(m_pDoc, ScAddress(0,2,0));
+CPPUNIT_ASSERT(m_pDoc-GetCellType(ScAddress(0,2,0)) == CELLTYPE_NONE);
+
 m_pDoc-DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-13 Thread Kohei Yoshida
 sc/qa/unit/data/xlsx/row-index-1-based.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx  |   39 
 sc/source/filter/inc/sheetdatacontext.hxx   |4 +-
 sc/source/filter/oox/sheetdatacontext.cxx   |4 +-
 4 files changed, 43 insertions(+), 4 deletions(-)

New commits:
commit ff56553e34dfed01b9226ce7a516dbeb6da32124
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Mar 13 18:01:21 2014 -0400

fdo#76032: This row index is 1-based whereas our own mnRow is 0-based.

Change-Id: I098d300532bef164bef0d40ebf62a6848bc19cb8

diff --git a/sc/source/filter/inc/sheetdatacontext.hxx 
b/sc/source/filter/inc/sheetdatacontext.hxx
index dba7a7e..e352cd0 100644
--- a/sc/source/filter/inc/sheetdatacontext.hxx
+++ b/sc/source/filter/inc/sheetdatacontext.hxx
@@ -129,8 +129,8 @@ private:
 boolmbHasFormula;   /// True = current cell has 
formula data (OOXML only).
 boolmbValidRange;   /// True = maFmlaData.maFormulaRef 
is valid (OOXML only).
 
-sal_Int32 mnRow;
-sal_Int32 mnCol;
+sal_Int32 mnRow; /// row index (0-based)
+sal_Int32 mnCol; /// column index (0-based)
 };
 
 
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx 
b/sc/source/filter/oox/sheetdatacontext.cxx
index 9628e78..4d2c57a 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -279,11 +279,11 @@ ContextHandlerRef 
SheetDataContext::onCreateRecordContext( sal_Int32 nRecId, Seq
 void SheetDataContext::importRow( const AttributeList rAttribs )
 {
 RowModel aModel;
-sal_Int32 nRow = rAttribs.getInteger( XML_r, -1 );
+sal_Int32 nRow = rAttribs.getInteger( XML_r, -1 ); // 1-based row index
 if(nRow != -1)
 {
 aModel.mnRow = nRow;
-mnRow = nRow;
+mnRow = nRow-1; // to 0-based row index.
 }
 else
 aModel.mnRow = ++mnRow;
commit a145e8859c5a878110ec1b346f244c51d1e5a80b
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Mar 13 18:00:19 2014 -0400

fdo#76032: Write test for this.

Change-Id: Iec8d32a4e53d2d5d3cdc9767c2ede7654fe2bdd6

diff --git a/sc/qa/unit/data/xlsx/row-index-1-based.xlsx 
b/sc/qa/unit/data/xlsx/row-index-1-based.xlsx
new file mode 100644
index 000..1f60c3b
Binary files /dev/null and b/sc/qa/unit/data/xlsx/row-index-1-based.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index f22e1e2..66bfb94 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -127,6 +127,12 @@ public:
 //change this test file only in excel and not in calc
 void testCellValueXLSX();
 
+/**
+ * Test importing of xlsx document that previously had its row index off
+ * by one. (fdo#76032)
+ */
+void testRowIndex1BasedXLSX();
+
 //misc tests unrelated to the import filters
 void testPasswordNew();
 void testPasswordOld();
@@ -195,6 +201,7 @@ public:
 CPPUNIT_TEST(testDataTableMultiTableXLSX);
 CPPUNIT_TEST(testBrokenQuotesCSV);
 CPPUNIT_TEST(testCellValueXLSX);
+CPPUNIT_TEST(testRowIndex1BasedXLSX);
 CPPUNIT_TEST(testControlImport);
 CPPUNIT_TEST(testChartImportODS);
 
@@ -1417,6 +1424,38 @@ void ScFiltersTest::testCellValueXLSX()
 xDocSh-DoClose();
 }
 
+void ScFiltersTest::testRowIndex1BasedXLSX()
+{
+ScDocShellRef xDocSh = loadDoc(row-index-1-based., XLSX);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh-GetDocument();
+
+// A1
+OUString aStr = pDoc-GetString(ScAddress(0,0,0));
+CPPUNIT_ASSERT_EQUAL(OUString(Action Plan.Name), aStr);
+
+// B1
+aStr = pDoc-GetString(ScAddress(1,0,0));
+CPPUNIT_ASSERT_EQUAL(OUString(Action Plan.Description), aStr);
+
+// A2
+aStr = pDoc-GetString(ScAddress(0,1,0));
+CPPUNIT_ASSERT_EQUAL(OUString(Jerry), aStr);
+
+// B2 - multi-line text.
+const EditTextObject* pText = pDoc-GetEditText(ScAddress(1,1,0));
+CPPUNIT_ASSERT(pText);
+CPPUNIT_ASSERT(pText-GetParagraphCount() == 3);
+aStr = pText-GetText(0);
+CPPUNIT_ASSERT_EQUAL(OUString(This is a longer Text.), aStr);
+aStr = pText-GetText(1);
+CPPUNIT_ASSERT_EQUAL(OUString(Second line.), aStr);
+aStr = pText-GetText(2);
+CPPUNIT_ASSERT_EQUAL(OUString(Third line.), aStr);
+
+xDocSh-DoClose();
+}
+
 void ScFiltersTest::testPassword_Impl(const OUString aFileNameBase)
 {
 OUString aFileExtension(getFileFormats()[0].pName, 
strlen(getFileFormats()[0].pName), RTL_TEXTENCODING_UTF8 );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-10 Thread Kohei Yoshida
 sc/qa/unit/data/xlsx/shared-formula/3d-reference.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx |   74 ++
 sc/source/filter/excel/xecontent.cxx  |   12 +-
 sc/source/filter/excel/xeextlst.cxx   |2 
 sc/source/filter/excel/xeroot.cxx |6 -
 sc/source/filter/excel/xestream.cxx   |   17 
 sc/source/filter/excel/xetable.cxx|4 
 sc/source/filter/inc/xeroot.hxx   |2 
 sc/source/filter/inc/xestream.hxx |4 
 sc/source/filter/xcl97/XclExpChangeTrack.cxx  |3 
 10 files changed, 87 insertions(+), 37 deletions(-)

New commits:
commit ca8ca8c28742879220f3ff88ae0d71c8d69b11cd
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Mar 10 14:02:00 2014 -0400

fdo#75950: Just set the right grammar and be done with it.

Using the Excel A1 syntax with custom opcode was probably a hack back
in the day.  These days we can just set the right grammar and expect the
compiler to do the right thing.

Change-Id: Iae98f9f09a7da0b7b9549e06308d5d313bbff1ea

diff --git a/sc/source/filter/excel/xecontent.cxx 
b/sc/source/filter/excel/xecontent.cxx
index 14baaea..0df97bb 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -946,13 +946,13 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream rStrm )
 {
 rWorksheet-startElement( XML_formula, FSEND );
 rWorksheet-write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
mrFormatEntry.GetValidSrcPos(),
-mrFormatEntry.CreateTokenArry( 0 ), 
GetRoot().GetOpCodeMap() ));
+mrFormatEntry.CreateTokenArry(0)));
 rWorksheet-endElement( XML_formula );
 if (bFmla2)
 {
 rWorksheet-startElement( XML_formula, FSEND );
 rWorksheet-write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
mrFormatEntry.GetValidSrcPos(),
-mrFormatEntry.CreateTokenArry( 1 ), 
GetRoot().GetOpCodeMap() ));
+mrFormatEntry.CreateTokenArry(1)));
 rWorksheet-endElement( XML_formula );
 }
 }
@@ -1093,7 +1093,7 @@ void XclExpCfvo::SaveXml( XclExpXmlStream rStrm )
 if(mrEntry.GetType() == COLORSCALE_FORMULA)
 {
 OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
maSrcPos,
-mrEntry.GetFormula()-Clone(), GetRoot().GetOpCodeMap() );
+mrEntry.GetFormula()-Clone());
 aValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
 }
 else
@@ -1602,7 +1602,7 @@ XclExpDV::XclExpDV( const XclExpRoot rRoot, sal_uLong 
nScHandle ) :
 CreateDataValFormula() and CreateListValFormula(). */
 mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_LISTVAL, 
*xScTokArr );
 msFormula1 = XclXmlUtils::ToOUString( GetDoc(), 
pValData-GetSrcPos(),
-xScTokArr.get(), GetRoot().GetOpCodeMap() );
+xScTokArr.get());
 }
 }
 else
@@ -1610,7 +1610,7 @@ XclExpDV::XclExpDV( const XclExpRoot rRoot, sal_uLong 
nScHandle ) :
 // no list validation - convert the formula
 mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, 
*xScTokArr );
 msFormula1 = XclXmlUtils::ToOUString( GetDoc(), 
pValData-GetSrcPos(),
-xScTokArr.get(), GetRoot().GetOpCodeMap() );
+xScTokArr.get());
 }
 }
 
@@ -1620,7 +1620,7 @@ XclExpDV::XclExpDV( const XclExpRoot rRoot, sal_uLong 
nScHandle ) :
 {
 mxTokArr2 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, 
*xScTokArr );
 msFormula2 = XclXmlUtils::ToOUString( GetDoc(), 
pValData-GetSrcPos(),
-xScTokArr.get(), GetRoot().GetOpCodeMap() );
+xScTokArr.get());
 }
 }
 else
diff --git a/sc/source/filter/excel/xeextlst.cxx 
b/sc/source/filter/excel/xeextlst.cxx
index 92fb6c6..852647c 100644
--- a/sc/source/filter/excel/xeextlst.cxx
+++ b/sc/source/filter/excel/xeextlst.cxx
@@ -63,7 +63,7 @@ XclExpExtCfvo::XclExpExtCfvo( const XclExpRoot rRoot, const 
ScColorScaleEntry
 if(pArr)
 {
 aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), rSrcPos,
-pArr-Clone(), GetRoot().GetOpCodeMap() );
+pArr-Clone());
 }
 maValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
 }
diff --git a/sc/source/filter/excel/xeroot.cxx 
b/sc/source/filter/excel/xeroot.cxx
index 88ab3e3..3da4427 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -167,12 +167,6 @@ XclExpPivotTableManager 
XclExpRoot::GetPivotTableManager() const
 return *mrExpData.mxPTableMgr;
 }
 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-10 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx   |2 
 sc/qa/unit/ucalc_sharedformula.cxx |   87 +
 sc/source/core/tool/token.cxx  |   19 
 3 files changed, 108 insertions(+)

New commits:
commit dd7787ed75e33b65ebee2a6c0aa152efded6f1b8
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Mar 10 20:39:01 2014 -0400

fdo#75815: Adjust external references here too.

Adjusting external references are much simpler than adjusting internal
ones since we don't need to worry about deleted references etc.

Change-Id: I82111e383e1fc6976ef08c1438c3dd916a249af6

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index eee7c9d2..8057224 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2751,6 +2751,25 @@ sc::RefUpdateResult 
ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
 rRef.SetRange(aAbs, aNewPos);
 }
 break;
+case svExternalSingleRef:
+{
+// For external reference, just reset the reference with
+// respect to the new cell position.
+ScToken* pToken = static_castScToken*(*p);
+ScSingleRefData rRef = pToken-GetSingleRef();
+ScAddress aAbs = rRef.toAbs(rOldPos);
+rRef.SetAddress(aAbs, aNewPos);
+}
+break;
+case svExternalDoubleRef:
+{
+// Same as above.
+ScToken* pToken = static_castScToken*(*p);
+ScComplexRefData rRef = pToken-GetDoubleRef();
+ScRange aAbs = rRef.toAbs(rOldPos);
+rRef.SetRange(aAbs, aNewPos);
+}
+break;
 case svIndex:
 {
 const formula::FormulaToken* pToken = *p;
commit 149b580900214c477f8eaf9dd51342796d27b296
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Mar 10 19:27:21 2014 -0400

fdo#75815: Write test for this first.

Change-Id: I2a5a1964dc6496aa4db15c9e8644692b460d0527

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 7c40fb8..58dc083 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -262,6 +262,7 @@ public:
 void testSharedFormulas();
 void testSharedFormulasRefUpdate();
 void testSharedFormulasRefUpdateRange();
+void testSharedFormulasRefUpdateExternal();
 void testSharedFormulasDeleteRows();
 void testSharedFormulasDeleteColumns();
 void testSharedFormulasRefUpdateMoveSheets();
@@ -435,6 +436,7 @@ public:
 CPPUNIT_TEST(testSharedFormulas);
 CPPUNIT_TEST(testSharedFormulasRefUpdate);
 CPPUNIT_TEST(testSharedFormulasRefUpdateRange);
+CPPUNIT_TEST(testSharedFormulasRefUpdateExternal);
 CPPUNIT_TEST(testSharedFormulasDeleteRows);
 CPPUNIT_TEST(testSharedFormulasDeleteColumns);
 CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index ae1ad58..98d087d 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -449,6 +449,93 @@ void Test::testSharedFormulasRefUpdateRange()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testSharedFormulasRefUpdateExternal()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+m_pDoc-InsertTab(0, Formula);
+
+// Launch an external document shell.
+ScDocShellRef xExtDocSh = new ScDocShell;
+OUString aExtDocName(file:///extdata.fake);
+
+SfxMedium* pMed = new SfxMedium(aExtDocName, STREAM_STD_READWRITE);
+xExtDocSh-DoInitNew(pMed);
+ScDocument* pExtDoc = xExtDocSh-GetDocument();
+
+// Populate A1:A3.
+pExtDoc-InsertTab(0, Data);
+pExtDoc-SetString(ScAddress(0,0,0), A);
+pExtDoc-SetString(ScAddress(0,1,0), B);
+pExtDoc-SetString(ScAddress(0,2,0), C);
+
+// Insert formula cells in A7:A10 of the host document, referencing A1:A3
+// of the external document.
+m_pDoc-SetString(ScAddress(0,6,0), ='file:///extdata.fake'#$Data.A1);
+m_pDoc-SetString(ScAddress(0,7,0), ='file:///extdata.fake'#$Data.A2);
+m_pDoc-SetString(ScAddress(0,8,0), ='file:///extdata.fake'#$Data.A3);
+m_pDoc-SetString(ScAddress(0,9,0), 
=COUNTA('file:///extdata.fake'#$Data.A1:A3));
+
+// Check the formula results.
+CPPUNIT_ASSERT_EQUAL(OUString(A), m_pDoc-GetString(ScAddress(0,6,0)));
+CPPUNIT_ASSERT_EQUAL(OUString(B), m_pDoc-GetString(ScAddress(0,7,0)));
+CPPUNIT_ASSERT_EQUAL(OUString(C), m_pDoc-GetString(ScAddress(0,8,0)));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc-GetValue(ScAddress(0,9,0)));
+
+// Check the formulas too.
+if (!checkFormula(*m_pDoc, ScAddress(0,6,0), 
'file:///extdata.fake'#$Data.A1))
+CPPUNIT_FAIL(Wrong formula!);
+if (!checkFormula(*m_pDoc, ScAddress(0,7,0), 
'file:///extdata.fake'#$Data.A2))
+CPPUNIT_FAIL(Wrong formula!);
+if 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc_pivottable.cxx  |   25 +
 sc/source/core/data/dpoutput.cxx |4 +++-
 2 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 0919979bd1da3379e030b353a097d8fe1fd8341a
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Mar 9 21:28:05 2014 -0400

fdo#75962: Avoid unwanted number detection when placing page field name.

Change-Id: I1a3c57ec029e03198b8f190acfa8d59e142acaba

diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index adff9b1..704861c 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -1003,7 +1003,9 @@ void ScDPOutput::Output()
 else if (n  1)
 aPageValue = ScResId(SCSTR_MULTIPLE).toString();
 
-pDoc-SetString( nFldCol, nHdrRow, nTab, aPageValue );
+ScSetStringParam aParam;
+aParam.setTextInput();
+pDoc-SetString(nFldCol, nHdrRow, nTab, aPageValue, aParam);
 
 lcl_SetFrame( pDoc,nTab, nFldCol,nHdrRow, nFldCol,nHdrRow, 20 );
 }
commit bd378b6346bf5aca4328c57f2ff3c18932691a47
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Mar 9 21:27:35 2014 -0400

fdo#75962: Write test for this first.

Change-Id: I731b4cbf72066f8a0cbabb5040acfe9c828afd8f

diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx
index 00e83b9..7ad0c1e 100644
--- a/sc/qa/unit/ucalc_pivottable.cxx
+++ b/sc/qa/unit/ucalc_pivottable.cxx
@@ -1668,6 +1668,31 @@ void Test::testPivotTableTextNumber()
 CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
 }
 
+// Set the Name dimension to page dimension.
+pDPObj-BuildAllDimensionMembers();
+ScDPSaveData aSaveData(*pDPObj-GetSaveData());
+ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName(Name);
+CPPUNIT_ASSERT(pDim);
+pDim-SetOrientation(sheet::DataPilotFieldOrientation_PAGE);
+OUString aVisiblePage(0004);
+pDim-SetCurrentPage(aVisiblePage);
+pDPObj-SetSaveData(aSaveData);
+
+aOutRange = refresh(pDPObj);
+
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][2] = {
+{ Name, 0004 },
+{  0, 0 },
+{ Sum - Value, 0 },
+{ 4, 0 }
+};
+
+bSuccess = checkDPTableOutput2(m_pDoc, aOutRange, aOutputCheck, 
Text number field members);
+CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
+}
+
 pDPs-FreeTable(pDPObj);
 CPPUNIT_ASSERT_EQUAL_MESSAGE(There should be no more tables., 
pDPs-GetCount(), static_castsize_t(0));
 CPPUNIT_ASSERT_EQUAL_MESSAGE(There shouldn't be any more cache stored.,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-07 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   36 
 sc/source/core/data/column2.cxx |   10 +-
 2 files changed, 41 insertions(+), 5 deletions(-)

New commits:
commit 01de94471c20a8b9c36d6080638d70e57eac55bf
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Mar 7 14:23:46 2014 -0500

fdo#75718: Correctly count the length of trailing empty range.

This affects auto fill, apparently.

Change-Id: I653918d374122bc9bb938231934c149da79a3306

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 6c6e47e..38eb94e 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1214,13 +1214,13 @@ bool ScColumn::IsNotesEmptyBlock(SCROW nStartRow, SCROW 
nEndRow) const
 
 SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, 
ScDirection eDir ) const
 {
-// Given a range of rows, find a top or bottom empty segment.
+// Given a range of rows, find a top or bottom empty segment.  Skip the 
start row.
 switch (eDir)
 {
 case DIR_TOP:
 {
 // Determine the length of empty head segment.
-size_t nLength = nEndRow - nStartRow + 1;
+size_t nLength = nEndRow - nStartRow;
 std::pairsc::CellStoreType::const_iterator,size_t aPos = 
maCells.position(nStartRow);
 sc::CellStoreType::const_iterator it = aPos.first;
 if (it-type != sc::element_type_empty)
@@ -1234,8 +1234,8 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, 
SCROW nEndRow, ScDirecti
 break;
 case DIR_BOTTOM:
 {
-// Determine the length empty tail segment.
-size_t nLength = nEndRow - nStartRow + 1;
+// Determine the length of empty tail segment.
+size_t nLength = nEndRow - nStartRow;
 std::pairsc::CellStoreType::const_iterator,size_t aPos = 
maCells.position(nEndRow);
 sc::CellStoreType::const_iterator it = aPos.first;
 if (it-type != sc::element_type_empty)
@@ -1243,7 +1243,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, 
SCROW nEndRow, ScDirecti
 return 0;
 
 // length of this empty block from the tip to the end row position.
-size_t nThisLen = aPos.second;
+size_t nThisLen = aPos.second + 1;
 return std::min(nThisLen, nLength);
 }
 break;
commit 9d54a7f67196cac2a5701c06d8dc55f102d0af60
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Mar 7 14:22:49 2014 -0500

fdo#75718: Write unit test for this.

Change-Id: I1f1fe515485209b67f14a1407ee20a88e71c08c9

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bf691c6..a49b6d2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4220,6 +4220,42 @@ void Test::testAutoFill()
 aTestValue = m_pDoc-GetString( 0, i, 0 );
 CPPUNIT_ASSERT_EQUAL( aTestValue, OUString(January) );
 }
+
+// Clear column A for a new test.
+clearRange(m_pDoc, ScRange(0,0,0,0,MAXROW,0));
+m_pDoc-SetRowHidden(0, MAXROW, 0, false); // Show all rows.
+
+// Fill A1:A6 with 1,2,3,4,5,6.
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+m_pDoc-SetValue(ScAddress(0,0,0), 1.0);
+ScRange aRange(0,0,0,0,5,0);
+aMarkData.SetMarkArea(aRange);
+rFunc.FillSeries(aRange, aMarkData, FILL_TO_BOTTOM, FILL_AUTO, FILL_DAY, 
MAXDOUBLE, 1.0, MAXDOUBLE, true, true);
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc-GetValue(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc-GetValue(ScAddress(0,3,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(0,4,0)));
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(0,5,0)));
+
+// Undo should clear the area except for the top cell.
+SfxUndoManager* pUndoMgr = m_pDoc-GetUndoManager();
+CPPUNIT_ASSERT(pUndoMgr);
+pUndoMgr-Undo();
+
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(0,0,0)));
+for (SCROW i = 1; i = 5; ++i)
+CPPUNIT_ASSERT(m_pDoc-GetCellType(ScAddress(0,i,0)) == CELLTYPE_NONE);
+
+// Redo should put the serial values back in.
+pUndoMgr-Redo();
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc-GetValue(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc-GetValue(ScAddress(0,3,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(ScAddress(0,4,0)));
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(0,5,0)));
+
 m_pDoc-DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-03-07 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx |   29 ++
 sc/source/core/tool/interpr6.cxx |   42 +++
 2 files changed, 66 insertions(+), 5 deletions(-)

New commits:
commit d658c092f488fc0d4cb924fe3e34cab997db76e2
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Mar 7 18:03:24 2014 -0500

fdo#75628: SUM should inherit error if one is present in its references.

Change-Id: I94017fe91295dbb929f57be5e3fb26edf5032a8f

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index a32b3c1..b98fb9b 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -210,8 +210,10 @@ namespace {
 class NumericCellAccumulator
 {
 double mfSum;
+sal_uInt16 mnError;
+
 public:
-NumericCellAccumulator() : mfSum(0.0) {}
+NumericCellAccumulator() : mfSum(0.0), mnError(0) {}
 
 void operator() (size_t, double fVal)
 {
@@ -220,11 +222,28 @@ public:
 
 void operator() (size_t, const ScFormulaCell* pCell)
 {
+if (mnError)
+// Skip all the rest if we have an error.
+return;
+
+double fVal = 0.0;
+sal_uInt16 nErr = 0;
 ScFormulaCell rCell = const_castScFormulaCell(*pCell);
-if (rCell.IsValue())
-mfSum += rCell.GetValue();
+if (!rCell.GetErrorOrValue(nErr, fVal))
+// The cell has neither error nor value.  Perhaps string result.
+return;
+
+if (nErr)
+{
+// Cell has error.
+mnError = nErr;
+return;
+}
+
+mfSum += fVal;
 }
 
+sal_uInt16 getError() const { return mnError; }
 double getSum() const { return mfSum; }
 };
 
@@ -299,10 +318,11 @@ class FuncSum : public sc::ColumnSpanSet::ColumnAction
 sc::ColumnBlockConstPosition maPos;
 ScColumn* mpCol;
 double mfSum;
+sal_uInt16 mnError;
 sal_uInt32 mnNumFmt;
 
 public:
-FuncSum() : mpCol(0), mfSum(0.0), mnNumFmt(0) {}
+FuncSum() : mpCol(0), mfSum(0.0), mnError(0), mnNumFmt(0) {}
 
 virtual void startColumn(ScColumn* pCol)
 {
@@ -315,12 +335,20 @@ public:
 if (!bVal)
 return;
 
+if (mnError)
+return;
+
 NumericCellAccumulator aFunc;
 maPos.miCellPos = sc::ParseFormulaNumeric(maPos.miCellPos, 
mpCol-GetCellStore(), nRow1, nRow2, aFunc);
+mnError = aFunc.getError();
+if (mnError)
+return;
+
 mfSum += aFunc.getSum();
 mnNumFmt = mpCol-GetNumberFormat(nRow2);
 };
 
+sal_uInt16 getError() const { return mnError; }
 double getSum() const { return mfSum; }
 sal_uInt32 getNumberFormat() const { return mnNumFmt; }
 };
@@ -806,6 +834,12 @@ void ScInterpreter::ScSum()
 
 FuncSum aAction;
 aSet.executeColumnAction(*pDok, aAction);
+sal_uInt16 nErr = aAction.getError();
+if (nErr)
+{
+SetError(nErr);
+return;
+}
 fRes += aAction.getSum();
 
 // Get the number format of the last iterated cell.
commit 78e6b7a94265507e43dd80182706970f49cdb303
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Mar 7 18:00:24 2014 -0500

fdo#75628: Write unit test for this.

Change-Id: I26e5d0bf4344eeb518222ba036c61eca861c5fcf

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 580e2a3..f4c6f7a 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1841,6 +1841,8 @@ void Test::testFuncSUM()
 CPPUNIT_ASSERT_MESSAGE (failed to insert sheet,
 m_pDoc-InsertTab (0, aTabName));
 
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
 // Single argument case.
 m_pDoc-SetValue(ScAddress(0,0,0), 1);
 m_pDoc-SetValue(ScAddress(0,1,0), 1);
@@ -1864,11 +1866,36 @@ void Test::testFuncSUM()
 m_pDoc-SetString(ScAddress(3,0,0), =SUM(A1:A2;B1:B2));
 m_pDoc-SetString(ScAddress(3,1,0), =SUM(A2:A3;B2:B3));
 m_pDoc-SetString(ScAddress(3,2,0), =SUM(A3:A4;B3:B4));
-m_pDoc-CalcAll();
 CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc-GetValue(ScAddress(3,0,0)));
 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc-GetValue(ScAddress(3,1,0)));
 CPPUNIT_ASSERT_EQUAL(20.0, m_pDoc-GetValue(ScAddress(3,2,0)));
 
+// Clear and start over.
+clearRange(m_pDoc, ScRange(0,0,0,3,MAXROW,0));
+
+// SUM needs to take the first error in case the range contains an error.
+m_pDoc-SetValue(ScAddress(0,0,0), 1.0);
+m_pDoc-SetValue(ScAddress(0,1,0), 10.0);
+m_pDoc-SetValue(ScAddress(0,2,0), 100.0);
+m_pDoc-SetString(ScAddress(0,3,0), =SUM(A1:A3));
+CPPUNIT_ASSERT_EQUAL(111.0, m_pDoc-GetValue(ScAddress(0,3,0)));
+
+// Set #DIV/0! error to A3. A4 should also inherit this error.
+m_pDoc-SetString(ScAddress(0,2,0), =1/0);
+sal_uInt16 nErr = 

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-02-20 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx  |   89 +
 sc/qa/unit/subsequent_filters-test.cxx |   69 -
 sc/source/filter/excel/xestyle.cxx |8 +-
 3 files changed, 93 insertions(+), 73 deletions(-)

New commits:
commit 1c1f42fdbad774cae7c45a7f8d60b9af766dee0a
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Feb 20 11:27:32 2014 -0500

fdo#75130: Export cell borders to xls and xlsx correctly.

Change-Id: Ic629fb4852d2ada9724dfee7618e2436c0fa28a8

diff --git a/sc/source/filter/excel/xestyle.cxx 
b/sc/source/filter/excel/xestyle.cxx
index f4f8ffc..c753228 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -1570,18 +1570,18 @@ void lclGetBorderLine(
 switch (pLine-GetBorderLineStyle())
 {
 case table::BorderLineStyle::DASHED:
+case table::BorderLineStyle::FINE_DASHED:
 rnXclLine = EXC_LINE_DASHED;
 break;
 case table::BorderLineStyle::DOTTED:
 rnXclLine = EXC_LINE_DOTTED;
 break;
-case table::BorderLineStyle::FINE_DASHED:
-rnXclLine = EXC_LINE_HAIR;
-break;
 default:
 break;
 }
 }
+else if (nOuterWidth = EXC_BORDER_HAIR)
+rnXclLine = EXC_LINE_HAIR;
 else
 rnXclLine = EXC_LINE_NONE;
 }
@@ -1726,7 +1726,7 @@ static const char* ToLineStyle( sal_uInt8 nLineStyle )
 case EXC_LINE_HAIR: return hair;
 case EXC_LINE_DOTTED: return dotted;
 case EXC_LINE_DASHED: return dashed;
-case EXC_LINE_MEDIUMDASHED: return mediumdashed;
+case EXC_LINE_MEDIUMDASHED: return mediumDashed;
 }
 return *unknown*;
 }
commit 6d5270dab5c8ea8bae1ac3462aa5f6768f7d2c8f
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Feb 20 11:26:38 2014 -0500

fdo#75130: Move these tests to the export test and test their export.

Change-Id: Ia6a155f12e3b50c5841211d32e0f8ff2de2bc9c8

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 26fc12a..e834ca6 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -42,6 +42,9 @@
 #include editeng/editobj.hxx
 #include editeng/section.hxx
 #include editeng/crossedoutitem.hxx
+#include editeng/borderline.hxx
+
+#include com/sun/star/table/BorderLineStyle.hpp
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -79,6 +82,9 @@ public:
 void testFormulaReferenceXLS();
 void testSheetProtectionXLSX();
 
+void testCellBordersXLS();
+void testCellBordersXLSX();
+
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
 #if !defined(MACOSX)  !defined(DRAGONFLY)
@@ -100,10 +106,14 @@ public:
 CPPUNIT_TEST(testEmbeddedChartXLS);
 CPPUNIT_TEST(testFormulaReferenceXLS);
 CPPUNIT_TEST(testSheetProtectionXLSX);
+CPPUNIT_TEST(testCellBordersXLS);
+CPPUNIT_TEST(testCellBordersXLSX);
 
 CPPUNIT_TEST_SUITE_END();
 
 private:
+void testExcelCellBorders( sal_uLong nFormatType );
+
 uno::Referenceuno::XInterface m_xCalcComponent;
 
 };
@@ -991,6 +1001,85 @@ void ScExportTest::testSheetProtectionXLSX()
 xDocSh-DoClose();
 }
 
+namespace {
+
+const char* toBorderName( sal_Int16 eStyle )
+{
+switch (eStyle)
+{
+case table::BorderLineStyle::SOLID: return SOLID;
+case table::BorderLineStyle::DOTTED: return DOTTED;
+case table::BorderLineStyle::DASHED: return DASHED;
+case table::BorderLineStyle::DOUBLE: return DOUBLE;
+case table::BorderLineStyle::FINE_DASHED: return FINE_DASHED;
+default:
+;
+}
+
+return ;
+}
+
+}
+
+void ScExportTest::testExcelCellBorders( sal_uLong nFormatType )
+{
+ScDocShellRef xDocSh = loadDoc(cell-borders., nFormatType);
+
+CPPUNIT_ASSERT_MESSAGE(Failed to load file, xDocSh.Is());
+ScDocument* pDoc = xDocSh-GetDocument();
+
+struct
+{
+SCROW mnRow;
+sal_Int16 mnStyle;
+long mnWidth;
+} aChecks[] = {
+{  1, table::BorderLineStyle::SOLID,1L }, // hair
+{  3, table::BorderLineStyle::DOTTED,  15L }, // thin
+{  9, table::BorderLineStyle::FINE_DASHED, 15L }, // dashed
+{ 11, table::BorderLineStyle::SOLID,   15L }, // thin
+{ 19, table::BorderLineStyle::DASHED,  35L }, // medium dashed
+{ 21, table::BorderLineStyle::SOLID,   35L }, // medium
+{ 23, table::BorderLineStyle::SOLID,   50L }, // thick
+{ 25, table::BorderLineStyle::DOUBLE,  -1L }, // double (don't 
check width)
+};
+
+for (size_t i = 0; i  SAL_N_ELEMENTS(aChecks); ++i)
+{
+const editeng::SvxBorderLine* pLine = NULL;
+

[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-02-19 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx |2 ++
 sc/qa/unit/ucalc_formula.cxx |   28 
 sc/source/core/tool/interpr6.cxx |1 +
 3 files changed, 31 insertions(+)

New commits:
commit 9e183fbfdbfbe364d17f9d36a0b33d2fae89862d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Feb 20 00:28:06 2014 -0500

fdo#75228: We still need to get the value only to pop value from the stack.

Change-Id: Iad231aa97ed35f91b96cddf8157ebcd9af0f8ec9

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index f404561..a32b3c1 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -891,6 +891,7 @@ void ScInterpreter::ScCount()
 }
 break;
 case svDouble:
+GetDouble();
 nCount++;
 nFuncFmtType = NUMBERFORMAT_NUMBER;
 break;
commit e50f17ace67dc7dc1680494567d74b4c76ce21d3
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Feb 20 00:16:00 2014 -0500

fdo#75228: Add test for this.

Change-Id: Ie89c9f80db0da7d1d0a4a5c06495715aaf555f4c

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index c40469a..7ceabb4 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -119,6 +119,7 @@ public:
 void testFormulaRefUpdateNamedExpression();
 void testMultipleOperations();
 void testFuncCOLUMN();
+void testFuncCOUNT();
 void testFuncROW();
 void testFuncSUM();
 void testFuncPRODUCT();
@@ -358,6 +359,7 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
 CPPUNIT_TEST(testMultipleOperations);
 CPPUNIT_TEST(testFuncCOLUMN);
+CPPUNIT_TEST(testFuncCOUNT);
 CPPUNIT_TEST(testFuncROW);
 CPPUNIT_TEST(testFuncSUM);
 CPPUNIT_TEST(testFuncPRODUCT);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 02dfff2..35e6369 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1734,6 +1734,34 @@ void Test::testFuncCOLUMN()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFuncCOUNT()
+{
+m_pDoc-InsertTab(0, Formula);
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+m_pDoc-SetValue(ScAddress(0,0,0), 2); // A1
+m_pDoc-SetValue(ScAddress(0,1,0), 4); // A2
+m_pDoc-SetValue(ScAddress(0,2,0), 6); // A3
+
+ScAddress aPos(1,0,0);
+m_pDoc-SetString(aPos, =COUNT(A1:A3));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc-GetValue(aPos));
+
+aPos.IncRow();
+m_pDoc-SetString(aPos, =COUNT(A1:A3;2));
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc-GetValue(aPos));
+
+aPos.IncRow();
+m_pDoc-SetString(aPos, =COUNT(A1:A3;2;4));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc-GetValue(aPos));
+
+aPos.IncRow();
+m_pDoc-SetString(aPos, =COUNT(A1:A3;2;4;6));
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(aPos));
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFuncROW()
 {
 m_pDoc-InsertTab(0, Formula);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source

2014-02-18 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   87 ++--
 sc/qa/unit/ucalc.hxx|9 
 sc/source/core/data/column3.cxx |   25 +--
 3 files changed, 95 insertions(+), 26 deletions(-)

New commits:
commit ca50752c34de4477c696471b707e1b8136e27661
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Feb 18 22:57:39 2014 -0500

fdo#72491: Always set input as text when that's requested.

Even when the text begins with '='.

Change-Id: I6e0a995f3042240b9f78068b5d0b9b758eb253ed

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 1445848..5776ac9 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1485,6 +1485,19 @@ void ScColumn::StartListeningInArea( 
sc::StartListeningContext rCxt, SCROW nRow
 sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc);
 }
 
+namespace {
+
+void applyTextNumFormat( ScColumn rCol, SCROW nRow, SvNumberFormatter* 
pFormatter )
+{
+sal_uInt32 nFormat = pFormatter-GetStandardFormat(NUMBERFORMAT_TEXT);
+ScPatternAttr aNewAttrs(rCol.GetDoc().GetPool());
+SfxItemSet rSet = aNewAttrs.GetItemSet();
+rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+rCol.ApplyPattern(nRow, aNewAttrs);
+}
+
+}
+
 bool ScColumn::ParseString(
 ScCellValue rCell, SCROW nRow, SCTAB nTabP, const OUString rString,
 formula::FormulaGrammar::AddressConvention eConv,
@@ -1521,6 +1534,12 @@ bool ScColumn::ParseString(
 {
 rCell.set(rPool.intern(rString));
 }
+else if (aParam.meSetTextNumFormat == ScSetStringParam::Always)
+{
+// Set the cell format type to Text.
+applyTextNumFormat(*this, nRow, aParam.mpNumFormatter);
+rCell.set(rPool.intern(rString));
+}
 else // = Formula
 rCell.set(
 new ScFormulaCell(
@@ -1625,11 +1644,7 @@ bool ScColumn::ParseString(
 if (aParam.meSetTextNumFormat != ScSetStringParam::Never  
aParam.mpNumFormatter-IsNumberFormat(rString, nIndex, nVal))
 {
 // Set the cell format type to Text.
-sal_uInt32 nFormat = 
aParam.mpNumFormatter-GetStandardFormat(NUMBERFORMAT_TEXT);
-ScPatternAttr aNewAttrs(pDocument-GetPool());
-SfxItemSet rSet = aNewAttrs.GetItemSet();
-rSet.Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat) );
-ApplyPattern(nRow, aNewAttrs);
+applyTextNumFormat(*this, nRow, aParam.mpNumFormatter);
 }
 
 rCell.set(rPool.intern(rString));
commit 891817922121765cef65ae73ebf7fdc524083d20
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Feb 18 22:11:10 2014 -0500

fdo#72491: Add test for this.

Change-Id: Ic37402cb950783b080e5f185b98b19aea62efa7e

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c7c9ba5..ed84bf2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1729,9 +1729,7 @@ void Test::testFuncParam()
 
 void Test::testNamedRange()
 {
-struct {
-const char* pName; const char* pExpr; sal_uInt16 nIndex;
-} aNames[] = {
+RangeNameDef aNames[] = {
 { Divisor,  $Sheet1.$A$1:$A$1048576, 1 },
 { MyRange1, $Sheet1.$A$1:$A$100, 2 },
 { MyRange2, $Sheet1.$B$1:$B$100, 3 },
@@ -1742,31 +1740,22 @@ void Test::testNamedRange()
 
 m_pDoc-SetValue (0, 0, 0, 101);
 
-ScAddress aA1(0, 0, 0);
-ScRangeName* pNewRanges = new ScRangeName();
-for (size_t i = 0; i  SAL_N_ELEMENTS(aNames); ++i)
-{
-ScRangeData* pNew = new ScRangeData(
-m_pDoc,
-OUString::createFromAscii(aNames[i].pName),
-OUString::createFromAscii(aNames[i].pExpr),
-aA1, 0, formula::FormulaGrammar::GRAM_ENGLISH);
-pNew-SetIndex(aNames[i].nIndex);
-bool bSuccess = pNewRanges-insert(pNew);
-CPPUNIT_ASSERT_MESSAGE (insertion failed, bSuccess);
-}
+bool bSuccess = insertRangeNames(m_pDoc, aNames, aNames + 
SAL_N_ELEMENTS(aNames));
+CPPUNIT_ASSERT_MESSAGE(Failed to insert range names., bSuccess);
+
+ScRangeName* pNewRanges = m_pDoc-GetRangeName();
+CPPUNIT_ASSERT(pNewRanges);
 
 // Make sure the index lookup does the right thing.
 for (size_t i = 0; i  SAL_N_ELEMENTS(aNames); ++i)
 {
-const ScRangeData* p = pNewRanges-findByIndex(aNames[i].nIndex);
+const ScRangeData* p = pNewRanges-findByIndex(aNames[i].mnIndex);
 CPPUNIT_ASSERT_MESSAGE(lookup of range name by index failed., p);
 OUString aName = p-GetName();
-CPPUNIT_ASSERT_MESSAGE(wrong range name is retrieved., 
aName.equalsAscii(aNames[i].pName));
+CPPUNIT_ASSERT_MESSAGE(wrong range name is retrieved., 
aName.equalsAscii(aNames[i].mpName));
 }
 
 // Test usage in formula expression.
-m_pDoc-SetRangeName(pNewRanges);
 m_pDoc-SetString (1, 

  1   2   >