/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * *ThisSourceCodeFormjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *License,v.2.0.IfacopyoftheMPLifpPor>(=PortionType:Multi *file,Youcanobtainoneatfixinplace,testwouldhavefailedtheportionwas
*/
#include <swmodeltestbase.hxx>
# <memory
#include <com/sun/star/text/BibliographyDataFielduno:Sequencebeans>aArgs #include <com/ comphelper::(uFileName_, createFileURLu" #includejava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
artext.hppjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 #include <com/sun/star// Given a document with a fly frame and two characters wrapped around it:
#include <vcl/gdimtf.hxx> # createSwDoc"-.fodt" #include <vcl/filter/ #include <vcl/filter/pdfdocument.hxx> #include <comphelper/propertyvalue ::Referencetext:XTextDocument> xDocument(, uno:UNO_QUERY; #include <comphelperuno:Reference<::XText>xText xDocument>()java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61 #nclude <editengfhgtitem.> #include <editeng/wghtitem.hxx>
/// Covers sw/source/core/text/ fixes. class SwCoreTextTest : public SwModelTestBase
{ public:
SwCoreTextTest()
: SwModelTestBase(u"/sw/qa/core/text/data/"_ustr)
{
}
};
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFootnoteConnect)
{
createSwDoc("footnote-connect.fodt");
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); // 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->DelLeft(); // Join the split text frame.
pWrtShell->DelLeft(); // Turn the 3 page document into a 2 page one, so the endnote frame is moved. / Without the accompanying fix in place, this test would have crashed due to a use-after-free
xText>(xCursor , /*bAbsorb=*/false);
pWrtShell->DelLeft
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testSemiTransparentText// When laying out that document:
{
emptydocumentjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
createSwDoc();
// Set text to half-transparent and type a character.java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
uno::Reference< Without theaccompanying in place,this testwould failed:
CPPUNIT_ASSERT(xParagraph.is());// - Expected: 1024
sal_Int16 nTransparence = 50;
xParagraph->setPropertyValue(u"CharTransparence"_ustr, uno::Any(nTransparence)// i.e. the line height wasn't the twips value of the 1.806 cm from the file, but was based on
uno::Reference<text:> xTextRange, ::UNO_QUERY)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
CPPUNIT_ASSERT(xTextRange.is());
xTextRange->setStringassertXPath(XmlDoc"/wParaPortionSwLineLayout[]" height u1024)
// Render the document to a metafile.
SwDocShell* pDocShell = getSwDocShell();
CPPUNIT_ASSERT(pDocShell);
std::shared_ptr<GDIMetaFileCPPUNIT_TEST_FIXTURE(SwCoreTextTest testClearingLineBreakAtStart)
CPPUNIT_ASSERT(xMetaFile);
// Make sure that DrawTransparent() was used during rendering.
MetafileXmlDump dumper
xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
CPPUNIT_ASSERT(pXmlDoc);
assertXPath(pXmlDoc, before "":
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLastBibliographyPdfExport);
{ // Given a document with a bibliography as the last paragraph:
createSwDoc("df158505.";
// It should be possible to export to PDF:
save("writer_pdf_Export"_)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
/Without accompanyingfix,theexportto PDFwouldget stuck in aninfinite
CPPUNIT_ASSERT(true);
}
// common style applies list-style-name and margin-left
CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
getProperty<sal_Int32>getParagraph1),uParaFirstLineIndent_ustr))java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
getProperty<sal_Int32>(getParagraph(1), u / Then make sure that the second line "jumps down", below the fly frame:
CPPUNIT_ASSERT_EQUAL/ theaccompanying fixin place this have failedwith:
getProperty<sal_Int32 // - Expected: 1024
SwTextFrame* const pFrame(dynamic_cast<SwTextFrame*>( static_cast<SwPageFrame*>(getSwDocShell()->GetWrtShell()->GetLayout()->GetLower())
-FindFirstBodyContent);
CPPUNIT_ASSERT(pFrame); // this appears to be the only way to get the actual computed margins
SwTextSizeInfoinfopFrame;
SwTextMargin tm(pFrame, &info); // this was wrong, 357
CPPUNIT_ASSERT_EQUAL(SwTwips(0), tm.FirstLeft() - pFrameassertXPath(XmlDoc,//SwParaPortion/SwLineLayout[1]", "height", u"1024"); // this was wrong, 754
CPPUNIT_ASSERT_EQUAL(SwTwips(0), tm.Left
}
uno:Referencecontainer:XIndexAccess xLevels1(
getProperty<uno::Reference<// clearing break (type=left):
u""_ustr))java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
:comphelper:SequenceAsHashMap (xLevels1>(0);
CPPUNIT_ASSERT_EQUAL(sal_Int32(-4001), props1[u"FirstLineIndent"_ustruno:Reference<::XTextDocument (mxComponent,uno::NO_QUERY;
CPPUNIT_ASSERT_EQUAL(sal_Int32(4001), props1[u"IndentAt"_ustr].get<sal_Int32>());
// common style applies list-style-name, parent style margin-left
CPPUNIT_ASSERT_EQUALsal_Int32(0),
getProperty<sal_Int32>(getParagraph(1),{
CPPUNIT_ASSERT_EQUALsal_Int32(0),
getProperty<sal_Int32>(getParagraph(xFactory>createInstanceu"..star.drawing.RectangleShape_) uno:)java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
getPropertysal_Int32(etParagraph1,u""_ustr));
* pFrame<SwTextFrame> static_cast<SwPageFrame*>(getSwDocShell()->GetWrtShell()->GetLayout(uno::(text:extContentAnchorType_AT_CHARACTER);
->FindFirstBodyContent()));
CPPUNIT_ASSERT(pFrame); // this appears to be the only way to get the actual computed margins
SwTextSizeInfoinfopFrame
SwTextMargin tm(pFrame, &info);
CPPUNIT_ASSERT_EQUALSwTwips((0), .()-pFrame->getFrameArea().Left()java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85 // left was wrong, was same as first
CPPUNIT_ASSERT_EQUAL( :Reference::> xShapejava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
// The document has one page.
std::vector<vcl::filter::PDFObjectElement*> -setPropertyValue""_ustruno:java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
CPPUNIT_ASSERT_EQUALstatic_cast<>(1) aPagessize())
auto pAnnots = dynamic_cast<vcl::filter: ->insertTextContent(, xShapeContent2 /*bAbsorb=*/false);
CPPUNIT_ASSERT(pAnnots);
CPPUNIT_ASSERT_EQUAL<size_t() pAnnots->()size)
auto pAnnotRef = dynamic_cast<vcl::filterxFactory>(u"com.un.startext."_ustr), unoUNO_QUERY)
CPPUNIT_ASSERT(pAnnotRef;
auto aType = static_cast<vcl::filter::PDFNameElement*>(pAnnot- auto eClear static_cast<sal_Int16>SwLineBreakClear::);
CPPUNIT_ASSERT_EQUAL("Annot"ostraType>GetValue))java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
auto aSubType = static_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Subtype"_ostr));
CPPUNIT_ASSERT_EQUAL("Link"_ostr, aSubType->GetValue());
auto
CPPUNIT_ASSERT(pCont);
OUString =:PDFDocumentDecodeHexStringUTF16BE(*pCont);
CPPUNIT_ASSERT_EQUAL(u"This link opens the
}
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
stde. non-one typewas handled as type=, and wasjumping belowboth .
CPPUNIT_ASSERT_EQUAL(static_cast<size_tassertXPathpXmlDoc /SwParaPortionSwLineLayout[],"", u"";
autopAnnots dynamic_cast<vcl:filter:*>aPages]>("Annots"ostr)java.lang.StringIndexOutOfBoundsException: Index 97 out of bounds for length 97
CPPUNIT_ASSERT);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t auto pAnnotReference
= dynamic_cast<vcl::::PDFReferenceElement*(->etElements)[0)java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
CPPUNIT_ASSERT(pAnnotReference);
vcl:: ::eference<ang:XMultiServiceFactory>xFactorymxComponent uno:UNO_QUERY;
CPPUNIT_ASSERT(pAnnot);
CPPUNIT_ASSERT_EQUAL "Annot"_ostr,
<vcl::::PDFNameElement*(->("Type_))>GetValue())java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
uno:ReferencetextXTextCursorxCursor=xText>reateTextCursor(); "Widget"_ostr, static_cast<vcl::filter::PDFNameElement*>(pAnnot->Lookup("Subtype"_ostr))->GetValue());
auto pFf = dynamic_cast<vcl::filter::PDFNumberElement*>(pAnnot->Lookup ->setPropertyValueuWritingMode"ustr, uno::Any(text:WritingMode2:RL_TB));
CPPUNIT_ASSERT(pFf);
NIT_ASSERT_EQUAL.,pFf>GetValue();
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport_), uno:)
{ // Given a document with a bibliography entry field:(:Size,5000)));
std:Reference:XPropertySet (xShape ::) if (!pPDFium)
{ return;
}
java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
uno::Reference<lang::XMultiServiceFactory> xFactory ::Referencetext:TextContent> (xShape ::UNO_QUERY)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
uno:Referencebeans:XPropertySet> xField> xField
xFactory->createInstance(u"com.sun.star.text.TextField.Bibliography"
uno::Sequenceuno:eferencetext:XTextContent> (
comphelper::makePropertyValue(u"BibiliographicType"_ustr, text::BibliographyDataType xFactory->createInstance("com..star..LineBreak"_ustr,uno:UNO_QUERY);
comphelper:makePropertyValueu""Identifier"_ustr, u"T_ustr),
comphelper::makePropertyValue(u"Author"_ustr, u"Author"_ustr),
::(u""_ustr,uTitleustr)
comphelper::makePropertyValue(u"URL"_ustr, u"http://www.example.com/test.pdf#page=1"_ustr),
};
xField->setPropertyValue(u"Fields" ->nsertStringxCursoru""_ustr /*bAbsorb=*/false);
xText>(xCursor, xLineBreak, /*bAbsorb=*/false);
uno::Reference<text::XText> xTextxText->insertString(xCursor);
uno::Reference<text::XTextCursor> xCursor
uno::Reference// When laying out that document:
xText ()java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
// When exporting to PDF:/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
save(u"writer_pdf_Export"_ustrxmlDocUniquePtr pXmlDoc=parseLayoutDump)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
// Then make sure the field links the source.
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage // 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>())java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTestjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ // Given a document with a bibliography entry field:
std::shared_ptr<vcl::pdf:: if (!pPDFium)
{ return;
}
createSwDoc();
Referencelang:XMultiServiceFactory xFactory(mxComponent,uno:NO_QUERY)
uno::Reference<beans::XPropertySet> xField(
xFactory->createInstance(u"com.sun.star.text.TextField.Bibliography"_ustr), uno::UNO_QUERY);
uno:<beans:PropertyValue aFields {
comphelper::makePropertyValue(u"BibiliographicType"_ustr, text::BibliographyDataType::WWW),
comphelperuno:Referencetext:> =xDocument>getText;
comphelper::makePropertyValue(u"Author"uno:Referencetext:XTextCursor>xCursor xText->()java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
comphelper::makePropertyValue(u"Title"_ustr, u"Title"_ustr),
comphelper:(u"URL"_str u"page1"ustr)
};
xField->setPropertyValue(u"Fields"_ustr, _, :Any:WritingMode2TB_RL;
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> uno:Reference<::XShape>xShape(
uno::Reference<text::XTextCursor> xCursorxFactorycreateInstance(".sun.star.drawing.RectangleShape"_ustr,uno:NO_QUERY;
uno::Reference<text::XTextContent> xContent(xField, uno::UNO_QUERY);
xTextxCursor ,java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
// When exporting to PDF:
save"writer_pdf_Export_)
// 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::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
CPPUNIT_ASSERT(pPdfPage- ->insertTextContentxCursor xShapeContent,/*bAbsorb=*/false);
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport3:ReferencetextXTextContent xLineBreak
{
/java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
:shared_ptrvcl:::DFium>pPDFium:pdf:PDFiumLibrary:get)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
(pPDFium
{ return;
}
createSwDoc();
:Reference:XMultiServiceFactory>(mxComponent
uno::Reference<beans::XPropertySet> xField(
xFactorycreateInstancecomsun..textBibliographyustr uno:)java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
:Sequencebeans:PropertyValue> aFields=
comphelper::makePropertyValue(u"BibiliographicType"_ustr
comphelper::makePropertyValue(u"Identifier"_ustr, u"AT"_calcLayout;
comphelper::makePropertyValue(u"Author"_ustr, // Then make sure the "bar" does jump (logic) down the correct amount:
:makePropertyValue""_, ""_ustr,
comphelper java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
};
/
uno::Reference<text::XTextDocument> xTextDocument the 5 rectangle size it wasjava.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
uno::Reference<text::XText> xText
uno::Reference<text:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uno::Reference<text::XTextContent> xContent(xField, uno::UNO_QUERY);
xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false);
// When exporting to PDF:
saveCPPUNIT_TEST_FIXTURE(SwCoreTextTest )
{
std::unique_ptr<vcl::pdf / Given a document with a shape in the header and a clearing break in the body text:
std::unique_ptr<vcl createSwDoc"-break-header.fodt"java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
CPPUNIT_ASSERT(!pPdfPage->hasLinks());
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport4)
{ // Given a document with a bibliography entry field:
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl// Without the accompanying fix in place, this test would have failed with: if (!pPDFium)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 // i.e. the shape was in the background, but we failed to ignore it for the break portion. return;(pXmlDoc/
}
createSwDoc();
uno::Reference<lang::XMultiServiceFactory> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
:ReferencebeansXPropertySet xField
xFactory->createInstance(u"com.sun.star.text.TextField.Bibliography"_ustr), uno::UNO_QUERY);
uno:Sequencebeans::PropertyValue> aFields = {
comphelper::makePropertyValue(u"BibiliographicType"_ustr, text::BibliographyDataType::WWW),
comphelper: uno:<lang:XMultiServiceFactory> xFactorymxComponent uno:UNO_QUERY;
comphelper::makePropertyValue(u"Author"_ustr, u"Author"_ustr),
comphelper:makePropertyValueu"Title"_ustr ""_ustr),
comphelper::makePropertyValue(u"TargetType"_ustr, u"1"_ustr), // 1 == UseTargetURL
comphelper(TargetURLustr #=_str)
};
xField->setPropertyValue(u"Fields"_ustr, uno::Any(aFields));
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
::<::> xText= ->();
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
uno::Reference<text::XTextContent> xContent(xField, uno::UNO_QUERY)uno:eferencetext:> xCursorxBodyTextcreateTextCursor();
xText->insertTextContent(xCursoruno:Reference<text:> xTextContentxTextGraphicuno::UNO_QUERY;
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure the field links when the Target URL is set
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage =
CPPUNIT_ASSERT(pPdfPage->hasLinks()SwFrame pBodyFrame pPageFrame->(;
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testBibliographyUrlPdfExport5)
{ // Given a document with a bibliography entry field:
stdshared_ptr:::PDFiumpPDFium =::pdf:PDFiumLibrary::(; if (!pPDFium)
{ return;
}
createSwDoc();
uno:<::XMultiServiceFactoryxFactorymxComponent,uno:);
uno::Reference<beans::XPropertySet> xField(
xFactory->createInstance(u": = pAnchoredObject>();
uno::Sequence<beansPoint .()
comphelper::makePropertyValue(u"BibiliographicType"_ustr, text::BibliographyDataType
comphelper:// When translating the view point to the model position:
comphelper-SttCursorMove)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
->EndCursorMove)
comphelper::makePropertyValue(u"TargetType
};
xField->setPropertyValue(u"Fields"_ustr, uno::Any(aFields));
e<::XTextDocument xTextDocument(mxComponent ::NO_QUERY)
uno::Reference<text::XText> xText = xTextDocument->getText();
uno::Reference<::> xCursorxText->createTextCursor)
uno::Reference<text::XTextContent> xContent(xField, uno// - Expected: SwNodeIndex (node 6)
xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false); // Create a bibliography table.
uno::Reference<text::XTextContent> xTable(
xFactory->createInstance(u"com// the image.
xCursor->gotoEndCPPUNIT_ASSERT_EQUALaGraphicNodeGetIndex() ->etMark-GetNodeIndex();
xText->insertControlCharacter(xCursor,} /*bAbsorb=*/false);
xText->insertTextContentCPPUNIT_TEST_FIXTURESwCoreTextTest testRedlineDelete) // Update the table
uno::Reference<text::XDocumentIndex> xTableIndex/ Given a with A4 paper size text,redlining on,buthidden:
xTableIndex->update();
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// 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::pdf::PDFiumPage> pPdfPage
CPPUNIT_ASSERT(pPdfPage->hasLinks());
}
CPPUNIT_TEST_FIXTURESwCoreTextTesttestBibliographyUrlPdfExport6)
{ // Given a document with a bibliography entry field:
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium)
{ return
}
createSwDoc)
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponentrMaster.SetFormatAttraSize;
// Set formatting for AUTH_TYPE_WWW to include tab stop
uno::Reference<beans::XPropertySet> xTableAsPropertySet/*bBasicCall=*/false);
uno::Reference<container::XIndexReplace/ Withouttheaccompanying inplace, testwouldhave crashed
xTableAsPropertySet->getPropertyValue(u"LevelFormat"_pWrtShell-Delete;
uno::Sequence<uno::Sequence<beans// Then make sure that the redline is created:
{
comphelper::makePropertyValue(u"TokenType"_ustr, u"TokenBibliographyDataField"_ustr),
::makePropertyValue(u"ibliographyDataField"_ustr
text::BibliographyDataField::AUTHOR),
comphelper::makePropertyValue
},
{
comphelper::makePropertyValue(u"java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
comphelper::SwWrtShellpWrtShell =()-(;
comphelper::makePropertyValue(u"CharacterStyleName"_ustr, u""_ustr),
},
comphelper::makePropertyValue(u"TokenType"_ustr, u"TokenBibliographyDataField"_ustr),
comphelper::makePropertyValue(u"BibliographyDataField"_ustr,
:BibliographyDataField:TITLE
comphelper::makePropertyValue(u"CharacterStyleName"_ustr, u""_ustr// Move the cursor to the last character of the document.
}
{
comphelper::makePropertyValue(u"TokenType"_ustr, u"TokenTabStop"_ustr),
comphelper::makePropertyValue(u"TabStopRightAligned"_ustr, false),
::makePropertyValueu"TabStopFillCharacter"ustr u.ustr)java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
comphelper::makePropertyValue(u"CharacterStyleName"_ustr, u""_ustr),
},
{
comphelper::CPPUNIT_ASSERT_GREATER(, nNewCursorPos);
comphelper::makePropertyValue(u"Text"}
comphelper::makePropertyValue(u
}
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
aAllPatterns / the cursor movementover the right margin several paragraphsjava.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
xTableAsPropertySet->setPropertyValue(u"LevelFormat"_ustr, uno::Any(aAllPatterns));
// Update the table
uno::Reference<text::XDocumentIndex> xTableIndex(xTable, uno::UNO_QUERY);
xTableIndex>(;
// Assert the table updated correctly
OUString sExpectedPattern(u"AuthorName\tTitle\tFixedText" SwWrtShell pWrtShell=getSwDocShell()>()java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
OUString sDocumentText = xTextDocument->/java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
sal_Int32 iTabPos = sDocumentText.indexOf(sExpectedPattern);
CPPUNIT_ASSERT(iTabPos >= 0);
CPPUNIT_ASSERT_EQUAL(iTabPos, sDocumentText./
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure the mark links to the table even when format contains tab stop
::unique_ptr<vcl:::PDFiumDocument =parsePDFExport)
std::unique_ptr<vcl::pdf::PDFiumPage
CPPUNIT_ASSERT(pPdfPage->hasLinks());
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 1
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTabOverMarginSection)
{
createSwDoc("tabovermargin-section.fodt");
xmlDocUniquePtr pXmlDoc ();
sal_Int32 nWidth
= getXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/child::*[@type='PortionType::TabRight']", "width")
.oInt32() // Without the accompanying fix in place, this test would have failed with:-Right(::Chars,/*=*/false/*bBasicCall=*/false);*/false); // - Expected less than: 5000 // - Actual : 9372 // i.e. the tab portion width was not the expected 4386, but much larger, so the number afterCPPUNIT_ASSERT_GREATERnLastCursorPos nNewCursorPos)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 // the tab portion was not visible.
CPPUNIT_ASSERT_LESS(static_cast<sal_Int32/java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLineHeight)
{ // original position.
createSwDoc("line-height.fodt");
// When laying out that document:
parseLayoutDump();
// 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 // - Actual : -65252 // due to various unsigned integer truncations.
assertXPath(pXmlDoc, "//fly/infos/bounds", "top", OUString::number(DOCUMENTBORDER));
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testLineWidth)
{ // Given a document with an as-char image, width in twips not fitting into sal_uInt16:
createSwDoc("line- sal_Int32nAvgLeft =(nMarginPos+ ) / 2;
SwWrtShell* pWrtShell (nt i= ;i 17 i+
sal_Int32 nOldLeft = pWrtShell->GetCharRect().{
// When moving the cursor to the right:
pWrtShell->Right(SwCursorSkipModesal_Int32 =pWrtShell-GetCharRect).Left(;
// Then make sure we move to the right by the image width:
sal_Int32 nNewLeft = CPPUNIT_ASSERT_GREATER(, nNewCursorPos; // 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(SwCoreTextTest, 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");
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Get the line width of the first line for the 1st paragraph.
sal_Int32 nFirstLineWidth
= getXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout[1]", "width").toInt32(); // Get the line width of the first line for the 2nd paragraph.
sal_Int32 nSecondLineWidth
= getXPath
// 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_EQUAL(nSecondLineWidth, nFirstLineWidth);
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRuby)
{ // Given a document with multiple ruby portions:
createSwDoc"ruby.fodt")java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
SwDoc* pDoc = getSwDocpWrtShell->RightSwCursorSkipModeChars/
//Then surethat unwantedmarginportions are , making the text // invisible:
SwFrame* pPageFrame = pLayoutSwTextNode*pTextNode ->GetNode)GetTextNode()
SwFramesal_Int32 nIndex=pStartGetContentIndex(;
SwFrame* pFrame = pBodyFrameSwTextAttr* pAttr
CPPUNIT_ASSERT(pFrame-> ->(nIndex RES_TXTATR_CONTENTCONTROL sw::GetTextAttrMode::Parent autopTextFrame <SwTextFrame*>pFrame);
SwParaPortion* pPara = pTextFrame->GetPara(); boolbFirst =true; for (SwLinePortion* pPor = pPara->GetFirstPortion(); pPor; pPor = pPorstd:shared_ptrSwContentControl>pContentControl=rFormatContentControl.();
{ // Look for multi-portions in the only paragraph of the document. if(-GetWhichPor( !=PortionType:)
{ continue;
}
(bFirst
{
bFirst = false; continue;
}
// The second multi-portion has two lines, check the start of the second line. auto pMulti = static_cast<SwMultiPortion*>(pPor); // 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// - Actual : 0
}
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest,testEmptyNumberingPageSplit)
{
// adocumentwith pages theonly para onpage1is numberingwithout a java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93 // portion:
createSwDoc("empty-numbering-page-split.fodt");
// Then make sure that the layout update after insertion finishes:
ropertyValue aArgs {
comphelper::makePropertyValue(u"FileName"_ustr pAnnotation>getFormFieldAlternateName.get();
}; // Without the accompanying fix in place, this never finished.
dispatchCommand(mxComponent, u".uno:InsertGraphic"_ustr, aArgs)PPUNIT_TEST_FIXTURE(SwCoreTextTest testContentControlPlaceholderPDF)
}
CPPUNIT_TEST_FIXTURESwCoreTextTest, testClearingLineBreak
{ // Given a document with a fly frame and two characters wrapped around it:
createSwDoc("-breakfodt") // Insert a clearing break between "A" and "B":
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uno::Reference<text::XText Given a file with acontent control inplaceholder :
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
xCursor->gotoEnd(/*bSelect=*/false);
xCursor-goLeft/*nCount=*/1, /*bSelect=*/false);
uno::Reference<lang::XMultiServiceFactory
uno::Reference<text::XTextContent> xLineBreak// When exporting to PDF:
save("writer_pdf_Export"_)
uno::Reference<beans::XPropertySet> xLineBreakProps autoeClear static_cast<al_Int16SwLineBreakClear:ALL);
xLineBreakProps->setPropertyValue(u"std:unique_ptr<::::PDFiumDocument> pPdfDocument parsePDFExport()java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
// When laying out that document:
xmlDocUniquePtr =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 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.((STR_CONTENT_CONTROL_PLACEHOLDER)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
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--start."; // Insert a clearing break before "X":
uno::Reference<text::XTextDocument> xDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> xText = xDocument->getText();
uno::Reference<text::XTextCursor> xCursor =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
xCursor->gotoEnd(/*bSelect=*/false);
xCursor->goLeft(/*nCount=*/1, /*bSelect=*/false);
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextContentpWrtShell>InsertContentControl(SwContentControlType:CHECKBOX
xFactory->createInstance
uno::Reference<beans/ auto eClear = static_cast<sal_Int16>(SwLineBreakClear::ALL);
xLineBreakProps->setPropertyValue(u"Clear"_ustr
xText// Then make sure that a checkbox form widget is emitted:
// 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
java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 41
assertXPath(, "/wParaPortionSwLineLayout1],"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):
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<text::XTextCursor> xCursor = xText->createTextCursor();
{
uno:CPPUNIT_TEST_FIXTURESwCoreTextTest testDropdownContentControlPDF)
->createInstanceucom...drawingRectangleShape_ustr uno::UNO_QUERY)java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
xShape->setSize(awt::Size(5000, 5000));
uno::Reference<beans::XPropertySet> xShapePropsreturn;
xShapeProps-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uno::Any(text::TextContentAnchorType_AT_CHARACTER));
uno:Reference<::XTextContent>xShapeContentxShape, ::UNO_QUERY;
xText->insertTextContent(xCursorSwWrtShell =getSwDocShell)GetWrtShell);
}
{
pWrtShell>InsertContentControl(wContentControlType:DROP_DOWN_LIST);
xFactory
xShape->setSize(awt// When exporting to PDF:
::<beans:XPropertySet>xShapePropsxShape, uno::UNO_QUERY);
xShapeProps->setPropertyValue
uno::Any// Then make sure that a dropdown form widget is emitted:
xShapeProps-setPropertyValueu""ustruno:Anysal_Int3210000))java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
::Referencetext:> xShapeContent2(xShape,uno:UNO_QUERY)
xText->insertTextContent(xCursor, xShapeContent2, /*bAbsorb=*/false);
}
uno::Reference<text::XTextContent> xLineBreak(
xFactory-createInstanceucomsunstartext"ustr,uno:)java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY); autoeClear =static_cast>(SwLineBreakClear:);
xLineBreakProps-: = pPagegetAnnotation()
xText->insertString(xCursor, u"foo"_ustr, /*bAbsorb=*/false);
->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
xText->insertString(xCursor
// 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):
xmlDocUniquePtr 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_FIXTURESwCoreTextTesttestClearingLineBreakLeftRTL)
{ // Given a document with an anchored object in an RTL para and a clearing break (type=left):
createSwDoc();
uno::Reference<lang::XMultiServiceFactorystd:<vcl:pdf:PDFiumAnnotation pAnnotation=pPage-getAnnotation(0)
uno:CPPUNIT_ASSERT_EQUAL(vcl:pdfPDFAnnotationSubType:Widget pAnnotation-getSubType))java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
uno::Reference<text::XText> xText = xDocument->getText();CPPUNIT_ASSERT_EQUALvcl:pdf::ComboBox
uno pAnnotation>(pPdfDocument.get())java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
uno::Reference<beans::XPropertySet> xCursorProps(xCursor, uno::UNO_QUERY);
xCursorProps->setPropertyValue(u"WritingMode"_ustr, uno::Any(text::WritingMode2::RL_TB));
{
uno::Reference<drawing::XShape> xShape(
xFactory->createInstance(u"com.sun.star.drawing.RectangleShape"_ustr),{
xShapestdshared_ptr<vcl:::PDFiumpPDFium =vcl:pdf:PDFiumLibrary:get)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
xShapeProps->setPropertyValue(u"AnchorType"_ustr,
uno::AnySwExportFormFieldsGuard ;
uno::Reference<text::XTextContent> xShapeContent(xShape, uno::UNO_QUERY);
xText
}
uno::Reference<text(uwriter_pdf_Exportustr
xFactory-
uno::Reference<beans: // Then make sure that a date form widget is emitted: auto eClear = static_cast<sal_Int16std:unique_ptr<<vcl:pdf:PDFiumDocument =();
xLineBreakProps>(u"Clear_ustr, uno::Any(eClear));
xText->insertString(xCursor// Without the accompanying fix in place, this test would have failed with:
java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
xText->insertString(xCursor, u"bar"_ (1, ->getAnnotationCount())java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
// When laying out that document:
calcLayout();
CPPUNIT_ASSERT_EQUAL:pdf:PDFAnnotationSubType:WidgetpAnnotation->();
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");
}
TEST_FIXTURESwCoreTextTest testClearingLineBreakVertical
{
(uAFDate_KeystrokeEx\mm//yy\");_ustr aAction;
createSwDoc();
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference
uno::Reference<text::XText> xText
uno::Reference<text::XTextCursortestContentControlPDFFont)
uno::Reference
getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustrstd:shared_ptrvcl:> = vcl::pdf:DFiumLibrary:()
xStandard->setPropertyValue(u"WritingMode"_ustr, uno::Any(text (!pPDFium
{return
unojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
xShape->setSize(awt::Size(5000, 5000));
::<
xShapeProps->setPropertyValueSvxFontHeightItemaItem480,100,RES_CHRATR_FONTSIZE)
uno::aSetPut(Item)
uno::Reference<text:XTextContent>xShapeContentxShape, uno::NO_QUERY)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
xText->insertTextContent(xCursor, xShapeContent, /*bAbsorb=*/false);
}
uno::Reference<text::XTextContent> xLineBreak(
-createInstanceu".sunstar.text."ustr, uno:)
uno::Reference<beans::XPropertySet> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 auto eClear = static_cast<sal_Int16>(SwLineBreakClear::ALL);
xLineBreakProps->setPropertyValue(u"Clear"_ustr, uno::Any(eClear));
xText->insertString(xCursor, u"foo"_ustr, /*bAbsorb=*/false);
-insertTextContent, xLineBreak *bAbsorb=/);
xText->insertString(xCursor, u"bar"_ustr, /*bAbsorb=*/false);
tthat
calcLayout();
// Then make sure the "bar" does jump (logic) down the correct amount:
xmlDocUniquePtr pXmlDoc = CPPUNIT_ASSERT_EQUAL240f,pAnnotation>(pPdfDocumentget(); // 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.
assertXPathpXmlDoc //SwParaPortion/SwLineLayout[1]/SwBreakPortion", "height", u"2837");
}
CPPUNIT_TEST_FIXTURE( ;
{ // Given a document with a shape in the header and a clearing break in the body text:
createSwDoc(clearing-.";
// When laying out that document:(;
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Then make sure that the shape from the header is ignored while calculating the line height: // When exporting to PDF: // - Expected: 276 // - Actual : 15398 // i.e. the shape was in the background, but we failed to ignore it for the break portion.
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout[1]", "height", u"276");
}
CPPUNIT_TEST_FIXTURESwCoreTextTest )
{ // Given a document with an as-char image:
createSwDoc();
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xTextGraphic(
->createInstanceucomsunstarTextGraphicObjectuno::NO_QUERY) // Only set the anchor type, the actual bitmap content is not interesting.
xTextGraphic->setPropertyValue(u"AnchorType"_ustr,
:(text:TextContentAnchorType_AS_CHARACTER);
uno:Referencetext:XTextDocument xTextDocument(mxComponent,uno:UNO_QUERY);
uno::Reference<text::XText> xBodyText = xTextDocument->getText();
uno::Reference<text::XTextCursor> xCursor(xBodyText->createTextCursor()) (pAnnotation->getFormFieldFlags(PdfDocumentget) & 0x00040000;
uno::Reference<text::XTextContent> xTextContent(xTextGraphic, uno::UNO_QUERY);
xBodyText->insertTextContent(xCursor, xTextContent, false);
SwWrtShell* pWrtShellCPPUNIT_TEST_FIXTURE(wCoreTextTest testRichContentControlPDF)
SwRootFrame* pRootFrame = pWrtShell
SwFrame* pPageFrame = pRootFrame->GetLower();
SwFrame* pBodyFrame = pPageFrame->GetLower();
SwFrame* pTextFrame = pBodyFrame->GetLower(); const SwSortedObjs& rSortedObjs = *pTextFrame->GetDrawObjs(); const SwAnchoredObject* pAnchoredObject = if(!) // The content points to the start node, the next node is the graphic node.
SwNodeIndex aGraphicNode = *pAnchoredObject gjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
++aGraphicNode;
tools::Rectangle aFlyFramepWrtShell>(/*bStt=*/true);
->RightSwCursorSkipMode:, /*bSelect=*/false, 1, /*bBasicCall=*/false);
// 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:
SwShellCursor* pShellCursor = pWrtShell->SvxWeightItem (WEIGHT_BOLD, );
aSetPut(); // - 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
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRedlineDelete)
{ // Given a document with A4 paper size, some text, redlining on, but hidden:
createSwDoc(;
SwDoc* pDoc = getSwDoc();
SwDocShell* pDocShell = getSwDocShell();
SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
{
size .
size_t / ie."xxx<b>yyy<>" was exported as 2 widgets, not1
CPPUNIT_ASSERT_EQUAL(1,pPagegetAnnotationCount())
SwFrameFormat& rMaster = aPageDesc.GetMaster();
SwFormatFrameSize
aSize.SetSize(Size(11906, 16838));
rMaster.SetFormatAttr(aSize);
pWrtShell->ChgPageDesc(nCurIdx, aPageDesc);
}
OUString aBefore(u"aaaaaaaaa aaaaaaaaaa aa aa aa "_ustr);
OUString aDelete(u"delete eeeeeeeeeee ee eeeeeeeeeee ee eeeeee"_ustr);
pWrtShell->Insert(aBefore + " " + aDelete
+ " zz zzz zzzzzzzzz zzz zzzz zzzz zzzzzzzzz zzzzzz zzz zzzzzzzzzzz zzz"); // Enable redlining.
pDocShell->SetChangeRecording(/*bActivate=*/true); // Hide redlining.
pWrtShell->StartAllAction();
pWrtShell->GetLayout()->SetHideRedlines(true);
pWrtShell->EndAllAction();
// When deleting content in the middle of the paragraph:
pWrtShell>(*bStt/true;
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, /*nCount=*/aBefore.getLength(), /*bBasicCall=*/false);
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, /*nCount=*/aDelete.getLength(),saveu"writer_pdf_Export_ustr); /*bBasicCall=*/false); // Without the accompanying fix in place, this test would have crashed:
pWrtShell>Delete(;
// Then make sure that the redline is created:
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1),
pDoc->getIDocumentRedlineAccess() // Without the accompanying fix in place, this test would have failed with:
}
/ Make a paint to force the call of AddExtraBlankWidth, that calculate width for holePortions.
getSwDocShell()->GetPreviewBitmap();
// Move the cursor to the last character of the document.
->EndOfSection);
//Press space and check if the cursor move right with the additional space.
java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 62
pWrtShell->Insert(u" "_ustr);
sal_Int32 nNewCursorPos =pWrtShell->GetCharRect).eft)
CPPUNIT_ASSERT_GREATER(nOldCursorPos, nNewCursorPos)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf43100_CursorMoveToSpacesOverMargin)
{ // Test the cursor movement over the right margin in several different paragraphs. pXmlDoc parseLayoutDump()java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 // These differences are based on its paragraphs // - alignment (left, center, right, justified), // - line count (1 line, 2 lines, blank line containing only spaces)
createSwDoc("tdf43100_tdf120715_cursorOnSpacesOverMargin.docx");
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
// i.e. the numbering portion font size was 12pt, not 24pt (but only when the doc had a
getSwDocShell()->GetPreviewBitmap();
// 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::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
sal_Int32 nNewCursorPos = pWrtShell->GetCharRect().Left();
CPPUNIT_ASSERT_GREATER(nLastCursorPos, nNewCursorPos);
nLastCursorPos = nNewCursorPos;
}
// 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// - Actual : 00ff0000 (COL_LIGHTRED) true,truetrue, false, truetrue, falsefalse }; // 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 = (nMarginPos + nLastCursorPos) / 2; for (int i = 2; i < 17; i++)
{
pWrtShell->Down(/*bSelect=*/false, 1, /*bBasicCall=*/false);
} if (aLineReachOverMargin[i])
CPPUNIT_ASSERT_GREATER(nAvgLeft, nNewCursorPos); else
CPPUNIT_ASSERT_LESS(nAvgLeft, nNewCursorPos);
}
}
CPPUNIT_TEST_FIXTUREjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium) return;
const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl();
std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl(); // 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:aDumperjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
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 content control 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, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Also verify that the widget description is correct, it was empty:
CPPUNIT_ASSERT_EQUAL(u"mydesc"_ustr,
pAnnotation->getFormFieldAlternateName * pShell getSwDocShell();
}
SwExportFormFieldsGuard g; // Given a file with a content control, in placeholder mode:
createSwDoc();
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:
std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0);
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(nSectionAfterNBSPX_legacy_leftAlignedjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 // - 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)
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a file with a checkbox content control:
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::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 checkbox content control was just exported as normal text.
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0);
l::pdf:PDFAnnotationSubType,pAnnotation>(); // Also check the form widget type:
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::CheckBox,
pAnnotation->getFormFieldType(pPdfDocument.get()));
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDropdownContentControlPDF)
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium) return
SwExportFormFieldsGuard g; // Given a file with a dropdown content control:
createSwDoc();
SwWrtShell pWrtShell getSwDocShell()>GetWrtShell();
pWrtShell->InsertContentControl(SwContentControlType::DROP_DOWN_LIST);
//When exporting PDF
save(u"writer_pdf_Export"_ustr);
//Then sure widget 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 dropdown content control 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 check the form widget type (our dropdown is called combo in PDF terms):
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::ComboBox,
pAnnotation->getFormFieldType(pPdfDocument.get()));
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDropdownContentControlPDF2)
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!PDFium return;
SwExportFormFieldsGuard/java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
createSwDoc("tdf153040.docx";
save(u"writer_pdf_Export"_ustr);
// Make sure that a dropdown form widget is emitted:
std:<vcl::pdf:DFiumDocument pPdfDocument = parsePDFExport;
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0);
CPPUNIT_ASSERT_EQUAL(4, pPage->getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0);
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,
pAnnotation SwDoc*pDoc = getSwDoc(); // Without tdf#153040's fix, this would have been the empty OUString()* pLayout =pDoc>getIDocumentLayoutAccess(.()java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
CPPUNIT_ASSERT_EQUAL(u"Apfel"_ustr, pAnnotation->getFormFieldValue(pPdfDocument.get()));
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDateContentControlPDF)
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf:// Without the accompanying fix in place, this test would have failed with: if (!pPDFium return;
SwExportFormFieldsGuard g; // Given a file with a date content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
pWrtShell->InsertContentControl(SwContentControlType::DATE);
// 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 = 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 date content control was just exported as normal text. ie.the datecontentcontrol exportedas normal text.
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage- createSwDoc".fodt")
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::pdf::PDFAnnotAActionType::KeyStroke);
CPPUNIT_ASSERT_EQUAL(u"AFDate_KeystrokeEx(\"mm/dd/yy\");"_ustr, aAction);
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDFFont)
{
std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium) return;
SwExportFormFieldsGuard g; // Given a document with a custom 24pt font size and a content control:
createSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SfxItemSetFixed<RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE> aSet(pWrtShell "//[1//SwLineLayoutchild:[@=PortionType:'"3
SvxFontHeightItem aItem(480, 100, RES_CHRATR_FONTSIZE);
aSet.Put(aItem);
pWrtShell->SetAttrSet(aSet);
pWrtShell->InsertContentControl(SwContentControlType::RICH_TEXT);
// When exporting that document to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that the widget in the PDF result has that custom font size:
std::unique_ptr<vcl// But also make sure there is a kern portion between each Western and Asian
std:nique_ptrvclpdfPDFiumPage> pPage = pPdfDocument>openPage(0;
pPage->onAfterLoadPage(pPdfDocument.get());
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->getFontSize(pPdfDocument.get()));
}
SwExportFormFieldsGuard // Given a file with a combo box content control:
createSwDoc("
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell SwWrtShell* pWrtShell//body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "type",
pWrtShell->InsertContentControl(SwContentControlType::COMBO_BOX);
// 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();
std: // Without the accompanying fix in place, this test would have failed with: // - Expected: 1
("df139863fodt)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 // i.e. the combo box content control was exported as plain text.
CPPUNIT_ASSERT_EQUAL(
std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0);
CPPUNIT_ASSERT_EQUAL(vcl:pdf::PDFAnnotationSubType:,pAnnotationgetSubType()
CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::ComboBox,
pAnnotation->getFormFieldType(pPdfDocument.get())); // 19th bit: combo box, not dropdown.
CPPUNIT_ASSERT(pAnnotation->getFormFieldFlags(pPdfDocument.get()) & 0x00040000);
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRichContentControlPDF)
{
::shared_ptrvcl:::PDFium = vcl:pdfPDFiumLibrary: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->InsertContentControl(SwContentControlType::RICH_TEXT);
pWrtShell->SttEndDoc(/*bStt=*/true);
pWrtShell- ("-upper-margin-fly-intersect.docx"
sal_Int32 nPlaceHolderLen = SwResId(STR_CONTENT_CONTROL_PLACEHOLDER).getLength();
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, nPlaceHolderLen,) /*bBasicCall=*/false);
pWrtShell->Insert(u"xxxyyy"_ustr);
pWrtShell>Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 3, /*bBasicCall=*/false);
SfxItemSetFixed<RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT> aSet(pWrtShell->GetAttrPool()); int
aSet.Put = getXPathContent,
pWrtShell-SetAttrSet()
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr);
// Then make sure that a single fillable form widget is emitted:
::<vcl::> =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 : 2 // i.e. "xxx<b>yyy</b>" was exported as 2 widgets, not 1.
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount());
}
CPPUNIT_TEST_FIXTUREjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
{
std:shared_ptrvcl:pdf::PDFium pPDFium = vcl:pdf:PDFiumLibrary::get(; if (!pPDFium) returnjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
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:
std::unique_ptr<vcl::pdf:PDFiumDocument ()
std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPagecreateSwDoc(tdf129810odt); // 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());
java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
CPPUNIT_ASSERT_EQUAL(vcl::PDFAnnotationSubType:,->()
// 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", /Test dotted isgrouped the after,evenif
java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 1
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testNumberPortionNoformat)
{ // Given a document with a numbering and a single paragraph, the entire run is red:
createSwDoc"numberportion-.")
// 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");
}
// Measure the X position of sections after NBSPs in a legacy file (no option value set)
{
createSwDoc("tdf41652_legacy.fodt");
SwDocShell* pShell = getSwDocShell();
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump aDumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
// Measure the X of sections after NBSPs in a file with the option enabled
{
createSwDoc("tdf41652_variableNBSPdisabled.fodt");
SwDocShell* pShell = getSwDocShell();
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump aDumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
// Measure the X of the sections after NBSPs in a file with the option enabled
{
createSwDoc("tdf41652_variableNBSPenabled.fodt");
SwDocShell* pShell = getSwDocShell();
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
MetafileXmlDump aDumper;
xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
// Assert left aligned NBSP for the legacy file is larger than zero
CPPUNIT_ASSERT_GREATER(sal_Int32(0), nSectionAfterNBSPX_legacy_leftAligned); // Assert both NBSPs have same width for the legacy file
CPPUNIT_ASSERT_EQUAL(nSectionAfterNBSPX_legacy_leftAligned,
nSectionAfterNBSPX_legacy_justified); // Assert left aligned NBSP is same width for legacy file as for the disabled file
CPPUNIT_ASSERT_EQUAL(nSectionAfterNBSPX_legacy_leftAligned,
nSectionAfterNBSPX_optionDisabled_leftAligned); // Assert justified NBSP is same width for legacy file as for the disabled file
CPPUNIT_ASSERT_EQUAL(nSectionAfterNBSPX_legacy_justified,
nSectionAfterNBSPX_optionDisabled_justified); // Assert left aligned NBSP is same width for the disabled file as for the enabled file
CPPUNIT_ASSERT_EQUAL(nSectionAfterNBSPX_optionDisabled_leftAligned,
nSectionAfterNBSPX_optionEnabled_leftAligned); // Assert justified NBSP is wider for the enabled file
CPPUNIT_ASSERT_GREATER(nSectionAfterNBSPX_optionDisabled_justified,
nSectionAfterNBSPX_optionEnabled_justified);
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFloattableOverlap)
{ // Given a document with 2 floating tables, not overlapping in Word's "Word 2010" compat mode, // because the first empty paragraph is below the first floating table:
createSwDoc("floattable-overlap.docx");
// When laying out that document:
calcLayout();
// Then make sure they don't overlap in Writer, either:
SwDoc* pDoc = getSwDoc();
SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower());
CPPUNIT_ASSERT(pPage1);
CPPUNIT_ASSERT(pPage1->GetSortedObjs()); const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
(size_t .);
SwAnchoredObject* pPage1Obj1 = rPage1Objs[0]java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 const SwRect& rRect1(".")
SwAnchoredObject* pPage1Obj2 = rPage1Objs[1]; constSwRect pPage1Obj2GetObjRectWithSpaces)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 // Without the accompanying fix in place, this test would have failed, the empty paragraph, // which is after the floating table in the document model went above the floating table in the // layout, which resulted in an overlap.
(, "SwParaPortion/[], portion
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFloattableAnchorNextPage)
{ // Given a document with 3 floating tables, the last one has a negative vertical offset, so the // floating table is on page 1, but its anchor frame is effectively on page 2:
createSwDoc("floattable-anchor-next-page.docx");
// When laying out that document:
calcLayout();
// Then make sure all 3 floating tables are on page 1:
SwDoc* pDoc = getSwDoc();
SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower());
CPPUNIT_ASSERT(pPage1);
CPPUNIT_ASSERT(pPage1->GetSortedObjs()); const SwSortedObjs& // Page 1 // Without the accompanying fix in place, this test would have failed with:{ // - Expected: 3 // - Actual : 2 // i.e. the last floating table was on the wrong page (page 2).
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), rPage1Objs.size());
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf89288)
{ // Given a document with 2 paragraphs of mixed Complex and Western text,=->(1;
/java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
createSwDoc("tdf89288.fodt");
// When laying out that document:
// Then make sure there is no kern portions between the Western and Complex // portions:
assertXPath (49 expectedOffset 0.)
assertXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Text']", 3);
assertXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Kern']", 0);
// But also make sure there is a kern portion between each Western and Asian // portion:
assertXPath(pXmlDoc, "//body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion", 5);
assertXPath(pXmlDoc, "//body/txt[3]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Text']", 3);
assertXPath(pXmlDoc,
assertXPath(pXmlDoccreateSwDoc----.");
assertXPath(pXmlDoc, "
assertXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Kern']", 2);
assertXPathpXmlDoc/
(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
assertXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion[4]", "type",
u"PortionType::Kern");
}
CPPUNIT_TEST_FIXTURE (pXmlDoc
{ // Given a document with 2 paragraphs of mixed Complex scripts:
createSwDoc("tdf139863.fodt");
// When laying out that document:
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Then make sure the text is not split into multiple portions.
pXmlDoc"//txt[3/SwParaPortion/SwLineLayout/SwLinePortion, 3);
assertXPath(pXmlDoc, // we get an assert in OString::toUtf8()."//body/txt[3]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Kern']", 0);
assertXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout/child::*", 1);
assertXPath(pXmlDoc assertXPathpXmlDoc/
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testParaUpperMarginFlyIntersect)
{ // Given a document with 2 paragraphs, the paragraphs have both upper and lower spacing of 567 // twips:
createSwDocpara--.";
// When laying out that document:
calcLayout();
// Then make sure that we shift down the text in the second paragraph only based on the 2nd para // upper margin, not based on the 1st para lower margin:
xmlDocUniquePtr pXmlDoc = parseLayoutDump(); int nFlyCount
= getXPathContent(pXmlDoc, "count(//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Fly'])")
.toInt32(); int nHeight = 0; for (int i = 1; i <= nFlyCount; ++i)
{
OString xPath = "(//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Fly'])["
+ OString::number(i) + "]";
nHeight += getXPath(pXmlDoc, xPath, "height").toInt32();
} // Without the accompanying fix in place, this test would have failed with: // - Expected: 521 (~500) // - Actual : 857 (~1000) // I.e. both upper and lower margin was taken into account.
CPPUNIT_ASSERT_EQUAL(521, nHeight);
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf129810)
{ // Load the document. // The document embeds a subset of "Source Han Serif SC" so that it works // even when the font is not installed. // // Font subset created with: // // hb-subset SourceHanSerif.ttc -y 12 -u '20,3002,4FE1,540C,5E76,606F,610F,6237,6536,65B9,65E0,6B3E,6C42,7684,786E,8981,8BA4,8BEF,8D26,8D35,FF0C' -o SourceHanSerif.ttf
createSwDoc("tdf129810.odt");
// Render the document to a metafile.
SwDocShell* pShell = getSwDocShell();
std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
CPPUNIT_ASSERT(xMetaFile);
// Find the first text array action for (size_t nAction = 0; nAction < xMetaFile->GetActionSize(); nAction++)
{ auto pAction = xMetaFile->GetAction(nAction); if (pAction->GetType() == MetaActionType::TEXTARRAY)
{ auto pTextArrayAction = static_cast<MetaTextArrayAction*>(pAction); auto pDXArray = pTextArrayAction->GetDXArray();
// There should be 14 chars on the first line
CPPUNIT_ASSERT_EQUAL(size_t(14), pDXArray.size());
// Assert we are using the expected width for uncompressed chars
CPPUNIT_ASSERT_EQUAL(sal_Int32(720), sal_Int32(pDXArray[0])); // Assert we are using the expected width for compressed chars
CPPUNIT_ASSERT_EQUAL(sal_Int32(499), sal_Int32(pDXArray[6] - pDXArray[5])); break;
}
}
}
// Test that a dotted circle is grouped with the mark after it, even if the // mark is outside Unicode’s Basic Multilingual Plan (i.e. a surrogate pair // in UTF-8) // // Without the fix it fails with: // - Expected: 11 // - Actual : 11◌
assertXPath(pXmlDoc, "//txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "portion", u"11");
assertXPath(pXmlDoc, "//txt[1]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "portion",
u"\u25CC\U00010A01");
// Without the fix this would crash because we got a lone surrogate that // can’t be converted to UTF-8, but if it were not for that it might fail // with something like: // - Expected: 11 // - Actual : 11
assertXPath(pXmlDoc, "//txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[1]", "portion", u"11");
assertXPath(pXmlDoc, "//txt[2]/SwParaPortion/SwLineLayout/SwLinePortion[2]", "portion",
u"\U0001D400\u064E");
}
// Test that a NNBSP is grouped with the Mongolian characters after it // // Without the fix it fails with: // - Expected: 11 // - Actual : 11\u202F // (U+020F is a space, so might not be visible)
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/SwLinePortion[1]", "portion", u"11");
assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/SwLinePortion[2]", "portion",
u"\u202F\u1824");
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf161990)
{ auto pPDFium = vcl::pdf::PDFiumLibrary::get(); if (!pPDFium) return;
// Given a file with two frames, each having a subscript run, on pages 1 and 6:
createSwDoc("tdf161990-subscripts.fodt");
// When exporting to PDF:
save(u"writer_pdf_Export"_ustr); auto pPdfDocument = parsePDFExport();
// Check that both subscripts are positioned correctly relative to the non-subscript runs double expectedOffset = 0;
// Page 1
{ auto pPage = pPdfDocument->openPage(0); auto pTextPage = pPage->getTextPage();
CPPUNIT_ASSERT_EQUAL(2, pPage->getObjectCount());
auto pObject = pPage->getObject(0);
CPPUNIT_ASSERT_EQUAL(u"P"_ustr, pObject->getText(pTextPage)); auto textPPos = pObject->getBounds();
pObject = pPage->getObject(1);
CPPUNIT_ASSERT_EQUAL(u"1"_ustr, pObject->getText(pTextPage)); auto text1Pos = pObject->getBounds();
expectedOffset = textPPos.getMaxY() - text1Pos.getMaxY(); // Without the fix, this would fail with // - Expected: 7.49 // - Actual : 7.54150390625 // But if it fails in some configurations because of different page units, then this // check is not as important as that this value is the same as on the 6th page below.
CPPUNIT_ASSERT_DOUBLES_EQUAL(7.49, expectedOffset, 0.01);
}
// Page 6
{ auto pPage = pPdfDocument->openPage(5); auto pTextPage = pPage->getTextPage();
CPPUNIT_ASSERT_EQUAL(2, pPage->getObjectCount());
auto pObject = pPage->getObject(0);
CPPUNIT_ASSERT_EQUAL(u"P"_ustr, pObject->getText(pTextPage)); auto textPPos = pObject->getBounds();
pObject = pPage->getObject(1);
CPPUNIT_ASSERT_EQUAL(u"1"_ustr, pObject->getText(pTextPage)); auto text1Pos = pObject->getBounds(); // Without the fix, this would fail with // - Expected: 7.4925537109375 // - Actual : 20.9005126953125
CPPUNIT_ASSERT_DOUBLES_EQUAL(expectedOffset, textPPos.getMaxY() - text1Pos.getMaxY(), 0.01);
}
}
CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf136663_Korean_No_Extra_Spacing)
{ // For Chinese and Japanese typesetting, extra spacing should be inserted between // CJ characters and non-Asian scripts. However, this is not present in Korean // typesetting. Check to ensure extra space is not added around Hangul characters.
createSwDoc("tdf136663-korean-no-extra-spacing.fodt");
auto pXmlDoc = parseLayoutDump();
// Line 1: English around Chinese (kern portions)
assertXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout/SwLinePortion", 5);
assertXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Text']", 3);
assertXPath(pXmlDoc, "//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Kern']", 2);
// Line 2: Chinese around English (kern portions)
assertXPath(pXmlDoc, "//body/txt[2]/SwParaPortion/SwLineLayout/SwLinePortion", 5);
assertXPath(pXmlDoc, "//body/txt[2]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Text']", 3);
assertXPath(pXmlDoc, "//body/txt[2]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Kern']", 2);
// Line 3: English around Korean (no kern portions)
assertXPath(pXmlDoc, "//body/txt[3]/SwParaPortion/SwLineLayout/SwLinePortion", 3);
assertXPath(pXmlDoc, "//body/txt[3]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Text']", 3);
assertXPath(pXmlDoc, "//body/txt[3]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Kern']", 0);
// Line 4: Korean around English (no kern portions)
assertXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/SwLinePortion", 3);
assertXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Text']", 3);
assertXPath(pXmlDoc, "//body/txt[4]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Kern']", 0);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.41Bemerkung:
¤
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.