23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/embed/XTransactedObject.hpp>
27 #include <osl/diagnose.h>
45 #include <document.hxx>
51 #include <docfunc.hxx>
62 #include <stlpool.hxx>
81 for(
SCTAB nTab = nTab1; nTab <= nTab2; nTab++ )
88 if( nLastCol > nMaxCol )
90 if( nLastRow > nMaxRow )
105 aViewData.SetTabNo( rBlock.
aEnd.
Tab() );
118 m_nSourceCursorX( m_pDoc->MaxCol() + 1 ),
119 m_nSourceCursorY( m_pDoc->MaxRow() + 1 ),
121 m_bDragWasInternal(
false ),
122 m_bUsedForLink(
false ),
125 OSL_ENSURE(
m_pDoc->IsClipboard(),
"wrong document");
133 m_pDoc->GetClipStart( nCol1, nRow1 );
134 m_pDoc->GetClipArea( nCol2, nRow2,
true );
135 nCol2 = sal::static_int_cast<
SCCOL>( nCol2 + nCol1 );
136 nRow2 = sal::static_int_cast<
SCROW>( nRow2 + nRow1 );
154 OSL_ENSURE(!bFirst,
"no sheet selected");
158 if ( nCol2>=
m_pDoc->MaxCol() && nRow2>=
m_pDoc->MaxRow() )
163 if( nMaxRow < nRow2 )
165 if( nMaxCol < nCol2 )
185 OSL_FAIL(
"ScTransferObj wasn't released");
199 return comphelper::getFromUnoTunnel<ScTransferObj>(xTransferable);
205 AddFormat( SotClipboardFormatId::EMBED_SOURCE );
206 AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
207 AddFormat( SotClipboardFormatId::GDIMETAFILE );
209 AddFormat( SotClipboardFormatId::BITMAP );
216 AddFormat( SotClipboardFormatId::STRING );
217 AddFormat( SotClipboardFormatId::STRING_TSVC );
220 AddFormat( SotClipboardFormatId::RICHTEXT );
223 AddFormat( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT );
235 SCCOL nPrintAreaEndCol = 0;
236 SCROW nPrintAreaEndRow = 0;
253 bool bShrunk =
false;
255 false,
true ,
true , &aDataAreaExtras);
260 bool bShrunk =
false;
262 false,
false ,
false );
265 if ( nPrintAreaEndRow > nEndRow )
266 nEndRow = nPrintAreaEndRow;
268 if ( nPrintAreaEndCol > nEndCol )
269 nEndCol = nPrintAreaEndCol;
271 aReducedBlock =
ScRange(nStartCol, nStartRow, aReducedBlock.
aStart.
Tab(), nEndCol, nEndRow, aReducedBlock.
aEnd.
Tab());
273 return aReducedBlock;
285 bool bReduceBlockFormat =
286 nFormat == SotClipboardFormatId::HTML
287 || nFormat == SotClipboardFormatId::RTF
288 || nFormat == SotClipboardFormatId::RICHTEXT
289 || nFormat == SotClipboardFormatId::BITMAP
290 || nFormat == SotClipboardFormatId::PNG;
292 const bool bIncludeVisual = (nFormat == SotClipboardFormatId::BITMAP ||
293 nFormat == SotClipboardFormatId::PNG);
295 if (bReduceBlockFormat)
298 if ( nFormat == SotClipboardFormatId::LINKSRCDESCRIPTOR || nFormat == SotClipboardFormatId::OBJECTDESCRIPTOR )
302 else if ( ( nFormat == SotClipboardFormatId::RTF || nFormat == SotClipboardFormatId::RICHTEXT ||
318 aEngine.SetTextCurrentDefaults(*pObj);
326 if (!aText.isEmpty())
327 aEngine.SetTextCurrentDefaults(aText);
332 ((nFormat == SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT) ?
337 || nFormat == SotClipboardFormatId::RICHTEXT )
341 if ( nFormat == SotClipboardFormatId::LINK )
356 const bool bPlainMulti = (nFormat == SotClipboardFormatId::STRING &&
363 (nFormat == SotClipboardFormatId::STRING_TSVC));
384 else if ( rFlavor.DataType.equals(
cppu::UnoType<uno::Sequence< sal_Int8 >>::
get() ) )
391 OSL_FAIL(
"unknown DataType");
394 else if ( nFormat == SotClipboardFormatId::BITMAP || nFormat == SotClipboardFormatId::PNG )
400 pVirtDev->SetOutputSizePixel(pVirtDev->LogicToPixel(aMMRect.
GetSize(),
MapMode(MapUnit::Map100thMM)));
404 pVirtDev->SetMapMode(
MapMode( MapUnit::MapPixel ) );
405 BitmapEx aBmp = pVirtDev->GetBitmapEx(
Point(), pVirtDev->GetOutputSize() );
408 else if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
424 pVDev->EnableOutput(
false );
425 pVDev->SetMapMode( aMapMode );
437 else if ( nFormat == SotClipboardFormatId::EMBED_SOURCE )
451 const datatransfer::DataFlavor& rFlavor )
456 switch (nUserObjectId)
464 if ( pImpEx->
ExportStream( *rxOStm, OUString(), nFormat ) )
475 pEngine->
Write( *rxOStm, EETextFormat::Rtf );
489 uno::Reference<datatransfer::XTransferable> xEditTrans = pEngine->
CreateTransferable( aSel );
500 pEngine->
Write(*rxOStm, EETextFormat::Xml);
511 uno::Reference< embed::XStorage > xWorkStore =
518 SfxMedium aMedium( xWorkStore, OUString() );
522 uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
523 if ( xTransact.is() )
529 rxOStm->SetBufferSize( 0xff00 );
530 rxOStm->WriteStream( *pSrcStm );
536 xWorkStore->dispose();
542 OSL_FAIL(
"unknown object id");
553 return nCells > 1000;
654 const ScRangeList& rRanges = pRangesObj->GetRangeList();
655 aMarkData.MarkFromRangeList( rRanges,
false );
698 for (nCol=nStartX; nCol<=nEndX; nCol++)
699 if (
m_pDoc->ColHidden(nCol, nSrcTab) )
700 rDestDoc.
ShowCol( nCol, 0,
false );
710 for (
SCROW nRow = nStartY; nRow <= nEndY; ++nRow)
712 if (
m_pDoc->RowHidden(nRow, nSrcTab) )
713 rDestDoc.
ShowRow( nRow, 0,
false );
719 bool bManual =
m_pDoc->IsManualRowHeight(nRow, nSrcTab);
731 ScRange aDestRange( nStartX,nStartY,0, nEndX,nEndY,0 );
732 bool bWasCut =
m_pDoc->IsCutMode();
734 m_pDoc->SetClipArea( aDestRange,
true );
736 m_pDoc->SetClipArea( aDestRange, bWasCut );
740 ScRange aMergeRange = aDestRange;
743 m_pDoc->CopyDdeLinks( rDestDoc );
758 pDestPool->
CopyStyleFrom( pStylePool, aStyleName, SfxStyleFamily::Page );
762 aViewData.
SetScreen( nStartX,nStartY, nEndX,nEndY );
774 for (nCol=0; nCol<nStartX; nCol++)
785 for (nCol=nStartX; nCol<=nEndX; nCol++)
788 if ( bLimitToPageSize && nSizeX+nAdd > aPaperSize.
Width() && nSizeX )
792 for (
SCROW nRow=nStartY; nRow<=nEndY; nRow++)
795 if ( bLimitToPageSize && nSizeY+nAdd > aPaperSize.
Height() && nSizeY )
845 OSL_FAIL(
"Sheet not found in ScTransferObj::StripRefs");
852 for (
bool bHas = aIter.
first(); bHas; bHas = aIter.
next())
860 while ( !bOut && aRefIter.
GetNextRef( aRef ) )
874 if (nErrCode != FormulaError::NONE)
877 SvxCellHorJustify::Standard )
912 return theScTransferUnoTunnelId.
getSeq();
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow)
static ScRange lcl_reduceBlock(const ScDocument &rDoc, ScRange aReducedBlock, bool bIncludeVisual=false)
static const com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId()
constexpr sal_uInt32 SCTRANS_TYPE_EMBOBJ
const ScDragData & GetDragData() const
OUString getString() const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Store parameters used in the ScDocument::SetString() method.
void SetCurX(SCCOL nNewCurX)
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
bool SetBitmapEx(const BitmapEx &rBitmap, const css::datatransfer::DataFlavor &rFlavor)
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
SC_DLLPUBLIC bool DeleteContents(const ScMarkData &rMark, InsertDeleteFlags nFlags, bool bRecord, bool bApi)
ScDocShell * GetDocShell() const
void setWidth(tools::Long nWidth)
void setTextInput()
Call this whenever you need to unconditionally set input as text, no matter what the input is...
virtual void DragFinished(sal_Int8 nDropAction) override
bool ExportString(OUString &, SotClipboardFormatId)
static void DrawToDev(ScDocument &rDoc, OutputDevice *pDev, double nPrintFactor, const tools::Rectangle &rBound, ScViewData *pViewData, bool bMetaFile)
SC_DLLPUBLIC void CopyStdStylesFrom(const ScDocument &rSrcDoc)
static bool IsFormatSupported(SotClipboardFormatId nFormat)
SC_DLLPUBLIC void SetLayoutRTL(SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling=ScObjectHandling::RecalcPosMode)
These options control how multi-line cells are converted during export in certain lossy formats (such...
void SetDragSource(ScDocShell *pSourceShell, const ScMarkData &rMark)
SfxObjectShellRef m_aDocShellRef
void SetDragSourceFlags(ScDragSrc nFlags)
bool SetTransferableObjectDescriptor(const TransferableObjectDescriptor &rDesc)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
virtual void DragFinished(sal_Int8 nDropAction) override
bool HasFormat(SotClipboardFormatId nFormat)
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
void InitDocShell(bool bLimitToPageSize)
bool WasSourceCursorInSelection() const
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
virtual SfxItemSet & GetItemSet()
This is very similar to ScCellValue, except that it references the original value instead of copying ...
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
ScFormulaCell * getFormulaCell()
ScTransferObj * pCellTransfer
bool SetObject(void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
void SetSourceCursorPos(SCCOL nX, SCROW nY)
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
void SetDragHandlePos(SCCOL nX, SCROW nY)
ScDocument * GetSourceDocument()
void AddFormat(SotClipboardFormatId nFormat)
constexpr tools::Long Width() 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.
static void GetAreaSize(const ScDocument &rDoc, SCTAB nTab1, SCTAB nTab2, SCROW &nRow, SCCOL &nCol)
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
NewlineConversion meNewlineConversion
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC SCTAB GetTableCount() const
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_ODF_TEXT_FLAT
ScTransferObj(const std::shared_ptr< ScDocument > &pClipDoc, const TransferableObjectDescriptor &rDesc)
css::uno::Reference< css::sheet::XSheetCellRanges > m_xDragSourceRanges
Walk through all cells in an area.
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
sal_Int32 GetTextLen() const
ScDrawLayer * MakeDrawLayer()
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 const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
const css::uno::Sequence< sal_Int8 > & getSeq() 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 SCCOL MaxCol() const
void SetDrawPersist(const SfxObjectShellRef &rRef)
bool IsChartListenerCollectionNeedsUpdate() const
bool SetString(const OUString &rString)
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
void SetDragWasInternal()
OUString const & GetURL() const
void SelectTable(SCTAB nTab, bool bNew)
static tools::SvRef< ScDocShell > xDrawClipDocShellRef
void SetCurY(SCROW nNewCurY)
Iterator for references in a formula cell.
TransferableObjectDescriptor m_aObjDesc
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
ScSheetLimits & GetSheetLimits() const
virtual ~ScTransferObj() override
Size GetOutputSize() const
std::unique_ptr< EditTextObject > CreateTextObject()
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_BIN
SC_DLLPUBLIC void SetRowHeight(SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight)
void PrepareOLE(const TransferableObjectDescriptor &rObjDesc)
ScMarkData GetSourceMarkData() const
static css::uno::Reference< css::embed::XStorage > GetStorageFromURL(const OUString &aURL, sal_Int32 nStorageMode, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
virtual void AddSupportedFormats() override
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
ScDragSrc m_nDragSourceFlags
sal_Unicode mcSeparatorConvertTo
bool ExportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
void SetVisibleTab(SCTAB nNew)
sal_Int32 GetParagraphCount() const
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
const ScAddress & GetPos() const
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
static ScTabViewShell * GetActiveViewShell()
bool GetNextRef(ScRange &rRange)
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef) const
static SfxObjectShell * SetDrawClipDoc(bool bAnyOle, const std::shared_ptr< ScDocument > &={})
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void CopyStyleFrom(ScStyleSheetPool *pSrcPool, const OUString &rName, SfxStyleFamily eFamily)
constexpr tools::Long Height() const
SC_DLLPUBLIC void SetUseInApi(bool bSet)
sal_Int64 getSomethingImpl(const css::uno::Sequence< sal_Int8 > &rId, T *pThis, FallbackToGetSomethingOf< Base >={})
css::uno::Reference< css::datatransfer::XTransferable > CreateTransferable(const ESelection &rSelection) const
MapUnit GetMapUnit() const
void SetExportTextOptions(const ScExportTextOptions &options)
void DoDraw(OutputDevice *, const Point &rObjPos, const Size &rSize, const JobSetup &rSetup, sal_uInt16 nAspect=ASPECT_CONTENT)
static SC_DLLPUBLIC ScTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
SC_DLLPUBLIC void SetManualHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual)
void Write(SvStream &rOutput, EETextFormat)
SfxObjectShellRef m_aDrawPersistRef
const ScDocument & GetDocument() const
SC_DLLPUBLIC void UpdateChartListenerCollection()
virtual sal_Bool SAL_CALL isComplex() override
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
constexpr sal_uInt32 SCTRANS_TYPE_IMPEX
void SetIncludeFiltered(bool b)
void setHeight(tools::Long nHeight)
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_RTF
bool DoSaveObjectAs(SfxMedium &rNewStor, bool bCommit)
void SetupStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, sal_Int32 nVersion, bool bTemplate) const
std::shared_ptr< ScDocument > m_pDoc
virtual void SetVisArea(const tools::Rectangle &rVisArea) override
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
static void PaintToDev(OutputDevice *pDev, ScDocument &rDoc, double nPrintFactor, const ScRange &rBlock)
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual sal_Int64 SAL_CALL getSomething(const com::sun::star::uno::Sequence< sal_Int8 > &rId) override
static OUString GetErrorString(FormulaError nErrNumber)
void EnableKillingFile(bool bEnable=true)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow)
bool SetGDIMetaFile(const GDIMetaFile &rMtf)
virtual tools::Rectangle GetVisArea(sal_uInt16 nAspect) const
ScDocShell * GetSourceDocShell()
static void StripRefs(ScDocument &rDoc, SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, ScDocument &rDestDoc)
bool m_bDetectedRangeSegmentation false