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  */
23 #include <memory>
24 #include <rangelst.hxx>
25 #include "xladdress.hxx"
26 #include "xeroot.hxx"
27 #include "xlstring.hxx"
29 // Export progress bar ========================================================
31 class ScfProgressBar;
41 class XclExpProgressBar : protected XclExpRoot
42 {
43 public:
44  explicit XclExpProgressBar( const XclExpRoot& rRoot );
45  virtual ~XclExpProgressBar() override;
48  void Initialize();
51  void IncRowRecordCount();
59  void Progress();
61 private:
62  typedef std::unique_ptr< ScfProgressBar > ScfProgressBarPtr;
64  ScfProgressBarPtr mxProgress;
71  sal_Int32 mnSegRowFinal;
73  std::size_t mnRowCount;
74 };
76 // Calc->Excel cell address/range conversion ==================================
80 {
81 public:
82  explicit XclExpAddressConverter( const XclExpRoot& rRoot );
84  // cell address -----------------------------------------------------------
91  bool CheckAddress( const ScAddress& rScPos, bool bWarn );
99  bool ConvertAddress( XclAddress& rXclPos,
100  const ScAddress& rScPos, bool bWarn );
107  XclAddress CreateValidAddress( const ScAddress& rScPos, bool bWarn );
109  // cell range -------------------------------------------------------------
116  bool CheckRange( const ScRange& rScRange, bool bWarn );
126  bool ValidateRange( ScRange& rScRange, bool bWarn );
134  bool ConvertRange( XclRange& rXclRange, const ScRange& rScRange, bool bWarn );
136  // cell range list --------------------------------------------------------
147  void ValidateRangeList( ScRangeList& rScRanges, bool bWarn );
159  void ConvertRangeList( XclRangeList& rXclRanges,
160  const ScRangeList& rScRanges, bool bWarn );
161 };
163 // EditEngine->String conversion ==============================================
165 class SvxURLField;
166 class XclExpHyperlink;
176 {
177 public:
180  explicit XclExpHyperlinkHelper( const XclExpRoot& rRoot, const ScAddress& rScPos );
181  virtual ~XclExpHyperlinkHelper() override;
185  OUString ProcessUrlField( const SvxURLField& rUrlField );
188  bool HasLinkRecord() const;
190  XclExpHyperlinkRef GetLinkRecord() const;
193  bool HasMultipleUrls() const { return mbMultipleUrls; }
195  const OUString& GetUrlList() const { return maUrlList; }
197 private:
198  XclExpHyperlinkRef mxLinkRec;
200  OUString maUrlList;
202 };
204 class EditEngine;
205 class EditTextObject;
206 class SdrTextObj;
207 class ScPatternAttr;
213 {
214 public:
216  XclExpStringHelper(const XclExpStringHelper &) = delete;
218  const XclExpStringHelper& operator=(const XclExpStringHelper&) = delete;
221  XclExpStringHelper() = delete;
231  const XclExpRoot& rRoot,
232  const OUString& rString,
234  sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
244  const XclExpRoot& rRoot,
245  sal_Unicode cChar,
247  sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
254  static void AppendString(
255  XclExpString& rXclString,
256  const XclExpRoot& rRoot,
257  const OUString& rString );
264  static void AppendChar(
265  XclExpString& rXclString,
266  const XclExpRoot& rRoot,
267  sal_Unicode cChar );
280  const XclExpRoot& rRoot,
281  const OUString& rString,
282  const ScPatternAttr* pCellAttr,
284  sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
296  const XclExpRoot& rRoot,
297  const EditTextObject& rEditText,
298  const ScPatternAttr* pCellAttr,
299  XclExpHyperlinkHelper& rLinkHelper,
301  sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
310  const XclExpRoot& rRoot,
311  const SdrTextObj& rTextObj,
312  XclStrFlags nFlags = XclStrFlags::NONE );
319  const XclExpRoot& rRoot,
320  const EditTextObject& rEditObj,
321  XclStrFlags nFlags = XclStrFlags::NONE );
325  static sal_Int16 GetLeadingScriptType( const XclExpRoot& rRoot, const OUString& rString );
326 };
328 // Header/footer conversion ===================================================
359 class XclExpHFConverter : protected XclExpRoot
360 {
361 public:
363  XclExpHFConverter(const XclExpHFConverter&) = delete;
365  const XclExpHFConverter& operator=(const XclExpHFConverter&) = delete;
367  explicit XclExpHFConverter( const XclExpRoot& rRoot );
370  void GenerateString(
371  const EditTextObject* pLeftObj,
372  const EditTextObject* pCenterObj,
373  const EditTextObject* pRightObj );
376  const OUString& GetHFString() const { return maHFString; }
378  sal_Int32 GetTotalHeight() const { return mnTotalHeight; }
380 private:
382  void AppendPortion(
383  const EditTextObject* pTextObj,
384  sal_Unicode cPortionCode );
386 private:
388  OUString maHFString;
389  sal_Int32 mnTotalHeight;
390 };
392 // URL conversion =============================================================
398 {
399 public:
401  XclExpUrlHelper(const XclExpUrlHelper&) = delete;
403  const XclExpUrlHelper& operator=(const XclExpUrlHelper&) = delete;
406  XclExpUrlHelper() = delete;
410  static OUString EncodeUrl( const XclExpRoot& rRoot, const OUString& rAbsUrl, const OUString* pTableName = nullptr );
412  static OUString EncodeDde( const OUString& rApplic, const OUString& rTopic );
413 };
415 class ScMatrix;
419 {
420  void GetDimensions( SCSIZE & nCols, SCSIZE & nRows ) const;
421 public:
424  explicit XclExpCachedMatrix( const ScMatrix& rMatrix );
428  std::size_t GetSize() const;
430  void Save( XclExpStream& rStrm ) const;
432 private:
434 };
436 #endif
438 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< XclExpHyperlink > XclExpHyperlinkRef
Definition: xehelper.hxx:178
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:113
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:43
const sal_uInt16 EXC_STR_MAXLEN
Definition: xlstring.hxx:43
XclExpHyperlinkRef mxLinkRec
Definition: xehelper.hxx:198
sal_Int32 mnSegRowFinal
Sub progress bar for finalizing ROW records.
Definition: xehelper.hxx:71
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:41
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:71
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:29
void Initialize()
Initializes all segments and sub progress bars.
Definition: xehelper.cxx:77
ScAddress maScPos
Created HLINK record.
Definition: xehelper.hxx:199
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:64
ScfProgressBar * mpSubRowCreate
Current sub progress bar.
Definition: xehelper.hxx:67
EditEngine & mrEE
Definition: xehelper.hxx:387
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:195
sal_uInt16 sal_Unicode
Access to global data from other classes.
Definition: xeroot.hxx:113
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:45
Helper to create HLINK records during creation of formatted cell strings.
Definition: xehelper.hxx:175
bool mbMultipleUrls
List with all processed URLs.
Definition: xehelper.hxx:201
ScfInt32Vec maSubSegRowCreate
Sub progress bar for creating table rows.
Definition: xehelper.hxx:68
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:418
OUString maHFString
The header/footer edit engine.
Definition: xehelper.hxx:388
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:101
bool HasMultipleUrls() const
Returns true, if multiple URLs have been processed.
Definition: xehelper.hxx:193
const ScMatrix & mrMatrix
Definition: xehelper.hxx:433
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:62
OUString maUrlList
Cell position to set at the HLINK record.
Definition: xehelper.hxx:200
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:30
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:397
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:378
static OUString EncodeDde(const OUString &rApplic, const OUString &rTopic)
Encodes and returns the passed DDE link to an Excel like DDE link.
Definition: xehelper.cxx:983
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:65
const XclExpUrlHelper & operator=(const XclExpUrlHelper &)=delete
delete copy-assignment operator
Provides functions to convert Calc cell addresses to Excel cell addresses.
Definition: xehelper.hxx:79
std::size_t mnRowCount
Progress segment for finalizing ROW records.
Definition: xehelper.hxx:73
sal_Int32 mnTotalHeight
The last generated header/footer string.
Definition: xehelper.hxx:389
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:376
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:139
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:212
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:36
::std::vector< sal_Int32 > ScfInt32Vec
Definition: ftools.hxx:255
ScfProgressBar * mpSubRowFinal
Segment ID's for all sheets in sub progress bar.
Definition: xehelper.hxx:70
void SvStream & rStrm
Converts edit engine text objects to an Excel header/footer string.
Definition: xehelper.hxx:359
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:58