/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ #include"vbaborders.hxx" #include <ooo/vba/word/XBorder.hpp> #include <ooo/vba/word/WdBorderType.hpp> #include <ooo/vba/word/WdLineStyle.hpp> #include <sal/macros.h> #include <cppuhelper/implbase.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/table/TableBorder.hpp> #include <utility> #include"vbapalette.hxx"
// #TODO sort these indexes to match the order in which Word iterates over the // borders, the enumeration will match the order in this list const sal_Int16 supportedIndexTable[] = { word::WdBorderType::wdBorderBottom, word::WdBorderType::wdBorderDiagonalDown, word::WdBorderType::wdBorderDiagonalUp, word::WdBorderType::wdBorderHorizontal, word::WdBorderType::wdBorderLeft, word::WdBorderType::wdBorderRight, word::WdBorderType::wdBorderTop, word::WdBorderType::wdBorderVertical };
// Equiv widths in 1/100 mm const sal_Int32 OOLineHairline = 2;
case word::WdBorderType::wdBorderBottom:
aTableBorder.IsBottomLineValid = true;
aTableBorder.BottomLine = rBorderLine; break; case word::WdBorderType::wdBorderRight:
aTableBorder.IsRightLineValid = true;
aTableBorder.RightLine = rBorderLine; break; case word::WdBorderType::wdBorderVertical:
aTableBorder.IsVerticalLineValid = true;
aTableBorder.VerticalLine = rBorderLine; break; case word::WdBorderType::wdBorderHorizontal:
aTableBorder.IsHorizontalLineValid = true;
aTableBorder.HorizontalLine = rBorderLine; break; case word::WdBorderType::wdBorderDiagonalDown: case word::WdBorderType::wdBorderDiagonalUp: // #TODO have to ignore at the moment, would be // nice to investigate what we can do here break; default: return;
}
m_xProps->setPropertyValue( u"TableBorder"_ustr, uno::Any(aTableBorder) );
}
bool getBorderLine( table::BorderLine& rBorderLine )
{
table::TableBorder aTableBorder;
m_xProps->getPropertyValue( u"TableBorder"_ustr ) >>= aTableBorder; switch ( m_LineType )
{ case word::WdBorderType::wdBorderLeft: if ( aTableBorder.IsLeftLineValid )
rBorderLine = aTableBorder.LeftLine; break; case word::WdBorderType::wdBorderTop: if ( aTableBorder.IsTopLineValid )
rBorderLine = aTableBorder.TopLine; break; case word::WdBorderType::wdBorderBottom: if ( aTableBorder.IsBottomLineValid )
rBorderLine = aTableBorder.BottomLine; break; case word::WdBorderType::wdBorderRight: if ( aTableBorder.IsRightLineValid )
rBorderLine = aTableBorder.RightLine; break; case word::WdBorderType::wdBorderVertical: if ( aTableBorder.IsVerticalLineValid )
rBorderLine = aTableBorder.VerticalLine; break; case word::WdBorderType::wdBorderHorizontal: if ( aTableBorder.IsHorizontalLineValid )
rBorderLine = aTableBorder.HorizontalLine; break;
case word::WdBorderType::wdBorderDiagonalDown: case word::WdBorderType::wdBorderDiagonalUp: // #TODO have to ignore at the moment, would be // nice to investigate what we can do here break; default: returnfalse;
} returntrue;
}
uno::Any SAL_CALL getLineStyle() override
{
sal_Int32 nLineStyle = word::WdLineStyle::wdLineStyleNone;
table::BorderLine aBorderLine; if ( getBorderLine( aBorderLine ) )
{ if( aBorderLine.InnerLineWidth !=0 && aBorderLine.OuterLineWidth !=0 )
{
nLineStyle = word::WdLineStyle::wdLineStyleDouble;
} elseif( aBorderLine.InnerLineWidth !=0 || aBorderLine.OuterLineWidth !=0 )
{
nLineStyle = word::WdLineStyle::wdLineStyleSingle;
} else
{
nLineStyle = word::WdLineStyle::wdLineStyleNone;
}
} return uno::Any( nLineStyle );
} void SAL_CALL setLineStyle( const uno::Any& _linestyle ) override
{ // Urk no choice but to silently ignore we don't support this attribute // #TODO would be nice to support the word line styles
sal_Int32 nLineStyle = 0;
_linestyle >>= nLineStyle;
table::BorderLine aBorderLine; if ( !getBorderLine( aBorderLine ) ) throw uno::RuntimeException(u"Method failed"_ustr );
switch ( nLineStyle )
{ case word::WdLineStyle::wdLineStyleNone:
{
aBorderLine.InnerLineWidth = 0;
aBorderLine.OuterLineWidth = 0; break;
} case word::WdLineStyle::wdLineStyleDashDot: case word::WdLineStyle::wdLineStyleDashDotDot: case word::WdLineStyle::wdLineStyleDashDotStroked: case word::WdLineStyle::wdLineStyleDashLargeGap: case word::WdLineStyle::wdLineStyleDashSmallGap: case word::WdLineStyle::wdLineStyleDot: case word::WdLineStyle::wdLineStyleDouble: case word::WdLineStyle::wdLineStyleDoubleWavy: case word::WdLineStyle::wdLineStyleEmboss3D: case word::WdLineStyle::wdLineStyleEngrave3D: case word::WdLineStyle::wdLineStyleInset: case word::WdLineStyle::wdLineStyleOutset: case word::WdLineStyle::wdLineStyleSingle: case word::WdLineStyle::wdLineStyleSingleWavy: case word::WdLineStyle::wdLineStyleThickThinLargeGap: case word::WdLineStyle::wdLineStyleThickThinMedGap: case word::WdLineStyle::wdLineStyleThickThinSmallGap: case word::WdLineStyle::wdLineStyleThinThickLargeGap: case word::WdLineStyle::wdLineStyleThinThickMedGap: case word::WdLineStyle::wdLineStyleThinThickSmallGap: case word::WdLineStyle::wdLineStyleThinThickThinLargeGap: case word::WdLineStyle::wdLineStyleThinThickThinMedGap: case word::WdLineStyle::wdLineStyleThinThickThinSmallGap: case word::WdLineStyle::wdLineStyleTriple:
{
aBorderLine.InnerLineWidth = 0;
aBorderLine.OuterLineWidth = OOLineHairline; break;
} default: throw uno::RuntimeException(u"Bad param"_ustr );
}
setBorderLine( aBorderLine );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.