INTEGRATION: CWS hb10 (1.103.102); FILE MERGED

2008/08/29 14:25:45 hbrinkm 1.103.102.4: RESYNC: (1.103-1.104); FILE MERGED
2008/08/29 13:39:05 hbrinkm 1.103.102.3: #158227# OOo needs checkbox height to be set for import
2008/07/23 11:47:45 hbrinkm 1.103.102.2: #158227# resolve warnings
2008/07/23 08:14:19 hbrinkm 1.103.102.1: #158227#: use WW8FFData to write form field data
This commit is contained in:
Rüdiger Timm 2008-09-04 08:34:23 +00:00
parent 85a333e07a
commit ed731aa599

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: wrtw8esh.cxx,v $
* $Revision: 1.104 $
* $Revision: 1.105 $
*
* This file is part of OpenOffice.org.
*
@ -109,6 +109,7 @@
// --> OD 2007-07-24 #148096#
#include <ndtxt.hxx>
// <--
#include "WW8FFData.hxx"
using namespace com::sun::star;
using namespace sw::util;
@ -200,7 +201,7 @@ void SwWW8Writer::DoComboBox(const rtl::OUString &rName,
if (!bWrtWW8)
return;
OutField(0, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN),
WRITEFIELD_START | WRITEFIELD_CMD_START);
WRITEFIELD_START | WRITEFIELD_CMD_START);
// write the refence to the "picture" structure
ULONG nDataStt = pDataStrm->Tell();
pChpPlc->AppendFkpEntry( Strm().Tell() );
@ -220,148 +221,26 @@ void SwWW8Writer::DoComboBox(const rtl::OUString &rName,
pChpPlc->AppendFkpEntry(Strm().Tell(), sizeof(aArr1), aArr1);
OutField(0, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN),
WRITEFIELD_CLOSE);
WRITEFIELD_CLOSE);
static const sal_uInt8 aComboData1[] =
::sw::WW8FFData * pFFData = new ::sw::WW8FFData();
pFFData->setType(2);
pFFData->setName(rName);
pFFData->setHelp(rHelp);
pFFData->setStatus(rToolTip);
sal_uInt32 nListItems = rListItems.getLength();
for (sal_uInt32 i = 0; i < nListItems; i++)
{
0,0,0,0, // len of struct
0x44,0, // the start of "next" data
0,0,0,0,0,0,0,0,0,0, // PIC-Structure!
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0, // /
};
pDataStrm->Write( aComboData1, sizeof(aComboData1) );
static const sal_uInt8 aComboData2[] =
{
0xFF, 0xFF, 0xFF, 0xFF
};
pDataStrm->Write( aComboData2, sizeof(aComboData2) );
sal_uInt8 nHeaderByte = 0xe2;
sal_uInt32 nNoStrings = rListItems.getLength();
if (nNoStrings)
{
bool bSelectedDone = false;
sal_uInt32 i;
for ( i = 0; i < nNoStrings; ++i)
{
if (rSelected == rListItems[i])
{
bSelectedDone = true;
i++;
break;
}
}
if (bSelectedDone && i <= 0x3F) //only 6 bit available for selected item
{
nHeaderByte |= (i << 2);
}
if (i < 0x20 && rSelected == rListItems[i])
pFFData->setResult(::sal::static_int_cast<sal_uInt8>(i));
pFFData->addListboxEntry(rListItems[i]);
}
*pDataStrm << nHeaderByte;
pFFData->Write(pDataStrm);
sal_uInt8 aComboData9[] =
{
0x80, 0x00, 0x00, 0x00, 0x00
};
if (rToolTip.getLength() > 0)
aComboData9[0] |= 1;
pDataStrm->Write( aComboData9, sizeof(aComboData9) );
sal_uInt16 nLen = msword_cast<sal_uInt16>(rName.getLength());
*pDataStrm << nLen;
WriteString16(*pDataStrm, rName, true);
static const sal_uInt8 aComboData3[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
pDataStrm->Write( aComboData3, sizeof(aComboData3) );
nLen = msword_cast<sal_uInt16>(rHelp.getLength());
*pDataStrm << nLen;
WriteString16(*pDataStrm, rHelp, true);
nLen = msword_cast<sal_uInt16>(rToolTip.getLength());
if (nLen > 0)
{
*pDataStrm << nLen;
WriteString16(*pDataStrm, rToolTip, true);
}
static const sal_uInt8 aComboData4[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff
};
pDataStrm->Write( aComboData4, sizeof(aComboData4) );
*pDataStrm << nNoStrings;
if (!nNoStrings)
*pDataStrm << sal_uInt16(0);
else
{
for (sal_uInt32 i = 0; i < nNoStrings; ++i)
{
const rtl::OUString &rItem = rListItems[i];
sal_uInt16 nStrLen = msword_cast<sal_uInt16>(rItem.getLength());
*pDataStrm << nStrLen;
WriteString16(*pDataStrm, rItem, false);
}
}
SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
pDataStrm->Tell() - nDataStt );
}
static bool lcl_HasPropertyNonEmpty
(uno::Reference<beans::XPropertySet> xPropSet,
const rtl::OUString & sPropName)
{
bool bResult = false;
uno::Reference<beans::XPropertySetInfo> xPropSetInfo =
xPropSet->getPropertySetInfo();
if (xPropSetInfo->hasPropertyByName(sPropName))
{
uno::Any aTmp(xPropSet->getPropertyValue(sPropName));
const rtl::OUString * pStr = (const rtl::OUString *)aTmp.getValue();
if (pStr && pStr->getLength() > 0)
bResult = true;
}
return bResult;
}
static void lcl_WW8WriteProperty(uno::Reference<beans::XPropertySet> xPropSet,
SvStream * pDataStrm,
const rtl::OUString & sPropName)
{
uno::Reference<beans::XPropertySetInfo> xPropSetInfo =
xPropSet->getPropertySetInfo();
const rtl::OUString * pStr = NULL;
uno::Any aTmp;
if (xPropSetInfo->hasPropertyByName(sPropName))
{
aTmp = xPropSet->getPropertyValue(sPropName);
pStr = (const rtl::OUString *)aTmp.getValue();
}
sal_uInt16 nLen = pStr ? msword_cast<sal_uInt16>(pStr->getLength()) : 0;
*pDataStrm << nLen;
if (pStr)
SwWW8Writer::WriteString16(*pDataStrm, String(*pStr), true);
else
SwWW8Writer::WriteString16(*pDataStrm, aEmptyStr, true);
}
void SwWW8Writer::DoCheckBox(uno::Reference<beans::XPropertySet> xPropSet)
@ -389,23 +268,10 @@ void SwWW8Writer::DoCheckBox(uno::Reference<beans::XPropertySet> xPropSet)
pChpPlc->AppendFkpEntry(Strm().Tell(),
sizeof( aArr1 ), aArr1 );
static const sal_uInt8 aComboData1[] =
{
0,0,0,0, // len of struct
0x44,0, // the start of "next" data
0,0,0,0,0,0,0,0,0,0, // PIC-Structure!
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0, // /
};
pDataStrm->Write( aComboData1, sizeof(aComboData1) );
::sw::WW8FFData * pFFData = new ::sw::WW8FFData();
static const sal_uInt8 aComboData2[] =
{
0xFF, 0xFF, 0xFF, 0xFF
};
pDataStrm->Write( aComboData2, sizeof(aComboData2) );
pFFData->setType(1);
pFFData->setCheckboxHeight(0x14);
sal_Int16 nTemp = 0;
xPropSet->getPropertyValue(C2U("DefaultState")) >>= nTemp;
@ -413,57 +279,44 @@ void SwWW8Writer::DoCheckBox(uno::Reference<beans::XPropertySet> xPropSet)
xPropSet->getPropertyValue(C2U("State")) >>= nTemp;
sal_uInt32 nIsChecked(nTemp);
sal_uInt8 nHeaderByte = 0xe5;
if (nIsDefaultChecked != nIsChecked)
{
switch (nIsChecked)
{
case false:
nHeaderByte = 0x1;
pFFData->setResult(0);
break;
case true:
nHeaderByte = 0x5;
pFFData->setResult(1);
break;
default:
ASSERT(!this, "how did that happen");
}
}
*pDataStrm << nHeaderByte;
sal_uInt8 aComboData5[] =
::rtl::OUString aStr;
static ::rtl::OUString sName(C2U("Name"));
if (xPropSetInfo->hasPropertyByName(sName))
{
0x04, 0x00, 0x00, 0x14, 0x00
};
xPropSet->getPropertyValue(sName) >>= aStr;
pFFData->setName(aStr);
}
const rtl::OUString sHelpText(C2U("HelpText"));
if (lcl_HasPropertyNonEmpty(xPropSet, sHelpText))
aComboData5[0] |= 0x1;
pDataStrm->Write( aComboData5, sizeof(aComboData5) );
lcl_WW8WriteProperty(xPropSet, pDataStrm, C2U("Name"));
*pDataStrm << nIsDefaultChecked;
static const sal_uInt8 aComboData3[] =
static ::rtl::OUString sHelpText(C2U("HelpText"));
if (xPropSetInfo->hasPropertyByName(sHelpText))
{
0x00, 0x00
};
pDataStrm->Write( aComboData3, sizeof(aComboData3) );
lcl_WW8WriteProperty(xPropSet, pDataStrm, C2U("HelpF1Text"));
lcl_WW8WriteProperty(xPropSet, pDataStrm, sHelpText);
static const sal_uInt8 aComboData4[] =
xPropSet->getPropertyValue(sHelpText) >>= aStr;
pFFData->setHelp(aStr);
}
static ::rtl::OUString sHelpF1Text(C2U("HelpF1Text"));
if (xPropSetInfo->hasPropertyByName(sHelpF1Text))
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
xPropSet->getPropertyValue(sHelpF1Text) >>= aStr;
pFFData->setStatus(aStr);
}
pDataStrm->Write( aComboData4, sizeof(aComboData4) );
SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
pDataStrm->Tell() - nDataStt );
pFFData->Write(pDataStrm);
OutField(0, ww::eFORMCHECKBOX, aEmptyStr, WRITEFIELD_CLOSE);
}
@ -490,64 +343,13 @@ void SwWW8Writer::DoFormText(const SwInputField * pFld)
pChpPlc->AppendFkpEntry(Strm().Tell(),
sizeof( aArr1 ), aArr1 );
static const sal_uInt8 aComboData1[] =
{
0,0,0,0, // len of struct
0x44,0, // the start of "next" data
0,0,0,0,0,0,0,0,0,0, // PIC-Structure!
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // |
0,0,0,0 // /
};
pDataStrm->Write( aComboData1, sizeof(aComboData1) );
::sw::WW8FFData * pFFData = new ::sw::WW8FFData();
sal_uInt8 aComboData2[] =
{
0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0
};
if (pFld->GetToolTip().Len() > 0)
aComboData2[5] |= 0x1;
pDataStrm->Write( aComboData2, sizeof(aComboData2) );
rtl::OUString aStr = pFld->GetPar2();
sal_uInt16 nLen = msword_cast<sal_uInt16>(aStr.getLength());
*pDataStrm << nLen;
WriteString16(*pDataStrm, aStr, true);
aStr = rtl::OUString();//aEmptyStr; //pFld->GetPar1();
nLen = msword_cast<sal_uInt16>(aStr.getLength());
*pDataStrm << nLen;
WriteString16(*pDataStrm, aStr, true);
aStr = pFld->GetHelp();
nLen = msword_cast<sal_uInt16>(aStr.getLength());
*pDataStrm << nLen;
WriteString16(*pDataStrm, aStr, true);
nLen = 0;
*pDataStrm << nLen;
WriteString16(*pDataStrm, aEmptyStr, true);
aStr = pFld->GetToolTip();
if (aStr.getLength() > 0)
{
nLen = msword_cast<sal_uInt16>(aStr.getLength());
*pDataStrm << nLen;
WriteString16(*pDataStrm, aStr, true);
}
static sal_uInt8 aComboData3[] =
{
0, 0, 0, 0, 0, 0, 0, 0
};
pDataStrm->Write( aComboData3, sizeof(aComboData3) );
SwWW8Writer::WriteLong( *pDataStrm, nDataStt,
pDataStrm->Tell() - nDataStt );
pFFData->setType(0);
pFFData->setName(pFld->GetPar2());
pFFData->setHelp(pFld->GetHelp());
pFFData->setStatus(pFld->GetToolTip());
pFFData->Write(pDataStrm);
OutField(0, ww::eFORMTEXT, aEmptyStr, WRITEFIELD_CMD_END);