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