[Libreoffice-commits] .: Branch 'libreoffice-3-3' - sw/source

Noel Power noelp at kemper.freedesktop.org
Fri Jan 21 05:53:49 PST 2011


 sw/source/core/crsr/bookmrk.cxx  |    8 ++++++++
 sw/source/filter/ww8/wrtww8.cxx  |   37 +++++++++++++++++++++----------------
 sw/source/filter/ww8/ww8par3.cxx |    2 ++
 3 files changed, 31 insertions(+), 16 deletions(-)

New commits:
commit 8b28483538dc426475d651687b5505cf94149d22
Author: Noel Power <noel.power at novell.com>
Date:   Mon Jan 10 15:23:27 2011 +0000

    bnc#660816 improve formfield checkbox binary export ( and import )

diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 46576e0..0641e96 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -336,6 +336,14 @@ namespace sw { namespace mark
     void CheckboxFieldmark::SetChecked(bool checked)
     {
         (*GetParameters())[::rtl::OUString::createFromAscii(ODF_FORMCHECKBOX_RESULT)] = makeAny(checked);
+        bool bOld( IsChecked() );
+        if ( bOld != checked )
+        {
+            // mark document as modified
+            SwDoc *const pDoc( GetMarkPos().GetDoc() );
+            if ( pDoc )
+                pDoc->SetModified();
+        }
     }
 
     bool CheckboxFieldmark::IsChecked() const
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index ffb8427..f8b34bb 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3554,13 +3554,19 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
 
     pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aArr1 ), aArr1 );
 
-    sal_uInt8 aFldHeader[] =
+    struct FFDataHeader
     {
-        0xFF, 0xFF, 0xFF, 0xFF, // Unicode Marker...
-        0, 0, 0, 0,// 0, 0, 0, 0
+        sal_uInt32 version;
+        sal_uInt16 bits;
+        sal_uInt16 cch;
+        sal_uInt16 hps;
+        FFDataHeader() : version( 0xFFFFFFFF ), bits(0), cch(0), hps(0) {}
     };
 
-    aFldHeader[4] |= (type & 0x03);
+
+    FFDataHeader aFldHeader;
+    aFldHeader.bits |= (type & 0x03);
+
     sal_Int32 ffres = 0; // rFieldmark.GetFFRes();
     if ( pAsCheckbox && pAsCheckbox->IsChecked() )
         ffres = 1;
@@ -3572,12 +3578,12 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
         else
             ffres = 0;
     }
-    aFldHeader[4] |= ( (ffres<<2) & 0x7C );
+    aFldHeader.bits |= ( (ffres<<2) & 0x7C );
 
     std::vector< ::rtl::OUString > aListItems;
     if (type==2)
     {
-        aFldHeader[5] |= 0x80; // ffhaslistbox
+        aFldHeader.bits |= 0x8000; // ffhaslistbox
         const ::sw::mark::IFieldmark::parameter_map_t* const pParameters = rFieldmark.GetParameters();
         ::sw::mark::IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find(::rtl::OUString::createFromAscii(ODF_FORMDROPDOWN_LISTENTRY));
         if(pListEntries != pParameters->end())
@@ -3607,7 +3613,7 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
     };
    sal_uInt32 slen = sizeof(sal_uInt32)      
         + sizeof(aFldData)
-        + sizeof( aFldHeader )
+        + sizeof( aFldHeader.version ) + sizeof( aFldHeader.bits ) + sizeof( aFldHeader.cch ) + sizeof( aFldHeader.hps )
         + 2*ffname.getLength() + 4
         + 2*ffdeftext.getLength() + 4
         + 2*ffformat.getLength() + 4
@@ -3615,8 +3621,10 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
         + 2*ffstattext.getLength() + 4
         + 2*ffentrymcr.getLength() + 4
         + 2*ffexitmcr.getLength() + 4;
+    if ( type )
+        slen += 2; // wDef
     if ( type==2 ) {
-        slen += 2; // for 0xFF, 0xFF
+        slen += 2; // sttb ( fExtend )
         slen += 4; // for num of list items
         const int items = aListItems.size();
         for( int i = 0; i < items; i++ ) {
@@ -3631,17 +3639,14 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
     OSL_ENSURE( len == 0x44-sizeof(sal_uInt32), "SwWW8Writer::WriteFormData(..) - wrong aFldData length" );
     pDataStrm->Write( aFldData, len );
 
-    len = sizeof( aFldHeader );
-    OSL_ENSURE( len == 8, "SwWW8Writer::WriteFormData(..) - wrong aFldHeader length" );
-
-    pDataStrm->Write( aFldHeader, len );
+    *pDataStrm << aFldHeader.version << aFldHeader.bits << aFldHeader.cch << aFldHeader.hps;
 
     SwWW8Writer::WriteString_xstz( *pDataStrm, ffname, true ); // Form field name
 
-    if ( type == 0 )
-        SwWW8Writer::WriteString_xstz( *pDataStrm, ffdeftext, true );
-    else
-        pDataStrm->WriteNumber( (sal_uInt16)0 );
+    SwWW8Writer::WriteString_xstz( *pDataStrm, ffdeftext, true );
+    if ( type )
+        *pDataStrm << sal_uInt16(0);
+
 
     SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffformat ), true );
     SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffhelptext ), true );
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 2cbe215..ce066fc 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -2222,6 +2222,8 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
                 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;


More information about the Libreoffice-commits mailing list