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;
187 uno::Reference< frame::XModel >
xModel = getModel();
203uno::Reference< excel::XWorksheet >
207 uno::Reference< sheet::XSpreadsheetView > xView(
xModel->getCurrentController(), uno::UNO_QUERY_THROW );
208 uno::Reference< sheet::XSpreadsheet > xSheet( xView->getActiveSheet(), uno::UNO_SET_THROW );
211 if( xWorksheet.is() )
return xWorksheet;
225 uno::Reference< frame::XModel >
xModel( getModel() );
226 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(
xModel, uno::UNO_QUERY_THROW );
227 uno::Reference<container::XIndexAccess > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
229 if (
aIndex.getValueTypeClass() == uno::TypeClass_VOID )
241 if (
aIndex.getValueTypeClass() == uno::TypeClass_VOID )
261 uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
262 return xProt->isProtected();
267 uno::Reference< frame::XModel >
xModel( getModel(), uno::UNO_SET_THROW );
274 uno::Reference< frame::XModel >
xModel( getModel(), uno::UNO_SET_THROW );
283 uno::Reference<document::XDocumentPropertiesSupplier> xDPS( getModel(), uno::UNO_QUERY );
286 uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
287 return xDocProps->getAuthor();
292 uno::Reference<document::XDocumentPropertiesSupplier> xDPS( getModel(), uno::UNO_QUERY );
295 uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
296 xDocProps->setAuthor( _author );
303 osl::FileBase::getFileURLFromSystemPath( sFileName,
aURL );
304 uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
306 "FilterName", OUString(
"MS Excel 97" )) };
307 xStor->storeToURL(
aURL, storeProps );
311ScVbaWorkbook::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& )
314 FileName >>= sFileName;
316 osl::FileBase::getFileURLFromSystemPath( sFileName, sURL );
324 sURL = getModel()->getURL();
326 if ( sURL.isEmpty() )
330 uno::Reference< excel::XApplication > xApplication (
Application(),uno::UNO_QUERY_THROW );
331 OUString sWorkPath = xApplication->getDefaultFilePath();
333 osl::FileBase::getFileURLFromSystemPath( sWorkPath, sWorkURL );
334 aURL.SetURL( sWorkURL );
339 aURL.Append( sFileName );
345 sal_Int32 nFileFormat = excel::XlFileFormat::xlExcel9795;
346 FileFormat >>= nFileFormat;
351 uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
352 xStor->storeAsURL( sURL, storeProps );
355css::uno::Any SAL_CALL
361 uno::Reference< XCollection > dStyles =
new ScVbaStyles( uno::Reference< XHelperInterface >(),
mxContext, getModel() );
363 return dStyles->Item( Item,
uno::Any() );
370 uno::Reference< frame::XModel >
xModel( getModel(), uno::UNO_SET_THROW );
371 uno::Reference< beans::XPropertySet > xProps(
xModel, uno::UNO_QUERY_THROW );
372 uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue(
"NamedRanges"), uno::UNO_QUERY_THROW );
382 return "ScVbaWorkbook";
385uno::Sequence< OUString >
390 "ooo.vba.excel.Workbook"
398 uno::Reference< beans::XPropertySet > xModelProp( getModel(), uno::UNO_QUERY_THROW );
399 return xModelProp->getPropertyValue(
"CodeName").get< OUString >();
405 if (comphelper::isUnoTunnelId<ScVbaWorksheet>(rId))
412extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
414 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& args)
void SetCalcAsShown(bool bVal)
bool IsCalcAsShown() const
void RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const &xWorkbook)
const ScDocument & GetDocument() 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 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)
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