LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/dialogs - colrdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 39 0.0 %
Date: 2012-12-27 Functions: 0 7 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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <com/sun/star/awt/XWindow.hpp>
      22             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      23             : #include <com/sun/star/beans/XPropertyAccess.hpp>
      24             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      25             : 
      26             : #include <comphelper/processfactory.hxx>
      27             : 
      28             : #include <toolkit/helper/vclunohelper.hxx>
      29             : 
      30             : #include <svtools/colrdlg.hxx>
      31             : 
      32             : using rtl::OUString;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::lang;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::ui::dialogs;
      37             : 
      38             : // ---------------
      39             : // - ColorDialog -
      40             : // ---------------
      41             : 
      42           0 : SvColorDialog::SvColorDialog( Window* pWindow )
      43             : : mpParent( pWindow )
      44           0 : , meMode( svtools::ColorPickerMode_SELECT )
      45             : {
      46           0 : }
      47             : 
      48           0 : SvColorDialog::~SvColorDialog()
      49             : {
      50           0 : }
      51             : 
      52           0 : void SvColorDialog::SetColor( const Color& rColor )
      53             : {
      54           0 :     maColor = rColor;
      55           0 : }
      56             : 
      57             : // -----------------------------------------------------------------------
      58             : 
      59           0 : const Color& SvColorDialog::GetColor() const
      60             : {
      61           0 :     return maColor;
      62             : }
      63             : 
      64             : // -----------------------------------------------------------------------
      65             : 
      66           0 : void SvColorDialog::SetMode( sal_Int16 eMode )
      67             : {
      68           0 :     meMode = eMode;
      69           0 : }
      70             : 
      71             : // -----------------------------------------------------------------------
      72             : 
      73           0 : short SvColorDialog::Execute()
      74             : {
      75           0 :     short ret = 0;
      76             :     try
      77             :     {
      78           0 :         const OUString sColor( RTL_CONSTASCII_USTRINGPARAM( "Color" ) );
      79           0 :         Reference< XMultiServiceFactory > xSMGR( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
      80             : 
      81           0 :         Reference< com::sun::star::awt::XWindow > xParent( VCLUnoHelper::GetInterface( mpParent ) );
      82             : 
      83           0 :         Sequence< Any > args(1);
      84           0 :         args[0] = Any( xParent );
      85             : 
      86           0 :         Reference< XExecutableDialog > xDialog( xSMGR->createInstanceWithArguments(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.cui.ColorPicker")), args), UNO_QUERY_THROW );
      87           0 :         Reference< XPropertyAccess > xPropertyAccess( xDialog, UNO_QUERY_THROW );
      88             : 
      89           0 :         Sequence< PropertyValue > props( 2 );
      90           0 :         props[0].Name = sColor;
      91           0 :         props[0].Value <<= (sal_Int32) maColor.GetColor();
      92           0 :         props[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Mode" ) );
      93           0 :         props[1].Value <<= (sal_Int16) meMode;
      94             : 
      95           0 :         xPropertyAccess->setPropertyValues( props );
      96             : 
      97           0 :         ret = xDialog->execute();
      98             : 
      99           0 :         if( ret )
     100             :         {
     101           0 :             props = xPropertyAccess->getPropertyValues();
     102           0 :             for( sal_Int32 n = 0; n < props.getLength(); n++ )
     103             :             {
     104           0 :                 if( props[n].Name.equals( sColor ) )
     105             :                 {
     106           0 :                     sal_Int32 nColor = 0;
     107           0 :                     if( props[n].Value >>= nColor )
     108             :                     {
     109           0 :                         maColor.SetColor( nColor );
     110             :                     }
     111             : 
     112             :                 }
     113             :             }
     114           0 :         }
     115             :     }
     116           0 :     catch(Exception&)
     117             :     {
     118             :         OSL_ASSERT(false);
     119             :     }
     120             : 
     121           0 :     return ret;
     122             : }
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10