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