From 60d09ae471ba117e2eb773398a883df1d023daa4 Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Wed, 6 Oct 2010 23:54:04 +0200 Subject: fate#307731, fate#307730: Adds dotted and dashed border lines --- xmloff/source/style/PageMasterExportPropMapper.cxx | 11 +++-- xmloff/source/style/PageMasterImportPropMapper.cxx | 14 +++--- xmloff/source/style/bordrhdl.cxx | 54 ++++++++++++++++++---- xmloff/source/text/txtexppr.cxx | 16 +++++-- xmloff/source/text/txtimppr.cxx | 10 ++-- 5 files changed, 75 insertions(+), 30 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/style/PageMasterExportPropMapper.cxx b/xmloff/source/style/PageMasterExportPropMapper.cxx index c73d697854..32973e2250 100644 --- a/xmloff/source/style/PageMasterExportPropMapper.cxx +++ b/xmloff/source/style/PageMasterExportPropMapper.cxx @@ -30,7 +30,7 @@ #include "PageMasterExportPropMapper.hxx" #include #include -#include +#include #include #include #include @@ -52,10 +52,11 @@ inline sal_Bool lcl_HasSameLineWidth( const table::BorderLine& rLine1, const tab (rLine1.LineDistance == rLine2.LineDistance); } -inline sal_Bool operator==( const table::BorderLine& rLine1, const table::BorderLine& rLine2 ) +inline sal_Bool operator==( const table::BorderLine2& rLine1, const table::BorderLine2& rLine2 ) { return (rLine1.Color == rLine2.Color) && - lcl_HasSameLineWidth( rLine1, rLine2 ); + lcl_HasSameLineWidth( rLine1, rLine2 ) && + ( rLine1.LineStyle == rLine2.LineStyle ); } inline void lcl_RemoveState( XMLPropertyState* pState ) @@ -131,7 +132,7 @@ void XMLPropertyStateBuffer::ContextFilter( ::std::vector< XMLPropertyState >& ) { if( pPMBorderTop && pPMBorderBottom && pPMBorderLeft && pPMBorderRight ) { - table::BorderLine aLineTop, aLineBottom, aLineLeft, aLineRight; + table::BorderLine2 aLineTop, aLineBottom, aLineLeft, aLineRight; pPMBorderTop->maValue >>= aLineTop; pPMBorderBottom->maValue >>= aLineBottom; @@ -156,7 +157,7 @@ void XMLPropertyStateBuffer::ContextFilter( ::std::vector< XMLPropertyState >& ) { if( pPMBorderWidthTop && pPMBorderWidthBottom && pPMBorderWidthLeft && pPMBorderWidthRight ) { - table::BorderLine aLineTop, aLineBottom, aLineLeft, aLineRight; + table::BorderLine2 aLineTop, aLineBottom, aLineLeft, aLineRight; pPMBorderWidthTop->maValue >>= aLineTop; pPMBorderWidthBottom->maValue >>= aLineBottom; diff --git a/xmloff/source/style/PageMasterImportPropMapper.cxx b/xmloff/source/style/PageMasterImportPropMapper.cxx index 48c65632b2..7b67bedd81 100644 --- a/xmloff/source/style/PageMasterImportPropMapper.cxx +++ b/xmloff/source/style/PageMasterImportPropMapper.cxx @@ -33,7 +33,7 @@ #include "PageMasterPropMapper.hxx" #include #include -#include +#include #include #include @@ -204,11 +204,11 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >& pBorderWidths[i]->mnIndex = -1; if( pBorders[i] ) { - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; pBorders[i]->maValue >>= aBorderLine; if( pBorderWidths[i] ) { - table::BorderLine aBorderLineWidth; + table::BorderLine2 aBorderLineWidth; pBorderWidths[i]->maValue >>= aBorderLineWidth; aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; @@ -226,11 +226,11 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >& pHeaderBorderWidths[i]->mnIndex = -1; if( pHeaderBorders[i] ) { - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; pHeaderBorders[i]->maValue >>= aBorderLine; if( pHeaderBorderWidths[i] ) { - table::BorderLine aBorderLineWidth; + table::BorderLine2 aBorderLineWidth; pHeaderBorderWidths[i]->maValue >>= aBorderLineWidth; aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; @@ -248,11 +248,11 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >& pFooterBorderWidths[i]->mnIndex = -1; if( pFooterBorders[i] ) { - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; pFooterBorders[i]->maValue >>= aBorderLine; if( pFooterBorderWidths[i] ) { - table::BorderLine aBorderLineWidth; + table::BorderLine2 aBorderLineWidth; pFooterBorderWidths[i]->maValue >>= aBorderLineWidth; aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; diff --git a/xmloff/source/style/bordrhdl.cxx b/xmloff/source/style/bordrhdl.cxx index df58f82b79..decb4502af 100644 --- a/xmloff/source/style/bordrhdl.cxx +++ b/xmloff/source/style/bordrhdl.cxx @@ -34,7 +34,7 @@ #include #include #include -#include +#include using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -42,6 +42,10 @@ using ::rtl::OUStringBuffer; using namespace ::com::sun::star; using namespace ::xmloff::token; +const sal_Int16 API_LINE_SOLID = 0; +const sal_Int16 API_LINE_DOTTED = 1; +const sal_Int16 API_LINE_DASHED = 2; + // copied from svx/boxitem.hxx #define DEF_LINE_WIDTH_0 1 #define DEF_LINE_WIDTH_1 35 @@ -101,6 +105,8 @@ using namespace ::xmloff::token; #define SVX_XML_BORDER_STYLE_NONE 0 #define SVX_XML_BORDER_STYLE_SOLID 1 #define SVX_XML_BORDER_STYLE_DOUBLE 2 +#define SVX_XML_BORDER_STYLE_DASHED 3 +#define SVX_XML_BORDER_STYLE_DOTTED 4 #define SVX_XML_BORDER_WIDTH_THIN 0 #define SVX_XML_BORDER_WIDTH_MIDDLE 1 @@ -112,8 +118,8 @@ SvXMLEnumMapEntry pXML_BorderStyles[] = { XML_HIDDEN, SVX_XML_BORDER_STYLE_NONE }, { XML_SOLID, SVX_XML_BORDER_STYLE_SOLID }, { XML_DOUBLE, SVX_XML_BORDER_STYLE_DOUBLE }, - { XML_DOTTED, SVX_XML_BORDER_STYLE_SOLID }, - { XML_DASHED, SVX_XML_BORDER_STYLE_SOLID }, + { XML_DOTTED, SVX_XML_BORDER_STYLE_DOTTED }, + { XML_DASHED, SVX_XML_BORDER_STYLE_DASHED }, { XML_GROOVE, SVX_XML_BORDER_STYLE_SOLID }, { XML_RIDGE, SVX_XML_BORDER_STYLE_SOLID }, { XML_INSET, SVX_XML_BORDER_STYLE_SOLID }, @@ -171,6 +177,23 @@ static sal_uInt16 __READONLY_DATA aDBorderWidths[] = DBORDER_ENTRY( 5 ) }; +void lcl_frmitems_setXMLBorderStyle( table::BorderLine2 & rBorderLine, sal_uInt16 nStyle ) +{ + sal_Int16 eStyle = API_LINE_SOLID; + switch ( nStyle ) + { + case SVX_XML_BORDER_STYLE_DOTTED: + eStyle = API_LINE_DOTTED; + break; + case SVX_XML_BORDER_STYLE_DASHED: + eStyle = API_LINE_DASHED; + break; + default: + break; + } + rBorderLine.LineStyle = eStyle; +} + void lcl_frmitems_setXMLBorderWidth( table::BorderLine &rBorderLine, sal_uInt16 nWidth, sal_Bool bDouble ) { @@ -273,7 +296,7 @@ sal_Bool XMLBorderWidthHdl::importXML( const OUString& rStrImpValue, uno::Any& r sal_uInt16 nWidth = i < nSize ? 0 : nOutWidth + nInWidth + nDistance; #endif - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; if(!(rValue >>= aBorderLine)) aBorderLine.Color = 0; @@ -289,7 +312,7 @@ sal_Bool XMLBorderWidthHdl::exportXML( OUString& rStrExpValue, const uno::Any& r { OUStringBuffer aOut; - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; if(!(rValue >>= aBorderLine)) return sal_False; @@ -368,7 +391,7 @@ sal_Bool XMLBorderHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue if( !bHasStyle || (SVX_XML_BORDER_STYLE_NONE != nStyle && !bHasWidth) ) return sal_False; - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; if(!(rValue >>= aBorderLine)) { aBorderLine.Color = 0; @@ -400,11 +423,13 @@ sal_Bool XMLBorderHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue else { lcl_frmitems_setXMLBorderWidth( aBorderLine, nWidth, bDouble ); + lcl_frmitems_setXMLBorderStyle( aBorderLine, nStyle ); } } else { lcl_frmitems_setXMLBorderWidth( aBorderLine, 0, bDouble ); + lcl_frmitems_setXMLBorderStyle( aBorderLine, nStyle ); } // set color @@ -419,7 +444,7 @@ sal_Bool XMLBorderHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue { OUStringBuffer aOut; - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; if(!(rValue >>= aBorderLine)) return sal_False; @@ -441,7 +466,20 @@ sal_Bool XMLBorderHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue aOut.append( sal_Unicode( ' ' ) ); - aOut.append( GetXMLToken((0 == nDistance) ? XML_SOLID : XML_DOUBLE) ); + XMLTokenEnum eStyleToken = XML_SOLID; + switch ( aBorderLine.LineStyle ) + { + case API_LINE_DASHED: + eStyleToken = XML_DASHED; + break; + case API_LINE_DOTTED: + eStyleToken = XML_DOTTED; + break; + case API_LINE_SOLID: + default: + eStyleToken = XML_SOLID; + } + aOut.append( GetXMLToken((0 == nDistance) ? eStyleToken : XML_DOUBLE) ); aOut.append( sal_Unicode( ' ' ) ); diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx index d148d78b0a..7555ca13f6 100644 --- a/xmloff/source/text/txtexppr.cxx +++ b/xmloff/source/text/txtexppr.cxx @@ -29,7 +29,7 @@ #include "precompiled_xmloff.hxx" #include #include -#include +#include #include #include #include @@ -692,7 +692,7 @@ void XMLTextExportPropertySetMapper::ContextFilter( { if( pLeftBorderWidthState && pRightBorderWidthState && pTopBorderWidthState && pBottomBorderWidthState ) { - table::BorderLine aLeft, aRight, aTop, aBottom; + table::BorderLine2 aLeft, aRight, aTop, aBottom; pLeftBorderWidthState->maValue >>= aLeft; pRightBorderWidthState->maValue >>= aRight; @@ -700,10 +700,13 @@ void XMLTextExportPropertySetMapper::ContextFilter( pBottomBorderWidthState->maValue >>= aBottom; if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth && aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance && + aLeft.LineStyle == aRight.LineStyle && aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth && aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance && + aLeft.LineStyle == aTop.LineStyle && aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth && - aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance ) + aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance && + aLeft.LineStyle == aBottom.LineStyle ) { pLeftBorderWidthState->mnIndex = -1; pLeftBorderWidthState->maValue.clear(); @@ -765,7 +768,7 @@ void XMLTextExportPropertySetMapper::ContextFilter( { if( pLeftBorderState && pRightBorderState && pTopBorderState && pBottomBorderState ) { - table::BorderLine aLeft, aRight, aTop, aBottom; + table::BorderLine2 aLeft, aRight, aTop, aBottom; pLeftBorderState->maValue >>= aLeft; pRightBorderState->maValue >>= aRight; @@ -773,10 +776,13 @@ void XMLTextExportPropertySetMapper::ContextFilter( pBottomBorderState->maValue >>= aBottom; if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth && aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance && + aLeft.LineStyle == aRight.LineStyle && aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth && aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance && + aLeft.LineStyle == aTop.LineStyle && aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth && - aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance ) + aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance && + aLeft.LineStyle == aBottom.LineStyle ) { pLeftBorderState->mnIndex = -1; pLeftBorderState->maValue.clear(); diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx index 1b8f10cdc8..5c82a848c9 100644 --- a/xmloff/source/text/txtimppr.cxx +++ b/xmloff/source/text/txtimppr.cxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -438,12 +438,12 @@ void XMLTextImportPropertyMapper::finished( sal_Bool bHasBorder = sal_False; if( pBorders[i] ) { - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; pBorders[i]->maValue >>= aBorderLine; if( pBorderWidths[i] ) { - table::BorderLine aBorderLineWidth; + table::BorderLine2 aBorderLineWidth; pBorderWidths[i]->maValue >>= aBorderLineWidth; aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; @@ -492,10 +492,10 @@ void XMLTextImportPropertyMapper::finished( #else if( pBorders[i] && pBorderWidths[i] ) { - table::BorderLine aBorderLine; + table::BorderLine2 aBorderLine; pBorders[i]->maValue >>= aBorderLine; - table::BorderLine aBorderLineWidth; + table::BorderLine2 aBorderLineWidth; pBorderWidths[i]->maValue >>= aBorderLineWidth; aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; -- cgit v1.2.3