diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sw/qa/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/inc')
-rw-r--r-- | sw/qa/inc/bordertest.hxx | 206 | ||||
-rw-r--r-- | sw/qa/inc/swmodeltestbase.hxx | 354 | ||||
-rw-r--r-- | sw/qa/inc/swqahelperdllapi.h | 20 |
3 files changed, 580 insertions, 0 deletions
diff --git a/sw/qa/inc/bordertest.hxx b/sw/qa/inc/bordertest.hxx new file mode 100644 index 0000000000..3137c85c97 --- /dev/null +++ b/sw/qa/inc/bordertest.hxx @@ -0,0 +1,206 @@ +/* -*- 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/. + */ +#ifndef INCLUDED_SW_QA_INC_BORDERTEST_HXX +#define INCLUDED_SW_QA_INC_BORDERTEST_HXX + +#include <cppunit/TestAssert.h> +#include <com/sun/star/table/BorderLine.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <map> + +namespace com::sun::star::table { class XCell; } + +typedef std::map<OUString, css::table::BorderLine> BorderLineMap; +typedef std::pair<OUString, css::table::BorderLine> StringBorderPair; + +using namespace com::sun::star; + +class BorderTest +{ +public: + BorderTest() + { + + } + static void testTheBorders(uno::Reference<lang::XComponent> const & mxComponent, bool isBinaryDoc) + { + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(textDocument->getText(), uno::UNO_QUERY); + // list of paragraphs + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + + // maps containing TopBorder widths for every cell + // one map for each tables - there are 8 of them, counting from 0 + BorderLineMap map0; + map0.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 53, 26, 26))); + map0.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 79, 26, 26))); + map0.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 106, 26, 26))); + map0.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 159, 26, 26))); + map0.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 212, 26, 26))); + BorderLineMap map1; + map1.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 9, 9, 9))); + map1.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 18, 18, 18))); + map1.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 26, 26))); + map1.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 53, 53))); + map1.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 79, 79, 79))); + map1.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 106, 106, 106))); + BorderLineMap map2; + map2.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 9, 5, 5))); + map2.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 18, 9, 9))); + map2.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 14, 14))); + map2.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 35, 18, 18))); + map2.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 53, 26, 26))); + map2.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 79, 41, 41))); + map2.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 106, 53, 53))); + map2.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 159, 79, 79))); + map2.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 212, 106, 106))); + BorderLineMap map3; + map3.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 53, 26, 9))); + map3.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 53, 26, 18))); + map3.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 53, 26, 26))); + map3.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 26, 35))); + map3.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 53, 26, 53))); + map3.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 53, 26, 79))); + map3.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 53, 26, 106))); + map3.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 53, 26, 159))); + map3.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 53, 26, 212))); + map3.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 53, 26, 9))); + + // Binary-DOC importer changes 'inset' and 'outset' border styles to other styles + // during import, so for now - leaving binary-doc results as they were. + BorderLineMap map4; + if (isBinaryDoc) + { + map4.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 53, 26, 18))); + map4.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 53, 26, 26))); + map4.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 26, 35))); + map4.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 53, 26, 35))); + map4.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 53, 26, 79))); + map4.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 53, 26, 106))); + map4.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 53, 26, 159))); + map4.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 53, 26, 212))); + } + else + { + map4.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 0, 26, 4))); + map4.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 5, 26, 5))); + map4.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 14, 26, 14))); + map4.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 23, 26, 23))); + map4.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 41, 26, 41))); + map4.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 67, 26, 67))); + map4.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 93, 26, 93))); + map4.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 146, 26, 146))); + map4.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 199, 26, 199))); + } + BorderLineMap map5; + if (isBinaryDoc) + { + map5.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 26, 53, 9))); + map5.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 53, 18))); + map5.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 53, 26))); + map5.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 26, 53, 35))); + map5.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 26, 53, 53))); + map5.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 26, 53, 79))); + map5.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 26, 53, 106))); + map5.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 26, 53, 159))); + map5.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 26, 53, 212))); + } + else + { + map5.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 26, 2, 4))); + map5.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 5, 5))); + map5.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 14, 14))); + map5.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 26, 23, 23))); + map5.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 26, 41, 41))); + map5.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 26, 67, 67))); + map5.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 26, 93, 93))); + map5.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 26, 146, 146))); + map5.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 26, 199, 199))); + } + BorderLineMap map6; + map6.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 14, 14, 26))); + map6.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 26, 53))); + map6.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 41, 41, 79))); + map6.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 53, 106))); + map6.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 79, 79, 159))); + map6.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 106, 106, 212))); + BorderLineMap map7; + map7.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 14, 14, 26))); + map7.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 26, 53))); + map7.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 41, 41, 79))); + map7.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 53, 106))); + map7.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 79, 79, 159))); + map7.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 106, 106, 212))); + + sal_Int32 currentTable = 0; //to know which map should we check with the current table + BorderLineMap* tempMap; + tempMap = &map0; + do + { + uno::Reference<lang::XServiceInfo> xServiceInfo; + if (xParaEnum->nextElement() >>= xServiceInfo) + { + if (xServiceInfo->supportsService("com.sun.star.text.TextTable")) + { + uno::Reference<text::XTextTable> const xTextTable(xServiceInfo, uno::UNO_QUERY_THROW); + uno::Sequence<OUString> const cells = xTextTable->getCellNames(); + + if(currentTable == sal_Int32(1)) + tempMap = &map1; + if(currentTable == sal_Int32(2)) + tempMap = &map2; + if(currentTable == sal_Int32(3)) + tempMap = &map3; + if(currentTable == sal_Int32(4)) + tempMap = &map4; + if(currentTable == sal_Int32(5)) + tempMap = &map5; + if(currentTable == sal_Int32(6)) + tempMap = &map6; + if(currentTable == sal_Int32(7)) + tempMap = &map7; + + BorderLineMap::iterator it = tempMap->begin(); + + for (const auto& rCell : cells) + { + uno::Reference<table::XCell> xCell = xTextTable->getCellByName(rCell); + uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW); + uno::Any aAny = xPropSet->getPropertyValue("TopBorder"); + table::BorderLine aBorderLine; + it = tempMap->find(rCell); + if ((aAny >>= aBorderLine) && (it!=tempMap->end())) + { + sal_Int32 innerLineWidth = aBorderLine.InnerLineWidth; + sal_Int32 outerLineWidth = aBorderLine.OuterLineWidth; + sal_Int32 lineDistance = aBorderLine.LineDistance; + + sal_Int32 perfectInner = it->second.InnerLineWidth; + sal_Int32 perfectOuter = it->second.OuterLineWidth; + sal_Int32 perfectDistance = it->second.LineDistance; + CPPUNIT_ASSERT_EQUAL(perfectInner, innerLineWidth); + CPPUNIT_ASSERT_EQUAL(perfectOuter, outerLineWidth); + CPPUNIT_ASSERT_EQUAL(perfectDistance, lineDistance); + } + } + ++currentTable; + } + } + } while(xParaEnum->hasMoreElements()); + } + +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx new file mode 100644 index 0000000000..950136e66e --- /dev/null +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -0,0 +1,354 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_SW_QA_INC_SWMODELTESTBASE_HXX +#define INCLUDED_SW_QA_INC_SWMODELTESTBASE_HXX + +#include <memory> +#include <string_view> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/style/XAutoStyleFamily.hpp> +#include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/table/XCell.hpp> +#include <com/sun/star/table/BorderLine2.hpp> +#include <com/sun/star/xml/AttributeData.hpp> + +#include "swqahelperdllapi.h" +#include <test/unoapixml_test.hxx> +#include <unotools/tempfile.hxx> + +#include <doc.hxx> + +/** + * Macro to declare a new test (with full round-trip. To test + * import only use the CPPUNIT_TEST_FIXTURE macro directly). + * In order to add a new test, one only needs to use this macro + * and then specify the test content, like this: + * + * DECLARE_SW_ROUNDTRIP_TEST(MyTest, "myfilename.docx", Test) + * { + * CPPUNIT_ASSERT_EQUAL(blabla); + * } + * + */ +#define DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, password, BaseClass) \ + class TestName : public BaseClass { \ + public:\ + CPPUNIT_TEST_SUITE(TestName); \ + CPPUNIT_TEST(Load_Verify_Reload_Verify); \ + CPPUNIT_TEST_SUITE_END(); \ + \ + void Load_Verify_Reload_Verify() {\ + executeLoadVerifyReloadVerify(filename, password);\ + }\ + void verify() override;\ + }; \ + CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \ + void TestName::verify() + +#define DECLARE_OOXMLEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test) +#define DECLARE_RTFEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test) +#define DECLARE_ODFEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test) +#define DECLARE_FODFEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test) +#define DECLARE_WW8EXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test) + +#define DECLARE_SW_EXPORT_TEST(TestName, filename, password, BaseClass) \ + class TestName : public BaseClass { \ + public:\ + CPPUNIT_TEST_SUITE(TestName); \ + CPPUNIT_TEST(Import_Export); \ + CPPUNIT_TEST_SUITE_END(); \ + \ + void Import_Export() {\ + executeImportExport(filename, password);\ + }\ + void verify() override;\ + }; \ + CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \ + void TestName::verify() + +class SwXTextDocument; +namespace vcl +{ +namespace pdf +{ +class PDFiumDocument; +} +} + +/// Base class for filter tests loading or roundtripping a document, then asserting the document model. +class SWQAHELPER_DLLPUBLIC SwModelTestBase : public UnoApiXmlTest +{ +private: + bool mbExported; ///< Does maTempFile already contain something useful? + +protected: + xmlBufferPtr mpXmlBuffer; + OUString mpFilter; + + sal_uInt32 mnStartTime; + + /// Copy&paste helper. + void paste(std::u16string_view aFilename, OUString aInstance, css::uno::Reference<css::text::XTextRange> const& xTextRange); + +public: + SwModelTestBase(const OUString& pTestDocumentPath = OUString(), const OUString& pFilter = {}); + +protected: + /** + * Helper func used by each unit test to test the 'import' code. + * (Loads the requested file and then calls 'verify' method) + */ + void executeImportTest(const char* filename, const char* pPassword = nullptr); + + /** + * Helper func used by each unit test to test the 'export' code. + * (Loads the requested file, calls 'verify' function, save it to temp file, load the + * temp file and then calls 'verify' function again) + */ + void executeLoadVerifyReloadVerify(const char* filename, const char* pPassword = nullptr); + + /** + * Helper func used by each unit test to test the 'export' code. + * (Loads the requested file, save it to temp file, load the + * temp file and then calls 'verify' method) + */ + void executeLoadReloadVerify(const char* filename, const char* pPassword = nullptr); + + /** + * Helper func used by each unit test to test the 'export' code. + * (Loads the requested file for document base (this represents + * the initial document condition), exports with the desired + * export filter and then calls 'verify' method) + */ + void executeImportExport(const char* filename, const char* pPassword); + + /** + * Function overridden by unit test. See DECLARE_SW_*_TEST macros + */ + virtual void verify() + { + CPPUNIT_FAIL( "verify method must be overridden" ); + } + + /// Override this function if some special file-specific setup is needed during export test: after load, but before save. + virtual void postLoad(const char* /*pFilename*/) + { + } + + void dumpLayout(const css::uno::Reference< css::lang::XComponent > & rComponent); + + void discardDumpedLayout(); + + void calcLayout(); + + /// Get the length of the whole document. @deprecated why use this? + int getLength() const; + /// Get the body text of the whole document. + OUString getBodyText() const; + + /// Get a family of styles, see com.sun.star.style.StyleFamilies for possible values. + css::uno::Reference<css::container::XNameAccess> getStyles(const OUString& aFamily); + + /// Get a family of auto styles, see com.sun.star.style.StyleFamilies for possible values. + css::uno::Reference<css::style::XAutoStyleFamily> getAutoStyles(const OUString& aFamily); + + /// Similar to parseExport(), but this gives the xmlDocPtr of the layout dump. + xmlDocUniquePtr parseLayoutDump(); + + /** + * Extract a value from the layout dump using an XPath expression and an attribute name. + * + * If the attribute is omitted, the text of the node is returned. + */ + OUString parseDump(const OString& aXPath, const OString& aAttribute = OString()); + + template< typename T > + T getProperty( const css::uno::Any& obj, const OUString& name ) const + { + css::uno::Reference< css::beans::XPropertySet > properties( obj, uno::UNO_QUERY_THROW ); + T data; + if (!css::uno::fromAny(properties->getPropertyValue(name), &data)) + { + OString const msg("the property is of unexpected type or void: " + + OUStringToOString(name, RTL_TEXTENCODING_UTF8)); + CPPUNIT_FAIL(msg.getStr()); + } + return data; + } + + template< typename T > + T getProperty( const css::uno::Reference< css::uno::XInterface >& obj, const OUString& name ) const + { + css::uno::Reference< css::beans::XPropertySet > properties( obj, uno::UNO_QUERY_THROW ); + T data = T(); + if (!(properties->getPropertyValue(name) >>= data)) + { + OString const msg("the property is of unexpected type or void: " + + OUStringToOString(name, RTL_TEXTENCODING_UTF8)); + CPPUNIT_FAIL(msg.getStr()); + } + return data; + } + + bool isPropertyVoid(const css::uno::Reference<css::uno::XInterface>& object, const OUString& name) const + { + if (!hasProperty(object, name)) + return false; + + css::uno::Reference< css::beans::XPropertySet > properties(object, uno::UNO_QUERY_THROW); + return !properties->getPropertyValue(name).hasValue(); + } + + bool hasProperty(const css::uno::Reference<css::uno::XInterface>& obj, const OUString& name) const; + + css::xml::AttributeData getUserDefineAttribute(const css::uno::Any& obj, const OUString& name, const OUString& rValue) const; + + int getParagraphs( css::uno::Reference<text::XText> const & xText ); + + /// Get number of paragraphs of the document. + int getParagraphs(); + + css::uno::Reference<css::text::XTextContent> getParagraphOrTable(int number, css::uno::Reference<css::text::XText> const & xText = css::uno::Reference<css::text::XText>()) const; + + // Get paragraph (counted from 1), optionally check it contains the given text. + css::uno::Reference< css::text::XTextRange > getParagraph( int number, const OUString& content = OUString() ) const; + + sal_Int16 getNumberingTypeOfParagraph(int nPara); + + css::uno::Reference<css::text::XTextRange> getParagraphOfText(int number, css::uno::Reference<css::text::XText> const & xText, const OUString& content = OUString()) const; + + /// get nth object/fly that is anchored AT paragraph + css::uno::Reference<css::beans::XPropertySet> getParagraphAnchoredObject( + int const index, css::uno::Reference<css::text::XTextRange> const & xPara) const; + + /// Get run (counted from 1) of a paragraph, optionally check it contains the given text. + css::uno::Reference<css::text::XTextRange> getRun(uno::Reference<css::text::XTextRange> const & xParagraph, int number, const OUString& content = OUString()) const; + + /// Get math formula string of a run. + OUString getFormula(css::uno::Reference<css::text::XTextRange> const & xRun) const; + + /// get cell of a table; table can be retrieved with getParagraphOrTable + css::uno::Reference<css::table::XCell> getCell( + css::uno::Reference<css::uno::XInterface> const& xTableIfc, + OUString const& rCell, OUString const& rContent = OUString()); + + /// Get shape (counted from 1) + css::uno::Reference<css::drawing::XShape> getShape(int number); + + /// Select shape (counted from 1) + void selectShape(int number); + + /// Get shape by name + css::uno::Reference<css::drawing::XShape> getShapeByName(std::u16string_view aName); + + /// Get TextFrame by name + css::uno::Reference<css::drawing::XShape> getTextFrameByName(const OUString& aName); + + void header(); + + void saveAndReload(const OUString& pFilter, const char* pPassword = nullptr); + + /// Combines load() and save(). + void loadAndSave(const char* pName, const char* pPassword = nullptr); + + /// Combines load() and saveAndReload(). + void loadAndReload(const char* pName); + + void finish(); + + /// Get page count. + int getPages() const; + + /// Get shape count. + int getShapes() const; + + /** + * Returns an xml stream of an exported file. + * To be used when the exporter doesn't create zip archives, but single files + * (like Flat ODF Export) + */ + xmlDocUniquePtr parseExportedFile(); + + /** + * Creates a new document to be used with the internal sw/ API. + * + * Examples: + * createSwDoc(); + * createSwDoc("test.fodt"); + * createSwDoc("test.fodt", "test"); + */ + void createSwDoc(const char* pName = nullptr, const char* pPassword = nullptr); + + /** + * As createSwDoc except a Web Document in Browse Mode + */ + void createSwWebDoc(const char* pName = nullptr); + + /** + * As createSwDoc except a Global Document + */ + void createSwGlobalDoc(const char* pName = nullptr); + + /** + * Gets SwDoc from loaded component + */ + SwDoc* getSwDoc(); + + /** + * Gets SwDocShell from loaded component + */ + SwDocShell* getSwDocShell(); + + /** + * Wraps a reqif-xhtml fragment into an XHTML file, and XML-parses it. + */ + xmlDocUniquePtr WrapReqifFromTempFile(); + + void WrapFromTempFile(SvMemoryStream& rStream); + + bool isExported(){ return mbExported; } + + void emulateTyping(SwXTextDocument& rTextDoc, const std::u16string_view& rStr); + +private: + void loadURL(OUString const& rURL, const char* pPassword = nullptr); +}; + +/** + * Test whether the expected and actual borderline parameters are equal + * and assert if not. + * + * @param[in] rExpected expected borderline object + * @param[in] rActual actual borderline object + * @param[in] rSourceLine line from where the assertion is called + * Note: This method is the implementation of CPPUNIT_ASSERT_BORDER_EQUAL, so + * use that macro instead. +**/ +inline void assertBorderEqual( + const css::table::BorderLine2& rExpected, const css::table::BorderLine2& rActual, + const CppUnit::SourceLine& rSourceLine ) +{ + CPPUNIT_NS::assertEquals( rExpected.Color, rActual.Color, rSourceLine, "different Color" ); + CPPUNIT_NS::assertEquals( rExpected.InnerLineWidth, rActual.InnerLineWidth, rSourceLine, "different InnerLineWidth" ); + CPPUNIT_NS::assertEquals( rExpected.OuterLineWidth, rActual.OuterLineWidth, rSourceLine, "different OuterLineWidth" ); + CPPUNIT_NS::assertEquals( rExpected.LineDistance, rActual.LineDistance, rSourceLine, "different LineDistance" ); + CPPUNIT_NS::assertEquals( rExpected.LineStyle, rActual.LineStyle, rSourceLine, "different LineStyle" ); + CPPUNIT_NS::assertEquals( rExpected.LineWidth, rActual.LineWidth, rSourceLine, "different LineWidth" ); +} + +#define CPPUNIT_ASSERT_BORDER_EQUAL(aExpected, aActual) \ + assertBorderEqual( aExpected, aActual, CPPUNIT_SOURCELINE() ) \ + +#endif // INCLUDED_SW_QA_INC_SWMODELTESTBASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/inc/swqahelperdllapi.h b/sw/qa/inc/swqahelperdllapi.h new file mode 100644 index 0000000000..1bda576791 --- /dev/null +++ b/sw/qa/inc/swqahelperdllapi.h @@ -0,0 +1,20 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sal/types.h> + +#if defined(SWQAHELPER_DLLIMPLEMENTATION) +#define SWQAHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define SWQAHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |