diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-02-11 17:32:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-02-12 12:11:07 +0100 |
commit | c4a91f1409fc21d92f207718f29377c2862e381f (patch) | |
tree | 103fdcc0d6bd2b06334ddf5cc8b99e90eb8f1d96 /sd | |
parent | 20f6e0babf3cb0dd66a2dfcfa7a15cb2d9f2592b (diff) |
weld SdInsertPagesObjsDlg
Change-Id: Ie8e0eaa6122274d86f2d16597cd928acd15df05c
Reviewed-on: https://gerrit.libreoffice.org/67695
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/inc/sdabstdlg.hxx | 2 | ||||
-rw-r--r-- | sd/qa/unit/dialogs-test.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/dlg/inspagob.cxx | 72 | ||||
-rw-r--r-- | sd/source/ui/dlg/sddlgfact.cxx | 15 | ||||
-rw-r--r-- | sd/source/ui/dlg/sddlgfact.hxx | 11 | ||||
-rw-r--r-- | sd/source/ui/dlg/sdtreelb.cxx | 258 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/inc/inspagob.hxx | 28 | ||||
-rw-r--r-- | sd/source/ui/inc/sdtreelb.hxx | 106 | ||||
-rw-r--r-- | sd/uiconfig/sdraw/ui/insertslidesdialog.ui | 58 |
10 files changed, 479 insertions, 77 deletions
diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx index 6c03002c6c22..adb34590569c 100644 --- a/sd/inc/sdabstdlg.hxx +++ b/sd/inc/sdabstdlg.hxx @@ -175,7 +175,7 @@ public: virtual VclPtr<AbstractSdModifyFieldDlg> CreateSdModifyFieldDlg(weld::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet) = 0; virtual VclPtr<AbstractSdSnapLineDlg> CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) = 0; virtual VclPtr<AbstractSdInsertLayerDlg> CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& rStr) = 0; - virtual VclPtr<AbstractSdInsertPagesObjsDlg> CreateSdInsertPagesObjsDlg(vcl::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName) = 0; + virtual VclPtr<AbstractSdInsertPagesObjsDlg> CreateSdInsertPagesObjsDlg(weld::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName) = 0; virtual VclPtr<AbstractMorphDlg> CreateMorphDlg(weld::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateSdOutlineBulletTabDlg(weld::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateSdParagraphTabDlg(weld::Window* pWindow, const SfxItemSet* pAttr) = 0; diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx index 7f475dfa70b4..7a8ea154a8c2 100644 --- a/sd/qa/unit/dialogs-test.cxx +++ b/sd/qa/unit/dialogs-test.cxx @@ -383,7 +383,7 @@ VclPtr<VclAbstractDialog> SdDialogsTest::createDialogByID(sal_uInt32 nID) CPPUNIT_ASSERT(pDrawDoc); const OUString aFileName("foo"); pRetval = getSdAbstractDialogFactory()->CreateSdInsertPagesObjsDlg( - getViewShell()->GetActiveWindow(), + getViewShell()->GetFrameWeld(), pDrawDoc, nullptr, aFileName); diff --git a/sd/source/ui/dlg/inspagob.cxx b/sd/source/ui/dlg/inspagob.cxx index f46adcc0175d..02a012e7f9ac 100644 --- a/sd/source/ui/dlg/inspagob.cxx +++ b/sd/source/ui/dlg/inspagob.cxx @@ -28,43 +28,32 @@ #include <ViewShell.hxx> SdInsertPagesObjsDlg::SdInsertPagesObjsDlg( - vcl::Window* pWindow, const SdDrawDocument* pInDoc, + weld::Window* pWindow, const SdDrawDocument* pInDoc, SfxMedium* pSfxMedium, const OUString& rFileName ) - : ModalDialog(pWindow, "InsertSlidesDialog", - "modules/sdraw/ui/insertslidesdialog.ui") - , pMedium(pSfxMedium) - , mpDoc(pInDoc) - , rName(rFileName) + : GenericDialogController(pWindow, "modules/sdraw/ui/insertslidesdialog.ui", "InsertSlidesDialog") + , m_pMedium(pSfxMedium) + , m_pDoc(pInDoc) + , m_rName(rFileName) + , m_xLbTree(new SdPageObjsTLV(m_xBuilder->weld_tree_view("tree"))) + , m_xCbxLink(m_xBuilder->weld_check_button("links")) + , m_xCbxMasters(m_xBuilder->weld_check_button("backgrounds")) { - get(m_pLbTree, "tree"); - get(m_pCbxMasters, "backgrounds"); - get(m_pCbxLink, "links"); + m_xLbTree->set_size_request(m_xLbTree->get_approximate_digit_width() * 48, + m_xLbTree->get_height_rows(12)); - m_pLbTree->set_width_request(m_pLbTree->approximate_char_width() * 50); - m_pLbTree->set_height_request(m_pLbTree->GetTextHeight() * 12); + m_xLbTree->SetViewFrame( pInDoc->GetDocSh()->GetViewShell()->GetViewFrame() ); - m_pLbTree->SetViewFrame( pInDoc->GetDocSh()->GetViewShell()->GetViewFrame() ); - - m_pLbTree->SetSelectHdl( LINK( this, SdInsertPagesObjsDlg, SelectObjectHdl ) ); + m_xLbTree->connect_changed(LINK(this, SdInsertPagesObjsDlg, SelectObjectHdl)); // insert text - if( !pMedium ) - SetText( SdResId( STR_INSERT_TEXT ) ); + if (!m_pMedium) + m_xDialog->set_title(SdResId(STR_INSERT_TEXT)); Reset(); } SdInsertPagesObjsDlg::~SdInsertPagesObjsDlg() { - disposeOnce(); -} - -void SdInsertPagesObjsDlg::dispose() -{ - m_pLbTree.clear(); - m_pCbxLink.clear(); - m_pCbxMasters.clear(); - ModalDialog::dispose(); } /** @@ -73,39 +62,39 @@ void SdInsertPagesObjsDlg::dispose() */ void SdInsertPagesObjsDlg::Reset() { - if( pMedium ) + if( m_pMedium ) { - m_pLbTree->SetSelectionMode( SelectionMode::Multiple ); + m_xLbTree->set_selection_mode(SelectionMode::Multiple); // transfer ownership of Medium - m_pLbTree->Fill( mpDoc, pMedium, rName ); + m_xLbTree->Fill( m_pDoc, m_pMedium, m_rName ); } else { - Image aImgText(StockImage::Yes, BMP_DOC_TEXT); - m_pLbTree->InsertEntry( rName, aImgText, aImgText ); + OUString sImgText(BMP_DOC_TEXT); + m_xLbTree->InsertEntry(m_rName, sImgText); } - m_pCbxMasters->Check(); + m_xCbxMasters->set_active(true); } std::vector<OUString> SdInsertPagesObjsDlg::GetList( const sal_uInt16 nType ) { // With Draw documents, we have to return NULL on selection of the document - if( pMedium ) + if( m_pMedium ) { // to ensure that bookmarks are opened // (when the whole document is selected) - m_pLbTree->GetBookmarkDoc(); + m_xLbTree->GetBookmarkDoc(); // If the document is selected (too) or nothing is selected, // the whole document is inserted (but not more!) - if( m_pLbTree->GetSelectionCount() == 0 || - ( m_pLbTree->IsSelected( m_pLbTree->First() ) ) ) + std::unique_ptr<weld::TreeIter> xIter(m_xLbTree->make_iterator()); + if (!m_xLbTree->get_iter_first(*xIter) || m_xLbTree->is_selected(*xIter)) return std::vector<OUString>(); } - return m_pLbTree->GetSelectEntryList( nType ); + return m_xLbTree->GetSelectEntryList( nType ); } /** @@ -113,7 +102,7 @@ std::vector<OUString> SdInsertPagesObjsDlg::GetList( const sal_uInt16 nType ) */ bool SdInsertPagesObjsDlg::IsLink() { - return m_pCbxLink->IsChecked(); + return m_xCbxLink->get_active(); } /** @@ -121,18 +110,15 @@ bool SdInsertPagesObjsDlg::IsLink() */ bool SdInsertPagesObjsDlg::IsRemoveUnnessesaryMasterPages() const { - return m_pCbxMasters->IsChecked(); + return m_xCbxMasters->get_active(); } /** * Enabled and selects end-color-LB */ -IMPL_LINK_NOARG(SdInsertPagesObjsDlg, SelectObjectHdl, SvTreeListBox*, void) +IMPL_LINK_NOARG(SdInsertPagesObjsDlg, SelectObjectHdl, weld::TreeView&, void) { - if( m_pLbTree->IsLinkableSelected() ) - m_pCbxLink->Enable(); - else - m_pCbxLink->Disable(); + m_xCbxLink->set_sensitive(m_xLbTree->IsLinkableSelected()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx index cf1ff8e9bab8..0818046394b1 100644 --- a/sd/source/ui/dlg/sddlgfact.cxx +++ b/sd/source/ui/dlg/sddlgfact.cxx @@ -89,7 +89,10 @@ short AbstractSdInsertLayerDlg_Impl::Execute() return m_xDlg->run(); } -IMPL_ABSTDLG_BASE(AbstractSdInsertPagesObjsDlg_Impl); +short AbstractSdInsertPagesObjsDlg_Impl::Execute() +{ + return m_xDlg->run(); +} short AbstractMorphDlg_Impl::Execute() { @@ -294,17 +297,17 @@ void AbstractSdInsertLayerDlg_Impl::SetHelpId( const OString& rHelpId ) std::vector<OUString> AbstractSdInsertPagesObjsDlg_Impl::GetList(const sal_uInt16 nType) { - return pDlg->GetList(nType); + return m_xDlg->GetList(nType); } bool AbstractSdInsertPagesObjsDlg_Impl::IsLink() { - return pDlg->IsLink(); + return m_xDlg->IsLink(); } bool AbstractSdInsertPagesObjsDlg_Impl::IsRemoveUnnessesaryMasterPages() const { - return pDlg->IsRemoveUnnessesaryMasterPages(); + return m_xDlg->IsRemoveUnnessesaryMasterPages(); } void AbstractMorphDlg_Impl::SaveSettings() const @@ -406,9 +409,9 @@ VclPtr<AbstractSdInsertLayerDlg> SdAbstractDialogFactory_Impl::CreateSdInsertLay return VclPtr<AbstractSdInsertLayerDlg_Impl>::Create(std::make_unique<SdInsertLayerDlg>(pParent, rInAttrs, bDeletable, aStr)); } -VclPtr<AbstractSdInsertPagesObjsDlg> SdAbstractDialogFactory_Impl::CreateSdInsertPagesObjsDlg( vcl::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName ) +VclPtr<AbstractSdInsertPagesObjsDlg> SdAbstractDialogFactory_Impl::CreateSdInsertPagesObjsDlg(weld::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName) { - return VclPtr<AbstractSdInsertPagesObjsDlg_Impl>::Create( VclPtr<SdInsertPagesObjsDlg>::Create( pParent, pDoc, pSfxMedium, rFileName ) ); + return VclPtr<AbstractSdInsertPagesObjsDlg_Impl>::Create(std::make_unique<SdInsertPagesObjsDlg>(pParent, pDoc, pSfxMedium, rFileName)); } VclPtr<AbstractMorphDlg> SdAbstractDialogFactory_Impl::CreateMorphDlg(weld::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2) diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx index ebf4e4980b3c..619e8cb4a319 100644 --- a/sd/source/ui/dlg/sddlgfact.hxx +++ b/sd/source/ui/dlg/sddlgfact.hxx @@ -237,7 +237,14 @@ public: class SdInsertPagesObjsDlg; class AbstractSdInsertPagesObjsDlg_Impl : public AbstractSdInsertPagesObjsDlg { - DECL_ABSTDLG_BASE(AbstractSdInsertPagesObjsDlg_Impl,SdInsertPagesObjsDlg) +private: + std::unique_ptr<SdInsertPagesObjsDlg> m_xDlg; +public: + AbstractSdInsertPagesObjsDlg_Impl(std::unique_ptr<SdInsertPagesObjsDlg> pDlg) + : m_xDlg(std::move(pDlg)) + { + } + virtual short Execute() override; virtual std::vector<OUString> GetList ( const sal_uInt16 nType ) override; virtual bool IsLink() override; virtual bool IsRemoveUnnessesaryMasterPages() const override; @@ -335,7 +342,7 @@ public: virtual VclPtr<AbstractSdModifyFieldDlg> CreateSdModifyFieldDlg(weld::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet) override; virtual VclPtr<AbstractSdSnapLineDlg> CreateSdSnapLineDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override; virtual VclPtr<AbstractSdInsertLayerDlg> CreateSdInsertLayerDlg(weld::Window* pParent, const SfxItemSet& rInAttrs, bool bDeletable, const OUString& aStr) override; - virtual VclPtr<AbstractSdInsertPagesObjsDlg> CreateSdInsertPagesObjsDlg(vcl::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName ) override; + virtual VclPtr<AbstractSdInsertPagesObjsDlg> CreateSdInsertPagesObjsDlg(weld::Window* pParent, const SdDrawDocument* pDoc, SfxMedium* pSfxMedium, const OUString& rFileName ) override; virtual VclPtr<AbstractMorphDlg> CreateMorphDlg(weld::Window* pParent, const SdrObject* pObj1, const SdrObject* pObj2) override; virtual VclPtr<SfxAbstractTabDialog> CreateSdOutlineBulletTabDlg(weld::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView) override; virtual VclPtr<SfxAbstractTabDialog> CreateSdParagraphTabDlg(weld::Window* pParent, const SfxItemSet* pAttr) override; diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index 045d3b2614e7..571d8ac36e32 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -1423,4 +1423,262 @@ SdPageObjsTLB::IconProvider::IconProvider() { } +SdPageObjsTLV::SdPageObjsTLV(std::unique_ptr<weld::TreeView> xTreeView) + : m_xTreeView(std::move(xTreeView)) + , m_xAccel(::svt::AcceleratorExecute::createAcceleratorHelper()) + , m_pDoc(nullptr) + , m_pBookmarkDoc(nullptr) + , m_pMedium(nullptr) + , m_pOwnMedium(nullptr) + , m_bLinkableSelected(false) + , m_bShowAllShapes(false) +{ + m_xTreeView->connect_expanding(LINK(this, SdPageObjsTLV, RequestingChildrenHdl)); +} + +OUString SdPageObjsTLV::GetObjectName( + const SdrObject* pObject, + const bool bCreate) const +{ + OUString aRet; + + if ( pObject ) + { + aRet = pObject->GetName(); + + if (aRet.isEmpty() && dynamic_cast<const SdrOle2Obj* >(pObject) != nullptr) + aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName(); + } + + if (bCreate + && m_bShowAllShapes + && aRet.isEmpty() + && pObject!=nullptr) + { + aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME); + aRet = aRet.replaceFirst("%1", OUString::number(pObject->GetOrdNum() + 1)); + } + + return aRet; +} + +std::vector<OUString> SdPageObjsTLV::GetSelectEntryList(const int nDepth) const +{ + std::vector<OUString> aEntries; + + m_xTreeView->selected_foreach([this, nDepth, &aEntries](weld::TreeIter& rEntry){ + int nListDepth = m_xTreeView->get_iter_depth(rEntry); + if (nListDepth == nDepth) + aEntries.push_back(m_xTreeView->get_text(rEntry)); + }); + + return aEntries; +} + +/** + * Checks if it is a draw file and opens the BookmarkDoc depending of + * the provided Docs + */ +SdDrawDocument* SdPageObjsTLV::GetBookmarkDoc(SfxMedium* pMed) +{ + if ( + !m_pBookmarkDoc || + (pMed && (!m_pOwnMedium || m_pOwnMedium->GetName() != pMed->GetName())) + ) + { + // create a new BookmarkDoc if now one exists or if a new Medium is provided + if (m_pOwnMedium != pMed) + { + CloseBookmarkDoc(); + } + + if (pMed) + { + // it looks that it is undefined if a Medium was set by Fill() already + DBG_ASSERT( !m_pMedium, "SfxMedium confusion!" ); + delete m_pMedium; + m_pMedium = nullptr; + + // take over this Medium (currently used only be Navigator) + m_pOwnMedium = pMed; + } + + DBG_ASSERT( m_pMedium || pMed, "No SfxMedium provided!" ); + + if( pMed ) + { + // in this mode the document is also owned and controlled by this instance + m_xBookmarkDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::STANDARD, true, DocumentType::Impress); + if (m_xBookmarkDocShRef->DoLoad(pMed)) + m_pBookmarkDoc = m_xBookmarkDocShRef->GetDoc(); + else + m_pBookmarkDoc = nullptr; + } + else if ( m_pMedium ) + // in this mode the document is owned and controlled by the SdDrawDocument + // it can be released by calling the corresponding CloseBookmarkDoc method + // successful creation of a document makes this the owner of the medium + m_pBookmarkDoc = const_cast<SdDrawDocument*>(m_pDoc)->OpenBookmarkDoc(m_pMedium); + + if ( !m_pBookmarkDoc ) + { + std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xTreeView.get(), + VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR))); + xErrorBox->run(); + m_pMedium = nullptr; //On failure the SfxMedium is invalid + } + } + + return m_pBookmarkDoc; +} + +/** + * Entries are inserted only by request (double click) + */ +IMPL_LINK(SdPageObjsTLV, RequestingChildrenHdl, weld::TreeIter&, rFileEntry, bool) +{ + if (!m_xTreeView->iter_has_child(rFileEntry)) + { + if (GetBookmarkDoc()) + { + SdrObject* pObj = nullptr; + + OUString sImgPage(BMP_PAGE); + OUString sImgPageObjs(BMP_PAGEOBJS); + OUString sImgObjects(BMP_OBJECTS); + OUString sImgOle(BMP_OLE); + OUString sImgGraphic(BMP_GRAPHIC); + + // document name already inserted + + // only insert all "normal" ? slides with objects + sal_uInt16 nPage = 0; + const sal_uInt16 nMaxPages = m_pBookmarkDoc->GetPageCount(); + + std::unique_ptr<weld::TreeIter> xPageEntry; + while (nPage < nMaxPages) + { + SdPage* pPage = static_cast<SdPage*>(m_pBookmarkDoc->GetPage(nPage)); + if (pPage->GetPageKind() == PageKind::Standard) + { + OUString sId(OUString::number(1)); + m_xTreeView->insert(&rFileEntry, -1, &pPage->GetName(), &sId, + nullptr, nullptr, &sImgPage, false); + + if (!xPageEntry) + { + xPageEntry = m_xTreeView->make_iterator(&rFileEntry); + m_xTreeView->iter_children(*xPageEntry); + } + else + m_xTreeView->iter_next_sibling(*xPageEntry); + + SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups ); + + while( aIter.IsMore() ) + { + pObj = aIter.Next(); + OUString aStr( GetObjectName( pObj ) ); + if( !aStr.isEmpty() ) + { + if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == OBJ_OLE2 ) + { + m_xTreeView->insert(xPageEntry.get(), -1, &aStr, nullptr, + nullptr, nullptr, &sImgOle, false); + } + else if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == OBJ_GRAF ) + { + m_xTreeView->insert(xPageEntry.get(), -1, &aStr, nullptr, + nullptr, nullptr, &sImgGraphic, false); + } + else + { + m_xTreeView->insert(xPageEntry.get(), -1, &aStr, nullptr, + nullptr, nullptr, &sImgObjects, false); + } + } + } + if (m_xTreeView->iter_has_child(*xPageEntry)) + { + m_xTreeView->set_expander_image(*xPageEntry, sImgPageObjs); + } + } + nPage++; + } + } + } + return true; +} + +void SdPageObjsTLV::SetViewFrame(const SfxViewFrame* pViewFrame) +{ + sd::ViewShellBase* pBase = sd::ViewShellBase::GetViewShellBase(pViewFrame); + const css::uno::Reference< css::frame::XFrame > xFrame = pBase->GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(); + m_xAccel->init(::comphelper::getProcessComponentContext(), xFrame); +} + +/** + * Close and delete bookmark document + */ +void SdPageObjsTLV::CloseBookmarkDoc() +{ + if (m_xBookmarkDocShRef.is()) + { + m_xBookmarkDocShRef->DoClose(); + m_xBookmarkDocShRef.clear(); + + // Medium is owned by document, so it's destroyed already + m_pOwnMedium = nullptr; + } + else if (m_pBookmarkDoc) + { + DBG_ASSERT(!m_pOwnMedium, "SfxMedium confusion!"); + if (m_pDoc) + { + // The document owns the Medium, so the Medium will be invalid after closing the document + const_cast<SdDrawDocument*>(m_pDoc)->CloseBookmarkDoc(); + m_pMedium = nullptr; + } + } + else + { + // perhaps mpOwnMedium provided, but no successful creation of BookmarkDoc + delete m_pOwnMedium; + m_pOwnMedium = nullptr; + } + + m_pBookmarkDoc = nullptr; +} + +/** + * We insert only the first entry. Children are created on demand. + */ +void SdPageObjsTLV::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium, + const OUString& rDocName ) +{ + m_pDoc = pInDoc; + + // this object now owns the Medium + m_pMedium = pInMedium; + m_aDocName = rDocName; + + OUString sImgDoc(BMP_DOC_OPEN); + + OUString sId(OUString::number(1)); + // insert document name + m_xTreeView->insert(nullptr, -1, &m_aDocName, &sId, nullptr, nullptr, &sImgDoc, true); +} + +SdPageObjsTLV::~SdPageObjsTLV() +{ + if (m_pBookmarkDoc) + CloseBookmarkDoc(); + else + { + // no document was created from mpMedium, so this object is still the owner of it + delete m_pMedium; + } + m_xAccel.reset(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index 7702ece5925e..56e1ef51ad9c 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -323,7 +323,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) mpDocSh->SetWaitCursor( false ); SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - vcl::Window* pParent = mpViewShell ? mpViewShell->GetActiveWindow() : nullptr; + weld::Window* pParent = mpViewShell ? mpViewShell->GetFrameWeld() : nullptr; ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( pFact->CreateSdInsertPagesObjsDlg(pParent, mpDoc, pMedium, aFile) ); sal_uInt16 nRet = pDlg->Execute(); @@ -405,7 +405,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) { SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( pFact->CreateSdInsertPagesObjsDlg(mpViewShell->GetActiveWindow(), mpDoc, nullptr, aFile) ); + ScopedVclPtr<AbstractSdInsertPagesObjsDlg> pDlg( pFact->CreateSdInsertPagesObjsDlg(mpViewShell->GetFrameWeld(), mpDoc, nullptr, aFile) ); mpDocSh->SetWaitCursor( false ); diff --git a/sd/source/ui/inc/inspagob.hxx b/sd/source/ui/inc/inspagob.hxx index 187cd6b102bf..e31122b15232 100644 --- a/sd/source/ui/inc/inspagob.hxx +++ b/sd/source/ui/inc/inspagob.hxx @@ -20,33 +20,29 @@ #ifndef INCLUDED_SD_SOURCE_UI_INC_INSPAGOB_HXX #define INCLUDED_SD_SOURCE_UI_INC_INSPAGOB_HXX -#include <vcl/button.hxx> -#include <vcl/dialog.hxx> +#include <vcl/weld.hxx> #include "sdtreelb.hxx" class SdDrawDocument; -class SdInsertPagesObjsDlg : public ModalDialog +class SdInsertPagesObjsDlg : public weld::GenericDialogController { private: - VclPtr<SdPageObjsTLB> m_pLbTree; - VclPtr<CheckBox> m_pCbxLink; - VclPtr<CheckBox> m_pCbxMasters; + SfxMedium* const m_pMedium; + const SdDrawDocument* m_pDoc; + const OUString& m_rName; - SfxMedium* const pMedium; - const SdDrawDocument* mpDoc; - const OUString& rName; + std::unique_ptr<SdPageObjsTLV> m_xLbTree; + std::unique_ptr<weld::CheckButton> m_xCbxLink; + std::unique_ptr<weld::CheckButton> m_xCbxMasters; void Reset(); - DECL_LINK( SelectObjectHdl, SvTreeListBox*, void ); + DECL_LINK(SelectObjectHdl, weld::TreeView&, void); public: - SdInsertPagesObjsDlg( vcl::Window* pParent, - const SdDrawDocument* pDoc, - SfxMedium* pSfxMedium, - const OUString& rFileName ); - virtual ~SdInsertPagesObjsDlg() override; - virtual void dispose() override; + SdInsertPagesObjsDlg(weld::Window* pParent, const SdDrawDocument* pDoc, + SfxMedium* pSfxMedium, const OUString& rFileName); + virtual ~SdInsertPagesObjsDlg() override; /** returns the list nType == 0 -> pages diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx index d32d23666162..00e30ac7cf8b 100644 --- a/sd/source/ui/inc/sdtreelb.hxx +++ b/sd/source/ui/inc/sdtreelb.hxx @@ -23,6 +23,7 @@ #include <pres.hxx> #include <sddllapi.h> #include <vcl/treelistbox.hxx> +#include <vcl/weld.hxx> #include <svl/urlbmk.hxx> #include <tools/ref.hxx> #include "sdxfer.hxx" @@ -296,6 +297,111 @@ private: SdrObject& rObject) const; }; +class SD_DLLPUBLIC SdPageObjsTLV +{ +private: + std::unique_ptr<weld::TreeView> m_xTreeView; + std::unique_ptr<::svt::AcceleratorExecute> m_xAccel; + const SdDrawDocument* m_pDoc; + SdDrawDocument* m_pBookmarkDoc; + SfxMedium* m_pMedium; + SfxMedium* m_pOwnMedium; + bool m_bLinkableSelected; + bool m_bShowAllShapes; + OUString m_aDocName; + ::sd::DrawDocShellRef m_xBookmarkDocShRef; ///< for the loading of bookmarks + + /** Return the name of the object. When the object has no user supplied + name and the bCreate flag is <TRUE/> then a name is created + automatically. Additionally the mbShowAllShapes flag is taken into + account when there is no user supplied name. When this flag is + <FALSE/> then no name is created. + @param pObject + When this is NULL then an empty string is returned, regardless + of the value of bCreate. + @param bCreate + This flag controls for objects without user supplied name + whether a name is created. When a name is created then this + name is not stored in the object. + */ + OUString GetObjectName ( + const SdrObject* pObject, + const bool bCreate = true) const; + + void CloseBookmarkDoc(); + + DECL_LINK(RequestingChildrenHdl, weld::TreeIter&, bool); + +public: + + SdPageObjsTLV(std::unique_ptr<weld::TreeView> xTreeview); + ~SdPageObjsTLV(); + + void set_size_request(int nWidth, int nHeight) + { + m_xTreeView->set_size_request(nWidth, nHeight); + } + + float get_approximate_digit_width() const + { + return m_xTreeView->get_approximate_digit_width(); + } + + int get_height_rows(int nRows) const + { + return m_xTreeView->get_height_rows(nRows); + } + + void set_selection_mode(SelectionMode eMode) + { + m_xTreeView->set_selection_mode(eMode); + } + + std::vector<int> get_selected_rows() const + { + return m_xTreeView->get_selected_rows(); + } + + void connect_changed(const Link<weld::TreeView&, void>& rLink) + { + m_xTreeView->connect_changed(rLink); + } + + bool is_selected(const weld::TreeIter& rIter) const + { + return m_xTreeView->is_selected(rIter); + } + + bool get_iter_first(weld::TreeIter& rIter) const + { + return m_xTreeView->get_iter_first(rIter); + } + + std::unique_ptr<weld::TreeIter> make_iterator() + { + return m_xTreeView->make_iterator(); + } + + void SetViewFrame(const SfxViewFrame* pViewFrame); + + void Fill(const SdDrawDocument*, SfxMedium* pSfxMedium, const OUString& rDocName); + + /** return selected entries + nDepth == 0 -> pages + nDepth == 1 -> objects */ + + std::vector<OUString> GetSelectEntryList(const int nDepth) const; + + SdDrawDocument* GetBookmarkDoc(SfxMedium* pMedium = nullptr); + + bool IsLinkableSelected() const { return m_bLinkableSelected; } + + void InsertEntry(const OUString &rName, const OUString &rExpander) + { + m_xTreeView->insert(nullptr, -1, &rName, nullptr, nullptr, nullptr, &rExpander, false); + } +}; + #endif // INCLUDED_SD_SOURCE_UI_INC_SDTREELB_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/uiconfig/sdraw/ui/insertslidesdialog.ui b/sd/uiconfig/sdraw/ui/insertslidesdialog.ui index fd4f6bc1635c..8b27da390f02 100644 --- a/sd/uiconfig/sdraw/ui/insertslidesdialog.ui +++ b/sd/uiconfig/sdraw/ui/insertslidesdialog.ui @@ -1,13 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sd"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name expander --> + <column type="GdkPixbuf"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkDialog" id="InsertSlidesDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="insertslidesdialog|InsertSlidesDialog">Insert Slides/Objects</property> + <property name="modal">True</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -109,13 +122,46 @@ </packing> </child> <child> - <object class="sdlo-SdPageObjsTLB" id="tree:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="SdPageObjsTLB-selection1"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="tree"> + <property name="width_request">-1</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="show_expanders">True</property> + <property name="search_column">1</property> + <property name="enable_tree_lines">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Macro Library List-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/> + <attributes> + <attribute name="pixbuf">0</attribute> + </attributes> + </child> + <child> + <object class="GtkCellRendererText" id="cellrenderertext2"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> |