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 <svx/grfcrop.hxx>
21 #include <editeng/itemtype.hxx>
22 #include <com/sun/star/text/GraphicCrop.hpp>
23 #include <tools/mapunit.hxx>
24 #include <tools/UnitConversion.hxx>
26 using namespace ::com::sun::star
;
28 SvxGrfCrop::SvxGrfCrop( TypedWhichId
<SvxGrfCrop
> nItemId
)
29 : SfxPoolItem( nItemId
),
30 nLeft( 0 ), nRight( 0 ), nTop( 0 ), nBottom( 0 )
33 SvxGrfCrop::SvxGrfCrop( sal_Int32 nL
, sal_Int32 nR
,
34 sal_Int32 nT
, sal_Int32 nB
, TypedWhichId
<SvxGrfCrop
> nItemId
)
35 : SfxPoolItem( nItemId
),
36 nLeft( nL
), nRight( nR
), nTop( nT
), nBottom( nB
)
39 SvxGrfCrop::~SvxGrfCrop()
43 bool SvxGrfCrop::operator==( const SfxPoolItem
& rAttr
) const
45 assert(SfxPoolItem::operator==(rAttr
));
47 const SvxGrfCrop
& rCrop
= static_cast<const SvxGrfCrop
&>(rAttr
);
48 return nLeft
== rCrop
.GetLeft() &&
49 nRight
== rCrop
.GetRight() &&
50 nTop
== rCrop
.GetTop() &&
51 nBottom
== rCrop
.GetBottom();
55 bool SvxGrfCrop::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
57 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
58 text::GraphicCrop aRet
;
62 aRet
.Bottom
= nBottom
;
66 aRet
.Right
= convertTwipToMm100(aRet
.Right
);
67 aRet
.Top
= convertTwipToMm100(aRet
.Top
);
68 aRet
.Left
= convertTwipToMm100(aRet
.Left
);
69 aRet
.Bottom
= convertTwipToMm100(aRet
.Bottom
);
77 bool SvxGrfCrop::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
79 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
80 text::GraphicCrop aVal
;
86 aVal
.Right
= o3tl::toTwips(aVal
.Right
, o3tl::Length::mm100
);
87 aVal
.Top
= o3tl::toTwips(aVal
.Top
, o3tl::Length::mm100
);
88 aVal
.Left
= o3tl::toTwips(aVal
.Left
, o3tl::Length::mm100
);
89 aVal
.Bottom
= o3tl::toTwips(aVal
.Bottom
, o3tl::Length::mm100
);
95 nBottom
= aVal
.Bottom
;
99 bool SvxGrfCrop::GetPresentation(
100 SfxItemPresentation ePres
, MapUnit eCoreUnit
, MapUnit
/*ePresUnit*/,
101 OUString
&rText
, const IntlWrapper
& rIntl
) const
106 case SfxItemPresentation::Nameless
:
108 case SfxItemPresentation::Complete
:
109 rText
= "L: " + ::GetMetricText( GetLeft(), eCoreUnit
, MapUnit::MapMM
, &rIntl
) +
110 " R: " + ::GetMetricText( GetRight(), eCoreUnit
, MapUnit::MapMM
, &rIntl
) +
111 " T: " + ::GetMetricText( GetTop(), eCoreUnit
, MapUnit::MapMM
, &rIntl
) +
112 " B: " + ::GetMetricText( GetBottom(), eCoreUnit
, MapUnit::MapMM
, &rIntl
);
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */