Update git submodules
[LibreOffice.git] / sd / source / ui / dlg / inspagob.cxx
blob5c984dd2329a40f3257674ff928650f31adadfcc
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 #include <inspagob.hxx>
21 #include <sdtreelb.hxx>
23 #include <strings.hrc>
25 #include <bitmaps.hlst>
26 #include <sdresid.hxx>
27 #include <drawdoc.hxx>
28 #include <DrawDocShell.hxx>
29 #include <ViewShell.hxx>
31 SdInsertPagesObjsDlg::SdInsertPagesObjsDlg(
32 weld::Window* pWindow, const SdDrawDocument* pInDoc,
33 SfxMedium* pSfxMedium, const OUString& rFileName )
34 : GenericDialogController(pWindow, "modules/sdraw/ui/insertslidesdialog.ui", "InsertSlidesDialog")
35 , m_pMedium(pSfxMedium)
36 , m_pDoc(pInDoc)
37 , m_rName(rFileName)
38 , m_xLbTree(new SdPageObjsTLV(m_xBuilder->weld_tree_view("tree")))
39 , m_xCbxLink(m_xBuilder->weld_check_button("links"))
40 , m_xCbxMasters(m_xBuilder->weld_check_button("backgrounds"))
42 m_xLbTree->set_size_request(m_xLbTree->get_approximate_digit_width() * 48,
43 m_xLbTree->get_height_rows(12));
45 m_xLbTree->SetViewFrame( pInDoc->GetDocSh()->GetViewShell()->GetViewFrame() );
47 m_xLbTree->connect_changed(LINK(this, SdInsertPagesObjsDlg, SelectObjectHdl));
49 // insert text
50 if (!m_pMedium)
51 m_xDialog->set_title(SdResId(STR_INSERT_TEXT));
52 else if (m_pDoc && m_pDoc->GetDocumentType() == DocumentType::Draw)
53 m_xDialog->set_title(SdResId(STR_INSERT_PAGES));
55 Reset();
58 SdInsertPagesObjsDlg::~SdInsertPagesObjsDlg()
62 /**
63 * Fills the TreeLB dependent on the medium. Is not medium available, then
64 * it is a text and not a draw document.
66 void SdInsertPagesObjsDlg::Reset()
68 if( m_pMedium )
70 m_xLbTree->set_selection_mode(SelectionMode::Multiple);
72 // transfer ownership of Medium
73 m_xLbTree->Fill( m_pDoc, m_pMedium, m_rName );
75 else
77 m_xLbTree->InsertEntry(m_rName, BMP_DOC_TEXT);
80 m_xCbxMasters->set_active(true);
83 std::vector<OUString> SdInsertPagesObjsDlg::GetList( const sal_uInt16 nType )
85 // With Draw documents, we have to return NULL on selection of the document
86 if( m_pMedium )
88 // to ensure that bookmarks are opened
89 // (when the whole document is selected)
90 m_xLbTree->GetBookmarkDoc();
92 // If the document is selected (too) or nothing is selected,
93 // the whole document is inserted (but not more!)
94 std::unique_ptr<weld::TreeIter> xIter(m_xLbTree->make_iterator());
95 if (!m_xLbTree->get_iter_first(*xIter) || m_xLbTree->is_selected(*xIter))
96 return std::vector<OUString>();
99 return m_xLbTree->GetSelectEntryList( nType );
103 * is link checked
105 bool SdInsertPagesObjsDlg::IsLink() const
107 return m_xCbxLink->get_active();
111 * is link checked
113 bool SdInsertPagesObjsDlg::IsRemoveUnnecessaryMasterPages() const
115 return m_xCbxMasters->get_active();
119 * Enabled and selects end-color-LB
121 IMPL_LINK_NOARG(SdInsertPagesObjsDlg, SelectObjectHdl, weld::TreeView&, void)
123 m_xCbxLink->set_sensitive(m_xLbTree->IsLinkableSelected());
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */