/* -*- 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 .
*/
/** * Create string for showing the page number in the statusbar * * @param nPhyNum The physical page number * @param nVirtNum The logical page number (user-assigned) * @param rPgStr User-defined page name (will be shown if different from logical page number) * * @return OUString Formatted string: Page 1 of 10 (Page 1 of 8 to print OR Page nVirtNumv/rPgStr)
**/
OUString SwView::GetPageStr(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
{ // Show user-defined page number in brackets if any.
OUString extra; if (!rPgStr.isEmpty() && std::u16string_view(OUString::number(nPhyNum)) != rPgStr)
extra = rPgStr; elseif (nPhyNum != nVirtNum)
extra = OUString::number(nVirtNum);
// #i123922# determine if we really want to insert or replace the graphic at a selected object constbool bReplaceMode(rShell.HasSelection() && SelectionType::Frame == rShell.GetSelectionType());
if(bReplaceMode)
{ // #i123922# Do same as in D&D, ReRead graphic and all is done
rShell.ReRead(
bLink ? rPath : OUString(),
bLink ? rFilter : OUString(),
&aGraphic);
} else
{
rShell.StartAction(); if( bLink )
{
SwDocShell* pDocSh = GetDocShell();
INetURLObject aTemp(
pDocSh->HasName() ?
pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ) :
OUString());
// #i123922# determine if we really want to insert or replace the graphic at a selected object constbool bReplaceMode(rSh.HasSelection() && SelectionType::Frame == rSh.GetSelectionType());
// format not equal to current filter (with autodetection) if( nError == ERRCODE_GRFILTER_FORMATERROR )
nError = InsertGraphic( aFileName, OUString(), bAsLink, &GraphicFilter::GetGraphicFilter() );
// #i123922# no new FrameFormat for replace mode, only when new object was created, // else this would reset the current setting for the frame holding the graphic if ( !bReplaceMode && rSh.IsFrameSelected() )
{
SwFrameFormat* pFormat = pDoc->FindFrameFormatByName( sGraphicFormat ); if(!pFormat)
pFormat = pDoc->MakeFrameFormat(sGraphicFormat,
pDocShell->GetDoc()->GetDfltFrameFormat(), false);
rSh.SetFrameFormat( pFormat );
}
case FN_LINE_NUMBERING_DLG:
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateVclSwViewDialog(*this));
VclAbstractDialog::AsyncContext aContext;
aContext.maEndDialogFn = [](sal_Int32){};
pDlg->StartExecuteAsync(aContext); break;
} case FN_EDIT_LINK_DLG:
EditLinkDlg(); break; case SID_REFRESH_VIEW:
GetEditWin().Invalidate();
m_pWrtShell->Reformat(); break; case FN_PAGEUP: case FN_PAGEUP_SEL: case FN_PAGEDOWN: case FN_PAGEDOWN_SEL:
{
tools::Rectangle aVis( GetVisArea() );
SwEditWin& rTmpWin = GetEditWin(); if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
PageUpCursor(FN_PAGEUP_SEL == nSlot); else
PageDownCursor(FN_PAGEDOWN_SEL == nSlot);
rReq.SetReturnValue(SfxBoolItem(nSlot,
aVis != GetVisArea())); //#i42732# - notify the edit window that from now on we do not use the input language
rTmpWin.SetUseInputLanguage( false );
} break; case SID_ZOOM_IN: case SID_ZOOM_OUT:
{
sal_uInt16 nFact = m_pWrtShell->GetViewOptions()->GetZoom(); if (SID_ZOOM_IN == nSlot)
nFact = basegfx::zoomtools::zoomIn(nFact); else
nFact = basegfx::zoomtools::zoomOut(nFact);
SetZoom(SvxZoomType::PERCENT, nFact);
} break; case FN_TO_PREV_PAGE: case FN_TO_NEXT_PAGE:
{
sal_uInt16 nPage = 0; if (m_pWrtShell->IsCursorVisible())
nPage = m_pWrtShell->GetCursor()->GetPageNum(); else
{
SwFrame* pPageFrame = m_pWrtShell->Imp()->GetFirstVisPage(m_pWrtShell->GetOut()); if (pPageFrame)
nPage = pPageFrame->GetPhyPageNum();
} if (nPage != 0)
{
sal_uInt16 nOldPage(nPage); if (FN_TO_PREV_PAGE == nSlot && nPage > 1)
nPage--; elseif (FN_TO_NEXT_PAGE == nSlot && nPage < m_pWrtShell->GetPageCount())
nPage++; if (nPage != nOldPage)
{
m_pWrtShell->LockPaint(LockPaintReason::GotoPage); if (IsDrawMode())
LeaveDrawCreate();
m_pWrtShell->EnterStdMode();
m_pWrtShell->GotoPage(nPage, true); // set visible area (borrowed from SwView::PhyPageUp/Down) const Point aPt(m_aVisArea.Left(), m_pWrtShell->GetPagePos(nPage).Y());
Point aAlPt(AlignToPixel(aPt)); if(aPt.Y() != aAlPt.Y())
aAlPt.AdjustY(3 * GetEditWin().PixelToLogic(Size(0, 1)).Height());
SetVisArea(aAlPt);
m_pWrtShell->UnlockPaint();
}
}
} break; case FN_SELECTION_CYCLE:
{ if (m_pWrtShell->IsSelFrameMode()) break; if (!m_pWrtShell->IsStdMode())
m_pWrtShell->EnterStdMode();
SwShellCursor *pCursor = m_pWrtShell->SwCursorShell::GetCursor_();
Point CurrMarkPt = pCursor->GetMkPos();
Point CurrPointPt = pCursor->GetPtPos();
sal_uInt16 nStep = m_aSelectCycle.nStep; if (nStep && (CurrMarkPt != m_aSelectCycle.m_MarkPt || CurrPointPt != m_aSelectCycle.m_PointPt))
nStep = 0; switch(nStep)
{ case 0:
m_aSelectCycle.m_pInitialCursor = CurrPointPt;
m_pWrtShell->SwCursorShell::ClearMark();
m_pWrtShell->SelWrd(&CurrPointPt); break; case 1:
m_pWrtShell->SelSentence(&CurrPointPt); break; case 2:
m_pWrtShell->SelPara(&CurrPointPt); break; case 3:
m_pWrtShell->SwCursorShell::ClearMark();
m_pWrtShell->SwCursorShell::SetCursor(m_aSelectCycle.m_pInitialCursor); break;
}
nStep++;
nStep %= 4;
pCursor = m_pWrtShell->SwCursorShell::GetCursor_();
m_aSelectCycle.m_MarkPt = pCursor->GetMkPos();
m_aSelectCycle.m_PointPt = pCursor->GetPtPos();
m_aSelectCycle.nStep = nStep;
} break; case FN_REDLINE_ON: case FN_TRACK_CHANGES_IN_THIS_VIEW: case FN_TRACK_CHANGES_IN_ALL_VIEWS:
{
std::optional<bool> oOn; if( pArgs &&
SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ))
{
oOn = static_cast<const SfxBoolItem*>(pItem)->GetValue();
} elseif (nSlot == FN_TRACK_CHANGES_IN_THIS_VIEW || nSlot == FN_TRACK_CHANGES_IN_ALL_VIEWS)
{
oOn = true;
}
if (oOn.has_value())
{
IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword(); if( aPasswd.hasElements() )
{
OSL_ENSURE( !oOn.value(), "SwView::Execute(): password set and redlining off doesn't match!" );
// xmlsec05: new password dialog
SfxPasswordDialog aPasswdDlg(GetFrameWeld());
aPasswdDlg.SetMinLen(1); //#i69751# the result of Execute() can be ignored
(void)aPasswdDlg.run();
OUString sNewPasswd(aPasswdDlg.GetPassword());
// password verification bool bPasswordOk = false; if (aPasswd.getLength() == 1 && aPasswd[0] == 1)
{ // dummy RedlinePassword from OOXML import: get real password info // from the grab-bag to verify the password const css::uno::Sequence< css::beans::PropertyValue > aDocumentProtection = static_cast<SfxObjectShell*>(GetDocShell())->
GetDocumentProtectionFromGrabBag();
bPasswordOk = // password is ok, if there is no DocumentProtection in the GrabBag, // i.e. the dummy RedlinePassword imported from an OpenDocument file
!aDocumentProtection.hasElements() || // verify password with the password info imported from OOXML
::comphelper::DocPasswordHelper::IsModifyPasswordCorrect(sNewPasswd,
::comphelper::DocPasswordHelper::ConvertPasswordInfo ( aDocumentProtection ) );
} else
{ // the simplified RedlinePassword
Sequence <sal_Int8> aNewPasswd = rIDRA.GetRedlinePassword();
SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
bPasswordOk = SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd);
}
if( pArgs &&
SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem))
{ // tdf#125754 avoid recursive layout // because all views share the layout, have to use AllAction constbool bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
m_pWrtShell->StartAllAction(); // always show redline insertions in Hide Changes mode if ( m_pWrtShell->GetViewOptions()->IsShowChangesInMargin() &&
m_pWrtShell->GetViewOptions()->IsShowChangesInMargin2() )
{
GetDocShell()->GetDoc()->GetDocumentRedlineManager().HideAll(/*bDeletion=*/!bShow);
}
m_pWrtShell->GetLayout()->SetHideRedlines( !bShow );
m_pWrtShell->EndAllAction(); if (m_pWrtShell->IsRedlineOn())
m_pWrtShell->SetInsMode();
GetDocShell()->Broadcast(SfxHint(SfxHintId::SwRedlineShowChanged));
} break; case FN_MAILMERGE_SENDMAIL_CHILDWINDOW: case FN_REDLINE_ACCEPT:
GetViewFrame().ToggleChildWindow(nSlot); break; case FN_REDLINE_ACCEPT_DIRECT: case FN_REDLINE_REJECT_DIRECT: case FN_REDLINE_ACCEPT_TONEXT: case FN_REDLINE_REJECT_TONEXT: case FN_REDLINE_REINSTATE_DIRECT: case FN_REDLINE_REINSTATE_TONEXT:
{
SwDoc *pDoc = m_pWrtShell->GetDoc();
SwPaM *pCursor = m_pWrtShell->GetCursor(); const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
SwRedlineTable::size_type nRedline = SwRedlineTable::npos; if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET)
{ const sal_Int64 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue(); for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
{ if (nChangeId == rRedlineTable[i]->GetId())
nRedline = i;
}
}
if( pCursor->HasMark() && nRedline == SwRedlineTable::npos)
{ bool bAccept = FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot; bool bReinstate = nSlot == FN_REDLINE_REINSTATE_DIRECT || nSlot == FN_REDLINE_REINSTATE_TONEXT;
SwUndoId eUndoId = bAccept ? SwUndoId::ACCEPT_REDLINE : SwUndoId::REJECT_REDLINE;
SwWrtShell& rSh = GetWrtShell();
SwRewriter aRewriter; bool bTableSelection = rSh.IsTableMode(); if ( bTableSelection )
{
aRewriter.AddRule(UndoArg1, SwResId( STR_REDLINE_TABLECHG ));
rSh.StartUndo( eUndoId, &aRewriter);
} if ( bAccept )
m_pWrtShell->AcceptRedlinesInSelection(); elseif (bReinstate)
{
m_pWrtShell->ReinstateRedlinesInSelection();
} else
m_pWrtShell->RejectRedlinesInSelection(); if ( bTableSelection )
rSh.EndUndo( eUndoId, &aRewriter);
} else
{ // We check for a redline at the start of the selection/cursor, not the point. // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the // point at the *end* of the redline and the mark at the start (so GetRedline // would return NULL if called on the point) const SwRangeRedline* pRedline = nullptr; if (nRedline != SwRedlineTable::npos)
{ // A redline was explicitly requested by specifying an // index, don't guess based on the cursor position.
// until next redline is not in the same row
SwTableBox* pTableBox = pRedline->Start()->GetNode().GetTableBox(); if ( !pTableBox || pTableBox->GetUpper() != pTabLine ) break;
// change only the cells with the same data
SwRedlineData aData(rRedlineTable[nRedline]->GetRedlineData(0));
// start from the first redline of the table to handle all the // cells of the changed column(s) while ( nRedline )
{
pRedline = rRedlineTable[nRedline-1];
SwTableBox* pTableBox = pRedline->Start()->GetNode().GetTableBox();
SwTableNode* pTableNode = pRedline->Start()->GetNode().FindTableNode();
// previous redline is not in the same table if ( !pTableBox || pTableNode != pTableNd ) break;
// until next redline is not in the same table
SwTableBox* pTableBox = pRedline->Start()->GetNode().GetTableBox();
SwTableNode* pTableNode = pRedline->Start()->GetNode().FindTableNode(); if ( !pTableBox || pTableNode != pTableNd ) break;
// skip cells which are not from the same author, same type change // or timestamp, i.e. keep only the cells of the same tracked // column insertion or deletion if ( !pRedline->GetRedlineData(0).CanCombine(aData) || // not a tracked cell change
RedlineType::None == pTableBox->GetRedlineType() )
{
++nRedline; continue;
}
if (pRedline && !bTableChange)
{ if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
m_pWrtShell->AcceptRedline(nRedline); elseif (nSlot == FN_REDLINE_REINSTATE_DIRECT || nSlot == FN_REDLINE_REINSTATE_TONEXT)
{
m_pWrtShell->ReinstateRedline(nRedline);
} else
m_pWrtShell->RejectRedline(nRedline);
}
} switch (nSlot)
{ case FN_REDLINE_ACCEPT_TONEXT: case FN_REDLINE_REJECT_TONEXT: case FN_REDLINE_REINSTATE_TONEXT: // Go to next change after accepting or rejecting one (tdf#101977)
GetViewFrame().GetDispatcher()->Execute(FN_REDLINE_NEXT_CHANGE, SfxCallMode::ASYNCHRON);
}
} break;
case FN_REDLINE_NEXT_CHANGE:
{ // If a parameter is provided, try going to the nth change, not to // the next one.
SwDoc* pDoc = m_pWrtShell->GetDoc(); const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
SwRedlineTable::size_type nRedline = SwRedlineTable::npos; if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET)
{ const sal_uInt32 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue(); for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
{ if (nChangeId == rRedlineTable[i]->GetId())
nRedline = i;
}
}
for( int i = 0; i < 2; ++i )
{ if( m_pWrtShell->GetTOXCount() == 1 )
++i;
while( m_pWrtShell->GotoPrevTOXBase() )
; // jump to the first "table of ..."
// if we are not in one, jump to next const SwTOXBase* pBase = m_pWrtShell->GetCurTOX(); if( !pBase )
{ if (m_pWrtShell->GotoNextTOXBase())
pBase = m_pWrtShell->GetCurTOX();
}
bool bAutoMarkApplied = false; while( pBase )
{ if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
{
m_pWrtShell->ApplyAutoMark();
bAutoMarkApplied = true;
} // pBase is needed only for the interface. Should be changed in future! (JP 1996)
m_pWrtShell->UpdateTableOf( *pBase );
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.