diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/complextext.cxx | 80 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 14 | ||||
-rw-r--r-- | vcl/qa/cppunit/svm/svmtest.cxx | 8 | ||||
-rw-r--r-- | vcl/qa/cppunit/text.cxx | 16 | ||||
-rw-r--r-- | vcl/source/filter/svm/SvmConverter.cxx | 6 | ||||
-rw-r--r-- | vcl/source/filter/wmf/emfwr.cxx | 4 | ||||
-rw-r--r-- | vcl/source/filter/wmf/wmfwr.cxx | 3 | ||||
-rw-r--r-- | vcl/source/gdi/metaact.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 32 |
9 files changed, 83 insertions, 86 deletions
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx index a3d033e7adba..693cde25b206 100644 --- a/vcl/qa/cppunit/complextext.cxx +++ b/vcl/qa/cppunit/complextext.cxx @@ -18,6 +18,7 @@ #if HAVE_MORE_FONTS // must be declared before inclusion of test/bootstrapfixture.hxx static std::ostream& operator<<(std::ostream& rStream, const std::vector<sal_Int32>& rVec); +static std::ostream& operator<<(std::ostream& rStream, const std::vector<double>& rVec); #endif #include <test/bootstrapfixture.hxx> @@ -40,6 +41,15 @@ static std::ostream& operator<<(std::ostream& rStream, const std::vector<sal_Int rStream << " }"; return rStream; } +static std::ostream& operator<<(std::ostream& rStream, const std::vector<double>& rVec) +{ + rStream << "{ "; + for (size_t i = 0; i < rVec.size() - 1; i++) + rStream << rVec[i] << ", "; + rStream << rVec.back(); + rStream << " }"; + return rStream; +} #endif class VclComplexTextTest : public test::BootstrapFixture @@ -82,17 +92,17 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testArabic) // absolute character widths AKA text array. tools::Long nRefTextWidth = 12595; - std::vector<sal_Int32> aRefCharWidths = { 989, 1558, 2824, 2824, 3899, + KernArray aRefCharWidths = { 989, 1558, 2824, 2824, 3899, 3899, 4550, 5119, 5689, 5689, 6307, 6925, 8484, 9135, 9705, 10927, 10927, 11497, 12595, 12595 }; KernArray aCharWidths; tools::Long nTextWidth = basegfx::fround<tools::Long>(pOutDev->GetTextArray(aOneTwoThree, &aCharWidths).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); // this sporadically returns 75 or 74 on some of the windows tinderboxes eg. tb73 CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // text advance width and line height CPPUNIT_ASSERT_EQUAL(nRefTextWidth, pOutDev->GetTextWidth(aOneTwoThree)); @@ -258,7 +268,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) OUString aText; KernArray aCharWidths; - std::vector<sal_Int32> aRefCharWidths; + KernArray aRefCharWidths; tools::Long nTextWidth, nTextWidth2, nRefTextWidth; // A. RTL text @@ -270,18 +280,18 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) aRefCharWidths = { 1168, 1168, 1819, 2389, 3611, 3611 }; nTextWidth = basegfx::fround<tools::Long>( pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/ false).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // 2) Caret placement DX array, ligature width is distributed over its // components. aRefCharWidths = { 584, 1168, 1819, 2389, 3000, 3611 }; nTextWidth = basegfx::fround<tools::Long>( pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/ true).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // 3) caret placement with combining marks, they should not add to ligature // component count. @@ -293,10 +303,10 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) CPPUNIT_ASSERT_EQUAL(aCharWidths[2], aCharWidths[3]); CPPUNIT_ASSERT_EQUAL(aCharWidths[6], aCharWidths[7]); CPPUNIT_ASSERT_EQUAL(aCharWidths[8], aCharWidths[9]); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth2); CPPUNIT_ASSERT_EQUAL(nTextWidth, nTextWidth2); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // B. LTR text aText = u"fi fl ffi ffl"_ustr; @@ -307,18 +317,18 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaret) aRefCharWidths = { 1290, 1290, 1941, 3231, 3231, 3882, 5862, 5862, 5862, 6513, 8493, 8493, 8493 }; nTextWidth = basegfx::fround<tools::Long>( pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/ false).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // 2) Caret placement DX array, ligature width is distributed over its // components. aRefCharWidths = { 645, 1290, 1941, 2586, 3231, 3882, 4542, 5202, 5862, 6513, 7173, 7833, 8493 }; nTextWidth = basegfx::fround<tools::Long>( pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/ true).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); #endif } @@ -332,7 +342,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) vcl::Font aFont; OUString aText; KernArray aCharWidths; - std::vector<sal_Int32> aRefCharWidths; + KernArray aRefCharWidths; tools::Long nTextWidth, nTextWidth2, nRefTextWidth; // A. RTL text @@ -348,18 +358,18 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) aRefCharWidths= { 582, 582, 842, 1111, 1710, 1710 }; nTextWidth = basegfx::fround<tools::Long>( pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/ false).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // 2) Caret placement DX array, ligature width is distributed over its // components. aRefCharWidths = { 291, 582, 842, 1111, 1410, 1710 }; nTextWidth = basegfx::fround<tools::Long>( pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/ true).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // 3) caret placement with combining marks, they should not add to ligature // component count. @@ -371,10 +381,10 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) CPPUNIT_ASSERT_EQUAL(aCharWidths[2], aCharWidths[3]); CPPUNIT_ASSERT_EQUAL(aCharWidths[6], aCharWidths[7]); CPPUNIT_ASSERT_EQUAL(aCharWidths[8], aCharWidths[9]); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth2); CPPUNIT_ASSERT_EQUAL(nTextWidth, nTextWidth2); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // B. LTR text // Set font size to its UPEM to decrease rounding issues @@ -390,9 +400,9 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) 3544, 3544, 3544, 3836, 4634, 4634, 4926, 5996, 5996, 5996 }; nTextWidth = basegfx::fround<tools::Long>( pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/ false).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // 2) Caret placement DX array, ligature width is distributed over its // components. @@ -400,9 +410,9 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testGdefCaret) 3004, 3278, 3544, 3836, 4138, 4634, 4926, 5199, 5494, 5996 }; nTextWidth = basegfx::fround<tools::Long>( pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, /*bCaret*/ true).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); #endif } @@ -417,25 +427,25 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf152048) pOutDev->SetFont(aFont); // get an compare the default text array - std::vector<sal_Int32> aRefCharWidths{ 934, 2341, 2341, 3689, 4647, 5495 }; + KernArray aRefCharWidths{ 934, 2341, 2341, 3689, 4647, 5495 }; tools::Long nRefTextWidth(5495); KernArray aCharWidths; tools::Long nTextWidth = basegfx::fround<tools::Long>(pOutDev->GetTextArray(aText, &aCharWidths).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // Simulate Kashida insertion using Kashida array and extending text array // to have room for Kashida. std::vector<sal_Bool> aKashidaArray{ false, false, false, true, false, false }; auto nKashida = 4000; - aCharWidths.set(3, aCharWidths[3] + nKashida); - aCharWidths.set(4, aCharWidths[4] + nKashida); - aCharWidths.set(5, aCharWidths[5] + nKashida); + aCharWidths[3] += nKashida; + aCharWidths[4] += nKashida; + aCharWidths[5] += nKashida; auto pLayout = pOutDev->ImplLayout(aText, 0, -1, Point(0, 0), 0, aCharWidths, aKashidaArray); // Without the fix this fails with: @@ -463,7 +473,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf152048_2) // Without the fix this fails with: // - Expected: 158 // - Actual : 118 - CPPUNIT_ASSERT_EQUAL(aCharWidths.back(), sal_Int32(nTextWidth)); + CPPUNIT_ASSERT_EQUAL(tools::Long(aCharWidths.back()), nTextWidth); #endif } @@ -525,14 +535,14 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testMixedCJKLatinScript_glyph_advanceme // absolute character widths AKA text array. tools::Long nRefTextWidth = 704; - std::vector<sal_Int32> aRefCharWidths = { 72, 144, 190, 236, 259, 305, 333, 379, 425, 474, 523, 551, 567, 612, 658, 704 }; + KernArray aRefCharWidths = { 72, 144, 190, 236, 259, 305, 333, 379, 425, 474, 523, 551, 567, 612, 658, 704 }; KernArray aCharWidths; tools::Long nTextWidth = basegfx::fround<tools::Long>(pOutDev->GetTextArray(aTestScript, &aCharWidths).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths); CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // text advance width and line height CPPUNIT_ASSERT_EQUAL(nRefTextWidth, pOutDev->GetTextWidth(aTestScript)); diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 765e4a0aaa4f..453b36f7bb84 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2246,7 +2246,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) const auto* pNumR = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[2]); CPPUNIT_ASSERT(pNumR); // this changed to the end of the text, not the start of the fly - CPPUNIT_ASSERT_DOUBLES_EQUAL(187.207, pNumR->GetValue(), 1e-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(187.157, pNumR->GetValue(), 1e-3); const auto* pNumB = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[3]); CPPUNIT_ASSERT(pNumB); CPPUNIT_ASSERT_DOUBLES_EQUAL(688.389, pNumB->GetValue(), 1e-3); @@ -2312,7 +2312,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) CPPUNIT_ASSERT_DOUBLES_EQUAL(660.789, pNumT->GetValue(), 1e-3); const auto* pNumR = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[2]); CPPUNIT_ASSERT(pNumR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(146.157, pNumR->GetValue(), 1e-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(146.107, pNumR->GetValue(), 1e-3); const auto* pNumB = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[3]); CPPUNIT_ASSERT(pNumB); CPPUNIT_ASSERT_DOUBLES_EQUAL(674.589, pNumB->GetValue(), 1e-3); @@ -2372,13 +2372,13 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), rElements.size()); const auto* pNumL = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[0]); CPPUNIT_ASSERT(pNumL); - CPPUNIT_ASSERT_DOUBLES_EQUAL(146.093, pNumL->GetValue(), 1e-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(146.043, pNumL->GetValue(), 1e-3); const auto* pNumT = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[1]); CPPUNIT_ASSERT(pNumT); CPPUNIT_ASSERT_DOUBLES_EQUAL(660.789, pNumT->GetValue(), 1e-3); const auto* pNumR = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[2]); CPPUNIT_ASSERT(pNumR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(179.457, pNumR->GetValue(), 1e-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(179.357, pNumR->GetValue(), 1e-3); const auto* pNumB = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[3]); CPPUNIT_ASSERT(pNumB); CPPUNIT_ASSERT_DOUBLES_EQUAL(674.589, pNumB->GetValue(), 1e-3); @@ -2510,7 +2510,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) CPPUNIT_ASSERT_DOUBLES_EQUAL(633.189, pNumT->GetValue(), 1e-3); const auto* pNumR = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[2]); CPPUNIT_ASSERT(pNumR); - CPPUNIT_ASSERT_DOUBLES_EQUAL(86.807, pNumR->GetValue(), 1e-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(86.757, pNumR->GetValue(), 1e-3); const auto* pNumB = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[3]); CPPUNIT_ASSERT(pNumB); CPPUNIT_ASSERT_DOUBLES_EQUAL(646.989, pNumB->GetValue(), 1e-3); @@ -2636,7 +2636,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link) const auto* pNumR = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[2]); CPPUNIT_ASSERT(pNumR); // this changed to the end of the text, not the start of the fly - CPPUNIT_ASSERT_DOUBLES_EQUAL(191.707, pNumR->GetValue(), 1e-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(191.657, pNumR->GetValue(), 1e-3); const auto* pNumB = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[3]); CPPUNIT_ASSERT(pNumB); CPPUNIT_ASSERT_DOUBLES_EQUAL(785.189, pNumB->GetValue(), 1e-3); @@ -2792,7 +2792,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link) const auto* pNumR = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[2]); CPPUNIT_ASSERT(pNumR); // this changed to the end of the text, not the start of the fly - CPPUNIT_ASSERT_DOUBLES_EQUAL(191.707, pNumR->GetValue(), 1e-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(191.657, pNumR->GetValue(), 1e-3); const auto* pNumB = dynamic_cast<vcl::filter::PDFNumberElement*>(rElements[3]); CPPUNIT_ASSERT(pNumB); CPPUNIT_ASSERT_DOUBLES_EQUAL(771.389, pNumB->GetValue(), 1e-3); diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index 67d59f9b7242..c9096728442a 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -865,8 +865,8 @@ void SvmTest::testTextArray() GDIMetaFile aGDIMetaFile; ScopedVclPtrInstance<VirtualDevice> pVirtualDev; setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile); - sal_Int32 const aDX[] = { 10, 15, 20, 25, 30, 35 }; - pVirtualDev->DrawTextArray(Point(4,6), u"123456"_ustr, KernArraySpan(aDX), {}, 1, 4); + KernArray aDX { 10, 15, 20, 25, 30, 35 }; + pVirtualDev->DrawTextArray(Point(4,6), u"123456"_ustr, aDX, {}, 1, 4); checkTextArray(writeAndReadStream(aGDIMetaFile)); checkTextArray(readFile(u"textarray.svm")); @@ -892,8 +892,8 @@ void SvmTest::testTextArrayWithContext() GDIMetaFile aGDIMetaFile; ScopedVclPtrInstance<VirtualDevice> pVirtualDev; setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile); - sal_Int32 const aDX[] = { 10, 15, 20, 25, 30, 35 }; - pVirtualDev->DrawPartialTextArray(Point(4, 6), u"123456"_ustr, KernArraySpan(aDX), {}, 0, 5, 1, 4); + KernArray aDX { 10, 15, 20, 25, 30, 35 }; + pVirtualDev->DrawPartialTextArray(Point(4, 6), u"123456"_ustr, aDX, {}, 0, 5, 1, 4); checkTextArrayWithContext(writeAndReadStream(aGDIMetaFile)); checkTextArrayWithContext(readFile(u"textarraycontext.svm")); diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx index ad7077a32a2a..f417b574fee8 100644 --- a/vcl/qa/cppunit/text.cxx +++ b/vcl/qa/cppunit/text.cxx @@ -240,16 +240,16 @@ CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleTextFontSpecificKerning) // absolute character widths AKA text array. tools::Long nRefTextWidth = 2671; - std::vector<sal_Int32> aRefCharWidths = { 1270, 2671 }; + KernArray aRefCharWidths{ 1270, 2671 }; KernArray aCharWidths; tools::Long nTextWidth = basegfx::fround<tools::Long>(pOutDev->GetTextArray(aAV, &aCharWidths).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths[0], aCharWidths.get_subunit_array()[0]); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths[1], aCharWidths.get_subunit_array()[1]); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths[0], aCharWidths[0]); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths[1], aCharWidths[1]); // this sporadically returns 75 or 74 on some of the windows tinderboxes eg. tb73 CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // text advance width and line height CPPUNIT_ASSERT_EQUAL(nRefTextWidth, pOutDev->GetTextWidth(aAV)); @@ -290,16 +290,16 @@ CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleTextNoKerning) // absolute character widths AKA text array. tools::Long nRefTextWidth = 2802; - std::vector<sal_Int32> aRefCharWidths = { 1401, 2802 }; + KernArray aRefCharWidths{ 1401, 2802 }; KernArray aCharWidths; tools::Long nTextWidth = basegfx::fround<tools::Long>(pOutDev->GetTextArray(aAV, &aCharWidths).nWidth); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths[0], aCharWidths.get_subunit_array()[0]); - CPPUNIT_ASSERT_EQUAL(aRefCharWidths[1], aCharWidths.get_subunit_array()[1]); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths[0], aCharWidths[0]); + CPPUNIT_ASSERT_EQUAL(aRefCharWidths[1], aCharWidths[1]); // this sporadically returns 75 or 74 on some of the windows tinderboxes eg. tb73 CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back()); + CPPUNIT_ASSERT_EQUAL(nTextWidth, tools::Long(aCharWidths.back())); // text advance width and line height CPPUNIT_ASSERT_EQUAL(nRefTextWidth, pOutDev->GetTextWidth(aAV)); diff --git a/vcl/source/filter/svm/SvmConverter.cxx b/vcl/source/filter/svm/SvmConverter.cxx index 2b5a65b189ce..a192d66df890 100644 --- a/vcl/source/filter/svm/SvmConverter.cxx +++ b/vcl/source/filter/svm/SvmConverter.cxx @@ -770,7 +770,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) for (sal_Int32 j = 0; j < nAryLen; ++j) { rIStm.ReadInt32( nTmp ); - aDXAry.set(j, nTmp); + aDXAry[j] = nTmp; } // #106172# Add last DX array elem, if missing @@ -794,9 +794,9 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) // difference to last elem and store // in very last. if( nStrLen > 1 ) - aDXAry.set(nStrLen-1, aDXAry[ nStrLen-2 ] + aTmpAry[ nStrLen-1 ] - aTmpAry[ nStrLen-2 ]); + aDXAry[nStrLen-1] = aDXAry[ nStrLen-2 ] + aTmpAry[ nStrLen-1 ] - aTmpAry[ nStrLen-2 ]; else - aDXAry.set(nStrLen-1, aTmpAry[ nStrLen-1 ]); // len=1: 0th position taken to be 0 + aDXAry[nStrLen-1] = aTmpAry[ nStrLen-1 ]; // len=1: 0th position taken to be 0 } } #ifdef DBG_UTIL diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index c9c08d590174..fb248fd9f3e0 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -891,13 +891,13 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, K { if (!pDXArray.empty()) { - aOwnArray.assign(pDXArray); + aOwnArray.assign(pDXArray.begin(), pDXArray.end()); pDX = aOwnArray; } const double fFactor = static_cast<double>(nWidth) / nNormWidth; for( i = 0; i < ( nLen - 1 ); i++ ) - aOwnArray.set(i, basegfx::fround(aOwnArray[i] * fFactor)); + aOwnArray[i] *= fFactor; } } diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index bd4f8b5d8fc6..06fb75d61ca0 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -1204,8 +1204,9 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) } else { + const double fAdjust = static_cast<double>(pA->GetWidth()) / nNormSize; for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ ) - aDXAry.set(i, aDXAry[i] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize); + aDXAry[i] *= fAdjust; if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) ) aDXAry.clear(); aSrcLineInfo = LineInfo(); diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 944a1e114128..b5f1eac47761 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -677,7 +677,7 @@ MetaTextArrayAction::MetaTextArrayAction( const Point& rStartPt, mnIndex ( nIndex ), mnLen ( nLen ) { - maDXAry.assign(pDXAry); + maDXAry.assign(pDXAry.begin(), pDXAry.end()); } MetaTextArrayAction::MetaTextArrayAction(const Point& rStartPt, OUString aStr, KernArraySpan pDXAry, @@ -693,7 +693,7 @@ MetaTextArrayAction::MetaTextArrayAction(const Point& rStartPt, OUString aStr, K , mnLayoutContextIndex(nLayoutContextIndex) , mnLayoutContextLen(nLayoutContextLen) { - maDXAry.assign(pDXAry); + maDXAry.assign(pDXAry.begin(), pDXAry.end()); } MetaTextArrayAction::~MetaTextArrayAction() @@ -733,7 +733,7 @@ void MetaTextArrayAction::Scale( double fScaleX, double fScaleY ) if ( !maDXAry.empty() && mnLen ) { for ( sal_uInt16 i = 0, nCount = mnLen; i < nCount; i++ ) - maDXAry.set(i, basegfx::fround(maDXAry[i] * fabs(fScaleX))); + maDXAry[i] *= fabs(fScaleX); } } diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 4113121b6820..ff83e0807a59 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -814,7 +814,7 @@ OutputDevice::GetPartialTextArray(const OUString& rStr, KernArray* pKernArray, s nPartLen = rStr.getLength() - nPartIndex; } - std::vector<sal_Int32>* pDXAry = pKernArray ? &pKernArray->get_subunit_array() : nullptr; + KernArray* pDXAry = pKernArray; // do layout std::unique_ptr<SalLayout> pSalLayout; @@ -885,16 +885,10 @@ OutputDevice::GetPartialTextArray(const OUString& rStr, KernArray* pKernArray, s if (pDXPixelArray) { assert(pKernArray && "pDXPixelArray depends on pKernArray existing"); - int nSubPixelFactor = pKernArray->get_factor(); if (mbMap) { for (int i = 0; i < nPartLen; ++i) - (*pDXPixelArray)[i] = ImplDevicePixelToLogicWidthDouble((*pDXPixelArray)[i] * nSubPixelFactor); - } - else if (nSubPixelFactor) - { - for (int i = 0; i < nPartLen; ++i) - (*pDXPixelArray)[i] *= nSubPixelFactor; + (*pDXPixelArray)[i] = ImplDevicePixelToLogicWidthDouble((*pDXPixelArray)[i]); } } @@ -902,7 +896,7 @@ OutputDevice::GetPartialTextArray(const OUString& rStr, KernArray* pKernArray, s { pDXAry->resize(nPartLen); for (int i = 0; i < nPartLen; ++i) - (*pDXAry)[i] = basegfx::fround((*pDXPixelArray)[i]); + (*pDXAry)[i] = (*pDXPixelArray)[i]; } vcl::TextArrayMetrics stReturnValue; @@ -919,7 +913,7 @@ OutputDevice::GetPartialTextArray(const OUString& rStr, KernArray* pKernArray, s return stReturnValue; } -void OutputDevice::GetCaretPositions( const OUString& rStr, KernArray& rCaretXArray, +void OutputDevice::GetCaretPositions( const OUString& rStr, KernArray& rCaretPos, sal_Int32 nIndex, sal_Int32 nLen, const SalLayoutGlyphs* pGlyphs ) const { @@ -930,7 +924,6 @@ void OutputDevice::GetCaretPositions( const OUString& rStr, KernArray& rCaretXAr nLen = rStr.getLength() - nIndex; sal_Int32 nCaretPos = nLen * 2; - std::vector<sal_Int32>& rCaretPos = rCaretXArray.get_subunit_array(); rCaretPos.resize(nCaretPos); // do layout @@ -950,7 +943,7 @@ void OutputDevice::GetCaretPositions( const OUString& rStr, KernArray& rCaretXAr for (i = 0; i < nCaretPos; ++i) if (aCaretPixelPos[i] >= 0) break; - tools::Long nXPos = (i < nCaretPos) ? aCaretPixelPos[i] : -1; + double nXPos = (i < nCaretPos) ? aCaretPixelPos[i] : -1; for (i = 0; i < nCaretPos; ++i) { if (aCaretPixelPos[i] >= 0) @@ -967,21 +960,15 @@ void OutputDevice::GetCaretPositions( const OUString& rStr, KernArray& rCaretXAr aCaretPixelPos[i] = nWidth - aCaretPixelPos[i] - 1; } - int nSubPixelFactor = rCaretXArray.get_factor(); // convert from font units to logical units if( mbMap ) { for (i = 0; i < nCaretPos; ++i) - aCaretPixelPos[i] = ImplDevicePixelToLogicWidth(aCaretPixelPos[i] * nSubPixelFactor); - } - else if (nSubPixelFactor) - { - for (i = 0; i < nCaretPos; ++i) - aCaretPixelPos[i] *= nSubPixelFactor; + aCaretPixelPos[i] = ImplDevicePixelToLogicWidthDouble(aCaretPixelPos[i]); } for (i = 0; i < nCaretPos; ++i) - rCaretPos[i] = basegfx::fround(aCaretPixelPos[i]); + rCaretPos[i] = aCaretPixelPos[i]; } void OutputDevice::DrawStretchText( const Point& rStartPt, sal_Int32 nWidth, @@ -1266,12 +1253,11 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout( { // convert from logical units to font units without rounding, // keeping accuracy for lower levels - int nSubPixels = pDXArray.get_factor(); for (int i = 0; i < nJustLen; ++i) { stJustification.SetTotalAdvance( nJustMinCluster + i, - ImplLogicWidthToDeviceSubPixel(pDXArray.get_subunit(i)) / nSubPixels); + ImplLogicWidthToDeviceSubPixel(pDXArray[i])); } nEndGlyphCoord = stJustification.GetTotalAdvance(nJustMinCluster + nJustLen - 1); @@ -1280,7 +1266,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout( { for (int i = 0; i < nJustLen; ++i) { - stJustification.SetTotalAdvance(nJustMinCluster + i, pDXArray.get(i)); + stJustification.SetTotalAdvance(nJustMinCluster + i, pDXArray[i]); } nEndGlyphCoord |