attempt to fix macos jenkins hangs - part 3
[LibreOffice.git] / svl / source / items / rectitem.cxx
blobf6a5db309d4b2da7ea6320aa7a5b69df3aa5e6e2
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>
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 ) :
39 SfxPoolItem( nW ),
40 maVal( rVal )
45 bool SfxRectangleItem::GetPresentation
47 SfxItemPresentation /*ePresentation*/,
48 MapUnit /*eCoreMetric*/,
49 MapUnit /*ePresentationMetric*/,
50 OUString& rText,
51 const IntlWrapper&
52 ) const
54 rText = OUString::number(maVal.Top()) + ", " +
55 OUString::number(maVal.Left()) + ", " +
56 OUString::number(maVal.Bottom()) + ", " +
57 OUString::number(maVal.Right());
58 return true;
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;
77 switch ( nMemberId )
79 case 0:
81 rVal <<= css::awt::Rectangle( maVal.Left(),
82 maVal.Top(),
83 maVal.getOpenWidth(),
84 maVal.getOpenHeight() );
85 break;
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;
94 return true;
98 bool SfxRectangleItem::PutValue( const css::uno::Any& rVal,
99 sal_uInt8 nMemberId )
101 bool bRet = false;
102 nMemberId &= ~CONVERT_TWIPS;
103 css::awt::Rectangle aValue;
104 sal_Int32 nVal = 0;
105 if ( !nMemberId )
106 bRet = (rVal >>= aValue);
107 else
108 bRet = (rVal >>= nVal);
110 if ( bRet )
112 switch ( nMemberId )
114 case 0:
115 maVal.SetLeft( aValue.X );
116 maVal.SetTop( aValue.Y );
117 maVal.setWidth( aValue.Width );
118 maVal.setHeight( aValue.Height );
119 break;
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;
128 return bRet;
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */