Bump for 3.6-28
[LibreOffice.git] / editeng / source / items / writingmodeitem.cxx
bloba552ec99097763f8051c0fc6dd9864f83ae5e05e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
33 #include <editeng/writingmodeitem.hxx>
34 #include <editeng/eerdll.hxx>
35 #include <editeng/editrids.hrc>
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::text;
41 TYPEINIT1_FACTORY(SvxWritingModeItem, SfxUInt16Item, new SvxWritingModeItem(com::sun::star::text::WritingMode_LR_TB, 0));
43 SvxWritingModeItem::SvxWritingModeItem( WritingMode eValue, sal_uInt16 _nWhich )
44 : SfxUInt16Item( _nWhich, (sal_uInt16)eValue )
48 SvxWritingModeItem::~SvxWritingModeItem()
52 int SvxWritingModeItem::operator==( const SfxPoolItem& rCmp ) const
54 DBG_ASSERT( SfxPoolItem::operator==(rCmp), "unequal types" );
56 return GetValue() == ((SvxWritingModeItem&)rCmp).GetValue();
59 SfxPoolItem* SvxWritingModeItem::Clone( SfxItemPool * ) const
61 return new SvxWritingModeItem( *this );
64 SfxPoolItem* SvxWritingModeItem::Create( SvStream & , sal_uInt16 ) const
66 OSL_FAIL("SvxWritingModeItem should not be streamed!");
67 return NULL;
70 SvStream& SvxWritingModeItem::Store( SvStream & rStrm, sal_uInt16 ) const
72 OSL_FAIL("SvxWritingModeItem should not be streamed!");
73 return rStrm;
76 sal_uInt16 SvxWritingModeItem::GetVersion( sal_uInt16 /*nFVer*/ ) const
78 return USHRT_MAX;
81 SfxItemPresentation SvxWritingModeItem::GetPresentation( SfxItemPresentation ePres,
82 SfxMapUnit /*eCoreMetric*/,
83 SfxMapUnit /*ePresMetric*/,
84 String &rText,
85 const IntlWrapper * ) const
87 SfxItemPresentation eRet = ePres;
88 switch( ePres )
90 case SFX_ITEM_PRESENTATION_NONE:
91 rText.Erase();
92 break;
94 case SFX_ITEM_PRESENTATION_NAMELESS:
95 case SFX_ITEM_PRESENTATION_COMPLETE:
96 rText = EE_RESSTR(RID_SVXITEMS_FRMDIR_BEGIN + GetValue());
97 break;
99 default:
100 eRet = SFX_ITEM_PRESENTATION_NONE;
102 return eRet;
105 bool SvxWritingModeItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
107 sal_Int32 nVal = 0;
108 bool bRet = ( rVal >>= nVal );
110 if( !bRet )
112 WritingMode eMode;
113 bRet = rVal >>= eMode;
115 if( bRet )
117 nVal = (sal_Int32)eMode;
121 if( bRet )
123 switch( nVal )
125 case WritingMode_LR_TB:
126 case WritingMode_RL_TB:
127 case WritingMode_TB_RL:
128 SetValue( (sal_uInt16)nVal );
129 bRet = true;
130 break;
131 default:
132 bRet = false;
133 break;
137 return bRet;
140 bool SvxWritingModeItem::QueryValue( com::sun::star::uno::Any& rVal,
141 sal_uInt8 ) const
143 rVal <<= (WritingMode)GetValue();
144 return true;
147 SvxWritingModeItem& SvxWritingModeItem::operator=( const SvxWritingModeItem& rItem )
149 SetValue( rItem.GetValue() );
150 return *this;
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */