1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/outdev.hxx>
21 #include <editeng/editrids.hrc>
22 #include <unotools/intlwrapper.hxx>
23 #include <unotools/localedatawrapper.hxx>
24 #include <editeng/itemtype.hxx>
25 #include <editeng/eerdll.hxx>
26 #include <rtl/ustrbuf.hxx>
30 OUString
GetMetricText( long nVal
, SfxMapUnit eSrcUnit
, SfxMapUnit eDestUnit
, const IntlWrapper
* pIntl
)
43 case SFX_MAPUNIT_100TH_MM
:
44 case SFX_MAPUNIT_10TH_MM
:
48 nRet
= (long)OutputDevice::LogicToLogic(
49 nVal
, (MapUnit
)eSrcUnit
, (MapUnit
)SFX_MAPUNIT_100TH_MM
);
53 case SFX_MAPUNIT_100TH_MM
: nRet
*= 1000; break;
54 case SFX_MAPUNIT_10TH_MM
: nRet
*= 100; break;
55 case SFX_MAPUNIT_MM
: nRet
*= 10; break;
56 default: ;//prevent warning
61 case SFX_MAPUNIT_1000TH_INCH
:
62 case SFX_MAPUNIT_100TH_INCH
:
63 case SFX_MAPUNIT_10TH_INCH
:
64 case SFX_MAPUNIT_INCH
:
66 nRet
= OutputDevice::LogicToLogic(
67 nVal
, (MapUnit
)eSrcUnit
, (MapUnit
)SFX_MAPUNIT_1000TH_INCH
);
71 case SFX_MAPUNIT_1000TH_INCH
: nRet
*= 1000; break;
72 case SFX_MAPUNIT_100TH_INCH
: nRet
*= 100; break;
73 case SFX_MAPUNIT_10TH_INCH
: nRet
*= 10; break;
74 default: ;//prevent warning
79 case SFX_MAPUNIT_POINT
:
80 case SFX_MAPUNIT_TWIP
:
81 case SFX_MAPUNIT_PIXEL
:
82 return OUString::number( (long)OutputDevice::LogicToLogic(
83 nVal
, (MapUnit
)eSrcUnit
, (MapUnit
)eDestUnit
));
86 OSL_FAIL( "not supported mapunit" );
90 if ( SFX_MAPUNIT_CM
== eDestUnit
|| SFX_MAPUNIT_INCH
== eDestUnit
)
92 sal_Int32 nMod
= nRet
% 10;
106 for( int nDigits
= 4; nDigits
; --nDigits
, nDiff
/= 10 )
111 sRet
.append(nRet
/ nDiff
);
116 sRet
.append(pIntl
->getLocaleData()->getNumDecimalSep());
128 return sRet
.makeStringAndClear();
133 OUString
GetSvxString( sal_uInt16 nId
)
135 return EE_RESSTR( nId
);
140 OUString
GetColorString( const Color
& rCol
)
145 RGB_COLORDATA( rCol
.GetRed(), rCol
.GetGreen(), rCol
.GetBlue() );
146 sal_uInt16 nColor
= 0;
148 static const ColorData aColAry
[] = {
149 COL_BLACK
, COL_BLUE
, COL_GREEN
, COL_CYAN
,
150 COL_RED
, COL_MAGENTA
, COL_BROWN
, COL_GRAY
,
151 COL_LIGHTGRAY
, COL_LIGHTBLUE
, COL_LIGHTGREEN
, COL_LIGHTCYAN
,
152 COL_LIGHTRED
, COL_LIGHTMAGENTA
, COL_YELLOW
, COL_WHITE
};
154 while ( nColor
< SAL_N_ELEMENTS(aColAry
) &&
155 aColAry
[nColor
] != nColData
)
160 if ( nColor
< SAL_N_ELEMENTS(aColAry
) )
161 sStr
= EE_RESSTR( RID_SVXITEMS_COLOR_BEGIN
+ nColor
+ 1 );
163 if ( sStr
.isEmpty() )
166 OUString::number( rCol
.GetRed() ) + OUString(cpDelim
) +
167 OUString::number( rCol
.GetGreen() ) + OUString(cpDelim
) +
168 OUString::number( rCol
.GetBlue() ) + ")";
175 sal_uInt16
GetMetricId( SfxMapUnit eUnit
)
177 sal_uInt16 nId
= RID_SVXITEMS_METRIC_MM
;
181 case SFX_MAPUNIT_100TH_MM
:
182 case SFX_MAPUNIT_10TH_MM
:
184 nId
= RID_SVXITEMS_METRIC_MM
;
188 nId
= RID_SVXITEMS_METRIC_CM
;
191 case SFX_MAPUNIT_1000TH_INCH
:
192 case SFX_MAPUNIT_100TH_INCH
:
193 case SFX_MAPUNIT_10TH_INCH
:
194 case SFX_MAPUNIT_INCH
:
195 nId
= RID_SVXITEMS_METRIC_INCH
;
198 case SFX_MAPUNIT_POINT
:
199 nId
= RID_SVXITEMS_METRIC_POINT
;
202 case SFX_MAPUNIT_TWIP
:
203 nId
= RID_SVXITEMS_METRIC_TWIP
;
206 case SFX_MAPUNIT_PIXEL
:
207 nId
= RID_SVXITEMS_METRIC_PIXEL
;
211 OSL_FAIL( "not supported mapunit" );
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */