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