25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/container/XEnumeration.hpp>
27#include <com/sun/star/container/XEnumerationAccess.hpp>
28#include <com/sun/star/frame/XModel.hpp>
29#include <com/sun/star/script/ModuleType.hpp>
30#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
32#include <oox/token/properties.hxx>
43 ::
oox::ole::VbaProject( rxContext,
Reference< XModel >( rxDocument, UNO_QUERY ),
u"Calc" ),
44 mxDocument( rxDocument )
52struct SheetCodeNameInfo
57 explicit SheetCodeNameInfo( PropertySet aSheetProps, OUString aPrefix ) :
73 ::std::set< OUString > aUsedCodeNames;
76 ::std::vector< SheetCodeNameInfo > aCodeNameInfos;
79 Reference< XEnumerationAccess > xSheetsEA(
mxDocument->getSheets(), UNO_QUERY_THROW );
80 Reference< XEnumeration > xSheetsEnum( xSheetsEA->createEnumeration(), UNO_SET_THROW );
82 while( xSheetsEnum->hasMoreElements() )
try
84 PropertySet aSheetProp( xSheetsEnum->nextElement() );
87 if( !aCodeName.isEmpty() )
89 aUsedCodeNames.insert( aCodeName );
94 aCodeNameInfos.emplace_back( aSheetProp,
"Sheet" );
102 for (
auto & codeName : aCodeNameInfos)
105 sal_Int32 nCounter = 1;
109 aCodeName = codeName.maPrefix + OUString::number( nCounter++ );
111 while( aUsedCodeNames.count( aCodeName ) > 0 );
112 aUsedCodeNames.insert( aCodeName );
115 codeName.maSheetProps.setProperty( PROP_CodeName, aCodeName );
bool getProperty(Type &orValue, sal_Int32 nPropId) const
void addDummyModule(const OUString &rName, sal_Int32 nType)
ExcelVbaProject(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::sheet::XSpreadsheetDocument > &rxDocument)
virtual void prepareImport() override
Adds dummy modules for sheets without imported code name.
css::uno::Reference< css::sheet::XSpreadsheetDocument > mxDocument
OUString maPrefix
Property set of the sheet without codename.