1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
{
29 _PgBorder::_PgBorder( ) :
31 m_ePos( BORDER_RIGHT
),
36 _PgBorder::~_PgBorder( )
40 PageBordersHandler::PageBordersHandler( ) :
41 LoggedProperties(dmapper_logger
, "PageBordersHandler"),
47 PageBordersHandler::~PageBordersHandler( )
51 void PageBordersHandler::lcl_attribute( Id eName
, Value
& rVal
)
53 int nIntValue
= rVal
.getInt( );
56 case NS_ooxml::LN_CT_PageBorders_display
:
61 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_allPages
:
64 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_firstPage
:
67 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_notFirstPage
:
73 case NS_ooxml::LN_CT_PageBorders_offsetFrom
:
78 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_page
:
81 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_text
:
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
:
111 case NS_ooxml::LN_CT_PageBorders_left
:
114 case NS_ooxml::LN_CT_PageBorders_bottom
:
115 ePos
= BORDER_BOTTOM
;
117 case NS_ooxml::LN_CT_PageBorders_right
:
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
);
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: */