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 2008 by Sun Microsystems, Inc.
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 "vbalistlevel.hxx"
29 : : #include <vbahelper/vbahelper.hxx>
30 : : #include <tools/diagnose_ex.h>
31 : : #include <com/sun/star/style/NumberingType.hpp>
32 : : #include <ooo/vba/word/WdListNumberStyle.hpp>
33 : : #include <ooo/vba/word/WdTrailingCharacter.hpp>
34 : : #include <com/sun/star/text/HoriOrientation.hpp>
35 : : #include <ooo/vba/word/WdListLevelAlignment.hpp>
36 : :
37 : : using namespace ::ooo::vba;
38 : : using namespace ::com::sun::star;
39 : :
40 [ # # ]: 0 : SwVbaListLevel::SwVbaListLevel( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, SwVbaListHelperRef pHelper, sal_Int32 nLevel ) throw ( uno::RuntimeException ) : SwVbaListLevel_BASE( rParent, rContext ), pListHelper( pHelper ), mnLevel( nLevel )
41 : : {
42 : 0 : }
43 : :
44 [ # # ]: 0 : SwVbaListLevel::~SwVbaListLevel()
45 : : {
46 [ # # ]: 0 : }
47 : :
48 : 0 : ::sal_Int32 SAL_CALL SwVbaListLevel::getAlignment() throw (uno::RuntimeException)
49 : : {
50 : 0 : sal_Int16 nAlignment = 0;
51 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Adjust") ) ) >>= nAlignment;
52 [ # # # # ]: 0 : switch( nAlignment )
53 : : {
54 : : case text::HoriOrientation::LEFT:
55 : : {
56 : 0 : nAlignment = word::WdListLevelAlignment::wdListLevelAlignLeft;
57 : 0 : break;
58 : : }
59 : : case text::HoriOrientation::RIGHT:
60 : : {
61 : 0 : nAlignment = word::WdListLevelAlignment::wdListLevelAlignRight;
62 : 0 : break;
63 : : }
64 : : case text::HoriOrientation::CENTER:
65 : : {
66 : 0 : nAlignment = word::WdListLevelAlignment::wdListLevelAlignCenter;
67 : 0 : break;
68 : : }
69 : : default:
70 : : {
71 [ # # ]: 0 : throw uno::RuntimeException();
72 : : }
73 : : }
74 : 0 : return nAlignment;
75 : : }
76 : :
77 : 0 : void SAL_CALL SwVbaListLevel::setAlignment( ::sal_Int32 _alignment ) throw (uno::RuntimeException)
78 : : {
79 : 0 : sal_Int16 nAlignment = text::HoriOrientation::LEFT;
80 [ # # # # ]: 0 : switch( _alignment )
81 : : {
82 : : case word::WdListLevelAlignment::wdListLevelAlignLeft:
83 : : {
84 : 0 : nAlignment = text::HoriOrientation::LEFT;
85 : 0 : break;
86 : : }
87 : : case word::WdListLevelAlignment::wdListLevelAlignRight:
88 : : {
89 : 0 : nAlignment = text::HoriOrientation::RIGHT;
90 : 0 : break;
91 : : }
92 : : case word::WdListLevelAlignment::wdListLevelAlignCenter:
93 : : {
94 : 0 : nAlignment = text::HoriOrientation::CENTER;
95 : 0 : break;
96 : : }
97 : : default:
98 : : {
99 [ # # ]: 0 : throw uno::RuntimeException();
100 : : }
101 : : }
102 [ # # ][ # # ]: 0 : pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Adjust") ), uno::makeAny( nAlignment ) );
[ # # ]
103 : 0 : }
104 : :
105 : 0 : uno::Reference< ::ooo::vba::word::XFont > SAL_CALL SwVbaListLevel::getFont() throw (uno::RuntimeException)
106 : : {
107 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
108 : : }
109 : :
110 : 0 : void SAL_CALL SwVbaListLevel::setFont( const uno::Reference< ::ooo::vba::word::XFont >& /*_font*/ ) throw (uno::RuntimeException)
111 : : {
112 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
113 : : }
114 : :
115 : 0 : ::sal_Int32 SAL_CALL SwVbaListLevel::getIndex() throw (uno::RuntimeException)
116 : : {
117 : 0 : return mnLevel + 1;
118 : : }
119 : :
120 : 0 : ::rtl::OUString SAL_CALL SwVbaListLevel::getLinkedStyle() throw (uno::RuntimeException)
121 : : {
122 : : // TODO:
123 : 0 : return rtl::OUString();
124 : : }
125 : :
126 : 0 : void SAL_CALL SwVbaListLevel::setLinkedStyle( const ::rtl::OUString& /*_linkedstyle*/ ) throw (uno::RuntimeException)
127 : : {
128 : : // TODO:
129 : 0 : }
130 : :
131 : 0 : ::rtl::OUString SAL_CALL SwVbaListLevel::getNumberFormat() throw (uno::RuntimeException)
132 : : {
133 : : // TODO::
134 : 0 : return rtl::OUString();
135 : : }
136 : :
137 : 0 : void SAL_CALL SwVbaListLevel::setNumberFormat( const ::rtl::OUString& /*_numberformat*/ ) throw (uno::RuntimeException)
138 : : {
139 : : // TODO::
140 : 0 : }
141 : :
142 : 0 : float SAL_CALL SwVbaListLevel::getNumberPosition() throw (uno::RuntimeException)
143 : : {
144 : : // indentAt + firstlineindent
145 : 0 : sal_Int32 nIndentAt = 0;
146 : 0 : sal_Int32 nFirstLineIndent = 0;
147 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt;
148 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ) ) >>= nFirstLineIndent;
149 : :
150 : 0 : sal_Int32 nResult = nIndentAt + nFirstLineIndent;
151 : :
152 [ # # ]: 0 : return static_cast< float >( Millimeter::getInPoints( nResult ) );
153 : : }
154 : :
155 : 0 : void SAL_CALL SwVbaListLevel::setNumberPosition( float _numberposition ) throw (uno::RuntimeException)
156 : : {
157 [ # # ]: 0 : sal_Int32 nNumberPosition = Millimeter::getInHundredthsOfOneMillimeter( _numberposition );
158 : :
159 : 0 : sal_Int32 nIndentAt = 0;
160 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt;
161 : :
162 : 0 : sal_Int32 nFirstLineIndent = nNumberPosition - nIndentAt;
163 [ # # ][ # # ]: 0 : pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ), uno::makeAny( nFirstLineIndent ) );
[ # # ]
164 : 0 : }
165 : :
166 : 0 : ::sal_Int32 SAL_CALL SwVbaListLevel::getNumberStyle() throw (uno::RuntimeException)
167 : : {
168 : 0 : sal_Int16 nNumberingType = 0;
169 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingType") ) ) >>= nNumberingType;
170 [ # # # # : 0 : switch( nNumberingType )
# # # # #
# # ]
171 : : {
172 : : case style::NumberingType::CHAR_SPECIAL:
173 : : {
174 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleBullet;
175 : 0 : break;
176 : : }
177 : : case style::NumberingType::CHARS_UPPER_LETTER:
178 : : {
179 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleUppercaseLetter;
180 : 0 : break;
181 : : }
182 : : case style::NumberingType::CHARS_LOWER_LETTER:
183 : : {
184 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleLowercaseLetter;
185 : 0 : break;
186 : : }
187 : : case style::NumberingType::ROMAN_UPPER:
188 : : {
189 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleUppercaseRoman;
190 : 0 : break;
191 : : }
192 : : case style::NumberingType::ROMAN_LOWER:
193 : : {
194 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleLowercaseRoman;
195 : 0 : break;
196 : : }
197 : : case style::NumberingType::ARABIC:
198 : : {
199 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleArabic;
200 : 0 : break;
201 : : }
202 : : case style::NumberingType::NUMBER_NONE:
203 : : {
204 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleNone;
205 : 0 : break;
206 : : }
207 : : case style::NumberingType::FULLWIDTH_ARABIC:
208 : : {
209 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleArabicFullWidth;
210 : 0 : break;
211 : : }
212 : : case style::NumberingType::CIRCLE_NUMBER:
213 : : {
214 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleNumberInCircle;
215 : 0 : break;
216 : : }
217 : : case style::NumberingType::CHARS_ARABIC:
218 : : {
219 : 0 : nNumberingType = word::WdListNumberStyle::wdListNumberStyleCardinalText;
220 : 0 : break;
221 : : }
222 : : default:
223 : : {
224 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
225 : : }
226 : : }
227 : 0 : return nNumberingType;
228 : : }
229 : :
230 : 0 : void SAL_CALL SwVbaListLevel::setNumberStyle( ::sal_Int32 _numberstyle ) throw (uno::RuntimeException)
231 : : {
232 : 0 : sal_Int16 nNumberingType = 0;
233 [ # # # # : 0 : switch( _numberstyle )
# # # # #
# # # ]
234 : : {
235 : : case word::WdListNumberStyle::wdListNumberStyleBullet:
236 : : {
237 : 0 : nNumberingType = style::NumberingType::CHAR_SPECIAL;
238 : 0 : break;
239 : : }
240 : : case word::WdListNumberStyle::wdListNumberStyleUppercaseLetter:
241 : : {
242 : 0 : nNumberingType = style::NumberingType::CHARS_UPPER_LETTER_N;
243 : 0 : break;
244 : : }
245 : : case word::WdListNumberStyle::wdListNumberStyleLowercaseLetter:
246 : : {
247 : 0 : nNumberingType = style::NumberingType::CHARS_LOWER_LETTER_N;
248 : 0 : break;
249 : : }
250 : : case word::WdListNumberStyle::wdListNumberStyleUppercaseRoman:
251 : : {
252 : 0 : nNumberingType = style::NumberingType::ROMAN_UPPER;
253 : 0 : break;
254 : : }
255 : : case word::WdListNumberStyle::wdListNumberStyleLowercaseRoman:
256 : : {
257 : 0 : nNumberingType = style::NumberingType::ROMAN_LOWER;
258 : 0 : break;
259 : : }
260 : : case word::WdListNumberStyle::wdListNumberStyleArabic:
261 : : {
262 : 0 : nNumberingType = style::NumberingType::ARABIC;
263 : 0 : break;
264 : : }
265 : : case word::WdListNumberStyle::wdListNumberStyleNone:
266 : : {
267 : 0 : nNumberingType = style::NumberingType::NUMBER_NONE;
268 : 0 : break;
269 : : }
270 : : case word::WdListNumberStyle::wdListNumberStyleArabicFullWidth:
271 : : {
272 : 0 : nNumberingType = style::NumberingType::FULLWIDTH_ARABIC;
273 : 0 : break;
274 : : }
275 : : case word::WdListNumberStyle::wdListNumberStyleNumberInCircle:
276 : : {
277 : 0 : nNumberingType = style::NumberingType::CIRCLE_NUMBER;
278 : 0 : break;
279 : : }
280 : : case word::WdListNumberStyle::wdListNumberStyleCardinalText:
281 : : {
282 : 0 : nNumberingType = style::NumberingType::CHARS_ARABIC;
283 : 0 : break;
284 : : }
285 : : case word::WdListNumberStyle::wdListNumberStyleOrdinal:
286 : : case word::WdListNumberStyle::wdListNumberStyleOrdinalText:
287 : : case word::WdListNumberStyle::wdListNumberStyleKanji:
288 : : case word::WdListNumberStyle::wdListNumberStyleKanjiDigit:
289 : : case word::WdListNumberStyle::wdListNumberStyleAiueoHalfWidth:
290 : : case word::WdListNumberStyle::wdListNumberStyleIrohaHalfWidth:
291 : : {
292 : 0 : nNumberingType = style::NumberingType::ARABIC;
293 : 0 : break;
294 : : }
295 : : default:
296 : : {
297 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
298 : : }
299 : : }
300 : :
301 [ # # ][ # # ]: 0 : pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingType") ), uno::makeAny( nNumberingType ) );
[ # # ]
302 : 0 : }
303 : :
304 : 0 : ::sal_Int32 SAL_CALL SwVbaListLevel::getResetOnHigher() throw (uno::RuntimeException)
305 : : {
306 : : //seems not support?
307 : 0 : return 0;
308 : : }
309 : :
310 : 0 : void SAL_CALL SwVbaListLevel::setResetOnHigher( ::sal_Int32 /*_resetonhigher*/ ) throw (uno::RuntimeException)
311 : : {
312 : : //seems not support?
313 : 0 : }
314 : :
315 : 0 : ::sal_Int32 SAL_CALL SwVbaListLevel::getStartAt() throw (uno::RuntimeException)
316 : : {
317 : 0 : sal_Int16 nStartWith = 0;
318 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StartWith") ) ) >>= nStartWith;
319 : 0 : return nStartWith;
320 : : }
321 : :
322 : 0 : void SAL_CALL SwVbaListLevel::setStartAt( ::sal_Int32 _startat ) throw (uno::RuntimeException)
323 : : {
324 : 0 : sal_Int16 nStartWith = (sal_Int16)_startat;
325 [ # # ][ # # ]: 0 : pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StartWith") ), uno::makeAny( nStartWith ) );
[ # # ]
326 : 0 : }
327 : :
328 : 0 : float SAL_CALL SwVbaListLevel::getTabPosition() throw (uno::RuntimeException)
329 : : {
330 : 0 : sal_Int32 nTabPosition = 0;
331 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ListtabStopPosition") ) ) >>= nTabPosition;
332 : :
333 [ # # ]: 0 : return static_cast< float >( Millimeter::getInPoints( nTabPosition ) );
334 : : }
335 : :
336 : 0 : void SAL_CALL SwVbaListLevel::setTabPosition( float _tabposition ) throw (uno::RuntimeException)
337 : : {
338 [ # # ]: 0 : sal_Int32 nTabPosition = Millimeter::getInHundredthsOfOneMillimeter( _tabposition );
339 [ # # ][ # # ]: 0 : pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ListtabStopPosition") ), uno::makeAny( nTabPosition ) );
[ # # ]
340 : 0 : }
341 : :
342 : 0 : float SAL_CALL SwVbaListLevel::getTextPosition() throw (uno::RuntimeException)
343 : : {
344 : : // indentAt
345 : 0 : sal_Int32 nIndentAt = 0;
346 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt;
347 : :
348 [ # # ]: 0 : return static_cast< float >( Millimeter::getInPoints( nIndentAt ) );
349 : : }
350 : :
351 : 0 : void SAL_CALL SwVbaListLevel::setTextPosition( float _textposition ) throw (uno::RuntimeException)
352 : : {
353 : 0 : sal_Int32 nIndentAt = 0;
354 : 0 : sal_Int32 nFirstLineIndent = 0;
355 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt;
356 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ) ) >>= nFirstLineIndent;
357 : :
358 : 0 : sal_Int32 nAlignedAt = nIndentAt + nFirstLineIndent;
359 : :
360 [ # # ]: 0 : nIndentAt = Millimeter::getInHundredthsOfOneMillimeter( _textposition );
361 : 0 : nFirstLineIndent = nAlignedAt - nIndentAt;
362 [ # # ][ # # ]: 0 : pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ), uno::makeAny( nIndentAt ) );
[ # # ]
363 [ # # ][ # # ]: 0 : pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ), uno::makeAny( nFirstLineIndent ) );
[ # # ]
364 : 0 : }
365 : :
366 : 0 : ::sal_Int32 SAL_CALL SwVbaListLevel::getTrailingCharacter() throw (uno::RuntimeException)
367 : : {
368 : 0 : sal_Int16 nLabelFollowedBy= 0;
369 [ # # ][ # # ]: 0 : pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LabelFollowedBy") ) ) >>= nLabelFollowedBy;
370 : :
371 : 0 : return nLabelFollowedBy;
372 : : }
373 : :
374 : 0 : void SAL_CALL SwVbaListLevel::setTrailingCharacter( ::sal_Int32 _trailingcharacter ) throw (uno::RuntimeException)
375 : : {
376 : 0 : sal_Int16 nLabelFollowedBy = (sal_Int16)_trailingcharacter;
377 [ # # ][ # # ]: 0 : pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LabelFollowedBy") ), uno::makeAny( nLabelFollowedBy ) );
[ # # ]
378 : 0 : }
379 : :
380 : : rtl::OUString
381 : 0 : SwVbaListLevel::getServiceImplName()
382 : : {
383 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaListLevel"));
384 : : }
385 : :
386 : : uno::Sequence< rtl::OUString >
387 : 0 : SwVbaListLevel::getServiceNames()
388 : : {
389 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
390 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
391 : : {
392 : 0 : aServiceNames.realloc( 1 );
393 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListLevel" ) );
394 : : }
395 : 0 : return aServiceNames;
396 : : }
397 : :
398 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|