bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svl / source / items / rectitem.cxx
blob170bf76db521ba880fac96d3966b4303a5e65360
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 ) :
40 SfxPoolItem( nW ),
41 aVal( rVal )
46 bool SfxRectangleItem::GetPresentation
48 SfxItemPresentation /*ePresentation*/,
49 MapUnit /*eCoreMetric*/,
50 MapUnit /*ePresentationMetric*/,
51 OUString& rText,
52 const IntlWrapper&
53 ) const
55 rText = OUString::number(aVal.Top()) + ", " +
56 OUString::number(aVal.Left()) + ", " +
57 OUString::number(aVal.Bottom()) + ", " +
58 OUString::number(aVal.Right());
59 return true;
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;
80 switch ( nMemberId )
82 case 0:
84 rVal <<= css::awt::Rectangle( aVal.getX(),
85 aVal.getY(),
86 aVal.getWidth(),
87 aVal.getHeight() );
88 break;
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;
97 return true;
101 bool SfxRectangleItem::PutValue( const css::uno::Any& rVal,
102 sal_uInt8 nMemberId )
104 bool bRet = false;
105 nMemberId &= ~CONVERT_TWIPS;
106 css::awt::Rectangle aValue;
107 sal_Int32 nVal = 0;
108 if ( !nMemberId )
109 bRet = (rVal >>= aValue);
110 else
111 bRet = (rVal >>= nVal);
113 if ( bRet )
115 switch ( nMemberId )
117 case 0:
118 aVal.setX( aValue.X );
119 aVal.setY( aValue.Y );
120 aVal.setWidth( aValue.Width );
121 aVal.setHeight( aValue.Height );
122 break;
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;
131 return bRet;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */