LibreOffice Module vbahelper (master) 1
vbapictureformat.cxx
Go to the documentation of this file.
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#include <utility>
20
21#include "vbapictureformat.hxx"
22
23using namespace ooo::vba;
24using namespace com::sun::star;
25
26ScVbaPictureFormat::ScVbaPictureFormat( const css::uno::Reference< ov::XHelperInterface >& xParent,
27 const css::uno::Reference< css::uno::XComponentContext >& xContext,
28 uno::Reference< drawing::XShape > xShape )
29 : ScVbaPictureFormat_BASE( xParent, xContext ), m_xShape(std::move( xShape ))
30{
31 m_xPropertySet.set( m_xShape, uno::UNO_QUERY_THROW );
32}
33
34void
35ScVbaPictureFormat::checkParameterRangeInDouble( double nRange, double nMin, double nMax )
36{
37 if( nRange < nMin )
38 {
39 throw uno::RuntimeException( "Parameter out of range, value is too small." );
40 }
41 if( nRange > nMax )
42 {
43 throw uno::RuntimeException( "Parameter out of range, value is too high." );
44 }
45}
46
47// Attributes
48double SAL_CALL
50{
51 sal_Int16 nLuminance = 0;
52 m_xPropertySet->getPropertyValue( "AdjustLuminance" ) >>= nLuminance;
53 double fBrightness = static_cast< double >( nLuminance );
54 fBrightness = ( fBrightness +100 ) / 200;
55 return fBrightness;
56}
57
58void SAL_CALL
60{
61 checkParameterRangeInDouble( _brightness, 0.0, 1.0 );
62 double fLuminance = _brightness * 200 - 100;
63 sal_Int16 nLuminance = static_cast< sal_Int16 >( fLuminance );
64 m_xPropertySet->setPropertyValue( "AdjustLuminance" , uno::Any( nLuminance ) );
65}
66
67double SAL_CALL
69{
70 sal_Int16 nContrast = 0;
71 m_xPropertySet->getPropertyValue( "AdjustContrast" ) >>= nContrast;
72 double fContrast = static_cast< double >( nContrast );
73 fContrast = ( fContrast + 100 ) / 200;
74 return fContrast;
75}
76
77void SAL_CALL
79{
80 checkParameterRangeInDouble( _contrast, 0.0, 1.0 );
81 double fContrast = _contrast * 200 - 100;
82 sal_Int16 nContrast = static_cast< sal_Int16 >( fContrast );
83 m_xPropertySet->setPropertyValue( "AdjustContrast" , uno::Any( nContrast ) );
84}
85
86
87// Methods
88void SAL_CALL
90{
91 double fBrightness = getBrightness();
92 fBrightness += increment;
93 if( fBrightness < 0 )
94 {
95 fBrightness = 0.0;
96 }
97 if( fBrightness > 1 )
98 {
99 fBrightness = 1;
100 }
101 setBrightness( fBrightness );
102}
103
104void SAL_CALL
106{
107 double nContrast = getContrast();
108 nContrast += increment;
109 if( nContrast < 0 )
110 {
111 nContrast = 0.0;
112 }
113 if( nContrast > 1 )
114 {
115 nContrast = 1.0;
116 }
117 setContrast( nContrast );
118}
119
120OUString
122{
123 return "ScVbaPictureFormat";
124}
125
126uno::Sequence< OUString >
128{
129 static uno::Sequence< OUString > const aServiceNames
130 {
131 "ooo.vba.msform.PictureFormat"
132 };
133 return aServiceNames;
134}
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::drawing::XShape > m_xShape
static void checkParameterRangeInDouble(double nRange, double nMin, double nMax)
ScVbaPictureFormat(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::drawing::XShape > xShape)
virtual double SAL_CALL getContrast() override
virtual double SAL_CALL getBrightness() override
virtual void SAL_CALL IncrementContrast(double increment) override
virtual OUString getServiceImplName() override
virtual void SAL_CALL setContrast(double _contrast) override
css::uno::Reference< css::beans::XPropertySet > m_xPropertySet
virtual void SAL_CALL IncrementBrightness(double increment) override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual void SAL_CALL setBrightness(double _brightness) override
Sequence< OUString > aServiceNames