Proposal/Prototype support for "fill in character" in Calc Number Format Strings

Johann Messner johann.messner at jku.at
Fri Jul 27 10:18:50 PDT 2012


hello Noel,

Am Do, 26.Jul.12, KW30 (13:06:22 Uhr) schrieb Noel Power <nopower at suse.com>:
> Hi Johann,
....
> Also if you wish you could help with is the patch for enabling 
> persisting to odf needs updating to use "<number:fill-character>" 
> instead of "number:repeated", of course any other general testing. bug 
> reporting & patches in this area wildly appreciated also. Are you 
> interested or have any time for any of that?
> 
> Noel

... and yes, I am willing to help with these tasks. Since
I am a complete "freshman" it will take definitely some time
for me to come up with "acceptable" contributions.

Nevertheless I will try to insert/apply your pertinent
patches to the source tree I used (on my ubuntu 12.04 box) for the
"quick & dirty hack". Thereafter I will play with it ... and come 
back to you in about 2 or 3 weeks and let you know about my
mileage - hope that's okay.

Keep up the good work!

regards,
hans


> >From 8a2f12168cb450de589853285871874231ec130f Mon Sep 17 00:00:00 2001
> From: Noel Power <noel.power at novell.com>
> Date: Tue, 17 Apr 2012 20:37:02 +0100
> Subject: [PATCH 2/3] support new xml number:repeated elem for number-style namespace
> 
> this is used to define the char to be repeated in a number format
> 
> e.g  repeat ' ' 0 or more times to fill available space
> 
>       <number:number-style style:name="N130P0" style:volatile="true">
>         <number:text> $</number:text>
> -->     <number:repeated> </number:repeated>
> ---
>  xmloff/inc/xmloff/xmlnumfe.hxx   |    1 +
>  xmloff/source/style/xmlnumfe.cxx |   12 ++++++++++++
>  xmloff/source/style/xmlnumfi.cxx |   10 ++++++++++
>  3 files changed, 23 insertions(+), 0 deletions(-)
> 
> diff --git a/xmloff/inc/xmloff/xmlnumfe.hxx b/xmloff/inc/xmloff/xmlnumfe.hxx
> index b1f00e7..9998cad 100644
> --- a/xmloff/inc/xmloff/xmlnumfe.hxx
> +++ b/xmloff/inc/xmloff/xmlnumfe.hxx
> @@ -95,6 +95,7 @@ private:
>      SAL_DLLPRIVATE void WriteMapElement_Impl( sal_Int32 nOp, double fLimit,
>                                      sal_Int32 nKey, sal_Int32 nPart );
>  
> +    SAL_DLLPRIVATE void  WriteRepeatedElement_Impl( sal_Unicode ch );
>      SAL_DLLPRIVATE sal_Bool WriteTextWithCurrency_Impl( const ::rtl::OUString& rString,
>                              const ::com::sun::star::lang::Locale& rLocale );
>      SAL_DLLPRIVATE void ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt32 nKey,
> diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
> index 714dcda..71aa5ef 100644
> --- a/xmloff/source/style/xmlnumfe.cxx
> +++ b/xmloff/source/style/xmlnumfe.cxx
> @@ -537,6 +537,14 @@ void SvXMLNumFmtExport::WriteMinutesElement_Impl( sal_Bool bLong )
>                                sal_True, sal_False );
>  }
>  
> +void SvXMLNumFmtExport::WriteRepeatedElement_Impl( sal_Unicode nChar )
> +{
> +    FinishTextElement_Impl();
> +    SvXMLElementExport aElem( rExport, XML_NAMESPACE_NUMBER, XML_REPEATED,
> +                                  sal_True, sal_False );
> +    rExport.Characters( OUString::valueOf( nChar ) );
> +}
> +
>  void SvXMLNumFmtExport::WriteSecondsElement_Impl( sal_Bool bLong, sal_uInt16 nDecimals )
>  {
>      FinishTextElement_Impl();
> @@ -1567,6 +1575,10 @@ void SvXMLNumFmtExport::ExportPart_Impl( const SvNumberformat& rFormat, sal_uInt
>                      WriteAMPMElement_Impl();        // short/long?
>                      bAnyContent = sal_True;
>                      break;
> +                case NF_SYMBOLTYPE_STAR :
> +                    if ( pElemStr && pElemStr->Len() > 1 )
> +                        WriteRepeatedElement_Impl( pElemStr->GetChar( 1 ) );
> +                    break;
>              }
>              nPrevType = nElemType;
>              ++nPos;
> diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
> index bd953a3..ecd33b9 100644
> --- a/xmloff/source/style/xmlnumfi.cxx
> +++ b/xmloff/source/style/xmlnumfi.cxx
> @@ -246,6 +246,7 @@ public:
>  enum SvXMLStyleTokens
>  {
>      XML_TOK_STYLE_TEXT,
> +    XML_TOK_STYLE_REPEATED,
>      XML_TOK_STYLE_NUMBER,
>      XML_TOK_STYLE_SCIENTIFIC_NUMBER,
>      XML_TOK_STYLE_FRACTION,
> @@ -521,6 +522,7 @@ const SvXMLTokenMap& SvXMLNumImpData::GetStyleElemTokenMap()
>          {
>              //  elements in a style
>              { XML_NAMESPACE_NUMBER, XML_TEXT,               XML_TOK_STYLE_TEXT              },
> +            { XML_NAMESPACE_NUMBER, XML_REPEATED,           XML_TOK_STYLE_REPEATED   },
>              { XML_NAMESPACE_NUMBER, XML_NUMBER,             XML_TOK_STYLE_NUMBER            },
>              { XML_NAMESPACE_NUMBER, XML_SCIENTIFIC_NUMBER,  XML_TOK_STYLE_SCIENTIFIC_NUMBER },
>              { XML_NAMESPACE_NUMBER, XML_FRACTION,           XML_TOK_STYLE_FRACTION          },
> @@ -1104,6 +1106,13 @@ void SvXMLNumFmtElementContext::EndElement()
>          case XML_TOK_STYLE_TEXT_CONTENT:
>              rParent.AddToCode( OUString::valueOf((sal_Unicode)'@') );
>              break;
> +        case XML_TOK_STYLE_REPEATED:
> +            if ( aContent.getLength() )
> +            {
> +                rParent.AddToCode( OUString::valueOf((sal_Unicode)'*') );
> +                rParent.AddToCode( OUString::valueOf( aContent[0] ) );
> +            }
> +            break;
>          case XML_TOK_STYLE_BOOLEAN:
>              // ignored - only default boolean format is supported
>              break;
> @@ -1436,6 +1445,7 @@ SvXMLImportContext* SvXMLNumFormatContext::CreateChildContext(
>      switch (nToken)
>      {
>          case XML_TOK_STYLE_TEXT:
> +        case XML_TOK_STYLE_REPEATED:
>          case XML_TOK_STYLE_NUMBER:
>          case XML_TOK_STYLE_SCIENTIFIC_NUMBER:
>          case XML_TOK_STYLE_FRACTION:
> -- 
> 1.7.3.4
> 



More information about the LibreOffice mailing list