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 <multmrk.hxx>
21 #include <toxmgr.hxx>
22 #include <wrtsh.hxx>
23 
SwMultiTOXMarkDlg(weld::Window * pParent,SwTOXMgr & rTOXMgr)24 SwMultiTOXMarkDlg::SwMultiTOXMarkDlg(weld::Window* pParent, SwTOXMgr& rTOXMgr)
25     : GenericDialogController(pParent, "modules/swriter/ui/selectindexdialog.ui",
26                               "SelectIndexDialog")
27     , m_rMgr(rTOXMgr)
28     , m_nPos(0)
29     , m_xTextFT(m_xBuilder->weld_label("type"))
30     , m_xTOXLB(m_xBuilder->weld_tree_view("treeview"))
31 {
32     m_xTOXLB->set_size_request(m_xTOXLB->get_approximate_digit_width() * 32,
33                                m_xTOXLB->get_height_rows(8));
34 
35     m_xTOXLB->connect_changed(LINK(this, SwMultiTOXMarkDlg, SelectHdl));
36 
37     sal_uInt16 nSize = m_rMgr.GetTOXMarkCount();
38     for (sal_uInt16 i = 0; i < nSize; ++i)
39         m_xTOXLB->append_text(m_rMgr.GetTOXMark(i)->GetText(m_rMgr.GetShell()->GetLayout()));
40 
41     m_xTOXLB->select(0);
42     m_xTextFT->set_label(m_rMgr.GetTOXMark(0)->GetTOXType()->GetTypeName());
43 }
44 
IMPL_LINK(SwMultiTOXMarkDlg,SelectHdl,weld::TreeView &,rBox,void)45 IMPL_LINK(SwMultiTOXMarkDlg, SelectHdl, weld::TreeView&, rBox, void)
46 {
47     if (rBox.get_selected_index() != -1)
48     {
49         SwTOXMark* pMark = m_rMgr.GetTOXMark(rBox.get_selected_index());
50         m_xTextFT->set_label(pMark->GetTOXType()->GetTypeName());
51         m_nPos = rBox.get_selected_index();
52     }
53 }
54 
run()55 short SwMultiTOXMarkDlg::run()
56 {
57     short nRet = GenericDialogController::run();
58     if (nRet == RET_OK)
59         m_rMgr.SetCurTOXMark(m_nPos);
60     return nRet;
61 }
62 
~SwMultiTOXMarkDlg()63 SwMultiTOXMarkDlg::~SwMultiTOXMarkDlg() {}
64 
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
66