LibreOffice Module sc (master)  1
transobj.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <scitems.hxx>
21 #include <editeng/justifyitem.hxx>
22 
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/embed/XTransactedObject.hpp>
25 
26 #include <o3tl/unit_conversion.hxx>
27 #include <osl/diagnose.h>
28 #include <unotools/tempfile.hxx>
30 #include <comphelper/fileformat.h>
33 #include <sot/storage.hxx>
34 #include <vcl/gdimtf.hxx>
35 #include <vcl/jobset.hxx>
36 #include <vcl/svapp.hxx>
37 #include <vcl/virdev.hxx>
38 #include <sfx2/docfile.hxx>
39 
40 #include <transobj.hxx>
41 #include <patattr.hxx>
42 #include <cellvalue.hxx>
43 #include <cellform.hxx>
44 #include <document.hxx>
45 #include <viewopti.hxx>
46 #include <editutil.hxx>
47 #include <impex.hxx>
48 #include <formulacell.hxx>
49 #include <printfun.hxx>
50 #include <docfunc.hxx>
51 #include <scmod.hxx>
52 #include <dragdata.hxx>
53 
54 #include <editeng/paperinf.hxx>
55 #include <editeng/sizeitem.hxx>
56 #include <formula/errorcodes.hxx>
57 #include <docsh.hxx>
58 #include <markdata.hxx>
59 #include <stlpool.hxx>
60 #include <viewdata.hxx>
61 #include <dociter.hxx>
62 #include <cellsuno.hxx>
63 #include <stringutil.hxx>
64 #include <formulaiter.hxx>
65 
66 using namespace com::sun::star;
67 
68 constexpr sal_uInt32 SCTRANS_TYPE_IMPEX = 1;
69 constexpr sal_uInt32 SCTRANS_TYPE_EDIT_RTF = 2;
70 constexpr sal_uInt32 SCTRANS_TYPE_EDIT_BIN = 3;
71 constexpr sal_uInt32 SCTRANS_TYPE_EMBOBJ = 4;
72 constexpr sal_uInt32 SCTRANS_TYPE_EDIT_ODF_TEXT_FLAT = 5;
73 
74 void ScTransferObj::GetAreaSize( const ScDocument& rDoc, SCTAB nTab1, SCTAB nTab2, SCROW& nRow, SCCOL& nCol )
75 {
76  SCCOL nMaxCol = 0;
77  SCROW nMaxRow = 0;
78  for( SCTAB nTab = nTab1; nTab <= nTab2; nTab++ )
79  {
80  SCCOL nLastCol = 0;
81  SCROW nLastRow = 0;
82  // GetPrintArea instead of GetCellArea - include drawing objects
83  if( rDoc.GetPrintArea( nTab, nLastCol, nLastRow ) )
84  {
85  if( nLastCol > nMaxCol )
86  nMaxCol = nLastCol;
87  if( nLastRow > nMaxRow )
88  nMaxRow = nLastRow;
89  }
90  }
91  nRow = nMaxRow;
92  nCol = nMaxCol;
93 }
94 
95 void ScTransferObj::PaintToDev( OutputDevice* pDev, ScDocument& rDoc, double nPrintFactor,
96  const ScRange& rBlock )
97 {
98  tools::Rectangle aBound( Point(), pDev->GetOutputSize() );
99 
100  ScViewData aViewData(rDoc);
101 
102  aViewData.SetTabNo( rBlock.aEnd.Tab() );
103  aViewData.SetScreen( rBlock.aStart.Col(), rBlock.aStart.Row(),
104  rBlock.aEnd.Col(), rBlock.aEnd.Row() );
105 
106  ScPrintFunc::DrawToDev( rDoc, pDev, nPrintFactor, aBound, &aViewData, false/*bMetaFile*/ );
107 }
108 
110  m_pDoc( std::move(pClipDoc ) ),
111  m_nNonFiltered(0),
112  m_aObjDesc( rDesc ),
113  m_nDragHandleX( 0 ),
114  m_nDragHandleY( 0 ),
115  m_nSourceCursorX( m_pDoc->MaxCol() + 1 ),
116  m_nSourceCursorY( m_pDoc->MaxRow() + 1 ),
117  m_nDragSourceFlags( ScDragSrc::Undefined ),
118  m_bDragWasInternal( false ),
119  m_bUsedForLink( false ),
120  m_bUseInApi( false )
121 {
122  OSL_ENSURE(m_pDoc->IsClipboard(), "wrong document");
123 
124  // get aBlock from clipboard doc
125 
126  SCCOL nCol1;
127  SCROW nRow1;
128  SCCOL nCol2;
129  SCROW nRow2;
130  m_pDoc->GetClipStart( nCol1, nRow1 );
131  m_pDoc->GetClipArea( nCol2, nRow2, true ); // real source area - include filtered rows
132  nCol2 = sal::static_int_cast<SCCOL>( nCol2 + nCol1 );
133  nRow2 = sal::static_int_cast<SCROW>( nRow2 + nRow1 );
134 
135  SCCOL nDummy;
136  m_pDoc->GetClipArea( nDummy, m_nNonFiltered, false );
137  m_bHasFiltered = (m_nNonFiltered < (nRow2 - nRow1));
138  ++m_nNonFiltered; // to get count instead of diff
139 
140  SCTAB nTab1=0;
141  SCTAB nTab2=0;
142  bool bFirst = true;
143  for (SCTAB i=0; i< m_pDoc->GetTableCount(); i++)
144  if (m_pDoc->HasTable(i))
145  {
146  if (bFirst)
147  nTab1 = i;
148  nTab2 = i;
149  bFirst = false;
150  }
151  OSL_ENSURE(!bFirst, "no sheet selected");
152 
153  // only limit to used cells if whole sheet was marked
154  // (so empty cell areas can be copied)
155  if ( nCol2>=m_pDoc->MaxCol() && nRow2>=m_pDoc->MaxRow() )
156  {
157  SCROW nMaxRow;
158  SCCOL nMaxCol;
159  GetAreaSize( *m_pDoc, nTab1, nTab2, nMaxRow, nMaxCol );
160  if( nMaxRow < nRow2 )
161  nRow2 = nMaxRow;
162  if( nMaxCol < nCol2 )
163  nCol2 = nMaxCol;
164  }
165 
166  m_aBlock = ScRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
167  m_nVisibleTab = nTab1; // valid table as default
168 
169  tools::Rectangle aMMRect = m_pDoc->GetMMRect( nCol1,nRow1, nCol2,nRow2, nTab1 );
170  m_aObjDesc.maSize = aMMRect.GetSize();
172 }
173 
175 {
176  SolarMutexGuard aSolarGuard;
177 
178  ScModule* pScMod = SC_MOD();
179  if (pScMod && pScMod->GetDragData().pCellTransfer == this)
180  {
181  OSL_FAIL("ScTransferObj wasn't released");
182  pScMod->ResetDragObject();
183  }
184 
185  m_pDoc.reset(); // ScTransferObj is owner of clipboard document
186 
187  m_aDocShellRef.clear(); // before releasing the mutex
188 
189  m_aDrawPersistRef.clear(); // after the model
190 
191 }
192 
193 ScTransferObj* ScTransferObj::GetOwnClipboard(const uno::Reference<datatransfer::XTransferable2>& xTransferable)
194 {
195  ScTransferObj* pObj = nullptr;
196  if (xTransferable.is())
197  {
198  uno::Reference<XUnoTunnel> xTunnel( xTransferable, uno::UNO_QUERY );
199  if ( xTunnel.is() )
200  {
201  sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() );
202  if ( nHandle )
203  pObj = dynamic_cast<ScTransferObj*>(reinterpret_cast<TransferableHelper*>( static_cast<sal_IntPtr>(nHandle) ));
204  }
205  }
206 
207  return pObj;
208 }
209 
211 {
212  // same formats as in ScSelectionTransferObj::AddSupportedFormats
213  AddFormat( SotClipboardFormatId::EMBED_SOURCE );
214  AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
215  AddFormat( SotClipboardFormatId::GDIMETAFILE );
216  AddFormat( SotClipboardFormatId::PNG );
217  AddFormat( SotClipboardFormatId::BITMAP );
218 
219  // ScImportExport formats
220  AddFormat( SotClipboardFormatId::HTML );
221  AddFormat( SotClipboardFormatId::SYLK );
222  AddFormat( SotClipboardFormatId::LINK );
223  AddFormat( SotClipboardFormatId::DIF );
224  AddFormat( SotClipboardFormatId::STRING );
225  AddFormat( SotClipboardFormatId::STRING_TSVC );
226 
227  AddFormat( SotClipboardFormatId::RTF );
228  AddFormat( SotClipboardFormatId::RICHTEXT );
229  if ( m_aBlock.aStart == m_aBlock.aEnd )
230  {
231  AddFormat( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT );
232  }
233 }
234 
235 static ScRange lcl_reduceBlock(const ScDocument& rDoc, ScRange aReducedBlock, bool bIncludeVisual = false)
236 {
237  if ((aReducedBlock.aEnd.Col() == rDoc.MaxCol() || aReducedBlock.aEnd.Row() == rDoc.MaxRow()) &&
238  aReducedBlock.aStart.Tab() == aReducedBlock.aEnd.Tab())
239  {
240  // Shrink the block here so we don't waste time creating huge
241  // output when whole columns or rows are selected.
242 
243  SCCOL nPrintAreaEndCol = 0;
244  SCROW nPrintAreaEndRow = 0;
245  if (bIncludeVisual)
246  rDoc.GetPrintArea( aReducedBlock.aStart.Tab(), nPrintAreaEndCol, nPrintAreaEndRow, true );
247 
248  // Shrink the area to allow pasting to external applications.
249  // Shrink to real data area for HTML, RTF and RICHTEXT, but include
250  // all objects and top-left area for BITMAP and PNG.
251  SCCOL nStartCol = aReducedBlock.aStart.Col();
252  SCROW nStartRow = aReducedBlock.aStart.Row();
253  SCCOL nEndCol = aReducedBlock.aEnd.Col();
254  SCROW nEndRow = aReducedBlock.aEnd.Row();
255  bool bShrunk = false;
256  rDoc.ShrinkToUsedDataArea( bShrunk, aReducedBlock.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow,
257  false, bIncludeVisual /*bStickyTopRow*/, bIncludeVisual /*bStickyLeftCol*/,
258  bIncludeVisual /*bConsiderCellNotes*/, bIncludeVisual /*bConsiderCellDrawObjects*/);
259 
260  if ( nPrintAreaEndRow > nEndRow )
261  nEndRow = nPrintAreaEndRow;
262 
263  if ( nPrintAreaEndCol > nEndCol )
264  nEndCol = nPrintAreaEndCol;
265 
266  aReducedBlock = ScRange(nStartCol, nStartRow, aReducedBlock.aStart.Tab(), nEndCol, nEndRow, aReducedBlock.aEnd.Tab());
267  }
268  return aReducedBlock;
269 }
270 
271 bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
272 {
273  SotClipboardFormatId nFormat = SotExchange::GetFormat( rFlavor );
274  bool bOK = false;
275 
276  if( HasFormat( nFormat ) )
277  {
278  ScRange aReducedBlock = m_aBlock;
279 
280  bool bReduceBlockFormat =
281  nFormat == SotClipboardFormatId::HTML
282  || nFormat == SotClipboardFormatId::RTF
283  || nFormat == SotClipboardFormatId::RICHTEXT
284  || nFormat == SotClipboardFormatId::BITMAP
285  || nFormat == SotClipboardFormatId::PNG;
286 
287  const bool bIncludeVisual = (nFormat == SotClipboardFormatId::BITMAP ||
288  nFormat == SotClipboardFormatId::PNG);
289 
290  if (bReduceBlockFormat)
291  aReducedBlock = lcl_reduceBlock(*m_pDoc, m_aBlock, bIncludeVisual);
292 
293  if ( nFormat == SotClipboardFormatId::LINKSRCDESCRIPTOR || nFormat == SotClipboardFormatId::OBJECTDESCRIPTOR )
294  {
296  }
297  else if ( ( nFormat == SotClipboardFormatId::RTF || nFormat == SotClipboardFormatId::RICHTEXT ||
298  nFormat == SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT ) && m_aBlock.aStart == m_aBlock.aEnd )
299  {
300  // RTF from a single cell is handled by EditEngine
301 
302  SCCOL nCol = m_aBlock.aStart.Col();
303  SCROW nRow = m_aBlock.aStart.Row();
304  SCTAB nTab = m_aBlock.aStart.Tab();
305  ScAddress aPos(nCol, nRow, nTab);
306 
307  const ScPatternAttr* pPattern = m_pDoc->GetPattern( nCol, nRow, nTab );
308  ScTabEditEngine aEngine( *pPattern, m_pDoc->GetEditPool(), m_pDoc.get() );
309  ScRefCellValue aCell(*m_pDoc, aPos);
310  if (aCell.meType == CELLTYPE_EDIT)
311  {
312  const EditTextObject* pObj = aCell.mpEditText;
313  aEngine.SetTextCurrentDefaults(*pObj);
314  }
315  else
316  {
317  SvNumberFormatter* pFormatter = m_pDoc->GetFormatTable();
318  sal_uInt32 nNumFmt = pPattern->GetNumberFormat(pFormatter);
319  OUString aText;
320  const Color* pColor;
321  ScCellFormat::GetString(aCell, nNumFmt, aText, &pColor, *pFormatter, *m_pDoc);
322  if (!aText.isEmpty())
323  aEngine.SetTextCurrentDefaults(aText);
324  }
325 
326  bOK = SetObject( &aEngine,
327  ((nFormat == SotClipboardFormatId::RTF) ? SCTRANS_TYPE_EDIT_RTF :
328  ((nFormat == SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT) ?
330  rFlavor );
331  }
332  else if ( ScImportExport::IsFormatSupported( nFormat ) || nFormat == SotClipboardFormatId::RTF
333  || nFormat == SotClipboardFormatId::RICHTEXT )
334  {
335  // if this transfer object was used to create a DDE link, filtered rows
336  // have to be included for subsequent calls (to be consistent with link data)
337  if ( nFormat == SotClipboardFormatId::LINK )
338  m_bUsedForLink = true;
339 
340  bool bIncludeFiltered = m_pDoc->IsCutMode() || m_bUsedForLink;
341 
342  ScImportExport aObj( *m_pDoc, aReducedBlock );
343  // Plain text ("Unformatted text") may contain embedded tabs and
344  // line breaks but is not enclosed in quotes. Which makes it
345  // unsuitable for multiple cells, especially if one of them is
346  // multi-line, but otherwise is expected behavior for plain text.
347  // For multiple cells replace embedded line breaks (and tabs) with
348  // space character, otherwise pasting would yield odd results.
349  /* XXX: it's debatable whether this is actually expected, but
350  * there's no way to satisfy all possible requirements when
351  * copy/pasting unformatted text. */
352  const bool bPlainMulti = (nFormat == SotClipboardFormatId::STRING &&
353  aReducedBlock.aStart != aReducedBlock.aEnd);
354  // Add quotes only for STRING_TSVC.
355  /* TODO: a possible future STRING_TSV should not contain embedded
356  * line breaks nor tab (separator) characters and not be quoted.
357  * A possible STRING_CSV should. */
359  (nFormat == SotClipboardFormatId::STRING_TSVC));
360  if ( bPlainMulti || m_bUsedForLink )
361  {
362  // For a DDE link or plain text multiple cells, convert line
363  // breaks and separators to space.
365  aTextOptions.mcSeparatorConvertTo = ' ';
366  aTextOptions.mbAddQuotes = false;
367  }
368  aObj.SetExportTextOptions(aTextOptions);
369  aObj.SetFormulas( m_pDoc->GetViewOptions().GetOption( VOPT_FORMULAS ) );
370  aObj.SetIncludeFiltered( bIncludeFiltered );
371 
372  // DataType depends on format type:
373 
374  if ( rFlavor.DataType.equals( ::cppu::UnoType<OUString>::get() ) )
375  {
376  OUString aString;
377  if ( aObj.ExportString( aString, nFormat ) )
378  bOK = SetString( aString, rFlavor );
379  }
380  else if ( rFlavor.DataType.equals( cppu::UnoType<uno::Sequence< sal_Int8 >>::get() ) )
381  {
382  // SetObject converts a stream into an Int8-Sequence
383  bOK = SetObject( &aObj, SCTRANS_TYPE_IMPEX, rFlavor );
384  }
385  else
386  {
387  OSL_FAIL("unknown DataType");
388  }
389  }
390  else if ( nFormat == SotClipboardFormatId::BITMAP || nFormat == SotClipboardFormatId::PNG )
391  {
392  tools::Rectangle aMMRect = m_pDoc->GetMMRect( aReducedBlock.aStart.Col(), aReducedBlock.aStart.Row(),
393  aReducedBlock.aEnd.Col(), aReducedBlock.aEnd.Row(),
394  aReducedBlock.aStart.Tab() );
396  pVirtDev->SetOutputSizePixel(pVirtDev->LogicToPixel(aMMRect.GetSize(), MapMode(MapUnit::Map100thMM)));
397 
398  PaintToDev( pVirtDev, *m_pDoc, 1.0, aReducedBlock );
399 
400  pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel ) );
401  BitmapEx aBmp = pVirtDev->GetBitmapEx( Point(), pVirtDev->GetOutputSize() );
402  bOK = SetBitmapEx( aBmp, rFlavor );
403  }
404  else if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
405  {
406  // #i123405# Do not limit visual size calculation for metafile creation.
407  // It seems unlikely that removing the limitation causes problems since
408  // metafile creation means that no real pixel device in the needed size is
409  // created.
410  InitDocShell(false);
411 
412  SfxObjectShell* pEmbObj = m_aDocShellRef.get();
413 
414  // like SvEmbeddedTransfer::GetData:
415  GDIMetaFile aMtf;
417  MapMode aMapMode( pEmbObj->GetMapUnit() );
418  tools::Rectangle aVisArea( pEmbObj->GetVisArea( ASPECT_CONTENT ) );
419 
420  pVDev->EnableOutput( false );
421  pVDev->SetMapMode( aMapMode );
422  aMtf.SetPrefSize( aVisArea.GetSize() );
423  aMtf.SetPrefMapMode( aMapMode );
424  aMtf.Record( pVDev );
425 
426  pEmbObj->DoDraw( pVDev, Point(), aVisArea.GetSize(), JobSetup() );
427 
428  aMtf.Stop();
429  aMtf.WindStart();
430 
431  bOK = SetGDIMetaFile( aMtf );
432  }
433  else if ( nFormat == SotClipboardFormatId::EMBED_SOURCE )
434  {
435  //TODO/LATER: differentiate between formats?!
436  // #i123405# Do limit visual size calculation to PageSize
437  InitDocShell(true); // set aDocShellRef
438 
439  SfxObjectShell* pEmbObj = m_aDocShellRef.get();
440  bOK = SetObject( pEmbObj, SCTRANS_TYPE_EMBOBJ, rFlavor );
441  }
442  }
443  return bOK;
444 }
445 
446 bool ScTransferObj::WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
447  const datatransfer::DataFlavor& rFlavor )
448 {
449  // called from SetObject, put data into stream
450 
451  bool bRet = false;
452  switch (nUserObjectId)
453  {
454  case SCTRANS_TYPE_IMPEX:
455  {
456  ScImportExport* pImpEx = static_cast<ScImportExport*>(pUserObject);
457 
458  SotClipboardFormatId nFormat = SotExchange::GetFormat( rFlavor );
459  // mba: no BaseURL for data exchange
460  if ( pImpEx->ExportStream( *rxOStm, OUString(), nFormat ) )
461  bRet = ( rxOStm->GetError() == ERRCODE_NONE );
462  }
463  break;
464 
467  {
468  ScTabEditEngine* pEngine = static_cast<ScTabEditEngine*>(pUserObject);
469  if ( nUserObjectId == SCTRANS_TYPE_EDIT_RTF )
470  {
471  pEngine->Write( *rxOStm, EETextFormat::Rtf );
472  bRet = ( rxOStm->GetError() == ERRCODE_NONE );
473  }
474  else
475  {
476  // can't use Write for EditEngine format because that would
477  // write old format without support for unicode characters.
478  // Get the data from the EditEngine's transferable instead.
479 
480  sal_Int32 nParCnt = pEngine->GetParagraphCount();
481  if ( nParCnt == 0 )
482  nParCnt = 1;
483  ESelection aSel( 0, 0, nParCnt-1, pEngine->GetTextLen(nParCnt-1) );
484 
485  uno::Reference<datatransfer::XTransferable> xEditTrans = pEngine->CreateTransferable( aSel );
486  TransferableDataHelper aEditHelper( xEditTrans );
487 
488  bRet = aEditHelper.GetSotStorageStream( rFlavor, rxOStm );
489  }
490  }
491  break;
492 
494  {
495  ScTabEditEngine* pEngine = static_cast<ScTabEditEngine*>(pUserObject);
496  pEngine->Write(*rxOStm, EETextFormat::Xml);
497  bRet = (rxOStm->GetError() == ERRCODE_NONE);
498  }
499  break;
500 
501  case SCTRANS_TYPE_EMBOBJ:
502  {
503  // TODO/MBA: testing
504  SfxObjectShell* pEmbObj = static_cast<SfxObjectShell*>(pUserObject);
505  ::utl::TempFile aTempFile;
506  aTempFile.EnableKillingFile();
507  uno::Reference< embed::XStorage > xWorkStore =
508  ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
509 
510  // write document storage
511  pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, false );
512 
513  // mba: no relative URLs for clipboard!
514  SfxMedium aMedium( xWorkStore, OUString() );
515  pEmbObj->DoSaveObjectAs( aMedium, false );
516  pEmbObj->DoSaveCompleted();
517 
518  uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
519  if ( xTransact.is() )
520  xTransact->commit();
521 
522  std::unique_ptr<SvStream> pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), StreamMode::READ );
523  if( pSrcStm )
524  {
525  rxOStm->SetBufferSize( 0xff00 );
526  rxOStm->WriteStream( *pSrcStm );
527  pSrcStm.reset();
528  }
529 
530  bRet = true;
531 
532  xWorkStore->dispose();
533  xWorkStore.clear();
534  }
535  break;
536 
537  default:
538  OSL_FAIL("unknown object id");
539  }
540  return bRet;
541 }
542 
544 {
545  ScRange aReduced = lcl_reduceBlock(*m_pDoc, m_aBlock);
546  size_t nCells = (aReduced.aEnd.Col() - aReduced.aStart.Col() + 1) *
547  (aReduced.aEnd.Row() - aReduced.aStart.Row() + 1) *
548  (aReduced.aEnd.Tab() - aReduced.aStart.Tab() + 1);
549  return nCells > 1000;
550 }
551 
553 {
555  {
556  // move: delete source data
557  ScDocShell* pSourceSh = GetSourceDocShell();
558  if (pSourceSh)
559  {
560  ScMarkData aMarkData = GetSourceMarkData();
561  // external drag&drop doesn't copy objects, so they also aren't deleted:
562  // bApi=TRUE, don't show error messages from drag&drop
563  pSourceSh->GetDocFunc().DeleteContents( aMarkData, InsertDeleteFlags::ALL & ~InsertDeleteFlags::OBJECTS, true, true );
564  }
565  }
566 
567  ScModule* pScMod = SC_MOD();
568  if ( pScMod->GetDragData().pCellTransfer == this )
569  pScMod->ResetDragObject();
570 
571  m_xDragSourceRanges = nullptr; // don't keep source after dropping
572 
574 }
575 
577 {
578  m_nDragHandleX = nX;
579  m_nDragHandleY = nY;
580 }
581 
583 {
584  m_nSourceCursorX = nX;
585  m_nSourceCursorY = nY;
586 }
587 
589 {
590  return
593 }
594 
596 {
597  m_nVisibleTab = nNew;
598 }
599 
601 {
602  m_aDrawPersistRef = rRef;
603 }
604 
605 void ScTransferObj::SetDragSource( ScDocShell* pSourceShell, const ScMarkData& rMark )
606 {
607  ScRangeList aRanges;
608  rMark.FillRangeListWithMarks( &aRanges, false );
609  m_xDragSourceRanges = new ScCellRangesObj( pSourceShell, aRanges );
610 }
611 
613 {
614  m_nDragSourceFlags = nFlags;
615 }
616 
618 {
619  m_bDragWasInternal = true;
620 }
621 
622 void ScTransferObj::SetUseInApi( bool bSet )
623 {
624  m_bUseInApi = bSet;
625 }
626 
628 {
629  ScDocShell* pSourceDocSh = GetSourceDocShell();
630  if (pSourceDocSh)
631  return &pSourceDocSh->GetDocument();
632  return nullptr;
633 }
634 
636 {
637  ScCellRangesBase* pRangesObj = comphelper::getUnoTunnelImplementation<ScCellRangesBase>( m_xDragSourceRanges );
638  if (pRangesObj)
639  return pRangesObj->GetDocShell();
640 
641  return nullptr; // none set
642 }
643 
645 {
646  ScMarkData aMarkData(m_pDoc->GetSheetLimits());
647  ScCellRangesBase* pRangesObj = comphelper::getUnoTunnelImplementation<ScCellRangesBase>( m_xDragSourceRanges );
648  if (pRangesObj)
649  {
650  const ScRangeList& rRanges = pRangesObj->GetRangeList();
651  aMarkData.MarkFromRangeList( rRanges, false );
652  }
653  return aMarkData;
654 }
655 
656 // initialize aDocShellRef with a live document from the ClipDoc
657 
658 // #i123405# added parameter to allow size calculation without limitation
659 // to PageSize, e.g. used for Metafile creation for clipboard.
660 
661 void ScTransferObj::InitDocShell(bool bLimitToPageSize)
662 {
663  if ( m_aDocShellRef.is() )
664  return;
665 
666  ScDocShell* pDocSh = new ScDocShell;
667  m_aDocShellRef = pDocSh; // ref must be there before InitNew
668 
669  pDocSh->DoInitNew();
670 
671  ScDocument& rDestDoc = pDocSh->GetDocument();
672  ScMarkData aDestMark(rDestDoc.GetSheetLimits());
673  aDestMark.SelectTable( 0, true );
674 
675  rDestDoc.SetDocOptions( m_pDoc->GetDocOptions() ); // #i42666#
676 
677  OUString aTabName;
678  m_pDoc->GetName( m_aBlock.aStart.Tab(), aTabName );
679  rDestDoc.RenameTab( 0, aTabName );
680 
681  rDestDoc.CopyStdStylesFrom(*m_pDoc);
682 
683  SCCOL nStartX = m_aBlock.aStart.Col();
684  SCROW nStartY = m_aBlock.aStart.Row();
685  SCCOL nEndX = m_aBlock.aEnd.Col();
686  SCROW nEndY = m_aBlock.aEnd.Row();
687 
688  // widths / heights
689  // (must be copied before CopyFromClip, for drawing objects)
690 
691  SCCOL nCol;
692  SCTAB nSrcTab = m_aBlock.aStart.Tab();
693  rDestDoc.SetLayoutRTL(0, m_pDoc->IsLayoutRTL(nSrcTab));
694  for (nCol=nStartX; nCol<=nEndX; nCol++)
695  if ( m_pDoc->ColHidden(nCol, nSrcTab) )
696  rDestDoc.ShowCol( nCol, 0, false );
697  else
698  rDestDoc.SetColWidth( nCol, 0, m_pDoc->GetColWidth( nCol, nSrcTab ) );
699 
700  if (nStartY > 0)
701  {
702  // Set manual height for all previous rows so we can ensure
703  // that visible area will not change due to autoheight
704  rDestDoc.SetManualHeight(0, nStartY - 1, 0, true);
705  }
706  for (SCROW nRow = nStartY; nRow <= nEndY; ++nRow)
707  {
708  if ( m_pDoc->RowHidden(nRow, nSrcTab) )
709  rDestDoc.ShowRow( nRow, 0, false );
710  else
711  {
712  rDestDoc.SetRowHeight( nRow, 0, m_pDoc->GetOriginalHeight( nRow, nSrcTab ) );
713 
714  // if height was set manually, that flag has to be copied, too
715  bool bManual = m_pDoc->IsManualRowHeight(nRow, nSrcTab);
716  rDestDoc.SetManualHeight(nRow, nRow, 0, bManual);
717  }
718  }
719 
720  if (m_pDoc->GetDrawLayer() || m_pDoc->HasNotes())
721  pDocSh->MakeDrawLayer();
722 
723  // cell range is copied to the original position, but on the first sheet
724  // -> bCutMode must be set
725  // pDoc is always a Clipboard-document
726 
727  ScRange aDestRange( nStartX,nStartY,0, nEndX,nEndY,0 );
728  bool bWasCut = m_pDoc->IsCutMode();
729  if (!bWasCut)
730  m_pDoc->SetClipArea( aDestRange, true ); // Cut
731  rDestDoc.CopyFromClip( aDestRange, aDestMark, InsertDeleteFlags::ALL, nullptr, m_pDoc.get(), false );
732  m_pDoc->SetClipArea( aDestRange, bWasCut );
733 
734  StripRefs(*m_pDoc, nStartX,nStartY, nEndX,nEndY, rDestDoc);
735 
736  ScRange aMergeRange = aDestRange;
737  rDestDoc.ExtendMerge( aMergeRange, true );
738 
739  m_pDoc->CopyDdeLinks( rDestDoc ); // copy values of DDE Links
740 
741  // page format (grid etc) and page size (maximum size for ole object)
742 
743  Size aPaperSize = SvxPaperInfo::GetPaperSize( PAPER_A4 ); // Twips
744  ScStyleSheetPool* pStylePool = m_pDoc->GetStyleSheetPool();
745  OUString aStyleName = m_pDoc->GetPageStyle( m_aBlock.aStart.Tab() );
746  SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SfxStyleFamily::Page );
747  if (pStyleSheet)
748  {
749  const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet();
750  aPaperSize = rSourceSet.Get(ATTR_PAGE_SIZE).GetSize();
751 
752  // CopyStyleFrom copies SetItems with correct pool
753  ScStyleSheetPool* pDestPool = rDestDoc.GetStyleSheetPool();
754  pDestPool->CopyStyleFrom( pStylePool, aStyleName, SfxStyleFamily::Page );
755  }
756 
757  ScViewData aViewData( *pDocSh, nullptr );
758  aViewData.SetScreen( nStartX,nStartY, nEndX,nEndY );
759  aViewData.SetCurX( nStartX );
760  aViewData.SetCurY( nStartY );
761 
762  rDestDoc.SetViewOptions( m_pDoc->GetViewOptions() );
763 
764  // Size
766 
767  tools::Long nPosX = 0;
768  tools::Long nPosY = 0;
769 
770  for (nCol=0; nCol<nStartX; nCol++)
771  nPosX += rDestDoc.GetColWidth( nCol, 0 );
772  nPosY += rDestDoc.GetRowHeight( 0, nStartY-1, 0 );
775 
776  aPaperSize.setWidth( aPaperSize.Width() * 2 ); // limit OLE object to double of page size
777  aPaperSize.setHeight( aPaperSize.Height() * 2 );
778 
779  tools::Long nSizeX = 0;
780  tools::Long nSizeY = 0;
781  for (nCol=nStartX; nCol<=nEndX; nCol++)
782  {
783  tools::Long nAdd = rDestDoc.GetColWidth( nCol, 0 );
784  if ( bLimitToPageSize && nSizeX+nAdd > aPaperSize.Width() && nSizeX ) // above limit?
785  break;
786  nSizeX += nAdd;
787  }
788  for (SCROW nRow=nStartY; nRow<=nEndY; nRow++)
789  {
790  tools::Long nAdd = rDestDoc.GetRowHeight( nRow, 0 );
791  if ( bLimitToPageSize && nSizeY+nAdd > aPaperSize.Height() && nSizeY ) // above limit?
792  break;
793  nSizeY += nAdd;
794  }
797 
798 // pDocSh->SetVisAreaSize( Size(nSizeX,nSizeY) );
799 
800  tools::Rectangle aNewArea( Point(nPosX,nPosY), Size(nSizeX,nSizeY) );
801  //TODO/LATER: why twice?!
802  //pDocSh->SvInPlaceObject::SetVisArea( aNewArea );
803  pDocSh->SetVisArea( aNewArea );
804 
805  pDocSh->UpdateOle(aViewData, true);
806 
808  if ( rDestDoc.IsChartListenerCollectionNeedsUpdate() )
810 }
811 
813 {
814  // update ScGlobal::xDrawClipDocShellRef
815 
817  if (bAnyOle)
818  {
819  ScGlobal::xDrawClipDocShellRef = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS); // there must be a ref
822  }
823  else
824  {
826  return nullptr;
827  }
828 }
829 
831  SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
832  ScDocument& rDestDoc )
833 {
834  // In a clipboard doc the data don't have to be on the first sheet
835 
836  SCTAB nSrcTab = 0;
837  while (nSrcTab < rDoc.GetTableCount() && !rDoc.HasTable(nSrcTab))
838  ++nSrcTab;
839  SCTAB nDestTab = 0;
840  while (nDestTab < rDestDoc.GetTableCount() && !rDestDoc.HasTable(nDestTab))
841  ++nDestTab;
842 
843  if (!rDoc.HasTable(nSrcTab) || !rDestDoc.HasTable(nDestTab))
844  {
845  OSL_FAIL("Sheet not found in ScTransferObj::StripRefs");
846  return;
847  }
848 
849  ScRange aRef;
850 
851  ScCellIterator aIter( rDoc, ScRange(nStartX, nStartY, nSrcTab, nEndX, nEndY, nSrcTab) );
852  for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
853  {
854  if (aIter.getType() != CELLTYPE_FORMULA)
855  continue;
856 
857  ScFormulaCell* pFCell = aIter.getFormulaCell();
858  bool bOut = false;
859  ScDetectiveRefIter aRefIter( rDoc, pFCell );
860  while ( !bOut && aRefIter.GetNextRef( aRef ) )
861  {
862  if ( aRef.aStart.Tab() != nSrcTab || aRef.aEnd.Tab() != nSrcTab ||
863  aRef.aStart.Col() < nStartX || aRef.aEnd.Col() > nEndX ||
864  aRef.aStart.Row() < nStartY || aRef.aEnd.Row() > nEndY )
865  bOut = true;
866  }
867  if (bOut)
868  {
869  SCCOL nCol = aIter.GetPos().Col();
870  SCROW nRow = aIter.GetPos().Row();
871 
872  FormulaError nErrCode = pFCell->GetErrCode();
873  ScAddress aPos(nCol, nRow, nDestTab);
874  if (nErrCode != FormulaError::NONE)
875  {
876  if ( rDestDoc.GetAttr( nCol,nRow,nDestTab, ATTR_HOR_JUSTIFY)->GetValue() ==
877  SvxCellHorJustify::Standard )
878  rDestDoc.ApplyAttr( nCol,nRow,nDestTab,
879  SvxHorJustifyItem(SvxCellHorJustify::Right, ATTR_HOR_JUSTIFY) );
880 
881  ScSetStringParam aParam;
882  aParam.setTextInput();
883  rDestDoc.SetString(aPos, ScGlobal::GetErrorString(nErrCode), &aParam);
884  }
885  else if (pFCell->IsValue())
886  {
887  rDestDoc.SetValue(aPos, pFCell->GetValue());
888  }
889  else
890  {
891  OUString aStr = pFCell->GetString().getString();
892  if ( pFCell->IsMultilineResult() )
893  {
894  ScFieldEditEngine& rEngine = rDestDoc.GetEditEngine();
895  rEngine.SetTextCurrentDefaults(aStr);
896  rDestDoc.SetEditText(ScAddress(nCol,nRow,nDestTab), rEngine.CreateTextObject());
897  }
898  else
899  {
900  ScSetStringParam aParam;
901  aParam.setTextInput();
902  rDestDoc.SetString(aPos, aStr, &aParam);
903  }
904  }
905  }
906  }
907 }
908 
909 const css::uno::Sequence< sal_Int8 >& ScTransferObj::getUnoTunnelId()
910 {
911  static const UnoTunnelIdInit theScTransferUnoTunnelId;
912  return theScTransferUnoTunnelId.getSeq();
913 }
914 
915 sal_Int64 SAL_CALL ScTransferObj::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
916 {
917  sal_Int64 nRet;
918  if( isUnoTunnelId<ScTransferObj>(rId) )
919  {
920  nRet = reinterpret_cast< sal_Int64 >( this );
921  }
922  else
924  return nRet;
925 }
926 
927 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
Definition: documen2.cxx:575
bool is() const
SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow)
Definition: document.cxx:4290
static ScRange lcl_reduceBlock(const ScDocument &rDoc, ScRange aReducedBlock, bool bIncludeVisual=false)
Definition: transobj.cxx:235
static const com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: transobj.cxx:909
constexpr sal_uInt32 SCTRANS_TYPE_EMBOBJ
Definition: transobj.cxx:71
OUString getString() const
ScAddress aStart
Definition: address.hxx:499
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef)
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
Store parameters used in the ScDocument::SetString() method.
Definition: stringutil.hxx:34
void SetCurX(SCCOL nNewCurX)
Definition: viewdata.hxx:430
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)
Definition: docfunc.cxx:570
SCROW Row() const
Definition: address.hxx:261
ScDocShell * GetDocShell() const
Definition: cellsuno.hxx:242
void setWidth(tools::Long nWidth)
void setTextInput()
Call this whenever you need to unconditionally set input as text, no matter what the input is...
Definition: stringutil.cxx:37
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: transobj.cxx:552
bool ExportString(OUString &, SotClipboardFormatId)
Definition: impex.cxx:327
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 bSkipAttrForEmpty=false, const ScRangeList *pDestRanges=nullptr)
If pDestRanges is given it overrides rDestRange, rDestRange in this case is the overall encompassing ...
Definition: document.cxx:2790
static void DrawToDev(ScDocument &rDoc, OutputDevice *pDev, double nPrintFactor, const tools::Rectangle &rBound, ScViewData *pViewData, bool bMetaFile)
Definition: printfun.cxx:447
signed char sal_Int8
SC_DLLPUBLIC void CopyStdStylesFrom(const ScDocument &rSrcDoc)
Definition: documen8.cxx:288
static bool IsFormatSupported(SotClipboardFormatId nFormat)
Definition: impex.cxx:222
SC_DLLPUBLIC void SetLayoutRTL(SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling=ScObjectHandling::RecalcPosMode)
Definition: document.cxx:949
static SfxObjectShell * SetDrawClipDoc(bool bAnyOle)
Definition: transobj.cxx:812
long Long
These options control how multi-line cells are converted during export in certain lossy formats (such...
Definition: impex.hxx:35
void SetDragSource(ScDocShell *pSourceShell, const ScMarkData &rMark)
Definition: transobj.cxx:605
SfxObjectShellRef m_aDocShellRef
Definition: transobj.hxx:45
void SetDragSourceFlags(ScDragSrc nFlags)
Definition: transobj.cxx:612
bool SetTransferableObjectDescriptor(const TransferableObjectDescriptor &rDesc)
#define SOFFICE_FILEFORMAT_CURRENT
virtual void DragFinished(sal_Int8 nDropAction) override
bool HasFormat(SotClipboardFormatId nFormat)
void SetPrefSize(const Size &rSize)
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
Definition: markdata.cxx:387
void InitDocShell(bool bLimitToPageSize)
Definition: transobj.cxx:661
ScAddress aEnd
Definition: address.hxx:500
bool WasSourceCursorInSelection() const
Definition: transobj.cxx:588
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
Definition: document.cxx:3450
virtual SfxItemSet & GetItemSet()
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4749
const ScDragData & GetDragData() const
Definition: scmod.hxx:140
ScFormulaCell * getFormulaCell()
Definition: dociter.hxx:238
bool IsMultilineResult()
Determines whether or not the result string contains more than one paragraph.
ScTransferObj * pCellTransfer
Definition: dragdata.hxx:20
bool SetObject(void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
void SetSourceCursorPos(SCCOL nX, SCROW nY)
Definition: transobj.cxx:582
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4153
void SetDragHandlePos(SCCOL nX, SCROW nY)
Definition: transobj.cxx:576
ScDocument * GetSourceDocument()
Definition: transobj.cxx:627
#define DND_ACTION_MOVE
CellType getType() const
Definition: dociter.hxx:235
void AddFormat(SotClipboardFormatId nFormat)
constexpr tools::Long Width() const
static void GetAreaSize(const ScDocument &rDoc, SCTAB nTab1, SCTAB nTab2, SCROW &nRow, SCCOL &nCol)
Definition: transobj.cxx:74
void Record(OutputDevice *pOutDev)
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
Definition: document.cxx:852
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
NewlineConversion meNewlineConversion
Definition: impex.hxx:41
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:871
SCCOL m_nSourceCursorX
Definition: transobj.hxx:50
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:313
SC_DLLPUBLIC void SetColWidth(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
Definition: document.cxx:4075
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_ODF_TEXT_FLAT
Definition: transobj.cxx:72
double GetValue()
FormulaError GetErrCode()
css::uno::Reference< css::sheet::XSheetCellRanges > m_xDragSourceRanges
Definition: transobj.hxx:47
Walk through all cells in an area.
Definition: dociter.hxx:207
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:190
SCTAB Tab() const
Definition: address.hxx:270
SotClipboardFormatId
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:169
bool m_bHasFiltered
Definition: transobj.hxx:56
sal_Int32 nHandle
SCROW m_nSourceCursorY
Definition: transobj.hxx:51
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4706
constexpr auto convert(N n, sal_Int64 mul, sal_Int64 div)
SC_DLLPUBLIC bool SetEditText(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
This method manages the lifecycle of the passed edit text object.
Definition: document.cxx:3386
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
Definition: document.cxx:3355
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:870
T * get() const
void SetDrawPersist(const SfxObjectShellRef &rRef)
Definition: transobj.cxx:600
bool IsChartListenerCollectionNeedsUpdate() const
Definition: document.hxx:2152
ScDragSrc
Definition: viewdata.hxx:91
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:598
void SetFormulas(bool b)
Definition: impex.hxx:132
int i
void SetDragWasInternal()
Definition: transobj.cxx:617
OUString const & GetURL() const
void SelectTable(SCTAB nTab, bool bNew)
Definition: markdata.cxx:172
sal_uInt32 GetTextLen() const
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2616
sal_Int16 SCCOL
Definition: types.hxx:21
static tools::SvRef< ScDocShell > xDrawClipDocShellRef
Definition: global.hxx:580
void SetCurY(SCROW nNewCurY)
Definition: viewdata.hxx:431
Iterator for references in a formula cell.
Definition: formulaiter.hxx:31
TransferableObjectDescriptor m_aObjDesc
Definition: transobj.hxx:44
#define SC_MOD()
Definition: scmod.hxx:249
ScRange m_aBlock
Definition: transobj.hxx:42
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1959
ScSheetLimits & GetSheetLimits() const
Definition: document.hxx:872
virtual ~ScTransferObj() override
Definition: transobj.cxx:174
Size GetOutputSize() const
SCCOL m_nDragHandleX
Definition: transobj.hxx:48
std::unique_ptr< EditTextObject > CreateTextObject()
unsigned char sal_Bool
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_BIN
Definition: transobj.cxx:70
SC_DLLPUBLIC void SetRowHeight(SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight)
Definition: document.cxx:4087
void PrepareOLE(const TransferableObjectDescriptor &rObjDesc)
ScMarkData GetSourceMarkData() const
Definition: transobj.cxx:644
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
Definition: patattr.cxx:1255
bool m_bUseInApi
Definition: transobj.hxx:57
virtual void AddSupportedFormats() override
Definition: transobj.cxx:210
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
SCTAB m_nVisibleTab
Definition: transobj.hxx:52
bool m_bDragWasInternal
Definition: transobj.hxx:54
void WindStart()
ScDragSrc m_nDragSourceFlags
Definition: transobj.hxx:53
sal_Unicode mcSeparatorConvertTo
Definition: impex.hxx:42
bool ExportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
Definition: impex.cxx:422
#define ASPECT_CONTENT
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5555
Size GetSize() const
const svl::SharedString & GetString()
FormulaError
SCCOL Col() const
Definition: address.hxx:266
void SetVisibleTab(SCTAB nNew)
Definition: transobj.cxx:595
sal_Int32 GetParagraphCount() const
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
Definition: transobj.cxx:446
ScDocumentUniquePtr m_pDoc
Definition: transobj.hxx:41
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rId) override
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
Definition: transobj.cxx:271
const ScAddress & GetPos() const
Definition: dociter.hxx:233
sal_Int32 SCROW
Definition: types.hxx:17
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
void UpdateOle(const ScViewData &rViewData, bool bSnapSize=false)
Definition: docsh6.cxx:152
SCROW m_nDragHandleY
Definition: transobj.hxx:49
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: documen3.cxx:1945
bool GetNextRef(ScRange &rRange)
Definition: formulaiter.cxx:52
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define ERRCODE_NONE
void CopyStyleFrom(ScStyleSheetPool *pSrcPool, const OUString &rName, SfxStyleFamily eFamily)
Definition: stlpool.cxx:128
constexpr tools::Long Height() const
bool m_bUsedForLink
Definition: transobj.hxx:55
SC_DLLPUBLIC void SetUseInApi(bool bSet)
Definition: transobj.cxx:622
css::uno::Reference< css::datatransfer::XTransferable > CreateTransferable(const ESelection &rSelection) const
MapUnit GetMapUnit() const
bool DoInitNew(SfxMedium *pMedium=nullptr)
void SetExportTextOptions(const ScExportTextOptions &options)
Definition: impex.hxx:158
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 > &)
Definition: transobj.cxx:193
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
SC_DLLPUBLIC void SetManualHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual)
Definition: document.cxx:4106
void Write(SvStream &rOutput, EETextFormat)
SfxObjectShellRef m_aDrawPersistRef
Definition: transobj.hxx:46
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
SC_DLLPUBLIC void UpdateChartListenerCollection()
Definition: documen5.cxx:570
virtual sal_Bool SAL_CALL isComplex() override
Definition: transobj.cxx:543
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6053
constexpr sal_uInt32 SCTRANS_TYPE_IMPEX
Definition: transobj.cxx:68
void SetIncludeFiltered(bool b)
Definition: impex.hxx:133
void setHeight(tools::Long nHeight)
ScTransferObj(ScDocumentUniquePtr pClipDoc, const TransferableObjectDescriptor &rDesc)
Definition: transobj.cxx:109
constexpr sal_uInt32 SCTRANS_TYPE_EDIT_RTF
Definition: transobj.cxx:69
bool DoSaveObjectAs(SfxMedium &rNewStor, bool bCommit)
void SetupStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, sal_Int32 nVersion, bool bTemplate) const
static void GetString(const ScRefCellValue &rCell, sal_uInt32 nFormat, OUString &rString, const Color **ppColor, SvNumberFormatter &rFormatter, const ScDocument &rDoc, bool bNullVals=true, bool bFormula=false, bool bUseStarFormat=false)
Definition: cellform.cxx:31
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:218
bool ShrinkToUsedDataArea(bool &o_bShrunk, SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bColumnsOnly, bool bStickyTopRow=false, bool bStickyLeftCol=false, bool bConsiderCellNotes=false, bool bConsiderCellDrawObjects=false, bool bConsiderCellFormats=false) const
Shrink a range to only include used data area.
Definition: document.cxx:1062
virtual void SetVisArea(const tools::Rectangle &rVisArea) override
Definition: docsh6.cxx:57
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: viewdata.cxx:2934
static void PaintToDev(OutputDevice *pDev, ScDocument &rDoc, double nPrintFactor, const ScRange &rBlock)
Definition: transobj.cxx:95
void ResetDragObject()
Definition: scmod.cxx:579
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4112
PAPER_A4
const css::uno::Sequence< sal_Int8 > & getSeq() 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
Definition: transobj.cxx:915
bool SetString(const OUString &rString, const css::datatransfer::DataFlavor &rFlavor)
SCROW m_nNonFiltered
Definition: transobj.hxx:43
aStr
static OUString GetErrorString(FormulaError nErrNumber)
Definition: global.cxx:301
void EnableKillingFile(bool bEnable=true)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:456
SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow)
Definition: document.cxx:4296
sal_Int16 SCTAB
Definition: types.hxx:22
bool SetGDIMetaFile(const GDIMetaFile &rMtf)
virtual tools::Rectangle GetVisArea(sal_uInt16 nAspect) const
ScDocShell * GetSourceDocShell()
Definition: transobj.cxx:635
static void StripRefs(ScDocument &rDoc, SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, ScDocument &rDestDoc)
Definition: transobj.cxx:830
void SetPrefMapMode(const MapMode &rMapMode)