fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / namedlg / namepast.cxx
blob5f0c238327ef71ba7c89eafe0932c372ff0574ab
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 .
20 #undef SC_DLLIMPLEMENTATION
22 #include "namepast.hxx"
23 #include "scresid.hxx"
24 #include "docsh.hxx"
25 #include "miscdlgs.hrc"
26 #include "rangenam.hxx"
27 #include "viewdata.hxx"
29 ScNamePasteDlg::ScNamePasteDlg( vcl::Window * pParent, ScDocShell* pShell, bool )
30 : ModalDialog( pParent, "InsertNameDialog", "modules/scalc/ui/insertname.ui" )
32 get(m_pBtnPasteAll, "pasteall");
33 get(m_pBtnPaste, "paste");
34 get(m_pBtnClose, "close");
36 ScDocument& rDoc = pShell->GetDocument();
37 std::map<OUString, ScRangeName*> aCopyMap;
38 rDoc.GetRangeNameMap(aCopyMap);
39 std::map<OUString, ScRangeName*>::iterator itr = aCopyMap.begin(), itrEnd = aCopyMap.end();
40 for (; itr != itrEnd; ++itr)
42 OUString aTemp(itr->first);
43 maRangeMap.insert(aTemp, new ScRangeName(*itr->second));
46 ScViewData* pViewData = ScDocShell::GetViewData();
47 ScAddress aPos(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
48 SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("ctrl");
49 Size aControlSize(210, 0);
50 aControlSize = LogicToPixel(aControlSize, MAP_APPFONT);
51 pContainer->set_width_request(aControlSize.Width());
52 pContainer->set_height_request(10 * GetTextHeight());
53 mpTable = VclPtr<ScRangeManagerTable>::Create(*pContainer, maRangeMap, aPos);
55 m_pBtnPaste->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl) );
56 m_pBtnPasteAll->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl));
57 m_pBtnClose->SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl));
59 if (!mpTable->GetEntryCount())
61 m_pBtnPaste->Disable();
62 m_pBtnPasteAll->Disable();
66 ScNamePasteDlg::~ScNamePasteDlg()
68 disposeOnce();
71 void ScNamePasteDlg::dispose()
73 mpTable.disposeAndClear();
74 m_pBtnPasteAll.clear();
75 m_pBtnPaste.clear();
76 m_pBtnClose.clear();
77 ModalDialog::dispose();
80 IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
82 if( pButton == m_pBtnPasteAll )
84 EndDialog( BTN_PASTE_LIST );
86 else if( pButton == m_pBtnPaste )
88 std::vector<ScRangeNameLine> aSelectedLines = mpTable->GetSelectedEntries();
89 for (std::vector<ScRangeNameLine>::const_iterator itr = aSelectedLines.begin();
90 itr != aSelectedLines.end(); ++itr)
92 maSelectedNames.push_back(itr->aName);
94 EndDialog( BTN_PASTE_NAME );
96 else if( pButton == m_pBtnClose )
98 EndDialog( BTN_PASTE_CLOSE );
100 return 0;
103 std::vector<OUString> ScNamePasteDlg::GetSelectedNames() const
105 return maSelectedNames;
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */