LCOV - code coverage report
Current view: top level - vcl/source/uipreviewer - previewer.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 42 0.0 %
Date: 2014-11-03 Functions: 0 8 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 void Init() SAL_OVERRIDE;
      27             :     virtual int Main() SAL_OVERRIDE;
      28             : };
      29             : 
      30             : using namespace com::sun::star;
      31             : 
      32           0 : void UIPreviewApp::Init()
      33             : {
      34             :     uno::Reference<uno::XComponentContext> xContext =
      35           0 :         cppu::defaultBootstrap_InitialComponentContext();
      36             :     uno::Reference<lang::XMultiComponentFactory> xFactory =
      37           0 :         xContext->getServiceManager();
      38             :     uno::Reference<lang::XMultiServiceFactory> xSFactory =
      39           0 :         uno::Reference<lang::XMultiServiceFactory> (xFactory, uno::UNO_QUERY_THROW);
      40           0 :     comphelper::setProcessServiceFactory(xSFactory);
      41             : 
      42             :     // Create UCB (for backwards compatibility, in case some code still uses
      43             :     // plain createInstance w/o args directly to obtain an instance):
      44             :     ::ucb::UniversalContentBroker::create(
      45           0 :         comphelper::getProcessComponentContext() );
      46           0 : }
      47             : 
      48           0 : int UIPreviewApp::Main()
      49             : {
      50           0 :     std::vector<OUString> uifiles;
      51           0 :     for (sal_uInt16 i = 0; i < GetCommandLineParamCount(); ++i)
      52             :     {
      53           0 :         OUString aFileUrl;
      54           0 :         osl::File::getFileURLFromSystemPath(GetCommandLineParam(i), aFileUrl);
      55           0 :         uifiles.push_back(aFileUrl);
      56           0 :     }
      57             : 
      58           0 :     if (uifiles.empty())
      59             :     {
      60           0 :         fprintf(stderr, "Usage: ui-previewer file.ui\n");
      61           0 :         return EXIT_FAILURE;
      62             :     }
      63             : 
      64             :     // turn on tooltips
      65           0 :     Help::EnableQuickHelp();
      66             : 
      67           0 :     int nRet = EXIT_SUCCESS;
      68             : 
      69             :     try
      70             :     {
      71           0 :         Dialog *pDialog = new Dialog(DIALOG_NO_PARENT, WB_STDDIALOG | WB_SIZEABLE);
      72             : 
      73             :         {
      74           0 :             VclBuilder aBuilder(pDialog, OUString(), uifiles[0]);
      75           0 :             vcl::Window *pRoot = aBuilder.get_widget_root();
      76           0 :             Dialog *pRealDialog = dynamic_cast<Dialog*>(pRoot);
      77             : 
      78           0 :             if (!pRealDialog)
      79           0 :                 pRealDialog = pDialog;
      80             : 
      81           0 :             pRealDialog->SetText(OUString("LibreOffice ui-previewer"));
      82           0 :             pRealDialog->SetStyle(pDialog->GetStyle()|WB_CLOSEABLE);
      83             :             /*
      84             :                Force a new StateChangedType::INITSHOW for the edge case where pRoot
      85             :                is not a dialog or contents of a dialog, but instead a visible floating window
      86             :                which may have had initshow already done before it was given children
      87             :             */
      88           0 :             pRoot->Hide();
      89           0 :             pRoot->Show();
      90           0 :             pRealDialog->Execute();
      91             :         }
      92             : 
      93           0 :         delete pDialog;
      94             :     }
      95           0 :     catch (const uno::Exception &e)
      96             :     {
      97           0 :         fprintf(stderr, "fatal error: %s\n", OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr());
      98           0 :         nRet = EXIT_FAILURE;
      99             :     }
     100           0 :     catch (const std::exception &e)
     101             :     {
     102           0 :         fprintf(stderr, "fatal error: %s\n", e.what());
     103           0 :         nRet = EXIT_FAILURE;
     104             :     }
     105             : 
     106           0 :     return nRet;
     107             : }
     108             : 
     109           0 : void vclmain::createApplication()
     110             : {
     111           0 :     static UIPreviewApp aApp;
     112           0 : }
     113             : 
     114             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10