Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » Ole Automation [FEATURE REQUEST?]
Ole Automation [FEATURE REQUEST?] [message #17864] Sun, 31 August 2008 21:20 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

Do you have any program using Upp++ for Ole automation? (only windows). This serve to handle not only Office programs like Excel or Word but other like Catia 5.

If it does exist it could be prepared as a class that may be added to Bazaar.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #18729 is a reply to message #17864] Sat, 18 October 2008 21:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

I am doing the job.

Next week I expect to have the first sample of a basic class to handle Excel spreadsheets.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19067 is a reply to message #18729] Sat, 08 November 2008 14:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Sat, 18 October 2008 15:02

Hello all

I am doing the job.

Next week I expect to have the first sample of a basic class to handle Excel spreadsheets.

Best regards
Koldo


Cute. Have you succeeded?

Mirek
Re: Ole Automation [FEATURE REQUEST?] [message #19075 is a reply to message #19067] Sun, 09 November 2008 17:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello luzr

Yes. I did some functions to handle Ole and a small demo filling an excel spreadsheet.

As I did not see any answer about this I centered to other functions, but after that I wanted to do the job.

Here I enclose you the public: side of the class declaration that is implemented.

class MSSheet
{
public:
	MSSheet();
	~MSSheet();
	
	bool AddSheet();
	bool OpenSheet(String fileName);
	bool SetVisible(bool);
	bool SetValue(int row, int col, String value);
	String GetValue(int row, int col);
	bool FillRange(String range);
	bool SetSaved(bool);
	bool SaveAs(String fileName, String type = "excel");
	void Quit();
};


I wanted to extend this class and to add other classes like MSText and Catia (to handle CAD program Dassault Catia V) as I know rather well the ole interface to them.

I was wondering too if doing something similar with OpenOffice so with the same set of functions we could handle both programs. But it is not very easy so I wanted to go step by step.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19171 is a reply to message #19075] Sun, 16 November 2008 18:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Sun, 09 November 2008 11:11

Hello luzr

Yes. I did some functions to handle Ole and a small demo filling an excel spreadsheet.

As I did not see any answer about this I centered to other functions, but after that I wanted to do the job.

Here I enclose you the public: side of the class declaration that is implemented.

class MSSheet
{
public:
	MSSheet();
	~MSSheet();
	
	bool AddSheet();
	bool OpenSheet(String fileName);
	bool SetVisible(bool);
	bool SetValue(int row, int col, String value);
	String GetValue(int row, int col);
	bool FillRange(String range);
	bool SetSaved(bool);
	bool SaveAs(String fileName, String type = "excel");
	void Quit();
};


I wanted to extend this class and to add other classes like MSText and Catia (to handle CAD program Dassault Catia V) as I know rather well the ole interface to them.

I was wondering too if doing something similar with OpenOffice so with the same set of functions we could handle both programs. But it is not very easy so I wanted to go step by step.

Best regards
Koldo


Great job. Any plans makeing them public? Smile

Mirek
Re: Ole Automation [FEATURE REQUEST?] [message #19191 is a reply to message #19171] Wed, 19 November 2008 08:00 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello luzr

Well... after the SysInfo functions first version release and full test I will follow working with it.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19447 is a reply to message #17864] Thu, 04 December 2008 12:09 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello luzr

After first batch of SysInfo I will have first batch of Automation functions ready on December including MSSheet and MSText.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19656 is a reply to message #17864] Tue, 30 December 2008 10:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

Ole Automation status:
- Access to MSOffice completed (Msc and MinGW tested)
- Access to OpenOffice
-- Using Ole: in progress
--- This interface only works in Windows
--- Expected to end in one week. Sorry for the delay
-- Using UNO: stopped!
--- This interface would work in Linux and Windows
--- I have spent many hours but it is too hard for me! (HELP REQUESTED)

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #19776 is a reply to message #17864] Sat, 17 January 2009 00:22 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

I am very happy to include in Bazaar the Automation library and a console demo.

It handles OpenOffice Calc and Writer and Microsoft Excel and Word.

I have prepared it thinking in simplicity. For example:

OfficeDoc doc;

if (OfficeDoc::IsAvailable("Open"))
    doc.Init("Open")
else if (OfficeDoc::IsAvailable("Microsoft"))
    doc.Init("Microsoft")
else
    return;

doc.SetFont("Arial", 14);
doc.SetBold(true);
doc.WriteText("Hello all!");
doc.SetFont("Arial", 12); 
doc.SetBold(false);
doc.SetItalic(true);
doc.WriteText("\n\nNon me latet [To replace] nonnullos vestrum");
doc.Select();
doc.Replace("[To replace]", "replaced text");

doc.Print();

doc.SaveAs("FileDemo", "doc");
doc.Quit();  


So with the same set of functions it manages OpenOffice and Microsoft Office transparently fo the programmer.

The main classes declaration is like this:

class OfficeSheet
{
public:
	OfficeSheet();
	~OfficeSheet();
	
	static bool IsAvailable(String type);
	
	bool Init(char *type);
	
	bool AddSheet(bool visible);
	bool OpenSheet(String fileName, bool visible);
	
	bool SetValue(int col, int row, Value value);
	bool SetValue(String cell, Value value);
	Value GetValue(int col, int row);
	Value GetValue(String cell);
	bool Replace(Value search, Value replace);
		
	bool SetBold(int col, int row, bool bold);
	bool SetBold(String cell, bool bold);
	bool SetBold(bool bold);
	bool SetFont(int col, int row, String name, int size);
	bool SetFont(String cell, String name, int size);
	bool SetFont(String name, int size);
	
	bool Select(String range);
	bool Select(int fromX, int fromY, int toX, int toY);
	bool Select();
	
	bool Print();
	
	bool SaveAs(String fileName, String type = "xls");
	bool Quit();
};

class OfficeDoc
{
public:
	OfficeDoc();
	~OfficeDoc();
	
	static bool IsAvailable(char *program);
	
	bool Init(char *type);
	
	bool AddDoc(bool visible);
	bool OpenDoc(String fileName, bool visible);

	bool SetFont(String font, int size);
	bool SetBold(bool bold);
	bool SetItalic(bool italic);
	bool WriteText(String value);
	
	bool Select();
	
	bool Replace(String search, String replace);
	
	bool Print();
	
	bool SetSaved(bool);
	bool SaveAs(String fileName, String type = "doc");
	bool Quit();
};


Unfortunately it only works in Windows (MinGW and MSC) using Ole Automation. As I have explained before the OpenOffice official interface called UNO has been too much for me until now.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21147 is a reply to message #19776] Tue, 05 May 2009 13:06 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo!
Thank you for interesting OleAutomation.
I tried to buid Automation demo console with MSC9 and have following errors:
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__DeleteDC@4 referenced in function "bool __cdecl Window_SaveCap
	ture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__DeleteObject@4 referenced in function "bool __cdecl Window_Sav
	eCapture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__GetDIBits@28 referenced in function "bool __cdecl Window_SaveC
	apture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__BitBlt@36 referenced in function "bool __cdecl Window_SaveCapt
	ure(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__SelectObject@8 referenced in function "bool __cdecl Window_Sav
	eCapture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleBitmap@12 referenced in function "bool __cdecl
	 Window_SaveCapture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
SysInfo.lib(SysInfo.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleDC@4 referenced in function "bool __cdecl Wind
	ow_SaveCapture(long,class Upp::String)" (?Window_SaveCapture@@YA_NJVString@Upp@@@Z)
C:\upp\out\MSC9.Force_size.Mt\Automation demo console.exe : fatal error LNK1120: 7 unresolved externals

With GCC MINGW have not errors and works fine!
Re: Ole Automation [FEATURE REQUEST?] [message #21148 is a reply to message #19776] Tue, 05 May 2009 13:57 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Sorry... repeated!

[Updated on: Tue, 05 May 2009 13:57]

Report message to a moderator

Re: Ole Automation [FEATURE REQUEST?] [message #21150 is a reply to message #21147] Tue, 05 May 2009 15:03 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello tojocky

All the functions not found by the linker are in gdi32.lib so it seems the compiler does not found it for MSC.

Please check if in "Build methods" menu for MSC in LIB directories it appears the directory "C:\Program Files\Microsoft SDKs\Windows\v6.1\lib". Gdi32.lib is located there for MSC.

Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21151 is a reply to message #21150] Tue, 05 May 2009 15:52 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

SDK libs is in "C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib"
Is configured in "Build methods"!

file Gdi32.lib I founded by address: C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib!

[Updated on: Tue, 05 May 2009 15:53]

Report message to a moderator

Re: Ole Automation [FEATURE REQUEST?] [message #21152 is a reply to message #21151] Tue, 05 May 2009 16:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello tojocky

Excuse me Smile. Your answer is clear, but in my theide I have this:

index.php?t=getfile&id=1710&private=0

After Visual C++ Express and SDK installation, gdi32.lib file is installed under "Microsoft SDKs".

Please confirm me that gdi32.lib file is located under

C:\Program Files\Microsoft Visual Studio 9.0\Vc\Lib

instead of under

C:\Program Files\Microsoft SDKs\Windows\v6.1\lib

Best regards
Koldo
  • Attachment: Screen.JPG
    (Size: 65.43KB, Downloaded 1720 times)


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21156 is a reply to message #21152] Tue, 05 May 2009 21:33 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo,

I have the same situation with this difference:
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib"

instead

"C:\Program Files\Microsoft SDKs\Windows\v6.1\lib"

index.php?t=getfile&id=1711&private=0

The gdi32.lib library is located in folder:

"C:\Program Files\Microsoft SDKs\Windows\v6.1\lib"

I want to notice that when i tried to build this demo under MSC8 with the latest source svn code I have following errors:

----- SysInfo ( MT MSC8 FORCE_SIZE WIN32 MSC ) (3 / 5)
SysInfo.cpp
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1179) : error C2065: 'PRODUCT_ULTIMATE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1179) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1182) : error C2065: 'PRODUCT_HOME_PREMIUM' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1182) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1185) : error C2065: 'PRODUCT_HOME_BASIC' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1185) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1188) : error C2065: 'PRODUCT_ENTERPRISE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1188) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1191) : error C2065: 'PRODUCT_BUSINESS' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1191) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1194) : error C2065: 'PRODUCT_STARTER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1194) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1197) : error C2065: 'PRODUCT_CLUSTER_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1197) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1200) : error C2065: 'PRODUCT_DATACENTER_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1200) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1203) : error C2065: 'PRODUCT_DATACENTER_SERVER_CORE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1203) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1206) : error C2065: 'PRODUCT_ENTERPRISE_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1206) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1209) : error C2065: 'PRODUCT_ENTERPRISE_SERVER_CORE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1209) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1212) : error C2065: 'PRODUCT_ENTERPRISE_SERVER_IA64' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1212) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1215) : error C2065: 'PRODUCT_SMALLBUSINESS_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1215) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1218) : error C2065: 'PRODUCT_SMALLBUSINESS_SERVER_PREMIUM' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1218) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1221) : error C2065: 'PRODUCT_STANDARD_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1221) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1224) : error C2065: 'PRODUCT_STANDARD_SERVER_CORE' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1224) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1227) : error C2065: 'PRODUCT_WEB_SERVER' : undeclared identifier
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1227) : error C2051: case expression not constant
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1230) : warning C4060: switch statement contains no 'case' or 'default' labels
D:\source_codes\upp\svn_google\bazaar\SysInfo\SysInfo.cpp(1233) : error C2065: 'SM_SERVERR2' : undeclared identifier
SysInfo: 1 file(s) built in (0:01.29), 1297 msecs / file, duration = 1312 msecs, parallelization 0%

There were errors. (0:01.39)


Thank you for you contribution!

After build this with MINGW I can propouse to divide OfficeSheet into OfficeBook and OfficeSheet. It can be add possibility to add more sheets under one book (file)!
  • Attachment: untitled.JPG
    (Size: 66.08KB, Downloaded 1735 times)
Re: Ole Automation [FEATURE REQUEST?] [message #21157 is a reply to message #21156] Wed, 06 May 2009 00:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello tojocky

- About the gdi32.lib problem

The issue is to link the program with gdi32.lib

index.php?t=getfile&id=1712&private=0

I have tested it now with v6.1 and v6.0A and both link and run well Confused . Please check it and tell me what happens.


- About MSC8 "undeclared identifier" errors

Reading sysinfo.cpp from line around 1100 you will see:

#if defined(__MINGW32__)

//#define PRODUCT_UNDEFINED                       0x00000000

#define PRODUCT_ULTIMATE                        0x00000001
#define PRODUCT_HOME_BASIC                      0x00000002
#define PRODUCT_HOME_PREMIUM                    0x00000003
...


They serve to define Win OS version.

As I have only tested this with MinGW and MSC9 I saw that these includes where in ...\Microsoft SDKs\Windows\v6.1\Include\WinNT.h, so they were included for MinGW as MSC9 did not need them.

The SM_SERVERR2 #include is in ...\Microsoft SDKs\Windows\v6.1\Include\WinUser.h and in ...\mingw\include\winuser.h, so I did not include it.

For using them in MSC8 they would have to be included.


- About Sheets and Books

Ok. Let me some days and I will do it.


Thank you for testing and giving feedback Smile

Best regards
Koldo

  • Attachment: Screen.JPG
    (Size: 56.51KB, Downloaded 1622 times)


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21158 is a reply to message #21157] Wed, 06 May 2009 06:05 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo!
When I put gdi32 in "package organizer" for SysInfo with MSC9 was compile and run OK! Please change this in svn (bazaar) too!

With MSC8 I modified your code and works too:

i modified:
#if !defined(PRODUCT_ULTIMATE)
#define PRODUCT_ULTIMATE                        0x00000001
#define PRODUCT_HOME_BASIC                      0x00000002
#define PRODUCT_HOME_PREMIUM                    0x00000003
#define PRODUCT_ENTERPRISE                      0x00000004
#define PRODUCT_HOME_BASIC_N                    0x00000005
#define PRODUCT_BUSINESS                        0x00000006
#define PRODUCT_STANDARD_SERVER                 0x00000007
#define PRODUCT_DATACENTER_SERVER               0x00000008
#define PRODUCT_SMALLBUSINESS_SERVER            0x00000009
#define PRODUCT_ENTERPRISE_SERVER               0x0000000A
#define PRODUCT_STARTER                         0x0000000B
#define PRODUCT_DATACENTER_SERVER_CORE          0x0000000C
#define PRODUCT_STANDARD_SERVER_CORE            0x0000000D
#define PRODUCT_ENTERPRISE_SERVER_CORE          0x0000000E
#define PRODUCT_ENTERPRISE_SERVER_IA64          0x0000000F
#define PRODUCT_BUSINESS_N                      0x00000010
#define PRODUCT_WEB_SERVER                      0x00000011
#define PRODUCT_CLUSTER_SERVER                  0x00000012
#define PRODUCT_HOME_SERVER                     0x00000013
#define PRODUCT_STORAGE_EXPRESS_SERVER          0x00000014
#define PRODUCT_STORAGE_STANDARD_SERVER         0x00000015
#define PRODUCT_STORAGE_WORKGROUP_SERVER        0x00000016
#define PRODUCT_STORAGE_ENTERPRISE_SERVER       0x00000017
#define PRODUCT_SERVER_FOR_SMALLBUSINESS        0x00000018
#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM    0x00000019

#define PRODUCT_UNLICENSED                      0xABCDABCD

#define SM_SERVERR2             89
#endif



instead:

#if defined(__MINGW32__)

//#define PRODUCT_UNDEFINED                       0x00000000

#define PRODUCT_ULTIMATE                        0x00000001
#define PRODUCT_HOME_BASIC                      0x00000002
#define PRODUCT_HOME_PREMIUM                    0x00000003
#define PRODUCT_ENTERPRISE                      0x00000004
#define PRODUCT_HOME_BASIC_N                    0x00000005
#define PRODUCT_BUSINESS                        0x00000006
#define PRODUCT_STANDARD_SERVER                 0x00000007
#define PRODUCT_DATACENTER_SERVER               0x00000008
#define PRODUCT_SMALLBUSINESS_SERVER            0x00000009
#define PRODUCT_ENTERPRISE_SERVER               0x0000000A
#define PRODUCT_STARTER                         0x0000000B
#define PRODUCT_DATACENTER_SERVER_CORE          0x0000000C
#define PRODUCT_STANDARD_SERVER_CORE            0x0000000D
#define PRODUCT_ENTERPRISE_SERVER_CORE          0x0000000E
#define PRODUCT_ENTERPRISE_SERVER_IA64          0x0000000F
#define PRODUCT_BUSINESS_N                      0x00000010
#define PRODUCT_WEB_SERVER                      0x00000011
#define PRODUCT_CLUSTER_SERVER                  0x00000012
#define PRODUCT_HOME_SERVER                     0x00000013
#define PRODUCT_STORAGE_EXPRESS_SERVER          0x00000014
#define PRODUCT_STORAGE_STANDARD_SERVER         0x00000015
#define PRODUCT_STORAGE_WORKGROUP_SERVER        0x00000016
#define PRODUCT_STORAGE_ENTERPRISE_SERVER       0x00000017
#define PRODUCT_SERVER_FOR_SMALLBUSINESS        0x00000018
#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM    0x00000019

#define PRODUCT_UNLICENSED                      0xABCDABCD
#endif


be care... I added new define:
#define SM_SERVERR2             89

Maybe i did something wrong, but it was compiled and runed ok with all 3 compilers: MSC8, MSC9 and MINGW.
Re: Ole Automation [FEATURE REQUEST?] [message #21159 is a reply to message #21158] Wed, 06 May 2009 08:34 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello tojocky

- About gdi32.lib

I suppose that the reason of this is that I added this lib in the last sysinfo version. I probably updated in Bazaar the sources but not the upp file.


- About MSC8

Added the includes


Best regards
Koldo


Best regards
Iñaki
Re: Ole Automation [FEATURE REQUEST?] [message #21163 is a reply to message #21159] Wed, 06 May 2009 09:52 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello Koldo!

I added new methods
for classes OfficeSheet and MSSheet:
	// >>>Ion Lupascu 06.05.2009 Add this methods
	int GetSheetsCount();
	bool SetActiveSheet(int index);
	bool SetActiveSheet(String name);
	bool SetSheetName(String new_name);
	// <<<Ion Lupascu 06.05.2009


Details for MSSheet:
// >>> Ion Lupascu 06.05.2009 Add this methods
int MSSheet::GetSheetsCount(){
	if (!Book)
		return(-1);
	
	return((int)Ole::GetValue(Ole::GetObject(Book, "Sheets"), "Count"));
}

// Set active sheet start with 0(zero)
bool MSSheet::SetActiveSheet(int index){
	if(!Book)
		return false;
	
	VariantOle index_ole;
	index_ole.Int4(index + 1);
	
	if (!(Sheet = Ole::GetObject(Book, "Sheets", index_ole)))
		return false;

	return true;
}

// Set active sheet by name
bool MSSheet::SetActiveSheet(String name){
	if(!Book)
		return false;
	
	VariantOle name_ole;
	name_ole.BString(name);
	
	if (!(Sheet = Ole::GetObject(Book, "Sheets", name_ole)))
		return false;

	return true;
}

bool MSSheet::SetSheetName(String new_name){
	if(!Sheet)
		return false;
	
	VariantOle new_name_ole;
	new_name_ole.BString(new_name);
	
	return Ole::SetValue(Sheet, "Name", new_name_ole);
}
// <<< Ion Lupascu 06.05.2009


Details for OfficeSheet:
// >>> Ion Lupascu 06.05.2009 Add this methods
int OfficeSheet::GetSheetsCount(){
	if (!data)
		return -1;
	if (type == SheetOPEN)
		return -1; //... need to add ((OPENSheet*)data)->GetSheetsCount();
	else if (type == SheetMS)
		return ((MSSheet*)data)->GetSheetsCount();
	else
		return -1;
}

// Set active sheet start with 0(zero)
bool OfficeSheet::SetActiveSheet(int index){
	if (!data)
		return false;
	if (type == SheetOPEN)
		return false; //... need to add ((OPENSheet*)data)->SetActiveSheet(index);
	else if (type == SheetMS)
		return ((MSSheet*)data)->SetActiveSheet(index);
	else
		return false;
}

// Set active sheet by name
bool OfficeSheet::SetActiveSheet(String name){
	if (!data)
		return false;
	if (type == SheetOPEN)
		return false; //... need to add ((OPENSheet*)data)->SetActiveSheet(name);
	else if (type == SheetMS)
		return ((MSSheet*)data)->SetActiveSheet(name);
	else
		return false;
}

bool OfficeSheet::SetSheetName(String new_name){
	if (!data)
		return false;
	if (type == SheetOPEN)
		return false; //... need to add ((OPENSheet*)data)->SetActiveSheet(name);
	else if (type == SheetMS)
		return ((MSSheet*)data)->SetSheetName(new_name);
	else
		return false;
}
// <<< Ion Lupascu 06.05.2009


I do not added this method for Open office. Please check this and add methods for Open calc too. Maybe exists memory leak in method:
// Set active sheet by name
bool MSSheet::SetActiveSheet(String name){
	if(!Book)
		return false;
	
	VariantOle name_ole;
	name_ole.BString(name);
	
>>HERE  if (!(Sheet = Ole::GetObject(Book, "Sheets", name_ole)))
		return false;

	return true;
}


I tested this new methods and works fine!

Thank you for changes with MSC8 and gdi32.lib
Re: Ole Automation [FEATURE REQUEST?] [message #21168 is a reply to message #21163] Wed, 06 May 2009 11:52 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Tojocky

Thank you for your effort.

Please next time tell me that you are going to implement code to avoid doing the things twice Smile. I had done almost all this morning!!!

About function naming, if you see class OPENSheet you will see:

class OPENSheet
{
...
	// New functs for next versions
	bool InsertTab(String name);
	bool ChooseTab(String name);
	bool ChooseTab(int index);
	int GetNumTabs();


These functions are already implemented in Automation.cpp for OpenOffice!!
As I did not implement them in MSOffice I did not make them visible before.

The final thing I am doing now and sometimes is the most difficult is to have just the same behaviour with OpenOffice and MSOffice implementations, as in some things they do not work the same.

Please, believe me. You have done the things well. Please next time tell me you are going to do the job before.

Best regards
Koldo


Best regards
Iñaki
Previous Topic: MAPIEx works with MinGW
Next Topic: [Controls4U] IE shows script errors
Goto Forum:
  


Current Time: Thu Mar 28 21:21:02 CET 2024

Total time taken to generate the page: 0.01942 seconds