26#include <osl/file.hxx>
27#include <com/sun/star/uno/XComponentContext.hpp>
48 ::osl::Directory aDir( rBaseURL);
50 if ( aDir.open() == ::osl::FileBase::E_None )
54 ::osl::DirectoryItem aItem;
55 while ( aDir.getNextItem( aItem ) == ::osl::FileBase::E_None )
57 ::osl::FileStatus aFileStatus( osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL );
58 if ( aItem.getFileStatus( aFileStatus ) == ::osl::FileBase::E_None )
60 if ( aFileStatus.getFileType() == ::osl::FileStatus::Directory )
61 aSubDirs.push_back( aFileStatus.getFileURL() );
63 aResult->push_back( aFileStatus.getFileURL() );
68 for (
auto const& subDir : aSubDirs)
71 aResult->insert( aResult->end(), aSubResult->begin(), aSubResult->end() );
82 if ( aResult == ::osl::FileBase::E_NOENT )
91#define MAX_HEADER_LENGTH 16
96 if ( pStream && !pStream->GetError() )
98 static const char*
const pVerOOo7 =
"OOoUserDict1";
99 sal_uInt64
const nSniffPos = pStream->Tell();
100 static std::size_t nVerOOo7Len = sal::static_int_cast< std::size_t >(strlen(
pVerOOo7 ));
102 pMagicHeader[ nVerOOo7Len ] =
'\0';
103 if (pStream->ReadBytes(
static_cast<void *
>(pMagicHeader), nVerOOo7Len) == nVerOOo7Len)
105 if ( !strcmp(pMagicHeader,
pVerOOo7) )
110 pStream->Seek (nSniffPos);
111 pStream->ReadUInt16( nLen );
114 pStream->ReadBytes(pMagicHeader, nLen);
115 pMagicHeader[nLen] =
'\0';
116 if ( !strcmp(pMagicHeader,
"WBSWG2")
117 || !strcmp(pMagicHeader,
"WBSWG5")
118 || !strcmp(pMagicHeader,
"WBSWG6") )
135 sTargetDir +=
"/user/wordbook";
137 for (
auto const& elem : *aFileList)
141 std::u16string_view sSourceLocalName = elem.subView(
m_sSourceDir.getLength() );
142 OUString sTargetName = sTargetDir + sSourceLocalName;
144 aURL.removeSegment();
146 ::osl::FileBase::RC aResult = ::osl::File::copy( elem, sTargetName );
147 if ( aResult != ::osl::FileBase::E_None )
149 SAL_WARN(
"desktop",
"WordbookMigration::copyFiles: cannot copy "
150 << elem <<
" to " << sTargetName);
157 OSL_FAIL(
"WordbookMigration::copyFiles: no user installation!" );
167 return "com.sun.star.comp.desktop.migration.Wordbooks";
179 return {
"com.sun.star.migration.Wordbooks" };
188 ::osl::MutexGuard aGuard(
m_aMutex );
192 for ( ; pIter != pEnd ; ++pIter )
194 beans::NamedValue aValue;
196 if ( aValue.Name ==
"UserData" )
200 OSL_FAIL(
"WordbookMigration::initialize: argument UserData has wrong type!" );
214 ::osl::MutexGuard aGuard(
m_aMutex );
224extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
226 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any>
const&)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
TStringVectorPtr getFiles(const OUString &rBaseURL) const
virtual ~WordbookMigration() override
void checkAndCreateDirectory(INetURLObject const &rDirURL)
virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue > &Arguments) override
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual OUString SAL_CALL getImplementationName() override
static PathStatus locateUserInstallation(OUString &_rURL)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
const char *const pVerOOo7
Sequence< PropertyValue > aArguments
#define SAL_WARN(area, stream)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
static bool IsUserWordbook(const OUString &rFile)
std::vector< OUString > TStringVector
std::unique_ptr< TStringVector > TStringVectorPtr
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * desktop_WordbookMigration_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
#define MAX_HEADER_LENGTH