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