[Libreoffice-commits] .: sw/source

Noel Power noelp at kemper.freedesktop.org
Tue Jun 7 02:26:59 PDT 2011


 sw/source/filter/ww8/docxattributeoutput.cxx |    9 +
 sw/source/filter/ww8/ww8par3.cxx             |  174 +++++++++++----------------
 2 files changed, 85 insertions(+), 98 deletions(-)

New commits:
commit 186032185beaa6859193c8946e7d1d0197db55be
Author: Noel Power <noel.power at novell.com>
Date:   Tue Jun 7 10:24:59 2011 +0100

    fix date format export, N is not a recognised format code
    
    patch tweaks the date formating as follows
    
    NNNN -> dddd
    NN   -> ddd

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 85ee6df..a70d5fe 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -756,6 +756,15 @@ void DocxAttributeOutput::CmdField_Impl( FieldInfos& rInfos )
     for ( xub_StrLen i = 0; i < nNbToken; i++ )
     {
         String sToken = rInfos.sCmd.GetToken( i, '\t' );
+        if ( rInfos.eType ==  ww::eCREATEDATE
+          || rInfos.eType ==  ww::eSAVEDATE
+          || rInfos.eType ==  ww::ePRINTDATE
+          || rInfos.eType ==  ww::eDATE
+          || rInfos.eType ==  ww::eTIME )
+        {
+           sToken.SearchAndReplaceAll( String( RTL_CONSTASCII_USTRINGPARAM("NNNN") ), String( RTL_CONSTASCII_USTRINGPARAM("dddd")  ) );
+           sToken.SearchAndReplaceAll( String( RTL_CONSTASCII_USTRINGPARAM("NN") ), String( RTL_CONSTASCII_USTRINGPARAM("ddd")  ) );
+        }
         // Write the Field command
         DoWriteCmd( sToken );
 
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 6b54aaa..03f594a 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -2138,118 +2138,88 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
     SvStream *pDataStream)
 {
     sal_uInt8 nField;
-    sal_uInt8 nHeaderByte;
+    // nHeaderBype == version
+    sal_uInt32 nHeaderByte;
+
+    // The following is a FFData structure as described in
+    // Microsoft's DOC specification (chapter 2.9.78)
 
-    int nType=0;
     *pDataStream >> nHeaderByte;
-    if (nHeaderByte == 0xFF) //Guesswork time, difference between 97 and 95 ?
-    {
-        pDataStream->SeekRel(3);
-        *pDataStream >> nHeaderByte;
-        nType=1;
-    }
-    fUnknown = nHeaderByte & 0x3;
-    fDropdownIndex = (nHeaderByte & 0x7C) >> 2;
-    *pDataStream >> nField;
-    fToolTip = nField & 0x01;
-    fNoMark = (nField & 0x02)>>1;
-    fUseSize = (nField & 0x04)>>2;
-    fNumbersOnly= (nField & 0x08)>>3;
-    fDateOnly = (nField & 0x10)>>4;
-    fUnused = (nField & 0xE0)>>5;
-    *pDataStream >> nSize;
 
-    *pDataStream >> hpsCheckBox;
-    if (nType == 0)
-        pDataStream->SeekRel(2); //Guess
+    // wouldn't it be better to read the bits as a 16 bit word ( like it is in the spec.
+    // certainly easier to follow.
+    sal_uInt8 bits1;
+    *pDataStream >> bits1;
+    sal_uInt8 bits2;
+    *pDataStream >> bits2;
 
-    rtl_TextEncoding eEnc = rRdr.eStructCharSet;
-    sTitle = !nType ? WW8ReadPString(*pDataStream, eEnc, true)
-                    : WW8Read_xstz(*pDataStream, 0, true);
+    sal_uInt8 iType = ( bits1 & 0x3 );
 
-    if (nWhich == WW8_CT_CHECKBOX)
-    {
-        *pDataStream >> nDefaultChecked;
-        nChecked = nDefaultChecked;
+    // we should verify that bits.iType & nWhich concur
+    OSL_ENSURE( iType == nWhich, "something wrong, expect control type read from stream doesn't match nWhich passed in");
+    if ( !( iType == nWhich ) )
+        return; // bail out
 
-        sal_uInt8 iRes = (nHeaderByte >> 2) & 0x1F;
-        switch (iRes)
-        {
-            case 1:  //checked
-                nChecked = true;
-                break;
-            case 25: //undefined, Undefined checkboxes are treated as unchecked
-                     //but it appear that both visually and the value are picked up from the default in that case
-                break;
-            case 0:  //unchecked
-                nChecked = false;
-                break;
-            default:
-                OSL_ENSURE(!this, "unknown option, please report to cmc");
-                break;
-        }
-        if ( nDefaultChecked )
-            sDefault = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("1") );
-        else
-            sDefault = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("0") );
-    }
-    else if (nWhich == WW8_CT_DROPDOWN)
-        *pDataStream >> nChecked;
-    else
-    {
-        sDefault = !nType ? WW8ReadPString(*pDataStream, eEnc, true)
-                          : WW8Read_xstz(*pDataStream, 0, true);
-    }
+    sal_uInt8 iRes = (bits1 & 0x7C) >> 2;
 
-    sFormatting = !nType ? WW8ReadPString(*pDataStream, eEnc, true)
-                         : WW8Read_xstz(*pDataStream, 0, true);
+    sal_uInt16 cch;
+    *pDataStream >> cch;
 
-    sHelp = !nType ? WW8ReadPString(*pDataStream, eEnc, true)
-                   : WW8Read_xstz(*pDataStream, 0, true);
+    sal_uInt16 hps;
+    *pDataStream >> hps;
 
-    if (nWhich == WW8_CT_DROPDOWN)      //is this the case ?
-        fToolTip = true;
+    rtl_TextEncoding eEnc = rRdr.eStructCharSet;
+
+    // xstzName
+    sTitle = WW8Read_xstz(*pDataStream, 0, true);
 
-    if( fToolTip )
+    if (nWhich == WW8_CT_EDIT)
+    {   // Field is a textbox
+        // Default text
+        // xstzTextDef
+        sDefault = WW8Read_xstz(*pDataStream, 0, true);
+    }
+    else
     {
-        sToolTip = !nType ? WW8ReadPString(*pDataStream, eEnc, true)
-                          : WW8Read_xstz(*pDataStream, 0, true);
+        // CheckBox or ComboBox
+        sal_uInt16 wDef = 0;
+        *pDataStream >> wDef;
+        nChecked = wDef; // default
+        if (nWhich == WW8_CT_CHECKBOX)
+        {
+            if ( iRes != 25 )
+                nChecked = iRes;
+            sDefault = ( wDef == 0 ) ? rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("0") ) :  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("1") );
+        }
     }
+    // xstzTextFormat
+    sFormatting = WW8Read_xstz(*pDataStream, 0, true);
+    // xstzHelpText
+    sHelp = WW8Read_xstz(*pDataStream, 0, true);
+    // xstzStatText
+    sToolTip = WW8Read_xstz(*pDataStream, 0, true);
+
+    String sEntryMacro = WW8Read_xstz(*pDataStream, 0, true);
+    String sExitMcr = WW8Read_xstz(*pDataStream, 0, true);
 
     if (nWhich == WW8_CT_DROPDOWN)
     {
         bool bAllOk = true;
-        pDataStream->SeekRel(4 * (nType ? 2 : 1));
-        sal_uInt16 nDummy;
-        *pDataStream >> nDummy;
-        sal_uInt32 nNoStrings;
-        if (!nType)
-        {
-            sal_uInt16 nWord95NoStrings;
-            *pDataStream >> nWord95NoStrings;
-            nNoStrings = nWord95NoStrings;
-            *pDataStream >> nWord95NoStrings;
-            if (nNoStrings != nWord95NoStrings)
-                bAllOk = false;
-            nNoStrings = nWord95NoStrings;
-            sal_uInt16 nDummy2;
-            *pDataStream >> nDummy2;
-            if (nDummy2 != 0)
-                bAllOk = false;
-            *pDataStream >> nDummy2;
-            if (nDummy2 != 0xA)
-                bAllOk = false;
-            if (!bAllOk)    //Not as expected, don't risk it at all.
-                nNoStrings = 0;
-            for (sal_uInt16 nI = 0; nI < nNoStrings; ++nI)
-                pDataStream->SeekRel(2);
-        }
-        else
-        {
-            if (nDummy != 0xFFFF)
-                bAllOk = false;
-            *pDataStream >> nNoStrings;
-        }
+        // SSTB (see Spec. 2.2.4)
+        sal_uInt16 fExtend;
+        *pDataStream >> fExtend;
+        sal_uInt16 nNoStrings;
+
+        // Isn't it that if fExtend isn't 0xFFFF then fExtend actually
+        // doesn't exist and we really have just read nNoStrings ( or cData )?
+        if (fExtend != 0xFFFF)
+            bAllOk = false;
+        *pDataStream >> nNoStrings;
+
+        // I guess this should be zero ( and we should ensure that )
+        sal_uInt16 cbExtra;
+        *pDataStream >> cbExtra;
+
         OSL_ENSURE(bAllOk,
             "Unknown formfield dropdown list structure. Report to cmc");
         if (!bAllOk)    //Not as expected, don't risk it at all.
@@ -2257,11 +2227,19 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
         maListEntries.reserve(nNoStrings);
         for (sal_uInt32 nI = 0; nI < nNoStrings; ++nI)
         {
-            String sEntry = !nType ? WW8ReadPString(*pDataStream, eEnc, false)
-                           : WW8Read_xstz(*pDataStream, 0, false);
+            String sEntry =  WW8Read_xstz(*pDataStream, 0, false);
             maListEntries.push_back(sEntry);
         }
     }
+    fDropdownIndex = iRes;
+
+    nField = bits2;
+    fToolTip = nField & 0x01;
+    fNoMark = (nField & 0x02)>>1;
+    fUseSize = (nField & 0x04)>>2;
+    fNumbersOnly= (nField & 0x08)>>3;
+    fDateOnly = (nField & 0x10)>>4;
+    fUnused = (nField & 0xE0)>>5;
 }
 
 WW8FormulaListBox::WW8FormulaListBox(SwWW8ImplReader &rR)


More information about the Libreoffice-commits mailing list