summaryrefslogtreecommitdiff
path: root/vcl/source/uipreviewer
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-03-26 12:15:22 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-09-28 08:48:11 +0100
commit9543bbaecf980aecec3ee71a4305573866d411d1 (patch)
treeff061a703673a7406c04c906570015037e481046 /vcl/source/uipreviewer
parent3a714f042ccb4c565b8aef9f5f2d14def1c20d71 (diff)
bootstrap a ui-previewer for rendering GtkBuilder xml with vcl widgets
Diffstat (limited to 'vcl/source/uipreviewer')
-rw-r--r--vcl/source/uipreviewer/previewer.cxx66
1 files changed, 66 insertions, 0 deletions
diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx
new file mode 100644
index 000000000000..9b5fa912ed8c
--- /dev/null
+++ b/vcl/source/uipreviewer/previewer.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <ucbhelper/configurationkeys.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <vcl/builder.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/svapp.hxx>
+
+class UIPreviewApp : public Application
+{
+public:
+ virtual int Main();
+};
+
+using namespace com::sun::star;
+
+int UIPreviewApp::Main()
+{
+ std::vector<rtl::OUString> uifiles;
+ for (sal_uInt16 i = 0; i < GetCommandLineParamCount(); ++i)
+ uifiles.push_back(GetCommandLineParam(i));
+
+ if (uifiles.empty())
+ {
+ fprintf(stderr, "Usage: ui-previewer file.ui\n");
+ return EXIT_FAILURE;
+ }
+
+ uno::Reference<uno::XComponentContext> xContext =
+ cppu::defaultBootstrap_InitialComponentContext();
+ uno::Reference<lang::XMultiComponentFactory> xFactory =
+ xContext->getServiceManager();
+ uno::Reference<lang::XMultiServiceFactory> xSFactory =
+ uno::Reference<lang::XMultiServiceFactory> (xFactory, uno::UNO_QUERY_THROW);
+ comphelper::setProcessServiceFactory(xSFactory);
+
+ // Create UCB.
+ uno::Sequence< uno::Any > aArgs(2);
+ aArgs[ 0 ] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UCB_CONFIGURATION_KEY1_LOCAL));
+ aArgs[ 1 ] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UCB_CONFIGURATION_KEY2_OFFICE));
+ ::ucbhelper::ContentBroker::initialize(xSFactory, aArgs);
+
+ VclBuilder aBuilder(NULL, uifiles[0]);
+ Window *pWindow = aBuilder.get_widget_root();
+ Dialog *pDialog = dynamic_cast<Dialog*>(pWindow);
+ if (pDialog)
+ {
+ pDialog->Execute();
+ }
+ else
+ {
+ fprintf(stderr, "to-do: no toplevel dialog, make one\n");
+ }
+
+ ::ucbhelper::ContentBroker::deinitialize();
+
+ return EXIT_SUCCESS;
+}
+
+UIPreviewApp aApp;
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */