| /************************************************************** |
| * |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| * |
| *************************************************************/ |
| |
| #include "PageBordersHandler.hxx" |
| |
| #include <ooxml/resourceids.hxx> |
| |
| #include "dmapperLoggers.hxx" |
| |
| namespace writerfilter { |
| namespace dmapper { |
| |
| _PgBorder::_PgBorder( ) : |
| m_nDistance( 0 ), |
| m_ePos( BORDER_RIGHT ) |
| { |
| } |
| |
| _PgBorder::~_PgBorder( ) |
| { |
| } |
| |
| PageBordersHandler::PageBordersHandler( ) : |
| LoggedProperties(dmapper_logger, "PageBordersHandler"), |
| m_nDisplay( 0 ), |
| m_nOffset( 0 ) |
| { |
| } |
| |
| PageBordersHandler::~PageBordersHandler( ) |
| { |
| } |
| |
| void PageBordersHandler::lcl_attribute( Id eName, Value& rVal ) |
| { |
| int nIntValue = rVal.getInt( ); |
| switch ( eName ) |
| { |
| case NS_ooxml::LN_CT_PageBorders_display: |
| { |
| switch ( nIntValue ) |
| { |
| default: |
| case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_allPages: |
| m_nDisplay = 0; |
| break; |
| case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_firstPage: |
| m_nDisplay = 1; |
| break; |
| case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_notFirstPage: |
| m_nDisplay = 2; |
| break; |
| } |
| } |
| break; |
| case NS_ooxml::LN_CT_PageBorders_offsetFrom: |
| { |
| switch ( nIntValue ) |
| { |
| default: |
| case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_page: |
| m_nOffset = 1; |
| break; |
| case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_text: |
| m_nOffset = 0; |
| break; |
| } |
| } |
| break; |
| default:; |
| } |
| } |
| |
| void PageBordersHandler::lcl_sprm( Sprm& rSprm ) |
| { |
| switch ( rSprm.getId( ) ) |
| { |
| case NS_ooxml::LN_CT_PageBorders_top: |
| case NS_ooxml::LN_CT_PageBorders_left: |
| case NS_ooxml::LN_CT_PageBorders_bottom: |
| case NS_ooxml::LN_CT_PageBorders_right: |
| { |
| writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); |
| if( pProperties.get()) |
| { |
| BorderHandlerPtr pBorderHandler( new BorderHandler( true ) ); |
| pProperties->resolve(*pBorderHandler); |
| BorderPosition ePos = BorderPosition( 0 ); |
| switch( rSprm.getId( ) ) |
| { |
| case NS_ooxml::LN_CT_PageBorders_top: |
| ePos = BORDER_TOP; |
| break; |
| case NS_ooxml::LN_CT_PageBorders_left: |
| ePos = BORDER_LEFT; |
| break; |
| case NS_ooxml::LN_CT_PageBorders_bottom: |
| ePos = BORDER_BOTTOM; |
| break; |
| case NS_ooxml::LN_CT_PageBorders_right: |
| ePos = BORDER_RIGHT; |
| break; |
| default:; |
| } |
| |
| _PgBorder aPgBorder; |
| aPgBorder.m_rLine = pBorderHandler->getBorderLine( ); |
| aPgBorder.m_nDistance = pBorderHandler->getLineDistance( ); |
| aPgBorder.m_ePos = ePos; |
| m_aBorders.push_back( aPgBorder ); |
| } |
| } |
| break; |
| default:; |
| } |
| } |
| |
| void PageBordersHandler::SetBorders( SectionPropertyMap* pSectContext ) |
| { |
| for ( int i = 0, length = m_aBorders.size( ); i < length; i++ ) |
| { |
| _PgBorder aBorder = m_aBorders[i]; |
| pSectContext->SetBorder( aBorder.m_ePos, aBorder.m_nDistance, aBorder.m_rLine ); |
| } |
| } |
| |
| } } |