summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/BorderHandler.cxx
blob: 98ea06beed56093dad52f5ca31c445075e62013d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: BorderHandler.cxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: fridrich_strba $ $Date: 2007-04-25 14:04:47 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef INCLUDED_BORDERHANDLER_HXX
#include <BorderHandler.hxx>
#endif
#ifndef INCLUDED_DMAPPER_PROPERTYMAP_HXX
#include <PropertyMap.hxx>
#endif
#ifndef INCLUDED_RESOURCESIDS
#include <doctok/resourceids.hxx>
#endif
#ifndef INCLUDED_DMAPPER_CONVERSIONHELPER_HXX
#include <ConversionHelper.hxx>
#endif
#ifndef _COM_SUN_STAR_TABLE_BORDERLINE_HPP_
#include <com/sun/star/table/BorderLine.hpp>
#endif

namespace dmapper {

using namespace ::com::sun::star;
using namespace writerfilter;
//using namespace ::std;

/*-- 24.04.2007 09:06:35---------------------------------------------------

  -----------------------------------------------------------------------*/
BorderHandler::BorderHandler() :
    m_nCurrentBorderPosition( BORDER_TOP ),
    m_nLineWidth(0),
    m_nLineType(0),
    m_nLineColor(0),
    m_nLineDistance(0)
{
    m_aTableBorder.IsTopLineValid = sal_False;;
    m_aTableBorder.IsBottomLineValid = sal_False;;
    m_aTableBorder.IsLeftLineValid = sal_False;;
    m_aTableBorder.IsRightLineValid = sal_False;;
    m_aTableBorder.IsHorizontalLineValid = sal_False;;
    m_aTableBorder.IsVerticalLineValid = sal_False;;
    m_aTableBorder.IsDistanceValid = sal_False;
}
/*-- 24.04.2007 09:06:35---------------------------------------------------

  -----------------------------------------------------------------------*/
BorderHandler::~BorderHandler()
{
}
/*-- 24.04.2007 09:06:35---------------------------------------------------

  -----------------------------------------------------------------------*/
void BorderHandler::attribute(doctok::Id rName, doctok::Value & rVal)
{
    sal_Int32 nIntValue = rVal.getInt();
    switch( rName )
    {
        case NS_rtf::LN_rgbrc:
        {
            doctok::Reference<Properties>::Pointer_t pProperties = rVal.getProperties();
            if( pProperties.get())
            {
                pProperties->resolve(*this);
                //
                table::BorderLine* pToFill = 0;
                switch(m_nCurrentBorderPosition)
                {
                    case BORDER_TOP:
                        pToFill = &m_aTableBorder.TopLine;
                        m_aTableBorder.IsTopLineValid = sal_True;
                    break;
                    case BORDER_LEFT:
                        pToFill = &m_aTableBorder.LeftLine;
                        m_aTableBorder.IsLeftLineValid = sal_True;
                    break;
                    case BORDER_BOTTOM:
                        pToFill = &m_aTableBorder.BottomLine;
                        m_aTableBorder.IsBottomLineValid = sal_True;;
                    break;
                    case BORDER_RIGHT:
                        pToFill = &m_aTableBorder.RightLine;
                        m_aTableBorder.IsRightLineValid = sal_True;
                    break;
                    case BORDER_HORIZONTAL:
                        pToFill = &m_aTableBorder.HorizontalLine;
                        m_aTableBorder.IsHorizontalLineValid = sal_True;;
                    break;
                    case BORDER_VERTICAL:
                        m_aTableBorder.IsVerticalLineValid = sal_True;;
                    default:
                        pToFill = &m_aTableBorder.VerticalLine; break;
                }
                ConversionHelper::MakeBorderLine( m_nLineWidth,   m_nLineType, m_nLineColor,  *pToFill );
                OSL_ENSURE(m_nCurrentBorderPosition <= BORDER_VERTICAL, "too many border values");
                ++m_nCurrentBorderPosition;
            }
        }
        break;
        case NS_rtf::LN_DPTLINEWIDTH: // 0x2871
            //  width of a single line in 1/8 pt, max of 32 pt -> twip * 5 / 2.
            m_nLineWidth = ConversionHelper::convertToMM100( nIntValue * 5 / 2 );
        break;
        case NS_rtf::LN_BRCTYPE:    // 0x2872
            m_nLineType = nIntValue;
        break;
        case NS_rtf::LN_ICO:        // 0x2873
            m_nLineColor = nIntValue;
        break;
        case NS_rtf::LN_DPTSPACE:   // 0x2874
            m_nLineDistance = nIntValue;
        break;
        case NS_rtf::LN_FSHADOW:    // 0x2875
            //if 1 then line has shadow - unsupported
        case NS_rtf::LN_FFRAME:     // 0x2876
        case NS_rtf::LN_UNUSED2_15: // 0x2877
            // ignored
        break;
        default:
            OSL_ASSERT("unknown attribute");
    }
}
/*-- 24.04.2007 09:06:35---------------------------------------------------

  -----------------------------------------------------------------------*/
void BorderHandler::sprm(doctok::Sprm & rSprm)
{
    (void)rSprm;
}
/*-- 24.04.2007 09:09:01---------------------------------------------------

  -----------------------------------------------------------------------*/
PropertyMapPtr  BorderHandler::getProperties()
{
    PropertyMapPtr pPropertyMap(new PropertyMap);
    pPropertyMap->Insert( PROP_TABLE_BORDER, uno::makeAny( m_aTableBorder ) );
    return pPropertyMap;
}
} //namespace dmapper