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 _SVT_UNITCONV_HXX 24 #define _SVT_UNITCONV_HXX 25 26 // include --------------------------------------------------------------- 27 #include <vcl/field.hxx> 28 #include "svtools/svtdllapi.h" 29 #include <svl/poolitem.hxx> 30 31 // macro ----------------------------------------------------------------- 32 33 // typedef --------------------------------------------------------------- 34 35 typedef long (*FUNC_CONVERT)(long); 36 37 // Functions ------------------------------------------------------------- 38 39 SVT_DLLPUBLIC void SetFieldUnit( MetricField& rCtrl, FieldUnit eUnit, sal_Bool bAll = sal_False ); 40 SVT_DLLPUBLIC void SetFieldUnit( MetricBox& rCtrl, FieldUnit eUnit, sal_Bool bAll = sal_False ); 41 42 SVT_DLLPUBLIC long CalcToUnit( float nIn, SfxMapUnit eUnit ); 43 SVT_DLLPUBLIC long CalcToPoint( long nIn, SfxMapUnit eUnit, sal_uInt16 nFaktor ); 44 45 SVT_DLLPUBLIC long ItemToControl( long nIn, SfxMapUnit eItem, SfxFieldUnit eCtrl ); 46 SVT_DLLPUBLIC long ControlToItem( long nIn, SfxFieldUnit eCtrl, SfxMapUnit eItem ); 47 48 SVT_DLLPUBLIC FieldUnit MapToFieldUnit( const SfxMapUnit eUnit ); 49 SVT_DLLPUBLIC MapUnit FieldToMapUnit( const SfxFieldUnit eUnit ); 50 51 SVT_DLLPUBLIC long ConvertValueToMap( long nVal, SfxMapUnit eUnit ); 52 SVT_DLLPUBLIC long ConvertValueToUnit( long nVal, SfxMapUnit eUnit ); 53 54 SVT_DLLPUBLIC void SetMetricValue( MetricField& rField, long lCoreValue, SfxMapUnit eUnit ); 55 SVT_DLLPUBLIC long GetCoreValue( const MetricField& rField, SfxMapUnit eUnit ); 56 57 SVT_DLLPUBLIC long PointToTwips( long nIn ); 58 59 #if 0 60 // to Twips 61 SVT_DLLPUBLIC long CMToTwips( long nIn ); 62 SVT_DLLPUBLIC long MMToTwips( long nIn ); 63 SVT_DLLPUBLIC long InchToTwips( long nIn ); 64 SVT_DLLPUBLIC long PicaToTwips( long nIn ); 65 66 // to CM 67 SVT_DLLPUBLIC long TwipsToCM( long nIn ); 68 SVT_DLLPUBLIC long InchToCM( long nIn ); 69 SVT_DLLPUBLIC long MMToCM( long nIn ); 70 SVT_DLLPUBLIC long PointToCM( long nIn ); 71 SVT_DLLPUBLIC long PicaToCM( long nIn ); 72 73 // to MM 74 SVT_DLLPUBLIC long TwipsToMM( long nIn ); 75 SVT_DLLPUBLIC long CMToMM( long nIn ); 76 SVT_DLLPUBLIC long InchToMM( long nIn ); 77 SVT_DLLPUBLIC long PointToMM( long nIn ); 78 SVT_DLLPUBLIC long PicaToMM( long nIn ); 79 80 // to Inch 81 SVT_DLLPUBLIC long TwipsToInch(long nIn ); 82 SVT_DLLPUBLIC long CMToInch(long nIn ); 83 SVT_DLLPUBLIC long MMToInch(long nIn ); 84 SVT_DLLPUBLIC long PointToInch(long nIn ); 85 SVT_DLLPUBLIC long PicaToInch(long nIn ); 86 87 // to Point 88 SVT_DLLPUBLIC long TwipsToPoint(long nIn ); 89 SVT_DLLPUBLIC long InchToPoint(long nIn ); 90 SVT_DLLPUBLIC long CMToPoint(long nIn ); 91 SVT_DLLPUBLIC long MMToPoint(long nIn ); 92 SVT_DLLPUBLIC long PicaToPoint(long nIn ); 93 94 // To Pica 95 long TwipsToPica(long nIn ); 96 long InchToPica(long nIn ); 97 long PointToPica(long nIn ); 98 long CMToPica(long nIn ); 99 long MMToPica(long nIn ); 100 101 #endif 102 103 SVT_DLLPUBLIC long TransformMetric( long nVal, FieldUnit aOld, FieldUnit aNew ); 104 105 #endif 106 107