/* -*- 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 .
*/
// disallow formatting, updating the view, ... while // converting the document. (saves time) // Also remember the current view and cursor position for later
m_pWrtShell->StartAction();
// remember cursor position data for later restoration of the cursor const SwPosition *pPoint = m_pWrtShell->GetCursor()->GetPoint(); bool bRestoreCursor = pPoint->GetNode().IsTextNode(); const SwNodeIndex aPointNodeIndex( pPoint->GetNode() );
sal_Int32 nPointIndex = pPoint->GetContentIndex();
// since this conversion is not interactive the whole converted // document should be undone in a single undo step.
m_pWrtShell->StartUndo( SwUndoId::OVERWRITE );
if (bRestoreCursor)
{
SwTextNode *pTextNode = aPointNodeIndex.GetNode().GetTextNode(); // check for unexpected error case
OSL_ENSURE(pTextNode && pTextNode->GetText().getLength() >= nPointIndex, "text missing: corrupted node?" ); // restore cursor to its original position if (!pTextNode || pTextNode->GetText().getLength() < nPointIndex)
m_pWrtShell->GetCursor()->GetPoint()->Assign( aPointNodeIndex ); else
m_pWrtShell->GetCursor()->GetPoint()->Assign( *pTextNode, nPointIndex );
}
// enable all, restore view and cursor position
m_pWrtShell->EndAction();
}
}
Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); if( xComponent.is() )
xComponent->dispose();
}
} break;
} case FN_HYPHENATE_OPT_DLG:
HyphenateDocument(); break; default:
OSL_ENSURE(false, "wrong Dispatcher"); return;
}
}
// start language specific text conversion
void SwView::StartTextConversion(
LanguageType nSourceLang,
LanguageType nTargetLang, const vcl::Font *pTargetFont,
sal_Int32 nOptions, bool bIsInteractive )
{ // do not do text conversion if it is active elsewhere if (SwEditShell::HasConvIter())
{ return;
}
void SwView::HyphStart( SvxSpellArea eWhich )
{ switch ( eWhich )
{ case SvxSpellArea::Body:
m_pWrtShell->HyphStart( SwDocPositions::Start, SwDocPositions::End ); break; case SvxSpellArea::BodyEnd:
m_pWrtShell->HyphStart( SwDocPositions::Curr, SwDocPositions::End ); break; case SvxSpellArea::BodyStart:
m_pWrtShell->HyphStart( SwDocPositions::Start, SwDocPositions::Curr ); break; case SvxSpellArea::Other:
m_pWrtShell->HyphStart( SwDocPositions::OtherStart, SwDocPositions::OtherEnd ); break; default:
OSL_ENSURE( false, "HyphStart with unknown Area" );
}
}
// Interactive separation
void SwView::HyphenateDocument()
{ // do not hyphenate if interactive hyphenation is active elsewhere if (SwEditShell::HasHyphIter())
{
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetEditWin().GetFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, SwResId(STR_MULT_INTERACT_HYPH_WARN)));
xBox->set_title(SwResId(STR_HYPH_TITLE));
xBox->run(); return;
}
bool SwView::IsValidSelectionForThesaurus() const
{ // must not be a multi-selection, and if it is a selection it needs // to be within a single paragraph
// make sure the selection build later from the data below does not // include "in word" character to the left and right in order to // preserve those. Therefore count those "in words" in order to modify // the selection accordingly. const sal_Unicode* pChar = rLookUpText.getStr();
sal_Int32 nLeft = 0; while (*pChar++ == CH_TXTATR_INWORD)
++nLeft;
pChar = rLookUpText.getLength() ? rLookUpText.getStr() + rLookUpText.getLength() - 1 : nullptr;
sal_Int32 nRight = 0; while (pChar && *pChar-- == CH_TXTATR_INWORD)
++nRight;
//!! Start of extra code for context menu modifying extensions struct ExecuteInfo
{
uno::Reference< frame::XDispatch > xDispatch;
util::URL aTargetURL;
};
IMPL_STATIC_LINK( AsyncExecute, ExecuteHdl_Impl, void*, p, void )
{
ExecuteInfo* pExecuteInfo = static_cast<ExecuteInfo*>(p);
SolarMutexReleaser aReleaser; try
{ // Asynchronous execution as this can lead to our own destruction! // Framework can recycle our current frame and the layout manager disposes all user interface // elements if a component gets detached from its frame!
pExecuteInfo->xDispatch->dispatch(pExecuteInfo->aTargetURL, uno::Sequence<beans::PropertyValue>());
} catch (const Exception&)
{
}
delete pExecuteInfo;
} //!! End of extra code for context menu modifying extensions
// Spell-check in case the idle jobs haven't had a chance to kick in. // This makes it possible to suggest spelling corrections for // wrong words independent of the spell-checking idle job. if (pNode && pNode->IsWrongDirty() &&
!pCursorShell->IsTableMode() &&
!pCursor->HasMark() && !pCursor->IsMultiSelection())
{
std::pair<Point, bool> const tmp(rPt, false);
SwContentFrame *const pContentFrame = pCursor->GetPointContentNode()->getLayoutFrame(
pCursorShell->GetLayout(),
&aPoint, &tmp); if (pContentFrame)
{
SwRect aRepaint(static_cast<SwTextFrame*>(pContentFrame)->AutoSpell_(
*pCursor->GetPointContentNode()->GetTextNode(), 0)); if (aRepaint.HasArea())
m_pWrtShell->InvalidateWindows(aRepaint);
}
}
// decide which variant of the context menu to use... // if neither spell checking nor grammar checking provides suggestions use the // default context menu. bool bUseGrammarContext = false;
Reference<XSpellAlternatives> xAlt(
m_pWrtShell->GetCorrection(bIsMouseEvent ? &rPt : nullptr, aToFill));
ProofreadingResult aGrammarCheckRes;
sal_Int32 nErrorInResult = -1;
uno::Sequence< OUString > aSuggestions; bool bCorrectionRes = false; if (!xAlt.is() || !xAlt->getAlternatives().hasElements())
{
sal_Int32 nErrorPosInText = -1;
bCorrectionRes = m_pWrtShell->GetGrammarCorrection(
aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions,
bIsMouseEvent ? &rPt : nullptr, aToFill);
OUString aMessageText; if (nErrorInResult >= 0)
aMessageText = aGrammarCheckRes.aErrors[ nErrorInResult ].aShortComment; // we like to use the grammar checking context menu if we either get // some suggestions or at least a comment about the error found...
bUseGrammarContext = bCorrectionRes &&
(aSuggestions.hasElements() || !aMessageText.isEmpty());
}
// open respective context menu for spell check or grammar errors with correction suggestions... if ((!bUseGrammarContext && xAlt.is()) ||
(bUseGrammarContext && bCorrectionRes && aGrammarCheckRes.aErrors.hasElements()))
{ // get paragraph text
OUString aParaText; if (pNode)
{
pCursorShell->Push(); if (!pCursorShell->IsSttPara())
{
pCursorShell->MovePara(GoCurrPara, fnParaStart);
}
pCursorShell->SetMark(); if (!pCursorShell->IsEndPara())
{
pCursorShell->MovePara(GoCurrPara, fnParaEnd);
}
aParaText = pCursorShell->GetSelText();
pCursorShell->Pop(SwCursorShell::PopMode::DeleteCurrent);
} else
{
OSL_FAIL("text node expected but not found" );
}
bRet = true;
m_pWrtShell->SttSelect();
std::unique_ptr<SwSpellPopup> xPopup(bUseGrammarContext ? new SwSpellPopup(m_pWrtShell.get(), aGrammarCheckRes, nErrorInResult, aSuggestions, aParaText) : new SwSpellPopup(m_pWrtShell.get(), xAlt, aParaText));
ui::ContextMenuExecuteEvent aEvent; const Point aPixPos = GetEditWin().LogicToPixel( rPt );
This function shows the popup menu for smarttag actions.
*/ void SwView::ExecSmartTagPopup( const Point& rPt )
{ constbool bOldViewLock = m_pWrtShell->IsViewLocked();
m_pWrtShell->LockView( true );
m_pWrtShell->Push();
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.