LibreOffice Module sc (master)  1
worksheethelper.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 <memory>
21 #include <worksheethelper.hxx>
22 
23 #include <algorithm>
24 #include <utility>
25 #include <com/sun/star/awt/Point.hpp>
26 #include <com/sun/star/awt/Size.hpp>
27 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
28 #include <com/sun/star/sheet/ConditionOperator2.hpp>
29 #include <com/sun/star/sheet/TableValidationVisibility.hpp>
30 #include <com/sun/star/sheet/ValidationType.hpp>
31 #include <com/sun/star/sheet/ValidationAlertStyle.hpp>
32 #include <com/sun/star/sheet/XCellAddressable.hpp>
33 #include <com/sun/star/sheet/XMultiFormulaTokens.hpp>
34 #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
35 #include <com/sun/star/sheet/XSheetCondition2.hpp>
36 #include <com/sun/star/sheet/XSheetOutline.hpp>
37 #include <com/sun/star/sheet/XSpreadsheet.hpp>
38 #include <com/sun/star/table/XColumnRowRange.hpp>
39 #include <com/sun/star/text/WritingMode2.hpp>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <osl/diagnose.h>
42 #include <rtl/ustrbuf.hxx>
43 #include <oox/core/filterbase.hxx>
45 #include <oox/token/properties.hxx>
46 #include <oox/token/tokens.hxx>
47 #include <addressconverter.hxx>
48 #include <autofilterbuffer.hxx>
49 #include <commentsbuffer.hxx>
50 #include <condformatbuffer.hxx>
51 #include <document.hxx>
52 #include <drawingfragment.hxx>
53 #include <pagesettings.hxx>
54 #include <querytablebuffer.hxx>
55 #include <sheetdatabuffer.hxx>
56 #include <stylesbuffer.hxx>
57 #include <tokenuno.hxx>
58 #include <unitconverter.hxx>
59 #include <viewsettings.hxx>
60 #include <worksheetbuffer.hxx>
61 #include <worksheetsettings.hxx>
62 #include <formulabuffer.hxx>
63 #include <scitems.hxx>
64 #include <editutil.hxx>
65 #include <tokenarray.hxx>
66 #include <tablebuffer.hxx>
67 #include <documentimport.hxx>
68 #include <stlsheet.hxx>
69 #include <stlpool.hxx>
70 #include <cellvalue.hxx>
71 
72 #include <svl/stritem.hxx>
73 #include <editeng/eeitem.hxx>
74 #include <editeng/editobj.hxx>
75 #include <editeng/flditem.hxx>
76 
77 namespace oox::xls {
78 
79 using namespace ::com::sun::star;
80 using namespace ::com::sun::star::beans;
81 using namespace ::com::sun::star::drawing;
82 using namespace ::com::sun::star::lang;
83 using namespace ::com::sun::star::sheet;
84 using namespace ::com::sun::star::table;
85 using namespace ::com::sun::star::text;
86 using namespace ::com::sun::star::uno;
87 
88 namespace {
89 
90 void lclUpdateProgressBar( const ISegmentProgressBarRef& rxProgressBar, double fPosition )
91 {
92  if( rxProgressBar )
93  rxProgressBar->setPosition( fPosition );
94 }
95 
96 } // namespace
97 
99  maRange( -1 ),
100  mfWidth( 0.0 ),
101  mnXfId( -1 ),
102  mnLevel( 0 ),
103  mbShowPhonetic( false ),
104  mbHidden( false ),
105  mbCollapsed( false )
106 {
107 }
108 
109 bool ColumnModel::isMergeable( const ColumnModel& rModel ) const
110 {
111  return
112  (maRange.mnFirst <= rModel.maRange.mnFirst) &&
113  (rModel.maRange.mnFirst <= maRange.mnLast + 1) &&
114  (mfWidth == rModel.mfWidth) &&
115  // ignore mnXfId, cell formatting is always set directly
116  (mnLevel == rModel.mnLevel) &&
117  (mbHidden == rModel.mbHidden) &&
118  (mbCollapsed == rModel.mbCollapsed);
119 }
120 
122  mnRow( -1 ),
123  mfHeight( 0.0 ),
124  mnXfId( -1 ),
125  mnLevel( 0 ),
126  mbCustomHeight( false ),
127  mbCustomFormat( false ),
128  mbShowPhonetic( false ),
129  mbHidden( false ),
130  mbCollapsed( false ),
131  mbThickTop( false ),
132  mbThickBottom( false )
133 {
134 }
135 
136 void RowModel::insertColSpan( const ValueRange& rColSpan )
137 {
138  if( (0 <= rColSpan.mnFirst) && (rColSpan.mnFirst <= rColSpan.mnLast) )
139  maColSpans.insert( rColSpan );
140 }
141 
142 bool RowModel::isMergeable( const RowModel& rModel ) const
143 {
144  return
145  // ignore maColSpans - is handled separately in SheetDataBuffer class
146  (mfHeight == rModel.mfHeight) &&
147  // ignore mnXfId, mbCustomFormat, mbShowPhonetic - cell formatting is always set directly
148  (mnLevel == rModel.mnLevel) &&
149  (mbCustomHeight == rModel.mbCustomHeight) &&
150  (mbHidden == rModel.mbHidden) &&
151  (mbCollapsed == rModel.mbCollapsed);
152 }
153 
155  : mnColRow(0)
156  , mnMin(0)
157  , mnMax(0)
158  , mbManual(false)
159 {
160 }
161 
163 {
164 }
165 
167  mnType( XML_none ),
168  mnOperator( XML_between ),
169  mnErrorStyle( XML_stop ),
170  mbShowInputMsg( false ),
171  mbShowErrorMsg( false ),
172  mbNoDropDown( false ),
173  mbAllowBlank( false )
174 {
175 }
176 
178 {
179  static const sal_Int32 spnTypeIds[] = {
180  XML_none, XML_whole, XML_decimal, XML_list, XML_date, XML_time, XML_textLength, XML_custom };
181  mnType = STATIC_ARRAY_SELECT( spnTypeIds, nType, XML_none );
182 }
183 
185 {
186  static const sal_Int32 spnOperators[] = {
187  XML_between, XML_notBetween, XML_equal, XML_notEqual,
188  XML_greaterThan, XML_lessThan, XML_greaterThanOrEqual, XML_lessThanOrEqual };
189  mnOperator = STATIC_ARRAY_SELECT( spnOperators, nOperator, XML_TOKEN_INVALID );
190 }
191 
193 {
194  static const sal_Int32 spnErrorStyles[] = { XML_stop, XML_warning, XML_information };
195  mnErrorStyle = STATIC_ARRAY_SELECT( spnErrorStyles, nErrorStyle, XML_stop );
196 }
197 
199 {
200 public:
201  explicit WorksheetGlobals(
202  const WorkbookHelper& rHelper,
203  const ISegmentProgressBarRef& rxProgressBar,
204  WorksheetType eSheetType,
205  SCTAB nSheet );
206 
208  bool isValidSheet() const { return mxSheet.is(); }
209 
213  SCTAB getSheetIndex() const { return maUsedArea.aStart.Tab(); }
215  const Reference< XSpreadsheet >& getSheet() const { return mxSheet; }
216 
218  Reference< XCell > getCell( const ScAddress& rAddress ) const;
220  Reference< XCellRange > getCellRange( const ScRange& rRange ) const;
222  Reference< XSheetCellRanges > getCellRangeList( const ScRangeList& rRanges ) const;
223 
225  Reference< XCellRange > getColumn( sal_Int32 nCol ) const;
227  Reference< XCellRange > getRow( sal_Int32 nRow ) const;
228 
230  Reference< XDrawPage > getDrawPage() const;
232  const awt::Size& getDrawPageSize() const;
233 
235  awt::Point getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const;
236 
238  ScAddress getCellAddressFromPosition( const awt::Point& rPosition ) const;
240  ScRange getCellRangeFromRectangle( const awt::Rectangle& rRect ) const;
241 
261  ExtLst& getExtLst() { return maExtLst; }
262 
264  void setPageBreak( const PageBreakModel& rModel, bool bRowBreak );
266  void setHyperlink( const HyperlinkModel& rModel );
268  void setValidation( const ValidationModel& rModel );
270  void setDrawingPath( const OUString& rDrawingPath );
272  void setVmlDrawingPath( const OUString& rVmlDrawingPath );
273 
275  void extendUsedArea( const ScAddress& rAddress );
276 
278  void extendUsedArea( const ScRange& rRange );
280  void extendShapeBoundingBox( const awt::Rectangle& rShapeRect );
281 
284  void setBaseColumnWidth( sal_Int32 nWidth );
287  void setDefaultColumnWidth( double fWidth );
291  void setColumnModel( const ColumnModel& rModel );
293  void convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId );
294 
296  void setDefaultRowSettings( double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom );
300  void setRowModel( const RowModel& rModel );
301 
306 
307  void finalizeDrawingImport();
308 
311  {
312  return mxRowProgress;
313  }
314  virtual void setCustomRowProgress( const ISegmentProgressBarRef &rxRowProgress ) override
315  {
316  mxRowProgress = rxRowProgress;
317  mbFastRowProgress = true;
318  }
319 
320 private:
321  typedef ::std::vector< sal_Int32 > OutlineLevelVec;
322  typedef ::std::pair< ColumnModel, sal_Int32 > ColumnModelRange;
323  typedef ::std::map< sal_Int32, ColumnModelRange > ColumnModelRangeMap;
324  typedef ::std::pair< RowModel, sal_Int32 > RowModelRange;
325  typedef ::std::map< sal_Int32, RowModelRange > RowModelRangeMap;
326 
330  OUString getHyperlinkUrl( const HyperlinkModel& rHyperlink ) const;
332  void insertHyperlink( const ScAddress& rAddress, const OUString& rUrl );
333 
335  void finalizeValidationRanges() const;
336 
338  void convertColumns();
340  void convertColumns( OutlineLevelVec& orColLevels, const ValueRange& rColRange, const ColumnModel& rModel );
341 
343  void convertRows();
345  void convertRows( OutlineLevelVec& orRowLevels, const ValueRange& rRowRange, const RowModel& rModel, double fDefHeight = -1.0 );
346 
348  void convertOutlines( OutlineLevelVec& orLevels, sal_Int32 nColRow, sal_Int32 nLevel, bool bCollapsed, bool bRows );
350  void groupColumnsOrRows( sal_Int32 nFirstColRow, sal_Int32 nLastColRow, bool bCollapsed, bool bRows );
351 
353  void finalizeDrawings();
354 
356  void UpdateRowProgress( const ScRange& rUsedArea, SCROW nRow );
357 
358 private:
359  typedef ::std::unique_ptr< VmlDrawing > VmlDrawingPtr;
360 
364  ColumnModelRangeMap maColModels;
366  RowModelRangeMap maRowModels;
367  std::vector< HyperlinkModel > maHyperlinks;
368  std::vector< ValidationModel > maValidations;
377  VmlDrawingPtr mxVmlDrawing;
379  OUString maDrawingPath;
380  OUString maVmlDrawingPath;
381  awt::Size maDrawPageSize;
382  awt::Rectangle maShapeBoundingBox;
388  Reference< XSpreadsheet > mxSheet;
390 };
391 
392 const OUStringLiteral gaSheetCellRanges( "com.sun.star.sheet.SheetCellRanges" );
393 
394 WorksheetGlobals::WorksheetGlobals( const WorkbookHelper& rHelper, const ISegmentProgressBarRef& rxProgressBar, WorksheetType eSheetType, SCTAB nSheet ) :
395  WorkbookHelper( rHelper ),
396  mrMaxApiPos( rHelper.getAddressConverter().getMaxApiAddress() ),
397  maUsedArea( SCCOL_MAX, SCROW_MAX, nSheet, -1, -1, nSheet ), // Set start address to largest possible value, and end address to smallest
398  maSheetData( *this ),
399  maCondFormats( *this ),
400  maComments( *this ),
401  maAutoFilters( *this ),
402  maQueryTables( *this ),
403  maSheetSett( *this ),
404  maPageSett( *this ),
405  maSheetViewSett( *this ),
406  mxProgressBar( rxProgressBar ),
407  mbFastRowProgress( false ),
408  meSheetType( eSheetType ),
409  mxSheet(getSheetFromDoc( nSheet )),
410  mbHasDefWidth( false )
411 {
412  if( !mxSheet.is() )
413  maUsedArea.aStart.SetTab( -1 );
414 
415  // default column settings (width and hidden state may be updated later)
416  maDefColModel.mfWidth = 8.5;
417  maDefColModel.mnXfId = -1;
419  maDefColModel.mbHidden = false;
420  maDefColModel.mbCollapsed = false;
421 
422  // default row settings (height and hidden state may be updated later)
423  maDefRowModel.mfHeight = 0.0;
424  maDefRowModel.mnXfId = -1;
429  maDefRowModel.mbHidden = false;
430  maDefRowModel.mbCollapsed = false;
431 
432  // buffers
433  mxVmlDrawing.reset( new VmlDrawing( *this ) );
434 
435  // prepare progress bars
436  if( mxProgressBar )
437  {
438  mxRowProgress = mxProgressBar->createSegment( 0.5 );
439  mxFinalProgress = mxProgressBar->createSegment( 0.5 );
440  }
441 }
442 
443 Reference< XCell > WorksheetGlobals::getCell( const ScAddress& rAddress ) const
444 {
445  Reference< XCell > xCell;
446  if( mxSheet.is() ) try
447  {
448  xCell = mxSheet->getCellByPosition( rAddress.Col(), rAddress.Row() );
449  }
450  catch( Exception& )
451  {
452  }
453  return xCell;
454 }
455 
456 Reference< XCellRange > WorksheetGlobals::getCellRange( const ScRange& rRange ) const
457 {
458  Reference< XCellRange > xRange;
459  if( mxSheet.is() ) try
460  {
461  xRange = mxSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
462  }
463  catch( Exception& )
464  {
465  }
466  return xRange;
467 }
468 
469 Reference< XSheetCellRanges > WorksheetGlobals::getCellRangeList( const ScRangeList& rRanges ) const
470 {
471  Reference< XSheetCellRanges > xRanges;
472  if( mxSheet.is() && !rRanges.empty() ) try
473  {
474  xRanges.set( getBaseFilter().getModelFactory()->createInstance( gaSheetCellRanges ), UNO_QUERY_THROW );
475  Reference< XSheetCellRangeContainer > xRangeCont( xRanges, UNO_QUERY_THROW );
476  xRangeCont->addRangeAddresses( AddressConverter::toApiSequence(rRanges), false );
477  }
478  catch( Exception& )
479  {
480  }
481  return xRanges;
482 }
483 
484 Reference< XCellRange > WorksheetGlobals::getColumn( sal_Int32 nCol ) const
485 {
486  Reference< XCellRange > xColumn;
487  try
488  {
489  Reference< XColumnRowRange > xColRowRange( mxSheet, UNO_QUERY_THROW );
490  Reference< XTableColumns > xColumns( xColRowRange->getColumns(), UNO_SET_THROW );
491  xColumn.set( xColumns->getByIndex( nCol ), UNO_QUERY );
492  }
493  catch( Exception& )
494  {
495  }
496  return xColumn;
497 }
498 
499 Reference< XCellRange > WorksheetGlobals::getRow( sal_Int32 nRow ) const
500 {
501  Reference< XCellRange > xRow;
502  try
503  {
504  Reference< XColumnRowRange > xColRowRange( mxSheet, UNO_QUERY_THROW );
505  Reference< XTableRows > xRows( xColRowRange->getRows(), UNO_SET_THROW );
506  xRow.set( xRows->getByIndex( nRow ), UNO_QUERY );
507  }
508  catch( Exception& )
509  {
510  }
511  return xRow;
512 }
513 
514 Reference< XDrawPage > WorksheetGlobals::getDrawPage() const
515 {
516  Reference< XDrawPage > xDrawPage;
517  try
518  {
519  xDrawPage = Reference< XDrawPageSupplier >( mxSheet, UNO_QUERY_THROW )->getDrawPage();
520  }
521  catch( Exception& )
522  {
523  }
524  return xDrawPage;
525 }
526 
527 const awt::Size& WorksheetGlobals::getDrawPageSize() const
528 {
529  OSL_ENSURE( (maDrawPageSize.Width > 0) && (maDrawPageSize.Height > 0), "WorksheetGlobals::getDrawPageSize - called too early, size invalid" );
530  return maDrawPageSize;
531 }
532 
533 awt::Point WorksheetGlobals::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const
534 {
535  awt::Point aPoint;
536  PropertySet aCellProp( getCell( ScAddress( nCol, nRow, getSheetIndex() ) ) );
537  aCellProp.getProperty( aPoint, PROP_Position );
538  return aPoint;
539 }
540 
541 namespace {
542 
543 sal_Int32 lclGetMidAddr( sal_Int32 nBegAddr, sal_Int32 nEndAddr, sal_Int32 nBegPos, sal_Int32 nEndPos, sal_Int32 nSearchPos )
544 {
545  // use sal_Int64 to prevent integer overflow
546  return nBegAddr + 1 + static_cast< sal_Int32 >( static_cast< sal_Int64 >( nEndAddr - nBegAddr - 2 ) * (nSearchPos - nBegPos) / (nEndPos - nBegPos) );
547 }
548 
549 bool lclPrepareInterval( sal_Int32 nBegAddr, sal_Int32& rnMidAddr, sal_Int32 nEndAddr,
550  sal_Int32 nBegPos, sal_Int32 nEndPos, sal_Int32 nSearchPos )
551 {
552  // searched position before nBegPos -> use nBegAddr
553  if( nSearchPos <= nBegPos )
554  {
555  rnMidAddr = nBegAddr;
556  return false;
557  }
558 
559  // searched position after nEndPos, or begin next to end -> use nEndAddr
560  if( (nSearchPos >= nEndPos) || (nBegAddr + 1 >= nEndAddr) )
561  {
562  rnMidAddr = nEndAddr;
563  return false;
564  }
565 
566  /* Otherwise find mid address according to position. lclGetMidAddr() will
567  return an address between nBegAddr and nEndAddr. */
568  rnMidAddr = lclGetMidAddr( nBegAddr, nEndAddr, nBegPos, nEndPos, nSearchPos );
569  return true;
570 }
571 
572 bool lclUpdateInterval( sal_Int32& rnBegAddr, sal_Int32& rnMidAddr, sal_Int32& rnEndAddr,
573  sal_Int32& rnBegPos, sal_Int32 nMidPos, sal_Int32& rnEndPos, sal_Int32 nSearchPos )
574 {
575  // nSearchPos < nMidPos: use the interval [begin,mid] in the next iteration
576  if( nSearchPos < nMidPos )
577  {
578  // if rnBegAddr is next to rnMidAddr, the latter is the column/row in question
579  if( rnBegAddr + 1 >= rnMidAddr )
580  return false;
581  // otherwise, set interval end to mid
582  rnEndPos = nMidPos;
583  rnEndAddr = rnMidAddr;
584  rnMidAddr = lclGetMidAddr( rnBegAddr, rnEndAddr, rnBegPos, rnEndPos, nSearchPos );
585  return true;
586  }
587 
588  // nSearchPos > nMidPos: use the interval [mid,end] in the next iteration
589  if( nSearchPos > nMidPos )
590  {
591  // if rnMidAddr is next to rnEndAddr, the latter is the column/row in question
592  if( rnMidAddr + 1 >= rnEndAddr )
593  {
594  rnMidAddr = rnEndAddr;
595  return false;
596  }
597  // otherwise, set interval start to mid
598  rnBegPos = nMidPos;
599  rnBegAddr = rnMidAddr;
600  rnMidAddr = lclGetMidAddr( rnBegAddr, rnEndAddr, rnBegPos, rnEndPos, nSearchPos );
601  return true;
602  }
603 
604  // nSearchPos == nMidPos: rnMidAddr is the column/row in question, do not loop anymore
605  return false;
606 }
607 
608 } // namespace
609 
611 {
612  // starting cell address and its position in drawing layer (top-left edge)
613  sal_Int32 nBegCol = 0;
614  sal_Int32 nBegRow = 0;
615  awt::Point aBegPos( 0, 0 );
616 
617  // end cell address and its position in drawing layer (bottom-right edge)
618  sal_Int32 nEndCol = mrMaxApiPos.Col() + 1;
619  sal_Int32 nEndRow = mrMaxApiPos.Row() + 1;
620  awt::Point aEndPos( maDrawPageSize.Width, maDrawPageSize.Height );
621 
622  // starting point for interval search
623  sal_Int32 nMidCol, nMidRow;
624  bool bLoopCols = lclPrepareInterval( nBegCol, nMidCol, nEndCol, aBegPos.X, aEndPos.X, rPosition.X );
625  bool bLoopRows = lclPrepareInterval( nBegRow, nMidRow, nEndRow, aBegPos.Y, aEndPos.Y, rPosition.Y );
626  awt::Point aMidPos = getCellPosition( nMidCol, nMidRow );
627 
628  /* The loop will find the column/row index of the cell right of/below
629  the cell containing the passed point, unless the point is located at
630  the top or left border of the containing cell. */
631  while( bLoopCols || bLoopRows )
632  {
633  bLoopCols = bLoopCols && lclUpdateInterval( nBegCol, nMidCol, nEndCol, aBegPos.X, aMidPos.X, aEndPos.X, rPosition.X );
634  bLoopRows = bLoopRows && lclUpdateInterval( nBegRow, nMidRow, nEndRow, aBegPos.Y, aMidPos.Y, aEndPos.Y, rPosition.Y );
635  aMidPos = getCellPosition( nMidCol, nMidRow );
636  }
637 
638  /* The cell left of/above the current search position contains the passed
639  point, unless the point is located on the top/left border of the cell,
640  or the last column/row of the sheet has been reached. */
641  if( aMidPos.X > rPosition.X ) --nMidCol;
642  if( aMidPos.Y > rPosition.Y ) --nMidRow;
643  return ScAddress( nMidCol, nMidRow, getSheetIndex() );
644 }
645 
646 ScRange WorksheetGlobals::getCellRangeFromRectangle( const awt::Rectangle& rRect ) const
647 {
648  ScAddress aStartAddr = getCellAddressFromPosition( awt::Point( rRect.X, rRect.Y ) );
649  awt::Point aBotRight( rRect.X + rRect.Width, rRect.Y + rRect.Height );
650  ScAddress aEndAddr = getCellAddressFromPosition( aBotRight );
651  bool bMultiCols = aStartAddr.Col() < aEndAddr.Col();
652  bool bMultiRows = aStartAddr.Row() < aEndAddr.Row();
653  if( bMultiCols || bMultiRows )
654  {
655  /* Reduce end position of the cell range to previous column or row, if
656  the rectangle ends exactly between two columns or rows. */
657  awt::Point aEndPos = getCellPosition( aEndAddr.Col(), aEndAddr.Row() );
658  if( bMultiCols && (aBotRight.X <= aEndPos.X) )
659  aEndAddr.IncCol(-1);
660  if( bMultiRows && (aBotRight.Y <= aEndPos.Y) )
661  aEndAddr.IncRow(-1);
662  }
663  return ScRange( aStartAddr.Col(), aStartAddr.Row(), getSheetIndex(),
664  aEndAddr.Col(), aEndAddr.Row(), getSheetIndex() );
665 }
666 
667 void WorksheetGlobals::setPageBreak( const PageBreakModel& rModel, bool bRowBreak )
668 {
669  if( rModel.mbManual && (rModel.mnColRow > 0) )
670  {
671  PropertySet aPropSet( bRowBreak ? getRow( rModel.mnColRow ) : getColumn( rModel.mnColRow ) );
672  aPropSet.setProperty( PROP_IsStartOfNewPage, true );
673  }
674 }
675 
677 {
678  maHyperlinks.push_back( rModel );
679 }
680 
682 {
683  maValidations.push_back( rModel );
684 }
685 
686 void WorksheetGlobals::setDrawingPath( const OUString& rDrawingPath )
687 {
688  maDrawingPath = rDrawingPath;
689 }
690 
691 void WorksheetGlobals::setVmlDrawingPath( const OUString& rVmlDrawingPath )
692 {
693  maVmlDrawingPath = rVmlDrawingPath;
694 }
695 
697 {
698  maUsedArea.aStart.SetCol( ::std::min( maUsedArea.aStart.Col(), rAddress.Col() ) );
699  maUsedArea.aStart.SetRow( ::std::min( maUsedArea.aStart.Row(), rAddress.Row() ) );
700  maUsedArea.aEnd.SetCol( ::std::max( maUsedArea.aEnd.Col(), rAddress.Col() ) );
701  maUsedArea.aEnd.SetRow( ::std::max( maUsedArea.aEnd.Row(), rAddress.Row() ) );
702 }
703 
705 {
706  extendUsedArea( rRange.aStart );
707  extendUsedArea( rRange.aEnd );
708 }
709 
711 {
712  extendUsedArea( rRange.aStart );
713  extendUsedArea( rRange.aEnd );
714 }
715 
716 void WorksheetGlobals::extendShapeBoundingBox( const awt::Rectangle& rShapeRect )
717 {
718  if( (maShapeBoundingBox.Width == 0) && (maShapeBoundingBox.Height == 0) )
719  {
720  // width and height of maShapeBoundingBox are assumed to be zero on first cell
721  maShapeBoundingBox = rShapeRect;
722  }
723  else
724  {
725  sal_Int32 nEndX = ::std::max( maShapeBoundingBox.X + maShapeBoundingBox.Width, rShapeRect.X + rShapeRect.Width );
726  sal_Int32 nEndY = ::std::max( maShapeBoundingBox.Y + maShapeBoundingBox.Height, rShapeRect.Y + rShapeRect.Height );
727  maShapeBoundingBox.X = ::std::min( maShapeBoundingBox.X, rShapeRect.X );
728  maShapeBoundingBox.Y = ::std::min( maShapeBoundingBox.Y, rShapeRect.Y );
729  maShapeBoundingBox.Width = nEndX - maShapeBoundingBox.X;
730  maShapeBoundingBox.Height = nEndY - maShapeBoundingBox.Y;
731  }
732 }
733 
734 void WorksheetGlobals::setBaseColumnWidth( sal_Int32 nWidth )
735 {
736  // do not modify width, if setDefaultColumnWidth() has been used
737  if( !mbHasDefWidth && (nWidth > 0) )
738  {
739  // #i3006# add 5 pixels padding to the width
740  const UnitConverter& rUnitConv = getUnitConverter();
742  rUnitConv.scaleToMm100( nWidth, Unit::Digit ) + rUnitConv.scaleToMm100( 5, Unit::ScreenX ), Unit::Digit );
743  }
744 }
745 
747 {
748  // overrides a width set with setBaseColumnWidth()
749  if( fWidth > 0.0 )
750  {
751  maDefColModel.mfWidth = fWidth;
752  mbHasDefWidth = true;
753  }
754 }
755 
757 {
758  // convert 1-based OOXML column indexes to 0-based API column indexes
759  sal_Int32 nFirstCol = rModel.maRange.mnFirst - 1;
760  sal_Int32 nLastCol = rModel.maRange.mnLast - 1;
761  if( getAddressConverter().checkCol( nFirstCol, true ) && (nFirstCol <= nLastCol) )
762  {
763  // Validate last column index.
764  // If last column is equal to last possible column, Excel adds one
765  // more. We do that also in XclExpColinfo::SaveXml() and for 1024 end
766  // up with 1025 instead, which would lead to excess columns in
767  // checkCol(). Cater for this oddity.
768  if (nLastCol == mrMaxApiPos.Col() + 1)
769  --nLastCol;
770  // This is totally fouled up. If we saved 1025 and the file is saved
771  // with Excel again, it increments the value to 1026.
772  else if (nLastCol == mrMaxApiPos.Col() + 2)
773  nLastCol -= 2;
774  // Excel may add a column range for the remaining columns (with
775  // <cols><col .../></cols>), even if not used or only used to grey out
776  // columns in page break view. Don't let that trigger overflow warning,
777  // so check for the last possible column. If there really is content in
778  // the range that should be caught anyway.
779  else if (nLastCol == getAddressConverter().getMaxXlsAddress().Col())
780  nLastCol = mrMaxApiPos.Col();
781  // User may have applied custom column widths to arbitrary excess
782  // columns. Ignore those and don't track as overflow columns (false).
783  // Effectively this does the same as the above cases, just keep them
784  // for explanation.
785  // Actual data present should trigger the overflow detection later.
786  else if( !getAddressConverter().checkCol( nLastCol, false ) )
787  nLastCol = mrMaxApiPos.Col();
788  // try to find entry in column model map that is able to merge with the passed model
789  bool bInsertModel = true;
790  if( !maColModels.empty() )
791  {
792  // find first column model range following nFirstCol (nFirstCol < aIt->first), or end of map
793  ColumnModelRangeMap::iterator aIt = maColModels.upper_bound( nFirstCol );
794  OSL_ENSURE( aIt == maColModels.end(), "WorksheetGlobals::setColModel - columns are unsorted" );
795  // if inserting before another column model, get last free column
796  OSL_ENSURE( (aIt == maColModels.end()) || (nLastCol < aIt->first), "WorksheetGlobals::setColModel - multiple models of the same column" );
797  if( aIt != maColModels.end() )
798  nLastCol = ::std::min( nLastCol, aIt->first - 1 );
799  if( aIt != maColModels.begin() )
800  {
801  // go to previous map element (which may be able to merge with the passed model)
802  --aIt;
803  // the usage of upper_bound() above ensures that aIt->first is less than or equal to nFirstCol now
804  sal_Int32& rnLastMapCol = aIt->second.second;
805  OSL_ENSURE( rnLastMapCol < nFirstCol, "WorksheetGlobals::setColModel - multiple models of the same column" );
806  nFirstCol = ::std::max( rnLastMapCol + 1, nFirstCol );
807  if( (rnLastMapCol + 1 == nFirstCol) && (nFirstCol <= nLastCol) && aIt->second.first.isMergeable( rModel ) )
808  {
809  // can merge with existing model, update last column index
810  rnLastMapCol = nLastCol;
811  bInsertModel = false;
812  }
813  }
814  }
815  if( nFirstCol <= nLastCol )
816  {
817  // insert the column model, if it has not been merged with another
818  if( bInsertModel )
819  maColModels[ nFirstCol ] = ColumnModelRange( rModel, nLastCol );
820  // set column formatting directly
821  convertColumnFormat( nFirstCol, nLastCol, rModel.mnXfId );
822  }
823  }
824 }
825 
826 void WorksheetGlobals::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId )
827 {
828  ScRange aRange( nFirstCol, 0, getSheetIndex(), nLastCol, mrMaxApiPos.Row(), getSheetIndex() );
829  if( getAddressConverter().validateCellRange( aRange, true, false ) )
830  {
831  const StylesBuffer& rStyles = getStyles();
832 
833  // Set cell styles via direct API - the preferred approach.
834  ScDocumentImport& rDoc = getDocImport();
835  rStyles.writeCellXfToDoc(rDoc, aRange, nXfId);
836  }
837 }
838 
839 void WorksheetGlobals::setDefaultRowSettings( double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom )
840 {
841  maDefRowModel.mfHeight = fHeight;
842  maDefRowModel.mbCustomHeight = bCustomHeight;
843  maDefRowModel.mbHidden = bHidden;
844  maDefRowModel.mbThickTop = bThickTop;
845  maDefRowModel.mbThickBottom = bThickBottom;
846 }
847 
849 {
850  // convert 1-based OOXML row index to 0-based API row index
851  sal_Int32 nRow = rModel.mnRow - 1;
852  if( getAddressConverter().checkRow( nRow, true ) )
853  {
854  // try to find entry in row model map that is able to merge with the passed model
855  bool bInsertModel = true;
856  bool bUnusedRow = true;
857  if( !maRowModels.empty() )
858  {
859  // find first row model range following nRow (nRow < aIt->first), or end of map
860  RowModelRangeMap::iterator aIt = maRowModels.upper_bound( nRow );
861  OSL_ENSURE( aIt == maRowModels.end(), "WorksheetGlobals::setRowModel - rows are unsorted" );
862  if( aIt != maRowModels.begin() )
863  {
864  // go to previous map element (which may be able to merge with the passed model)
865  --aIt;
866  // the usage of upper_bound() above ensures that aIt->first is less than or equal to nRow now
867  sal_Int32& rnLastMapRow = aIt->second.second;
868  bUnusedRow = rnLastMapRow < nRow;
869  OSL_ENSURE( bUnusedRow, "WorksheetGlobals::setRowModel - multiple models of the same row" );
870  if( (rnLastMapRow + 1 == nRow) && aIt->second.first.isMergeable( rModel ) )
871  {
872  // can merge with existing model, update last row index
873  ++rnLastMapRow;
874  bInsertModel = false;
875  }
876  }
877  }
878  if( bUnusedRow )
879  {
880  // insert the row model, if it has not been merged with another
881  if( bInsertModel )
882  maRowModels[ nRow ] = RowModelRange( rModel, nRow );
883  // set row formatting
884  maSheetData.setRowFormat( nRow, rModel.mnXfId, rModel.mbCustomFormat );
885  // set column spans
886  maSheetData.setColSpans( nRow, rModel.maColSpans );
887  }
888  }
889 
890  UpdateRowProgress( maUsedArea, nRow );
891 }
892 
893 // This is called at a higher frequency inside the (threaded) inner loop.
894 void WorksheetGlobals::UpdateRowProgress( const ScRange& rUsedArea, SCROW nRow )
895 {
896  if (!mxRowProgress || nRow < rUsedArea.aStart.Row() || rUsedArea.aEnd.Row() < nRow)
897  return;
898 
899  double fNewPos = static_cast<double>(nRow - rUsedArea.aStart.Row() + 1.0) / (rUsedArea.aEnd.Row() - rUsedArea.aStart.Row() + 1.0);
900 
901  if (mbFastRowProgress)
902  mxRowProgress->setPosition(fNewPos);
903  else
904  {
905  double fCurPos = mxRowProgress->getPosition();
906  if (fCurPos < fNewPos && (fNewPos - fCurPos) > 0.3)
907  // Try not to re-draw progress bar too frequently.
908  mxRowProgress->setPosition(fNewPos);
909  }
910 }
911 
913 {
914  // set default cell style for unused cells
915  ScDocumentImport& rDoc = getDocImport();
916 
917  ScStyleSheet* pStyleSheet =
918  static_cast<ScStyleSheet*>(rDoc.getDoc().GetStyleSheetPool()->Find(
919  getStyles().getDefaultStyleName(), SfxStyleFamily::Para));
920 
921  if (pStyleSheet)
922  rDoc.setCellStyleToSheet(getSheetIndex(), *pStyleSheet);
923 
924  /* Remember the current sheet index in global data, needed by global
925  objects, e.g. the chart converter. */
927 }
928 
930 {
931  lclUpdateProgressBar( mxRowProgress, 1.0 );
933  // assumes getTables().finalizeImport ( which creates the DatabaseRanges )
934  // has been called already
936 
938  lclUpdateProgressBar( mxFinalProgress, 0.25 );
946 
947  lclUpdateProgressBar( mxFinalProgress, 0.5 );
948  convertColumns();
949  convertRows();
950  lclUpdateProgressBar( mxFinalProgress, 1.0 );
951 }
952 
954 {
956 
957  // forget current sheet index in global data
958  setCurrentSheetIndex( -1 );
959 }
960 
961 // private --------------------------------------------------------------------
962 
964 {
965  for (auto const& link : maHyperlinks)
966  {
967  OUString aUrl = getHyperlinkUrl(link);
968  // try to insert URL into each cell of the range
969  if( !aUrl.isEmpty() )
970  for( ScAddress aAddress(link.maRange.aStart.Col(), link.maRange.aStart.Row(), getSheetIndex() ); aAddress.Row() <= link.maRange.aEnd.Row(); aAddress.IncRow() )
971  for( aAddress.SetCol(link.maRange.aStart.Col()); aAddress.Col() <= link.maRange.aEnd.Col(); aAddress.IncCol() )
972  insertHyperlink( aAddress, aUrl );
973  }
974 }
975 
976 OUString WorksheetGlobals::getHyperlinkUrl( const HyperlinkModel& rHyperlink ) const
977 {
978  OUStringBuffer aUrlBuffer;
979  if( !rHyperlink.maTarget.isEmpty() )
980  aUrlBuffer.append( getBaseFilter().getAbsoluteUrl( rHyperlink.maTarget ) );
981  if( !rHyperlink.maLocation.isEmpty() )
982  aUrlBuffer.append( '#' ).append( rHyperlink.maLocation );
983  OUString aUrl = aUrlBuffer.makeStringAndClear();
984 
985  if( aUrl.startsWith("#") )
986  {
987  sal_Int32 nSepPos = aUrl.lastIndexOf( '!' );
988  if( nSepPos > 0 )
989  {
990  // Do not attempt to blindly convert '#SheetName!A1' to
991  // '#SheetName.A1', it can be #SheetName!R1C1 as well. Hyperlink
992  // handler has to handle all, but prefer '#SheetName.A1' if
993  // possible.
994  if (nSepPos < aUrl.getLength() - 1)
995  {
996  ScRange aRange;
997  const ScDocumentImport& rDoc = getDocImport();
998  if ((aRange.ParseAny( aUrl.copy( nSepPos + 1 ), &rDoc.getDoc(),
1001  aUrl = aUrl.replaceAt( nSepPos, 1, OUString( '.' ) );
1002  }
1003  // #i66592# convert sheet names that have been renamed on import
1004  OUString aSheetName = aUrl.copy( 1, nSepPos - 1 );
1005  OUString aCalcName = getWorksheets().getCalcSheetName( aSheetName );
1006  if( !aCalcName.isEmpty() )
1007  aUrl = aUrl.replaceAt( 1, nSepPos - 1, aCalcName );
1008  }
1009  }
1010 
1011  return aUrl;
1012 }
1013 
1014 void WorksheetGlobals::insertHyperlink( const ScAddress& rAddress, const OUString& rUrl )
1015 {
1016  ScDocumentImport& rDoc = getDocImport();
1017  ScRefCellValue aCell(rDoc.getDoc(), rAddress);
1018 
1019  if (aCell.meType == CELLTYPE_STRING || aCell.meType == CELLTYPE_EDIT)
1020  {
1021  OUString aStr = aCell.getString(&rDoc.getDoc());
1022  ScFieldEditEngine& rEE = rDoc.getDoc().GetEditEngine();
1023  rEE.Clear();
1024 
1025  SvxURLField aURLField(rUrl, aStr, SvxURLFormat::Repr);
1026  SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD);
1027  rEE.QuickInsertField(aURLItem, ESelection());
1028 
1029  rDoc.setEditCell(rAddress, rEE.CreateTextObject());
1030  }
1031  else
1032  {
1033  // Handle other cell types e.g. formulas ( and ? ) that have associated
1034  // hyperlinks.
1035  // Ideally all hyperlinks should be treated as below. For the moment,
1036  // given the current absence of ods support lets just handle what we
1037  // previously didn't handle the new way.
1038  // Unfortunately we won't be able to preserve such hyperlinks when
1039  // saving to ods. Note: when we are able to save such hyperlinks to ods
1040  // we should handle *all* imported hyperlinks as below ( e.g. as cell
1041  // attribute ) for better interoperability.
1042 
1043  SfxStringItem aItem(ATTR_HYPERLINK, rUrl);
1044  rDoc.getDoc().ApplyAttr(rAddress.Col(), rAddress.Row(), rAddress.Tab(), aItem);
1045  }
1046 }
1047 
1049 {
1050  for (auto const& validation : maValidations)
1051  {
1052  PropertySet aPropSet( getCellRangeList(validation.maRanges) );
1053 
1054  Reference< XPropertySet > xValidation( aPropSet.getAnyProperty( PROP_Validation ), UNO_QUERY );
1055  if( xValidation.is() )
1056  {
1057  PropertySet aValProps( xValidation );
1058 
1059  try
1060  {
1061  const OUString aToken = validation.msRef.getToken( 0, ' ' );
1062 
1063  Reference<XSpreadsheet> xSheet = getSheetFromDoc( getCurrentSheetIndex() );
1064  Reference<XCellRange> xDBCellRange;
1065  Reference<XCell> xCell;
1066  xDBCellRange = xSheet->getCellRangeByName( aToken );
1067 
1068  xCell = xDBCellRange->getCellByPosition( 0, 0 );
1069  Reference<XCellAddressable> xCellAddressable( xCell, UNO_QUERY_THROW );
1070  CellAddress aFirstCell = xCellAddressable->getCellAddress();
1071  Reference<XSheetCondition> xCondition( xValidation, UNO_QUERY_THROW );
1072  xCondition->setSourcePosition( aFirstCell );
1073  }
1074  catch(const Exception&)
1075  {
1076  }
1077 
1078  // convert validation type to API enum
1079  ValidationType eType = ValidationType_ANY;
1080  switch( validation.mnType )
1081  {
1082  case XML_custom: eType = ValidationType_CUSTOM; break;
1083  case XML_date: eType = ValidationType_DATE; break;
1084  case XML_decimal: eType = ValidationType_DECIMAL; break;
1085  case XML_list: eType = ValidationType_LIST; break;
1086  case XML_none: eType = ValidationType_ANY; break;
1087  case XML_textLength: eType = ValidationType_TEXT_LEN; break;
1088  case XML_time: eType = ValidationType_TIME; break;
1089  case XML_whole: eType = ValidationType_WHOLE; break;
1090  default: OSL_FAIL( "WorksheetData::finalizeValidationRanges - unknown validation type" );
1091  }
1092  aValProps.setProperty( PROP_Type, eType );
1093 
1094  // convert error alert style to API enum
1095  ValidationAlertStyle eAlertStyle = ValidationAlertStyle_STOP;
1096  switch( validation.mnErrorStyle )
1097  {
1098  case XML_information: eAlertStyle = ValidationAlertStyle_INFO; break;
1099  case XML_stop: eAlertStyle = ValidationAlertStyle_STOP; break;
1100  case XML_warning: eAlertStyle = ValidationAlertStyle_WARNING; break;
1101  default: OSL_FAIL( "WorksheetData::finalizeValidationRanges - unknown error style" );
1102  }
1103  aValProps.setProperty( PROP_ErrorAlertStyle, eAlertStyle );
1104 
1105  // convert dropdown style to API visibility constants
1106  sal_Int16 nVisibility = validation.mbNoDropDown ? TableValidationVisibility::INVISIBLE : TableValidationVisibility::UNSORTED;
1107  aValProps.setProperty( PROP_ShowList, nVisibility );
1108 
1109  // messages
1110  aValProps.setProperty( PROP_ShowInputMessage, validation.mbShowInputMsg );
1111  aValProps.setProperty( PROP_InputTitle, validation.maInputTitle );
1112  aValProps.setProperty( PROP_InputMessage, validation.maInputMessage );
1113  aValProps.setProperty( PROP_ShowErrorMessage, validation.mbShowErrorMsg );
1114  aValProps.setProperty( PROP_ErrorTitle, validation.maErrorTitle );
1115  aValProps.setProperty( PROP_ErrorMessage, validation.maErrorMessage );
1116 
1117  // allow blank cells
1118  aValProps.setProperty( PROP_IgnoreBlankCells, validation.mbAllowBlank );
1119 
1120  try
1121  {
1122  // condition operator
1123  Reference< XSheetCondition2 > xSheetCond( xValidation, UNO_QUERY_THROW );
1124  if( eType == ValidationType_CUSTOM )
1125  xSheetCond->setConditionOperator( ConditionOperator2::FORMULA );
1126  else
1127  xSheetCond->setConditionOperator( CondFormatBuffer::convertToApiOperator( validation.mnOperator ) );
1128 
1129  // condition formulas
1130  Reference< XMultiFormulaTokens > xTokens( xValidation, UNO_QUERY_THROW );
1131  xTokens->setTokens( 0, validation.maTokens1 );
1132  xTokens->setTokens( 1, validation.maTokens2 );
1133  }
1134  catch( Exception& )
1135  {
1136  }
1137 
1138  // write back validation settings to cell range(s)
1139  aPropSet.setProperty( PROP_Validation, xValidation );
1140  }
1141  }
1142 }
1143 
1145 {
1146  sal_Int32 nNextCol = 0;
1147  sal_Int32 nMaxCol = mrMaxApiPos.Col();
1148  // stores first grouped column index for each level
1149  OutlineLevelVec aColLevels;
1150 
1151  for (auto const& colModel : maColModels)
1152  {
1153  // column indexes are stored 0-based in maColModels
1154  ValueRange aColRange( ::std::max( colModel.first, nNextCol ), ::std::min( colModel.second.second, nMaxCol ) );
1155  // process gap between two column models, use default column model
1156  if( nNextCol < aColRange.mnFirst )
1157  convertColumns( aColLevels, ValueRange( nNextCol, aColRange.mnFirst - 1 ), maDefColModel );
1158  // process the column model
1159  convertColumns( aColLevels, aColRange, colModel.second.first );
1160  // cache next column to be processed
1161  nNextCol = aColRange.mnLast + 1;
1162  }
1163 
1164  // remaining default columns to end of sheet
1165  convertColumns( aColLevels, ValueRange( nNextCol, nMaxCol ), maDefColModel );
1166  // close remaining column outlines spanning to end of sheet
1167  convertOutlines( aColLevels, nMaxCol + 1, 0, false, false );
1168 }
1169 
1171  const ValueRange& rColRange, const ColumnModel& rModel )
1172 {
1173  // column width: convert 'number of characters' to column width in 1/100 mm
1174  sal_Int32 nWidth = getUnitConverter().scaleToMm100( rModel.mfWidth, Unit::Digit );
1175 
1176  // macro sheets have double width
1178  nWidth *= 2;
1179 
1180  SCTAB nTab = getSheetIndex();
1181  ScDocument& rDoc = getScDocument();
1182  SCCOL nStartCol = rColRange.mnFirst;
1183  SCCOL nEndCol = rColRange.mnLast;
1184 
1185  if( nWidth > 0 )
1186  {
1187  for( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
1188  {
1189  rDoc.SetColWidthOnly( nCol, nTab, static_cast<sal_uInt16>(sc::HMMToTwips( nWidth )) );
1190  }
1191  }
1192 
1193  // hidden columns: TODO: #108683# hide columns later?
1194  if( rModel.mbHidden )
1195  {
1196  rDoc.SetColHidden( nStartCol, nEndCol, nTab, true );
1197  }
1198 
1199  // outline settings for this column range
1200  convertOutlines( orColLevels, rColRange.mnFirst, rModel.mnLevel, rModel.mbCollapsed, false );
1201 }
1202 
1204 {
1205  sal_Int32 nNextRow = 0;
1206  sal_Int32 nMaxRow = mrMaxApiPos.Row();
1207  // stores first grouped row index for each level
1208  OutlineLevelVec aRowLevels;
1209 
1210  for (auto const& rowModel : maRowModels)
1211  {
1212  // row indexes are stored 0-based in maRowModels
1213  ValueRange aRowRange( ::std::max( rowModel.first, nNextRow ), ::std::min( rowModel.second.second, nMaxRow ) );
1214  // process gap between two row models, use default row model
1215  if( nNextRow < aRowRange.mnFirst )
1216  convertRows( aRowLevels, ValueRange( nNextRow, aRowRange.mnFirst - 1 ), maDefRowModel );
1217  // process the row model
1218  convertRows( aRowLevels, aRowRange, rowModel.second.first, maDefRowModel.mfHeight );
1219  // cache next row to be processed
1220  nNextRow = aRowRange.mnLast + 1;
1221  }
1222 
1223  // remaining default rows to end of sheet
1224  convertRows( aRowLevels, ValueRange( nNextRow, nMaxRow ), maDefRowModel );
1225  // close remaining row outlines spanning to end of sheet
1226  convertOutlines( aRowLevels, nMaxRow + 1, 0, false, true );
1227 }
1228 
1230  const ValueRange& rRowRange, const RowModel& rModel, double fDefHeight )
1231 {
1232  // row height: convert points to row height in 1/100 mm
1233  double fHeight = (rModel.mfHeight >= 0.0) ? rModel.mfHeight : fDefHeight;
1234  sal_Int32 nHeight = getUnitConverter().scaleToMm100( fHeight, Unit::Point );
1235  SCROW nStartRow = rRowRange.mnFirst;
1236  SCROW nEndRow = rRowRange.mnLast;
1237  SCTAB nTab = getSheetIndex();
1238  if( nHeight > 0 )
1239  {
1240  /* always import the row height, ensures better layout */
1241  ScDocument& rDoc = getScDocument();
1242  rDoc.SetRowHeightOnly( nStartRow, nEndRow, nTab, static_cast<sal_uInt16>(sc::HMMToTwips(nHeight)) );
1243  if(rModel.mbCustomHeight)
1244  rDoc.SetManualHeight( nStartRow, nEndRow, nTab, true );
1245  }
1246 
1247  // hidden rows: TODO: #108683# hide rows later?
1248  if( rModel.mbHidden )
1249  {
1250  ScDocument& rDoc = getScDocument();
1251  rDoc.SetRowHidden( nStartRow, nEndRow, nTab, true );
1252  }
1253 
1254  // outline settings for this row range
1255  convertOutlines( orRowLevels, rRowRange.mnFirst, rModel.mnLevel, rModel.mbCollapsed, true );
1256 }
1257 
1259  sal_Int32 nColRow, sal_Int32 nLevel, bool bCollapsed, bool bRows )
1260 {
1261  /* It is ensured from caller functions, that this function is called
1262  without any gaps between the processed column or row ranges. */
1263 
1264  OSL_ENSURE( nLevel >= 0, "WorksheetGlobals::convertOutlines - negative outline level" );
1265  nLevel = ::std::max< sal_Int32 >( nLevel, 0 );
1266 
1267  sal_Int32 nSize = orLevels.size();
1268  if( nSize < nLevel )
1269  {
1270  // Outline level increased. Push the begin column position.
1271  orLevels.insert(orLevels.end(), nLevel - nSize, nColRow);
1272  }
1273  else if( nLevel < nSize )
1274  {
1275  // Outline level decreased. Pop them all out.
1276  for( sal_Int32 nIndex = nLevel; nIndex < nSize; ++nIndex )
1277  {
1278  sal_Int32 nFirstInLevel = orLevels.back();
1279  orLevels.pop_back();
1280  groupColumnsOrRows( nFirstInLevel, nColRow - 1, bCollapsed, bRows );
1281  bCollapsed = false; // collapse only once
1282  }
1283  }
1284 }
1285 
1286 void WorksheetGlobals::groupColumnsOrRows( sal_Int32 nFirstColRow, sal_Int32 nLastColRow, bool bCollapse, bool bRows )
1287 {
1288  try
1289  {
1290  Reference< XSheetOutline > xOutline( mxSheet, UNO_QUERY_THROW );
1291  if( bRows )
1292  {
1293  CellRangeAddress aRange( getSheetIndex(), 0, nFirstColRow, 0, nLastColRow );
1294  xOutline->group( aRange, TableOrientation_ROWS );
1295  if( bCollapse )
1296  xOutline->hideDetail( aRange );
1297  }
1298  else
1299  {
1300  CellRangeAddress aRange( getSheetIndex(), nFirstColRow, 0, nLastColRow, 0 );
1301  xOutline->group( aRange, TableOrientation_COLUMNS );
1302  if( bCollapse )
1303  xOutline->hideDetail( aRange );
1304  }
1305  }
1306  catch( Exception& )
1307  {
1308  }
1309 }
1310 
1312 {
1313  // calculate the current drawing page size (after rows/columns are imported)
1315  aRangeProp.getProperty( maDrawPageSize, PROP_Size );
1316 
1317  // import DML and VML
1318  if( !maDrawingPath.isEmpty() )
1320  if( !maVmlDrawingPath.isEmpty() )
1322 
1323  // comments (after callout shapes have been imported from VML/DFF)
1325 
1326  /* Extend used area of the sheet by cells covered with drawing objects.
1327  Needed if the imported document is inserted as "OLE object from file"
1328  and thus does not provide an OLE size property by itself. */
1329  if( (maShapeBoundingBox.Width > 0) || (maShapeBoundingBox.Height > 0) )
1331 
1332  // if no used area is set, default to A1
1333  if( maUsedArea.aStart.Col() > maUsedArea.aEnd.Col() )
1334  {
1335  maUsedArea.aStart.SetCol( 0 );
1336  maUsedArea.aEnd.SetCol( 0 );
1337  }
1338 
1339  if( maUsedArea.aStart.Row() > maUsedArea.aEnd.Row() )
1340  {
1341  maUsedArea.aStart.SetRow( 0 );
1342  maUsedArea.aEnd.SetRow( 0 );
1343  }
1344 
1345  /* Register the used area of this sheet in global view settings. The
1346  global view settings will set the visible area if this document is an
1347  embedded OLE object. */
1349 
1350  /* #i103686# Set right-to-left sheet layout. Must be done after all
1351  drawing shapes to simplify calculation of shape coordinates. */
1353  {
1354  PropertySet aPropSet( mxSheet );
1355  aPropSet.setProperty( PROP_TableLayout, WritingMode2::RL_TB );
1356  }
1357 }
1358 
1360  WorkbookHelper( rSheetGlob ),
1361  mrSheetGlob( rSheetGlob )
1362 {
1363 }
1364 
1366 {
1367  return getDocImport().getDoc();
1368 }
1369 
1371  const ISegmentProgressBarRef& rxProgressBar, WorksheetType eSheetType, SCTAB nSheet )
1372 {
1373  WorksheetGlobalsRef xSheetGlob = std::make_shared<WorksheetGlobals>( rHelper, rxProgressBar, eSheetType, nSheet );
1374  if( !xSheetGlob->isValidSheet() )
1375  xSheetGlob.reset();
1376  return xSheetGlob;
1377 }
1378 
1380 {
1381  return static_cast< IWorksheetProgress *>( xRef.get() );
1382 }
1383 
1385 {
1386  return mrSheetGlob.getSheetType();
1387 }
1388 
1390 {
1391  return mrSheetGlob.getSheetIndex();
1392 }
1393 
1394 const Reference< XSpreadsheet >& WorksheetHelper::getSheet() const
1395 {
1396  return mrSheetGlob.getSheet();
1397 }
1398 
1399 Reference< XCell > WorksheetHelper::getCell( const ScAddress& rAddress ) const
1400 {
1401  return mrSheetGlob.getCell( rAddress );
1402 }
1403 
1404 Reference< XCellRange > WorksheetHelper::getCellRange( const ScRange& rRange ) const
1405 {
1406  return mrSheetGlob.getCellRange( rRange );
1407 }
1408 
1409 Reference< XDrawPage > WorksheetHelper::getDrawPage() const
1410 {
1411  return mrSheetGlob.getDrawPage();
1412 }
1413 
1414 awt::Point WorksheetHelper::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const
1415 {
1416  return mrSheetGlob.getCellPosition( nCol, nRow );
1417 }
1418 
1419 const awt::Size& WorksheetHelper::getDrawPageSize() const
1420 {
1421  return mrSheetGlob.getDrawPageSize();
1422 }
1423 
1425 {
1426  return mrSheetGlob.getSheetData();
1427 }
1428 
1430 {
1431  return mrSheetGlob.getCondFormats();
1432 }
1433 
1435 {
1436  return mrSheetGlob.getComments();
1437 }
1438 
1440 {
1441  return mrSheetGlob.getAutoFilters();
1442 }
1443 
1445 {
1446  return mrSheetGlob.getQueryTables();
1447 }
1448 
1450 {
1452 }
1453 
1455 {
1456  return mrSheetGlob.getPageSettings();
1457 }
1458 
1460 {
1462 }
1463 
1465 {
1466  return mrSheetGlob.getVmlDrawing();
1467 }
1468 
1470 {
1471  return mrSheetGlob.getExtLst();
1472 }
1473 
1474 void WorksheetHelper::setPageBreak( const PageBreakModel& rModel, bool bRowBreak )
1475 {
1476  mrSheetGlob.setPageBreak( rModel, bRowBreak );
1477 }
1478 
1480 {
1481  mrSheetGlob.setHyperlink( rModel );
1482 }
1483 
1485 {
1486  mrSheetGlob.setValidation( rModel );
1487 }
1488 
1489 void WorksheetHelper::setDrawingPath( const OUString& rDrawingPath )
1490 {
1491  mrSheetGlob.setDrawingPath( rDrawingPath );
1492 }
1493 
1494 void WorksheetHelper::setVmlDrawingPath( const OUString& rVmlDrawingPath )
1495 {
1496  mrSheetGlob.setVmlDrawingPath( rVmlDrawingPath );
1497 }
1498 
1500 {
1501  mrSheetGlob.extendUsedArea( rAddress );
1502 }
1503 
1504 void WorksheetHelper::extendShapeBoundingBox( const awt::Rectangle& rShapeRect )
1505 {
1506  mrSheetGlob.extendShapeBoundingBox( rShapeRect );
1507 }
1508 
1509 void WorksheetHelper::setBaseColumnWidth( sal_Int32 nWidth )
1510 {
1511  mrSheetGlob.setBaseColumnWidth( nWidth );
1512 }
1513 
1515 {
1517 }
1518 
1520 {
1521  mrSheetGlob.setColumnModel( rModel );
1522 }
1523 
1524 void WorksheetHelper::setDefaultRowSettings( double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom )
1525 {
1526  mrSheetGlob.setDefaultRowSettings( fHeight, bCustomHeight, bHidden, bThickTop, bThickBottom );
1527 }
1528 
1530 {
1531  mrSheetGlob.setRowModel( rModel );
1532 }
1533 
1535  const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType )
1536 {
1537  getFormulaBuffer().setCellFormulaValue(rAddress, rValueStr, nCellType);
1538 }
1539 
1540 void WorksheetHelper::putRichString( const ScAddress& rAddress, const RichString& rString, const oox::xls::Font* pFirstPortionFont )
1541 {
1543 
1544  // The cell will own the text object instance returned from convert().
1545  getDocImport().setEditCell(rAddress, rString.convert(rEE, pFirstPortionFont));
1546 }
1547 
1548 void WorksheetHelper::putFormulaTokens( const ScAddress& rAddress, const ApiTokenSequence& rTokens )
1549 {
1550  ScDocumentImport& rDoc = getDocImport();
1551  std::unique_ptr<ScTokenArray> pTokenArray(new ScTokenArray(&rDoc.getDoc()));
1552  ScTokenConversion::ConvertToTokenArray(rDoc.getDoc(), *pTokenArray, rTokens);
1553  rDoc.setFormulaCell(rAddress, std::move(pTokenArray));
1554 }
1555 
1557 {
1559 }
1560 
1562 {
1564 }
1565 
1567 {
1569 }
1570 
1571 void WorksheetHelper::setCellFormula( const ScAddress& rTokenAddress, const OUString& rTokenStr )
1572 {
1573  getFormulaBuffer().setCellFormula( rTokenAddress, rTokenStr );
1574 }
1575 
1577  const ScAddress& rAddr, sal_Int32 nSharedId,
1578  const OUString& rCellValue, sal_Int32 nValueType )
1579 {
1580  getFormulaBuffer().setCellFormula(rAddr, nSharedId, rCellValue, nValueType);
1581 }
1582 
1583 void WorksheetHelper::setCellArrayFormula( const ScRange& rRangeAddress, const ScAddress& rTokenAddress, const OUString& rTokenStr )
1584 {
1585  getFormulaBuffer().setCellArrayFormula( rRangeAddress, rTokenAddress, rTokenStr );
1586 }
1587 
1589  const ScAddress& rAddress, sal_Int32 nSharedId, const OUString& rTokens )
1590 {
1591  getFormulaBuffer().createSharedFormulaMapEntry(rAddress, nSharedId, rTokens);
1592 }
1593 
1594 } // namespace oox
1595 
1596 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void convertColumns()
Converts column properties for all columns in the sheet.
static css::uno::Sequence< css::table::CellRangeAddress > toApiSequence(const ScRangeList &orRanges)
Converts the passed range list to a sequence of cell range addresses.
Helper class to provide access to global workbook data.
bool isSheetRightToLeft() const
Returns true, if the sheet layout is set to right-to-left.
HyperlinkModel()
Additional tooltip text.
SCTAB getSheetIndex() const
Returns the index of the current sheet.
static WorksheetGlobalsRef constructGlobals(const WorkbookHelper &rHelper, const ISegmentProgressBarRef &rxProgressBar, WorksheetType eSheetType, SCTAB nSheet)
bool mbFastRowProgress
Sheet progress bar.
void setBaseColumnWidth(sal_Int32 nWidth)
Sets base width for all columns (without padding pixels).
void setCurrentSheetIndex(SCTAB nSheet)
Sets the index of the current Calc sheet, if filter currently processes a sheet.
awt::Size maDrawPageSize
Path to legacy VML drawing fragment.
SC_DLLPUBLIC ScRefFlags ParseAny(const OUString &, const ScDocument *, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
Definition: address.cxx:1770
sal_Int32 nIndex
ScAddress getCellAddressFromPosition(const awt::Point &rPosition) const
Returns the address of the cell that contains the passed point in 1/100 mm.
ScAddress aStart
Definition: address.hxx:500
ScDocumentImport & getDocImport()
SheetDataBuffer & getSheetData() const
Returns the buffer for cell contents and cell formatting.
static sal_Int32 convertToApiOperator(sal_Int32 nToken)
Converts an OOXML condition operator token to the API constant.
Reference< XDrawPage > getDrawPage() const
Returns the XDrawPage interface of the draw page of the current sheet.
PageSettings & getPageSettings()
Returns the page/print settings for this sheet.
SCROW Row() const
Definition: address.hxx:262
bool mbThickTop
True = row outline is collapsed.
bool getProperty(Type &orValue, sal_Int32 nPropId) const
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
sal_Int16 mnLevel
void createSharedFormulaMapEntry(const ScAddress &rAddress, sal_Int32 nSharedId, const OUString &rTokens)
WorksheetSettings & getWorksheetSettings()
Returns the worksheet settings object.
void setColumnModel(const ColumnModel &rModel)
Sets column settings for a specific column range.
const awt::Size & getDrawPageSize() const
Returns the size of the entire drawing page in 1/100 mm.
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
bool validateCellRange(ScRange &orRange, bool bAllowOverflow, bool bTrackOverflow)
Checks the passed cell range, may try to fit it to current sheet limits.
Contains string data and a list of formatting runs for a rich formatted string.
Definition: richstring.hxx:209
OUString getCalcSheetName(sal_Int32 nWorksheet) const
Returns the finalized name of the specified worksheet.
const SCCOL SCCOL_MAX
Definition: address.hxx:57
SheetDataBuffer maSheetData
Cell ranges containing data validation settings.
::std::map< sal_Int32, RowModelRange > RowModelRangeMap
css::uno::Any getAnyProperty(sal_Int32 nPropId) const
bool mbHasDefWidth
Reference to the current sheet.
SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden)
Definition: document.cxx:4470
WorksheetGlobals & mrSheetGlob
void finalizeImport()
Converts all imported sheet view settings.
void convertOutlines(OutlineLevelVec &orLevels, sal_Int32 nColRow, sal_Int32 nLevel, bool bCollapsed, bool bRows)
Converts outline grouping for the passed column or row.
ColumnModel()
True = column outline is collapsed.
bool mbCustomFormat
True = row has custom height.
void extendShapeBoundingBox(const awt::Rectangle &rShapeRect)
Extends the shape bounding box by the position and size of the passed rectangle.
ExtLst & getExtLst()
returns the ExtLst entries that need to be filled
RowModel maDefRowModel
Ranges of columns sorted by first column index.
css::uno::Reference< css::table::XCellRange > getCellRange(const ScRange &rRange) const
Returns the XCellRange interface for the passed cell range address.
Helper class that provides functions to convert values from and to different units.
ScAddress aEnd
Definition: address.hxx:501
void finalizeImport()
Inserts all web queries into the sheet.
SheetViewSettings & getSheetViewSettings()
Returns the view settings for this sheet.
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:104
#define STATIC_ARRAY_SELECT(array, index, def)
WorksheetSettings & getWorksheetSettings() const
Returns the worksheet settings object.
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4760
Accessor class to ScDocument.
ScRange maUsedArea
Reference to maximum Calc cell address from address converter.
SheetViewSettings & getSheetViewSettings() const
Returns the view settings for this sheet.
const SCROW SCROW_MAX
Definition: address.hxx:56
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
void putFormulaTokens(const ScAddress &rAddress, const ApiTokenSequence &rTokens)
Inserts a formula cell directly into the Calc sheet.
void finalizeDrawings()
Imports the drawings of the sheet (DML, VML, DFF) and updates the used area.
ISegmentProgressBarRef mxFinalProgress
Progress bar for row/cell processing.
bool importOoxFragment(const rtl::Reference< oox::core::FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
void setEditCell(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
QueryTableBuffer maQueryTables
Sheet auto filters (not associated to a table).
const css::awt::Size & getDrawPageSize() const
Returns the size of the entire drawing page in 1/100 mm.
Fragment handler for a complete sheet drawing.
sal_Int32 scaleToMm100(double fValue, Unit eUnit) const
Converts the passed value to 1/100 millimeters.
Reference< XSheetCellRanges > getCellRangeList(const ScRangeList &rRanges) const
Returns the XSheetCellRanges interface for the passed cell range addresses.
void setDrawingPath(const OUString &rDrawingPath)
Sets the path to the DrawingML fragment of this sheet.
void setHyperlink(const HyperlinkModel &rModel)
Inserts the hyperlink URL into the spreadsheet.
CondFormatBuffer & getCondFormats() const
Returns the conditional formatting in this sheet.
void extendShapeBoundingBox(const css::awt::Rectangle &rShapeRect)
Extends the shape bounding box by the position and size of the passed rectangle (in 1/100 mm)...
void finalizeImport()
Finalizes the formatted string of all comments.
bool mbShowPhonetic
True = cells in row have explicit formatting.
ViewSettings & getViewSettings() const
Returns the workbook and sheet view settings object.
void initializeWorksheetImport()
Initial conversion before importing the worksheet.
void setBiffType(sal_uInt8 nType)
Sets the passed BIFF validation type.
void finalizeValidationRanges() const
Inserts all imported data validations into their cell ranges.
bool mbCustomHeight
Row outline level.
Reference< XSpreadsheet > mxSheet
Type of this sheet.
std::shared_ptr< WorksheetGlobals > WorksheetGlobalsRef
std::vector< ValidationModel > maValidations
Cell ranges containing hyperlinks.
void convertColumnFormat(sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId)
Converts column default cell formatting.
Stores formatting data about a page break.
bool mbCollapsed
True = row is hidden.
void setRowFormat(sal_Int32 nRow, sal_Int32 nXfId, bool bCustomFormat)
Sets default cell formatting for the specified range of rows.
WorksheetType getSheetType() const
Returns the type of this sheet.
void setVmlDrawingPath(const OUString &rVmlDrawingPath)
Sets the path to the legacy VML drawing fragment of this sheet.
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
void setCellArrayFormula(const ScRange &rRangeAddress, const ScAddress &rTokenAddress, const OUString &rTokenStr)
void putRichString(const ScAddress &rAddress, const RichString &rString, const oox::xls::Font *pFirstPortionFont)
Inserts a rich-string cell directly into the Calc sheet.
sal_Int16 getCurrentSheetIndex() const
Returns the index of the current Calc sheet, if filter currently processes a sheet.
SCTAB Tab() const
Definition: address.hxx:271
void SetRow(SCROW nRowP)
Definition: address.hxx:275
WorksheetType meSheetType
Progress bar for finalization.
void applyAutoFilters()
Applies autofilters from created database range ( requires finalizeImport to have run before being ca...
CommentsBuffer & getComments() const
Returns the buffer for all cell comments in this sheet.
CommentsBuffer maComments
Buffer for conditional formatting.
uno::Reference< sdbc::XRow > xRow
double mfHeight
0-based (!) column ranges of used cells.
void extendUsedArea(const ScAddress &rAddress)
Extends the used area of this sheet by the passed cell position.
SC_DLLPUBLIC void SetColWidthOnly(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
Definition: document.cxx:4092
bool isValidSheet() const
Returns true, if this helper refers to an existing Calc sheet.
std::vector< HyperlinkModel > maHyperlinks
Ranges of rows sorted by first row index.
static IWorksheetProgress * getWorksheetInterface(const WorksheetGlobalsRef &xRef)
SC_DLLPUBLIC void SetRowHeightOnly(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt16 nNewHeight)
Definition: document.cxx:4111
sal_Int32 mnLevel
Column default formatting.
bool isMergeable(const ColumnModel &rModel) const
Returns true, if this entry can be merged with the passed column range (column settings are equal)...
void setCellStyleToSheet(SCTAB nTab, const ScStyleSheet &rStyle)
Apply specified cell style to an entire sheet.
void SetCol(SCCOL nColP)
Definition: address.hxx:279
CommentsBuffer & getComments()
Returns the buffer for all cell comments in this sheet.
void setCellFormulaValue(const ScAddress &rAddress, const OUString &rValueStr, sal_Int32 nCellType)
Stores settings and formatting data about a sheet row.
void setBiffOperator(sal_uInt8 nOperator)
Sets the passed BIFF operator.
OUString getHyperlinkUrl(const HyperlinkModel &rHyperlink) const
Generates the final URL for the passed hyperlink.
bool empty() const
Definition: rangelst.hxx:89
DocumentType eType
awt::Rectangle maShapeBoundingBox
Current size of the drawing page in 1/100 mm.
AutoFilterBuffer maAutoFilters
Buffer for all cell comments in this sheet.
sal_Int32 mnFirst
double mfWidth
1-based (!) range of the described columns.
sal_Int32 mnXfId
Column width in number of characters.
bool mbHidden
True = cells in row show phonetic settings.
void setCellFormula(const ScAddress &rTokenAddress, const OUString &)
VmlDrawingPtr mxVmlDrawing
View settings for this sheet.
::std::map< sal_Int32, ColumnModelRange > ColumnModelRangeMap
void SetTab(SCTAB nTabP)
Definition: address.hxx:283
void createSharedFormulaMapEntry(const ScAddress &rAddress, sal_Int32 nSharedId, const OUString &rTokens)
css::uno::Reference< css::drawing::XDrawPage > getDrawPage() const
Returns the XDrawPage interface of the draw page of the current sheet.
void convertRows()
Converts row properties for all rows in the sheet.
void setDrawingPath(const OUString &rDrawingPath)
Sets the path to the DrawingML fragment of this sheet.
ISegmentProgressBarRef mxProgressBar
Bounding box for all shapes from all drawings.
void setCellFormula(const ScAddress &rAddress, const OUString &)
bool mbHidden
True = cells in column show phonetic settings.
bool mbCollapsed
True = column is hidden.
ISegmentProgressBarRef mxRowProgress
Do we have a progress bar thread ?
void setDefaultRowSettings(double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom)
Sets default height and hidden state for all unused rows in the sheet.
void setDefaultColumnWidth(double fWidth)
Sets default width for all columns.
PageBreakModel()
True = manual page break.
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:304
sal_Int32 mnType
virtual void setCustomRowProgress(const ISegmentProgressBarRef &rxRowProgress) override
Reference< XCellRange > getCellRange(const ScRange &rRange) const
Returns the XCellRange interface for the passed cell range address.
sal_Int16 SCCOL
Definition: types.hxx:22
Stores settings and formatting data about a range of sheet columns.
void UpdateRowProgress(const ScRange &rUsedArea, SCROW nRow)
Update the row import progress bar.
WorksheetType getSheetType() const
Returns the type of this sheet.
std::shared_ptr< ISegmentProgressBar > ISegmentProgressBarRef
::std::pair< ColumnModel, sal_Int32 > ColumnModelRange
long HMMToTwips(long nHMM)
Definition: global.hxx:109
void insertHyperlink(const ScAddress &rAddress, const OUString &rUrl)
Inserts a hyperlinks into the specified cell.
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
void setPageBreak(const PageBreakModel &rModel, bool bRowBreak)
Sets a column or row page break described in the passed struct.
std::unique_ptr< EditTextObject > CreateTextObject()
AutoFilterBuffer & getAutoFilters()
Returns the auto filters for the sheet.
void IncRow(SCROW nDelta=1)
Definition: address.hxx:300
void convert(const css::uno::Reference< css::text::XText > &rxText) const
Converts the string and writes it into the passed XText, replace old contents of the text object...
const Reference< XSpreadsheet > & getSheet() const
Returns the XSpreadsheet interface of the current sheet.
void insertColSpan(const ValueRange &rColSpan)
Inserts the passed column span into the row model.
XML_TOKEN_INVALID
SheetViewSettings maSheetViewSett
Page/print settings for this sheet.
static SC_DLLPUBLIC bool ConvertToTokenArray(ScDocument &rDoc, ScTokenArray &rTokenArray, const css::uno::Sequence< css::sheet::FormulaToken > &rSequence)
Definition: tokenuno.cxx:348
void setBaseColumnWidth(sal_Int32 nWidth)
Sets base width for all columns (without padding pixels).
void finalizeImport(sal_Int16 nSheet)
Applies filter settings to a new database range object (used for sheet autofilter or advanced filter ...
ScEditEngineDefaulter & getEditEngine() const
void setVmlDrawingPath(const OUString &rVmlDrawingPath)
Sets the path to the legacy VML drawing fragment of this sheet.
css::uno::Reference< css::table::XCell > getCell(const ScAddress &rAddress) const
Returns the XCell interface for the passed cell address.
VmlDrawing & getVmlDrawing()
Returns the VML drawing page for this sheet (OOXML/BIFF12 only).
void setDefaultRowSettings(double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom)
Sets default height and hidden state for all unused rows in the sheet.
::std::map< OUString, ScDataBarFormatData * > ExtLst
CondFormatBuffer maCondFormats
Buffer for cell contents and cell formatting.
void initializeWorksheetImport()
Initial conversion before importing the worksheet.
ExtLst maExtLst
Collection of all VML shapes.
QueryTableBuffer & getQueryTables() const
Returns the buffer for all web query tables in this sheet.
ColumnModelRangeMap maColModels
Default column formatting.
void setColumnModel(const ColumnModel &rModel)
Sets column settings for a specific range of columns.
OUString maVmlDrawingPath
Path to DrawingML fragment.
SCCOL Col() const
Definition: address.hxx:267
void setValidation(const ValidationModel &rModel)
Inserts the data validation settings into the spreadsheet.
RowModel()
True = row has extra space below text.
::std::vector< sal_Int32 > OutlineLevelVec
sal_Int32 mnXfId
Row height in points.
CondFormatBuffer & getCondFormats()
Returns the conditional formatting in this sheet.
css::uno::Sequence< ApiToken > ApiTokenSequence
Stores data about ranges with data validation settings.
void finalizeDrawingImport()
Final import of drawing objects.
ScRange getCellRangeFromRectangle(const awt::Rectangle &rRect) const
Returns the cell range address that contains the passed rectangle in 1/100 mm.
PageSettings maPageSett
Global settings for this sheet.
void extendUsedArea(const ScAddress &rAddress)
Extends the used area of this sheet by the passed cell position.
void setFormulaCell(const ScAddress &rPos, const OUString &rFormula, formula::FormulaGrammar::Grammar eGrammar, const double *pResult=nullptr)
sal_Int32 SCROW
Definition: types.hxx:18
ColumnModel maDefColModel
Used area of the sheet, and sheet index of the sheet.
bool isMergeable(const RowModel &rModel) const
Returns true, if this entry can be merged with the passed row range (row settings are equal)...
void setColSpans(sal_Int32 nRow, const ValueRangeSet &rColSpans)
Sets column span information for a row.
void setCellArrayFormula(const ScRange &rRangeAddress, const ScAddress &rTokenAddress, const OUString &)
css::awt::Point getCellPosition(sal_Int32 nCol, sal_Int32 nRow) const
Returns the absolute cell position in 1/100 mm.
void setSheetUsedArea(const ScRange &rUsedArea)
Stores the used area for a specific worksheet.
void finalizeImport()
Creates a page style for the spreadsheet and sets all page properties.
const css::uno::Reference< css::sheet::XSpreadsheet > & getSheet() const
Returns the XSpreadsheet interface of the current sheet.
WorksheetGlobals(const WorkbookHelper &rHelper, const ISegmentProgressBarRef &rxProgressBar, WorksheetType eSheetType, SCTAB nSheet)
Service name for a SheetCellRanges object.
unsigned char sal_uInt8
void finalizeWorksheetImport()
Final conversion after importing the worksheet.
SheetDataBuffer & getSheetData()
Returns the buffer for cell contents and cell formatting.
ValueRangeSet maColSpans
1-based (!) index of the described row.
RowModelRangeMap maRowModels
Default row formatting.
Reference< XCell > getCell(const ScAddress &rAddress) const
Returns the XCell interface for the passed cell address.
English Metric Unit (1/360,000 cm).
SCTAB getSheetIndex() const
Returns the index of the current sheet.
void insert(const ValueRange &rRange)
awt::Point getCellPosition(sal_Int32 nCol, sal_Int32 nRow) const
Returns the absolute position of the top-left corner of the cell in 1/100 mm.
void setCellFormulaValue(const ScAddress &rAddress, const OUString &rValueStr, sal_Int32 nCellType)
SC_DLLPUBLIC void SetManualHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual)
Definition: document.cxx:4117
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
::std::unique_ptr< VmlDrawing > VmlDrawingPtr
QueryTableBuffer & getQueryTables()
Returns the buffer for all web query tables in this sheet.
SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden)
Definition: document.cxx:4462
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6069
void finalizeImport()
Converts the imported worksheet settings.
double scaleFromMm100(sal_Int32 nMm100, Unit eUnit) const
Converts the passed value from 1/100 millimeters to the passed unit.
constexpr TypedWhichId< SfxStringItem > ATTR_HYPERLINK(155)
Reference< XColumn > xColumn
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
Reference< XCellRange > getColumn(sal_Int32 nCol) const
Returns the XCellRange interface for a column.
css::uno::Reference< css::sheet::XSpreadsheet > getSheetFromDoc(sal_Int32 nSheet) const
Returns a reference to the specified spreadsheet in the document model.
virtual ISegmentProgressBarRef getRowProgress() override
Allow the threaded importer to override our progress bar impl.
constexpr sal_uInt16 EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
WorksheetHelper(WorksheetGlobals &rSheetGlob)
void writeCellXfToDoc(ScDocumentImport &rDoc, const ScRange &rRange, sal_Int32 nXfId) const
Writes the cell formatting attributes of the specified XF to the passed property set.
VmlDrawing & getVmlDrawing() const
Returns the VML drawing page for this sheet (OOXML/BIFF12 only).
sal_Int32 mnRow
WorksheetSettings maSheetSett
Buffer for all web query tables in this sheet.
void finalizeImport()
Final processing after the sheet has been imported.
void setHyperlink(const HyperlinkModel &rModel)
Inserts the hyperlink URL into the spreadsheet.
Stores data about a hyperlink range.
Reference< XCellRange > getRow(sal_Int32 nRow) const
Returns the XCellRange interface for a row.
const OUStringLiteral gaSheetCellRanges("com.sun.star.sheet.SheetCellRanges")
sal_Int32 mnLevel
Row default formatting (see mbIsFormatted).
WorksheetType
An enumeration for all types of sheets in a workbook.
void setValidation(const ValidationModel &rModel)
Inserts the data validation settings into the spreadsheet.
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
::std::pair< RowModel, sal_Int32 > RowModelRange
AutoFilterBuffer & getAutoFilters() const
Returns the auto filters for the sheet.
void setPageBreak(const PageBreakModel &rModel, bool bRowBreak)
Sets a column or row page break described in the passed struct.
const ScAddress & getMaxXlsAddress() const
Returns the biggest valid cell address in the imported/exported Excel document.
aStr
void setRowModel(const RowModel &rModel)
Sets row settings for a specific row.
void finalizeWorksheetImport()
Final conversion after importing the worksheet.
OUString maDrawingPath
List of extended elements.
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:454
void finalizeHyperlinkRanges()
Inserts all imported hyperlinks into their cell ranges.
bool mbThickBottom
True = row has extra space above text.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
B2DRange maRange
void setRowModel(const RowModel &rModel)
Sets row settings for a specific range of rows.
sal_Int16 SCTAB
Definition: types.hxx:23
PageSettings & getPageSettings() const
Returns the page/print settings for this sheet.
const char first[]
Manages the cell contents and cell formatting of a sheet.
Vertical screen pixels.
void Clear()
bool mbManual
End of limited break.
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
FormulaBuffer & getFormulaBuffer() const
sal_Int32 mnLast
void groupColumnsOrRows(sal_Int32 nFirstColRow, sal_Int32 nLastColRow, bool bCollapsed, bool bRows)
Groups columns or rows for the given range.
void setDefaultColumnWidth(double fWidth)
Sets default width for all columns.
void setBiffErrorStyle(sal_uInt8 nErrorStyle)
Sets the passed BIFF error style.
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
ScDocument & getDoc()