1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
)
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
));
51 m_xDialog
->set_title(SdResId(STR_INSERT_TEXT
));
56 SdInsertPagesObjsDlg::~SdInsertPagesObjsDlg()
61 * Fills the TreeLB dependent on the medium. Is not medium available, then
62 * it is a text and not a draw document.
64 void SdInsertPagesObjsDlg::Reset()
68 m_xLbTree
->set_selection_mode(SelectionMode::Multiple
);
70 // transfer ownership of Medium
71 m_xLbTree
->Fill( m_pDoc
, m_pMedium
, m_rName
);
75 OUString
sImgText(BMP_DOC_TEXT
);
76 m_xLbTree
->InsertEntry(m_rName
, sImgText
);
79 m_xCbxMasters
->set_active(true);
82 std::vector
<OUString
> SdInsertPagesObjsDlg::GetList( const sal_uInt16 nType
)
84 // With Draw documents, we have to return NULL on selection of the document
87 // to ensure that bookmarks are opened
88 // (when the whole document is selected)
89 m_xLbTree
->GetBookmarkDoc();
91 // If the document is selected (too) or nothing is selected,
92 // the whole document is inserted (but not more!)
93 std::unique_ptr
<weld::TreeIter
> xIter(m_xLbTree
->make_iterator());
94 if (!m_xLbTree
->get_iter_first(*xIter
) || m_xLbTree
->is_selected(*xIter
))
95 return std::vector
<OUString
>();
98 return m_xLbTree
->GetSelectEntryList( nType
);
104 bool SdInsertPagesObjsDlg::IsLink()
106 return m_xCbxLink
->get_active();
112 bool SdInsertPagesObjsDlg::IsRemoveUnnessesaryMasterPages() const
114 return m_xCbxMasters
->get_active();
118 * Enabled and selects end-color-LB
120 IMPL_LINK_NOARG(SdInsertPagesObjsDlg
, SelectObjectHdl
, weld::TreeView
&, void)
122 m_xCbxLink
->set_sensitive(m_xLbTree
->IsLinkableSelected());
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */