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 <table.hxx>
67#include <tablebuffer.hxx>
68#include <documentimport.hxx>
69#include <stlsheet.hxx>
70#include <stlpool.hxx>
71#include <cellvalue.hxx>
72#include <columnspanset.hxx>
73#include <dbdata.hxx>
74
75#include <svl/stritem.hxx>
76#include <editeng/eeitem.hxx>
77#include <editeng/editobj.hxx>
78#include <editeng/flditem.hxx>
79#include <tools/gen.hxx>
80
81namespace oox::xls {
82
83using namespace ::com::sun::star;
84using namespace ::com::sun::star::beans;
85using namespace ::com::sun::star::drawing;
86using namespace ::com::sun::star::lang;
87using namespace ::com::sun::star::sheet;
88using namespace ::com::sun::star::table;
89using namespace ::com::sun::star::text;
90using namespace ::com::sun::star::uno;
91
92namespace {
93
94void lclUpdateProgressBar( const ISegmentProgressBarRef& rxProgressBar, double fPosition )
95{
96 if( rxProgressBar )
97 rxProgressBar->setPosition( fPosition );
98}
99
100// TODO Needed because input might be >32-bit (in 64-bit builds),
101// or a negative, already overflown value (in 32-bit builds)
102sal_Int32 lclClampToNonNegativeInt32( tools::Long aVal )
103{
104 if ( aVal > SAL_MAX_INT32 || aVal < 0 )
105 {
106 SAL_WARN( "sc.filter", "Overflow detected, " << aVal << " does not fit into sal_Int32, or is negative." );
107 return SAL_MAX_INT32;
108 }
109 return static_cast<sal_Int32>( aVal );
110}
111
112} // namespace
113
115 maRange( -1 ),
116 mfWidth( 0.0 ),
117 mnXfId( -1 ),
118 mnLevel( 0 ),
119 mbShowPhonetic( false ),
120 mbHidden( false ),
121 mbCollapsed( false )
122{
123}
124
125bool ColumnModel::isMergeable( const ColumnModel& rModel ) const
126{
127 return
128 (maRange.mnFirst <= rModel.maRange.mnFirst) &&
129 (rModel.maRange.mnFirst <= maRange.mnLast + 1) &&
130 (mfWidth == rModel.mfWidth) &&
131 // ignore mnXfId, cell formatting is always set directly
132 (mnLevel == rModel.mnLevel) &&
133 (mbHidden == rModel.mbHidden) &&
134 (mbCollapsed == rModel.mbCollapsed);
135}
136
138 mnRow( -1 ),
139 mfHeight( 0.0 ),
140 mnXfId( -1 ),
141 mnLevel( 0 ),
142 mbCustomHeight( false ),
143 mbCustomFormat( false ),
144 mbShowPhonetic( false ),
145 mbHidden( false ),
146 mbCollapsed( false ),
147 mbThickTop( false ),
148 mbThickBottom( false )
149{
150}
151
152bool RowModel::isMergeable( const RowModel& rModel ) const
153{
154 return
155 // ignore maColSpans - is handled separately in SheetDataBuffer class
156 (mfHeight == rModel.mfHeight) &&
157 // ignore mnXfId, mbCustomFormat, mbShowPhonetic - cell formatting is always set directly
158 (mnLevel == rModel.mnLevel) &&
159 (mbCustomHeight == rModel.mbCustomHeight) &&
160 (mbHidden == rModel.mbHidden) &&
161 (mbCollapsed == rModel.mbCollapsed);
162}
163
165 : mnColRow(0)
166 , mnMin(0)
167 , mnMax(0)
168 , mbManual(false)
169{
170}
171
173{
174}
175
177 mnType( XML_none ),
178 mnOperator( XML_between ),
179 mnErrorStyle( XML_stop ),
180 mbShowInputMsg( false ),
181 mbShowErrorMsg( false ),
182 mbNoDropDown( false ),
183 mbAllowBlank( false )
184{
185}
186
188{
189 static const sal_Int32 spnTypeIds[] = {
190 XML_none, XML_whole, XML_decimal, XML_list, XML_date, XML_time, XML_textLength, XML_custom };
191 mnType = STATIC_ARRAY_SELECT( spnTypeIds, nType, XML_none );
192}
193
195{
196 static const sal_Int32 spnOperators[] = {
197 XML_between, XML_notBetween, XML_equal, XML_notEqual,
198 XML_greaterThan, XML_lessThan, XML_greaterThanOrEqual, XML_lessThanOrEqual };
199 mnOperator = STATIC_ARRAY_SELECT( spnOperators, nOperator, XML_TOKEN_INVALID );
200}
201
203{
204 static const sal_Int32 spnErrorStyles[] = { XML_stop, XML_warning, XML_information };
205 mnErrorStyle = STATIC_ARRAY_SELECT( spnErrorStyles, nErrorStyle, XML_stop );
206}
207
209{
210public:
211 explicit WorksheetGlobals(
212 const WorkbookHelper& rHelper,
213 ISegmentProgressBarRef xProgressBar,
214 WorksheetType eSheetType,
215 SCTAB nSheet );
216
218 bool isValidSheet() const { return mxSheet.is(); }
219
225 const Reference< XSpreadsheet >& getSheet() const { return mxSheet; }
226
228 Reference< XCell > getCell( const ScAddress& rAddress ) const;
230 Reference< XCellRange > getCellRange( const ScRange& rRange ) const;
232 Reference< XSheetCellRanges > getCellRangeList( const ScRangeList& rRanges ) const;
233
235 Reference< XCellRange > getColumn( sal_Int32 nCol ) const;
237 Reference< XCellRange > getRow( sal_Int32 nRow ) const;
238
240 Reference< XDrawPage > getDrawPage() const;
242 const awt::Size& getDrawPageSize() const;
243
245 awt::Point getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const;
246
248 ScAddress getCellAddressFromPosition( const awt::Point& rPosition ) const;
250 ScRange getCellRangeFromRectangle( const awt::Rectangle& rRect ) const;
251
271 ExtLst& getExtLst() { return maExtLst; }
272
274 void setPageBreak( const PageBreakModel& rModel, bool bRowBreak );
276 void setHyperlink( const HyperlinkModel& rModel );
278 void setValidation( const ValidationModel& rModel );
280 void setDrawingPath( const OUString& rDrawingPath );
282 void setVmlDrawingPath( const OUString& rVmlDrawingPath );
283
285 void extendUsedArea( const ScAddress& rAddress );
286
288 void extendUsedArea( const ScRange& rRange );
290 void extendShapeBoundingBox( const awt::Rectangle& rShapeRect );
291
294 void setBaseColumnWidth( sal_Int32 nWidth );
297 void setDefaultColumnWidth( double fWidth );
301 void setColumnModel( const ColumnModel& rModel );
303 void convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId );
304
306 void setDefaultRowSettings( double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom );
310 void setRowModel( const RowModel& rModel );
311
316
318
321 {
322 return mxRowProgress;
323 }
324 virtual void setCustomRowProgress( const ISegmentProgressBarRef &rxRowProgress ) override
325 {
326 mxRowProgress = rxRowProgress;
327 mbFastRowProgress = true;
328 }
329
330private:
331 typedef ::std::vector< sal_Int32 > OutlineLevelVec;
332 typedef ::std::pair< ColumnModel, sal_Int32 > ColumnModelRange;
333 typedef ::std::map< sal_Int32, ColumnModelRange > ColumnModelRangeMap;
334 typedef ::std::pair< RowModel, sal_Int32 > RowModelRange;
335 typedef ::std::map< sal_Int32, RowModelRange > RowModelRangeMap;
336
340 OUString getHyperlinkUrl( const HyperlinkModel& rHyperlink ) const;
342 void insertHyperlink( const ScAddress& rAddress, const OUString& rUrl );
343
345 void finalizeValidationRanges() const;
346
348 void convertColumns();
350 void convertColumns( OutlineLevelVec& orColLevels, const ValueRange& rColRange, const ColumnModel& rModel );
351
353 void convertRows(const std::vector<sc::ColRowSpan>& rSpans);
355 void convertRows(OutlineLevelVec& orRowLevels, const ValueRange& rRowRange,
356 const RowModel& rModel,
357 const std::vector<sc::ColRowSpan>& rSpans,
358 double fDefHeight = -1.0);
359
361 void convertOutlines( OutlineLevelVec& orLevels, sal_Int32 nColRow, sal_Int32 nLevel, bool bCollapsed, bool bRows );
363 void groupColumnsOrRows( sal_Int32 nFirstColRow, sal_Int32 nLastColRow, bool bCollapsed, bool bRows );
364
366 void finalizeDrawings();
367
369 void UpdateRowProgress( const ScRange& rUsedArea, SCROW nRow );
370
371private:
372 typedef ::std::unique_ptr< VmlDrawing > VmlDrawingPtr;
373
380 std::vector< HyperlinkModel > maHyperlinks;
381 std::vector< ValidationModel > maValidations;
392 OUString maDrawingPath;
394 awt::Size maDrawPageSize;
395 awt::Rectangle maShapeBoundingBox;
401 Reference< XSpreadsheet > mxSheet;
403};
404
405constexpr OUStringLiteral gaSheetCellRanges( u"com.sun.star.sheet.SheetCellRanges" );
406
408 WorkbookHelper( rHelper ),
409 mrMaxApiPos( rHelper.getAddressConverter().getMaxApiAddress() ),
410 maUsedArea( SCCOL_MAX, SCROW_MAX, nSheet, -1, -1, nSheet ), // Set start address to largest possible value, and end address to smallest
411 maSheetData( *this ),
412 maCondFormats( *this ),
413 maComments( *this ),
414 maAutoFilters( *this ),
415 maQueryTables( *this ),
416 maSheetSett( *this ),
417 maPageSett( *this ),
418 maSheetViewSett( *this ),
419 mxProgressBar(std::move( xProgressBar )),
420 mbFastRowProgress( false ),
421 meSheetType( eSheetType ),
422 mxSheet(getSheetFromDoc( nSheet )),
423 mbHasDefWidth( false )
424{
425 if( !mxSheet.is() )
427
428 // default column settings (width and hidden state may be updated later)
432 maDefColModel.mbHidden = false;
434
435 // default row settings (height and hidden state may be updated later)
442 maDefRowModel.mbHidden = false;
444
445 // buffers
446 mxVmlDrawing.reset( new VmlDrawing( *this ) );
447
448 // prepare progress bars
449 if( mxProgressBar )
450 {
451 mxRowProgress = mxProgressBar->createSegment( 0.5 );
452 mxFinalProgress = mxProgressBar->createSegment( 0.5 );
453 }
454}
455
456Reference< XCell > WorksheetGlobals::getCell( const ScAddress& rAddress ) const
457{
458 Reference< XCell > xCell;
459 if( mxSheet.is() ) try
460 {
461 xCell = mxSheet->getCellByPosition( rAddress.Col(), rAddress.Row() );
462 }
463 catch( Exception& )
464 {
465 }
466 return xCell;
467}
468
469Reference< XCellRange > WorksheetGlobals::getCellRange( const ScRange& rRange ) const
470{
471 Reference< XCellRange > xRange;
472 if( mxSheet.is() ) try
473 {
474 xRange = mxSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
475 }
476 catch( Exception& )
477 {
478 }
479 return xRange;
480}
481
482Reference< XSheetCellRanges > WorksheetGlobals::getCellRangeList( const ScRangeList& rRanges ) const
483{
484 Reference< XSheetCellRanges > xRanges;
485 if( mxSheet.is() && !rRanges.empty() ) try
486 {
487 xRanges.set( getBaseFilter().getModelFactory()->createInstance( gaSheetCellRanges ), UNO_QUERY_THROW );
488 Reference< XSheetCellRangeContainer > xRangeCont( xRanges, UNO_QUERY_THROW );
489 xRangeCont->addRangeAddresses( AddressConverter::toApiSequence(rRanges), false );
490 }
491 catch( Exception& )
492 {
493 }
494 return xRanges;
495}
496
497Reference< XCellRange > WorksheetGlobals::getColumn( sal_Int32 nCol ) const
498{
499 Reference< XCellRange > xColumn;
500 try
501 {
502 Reference< XColumnRowRange > xColRowRange( mxSheet, UNO_QUERY_THROW );
503 Reference< XTableColumns > xColumns( xColRowRange->getColumns(), UNO_SET_THROW );
504 xColumn.set( xColumns->getByIndex( nCol ), UNO_QUERY );
505 }
506 catch( Exception& )
507 {
508 }
509 return xColumn;
510}
511
512Reference< XCellRange > WorksheetGlobals::getRow( sal_Int32 nRow ) const
513{
514 Reference< XCellRange > xRow;
515 try
516 {
517 Reference< XColumnRowRange > xColRowRange( mxSheet, UNO_QUERY_THROW );
518 Reference< XTableRows > xRows( xColRowRange->getRows(), UNO_SET_THROW );
519 xRow.set( xRows->getByIndex( nRow ), UNO_QUERY );
520 }
521 catch( Exception& )
522 {
523 }
524 return xRow;
525}
526
527Reference< XDrawPage > WorksheetGlobals::getDrawPage() const
528{
529 Reference< XDrawPage > xDrawPage;
530 try
531 {
532 xDrawPage = Reference< XDrawPageSupplier >( mxSheet, UNO_QUERY_THROW )->getDrawPage();
533 }
534 catch( Exception& )
535 {
536 }
537 return xDrawPage;
538}
539
540const awt::Size& WorksheetGlobals::getDrawPageSize() const
541{
542 OSL_ENSURE( (maDrawPageSize.Width > 0) && (maDrawPageSize.Height > 0), "WorksheetGlobals::getDrawPageSize - called too early, size invalid" );
543 return maDrawPageSize;
544}
545
546awt::Point WorksheetGlobals::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const
547{
548 const tools::Rectangle aMMRect( getScDocument().GetMMRect( nCol, nRow, nCol, nRow, getSheetIndex() ) );
549 awt::Point aPoint( lclClampToNonNegativeInt32( aMMRect.Left() ),
550 lclClampToNonNegativeInt32( aMMRect.Top() ) );
551 return aPoint;
552}
553
554namespace {
555
556sal_Int32 lclGetMidAddr( sal_Int32 nBegAddr, sal_Int32 nEndAddr, sal_Int32 nBegPos, sal_Int32 nEndPos, sal_Int32 nSearchPos )
557{
558 // use sal_Int64 to prevent integer overflow
559 return nBegAddr + 1 + static_cast< sal_Int32 >( static_cast< sal_Int64 >( nEndAddr - nBegAddr - 2 ) * (nSearchPos - nBegPos) / (nEndPos - nBegPos) );
560}
561
562bool lclPrepareInterval( sal_Int32 nBegAddr, sal_Int32& rnMidAddr, sal_Int32 nEndAddr,
563 sal_Int32 nBegPos, sal_Int32 nEndPos, sal_Int32 nSearchPos )
564{
565 // searched position before nBegPos -> use nBegAddr
566 if( nSearchPos <= nBegPos )
567 {
568 rnMidAddr = nBegAddr;
569 return false;
570 }
571
572 // searched position after nEndPos, or begin next to end -> use nEndAddr
573 if( (nSearchPos >= nEndPos) || (nBegAddr + 1 >= nEndAddr) )
574 {
575 rnMidAddr = nEndAddr;
576 return false;
577 }
578
579 /* Otherwise find mid address according to position. lclGetMidAddr() will
580 return an address between nBegAddr and nEndAddr. */
581 rnMidAddr = lclGetMidAddr( nBegAddr, nEndAddr, nBegPos, nEndPos, nSearchPos );
582 return true;
583}
584
585bool lclUpdateInterval( sal_Int32& rnBegAddr, sal_Int32& rnMidAddr, sal_Int32& rnEndAddr,
586 sal_Int32& rnBegPos, sal_Int32 nMidPos, sal_Int32& rnEndPos, sal_Int32 nSearchPos )
587{
588 // nSearchPos < nMidPos: use the interval [begin,mid] in the next iteration
589 if( nSearchPos < nMidPos )
590 {
591 // if rnBegAddr is next to rnMidAddr, the latter is the column/row in question
592 if( rnBegAddr + 1 >= rnMidAddr )
593 return false;
594 // otherwise, set interval end to mid
595 rnEndPos = nMidPos;
596 rnEndAddr = rnMidAddr;
597 rnMidAddr = lclGetMidAddr( rnBegAddr, rnEndAddr, rnBegPos, rnEndPos, nSearchPos );
598 return true;
599 }
600
601 // nSearchPos > nMidPos: use the interval [mid,end] in the next iteration
602 if( nSearchPos > nMidPos )
603 {
604 // if rnMidAddr is next to rnEndAddr, the latter is the column/row in question
605 if( rnMidAddr + 1 >= rnEndAddr )
606 {
607 rnMidAddr = rnEndAddr;
608 return false;
609 }
610 // otherwise, set interval start to mid
611 rnBegPos = nMidPos;
612 rnBegAddr = rnMidAddr;
613 rnMidAddr = lclGetMidAddr( rnBegAddr, rnEndAddr, rnBegPos, rnEndPos, nSearchPos );
614 return true;
615 }
616
617 // nSearchPos == nMidPos: rnMidAddr is the column/row in question, do not loop anymore
618 return false;
619}
620
621} // namespace
622
623ScAddress WorksheetGlobals::getCellAddressFromPosition( const awt::Point& rPosition ) const
624{
625 // starting cell address and its position in drawing layer (top-left edge)
626 sal_Int32 nBegCol = 0;
627 sal_Int32 nBegRow = 0;
628 awt::Point aBegPos( 0, 0 );
629
630 // end cell address and its position in drawing layer (bottom-right edge)
631 sal_Int32 nEndCol = mrMaxApiPos.Col() + 1;
632 sal_Int32 nEndRow = mrMaxApiPos.Row() + 1;
633 awt::Point aEndPos( maDrawPageSize.Width, maDrawPageSize.Height );
634
635 // starting point for interval search
636 sal_Int32 nMidCol, nMidRow;
637 bool bLoopCols = lclPrepareInterval( nBegCol, nMidCol, nEndCol, aBegPos.X, aEndPos.X, rPosition.X );
638 bool bLoopRows = lclPrepareInterval( nBegRow, nMidRow, nEndRow, aBegPos.Y, aEndPos.Y, rPosition.Y );
639 awt::Point aMidPos = getCellPosition( nMidCol, nMidRow );
640
641 /* The loop will find the column/row index of the cell right of/below
642 the cell containing the passed point, unless the point is located at
643 the top or left border of the containing cell. */
644 while( bLoopCols || bLoopRows )
645 {
646 bLoopCols = bLoopCols && lclUpdateInterval( nBegCol, nMidCol, nEndCol, aBegPos.X, aMidPos.X, aEndPos.X, rPosition.X );
647 bLoopRows = bLoopRows && lclUpdateInterval( nBegRow, nMidRow, nEndRow, aBegPos.Y, aMidPos.Y, aEndPos.Y, rPosition.Y );
648 aMidPos = getCellPosition( nMidCol, nMidRow );
649 }
650
651 /* The cell left of/above the current search position contains the passed
652 point, unless the point is located on the top/left border of the cell,
653 or the last column/row of the sheet has been reached. */
654 if( aMidPos.X > rPosition.X ) --nMidCol;
655 if( aMidPos.Y > rPosition.Y ) --nMidRow;
656 return ScAddress( nMidCol, nMidRow, getSheetIndex() );
657}
658
659ScRange WorksheetGlobals::getCellRangeFromRectangle( const awt::Rectangle& rRect ) const
660{
661 ScAddress aStartAddr = getCellAddressFromPosition( awt::Point( rRect.X, rRect.Y ) );
662 awt::Point aBotRight( rRect.X + rRect.Width, rRect.Y + rRect.Height );
663 ScAddress aEndAddr = getCellAddressFromPosition( aBotRight );
664 bool bMultiCols = aStartAddr.Col() < aEndAddr.Col();
665 bool bMultiRows = aStartAddr.Row() < aEndAddr.Row();
666 if( bMultiCols || bMultiRows )
667 {
668 /* Reduce end position of the cell range to previous column or row, if
669 the rectangle ends exactly between two columns or rows. */
670 awt::Point aEndPos = getCellPosition( aEndAddr.Col(), aEndAddr.Row() );
671 if( bMultiCols && (aBotRight.X <= aEndPos.X) )
672 aEndAddr.IncCol(-1);
673 if( bMultiRows && (aBotRight.Y <= aEndPos.Y) )
674 aEndAddr.IncRow(-1);
675 }
676 return ScRange( aStartAddr.Col(), aStartAddr.Row(), getSheetIndex(),
677 aEndAddr.Col(), aEndAddr.Row(), getSheetIndex() );
678}
679
680void WorksheetGlobals::setPageBreak( const PageBreakModel& rModel, bool bRowBreak )
681{
682 if( rModel.mbManual && (rModel.mnColRow > 0) )
683 {
684 PropertySet aPropSet( bRowBreak ? getRow( rModel.mnColRow ) : getColumn( rModel.mnColRow ) );
685 aPropSet.setProperty( PROP_IsStartOfNewPage, true );
686 }
687}
688
690{
691 maHyperlinks.push_back( rModel );
692}
693
695{
696 maValidations.push_back( rModel );
697}
698
699void WorksheetGlobals::setDrawingPath( const OUString& rDrawingPath )
700{
701 maDrawingPath = rDrawingPath;
702}
703
704void WorksheetGlobals::setVmlDrawingPath( const OUString& rVmlDrawingPath )
705{
706 maVmlDrawingPath = rVmlDrawingPath;
707}
708
710{
711 maUsedArea.aStart.SetCol( ::std::min( maUsedArea.aStart.Col(), rAddress.Col() ) );
712 maUsedArea.aStart.SetRow( ::std::min( maUsedArea.aStart.Row(), rAddress.Row() ) );
713 maUsedArea.aEnd.SetCol( ::std::max( maUsedArea.aEnd.Col(), rAddress.Col() ) );
714 maUsedArea.aEnd.SetRow( ::std::max( maUsedArea.aEnd.Row(), rAddress.Row() ) );
715}
716
718{
719 extendUsedArea( rRange.aStart );
720 extendUsedArea( rRange.aEnd );
721}
722
724{
725 extendUsedArea( rRange.aStart );
726 extendUsedArea( rRange.aEnd );
727}
728
729void WorksheetGlobals::extendShapeBoundingBox( const awt::Rectangle& rShapeRect )
730{
731 if( (maShapeBoundingBox.Width == 0) && (maShapeBoundingBox.Height == 0) )
732 {
733 // width and height of maShapeBoundingBox are assumed to be zero on first cell
734 maShapeBoundingBox = rShapeRect;
735 }
736 else
737 {
738 sal_Int32 nEndX = ::std::max( maShapeBoundingBox.X + maShapeBoundingBox.Width, rShapeRect.X + rShapeRect.Width );
739 sal_Int32 nEndY = ::std::max( maShapeBoundingBox.Y + maShapeBoundingBox.Height, rShapeRect.Y + rShapeRect.Height );
740 maShapeBoundingBox.X = ::std::min( maShapeBoundingBox.X, rShapeRect.X );
741 maShapeBoundingBox.Y = ::std::min( maShapeBoundingBox.Y, rShapeRect.Y );
742 maShapeBoundingBox.Width = nEndX - maShapeBoundingBox.X;
743 maShapeBoundingBox.Height = nEndY - maShapeBoundingBox.Y;
744 }
745}
746
748{
749 // do not modify width, if setDefaultColumnWidth() has been used
750 if( !mbHasDefWidth && (nWidth > 0) )
751 {
752 // #i3006# add 5 pixels padding to the width
754 }
755}
756
758{
759 // overrides a width set with setBaseColumnWidth()
760 if( fWidth > 0.0 )
761 {
762 maDefColModel.mfWidth = fWidth;
763 mbHasDefWidth = true;
764 }
765}
766
768{
769 // convert 1-based OOXML column indexes to 0-based API column indexes
770 sal_Int32 nFirstCol = rModel.maRange.mnFirst - 1;
771 sal_Int32 nLastCol = rModel.maRange.mnLast - 1;
772 if( !(getAddressConverter().checkCol( nFirstCol, true ) && (nFirstCol <= nLastCol)) )
773 return;
774
775 // Validate last column index.
776 // If last column is equal to last possible column, Excel adds one
777 // more. We do that also in XclExpColinfo::SaveXml() and for 1024 end
778 // up with 1025 instead, which would lead to excess columns in
779 // checkCol(). Cater for this oddity.
780 if (nLastCol == mrMaxApiPos.Col() + 1)
781 --nLastCol;
782 // This is totally fouled up. If we saved 1025 and the file is saved
783 // with Excel again, it increments the value to 1026.
784 else if (nLastCol == mrMaxApiPos.Col() + 2)
785 nLastCol -= 2;
786 // Excel may add a column range for the remaining columns (with
787 // <cols><col .../></cols>), even if not used or only used to grey out
788 // columns in page break view. Don't let that trigger overflow warning,
789 // so check for the last possible column. If there really is content in
790 // the range that should be caught anyway.
791 else if (nLastCol == getAddressConverter().getMaxXlsAddress().Col())
792 nLastCol = mrMaxApiPos.Col();
793 // User may have applied custom column widths to arbitrary excess
794 // columns. Ignore those and don't track as overflow columns (false).
795 // Effectively this does the same as the above cases, just keep them
796 // for explanation.
797 // Actual data present should trigger the overflow detection later.
798 else if( !getAddressConverter().checkCol( nLastCol, false ) )
799 nLastCol = mrMaxApiPos.Col();
800 // try to find entry in column model map that is able to merge with the passed model
801 bool bInsertModel = true;
802 if( !maColModels.empty() )
803 {
804 // find first column model range following nFirstCol (nFirstCol < aIt->first), or end of map
805 ColumnModelRangeMap::iterator aIt = maColModels.upper_bound( nFirstCol );
806 OSL_ENSURE( aIt == maColModels.end(), "WorksheetGlobals::setColModel - columns are unsorted" );
807 // if inserting before another column model, get last free column
808 OSL_ENSURE( (aIt == maColModels.end()) || (nLastCol < aIt->first), "WorksheetGlobals::setColModel - multiple models of the same column" );
809 if( aIt != maColModels.end() )
810 nLastCol = ::std::min( nLastCol, aIt->first - 1 );
811 if( aIt != maColModels.begin() )
812 {
813 // go to previous map element (which may be able to merge with the passed model)
814 --aIt;
815 // the usage of upper_bound() above ensures that aIt->first is less than or equal to nFirstCol now
816 sal_Int32& rnLastMapCol = aIt->second.second;
817 OSL_ENSURE( rnLastMapCol < nFirstCol, "WorksheetGlobals::setColModel - multiple models of the same column" );
818 nFirstCol = ::std::max( rnLastMapCol + 1, nFirstCol );
819 if( (rnLastMapCol + 1 == nFirstCol) && (nFirstCol <= nLastCol) && aIt->second.first.isMergeable( rModel ) )
820 {
821 // can merge with existing model, update last column index
822 rnLastMapCol = nLastCol;
823 bInsertModel = false;
824 }
825 }
826 }
827 if( nFirstCol <= nLastCol )
828 {
829 // insert the column model, if it has not been merged with another
830 if( bInsertModel )
831 maColModels[ nFirstCol ] = ColumnModelRange( rModel, nLastCol );
832 // set column formatting directly
833 convertColumnFormat( nFirstCol, nLastCol, rModel.mnXfId );
834 }
835}
836
837void WorksheetGlobals::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId )
838{
839 ScRange aRange( nFirstCol, 0, getSheetIndex(), nLastCol, mrMaxApiPos.Row(), getSheetIndex() );
840 if( getAddressConverter().validateCellRange( aRange, true, false ) )
841 {
842 const StylesBuffer& rStyles = getStyles();
843
844 // Set cell styles via direct API - the preferred approach.
846 rStyles.writeCellXfToDoc(rDoc, aRange, nXfId);
847 }
848}
849
850void WorksheetGlobals::setDefaultRowSettings( double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom )
851{
852 maDefRowModel.mfHeight = fHeight;
853 maDefRowModel.mbCustomHeight = bCustomHeight;
854 maDefRowModel.mbHidden = bHidden;
855 maDefRowModel.mbThickTop = bThickTop;
856 maDefRowModel.mbThickBottom = bThickBottom;
857}
858
860{
861 // convert 1-based OOXML row index to 0-based API row index
862 sal_Int32 nRow = rModel.mnRow - 1;
863 if( getAddressConverter().checkRow( nRow, true ) )
864 {
865 // try to find entry in row model map that is able to merge with the passed model
866 bool bInsertModel = true;
867 bool bUnusedRow = true;
868 if( !maRowModels.empty() )
869 {
870 // find first row model range following nRow (nRow < aIt->first), or end of map
871 RowModelRangeMap::iterator aIt = maRowModels.upper_bound( nRow );
872 OSL_ENSURE( aIt == maRowModels.end(), "WorksheetGlobals::setRowModel - rows are unsorted" );
873 if( aIt != maRowModels.begin() )
874 {
875 // go to previous map element (which may be able to merge with the passed model)
876 --aIt;
877 // the usage of upper_bound() above ensures that aIt->first is less than or equal to nRow now
878 sal_Int32& rnLastMapRow = aIt->second.second;
879 bUnusedRow = rnLastMapRow < nRow;
880 OSL_ENSURE( bUnusedRow, "WorksheetGlobals::setRowModel - multiple models of the same row" );
881 if( (rnLastMapRow + 1 == nRow) && aIt->second.first.isMergeable( rModel ) )
882 {
883 // can merge with existing model, update last row index
884 ++rnLastMapRow;
885 bInsertModel = false;
886 }
887 }
888 }
889 if( bUnusedRow )
890 {
891 // insert the row model, if it has not been merged with another
892 if( bInsertModel )
893 maRowModels[ nRow ] = RowModelRange( rModel, nRow );
894 // set row formatting
895 maSheetData.setRowFormat( nRow, rModel.mnXfId, rModel.mbCustomFormat );
896 }
897 }
898
900}
901
902// This is called at a higher frequency inside the (threaded) inner loop.
904{
905 if (!mxRowProgress || nRow < rUsedArea.aStart.Row() || rUsedArea.aEnd.Row() < nRow)
906 return;
907
908 double fNewPos = static_cast<double>(nRow - rUsedArea.aStart.Row() + 1.0) / (rUsedArea.aEnd.Row() - rUsedArea.aStart.Row() + 1.0);
909
911 mxRowProgress->setPosition(fNewPos);
912 else
913 {
914 double fCurPos = mxRowProgress->getPosition();
915 if (fCurPos < fNewPos && (fNewPos - fCurPos) > 0.3)
916 // Try not to re-draw progress bar too frequently.
917 mxRowProgress->setPosition(fNewPos);
918 }
919}
920
922{
923 // set default cell style for unused cells
925
926 ScStyleSheet* pStyleSheet =
927 static_cast<ScStyleSheet*>(rDoc.getDoc().GetStyleSheetPool()->Find(
928 getStyles().getDefaultStyleName(), SfxStyleFamily::Para));
929
930 if (pStyleSheet)
931 rDoc.setCellStyleToSheet(getSheetIndex(), *pStyleSheet);
932
933 /* Remember the current sheet index in global data, needed by global
934 objects, e.g. the chart converter. */
936}
937
939{
940 lclUpdateProgressBar( mxRowProgress, 1.0 );
942
944 lclUpdateProgressBar( mxFinalProgress, 0.25 );
952
953 lclUpdateProgressBar( mxFinalProgress, 0.5 );
955
956 // tdf#99913 rows hidden by filter need extra flag
957 ScDocument& rDoc = getScDocument();
958 std::vector<sc::ColRowSpan> aSpans;
959 SCTAB nTab = getSheetIndex();
960
961 ScTable* pTable = rDoc.FetchTable(nTab);
962 if (pTable)
963 pTable->SetOptimalMinRowHeight(maDefRowModel.mfHeight * 20); // in TWIPS
964
965 ScDBData* pDBData = rDoc.GetAnonymousDBData(nTab);
966 if (pDBData && pDBData->HasAutoFilter())
967 {
968 ScRange aRange;
969 pDBData->GetArea(aRange);
970 SCCOLROW nStartRow = static_cast<SCCOLROW>(aRange.aStart.Row());
971 SCCOLROW nEndRow = static_cast<SCCOLROW>(aRange.aEnd.Row());
972 aSpans.push_back(sc::ColRowSpan(nStartRow, nEndRow));
973 }
974 ScDBCollection* pDocColl = rDoc.GetDBCollection();
975 if (!pDocColl->empty())
976 {
977 ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
978 for (const auto& rxDB : rDBs)
979 {
980 if (rxDB->GetTab() == nTab && rxDB->HasAutoFilter())
981 {
982 ScRange aRange;
983 rxDB->GetArea(aRange);
984 SCCOLROW nStartRow = static_cast<SCCOLROW>(aRange.aStart.Row());
985 SCCOLROW nEndRow = static_cast<SCCOLROW>(aRange.aEnd.Row());
986 aSpans.push_back(sc::ColRowSpan(nStartRow, nEndRow));
987 }
988 }
989 }
990 convertRows(aSpans);
991 lclUpdateProgressBar( mxFinalProgress, 1.0 );
992}
993
995{
997
998 // forget current sheet index in global data
1000}
1001
1002// private --------------------------------------------------------------------
1003
1005{
1006 for (auto const& link : maHyperlinks)
1007 {
1008 OUString aUrl = getHyperlinkUrl(link);
1009 // try to insert URL into each cell of the range
1010 if( !aUrl.isEmpty() )
1011 for( ScAddress aAddress(link.maRange.aStart.Col(), link.maRange.aStart.Row(), getSheetIndex() ); aAddress.Row() <= link.maRange.aEnd.Row(); aAddress.IncRow() )
1012 for( aAddress.SetCol(link.maRange.aStart.Col()); aAddress.Col() <= link.maRange.aEnd.Col(); aAddress.IncCol() )
1013 insertHyperlink( aAddress, aUrl );
1014 }
1015}
1016
1017OUString WorksheetGlobals::getHyperlinkUrl( const HyperlinkModel& rHyperlink ) const
1018{
1019 OUStringBuffer aUrlBuffer;
1020 if( !rHyperlink.maTarget.isEmpty() )
1021 aUrlBuffer.append( getBaseFilter().getAbsoluteUrl( rHyperlink.maTarget ) );
1022 if( !rHyperlink.maLocation.isEmpty() )
1023 aUrlBuffer.append( "#" + rHyperlink.maLocation );
1024 OUString aUrl = aUrlBuffer.makeStringAndClear();
1025
1026 if( aUrl.startsWith("#") )
1027 {
1028 sal_Int32 nSepPos = aUrl.lastIndexOf( '!' );
1029 if( nSepPos > 0 )
1030 {
1031 // Do not attempt to blindly convert '#SheetName!A1' to
1032 // '#SheetName.A1', it can be #SheetName!R1C1 as well. Hyperlink
1033 // handler has to handle all, but prefer '#SheetName.A1' if
1034 // possible.
1035 if (nSepPos < aUrl.getLength() - 1)
1036 {
1037 ScRange aRange;
1038 const ScDocumentImport& rDoc = getDocImport();
1039 if ((aRange.ParseAny( aUrl.copy( nSepPos + 1 ), rDoc.getDoc(),
1042 aUrl = aUrl.replaceAt( nSepPos, 1, rtl::OUStringChar( '.' ) );
1043 }
1044 // #i66592# convert sheet names that have been renamed on import
1045 OUString aSheetName = aUrl.copy( 1, nSepPos - 1 );
1046 OUString aCalcName = getWorksheets().getCalcSheetName( aSheetName );
1047 if( !aCalcName.isEmpty() )
1048 aUrl = aUrl.replaceAt( 1, nSepPos - 1, aCalcName );
1049 }
1050 }
1051
1052 return aUrl;
1053}
1054
1055void WorksheetGlobals::insertHyperlink( const ScAddress& rAddress, const OUString& rUrl )
1056{
1058 ScRefCellValue aCell(rDoc.getDoc(), rAddress);
1059
1060 if (aCell.getType() == CELLTYPE_STRING || aCell.getType() == CELLTYPE_EDIT)
1061 {
1062 OUString aStr = aCell.getString(&rDoc.getDoc());
1063 ScFieldEditEngine& rEE = rDoc.getDoc().GetEditEngine();
1064 rEE.Clear();
1065
1066 SvxURLField aURLField(rUrl, aStr, SvxURLFormat::Repr);
1067 SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD);
1068 rEE.QuickInsertField(aURLItem, ESelection());
1069
1070 rDoc.setEditCell(rAddress, rEE.CreateTextObject());
1071 }
1072 else
1073 {
1074 // Handle other cell types e.g. formulas ( and ? ) that have associated
1075 // hyperlinks.
1076 // Ideally all hyperlinks should be treated as below. For the moment,
1077 // given the current absence of ods support lets just handle what we
1078 // previously didn't handle the new way.
1079 // Unfortunately we won't be able to preserve such hyperlinks when
1080 // saving to ods. Note: when we are able to save such hyperlinks to ods
1081 // we should handle *all* imported hyperlinks as below ( e.g. as cell
1082 // attribute ) for better interoperability.
1083
1084 SfxStringItem aItem(ATTR_HYPERLINK, rUrl);
1085 rDoc.getDoc().ApplyAttr(rAddress.Col(), rAddress.Row(), rAddress.Tab(), aItem);
1086 }
1087}
1088
1090{
1091 for (auto const& validation : maValidations)
1092 {
1093 PropertySet aPropSet( getCellRangeList(validation.maRanges) );
1094
1095 Reference< XPropertySet > xValidation( aPropSet.getAnyProperty( PROP_Validation ), UNO_QUERY );
1096 if( xValidation.is() )
1097 {
1098 PropertySet aValProps( xValidation );
1099
1100 try
1101 {
1102 const OUString aToken = validation.msRef.getToken( 0, ' ' );
1103
1104 Reference<XSpreadsheet> xSheet = getSheetFromDoc( getCurrentSheetIndex() );
1105 Reference<XCellRange> xDBCellRange;
1106 Reference<XCell> xCell;
1107 xDBCellRange = xSheet->getCellRangeByName( aToken );
1108
1109 xCell = xDBCellRange->getCellByPosition( 0, 0 );
1110 Reference<XCellAddressable> xCellAddressable( xCell, UNO_QUERY_THROW );
1111 CellAddress aFirstCell = xCellAddressable->getCellAddress();
1112 Reference<XSheetCondition> xCondition( xValidation, UNO_QUERY_THROW );
1113 xCondition->setSourcePosition( aFirstCell );
1114 }
1115 catch(const Exception&)
1116 {
1117 }
1118
1119 // convert validation type to API enum
1120 ValidationType eType = ValidationType_ANY;
1121 switch( validation.mnType )
1122 {
1123 case XML_custom: eType = ValidationType_CUSTOM; break;
1124 case XML_date: eType = ValidationType_DATE; break;
1125 case XML_decimal: eType = ValidationType_DECIMAL; break;
1126 case XML_list: eType = ValidationType_LIST; break;
1127 case XML_none: eType = ValidationType_ANY; break;
1128 case XML_textLength: eType = ValidationType_TEXT_LEN; break;
1129 case XML_time: eType = ValidationType_TIME; break;
1130 case XML_whole: eType = ValidationType_WHOLE; break;
1131 default: OSL_FAIL( "WorksheetData::finalizeValidationRanges - unknown validation type" );
1132 }
1133 aValProps.setProperty( PROP_Type, eType );
1134
1135 // convert error alert style to API enum
1136 ValidationAlertStyle eAlertStyle = ValidationAlertStyle_STOP;
1137 switch( validation.mnErrorStyle )
1138 {
1139 case XML_information: eAlertStyle = ValidationAlertStyle_INFO; break;
1140 case XML_stop: eAlertStyle = ValidationAlertStyle_STOP; break;
1141 case XML_warning: eAlertStyle = ValidationAlertStyle_WARNING; break;
1142 default: OSL_FAIL( "WorksheetData::finalizeValidationRanges - unknown error style" );
1143 }
1144 aValProps.setProperty( PROP_ErrorAlertStyle, eAlertStyle );
1145
1146 // convert dropdown style to API visibility constants
1147 sal_Int16 nVisibility = validation.mbNoDropDown ? TableValidationVisibility::INVISIBLE : TableValidationVisibility::UNSORTED;
1148 aValProps.setProperty( PROP_ShowList, nVisibility );
1149
1150 // messages
1151 aValProps.setProperty( PROP_ShowInputMessage, validation.mbShowInputMsg );
1152 aValProps.setProperty( PROP_InputTitle, validation.maInputTitle );
1153 aValProps.setProperty( PROP_InputMessage, validation.maInputMessage );
1154 aValProps.setProperty( PROP_ShowErrorMessage, validation.mbShowErrorMsg );
1155 aValProps.setProperty( PROP_ErrorTitle, validation.maErrorTitle );
1156 aValProps.setProperty( PROP_ErrorMessage, validation.maErrorMessage );
1157
1158 // allow blank cells
1159 aValProps.setProperty( PROP_IgnoreBlankCells, validation.mbAllowBlank );
1160
1161 try
1162 {
1163 // condition operator
1164 Reference< XSheetCondition2 > xSheetCond( xValidation, UNO_QUERY_THROW );
1165 if( eType == ValidationType_CUSTOM )
1166 xSheetCond->setConditionOperator( ConditionOperator2::FORMULA );
1167 else
1168 xSheetCond->setConditionOperator( CondFormatBuffer::convertToApiOperator( validation.mnOperator ) );
1169
1170 // condition formulas
1171 Reference< XMultiFormulaTokens > xTokens( xValidation, UNO_QUERY_THROW );
1172 xTokens->setTokens( 0, validation.maTokens1 );
1173 xTokens->setTokens( 1, validation.maTokens2 );
1174 }
1175 catch( Exception& )
1176 {
1177 }
1178
1179 // write back validation settings to cell range(s)
1180 aPropSet.setProperty( PROP_Validation, xValidation );
1181 }
1182 }
1183}
1184
1186{
1187 sal_Int32 nNextCol = 0;
1188 sal_Int32 nMaxCol = mrMaxApiPos.Col();
1189 // stores first grouped column index for each level
1190 OutlineLevelVec aColLevels;
1191
1192 for (auto const& colModel : maColModels)
1193 {
1194 // column indexes are stored 0-based in maColModels
1195 ValueRange aColRange( ::std::max( colModel.first, nNextCol ), ::std::min( colModel.second.second, nMaxCol ) );
1196 // process gap between two column models, use default column model
1197 if( nNextCol < aColRange.mnFirst )
1198 convertColumns( aColLevels, ValueRange( nNextCol, aColRange.mnFirst - 1 ), maDefColModel );
1199 // process the column model
1200 convertColumns( aColLevels, aColRange, colModel.second.first );
1201 // cache next column to be processed
1202 nNextCol = aColRange.mnLast + 1;
1203 }
1204
1205 // remaining default columns to end of sheet
1206 convertColumns( aColLevels, ValueRange( nNextCol, nMaxCol ), maDefColModel );
1207 // close remaining column outlines spanning to end of sheet
1208 convertOutlines( aColLevels, nMaxCol + 1, 0, false, false );
1209}
1210
1212 const ValueRange& rColRange, const ColumnModel& rModel )
1213{
1214 // column width: convert 'number of characters' to column width in twips
1215 sal_Int32 nWidth = std::round(getUnitConverter().scaleValue( rModel.mfWidth, Unit::Digit, Unit::Twip ));
1216
1217 SCTAB nTab = getSheetIndex();
1218 ScDocument& rDoc = getScDocument();
1219 SCCOL nStartCol = rColRange.mnFirst;
1220 SCCOL nEndCol = rColRange.mnLast;
1221
1222 if( nWidth > 0 )
1223 {
1224 // macro sheets have double width
1226 nWidth *= 2;
1227
1228 for( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
1229 {
1230 rDoc.SetColWidthOnly(nCol, nTab, nWidth);
1231 }
1232 }
1233
1234 // hidden columns: TODO: #108683# hide columns later?
1235 if( rModel.mbHidden )
1236 {
1237 rDoc.SetColHidden( nStartCol, nEndCol, nTab, true );
1238 }
1239
1240 // outline settings for this column range
1241 convertOutlines( orColLevels, rColRange.mnFirst, rModel.mnLevel, rModel.mbCollapsed, false );
1242}
1243
1244void WorksheetGlobals::convertRows(const std::vector<sc::ColRowSpan>& rSpans)
1245{
1246 sal_Int32 nNextRow = 0;
1247 sal_Int32 nMaxRow = mrMaxApiPos.Row();
1248 // stores first grouped row index for each level
1249 OutlineLevelVec aRowLevels;
1250
1251 for (auto const& rowModel : maRowModels)
1252 {
1253 // row indexes are stored 0-based in maRowModels
1254 ValueRange aRowRange( ::std::max( rowModel.first, nNextRow ), ::std::min( rowModel.second.second, nMaxRow ) );
1255 // process gap between two row models, use default row model
1256 if( nNextRow < aRowRange.mnFirst )
1257 convertRows(aRowLevels, ValueRange(nNextRow, aRowRange.mnFirst - 1), maDefRowModel,
1258 rSpans);
1259 // process the row model
1260 convertRows(aRowLevels, aRowRange, rowModel.second.first, rSpans, maDefRowModel.mfHeight);
1261 // cache next row to be processed
1262 nNextRow = aRowRange.mnLast + 1;
1263 }
1264
1265 // remaining default rows to end of sheet
1266 convertRows(aRowLevels, ValueRange(nNextRow, nMaxRow), maDefRowModel, rSpans);
1267 // close remaining row outlines spanning to end of sheet
1268 convertOutlines( aRowLevels, nMaxRow + 1, 0, false, true );
1269}
1270
1272 const RowModel& rModel,
1273 const std::vector<sc::ColRowSpan>& rSpans, double fDefHeight)
1274{
1275 // row height: convert points to row height in twips
1276 double fHeight = (rModel.mfHeight >= 0.0) ? rModel.mfHeight : fDefHeight;
1277 sal_Int32 nHeight = std::round(o3tl::toTwips( fHeight, o3tl::Length::pt ));
1278 SCROW nStartRow = rRowRange.mnFirst;
1279 SCROW nEndRow = rRowRange.mnLast;
1280 SCTAB nTab = getSheetIndex();
1281 if( nHeight > 0 )
1282 {
1283 /* always import the row height, ensures better layout */
1284 ScDocument& rDoc = getScDocument();
1285 rDoc.SetRowHeightOnly(nStartRow, nEndRow, nTab, nHeight);
1286 if(rModel.mbCustomHeight)
1287 rDoc.SetManualHeight( nStartRow, nEndRow, nTab, true );
1288 }
1289
1290 // hidden rows: TODO: #108683# hide rows later?
1291 if( rModel.mbHidden )
1292 {
1293 ScDocument& rDoc = getScDocument();
1294 rDoc.SetRowHidden( nStartRow, nEndRow, nTab, true );
1295 for (const auto& rSpan : rSpans)
1296 {
1297 // tdf#99913 rows hidden by filter need extra flag
1298 if (rSpan.mnStart <= nStartRow && nStartRow <= rSpan.mnEnd)
1299 {
1300 SCROW nLast = ::std::min(nEndRow, rSpan.mnEnd);
1301 rDoc.SetRowFiltered(nStartRow, nLast, nTab, true);
1302 break;
1303 }
1304 }
1305 }
1306
1307 // outline settings for this row range
1308 convertOutlines( orRowLevels, rRowRange.mnFirst, rModel.mnLevel, rModel.mbCollapsed, true );
1309}
1310
1312 sal_Int32 nColRow, sal_Int32 nLevel, bool bCollapsed, bool bRows )
1313{
1314 /* It is ensured from caller functions, that this function is called
1315 without any gaps between the processed column or row ranges. */
1316
1317 OSL_ENSURE( nLevel >= 0, "WorksheetGlobals::convertOutlines - negative outline level" );
1318 nLevel = ::std::max< sal_Int32 >( nLevel, 0 );
1319
1320 sal_Int32 nSize = orLevels.size();
1321 if( nSize < nLevel )
1322 {
1323 // Outline level increased. Push the begin column position.
1324 orLevels.insert(orLevels.end(), nLevel - nSize, nColRow);
1325 }
1326 else if( nLevel < nSize )
1327 {
1328 // Outline level decreased. Pop them all out.
1329 for( sal_Int32 nIndex = nLevel; nIndex < nSize; ++nIndex )
1330 {
1331 sal_Int32 nFirstInLevel = orLevels.back();
1332 orLevels.pop_back();
1333 groupColumnsOrRows( nFirstInLevel, nColRow - 1, bCollapsed, bRows );
1334 bCollapsed = false; // collapse only once
1335 }
1336 }
1337}
1338
1339void WorksheetGlobals::groupColumnsOrRows( sal_Int32 nFirstColRow, sal_Int32 nLastColRow, bool bCollapse, bool bRows )
1340{
1341 try
1342 {
1343 Reference< XSheetOutline > xOutline( mxSheet, UNO_QUERY_THROW );
1344 if( bRows )
1345 {
1346 CellRangeAddress aRange( getSheetIndex(), 0, nFirstColRow, 0, nLastColRow );
1347 xOutline->group( aRange, TableOrientation_ROWS );
1348 if( bCollapse )
1349 xOutline->hideDetail( aRange );
1350 }
1351 else
1352 {
1353 CellRangeAddress aRange( getSheetIndex(), nFirstColRow, 0, nLastColRow, 0 );
1354 xOutline->group( aRange, TableOrientation_COLUMNS );
1355 if( bCollapse )
1356 xOutline->hideDetail( aRange );
1357 }
1358 }
1359 catch( Exception& )
1360 {
1361 }
1362}
1363
1365{
1366 // calculate the current drawing page size (after rows/columns are imported)
1367 const Size aPageSize( getScDocument().GetMMRect( 0, 0, mrMaxApiPos.Col(), mrMaxApiPos.Row(), getSheetIndex() ).GetSize() );
1368 maDrawPageSize.Width = lclClampToNonNegativeInt32( aPageSize.Width() );
1369 maDrawPageSize.Height = lclClampToNonNegativeInt32( aPageSize.Height() );
1370
1371 // import DML and VML
1372 if( !maDrawingPath.isEmpty() )
1374 if( !maVmlDrawingPath.isEmpty() )
1376
1377 // comments (after callout shapes have been imported from VML/DFF)
1379
1380 /* Extend used area of the sheet by cells covered with drawing objects.
1381 Needed if the imported document is inserted as "OLE object from file"
1382 and thus does not provide an OLE size property by itself. */
1383 if( (maShapeBoundingBox.Width > 0) || (maShapeBoundingBox.Height > 0) )
1384 {
1386 if (aRange.aStart.Col() < 0)
1387 aRange.aStart.SetCol(0);
1388 if (aRange.aStart.Row() < 0)
1389 aRange.aStart.SetRow(0);
1390 if (aRange.aEnd.Col() < 0)
1391 aRange.aEnd.SetCol(0);
1392 if (aRange.aEnd.Row() < 0)
1393 aRange.aEnd.SetRow(0);
1394 extendUsedArea(aRange);
1395 }
1396
1397 // if no used area is set, default to A1
1399 {
1401 maUsedArea.aEnd.SetCol( 0 );
1402 }
1403
1405 {
1407 maUsedArea.aEnd.SetRow( 0 );
1408 }
1409
1410 /* Register the used area of this sheet in global view settings. The
1411 global view settings will set the visible area if this document is an
1412 embedded OLE object. */
1414
1415 /* #i103686# Set right-to-left sheet layout. Must be done after all
1416 drawing shapes to simplify calculation of shape coordinates. */
1418 {
1419 PropertySet aPropSet( mxSheet );
1420 aPropSet.setProperty( PROP_TableLayout, WritingMode2::RL_TB );
1421 }
1422}
1423
1425 WorkbookHelper( rSheetGlob ),
1426 mrSheetGlob( rSheetGlob )
1427{
1428}
1429
1431{
1432 return getDocImport().getDoc();
1433}
1434
1436 const ISegmentProgressBarRef& rxProgressBar, WorksheetType eSheetType, SCTAB nSheet )
1437{
1438 WorksheetGlobalsRef xSheetGlob = std::make_shared<WorksheetGlobals>( rHelper, rxProgressBar, eSheetType, nSheet );
1439 if( !xSheetGlob->isValidSheet() )
1440 xSheetGlob.reset();
1441 return xSheetGlob;
1442}
1443
1445{
1446 return static_cast< IWorksheetProgress *>( xRef.get() );
1447}
1448
1450{
1451 return mrSheetGlob.getSheetType();
1452}
1453
1455{
1456 return mrSheetGlob.getSheetIndex();
1457}
1458
1459const Reference< XSpreadsheet >& WorksheetHelper::getSheet() const
1460{
1461 return mrSheetGlob.getSheet();
1462}
1463
1464Reference< XCell > WorksheetHelper::getCell( const ScAddress& rAddress ) const
1465{
1466 return mrSheetGlob.getCell( rAddress );
1467}
1468
1469Reference< XCellRange > WorksheetHelper::getCellRange( const ScRange& rRange ) const
1470{
1471 return mrSheetGlob.getCellRange( rRange );
1472}
1473
1474Reference< XDrawPage > WorksheetHelper::getDrawPage() const
1475{
1476 return mrSheetGlob.getDrawPage();
1477}
1478
1479awt::Point WorksheetHelper::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const
1480{
1481 return mrSheetGlob.getCellPosition( nCol, nRow );
1482}
1483
1484const awt::Size& WorksheetHelper::getDrawPageSize() const
1485{
1487}
1488
1490{
1491 return mrSheetGlob.getSheetData();
1492}
1493
1495{
1496 return mrSheetGlob.getCondFormats();
1497}
1498
1500{
1501 return mrSheetGlob.getComments();
1502}
1503
1505{
1506 return mrSheetGlob.getAutoFilters();
1507}
1508
1510{
1511 return mrSheetGlob.getQueryTables();
1512}
1513
1515{
1517}
1518
1520{
1522}
1523
1525{
1527}
1528
1530{
1531 return mrSheetGlob.getVmlDrawing();
1532}
1533
1535{
1536 return mrSheetGlob.getExtLst();
1537}
1538
1539void WorksheetHelper::setPageBreak( const PageBreakModel& rModel, bool bRowBreak )
1540{
1541 mrSheetGlob.setPageBreak( rModel, bRowBreak );
1542}
1543
1545{
1546 mrSheetGlob.setHyperlink( rModel );
1547}
1548
1550{
1551 mrSheetGlob.setValidation( rModel );
1552}
1553
1554void WorksheetHelper::setDrawingPath( const OUString& rDrawingPath )
1555{
1556 mrSheetGlob.setDrawingPath( rDrawingPath );
1557}
1558
1559void WorksheetHelper::setVmlDrawingPath( const OUString& rVmlDrawingPath )
1560{
1561 mrSheetGlob.setVmlDrawingPath( rVmlDrawingPath );
1562}
1563
1565{
1566 mrSheetGlob.extendUsedArea( rAddress );
1567}
1568
1569void WorksheetHelper::extendShapeBoundingBox( const awt::Rectangle& rShapeRect )
1570{
1571 mrSheetGlob.extendShapeBoundingBox( rShapeRect );
1572}
1573
1575{
1577}
1578
1580{
1582}
1583
1585{
1586 mrSheetGlob.setColumnModel( rModel );
1587}
1588
1589void WorksheetHelper::setDefaultRowSettings( double fHeight, bool bCustomHeight, bool bHidden, bool bThickTop, bool bThickBottom )
1590{
1591 mrSheetGlob.setDefaultRowSettings( fHeight, bCustomHeight, bHidden, bThickTop, bThickBottom );
1592}
1593
1595{
1596 mrSheetGlob.setRowModel( rModel );
1597}
1598
1600 const ScAddress& rAddress, const OUString& rValueStr, sal_Int32 nCellType )
1601{
1602 getFormulaBuffer().setCellFormulaValue(rAddress, rValueStr, nCellType);
1603}
1604
1605void WorksheetHelper::putRichString( const ScAddress& rAddress, RichString& rString, const oox::xls::Font* pFirstPortionFont, bool bSingleLine )
1606{
1608
1609 rEE.SetSingleLine(bSingleLine);
1610
1611 // The cell will own the text object instance returned from convert().
1612 getDocImport().setEditCell(rAddress, rString.convert(rEE, pFirstPortionFont));
1613
1614 rEE.SetSingleLine(false);
1615}
1616
1617void WorksheetHelper::putFormulaTokens( const ScAddress& rAddress, const ApiTokenSequence& rTokens )
1618{
1620 std::unique_ptr<ScTokenArray> pTokenArray(new ScTokenArray(rDoc.getDoc()));
1621 ScTokenConversion::ConvertToTokenArray(rDoc.getDoc(), *pTokenArray, rTokens);
1622 rDoc.setFormulaCell(rAddress, std::move(pTokenArray));
1623}
1624
1626{
1628}
1629
1631{
1633}
1634
1636{
1638}
1639
1640void WorksheetHelper::setCellFormula( const ScAddress& rTokenAddress, const OUString& rTokenStr )
1641{
1642 getFormulaBuffer().setCellFormula( rTokenAddress, rTokenStr );
1643}
1644
1646 const ScAddress& rAddr, sal_Int32 nSharedId,
1647 const OUString& rCellValue, sal_Int32 nValueType )
1648{
1649 getFormulaBuffer().setCellFormula(rAddr, nSharedId, rCellValue, nValueType);
1650}
1651
1652void WorksheetHelper::setCellArrayFormula( const ScRange& rRangeAddress, const ScAddress& rTokenAddress, const OUString& rTokenStr )
1653{
1654 getFormulaBuffer().setCellArrayFormula( rRangeAddress, rTokenAddress, rTokenStr );
1655}
1656
1658 const ScAddress& rAddress, sal_Int32 nSharedId, const OUString& rTokens )
1659{
1660 getFormulaBuffer().createSharedFormulaMapEntry(rAddress, nSharedId, rTokens);
1661}
1662
1663} // namespace oox
1664
1665/* 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 SetSingleLine(bool bValue)
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:243
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:324
bool empty() const
Definition: dbdata.cxx:1634
bool HasAutoFilter() const
Definition: dbdata.hxx:212
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:298
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 ScTable * FetchTable(SCTAB nTab)
Definition: document.cxx:2509
SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden)
Definition: document.cxx:4448
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:483
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:827
SC_DLLPUBLIC void SetColWidthOnly(SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth)
Definition: document.cxx:4092
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4741
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6055
SC_DLLPUBLIC void SetRowHeightOnly(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, sal_uInt16 nNewHeight)
Definition: document.cxx:4110
SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden)
Definition: document.cxx:4442
SC_DLLPUBLIC void SetManualHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual)
Definition: document.cxx:4116
SC_DLLPUBLIC ScDBData * GetAnonymousDBData(SCTAB nTab)
Definition: document.cxx:290
SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered)
Definition: document.cxx:4496
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
void SetOptimalMinRowHeight(sal_uInt16 nSet)
Definition: table.hxx:885
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)
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.
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).
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.
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 putRichString(const ScAddress &rAddress, RichString &rString, const oox::xls::Font *pFirstPortionFont, bool bSingleLine=false)
Inserts a rich-string cell directly into the Calc 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:277
@ CELLTYPE_STRING
Definition: global.hxx:275
#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