summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-07-30 14:15:39 +0200
committerNoel Grandin <noel@peralex.com>2014-07-31 11:38:47 +0200
commit65803ad94c8652edb84f82202717b1b206407a65 (patch)
treec9de76166e6b7ce9f336edf7c927a30eca0977e6
parentGtkComboBoxText requires gtk >= 2.24 (again). (diff)
downloadcore-65803ad94c8652edb84f82202717b1b206407a65.tar.gz
core-65803ad94c8652edb84f82202717b1b206407a65.zip
fix some dodgy FieldUnit conversions
the FieldUnit enum was being converted in some dodgy ways and in some places the MapUnit enum values were being used. Change-Id: Ic9aacb84058d1c14c3a4a79ef6676082df9a7270
-rw-r--r--editeng/source/xml/xmltxtexp.cxx2
-rw-r--r--include/svx/unoapi.hxx5
-rw-r--r--include/xmloff/xmlexp.hxx3
-rw-r--r--include/xmloff/xmluconv.hxx3
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx4
-rw-r--r--sc/source/filter/xml/xmlexprt.hxx2
-rw-r--r--sd/source/ui/unoidl/UnoDocumentSettings.cxx6
-rw-r--r--svx/source/unodraw/unoprov.cxx4
-rw-r--r--svx/source/xml/xmlxtexp.cxx2
-rw-r--r--sw/inc/swmodule.hxx2
-rw-r--r--sw/source/uibase/app/swmodul1.cxx4
-rw-r--r--sw/source/uibase/inc/unomod.hxx4
-rw-r--r--sw/source/uibase/uno/unomod.cxx30
-rw-r--r--xmloff/source/core/xmlexp.cxx2
-rw-r--r--xmloff/source/core/xmluconv.cxx8
15 files changed, 45 insertions, 36 deletions
diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx
index 48f73421e678..a0136a6d4e1a 100644
--- a/editeng/source/xml/xmltxtexp.cxx
+++ b/editeng/source/xml/xmltxtexp.cxx
@@ -372,7 +372,7 @@ SvxXMLTextExportComponent::SvxXMLTextExportComponent(
const ESelection& rSel,
const OUString& rFileName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > & xHandler)
-: SvXMLExport( xContext, "", rFileName, xHandler, ((frame::XModel*)new SvxSimpleUnoModel()), MAP_CM ),
+: SvXMLExport( xContext, "", rFileName, xHandler, ((frame::XModel*)new SvxSimpleUnoModel()), FUNIT_CM ),
maSelection( rSel )
{
SvxEditEngineSource aEditSource( pEditEngine );
diff --git a/include/svx/unoapi.hxx b/include/svx/unoapi.hxx
index 74bd154f08cd..07330ac255ba 100644
--- a/include/svx/unoapi.hxx
+++ b/include/svx/unoapi.hxx
@@ -27,6 +27,7 @@
#include <svtools/grfmgr.hxx>
#include <svl/poolitem.hxx>
#include <svx/svxdllapi.h>
+#include <tools/fldunit.hxx>
class SvxShape;
class SdrObject;
@@ -68,13 +69,13 @@ SVX_DLLPUBLIC bool SvxMapUnitToMeasureUnit( const short nVcl, short& eApi ) thro
* Maps the API constant MeasureUnit to a vcl MapUnit enum.
* Returns false if conversion is not supported.
*/
-SVX_DLLPUBLIC bool SvxMeasureUnitToFieldUnit( const short eApi, short& nVcl ) throw();
+SVX_DLLPUBLIC bool SvxMeasureUnitToFieldUnit( const short eApi, FieldUnit& nVcl ) throw();
/**
* Maps the vcl MapUnit enum to a API constant MeasureUnit.
* Returns false if conversion is not supported.
*/
-SVX_DLLPUBLIC bool SvxFieldUnitToMeasureUnit( const short nVcl, short& eApi ) throw();
+SVX_DLLPUBLIC bool SvxFieldUnitToMeasureUnit( const FieldUnit nVcl, short& eApi ) throw();
/**
* If the given name is a predefined name for the current language it is replaced by
diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index 57cc643536bf..d149aed89c32 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -58,6 +58,7 @@
#include <xmloff/XMLPageExport.hxx>
#include <xmloff/ProgressBarHelper.hxx>
#include <cppuhelper/implbase6.hxx>
+#include <tools/fldunit.hxx>
#include <list>
@@ -287,7 +288,7 @@ public:
const OUString& rFileName,
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > &,
- sal_Int16 const eDefaultFieldUnit );
+ FieldUnit const eDefaultFieldUnit );
virtual ~SvXMLExport();
diff --git a/include/xmloff/xmluconv.hxx b/include/xmloff/xmluconv.hxx
index 29a5e37b40c6..63216feca769 100644
--- a/include/xmloff/xmluconv.hxx
+++ b/include/xmloff/xmluconv.hxx
@@ -38,6 +38,7 @@
#include <com/sun/star/drawing/Position3D.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include <tools/fldunit.hxx>
// predeclarations
@@ -96,7 +97,7 @@ public:
virtual ~SvXMLUnitConverter();
- static sal_Int16 GetMeasureUnit(sal_Int16 const nFieldUnit);
+ static sal_Int16 GetMeasureUnit(FieldUnit const nFieldUnit);
/** sets the default unit for numerical measures */
void SetCoreMeasureUnit( sal_Int16 const eCoreMeasureUnit );
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 6e59a8364d09..9c44f8d086ce 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -456,7 +456,7 @@ void ScXMLShapeExport::onExport( const uno::Reference < drawing::XShape >& xShap
}
}
-sal_Int16 ScXMLExport::GetFieldUnit()
+sal_Int16 ScXMLExport::GetMeasureUnit()
{
css::uno::Reference<css::sheet::XGlobalSheetSettings> xProperties =
css::sheet::GlobalSheetSettings::create( comphelper::getProcessComponentContext() );
@@ -467,7 +467,7 @@ sal_Int16 ScXMLExport::GetFieldUnit()
ScXMLExport::ScXMLExport(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext,
OUString const & implementationName, sal_uInt16 nExportFlag)
-: SvXMLExport( SvXMLUnitConverter::GetMeasureUnit(GetFieldUnit()),
+: SvXMLExport( GetMeasureUnit(),
xContext, implementationName, XML_SPREADSHEET, nExportFlag ),
pDoc(NULL),
nSourceStreamPos(0),
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index a6ed6899a930..d86dd695fb46 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -242,7 +242,7 @@ public:
virtual ~ScXMLExport();
- static sal_Int16 GetFieldUnit();
+ static sal_Int16 GetMeasureUnit();
inline ScDocument* GetDocument() { return pDoc; }
inline const ScDocument* GetDocument() const { return pDoc; }
bool IsMatrix (const ScAddress& aCell,
diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
index 8b3851b7192e..e792db8d4d30 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -658,10 +658,10 @@ throw (UnknownPropertyException, PropertyVetoException,
sal_Int16 nValue = 0;
if( *pValues >>= nValue )
{
- short nFieldUnit;
+ FieldUnit nFieldUnit;
if( SvxMeasureUnitToFieldUnit( nValue, nFieldUnit ) )
{
- pDoc->SetUIUnit((FieldUnit)nFieldUnit );
+ pDoc->SetUIUnit( nFieldUnit );
bOk = true;
}
}
@@ -1065,7 +1065,7 @@ throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
case HANDLE_MEASUREUNIT:
{
short nMeasure;
- SvxFieldUnitToMeasureUnit( (const short)pDoc->GetUIUnit(), nMeasure );
+ SvxFieldUnitToMeasureUnit( pDoc->GetUIUnit(), nMeasure );
*pValue <<= (sal_Int16)nMeasure;
}
break;
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 67467f832f4b..7358264c4ec9 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -1034,7 +1034,7 @@ bool SvxMapUnitToMeasureUnit( const short eVcl, short& eApi ) throw()
Returns false if conversion is not supported.
*/
-bool SvxMeasureUnitToFieldUnit( const short eApi, short& eVcl ) throw()
+bool SvxMeasureUnitToFieldUnit( const short eApi, FieldUnit& eVcl ) throw()
{
switch( eApi )
{
@@ -1060,7 +1060,7 @@ bool SvxMeasureUnitToFieldUnit( const short eApi, short& eVcl ) throw()
/** maps the vcl MapUnit enum to a API constant MeasureUnit.
Returns false if conversion is not supported.
*/
-bool SvxFieldUnitToMeasureUnit( const short eVcl, short& eApi ) throw()
+bool SvxFieldUnitToMeasureUnit( const FieldUnit eVcl, short& eApi ) throw()
{
switch( eVcl )
{
diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx
index 511d8ec79fd9..475cb2cd9f44 100644
--- a/svx/source/xml/xmlxtexp.cxx
+++ b/svx/source/xml/xmlxtexp.cxx
@@ -151,7 +151,7 @@ SvxXMLXTableExportComponent::SvxXMLXTableExportComponent(
const uno::Reference<xml::sax::XDocumentHandler> & rHandler,
const uno::Reference<container::XNameContainer >& xTable,
uno::Reference<document::XGraphicObjectResolver >& xGrfResolver )
-: SvXMLExport( xContext, "", rFileName, rHandler, NULL, MAP_100TH_MM),
+: SvXMLExport( xContext, "", rFileName, rHandler, NULL, FUNIT_100TH_MM),
mxTable( xTable )
{
diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx
index 7f61e42185ec..ad7f677f115a 100644
--- a/sw/inc/swmodule.hxx
+++ b/sw/inc/swmodule.hxx
@@ -210,7 +210,7 @@ public:
OUString GetDocStatWordDelim() const;
// Pass metric of ModuleConfig (for HTML-export).
- sal_uInt16 GetMetric( bool bWeb ) const;
+ FieldUnit GetMetric( bool bWeb ) const;
// Pass update-statuses.
sal_uInt16 GetLinkUpdMode( bool bWeb ) const;
diff --git a/sw/source/uibase/app/swmodul1.cxx b/sw/source/uibase/app/swmodul1.cxx
index dcdfc0101625..db6e4596d090 100644
--- a/sw/source/uibase/app/swmodul1.cxx
+++ b/sw/source/uibase/app/swmodul1.cxx
@@ -557,7 +557,7 @@ OUString SwModule::GetDocStatWordDelim() const
}
// Passing-through of the ModuleConfig's Metric (for HTML-Export)
-sal_uInt16 SwModule::GetMetric( bool bWeb ) const
+FieldUnit SwModule::GetMetric( bool bWeb ) const
{
SwMasterUsrPref* pPref;
if(bWeb)
@@ -572,7 +572,7 @@ sal_uInt16 SwModule::GetMetric( bool bWeb ) const
GetUsrPref(false);
pPref = pUsrPref;
}
- return static_cast< sal_uInt16 >(pPref->GetMetric());
+ return pPref->GetMetric();
}
// Pass-through Update-Status
diff --git a/sw/source/uibase/inc/unomod.hxx b/sw/source/uibase/inc/unomod.hxx
index 839816a9651b..264ae0719d63 100644
--- a/sw/source/uibase/inc/unomod.hxx
+++ b/sw/source/uibase/inc/unomod.hxx
@@ -136,9 +136,9 @@ protected:
const SwViewOption* mpConstViewOption;
bool bObjectValid:1, bWeb:1, mbApplyZoom;
- sal_Int32 eHRulerUnit;
+ FieldUnit eHRulerUnit;
bool mbApplyHRulerMetric;
- sal_Int32 eVRulerUnit;
+ FieldUnit eVRulerUnit;
bool mbApplyVRulerMetric;
virtual void _preSetValues ()
diff --git a/sw/source/uibase/uno/unomod.cxx b/sw/source/uibase/uno/unomod.cxx
index 4ebd2dd16bcb..0e2ec54d9e9c 100644
--- a/sw/source/uibase/uno/unomod.cxx
+++ b/sw/source/uibase/uno/unomod.cxx
@@ -760,29 +760,29 @@ void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, c
case HANDLE_VIEWSET_HORI_RULER_METRIC:
case HANDLE_VIEWSET_VERT_RULER_METRIC:
{
- sal_Int32 nUnit = -1;
+ sal_uInt16 nUnit;
if( rValue >>= nUnit )
- switch( nUnit )
- {
+ switch( nUnit )
+ {
case FUNIT_MM:
case FUNIT_CM:
case FUNIT_POINT:
case FUNIT_PICA:
case FUNIT_INCH:
- if( rInfo.mnHandle == HANDLE_VIEWSET_HORI_RULER_METRIC )
- {
- eHRulerUnit = nUnit;
- mbApplyHRulerMetric = true;
- }
- else
- {
- eVRulerUnit = nUnit;
- mbApplyVRulerMetric = true;
- }
- break;
+ if( rInfo.mnHandle == HANDLE_VIEWSET_HORI_RULER_METRIC )
+ {
+ eHRulerUnit = static_cast<FieldUnit>(nUnit);
+ mbApplyHRulerMetric = true;
+ }
+ else
+ {
+ eVRulerUnit = static_cast<FieldUnit>(nUnit);
+ mbApplyVRulerMetric = true;
+ }
+ break;
default:
throw IllegalArgumentException();
- }
+ }
}
break;
default:
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 5e6571319d18..3f7d0e83634c 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -500,7 +500,7 @@ SvXMLExport::SvXMLExport(
const OUString &rFileName,
const uno::Reference< xml::sax::XDocumentHandler > & rHandler,
const Reference< XModel >& rModel,
- sal_Int16 const eDefaultFieldUnit)
+ FieldUnit const eDefaultFieldUnit)
: mpImpl( new SvXMLExport_Impl ),
m_xContext(xContext), m_implementationName(implementationName),
mxModel( rModel ),
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx
index d271df307810..c441566b3546 100644
--- a/xmloff/source/core/xmluconv.cxx
+++ b/xmloff/source/core/xmluconv.cxx
@@ -129,7 +129,7 @@ SvXMLUnitConverter::~SvXMLUnitConverter()
{
}
-sal_Int16 SvXMLUnitConverter::GetMeasureUnit(sal_Int16 const nFieldUnit)
+sal_Int16 SvXMLUnitConverter::GetMeasureUnit(FieldUnit const nFieldUnit)
{
sal_Int16 eUnit = util::MeasureUnit::INCH;
switch( nFieldUnit )
@@ -152,6 +152,12 @@ sal_Int16 SvXMLUnitConverter::GetMeasureUnit(sal_Int16 const nFieldUnit)
case FUNIT_100TH_MM:
eUnit = util::MeasureUnit::MM_100TH;
break;
+ case FUNIT_INCH:
+ eUnit = util::MeasureUnit::INCH;
+ break;
+ default:
+ assert(false);
+ break;
}
return eUnit;
}