tdf#130857 qt weld: Support "Insert Breaks" dialog
[LibreOffice.git] / dbaccess / qa / extras / nolib-save.cxx
blob2ad68714528eedec685535d4e451c32ff8864734
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 xBasLib->removeLibrary(sStandard);
61 xDlgLib->removeLibrary(sStandard);
63 // uno::Reference< util::XModifiable > xDlgMod(xDlgLib, UNO_QUERY_THROW);
64 // xDlgMod->setModified(sal_True);
66 // uno::Reference< util::XModifiable > xScrMod(xDocScr, UNO_QUERY_THROW);
67 // xScrMod->setModified(sal_True);
69 // uno::Reference< util::XModifiable > xDocMod(mxComponent, UNO_QUERY_THROW);
70 // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
71 // xDocMod->setModified(sal_True);
72 // std::cerr << "** Modified: " << static_cast<bool>(xDocMod->isModified()) << std::endl;
73 // CPPUNIT_ASSERT(xDocMod->isModified());
75 // now save; the code path to exercise in this test is the "store to same location"
76 // do *not* change to store(As|To|URL)!
77 xDocStorable->store();
79 // All our uno::References are (should?) be invalid now -> let them go out of scope
82 uno::Sequence<uno::Any> args{ uno::Any(maTempFile.GetURL()) };
83 Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments(u"com.sun.star.packages.Package"_ustr, args), UNO_QUERY_THROW);
84 CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName(u"Basic/Standard"_ustr));
85 CPPUNIT_ASSERT(!xHNA->hasByHierarchicalName(u"Dialogs/Standard"_ustr));
89 CPPUNIT_TEST_SUITE_REGISTRATION(DialogSaveTest);
91 CPPUNIT_PLUGIN_IMPLEMENT();
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */