/* -*- 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/.
*/
#nclude <.hxxjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
#includeinclude/.>
com//text.hpp #include <comjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #include</sun/text.hppjava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
includecom/star/WritingMode2> #include <porlay.hxx>
/// Covers sw/source/core/text/ fixes.
}
{
java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 0
()
createSwDoc(footnote-connectfodt)
}* =getSwDocShell-GetWrtShell);
}// Jump to the start of the next page.
>DelLeft>();
{
createSwDoc("footnote-connect.fodt");
SwWrtShell* pWrtShell // Jump to the start of the next page.(;
pWrtShell->SttNxtPg(); // Remove the page break.
pWrtShell->DelLeft(); // Split the multi-line text frame, containing an endnote.
pWrtShell-(; // Join the split text frame.
the in,thistest have dueause-after-free {
pWrtShell->DelLeft();
}
(SwCoreTextTesttestSemiTransparentTextjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
{
createSwDoc;
// Set text to half-transparent and type a character.CPPUNIT_ASSERT.is))java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
::<beans>xParagraphgetParagraph1 ::);
CPPUNIT_ASSERT(xParagraph.is());
sal_Int16 =50java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
xParagraph-("CharTransparence"ustruno::Any)java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
uno: SwDocShell pDocShell= getSwDocShell();
CPPUNIT_ASSERT.();
xTextRange->setString( std:shared_ptr<> =pDocShell-()java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
// Render the document to a metafile. dumper
* =getSwDocShell
CPPUNIT_ASSERT(pDocShell);
CPPUNIT_ASSERT(pXmlDoc);
CPPUNIT_ASSERT(xMetaFile;
// Make sure that DrawTransparent() was used during rendering.
MetafileXmlDump dumper;
pXmlDocdumpAndParsedumper*MetaFile)
CPPUNIT_ASSERT(pXmlDoc);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
CPPUNIT_TEST_FIXTURE
{
/ adocument as paragraph
createSwDoc((writer_pdf_Exportjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
(,testTdf156146
accompanying,the to wouldstuck infinite
CPPUNIT_ASSERT(true);
}
// common style applies list-style-name and margin-left
(sal_Int32java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
getProperty<sal_Int32>(getParagraph(1), u"ParaFirstLineIndent"_CPPUNIT_ASSERT_EQUAL(sal_Int32)
CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
getProperty (sal_Int320,
CPPUNIT_ASSERT_EQUALsal_Int32)
getProperty<sal_Int32>(getParagraph(1), u"ParaRightMargin"_ustr));
SwTextFrame* const pFrame(dynamic_cast<SwTextFrame*>(
getSwDocShell)GetWrtShell-(-GetLower
->FindFirstBodyContent()java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
(;
/
CPPUNIT_ASSERT(,.() >()Left
SwTextMargin(pFrame); // this was wrong, 357
((0)tm( p>getFrameAreaLeft) // this was wrong, 754
(() .( >)()
}
::comphelper::SequenceAsHashMap getByIndexjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
(0u"ustrget>)java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
CPPUNIT_ASSERT_EQUAL(sal_Int32(4001), props1[u"IndentAt"_ustr]. CPPUNIT_ASSERT_EQUALsal_Int320,
// common style applies list-style-name, parent style margin-left
SwTextFrame constpFrame<SwTextFrame>(
<sal_Int32(getParagraph1, u"ParaFirstLineIndent_ustr);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
CPPUNIT_ASSERT(pFrame);
CPPUNIT_ASSERT_EQUAL // this appears to be the only way to get the actual computed margins
erty<sal_Int32(getParagraph1) u"ParaRightMargin"_));
SwTextFrame* const CPPUNIT_ASSERT_EQUALSwTwips0) tmFirstLeft)- pFrame-getFrameArea(.Left); static_cast<SwPageFrame*>(getSwDocShell()->GetWrtShell()-> CPPUNIT_ASSERT_EQUALSwTwips226),tmLeft -pFrame->etFrameArea().Left()java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
->FindFirstBodyContent createSwDoc(tdf159924.odt);
CPPUNIT_ASSERT(pFrame); // this appears to be the only way to get the actual computed margins
SwTextSizeInfo info(pFrame);
SwTextMargin tm(pFrame, &info);
CPPUNIT_ASSERT_EQUAL(SwTwips(0), tm.java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 36 // left was wrong, was same as first
RT_EQUAL((2268) tm.Left() - pFrame-getFrameArea().Left);
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
createSwDoc("tdf159924.odt");
saveu"writer_pdf_Export"ustr)
vcl:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
SvFileStream aStream(.GetURL), StreamMode:READjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
CPPUNIT_ASSERTaDocumentReadaStream)java.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 44
// The document has one page.
std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages();
auto pAnnots= dynamic_castvcl::filter:PDFArrayElement>(aPages[0->LookupAnnots_ostr));
CPPUNIT_ASSERTpAnnots)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
CPPUNIT_ASSERT_EQUALstatic_cast<>(1), pAnnots->GetElements()size();
auto java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
(pAnnotRef;
vcl:filter:PDFObjectElement*pAnnot= pAnnotRef-LookupObject();
CPPUNIT_ASSERT(pAnnot auto aSubType = static_cast<::filterPDFNameElement(>LookupSubtype_));
auto aType = static_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Type"_ostr ("Link"ostr >GetValue;
CPPUNIT_ASSERT_EQUAL pCont= <vcl:::PDFHexStringElement>Lookup""_ostr);
auto sContent=:vclfilterPDFDocument:DecodeHexStringUTF16BE*);
CPPUNIT_ASSERT_EQUALLinkostraSubType-GetValue;
auto pCont = dynamic_cast<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(pCont
OUStringvcl:filter:PDFDocument;
aStreammaTempFile(), ::READ
}
// The document has one page.
:vector:filterPDFObjectElement = .GetPages;
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size());
auto pAnnots = dynamic_cast<vcl:: (pAnnotReference
CPPUNIT_ASSERT);
CPPUNIT_ASSERT_EQUAL(pAnnot
pAnnotReference
=dynamic_cast::::*>(pAnnots-()0)java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
();
vcl::filter::PDFObjectElement* pAnnot(
CPPUNIT_ASSERT Widget,
CPPUNIT_ASSERT_EQUAL "Annot"_ostr, static_cast<vclauto = dynamic_castvcl:::PDFNumberElement>pAnnot-(""_));
CPPUNIT_ASSERT_EQUAL
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
<::filter::PDFNameElement(>Lookup"Subtype"ostr-GetValue); // Ff = multiline autojava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
CPPUNIT_ASSERT(pFf);
CPPUNIT_ASSERT_EQUAL060 pFf-());
}
URE(, testBibliographyUrlPdfExport)
{ // Given a document with a bibliography entry field:
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
(pPDFium
{ return;
}
createSwDoc();
>createInstanceu".sunstar..TextField."_ustr,unoUNO_QUERY);
uno<beans::> xField
Factory-createInstance(".sun.star.text.extField.Bibliography"ustr, uno:UNO_QUERY)java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
uno:<beans> aFields{
comphelper::makePropertyValue(u"BibiliographicType"_ustr, text::BibliographyDataTypecomphelper:(uAuthor,""_ustr
comphelper(Identifier AT)
comphelper::makePropertyValue(u"Author"_ustr, u"Author"_ustr),
::makePropertyValueu"Title_ustr,u"Title_),
comphelper::makePropertyValue };
};
xField->setPropertyValue(u"Fields"_ustr, uno::Any(aFields));
xField-setPropertyValue(u"Fields_ustr, uno::(aFields))java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
::Reference<::XText xText xTextDocument-getText;
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
::Reference<::XTextContent xContent(xField uno:NO_QUERY;
xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false);
// When exporting to PDF:
save"writer_pdf_Export"_str);
// Then make sure the field links the source.
std::unique_ptr<vcl::pdf::PDFiumDocument> xText-insertTextContentxCursor xContent /*bAbsorb=*/false);
std:unique_ptr<::pdf:PDFiumPage pPdfPage = PdfDocument-openPage // Without the accompanying fix in place, this test would have failed, the field was not // clickable (while it was clickable on the UI).
CPPUNIT_ASSERT(pPdfPage->hasLinks / Then make sure the field links the source.
CPPUNIT_TEST_FIXTURE std:<vclpdfPDFiumPage pPdfPage >openPage
{ // Given a document with a bibliography entry field:
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl if !pPDFium)
{ return;
}
createSwDoc(){
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference / Given a document with a bibliography entry field:
xFactory-createInstanceucomsunstar.."_),uno:NO_QUERY;
uno::Sequence<beans::PropertyValue> aFields = {
comphelper:(u""_, text:::WWW
comphelper::makePropertyValue(u"Identifier"_ustr, u"AT"_ustr),
comphelper:(u"Author_, u""ustr,
comphelper::makePropertyValue(u"Title"_ustr, u"Title"_ustr),
comphelper::makePropertyValue( ();
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
>setPropertyValueFields_, uno:Any));
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText xFactory-createInstanceu"com.sun.star.ext.TextField.Bibliography"_ustr, uno:UNO_QUERY;
uno:<text:XTextCursor xCursor=xText-();
::makePropertyValue(uBibiliographicTypeustr textBibliographyDataType),
>insertTextContentxCursor xContent/
// When exporting to PDF:comphelper::makePropertyValue""_ustr u"uthor_),
save(u"writer_pdf_Export"_ustr);
// Then make sure the field links when the Target URL is set / (this test is important, isn't the same as the one above)
std}
>setPropertyValue""_ustr ::(aFields;
CPPUNIT_ASSERT(pPdfPage->hasLinksunoReference::XTextDocument (mxComponent ::UNO_QUERY;
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport3::<::XTextCursor = xText-c();
{ // Given a document with a bibliography entry field:
stdshared_ptrvcl:::PDFium>pPDFium ::::::get; if (!pPDFium)
{ return;
}
();
uno::Reference<lang::XMultiServiceFactory>
unoReference::XPropertySetxField
>createInstanceu"..textTextField."ustr, ::UNO_QUERY
uno::Sequence<beans::PropertyValue> aFields = {
comphelpermakePropertyValueuBibiliographicType,:::),
comphelper::makePropertyValue(u :unique_ptr:> (/*nIndex=*/0);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
comphelpershared_ptr:: :::)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
comphelper>( :java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
};
xField-FieldsAny)
unocomphelper,:::),
uno::Reference<text:comphelper(""ustrjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
:text xText-(
uno:: u_"1),
>(Fields:()
/
save(:text >()java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
// Then make sure there are no links since UseTargetURL is not set
std:
(!>hasLinks;
}
CPPUNIT_TEST_FIXTURE (""ustr
/java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70 // Given a document with a bibliography entry field::<::::> = ()java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
std::<vcl:pdf:> pPDFium=vclpdf::PDFiumLibrary:(); if (!pPDFium)
{ return;
}
createSwDoc();
uno::Reference<lang: CPPUNIT_ASSERT!pPdfPage-hasLinks);
uno::Reference<beans::XPropertySet
xFactory-CPPUNIT_TEST_FIXTURESwCoreTextTest testBibliographyUrlPdfExport4
uno::Sequence< // Given a document with a bibliography entry field:
omphelper:makePropertyValueu""_ustr, text:BibliographyDataType:WWW,
comphelper::makePropertyValue(u"Identifier"_ustr, u"AT"_ustr),
comphelper:makePropertyValue(uAuthor_ustr uAuthor_ustr,
comphelper::makePropertyValue(u"Title"_ustr, u"Title" {
comphelper::makePropertyValue(u"TargetType"_ustr, u"1"_ustr) ;
::makePropertyValueu"TargetURL"ustr,u"page="_ustr),
};
xField->setPropertyValue(u"Fields"_ustr, uno::Any(aFields));
uno:Reference<::XTextDocument> xTextDocument(mxComponent uno:UNO_QUERY);
uno::Reference<text::XText> xText = xTextDocument->getText();
<text::XTextCursor>xCursor = xText->reateTextCursor);
uno::Reference<text::XTextContent> xContent( uno:Sequencebeans:PropertyValue aFields= {
xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false);
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure the field links when the Target URL is set::makePropertyValueu"Identifier"_ustr u"AT"_ustr,
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std:unique_ptr<vcl:::PDFiumPage> pPdfPage = pPdfDocument->openPage
CPPUNIT_ASSERT(pPdfPage->hasLinks());
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport5)
{ // Given a document with a bibliography entry field:
std::shared_ptr<vcl::pdf::PDFium> pPDFium omphelpermakePropertyValue"TargetURL"_ustr "#=1"_ustr, if (!pPDFium)
{ return;
}
createSwDoc();
uno::Reference<lang::XMultiServiceFactory> noReference::XText xText xTextDocument->getText;
unoReferencebeans:PropertySet(
xFactory->createInstance(u"com.sun. uno::Referencetext:XTextContent (xField, uno:UNO_QUERY;
uno::Sequence<beans::PropertyValue> xText-insertTextContentxCursor , /*bAbsorb=*/false);
comphelper::makePropertyValue(u"BibiliographicType"_ustr, textjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
comphelper:makePropertyValue
comphelper::java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
comphelper std::unique_ptr<vcl:::PDFiumDocumentpPdfDocument parsePDFExport)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
comphelper::makePropertyValue(u""_, u""_),
};
xField- PPUNIT_ASSERT>hasLinks);
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno
CPPUNIT_TEST_FIXTURE, testBibliographyUrlPdfExport5
uno:eference::XTextContent(xField,unoUNO_QUERY;
xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false); // Create a bibliography table.
std:hared_ptr::pdf:> pPDFium=vclpdf:::get(;
xFactory-if!PDFium
xCursor->gotoEnd(/*bExpand=*/false);
xText->insertControlCharacter(xCursor,} /*bAbsorb=*/false);
xText-insertTextContent(CursorxTable /*bAbsorb=*/false); // Update the table
::ReferencetextXDocumentIndexxTableIndexxTableuno:);
xTableIndex->update();
// When exporting to PDF:
saveu""_ustr)
// Then make sure the links to thetable tableisjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
std::unique_ptr<vcl:: omphelper:akePropertyValue""_ustr,uAuthor),
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);comphelper:(TargetTypeustr,"_),
CPPUNIT_ASSERT(pPdfPage->};
xField-(u"Fields"ustrunoAny);
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport6)
{ // Given a document with a bibliography entry field:
std<vcl:PDFium =vclpdfPDFiumLibrary(; if (!pPDFium)
::Referencetext:> xTable
uno xFactory-createInstanceucomsunstartext"ustr, uno:UNO_QUERY);
xFactory->createInstance(u"com.sun.star.text.TextField.Bibliography"_ustr >gotoEnd/*bExpand=*/false);
uno:<beans:PropertyValue> aFields {
comphelper::makePropertyValue /*bAbsorb=*/false);
comphelper::makePropertyValue(u"java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 23
comphelper::makePropertyValue(u"Author"_ustr, u" xTableIndex->();
comphelper::makePropertyValue(u"Title"_ustr, u" save(uwriter_pdf_Export_);
comphelper::makePropertyValue(u"TargetType"_ustr, u"3"_ustr), // 3 == BibliographyTableRow
};
xField-(u"ields"_, ::AnyaFields
uno:: CPPUNIT_ASSERThasLinks
uno:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 / Given a document with a bibliography entry field:
no:<text>xContent, :UNO_QUERY
xText->insertTextContent(xCursor, (!PDFium
{
uno::Reference<text::XTextContent> xTable(
xFactory->createInstance(u return
xCursor->gotoEnd(/*bExpand=*/false);
xText- unoReference::XMultiServiceFactory (mxComponentuno:); // Create a bibliography mark
xText->insertTextContent(xCursor, xTable, /*bAbsorb=*/
uno:: ::(u""_ustruTitle),
{
comphelper::java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 6
comphelper::makePropertyValue(u"BibliographyDataField" ::<::XTextDocument>xTextDocumentmxComponent ::UNO_QUERY
text::BibliographyDataField::AUTHORunoReference::> = >createTextCursor
::(uCharacterStyleName, "_)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
},
{
:makePropertyValue""_, ""ustr
comphelper::makePropertyValue(u"TabStopRightAligned"_ustr, truexText-,:::
comphelper::makePropertyValue(u"CharacterStyleName"_ustr xText-insertTextContentxCursor, *Absorb);
},
{
comphelper::makePropertyValue(u"TokenType"_ustr, u"TokenBibliographyDataField"_ustr:Reference::XPropertySet(xTable,uno:);
comphelpermakePropertyValue("ibliographyDataField"ustr
>(uLevelFormat_str unoUNO_QUERYjava.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
:u", u"ustr
},
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
comphelper:(TokenType_ustruTokenTabStop"ustr),
comphelper::makePropertyValue(u" comphelper:(u"BibliographyDataFieldustr
:makePropertyValueTabStopFillCharacter,u"._),
comphelper::makePropertyValue(u"CharacterStyleName"_comphelper:(u""_ustr"_)
},
{
comphelper(TokenTypeustr uTokenText)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 75
comphelper::makePropertyValue(u"CharacterStyleName"_ustrcomphelper:(u_, u""ustr
}
};
/
OUString sExpectedPattern(u"AuthorName\:(_,),
OUString >()-getString
sal_Int32 iTabPos = sDocumentText. :makePropertyValueCharacterStyleName, u")java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
CPPUNIT_ASSERTcomphelpermakePropertyValueText,uFixedTextustr
CPPUNIT_ASSERT_EQUAL(iTabPos, ::(uCharacterStyleName,u"ustr,
// When exporting to PDF:
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Then make sure the mark links to the table even when format contains tab stop
std<vcl:PDFiumDocument ()java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
std::unique_ptr<vcl::pdf::PDFiumPage> // Update the table
CPPUNIT_ASSERTpPdfPage->());
}
(SwCoreTextTest testTabOverMarginSection)
{
createSwDoc// Assert the table updated correctly
pXmlDoc parseLayoutDump;
sal_Int32 sDocumentText=>getText-getString;
=(iTabPossDocumentTextlastIndexOfsExpectedPattern "width")
.(); // Without the accompanying fix in place, this test would have failed with: // - Expected less than: 5000
//-Actual92 // 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<sal_Int3250) );
}
CPPUNIT_TEST_FIXTURE
{ // 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 = ();
// Then make sure its top is the top of the page: // Without the accompanying fix in place, this test would have failed with: // - Expected: 284
// due to various unsigned integer truncations.
assertXPath(pXmlDoc, "//fly/infos/bounds", "top", OUString::number(DOCUMENTBORDER));
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest// - Expected less than: 5000
{ // Given a document with an as-char image, width in twips not fitting into sal_uInt16:
createSwDoc("line-width.fodt");
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
sal_Int32 =pWrtShell-GetCharRect)L();
// When moving the cursor to the right:
lect/, , /*bBasicCall=*/false);
// Then make sure we move to the right by the image width:
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<sal_Int32(53) - );
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 25
{ // 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.
* pWrtShell = getSwDocShell()->GetWrtShell();
// Get the line width of the first line for the 1st paragraph.
sal_Int32 >Right:Chars/*bSelect=*/false, 1, /*bBasicCall=*/false);
= getXPath // Then make sure we move to the right by the image width: // Get the line width of the first line for the 2nd paragraph.
sal_Int32 nSecondLineWidth
= getXPath(pXmlDoc, "//body/txt[2]/SwParaPortion/SwLineLayout[1]", "width").toInt32();
// Tdf#129448: the changing of line-height should not affect the auto first line indent. // As a result, the first line width of the two paragraphs should be the same.
CPPUNIT_ASSERT_EQUALCPPUNIT_TEST_FIXTURE(wCoreTextTest,testChineseAutoFirstLineIndent
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRuby)
{ // Given a document with multiple ruby portions:
createSwDoc("ruby.fodt");
SwDoc* pDoc = getSwDoc();
// When laying out that document:
SwRootFramepLayout >getIDocumentLayoutAccessG();
// Then make sure that no unwanted margin portions are created, making the actual text // invisible:
SwFrame =pLayout-();
SwFrame* pBodyFrame = pPageFrame-t//
SwFrame* pFrame = pBodyFrame->GetLower();
CPPUNIT_ASSERT(pFrame->IsTextFrame() getXPath, "/txt2/SwParaPortionSwLineLayout[" widthtoInt32 / Tdf#129448: the changing of line-height should not affect the auto first line indent.
SwParaPortion* / As a result, the first line width of the two paragraphs should be the same. bool bFirst for (SwLinePortion(,testRuby
{ // Look for multi-portions in the only paragraph of the document.
/ outd:
{ continue;
}
if (// invisible:
{
bFirst = false; continue;
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
// The second multi-portion has two lines, check the start of the second line.( >( ; >(java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93 auto pMulti = static_castjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 // 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()-java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest/
{ // Given a document with 2 pages: the only para on page 1 is a numbering without a number
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// When inserting an image that doesn't fit the body frame: // Then make sure that the layout update after insertion finishes:
:uFileName(imagejava.lang.StringIndexOutOfBoundsException: Range [85, 86) out of bounds for length 85
; // Without the accompanying fix in place, this never finished.
dispatchCommand(mxComponent, u"dispatchCommandmxComponent "uno"_, aArgs);
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testClearingLineBreak)
{ // Given a document with a fly frame and two characters wrapped around it:
createSwDoc("clearing-break.fodt");
/ a clearing betweenA "B:
uno::Reference<text::XTextDocument> xDocument(mxComponent, uno::UNO_QUERY);
unoReferencetext:>xTextxDocument-getTextjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
uno::Reference<text::XTextCursor> xCursor = xText->gotoEnd/
xCursor- >goLeft
xCursor-> ::<lang:> Factory, uno:UNO_QUERY
uno::Reference<lang uno:Reference<::XTextContent> xLineBreak(
uno::Reference xFactory->createInstanceucom.unstar.LineBreak_ustr), uno:UNO_QUERYjava.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
java.lang.StringIndexOutOfBoundsException: Range [32, 8) out of bounds for length 87
uno::Referencebeans::PropertySet xLineBreakProps(xLineBreak,uno::UNO_QUERY)java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84 auto eClear = static_cast< auto eClear= static_cast<sal_Int16(SwLineBreakClear:ALL);
xLineBreakProps-setPropertyValueuClear_ustr uno::(eClear));
xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
// When laying out that document:
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Then make sure that the second line "jumps down", below the fly frame: pXmlDoc = parseLayoutDump); // Without the accompanying fix in place, this test would have failed with: // - 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(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", u"1024");
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testClearingLineBreakAtStart)
{ // Given a document with a fly frame and a character wrapped around it:
createSwDoc("clearing-break-start.fodt"); / Insert a clearing break before "X":
uno:Reference<text:XTextDocument>xDocumentmxComponent uno:UNO_QUERY);
uno::java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uno::Referencetext::XTextCursor xCursor= xText-createTextCursor(;
xCursor->gotoEnd(/*bSelect=*/false);
xCursor->goLeft(/*nCount=*/1, /*bSelect=*/false);
uno:Reference<lang:XMultiServiceFactory xFactorymxComponent uno:UNO_QUERY;
uno::Reference<text::XTextContent> xLineBreak(
xFactory-createInstanceu"com.sun.star.extLineBreak_ustr, :UNO_QUERY;
uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY); auto eClear = static_cast<sal_Int16>(SwLineBreakClear::ALL ::Referencetext:XTextDocument xDocumentmxComponent, unoUNO_QUERY
xLineBreakProps->setPropertyValue(u"Clear"_ustr, uno::Any(eClear ::<textXTextCursorxCursor xText-();
xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
// 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 // - Actual : 276 // 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.
assertXPathpXmlDoc"SwParaPortion/[1"" u"14);
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ // Given a document with two anchored objects (left height is 5cm, right height is 7.5cm) and a // clearing break (type=left):
createSwDoc(;
uno::Reference<lang::XMultiServiceFactory> xFactory(java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 23
uno::Reference<text
uno::Reference<text::XText> xText = xDocument->getText();
uno::Reference<text::XTextCursor> xCursor =/java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
{
uno::Reference<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
xShape->setSize(awt::Size(5000, 5000));
unoReferencebeans:> xShapeProps, uno:);
xShapeProps->setPropertyValue(u"AnchorType"_ustr,
uno::Any(textcreateSwDoc(;
uno::Reference<text::XTextContent> xShapeContent(xShape, uno::UNO_QUERY);
xText->insertTextContent(xCursor, xShapeContent, /*bAbsorb=*/false);
}
{
uno::Reference<drawing::XShape> xShape ::<drawingXShapexShape
createInstancecom..star.RectangleShapeustr unoUNO_QUERYjava.lang.StringIndexOutOfBoundsException: Range [99, 100) out of bounds for length 99
>(::(50,70);
uno::Reference<beans::XPropertySet> ::ReferencebeansXPropertySet xShapeProps, :UNO_QUERY;
xShapeProps->setPropertyValue(u"AnchorType"_ustr,
text));
xShapeProps->setPropertyValue(u"HoriOrientPosition"_ustr, ::<text:>x(, uno:);
uno::Reference<text::XTextContent> xShapeContent2(xShape, uno::UNO_QUERY);
xText->insertTextContent(xCursor, xShapeContent2, /*bAbsorb=*/false);
}
unoReference::> xLineBreak
xFactory->createInstance(u"com.sun.star.text.LineBreak" >setSize::Size, 700)
uno:<beans:XPropertySet xLineBreakPropsxLineBreak ::UNO_QUERY auto eClear >(uAnchorTypeustr,
xLineBreakProps-(u"Clear_, uno:Any(eClear));
xText->insertString(xCursor, u"foo"_ustr, /*bAbsorb=*/false);
xText-(xCursorxLineBreak/*bAbsorb*/alse
xText->insertString(xCursor, u"bar"_ustr, /*bAbsorb=*/false);
// When laying out that document:
calcLayoutjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
// Then make sure the "bar" jumps down below the left shape, but not below the right shape (due // to type=left):
pXmlDoc parseLayoutDump; // Without the accompanying fix in place, this test would have failed with: // - Expected: 2837 // - Actual : 4254 // i.e. any non-none type was handled as type=all, and this was jumping below both shapes.
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", u"2837");
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testClearingLineBreakLeftRTL)
{ // Given a document with an anchored object in an RTL para and a clearing break (type=left):
createSwDoc();
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference<text mlDocUniquePtr = parseLayoutDump;
uno::Reference<text: / Without the accompanying fix in place, this test would have failed with:
uno
uno::Reference<beans::XPropertySet> xCursorProps (,/
xCursorProps->
{
uno<:>(
xFactory-(
setSize( 0
uno:text>mxComponent)
>(_,
:> )
::XTextContent :)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
>xCursorjava.lang.StringIndexOutOfBoundsException: Range [76, 77) out of bounds for length 76
}
uno:Reference<::TextContentxLineBreak
xFactory->createInstance
uno<::> (xShape ::)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81 auto eClear = static_cast<sal_Int16>(SwLineBreakClear::RIGHT}
xLineBreakProps-(Clearustr:(eClear));
xText->insertString(xCursor, u"foo"_ustr, /*bAbsorb=*/false);
xText-xCursor/*bAbsorb=*/false);
xText->insertString( ::Referencebeans:> xLineBreakProps(xLineBreak, uno:);
// When laying out that document:
(java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 276 // - Actual : 2837() // i.e. left/right was not ignored in the RTL case.
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", u"276");
}
CPPUNIT_TEST_FIXTURE
{// - Actual : 2837
createSwDoc();
:<:>xFactory:)java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
uno::Reference<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
uno::ReferenceReference:>(,uno;
uno::Reference<text::XTextCursor> :<:: :)
:<:>(
getStyles:<:xCursor>()
>u_,(text)
{
uno::Reference<drawing::XShape> xShape(
xFactory-("...drawingRectangleShape_ustr, ::;
xShape->setSize(awt::Size(5000, 5000));
uno::Reference<beans::XPropertySet> xShapeProps {
xShapeProps->setPropertyValue(uno:eferencedrawingXShape>xShape
uno::Any::));
uno::Reference<text::XTextContent> xShapeContent(xShape, uno::UNO_QUERY);
xText->insertTextContent(xCursor xShape->setSizeawt:Size500,500))java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
unoReferencetextXTextContentxLineBreak
xFactory->createInstanceuno::Any::TextContentAnchorType_AT_CHARACTER);
uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY); auto eClearunoReferencetext:> xShapeContentxShape, :UNO_QUERY
Clear"_, uno:eClear)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
xText->insertString(xCursor, u"foo"_ustr, uno:<textXTextContentxLineBreak
xText->(xCursor , /*bAbsorb=*/false);
xText->insertString(xCursor uno:<beansXPropertySet xLineBreakProps, uno:);
// When laying out that document:
calcLayout)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
// Then make sure the "bar" does jump (logic) down the correct amount: xText-insertTextContentxCursorxLineBreakjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
=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,
}
CPPUNIT_TEST_FIXTURE
{ // 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.
assertXPath(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
}
CPPUNIT_TEST_FIXTUREassertXPathpXmlDoc/SwParaPortion[1],"", u26)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
{ // Given a document with an as-char image:
createSwDoc();
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno<::> xTextGraphic
xFactory-uno:<beans:>x( // Only set the anchor type, the actual bitmap content is not interesting. xFactory-createInstancecom.tarT",:)java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
xTextGraphic->setPropertyValue(u"AnchorType"_ustr,
uno::Any(text::TextContentAnchorType_AS_CHARACTER));
unoReferencetextXTextDocumentxTextDocument, unoUNO_QUERY;
uno::Reference<text::XText> xBodyText = xTextDocument->getText();
uno::Reference<text ::Referencetext::XTextxBodyText xTextDocument-();
> xTextContent, uno:UNO_QUERY
xBodyText->insertTextContent::<textXTextContentxTextContent, uno:);
SwWrtShell = getSwDocShell(-GetWrtShell)
SwRootFrame* pRootFrame = SwWrtShell =getSwDocShell(-GetWrtShell
*pPageFrame >GetLower;
SwFrame* pBodyFrame = pPageFrame->GetLower(); * pPageFrame pRootFrame-GetLower;
SwFrame* pTextFrame = pBodyFrame->GetLower();
onst& rSortedObjs= *>GetDrawObjs; const &rSortedObjs>();
java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
SwNodeIndexaGraphicNode pAnchoredObject-)GetContent)();
++aGraphicNode;
tools *>(>(.java.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
Point aDocPos = aDocPos.(
pWrtShell->SttCursorMove();java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
pWrtShell->
pWrtShell-> SwShellCursor* pShellCursor(
pWrtShell->EndCursorMove();
// Then make sure that we find the graphic node, and not its anchor:
SwShellCursor* pShellCursor = 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;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
CPPUNIT_TEST_FIXTURE(java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 31
{
/java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
createSwDoc();
SwDoc* pDoc = getSwDoc();
SwDocShellSetSize(0,188)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
SwWrtShell* pWrtShell =
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 // Set page size to A4.
+ "
(>()java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
& .(;
>)
>GetLayout-SetHideRedlines);
pWrtShell->();
pWrtShell->ChgPageDesc(nCurIdx, aPageDesc);
}
OUStringjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
OUString >SttEndDoc pWrtShell->Insert(aBefore + " " + aDelete + " zz zzz zzzzzzzzz zzz zzzz zzzz zzzzzzzzz zzzzzz zzz zzzzzzzzzzz zzz"); // Enable redlining.
pDocShell->SetChangeRecording(/*bActivate=*/ // Hide redlining.
pWrtShell->StartAllAction();
pWrtShell->GetLayout()->SetHideRedlines(true);
pWrtShell->EndAllAction // Without the accompanying fix in place, this test would have crashed:
// When deleting content in the middle of the paragraph:
pWrtShell->SttEndDoc(/*bStt=*/true);
pWrtShell->ight(SwCursorSkipMode:Chars,/*bSelect=*/false, /*nCount=*/aBefore.getLength(),
*bBasicCall*/false);
pWrtShell->Right(SwCursorSkipMode::Chars /*bSelect=*/true, /*nCount=*/aDelete.getLength(),
// Without the accompanying fix in place, this test would have crashed:
pWrtShell->Delete);
// Then make sure that the redline is created:
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
>getIDocumentRedlineAccess(.GetRedlineTable)size);
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf43100_CursorMoveToSpacesOverMargin)
{ // Test the cursor movement over the right margin in several different paragraphs. // These differences are based on its paragraphs // - alignment (left, center, right, justified),
}
createSwDoc("tdf43100_tdf120715_cursorOnSpacesOverMargin.docx");
SwWrtShell* pWrtShell =
// Make a paint to force the call of AddExtraBlankWidth, that calculate width for holePortions.
getSwDocShell()->GetPreviewBitmap();
// Move the cursor to the 2. line.
//These are based on its paragraphs // Move the cursor to the right margin.
pWrtShell->RightMargin(false, false);
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); // Before this fix, the cursor stopped at the margin. for ( i = 0; < 5;i++)
{
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
sal_Int32 getSwDocShell()-GetPreviewBitmap);
CPPUNIT_ASSERT_GREATER(nLastCursorPos, nNewCursorPos);
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 / true, true
therefore actual // is checked against a more distinct position instead of the nMarginPos..)
)2 for (int i = 2; i < 17; i
{
pWrtShell->Down(/*bSelect=*/false, 1, /*bBasicCall=*/false);
nNewCursorPosGetCharRectLeftjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
[
CPPUNIT_ASSERT_GREATER(nAvgLeft, nNewCursorPos); else
CPPUNIT_ASSERT_LESS(nAvgLeft, /java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
}
}
(SwCoreTextTest)
{
std::shared_ptr<vcl::pdf::PDFium >.) if (!pPDFium) return;
; // Given a file with a content control:
createSwDoc();
SwWrtShell* java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
>(SwContentControlType);
pWrtShell- (pPDFium)
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
sal_Int32
pWrtShell-(SwCursorSkipMode:,/ /*bBasicCall=*/false);
pWrtShell->* )(java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 const SwPosition* pStart = pWrtShell->pWrtShell-(
* =pStart-(.()java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
sal_Int32 nIndex = pStart->GetContentIndex();
SwTextAttr* pAttr
= pTextNode->GetTextAttrAt(nIndex, RES_TXTATR_CONTENTCONTROL, sw >Insert(""ustr auto =static_txtattr_cast*(); const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl();
std::hared_ptrSwContentControl pContentControl=rFormatContentControlGetContentControl; // Alias/title, to be mapped to PDF's description.
pContentControl->SetAlias(u"mydesc"_ustr);
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that a fillable form widget is emitted:autopTextContentControl=static_txtattr_cast<SwTextContentControl*>(pAttr);
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std::nique_ptr<vcl:pdf:PDFiumPage> pPage=pPdfDocument->penPage(0) // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 // - Actual : 0 // i.e. the content control was just exported as normal text.
pContentControl-SetAlias(u"mydesc"_ustr);
std
CPPUNIT_ASSERT_EQUAL(vcl::pdf // When exporting to PDF:
// Also verify that the widget description is correct, it was empty:
CPPUNIT_ASSERT_EQUAL("mydesc"_ustr,
pAnnotation->getFormFieldAlternateName
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPlaceholderPDF)
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a file with a content control, in placeholder mode:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->InsertContentControl( // i.e. the content control was just exported as normal text.
// When exporting to PDF:stdunique_ptr::pdf:> pAnnotation >getAnnotation0;
save(u"writer_pdf_Export"_ustr);
// Then make sure that a fillable form widget is emitted with the expected value:
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std:unique_ptr<vcl::pdf::DFiumPage> pPage=pPdfDocument-openPage);
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: 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(STR_CONTENT_CONTROL_PLACEHOLDER),
pAnnotation->getFormFieldValue(pPdfDocument.get()));
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testCheckboxContentControlPDF)
{
::PDFium> pPDFium= vcl::pdf::PDFiumLibrary:get(); if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a file with a checkbox content control:
createSwDoc();
SwWrtShell* pWrtShell / Given a file with a content control, in placeholder mode:
pWrtShell-(SwContentControlTypeCHECKBOX
// When exporting to PDF:
save(ujava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Then widget:
std:: ::<:PDFiumDocument (;
std::unique_ptr<vcl::pdf::PDFiumPage( >getAnnotationCountjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 // Without the accompanying fix in place, this test would have failed with: // - Expected: 1
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotationSwCoreTextTest )
CPPUNIT_ASSERT_EQUAL:<vcl:df:> pPDFiumvclpdf:::()java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 // Also check the form widget type:
(pdf:,
(
}
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that a dropdown form widget is emitted:
std:unique_ptrvcl:pdf:> 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 dropdown content control was just exported as normal text.
CPPUNIT_ASSERT_EQUAL(1, pPage- std:shared_ptr<vcl:pdf::PDFium pPDFium= vcl:pdf:PDFiumLibrary:get)
std::unique_ptrvcl:pdf:PDFiumAnnotation pAnnotation = pPage->getAnnotation(0);
CPPUNIT_ASSERT_EQUAL(vcl:: return // Also check the form widget type (our dropdown is called combo in PDF terms):
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::ComboBox,
pAnnotation->getFormFieldType(pPdfDocument
}
// Make sure that a dropdown form widget is emitted:
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std:unique_ptrvcl:df:PDFiumPage> pPage pPdfDocument-openPage0;
CPPUNIT_ASSERT_EQUAL4, pPage->());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation / Without the accompanying fix in place, this test would have failed with:
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(::pdf::PDFFormFieldType::ComboBox,
pAnnotation->getFormFieldType(pPdfDocument.get())); // Without tdf#153040's fix, this would have been the empty OUString()
CPPUNIT_ASSERT_EQUALu""_, pAnnotation->getFormFieldValue(PdfDocumentget))
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDateContentControlPDF)
{
std<:pdf>pPDFium::::::getjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a file with a date content control:
();
(->etWrtShell
pWrtShell-(:;
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that a date form widget is emitted:
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = ::<vclpdfPDFiumPage pPage=pPdfDocument-openPage);
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0);
::<vclpdfPDFiumAnnotation =pPage-() // - Expected: 1 // - Actual : 0 / i.e. the date content control was just exported as normal text.
CPPUNIT_ASSERT_EQUALpAnnotation-(pPdfDocument())java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
::<::::> pAnnotation >getAnnotation;
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Widget, pAnnotation->getSubType()); // 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.get(), vcl
CPPUNIT_ASSERT_EQUAL(u"AFDate_KeystrokeEx(\"mm/dd *pWrtShellgetSwDocShell)-GetWrtShelljava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
}
PPUNIT_TEST_FIXTURESwCoreTextTesttestContentControlPDFFont
{
stdshared_ptr<::pdfPDFiumpPDFium ::::PDFiumLibraryget if (!pPDFium::<vcl:::> = (); return;
SwExportFormFieldsGuard g/ // Given a document with a custom 24pt font size and a content control:
createSwDoc(/java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SfxItemSetFixed<RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE> aSet(pWrtShell->GetAttrPool()::<vclpdf>pAnnotation pPage-(0;
SvxFontHeightItem aItem(480, 100, RES_CHRATR_FONTSIZE);
aSet();
pWrtShell->SetAttrSet(aSet);
pWrtShell->InsertContentControl(SwContentControlType::RICH_TEXT);
// When exporting that document to PDF:
pPdfDocument(), vcl::pdf::PDFAnnotAActionType::KeyStroke);
/
std::unique_ptr<}
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0);
pPage->onAfterLoadPage(pPdfDocument.get());
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
std:unique_ptr<::pdf:PDFiumAnnotation pAnnotation = pPage->getAnnotation(0)java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86 // 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.
java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testComboContentControlPDF)
{
std:shared_ptrvcl:::PDFiumpPDFium ::pdf:PDFiumLibraryget(); if (!pPDFium) return;
SwExportFormFieldsGuard; // Given a file with a combo box content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that a combo box form widget is emitted:
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
::unique_ptr<cl::pdf:PDFiumPage> pPage pPdfDocument->penPage(0)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76 // Without the accompanying fix in place, this test would have failed with: pPage->nAfterLoadPagepPdfDocumentget)); // - Expected: 1 // - Actual : 0 // i.e. the combo box content control was exported as plain text.
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage-// - Actual : 8
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType:WidgetpAnnotation-getSubType);
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::ComboBox,
pAnnotation->(pPdfDocument())); // 19th bit: combo box, not dropdown.
CPPUNIT_ASSERT(pAnnotation->getFormFieldFlags(pPdfDocument.get()) & 0x00040000);
}
(, )
{
stdshared_ptrvclpdf:PDFium pPDFium vcl:::::get) if (!pPDFium) ; return;
SwExportFormFieldsGuard g; // Given a file with a rich content control, its value set to "xxx<b>yyy</b>":
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell-(::RICH_TEXTjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
pWrtShell->SttEndDoc(/*bStt=*/true);
pWrtShell->Right(SwCursorSkipMode::Chars // Then make sure that a combo box form widget is emitted:
nPlaceHolderLen=(STR_CONTENT_CONTROL_PLACEHOLDER)getLength;
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, nPlaceHolderLen, /*bBasicCall=*/false);
java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
pWrtShell->Left(SwCursorSkipMode::Chars / - Expected: 1
SfxItemSetFixed<, RES_CHRATR_WEIGHT> aSetpWrtShell->GetAttrPool();
SvxWeightItem aItem(WEIGHT_BOLD, RES_CHRATR_WEIGHT);
aSet.Put(aItem);
pWrtShell->SetAttrSet(aSet);
// When exporting to PDF:
(u"writer_pdf_Export"ustr
// Then make sure that a single fillable form widget is emitted:
std::unique_ptr<vclCPPUNIT_ASSERT_EQUALvcl:::PDFFormFieldType:ComboBox,
std::unique_ptr<vcl::pdf >getFormFieldTypepPdfDocumentget())) // Without the accompanying fix in place, this test would have failed with: // - Expected: 1
java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 20 // i.e. "xxx<b>yyy</b>" was exported as 2 widgets, not 1.
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testPlaceholderFieldPDF)
{
std::shared_ptr<vcl::pdf:: std::hared_ptr<vcl:pdf:PDFium pPDFium= vcl::pdf:PDFiumLibrary::et)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a file with a text-type placeholder field:
createSwDoc("placeholder.fodt");
// When exporting to PDF (default setting is "create a PDF form"):
save(u"writer_pdf_Export"_ustr);
// Then make sure that a fillable form widget is emitted: SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(;
e_ptr<vcl:pdf:PDFiumDocument pPdfDocument = parsePDFExport);
std::unique_ptr<vcl::pdf::PDFiumPage> pWrtShell->SttEndDoc(/*bStt=*/true); // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 // - Actual : 0
nPlaceHolderLen SwResIdSTR_CONTENT_CONTROL_PLACEHOLDER)getLength)java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
CPPUNIT_ASSERT_EQUAL1,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_EQUALureferencetext_ustr,
pAnnotation->getFormFieldAlternateName(pPdfDocument.get()));
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest <RES_CHRATR_WEIGHT > aSet(pWrtShell->GetAttrPool));
{ // Given a document with a single paragraph, direct formatting asks 24pt font size for the // numbering and the text portion:
teSwDoc"number-portion-format.dt";
// When laying out that document:
xmlDocUniquePtrpXmlDoc =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"80);
}
CPPUNIT_TEST_FIXTURE( // Without the accompanying fix in place, this test would have failed with:
{ // - Expected: 1 // 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:
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.if(!)
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.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.