summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2011-10-11 14:19:00 +0200
committerMichael Stahl <mst@openoffice.org>2011-10-11 17:57:00 +0200
commit3ca2bef76886450058d1667703aeafe4c2e456c3 (patch)
treeb18d70f79bfcfd2b2e34790e86edafb4c4337a80 /sw/source
parent02c32e0f0e75a9df80888051d1ec189fa14129bd (diff)
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter. remove duplicate methods from SvXMLUnitConverter: convertBool, convertPercent, convertColor, convertNumber, convertDouble, indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars, clearUndefinedChars
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/xml/xmlexp.cxx6
-rw-r--r--sw/source/filter/xml/xmlexpit.cxx50
-rw-r--r--sw/source/filter/xml/xmlimpit.cxx29
-rw-r--r--sw/source/filter/xml/xmlithlp.cxx4
-rw-r--r--sw/source/filter/xml/xmltbli.cxx15
-rw-r--r--sw/source/ui/uiview/view.cxx4
6 files changed, 72 insertions, 36 deletions
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 569a410cf18b..520aa17025f2 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -36,6 +36,8 @@
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/xforms/XFormsSupplier.hpp>
+
+#include <sax/tools/converter.hxx>
#include <svx/svdmodel.hxx>
#include <svx/svdpage.hxx>
#include <svx/xmleohlp.hxx>
@@ -579,7 +581,7 @@ void SwXMLExport::SetBodyAttributes()
{
sal_Bool bValue = sal_True;
rtl::OUStringBuffer sBuffer;
- GetMM100UnitConverter().convertBool(sBuffer, bValue);
+ ::sax::Converter::convertBool(sBuffer, bValue);
AddAttribute(XML_NAMESPACE_TEXT, XML_USE_SOFT_PAGE_BREAKS,
sBuffer.makeStringAndClear());
}
@@ -630,7 +632,7 @@ void SwXMLExport::_ExportContent()
if (nYear != 1930 )
{
rtl::OUStringBuffer sBuffer;
- GetMM100UnitConverter().convertNumber(sBuffer, nYear);
+ ::sax::Converter::convertNumber(sBuffer, nYear);
AddAttribute(XML_NAMESPACE_TABLE, XML_NULL_YEAR, sBuffer.makeStringAndClear());
SvXMLElementExport aCalcSettings(*this, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, sal_True, sal_True);
}
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index 7faeaa942494..065571abf15d 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -28,13 +28,15 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
+
#include "xmlexpit.hxx"
-#include <xmloff/xmluconv.hxx>
#include <rtl/ustrbuf.hxx>
+#include <sax/tools/converter.hxx>
#include <svl/itempool.hxx>
#include <svl/poolitem.hxx>
#include <svl/itemset.hxx>
+#include <xmloff/xmluconv.hxx>
#include <xmloff/attrlist.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmlnmspe.hxx>
@@ -412,21 +414,30 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
{
case MID_L_MARGIN:
if(pLRSpace->GetPropLeft() != 100)
- rUnitConverter.convertPercent( aOut, pLRSpace->GetPropLeft() );
+ {
+ ::sax::Converter::convertPercent(
+ aOut, pLRSpace->GetPropLeft() );
+ }
else
rUnitConverter.convertMeasure( aOut, pLRSpace->GetLeft() );
break;
case MID_R_MARGIN:
if(pLRSpace->GetPropRight() != 100)
- rUnitConverter.convertPercent( aOut, pLRSpace->GetPropRight() );
+ {
+ ::sax::Converter::convertPercent(
+ aOut, pLRSpace->GetPropRight() );
+ }
else
rUnitConverter.convertMeasure( aOut, pLRSpace->GetRight() );
break;
case MID_FIRST_AUTO:
if( pLRSpace->IsAutoFirst() )
- rUnitConverter.convertBool( aOut, pLRSpace->IsAutoFirst() );
+ {
+ ::sax::Converter::convertBool(
+ aOut, pLRSpace->IsAutoFirst() );
+ }
else
bOk = sal_False;
break;
@@ -435,8 +446,10 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
if( !pLRSpace->IsAutoFirst() )
{
if(pLRSpace->GetPropTxtFirstLineOfst() != 100)
- rUnitConverter.convertPercent(
+ {
+ ::sax::Converter::convertPercent(
aOut, pLRSpace->GetPropTxtFirstLineOfst() );
+ }
else
rUnitConverter.convertMeasure( aOut, pLRSpace->GetTxtFirstLineOfst() );
}
@@ -461,14 +474,20 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
{
case MID_UP_MARGIN:
if( pULSpace->GetPropUpper() != 100 )
- rUnitConverter.convertPercent( aOut, pULSpace->GetPropUpper() );
+ {
+ ::sax::Converter::convertPercent(
+ aOut, pULSpace->GetPropUpper() );
+ }
else
rUnitConverter.convertMeasure( aOut, pULSpace->GetUpper() );
break;
case MID_LO_MARGIN:
if( pULSpace->GetPropLower() != 100 )
- rUnitConverter.convertPercent( aOut, pULSpace->GetPropLower() );
+ {
+ ::sax::Converter::convertPercent(
+ aOut, pULSpace->GetPropLower() );
+ }
else
rUnitConverter.convertMeasure( aOut, pULSpace->GetLower() );
break;
@@ -510,7 +529,7 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
nX *= pShadow->GetWidth();
nY *= pShadow->GetWidth();
- rUnitConverter.convertColor( aOut, pShadow->GetColor() );
+ ::sax::Converter::convertColor(aOut, pShadow->GetColor().GetColor());
aOut.append( sal_Unicode(' ') );
rUnitConverter.convertMeasure( aOut, nX );
aOut.append( sal_Unicode(' ') );
@@ -762,7 +781,8 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
aOut.append( sal_Unicode( ' ' ) );
aOut.append( GetXMLToken( eStyle ) );
aOut.append( sal_Unicode( ' ' ) );
- rUnitConverter.convertColor( aOut, pLine->GetColor() );
+ ::sax::Converter::convertColor(aOut,
+ pLine->GetColor().GetColor());
}
}
else
@@ -883,7 +903,10 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
if ( pBrush->GetColor().GetTransparency() )
aOut.append( GetXMLToken(XML_TRANSPARENT) );
else
- rUnitConverter.convertColor( aOut, pBrush->GetColor());
+ {
+ ::sax::Converter::convertColor(aOut,
+ pBrush->GetColor().GetColor());
+ }
bOk = sal_True;
break;
@@ -993,7 +1016,7 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
}
else // #i114163# positiveInteger only!
{
- rUnitConverter.convertNumber(aOut, number);
+ ::sax::Converter::convertNumber(aOut, number);
}
bOk = sal_True;
}
@@ -1006,7 +1029,7 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
const SfxBoolItem* pSplit = PTR_CAST(SfxBoolItem, &rItem);
OSL_ENSURE( pSplit != NULL, "Wrong Which-ID" );
- rUnitConverter.convertBool( aOut, pSplit->GetValue() );
+ ::sax::Converter::convertBool( aOut, pSplit->GetValue() );
bOk = sal_True;
}
break;
@@ -1044,7 +1067,8 @@ sal_Bool SvXMLExportItemMapper::QueryXMLValue(
case MID_FRMSIZE_REL_WIDTH:
if( pFrmSize->GetWidthPercent() )
{
- rUnitConverter.convertPercent( aOut, pFrmSize->GetWidthPercent() );
+ ::sax::Converter::convertPercent(
+ aOut, pFrmSize->GetWidthPercent() );
bOk = sal_True;
}
break;
diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx
index 6ee9e403071c..21f9ea7c3364 100644
--- a/sw/source/filter/xml/xmlimpit.cxx
+++ b/sw/source/filter/xml/xmlimpit.cxx
@@ -28,7 +28,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
+
#include "xmlimpit.hxx"
+
+#include <sax/tools/converter.hxx>
#include <xmloff/xmluconv.hxx>
#include <svl/itempool.hxx>
#include <svl/poolitem.hxx>
@@ -258,7 +261,7 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
sal_Int32 nAbs = 0;
if( rValue.indexOf( sal_Unicode('%') ) != -1 )
- bOk = rUnitConverter.convertPercent( nProp, rValue );
+ bOk = ::sax::Converter::convertPercent(nProp, rValue);
else
bOk = rUnitConverter.convertMeasure( nAbs, rValue );
@@ -282,7 +285,7 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
sal_Int32 nAbs = 0;
if( rValue.indexOf( sal_Unicode('%') ) != -1 )
- bOk = rUnitConverter.convertPercent( nProp, rValue );
+ bOk = ::sax::Converter::convertPercent(nProp, rValue);
else
bOk = rUnitConverter.convertMeasure( nAbs, rValue,
-0x7fff, 0x7fff );
@@ -292,8 +295,8 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
case MID_FIRST_AUTO:
{
- bool bAutoFirst;
- bOk = rUnitConverter.convertBool( bAutoFirst, rValue );
+ bool bAutoFirst(false);
+ bOk = ::sax::Converter::convertBool( bAutoFirst, rValue );
if( bOk )
pLRSpace->SetAutoFirst( bAutoFirst );
}
@@ -314,7 +317,7 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
sal_Int32 nAbs = 0;
if( rValue.indexOf( sal_Unicode('%') ) != -1 )
- bOk = rUnitConverter.convertPercent( nProp, rValue );
+ bOk = ::sax::Converter::convertPercent( nProp, rValue );
else
bOk = rUnitConverter.convertMeasure( nAbs, rValue );
@@ -355,10 +358,12 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
}
else if( !bColorFound && aToken.compareToAscii( "#", 1 ) == 0 )
{
- bOk = rUnitConverter.convertColor( aColor, aToken );
+ sal_Int32 nColor(0);
+ bOk = ::sax::Converter::convertColor( nColor, aToken );
if( !bOk )
return sal_False;
+ aColor.SetColor(nColor);
bColorFound = sal_True;
}
else if( !bOffsetFound )
@@ -636,7 +641,7 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
SvxBrushItem* pBrush = PTR_CAST(SvxBrushItem, &rItem);
OSL_ENSURE( pBrush != NULL, "Wrong Which-ID" );
- Color aTempColor;
+ sal_Int32 nTempColor(0);
switch( nMemberId )
{
case MID_BACK_COLOR:
@@ -645,8 +650,9 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
pBrush->GetColor().SetTransparency(0xff);
bOk = sal_True;
}
- else if( rUnitConverter.convertColor( aTempColor, rValue ) )
+ else if (::sax::Converter::convertColor(nTempColor, rValue))
{
+ Color aTempColor(nTempColor);
aTempColor.SetTransparency(0);
pBrush->SetColor( aTempColor );
bOk = sal_True;
@@ -698,7 +704,7 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
else if( -1 != aToken.indexOf( sal_Unicode('%') ) )
{
sal_Int32 nPrc = 50;
- if( rUnitConverter.convertPercent( nPrc, aToken ) )
+ if (::sax::Converter::convertPercent(nPrc, aToken))
{
if( !bHori )
{
@@ -781,7 +787,8 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId )
{
sal_Int32 nVal;
- bOk = rUnitConverter.convertNumber( nVal, rValue, 0, USHRT_MAX );
+ bOk = ::sax::Converter::convertNumber(
+ nVal, rValue, 0, USHRT_MAX);
if( bOk )
pPageDesc->SetNumOffset( (sal_uInt16)nVal );
}
@@ -857,7 +864,7 @@ sal_Bool SvXMLImportItemMapper::PutXMLValue(
case MID_FRMSIZE_REL_WIDTH:
{
sal_Int32 nValue;
- bOk = rUnitConverter.convertPercent( nValue, rValue );
+ bOk = ::sax::Converter::convertPercent( nValue, rValue );
if( bOk )
{
if( nValue < 1 )
diff --git a/sw/source/filter/xml/xmlithlp.cxx b/sw/source/filter/xml/xmlithlp.cxx
index 7f40dc0ee837..d972c73e63e3 100644
--- a/sw/source/filter/xml/xmlithlp.cxx
+++ b/sw/source/filter/xml/xmlithlp.cxx
@@ -31,6 +31,7 @@
#include "xmlithlp.hxx"
#include "hintids.hxx"
#include "unomid.h"
+#include <sax/tools/converter.hxx>
#include <svx/unomid.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx>
@@ -132,8 +133,9 @@ sal_Bool lcl_frmitems_parseXMLBorder( const OUString& rValue,
{
rHasStyle = sal_True;
}
- else if( !rHasColor && rUnitConverter.convertColor( rColor, aToken ) )
+ else if (!rHasColor && ::sax::Converter::convertColor(nTemp, aToken))
{
+ rColor.SetColor(nTemp);
rHasColor = sal_True;
}
else if( !rHasWidth &&
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 41b181ad0cde..ee98ec17c609 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/table/XCellRange.hpp>
#include <svl/itemset.hxx>
#include <svl/zformat.hxx>
+#include <sax/tools/converter.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmltkmap.hxx>
#include <xmloff/nmspmap.hxx>
@@ -505,7 +506,7 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
case XML_TOK_TABLE_VALUE:
{
double fTmp;
- if (SvXMLUnitConverter::convertDouble(fTmp, rValue))
+ if (::sax::Converter::convertDouble(fTmp, rValue))
{
fValue = fTmp;
bHasValue = sal_True;
@@ -535,8 +536,8 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
break;
case XML_TOK_TABLE_BOOLEAN_VALUE:
{
- bool bTmp;
- if (SvXMLUnitConverter::convertBool(bTmp, rValue))
+ bool bTmp(false);
+ if (::sax::Converter::convertBool(bTmp, rValue))
{
fValue = (bTmp ? 1.0 : 0.0);
bHasValue = sal_True;
@@ -545,8 +546,8 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl(
break;
case XML_TOK_TABLE_PROTECTED:
{
- bool bTmp;
- if (SvXMLUnitConverter::convertBool(bTmp, rValue))
+ bool bTmp(false);
+ if (::sax::Converter::convertBool(bTmp, rValue))
{
bProtect = bTmp;
}
@@ -1132,8 +1133,8 @@ void SwXMLDDETableContext_Impl::StartElement(
}
else if ( IsXMLToken( aLocalName, XML_AUTOMATIC_UPDATE ) )
{
- bool bTmp;
- if (SvXMLUnitConverter::convertBool(bTmp, rValue))
+ bool bTmp(false);
+ if (::sax::Converter::convertBool(bTmp, rValue))
{
bIsAutomaticUpdate = bTmp;
}
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index ccdfda45218b..9ddbc8c9f2a5 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -101,7 +101,7 @@
#include <com/sun/star/scanner/XScannerManager.hpp>
#include <toolkit/unohlp.hxx>
#include <rtl/ustrbuf.hxx>
-#include <xmloff/xmluconv.hxx>
+#include <sax/tools/converter.hxx>
#include "formatclipboard.hxx"
#include <PostItMgr.hxx>
@@ -1471,7 +1471,7 @@ void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSe
sal_uInt16 nViewID( GetViewFrame()->GetCurViewId());
pValue->Name = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "ViewId" ) );
OUStringBuffer sBuffer ( OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
- SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
+ ::sax::Converter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
pValue->Value <<= sBuffer.makeStringAndClear();
pValue++;nIndex++;