23#include <osl/diagnose.h>
25#include <oox/token/namespaces.hxx>
26#include <oox/token/tokens.hxx>
35const sal_Int32 BIFF12_RECONNECT_AS_REQUIRED = 1;
37const sal_uInt8 BIFF12_CONNECTION_SAVEPASSWORD_ON = 1;
39const sal_uInt16 BIFF12_CONNECTION_KEEPALIVE = 0x0001;
40const sal_uInt16 BIFF12_CONNECTION_NEW = 0x0002;
41const sal_uInt16 BIFF12_CONNECTION_DELETED = 0x0004;
42const sal_uInt16 BIFF12_CONNECTION_ONLYUSECONNFILE = 0x0008;
43const sal_uInt16 BIFF12_CONNECTION_BACKGROUND = 0x0010;
44const sal_uInt16 BIFF12_CONNECTION_REFRESHONLOAD = 0x0020;
45const sal_uInt16 BIFF12_CONNECTION_SAVEDATA = 0x0040;
47const sal_uInt16 BIFF12_CONNECTION_HAS_SOURCEFILE = 0x0001;
48const sal_uInt16 BIFF12_CONNECTION_HAS_SOURCECONNFILE = 0x0002;
49const sal_uInt16 BIFF12_CONNECTION_HAS_DESCRIPTION = 0x0004;
50const sal_uInt16 BIFF12_CONNECTION_HAS_NAME = 0x0008;
51const sal_uInt16 BIFF12_CONNECTION_HAS_SSOID = 0x0010;
53const sal_uInt32 BIFF12_WEBPR_XML = 0x00000100;
54const sal_uInt32 BIFF12_WEBPR_SOURCEDATA = 0x00000200;
55const sal_uInt32 BIFF12_WEBPR_PARSEPRE = 0x00000400;
56const sal_uInt32 BIFF12_WEBPR_CONSECUTIVE = 0x00000800;
57const sal_uInt32 BIFF12_WEBPR_FIRSTROW = 0x00001000;
58const sal_uInt32 BIFF12_WEBPR_XL97CREATED = 0x00002000;
59const sal_uInt32 BIFF12_WEBPR_TEXTDATES = 0x00004000;
60const sal_uInt32 BIFF12_WEBPR_XL2000REFRESHED = 0x00008000;
61const sal_uInt32 BIFF12_WEBPR_HTMLTABLES = 0x00010000;
63const sal_uInt8 BIFF12_WEBPR_HAS_POSTMETHOD = 0x01;
64const sal_uInt8 BIFF12_WEBPR_HAS_EDITPAGE = 0x02;
65const sal_uInt8 BIFF12_WEBPR_HAS_URL = 0x04;
72 mbSourceData( false ),
74 mbConsecutive( false ),
76 mbXl97Created( false ),
78 mbXl2000Refreshed( false ),
86 mnReconnectMethod( BIFF12_RECONNECT_AS_REQUIRED ),
87 mnCredentials( XML_integrated ),
92 mbOnlyUseConnFile( false ),
93 mbBackground( false ),
94 mbRefreshOnLoad( false ),
96 mbSavePassword( false )
102 OSL_ENSURE( !
mxWebPr,
"ConnectionModel::createWebPr - multiple call" );
159 OSL_ENSURE(
maModel.
mxWebPr->maTables.empty(),
"Connection::importTables - multiple calls" );
172 case XLS_TOKEN(
m ):
break;
173 case XLS_TOKEN( s ): aTableAny <<= rAttribs.
getXString( XML_v, OUString() );
break;
174 case XLS_TOKEN(
x ): aTableAny <<= rAttribs.
getInteger( XML_v, -1 );
break;
176 OSL_ENSURE(
false,
"Connection::importTable - unexpected element" );
184 sal_uInt16 nFlags, nStrFlags;
187 nSavePassword =
rStrm.readuChar();
190 nFlags =
rStrm.readuInt16();
191 nStrFlags =
rStrm.readuInt16();
195 nCredentials =
rStrm.readuChar();
197 if(
getFlag( nStrFlags, BIFF12_CONNECTION_HAS_SOURCEFILE ) )
199 if(
getFlag( nStrFlags, BIFF12_CONNECTION_HAS_SOURCECONNFILE ) )
201 if(
getFlag( nStrFlags, BIFF12_CONNECTION_HAS_DESCRIPTION ) )
203 if(
getFlag( nStrFlags, BIFF12_CONNECTION_HAS_NAME ) )
205 if(
getFlag( nStrFlags, BIFF12_CONNECTION_HAS_SSOID ) )
208 static const sal_Int32 spnCredentials[] = { XML_integrated,
XML_none, XML_stored, XML_prompt };
227 nFlags =
rStrm.readuInt32();
228 nStrFlags =
rStrm.readuChar();
230 if(
getFlag( nStrFlags, BIFF12_WEBPR_HAS_URL ) )
232 if(
getFlag( nStrFlags, BIFF12_WEBPR_HAS_POSTMETHOD ) )
234 if(
getFlag( nStrFlags, BIFF12_WEBPR_HAS_EDITPAGE ) )
237 static const sal_Int32 spnHmlFormats[] = {
XML_none, XML_rtf, XML_all };
255 OSL_ENSURE(
maModel.
mxWebPr->maTables.empty(),
"Connection::importWebPrTables - multiple calls" );
272 OSL_ENSURE(
false,
"Connection::importWebPrTable - unexpected record" );
286 ConnectionRef xConnection = std::make_shared<Connection>( *
this );
304 sal_Int32 nConnId = rxConnection->getConnectionId();
307 OSL_ENSURE( !
maConnectionsById.
has( nConnId ),
"ConnectionsBuffer::insertConnectionToMap - multiple connection identifier" );
std::optional< OUString > getXString(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
std::optional< bool > getBool(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
bool has(key_type nKey) const
mapped_type get(key_type nKey) const
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
An external data connection (database, web query, etc.).
void importTables()
Imports web query table settings from the tables element.
void importWebPr(const AttributeList &rAttribs)
Imports web query settings from the webPr element.
void importWebPrTable(SequenceInputStream &rStrm, sal_Int32 nRecId)
Imports a web query table identifier from the PCITEM_MISSING, PCITEM_STRING, or PCITEM_INDEX record.
void importTable(const AttributeList &rAttribs, sal_Int32 nElement)
Imports a web query table identifier from the m, s, or x element.
Connection(const WorkbookHelper &rHelper)
void importConnection(const AttributeList &rAttribs)
Imports connection settings from the connection element.
void importWebPrTables(SequenceInputStream &rStrm)
Imports web query table settings from the WEBPRTABLES record.
ConnectionRef getConnection(sal_Int32 nConnId) const
Returns a data connection by its unique identifier.
ConnectionsBuffer(const WorkbookHelper &rHelper)
void finalizeImport()
Maps all connections by their identifier.
Connection & createConnection()
Creates a new empty connection.
void insertConnectionToMap(const ConnectionRef &rxConnection)
Inserts the passed connection into the map according to its identifier.
ConnectionMap maConnectionsById
ConnectionVector maConnections
Helper class to provide access to global workbook data.
#define STATIC_ARRAY_SELECT(array, index, def)
const sal_Int32 BIFF12_ID_PCITEM_INDEX
const sal_Int32 BIFF12_ID_PCITEM_MISSING
const sal_Int32 BIFF12_CONNECTION_UNKNOWN
std::shared_ptr< Connection > ConnectionRef
const sal_Int32 BIFF12_ID_PCITEM_STRING
bool getFlag(Type nBitField, Type nMask)
sal_Int32 mnId
Single sign-on identifier.
sal_Int32 mnInterval
Credentials method.
sal_Int32 mnReconnectMethod
Data source type.
OUString maName
Special settings for web queries.
OUString maSsoId
URL of a source connection file.
bool mbSavePassword
True = save cached data with connection.
bool mbKeepAlive
Refresh interval in minutes.
bool mbSaveData
True = refresh connection on import.
bool mbBackground
True = use maSourceConnFile, ignore mnReconnectMethod.
bool mbNew
True = keep connection open after import.
ConnectionModel()
True = save password in connection string.
bool mbRefreshOnLoad
True = background refresh enabled.
OUString maDescription
Unique name of this connection.
WebPrModel & createWebPr()
sal_Int32 mnCredentials
Reconnection method.
OUString maSourceFile
User description of this connection.
bool mbDeleted
True = new connection, never updated.
sal_Int32 mnType
Unique connection identifier.
OUString maSourceConnFile
URL of a source data file.
bool mbOnlyUseConnFile
True = connection has been deleted.
Special properties for data connections representing web queries.
WebPrModel()
True = HTML tables, false = entire document.
OUString maPostMethod
Source URL to refresh the data.
OUString maEditPage
POST method to query data.
bool mbXl2000Refreshed
True = read date values as text, false = parse dates.
bool mbHtmlTables
True = refreshed with Excel 2000 or newer.
bool mbTextDates
True = web query created with Excel 97.
bool mbXl97Created
True = use column widths of first row for entire.
bool mbParsePre
True = import XML source data referred by HTML table.
bool mbConsecutive
True = parse preformatted sections (.
OUString maUrl
Names or indexes of the web query tables.
bool mbSourceData
True = XML query, false = HTML query.
bool mbFirstRow
True = join consecutive delimiters.
sal_Int32 mnHtmlFormat
Web page showing query data (for XML queries).
bool mbXml
Plain text, rich text, or HTML.