[Libreoffice-commits] core.git: 2 commits - editeng/source include/svx include/xmloff reportdesign/source sc/source sd/source svx/source sw/inc sw/source xmloff/source
Noel Grandin
noel at peralex.com
Thu Jul 31 02:40:18 PDT 2014
editeng/source/xml/xmltxtexp.cxx | 2 -
include/svx/unoapi.hxx | 7 +++---
include/xmloff/xmlexp.hxx | 3 +-
include/xmloff/xmluconv.hxx | 12 ++++++----
reportdesign/source/filter/xml/xmlExport.cxx | 4 +--
sc/source/filter/xml/xmlexprt.cxx | 4 +--
sc/source/filter/xml/xmlexprt.hxx | 2 -
sd/source/ui/unoidl/UnoDocumentSettings.cxx | 6 ++---
sd/source/ui/unoidl/unomodel.cxx | 2 -
svx/source/unodraw/unoprov.cxx | 6 ++---
svx/source/xml/xmlxtexp.cxx | 2 -
sw/inc/swmodule.hxx | 2 -
sw/source/uibase/app/swmodul1.cxx | 4 +--
sw/source/uibase/inc/unomod.hxx | 4 +--
sw/source/uibase/uno/unomod.cxx | 30 +++++++++++++--------------
xmloff/source/core/xmlexp.cxx | 2 -
xmloff/source/core/xmluconv.cxx | 16 +++++++++-----
17 files changed, 59 insertions(+), 49 deletions(-)
New commits:
commit 7e0e581c162a8836034a47e84d28a638e9aa9744
Author: Noel Grandin <noel at peralex.com>
Date: Thu Jul 31 10:19:33 2014 +0200
cleanup usage of MapUnit enum
some places were using the wrong enum constant, and some places were
unnnecessarily converting to sal_Int16
Change-Id: I754993533c840cd33106820d99af2dc951f26a80
diff --git a/include/svx/unoapi.hxx b/include/svx/unoapi.hxx
index 07330ac..076f629 100644
--- a/include/svx/unoapi.hxx
+++ b/include/svx/unoapi.hxx
@@ -63,7 +63,7 @@ SvxNumBulletItem* SvxGetNumBulletItemByName( SfxItemPool* pPool, const OUString&
* Maps the vcl MapUnit enum to a API constant MeasureUnit.
* Returns false if conversion is not supported.
*/
-SVX_DLLPUBLIC bool SvxMapUnitToMeasureUnit( const short nVcl, short& eApi ) throw();
+SVX_DLLPUBLIC bool SvxMapUnitToMeasureUnit( const MapUnit nVcl, short& eApi ) throw();
/**
* Maps the API constant MeasureUnit to a vcl MapUnit enum.
diff --git a/include/xmloff/xmluconv.hxx b/include/xmloff/xmluconv.hxx
index 63216fe..25ef7fc 100644
--- a/include/xmloff/xmluconv.hxx
+++ b/include/xmloff/xmluconv.hxx
@@ -39,6 +39,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <tools/fldunit.hxx>
+#include <tools/mapunit.hxx>
// predeclarations
@@ -92,18 +93,18 @@ public:
SvXMLUnitConverter(
const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext >& xContext,
- sal_Int16 eCoreMeasureUnit,
- sal_Int16 eXMLMeasureUnit);
+ sal_Int16 eCoreMeasureUnit /*css::util::MeasureUnit*/,
+ sal_Int16 eXMLMeasureUnit /*css::util::MeasureUnit*/);
virtual ~SvXMLUnitConverter();
static sal_Int16 GetMeasureUnit(FieldUnit const nFieldUnit);
/** sets the default unit for numerical measures */
- void SetCoreMeasureUnit( sal_Int16 const eCoreMeasureUnit );
+ void SetCoreMeasureUnit( sal_Int16 const eCoreMeasureUnit /*css::util::MeasureUnit*/);
/** sets the default unit for textual measures */
- void SetXMLMeasureUnit( sal_Int16 const eXMLMeasureUnit );
+ void SetXMLMeasureUnit( sal_Int16 const eXMLMeasureUnit /*css::util::MeasureUnit*/);
/** gets the default unit for textual measures */
sal_Int16 GetXMLMeasureUnit() const;
diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx
index ffcf047..b200d0b 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -217,8 +217,8 @@ ORptExport::ORptExport(const Reference< XComponentContext >& _rxContext, OUStrin
,m_bAllreadyFilled(false)
{
setExportFlags( EXPORT_OASIS | nExportFlag);
- GetMM100UnitConverter().SetCoreMeasureUnit(MAP_100TH_MM);
- GetMM100UnitConverter().SetXMLMeasureUnit(MAP_CM);
+ GetMM100UnitConverter().SetCoreMeasureUnit(css::util::MeasureUnit::MM_100TH);
+ GetMM100UnitConverter().SetXMLMeasureUnit(css::util::MeasureUnit::CM);
// (getExportFlags() & EXPORT_CONTENT) != 0 ? : XML_N_OOO
_GetNamespaceMap().Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE ), XML_NAMESPACE_OFFICE );
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 6c1661b..82281dd 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1316,7 +1316,7 @@ uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& Property
break;
sal_Int16 nMeasureUnit = 0;
- SvxMapUnitToMeasureUnit( (const short)pEmbeddedObj->GetMapUnit(), nMeasureUnit );
+ SvxMapUnitToMeasureUnit( pEmbeddedObj->GetMapUnit(), nMeasureUnit );
aAny <<= (sal_Int16)nMeasureUnit;
}
break;
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 7358264..8d0cc2b 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -1008,7 +1008,7 @@ sal_Bool SvxMeasureUnitToMapUnit( const short eApi, int& eVcl ) throw()
/** maps the vcl MapUnit enum to a API constant MeasureUnit.
Returns false if conversion is not supported.
*/
-bool SvxMapUnitToMeasureUnit( const short eVcl, short& eApi ) throw()
+bool SvxMapUnitToMeasureUnit( const MapUnit eVcl, short& eApi ) throw()
{
switch( eVcl )
{
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx
index c441566..5f3eb01 100644
--- a/xmloff/source/core/xmluconv.cxx
+++ b/xmloff/source/core/xmluconv.cxx
@@ -59,8 +59,8 @@ const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11;
struct SvXMLUnitConverter::Impl
{
- sal_Int16 m_eCoreMeasureUnit;
- sal_Int16 m_eXMLMeasureUnit;
+ sal_Int16 m_eCoreMeasureUnit; /*css::util::MeasureUnit*/
+ sal_Int16 m_eXMLMeasureUnit; /*css::util::MeasureUnit*/
util::Date m_aNullDate;
mutable uno::Reference< text::XNumberingTypeInfo > m_xNumTypeInfo;
mutable uno::Reference< i18n::XCharacterClassification > m_xCharClass;
@@ -97,12 +97,12 @@ SvXMLUnitConverter::getNumTypeInfo() const
return m_pImpl->m_xNumTypeInfo;
}
-void SvXMLUnitConverter::SetCoreMeasureUnit(sal_Int16 const eCoreMeasureUnit)
+void SvXMLUnitConverter::SetCoreMeasureUnit(sal_Int16 const eCoreMeasureUnit/*css::util::MeasureUnit*/)
{
m_pImpl->m_eCoreMeasureUnit = eCoreMeasureUnit;
}
-void SvXMLUnitConverter::SetXMLMeasureUnit(sal_Int16 const eXMLMeasureUnit)
+void SvXMLUnitConverter::SetXMLMeasureUnit(sal_Int16 const eXMLMeasureUnit/*css::util::MeasureUnit*/)
{
m_pImpl->m_eXMLMeasureUnit = eXMLMeasureUnit;
}
commit 65803ad94c8652edb84f82202717b1b206407a65
Author: Noel Grandin <noel at peralex.com>
Date: Wed Jul 30 14:15:39 2014 +0200
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
diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx
index 48f7342..a0136a6 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 74bd154..07330ac 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 57cc643..d149aed 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 29a5e37..63216fe 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 6e59a83..9c44f8d 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 a6ed689..d86dd69 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 8b3851b..e792db8 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 67467f8..7358264 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 511d8ec..475cb2c 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 7f61e42..ad7f677 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 dcdfc01..db6e459 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 839816a..264ae07 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 4ebd2dd..0e2ec54 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 5e65713..3f7d0e8 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 d271df3..c441566 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;
}
More information about the Libreoffice-commits
mailing list