android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / vba / vbalistlevel.cxx
blob43f16e85243f31a5f21ec244092c3ee01089899f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "vbalistlevel.hxx"
20 #include <utility>
21 #include <vbahelper/vbahelper.hxx>
22 #include <com/sun/star/style/NumberingType.hpp>
23 #include <ooo/vba/word/WdListNumberStyle.hpp>
24 #include <com/sun/star/text/HoriOrientation.hpp>
25 #include <ooo/vba/word/WdListLevelAlignment.hpp>
27 using namespace ::ooo::vba;
28 using namespace ::com::sun::star;
30 SwVbaListLevel::SwVbaListLevel( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, SwVbaListHelperRef pHelper, sal_Int32 nLevel ) : SwVbaListLevel_BASE( rParent, rContext ), m_pListHelper(std::move( pHelper )), mnLevel( nLevel )
34 SwVbaListLevel::~SwVbaListLevel()
38 ::sal_Int32 SAL_CALL SwVbaListLevel::getAlignment()
40 sal_Int16 nAlignment = 0;
41 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "Adjust" ) >>= nAlignment;
42 switch( nAlignment )
44 case text::HoriOrientation::LEFT:
46 nAlignment = word::WdListLevelAlignment::wdListLevelAlignLeft;
47 break;
49 case text::HoriOrientation::RIGHT:
51 nAlignment = word::WdListLevelAlignment::wdListLevelAlignRight;
52 break;
54 case text::HoriOrientation::CENTER:
56 nAlignment = word::WdListLevelAlignment::wdListLevelAlignCenter;
57 break;
59 default:
61 throw uno::RuntimeException();
64 return nAlignment;
67 void SAL_CALL SwVbaListLevel::setAlignment( ::sal_Int32 _alignment )
69 sal_Int16 nAlignment = text::HoriOrientation::LEFT;
70 switch( _alignment )
72 case word::WdListLevelAlignment::wdListLevelAlignLeft:
74 nAlignment = text::HoriOrientation::LEFT;
75 break;
77 case word::WdListLevelAlignment::wdListLevelAlignRight:
79 nAlignment = text::HoriOrientation::RIGHT;
80 break;
82 case word::WdListLevelAlignment::wdListLevelAlignCenter:
84 nAlignment = text::HoriOrientation::CENTER;
85 break;
87 default:
89 throw uno::RuntimeException();
92 m_pListHelper->setPropertyValueWithNameAndLevel( mnLevel, "Adjust", uno::Any( nAlignment ) );
95 uno::Reference< ::ooo::vba::word::XFont > SAL_CALL SwVbaListLevel::getFont()
97 throw uno::RuntimeException("Not implemented" );
100 void SAL_CALL SwVbaListLevel::setFont( const uno::Reference< ::ooo::vba::word::XFont >& /*_font*/ )
102 throw uno::RuntimeException("Not implemented" );
105 ::sal_Int32 SAL_CALL SwVbaListLevel::getIndex()
107 return mnLevel + 1;
110 OUString SAL_CALL SwVbaListLevel::getLinkedStyle()
112 // TODO:
113 return OUString();
116 void SAL_CALL SwVbaListLevel::setLinkedStyle( const OUString& /*_linkedstyle*/ )
118 // TODO:
121 OUString SAL_CALL SwVbaListLevel::getNumberFormat()
123 // TODO::
124 return OUString();
127 void SAL_CALL SwVbaListLevel::setNumberFormat( const OUString& /*_numberformat*/ )
129 // TODO::
132 float SAL_CALL SwVbaListLevel::getNumberPosition()
134 // indentAt + firstlineindent
135 sal_Int32 nIndentAt = 0;
136 sal_Int32 nFirstLineIndent = 0;
137 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "IndentAt" ) >>= nIndentAt;
138 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "FirstLineIndent" ) >>= nFirstLineIndent;
140 sal_Int32 nResult = nIndentAt + nFirstLineIndent;
142 return static_cast< float >( Millimeter::getInPoints( nResult ) );
145 void SAL_CALL SwVbaListLevel::setNumberPosition( float _numberposition )
147 sal_Int32 nNumberPosition = Millimeter::getInHundredthsOfOneMillimeter( _numberposition );
149 sal_Int32 nIndentAt = 0;
150 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "IndentAt" ) >>= nIndentAt;
152 sal_Int32 nFirstLineIndent = nNumberPosition - nIndentAt;
153 m_pListHelper->setPropertyValueWithNameAndLevel( mnLevel, "FirstLineIndent", uno::Any( nFirstLineIndent ) );
156 ::sal_Int32 SAL_CALL SwVbaListLevel::getNumberStyle()
158 sal_Int16 nNumberingType = 0;
159 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "NumberingType" ) >>= nNumberingType;
160 switch( nNumberingType )
162 case style::NumberingType::CHAR_SPECIAL:
164 nNumberingType = word::WdListNumberStyle::wdListNumberStyleBullet;
165 break;
167 case style::NumberingType::CHARS_UPPER_LETTER:
169 nNumberingType = word::WdListNumberStyle::wdListNumberStyleUppercaseLetter;
170 break;
172 case style::NumberingType::CHARS_LOWER_LETTER:
174 nNumberingType = word::WdListNumberStyle::wdListNumberStyleLowercaseLetter;
175 break;
177 case style::NumberingType::ROMAN_UPPER:
179 nNumberingType = word::WdListNumberStyle::wdListNumberStyleUppercaseRoman;
180 break;
182 case style::NumberingType::ROMAN_LOWER:
184 nNumberingType = word::WdListNumberStyle::wdListNumberStyleLowercaseRoman;
185 break;
187 case style::NumberingType::ARABIC:
189 nNumberingType = word::WdListNumberStyle::wdListNumberStyleArabic;
190 break;
192 case style::NumberingType::NUMBER_NONE:
194 nNumberingType = word::WdListNumberStyle::wdListNumberStyleNone;
195 break;
197 case style::NumberingType::FULLWIDTH_ARABIC:
199 nNumberingType = word::WdListNumberStyle::wdListNumberStyleArabicFullWidth;
200 break;
202 case style::NumberingType::CIRCLE_NUMBER:
204 nNumberingType = word::WdListNumberStyle::wdListNumberStyleNumberInCircle;
205 break;
207 case style::NumberingType::CHARS_ARABIC:
209 nNumberingType = word::WdListNumberStyle::wdListNumberStyleCardinalText;
210 break;
212 default:
214 throw uno::RuntimeException("Not implemented" );
217 return nNumberingType;
220 void SAL_CALL SwVbaListLevel::setNumberStyle( ::sal_Int32 _numberstyle )
222 sal_Int16 nNumberingType = 0;
223 switch( _numberstyle )
225 case word::WdListNumberStyle::wdListNumberStyleBullet:
227 nNumberingType = style::NumberingType::CHAR_SPECIAL;
228 break;
230 case word::WdListNumberStyle::wdListNumberStyleUppercaseLetter:
232 nNumberingType = style::NumberingType::CHARS_UPPER_LETTER_N;
233 break;
235 case word::WdListNumberStyle::wdListNumberStyleLowercaseLetter:
237 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER_N;
238 break;
240 case word::WdListNumberStyle::wdListNumberStyleUppercaseRoman:
242 nNumberingType = style::NumberingType::ROMAN_UPPER;
243 break;
245 case word::WdListNumberStyle::wdListNumberStyleLowercaseRoman:
247 nNumberingType = style::NumberingType::ROMAN_LOWER;
248 break;
250 case word::WdListNumberStyle::wdListNumberStyleArabic:
252 nNumberingType = style::NumberingType::ARABIC;
253 break;
255 case word::WdListNumberStyle::wdListNumberStyleNone:
257 nNumberingType = style::NumberingType::NUMBER_NONE;
258 break;
260 case word::WdListNumberStyle::wdListNumberStyleArabicFullWidth:
262 nNumberingType = style::NumberingType::FULLWIDTH_ARABIC;
263 break;
265 case word::WdListNumberStyle::wdListNumberStyleNumberInCircle:
267 nNumberingType = style::NumberingType::CIRCLE_NUMBER;
268 break;
270 case word::WdListNumberStyle::wdListNumberStyleCardinalText:
272 nNumberingType = style::NumberingType::CHARS_ARABIC;
273 break;
275 case word::WdListNumberStyle::wdListNumberStyleOrdinal:
276 case word::WdListNumberStyle::wdListNumberStyleOrdinalText:
277 case word::WdListNumberStyle::wdListNumberStyleKanji:
278 case word::WdListNumberStyle::wdListNumberStyleKanjiDigit:
279 case word::WdListNumberStyle::wdListNumberStyleAiueoHalfWidth:
280 case word::WdListNumberStyle::wdListNumberStyleIrohaHalfWidth:
282 nNumberingType = style::NumberingType::ARABIC;
283 break;
285 default:
287 throw uno::RuntimeException("Not implemented" );
291 m_pListHelper->setPropertyValueWithNameAndLevel( mnLevel, "NumberingType", uno::Any( nNumberingType ) );
294 ::sal_Int32 SAL_CALL SwVbaListLevel::getResetOnHigher()
296 //seems not support?
297 return 0;
300 void SAL_CALL SwVbaListLevel::setResetOnHigher( ::sal_Int32 /*_resetonhigher*/ )
302 //seems not support?
305 ::sal_Int32 SAL_CALL SwVbaListLevel::getStartAt()
307 sal_Int16 nStartWith = 0;
308 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "StartWith" ) >>= nStartWith;
309 return nStartWith;
312 void SAL_CALL SwVbaListLevel::setStartAt( ::sal_Int32 _startat )
314 sal_Int16 nStartWith = static_cast<sal_Int16>(_startat);
315 m_pListHelper->setPropertyValueWithNameAndLevel( mnLevel, "StartWith", uno::Any( nStartWith ) );
318 float SAL_CALL SwVbaListLevel::getTabPosition()
320 sal_Int32 nTabPosition = 0;
321 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "ListtabStopPosition" ) >>= nTabPosition;
323 return static_cast< float >( Millimeter::getInPoints( nTabPosition ) );
326 void SAL_CALL SwVbaListLevel::setTabPosition( float _tabposition )
328 sal_Int32 nTabPosition = Millimeter::getInHundredthsOfOneMillimeter( _tabposition );
329 m_pListHelper->setPropertyValueWithNameAndLevel( mnLevel, "ListtabStopPosition", uno::Any( nTabPosition ) );
332 float SAL_CALL SwVbaListLevel::getTextPosition()
334 // indentAt
335 sal_Int32 nIndentAt = 0;
336 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "IndentAt" ) >>= nIndentAt;
338 return static_cast< float >( Millimeter::getInPoints( nIndentAt ) );
341 void SAL_CALL SwVbaListLevel::setTextPosition( float _textposition )
343 sal_Int32 nIndentAt = 0;
344 sal_Int32 nFirstLineIndent = 0;
345 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "IndentAt" ) >>= nIndentAt;
346 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "FirstLineIndent" ) >>= nFirstLineIndent;
348 sal_Int32 nAlignedAt = nIndentAt + nFirstLineIndent;
350 nIndentAt = Millimeter::getInHundredthsOfOneMillimeter( _textposition );
351 nFirstLineIndent = nAlignedAt - nIndentAt;
352 m_pListHelper->setPropertyValueWithNameAndLevel( mnLevel, "IndentAt", uno::Any( nIndentAt ) );
353 m_pListHelper->setPropertyValueWithNameAndLevel( mnLevel, "FirstLineIndent", uno::Any( nFirstLineIndent ) );
356 ::sal_Int32 SAL_CALL SwVbaListLevel::getTrailingCharacter()
358 sal_Int16 nLabelFollowedBy= 0;
359 m_pListHelper->getPropertyValueWithNameAndLevel( mnLevel, "LabelFollowedBy" ) >>= nLabelFollowedBy;
361 return nLabelFollowedBy;
364 void SAL_CALL SwVbaListLevel::setTrailingCharacter( ::sal_Int32 _trailingcharacter )
366 sal_Int16 nLabelFollowedBy = static_cast<sal_Int16>(_trailingcharacter);
367 m_pListHelper->setPropertyValueWithNameAndLevel( mnLevel, "LabelFollowedBy", uno::Any( nLabelFollowedBy ) );
370 OUString
371 SwVbaListLevel::getServiceImplName()
373 return "SwVbaListLevel";
376 uno::Sequence< OUString >
377 SwVbaListLevel::getServiceNames()
379 static uno::Sequence< OUString > const aServiceNames
381 "ooo.vba.word.ListLevel"
383 return aServiceNames;
386 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */