1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "RelativeSizeHelper.hxx"
36 using namespace ::com::sun::star::awt
;
37 using namespace ::com::sun::star::beans
;
38 using namespace ::std
;
40 using ::com::sun::star::uno::Reference
;
41 using ::com::sun::star::uno::makeAny
;
42 using ::com::sun::star::uno::Exception
;
43 using ::rtl::OUString
;
49 double RelativeSizeHelper::calculate(
51 const Size
& rOldReferenceSize
,
52 const Size
& rNewReferenceSize
)
54 if( rOldReferenceSize
.Width
<= 0 ||
55 rOldReferenceSize
.Height
<= 0 )
59 static_cast< double >( rNewReferenceSize
.Width
) / static_cast< double >( rOldReferenceSize
.Width
),
60 static_cast< double >( rNewReferenceSize
.Height
) / static_cast< double >( rOldReferenceSize
.Height
))
65 void RelativeSizeHelper::adaptFontSizes(
66 const Reference
< XPropertySet
> & xTargetProperties
,
67 const Size
& rOldReferenceSize
,
68 const Size
& rNewReferenceSize
)
70 if( ! xTargetProperties
.is())
73 float fFontHeight
= 0;
75 vector
< OUString
> aProperties
;
76 aProperties
.push_back( OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeight" )));
77 aProperties
.push_back( OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeightAsian" )));
78 aProperties
.push_back( OUString( RTL_CONSTASCII_USTRINGPARAM( "CharHeightComplex" )));
80 for( vector
< OUString
>::const_iterator aIt
= aProperties
.begin();
81 aIt
!= aProperties
.end(); ++aIt
)
85 if( xTargetProperties
->getPropertyValue( *aIt
) >>= fFontHeight
)
87 xTargetProperties
->setPropertyValue(
89 makeAny( static_cast< float >(
90 calculate( fFontHeight
, rOldReferenceSize
, rNewReferenceSize
))));
93 catch( const Exception
& ex
)
95 ASSERT_EXCEPTION( ex
);