LibreOffice Module sc (master)  1
xehelper.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 <sal/config.h>
21 
22 #include <string_view>
23 
24 #include <com/sun/star/i18n/XBreakIterator.hpp>
25 #include <com/sun/star/i18n/ScriptType.hpp>
26 #include <sfx2/objsh.hxx>
27 #include <vcl/font.hxx>
28 #include <tools/urlobj.hxx>
29 #include <svl/itemset.hxx>
30 #include <svtools/ctrltool.hxx>
31 #include <svx/svdotext.hxx>
32 #include <editeng/outlobj.hxx>
33 #include <scitems.hxx>
34 #include <editeng/fhgtitem.hxx>
35 #include <editeng/flstitem.hxx>
36 #include <editeng/colritem.hxx>
37 #include <editeng/eeitem.hxx>
38 #include <editeng/flditem.hxx>
40 #include <editeng/svxfont.hxx>
41 #include <editeng/editids.hrc>
42 
43 #include <document.hxx>
44 #include <docpool.hxx>
45 #include <editutil.hxx>
46 #include <patattr.hxx>
47 #include <scmatrix.hxx>
48 #include <xestyle.hxx>
49 #include <fprogressbar.hxx>
50 #include <globstr.hrc>
51 #include <xltracer.hxx>
52 #include <xltools.hxx>
53 #include <xecontent.hxx>
54 #include <xelink.hxx>
55 #include <xehelper.hxx>
56 
57 using ::com::sun::star::uno::Reference;
58 using ::com::sun::star::i18n::XBreakIterator;
59 
60 // Export progress bar ========================================================
61 
63  XclExpRoot( rRoot ),
64  mxProgress( new ScfProgressBar( rRoot.GetDocShell(), STR_SAVE_DOC ) ),
65  mpSubProgress( nullptr ),
66  mpSubRowCreate( nullptr ),
67  mpSubRowFinal( nullptr ),
68  mnSegRowFinal( SCF_INV_SEGMENT ),
69  mnRowCount( 0 )
70 {
71 }
72 
74 {
75 }
76 
78 {
79  const ScDocument& rDoc = GetDoc();
80  const XclExpTabInfo& rTabInfo = GetTabInfo();
81  SCTAB nScTabCount = rTabInfo.GetScTabCount();
82 
83  // *** segment: creation of ROW records *** -------------------------------
84 
85  sal_Int32 nSegRowCreate = mxProgress->AddSegment( 2000 );
86  mpSubRowCreate = &mxProgress->GetSegmentProgressBar( nSegRowCreate );
87  maSubSegRowCreate.resize( nScTabCount, SCF_INV_SEGMENT );
88 
89  for( SCTAB nScTab = 0; nScTab < nScTabCount; ++nScTab )
90  {
91  if( rTabInfo.IsExportTab( nScTab ) )
92  {
93  SCCOL nLastUsedScCol;
94  SCROW nLastUsedScRow;
95  rDoc.GetTableArea( nScTab, nLastUsedScCol, nLastUsedScRow );
96  std::size_t nSegSize = static_cast< std::size_t >( nLastUsedScRow + 1 );
97  maSubSegRowCreate[ nScTab ] = mpSubRowCreate->AddSegment( nSegSize );
98  }
99  }
100 
101  // *** segment: writing all ROW records *** -------------------------------
102 
103  mnSegRowFinal = mxProgress->AddSegment( 1000 );
104  // sub progress bar and segment are created later in ActivateFinalRowsSegment()
105 }
106 
108 {
109  ++mnRowCount;
110 }
111 
113 {
114  OSL_ENSURE( (0 <= GetCurrScTab()) && (GetCurrScTab() < GetTabInfo().GetScTabCount()),
115  "XclExpProgressBar::ActivateCreateRowsSegment - invalid sheet" );
116  sal_Int32 nSeg = maSubSegRowCreate[ GetCurrScTab() ];
117  OSL_ENSURE( nSeg != SCF_INV_SEGMENT, "XclExpProgressBar::ActivateCreateRowsSegment - invalid segment" );
118  if( nSeg != SCF_INV_SEGMENT )
119  {
122  }
123  else
124  mpSubProgress = nullptr;
125 }
126 
128 {
129  if( !mpSubRowFinal && (mnRowCount > 0) )
130  {
131  mpSubRowFinal = &mxProgress->GetSegmentProgressBar( mnSegRowFinal );
133  }
135  if( mpSubProgress )
137 }
138 
140 {
141  if( mpSubProgress && !mpSubProgress->IsFull() )
143 }
144 
145 // Calc->Excel cell address/range conversion ==================================
146 
147 namespace {
148 
150 void lclFillAddress( XclAddress& rXclPos, SCCOL nScCol, SCROW nScRow )
151 {
152  rXclPos.mnCol = static_cast< sal_uInt16 >( nScCol );
153  rXclPos.mnRow = static_cast< sal_uInt32 >( nScRow );
154 }
155 
156 } // namespace
157 
159  XclAddressConverterBase( rRoot.GetTracer(), rRoot.GetXclMaxPos() )
160 {
161 }
162 
163 // cell address ---------------------------------------------------------------
164 
165 bool XclExpAddressConverter::CheckAddress( const ScAddress& rScPos, bool bWarn )
166 {
167  // ScAddress::operator<=() doesn't do what we want here
168  bool bValidCol = (0 <= rScPos.Col()) && (rScPos.Col() <= maMaxPos.Col());
169  bool bValidRow = (0 <= rScPos.Row()) && (rScPos.Row() <= maMaxPos.Row());
170  bool bValidTab = (0 <= rScPos.Tab()) && (rScPos.Tab() <= maMaxPos.Tab());
171 
172  bool bValid = bValidCol && bValidRow && bValidTab;
173  if( !bValid )
174  {
175  mbColTrunc |= !bValidCol;
176  mbRowTrunc |= !bValidRow;
177  }
178  if( !bValid && bWarn )
179  {
180  mbTabTrunc |= (rScPos.Tab() > maMaxPos.Tab()); // do not warn for deleted refs
182  }
183  return bValid;
184 }
185 
187  const ScAddress& rScPos, bool bWarn )
188 {
189  bool bValid = CheckAddress( rScPos, bWarn );
190  if( bValid )
191  lclFillAddress( rXclPos, rScPos.Col(), rScPos.Row() );
192  return bValid;
193 }
194 
196 {
198  if( !ConvertAddress( aXclPos, rScPos, bWarn ) )
199  lclFillAddress( aXclPos, ::std::min( rScPos.Col(), maMaxPos.Col() ), ::std::min( rScPos.Row(), maMaxPos.Row() ) );
200  return aXclPos;
201 }
202 
203 // cell range -----------------------------------------------------------------
204 
205 bool XclExpAddressConverter::CheckRange( const ScRange& rScRange, bool bWarn )
206 {
207  return CheckAddress( rScRange.aStart, bWarn ) && CheckAddress( rScRange.aEnd, bWarn );
208 }
209 
210 bool XclExpAddressConverter::ValidateRange( ScRange& rScRange, bool bWarn )
211 {
212  rScRange.PutInOrder();
213 
214  // check start position
215  bool bValidStart = CheckAddress( rScRange.aStart, bWarn );
216  if( bValidStart )
217  {
218  // check & correct end position
219  ScAddress& rScEnd = rScRange.aEnd;
220  if( !CheckAddress( rScEnd, bWarn ) )
221  {
222  rScEnd.SetCol( ::std::min( rScEnd.Col(), maMaxPos.Col() ) );
223  rScEnd.SetRow( ::std::min( rScEnd.Row(), maMaxPos.Row() ) );
224  rScEnd.SetTab( ::std::min( rScEnd.Tab(), maMaxPos.Tab() ) );
225  }
226  }
227 
228  return bValidStart;
229 }
230 
232  const ScRange& rScRange, bool bWarn )
233 {
234  // check start position
235  bool bValidStart = CheckAddress( rScRange.aStart, bWarn );
236  if( bValidStart )
237  {
238  lclFillAddress( rXclRange.maFirst, rScRange.aStart.Col(), rScRange.aStart.Row() );
239 
240  // check & correct end position
241  SCCOL nScCol2 = rScRange.aEnd.Col();
242  SCROW nScRow2 = rScRange.aEnd.Row();
243  if( !CheckAddress( rScRange.aEnd, bWarn ) )
244  {
245  nScCol2 = ::std::min( nScCol2, maMaxPos.Col() );
246  nScRow2 = ::std::min( nScRow2, maMaxPos.Row() );
247  }
248  lclFillAddress( rXclRange.maLast, nScCol2, nScRow2 );
249  }
250  return bValidStart;
251 }
252 
253 // cell range list ------------------------------------------------------------
254 
256 {
257  for ( size_t nRange = rScRanges.size(); nRange > 0; )
258  {
259  ScRange & rScRange = rScRanges[ --nRange ];
260  if( !CheckRange( rScRange, bWarn ) )
261  rScRanges.Remove(nRange);
262  }
263 }
264 
266  const ScRangeList& rScRanges, bool bWarn )
267 {
268  rXclRanges.clear();
269  for( size_t nPos = 0, nCount = rScRanges.size(); nPos < nCount; ++nPos )
270  {
271  const ScRange & rScRange = rScRanges[ nPos ];
272  XclRange aXclRange( ScAddress::UNINITIALIZED );
273  if( ConvertRange( aXclRange, rScRange, bWarn ) )
274  rXclRanges.push_back( aXclRange );
275  }
276 }
277 
278 // EditEngine->String conversion ==============================================
279 
280 namespace {
281 
282 OUString lclGetUrlRepresentation( const SvxURLField& rUrlField )
283 {
284  const OUString& aRepr = rUrlField.GetRepresentation();
285  // no representation -> use URL
286  return aRepr.isEmpty() ? rUrlField.GetURL() : aRepr;
287 }
288 
289 } // namespace
290 
292  XclExpRoot( rRoot ),
293  maScPos( rScPos ),
294  mbMultipleUrls( false )
295 {
296 }
297 
299 {
300 }
301 
303 {
304  OUString aUrlRepr;
305 
306  if( GetBiff() == EXC_BIFF8 ) // no HLINK records in BIFF2-BIFF7
307  {
308  // there was/is already a HLINK record
309  mbMultipleUrls = static_cast< bool >(mxLinkRec);
310 
311  mxLinkRec = new XclExpHyperlink( GetRoot(), rUrlField, maScPos );
312 
313  if( const OUString* pRepr = mxLinkRec->GetRepr() )
314  aUrlRepr = *pRepr;
315 
316  // add URL to note text
317  maUrlList = ScGlobal::addToken( maUrlList, rUrlField.GetURL(), '\n' );
318  }
319 
320  // no hyperlink representation from Excel HLINK record -> use it from text field
321  return aUrlRepr.isEmpty() ? lclGetUrlRepresentation(rUrlField) : aUrlRepr;
322 }
323 
325 {
326  return !mbMultipleUrls && mxLinkRec;
327 }
328 
330 {
331  if( HasLinkRecord() )
332  return mxLinkRec;
333  return XclExpHyperlinkRef();
334 }
335 
336 namespace {
337 
353 XclExpStringRef lclCreateFormattedString(
354  const XclExpRoot& rRoot, const OUString& rText, const ScPatternAttr* pCellAttr,
355  XclStrFlags nFlags, sal_uInt16 nMaxLen )
356 {
357  /* Create an empty Excel string object with correctly initialized BIFF mode,
358  because this function only uses Append() functions that require this. */
359  XclExpStringRef xString = XclExpStringHelper::CreateString( rRoot, EMPTY_OUSTRING, nFlags, nMaxLen );
360 
361  // script type handling
362  Reference< XBreakIterator > xBreakIt = rRoot.GetDoc().GetBreakIterator();
363  namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
364  // #i63255# get script type for leading weak characters
365  sal_Int16 nLastScript = XclExpStringHelper::GetLeadingScriptType( rRoot, rText );
366 
367  // font buffer and cell item set
368  XclExpFontBuffer& rFontBuffer = rRoot.GetFontBuffer();
369  const SfxItemSet& rItemSet = pCellAttr ? pCellAttr->GetItemSet() : rRoot.GetDoc().GetDefPattern()->GetItemSet();
370 
371  // process all script portions
372  sal_Int32 nPortionPos = 0;
373  sal_Int32 nTextLen = rText.getLength();
374  while( nPortionPos < nTextLen )
375  {
376  // get script type and end position of next script portion
377  sal_Int16 nScript = xBreakIt->getScriptType( rText, nPortionPos );
378  sal_Int32 nPortionEnd = xBreakIt->endOfScript( rText, nPortionPos, nScript );
379 
380  // reuse previous script for following weak portions
381  if( nScript == ApiScriptType::WEAK )
382  nScript = nLastScript;
383 
384  // construct font from current text portion
385  SvxFont aFont( XclExpFontHelper::GetFontFromItemSet( rRoot, rItemSet, nScript ) );
386 
387  // Excel start position of this portion
388  sal_Int32 nXclPortionStart = xString->Len();
389  // add portion text to Excel string
390  XclExpStringHelper::AppendString( *xString, rRoot, rText.copy( nPortionPos, nPortionEnd - nPortionPos ) );
391  if( nXclPortionStart < xString->Len() )
392  {
393  // insert font into buffer
394  sal_uInt16 nFontIdx = rFontBuffer.Insert( aFont, EXC_COLOR_CELLTEXT );
395  // insert font index into format run vector
396  xString->AppendFormat( nXclPortionStart, nFontIdx );
397  }
398 
399  // go to next script portion
400  nLastScript = nScript;
401  nPortionPos = nPortionEnd;
402  }
403 
404  return xString;
405 }
406 
421 XclExpStringRef lclCreateFormattedString(
422  const XclExpRoot& rRoot, EditEngine& rEE, XclExpHyperlinkHelper* pLinkHelper,
423  XclStrFlags nFlags, sal_uInt16 nMaxLen )
424 {
425  /* Create an empty Excel string object with correctly initialized BIFF mode,
426  because this function only uses Append() functions that require this. */
427  XclExpStringRef xString = XclExpStringHelper::CreateString( rRoot, EMPTY_OUSTRING, nFlags, nMaxLen );
428 
429  // font buffer and helper item set for edit engine -> Calc item conversion
430  XclExpFontBuffer& rFontBuffer = rRoot.GetFontBuffer();
432 
433  // script type handling
434  Reference< XBreakIterator > xBreakIt = rRoot.GetDoc().GetBreakIterator();
435  namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
436  // #i63255# get script type for leading weak characters
437  sal_Int16 nLastScript = XclExpStringHelper::GetLeadingScriptType( rRoot, rEE.GetText() );
438 
439  // process all paragraphs
440  sal_Int32 nParaCount = rEE.GetParagraphCount();
441  for( sal_Int32 nPara = 0; nPara < nParaCount; ++nPara )
442  {
443  ESelection aSel( nPara, 0 );
444  OUString aParaText( rEE.GetText( nPara ) );
445 
446  std::vector<sal_Int32> aPosList;
447  rEE.GetPortions( nPara, aPosList );
448 
449  // process all portions in the paragraph
450  for( const auto& rPos : aPosList )
451  {
452  aSel.nEndPos = rPos;
453  OUString aXclPortionText = aParaText.copy( aSel.nStartPos, aSel.nEndPos - aSel.nStartPos );
454 
455  aItemSet.ClearItem();
456  SfxItemSet aEditSet( rEE.GetAttribs( aSel ) );
457  ScPatternAttr::GetFromEditItemSet( aItemSet, aEditSet );
458 
459  // get escapement value
460  short nEsc = aEditSet.Get( EE_CHAR_ESCAPEMENT ).GetEsc();
461 
462  // process text fields
463  bool bIsHyperlink = false;
464  if( aSel.nStartPos + 1 == aSel.nEndPos )
465  {
466  // test if the character is a text field
467  const SfxPoolItem* pItem;
468  if( aEditSet.GetItemState( EE_FEATURE_FIELD, false, &pItem ) == SfxItemState::SET )
469  {
470  const SvxFieldData* pField = static_cast< const SvxFieldItem* >( pItem )->GetField();
471  if( const SvxURLField* pUrlField = dynamic_cast<const SvxURLField*>( pField ) )
472  {
473  // convert URL field to string representation
474  aXclPortionText = pLinkHelper ?
475  pLinkHelper->ProcessUrlField( *pUrlField ) :
476  lclGetUrlRepresentation( *pUrlField );
477  bIsHyperlink = true;
478  }
479  else
480  {
481  OSL_FAIL( "lclCreateFormattedString - unknown text field" );
482  aXclPortionText.clear();
483  }
484  }
485  }
486 
487  // Excel start position of this portion
488  sal_Int32 nXclPortionStart = xString->Len();
489  // add portion text to Excel string
490  XclExpStringHelper::AppendString( *xString, rRoot, aXclPortionText );
491  if( (nXclPortionStart < xString->Len()) || (aParaText.isEmpty()) )
492  {
493  /* Construct font from current edit engine text portion. Edit engine
494  creates different portions for different script types, no need to loop. */
495  sal_Int16 nScript = xBreakIt->getScriptType( aXclPortionText, 0 );
496  if( nScript == ApiScriptType::WEAK )
497  nScript = nLastScript;
498  SvxFont aFont( XclExpFontHelper::GetFontFromItemSet( rRoot, aItemSet, nScript ) );
499  nLastScript = nScript;
500 
501  // add escapement
502  aFont.SetEscapement( nEsc );
503  // modify automatic font color for hyperlinks
504  if( bIsHyperlink && aItemSet.Get( ATTR_FONT_COLOR ).GetValue() == COL_AUTO)
505  aFont.SetColor( COL_LIGHTBLUE );
506 
507  // insert font into buffer
508  sal_uInt16 nFontIdx = rFontBuffer.Insert( aFont, EXC_COLOR_CELLTEXT );
509  // insert font index into format run vector
510  xString->AppendFormat( nXclPortionStart, nFontIdx );
511  }
512 
513  aSel.nStartPos = aSel.nEndPos;
514  }
515 
516  // add trailing newline (important for correct character index calculation)
517  if( nPara + 1 < nParaCount )
518  XclExpStringHelper::AppendChar( *xString, rRoot, '\n' );
519  }
520 
521  return xString;
522 }
523 
524 } // namespace
525 
527  const XclExpRoot& rRoot, const OUString& rString, XclStrFlags nFlags, sal_uInt16 nMaxLen )
528 {
529  XclExpStringRef xString = std::make_shared<XclExpString>();
530  if( rRoot.GetBiff() == EXC_BIFF8 )
531  xString->Assign( rString, nFlags, nMaxLen );
532  else
533  xString->AssignByte( rString, rRoot.GetTextEncoding(), nFlags, nMaxLen );
534  return xString;
535 }
536 
538  const XclExpRoot& rRoot, sal_Unicode cChar, XclStrFlags nFlags, sal_uInt16 nMaxLen )
539 {
540  XclExpStringRef xString = CreateString( rRoot, EMPTY_OUSTRING, nFlags, nMaxLen );
541  AppendChar( *xString, rRoot, cChar );
542  return xString;
543 }
544 
545 void XclExpStringHelper::AppendString( XclExpString& rXclString, const XclExpRoot& rRoot, const OUString& rString )
546 {
547  if( rRoot.GetBiff() == EXC_BIFF8 )
548  rXclString.Append( rString );
549  else
550  rXclString.AppendByte( rString, rRoot.GetTextEncoding() );
551 }
552 
553 void XclExpStringHelper::AppendChar( XclExpString& rXclString, const XclExpRoot& rRoot, sal_Unicode cChar )
554 {
555  if( rRoot.GetBiff() == EXC_BIFF8 )
556  rXclString.Append( OUString(cChar) );
557  else
558  rXclString.AppendByte( cChar, rRoot.GetTextEncoding() );
559 }
560 
562  const XclExpRoot& rRoot, const OUString& rString, const ScPatternAttr* pCellAttr,
563  XclStrFlags nFlags, sal_uInt16 nMaxLen )
564 {
565  return lclCreateFormattedString(rRoot, rString, pCellAttr, nFlags, nMaxLen);
566 }
567 
569  const XclExpRoot& rRoot, const EditTextObject& rEditText, const ScPatternAttr* pCellAttr,
570  XclExpHyperlinkHelper& rLinkHelper, XclStrFlags nFlags, sal_uInt16 nMaxLen )
571 {
572  XclExpStringRef xString;
573 
574  // formatted cell
575  ScEditEngineDefaulter& rEE = rRoot.GetEditEngine();
576  bool bOldUpdateMode = rEE.GetUpdateMode();
577  rEE.SetUpdateMode( true );
578 
579  // default items
580  const SfxItemSet& rItemSet = pCellAttr ? pCellAttr->GetItemSet() : rRoot.GetDoc().GetDefPattern()->GetItemSet();
581  auto pEEItemSet = std::make_unique<SfxItemSet>( rEE.GetEmptyItemSet() );
582  ScPatternAttr::FillToEditItemSet( *pEEItemSet, rItemSet );
583  rEE.SetDefaults( std::move(pEEItemSet) ); // edit engine takes ownership
584 
585  // create the string
586  rEE.SetTextCurrentDefaults(rEditText);
587  xString = lclCreateFormattedString( rRoot, rEE, &rLinkHelper, nFlags, nMaxLen );
588  rEE.SetUpdateMode( bOldUpdateMode );
589 
590  return xString;
591 }
592 
594  const XclExpRoot& rRoot, const SdrTextObj& rTextObj,
595  XclStrFlags nFlags )
596 {
597  XclExpStringRef xString;
598  if( const OutlinerParaObject* pParaObj = rTextObj.GetOutlinerParaObject() )
599  {
600  EditEngine& rEE = rRoot.GetDrawEditEngine();
601  bool bOldUpdateMode = rEE.GetUpdateMode();
602  rEE.SetUpdateMode( true );
603  // create the string
604  rEE.SetText( pParaObj->GetTextObject() );
605  xString = lclCreateFormattedString( rRoot, rEE, nullptr, nFlags, EXC_STR_MAXLEN );
606  rEE.SetUpdateMode( bOldUpdateMode );
607  // limit formats - TODO: BIFF dependent
608  if( !xString->IsEmpty() )
609  {
610  xString->LimitFormatCount( EXC_MAXRECSIZE_BIFF8 / 8 - 1 );
611  xString->AppendTrailingFormat( EXC_FONT_APP );
612  }
613  }
614  else
615  {
616  OSL_FAIL( "XclExpStringHelper::CreateString - textbox without para object" );
617  // create BIFF dependent empty Excel string
618  xString = CreateString( rRoot, EMPTY_OUSTRING, nFlags );
619  }
620  return xString;
621 }
622 
624  const XclExpRoot& rRoot, const EditTextObject& rEditObj,
625  XclStrFlags nFlags )
626 {
627  XclExpStringRef xString;
628  EditEngine& rEE = rRoot.GetDrawEditEngine();
629  bool bOldUpdateMode = rEE.GetUpdateMode();
630  rEE.SetUpdateMode( true );
631  rEE.SetText( rEditObj );
632  xString = lclCreateFormattedString( rRoot, rEE, nullptr, nFlags, EXC_STR_MAXLEN );
633  rEE.SetUpdateMode( bOldUpdateMode );
634  // limit formats - TODO: BIFF dependent
635  if( !xString->IsEmpty() )
636  {
637  xString->LimitFormatCount( EXC_MAXRECSIZE_BIFF8 / 8 - 1 );
638  xString->AppendTrailingFormat( EXC_FONT_APP );
639  }
640  return xString;
641 }
642 
643 sal_Int16 XclExpStringHelper::GetLeadingScriptType( const XclExpRoot& rRoot, const OUString& rString )
644 {
645  namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
646  Reference< XBreakIterator > xBreakIt = rRoot.GetDoc().GetBreakIterator();
647  sal_Int32 nStrPos = 0;
648  sal_Int32 nStrLen = rString.getLength();
649  sal_Int16 nScript = ApiScriptType::WEAK;
650  while( (nStrPos < nStrLen) && (nScript == ApiScriptType::WEAK) )
651  {
652  nScript = xBreakIt->getScriptType( rString, nStrPos );
653  nStrPos = xBreakIt->endOfScript( rString, nStrPos, nScript );
654  }
655  return (nScript == ApiScriptType::WEAK) ? rRoot.GetDefApiScript() : nScript;
656 }
657 
658 // Header/footer conversion ===================================================
659 
661  XclExpRoot( rRoot ),
662  mrEE( rRoot.GetHFEditEngine() ),
663  mnTotalHeight( 0 )
664 {
665 }
666 
668  const EditTextObject* pLeftObj,
669  const EditTextObject* pCenterObj,
670  const EditTextObject* pRightObj )
671 {
672  maHFString.clear();
673  mnTotalHeight = 0;
674  AppendPortion( pLeftObj, 'L' );
675  AppendPortion( pCenterObj, 'C' );
676  AppendPortion( pRightObj, 'R' );
677 }
678 
679 void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unicode cPortionCode )
680 {
681  if( !pTextObj ) return;
682 
683  OUString aText;
684  sal_Int32 nHeight = 0;
686 
687  // edit engine
688  bool bOldUpdateMode = mrEE.GetUpdateMode();
689  mrEE.SetUpdateMode( true );
690  mrEE.SetText( *pTextObj );
691 
692  // font information
693  XclFontData aFontData, aNewData;
694  if( const XclExpFont* pFirstFont = GetFontBuffer().GetFont( EXC_FONT_APP ) )
695  {
696  aFontData = pFirstFont->GetFontData();
697  aFontData.mnHeight = (aFontData.mnHeight + 10) / 20; // using pt here, not twips
698  }
699  else
700  aFontData.mnHeight = 10;
701 
702  const FontList* pFontList = nullptr;
703  if( SfxObjectShell* pDocShell = GetDocShell() )
704  {
705  if( const SvxFontListItem* pInfoItem = static_cast< const SvxFontListItem* >(
706  pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) ) )
707  pFontList = pInfoItem->GetFontList();
708  }
709 
710  sal_Int32 nParaCount = mrEE.GetParagraphCount();
711  for( sal_Int32 nPara = 0; nPara < nParaCount; ++nPara )
712  {
713  ESelection aSel( nPara, 0 );
714  OUStringBuffer aParaText;
715  sal_Int32 nParaHeight = 0;
716  std::vector<sal_Int32> aPosList;
717  mrEE.GetPortions( nPara, aPosList );
718 
719  for( const auto& rPos : aPosList )
720  {
721  aSel.nEndPos = rPos;
722  if( aSel.nStartPos < aSel.nEndPos )
723  {
724 
725 // --- font attributes ---
726 
727  vcl::Font aFont;
728  aItemSet.ClearItem();
729  SfxItemSet aEditSet( mrEE.GetAttribs( aSel ) );
730  ScPatternAttr::GetFromEditItemSet( aItemSet, aEditSet );
731  ScPatternAttr::GetFont( aFont, aItemSet, SC_AUTOCOL_RAW );
732 
733  // font name and style
734  aNewData.maName = XclTools::GetXclFontName( aFont.GetFamilyName() );
736  aNewData.mbItalic = (aFont.GetItalic() != ITALIC_NONE);
737  bool bNewFont = (aFontData.maName != aNewData.maName);
738  bool bNewStyle = (aFontData.mnWeight != aNewData.mnWeight) ||
739  (aFontData.mbItalic != aNewData.mbItalic);
740  if( bNewFont || (bNewStyle && pFontList) )
741  {
742  aParaText.append("&\"").append(aNewData.maName);
743  if( pFontList )
744  {
745  FontMetric aFontMetric( pFontList->Get(
746  aNewData.maName,
748  aNewData.mbItalic ? ITALIC_NORMAL : ITALIC_NONE ) );
749  aNewData.maStyle = pFontList->GetStyleName( aFontMetric );
750  if( !aNewData.maStyle.isEmpty() )
751  aParaText.append(",").append(aNewData.maStyle);
752  }
753  aParaText.append("\"");
754  }
755 
756  // height
757  // is calculated wrong in ScPatternAttr::GetFromEditItemSet, because already in twips and not 100thmm
758  // -> get it directly from edit engine item set
759  aNewData.mnHeight = ulimit_cast< sal_uInt16 >( aEditSet.Get( EE_CHAR_FONTHEIGHT ).GetHeight() );
760  aNewData.mnHeight = (aNewData.mnHeight + 10) / 20;
761  bool bFontHtChanged = (aFontData.mnHeight != aNewData.mnHeight);
762  if( bFontHtChanged )
763  aParaText.append("&").append(OUString::number( aNewData.mnHeight ));
764  // update maximum paragraph height, convert to twips
765  nParaHeight = ::std::max< sal_Int32 >( nParaHeight, aNewData.mnHeight * 20 );
766 
767  // underline
768  aNewData.mnUnderline = EXC_FONTUNDERL_NONE;
769  switch( aFont.GetUnderline() )
770  {
771  case LINESTYLE_NONE: aNewData.mnUnderline = EXC_FONTUNDERL_NONE; break;
772  case LINESTYLE_SINGLE: aNewData.mnUnderline = EXC_FONTUNDERL_SINGLE; break;
773  case LINESTYLE_DOUBLE: aNewData.mnUnderline = EXC_FONTUNDERL_DOUBLE; break;
774  default: aNewData.mnUnderline = EXC_FONTUNDERL_SINGLE;
775  }
776  if( aFontData.mnUnderline != aNewData.mnUnderline )
777  {
778  sal_uInt8 nTmpUnderl = (aNewData.mnUnderline == EXC_FONTUNDERL_NONE) ?
779  aFontData.mnUnderline : aNewData.mnUnderline;
780  (nTmpUnderl == EXC_FONTUNDERL_SINGLE)? aParaText.append("&U") : aParaText.append("&E");
781  }
782 
783  // font color
784  aNewData.maColor = aFont.GetColor();
785  if ( !aFontData.maColor.IsRGBEqual( aNewData.maColor ) )
786  {
787  aParaText.append("&K").append(aNewData.maColor.AsRGBHexString());
788  }
789 
790  // strikeout
791  aNewData.mbStrikeout = (aFont.GetStrikeout() != STRIKEOUT_NONE);
792  if( aFontData.mbStrikeout != aNewData.mbStrikeout )
793  aParaText.append("&S");
794 
795  // super/sub script
796  const SvxEscapementItem& rEscapeItem = aEditSet.Get( EE_CHAR_ESCAPEMENT );
797  aNewData.SetScEscapement( rEscapeItem.GetEsc() );
798  if( aFontData.mnEscapem != aNewData.mnEscapem )
799  {
800  switch(aNewData.mnEscapem)
801  {
802  // close the previous super/sub script.
803  case EXC_FONTESC_NONE: (aFontData.mnEscapem == EXC_FONTESC_SUPER) ? aParaText.append("&X") : aParaText.append("&Y"); break;
804  case EXC_FONTESC_SUPER: aParaText.append("&X"); break;
805  case EXC_FONTESC_SUB: aParaText.append("&Y"); break;
806  default: break;
807  }
808  }
809 
810  aFontData = aNewData;
811 
812 // --- text content or text fields ---
813 
814  const SfxPoolItem* pItem;
815  if( (aSel.nStartPos + 1 == aSel.nEndPos) && // fields are single characters
816  (aEditSet.GetItemState( EE_FEATURE_FIELD, false, &pItem ) == SfxItemState::SET) )
817  {
818  if( const SvxFieldData* pFieldData = static_cast< const SvxFieldItem* >( pItem )->GetField() )
819  {
820  if( dynamic_cast<const SvxPageField*>( pFieldData) != nullptr )
821  aParaText.append("&P");
822  else if( dynamic_cast<const SvxPagesField*>( pFieldData) != nullptr )
823  aParaText.append("&N");
824  else if( dynamic_cast<const SvxDateField*>( pFieldData) != nullptr )
825  aParaText.append("&D");
826  else if( dynamic_cast<const SvxTimeField*>( pFieldData) != nullptr || dynamic_cast<const SvxExtTimeField*>( pFieldData) != nullptr )
827  aParaText.append("&T");
828  else if( dynamic_cast<const SvxTableField*>( pFieldData) != nullptr )
829  aParaText.append("&A");
830  else if( dynamic_cast<const SvxFileField*>( pFieldData) != nullptr ) // title -> file name
831  aParaText.append("&F");
832  else if( const SvxExtFileField* pFileField = dynamic_cast<const SvxExtFileField*>( pFieldData ) )
833  {
834  switch( pFileField->GetFormat() )
835  {
836  case SvxFileFormat::NameAndExt:
837  case SvxFileFormat::NameOnly:
838  aParaText.append("&F");
839  break;
840  case SvxFileFormat::PathOnly:
841  aParaText.append("&Z");
842  break;
843  case SvxFileFormat::PathFull:
844  aParaText.append("&Z&F");
845  break;
846  default:
847  OSL_FAIL( "XclExpHFConverter::AppendPortion - unknown file field" );
848  }
849  }
850  }
851  }
852  else
853  {
854  OUString aPortionText( mrEE.GetText( aSel ) );
855  aPortionText = aPortionText.replaceAll( "&", "&&" );
856  // #i17440# space between font height and numbers in text
857  if( bFontHtChanged && aParaText.getLength() && !aPortionText.isEmpty() )
858  {
859  sal_Unicode cLast = aParaText[ aParaText.getLength() - 1 ];
860  sal_Unicode cFirst = aPortionText[0];
861  if( ('0' <= cLast) && (cLast <= '9') && ('0' <= cFirst) && (cFirst <= '9') )
862  aParaText.append(" ");
863  }
864  aParaText.append(aPortionText);
865  }
866  }
867 
868  aSel.nStartPos = aSel.nEndPos;
869  }
870 
871  aText = ScGlobal::addToken( aText, aParaText.makeStringAndClear(), '\n' );
872  if( nParaHeight == 0 )
873  nParaHeight = aFontData.mnHeight * 20; // points -> twips
874  nHeight += nParaHeight;
875  }
876 
877  mrEE.SetUpdateMode( bOldUpdateMode );
878 
879  if( !aText.isEmpty() )
880  {
881  maHFString += "&" + OUStringChar(cPortionCode) + aText;
882  mnTotalHeight = ::std::max( mnTotalHeight, nHeight );
883  }
884 }
885 
886 // URL conversion =============================================================
887 
888 namespace {
889 
892 OUString lclEncodeDosUrl(
893  XclBiff eBiff, const OUString& rUrl, const OUString& rBase, const OUString* pTableName)
894 {
895  OUStringBuffer aBuf;
896 
897  if (!rUrl.isEmpty())
898  {
899  OUString aOldUrl = rUrl;
900  aBuf.append(EXC_URLSTART_ENCODED);
901 
902  if ( aOldUrl.getLength() > 2 && aOldUrl.startsWith("\\\\") )
903  {
904  // UNC
905  aBuf.append(EXC_URL_DOSDRIVE).append('@');
906  aOldUrl = aOldUrl.copy(2);
907  }
908  else if ( aOldUrl.getLength() > 2 && aOldUrl.match(":\\", 1) )
909  {
910  // drive letter
911  sal_Unicode cThisDrive = rBase.isEmpty() ? ' ' : rBase[0];
912  sal_Unicode cDrive = aOldUrl[0];
913  if (cThisDrive == cDrive)
914  // This document and the referenced document are under the same drive.
915  aBuf.append(EXC_URL_DRIVEROOT);
916  else
917  aBuf.append(EXC_URL_DOSDRIVE).append(cDrive);
918  aOldUrl = aOldUrl.copy(3);
919  }
920  else
921  {
922  // URL probably points to a document on a Unix-like file system
923  aBuf.append(EXC_URL_DRIVEROOT);
924  }
925 
926  // directories
927  sal_Int32 nPos = -1;
928  while((nPos = aOldUrl.indexOf('\\')) != -1)
929  {
930  if ( aOldUrl.startsWith("..") )
931  // parent dir (NOTE: the MS-XLS spec doesn't mention this, and
932  // Excel seems confused by this token).
933  aBuf.append(EXC_URL_PARENTDIR);
934  else
935  aBuf.append(std::u16string_view(aOldUrl).substr(0,nPos)).append(EXC_URL_SUBDIR);
936 
937  aOldUrl = aOldUrl.copy(nPos + 1);
938  }
939 
940  // file name
941  if (pTableName) // enclose file name in brackets if table name follows
942  aBuf.append('[').append(aOldUrl).append(']');
943  else
944  aBuf.append(aOldUrl);
945  }
946  else // empty URL -> self reference
947  {
948  switch( eBiff )
949  {
950  case EXC_BIFF5:
951  aBuf.append(pTableName ? EXC_URLSTART_SELFENCODED : EXC_URLSTART_SELF);
952  break;
953  case EXC_BIFF8:
954  DBG_ASSERT( pTableName, "lclEncodeDosUrl - sheet name required for BIFF8" );
955  aBuf.append(EXC_URLSTART_SELF);
956  break;
957  default:
958  DBG_ERROR_BIFF();
959  }
960  }
961 
962  // table name
963  if (pTableName)
964  aBuf.append(*pTableName);
965 
966  // VirtualPath must be shorter than 255 chars ([MS-XLS].pdf 2.5.277)
967  // It's better to truncate, than generate invalid file that Excel cannot open.
968  if (aBuf.getLength() > 255)
969  aBuf.setLength(255);
970 
971  return aBuf.makeStringAndClear();
972 }
973 
974 } // namespace
975 
976 OUString XclExpUrlHelper::EncodeUrl( const XclExpRoot& rRoot, const OUString& rAbsUrl, const OUString* pTableName )
977 {
978  OUString aDosUrl = INetURLObject(rAbsUrl).getFSysPath(FSysStyle::Dos);
979  OUString aDosBase = INetURLObject(rRoot.GetBasePath()).getFSysPath(FSysStyle::Dos);
980  return lclEncodeDosUrl(rRoot.GetBiff(), aDosUrl, aDosBase, pTableName);
981 }
982 
983 OUString XclExpUrlHelper::EncodeDde( const OUString& rApplic, const OUString& rTopic )
984 {
985  return rApplic + OUStringChar(EXC_DDE_DELIM) + rTopic;
986 }
987 
988 // Cached Value Lists =========================================================
989 
991  : mrMatrix( rMatrix )
992 {
993  mrMatrix.IncRef();
994 }
996 {
997  mrMatrix.DecRef();
998 }
999 
1000 void XclExpCachedMatrix::GetDimensions( SCSIZE & nCols, SCSIZE & nRows ) const
1001 {
1002  mrMatrix.GetDimensions( nCols, nRows );
1003 
1004  OSL_ENSURE( nCols && nRows, "XclExpCachedMatrix::GetDimensions - empty matrix" );
1005  OSL_ENSURE( nCols <= 256, "XclExpCachedMatrix::GetDimensions - too many columns" );
1006 }
1007 
1008 std::size_t XclExpCachedMatrix::GetSize() const
1009 {
1010  SCSIZE nCols, nRows;
1011 
1012  GetDimensions( nCols, nRows );
1013 
1014  /* The returned size may be wrong if the matrix contains strings. The only
1015  effect is that the export stream has to update a wrong record size which is
1016  faster than to iterate through all cached values and calculate their sizes. */
1017  return 3 + 9 * (nCols * nRows);
1018 }
1019 
1021 {
1022  SCSIZE nCols, nRows;
1023 
1024  GetDimensions( nCols, nRows );
1025 
1026  if( rStrm.GetRoot().GetBiff() <= EXC_BIFF5 )
1027  // in BIFF2-BIFF7: 256 columns represented by 0 columns
1028  rStrm << static_cast< sal_uInt8 >( nCols ) << static_cast< sal_uInt16 >( nRows );
1029  else
1030  // in BIFF8: columns and rows decreased by 1
1031  rStrm << static_cast< sal_uInt8 >( nCols - 1 ) << static_cast< sal_uInt16 >( nRows - 1 );
1032 
1033  for( SCSIZE nRow = 0; nRow < nRows; ++nRow )
1034  {
1035  for( SCSIZE nCol = 0; nCol < nCols; ++nCol )
1036  {
1037  ScMatrixValue nMatVal = mrMatrix.Get( nCol, nRow );
1038 
1039  FormulaError nScError;
1040  if( ScMatValType::Empty == nMatVal.nType )
1041  {
1042  rStrm.SetSliceSize( 9 );
1043  rStrm << EXC_CACHEDVAL_EMPTY;
1044  rStrm.WriteZeroBytes( 8 );
1045  }
1046  else if( ScMatrix::IsNonValueType( nMatVal.nType ) )
1047  {
1049  rStrm.SetSliceSize( 6 );
1050  rStrm << EXC_CACHEDVAL_STRING << aStr;
1051  }
1052  else if( ScMatValType::Boolean == nMatVal.nType )
1053  {
1054  sal_Int8 nBool = sal_Int8(nMatVal.GetBoolean());
1055  rStrm.SetSliceSize( 9 );
1056  rStrm << EXC_CACHEDVAL_BOOL << nBool;
1057  rStrm.WriteZeroBytes( 7 );
1058  }
1059  else if( (nScError = nMatVal.GetError()) != FormulaError::NONE )
1060  {
1061  sal_Int8 nError ( XclTools::GetXclErrorCode( nScError ) );
1062  rStrm.SetSliceSize( 9 );
1063  rStrm << EXC_CACHEDVAL_ERROR << nError;
1064  rStrm.WriteZeroBytes( 7 );
1065  }
1066  else
1067  {
1068  rStrm.SetSliceSize( 9 );
1069  rStrm << EXC_CACHEDVAL_DOUBLE << nMatVal.fVal;
1070  }
1071  }
1072  }
1073 }
1074 
1075 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ActivateSegment(sal_Int32 nSegment)
Starts the progress bar or activates another segment.
OUString AsRGBHexString() const
rtl::Reference< XclExpHyperlink > XclExpHyperlinkRef
Definition: xehelper.hxx:178
static bool IsNonValueType(ScMatValType nType)
String, empty or empty path, but not value nor boolean.
Definition: scmatrix.hxx:173
ScAddress maMaxPos
Tracer for invalid addresses.
Definition: xladdress.hxx:161
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:113
const sal_Unicode EXC_URLSTART_SELF
Encoded URL.
Definition: xlconst.hxx:90
static OUString EncodeUrl(const XclExpRoot &rRoot, const OUString &rAbsUrl, const OUString *pTableName=nullptr)
Encodes and returns the URL passed in rAbsUrl to an Excel like URL.
Definition: xehelper.cxx:976
void ConvertRangeList(XclRangeList &rXclRanges, const ScRangeList &rScRanges, bool bWarn)
Converts the passed Calc cell range list to an Excel cell range list.
Definition: xehelper.cxx:265
SC_DLLPUBLIC const css::uno::Reference< css::i18n::XBreakIterator > & GetBreakIterator()
Definition: documen6.cxx:40
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:43
EditEngine & GetDrawEditEngine() const
Returns the edit engine for import/export of drawing text boxes.
Definition: xlroot.cxx:395
OUString GetText(LineEnd eEnd=LINEEND_LF) const
#define DBG_ERROR_BIFF()
Definition: xltools.hxx:31
const sal_uInt16 EXC_STR_MAXLEN
Definition: xlstring.hxx:43
const sal_Unicode EXC_URL_PARENTDIR
Directory name delimiter.
Definition: xlconst.hxx:97
vcl::Font GetFontFromItemSet(const XclExpRoot &rRoot, const SfxItemSet &rItemSet, sal_Int16 nScript)
Returns a VCL font object filled from the passed item set.
Definition: xestyle.cxx:880
XclExpHyperlinkRef mxLinkRec
Definition: xehelper.hxx:198
sal_Int32 mnSegRowFinal
Sub progress bar for finalizing ROW records.
Definition: xehelper.hxx:71
rtl_TextEncoding GetTextEncoding() const
Returns the text encoding to import/export byte strings.
Definition: xlroot.hxx:147
OUString getString() const
XclBiff
An enumeration for all Excel file format types (BIFF types).
Definition: xlconst.hxx:30
void SetDefaults(const SfxItemSet &rDefaults, bool bRememberCopy=true)
Creates a copy of SfxItemSet if bRememberCopy set.
Definition: editutil.cxx:502
ScAddress aStart
Definition: address.hxx:500
bool ConvertRange(XclRange &rXclRange, const ScRange &rScRange, bool bWarn)
Converts the passed Calc cell range to an Excel cell range.
Definition: xehelper.cxx:231
XclExpAddressConverter(const XclExpRoot &rRoot)
Definition: xehelper.cxx:158
const OUString & GetFamilyName() const
bool IsExportTab(SCTAB nScTab) const
Returns true, if the specified Calc sheet will be exported.
Definition: xelink.cxx:771
#define EMPTY_OUSTRING
Definition: global.hxx:215
void ActivateCreateRowsSegment()
Activates the progress segment to create ROW records.
Definition: xehelper.cxx:112
This class is used to export Excel record streams.
Definition: xestream.hxx:71
SCROW Row() const
Definition: address.hxx:262
XclStrFlags
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:29
const SfxItemSet & GetEmptyItemSet() const
void SetUpdateMode(bool bUpdate, bool bRestoring=false)
void Initialize()
Initializes all segments and sub progress bars.
Definition: xehelper.cxx:77
signed char sal_Int8
void push_back(const XclRange &rRange)
Definition: xladdress.hxx:114
bool mbTabTrunc
Flag for "rows truncated" warning box.
Definition: xladdress.hxx:166
ScAddress maScPos
Created HLINK record.
Definition: xehelper.hxx:199
void Progress()
Increases the currently activated (sub) progress bar by 1 step.
Definition: xehelper.cxx:139
sal_uInt16 Insert(const XclFontData &rFontData, XclExpColorType eColorType, bool bAppFont=false)
Inserts a new font with the passed font data into the buffer if not present.
Definition: xestyle.cxx:1190
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:286
bool CheckRange(const ScRange &rScRange, bool bWarn)
Checks if the passed cell range is valid (checks start and end position).
Definition: xehelper.cxx:205
ScMatrixValue Get(SCSIZE nC, SCSIZE nR) const
: If bString the ScMatrixValue->pS may still be NULL to indicate an empty string! ...
Definition: scmatrix.cxx:3094
ScfProgressBarPtr mxProgress
Definition: xehelper.hxx:64
aBuf
const SfxItemSet & GetItemSet() const
sal_uInt16 mnHeight
Font color.
Definition: xlstyle.hxx:291
ScAddress aEnd
Definition: address.hxx:501
XclAddress maLast
Definition: xladdress.hxx:61
ScfProgressBar * mpSubRowCreate
Current sub progress bar.
Definition: xehelper.hxx:67
sal_uInt32 mnRow
Definition: xladdress.hxx:33
const sal_uInt16 EXC_MAXRECSIZE_BIFF8
Definition: xlstream.hxx:31
EditEngine & mrEE
Definition: xehelper.hxx:387
XclAddress maFirst
Definition: xladdress.hxx:60
const sal_uInt8 EXC_CACHEDVAL_ERROR
Definition: xlconst.hxx:119
const sal_Unicode EXC_URLSTART_ENCODED
Definition: xlconst.hxx:89
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:276
void ActivateFinalRowsSegment()
Activates the progress segment to finalize ROW records.
Definition: xehelper.cxx:127
static void FillToEditItemSet(SfxItemSet &rEditSet, const SfxItemSet &rSrcSet, const SfxItemSet *pCondSet=nullptr)
Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet...
Definition: patattr.cxx:553
XclExpHFConverter(const XclExpHFConverter &)=delete
delete copy constructor
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
SfxItemSet GetAttribs(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags=GetAttribsFlags::ALL) const
Try NOT to use this struct.
Definition: scmatrix.hxx:53
XclExpCachedMatrix(const ScMatrix &rMatrix)
Constructs and fills a new matrix.
Definition: xehelper.cxx:990
void clear()
Definition: xladdress.hxx:113
const sal_uInt16 EXC_FONTESC_SUB
Definition: xlstyle.hxx:128
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6061
WEIGHT_BOLD
const sal_uInt16 EXC_FONTWGHT_BOLD
Definition: xlstyle.hxx:114
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
const sal_Unicode EXC_DDE_DELIM
Sheet name starts here (BIFF4).
Definition: xlconst.hxx:101
sal_uInt16 sal_Unicode
FontItalic GetItalic()
double fVal
Definition: scmatrix.hxx:55
Access to global data from other classes.
Definition: xeroot.hxx:113
const sal_uInt16 EXC_FONT_APP
Definition: xlstyle.hxx:77
bool GetBoolean() const
Only valid if ScMatrix methods indicate that this is a boolean.
Definition: scmatrix.hxx:66
static OUString GetXclFontName(const OUString &rFontName)
Returns the matching Excel font name for a passed Calc font name.
Definition: xltools.cxx:453
LINESTYLE_NONE
void SetText(const OUString &rStr)
MS Excel 4.0.
Definition: xlconst.hxx:35
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
ReturnType ulimit_cast(Type nValue, ReturnType nMax)
Returns the value, if it is not greater than nMax, otherwise nMax.
Definition: ftools.hxx:51
Helper to create HLINK records during creation of formatted cell strings.
Definition: xehelper.hxx:175
bool mbMultipleUrls
List with all processed URLs.
Definition: xehelper.hxx:201
int nCount
bool IsFull() const
Returns true, if the current progress segment is already full.
FontMetric Get(const OUString &rName, const OUString &rStyleName) const
const sal_uInt16 EXC_FONTESC_NONE
Definition: xlstyle.hxx:126
ScfInt32Vec maSubSegRowCreate
Sub progress bar for creating table rows.
Definition: xehelper.hxx:68
void GenerateString(const EditTextObject *pLeftObj, const EditTextObject *pCenterObj, const EditTextObject *pRightObj)
Generates the header/footer string from the passed edit engine text objects.
Definition: xehelper.cxx:667
SCTAB Tab() const
Definition: address.hxx:271
void SetRow(SCROW nRowP)
Definition: address.hxx:275
XclAddress CreateValidAddress(const ScAddress &rScPos, bool bWarn)
Returns a valid cell address by moving it into allowed dimensions.
Definition: xehelper.cxx:195
sal_Int32 nEndPos
bool mbItalic
Underline style.
Definition: xlstyle.hxx:297
void DecRef() const
Definition: scmatrix.cxx:2849
const OUString & GetStyleName(FontWeight eWeight, FontItalic eItalic) const
void Append(const OUString &rString)
Appends a string.
Definition: xestring.cxx:131
void SetCol(SCCOL nColP)
Definition: address.hxx:279
void GetDimensions(SCSIZE &nCols, SCSIZE &nRows) const
Definition: xehelper.cxx:1000
const sal_Int32 SCF_INV_SEGMENT
void SetSliceSize(sal_uInt16 nSize)
Sets data slice length.
Definition: xestream.cxx:129
const sal_Unicode EXC_URLSTART_SELFENCODED
Reference to own workbook.
Definition: xlconst.hxx:91
void Progress(std::size_t nDelta=1)
Increase current segment by the passed value.
void Remove(size_t nPos)
Definition: rangelst.cxx:1100
FormulaError GetError() const
Only valid if ScMatrix methods indicate that this is no string!
Definition: scmatrix.hxx:63
std::size_t GetSize() const
Returns the byte count of all contained data.
Definition: xehelper.cxx:1008
void SetTab(SCTAB nTabP)
Definition: address.hxx:283
sal_uInt16 mnEscapem
Boldness: 400=normal, 700=bold.
Definition: xlstyle.hxx:293
void SetScEscapement(short nScEscapem)
Sets the Calc escapement style.
Definition: xlstyle.cxx:370
Stores all data of an Excel font and provides export of FONT records.
Definition: xestyle.hxx:155
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:36
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
static void GetFont(vcl::Font &rFont, const SfxItemSet &rItemSet, ScAutoFontColorMode eAutoMode, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE, const Color *pBackConfigColor=nullptr, const Color *pTextConfigColor=nullptr)
Static helper function to fill a font object from the passed item set.
Definition: patattr.cxx:216
OUString maStyle
Font name.
Definition: xlstyle.hxx:289
void Activate()
Starts the progress bar (with first segment).
sal_uInt8 mnUnderline
Windows character set.
Definition: xlstyle.hxx:296
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:559
void IncRowRecordCount()
Increases the number of existing ROW records by 1.
Definition: xehelper.cxx:107
#define DBG_ASSERT(sCon, aError)
XclExpHyperlinkHelper(const XclExpRoot &rRoot, const ScAddress &rScPos)
Definition: xehelper.cxx:291
static sal_uInt8 GetXclErrorCode(FormulaError nScError)
Converts a Calc error code to an Excel error code.
Definition: xltools.cxx:200
void GetDimensions(SCSIZE &rC, SCSIZE &rR) const
Definition: scmatrix.cxx:2984
sal_Int16 SCCOL
Definition: types.hxx:22
OUString maHFString
The header/footer edit engine.
Definition: xehelper.hxx:388
static void GetFromEditItemSet(SfxItemSet &rDestSet, const SfxItemSet &rEditSet)
Converts all edit engine items contained in rEditSet to Calc items and puts them into rDestSet...
Definition: patattr.cxx:782
bool mbColTrunc
Maximum row index.
Definition: xladdress.hxx:164
const sal_Unicode EXC_URL_DOSDRIVE
Reference to own workbook (BIFF5/BIFF7).
Definition: xlconst.hxx:94
XclExpHyperlinkRef GetLinkRecord() const
Returns the created single HLINk record, or an empty reference.
Definition: xehelper.cxx:329
A 2D cell range address list with Excel column and row indexes.
Definition: xladdress.hxx:101
size_t size() const
Definition: rangelst.hxx:90
WEIGHT_NORMAL
LINESTYLE_SINGLE
Stores the correct Excel sheet index for each Calc sheet.
Definition: xelink.hxx:62
const sal_uInt8 EXC_CACHEDVAL_BOOL
Definition: xlconst.hxx:118
const ScMatrix & mrMatrix
Definition: xehelper.hxx:433
static sal_Int16 GetLeadingScriptType(const XclExpRoot &rRoot, const OUString &rString)
Returns the script type first text portion different to WEAK, or the system default script type...
Definition: xehelper.cxx:643
FontStrikeout GetStrikeout() const
const OUString & GetRepresentation() const
const sal_Unicode EXC_URL_SUBDIR
Root directory of current drive.
Definition: xlconst.hxx:96
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
Definition: xeroot.cxx:75
OUString maUrlList
Cell position to set at the HLINK record.
Definition: xehelper.hxx:200
sal_uInt16 mnCol
Definition: xladdress.hxx:32
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:30
ITALIC_NONE
bool IsRGBEqual(const Color &rColor) const
bool HasLinkRecord() const
Returns true, if a single HLINK record has been created.
Definition: xehelper.cxx:324
const sal_uInt8 EXC_FONTUNDERL_SINGLE
Definition: xlstyle.hxx:120
Progress bar for complex progress representation.
ScMatValType nType
Definition: scmatrix.hxx:57
static void AppendString(XclExpString &rXclString, const XclExpRoot &rRoot, const OUString &rString)
Appends an unformatted string to an Excel string object.
Definition: xehelper.cxx:545
const sal_uInt8 EXC_CACHEDVAL_EMPTY
Definition: xlconst.hxx:115
static OUString EncodeDde(const OUString &rApplic, const OUString &rTopic)
Encodes and returns the passed DDE link to an Excel like DDE link.
Definition: xehelper.cxx:983
const sal_uInt16 EXC_FONTWGHT_NORMAL
Definition: xlstyle.hxx:111
bool ValidateRange(ScRange &rScRange, bool bWarn)
Checks and eventually crops the cell range to valid dimensions.
Definition: xehelper.cxx:210
virtual ~XclExpProgressBar() override
Definition: xehelper.cxx:73
FormulaError
sal_Int16 GetDefApiScript() const
Returns the default script type, e.g.
Definition: xlroot.hxx:155
SCCOL Col() const
Definition: address.hxx:267
sal_Int32 GetParagraphCount() const
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xeroot.hxx:119
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:161
const OUString & GetURL() const
ScfProgressBar * mpSubProgress
Progress bar implementation.
Definition: xehelper.hxx:65
SCTAB GetScTabCount() const
Returns the number of Calc sheets.
Definition: xelink.hxx:90
const svl::SharedString & GetString() const
Only valid if ScMatrix methods indicate so!
Definition: scmatrix.hxx:60
const sal_uInt8 EXC_CACHEDVAL_DOUBLE
Definition: xlconst.hxx:116
const sal_uInt16 EXC_FONTESC_SUPER
Definition: xlstyle.hxx:127
sal_Int32 SCROW
Definition: types.hxx:18
SC_DLLPUBLIC void PutInOrder()
Definition: address.cxx:1573
const Color & GetColor() const
ScEditEngineDefaulter & GetEditEngine() const
Returns the edit engine for import/export of rich strings etc.
Definition: xlroot.cxx:356
std::size_t mnRowCount
Progress segment for finalizing ROW records.
Definition: xehelper.hxx:73
sal_Int32 mnTotalHeight
The last generated header/footer string.
Definition: xehelper.hxx:389
void IncRef() const
Definition: scmatrix.cxx:2844
static XclExpStringRef CreateCellString(const XclExpRoot &rRoot, const OUString &rString, const ScPatternAttr *pCellAttr, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Creates a new formatted string from a Calc string cell.
Definition: xehelper.cxx:561
FontWeight GetWeight()
const sal_uInt8 EXC_CACHEDVAL_STRING
Definition: xlconst.hxx:117
ITALIC_NORMAL
static SC_DLLPUBLIC OUString addToken(const OUString &rTokenList, const OUString &rToken, sal_Unicode cSep, sal_Int32 nSepCount=1, bool bForceSep=false)
Adds the string rToken to rTokenList, using a list separator character.
Definition: global.cxx:656
unsigned char sal_uInt8
virtual OutlinerParaObject * GetOutlinerParaObject() const override
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
bool GetUpdateMode() const
XclExpProgressBar(const XclExpRoot &rRoot)
Definition: xehelper.cxx:62
void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList)
SC_DLLPUBLIC bool GetTableArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow) const
Definition: document.cxx:1029
Stores the data of all fonts used in the document.
Definition: xestyle.hxx:208
sal_uInt16 mnWeight
Font height in twips (1/20 of a point).
Definition: xlstyle.hxx:292
void AppendPortion(const EditTextObject *pTextObj, sal_Unicode cPortionCode)
Converts the text object contents and stores it in the passed string.
Definition: xehelper.cxx:679
static void AppendChar(XclExpString &rXclString, const XclExpRoot &rRoot, sal_Unicode cChar)
Appends a character to an Excel string object.
Definition: xehelper.cxx:553
void Save(XclExpStream &rStrm) const
Writes the complete matrix to stream.
Definition: xehelper.cxx:1020
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
Definition: document.cxx:6056
bool mbRowTrunc
Flag for "columns truncated" warning box.
Definition: xladdress.hxx:165
const sal_uInt8 EXC_FONTUNDERL_NONE
Definition: xlstyle.hxx:119
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:141
Base class for import/export address converters.
Definition: xladdress.hxx:139
OUString ProcessUrlField(const SvxURLField &rUrlField)
Processes the passed URL field (tries to create a HLINK record).
Definition: xehelper.cxx:302
void TraceInvalidAddress(const ScAddress &rPos, const ScAddress &rMaxPos)
Definition: xltracer.cxx:49
const sal_Unicode EXC_URL_DRIVEROOT
DOS drive letter or UNC server name.
Definition: xlconst.hxx:95
FontLineStyle GetUnderline() const
void ValidateRangeList(ScRangeList &rScRanges, bool bWarn)
Checks and eventually crops the cell ranges to valid dimensions.
Definition: xehelper.cxx:255
static XclExpStringRef CreateString(const XclExpRoot &rRoot, const OUString &rString, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Creates a new unformatted string from the passed string.
Definition: xehelper.cxx:526
const OUString & GetBasePath() const
Returns the base path of the imported/exported file.
Definition: xlroot.hxx:173
constexpr sal_uInt16 EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
Color maColor
String with styles (bold, italic).
Definition: xlstyle.hxx:290
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
Definition: xlroot.cxx:281
std::shared_ptr< XclExpString > XclExpStringRef
Definition: xeroot.hxx:36
LINESTYLE_DOUBLE
STRIKEOUT_NONE
const XclExpRoot & GetRoot() const
Returns the filter root data.
Definition: xestream.hxx:86
ScfProgressBar * mpSubRowFinal
Segment ID's for all sheets in sub progress bar.
Definition: xehelper.hxx:70
void AppendByte(const OUString &rString, rtl_TextEncoding eTextEnc)
Appends a string.
Definition: xestring.cxx:136
const sal_uInt8 EXC_FONTUNDERL_DOUBLE
Definition: xlstyle.hxx:121
bool mbStrikeout
true = Italic.
Definition: xlstyle.hxx:298
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
XclExpFontBuffer & GetFontBuffer() const
Returns the font buffer.
Definition: xeroot.cxx:111
virtual ~XclExpHyperlinkHelper() override
Definition: xehelper.cxx:298
aStr
bool CheckAddress(const ScAddress &rScPos, bool bWarn)
Checks if the passed Calc cell address is valid.
Definition: xehelper.cxx:165
bool ConvertAddress(XclAddress &rXclPos, const ScAddress &rScPos, bool bWarn)
Converts the passed Calc cell address to an Excel cell address.
Definition: xehelper.cxx:186
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:58
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:23
sal_Int32 AddSegment(std::size_t nSize)
Adds a new segment to the progress bar.
void WriteZeroBytes(std::size_t nBytes)
Writes a sequence of nBytes zero bytes (respects slice setting).
Definition: xestream.cxx:256
OUString maName
Definition: xlstyle.hxx:288
sal_Int32 nStartPos