/* -*- 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 .
*/
if ( pAnnotationTextRange )
{ if ( GetDoc() != nullptr )
{ const SwPaM& rCurrPaM = GetCurrentShellCursor(); if (*rCurrPaM.Start() == *pAnnotationTextRange->Start()
&& *rCurrPaM.End() == *pAnnotationTextRange->End())
{ // Annotation range was passed in externally, and inserting the postit field shifted // its start/end positions right by one. Restore the original position for the range // start. This allows commenting on the placeholder character of the field. if (pAnnotationTextRange->Start()->GetContentIndex() > 0)
pAnnotationTextRange->Start()->AdjustContent(-1);
}
IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess(); auto pMark{pMarksAccess->makeAnnotationMark(*pAnnotationTextRange, SwMarkName())}; if (poAnchorStart)
{
poAnchorStart->emplace(pMark->GetMarkStart());
}
}
pAnnotationTextRange.reset();
}
EndUndo();
EndAllAction();
return isSuccess;
}
// Start the field update
void SwWrtShell::UpdateInputFields( SwInputFieldList* pLst )
{ // Go through the list of fields and updating
std::unique_ptr<SwInputFieldList> pTmp; if (!pLst)
{
pTmp.reset(new SwInputFieldList( this ));
pLst = pTmp.get();
}
// Listener class: will close InputField dialog if input field(s) // is(are) deleted (for instance, by an extension) after the dialog shows up. // Otherwise, the for loop in SwWrtShell::UpdateInputFields will crash when doing: // 'pTmp->GetField( i )->GetTyp()->UpdateFields();' // on a deleted field. class FieldDeletionListener : public SvtListener
{ public:
FieldDeletionListener(AbstractFieldInputDlg* pInputFieldDlg, SwField* pField)
: mpInputFieldDlg(pInputFieldDlg)
, mpFormatField(nullptr)
{
SwInputField *const pInputField(dynamic_cast<SwInputField*>(pField));
SwSetExpField *const pSetExpField(dynamic_cast<SwSetExpField*>(pField));
virtualvoid Notify(const SfxHint& rHint) override
{ // Input field has been deleted: better to close the dialog if(rHint.GetId() == SfxHintId::Dying)
{
mpFormatField = nullptr;
mpInputFieldDlg->EndDialog(RET_CANCEL);
}
} private:
VclPtr<AbstractFieldInputDlg> mpInputFieldDlg;
SwFormatField* mpFormatField;
};
}
// Start input dialog for a specific field bool SwWrtShell::StartInputFieldDlg(SwField* pField, bool bPrevButton, bool bNextButton,
weld::Widget* pParentWin, SwWrtShell::FieldDialogPressedButton* pPressedButton)
{
// Since the cross reference and bibliography mark move the cursor, // only select the field if it's not a Ctrl+Click if (!bExecHyperlinks
|| (SwFieldIds::GetRef != rField.GetTyp()->Which()
&& SwFieldIds::TableOfAuthorities != rField.GetTyp()->Which()))
{
StartAllAction();
Right( SwCursorSkipMode::Chars, true, 1, false ); // Select the field.
NormalizePam();
EndAllAction();
}
case SwFieldIds::TableOfAuthorities:
{ if (!bExecHyperlinks) break; // Since it's not a Ctrl+Click, do not jump anywhere
Point vStartPoint = GetCursor_()->GetPtPos(); const SwAuthorityField* pField = static_cast<const SwAuthorityField*>(&rField);
if (auto targetType = pField->GetTargetType();
targetType == SwAuthorityField::TargetType::UseDisplayURL
|| targetType == SwAuthorityField::TargetType::UseTargetURL)
{ // Since the user selected target type with URL, try to use it if not empty if (const OUString aURL = pField->GetAbsoluteURL();
aURL.getLength() > 0)
::LoadURL(*this, aURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString());
} elseif (targetType == SwAuthorityField::TargetType::BibliographyTableRow)
{ // Since the user selected to target Bibliography Table Row, // try finding matching bibliography table line
// Note: This way of iterating doesn't seem to take into account TOXes // that are in a frame, probably in some other cases too
GotoPage(1); while (GotoNextTOXBase())
{ const SwTOXBase* pIteratedTOX = nullptr; const SwTOXBase* pPreviousTOX = nullptr;
OUString vFieldText; while ((pIteratedTOX = GetCurTOX()) != nullptr
&& pIteratedTOX->GetType() == TOX_AUTHORITIES)
{ if (pIteratedTOX != pPreviousTOX)
vFieldText = pField->GetAuthority(GetLayout(), &pIteratedTOX->GetTOXForm());
if (const SwNode& rCurrentNode = GetCursor()->GetPoint()->GetNode();
rCurrentNode.GetNodeType() == SwNodeType::Text
&& (GetCursor()->GetPoint()->GetNode().FindSectionNode()->GetSection().GetType()
== SectionType::ToxContent) // this checks it's not a heading
&& static_cast<const SwTextNode*>(&rCurrentNode)->GetText() == vFieldText)
{ // Since a node has been found that is a text node, isn't a heading, // and has text matching to text generated by the field, jump to it
LockView(bWasViewLocked);
ShowCursor(); return;
}
pPreviousTOX = pIteratedTOX;
FwdPara();
}
} // Since a matching node has not been found, return to original position
SetCursor(&vStartPoint);
LockView(bWasViewLocked);
}
} break;
case SwFieldIds::GetRef: if (!bExecHyperlinks) break;
if (!SfxObjectShell::AllowedLinkProtocolFromDocument(rURL, pDShell, rViewFrame.GetFrameWeld())) returnfalse;
// We are doing tiledRendering, let the client handles the URL loading, // unless we are jumping to a TOC mark. if (comphelper::LibreOfficeKit::isActive() && !rURL.startsWith("#"))
{
rView.libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, rURL.toUtf8()); returntrue;
}
if (sInsert == "hyperlink")
{
OUString sURL = rBkmk.GetURL(); // Is this is a jump within the current Doc? const SwDocShell* pDocShell = GetView().GetDocShell(); if(pDocShell->HasName())
{ const OUString aName = pDocShell->GetMedium()->GetURLObject().GetURLNoMark();
// the update of content from linked section at time delete // the undostack. Then the change of the section don't create // any undoobject. - BUG 69145 bool bDoesUndo = DoesUndo();
SwUndoId nLastUndoId(SwUndoId::EMPTY); if (GetLastUndoInfo(nullptr, & nLastUndoId))
{ if (SwUndoId::INSSECTION != nLastUndoId)
{
DoUndo(false);
}
}
UpdateSection( GetSectionFormatPos( *pIns->GetFormat() ), aSection );
DoUndo( bDoesUndo );
}
} else// insert is for a reference mark type
{
REFERENCEMARK eRefMarkType;
// Change REFERENCESUBTYPE_OUTLINE to REFERENCESUBTYPE::BOOKMARK. It is used to show // different options for headings reference and a regular bookmark in the reference mark // type popup menu. See related comment in SwContentTree::FillTransferData. if (oeRefSubType == REFERENCESUBTYPE::REF_OUTLINE)
oeRefSubType = REFERENCESUBTYPE::REF_BOOKMARK;
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.