android: Update app-specific/MIME type icons
[LibreOffice.git] / writerfilter / source / dmapper / PageBordersHandler.cxx
blob89548eb351ee5e8c26692aef9acda22d40825c17
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 "BorderHandler.hxx"
21 #include "PageBordersHandler.hxx"
23 #include <ooxml/resourceids.hxx>
25 namespace writerfilter::dmapper {
27 PgBorder::PgBorder( ) :
28 m_nDistance( 0 ),
29 m_ePos( BORDER_RIGHT ),
30 m_bShadow(false)
34 PageBordersHandler::PageBordersHandler( ) :
35 LoggedProperties("PageBordersHandler"),
36 m_eBorderApply(SectionPropertyMap::BorderApply::ToAllInSection),
37 m_eOffsetFrom(SectionPropertyMap::BorderOffsetFrom::Text)
41 PageBordersHandler::~PageBordersHandler( )
45 void PageBordersHandler::lcl_attribute( Id eName, Value& rVal )
47 int nIntValue = rVal.getInt( );
48 switch ( eName )
50 case NS_ooxml::LN_CT_PageBorders_display:
52 switch ( nIntValue )
54 default:
55 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_allPages:
56 m_eBorderApply = SectionPropertyMap::BorderApply::ToAllInSection;
57 break;
58 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_firstPage:
59 m_eBorderApply = SectionPropertyMap::BorderApply::ToFirstPageInSection;
60 break;
61 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_notFirstPage:
62 m_eBorderApply = SectionPropertyMap::BorderApply::ToAllButFirstInSection;
63 break;
66 break;
67 case NS_ooxml::LN_CT_PageBorders_offsetFrom:
69 switch ( nIntValue )
71 default:
72 case NS_ooxml::LN_Value_doc_ST_PageBorderOffset_page:
73 m_eOffsetFrom = SectionPropertyMap::BorderOffsetFrom::Edge;
74 break;
75 case NS_ooxml::LN_Value_doc_ST_PageBorderOffset_text:
76 m_eOffsetFrom = SectionPropertyMap::BorderOffsetFrom::Text;
77 break;
80 break;
81 default:;
85 void PageBordersHandler::lcl_sprm( Sprm& rSprm )
87 switch ( rSprm.getId( ) )
89 case NS_ooxml::LN_CT_PageBorders_top:
90 case NS_ooxml::LN_CT_PageBorders_left:
91 case NS_ooxml::LN_CT_PageBorders_bottom:
92 case NS_ooxml::LN_CT_PageBorders_right:
94 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
95 if( pProperties )
97 auto pBorderHandler = std::make_shared<BorderHandler>( true );
98 pProperties->resolve(*pBorderHandler);
99 BorderPosition ePos = BorderPosition( 0 );
100 switch( rSprm.getId( ) )
102 case NS_ooxml::LN_CT_PageBorders_top:
103 ePos = BORDER_TOP;
104 break;
105 case NS_ooxml::LN_CT_PageBorders_left:
106 ePos = BORDER_LEFT;
107 break;
108 case NS_ooxml::LN_CT_PageBorders_bottom:
109 ePos = BORDER_BOTTOM;
110 break;
111 case NS_ooxml::LN_CT_PageBorders_right:
112 ePos = BORDER_RIGHT;
113 break;
114 default:;
117 PgBorder aPgBorder;
118 aPgBorder.m_rLine = pBorderHandler->getBorderLine( );
119 aPgBorder.m_nDistance = pBorderHandler->getLineDistance( );
120 aPgBorder.m_ePos = ePos;
121 aPgBorder.m_bShadow = pBorderHandler->getShadow();
122 if (pBorderHandler->getLineType() != NS_ooxml::LN_Value_ST_Border_none)
124 m_aBorders.push_back( aPgBorder );
128 break;
129 default:;
133 void PageBordersHandler::SetBorders( SectionPropertyMap* pSectContext )
135 for (const PgBorder& rBorder : m_aBorders)
137 pSectContext->SetBorder( rBorder.m_ePos, rBorder.m_nDistance, rBorder.m_rLine, rBorder.m_bShadow );
139 pSectContext->SetBorderApply(m_eBorderApply);
140 pSectContext->SetBorderOffsetFrom(m_eOffsetFrom);
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */