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 .
20 #include <svx/SvxNumOptionsTabPageHelper.hxx>
21 #include <com/sun/star/style/NumberingType.hpp>
22 #include <com/sun/star/text/DefaultNumberingProvider.hpp>
23 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
24 #include <comphelper/processfactory.hxx>
27 using namespace css::uno
;
28 using namespace css::text
;
29 using namespace css::style
;
31 Reference
<XDefaultNumberingProvider
> SvxNumOptionsTabPageHelper::GetNumberingProvider()
33 Reference
<XComponentContext
> xContext(::comphelper::getProcessComponentContext());
34 Reference
<XDefaultNumberingProvider
> xRet
= text::DefaultNumberingProvider::create(xContext
);
38 void SvxNumOptionsTabPageHelper::GetI18nNumbering(weld::ComboBox
& rFmtLB
, sal_uInt16 nDoNotRemove
)
40 Reference
<XDefaultNumberingProvider
> xDefNum
= GetNumberingProvider();
41 Reference
<XNumberingTypeInfo
> xInfo(xDefNum
, UNO_QUERY
);
43 // Extended numbering schemes present in the resource but not offered by
44 // the i18n framework per configuration must be removed from the listbox.
45 // Do not remove a special entry matching nDoNotRemove.
46 const sal_uInt16 nDontRemove
= SAL_MAX_UINT16
;
47 ::std::vector
<sal_uInt16
> aRemove(rFmtLB
.get_count(), nDontRemove
);
48 for (size_t i
= 0; i
< aRemove
.size(); ++i
)
50 sal_uInt16 nEntryData
= rFmtLB
.get_id(i
).toInt32();
51 if (nEntryData
> NumberingType::CHARS_LOWER_LETTER_N
&& nEntryData
!= nDoNotRemove
)
52 aRemove
[i
] = nEntryData
;
56 Sequence
<sal_Int16
> aTypes
= xInfo
->getSupportedNumberingTypes();
57 for (const sal_Int16 nCurrent
: aTypes
)
59 if (nCurrent
> NumberingType::CHARS_LOWER_LETTER_N
)
62 for (int nEntry
= 0; nEntry
< rFmtLB
.get_count(); ++nEntry
)
64 sal_uInt16 nEntryData
= rFmtLB
.get_id(nEntry
).toInt32();
65 if (nEntryData
== static_cast<sal_uInt16
>(nCurrent
))
68 aRemove
[nEntry
] = nDontRemove
;
74 OUString aIdent
= xInfo
->getNumberingIdentifier(nCurrent
);
75 rFmtLB
.append(OUString::number(nCurrent
), aIdent
);
80 for (unsigned short i
: aRemove
)
84 rFmtLB
.remove_id(OUString::number(i
));
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */