LibreOffice Module writerfilter (master) 1
PageBordersHandler.cxx
Go to the documentation of this file.
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 "BorderHandler.hxx"
22
23#include <ooxml/resourceids.hxx>
24
25namespace writerfilter::dmapper {
26
28 m_nDistance( 0 ),
29 m_ePos( BORDER_RIGHT ),
30 m_bShadow(false)
31{
32}
33
35LoggedProperties("PageBordersHandler"),
36m_eBorderApply(SectionPropertyMap::BorderApply::ToAllInSection),
37m_eOffsetFrom(SectionPropertyMap::BorderOffsetFrom::Text)
38{
39}
40
42{
43}
44
46{
47 int nIntValue = rVal.getInt( );
48 switch ( eName )
49 {
50 case NS_ooxml::LN_CT_PageBorders_display:
51 {
52 switch ( nIntValue )
53 {
54 default:
55 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_allPages:
57 break;
58 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_firstPage:
60 break;
61 case NS_ooxml::LN_Value_doc_ST_PageBorderDisplay_notFirstPage:
63 break;
64 }
65 }
66 break;
67 case NS_ooxml::LN_CT_PageBorders_offsetFrom:
68 {
69 switch ( nIntValue )
70 {
71 default:
72 case NS_ooxml::LN_Value_doc_ST_PageBorderOffset_page:
74 break;
75 case NS_ooxml::LN_Value_doc_ST_PageBorderOffset_text:
77 break;
78 }
79 }
80 break;
81 default:;
82 }
83}
84
86{
87 switch ( rSprm.getId( ) )
88 {
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:
93 {
95 if( pProperties )
96 {
97 auto pBorderHandler = std::make_shared<BorderHandler>( true );
98 pProperties->resolve(*pBorderHandler);
100 switch( rSprm.getId( ) )
101 {
102 case NS_ooxml::LN_CT_PageBorders_top:
104 break;
105 case NS_ooxml::LN_CT_PageBorders_left:
107 break;
108 case NS_ooxml::LN_CT_PageBorders_bottom:
110 break;
111 case NS_ooxml::LN_CT_PageBorders_right:
113 break;
114 default:;
115 }
116
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)
123 {
124 m_aBorders.push_back( aPgBorder );
125 }
126 }
127 }
128 break;
129 default:;
130 }
131}
132
134{
135 for (const PgBorder& rBorder : m_aBorders)
136 {
137 pSectContext->SetBorder( rBorder.m_ePos, rBorder.m_nDistance, rBorder.m_rLine, rBorder.m_bShadow );
138 }
139 pSectContext->SetBorderApply(m_eBorderApply);
140 pSectContext->SetBorderOffsetFrom(m_eOffsetFrom);
141}
142
143}
144
145/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::chart::ChartAxisLabelPosition ePos
An SPRM: Section, Paragraph and Run Modifier.
virtual sal_uInt32 getId() const =0
Returns id of the SPRM.
virtual writerfilter::Reference< Properties >::Pointer_t getProps()=0
Returns reference to properties contained in the SPRM.
virtual int getInt() const =0
Returns integer representation of the value.
void SetBorders(SectionPropertyMap *pSectContext)
SectionPropertyMap::BorderOffsetFrom m_eOffsetFrom
virtual void lcl_attribute(Id eName, Value &rVal) override
SectionPropertyMap::BorderApply m_eBorderApply
virtual void lcl_sprm(Sprm &rSprm) override
void SetBorder(BorderPosition ePos, sal_Int32 nLineDistance, const css::table::BorderLine2 &rBorderLine, bool bShadow)
void SetBorderOffsetFrom(BorderOffsetFrom nSet)
sal_uInt32 Id