20#include <config_features.h>
47#include <osl/diagnose.h>
52#include <viewfunc.hxx>
54#include <document.hxx>
70#include <compiler.hxx>
71#include <tokenarray.hxx>
79 const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable )
82 if ( aDataHelper.
HasFormat( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT ) )
92 std::optional<ScTabEditEngine> pEngine(std::in_place, *pPattern, rDoc.
GetEnginePool(), &rDoc );
93 pEngine->EnableUndo(
false );
98 pEngine->SetPaperSize(
Size(100000,100000));
105 aEditView.
InsertText( rxTransferable, OUString(),
true );
108 sal_Int32 nParCnt = pEngine->GetParagraphCount();
111 SCROW nEndRow = nStartRow +
static_cast<SCROW>(nParCnt) - 1;
112 if (nEndRow > rDoc.
MaxRow())
119 pUndoDoc->InitUndo( rDoc, nTab, nTab );
123 SCROW nRow = nStartRow;
128 for( sal_Int32
n = 0;
n < nParCnt;
n++ )
130 std::unique_ptr<EditTextObject>
pObject(pEngine->CreateTextObject(
n));
132 if( ++nRow > rDoc.
MaxRow() )
140 pRedoDoc->InitUndo( rDoc, nTab, nTab );
143 ScRange aMarkRange(nStartCol, nStartRow, nTab, nStartCol, nEndRow, nTab);
147 std::make_unique<ScUndoPaste>( pDocSh, aMarkRange, aDestMark,
168 else if ( aDataHelper.
GetString( SotClipboardFormatId::RTF,
aStr ) )
172 else if ( aDataHelper.
GetString( SotClipboardFormatId::RICHTEXT,
aStr ) )
217 pUndoDoc->InitUndo( rDoc, nTab, nTab );
221 for (
const auto& rTab : rMark)
223 pUndoDoc->AddUndoTab( rTab, rTab );
225 ScRange aCopyRange = aMarkRange;
233 size_t nCount = xRanges->size();
235 for (
const SCTAB&
i : rMark)
237 for (
size_t j = 0; j <
nCount; ++j)
239 ScRange aRange = (*xRanges)[j];
243 for (
bool bHas = aIter.
first(); bHas; bHas = aIter.
next())
254 sal_Int32 nLen = aOld.getLength();
257 assert(nLen >= 2 && aOld[0] ==
'{' && aOld[nLen-1] ==
'}');
259 aOld = aOld.copy( 1, nLen);
266 const OUString& aNew = aFinder.
GetText();
268 std::unique_ptr<ScTokenArray> pArr(aComp.
CompileString(aNew));
283 pRedoDoc->InitUndo( rDoc, nTab, nTab );
287 for (
const auto& rTab : rMark)
289 pRedoDoc->AddUndoTab( rTab, rTab );
291 ScRange aCopyRange = aMarkRange;
297 std::make_unique<ScUndoRefConversion>( pDocSh,
298 aMarkRange, rMark, std::move(pUndoDoc), std::move(pRedoDoc), bMulti) );
322 std::unique_ptr<ESelection> pEditSel;
323 std::unique_ptr<ScEditEngineDefaulter> pThesaurusEngine;
332 SC_MOD()->InputEnterHandler();
351 aOldText.
assign(rDoc, aPos);
361 pThesaurusEngine->SetEditTextObjectPool( rDoc.
GetEditPool() );
363 pThesaurusEngine->SetSpeller(xSpeller);
365 SfxItemSet aEditDefaults(pThesaurusEngine->GetEmptyItemSet());
370 pThesaurusEngine->SetDefaults( aEditDefaults );
374 pThesaurusEngine->SetTextCurrentDefaults(*aOldText.
getEditText());
376 pThesaurusEngine->SetTextCurrentDefaults(aOldText.
getString(rDoc));
384 pThesaurusEngine->ClearModifyFlag();
389 OSL_ENSURE(eState != EESpellState::NoSpeller,
"No SpellChecker");
391 if (eState == EESpellState::ErrorFound)
397 VclMessageType::Info, VclButtonsType::Ok,
401 if (pThesaurusEngine->IsModified())
408 std::unique_ptr<EditTextObject> pText = pThesaurusEngine->CreateTextObject();
409 auto tmp = pText.get();
415 OUString
aStr = pThesaurusEngine->GetText();
424 std::make_unique<ScUndoThesaurus>(
425 GetViewData().GetDocShell(), nCol, nRow, nTab, aOldText, aNewText));
456 rViewData.
GetEditView(eWhich, pEditView, nCol, nRow);
457 SC_MOD()->InputEnterHandler();
485 pUndoDoc->InitUndo( rDoc, nTab, nTab );
487 pRedoDoc->InitUndo( rDoc, nTab, nTab );
491 for (
const auto& rTab : rMark)
494 pUndoDoc->AddUndoTab( rTab, rTab );
495 pRedoDoc->AddUndoTab( rTab, rTab );
507 std::unique_ptr<ScConversionEngineBase> pEngine;
517 rDoc.
GetEnginePool(), rViewData, rConvParam, pUndoDoc.get(), pRedoDoc.get() ));
520 OSL_FAIL(
"ScViewFunc::DoSheetConversion - unknown conversion type" );
530 pEngine->SetControlWord( EEControlBits::USECHARATTRIBS );
531 pEngine->EnableUndo(
false );
532 pEngine->SetPaperSize( aRect.
GetSize() );
533 pEngine->SetTextCurrentDefaults( OUString() );
537 pEngine->ClearModifyFlag();
538 pEngine->ConvertAll(
GetViewData().GetDialogParent(), *pEditView);
542 if( pEngine->IsAnyModified() )
549 std::make_unique<ScUndoConversion>(
551 nCol, nRow, nTab, std::move(pUndoDoc),
552 nNewCol, nNewRow, nTab, std::move(pRedoDoc), rConvParam ) );
582 aURL.SetSmartURL( rFile );
586#if HAVE_FEATURE_AVMEDIA
589 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, aStrURL );
591 SID_INSERT_AVMEDIA, SfxCallMode::SYNCHRON,
592 { &aMediaURLItem }) );
599 std::shared_ptr<const SfxFilter> pFlt;
603 SfxMedium aSfxMedium( aStrURL, (StreamMode::READ | StreamMode::SHARE_DENYNONE) );
614 SfxStringItem aFilterItem( SID_FILTER_NAME, pFlt->GetName() );
620 return (
nullptr != rDispatcher.
ExecuteList(SID_OPENDOC,
621 SfxCallMode::ASYNCHRON,
622 { &aFileNameItem, &aFilterItem, &aTargetItem}));
682 const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable,
695 SCCOL nPosX,
SCROW nPosY,
const OUString* pTarget,
705 OUString aTargetFrame;
707 aTargetFrame = *pTarget;
716 ScAddress aCellPos( nPosX, nPosY, nTab );
732 sal_Int32 nTxtLen = aEngine.
GetTextLen(nPara);
733 ESelection aInsSel( nPara, nTxtLen, nPara, nTxtLen );
743 SvxURLField aField( rURL, rDescription, SvxURLFormat::AppDefault );
761 if (!
pData->IsFieldObject())
775 if (pField->
GetClassId() != css::text::textfield::Type::URL)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
std::unique_ptr< EditTextObject > CreateTextObject()
void SetText(const OUString &rStr)
sal_Int32 GetParagraphCount() const
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
sal_Int32 GetTextLen() const
ESelection GetSelection() const
EESpellState StartThesaurus(weld::Widget *pDialogParent)
void SetOutputArea(const tools::Rectangle &rRect)
void SetSelection(const ESelection &rNewSel)
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
static GraphicFilter & GetGraphicFilter()
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
const OUString & GetDescription() const
const OUString & GetURL() const
static css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker()
Walk through all cells in an area.
ScFormulaCell * getFormulaCell()
const ScAddress & GetPos() const
std::unique_ptr< ScTokenArray > CompileString(const OUString &rFormula)
Tokenize formula expression string into an array of tokens.
Parameters for conversion.
ScConversionType GetType() const
void SetDocumentModified()
const ScDocument & GetDocument() const
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
virtual SfxUndoManager * GetUndoManager() override
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
SC_DLLPUBLIC bool SetEditText(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
This method manages the lifecycle of the passed edit text object.
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC ScFormulaCell * SetFormulaCell(const ScAddress &rPos, ScFormulaCell *pCell)
Set formula cell, and transfer its ownership to the document.
bool IsIdleEnabled() const
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC void EnableUndo(bool bVal)
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
void SetAllFormulasDirty(const sc::SetFormulaDirtyContext &rCxt)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
SC_DLLPUBLIC OUString GetInputString(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bForceSystemLocale=false) const
void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, InsertDeleteFlags nFlags, bool bMarked, ScDocument &rDestDoc, const ScMarkData *pMarks=nullptr, bool bColRowFlags=true)
void EnableIdle(bool bDo)
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
SC_DLLPUBLIC const EditTextObject * GetEditText(const ScAddress &rPos) const
bool IsUndoEnabled() const
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC SCTAB GetTableCount() const
TranslateId GetMessageId() const
const ScRange & GetRange() const
bool ImportString(const OUString &, SotClipboardFormatId)
bool ImportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
const ScRange & GetMultiMarkArea() const
const ScRange & GetMarkArea() const
bool IsMultiMarked() const
SCTAB GetSelectCount() const
void SetMarkArea(const ScRange &rRange)
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...
void ToggleRel(sal_Int32 nStartPos, sal_Int32 nEndPos)
sal_Int32 GetFound() const
const OUString & GetText() const
Edit engine for spell checking.
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
void InsertURLField(const OUString &rName, const OUString &rURL, const OUString &rTarget)
void InsertURLButton(const OUString &rName, const OUString &rURL, const OUString &rTarget, const Point *pInsPos)
void AlignToCursor(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, const ScSplitPos *pWhich=nullptr)
void ErrorMessage(TranslateId pGlobStrId)
void MakeEditView(ScEditEngineDefaulter *pEngine, SCCOL nCol, SCROW nRow)
ScViewData & GetViewData()
ScGridWindow * GetActiveWin()
SC_DLLPUBLIC void CellContentChanged()
void KillEditView(bool bNoPaint)
Edit engine for text conversion.
void GetMultiArea(ScRangeListRef &rRange) const
SfxDispatcher & GetDispatcher()
SCCOL GetEditEndCol() const
SCROW GetEditEndRow() const
void SetSpellingView(EditView *pSpView)
ScMarkData & GetMarkData()
SCROW GetEditStartRow() const
ScDocument & GetDocument() const
SCCOL GetEditStartCol() const
ScDocShell * GetDocShell() const
ScGridWindow * GetActiveWin()
ScTabViewShell * GetViewShell() const
ScSplitPos GetActivePart() const
void GetEditView(ScSplitPos eWhich, EditView *&rViewPtr, SCCOL &rCol, SCROW &rRow)
SfxBindings & GetBindings()
bool HasEditView(ScSplitPos eWhich) const
bool PasteGraphic(const Point &rPos, const Graphic &rGraphic, const OUString &rFile)
void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const EditTextObject *pData=nullptr, bool bMatrixExpand=false)
bool HasBookmarkAtCursor(SvxHyperlinkItem *pContent)
bool PasteBookmark(SotClipboardFormatId nFormatId, const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable, SCCOL nPosX, SCROW nPosY)
void PasteRTF(SCCOL nCol, SCROW nStartRow, const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable)
void DoHangulHanjaConversion()
void DoSheetConversion(const ScConversionParam &rParam)
Generic implementation of sheet conversion functions.
void InsertBookmark(const OUString &rDescription, const OUString &rURL, SCCOL nPosX, SCROW nPosY, const OUString *pTarget=nullptr, bool bTryReplace=false)
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, bool bApi)
bool PasteObject(const Point &, const css::uno::Reference< css::embed::XEmbeddedObject > &, const Size *, const Graphic *=nullptr, const OUString &=OUString(), sal_Int64 nAspect=css::embed::Aspects::MSOLE_CONTENT)
bool PasteFile(const Point &, const OUString &, bool bLink)
static LanguageType GetEffLanguage(ScDocument &rDoc, const ScAddress &rPos)
void Update(sal_uInt16 nId)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
void UseInteractionHandler(bool)
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
static OUString GetLanguageString(const LanguageType eType)
virtual sal_Int32 GetClassId() const
const SvxFieldData * GetField() const
void SetName(const OUString &rName)
void SetURL(const OUString &rURL)
void SetTargetFrame(const OUString &rTarget)
const OUString & GetRepresentation() const
void SetTargetFrame(const OUString &rFrm)
const OUString & GetTargetFrame() const
const OUString & GetURL() const
bool GetString(SotClipboardFormatId nFormat, OUString &rStr) const
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef) const
bool HasFormat(SotClipboardFormatId nFormat) const
bool GetINetBookmark(SotClipboardFormatId nFormat, INetBookmark &rBmk) const
reference_type * get() const
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
SharedString intern(const OUString &rStr)
::OutputDevice const * GetOutDev() const
virtual OUString GetName() const override
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
EmbeddedObjectRef * pObject
@ NOCAPTIONS
Sparklines in a cell.
#define GRFILTER_FORMAT_DONTKNOW
std::unique_ptr< sal_Int32[]> pData
SfxDispatcher * GetDispatcher()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
OUString ScResId(TranslateId aId)
@ SC_CONVERSION_CHINESE_TRANSL
Hangul-Hanja converter.
@ SC_CONVERSION_SPELLCHECK
@ SC_CONVERSION_HANGULHANJA
Spell checker.
Store arbitrary cell value of any kind.
OUString getString(const ScDocument &rDoc) const
void assign(const ScDocument &rDoc, const ScAddress &rPos)
Take cell value from specified position in specified document.
EditTextObject * getEditText() const