1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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
;
44 case text::HoriOrientation::LEFT
:
46 nAlignment
= word::WdListLevelAlignment::wdListLevelAlignLeft
;
49 case text::HoriOrientation::RIGHT
:
51 nAlignment
= word::WdListLevelAlignment::wdListLevelAlignRight
;
54 case text::HoriOrientation::CENTER
:
56 nAlignment
= word::WdListLevelAlignment::wdListLevelAlignCenter
;
61 throw uno::RuntimeException();
67 void SAL_CALL
SwVbaListLevel::setAlignment( ::sal_Int32 _alignment
)
69 sal_Int16 nAlignment
= text::HoriOrientation::LEFT
;
72 case word::WdListLevelAlignment::wdListLevelAlignLeft
:
74 nAlignment
= text::HoriOrientation::LEFT
;
77 case word::WdListLevelAlignment::wdListLevelAlignRight
:
79 nAlignment
= text::HoriOrientation::RIGHT
;
82 case word::WdListLevelAlignment::wdListLevelAlignCenter
:
84 nAlignment
= text::HoriOrientation::CENTER
;
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()
110 OUString SAL_CALL
SwVbaListLevel::getLinkedStyle()
116 void SAL_CALL
SwVbaListLevel::setLinkedStyle( const OUString
& /*_linkedstyle*/ )
121 OUString SAL_CALL
SwVbaListLevel::getNumberFormat()
127 void SAL_CALL
SwVbaListLevel::setNumberFormat( const OUString
& /*_numberformat*/ )
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
;
167 case style::NumberingType::CHARS_UPPER_LETTER
:
169 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleUppercaseLetter
;
172 case style::NumberingType::CHARS_LOWER_LETTER
:
174 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleLowercaseLetter
;
177 case style::NumberingType::ROMAN_UPPER
:
179 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleUppercaseRoman
;
182 case style::NumberingType::ROMAN_LOWER
:
184 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleLowercaseRoman
;
187 case style::NumberingType::ARABIC
:
189 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleArabic
;
192 case style::NumberingType::NUMBER_NONE
:
194 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleNone
;
197 case style::NumberingType::FULLWIDTH_ARABIC
:
199 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleArabicFullWidth
;
202 case style::NumberingType::CIRCLE_NUMBER
:
204 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleNumberInCircle
;
207 case style::NumberingType::CHARS_ARABIC
:
209 nNumberingType
= word::WdListNumberStyle::wdListNumberStyleCardinalText
;
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
;
230 case word::WdListNumberStyle::wdListNumberStyleUppercaseLetter
:
232 nNumberingType
= style::NumberingType::CHARS_UPPER_LETTER_N
;
235 case word::WdListNumberStyle::wdListNumberStyleLowercaseLetter
:
237 nNumberingType
= style::NumberingType::CHARS_LOWER_LETTER_N
;
240 case word::WdListNumberStyle::wdListNumberStyleUppercaseRoman
:
242 nNumberingType
= style::NumberingType::ROMAN_UPPER
;
245 case word::WdListNumberStyle::wdListNumberStyleLowercaseRoman
:
247 nNumberingType
= style::NumberingType::ROMAN_LOWER
;
250 case word::WdListNumberStyle::wdListNumberStyleArabic
:
252 nNumberingType
= style::NumberingType::ARABIC
;
255 case word::WdListNumberStyle::wdListNumberStyleNone
:
257 nNumberingType
= style::NumberingType::NUMBER_NONE
;
260 case word::WdListNumberStyle::wdListNumberStyleArabicFullWidth
:
262 nNumberingType
= style::NumberingType::FULLWIDTH_ARABIC
;
265 case word::WdListNumberStyle::wdListNumberStyleNumberInCircle
:
267 nNumberingType
= style::NumberingType::CIRCLE_NUMBER
;
270 case word::WdListNumberStyle::wdListNumberStyleCardinalText
:
272 nNumberingType
= style::NumberingType::CHARS_ARABIC
;
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
;
287 throw uno::RuntimeException("Not implemented" );
291 m_pListHelper
->setPropertyValueWithNameAndLevel( mnLevel
, "NumberingType", uno::Any( nNumberingType
) );
294 ::sal_Int32 SAL_CALL
SwVbaListLevel::getResetOnHigher()
300 void SAL_CALL
SwVbaListLevel::setResetOnHigher( ::sal_Int32
/*_resetonhigher*/ )
305 ::sal_Int32 SAL_CALL
SwVbaListLevel::getStartAt()
307 sal_Int16 nStartWith
= 0;
308 m_pListHelper
->getPropertyValueWithNameAndLevel( mnLevel
, "StartWith" ) >>= 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()
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
) );
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: */