xref: /AOO41X/main/xmloff/inc/xmloff/table/XMLTableExport.hxx (revision ecfe53c5d1886e1e0d215b0d140d05282ab1c477)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _XMLOFF_XMLTABLEEXPORT_HXX
24 #define _XMLOFF_XMLTABLEEXPORT_HXX
25 
26 #include "sal/config.h"
27 
28 #include <sal/types.h>
29 #include <rtl/ustring.hxx>
30 #include <rtl/ustrbuf.hxx>
31 
32 #include <boost/shared_ptr.hpp>
33 #include <map>
34 #include <vector>
35 
36 #include <com/sun/star/table/XTableColumns.hpp>
37 #include <com/sun/star/table/XColumnRowRange.hpp>
38 #include <com/sun/star/table/XCell.hpp>
39 #include <com/sun/star/text/XText.hpp>
40 #include <com/sun/star/container/XIndexAccess.hpp>
41 
42 #include <rtl/ref.hxx>
43 
44 #include "xmloff/dllapi.h"
45 #include "xmloff/uniref.hxx"
46 #include "xmloff/xmlprmap.hxx"
47 #include "xmloff/xmlexppr.hxx"
48 
49 
50 //////////////////////////////////////////////////////////////////////////////
51 // predeclarations
52 
53 class SvXMLExport;
54 class SvXMLExportPropertyMapper;
55 
56 typedef ::std::map< const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >, rtl::OUString > TableStyleMap;
57 
58 struct XMLTableInfo
59 {
60     TableStyleMap   maColumnStyleMap;
61     TableStyleMap   maRowStyleMap;
62     TableStyleMap   maCellStyleMap;
63     std::vector< ::rtl::OUString > maDefaultRowCellStyles;
64 };
65 
66 typedef ::std::map< const ::com::sun::star::uno::Reference< com::sun::star::table::XColumnRowRange >, boost::shared_ptr< XMLTableInfo > > TableInfoMap;
67 
68 class XMLOFF_DLLPUBLIC XMLTableExport : public UniRefBase
69 {
70 public:
71     XMLTableExport(SvXMLExport& rExp, const rtl::Reference< SvXMLExportPropertyMapper >& xCellExportPropertySetMapper, const rtl::Reference< XMLPropertyHandlerFactory >& xFactoryRef );
72     virtual ~XMLTableExport();
73 
74     // This method collects all automatic styles for the given table
75     void collectTableAutoStyles(const com::sun::star::uno::Reference < com::sun::star::table::XColumnRowRange >& xColumnRowRange);
76 
77     // This method exports the given table
78     void exportTable(const com::sun::star::uno::Reference < com::sun::star::table::XColumnRowRange >& xColumnRowRange);
79 
80     // export the styles from the cell style family
81     void exportTableStyles();
82 
83     // Export the collected automatic styles
84     void exportAutoStyles();
85 
86 private:
87     void exportTableTemplates();
88 
89     SvXMLExport&                                    mrExport;
90     rtl::Reference< SvXMLExportPropertyMapper >     mxCellExportPropertySetMapper;
91     rtl::Reference< SvXMLExportPropertyMapper >     mxRowExportPropertySetMapper;
92     rtl::Reference< SvXMLExportPropertyMapper >     mxColumnExportPropertySetMapper;
93     TableInfoMap                                    maTableInfoMap;
94     bool                                            mbExportTables;
95 
96 protected:
GetExport()97     SvXMLExport& GetExport() { return mrExport; }
GetExport() const98     const SvXMLExport& GetExport() const  { return mrExport; }
99 private:
100 
101     SAL_DLLPRIVATE void ImpExportText( const com::sun::star::uno::Reference < com::sun::star::table::XCell >& xCell );
102 
103     void ExportCell( const com::sun::star::uno::Reference < com::sun::star::table::XCell >& xCell, const boost::shared_ptr< XMLTableInfo >& pTableInfo, const ::rtl::OUString& sDefaultCellStyle  );
104     void ExportTableColumns( const com::sun::star::uno::Reference < com::sun::star::container::XIndexAccess >& xtableColumns, const boost::shared_ptr< XMLTableInfo >& pTableInfo );
105 
106 };
107 
108 #endif
109