LibreOffice Module svx (master) 1
papersizelistbox.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
20#include <svx/dialmgr.hxx>
22#include "page.hrc"
23
24SvxPaperSizeListBox::SvxPaperSizeListBox(std::unique_ptr<weld::ComboBox> pControl)
25 : m_xControl(std::move(pControl))
26{
27 m_xControl->set_size_request(150, -1);
28}
29
31{
32 const std::pair<TranslateId, 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);
36
37 for ( sal_uInt32 i = 0; i < nCnt; ++i )
38 {
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);
42 }
43}
44
46{
47 int nEntryCount = m_xControl->get_count();
48 int nSelPos = -1;
49 int nUserPos = -1;
50
51 for (int i = 0; i < nEntryCount; ++i)
52 {
53 Paper eTmp = static_cast<Paper>(m_xControl->get_id(i).toInt32());
54 if (eTmp == ePreselectPaper)
55 {
56 nSelPos = i;
57 break;
58 }
59
60 if (eTmp == PAPER_USER)
61 nUserPos = i;
62 }
63
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);
66}
67
69{
70 return static_cast<Paper>(m_xControl->get_active_id().toInt32());
71}
72
73/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
74
void set_active_id(Paper eSize)
SvxPaperSizeListBox(std::unique_ptr< weld::ComboBox > pControl)
void FillPaperSizeEntries(PaperSizeApp eApp)
Paper get_active_id() const
std::unique_ptr< weld::ComboBox > m_xControl
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
#define SAL_N_ELEMENTS(arr)
aStr
int i
constexpr OUStringLiteral first
Paper
PAPER_USER
PaperSizeApp
Reference< XControl > m_xControl