1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*190118d0SAndrew Rist  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19*190118d0SAndrew Rist  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx>
31cdf0e10cSrcweir #include <editeng/eerdll.hxx>
32cdf0e10cSrcweir #include <editeng/editrids.hrc>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using namespace ::com::sun::star::uno;
35cdf0e10cSrcweir using namespace ::com::sun::star::text;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir // class SvxWritingModeItem -------------------------------------------------
38cdf0e10cSrcweir 
39cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxWritingModeItem, SfxUInt16Item, new SvxWritingModeItem(com::sun::star::text::WritingMode_LR_TB, 0));
40cdf0e10cSrcweir 
SvxWritingModeItem(WritingMode eValue,sal_uInt16 _nWhich)41cdf0e10cSrcweir SvxWritingModeItem::SvxWritingModeItem( WritingMode eValue, sal_uInt16 _nWhich )
42cdf0e10cSrcweir     : SfxUInt16Item( _nWhich, (sal_uInt16)eValue )
43cdf0e10cSrcweir {
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
~SvxWritingModeItem()46cdf0e10cSrcweir SvxWritingModeItem::~SvxWritingModeItem()
47cdf0e10cSrcweir {
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rCmp) const50cdf0e10cSrcweir int SvxWritingModeItem::operator==( const SfxPoolItem& rCmp ) const
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	DBG_ASSERT( SfxPoolItem::operator==(rCmp), "unequal types" );
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	return GetValue() == ((SvxWritingModeItem&)rCmp).GetValue();
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
Clone(SfxItemPool *) const57cdf0e10cSrcweir SfxPoolItem* SvxWritingModeItem::Clone( SfxItemPool * ) const
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	return new SvxWritingModeItem( *this );
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
Create(SvStream &,sal_uInt16) const62cdf0e10cSrcweir SfxPoolItem* SvxWritingModeItem::Create( SvStream & , sal_uInt16  ) const
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	DBG_ERROR("SvxWritingModeItem should not be streamed!");
65cdf0e10cSrcweir 	return NULL;
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
Store(SvStream & rStrm,sal_uInt16) const68cdf0e10cSrcweir SvStream& SvxWritingModeItem::Store( SvStream & rStrm, sal_uInt16  ) const
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	DBG_ERROR("SvxWritingModeItem should not be streamed!");
71cdf0e10cSrcweir 	return rStrm;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
GetVersion(sal_uInt16) const74cdf0e10cSrcweir sal_uInt16 SvxWritingModeItem::GetVersion( sal_uInt16 /*nFVer*/ ) const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	return USHRT_MAX;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,String & rText,const IntlWrapper *) const79cdf0e10cSrcweir SfxItemPresentation SvxWritingModeItem::GetPresentation( SfxItemPresentation ePres,
80cdf0e10cSrcweir         SfxMapUnit /*eCoreMetric*/,
81cdf0e10cSrcweir         SfxMapUnit /*ePresMetric*/,
82cdf0e10cSrcweir         String &rText,
83cdf0e10cSrcweir         const IntlWrapper *  ) const
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	SfxItemPresentation eRet = ePres;
86cdf0e10cSrcweir     switch( ePres )
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir     case SFX_ITEM_PRESENTATION_NONE:
89cdf0e10cSrcweir         rText.Erase();
90cdf0e10cSrcweir 		break;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     case SFX_ITEM_PRESENTATION_NAMELESS:
93cdf0e10cSrcweir     case SFX_ITEM_PRESENTATION_COMPLETE:
94cdf0e10cSrcweir 		rText = String( EditResId( RID_SVXITEMS_FRMDIR_BEGIN + GetValue() ) );
95cdf0e10cSrcweir 		break;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	default:
98cdf0e10cSrcweir 		eRet = SFX_ITEM_PRESENTATION_NONE;
99cdf0e10cSrcweir     }
100cdf0e10cSrcweir     return eRet;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)103cdf0e10cSrcweir sal_Bool SvxWritingModeItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir     sal_Int32 nVal = 0;
106cdf0e10cSrcweir     sal_Bool bRet = ( rVal >>= nVal );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	if( !bRet )
109cdf0e10cSrcweir 	{
110cdf0e10cSrcweir 		WritingMode eMode;
111cdf0e10cSrcweir 		bRet = rVal >>= eMode;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		if( bRet )
114cdf0e10cSrcweir 		{
115cdf0e10cSrcweir 			nVal = (sal_Int32)eMode;
116cdf0e10cSrcweir 		}
117cdf0e10cSrcweir 	}
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     if( bRet )
120cdf0e10cSrcweir     {
121cdf0e10cSrcweir         switch( nVal )
122cdf0e10cSrcweir         {
123cdf0e10cSrcweir 			case WritingMode_LR_TB:
124cdf0e10cSrcweir 			case WritingMode_RL_TB:
125cdf0e10cSrcweir 			case WritingMode_TB_RL:
126cdf0e10cSrcweir 				SetValue( (sal_uInt16)nVal );
127cdf0e10cSrcweir 				bRet = true;
128cdf0e10cSrcweir                 break;
129cdf0e10cSrcweir             default:
130cdf0e10cSrcweir                 bRet = false;
131cdf0e10cSrcweir                 break;
132cdf0e10cSrcweir         }
133cdf0e10cSrcweir     }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	return bRet;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const138cdf0e10cSrcweir sal_Bool SvxWritingModeItem::QueryValue( com::sun::star::uno::Any& rVal,
139cdf0e10cSrcweir 											sal_uInt8 ) const
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	rVal <<= (WritingMode)GetValue();
142cdf0e10cSrcweir 	return true;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
operator =(const SvxWritingModeItem & rItem)145cdf0e10cSrcweir SvxWritingModeItem& SvxWritingModeItem::operator=( const SvxWritingModeItem& rItem )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	SetValue( rItem.GetValue() );
148cdf0e10cSrcweir 	return *this;
149cdf0e10cSrcweir }
150