/* -*- 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 .
*/
// Filter the control characters out of the Outline-Entry
OUString SwNavigationPI::CleanEntry(const OUString& rEntry)
{ if (rEntry.isEmpty()) return rEntry;
OUStringBuffer aEntry(rEntry); for (sal_Int32 i = 0; i < rEntry.getLength(); ++i) if(aEntry[i] == 10 || aEntry[i] == 9)
aEntry[i] = 0x20;
return aEntry.makeStringAndClear();
}
// Execution of the drag operation with and without the children.
// After goto cancel the status frame selection staticvoid lcl_UnSelectFrame(SwWrtShell *pSh)
{ if (pSh->IsFrameSelected())
{
pSh->UnSelectFrame();
pSh->LeaveSelFrameMode();
}
}
// Filling of the list box for outline view or documents // The PI will be set to full size void SwNavigationPI::FillBox()
{ if(m_pContentWrtShell)
{
m_xContentTree->SetHiddenShell( m_pContentWrtShell );
m_xContentTree->Display( false );
} else
{
SwView *pView = GetCreateView(); if(!pView)
{
m_xContentTree->SetActiveShell(nullptr);
} elseif( pView != m_pActContView)
{
SwWrtShell* pWrtShell = pView->GetWrtShellPtr();
m_xContentTree->SetActiveShell(pWrtShell);
} else
m_xContentTree->Display( true );
m_pActContView = pView; if (m_pActContView)
m_xContentTree->UpdateTracking();
}
}
// Select handler of the toolboxes
IMPL_LINK(SwNavigationPI, ToolBoxSelectHdl, const OUString&, rCommand, void)
{
SwView *pView = GetCreateView(); if (!pView) return;
SwWrtShell &rSh = pView->GetWrtShell(); // Get MouseModifier for Outline-Move
int nFuncId = 0; bool bFocusToDoc = false; if (rCommand == "root")
{
m_xContentTree->ToggleToRoot();
} elseif (rCommand == "listbox")
{ if (ParentIsFloatingWindow(m_xNavigatorDlg))
{ if (IsZoomedIn())
{
ZoomOut();
} else
{
ZoomIn();
}
} return;
} // Functions that will trigger a direct action. elseif (rCommand == "footer")
{
rSh.MoveCursor(); const FrameTypeFlags eType = rSh.GetFrameType(nullptr,false); if (eType & FrameTypeFlags::FOOTER)
{ if (rSh.EndPg())
nFuncId = FN_END_OF_PAGE;
} elseif (rSh.GotoFooterText())
nFuncId = FN_TO_FOOTER;
bFocusToDoc = true;
} elseif (rCommand == "header")
{
rSh.MoveCursor(); const FrameTypeFlags eType = rSh.GetFrameType(nullptr,false); if (eType & FrameTypeFlags::HEADER)
{ if (rSh.SttPg())
nFuncId = FN_START_OF_PAGE;
} elseif (rSh.GotoHeaderText())
nFuncId = FN_TO_HEADER;
bFocusToDoc = true;
} elseif (rCommand == "anchor")
{
rSh.MoveCursor(); const FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,false); // Jump from the footnote to the anchor. if (eFrameType & FrameTypeFlags::FOOTNOTE)
{ if (rSh.GotoFootnoteAnchor())
nFuncId = FN_FOOTNOTE_TO_ANCHOR;
} // Otherwise, jump to the first footnote text; // go to the next footnote if this is not possible; // if this is also not possible got to the footnote before. else
{ if (rSh.GotoFootnoteText())
nFuncId = FN_FOOTNOTE_TO_ANCHOR; elseif (rSh.GotoNextFootnoteAnchor())
nFuncId = FN_NEXT_FOOTNOTE; elseif (rSh.GotoPrevFootnoteAnchor())
nFuncId = FN_PREV_FOOTNOTE;
}
bFocusToDoc = true;
} elseif (rCommand == "reminder")
{
rSh.GetView().GetViewFrame().GetDispatcher()->Execute(FN_SET_REMINDER, SfxCallMode::ASYNCHRON);
} elseif (rCommand == "movedown" ||
rCommand == "moveup" ||
rCommand == "edit")
{ if (IsGlobalMode())
m_xGlobalTree->ExecCommand(rCommand);
} elseif (rCommand == "contenttoggle" || rCommand == "globaltoggle")
{
ToggleTree(); bool bGlobalMode = IsGlobalMode();
m_pConfig->SetGlobalActive(bGlobalMode);
m_xGlobalToolBox->set_item_active(u"globaltoggle"_ustr, bGlobalMode);
} elseif (rCommand == "save")
{ bool bSave = rSh.IsGlblDocSaveLinks();
rSh.SetGlblDocSaveLinks( !bSave );
m_xGlobalToolBox->set_item_active(rCommand, !bSave);
} elseif (rCommand == "headings")
m_xContent5ToolBox->set_menu_item_active(u"headings"_ustr, !m_xContent5ToolBox->get_menu_item_active(u"headings"_ustr)); elseif (rCommand == "update")
m_xGlobalToolBox->set_menu_item_active(u"update"_ustr, !m_xGlobalToolBox->get_menu_item_active(u"update"_ustr)); elseif (rCommand == "insert")
m_xGlobalToolBox->set_menu_item_active(u"insert"_ustr, !m_xGlobalToolBox->get_menu_item_active(u"insert"_ustr));
if (nFuncId)
lcl_UnSelectFrame(&rSh); if (bFocusToDoc)
pView->GetEditWin().GrabFocus();
}
// Click handler of the toolboxes
IMPL_LINK(SwNavigationPI, ToolBoxClickHdl, const OUString&, rCommand, void)
{ if (!m_xGlobalToolBox->get_menu_item_active(rCommand)) return;
// In case of LOK, the xController may not a NavElementToolBoxControl if (comphelper::LibreOfficeKit::isActive() && !pToolBoxControl)
{
m_pNavigateByComboBox = nullptr;
} else
{
assert(pToolBoxControl);
m_pNavigateByComboBox = pToolBoxControl->GetComboBox();
SetContent3And4ToolBoxVisibility();
}
// Restore content tree settings before calling UpdateInitShow. UpdateInitShow calls Fillbox, // which calls Display and UpdateTracking. Incorrect outline levels could be displayed and // unexpected content tracking could occur if these content tree settings are not done before.
m_xContentTree->SetOutlineLevel(static_cast<sal_uInt8>(m_pConfig->GetOutlineLevel()));
m_xContentTree->SetOutlineTracking(static_cast<sal_uInt8>(m_pConfig->GetOutlineTracking())); for (ContentTypeId eCntTypeId : o3tl::enumrange<ContentTypeId>())
{ if (eCntTypeId != ContentTypeId::OUTLINE)
m_xContentTree->SetContentTypeTracking(
eCntTypeId, m_pConfig->IsContentTypeTrack(eCntTypeId));
}
m_xContent1ToolBox->set_help_id(HID_NAVIGATOR_TOOLBOX);
m_xContent2ToolBox->set_help_id(HID_NAVIGATOR_TOOLBOX);
m_xContent3ToolBox->set_help_id(HID_NAVIGATOR_TOOLBOX);
m_xContent4ToolBox->set_help_id(HID_NAVIGATOR_TOOLBOX);
m_xContent5ToolBox->set_help_id(HID_NAVIGATOR_TOOLBOX);
m_xContent6ToolBox->set_help_id(HID_NAVIGATOR_TOOLBOX);
m_xGlobalToolBox->set_help_id(HID_NAVIGATOR_GLOBAL_TOOLBOX);
m_xDocListBox->set_help_id(HID_NAVIGATOR_LISTBOX);
m_xDocListBox->set_size_request(42, -1); // set a nominal width so it takes width of surroundings
IMPL_LINK_NOARG(SwNavigationPI, GotoPageSpinButtonValueChangedHdl, weld::SpinButton&, void)
{ auto nPage = m_xGotoPageSpinButton->get_value();
SwView *pView = GetCreateView();
SwWrtShell &rSh = pView->GetWrtShell(); auto nPageCount = rSh.GetPageCount(); if (nPage > nPageCount)
{
nPage = nPageCount;
m_xGotoPageSpinButton->set_text(OUString::number(nPage));
}
rSh.LockView(true);
rSh.GotoPage(nPage, false); // adjust the visible area so that the top of the page is at the top of the view const Point aPt(pView->GetVisArea().Left(), rSh.GetPagePos(nPage).Y());
pView->SetVisArea(aPt);
rSh.LockView(false);
}
SwNavigationPI::~SwNavigationPI()
{ if (IsGlobalDoc() && !IsGlobalMode())
{
SwView *pView = GetCreateView();
SwWrtShell &rSh = pView->GetWrtShell(); if (!rSh.IsAllProtect())
pView->GetDocShell()->SetReadOnlyUI(false);
}
EndListening(*SfxGetpApp());
if (m_oObjectShell)
{ if (m_oObjectShell->Is())
(*m_oObjectShell)->DoClose();
m_oObjectShell.reset();
}
void SwNavigationPI::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState /*eState*/, const SfxPoolItem* /*pState*/)
{ switch (nSID)
{ case SID_DOCFULLNAME:
{
SwView *pActView = GetCreateView(); if(pActView)
{
SwWrtShell* pWrtShell = pActView->GetWrtShellPtr();
m_xContentTree->SetActiveShell(pWrtShell); if (IsGlobalDoc())
{
m_xGlobalToolBox->set_item_active(u"save"_ustr, pWrtShell->IsGlblDocSaveLinks());
}
} else
{
m_xContentTree->SetActiveShell(nullptr);
}
UpdateListBox();
} break; case FN_NAV_ELEMENT:
SetContent3And4ToolBoxVisibility();
[[fallthrough]]; case FN_STAT_PAGE:
{ if (SwView::GetMoveType() == NID_PGE)
{
SwView *pView = GetCreateView(); if (pView)
{
SwWrtShell& rSh = pView->GetWrtShell(); if (rSh.GetViewOptions()->IsMultipageView()) // maybe set the spin button text to the page that has the cursor? break;
SwVisiblePageNumbers aVisiblePageNumbers;
rSh.GetFirstLastVisPageNumbers(aVisiblePageNumbers, *pView);
m_xGotoPageSpinButton->set_text(OUString::number(aVisiblePageNumbers.nFirstPhy));
}
}
}
}
}
void SwNavigationPI::UpdateInitShow()
{ // if the parent isn't a float, then the navigator is displayed in // the sidebar or is otherwise docked. While the navigator could change // its size, the sidebar can not, and the navigator would just waste // space. Therefore disable this button. bool bParentIsFloatingWindow(ParentIsFloatingWindow(m_xNavigatorDlg));
m_xContent6ToolBox->set_item_sensitive(u"listbox"_ustr, bParentIsFloatingWindow); // show content if docked if (!bParentIsFloatingWindow && IsZoomedIn())
ZoomOut(); if (!IsZoomedIn())
FillBox();
}
if(m_xContentTree->IsActiveView())
{ //Either the name of the current Document or "Active Document".
m_xDocListBox->set_active(pActView ? nAct : --nCount);
} elseif(m_xContentTree->IsHiddenView())
{
m_xDocListBox->set_active(nCount);
} else
m_xDocListBox->set_active(nConstPos);
// toggle between showing the global tree or the content tree void SwNavigationPI::ToggleTree()
{ if (comphelper::LibreOfficeKit::isActive())
{
m_xGlobalTree->HideTree(); return;
}
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.