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