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 #ifndef INCLUDED_TABLEPROPERTIESHANDLER_HXX
23 #define INCLUDED_TABLEPROPERTIESHANDLER_HXX
24 
25 #include <PropertyMap.hxx>
26 
27 #include <resourcemodel/TableManager.hxx>
28 #include <WriterFilterDllApi.hxx>
29 #include <resourcemodel/WW8ResourceModel.hxx>
30 
31 #include <boost/shared_ptr.hpp>
32 
33 #include <vector>
34 
35 namespace writerfilter {
36 namespace dmapper {
37 
38 
39 typedef ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > Handle_t;
40 typedef TableManager<Handle_t , TablePropertyMapPtr > DomainMapperTableManager_Base_t;
41 
42 class TablePropertiesHandler
43 {
44 private:
45     vector< PropertyMapPtr > m_rPropertiesStack;
46     PropertyMapPtr m_pCurrentProperties;
47     DomainMapperTableManager_Base_t *m_pTableManager;
48     bool m_bOOXML;
49 
50 public:
51     TablePropertiesHandler( bool bOOXML );
52     virtual ~TablePropertiesHandler( );
53 
54     bool sprm(Sprm & sprm);
55 
SetTableManager(DomainMapperTableManager_Base_t * pTableManager)56     inline void SetTableManager( DomainMapperTableManager_Base_t *pTableManager )
57     {
58         m_pTableManager = pTableManager;
59     };
60 
SetProperties(PropertyMapPtr pProperties)61     inline void SetProperties( PropertyMapPtr pProperties )
62     {
63         m_pCurrentProperties = pProperties;
64     };
65 
66 private:
67 
cellProps(TablePropertyMapPtr pProps)68     inline void cellProps( TablePropertyMapPtr pProps )
69     {
70         if ( m_pTableManager )
71             m_pTableManager->cellProps( pProps );
72         else
73             m_pCurrentProperties->insert( pProps, true );
74     };
75 
cellPropsByCell(unsigned int i,TablePropertyMapPtr pProps)76     inline void cellPropsByCell( unsigned int i, TablePropertyMapPtr pProps )
77     {
78         if ( m_pTableManager )
79             m_pTableManager->cellPropsByCell( i, pProps );
80         else
81             m_pCurrentProperties->insert( pProps, true );
82     };
83 
insertRowProps(TablePropertyMapPtr pProps)84     inline void insertRowProps( TablePropertyMapPtr pProps )
85     {
86         if ( m_pTableManager )
87             m_pTableManager->insertRowProps( pProps );
88         else
89             m_pCurrentProperties->insert( pProps, true );
90     };
91 
insertTableProps(TablePropertyMapPtr pProps)92     inline void insertTableProps( TablePropertyMapPtr pProps )
93     {
94         if ( m_pTableManager )
95             m_pTableManager->insertTableProps( pProps );
96         else
97             m_pCurrentProperties->insert( pProps, true );
98     };
99 };
100 typedef boost::shared_ptr<TablePropertiesHandler> TablePropertiesHandlerPtr;
101 
102 } }
103 
104 #endif
105