1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <tablecolumnsbuffer.hxx>
22 #include <sal/log.hxx>
23 #include <oox/helper/attributelist.hxx>
24 #include <oox/token/tokens.hxx>
30 TableColumn::TableColumn( const WorkbookHelper
& rHelper
) :
31 WorkbookHelper( rHelper
),
37 void TableColumn::importTableColumn( const AttributeList
& rAttribs
)
39 mnId
= rAttribs
.getInteger( XML_id
, -1 );
40 maName
= rAttribs
.getString( XML_name
, OUString() );
41 mnDataDxfId
= rAttribs
.getInteger( XML_dataDxfId
, -1 );
44 void TableColumn::importTableColumn( SequenceInputStream
& /*rStrm*/ )
46 /* XXX not implemented */
50 const OUString
& TableColumn::getName() const
55 TableColumns::TableColumns( const WorkbookHelper
& rHelper
) :
56 WorkbookHelper( rHelper
),
61 void TableColumns::importTableColumns( const AttributeList
& rAttribs
)
63 mnCount
= rAttribs
.getInteger( XML_count
, 0 );
66 void TableColumns::importTableColumns( SequenceInputStream
& /*rStrm*/ )
68 /* XXX not implemented */
72 TableColumn
& TableColumns::createTableColumn()
74 TableColumnVector::value_type
xTableColumn( new TableColumn( *this ) );
75 maTableColumnVector
.push_back( xTableColumn
);
79 bool TableColumns::finalizeImport( ScDBData
* pDBData
)
81 SAL_WARN_IF( static_cast<size_t>(mnCount
) != maTableColumnVector
.size(), "sc.filter",
82 "TableColumns::finalizeImport - count attribute doesn't match number of tableColumn elements");
85 /* TODO: use svl::SharedString for names */
86 ::std::vector
< OUString
> aNames( maTableColumnVector
.size());
88 for (const auto& rxTableColumn
: maTableColumnVector
)
90 aNames
[i
] = rxTableColumn
->getName();
93 pDBData
->SetTableColumnNames( aNames
);
99 TableColumnsBuffer::TableColumnsBuffer( const WorkbookHelper
& rHelper
) :
100 WorkbookHelper( rHelper
)
104 TableColumns
& TableColumnsBuffer::createTableColumns()
106 TableColumnsVector::value_type
xTableColumns( new TableColumns( *this ) );
107 maTableColumnsVector
.push_back( xTableColumns
);
108 return *xTableColumns
;
111 void TableColumnsBuffer::finalizeImport( ScDBData
* pDBData
)
113 TableColumns
* pTableColumns
= getActiveTableColumns();
115 pTableColumns
->finalizeImport( pDBData
);
118 TableColumns
* TableColumnsBuffer::getActiveTableColumns()
120 // not more than one table columns descriptor per table
121 SAL_WARN_IF( maTableColumnsVector
.size() > 1, "sc.filter",
122 "TableColumnsBuffer::getActiveTableColumns - too many table columns" );
123 // stick to the last imported table columns
124 return maTableColumnsVector
.empty() ? nullptr : maTableColumnsVector
.back().get();
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */