bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svl / source / items / ptitem.cxx
blobed228db34e8708be13b83e4b5841a086108085c7
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/ptitem.hxx>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/awt/Point.hpp>
24 #include <osl/diagnose.h>
25 #include <tools/stream.hxx>
26 #include <tools/mapunit.hxx>
28 #include <svl/poolitem.hxx>
29 #include <svl/memberid.h>
31 using namespace ::com::sun::star;
34 SfxPoolItem* SfxPointItem::CreateDefault() { return new SfxPointItem; }
37 SfxPointItem::SfxPointItem()
42 SfxPointItem::SfxPointItem( sal_uInt16 nW, const Point& rVal ) :
43 SfxPoolItem( nW ),
44 aVal( rVal )
49 bool SfxPointItem::GetPresentation
51 SfxItemPresentation /*ePresentation*/,
52 MapUnit /*eCoreMetric*/,
53 MapUnit /*ePresentationMetric*/,
54 OUString& rText,
55 const IntlWrapper&
56 ) const
58 rText = OUString::number(aVal.X()) + ", " + OUString::number(aVal.Y()) + ", ";
59 return true;
63 bool SfxPointItem::operator==( const SfxPoolItem& rItem ) const
65 assert(SfxPoolItem::operator==(rItem));
66 return static_cast<const SfxPointItem&>(rItem).aVal == aVal;
70 SfxPoolItem* SfxPointItem::Clone(SfxItemPool *) const
72 return new SfxPointItem( *this );
76 bool SfxPointItem::QueryValue( uno::Any& rVal,
77 sal_uInt8 nMemberId ) const
79 bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
80 awt::Point aTmp(aVal.X(), aVal.Y());
81 if( bConvert )
83 aTmp.X = convertTwipToMm100(aTmp.X);
84 aTmp.Y = convertTwipToMm100(aTmp.Y);
86 nMemberId &= ~CONVERT_TWIPS;
87 switch ( nMemberId )
89 case 0: rVal <<= aTmp; break;
90 case MID_X: rVal <<= aTmp.X; break;
91 case MID_Y: rVal <<= aTmp.Y; break;
92 default: OSL_FAIL("Wrong MemberId!"); return true;
95 return true;
99 bool SfxPointItem::PutValue( const uno::Any& rVal,
100 sal_uInt8 nMemberId )
102 bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
103 nMemberId &= ~CONVERT_TWIPS;
104 bool bRet = false;
105 awt::Point aValue;
106 sal_Int32 nVal = 0;
107 if ( !nMemberId )
109 bRet = ( rVal >>= aValue );
110 if( bConvert )
112 aValue.X = convertMm100ToTwip(aValue.X);
113 aValue.Y = convertMm100ToTwip(aValue.Y);
116 else
118 bRet = ( rVal >>= nVal );
119 if( bConvert )
120 nVal = convertMm100ToTwip( nVal );
123 if ( bRet )
125 switch ( nMemberId )
127 case 0: aVal.setX( aValue.X ); aVal.setY( aValue.Y ); break;
128 case MID_X: aVal.setX( nVal ); break;
129 case MID_Y: aVal.setY( nVal ); break;
130 default: OSL_FAIL("Wrong MemberId!"); return false;
134 return bRet;
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */