summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2011-08-24 19:45:40 +0100
committerNoel Power <noel.power@novell.com>2011-08-24 19:47:13 +0100
commitcecb746a3d8132998711c429163874d39ff5b2ff (patch)
treee76e89d6defe1396864b4ae56b271509d17f968e
parent67b79b6ada570f83fb1f8fc5aaeddd91d8517c19 (diff)
kill old vba and ole control filter(s) for import at least
-rw-r--r--filter/inc/filter/msfilter/msocximex.hxx342
-rw-r--r--filter/inc/filter/msfilter/svxmsbas.hxx13
-rw-r--r--filter/source/msfilter/makefile.mk1
-rw-r--r--filter/source/msfilter/msocximex.cxx3603
-rw-r--r--filter/source/msfilter/msvbasic.cxx1461
-rw-r--r--filter/source/msfilter/msvbasic.hxx127
-rw-r--r--filter/source/msfilter/svxmsbas.cxx479
-rw-r--r--sw/source/filter/ww8/ww8par.hxx15
8 files changed, 11 insertions, 6030 deletions
diff --git a/filter/inc/filter/msfilter/msocximex.hxx b/filter/inc/filter/msfilter/msocximex.hxx
index 31b3732dbfdd..98c2f676ac6b 100644
--- a/filter/inc/filter/msfilter/msocximex.hxx
+++ b/filter/inc/filter/msfilter/msocximex.hxx
@@ -76,19 +76,6 @@ class OCX_Control;
class SfxObjectShell;
class SwPaM;
-class TypeName
-{
-public:
- String msName;
- sal_uInt16 mnType;
- sal_Int32 mnLeft;
- sal_Int32 mnTop;
- sal_Int32 mnStoreId;
- TypeName(sal_Char *pName, sal_uInt32 nStoreId, sal_uInt32 nLen, sal_uInt16 nType,
- sal_Int32 nLeft, sal_Int32 nTop);
-};
-
-
class MSFILTER_DLLPUBLIC SvxMSConvertOCXControls
{
public:
@@ -178,9 +165,6 @@ public:
if (pFontName)
delete [] pFontName;
}
- sal_Bool Read(SotStorageStream *pS);
- void Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet > &rPropSet);
sal_Bool Export(SotStorageStreamRef &rContent,
const com::sun::star::uno::Reference<
@@ -213,7 +197,6 @@ public:
protected:
static sal_uInt16 nStandardId;
sal_uInt8 ExportAlign(sal_Int16 nAlign) const;
- sal_Int16 ImportAlign(sal_uInt8 nJustification) const;
private:
sal_Bool bHasAlign;
sal_Bool bHasFont;
@@ -225,23 +208,6 @@ public:
OCX_Control(UniString sN, OCX_Control* parent = NULL ) : nWidth( 0 ), nHeight( 0 ), mnLeft(0), mnTop(0),
mnStep(0), mnBackColor(0x8000000FL), mnForeColor(0), mnTabPos(0), mbVisible(true), sName(sN), pDocSh(0),
bSetInDialog(sal_False), mpParent( parent ) {}
- sal_Bool FullRead(SotStorageStream *pS)
- {
- return Read(pS) && ReadFontData(pS);
- };
- virtual sal_Bool Read(SotStorageStream *pS);
- virtual sal_Bool ReadFontData(SotStorageStream *pS);
- virtual sal_Bool Import(const com::sun::star::uno::Reference<
- com::sun::star::lang::XMultiServiceFactory > &rServiceFactory,
- com::sun::star::uno::Reference<
- com::sun::star::form::XFormComponent > &rFComp,
- com::sun::star::awt::Size &rSz);
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::container::XNameContainer>
- &rDialog);
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet>& /*rPropSet*/)
- {return sal_False;}
//Export exports a control as an OLE style storage stream tree
virtual sal_Bool Export(SotStorageRef& /*rObj*/,
const com::sun::star::uno::Reference<
@@ -257,17 +223,6 @@ public:
void SetInDialog(bool bState) { bSetInDialog = bState; }
bool GetInDialog() { return bSetInDialog; }
- sal_Bool ReadAndImport(SotStorageStream *pS,
- com::sun::star::uno::Reference<
- com::sun::star::lang::XMultiServiceFactory > &rSF,
- com::sun::star::uno::Reference<
- com::sun::star::form::XFormComponent > &rFComp,
- com::sun::star::awt::Size &rSz)
- {
- if (Read(pS))
- return Import(rSF,rFComp,rSz);
- return sal_False;
- }
virtual ~OCX_Control() {}
static void FillSystemColors();
@@ -292,14 +247,10 @@ public:
com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicObject> mxGrfObj;
protected:
- sal_uInt32 ImportColor(sal_uInt32 nColorCode) const;
sal_uInt32 ExportColor(sal_uInt32 nColorCode) const;
sal_uInt32 SwapColor(sal_uInt32 nColorCode) const;
- sal_Int16 ImportBorder(sal_uInt16 nSpecialEffect,sal_uInt16 nBorderStyle)
- const;
sal_uInt8 ExportBorder(sal_uInt16 nBorder,sal_uInt8 &rBorderStyle) const;
bool bSetInDialog;
- sal_Int16 ImportSpecEffect( sal_uInt8 nSpecialEffect ) const;
sal_uInt8 ExportSpecEffect( sal_Int16 nApiEffect ) const;
static sal_uInt16 nStandardId;
static sal_uInt8 const aObjInfo[4];
@@ -333,8 +284,6 @@ public:
if (pGroupName) delete[] pGroupName;
if (pIcon) delete[] pIcon;
}
- sal_Bool Read(SotStorageStream *pS);
-
/*sal_uInt8 for sal_uInt8 Word Struct*/
sal_uInt16 nIdentifier;
@@ -415,22 +364,6 @@ public:
};
-class OCX_TabStrip : public OCX_Control
-{
-public:
- OCX_TabStrip() : OCX_Control( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TabStrip" ))), nIdentifier(0), nFixedAreaLen(0), nNumTabs(0), bHasTabs(true) {}
-
- virtual sal_Bool ReadFontData(SotStorageStream *pS);
- virtual sal_Bool Read(SotStorageStream *pS);
-
- std::vector< rtl::OUString > msItems;
- sal_uInt16 nIdentifier;
- sal_uInt16 nFixedAreaLen;
- sal_uInt8 pBlockFlags[4];
- sal_Int32 nNumTabs;
- bool bHasTabs;
-};
-
class OCX_Image : public OCX_Control
{
public:
@@ -462,11 +395,6 @@ public:
sal_uInt8 nSpecialEffect;
bool bAutoSize;
- sal_Bool Read(SotStorageStream *pS);
-
- using OCX_Control::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet>& rPropSet);
sal_Bool Export(SotStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -475,215 +403,11 @@ public:
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
const com::sun::star::awt::Size& rSize);
- // No Font record
- virtual sal_Bool ReadFontData(SvStorageStream* /*pS*/) { return sal_True; }
static OCX_Control *Create() { return new OCX_Image;}
};
-struct ContainerRecord
-{
- ContainerRecord():nTop(0), nLeft(0), nSubStorageId(0), nSubStreamLen(0), nTabPos(0), nTypeIdent(0), bVisible( true ), bTabStop( true ) {}
- ::rtl::OUString cName;
- ::rtl::OUString controlTip;
- ::rtl::OUString sCtrlSource;
- ::rtl::OUString sRowSource;
-
- sal_uInt32 nTop;
- sal_uInt32 nLeft;
- sal_uInt32 nSubStorageId;
- sal_uInt32 nSubStreamLen;
- sal_uInt16 nTabPos;
- sal_uInt16 nTypeIdent;
- bool bVisible;
- bool bTabStop;
-};
-
-typedef std::vector<OCX_Control*>::iterator CtrlIterator;
-typedef std::vector<OCX_Control*>::const_iterator CtrlIteratorConst;
-typedef std::vector<OCX_Control*> CtrlList;
-
class OCX_OptionButton;
-class OCX_ParentControl : public OCX_Control
-{
-public:
- virtual sal_Bool Read(SvStorageStream *pS);
- virtual sal_Bool ReadFontData(SvStorageStream* /*pS*/) { return sal_True; }
-
- using OCX_Control::Import; // to not hide the other two import methods
-
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
-
- SotStorageStreamRef getContainerStream() { return mContainerStream; }
-
- SotStorageStreamRef getOStream() { return mContainedControlsStream; }
- virtual void ProcessControl( OCX_Control* pControl, SvStorageStream* pS, ContainerRecord& rec );
- bool createFromContainerRecord( const ContainerRecord& record,
- OCX_Control*& );
- SotStorageStreamRef getContainedControlsStream(){ return mContainedControlsStream; }
-protected:
- OCX_ParentControl( SotStorageRef& parent,
- const ::rtl::OUString& storageName,
- const ::rtl::OUString& sN,
- const com::sun::star::uno::Reference<
- com::sun::star::container::XNameContainer > &rDialog,
- OCX_Control* pParent = NULL );
- ~OCX_ParentControl();
-
- com::sun::star::uno::Reference<
- com::sun::star::container::XNameContainer > mxParent;
- std::vector<OCX_Control*> mpControls;
- boost::unordered_map<sal_uInt16, sal_uInt16> mActiveXIDMap;
- SotStorageRef mContainerStorage;
- SotStorageStreamRef mContainerStream;
- SotStorageStreamRef mContainedControlsStream;
- sal_uInt16 nIdentifier;
- sal_uInt16 nFixedAreaLen;
- sal_uInt8 pBlockFlags[4];
-
- sal_uInt32 nChildrenA;
- sal_uInt32 nNextAvailableID;
- sal_uInt32 nBooleanProperties;
- sal_uInt32 nGroupCnt;
- sal_uInt32 nZoom;
-
- sal_uInt8 fUnknown1:1;
- sal_uInt8 fEnabled:1;
- sal_uInt8 fLocked:1;
- sal_uInt8 fBackStyle:1;
- sal_uInt8 fUnknown2:4;
-
- sal_uInt8 fUnknown3:8;
-
- sal_uInt8 fUnknown4:7;
- sal_uInt8 fWordWrap:1;
-
- sal_uInt8 fUnknown5:4;
- sal_uInt8 fAutoSize:1;
- sal_uInt8 fUnknown6:3;
-
- sal_uInt32 nCaptionLen;
- sal_uInt16 nVertPos;
- sal_uInt16 nHorzPos;
- sal_uInt32 nBorderColor;
- sal_uInt32 nDrawBuffer;
- sal_uInt32 nShapeCookie;
- sal_uInt8 nKeepScrollBarsVisible;
- sal_uInt8 nCycle;
- sal_uInt8 nBorderStyle;
- sal_uInt8 nMousePointer;
- sal_uInt8 nSpecialEffect;
- sal_uInt16 nPicture;
- sal_uInt8 nPictureAlignment;
- sal_uInt8 nPictureSizeMode;
- bool bPictureTiling;
- sal_uInt16 nAccelerator;
- sal_uInt16 nIcon;
- sal_uInt16 fUnknown7;
-
- char *pCaption;
-
- sal_uInt32 nScrollWidth;
- sal_uInt32 nScrollHeight;
- sal_uInt32 nScrollLeft;
- sal_uInt32 nScrollTop;
-
- sal_uInt8 pIconHeader[20];
- sal_uInt32 nIconLen;
- sal_uInt8 *pIcon;
-
- sal_uInt8 pPictureHeader[20];
- sal_uInt32 nPictureLen;
-private:
- OCX_ParentControl(); // not implemented
- OCX_ParentControl(const OCX_ParentControl&); // not implemented
-
-};
-
-class OCX_Page;
-class OCX_MultiPage : public OCX_ParentControl
-{
-public:
- OCX_MultiPage( SotStorageRef& parent,
- const ::rtl::OUString& storageName,
- const ::rtl::OUString& sN,
- const com::sun::star::uno::Reference<
- com::sun::star::container::XNameContainer > &rDialog, OCX_Control* pParent = NULL);
-
- virtual sal_Bool Read(SvStorageStream *pS);
-
- using OCX_ParentControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
- virtual void ProcessControl( OCX_Control* pControl, SvStorageStream* pS, ContainerRecord& rec );
-private:
- sal_Int32 nActiveTab;
- SotStorageStreamRef mXStream;
- bool bHasTabs;
- std::vector< rtl::OUString > sCaptions;
- // order of Ids corrosponds to the order of captions above
- std::vector< sal_Int32 > mPageIds;
- boost::unordered_map< sal_Int32, OCX_Page* > idToPage;
-};
-
-
-class OCX_Page : public OCX_ParentControl
-{
-public:
- OCX_Page( SotStorageRef& parentStorage,
- sal_Int32 nID,
- const ::rtl::OUString& sN,
- const com::sun::star::uno::Reference<
- com::sun::star::container::XNameContainer > &rDialog, OCX_Control* parent = NULL);
- virtual sal_Bool Read(SvStorageStream *pS);
-
- using OCX_ParentControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
- rtl::OUString msTitle; // #FIXME we should use the existing caption
- sal_Int32 mnID;
-private:
-};
-
-
-class OCX_Frame : public OCX_ParentControl
-{
-public:
- OCX_Frame( SotStorageRef& parent,
- const ::rtl::OUString& storageName,
- const ::rtl::OUString& sN,
- const com::sun::star::uno::Reference<
- com::sun::star::container::XNameContainer > &rDialog, OCX_Control* pParent = NULL);
- virtual sal_Bool Read(SvStorageStream *pS);
-
- using OCX_ParentControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
-};
-
-
-class OCX_UserForm : public OCX_ParentControl
-{
-public:
- OCX_UserForm( SotStorageRef& parent,
- const ::rtl::OUString& storageName,
- const ::rtl::OUString& sN,
- const com::sun::star::uno::Reference<
- com::sun::star::container::XNameContainer > &rDialog,
- const com::sun::star::uno::Reference<
- com::sun::star::lang::XMultiServiceFactory >& rMsf);
- using OCX_ParentControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import( com::sun::star::uno::Reference<
- com::sun::star::container::XNameContainer>
- &rDialog);
-private:
- com::sun::star::uno::Reference<
- com::sun::star::uno::XComponentContext> mxCtx;
-};
-
-
-
class OCX_CheckBox : public OCX_ModernControl
{
public:
@@ -695,9 +419,6 @@ public:
aFontData.SetHasAlign(sal_True);
}
- using OCX_ModernControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
sal_Bool Export(SotStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -722,9 +443,6 @@ public:
aFontData.SetHasAlign(sal_True);
}
- using OCX_ModernControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
sal_Bool Export(SotStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -750,10 +468,6 @@ public:
aFontData.SetHasAlign(sal_True);
}
- using OCX_ModernControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
-
sal_Bool Export(SotStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -799,9 +513,6 @@ public:
}
static OCX_Control *Create() { return new OCX_ToggleButton;}
- using OCX_ModernControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
sal_Bool Export(SvStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -824,9 +535,6 @@ public:
aFontData.SetHasAlign(sal_True);
}
static OCX_Control *Create() { return new OCX_ComboBox;}
- using OCX_ModernControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
sal_Bool Export(SotStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -850,9 +558,6 @@ public:
aFontData.SetHasAlign(sal_True);
}
static OCX_Control *Create() { return new OCX_ListBox;}
- using OCX_ModernControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
sal_Bool Export(SotStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -883,7 +588,6 @@ public:
if (pCaption) delete[] pCaption;
if (pIcon) delete[] pIcon;
}
- sal_Bool Read(SotStorageStream *pS);
/*sal_uInt8 for sal_uInt8 Word Struct*/
sal_uInt16 nIdentifier;
@@ -928,9 +632,6 @@ public:
bool mbTakeFocus;
static OCX_Control *Create() { return new OCX_CommandButton;}
- using OCX_Control::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
sal_Bool Export(SotStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -998,7 +699,6 @@ public:
if (pCaption) delete[] pCaption;
if (pIcon) delete[] pIcon;
}
- sal_Bool Read(SotStorageStream *pS);
/*sal_uInt8 for sal_uInt8 Word Struct*/
sal_uInt16 nIdentifier;
@@ -1043,10 +743,6 @@ public:
static OCX_Control *Create() { return new OCX_Label;}
- using OCX_Control::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
-
sal_Bool Export(SotStorageRef &rObj,
const com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySet> &rPropSet,
@@ -1066,12 +762,6 @@ public:
static OCX_Control* Create();
- virtual sal_Bool Read( SvStorageStream *pS );
- using OCX_Control::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
- // No Font record
- virtual sal_Bool ReadFontData(SvStorageStream* /*pS*/) { return sal_True; }
private:
sal_Int32 nMin;
sal_Int32 nMax;
@@ -1087,13 +777,6 @@ public:
static OCX_Control* Create();
- virtual sal_Bool Read( SvStorageStream *pS );
-
- virtual sal_Bool ReadFontData( SvStorageStream *pS );
-
- using OCX_Control::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
//Export exports a control as an OLE style storage stream tree
virtual sal_Bool Export( SvStorageRef &rObj,
const com::sun::star::uno::Reference<
@@ -1153,10 +836,6 @@ public:
static OCX_Control* Create();
- using OCX_Control::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
-
//Export exports a control as an OLE style storage stream tree
virtual sal_Bool Export( SvStorageRef &rObj,
const com::sun::star::uno::Reference<
@@ -1185,14 +864,8 @@ public:
nMultiState =false;
}
- using OCX_ModernControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
-
static OCX_Control *Create() { return new HTML_Select;}
- virtual sal_Bool Read(SotStorageStream *pS);
- virtual sal_Bool ReadFontData(SotStorageStream *pS);
com::sun::star::uno::Sequence< rtl::OUString > msListData;
com::sun::star::uno::Sequence< sal_Int16 > msIndices;
};
@@ -1209,23 +882,8 @@ public:
aFontData.SetHasAlign(sal_True);
}
- using OCX_ModernControl::Import; // to not hide the other two import methods
- virtual sal_Bool Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet);
- /*
- sal_Bool Export(SotStorageRef &rObj,
- const com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet,
- const com::sun::star::awt::Size& rSize);
- sal_Bool WriteContents(SotStorageStreamRef &rObj,
- const com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet,
- const com::sun::star::awt::Size& rSize);
- */
static OCX_Control *Create() { return new HTML_TextBox;}
- virtual sal_Bool Read(SotStorageStream *pS);
- virtual sal_Bool ReadFontData(SotStorageStream *pS);
};
diff --git a/filter/inc/filter/msfilter/svxmsbas.hxx b/filter/inc/filter/msfilter/svxmsbas.hxx
index e2aa7345804c..f04a83b5111a 100644
--- a/filter/inc/filter/msfilter/svxmsbas.hxx
+++ b/filter/inc/filter/msfilter/svxmsbas.hxx
@@ -67,16 +67,6 @@ public:
: xRoot(&rRoot), rDocSh(rDocS),
bImport(bImportCode), bCopy(bCopyStorage)
{}
- // returns the status of import:
- // 0 - nothing has done
- // bit 0 = 1 -> any code is imported to the SO-Basic
- // bit 1 = 1 -> the VBA - storage is copy to the ObjectShell storage
- int Import( const String& rStorageName, const String &rSubStorageName,
- sal_Bool bAsComment=sal_True, sal_Bool bStripped=sal_True );
- int Import( const String& rStorageName, const String &rSubStorageName,
- const std::vector< String >& codeNames,
- sal_Bool bAsComment=sal_True, sal_Bool bStripped=sal_True );
-
// only for the export - copy or delete the saved VBA-macro-storage
// form the ObjectShell
// - returns a warning code if a modified basic exist, in all other
@@ -102,13 +92,10 @@ private:
const String &rSubStorageName,
const std::vector< String >& codeNames,
sal_Bool bAsComment, sal_Bool bStripped);
- MSFILTER_DLLPRIVATE bool ImportForms_Impl(const String& rStorageName,
- const String &rSubStorageName, sal_Bool bVBAMode);
MSFILTER_DLLPRIVATE sal_Bool CopyStorage_Impl( const String& rStorageName,
const String &rSubStorageName);
rtl::OUString msProjectName;
MSFILTER_DLLPRIVATE sal_Bool ImportCode_Impl( VBA_Impl&, const std::vector< String >&, sal_Bool, sal_Bool );
- MSFILTER_DLLPRIVATE bool ImportForms_Impl( VBA_Impl&, const String&, const String&, sal_Bool);
};
#endif
diff --git a/filter/source/msfilter/makefile.mk b/filter/source/msfilter/makefile.mk
index 8070bc4f4f88..142e28f0b9ab 100644
--- a/filter/source/msfilter/makefile.mk
+++ b/filter/source/msfilter/makefile.mk
@@ -50,7 +50,6 @@ SLOFILES= \
$(SLO)$/msocximex.obj \
$(SLO)$/msoleexp.obj \
$(SLO)$/msvbahelper.obj \
- $(SLO)$/msvbasic.obj \
$(SLO)$/services.obj \
$(SLO)$/svdfppt.obj \
$(SLO)$/svxmsbas.obj \
diff --git a/filter/source/msfilter/msocximex.cxx b/filter/source/msfilter/msocximex.cxx
index 6c79d1b9b384..2bc00155b05e 100644
--- a/filter/source/msfilter/msocximex.cxx
+++ b/filter/source/msfilter/msocximex.cxx
@@ -106,281 +106,11 @@ using namespace cppu;
#define WW8_ASCII2STR(s) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(s))
-#define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
-
-
-// #FIXME remove when oox is used for control import
-// convertion class lifted from oox ( yes, duplication I know but
-// should be very short term )
-class GraphicHelper
-{
-public:
- GraphicHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel );
- ~GraphicHelper();
-
- /** Returns information about the output device. */
- const ::com::sun::star::awt::DeviceInfo& getDeviceInfo() const;
-
- /** Converts the passed value from horizontal screen pixels to 1/100 mm. */
- sal_Int32 convertScreenPixelXToHmm( double fPixelX ) const;
- /** Converts the passed value from vertical screen pixels to 1/100 mm. */
- sal_Int32 convertScreenPixelYToHmm( double fPixelY ) const;
- /** Converts the passed point from screen pixels to 1/100 mm. */
- ::com::sun::star::awt::Point convertScreenPixelToHmm( const ::com::sun::star::awt::Point& rPixel ) const;
- /** Converts the passed size from screen pixels to 1/100 mm. */
- ::com::sun::star::awt::Size convertScreenPixelToHmm( const ::com::sun::star::awt::Size& rPixel ) const;
-
- /** Converts the passed value from 1/100 mm to horizontal screen pixels. */
- double convertHmmToScreenPixelX( sal_Int32 nHmmX ) const;
- /** Converts the passed value from 1/100 mm to vertical screen pixels. */
- double convertHmmToScreenPixelY( sal_Int32 nHmmY ) const;
- /** Converts the passed point from 1/100 mm to screen pixels. */
- ::com::sun::star::awt::Point convertHmmToScreenPixel( const ::com::sun::star::awt::Point& rHmm ) const;
- /** Converts the passed size from 1/100 mm to screen pixels. */
- ::com::sun::star::awt::Size convertHmmToScreenPixel( const ::com::sun::star::awt::Size& rHmm ) const;
-
- /** Converts the passed point from AppFont units to 1/100 mm. */
- ::com::sun::star::awt::Point convertAppFontToHmm( const ::com::sun::star::awt::Point& rAppFont ) const;
- /** Converts the passed point from AppFont units to 1/100 mm. */
- ::com::sun::star::awt::Size convertAppFontToHmm( const ::com::sun::star::awt::Size& rAppFont ) const;
-
- /** Converts the passed point from 1/100 mm to AppFont units. */
- ::com::sun::star::awt::Point convertHmmToAppFont( const ::com::sun::star::awt::Point& rHmm ) const;
- /** Converts the passed size from 1/100 mm to AppFont units. */
- ::com::sun::star::awt::Size convertHmmToAppFont( const ::com::sun::star::awt::Size& rHmm ) const;
-
-private:
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxGlobalFactory;
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxCompContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion > mxUnitConversion;
- ::com::sun::star::awt::DeviceInfo maDeviceInfo; /// Current output device info.
- double mfPixelPerHmmX; /// Number of screen pixels per 1/100 mm in X direction.
- double mfPixelPerHmmY; /// Number of screen pixels per 1/100 mm in Y direction.
-};
-
-inline sal_Int32 lclConvertScreenPixelToHmm( double fPixel, double fPixelPerHmm )
-{
- return static_cast< sal_Int32 >( (fPixelPerHmm > 0.0) ? (fPixel / fPixelPerHmm + 0.5) : 0.0 );
-}
-
-GraphicHelper::GraphicHelper( const uno::Reference< frame::XModel >& rxModel )
-{
- mxGlobalFactory = comphelper::getProcessServiceFactory();
- ::comphelper::ComponentContext aContext( mxGlobalFactory );
- mxCompContext = aContext.getUNOContext();
-
- // if no target frame has been passed (e.g. OLE objects), try to fallback to the active frame
- // TODO: we need some mechanism to keep and pass the parent frame
- uno::Reference< frame::XFrame > xFrame;
- if ( rxModel.is() )
- {
- uno::Reference< frame::XController > xController = rxModel->getCurrentController();
- xFrame = xController.is() ? xController->getFrame() : NULL;
- }
- if( !xFrame.is() && mxGlobalFactory.is() ) try
- {
- uno::Reference< frame::XFramesSupplier > xFramesSupp( mxGlobalFactory->createInstance( WW8_ASCII2STR( "com.sun.star.frame.Desktop" ) ), uno::UNO_QUERY_THROW );
- xFrame = xFramesSupp->getActiveFrame();
- }
- catch( uno::Exception& )
- {
- }
-
- // get the metric of the output device
- OSL_ENSURE( xFrame.is(), "GraphicHelper::GraphicHelper - cannot get target frame" );
- maDeviceInfo.PixelPerMeterX = maDeviceInfo.PixelPerMeterY = 3500.0; // some default just in case
- if( xFrame.is() ) try
- {
- uno::Reference< awt::XDevice > xDevice( xFrame->getContainerWindow(), uno::UNO_QUERY_THROW );
- mxUnitConversion.set( xDevice, uno::UNO_QUERY );
- OSL_ENSURE( mxUnitConversion.is(), "GraphicHelper::GraphicHelper - cannot get unit converter" );
- maDeviceInfo = xDevice->getInfo();
- }
- catch( uno::Exception& )
- {
- OSL_FAIL( "GraphicHelper::GraphicHelper - cannot get output device info" );
- }
- mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0;
- mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0;
-}
-
-GraphicHelper::~GraphicHelper()
-{
-}
-
-// Device info and device dependent unit conversion ---------------------------
-
-const awt::DeviceInfo& GraphicHelper::getDeviceInfo() const
-{
- return maDeviceInfo;
-}
-
-sal_Int32 GraphicHelper::convertScreenPixelXToHmm( double fPixelX ) const
-{
- return lclConvertScreenPixelToHmm( fPixelX, mfPixelPerHmmX );
-}
-
-sal_Int32 GraphicHelper::convertScreenPixelYToHmm( double fPixelY ) const
-{
- return lclConvertScreenPixelToHmm( fPixelY, mfPixelPerHmmY );
-}
-
-awt::Point GraphicHelper::convertScreenPixelToHmm( const awt::Point& rPixel ) const
-{
- return awt::Point( convertScreenPixelXToHmm( rPixel.X ), convertScreenPixelYToHmm( rPixel.Y ) );
-}
-
-awt::Size GraphicHelper::convertScreenPixelToHmm( const awt::Size& rPixel ) const
-{
- return awt::Size( convertScreenPixelXToHmm( rPixel.Width ), convertScreenPixelYToHmm( rPixel.Height ) );
-}
-
-double GraphicHelper::convertHmmToScreenPixelX( sal_Int32 nHmmX ) const
-{
- return nHmmX * mfPixelPerHmmX;
-}
-
-double GraphicHelper::convertHmmToScreenPixelY( sal_Int32 nHmmY ) const
-{
- return nHmmY * mfPixelPerHmmY;
-}
-
-awt::Point GraphicHelper::convertHmmToScreenPixel( const awt::Point& rHmm ) const
-{
- return awt::Point(
- static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.X ) + 0.5 ),
- static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Y ) + 0.5 ) );
-}
-
-awt::Size GraphicHelper::convertHmmToScreenPixel( const awt::Size& rHmm ) const
-{
- return awt::Size(
- static_cast< sal_Int32 >( convertHmmToScreenPixelX( rHmm.Width ) + 0.5 ),
- static_cast< sal_Int32 >( convertHmmToScreenPixelY( rHmm.Height ) + 0.5 ) );
-}
-
-awt::Point GraphicHelper::convertAppFontToHmm( const awt::Point& rAppFont ) const
-{
- if( mxUnitConversion.is() ) try
- {
- awt::Point aPixel = mxUnitConversion->convertPointToPixel( rAppFont, ::com::sun::star::util::MeasureUnit::APPFONT );
- return convertScreenPixelToHmm( aPixel );
- }
- catch( uno::Exception& )
- {
- }
- return awt::Point( 0, 0 );
-}
-
-awt::Size GraphicHelper::convertAppFontToHmm( const awt::Size& rAppFont ) const
-{
- if( mxUnitConversion.is() ) try
- {
- awt::Size aPixel = mxUnitConversion->convertSizeToPixel( rAppFont, ::com::sun::star::util::MeasureUnit::APPFONT );
- return convertScreenPixelToHmm( aPixel );
- }
- catch( uno::Exception& )
- {
- }
- return awt::Size( 0, 0 );
-}
-
-awt::Point GraphicHelper::convertHmmToAppFont( const awt::Point& rHmm ) const
-{
- if( mxUnitConversion.is() ) try
- {
- awt::Point aPixel = convertHmmToScreenPixel( rHmm );
- return mxUnitConversion->convertPointToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT );
- }
- catch( uno::Exception& )
- {
- }
- return awt::Point( 0, 0 );
-}
-
-awt::Size GraphicHelper::convertHmmToAppFont( const awt::Size& rHmm ) const
-{
- if( mxUnitConversion.is() ) try
- {
- awt::Size aPixel = convertHmmToScreenPixel( rHmm );
- return mxUnitConversion->convertSizeToLogic( aPixel, ::com::sun::star::util::MeasureUnit::APPFONT );
- }
- catch( uno::Exception& )
- {
- }
- return awt::Size( 0, 0 );
-}
-
static char sWW8_form[] = "WW-Standard";
-
-struct SortOrderByTabPos
-{
- bool operator()( const OCX_Control* a, const OCX_Control* b )
- {
- return a->mnTabPos < b->mnTabPos;
- }
-};
-
-
sal_uInt8 const OCX_Control::aObjInfo[4] = { 0x00, 0x12, 0x03, 0x00 };
-long ReadAlign(SvStorageStream *pS, long nPos, int nAmount)
-{
- if (long nAlign = nPos % nAmount)
- {
-
- long nLen = nAmount - nAlign;
- pS->SeekRel(nLen);
- return nLen;
- }
- return 0;
-}
-
-// NP - Images in controls in OO2.0/SO8 exist as links, e.g. they are not part of the document so are
-// referenced externally. On import from ms document try to save images for controls here.
-// Images are stored in directory called temp in the user installation directory. Next version of OO/SO
-// hopefully will address this issue and allow a choice e.g. images for controls to be stored as links
-// or embeded in the document.
-uno::Reference< graphic::XGraphicObject> lcl_readGraphicObject( SotStorageStream *pS )
-{
- uno::Reference< graphic::XGraphicObject > xGrfObj;
- uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
- if( xServiceManager.is() )
- {
- try
- {
- // use the GraphicProvider service to get the XGraphic
- uno::Reference< graphic::XGraphicProvider > xGraphProvider(
- xServiceManager->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" )) ), uno::UNO_QUERY );
- if( xGraphProvider.is() )
- {
- uno::Reference< io::XInputStream > xStream( new utl::OInputStreamWrapper( *pS ) );
- if( xStream.is() )
- {
- uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
- aMediaProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InputStream" ));
- aMediaProps[0].Value <<= xStream;
- uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps );
- if( xGraphic.is() )
- {
- // create an XGraphicObject
- ::comphelper::ComponentContext aContext( xServiceManager );
- xGrfObj = graphic::GraphicObject::create( aContext.getUNOContext() );
- xGrfObj->setGraphic(xGraphic);
- }
- }
- }
- }
- catch( uno::Exception& )
- {
- }
- }
- return xGrfObj;
-}
-
-
long WriteAlign(SvStorageStream *pS, int nAmount)
{
if (long nAlign = pS->Tell() % nAmount)
@@ -416,52 +146,6 @@ bool writeOCXNAME( const OUString& sOCXName, SvStorageStream* pStream )
}
-bool readOCXNAME( OUString& sCName, SvStorageStream* pStream )
-{
- /*
- * Read uniCode until no data or 0 encountered
- */
- OUStringBuffer buf(40);
- do
- {
- sal_uInt16 ch = 0;
- *pStream >> ch;
- sal_Unicode uni = static_cast< sal_Unicode >( ch );
- if ( uni == 0 )
- {
- break;
- }
- buf.append( &uni, 1 );
-
- } while ( !pStream->IsEof() );
-
- sCName = buf.makeStringAndClear();
- return ( SVSTREAM_OK == pStream->GetError() );
-}
-
-
-/* ** Import of Unicode strings in form controls **
-
- Strings may be stored either as compressed or uncompressed Unicode
- character array. There are no encoded byte strings anywhere.
-
- The string length field stores the length of the character array (not the
- character count of the string) in the lower 31 bits, and the compression
- state in the highest bit.
-
- A set bit means the character array is compressed. This means all Unicode
- characters are <=0xFF. Therefore the high bytes of all characters are left
- out, and the character array size is equal to the string length.
-
- A cleared bit means the character array is not compressed. The buffer
- contains Little-Endian Unicode characters, and the resulting string length
- is half the buffer size.
-
- TODO: This implementation of the new string import is a hack to keep
- msocximex.hxx unchanged. A better implementation would replace the char*
- members of all classes by something more reasonable.
- */
-
namespace {
const sal_uInt32 SVX_MSOCX_SIZEMASK = 0x7FFFFFFF; /// Mask for character buffer size.
@@ -484,104 +168,6 @@ inline sal_uInt32 lclGetBufferSize( sal_uInt32 nLenFld )
return nLenFld & SVX_MSOCX_SIZEMASK;
}
-
-// import ---------------------------------------------------------------------
-
-/** Reads the character array of a string in a form control.
-
- Creates a new character array containing the character data.
- The length field must be read before and passed to this function.
- Aligns stream position to multiple of 4 before.
-
- @param rStrm
- The input stream.
-
- @param rpcCharArr
- (out-param) Will point to the created character array,
- or will be 0 if string is empty. The array is NOT null-terminated.
- If the passed pointer points to an old existing array, it will be
- deleted before. Caller must delete the returned array.
-
- @param nLenFld
- The corresponding string length field read somewhere before.
- */
-void lclReadCharArray( SvStorageStream& rStrm, char*& rpcCharArr, sal_uInt32 nLenFld, long nPos )
-{
- delete[] rpcCharArr;
- rpcCharArr = 0;
- sal_uInt32 nBufSize = lclGetBufferSize( nLenFld );
- DBG_ASSERT( nBufSize <= 0xFFFF, "lclReadCharArray - possible read error: char array is too big" );
- if( nBufSize && nBufSize <= 0xFFFF )
- {
- rpcCharArr = new char[ nBufSize ];
- if( rpcCharArr )
- {
- ReadAlign( &rStrm, nPos, 4 );
- rStrm.Read( rpcCharArr, nBufSize );
- }
- }
-}
-
-/** Creates an OUString from a character array created with lclReadCharArray().
-
- The passed parameters must match, that means the length field must be the
- same used to create the passed character array.
-
- @param pcCharArr
- The character array returned by lclReadCharArray(). May be compressed
- or uncompressed, next parameter nLenFld will specify this.
-
- @param nLenFld
- MUST be the same string length field that has been passed to
- lclReadCharArray() to create the character array in previous parameter
- pcCharArr.
-
- @return
- An OUString containing the decoded string data. Will be empty if
- pcCharArr is 0.
- */
-OUString lclCreateOUString( const char* pcCharArr, sal_uInt32 nLenFld )
-{
- sal_uInt32 nBufSize = lclGetBufferSize( nLenFld );
- if( lclIsCompressed( nLenFld ) )
- return svt::BinFilterUtils::CreateOUStringFromStringArray( pcCharArr, nBufSize );
-
- return svt::BinFilterUtils::CreateOUStringFromUniStringArray( pcCharArr, nBufSize );
-}
-
-void readArrayString( SotStorageStream *pS, std::vector< rtl::OUString >& sStringsOut, sal_Int32 nSize, long nStart )
-{
- unsigned long nFinish = pS->Tell() + nSize;
- while ( pS->Tell() < nFinish )
- {
- sal_Int32 nStringLen = 0;
- *pS >> nStringLen;
- sal_uInt32 nStringSize = lclGetBufferSize( nStringLen );
- sal_Char* pString = new sal_Char[ nStringSize ];
- pS->Read( pString, nStringSize );
- rtl::OUString sString = lclCreateOUString( pString, nStringLen );
- delete[] pString;
- sStringsOut.push_back( sString );
- ReadAlign(pS, pS->Tell() - nStart, 4);
- }
-}
-
-OUString createSubStreamName( const sal_uInt32& subStorageId )
-{
- static OUString sI( RTL_CONSTASCII_USTRINGPARAM( "i" ));
- static OUString sZero( RTL_CONSTASCII_USTRINGPARAM( "0" ));
- OUStringBuffer buf( 6 );
- buf.append( sI );
- // for subStorage id < 10 stream name has leading '0'
- // eg "i07"
- if ( subStorageId < 10 )
- {
- buf.append( sZero );
- }
- buf.append( OUString::valueOf( (sal_Int32)subStorageId ) );
- return buf.makeStringAndClear();
-}
-
// export ---------------------------------------------------------------------
/** This class implements writing a character array from a Unicode string.
@@ -674,518 +260,6 @@ void SvxOcxString::WriteCharArray( SvStorageStream& rStrm ) const
}
}
-class MultiPageProps
-{
-public:
- sal_uInt16 nIdentifier; // major & minor version
- sal_uInt16 nFixedAreaLen; // size of record
- sal_uInt8 pBlockFlags[4]; // size of record
- sal_Int32 mnPageCount;
- sal_Int32 mnID;
- bool mbEnabled;
- std::vector< sal_Int32 > mnIDs;
-
- MultiPageProps();
- bool Read(SotStorageStream *pS);
-};
-
-MultiPageProps::MultiPageProps() : nIdentifier(0), nFixedAreaLen(0), mnPageCount(0), mnID(0), mbEnabled( true )
-{
-}
-
-bool MultiPageProps::Read(SotStorageStream *pS)
-{
- *pS >> nIdentifier >> nFixedAreaLen;
- pS->Read( pBlockFlags, sizeof( pBlockFlags ) );
- if ( pBlockFlags[ 0 ] & 0x02 )
- *pS >> mnPageCount;
- if ( pBlockFlags[ 0 ] & 0x04 )
- *pS >> mnID;
- if ( pBlockFlags[ 0 ] & 0x08 )
- mbEnabled = false;
- for ( sal_Int32 i=0; i<mnPageCount; ++i )
- {
- sal_Int32 nID(0);
- *pS >> nID;
- mnIDs.push_back( nID );
- }
- return true;
-}
-
-const sal_uInt16 USERFORM = (sal_uInt16)0xFF;
-const sal_uInt16 STDCONTAINER = (sal_uInt16)0xFE;
-
-const sal_uInt16 PAGE = (sal_uInt16)0x07;
-
-const sal_uInt16 IMAGE = (sal_uInt16)0x0C;
-const sal_uInt16 FRAME = (sal_uInt16)0x0E;
-
-const sal_uInt16 SPINBUTTON = (sal_uInt16)0x10;
-const sal_uInt16 CMDBUTTON = (sal_uInt16)0x11;
-const sal_uInt16 TABSTRIP = (sal_uInt16)0x12;
-
-const sal_uInt16 LABEL = (sal_uInt16)0x15;
-
-const sal_uInt16 TEXTBOX = (sal_uInt16)0x17;
-const sal_uInt16 LISTBOX = (sal_uInt16)0x18;
-const sal_uInt16 COMBOBOX = (sal_uInt16)0x19;
-const sal_uInt16 CHECKBOX = (sal_uInt16)0x1A;
-
-const sal_uInt16 OPTIONBUTTON = (sal_uInt16)0x1B;
-const sal_uInt16 TOGGLEBUTTON = (sal_uInt16)0x1C;
-
-const sal_uInt16 SCROLLBAR = (sal_uInt16)0x2F;
-
-const sal_uInt16 MULTIPAGE = (sal_uInt16)0x39;
-
-const sal_uInt16 UNKNOWNCTRL = (sal_uInt16)0x7FFF;
-const sal_uInt16 PROGRESSBAR = (sal_uInt16)0x8000;
-
-// following ActiveX controls are just for reference ( are NOT supported )
-const sal_uInt16 REFEDIT = (sal_uInt16)0x8001;
-const sal_uInt16 CALENDAR = (sal_uInt16)0x8002;
-const sal_uInt16 IMAGECOMBO = (sal_uInt16)0x8003;
-const sal_uInt16 IMAGELIST = (sal_uInt16)0x8004;
-const sal_uInt16 SLIDER = (sal_uInt16)0x8005;
-const sal_uInt16 STATUSBAR = (sal_uInt16)0x8006;
-const sal_uInt16 CHARTSPACE = (sal_uInt16)0x8007;
-
-// A set of common CLSIDs
-// there are to identify the following ActiveX controls ( that appear in the ClassTable records )
-// Currently we only can process ( in a limited way ) the ProgressBar
-// the other ID's are for reference ( & future )
-
-// Microsoft ProgressBar Control, version 6.0 {35053A22-8589-11D1-B16A-00C0F0283628}
-const sal_uInt8 aProgressID[] =
-{
-0x22, 0x3a, 0x05, 0x35, 0x89, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
-};
-
-// RefEdit control {00024512-0000-0000-c000-000000000046}
-const sal_uInt8 aRefEditID[] =
-{
-0x12, 0x45, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
-};
-
-// Calendar Control 10.0
-const sal_uInt8 aCalendarID[] =
-{
-0x2b, 0xc9, 0x27, 0x8e, 0x64, 0x12, 0x1c, 0x10, 0x8a, 0x2f, 0x04, 0x02, 0x24, 0x00, 0x9c, 0x02,
-};
-
-// Microsoft ImageComboxBox Control, version 6.0 {DD9DA666-8594-11D1-B16A-00C0F0283628}
-const sal_uInt8 aImageComboID[] =
-{
-0x66, 0xa6, 0x9d, 0xdd, 0x94, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
-};
-
-// Microsoft ImageList Control, version 6.0 {2C247F23-8591-11D1-B16A-00C0F0283628}
-const sal_uInt8 aImageListID[] =
-{
-0x23, 0x7f, 0x24, 0x2c, 0x91, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
-};
-
-// Microsoft Slider Control, version 6.0 {F08DF954-8592-11D1-B16A-00C0F0283628}
-const sal_uInt8 aSliderID[] =
-{
-0x54, 0xf9, 0x8d, 0xf0, 0x92, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
-};
-
-// Microsoft StatusBar Control, version 6.0 {8E3867A3-8586-11D1-B16A-00C0F0283628}
-const sal_uInt8 aStatusBarID[] =
-{
-0xa3, 0x67, 0x38, 0x8e, 0x86, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
-};
-
-// Microsoft Office Chart 10.0
-const sal_uInt8 aChartSpaceID[] =
-{
-0x46, 0xe5, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
-};
-
-const sal_uInt8 nSizeOfClsid = sizeof( aProgressID );
-
-struct ClsIdTypeIDPair
-{
-// ClsIdTypeIDPair() : pClsID( NULL ), nTypeID( UNKNOWNCTRL ) {}
- const sal_uInt8* pClsID;
- const sal_uInt16 nTypeID;
-};
-
-ClsIdTypeIDPair ClsidList[] = { { aProgressID, PROGRESSBAR },
-// unsupported common activex controls
-#ifdef DEBUG
- { aRefEditID, REFEDIT },
- { aCalendarID, CALENDAR },
- { aImageComboID, IMAGECOMBO },
- { aImageListID, IMAGELIST },
- { aSliderID, SLIDER },
- { aStatusBarID, STATUSBAR },
- { aChartSpaceID, CHARTSPACE },
-#endif
-};
-
-typedef std::vector< ContainerRecord > ContainerRecordList;
-
-class FormObjectDepthTypeCount
-{
- public:
- sal_uInt8 depth;
- sal_uInt8 TypeOrCount;
- std::auto_ptr< sal_uInt8 > OptionalType;
- FormObjectDepthTypeCount() : depth(0), TypeOrCount(0) {}
- bool Read( SvStorageStream* pS )
- {
- *pS >> depth >> TypeOrCount;
- if ( TypeOrCount & 0x80 )
- {
- OptionalType.reset( new sal_uInt8 );
- *pS >> *OptionalType;
- }
- TypeOrCount = ( TypeOrCount >> 1 );
- return true;
- }
-};
-
-class ClassTable
-{
- sal_uInt16 nIdentifier;
- sal_uInt16 nFixedAreaLen;
- sal_uInt32 nContentFlags;
- sal_uInt16 nClassTableFlags;
- sal_uInt16 nVarFlags;
- sal_Int32 nCountOfMethods;
- sal_Int32 nDispidBind;
- sal_uInt16 nGetBindIndex;
- sal_uInt16 nPutBindIndex;
- sal_uInt16 nBindType;
- sal_uInt16 nGetValueIndex;
- sal_uInt16 nPutValueIndex;
- sal_uInt16 nValueType;
- sal_uInt32 nDisidRowset;
- sal_uInt16 nSetRowset;
- sal_uInt8 pClsId[16];
- sal_uInt8 pDispEvent[16];
- sal_uInt8 pDefaultProg[16];
- sal_uInt16 nTypeId;
-public:
- ClassTable() : nIdentifier( 0 )
- ,nFixedAreaLen( 0 )
- ,nContentFlags(0)
- ,nClassTableFlags(0)
- ,nVarFlags(0)
- ,nCountOfMethods(0)
- ,nDispidBind(0)
- ,nGetBindIndex(0)
- ,nPutBindIndex(0)
- ,nBindType(0)
- ,nGetValueIndex(0)
- ,nPutValueIndex(0)
- ,nValueType(0)
- ,nDisidRowset(0)
- ,nSetRowset(0)
- ,nTypeId(UNKNOWNCTRL)
-
- {
- memset( pClsId, 0, sizeof( pClsId ) );
- memset( pDispEvent, 0, sizeof( pDispEvent ) );
- memset( pDefaultProg, 0, sizeof( pDefaultProg ) );
- }
- bool Read( SvStorageStream* pS )
- {
- long nStartPos = pS->Tell();
- *pS >> nIdentifier >> nFixedAreaLen >> nContentFlags;
- bool bClsID( false );
- bool bDispEvent( false );
- bool bDefaultProg( false );
- if ( nContentFlags & 0x00000001 )
- bClsID = true;
- if ( nContentFlags & 0x00000002 )
- bDispEvent = true;
-// if ( nContentFlags & 0x00000004 ) ' not set should be 0
- if ( nContentFlags & 0x00000008 )
- bDefaultProg = true;
- if ( nContentFlags & 0x00000010 )
- *pS >> nClassTableFlags >> nVarFlags;
- if ( nContentFlags & 0x00000020 )
- *pS >> nCountOfMethods;
- if ( nContentFlags & 0x00000040 )
- *pS >> nDispidBind;
- if ( nContentFlags & 0x00000080 )
- *pS >> nGetBindIndex;
- if ( nContentFlags & 0x00000100 )
- *pS >> nPutBindIndex;
- if ( nContentFlags & 0x00000200 )
- *pS >> nBindType;
- if ( nContentFlags & 0x00000400 )
- *pS >> nGetValueIndex;
- if ( nContentFlags & 0x00000800 )
- *pS >> nPutValueIndex;
- if ( nContentFlags & 0x00001000 )
- *pS >> nValueType;
- if ( nContentFlags & 0x00002000 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- *pS >> nDisidRowset;
- }
- if ( nContentFlags & 0x00004000 )
- *pS >> nSetRowset;
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- // Extra Block
- if ( bClsID )
- pS->Read( pClsId, sizeof( pClsId ) );
- if ( bDispEvent )
- pS->Read( pDispEvent, sizeof( pDispEvent ) );
- if ( bDefaultProg )
- pS->Read( pDefaultProg, sizeof( pDefaultProg ) );
-
- sal_Int32 nNumIds = SAL_N_ELEMENTS( ClsidList );
-
- if ( bClsID )
- {
- for ( sal_Int32 index = 0; index < nNumIds; ++index )
- {
- if ( memcmp( pClsId, ClsidList[ index ].pClsID, nSizeOfClsid ) == 0 )
- {
- nTypeId = ClsidList[ index ].nTypeID;
- OSL_TRACE( "... found activex control ClsidList[ %d ] and have given it TypeIdent 0x%x", index, nTypeId );
- }
- }
- }
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- return true;
- }
-
- sal_uInt16 getTypeId() { return nTypeId; }
-};
-
-class OleSiteConcreteControl
-{
- sal_uInt16 nIdentifier;
- sal_uInt16 nFixedAreaLen;
- sal_uInt32 nContentFlags;
-public:
- OleSiteConcreteControl() : nIdentifier( 0 ), nFixedAreaLen( 0 ), nContentFlags(0) {}
- bool Read( ContainerRecord& rec, SvStorageStream* pS )
- {
- long nStartPos = pS->Tell();
- *pS >> nIdentifier >> nFixedAreaLen >> nContentFlags;
-
- bool bPosition( false );
-
- sal_uInt32 nNameLen = 0;
- // length of control name
- if ( nContentFlags & 0x00000001 )
- *pS >> nNameLen;
- // length of control tag
- sal_uInt32 nTagLen = 0;
- if( nContentFlags & 0x00000002 )
- *pS >> nTagLen;
- // substorage id for frames
- if( nContentFlags & 0x00000004 )
- *pS >> rec.nSubStorageId;
- // help-context id
- if( nContentFlags & 0x00000008 )
- pS->SeekRel( 4 );
- // option flags
- if( nContentFlags & 0x00000010 )
- {
- sal_uInt32 nBitFlags = 0;
- *pS >> nBitFlags;
- rec.bVisible = ( nBitFlags & 0x02 );
- rec.bTabStop = ( nBitFlags & 0x01 );
- }
- // substream size
- if( nContentFlags & 0x00000020 )
- *pS >> rec.nSubStreamLen;
- // tabstop position
- if( nContentFlags & 0x00000040 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 2 );
- *pS >> rec.nTabPos;
- }
- // control type
- if( nContentFlags & 0x00000080 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 2 );
- *pS >> rec.nTypeIdent;
- }
- if( nContentFlags & 0x00000100 )
- bPosition = true;
- sal_Int16 nGroupId = 0;
- if( nContentFlags & 0x00000200 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 2 );
- *pS >> nGroupId;
- }
-
- // length of infotip
- sal_uInt32 nTipLen = 0;
- if( nContentFlags & 0x00000800 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- *pS >> nTipLen;
- }
- sal_uInt32 nCntrlIdLen = 0;
- if( nContentFlags & 0x00001000 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- *pS >> nCntrlIdLen;
- }
-
- // length of control source name
- sal_uInt32 nCtrlSrcLen = 0;
- if( nContentFlags & 0x00002000 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- *pS >> nCtrlSrcLen;
- }
-
- // length of row source name
- sal_uInt32 nRowSrcLen = 0;
- if( nContentFlags & 0x00004000 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- *pS >> nRowSrcLen;
- }
-
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- // control name
- sal_Char* pName = 0;
- sal_uInt32 nNameBufSize = lclGetBufferSize( nNameLen );
- if( nNameBufSize > 0 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- pName = new char[ nNameBufSize ];
- pS->Read( pName, nNameBufSize );
- }
- // control tag
- sal_uInt32 nTagBufSize = lclGetBufferSize( nTagLen );
- if( nTagBufSize > 0 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- pS->SeekRel( nTagBufSize );
- }
-
- // control position
- if( bPosition )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- *pS >> rec.nLeft >> rec.nTop;
- }
-
- // control infotip
- sal_uInt32 nTipBufSize = lclGetBufferSize( nTipLen );
- if( nTipBufSize > 0 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- std::auto_ptr< sal_Char > pTipName;
- pTipName.reset( new sal_Char[ nTipBufSize ] );
- pS->Read( pTipName.get(), nTipBufSize );
- rec.controlTip = lclCreateOUString( pTipName.get(), nTipLen );
- }
- // control id
- sal_uInt32 nCntrlIdSize = lclGetBufferSize( nCntrlIdLen );
- if( nCntrlIdSize > 0 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- pS->SeekRel( nCntrlIdSize );
- }
- // control source name
- sal_uInt32 nCtrlSrcBufSize = lclGetBufferSize( nCtrlSrcLen );
- if( nCtrlSrcBufSize > 0 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- std::vector< sal_Char > pCtrlSrcName( nCtrlSrcBufSize );
- pS->Read( &pCtrlSrcName[0], nCtrlSrcBufSize );
- rec.sCtrlSource = lclCreateOUString( &pCtrlSrcName[0], nCtrlSrcLen );
- OSL_TRACE("*** *** *** ControlSourceName -> %s ", rtl::OUStringToOString( rec.sCtrlSource, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- // row source name
- sal_uInt32 nRowSrcBufSize = lclGetBufferSize( nRowSrcLen );
- if( nRowSrcBufSize > 0 )
- {
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- std::vector< sal_Char > pRowSrcName( nRowSrcBufSize );
- pS->Read( &pRowSrcName[0], nRowSrcBufSize );
- rec.sRowSource = lclCreateOUString( &pRowSrcName[0], nRowSrcLen );
- OSL_TRACE("*** *** *** RowSourceName -> %s ", rtl::OUStringToOString( rec.sRowSource, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
-
- ReadAlign( pS, pS->Tell() - nStartPos, 4 );
- rec.cName = lclCreateOUString(pName, nNameLen);
- delete[] pName;
- return true;
- }
-};
-
-class ContainerRecReader
-{
- public:
-
- virtual ~ContainerRecReader() {}
-
- virtual bool Read( OCX_ParentControl* pContainerControl, SvStorageStream *pS, std::vector< ClassTable >& rSiteClassInfo )
- {
- *pS >> nNoRecords;
- *pS >> nTotalLen;
- long nStart = pS->Tell();
- for ( sal_uInt32 nSite = 0; nSite < nNoRecords; )
- {
- FormObjectDepthTypeCount siteAndDepth;
- siteAndDepth.Read( pS );
- nSite += ( siteAndDepth.OptionalType.get() ? siteAndDepth.TypeOrCount : 1 );
- }
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
-
- for (sal_uInt32 nRecord = 0; nRecord < nNoRecords; ++nRecord)
- {
-
- ContainerRecord rec;
-
- OleSiteConcreteControl site;
- site.Read( rec, pS );
- if ( rec.nTypeIdent >= ( UNKNOWNCTRL + 1 ) )
- {
- sal_uInt16 nIndex = rec.nTypeIdent - ( UNKNOWNCTRL + 1 );
- if ( nIndex < rSiteClassInfo.size() )
- rec.nTypeIdent = rSiteClassInfo[ nIndex ].getTypeId();
- }
- OCX_Control* pControl = NULL;
- OSL_TRACE("** About to create control of type 0x%x with name %s from rec", rec.nTypeIdent, rtl::OUStringToOString( rec.cName, RTL_TEXTENCODING_UTF8 ).getStr() );
- if( pContainerControl->createFromContainerRecord( rec, pControl ) &&
- pControl )
- {
- // propagate doc shell from parent
- pControl->pDocSh = pContainerControl->pDocSh;
- pContainerControl->ProcessControl( pControl, pS, rec );
-
- }
- else if ( rec.nTypeIdent & 0x8000 )
- {
- // Skip ActiveX Controls we can't import
- SotStorageStreamRef oStream = pContainerControl->getContainedControlsStream();
- sal_uLong nStrmPos = oStream->Tell();
- oStream->Seek( nStrmPos + rec.nSubStreamLen );
- }
- else
- {
- OSL_FAIL("Terminating import, unexpected error");
- return false;
- }
- }
- return true;
- }
-
- ContainerRecReader():nNoRecords(0), nTotalLen(0){}
- protected:
- sal_uInt32 nNoRecords;
- sal_uInt32 nTotalLen;
-
- private:
-};
-
} // namespace
// ============================================================================
@@ -1240,46 +314,6 @@ void OCX_Control::FillSystemColors()
pColor[ 0x18 ] = rSett.GetHelpColor().GetColor();
}
-sal_uInt32 OCX_Control::ImportColor(sal_uInt32 nColor) const
-{
- sal_uInt8 nUpper = (sal_uInt8)( nColor >> 24 );
- if (nUpper & 0x80) //Palette color, should be switch on bottom 24 bits
- {
- /*Might as well use my systems ones in the absence of any other ideas*/
- nColor = nColor&0x00FFFFFF;
- DBG_ASSERT (nColor <= 24,"Unknown Palette Index");
- if (nColor > 24)
- nColor = 0xFFFFFF;
- else
- nColor = pColor[nColor];
- }
- else
- {
- //Stored in bgr! rather than rgb
- nColor = SwapColor(nColor);
- }
- return nColor;
-}
-
-sal_Int16 OCX_FontData::ImportAlign(sal_uInt8 _nJustification) const
-{
- sal_Int16 nRet;
- switch (_nJustification)
- {
- default:
- case 1:
- nRet = 0;
- break;
- case 2:
- nRet = 2;
- break;
- case 3:
- nRet = 1;
- break;
- }
- return nRet;
-}
-
sal_uInt8 OCX_FontData::ExportAlign(sal_Int16 nAlign) const
{
sal_Int8 nRet;
@@ -1328,115 +362,6 @@ sal_uInt32 OCX_Control::ExportColor(sal_uInt32 nColor) const
return nColor;
}
-sal_Bool OCX_Control::Import(
- const uno::Reference< lang::XMultiServiceFactory > &rServiceFactory,
- uno::Reference< form::XFormComponent > &rFComp, awt::Size &rSz)
-{
-
- if(msFormType.getLength() == 0)
- return sal_False;
-
- rSz.Width = nWidth;
- rSz.Height = nHeight;
-
- uno::Reference<uno::XInterface> xCreate =
- rServiceFactory->createInstance(msFormType);
- if (!xCreate.is())
- return sal_False;
-
- rFComp = uno::Reference<form::XFormComponent>(xCreate,uno::UNO_QUERY);
- if (!rFComp.is())
- return sal_False;
- uno::Reference<beans::XPropertySet> xPropSet(xCreate,uno::UNO_QUERY);
- if (!xPropSet.is())
- return sal_False;
- return Import(xPropSet);
-}
-
-sal_Bool OCX_Control::Import(uno::Reference<container::XNameContainer> &rDialog
- )
-{
- uno::Reference<beans::XPropertySet > xDlgProps( rDialog, uno::UNO_QUERY);
-
-
- uno::Reference<lang::XMultiServiceFactory>
- xFactory(rDialog, uno::UNO_QUERY);
-
- uno::Reference<uno::XInterface> xCreate =
- xFactory->createInstance(msDialogType);
- if (!xCreate.is())
- return sal_False;
-
- uno::Reference<awt::XControlModel> xModel(xCreate, uno::UNO_QUERY);
- if (!xModel.is())
- return sal_False;
-
- /* #147900# sometimes insertion of a control fails due to existing name,
- do not break entire form import then... */
- try
- {
- rDialog->insertByName(sName, uno::makeAny(xModel));
- }
- catch( uno::Exception& )
- {
- DBG_ERRORFILE(
- ByteString( "OCX_Control::Import - cannot insert control \"" ).
- Append( ByteString( sName, RTL_TEXTENCODING_UTF8 ) ).
- Append( '"' ).GetBuffer() );
- }
-
- uno::Reference<beans::XPropertySet> xPropSet(xCreate, uno::UNO_QUERY);
-
- if (!xPropSet.is())
- return sal_False;
-
- if (!Import(xPropSet))
- return sal_False;
-
- uno::Any aTmp;
-
- GraphicHelper gHelper( pDocSh->GetModel() );
-
- awt::Point aAppFontPos = gHelper.convertHmmToAppFont( awt::Point( mnLeft, mnTop ) );
- aTmp <<= sal_Int32( aAppFontPos.X );
- xPropSet->setPropertyValue(WW8_ASCII2STR("PositionX"), aTmp);
- aTmp <<= sal_Int32( aAppFontPos.Y );
- xPropSet->setPropertyValue(WW8_ASCII2STR("PositionY"), aTmp);
-
- awt::Size aAppFontSize = gHelper.convertHmmToAppFont( awt::Size( nWidth, nHeight ) );
- aTmp <<= sal_Int32( aAppFontSize.Width ); // 100thmm
- xPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
- aTmp <<= sal_Int32( aAppFontSize.Height); //100th mm
- xPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
- if ( msToolTip.Len() > 0 )
- xPropSet->setPropertyValue(WW8_ASCII2STR("HelpText"), uno::Any(OUString(msToolTip)));
-
- if ( mnStep )
- {
- aTmp <<= mnStep;
- xPropSet->setPropertyValue(WW8_ASCII2STR("Step"), aTmp);
- }
-
- try
- {
- xPropSet->setPropertyValue(WW8_ASCII2STR("EnableVisible"), uno::makeAny( mbVisible ) );
- }
- catch( uno::Exception& )
- {
- }
- return sal_True;
-}
-
-sal_Int16 OCX_Control::ImportBorder(sal_uInt16 nSpecialEffect,
- sal_uInt16 nBorderStyle) const
-{
- if ((nSpecialEffect == 0) && (nBorderStyle == 0))
- return 0; //No Border
- else if ((nSpecialEffect == 0) && (nBorderStyle == 1))
- return 2; //Flat Border
- return 1; //3D Border
-}
-
sal_uInt8 OCX_Control::ExportBorder(sal_uInt16 nBorder,sal_uInt8 &rBorderStyle)
const
{
@@ -1459,22 +384,11 @@ sal_uInt8 OCX_Control::ExportBorder(sal_uInt16 nBorder,sal_uInt8 &rBorderStyle)
return nRet;
}
-sal_Int16 OCX_Control::ImportSpecEffect( sal_uInt8 nSpecialEffect ) const
-{
- return (nSpecialEffect == 0) ? 2 : 1;
-}
-
sal_uInt8 OCX_Control::ExportSpecEffect( sal_Int16 nApiEffect ) const
{
return (nApiEffect == 2) ? 0 : 2;
}
-sal_Bool OCX_Control::ReadFontData(SvStorageStream *pS)
-{
- return aFontData.Read(pS);
-}
-
-
const uno::Reference< drawing::XDrawPage >&
SvxMSConvertOCXControls::GetDrawPage()
{
@@ -1584,53 +498,6 @@ const uno::Reference< container::XIndexContainer >&
return xFormComps;
}
-sal_Bool OCX_CommandButton::Import( com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- // fake transparent push button by setting window background color
- if( !fBackStyle )
- mnBackColor = 0x80000005;
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- sal_Bool bTemp;
- if ((!(fEnabled)) || (fLocked))
- bTemp = sal_False;
- else
- bTemp = sal_True;
- aTmp = bool2any(bTemp);
-
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- bTemp = fWordWrap != 0;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
-
- if (pCaption)
- {
- aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
- }
-
- aTmp = bool2any( mbTakeFocus );
- rPropSet->setPropertyValue( WW8_ASCII2STR( "FocusOnClick" ), aTmp );
-
- aFontData.Import(rPropSet);
-
- if ( sImageUrl.getLength() )
- {
- aTmp <<= sImageUrl;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
- }
- return sal_True;
-}
-
sal_Bool OCX_GroupBox::Export(SvStorageRef& /* rObj */,
const uno::Reference< beans::XPropertySet >& /* rPropSet */,
const awt::Size& /* rSize */ )
@@ -1969,105 +836,6 @@ void lcl_ApplyListSourceAndBindableStuff( uno::Reference< frame::XModel >& xMode
}
}
-sal_Bool OCX_OptionButton::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- // background color: fBackStyle==0 -> transparent
- if( fBackStyle )
- aTmp <<= ImportColor(mnBackColor);
- else
- aTmp = uno::Any();
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- sal_Bool bTemp;
- if ((!(fEnabled)) || (fLocked))
- bTemp = sal_False;
- else
- bTemp = sal_True;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- bTemp = fWordWrap != 0;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- aTmp <<= ImportSpecEffect( nSpecialEffect );
- rPropSet->setPropertyValue( WW8_ASCII2STR("VisualEffect"), aTmp);
-
- if (pValue)
- {
- sal_Int16 nTmp = pValue[0]-0x30;
- aTmp <<= nTmp;
- if (!bSetInDialog)
- rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
- else
- {
- // dialog ( but we might be using the form model )
- if ( rPropSet->getPropertySetInfo()->hasPropertyByName( WW8_ASCII2STR("DefaultState") ) )
- rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
- else
- rPropSet->setPropertyValue( WW8_ASCII2STR("State"), aTmp);
- }
- }
- // If this is a dialog control then we need to set a groupname *always*
- rtl::OUString sGroupName = lclCreateOUString( pGroupName, nGroupNameLen );
- if ( GetInDialog() ) // Userform/Dialog
- {
- // By default groupnames are not set in Excel, it's not unusual to have
- // a number of groups of radiobuttons located inside frame ( or other container
- // controls ) where there is *no* specific groupname set for the radiobuttons.
- // But... there is implicit grouping for radio buttons in seperate containers
- // e.g. radio buttons in a frame are by default in the same group.
- // Unfortunately in openoffice there are no containers below the dialog itself :-(
- // To ensure correct grouping for imported radiobuttons either with no groupname
- // or identical groupnames that are in separate containers we *must* ensure
- // that a suitable groupname is applied.
- // Because controlNames are unique even across different containers we can use the
- // controls container (e.g. parent) name as a prefix for a group name
- rtl::OUString sParentName = msParentName;
- sGroupName = sParentName.concat( C2U( ":" ) ).concat( sGroupName );
- }
- if ( sGroupName.getLength() == 0 )
- sGroupName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultGroup" ));
- OSL_TRACE("RadioButton %s has groupname %s",
- rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sGroupName, RTL_TEXTENCODING_UTF8 ).getStr() );
- try
- {
- aTmp <<= sGroupName;
- rPropSet->setPropertyValue( WW8_ASCII2STR("GroupName"), aTmp);
- }
- catch( uno::Exception& )
- {
- }
-
- if (pCaption)
- {
- aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
- }
-
- // #i40279# always centered vertically
- aTmp <<= ::com::sun::star::style::VerticalAlignment_MIDDLE;
- rPropSet->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp );
-
- uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
- lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
- if ( sImageUrl.getLength() )
- {
- aTmp <<= sImageUrl;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
- }
-
- aFontData.Import(rPropSet);
- return sal_True;
-}
-
sal_Bool OCX_OptionButton::WriteContents(SvStorageStreamRef &rContents,
const uno::Reference< beans::XPropertySet > &rPropSet,
const awt::Size &rSize)
@@ -2234,98 +1002,6 @@ sal_Bool OCX_OptionButton::Export(SvStorageRef &rObj,
return WriteContents(xContents, rPropSet, rSize);
}
-
-sal_Bool OCX_TextBox::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- aTmp = bool2any( fEnabled != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- aTmp = bool2any( fLocked != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
-
- aTmp = bool2any( fHideSelection != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
-
- aTmp <<= ImportColor( nBorderColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
-
- aTmp = bool2any( fMultiLine != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
-
- sal_uInt16 nTmp = static_cast<sal_uInt16>(nMaxLength);
- aTmp <<= nTmp;
- rPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);
-
-
- sal_Bool bTemp1,bTemp2;
- uno::Any aBarsH,aBarsV;
- switch(nScrollBars)
- {
- case 1:
- bTemp1 = sal_True;
- bTemp2 = sal_False;
- break;
- case 2:
- bTemp1 = sal_False;
- bTemp2 = sal_True;
- break;
- case 3:
- bTemp1 = sal_True;
- bTemp2 = sal_True;
- break;
- case 0:
- default:
- bTemp1 = sal_False;
- bTemp2 = sal_False;
- break;
- }
-
- aBarsH = bool2any(bTemp1);
- aBarsV = bool2any(bTemp2);
- rPropSet->setPropertyValue( WW8_ASCII2STR("HScroll"), aBarsH);
- rPropSet->setPropertyValue( WW8_ASCII2STR("VScroll"), aBarsV);
-
- nTmp = nPasswordChar;
- aTmp <<= nTmp;
- rPropSet->setPropertyValue( WW8_ASCII2STR("EchoChar"), aTmp);
-
- if (pValue)
- {
- aTmp <<= lclCreateOUString( pValue, nValueLen );
- // DefaultText seems to no longer be in UnoEditControlModel
- if ( bSetInDialog )
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("Text"), aTmp);
- }
- else
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
- }
- }
-
- if ( sImageUrl.getLength() )
- {
- aTmp <<= sImageUrl;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
- }
-
- aFontData.Import(rPropSet);
- return sal_True;
-}
-
sal_Bool OCX_TextBox::WriteContents(SvStorageStreamRef &rContents,
const uno::Reference< beans::XPropertySet > &rPropSet,
const awt::Size &rSize)
@@ -2659,62 +1335,6 @@ sal_Bool OCX_FieldControl::Export(SvStorageRef &rObj,
return WriteContents(xContents, rPropSet, rSize);
}
-
-
-sal_Bool OCX_ToggleButton::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- aTmp = bool2any(true);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Toggle"), aTmp );
-
- sal_Bool bTemp;
- if ((!(fEnabled)) || (fLocked))
- bTemp = sal_False;
- else
- bTemp = sal_True;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- bTemp = fWordWrap != 0;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- // fake transparent toggle button by setting window background color
- if( !fBackStyle )
- mnBackColor = 0x80000005;
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- if (pValue)
- {
- sal_Int16 nTmp=pValue[0]-0x30;
- //aTmp <<= nTmp == 1;
- aTmp <<= nTmp;
- rPropSet->setPropertyValue( WW8_ASCII2STR("State"), aTmp);
- }
-
- if (pCaption)
- {
- aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
- }
-
- aFontData.Import(rPropSet);
-
- if ( sImageUrl.getLength() )
- {
- aTmp <<= sImageUrl;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
- }
- return sal_True;
-}
-
sal_Bool OCX_ToggleButton::Export(
SvStorageRef &rObj, const uno::Reference< beans::XPropertySet> &rPropSet,
const awt::Size& rSize )
@@ -2863,115 +1483,6 @@ sal_Bool OCX_ToggleButton::WriteContents(SvStorageStreamRef &rContents,
return bRet;
}
-sal_Bool OCX_Label::Import(uno::Reference< beans::XPropertySet > &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- sal_Bool bTemp;
- if ((!(fEnabled)) || (fLocked))
- bTemp = sal_False;
- else
- bTemp = sal_True;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- // background color: fBackStyle==0 -> transparent
- if( fBackStyle )
- {
- aTmp <<= ImportColor(mnBackColor);
- }
- else
- {
- // try fake transparent by using parents backColor
- if ( bSetInDialog && mpParent != NULL )
- {
- aTmp <<= ImportColor( mpParent->mnBackColor );
- }
- else
- {
- aTmp = uno::Any(); // use SO default
- }
- }
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
-
- aTmp <<= ImportColor( nBorderColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
-
- bTemp=fWordWrap;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
-
- if (pCaption)
- {
- aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
- }
-
- aFontData.Import(rPropSet);
- return sal_True;
-}
-
-sal_Bool OCX_ComboBox::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
-
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- aTmp = bool2any(fEnabled != 0);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- aTmp = bool2any(fLocked != 0);
- rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
-
- aTmp = bool2any( nDropButtonStyle != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Dropdown"), aTmp);
-
- aTmp = bool2any( fHideSelection != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- if (pValue)
- {
- aTmp <<= lclCreateOUString( pValue, nValueLen );
- if ( bSetInDialog )
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("Text"), aTmp);
- }
- else
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
- }
- }
-
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
-
- aTmp <<= ImportColor( nBorderColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
-
- sal_Int16 nTmp=static_cast<sal_Int16>(nMaxLength);
- aTmp <<= nTmp;
- rPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);
-
- aFontData.Import(rPropSet);
- uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
- lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
- return sal_True;
-}
-
sal_Bool OCX_ComboBox::WriteContents(SvStorageStreamRef &rContents,
const uno::Reference< beans::XPropertySet > &rPropSet,
const awt::Size &rSize)
@@ -3148,52 +1659,6 @@ sal_Bool OCX_ComboBox::Export(SvStorageRef &rObj,
return WriteContents(xContents, rPropSet, rSize);
}
-
-
-sal_Bool OCX_ListBox::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
-
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- sal_Bool bTmp=fEnabled;
- aTmp = bool2any(bTmp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- bTmp=fLocked;
- aTmp = bool2any(bTmp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- sal_Bool bTemp = nMultiState;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiSelection"), aTmp);
-
-#if 0 //Don't delete this for now until I figure out if I can make this
- if (pValue)
- {
- aTmp <<= lclCreateOUString( pValue, nValueLen );
- xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
- }
-#endif
-
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
-
- aTmp <<= ImportColor( nBorderColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
- uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
- lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
- aFontData.Import(rPropSet);
- return sal_True;
-}
-
sal_Bool OCX_ListBox::WriteContents(SvStorageStreamRef &rContents,
const uno::Reference< beans::XPropertySet > &rPropSet,
const awt::Size &rSize)
@@ -3365,717 +1830,6 @@ sal_Bool OCX_ListBox::Export(SvStorageRef &rObj,
return WriteContents(xContents, rPropSet, rSize);
}
-sal_Bool OCX_Control::Read(SvStorageStream *pS)
-{
- sal_uInt16 nIdentifier, nFixedAreaLen;
- *pS >> nIdentifier;
- DBG_ASSERT(nStandardId==nIdentifier,
- "A control that has a different identifier");
- *pS >> nFixedAreaLen;
- pS->SeekRel(nFixedAreaLen);
- return true;
-}
-
-sal_Bool OCX_ModernControl::Read(SvStorageStream *pS)
-{
- long nStart = pS->Tell();
- *pS >> nIdentifier;
- DBG_ASSERT(nIdentifier==nStandardId,
- "A control that has a different identifier");
- *pS >> nFixedAreaLen;
- pS->Read(pBlockFlags,8);
-
- if (pBlockFlags[0] & 0x01)
- {
- sal_uInt8 nTemp;
- *pS >> nTemp;
-
- fEnabled = (nTemp & 0x02) >> 1;
- fLocked = (nTemp & 0x04) >> 2;
- fBackStyle = (nTemp & 0x08) >> 3;
-
- *pS >> nTemp;
-
- fColumnHeads = (nTemp & 0x04) >> 2;
- fIntegralHeight = (nTemp & 0x08) >> 3;
- fMatchRequired = (nTemp & 0x10) >> 4;
- fAlignment = (nTemp & 0x20) >> 5;
-
- *pS >> nTemp;
-
- fDragBehaviour = (nTemp & 0x08) >> 3;
- fEnterKeyBehaviour = (nTemp & 0x10) >> 4;
- fEnterFieldBehaviour = (nTemp & 0x20) >> 5;
- fTabKeyBehaviour = (nTemp & 0x40) >> 6;
- fWordWrap = (nTemp & 0x80) >> 7;
-
- *pS >> nTemp;
- fSelectionMargin = (nTemp & 0x04) >> 2;
- fAutoWordSelect = (nTemp & 0x08) >> 3;
- fAutoSize = (nTemp & 0x10) >> 4;
- fHideSelection = (nTemp & 0x20) >> 5;
- fAutoTab = (nTemp & 0x40) >> 6;
- fMultiLine = (nTemp & 0x80) >> 7;
-
- }
-
- /*If any of these are set they follow eachother in this order one after
- another padded out to the next U32 boundary with 0's
- U8 can abut each other U16 must start on a U16 boundary and are padded to
- that with 0's. A standardish word alignment structure*/
-
- if (pBlockFlags[0] & 0x02)
- *pS >> mnBackColor;
- if (pBlockFlags[0] & 0x04)
- *pS >> mnForeColor;
- if (pBlockFlags[0] & 0x08)
- *pS >> nMaxLength;
-
- if (pBlockFlags[0] & 0x10)
- *pS >> nBorderStyle;
- if (pBlockFlags[0] & 0x20)
- *pS >> nScrollBars;
- if (pBlockFlags[0] & 0x40)
- *pS >> nStyle;// (UI 0 == Data 3, UI 2 = Data 7)
- if (pBlockFlags[0] & 0x80)
- *pS >> nMousePointer;
-
- if (pBlockFlags[1] & 0x02)
- *pS >> nPasswordChar; //HUH ??? always 0 ??? not sure maybe just padding
-
- if (pBlockFlags[1] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nListWidth;
- }
-
- if (pBlockFlags[1] & 0x08)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nBoundColumn;
- }
- if (pBlockFlags[1] & 0x10)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nTextColumn;
- }
- if (pBlockFlags[1] & 0x20)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nColumnCount;
- }
- if (pBlockFlags[1] & 0x40)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nListRows;
- }
- if (pBlockFlags[1] & 0x80)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nUnknown8; //something to do with ColumnWidths
- }
- if (pBlockFlags[2] & 0x01)
- *pS >> nMatchEntry;
- if (pBlockFlags[2] & 0x02)
- *pS >> nListStyle;
- if (pBlockFlags[2] & 0x04)
- *pS >> nShowDropButtonWhen;
- if (pBlockFlags[2] & 0x10)
- *pS >> nDropButtonStyle;
- if (pBlockFlags[2] & 0x20)
- *pS >> nMultiState;
-
- bool bValue = (pBlockFlags[2] & 0x40) != 0;
- if (bValue)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nValueLen;
- }
- bool bCaption = (pBlockFlags[2] & 0x80) != 0;
- if (bCaption)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nCaptionLen;
- }
- if (pBlockFlags[3] & 0x01)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nHorzPos;
- *pS >> nVertPos;
- }
- if (pBlockFlags[3] & 0x02)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nBorderColor;
- }
- if (pBlockFlags[3] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4); // NEW
- *pS >> nSpecialEffect;
- pS->SeekRel( 3 ); // special effect is 32bit, not 8bit
- }
- if (pBlockFlags[3] & 0x08)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nIcon;
- DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
- }
- if (pBlockFlags[3] & 0x10)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nPicture;
- DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
- }
- if (pBlockFlags[3] & 0x20)
- *pS >> nAccelerator;
- /*
- if (pBlockFlags[3] & 0x80)
- *pS >> nUnknown9;
- */
- bool bGroupName = (pBlockFlags[4] & 0x01) != 0;
- if (bGroupName)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nGroupNameLen;
- }
-
- //End
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nWidth;
- *pS >> nHeight;
-
- if (bValue)
- lclReadCharArray( *pS, pValue, nValueLen, pS->Tell() - nStart);
-
- if (bCaption)
- lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
-
- if (bGroupName)
- lclReadCharArray( *pS, pGroupName, nGroupNameLen, pS->Tell() - nStart);
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
- if (nIcon)
- {
- pS->Read(pIconHeader,20);
- *pS >> nIconLen;
- pIcon = new sal_uInt8[nIconLen];
- pS->Read(pIcon,nIconLen);
- }
-
- if (nPicture)
- {
- pS->Read(pPictureHeader,20);
- *pS >> nPictureLen;
- long imagePos = pS->Tell();
- mxGrfObj = lcl_readGraphicObject( pS );
- if( mxGrfObj.is() )
- {
- sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
- sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
- }
- // make sure the stream position should be pointing after the image
- pS->Seek( imagePos + nPictureLen );
- }
-
- return sal_True;
-}
-
-
-sal_Bool OCX_CommandButton::Read(SvStorageStream *pS)
-{
- long nStart = pS->Tell();
- *pS >> nIdentifier;
- DBG_ASSERT(nStandardId==nIdentifier,
- "A control that has a different identifier");
- *pS >> nFixedAreaLen;
- pS->Read(pBlockFlags,4);
-
-
- if (pBlockFlags[0] & 0x01)
- *pS >> mnForeColor;
- if (pBlockFlags[0] & 0x02)
- *pS >> mnBackColor;
-
- if (pBlockFlags[0] & 0x04)
- {
- sal_uInt8 nTemp;
- *pS >> nTemp;
- fEnabled = (nTemp&0x02)>>1;
- fLocked = (nTemp&0x04)>>2;
- fBackStyle = (nTemp&0x08)>>3;
- *pS >> nTemp;
- *pS >> nTemp;
- fWordWrap = (nTemp&0x80)>>7;
- *pS >> nTemp;
- fAutoSize = (nTemp&0x10)>>4;
- }
-
- bool bCaption = (pBlockFlags[0] & 0x08) != 0;
- if (bCaption)
- {
- *pS >> nCaptionLen;
- }
- if (pBlockFlags[0] & 0x10) /*Picture Position, a strange mechanism here*/
- {
- *pS >> nVertPos;
- *pS >> nHorzPos;
- }
-
- if (pBlockFlags[0] & 0x40) /*MousePointer*/
- *pS >> nMousePointer;
-
- if (pBlockFlags[0] & 0x80)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nPicture;
- }
-
- if (pBlockFlags[1] & 0x01)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nAccelerator;
- }
-
- // "take focus on click" is directly in content flags, not in option field...
- mbTakeFocus = (pBlockFlags[1] & 0x02) == 0; // option is on, if flag is not set
-
- if (pBlockFlags[1] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nIcon;
- }
-
- if (bCaption)
- lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nWidth;
- *pS >> nHeight;
-
- if (nIcon)
- {
- pS->Read(pIconHeader,20);
- *pS >> nIconLen;
- pIcon = new sal_uInt8[nIconLen];
- pS->Read(pIcon,nIconLen);
- }
-
- if (nPicture)
- {
- pS->Read(pPictureHeader,20);
- *pS >> nPictureLen;
- long imagePos = pS->Tell();
- mxGrfObj = lcl_readGraphicObject( pS );
- if( mxGrfObj.is() )
- {
- sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
- sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
- }
- // make sure the stream position should be pointing after the image
- pS->Seek( imagePos + nPictureLen );
- }
-
- return sal_True;
-}
-
-sal_Bool OCX_Label::Read(SvStorageStream *pS)
-{
- long nStart = pS->Tell();
- *pS >> nIdentifier;
- DBG_ASSERT(nStandardId==nIdentifier,
- "A control that has a different identifier");
- *pS >> nFixedAreaLen;
- pS->Read(pBlockFlags,4);
-
-
- if (pBlockFlags[0] & 0x01)
- *pS >> mnForeColor;
- if (pBlockFlags[0] & 0x02)
- *pS >> mnBackColor;
-
-
- if (pBlockFlags[0] & 0x04)
- {
- sal_uInt8 nTemp;
- *pS >> nTemp;
- fEnabled = (nTemp&0x02)>>1;
- fLocked = (nTemp&0x04)>>2;
- fBackStyle = (nTemp&0x08)>>3;
- *pS >> nTemp;
- *pS >> nTemp;
- fWordWrap = (nTemp&0x80)>>7;
- *pS >> nTemp;
- fAutoSize = (nTemp&0x10)>>4;
- }
- bool bCaption = (pBlockFlags[0] & 0x08) != 0;
- if (bCaption)
- *pS >> nCaptionLen;
-
- if (pBlockFlags[0] & 0x10)
- {
- *pS >> nVertPos;
- *pS >> nHorzPos;
- }
-
- if (pBlockFlags[0] & 0x40)
- *pS >> nMousePointer;
-
- if (pBlockFlags[0] & 0x80)
- {
- ReadAlign(pS,pS->Tell() - nStart, 4);
- *pS >> nBorderColor;
- }
-
- if (pBlockFlags[1] & 0x01)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nBorderStyle;
- }
-
- if (pBlockFlags[1] & 0x02)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nSpecialEffect;
- }
-
- if (pBlockFlags[1] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nPicture;
- }
-
- if (pBlockFlags[1] & 0x08)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nAccelerator;
- }
-
- if (pBlockFlags[1] & 0x10)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nIcon;
- }
-
- if (bCaption)
- lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nWidth;
- *pS >> nHeight;
-
- if (nPicture)
- {
- pS->Read(pPictureHeader,20);
- *pS >> nPictureLen;
- long imagePos = pS->Tell();
- mxGrfObj = lcl_readGraphicObject( pS );
- if( mxGrfObj.is() )
- {
- sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
- sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
- }
- // make sure the stream position should be pointing after the image
- pS->Seek( imagePos + nPictureLen );
- }
- if (nIcon)
- {
- pS->Read(pIconHeader,20);
- *pS >> nIconLen;
- pIcon = new sal_uInt8[nIconLen];
- pS->Read(pIcon,nIconLen);
- }
-
- return sal_True;
-}
-
-TypeName::TypeName(sal_Char *pName, sal_uInt32 nStoreId, sal_uInt32 nLen, sal_uInt16 nType, sal_Int32 nLeft,
- sal_Int32 nTop)
- : msName(lclCreateOUString(pName, nLen)), mnType(nType), mnLeft(nLeft),
- mnTop(nTop),mnStoreId(nStoreId)
-{
-}
-
-OCX_MultiPage::OCX_MultiPage( SotStorageRef& parent,
- const ::rtl::OUString& storageName,
- const ::rtl::OUString& sN,
- const uno::Reference< container::XNameContainer > &rDialog,
- OCX_Control* pParent):
- OCX_ParentControl(parent, storageName, sN, rDialog, pParent ), bHasTabs( true )
-
-{
- msDialogType = C2U("com.sun.star.awt.UnoMultiPageModel");
- mnForeColor = 0x80000012L,
- mnBackColor = 0x8000000FL;
- bSetInDialog = true;// UserForm control only
- aFontData.SetHasAlign(sal_True);
- nActiveTab = 0;
- // open up the 'x' stream
- mXStream = mContainerStorage->OpenSotStream(
- String(RTL_CONSTASCII_STRINGPARAM("x"),
- RTL_TEXTENCODING_MS_1252),
- STREAM_STD_READ | STREAM_NOCREATE);
-}
-
-void OCX_MultiPage::ProcessControl(OCX_Control* pControl, SvStorageStream* /* pS */, ContainerRecord& rec )
-{
- SotStorageStreamRef oStream = mContainedControlsStream;
-
- if ( rec.nTypeIdent == TABSTRIP )
- {
- // TabStrip reads the 'o' stream
- OCX_TabStrip oTabStrip;
- oTabStrip.sName = C2S("FromMultiPage-o");
- oTabStrip.Read( mContainedControlsStream );
- sCaptions = oTabStrip.msItems;
- bHasTabs = oTabStrip.bHasTabs;
- nHeight = oTabStrip.nHeight;
- nWidth = oTabStrip.nWidth;
- }
- else if ( rec.nTypeIdent == PAGE )
- {
- OCX_Page *pPage = NULL;
- pPage = static_cast< OCX_Page* >( pControl );
- if ( pPage != NULL )
- {
- oStream = pPage->getContainerStream();;
- // Position of controls is relative to pos of this MuliPage
- // Control
- pPage->FullRead( oStream );
- // nWidth & nHeight seem to screw up multipage control
- pPage->nWidth = 0;
- pPage->nHeight = 0;
- pPage->mnBackColor = mnBackColor;
-
- mpControls.push_back( pPage );
- idToPage[ pPage->mnID ] = pPage;
- }
-
- }
- else
- {
- OSL_TRACE("!!!! Unsupported Control 0x%x ", rec.nTypeIdent);
- OSL_FAIL("MultiPage error expected Page control");
- }
-
-}
-
-sal_Bool OCX_MultiPage::Read(SvStorageStream *pS)
-{
- // Unlike the other containers e.g. UserForm & Frame
- // the o stream is does not contain info for the contained controls
- // 'o' stream contains a tabstrip control
- // 'f' stream as usual ( info about the containees )
- // '01..09' ( etc. ) these streams contain the page controls
- // 'x' stream, this contains an array of properties for each page followed
- // by a set of properties for the multipage control itself
-
- // read the 'f' stream
- OCX_ParentControl::Read(pS);
-
- // Read the 'x' stream
- // consists of
- // a) nTabs + 1 PageProperties ( which are little use to us )
- // => skip
- // b) a MutliPageProperty ( which contains at least the page count and
- // IDs of the pages ( and order ) - useful for associating correct page
- // with correct tab
-
-
- OCX_Control skip(C2S("Dummy"));
- sal_Int32 nPagePropsToRead = sCaptions.size() + 1;
- for ( sal_Int32 page = 0; page < nPagePropsToRead; ++page )
- skip.Read( mXStream );
- MultiPageProps multiPage;
- multiPage.Read( mXStream );
- mPageIds = multiPage.mnIDs;
- return true;
-}
-
-
-sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
- if ( !bHasTabs )
- rPropSet->setPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM("Decoration")), uno::makeAny( sal_False ) );
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
- // apply caption/titles to pages
- std::vector<sal_Int32>::iterator itCtrlId = mPageIds.begin();
- std::vector<sal_Int32>::iterator itCtrlId_end = mPageIds.end();
- std::vector< rtl::OUString >::iterator itCaption = sCaptions.begin();
- mpControls.clear();
- // need to sort the controls according to the order of the ids
- for ( sal_Int32 index = 1 ; ( sCaptions.size() == idToPage.size() ) && itCtrlId != itCtrlId_end; ++itCtrlId, ++itCaption, ++index )
- {
- boost::unordered_map< sal_Int32, OCX_Page* >::iterator it = idToPage.find( *itCtrlId );
- if ( it != idToPage.end() )
- {
- it->second->msTitle = *itCaption;
- if ( it->second->mbVisible )
- nActiveTab = index;
- mpControls.push_back( it->second );
-
- }
- }
-
- OCX_ParentControl::Import( rPropSet );
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiPageValue"), uno::makeAny( nActiveTab ));
- return sal_True;
-}
-
-OCX_Page::OCX_Page( SotStorageRef& parent,
- sal_Int32 nId,
- const ::rtl::OUString& sN,
- const uno::Reference< container::XNameContainer > &rDialog,
- OCX_Control* pParent):
- OCX_ParentControl(parent, createSubStreamName( nId ), sN, rDialog, pParent ), mnID( nId )
-{
- msDialogType = C2U("com.sun.star.awt.UnoPageModel");
- mnForeColor = 0x80000012,
- mnBackColor = 0x8000000F,
- bSetInDialog = true;// UserForm control only
- aFontData.SetHasAlign(sal_True);
-}
-
-
-sal_Bool OCX_Page::Read(SvStorageStream *pS)
-{
- return OCX_ParentControl::Read(pS);
-}
-
-sal_Bool OCX_Page::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet>
- &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
-
- if (msTitle.getLength())
- rPropSet->setPropertyValue( WW8_ASCII2STR("Title"), uno::makeAny( msTitle ) );
-
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- // Calls import on contained controls
- OCX_ParentControl::Import( rPropSet );
- return sal_True;
-
-}
-
-OCX_Frame::OCX_Frame( SotStorageRef& parent,
- const ::rtl::OUString& storageName,
- const ::rtl::OUString& sN,
- const uno::Reference< container::XNameContainer > &rDialog, OCX_Control* pParent): OCX_ParentControl(parent, storageName, sN, rDialog, pParent )
-{
- msDialogType = C2U("com.sun.star.awt.UnoFrameModel");
- mnForeColor = 0x80000012;
- mnBackColor = 0x8000000F;
- bSetInDialog = true;// UserForm control only
- aFontData.SetHasAlign(sal_True);
-}
-
-
-sal_Bool OCX_Frame::Read(SvStorageStream *pS)
-{
- return OCX_ParentControl::Read( pS );
-}
-
-sal_Bool OCX_Frame::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
- if ( pCaption )
- {
- aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
- }
-
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- // Calls import on contained controls
- OCX_ParentControl::Import( rPropSet );
- return sal_True;
-}
-
-OCX_UserForm::OCX_UserForm( SotStorageRef& parent,
- const OUString& storageName,
- const OUString& sN,
- const ::uno::Reference< container::XNameContainer > &rDialog,
- const ::uno::Reference< lang::XMultiServiceFactory >& rMsf):
- OCX_ParentControl(parent, storageName, sN, rDialog )
- {
- uno::Reference< beans::XPropertySet> xProps( rMsf, uno::UNO_QUERY);
- if ( xProps.is() )
- {
- xProps->getPropertyValue(C2S("DefaultContext")) >>= mxCtx;
- }
-}
-
-sal_Bool OCX_UserForm::Import(
- uno::Reference<container::XNameContainer> &rLib )
-{
- uno::Reference<beans::XPropertySet>
- xDialogPropSet(mxParent, uno::UNO_QUERY);
- if ( !xDialogPropSet.is() )
- return sal_False;
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- xDialogPropSet->setPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
- xDialogPropSet->setPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM("Title")), aTmp);
- aTmp <<= ImportColor(mnBackColor);
- xDialogPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- GraphicHelper gHelper( pDocSh->GetModel() );
-
- awt::Size aAppFontSize = gHelper.convertHmmToAppFont( awt::Size( nWidth, nHeight ) );
- aTmp <<= sal_Int32( aAppFontSize.Width ); //
- xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
- aTmp <<= sal_Int32( aAppFontSize.Height ); //100th mm
- xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
-
- if ( sImageUrl.getLength() )
- {
- aTmp <<= sImageUrl;
- xDialogPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
- }
-
- uno::Reference<beans::XPropertySet> xPropSet( mxParent, uno::UNO_QUERY );
- OCX_ParentControl::Import( xPropSet );
- uno::Reference< frame::XModel > xModel( pDocSh ? pDocSh->GetModel() : NULL );
-
- uno::Reference<io::XInputStreamProvider> xSource =
- xmlscript::exportDialogModel(mxParent, mxCtx, pDocSh->GetModel() );
- uno::Any aSourceAny(uno::makeAny(xSource));
- if (rLib->hasByName(sName))
- rLib->replaceByName(sName, aSourceAny);
- else
- rLib->insertByName(sName, aSourceAny);
-
- if ( sImageUrl.getLength() )
- {
- aTmp <<= sImageUrl;
- try
- {
- xDialogPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
- }
- catch( uno::Exception& )
- {
- OSL_TRACE("OCX_UserForm::Import, Image fails to import");
- }
- }
- return sal_True;
-}
-
sal_Bool OCX_Label::WriteContents(SvStorageStreamRef &rContents,
const uno::Reference< beans::XPropertySet > &rPropSet,
const awt::Size &rSize)
@@ -4456,76 +2210,6 @@ sal_Bool SvxMSConvertOCXControls::WriteOCXExcelKludgeStream(
return bRet;
}
-
-
-
-
-
-
-sal_Bool OCX_CheckBox::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- // background color: fBackStyle==0 -> transparent
- if( fBackStyle )
- aTmp <<= ImportColor(mnBackColor);
- else
- aTmp = uno::Any();
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- sal_Bool bTemp;
- if ((!(fEnabled)) || (fLocked))
- bTemp = sal_False;
- else
- bTemp = sal_True;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- bTemp = fWordWrap != 0;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- bTemp = nMultiState;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TriState"), aTmp);
-
- aTmp <<= ImportSpecEffect( nSpecialEffect );
- rPropSet->setPropertyValue( WW8_ASCII2STR("VisualEffect"), aTmp);
-
- if (pValue)
- {
- sal_Int16 nTmp=pValue[0]-0x30;
- aTmp <<= nTmp;
- if ( !bSetInDialog )
- rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
- else
- rPropSet->setPropertyValue( WW8_ASCII2STR("State"), aTmp);
- }
-
- if (pCaption)
- {
- aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
- }
-
- // #i40279# always centered vertically
- aTmp <<= ::com::sun::star::style::VerticalAlignment_MIDDLE;
- rPropSet->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp );
-
- aFontData.Import(rPropSet);
- if ( sImageUrl.getLength() )
- {
- aTmp <<= sImageUrl;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
- }
- return(sal_True);
-}
-
sal_Bool OCX_CheckBox::WriteContents(SvStorageStreamRef &rContents,
const uno::Reference< beans::XPropertySet > &rPropSet,
const awt::Size &rSize)
@@ -4693,105 +2377,6 @@ sal_Bool OCX_CheckBox::Export(SvStorageRef &rObj,
}
-sal_Bool OCX_FontData::Read(SvStorageStream *pS)
-{
- long nStart = pS->Tell();
- *pS >> nIdentifier;
- *pS >> nFixedAreaLen;
- pS->Read(pBlockFlags,4);
-
- bool bFontName = (pBlockFlags[0] & 0x01) != 0;
- if (bFontName)
- *pS >> nFontNameLen;
- if (pBlockFlags[0] & 0x02)
- {
- sal_uInt8 nTmp;
- *pS >> nTmp;
- fBold = nTmp & 0x01;
- fItalic = (nTmp & 0x02) >> 1;
- fUnderline = (nTmp & 0x04) >> 2;
- fStrike = (nTmp & 0x08) >> 3;
- fUnknown1 = (nTmp & 0xF0) >> 4;
- *pS >> nUnknown2;
- *pS >> nUnknown3;
- *pS >> nUnknown4;
- }
- if (pBlockFlags[0] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nFontSize;
- }
- else
- nFontSize = 240;
- if (pBlockFlags[0] & 0x10)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nLanguageID;
- }
- if (pBlockFlags[0] & 0x40)
- {
- *pS >> nJustification;
- }
- if (pBlockFlags[0] & 0x80) // font weight before font name
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nFontWeight;
- }
-
- if (bFontName)
- lclReadCharArray( *pS, pFontName, nFontNameLen, pS->Tell() - nStart);
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
- return(sal_True);
-}
-
-void OCX_FontData::Import(uno::Reference< beans::XPropertySet > &rPropSet)
-{
- uno::Any aTmp;
- if (pFontName)
- {
- aTmp <<= lclCreateOUString( pFontName, nFontNameLen );
- rPropSet->setPropertyValue( WW8_ASCII2STR("FontName"), aTmp);
- }
-
- if (bHasAlign)
- {
- sal_Int16 nAlign = ImportAlign(nJustification);
- aTmp <<= nAlign;
- rPropSet->setPropertyValue( WW8_ASCII2STR("Align"), aTmp);
- }
-
- if (fBold)
- {
- aTmp <<= awt::FontWeight::BOLD;
- rPropSet->setPropertyValue( WW8_ASCII2STR("FontWeight"), aTmp);
- }
-
- if (fItalic)
- {
- aTmp <<= (sal_Int16)awt::FontSlant_ITALIC;
- rPropSet->setPropertyValue( WW8_ASCII2STR("FontSlant"), aTmp);
- }
-
- if (fUnderline)
- {
- aTmp <<= awt::FontUnderline::SINGLE;
- rPropSet->setPropertyValue( WW8_ASCII2STR("FontUnderline"), aTmp);
- }
-
- if (fStrike)
- {
- aTmp <<= awt::FontStrikeout::SINGLE;
- rPropSet->setPropertyValue( WW8_ASCII2STR("FontStrikeout"), aTmp);
- }
-
- // very strange way of storing font sizes...
- // 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135
- // 8pt->165, 9pt->180, 10pt->195, 11pt->225, ...
- aTmp <<= sal_Int16( (nFontSize <= 30) ? 1 : ((nFontSize + 10) / 20) );
- rPropSet->setPropertyValue( WW8_ASCII2STR("FontHeight"), aTmp);
-}
-
sal_Bool OCX_FontData::Export(SvStorageStreamRef &rContent,
const uno::Reference< beans::XPropertySet > &rPropSet)
{
@@ -4871,601 +2456,6 @@ sal_Bool OCX_FontData::Export(SvStorageStreamRef &rContent,
return sal_True;
}
-
-sal_Bool HTML_TextBox::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- aTmp = bool2any( fEnabled != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- aTmp = bool2any( fLocked != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
-
- aTmp = bool2any( fHideSelection != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
-
- aTmp <<= ImportColor( nBorderColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
-
- aTmp = bool2any( fMultiLine != 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
-
- sal_uInt16 nTmp = static_cast<sal_uInt16>(nMaxLength);
- aTmp <<= nTmp;
- rPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);
-
-
- sal_Bool bTemp1,bTemp2;
- uno::Any aBarsH,aBarsV;
- switch(nScrollBars)
- {
- case 1:
- bTemp1 = sal_True;
- bTemp2 = sal_False;
- break;
- case 2:
- bTemp1 = sal_False;
- bTemp2 = sal_True;
- break;
- case 3:
- bTemp1 = sal_True;
- bTemp2 = sal_True;
- break;
- case 0:
- default:
- bTemp1 = sal_False;
- bTemp2 = sal_False;
- break;
- }
-
- aBarsH = bool2any(bTemp1);
- aBarsV = bool2any(bTemp2);
- rPropSet->setPropertyValue( WW8_ASCII2STR("HScroll"), aBarsH);
- rPropSet->setPropertyValue( WW8_ASCII2STR("VScroll"), aBarsV);
-
- nTmp = nPasswordChar;
- aTmp <<= nTmp;
- rPropSet->setPropertyValue( WW8_ASCII2STR("EchoChar"), aTmp);
-
- if (pValue)
- {
- aTmp <<= lclCreateOUString( pValue, nValueLen );
- // DefaultText seems to no longer be in UnoEditControlModel
- if ( bSetInDialog )
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("Text"), aTmp);
- }
- else
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
- }
- }
-
- // aFontData.Import(rPropSet);
- return sal_True;
-}
-
-sal_Bool HTML_TextBox::Read(SotStorageStream * /*pS*/)
-{
- return sal_True;
-}
-
-sal_Bool HTML_TextBox::ReadFontData(SotStorageStream * /*pS*/)
-{
- return sal_True;
-}
-
-// HTML_Select
-sal_Bool HTML_Select::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- sal_Bool bTmp=fEnabled;
- aTmp = bool2any(bTmp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- bTmp=fLocked;
- aTmp = bool2any(bTmp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
-
- aTmp <<= ImportColor(mnForeColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
-
- sal_Bool bTemp = nMultiState;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("MultiSelection"), aTmp);
-
- aTmp <<= ImportColor(mnBackColor);
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
-
- aTmp <<= ImportColor( nBorderColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
-
- if ( msListData.getLength() )
- {
- aTmp <<= msListData;
- rPropSet->setPropertyValue( WW8_ASCII2STR("StringItemList"), aTmp);
- if ( msIndices.getLength() )
- {
- aTmp <<= msIndices;
- rPropSet->setPropertyValue( WW8_ASCII2STR("SelectedItems"), aTmp);
- }
- }
- rPropSet->setPropertyValue( WW8_ASCII2STR("Dropdown"), uno::makeAny( sal_True ));
-
- return sal_True;
-}
-
-sal_Bool HTML_Select::Read(SotStorageStream *pS)
-{
- static rtl::OUString sTerm( RTL_CONSTASCII_USTRINGPARAM("</SELECT") );
- static String sMultiple( RTL_CONSTASCII_USTRINGPARAM("<SELECT MULTIPLE") );
- static String sSelected( RTL_CONSTASCII_USTRINGPARAM("OPTION SELECTED") );
-
- // we should be positioned at the html fragment ( really we should
- // reorganise the reading of controls from excel such that the position and
- // lenght of the associated record in the Ctls stream is available
- // But since we don't know about the lenght of the stream lets read the stream
- // until we reach the end of the fragment
- // I wish I know where there was a html parser in openoffice
- OUStringBuffer buf(40);
- bool bTerminate = false;
- do
- {
- sal_uInt16 ch = 0;
- *pS >> ch;
- sal_Unicode uni = static_cast< sal_Unicode >( ch );
- // if the buffer ends with </SELECT> we are done
- if ( uni == '>' )
- {
- rtl::OUString bufContents( buf.getStr() );
- if ( bufContents.indexOf( sTerm ) != -1 )
- bTerminate = true;
-
- }
- buf.append( &uni, 1 );
-
- } while ( !pS->IsEof() && !bTerminate );
- String data = buf.makeStringAndClear();
-
- // replace crlf with lf
- data.SearchAndReplaceAll( String( RTL_CONSTASCII_USTRINGPARAM( "\x0D\x0A" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "\x0A" ) ) );
- std::vector< rtl::OUString > listValues;
- std::vector< sal_Int16 > selectedIndices;
-
- // Ultra hacky parser for the info
- sal_Int32 nTokenCount = data.GetTokenCount( '\n' );
-
- for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken )
- {
- String sLine( data.GetToken( nToken, '\n' ) );
- if ( !nToken ) // first line will tell us if multiselect is enabled
- {
- if ( sLine.CompareTo( sMultiple, sMultiple.Len() ) == COMPARE_EQUAL )
- nMultiState = true;
- }
- // skip first and last lines, no data there
- else if ( nToken < nTokenCount - 1)
- {
- if ( sLine.GetTokenCount( '>' ) )
- {
- String displayValue = sLine.GetToken( 1, '>' );
- if ( displayValue.Len() )
- {
- // Really we should be using a proper html parser
- // escaping some common bits to be escaped
- displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&lt;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("<") ) );
- displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&gt;" ) ), String( RTL_CONSTASCII_USTRINGPARAM(">") ) );
- displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&quot;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("\"") ) );
- displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&amp;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("&") ) );
- listValues.push_back( displayValue );
- if( sLine.Search( sSelected ) != STRING_NOTFOUND )
- selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 );
- }
- }
- }
- }
- if ( !listValues.empty() )
- {
- msListData.realloc( listValues.size() );
- sal_Int32 index = 0;
- for( std::vector< rtl::OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index )
- msListData[ index ] = *it;
- }
- if ( !selectedIndices.empty() )
- {
- msIndices.realloc( selectedIndices.size() );
- sal_Int32 index = 0;
- for( std::vector< sal_Int16 >::iterator it = selectedIndices.begin(); it != selectedIndices.end(); ++it, ++index )
- msIndices[ index ] = *it;
- }
- return sal_True;
-}
-
-sal_Bool HTML_Select::ReadFontData(SotStorageStream* /*pS*/)
-{
- return sal_True;
-}
-
-// Doesn't really read anything but just skips the
-// record.
-sal_Bool OCX_TabStrip::Read(SotStorageStream *pS)
-{
- long nStart = pS->Tell();
- *pS >> nIdentifier;
- DBG_ASSERT(nStandardId==nIdentifier,
- "A control that has a different identifier");
- *pS >> nFixedAreaLen;
-
- pS->Read(pBlockFlags, sizeof(pBlockFlags));
-
- bool bSize = false;
- bool hasEmbeddedImage = false;
- sal_Int32 nameSize = 0;
- sal_Int32 tipStringSize = 0;
- sal_Int32 nAcceleratorSize = 0;
- sal_Int32 nItemSize = 0;
- sal_Int32 nTagSize = 0;
- if ( pBlockFlags[ 0 ] & 0x01 )
- {
- //List index
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_Int32 nOptional32 = 0; //
- *pS >> nOptional32;
- }
- if (pBlockFlags[0] & 0x02)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> mnBackColor;
- }
- if (pBlockFlags[0] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> mnForeColor;
- }
- if (pBlockFlags[0] & 0x10)
- bSize = true;
- if (pBlockFlags[0] & 0x20)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nItemSize;
- }
- if (pBlockFlags[0] & 0x40)
- {
- sal_Int8 nOptional8 = 0; // mouse pointer
- *pS >> nOptional8;
- }
- if (pBlockFlags[1] & 0x01)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_Int32 nOptional32 = 0; // taborientation
- *pS >> nOptional32;
- }
- if (pBlockFlags[1] & 0x02)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_Int32 nOptional32 = 0; // tabstyle
- *pS >> nOptional32;
- if ( nOptional32 == 2 )
- bHasTabs =false;
- }
- // (pBlockFlags[1] & 0x04) -> MultiRow is true
-
- if (pBlockFlags[1] & 0x08)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_Int32 nOptional32 = 0; // tabfixedwidth
- *pS >> nOptional32;
- }
- if (pBlockFlags[1] & 0x10)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_Int32 nOptional32 = 0; // tabfixedheight
- *pS >> nOptional32;
- }
-
- // (pBlockFlags[1] & 0x20) -> Tooltips is false
-
- if (pBlockFlags[1] & 0x80)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> tipStringSize;
- }
-
- if (pBlockFlags[2] & 0x02)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nameSize;
- }
-
- if (pBlockFlags[2] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_Int32 nOptional32 = 0; // variouspropertybits
- *pS >> nOptional32;
- }
-
- if (pBlockFlags[2] & 0x10)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_Int32 nOptional32 = 0; // tabsallocated
- *pS >> nOptional32;
- }
-
- if (pBlockFlags[2] & 0x20)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nTagSize;
- }
-
- if (pBlockFlags[2] & 0x40)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nNumTabs;
- }
-
- if (pBlockFlags[2] & 0x80)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nAcceleratorSize;
- }
-
- if (pBlockFlags[3] & 0x01)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- sal_Int16 nOptional16 = 0; // Mouse Icon
- *pS >> nOptional16;
- hasEmbeddedImage = true;
- }
-
- // Extra block
- if ( bSize )
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nWidth;
- *pS >> nHeight;
- }
- if ( nItemSize )
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- // read the caption for each tab
- readArrayString( pS, msItems, nItemSize, nStart );
- std::vector< rtl::OUString >::iterator it = msItems.begin();
- std::vector< rtl::OUString >::iterator it_end = msItems.end();
- for ( sal_Int32 i=0; it != it_end; ++i, ++it )
- OSL_TRACE(" Caption [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
-
- if ( tipStringSize )
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- // read the tip for each tab
- std::vector< rtl::OUString > sTips;
- readArrayString( pS, sTips, tipStringSize, nStart );
- std::vector< rtl::OUString >::iterator it = sTips.begin();
- std::vector< rtl::OUString >::iterator it_end = sTips.end();
- for ( sal_Int32 i=0; it != it_end; ++i, ++it )
- OSL_TRACE(" Tip [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
-
- if ( nameSize )
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- // read the name for each tab
- std::vector< rtl::OUString > sNames;
- readArrayString( pS, sNames, nameSize, nStart );
- std::vector< rtl::OUString >::iterator it = sNames.begin();
- std::vector< rtl::OUString >::iterator it_end = sNames.end();
- for ( sal_Int32 i=0; it != it_end; ++i, ++it )
- OSL_TRACE(" Name [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
-
- if ( nTagSize )
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- // read the name for each tab
- std::vector< rtl::OUString > sTags;
- readArrayString( pS, sTags, nTagSize, nStart );
- std::vector< rtl::OUString >::iterator it = sTags.begin();
- std::vector< rtl::OUString >::iterator it_end = sTags.end();
- for ( sal_Int32 i=0; it != it_end; ++i, ++it )
- OSL_TRACE(" Tag [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
-
- if ( nAcceleratorSize )
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- // read the name for each tab
- std::vector< rtl::OUString > sAccelerators;
- readArrayString( pS, sAccelerators, nAcceleratorSize, nStart );
- std::vector< rtl::OUString >::iterator it = sAccelerators.begin();
- std::vector< rtl::OUString >::iterator it_end = sAccelerators.end();
- for ( sal_Int32 i=0; it != it_end; ++i, ++it )
- OSL_TRACE(" Accelerator [ %d ] is %s", i, rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
-
- // Stream data
- if ( hasEmbeddedImage )
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_uInt8 pPictureHeader[20];
- sal_uInt32 nPictureLen(0);
- pS->Read(pPictureHeader,20);
- *pS >> nPictureLen;
- long imagePos = pS->Tell();
- // great embedded object
- mxGrfObj = lcl_readGraphicObject( pS );
- if( mxGrfObj.is() )
- {
- sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
- sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
- }
- // make sure the stream position should be pointing after the image.
- pS->Seek( imagePos + nPictureLen );
- }
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
- OCX_Control::ReadFontData(pS); // read textprops
- ReadAlign(pS, pS->Tell() - nStart, 4);
- for ( sal_Int32 i = 0; i < nNumTabs; ++i )
- {
- sal_uInt32 TabStripTabFlags(0);
- *pS >> TabStripTabFlags;
- }
- return sal_True;
-}
-
-sal_Bool OCX_TabStrip::ReadFontData(SotStorageStream* /* pS */)
-{
- // OCX_TabStrip::Read includes the text props
- return true;
-}
-
-sal_Bool OCX_Image::Read(SotStorageStream *pS)
-{
- sal_uLong nStart = pS->Tell();
- *pS >> nIdentifier;
- DBG_ASSERT(nStandardId==nIdentifier,
- "A control that has a different identifier");
- *pS >> nFixedAreaLen;
-
- pS->Read(pBlockFlags, sizeof(pBlockFlags));
-
- bool hasEmbeddedImage = false;
-
- if ( pBlockFlags[0] & 0x04 )
- {
- bAutoSize = true;
- }
- if ( pBlockFlags[0] & 0x08 )
- {
- *pS >> nBorderColor;
- }
- if ( pBlockFlags[0] & 0x10 )
- {
- *pS >> mnBackColor;
- }
- if ( pBlockFlags[0] & 0x20 )
- {
- *pS >> nBorderStyle;
- }
- if ( pBlockFlags[0] & 0x40 )
- {
- *pS >> nMousePointer;
- }
- if ( pBlockFlags[0] & 0x80 )
- {
- *pS >> nPictureSizeMode;
- }
-
- if ( pBlockFlags[ 1 ] & 0x1 )
- {
- *pS >> nSpecialEffect;
- }
- // investigate if valid also for formcontrols, although for controls
- // images themselves seem to come through from escher ( as shape, think
- // its probably a preview? )
-
- // np a bit of a guess ( until proved incorrect )
- if ( pBlockFlags[ 1 ] & 0x4 )
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- hasEmbeddedImage = true;
- sal_uInt16 unknown;
- *pS >> unknown;
- }
-
-
- if ( pBlockFlags[ 1 ] & 0x8 )
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nPictureAlignment;
-
- }
- if ( pBlockFlags[ 1 ] & 0x10 )
- {
- bPictureTiling = true;
- }
- if ( pBlockFlags[1] & 0x20 )
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- sal_uInt8 nTemp;
- *pS >> nTemp;
- fEnabled = (nTemp&0x02)>>1;
- fBackStyle = (nTemp&0x08)>>3;
- // padding?
- *pS >> nTemp;
- *pS >> nTemp;
- *pS >> nTemp;
- }
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nWidth;
- *pS >> nHeight;
-
- if ( hasEmbeddedImage )
- {
- sal_uInt8 pPictureHeader[20];
- sal_uInt32 nPictureLen(0);
- pS->Read(pPictureHeader,20);
- *pS >> nPictureLen;
-
- long imagePos = pS->Tell();
-
- mxGrfObj = lcl_readGraphicObject( pS );
- if( mxGrfObj.is() )
- {
- sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
- sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
- }
- // make sure the stream position should be pointing after the image
- pS->Seek( imagePos + nPictureLen );
- }
- return sal_True;
-}
-
-sal_Bool OCX_Image::Import( uno::Reference< beans::XPropertySet > &rPropSet )
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-
- if( fBackStyle )
- aTmp <<= ImportColor(mnBackColor);
- else
- aTmp = uno::Any();
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- sal_Bool bTemp;
- if (fEnabled)
- bTemp = sal_True;
- else
- bTemp = sal_False;
- aTmp = bool2any(bTemp);
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
- if ( sImageUrl.getLength() )
- {
- aTmp <<= sImageUrl;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
- }
- return sal_True;
-}
-
sal_Bool OCX_Image::WriteContents(SvStorageStreamRef &rContents,
const uno::Reference< beans::XPropertySet > &rPropSet,
const awt::Size &rSize)
@@ -5612,125 +2602,6 @@ OCX_Control* OCX_SpinButton::Create()
return new OCX_SpinButton;
}
-sal_Bool OCX_SpinButton::Read( SvStorageStream *pS )
-{
- if( !pS ) return sal_False;
-
- SvStream& rStrm = *pS;
- sal_uInt16 nId, nSize;
- sal_Int32 nIcon = 0;
-
- rStrm >> nId >> nSize >> mnBlockFlags;
-
- DBG_ASSERT( nStandardId == nId, "OCX_SpinButton::Read - unknown identifier" );
-
- if( mnBlockFlags & 0x00000001 ) rStrm >> mnForeColor;
- if( mnBlockFlags & 0x00000002 ) rStrm >> mnBackColor;
- if( mnBlockFlags & 0x00000004 )
- {
- sal_Int32 nFlags;
- rStrm >> nFlags;
- mbEnabled = (nFlags & 0x00000002) != 0;
- mbLocked = (nFlags & 0x00000004) != 0;
- }
- if( mnBlockFlags & 0x00000010 ) rStrm.SeekRel( 4 ); // mouse pointer
- if( mnBlockFlags & 0x00000020 ) rStrm >> mnMin;
- if( mnBlockFlags & 0x00000040 ) rStrm >> mnMax;
- if( mnBlockFlags & 0x00000080 ) rStrm >> mnValue;
- if( mnBlockFlags & 0x00000100 ) rStrm.SeekRel( 4 ); // unknown
- if( mnBlockFlags & 0x00000200 ) rStrm.SeekRel( 4 ); // unknown
- if( mnBlockFlags & 0x00000400 ) rStrm >> mnSmallStep;
- if( mnBlockFlags & 0x00000800 ) rStrm.SeekRel( 4 ); // unknown
- if( mnBlockFlags & 0x00001000 ) rStrm >> mnPageStep;
- if( mnBlockFlags & 0x00002000 ) rStrm >> mnOrient;
- if( mnBlockFlags & 0x00004000 )
- {
- sal_Int32 nThumb;
- *pS >> nThumb;
- mbPropThumb = nThumb != 0;
- }
- if( mnBlockFlags & 0x00008000 ) rStrm >> mnDelay;
- if( mnBlockFlags & 0x00010000 ) rStrm >> nIcon;
- if( mnBlockFlags & 0x00000008 ) rStrm >> nWidth >> nHeight;
-
- if( nIcon )
- {
- sal_Int32 nIconSize;
- pS->SeekRel( 20 );
- *pS >> nIconSize;
- pS->SeekRel( nIconSize );
- }
-
- return sal_True;
-}
-
-sal_Bool OCX_SpinButton::ReadFontData( SvStorageStream* /* pS */ )
-{
- // spin buttons and scroll bars do not support font data
- return sal_True;
-}
-
-sal_Bool OCX_SpinButton::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- if( (nWidth < 1) || (nHeight < 1) )
- return sal_False;
-
- uno::Any aTmp( &sName, getCppuType((OUString *)0) );
- rPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
-
- aTmp <<= ImportColor( mnForeColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("SymbolColor"), aTmp);
-
- aTmp <<= ImportColor( mnBackColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- aTmp = bool2any( mbEnabled && !mbLocked );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- aTmp <<= mnValue;
- if ( bSetInDialog )
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValue"), aTmp );
- }
- else
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultSpinValue"), aTmp );
- }
-
- aTmp <<= mnMin;
- rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValueMin"), aTmp );
-
- aTmp <<= mnMax;
- rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValueMax"), aTmp );
-
- aTmp <<= mnSmallStep;
- rPropSet->setPropertyValue( WW8_ASCII2STR("SpinIncrement"), aTmp );
-
- namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
- switch( mnOrient )
- {
- case 0: aTmp <<= AwtScrollOrient::VERTICAL; break;
- case 1: aTmp <<= AwtScrollOrient::HORIZONTAL; break;
- default: aTmp <<= (nWidth < nHeight) ? AwtScrollOrient::VERTICAL : AwtScrollOrient::HORIZONTAL;
- }
- rPropSet->setPropertyValue( WW8_ASCII2STR("Orientation"), aTmp );
-
- aTmp = bool2any( true );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Repeat"), aTmp );
-
- aTmp <<= mnDelay;
- rPropSet->setPropertyValue( WW8_ASCII2STR("RepeatDelay"), aTmp );
-
- aTmp <<= sal_Int16( 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
-
- uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
- lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
-
- return sal_True;
-}
-
sal_Bool OCX_SpinButton::Export(
SvStorageRef &rObj,
const uno::Reference< beans::XPropertySet>& rPropSet,
@@ -5904,69 +2775,6 @@ OCX_Control* OCX_ScrollBar::Create()
return new OCX_ScrollBar;
}
-sal_Bool OCX_ScrollBar::Import(com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet> &rPropSet)
-{
- if( (nWidth < 1) || (nHeight < 1) )
- return sal_False;
-
- uno::Any aTmp( &sName, getCppuType((OUString *)0) );
- rPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
-
- aTmp <<= ImportColor( mnForeColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("SymbolColor"), aTmp);
-
- aTmp <<= ImportColor( mnBackColor );
- rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
-
- aTmp = bool2any( mbEnabled && !mbLocked );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
-
- aTmp <<= mnValue;
- if ( bSetInDialog )
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValue"), aTmp );
- }
- else
- {
- rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultScrollValue"), aTmp );
- }
-
- aTmp <<= mnMin;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValueMin"), aTmp );
-
- aTmp <<= mnMax;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValueMax"), aTmp );
-
- aTmp <<= mnSmallStep;
- rPropSet->setPropertyValue( WW8_ASCII2STR("LineIncrement"), aTmp );
-
- aTmp <<= mnPageStep;
- rPropSet->setPropertyValue( WW8_ASCII2STR("BlockIncrement"), aTmp );
- if( mbPropThumb && (mnPageStep > 0) )
- rPropSet->setPropertyValue( WW8_ASCII2STR("VisibleSize"), aTmp );
-
- namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
- switch( mnOrient )
- {
- case 0: aTmp <<= AwtScrollOrient::VERTICAL; break;
- case 1: aTmp <<= AwtScrollOrient::HORIZONTAL; break;
- default: aTmp <<= (nWidth < nHeight) ? AwtScrollOrient::VERTICAL : AwtScrollOrient::HORIZONTAL;
- }
- rPropSet->setPropertyValue( WW8_ASCII2STR("Orientation"), aTmp );
-
- aTmp <<= mnDelay;
- rPropSet->setPropertyValue( WW8_ASCII2STR("RepeatDelay"), aTmp );
-
- aTmp <<= sal_Int16( 0 );
- rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
-
- uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
- lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
-
- return sal_True;
-}
-
sal_Bool OCX_ScrollBar::Export(
SvStorageRef &rObj,
const uno::Reference< beans::XPropertySet>& rPropSet,
@@ -6064,420 +2872,9 @@ OCX_ProgressBar::OCX_ProgressBar() :
bSetInDialog = true;
}
-sal_Bool OCX_ProgressBar::Read( SvStorageStream *pS )
-{
- pS->SeekRel( 8 );
- *pS >> nWidth >> nHeight;
- pS->SeekRel( 12 );
-
- float fMin, fMax;
- *pS >> fMin >> fMax;
- nMin = static_cast< sal_Int32 >( fMin );
- nMax = static_cast< sal_Int32 >( fMax );
- sal_uInt8 pUnknownFlags[4];
- pS->Read(pUnknownFlags,4);
-
- //complete guess, but we don't handle visible anyway
- //( ( pUnknownFlags[2] & 0x8 ) && ( pUnknownFlags[2] & 0x2 ) ) -> Visible is false
-
- sal_uInt32 nFlags;
- *pS >> nFlags;
-
- // seems these work out
- bFixedSingle = (nFlags & 0x01) != 0;
- bEnabled = (nFlags & 0x02) != 0;
- b3d = (nFlags & 0x04) != 0;
-
- return true;
-}
-
OCX_Control* OCX_ProgressBar::Create()
{
return new OCX_ProgressBar;
}
-sal_Bool OCX_ProgressBar::Import(uno::Reference< beans::XPropertySet > &rPropSet)
-{
- uno::Any aTmp(&sName,getCppuType((OUString *)0));
- rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
- aTmp <<= nMax;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp );
- aTmp <<= nMin;
- rPropSet->setPropertyValue( WW8_ASCII2STR("ProgressValueMin"), aTmp );
-
- if ( !bEnabled )
- rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), uno::makeAny( sal_False ) );
- return sal_True;
-}
-
-// ============================================================================
-OCX_ParentControl::OCX_ParentControl( SotStorageRef& parent, const OUString& storageName, const OUString& sN, const ::uno::Reference< container::XNameContainer > &rParent, OCX_Control* pParent ) : OCX_Control(sN, pParent), mxParent(rParent), nNextAvailableID(0), nBooleanProperties(0), nGroupCnt(0), nZoom(0), fEnabled(1), fLocked(0), fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1), nHorzPos(7), nBorderColor(0x80000012), nShapeCookie(0), nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nMousePointer(0), nSpecialEffect(0), nPicture(0), nPictureAlignment(2), nPictureSizeMode(0), bPictureTiling(sal_False), nAccelerator(0), nIcon(0), pCaption(0), nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0)
-{
- mnForeColor = 0x80000012;
- mnBackColor = 0x8000000F;
- aFontData.SetHasAlign(sal_True);
- mContainerStorage = parent->OpenSotStorage(storageName,
- STREAM_READWRITE |
- STREAM_NOCREATE |
- STREAM_SHARE_DENYALL);
- mContainerStream = mContainerStorage->OpenSotStream(
- String(RTL_CONSTASCII_STRINGPARAM("f"),
- RTL_TEXTENCODING_MS_1252),
- STREAM_STD_READ | STREAM_NOCREATE);
- mContainedControlsStream = mContainerStorage->OpenSotStream( String(RTL_CONSTASCII_STRINGPARAM("o"),
- RTL_TEXTENCODING_MS_1252),
- STREAM_STD_READ | STREAM_NOCREATE);
-}
-
-OCX_ParentControl::~OCX_ParentControl()
-{
- CtrlIterator aEnd = mpControls.end();
- for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
- {
- delete *aIter;
- }
-}
-
-sal_Bool OCX_ParentControl::Import(uno::Reference<beans::XPropertySet>& rProps )
-{
- // #FIXME we probably don't need this (fake) parent (mxParen) which is the dialog iirc
- if ( !mxParent.is() )
- {
- return sal_False;
- }
- CtrlIterator aEnd = mpControls.end();
-
- for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
- {
- uno::Reference< container::XNameContainer > xNameContainer( rProps, uno::UNO_QUERY );
- if ( !(*aIter)->Import( xNameContainer ) )
- {
- return sal_False;
- }
- }
- return sal_True;
-}
-
-bool OCX_ParentControl::createFromContainerRecord( const ContainerRecord& record, OCX_Control*& pControl )
-{
- pControl = NULL;
- switch ( record.nTypeIdent)
- {
- case CMDBUTTON:
- pControl = new OCX_CommandButton;
- break;
- case LABEL:
- pControl = new OCX_UserFormLabel(this);
- break;
- case TEXTBOX:
- pControl = new OCX_TextBox;
- break;
- case LISTBOX:
- pControl = new OCX_ListBox;
- break;
- case COMBOBOX:
- pControl = new OCX_ComboBox;
- break;
- case CHECKBOX:
- pControl = new OCX_CheckBox;
- break;
- case OPTIONBUTTON:
- pControl = new OCX_OptionButton;
- break;
- case TOGGLEBUTTON:
- pControl = new OCX_ToggleButton;
- break;
- case IMAGE: //Image
- {
- pControl = new OCX_Image;
- break;
- }
- case PAGE: // Page
- {
- pControl = new OCX_Page(mContainerStorage, record.nSubStorageId,
- record.cName, mxParent, this);
- break;
- }
- case MULTIPAGE: // MultiPage
- {
- OUString sMSStore = createSubStreamName( record.nSubStorageId );
- pControl = new OCX_MultiPage( mContainerStorage, sMSStore,
- record.cName, mxParent, this);
- break;
- }
- case FRAME: //Frame
- {
- OUString sFrameStore = createSubStreamName( record.nSubStorageId );
- pControl = new OCX_Frame(mContainerStorage, sFrameStore,
- record.cName, mxParent, this);
-
- break;
- }
- case SPINBUTTON: //SpinButton
- {
- pControl = new OCX_SpinButton;
- break;
- }
- case TABSTRIP: //TabStrip
- {
- pControl = new OCX_TabStrip;
- break;
- }
- case SCROLLBAR: //ScrollBar
- pControl = new OCX_ScrollBar;
- break;
- case PROGRESSBAR: //ProgressBar Active X control
- pControl = new OCX_ProgressBar;
- break;
- default:
- OSL_TRACE( "**** Unknown control 0x%x", record.nTypeIdent );
- OSL_FAIL( "Unknown control");
- return false;
- }
- pControl->sName = record.cName;
-
- pControl->msToolTip = record.controlTip;
- pControl->mnTop = record.nTop;
- pControl->mnLeft = record.nLeft;
- // MS tabIndex, pretty useless in OpenOffice land
- // as tab indexes in MS are relative to parent container.
- // However we need this value in order to set
- // OpenOffice tab indices in a sensible way to
- // reflect the ms tabbing from orig MS UserForm, see below
- pControl->mnTabPos = record.nTabPos;
- pControl->SetInDialog(true);
- pControl->mbVisible = record.bVisible;
-
- return true;
-}
-
-void OCX_ParentControl::ProcessControl(OCX_Control* pControl,SvStorageStream* /* pS */, ContainerRecord& rec )
-{
- SotStorageStreamRef oStream = mContainedControlsStream;
-
- // can insert into OO Dialog (e.g is this a supported dialog control)??
- if ( rec.nTypeIdent == TABSTRIP )
- {
- // skip the record in the stream, discard the control
- oStream->SeekRel( rec.nSubStreamLen );
- delete pControl;
- }
- else
- {
- // A container control needs to read the f stream in
- // the folder ( substorage ) associated with this control
- if ( rec.nTypeIdent == FRAME ||
- rec.nTypeIdent == MULTIPAGE||
- rec.nTypeIdent == PAGE )
- {
- OCX_ParentControl* pContainer =
- static_cast< OCX_ParentControl* >( pControl );
- oStream = pContainer->getContainerStream();
- }
- // #117490# DR: container records provide size of substream, use it here...
-
- // remember initial position to set correct stream position
- sal_uLong nStrmPos = oStream->Tell();
- // import control, may return with invalid stream position
- pControl->FullRead(oStream);
- // set stream to position behind substream of this control
- oStream->Seek( nStrmPos + rec.nSubStreamLen );
- }
-}
-
-sal_Bool OCX_ParentControl::Read(SvStorageStream *pS)
-{
- long nStart = pS->Tell();
-
- *pS >> nIdentifier;
- DBG_ASSERT(0x400==nIdentifier,
- "A control that has a different identifier");
- *pS >> nFixedAreaLen;
- pS->Read(pBlockFlags,4);
-
- bool bExtraSize = false;
- bool bLogicalSize = false;
- bool bScrollPosition = false;
- bool bFont = false;
- if (pBlockFlags[0] & 0x01)
- {
- DBG_ASSERT(!this, "ARSE");
- }
- if (pBlockFlags[0] & 0x02)
- *pS >> mnBackColor;
- if (pBlockFlags[0] & 0x04)
- *pS >> mnForeColor;
- if (pBlockFlags[0] & 0x08)
- *pS >> nNextAvailableID;
- if (pBlockFlags[0] & 0x40)
- *pS >> nBooleanProperties;
- ReadAlign(pS, pS->Tell() - nStart, 4);
- if (pBlockFlags[0] & 0x80)
- {
- *pS >> nBorderStyle;
- }
- if (pBlockFlags[1] & 0x01)
- *pS >> nMousePointer;
- if (pBlockFlags[1] & 0x02)
- *pS >> nKeepScrollBarsVisible;
- if (pBlockFlags[1] & 0x04)
- bExtraSize = true;
- if (pBlockFlags[1] & 0x08)
- bLogicalSize = true;
- if (pBlockFlags[1] & 0x10)
- bScrollPosition = true;
- if (pBlockFlags[1] & 0x20)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nGroupCnt;
- }
-
- if (pBlockFlags[1] & 0x80)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nIcon;
- DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
- }
- if (pBlockFlags[2] & 0x01)
- *pS >> nCycle;
- if (pBlockFlags[2] & 0x02)
- *pS >> nSpecialEffect;
- if (pBlockFlags[2] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nBorderColor;
- }
- if (pBlockFlags[2] & 0x08)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nCaptionLen;
- }
-
- if (pBlockFlags[2] & 0x10)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- sal_uInt16 nNoIdea;
- *pS >> nNoIdea;
- DBG_ASSERT(nNoIdea == 0xFFFF, "Expected 0xFFFF, (related to font ?)");
- bFont = true;
- }
- if (pBlockFlags[2] & 0x20)
- {
- ReadAlign(pS, pS->Tell() - nStart, 2);
- *pS >> nPicture;
- DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
- }
-
- if (pBlockFlags[2] & 0x40)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nZoom;
- }
- if (pBlockFlags[2] & 0x80)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nPictureAlignment;
- }
-
- if (pBlockFlags[3] & 0x01)
- bPictureTiling = true;
-
- if (pBlockFlags[3] & 0x02)
- *pS >> nPictureSizeMode;
-
- if (pBlockFlags[3] & 0x04)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nShapeCookie;
- }
- if (pBlockFlags[3] & 0x08)
- {
- ReadAlign(pS, pS->Tell() - nStart, 4);
- *pS >> nDrawBuffer;
- }
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
- // Extra
- if ( bExtraSize )
- {
- *pS >> nWidth;
- *pS >> nHeight;
- }
- if ( bLogicalSize )
- {
- *pS >> nScrollWidth;
- *pS >> nScrollHeight;
- }
- if ( bScrollPosition )
- {
- *pS >> nScrollLeft;
- *pS >> nScrollTop;
- }
- if ( nCaptionLen )
- {
- sal_uInt32 nCaptionSize = lclGetBufferSize( nCaptionLen );
- if ( nCaptionSize )
- {
- pCaption = new sal_Char[ nCaptionSize ];
- pS->Read( pCaption, nCaptionSize );
- }
- }
-
- ReadAlign(pS, pS->Tell() - nStart, 4);
-
- // StreamData
- if (nIcon)
- {
- pS->Read(pIconHeader,20);
- *pS >> nIconLen;
- pIcon = new sal_uInt8[nIconLen];
- pS->Read(pIcon,nIconLen);
- }
- if ( bFont )
- {
- //Font Stuff..
- pS->SeekRel(0x1a);
- sal_uInt8 nFontLen;
- *pS >> nFontLen;
- pS->SeekRel(nFontLen);
- }
- if (nPicture)
- {
- pS->Read(pPictureHeader,20);
- *pS >> nPictureLen;
- long imagePos = pS->Tell();
- // great embedded object
- mxGrfObj = lcl_readGraphicObject( pS );
- if( mxGrfObj.is() )
- {
- sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
- sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
- }
- // make sure the stream position should be pointing after the image.
- pS->Seek( imagePos + nPictureLen );
- }
- // FormSiteData
- std::vector< ClassTable > siteClassInfo;
- if ( ( nBooleanProperties & 0x00008000 ) == 0x0)
- {
- sal_Int16 numTrailingRecs = 0;
- *pS >> numTrailingRecs;
- if ( numTrailingRecs )
- {
- for ( ; numTrailingRecs ; --numTrailingRecs )
- {
- ClassTable cacheClass;
- cacheClass.Read( pS );
- siteClassInfo.push_back( cacheClass );
- }
- }
- }
- // Sites
- ContainerRecReader reader;
- reader.Read( this, pS, siteClassInfo );
-
- return true;
-}
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/msfilter/msvbasic.cxx b/filter/source/msfilter/msvbasic.cxx
deleted file mode 100644
index 15fa6b4b9054..000000000000
--- a/filter/source/msfilter/msvbasic.cxx
+++ /dev/null
@@ -1,1461 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_filter.hxx"
-
-#include <string.h> // memset(), ...
-#ifndef UNX
-#include <io.h> // access()
-#endif
-#include <osl/endian.h>
-#include <rtl/tencinfo.h> //rtl_getTextEncodingFromWindowsCodePage
-#include "msvbasic.hxx"
-#include <memory>
-#include <rtl/ustrbuf.hxx>
-#include <boost/shared_ptr.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/shared_array.hpp>
-#include <svtools/filterutils.hxx>
-
-#include <com/sun/star/script/ModuleType.hpp>
-#include <fstream>
-
-using namespace ::com::sun::star::script;
-
-namespace MSLZSS {
-
-static unsigned int getShift( sal_uInt32 nPos )
-{
- if (nPos <= 0x80) {
- if (nPos <= 0x20)
- return (nPos <= 0x10) ? 12 : 11;
- else
- return (nPos <= 0x40) ? 10 : 9;
- } else {
- if (nPos <= 0x200)
- return (nPos <= 0x100) ? 8 : 7;
- else if (nPos <= 0x800)
- return (nPos <= 0x400) ? 6 : 5;
- else
- return 4;
- }
-}
-
-SvMemoryStream *decompressAsStream( SvStream *pStream, sal_uInt32 nOffset, sal_uInt32 *pCompressedLength = NULL, sal_uInt32 *pLength = NULL )
-{
- SvMemoryStream *pResult;
- const sal_Int32 nWINDOWLEN = 4096;
- pResult = new SvMemoryStream();
-
- sal_uInt8 nLeadbyte;
- unsigned int nPos = 0;
- int nLen, nDistance, nShift, nClean=1;
- sal_uInt8 aHistory[ nWINDOWLEN ];
-
- pStream->Seek( nOffset + 3 );
-
- while( pStream->Read( &nLeadbyte, 1 ) )
- {
- for(int nMask=0x01; nMask < 0x100; nMask = nMask<<1)
- {
- // we see if the leadbyte has flagged this location as a dataunit
- // which is actually a token which must be looked up in the history
- if( nLeadbyte & nMask )
- {
- sal_uInt16 nToken;
-
- *pStream >> nToken;
-
- if (nClean == 0)
- nClean=1;
-
- //For some reason the division of the token into the length
- //field of the data to be inserted, and the distance back into
- //the history differs depending on how full the history is
- nShift = getShift( nPos % nWINDOWLEN );
-
- nLen = (nToken & ((1<<nShift) - 1)) + 3;
- nDistance = nToken >> nShift;
-
- //read the len of data from the history, wrapping around the
- //nWINDOWLEN boundary if necessary data read from the history
- //is also copied into the recent part of the history as well.
- for (int i = 0; i < nLen; i++)
- {
- unsigned char c;
- c = aHistory[(nPos-nDistance-1) % nWINDOWLEN];
- aHistory[nPos % nWINDOWLEN] = c;
- nPos++;
- }
- }
- else
- {
- // special boundary case code, not guarantueed to be correct
- // seems to work though, there is something wrong with the
- // compression scheme (or maybe a feature) where when the data
- // ends on a nWINDOWLEN boundary and the excess bytes in the 8
- // dataunit list are discarded, and not interpreted as tokens
- // or normal data.
- if ((nPos != 0) && ((nPos % nWINDOWLEN) == 0) && (nClean))
- {
- pStream->SeekRel(2);
- nClean=0;
- pResult->Write( aHistory, nWINDOWLEN );
- break;
- }
- //This is the normal case for when the data unit is not a
- //token to be looked up, but instead some normal data which
- //can be output, and placed in the history.
- if (pStream->Read(&aHistory[nPos % nWINDOWLEN],1))
- nPos++;
-
- if (nClean == 0)
- nClean=1;
- }
- }
- }
- if (nPos % nWINDOWLEN)
- pResult->Write( aHistory, nPos % nWINDOWLEN );
- pResult->Flush();
-
- if( pCompressedLength )
- *pCompressedLength = nPos;
-
- if( pLength )
- *pLength = pResult->Tell();
-
- pResult->Seek( 0 );
-
- return pResult;
-}
-
-} //MSZSS
-
-// also _VBA_PROJECT_VDPI can be used to create a usable
-// ( and much smaller ) "_VBA_PROJECT" stream
-
-// _VBA_PROJECT Stream Version Dependant Project Information
-// _VBA_PROJECT Stream Version Dependant Project Information
-
-class _VBA_PROJECT_VDPI
-{
-public:
-sal_Int16 Reserved1;
-sal_Int16 Version;
-sal_Int8 Reserved2;
-sal_Int16 Reserved3;
-boost::scoped_array< sal_uInt8 > PerformanceCache;
-sal_Int32 PerformanceCacheSize;
-_VBA_PROJECT_VDPI(): Reserved1( 0x61CC), Version( 0xFFFF ), Reserved2(0x0), Reserved3(0x0), PerformanceCacheSize(0) {}
-~_VBA_PROJECT_VDPI()
-{
- PerformanceCacheSize = 0;
-}
-void read(){}
-void write( SvStream* pStream )
-{
- *pStream << Reserved1 << Version << Reserved2 << Reserved3;
- if ( PerformanceCacheSize )
- {
- PerformanceCache.reset( new sal_uInt8[ PerformanceCacheSize ] );
- pStream->Read( PerformanceCache.get(), PerformanceCacheSize );
- }
-}
-};
-
-class ProjectSysKindRecord
-{
-public:
-sal_Int16 Id;
-sal_Int32 Size;
-sal_Int32 SysKind;
-ProjectSysKindRecord(): Id(0x1), Size(0x4), SysKind( 0x1 ) {}
-void read( SvStream* pStream )
-{
- *pStream >> Id >> Size >> SysKind;
-}
-};
-
-class ProjectLcidRecord
-{
-public:
-sal_Int16 Id;
-sal_Int32 Size;
-sal_Int32 Lcid;
-
-ProjectLcidRecord() : Id( 0x2 ), Size( 0x4 ), Lcid( 0x409 ) {}
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectLcidRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> Size >> Lcid;
-}
-};
-
-class ProjectLcidInvokeRecord
-{
-sal_Int16 Id;
-sal_Int32 Size;
-sal_Int32 LcidInvoke;
-public:
-ProjectLcidInvokeRecord() : Id( 0x14 ), Size( 0x4 ), LcidInvoke( 0x409 ) {}
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectLcidInvokeRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> Size >> LcidInvoke;
-}
-};
-
-class ProjectCodePageRecord
-{
-sal_Int16 Id;
-sal_Int32 Size;
-sal_Int16 CodePage;
-public:
-// #FIXME get a better default for the CodePage
-ProjectCodePageRecord() : Id( 0x03 ), Size( 0x2 ), CodePage( 0x0 ) {}
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectCodePageRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> Size >> CodePage;
-}
-};
-class ProjectNameRecord
-{
-public:
-sal_Int16 Id;
-sal_Int32 SizeOfProjectName;
-rtl::OUString ProjectName;
-ProjectNameRecord() : Id( 0x04 ), SizeOfProjectName( 0x0 ){}
-~ProjectNameRecord()
-{
-}
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectNameRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> SizeOfProjectName;
-
- if ( SizeOfProjectName )
- {
- boost::scoped_array< sal_uInt8 > pProjectName( new sal_uInt8[ SizeOfProjectName ] );
- OSL_TRACE("ProjectNameRecord about to read name from [0x%x], size %d", pStream->Tell(), SizeOfProjectName );
- pStream->Read( pProjectName.get(), SizeOfProjectName );
- ProjectName = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pProjectName.get() ), SizeOfProjectName );
- }
-}
-};
-
-class ProjectDocStringRecord
-{
-public:
-sal_Int16 Id;
-sal_Int32 SizeOfDocString;
-sal_Int16 Reserved;
-sal_Int32 SizeOfDocStringUnicode;
-rtl::OUString DocString;
-rtl::OUString DocStringUnicode;
-
-ProjectDocStringRecord() : Id( 0x5 ), SizeOfDocString( 0x0 ), Reserved( 0x0 ), SizeOfDocStringUnicode( 0 ){}
-
-~ProjectDocStringRecord()
-{
-}
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectDocStringRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> SizeOfDocString;
-
-
- boost::scoped_array< sal_uInt8 > pDocString( new sal_uInt8[ SizeOfDocString ] );
- pStream->Read( pDocString.get(), SizeOfDocString );
-
- DocString = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pDocString.get() ), SizeOfDocString );
-
- *pStream >> Reserved >> SizeOfDocStringUnicode;
-
- boost::scoped_array< sal_uInt8 > pDocStringUnicode( new sal_uInt8[ SizeOfDocStringUnicode ] );
-
- pStream->Read( pDocStringUnicode.get(), SizeOfDocStringUnicode );
- DocStringUnicode = svt::BinFilterUtils::CreateOUStringFromUniStringArray( reinterpret_cast< const char* >( pDocStringUnicode.get() ), SizeOfDocString );
-
-}
-
-};
-
-class ProjectHelpFilePath
-{
-public:
-sal_Int16 Id;
-sal_Int32 SizeOfHelpFile1;
-boost::scoped_array< sal_uInt8 > HelpFile1;
-sal_Int16 Reserved;
-sal_Int32 SizeOfHelpFile2;
-boost::scoped_array< sal_uInt8 > HelpFile2;
-
-ProjectHelpFilePath() : Id( 0x06 ), SizeOfHelpFile1(0), Reserved(0x0), SizeOfHelpFile2(0) {}
-~ProjectHelpFilePath()
-{
-}
-
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectHelpFilePath [0x%x]", pStream->Tell() );
- *pStream >> Id >> SizeOfHelpFile1;
-
- HelpFile1.reset( new sal_uInt8[ SizeOfHelpFile1 ] );
- pStream->Read( HelpFile1.get(), SizeOfHelpFile1 );
-
- *pStream >> Reserved >> SizeOfHelpFile2;
-
- HelpFile2.reset( new sal_uInt8[ SizeOfHelpFile2 ] );
- pStream->Read( HelpFile2.get(), SizeOfHelpFile2 );
-
-}
-};
-
-class ProjectHelpContextRecord
-{
-public:
-sal_Int16 Id;
-sal_Int32 Size;
-sal_Int32 HelpContext;
-
-ProjectHelpContextRecord() : Id( 0x7 ), Size( 0x4 ), HelpContext( 0 ) {}
-void read( SvStream* pStream )
-{
-
- OSL_TRACE("ProjectHelpContextRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> Size >> HelpContext;
-}
-
-};
-
-class ProjectLibFlagsRecord
-{
-sal_Int16 Id;
-sal_Int32 Size;
-sal_Int32 ProjectLibFlags;
-
-public:
-ProjectLibFlagsRecord() : Id( 0x8 ), Size( 0x4 ), ProjectLibFlags( 0x0 ) {}
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectLibFlagsRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> Size >> ProjectLibFlags;
-}
-};
-
-class ProjectVersionRecord
-{
-public:
-sal_Int16 Id;
-sal_Int32 Reserved;
-sal_Int32 VersionMajor;
-sal_Int16 VersionMinor;
-ProjectVersionRecord() : Id( 0x9 ), Reserved( 0x4 ), VersionMajor( 0x1 ), VersionMinor( 0 ) {}
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectVersionRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> Reserved >> VersionMajor >> VersionMinor;
-}
-};
-
-class ProjectConstantsRecord
-{
-sal_Int16 Id;
-sal_Int32 SizeOfConstants;
-boost::scoped_array< sal_uInt8 > Constants;
-sal_Int16 Reserved;
-sal_Int32 SizeOfConstantsUnicode;
-boost::scoped_array< sal_uInt8 > ConstantsUnicode;
-public:
-ProjectConstantsRecord() : Id( 0xC ), SizeOfConstants( 0 ), Constants( 0 ), Reserved( 0x3C ), SizeOfConstantsUnicode( 0 ), ConstantsUnicode(0) {}
-
-~ProjectConstantsRecord()
-{
-}
-
-void read( SvStream* pStream )
-{
- OSL_TRACE("ProjectConstantsRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> SizeOfConstants;
- Constants.reset( new sal_uInt8[ SizeOfConstants ] );
-
- pStream->Read( Constants.get(), SizeOfConstants );
-
- *pStream >> Reserved;
-
- *pStream >> SizeOfConstantsUnicode;
-
- ConstantsUnicode.reset( new sal_uInt8[ SizeOfConstantsUnicode ] );
- pStream->Read( ConstantsUnicode.get(), SizeOfConstantsUnicode );
-}
-
-};
-
-class ReferenceNameRecord
-{
-public:
-sal_Int16 Id;
-sal_Int32 SizeOfName;
-rtl::OUString Name;
-sal_Int16 Reserved;
-sal_Int32 SizeOfNameUnicode;
-rtl::OUString NameUnicode;
-
-ReferenceNameRecord() : Id( 0x16 ), SizeOfName( 0 ), Reserved( 0x3E ), SizeOfNameUnicode( 0 ){}
-~ReferenceNameRecord()
-{
-}
-
-void read( SvStream* pStream )
-{
- long nPos = pStream->Tell();
- OSL_TRACE("NameRecord [0x%x]", nPos );
- *pStream >> Id >> SizeOfName;
-
- boost::scoped_array< sal_uInt8 > pName( new sal_uInt8[ SizeOfName ] );
-
- pStream->Read( pName.get(), SizeOfName );
- Name = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pName.get() ), SizeOfName );
-
- nPos = pStream->Tell();
- *pStream >> Reserved;
-
- if ( Reserved != 0x3E )
- {
- // it seems the spec here is incorrect and the Unicode portion
- // looks like it can be optional ( if 'Reserved' isn't the expected
- // 0x34 ) - return stream here to point before Reserved
- pStream->Seek( nPos );
- return;
- }
-
- *pStream >> SizeOfNameUnicode;
-
- boost::scoped_array< sal_uInt8 > pNameUnicode( new sal_uInt8[ SizeOfNameUnicode ] );
- pStream->Read( pNameUnicode.get(), SizeOfNameUnicode );
- NameUnicode = svt::BinFilterUtils::CreateOUStringFromUniStringArray( reinterpret_cast< const char* >( pNameUnicode.get() ), SizeOfName );
-}
-
-};
-
-// Baseclass for ReferenceControlRecord, ReferenceRegisteredRecord, ReferenceProjectRecord
-class DirDumper;
-
-class BaseReferenceRecord
-{
-public:
-virtual ~BaseReferenceRecord(){}
-virtual bool read( SvStream* pStream ) = 0;
-virtual void import( VBA_Impl& ){}
-};
-
-
-class ReferenceProjectRecord : public BaseReferenceRecord
-{
-public:
- sal_uInt16 Id;
- sal_uInt32 Size;
- sal_uInt32 SizeOfLibidAbsolute;
- sal_uInt32 SizeOfLibidRelative;
- sal_uInt32 MajorVersion;
- sal_uInt16 MinorVersion;
- rtl::OUString AbsoluteLibid;
- rtl::OUString RelativeLibid;
-
- virtual bool read( SvStream* pStream );
- virtual void import( VBA_Impl& rDir );
- ReferenceProjectRecord();
- ~ReferenceProjectRecord();
-};
-
-ReferenceProjectRecord::ReferenceProjectRecord() : Id( 0x000E ), Size( 0 ), SizeOfLibidAbsolute( 0 ), SizeOfLibidRelative( 0 ), MajorVersion( 0 ), MinorVersion( 0 )
-{
-}
-
-ReferenceProjectRecord::~ReferenceProjectRecord()
-{
-}
-
-bool ReferenceProjectRecord::read( SvStream* pStream )
-{
- OSL_TRACE("ReferenceProjectRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> Size >> SizeOfLibidAbsolute;
-
- boost::scoped_array< sal_uInt8 > pLibidAbsolute( new sal_uInt8[ SizeOfLibidAbsolute ] );
- OSL_TRACE("ReferenceProjectRecord about to read LibidAbsolute at [0x%x]", pStream->Tell() );
- pStream->Read( pLibidAbsolute.get(), SizeOfLibidAbsolute );
-
- *pStream >> SizeOfLibidRelative;
-
- boost::scoped_array< sal_uInt8 > pLibidRelative( new sal_uInt8[ SizeOfLibidRelative ] );
- OSL_TRACE("ReferenceProjectRecord about to read LibidRelative at [0x%x]", pStream->Tell() );
- pStream->Read( pLibidRelative.get(), SizeOfLibidRelative );
-
- *pStream >> MajorVersion >> MinorVersion;
-
- // array size is ORed with SVX_MSOCX_COMPRESSED to force processing of ascii bytes ( and not
- // 16 bit unicode )
- // the offset of 3 is needed to skip the ProjectReference "*\" and project kind ( 0x4[1-4] ) info.
-
- AbsoluteLibid = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pLibidAbsolute.get() + 3 ), (SizeOfLibidAbsolute - 3 ) );
- RelativeLibid = svt::BinFilterUtils::CreateOUStringFromStringArray( reinterpret_cast< const char* >( pLibidRelative.get() + 3 ), ( SizeOfLibidRelative -3 ) );
-
- OSL_TRACE("ReferenceProjectRecord - absolute path %s", rtl::OUStringToOString( AbsoluteLibid, RTL_TEXTENCODING_UTF8 ).getStr() );
- OSL_TRACE("ReferenceProjectRecord - relative path %s", rtl::OUStringToOString( RelativeLibid, RTL_TEXTENCODING_UTF8 ).getStr() );
- return true;
-}
-
-void ReferenceProjectRecord::import( VBA_Impl& rDir )
-{
- rDir.AddProjectReference( AbsoluteLibid );
-}
-
-class ReferenceRegisteredRecord : public BaseReferenceRecord
-{
-public:
- sal_uInt16 Id;
- sal_uInt32 Size;
- sal_uInt32 SizeOfLibid;
- boost::scoped_array< sal_uInt8> pLibid;
- sal_Int32 Reserved1;
- sal_Int16 Reserved2;
-
- ReferenceRegisteredRecord();
- ~ReferenceRegisteredRecord();
- bool read( SvStream* pStream );
-};
-
-ReferenceRegisteredRecord::ReferenceRegisteredRecord() : Id( 0x000D ), Size( 0 ), SizeOfLibid( 0 ), Reserved1( 0 ), Reserved2( 0 )
-{
-}
-
-ReferenceRegisteredRecord::~ReferenceRegisteredRecord()
-{
-}
-
-bool
-ReferenceRegisteredRecord::read( SvStream* pStream )
-{
- OSL_TRACE("ReferenceRegisteredRecord [0x%x]", pStream->Tell() );
- *pStream >> Id >> Size >> SizeOfLibid;
- if ( SizeOfLibid )
- {
- pLibid.reset( new sal_uInt8[ SizeOfLibid] );
- pStream->Read( pLibid.get(), SizeOfLibid );
- }
- *pStream >> Reserved1 >> Reserved2;
- return true;
-}
-
-class ReferenceOriginalRecord
-{
-public:
- sal_uInt16 Id;
- sal_uInt32 SizeOfLibOriginal;
- boost::scoped_array< sal_uInt8 > pLibidOriginal;
-
-
-ReferenceOriginalRecord() : Id( 0x033 ), SizeOfLibOriginal( 0 )
-{
-}
-
-~ReferenceOriginalRecord()
-{
-}
-
-void read( SvStream* pStream )
-{
- *pStream >> Id >> SizeOfLibOriginal;
- if ( SizeOfLibOriginal )
- {
- pLibidOriginal.reset( new sal_uInt8[ SizeOfLibOriginal ] );
- pStream->Read( pLibidOriginal.get(), SizeOfLibOriginal );
- }
-}
-
-};
-
-class ReferenceControlRecord : public BaseReferenceRecord
-{
-public:
-std::auto_ptr< ReferenceOriginalRecord > OriginalRecord;
-sal_Int16 Id;
-sal_uInt32 SizeTwiddled;
-sal_uInt32 SizeOfLibidTwiddled;
-boost::shared_array< sal_uInt8 > LibidTwiddled;
-sal_uInt32 Reserved1;
-sal_uInt16 Reserved2;
-std::auto_ptr< ReferenceNameRecord > NameRecordExtended;// Optional
-sal_uInt16 Reserved3;
-sal_uInt32 SizeExtended;
-sal_uInt32 SizeOfLibidExtended;
-boost::shared_array< sal_uInt8 > LibidExtended;
-sal_uInt32 Reserved4;
-sal_uInt16 Reserved5;
-sal_uInt8 OriginalTypeLib[ 16 ];
-sal_uInt32 Cookie;
-
-ReferenceControlRecord() : Id( 0x2F ), SizeTwiddled( 0 ), SizeOfLibidTwiddled( 0 ), Reserved1( 0 ), Reserved2( 0 ), Reserved3( 0x30 ), SizeExtended( 0 ), SizeOfLibidExtended( 0 ), Reserved4( 0 ), Reserved5( 0 ), Cookie( 0 )
-{
- for( int i = 0; i < 16; ++i )
- OriginalTypeLib[ i ] = 0;
-}
-
-~ReferenceControlRecord()
-{
-}
-
-bool read( SvStream* pStream )
-{
- OSL_TRACE("ReferenceControlRecord [0x%x]", pStream->Tell() );
- long nPos = pStream->Tell();
-
- *pStream >> Id;
- pStream->Seek( nPos ); // point before the peeked Id
- if ( Id == 0x33 ) // we have an OriginalRecord
- {
- OriginalRecord.reset( new ReferenceOriginalRecord() );
- OriginalRecord->read( pStream );
- }
- *pStream >> Id >> SizeTwiddled >> SizeOfLibidTwiddled;
-
- if ( SizeOfLibidTwiddled )
- {
- LibidTwiddled.reset( new sal_uInt8[ SizeOfLibidTwiddled ] );
- pStream->Read( LibidTwiddled.get(), SizeOfLibidTwiddled );
- }
-
- *pStream >> Reserved1 >> Reserved2;
-
- nPos = pStream->Tell();
- // peek at the id for optional NameRecord
- sal_Int16 nTmpId;
- *pStream >> nTmpId;
- if ( nTmpId == 0x30 )
- {
- Reserved3 = 0x30;
- }
- else
- {
- pStream->Seek( nPos );
- NameRecordExtended.reset( new ReferenceNameRecord() );
- NameRecordExtended->read( pStream );
- *pStream >> Reserved3;
- }
- *pStream >> SizeExtended >> SizeOfLibidExtended;
-
- if ( SizeExtended )
- {
- LibidExtended.reset( new sal_uInt8[ SizeOfLibidExtended ] );
- pStream->Read( LibidExtended.get(), SizeOfLibidExtended );
- }
-
- *pStream >> Reserved4;
- *pStream >> Reserved5;
-
- pStream->Read( OriginalTypeLib, sizeof( OriginalTypeLib ) );
- *pStream >> Cookie;
- return true;
-}
-
-};
-
-class ReferenceRecord : public BaseReferenceRecord
-{
-public:
-// NameRecord is Optional
-std::auto_ptr< ReferenceNameRecord > NameRecord;
-std::auto_ptr< BaseReferenceRecord > aReferenceRecord;
-
-ReferenceRecord(){}
-~ReferenceRecord()
-{
-}
-
-// false return would mean failed to read Record e.g. end of array encountered
-// Note: this read routine will make sure the stream is pointing to where it was the
-// method was called )
-
-bool read( SvStream* pStream )
-{
- OSL_TRACE("ReferenceRecord [0x%x]", pStream->Tell() );
- bool bRead = true;
- long nStart = pStream->Tell();
- long nPos = nStart;
- // Peek at the ID
- sal_Int16 Id;
- *pStream >> Id;
- pStream->Seek( nPos ); // place back before Id
- if ( Id == 0x16 ) // Optional NameRecord
- {
- NameRecord.reset( new ReferenceNameRecord() );
- NameRecord->read( pStream );
- }
- else if ( Id == 0x0f )
- {
- pStream->Seek( nStart );
- bRead = false;
- return bRead; // start of module, terminate read
- }
-
- nPos = pStream->Tell(); // mark position, peek at next Id
- *pStream >> Id;
- pStream->Seek( nPos ); // place back before Id
-
- switch( Id )
- {
- case 0x0D:
- aReferenceRecord.reset( new ReferenceRegisteredRecord() );
- break;
- case 0x0E:
- aReferenceRecord.reset( new ReferenceProjectRecord() );
- break;
- case 0x2F:
- case 0x33:
- aReferenceRecord.reset( new ReferenceControlRecord() );
- break;
- default:
- bRead = false;
- OSL_TRACE("Big fat error, unknown ID 0x%x", Id);
- break;
- }
- if ( bRead )
- aReferenceRecord->read( pStream );
- return bRead;
-}
-
-void import( VBA_Impl& rVBA )
-{
- if ( aReferenceRecord.get() )
- aReferenceRecord->import( rVBA );
-}
-
-};
-
-class DirDumper
-{
-public:
-ProjectSysKindRecord mSysKindRec;
-ProjectLcidRecord mLcidRec;
-ProjectLcidInvokeRecord mLcidInvokeRec;
-ProjectCodePageRecord mCodePageRec;
-ProjectNameRecord mProjectNameRec;
-ProjectDocStringRecord mDocStringRec;
-ProjectHelpFilePath mHelpFileRec;
-ProjectHelpContextRecord mHelpContextRec;
-ProjectLibFlagsRecord mLibFlagsRec;
-ProjectVersionRecord mVersionRec;
-ProjectConstantsRecord mConstantsRecord;
-std::vector< ReferenceRecord* > ReferenceArray;
-
-DirDumper() {}
-~DirDumper()
-{
- for ( std::vector< ReferenceRecord* >::iterator it = ReferenceArray.begin(); it != ReferenceArray.end(); ++it )
- delete *it;
-
-}
-
-void read( SvStream* pStream )
-{
- sal_Int32 nPos = pStream->Tell();
-#ifdef DEBUG
- std::ofstream aDump("dir.dump");
- while ( !pStream->IsEof() )
- {
- sal_Int8 aByte;
- *pStream >> aByte;
- aDump << aByte;
- }
- aDump.flush();
-#endif
- pStream->Seek( nPos );
- readProjectInformation( pStream );
- readProjectReferenceInformation( pStream );
-}
-
-void readProjectReferenceInformation( SvStream* pStream )
-{
- bool bKeepReading = true;
- while( bKeepReading )
- {
- ReferenceRecord* pRef = new ReferenceRecord();
- bKeepReading = pRef->read( pStream );
- if ( bKeepReading )
- ReferenceArray.push_back( pRef );
- }
-}
-
-void readProjectInformation( SvStream* pStream )
-{
- mSysKindRec.read( pStream );
- mLcidRec.read( pStream );
- mLcidInvokeRec.read( pStream );
- mCodePageRec.read( pStream );
- mProjectNameRec.read( pStream );
- mDocStringRec.read( pStream );
- mHelpFileRec.read( pStream );
- mHelpContextRec.read( pStream );
- mLibFlagsRec.read( pStream );
- mVersionRec.read( pStream );
- sal_Int32 nPos = pStream->Tell();
- sal_uInt16 nTmp;
- *pStream >> nTmp;
- if ( nTmp == 0x0C )
- {
- pStream->Seek( nPos );
- mConstantsRecord.read( pStream );
- }
- OSL_TRACE("After Information pos is 0x%x", pStream->Tell() );
-}
-
-void import( VBA_Impl& rVBA )
-{
- // get project references
- for ( std::vector< ReferenceRecord* >::iterator it = ReferenceArray.begin(); it != ReferenceArray.end(); ++it )
- (*it)->import( rVBA );
- rVBA.SetProjectName( mProjectNameRec.ProjectName );
-
-}
-};
-
-
-/*
-A few urls which may in the future be of some use
-http://www.virusbtn.com/vb2000/Programme/papers/bontchev.pdf
-*/
-
-/* class VBA_Impl:
- * The VBA class provides a set of methods to handle Visual Basic For
- * Applications streams, the constructor is given the root ole2 stream
- * of the document, Open reads the VBA project file and figures out
- * the number of VBA streams, and the offset of the data within them.
- * Decompress decompresses a particular numbered stream, NoStreams returns
- * this number, and StreamName can give you the streams name. Decompress
- * will call Output when it has a 4096 byte collection of data to output,
- * and also with the final remainder of data if there is still some left
- * at the end of compression. Output is virtual to allow custom handling
- * of each chunk of decompressed data. So inherit from this to do something
- * useful with the data.
- *
- * cmc
- * */
-const int MINVBASTRING = 6;
-
-VBA_Impl::VBA_Impl(SvStorage &rIn, bool bCmmntd)
- : aVBAStrings(0),
- sComment(RTL_CONSTASCII_USTRINGPARAM("Rem ")),
- xStor(&rIn), pOffsets(0), nOffsets(0), meCharSet(RTL_TEXTENCODING_MS_1252),
- bCommented(bCmmntd), mbMac(false), nLines(0)
-{
-}
-
-VBA_Impl::~VBA_Impl()
-{
- delete [] pOffsets;
- for (sal_uLong i=0;i<aVBAStrings.GetSize();++i)
- delete aVBAStrings.Get(i);
-}
-
-sal_uInt8 VBA_Impl::ReadPString(SvStorageStreamRef &xVBAProject,
- bool bIsUnicode)
-{
- sal_uInt16 nIdLen, nOut16;
- sal_uInt8 nType = 0, nOut8;
- String sReference;
-
- *xVBAProject >> nIdLen;
-
- if (nIdLen < MINVBASTRING) //Error recovery
- xVBAProject->SeekRel(-2); //undo 2 byte len
- else
- {
- for(sal_uInt16 i=0; i < nIdLen / (bIsUnicode ? 2 : 1); i++)
- {
- if (bIsUnicode)
- *xVBAProject >> nOut16;
- else
- {
- *xVBAProject >> nOut8;
- nOut16 = nOut8;
- }
- sReference += nOut16;
- if (i==2)
- {
- if ((nOut16 == 'G') || (nOut16 == 'H') || (nOut16 == 'C') ||
- nOut16 == 'D')
- {
- nType = static_cast<sal_uInt8>(nOut16);
- }
- if (nType == 0)
- {
- //Error recovery, 2byte len + 3 characters of used type
- xVBAProject->SeekRel(-(2 + 3 * (bIsUnicode ? 2 : 1)));
- break;
- }
- }
- }
- maReferences.push_back(sReference);
- }
- return nType;
-}
-
-void VBA_Impl::Output( int nLen, const sal_uInt8*pData )
-{
- /*
- Each StarBasic module is tragically limited to the maximum len of a
- string and WordBasic is not, so each overlarge module must be split
- */
- String sTemp((const sal_Char *)pData, (xub_StrLen)nLen,
- meCharSet);
- int nTmp = sTemp.GetTokenCount('\x0D');
- int nIndex = aVBAStrings.GetSize()-1;
- if (aVBAStrings.Get(nIndex)->Len() +
- nLen + ((nLines+nTmp) * sComment.Len()) >= STRING_MAXLEN)
- {
- //DBG_ASSERT(0,"New Module String\n");
- //we are too large for our boots, break out into another
- //string
- nLines=0;
- nIndex++;
- aVBAStrings.SetSize(nIndex+1);
- aVBAStrings.Put(nIndex,new String);
- }
- *(aVBAStrings.Get(nIndex)) += sTemp;
- nLines+=nTmp;
-}
-
-
-int VBA_Impl::ReadVBAProject(const SvStorageRef &rxVBAStorage)
-{
- SvStorageStreamRef xVBAProject;
- xVBAProject = rxVBAStorage->OpenSotStream(
- String( RTL_CONSTASCII_USTRINGPARAM( "_VBA_PROJECT" ) ),
- STREAM_STD_READ | STREAM_NOCREATE );
- // read Dir stream
- SvStorageStreamRef xDir = rxVBAStorage->OpenSotStream(
- String( RTL_CONSTASCII_USTRINGPARAM( "dir" ) ),
- STREAM_STD_READ | STREAM_NOCREATE );
-// disable read and import of Dir stream bits, e.g. project references and
-// project name for 3.1 ( a bit unstable yet )
-#if 1
- // decompress the stream
- std::auto_ptr< SvMemoryStream > xCmpDir;
- xCmpDir.reset( MSLZSS::decompressAsStream( xDir, 0 ) );
- // try to parse the dir stream
- DirDumper dDump;
- dDump.read( xCmpDir.get() );
- dDump.import( *this );
-#endif
- if( !xVBAProject.Is() || SVSTREAM_OK != xVBAProject->GetError() )
- {
- DBG_WARNING("Not able to find vba project, cannot find macros");
- return 0;
- }
-
- static const sal_uInt8 aKnownId[] = {0xCC, 0x61};
- sal_uInt8 aId[2];
- xVBAProject->Read( aId, sizeof(aId) );
- if (memcmp( aId, aKnownId, sizeof(aId)))
- {
- DBG_WARNING("unrecognized VBA macro project type");
- return 0;
- }
-
- static const sal_uInt8 aOffice2007LE[] = { 0x88, 0x00, 0x00, 0x01, 0x00, 0xFF };
- static const sal_uInt8 aOffice2003LE_2[] = { 0x79, 0x00, 0x00, 0x01, 0x00, 0xFF };
- static const sal_uInt8 aOffice2003LE[] = { 0x76, 0x00, 0x00, 0x01, 0x00, 0xFF };
- static const sal_uInt8 aOfficeXPLE[] = { 0x73, 0x00, 0x00, 0x01, 0x00, 0xFF };
- static const sal_uInt8 aOfficeXPBE[] = { 0x63, 0x00, 0x00, 0x0E, 0x00, 0xFF };
- static const sal_uInt8 aOffice2000LE[] = { 0x6D, 0x00, 0x00, 0x01, 0x00, 0xFF };
- static const sal_uInt8 aOffice98BE[] = { 0x60, 0x00, 0x00, 0x0E, 0x00, 0xFF };
- static const sal_uInt8 aOffice97LE[] = { 0x5E, 0x00, 0x00, 0x01, 0x00, 0xFF };
-
- sal_uInt8 aProduct[6];
- xVBAProject->Read( aProduct, sizeof(aProduct) );
-
- bool bIsUnicode;
- if (!(memcmp(aProduct, aOffice2007LE, sizeof(aProduct))) ||
- !(memcmp(aProduct, aOffice2003LE, sizeof(aProduct))) ||
- !(memcmp(aProduct, aOffice2003LE_2, sizeof(aProduct))) ||
- !(memcmp(aProduct, aOfficeXPLE, sizeof(aProduct))) ||
- !(memcmp(aProduct, aOffice2000LE, sizeof(aProduct))) ||
- !(memcmp(aProduct, aOffice97LE, sizeof(aProduct))) )
- {
- xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
- bIsUnicode = true;
- }
- else if (!(memcmp(aProduct, aOfficeXPBE, sizeof(aProduct))) ||
- !(memcmp(aProduct, aOffice98BE, sizeof(aProduct))) )
- {
- xVBAProject->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
- mbMac = true;
- bIsUnicode = false;
- }
- else
- {
- switch (aProduct[3])
- {
- case 0x1:
- xVBAProject->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
- bIsUnicode = true;
- DBG_ASSERT(!this, "unrecognized VBA macro version, report to cmc. Guessing at unicode little endian");
- break;
- case 0xe:
- xVBAProject->SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
- mbMac = true;
- bIsUnicode = false;
- DBG_ASSERT(!this, "unrecognized VBA macro version, report to cmc. Guessing at 8bit big endian");
- break;
- default:
- DBG_ASSERT(!this, "totally unrecognized VBA macro version, report to cmc");
- return 0;
- }
- }
-
- sal_uInt32 nLidA; //Language identifiers
- sal_uInt32 nLidB;
- sal_uInt16 nCharSet;
- sal_uInt16 nLenA;
- sal_uInt32 nUnknownB;
- sal_uInt32 nUnknownC;
- sal_uInt16 nLenB;
- sal_uInt16 nLenC;
- sal_uInt16 nLenD;
-
- *xVBAProject >> nLidA >> nLidB >> nCharSet >> nLenA >> nUnknownB;
- *xVBAProject >> nUnknownC >> nLenB >> nLenC >> nLenD;
-
- meCharSet = rtl_getTextEncodingFromWindowsCodePage(nCharSet);
-
- DBG_ASSERT(meCharSet != RTL_TEXTENCODING_DONTKNOW,
- "don't know what vba charset to use");
- if (meCharSet == RTL_TEXTENCODING_DONTKNOW)
- meCharSet = RTL_TEXTENCODING_MS_1252;
-
- if (nLenD != 0x02)
- {
- DBG_WARNING("Warning VBA number is different, please report");
- return 0;
- }
-
- /*
- A sequence of string that are prepended with a len and then begin with G
- or H, there are also those that begin with C or D. If a string begins with
- C or D, it is really two strings, one right after the other. Each string
- then has a 12 bytes suffix
-
- Recognizing the end of the sequence is done by finding a str len of < 6
- which does not appear to be the beginning of an object id. Admittedly this
- isn't a great test, but nothing in the header appears to count the number
- of strings, and nothing else seems to match. So it'll have to do, its
- protected by a number of secondry tests to prove its a valid string, and
- everything gives up if this isn't proven.
- */
- bool bPredictsTrailingTwenty = false;
- while (1)
- {
- sal_uInt8 nType = ReadPString(xVBAProject,bIsUnicode);
- //Type C and D seem to come as pairs, so skip the following one
- if (nType == 'C' || nType == 'D')
- {
- nType = ReadPString(xVBAProject,bIsUnicode);
- DBG_ASSERT( nType == 'C' || nType == 'D',
- "VBA: This must be a 'C' or 'D' string!" );
- if (nType != 'C' && nType != 'D')
- return 0;
- }
- if (!nType)
- break;
- xVBAProject->SeekRel(10);
- sal_uInt16 nPredictsTrailingTwenty;
- *xVBAProject >> nPredictsTrailingTwenty;
- if (nPredictsTrailingTwenty)
- bPredictsTrailingTwenty = true;
- if (bPredictsTrailingTwenty)
- {
- sal_uInt16 nTestIsNotString;
- *xVBAProject >> nTestIsNotString;
- if (nTestIsNotString < MINVBASTRING)
- {
- DBG_ASSERT(nTestIsNotString <= 1,
- "Haven't seen a len like this in VBA, report to CMC");
- xVBAProject->SeekRel(18);
- bPredictsTrailingTwenty = false;
- }
- else
- xVBAProject->SeekRel(-2);
- }
- }
-
- sal_Int16 nInt16s;
- *xVBAProject >> nInt16s;
- DBG_ASSERT( nInt16s >= 0, "VBA: Bad no of records in VBA Project, panic!" );
- if (!nInt16s)
- return 0;
-
- xVBAProject->SeekRel(2*nInt16s);
-
- sal_Int16 nInt32s;
- *xVBAProject >> nInt32s;
- DBG_ASSERT( nInt32s >= 0, "VBA: Bad no of records in VBA Project, panic!" );
- if (!nInt32s)
- return 0;
- xVBAProject->SeekRel(4*nInt32s);
-
- xVBAProject->SeekRel(2);
- for(int k=0;k<3;k++)
- {
- sal_uInt16 nLen;
- *xVBAProject >> nLen;
- if (nLen != 0xFFFF)
- xVBAProject->SeekRel(nLen);
- }
- xVBAProject->SeekRel(100); //Seems fixed len
-
- *xVBAProject >> nOffsets;
- DBG_ASSERT( nOffsets != 0xFFFF, "VBA: Bad nOffsets, panic!!" );
- if ((nOffsets == 0xFFFF) || (nOffsets == 0))
- return 0;
- pOffsets = new VBAOffset_Impl[ nOffsets ];
-
- int i, j;
- for( i=0; i < nOffsets; i++)
- {
- sal_uInt16 nLen;
- *xVBAProject >> nLen;
-
- if (bIsUnicode)
- {
- sal_Unicode* pBuf = pOffsets[i].sName.AllocBuffer( nLen / 2 );
- xVBAProject->Read( (sal_Char*)pBuf, nLen );
-
-#ifdef OSL_BIGENDIAN
- for( j = 0; j < nLen / 2; ++j, ++pBuf )
- *pBuf = SWAPSHORT( *pBuf );
-#endif // ifdef OSL_BIGENDIAN
- }
- else
- {
- ByteString aByteStr;
- sal_Char* pByteData = aByteStr.AllocBuffer( nLen );
- sal_Size nWasRead = xVBAProject->Read( pByteData, nLen );
- if( nWasRead != nLen )
- aByteStr.ReleaseBufferAccess();
- pOffsets[i].sName += String( aByteStr, meCharSet);
- }
-
- *xVBAProject >> nLen;
- xVBAProject->SeekRel( nLen );
-
- //begin section, another problem area
- *xVBAProject >> nLen;
- if ( nLen == 0xFFFF)
- {
- xVBAProject->SeekRel(2);
- *xVBAProject >> nLen;
- xVBAProject->SeekRel( nLen );
- }
- else
- xVBAProject->SeekRel( nLen+2 );
-
- *xVBAProject >> nLen;
- DBG_ASSERT( nLen == 0xFFFF, "VBA: Bad field in VBA Project, panic!!" );
- if ( nLen != 0xFFFF)
- return 0;
-
- xVBAProject->SeekRel(6);
- sal_uInt16 nOctects;
- *xVBAProject >> nOctects;
- for(j=0;j<nOctects;j++)
- xVBAProject->SeekRel(8);
-
- xVBAProject->SeekRel(5);
- //end section
-
- *xVBAProject >> pOffsets[i].nOffset;
- xVBAProject->SeekRel(2);
- }
-
- return nOffsets;
-}
-
-
-/* #117718# For a given Module name return its type,
- * Form, Class, Document, Normal or Unknown
- *
-*/
-
-ModType VBA_Impl::GetModuleType( const UniString& rModuleName )
-{
- ModuleTypeHash::iterator iter = mhModHash.find( rModuleName );
- ModuleTypeHash::iterator iterEnd = mhModHash.end();
- if ( iter != iterEnd )
- {
- return iter->second;
- }
- return ModuleType::UNKNOWN;
-}
-
-bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
-{
- /* beginning test for vba stuff */
- bool bRet = false;
- SvStorageRef xMacros= xStor->OpenSotStorage( rToplevel,
- STREAM_READWRITE | STREAM_NOCREATE |
- STREAM_SHARE_DENYALL );
- if( !xMacros.Is() || SVSTREAM_OK != xMacros->GetError() )
- {
- DBG_WARNING("No Macros Storage");
- OSL_TRACE("No Macros Storage");
- }
- else
- {
- xVBA = xMacros->OpenSotStorage( rSublevel,
- STREAM_READWRITE | STREAM_NOCREATE |
- STREAM_SHARE_DENYALL );
- if( !xVBA.Is() || SVSTREAM_OK != xVBA->GetError() )
- {
- DBG_WARNING("No Visual Basic in Storage");
- OSL_TRACE("No Visual Basic in Storage");
- }
- else
- {
- if (ReadVBAProject(xVBA))
- bRet = true;
- }
- /* #117718#
- * Information regarding the type of module is contained in the
- * "PROJECT" stream, this stream consists of a number of ascii lines
- * entries are of the form Key=Value, the ones that we are interested
- * in have the keys; Class, BaseClass & Module indicating the module
- * ( value ) is either a Class Module, Form Module or a plain VB Module. */
- SvStorageStreamRef xProject = xMacros->OpenSotStream(
- String( RTL_CONSTASCII_USTRINGPARAM( "PROJECT" ) ) );
-
- SvStorageStream* pStp = xProject;
- UniString tmp;
- static const String sThisDoc( RTL_CONSTASCII_USTRINGPARAM( "ThisDocument" ) );
- static const String sModule( RTL_CONSTASCII_USTRINGPARAM( "Module" ) );
- static const String sClass( RTL_CONSTASCII_USTRINGPARAM( "Class" ) );
- static const String sBaseClass( RTL_CONSTASCII_USTRINGPARAM( "BaseClass" ) );
- static const String sDocument( RTL_CONSTASCII_USTRINGPARAM( "Document" ) );
- mhModHash[ sThisDoc ] = ModuleType::CLASS;
- while ( pStp->ReadByteStringLine( tmp, meCharSet ) )
- {
- xub_StrLen index = tmp.Search( '=' );
- if ( index != STRING_NOTFOUND )
- {
- String key = tmp.Copy( 0, index );
- String value = tmp.Copy( index + 1 );
- if ( key == sClass )
- {
- mhModHash[ value ] = ModuleType::CLASS;
- OSL_TRACE("Module %s is of type Class",
- ::rtl::OUStringToOString( value ,
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- }
- else if ( key == sBaseClass )
- {
- mhModHash[ value ] = ModuleType::FORM;
- OSL_TRACE("Module %s is of type Form",
- ::rtl::OUStringToOString( value ,
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- }
- else if ( key == sDocument )
- {
- /* #i37965# add "Document", used i.e.
- in Excel for macros attached to sheet or document. */
-
- // value is of form <name>/&H<identifier>, strip the identifier
- value.Erase( value.Search( '/' ) );
-
- mhModHash[ value ] = ModuleType::DOCUMENT;
- OSL_TRACE("Module %s is of type Document VBA",
- ::rtl::OUStringToOString( value ,
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- }
- else if ( key == sModule )
- {
- mhModHash[ value ] = ModuleType::NORMAL;
- OSL_TRACE("Module %s is of type Normal VBA",
- ::rtl::OUStringToOString( value ,
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- }
- }
- }
- }
- /* end test for vba stuff */
- return bRet;
-}
-
-const StringArray &VBA_Impl::Decompress(sal_uInt16 nIndex, int *pOverflow)
-{
- DBG_ASSERT( nIndex < nOffsets, "Index out of range" );
- SvStorageStreamRef xVBAStream;
- aVBAStrings.SetSize(1);
- aVBAStrings.Put(0,new String);
-
- xVBAStream = xVBA->OpenSotStream( pOffsets[nIndex].sName,
- STREAM_STD_READ | STREAM_NOCREATE );
- if (pOverflow)
- *pOverflow=0;
-
- if( !xVBAStream.Is() || SVSTREAM_OK != xVBAStream->GetError() )
- {
- DBG_WARNING("Not able to open vb module ");
- }
- else
- {
- xVBAStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
- DecompressVBA( nIndex, xVBAStream );
- /*
- * if len was too big for a single string set that variable ?
- * if ((len > XX) && (pOverflow))
- *pOverflow=1;
- */
- if (bCommented)
- {
- String sTempStringa;
- if (mbMac)
- sTempStringa = String( RTL_CONSTASCII_USTRINGPARAM( "\x0D" ) );
- else
- sTempStringa = String( RTL_CONSTASCII_USTRINGPARAM( "\x0D\x0A" ) );
- String sTempStringb(sTempStringa);
- sTempStringb+=sComment;
- for(sal_uLong i=0;i<aVBAStrings.GetSize();i++)
- {
- aVBAStrings.Get(i)->SearchAndReplaceAll(
- sTempStringa,sTempStringb);
- aVBAStrings.Get(i)->Insert(sComment,0);
- }
- }
- }
- return aVBAStrings;
-}
-
-
-int VBA_Impl::DecompressVBA( int nIndex, SvStorageStreamRef &xVBAStream )
-{
- sal_uInt8 nLeadbyte;
- sal_uInt16 nToken;
- unsigned int nPos = 0;
- int nLen, nDistance, nShift, nClean=1;
-
- xVBAStream->Seek( pOffsets[ nIndex ].nOffset + 3 );
-
- while(xVBAStream->Read(&nLeadbyte,1))
- {
- for(int nPosition=0x01;nPosition < 0x100;nPosition=nPosition<<1)
- {
- //we see if the leadbyte has flagged this location as a dataunit
- //which is actually a token which must be looked up in the history
- if (nLeadbyte & nPosition)
- {
- *xVBAStream >> nToken;
-
- if (nClean == 0)
- nClean=1;
-
- //For some reason the division of the token into the length
- //field of the data to be inserted, and the distance back into
- //the history differs depending on how full the history is
- int nPos2 = nPos % nWINDOWLEN;
- if (nPos2 <= 0x10)
- nShift = 12;
- else if (nPos2 <= 0x20)
- nShift = 11;
- else if (nPos2 <= 0x40)
- nShift = 10;
- else if (nPos2 <= 0x80)
- nShift = 9;
- else if (nPos2 <= 0x100)
- nShift = 8;
- else if (nPos2 <= 0x200)
- nShift = 7;
- else if (nPos2 <= 0x400)
- nShift = 6;
- else if (nPos2 <= 0x800)
- nShift = 5;
- else
- nShift = 4;
-
- int i;
- nLen=0;
- for(i=0;i<nShift;i++)
- nLen |= nToken & (1<<i);
-
- nLen += 3;
-
- nDistance = nToken >> nShift;
-
- //read the len of data from the history, wrapping around the
- //nWINDOWLEN boundary if necessary data read from the history
- //is also copied into the recent part of the history as well.
- for (i = 0; i < nLen; i++)
- {
- unsigned char c;
- c = aHistory[(nPos-nDistance-1) % nWINDOWLEN];
- aHistory[nPos % nWINDOWLEN] = c;
- nPos++;
- }
- }
- else
- {
- // special boundary case code, not guarantueed to be correct
- // seems to work though, there is something wrong with the
- // compression scheme (or maybe a feature) where when the data
- // ends on a nWINDOWLEN boundary and the excess bytes in the 8
- // dataunit list are discarded, and not interpreted as tokens
- // or normal data.
- if ((nPos != 0) && ((nPos % nWINDOWLEN) == 0) && (nClean))
- {
- xVBAStream->SeekRel(2);
- nClean=0;
- Output(nWINDOWLEN, aHistory);
- break;
- }
- //This is the normal case for when the data unit is not a
- //token to be looked up, but instead some normal data which
- //can be output, and placed in the history.
- if (xVBAStream->Read(&aHistory[nPos % nWINDOWLEN],1))
- nPos++;
-
- if (nClean == 0)
- nClean=1;
- }
- }
- }
- if (nPos % nWINDOWLEN)
- Output(nPos % nWINDOWLEN,aHistory);
- return(nPos);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/msfilter/msvbasic.hxx b/filter/source/msfilter/msvbasic.hxx
deleted file mode 100644
index 1e5349684776..000000000000
--- a/filter/source/msfilter/msvbasic.hxx
+++ /dev/null
@@ -1,127 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _MSVBASIC_HXX
-#define _MSVBASIC_HXX
-
-#include <tools/solar.h>
-#include <tools/debug.hxx>
-#include <sot/storage.hxx>
-#include <tools/dynary.hxx>
-#include <vector>
-#include <map>
-#include <com/sun/star/script/ModuleType.hpp>
-using namespace ::com::sun::star::script::ModuleType;
-
-/* class VBA:
- * The VBA class provides a set of methods to handle Visual Basic For
- * Applications streams, the constructor is given the root ole2 stream
- * of the document, Open reads the VBA project file and figures out
- * the number of VBA streams, and the offset of the data within them.
- * Decompress decompresses a particular numbered stream, NoStreams returns
- * this number, and StreamName can give you the streams name. Decompress
- * will return a string with the decompressed data. The optional extra
- * argument will be set if not NULL to 1 in the case of a string overflow,
- * if I can figure out how to do that.
- *
- * Otherwise it is possible to inherit from VBA and implement a Output
- * member which gets called with each 4096 output sized block.
- *
- * cmc
- * */
-
-DECLARE_DYNARRAY(StringArray,String *)
-
-// define internal types to distinguish between
-// module types, form, class & normal
-// #i37965# add "Document", used in Excel for macros attached to sheet
-
-// define map to hold types of module
-typedef sal_Int32 ModType;
-typedef ::std::map< UniString,
- ModType > ModuleTypeHash;
-
-class VBA_Impl
-{
-public:
- VBA_Impl(SvStorage &rIn, bool bCmmntd = true);
- ~VBA_Impl();
- //0 for failure, 1 for success
- bool Open( const String &rToplevel, const String &rSublevel);
- const StringArray & Decompress(sal_uInt16 nIndex, int *pOverflow=0);
- sal_uInt16 GetNoStreams() const { return nOffsets; }
- const String &GetStreamName(sal_uInt16 nIndex) const
- {
- DBG_ASSERT( nIndex < nOffsets, "Index out of range" );
- return pOffsets[ nIndex ].sName;
- }
- //I'm the method that would be made virtual to make this class
- //useful elsewhere
- void Output(int len, const sal_uInt8 *data);
- //
- // #117718# member map of module names to types of module
- ModType GetModuleType( const UniString& rModuleName );
- rtl::OUString& ProjectName() { return msProjectName; }
- void SetProjectName( const rtl::OUString& rPName ) { msProjectName = rPName; }
- const std::vector<rtl::OUString>& ProjectReferences() { return maPrjReferences; }
- void AddProjectReference( const rtl::OUString& rProject ) { maPrjReferences.push_back( rProject); }
- SvStorage* GetStorage() { return xStor; }
-private:
- std::vector<rtl::OUString> maReferences;
- std::vector<rtl::OUString> maPrjReferences;
- struct VBAOffset_Impl
- {
- String sName;
- sal_uInt32 nOffset;
- };
-
- // #117718# member map of module names to types of module
- ModuleTypeHash mhModHash;
- SvStorageRef xVBA;
- StringArray aVBAStrings;
- String sComment;
- SvStorageRef xStor;
- VBAOffset_Impl *pOffsets;
- sal_uInt16 nOffsets;
- enum Limits {nWINDOWLEN = 4096};
- sal_uInt8 aHistory[nWINDOWLEN];
- rtl_TextEncoding meCharSet;
- bool bCommented;
- bool mbMac;
- int nLines;
-
- //0 for failure, anything else for success
- int ReadVBAProject(const SvStorageRef &rxVBAStorage);
- int DecompressVBA(int index, SvStorageStreamRef &rxVBAStream);
- sal_uInt8 ReadPString(SvStorageStreamRef &xVBAProject, bool bIsUnicode);
- rtl::OUString msProjectName;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx
index b87eb55a7278..2aa0a00c2b90 100644
--- a/filter/source/msfilter/svxmsbas.cxx
+++ b/filter/source/msfilter/svxmsbas.cxx
@@ -63,197 +63,6 @@ using namespace com::sun::star;
using rtl::OUString;
-static ::rtl::OUString sVBAOption( RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) );
-
-void SvxImportMSVBasic::extractAttribute( const String& rAttribute, const String& rModName )
-{
- // format of the attribute we are interested in is
- // Attribute VB_Control = "ControlName", intString, MSForms, ControlTypeAsString
- // e.g.
- // Attribute VB_Control = "CommandButton1, 201, 19, MSForms, CommandButton"
- String sControlAttribute( RTL_CONSTASCII_USTRINGPARAM("Attribute VB_Control = \"") );
- if ( rAttribute.Search( sControlAttribute ) != STRING_NOTFOUND )
- {
- String sRest = rAttribute.Copy( sControlAttribute.Len() );
- xub_StrLen nPos = 0;
- String sCntrlName = sRest.GetToken( 0, ',', nPos );
-
- sal_Int32 nCntrlId = sRest.GetToken( 0, ',', nPos).ToInt32();
- OSL_TRACE("In module %s, assiging %d controlname %s",
- rtl::OUStringToOString( rModName, RTL_TEXTENCODING_UTF8 ).getStr(), nCntrlId,
- rtl::OUStringToOString( sCntrlName, RTL_TEXTENCODING_UTF8 ).getStr() );
- m_ModuleNameToObjIdHash[ rModName ][ nCntrlId ] = sCntrlName;
- }
-}
-
-int SvxImportMSVBasic::Import( const String& rStorageName,
- const String &rSubStorageName,
- sal_Bool bAsComment, sal_Bool bStripped )
-{
- std::vector< String > codeNames;
- return Import( rStorageName, rSubStorageName, codeNames, bAsComment, bStripped );
-}
-int SvxImportMSVBasic::Import( const String& rStorageName,
- const String &rSubStorageName,
- const std::vector< String >& codeNames,
- sal_Bool bAsComment, sal_Bool bStripped )
-{
- msProjectName = rtl::OUString();
- int nRet = 0;
- if( bImport && ImportCode_Impl( rStorageName, rSubStorageName, codeNames,
- bAsComment, bStripped ))
- nRet |= 1;
-
- if (bImport)
- ImportForms_Impl(rStorageName, rSubStorageName, !bAsComment);
-
- if( bCopy && CopyStorage_Impl( rStorageName, rSubStorageName ))
- nRet |= 2;
-
- return nRet;
-}
-
-bool SvxImportMSVBasic::ImportForms_Impl(const String& rStorageName,
- const String& rSubStorageName, sal_Bool bVBAMode )
-{
- bool bRet = false;
- // #FIXME VBA_Impl ( or some other new class ) should handle both userforms
- // and code
- VBA_Impl aVBA( *xRoot, sal_True );
- // This call is a waste we read the source ( again ) only to get the refereneces
- // *AGAIN*, we really need to rewrite all of this
- aVBA.Open( rStorageName, rSubStorageName );
-
- bRet = ImportForms_Impl( aVBA, rStorageName, rSubStorageName, bVBAMode );
- std::vector<rtl::OUString> sProjectRefs = aVBA.ProjectReferences();
-
- for ( std::vector<rtl::OUString>::iterator it = sProjectRefs.begin(); it != sProjectRefs.end(); ++it )
- {
- rtl::OUString sFileName = *it;
-#ifndef WIN
-#ifdef DEBUG
- // hacky test code to read referenced projects on linux
- sal_Int32 nPos = (*it).lastIndexOf('\\');
- sFileName = (*it).copy( nPos + 1 );
- sFileName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "~/Documents/" )) + sFileName;
-#endif
-#endif
- SotStorageRef rRoot = new SotStorage( sFileName, STREAM_STD_READWRITE, STORAGE_TRANSACTED );
- VBA_Impl refVBA( *rRoot, sal_True );
- refVBA.Open( rStorageName, rSubStorageName );
- // The return from ImportForms doesn't indicate and error ( it could )
- // but also it just means no userforms were imported
- if ( ImportForms_Impl( refVBA, rStorageName, rSubStorageName, bVBAMode ) )
- bRet = true; // mark that at least on userform was imported
- }
- return bRet;
-}
-
-bool SvxImportMSVBasic::ImportForms_Impl( VBA_Impl& rVBA, const String& rStorageName, const String& rSubStorageName, sal_Bool /*bVBAMode*/ )
-{
- SvStorageRef xVBAStg(rVBA.GetStorage()->OpenSotStorage(rStorageName,
- STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYALL));
- if (!xVBAStg.Is() || xVBAStg->GetError())
- return false;
-
- std::vector<String> aUserForms;
- SvStorageInfoList aContents;
- xVBAStg->FillInfoList(&aContents);
- for (sal_uInt16 nI = 0; nI < aContents.size(); ++nI)
- {
- SvStorageInfo& rInfo = aContents[ nI ];
- if (!rInfo.IsStream() && rInfo.GetName() != rSubStorageName)
- aUserForms.push_back(rInfo.GetName());
- }
-
- if (aUserForms.empty())
- return false;
-
- bool bRet = true;
- try
- {
- Reference<XMultiServiceFactory> xSF(comphelper::getProcessServiceFactory());
-
- Reference<XComponentContext> xContext;
- Reference<XPropertySet> xProps(xSF, UNO_QUERY);
- xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext;
-
-
- Reference<XLibraryContainer> xLibContainer = rDocSh.GetDialogContainer();
- DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
-
- String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
-
- if (rVBA.ProjectName().getLength() )
- aLibName = rVBA.ProjectName();
- OSL_TRACE( "userformage lib name %s", rtl::OUStringToOString( aLibName, RTL_TEXTENCODING_UTF8 ).getStr() );
- Reference<XNameContainer> xLib;
- if (xLibContainer.is())
- {
- if( !xLibContainer->hasByName(aLibName))
- xLibContainer->createLibrary(aLibName);
-
- Any aLibAny = xLibContainer->getByName( aLibName );
- aLibAny >>= xLib;
- }
-
- if(xLib.is())
- {
- typedef std::vector<String>::iterator myIter;
- myIter aEnd = aUserForms.end();
- for (myIter aIter = aUserForms.begin(); aIter != aEnd; ++aIter)
- {
- SvStorageRef xForm (xVBAStg->OpenSotStorage(*aIter,
- STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYALL));
-
- if (!xForm.Is() || xForm->GetError())
- continue;
-
- SvStorageStreamRef xFrame = xForm->OpenSotStream(
- String( RTL_CONSTASCII_USTRINGPARAM( "\3VBFrame" ) ),
- STREAM_STD_READ | STREAM_NOCREATE);
-
- if (!xFrame.Is() || xFrame->GetError())
- continue;
-
- SvStorageStreamRef xTypes = xForm->OpenSotStream(
- String( 'f' ), STREAM_STD_READ | STREAM_NOCREATE);
-
- if (!xTypes.Is() || xTypes->GetError())
- continue;
-
- //<UserForm Name=""><VBFrame></VBFrame>"
- String sData;
- String sLine;
- while(xFrame->ReadByteStringLine(sLine, RTL_TEXTENCODING_MS_1252))
- {
- sData += sLine;
- sData += '\n';
- }
- sData.ConvertLineEnd();
-
- Reference<container::XNameContainer> xDialog(
- xSF->createInstance(
- OUString(RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.awt.UnoControlDialogModel"))), uno::UNO_QUERY);
- OCX_UserForm aForm(xVBAStg, *aIter, *aIter, xDialog, xSF );
- aForm.pDocSh = &rDocSh;
- sal_Bool bOk = aForm.Read(xTypes);
- DBG_ASSERT(bOk, "Had unexpected content, not risking this module");
- if (bOk)
- aForm.Import(xLib);
- }
- }
- }
- catch(...)
- {
- DBG_ERRORFILE( "SvxImportMSVBasic::ImportForms_Impl - any exception caught" );
- //bRet = false;
- }
- return bRet;
-}
-
-
sal_Bool SvxImportMSVBasic::CopyStorage_Impl( const String& rStorageName,
const String& rSubStorageName)
{
@@ -295,292 +104,4 @@ sal_Bool SvxImportMSVBasic::CopyStorage_Impl( const String& rStorageName,
return bValidStg;
}
-
-sal_Bool SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
- const String &rSubStorageName,
- const std::vector< String >& codeNames,
- sal_Bool bAsComment, sal_Bool bStripped )
-{
- sal_Bool bRet = sal_False;
- VBA_Impl aVBA( *xRoot, bAsComment );
-
- if( aVBA.Open(rStorageName,rSubStorageName) )
- {
- msProjectName = aVBA.ProjectName();
-
- if ( msProjectName.getLength() )
- rDocSh.GetBasicManager()->SetName( msProjectName ); // set name of Project
-
- bRet = ImportCode_Impl( aVBA, codeNames, bAsComment, bStripped );
- std::vector<rtl::OUString> sProjectRefs = aVBA.ProjectReferences();
-
- for ( std::vector<rtl::OUString>::iterator it = sProjectRefs.begin(); it != sProjectRefs.end(); ++it )
- {
- rtl::OUString sFileName = *it;
- OSL_TRACE("referenced project %s ", rtl::OUStringToOString( sFileName, RTL_TEXTENCODING_UTF8 ).getStr() );
- SotStorageRef rRoot = new SotStorage( sFileName, STREAM_STD_READWRITE, STORAGE_TRANSACTED );
- VBA_Impl refVBA( *rRoot, bAsComment );
- std::vector< String > codeNamesNone;
- if( refVBA.Open(rStorageName,rSubStorageName) && ImportCode_Impl( refVBA, codeNamesNone, bAsComment, bStripped ) )
- bRet = sal_True; // mark that some code was imported
- }
- }
- return bRet;
-}
-
-sal_Bool SvxImportMSVBasic::ImportCode_Impl( VBA_Impl& aVBA, const std::vector< String >& codeNames, sal_Bool bAsComment, sal_Bool bStripped )
-{
- sal_Bool bRet = sal_False;
- Reference<XLibraryContainer> xLibContainer = rDocSh.GetBasicContainer();
- DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
-
- /* Set library container to VBA compatibility mode. This will create
- the VBA Globals object and store it in the Basic manager of the
- document. */
- if( !bAsComment ) try
- {
- Reference< vba::XVBACompatibility >( xLibContainer, UNO_QUERY_THROW )->setVBACompatibilityMode( sal_True );
- }
- catch( Exception& )
- {
- }
-
- sal_uInt16 nStreamCount = aVBA.GetNoStreams();
- Reference<XNameContainer> xLib;
- String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
- if ( aVBA.ProjectName().getLength() )
- aLibName = aVBA.ProjectName();
- if( xLibContainer.is() && nStreamCount )
- {
- if( !xLibContainer->hasByName( aLibName ) )
- xLibContainer->createLibrary( aLibName );
-
- Any aLibAny = xLibContainer->getByName( aLibName );
- aLibAny >>= xLib;
- }
- if( xLib.is() )
- {
- Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY );
- Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
- if ( !bAsComment )
- {
- Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
- if ( xSF.is() )
- {
- try
- {
- xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), UNO_QUERY );
- }
- catch( Exception& ) { }
- }
- }
- typedef boost::unordered_map< rtl::OUString, uno::Any, ::rtl::OUStringHash,
-::std::equal_to< ::rtl::OUString > > NameModuleDataHash;
- typedef boost::unordered_map< rtl::OUString, script::ModuleInfo, ::rtl::OUStringHash,
-::std::equal_to< ::rtl::OUString > > NameModuleInfoHash;
-
- NameModuleDataHash moduleData;
- NameModuleInfoHash moduleInfos;
-
- for( sal_uInt16 i=0; i<nStreamCount;i++)
- {
- StringArray aDecompressed = aVBA.Decompress(i);
-#if 0
-/* Do not filter special characters from module name.
- Just put the original module name and let the Basic interpreter deal with
- it. Needed for roundtrip...
- */
- ByteString sByteBasic(aVBA.GetStreamName(i),
- RTL_TEXTENCODING_ASCII_US,
- (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE|
- RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE |
- RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |
- RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE)
- );
-
- const String sBasicModule(sByteBasic,
- RTL_TEXTENCODING_ASCII_US);
-#else
- const String &sBasicModule = aVBA.GetStreamName( i);
-#endif
- /* #117718# expose information regarding type of Module
- * Class, Form or plain 'ould VBA module with a REM statment
- * at the top of the module. Mapping of Module Name
- * to type is performed in VBA_Impl::Open() method,
- * ( msvbasic.cxx ) by examining the PROJECT stream.
- */
-
- // using name from aVBA.GetStreamName
- // because the encoding of the same returned
- // is the same as the encoding for the names
- // that are keys in the map used by GetModuleType method
- const String &sOrigVBAModName = aVBA.GetStreamName( i );
- ModType mType = aVBA.GetModuleType( sOrigVBAModName );
-
- rtl::OUString sClassRem( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=" ) );
-
- rtl::OUString modeTypeComment;
-
- switch( mType )
- {
- case ModuleType::CLASS:
- modeTypeComment = sClassRem +
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAClassModule\n" ) );
- break;
- case ModuleType::FORM:
- modeTypeComment = sClassRem +
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAFormModule\n" ) );
- break;
- case ModuleType::DOCUMENT:
- modeTypeComment = sClassRem +
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBADocumentModule\n" ) );
- break;
- case ModuleType::NORMAL:
- modeTypeComment = sClassRem +
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAModule\n" ) );
- break;
- case ModuleType::UNKNOWN:
- modeTypeComment = sClassRem +
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAUnknown\n" ) );
- break;
- default:
- DBG_ERRORFILE( "SvxImportMSVBasic::ImportCode_Impl - unknown module type" );
- break;
- }
- static ::rtl::OUString sClassOption( RTL_CONSTASCII_USTRINGPARAM( "Option ClassModule\n" ) );
- if ( !bAsComment )
- {
- modeTypeComment += sVBAOption;
- if ( mType == ModuleType::CLASS )
- modeTypeComment += sClassOption;
- }
-
- String sModule(sBasicModule); //#i52606# no need to split Macros in 64KB blocks any more!
- String sTemp;
- if (bAsComment)
- {
- sTemp+=String(RTL_CONSTASCII_USTRINGPARAM( "Sub " ));
- String sMunge(sModule);
- //Streams can have spaces in them, but modulenames
- //cannot !
- sMunge.SearchAndReplaceAll(' ','_');
-
- sTemp += sMunge;
- sTemp.AppendAscii("\n");
- };
- ::rtl::OUString aSource(sTemp);
-
- for(sal_uLong j=0;j<aDecompressed.GetSize();j++)
- {
- if (bStripped)
- {
- String *pStr = aDecompressed.Get(j);
- bool bMac = true;
- xub_StrLen nBegin = pStr->Search('\x0D');
- if ((STRING_NOTFOUND != nBegin) && (pStr->Len() > 1) && (pStr->GetChar(nBegin+1) == '\x0A'))
- bMac = false;
-
- const char cLineEnd = bMac ? '\x0D' : '\x0A';
- const String sAttribute(String::CreateFromAscii(
- bAsComment ? "Rem Attribute" : "Attribute"));
- nBegin = 0;
- while (STRING_NOTFOUND != (nBegin = pStr->Search(sAttribute, nBegin)))
- {
- if ((nBegin) && pStr->GetChar(nBegin-1) != cLineEnd)
- {
- // npower #i63766# Need to skip instances of Attribute
- // that are NOT Attribute statements
- nBegin = nBegin + sAttribute.Len();
- continue;
- }
- xub_StrLen nEnd = pStr->Search(cLineEnd ,nBegin);
- // DR #i26521# catch STRING_NOTFOUND, will loop endless otherwise
- if( nEnd == STRING_NOTFOUND )
- pStr->Erase();
- else
- {
- String sAttr= pStr->Copy( nBegin, (nEnd-nBegin)+1);
- extractAttribute( sAttr, sModule );
- pStr->Erase(nBegin, (nEnd-nBegin)+1);
- }
- }
- }
- if( aDecompressed.Get(j)->Len() )
- {
- aSource+=::rtl::OUString( *aDecompressed.Get(j) );
- }
-
- }
- if (bAsComment)
- {
- aSource += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\nEnd Sub" ));
- }
- ::rtl::OUString aModName( sModule );
- aSource = modeTypeComment + aSource;
-
- Any aSourceAny;
- OSL_TRACE("erm %d", mType );
- aSourceAny <<= aSource;
- if ( !bAsComment )
- {
- OSL_TRACE("vba processing %d", mType );
- script::ModuleInfo sModuleInfo;
- sModuleInfo.ModuleType = mType;
- moduleInfos[ aModName ] = sModuleInfo;
- }
- moduleData[ aModName ] = aSourceAny;
- }
- // Hack for missing codenames ( only know to happen in excel but... )
- // only makes sense to do this if we are importing non-commented basic
- if ( !bAsComment )
- {
- for ( std::vector< String >::const_iterator it = codeNames.begin(); it != codeNames.end(); ++it )
- {
- script::ModuleInfo sModuleInfo;
- sModuleInfo.ModuleType = ModuleType::DOCUMENT;
- moduleInfos[ *it ] = sModuleInfo;
- moduleData[ *it ] = uno::makeAny( sVBAOption );
- }
- }
- NameModuleDataHash::iterator it_end = moduleData.end();
- for ( NameModuleDataHash::iterator it = moduleData.begin(); it != it_end; ++it )
- {
- NameModuleInfoHash::iterator it_info = moduleInfos.find( it->first );
- if ( it_info != moduleInfos.end() )
- {
- ModuleInfo& sModuleInfo = it_info->second;
- if ( sModuleInfo.ModuleType == ModuleType::FORM )
- // hack, the module ( imo document basic should...
- // know the XModel... ) but it doesn't
- sModuleInfo.ModuleObject.set( rDocSh.GetModel(), UNO_QUERY );
- // document modules, we should be able to access
- // the api objects at this time
- else if ( sModuleInfo.ModuleType == ModuleType::DOCUMENT )
- {
- if ( xVBACodeNamedObjectAccess.is() )
- {
- try
- {
- sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( it->first ), uno::UNO_QUERY );
- OSL_TRACE("** Straight up creation of Module");
- }
- catch(uno::Exception& e)
- {
- OSL_TRACE("Failed to get documument object for %s", rtl::OUStringToOString( it->first, RTL_TEXTENCODING_UTF8 ).getStr() );
- }
- }
- }
- xVBAModuleInfo->insertModuleInfo( it->first, sModuleInfo );
- }
-
- if( xLib->hasByName( it->first ) )
- xLib->replaceByName( it->first, it->second );
- else
- xLib->insertByName( it->first, it->second );
- }
- bRet = true;
- }
- return bRet;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index fdf5185146de..b39d363eec3d 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -616,6 +616,11 @@ public:
std::vector<String> maListEntries;
virtual ~WW8FormulaControl() {}
void FormulaRead(SwWw8ControlType nWhich,SvStream *pD);
+ virtual sal_Bool Import(const com::sun::star::uno::Reference <
+ com::sun::star::lang::XMultiServiceFactory> &rServiceFactory,
+ com::sun::star::uno::Reference <
+ com::sun::star::form::XFormComponent> &rFComp,
+ com::sun::star::awt::Size &rSz) = 0;
private:
//No copying
WW8FormulaControl(const WW8FormulaControl&);
@@ -629,8 +634,6 @@ private:
WW8FormulaCheckBox(const WW8FormulaCheckBox&);
WW8FormulaCheckBox& operator=(const WW8FormulaCheckBox&);
- using OCX_Control::Import;
-
public:
WW8FormulaCheckBox(SwWW8ImplReader &rR);
@@ -648,8 +651,6 @@ private:
WW8FormulaListBox(const WW8FormulaListBox&);
WW8FormulaListBox& operator=(const WW8FormulaListBox&);
- using OCX_Control::Import;
-
public:
WW8FormulaListBox(SwWW8ImplReader &rR);
@@ -668,6 +669,12 @@ private:
WW8FormulaEditBox& operator=(const WW8FormulaEditBox&);
public:
WW8FormulaEditBox(SwWW8ImplReader &rR);
+ //no real implementation, return false
+ virtual sal_Bool Import(const com::sun::star::uno::Reference <
+ com::sun::star::lang::XMultiServiceFactory> &rServiceFactory,
+ com::sun::star::uno::Reference <
+ com::sun::star::form::XFormComponent> &rFComp,
+ com::sun::star::awt::Size &rSz) { return sal_False; }
};
class SwMSConvertControls: public SvxMSConvertOCXControls