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