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/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
) :
49 bool SfxPointItem::GetPresentation
51 SfxItemPresentation
/*ePresentation*/,
52 MapUnit
/*eCoreMetric*/,
53 MapUnit
/*ePresentationMetric*/,
58 rText
= OUString::number(aVal
.X()) + ", " + OUString::number(aVal
.Y()) + ", ";
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());
83 aTmp
.X
= convertTwipToMm100(aTmp
.X
);
84 aTmp
.Y
= convertTwipToMm100(aTmp
.Y
);
86 nMemberId
&= ~CONVERT_TWIPS
;
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;
99 bool SfxPointItem::PutValue( const uno::Any
& rVal
,
100 sal_uInt8 nMemberId
)
102 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
103 nMemberId
&= ~CONVERT_TWIPS
;
109 bRet
= ( rVal
>>= aValue
);
112 aValue
.X
= convertMm100ToTwip(aValue
.X
);
113 aValue
.Y
= convertMm100ToTwip(aValue
.Y
);
118 bRet
= ( rVal
>>= nVal
);
120 nVal
= convertMm100ToTwip( nVal
);
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;
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */