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, 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.subView( 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, 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  if( const SvxFieldItem* pItem = aEditSet.GetItemIfSet( EE_FEATURE_FIELD, false ) )
468  {
469  const SvxFieldData* pField = pItem->GetField();
470  if( const SvxURLField* pUrlField = dynamic_cast<const SvxURLField*>( pField ) )
471  {
472  // convert URL field to string representation
473  aXclPortionText = pLinkHelper ?
474  pLinkHelper->ProcessUrlField( *pUrlField ) :
475  lclGetUrlRepresentation( *pUrlField );
476  bIsHyperlink = true;
477  }
478  else
479  {
480  OSL_FAIL( "lclCreateFormattedString - unknown text field" );
481  aXclPortionText.clear();
482  }
483  }
484  }
485 
486  // Excel start position of this portion
487  sal_Int32 nXclPortionStart = xString->Len();
488  // add portion text to Excel string
489  XclExpStringHelper::AppendString( *xString, rRoot, aXclPortionText );
490  if( (nXclPortionStart < xString->Len()) || (aParaText.isEmpty()) )
491  {
492  /* Construct font from current edit engine text portion. Edit engine
493  creates different portions for different script types, no need to loop. */
494  sal_Int16 nScript = xBreakIt->getScriptType( aXclPortionText, 0 );
495  if( nScript == ApiScriptType::WEAK )
496  nScript = nLastScript;
497  SvxFont aFont( XclExpFontHelper::GetFontFromItemSet( rRoot, aItemSet, nScript ) );
498  nLastScript = nScript;
499 
500  // add escapement
501  aFont.SetEscapement( nEsc );
502  // modify automatic font color for hyperlinks
503  if( bIsHyperlink && aItemSet.Get( ATTR_FONT_COLOR ).GetValue() == COL_AUTO)
504  aFont.SetColor( COL_LIGHTBLUE );
505 
506  // insert font into buffer
507  sal_uInt16 nFontIdx = rFontBuffer.Insert( aFont, EXC_COLOR_CELLTEXT );
508  // insert font index into format run vector
509  xString->AppendFormat( nXclPortionStart, nFontIdx );
510  }
511 
512  aSel.nStartPos = aSel.nEndPos;
513  }
514 
515  // add trailing newline (important for correct character index calculation)
516  if( nPara + 1 < nParaCount )
517  XclExpStringHelper::AppendChar( *xString, rRoot, '\n' );
518  }
519 
520  return xString;
521 }
522 
523 } // namespace
524 
526  const XclExpRoot& rRoot, const OUString& rString, XclStrFlags nFlags, sal_uInt16 nMaxLen )
527 {
528  XclExpStringRef xString = std::make_shared<XclExpString>();
529  if( rRoot.GetBiff() == EXC_BIFF8 )
530  xString->Assign( rString, nFlags, nMaxLen );
531  else
532  xString->AssignByte( rString, rRoot.GetTextEncoding(), nFlags, nMaxLen );
533  return xString;
534 }
535 
537  const XclExpRoot& rRoot, sal_Unicode cChar, XclStrFlags nFlags, sal_uInt16 nMaxLen )
538 {
539  XclExpStringRef xString = CreateString( rRoot, OUString(), nFlags, nMaxLen );
540  AppendChar( *xString, rRoot, cChar );
541  return xString;
542 }
543 
544 void XclExpStringHelper::AppendString( XclExpString& rXclString, const XclExpRoot& rRoot, std::u16string_view rString )
545 {
546  if( rRoot.GetBiff() == EXC_BIFF8 )
547  rXclString.Append( rString );
548  else
549  rXclString.AppendByte( rString, rRoot.GetTextEncoding() );
550 }
551 
552 void XclExpStringHelper::AppendChar( XclExpString& rXclString, const XclExpRoot& rRoot, sal_Unicode cChar )
553 {
554  if( rRoot.GetBiff() == EXC_BIFF8 )
555  rXclString.Append( rtl::OUStringChar(cChar) );
556  else
557  rXclString.AppendByte( cChar, rRoot.GetTextEncoding() );
558 }
559 
561  const XclExpRoot& rRoot, const OUString& rString, const ScPatternAttr* pCellAttr,
562  XclStrFlags nFlags, sal_uInt16 nMaxLen )
563 {
564  return lclCreateFormattedString(rRoot, rString, pCellAttr, nFlags, nMaxLen);
565 }
566 
568  const XclExpRoot& rRoot, const EditTextObject& rEditText, const ScPatternAttr* pCellAttr,
569  XclExpHyperlinkHelper& rLinkHelper, XclStrFlags nFlags, sal_uInt16 nMaxLen )
570 {
571  XclExpStringRef xString;
572 
573  // formatted cell
574  ScEditEngineDefaulter& rEE = rRoot.GetEditEngine();
575  bool bOldUpdateMode = rEE.SetUpdateLayout( true );
576 
577  // default items
578  const SfxItemSet& rItemSet = pCellAttr ? pCellAttr->GetItemSet() : rRoot.GetDoc().GetDefPattern()->GetItemSet();
579  auto pEEItemSet = std::make_unique<SfxItemSet>( rEE.GetEmptyItemSet() );
580  ScPatternAttr::FillToEditItemSet( *pEEItemSet, rItemSet );
581  rEE.SetDefaults( std::move(pEEItemSet) ); // edit engine takes ownership
582 
583  // create the string
584  rEE.SetTextCurrentDefaults(rEditText);
585  xString = lclCreateFormattedString( rRoot, rEE, &rLinkHelper, nFlags, nMaxLen );
586  rEE.SetUpdateLayout( bOldUpdateMode );
587 
588  return xString;
589 }
590 
592  const XclExpRoot& rRoot, const SdrTextObj& rTextObj,
593  XclStrFlags nFlags )
594 {
595  XclExpStringRef xString;
596  if( const OutlinerParaObject* pParaObj = rTextObj.GetOutlinerParaObject() )
597  {
598  EditEngine& rEE = rRoot.GetDrawEditEngine();
599  bool bOldUpdateMode = rEE.SetUpdateLayout( true );
600  // create the string
601  rEE.SetText( pParaObj->GetTextObject() );
602  xString = lclCreateFormattedString( rRoot, rEE, nullptr, nFlags, EXC_STR_MAXLEN );
603  rEE.SetUpdateLayout( bOldUpdateMode );
604  // limit formats - TODO: BIFF dependent
605  if( !xString->IsEmpty() )
606  {
607  xString->LimitFormatCount( EXC_MAXRECSIZE_BIFF8 / 8 - 1 );
608  xString->AppendTrailingFormat( EXC_FONT_APP );
609  }
610  }
611  else
612  {
613  OSL_FAIL( "XclExpStringHelper::CreateString - textbox without para object" );
614  // create BIFF dependent empty Excel string
615  xString = CreateString( rRoot, OUString(), nFlags );
616  }
617  return xString;
618 }
619 
621  const XclExpRoot& rRoot, const EditTextObject& rEditObj,
622  XclStrFlags nFlags )
623 {
624  XclExpStringRef xString;
625  EditEngine& rEE = rRoot.GetDrawEditEngine();
626  bool bOldUpdateMode = rEE.SetUpdateLayout( true );
627  rEE.SetText( rEditObj );
628  xString = lclCreateFormattedString( rRoot, rEE, nullptr, nFlags, EXC_STR_MAXLEN );
629  rEE.SetUpdateLayout( bOldUpdateMode );
630  // limit formats - TODO: BIFF dependent
631  if( !xString->IsEmpty() )
632  {
633  xString->LimitFormatCount( EXC_MAXRECSIZE_BIFF8 / 8 - 1 );
634  xString->AppendTrailingFormat( EXC_FONT_APP );
635  }
636  return xString;
637 }
638 
639 sal_Int16 XclExpStringHelper::GetLeadingScriptType( const XclExpRoot& rRoot, const OUString& rString )
640 {
641  namespace ApiScriptType = ::com::sun::star::i18n::ScriptType;
642  Reference< XBreakIterator > xBreakIt = rRoot.GetDoc().GetBreakIterator();
643  sal_Int32 nStrPos = 0;
644  sal_Int32 nStrLen = rString.getLength();
645  sal_Int16 nScript = ApiScriptType::WEAK;
646  while( (nStrPos < nStrLen) && (nScript == ApiScriptType::WEAK) )
647  {
648  nScript = xBreakIt->getScriptType( rString, nStrPos );
649  nStrPos = xBreakIt->endOfScript( rString, nStrPos, nScript );
650  }
651  return (nScript == ApiScriptType::WEAK) ? rRoot.GetDefApiScript() : nScript;
652 }
653 
654 // Header/footer conversion ===================================================
655 
657  XclExpRoot( rRoot ),
658  mrEE( rRoot.GetHFEditEngine() ),
659  mnTotalHeight( 0 )
660 {
661 }
662 
664  const EditTextObject* pLeftObj,
665  const EditTextObject* pCenterObj,
666  const EditTextObject* pRightObj )
667 {
668  maHFString.clear();
669  mnTotalHeight = 0;
670  AppendPortion( pLeftObj, 'L' );
671  AppendPortion( pCenterObj, 'C' );
672  AppendPortion( pRightObj, 'R' );
673 }
674 
675 void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unicode cPortionCode )
676 {
677  if( !pTextObj ) return;
678 
679  OUString aText;
680  sal_Int32 nHeight = 0;
682 
683  // edit engine
684  bool bOldUpdateMode = mrEE.SetUpdateLayout( true );
685  mrEE.SetText( *pTextObj );
686 
687  // font information
688  XclFontData aFontData, aNewData;
689  if( const XclExpFont* pFirstFont = GetFontBuffer().GetFont( EXC_FONT_APP ) )
690  {
691  aFontData = pFirstFont->GetFontData();
692  aFontData.mnHeight = (aFontData.mnHeight + 10) / 20; // using pt here, not twips
693  }
694  else
695  aFontData.mnHeight = 10;
696 
697  const FontList* pFontList = nullptr;
698  if( SfxObjectShell* pDocShell = GetDocShell() )
699  {
700  if( const SvxFontListItem* pInfoItem = static_cast< const SvxFontListItem* >(
701  pDocShell->GetItem( SID_ATTR_CHAR_FONTLIST ) ) )
702  pFontList = pInfoItem->GetFontList();
703  }
704 
705  sal_Int32 nParaCount = mrEE.GetParagraphCount();
706  for( sal_Int32 nPara = 0; nPara < nParaCount; ++nPara )
707  {
708  ESelection aSel( nPara, 0 );
709  OUStringBuffer aParaText;
710  sal_Int32 nParaHeight = 0;
711  std::vector<sal_Int32> aPosList;
712  mrEE.GetPortions( nPara, aPosList );
713 
714  for( const auto& rPos : aPosList )
715  {
716  aSel.nEndPos = rPos;
717  if( aSel.nStartPos < aSel.nEndPos )
718  {
719 
720 // --- font attributes ---
721 
722  vcl::Font aFont;
723  aItemSet.ClearItem();
724  SfxItemSet aEditSet( mrEE.GetAttribs( aSel ) );
725  ScPatternAttr::GetFromEditItemSet( aItemSet, aEditSet );
726  ScPatternAttr::GetFont( aFont, aItemSet, SC_AUTOCOL_RAW );
727 
728  // font name and style
729  aNewData.maName = XclTools::GetXclFontName( aFont.GetFamilyName() );
731  aNewData.mbItalic = (aFont.GetItalic() != ITALIC_NONE);
732  bool bNewFont = (aFontData.maName != aNewData.maName);
733  bool bNewStyle = (aFontData.mnWeight != aNewData.mnWeight) ||
734  (aFontData.mbItalic != aNewData.mbItalic);
735  if( bNewFont || (bNewStyle && pFontList) )
736  {
737  aParaText.append("&\"" + aNewData.maName);
738  if( pFontList )
739  {
740  FontMetric aFontMetric( pFontList->Get(
741  aNewData.maName,
743  aNewData.mbItalic ? ITALIC_NORMAL : ITALIC_NONE ) );
744  aNewData.maStyle = pFontList->GetStyleName( aFontMetric );
745  if( !aNewData.maStyle.isEmpty() )
746  aParaText.append("," + aNewData.maStyle);
747  }
748  aParaText.append("\"");
749  }
750 
751  // height
752  // is calculated wrong in ScPatternAttr::GetFromEditItemSet, because already in twips and not 100thmm
753  // -> get it directly from edit engine item set
754  aNewData.mnHeight = ulimit_cast< sal_uInt16 >( aEditSet.Get( EE_CHAR_FONTHEIGHT ).GetHeight() );
755  aNewData.mnHeight = (aNewData.mnHeight + 10) / 20;
756  bool bFontHtChanged = (aFontData.mnHeight != aNewData.mnHeight);
757  if( bFontHtChanged )
758  aParaText.append("&" + OUString::number(aNewData.mnHeight));
759  // update maximum paragraph height, convert to twips
760  nParaHeight = ::std::max< sal_Int32 >( nParaHeight, aNewData.mnHeight * 20 );
761 
762  // underline
763  aNewData.mnUnderline = EXC_FONTUNDERL_NONE;
764  switch( aFont.GetUnderline() )
765  {
766  case LINESTYLE_NONE: aNewData.mnUnderline = EXC_FONTUNDERL_NONE; break;
767  case LINESTYLE_SINGLE: aNewData.mnUnderline = EXC_FONTUNDERL_SINGLE; break;
768  case LINESTYLE_DOUBLE: aNewData.mnUnderline = EXC_FONTUNDERL_DOUBLE; break;
769  default: aNewData.mnUnderline = EXC_FONTUNDERL_SINGLE;
770  }
771  if( aFontData.mnUnderline != aNewData.mnUnderline )
772  {
773  sal_uInt8 nTmpUnderl = (aNewData.mnUnderline == EXC_FONTUNDERL_NONE) ?
774  aFontData.mnUnderline : aNewData.mnUnderline;
775  (nTmpUnderl == EXC_FONTUNDERL_SINGLE)? aParaText.append("&U") : aParaText.append("&E");
776  }
777 
778  // font color
779  aNewData.maColor = aFont.GetColor();
780  if ( !aFontData.maColor.IsRGBEqual( aNewData.maColor ) )
781  {
782  aParaText.append("&K" + aNewData.maColor.AsRGBHexString());
783  }
784 
785  // strikeout
786  aNewData.mbStrikeout = (aFont.GetStrikeout() != STRIKEOUT_NONE);
787  if( aFontData.mbStrikeout != aNewData.mbStrikeout )
788  aParaText.append("&S");
789 
790  // super/sub script
791  const SvxEscapementItem& rEscapeItem = aEditSet.Get( EE_CHAR_ESCAPEMENT );
792  aNewData.SetScEscapement( rEscapeItem.GetEsc() );
793  if( aFontData.mnEscapem != aNewData.mnEscapem )
794  {
795  switch(aNewData.mnEscapem)
796  {
797  // close the previous super/sub script.
798  case EXC_FONTESC_NONE: (aFontData.mnEscapem == EXC_FONTESC_SUPER) ? aParaText.append("&X") : aParaText.append("&Y"); break;
799  case EXC_FONTESC_SUPER: aParaText.append("&X"); break;
800  case EXC_FONTESC_SUB: aParaText.append("&Y"); break;
801  default: break;
802  }
803  }
804 
805  aFontData = aNewData;
806 
807 // --- text content or text fields ---
808 
809  const SvxFieldItem* pItem;
810  if( (aSel.nStartPos + 1 == aSel.nEndPos) && // fields are single characters
811  (pItem = aEditSet.GetItemIfSet( EE_FEATURE_FIELD, false )) )
812  {
813  if( const SvxFieldData* pFieldData = pItem->GetField() )
814  {
815  if( dynamic_cast<const SvxPageField*>( pFieldData) != nullptr )
816  aParaText.append("&P");
817  else if( dynamic_cast<const SvxPagesField*>( pFieldData) != nullptr )
818  aParaText.append("&N");
819  else if( dynamic_cast<const SvxDateField*>( pFieldData) != nullptr )
820  aParaText.append("&D");
821  else if( dynamic_cast<const SvxTimeField*>( pFieldData) != nullptr || dynamic_cast<const SvxExtTimeField*>( pFieldData) != nullptr )
822  aParaText.append("&T");
823  else if( dynamic_cast<const SvxTableField*>( pFieldData) != nullptr )
824  aParaText.append("&A");
825  else if( dynamic_cast<const SvxFileField*>( pFieldData) != nullptr ) // title -> file name
826  aParaText.append("&F");
827  else if( const SvxExtFileField* pFileField = dynamic_cast<const SvxExtFileField*>( pFieldData ) )
828  {
829  switch( pFileField->GetFormat() )
830  {
831  case SvxFileFormat::NameAndExt:
832  case SvxFileFormat::NameOnly:
833  aParaText.append("&F");
834  break;
835  case SvxFileFormat::PathOnly:
836  aParaText.append("&Z");
837  break;
838  case SvxFileFormat::PathFull:
839  aParaText.append("&Z&F");
840  break;
841  default:
842  OSL_FAIL( "XclExpHFConverter::AppendPortion - unknown file field" );
843  }
844  }
845  }
846  }
847  else
848  {
849  OUString aPortionText( mrEE.GetText( aSel ) );
850  aPortionText = aPortionText.replaceAll( "&", "&&" );
851  // #i17440# space between font height and numbers in text
852  if( bFontHtChanged && aParaText.getLength() && !aPortionText.isEmpty() )
853  {
854  sal_Unicode cLast = aParaText[ aParaText.getLength() - 1 ];
855  sal_Unicode cFirst = aPortionText[0];
856  if( ('0' <= cLast) && (cLast <= '9') && ('0' <= cFirst) && (cFirst <= '9') )
857  aParaText.append(" ");
858  }
859  aParaText.append(aPortionText);
860  }
861  }
862 
863  aSel.nStartPos = aSel.nEndPos;
864  }
865 
866  aText = ScGlobal::addToken( aText, aParaText.makeStringAndClear(), '\n' );
867  if( nParaHeight == 0 )
868  nParaHeight = aFontData.mnHeight * 20; // points -> twips
869  nHeight += nParaHeight;
870  }
871 
872  mrEE.SetUpdateLayout( bOldUpdateMode );
873 
874  if( !aText.isEmpty() )
875  {
876  maHFString += "&" + OUStringChar(cPortionCode) + aText;
877  mnTotalHeight = ::std::max( mnTotalHeight, nHeight );
878  }
879 }
880 
881 // URL conversion =============================================================
882 
883 namespace {
884 
887 OUString lclEncodeDosUrl(
888  XclBiff eBiff, const OUString& rUrl, std::u16string_view rBase, const OUString* pTableName)
889 {
890  OUStringBuffer aBuf;
891 
892  if (!rUrl.isEmpty())
893  {
894  OUString aOldUrl = rUrl;
895  aBuf.append(EXC_URLSTART_ENCODED);
896 
897  if ( aOldUrl.getLength() > 2 && aOldUrl.startsWith("\\\\") )
898  {
899  // UNC
900  aBuf.append(EXC_URL_DOSDRIVE).append('@');
901  aOldUrl = aOldUrl.copy(2);
902  }
903  else if ( aOldUrl.getLength() > 2 && aOldUrl.match(":\\", 1) )
904  {
905  // drive letter
906  sal_Unicode cThisDrive = rBase.empty() ? ' ' : rBase[0];
907  sal_Unicode cDrive = aOldUrl[0];
908  if (cThisDrive == cDrive)
909  // This document and the referenced document are under the same drive.
910  aBuf.append(EXC_URL_DRIVEROOT);
911  else
912  aBuf.append(EXC_URL_DOSDRIVE).append(cDrive);
913  aOldUrl = aOldUrl.copy(3);
914  }
915  else
916  {
917  // URL probably points to a document on a Unix-like file system
918  aBuf.append(EXC_URL_DRIVEROOT);
919  }
920 
921  // directories
922  sal_Int32 nPos = -1;
923  while((nPos = aOldUrl.indexOf('\\')) != -1)
924  {
925  if ( aOldUrl.startsWith("..") )
926  // parent dir (NOTE: the MS-XLS spec doesn't mention this, and
927  // Excel seems confused by this token).
928  aBuf.append(EXC_URL_PARENTDIR);
929  else
930  aBuf.append(aOldUrl.subView(0,nPos)).append(EXC_URL_SUBDIR);
931 
932  aOldUrl = aOldUrl.copy(nPos + 1);
933  }
934 
935  // file name
936  if (pTableName) // enclose file name in brackets if table name follows
937  aBuf.append('[').append(aOldUrl).append(']');
938  else
939  aBuf.append(aOldUrl);
940  }
941  else // empty URL -> self reference
942  {
943  switch( eBiff )
944  {
945  case EXC_BIFF5:
946  aBuf.append(pTableName ? EXC_URLSTART_SELFENCODED : EXC_URLSTART_SELF);
947  break;
948  case EXC_BIFF8:
949  DBG_ASSERT( pTableName, "lclEncodeDosUrl - sheet name required for BIFF8" );
950  aBuf.append(EXC_URLSTART_SELF);
951  break;
952  default:
953  DBG_ERROR_BIFF();
954  }
955  }
956 
957  // table name
958  if (pTableName)
959  aBuf.append(*pTableName);
960 
961  // VirtualPath must be shorter than 255 chars ([MS-XLS].pdf 2.5.277)
962  // It's better to truncate, than generate invalid file that Excel cannot open.
963  if (aBuf.getLength() > 255)
964  aBuf.setLength(255);
965 
966  return aBuf.makeStringAndClear();
967 }
968 
969 } // namespace
970 
971 OUString XclExpUrlHelper::EncodeUrl( const XclExpRoot& rRoot, std::u16string_view rAbsUrl, const OUString* pTableName )
972 {
973  OUString aDosUrl = INetURLObject(rAbsUrl).getFSysPath(FSysStyle::Dos);
974  OUString aDosBase = INetURLObject(rRoot.GetBasePath()).getFSysPath(FSysStyle::Dos);
975  return lclEncodeDosUrl(rRoot.GetBiff(), aDosUrl, aDosBase, pTableName);
976 }
977 
978 OUString XclExpUrlHelper::EncodeDde( std::u16string_view rApplic, std::u16string_view rTopic )
979 {
980  return rApplic + OUStringChar(EXC_DDE_DELIM) + rTopic;
981 }
982 
983 // Cached Value Lists =========================================================
984 
986  : mrMatrix( rMatrix )
987 {
988  mrMatrix.IncRef();
989 }
991 {
992  mrMatrix.DecRef();
993 }
994 
995 void XclExpCachedMatrix::GetDimensions( SCSIZE & nCols, SCSIZE & nRows ) const
996 {
997  mrMatrix.GetDimensions( nCols, nRows );
998 
999  OSL_ENSURE( nCols && nRows, "XclExpCachedMatrix::GetDimensions - empty matrix" );
1000  OSL_ENSURE( nCols <= 256, "XclExpCachedMatrix::GetDimensions - too many columns" );
1001 }
1002 
1003 std::size_t XclExpCachedMatrix::GetSize() const
1004 {
1005  SCSIZE nCols, nRows;
1006 
1007  GetDimensions( nCols, nRows );
1008 
1009  /* The returned size may be wrong if the matrix contains strings. The only
1010  effect is that the export stream has to update a wrong record size which is
1011  faster than to iterate through all cached values and calculate their sizes. */
1012  return 3 + 9 * (nCols * nRows);
1013 }
1014 
1016 {
1017  SCSIZE nCols, nRows;
1018 
1019  GetDimensions( nCols, nRows );
1020 
1021  if( rStrm.GetRoot().GetBiff() <= EXC_BIFF5 )
1022  // in BIFF2-BIFF7: 256 columns represented by 0 columns
1023  rStrm << static_cast< sal_uInt8 >( nCols ) << static_cast< sal_uInt16 >( nRows );
1024  else
1025  // in BIFF8: columns and rows decreased by 1
1026  rStrm << static_cast< sal_uInt8 >( nCols - 1 ) << static_cast< sal_uInt16 >( nRows - 1 );
1027 
1028  for( SCSIZE nRow = 0; nRow < nRows; ++nRow )
1029  {
1030  for( SCSIZE nCol = 0; nCol < nCols; ++nCol )
1031  {
1032  ScMatrixValue nMatVal = mrMatrix.Get( nCol, nRow );
1033 
1034  FormulaError nScError;
1035  if( ScMatValType::Empty == nMatVal.nType )
1036  {
1037  rStrm.SetSliceSize( 9 );
1038  rStrm << EXC_CACHEDVAL_EMPTY;
1039  rStrm.WriteZeroBytes( 8 );
1040  }
1041  else if( ScMatrix::IsNonValueType( nMatVal.nType ) )
1042  {
1044  rStrm.SetSliceSize( 6 );
1045  rStrm << EXC_CACHEDVAL_STRING << aStr;
1046  }
1047  else if( ScMatValType::Boolean == nMatVal.nType )
1048  {
1049  sal_Int8 nBool = sal_Int8(nMatVal.GetBoolean());
1050  rStrm.SetSliceSize( 9 );
1051  rStrm << EXC_CACHEDVAL_BOOL << nBool;
1052  rStrm.WriteZeroBytes( 7 );
1053  }
1054  else if( (nScError = nMatVal.GetError()) != FormulaError::NONE )
1055  {
1056  sal_Int8 nError ( XclTools::GetXclErrorCode( nScError ) );
1057  rStrm.SetSliceSize( 9 );
1058  rStrm << EXC_CACHEDVAL_ERROR << nError;
1059  rStrm.WriteZeroBytes( 7 );
1060  }
1061  else
1062  {
1063  rStrm.SetSliceSize( 9 );
1064  rStrm << EXC_CACHEDVAL_DOUBLE << nMatVal.fVal;
1065  }
1066  }
1067  }
1068 }
1069 
1070 /* 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
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
static OUString EncodeUrl(const XclExpRoot &rRoot, std::u16string_view rAbsUrl, const OUString *pTableName=nullptr)
Encodes and returns the URL passed in rAbsUrl to an Excel like URL.
Definition: xehelper.cxx:971
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:43
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:561
ScAddress aStart
Definition: address.hxx:497
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
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:274
XclStrFlags
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:29
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
static void AppendString(XclExpString &rXclString, const XclExpRoot &rRoot, std::u16string_view rString)
Appends an unformatted string to an Excel string object.
Definition: xehelper.cxx:544
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
sal_uInt16 mnHeight
Font color.
Definition: xlstyle.hxx:290
ScAddress aEnd
Definition: address.hxx:498
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:601
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:985
void clear()
Definition: xladdress.hxx:113
const sal_uInt16 EXC_FONTESC_SUB
Definition: xlstyle.hxx:127
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6156
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
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
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:663
SCTAB Tab() const
Definition: address.hxx:283
void SetRow(SCROW nRowP)
Definition: address.hxx:287
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 SetCol(SCCOL nColP)
Definition: address.hxx:291
void GetDimensions(SCSIZE &nCols, SCSIZE &nRows) const
Definition: xehelper.cxx:995
const sal_Int32 SCF_INV_SEGMENT
void SetSliceSize(sal_uInt16 nSize)
Sets data slice length.
Definition: xestream.cxx:134
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:1093
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:1003
void SetTab(SCTAB nTabP)
Definition: address.hxx:295
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:251
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:616
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:833
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
SfxItemSet & GetItemSet()
Definition: patattr.hxx:155
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:639
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:75
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
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:279
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.hxx:622
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:665
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:1024
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:560
FontWeight GetWeight()
const sal_uInt8 EXC_CACHEDVAL_STRING
Definition: xlconst.hxx:116
ITALIC_NORMAL
unsigned char sal_uInt8
virtual OutlinerParaObject * GetOutlinerParaObject() const override
void Append(std::u16string_view rString)
Appends a string.
Definition: xestring.cxx:132
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:978
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:675
static void AppendChar(XclExpString &rXclString, const XclExpRoot &rRoot, sal_Unicode cChar)
Appends a character to an Excel string object.
Definition: xehelper.cxx:552
void Save(XclExpStream &rStrm) const
Writes the complete matrix to stream.
Definition: xehelper.cxx:1015
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
Definition: document.cxx:6151
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:44
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:525
const OUString & GetBasePath() const
Returns the base path of the imported/exported file.
Definition: xlroot.hxx:174
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: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: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:261
OUString maName
Definition: xlstyle.hxx:287
const SvxFieldData * GetField() const
bool m_bDetectedRangeSegmentation false
sal_Int32 nStartPos