LibreOffice Module svx (master) 1
SvxNumOptionsTabPageHelper.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
21#include <com/sun/star/style/NumberingType.hpp>
22#include <com/sun/star/text/DefaultNumberingProvider.hpp>
23#include <com/sun/star/text/XNumberingTypeInfo.hpp>
25
26using namespace css;
27using namespace css::uno;
28using namespace css::text;
29using namespace css::style;
30
31Reference<XDefaultNumberingProvider> SvxNumOptionsTabPageHelper::GetNumberingProvider()
32{
33 Reference<XComponentContext> xContext(::comphelper::getProcessComponentContext());
34 Reference<XDefaultNumberingProvider> xRet = text::DefaultNumberingProvider::create(xContext);
35 return xRet;
36}
37
39{
40 Reference<XDefaultNumberingProvider> xDefNum = GetNumberingProvider();
41 Reference<XNumberingTypeInfo> xInfo(xDefNum, UNO_QUERY);
42
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)
49 {
50 sal_uInt16 nEntryData = rFmtLB.get_id(i).toInt32();
51 if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N && nEntryData != nDoNotRemove)
52 aRemove[i] = nEntryData;
53 }
54 if (xInfo.is())
55 {
56 const Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes();
57 for (const sal_Int16 nCurrent : aTypes)
58 {
59 if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
60 {
61 bool bInsert = true;
62 for (int nEntry = 0; nEntry < rFmtLB.get_count(); ++nEntry)
63 {
64 sal_uInt16 nEntryData = rFmtLB.get_id(nEntry).toInt32();
65 if (nEntryData == static_cast<sal_uInt16>(nCurrent))
66 {
67 bInsert = false;
68 aRemove[nEntry] = nDontRemove;
69 break;
70 }
71 }
72 if (bInsert)
73 {
74 OUString aIdent = xInfo->getNumberingIdentifier(nCurrent);
75 rFmtLB.append(OUString::number(nCurrent), aIdent);
76 }
77 }
78 }
79 }
80 for (unsigned short i : aRemove)
81 {
82 if (i == nDontRemove)
83 continue;
84 rFmtLB.remove_id(OUString::number(i));
85 }
86}
87
88/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void GetI18nNumbering(weld::ComboBox &rFmtLB, sal_uInt16 nDoNotRemove)
Get the numberings provided by the i18n framework (CTL, Asian, ...) and add them to the listbox.
static Reference< XDefaultNumberingProvider > GetNumberingProvider()
virtual OUString get_id(int pos) const=0
void append(const weld::ComboBoxEntry &rItem)
virtual int get_count() const=0
void remove_id(const OUString &rId)
int i
#define SAL_MAX_UINT16
const SvXMLTokenMapEntry aTypes[]