1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 #ifndef CHART2_REFERENCESIZEPROVIDER_HXX 28 #define CHART2_REFERENCESIZEPROVIDER_HXX 29 30 #include <com/sun/star/uno/Reference.hxx> 31 #include <com/sun/star/chart2/XChartDocument.hpp> 32 #include <com/sun/star/awt/Size.hpp> 33 #include "charttoolsdllapi.hxx" 34 35 namespace com { namespace sun { namespace star { 36 namespace chart2 { 37 class XTitle; 38 class XTitled; 39 } 40 }}} 41 42 // ---------------------------------------- 43 namespace chart 44 { 45 46 class OOO_DLLPUBLIC_CHARTTOOLS ReferenceSizeProvider 47 { 48 public: 49 50 enum AutoResizeState 51 { 52 AUTO_RESIZE_YES, 53 AUTO_RESIZE_NO, 54 AUTO_RESIZE_AMBIGUOUS, 55 AUTO_RESIZE_UNKNOWN 56 }; 57 58 ReferenceSizeProvider( 59 ::com::sun::star::awt::Size aPageSize, 60 const ::com::sun::star::uno::Reference< 61 ::com::sun::star::chart2::XChartDocument > & xChartDoc ); 62 63 ::com::sun::star::awt::Size getPageSize() const; 64 65 /** Retrieves the state auto-resize from all objects that support this 66 feature. If all objects return the same state, AUTO_RESIZE_YES or 67 AUTO_RESIZE_NO is returned. 68 69 If no object supporting the feature is found, AUTO_RESIZE_UNKNOWN is 70 returned. If there are multiple objects, some with state YES and some 71 with state NO, AUTO_RESIZE_AMBIGUOUS is returned. 72 */ 73 static AutoResizeState getAutoResizeState( 74 const ::com::sun::star::uno::Reference< 75 ::com::sun::star::chart2::XChartDocument > & xChartDoc ); 76 77 /** sets or resets the auto-resize at all objects that support this feature 78 for text to the opposite of the current setting. If the current state 79 is ambiguous, it is turned on. If the current state is unknown it stays 80 unknown. 81 */ 82 void toggleAutoResizeState(); 83 84 85 /** Sets the ReferencePageSize according to the internal settings of this 86 class at the XPropertySet, and the adapted font sizes if bAdaptFontSizes 87 is </sal_True>. 88 */ 89 SAL_DLLPRIVATE void setValuesAtPropertySet( 90 const ::com::sun::star::uno::Reference< 91 ::com::sun::star::beans::XPropertySet > & xProp, 92 bool bAdaptFontSizes = true ); 93 94 /** Sets the ReferencePageSize according to the internal settings of this 95 class at the XTitle, and the adapted font sizes at the contained 96 XFormattedStrings 97 */ 98 SAL_DLLPRIVATE void setValuesAtTitle( 99 const ::com::sun::star::uno::Reference< 100 ::com::sun::star::chart2::XTitle > & xTitle ); 101 102 /** Sets the internal value at all data series in the currently set model. 103 This is useful, if you have changed a chart-type and thus probably added 104 some new data series via model functionality. 105 */ 106 void setValuesAtAllDataSeries(); 107 108 private: 109 SAL_DLLPRIVATE bool useAutoScale() const; 110 111 /** sets the auto-resize at all objects that support this feature for text. 112 eNewState must be either AUTO_RESIZE_YES or AUTO_RESIZE_NO 113 */ 114 SAL_DLLPRIVATE void setAutoResizeState( AutoResizeState eNewState ); 115 116 /** Retrieves the auto-resize state from the given propertyset. The result 117 will be put into eInOutState. If you initialize eInOutState with 118 AUTO_RESIZE_UNKNOWN, you will get the actual state. If you pass any 119 other state, the result will be the accumulated state, 120 esp. AUTO_RESIZE_AMBIGUOUS, if the value was NO before, and is YES for 121 the current property set, or the other way round. 122 */ 123 SAL_DLLPRIVATE static void getAutoResizeFromPropSet( 124 const ::com::sun::star::uno::Reference< 125 ::com::sun::star::beans::XPropertySet > & xProp, 126 AutoResizeState & rInOutState ); 127 128 SAL_DLLPRIVATE void impl_setValuesAtTitled( 129 const ::com::sun::star::uno::Reference< 130 ::com::sun::star::chart2::XTitled > & xTitled ); 131 SAL_DLLPRIVATE static void impl_getAutoResizeFromTitled( 132 const ::com::sun::star::uno::Reference< 133 ::com::sun::star::chart2::XTitled > & xTitled, 134 AutoResizeState & rInOutState ); 135 136 ::com::sun::star::awt::Size m_aPageSize; 137 ::com::sun::star::uno::Reference< 138 ::com::sun::star::chart2::XChartDocument > m_xChartDoc; 139 bool m_bUseAutoScale; 140 }; 141 142 } // namespace chart 143 144 // CHART2_REFERENCESIZEPROVIDER_HXX 145 #endif 146