23#include <com/sun/star/uno/Sequence.hxx>
24#include <com/sun/star/embed/XTransactedObject.hpp>
27#include <osl/diagnose.h>
47#include <document.hxx>
83 for(
SCTAB nTab = nTab1; nTab <= nTab2; nTab++ )
90 if( nLastCol > nMaxCol )
92 if( nLastRow > nMaxRow )
117 m_aObjDesc(
std::move( aDesc )),
120 m_nSourceCursorX( m_pDoc->MaxCol() + 1 ),
121 m_nSourceCursorY( m_pDoc->MaxRow() + 1 ),
123 m_bDragWasInternal( false ),
124 m_bUsedForLink( false ),
127 OSL_ENSURE(
m_pDoc->IsClipboard(),
"wrong document");
135 m_pDoc->GetClipStart( nCol1, nRow1 );
136 m_pDoc->GetClipArea( nCol2, nRow2,
true );
137 nCol2 = sal::static_int_cast<SCCOL>( nCol2 + nCol1 );
138 nRow2 = sal::static_int_cast<SCROW>( nRow2 + nRow1 );
156 OSL_ENSURE(!bFirst,
"no sheet selected");
160 if ( nCol2>=
m_pDoc->MaxCol() && nRow2>=
m_pDoc->MaxRow() )
165 if( nMaxRow < nRow2 )
167 if( nMaxCol < nCol2 )
187 OSL_FAIL(
"ScTransferObj wasn't released");
207 AddFormat( SotClipboardFormatId::EMBED_SOURCE );
208 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
209 AddFormat( SotClipboardFormatId::GDIMETAFILE );
211 AddFormat( SotClipboardFormatId::BITMAP );
218 AddFormat( SotClipboardFormatId::STRING );
219 AddFormat( SotClipboardFormatId::STRING_TSVC );
222 AddFormat( SotClipboardFormatId::RICHTEXT );
225 AddFormat( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT );
237 SCCOL nPrintAreaEndCol = 0;
238 SCROW nPrintAreaEndRow = 0;
255 bool bShrunk =
false;
257 false,
true ,
true , &aDataAreaExtras);
262 bool bShrunk =
false;
264 false,
false ,
false );
267 if ( nPrintAreaEndRow > nEndRow )
268 nEndRow = nPrintAreaEndRow;
270 if ( nPrintAreaEndCol > nEndCol )
271 nEndCol = nPrintAreaEndCol;
273 aReducedBlock =
ScRange(nStartCol, nStartRow, aReducedBlock.
aStart.
Tab(), nEndCol, nEndRow, aReducedBlock.
aEnd.
Tab());
275 return aReducedBlock;
287 bool bReduceBlockFormat =
288 nFormat == SotClipboardFormatId::HTML
289 || nFormat == SotClipboardFormatId::RTF
290 || nFormat == SotClipboardFormatId::RICHTEXT
291 || nFormat == SotClipboardFormatId::BITMAP
292 || nFormat == SotClipboardFormatId::PNG;
294 const bool bIncludeVisual = (nFormat == SotClipboardFormatId::BITMAP ||
295 nFormat == SotClipboardFormatId::PNG);
297 if (bReduceBlockFormat)
300 if ( nFormat == SotClipboardFormatId::LINKSRCDESCRIPTOR || nFormat == SotClipboardFormatId::OBJECTDESCRIPTOR )
304 else if ( ( nFormat == SotClipboardFormatId::RTF || nFormat == SotClipboardFormatId::RICHTEXT ||
328 if (!aText.isEmpty())
334 ((nFormat == SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT) ?
339 || nFormat == SotClipboardFormatId::RICHTEXT )
343 if ( nFormat == SotClipboardFormatId::LINK )
358 const bool bPlainMulti = (nFormat == SotClipboardFormatId::STRING &&
365 (nFormat == SotClipboardFormatId::STRING_TSVC));
386 else if ( rFlavor.DataType.equals(
cppu::UnoType<uno::Sequence< sal_Int8 >>::get() ) )
393 OSL_FAIL(
"unknown DataType");
396 else if ( nFormat == SotClipboardFormatId::BITMAP || nFormat == SotClipboardFormatId::PNG )
402 pVirtDev->SetOutputSizePixel(pVirtDev->LogicToPixel(aMMRect.
GetSize(),
MapMode(MapUnit::Map100thMM)));
406 pVirtDev->SetMapMode(
MapMode( MapUnit::MapPixel ) );
407 BitmapEx aBmp = pVirtDev->GetBitmapEx(
Point(), pVirtDev->GetOutputSize() );
410 else if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
426 pVDev->EnableOutput(
false );
427 pVDev->SetMapMode( aMapMode );
439 else if ( nFormat == SotClipboardFormatId::EMBED_SOURCE )
453 const datatransfer::DataFlavor& rFlavor )
458 switch (nUserObjectId)
466 if ( pImpEx->
ExportStream( *rxOStm, OUString(), nFormat ) )
477 pEngine->
Write( *rxOStm, EETextFormat::Rtf );
491 uno::Reference<datatransfer::XTransferable> xEditTrans = pEngine->
CreateTransferable( aSel );
502 pEngine->
Write(*rxOStm, EETextFormat::Xml);
513 uno::Reference< embed::XStorage > xWorkStore =
520 SfxMedium aMedium( xWorkStore, OUString() );
524 uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
525 if ( xTransact.is() )
528 rxOStm->SetBufferSize( 0xff00 );
529 rxOStm->WriteStream( *pTempStream );
533 xWorkStore->dispose();
539 OSL_FAIL(
"unknown object id");
550 return nCells > 1000;
695 for (nCol=nStartX; nCol<=nEndX; nCol++)
696 if (
m_pDoc->ColHidden(nCol, nSrcTab) )
697 rDestDoc.
ShowCol( nCol, 0,
false );
707 for (
SCROW nRow = nStartY; nRow <= nEndY; ++nRow)
709 if (
m_pDoc->RowHidden(nRow, nSrcTab) )
710 rDestDoc.
ShowRow( nRow, 0,
false );
716 bool bManual =
m_pDoc->IsManualRowHeight(nRow, nSrcTab);
725 ScRange aDestRange( nStartX,nStartY,0, nEndX,nEndY,0 );
726 bool bWasCut =
m_pDoc->IsCutMode();
728 m_pDoc->SetClipArea( aDestRange,
true );
730 m_pDoc->SetClipArea( aDestRange, bWasCut );
734 ScRange aMergeRange = aDestRange;
737 m_pDoc->CopyDdeLinks( rDestDoc );
752 pDestPool->
CopyStyleFrom( pStylePool, aStyleName, SfxStyleFamily::Page );
756 aViewData.
SetScreen( nStartX,nStartY, nEndX,nEndY );
768 for (nCol=0; nCol<nStartX; nCol++)
779 for (nCol=nStartX; nCol<=nEndX; nCol++)
782 if ( bLimitToPageSize && nSizeX+nAdd > aPaperSize.
Width() && nSizeX )
786 for (
SCROW nRow=nStartY; nRow<=nEndY; nRow++)
789 if ( bLimitToPageSize && nSizeY+nAdd > aPaperSize.
Height() && nSizeY )
839 OSL_FAIL(
"Sheet not found in ScTransferObj::StripRefs");
846 for (
bool bHas = aIter.
first(); bHas; bHas = aIter.
next())
854 while ( !bOut && aRefIter.
GetNextRef( aRef ) )
868 if (nErrCode != FormulaError::NONE)
871 SvxCellHorJustify::Standard )
css::uno::Reference< css::datatransfer::XTransferable > CreateTransferable(const ESelection &rSelection) const
std::unique_ptr< EditTextObject > CreateTextObject()
sal_Int32 GetParagraphCount() const
sal_Int32 GetTextLen() const
void Write(SvStream &rOutput, EETextFormat)
Size GetOutputSize() const
Walk through all cells in an area.
ScFormulaCell * getFormulaCell()
const ScAddress & GetPos() const
Iterator for references in a formula cell.
bool GetNextRef(ScRange &rRange)
SC_DLLPUBLIC bool DeleteContents(const ScMarkData &rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi)
const ScDocument & GetDocument() const
ScDrawLayer * MakeDrawLayer()
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
virtual void SetVisArea(const tools::Rectangle &rVisArea) override
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 sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC void CopyFromClip(const ScRange &rDestRange, const ScMarkData &rMark, InsertDeleteFlags nInsFlag, ScDocument *pRefUndoDoc, ScDocument *pClipDoc, bool bResetCut=true, bool bAsLink=false, bool bIncludeFiltered=true, bool bSkipEmptyCells=false, const ScRangeList *pDestRanges=nullptr)
Paste data from a clipboard document into this document.
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC void SetLayoutRTL(SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling=ScObjectHandling::RecalcPosMode)
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
SC_DLLPUBLIC void UpdateChartListenerCollection()
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow)
SC_DLLPUBLIC void CopyStdStylesFrom(const ScDocument &rSrcDoc)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
bool ShrinkToUsedDataArea(bool &o_bShrunk, SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bColumnsOnly, bool bStickyTopRow=false, bool bStickyLeftCol=false, ScDataAreaExtras *pDataAreaExtras=nullptr) const
Shrink a range to only include used data area.
SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow)
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
SC_DLLPUBLIC void SetRowHeight(SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight)
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
SC_DLLPUBLIC void SetManualHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual)
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
bool IsChartListenerCollectionNeedsUpdate() const
SC_DLLPUBLIC SCTAB GetTableCount() const
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
static OUString GetErrorString(FormulaError nErrNumber)
static tools::SvRef< ScDocShell > xDrawClipDocShellRef
void SetIncludeFiltered(bool b)
static bool IsFormatSupported(SotClipboardFormatId nFormat)
void SetExportTextOptions(const ScExportTextOptions &options)
bool ExportString(OUString &, SotClipboardFormatId)
bool ExportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void SelectTable(SCTAB nTab, bool bNew)
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
void MarkFromRangeList(const ScRangeList &rList, bool bReset)
const ScDragData & GetDragData() const
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
static void DrawToDev(ScDocument &rDoc, OutputDevice *pDev, double nPrintFactor, const tools::Rectangle &rBound, ScViewData *pViewData, bool bMetaFile)
void CopyStyleFrom(SfxStyleSheetBasePool *pSrcPool, const OUString &rName, SfxStyleFamily eFamily, bool bNewStyleHierarchy=false)
static ScTabViewShell * GetActiveViewShell()
void InitDocShell(bool bLimitToPageSize)
void SetDragSourceFlags(ScDragSrc nFlags)
ScMarkData GetSourceMarkData() const
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
ScDragSrc m_nDragSourceFlags
SfxObjectShellRef m_aDocShellRef
void SetDragWasInternal()
void SetDragSource(ScDocShell *pSourceShell, const ScMarkData &rMark)
static void StripRefs(ScDocument &rDoc, SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, ScDocument &rDestDoc)
void SetDragHandlePos(SCCOL nX, SCROW nY)
ScDocShell * GetSourceDocShell()
static void PaintToDev(OutputDevice *pDev, ScDocument &rDoc, double nPrintFactor, const ScRange &rBlock)
ScTransferObj(const std::shared_ptr< ScDocument > &pClipDoc, TransferableObjectDescriptor aDesc)
virtual ~ScTransferObj() override
ScDocument * GetSourceDocument()
void SetVisibleTab(SCTAB nNew)
std::shared_ptr< ScDocument > m_pDoc
void SetDrawPersist(const SfxObjectShellRef &rRef)
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
SfxObjectShellRef m_aDrawPersistRef
virtual void DragFinished(sal_Int8 nDropAction) override
rtl::Reference< ScCellRangesBase > m_xDragSourceRanges
static SfxObjectShell * SetDrawClipDoc(bool bAnyOle, const std::shared_ptr< ScDocument > &={})
virtual sal_Bool SAL_CALL isComplex() override
TransferableObjectDescriptor m_aObjDesc
void SetSourceCursorPos(SCCOL nX, SCROW nY)
static SC_DLLPUBLIC ScTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
bool WasSourceCursorInSelection() const
virtual void AddSupportedFormats() override
SC_DLLPUBLIC void SetUseInApi(bool bSet)
static void GetAreaSize(const ScDocument &rDoc, SCTAB nTab1, SCTAB nTab2, SCROW &nRow, SCCOL &nCol)
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void SetTabNo(SCTAB nNewTab)
void SetCurX(SCCOL nNewCurX)
void SetCurY(SCROW nNewCurY)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
MapUnit GetMapUnit() const
bool DoSaveObjectAs(SfxMedium &rNewStor, bool bCommit)
void DoDraw(OutputDevice *, const Point &rObjPos, const Size &rSize, const JobSetup &rSetup, sal_uInt16 nAspect=ASPECT_CONTENT, bool bOutputForScreen=false)
virtual tools::Rectangle GetVisArea(sal_uInt16 nAspect) const
void SetupStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, sal_Int32 nVersion, bool bTemplate) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual SfxItemSet & GetItemSet()
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
virtual void DragFinished(sal_Int8 nDropAction) override
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef) const
bool SetTransferableObjectDescriptor(const TransferableObjectDescriptor &rDesc)
bool SetObject(void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
bool SetString(const OUString &rString)
bool SetBitmapEx(const BitmapEx &rBitmap, const css::datatransfer::DataFlavor &rFlavor)
bool HasFormat(SotClipboardFormatId nFormat)
void PrepareOLE(const TransferableObjectDescriptor &rObjDesc)
void AddFormat(SotClipboardFormatId nFormat)
bool SetGDIMetaFile(const GDIMetaFile &rMtf)
static css::uno::Reference< css::embed::XStorage > GetStorageFromStream(const css::uno::Reference< css::io::XStream > &xStream, sal_Int32 nStorageMode=css::embed::ElementModes::READWRITE, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
const OUString & getString() const
SvStream * GetStream(StreamMode eMode)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
ScTransferObj * pCellTransfer
These options control how multi-line cells are converted during export in certain lossy formats (such...
sal_Unicode mcSeparatorConvertTo
NewlineConversion meNewlineConversion
This is very similar to ScCellValue, except that it references the original value instead of copying ...
const EditTextObject * getEditText() const
Store parameters used in the ScDocument::SetString() method.
void setTextInput()
Call this whenever you need to unconditionally set input as text, no matter what the input is.
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_ODF_TEXT_FLAT
constexpr sal_uInt32 SCTRANS_TYPE_EMBOBJ
static ScRange lcl_reduceBlock(const ScDocument &rDoc, ScRange aReducedBlock, bool bIncludeVisual=false)
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_RTF
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_BIN
constexpr sal_uInt32 SCTRANS_TYPE_IMPEX