/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// 2. Setup data and formulas for (unsignedint r = 0; r <= 4991; ++r) for (unsignedint c = 0; c <= 14; ++c)
pDoc->SetValue( ScAddress(c,r,0), (r+1)*(c+1) );
// Set content and height of first row
pDoc->SetString(ScAddress(0, 0, 0), u"Test"_ustr);
pDoc->SetRowHeight(0, 0, 500);
pDoc->SetManualHeight(0, 0, 0, true);
// 3. Check all cells in destination table for (int r = 0; r < 2; ++r) for (int c = 0; c < 1024; ++c)
CPPUNIT_ASSERT_EQUAL(double((c + 1) * 100 + (r + 1)), pDoc->GetValue(c, r, n2ndTab));
}
// Undo, and check the result.
SfxUndoManager* pUndoMgr = pDoc->GetUndoManager();
CPPUNIT_ASSERT_MESSAGE("Failed to get the undo manager.", pUndoMgr);
pUndoMgr->Undo();
nFirstRowHeight = pDoc->GetRowHeight(0, 0);
nSecondRowHeight = pDoc->GetRowHeight(1, 0); // Without the accompanying fix in place, this test would have failed: // - Expected: 256 // - Actual : 477 // i.e. the increased height of the second row remained after undo.
CPPUNIT_ASSERT_EQUAL(nFirstRowHeight, nSecondRowHeight);
}
// check content of the merged cell H11:I11
CPPUNIT_ASSERT_EQUAL(u"1.5"_ustr, pDoc->GetString(ScAddress(7, 10, 0)));
// fill operation on the merged cell should clone ATTR_MERGE and ATTR_MERGE_FLAG // (as long as ATTR_MERGE_FLAG has only ScMF::Hor or ScMF::Ver) // // select merged cell
pViewShell->GetViewData().GetMarkData().SetMarkArea(ScRange(7, 10, 0, 8, 10, 0)); // copy its content in the next ten rows
pViewShell->FillAuto(FILL_TO_BOTTOM, 7, 10, 8, 10, 10); for (int i = 7; i < 9; i++)
{
ScMF nOriginFlag = lcl_getMergeFlagOfCell(*pDoc, i, 10, 0);
ScAddress aOriginMerge = lcl_getMergeSizeOfCell(*pDoc, i, 10, 0);
// ATTR_MERGE_FLAG: top left cell is NONE, the other cell shows horizontal overlapping
CPPUNIT_ASSERT_EQUAL(i == 7 ? ScMF::NONE : ScMF::Hor, nOriginFlag);
// ATTR_MERGE: top left cell contains the size of the // merged area (2:1), the other cell doesn't
CPPUNIT_ASSERT_EQUAL(i == 7 ? ScAddress(2, 1, 0): ScAddress(0, 0, 0), aOriginMerge);
for (int j = 11; j < 21; j++)
{ // check copying of ATTR_MERGE and ATTR_MERGE_FLAG
CPPUNIT_ASSERT_EQUAL(lcl_getMergeFlagOfCell(*pDoc, i, j, 0), nOriginFlag);
CPPUNIT_ASSERT_EQUAL(lcl_getMergeSizeOfCell(*pDoc, i, j, 0), aOriginMerge);
}
}
// select cell (e.g. by clicking on it) and check what is selected [but not marked]: // if it is the top left cell of a merged area, the selection is enlarged to the area
lcl_clickAndCheckCurrentArea(1, 5, 2, 8, pViewShell); // B6 -> B6:C9
lcl_clickAndCheckCurrentArea(0, 5, 0, 6, pViewShell); // A6 -> A6:A7
lcl_clickAndCheckCurrentArea(3, 5, 4, 5, pViewShell); // D6 -> D6:E6
lcl_clickAndCheckCurrentArea(4, 6, 4, 7, pViewShell); // D7 -> D6:D7
lcl_clickAndCheckCurrentArea(7, 10, 8, 10, pViewShell); // H11 -> H11:I11
lcl_clickAndCheckCurrentArea(7, 13, 8, 13, pViewShell); // H14 -> H14:I14
// compare the results of fill-down with the reference stored in the test file // this compares the whole area blindly, for specific test cases, check the test file // the test file have instructions / explanations, so that is easy to understand for (int nCol = 1; nCol <= 10; nCol++)
{ for (int nRow = 8; nRow <= 27; nRow++)
{
CellType nType1 = pDoc->GetCellType(ScAddress(nCol, nRow, 0));
CellType nType2 = pDoc->GetCellType(ScAddress(nCol + 22, nRow, 0)); double* pValue1 = pDoc->GetValueCell(ScAddress(nCol, nRow, 0)); double* pValue2 = pDoc->GetValueCell(ScAddress(nCol + 22, nRow, 0));
CPPUNIT_ASSERT_EQUAL(nType1, nType2); if (pValue2 != nullptr)
CPPUNIT_ASSERT_EQUAL(*pValue1, *pValue2); //cells with number value else
CPPUNIT_ASSERT_EQUAL(pValue1, pValue2); //empty cells
}
}
// compare the results of fill-right and left with the reference stored in the test file for (int nCol = 1; nCol <= 24; nCol++)
{ for (int nRow = 30; nRow <= 35; nRow++)
{
CellType nType1 = pDoc->GetCellType(ScAddress(nCol, nRow, 0));
CellType nType2 = pDoc->GetCellType(ScAddress(nCol, nRow + 16, 0)); double* pValue1 = pDoc->GetValueCell(ScAddress(nCol, nRow, 0)); double* pValue2 = pDoc->GetValueCell(ScAddress(nCol, nRow + 16, 0));
// fillauto booleans, these areas contain only merged cells
pViewShell->FillAuto(FILL_TO_RIGHT, 0, 4, 3, 5, 8); //A5:D6
// compare the results of fill-right 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 = 4; nCol <= 11; nCol++)
{ for (int nRow = 4; nRow <= 5; nRow++)
{
CellType nType1 = pDoc->GetCellType(ScAddress(nCol, nRow, 0));
CellType nType2 = pDoc->GetCellType(ScAddress(nCol, nRow + 3, 0)); double* pValue1 = pDoc->GetValueCell(ScAddress(nCol, nRow, 0)); double* pValue2 = pDoc->GetValueCell(ScAddress(nCol, nRow + 3, 0));
CPPUNIT_ASSERT_EQUAL(nType1, nType2); if (pValue2 != nullptr)
CPPUNIT_ASSERT_EQUAL(*pValue1, *pValue2); //cells with boolean value else
CPPUNIT_ASSERT_EQUAL(pValue1, pValue2); //empty cells
}
}
}
// fillauto dates, this areas contain only merged cells
pViewShell->FillAuto(FILL_TO_RIGHT, 1, 5, 4, 7, 8); //B6:E8
// compare the results of fill-right 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 = 5; nCol <= 12; nCol++)
{ for (int nRow = 5; nRow <= 7; nRow++)
{
CellType nType1 = pDoc->GetCellType(ScAddress(nCol, nRow, 0));
CellType nType2 = pDoc->GetCellType(ScAddress(nCol, nRow + 5, 0)); double* pValue1 = pDoc->GetValueCell(ScAddress(nCol, nRow, 0)); double* pValue2 = pDoc->GetValueCell(ScAddress(nCol, nRow + 5, 0));
CPPUNIT_ASSERT_EQUAL(nType1, nType2); if (pValue2 != nullptr)
CPPUNIT_ASSERT_EQUAL(*pValue1, *pValue2); //cells with number value else
CPPUNIT_ASSERT_EQUAL(pValue1, pValue2); //empty cells
}
}
}
// delete every userlist to make sure there won't be any string that is in 2 different userlist
ScGlobal::GetUserList().clear();
addToUserList({ u"January,February,March,April,May,June,July,August,September,October,November,December"_ustr }); const ScUserListData* pListData = ScGlobal::GetUserList().GetData(u"January"_ustr);
sal_uInt16 nIdx1 = 0, nIdx2 = 0; bool bHasIdx1, bHasIdx2; bool bMatchCase = false;
// 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 <= 9; nCol++)
{ for (int nRow = 5; nRow <= 7; nRow++)
{
CellType nType1 = pDoc->GetCellType(ScAddress(nCol, nRow, 0));
CellType nType2 = pDoc->GetCellType(ScAddress(nCol, nRow + 4, 0));
bHasIdx1 = pListData->GetSubIndex(pDoc->GetString(nCol, nRow, 0), nIdx1, bMatchCase);
bHasIdx2 = pListData->GetSubIndex(pDoc->GetString(nCol, nRow + 4, 0), nIdx2, bMatchCase);
CPPUNIT_ASSERT_EQUAL(nType1, nType2);
CPPUNIT_ASSERT(bHasIdx1);
CPPUNIT_ASSERT(bHasIdx2);
CPPUNIT_ASSERT_EQUAL(nIdx1, nIdx2); // userlist index value of cells
}
}
CPPUNIT_ASSERT_EQUAL(nType1, nType2);
CPPUNIT_ASSERT(bHasIdx1);
CPPUNIT_ASSERT(bHasIdx2);
CPPUNIT_ASSERT_EQUAL(nIdx1, nIdx2); // userlist index value of cells
}
}
}
// 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 // do not check the 3. row: a1,b2,a3. It is another bug to fix for (int nCol = 1; nCol <= 9; nCol++)
{ for (int nRow = 5; nRow <= 6; nRow++)
{
CellType nType1 = pDoc->GetCellType(ScAddress(nCol, nRow, 0));
CellType nType2 = pDoc->GetCellType(ScAddress(nCol, nRow + 4, 0));
OUString aStr1 = pDoc->GetString(nCol, nRow, 0);
OUString aStr2 = pDoc->GetString(nCol, nRow + 4, 0);
// delete every userlist to make sure there won't be any string that is in 2 different userlist
ScGlobal::GetUserList().clear();
addToUserList({ u"January,February,March,April,May,June,July,August,September,October,November,December"_ustr }); const ScUserListData* pListData = ScGlobal::GetUserList().GetData(u"January"_ustr);
sal_uInt16 nIdx1 = 0, nIdx2 = 0; bool bHasIdx1, bHasIdx2; bool bMatchCase = false;
// 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 = pDoc->GetCellType(ScAddress(nCol, nRow, 0));
CellType nType2 = pDoc->GetCellType(ScAddress(nCol, nRow + 4, 0));
bHasIdx1 = pListData->GetSubIndex(pDoc->GetString(nCol, nRow, 0), nIdx1, bMatchCase);
bHasIdx2 = pListData->GetSubIndex(pDoc->GetString(nCol, nRow + 4, 0), nIdx2, bMatchCase);
CPPUNIT_ASSERT_EQUAL(nType1, nType2);
CPPUNIT_ASSERT_EQUAL(bHasIdx1, bHasIdx2); if (bHasIdx1)
CPPUNIT_ASSERT_EQUAL(nIdx1, nIdx2); //cells with userlist value
}
}
CPPUNIT_ASSERT_EQUAL(nType1, nType2);
CPPUNIT_ASSERT_EQUAL(bHasIdx1, bHasIdx2); if (bHasIdx1)
CPPUNIT_ASSERT_EQUAL(nIdx1, nIdx2); //cells with userlist value
}
}
}
// 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({ u"1aa,2bb,3cc,4dd,5ee,6ff"_ustr });
// 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 = pDoc->GetCellType(ScAddress(nCol, nRow, 0));
CellType nType2 = pDoc->GetCellType(ScAddress(nCol, nRow + 4, 0));
OUString aStr1 = pDoc->GetString(nCol, nRow, 0);
OUString aStr2 = pDoc->GetString(nCol, nRow + 4, 0);
void ScCopyPasteTest::tdf122716_rtf_portion_encoding()
{ // Given a document with an explicitly defined "204" (Russian) charset for a font, // and a cell having contents of "Šampūnas", which has character "Š" representable // in Windows-1252 (RTF default), but not in Windows-1251 (i.e. charset 204):
createScDoc("xlsx/tdf122716_font_with_charset.xlsx");
ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent); // Obtain a transferable, similar to what happens on copy to clipboard: auto xTransferable = pModelObj->getSelection(); // Get the RTF data: auto rtf_any = xTransferable->getTransferData({ u"text/rtf"_ustr, {}, {} });
css::uno::Sequence<sal_Int8> rtf_bytes;
CPPUNIT_ASSERT(rtf_any >>= rtf_bytes);
OString rtf_string(reinterpret_cast<constchar*>(rtf_bytes.getConstArray()),
rtf_bytes.getLength()); // Check that the font with charset was actually emitted
CPPUNIT_ASSERT(rtf_string.indexOf("\\fcharset204 Liberation Sans;") >= 0); // Make sure that Unicode markup is emitted for the non-Ascii characters. // Without the fix, "\u352" wasn't there, because the export was using Windows-1252 // encoding unconditionally, even though the exported font defined a different one; // so the exported characters only had Unicode markup, when not representable in the // Windows-1252 encoding, and "Š" got exported as "\'8a". On import to Writer, font // encoding was used, and "\'8a" was interpreted as a Cyrillic alphabet character.
CPPUNIT_ASSERT(rtf_string.indexOf("\\u352\\'3famp\\u363\\'3fnas") >= 0);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.