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 .
21 #include <svl/rectitem.hxx>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/awt/Rectangle.hpp>
24 #include <osl/diagnose.h>
26 #include <svl/poolitem.hxx>
27 #include <svl/memberid.h>
30 SfxPoolItem
* SfxRectangleItem::CreateDefault() { return new SfxRectangleItem
; }
33 SfxRectangleItem::SfxRectangleItem()
38 SfxRectangleItem::SfxRectangleItem( sal_uInt16 nW
, const tools::Rectangle
& rVal
) :
45 bool SfxRectangleItem::GetPresentation
47 SfxItemPresentation
/*ePresentation*/,
48 MapUnit
/*eCoreMetric*/,
49 MapUnit
/*ePresentationMetric*/,
54 rText
= OUString::number(maVal
.Top()) + ", " +
55 OUString::number(maVal
.Left()) + ", " +
56 OUString::number(maVal
.Bottom()) + ", " +
57 OUString::number(maVal
.Right());
62 bool SfxRectangleItem::operator==( const SfxPoolItem
& rItem
) const
64 assert(SfxPoolItem::operator==(rItem
));
65 return static_cast<const SfxRectangleItem
&>(rItem
).maVal
== maVal
;
68 SfxRectangleItem
* SfxRectangleItem::Clone(SfxItemPool
*) const
70 return new SfxRectangleItem( *this );
73 bool SfxRectangleItem::QueryValue( css::uno::Any
& rVal
,
74 sal_uInt8 nMemberId
) const
76 nMemberId
&= ~CONVERT_TWIPS
;
81 rVal
<<= css::awt::Rectangle( maVal
.Left(),
84 maVal
.getOpenHeight() );
87 case MID_RECT_LEFT
: rVal
<<= maVal
.Left(); break;
88 case MID_RECT_RIGHT
: rVal
<<= maVal
.Top(); break;
89 case MID_WIDTH
: rVal
<<= maVal
.getOpenWidth(); break;
90 case MID_HEIGHT
: rVal
<<= maVal
.getOpenHeight(); break;
91 default: OSL_FAIL("Wrong MemberID!"); return false;
98 bool SfxRectangleItem::PutValue( const css::uno::Any
& rVal
,
102 nMemberId
&= ~CONVERT_TWIPS
;
103 css::awt::Rectangle aValue
;
106 bRet
= (rVal
>>= aValue
);
108 bRet
= (rVal
>>= nVal
);
115 maVal
.SetLeft( aValue
.X
);
116 maVal
.SetTop( aValue
.Y
);
117 maVal
.setWidth( aValue
.Width
);
118 maVal
.setHeight( aValue
.Height
);
120 case MID_RECT_LEFT
: maVal
.SetPosX( nVal
); break;
121 case MID_RECT_RIGHT
: maVal
.SetPosY( nVal
); break;
122 case MID_WIDTH
: maVal
.setWidth( nVal
); break;
123 case MID_HEIGHT
: maVal
.setHeight( nVal
); break;
124 default: OSL_FAIL("Wrong MemberID!"); return false;
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */