parent
fdd202001b
commit
f343f42156
@ -1,55 +0,0 @@ |
|||||||
/*
|
|
||||||
* UBImportVirtualPrinter.h |
|
||||||
* |
|
||||||
* Created on: 18 mars 2009 |
|
||||||
* Author: Julien |
|
||||||
*/ |
|
||||||
|
|
||||||
#ifndef UBIMPORTVIRTUALPRINTER_H_ |
|
||||||
#define UBIMPORTVIRTUALPRINTER_H_ |
|
||||||
|
|
||||||
#include <QtGui> |
|
||||||
|
|
||||||
#include "UBImportAdaptor.h" |
|
||||||
|
|
||||||
#include "document/UBDocumentProxy.h" |
|
||||||
|
|
||||||
/**
|
|
||||||
* This class import ini file that are generated by Uniboard Printer. |
|
||||||
*/ |
|
||||||
class UBImportVirtualPrinter: public UBImportAdaptor |
|
||||||
{ |
|
||||||
Q_OBJECT; |
|
||||||
|
|
||||||
public: |
|
||||||
UBImportVirtualPrinter(QObject *parent = 0); |
|
||||||
virtual ~UBImportVirtualPrinter(); |
|
||||||
|
|
||||||
// this is the name of the default printer that must be reset after importing from virtual printer.
|
|
||||||
// this allow other import adaptor to backup default printer, then set Uniboard printer as default printer and launch the
|
|
||||||
// print. Then when uniboard will import the file from virtual printer, it will reset the default printer to this one.
|
|
||||||
static QString sOriginalDefaultPrintername; |
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The document expecting to be merged with incoming data |
|
||||||
*/ |
|
||||||
static QPointer<UBDocumentProxy> pendingDocument; |
|
||||||
|
|
||||||
virtual QStringList supportedExtentions(); |
|
||||||
virtual QString importFileFilter(); |
|
||||||
virtual UBDocumentProxy* importFile(const QFile& pFile, const QString& pGroup); |
|
||||||
|
|
||||||
virtual bool addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile); |
|
||||||
|
|
||||||
|
|
||||||
private: |
|
||||||
|
|
||||||
QString pdfFileName(const QFile& pFile); |
|
||||||
QStringList emfFileNames(const QFile& pFile); |
|
||||||
|
|
||||||
void cleanUp(const QFile& pFile, const QString& pPdfFileName, QStringList pEmfFilenames); |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
#endif /* UBIMPORTVIRTUALPRINTER_H_ */ |
|
@ -1,13 +0,0 @@ |
|||||||
|
|
||||||
#ifndef UBPOWERPOINTAPPLICATION_H_ |
|
||||||
#define UBPOWERPOINTAPPLICATION_H_ |
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) |
|
||||||
#include "UBPowerPointApplication_win.h" |
|
||||||
#elif defined(Q_OS_MAC) |
|
||||||
#include "UBPowerPointApplication_mac.h" |
|
||||||
#else |
|
||||||
//TODO Linux
|
|
||||||
#endif |
|
||||||
|
|
||||||
#endif /* UBPOWERPOINTAPPLICATION_H_ */ |
|
@ -1,28 +0,0 @@ |
|||||||
|
|
||||||
#ifndef UBPOWERPOINTAPPLICATIONMAC_H_ |
|
||||||
#define UBPOWERPOINTAPPLICATIONMAC_H_ |
|
||||||
|
|
||||||
#include <QtCore> |
|
||||||
#include "UBImportAdaptor.h" |
|
||||||
|
|
||||||
class UBPowerPointApplication : public UBImportAdaptor |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
|
|
||||||
public: |
|
||||||
UBPowerPointApplication(QObject* parent = 0); |
|
||||||
virtual ~UBPowerPointApplication(); |
|
||||||
|
|
||||||
virtual QStringList supportedExtentions(); |
|
||||||
virtual QString importFileFilter(); |
|
||||||
virtual UBDocumentProxy* importFile(const QFile& pFile, const QString& pGroup); |
|
||||||
|
|
||||||
virtual bool addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile); |
|
||||||
|
|
||||||
private: |
|
||||||
bool generatePdfFromPptFile(const QString& pptFile, const QString& pOutputFile); |
|
||||||
|
|
||||||
|
|
||||||
}; |
|
||||||
|
|
||||||
#endif /* UBPOWERPOINTAPPLICATIONMAC_H_ */ |
|
@ -1,227 +0,0 @@ |
|||||||
|
|
||||||
#include "UBPowerPointApplication_mac.h" |
|
||||||
|
|
||||||
#include "core/UBApplication.h" |
|
||||||
#include "core/UBDocumentManager.h" |
|
||||||
#include "frameworks/UBPlatformUtils.h" |
|
||||||
#include "frameworks/UBFileSystemUtils.h" |
|
||||||
|
|
||||||
#import <Foundation/NSAutoreleasePool.h> |
|
||||||
#import <Carbon/Carbon.h> |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UBPowerPointApplication::UBPowerPointApplication(QObject* parent) |
|
||||||
: UBImportAdaptor(parent) |
|
||||||
{ |
|
||||||
// NOOP |
|
||||||
} |
|
||||||
|
|
||||||
UBPowerPointApplication::~UBPowerPointApplication() |
|
||||||
{ |
|
||||||
// NOOP |
|
||||||
} |
|
||||||
|
|
||||||
class AppleScriptThread : public QThread |
|
||||||
{ |
|
||||||
public: |
|
||||||
AppleScriptThread(NSAppleScript *appleScript, QObject *parent = 0) |
|
||||||
: QThread(parent) |
|
||||||
, mAppleScript(appleScript) |
|
||||||
, mError(nil) |
|
||||||
{ |
|
||||||
// NOOP |
|
||||||
} |
|
||||||
|
|
||||||
~AppleScriptThread() |
|
||||||
{ |
|
||||||
if (mError) |
|
||||||
{ |
|
||||||
[mError release]; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void run() |
|
||||||
{ |
|
||||||
NSDictionary *error = nil; |
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
|
||||||
[mAppleScript executeAndReturnError:&error]; |
|
||||||
mError = error ? [[NSDictionary alloc] initWithDictionary:error] : nil; |
|
||||||
[pool release]; |
|
||||||
} |
|
||||||
|
|
||||||
NSDictionary* error() |
|
||||||
{ |
|
||||||
return mError; |
|
||||||
} |
|
||||||
|
|
||||||
private: |
|
||||||
NSAppleScript *mAppleScript; |
|
||||||
NSDictionary *mError; |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
NSString* escapePath(const QString &filePath) |
|
||||||
{ |
|
||||||
QString escapedFilePath(filePath); |
|
||||||
escapedFilePath.replace("\"", "\\\""); |
|
||||||
QByteArray pathRepresentation = QFile::encodeName(escapedFilePath); |
|
||||||
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:pathRepresentation.constData() length:pathRepresentation.length()]; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
bool UBPowerPointApplication::generatePdfFromPptFile(const QString& pptFile, const QString& pOutputFile) |
|
||||||
{ |
|
||||||
bool result = true; |
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
|
||||||
QResource scriptResource(":/PowerPointImport.applescript"); |
|
||||||
NSString *script = [[NSString alloc] initWithBytes:scriptResource.data() length:scriptResource.size() encoding:NSUTF8StringEncoding]; |
|
||||||
QFileInfo pptFileInfo(pptFile); |
|
||||||
NSString *scriptSource = [NSString stringWithFormat:script, escapePath(pptFileInfo.fileName()), escapePath(pptFile), escapePath(pOutputFile)]; |
|
||||||
[script release]; |
|
||||||
NSAppleScript *pdfExportScript = [[NSAppleScript alloc] initWithSource:scriptSource]; |
|
||||||
AppleScriptThread appleScriptThread(pdfExportScript); |
|
||||||
appleScriptThread.start(); |
|
||||||
while (appleScriptThread.isRunning()) |
|
||||||
{ |
|
||||||
qApp->processEvents(); |
|
||||||
} |
|
||||||
if (appleScriptThread.error()) |
|
||||||
{ |
|
||||||
const char* errorDescription = [[appleScriptThread.error() description] UTF8String]; |
|
||||||
qWarning() << "PowerPoint import error:" << QString::fromUtf8(errorDescription, strlen(errorDescription)); |
|
||||||
result = false; |
|
||||||
} |
|
||||||
[pdfExportScript release]; |
|
||||||
[pool drain]; |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
QStringList UBPowerPointApplication::supportedExtentions() |
|
||||||
{ |
|
||||||
QStringList result; |
|
||||||
CFURLRef powerPointURL = NULL; |
|
||||||
|
|
||||||
if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.microsoft.Powerpoint"), NULL, NULL, &powerPointURL) == noErr) |
|
||||||
{ |
|
||||||
CFBundleRef powerPointBundle = CFBundleCreate(kCFAllocatorDefault, powerPointURL); |
|
||||||
if (powerPointBundle) |
|
||||||
{ |
|
||||||
CFStringRef buildNumber = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(powerPointBundle, CFSTR("MicrosoftBuildNumber")); |
|
||||||
if (buildNumber && (CFGetTypeID(buildNumber) == CFStringGetTypeID())) |
|
||||||
{ |
|
||||||
int buildValue = CFStringGetIntValue(buildNumber); |
|
||||||
if (buildValue >= 80409) |
|
||||||
{ |
|
||||||
// PowerPoint 2008 |
|
||||||
result << "ppt" << "pptx" << "pptm" << "pps" << "ppsx" << "ppsm"; |
|
||||||
} |
|
||||||
/* |
|
||||||
else if (buildValue >= `Office 2004 MicrosoftBuildNumber`) |
|
||||||
{ |
|
||||||
result << "ppt" << "pptm" << "pps" << "ppsm"; |
|
||||||
} |
|
||||||
*/ |
|
||||||
else |
|
||||||
{ |
|
||||||
qWarning("Unsupported Microsoft PowerPoint version: %d", buildValue); |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
qWarning("Invalid PowerPoint MicrosoftBuildNumber"); |
|
||||||
} |
|
||||||
CFRelease(powerPointBundle); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
qWarning("Microsoft PowerPoint bundle was not found"); |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
qWarning("Microsoft PowerPoint was not found"); |
|
||||||
} |
|
||||||
|
|
||||||
if (powerPointURL) |
|
||||||
{ |
|
||||||
CFRelease(powerPointURL); |
|
||||||
} |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
QString UBPowerPointApplication::importFileFilter() |
|
||||||
{ |
|
||||||
QStringList extentions = supportedExtentions(); |
|
||||||
if (extentions.count() > 0) |
|
||||||
{ |
|
||||||
QString filter = "PowerPoint ("; |
|
||||||
foreach (const QString ext, extentions) |
|
||||||
{ |
|
||||||
filter.append("*."); |
|
||||||
filter.append(ext); |
|
||||||
filter.append(" "); |
|
||||||
} |
|
||||||
filter = filter.trimmed(); |
|
||||||
filter.append(")"); |
|
||||||
return filter; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return 0; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
UBDocumentProxy* UBPowerPointApplication::importFile(const QFile& pFile, const QString& pGroup) |
|
||||||
{ |
|
||||||
UBApplication::showMessage(tr("Converting PowerPoint file ..."), true); |
|
||||||
UBDocumentProxy* result = 0; |
|
||||||
|
|
||||||
QString tempDir = UBFileSystemUtils::createTempDir(); |
|
||||||
QFileInfo sourceFileInfo(pFile); |
|
||||||
QString tempFile = tempDir + "/" + sourceFileInfo.baseName() + ".pdf"; |
|
||||||
|
|
||||||
if (generatePdfFromPptFile(pFile.fileName(), tempFile)) |
|
||||||
{ |
|
||||||
UBApplication::showMessage(tr("PowerPoint import successful.")); |
|
||||||
QFile tmp(tempFile); |
|
||||||
result = UBDocumentManager::documentManager()->importFile(tmp, pGroup); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
UBApplication::showMessage(tr("PowerPoint import failed.")); |
|
||||||
} |
|
||||||
|
|
||||||
UBFileSystemUtils::deleteDir(tempDir); |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
bool UBPowerPointApplication::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) |
|
||||||
{ |
|
||||||
UBApplication::showMessage(tr("Converting PowerPoint file ..."), true); |
|
||||||
bool result = false; |
|
||||||
|
|
||||||
QString tempDir = UBFileSystemUtils::createTempDir(); |
|
||||||
QFileInfo sourceFileInfo(pFile); |
|
||||||
QString tempFile = tempDir + "/" + sourceFileInfo.baseName() + ".pdf"; |
|
||||||
|
|
||||||
if (generatePdfFromPptFile(pFile.fileName(), tempFile)) |
|
||||||
{ |
|
||||||
UBApplication::showMessage(tr("PowerPoint import successful.")); |
|
||||||
QFile tmp(tempFile); |
|
||||||
result = UBDocumentManager::documentManager()->addFileToDocument(pDocument, tmp); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
UBApplication::showMessage(tr("PowerPoint import failed.")); |
|
||||||
} |
|
||||||
|
|
||||||
UBFileSystemUtils::deleteDir(tempDir); |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
@ -1,269 +0,0 @@ |
|||||||
/*
|
|
||||||
* UBPowerPointApplication.cpp |
|
||||||
* |
|
||||||
* Created on: Dec 4, 2008 |
|
||||||
* Author: Luc |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "UBPowerPointApplication_win.h" |
|
||||||
|
|
||||||
#include "frameworks/UBFileSystemUtils.h" |
|
||||||
|
|
||||||
#include "core/UBApplication.h" |
|
||||||
#include "core/UBDocumentManager.h" |
|
||||||
#include "core/UBPersistenceManager.h" |
|
||||||
|
|
||||||
#include "UBImportVirtualPrinter.h" |
|
||||||
#include "msppt.h" |
|
||||||
#include "mso.h" |
|
||||||
#include "windows.h" |
|
||||||
|
|
||||||
UBPowerPointApplication::UBPowerPointApplication(QObject* parent) |
|
||||||
: UBImportAdaptor(parent) |
|
||||||
, mInit(false) |
|
||||||
, mHasException(false) |
|
||||||
, mSupportPpt(false) |
|
||||||
, mSupportPptX(false) |
|
||||||
{ |
|
||||||
// NOOP
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
UBPowerPointApplication::~UBPowerPointApplication() |
|
||||||
{ |
|
||||||
// NOOP
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void UBPowerPointApplication::init() |
|
||||||
{ |
|
||||||
PowerPoint::Application ppt; |
|
||||||
qDebug() << "PPT version :" << ppt.Version().toFloat(); |
|
||||||
mSupportPpt = !ppt.isNull(); |
|
||||||
mSupportPptX = ppt.Version().toFloat() >= 12; |
|
||||||
mInit = true; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
bool UBPowerPointApplication::isPowerPointInstalled() |
|
||||||
{ |
|
||||||
if (!mInit) |
|
||||||
{ |
|
||||||
init(); |
|
||||||
} |
|
||||||
return mSupportPpt; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
bool UBPowerPointApplication::supportPptx() |
|
||||||
{ |
|
||||||
if (!mInit) |
|
||||||
{ |
|
||||||
init(); |
|
||||||
} |
|
||||||
|
|
||||||
return mSupportPptX; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
bool UBPowerPointApplication::generatePdfFromPptFile(const QString& pptFile, const QString& outputDir) |
|
||||||
{ |
|
||||||
Q_UNUSED(pptFile); |
|
||||||
Q_UNUSED(outputDir); |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
bool UBPowerPointApplication::generateImagesFromPptFile(const QString& pptFile, const QString& outputDir, const QString& imageFormat, const QSize& imageSize) |
|
||||||
{ |
|
||||||
mHasException = false; |
|
||||||
|
|
||||||
PowerPoint::Application ppt; |
|
||||||
|
|
||||||
connect(&ppt, SIGNAL(exception ( int , const QString & , const QString & , const QString & )) |
|
||||||
, this, SLOT(exception ( int , const QString & , const QString & , const QString & ))); |
|
||||||
|
|
||||||
if (ppt.isNull()) |
|
||||||
return false; |
|
||||||
|
|
||||||
ppt.Activate(); |
|
||||||
ppt.SetWindowState(PowerPoint::ppWindowMinimized); |
|
||||||
|
|
||||||
UBApplication::processEvents(); |
|
||||||
|
|
||||||
int previouslyOpenPresentations = ppt.Presentations()->Count(); |
|
||||||
|
|
||||||
PowerPoint::Presentation *presentation = |
|
||||||
ppt.Presentations()->Open(QDir::toNativeSeparators(pptFile)); |
|
||||||
|
|
||||||
int currentOpenPresentations = ppt.Presentations()->Count(); |
|
||||||
|
|
||||||
if(!presentation) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (ppt.Version().toFloat() >= 12) // PPT 2007 is broken with high res exports : https://trac.assembla.com/uniboard/ticket/297#comment:16
|
|
||||||
{ |
|
||||||
presentation->Export(QDir::toNativeSeparators(outputDir), imageFormat); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
presentation->Export(QDir::toNativeSeparators(outputDir), imageFormat, imageSize.width(), imageSize.height()); |
|
||||||
} |
|
||||||
|
|
||||||
if(mHasException) |
|
||||||
return false; |
|
||||||
|
|
||||||
if (currentOpenPresentations != previouslyOpenPresentations) |
|
||||||
presentation->Close(); |
|
||||||
|
|
||||||
if (ppt.Presentations()->Count() == 0) |
|
||||||
ppt.Quit(); |
|
||||||
|
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
QStringList UBPowerPointApplication::supportedExtentions() |
|
||||||
{ |
|
||||||
QStringList result; |
|
||||||
if (UBPowerPointApplication::isPowerPointInstalled()) |
|
||||||
{ |
|
||||||
result << QStringList("ppt") << "pps"; |
|
||||||
if (UBPowerPointApplication::supportPptx()) |
|
||||||
{ |
|
||||||
result << "pptx" << "pptm" << "ppsx" << "ppsm"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
QString UBPowerPointApplication::importFileFilter() |
|
||||||
{ |
|
||||||
if (UBPowerPointApplication::isPowerPointInstalled()) |
|
||||||
{ |
|
||||||
if (UBPowerPointApplication::supportPptx()) |
|
||||||
{ |
|
||||||
return "PowerPoint (*.ppt *.pptx *.pptm *.pps *.ppsx *.ppsm)"; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return "PowerPoint (*.ppt *.pps)"; |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
UBDocumentProxy* UBPowerPointApplication::importFile(const QFile& pFile, const QString& pGroup) |
|
||||||
{ |
|
||||||
|
|
||||||
UBDocumentProxy* document = 0; |
|
||||||
// print by changing default printer and use shell execute to print
|
|
||||||
LPTSTR wDefaultPrinterName = new TCHAR[255]; |
|
||||||
LPTSTR virtualPrinter = new TCHAR[255]; |
|
||||||
|
|
||||||
int i = QString("Uniboard").toWCharArray(virtualPrinter); // TODO UB 4.x make me configurable ....
|
|
||||||
virtualPrinter[i] = 0; |
|
||||||
DWORD bufferSize = 1000; |
|
||||||
GetDefaultPrinter(wDefaultPrinterName, &bufferSize); |
|
||||||
UBImportVirtualPrinter::sOriginalDefaultPrintername = QString::fromWCharArray(wDefaultPrinterName); |
|
||||||
|
|
||||||
if (!SetDefaultPrinter(virtualPrinter)) |
|
||||||
{ |
|
||||||
QMessageBox msgBox(0); |
|
||||||
msgBox.setText(tr("Uniboard printer is not installed. Import will be done in jpg format.")); |
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok); |
|
||||||
msgBox.setDefaultButton(QMessageBox::Ok); |
|
||||||
msgBox.exec(); |
|
||||||
QString tempLocation = UBFileSystemUtils::createTempDir(); |
|
||||||
QDir tempDir(tempLocation); |
|
||||||
|
|
||||||
bool pptSuccess = generateImagesFromPptFile(pFile.fileName(), tempLocation, "jpg", QSize(3000, 2250)); |
|
||||||
|
|
||||||
if (pptSuccess) |
|
||||||
{ |
|
||||||
document = UBDocumentManager::documentManager()->importDir(tempDir, pGroup); |
|
||||||
|
|
||||||
if (document) |
|
||||||
{ |
|
||||||
UBFileSystemUtils::deleteDir(tempLocation); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
document = UBPersistenceManager::persistenceManager()->createDocument(pGroup); |
|
||||||
|
|
||||||
QFileInfo sourceFileInfo(pFile); |
|
||||||
|
|
||||||
document->setMetaData(UBSettings::documentName, sourceFileInfo.baseName()); |
|
||||||
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(document); |
|
||||||
|
|
||||||
UBImportVirtualPrinter::pendingDocument = document; |
|
||||||
|
|
||||||
int result = (int)ShellExecute(NULL, QString("print").utf16() , pFile.fileName().utf16(), NULL, NULL, SW_HIDE); |
|
||||||
|
|
||||||
qDebug() << "PPT shellexec print result" << result; |
|
||||||
} |
|
||||||
|
|
||||||
delete[] wDefaultPrinterName; |
|
||||||
delete[] virtualPrinter; |
|
||||||
|
|
||||||
return document; |
|
||||||
} |
|
||||||
|
|
||||||
bool UBPowerPointApplication::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) |
|
||||||
{ |
|
||||||
bool result = false; |
|
||||||
// print by changing default printer and use shell execute to print
|
|
||||||
LPTSTR wDefaultPrinterName = new TCHAR[255]; |
|
||||||
LPTSTR virtualPrinter = new TCHAR[255]; |
|
||||||
|
|
||||||
int i = QString("Uniboard").toWCharArray(virtualPrinter); // TODO UB 4.x make me configurable ....
|
|
||||||
virtualPrinter[i] = 0; |
|
||||||
DWORD bufferSize = 1000; |
|
||||||
GetDefaultPrinter(wDefaultPrinterName, &bufferSize); |
|
||||||
UBImportVirtualPrinter::sOriginalDefaultPrintername = QString::fromWCharArray(wDefaultPrinterName); |
|
||||||
|
|
||||||
if (!SetDefaultPrinter(virtualPrinter)) |
|
||||||
{ |
|
||||||
QMessageBox msgBox(0); |
|
||||||
msgBox.setText(tr("Uniboard printer is not installed. Import will be done in jpg format.")); |
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok); |
|
||||||
msgBox.setDefaultButton(QMessageBox::Ok); |
|
||||||
msgBox.exec(); |
|
||||||
QString tempLocation = UBFileSystemUtils::createTempDir(); |
|
||||||
QDir tempDir(tempLocation); |
|
||||||
|
|
||||||
bool pptSuccess = generateImagesFromPptFile(pFile.fileName(), tempLocation, "jpg", QSize(3000, 2250)); |
|
||||||
|
|
||||||
if (pptSuccess) |
|
||||||
{ |
|
||||||
if (UBDocumentManager::documentManager()->addImageDirToDocument(tempDir, pDocument)) |
|
||||||
{ |
|
||||||
UBFileSystemUtils::deleteDir(tempLocation); |
|
||||||
result = true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
UBImportVirtualPrinter::pendingDocument = pDocument; |
|
||||||
result = ShellExecute(NULL, QString("print").utf16() , pFile.fileName().utf16(), NULL, NULL, SW_HIDE); |
|
||||||
} |
|
||||||
|
|
||||||
delete[] wDefaultPrinterName; |
|
||||||
delete[] virtualPrinter; |
|
||||||
return result; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void UBPowerPointApplication::exception ( int code, const QString & source, const QString & desc, const QString & help ) |
|
||||||
{ |
|
||||||
Q_UNUSED(help); |
|
||||||
mHasException = true; |
|
||||||
qCritical() << source << desc << code; |
|
||||||
} |
|
||||||
|
|
@ -1,50 +0,0 @@ |
|||||||
/*
|
|
||||||
* UBPowerPointApplication.h |
|
||||||
* |
|
||||||
* Created on: Dec 4, 2008 |
|
||||||
* Author: Luc |
|
||||||
*/ |
|
||||||
|
|
||||||
#ifndef UBPOWERPOINTAPPLICATIONWIN_H_ |
|
||||||
#define UBPOWERPOINTAPPLICATIONWIN_H_ |
|
||||||
|
|
||||||
#include <QtCore> |
|
||||||
#include "UBImportAdaptor.h" |
|
||||||
|
|
||||||
class UBPowerPointApplication : public UBImportAdaptor { |
|
||||||
|
|
||||||
Q_OBJECT; |
|
||||||
|
|
||||||
public: |
|
||||||
UBPowerPointApplication(QObject* parent = 0); |
|
||||||
virtual ~UBPowerPointApplication(); |
|
||||||
|
|
||||||
bool isPowerPointInstalled(); |
|
||||||
|
|
||||||
bool supportPptx(); |
|
||||||
|
|
||||||
virtual QStringList supportedExtentions(); |
|
||||||
virtual QString importFileFilter(); |
|
||||||
virtual UBDocumentProxy* importFile(const QFile& pFile, const QString& pGroup); |
|
||||||
|
|
||||||
virtual bool addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile); |
|
||||||
|
|
||||||
private: |
|
||||||
|
|
||||||
bool generateImagesFromPptFile(const QString& pptFile, const QString&outputDir, const QString& imageFormat, const QSize& imageSize); |
|
||||||
bool generatePdfFromPptFile(const QString& pptFile, const QString& pOutputFile); |
|
||||||
bool catchAndProcessFile(); |
|
||||||
|
|
||||||
void init(); |
|
||||||
bool mInit; |
|
||||||
bool mHasException; |
|
||||||
bool mSupportPpt; |
|
||||||
bool mSupportPptX; |
|
||||||
|
|
||||||
|
|
||||||
private slots: |
|
||||||
void exception ( int code, const QString & source, const QString & desc, const QString & help); |
|
||||||
|
|
||||||
}; |
|
||||||
|
|
||||||
#endif /* UBPOWERPOINTAPPLICATIONWIN_H_ */ |
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,23 +0,0 @@ |
|||||||
TEMPLATE = lib |
|
||||||
CONFIG += staticlib release warn_off |
|
||||||
|
|
||||||
DESTDIR = "lib" |
|
||||||
|
|
||||||
win32 { |
|
||||||
|
|
||||||
CONFIG += qaxcontainer |
|
||||||
|
|
||||||
# The folowing COM wrappers are generated from dumcpp |
|
||||||
# |
|
||||||
TYPELIBS = $$system(dumpcpp -getfile {91493440-5A91-11CF-8700-00AA0060263B}) |
|
||||||
TYPELIBS += $$system(dumpcpp -getfile {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}) |
|
||||||
|
|
||||||
SOURCES += msppt.cpp \ |
|
||||||
mso.cpp |
|
||||||
|
|
||||||
HEADERS += msppt.h \ |
|
||||||
mso.h |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,13 +0,0 @@ |
|||||||
TEMPLATE = lib |
|
||||||
CONFIG += static release warn_off |
|
||||||
|
|
||||||
DESTDIR = "lib" |
|
||||||
|
|
||||||
win32 { |
|
||||||
|
|
||||||
SOURCES += src/RTSCOM_i.c |
|
||||||
|
|
||||||
HEADERS += include/RTSCOM.h |
|
||||||
} |
|
||||||
|
|
||||||
|
|
@ -1,128 +0,0 @@ |
|||||||
//--------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
//
|
|
||||||
// File: rtscom_i.c
|
|
||||||
// Microsoft Tablet PC API definitions
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */ |
|
||||||
|
|
||||||
/* link this file in with the server and any clients */ |
|
||||||
|
|
||||||
|
|
||||||
/* File created by MIDL compiler version 7.00.0499 */ |
|
||||||
/* Compiler settings for rtscom.idl:
|
|
||||||
Oicf, W1, Zp8, env=Win32 (32b run) |
|
||||||
protocol : dce , ms_ext, c_ext, robust |
|
||||||
error checks: allocation ref bounds_check enum stub_data
|
|
||||||
VC __declspec() decoration level:
|
|
||||||
__declspec(uuid()), __declspec(selectany), __declspec(novtable) |
|
||||||
DECLSPEC_UUID(), MIDL_INTERFACE() |
|
||||||
*/ |
|
||||||
//@@MIDL_FILE_HEADING( )
|
|
||||||
|
|
||||||
#pragma warning( disable: 4049 ) /* more than 64k source lines */ |
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus |
|
||||||
extern "C"{ |
|
||||||
#endif |
|
||||||
|
|
||||||
|
|
||||||
#include <rpc.h> |
|
||||||
#include <rpcndr.h> |
|
||||||
|
|
||||||
#ifdef _MIDL_USE_GUIDDEF_ |
|
||||||
|
|
||||||
#ifndef INITGUID |
|
||||||
#define INITGUID |
|
||||||
#include <guiddef.h> |
|
||||||
#undef INITGUID |
|
||||||
#else |
|
||||||
#include <guiddef.h> |
|
||||||
#endif |
|
||||||
|
|
||||||
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ |
|
||||||
DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) |
|
||||||
|
|
||||||
#else // !_MIDL_USE_GUIDDEF_
|
|
||||||
|
|
||||||
#ifndef __IID_DEFINED__ |
|
||||||
#define __IID_DEFINED__ |
|
||||||
|
|
||||||
typedef struct _IID |
|
||||||
{ |
|
||||||
unsigned long x; |
|
||||||
unsigned short s1; |
|
||||||
unsigned short s2; |
|
||||||
unsigned char c[8]; |
|
||||||
} IID; |
|
||||||
|
|
||||||
#endif // __IID_DEFINED__
|
|
||||||
|
|
||||||
#ifndef CLSID_DEFINED |
|
||||||
#define CLSID_DEFINED |
|
||||||
typedef IID CLSID; |
|
||||||
#endif // CLSID_DEFINED
|
|
||||||
|
|
||||||
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ |
|
||||||
const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} |
|
||||||
|
|
||||||
#endif !_MIDL_USE_GUIDDEF_ |
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, LIBID_TPCRTSLib,0xA76A6D34,0xA06D,0x43e1,0x8C,0x05,0x0C,0x56,0xD3,0x6F,0x46,0x2E); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IRealTimeStylus,0xA8BB5D22,0x3144,0x4a7b,0x93,0xCD,0xF3,0x4A,0x16,0xBE,0x51,0x3A); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IRealTimeStylus2,0xB5F2A6CD,0x3179,0x4a3e,0xB9,0xC4,0xBB,0x58,0x65,0x96,0x2B,0xE2); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IRealTimeStylusSynchronization,0xAA87EAB8,0xAB4A,0x4cea,0xB5,0xCB,0x46,0xD8,0x4C,0x6A,0x25,0x09); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IStrokeBuilder,0xA5FD4E2D,0xC44B,0x4092,0x91,0x77,0x26,0x09,0x05,0xEB,0x67,0x2B); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IStylusPlugin,0xA81436D8,0x4757,0x4fd1,0xA1,0x85,0x13,0x3F,0x97,0xC6,0xC5,0x45); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IStylusSyncPlugin,0xA157B174,0x482F,0x4d71,0xA3,0xF6,0x3A,0x41,0xDD,0xD1,0x1B,0xE9); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IStylusAsyncPlugin,0xA7CCA85A,0x31BC,0x4cd2,0xAA,0xDC,0x32,0x89,0xA3,0xAF,0x11,0xC8); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IDynamicRenderer,0xA079468E,0x7165,0x46f9,0xB7,0xAF,0x98,0xAD,0x01,0xA9,0x30,0x09); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(IID, IID_IGestureRecognizer,0xAE9EF86B,0x7054,0x45e3,0xAE,0x22,0x31,0x74,0xDC,0x88,0x11,0xB7); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(CLSID, CLSID_RealTimeStylus,0xE26B366D,0xF998,0x43ce,0x83,0x6F,0xCB,0x6D,0x90,0x44,0x32,0xB0); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(CLSID, CLSID_DynamicRenderer,0xECD32AEA,0x746F,0x4dcb,0xBF,0x68,0x08,0x27,0x57,0xFA,0xFF,0x18); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(CLSID, CLSID_GestureRecognizer,0xEA30C654,0xC62C,0x441f,0xAC,0x00,0x95,0xF9,0xA1,0x96,0x78,0x2C); |
|
||||||
|
|
||||||
|
|
||||||
MIDL_DEFINE_GUID(CLSID, CLSID_StrokeBuilder,0xE810CEE7,0x6E51,0x4cb0,0xAA,0x3A,0x0B,0x98,0x5B,0x70,0xDA,0xF7); |
|
||||||
|
|
||||||
#undef MIDL_DEFINE_GUID |
|
||||||
|
|
||||||
#ifdef __cplusplus |
|
||||||
} |
|
||||||
#endif |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue