Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : : #include <com/sun/star/beans/XProperty.hpp>
29 : : #include <com/sun/star/awt/FontWeight.hpp>
30 : : #include <com/sun/star/awt/FontUnderline.hpp>
31 : : #include <com/sun/star/awt/FontStrikeout.hpp>
32 : : #include <com/sun/star/awt/FontSlant.hpp>
33 : : #include <com/sun/star/text/XSimpleText.hpp>
34 : : #include <com/sun/star/table/XCellRange.hpp>
35 : : #include <com/sun/star/table/XCell.hpp>
36 : : #include <com/sun/star/table/XColumnRowRange.hpp>
37 : : #include <ooo/vba/excel/XlColorIndex.hpp>
38 : : #include <ooo/vba/excel/XlUnderlineStyle.hpp>
39 : : #include <svl/itemset.hxx>
40 : : #include "excelvbahelper.hxx"
41 : : #include "vbafont.hxx"
42 : : #include "scitems.hxx"
43 : : #include "cellsuno.hxx"
44 : :
45 : : using namespace ::ooo::vba;
46 : : using namespace ::com::sun::star;
47 : :
48 : 0 : ScVbaFont::ScVbaFont(
49 : : const uno::Reference< XHelperInterface >& xParent,
50 : : const uno::Reference< uno::XComponentContext >& xContext,
51 : : const ScVbaPalette& dPalette,
52 : : const uno::Reference< beans::XPropertySet >& xPropertySet,
53 : : ScCellRangeObj* pRangeObj, bool bFormControl ) throw ( uno::RuntimeException ) :
54 : : ScVbaFont_BASE( xParent, xContext, dPalette.getPalette(), xPropertySet, bFormControl ),
55 : : mPalette( dPalette ),
56 [ # # ]: 0 : mpRangeObj( pRangeObj )
57 : : {
58 : 0 : }
59 : :
60 : : SfxItemSet*
61 : 0 : ScVbaFont::GetDataSet()
62 : : {
63 [ # # ]: 0 : return mpRangeObj ? excel::ScVbaCellRangeAccess::GetDataSet( mpRangeObj ) : 0;
64 : : }
65 : :
66 : 0 : ScVbaFont::~ScVbaFont()
67 : : {
68 [ # # ]: 0 : }
69 : :
70 : :
71 : 0 : uno::Reference< beans::XPropertySet > lcl_TextProperties( uno::Reference< table::XCell >& xIf ) throw ( uno::RuntimeException )
72 : : {
73 [ # # ]: 0 : uno::Reference< text::XTextRange > xTxtRange( xIf, uno::UNO_QUERY_THROW );
74 [ # # ][ # # ]: 0 : uno::Reference< text::XSimpleText > xTxt( xTxtRange->getText(), uno::UNO_QUERY_THROW ) ;
[ # # ]
75 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xTxt->createTextCursor(), uno::UNO_QUERY_THROW );
[ # # ]
76 : 0 : return xProps;
77 : : }
78 : : void SAL_CALL
79 : 0 : ScVbaFont::setSuperscript( const uno::Any& aValue ) throw ( uno::RuntimeException )
80 : : {
81 : : // #FIXEME create some sort of generic get/set code where
82 : : // you can pass a functor
83 : : // get/set - Super/sub script code is exactly the same
84 : : // except for the call applied at each cell position
85 [ # # ]: 0 : uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
86 [ # # ]: 0 : uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
87 [ # # ]: 0 : if ( !xCell.is() )
88 : : {
89 [ # # ]: 0 : uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
90 [ # # ][ # # ]: 0 : sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
[ # # ][ # # ]
91 [ # # ][ # # ]: 0 : sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
[ # # ][ # # ]
92 [ # # ]: 0 : for ( sal_Int32 col = 0; col < nCols; ++col )
93 : : {
94 [ # # ]: 0 : for ( sal_Int32 row = 0; row < nRows; ++row )
95 : : {
96 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW );
[ # # ]
97 [ # # ][ # # ]: 0 : ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
98 [ # # ]: 0 : aFont.setSuperscript( aValue );
99 [ # # ]: 0 : }
100 : : }
101 : 0 : return;
102 : :
103 : : }
104 [ # # ][ # # ]: 0 : xCell.set( xCellRange->getCellByPosition( 0,0 ) );
[ # # ]
105 : :
106 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
107 : 0 : sal_Bool bValue = false;
108 : 0 : aValue >>= bValue;
109 : 0 : sal_Int16 nValue = NORMAL;
110 : 0 : sal_Int8 nValue2 = NORMALHEIGHT;
111 : :
112 [ # # ]: 0 : if( bValue )
113 : : {
114 : 0 : nValue = SUPERSCRIPT;
115 : 0 : nValue2 = SUPERSCRIPTHEIGHT;
116 : : }
117 [ # # ][ # # ]: 0 : xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ), ( uno::Any )nValue );
[ # # ][ # # ]
118 [ # # ][ # # ]: 0 : xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapementHeight" ) ), ( uno::Any )nValue2 );
[ # # ][ # # ]
[ # # ][ # # ]
119 : : }
120 : :
121 : : uno::Any SAL_CALL
122 : 0 : ScVbaFont::getSuperscript() throw ( uno::RuntimeException )
123 : : {
124 [ # # ]: 0 : uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
125 [ # # ]: 0 : uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
126 [ # # ]: 0 : if ( !xCell.is() )
127 : : {
128 [ # # ]: 0 : uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
129 [ # # ][ # # ]: 0 : sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
[ # # ][ # # ]
130 [ # # ][ # # ]: 0 : sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
[ # # ][ # # ]
131 : 0 : uno::Any aRes;
132 [ # # ]: 0 : for ( sal_Int32 col = 0; col < nCols; ++col )
133 : : {
134 [ # # ]: 0 : for ( sal_Int32 row = 0; row < nRows; ++row )
135 : : {
136 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW );
[ # # ]
137 [ # # ][ # # ]: 0 : ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
138 [ # # ][ # # ]: 0 : if ( !col && !row )
139 [ # # ]: 0 : aRes = aFont.getSuperscript();
140 [ # # ][ # # ]: 0 : else if ( aRes != aFont.getSuperscript() )
141 [ # # ]: 0 : return aNULL();
142 [ # # ][ # # ]: 0 : }
[ # # ]
143 : : }
144 : 0 : return aRes;
145 : :
146 : : }
147 [ # # ][ # # ]: 0 : xCell.set( xCellRange->getCellByPosition( 0,0 ) );
[ # # ]
148 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
149 : 0 : short nValue = 0;
150 [ # # ][ # # ]: 0 : xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ) ) >>= nValue;
[ # # ]
151 [ # # ]: 0 : return uno::makeAny( ( nValue == SUPERSCRIPT ) );
152 : : }
153 : :
154 : : void SAL_CALL
155 : 0 : ScVbaFont::setSubscript( const uno::Any& aValue ) throw ( uno::RuntimeException )
156 : : {
157 [ # # ]: 0 : uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
158 [ # # ]: 0 : uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
159 [ # # ]: 0 : if ( !xCell.is() )
160 : : {
161 [ # # ]: 0 : uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
162 [ # # ][ # # ]: 0 : sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
[ # # ][ # # ]
163 [ # # ][ # # ]: 0 : sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
[ # # ][ # # ]
164 [ # # ]: 0 : for ( sal_Int32 col = 0; col < nCols; ++col )
165 : : {
166 [ # # ]: 0 : for ( sal_Int32 row = 0; row < nRows; ++row )
167 : : {
168 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW );
[ # # ]
169 [ # # ][ # # ]: 0 : ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
170 [ # # ]: 0 : aFont.setSubscript( aValue );
171 [ # # ]: 0 : }
172 : : }
173 : 0 : return;
174 : :
175 : : }
176 [ # # ][ # # ]: 0 : xCell.set( xCellRange->getCellByPosition( 0,0 ) );
[ # # ]
177 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
178 : :
179 : 0 : sal_Bool bValue = false;
180 : 0 : aValue >>= bValue;
181 : 0 : sal_Int16 nValue = NORMAL;
182 : 0 : sal_Int8 nValue2 = NORMALHEIGHT;
183 : :
184 [ # # ]: 0 : if( bValue )
185 : : {
186 : 0 : nValue= SUBSCRIPT;
187 : 0 : nValue2 = SUBSCRIPTHEIGHT;
188 : : }
189 : :
190 [ # # ][ # # ]: 0 : xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapementHeight" ) ), ( uno::Any )nValue2 );
[ # # ][ # # ]
191 [ # # ][ # # ]: 0 : xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ), ( uno::Any )nValue );
[ # # ][ # # ]
[ # # ][ # # ]
192 : :
193 : : }
194 : :
195 : : uno::Any SAL_CALL
196 : 0 : ScVbaFont::getSubscript() throw ( uno::RuntimeException )
197 : : {
198 [ # # ]: 0 : uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
199 [ # # ]: 0 : uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
200 [ # # ]: 0 : if ( !xCell.is() )
201 : : {
202 [ # # ]: 0 : uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
203 [ # # ][ # # ]: 0 : sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
[ # # ][ # # ]
204 [ # # ][ # # ]: 0 : sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
[ # # ][ # # ]
205 : 0 : uno::Any aRes;
206 [ # # ]: 0 : for ( sal_Int32 col = 0; col < nCols; ++col )
207 : : {
208 [ # # ]: 0 : for ( sal_Int32 row = 0; row < nRows; ++row )
209 : : {
210 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW );
[ # # ]
211 [ # # ][ # # ]: 0 : ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
212 [ # # ][ # # ]: 0 : if ( !col && !row )
213 [ # # ]: 0 : aRes = aFont.getSubscript();
214 [ # # ][ # # ]: 0 : else if ( aRes != aFont.getSubscript() )
215 [ # # ]: 0 : return aNULL();
216 [ # # ][ # # ]: 0 : }
[ # # ]
217 : : }
218 : 0 : return aRes;
219 : :
220 : : }
221 [ # # ][ # # ]: 0 : xCell.set( xCellRange->getCellByPosition( 0,0 ) );
[ # # ]
222 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
223 : :
224 : 0 : short nValue = NORMAL;
225 [ # # ][ # # ]: 0 : xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ) ) >>= nValue;
[ # # ]
226 [ # # ]: 0 : return uno::makeAny( ( nValue == SUBSCRIPT ) );
227 : : }
228 : :
229 : : uno::Any SAL_CALL
230 : 0 : ScVbaFont::getSize() throw ( uno::RuntimeException )
231 : : {
232 [ # # ]: 0 : if ( GetDataSet() )
233 [ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT_HEIGHT, sal_True, NULL) == SFX_ITEM_DONTCARE )
234 : 0 : return aNULL();
235 : 0 : return ScVbaFont_BASE::getSize();
236 : : }
237 : :
238 : : void SAL_CALL
239 : 0 : ScVbaFont::setColorIndex( const uno::Any& _colorindex ) throw( uno::RuntimeException )
240 : : {
241 : 0 : sal_Int32 nIndex = 0;
242 : 0 : _colorindex >>= nIndex;
243 : : // #FIXME xlColorIndexAutomatic & xlColorIndexNone are not really
244 : : // handled properly here
245 : :
246 [ # # ][ # # ]: 0 : if ( !nIndex || ( nIndex == excel::XlColorIndex::xlColorIndexAutomatic ) )
247 : : {
248 : 0 : nIndex = 1; // check defualt ( assume black )
249 [ # # ][ # # ]: 0 : ScVbaFont_BASE::setColorIndex( uno::makeAny( nIndex ) );
250 : : }
251 : : else
252 [ # # ]: 0 : ScVbaFont_BASE::setColorIndex( _colorindex );
253 : 0 : }
254 : :
255 : :
256 : : uno::Any SAL_CALL
257 : 0 : ScVbaFont::getColorIndex() throw ( uno::RuntimeException )
258 : : {
259 [ # # ]: 0 : if ( GetDataSet() )
260 [ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT_COLOR, sal_True, NULL) == SFX_ITEM_DONTCARE )
261 : 0 : return aNULL();
262 : 0 : return ScVbaFont_BASE::getColorIndex();
263 : : }
264 : :
265 : : //////////////////////////////////////////////////////////////////////////////////////////
266 : : void SAL_CALL
267 : 0 : ScVbaFont::setStandardFontSize( const uno::Any& /*aValue*/ ) throw( uno::RuntimeException )
268 : : {
269 : : //XXX #TODO# #FIXME#
270 : : //mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharSize" ) ), ( uno::Any )fValue );
271 : : throw uno::RuntimeException(
272 [ # # ][ # # ]: 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setStandardFontSize not supported") ), uno::Reference< uno::XInterface >() );
273 : : }
274 : :
275 : :
276 : : uno::Any SAL_CALL
277 : 0 : ScVbaFont::getStandardFontSize() throw ( uno::RuntimeException )
278 : : {
279 : : //XXX #TODO# #FIXME#
280 : : throw uno::RuntimeException(
281 [ # # ][ # # ]: 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getStandardFontSize not supported") ), uno::Reference< uno::XInterface >() );
282 : : // return uno::Any();
283 : : }
284 : :
285 : :
286 : : void SAL_CALL
287 : 0 : ScVbaFont::setStandardFont( const uno::Any& /*aValue*/ ) throw( uno::RuntimeException )
288 : : {
289 : : //XXX #TODO# #FIXME#
290 : : throw uno::RuntimeException(
291 [ # # ][ # # ]: 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setStandardFont not supported") ), uno::Reference< uno::XInterface >() );
292 : : }
293 : :
294 : :
295 : : uno::Any SAL_CALL
296 : 0 : ScVbaFont::getStandardFont() throw ( uno::RuntimeException )
297 : : {
298 : : //XXX #TODO# #FIXME#
299 : : throw uno::RuntimeException(
300 [ # # ][ # # ]: 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getStandardFont not supported") ), uno::Reference< uno::XInterface >() );
301 : : // return uno::Any();
302 : : }
303 : :
304 : : void SAL_CALL
305 : 0 : ScVbaFont::setFontStyle( const uno::Any& aValue ) throw( uno::RuntimeException )
306 : : {
307 : 0 : sal_Bool bBold = false;
308 : 0 : sal_Bool bItalic = false;
309 : :
310 : 0 : rtl::OUString aStyles;
311 : 0 : aValue >>= aStyles;
312 : :
313 [ # # ]: 0 : std::vector< rtl::OUString > aTokens;
314 : 0 : sal_Int32 nIndex = 0;
315 [ # # ]: 0 : do
316 : : {
317 : 0 : rtl::OUString aToken = aStyles.getToken( 0, ' ', nIndex );
318 [ # # ]: 0 : aTokens.push_back( aToken );
319 : : }while( nIndex >= 0 );
320 : :
321 : 0 : std::vector< rtl::OUString >::iterator it;
322 [ # # ][ # # ]: 0 : for( it = aTokens.begin(); it != aTokens.end(); ++it )
323 : : {
324 [ # # ]: 0 : if( (*it).equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("Bold")) )
325 : 0 : bBold = sal_True;
326 : :
327 [ # # ]: 0 : if( (*it).equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("Italic")) )
328 : 0 : bItalic = sal_True;
329 : : }
330 : :
331 [ # # ][ # # ]: 0 : setBold( uno::makeAny( bBold ) );
332 [ # # ][ # # ]: 0 : setItalic( uno::makeAny( bItalic ) );
333 : 0 : }
334 : :
335 : :
336 : : uno::Any SAL_CALL
337 : 0 : ScVbaFont::getFontStyle() throw ( uno::RuntimeException )
338 : : {
339 : 0 : rtl::OUStringBuffer aStyles;
340 : 0 : sal_Bool bValue = false;
341 [ # # ]: 0 : getBold() >>= bValue;
342 [ # # ]: 0 : if( bValue )
343 [ # # ]: 0 : aStyles.appendAscii("Bold");
344 : :
345 [ # # ]: 0 : getItalic() >>= bValue;
346 [ # # ]: 0 : if( bValue )
347 : : {
348 [ # # ]: 0 : if( aStyles.getLength() )
349 [ # # ]: 0 : aStyles.appendAscii(" ");
350 [ # # ]: 0 : aStyles.appendAscii("Italic");
351 : : }
352 [ # # ][ # # ]: 0 : return uno::makeAny( aStyles.makeStringAndClear() );
353 : : }
354 : :
355 : : uno::Any SAL_CALL
356 : 0 : ScVbaFont::getBold() throw ( uno::RuntimeException )
357 : : {
358 [ # # ]: 0 : if ( GetDataSet() )
359 [ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT_WEIGHT, sal_True, NULL) == SFX_ITEM_DONTCARE )
360 : 0 : return aNULL();
361 : 0 : return ScVbaFont_BASE::getBold();
362 : : }
363 : :
364 : : void SAL_CALL
365 : 0 : ScVbaFont::setUnderline( const uno::Any& aValue ) throw ( uno::RuntimeException )
366 : : {
367 : : // default
368 : 0 : sal_Int32 nValue = excel::XlUnderlineStyle::xlUnderlineStyleNone;
369 : 0 : aValue >>= nValue;
370 [ # # # # ]: 0 : switch ( nValue )
371 : : {
372 : : // NOTE:: #TODO #FIMXE
373 : : // xlUnderlineStyleDoubleAccounting & xlUnderlineStyleSingleAccounting
374 : : // don't seem to be supported in Openoffice.
375 : : // The import filter converts them to single or double underlines as appropriate
376 : : // So, here at the moment we are similarly silently converting
377 : : // xlUnderlineStyleSingleAccounting to xlUnderlineStyleSingle.
378 : :
379 : : case excel::XlUnderlineStyle::xlUnderlineStyleNone:
380 : 0 : nValue = awt::FontUnderline::NONE;
381 : 0 : break;
382 : : case excel::XlUnderlineStyle::xlUnderlineStyleSingle:
383 : : case excel::XlUnderlineStyle::xlUnderlineStyleSingleAccounting:
384 : 0 : nValue = awt::FontUnderline::SINGLE;
385 : 0 : break;
386 : : case excel::XlUnderlineStyle::xlUnderlineStyleDouble:
387 : : case excel::XlUnderlineStyle::xlUnderlineStyleDoubleAccounting:
388 : 0 : nValue = awt::FontUnderline::DOUBLE;
389 : 0 : break;
390 : : default:
391 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown value for Underline")), uno::Reference< uno::XInterface >() );
392 : : }
393 : :
394 [ # # ][ # # ]: 0 : mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" ) ), ( uno::Any )nValue );
[ # # ][ # # ]
395 : :
396 : 0 : }
397 : :
398 : : uno::Any SAL_CALL
399 : 0 : ScVbaFont::getUnderline() throw ( uno::RuntimeException )
400 : : {
401 [ # # ][ # # ]: 0 : if ( GetDataSet() )
402 [ # # ][ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT_UNDERLINE, sal_True, NULL) == SFX_ITEM_DONTCARE )
[ # # ]
403 [ # # ]: 0 : return aNULL();
404 : :
405 : 0 : sal_Int32 nValue = awt::FontUnderline::NONE;
406 [ # # ][ # # ]: 0 : mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" ) ) ) >>= nValue;
[ # # ]
407 [ # # # # ]: 0 : switch ( nValue )
408 : : {
409 : : case awt::FontUnderline::DOUBLE:
410 : 0 : nValue = excel::XlUnderlineStyle::xlUnderlineStyleDouble;
411 : 0 : break;
412 : : case awt::FontUnderline::SINGLE:
413 : 0 : nValue = excel::XlUnderlineStyle::xlUnderlineStyleSingle;
414 : 0 : break;
415 : : case awt::FontUnderline::NONE:
416 : 0 : nValue = excel::XlUnderlineStyle::xlUnderlineStyleNone;
417 : 0 : break;
418 : : default:
419 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown value retrieved for Underline") ), uno::Reference< uno::XInterface >() );
420 : :
421 : : }
422 [ # # ]: 0 : return uno::makeAny( nValue );
423 : : }
424 : :
425 : : uno::Any SAL_CALL
426 : 0 : ScVbaFont::getStrikethrough() throw ( uno::RuntimeException )
427 : : {
428 [ # # ]: 0 : if ( GetDataSet() )
429 [ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT_CROSSEDOUT, sal_True, NULL) == SFX_ITEM_DONTCARE )
430 : 0 : return aNULL();
431 : 0 : return ScVbaFont_BASE::getStrikethrough();
432 : : }
433 : :
434 : : uno::Any SAL_CALL
435 : 0 : ScVbaFont::getShadow() throw (uno::RuntimeException)
436 : : {
437 [ # # ]: 0 : if ( GetDataSet() )
438 [ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT_SHADOWED, sal_True, NULL) == SFX_ITEM_DONTCARE )
439 : 0 : return aNULL();
440 : 0 : return ScVbaFont_BASE::getShadow();
441 : : }
442 : :
443 : : uno::Any SAL_CALL
444 : 0 : ScVbaFont::getItalic() throw ( uno::RuntimeException )
445 : : {
446 [ # # ]: 0 : if ( GetDataSet() )
447 [ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT_POSTURE, sal_True, NULL) == SFX_ITEM_DONTCARE )
448 : 0 : return aNULL();
449 : :
450 : 0 : return ScVbaFont_BASE::getItalic();
451 : : }
452 : :
453 : : uno::Any SAL_CALL
454 : 0 : ScVbaFont::getName() throw ( uno::RuntimeException )
455 : : {
456 [ # # ]: 0 : if ( GetDataSet() )
457 [ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT, sal_True, NULL) == SFX_ITEM_DONTCARE )
458 : 0 : return aNULL();
459 : 0 : return ScVbaFont_BASE::getName();
460 : : }
461 : : uno::Any
462 : 0 : ScVbaFont::getColor() throw (uno::RuntimeException)
463 : : {
464 : : // #TODO #FIXME - behave like getXXX above ( wrt. GetDataSet )
465 : 0 : uno::Any aAny;
466 [ # # ][ # # ]: 0 : aAny = OORGBToXLRGB( mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) ) ) );
[ # # ][ # # ]
467 : 0 : return aAny;
468 : : }
469 : :
470 : : void SAL_CALL
471 : 0 : ScVbaFont::setOutlineFont( const uno::Any& aValue ) throw ( uno::RuntimeException )
472 : : {
473 [ # # ]: 0 : mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharContoured" ) ), aValue );
474 : 0 : }
475 : :
476 : : uno::Any SAL_CALL
477 : 0 : ScVbaFont::getOutlineFont() throw (uno::RuntimeException)
478 : : {
479 [ # # ]: 0 : if ( GetDataSet() )
480 [ # # ]: 0 : if ( GetDataSet()->GetItemState( ATTR_FONT_CONTOUR, sal_True, NULL) == SFX_ITEM_DONTCARE )
481 : 0 : return aNULL();
482 [ # # ]: 0 : return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharContoured" ) ) );
483 : : }
484 : :
485 : : rtl::OUString
486 : 0 : ScVbaFont::getServiceImplName()
487 : : {
488 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaFont"));
489 : : }
490 : :
491 : : uno::Sequence< rtl::OUString >
492 : 0 : ScVbaFont::getServiceNames()
493 : : {
494 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
495 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
496 : : {
497 : 0 : aServiceNames.realloc( 1 );
498 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Font" ) );
499 : : }
500 : 0 : return aServiceNames;
501 : : }
502 : :
503 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|