Update ooo320-m1
[ooovba.git] / svx / source / items / writingmodeitem.cxx
blob35afd13291e817ab936b6788625e6683e1694ce0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: writingmodeitem.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
37 #include <svx/writingmodeitem.hxx>
38 #include <svx/dialmgr.hxx>
40 #ifndef _SVXITEMS_HRC
41 #include <svx/svxitems.hrc>
42 #endif
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::text;
47 // class SvxWritingModeItem -------------------------------------------------
49 TYPEINIT1_FACTORY(SvxWritingModeItem, SfxUInt16Item, new SvxWritingModeItem(com::sun::star::text::WritingMode_LR_TB, 0));
51 SvxWritingModeItem::SvxWritingModeItem( WritingMode eValue, USHORT _nWhich )
52 : SfxUInt16Item( _nWhich, (sal_uInt16)eValue )
56 SvxWritingModeItem::~SvxWritingModeItem()
60 int SvxWritingModeItem::operator==( const SfxPoolItem& rCmp ) const
62 DBG_ASSERT( SfxPoolItem::operator==(rCmp), "unequal types" );
64 return GetValue() == ((SvxWritingModeItem&)rCmp).GetValue();
67 SfxPoolItem* SvxWritingModeItem::Clone( SfxItemPool * ) const
69 return new SvxWritingModeItem( *this );
72 SfxPoolItem* SvxWritingModeItem::Create( SvStream & , USHORT ) const
74 DBG_ERROR("SvxWritingModeItem should not be streamed!");
75 return NULL;
78 SvStream& SvxWritingModeItem::Store( SvStream & rStrm, USHORT ) const
80 DBG_ERROR("SvxWritingModeItem should not be streamed!");
81 return rStrm;
84 USHORT SvxWritingModeItem::GetVersion( USHORT /*nFVer*/ ) const
86 return USHRT_MAX;
89 SfxItemPresentation SvxWritingModeItem::GetPresentation( SfxItemPresentation ePres,
90 SfxMapUnit /*eCoreMetric*/,
91 SfxMapUnit /*ePresMetric*/,
92 String &rText,
93 const IntlWrapper * ) const
95 SfxItemPresentation eRet = ePres;
96 switch( ePres )
98 case SFX_ITEM_PRESENTATION_NONE:
99 rText.Erase();
100 break;
102 case SFX_ITEM_PRESENTATION_NAMELESS:
103 case SFX_ITEM_PRESENTATION_COMPLETE:
104 rText = SVX_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN + GetValue() );
105 break;
107 default:
108 eRet = SFX_ITEM_PRESENTATION_NONE;
110 return eRet;
113 sal_Bool SvxWritingModeItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE )
115 sal_Int32 nVal = 0;
116 sal_Bool bRet = ( rVal >>= nVal );
118 if( !bRet )
120 WritingMode eMode;
121 bRet = rVal >>= eMode;
123 if( bRet )
125 nVal = (sal_Int32)eMode;
129 if( bRet )
131 switch( nVal )
133 case WritingMode_LR_TB:
134 case WritingMode_RL_TB:
135 case WritingMode_TB_RL:
136 SetValue( (sal_uInt16)nVal );
137 bRet = true;
138 break;
139 default:
140 bRet = false;
141 break;
145 return bRet;
148 sal_Bool SvxWritingModeItem::QueryValue( com::sun::star::uno::Any& rVal,
149 BYTE ) const
151 rVal <<= (WritingMode)GetValue();
152 return true;
155 SvxWritingModeItem& SvxWritingModeItem::operator=( const SvxWritingModeItem& rItem )
157 SetValue( rItem.GetValue() );
158 return *this;