Kaydet (Commit) 9b04093e authored tarafından Charu Tyagi's avatar Charu Tyagi Kaydeden (comit) Muthu Subramanian K

fdo#74745: (DOCX) Number formatting for custom document properties.

Change-Id: Ifb9ef14180cac84fd111d81b9535266476d5f04f
Reviewed-on: https://gerrit.libreoffice.org/9896Reviewed-by: 's avatarMuthu Subramanian K <muthusuba@gmail.com>
Tested-by: 's avatarMuthu Subramanian K <muthusuba@gmail.com>
üst 9a741fca
...@@ -52,7 +52,9 @@ ...@@ -52,7 +52,9 @@
#include <com/sun/star/text/XRedline.hpp> #include <com/sun/star/text/XRedline.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/style/DropCapFormat.hpp> #include <com/sun/star/style/DropCapFormat.hpp>
#include <com/sun/star/util/NumberFormatter.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <com/sun/star/util/XNumberFormatter.hpp>
#include <com/sun/star/document/XViewDataSupplier.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp>
#include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/awt/XControlModel.hpp> #include <com/sun/star/awt/XControlModel.hpp>
...@@ -2215,7 +2217,7 @@ void DomainMapper_Impl::GetCurrentLocale(lang::Locale& rLocale) ...@@ -2215,7 +2217,7 @@ void DomainMapper_Impl::GetCurrentLocale(lang::Locale& rLocale)
format to the XPropertySet format to the XPropertySet
-----------------------------------------------------------------------*/ -----------------------------------------------------------------------*/
void DomainMapper_Impl::SetNumberFormat( const OUString& rCommand, void DomainMapper_Impl::SetNumberFormat( const OUString& rCommand,
uno::Reference< beans::XPropertySet >& xPropertySet ) uno::Reference< beans::XPropertySet >& xPropertySet, bool bDetectFormat )
{ {
OUString sFormatString = lcl_ParseFormat( rCommand ); OUString sFormatString = lcl_ParseFormat( rCommand );
// find \h - hijri/luna calendar todo: what about saka/era calendar? // find \h - hijri/luna calendar todo: what about saka/era calendar?
...@@ -2231,8 +2233,18 @@ void DomainMapper_Impl::SetNumberFormat( const OUString& rCommand, ...@@ -2231,8 +2233,18 @@ void DomainMapper_Impl::SetNumberFormat( const OUString& rCommand,
//get the number formatter and convert the string to a format value //get the number formatter and convert the string to a format value
try try
{ {
sal_Int32 nKey = 0;
uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( m_xTextDocument, uno::UNO_QUERY_THROW ); uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( m_xTextDocument, uno::UNO_QUERY_THROW );
sal_Int32 nKey = xNumberSupplier->getNumberFormats()->addNewConverted( sFormat, aUSLocale, aCurrentLocale ); if( bDetectFormat )
{
uno::Reference< util::XNumberFormatter> xFormatter( ::com::sun::star::util::NumberFormatter::create( m_xComponentContext ), uno::UNO_QUERY_THROW );
xFormatter->attachNumberFormatsSupplier( xNumberSupplier );
nKey = xFormatter->detectNumberFormat( 0, rCommand );
}
else
{
nKey = xNumberSupplier->getNumberFormats()->addNewConverted( sFormat, aUSLocale, aCurrentLocale );
}
xPropertySet->setPropertyValue( xPropertySet->setPropertyValue(
PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_NUMBER_FORMAT), PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_NUMBER_FORMAT),
uno::makeAny( nKey )); uno::makeAny( nKey ));
...@@ -2797,8 +2809,11 @@ void DomainMapper_Impl::handleAuthor ...@@ -2797,8 +2809,11 @@ void DomainMapper_Impl::handleAuthor
uno::Reference< beans::XPropertySet >( xFieldInterface, uno::Reference< beans::XPropertySet >( xFieldInterface,
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
if( bIsCustomField ) if( bIsCustomField )
{
xFieldProperties->setPropertyValue( xFieldProperties->setPropertyValue(
rPropNameSupplier.GetName(PROP_NAME), uno::makeAny(rFirstParam)); rPropNameSupplier.GetName(PROP_NAME), uno::makeAny(rFirstParam));
pContext->SetCustomField( xFieldProperties );
}
else else
{ {
if(0 != (aDocProperties[nMap].nFlags & SET_ARABIC)) if(0 != (aDocProperties[nMap].nFlags & SET_ARABIC))
...@@ -4036,7 +4051,12 @@ void DomainMapper_Impl::PopFieldContext() ...@@ -4036,7 +4051,12 @@ void DomainMapper_Impl::PopFieldContext()
CloseFieldCommand(); CloseFieldCommand();
if (!pContext->GetResult().isEmpty()) if (!pContext->GetResult().isEmpty())
SetFieldResult(pContext->GetResult()); {
uno::Reference< beans::XPropertySet > xFieldProperties = pContext->GetCustomField();
if(xFieldProperites.is())
SetNumberFormat( pContext->GetResult(), xFieldProperties, true );
SetFieldResult( pContext->GetResult() );
}
//insert the field, TC or TOC //insert the field, TC or TOC
uno::Reference< text::XTextAppend > xTextAppend; uno::Reference< text::XTextAppend > xTextAppend;
......
...@@ -128,6 +128,7 @@ class FieldContext ...@@ -128,6 +128,7 @@ class FieldContext
::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > m_xFormField; ::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > m_xFormField;
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTOC;//TOX ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTOC;//TOX
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTC;//TOX entry ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTC;//TOX entry
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCustomField;
OUString m_sHyperlinkURL; OUString m_sHyperlinkURL;
FFDataHandler::Pointer_t m_pFFDataHandler; FFDataHandler::Pointer_t m_pFFDataHandler;
FormControlHelper::Pointer_t m_pFormControlHelper; FormControlHelper::Pointer_t m_pFormControlHelper;
...@@ -147,6 +148,8 @@ public: ...@@ -147,6 +148,8 @@ public:
void SetCommandCompleted() { m_bFieldCommandCompleted = true; } void SetCommandCompleted() { m_bFieldCommandCompleted = true; }
bool IsCommandCompleted() const { return m_bFieldCommandCompleted; } bool IsCommandCompleted() const { return m_bFieldCommandCompleted; }
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetCustomField() const { return m_xCustomField; }
void SetCustomField( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xCustomField ) { m_xCustomField = xCustomField; }
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > GetTextField() const { return m_xTextField;} ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > GetTextField() const { return m_xTextField;}
void SetTextField(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > xTextField) { m_xTextField = xTextField;} void SetTextField(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > xTextField) { m_xTextField = xTextField;}
::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > GetFormField() const { return m_xFormField;} ::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > GetFormField() const { return m_xFormField;}
...@@ -401,7 +404,7 @@ private: ...@@ -401,7 +404,7 @@ private:
void GetCurrentLocale(::com::sun::star::lang::Locale& rLocale); void GetCurrentLocale(::com::sun::star::lang::Locale& rLocale);
void SetNumberFormat( const OUString& rCommand, void SetNumberFormat( const OUString& rCommand,
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropertySet ); ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropertySet, bool bDetectFormat = false );
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
FindOrCreateFieldMaster( const sal_Char* pFieldMasterService, FindOrCreateFieldMaster( const sal_Char* pFieldMasterService,
const OUString& rFieldMasterName ) const OUString& rFieldMasterName )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment