xref: /trunk/main/svx/source/items/rotmodit.cxx (revision f6e50924)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <tools/stream.hxx>
27 #include <com/sun/star/table/BorderLine.hpp>
28 #include <com/sun/star/table/CellVertJustify.hpp>
29 #include <com/sun/star/table/ShadowLocation.hpp>
30 #include <com/sun/star/table/TableBorder.hpp>
31 #include <com/sun/star/table/ShadowFormat.hpp>
32 #include <com/sun/star/table/CellRangeAddress.hpp>
33 #include <com/sun/star/table/CellContentType.hpp>
34 #include <com/sun/star/table/TableOrientation.hpp>
35 #include <com/sun/star/table/CellHoriJustify.hpp>
36 #include <com/sun/star/util/SortField.hpp>
37 #include <com/sun/star/util/SortFieldType.hpp>
38 #include <com/sun/star/table/CellOrientation.hpp>
39 #include <com/sun/star/table/CellAddress.hpp>
40 
41 #include "svx/rotmodit.hxx"
42 
43 using namespace ::rtl;
44 using namespace ::com::sun::star;
45 
46 // STATIC DATA -----------------------------------------------------------
47 
48 TYPEINIT1_FACTORY(SvxRotateModeItem, SfxEnumItem, new SvxRotateModeItem(SVX_ROTATE_MODE_STANDARD, 0));
49 
50 
51 //-----------------------------------------------------------------------
52 //	SvxRotateModeItem - Ausrichtung bei gedrehtem Text
53 //-----------------------------------------------------------------------
54 
SvxRotateModeItem(SvxRotateMode eMode,sal_uInt16 _nWhich)55 SvxRotateModeItem::SvxRotateModeItem( SvxRotateMode eMode, sal_uInt16 _nWhich )
56     : SfxEnumItem( _nWhich, (sal_uInt16)eMode )
57 {
58 }
59 
SvxRotateModeItem(const SvxRotateModeItem & rItem)60 SvxRotateModeItem::SvxRotateModeItem( const SvxRotateModeItem& rItem )
61 	: SfxEnumItem( rItem )
62 {
63 }
64 
~SvxRotateModeItem()65 __EXPORT SvxRotateModeItem::~SvxRotateModeItem()
66 {
67 }
68 
Create(SvStream & rStream,sal_uInt16) const69 SfxPoolItem* __EXPORT SvxRotateModeItem::Create( SvStream& rStream, sal_uInt16 ) const
70 {
71 	sal_uInt16 nVal;
72 	rStream >> nVal;
73 	return new SvxRotateModeItem( (SvxRotateMode) nVal,Which() );
74 }
75 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,String & rText,const IntlWrapper *) const76 SfxItemPresentation __EXPORT SvxRotateModeItem::GetPresentation(
77 								SfxItemPresentation ePres,
78                                 SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
79                                 String& rText, const IntlWrapper * )  const
80 {
81 	rText.Erase();
82 
83 	switch ( ePres )
84 	{
85 		case SFX_ITEM_PRESENTATION_COMPLETE:
86 			rText.AppendAscii("...");
87 			rText.AppendAscii(": ");
88 //			break; // DURCHFALLEN!!!
89 
90 		case SFX_ITEM_PRESENTATION_NAMELESS:
91 			rText += UniString::CreateFromInt32( GetValue() );
92 			break;
93         default: ;//prevent warning
94     }
95 
96 	return ePres;
97 }
98 
GetValueText(sal_uInt16 nVal) const99 String __EXPORT SvxRotateModeItem::GetValueText( sal_uInt16 nVal ) const
100 {
101 	String aText;
102 
103 	switch ( nVal )
104 	{
105 		case SVX_ROTATE_MODE_STANDARD:
106 		case SVX_ROTATE_MODE_TOP:
107 		case SVX_ROTATE_MODE_CENTER:
108 		case SVX_ROTATE_MODE_BOTTOM:
109 			aText.AppendAscii("...");
110 			break;
111 		default:
112 			DBG_ERROR("SvxRotateModeItem: falscher enum");
113 			break;
114 	}
115 	return aText;
116 }
117 
GetValueCount() const118 sal_uInt16 __EXPORT SvxRotateModeItem::GetValueCount() const
119 {
120 	return 4;		// STANDARD, TOP, CENTER, BOTTOM
121 }
122 
Clone(SfxItemPool *) const123 SfxPoolItem* __EXPORT SvxRotateModeItem::Clone( SfxItemPool* ) const
124 {
125 	return new SvxRotateModeItem( *this );
126 }
127 
GetVersion(sal_uInt16) const128 sal_uInt16 __EXPORT SvxRotateModeItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
129 {
130 	return 0;
131 }
132 
133 //	QueryValue/PutValue: Der ::com::sun::star::table::CellVertJustify enum wird mitbenutzt...
134 
QueryValue(uno::Any & rVal,sal_uInt8) const135 sal_Bool SvxRotateModeItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
136 {
137 	table::CellVertJustify eUno = table::CellVertJustify_STANDARD;
138 	switch ( (SvxRotateMode)GetValue() )
139 	{
140 		case SVX_ROTATE_MODE_STANDARD: eUno = table::CellVertJustify_STANDARD; break;
141 		case SVX_ROTATE_MODE_TOP:	   eUno = table::CellVertJustify_TOP;	  	break;
142 		case SVX_ROTATE_MODE_CENTER:   eUno = table::CellVertJustify_CENTER;	break;
143 		case SVX_ROTATE_MODE_BOTTOM:   eUno = table::CellVertJustify_BOTTOM;	break;
144 	}
145 	rVal <<= eUno;
146 	return sal_True;
147 }
148 
PutValue(const uno::Any & rVal,sal_uInt8)149 sal_Bool SvxRotateModeItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
150 {
151 	table::CellVertJustify eUno;
152 	if(!(rVal >>= eUno))
153 	{
154 		sal_Int32 nValue = 0;
155 		if(!(rVal >>= nValue))
156 			return sal_False;
157 		eUno = (table::CellVertJustify)nValue;
158 	}
159 
160 	SvxRotateMode eSvx = SVX_ROTATE_MODE_STANDARD;
161 	switch (eUno)
162 	{
163 		case table::CellVertJustify_STANDARD: eSvx = SVX_ROTATE_MODE_STANDARD; break;
164 		case table::CellVertJustify_TOP:	   eSvx = SVX_ROTATE_MODE_TOP;	  	break;
165 		case table::CellVertJustify_CENTER:   eSvx = SVX_ROTATE_MODE_CENTER;	break;
166 		case table::CellVertJustify_BOTTOM:   eSvx = SVX_ROTATE_MODE_BOTTOM;	break;
167         default: ;//prevent warning
168     }
169 	SetValue( (sal_uInt16)eSvx );
170 	return sal_True;
171 }
172 
173 
174 
175