OfficeAutomation: Fully refurbished with StaticPlugin

git-svn-id: svn://ultimatepp.org/upp/trunk@3246 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2011-02-25 16:27:08 +00:00
parent d8ead8fba4
commit a8d953ae52
10 changed files with 381 additions and 988 deletions

View file

@ -8,9 +8,9 @@ using namespace Upp;
#include <winnls.h>
#include "Functions4U/Functions4U.h"
#include "OfficeAutomationBase.h"
#include <Functions4U/Functions4U.h>
#include "OfficeAutomation.h"
#include "OfficeAutomationBase.h"
////////////////////////////////////////////////////////////////////////////////////////
VariantOle::VariantOle() {
@ -379,6 +379,11 @@ ObjectOle Ole::MethodGet(ObjectOle from, String which, VariantOle &value, Varian
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
INITBLOCK {
PluginRegister(OfficeSheet, MSSheet, "Microsoft");
}
MSSheet::MSSheet() {
App = Books = Book = Sheet = Range = NULL;
quit = false;
@ -585,6 +590,8 @@ bool MSSheet::SaveAs(String fileName, String type) {
if (!Book)
return false;
if (type[0] == '.')
type = type.Mid(1);
fileName = ForceExt(fileName, "." + type);
VariantOle vFileName, vType;
@ -1029,6 +1036,11 @@ int MSSheet::GetNumTabs() {
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
INITBLOCK {
PluginRegister(OfficeDoc, MSDoc, "Microsoft");
}
MSDoc::MSDoc() {
App = Docs = Doc = Selection = NULL;
quit = false;
@ -1125,6 +1137,8 @@ bool MSDoc::SaveAs(String fileName, String type) {
if (!Doc)
return false;
if (type[0] == '.')
type = type.Mid(1);
fileName = ForceExt(fileName, "." + type);
VariantOle vFileName, vType;
@ -1208,8 +1222,8 @@ bool MSDoc::Select() {
// about 250 chars and for some special chars
bool MSDoc::Replace(String search, String _replace) {
String replace = CleanString(_replace);
replace = ::Replace(replace, "^", " ");
replace = ::Replace(replace, "\r", ""); // To remove squares
replace.Replace("^", " ");
replace.Replace("\r", ""); // To remove squares
String replaceSubset;
while (replace.GetCount() > 200) {
@ -1217,11 +1231,11 @@ bool MSDoc::Replace(String search, String _replace) {
replaceSubset.Cat(search);
replace = replace.Right(replace.GetCount() - 200);
replaceSubset = ::Replace(replaceSubset, "\n", "^l");
replaceSubset.Replace("\n", "^l");
if (!ReplaceSubset(search, replaceSubset))
return false;
}
replace = ::Replace(replace, "\n", "^l");
replace.Replace("\n", "^l");
return ReplaceSubset(search, replace);
}
@ -1360,6 +1374,11 @@ public:
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
INITBLOCK {
PluginRegister(OfficeSheet, OPENSheet, "Open");
}
OPENSheet::OPENSheet() {
ServiceManager = CoreReflection = Desktop = Document = Sheets = Sheet = Cell = Range = NULL;
selectedAll = false;
@ -1620,17 +1639,19 @@ bool OPENSheet::Select() {
selectedAll = true;
return true;
}
/*
void OPENSheet::DefMatrix(int width, int height) {
return;
}
void OPENSheet::SetMatrixValue(int x, int y, ::Value value) {
return;
}
bool OPENSheet::FillSelectionMatrix() {
return false;
}
*/
bool OPENSheet::Replace(Value search, Value replace) {
if (!Sheet)
return false;
@ -1677,6 +1698,8 @@ bool OPENSheet::SaveAs(String fileName, String type) {
if (!Document)
return false;
if (type[0] == '.')
type = type.Mid(1);
fileName = ForceExt(fileName, "." + type);
VariantOle vFileName;
vFileName.BString(OOo::ConvertToUrl(fileName));
@ -1698,16 +1721,20 @@ bool OPENSheet::SaveAs(String fileName, String type) {
return false;
VariantOle vArraySave;
bool ret;
if (filter.IsEmpty()) {
vArraySave.ArrayDim(0);
return Ole::Method(Document, "storeToURL", vArraySave, vFileName);
ret = Ole::Method(Document, "storeToURL", vArraySave, vFileName);
} else {
VariantOle vArg;
vArg.ObjectOle(OOo::MakePropertyValue("FilterName", filter));
vArraySave.ArrayDim(1);
vArraySave.ArraySetVariant(1, vArg);
return Ole::Method(Document, "storeToURL", vArraySave, vFileName);
ret = Ole::Method(Document, "storeToURL", vArraySave, vFileName);
}
if (ret)
SetSaved(true);
return ret;
}
bool OPENSheet::SelCell(int x, int y)
@ -2043,6 +2070,11 @@ bool OPENSheet::Print() {
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
INITBLOCK {
PluginRegister(OfficeDoc, OPENDoc, "Open");
}
OPENDoc::OPENDoc() {
ServiceManager = CoreReflection = Desktop = Document = Text = Cursor = NULL;
quit = false;
@ -2176,13 +2208,13 @@ bool OPENDoc::SetVisible(bool visible) {
return Ole::Method(DocWindow, "setVisible", vvisible);
}
bool OPENDoc::SetColor(Color col) {
/*bool OPENDoc::SetColor(Color col) {
VariantOle vColor;
vColor.BString("CharColor");
VariantOle vValue;
vValue.Int4(RGB(col.GetR(), col.GetG(), col.GetB()));
return Ole::Method(Cursor, "setPropertyValue", vValue, vColor);
}
}*/
bool OPENDoc::SetFont(String font, int size) {
VariantOle vFont;
@ -2282,6 +2314,8 @@ bool OPENDoc::SaveAs(String fileName, String type) {
if (!Document)
return false;
if (type[0] == '.')
type = type.Mid(1);
fileName = ForceExt(fileName, "." + type);
VariantOle vFileName;
vFileName.BString(OOo::ConvertToUrl(fileName));
@ -2319,7 +2353,8 @@ bool OPENDoc::SaveAs(String fileName, String type) {
bool OPENDoc::Quit() {
if (!quit) {
quit = true;
return Ole::Method(Document, "Dispose");
if (Document)
return Ole::Method(Document, "Dispose");
}
return true;
}

View file

@ -3,146 +3,53 @@
using namespace Upp;
#include "OfficeAutomationMethods.h"
struct Cell {
int col;
int row;
};
class OfficeSheet
{
class SheetPlugin {
public:
virtual bool IsAvailable();
Sheet_METHOD_LIST
};
class OfficeSheet : public SheetPlugin, public StaticPlugin {
public:
OfficeSheet();
~OfficeSheet();
static bool IsAvailable(String type);
bool Init(const char *name);
virtual bool IsAvailable(const char *_name);
bool Init(String 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);
bool SetValue(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 SetItalic(int col, int row, bool italic);
bool SetItalic(String cell, bool italic);
bool SetItalic(bool italic);
bool SetUnderline(bool underline);
bool SetUnderline(String cell, bool underline);
bool SetUnderline(int col, int row, bool underline);
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 SetColor(int col, int row, Color color);
bool SetColor(String cell, Color color);
bool SetColor(Color color);
bool SetBackColor(int col, int row, Color color);
bool SetBackColor(String cell, Color color);
bool SetBackColor(Color color);
bool SetRowHeight(int row, double height);
bool SetColWidth(int col, double width);
enum {LEFT = 0, CENTER, RIGHT, JUSTIFY, TOP, BOTTOM, MAX_JUSTIFY};
bool SetHorizAlignment(String cell, int alignment);
bool SetHorizAlignment(int col, int row, int alignment);
bool SetVertAlignment(String cell, int alignment);
bool SetVertAlignment(int col, int row, int alignment);
enum {BORDER_DIAG_DOWN = 0, BORDER_DIAG_UP, BORDER_LEFT, BORDER_TOP, BORDER_BOTTOM, BORDER_RIGHT};
enum {HAIRLINE = 0, MEDIUM, THIN, THICK};
enum {NONE = 0, CONTINUOUS, DASH, DASHDOT, DOT};
bool SetBorder(int borderIndx, int lineStyle, int weight, Color color);
bool SetBorder(int col, int row, int borderIndx, int lineStyle, int weight, Color color);
bool Select(String range);
bool Select(int fromX, int fromY, int toX, int toY);
bool Select();
/*// New functs for next versions
void DefMatrix(int width, int height);
bool FillSelectionMatrix();
void SetMatrixValue(int i, int j, ::Value value);
*/
bool Print();
bool SaveAs(String fileName, String type = "xls");
bool Quit();
bool InsertTab(String name);
bool ChooseTab(String name);
bool ChooseTab(int index);
bool RemoveTab(String name);
bool RemoveTab(int index);
int GetNumTabs();
String GetType()
{
if (type == SheetOPEN)
return "Open";
else
return "Microsoft";
}
Sheet_METHOD_LIST
static void CellToColRow(const char *cell, int &col, int &row);
static void CellToColRow(const char *cell, Cell &cellPos);
static String ColRowToCell(const int col, const int row);
static String ColRowToCell(const Cell &cellPos);
private:
void *data;
enum {SheetOPEN = 1, SheetMS};
int type;
};
class OfficeDoc
{
class DocPlugin {
public:
virtual bool IsAvailable();
Doc_METHOD_LIST
};
class OfficeDoc : public DocPlugin, public StaticPlugin {
public:
OfficeDoc();
~OfficeDoc();
static bool IsAvailable(String type);
bool Init(String 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 Init(const char *name);
virtual bool IsAvailable(const char *_name);
bool Select();
bool Replace(String search, String replace);
bool Print();
bool SetSaved(bool saved);
bool SaveAs(String fileName, String type = "doc");
bool Quit();
String GetType()
{
if (type == DocOPEN)
return "Open";
else
return "Microsoft";
}
private:
void *data;
enum {DocOPEN = 1, DocMS};
int type;
Doc_METHOD_LIST
};

View file

@ -11,8 +11,9 @@ library(WIN32) Oleaut32;
file
OfficeSheet.cpp,
OfficeDoc.cpp,
OfficeAutomation.cpp,
OfficeAutomation.h,
OfficeAutomation.cpp,
OfficeAutomationMethods.h,
OfficeAutomationBase.h,
srcdoc.tpp,
src.tpp,

View file

@ -3,6 +3,8 @@
using namespace Upp;
#include "OfficeAutomationMethods.h"
typedef IDispatch* ObjectOle;
class VariantOle
@ -30,76 +32,17 @@ public:
public:
VARIANT var;
};
class MSSheet
class MSSheet : public OfficeSheet
{
public:
MSSheet();
~MSSheet();
static bool IsAvailable();
virtual bool IsAvailable();
bool AddSheet(bool visible);
bool OpenSheet(String fileName, bool visible);
bool SetValue(int col, int row, Value value);
bool SetValue(String cell, Value value);
bool SetValue(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 SetItalic(int col, int row, bool italic);
bool SetItalic(String cell, bool italic);
bool SetItalic(bool italic);
bool SetUnderline(bool underline);
bool SetUnderline(String cell, bool underline);
bool SetUnderline(int col, int row, bool underline);
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 SetColor(int col, int row, Color color);
bool SetColor(String cell, Color color);
bool SetColor(Color color);
bool SetBackColor(int col, int row, Color color);
bool SetBackColor(String cell, Color color);
bool SetBackColor(Color color);
bool SetRowHeight(int row, double height);
bool SetColWidth(int col, double width);
bool SetHorizAlignment(String cell, int alignment);
bool SetHorizAlignment(int col, int row, int alignment);
bool SetVertAlignment(String cell, int alignment);
bool SetVertAlignment(int col, int row, int alignment);
bool SetBorder(int borderIndx, int lineStyle, int weight, Color color);
bool SetBorder(int col, int row, int borderIndx, int lineStyle, int weight, Color color);
bool Select(String range);
bool Select(int fromX, int fromY, int toX, int toY);
bool Select();
bool Print();
bool SetSaved(bool);
bool SaveAs(String fileName, String type = "xls");
bool Quit();
bool InsertTab(String name);
bool ChooseTab(String name);
bool ChooseTab(int index);
bool RemoveTab(String name);
bool RemoveTab(int index);
int GetNumTabs();
// New functs for next versions
void DefMatrix(int width, int height);
bool FillSelectionMatrix();
void SetMatrixValue(int i, int j, ::Value value);
Sheet_METHOD_LIST
private:
ObjectOle App;
@ -116,31 +59,15 @@ private:
bool SetBorder(ObjectOle &borders, int borderIndx, int lineStyle, int weight, Color color);
};
class MSDoc
class MSDoc : public OfficeDoc
{
public:
MSDoc();
~MSDoc();
static bool IsAvailable();
virtual bool IsAvailable();
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();
Doc_METHOD_LIST
private:
ObjectOle App;
@ -159,79 +86,16 @@ private:
#define wdReplaceAll 2
class OPENSheet
class OPENSheet : public OfficeSheet
{
public:
OPENSheet();
~OPENSheet();
static bool IsAvailable();
virtual bool IsAvailable();
bool AddSheet(bool visible);
bool OpenSheet(String fileName, bool visible);
Sheet_METHOD_LIST
bool SetValue(int col, int row, Value value);
bool SetValue(String cell, Value value);
bool SetValue(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 SetItalic(String cell, bool italic);
bool SetItalic(int col, int row, bool italic);
bool SetItalic(bool italic);
bool SetUnderline(bool underline);
bool SetUnderline(String cell, bool underline);
bool SetUnderline(int col, int row, bool underline);
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 SetColor(int col, int row, Color color);
bool SetColor(String cell, Color color);
bool SetColor(Color color);
bool SetBackColor(int col, int row, Color color);
bool SetBackColor(String cell, Color color);
bool SetBackColor(Color color);
bool SetColWidth(int col, double width);
bool SetRowHeight(int row, double height);
bool SetHorizAlignment(String cell, int alignment);
bool SetHorizAlignment(int col, int row, int alignment);
bool SetVertAlignment(String cell, int alignment);
bool SetVertAlignment(int col, int row, int alignment);
bool SetBorder(int borderIndx, int lineStyle, int weight, Color color);
bool SetBorder(int col, int row, int borderIndx, int lineStyle, int weight, Color color);
bool Select(String range);
bool Select(int fromX, int fromY, int toX, int toY);
bool Select();
/* // New functs for next versions
void DefMatrix(int width, int height);
bool FillSelectionMatrix();
void SetMatrixValue(int i, int j, ::Value value);
*/
bool Print();
bool SetSaved(bool);
bool SaveAs(String fileName, String type = "xls");
bool Quit();
bool InsertTab(String name);
bool ChooseTab(String name);
bool ChooseTab(int index);
bool RemoveTab(String name);
bool RemoveTab(int index);
int GetNumTabs();
// New functs for next versions
//bool SetCellBackColor(Color color);
//bool SetCellBackColor(String cell, Color color);
//bool SetCellBackColor(int col, int row, Color color);
bool SetFormat(String format);
private:
@ -250,34 +114,18 @@ private:
bool quit;
};
class OPENDoc
class OPENDoc : public OfficeDoc
{
public:
OPENDoc();
~OPENDoc();
static bool IsAvailable();
virtual bool IsAvailable();
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();
Doc_METHOD_LIST
// New functs for next versions
bool SetColor(Color col);
//bool SetColor(Color col);
private:
ObjectOle ServiceManager;

View file

@ -0,0 +1,95 @@
#ifndef _OfficeAutomation_OfficeAutomationMethods_h_
#define _OfficeAutomation_OfficeAutomationMethods_h_
#define Sheet_METHOD_LIST \
virtual bool AddSheet(bool visible); \
virtual bool OpenSheet(String fileName, bool visible); \
\
virtual bool SetValue(int col, int row, Value value); \
virtual bool SetValue(String cell, Value value); \
virtual bool SetValue(Value value); \
virtual Value GetValue(int col, int row); \
virtual Value GetValue(String cell); \
virtual bool Replace(Value search, Value replace); \
\
virtual bool SetBold(int col, int row, bool bold); \
virtual bool SetBold(String cell, bool bold); \
virtual bool SetBold(bool bold); \
virtual bool SetItalic(int col, int row, bool italic); \
virtual bool SetItalic(String cell, bool italic); \
virtual bool SetItalic(bool italic); \
virtual bool SetUnderline(bool underline); \
virtual bool SetUnderline(String cell, bool underline); \
virtual bool SetUnderline(int col, int row, bool underline); \
virtual bool SetFont(int col, int row, String name, int size); \
virtual bool SetFont(String cell, String name, int size); \
virtual bool SetFont(String name, int size); \
virtual bool SetColor(int col, int row, Color color); \
virtual bool SetColor(String cell, Color color); \
virtual bool SetColor(Color color); \
virtual bool SetBackColor(int col, int row, Color color); \
virtual bool SetBackColor(String cell, Color color); \
virtual bool SetBackColor(Color color); \
\
virtual bool SetRowHeight(int row, double height); \
virtual bool SetColWidth(int col, double width); \
\
enum {LEFT = 0, CENTER, RIGHT, JUSTIFY, TOP, BOTTOM, MAX_JUSTIFY}; \
\
virtual bool SetHorizAlignment(String cell, int alignment); \
virtual bool SetHorizAlignment(int col, int row, int alignment); \
virtual bool SetVertAlignment(String cell, int alignment); \
virtual bool SetVertAlignment(int col, int row, int alignment); \
\
enum {BORDER_DIAG_DOWN = 0, BORDER_DIAG_UP, BORDER_LEFT, BORDER_TOP, BORDER_BOTTOM, BORDER_RIGHT}; \
enum {HAIRLINE = 0, MEDIUM, THIN, THICK}; \
enum {NONE = 0, CONTINUOUS, DASH, DASHDOT, DOT}; \
\
virtual bool SetBorder(int borderIndx, int lineStyle, int weight, Color color); \
virtual bool SetBorder(int col, int row, int borderIndx, int lineStyle, int weight, Color color); \
\
virtual bool Select(String range); \
virtual bool Select(int fromX, int fromY, int toX, int toY); \
virtual bool Select(); \
\
virtual void DefMatrix(int width, int height); \
virtual bool FillSelectionMatrix(); \
virtual void SetMatrixValue(int i, int j, ::Value value); \
\
virtual bool Print(); \
\
virtual bool SaveAs(String fileName, String type); \
virtual bool SetSaved(bool); \
virtual bool Quit(); \
\
virtual bool InsertTab(String name); \
virtual bool ChooseTab(String name); \
virtual bool ChooseTab(int index); \
virtual bool RemoveTab(String name); \
virtual bool RemoveTab(int index); \
virtual int GetNumTabs();
#define Doc_METHOD_LIST \
virtual bool AddDoc(bool visible); \
virtual bool OpenDoc(String fileName, bool visible); \
\
virtual bool SetFont(String font, int size); \
virtual bool SetBold(bool bold); \
virtual bool SetItalic(bool italic); \
virtual bool WriteText(String value); \
\
virtual bool Select(); \
\
virtual bool Replace(String search, String replace); \
\
virtual bool Print(); \
\
virtual bool SetSaved(bool saved); \
virtual bool SaveAs(String fileName, String type = "doc"); \
virtual bool Quit();
#endif

View file

@ -1,179 +1,76 @@
#include <Core/Core.h>
using namespace Upp;
#include <Functions4U/Functions4U.h>
#ifndef PLATFORM_WIN32
#error Sorry: This platform is not supported!. Look for OfficeAutomation in Bazaar Upp Forum to search for info and new news
#endif
#include "OfficeAutomationBase.h"
#include "OfficeAutomation.h"
#include "OfficeAutomationBase.h"
OfficeDoc::OfficeDoc() {
data = NULL;
Ole::Init();
}
OfficeDoc::~OfficeDoc() {
if (!data)
return;
if (type == DocOPEN)
delete (OPENDoc*)data;
else if (type == DocMS)
delete (MSDoc*)data;
Ole::Close();
}
bool OfficeDoc::IsAvailable(String strtype) {
if (strcmp(strtype, "Open") >= 0)
return OPENDoc::IsAvailable();
else if (strcmp(strtype, "Microsoft") >= 0)
return MSDoc::IsAvailable();
else
return false;
bool OfficeDoc::Init(const char *name) {
return PluginInit(*this, name);
}
bool OfficeDoc::Init(String strtype) {
if (data) {
if (type == DocOPEN)
delete (OPENDoc*)data;
else if (type == DocMS)
delete (MSDoc*)data;
bool DocPlugin::IsAvailable() {return false;}
bool OfficeDoc::IsAvailable(const char *_name) {
for (int i = 0; i < Plugins().GetCount(); ++i) {
if (Plugins()[i].name == _name && Plugins()[i].type == typeid(OfficeDoc).name()) {
void *dat = Plugins()[i].New();
if (!dat)
return false;
bool ret = (static_cast<DocPlugin *>(dat))->IsAvailable();
Plugins()[i].Delete(dat);
return ret;
}
}
if (strcmp(strtype, "Open") >= 0) {
type = DocOPEN;
data = new OPENDoc();
} else if (strcmp(strtype, "Microsoft") >= 0) {
type = DocMS;
data = new MSDoc();
} else
return false;
return true;
return false;
}
bool OfficeDoc::AddDoc(bool visible) {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->AddDoc(visible);
else if (type == DocMS)
return ((MSDoc*)data)->AddDoc(visible);
else
return false;
}
bool DocPlugin::AddDoc(bool visible) {return false;}
bool OfficeDoc::AddDoc(bool visible) {return (static_cast<DocPlugin *>(GetData()))->AddDoc(visible);}
bool OfficeDoc::OpenDoc(String fileName, bool visible) {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->OpenDoc(fileName, visible);
else if (type == DocMS)
return ((MSDoc*)data)->OpenDoc(fileName, visible);
else
return false;
}
bool DocPlugin::OpenDoc(String fileName, bool visible) {return false;}
bool OfficeDoc::OpenDoc(String fileName, bool visible) {return (static_cast<DocPlugin *>(GetData()))->OpenDoc(fileName, visible);}
bool OfficeDoc::SetFont(String font, int size) {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->SetFont(font, size);
else if (type == DocMS)
return ((MSDoc*)data)->SetFont(font, size);
else
return false;
}
bool DocPlugin::SetFont(String font, int size) {return false;}
bool OfficeDoc::SetFont(String font, int size) {return (static_cast<DocPlugin *>(GetData()))->SetFont(font, size);}
bool OfficeDoc::SetBold(bool bold) {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->SetBold(bold);
else if (type == DocMS)
return ((MSDoc*)data)->SetBold(bold);
else
return false;
}
bool DocPlugin::SetBold(bool bold) {return false;}
bool OfficeDoc::SetBold(bool bold) {return (static_cast<DocPlugin *>(GetData()))->SetBold(bold);}
bool OfficeDoc::SetItalic(bool italic) {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->SetItalic(italic);
else if (type == DocMS)
return ((MSDoc*)data)->SetItalic(italic);
else
return false;
}
bool DocPlugin::SetItalic(bool italic) {return false;}
bool OfficeDoc::SetItalic(bool italic) {return (static_cast<DocPlugin *>(GetData()))->SetItalic(italic);}
bool OfficeDoc::WriteText(String value) {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->WriteText(value);
else if (type == DocMS)
return ((MSDoc*)data)->WriteText(value);
else
return false;
}
bool DocPlugin::WriteText(String value) {return false;}
bool OfficeDoc::WriteText(String value) {return (static_cast<DocPlugin *>(GetData()))->WriteText(value);}
bool OfficeDoc::Select() {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->Select();
else if (type == DocMS)
return ((MSDoc*)data)->Select();
else
return false;
}
bool DocPlugin::Select() {return false;}
bool OfficeDoc::Select() {return (static_cast<DocPlugin *>(GetData()))->Select();}
bool OfficeDoc::Replace(String search, String replace) {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->Replace(search, replace);
else if (type == DocMS)
return ((MSDoc*)data)->Replace(search, replace);
else
return false;
}
bool DocPlugin::Replace(String search, String replace) {return false;}
bool OfficeDoc::Replace(String search, String replace) {return (static_cast<DocPlugin *>(GetData()))->Replace(search, replace);}
bool OfficeDoc::Print() {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->Print();
else if (type == DocMS)
return ((MSDoc*)data)->Print();
else
return false;
}
bool DocPlugin::Print() {return false;}
bool OfficeDoc::Print() {return (static_cast<DocPlugin *>(GetData()))->Print();}
bool OfficeDoc::SaveAs(String fileName, String _type) {
if (!data)
return false;
if (type == DocOPEN) {
int ret;
ret = ((OPENDoc*)data)->SaveAs(fileName, _type);
((OPENDoc*)data)->SetSaved(true);
return ret;
} else if (type == DocMS) {
((MSDoc*)data)->SetSaved(true);
return ((MSDoc*)data)->SaveAs(fileName, _type);
} else
return false;
}
bool OfficeDoc::Quit() {
if (!data)
return false;
if (type == DocOPEN)
return ((OPENDoc*)data)->Quit();
else if (type == DocMS)
return ((MSDoc*)data)->Quit();
else
return false;
}
bool DocPlugin::SaveAs(String fileName, String _type) {return false;}
bool OfficeDoc::SaveAs(String fileName, String _type) {return (static_cast<DocPlugin *>(GetData()))->SaveAs(fileName, _type);}
bool DocPlugin::Quit() {return false;}
bool OfficeDoc::Quit() {return (static_cast<DocPlugin *>(GetData()))->Quit();}
bool DocPlugin::SetSaved(bool saved) {return false;}
bool OfficeDoc::SetSaved(bool saved) {return (static_cast<DocPlugin *>(GetData()))->SetSaved(saved);}

View file

@ -1,26 +1,22 @@
#include <Core/Core.h>
using namespace Upp;
#include <Functions4U/Functions4U.h>
#ifndef PLATFORM_WIN32
#error Sorry: This platform is not supported!. Look for OfficeAutomation in Bazaar Upp Forum to search for info and new news
#endif
#include "OfficeAutomationBase.h"
#include "OfficeAutomation.h"
#include "OfficeAutomationBase.h"
OfficeSheet::OfficeSheet() {
data = NULL;
Ole::Init();
}
OfficeSheet::~OfficeSheet() {
if (!data)
return;
if (type == SheetOPEN)
delete (OPENSheet*)data;
else if (type == SheetMS)
delete (MSSheet*)data;
Ole::Close();
}
@ -70,575 +66,176 @@ String OfficeSheet::ColRowToCell(const int col, const int row) {
String OfficeSheet::ColRowToCell(const Cell &cellPos) {
return ColRowToCell(cellPos.col, cellPos.row);
}
}
bool OfficeSheet::IsAvailable(String strtype) {
if (strtype == "Open" || strtype == "Libre")
return OPENSheet::IsAvailable();
else if (strtype == "Microsoft")
return MSSheet::IsAvailable();
else
return false;
bool OfficeSheet::Init(const char *name) {
return PluginInit(*this, name);
}
bool OfficeSheet::Init(String strtype) {
if (data) {
if (type == SheetOPEN)
delete (OPENSheet*)data;
else if (type == SheetMS)
delete (MSSheet*)data;
bool SheetPlugin::IsAvailable() {return false;}
bool OfficeSheet::IsAvailable(const char *_name) {
for (int i = 0; i < Plugins().GetCount(); ++i) {
String a = Plugins()[i].type;
String b = typeid(OfficeSheet).name();
if (Plugins()[i].name == _name && Plugins()[i].type == typeid(OfficeSheet).name()) {
void *dat = Plugins()[i].New();
if (!dat)
return false;
bool ret = (static_cast<SheetPlugin *>(dat))->IsAvailable();
Plugins()[i].Delete(dat);
return ret;
}
}
if (strtype == "Open" || strtype == "Libre") {
type = SheetOPEN;
data = new OPENSheet();
} else if (strtype == "Microsoft") {
type = SheetMS;
data = new MSSheet();
} else
return false;
return true;
return false;
}
bool OfficeSheet::AddSheet(bool visible) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->AddSheet(visible);
else if (type == SheetMS)
return ((MSSheet*)data)->AddSheet(visible);
else
return false;
}
bool OfficeSheet::OpenSheet(String fileName, bool visible) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->OpenSheet(fileName, visible);
else if (type == SheetMS)
return ((MSSheet*)data)->OpenSheet(fileName, visible);
else
return false;
}
bool SheetPlugin::AddSheet(bool visible) {return false;}
bool OfficeSheet::AddSheet(bool visible) {return (static_cast<SheetPlugin *>(GetData()))->AddSheet(visible);}
bool OfficeSheet::SetValue(int col, int row, Value value) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetValue(col, row, value);
else if (type == SheetMS)
return ((MSSheet*)data)->SetValue(col, row, value);
else
return false;
}
bool SheetPlugin::OpenSheet(String fileName, bool visible) {return false;}
bool OfficeSheet::OpenSheet(String fileName, bool visible) {return (static_cast<SheetPlugin *>(GetData()))->OpenSheet(fileName, visible);}
bool OfficeSheet::SetValue(String cell, Value value) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetValue(cell, value);
else if (type == SheetMS)
return ((MSSheet*)data)->SetValue(cell, value);
else
return false;
}
bool SheetPlugin::SetValue(int col, int row, Value value) {return false;}
bool OfficeSheet::SetValue(int col, int row, Value value) {return (static_cast<SheetPlugin *>(GetData()))->SetValue(col, row, value);}
bool OfficeSheet::SetValue(Value value) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetValue(value);
else if (type == SheetMS)
return ((MSSheet*)data)->SetValue(value);
else
return false;
}
bool SheetPlugin::SetValue(String cell, Value value) {return false;}
bool OfficeSheet::SetValue(String cell, Value value) {return (static_cast<SheetPlugin *>(GetData()))->SetValue(cell, value);}
Value OfficeSheet::GetValue(String cell) {
if (!data)
return Null;
if (type == SheetOPEN)
return ((OPENSheet*)data)->GetValue(cell);
else if (type == SheetMS)
return ((MSSheet*)data)->GetValue(cell);
else
return Null;
}
bool SheetPlugin::SetValue(Value value) {return false;}
bool OfficeSheet::SetValue(Value value) {return (static_cast<SheetPlugin *>(GetData()))->SetValue(value);}
Value OfficeSheet::GetValue(int col, int row) {
if (!data)
return Null;
if (type == SheetOPEN)
return ((OPENSheet*)data)->GetValue(col, row);
else if (type == SheetMS)
return ((MSSheet*)data)->GetValue(col, row);
else
return Null;
}
Value SheetPlugin::GetValue(String cell) {return Null;}
Value OfficeSheet::GetValue(String cell) {return (static_cast<SheetPlugin *>(GetData()))->GetValue(cell);}
bool OfficeSheet::Replace(Value search, Value replace) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->Replace(search, replace);
else if (type == SheetMS)
return ((MSSheet*)data)->Replace(search, replace);
else
return false;
}
Value SheetPlugin::GetValue(int col, int row) {return Null;}
Value OfficeSheet::GetValue(int col, int row) {return (static_cast<SheetPlugin *>(GetData()))->GetValue(col, row);}
bool OfficeSheet::SetBold(int col, int row, bool bold) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetBold(col, row, bold);
else if (type == SheetMS)
return ((MSSheet*)data)->SetBold(col, row, bold);
else
return false;
}
bool SheetPlugin::Replace(Value search, Value replace) {return false;}
bool OfficeSheet::Replace(Value search, Value replace) {return (static_cast<SheetPlugin *>(GetData()))->Replace(search, replace);}
bool OfficeSheet::SetBold(String cell, bool bold) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetBold(cell, bold);
else if (type == SheetMS)
return ((MSSheet*)data)->SetBold(cell, bold);
else
return false;
}
bool SheetPlugin::SetBold(int col, int row, bool bold) {return false;}
bool OfficeSheet::SetBold(int col, int row, bool bold) {return (static_cast<SheetPlugin *>(GetData()))->SetBold(col, row, bold);}
bool OfficeSheet::SetBold(bool bold) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetBold(bold);
else if (type == SheetMS)
return ((MSSheet*)data)->SetBold(bold);
else
return false;
}
bool SheetPlugin::SetBold(String cell, bool bold) {return false;}
bool OfficeSheet::SetBold(String cell, bool bold) {return (static_cast<SheetPlugin *>(GetData()))->SetBold(cell, bold);}
bool OfficeSheet::SetItalic(int col, int row, bool italic) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetItalic(col, row, italic);
else if (type == SheetMS)
return ((MSSheet*)data)->SetItalic(col, row, italic);
else
return false;
}
bool SheetPlugin::SetBold(bool bold) {return false;}
bool OfficeSheet::SetBold(bool bold) {return (static_cast<SheetPlugin *>(GetData()))->SetBold(bold);}
bool OfficeSheet::SetItalic(String cell, bool italic) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetItalic(cell, italic);
else if (type == SheetMS)
return ((MSSheet*)data)->SetItalic(cell, italic);
else
return false;
}
bool SheetPlugin::SetItalic(int col, int row, bool italic) {return false;}
bool OfficeSheet::SetItalic(int col, int row, bool italic) {return (static_cast<SheetPlugin *>(GetData()))->SetBold(col, row, italic);}
bool OfficeSheet::SetItalic(bool italic) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetItalic(italic);
else if (type == SheetMS)
return ((MSSheet*)data)->SetItalic(italic);
else
return false;
}
bool SheetPlugin::SetItalic(String cell, bool italic) {return false;}
bool OfficeSheet::SetItalic(String cell, bool italic) {return (static_cast<SheetPlugin *>(GetData()))->SetBold(cell, italic);}
bool OfficeSheet::SetUnderline(int col, int row, bool underline) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetUnderline(col, row, underline);
else if (type == SheetMS)
return ((MSSheet*)data)->SetUnderline(col, row, underline);
else
return false;
}
bool SheetPlugin::SetItalic(bool italic) {return false;}
bool OfficeSheet::SetItalic(bool italic) {return (static_cast<SheetPlugin *>(GetData()))->SetBold(italic);}
bool OfficeSheet::SetUnderline(String cell, bool underline) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetUnderline(cell, underline);
else if (type == SheetMS)
return ((MSSheet*)data)->SetUnderline(cell, underline);
else
return false;
}
bool SheetPlugin::SetUnderline(int col, int row, bool underline) {return false;}
bool OfficeSheet::SetUnderline(int col, int row, bool underline) {return (static_cast<SheetPlugin *>(GetData()))->SetUnderline(col, row, underline);}
bool OfficeSheet::SetUnderline(bool underline) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetUnderline(underline);
else if (type == SheetMS)
return ((MSSheet*)data)->SetUnderline(underline);
else
return false;
}
bool SheetPlugin::SetUnderline(String cell, bool underline) {return false;}
bool OfficeSheet::SetUnderline(String cell, bool underline) {return (static_cast<SheetPlugin *>(GetData()))->SetUnderline(cell, underline);}
bool OfficeSheet::SetFont(int col, int row, String name, int size) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetFont(col, row, name, size);
else if (type == SheetMS)
return ((MSSheet*)data)->SetFont(col, row, name, size);
else
return false;
}
bool SheetPlugin::SetUnderline(bool underline) {return false;}
bool OfficeSheet::SetUnderline(bool underline) {return (static_cast<SheetPlugin *>(GetData()))->SetUnderline(underline);}
bool OfficeSheet::SetFont(String cell, String name, int size) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetFont(cell, name, size);
else if (type == SheetMS)
return ((MSSheet*)data)->SetFont(cell, name, size);
else
return false;
}
bool SheetPlugin::SetFont(int col, int row, String name, int size) {return false;}
bool OfficeSheet::SetFont(int col, int row, String name, int size) {return (static_cast<SheetPlugin *>(GetData()))->SetFont(col, row, name, size);}
bool OfficeSheet::SetFont(String name, int size) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetFont(name, size);
else if (type == SheetMS)
return ((MSSheet*)data)->SetFont(name, size);
else
return false;
}
bool SheetPlugin::SetFont(String cell, String name, int size) {return false;}
bool OfficeSheet::SetFont(String cell, String name, int size) {return (static_cast<SheetPlugin *>(GetData()))->SetFont(cell, name, size);}
bool OfficeSheet::SetColor(int col, int row, Color color) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetColor(col, row, color);
else if (type == SheetMS)
return ((MSSheet*)data)->SetColor(col, row, color);
else
return false;
}
bool SheetPlugin::SetFont(String name, int size) {return false;}
bool OfficeSheet::SetFont(String name, int size) {return (static_cast<SheetPlugin *>(GetData()))->SetFont(name, size);}
bool OfficeSheet::SetColor(String cell, Color color) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetColor(cell, color);
else if (type == SheetMS)
return ((MSSheet*)data)->SetColor(cell, color);
else
return false;
}
bool SheetPlugin::SetColor(int col, int row, Color color) {return false;}
bool OfficeSheet::SetColor(int col, int row, Color color) {return (static_cast<SheetPlugin *>(GetData()))->SetColor(col, row, color);}
bool OfficeSheet::SetColor(Color color) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetColor(color);
else if (type == SheetMS)
return ((MSSheet*)data)->SetColor(color);
else
return false;
}
bool SheetPlugin::SetColor(String cell, Color color) {return false;}
bool OfficeSheet::SetColor(String cell, Color color) {return (static_cast<SheetPlugin *>(GetData()))->SetColor(cell, color);}
bool OfficeSheet::SetBackColor(int col, int row, Color color) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetBackColor(col, row, color);
else if (type == SheetMS)
return ((MSSheet*)data)->SetBackColor(col, row, color);
else
return false;
}
bool SheetPlugin::SetColor(Color color) {return false;}
bool OfficeSheet::SetColor(Color color) {return (static_cast<SheetPlugin *>(GetData()))->SetColor(color);}
bool OfficeSheet::SetBackColor(String cell, Color color) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetBackColor(cell, color);
else if (type == SheetMS)
return ((MSSheet*)data)->SetBackColor(cell, color);
else
return false;
}
bool SheetPlugin::SetBackColor(int col, int row, Color color) {return false;}
bool OfficeSheet::SetBackColor(int col, int row, Color color) {return (static_cast<SheetPlugin *>(GetData()))->SetBackColor(col, row, color);}
bool OfficeSheet::SetBackColor(Color color) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetBackColor(color);
else if (type == SheetMS)
return ((MSSheet*)data)->SetBackColor(color);
else
return false;
}
bool SheetPlugin::SetBackColor(String cell, Color color) {return false;}
bool OfficeSheet::SetBackColor(String cell, Color color) {return (static_cast<SheetPlugin *>(GetData()))->SetBackColor(cell, color);}
bool OfficeSheet::SetRowHeight(int row, double height) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetRowHeight(row, height);
else if (type == SheetMS)
return ((MSSheet*)data)->SetRowHeight(row, height);
else
return false;
}
bool SheetPlugin::SetBackColor(Color color) {return false;}
bool OfficeSheet::SetBackColor(Color color) {return (static_cast<SheetPlugin *>(GetData()))->SetBackColor(color);}
bool OfficeSheet::SetColWidth(int col, double width) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetColWidth(col, width);
else if (type == SheetMS)
return ((MSSheet*)data)->SetColWidth(col, width);
else
return false;
}
bool SheetPlugin::SetRowHeight(int row, double height) {return false;}
bool OfficeSheet::SetRowHeight(int row, double height) {return (static_cast<SheetPlugin *>(GetData()))->SetRowHeight(row, height);}
bool OfficeSheet::SetVertAlignment(int col, int row, int alignment) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetVertAlignment(col, row, alignment);
else if (type == SheetMS)
return ((MSSheet*)data)->SetVertAlignment(col, row, alignment);
else
return false;
}
bool SheetPlugin::SetColWidth(int col, double width) {return false;}
bool OfficeSheet::SetColWidth(int col, double width) {return (static_cast<SheetPlugin *>(GetData()))->SetColWidth(col, width);}
bool OfficeSheet::SetVertAlignment(String cell, int alignment) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetVertAlignment(cell, alignment);
else if (type == SheetMS)
return ((MSSheet*)data)->SetVertAlignment(cell, alignment);
else
return false;
}
bool SheetPlugin::SetVertAlignment(int col, int row, int alignment) {return false;}
bool OfficeSheet::SetVertAlignment(int col, int row, int alignment) {return (static_cast<SheetPlugin *>(GetData()))->SetVertAlignment(col, row, alignment);}
bool SheetPlugin::SetVertAlignment(String cell, int alignment) {return false;}
bool OfficeSheet::SetVertAlignment(String cell, int alignment) {return (static_cast<SheetPlugin *>(GetData()))->SetVertAlignment(cell, alignment);}
bool SheetPlugin::SetHorizAlignment(int col, int row, int alignment) {return false;}
bool OfficeSheet::SetHorizAlignment(int col, int row, int alignment) {return (static_cast<SheetPlugin *>(GetData()))->SetHorizAlignment(col, row, alignment);}
bool SheetPlugin::SetHorizAlignment(String cell, int alignment) {return false;}
bool OfficeSheet::SetHorizAlignment(String cell, int alignment) {return (static_cast<SheetPlugin *>(GetData()))->SetHorizAlignment(cell, alignment);}
bool OfficeSheet::SetHorizAlignment(int col, int row, int alignment) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetHorizAlignment(col, row, alignment);
else if (type == SheetMS)
return ((MSSheet*)data)->SetHorizAlignment(col, row, alignment);
else
return false;
}
bool SheetPlugin::SetBorder(int col, int row, int borderIndx, int lineStyle, int weight, Color color) {return false;}
bool OfficeSheet::SetBorder(int col, int row, int borderIndx, int lineStyle, int weight, Color color) {return (static_cast<SheetPlugin *>(GetData()))->SetBorder(col, row, borderIndx, lineStyle, weight, color);}
bool OfficeSheet::SetHorizAlignment(String cell, int alignment) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetHorizAlignment(cell, alignment);
else if (type == SheetMS)
return ((MSSheet*)data)->SetHorizAlignment(cell, alignment);
else
return false;
}
bool SheetPlugin::SetBorder(int borderIndx, int lineStyle, int weight, Color color) {return false;}
bool OfficeSheet::SetBorder(int borderIndx, int lineStyle, int weight, Color color) {return (static_cast<SheetPlugin *>(GetData()))->SetBorder(borderIndx, lineStyle, weight, color);}
bool OfficeSheet::SetBorder(int col, int row, int borderIndx, int lineStyle, int weight, Color color) {
if (!data)
return false;
// if (type == SheetOPEN)
// return ((OPENSheet*)data)->SetBorder(col, row, borderIndx, lineStyle, weight, color);
else if (type == SheetMS)
return ((MSSheet*)data)->SetBorder(col, row, borderIndx, lineStyle, weight, color);
else
return false;
}
bool SheetPlugin::Select() {return false;}
bool OfficeSheet::Select() {return (static_cast<SheetPlugin *>(GetData()))->Select();}
bool OfficeSheet::SetBorder(int borderIndx, int lineStyle, int weight, Color color) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->SetBorder(borderIndx, lineStyle, weight, color);
else if (type == SheetMS)
return ((MSSheet*)data)->SetBorder(borderIndx, lineStyle, weight, color);
else
return false;
}
bool SheetPlugin::Select(String range) {return false;}
bool OfficeSheet::Select(String range) {return (static_cast<SheetPlugin *>(GetData()))->Select(range);}
bool SheetPlugin::Select(int fromX, int fromY, int toX, int toY) {return false;}
bool OfficeSheet::Select(int fromX, int fromY, int toX, int toY) {return (static_cast<SheetPlugin *>(GetData()))->Select(fromX, fromY, toX, toY);}
bool OfficeSheet::Select(String range) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->Select(range);
else if (type == SheetMS)
return ((MSSheet*)data)->Select(range);
else
return false;
}
void SheetPlugin::DefMatrix(int width, int height) {}
void OfficeSheet::DefMatrix(int width, int height) {(static_cast<SheetPlugin *>(GetData()))->DefMatrix(width, height);}
bool OfficeSheet::Select(int fromX, int fromY, int toX, int toY) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->Select(fromX, fromY, toX, toY);
else if (type == SheetMS)
return ((MSSheet*)data)->Select(fromX, fromY, toX, toY);
else
return false;
}
bool SheetPlugin::FillSelectionMatrix() {return false;}
bool OfficeSheet::FillSelectionMatrix() {return (static_cast<SheetPlugin *>(GetData()))->FillSelectionMatrix();}
bool OfficeSheet::Select() {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->Select();
else if (type == SheetMS)
return ((MSSheet*)data)->Select();
else
return false;
}
/*
void OfficeSheet::DefMatrix(int width, int height)
{
if (!data)
return;
if (type == SheetOPEN)
((OPENSheet*)data)->DefMatrix(width, height);
else if (type == SheetMS)
((MSSheet*)data)->DefMatrix(width, height);
else
return;
}
bool OfficeSheet::FillSelectionMatrix()
{
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->FillSelectionMatrix();
else if (type == SheetMS)
return ((MSSheet*)data)->FillSelectionMatrix();
else
return false;
}
void OfficeSheet::SetMatrixValue(int i, int j, ::Value value)
{
if (!data)
return;
if (type == SheetOPEN)
((OPENSheet*)data)->SetMatrixValue(i, j, value);
else if (type == SheetMS)
((MSSheet*)data)->SetMatrixValue(i, j, value);
else
return;
}
*/
bool OfficeSheet::SaveAs(String fileName, String _type) {
if (!data)
return false;
if (type == SheetOPEN) {
int ret;
ret = ((OPENSheet*)data)->SaveAs(fileName, _type);
((OPENSheet*)data)->SetSaved(true);
return ret;
} else if (type == SheetMS) {
((MSSheet*)data)->SetSaved(true);
return ((MSSheet*)data)->SaveAs(fileName, _type);
} else
return false;
}
void SheetPlugin::SetMatrixValue(int i, int j, ::Value value) {}
void OfficeSheet::SetMatrixValue(int i, int j, ::Value value) {(static_cast<SheetPlugin *>(GetData()))->SetMatrixValue(i, j, value);}
bool OfficeSheet::Quit() {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->Quit();
else if (type == SheetMS)
return ((MSSheet*)data)->Quit();
else
return false;
}
bool SheetPlugin::SaveAs(String fileName, String _type) {return false;}
bool OfficeSheet::SaveAs(String fileName, String _type) {return (static_cast<SheetPlugin *>(GetData()))->SaveAs(fileName, _type);}
bool OfficeSheet::Print() {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->Print();
else if (type == SheetMS)
return ((MSSheet*)data)->Print();
else
return false;
}
bool SheetPlugin::SetSaved(bool saved) {return false;}
bool OfficeSheet::SetSaved(bool saved) {return (static_cast<SheetPlugin *>(GetData()))->SetSaved(saved);}
bool OfficeSheet::InsertTab(String name) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->InsertTab(name);
else if (type == SheetMS)
return ((MSSheet*)data)->InsertTab(name);
else
return false;
}
bool SheetPlugin::Quit() {return false;}
bool OfficeSheet::Quit() {return (static_cast<SheetPlugin *>(GetData()))->Quit();}
bool SheetPlugin::Print() {return false;}
bool OfficeSheet::Print() {return (static_cast<SheetPlugin *>(GetData()))->Print();}
bool SheetPlugin::InsertTab(String name) {return false;}
bool OfficeSheet::InsertTab(String name) {return (static_cast<SheetPlugin *>(GetData()))->InsertTab(name);}
bool OfficeSheet::ChooseTab(String name) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->ChooseTab(name);
else if (type == SheetMS)
return ((MSSheet*)data)->ChooseTab(name);
else
return false;
}
bool SheetPlugin::ChooseTab(String name) {return false;}
bool OfficeSheet::ChooseTab(String name) {return (static_cast<SheetPlugin *>(GetData()))->ChooseTab(name);}
bool OfficeSheet::ChooseTab(int index) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->ChooseTab(index);
else if (type == SheetMS)
return ((MSSheet*)data)->ChooseTab(index);
else
return false;
}
bool SheetPlugin::ChooseTab(int index) {return false;}
bool OfficeSheet::ChooseTab(int index) {return (static_cast<SheetPlugin *>(GetData()))->ChooseTab(index);}
bool OfficeSheet::RemoveTab(String name) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->RemoveTab(name);
else if (type == SheetMS)
return ((MSSheet*)data)->RemoveTab(name);
else
return false;
}
bool SheetPlugin::RemoveTab(String name) {return false;}
bool OfficeSheet::RemoveTab(String name) {return (static_cast<SheetPlugin *>(GetData()))->RemoveTab(name);}
bool OfficeSheet::RemoveTab(int index) {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->RemoveTab(index);
else if (type == SheetMS)
return ((MSSheet*)data)->RemoveTab(index);
else
return false;
}
bool SheetPlugin::RemoveTab(int index) {return false;}
bool OfficeSheet::RemoveTab(int index) {return (static_cast<SheetPlugin *>(GetData()))->RemoveTab(index);}
int OfficeSheet::GetNumTabs() {
if (!data)
return false;
if (type == SheetOPEN)
return ((OPENSheet*)data)->GetNumTabs();
else if (type == SheetMS)
return ((MSSheet*)data)->GetNumTabs();
else
return false;
}
int SheetPlugin::GetNumTabs() {return false;}
int OfficeSheet::GetNumTabs() {return (static_cast<SheetPlugin *>(GetData()))->GetNumTabs();}

