void DialogSaveTest::test()
{
createTempCopy(u"testDialogSave.odb");
{
loadFromURL(maTempFile.GetURL());
uno::Reference< frame::XStorable > xDocStorable(mxComponent, UNO_QUERY_THROW);
uno::Reference< document::XEmbeddedScripts > xDocScr(mxComponent, UNO_QUERY_THROW);
uno::Reference< script::XStorageBasedLibraryContainer > xStorBasLib(xDocScr->getBasicLibraries());
CPPUNIT_ASSERT(xStorBasLib.is());
uno::Reference< script::XLibraryContainer > xBasLib(xStorBasLib, UNO_QUERY_THROW);
uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries());
CPPUNIT_ASSERT(xStorDlgLib.is());
uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW); static constexpr OUString sStandard(u"Standard"_ustr);
xBasLib->loadLibrary(sStandard);
CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard)); // the whole point of this test is to test the "save" operation // when the Basic library is loaded, but not the Dialog library
CPPUNIT_ASSERT(!xDlgLib->isLibraryLoaded(sStandard));
// make some change to enable a save // uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSuppl(mxComponent, UNO_QUERY_THROW); // uno::Reference< document::XDocumentPropertiesSupplier > xDocProps(xDocPropSuppl->getDocumentProperties()); // CPPUNIT_ASSERT(xDocProps.is()); // xDocProps.setTitle(xDocProps.getTitle() + " suffix");
uno::Reference< util::XModifiable > xDocMod(mxComponent, UNO_QUERY_THROW);
xDocMod->setModified(true);
// now save; the code path to exercise in this test is the "store to same location" // do *not* change to store(As|To|URL)!
xDocStorable->store();
// All our uno::References are (should?) be invalid now -> let them go out of scope
}
{
uno::Sequence<uno::Any> args{ uno::Any(maTempFile.GetURL()) };
Reference<container::XHierarchicalNameAccess> xHNA(getMultiServiceFactory()->createInstanceWithArguments(u"com.sun.star.packages.Package"_ustr, args), UNO_QUERY_THROW);
Reference< beans::XPropertySet > xPS(xHNA->getByHierarchicalName(u"Dialogs/Standard/Dialog1.xml"_ustr), UNO_QUERY_THROW);
sal_Int64 nSize = 0;
CPPUNIT_ASSERT(xPS->getPropertyValue(u"Size"_ustr) >>= nSize);
CPPUNIT_ASSERT(nSize != 0);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.