merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / source / dmapper / PageBordersHandler.cxx
blob52806974046790de9f3b892c5a03d7060888ca2f
1 #include "PageBordersHandler.hxx"
3 #include <ooxml/resourceids.hxx>
5 namespace writerfilter {
6 namespace dmapper {
8 _PgBorder::_PgBorder( ) :
9 m_nDistance( 0 ),
10 m_ePos( BORDER_RIGHT )
14 _PgBorder::~_PgBorder( )
18 PageBordersHandler::PageBordersHandler( ) :
19 m_nDisplay( 0 ),
20 m_nOffset( 0 )
24 PageBordersHandler::~PageBordersHandler( )
28 void PageBordersHandler::attribute( Id eName, Value& rVal )
30 int nIntValue = rVal.getInt( );
31 switch ( eName )
33 case NS_ooxml::LN_CT_PageBorders_display:
35 switch ( nIntValue )
37 default:
38 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_allPages:
39 m_nDisplay = 0;
40 break;
41 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_firstPage:
42 m_nDisplay = 1;
43 break;
44 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_notFirstPage:
45 m_nDisplay = 2;
46 break;
49 break;
50 case NS_ooxml::LN_CT_PageBorders_offsetFrom:
52 switch ( nIntValue )
54 default:
55 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_page:
56 m_nOffset = 1;
57 break;
58 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_text:
59 m_nOffset = 0;
60 break;
63 break;
64 default:;
68 void PageBordersHandler::sprm( Sprm& rSprm )
70 switch ( rSprm.getId( ) )
72 case NS_ooxml::LN_CT_PageBorders_top:
73 case NS_ooxml::LN_CT_PageBorders_left:
74 case NS_ooxml::LN_CT_PageBorders_bottom:
75 case NS_ooxml::LN_CT_PageBorders_right:
77 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
78 if( pProperties.get())
80 BorderHandlerPtr pBorderHandler( new BorderHandler( true ) );
81 pProperties->resolve(*pBorderHandler);
82 BorderPosition ePos = BorderPosition( 0 );
83 switch( rSprm.getId( ) )
85 case NS_ooxml::LN_CT_PageBorders_top:
86 ePos = BORDER_TOP;
87 break;
88 case NS_ooxml::LN_CT_PageBorders_left:
89 ePos = BORDER_LEFT;
90 break;
91 case NS_ooxml::LN_CT_PageBorders_bottom:
92 ePos = BORDER_BOTTOM;
93 break;
94 case NS_ooxml::LN_CT_PageBorders_right:
95 ePos = BORDER_RIGHT;
96 break;
97 default:;
100 _PgBorder aPgBorder;
101 aPgBorder.m_rLine = pBorderHandler->getBorderLine( );
102 aPgBorder.m_nDistance = pBorderHandler->getLineDistance( );
103 aPgBorder.m_ePos = ePos;
104 m_aBorders.push_back( aPgBorder );
107 break;
108 default:;
112 void PageBordersHandler::SetBorders( SectionPropertyMap* pSectContext )
114 for ( int i = 0, length = m_aBorders.size( ); i < length; i++ )
116 _PgBorder aBorder = m_aBorders[i];
117 pSectContext->SetBorder( aBorder.m_ePos, aBorder.m_nDistance, aBorder.m_rLine );