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