2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-15 17:28:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-17 13:43:51 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
#include <com/sun/star/awt/XWindow.hpp>
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertyAccess.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
|
2013-02-06 15:22:34 +02:00
|
|
|
#include <com/sun/star/cui/ColorPicker.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-08-15 17:16:28 +02:00
|
|
|
#include <svtools/colrdlg.hxx>
|
2015-03-09 14:29:30 +02:00
|
|
|
#include <vcl/window.hxx>
|
2006-06-19 19:59:12 +00:00
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
2006-06-19 19:59:12 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
// - ColorDialog -
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SvColorDialog::SvColorDialog( vcl::Window* pWindow )
|
2011-05-06 16:11:58 +02:00
|
|
|
: mpParent( pWindow )
|
|
|
|
, meMode( svtools::ColorPickerMode_SELECT )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-15 16:56:53 +01:00
|
|
|
SvColorDialog::~SvColorDialog()
|
|
|
|
{
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void SvColorDialog::SetColor( const Color& rColor )
|
|
|
|
{
|
|
|
|
maColor = rColor;
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
void SvColorDialog::SetMode( sal_Int16 eMode )
|
|
|
|
{
|
|
|
|
meMode = eMode;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
short SvColorDialog::Execute()
|
|
|
|
{
|
|
|
|
short ret = 0;
|
|
|
|
try
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-03-19 11:39:07 +01:00
|
|
|
const OUString sColor( "Color" );
|
2013-02-06 15:22:34 +02:00
|
|
|
Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
|
2011-05-06 16:11:58 +02:00
|
|
|
|
|
|
|
Reference< com::sun::star::awt::XWindow > xParent( VCLUnoHelper::GetInterface( mpParent ) );
|
|
|
|
|
2013-02-06 15:22:34 +02:00
|
|
|
Reference< XExecutableDialog > xDialog = com::sun::star::cui::ColorPicker::createWithParent(xContext, xParent);
|
2011-05-06 16:11:58 +02:00
|
|
|
Reference< XPropertyAccess > xPropertyAccess( xDialog, UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
Sequence< PropertyValue > props( 2 );
|
|
|
|
props[0].Name = sColor;
|
|
|
|
props[0].Value <<= (sal_Int32) maColor.GetColor();
|
2013-11-15 11:05:19 +02:00
|
|
|
props[1].Name = "Mode";
|
2011-05-06 16:11:58 +02:00
|
|
|
props[1].Value <<= (sal_Int16) meMode;
|
|
|
|
|
|
|
|
xPropertyAccess->setPropertyValues( props );
|
|
|
|
|
|
|
|
ret = xDialog->execute();
|
|
|
|
|
|
|
|
if( ret )
|
|
|
|
{
|
|
|
|
props = xPropertyAccess->getPropertyValues();
|
|
|
|
for( sal_Int32 n = 0; n < props.getLength(); n++ )
|
|
|
|
{
|
|
|
|
if( props[n].Name.equals( sColor ) )
|
|
|
|
{
|
|
|
|
sal_Int32 nColor = 0;
|
|
|
|
if( props[n].Value >>= nColor )
|
|
|
|
{
|
|
|
|
maColor.SetColor( nColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2011-05-06 16:11:58 +02:00
|
|
|
catch(Exception&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-05-06 16:11:58 +02:00
|
|
|
OSL_ASSERT(false);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2011-05-06 16:11:58 +02:00
|
|
|
return ret;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|