35 #include <osl/diagnose.h>
40 #include <drawdoc.hxx>
46 #include <strings.hrc>
68 std::unique_ptr<SwPaM>
93 m_bBodySpelled(
false),
94 m_bOtherSpelled(
false),
95 m_bStartedInOther(
false),
96 m_bStartedInSelection(
false),
97 m_bDrawingsSpelled(
false),
98 m_pStartDrawing(nullptr),
99 m_bRestartDrawing(
false),
102 m_pPointNode(nullptr),
103 m_pMarkNode(nullptr),
106 m_pOutliner(nullptr),
107 m_bTextObjectsCollected(
false)
112 { m_bInitialCall =
true;
113 m_bBodySpelled = m_bOtherSpelled = m_bDrawingsSpelled =
false;
114 m_xStartRange =
nullptr;
115 m_pStartDrawing =
nullptr;
116 m_bRestartDrawing =
false;
117 m_bTextObjectsCollected =
false;
118 m_aTextObjects.clear();
119 m_bStartedInOther =
false;
120 pOtherCursor.reset();
129 Point aPt(LONG_MIN, LONG_MIN);
133 rSh.
GetView().AttrChangedNotify(
nullptr);
142 :
svx::SpellDialogChildWindow (
143 _pParent, nId, pBindings)
144 , m_bIsGrammarCheckingOn(
false)
188 bool bOtherText =
false;
193 if(!bDrawText && !bNormalText)
199 bNormalText = !bDrawText;
231 pUnoCursor->Left( 1 );
232 pStart = pUnoCursor->Start();
371 bool bCloseMessage =
true;
376 "not all parts of the document are already spelled");
377 if(
m_pSpellState->m_xStartRange.is() && !bNoDictionaryAvailable )
381 VclMessageType::Question, VclButtonsType::YesNo,
SwResId(STR_QUERY_SPELL_CONTINUE)));
382 sal_uInt16 nRet = xBox->run();
400 bCloseMessage =
false;
403 if( aRet.empty() && bCloseMessage && !bNoDictionaryAvailable )
406 OUString sInfo(
SwResId( bNoDictionaryAvailable ? STR_DICTIONARY_UNAVAILABLE : STR_SPELLING_COMPLETED ) );
409 std::unique_ptr<weld::MessageDialog> xBox(
411 VclMessageType::Info,
418 xSpellController->getDialog()->grab_focus();
427 OSL_ENSURE(!
m_pSpellState->m_bInitialCall,
"ApplyChangedSentence in initial call or after resume");
455 const OUString& rOld,
const OUString& rNew,
LanguageType eLanguage)
458 pACorr->
PutText( rOld, rNew, eLanguage );
501 OSL_ENSURE(pOutliner,
"No Outliner in SwSpellDialogChildWindow::SetGrammarChecking");
513 bool bInvalidate =
false;
550 OSL_ENSURE(pOLV,
"no OutlinerView in SwSpellDialogChildWindow::GetFocus()");
556 default: bInvalidate =
true;
604 OSL_ENSURE(pOutliner && pOLV,
"no Outliner/OutlinerView in SwSpellDialogChildWindow::LoseFocus()");
622 pWrtShell->
SpellEnd(
nullptr,
false);
633 sal_uInt16 nShellIdx = 0;
635 while(
nullptr != (pShell = pDispatch->
GetShell(nShellIdx++)))
636 if(
auto pSwView = dynamic_cast< SwView *>( pShell ))
657 OSL_FAIL(
"text already active in SwSpellDialogChildWindow::MakeTextSelection_Impl()");
664 rView.AttrChangedNotify(
nullptr);
673 rView.AttrChangedNotify(
nullptr);
683 rView.AttrChangedNotify(
nullptr);
696 Point aPt(LONG_MIN, LONG_MIN);
702 rView.AttrChangedNotify(
nullptr);
714 bool bNextDoc =
false;
726 if(
auto pSdrTextObj = dynamic_cast<SdrTextObj *>( pObj ) )
727 pCurrentTextObj = pSdrTextObj;
745 std::list<SdrTextObj*>::iterator aStart =
m_pSpellState->m_aTextObjects.begin();
753 bool bHasSpellError =
false;
756 GetDrawOutliner().GetEmptyItemSet().GetPool(),
757 OutlinerMode::TextObject );
759 MapMode aMapMode (MapUnit::MapTwip);
760 aTmpOutliner.SetRefMapMode(aMapMode);
762 aTmpOutliner.SetSpeller( xSpell );
766 aTmpOutliner.InsertView( &aOutlView );
770 aTmpOutliner.SetText( *pParaObj );
771 aTmpOutliner.ClearModifyFlag();
772 bHasSpellError = EESpellState::Ok != aTmpOutliner.HasSpellErrors();
773 aTmpOutliner.RemoveView( &aOutlView );
786 rView.AttrChangedNotify(
nullptr);
800 OSL_ENSURE(pOutliner,
"No Outliner in SwSpellDialogChildWindow::SpellDrawText_Impl");
824 OSL_ENSURE(
m_pSpellState->m_bLockFocus != bLock,
"invalid locking - no change of state");
SfxViewFrame * GetViewFrame() const
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
SwWrtShell * GetWrtShell_Impl()
SwNode & GetNode(bool bPoint=true) const
void ExpandToSentenceBorders()
size_t GetMarkCount() const
static SvxAutoCorrCfg & Get()
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
const SwNode * m_pMarkNode
bool FindNextDrawTextError_Impl(SwWrtShell &rSh)
bool BeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, bool bSetSelectionToStart=false)
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
bool AreObjectsMarked() const
bool IsStartOfDoc() const
static bool HasLastSentenceGotGrammarChecked()
Check SwSpellIter data to see if the last sentence got grammar checked.
const SwPosition * GetMark() const
virtual std::shared_ptr< SfxDialogController > GetController() override
void InvalidateSpellDialog()
bool SpellSentence(svx::SpellPortions &rToFill, bool bIsGrammarCheck)
Spells on a sentence basis - the SpellPortions are needed.
SdrMark * GetMark(size_t nNum) const
const SdrObject * m_pStartDrawing
Of course Writer needs its own rectangles.
Reference< XTextRange > m_xStartRange
void ApplyChangedSentence(const svx::SpellPortions &rNewPortions, bool bRecheck)
Applies a changed sentence.
void Invalidate(sal_uInt16 nId)
constexpr OUStringLiteral UPN_IS_GRAMMAR_INTERACTIVE
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Used by the UI to modify the document model.
OUString SwResId(TranslateId aId)
std::unique_ptr< SpellState > m_pSpellState
const SwView & GetView() const
SfxShell * GetShell(sal_uInt16 nIdx) const
void MakeTextSelection_Impl(SwWrtShell &rSh, ShellMode eSelMode)
const SdrOutliner * m_pOutliner
virtual void LoseFocus() override
bool SpellDrawText_Impl(SwWrtShell &rSh, svx::SpellPortions &rPortions)
void LockFocusNotification(bool bLock)
EditView & GetEditView() const
virtual ~SwSpellDialogChildWindow() override
void MakeVisible(const SwRect &)
virtual bool HasGrammarChecking() override
virtual void GetFocus() override
SdrObject * GetMarkedSdrObj() const
SwDoc * GetDoc()
returns Doc. But be careful!
PaM is Point and Mark: a selection of the document model.
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
bool HasOtherCnt() const
Are there frames, footnotes, etc.
const SdrOutliner * GetTextEditOutliner() const
bool HasSelection() const
SfxBindings & GetBindings() const
std::unique_ptr< SwPaM > pOtherCursor
ESelection m_aStartDrawingSelection
void SpellEnd(SwConversionArgs const *pConvArgs=nullptr, bool bRestoreSelection=true)
Restore selections.
SwSpellDialogChildWindow(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
bool HasGrammarChecker() const
const SwPosition * GetPoint() const
virtual void ApplyChangedSentence(const svx::SpellPortions &rChanged, bool bRecheck) override
css::uno::Any GetProperty(std::u16string_view rPropertyName) const
SvxAutoCorrect * GetAutoCorrect()
bool m_bTextObjectsCollected
SfxBindings & GetBindings()
const SdrMarkList & GetMarkedObjectList() const
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
virtual svx::SpellPortions GetNextWrongSentence(bool bRecheck) override
void SetSelection(const SwPaM &rCursor)
SFX_IMPL_CHILDWINDOW_WITHID(SearchResultsDlgWrapper, SID_SEARCH_RESULTS_DIALOG)
const OutlinerView * GetTextEditOutlinerView() const
Outliner * GetOutliner() const
virtual bool HasAutoCorrection() override
SwDrawBase * GetDrawFuncPtr() const
virtual void SetGrammarChecking(bool bOn) override
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
const SwPosition * Start() const
SwDocShell * GetDocShell()
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
static void MoveContinuationPosToEndOfCheckedSentence()
Moves the continuation position to the end of the currently checked sentence.
ESelection GetSelection() const
bool IsDictionaryMissing() const
Returns true if no dictionary can be found for any content.
SdrHdl * GetFocusHdl() const
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
const SwNode * m_pPointNode
void SetSelection(const ESelection &)
SwWrtShell * GetWrtShellPtr() const
bool PutText(const OUString &rShort, const OUString &rLong, LanguageType eLang)
void InvalidateSpellDialog()
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
#define FN_SPELL_GRAMMAR_DIALOG
virtual OutlinerParaObject * GetOutlinerParaObject() const override
sal_Int32 GetIndex() const
void SpellStart(SwDocPositions eStart, SwDocPositions eEnd, SwDocPositions eCurr, SwConversionArgs *pConvArgs=nullptr)
Functions used for spell checking and text conversion.
void SetRefDevice(OutputDevice *pRefDev)
void SetOutputArea(const tools::Rectangle &rRect)
bool SelectObj(const Point &rSelPt, sal_uInt8 nFlag=0, SdrObject *pObj=nullptr)
If an object has been given, exactly this object is selected (instead of searching over position)...
SdrPageView * GetSdrPageView() const
static void lcl_LeaveDrawText(SwWrtShell &rSh)
SfxDispatcher * GetDispatcher() const
static void PutSpellingToSentenceStart()
Make SpellIter start with the current sentence when called next time.
bool m_bIsGrammarCheckingOn
virtual bool IsGrammarChecking() override
const SdrHdlList & GetHdlList() const
std::vector< SpellPortion > SpellPortions
SelectionType GetSelectionType() const
bool IsDrawCreate() const
ShellMode GetShellMode() const
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
bool m_bStartedInSelection
std::list< SdrTextObj * > m_aTextObjects
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
bool SetProperty(std::u16string_view rPropertyName, const css::uno::Any &rValue)
virtual void AddAutoCorrection(const OUString &rOld, const OUString &rNew, LanguageType eLanguage) override
bool m_bDetectedRangeSegmentation false
virtual const tools::Rectangle & GetLogicRect() const override
Base class of the Writer document model elements.