bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / namedlg / namepast.cxx
blob64a296c90e0d51b744f258ac21b8c7877542d838
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #undef SC_DLLIMPLEMENTATION
25 //------------------------------------------------------------------
27 #include "namepast.hxx"
28 #include "scresid.hxx"
29 #include "docsh.hxx"
30 #include "miscdlgs.hrc"
31 #include "rangenam.hxx"
32 #include "viewdata.hxx"
35 //==================================================================
37 ScNamePasteDlg::ScNamePasteDlg( Window * pParent, ScDocShell* pShell, bool )
38 : ModalDialog( pParent, "InsertNameDialog", "modules/scalc/ui/insertname.ui" )
40 get(m_pBtnPasteAll, "pasteall");
41 get(m_pBtnPaste, "paste");
42 get(m_pBtnClose, "close");
44 ScDocument* pDoc = pShell->GetDocument();
45 std::map<OUString, ScRangeName*> aCopyMap;
46 pDoc->GetRangeNameMap(aCopyMap);
47 std::map<OUString, ScRangeName*>::iterator itr = aCopyMap.begin(), itrEnd = aCopyMap.end();
48 for (; itr != itrEnd; ++itr)
50 OUString aTemp(itr->first);
51 maRangeMap.insert(aTemp, new ScRangeName(*itr->second));
54 ScViewData* pViewData = pShell->GetViewData();
55 ScAddress aPos(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
56 SvxSimpleTableContainer *pContainer = get<SvxSimpleTableContainer>("ctrl");
57 Size aControlSize(210, 0);
58 aControlSize = LogicToPixel(aControlSize, MAP_APPFONT);
59 pContainer->set_width_request(aControlSize.Width());
60 pContainer->set_height_request(10 * GetTextHeight());
61 mpTable = new ScRangeManagerTable(*pContainer, maRangeMap, aPos);
63 m_pBtnPaste->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl) );
64 m_pBtnPasteAll->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl));
65 m_pBtnClose->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl));
67 if (!mpTable->GetEntryCount())
69 m_pBtnPaste->Disable();
70 m_pBtnPasteAll->Disable();
74 ScNamePasteDlg::~ScNamePasteDlg()
76 delete mpTable;
79 //------------------------------------------------------------------
81 IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
83 if( pButton == m_pBtnPasteAll )
85 EndDialog( BTN_PASTE_LIST );
87 else if( pButton == m_pBtnPaste )
89 std::vector<ScRangeNameLine> aSelectedLines = mpTable->GetSelectedEntries();
90 for (std::vector<ScRangeNameLine>::const_iterator itr = aSelectedLines.begin();
91 itr != aSelectedLines.end(); ++itr)
93 maSelectedNames.push_back(itr->aName);
95 EndDialog( BTN_PASTE_NAME );
97 else if( pButton == m_pBtnClose )
99 EndDialog( BTN_PASTE_CLOSE );
101 return 0;
104 //------------------------------------------------------------------
106 std::vector<OUString> ScNamePasteDlg::GetSelectedNames() const
108 return maSelectedNames;
111 bool ScNamePasteDlg::IsAllSelected() const
113 return false;
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */