Converting C++ Props

K

Ken

Is there a easy way to convert properties from C++?

Here is the code I am working with:

PROP rgprop [ipropMax] = {
actnByte, propChp, offsetof(CHP, fBold), // ipropBold
actnByte, propChp, offsetof(CHP, fItalic), // ipropItalic
actnByte, propChp, offsetof(CHP, fUnderline), // ipropUnderline
actnWord, propPap, offsetof(PAP, xaLeft), // ipropLeftInd
actnWord, propPap, offsetof(PAP, xaRight), // ipropRightInd
actnWord, propPap, offsetof(PAP, xaFirst), // ipropFirstInd
actnWord, propSep, offsetof(SEP, cCols), // ipropCols
actnWord, propSep, offsetof(SEP, xaPgn), // ipropPgnX
actnWord, propSep, offsetof(SEP, yaPgn), // ipropPgnY
actnWord, propDop, offsetof(DOP, xaPage), // ipropXaPage
actnWord, propDop, offsetof(DOP, yaPage), // ipropYaPage
actnWord, propDop, offsetof(DOP, xaLeft), // ipropXaLeft
actnWord, propDop, offsetof(DOP, xaRight), // ipropXaRight
actnWord, propDop, offsetof(DOP, yaTop), // ipropYaTop
actnWord, propDop, offsetof(DOP, yaBottom), // ipropYaBottom
actnWord, propDop, offsetof(DOP, pgnStart), // ipropPgnStart
actnByte, propSep, offsetof(SEP, sbk), // ipropSbk
actnByte, propSep, offsetof(SEP, pgnFormat), // ipropPgnFormat
actnByte, propDop, offsetof(DOP, fFacingp), // ipropFacingp
actnByte, propDop, offsetof(DOP, fLandscape), // ipropLandscape
actnByte, propPap, offsetof(PAP, just), // ipropJust
actnSpec, propPap, 0, // ipropPard
actnSpec, propChp, 0, // ipropPlain
actnSpec, propSep, 0, // ipropSectd
};
 
B

Banana

Ken said:
Is there a easy way to convert properties from C++?

Here is the code I am working with:

PROP rgprop [ipropMax] = {
actnByte, propChp, offsetof(CHP, fBold), // ipropBold
actnByte, propChp, offsetof(CHP, fItalic), // ipropItalic
actnByte, propChp, offsetof(CHP, fUnderline), // ipropUnderline
actnWord, propPap, offsetof(PAP, xaLeft), // ipropLeftInd
actnWord, propPap, offsetof(PAP, xaRight), // ipropRightInd
actnWord, propPap, offsetof(PAP, xaFirst), // ipropFirstInd
actnWord, propSep, offsetof(SEP, cCols), // ipropCols
actnWord, propSep, offsetof(SEP, xaPgn), // ipropPgnX
actnWord, propSep, offsetof(SEP, yaPgn), // ipropPgnY
actnWord, propDop, offsetof(DOP, xaPage), // ipropXaPage
actnWord, propDop, offsetof(DOP, yaPage), // ipropYaPage
actnWord, propDop, offsetof(DOP, xaLeft), // ipropXaLeft
actnWord, propDop, offsetof(DOP, xaRight), // ipropXaRight
actnWord, propDop, offsetof(DOP, yaTop), // ipropYaTop
actnWord, propDop, offsetof(DOP, yaBottom), // ipropYaBottom
actnWord, propDop, offsetof(DOP, pgnStart), // ipropPgnStart
actnByte, propSep, offsetof(SEP, sbk), // ipropSbk
actnByte, propSep, offsetof(SEP, pgnFormat), // ipropPgnFormat
actnByte, propDop, offsetof(DOP, fFacingp), // ipropFacingp
actnByte, propDop, offsetof(DOP, fLandscape), // ipropLandscape
actnByte, propPap, offsetof(PAP, just), // ipropJust
actnSpec, propPap, 0, // ipropPard
actnSpec, propChp, 0, // ipropPlain
actnSpec, propSep, 0, // ipropSectd
};

Where is the C++ code coming from? I'm assuming you want to convert this
to VBA? Furthermore, if it's a property, doesn't it imply there is an
associated object you need to convert? Finally, do you really need to
convert the code? Wouldn't it be easier to call the C++ code directly
from VBA?
 
C

Clifford Bass via AccessMonster.com

Hi Ken,

These are not standard C++ items. You will need to tell us what PROP,
ipropMax, actnByte, PropChp, CHP and a whole bunch of other items are that
are there in that array. Somewhere I presume they are #defined, probably in
a header file. Without further information, I can only guess that it is a C
int/long array, which would be an array of type Long in VBA. So it might
convert to:

Dim rgprop(0 to 71) As Long

' Code to initialize the values
rgprop(0) = ???
rgprop(1) = ???
rgprop(2) = ???
' etc.

You could store the values in a table and read them into the array.

Perhaps that helps?

Clifford Bass
Is there a easy way to convert properties from C++?

Here is the code I am working with:

PROP rgprop [ipropMax] = {
actnByte, propChp, offsetof(CHP, fBold), // ipropBold
actnByte, propChp, offsetof(CHP, fItalic), // ipropItalic
actnByte, propChp, offsetof(CHP, fUnderline), // ipropUnderline
actnWord, propPap, offsetof(PAP, xaLeft), // ipropLeftInd
actnWord, propPap, offsetof(PAP, xaRight), // ipropRightInd
actnWord, propPap, offsetof(PAP, xaFirst), // ipropFirstInd
actnWord, propSep, offsetof(SEP, cCols), // ipropCols
actnWord, propSep, offsetof(SEP, xaPgn), // ipropPgnX
actnWord, propSep, offsetof(SEP, yaPgn), // ipropPgnY
actnWord, propDop, offsetof(DOP, xaPage), // ipropXaPage
actnWord, propDop, offsetof(DOP, yaPage), // ipropYaPage
actnWord, propDop, offsetof(DOP, xaLeft), // ipropXaLeft
actnWord, propDop, offsetof(DOP, xaRight), // ipropXaRight
actnWord, propDop, offsetof(DOP, yaTop), // ipropYaTop
actnWord, propDop, offsetof(DOP, yaBottom), // ipropYaBottom
actnWord, propDop, offsetof(DOP, pgnStart), // ipropPgnStart
actnByte, propSep, offsetof(SEP, sbk), // ipropSbk
actnByte, propSep, offsetof(SEP, pgnFormat), // ipropPgnFormat
actnByte, propDop, offsetof(DOP, fFacingp), // ipropFacingp
actnByte, propDop, offsetof(DOP, fLandscape), // ipropLandscape
actnByte, propPap, offsetof(PAP, just), // ipropJust
actnSpec, propPap, 0, // ipropPard
actnSpec, propChp, 0, // ipropPlain
actnSpec, propSep, 0, // ipropSectd
};
 
K

Ken

Yes I want to convert the code to VBA. I don't want to call the external
code but use the code to convert the RTF tags to LaTex.

The code comes from Microsofts gc1039 Conversion SDK.

The properties are integers defined elsewhere. I was hoping there was a
easy way to convert the code to VBA without having to implicitily set each
item in the structure, but it does not look like it.


Clifford Bass via AccessMonster.com said:
Hi Ken,

These are not standard C++ items. You will need to tell us what PROP,
ipropMax, actnByte, PropChp, CHP and a whole bunch of other items are that
are there in that array. Somewhere I presume they are #defined, probably in
a header file. Without further information, I can only guess that it is a C
int/long array, which would be an array of type Long in VBA. So it might
convert to:

Dim rgprop(0 to 71) As Long

' Code to initialize the values
rgprop(0) = ???
rgprop(1) = ???
rgprop(2) = ???
' etc.

You could store the values in a table and read them into the array.

Perhaps that helps?

Clifford Bass
Is there a easy way to convert properties from C++?

Here is the code I am working with:

PROP rgprop [ipropMax] = {
actnByte, propChp, offsetof(CHP, fBold), // ipropBold
actnByte, propChp, offsetof(CHP, fItalic), // ipropItalic
actnByte, propChp, offsetof(CHP, fUnderline), // ipropUnderline
actnWord, propPap, offsetof(PAP, xaLeft), // ipropLeftInd
actnWord, propPap, offsetof(PAP, xaRight), // ipropRightInd
actnWord, propPap, offsetof(PAP, xaFirst), // ipropFirstInd
actnWord, propSep, offsetof(SEP, cCols), // ipropCols
actnWord, propSep, offsetof(SEP, xaPgn), // ipropPgnX
actnWord, propSep, offsetof(SEP, yaPgn), // ipropPgnY
actnWord, propDop, offsetof(DOP, xaPage), // ipropXaPage
actnWord, propDop, offsetof(DOP, yaPage), // ipropYaPage
actnWord, propDop, offsetof(DOP, xaLeft), // ipropXaLeft
actnWord, propDop, offsetof(DOP, xaRight), // ipropXaRight
actnWord, propDop, offsetof(DOP, yaTop), // ipropYaTop
actnWord, propDop, offsetof(DOP, yaBottom), // ipropYaBottom
actnWord, propDop, offsetof(DOP, pgnStart), // ipropPgnStart
actnByte, propSep, offsetof(SEP, sbk), // ipropSbk
actnByte, propSep, offsetof(SEP, pgnFormat), // ipropPgnFormat
actnByte, propDop, offsetof(DOP, fFacingp), // ipropFacingp
actnByte, propDop, offsetof(DOP, fLandscape), // ipropLandscape
actnByte, propPap, offsetof(PAP, just), // ipropJust
actnSpec, propPap, 0, // ipropPard
actnSpec, propChp, 0, // ipropPlain
actnSpec, propSep, 0, // ipropSectd
};

--



.
 
C

Clifford Bass via AccessMonster.com

Hi Ken,

Since you are converting all the code to VBA and do not intend to call
out to the external code, you might try the Array() function which returns a
variant that contains an array.

Dim rgprop As Variant

rgprop = Array(???, ???, ???, ...)

Clifford Bass
 
C

ChrisO

Just a guess but it might convert to
the User-defined Data Type rgProp.

If you want it to be persistent you
could also try creating Tables for
each of the UDT's CHP, PAP, SEP and
DOP and relate those to Table rgProp.

Public Type CHP
fBold As Byte
fItalic As Byte
fUnderline As Byte
End Type

Public Type PAP
xaLeft As Long
xaRight As Long
xaFirst As Long
just As Byte
End Type

Public Type SEP
cCols As Long
xaPgn As Long
yaPgn As Long
sbk As Byte
pgnFormat As Byte
End Type

Public Type DOP
xaPage As Long
yaPage As Long
xaLeft As Long
xaRight As Long
yaTop As Long
yaBottom As Long
pgnStart As Long
fFacingp As Byte
fLandscape As Byte
End Type

Public Type rgProp
ipropPard As Variant ' Don't know what this is.
ipropPlain As Variant ' Don't know what this is.
ipropSectd As Variant ' Don't know what this is.
propChp As CHP
propPap As PAP
propSep As SEP
propDop As DOP
End Type


Sub TestIt()
Dim MyrgProp As rgProp

With LoadProp(MyrgProp)
Debug.Print .ipropPard
Debug.Print .ipropPlain
Debug.Print .ipropSectd

Debug.Print .propChp.fBold
Debug.Print .propChp.fItalic
Debug.Print .propChp.fUnderline

Debug.Print .propPap.xaLeft
Debug.Print .propPap.xaRight
Debug.Print .propPap.xaFirst
Debug.Print .propPap.just

' And so forth.
End With

End Sub


Public Function LoadProp(ByRef Prop As rgProp) As rgProp

LoadProp.ipropPard = Null
LoadProp.ipropPlain = Null
LoadProp.ipropSectd = Null

LoadProp.propChp.fBold = 1
LoadProp.propChp.fItalic = 0
LoadProp.propChp.fUnderline = 0

LoadProp.propPap.xaLeft = 1234
LoadProp.propPap.xaRight = 5678
LoadProp.propPap.xaFirst = 1
LoadProp.propPap.just = 0

' And so forth.

End Function

--
A nod is as good as a wink to a blind horse.


Ken said:
Yes I want to convert the code to VBA. I don't want to call the external
code but use the code to convert the RTF tags to LaTex.

The code comes from Microsofts gc1039 Conversion SDK.

The properties are integers defined elsewhere. I was hoping there was a
easy way to convert the code to VBA without having to implicitily set each
item in the structure, but it does not look like it.


Clifford Bass via AccessMonster.com said:
Hi Ken,

These are not standard C++ items. You will need to tell us what PROP,
ipropMax, actnByte, PropChp, CHP and a whole bunch of other items are that
are there in that array. Somewhere I presume they are #defined, probably in
a header file. Without further information, I can only guess that it is a C
int/long array, which would be an array of type Long in VBA. So it might
convert to:

Dim rgprop(0 to 71) As Long

' Code to initialize the values
rgprop(0) = ???
rgprop(1) = ???
rgprop(2) = ???
' etc.

You could store the values in a table and read them into the array.

Perhaps that helps?

Clifford Bass
Is there a easy way to convert properties from C++?

Here is the code I am working with:

PROP rgprop [ipropMax] = {
actnByte, propChp, offsetof(CHP, fBold), // ipropBold
actnByte, propChp, offsetof(CHP, fItalic), // ipropItalic
actnByte, propChp, offsetof(CHP, fUnderline), // ipropUnderline
actnWord, propPap, offsetof(PAP, xaLeft), // ipropLeftInd
actnWord, propPap, offsetof(PAP, xaRight), // ipropRightInd
actnWord, propPap, offsetof(PAP, xaFirst), // ipropFirstInd
actnWord, propSep, offsetof(SEP, cCols), // ipropCols
actnWord, propSep, offsetof(SEP, xaPgn), // ipropPgnX
actnWord, propSep, offsetof(SEP, yaPgn), // ipropPgnY
actnWord, propDop, offsetof(DOP, xaPage), // ipropXaPage
actnWord, propDop, offsetof(DOP, yaPage), // ipropYaPage
actnWord, propDop, offsetof(DOP, xaLeft), // ipropXaLeft
actnWord, propDop, offsetof(DOP, xaRight), // ipropXaRight
actnWord, propDop, offsetof(DOP, yaTop), // ipropYaTop
actnWord, propDop, offsetof(DOP, yaBottom), // ipropYaBottom
actnWord, propDop, offsetof(DOP, pgnStart), // ipropPgnStart
actnByte, propSep, offsetof(SEP, sbk), // ipropSbk
actnByte, propSep, offsetof(SEP, pgnFormat), // ipropPgnFormat
actnByte, propDop, offsetof(DOP, fFacingp), // ipropFacingp
actnByte, propDop, offsetof(DOP, fLandscape), // ipropLandscape
actnByte, propPap, offsetof(PAP, just), // ipropJust
actnSpec, propPap, 0, // ipropPard
actnSpec, propChp, 0, // ipropPlain
actnSpec, propSep, 0, // ipropSectd
};

--



.
 
C

Clifford Bass via AccessMonster.com

Hi Ken,

In looking at the C files, I come up with this as a start:

' C definitions

' typedef enum {actnSpec, actnByte, actnWord} ACTN;
' typedef enum {propChp, propPap, propSep, propDop} PROPTYPE;
' typedef enum {ipropBold, ipropItalic, ipropUnderline, ipropLeftInd,
' ipropRightInd, ipropFirstInd, ipropCols, ipropPgnX,
' ipropPgnY, ipropXaPage, ipropYaPage, ipropXaLeft,
' ipropXaRight, ipropYaTop, ipropYaBottom, ipropPgnStart,
' ipropSbk, ipropPgnFormat, ipropFacingp, ipropLandscape,
' ipropJust, ipropPard, ipropPlain, ipropSectd,
' ipropMax } IPROP;

' typedef struct propmod
' {
' ACTN actn; // size of value
' PROPTYPE prop; // structure containing value
' int offset; // offset of value from base of structure
' } PROP;

' typedef struct char_prop
' {
' char fBold;
' char fUnderline;
' char fItalic;
' } CHP; // CHaracter Properties

' PROP rgprop [ipropMax] = {
' actnByte, propChp, offsetof(CHP, fBold), // ipropBold
' actnByte, propChp, offsetof(CHP, fItalic), // ipropItalic
' actnByte, propChp, offsetof(CHP, fUnderline), // ipropUnderline
' actnWord, propPap, offsetof(PAP, xaLeft), // ipropLeftInd
' actnWord, propPap, offsetof(PAP, xaRight), // ipropRightInd
' actnWord, propPap, offsetof(PAP, xaFirst), // ipropFirstInd
' actnWord, propSep, offsetof(SEP, cCols), // ipropCols
' actnWord, propSep, offsetof(SEP, xaPgn), // ipropPgnX
' actnWord, propSep, offsetof(SEP, yaPgn), // ipropPgnY
' actnWord, propDop, offsetof(DOP, xaPage), // ipropXaPage
' actnWord, propDop, offsetof(DOP, yaPage), // ipropYaPage
' actnWord, propDop, offsetof(DOP, xaLeft), // ipropXaLeft
' actnWord, propDop, offsetof(DOP, xaRight), // ipropXaRight
' actnWord, propDop, offsetof(DOP, yaTop), // ipropYaTop
' actnWord, propDop, offsetof(DOP, yaBottom), // ipropYaBottom
' actnWord, propDop, offsetof(DOP, pgnStart), // ipropPgnStart
' actnByte, propSep, offsetof(SEP, sbk), // ipropSbk
' actnByte, propSep, offsetof(SEP, pgnFormat), // ipropPgnFormat
' actnByte, propDop, offsetof(DOP, fFacingp), // ipropFacingp
' actnByte, propDop, offsetof(DOP, fLandscape), // ipropLandscape
' actnByte, propPap, offsetof(PAP, just), // ipropJust
' actnSpec, propPap, 0, // ipropPard
' actnSpec, propChp, 0, // ipropPlain
' actnSpec, propSep, 0, // ipropSectd
' };

' VBA definitions
Public Enum eACTN ' Added e to beginning of name to distinguish
' it from the "actn" element of tPROP
actnSpec
actnByte
actnWord
End Enum

Public Enum ePROPTYPE ' Added e to beginning of name to be
' consistent
propChp
propPap
propSep
propDop
End Enum

Public Enum eIPROP ' Added e to be consistent
ipropBold
ipropItalic
ipropUnderline
ipropLeftInd
ipropRightInd
ipropFirstInd
ipropCols
ipropPgnX
ipropPgnY
ipropXaPage
ipropYaPage
ipropXaLeft
ipropXaRight
ipropYaTop
ipropYaBottom
ipropPgnStart
ipropSbk
ipropPgnFormat
ipropFacingp
ipropLandscape
ipropJust
ipropPard
ipropPlain
ipropSectd

ipropmax
End Enum

Public Type tPROP ' Added t to beginning of name to
' distinguish it from the "prop" element
actn As eACTN ' Size of value
prop As ePROPTYPE ' Structure containing value
offset As Long ' Offset of value from base of structure
End Type

Public Type tCHP ' Added t to be consistent
fBold As Byte
fUnderline As Byte
fItalic As Byte
End Type ' CHaracter Properties

Private rgprop(0 To ipropmax - 1) As tPROP

Public Sub Initialize_rgprop()

With rgprop(ipropBold)
.actn = actnByte
.prop = propChp
.offset = 0
End With
With rgprop(ipropItalic)
.actn = actnByte
.prop = propChp
.offset = 2
End With
With rgprop(ipropUnderline)
.actn = actnByte
.prop = propChp
.offset = 1
End With

' etc.

End Sub

I am not sure if there is a way in VBA to get the offset (in bytes) of
an item in a Type or if you will just have to calculate that by hand and
enter it as a constant as I did. That item may not be needed for all I know.
As you go through the code, it will be for you to determine.

Hope that helps,

Clifford Bass
 
Top