diff options
author | Noel Power <noel.power@novell.com> | 2011-01-10 15:23:27 +0000 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2011-01-21 12:41:13 +0000 |
commit | 8b28483538dc426475d651687b5505cf94149d22 (patch) | |
tree | 9c27e82418dcd6b5847f4de74cbafc4639f622f3 | |
parent | 866e4b44f7d5ea75ba31ad78b6c8b58067627788 (diff) |
bnc#660816 improve formfield checkbox binary export ( and import )
-rw-r--r-- | sw/source/core/crsr/bookmrk.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 37 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par3.cxx | 2 |
3 files changed, 31 insertions, 16 deletions
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 46576e0461..0641e96d27 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 ffb8427585..f8b34bb317 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 2cbe21529f..ce066fc5bb 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; |