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>
25 #include <tools/stream.hxx>
27 #include <svl/poolitem.hxx>
28 #include <svl/memberid.h>
31 SfxPoolItem
* SfxRectangleItem::CreateDefault() { return new SfxRectangleItem
; }
34 SfxRectangleItem::SfxRectangleItem()
39 SfxRectangleItem::SfxRectangleItem( sal_uInt16 nW
, const tools::Rectangle
& rVal
) :
46 bool SfxRectangleItem::GetPresentation
48 SfxItemPresentation
/*ePresentation*/,
49 MapUnit
/*eCoreMetric*/,
50 MapUnit
/*ePresentationMetric*/,
55 rText
= OUString::number(aVal
.Top()) + ", " +
56 OUString::number(aVal
.Left()) + ", " +
57 OUString::number(aVal
.Bottom()) + ", " +
58 OUString::number(aVal
.Right());
63 bool SfxRectangleItem::operator==( const SfxPoolItem
& rItem
) const
65 assert(SfxPoolItem::operator==(rItem
));
66 return static_cast<const SfxRectangleItem
&>(rItem
).aVal
== aVal
;
70 SfxPoolItem
* SfxRectangleItem::Clone(SfxItemPool
*) const
72 return new SfxRectangleItem( *this );
76 bool SfxRectangleItem::QueryValue( css::uno::Any
& rVal
,
77 sal_uInt8 nMemberId
) const
79 nMemberId
&= ~CONVERT_TWIPS
;
84 rVal
<<= css::awt::Rectangle( aVal
.getX(),
90 case MID_RECT_LEFT
: rVal
<<= aVal
.getX(); break;
91 case MID_RECT_RIGHT
: rVal
<<= aVal
.getY(); break;
92 case MID_WIDTH
: rVal
<<= aVal
.getWidth(); break;
93 case MID_HEIGHT
: rVal
<<= aVal
.getHeight(); break;
94 default: OSL_FAIL("Wrong MemberID!"); return false;
101 bool SfxRectangleItem::PutValue( const css::uno::Any
& rVal
,
102 sal_uInt8 nMemberId
)
105 nMemberId
&= ~CONVERT_TWIPS
;
106 css::awt::Rectangle aValue
;
109 bRet
= (rVal
>>= aValue
);
111 bRet
= (rVal
>>= nVal
);
118 aVal
.setX( aValue
.X
);
119 aVal
.setY( aValue
.Y
);
120 aVal
.setWidth( aValue
.Width
);
121 aVal
.setHeight( aValue
.Height
);
123 case MID_RECT_LEFT
: aVal
.setX( nVal
); break;
124 case MID_RECT_RIGHT
: aVal
.setY( nVal
); break;
125 case MID_WIDTH
: aVal
.setWidth( nVal
); break;
126 case MID_HEIGHT
: aVal
.setHeight( nVal
); break;
127 default: OSL_FAIL("Wrong MemberID!"); return false;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */