25#include <com/sun/star/util/XProtectable.hpp>
26#include <com/sun/star/sheet/XNamedRanges.hpp>
27#include <com/sun/star/sheet/XSpreadsheetView.hpp>
28#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
29#include <com/sun/star/frame/XStorable.hpp>
30#include <com/sun/star/beans/XPropertySet.hpp>
31#include <ooo/vba/excel/XlFileFormat.hpp>
32#include <ooo/vba/excel/XApplication.hpp>
41#include <osl/file.hxx>
58 sal_Int32 nLen = xIndexAccess->getCount();
63 xIndexAccess->getByIndex(
index ) >>= *pDest;
70 if (
Index.hasValue() )
83 auto [
begin,
end] = asNonConstRange(rProps);
84 auto pProp = std::find_if(
begin,
end,
85 [](
const beans::PropertyValue& rProp) {
return rProp.Name ==
"FilterName"; });
86 bool bRes = pProp !=
end;
91 case excel::XlFileFormat::xlCSV:
94 case excel::XlFileFormat::xlDBF4:
95 pProp->Value <<= OUString(
"DBF");
97 case excel::XlFileFormat::xlDIF:
98 pProp->Value <<= OUString(
"DIF");
100 case excel::XlFileFormat::xlWK3:
101 pProp->Value <<= OUString(
"Lotus");
103 case excel::XlFileFormat::xlExcel4Workbook:
104 pProp->Value <<= OUString(
"MS Excel 4.0");
106 case excel::XlFileFormat::xlExcel5:
107 pProp->Value <<= OUString(
"MS Excel 5.0/95");
109 case excel::XlFileFormat::xlHtml:
110 pProp->Value <<= OUString(
"HTML (StarCalc)");
112 case excel::XlFileFormat::xlExcel9795:
114 pProp->Value <<= OUString(
"MS Excel 97");
124 sal_Int32 aFileFormat = 0;
125 OUString aFilterName;
126 uno::Sequence< beans::PropertyValue > aArgs = getModel()->getArgs();
130 if ( aArgs[0].
Name ==
"FilterName" ) {
131 aArgs[0].Value >>= aFilterName;
133 aArgs[1].Value >>= aFilterName;
137 aFileFormat = excel::XlFileFormat::xlCSV;
140 if ( aFilterName ==
"DBF" ) {
141 aFileFormat = excel::XlFileFormat::xlDBF4;
144 if ( aFilterName ==
"DIF" ) {
145 aFileFormat = excel::XlFileFormat::xlDIF;
148 if ( aFilterName ==
"Lotus" ) {
149 aFileFormat = excel::XlFileFormat::xlWK3;
152 if ( aFilterName ==
"MS Excel 4.0" ) {
153 aFileFormat = excel::XlFileFormat::xlExcel4Workbook;
156 if ( aFilterName ==
"MS Excel 5.0/95" ) {
157 aFileFormat = excel::XlFileFormat::xlExcel5;
160 if ( aFilterName ==
"MS Excel 97" ) {
161 aFileFormat = excel::XlFileFormat::xlExcel9795;
164 if (aFilterName ==
"HTML (StarCalc)") {
165 aFileFormat = excel::XlFileFormat::xlHtml;
168 if ( aFilterName ==
"calc_StarOffice_XML_Calc_Template" ) {
169 aFileFormat = excel::XlFileFormat::xlTemplate;
172 if (aFilterName ==
"StarOffice XML (Calc)") {
173 aFileFormat = excel::XlFileFormat::xlWorkbookNormal;
175 if ( aFilterName ==
"calc8" ) {
176 aFileFormat = excel::XlFileFormat::xlWorkbookNormal;
188 pShell->RegisterAutomationWorkbookObject(
this );
202uno::Reference< excel::XWorksheet >
206 uno::Reference< sheet::XSpreadsheetView > xView(
xModel->getCurrentController(), uno::UNO_QUERY_THROW );
207 uno::Reference< sheet::XSpreadsheet > xSheet( xView->getActiveSheet(), uno::UNO_SET_THROW );
210 if( xWorksheet.is() )
return xWorksheet;
224 uno::Reference< frame::XModel >
xModel( getModel() );
225 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(
xModel, uno::UNO_QUERY_THROW );
226 uno::Reference<container::XIndexAccess > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
228 if (
aIndex.getValueTypeClass() == uno::TypeClass_VOID )
240 if (
aIndex.getValueTypeClass() == uno::TypeClass_VOID )
260 uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
261 return xProt->isProtected();
287 uno::Reference<document::XDocumentPropertiesSupplier> xDPS( getModel(), uno::UNO_QUERY );
290 uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
291 return xDocProps->getAuthor();
296 uno::Reference<document::XDocumentPropertiesSupplier> xDPS( getModel(), uno::UNO_QUERY );
299 uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
300 xDocProps->setAuthor( _author );
307 osl::FileBase::getFileURLFromSystemPath( sFileName,
aURL );
308 uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
310 "FilterName", OUString(
"MS Excel 97" )) };
311 xStor->storeToURL(
aURL, storeProps );
315ScVbaWorkbook::SaveAs(
const uno::Any& FileName,
const uno::Any& FileFormat,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& ,
const uno::Any& )
318 FileName >>= sFileName;
320 osl::FileBase::getFileURLFromSystemPath( sFileName, sURL );
328 sURL = getModel()->getURL();
330 if ( sURL.isEmpty() )
334 uno::Reference< excel::XApplication > xApplication (
Application(),uno::UNO_QUERY_THROW );
335 OUString sWorkPath = xApplication->getDefaultFilePath();
337 osl::FileBase::getFileURLFromSystemPath( sWorkPath, sWorkURL );
338 aURL.SetURL( sWorkURL );
343 aURL.Append( sFileName );
349 sal_Int32 nFileFormat = excel::XlFileFormat::xlExcel9795;
350 FileFormat >>= nFileFormat;
355 uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
356 xStor->storeAsURL( sURL, storeProps );
361 const css::uno::Any& IncludeDocProperties,
const css::uno::Any& ,
const css::uno::Any& From,
362 const css::uno::Any& To,
const css::uno::Any& OpenAfterPublish,
const css::uno::Any& )
364 uno::Reference< frame::XModel >
xModel(getModel(), uno::UNO_SET_THROW);
365 uno::Reference< excel::XApplication > xApplication(
Application(), uno::UNO_QUERY_THROW);
368 IncludeDocProperties, From,
To, OpenAfterPublish);
371css::uno::Any SAL_CALL
377 uno::Reference< XCollection > dStyles =
new ScVbaStyles( uno::Reference< XHelperInterface >(),
mxContext, getModel() );
379 return dStyles->Item( Item,
uno::Any() );
386 uno::Reference< frame::XModel >
xModel( getModel(), uno::UNO_SET_THROW );
387 uno::Reference< beans::XPropertySet > xProps(
xModel, uno::UNO_QUERY_THROW );
388 uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue(
"NamedRanges"), uno::UNO_QUERY_THROW );
398 return "ScVbaWorkbook";
401uno::Sequence< OUString >
406 "ooo.vba.excel.Workbook"
414 uno::Reference< beans::XPropertySet > xModelProp( getModel(), uno::UNO_QUERY_THROW );
415 return xModelProp->getPropertyValue(
"CodeName").get< OUString >();
421 if (comphelper::isUnoTunnelId<ScVbaWorksheet>(rId))
428extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
430 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& args)
void SetCalcAsShown(bool bVal)
bool IsCalcAsShown() const
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
static css::uno::Reference< css::container::XIndexAccess > getDefaultPalette()
virtual css::uno::Any SAL_CALL Windows(const css::uno::Any &aIndex) override
virtual OUString SAL_CALL getCodeName() override
virtual ::sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rId) override
virtual css::uno::Any SAL_CALL Sheets(const css::uno::Any &aIndex) override
virtual OUString SAL_CALL getAuthor() override
virtual void SAL_CALL setAuthor(const OUString &_author) override
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Any SAL_CALL Worksheets(const css::uno::Any &aIndex) override
virtual void SAL_CALL ExportAsFixedFormat(const css::uno::Any &Type, const css::uno::Any &FileName, const css::uno::Any &Quality, const css::uno::Any &IncludeDocProperties, const css::uno::Any &IgnorePrintAreas, const css::uno::Any &From, const css::uno::Any &To, const css::uno::Any &OpenAfterPublish, const css::uno::Any &FixedFormatExtClassPtr) override
virtual void SAL_CALL ResetColors() override
virtual void SAL_CALL setPrecisionAsDisplayed(sal_Bool _precisionAsDisplayed) override
virtual void SAL_CALL Protect(const css::uno::Any &aPassword) override
virtual sal_Bool SAL_CALL getPrecisionAsDisplayed() override
virtual css::uno::Any SAL_CALL Styles(const css::uno::Any &Item) override
virtual OUString getServiceImplName() override
virtual css::uno::Any SAL_CALL Names(const css::uno::Any &aIndex) override
virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() override
virtual void SAL_CALL Activate() override
virtual sal_Bool SAL_CALL getProtectStructure() override
static css::uno::Sequence< sal_Int32 > ColorData
static bool setFilterPropsFromFormat(sal_Int32 nFormat, css::uno::Sequence< css::beans::PropertyValue > &rProps)
virtual ::sal_Int32 SAL_CALL getFileFormat() override
virtual void SAL_CALL SaveAs(const css::uno::Any &FileName, const css::uno::Any &FileFormat, const css::uno::Any &Password, const css::uno::Any &WriteResPassword, const css::uno::Any &ReadOnlyRecommended, const css::uno::Any &CreateBackup, const css::uno::Any &AccessMode, const css::uno::Any &ConflictResolution, const css::uno::Any &AddToMru, const css::uno::Any &TextCodepage, const css::uno::Any &TextVisualLayout, const css::uno::Any &Local) override
ScVbaWorkbook(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::frame::XModel > const &xModel)
virtual void SAL_CALL SaveCopyAs(const OUString &Filename) override
virtual css::uno::Any SAL_CALL Colors(const css::uno::Any &Index) override
virtual void SAL_CALL Activate() override
virtual void SAL_CALL Protect(const css::uno::Any &aPassword)
std::deque< AttacherIndex_Impl > aIndex
Sequence< OUString > aServiceNames
constexpr OUStringLiteral SC_TEXT_CSV_FILTER_NAME
sal_Int64 getSomething_cast(void *p)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
enumrange< T >::Iterator begin(enumrange< T >)
ScDocShell * getDocShell(const css::uno::Reference< css::frame::XModel > &xModel)
void ExportAsFixedFormatHelper(const uno::Reference< frame::XModel > &xModel, const css::uno::Reference< XApplication > &xApplication, const css::uno::Any &Type, const css::uno::Any &FileName, const css::uno::Any &Quality, const css::uno::Any &IncludeDocProperties, const css::uno::Any &From, const css::uno::Any &To, const css::uno::Any &OpenAfterPublish)
uno::Reference< XHelperInterface > getUnoSheetModuleObj(const uno::Reference< table::XCellRange > &xRange)
sal_Int32 XLRGBToOORGB(sal_Int32 nCol)
VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentExcelDoc(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Reference< XModel > xModel
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Calc_ScVbaWorkbook_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &args)
cppu::ImplInheritanceHelper< VbaDocumentBase, ov::excel::XWorkbook > ScVbaWorkbook_BASE