View file

@ -8,7 +8,8 @@ topic "OfficeDoc class reference";
[{_}
[ {{10000@(113.42.0) [s0;%% [*@7;4 OfficeDoc]]}}&]
[s0;2 &]
[s0; [@(0.0.255)4 class][4 _][*4 OfficeDoc]&]
[s0; [@(0.0.255)4 class][4 _][*4 OfficeDoc ][4 : ][@(0.0.255)4 public][4 ][*4 DocPlugin][4 ,
][@(0.0.255)4 public][4 ][*4 StaticPlugin]&]
[s0;*2 &]
[s0; [2 OfficeDoc class serves to manage documents made with OpenOffice
Doc or Microsoft Office Word.]&]
@ -32,14 +33,15 @@ Init() it is defined which Office suite is going to be used.&]
[s2;%% OfficeDoc destructor. It closes document editor application.&]
[s3; &]
[s4;* &]
[s5;:OfficeDoc`:`:IsAvailable`(String`): [@(0.0.255) static] [@(0.0.255) bool]_[* IsAvailab
le]([_^String^ String]_[*@3 type])&]
[s5;:OfficeDoc`:`:IsAvailable`(const char`*`): [@(0.0.255) bool]_[* IsAvailable]([@(0.0.255) c
onst]_[@(0.0.255) char]_`*[*@3 type])&]
[s2;%% It checks if office suit of name [%-*@3 type ]is available to
be init. &]
[s2;%% Valid values are `"Open`" and `"Microsoft`".&]
[s3;%% &]
[s4; &]
[s5;:OfficeDoc`:`:Init`(String`): [@(0.0.255) bool]_[* Init]([_^String^ String]_[*@3 type])&]
[s5;:OfficeDoc`:`:Init`(const char`*`): [@(0.0.255) bool]_[* Init]([@(0.0.255) const]_[@(0.0.255) c
har]_`*[*@3 type])&]
[s2;%% Initializes OfficeSheet to use [%-*@3 type].suite.&]
[s2;%% Valid values are `"Open`" and `"Microsoft`".&]
[s3;%% &]

View file

@ -9,7 +9,8 @@ topic "OfficeSheet class reference";
[{_}
[ {{10000@(113.42.0) [s0;%% [*@7;4 OfficeSheet]]}}&]
[s1;*2 &]
[s1;:OfficeSheet`:`:class: [@(0.0.255)4 class][4 _][*4 OfficeSheet]&]
[s1;:OfficeSheet`:`:class: [@(0.0.255)4 class][4 _][*4 OfficeSheet][4 : ][@(0.0.255)4 public][4
][*4 SheetPlugin][4 , ][@(0.0.255)4 public][4 ][*4 StaticPlugin]&]
[s2;l0;* &]
[s0; [2 OfficeSheet class serves to manage spreadsheets made with OpenOffice
Calc or Microsoft Office Excel.]&]
@ -33,15 +34,22 @@ Init() it is defined which Office suite is going to be used.&]
[s2;%% OfficeSheet destructor. It closes spreadsheet application.&]
[s3; &]
[s4; &]
[s5;:OfficeSheet`:`:IsAvailable`(String`): [@(0.0.255) static] [@(0.0.255) bool]_[* IsAvail
able]([_^String^ String]_[*@3 type])&]
[s5;:OfficeSheet`:`:IsAvailable`(const char`*`): [@(0.0.255) bool]_[* IsAvailable]([@(0.0.255) c
onst]_[@(0.0.255) char]_`*[*@3 type])&]
[s2;%% It checks if office suit of name [%-*@3 type].is available to
be init. &]
[s2;%% Valid values are `"Open`" and `"Microsoft`".&]
[s3;%% &]
[s4; &]
[s5;:OfficeSheet`:`:Init`(String`): [@(0.0.255) bool]_[* Init]([_^String^ String]_[*@3 type])
&]
[s5;:OfficeSheet`:`:SetSaved`(bool`): [@(0.0.255) bool]_[* SetSaved]([@(0.0.255) bool]_[*@3 s
aved])&]
[s2;%% Sets or unsets the flag [%-*@3 saved], so that the application
did not ask for saving the document if the application receives
the Quit() order.&]
[s3;%% &]
[s4; &]
[s5;:OfficeSheet`:`:Init`(const char`*`): [@(0.0.255) bool]_[* Init]([@(0.0.255) const]_[@(0.0.255) c
har]_`*[*@3 type])&]
[s2;%% Initializes OfficeSheet to use [%-*@3 type].suite.&]
[s2;%% Valid values are `"Open`" and `"Microsoft`".&]
[s3;%% &]

View file

@ -26,4 +26,7 @@ Office.]&]
OfficeAutomation in Posix systems will be acknowledged.]&]
[s0;2 &]
[s0; [2 In this case please contact koldo.]&]
[s0;2 &]
[s0; [2 An important documentation source is ][^http`:`/`/wiki`.services`.openoffice`.org`/wiki`/Using`_Cpp`_with`_the`_OOo`_SDK^2 h
ere][2 .]&]
[s0; ]