Bump version to 4.3-4
[LibreOffice.git] / writerfilter / source / dmapper / PageBordersHandler.cxx
blob471a85a3b0ca4fb67c1ac35244f8385d3786cafa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "PageBordersHandler.hxx"
22 #include <ooxml/resourceids.hxx>
24 #include "dmapperLoggers.hxx"
26 namespace writerfilter {
27 namespace dmapper {
29 _PgBorder::_PgBorder( ) :
30 m_nDistance( 0 ),
31 m_ePos( BORDER_RIGHT ),
32 m_bShadow(false)
36 _PgBorder::~_PgBorder( )
40 PageBordersHandler::PageBordersHandler( ) :
41 LoggedProperties(dmapper_logger, "PageBordersHandler"),
42 m_nDisplay( 0 ),
43 m_nOffset( 0 )
47 PageBordersHandler::~PageBordersHandler( )
51 void PageBordersHandler::lcl_attribute( Id eName, Value& rVal )
53 int nIntValue = rVal.getInt( );
54 switch ( eName )
56 case NS_ooxml::LN_CT_PageBorders_display:
58 switch ( nIntValue )
60 default:
61 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_allPages:
62 m_nDisplay = 0;
63 break;
64 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_firstPage:
65 m_nDisplay = 1;
66 break;
67 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_notFirstPage:
68 m_nDisplay = 2;
69 break;
72 break;
73 case NS_ooxml::LN_CT_PageBorders_offsetFrom:
75 switch ( nIntValue )
77 default:
78 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_page:
79 m_nOffset = 1;
80 break;
81 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_text:
82 m_nOffset = 0;
83 break;
86 break;
87 default:;
91 void PageBordersHandler::lcl_sprm( Sprm& rSprm )
93 switch ( rSprm.getId( ) )
95 case NS_ooxml::LN_CT_PageBorders_top:
96 case NS_ooxml::LN_CT_PageBorders_left:
97 case NS_ooxml::LN_CT_PageBorders_bottom:
98 case NS_ooxml::LN_CT_PageBorders_right:
100 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
101 if( pProperties.get())
103 BorderHandlerPtr pBorderHandler( new BorderHandler( true ) );
104 pProperties->resolve(*pBorderHandler);
105 BorderPosition ePos = BorderPosition( 0 );
106 switch( rSprm.getId( ) )
108 case NS_ooxml::LN_CT_PageBorders_top:
109 ePos = BORDER_TOP;
110 break;
111 case NS_ooxml::LN_CT_PageBorders_left:
112 ePos = BORDER_LEFT;
113 break;
114 case NS_ooxml::LN_CT_PageBorders_bottom:
115 ePos = BORDER_BOTTOM;
116 break;
117 case NS_ooxml::LN_CT_PageBorders_right:
118 ePos = BORDER_RIGHT;
119 break;
120 default:;
123 _PgBorder aPgBorder;
124 aPgBorder.m_rLine = pBorderHandler->getBorderLine( );
125 aPgBorder.m_nDistance = pBorderHandler->getLineDistance( );
126 aPgBorder.m_ePos = ePos;
127 aPgBorder.m_bShadow = pBorderHandler->getShadow();
128 m_aBorders.push_back( aPgBorder );
131 break;
132 default:;
136 void PageBordersHandler::SetBorders( SectionPropertyMap* pSectContext )
138 for ( int i = 0, length = m_aBorders.size( ); i < length; i++ )
140 _PgBorder aBorder = m_aBorders[i];
141 pSectContext->SetBorder( aBorder.m_ePos, aBorder.m_nDistance, aBorder.m_rLine, aBorder.m_bShadow );
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */