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.SetUpdateLayout( true );
577 
578  // default items
579  const SfxItemSet& rItemSet = pCellAttr ? pCellAttr->GetItemSet() : rRoot.GetDoc().GetDefPattern()->GetItemSet();
580  auto pEEItemSet = std::make_unique<SfxItemSet>( rEE.GetEmptyItemSet() );
581  ScPatternAttr::FillToEditItemSet( *pEEItemSet, rItemSet );
582  rEE.SetDefaults( std::move(pEEItemSet) ); // edit engine takes ownership
583 
584  // create the string
585  rEE.SetTextCurrentDefaults(rEditText);
586  xString = lclCreateFormattedString( rRoot, rEE, &rLinkHelper, nFlags, nMaxLen );
587  rEE.SetUpdateLayout( bOldUpdateMode );
588 
589  return xString;
590 }
591 
593  const XclExpRoot& rRoot, const SdrTextObj& rTextObj,
594  XclStrFlags nFlags )
595 {
596  XclExpStringRef xString;
597  if( const OutlinerParaObject* pParaObj = rTextObj.GetOutlinerParaObject() )
598  {
599  EditEngine& rEE = rRoot.GetDrawEditEngine();
600  bool bOldUpdateMode = rEE.SetUpdateLayout( true );
601  // create the string
602  rEE.SetText( pParaObj->GetTextObject() );
603  xString = lclCreateFormattedString( rRoot, rEE, nullptr, nFlags, EXC_STR_MAXLEN );
604  rEE.SetUpdateLayout( bOldUpdateMode );
605  // limit formats - TODO: BIFF dependent
606  if( !xString->IsEmpty() )
607  {
608  xString->LimitFormatCount( EXC_MAXRECSIZE_BIFF8 / 8 - 1 );
609  xString->AppendTrailingFormat( EXC_FONT_APP );
610  }
611  }
612  else
613  {
614  OSL_FAIL( "XclExpStringHelper::CreateString - textbox without para object" );
615  // create BIFF dependent empty Excel string
616  xString = CreateString( rRoot, EMPTY_OUSTRING, nFlags );
617  }
618  return xString;
619 }
620 
622  const XclExpRoot& rRoot, const EditTextObject& rEditObj,
623  XclStrFlags nFlags )
624 {
625  XclExpStringRef xString;
626  EditEngine& rEE = rRoot.GetDrawEditEngine();
627  bool bOldUpdateMode = rEE.SetUpdateLayout( true );
628  rEE.SetText( rEditObj );
629  xString = lclCreateFormattedString( rRoot, rEE, nullptr, nFlags, EXC_STR_MAXLEN );
630  rEE.SetUpdateLayout( bOldUpdateMode );
631  // limit formats - TODO: BIFF dependent
632  if( !xString->IsEmpty() )
633  {
634  xString->LimitFormatCount( EXC_MAXRECSIZE_BIFF8 / 8 - 1 );
635  xString->AppendTrailingFormat( EXC_FONT_APP );
636  }
637  return xString;
638 }
639 
640 sal_Int16 XclExpStringHelper::GetLeadingScriptType( const XclExpRoot& rRoot, const OUString& rString )
641 {
642  namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
643  Reference< XBreakIterator > xBreakIt = rRoot.GetDoc().GetBreakIterator();
644  sal_Int32 nStrPos = 0;
645  sal_Int32 nStrLen = rString.getLength();
646  sal_Int16 nScript = ApiScriptType::WEAK;
647  while( (nStrPos < nStrLen) && (nScript == ApiScriptType::WEAK) )
648  {
649  nScript = xBreakIt->getScriptType( rString, nStrPos );
650  nStrPos = xBreakIt->endOfScript( rString, nStrPos, nScript );
651  }
652  return (nScript == ApiScriptType::WEAK) ? rRoot.GetDefApiScript() : nScript;
653 }
654 
655 // Header/footer conversion ===================================================
656 
658  XclExpRoot( rRoot ),
659  mrEE( rRoot.GetHFEditEngine() ),
660  mnTotalHeight( 0 )
661 {
662 }
663 
665  const EditTextObject* pLeftObj,
666  const EditTextObject* pCenterObj,
667  const EditTextObject* pRightObj )
668 {
669  maHFString.clear();
670  mnTotalHeight = 0;
671  AppendPortion( pLeftObj, 'L' );
672  AppendPortion( pCenterObj, 'C' );
673  AppendPortion( pRightObj, 'R' );
674 }
675 
676 void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unicode cPortionCode )
677 {
678  if( !pTextObj ) return;
679 
680  OUString aText;
681  sal_Int32 nHeight = 0;
683 
684  // edit engine
685  bool bOldUpdateMode = mrEE.SetUpdateLayout( true );
686  mrEE.SetText( *pTextObj );
687 
688  // font information
689  XclFontData aFontData, aNewData;
690  if( const XclExpFont* pFirstFont = GetFontBuffer().GetFont( EXC_FONT_APP ) )
691  {
692  aFontData = pFirstFont->GetFontData();
693  aFontData.mnHeight = (aFontData.mnHeight + 10) / 20; // using pt here, not twips
694  }
695  else
696  aFontData.mnHeight = 10;
697 
698  const FontList* pFontList = nullptr;
699  if( SfxObjectShell* pDocShell = GetDocShell() )
700  {
701  if( const SvxFontListItem* pInfoItem = static_cast< const SvxFontListItem* >(
702  pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) ) )
703  pFontList = pInfoItem->GetFontList();
704  }
705 
706  sal_Int32 nParaCount = mrEE.GetParagraphCount();
707  for( sal_Int32 nPara = 0; nPara < nParaCount; ++nPara )
708  {
709  ESelection aSel( nPara, 0 );
710  OUStringBuffer aParaText;
711  sal_Int32 nParaHeight = 0;
712  std::vector<sal_Int32> aPosList;
713  mrEE.GetPortions( nPara, aPosList );
714 
715  for( const auto& rPos : aPosList )
716  {
717  aSel.nEndPos = rPos;
718  if( aSel.nStartPos < aSel.nEndPos )
719  {
720 
721 // --- font attributes ---
722 
723  vcl::Font aFont;
724  aItemSet.ClearItem();
725  SfxItemSet aEditSet( mrEE.GetAttribs( aSel ) );
726  ScPatternAttr::GetFromEditItemSet( aItemSet, aEditSet );
727  ScPatternAttr::GetFont( aFont, aItemSet, SC_AUTOCOL_RAW );
728 
729  // font name and style
730  aNewData.maName = XclTools::GetXclFontName( aFont.GetFamilyName() );
732  aNewData.mbItalic = (aFont.GetItalic() != ITALIC_NONE);
733  bool bNewFont = (aFontData.maName != aNewData.maName);
734  bool bNewStyle = (aFontData.mnWeight != aNewData.mnWeight) ||
735  (aFontData.mbItalic != aNewData.mbItalic);
736  if( bNewFont || (bNewStyle && pFontList) )
737  {
738  aParaText.append("&\"" + aNewData.maName);
739  if( pFontList )
740  {
741  FontMetric aFontMetric( pFontList->Get(
742  aNewData.maName,
744  aNewData.mbItalic ? ITALIC_NORMAL : ITALIC_NONE ) );
745  aNewData.maStyle = pFontList->GetStyleName( aFontMetric );
746  if( !aNewData.maStyle.isEmpty() )
747  aParaText.append("," + aNewData.maStyle);
748  }
749  aParaText.append("\"");
750  }
751 
752  // height
753  // is calculated wrong in ScPatternAttr::GetFromEditItemSet, because already in twips and not 100thmm
754  // -> get it directly from edit engine item set
755  aNewData.mnHeight = ulimit_cast< sal_uInt16 >( aEditSet.Get( EE_CHAR_FONTHEIGHT ).GetHeight() );
756  aNewData.mnHeight = (aNewData.mnHeight + 10) / 20;
757  bool bFontHtChanged = (aFontData.mnHeight != aNewData.mnHeight);
758  if( bFontHtChanged )
759  aParaText.append("&" + OUString::number(aNewData.mnHeight));
760  // update maximum paragraph height, convert to twips
761  nParaHeight = ::std::max< sal_Int32 >( nParaHeight, aNewData.mnHeight * 20 );
762 
763  // underline
764  aNewData.mnUnderline = EXC_FONTUNDERL_NONE;
765  switch( aFont.GetUnderline() )
766  {
767  case LINESTYLE_NONE: aNewData.mnUnderline = EXC_FONTUNDERL_NONE; break;
768  case LINESTYLE_SINGLE: aNewData.mnUnderline = EXC_FONTUNDERL_SINGLE; break;
769  case LINESTYLE_DOUBLE: aNewData.mnUnderline = EXC_FONTUNDERL_DOUBLE; break;
770  default: aNewData.mnUnderline = EXC_FONTUNDERL_SINGLE;
771  }
772  if( aFontData.mnUnderline != aNewData.mnUnderline )
773  {
774  sal_uInt8 nTmpUnderl = (aNewData.mnUnderline == EXC_FONTUNDERL_NONE) ?
775  aFontData.mnUnderline : aNewData.mnUnderline;
776  (nTmpUnderl == EXC_FONTUNDERL_SINGLE)? aParaText.append("&U") : aParaText.append("&E");
777  }
778 
779  // font color
780  aNewData.maColor = aFont.GetColor();
781  if ( !aFontData.maColor.IsRGBEqual( aNewData.maColor ) )
782  {
783  aParaText.append("&K" + aNewData.maColor.AsRGBHexString());
784  }
785 
786  // strikeout
787  aNewData.mbStrikeout = (aFont.GetStrikeout() != STRIKEOUT_NONE);
788  if( aFontData.mbStrikeout != aNewData.mbStrikeout )
789  aParaText.append("&S");
790 
791  // super/sub script
792  const SvxEscapementItem& rEscapeItem = aEditSet.Get( EE_CHAR_ESCAPEMENT );
793  aNewData.SetScEscapement( rEscapeItem.GetEsc() );
794  if( aFontData.mnEscapem != aNewData.mnEscapem )
795  {
796  switch(aNewData.mnEscapem)
797  {
798  // close the previous super/sub script.
799  case EXC_FONTESC_NONE: (aFontData.mnEscapem == EXC_FONTESC_SUPER) ? aParaText.append("&X") : aParaText.append("&Y"); break;
800  case EXC_FONTESC_SUPER: aParaText.append("&X"); break;
801  case EXC_FONTESC_SUB: aParaText.append("&Y"); break;
802  default: break;
803  }
804  }
805 
806  aFontData = aNewData;
807 
808 // --- text content or text fields ---
809 
810  const SfxPoolItem* pItem;
811  if( (aSel.nStartPos + 1 == aSel.nEndPos) && // fields are single characters
812  (aEditSet.GetItemState( EE_FEATURE_FIELD, false, &pItem ) == SfxItemState::SET) )
813  {
814  if( const SvxFieldData* pFieldData = static_cast< const SvxFieldItem* >( pItem )->GetField() )
815  {
816  if( dynamic_cast<const SvxPageField*>( pFieldData) != nullptr )
817  aParaText.append("&P");
818  else if( dynamic_cast<const SvxPagesField*>( pFieldData) != nullptr )
819  aParaText.append("&N");
820  else if( dynamic_cast<const SvxDateField*>( pFieldData) != nullptr )
821  aParaText.append("&D");
822  else if( dynamic_cast<const SvxTimeField*>( pFieldData) != nullptr || dynamic_cast<const SvxExtTimeField*>( pFieldData) != nullptr )
823  aParaText.append("&T");
824  else if( dynamic_cast<const SvxTableField*>( pFieldData) != nullptr )
825  aParaText.append("&A");
826  else if( dynamic_cast<const SvxFileField*>( pFieldData) != nullptr ) // title -> file name
827  aParaText.append("&F");
828  else if( const SvxExtFileField* pFileField = dynamic_cast<const SvxExtFileField*>( pFieldData ) )
829  {
830  switch( pFileField->GetFormat() )
831  {
832  case SvxFileFormat::NameAndExt:
833  case SvxFileFormat::NameOnly:
834  aParaText.append("&F");
835  break;
836  case SvxFileFormat::PathOnly:
837  aParaText.append("&Z");
838  break;
839  case SvxFileFormat::PathFull:
840  aParaText.append("&Z&F");
841  break;
842  default:
843  OSL_FAIL( "XclExpHFConverter::AppendPortion - unknown file field" );
844  }
845  }
846  }
847  }
848  else
849  {
850  OUString aPortionText( mrEE.GetText( aSel ) );
851  aPortionText = aPortionText.replaceAll( "&", "&&" );
852  // #i17440# space between font height and numbers in text
853  if( bFontHtChanged && aParaText.getLength() && !aPortionText.isEmpty() )
854  {
855  sal_Unicode cLast = aParaText[ aParaText.getLength() - 1 ];
856  sal_Unicode cFirst = aPortionText[0];
857  if( ('0' <= cLast) && (cLast <= '9') && ('0' <= cFirst) && (cFirst <= '9') )
858  aParaText.append(" ");
859  }
860  aParaText.append(aPortionText);
861  }
862  }
863 
864  aSel.nStartPos = aSel.nEndPos;
865  }
866 
867  aText = ScGlobal::addToken( aText, aParaText.makeStringAndClear(), '\n' );
868  if( nParaHeight == 0 )
869  nParaHeight = aFontData.mnHeight * 20; // points -> twips
870  nHeight += nParaHeight;
871  }
872 
873  mrEE.SetUpdateLayout( bOldUpdateMode );
874 
875  if( !aText.isEmpty() )
876  {
877  maHFString += "&" + OUStringChar(cPortionCode) + aText;
878  mnTotalHeight = ::std::max( mnTotalHeight, nHeight );
879  }
880 }
881 
882 // URL conversion =============================================================
883 
884 namespace {
885 
888 OUString lclEncodeDosUrl(
889  XclBiff eBiff, const OUString& rUrl, std::u16string_view rBase, const OUString* pTableName)
890 {
891  OUStringBuffer aBuf;
892 
893  if (!rUrl.isEmpty())
894  {
895  OUString aOldUrl = rUrl;
896  aBuf.append(EXC_URLSTART_ENCODED);
897 
898  if ( aOldUrl.getLength() > 2 && aOldUrl.startsWith("\\\\") )
899  {
900  // UNC
901  aBuf.append(EXC_URL_DOSDRIVE).append('@');
902  aOldUrl = aOldUrl.copy(2);
903  }
904  else if ( aOldUrl.getLength() > 2 && aOldUrl.match(":\\", 1) )
905  {
906  // drive letter
907  sal_Unicode cThisDrive = rBase.empty() ? ' ' : rBase[0];
908  sal_Unicode cDrive = aOldUrl[0];
909  if (cThisDrive == cDrive)
910  // This document and the referenced document are under the same drive.
911  aBuf.append(EXC_URL_DRIVEROOT);
912  else
913  aBuf.append(EXC_URL_DOSDRIVE).append(cDrive);
914  aOldUrl = aOldUrl.copy(3);
915  }
916  else
917  {
918  // URL probably points to a document on a Unix-like file system
919  aBuf.append(EXC_URL_DRIVEROOT);
920  }
921 
922  // directories
923  sal_Int32 nPos = -1;
924  while((nPos = aOldUrl.indexOf('\\')) != -1)
925  {
926  if ( aOldUrl.startsWith("..") )
927  // parent dir (NOTE: the MS-XLS spec doesn't mention this, and
928  // Excel seems confused by this token).
929  aBuf.append(EXC_URL_PARENTDIR);
930  else
931  aBuf.append(aOldUrl.subView(0,nPos)).append(EXC_URL_SUBDIR);
932 
933  aOldUrl = aOldUrl.copy(nPos + 1);
934  }
935 
936  // file name
937  if (pTableName) // enclose file name in brackets if table name follows
938  aBuf.append('[').append(aOldUrl).append(']');
939  else
940  aBuf.append(aOldUrl);
941  }
942  else // empty URL -> self reference
943  {
944  switch( eBiff )
945  {
946  case EXC_BIFF5:
947  aBuf.append(pTableName ? EXC_URLSTART_SELFENCODED : EXC_URLSTART_SELF);
948  break;
949  case EXC_BIFF8:
950  DBG_ASSERT( pTableName, "lclEncodeDosUrl - sheet name required for BIFF8" );
951  aBuf.append(EXC_URLSTART_SELF);
952  break;
953  default:
954  DBG_ERROR_BIFF();
955  }
956  }
957 
958  // table name
959  if (pTableName)
960  aBuf.append(*pTableName);
961 
962  // VirtualPath must be shorter than 255 chars ([MS-XLS].pdf 2.5.277)
963  // It's better to truncate, than generate invalid file that Excel cannot open.
964  if (aBuf.getLength() > 255)
965  aBuf.setLength(255);
966 
967  return aBuf.makeStringAndClear();
968 }
969 
970 } // namespace
971 
972 OUString XclExpUrlHelper::EncodeUrl( const XclExpRoot& rRoot, const OUString& rAbsUrl, const OUString* pTableName )
973 {
974  OUString aDosUrl = INetURLObject(rAbsUrl).getFSysPath(FSysStyle::Dos);
975  OUString aDosBase = INetURLObject(rRoot.GetBasePath()).getFSysPath(FSysStyle::Dos);
976  return lclEncodeDosUrl(rRoot.GetBiff(), aDosUrl, aDosBase, pTableName);
977 }
978 
979 OUString XclExpUrlHelper::EncodeDde( std::u16string_view rApplic, std::u16string_view rTopic )
980 {
981  return rApplic + OUStringChar(EXC_DDE_DELIM) + rTopic;
982 }
983 
984 // Cached Value Lists =========================================================
985 
987  : mrMatrix( rMatrix )
988 {
989  mrMatrix.IncRef();
990 }
992 {
993  mrMatrix.DecRef();
994 }
995 
996 void XclExpCachedMatrix::GetDimensions( SCSIZE & nCols, SCSIZE & nRows ) const
997 {
998  mrMatrix.GetDimensions( nCols, nRows );
999 
1000  OSL_ENSURE( nCols && nRows, "XclExpCachedMatrix::GetDimensions - empty matrix" );
1001  OSL_ENSURE( nCols <= 256, "XclExpCachedMatrix::GetDimensions - too many columns" );
1002 }
1003 
1004 std::size_t XclExpCachedMatrix::GetSize() const
1005 {
1006  SCSIZE nCols, nRows;
1007 
1008  GetDimensions( nCols, nRows );
1009 
1010  /* The returned size may be wrong if the matrix contains strings. The only
1011  effect is that the export stream has to update a wrong record size which is
1012  faster than to iterate through all cached values and calculate their sizes. */
1013  return 3 + 9 * (nCols * nRows);
1014 }
1015 
1017 {
1018  SCSIZE nCols, nRows;
1019 
1020  GetDimensions( nCols, nRows );
1021 
1022  if( rStrm.GetRoot().GetBiff() <= EXC_BIFF5 )
1023  // in BIFF2-BIFF7: 256 columns represented by 0 columns
1024  rStrm << static_cast< sal_uInt8 >( nCols ) << static_cast< sal_uInt16 >( nRows );
1025  else
1026  // in BIFF8: columns and rows decreased by 1
1027  rStrm << static_cast< sal_uInt8 >( nCols - 1 ) << static_cast< sal_uInt16 >( nRows - 1 );
1028 
1029  for( SCSIZE nRow = 0; nRow < nRows; ++nRow )
1030  {
1031  for( SCSIZE nCol = 0; nCol < nCols; ++nCol )
1032  {
1033  ScMatrixValue nMatVal = mrMatrix.Get( nCol, nRow );
1034 
1035  FormulaError nScError;
1036  if( ScMatValType::Empty == nMatVal.nType )
1037  {
1038  rStrm.SetSliceSize( 9 );
1039  rStrm << EXC_CACHEDVAL_EMPTY;
1040  rStrm.WriteZeroBytes( 8 );
1041  }
1042  else if( ScMatrix::IsNonValueType( nMatVal.nType ) )
1043  {
1045  rStrm.SetSliceSize( 6 );
1046  rStrm << EXC_CACHEDVAL_STRING << aStr;
1047  }
1048  else if( ScMatValType::Boolean == nMatVal.nType )
1049  {
1050  sal_Int8 nBool = sal_Int8(nMatVal.GetBoolean());
1051  rStrm.SetSliceSize( 9 );
1052  rStrm << EXC_CACHEDVAL_BOOL << nBool;
1053  rStrm.WriteZeroBytes( 7 );
1054  }
1055  else if( (nScError = nMatVal.GetError()) != FormulaError::NONE )
1056  {
1057  sal_Int8 nError ( XclTools::GetXclErrorCode( nScError ) );
1058  rStrm.SetSliceSize( 9 );
1059  rStrm << EXC_CACHEDVAL_ERROR << nError;
1060  rStrm.WriteZeroBytes( 7 );
1061  }
1062  else
1063  {
1064  rStrm.SetSliceSize( 9 );
1065  rStrm << EXC_CACHEDVAL_DOUBLE << nMatVal.fVal;
1066  }
1067  }
1068  }
1069 }
1070 
1071 /* 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:180
static bool IsNonValueType(ScMatValType nType)
String, empty or empty path, but not value nor boolean.
Definition: scmatrix.hxx:190
ScAddress maMaxPos
Tracer for invalid addresses.
Definition: xladdress.hxx:161
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:112
const sal_Unicode EXC_URLSTART_SELF
Encoded URL.
Definition: xlconst.hxx:89
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:972
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:47
EditEngine & GetDrawEditEngine() const
Returns the edit engine for import/export of drawing text boxes.
Definition: xlroot.cxx:404
OUString GetText(LineEnd eEnd=LINEEND_LF) const
#define DBG_ERROR_BIFF()
Definition: xltools.hxx:33
const sal_uInt16 EXC_STR_MAXLEN
Definition: xlstring.hxx:42
const sal_Unicode EXC_URL_PARENTDIR
Directory name delimiter.
Definition: xlconst.hxx:96
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:883
XclExpHyperlinkRef mxLinkRec
Definition: xehelper.hxx:200
sal_Int32 mnSegRowFinal
Sub progress bar for finalizing ROW records.
Definition: xehelper.hxx:73
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:29
void SetDefaults(const SfxItemSet &rDefaults, bool bRememberCopy=true)
Creates a copy of SfxItemSet if bRememberCopy set.
Definition: editutil.cxx:541
ScAddress aStart
Definition: address.hxx:499
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:773
#define EMPTY_OUSTRING
Definition: global.hxx:214
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:72
SCROW Row() const
Definition: address.hxx:261
XclStrFlags
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:28
const SfxItemSet & GetEmptyItemSet() const
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:201
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:1192
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:285
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:3040
ScfProgressBarPtr mxProgress
Definition: xehelper.hxx:66
aBuf
const SfxItemSet & GetItemSet() const
sal_uInt16 mnHeight
Font color.
Definition: xlstyle.hxx:290
ScAddress aEnd
Definition: address.hxx:500
XclAddress maLast
Definition: xladdress.hxx:61
ScfProgressBar * mpSubRowCreate
Current sub progress bar.
Definition: xehelper.hxx:69
sal_uInt32 mnRow
Definition: xladdress.hxx:32
const sal_uInt16 EXC_MAXRECSIZE_BIFF8
Definition: xlstream.hxx:30
EditEngine & mrEE
Definition: xehelper.hxx:389
XclAddress maFirst
Definition: xladdress.hxx:60
const sal_uInt8 EXC_CACHEDVAL_ERROR
Definition: xlconst.hxx:118
const sal_Unicode EXC_URLSTART_ENCODED
Definition: xlconst.hxx:88
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
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:552
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:52
XclExpCachedMatrix(const ScMatrix &rMatrix)
Constructs and fills a new matrix.
Definition: xehelper.cxx:986
void clear()
Definition: xladdress.hxx:113
const sal_uInt16 EXC_FONTESC_SUB
Definition: xlstyle.hxx:127
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6087
WEIGHT_BOLD
const sal_uInt16 EXC_FONTWGHT_BOLD
Definition: xlstyle.hxx:113
const sal_Unicode EXC_DDE_DELIM
Sheet name starts here (BIFF4).
Definition: xlconst.hxx:100
sal_uInt16 sal_Unicode
FontItalic GetItalic()
double fVal
Definition: scmatrix.hxx:54
Access to global data from other classes.
Definition: xeroot.hxx:112
const sal_uInt16 EXC_FONT_APP
Definition: xlstyle.hxx:76
bool GetBoolean() const
Only valid if ScMatrix methods indicate that this is a boolean.
Definition: scmatrix.hxx:65
static OUString GetXclFontName(const OUString &rFontName)
Returns the matching Excel font name for a passed Calc font name.
Definition: xltools.cxx:455
LINESTYLE_NONE
void SetText(const OUString &rStr)
MS Excel 4.0.
Definition: xlconst.hxx:34
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:44
ReturnType ulimit_cast(Type nValue, ReturnType nMax)
Returns the value, if it is not greater than nMax, otherwise nMax.
Definition: ftools.hxx:53
Helper to create HLINK records during creation of formatted cell strings.
Definition: xehelper.hxx:177
bool mbMultipleUrls
List with all processed URLs.
Definition: xehelper.hxx:203
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:125
ScfInt32Vec maSubSegRowCreate
Sub progress bar for creating table rows.
Definition: xehelper.hxx:70
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:664
SCTAB Tab() const
Definition: address.hxx:270
void SetRow(SCROW nRowP)
Definition: address.hxx:274
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:296
void DecRef() const
Definition: scmatrix.cxx:2795
const OUString & GetStyleName(FontWeight eWeight, FontItalic eItalic) const
void Append(const OUString &rString)
Appends a string.
Definition: xestring.cxx:132
void SetCol(SCCOL nColP)
Definition: address.hxx:278
void GetDimensions(SCSIZE &nCols, SCSIZE &nRows) const
Definition: xehelper.cxx:996
const sal_Int32 SCF_INV_SEGMENT
void SetSliceSize(sal_uInt16 nSize)
Sets data slice length.
Definition: xestream.cxx:131
const sal_Unicode EXC_URLSTART_SELFENCODED
Reference to own workbook.
Definition: xlconst.hxx:90
void Progress(std::size_t nDelta=1)
Increase current segment by the passed value.
void Remove(size_t nPos)
Definition: rangelst.cxx:1105
FormulaError GetError() const
Only valid if ScMatrix methods indicate that this is no string!
Definition: scmatrix.hxx:62
std::size_t GetSize() const
Returns the byte count of all contained data.
Definition: xehelper.cxx:1004
void SetTab(SCTAB nTabP)
Definition: address.hxx:282
sal_uInt16 mnEscapem
Boldness: 400=normal, 700=bold.
Definition: xlstyle.hxx:292
void SetScEscapement(short nScEscapem)
Sets the Calc escapement style.
Definition: xlstyle.cxx:372
Stores all data of an Excel font and provides export of FONT records.
Definition: xestyle.hxx:153
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:35
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:215
OUString maStyle
Font name.
Definition: xlstyle.hxx:288
void Activate()
Starts the progress bar (with first segment).
sal_uInt8 mnUnderline
Windows character set.
Definition: xlstyle.hxx:295
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:596
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:201
void GetDimensions(SCSIZE &rC, SCSIZE &rR) const
Definition: scmatrix.cxx:2930
sal_Int16 SCCOL
Definition: types.hxx:21
OUString maHFString
The header/footer edit engine.
Definition: xehelper.hxx:390
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:781
bool mbColTrunc
Maximum row index.
Definition: xladdress.hxx:164
const sal_Unicode EXC_URL_DOSDRIVE
Reference to own workbook (BIFF5/BIFF7).
Definition: xlconst.hxx:93
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:89
WEIGHT_NORMAL
LINESTYLE_SINGLE
Stores the correct Excel sheet index for each Calc sheet.
Definition: xelink.hxx:61
const sal_uInt8 EXC_CACHEDVAL_BOOL
Definition: xlconst.hxx:117
const ScMatrix & mrMatrix
Definition: xehelper.hxx:435
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:640
FontStrikeout GetStrikeout() const
const OUString & GetRepresentation() const
const sal_Unicode EXC_URL_SUBDIR
Root directory of current drive.
Definition: xlconst.hxx:95
XclExpTabInfo & GetTabInfo() const
Returns the buffer for Calc->Excel sheet index conversion.
Definition: xeroot.cxx:77
OUString maUrlList
Cell position to set at the HLINK record.
Definition: xehelper.hxx:202
sal_uInt16 mnCol
Definition: xladdress.hxx:31
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:29
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
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
const sal_uInt8 EXC_FONTUNDERL_SINGLE
Definition: xlstyle.hxx:119
Progress bar for complex progress representation.
ScMatValType nType
Definition: scmatrix.hxx:56
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:114
const sal_uInt16 EXC_FONTWGHT_NORMAL
Definition: xlstyle.hxx:110
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:266
sal_Int32 GetParagraphCount() const
const XclExpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xeroot.hxx:118
bool SetUpdateLayout(bool bUpdate, bool bRestoring=false)
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:162
const OUString & GetURL() const
ScfProgressBar * mpSubProgress
Progress bar implementation.
Definition: xehelper.hxx:67
SCTAB GetScTabCount() const
Returns the number of Calc sheets.
Definition: xelink.hxx:89
const svl::SharedString & GetString() const
Only valid if ScMatrix methods indicate so!
Definition: scmatrix.hxx:59
const sal_uInt8 EXC_CACHEDVAL_DOUBLE
Definition: xlconst.hxx:115
const sal_uInt16 EXC_FONTESC_SUPER
Definition: xlstyle.hxx:126
sal_Int32 SCROW
Definition: types.hxx:17
void PutInOrder()
Definition: address.cxx:1582
const Color & GetColor() const
ScEditEngineDefaulter & GetEditEngine() const
Returns the edit engine for import/export of rich strings etc.
Definition: xlroot.cxx:365
std::size_t mnRowCount
Progress segment for finalizing ROW records.
Definition: xehelper.hxx:75
static SC_DLLPUBLIC OUString addToken(std::u16string_view rTokenList, std::u16string_view 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:657
sal_Int32 mnTotalHeight
The last generated header/footer string.
Definition: xehelper.hxx:391
void IncRef() const
Definition: scmatrix.cxx:2790
SC_DLLPUBLIC bool GetTableArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bCalcHiddens=false) const
Definition: document.cxx:1021
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:116
ITALIC_NORMAL
unsigned char sal_uInt8
virtual OutlinerParaObject * GetOutlinerParaObject() const override
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
XclExpProgressBar(const XclExpRoot &rRoot)
Definition: xehelper.cxx:62
static OUString EncodeDde(std::u16string_view rApplic, std::u16string_view rTopic)
Encodes and returns the passed DDE link to an Excel like DDE link.
Definition: xehelper.cxx:979
void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList)
Stores the data of all fonts used in the document.
Definition: xestyle.hxx:206
sal_uInt16 mnWeight
Font height in twips (1/20 of a point).
Definition: xlstyle.hxx:291
void AppendPortion(const EditTextObject *pTextObj, sal_Unicode cPortionCode)
Converts the text object contents and stores it in the passed string.
Definition: xehelper.cxx:676
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:1016
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
Definition: document.cxx:6082
bool mbRowTrunc
Flag for "columns truncated" warning box.
Definition: xladdress.hxx:165
const sal_uInt8 EXC_FONTUNDERL_NONE
Definition: xlstyle.hxx:118
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:47
const sal_Unicode EXC_URL_DRIVEROOT
DOS drive letter or UNC server name.
Definition: xlconst.hxx:94
void AppendByte(std::u16string_view rString, rtl_TextEncoding eTextEnc)
Appends a string.
Definition: xestring.cxx:137
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:174
constexpr sal_uInt16 EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
Color maColor
String with styles (bold, italic).
Definition: xlstyle.hxx:289
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
Definition: xlroot.cxx:290
std::shared_ptr< XclExpString > XclExpStringRef
Definition: xeroot.hxx:35
LINESTYLE_DOUBLE
STRIKEOUT_NONE
const XclExpRoot & GetRoot() const
Returns the filter root data.
Definition: xestream.hxx:87
ScfProgressBar * mpSubRowFinal
Segment ID's for all sheets in sub progress bar.
Definition: xehelper.hxx:72
const sal_uInt8 EXC_FONTUNDERL_DOUBLE
Definition: xlstyle.hxx:120
bool mbStrikeout
true = Italic.
Definition: xlstyle.hxx:297
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
XclExpFontBuffer & GetFontBuffer() const
Returns the font buffer.
Definition: xeroot.cxx:113
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:22
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:258
OUString maName
Definition: xlstyle.hxx:287
sal_Int32 nStartPos