LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/uipreviewer - previewer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 34 0.0 %
Date: 2012-12-27 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  */
       9             : 
      10             : #include <com/sun/star/lang/XComponent.hpp>
      11             : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      12             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      13             : #include <com/sun/star/ucb/UniversalContentBroker.hpp>
      14             : #include <comphelper/processfactory.hxx>
      15             : #include <cppuhelper/bootstrap.hxx>
      16             : #include <osl/file.hxx>
      17             : #include <vcl/builder.hxx>
      18             : #include <vcl/dialog.hxx>
      19             : #include <vcl/help.hxx>
      20             : #include <vcl/svapp.hxx>
      21             : #include <vcl/vclmain.hxx>
      22             : 
      23           0 : class UIPreviewApp : public Application
      24             : {
      25             : public:
      26             :     virtual int Main();
      27             : };
      28             : 
      29             : using namespace com::sun::star;
      30             : 
      31           0 : int UIPreviewApp::Main()
      32             : {
      33           0 :     std::vector<rtl::OUString> uifiles;
      34           0 :     for (sal_uInt16 i = 0; i < GetCommandLineParamCount(); ++i)
      35             :     {
      36           0 :         rtl::OUString aFileUrl;
      37           0 :         osl::File::getFileURLFromSystemPath(GetCommandLineParam(i), aFileUrl);
      38           0 :         uifiles.push_back(aFileUrl);
      39           0 :     }
      40             : 
      41           0 :     if (uifiles.empty())
      42             :     {
      43           0 :         fprintf(stderr, "Usage: ui-previewer file.ui\n");
      44           0 :         return EXIT_FAILURE;
      45             :     }
      46             : 
      47             :     uno::Reference<uno::XComponentContext> xContext =
      48           0 :         cppu::defaultBootstrap_InitialComponentContext();
      49             :     uno::Reference<lang::XMultiComponentFactory> xFactory =
      50           0 :         xContext->getServiceManager();
      51             :     uno::Reference<lang::XMultiServiceFactory> xSFactory =
      52           0 :         uno::Reference<lang::XMultiServiceFactory> (xFactory, uno::UNO_QUERY_THROW);
      53           0 :     comphelper::setProcessServiceFactory(xSFactory);
      54             : 
      55             :     // Create UCB (for backwards compatibility, in case some code still uses
      56             :     // plain createInstance w/o args directly to obtain an instance):
      57             :     ::ucb::UniversalContentBroker::create(
      58           0 :         comphelper::getProcessComponentContext() );
      59             : 
      60             :     // turn on tooltips
      61           0 :     Help::EnableQuickHelp();
      62             : 
      63             :     try
      64             :     {
      65           0 :         Dialog *pDialog = new Dialog(DIALOG_NO_PARENT, WB_STDDIALOG);
      66             : 
      67             :         {
      68           0 :             VclBuilder aBuilder(pDialog, rtl::OUString(), uifiles[0]);
      69           0 :             Dialog *pRealDialog = dynamic_cast<Dialog*>(aBuilder.get_widget_root());
      70             : 
      71           0 :             if (!pRealDialog)
      72           0 :                 pRealDialog = pDialog;
      73             : 
      74           0 :             if (pRealDialog)
      75             :             {
      76           0 :                 pRealDialog->SetText(rtl::OUString("LibreOffice ui-previewer"));
      77           0 :                 pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE);
      78           0 :                 pRealDialog->Execute();
      79           0 :             }
      80             :         }
      81             : 
      82           0 :         delete pDialog;
      83             :     }
      84           0 :     catch (const uno::Exception &e)
      85             :     {
      86           0 :         fprintf(stderr, "fatal error: %s\n", rtl::OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr());
      87             :     }
      88             : 
      89           0 :     return EXIT_SUCCESS;
      90             : }
      91             : 
      92           0 : void vclmain::createApplication()
      93             : {
      94           0 :     static UIPreviewApp aApp;
      95           0 : }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10