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