Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
30e1eaab
Kaydet (Commit)
30e1eaab
authored
Eki 11, 2011
tarafından
Michael Stahl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#i108468#: clean up xmluconv: add a pImpl to SvXMLUnitConverter
üst
8666469d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
73 deletions
+102
-73
xmluconv.hxx
xmloff/inc/xmloff/xmluconv.hxx
+10
-46
xmluconv.cxx
xmloff/source/core/xmluconv.cxx
+92
-27
No files found.
xmloff/inc/xmloff/xmluconv.hxx
Dosyayı görüntüle @
30e1eaab
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include "xmloff/dllapi.h"
#include "xmloff/dllapi.h"
#include "sal/types.h"
#include "sal/types.h"
#include <memory>
#include <limits.h>
#include <limits.h>
#include <tools/solar.h>
#include <tools/solar.h>
#include <xmloff/xmlement.hxx>
#include <xmloff/xmlement.hxx>
...
@@ -58,7 +59,6 @@ class OUStringBuffer;
...
@@ -58,7 +59,6 @@ class OUStringBuffer;
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
util
{
struct
DateTime
;
}
namespace
util
{
struct
DateTime
;
}
namespace
text
{
class
XNumberingTypeInfo
;
}
namespace
text
{
class
XNumberingTypeInfo
;
}
namespace
i18n
{
class
XCharacterClassification
;
}
}}}
}}}
namespace
basegfx
namespace
basegfx
...
@@ -92,17 +92,8 @@ public:
...
@@ -92,17 +92,8 @@ public:
class
XMLOFF_DLLPUBLIC
SvXMLUnitConverter
class
XMLOFF_DLLPUBLIC
SvXMLUnitConverter
{
{
private
:
private
:
sal_Int16
meCoreMeasureUnit
;
struct
Impl
;
sal_Int16
meXMLMeasureUnit
;
::
std
::
auto_ptr
<
Impl
>
m_pImpl
;
com
::
sun
::
star
::
util
::
Date
aNullDate
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
text
::
XNumberingTypeInfo
>
xNumTypeInfo
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
i18n
::
XCharacterClassification
>
xCharClass
;
// #110680#
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
lang
::
XMultiServiceFactory
>
mxServiceFactory
;
SAL_DLLPRIVATE
void
createNumTypeInfo
()
const
;
public
:
public
:
/** constructs a SvXMLUnitConverter. The core measure unit is the
/** constructs a SvXMLUnitConverter. The core measure unit is the
...
@@ -119,10 +110,10 @@ public:
...
@@ -119,10 +110,10 @@ public:
static
sal_Int16
GetMeasureUnit
(
sal_Int16
const
nFieldUnit
);
static
sal_Int16
GetMeasureUnit
(
sal_Int16
const
nFieldUnit
);
/** sets the default unit for numerical measures */
/** sets the default unit for numerical measures */
inline
void
SetCoreMeasureUnit
(
sal_Int16
const
eCoreMeasureUnit
);
void
SetCoreMeasureUnit
(
sal_Int16
const
eCoreMeasureUnit
);
/** gets the default unit for numerical measures */
/** gets the default unit for numerical measures */
inline
sal_Int16
GetCoreMeasureUnit
()
const
;
sal_Int16
GetCoreMeasureUnit
()
const
;
/** sets the default unit for textual measures */
/** sets the default unit for textual measures */
void
SetXMLMeasureUnit
(
sal_Int16
const
eXMLMeasureUnit
);
void
SetXMLMeasureUnit
(
sal_Int16
const
eXMLMeasureUnit
);
...
@@ -132,12 +123,7 @@ public:
...
@@ -132,12 +123,7 @@ public:
/** gets XNumberingTypeInfo */
/** gets XNumberingTypeInfo */
const
::
com
::
sun
::
star
::
uno
::
Reference
<
const
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
text
::
XNumberingTypeInfo
>&
getNumTypeInfo
()
const
::
com
::
sun
::
star
::
text
::
XNumberingTypeInfo
>&
getNumTypeInfo
()
const
;
{
if
(
!
xNumTypeInfo
.
is
()
)
createNumTypeInfo
();
return
xNumTypeInfo
;
}
/** convert string to measure with meCoreMeasureUnit,
/** convert string to measure with meCoreMeasureUnit,
using optional min and max values*/
using optional min and max values*/
...
@@ -201,16 +187,16 @@ public:
...
@@ -201,16 +187,16 @@ public:
const
com
::
sun
::
star
::
uno
::
Reference
<
com
::
sun
::
star
::
frame
::
XModel
>&
xModel
);
const
com
::
sun
::
star
::
uno
::
Reference
<
com
::
sun
::
star
::
frame
::
XModel
>&
xModel
);
/** Set the Null Date of the UnitConverter */
/** Set the Null Date of the UnitConverter */
void
setNullDate
(
const
com
::
sun
::
star
::
util
::
Date
&
aTempNullDate
)
{
aNullDate
=
aTempNullDate
;
}
void
setNullDate
(
const
com
::
sun
::
star
::
util
::
Date
&
aTempNullDate
)
;
/** convert double to ISO Date Time String */
/** convert double to ISO Date Time String */
void
convertDateTime
(
::
rtl
::
OUStringBuffer
&
rBuffer
,
void
convertDateTime
(
::
rtl
::
OUStringBuffer
&
rBuffer
,
const
double
&
fDateTime
,
const
double
&
fDateTime
,
sal_Bool
bAddTimeIf0AM
=
sal_False
)
{
convertDateTime
(
rBuffer
,
fDateTime
,
aNullDate
,
bAddTimeIf0AM
);
}
bool
const
bAddTimeIf0AM
=
false
);
/** convert ISO Date Time String to double */
/** convert ISO Date Time String to double */
sal_Bool
convertDateTime
(
double
&
fDateTime
,
bool
convertDateTime
(
double
&
fDateTime
,
const
::
rtl
::
OUString
&
rString
)
{
return
convertDateTime
(
fDateTime
,
rString
,
aNullDate
);
}
const
::
rtl
::
OUString
&
rString
);
/// these 2 functions use tools Date, so they're not yet moved to sax
/// these 2 functions use tools Date, so they're not yet moved to sax
...
@@ -264,28 +250,6 @@ public:
...
@@ -264,28 +250,6 @@ public:
};
};
inline
void
SvXMLUnitConverter
::
SetCoreMeasureUnit
(
sal_Int16
const
eCoreMeasureUnit
)
{
meCoreMeasureUnit
=
eCoreMeasureUnit
;
}
inline
sal_Int16
SvXMLUnitConverter
::
GetCoreMeasureUnit
()
const
{
return
meCoreMeasureUnit
;
}
inline
void
SvXMLUnitConverter
::
SetXMLMeasureUnit
(
sal_Int16
const
eXMLMeasureUnit
)
{
meXMLMeasureUnit
=
eXMLMeasureUnit
;
}
inline
sal_Int16
SvXMLUnitConverter
::
GetXMLMeasureUnit
()
const
{
return
meXMLMeasureUnit
;
}
#endif // _XMLOFF_XMLUCONV_HXX
#endif // _XMLOFF_XMLUCONV_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
xmloff/source/core/xmluconv.cxx
Dosyayı görüntüle @
30e1eaab
...
@@ -69,17 +69,71 @@ const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11;
...
@@ -69,17 +69,71 @@ const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11;
const
sal_Int8
XML_MAXDIGITSCOUNT_DATETIME
=
6
;
const
sal_Int8
XML_MAXDIGITSCOUNT_DATETIME
=
6
;
#define XML_NULLDATE "NullDate"
#define XML_NULLDATE "NullDate"
void
SvXMLUnitConverter
::
createNumTypeInfo
()
const
struct
SvXMLUnitConverter
::
Impl
{
{
if
(
mxServiceFactory
.
is
()
)
sal_Int16
m_eCoreMeasureUnit
;
sal_Int16
m_eXMLMeasureUnit
;
util
::
Date
m_aNullDate
;
uno
::
Reference
<
text
::
XNumberingTypeInfo
>
m_xNumTypeInfo
;
uno
::
Reference
<
i18n
::
XCharacterClassification
>
m_xCharClass
;
uno
::
Reference
<
lang
::
XMultiServiceFactory
>
m_xServiceFactory
;
Impl
(
uno
::
Reference
<
lang
::
XMultiServiceFactory
>
const
&
xServiceFactory
,
sal_Int16
const
eCoreMeasureUnit
,
sal_Int16
const
eXMLMeasureUnit
)
:
m_eCoreMeasureUnit
(
eCoreMeasureUnit
)
,
m_eXMLMeasureUnit
(
eXMLMeasureUnit
)
,
m_aNullDate
(
30
,
12
,
1899
)
,
m_xServiceFactory
(
xServiceFactory
)
{
{
((
SvXMLUnitConverter
*
)
this
)
->
xNumTypeInfo
=
OSL_ENSURE
(
m_xServiceFactory
.
is
(),
"got no service manager"
);
}
void
createNumTypeInfo
()
const
;
};
void
SvXMLUnitConverter
::
Impl
::
createNumTypeInfo
()
const
{
if
(
m_xServiceFactory
.
is
())
{
const_cast
<
Impl
*>
(
this
)
->
m_xNumTypeInfo
=
Reference
<
XNumberingTypeInfo
>
(
Reference
<
XNumberingTypeInfo
>
(
mxServiceFactory
->
createInstance
(
m
_
xServiceFactory
->
createInstance
(
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"com.sun.star.text.DefaultNumberingProvider"
)
)
),
UNO_QUERY
);
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"com.sun.star.text.DefaultNumberingProvider"
)
)
),
UNO_QUERY
);
}
}
}
}
const
uno
::
Reference
<
text
::
XNumberingTypeInfo
>&
SvXMLUnitConverter
::
getNumTypeInfo
()
const
{
if
(
!
m_pImpl
->
m_xNumTypeInfo
.
is
())
{
m_pImpl
->
createNumTypeInfo
();
}
return
m_pImpl
->
m_xNumTypeInfo
;
}
void
SvXMLUnitConverter
::
SetCoreMeasureUnit
(
sal_Int16
const
eCoreMeasureUnit
)
{
m_pImpl
->
m_eCoreMeasureUnit
=
eCoreMeasureUnit
;
}
sal_Int16
SvXMLUnitConverter
::
GetCoreMeasureUnit
()
const
{
return
m_pImpl
->
m_eCoreMeasureUnit
;
}
void
SvXMLUnitConverter
::
SetXMLMeasureUnit
(
sal_Int16
const
eXMLMeasureUnit
)
{
m_pImpl
->
m_eXMLMeasureUnit
=
eXMLMeasureUnit
;
}
sal_Int16
SvXMLUnitConverter
::
GetXMLMeasureUnit
()
const
{
return
m_pImpl
->
m_eXMLMeasureUnit
;
}
/** constructs a SvXMLUnitConverter. The core measure unit is the
/** constructs a SvXMLUnitConverter. The core measure unit is the
default unit for numerical measures, the XML measure unit is
default unit for numerical measures, the XML measure unit is
the default unit for textual measures
the default unit for textual measures
...
@@ -89,14 +143,8 @@ SvXMLUnitConverter::SvXMLUnitConverter(
...
@@ -89,14 +143,8 @@ SvXMLUnitConverter::SvXMLUnitConverter(
const
uno
::
Reference
<
lang
::
XMultiServiceFactory
>&
xServiceFactory
,
const
uno
::
Reference
<
lang
::
XMultiServiceFactory
>&
xServiceFactory
,
sal_Int16
const
eCoreMeasureUnit
,
sal_Int16
const
eCoreMeasureUnit
,
sal_Int16
const
eXMLMeasureUnit
)
sal_Int16
const
eXMLMeasureUnit
)
:
:
m_pImpl
(
new
Impl
(
xServiceFactory
,
eCoreMeasureUnit
,
eXMLMeasureUnit
))
aNullDate
(
30
,
12
,
1899
),
mxServiceFactory
(
xServiceFactory
)
{
{
DBG_ASSERT
(
mxServiceFactory
.
is
(),
"got no service manager"
);
meCoreMeasureUnit
=
eCoreMeasureUnit
;
meXMLMeasureUnit
=
eXMLMeasureUnit
;
}
}
SvXMLUnitConverter
::~
SvXMLUnitConverter
()
SvXMLUnitConverter
::~
SvXMLUnitConverter
()
...
@@ -136,7 +184,7 @@ bool SvXMLUnitConverter::convertMeasureToCore( sal_Int32& nValue,
...
@@ -136,7 +184,7 @@ bool SvXMLUnitConverter::convertMeasureToCore( sal_Int32& nValue,
sal_Int32
nMin
,
sal_Int32
nMax
)
const
sal_Int32
nMin
,
sal_Int32
nMax
)
const
{
{
return
::
sax
::
Converter
::
convertMeasure
(
nValue
,
rString
,
return
::
sax
::
Converter
::
convertMeasure
(
nValue
,
rString
,
meCoreMeasureUnit
,
m
_pImpl
->
m_
eCoreMeasureUnit
,
nMin
,
nMax
);
nMin
,
nMax
);
}
}
...
@@ -145,8 +193,8 @@ void SvXMLUnitConverter::convertMeasureToXML( OUStringBuffer& rString,
...
@@ -145,8 +193,8 @@ void SvXMLUnitConverter::convertMeasureToXML( OUStringBuffer& rString,
sal_Int32
nMeasure
)
const
sal_Int32
nMeasure
)
const
{
{
::
sax
::
Converter
::
convertMeasure
(
rString
,
nMeasure
,
::
sax
::
Converter
::
convertMeasure
(
rString
,
nMeasure
,
meCoreMeasureUnit
,
m
_pImpl
->
m_
eCoreMeasureUnit
,
meXMLMeasureUnit
);
m
_pImpl
->
m_
eXMLMeasureUnit
);
}
}
/** convert measure with given unit to string */
/** convert measure with given unit to string */
...
@@ -156,7 +204,7 @@ void SvXMLUnitConverter::convertMeasureToXML( OUStringBuffer& rString,
...
@@ -156,7 +204,7 @@ void SvXMLUnitConverter::convertMeasureToXML( OUStringBuffer& rString,
{
{
::
sax
::
Converter
::
convertMeasure
(
rString
,
nMeasure
,
::
sax
::
Converter
::
convertMeasure
(
rString
,
nMeasure
,
eSrcUnit
,
eSrcUnit
,
meXMLMeasureUnit
);
m
_pImpl
->
m_
eXMLMeasureUnit
);
}
}
/** convert string to enum using given enum map, if the enum is
/** convert string to enum using given enum map, if the enum is
...
@@ -281,7 +329,7 @@ void SvXMLUnitConverter::convertDouble(OUStringBuffer& rBuffer,
...
@@ -281,7 +329,7 @@ void SvXMLUnitConverter::convertDouble(OUStringBuffer& rBuffer,
double
fNumber
,
sal_Bool
bWriteUnits
)
const
double
fNumber
,
sal_Bool
bWriteUnits
)
const
{
{
::
sax
::
Converter
::
convertDouble
(
rBuffer
,
fNumber
,
::
sax
::
Converter
::
convertDouble
(
rBuffer
,
fNumber
,
bWriteUnits
,
m
eCoreMeasureUnit
,
m
eXMLMeasureUnit
);
bWriteUnits
,
m
_pImpl
->
m_eCoreMeasureUnit
,
m_pImpl
->
m_
eXMLMeasureUnit
);
}
}
/** convert string to double number (using ::rtl::math) */
/** convert string to double number (using ::rtl::math) */
...
@@ -290,11 +338,11 @@ sal_Bool SvXMLUnitConverter::convertDouble(double& rValue,
...
@@ -290,11 +338,11 @@ sal_Bool SvXMLUnitConverter::convertDouble(double& rValue,
{
{
if
(
bLookForUnits
)
if
(
bLookForUnits
)
{
{
sal_Int16
const
eSrcUnit
=
sal_Int16
const
eSrcUnit
=
::
sax
::
Converter
::
GetUnitFromString
(
::
sax
::
Converter
::
GetUnitFromString
(
rString
,
m
eCoreMeasureUnit
);
rString
,
m_pImpl
->
m_
eCoreMeasureUnit
);
return
::
sax
::
Converter
::
convertDouble
(
rValue
,
rString
,
return
::
sax
::
Converter
::
convertDouble
(
rValue
,
rString
,
eSrcUnit
,
meCoreMeasureUnit
);
eSrcUnit
,
m
_pImpl
->
m_
eCoreMeasureUnit
);
}
}
else
else
{
{
...
@@ -309,11 +357,28 @@ sal_Bool SvXMLUnitConverter::setNullDate(const com::sun::star::uno::Reference <c
...
@@ -309,11 +357,28 @@ sal_Bool SvXMLUnitConverter::setNullDate(const com::sun::star::uno::Reference <c
if
(
xNumberFormatsSupplier
.
is
())
if
(
xNumberFormatsSupplier
.
is
())
{
{
const
com
::
sun
::
star
::
uno
::
Reference
<
com
::
sun
::
star
::
beans
::
XPropertySet
>
xPropertySet
=
xNumberFormatsSupplier
->
getNumberFormatSettings
();
const
com
::
sun
::
star
::
uno
::
Reference
<
com
::
sun
::
star
::
beans
::
XPropertySet
>
xPropertySet
=
xNumberFormatsSupplier
->
getNumberFormatSettings
();
return
xPropertySet
.
is
()
&&
(
xPropertySet
->
getPropertyValue
(
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
XML_NULLDATE
)))
>>=
aNullDate
);
return
xPropertySet
.
is
()
&&
(
xPropertySet
->
getPropertyValue
(
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
XML_NULLDATE
)))
>>=
m_pImpl
->
m_
aNullDate
);
}
}
return
sal_False
;
return
sal_False
;
}
}
void
SvXMLUnitConverter
::
setNullDate
(
const
util
::
Date
&
aTempNullDate
)
{
m_pImpl
->
m_aNullDate
=
aTempNullDate
;
}
/** convert double to ISO Date Time String */
void
SvXMLUnitConverter
::
convertDateTime
(
::
rtl
::
OUStringBuffer
&
rBuffer
,
const
double
&
fDateTime
,
bool
const
bAddTimeIf0AM
)
{
convertDateTime
(
rBuffer
,
fDateTime
,
m_pImpl
->
m_aNullDate
,
bAddTimeIf0AM
);
}
/** convert ISO Date Time String to double */
bool
SvXMLUnitConverter
::
convertDateTime
(
double
&
fDateTime
,
const
::
rtl
::
OUString
&
rString
)
{
return
convertDateTime
(
fDateTime
,
rString
,
m_pImpl
->
m_aNullDate
);
}
/** convert double to ISO Date Time String */
/** convert double to ISO Date Time String */
void
SvXMLUnitConverter
::
convertDateTime
(
OUStringBuffer
&
rBuffer
,
void
SvXMLUnitConverter
::
convertDateTime
(
OUStringBuffer
&
rBuffer
,
const
double
&
fDateTime
,
const
double
&
fDateTime
,
...
@@ -782,21 +847,21 @@ OUString SvXMLUnitConverter::encodeStyleName(
...
@@ -782,21 +847,21 @@ OUString SvXMLUnitConverter::encodeStyleName(
}
}
else
else
{
{
if
(
!
xCharClass
.
is
()
)
if
(
!
m_pImpl
->
m_xCharClass
.
is
()
)
{
{
if
(
mxServiceFactory
.
is
()
)
if
(
m_pImpl
->
m_xServiceFactory
.
is
()
)
{
{
try
try
{
{
const_cast
<
SvXMLUnitConverter
*
>
(
this
)
const_cast
<
SvXMLUnitConverter
*
>
(
this
)
->
xCharClass
=
->
m_pImpl
->
m_
xCharClass
=
Reference
<
XCharacterClassification
>
(
Reference
<
XCharacterClassification
>
(
mxServiceFactory
->
createInstance
(
m
_pImpl
->
m_
xServiceFactory
->
createInstance
(
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"com.sun.star.i18n.CharacterClassification_Unicode"
))
),
"com.sun.star.i18n.CharacterClassification_Unicode"
))
),
UNO_QUERY
);
UNO_QUERY
);
OSL_ENSURE
(
xCharClass
.
is
(),
OSL_ENSURE
(
m_pImpl
->
m_
xCharClass
.
is
(),
"can't instantiate character clossification component"
);
"can't instantiate character clossification component"
);
}
}
catch
(
com
::
sun
::
star
::
uno
::
Exception
&
)
catch
(
com
::
sun
::
star
::
uno
::
Exception
&
)
...
@@ -804,9 +869,9 @@ OUString SvXMLUnitConverter::encodeStyleName(
...
@@ -804,9 +869,9 @@ OUString SvXMLUnitConverter::encodeStyleName(
}
}
}
}
}
}
if
(
xCharClass
.
is
()
)
if
(
m_pImpl
->
m_xCharClass
.
is
()
)
{
{
sal_Int16
nType
=
xCharClass
->
getType
(
rName
,
i
);
sal_Int16
nType
=
m_pImpl
->
m_xCharClass
->
getType
(
rName
,
i
);
switch
(
nType
)
switch
(
nType
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment