LibreOffice Module sc (master) 1
xehelper.hxx
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#pragma once
21
22#include <memory>
23#include <string_view>
24
25#include "ftools.hxx"
26#include <rangelst.hxx>
27#include "xladdress.hxx"
28#include "xeroot.hxx"
29#include "xlstring.hxx"
30
31// Export progress bar ========================================================
32
33class ScfProgressBar;
34
44{
45public:
46 explicit XclExpProgressBar( const XclExpRoot& rRoot );
47 virtual ~XclExpProgressBar() override;
48
50 void Initialize();
51
53 void IncRowRecordCount();
54
59
61 void Progress();
62
63private:
64 typedef std::unique_ptr< ScfProgressBar > ScfProgressBarPtr;
65
68
71
73 sal_Int32 mnSegRowFinal;
74
75 std::size_t mnRowCount;
76};
77
78// Calc->Excel cell address/range conversion ==================================
79
82{
83public:
84 explicit XclExpAddressConverter( const XclExpRoot& rRoot );
85
86 // cell address -----------------------------------------------------------
87
93 bool CheckAddress( const ScAddress& rScPos, bool bWarn );
94
101 bool ConvertAddress( XclAddress& rXclPos,
102 const ScAddress& rScPos, bool bWarn );
103
109 XclAddress CreateValidAddress( const ScAddress& rScPos, bool bWarn );
110
111 // cell range -------------------------------------------------------------
112
118 bool CheckRange( const ScRange& rScRange, bool bWarn );
119
128 bool ValidateRange( ScRange& rScRange, bool bWarn );
129
136 bool ConvertRange( XclRange& rXclRange, const ScRange& rScRange, bool bWarn );
137
138 // cell range list --------------------------------------------------------
139
149 void ValidateRangeList( ScRangeList& rScRanges, bool bWarn );
150
161 void ConvertRangeList( XclRangeList& rXclRanges,
162 const ScRangeList& rScRanges, bool bWarn );
163};
164
165// EditEngine->String conversion ==============================================
166
167class SvxURLField;
168class XclExpHyperlink;
169
178{
179public:
181
182 explicit XclExpHyperlinkHelper( const XclExpRoot& rRoot, const ScAddress& rScPos );
183 virtual ~XclExpHyperlinkHelper() override;
184
187 OUString ProcessUrlField( const SvxURLField& rUrlField );
188
190 bool HasLinkRecord() const;
193
195 bool HasMultipleUrls() const { return mbMultipleUrls; }
197 const OUString& GetUrlList() const { return maUrlList; }
198
199private:
202 OUString maUrlList;
204};
205
206class EditEngine;
207class EditTextObject;
208class SdrTextObj;
209class ScPatternAttr;
210
215{
216public:
224
233 const XclExpRoot& rRoot,
234 const OUString& rString,
236 sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
237
246 const XclExpRoot& rRoot,
247 sal_Unicode cChar,
249 sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
250
256 static void AppendString(
257 XclExpString& rXclString,
258 const XclExpRoot& rRoot,
259 std::u16string_view rString);
260
266 static void AppendChar(
267 XclExpString& rXclString,
268 const XclExpRoot& rRoot,
269 sal_Unicode cChar );
270
282 const XclExpRoot& rRoot,
283 const OUString& rString,
284 const ScPatternAttr* pCellAttr,
286 sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
287
298 const XclExpRoot& rRoot,
299 const EditTextObject& rEditText,
300 const ScPatternAttr* pCellAttr,
301 XclExpHyperlinkHelper& rLinkHelper,
303 sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
304
312 const XclExpRoot& rRoot,
313 const SdrTextObj& rTextObj,
315
321 const XclExpRoot& rRoot,
322 const EditTextObject& rEditObj,
324
327 static sal_Int16 GetLeadingScriptType( const XclExpRoot& rRoot, const OUString& rString );
328};
329
330// Header/footer conversion ===================================================
331
362{
363public:
368
369 explicit XclExpHFConverter( const XclExpRoot& rRoot );
370
372 void GenerateString(
373 const EditTextObject* pLeftObj,
374 const EditTextObject* pCenterObj,
375 const EditTextObject* pRightObj );
376
378 const OUString& GetHFString() const { return maHFString; }
380 sal_Int32 GetTotalHeight() const { return mnTotalHeight; }
381
382private:
384 void AppendPortion(
385 const EditTextObject* pTextObj,
386 sal_Unicode cPortionCode );
387
388private:
390 OUString maHFString;
391 sal_Int32 mnTotalHeight;
392};
393
394// URL conversion =============================================================
395
400{
401public:
408 XclExpUrlHelper() = delete;
409
412 static OUString EncodeUrl( const XclExpRoot& rRoot, std::u16string_view rAbsUrl, const OUString* pTableName = nullptr );
414 static OUString EncodeDde( std::u16string_view rApplic, std::u16string_view rTopic );
415};
416
417class ScMatrix;
418
421{
422 void GetDimensions( SCSIZE & nCols, SCSIZE & nRows ) const;
423public:
426 explicit XclExpCachedMatrix( const ScMatrix& rMatrix );
428
430 std::size_t GetSize() const;
432 void Save( XclExpStream& rStrm ) const;
433
434private:
436};
437
438/* 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
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:101
Progress bar for complex progress representation.
Base class for import/export address converters.
Definition: xladdress.hxx:140
Provides functions to convert Calc cell addresses to Excel cell addresses.
Definition: xehelper.hxx:82
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
Contains cached values in a 2-dimensional array.
Definition: xehelper.hxx:421
XclExpCachedMatrix(const ScMatrix &rMatrix)
Constructs and fills a new matrix.
Definition: xehelper.cxx:1024
void GetDimensions(SCSIZE &nCols, SCSIZE &nRows) const
Definition: xehelper.cxx:1034
const ScMatrix & mrMatrix
Definition: xehelper.hxx:435
std::size_t GetSize() const
Returns the byte count of all contained data.
Definition: xehelper.cxx:1042
void Save(XclExpStream &rStrm) const
Writes the complete matrix to stream.
Definition: xehelper.cxx:1054
Converts edit engine text objects to an Excel header/footer string.
Definition: xehelper.hxx:362
sal_Int32 GetTotalHeight() const
Returns the total height of the last generated header/footer in twips.
Definition: xehelper.hxx:380
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:686
sal_Int32 mnTotalHeight
The last generated header/footer string.
Definition: xehelper.hxx:391
OUString maHFString
The header/footer edit engine.
Definition: xehelper.hxx:390
const XclExpHFConverter & operator=(const XclExpHFConverter &)=delete
delete copy-assignment operator
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:674
const OUString & GetHFString() const
Returns the last generated header/footer string.
Definition: xehelper.hxx:378
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
bool HasMultipleUrls() const
Returns true, if multiple URLs have been processed.
Definition: xehelper.hxx:195
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
const OUString & GetUrlList() const
Returns a string containing all processed URLs.
Definition: xehelper.hxx:197
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
The main progress bar for the export filter.
Definition: xehelper.hxx:44
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
std::unique_ptr< ScfProgressBar > ScfProgressBarPtr
Definition: xehelper.hxx:64
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
This class is used to export Excel record streams.
Definition: xestream.hxx:73
This class provides methods to create an XclExpString.
Definition: xehelper.hxx:215
const XclExpStringHelper & operator=(const XclExpStringHelper &)=delete
remove copy-assignment operator
XclExpStringHelper(const XclExpStringHelper &)=delete
removes copy constructor
static void AppendChar(XclExpString &rXclString, const XclExpRoot &rRoot, sal_Unicode cChar)
Appends a character to an Excel string object.
Definition: xehelper.cxx:563
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:650
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:536
static void AppendString(XclExpString &rXclString, const XclExpRoot &rRoot, std::u16string_view rString)
Appends an unformatted string to an Excel string object.
Definition: xehelper.cxx:555
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
XclExpStringHelper()=delete
We don't want anybody to instantiate this class, since it is just a collection of static methods.
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:48
This class contains static methods to encode a file URL.
Definition: xehelper.hxx:400
const XclExpUrlHelper & operator=(const XclExpUrlHelper &)=delete
delete copy-assignment operator
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:1017
XclExpUrlHelper()=delete
We don't want anybody to instantiate this class, since it is just a collection of static methods.
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:989
XclExpUrlHelper(const XclExpUrlHelper &)=delete
delete copy constructor
A 2D cell range address list with Excel column and row indexes.
Definition: xladdress.hxx:102
::std::vector< sal_Int32 > ScfInt32Vec
Definition: ftools.hxx:256
void SvStream & rStrm
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:30
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:59
sal_uInt16 sal_Unicode
std::shared_ptr< XclExpString > XclExpStringRef
Definition: xeroot.hxx:35
const sal_uInt16 EXC_STR_MAXLEN
Definition: xlstring.hxx:43
XclStrFlags
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:29