sw/qa/extras/odfimport/data/timeFormFormats.odt |binary sw/qa/extras/odfimport/odfimport.cxx | 47 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
New commits: commit bef317ec9d00beb70d6b59c2af3b61ef2544b4a5 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Mar 3 17:15:02 2020 +0100 Commit: Xisco Faulí <xiscofa...@libreoffice.org> CommitDate: Thu Mar 5 09:51:41 2020 +0100 tdf#130515: Add unittest Change-Id: Ie98a4a6f35d31f8fdca9d439aa5ec9990e9c4213 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89895 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/odfimport/data/timeFormFormats.odt b/sw/qa/extras/odfimport/data/timeFormFormats.odt new file mode 100644 index 000000000000..9b39aec57925 Binary files /dev/null and b/sw/qa/extras/odfimport/data/timeFormFormats.odt differ diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 973cc4a0d311..8eff1cf92e1f 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -11,9 +11,15 @@ #include <config_features.h> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XWindowPeer.hpp> #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/drawing/BitmapMode.hpp> +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/XFormsSupplier.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/style/PageStyleLayout.hpp> #include <com/sun/star/style/FootnoteLineStyle.hpp> @@ -23,6 +29,7 @@ #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/PageNumberType.hpp> #include <com/sun/star/text/VertOrientation.hpp> +#include <com/sun/star/view/XControlAccess.hpp> #include <IDocumentSettingAccess.hxx> #include <wrtsh.hxx> @@ -258,6 +265,46 @@ DECLARE_ODFIMPORT_TEST(testPageStyleLayoutDefault, "hello.odt") CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_ALL, getProperty<style::PageStyleLayout>(xPropertySet, "PageStyleLayout")); } +DECLARE_ODFIMPORT_TEST(testTimeFormFormats, "timeFormFormats.odt") +{ + //FIXME: make it an ODFEXPORT_TEST. Validator fails with + //attribute "form:current-value" has a bad value: "PT12H12M" does not satisfy the "time" type + + uno::Reference<frame::XModel> const xModel(mxComponent, uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + uno::Reference<drawing::XDrawPageSupplier> const xDPS(xModel, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> const xDP = xDPS->getDrawPage(); + CPPUNIT_ASSERT(xDP.is()); + uno::Reference<form::XFormsSupplier> const xFS(xDP, uno::UNO_QUERY); + CPPUNIT_ASSERT(xFS.is()); + uno::Reference<container::XIndexContainer> const xForms(xFS->getForms(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xForms.is()); + uno::Reference<form::XForm> xForm(xForms->getByIndex(0), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xForm.is()); + uno::Reference<container::XNameContainer> xFormNC(xForm, uno::UNO_QUERY); + + uno::Any aAny; + uno::Reference<awt::XControlModel> xControlModel; + uno::Reference<view::XControlAccess> xController; + uno::Reference<awt::XControl> xControl; + uno::Reference<awt::XWindowPeer> xWindowPeer; + uno::Reference<awt::XTextComponent> xTextComponent; + OUString aName = "Time Field "; + + static const char* const aExpectedResults[] = { "12:12", "12:12:00", "12:12PM", "06:00:00AM"}; + + for (size_t i = 1; i <= 4; ++i) + { + aAny = xFormNC->getByName(aName + OUString::number(i)); + xControlModel.set(aAny, uno::UNO_QUERY); + xController.set(xModel->getCurrentController(), uno::UNO_QUERY_THROW); + xControl = xController->getControl(xControlModel); + xWindowPeer = xControl->getPeer(); + xTextComponent.set(xWindowPeer, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(aExpectedResults[i - 1]), xTextComponent->getText()); + } +} + DECLARE_ODFIMPORT_TEST(testTdf64038, "space.odt") { // no space _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits