summaryrefslogtreecommitdiffstats
path: root/test/source/text
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/source/text/baseindex.cxx151
-rw-r--r--test/source/text/textcontent.cxx68
-rw-r--r--test/source/text/textdocumentindex.cxx36
-rw-r--r--test/source/text/textdocumentsettings.cxx42
-rw-r--r--test/source/text/textprintersettings.cxx39
-rw-r--r--test/source/text/textsettings.cxx153
-rw-r--r--test/source/text/xdocumentindex.cxx66
-rw-r--r--test/source/text/xsimpletext.cxx76
-rw-r--r--test/source/text/xtext.cxx29
-rw-r--r--test/source/text/xtextcontent.cxx57
-rw-r--r--test/source/text/xtextfield.cxx43
-rw-r--r--test/source/text/xtextrange.cxx61
12 files changed, 821 insertions, 0 deletions
diff --git a/test/source/text/baseindex.cxx b/test/source/text/baseindex.cxx
new file mode 100644
index 000000000..683a24221
--- /dev/null
+++ b/test/source/text/baseindex.cxx
@@ -0,0 +1,151 @@
+/* -*- 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/.
+ */
+
+#include <cppunit/TestAssert.h>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/text/XTextColumns.hpp>
+#include <com/sun/star/text/XTextSection.hpp>
+
+#include <vcl/BitmapTools.hxx>
+#include <vcl/pngwrite.hxx>
+#include <unotools/tempfile.hxx>
+#include <tools/stream.hxx>
+
+#include <test/unoapi_property_testers.hxx>
+#include <test/text/baseindex.hxx>
+
+namespace
+{
+BitmapEx createExampleBitmap()
+{
+ vcl::bitmap::RawBitmap aRawBitmap(Size(4, 4), 24);
+ aRawBitmap.SetPixel(0, 0, COL_LIGHTBLUE);
+ aRawBitmap.SetPixel(0, 1, COL_LIGHTGREEN);
+ aRawBitmap.SetPixel(1, 0, COL_LIGHTRED);
+ aRawBitmap.SetPixel(1, 1, COL_LIGHTMAGENTA);
+ return vcl::bitmap::CreateFromData(std::move(aRawBitmap));
+}
+
+void writerFileWithBitmap(OUString const& rURL)
+{
+ BitmapEx aBitmapEx = createExampleBitmap();
+ SvFileStream aFileStream(rURL, StreamMode::READ | StreamMode::WRITE);
+ vcl::PNGWriter aWriter(aBitmapEx);
+ aWriter.Write(aFileStream);
+ aFileStream.Seek(STREAM_SEEK_TO_BEGIN);
+ aFileStream.Close();
+}
+}
+
+namespace apitest
+{
+BaseIndex::~BaseIndex() {}
+
+void BaseIndex::testBaseIndexProperties()
+{
+ css::uno::Reference<css::beans::XPropertySet> xBaseIndex(init(), css::uno::UNO_QUERY_THROW);
+ testStringProperty(xBaseIndex, "Title", "Value");
+ testBooleanProperty(xBaseIndex, "IsProtected");
+
+ testStringProperty(xBaseIndex, "ParaStyleHeading", "Value");
+ testStringProperty(xBaseIndex, "ParaStyleLevel1", "Value");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel2");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel3");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel4");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel5");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel6");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel7");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel8");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel9");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleLevel10");
+ testStringOptionalProperty(xBaseIndex, "ParaStyleSeparator");
+
+ // [property] XTextColumns TextColumns;
+ {
+ OUString name = "TextColumns";
+
+ css::uno::Reference<css::text::XTextColumns> xGetTextColumns;
+ CPPUNIT_ASSERT(xBaseIndex->getPropertyValue(name) >>= xGetTextColumns);
+
+ xGetTextColumns->setColumnCount(xGetTextColumns->getColumnCount() + 1);
+ xBaseIndex->setPropertyValue(name, css::uno::Any(xGetTextColumns));
+
+ css::uno::Reference<css::text::XTextColumns> xSetTextColumns;
+ CPPUNIT_ASSERT(xBaseIndex->getPropertyValue(name) >>= xSetTextColumns);
+
+ //CPPUNIT_ASSERT_EQUAL(xGetTextColumns->getColumnCount(), xSetTextColumns->getColumnCount());
+ }
+
+ // [property] com::sun::star::graphic::XGraphic BackGraphic;
+ // [property] string BackGraphicURL;
+ {
+ OUString name = "BackGraphicURL";
+ bool bOK = false;
+ try
+ {
+ xBaseIndex->getPropertyValue(name);
+ }
+ catch (css::uno::RuntimeException const& /*ex*/)
+ {
+ bOK = true;
+ }
+ // BackGraphicURL is "set-only" attribute
+ CPPUNIT_ASSERT_MESSAGE("Expected RuntimeException wasn't thrown", bOK);
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ writerFileWithBitmap(aTempFile.GetURL());
+
+ css::uno::Reference<css::graphic::XGraphic> xGraphic;
+ CPPUNIT_ASSERT(xBaseIndex->getPropertyValue("BackGraphic") >>= xGraphic);
+ CPPUNIT_ASSERT(!xGraphic.is());
+
+ xBaseIndex->setPropertyValue(name, css::uno::Any(aTempFile.GetURL()));
+
+ CPPUNIT_ASSERT(xBaseIndex->getPropertyValue("BackGraphic") >>= xGraphic);
+ CPPUNIT_ASSERT(xGraphic.is());
+ }
+
+ testStringProperty(xBaseIndex, "BackGraphicFilter", "Value");
+
+ // [property] com::sun::star::style::GraphicLocation BackGraphicLocation;
+
+ testColorProperty(xBaseIndex, "BackColor");
+ testBooleanProperty(xBaseIndex, "BackTransparent");
+
+ // [optional, property] com::sun::star::container::XIndexReplace LevelFormat;
+
+ testBooleanOptionalProperty(xBaseIndex, "CreateFromChapter");
+
+ // [property] com::sun::star::text::XTextSection ContentSection;
+ {
+ OUString name = "ContentSection";
+
+ css::uno::Reference<css::text::XTextSection> xGetTextSection;
+ CPPUNIT_ASSERT_MESSAGE(name.toUtf8().getStr(),
+ xBaseIndex->getPropertyValue(name) >>= xGetTextSection);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(name.toUtf8().getStr(), OUString(""),
+ xGetTextSection->getAnchor()->getString());
+ }
+
+ // [property] com::sun::star::text::XTextSection HeaderSection;
+ {
+ OUString name = "HeaderSection";
+
+ css::uno::Reference<css::text::XTextSection> xGetTextSection;
+ if (xBaseIndex->getPropertyValue(name).hasValue())
+ CPPUNIT_ASSERT_MESSAGE(name.toUtf8().getStr(),
+ xBaseIndex->getPropertyValue(name) >>= xGetTextSection);
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/textcontent.cxx b/test/source/text/textcontent.cxx
new file mode 100644
index 000000000..61990d869
--- /dev/null
+++ b/test/source/text/textcontent.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/text/textcontent.hxx>
+
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+
+namespace apitest
+{
+void TextContent::testTextContentProperties()
+{
+ uno::Reference<beans::XPropertySet> xPS(init(), uno::UNO_QUERY_THROW);
+
+ text::TextContentAnchorType aExpectedTCAT;
+ CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorType") >>= aExpectedTCAT);
+ CPPUNIT_ASSERT_EQUAL(m_aExpectedTCAT, aExpectedTCAT);
+
+ try
+ {
+ xPS->setPropertyValue("AnchorType", uno::Any(m_aNewTCAT));
+ text::TextContentAnchorType aNewTCAT;
+ CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorType") >>= aNewTCAT);
+ CPPUNIT_ASSERT_EQUAL(m_aNewTCAT, aNewTCAT);
+ }
+ catch (const beans::UnknownPropertyException& /* ex */)
+ {
+ // ignore if property is optional
+ }
+
+ uno::Sequence<text::TextContentAnchorType> aAnchorTypes;
+ CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorTypes") >>= aAnchorTypes);
+ CPPUNIT_ASSERT(aAnchorTypes.hasElements());
+
+ text::WrapTextMode aExpectedWTM;
+ CPPUNIT_ASSERT(xPS->getPropertyValue("TextWrap") >>= aExpectedWTM);
+ CPPUNIT_ASSERT_EQUAL(m_aExpectedWTM, aExpectedWTM);
+
+ try
+ {
+ xPS->setPropertyValue("TextWrap", uno::Any(m_aNewWTM));
+ text::WrapTextMode aNewWTM;
+ CPPUNIT_ASSERT(xPS->getPropertyValue("TextWrap") >>= aNewWTM);
+ CPPUNIT_ASSERT_EQUAL(m_aNewWTM, aNewWTM);
+ }
+ catch (const beans::UnknownPropertyException& /* ex */)
+ {
+ // ignore if property is optional
+ }
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/text/textdocumentindex.cxx b/test/source/text/textdocumentindex.cxx
new file mode 100644
index 000000000..67f161cf3
--- /dev/null
+++ b/test/source/text/textdocumentindex.cxx
@@ -0,0 +1,36 @@
+/* -*- 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/.
+ */
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <test/unoapi_property_testers.hxx>
+#include <test/text/textdocumentindex.hxx>
+
+namespace apitest
+{
+TextDocumentIndex::~TextDocumentIndex() {}
+
+void TextDocumentIndex::testDocumentIndexProperties()
+{
+ css::uno::Reference<css::beans::XPropertySet> xDocumentIndex(init(), css::uno::UNO_QUERY_THROW);
+
+ testBooleanProperty(xDocumentIndex, "UseAlphabeticalSeparators");
+ testBooleanProperty(xDocumentIndex, "UseKeyAsEntry");
+ testBooleanProperty(xDocumentIndex, "UseCombinedEntries");
+ testBooleanProperty(xDocumentIndex, "IsCaseSensitive");
+ testBooleanProperty(xDocumentIndex, "UsePP");
+ testBooleanProperty(xDocumentIndex, "UseDash");
+ testBooleanProperty(xDocumentIndex, "UseUpperCase");
+ testStringOptionalProperty(xDocumentIndex, "MainEntryCharacterStyleName");
+ // [readonly, property] sequence <com::sun::star::text::XDocumentIndexMark> DocumentIndexMarks;
+ // [property] com::sun::star::lang::Locale Locale;
+ testStringProperty(xDocumentIndex, "SortAlgorithm", "Value");
+}
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/textdocumentsettings.cxx b/test/source/text/textdocumentsettings.cxx
new file mode 100644
index 000000000..9ef0518b0
--- /dev/null
+++ b/test/source/text/textdocumentsettings.cxx
@@ -0,0 +1,42 @@
+/* -*- 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/.
+ */
+
+#include <test/text/textdocumentsettings.hxx>
+#include <test/unoapi_property_testers.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace css::uno;
+
+namespace apitest
+{
+TextDocumentSettings::~TextDocumentSettings() {}
+
+void TextDocumentSettings::testDocumentSettingsProperties()
+{
+ css::uno::Reference<css::beans::XPropertySet> xDocumentSettings(init(),
+ css::uno::UNO_QUERY_THROW);
+
+ testBooleanOptionalProperty(xDocumentSettings, "ChartAutoUpdate");
+ testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacing");
+ testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacingAtStart");
+ testBooleanOptionalProperty(xDocumentSettings, "AlignTabStopPosition");
+ testBooleanOptionalProperty(xDocumentSettings, "SaveGlobalDocumentLinks");
+ testBooleanOptionalProperty(xDocumentSettings, "IsLabelDocument");
+ testBooleanOptionalProperty(xDocumentSettings, "UseFormerLineSpacing");
+ testBooleanOptionalProperty(xDocumentSettings, "AddParaSpacingToTableCells");
+ testBooleanOptionalProperty(xDocumentSettings, "UseFormerObjectPositioning");
+ testBooleanOptionalProperty(xDocumentSettings, "ConsiderTextWrapOnObjPos");
+ testBooleanOptionalProperty(xDocumentSettings, "MathBaselineAlignment");
+}
+
+} // end namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/textprintersettings.cxx b/test/source/text/textprintersettings.cxx
new file mode 100644
index 000000000..b28c65241
--- /dev/null
+++ b/test/source/text/textprintersettings.cxx
@@ -0,0 +1,39 @@
+/* -*- 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/.
+ */
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <test/unoapi_property_testers.hxx>
+#include <test/text/textprintersettings.hxx>
+
+namespace apitest
+{
+TextPrinterSettings::~TextPrinterSettings() {}
+void TextPrinterSettings::testPrinterSettingsProperties()
+{
+ css::uno::Reference<css::beans::XPropertySet> xPrinterSettings(init(),
+ css::uno::UNO_QUERY_THROW);
+
+ testBooleanProperty(xPrinterSettings, "PrintGraphics");
+ testBooleanProperty(xPrinterSettings, "PrintTables");
+ testBooleanProperty(xPrinterSettings, "PrintDrawings");
+ testBooleanProperty(xPrinterSettings, "PrintLeftPages");
+ testBooleanProperty(xPrinterSettings, "PrintRightPages");
+ testBooleanProperty(xPrinterSettings, "PrintControls");
+ testBooleanProperty(xPrinterSettings, "PrintReversed");
+ testBooleanProperty(xPrinterSettings, "PrintControls");
+ testStringProperty(xPrinterSettings, "PrintFaxName", "FaxName");
+ testBooleanProperty(xPrinterSettings, "PrintProspect");
+ testBooleanProperty(xPrinterSettings, "PrintPageBackground");
+ testBooleanProperty(xPrinterSettings, "PrintBlackFonts");
+ testBooleanOptionalProperty(xPrinterSettings, "PrintEmptyPages");
+}
+} // end namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/textsettings.cxx b/test/source/text/textsettings.cxx
new file mode 100644
index 000000000..112fc939d
--- /dev/null
+++ b/test/source/text/textsettings.cxx
@@ -0,0 +1,153 @@
+/* -*- 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/.
+ */
+
+#include <cppunit/TestAssert.h>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+
+#include <test/unoapi_property_testers.hxx>
+#include <test/text/textsettings.hxx>
+
+namespace
+{
+bool extstsProperty(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
+ OUString const& rPropertyName)
+{
+ css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
+ rxPropertySet->getPropertySetInfo());
+ return xPropertySetInfo->hasPropertyByName(rPropertyName);
+}
+
+bool isPropertyReadOnly(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
+ std::u16string_view rPropertyName)
+{
+ css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
+ rxPropertySet->getPropertySetInfo());
+ const css::uno::Sequence<css::beans::Property> xProperties = xPropertySetInfo->getProperties();
+
+ for (auto const& rProperty : xProperties)
+ {
+ if (rProperty.Name == rPropertyName)
+ return (rProperty.Attributes & com::sun::star::beans::PropertyAttribute::READONLY) != 0;
+ }
+
+ return false;
+}
+// [property] string PrinterName;
+void testPrinterName(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
+{
+ static const OUStringLiteral rPropertyName(u"PrinterName");
+
+ if (!extstsProperty(rxSettings, rPropertyName))
+ return; // Property is sometimes not set - bug? it is not defined as optional
+
+ OUString aPrinterName_Get;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+ rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Get);
+
+ OUString aPrinterName_Set;
+ css::uno::Any aNewValue;
+ aNewValue <<= aPrinterName_Get;
+ rxSettings->setPropertyValue(rPropertyName, aNewValue);
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+ rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Set);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aPrinterName_Get, aPrinterName_Set);
+}
+
+// [optional, property] short PrinterIndependentLayout;
+void testPrinterIndependentLayout(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
+{
+ static const OUStringLiteral rPropertyName(u"PrinterIndependentLayout");
+
+ if (!extstsProperty(rxSettings, rPropertyName))
+ return; // Property is optional
+
+ sal_Int16 aValue_Get = {};
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+ rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
+
+ sal_Int16 aValue_New;
+ aValue_New = (aValue_Get == 1 ? 3 : 1);
+ rxSettings->setPropertyValue(rPropertyName, css::uno::Any(aValue_New));
+
+ sal_Int16 aValue_Set;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+ rxSettings->getPropertyValue(rPropertyName) >>= aValue_Set);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aValue_New, aValue_Set);
+}
+
+// [optional, property] com::sun::star::i18n::XForbiddenCharacters ForbiddenCharacters;
+void testForbiddenCharacters(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
+{
+ static const OUStringLiteral rPropertyName(u"ForbiddenCharacters");
+
+ if (!extstsProperty(rxSettings, rPropertyName))
+ return; // Property is optional
+
+ CPPUNIT_ASSERT_MESSAGE("Property is read-only but shouldn't be",
+ !isPropertyReadOnly(rxSettings, rPropertyName));
+
+ css::uno::Reference<css::i18n::XForbiddenCharacters> aValue_Get;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
+ rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
+ CPPUNIT_ASSERT_MESSAGE("Empty reference to XForbiddenCharacters", aValue_Get.is());
+}
+}
+
+namespace apitest
+{
+TextSettings::~TextSettings() {}
+void TextSettings::testSettingsProperties()
+{
+ css::uno::Reference<css::beans::XPropertySet> xSettings(init(), css::uno::UNO_QUERY_THROW);
+
+ testForbiddenCharacters(xSettings);
+ //testShortOptionalProperty(xSettings, "LinkUpdateMode");
+ testPrinterName(xSettings);
+ // [property] sequence< byte > PrinterSetup;
+ testBooleanOptionalProperty(xSettings, "IsKernAsianPunctuation");
+ //testShortOptionalProperty(xSettings, "CharacterCompressionType");
+ testBooleanOptionalProperty(xSettings, "ApplyUserData");
+ testBooleanOptionalProperty(xSettings, "SaveVersionOnClose");
+ testBooleanOptionalProperty(xSettings, "UpdateFromTemplate");
+ testBooleanOptionalProperty(xSettings, "FieldAutoUpdate");
+ testStringOptionalProperty(xSettings, "CurrentDatabaseDataSource");
+ testStringOptionalProperty(xSettings, "CurrentDatabaseCommand");
+ testLongOptionalProperty(xSettings, "CurrentDatabaseCommandType");
+ testLongOptionalProperty(xSettings, "DefaultTabStop");
+ testBooleanOptionalProperty(xSettings, "IsPrintBooklet");
+ testBooleanOptionalProperty(xSettings, "IsPrintBookletFront");
+ testBooleanOptionalProperty(xSettings, "IsPrintBookletBack");
+ testLongOptionalProperty(xSettings, "PrintQuality");
+ testStringOptionalProperty(xSettings, "ColorTableURL");
+ testStringOptionalProperty(xSettings, "DashTableURL");
+ testStringOptionalProperty(xSettings, "LineEndTableURL");
+ testStringOptionalProperty(xSettings, "HatchTableURL");
+ testStringOptionalProperty(xSettings, "GradientTableURL");
+ testStringOptionalProperty(xSettings, "BitmapTableURL");
+ testBooleanOptionalProperty(xSettings, "AutoCalculate");
+ testPrinterIndependentLayout(xSettings);
+ testBooleanOptionalProperty(xSettings, "AddExternalLeading");
+ testBooleanOptionalProperty(xSettings, "EmbedFonts");
+ testBooleanOptionalProperty(xSettings, "EmbedSystemFonts");
+ testBooleanOptionalProperty(xSettings, "EmbedOnlyUsedFonts");
+ testBooleanOptionalProperty(xSettings, "EmbedLatinScriptFonts");
+ testBooleanOptionalProperty(xSettings, "EmbedAsianScriptFonts");
+ testBooleanOptionalProperty(xSettings, "EmbedComplexScriptFonts");
+}
+} // end namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/xdocumentindex.cxx b/test/source/text/xdocumentindex.cxx
new file mode 100644
index 000000000..9f9ad73c8
--- /dev/null
+++ b/test/source/text/xdocumentindex.cxx
@@ -0,0 +1,66 @@
+/* -*- 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/.
+ */
+
+#include <cppunit/TestAssert.h>
+
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XDocumentIndex.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <test/text/xdocumentindex.hxx>
+
+namespace apitest
+{
+XDocumentIndex::~XDocumentIndex() {}
+/**
+ * Gets the document from relation and insert a new index mark.
+ * Then it stores the text content of document index before
+ * update and after.<p>
+ *
+ * Has <b> OK </b> status if index content is changed and
+ * new index contains index mark inserted. <p>
+ */
+void XDocumentIndex::testUpdate()
+{
+ css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(init(),
+ css::uno::UNO_QUERY_THROW);
+
+ bool bOK = true;
+ try
+ {
+ auto xText = getTextDocument()->getText();
+ auto xTextRange = xText->getEnd();
+ xTextRange->setString("IndexMark");
+ css::uno::Reference<css::lang::XMultiServiceFactory> xFactory(getTextDocument(),
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::text::XTextContent> xTextContentMark(
+ xFactory->createInstance("com.sun.star.text.DocumentIndexMark"),
+ css::uno::UNO_QUERY_THROW);
+ xText->insertTextContent(xTextRange, xTextContentMark, true);
+ }
+ catch (css::uno::Exception /*exception*/)
+ {
+ bOK = false;
+ }
+
+ CPPUNIT_ASSERT_MESSAGE("Couldn't create the document index mark", bOK);
+
+ OUString sContentBefore = xDocumentIndex->getAnchor()->getString();
+ xDocumentIndex->update();
+ OUString sContentAfter = xDocumentIndex->getAnchor()->getString();
+
+ CPPUNIT_ASSERT_MESSAGE("Before and after shouldn't be equal", sContentBefore != sContentAfter);
+ CPPUNIT_ASSERT_MESSAGE("Content after should contain string 'IndexMark'",
+ sContentAfter.indexOf("IndexMark") >= 0);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/xsimpletext.cxx b/test/source/text/xsimpletext.cxx
new file mode 100644
index 000000000..23ea6c785
--- /dev/null
+++ b/test/source/text/xsimpletext.cxx
@@ -0,0 +1,76 @@
+/* -*- 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/.
+ */
+
+#include <test/text/xsimpletext.hxx>
+#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/text/ControlCharacter.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSimpleText::testCreateTextCursor()
+{
+ uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT(xSimpleText->createTextCursor());
+}
+
+void XSimpleText::testCreateTextCursorByRange()
+{
+ uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
+ uno::Reference<text::XTextCursor> xCursor(xSimpleText->createTextCursor(), UNO_SET_THROW);
+
+ xCursor->gotoStart(false);
+
+ CPPUNIT_ASSERT(xSimpleText->createTextCursorByRange(xCursor));
+}
+
+void XSimpleText::testInsertString()
+{
+ uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> xCursor(xSimpleText->createTextCursor(), UNO_QUERY_THROW);
+ ::rtl::OUString sString = "TestString";
+
+ xSimpleText->insertString(xCursor, sString, false);
+ ::rtl::OUString gString = xSimpleText->getText()->getString();
+
+ CPPUNIT_ASSERT(!gString.isEmpty());
+ CPPUNIT_ASSERT(gString.indexOf(sString) >= 0);
+}
+
+void XSimpleText::testInsertControlCharacter()
+{
+ bool bOK = true;
+
+ uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> xCursor(xSimpleText->createTextCursor(), UNO_QUERY_THROW);
+
+ try
+ {
+ xSimpleText->insertControlCharacter(xCursor, text::ControlCharacter::PARAGRAPH_BREAK,
+ false);
+ xSimpleText->insertControlCharacter(xCursor, text::ControlCharacter::LINE_BREAK, false);
+ xSimpleText->insertString(xSimpleText->createTextCursor(), "newLine", false);
+ }
+ catch (const lang::IllegalArgumentException&)
+ {
+ bOK = false;
+ }
+
+ OUString gString = xSimpleText->getString();
+ CPPUNIT_ASSERT(bOK);
+ CPPUNIT_ASSERT(gString.indexOf("\n") > -1);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/xtext.cxx b/test/source/text/xtext.cxx
new file mode 100644
index 000000000..6f6274156
--- /dev/null
+++ b/test/source/text/xtext.cxx
@@ -0,0 +1,29 @@
+/* -*- 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/.
+ */
+
+#include <test/text/xtext.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+XText::~XText() {}
+
+void XText::testInsertRemoveTextContent()
+{
+ uno::Reference<text::XText> xText(init(), UNO_QUERY_THROW);
+ uno::Reference<text::XTextRange> xCursor(xText->createTextCursor(), UNO_QUERY_THROW);
+
+ xText->insertTextContent(xCursor, getTextContent(), false);
+ xText->removeTextContent(getTextContent());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/xtextcontent.cxx b/test/source/text/xtextcontent.cxx
new file mode 100644
index 000000000..762584e88
--- /dev/null
+++ b/test/source/text/xtextcontent.cxx
@@ -0,0 +1,57 @@
+/* -*- 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/.
+ */
+
+#include <test/text/xtextcontent.hxx>
+#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XTextContent::testGetAnchor()
+{
+ uno::Reference<text::XTextContent> xTextContent(init(), UNO_QUERY_THROW);
+ uno::Reference<uno::XInterface> xAnchor(xTextContent->getAnchor());
+ CPPUNIT_ASSERT(xAnchor.is());
+}
+
+void XTextContent::testAttach()
+{
+ uno::Reference<text::XTextContent> xTextContent(init(), UNO_QUERY_THROW);
+
+ uno::Reference<text::XTextContent> xContent(getTextContent(), UNO_SET_THROW);
+ uno::Reference<text::XTextRange> xRange(getTextRange(), UNO_SET_THROW);
+
+ try
+ {
+ if (xContent.is())
+ xContent->attach(xRange);
+ else
+ xTextContent->attach(xRange);
+ }
+ catch (const lang::IllegalArgumentException&)
+ {
+ bool bAttachSupported = isAttachSupported();
+ if (bAttachSupported)
+ CPPUNIT_ASSERT(false);
+ }
+ catch (const RuntimeException&)
+ {
+ bool bAttachSupported = isAttachSupported();
+ if (bAttachSupported)
+ CPPUNIT_ASSERT(false);
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/text/xtextfield.cxx b/test/source/text/xtextfield.cxx
new file mode 100644
index 000000000..ceefcceed
--- /dev/null
+++ b/test/source/text/xtextfield.cxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/text/xtextfield.hxx>
+
+#include <com/sun/star/text/XTextField.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+
+namespace apitest
+{
+void XTextField::testGetPresentation()
+{
+ uno::Reference<text::XTextField> xTextField(init(), uno::UNO_QUERY_THROW);
+
+ OUString aString = xTextField->getPresentation(true);
+ CPPUNIT_ASSERT(!aString.isEmpty());
+ aString = xTextField->getPresentation(false);
+ CPPUNIT_ASSERT(!aString.isEmpty());
+}
+
+void XTextField::testGetPresentationEmptyString()
+{
+ uno::Reference<text::XTextField> xTextField(init(), uno::UNO_QUERY_THROW);
+
+ OUString aString = xTextField->getPresentation(true);
+ CPPUNIT_ASSERT(aString.isEmpty());
+ aString = xTextField->getPresentation(false);
+ CPPUNIT_ASSERT(aString.isEmpty());
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/text/xtextrange.cxx b/test/source/text/xtextrange.cxx
new file mode 100644
index 000000000..64428b476
--- /dev/null
+++ b/test/source/text/xtextrange.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/text/xtextrange.hxx>
+
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+
+namespace apitest
+{
+void XTextRange::testGetEnd()
+{
+ uno::Reference<text::XTextRange> xTextRange(init(), uno::UNO_QUERY_THROW);
+
+ xTextRange->setString("UnitTest");
+ uno::Reference<text::XTextRange> xTR_end(xTextRange->getEnd(), uno::UNO_SET_THROW);
+ xTR_end->setString("End");
+
+ CPPUNIT_ASSERT(xTextRange->getText()->getString().endsWith("End"));
+}
+
+void XTextRange::testGetSetString()
+{
+ uno::Reference<text::XTextRange> xTextRange(init(), uno::UNO_QUERY_THROW);
+
+ xTextRange->setString("UnitTest");
+ CPPUNIT_ASSERT_EQUAL(OUString("UnitTest"), xTextRange->getString());
+}
+
+void XTextRange::testGetStart()
+{
+ uno::Reference<text::XTextRange> xTextRange(init(), uno::UNO_QUERY_THROW);
+
+ xTextRange->setString("UnitTest");
+ uno::Reference<text::XTextRange> xTR_start(xTextRange->getStart(), uno::UNO_SET_THROW);
+ xTR_start->setString("Start");
+
+ CPPUNIT_ASSERT(xTextRange->getText()->getString().startsWith("Start"));
+}
+
+void XTextRange::testGetText()
+{
+ uno::Reference<text::XTextRange> xTextRange(init(), uno::UNO_QUERY_THROW);
+
+ xTextRange->setString("UnitTest");
+ uno::Reference<text::XText> xText(xTextRange->getText(), uno::UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("UnitTest"), xTextRange->getString());
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */