LibreOffice Module sc (master)  1
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
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 .
18  */
20 #pragma once
22 #include <memory>
23 #include <string_view>
25 #include "ftools.hxx"
26 #include <rangelst.hxx>
27 #include "xladdress.hxx"
28 #include "xeroot.hxx"
29 #include "xlstring.hxx"
31 // Export progress bar ========================================================
33 class ScfProgressBar;
43 class XclExpProgressBar : protected XclExpRoot
44 {
45 public:
46  explicit XclExpProgressBar( const XclExpRoot& rRoot );
47  virtual ~XclExpProgressBar() override;
50  void Initialize();
53  void IncRowRecordCount();
61  void Progress();
63 private:
64  typedef std::unique_ptr< ScfProgressBar > ScfProgressBarPtr;
66  ScfProgressBarPtr mxProgress;
73  sal_Int32 mnSegRowFinal;
75  std::size_t mnRowCount;
76 };
78 // Calc->Excel cell address/range conversion ==================================
82 {
83 public:
84  explicit XclExpAddressConverter( const XclExpRoot& rRoot );
86  // cell address -----------------------------------------------------------
93  bool CheckAddress( const ScAddress& rScPos, bool bWarn );
101  bool ConvertAddress( XclAddress& rXclPos,
102  const ScAddress& rScPos, bool bWarn );
109  XclAddress CreateValidAddress( const ScAddress& rScPos, bool bWarn );
111  // cell range -------------------------------------------------------------
118  bool CheckRange( const ScRange& rScRange, bool bWarn );
128  bool ValidateRange( ScRange& rScRange, bool bWarn );
136  bool ConvertRange( XclRange& rXclRange, const ScRange& rScRange, bool bWarn );
138  // cell range list --------------------------------------------------------
149  void ValidateRangeList( ScRangeList& rScRanges, bool bWarn );
161  void ConvertRangeList( XclRangeList& rXclRanges,
162  const ScRangeList& rScRanges, bool bWarn );
163 };
165 // EditEngine->String conversion ==============================================
167 class SvxURLField;
168 class XclExpHyperlink;
178 {
179 public:
182  explicit XclExpHyperlinkHelper( const XclExpRoot& rRoot, const ScAddress& rScPos );
183  virtual ~XclExpHyperlinkHelper() override;
187  OUString ProcessUrlField( const SvxURLField& rUrlField );
190  bool HasLinkRecord() const;
192  XclExpHyperlinkRef GetLinkRecord() const;
195  bool HasMultipleUrls() const { return mbMultipleUrls; }
197  const OUString& GetUrlList() const { return maUrlList; }
199 private:
200  XclExpHyperlinkRef mxLinkRec;
202  OUString maUrlList;
204 };
206 class EditEngine;
207 class EditTextObject;
208 class SdrTextObj;
209 class ScPatternAttr;
215 {
216 public:
218  XclExpStringHelper(const XclExpStringHelper &) = delete;
220  const XclExpStringHelper& operator=(const XclExpStringHelper&) = delete;
223  XclExpStringHelper() = delete;
233  const XclExpRoot& rRoot,
234  const OUString& rString,
236  sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
246  const XclExpRoot& rRoot,
247  sal_Unicode cChar,
249  sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
256  static void AppendString(
257  XclExpString& rXclString,
258  const XclExpRoot& rRoot,
259  const OUString& rString );
266  static void AppendChar(
267  XclExpString& rXclString,
268  const XclExpRoot& rRoot,
269  sal_Unicode cChar );
282  const XclExpRoot& rRoot,
283  const OUString& rString,
284  const ScPatternAttr* pCellAttr,
286  sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
298  const XclExpRoot& rRoot,
299  const EditTextObject& rEditText,
300  const ScPatternAttr* pCellAttr,
301  XclExpHyperlinkHelper& rLinkHelper,
303  sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
312  const XclExpRoot& rRoot,
313  const SdrTextObj& rTextObj,
314  XclStrFlags nFlags = XclStrFlags::NONE );
321  const XclExpRoot& rRoot,
322  const EditTextObject& rEditObj,
323  XclStrFlags nFlags = XclStrFlags::NONE );
327  static sal_Int16 GetLeadingScriptType( const XclExpRoot& rRoot, const OUString& rString );
328 };
330 // Header/footer conversion ===================================================
361 class XclExpHFConverter : protected XclExpRoot
362 {
363 public:
365  XclExpHFConverter(const XclExpHFConverter&) = delete;
367  const XclExpHFConverter& operator=(const XclExpHFConverter&) = delete;
369  explicit XclExpHFConverter( const XclExpRoot& rRoot );
372  void GenerateString(
373  const EditTextObject* pLeftObj,
374  const EditTextObject* pCenterObj,
375  const EditTextObject* pRightObj );
378  const OUString& GetHFString() const { return maHFString; }
380  sal_Int32 GetTotalHeight() const { return mnTotalHeight; }
382 private:
384  void AppendPortion(
385  const EditTextObject* pTextObj,
386  sal_Unicode cPortionCode );
388 private:
390  OUString maHFString;
391  sal_Int32 mnTotalHeight;
392 };
394 // URL conversion =============================================================
400 {
401 public:
403  XclExpUrlHelper(const XclExpUrlHelper&) = delete;
405  const XclExpUrlHelper& operator=(const XclExpUrlHelper&) = delete;
408  XclExpUrlHelper() = delete;
412  static OUString EncodeUrl( const XclExpRoot& rRoot, const OUString& rAbsUrl, const OUString* pTableName = nullptr );
414  static OUString EncodeDde( std::u16string_view rApplic, std::u16string_view rTopic );
415 };
417 class ScMatrix;
421 {
422  void GetDimensions( SCSIZE & nCols, SCSIZE & nRows ) const;
423 public:
426  explicit XclExpCachedMatrix( const ScMatrix& rMatrix );
430  std::size_t GetSize() const;
432  void Save( XclExpStream& rStrm ) const;
434 private:
436 };
438 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< XclExpHyperlink > XclExpHyperlinkRef
Definition: xehelper.hxx:180
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:112
static OUString EncodeUrl(const XclExpRoot &rRoot, const OUString &rAbsUrl, const OUString *pTableName=nullptr)
Encodes and returns the URL passed in rAbsUrl to an Excel like URL.
Definition: xehelper.cxx:976
void ConvertRangeList(XclRangeList &rXclRanges, const ScRangeList &rScRanges, bool bWarn)
Converts the passed Calc cell range list to an Excel cell range list.
Definition: xehelper.cxx:265
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:47
const sal_uInt16 EXC_STR_MAXLEN
Definition: xlstring.hxx:42
XclExpHyperlinkRef mxLinkRec
Definition: xehelper.hxx:200
sal_Int32 mnSegRowFinal
Sub progress bar for finalizing ROW records.
Definition: xehelper.hxx:73
bool ConvertRange(XclRange &rXclRange, const ScRange &rScRange, bool bWarn)
Converts the passed Calc cell range to an Excel cell range.
Definition: xehelper.cxx:231
The main progress bar for the export filter.
Definition: xehelper.hxx:43
XclExpAddressConverter(const XclExpRoot &rRoot)
Definition: xehelper.cxx:158
void ActivateCreateRowsSegment()
Activates the progress segment to create ROW records.
Definition: xehelper.cxx:112
This class is used to export Excel record streams.
Definition: xestream.hxx:72
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:28
void Initialize()
Initializes all segments and sub progress bars.
Definition: xehelper.cxx:77
ScAddress maScPos
Created HLINK record.
Definition: xehelper.hxx:201
void Progress()
Increases the currently activated (sub) progress bar by 1 step.
Definition: xehelper.cxx:139
bool CheckRange(const ScRange &rScRange, bool bWarn)
Checks if the passed cell range is valid (checks start and end position).
Definition: xehelper.cxx:205
ScfProgressBarPtr mxProgress
Definition: xehelper.hxx:66
ScfProgressBar * mpSubRowCreate
Current sub progress bar.
Definition: xehelper.hxx:69
EditEngine & mrEE
Definition: xehelper.hxx:389
void ActivateFinalRowsSegment()
Activates the progress segment to finalize ROW records.
Definition: xehelper.cxx:127
XclExpHFConverter(const XclExpHFConverter &)=delete
delete copy constructor
XclExpCachedMatrix(const ScMatrix &rMatrix)
Constructs and fills a new matrix.
Definition: xehelper.cxx:990
const XclExpStringHelper & operator=(const XclExpStringHelper &)=delete
remove copy-assignment operator
const OUString & GetUrlList() const
Returns a string containing all processed URLs.
Definition: xehelper.hxx:197
sal_uInt16 sal_Unicode
Access to global data from other classes.
Definition: xeroot.hxx:112
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
Helper to create HLINK records during creation of formatted cell strings.
Definition: xehelper.hxx:177
bool mbMultipleUrls
List with all processed URLs.
Definition: xehelper.hxx:203
ScfInt32Vec maSubSegRowCreate
Sub progress bar for creating table rows.
Definition: xehelper.hxx:70
void GenerateString(const EditTextObject *pLeftObj, const EditTextObject *pCenterObj, const EditTextObject *pRightObj)
Generates the header/footer string from the passed edit engine text objects.
Definition: xehelper.cxx:667
XclAddress CreateValidAddress(const ScAddress &rScPos, bool bWarn)
Returns a valid cell address by moving it into allowed dimensions.
Definition: xehelper.cxx:195
void GetDimensions(SCSIZE &nCols, SCSIZE &nRows) const
Definition: xehelper.cxx:1000
std::size_t GetSize() const
Returns the byte count of all contained data.
Definition: xehelper.cxx:1008
void IncRowRecordCount()
Increases the number of existing ROW records by 1.
Definition: xehelper.cxx:107
XclExpHyperlinkHelper(const XclExpRoot &rRoot, const ScAddress &rScPos)
Definition: xehelper.cxx:291
Contains cached values in a 2-dimensional array.
Definition: xehelper.hxx:420
OUString maHFString
The header/footer edit engine.
Definition: xehelper.hxx:390
XclExpHyperlinkRef GetLinkRecord() const
Returns the created single HLINk record, or an empty reference.
Definition: xehelper.cxx:329
A 2D cell range address list with Excel column and row indexes.
Definition: xladdress.hxx:100
bool HasMultipleUrls() const
Returns true, if multiple URLs have been processed.
Definition: xehelper.hxx:195
const ScMatrix & mrMatrix
Definition: xehelper.hxx:435
static sal_Int16 GetLeadingScriptType(const XclExpRoot &rRoot, const OUString &rString)
Returns the script type first text portion different to WEAK, or the system default script type...
Definition: xehelper.cxx:643
std::unique_ptr< ScfProgressBar > ScfProgressBarPtr
Definition: xehelper.hxx:64
OUString maUrlList
Cell position to set at the HLINK record.
Definition: xehelper.hxx:202
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:29
bool HasLinkRecord() const
Returns true, if a single HLINK record has been created.
Definition: xehelper.cxx:324
Progress bar for complex progress representation.
This class contains static methods to encode a file URL.
Definition: xehelper.hxx:399
static void AppendString(XclExpString &rXclString, const XclExpRoot &rRoot, const OUString &rString)
Appends an unformatted string to an Excel string object.
Definition: xehelper.cxx:545
sal_Int32 GetTotalHeight() const
Returns the total height of the last generated header/footer in twips.
Definition: xehelper.hxx:380
bool ValidateRange(ScRange &rScRange, bool bWarn)
Checks and eventually crops the cell range to valid dimensions.
Definition: xehelper.cxx:210
virtual ~XclExpProgressBar() override
Definition: xehelper.cxx:73
ScfProgressBar * mpSubProgress
Progress bar implementation.
Definition: xehelper.hxx:67
const XclExpUrlHelper & operator=(const XclExpUrlHelper &)=delete
delete copy-assignment operator
Provides functions to convert Calc cell addresses to Excel cell addresses.
Definition: xehelper.hxx:81
std::size_t mnRowCount
Progress segment for finalizing ROW records.
Definition: xehelper.hxx:75
sal_Int32 mnTotalHeight
The last generated header/footer string.
Definition: xehelper.hxx:391
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:561
XclExpProgressBar(const XclExpRoot &rRoot)
Definition: xehelper.cxx:62
const OUString & GetHFString() const
Returns the last generated header/footer string.
Definition: xehelper.hxx:378
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:983
void AppendPortion(const EditTextObject *pTextObj, sal_Unicode cPortionCode)
Converts the text object contents and stores it in the passed string.
Definition: xehelper.cxx:679
static void AppendChar(XclExpString &rXclString, const XclExpRoot &rRoot, sal_Unicode cChar)
Appends a character to an Excel string object.
Definition: xehelper.cxx:553
void Save(XclExpStream &rStrm) const
Writes the complete matrix to stream.
Definition: xehelper.cxx:1020
const XclExpHFConverter & operator=(const XclExpHFConverter &)=delete
delete copy-assignment operator
Base class for import/export address converters.
Definition: xladdress.hxx:138
OUString ProcessUrlField(const SvxURLField &rUrlField)
Processes the passed URL field (tries to create a HLINK record).
Definition: xehelper.cxx:302
This class provides methods to create an XclExpString.
Definition: xehelper.hxx:214
void ValidateRangeList(ScRangeList &rScRanges, bool bWarn)
Checks and eventually crops the cell ranges to valid dimensions.
Definition: xehelper.cxx:255
static XclExpStringRef CreateString(const XclExpRoot &rRoot, const OUString &rString, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Creates a new unformatted string from the passed string.
Definition: xehelper.cxx:526
We don't want anybody to instantiate this class, since it is just a collection of static methods...
std::shared_ptr< XclExpString > XclExpStringRef
Definition: xeroot.hxx:35
::std::vector< sal_Int32 > ScfInt32Vec
Definition: ftools.hxx:256
ScfProgressBar * mpSubRowFinal
Segment ID's for all sheets in sub progress bar.
Definition: xehelper.hxx:72
void SvStream & rStrm
Converts edit engine text objects to an Excel header/footer string.
Definition: xehelper.hxx:361
virtual ~XclExpHyperlinkHelper() override
Definition: xehelper.cxx:298
We don't want anybody to instantiate this class, since it is just a collection of static methods...
bool CheckAddress(const ScAddress &rScPos, bool bWarn)
Checks if the passed Calc cell address is valid.
Definition: xehelper.cxx:165
bool ConvertAddress(XclAddress &rXclPos, const ScAddress &rScPos, bool bWarn)
Converts the passed Calc cell address to an Excel cell address.
Definition: xehelper.cxx:186
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:57