1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef CHART2_REFERENCESIZEPROVIDER_HXX 24 #define CHART2_REFERENCESIZEPROVIDER_HXX 25 26 #include <com/sun/star/uno/Reference.hxx> 27 #include <com/sun/star/chart2/XChartDocument.hpp> 28 #include <com/sun/star/awt/Size.hpp> 29 #include "charttoolsdllapi.hxx" 30 31 namespace com { namespace sun { namespace star { 32 namespace chart2 { 33 class XTitle; 34 class XTitled; 35 } 36 }}} 37 38 // ---------------------------------------- 39 namespace chart 40 { 41 42 class OOO_DLLPUBLIC_CHARTTOOLS ReferenceSizeProvider 43 { 44 public: 45 46 enum AutoResizeState 47 { 48 AUTO_RESIZE_YES, 49 AUTO_RESIZE_NO, 50 AUTO_RESIZE_AMBIGUOUS, 51 AUTO_RESIZE_UNKNOWN 52 }; 53 54 ReferenceSizeProvider( 55 ::com::sun::star::awt::Size aPageSize, 56 const ::com::sun::star::uno::Reference< 57 ::com::sun::star::chart2::XChartDocument > & xChartDoc ); 58 59 ::com::sun::star::awt::Size getPageSize() const; 60 61 /** Retrieves the state auto-resize from all objects that support this 62 feature. If all objects return the same state, AUTO_RESIZE_YES or 63 AUTO_RESIZE_NO is returned. 64 65 If no object supporting the feature is found, AUTO_RESIZE_UNKNOWN is 66 returned. If there are multiple objects, some with state YES and some 67 with state NO, AUTO_RESIZE_AMBIGUOUS is returned. 68 */ 69 static AutoResizeState getAutoResizeState( 70 const ::com::sun::star::uno::Reference< 71 ::com::sun::star::chart2::XChartDocument > & xChartDoc ); 72 73 /** sets or resets the auto-resize at all objects that support this feature 74 for text to the opposite of the current setting. If the current state 75 is ambiguous, it is turned on. If the current state is unknown it stays 76 unknown. 77 */ 78 void toggleAutoResizeState(); 79 80 81 /** Sets the ReferencePageSize according to the internal settings of this 82 class at the XPropertySet, and the adapted font sizes if bAdaptFontSizes 83 is </sal_True>. 84 */ 85 SAL_DLLPRIVATE void setValuesAtPropertySet( 86 const ::com::sun::star::uno::Reference< 87 ::com::sun::star::beans::XPropertySet > & xProp, 88 bool bAdaptFontSizes = true ); 89 90 /** Sets the ReferencePageSize according to the internal settings of this 91 class at the XTitle, and the adapted font sizes at the contained 92 XFormattedStrings 93 */ 94 SAL_DLLPRIVATE void setValuesAtTitle( 95 const ::com::sun::star::uno::Reference< 96 ::com::sun::star::chart2::XTitle > & xTitle ); 97 98 /** Sets the internal value at all data series in the currently set model. 99 This is useful, if you have changed a chart-type and thus probably added 100 some new data series via model functionality. 101 */ 102 void setValuesAtAllDataSeries(); 103 104 private: 105 SAL_DLLPRIVATE bool useAutoScale() const; 106 107 /** sets the auto-resize at all objects that support this feature for text. 108 eNewState must be either AUTO_RESIZE_YES or AUTO_RESIZE_NO 109 */ 110 SAL_DLLPRIVATE void setAutoResizeState( AutoResizeState eNewState ); 111 112 /** Retrieves the auto-resize state from the given propertyset. The result 113 will be put into eInOutState. If you initialize eInOutState with 114 AUTO_RESIZE_UNKNOWN, you will get the actual state. If you pass any 115 other state, the result will be the accumulated state, 116 esp. AUTO_RESIZE_AMBIGUOUS, if the value was NO before, and is YES for 117 the current property set, or the other way round. 118 */ 119 SAL_DLLPRIVATE static void getAutoResizeFromPropSet( 120 const ::com::sun::star::uno::Reference< 121 ::com::sun::star::beans::XPropertySet > & xProp, 122 AutoResizeState & rInOutState ); 123 124 SAL_DLLPRIVATE void impl_setValuesAtTitled( 125 const ::com::sun::star::uno::Reference< 126 ::com::sun::star::chart2::XTitled > & xTitled ); 127 SAL_DLLPRIVATE static void impl_getAutoResizeFromTitled( 128 const ::com::sun::star::uno::Reference< 129 ::com::sun::star::chart2::XTitled > & xTitled, 130 AutoResizeState & rInOutState ); 131 132 ::com::sun::star::awt::Size m_aPageSize; 133 ::com::sun::star::uno::Reference< 134 ::com::sun::star::chart2::XChartDocument > m_xChartDoc; 135 bool m_bUseAutoScale; 136 }; 137 138 } // namespace chart 139 140 // CHART2_REFERENCESIZEPROVIDER_HXX 141 #endif 142