Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _SVX_FWDTITEM_HXX
20 : #define _SVX_FWDTITEM_HXX
21 :
22 : #include <svl/poolitem.hxx>
23 :
24 :
25 : // class SvxFontWidthItem -----------------------------------------------
26 :
27 :
28 : /* [Description]
29 :
30 : This item describes the font width.
31 : */
32 :
33 0 : class SvxFontWidthItem : public SfxPoolItem
34 : {
35 : sal_uInt16 nWidth; // 0 = default
36 : sal_uInt16 nProp; // default 100%
37 : public:
38 : TYPEINFO();
39 :
40 : SvxFontWidthItem( const sal_uInt16 nSz /*= 0*/,
41 : const sal_uInt16 nPropWidth /*= 100*/,
42 : const sal_uInt16 nId );
43 :
44 : // "pure virtual Methods" from SfxPoolItem
45 : virtual int operator==( const SfxPoolItem& ) const;
46 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
47 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
48 :
49 : virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
50 : SfxMapUnit eCoreMetric,
51 : SfxMapUnit ePresMetric,
52 : OUString &rText, const IntlWrapper * = 0 ) const;
53 :
54 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
55 : virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
56 : virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion) const;
57 : virtual bool ScaleMetrics( long nMult, long nDiv );
58 : virtual bool HasMetrics() const;
59 :
60 : inline SvxFontWidthItem& operator=(const SvxFontWidthItem& rItem )
61 : {
62 : SetWidthValue( rItem.GetWidth() );
63 : SetProp( rItem.GetProp() );
64 : return *this;
65 : }
66 :
67 : void SetWidth( sal_uInt16 nNewWidth, const sal_uInt16 nNewProp = 100 )
68 : {
69 : DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
70 : nWidth = sal_uInt16(( (sal_uInt32)nNewWidth * nNewProp ) / 100 );
71 : nProp = nNewProp;
72 : }
73 :
74 0 : sal_uInt16 GetWidth() const { return nWidth; }
75 :
76 0 : void SetWidthValue( sal_uInt16 nNewWidth )
77 : {
78 : DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
79 0 : nWidth = nNewWidth;
80 0 : }
81 :
82 : void SetProp( const sal_uInt16 nNewProp )
83 : {
84 : DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
85 : nProp = nNewProp;
86 : }
87 :
88 0 : sal_uInt16 GetProp() const { return nProp; }
89 : };
90 :
91 :
92 :
93 :
94 :
95 : #endif
96 :
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|