96 lines
3.1 KiB
C++
96 lines
3.1 KiB
C++
|
|
#include <cstdlib> // For std::putenv
|
|||
|
|
#include <cstring> // For std::strdup
|
|||
|
|
#include <qwidget.h>
|
|||
|
|
#include <QHBoxLayout>
|
|||
|
|
#include <QIcon>
|
|||
|
|
#include <QVBoxLayout>
|
|||
|
|
|
|||
|
|
#include <com/sun/star/frame/XComponentLoader.hpp>
|
|||
|
|
#include <com/sun/star/frame/XStorable.hpp>
|
|||
|
|
#include <com/sun/star/frame/XDesktop.hpp>
|
|||
|
|
#include <com/sun/star/frame/Desktop.hpp>
|
|||
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|||
|
|
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
|
|||
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
|||
|
|
#include <com/sun/star/uno/Reference.hxx>
|
|||
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
|||
|
|
#include <com/sun/star/uno/XInterface.hpp>
|
|||
|
|
#include <com/sun/star/uno/RuntimeException.hpp>
|
|||
|
|
#include <com/sun/star/uno/Exception.hpp>
|
|||
|
|
#include <com/sun/star/uno/Any.hxx>
|
|||
|
|
#include <com/sun/star/document/IndexedPropertyValues.hpp>
|
|||
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
|||
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|||
|
|
#include <com/sun/star/text/XTextDocument.hpp>
|
|||
|
|
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
|
|||
|
|
#include <com/sun/star/sheet/XSpreadsheet.hpp>
|
|||
|
|
#include <com/sun/star/registry/XSimpleRegistry.hpp>
|
|||
|
|
#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
|
|||
|
|
#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
|
|||
|
|
#include <com/sun/star/util/XCloseable.hpp>
|
|||
|
|
#include <cppuhelper/bootstrap.hxx>
|
|||
|
|
|
|||
|
|
#include <osl/mutex.hxx>
|
|||
|
|
#include <rtl/ustring.hxx>
|
|||
|
|
#include <iostream>
|
|||
|
|
#include <sal/main.h>
|
|||
|
|
#include <osl/file.hxx>
|
|||
|
|
#include <osl/process.h>
|
|||
|
|
#include <rtl/process.h>
|
|||
|
|
#include <rtl/ustrbuf.hxx>
|
|||
|
|
#include "MainWindow.h"
|
|||
|
|
#include "GenerateReportBase.h"
|
|||
|
|
#include "CloseCurrentReport.h"
|
|||
|
|
|
|||
|
|
using namespace std;
|
|||
|
|
using namespace com::sun::star::uno;
|
|||
|
|
using namespace com::sun::star::lang;
|
|||
|
|
using namespace com::sun::star::beans;
|
|||
|
|
using namespace com::sun::star::bridge;
|
|||
|
|
using namespace com::sun::star::frame;
|
|||
|
|
using namespace com::sun::star::sheet;
|
|||
|
|
using namespace com::sun::star::registry;
|
|||
|
|
using namespace com::sun::star::text;
|
|||
|
|
using namespace rtl;
|
|||
|
|
|
|||
|
|
using com::sun::star::beans::PropertyValue;
|
|||
|
|
|
|||
|
|
using com::sun::star::text::XTextDocument;
|
|||
|
|
using com::sun::star::text::XText;
|
|||
|
|
using com::sun::star::text::XTextCursor;
|
|||
|
|
|
|||
|
|
namespace GenerateReport
|
|||
|
|
{
|
|||
|
|
CloseCurrentReport::CloseCurrentReport()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
//CloseCurrentReport::~CloseCurrentReport()
|
|||
|
|
//{
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
void CloseCurrentReport::closeReportExcute()
|
|||
|
|
{
|
|||
|
|
//确认生成报告后关闭文档
|
|||
|
|
auto _textDocument = GenerateReportBaseInstance->getTextDocument();
|
|||
|
|
Reference<com::sun::star::util::XCloseable> xCloseable(_textDocument, UNO_QUERY);
|
|||
|
|
if (xCloseable.is())
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
auto _main = GenerateReportBaseInstance->getMainWindow();
|
|||
|
|
_main->destructionCenterWidget();
|
|||
|
|
//参数false表示如果文档有未保存的修改,不会强制保存文档。如果将参数设置为true,
|
|||
|
|
// 则在关闭文档时会自动保存文档(前提是文档支持保存操作并且有合适的保存位置等条件)
|
|||
|
|
//xCloseable->close(false);
|
|||
|
|
GenerateReportBaseInstance->setCurrentReportNumber(0);
|
|||
|
|
}
|
|||
|
|
catch (Exception& e)
|
|||
|
|
{
|
|||
|
|
// 处理关闭文档时可能出现的异常
|
|||
|
|
OUString errorMessage = e.Message;
|
|||
|
|
// 可以在这里输出错误信息或进行其他错误处理
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|