LibreOffice Module sc (master) 1
XclExpChangeTrack.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <memory>
21#include <numeric>
22#include <stdio.h>
23#include <sot/storage.hxx>
24#include <XclExpChangeTrack.hxx>
25#include <utility>
26#include <xeformula.hxx>
27#include <xehelper.hxx>
28#include <xltools.hxx>
29#include <formulacell.hxx>
30#include <document.hxx>
31#include <editutil.hxx>
32#include <root.hxx>
33#include <tools/Guid.hxx>
34
35#include <oox/export/utils.hxx>
36#include <oox/token/namespaces.hxx>
37#include <oox/token/tokens.hxx>
38#include <rtl/uuid.h>
39#include <svl/sharedstring.hxx>
40
41using namespace oox;
42
43static OString lcl_DateTimeToOString( const DateTime& rDateTime )
44{
45 char sBuf[ 200 ];
46 snprintf( sBuf, sizeof( sBuf ),
47 "%d-%02d-%02dT%02d:%02d:%02d.%09" SAL_PRIuUINT32 "Z",
48 rDateTime.GetYear(), rDateTime.GetMonth(), rDateTime.GetDay(),
49 rDateTime.GetHour(), rDateTime.GetMin(), rDateTime.GetSec(),
50 rDateTime.GetNanoSec() );
51 return sBuf;
52}
53
54// local functions
55
56static void lcl_WriteDateTime( XclExpStream& rStrm, const DateTime& rDateTime )
57{
58 rStrm.SetSliceSize( 7 );
59 rStrm << static_cast<sal_uInt16>(rDateTime.GetYear())
60 << static_cast<sal_uInt8>(rDateTime.GetMonth())
61 << static_cast<sal_uInt8>(rDateTime.GetDay())
62 << static_cast<sal_uInt8>(rDateTime.GetHour())
63 << static_cast<sal_uInt8>(rDateTime.GetMin())
64 << static_cast<sal_uInt8>(rDateTime.GetSec());
65 rStrm.SetSliceSize( 0 );
66}
67
68// write string and fill rest of <nLength> with zero bytes
69// <nLength> is without string header
70static void lcl_WriteFixedString( XclExpStream& rStrm, const XclExpString& rString, std::size_t nLength )
71{
72 std::size_t nStrBytes = rString.GetBufferSize();
73 OSL_ENSURE( nLength >= nStrBytes, "lcl_WriteFixedString - String too long" );
74 if( rString.Len() > 0 )
75 rStrm << rString;
76 if( nLength > nStrBytes )
77 rStrm.WriteZeroBytes( nLength - nStrBytes );
78}
79
80static void lcl_GenerateGUID( sal_uInt8* pGUID, bool& rValidGUID )
81{
82 rtl_createUuid( pGUID, rValidGUID ? pGUID : nullptr, false );
83 rValidGUID = true;
84}
85
86static void lcl_WriteGUID( XclExpStream& rStrm, const sal_uInt8* pGUID )
87{
88 rStrm.SetSliceSize( 16 );
89 for( std::size_t nIndex = 0; nIndex < 16; nIndex++ )
90 rStrm << pGUID[ nIndex ];
91 rStrm.SetSliceSize( 0 );
92}
93
94XclExpUserBView::XclExpUserBView( const OUString& rUsername, const sal_uInt8* pGUID ) :
95 sUsername( rUsername )
96{
97 memcpy( aGUID, pGUID, 16 );
98}
99
101{
102 rStrm << sal_uInt32(0xFF078014)
103 << sal_uInt32(0x00000001);
105 rStrm.WriteZeroBytes( 8 );
106 rStrm << sal_uInt32(1200)
107 << sal_uInt32(1000)
108 << sal_uInt16(1000)
109 << sal_uInt16(0x0CF7)
110 << sal_uInt16(0x0000)
111 << sal_uInt16(0x0001)
112 << sal_uInt16(0x0000);
113 if( sUsername.Len() > 0 )
114 rStrm << sUsername;
115}
116
117sal_uInt16 XclExpUserBView::GetNum() const
118{
119 return 0x01A9;
120}
121
122std::size_t XclExpUserBView::GetLen() const
123{
124 return 50 + ((sUsername.Len() > 0) ? sUsername.GetSize() : 0);
125}
126
128{
129 sal_uInt8 aGUID[ 16 ];
130 bool bValidGUID = false;
131 const std::set<OUString>& rStrColl = rChangeTrack.GetUserCollection();
132 aViews.reserve(rStrColl.size());
133 for (const auto& rStr : rStrColl)
134 {
135 lcl_GenerateGUID( aGUID, bValidGUID );
136 aViews.emplace_back( rStr, aGUID );
137 }
138}
139
141{
142}
143
145{
146 for( XclExpUserBView& rView : aViews )
147 rView.Save( rStrm );
148}
149
151 nCurrTab( nTab )
152{
153 memcpy( aGUID, pGUID, 16 );
154}
155
157{
159 rStrm << nCurrTab
160 << sal_uInt32(100)
161 << sal_uInt32(64)
162 << sal_uInt32(3)
163 << sal_uInt32(0x0000003C)
164 << sal_uInt16(0)
165 << sal_uInt16(3)
166 << sal_uInt16(0)
167 << sal_uInt16(3)
168 << double(0)
169 << double(0)
170 << sal_Int16(-1)
171 << sal_Int16(-1);
172}
173
175{
176 return 0x01AA;
177}
178
180{
181 return 64;
182}
183
185{
186 rStrm << sal_uInt16(0x0001);
187}
188
190{
191 return 0x01AB;
192}
193
194std::size_t XclExpUsersViewEnd::GetLen() const
195{
196 return 2;
197}
198
200{
201 rStrm << sal_uInt16(0x0000);
202}
203
204sal_uInt16 XclExpChTr0x0191::GetNum() const
205{
206 return 0x0191;
207}
208
209std::size_t XclExpChTr0x0191::GetLen() const
210{
211 return 2;
212}
213
215{
216 rStrm << sal_uInt16(0x0006)
217 << sal_uInt16(0x0000);
218}
219
220sal_uInt16 XclExpChTr0x0198::GetNum() const
221{
222 return 0x0198;
223}
224
225std::size_t XclExpChTr0x0198::GetLen() const
226{
227 return 4;
228}
229
231{
232 rStrm << sal_uInt16( 0x0022 );
233 rStrm.WriteZeroBytes( 510 );
234}
235
236sal_uInt16 XclExpChTr0x0192::GetNum() const
237{
238 return 0x0192;
239}
240
241std::size_t XclExpChTr0x0192::GetLen() const
242{
243 return 512;
244}
245
247{
248 rStrm << sal_uInt16(0x0000);
249}
250
251sal_uInt16 XclExpChTr0x0197::GetNum() const
252{
253 return 0x0197;
254}
255
256std::size_t XclExpChTr0x0197::GetLen() const
257{
258 return 2;
259}
260
262{
263}
264
265sal_uInt16 XclExpChTrEmpty::GetNum() const
266{
267 return nRecNum;
268}
269
270std::size_t XclExpChTrEmpty::GetLen() const
271{
272 return 0;
273}
274
276{
277}
278
280{
281 rStrm.WriteZeroBytes( 162 );
282}
283
284sal_uInt16 XclExpChTr0x0195::GetNum() const
285{
286 return 0x0195;
287}
288
289std::size_t XclExpChTr0x0195::GetLen() const
290{
291 return 162;
292}
293
295{
296}
297
299{
300 rStrm << sal_uInt32(0);
302 rStrm << sal_uInt8(0);
304}
305
306sal_uInt16 XclExpChTr0x0194::GetNum() const
307{
308 return 0x0194;
309}
310
311std::size_t XclExpChTr0x0194::GetLen() const
312{
313 return 162;
314}
315
317{
318}
319
321{
322 rStrm << sal_uInt16(0x0006)
323 << sal_uInt16(0x0000)
324 << sal_uInt16(0x000D);
327 rStrm << nCount
328 << sal_uInt16(0x0001)
329 << sal_uInt32(0x00000000)
330 << sal_uInt16(0x001E);
331}
332
333sal_uInt16 XclExpChTrHeader::GetNum() const
334{
335 return 0x0196;
336}
337
338std::size_t XclExpChTrHeader::GetLen() const
339{
340 return 50;
341}
342
343void XclExpChTrHeader::SaveXml( XclExpXmlStream& rRevisionHeadersStrm )
344{
345 sax_fastparser::FSHelperPtr pHeaders = rRevisionHeadersStrm.GetCurrentStream();
346 tools::Guid aGuid(aGUID);
347 rRevisionHeadersStrm.WriteAttributes(
348 XML_guid, aGuid.getString(),
349 XML_lastGuid, nullptr, // OOXTODO
350 XML_shared, nullptr, // OOXTODO
351 XML_diskRevisions, nullptr, // OOXTODO
352 XML_history, nullptr, // OOXTODO
353 XML_trackRevisions, nullptr, // OOXTODO
354 XML_exclusive, nullptr, // OOXTODO
355 XML_revisionId, nullptr, // OOXTODO
356 XML_version, nullptr, // OOXTODO
357 XML_keepChangeHistory, nullptr, // OOXTODO
358 XML_protected, nullptr, // OOXTODO
359 XML_preserveHistory, nullptr); // OOXTODO
360 pHeaders->write( ">" );
361}
362
364{
365 memcpy(maGUID, pGUID, 16);
366}
367
369{
370 sax_fastparser::FSHelperPtr pHeaders = rStrm.GetCurrentStream();
371
372 pHeaders->write("<")->writeId(XML_headers);
373
374 tools::Guid aGuid(maGUID);
375 rStrm.WriteAttributes(
376 XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)),
377 FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)),
378 XML_guid, aGuid.getString(),
379 XML_lastGuid, nullptr, // OOXTODO
380 XML_shared, nullptr, // OOXTODO
381 XML_diskRevisions, nullptr, // OOXTODO
382 XML_history, nullptr, // OOXTODO
383 XML_trackRevisions, nullptr, // OOXTODO
384 XML_exclusive, nullptr, // OOXTODO
385 XML_revisionId, nullptr, // OOXTODO
386 XML_version, nullptr, // OOXTODO
387 XML_keepChangeHistory, nullptr, // OOXTODO
388 XML_protected, nullptr, // OOXTODO
389 XML_preserveHistory, nullptr); // OOXTODO
390
391 pHeaders->write(">");
392}
393
395 OUString aUserName, const DateTime& rDateTime, const sal_uInt8* pGUID,
396 sal_Int32 nLogNumber, const XclExpChTrTabIdBuffer& rBuf ) :
397 maUserName(std::move(aUserName)), maDateTime(rDateTime), mnLogNumber(nLogNumber),
398 mnMinAction(0), mnMaxAction(0)
399{
400 memcpy(maGUID, pGUID, 16);
401 if (rBuf.GetBufferCount())
402 {
403 maTabBuffer.resize(rBuf.GetBufferCount());
404 rBuf.GetBufferCopy(maTabBuffer.data());
405 }
406}
407
409{
410 sax_fastparser::FSHelperPtr pHeader = rStrm.GetCurrentStream();
411
412 pHeader->write("<")->writeId(XML_header);
413
414 OUString aRelId;
415 sax_fastparser::FSHelperPtr pRevLogStrm = rStrm.CreateOutputStream(
416 XclXmlUtils::GetStreamName("xl/revisions/", "revisionLog", mnLogNumber),
417 XclXmlUtils::GetStreamName(nullptr, "revisionLog", mnLogNumber),
418 rStrm.GetCurrentStream()->getOutputStream(),
419 "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml",
420 CREATE_OFFICEDOC_RELATION_TYPE("revisionLog"),
421 &aRelId);
422
423 tools::Guid aGuid(maGUID);
424 rStrm.WriteAttributes(
425 XML_guid, aGuid.getString(),
426 XML_dateTime, lcl_DateTimeToOString(maDateTime),
427 XML_userName, maUserName,
428 FSNS(XML_r, XML_id), aRelId);
429
430 if (mnMinAction)
431 rStrm.WriteAttributes(XML_minRId, OUString::number(mnMinAction));
432
433 if (mnMaxAction)
434 rStrm.WriteAttributes(XML_maxRId, OUString::number(mnMaxAction));
435
436 if (!maTabBuffer.empty())
437 // next available sheet index.
438 rStrm.WriteAttributes(XML_maxSheetId, OUString::number(maTabBuffer.back()+1));
439
440 pHeader->write(">");
441
442 if (!maTabBuffer.empty())
443 {
444 // Write sheet index map.
445 size_t n = maTabBuffer.size();
446 pHeader->startElement(XML_sheetIdMap, XML_count, OString::number(n));
447
448 for (size_t i = 0; i < n; ++i)
449 {
450 pHeader->singleElement(XML_sheetId, XML_val, OString::number(maTabBuffer[i]));
451 }
452 pHeader->endElement(XML_sheetIdMap);
453 }
454
455 // Write all revision logs in a separate stream.
456
457 rStrm.PushStream(pRevLogStrm);
458
459 pRevLogStrm->write("<")->writeId(XML_revisions);
460
461 rStrm.WriteAttributes(
462 XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)),
463 FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)));
464
465 pRevLogStrm->write(">");
466
467 for (const auto& rxAction : maActions)
468 {
469 rxAction->SaveXml(rStrm);
470 }
471
472 pRevLogStrm->write("</")->writeId(XML_revisions)->write(">");
473
474 rStrm.PopStream();
475
476 pHeader->write("</")->writeId(XML_header)->write(">");
477}
478
479void XclExpXmlChTrHeader::AppendAction( std::unique_ptr<XclExpChTrAction> pAction )
480{
481 sal_uInt32 nActionNum = pAction->GetActionNumber();
482 if (!mnMinAction || mnMinAction > nActionNum)
483 mnMinAction = nActionNum;
484
485 if (!mnMaxAction || mnMaxAction < nActionNum)
486 mnMaxAction = nActionNum;
487
488 maActions.push_back(std::move(pAction));
489}
490
491XclExpChTrInfo::XclExpChTrInfo( const OUString& rUsername, const DateTime& rDateTime, const sal_uInt8* pGUID ) :
492 sUsername( rUsername ),
493 aDateTime( rDateTime )
494{
495 memcpy( aGUID, pGUID, 16 );
496}
497
499{
500}
501
503{
504 rStrm << sal_uInt32(0xFFFFFFFF)
505 << sal_uInt32(0x00000000)
506 << sal_uInt32(0x00000020)
507 << sal_uInt16(0xFFFF);
509 rStrm << sal_uInt16(0x04B0);
512 rStrm << sal_uInt8(0x0000)
513 << sal_uInt16(0x0002);
514}
515
516sal_uInt16 XclExpChTrInfo::GetNum() const
517{
518 return 0x0138;
519}
520
521std::size_t XclExpChTrInfo::GetLen() const
522{
523 return 158;
524}
525
527 nBufSize( nCount ),
528 nLastId( nCount )
529{
530 pBuffer.reset( new sal_uInt16[ nBufSize ] );
531 memset( pBuffer.get(), 0, sizeof(sal_uInt16) * nBufSize );
532 pLast = pBuffer.get() + nBufSize - 1;
533}
534
536 nBufSize( rCopy.nBufSize ),
537 nLastId( rCopy.nLastId )
538{
539 pBuffer.reset( new sal_uInt16[ nBufSize ] );
540 memcpy( pBuffer.get(), rCopy.pBuffer.get(), sizeof(sal_uInt16) * nBufSize );
541 pLast = pBuffer.get() + nBufSize - 1;
542}
543
545{
546}
547
548void XclExpChTrTabIdBuffer::InitFill( sal_uInt16 nIndex )
549{
550 OSL_ENSURE( nIndex < nLastId, "XclExpChTrTabIdBuffer::Insert - out of range" );
551
552 sal_uInt16 nFreeCount = 0;
553 for( sal_uInt16* pElem = pBuffer.get(); pElem <= pLast; pElem++ )
554 {
555 if( !*pElem )
556 nFreeCount++;
557 if( nFreeCount > nIndex )
558 {
559 *pElem = nLastId--;
560 return;
561 }
562 }
563}
564
566{
567 sal_uInt16 nFreeCount = 1;
568 for( sal_uInt16* pElem = pBuffer.get(); pElem <= pLast; pElem++ )
569 if( !*pElem )
570 *pElem = nFreeCount++;
572}
573
574sal_uInt16 XclExpChTrTabIdBuffer::GetId( sal_uInt16 nIndex ) const
575{
576 assert(nIndex < nBufSize && "XclExpChTrTabIdBuffer::GetId - out of range");
577 return pBuffer[ nIndex ];
578}
579
580bool XclExpChTrTabIdBuffer::HasId( sal_uInt16 nIndex ) const
581{
582 return nIndex < nBufSize;
583}
584
586{
587 OSL_ENSURE( pBuffer.get() <= pLast, "XclExpChTrTabIdBuffer::Remove - buffer empty" );
588 sal_uInt16* pElem = pBuffer.get();
589 while( (pElem <= pLast) && (*pElem != nLastId) )
590 pElem++;
591 while( pElem < pLast )
592 {
593 *pElem = *(pElem + 1);
594 pElem++;
595 }
596 pLast--;
597 nLastId--;
598}
599
601 : nTabCount( rBuffer.GetBufferCount() )
602{
603 pBuffer.reset( new sal_uInt16[ nTabCount ] );
604 rBuffer.GetBufferCopy( pBuffer.get() );
605}
606
608{
609 Clear();
610}
611
613{
614 Clear();
615 nTabCount = rBuffer.GetBufferCount();
616 pBuffer.reset( new sal_uInt16[ nTabCount ] );
617 rBuffer.GetBufferCopy( pBuffer.get() );
618}
619
621{
622 rStrm.EnableEncryption();
623 if( pBuffer )
624 rStrm.Write(pBuffer.get(), nTabCount);
625 else
626 for( sal_uInt16 nIndex = 1; nIndex <= nTabCount; nIndex++ )
627 rStrm << nIndex;
628}
629
630sal_uInt16 XclExpChTrTabId::GetNum() const
631{
632 return 0x013D;
633}
634
635std::size_t XclExpChTrTabId::GetLen() const
636{
637 return nTabCount << 1;
638}
639
640// ! does not copy additional actions
642 ExcRecord( rCopy ),
643 sUsername( rCopy.sUsername ),
644 aDateTime( rCopy.aDateTime ),
645 nIndex( 0 ),
646 bAccepted( rCopy.bAccepted ),
647 rTabInfo( rCopy.rTabInfo ),
648 rIdBuffer( rCopy.rIdBuffer ),
649 nLength( rCopy.nLength ),
650 nOpCode( rCopy.nOpCode ),
651 bForceInfo( rCopy.bForceInfo )
652{
653}
654
656 const ScChangeAction& rAction,
657 const XclExpRoot& rRoot,
658 const XclExpChTrTabIdBuffer& rTabIdBuffer,
659 sal_uInt16 nNewOpCode ) :
660 sUsername( rAction.GetUser() ),
661 aDateTime( rAction.GetDateTime() ),
662 nIndex( 0 ),
663 bAccepted( rAction.IsAccepted() ),
664 rTabInfo( rRoot.GetTabInfo() ),
665 rIdBuffer( rTabIdBuffer ),
666 nLength( 0 ),
667 nOpCode( nNewOpCode ),
668 bForceInfo( false )
669{
670 aDateTime.SetSec( 0 );
672}
673
675{
676}
677
679{
680 if( pAddAction )
681 pAddAction->SetAddAction( pAction );
682 else
683 pAddAction.reset( pAction );
684}
685
687 const ScChangeAction& rAction,
688 const XclExpRoot& rRoot,
689 const ScChangeTrack& rChangeTrack )
690{
691 ScChangeActionMap aActionMap;
692
693 rChangeTrack.GetDependents( const_cast<ScChangeAction*>(&rAction), aActionMap );
694 for( const auto& rEntry : aActionMap )
695 if( rEntry.second->GetType() == SC_CAT_CONTENT )
697 *static_cast<const ScChangeActionContent*>(rEntry.second), rRoot, rIdBuffer ) );
698}
699
700void XclExpChTrAction::SetIndex( sal_uInt32& rIndex )
701{
702 nIndex = rIndex++;
703}
704
706{
707 OSL_ENSURE( nOpCode != EXC_CHTR_OP_UNKNOWN, "XclExpChTrAction::SaveCont - unknown action" );
708 rStrm << nLength
709 << nIndex
710 << nOpCode
711 << static_cast<sal_uInt16>(bAccepted ? EXC_CHTR_ACCEPT : EXC_CHTR_NOTHING);
713}
714
716{
717}
718
720{
721}
722
724{
725 if (UsesDeletedTab())
726 {
727 SAL_WARN("sc", "XclExpChTrAction : unable to export position with tab of EXC_TAB_DELETED");
728 return;
729 }
732 if( pAddAction )
733 pAddAction->Save( rStrm );
735}
736
737std::size_t XclExpChTrAction::GetLen() const
738{
740}
741
743 mpFormulaCell( nullptr ),
744 fValue( 0.0 ),
745 nRKValue( 0 ),
747 nSize( 0 )
748{
749}
750
752{
753 Clear();
754}
755
757{
758 pString.reset();
759 mpFormulaCell = nullptr;
760 mxTokArr.reset();
761 maRefLog.clear();
762 fValue = 0.0;
763 nRKValue = 0;
765 nSize = 0;
766}
767
769{
770 OSL_ENSURE( mxTokArr && !mxTokArr->Empty(), "XclExpChTrData::Write - no formula" );
771 rStrm << *mxTokArr;
772
773 for( const auto& rLogEntry : maRefLog )
774 {
775 if( rLogEntry.mpUrl && rLogEntry.mpFirstTab )
776 {
777 rStrm << *rLogEntry.mpUrl << sal_uInt8(0x01) << *rLogEntry.mpFirstTab << sal_uInt8(0x02);
778 }
779 else
780 {
781 bool bSingleTab = rLogEntry.mnFirstXclTab == rLogEntry.mnLastXclTab;
782 rStrm.SetSliceSize( bSingleTab ? 6 : 8 );
783 rStrm << sal_uInt8(0x01) << sal_uInt8(0x02) << sal_uInt8(0x00);
784 rStrm << rTabIdBuffer.GetId( rLogEntry.mnFirstXclTab );
785 if( bSingleTab )
786 rStrm << sal_uInt8(0x02);
787 else
788 rStrm << sal_uInt8(0x00) << rTabIdBuffer.GetId( rLogEntry.mnLastXclTab );
789 }
790 }
791 rStrm.SetSliceSize( 0 );
792 rStrm << sal_uInt8(0x00);
793}
794
796{
797 switch( nType )
798 {
799 case EXC_CHTR_TYPE_RK:
800 rStrm << nRKValue;
801 break;
803 rStrm << fValue;
804 break;
806 OSL_ENSURE( pString, "XclExpChTrData::Write - no string" );
807 rStrm << *pString;
808 break;
810 WriteFormula( rStrm, rTabIdBuffer );
811 break;
812 }
813}
814
815static bool lcl_IsDeletedTab(const XclExpChTrTabIdBuffer& rTabIdBuffer, sal_uInt16 nIndex)
816{
817 return !rTabIdBuffer.HasId(nIndex);
818}
819
821{
823 return false;
824
825 for( const auto& rLogEntry : maRefLog )
826 {
827 if (rLogEntry.mpUrl && rLogEntry.mpFirstTab)
828 continue;
829 if (lcl_IsDeletedTab(rTabIdBuffer, rLogEntry.mnFirstXclTab))
830 return true;
831 bool bSingleTab = rLogEntry.mnFirstXclTab == rLogEntry.mnLastXclTab;
832 if (!bSingleTab)
833 continue;
834 if (lcl_IsDeletedTab(rTabIdBuffer, rLogEntry.mnLastXclTab))
835 return true;
836 }
837 return false;
838}
839
841 const ScChangeActionContent& rAction,
842 const XclExpRoot& rRoot,
843 const XclExpChTrTabIdBuffer& rTabIdBuffer ) :
844 XclExpChTrAction( rAction, rRoot, rTabIdBuffer, EXC_CHTR_OP_CELL ),
845 XclExpRoot( rRoot ),
846 aPosition( rAction.GetBigRange().MakeRange( rRoot.GetDoc()).aStart )
847{
848 sal_uInt32 nDummy32;
849 sal_uInt16 nDummy16;
850 GetCellData( rRoot, rAction.GetOldCell(), pOldData, nDummy32, nOldLength );
851 GetCellData( rRoot, rAction.GetNewCell(), pNewData, nLength, nDummy16 );
852}
853
855{
856 pOldData.reset();
857 pNewData.reset();
858}
859
860void XclExpChTrCellContent::MakeEmptyChTrData( std::unique_ptr<XclExpChTrData>& rpData )
861{
862 if( rpData )
863 rpData->Clear();
864 else
865 rpData.reset( new XclExpChTrData );
866}
867
869 const XclExpRoot& rRoot, const ScCellValue& rScCell,
870 std::unique_ptr<XclExpChTrData>& rpData, sal_uInt32& rXclLength1, sal_uInt16& rXclLength2 )
871{
872 MakeEmptyChTrData( rpData );
873 rXclLength1 = 0x0000003A;
874 rXclLength2 = 0x0000;
875
876 if (rScCell.isEmpty())
877 {
878 rpData.reset();
879 return;
880 }
881
882 switch (rScCell.getType())
883 {
884 case CELLTYPE_VALUE:
885 {
886 rpData->fValue = rScCell.getDouble();
887 if( XclTools::GetRKFromDouble( rpData->nRKValue, rpData->fValue ) )
888 {
889 rpData->nType = EXC_CHTR_TYPE_RK;
890 rpData->nSize = 4;
891 rXclLength1 = 0x0000003E;
892 rXclLength2 = 0x0004;
893 }
894 else
895 {
896 rpData->nType = EXC_CHTR_TYPE_DOUBLE;
897 rpData->nSize = 8;
898 rXclLength1 = 0x00000042;
899 rXclLength2 = 0x0008;
900 }
901 }
902 break;
903 case CELLTYPE_STRING:
904 case CELLTYPE_EDIT:
905 {
906 OUString sCellStr;
907 if (rScCell.getType() == CELLTYPE_STRING)
908 {
909 sCellStr = rScCell.getSharedString()->getString();
910 rpData->mpFormattedString = XclExpStringHelper::CreateCellString(
911 rRoot, sCellStr, nullptr);
912 }
913 else
914 {
915 XclExpHyperlinkHelper aLinkHelper( rRoot, aPosition );
916 if (rScCell.getEditText())
917 {
918 sCellStr = ScEditUtil::GetString(*rScCell.getEditText(), &GetDoc());
919 rpData->mpFormattedString = XclExpStringHelper::CreateCellString(
920 rRoot, *rScCell.getEditText(), nullptr, aLinkHelper);
921 }
922 else
923 {
924 rpData->mpFormattedString = XclExpStringHelper::CreateCellString(
925 rRoot, OUString(), nullptr);
926 }
927 }
928 rpData->pString.reset( new XclExpString( sCellStr, XclStrFlags::NONE, 32766 ) );
929 rpData->nType = EXC_CHTR_TYPE_STRING;
930 rpData->nSize = 3 + rpData->pString->GetSize();
931 rXclLength1 = 64 + (sCellStr.getLength() << 1);
932 rXclLength2 = 6 + static_cast<sal_uInt16>(sCellStr.getLength() << 1);
933 }
934 break;
935 case CELLTYPE_FORMULA:
936 {
937 const ScFormulaCell* pFmlCell = rScCell.getFormula();
938 rpData->mpFormulaCell = pFmlCell;
939
940 const ScTokenArray* pTokenArray = pFmlCell->GetCode();
941 if( pTokenArray )
942 {
943 XclExpRefLog& rRefLog = rpData->maRefLog;
944 rpData->mxTokArr = GetFormulaCompiler().CreateFormula(
945 EXC_FMLATYPE_CELL, *pTokenArray, &pFmlCell->aPos, &rRefLog );
946 rpData->nType = EXC_CHTR_TYPE_FORMULA;
947 std::size_t nSize = std::accumulate(rRefLog.begin(), rRefLog.end(),
948 static_cast<std::size_t>(rpData->mxTokArr->GetSize() + 3),
949 [](const std::size_t& rSum, const XclExpRefLogEntry& rLogEntry) {
950 if( rLogEntry.mpUrl && rLogEntry.mpFirstTab )
951 return rSum + rLogEntry.mpUrl->GetSize() + rLogEntry.mpFirstTab->GetSize() + 2;
952 else
953 return rSum + ((rLogEntry.mnFirstXclTab == rLogEntry.mnLastXclTab) ? 6 : 8);
954 });
955 rpData->nSize = ::std::min< std::size_t >( nSize, 0xFFFF );
956 rXclLength1 = 0x00000052;
957 rXclLength2 = 0x0018;
958 }
959 }
960 break;
961 default:;
962 }
963}
964
966{
968 return true;
969 if (pOldData && pOldData->UsesDeletedTab(rIdBuffer))
970 return true;
971 return pNewData && pNewData->UsesDeletedTab(rIdBuffer);
972}
973
975{
977 rStrm << static_cast<sal_uInt16>((pOldData ? (pOldData->nType << 3) : 0x0000) | (pNewData ? pNewData->nType : 0x0000))
978 << sal_uInt16(0x0000);
981 << sal_uInt32(0x00000000);
982 if( pOldData )
983 pOldData->Write( rStrm, rIdBuffer );
984 if( pNewData )
985 pNewData->Write( rStrm, rIdBuffer );
986}
987
989{
990 return 0x013B;
991}
992
994{
995 std::size_t nLen = 16;
996 if( pOldData )
997 nLen += pOldData->nSize;
998 if( pNewData )
999 nLen += pNewData->nSize;
1000 return nLen;
1001}
1002
1003static const char* lcl_GetType( XclExpChTrData* pData )
1004{
1005 switch( pData->nType )
1006 {
1007 case EXC_CHTR_TYPE_RK:
1009 return "n";
1011 {
1012 ScFormulaCell* pFormulaCell = const_cast< ScFormulaCell* >( pData->mpFormulaCell );
1013 const char* sType;
1014 OUString sValue;
1015 XclXmlUtils::GetFormulaTypeAndValue( *pFormulaCell, sType, sValue );
1016 return sType;
1017 }
1018 break;
1020 return "inlineStr";
1021 default:
1022 break;
1023 }
1024 return "*unknown*";
1025}
1026
1027static void lcl_WriteCell( XclExpXmlStream& rStrm, sal_Int32 nElement, const ScAddress& rPosition, XclExpChTrData* pData )
1028{
1029 sax_fastparser::FSHelperPtr pStream = rStrm.GetCurrentStream();
1030
1031 pStream->startElement(nElement,
1032 XML_r, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), rPosition),
1033 XML_s, nullptr, // OOXTODO: not supported
1034 XML_t, lcl_GetType(pData),
1035 XML_cm, nullptr, // OOXTODO: not supported
1036 XML_vm, nullptr, // OOXTODO: not supported
1037 XML_ph, nullptr); // OOXTODO: not supported
1038 switch( pData->nType )
1039 {
1040 case EXC_CHTR_TYPE_RK:
1042 pStream->startElement(XML_v);
1043 pStream->write( pData->fValue );
1044 pStream->endElement( XML_v );
1045 break;
1047 pStream->startElement( XML_f
1048 // OOXTODO: other attributes? see XclExpFormulaCell::SaveXml()
1049 );
1050 pStream->writeEscaped( XclXmlUtils::ToOUString(
1051 rStrm.GetRoot().GetCompileFormulaContext(),
1052 pData->mpFormulaCell->aPos, pData->mpFormulaCell->GetCode()));
1053 pStream->endElement( XML_f );
1054 break;
1056 pStream->startElement(XML_is);
1057 if( pData->mpFormattedString )
1058 pData->mpFormattedString->WriteXml( rStrm );
1059 else
1060 pData->pString->WriteXml( rStrm );
1061 pStream->endElement( XML_is );
1062 break;
1063 default:
1064 // ignore
1065 break;
1066 }
1067 pStream->endElement( nElement );
1068}
1069
1071{
1072 if (IsDeletedTab(aPosition.Tab()))
1073 {
1074 // seen on attempt to export tdf66241-1.ods to xlsx
1075 SAL_WARN("sc", "XclExpChTrCellContent: unable to export position with tab of EXC_TAB_DELETED");
1076 return;
1077 }
1078
1079 sax_fastparser::FSHelperPtr pStream = rRevisionLogStrm.GetCurrentStream();
1080 pStream->startElement( XML_rcc,
1081 XML_rId, OString::number(GetActionNumber()),
1082 XML_ua, ToPsz( GetAccepted () ), // OOXTODO? bAccepted == ua or ra; not sure.
1083 XML_ra, nullptr, // OOXTODO: RRD.fUndoAction? Or RRD.fAccepted?
1084 XML_sId, OString::number(GetTabId(aPosition.Tab())),
1085 XML_odxf, nullptr, // OOXTODO: not supported
1086 XML_xfDxf, nullptr, // OOXTODO: not supported
1087 XML_s, nullptr, // OOXTODO: not supported
1088 XML_dxf, nullptr, // OOXTODO: not supported
1089 XML_numFmtId, nullptr, // OOXTODO: not supported
1090 XML_quotePrefix, nullptr, // OOXTODO: not supported
1091 XML_oldQuotePrefix, nullptr, // OOXTODO: not supported
1092 XML_ph, nullptr, // OOXTODO: not supported
1093 XML_oldPh, nullptr, // OOXTODO: not supported
1094 XML_endOfListFormulaUpdate, nullptr); // OOXTODO: not supported
1095 if( pOldData )
1096 {
1097 lcl_WriteCell( rRevisionLogStrm, XML_oc, aPosition, pOldData.get() );
1098 if (!pNewData)
1099 {
1100 pStream->singleElement(XML_nc, XML_r, XclXmlUtils::ToOString(rRevisionLogStrm.GetRoot().GetDoc(), aPosition));
1101 }
1102 }
1103 if( pNewData )
1104 {
1105 lcl_WriteCell( rRevisionLogStrm, XML_nc, aPosition, pNewData.get() );
1106 }
1107 // OOXTODO: XML_odxf, XML_ndxf, XML_extLst elements
1108 pStream->endElement( XML_rcc );
1109}
1110
1112 XclExpChTrAction(rCopy),
1113 mbEndOfList(rCopy.mbEndOfList),
1114 aRange(rCopy.aRange) {}
1115
1117 const ScChangeAction& rAction,
1118 const XclExpRoot& rRoot,
1119 const XclExpChTrTabIdBuffer& rTabIdBuffer,
1120 const ScChangeTrack& rChangeTrack ) :
1121 XclExpChTrAction( rAction, rRoot, rTabIdBuffer ),
1122 mbEndOfList(false),
1123 aRange( rAction.GetBigRange().MakeRange( rRoot.GetDoc()) )
1124{
1125 nLength = 0x00000030;
1126 switch( rAction.GetType() )
1127 {
1129 case SC_CAT_INSERT_ROWS:
1130 {
1131 const ScChangeActionIns& rIns = static_cast<const ScChangeActionIns&>(rAction);
1132 mbEndOfList = rIns.IsEndOfList();
1134 }
1135 break;
1138 default:
1139 OSL_FAIL( "XclExpChTrInsert::XclExpChTrInsert - unknown action" );
1140 }
1141
1143 {
1144 aRange.aStart.SetRow( 0 );
1145 aRange.aEnd.SetRow( rRoot.GetXclMaxPos().Row() );
1146 }
1147 else
1148 {
1149 aRange.aStart.SetCol( 0 );
1150 aRange.aEnd.SetCol( rRoot.GetXclMaxPos().Col() );
1151 }
1152
1154 {
1155 SetAddAction( new XclExpChTr0x014A( *this ) );
1156 AddDependentContents( rAction, rRoot, rChangeTrack );
1157 }
1158}
1159
1161{
1162}
1163
1165{
1166 return IsDeletedTab(aRange.aStart.Tab());
1167}
1168
1170{
1172 sal_uInt16 nFlagVal = mbEndOfList ? 0x0001 : 0x0000;
1173 rStrm << nFlagVal;
1175 rStrm << sal_uInt32(0x00000000);
1176}
1177
1179{
1181 XclExpChTrEmpty( 0x0150 ).Save( rStrm );
1182}
1183
1185{
1187 XclExpChTrEmpty( 0x0151 ).Save( rStrm );
1188}
1189
1191{
1192 return 0x0137;
1193}
1194
1196{
1197 return 16;
1198}
1199
1200static const char* lcl_GetAction( sal_uInt16 nOpCode )
1201{
1202 switch( nOpCode )
1203 {
1204 case EXC_CHTR_OP_INSCOL: return "insertCol";
1205 case EXC_CHTR_OP_INSROW: return "insertRow";
1206 case EXC_CHTR_OP_DELCOL: return "deleteCol";
1207 case EXC_CHTR_OP_DELROW: return "deleteRow";
1208 default: return "*unknown*";
1209 }
1210}
1211
1213{
1215 {
1216 // seen on attempt to export tdf66241-1.ods to xlsx
1217 SAL_WARN("sc", "XclExpChTrCellContent: unable to export position with tab of EXC_TAB_DELETED");
1218 return;
1219 }
1220
1221 sax_fastparser::FSHelperPtr pStream = rRevisionLogStrm.GetCurrentStream();
1222 pStream->startElement( XML_rrc,
1223 XML_rId, OString::number(GetActionNumber()),
1224 XML_ua, ToPsz( GetAccepted () ), // OOXTODO? bAccepted == ua or ra; not sure.
1225 XML_ra, nullptr, // OOXTODO: RRD.fUndoAction? Or RRD.fAccepted?
1226 XML_sId, OString::number(GetTabId(aRange.aStart.Tab())),
1227 XML_eol, ToPsz10(mbEndOfList),
1228 XML_ref, XclXmlUtils::ToOString(rRevisionLogStrm.GetRoot().GetDoc(), aRange),
1229 XML_action, lcl_GetAction( nOpCode ),
1230 XML_edge, nullptr); // OOXTODO: ???
1231
1232 // OOXTODO: does this handle XML_rfmt, XML_undo?
1233 XclExpChTrAction* pAction = GetAddAction();
1234 while( pAction != nullptr )
1235 {
1236 pAction->SaveXml( rRevisionLogStrm );
1237 pAction = pAction->GetAddAction();
1238 }
1239 pStream->endElement( XML_rrc );
1240}
1241
1243 const ScChangeAction& rAction,
1244 const XclExpRoot& rRoot,
1245 const XclExpChTrTabIdBuffer& rTabIdBuffer ) :
1246 XclExpChTrAction( rAction, rRoot, rTabIdBuffer, EXC_CHTR_OP_INSTAB ),
1247 XclExpRoot( rRoot ),
1248 nTab( static_cast<SCTAB>(rAction.GetBigRange().aStart.Tab()) )
1249{
1250 nLength = 0x0000021C;
1251 bForceInfo = true;
1252}
1253
1255{
1256}
1257
1259{
1260 return IsDeletedTab(nTab);
1261}
1262
1264{
1265 WriteTabId( rStrm, nTab );
1266 rStrm << sal_uInt32( 0 );
1267 lcl_WriteFixedString( rStrm, XclExpString( GetTabInfo().GetScTabName( nTab ) ), 127 );
1269 rStrm.WriteZeroBytes( 133 );
1270}
1271
1273{
1274 return 0x014D;
1275}
1276
1278{
1279 return 276;
1280}
1281
1283{
1284 sax_fastparser::FSHelperPtr pStream = rStrm.GetCurrentStream();
1285 pStream->singleElement( XML_ris,
1286 XML_rId, OString::number(GetActionNumber()),
1287 XML_ua, ToPsz( GetAccepted () ), // OOXTODO? bAccepted == ua or ra; not sure.
1288 XML_ra, nullptr, // OOXTODO: RRD.fUndoAction? Or RRD.fAccepted?
1289 XML_sheetId, OString::number(GetTabId(nTab)),
1290 XML_name, GetTabInfo().GetScTabName(nTab).toUtf8(),
1291 XML_sheetPosition, OString::number(nTab) );
1292}
1293
1295 const ScChangeActionMove& rAction,
1296 const XclExpRoot& rRoot,
1297 const XclExpChTrTabIdBuffer& rTabIdBuffer,
1298 const ScChangeTrack& rChangeTrack ) :
1299 XclExpChTrAction( rAction, rRoot, rTabIdBuffer, EXC_CHTR_OP_MOVE ),
1300 aDestRange( rAction.GetBigRange().MakeRange( rRoot.GetDoc() ) )
1301{
1302 nLength = 0x00000042;
1304 sal_Int32 nDCols, nDRows, nDTabs;
1305 rAction.GetDelta( nDCols, nDRows, nDTabs );
1306 aSourceRange.aStart.IncRow( static_cast<SCROW>(-nDRows) );
1307 aSourceRange.aStart.IncCol( static_cast<SCCOL>(-nDCols) );
1308 aSourceRange.aStart.IncTab( static_cast<SCTAB>(-nDTabs) );
1309 aSourceRange.aEnd.IncRow( static_cast<SCROW>(-nDRows) );
1310 aSourceRange.aEnd.IncCol( static_cast<SCCOL>(-nDCols) );
1311 aSourceRange.aEnd.IncTab( static_cast<SCTAB>(-nDTabs) );
1312 AddDependentContents( rAction, rRoot, rChangeTrack );
1313}
1314
1316{
1317}
1318
1320{
1321 return IsDeletedTab(aDestRange.aStart.Tab()) ||
1323}
1324
1326{
1331 rStrm << sal_uInt32(0x00000000);
1332}
1333
1335{
1336 XclExpChTrEmpty( 0x014E ).Save( rStrm );
1337}
1338
1340{
1341 XclExpChTrEmpty( 0x014F ).Save( rStrm );
1342}
1343
1345{
1346 return 0x0140;
1347}
1348
1350{
1351 return 24;
1352}
1353
1355{
1357 {
1358 // seen on attempt to export tdf66241-1.ods to xlsx
1359 SAL_WARN("sc", "XclExpChTrCellContent: unable to export position with tab of EXC_TAB_DELETED");
1360 return;
1361 }
1362
1363 sax_fastparser::FSHelperPtr pStream = rRevisionLogStrm.GetCurrentStream();
1364
1365 pStream->startElement( XML_rm,
1366 XML_rId, OString::number(GetActionNumber()),
1367 XML_ua, ToPsz( GetAccepted () ), // OOXTODO? bAccepted == ua or ra; not sure.
1368 XML_ra, nullptr, // OOXTODO: RRD.fUndoAction? Or RRD.fAccepted?
1369 XML_sheetId, OString::number(GetTabId(aDestRange.aStart.Tab())),
1370 XML_source, XclXmlUtils::ToOString(rRevisionLogStrm.GetRoot().GetDoc(), aSourceRange),
1371 XML_destination, XclXmlUtils::ToOString(rRevisionLogStrm.GetRoot().GetDoc(), aDestRange),
1372 XML_sourceSheetId, OString::number(GetTabId(aSourceRange.aStart.Tab())) );
1373 // OOXTODO: does this handle XML_rfmt, XML_undo?
1374 XclExpChTrAction* pAction = GetAddAction();
1375 while( pAction != nullptr )
1376 {
1377 pAction->SaveXml( rRevisionLogStrm );
1378 pAction = pAction->GetAddAction();
1379 }
1380 pStream->endElement( XML_rm );
1381}
1382
1384 XclExpChTrInsert( rAction )
1385{
1386 nLength = 0x00000026;
1388}
1389
1391{
1392}
1393
1395{
1397 rStrm << sal_uInt16(0x0003)
1398 << sal_uInt16(0x0001);
1400}
1401
1403{
1404 return 0x014A;
1405}
1406
1408{
1409 return 14;
1410}
1411
1413{
1414 sax_fastparser::FSHelperPtr pStream = rStrm.GetCurrentStream();
1415
1416 pStream->startElement( XML_rfmt,
1417 XML_sheetId, OString::number(GetTabId(aRange.aStart.Tab())),
1418 XML_xfDxf, nullptr, // OOXTODO: not supported
1419 XML_s, nullptr, // OOXTODO: style
1420 XML_sqref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), aRange),
1421 XML_start, nullptr, // OOXTODO: for string changes
1422 XML_length, nullptr); // OOXTODO: for string changes
1423 // OOXTODO: XML_dxf, XML_extLst
1424
1425 pStream->endElement( XML_rfmt );
1426}
1427
1428std::size_t ExcXmlRecord::GetLen() const
1429{
1430 return 0;
1431}
1432
1433sal_uInt16 ExcXmlRecord::GetNum() const
1434{
1435 return 0;
1436}
1437
1439{
1440 // Do nothing; ignored for BIFF output.
1441}
1442
1443namespace {
1444
1445class EndXmlElement : public ExcXmlRecord
1446{
1447 sal_Int32 mnElement;
1448public:
1449 explicit EndXmlElement( sal_Int32 nElement ) : mnElement( nElement) {}
1450 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
1451};
1452
1453}
1454
1455void EndXmlElement::SaveXml( XclExpXmlStream& rStrm )
1456{
1457 sax_fastparser::FSHelperPtr pStream = rStrm.GetCurrentStream();
1458 pStream->write("</")->writeId(mnElement)->write(">");
1459}
1460
1462 XclExpRoot( rRoot ),
1463 pTabIdBuffer( nullptr )
1464{
1465 OSL_ENSURE( GetOldRoot().pTabId, "XclExpChangeTrack::XclExpChangeTrack - root data incomplete" );
1466 if( !GetOldRoot().pTabId )
1467 return;
1468
1469 ScChangeTrack* pTempChangeTrack = CreateTempChangeTrack();
1470 if (!pTempChangeTrack)
1471 return;
1472
1473 pTabIdBuffer = new XclExpChTrTabIdBuffer( GetTabInfo().GetXclTabCount() );
1474 maBuffers.push_back( std::unique_ptr<XclExpChTrTabIdBuffer>(pTabIdBuffer) );
1475
1476 // calculate final table order (tab id list)
1477 const ScChangeAction* pScAction;
1478 for( pScAction = pTempChangeTrack->GetLast(); pScAction; pScAction = pScAction->GetPrev() )
1479 {
1480 if( pScAction->GetType() == SC_CAT_INSERT_TABS )
1481 {
1482 SCTAB nScTab = static_cast< SCTAB >( pScAction->GetBigRange().aStart.Tab() );
1483 pTabIdBuffer->InitFill( GetTabInfo().GetXclTab( nScTab ) );
1484 }
1485 }
1488
1489 // get actions in reverse order
1490 pScAction = pTempChangeTrack->GetLast();
1491 while( pScAction )
1492 {
1493 PushActionRecord( *pScAction );
1494 const ScChangeAction* pPrevAction = pScAction->GetPrev();
1495 pScAction = pPrevAction;
1496 }
1497
1498 // build record list
1500 {
1501 XclExpChTrHeader* pHeader = new XclExpChTrHeader; // header record for last GUID
1502 maRecList.push_back( std::unique_ptr<ExcRecord>(pHeader) );
1503 maRecList.push_back( std::unique_ptr<ExcRecord>( new XclExpChTr0x0195 ) );
1504 maRecList.push_back( std::unique_ptr<ExcRecord>( new XclExpChTr0x0194( *pTempChangeTrack ) ) );
1505
1506 OUString sLastUsername;
1507 DateTime aLastDateTime( DateTime::EMPTY );
1508 sal_uInt32 nIndex = 1;
1509 sal_uInt8 aGUID[ 16 ]; // GUID for action info records
1510 bool bValidGUID = false;
1511 while( !aActionStack.empty() )
1512 {
1513 XclExpChTrAction* pAction = aActionStack.top();
1514 aActionStack.pop();
1515
1516 if( (nIndex == 1) || pAction->ForceInfoRecord() ||
1517 (pAction->GetUsername() != sLastUsername) ||
1518 (pAction->GetDateTime() != aLastDateTime) )
1519 {
1520 lcl_GenerateGUID( aGUID, bValidGUID );
1521 sLastUsername = pAction->GetUsername();
1522 aLastDateTime = pAction->GetDateTime();
1523
1524 maRecList.push_back( std::unique_ptr<ExcRecord>(new XclExpChTrInfo(sLastUsername, aLastDateTime, aGUID)) );
1525 maRecList.push_back( std::unique_ptr<ExcRecord>(new XclExpChTrTabId(pAction->GetTabIdBuffer())) );
1526 pHeader->SetGUID( aGUID );
1527 }
1528 pAction->SetIndex( nIndex );
1529 maRecList.push_back( std::unique_ptr<ExcRecord>(pAction) );
1530 }
1531
1532 pHeader->SetGUID( aGUID );
1533 pHeader->SetCount( nIndex - 1 );
1534 maRecList.push_back( std::unique_ptr<ExcRecord>(new ExcEof) );
1535 }
1536 else
1537 {
1539 maRecList.push_back( std::unique_ptr<ExcRecord>(pHeaders));
1540
1541 OUString sLastUsername;
1542 DateTime aLastDateTime(DateTime::EMPTY);
1543 sal_uInt32 nIndex = 1;
1544 sal_Int32 nLogNumber = 1;
1545 XclExpXmlChTrHeader* pCurHeader = nullptr;
1546 sal_uInt8 aGUID[ 16 ]; // GUID for action info records
1547 bool bValidGUID = false;
1548
1549 while (!aActionStack.empty())
1550 {
1551 XclExpChTrAction* pAction = aActionStack.top();
1552 aActionStack.pop();
1553
1554 if( (nIndex == 1) || pAction->ForceInfoRecord() ||
1555 (pAction->GetUsername() != sLastUsername) ||
1556 (pAction->GetDateTime() != aLastDateTime) )
1557 {
1558 lcl_GenerateGUID( aGUID, bValidGUID );
1559 sLastUsername = pAction->GetUsername();
1560 aLastDateTime = pAction->GetDateTime();
1561
1562 pCurHeader = new XclExpXmlChTrHeader(sLastUsername, aLastDateTime, aGUID, nLogNumber, pAction->GetTabIdBuffer());
1563 maRecList.push_back( std::unique_ptr<ExcRecord>(pCurHeader));
1564 nLogNumber++;
1565 pHeaders->SetGUID(aGUID);
1566 }
1567 pAction->SetIndex(nIndex);
1568 pCurHeader->AppendAction(std::unique_ptr<XclExpChTrAction>(pAction));
1569 }
1570
1571 pHeaders->SetGUID(aGUID);
1572 maRecList.push_back( std::unique_ptr<ExcRecord>(new EndXmlElement(XML_headers)));
1573 }
1574}
1575
1577{
1578 while( !aActionStack.empty() )
1579 {
1580 delete aActionStack.top();
1581 aActionStack.pop();
1582 }
1583}
1584
1586{
1587 // get original change track
1588 ScChangeTrack* pOrigChangeTrack = GetDoc().GetChangeTrack();
1589 OSL_ENSURE( pOrigChangeTrack, "XclExpChangeTrack::CreateTempChangeTrack - no change track data" );
1590 if( !pOrigChangeTrack )
1591 return nullptr;
1592
1593 assert(!xTempDoc);
1594 // create empty document
1595 xTempDoc.reset(new ScDocument);
1596
1597 // adjust table count
1598 SCTAB nOrigCount = GetDoc().GetTableCount();
1599 OUString sTabName;
1600 for( sal_Int32 nIndex = 0; nIndex < nOrigCount; nIndex++ )
1601 {
1602 xTempDoc->CreateValidTabName(sTabName);
1603 xTempDoc->InsertTab(SC_TAB_APPEND, sTabName);
1604 }
1605 OSL_ENSURE(nOrigCount == xTempDoc->GetTableCount(),
1606 "XclExpChangeTrack::CreateTempChangeTrack - table count mismatch");
1607 if(nOrigCount != xTempDoc->GetTableCount())
1608 return nullptr;
1609
1610 return pOrigChangeTrack->Clone(xTempDoc.get());
1611}
1612
1614{
1615 XclExpChTrAction* pXclAction = nullptr;
1616 ScChangeTrack* pTempChangeTrack = xTempDoc->GetChangeTrack();
1617 switch( rAction.GetType() )
1618 {
1619 case SC_CAT_CONTENT:
1620 pXclAction = new XclExpChTrCellContent( static_cast<const ScChangeActionContent&>(rAction), GetRoot(), *pTabIdBuffer );
1621 break;
1622 case SC_CAT_INSERT_ROWS:
1623 case SC_CAT_INSERT_COLS:
1624 case SC_CAT_DELETE_ROWS:
1625 case SC_CAT_DELETE_COLS:
1626 if (pTempChangeTrack)
1627 pXclAction = new XclExpChTrInsert( rAction, GetRoot(), *pTabIdBuffer, *pTempChangeTrack );
1628 break;
1629 case SC_CAT_INSERT_TABS:
1630 {
1631 pXclAction = new XclExpChTrInsertTab( rAction, GetRoot(), *pTabIdBuffer );
1633 pNewBuffer->Remove();
1634 maBuffers.push_back( std::unique_ptr<XclExpChTrTabIdBuffer>(pNewBuffer) );
1635 pTabIdBuffer = pNewBuffer;
1636 }
1637 break;
1638 case SC_CAT_MOVE:
1639 if (pTempChangeTrack)
1640 pXclAction = new XclExpChTrMoveRange( static_cast<const ScChangeActionMove&>(rAction), GetRoot(), *pTabIdBuffer, *pTempChangeTrack );
1641 break;
1642 default:;
1643 }
1644 if( pXclAction )
1645 aActionStack.push( pXclAction );
1646}
1647
1649{
1650 bool bRet = false;
1652 OSL_ENSURE( xSvStrm.is(), "XclExpChangeTrack::WriteUserNamesStream - no stream" );
1653 if( xSvStrm.is() )
1654 {
1655 XclExpStream aXclStrm( *xSvStrm, GetRoot() );
1656 XclExpChTr0x0191().Save( aXclStrm );
1657 XclExpChTr0x0198().Save( aXclStrm );
1658 XclExpChTr0x0192().Save( aXclStrm );
1659 XclExpChTr0x0197().Save( aXclStrm );
1660 xSvStrm->Commit();
1661 bRet = true;
1662 }
1663 return bRet;
1664}
1665
1667{
1668 if (maRecList.empty())
1669 return;
1670
1671 if( !WriteUserNamesStream() )
1672 return;
1673
1675 OSL_ENSURE( xSvStrm.is(), "XclExpChangeTrack::Write - no stream" );
1676 if( xSvStrm.is() )
1677 {
1678 XclExpStream aXclStrm( *xSvStrm, GetRoot(), EXC_MAXRECSIZE_BIFF8 + 8 );
1679
1680 for(const auto& rxRec : maRecList)
1681 rxRec->Save(aXclStrm);
1682
1683 xSvStrm->Commit();
1684 }
1685}
1686
1687static void lcl_WriteUserNamesXml( XclExpXmlStream& rWorkbookStrm )
1688{
1689 sax_fastparser::FSHelperPtr pUserNames = rWorkbookStrm.CreateOutputStream(
1690 "xl/revisions/userNames.xml",
1691 u"revisions/userNames.xml",
1692 rWorkbookStrm.GetCurrentStream()->getOutputStream(),
1693 "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml",
1694 CREATE_OFFICEDOC_RELATION_TYPE("usernames"));
1695 pUserNames->startElement( XML_users,
1696 XML_xmlns, rWorkbookStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(),
1697 FSNS( XML_xmlns, XML_r ), rWorkbookStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(),
1698 XML_count, "0" );
1699 // OOXTODO: XML_userinfo elements for each user editing the file
1700 // Doesn't seem to be supported by .xls output either (based on
1701 // contents of XclExpChangeTrack::WriteUserNamesStream()).
1702 pUserNames->endElement( XML_users );
1703}
1704
1706{
1707 if (maRecList.empty())
1708 return;
1709
1710 lcl_WriteUserNamesXml( rWorkbookStrm );
1711
1712 sax_fastparser::FSHelperPtr pRevisionHeaders = rWorkbookStrm.CreateOutputStream(
1713 "xl/revisions/revisionHeaders.xml",
1714 u"revisions/revisionHeaders.xml",
1715 rWorkbookStrm.GetCurrentStream()->getOutputStream(),
1716 "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml",
1717 CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
1718 // OOXTODO: XML_userinfo elements for each user editing the file
1719 // Doesn't seem to be supported by .xls output either (based on
1720 // contents of XclExpChangeTrack::WriteUserNamesStream()).
1721 rWorkbookStrm.PushStream( pRevisionHeaders );
1722
1723 for (const auto& rxRec : maRecList)
1724 rxRec->SaveXml(rWorkbookStrm);
1725
1726 rWorkbookStrm.PopStream();
1727}
1728
1729/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sType
static void lcl_WriteCell(XclExpXmlStream &rStrm, sal_Int32 nElement, const ScAddress &rPosition, XclExpChTrData *pData)
static void lcl_WriteFixedString(XclExpStream &rStrm, const XclExpString &rString, std::size_t nLength)
static bool lcl_IsDeletedTab(const XclExpChTrTabIdBuffer &rTabIdBuffer, sal_uInt16 nIndex)
static void lcl_WriteUserNamesXml(XclExpXmlStream &rWorkbookStrm)
static void lcl_WriteDateTime(XclExpStream &rStrm, const DateTime &rDateTime)
static OString lcl_DateTimeToOString(const DateTime &rDateTime)
static const char * lcl_GetAction(sal_uInt16 nOpCode)
static void lcl_WriteGUID(XclExpStream &rStrm, const sal_uInt8 *pGUID)
static const char * lcl_GetType(XclExpChTrData *pData)
static void lcl_GenerateGUID(sal_uInt8 *pGUID, bool &rValidGUID)
const SCTAB SC_TAB_APPEND
Definition: address.hxx:90
std::map< sal_uLong, ScChangeAction * > ScChangeActionMap
Definition: chgtrack.hxx:798
@ SC_CAT_MOVE
Definition: chgtrack.hxx:71
@ SC_CAT_INSERT_TABS
Definition: chgtrack.hxx:67
@ SC_CAT_DELETE_ROWS
Definition: chgtrack.hxx:69
@ SC_CAT_CONTENT
Definition: chgtrack.hxx:72
@ SC_CAT_DELETE_COLS
Definition: chgtrack.hxx:68
@ SC_CAT_INSERT_ROWS
Definition: chgtrack.hxx:66
@ SC_CAT_INSERT_COLS
Definition: chgtrack.hxx:65
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
sal_uInt16 GetMonth() const
virtual void SaveXml(XclExpXmlStream &rStrm) override
Definition: excrecds.cxx:108
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
Definition: excrecds.cxx:93
virtual sal_uInt16 GetNum() const override
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
virtual std::size_t GetLen() const override
void IncTab(SCTAB nDelta=1)
Definition: address.hxx:320
SCTAB Tab() const
Definition: address.hxx:283
void SetCol(SCCOL nColP)
Definition: address.hxx:291
void IncCol(SCCOL nDelta=1)
Definition: address.hxx:316
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
void IncRow(SCROW nDelta=1)
Definition: address.hxx:312
SCCOL Col() const
Definition: address.hxx:279
sal_Int64 Tab() const
Definition: bigrange.hxx:46
ScBigAddress aStart
Definition: bigrange.hxx:108
const ScCellValue & GetNewCell() const
Definition: chgtrack.hxx:740
const ScCellValue & GetOldCell() const
Definition: chgtrack.hxx:739
SC_DLLPUBLIC bool IsEndOfList() const
Definition: chgtrack.cxx:694
SC_DLLPUBLIC void GetDelta(sal_Int32 &nDx, sal_Int32 &nDy, sal_Int32 &nDz) const
Definition: chgtrack.cxx:1127
ScBigRange & GetBigRange()
Definition: chgtrack.hxx:229
ScChangeActionType GetType() const
Definition: chgtrack.hxx:315
ScChangeAction * GetPrev() const
Definition: chgtrack.hxx:321
const std::set< OUString > & GetUserCollection() const
Definition: chgtrack.hxx:972
ScChangeAction * GetLast() const
Definition: chgtrack.hxx:952
SC_DLLPUBLIC ScChangeTrack * Clone(ScDocument *pDocument) const
Definition: chgtrack.cxx:4361
SC_DLLPUBLIC void GetDependents(ScChangeAction *, ScChangeActionMap &, bool bListMasterDelete=false, bool bAllFlat=false) const
Definition: chgtrack.cxx:3802
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2494
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
static SC_DLLPUBLIC OUString GetString(const EditTextObject &rEditText, const ScDocument *pDoc)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:119
ScTokenArray * GetCode()
ScAddress aPos
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
virtual ~XclExpChTr0x014A() override
virtual void SaveActionData(XclExpStream &rStrm) const override
virtual std::size_t GetActionByteCount() const override
XclExpChTr0x014A(const XclExpChTrInsert &rAction)
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual sal_uInt16 GetNum() const override
virtual sal_uInt16 GetNum() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual std::size_t GetLen() const override
virtual sal_uInt16 GetNum() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual std::size_t GetLen() const override
virtual std::size_t GetLen() const override
virtual ~XclExpChTr0x0194() override
virtual sal_uInt16 GetNum() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual std::size_t GetLen() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual ~XclExpChTr0x0195() override
virtual sal_uInt16 GetNum() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual sal_uInt16 GetNum() const override
virtual std::size_t GetLen() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual std::size_t GetLen() const override
virtual sal_uInt16 GetNum() const override
virtual void PrepareSaveAction(XclExpStream &rStrm) const
bool GetAccepted() const
bool ForceInfoRecord() const
virtual ~XclExpChTrAction() override
const OUString & GetUsername() const
void SetIndex(sal_uInt32 &rIndex)
const XclExpChTrTabIdBuffer & GetTabIdBuffer() const
std::unique_ptr< XclExpChTrAction > pAddAction
void WriteTabId(XclExpStream &rStrm, SCTAB nTabId) const
sal_uInt16 GetTabId(SCTAB nTabId) const
virtual void SaveActionData(XclExpStream &rStrm) const =0
virtual std::size_t GetActionByteCount() const =0
void AddDependentContents(const ScChangeAction &rAction, const XclExpRoot &rRoot, const ScChangeTrack &rChangeTrack)
virtual bool UsesDeletedTab() const =0
virtual std::size_t GetLen() const override
static std::size_t GetHeaderByteCount()
void SetAddAction(XclExpChTrAction *pAction)
XclExpChTrAction(const XclExpChTrAction &rCopy)
virtual void CompleteSaveAction(XclExpStream &rStrm) const
const XclExpChTrTabIdBuffer & rIdBuffer
virtual void SaveCont(XclExpStream &rStrm) override
static void Write2DRange(XclExpStream &rStrm, const ScRange &rRange)
sal_uInt32 GetActionNumber() const
bool IsDeletedTab(SCTAB nTab) const
const DateTime & GetDateTime() const
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
static void Write2DAddress(XclExpStream &rStrm, const ScAddress &rAddress)
XclExpChTrAction * GetAddAction()
void GetCellData(const XclExpRoot &rRoot, const ScCellValue &rScCell, std::unique_ptr< XclExpChTrData > &rpData, sal_uInt32 &rXclLength1, sal_uInt16 &rXclLength2)
std::unique_ptr< XclExpChTrData > pOldData
virtual ~XclExpChTrCellContent() override
virtual std::size_t GetActionByteCount() const override
virtual sal_uInt16 GetNum() const override
virtual void SaveActionData(XclExpStream &rStrm) const override
static void MakeEmptyChTrData(std::unique_ptr< XclExpChTrData > &rpData)
std::unique_ptr< XclExpChTrData > pNewData
XclExpChTrCellContent(const ScChangeActionContent &rAction, const XclExpRoot &rRoot, const XclExpChTrTabIdBuffer &rTabIdBuffer)
virtual bool UsesDeletedTab() const override
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual sal_uInt16 GetNum() const override
virtual std::size_t GetLen() const override
virtual ~XclExpChTrEmpty() override
virtual sal_uInt16 GetNum() const override
void SetCount(sal_uInt32 nNew)
virtual std::size_t GetLen() const override
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual void SaveCont(XclExpStream &rStrm) override
virtual ~XclExpChTrHeader() override
void SetGUID(const sal_uInt8 *pGUID)
virtual std::size_t GetLen() const override
virtual sal_uInt16 GetNum() const override
XclExpChTrInfo(const OUString &rUsername, const DateTime &rDateTime, const sal_uInt8 *pGUID)
virtual ~XclExpChTrInfo() override
virtual void SaveCont(XclExpStream &rStrm) override
sal_uInt8 aGUID[16]
XclExpString sUsername
virtual bool UsesDeletedTab() const override
virtual void SaveActionData(XclExpStream &rStrm) const override
virtual ~XclExpChTrInsertTab() override
virtual sal_uInt16 GetNum() const override
virtual std::size_t GetActionByteCount() const override
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpChTrInsertTab(const ScChangeAction &rAction, const XclExpRoot &rRoot, const XclExpChTrTabIdBuffer &rTabIdBuffer)
virtual void SaveActionData(XclExpStream &rStrm) const override
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual bool UsesDeletedTab() const override
XclExpChTrInsert(const XclExpChTrInsert &rCopy)
virtual ~XclExpChTrInsert() override
virtual sal_uInt16 GetNum() const override
virtual void CompleteSaveAction(XclExpStream &rStrm) const override
virtual void PrepareSaveAction(XclExpStream &rStrm) const override
virtual std::size_t GetActionByteCount() const override
virtual std::size_t GetActionByteCount() const override
virtual sal_uInt16 GetNum() const override
virtual void PrepareSaveAction(XclExpStream &rStrm) const override
XclExpChTrMoveRange(const ScChangeActionMove &rAction, const XclExpRoot &rRoot, const XclExpChTrTabIdBuffer &rTabIdBuffer, const ScChangeTrack &rChangeTrack)
virtual void CompleteSaveAction(XclExpStream &rStrm) const override
virtual void SaveActionData(XclExpStream &rStrm) const override
virtual bool UsesDeletedTab() const override
virtual void SaveXml(XclExpXmlStream &rStrm) override
virtual ~XclExpChTrMoveRange() override
XclExpChTrTabIdBuffer(sal_uInt16 nCount)
bool HasId(sal_uInt16 nIndex) const
sal_uInt16 GetBufferCount() const
void InitFill(sal_uInt16 nIndex)
void GetBufferCopy(sal_uInt16 *pDest) const
sal_uInt16 GetId(sal_uInt16 nIndex) const
std::unique_ptr< sal_uInt16[]> pBuffer
virtual void SaveCont(XclExpStream &rStrm) override
virtual ~XclExpChTrTabId() override
virtual sal_uInt16 GetNum() const override
virtual std::size_t GetLen() const override
void Copy(const XclExpChTrTabIdBuffer &rBuffer)
std::unique_ptr< sal_uInt16[]> pBuffer
XclExpChTrTabId(sal_uInt16 nCount)
void PushActionRecord(const ScChangeAction &rAction)
XclExpChTrTabIdBuffer * pTabIdBuffer
virtual ~XclExpChangeTrack() override
std::stack< XclExpChTrAction * > aActionStack
void WriteXml(XclExpXmlStream &rStrm)
XclExpChangeTrack(const XclExpRoot &rRoot)
ScDocumentUniquePtr xTempDoc
std::vector< std::unique_ptr< XclExpChTrTabIdBuffer > > maBuffers
ScChangeTrack * CreateTempChangeTrack()
XclTokenArrayRef CreateFormula(XclFormulaType eType, const ScTokenArray &rScTokArr, const ScAddress *pScBasePos=nullptr, XclExpRefLog *pRefLog=nullptr)
Creates and returns the token array of a formula.
Definition: xeformula.cxx:2656
Helper to create HLINK records during creation of formatted cell strings.
Definition: xehelper.hxx:178
Access to global data from other classes.
Definition: xeroot.hxx:113
XclExpFormulaCompiler & GetFormulaCompiler() const
Returns the formula compiler to produce formula token arrays.
Definition: xeroot.cxx:88
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 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:571
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:48
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
Definition: xestring.cxx:249
std::size_t GetBufferSize() const
Returns the byte count the character buffer will take on export.
Definition: xestring.cxx:244
sal_uInt16 Len() const
Returns the character count of the string.
Definition: xestring.hxx:118
sal_uInt16 GetXclTab(SCTAB nScTab) const
Returns the Excel sheet index for a given Calc sheet.
Definition: xelink.cxx:814
virtual ~XclExpUserBViewList() override
XclExpUserBViewList(const ScChangeTrack &rChangeTrack)
virtual void Save(XclExpStream &rStrm) override
Writes the record header and calls WriteBody().
std::vector< XclExpUserBView > aViews
XclExpString sUsername
sal_uInt8 aGUID[16]
XclExpUserBView(const OUString &rUsername, const sal_uInt8 *pGUID)
virtual std::size_t GetLen() const override
virtual sal_uInt16 GetNum() const override
virtual void SaveCont(XclExpStream &rStrm) override
XclExpUsersViewBegin(const sal_uInt8 *pGUID, sal_uInt32 nTab)
virtual void SaveCont(XclExpStream &rStrm) override
virtual sal_uInt16 GetNum() const override
virtual std::size_t GetLen() const override
virtual void SaveCont(XclExpStream &rStrm) override
virtual sal_uInt16 GetNum() const override
virtual std::size_t GetLen() const override
std::vector< std::unique_ptr< XclExpChTrAction > > maActions
void AppendAction(std::unique_ptr< XclExpChTrAction > pAction)
std::vector< sal_uInt16 > maTabBuffer
virtual void SaveXml(XclExpXmlStream &rStrm) override
XclExpXmlChTrHeader(OUString aUserName, const DateTime &rDateTime, const sal_uInt8 *pGUID, sal_Int32 nLogNumber, const XclExpChTrTabIdBuffer &rBuf)
void SetGUID(const sal_uInt8 *pGUID)
virtual void SaveXml(XclExpXmlStream &rStrm) override
void WriteAttributes(sal_Int32 nAttribute, Str &&value, Args &&... rest)
Definition: xestream.hxx:300
sax_fastparser::FSHelperPtr & GetCurrentStream()
Definition: xestream.cxx:923
sax_fastparser::FSHelperPtr CreateOutputStream(const OUString &sFullStream, std::u16string_view sRelativeStream, const css::uno::Reference< css::io::XOutputStream > &xParentRelation, const char *sContentType, std::u16string_view sRelationshipType, OUString *pRelationshipId=nullptr)
Definition: xestream.cxx:952
void PopStream()
Definition: xestream.cxx:934
void PushStream(sax_fastparser::FSHelperPtr const &aStream)
Definition: xestream.cxx:929
const XclExpRoot & GetRoot() const
Returns the filter root data.
Definition: xestream.hxx:291
XclOutput GetOutput() const
Returns the current output format of the importer/exporter.
Definition: xlroot.hxx:143
tools::SvRef< SotStorageStream > OpenStream(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrmName) const
Tries to open a new stream in the specified storage for reading or writing.
Definition: xlroot.cxx:273
RootData & GetOldRoot() const
Returns old RootData struct.
Definition: xlroot.hxx:138
const ScAddress & GetXclMaxPos() const
Returns the highest possible cell address in an Excel document (using current BIFF version).
Definition: xlroot.hxx:246
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
static bool GetRKFromDouble(sal_Int32 &rnRKValue, double fValue)
Calculates an RK value (encoded integer or double) from a double value.
Definition: xltools.cxx:124
static OString ToOString(const Color &rColor)
Definition: xestream.cxx:712
static void GetFormulaTypeAndValue(ScFormulaCell &rCell, const char *&sType, OUString &rValue)
Definition: xestream.cxx:668
static OUString ToOUString(const char *s)
Definition: xestream.cxx:788
static OUString GetStreamName(const char *sStreamDir, const char *sStream, sal_Int32 nId)
Definition: xestream.cxx:697
OUString getNamespaceURL(sal_Int32 nNSID) const
const OUString & getString() const
OString getString() const
bool is() const
sal_uInt16 GetSec() const
sal_uInt16 GetMin() const
void SetNanoSec(sal_uInt32 nNewNanoSec)
sal_uInt16 GetHour() const
sal_uInt32 GetNanoSec() const
void SetSec(sal_uInt16 nNewSec)
int nCount
float u
#define EXC_CHTR_TYPE_STRING
Definition: excdefs.hxx:84
constexpr OUStringLiteral EXC_STREAM_REVLOG
Definition: excdefs.hxx:63
constexpr OUStringLiteral EXC_STREAM_USERNAMES
Definition: excdefs.hxx:62
#define EXC_CHTR_TYPE_DOUBLE
Definition: excdefs.hxx:83
#define EXC_CHTR_OP_DELCOL
Definition: excdefs.hxx:71
#define EXC_CHTR_ACCEPT
Definition: excdefs.hxx:90
#define EXC_CHTR_TYPE_RK
Definition: excdefs.hxx:82
#define EXC_CHTR_OP_FORMAT
Definition: excdefs.hxx:75
#define EXC_CHTR_OP_DELFLAG
Definition: excdefs.hxx:67
#define EXC_CHTR_OP_DELROW
Definition: excdefs.hxx:70
#define EXC_CHTR_OP_INSCOL
Definition: excdefs.hxx:69
#define EXC_CHTR_TYPE_FORMULA
Definition: excdefs.hxx:86
#define EXC_CHTR_OP_CELL
Definition: excdefs.hxx:74
#define EXC_CHTR_OP_COLFLAG
Definition: excdefs.hxx:66
#define EXC_CHTR_OP_INSROW
Definition: excdefs.hxx:68
#define EXC_CHTR_TYPE_EMPTY
Definition: excdefs.hxx:81
#define EXC_CHTR_OP_INSTAB
Definition: excdefs.hxx:73
#define EXC_CHTR_NOTHING
Definition: excdefs.hxx:89
#define EXC_CHTR_OP_UNKNOWN
Definition: excdefs.hxx:76
#define EXC_CHTR_OP_MOVE
Definition: excdefs.hxx:72
constexpr sal_Int32 FSNS(sal_Int32 namespc, sal_Int32 element)
@ CELLTYPE_EDIT
Definition: global.hxx:277
@ CELLTYPE_STRING
Definition: global.hxx:275
@ CELLTYPE_FORMULA
Definition: global.hxx:276
@ CELLTYPE_VALUE
Definition: global.hxx:274
sal_Int32 nIndex
sal_Int64 n
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
int i
void SvStream & rStrm
std::shared_ptr< FastSerializerHelper > FSHelperPtr
DateTime GetDateTime(const css::util::DateTime &_rDT)
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
#define CREATE_OFFICEDOC_RELATION_TYPE(ascii)
OUString maUserName
DateTime maDateTime
XclExpChTrTabId * pTabId
Definition: root.hxx:56
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:32
bool isEmpty() const
Definition: cellvalue.cxx:519
const svl::SharedString * getSharedString() const
Definition: cellvalue.hxx:60
CellType getType() const
Definition: cellvalue.cxx:296
ScFormulaCell * getFormula() const
Definition: cellvalue.hxx:59
EditTextObject * getEditText() const
Definition: cellvalue.hxx:61
double getDouble() const
Definition: cellvalue.hxx:58
XclTokenArrayRef mxTokArr
bool UsesDeletedTab(const XclExpChTrTabIdBuffer &rTabIdBuffer) const
void Write(XclExpStream &rStrm, const XclExpChTrTabIdBuffer &rTabIdBuffer)
std::unique_ptr< XclExpString > pString
void WriteFormula(XclExpStream &rStrm, const XclExpChTrTabIdBuffer &rTabIdBuffer)
XclExpRefLog maRefLog
const ScFormulaCell * mpFormulaCell
Log entry for external references in a formula, used i.e.
Definition: xeformula.hxx:32
unsigned char sal_uInt8
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
::std::vector< XclExpRefLogEntry > XclExpRefLog
Vector containing a log for all external references in a formula, used i.e.
Definition: xeformula.hxx:43
@ EXC_OUTPUT_BINARY
Definition: xlconst.hxx:42
@ EXC_FMLATYPE_CELL
Definition: xlformula.hxx:161
const sal_uInt16 EXC_MAXRECSIZE_BIFF8
Definition: xlstream.hxx:30
sal_Int32 nLength