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