Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / dialog / papersizelistbox.cxx
blobf746a023c38d75b5d325f661370b59579bafd660
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 .
20 #include <svx/dialmgr.hxx>
21 #include <svx/papersizelistbox.hxx>
22 #include "page.hrc"
24 SvxPaperSizeListBox::SvxPaperSizeListBox(std::unique_ptr<weld::ComboBox> pControl)
25 : m_xControl(std::move(pControl))
27 m_xControl->set_size_request(150, -1);
30 void SvxPaperSizeListBox::FillPaperSizeEntries( PaperSizeApp eApp )
32 const std::pair<const char*, int>* pPaperAry = eApp == PaperSizeApp::Std ?
33 RID_SVXSTRARY_PAPERSIZE_STD : RID_SVXSTRARY_PAPERSIZE_DRAW;
34 sal_uInt32 nCnt = eApp == PaperSizeApp::Std ?
35 SAL_N_ELEMENTS(RID_SVXSTRARY_PAPERSIZE_STD) : SAL_N_ELEMENTS(RID_SVXSTRARY_PAPERSIZE_DRAW);
37 for ( sal_uInt32 i = 0; i < nCnt; ++i )
39 OUString aStr = SvxResId(pPaperAry[i].first);
40 Paper eSize = static_cast<Paper>(pPaperAry[i].second);
41 m_xControl->append(OUString::number(static_cast<sal_Int32>(eSize)), aStr);
45 void SvxPaperSizeListBox::set_active_id( Paper ePreselectPaper )
47 int nEntryCount = m_xControl->get_count();
48 int nSelPos = -1;
49 int nUserPos = -1;
51 for (int i = 0; i < nEntryCount; ++i)
53 Paper eTmp = static_cast<Paper>(m_xControl->get_id(i).toInt32());
54 if (eTmp == ePreselectPaper)
56 nSelPos = i;
57 break;
60 if (eTmp == PAPER_USER)
61 nUserPos = i;
64 // preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead
65 m_xControl->set_active((nSelPos != -1) ? nSelPos : nUserPos);
68 Paper SvxPaperSizeListBox::get_active_id() const
70 return static_cast<Paper>(m_xControl->get_active_id().toInt32());
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */