21 #include <com/sun/star/i18n/TextConversionOption.hpp>
33 #include <osl/diagnose.h>
41 #include <globstr.hrc>
54 mrViewData( rViewData ),
55 mrDocShell( *rViewData.GetDocShell() ),
56 mrDoc( rViewData.GetDocShell()->GetDocument() ),
57 maSelState( rViewData ),
58 mpUndoDoc( pUndoDoc ),
59 mpRedoDoc( pRedoDoc ),
61 mbIsAnyModified(
false ),
62 mbInitialState( true ),
63 mbWrappedInTable(
false ),
104 aLang.
nEnd == aNewStr.getLength();
108 OUString aVisibleStr;
138 std::unique_ptr<ScPatternAttr> pNewAttr;
141 pNewAttr = std::make_unique<ScPatternAttr>(*pAttr);
143 pNewAttr = std::make_unique<ScPatternAttr>(
mrDoc.
GetPool());
171 while( bLoop && !bFound )
211 if( pPattern && (pPattern != pLastPattern) )
215 pLastPattern = pPattern;
220 if(
const SvxLanguageItem* pLangItem = dynamic_cast<const SvxLanguageItem*>( pItem ) )
242 pViewShell->
SetCursor( nNewCol, nNewRow,
true );
306 css::uno::Reference< css::linguistic2::XSpellChecker1 >
const & xSpeller ) :
318 OSL_ENSURE( eState != EESpellState::NoSpeller,
"ScSpellingEngine::Convert - no spell checker" );
337 VclMessageType::Question, VclButtonsType::YesNo,
338 ScResId(STR_SPELLING_BEGIN_TAB)));
339 xBox->set_title(
ScResId(STR_MSSG_DOSUBTOTALS_0));
340 xBox->set_default_response(
RET_YES);
349 VclMessageType::Info, VclButtonsType::Ok,
350 ScResId(STR_SPELLING_STOP_OK)));
356 sal_uInt16 nWinId = ScSpellDialogChildWindow::GetChildWindowId();
367 if (pRet->get_visible())
379 meConvType( eConvType ),
383 mbUseTargetFont(
false ),
384 mbIsInteractive(
false )
389 LanguageType eLang, sal_Int32 nOptions,
bool bIsInteractive ) :
390 meConvType( eConvType ),
391 meSourceLang( eLang ),
392 meTargetLang( eLang ),
393 mnOptions( nOptions ),
394 mbUseTargetFont(
false ),
395 mbIsInteractive( bIsInteractive )
398 mnOptions = i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
403 sal_Int32 nOptions,
bool bIsInteractive ) :
404 meConvType( eConvType ),
405 meSourceLang( eSourceLang ),
406 meTargetLang( eTargetLang ),
407 maTargetFont( rTargetFont ),
408 mnOptions( nOptions ),
409 mbUseTargetFont( true ),
410 mbIsInteractive( bIsInteractive )
413 mnOptions = i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
421 maConvParam( rConvParam )
void RestoreCursorPos()
Restores the initial cursor position.
ScMarkData & GetMarkData()
SfxViewFrame * GetViewFrame() const
ScSelectionState maSelState
OUString GetText(LineEnd eEnd=LINEEND_LF) const
void GetVars(SCCOL &nColP, SCROW &nRowP, SCTAB &nTabP) const
void SetDefaults(const SfxItemSet &rDefaults, bool bRememberCopy=true)
Creates a copy of SfxItemSet if bRememberCopy set.
bool HasConvertibleTextPortion(LanguageType nLang)
LanguageType meSourceLang
Type of the conversion.
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
EESpellState StartSpeller(weld::Widget *pDialogParent, bool bMultipleDoc=false)
SfxChildWindow * GetChildWindow(sal_uInt16)
OUString ScResId(TranslateId aId)
bool mbIsAnyModified
Current row index.
LanguageType GetTargetLang() const
#define LANGUAGE_ENGLISH_US
void CopyCellToDocument(const ScAddress &rSrcPos, const ScAddress &rDestPos, ScDocument &rDestDoc)
Copy only cell, nothing but cell to another document.
const SfxItemSet & GetEmptyItemSet() const
static weld::Window * GetActiveDialogParent()
SCCOL mnStartCol
Current cell language.
LanguageType getLanguageType(bool bResolveSystem=true) const
void PostPaintCell(SCCOL nCol, SCROW nRow, SCTAB nTab)
ScConversionEngineBase(SfxItemPool *pEnginePool, ScViewData &rViewData, ScDocument *pUndoDoc, ScDocument *pRedoDoc)
constexpr TypedWhichId< SvxLanguageItem > ATTR_FONT_LANGUAGE(110)
static const AllSettings & GetSettings()
virtual void ShowFinishDialog()
Derived classes may show a message box stating that the conversion is finished.
This is very similar to ScCellValue, except that it references the original value instead of copying ...
SCTAB mnStartTab
Initial row index.
virtual void ConvertAll(weld::Widget *pDialogParent, EditView &rEditView) override
Checks spelling of all cells in the selection or sheet.
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
const ESelection & GetEditSelection() const
Returns the edit engine selection.
SCROW mnCurrRow
Current column index.
No selection, simple cell cursor.
bool mbWrappedInTable
true = Not searched for a cell yet.
ScDocument * mpRedoDoc
Document stores all old cells for UNDO action.
ScSelectionType GetSelectionType() const
Returns the type of the selection this object contains.
bool GetNextSpellingCell(SCCOL &nCol, SCROW &nRow, SCTAB nTab, bool bInSel, const ScMarkData &rMark) const
SC_DLLPUBLIC ScDocumentPool * GetPool()
Base class for special type of edit engines, i.e.
Reference< XController > xController
const EditTextObject * mpEditText
void StartTextConversion(weld::Widget *pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc)
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC SCTAB GetTableCount() const
SCTAB GetSelectCount() const
ScDocument * mpUndoDoc
Selection data of the document.
SC_DLLPUBLIC OUString GetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScInterpreterContext *pContext=nullptr) const
sal_Int32 mnOptions
Target font to be used if language has to be changed.
ScTextConversionEngine(SfxItemPool *pEnginePool, ScViewData &rViewData, const ScConversionParam &rConvParam, ScDocument *pUndoDoc, ScDocument *pRedoDoc)
ScConversionParam(ScConversionType eConvType)
Constructs an empty parameter struct with the passed conversion type.
void FillFromCell(SCCOL nCol, SCROW nRow, SCTAB nTab)
Fills the edit engine from a document cell.
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
EditView * GetSpellingView() const
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
virtual void ConvertAll(weld::Widget *pDialogParent, EditView &rEditView) override
Converts all cells in the selection or sheet according to set language.
virtual bool SpellNextDocument() override
Callback from edit engine to check the next cell.
SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const
const LanguageTag & GetLanguageTag() const
ScTabViewShell * GetViewShell() const
SC_DLLPUBLIC bool SetEditText(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
This method manages the lifecycle of the passed edit text object.
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC void SetPattern(const ScAddress &, const ScPatternAttr &rAttr)
LanguageType meTargetLang
Source language for conversion.
LanguageType GetSourceLang() const
SC_DLLPUBLIC CellType GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab) const
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
EESpellState HasSpellErrors()
virtual bool NeedsConversion()=0
Derived classes return, if the current text needs conversion (i.e.
ScSpellingEngine(SfxItemPool *pEnginePool, ScViewData &rViewData, ScDocument *pUndoDoc, ScDocument *pRedoDoc, css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller)
Parameters for conversion.
virtual bool NeedsConversion() override
Returns true, if the current text contains text to convert.
std::unique_ptr< EditTextObject > CreateTextObject()
SfxItemSet & GetItemSet()
#define LANGUAGE_DONTKNOW
const vcl::Font * GetTargetFont() const
void MakeEditView(ScEditEngineDefaulter *pEngine, SCCOL nCol, SCROW nRow)
bool mbFinished
true = Already restarted at top of the sheet.
void SetDefaultLanguage(LanguageType eLang)
weld::Widget * GetDialogParent()
Returns the spelling dialog if it is open.
sal_Int32 GetParagraphCount() const
const ScAddress & GetCellCursor() const
Returns the position of the cell cursor.
ScDBFunc * GetView() const
bool FindNextConversionCell()
Implementation of cell iteration.
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool HasChildWindow(sal_uInt16)
ScConversionParam maConvParam
sal_Int32 GetOptions() const
ScConversionType
Specifiers for sheet conversion (functions iterating over the sheet and modifying cells)...
virtual bool ShowTableWrapDialog() override
Show a query box that asks whether to restart at top of the sheet.
bool IsInteractive() const
virtual ~ScConversionEngineBase() override
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
void AlignToCursor(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, const ScSplitPos *pWhich=nullptr)
void SetSpeller(css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller)
virtual bool ShowTableWrapDialog()
Derived classes may show a query box that asks whether to restart at top of the sheet.
void SetSelection(const ESelection &rNewSel)
SCROW mnStartRow
Initial column index.
virtual bool NeedsConversion() override
Returns true, if the current text contains a spelling error.
SCCOL mnCurrCol
Initial sheet index.
bool GetTableSelect(SCTAB nTab) const
virtual void ShowFinishDialog() override
Show a message box stating that spell checking is finished.
editeng::LanguageSpan GetLanguage(const EditPaM &rPaM) const
virtual bool ConvertNextDocument() override
Callback from edit engine to convert the next cell.
LanguageType meCurrLang
Document stores all new cells for REDO action.
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
bool m_bDetectedRangeSegmentation false
SfxItemPool * GetEditTextObjectPool() const
void FillEditItemSet(SfxItemSet *pEditSet, const SfxItemSet *pCondSet=nullptr) const
Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSe...
bool mbInitialState
true = At least one cell has been changed.