Line data Source code
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 : #undef SC_DLLIMPLEMENTATION
21 :
22 : #include "namepast.hxx"
23 : #include "scresid.hxx"
24 : #include "docsh.hxx"
25 : #include "miscdlgs.hrc"
26 : #include "rangenam.hxx"
27 : #include "viewdata.hxx"
28 :
29 0 : ScNamePasteDlg::ScNamePasteDlg( vcl::Window * pParent, ScDocShell* pShell, bool )
30 0 : : ModalDialog( pParent, "InsertNameDialog", "modules/scalc/ui/insertname.ui" )
31 : {
32 0 : get(m_pBtnPasteAll, "pasteall");
33 0 : get(m_pBtnPaste, "paste");
34 0 : get(m_pBtnClose, "close");
35 :
36 0 : ScDocument& rDoc = pShell->GetDocument();
37 0 : std::map<OUString, ScRangeName*> aCopyMap;
38 0 : rDoc.GetRangeNameMap(aCopyMap);
39 0 : std::map<OUString, ScRangeName*>::iterator itr = aCopyMap.begin(), itrEnd = aCopyMap.end();
40 0 : for (; itr != itrEnd; ++itr)
41 : {
42 0 : OUString aTemp(itr->first);
43 0 : maRangeMap.insert(aTemp, new ScRangeName(*itr->second));
44 0 : }
45 :
46 0 : ScViewData* pViewData = ScDocShell::GetViewData();
47 0 : ScAddress aPos(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
48 0 : SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("ctrl");
49 0 : Size aControlSize(210, 0);
50 0 : aControlSize = LogicToPixel(aControlSize, MAP_APPFONT);
51 0 : pContainer->set_width_request(aControlSize.Width());
52 0 : pContainer->set_height_request(10 * GetTextHeight());
53 0 : mpTable = VclPtr<ScRangeManagerTable>::Create(*pContainer, maRangeMap, aPos);
54 :
55 0 : m_pBtnPaste->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl) );
56 0 : m_pBtnPasteAll->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl));
57 0 : m_pBtnClose->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl));
58 :
59 0 : if (!mpTable->GetEntryCount())
60 : {
61 0 : m_pBtnPaste->Disable();
62 0 : m_pBtnPasteAll->Disable();
63 0 : }
64 0 : }
65 :
66 0 : ScNamePasteDlg::~ScNamePasteDlg()
67 : {
68 0 : disposeOnce();
69 0 : }
70 :
71 0 : void ScNamePasteDlg::dispose()
72 : {
73 0 : mpTable.disposeAndClear();
74 0 : m_pBtnPasteAll.clear();
75 0 : m_pBtnPaste.clear();
76 0 : m_pBtnClose.clear();
77 0 : ModalDialog::dispose();
78 0 : }
79 :
80 0 : IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
81 : {
82 0 : if( pButton == m_pBtnPasteAll )
83 : {
84 0 : EndDialog( BTN_PASTE_LIST );
85 : }
86 0 : else if( pButton == m_pBtnPaste )
87 : {
88 0 : std::vector<ScRangeNameLine> aSelectedLines = mpTable->GetSelectedEntries();
89 0 : for (std::vector<ScRangeNameLine>::const_iterator itr = aSelectedLines.begin();
90 0 : itr != aSelectedLines.end(); ++itr)
91 : {
92 0 : maSelectedNames.push_back(itr->aName);
93 : }
94 0 : EndDialog( BTN_PASTE_NAME );
95 : }
96 0 : else if( pButton == m_pBtnClose )
97 : {
98 0 : EndDialog( BTN_PASTE_CLOSE );
99 : }
100 0 : return 0;
101 : }
102 :
103 0 : std::vector<OUString> ScNamePasteDlg::GetSelectedNames() const
104 : {
105 0 : return maSelectedNames;
106 0 : }
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|