// Test Office URI Schemes support void Test::testTdf100837() { auto xContext = ::cppu::defaultBootstrap_InitialComponentContext();
::css::uno::Reference<::css::lang::XMultiComponentFactory> xFactory(xContext->getServiceManager());
::css::uno::Reference<::css::lang::XMultiServiceFactory> xSM(xFactory, ::css::uno::UNO_QUERY_THROW); // Without this we're crashing because callees are using getProcessServiceFactory
::comphelper::setProcessServiceFactory(xSM);
{ // 1. Test default behaviour: Office URIs define open mode
TestSupplier supplier{ u"foo"_ustr, u"ms-word:ofe|u|bar1"_ustr, u"ms-word:ofv|u|bar2"_ustr, u"ms-word:nft|u|bar3"_ustr, u"baz"_ustr };
desktop::CommandLineArgs args(supplier); auto vOpenList = args.GetOpenList(); auto vForceOpenList = args.GetForceOpenList(); auto vViewList = args.GetViewList(); auto vForceNewList = args.GetForceNewList(); // 2 documents go to Open list: foo; baz
CPPUNIT_ASSERT_EQUAL(decltype(vOpenList.size())(2), vOpenList.size());
CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, vOpenList[0]);
CPPUNIT_ASSERT_EQUAL(u"baz"_ustr, vOpenList[1]); // 1 document goes to ForceOpen list: bar1
CPPUNIT_ASSERT_EQUAL(decltype(vForceOpenList.size())(1), vForceOpenList.size());
CPPUNIT_ASSERT_EQUAL(u"bar1"_ustr, vForceOpenList[0]); // 1 document goes to View list: bar2
CPPUNIT_ASSERT_EQUAL(decltype(vViewList.size())(1), vViewList.size());
CPPUNIT_ASSERT_EQUAL(u"bar2"_ustr, vViewList[0]); // 1 document goes to ForceNew list: bar3
CPPUNIT_ASSERT_EQUAL(decltype(vForceNewList.size())(1), vForceNewList.size());
CPPUNIT_ASSERT_EQUAL(u"bar3"_ustr, vForceNewList[0]);
}
{ // 2. Test explicit open mode arguments. Office URI commands should have no effect
TestSupplier supplier{ u"--view"_ustr, u"ms-word:ofe|u|foo"_ustr, u"-o"_ustr, u"ms-word:ofv|u|bar"_ustr, u"ms-word:nft|u|baz"_ustr };
desktop::CommandLineArgs args(supplier); auto vViewList = args.GetViewList(); auto vForceOpenList = args.GetForceOpenList(); // 1 document goes to View list: foo
CPPUNIT_ASSERT_EQUAL(decltype(vViewList.size())(1), vViewList.size());
CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, vViewList[0]); // 2 documents go to ForceOpen list: bar, baz
CPPUNIT_ASSERT_EQUAL(decltype(vForceOpenList.size())(2), vForceOpenList.size());
CPPUNIT_ASSERT_EQUAL(u"bar"_ustr, vForceOpenList[0]);
CPPUNIT_ASSERT_EQUAL(u"baz"_ustr, vForceOpenList[1]);
}
{ // 3. Test encoded URLs
TestSupplier supplier{ u"foo"_ustr, u"ms-word:ofe%7Cu%7cbar1"_ustr, u"ms-word:ofv%7cu%7Cbar2"_ustr, u"ms-word:nft%7Cu%7cbar3"_ustr, u"baz"_ustr };
desktop::CommandLineArgs args(supplier); auto vOpenList = args.GetOpenList(); auto vForceOpenList = args.GetForceOpenList(); auto vViewList = args.GetViewList(); auto vForceNewList = args.GetForceNewList(); // 2 documents go to Open list: foo; baz
CPPUNIT_ASSERT_EQUAL(decltype(vOpenList.size())(2), vOpenList.size());
CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, vOpenList[0]);
CPPUNIT_ASSERT_EQUAL(u"baz"_ustr, vOpenList[1]); // 1 document goes to ForceOpen list: bar1
CPPUNIT_ASSERT_EQUAL(decltype(vForceOpenList.size())(1), vForceOpenList.size());
CPPUNIT_ASSERT_EQUAL(u"bar1"_ustr, vForceOpenList[0]); // 1 document goes to View list: bar2
CPPUNIT_ASSERT_EQUAL(decltype(vViewList.size())(1), vViewList.size());
CPPUNIT_ASSERT_EQUAL(u"bar2"_ustr, vViewList[0]); // 1 document goes to ForceNew list: bar3
CPPUNIT_ASSERT_EQUAL(decltype(vForceNewList.size())(1), vForceNewList.size());
CPPUNIT_ASSERT_EQUAL(u"bar3"_ustr, vForceNewList[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.