Files
core/MsBinaryFile/DocFile/DocumentMapping.h
Alexander Trofimov 76ee07f61c [copyright] Update copyright header
Co-authored-by: Alexander Trofimov <alexander.trofimov@onlyoffice.com>
Co-committed-by: Alexander Trofimov <alexander.trofimov@onlyoffice.com>
2026-05-14 08:23:56 +00:00

186 lines
6.8 KiB
C++

/*
* Copyright (C) Ascensio System SIA, 2009-2026
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation, together with the
* additional terms provided in the LICENSE file.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: https://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA by email at info@onlyoffice.com
* or by postal mail at 20A-6 Ernesta Birznieka-Upisha Street, Riga,
* LV-1050, Latvia, European Union.
*
* The interactive user interfaces in modified versions of the Program
* are required to display Appropriate Legal Notices in accordance with
* Section 5 of the GNU AGPL version 3.
*
* No trademark rights are granted under this License.
*
* All non-code elements of the Product, including illustrations,
* icon sets, and technical writing content, are licensed under the
* Creative Commons Attribution-ShareAlike 4.0 International License:
* https://creativecommons.org/licenses/by-sa/4.0/legalcode
*
* This license applies only to such non-code elements and does not
* modify or replace the licensing terms applicable to the Program's
* source code, which remains licensed under the GNU Affero General
* Public License v3.
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
#pragma once
#include "ContentTypes.h"
#include "RevisionData.h"
#include "BookmarkFirst.h"
#include "WideString.h"
#include "PictureDescriptor.h"
#include "VMLPictureMapping.h"
#include "VMLShapeMapping.h"
#include "CharacterPropertyExceptions.h"
#include "TableInfo.h"
#include "TablePropertyExceptions.h"
#include "AbstractOpenXmlMapping.h"
#include "TableRowPropertiesMapping.h"
#include "TableCellPropertiesMapping.h"
#include "OleObject.h"
#include "OleObjectMapping.h"
#include "ConversionContext.h"
#include "IMapping.h"
#include "FormFieldData.h"
#include "FormFieldDataMapping.h"
#define START_PARAGRAPH 0x1
#define END_PARAGRAPH 0x2
#define START_END_PARAGRAPH 0x3
#define NOSTART_NOEND_PARAGRAPH 0x0
namespace DocFileFormat
{
class FootnotesMapping;
class CommentsMapping;
struct Symbol
{
std::wstring FontName;
std::wstring HexValue;
};
class DocumentMapping: public AbstractOpenXmlMapping, public IMapping
{
friend class Table;
friend class TableRow;
friend class TableCell;
friend class DocParagraph;
public:
DocumentMapping(ConversionContext* context, IMapping* caller);
DocumentMapping(ConversionContext* context, XMLTools::CStringXmlWriter* writer, IMapping* caller);
virtual ~DocumentMapping();
virtual void Apply( IVisitable* visited ) = 0;
//--------------------------------- 4571833.doc
std::wstring m_shapeIdOwner;
std::wstring getOLEObject() { return _lastOLEObject; }
bool m_bOleInPicture = false;
bool bPict = true;
protected:
int getListNumCache (int fc, int fc_end);
int getCurrentSection (int cp);
//---------------------------------
bool isSectionEnd ( int cp );
int writeParagraph( int cp, int cpEnd );
int writeParagraph( int initialCp, int cpEnd, bool sectionEnd, bool lastBad = false, int paragraphState = 0 );
int writeRun( std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp );
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeParagraphRsid ( const ParagraphPropertyExceptions* papx );
void writeTextElement ( const std::wstring& text, const std::wstring& textType );
void writeTextStart ( const std::wstring& textType, bool preserve_space);
void writeTextEnd ( const std::wstring& textType );
void writeField (const std::wstring& sFieldString, int cpFieldStart, int cpFieldEnd);
ParagraphPropertyExceptions* findValidPapx( int fc );
std::vector<std::vector<wchar_t> >* splitCharList( std::vector<wchar_t>* chars, std::vector<int>* splitIndices );
int writeTable ( int initialCp, unsigned int nestingLevel );
bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector<short>& grid);
int findRowEndFc ( int initialCp, int& rowEndCp, unsigned int nestingLevel );
int findRowEndFc ( int initialCp, unsigned int nestingLevel );
int writeTableRow ( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int findCellEndCp ( int initialCp, unsigned int nestingLevel );
std::vector<int> searchBookmarks(std::vector<wchar_t>* chars, int initialCp);
std::vector<int> searchAnnotation(std::vector<wchar_t>* chars, int initialCp);
std::vector<int> searchPermission(std::vector<wchar_t>* chars, int initialCp);
bool writeBookmarks ( int cp, bool para );
bool writeBookmarkStart ( short id );
bool writeBookmarkEnd ( short id );
bool writeNotesReferences(int cp);
bool writeAnnotations ( int cp );
bool writeAnnotationStart( short id );
bool writeAnnotationEnd ( short id );
bool writePermissions(int cp);
bool writePermissionStart(short id, size_t index);
bool writePermissionEnd(short id);
bool isSpecial( CharacterPropertyExceptions* chpx );
SectionPropertyExceptions* findValidSepx( int cp );
int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark );
Symbol getSymbol ( const CharacterPropertyExceptions* chpx );
void AddBoundary(short boundary1, short boundary2, std::map<short, short> &boundaries);
std::vector<std::pair<int, int>> get_subsequence(int cpStart, int cpEnd, int fcStars, int fcEnd);
//----------------------------------------------------------------------------------------------------------------------
bool m_bInternalXmlWriter;
WordDocument* m_document;
ConversionContext* m_context;
IMapping* _caller;
ParagraphPropertyExceptions* _lastValidPapx;
SectionPropertyExceptions* _lastValidSepx;
bool _embeddedObject;
int _skipRuns;
int _sectionNr;
int _footnoteNr;
int _endnoteNr;
int _commentNr;
int _permissionNr;
bool _isTextBoxContent;
// int _isSectionPageBreak; //0 - not set, 1 -page break, 2 - continues, -1 - already
bool _writeWebHidden;
std::wstring _writeAfterRun;
std::wstring _lastOLEObject;
std::wstring _writeNoteRef;
int _cacheListNum;
std::wstring _paraId;
struct fieldLevels
{
bool bBegin = false;
bool bSeparate = false;
bool bResult = false;
//bool bInstrText = false;
bool bEnd = false;
};
std::vector<fieldLevels> _fieldLevels;
bool _bContentWrite;
};
}