diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-07-20 11:15:05 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-08-02 11:41:49 -0400 |
commit | 93400d9b37063721d4d925a9c37020633801248c (patch) | |
tree | 8d607da5b6159e9a1308c824273cf03711954f33 /sc | |
parent | 05683f3ade1ed623847df5204338f440981239c7 (diff) |
lok: minimal implementation of isComplex for calc for now.
Change-Id: Ic4141d30a0ff48a9ec5ecc8e6119d9d779c4a0fc
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/app/seltrans.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 83 | ||||
-rw-r--r-- | sc/source/ui/inc/seltrans.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/transobj.hxx | 1 |
4 files changed, 64 insertions, 33 deletions
diff --git a/sc/source/ui/app/seltrans.cxx b/sc/source/ui/app/seltrans.cxx index 79a0437f6061..3a1c2128d560 100644 --- a/sc/source/ui/app/seltrans.cxx +++ b/sc/source/ui/app/seltrans.cxx @@ -413,4 +413,16 @@ void ScSelectionTransferObj::ObjectReleased() TransferableHelper::ObjectReleased(); } +sal_Bool SAL_CALL ScSelectionTransferObj::isComplex() +{ + switch (eMode) + { + case SC_SELTRANS_CELL: + case SC_SELTRANS_CELLS: + return false; + default: + return true; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index c78e8ae9e859..dfa3d47cf8e9 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -234,6 +234,42 @@ void ScTransferObj::AddSupportedFormats() } } +static ScRange lcl_reduceBlock(ScDocumentUniquePtr &pDoc, ScRange aReducedBlock, bool bIncludeVisual = false) +{ + if ((aReducedBlock.aEnd.Col() == MAXCOL || aReducedBlock.aEnd.Row() == MAXROW) && + aReducedBlock.aStart.Tab() == aReducedBlock.aEnd.Tab()) + { + // Shrink the block here so we don't waste time creating huge + // output when whole columns or rows are selected. + + SCCOL nPrintAreaEndCol = 0; + SCROW nPrintAreaEndRow = 0; + if (bIncludeVisual) + pDoc->GetPrintArea( aReducedBlock.aStart.Tab(), nPrintAreaEndCol, nPrintAreaEndRow, true ); + + // Shrink the area to allow pasting to external applications. + // Shrink to real data area for HTML, RTF and RICHTEXT, but include + // all objects and top-left area for BITMAP and PNG. + SCCOL nStartCol = aReducedBlock.aStart.Col(); + SCROW nStartRow = aReducedBlock.aStart.Row(); + SCCOL nEndCol = aReducedBlock.aEnd.Col(); + SCROW nEndRow = aReducedBlock.aEnd.Row(); + bool bShrunk = false; + pDoc->ShrinkToUsedDataArea( bShrunk, aReducedBlock.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, + false, bIncludeVisual /*bStickyTopRow*/, bIncludeVisual /*bStickyLeftCol*/, + bIncludeVisual /*bConsiderCellNotes*/, bIncludeVisual /*bConsiderCellDrawObjects*/); + + if ( nPrintAreaEndRow > nEndRow ) + nEndRow = nPrintAreaEndRow; + + if ( nPrintAreaEndCol > nEndCol ) + nEndCol = nPrintAreaEndCol; + + aReducedBlock = ScRange(nStartCol, nStartRow, aReducedBlock.aStart.Tab(), nEndCol, nEndRow, aReducedBlock.aEnd.Tab()); + } + return aReducedBlock; +} + bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ ) { SotClipboardFormatId nFormat = SotExchange::GetFormat( rFlavor ); @@ -250,39 +286,11 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt || nFormat == SotClipboardFormatId::BITMAP || nFormat == SotClipboardFormatId::PNG; - if (bReduceBlockFormat && (m_aBlock.aEnd.Col() == MAXCOL || m_aBlock.aEnd.Row() == MAXROW) && - m_aBlock.aStart.Tab() == m_aBlock.aEnd.Tab()) - { - // Shrink the block here so we don't waste time creating huge - // output when whole columns or rows are selected. - - SCCOL nPrintAreaEndCol = 0; - SCROW nPrintAreaEndRow = 0; - const bool bIncludeVisual = (nFormat == SotClipboardFormatId::BITMAP || - nFormat == SotClipboardFormatId::PNG); - if (bIncludeVisual) - m_pDoc->GetPrintArea( m_aBlock.aStart.Tab(), nPrintAreaEndCol, nPrintAreaEndRow, true ); - - // Shrink the area to allow pasting to external applications. - // Shrink to real data area for HTML, RTF and RICHTEXT, but include - // all objects and top-left area for BITMAP and PNG. - SCCOL nStartCol = aReducedBlock.aStart.Col(); - SCROW nStartRow = aReducedBlock.aStart.Row(); - SCCOL nEndCol = aReducedBlock.aEnd.Col(); - SCROW nEndRow = aReducedBlock.aEnd.Row(); - bool bShrunk = false; - m_pDoc->ShrinkToUsedDataArea( bShrunk, aReducedBlock.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, - false, bIncludeVisual /*bStickyTopRow*/, bIncludeVisual /*bStickyLeftCol*/, - bIncludeVisual /*bConsiderCellNotes*/, bIncludeVisual /*bConsiderCellDrawObjects*/); - - if ( nPrintAreaEndRow > nEndRow ) - nEndRow = nPrintAreaEndRow; - - if ( nPrintAreaEndCol > nEndCol ) - nEndCol = nPrintAreaEndCol; - - aReducedBlock = ScRange(nStartCol, nStartRow, aReducedBlock.aStart.Tab(), nEndCol, nEndRow, aReducedBlock.aEnd.Tab()); - } + const bool bIncludeVisual = (nFormat == SotClipboardFormatId::BITMAP || + nFormat == SotClipboardFormatId::PNG); + + if (bReduceBlockFormat) + aReducedBlock = lcl_reduceBlock(m_pDoc, m_aBlock, bIncludeVisual); if ( nFormat == SotClipboardFormatId::LINKSRCDESCRIPTOR || nFormat == SotClipboardFormatId::OBJECTDESCRIPTOR ) { @@ -535,6 +543,15 @@ bool ScTransferObj::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* p return bRet; } +sal_Bool SAL_CALL ScTransferObj::isComplex() +{ + ScRange aReduced = lcl_reduceBlock(m_pDoc, m_aBlock); + size_t nCells = (aReduced.aEnd.Col() - aReduced.aStart.Col() + 1) * + (aReduced.aEnd.Row() - aReduced.aStart.Row() + 1) * + (aReduced.aEnd.Tab() - aReduced.aStart.Tab() + 1); + return nCells > 1000; +} + void ScTransferObj::DragFinished( sal_Int8 nDropAction ) { if ( nDropAction == DND_ACTION_MOVE && !m_bDragWasInternal && !(m_nDragSourceFlags & ScDragSrc::Navigator) ) diff --git a/sc/source/ui/inc/seltrans.hxx b/sc/source/ui/inc/seltrans.hxx index af73f0adf896..83adb2c11eb2 100644 --- a/sc/source/ui/inc/seltrans.hxx +++ b/sc/source/ui/inc/seltrans.hxx @@ -67,6 +67,7 @@ public: virtual void AddSupportedFormats() override; virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; virtual void ObjectReleased() override; + virtual sal_Bool SAL_CALL isComplex() override; }; #endif diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx index 5b7f405fb55e..1ebfd1a4e892 100644 --- a/sc/source/ui/inc/transobj.hxx +++ b/sc/source/ui/inc/transobj.hxx @@ -76,6 +76,7 @@ public: virtual bool WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override; virtual void DragFinished( sal_Int8 nDropAction ) override; + virtual sal_Bool SAL_CALL isComplex() override; ScDocument* GetDocument() const { return m_pDoc.get(); } // owned by ScTransferObj const ScRange& GetRange() const { return m_aBlock; } |