Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include "PageBordersHandler.hxx"
21 : :
22 : : #include <ooxml/resourceids.hxx>
23 : :
24 : : #include "dmapperLoggers.hxx"
25 : :
26 : : namespace writerfilter {
27 : : namespace dmapper {
28 : :
29 : 24 : _PgBorder::_PgBorder( ) :
30 : : m_nDistance( 0 ),
31 : 24 : m_ePos( BORDER_RIGHT )
32 : : {
33 : 24 : }
34 : :
35 : 90 : _PgBorder::~_PgBorder( )
36 : : {
37 : 90 : }
38 : :
39 : 6 : PageBordersHandler::PageBordersHandler( ) :
40 : : LoggedProperties(dmapper_logger, "PageBordersHandler"),
41 : : m_nDisplay( 0 ),
42 [ + - ][ + - ]: 6 : m_nOffset( 0 )
[ + - ][ + - ]
[ + - ]
43 : : {
44 : 6 : }
45 : :
46 : 6 : PageBordersHandler::~PageBordersHandler( )
47 : : {
48 [ - + ]: 12 : }
49 : :
50 : 6 : void PageBordersHandler::lcl_attribute( Id eName, Value& rVal )
51 : : {
52 : 6 : int nIntValue = rVal.getInt( );
53 [ - + - ]: 6 : switch ( eName )
54 : : {
55 : : case NS_ooxml::LN_CT_PageBorders_display:
56 : : {
57 [ # # # ]: 0 : switch ( nIntValue )
58 : : {
59 : : default:
60 : : case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_allPages:
61 : 0 : m_nDisplay = 0;
62 : 0 : break;
63 : : case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_firstPage:
64 : 0 : m_nDisplay = 1;
65 : 0 : break;
66 : : case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_notFirstPage:
67 : 0 : m_nDisplay = 2;
68 : 0 : break;
69 : : }
70 : : }
71 : 0 : break;
72 : : case NS_ooxml::LN_CT_PageBorders_offsetFrom:
73 : : {
74 [ + - ]: 6 : switch ( nIntValue )
75 : : {
76 : : default:
77 : : case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_page:
78 : 6 : m_nOffset = 1;
79 : 6 : break;
80 : : case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_text:
81 : 0 : m_nOffset = 0;
82 : 0 : break;
83 : : }
84 : : }
85 : 6 : break;
86 : : default:;
87 : : }
88 : 6 : }
89 : :
90 : 24 : void PageBordersHandler::lcl_sprm( Sprm& rSprm )
91 : : {
92 [ + - ]: 24 : switch ( rSprm.getId( ) )
93 : : {
94 : : case NS_ooxml::LN_CT_PageBorders_top:
95 : : case NS_ooxml::LN_CT_PageBorders_left:
96 : : case NS_ooxml::LN_CT_PageBorders_bottom:
97 : : case NS_ooxml::LN_CT_PageBorders_right:
98 : : {
99 [ + - ]: 24 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
100 [ + - ]: 24 : if( pProperties.get())
101 : : {
102 [ + - ][ + - ]: 24 : BorderHandlerPtr pBorderHandler( new BorderHandler( true ) );
[ + - ]
103 [ + - ]: 24 : pProperties->resolve(*pBorderHandler);
104 : 24 : BorderPosition ePos = BorderPosition( 0 );
105 [ + - ][ + + : 24 : switch( rSprm.getId( ) )
+ + - ]
106 : : {
107 : : case NS_ooxml::LN_CT_PageBorders_top:
108 : 6 : ePos = BORDER_TOP;
109 : 6 : break;
110 : : case NS_ooxml::LN_CT_PageBorders_left:
111 : 6 : ePos = BORDER_LEFT;
112 : 6 : break;
113 : : case NS_ooxml::LN_CT_PageBorders_bottom:
114 : 6 : ePos = BORDER_BOTTOM;
115 : 6 : break;
116 : : case NS_ooxml::LN_CT_PageBorders_right:
117 : 6 : ePos = BORDER_RIGHT;
118 : 6 : break;
119 : : default:;
120 : : }
121 : :
122 : 24 : _PgBorder aPgBorder;
123 [ + - ]: 24 : aPgBorder.m_rLine = pBorderHandler->getBorderLine( );
124 : 24 : aPgBorder.m_nDistance = pBorderHandler->getLineDistance( );
125 : 24 : aPgBorder.m_ePos = ePos;
126 [ + - ][ + - ]: 24 : m_aBorders.push_back( aPgBorder );
127 [ + - ]: 24 : }
128 : : }
129 : 24 : break;
130 : : default:;
131 : : }
132 : 24 : }
133 : :
134 : 6 : void PageBordersHandler::SetBorders( SectionPropertyMap* pSectContext )
135 : : {
136 [ + + ]: 30 : for ( int i = 0, length = m_aBorders.size( ); i < length; i++ )
137 : : {
138 : 24 : _PgBorder aBorder = m_aBorders[i];
139 [ + - ]: 24 : pSectContext->SetBorder( aBorder.m_ePos, aBorder.m_nDistance, aBorder.m_rLine );
140 : 24 : }
141 : 6 : }
142 : :
143 [ + - ][ + - ]: 60 : } }
144 : :
145 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|