/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// Shape filter drop down menu.
mxToolbox->set_item_menu(u"shapes"_ustr, mxShapeMenu.get());
mxShapeMenu->connect_activate(LINK(this, SdNavigatorWin, ShapeFilterCallback));
mxTlbObjects->SetSdNavigator(this);
// DragTypeListBox
mxLbDocs->set_size_request(42, -1); // set a nominal width so it takes width of surroundings
mxLbDocs->connect_changed(LINK(this, SdNavigatorWin, SelectDocumentHdl));
void SdNavigatorWin::FirstFocus()
{ // set focus to listbox, otherwise it is in the toolbox which is only useful // for keyboard navigation
mxTlbObjects->grab_focus();
}
// tdf#139944 disable navigator in master mode if (const sd::DrawViewShell* pDrawViewShell = static_cast<::sd::DrawViewShell*>(pViewShell))
{ if (pDrawViewShell->GetEditMode() == EditMode::MasterPage)
{
m_xContainer->set_sensitive(false);
mxTlbObjects->clear();
RefreshDocumentLB(); return;
} else
m_xContainer->set_sensitive(true);
}
// Restore the 'ShowAllShapes' flag from the last time (in this session) // that the navigator was shown.
::sd::FrameView* pFrameView = pViewShell->GetFrameView(); if (pFrameView != nullptr)
mxTlbObjects->SetShowAllShapes(pFrameView->IsNavigatorShowingAllShapes(), false);
// Disable the shape filter drop down menu when there is a running slide // show. if (sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() )
&& !sd::SlideShow::IsInteractiveSlideshow( &pViewShell->GetViewShellBase() ) ) // IASS
mxToolbox->set_item_sensitive(u"shapes"_ustr, false); else
mxToolbox->set_item_sensitive(u"shapes"_ustr, true);
if( !mxTlbObjects->IsEqualToDoc( pDoc ) )
{
OUString aDocName = pDocShell->GetMedium()->GetName();
mxTlbObjects->clear();
mxTlbObjects->Fill( pDoc, false, aDocName ); // only normal pages
/** * DragType is set on dependence if a Drag is even possible. For example, * under certain circumstances, it is not allowed to drag graphics (#31038#).
*/
NavigatorDragType SdNavigatorWin::GetNavigatorDragType()
{
NavigatorDragType eDT = meDragType;
NavDocInfo* pInfo = GetDocInfo();
// if it is the active window, we jump to the page if( pInfo && pInfo->IsActive() )
{
OUString aStr(mxTlbObjects->get_cursor_text());
if( !aStr.isEmpty() )
{
sd::DrawDocShell* pDocShell = pInfo->mpDocShell; if (!pDocShell) returnfalse;
sd::ViewShell* pViewShell = pDocShell->GetViewShell(); if (!pViewShell) returnfalse;
SdrView* pDrawView = pViewShell->GetDrawView(); if (!pDrawView) returnfalse;
// Save the selected tree entries re-mark the objects in the view after navigation. auto vSelectedEntryIds = mxTlbObjects->GetSelectedEntryIds();
// Page entries in the tree have id value 1. Object entries have id value of // the address of the pointer to the object. constauto aCursorEntryId = mxTlbObjects->get_cursor_id(); auto nCursorEntryId = aCursorEntryId.toInt64();
SdrObject* pCursorEntryObject = weld::fromId<SdrObject*>(aCursorEntryId);
if (bIsCursorEntrySelected)
{ // Set a temporary name, if need be, so the object can be navigated to. bool bCursorEntryObjectHasEmptyName = false; if (nCursorEntryId != 1 && pCursorEntryObject
&& pCursorEntryObject->GetName().isEmpty())
{
bCursorEntryObjectHasEmptyName = true; bool bUndo = pCursorEntryObject->getSdrModelFromSdrObject().IsUndoEnabled();
pCursorEntryObject->getSdrModelFromSdrObject().EnableUndo(false);
pCursorEntryObject->SetName(aStr, false);
pCursorEntryObject->getSdrModelFromSdrObject().EnableUndo(bUndo);
}
// All objects are unmarked when navigating to an object.
SfxStringItem aItem(SID_NAVIGATOR_OBJECT, aStr);
mpBindings->GetDispatcher()->ExecuteList(SID_NAVIGATOR_OBJECT,
SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
// re-mark the objects if (bIsCursorEntrySelected)
{ // Mark the objects in the view that are selected in the Navigator tree. for (auto& rEntryId: vSelectedEntryIds)
{ if (rEntryId != "1")
{
SdrObject* pEntryObject = weld::fromId<SdrObject*>(rEntryId); if (pEntryObject)
pDrawView->MarkObj(pEntryObject, pDrawView->GetSdrPageView());
}
}
}
} elseif (nCursorEntryId != 1 && pCursorEntryObject)
{ // unmark
pDrawView->MarkObj(pCursorEntryObject, pDrawView->GetSdrPageView(), true);
}
// SID_NAVIGATOR_STATE invalidate is done in DrawViewShell::ExecNavigatorWin // and DrawDocShell::GotoBookmark. Update the bindings here to speed up Navigator // state update.
mpBindings->Update();
if (mxTlbObjects->IsNavigationGrabsFocus())
{ // moved here from SetGetFocusHdl. Reset the // focus only if something has been selected in the // document.
SfxViewShell* pCurSh = SfxViewShell::Current();
if ( pCurSh )
{
vcl::Window* pShellWnd = pCurSh->GetWindow(); if ( pShellWnd )
pShellWnd->GrabFocus();
}
// We navigated to an object, but the current shell may be // still the slide sorter. Explicitly try to grab the draw // shell focus, so follow-up operations work with the object // and not with the whole slide.
vcl::Window* pWindow = pViewShell->GetActiveWindow(); if (pWindow)
pWindow->GrabFocus();
}
}
}
} returnfalse;
}
// check if link or url is possible if( ( pInfo && !pInfo->HasName() ) || !mxTlbObjects->IsLinkableSelected() || ( meDragType != NAVIGATOR_DRAGTYPE_EMBEDDED ) )
{
meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
SetDragImage();
}
}
/** * Set DrageType and set image accordingly to it.
*/
IMPL_LINK(SdNavigatorWin, MenuSelectHdl, const OUString&, rIdent, void)
{
sal_uInt32 nMenuId = rIdent.toUInt32();
// get adjusted FileName
OUString aFileName( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
if (aFileName.isEmpty())
{ // show actual document again
maDropFileName = aFileName;
} else
{ // show dragged-in document
std::shared_ptr<const SfxFilter> pFilter;
ErrCode nErr = ERRCODE_NONE;
if ((pFilter && !nErr) || aFileName == maDropFileName)
{ // The medium may be opened with READ/WRITE. Therefore, we first // check if it contains a Storage.
std::unique_ptr<SfxMedium> xMedium(new SfxMedium(aFileName,
StreamMode::READ | StreamMode::NOCREATE));
if (xMedium->IsStorage())
{ // Now depending on mode: // mxTlbObjects->set_selection_mode(SelectionMode::Multiple); // handover of ownership of xMedium;
SdDrawDocument* pDropDoc = mxTlbObjects->GetBookmarkDoc(xMedium.release());
if (pDropDoc)
{
mxTlbObjects->clear();
maDropFileName = aFileName;
SfxMedium *pMedium = pDocShell->GetMedium();
aStr = pMedium ? pMedium->GetName() : OUString(); if( !aStr.isEmpty() )
aInfo.SetName( true ); else
aInfo.SetName( false ); // at the moment, we use the name of the shell again (i.e. // without path) since Koose thinks it is an error if the path // is shown in url notation!
aStr = pDocShell->GetName();
// for the sidebar to make the panel invisible when the shell type is outline or slide sorter void SdNavigatorWin::HandleContextChange(const vcl::EnumContext& eContext)
{ if (eContext.GetApplication() != vcl::EnumContext::Application::Impress) return;
::sd::DrawDocShell* pCurrentDocShell
= dynamic_cast<::sd::DrawDocShell*>(SfxObjectShell::Current()); if (!pCurrentDocShell) return;
const ::sd::DrawViewShell* pDrawViewShell
= static_cast<::sd::DrawViewShell*>(pCurrentDocShell->GetViewShell()); if (!pDrawViewShell) return;
// First if (nState & NavState::BtnFirstEnabled &&
!pNavigatorWin->mxToolbox->get_item_sensitive(u"first"_ustr))
pNavigatorWin->mxToolbox->set_item_sensitive(u"first"_ustr, true); if (nState & NavState::BtnFirstDisabled &&
pNavigatorWin->mxToolbox->get_item_sensitive(u"first"_ustr))
pNavigatorWin->mxToolbox->set_item_sensitive(u"first"_ustr, false);
// Prev if (nState & NavState::BtnPrevEnabled &&
!pNavigatorWin->mxToolbox->get_item_sensitive(u"previous"_ustr))
pNavigatorWin->mxToolbox->set_item_sensitive(u"previous"_ustr, true); if (nState & NavState::BtnPrevDisabled &&
pNavigatorWin->mxToolbox->get_item_sensitive(u"previous"_ustr))
pNavigatorWin->mxToolbox->set_item_sensitive(u"previous"_ustr, false);
// Last if (nState & NavState::BtnLastEnabled &&
!pNavigatorWin->mxToolbox->get_item_sensitive(u"last"_ustr))
pNavigatorWin->mxToolbox->set_item_sensitive(u"last"_ustr, true); if (nState & NavState::BtnLastDisabled &&
pNavigatorWin->mxToolbox->get_item_sensitive(u"last"_ustr))
pNavigatorWin->mxToolbox->set_item_sensitive(u"last"_ustr, false);
// Next if (nState & NavState::BtnNextEnabled &&
!pNavigatorWin->mxToolbox->get_item_sensitive(u"next"_ustr))
pNavigatorWin->mxToolbox->set_item_sensitive(u"next"_ustr, true); if (nState & NavState::BtnNextDisabled &&
pNavigatorWin->mxToolbox->get_item_sensitive(u"next"_ustr))
pNavigatorWin->mxToolbox->set_item_sensitive(u"next"_ustr, false);
if (nState & NavState::TableUpdate)
{ // InitTlb; is initiated by Slot if (maUpdateRequest && !pNavigatorWin->GetObjects().get_treeview().has_focus())
maUpdateRequest();
}
}
/** * ControllerItem for Navigator to show page in TreeLB
*/
SdPageNameControllerItem::SdPageNameControllerItem(
sal_uInt16 _nId,
SdNavigatorWin* pNavWin,
SfxBindings* _pBindings)
: SfxControllerItem( _nId, *_pBindings ),
pNavigatorWin( pNavWin )
{
}
// only if doc in LB is the active
NavDocInfo* pInfo = pNavigatorWin->GetDocInfo(); if( !(pInfo && pInfo->IsActive()) ) return;
// Without a test for marked objects the page name entry is not selected when there are no // marked objects. The HasSelectedChildren test is required when in 'Named Shapes' mode in // order to select the page name when none of the marked objects have a name. bool bDrawViewHasMarkedObjects = false; if (pInfo->GetDrawDocShell() && pInfo->GetDrawDocShell()->GetViewShell())
{ const SdrView* pDrawView = pInfo->GetDrawDocShell()->GetViewShell()->GetDrawView(); if (pDrawView && pDrawView->GetMarkedObjectList().GetMarkCount())
bDrawViewHasMarkedObjects = true;
}
if (!bDrawViewHasMarkedObjects || !pNavigatorWin->mxTlbObjects->HasSelectedChildren(aPageName))
{ if (pNavigatorWin->mxTlbObjects->get_selection_mode() == SelectionMode::Multiple)
{ // because otherwise it is always additional select
pNavigatorWin->mxTlbObjects->unselect_all();
}
pNavigatorWin->mxTlbObjects->SelectEntry( aPageName );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.