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