sw/source/filter/ww8/docxattributeoutput.cxx | 262 +++++++++++++++------------ sw/source/filter/ww8/docxattributeoutput.hxx | 3 2 files changed, 149 insertions(+), 116 deletions(-)
New commits: commit 1c1980728e6eb0ec65745b824db4f20502b5e9ae Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Fri Dec 20 19:44:41 2013 +0100 Revert "sw: small code refactor" This reverts commit 7b073527da7dce314e14dba7b34245db3f0b5ae1. It seems to require additional testing in Windows so I'm taking it back at the moment. diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 130e0cc..7daf788 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4308,7 +4308,10 @@ void DocxAttributeOutput::CharColor( const SvxColorItem& rColor ) aColorString = msfilter::util::ConvertColor( aColor ); - pushToAttrList( &m_pColorAttrList, FSNS( XML_w, XML_val ), aColorString.getStr() ); + if( !m_pColorAttrList ) + m_pColorAttrList = m_pSerializer->createAttrList(); + + m_pColorAttrList->add( FSNS( XML_w, XML_val ), aColorString.getStr() ); } void DocxAttributeOutput::CharContour( const SvxContourItem& rContour ) @@ -4377,12 +4380,13 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement ) void DocxAttributeOutput::CharFont( const SvxFontItem& rFont) { + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); GetExport().GetId( rFont ); // ensure font info is written to fontTable.xml OUString sFontName(rFont.GetFamilyName()); OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8); - pushToAttrList(&m_pFontsAttrList, 2, - FSNS(XML_w, XML_ascii), sFontNameUtf8.getStr(), - FSNS(XML_w, XML_hAnsi), sFontNameUtf8.getStr() ); + m_pFontsAttrList->add(FSNS(XML_w, XML_ascii), sFontNameUtf8); + m_pFontsAttrList->add(FSNS(XML_w, XML_hAnsi), sFontNameUtf8); } void DocxAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize) @@ -4409,6 +4413,9 @@ void DocxAttributeOutput::CharKerning( const SvxKerningItem& rKerning ) void DocxAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage ) { + if (!m_pCharLangAttrList) + m_pCharLangAttrList = m_pSerializer->createAttrList(); + OString aLanguageCode( OUStringToOString( LanguageTag( rLanguage.GetLanguage()).getBcp47(), RTL_TEXTENCODING_UTF8)); @@ -4416,13 +4423,13 @@ void DocxAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage ) switch ( rLanguage.Which() ) { case RES_CHRATR_LANGUAGE: - pushToAttrList(&m_pCharLangAttrList, FSNS(XML_w, XML_val), aLanguageCode.getStr()); + m_pCharLangAttrList->add(FSNS(XML_w, XML_val), aLanguageCode); break; case RES_CHRATR_CJK_LANGUAGE: - pushToAttrList(&m_pCharLangAttrList, FSNS(XML_w, XML_eastAsia), aLanguageCode.getStr()); + m_pCharLangAttrList->add(FSNS(XML_w, XML_eastAsia), aLanguageCode); break; case RES_CHRATR_CTL_LANGUAGE: - pushToAttrList(&m_pCharLangAttrList, FSNS(XML_w, XML_bidi), aLanguageCode.getStr()); + m_pCharLangAttrList->add(FSNS(XML_w, XML_bidi), aLanguageCode); break; } } @@ -4533,9 +4540,11 @@ void DocxAttributeOutput::CharBackground( const SvxBrushItem& rBrush ) void DocxAttributeOutput::CharFontCJK( const SvxFontItem& rFont ) { + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); OUString sFontName(rFont.GetFamilyName()); OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8); - pushToAttrList(&m_pFontsAttrList, FSNS(XML_w, XML_eastAsia), sFontNameUtf8.getStr()); + m_pFontsAttrList->add(FSNS(XML_w, XML_eastAsia), sFontNameUtf8); } void DocxAttributeOutput::CharPostureCJK( const SvxPostureItem& rPosture ) @@ -4556,9 +4565,11 @@ void DocxAttributeOutput::CharWeightCJK( const SvxWeightItem& rWeight ) void DocxAttributeOutput::CharFontCTL( const SvxFontItem& rFont ) { + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); OUString sFontName(rFont.GetFamilyName()); OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8); - pushToAttrList(&m_pFontsAttrList, FSNS(XML_w, XML_cs), sFontNameUtf8.getStr()); + m_pFontsAttrList->add(FSNS(XML_w, XML_cs), sFontNameUtf8); } @@ -4584,10 +4595,13 @@ void DocxAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate) if ( !rRotate.GetValue() || m_bBtLr || m_bFrameBtLr) return; - pushToAttrList(&m_pEastAsianLayoutAttrList, FSNS(XML_w, XML_vert), "true"); + if (!m_pEastAsianLayoutAttrList) + m_pEastAsianLayoutAttrList = m_pSerializer->createAttrList(); + OString sTrue((sal_Char *)"true"); + m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_vert), sTrue); if (rRotate.IsFitToLine()) - pushToAttrList(&m_pEastAsianLayoutAttrList, FSNS(XML_w, XML_vertCompress), "true"); + m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_vertCompress), sTrue); } void DocxAttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark ) @@ -4611,7 +4625,10 @@ void DocxAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines ) if ( !rTwoLines.GetValue() ) return; - pushToAttrList(&m_pEastAsianLayoutAttrList, FSNS(XML_w, XML_combine), "true"); + if (!m_pEastAsianLayoutAttrList) + m_pEastAsianLayoutAttrList = m_pSerializer->createAttrList(); + OString sTrue((sal_Char *)"true"); + m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_combine), sTrue); sal_Unicode cStart = rTwoLines.GetStartBracket(); sal_Unicode cEnd = rTwoLines.GetEndBracket(); @@ -4628,7 +4645,7 @@ void DocxAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines ) sBracket = (sal_Char *)"square"; else sBracket = (sal_Char *)"round"; - pushToAttrList(&m_pEastAsianLayoutAttrList, FSNS(XML_w, XML_combineBrackets), sBracket.getStr()); + m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_combineBrackets), sBracket); } void DocxAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth ) @@ -5055,26 +5072,26 @@ void DocxAttributeOutput::SectFootnoteEndnotePr() void DocxAttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti ) { + if ( !m_pParagraphSpacingAttrList ) + m_pParagraphSpacingAttrList = m_pSerializer->createAttrList(); + if ( nSpace < 0 ) { - pushToAttrList( &m_pParagraphSpacingAttrList, 2, - FSNS( XML_w, XML_lineRule ), "exact", - FSNS( XML_w, XML_line ), OString::number( -nSpace ).getStr() ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "exact" ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_line ), OString::number( -nSpace ) ); } else if( nMulti ) { - pushToAttrList( &m_pParagraphSpacingAttrList, 2, - FSNS( XML_w, XML_lineRule ), "auto", - FSNS( XML_w, XML_line ), OString::number( nSpace ).getStr() ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "auto" ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_line ), OString::number( nSpace ) ); } else if ( nSpace > 0 ) { - pushToAttrList( &m_pParagraphSpacingAttrList, 2, - FSNS( XML_w, XML_lineRule ), "atLeast", - FSNS( XML_w, XML_line ), OString::number( nSpace ).getStr() ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "atLeast" ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_line ), OString::number( nSpace ) ); } else - pushToAttrList( &m_pParagraphSpacingAttrList, FSNS( XML_w, XML_lineRule ), "auto" ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "auto" ); } void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) @@ -5308,18 +5325,21 @@ void DocxAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize ) } else if ( m_rExport.bOutFlyFrmAttrs ) { + if ( !m_pFlyAttrList ) + m_pFlyAttrList = m_pSerializer->createAttrList( ); + if ( rSize.GetWidth() && rSize.GetWidthSizeType() == ATT_FIX_SIZE ) - pushToAttrList( &m_pFlyAttrList, - FSNS( XML_w, XML_w ), OString::number( rSize.GetWidth( ) ).getStr() ); + { + m_pFlyAttrList->add( FSNS( XML_w, XML_w ), OString::number( rSize.GetWidth( ) ) ); + } if ( rSize.GetHeight() ) { OString sRule( "exact" ); if ( rSize.GetHeightSizeType() == ATT_MIN_SIZE ) sRule = OString( "atLeast" ); - pushToAttrList( &m_pFlyAttrList, 2, - FSNS( XML_w, XML_hRule ), sRule.getStr(), - FSNS( XML_w, XML_h ), OString::number( rSize.GetHeight( ) ).getStr() ); + m_pFlyAttrList->add( FSNS( XML_w, XML_hRule ), sRule ); + m_pFlyAttrList->add( FSNS( XML_w, XML_h ), OString::number( rSize.GetHeight( ) ) ); } } else if ( m_rExport.bOutPageDescs ) @@ -5357,12 +5377,18 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) } else if ( m_rExport.bOutFlyFrmAttrs ) { - pushToAttrList( &m_pFlyAttrList, FSNS( XML_w, XML_hSpace ), + if ( !m_pFlyAttrList ) + m_pFlyAttrList = m_pSerializer->createAttrList(); + + m_pFlyAttrList->add( FSNS( XML_w, XML_hSpace ), OString::number( - ( rLRSpace.GetLeft() + rLRSpace.GetRight() ) / 2 ).getStr() ); + ( rLRSpace.GetLeft() + rLRSpace.GetRight() ) / 2 ) ); } else if ( m_rExport.bOutPageDescs ) { + if ( !m_pSectionSpacingAttrList ) + m_pSectionSpacingAttrList = m_pSerializer->createAttrList(); + m_pageMargins.nPageMarginLeft = 0; m_pageMargins.nPageMarginRight = 0; @@ -5378,9 +5404,8 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) m_pageMargins.nPageMarginLeft = m_pageMargins.nPageMarginLeft + (sal_uInt16)rLRSpace.GetLeft(); m_pageMargins.nPageMarginRight = m_pageMargins.nPageMarginRight + (sal_uInt16)rLRSpace.GetRight(); - pushToAttrList( &m_pSectionSpacingAttrList, 2, - FSNS( XML_w, XML_left ), OString::number( m_pageMargins.nPageMarginLeft ).getStr(), - FSNS( XML_w, XML_right ), OString::number( m_pageMargins.nPageMarginRight ).getStr() ); + m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_left ), OString::number( m_pageMargins.nPageMarginLeft ) ); + m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_right ), OString::number( m_pageMargins.nPageMarginRight ) ); } else { @@ -5411,9 +5436,12 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace ) } else if ( m_rExport.bOutFlyFrmAttrs ) { - pushToAttrList( &m_pFlyAttrList, FSNS( XML_w, XML_vSpace ), + if ( !m_pFlyAttrList ) + m_pFlyAttrList = m_pSerializer->createAttrList(); + + m_pFlyAttrList->add( FSNS( XML_w, XML_vSpace ), OString::number( - ( rULSpace.GetLower() + rULSpace.GetUpper() ) / 2 ).getStr() ); + ( rULSpace.GetLower() + rULSpace.GetUpper() ) / 2 ) ); } else if (m_rExport.bOutPageDescs ) { @@ -5421,57 +5449,64 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace ) if ( !m_rExport.GetCurItemSet() ) return; + if ( !m_pSectionSpacingAttrList ) + m_pSectionSpacingAttrList = m_pSerializer->createAttrList(); + HdFtDistanceGlue aDistances( *m_rExport.GetCurItemSet() ); sal_Int32 nHeader = 0; if ( aDistances.HasHeader() ) nHeader = sal_Int32( aDistances.dyaHdrTop ); + m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_header ), OString::number( nHeader ) ); // Page top m_pageMargins.nPageMarginTop = aDistances.dyaTop; + m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_top ), + OString::number( m_pageMargins.nPageMarginTop ) ); sal_Int32 nFooter = 0; if ( aDistances.HasFooter() ) nFooter = sal_Int32( aDistances.dyaHdrBottom ); + m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_footer ), OString::number( nFooter ) ); // Page Bottom m_pageMargins.nPageMarginBottom = aDistances.dyaBottom; + m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_bottom ), + OString::number( m_pageMargins.nPageMarginBottom ) ); - pushToAttrList( &m_pSectionSpacingAttrList, 5, - FSNS( XML_w, XML_header ), OString::number( nHeader ).getStr(), - FSNS( XML_w, XML_top ), OString::number( m_pageMargins.nPageMarginTop ).getStr(), - FSNS( XML_w, XML_footer ), OString::number( nFooter ).getStr(), - FSNS( XML_w, XML_bottom ), OString::number( m_pageMargins.nPageMarginBottom ).getStr(), - // FIXME Page Gutter is not handled ATM, setting to 0 as it's mandatory for OOXML - FSNS( XML_w, XML_gutter ), "0" ); + // FIXME Page Gutter is not handled ATM, setting to 0 as it's mandatory for OOXML + m_pSectionSpacingAttrList->add( FSNS( XML_w, XML_gutter ), + OString::number( 0 ) ); } else { + if ( !m_pParagraphSpacingAttrList ) + m_pParagraphSpacingAttrList = m_pSerializer->createAttrList(); SAL_INFO("sw.ww8", "DocxAttributeOutput::FormatULSpace: setting spacing" << rULSpace.GetUpper() ); // check if before auto spacing was set during import and spacing we get from actual object is same // that we set in import. If yes just write beforeAutoSpacing tag. if (m_bParaBeforeAutoSpacing && m_nParaBeforeSpacing == rULSpace.GetUpper()) { - pushToAttrList( &m_pParagraphSpacingAttrList, - FSNS( XML_w, XML_beforeAutospacing ), "1" ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_beforeAutospacing ), + "1" ); } else { - pushToAttrList( &m_pParagraphSpacingAttrList, - FSNS( XML_w, XML_before ), OString::number( rULSpace.GetUpper() ).getStr() ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_before ), + OString::number( rULSpace.GetUpper() ) ); } m_bParaBeforeAutoSpacing = false; // check if after auto spacing was set during import and spacing we get from actual object is same // that we set in import. If yes just write afterAutoSpacing tag. if (m_bParaAfterAutoSpacing && m_nParaAfterSpacing == rULSpace.GetLower()) { - pushToAttrList( &m_pParagraphSpacingAttrList, - FSNS( XML_w, XML_afterAutospacing ), "1" ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_afterAutospacing ), + "1" ); } else { - pushToAttrList( &m_pParagraphSpacingAttrList, - FSNS( XML_w, XML_after ), OString::number( rULSpace.GetLower()).getStr() ); + m_pParagraphSpacingAttrList->add( FSNS( XML_w, XML_after ), + OString::number( rULSpace.GetLower()) ); } m_bParaAfterAutoSpacing = false; @@ -5524,6 +5559,9 @@ void DocxAttributeOutput::FormatSurround( const SwFmtSurround& rSurround ) } else if ( m_rExport.bOutFlyFrmAttrs ) { + if ( !m_pFlyAttrList ) + m_pFlyAttrList = m_pSerializer->createAttrList(); + OString sWrap( "auto" ); switch ( rSurround.GetSurround( ) ) { @@ -5541,7 +5579,7 @@ void DocxAttributeOutput::FormatSurround( const SwFmtSurround& rSurround ) sWrap = OString( "around" ); } - pushToAttrList(&m_pFlyAttrList, FSNS( XML_w, XML_wrap ), sWrap.getStr() ); + m_pFlyAttrList->add( FSNS( XML_w, XML_wrap ), sWrap ); } } @@ -5556,6 +5594,9 @@ void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert } else if ( m_rExport.bOutFlyFrmAttrs ) { + if ( !m_pFlyAttrList ) + m_pFlyAttrList = m_pSerializer->createAttrList(); + OString sAlign; switch( rFlyVert.GetVertOrient() ) { @@ -5577,10 +5618,10 @@ void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert } if ( !sAlign.isEmpty() ) - pushToAttrList( &m_pFlyAttrList, FSNS( XML_w, XML_yAlign ), sAlign.getStr() ); + m_pFlyAttrList->add( FSNS( XML_w, XML_yAlign ), sAlign ); else - pushToAttrList( &m_pFlyAttrList, FSNS( XML_w, XML_y ), - OString::number( rFlyVert.GetPos() ).getStr() ); + m_pFlyAttrList->add( FSNS( XML_w, XML_y ), + OString::number( rFlyVert.GetPos() ) ); OString sVAnchor( "page" ); switch ( rFlyVert.GetRelationOrient( ) ) @@ -5603,7 +5644,7 @@ void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert break; } - pushToAttrList( &m_pFlyAttrList, FSNS( XML_w, XML_vAnchor ), sVAnchor.getStr() ); + m_pFlyAttrList->add( FSNS( XML_w, XML_vAnchor ), sVAnchor ); } } @@ -5618,6 +5659,9 @@ void DocxAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHor } else if ( m_rExport.bOutFlyFrmAttrs ) { + if ( !m_pFlyAttrList ) + m_pFlyAttrList = m_pSerializer->createAttrList(); + OString sAlign; switch( rFlyHori.GetHoriOrient() ) { @@ -5637,10 +5681,10 @@ void DocxAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHor } if ( !sAlign.isEmpty() ) - pushToAttrList( &m_pFlyAttrList, FSNS( XML_w, XML_xAlign ), sAlign.getStr() ); + m_pFlyAttrList->add( FSNS( XML_w, XML_xAlign ), sAlign ); else - pushToAttrList( &m_pFlyAttrList, FSNS( XML_w, XML_x ), - OString::number( rFlyHori.GetPos() ).getStr() ); + m_pFlyAttrList->add( FSNS( XML_w, XML_x ), + OString::number( rFlyHori.GetPos() ) ); OString sHAnchor( "page" ); switch ( rFlyHori.GetRelationOrient( ) ) @@ -5662,7 +5706,7 @@ void DocxAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHor break; } - pushToAttrList( &m_pFlyAttrList, FSNS( XML_w, XML_hAnchor ), sHAnchor.getStr() ); + m_pFlyAttrList->add( FSNS( XML_w, XML_hAnchor ), sHAnchor ); } } @@ -5700,13 +5744,15 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) // Calculate opacity value // Consider oox/source/vml/vmlformatting.cxx : decodeColor() function. double fOpacity = (double)(*oAlpha) * 65535 / ::oox::drawingml::MAX_PERCENT; - OUString sOpacity = OUString::number(fOpacity) + "f"; + OUString sOpacity = OUString::number(fOpacity); - pushToAttrList( &m_pFlyFillAttrList, XML_opacity, OUStringToOString(sOpacity, RTL_TEXTENCODING_UTF8).getStr() ); + if ( !m_pFlyFillAttrList ) + m_pFlyFillAttrList = m_pSerializer->createAttrList(); + + m_pFlyFillAttrList->add(XML_opacity, OUStringToOString(sOpacity, RTL_TEXTENCODING_UTF8) + "f"); } - sColor = "#" + sColor; - pushToAttrList( &m_pFlyAttrList, XML_fillcolor, sColor.getStr() ); + m_pFlyAttrList->add(XML_fillcolor, "#" + sColor); } else if (m_bDMLTextFrameSyntax) { @@ -5739,7 +5785,10 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad { if (*m_oFillStyle == XFILL_GRADIENT) { - pushToAttrList(&m_pFlyFillAttrList, XML_type, "gradient"); + if ( !m_pFlyFillAttrList ) + m_pFlyFillAttrList = m_pSerializer->createAttrList(); + + m_pFlyFillAttrList->add(XML_type, "gradient"); const XGradient& rGradient = rFillGradient.GetGradientValue(); OString sStartColor = msfilter::util::ConvertColor(rGradient.GetStartColor()); @@ -5754,8 +5803,7 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad nReverseAngle = nReverseAngle / 10; nReverseAngle = (270 - nReverseAngle) % 360; if (nReverseAngle != 0) - pushToAttrList(&m_pFlyFillAttrList, - XML_angle, OString::number(nReverseAngle).getStr()); + m_pFlyFillAttrList->add(XML_angle, OString::number(nReverseAngle)); OString sColor1 = sStartColor; OString sColor2 = sEndColor; @@ -5763,7 +5811,7 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad switch (rGradient.GetGradientStyle()) { case XGRAD_AXIAL: - pushToAttrList(&m_pFlyFillAttrList, XML_focus, "50%"); + m_pFlyFillAttrList->add(XML_focus, "50%"); // If it is an 'axial' gradient - swap the colors // (because in the import process they were imported swapped) sColor1 = sEndColor; @@ -5776,10 +5824,8 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad case XGRAD_RECT: break; } - sColor1 = "#" + sColor1; - sColor2 = "#" + sColor2; - pushToAttrList(&m_pFlyAttrList, XML_fillcolor , sColor1.getStr()); - pushToAttrList(&m_pFlyFillAttrList, XML_color2, sColor2.getStr()); + m_pFlyAttrList->add(XML_fillcolor , "#" + sColor1); + m_pFlyFillAttrList->add(XML_color2, "#" + sColor2); } m_oFillStyle.reset(); } @@ -5802,8 +5848,8 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) { if (m_bTextFrameSyntax) { - pushToAttrList(&m_pFlyAttrList, 2, - XML_stroked, "f", XML_strokeweight, "0pt"); + m_pFlyAttrList->add(XML_stroked, "f"); + m_pFlyAttrList->add(XML_strokeweight, "0pt"); } } else @@ -5814,17 +5860,15 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) if (m_bTextFrameSyntax) { sColor = "#" + sColor; + m_pFlyAttrList->add(XML_strokecolor, sColor); sal_Int32 nWidth = sal_Int32(fConverted / 20); - OString sWidth = OString::number(nWidth) + "pt"; - pushToAttrList(&m_pFlyAttrList, 2, - XML_strokecolor, sColor.getStr(), - XML_strokeweight, sWidth.getStr()); + m_pFlyAttrList->add(XML_strokeweight, OString::number(nWidth) + "pt"); } else { - OString sWidth(OString::number(TwipsToEMU(fConverted))); + OString aWidth(OString::number(TwipsToEMU(fConverted))); m_pSerializer->startElementNS(XML_a, XML_ln, - XML_w, sWidth.getStr(), + XML_w, aWidth.getStr(), FSEND); m_pSerializer->startElementNS(XML_a, XML_solidFill, FSEND); m_pSerializer->singleElementNS(XML_a, XML_srgbClr, @@ -6115,40 +6159,54 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem ) if ( i->first == "CharThemeNameAscii" && bWriteAsciiTheme ) { i->second >>= str; - pushToAttrList( &m_pFontsAttrList, FSNS( XML_w, XML_asciiTheme ), - OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); + m_pFontsAttrList->add( FSNS( XML_w, XML_asciiTheme ), + OUStringToOString( str, RTL_TEXTENCODING_UTF8 ) ); } else if ( i->first == "CharThemeNameCs" && bWriteCSTheme ) { i->second >>= str; - pushToAttrList( &m_pFontsAttrList, FSNS( XML_w, XML_cstheme ), - OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); + m_pFontsAttrList->add( FSNS( XML_w, XML_cstheme ), + OUStringToOString( str, RTL_TEXTENCODING_UTF8 ) ); } else if ( i->first == "CharThemeNameEastAsia" && bWriteEastAsiaTheme ) { i->second >>= str; - pushToAttrList( &m_pFontsAttrList, FSNS( XML_w, XML_eastAsiaTheme ), - OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); + m_pFontsAttrList->add( FSNS( XML_w, XML_eastAsiaTheme ), + OUStringToOString( str, RTL_TEXTENCODING_UTF8 ) ); } else if ( i->first == "CharThemeNameHAnsi" && bWriteAsciiTheme ) // this is not a mistake: in LibO we don't directly support the hAnsi family // of attributes so we save the same value from ascii attributes instead { i->second >>= str; - pushToAttrList( &m_pFontsAttrList, FSNS( XML_w, XML_hAnsiTheme ), - OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); + m_pFontsAttrList->add( FSNS( XML_w, XML_hAnsiTheme ), + OUStringToOString( str, RTL_TEXTENCODING_UTF8 ) ); } else if ( i->first == "CharThemeColor" && bWriteThemeFontColor ) { i->second >>= str; - pushToAttrList( &m_pColorAttrList, FSNS( XML_w, XML_themeColor ), - OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); + if( !m_pColorAttrList ) + m_pColorAttrList = m_pSerializer->createAttrList(); + + m_pColorAttrList->add( FSNS( XML_w, XML_themeColor ), + OUStringToOString( str, RTL_TEXTENCODING_UTF8 ) ); } else if ( i->first == "CharThemeColorShade" ) { i->second >>= str; - pushToAttrList( &m_pColorAttrList, FSNS( XML_w, XML_themeShade ), - OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); + if( !m_pColorAttrList ) + m_pColorAttrList = m_pSerializer->createAttrList(); + + m_pColorAttrList->add( FSNS( XML_w, XML_themeShade ), + OUStringToOString( str, RTL_TEXTENCODING_UTF8 ) ); } else if( i->first == "CharThemeFontNameCs" || i->first == "CharThemeFontNameAscii" || @@ -6297,26 +6355,4 @@ void DocxAttributeOutput::BulletDefinition(int nId, const Graphic& rGraphic, Siz m_pSerializer->endElementNS(XML_w, XML_numPicBullet); } -void DocxAttributeOutput::pushToAttrList( ::sax_fastparser::FastAttributeList **pAttrList, sal_Int32 nAttrName, const sal_Char* sAttrValue ) -{ - pushToAttrList( pAttrList, 1, nAttrName, sAttrValue ); -} - -void DocxAttributeOutput::pushToAttrList( ::sax_fastparser::FastAttributeList **pAttrList, sal_Int32 nAttrs, ... ) -{ - if( !*pAttrList ) - *pAttrList = m_pSerializer->createAttrList(); - - va_list args; - va_start( args, nAttrs ); - for( sal_Int32 i = 0; i<nAttrs; i++) - { - sal_Int32 nName = va_arg( args, sal_Int32 ); - const char* pValue = va_arg( args, const char* ); - if( pValue ) - (*pAttrList)->add( nName, pValue ); - } - va_end( args ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 68a3e5d..62ec9f4 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -672,9 +672,6 @@ private: void CmdField_Impl( FieldInfos& rInfos ); void EndField_Impl( FieldInfos& rInfos ); - void pushToAttrList( ::sax_fastparser::FastAttributeList **pAttrList, sal_Int32 nAttrName, const sal_Char* sAttrValue ); - void pushToAttrList( ::sax_fastparser::FastAttributeList **pAttrList, sal_Int32 nArgs, ... ); - ::sax_fastparser::FastAttributeList *m_pFontsAttrList, *m_pEastAsianLayoutAttrList; ::sax_fastparser::FastAttributeList *m_pCharLangAttrList; ::sax_fastparser::FastAttributeList *m_pSectionSpacingAttrList;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits