tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / dbaccess / qa / extras / empty-stdlib-save.cxx
blob708ce86c9eed8f82f0351442908a7ab510997e76
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
11 #include <test/unoapi_test.hxx>
12 #include <com/sun/star/frame/XStorable.hpp>
13 #include <com/sun/star/document/XEmbeddedScripts.hpp>
14 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
15 #include <com/sun/star/script/XLibraryContainer.hpp>
16 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
18 using namespace ::com::sun::star;
19 using namespace ::com::sun::star::uno;
22 class DialogSaveTest : public UnoApiTest
24 public:
25 DialogSaveTest();
27 void test();
29 CPPUNIT_TEST_SUITE(DialogSaveTest);
30 CPPUNIT_TEST(test);
31 CPPUNIT_TEST_SUITE_END();
36 DialogSaveTest::DialogSaveTest()
37 : UnoApiTest(u"/dbaccess/qa/extras/testdocuments"_ustr)
41 void DialogSaveTest::test()
43 createTempCopy(u"testDialogSave.odb");
45 loadFromURL(maTempFile.GetURL());
46 uno::Reference< frame::XStorable > xDocStorable(mxComponent, UNO_QUERY_THROW);
47 uno::Reference< document::XEmbeddedScripts > xDocScr(mxComponent, UNO_QUERY_THROW);
48 uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
49 CPPUNIT_ASSERT(xStorBasLib.is());
50 uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
51 uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
52 CPPUNIT_ASSERT(xStorDlgLib.is());
53 uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW);
54 static constexpr OUString sStandard(u"Standard"_ustr);
55 xBasLib->loadLibrary(sStandard);
56 xDlgLib->loadLibrary(sStandard);
57 CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard));
58 CPPUNIT_ASSERT(xDlgLib->isLibraryLoaded(sStandard));
60 Any a;
61 uno::Reference< container::XNameContainer > xI;
63 a = xBasLib->getByName(sStandard);
64 a >>= xI;
65 CPPUNIT_ASSERT(xI.is());
66 xI->removeByName(u"Raralix"_ustr);
68 a = xDlgLib->getByName(sStandard);
69 a >>= xI;
70 CPPUNIT_ASSERT(xI.is());
71 xI->removeByName(u"Dialog1"_ustr);
73 // uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW);
74 // xDlgMod->setModified(sal_True);
76 // uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW);
77 // xScrMod->setModified(sal_True);
79 // uno::Reference< util::XModifiable > xDocMod(mxComponent, UNO_QUERY_THROW);
80 // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
81 // xDocMod->setModified(sal_True);
82 // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
83 // CPPUNIT_ASSERT(xDocMod->isModified());
85 // now save; the code path to exercise in this test is the "store to same location"
86 // do *not* change to store(As|To|URL)!
87 xDocStorable->store();
89 // All our uno::References are (should?) be invalid now -> let them go out of scope
92 uno::Sequence<uno::Any> args{ uno::Any(maTempFile.GetURL()) };
93 Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments(u"com.sun.star.packages.Package"_ustr, args), UNO_QUERY_THROW);
94 CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName(u"Basic/Standard"_ustr));
95 CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName(u"Dialogs/Standard"_ustr));
99 CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
101 CPPUNIT_PLUGIN_IMPLEMENT();
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */