1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: copyeditiondata.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #define _WIN32_WINDOWS 0x0410
38 #pragma warning(push, 1) /* disable warnings within system headers */
39 #define WIN32_LEAN_AND_MEAN
54 #define _tstring wstring
56 #define _tstring string
62 static std::_tstring
GetMsiProperty( MSIHANDLE handle
, const std::_tstring
& sProperty
)
65 TCHAR szDummy
[1] = TEXT("");
68 if ( MsiGetProperty( handle
, sProperty
.c_str(), szDummy
, &nChars
) == ERROR_MORE_DATA
)
70 DWORD nBytes
= ++nChars
* sizeof(TCHAR
);
71 LPTSTR buffer
= reinterpret_cast<LPTSTR
>(_alloca(nBytes
));
72 ZeroMemory( buffer
, nBytes
);
73 MsiGetProperty(handle
, sProperty
.c_str(), buffer
, &nChars
);
80 extern "C" UINT __stdcall
copyExtensionData(MSIHANDLE handle
) {
82 std::_tstring sSourceDir
= GetMsiProperty( handle
, TEXT("SourceDir") );
83 std::_tstring sExtensionDir
= sSourceDir
+ TEXT("extension\\");
84 std::_tstring sPattern
= sExtensionDir
+ TEXT("*.oxt");
85 // std::_tstring mystr;
87 // Finding all oxt files in sExtensionDir
89 WIN32_FIND_DATA aFindFileData
;
91 HANDLE hFindOxt
= FindFirstFile( sPattern
.c_str(), &aFindFileData
);
93 if ( hFindOxt
!= INVALID_HANDLE_VALUE
)
95 bool fNextFile
= false;
97 bool bFailIfExist
= true;
99 std::_tstring sDestDir
= GetMsiProperty( handle
, TEXT("OFFICEINSTALLLOCATION") );
100 std::_tstring sShareInstallDir
= sDestDir
+ TEXT("share\\extension\\install\\");
102 // creating directories
103 std::_tstring sShareDir
= sDestDir
+ TEXT("share");
104 std::_tstring sExtDir
= sShareDir
+ TEXT("\\extension");
105 std::_tstring sExtInstDir
= sExtDir
+ TEXT("\\install");
106 bool bDir
= CreateDirectory(sShareDir
.c_str(), NULL
);
107 bDir
= CreateDirectory(sExtDir
.c_str(), NULL
);
108 bDir
= CreateDirectory(sExtInstDir
.c_str(), NULL
);
112 std::_tstring sOxtFile
= aFindFileData
.cFileName
;
114 std::_tstring sSourceFile
= sExtensionDir
+ sOxtFile
;
115 std::_tstring sDestFile
= sShareInstallDir
+ sOxtFile
;
117 fSuccess
= CopyFile( sSourceFile
.c_str(), sDestFile
.c_str(), bFailIfExist
);
119 fNextFile
= FindNextFile( hFindOxt
, &aFindFileData
);
121 } while ( fNextFile
);
123 FindClose( hFindOxt
);
126 return ERROR_SUCCESS
;