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 namespace writerfilter
{
27 _PgBorder::_PgBorder( ) :
29 m_ePos( BORDER_RIGHT
),
34 _PgBorder::~_PgBorder( )
38 PageBordersHandler::PageBordersHandler( ) :
39 LoggedProperties("PageBordersHandler"),
45 PageBordersHandler::~PageBordersHandler( )
49 void PageBordersHandler::lcl_attribute( Id eName
, Value
& rVal
)
51 int nIntValue
= rVal
.getInt( );
54 case NS_ooxml::LN_CT_PageBorders_display
:
59 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_allPages
:
62 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_firstPage
:
65 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_notFirstPage
:
71 case NS_ooxml::LN_CT_PageBorders_offsetFrom
:
76 case NS_ooxml::LN_Value_doc_ST_PageBorderOffset_page
:
79 case NS_ooxml::LN_Value_doc_ST_PageBorderOffset_text
:
89 void PageBordersHandler::lcl_sprm( Sprm
& rSprm
)
91 switch ( rSprm
.getId( ) )
93 case NS_ooxml::LN_CT_PageBorders_top
:
94 case NS_ooxml::LN_CT_PageBorders_left
:
95 case NS_ooxml::LN_CT_PageBorders_bottom
:
96 case NS_ooxml::LN_CT_PageBorders_right
:
98 writerfilter::Reference
<Properties
>::Pointer_t pProperties
= rSprm
.getProps();
99 if( pProperties
.get())
101 BorderHandlerPtr
pBorderHandler( new BorderHandler( true ) );
102 pProperties
->resolve(*pBorderHandler
);
103 BorderPosition ePos
= BorderPosition( 0 );
104 switch( rSprm
.getId( ) )
106 case NS_ooxml::LN_CT_PageBorders_top
:
109 case NS_ooxml::LN_CT_PageBorders_left
:
112 case NS_ooxml::LN_CT_PageBorders_bottom
:
113 ePos
= BORDER_BOTTOM
;
115 case NS_ooxml::LN_CT_PageBorders_right
:
122 aPgBorder
.m_rLine
= pBorderHandler
->getBorderLine( );
123 aPgBorder
.m_nDistance
= pBorderHandler
->getLineDistance( );
124 aPgBorder
.m_ePos
= ePos
;
125 aPgBorder
.m_bShadow
= pBorderHandler
->getShadow();
126 m_aBorders
.push_back( aPgBorder
);
134 void PageBordersHandler::SetBorders( SectionPropertyMap
* pSectContext
)
136 for ( int i
= 0, length
= m_aBorders
.size( ); i
< length
; i
++ )
138 _PgBorder aBorder
= m_aBorders
[i
];
139 pSectContext
->SetBorder( aBorder
.m_ePos
, aBorder
.m_nDistance
, aBorder
.m_rLine
, aBorder
.m_bShadow
);
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */