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