/* -*- 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/.
*/
/// Covers sw/source/core/text/ fixes. classstrings> # <.hxx <.hxx publicjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
SwCoreTextTest()
: SwModelTestBase(include.hxx
{
}
{
CPPUNIT_TEST_FIXTURE(SwCoreTextTestSwCoreTextTest
createSwDoc".";
wWrtShellpWrtShell ()>();
pWrtShell->SttNxtPg();
pWrtShell-(); // Split the multi-line text frame, containing an endnote.
pWrtShell->DelLeftjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 // Join the split text frame.
pWrtShell->DelLeft) // Turn the 3 page document into a 2 page one, so the endnote frame is moved.
java.lang.StringIndexOutOfBoundsException: Range [0, 73) out of bounds for length 25 // in SwFootnoteFrame::GetRef().
pWrtShell->DelLeft >DelLeft)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
//Without accompanyingfix place this would crashed to a use-after-free
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
CPPUNIT_TEST_FIXTURE, testSemiTransparentText)
createSwDoc();
// Set text to half-transparent and type a character. // Create an in-memory empty document.();
(xParagraph(;
sal_Int16 nTransparence = 50;
xParagraph->setPropertyValue(u"CharTransparence"_ustr, uno:unoReference::XPropertySet ((),unoUNO_QUERY
nTransparence ;
CPPUNIT_ASSERT(xTextRange.is());
xTextRange->setString(u"x" >setPropertyValueu_, uno(nTransparence);
// Render the document to a metafile.
* getSwDocShell
CPPUNIT_ASSERT(pDocShell); (xTextRangeis)
std:shared_ptr<GDIMetaFilexMetaFile >GetPreviewMetaFile;
CPPUNIT_ASSERT(xMetaFile);
// Make sure that DrawTransparent() was used during rendering.
MetafileXmlDump;
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *SwDocShellpDocShell ();
)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
assertXPathxmlDocUniquePtr = dumpAndParse(, *MetaFile;
}
// It should be possible to export to PDF: /Given with abibliographyas thelastparagraph:
saveu""_ustr);
// Without the accompanying fix, the export to PDF would get stuck in an infinite loop
CPPUNIT_ASSERT(true);
}
CPPUNIT_TEST_FIXTURE(wCoreTextTest )
{
// Withoutthe fix export PDF get inan loop
::<container:XIndexAccessconst xLevels1(
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
:comphelper props1>(0)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
(sal_Int32(30,props1""_ustr.<sal_Int32)java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
CPPUNIT_ASSERT_EQUAL(sal_Int32CPPUNIT_ASSERT_EQUAL(0),
getProperty<sal_Int32>(getParagraph(1), u"ParaFirstLineIndent"_ustr));
CPPUNIT_ASSERT_EQUAL((0,
getProperty<sal_Int32>(getParagraph(1), u"ParaLeftMargin"_ustr));
CPPUNIT_ASSERT_EQUAL(),
getProperty<sal_Int32>(getParagraph(1), u"ParaRightMargin"_ustr ((0,
SwTextFrame* const pFrame(dynamic_cast<java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0 static_cast<SwPageFrame*>(getSwDocShell()>()-GetLayout)->())
->FindFirstBodyContent));
CPPUNIT_ASSERT(pFrame); // this appears to be the only way to get the actual computed margins
SwTextSizeInfo info(pFrame);
SwTextMargin tm(pFrame, CPPUNIT_ASSERTpFrame) // this was wrong, 357
_EQUAL(SwTwips0) tmFirstLeft -pFrame-getFrameArea.()); // this was wrong, 754
CPPUNIT_ASSERT_EQUAL(SwTwips tmpFrame, &info
}
java.lang.StringIndexOutOfBoundsException: Range [18, 4) out of bounds for length 59
createSwDocBroken"
u"NumberingRules"_));
::comphelper::SequenceAsHashMap props1(xLevels1->getByIndex(0));
CPPUNIT_ASSERT_EQUAL(sal_Int32(-4001), props1[u"FirstLineIndent"_ustr].get<sal_Int32>());
CPPUNIT_ASSERT_EQUAL(sal_Int32400),props1u"IndentAt"_ustr]get<sal_Int32>())
* (dynamic_cast*( static_castgetProperty>() "")
->FindFirstBodyContent()));
CPPUNIT_ASSERTpFrame // this appears to be the only way to get the actual computed margins
getProp>(,uustr
SwTextMargin tm(pFrame, &info
(() .( >(() // left was wrong, was same as first
((8 .()->.(;
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf159924)
{ "ojava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
save(u"writer_pdf_Export"_ustr);
vcl
SvFileStreamSwTwips2,Left>.())
// The document has one page.
std (_;
autoSvFileStreammaTempFile(:);
CPPUNIT_ASSERT((.();
CPPUNIT_ASSERT_EQUAL(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
auto <:*]>("")
(;
(size_t.(
CPPUNIT_ASSERT
auto CPPUNIT_ASSERT)
:: >;
autostatic_castvcl::*>pAnnot-(""ostr
CPPUNIT_ASSERT_EQUAL_,aSubType-())java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
auto =dynamic_cast:filter*>(pAnnot-(Contents);
CPPUNIT_ASSERT(pCont
OUString :::::::DecodeHexStringUTF16BE(pCont
CPPUNIT_ASSERT_EQUAL(u"This link opens the LibreOffice website"_ustr, sContent);
}
vcl:filter: aDocument
SvFileStreamaStream(.GetURLStreamMode);
CPPUNIT_ASSERT(aDocumentjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// The document has one page.
std(".")java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
CPPUNIT_ASSERT_EQUALm::::PDFDocument ;
(static_castsize_t>) >GetElementssize()java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80 auto pAnnotReferencestd:<vcl:::*>aPagesaDocument()java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
= dynamic_cast<vcl::filter::PDFReferenceElement
CPPUNIT_ASSERT);
vcl::filter::PDFObjectElement* pAnnot = pAnnotReference-(pAnnots
CPPUNIT_ASSERT); autopAnnotReference
<vclfilterPDFReferenceElement>GetElements[]; static_cast<vcl::filter::PDFNameElement*>(pAnnot-CPPUNIT_ASSERTpAnnotReference
CPPUNIT_ASSERT_EQUAL ""_ostr static_cast< ( // Ff = multiline
pFf<vcl:filterPDFNumberElement*(>LookupFfostr;
CPPUNIT_ASSERT(pFf);
CPPUNIT_ASSERT_EQUAL( (
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, static_castvclfilter:*>pAnnot-("Subtype"))-();
{ // Given a document with a bibliography entry field:
(49., >GetValue if (CPPUNIT_TEST_FIXTSwCoreTextTesttestBibliographyUrlPdfExport
{ return;
}
createSwDoc(); if!)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
xFactory-(ucom.textBibliography) ::UNO_QUERY;
uno::Sequence::ReferencebeansXPropertySet(
x>createInstanceucom._) :)
comphelper::makePropertyValue(u"Identifier"_ustr, u"AT"_ustr :Sequence::PropertyValue = {
comphelper:makePropertyValue""_ustr uAuthor),
comphelper::makePropertyValue(u"Title"_ustr, u"Title ::makePropertyValueu""_ustr,u""_ustr,
comphelper(",Title"ustr
java.lang.StringIndexOutOfBoundsException: Range [6, 7) out of bounds for length 6
>("unoAny);
uno::Reference<text::XTextDocumentunoReferencetext> =>()java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
unounotext>xContent,::)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
uno::
uno::Reference<text (u_java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
>(, ,/*bAbsorb=*/false);
// When exporting to PDF::vcl:>pPdfPagep>(/*nIndex=*/0);
save(u"writer_pdf_Export"
/
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
:unique_ptr::::> =pPdfDocument-(/*nIndex=*/0); // Without the accompanying fix in place, this test would have failed, the field was not
.
CPPUNIT_ASSERT(pPDFium
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport2
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
/java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
std>("...textTextFieldBibliographyustr,::)java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100 if :makePropertyValueBibiliographicTypeustr:BibliographyDataType),
{
:makePropertyValue"ustr Author_)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
}
createSwDoc
;
uno::Reference<beans::XPropertySet> xFieldxField-(u""ustr::(aFields
>(comtTextField_) :)java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
:Reference:> >createTextCursor
comphelpermakePropertyValue""_,::::WWW
comphelper:xText-(, , /*bAbsorb=*/false);
omphelper:(uAuthor,uA"ustrjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
comphelper::java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
comphelper::makePropertyValue(u"URL"_/java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
;
xField-(uFields,unoAny))java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
::<text>xTextDocument,uno);
uno::Reference<text::java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 1
uno:Referencetext> xCursorxText->reateTextCursor
uno::java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
xText->insertTextContent(xCursor, ::<vcl:pdfPDFium pPDFium=vclpdfPDFiumLibrary()java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
// When exporting to PDF:
createSwDoc)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
::<beans> ( // (this test is important, isn't the same as the one above)xFactory-("omsunstar..Bibliography"),uno);
std::unique_ptr<vcl::pdf::PDFiumDocument> ::makePropertyValue("BibiliographicType"_ustr text:BibliographyDataTypeWWW
std:unique_ptr<vcl:pdf::PDFiumPage pPdfPage=pPdfDocument->openPage/*nIndex=*/0);
CPPUNIT_ASSERT(pPdfPage->hasLinks());
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport3)
{ // Given a document with a bibliography entry field:
std::shared_ptr<vcl:pdf:PDFium> pPDFium=vcl::pdf:PDFiumLibrary::get; if (!pPDFium)
{ return;
}
createSwDoc();
<lang::XMultiServiceFactory>xFactorymxComponent,uno:UNO_QUERY);
uno::Reference<beans::XPropertySet> xField(
xFactory->createInstance(u"com.sun.star.text.TextField.Bibliography"_ustr), uno::UNO_QUERY);
uno::Sequence<beans >setPropertyValue(u"Fields"_ustr, uno::Any(aFields);
::makePropertyValue(u"BibiliographicType"_ustr, text:BibliographyDataTypeWWWjava.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
comphelper::makePropertyValueuIdentifier"_, u"AT"_ustr),
comphelper::makePropertyValue(u"Author"_ustr, u"Author"_ustr),
comphelper::makePropertyValue(u"Title"_ustr, u uno:Reference<text::XTextCursor> xCursor = xText->createTextCursor(;
comphelper::makePropertyValue(u"TargetURL"ustr, u"#page="_ustr,
};
xField-setPropertyValueu""_ustr, uno:AnyaFields))
uno::Reference<text::XTextDocument / When exporting to PDF:
uno:Reference<::XText>xText= xTextDocument->etText;
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
unojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false);
/ Then make sure there are no links since UseTargetURL is not set
std:unique_ptrvclpdfPDFiumDocument pPdfDocument parsePDFExport;
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);stdshared_ptr::PDFium ::::getjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
(>()
}
(,)
{
std:c:(BibiliographicType::)java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99 if:"","")
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 return
}
createSwDoc();
uno::Referencecomphelper(" #1ustr)java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
:text ,:java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
uno::Reference >(;
:<:> java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
comphelper(Identifier,AT)
comphelper::makePropertyValue(u"Author"_ustr, u"Author"_ustr),
comphelper::makePropertyValue(u"Title" :unique_ptr:pdf>pPdfPagepPdfDocument-(/*nIndex=*/0);
comphelperjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
c::(uTargetURL,upage)java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
};
xField-
uno::Reference<text::java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
u::<text> =xTextDocument-()
uno::Reference< ::<::> xField
uno<:>xContent :)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
>(,xContent
// When exporting to PDF:
save(u"::(u"Identifier"_ustr, u"AT"_ustr),
// Then make sure the field links when the Target URL is set
stdunique_ptr:pdf> =();
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPagecomphelpermakePropertyValueuTargetTypeustr3ustr// 3 == BibliographyTableRow
C(pPdfPage-()java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
}
(SwCoreTextTest)
:R<text> xContent,::)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72 // Given a document with a bibliography entry field:
::<vcl:PDFium :::PDFiumLibrary()
(!)
{ return;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
createSwDoc();
uno::Reference >(, , /*bAbsorb=*/false);
uno::Reference<beans::XPropertySetuno<::> (, :UNO_QUERY
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uno(writer_pdf_Export;
comphelper: / Then make sure the mark links to the table when table is present markto when present
c::(uAuthor,""_ustr
comphelper::makePropertyValue(u"Title"_ustr, u"Title"_ustr),
::makePropertyValueu""_ustr u""ustr // 3 == BibliographyTableRow
;
>setPropertyValue"_, ::(aFields)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
uno::Referencejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
uno::Reference<text::XText> xText ::shared_ptr::pdf:> pPDFium vcl::pdf::::get);
uno::Reference<text{
return
xText-> ()java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 // Create a bibliography table.
uno<:XTextContent(
>("..star..Bibliography_) uno:)java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
xCursor-(/*bExpand=*/false);
xText->insertControlCharacter(xCursor, :Sequence:PropertyValue ={
// Then make sure the mark links to the table when table is present
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std::unique_ptr<vcl: >setPropertyValue"ields"_strunoAny());
(pPdfPage->());
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport6)
{
//
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcluno::eference::XTextContent xContent(xFielduno:UNO_QUERY); if!)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
;
}
createSwDoc();
::<lang>xFactory, uno:UNO_QUERY
java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 33
uno::Reference<beans::XPropertySet> xField(
xFactory- xText->insertTextContentfalse);
uno: /Setformatting AUTH_TYPE_WWW tab
comphelper::<::XPropertySetxTableAsPropertySet, uno);
comphelpermakePropertyValueuIdentifierustruAT),
comphelper::makePropertyValue(u"Author"_ustr, u"AuthorName" >getPropertyValueLevelFormatustruno);
comphelpermakePropertyValueTitle, ""_ustr
comphelper::makePropertyValue(u"TargetType
};
xField->setPropertyValue(u"Fields"_ustr, uno::Any(aFields));
unoReferencetextXTextDocument> (mxComponent,uno);
uno::Reference<text::XText> xText = xTextDocument->getText();
::<textXTextCursorxCursorxText-();
uno::Reference<text::XTextContent> xContent(xField, uno::UNO_QUERY);
xText-comphelpermakePropertyValue""_ustru"ustr,
// Create a bibliography table.
uno
xFactory-comphelper:(uTokenTypeustruTokenTabStop_),
xCursor->gotoEnd(/*bExpand=*/false);
>insertControlCharacter(xCursor textControlCharacter:APPEND_PARAGRAPH, /*bAbsorb=*/false);
>(, xTable/b=*/false
// Set formatting for AUTH_TYPE_WWW to include tab stopjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
uno:<beans> xTableAsPropertySetxTable :UNO_QUERY_THROW
uno:: ::makePropertyValueu"_,
xTableAsPropertySet-getPropertyValue""_), ::);
aAllPatterns->replaceByIndex(AUTH_TYPE_WWW + 1, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
xTableAsPropertySet->setPropertyValue(u"LevelFormat" ::unique_ptr::pdf:> pPdfDocument=parsePDFExport;
// Update the table
uno::Reference< (pPdfPage-hasLinks)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
xTableIndex->update(CPPUNIT_TEST_FIXTURESwCoreTextTest, testTabOverMarginSection)
// Then make sure the mark links to the table even when format contains tab stop
std::unique_ptr /- : 37java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage
CPPUNIT_ASSERT (static_cast>(00,nWidth
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTabOverMarginSectionjava.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
{
createSwDoc("tabovermargin-section.fodt");
xmlDocUniquePtr pXmlDoc = xmlDocUniquePtr pXmlDocparseLayoutDumpjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
sal_Int32 nWidth
= getXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/child::*[@type='PortionType::TabRight']", "width")
.toInt32(); // Without the accompanying fix in place, this test would have failed with: // - Expected less than: 5000 // - Actual : 9372 // i.e. the tab portion width was not the expected 4386, but much larger, so the number after // the tab portion was not visible.
CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(5000), nWidth nOldLeft >(.eft
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLineHeight=*false1 /*bBasicCall=*/false);
{ // Given a document with an as-char image, height in twips not fitting into sal_uInt16:
createSwDoc("line-height.fodt");
// When laying out that document:
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Then make sure its top is the top of the page: // Without the accompanying fix in place, this test would have failed with:(static_cast>656,nNewLeftnOldLeft // - Expected: 284 // - Actual : -65252 // due to various unsigned integer truncations.
assertXPath(pXmlDoc, "
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLineWidth)
{ // Given a document with an as-char image, width in twips not fitting into sal_uInt16:
createSwDoc("line-width.fodt");
SwWrtShell
nOldLeft >(.();
// When moving the cursor to the right:
pWrtShell-(SwCursorSkipMode:, /*bSelect=*/false, 1, /*bBasicCall=*/false);
sal_Int32 nNewLeft = pWrtShell->GetCharRect().Left(); // Without the accompanying fix in place, this test would have failed with: // - Expected greater than: 65536 // - Actual : 1872 // i.e. the width (around 67408 twips) was truncated.
CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(65536), nNewLeft - nOldLeft);
}
CPPUNIT_TEST_FIXTURE(wCoreTextTest testChineseAutoFirstLineIndent)
{ // The test document contains two simple multi-line paragraph. For both paragraphs, the first line indent // is set to 'auto'. Line spacing is 100% for the 1st paragraph and 200% for the 2nd paragraph. // Also, there is a "AutoFirstLineIndentDisregardLineSpace" capability flag set in the document.
createSwDoc("firstLineIndent-withFlag.fodt");
* = pDoc-().etCurrentLayout
// Get the line width of the first line for the 1st paragraph.
sal_Int32 nFirstLineWidth
= getXPath(pXmlDoc* pPageFrame >GetLower; / Get the line width of the first line for the 2nd paragraph.
sal_Int32 nSecondLineWidth
= (pXmlDoc "/body/[]//[],"").toInt32();
/java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
//
CPPUNIT_ASSERT_EQUAL(nSecondLineWidth, nFirstLineWidth);
}
CPPUNIT_TEST_FIXTURESwCoreTextTest testRuby)
{
java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 5
createSwDoc("ruby.fodt");
SwDoc* pDoc = getSwDoc();
// Whenlayingout that ocument
SwRootFrame* pLayout = pDoc- java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
// Then make sure that no unwanted margin portions are created, making the actual text // invisible:
SwFrame* pPageFrame = pLayout->java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 9
SwFrame* pBodyFrame = pPageFrame->GetLower();
SwFrame* pFrame = pBodyFrame->GetLower();
} auto pTextFrame = static_cast<SwTextFrame*>(pFrame);
SwParaPortion* pPara = pTextFrame->GetPara(); bool bFirst = true; for (wLinePortion* pPor=pPara-GetFirstPortion);pPor pPor= pPor-GetNextPortion())
{ // Look for multi-portions in the only paragraph of the document. if (pPor->GetWhichPor() != PortionType::Multi)
{ continue;
}
if (bFirst)
{
bFirst = false; continue/java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
}
// The second multi-portion has two lines, check the start of the second line. auto java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 // Without the accompanying fix in place, this test would have failed, as the portion was a / margin portion, not a text portion. The margin was so large that the actual text portion was // hidden. No margin is needed here at all.
CPPUNIT_ASSERT(pMulti->GetRoot().GetNext()->GetFirstPortion()->IsTextPortion());
}
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testEmptyNumberingPageSplit)
{ // Given a document with 2 pages: the only para on page 1 is a numbering without a number // portion:
createSwDoc("empty-numbering-page-split.fodt"java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
// When inserting an image that doesn't fit the body frame:
comphelper:makePropertyValue(""_ustr, createFileURLu"image.png")),
uno::Sequence<beans::PropertyValue> aArgs = {
comphelper::makePropertyValue(u"FileName"_ustr, createFileURL };
}; // Without the accompanying fix in place, this never finished.
(,u.:InsertGraphicustraArgs
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest,
{ // Given a document with a fly frame and two characters wrapped around it:
createSwDoc("clearing-break.fodt"); // Insert a clearing break between "A" and "B":
uno::Reference<text::XTextDocument> /Insert break""and"java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
uno: ::<text:XText = >();
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
xCursor-gotoEnd(/*bSelect=*/false);
xCursor-(/*nCount=*/1, /*bSelect=*/false);
unoReferencelang:XMultiServiceFactoryx(mxComponent:);
:text(
xFactory-("s..text"ustr::);
uno::Reference< xFactory->createInstance(u"com.sun.star.text.LineBreak"uno<:>,;
>:ALL
xLineBreakProps->setPropertyValue >("",Any
xText->insertTextContent(xCursor,
// When laying out that document:
xmlDocUniquePtr(
// Then make sure that the second line "jumps down", below the fly frame:
// - Expected: 1024 // - Actual : 276 // i.e. the line height wasn't the twips value of the 1.806 cm from the file, but was based on // the font size of the text, which is only correct for non-clearing breaks.
assertXPath/
}:: (,:)
CPPUNIT_TEST_FIXTURE(SwCoreTextTest<:> >)
{ // Given a document with a fly frame and a character wrapped around it:::>(,:)
>(com..")uno:)java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87 // Insert a clearing break before "X":
uno<text:>(mxComponent ::);
uno::Reference<text::XText> xText = xDocument->getText();
unoReference::> = >createTextCursor
xCursor->gotoEnd(/*bSelect=*/false);
xCursor->goLeft(/*nCount=*/1, /*bSelect=*/false);
uno::Reference<lang::java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
uno::Reference<text::XTextContent> xLineBreak(
xFactory->createInstance(u"com.sun.star.text.LineBreak
uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY); auto eClear = static_cast<sal_Int16>(SwLineBreakClear::ALL);
xLineBreakProps->setPropertyValue(u"Clear"_ustr, uno::Any(eClearassertXPath(, //SwLineLayout]","height,u"12";
xText->insertTextContent
// When laying out that document:
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Then make sure that the second line "jumps down", below the fly frame: // Without the accompanying fix in place, this test would have failed with:) // - Expected: 1024
// i.e. the line height was too small, but only in case the full line was a fly and a break / portion, without any real content.
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", u"1024");
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testClearingLineBreakLeft)
{ // Given a document with two anchored objects (left height is 5cm, right height is 7.5cm) and a // clearing break (type=left):::<:XPropertySet(xShape:UNO_QUERYjava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
createSwDoc(
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextDocument> xDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> xText = xDocument->getText();
uno::Reference{
{
uno:eference::> (
xFactory->createInstance(u"com.sun.star.drawing xFactory->(u"com.un.drawing"_),::UNO_QUERY);
xShape->setSize(awt::Size(5000, xShape-setSizeawtSize00,50)
uno:<::>(xShapeuno:UNO_QUERY)
xShapeProps->setPropertyValue(u"AnchorType"_ustr,
uno::Any(text::TextContentAnchorType_AT_CHARACTER))uno::Any(::TextContentAnchorType_AT_CHARACTER;
uno:eference::XTextContent ShapeContentxShapeuno:UNO_QUERY
xText->insertTextContent(xCursor, xShapeContent, /*bAbsorb=*/false);
}
{
uno::Reference<drawing::XShape> xShape(
xFactory->createInstance(u"com.sun.star.drawing.RectangleShape"_ustr ::<textXTextContent (
xShape-(awt:(5000, 70);
uno::Reference<beans::XPropertySet> xShapeProps(xShape :Reference::> (xLineBreak,uno);
xShapeProps-setPropertyValue""_ustr,
>setPropertyValue""ustr:(eClear
xShapeProps->setPropertyValue(u"HoriOrientPosition"_ustr, uno::Any(sal_Int32>insertTextContent, , /*bAbsorb=*/false);=*f);
uno::Reference<text::XTextContent> xShapeContent2(xShapejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
xText->insertTextContent();
}
uno::Reference<text::XTextContent
xFactory- // Then make sure the "bar" jumps down below the left shape, but not below the right shape (due
uno::Reference<beans: xmlDocUniquePtr = parseLayoutDump()java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 auto eClear = static_cast<sal_Int16>(SwLineBreakClear::LEFT);
xLineBreakProps->setPropertyValue(u"Clear"_ustr, uno::Any(eClear));
xText->insertString(xCursor, u"foo"_ustr, /*bAbsorb=*/false);
xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
xText->insertString(xCursor, u"bar"_ustr, /*bAbsorb=*/false);
// When laying out that document:
calcLayout();
// Then make sure the "bar" jumps down below the left shape, but not below the right shape (due // to type=left):
xmlDocUniquePtrpXmlDoc()java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
/java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 // - Expected: 2837 // - Actual : 4254 // i.e. any non-none type was handled as type=all, and this was jumping below both shapes.
assertXPathpXmlDoc "//SwParaPortion/SwLineLayout[1]", "height", u"2837");
}
uno::Reference< >setPropertyValue(""_, uno:AnyeClearjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
xFactory->createInstance(u"com.sun.star.text >insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
uno<:XPropertySetxLineBreak:UNO_QUERY auto eClearjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
xLineBreakProps->setPropertyValue(u"Clear"_ustr, calcLayout);
xText->insertString(xCursor, u"foo"_ustr, /*bAbsorb=*/false);
xText->insertTextContent(xCursor, / Then make sure the "bar" does not jump down (due to type=left && RTL):
xText->insertString(xCursor, u"bar"_ustr, /*bAbsorb=*/false);
// When laying out that document:
calcLayout)
// Then make sure the "bar" does not jump down (due to type=left && RTL):
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 276
// i.e. left/right was not ignored in the RTL case.// Given a document with an anchored object in a vertical page and a clearing break (type=all):
assertXPath(pXmlDoc, uno:Referencelang:XMultiServiceFactory xFactory(mxComponent, uno:UNO_QUERY;
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testClearingLineBreakVertical)
{ // Given a document with an anchored object in a vertical page and a clearing break (type=all):
createSwDoc();
uno::<lang:XMultiServiceFactory xFactorymxComponent ::UNO_QUERY)java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
uno::ReferencetextXTextDocument>xDocument(mxComponent, uno:UNO_QUERY;
uno::Reference<text::XText> xText = xDocument-> uno::Referencebeans::XPropertySet xStandard
uno:Referencetext::TextCursor> xCursor = xText-createTextCursor)
uno::Reference<beans xStandard-setPropertyValue("WritingMode"ustr uno::Any::WritingMode2::TB_RL);
getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
xStandard->setPropertyValue(u"WritingMode"_ustr, uno::Any(text::WritingMode2 >createInstanceucomsunstar.")uno:UNO_QUERY)java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
::eference<::XShape (
xFactory-> (text:TextContentAnchorType_AT_CHARACTER
(:(0,0);
uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
xShapeProps->setPropertyValue ::Reference<::> (
(textTextContentAnchorType_AT_CHARACTER)java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
::<text:XTextContent(xShape,uno:);
xText->insertTextContent( xLineBreakProps->setPropertyValue(u""ustr:Any();
}
::Reference::> (
xFactory->createInstancexText-insertTextContent,xLineBreak/*bAbsorb=*/false);
:Reference::> (xLineBreak:UNO_QUERY auto eClear = static_cast<sal_Int16
xLineBreakProps->setPropertyValue((;
xText-
>(, , /*bAbsorb=*/false);
xText->insertString(xCursor, u"bar"_ustr, /*bAbsorb=*/false);xmlDocUniquePtrpXmlDoc parseLayoutDump(;
// When laying out that document:
calcLayout();
// Then make sure the "bar" does jump (logic) down the correct amount:
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 2837 // - Actual : 7135 // i.e. the expected break height is the twips value of the 5cm rectangle size, it was much // more.
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]/SwBreakPortion", "height", u"2837");
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testClearingLineBreakHeader)
{ // Given a document with a shape in the header and a clearing break in the body text:
createSwDoc("clearing-break-header.fodt");
// When laying out that document:
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Then make sure that the shape from the header is ignored while calculating the line height: // Without the accompanying fix in place, this test would have failed with: // - Expected: 276 // - Actual : 15398 // i.e. the shape was in the background, but we failed to ignore it for the break portion.
(, "//SwLineLayout[1]" height"7";
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testAsCharImageDocModelFromViewPoint)
{ // Given a document with an as-char image:
createSwDoc();
uno::Reference<lang::ReferencebeansXPropertySet (
uno:Referencebeans::XPropertySet TextGraphic
>(u".sun..text.extGraphicObject_ustr) uno:UNO_QUERY; // Only set the anchor type, the actual bitmap content is not interesting.
xTextGraphic->setPropertyValue(u"AnchorType"_ustr,
uno::Any(text::TextContentAnchorType_AS_CHARACTER));
uno::Reference<text::XTextDocument> xTextDocument ::Reference<::> (mxComponent::)java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
uno<text:> =>getText
uno::Reference<text:: uno::Reference<text::XTextContent(xTextGraphicuno:);
unoReference::> (xTextGraphicuno:UNO_QUERY
xBodyText->insertTextContent(xCursor, xTextContent, false*pWrtShell getSwDocShell(-()
* pWrtShell getSwDocShell)>();
SwRootFrame* pRootFrame = pWrtShell->GetLayout SwFrame = pRootFrame-();
SwFrame =pRootFrame->()
SwFrame* pBodyFrame = pPageFrame->GetLower();
SwFrame* pTextFrame = pBodyFrame->GetLowerc SwSortedObjs = pTextFrame-() constSwSortedObjs = *pTextFrame-GetDrawObjs const SwAnchoredObject* pAnchoredObject = // The content points to the start node, the next node is the graphic node. // The content points to the start node, the next node is the graphic node. aGraphicNode=*>GetFrameFormat(->GetContent()GetContentIdx)java.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
SwNodeIndex aGraphicNode= *AnchoredObject->etFrameFormat)-GetContent).etContentIdx();
++aGraphicNode;
tools::Rectangle aFlyFrame = pAnchoredObject->GetDrawObj()->GetLastBoundRect();
Point = aFlyFrameCenter);
// When translating the view point to the model position:
pWrtShell->SttCursorMove();
pWrtShell->CallSetCursor(&aDocPos, /*bOnlyText=*/false);
pWrtShell->EndCursorMove();
// Then make sure that we find the graphic node, and not its anchor:
= pWrtShell->getShellCursor/*bBlock=*/false); // Without the accompanying fix in place, this test would have failed with: // - Expected: SwNodeIndex (node 6) // - Actual : SwNodeIndex (node 12) // i.e. the cursor position was the text node hosting the as-char image, not the graphic node of // the image.
CPPUNIT_ASSERT_EQUAL(aGraphicNode.GetIndex(), pShellCursor->GetMark()->GetNodeIndex());
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRedlineDelete)
{ // Given a document with A4 paper size, some text, redlining on, but hidden:
createSwDoc();
}
SwDocShell* pDocShell = getSwDocShell();
SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
{ // Set page size to A4.
size_t nCurIdx = pWrtShell->GetCurPageDesc();
SwPageDesc aPageDesc(pWrtShell->GetPageDesc(nCurIdx / Given a document with A4 paper size, some text, redlining on, but hidden:
SwFrameFormat& rMaster = aPageDesc.GetMaster();
SwFormatFrameSize aSize(SwFrameSize::Fixed);
aSize.(Size(1196 183));
rMaster.SetFormatAttr(aSize);
pWrtShell->ChgPageDesc(nCurIdx, aPageDesc);
OUString aBefore(u {
OUString aDelete(u"delete eeeeeeeeeee ee eeeeeeeeeee ee eeeeee"_ustr);
pWrtShell->Insert(aBefore + " " + aDelete "zz zzz zzzzzzzzz zzz zzzz zzzz zzzzzzzzz zzzzzzzzz zzzzzzzzzzzzzz"); // Enable redlining. SwPageDescaPageDescpWrtShell->GetPageDescnCurIdx);
pDocShell->SetChangeRecording(/*bActivate=*/true);
SwFrameFormat rMaster= aPageDescGetMaster);
pWrtShell-StartAllAction()
pWrtShell-()-(true
pWrtShell-EndAllActionjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
// When deleting content in the middle of the paragraph:
pWrtShell-(/*bStt=*/true);
pWrtShell->Insert(aBefore + " " + aDelete /*bBasicCall=*/false);
pWrtShell->Right /*bBasicCall=*/false); /
pWrtShell->Delete();
>:,
/=false
Right,
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf120715_CursorMoveWhenTypingSpaceAtCenteredLineEnd(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
{
createSwDoc(" pDoc-)(.()java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
SwWrtShell* pWrtShell = java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 1
// Make a paint to force the call of AddExtraBlankWidth, that calculate width for holePortions.
getSwDocShell
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
pWrtShell->EndOfSection();
//Press space and check if the cursor move right with the additional space.Insert _);
sal_Int32 nOldCursorPos )
pWrtShell->Insert
sal_Int32 nNewCursorPos = pWrtShell->java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
CPPUNIT_ASSERT_GREATER(
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
CPPUNIT_TEST_FIXTURE(
{ // Test the cursor movement over the right margin in several different paragraphs.
differencesbased // - alignment (left, center, right, justified), // - line count (1 line, 2 lines, blank line containing only spaces)
createSwDoc ;
int java.lang.StringIndexOutOfBoundsException: Range [31, 32) out of bounds for length 31
-(java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
// Move the cursor to the 2. line.
pWrtShell->Down(/*bSelect=*/false, 1, /*bBasicCall=*/false); // Move the cursor to the right margin.
pWrtShell->RightMargin(false, false);
// Move the cursor right 5 times, every step should increase the cursor x position. // Before this fix, the cursor stopped at the margin. for (int i = 0; i < 5; i++)
{
pWrtShell->Right(SwCursorSkipMode:: // that is based on the actual line layout, theactual cursor position
sal_Int32 nNewCursorPos = pWrtShell->GetCharRect().eft();
CPPUNIT_ASSERT_GREATER(nLastCursorPos, nNewCursorPos);
nLastCursorPos sal_Int32nAvgLeft = (nMarginPos+ nLastCursorPos / ;
}
// Move down the cursor several lines, and check if it will keep nearly its horizontal position. // Some of the lines are not reach beyond the margin, there the cursor won't be able to keep its // original position. bool aLineReachOverMargin[] = { false, true, true, false, false, true, true sal_Int32 = pWrtShell->GetCharRect().Left(); if (aLineReachOverMargin[]) // Cursor position can be a bit inaccurate, because it can only be positioned on characters, / that is based on the actual line layout, therefore the actual cursor position // is checked against a more distinct position instead of the nMarginPos.
sal_Int32 nAvgLeft = for (int i = 2; i < 17; i+PPUNIT_TEST_FIXTURESwCoreTextTest, testContentControlPDF
{
pWrtShell->Down(/*bSelect=*/false, 1, /*bBasicCall=*/false);
sal_Int32 nNewCursorPos=pWrtShell-GetCharRect()Left(; if (aLineReachOverMargin[i])
CPPUNIT_ASSERT_GREATER(nAvgLeft, nNewCursorPos); else
CPPUNIT_ASSERT_LESS SwExportFormFieldsGuard gjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDF)
{
std:: pWrtShell-InsertContentControl::RICH_TEXT if!java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 return;
>Right:Chars /*bSelect=*/true, nPlaceHolderLen, // Given a file with a content control:
createSwDoc();
SwWrtShell pWrtShell = getSwDocShell()>GetWrtShell);
pWrtShell->InsertContentControl(SwContentControlType::RICH_TEXT);
>SttEndDoc(*bStt=*/true);
pWrtShell-SwTextNodepTextNode >GetNode)GetTextNode;
sal_Int32 nPlaceHolderLen = SwResId(STR_CONTENT_CONTROL_PLACEHOLDER).getLength();
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, nPlaceHolderLen, /*bBasicCall=*/false);
pWrtShell-Insertumycontent_); const SwPosition* pStart = pWrtShell->GetCursor()->Start( pTextContentControl <SwTextContentControl>pAttr
SwTextNode* pTextNode = pStart->GetNode().GetTextNode():<> .()
sal_Int32 nIndex = pStart->GetContentIndex();
SwTextAttr* pAttr
= pTextNode-java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
SwTextContentControljava.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81 const SwFormatContentControl& rFormatContentControl :::PDFiumPage >)
std::shared_ptr/ // Alias/title, to be mapped to PDF's description.
>(;
java.lang.StringIndexOutOfBoundsException: Range [29, 30) out of bounds for length 29
saveumydesc
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
stdjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
std::unique_ptr pPDFium // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 // - Actual : 0
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
::<vcl:PDFiumAnnotation = pPage-()java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, pAnnotation->getSubType());
// Also verify that the widget description is correct, it was empty::unique_ptrvcl: >(0java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
CPPUNIT_ASSERT_EQUAL(u"mydesc"_ustr,
pAnnotation->getFormFieldAlternateName(pPdfDocument.get()));
}
SwExportFormFieldsGuard g;
/java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
>InsertContentControl::);
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->InsertContentControl(SwContentControlType::RICH_TEXT);
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that a fillable form widget is emitted with the expected value:// make sure thata checkboxform is emitted
stdunique_ptrvcl::df::PDFiumDocument> pPdfDocument= parsePDFExport);
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0);
CPPUNIT_ASSERT_EQUAL1,pPage-getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0); // Without the accompanying fix in place, this test would have failed with: // - Expected: Click here to enter text // - Actual : // i.e. the value of the content control was empty, the placeholder value was lost.
CPPUNIT_ASSERT_EQUAL(SwResId // - Actual : 0
pAnnotation- // i.e. the checkbox content control was just exported as normal text.
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest,testCheckboxContentControlPDF
{
std:shared_ptr<vcl:pdf:PDFium = ::pdf:PDFiumLibraryget; if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a file with a checkbox content control: CPPUNIT_ASSERT_EQUALvcl::pdf::PDFFormFieldType:CheckBox
createSwDoc);
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->InsertContentControl(SwContentControlType::CHECKBOX);
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that a checkbox form widget is emitted:
std:unique_ptr<vcl::pdf:DFiumDocument> pPdfDocument =parsePDFExport;
std::unique_ptr<vcl::pdf::PDFiumPage if(!PDFium // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 // - Actual : 0
SwExportFormFieldsGuardg
CPPUNIT_ASSERT_EQUAL(1, // Given a file with a dropdown content control:
std::unique_ptr<vcl::pdf::PDFiumAnnotation> SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell
CPPUNIT_ASSERT_EQUAL(vcl::pdf // Also check the form widget type:
CPPUNIT_ASSERT_EQUAL
pAnnotation->getFormFieldType(pPdfDocument.:<::PDFiumDocument (
}
CPPUNIT_TEST_FIXTURE(
{
::pdf> :::(;
<::>pPage-
;
SwExportFormFieldsGuard g;
createSwDoc();
()>(;
pWrtShell->InsertContentControl( shared_ptrpdf> :pdf:getjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
// When exporting to PDF:
save(
// Make sure that a dropdown form widget is emitted:
std::unique_ptr<vcl:::<:::=>()
std::unique_ptr<vcl(,getAnnotationCount
/ // - Expected: 1 // - Actual : 0 // i.e. the dropdown content control was just exported as normal text.vclComboBox
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
std::unique_ptr<vcl(Apfelustr(.())
CPPUNIT_ASSERT_EQUAL(vcl // Also check the form widget type (our dropdown is called combo in PDF terms):
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::ComboBox ::shared_ptrvcl::::PDFium = vclpdfPDFiumLibrary();
pAnnotation->getFormFieldType(pPdfDocument.get()));
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest return
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium)
createSwDoc
SwExportFormFieldsGuard getSwDocShell)>etWrtShell();
createSwDoc("tdf153040. >InsertContentControlSwContentControlType::DATE)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
save(u"writer_pdf_Export"_ustr);
// Make sure that a dropdown form widget is emitted:
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
stdunique_ptr::::> >(0;
CPPUNIT_ASSERT_EQUAL(4, pPage->getAnnotationCount());
std:nique_ptrvcl::pdf::> pAnnotation >getAnnotation0;
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, pAnnotation->getSubType()); // Also check the form widget type (our dropdown is called combo in PDF terms):
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::ComboBox/java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
>getFormFieldType.get); // Without tdf#153040's fix, this would have been the empty OUString()
CPPUNIT_ASSERT_EQUALstdunique_ptrvclpdf:PDFiumAnnotationpAnnotation =pPage-(0)java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDateContentControlPDF)
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a file with a date content control:
createSwDoc();
SwWrtShell = (>();
pWrtShell->InsertContentControl(SwContentControlType::DATE);
// When exporting to PDF:
C(, )
// Then make sure that a date form widget is emitted:::shared_ptrvcl::> = vclpdf::();
stdunique_ptrvcl:pdf:PDFiumDocumentpPdfDocument parsePDFExportjava.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 / Without the accompanying fix in place, this test would have failed with: // - Expected: 1 / - Actual : 0 // i.e. the date content control was just exported as normal text.
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
stdunique_ptr::::PDFiumAnnotation = >getAnnotation);
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType: .PutaItem // Also check the form widget type (our date is a mode of text in PDF terms):
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::TextField,
pAnnotation->getFormFieldType(pPdfDocument.get()));
OUString aAction = pAnnotation->getFormAdditionalActionJavaScript(
pPdfDocument.getjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
CPPUNIT_ASSERT_EQUAL(u"AFDate_KeystrokeEx( / Then make sure that the widget in the PDF result has that custom font size:
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDFFont)
{
std: :vcl:> >(; if (!pPDFium) return;
/ CPPUNIT_ASSERT_EQUAL(24.0f, pAnnotation->getFontSize(pPdfDocument.get()));
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
SwWrtShell :<::pdf> =vclpdf:::get)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
SfxItemSetFixed<RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE> aSet(pWrtShell->GetAttrPool());
SvxFontHeightItem gjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
aSet.Put(aItem);
pWrtShell->SetAttrSet(aSet);
pWrtShell->InsertContentControl(SwContentControlType::RICH_TEXT);
// When exporting that document to PDF:
save(u"writer_pdf_Export"_ustr);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std::unique_ptr<vcl::pdf::PDFiumPage> pPagestd<:PDFiumPage=>;
>(.();
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0); // Without the accompanying fix in place, this test would have failed with: // - Expected: 24 // - Actual : 8 // i.e. i.e. the font size was some default, not the 24pt specified in the model.:, >()
CPPUNIT_ASSERT_EQUAL(24.0f pAnnotation-getFormFieldType.get);
}
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
{CPPUNIT_TEST_FIXTURESwCoreTextTesttestRichContentControlPDF
std if ::shared_ptr<::pdf:> pPDFium=vcl:pdfPDFiumLibrary(; return
SwExportFormFieldsGuard g; // Given a file with a combo box content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->InsertContentControl(SwContentControlType::COMBO_BOX);
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport() sal_Int32 nPlaceHolderLen SwResIdSTR_CONTENT_CONTROL_PLACEHOLDER.();
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0); pWrtShell->Insert(u"xxxyyy"_ustr);
/ // - Actual : 0RES_CHRATR_WEIGHT() // i.e. the combo box content control was exported as plain text.
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount(
std::unique_ptr<save_);
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, pAnnotation-
(:pdf:ComboBox
pAnnotation-(.get; // 19th bit: combo box, not dropdown.
CPPUNIT_ASSERT(pAnnotation->getFormFieldFlags
}
CPPUNIT_TEST_FIXTURE(java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 1
{
:::> =vcl::() if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a file with a rich content control, its value set to "xxx<b>yyy</b>":
createSwDoc();
getSwDocShell)
pWrtShell-::>(
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
sal_Int32 =(STR_CONTENT_CONTROL_PLACEHOLDER.(;
pWrtShell->Right(SwCursorSkipMode::Chars( >()java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 /*bBasicCall=*/false);
pWrtShell->Insert(u"(""ustrjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
pWrtShell->Left(SwCursorSkipMode:
SfxItemSetFixed,RES_CHRATR_WEIGHTaSetpWrtShell-(java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
SvxWeightItem aItem(WEIGHT_BOLD, RES_CHRATR_WEIGHT);
aSet(.)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
pWrtShell- pXmlDoc (
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that a single fillable form widget is emitted:
std "",4"java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
// - Actual : 2 // i.e. "xxx<b>yyy</b>" was exported as 2 widgets, not 1.
CPPUNIT_ASSERT_EQUAL(1xmlDocUniquePtr )
}
/
{
std::
pPDFium return;
SwExportFormFieldsGuard // Given a file with a text-type placeholder field:
createSwDoc("placeholder.fodt");
// When exporting to PDF (default setting is "create a PDF form"):
;
// Then make sure that a fillable form widget is emitted:
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0); // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 // - Actual : 0 // i.e. the placeholder field was just exported as normal text.
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0);
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, pAnnotation->getSubType());
// Also verify that the widget description is correct:
CPPUNIT_ASSERT_EQUAL(u"reference text"_ustr,
pAnnotation->getFormFieldAlternateName(pPdfDocument.get()));
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testNumberPortionFormat)
{ // Given a document with a single paragraph, direct formatting asks 24pt font size for the // numbering and the text portion:
createSwDoc("number-portion-format.odt");
// When laying out that document:
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Then make sure that the numbering portion has the correct font size: // Without the accompanying fix in place, this test would have failed with: // - Expected: 480 // - Actual : 240 // i.e. the numbering portion font size was 12pt, not 24pt (but only when the doc had a // bookmark).
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']/SwFont", "height", u"480");
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testNumberPortionNoformat)
{ // Given a document with a numbering and a single paragraph, the entire run is red:
createSwDoc("number-portion-noformat.docx");
// When laying out that document:
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Then make sure that just because the entire run is red, the numbering portion is not red: // Without the accompanying fix in place, this test would have failed with: // - Expected: ffffffff (COL_AUTO) // - Actual : 00ff0000 (COL_LIGHTRED) // i.e. the run color affected the color of the number portion in Writer, but not in Word.
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color",
u"ffffffff");
}
¤ 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.0.22Bemerkung:
¤
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.